Author Topic: How to use the link port  (Read 10370 times)

0 Members and 1 Guest are viewing this topic.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
How to use the link port
« on: January 03, 2012, 09:53:42 am »
Hi guys !

I try to make a little link port test with two balls which are moved with the arrows of the other calc. But when I push a key on each calc, the balls don't move.

Why ?

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4684
  • Rating: +718/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: How to use the link port
« Reply #1 on: January 03, 2012, 09:57:56 am »
Could you post a some of your code? I imagine if you are only using arrows, you will only need to send 4 bits, too, if that helps :) We might be able to help out!

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: How to use the link port
« Reply #2 on: January 03, 2012, 12:29:33 pm »
Now, no bug when I push a key on each calc, but only one white ball moves (on each calc, there is a black balle moved by the calc and a white ball moved by the other calc).

Code: [Select]
.MULTI

ClrHome
ClrDraw
ClrDrawr

0→A→C→D→X→Y
56→B

[3C7EFFFFFFFFFF7E3C→Pic1J1
[3C428181818181423C→Pic1J2

Repeat getkey(15)
 If getkey(2) and (X>0)
  X--
  1→C
 ElseIf getkey(3) and (X<88)
  X++
  2→C
 Else
  0→C
 End

 sub(GET)
 Send(C,500)
 sub(GET)

 DispGraphrClrDraw

End

ClrHome
ClrDraw

Lbl GET
Get→D
If D=1
 A--
ElseIf D=2
 A++
End
Pt-Off(X,Y,Pic1J1
Pt-Off(A,B,Pic1J2
Return

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: How to use the link port
« Reply #3 on: January 03, 2012, 01:25:34 pm »
Ooooh i love two player games! I hope thats what your going to make! Although good calc gamers are hard to fin at my school :P good luck!
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: How to use the link port
« Reply #4 on: January 03, 2012, 01:27:42 pm »
isn't it just because you store the value for both calcs in D ?
when you do that, the sent and gotten value are the same, since it's D for both calcs, get it?
i might be wrong :w00t:

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: How to use the link port
« Reply #5 on: January 03, 2012, 02:51:04 pm »
@saintrunner yes, that's what I'm trying to do :)

@Nick it's not that, because variables of each calc are undependant, I believe.

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: How to use the link port
« Reply #6 on: January 03, 2012, 02:52:56 pm »
OOOH! What type of game?
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: How to use the link port
« Reply #7 on: January 03, 2012, 04:16:27 pm »
I don't know right now ; I'll first practice a bit with the link port, and after that make a big game. Coming soon ;) (if I can resolve the current problem ;D )

Offline kindermoumoute

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 836
  • Rating: +54/-3
    • View Profile
Re: How to use the link port
« Reply #8 on: January 06, 2012, 03:10:46 pm »
Ok, the fact : I looked around the forum about link command, but I saw nowhere a complete code that used the port link so improved.
So today I worked on it.

My technique is initially to define a calculator server and a calculator client, in Boolean it mean 1 and 0. To specify if the calculator is server or client, I do it more or less randomly, because for the rest of the program I don't mind the order.
Code: [Select]
:.r1 is the number of swap you want to try it work, ussualy 10 is same than 200
:Lbl SYN
:Output(0,,"Synchronisation ...
:0→r2
:Repeat r2>r1 or getKey(15)
:If Get+1
:→r2
:End
:Send(r2,100)
:End
:Returnr2^2
Now we have a server (0) and a client (1), and the first application is to separate server code and client code :
Code: [Select]
!If B
:SRV()
:Else
:CLT()
:End
My first idea was to make a program where the server send and the client get each loop, here a funny example :
Code: [Select]
:.AXE
:[183C7EFFFF7E3C18]→Pic1
:0→X
:ClrHome
:SYN(200)→B
:Repeat getKey(15) or (B>1
:!If B
:SRV()
:Else
:CLT()
:End
:DispGraphClrDraw
:End
:Return

:.Program host
:Lbl SRV
:If X<96
:Pt-On(X,48,Pic1
:End
:X<192?X++,→X
:Send(X,5000)
:Return

:.Program client
:Lbl CLT
:If X>95
:Pt-On(X-96,48,Pic1
:End
:If Get+1:-1→X:End
:Return

NB : With real calculator there isn't this speed lag, here it's cause of wabbitemu mistake.

Now I thought about a way to send multiple bytes in both directions (for games such as Battleship, Chess, pokemon, and thousands more). My first solution is a system of roundtrip between server and client, after synchronizing calcs.
Code: [Select]
:.r1 ==> number of bytes to send
:Lbl ECH
:SYN(10)
:For(I,0,r1)
:!If B
:Send({L1+I},5000)
:GET()→{L2+I}
:Else
:GET()→{L2+I}
:Send({L1+I},10000)
:End
:End
:Return
:
:Lbl GET
:Repeat Get+1→r2
:If getKey(15)
:Goto ERR
:.ERR routine just leave program
:End
:End
:Returnr2-1
And it work perfectly, but I find this routine not very optimized, so I decided to try another way by sending all at once to the server, then to the client... to be continued.  :thumbsup:

PS : I can't test my code for the moment because of wabbitemu' mistakes...
Projects :

Worms armageddon z80 :
- smoothscrolling Pixelmapping : 100%
- Map editor : 80%
- Game System : 0%

Tutoriel français sur l'Axe Parser
- 1ère partie : en ligne.
- 2ème partie : en ligne.
- 3ème partie : en ligne.
- 4ème partie : 10%
- Annexe : 100%

Offline kindermoumoute

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 836
  • Rating: +54/-3
    • View Profile
Re: How to use the link port
« Reply #9 on: February 08, 2012, 04:12:35 pm »
I appeal to experts to advise me about the best way to exchange bytes between 2 calcs. Actually the main problem is that link command are bugged : I always loss of bytes with a constant percentage (2~10% according to the calculator). How can we fix and optimize it? :w00t:


I have attached a program that exchange 20 bytes, and then calculates the sum of received values​​: it should display 190. Try it with real calc please.
« Last Edit: February 08, 2012, 04:12:52 pm by kindermoumoute »
Projects :

Worms armageddon z80 :
- smoothscrolling Pixelmapping : 100%
- Map editor : 80%
- Game System : 0%

Tutoriel français sur l'Axe Parser
- 1ère partie : en ligne.
- 2ème partie : en ligne.
- 3ème partie : en ligne.
- 4ème partie : 10%
- Annexe : 100%

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4684
  • Rating: +718/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: How to use the link port
« Reply #10 on: February 08, 2012, 04:27:11 pm »
Do I send the program to both calcs and then run the program on both?

EDIT: I tried it 10 times on each calculator and they said 190 each time. Also, I even have a bad cord and it worked! +1 :D

EDIT2: If I can figure out how this code works, can I use it in Grammer? (My link protocol does not work for synchronising and whatnot :/)

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: How to use the link port
« Reply #11 on: February 08, 2012, 10:15:54 pm »
Maybe the problem is that you left Interrupts on?  Interrupts should be off or custom when using the link port otherwise the OS might decide to alter the ports in the middle of the linking.  Try adding an FnOff at the beginning of your program.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline kindermoumoute

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 836
  • Rating: +54/-3
    • View Profile
Re: How to use the link port
« Reply #12 on: February 09, 2012, 12:37:49 pm »
I tried it 10 times on each calculator and they said 190 each time. Also, I even have a bad cord and it worked! +1 :D
Really ? O_o
Ok Quigibo, I'll try it tomorrow.
Projects :

Worms armageddon z80 :
- smoothscrolling Pixelmapping : 100%
- Map editor : 80%
- Game System : 0%

Tutoriel français sur l'Axe Parser
- 1ère partie : en ligne.
- 2ème partie : en ligne.
- 3ème partie : en ligne.
- 4ème partie : 10%
- Annexe : 100%

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4684
  • Rating: +718/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: How to use the link port
« Reply #13 on: February 09, 2012, 02:15:02 pm »
Yes and I found that if I pressed clear while it was still synchronizing it returned 20 every time (on either calculator).

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: How to use the link port
« Reply #14 on: February 09, 2012, 04:46:31 pm »
wish youwould have told me that months ago Quigibo....
awesome
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________