Page 1 of 2

[TI Basic] How to make link games in basic

Posted: Sat 14 Oct, 2006 12:24 pm
by Gert-Jan
Hi, i just tried making a little link-game in basic, but it seems there is some kind of bug in the linking system.
Just try this
Calc 1:
While 1
1->A
End

Calc 2:
0->A
While 1
Get(A)
Disp A
End


What you will see is that calc 2 displays all the time 0, and doesnt get the A from calc one. Is there any way to solve this? or do i have to call for little ASM-progs in my basic prog, that do the linking for me?

Posted: Sat 14 Oct, 2006 1:13 pm
by threefingeredguy
I was under the impression that Get and Send were used for CBR/CBL apps. GetCalc ought to work.

Posted: Sat 14 Oct, 2006 2:01 pm
by Gert-Jan
no, i tried it, still doesnt work.

Posted: Sat 14 Oct, 2006 4:35 pm
by leofox
Getcalc only works if the other calc is in idle mode (homescreen or input/prompt)

Posted: Sat 14 Oct, 2006 4:57 pm
by King Harold
leofox wrote:Getcalc only works if the other calc is in idle mode (homescreen or input/prompt)
That's probebly the most annoying thing in BASIC.
If the other calc is doing anything at all (and it usually is in games) it will fail.

so gert-jan you'll have to use ZCOM or any other asm program that will do the linking for you, or be creative and use omnicalcs LinkGet( and LinkSend( to send 1 byte at a time. (this really isn't the fastest way, but when you only have to send values between 0 and 255 it might be a good idea)

Posted: Sat 14 Oct, 2006 5:19 pm
by Saibot84
actually, i believe executing a "Pause" on one calc is enough for it to be considered in "idle" mode... so you will have to "Pause" in order for the calc to be able to send any data to the other calc

Posted: Sat 14 Oct, 2006 5:40 pm
by King Harold
That isn't practical in games though. Actually it isn't practical anywhere (well except some sort of BASIC file transfer programs)

Posted: Sat 14 Oct, 2006 7:08 pm
by Gert-Jan
ye, that isnt possible in games then, what should be the best solution?

Posted: Sat 14 Oct, 2006 7:42 pm
by King Harold
CLAP, ZCOM, usb8x, or even the Omnicalc sendbyte if you only have to send a few bytes anyway

Posted: Sat 14 Oct, 2006 8:20 pm
by Gert-Jan
ok, will try this in the morning. TY

Posted: Sat 14 Oct, 2006 11:12 pm
by kv83
I'm moving this to Programming Help, since that's where it belongs.

Posted: Sun 15 Oct, 2006 7:13 am
by Gert-Jan
ok, sry, didn't know i putted it wrong

Posted: Sun 15 Oct, 2006 11:11 am
by Timendus
Easiest way is to use something like this in your game loop:

Code: Select all

"SWAP A BYTE IN B BETWEEN 2 CALCS
"EXPECTS CALC# IN A
If A=1
Then
B->W
1->V
Asm(prgmZCLAP
0->V
Asm(prgmZCLAP
W->B
Else
0->V
Asm(prgmZCLAP
B->V
W->B
V->W
1->V
Asm(prgmZCLAP
End
Return
Haven't tested this, but it's the theory that counts, not the implementation :)

Posted: Sun 15 Oct, 2006 11:01 pm
by Dwedit
Getcalc works if the other calc is at a Pause command, then it resumes the other calc.

Posted: Mon 16 Oct, 2006 12:57 pm
by thegamefreak0134
I have a nice little tutorial for calc linking, sort of. I lost it and the link, but it basically shows a nice loop between the two where you do nothing on one and it still sends the data. Whenever you getcalc on one calc, if the other is in pause mode and it sends the data, ut un-pauses (resumes as mentioned above) and continues on it's merry way. Think of this as a "wait to send my data" sort of thing. My theorey has always been to send a byte, then get a "confirmation" byte from the other end to make sure the data was recieved.

I also hear that the 83+SE and 84+SE have issues with the link port, unconfirmed of course. Anyone else know of this?