Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: matthias1992 on September 11, 2010, 01:32:35 pm

Title: USB Linking.
Post by: matthias1992 on September 11, 2010, 01:32:35 pm
Ok so recently a friend of mine and I tried some multiplayer games for the TI84+ series, guess whata, out of 5 tried games 0 worked! This is why we came up with the idea for a small asm library that we could use to make our own bomberman two-calc multiplayer game. however I can't find any info about sending info from one calc to another via the miniusb.

I intend on having the following commands available:

SendMode (sets a calculator ready for sending stuff, it will pause the program until one (one exactly) request is completed)
Syntax: {3}
requests:

ReqReal Requests a real variable from the other calc, the other calc has to be in SendMode!
Syntax: {4,#} #= any number from 1 to 26, 1=A, 2=B...26=Z (theta not supported)

ReqStr Requests a string variable from the other calc, the other calc has to be in SendMode!
Syntax: {5,#} #= any number from 0 to 9, 0=Str0, 1=Str1...9=Str9

ReqMtrx Requests a matrix variable from the other calc, the other calc has to be in SendMode!
Syntax: {6,#} #= any number from 1 to 10, 1=A, 2=B...10=J

ReqBuf Requests the screen buffer (basically what is on the screen on the sending calc) from the sending calc and draws it onto the screen of the requesting calc, the other calc has to be in SendMode!
Syntax: {7}

So can anybody give me some pointers on this? so far I ahve only found guides on how to link between a calc and a PC but not between two calcs...
Title: Re: USB Linking.
Post by: DJ Omnimaga on September 11, 2010, 01:47:17 pm
Yeah, the issue with most of those games is that they came out before 15 MHz TI calcs existed, so most have broken linking on them. It would be cool to have USB linking. However, the games wouldn't be 83+ compatible, then.

In S.A.D case, I think one calc waits info from the other and to get told it received it, then does the same back, then back and forth.
Title: Re: USB Linking.
Post by: calcdude84se on September 11, 2010, 02:56:22 pm
I wish you luck, especially given the sparse documentation. You'd probably be best off looking at http://wikiti.brandonw.net/index.php?title=Category:83Plus:Ports:By_Address (http://wikiti.brandonw.net/index.php?title=Category:83Plus:Ports:By_Address) and http://wikiti.brandonw.net/index.php?title=83Plus:OS:84_Plus_USB_Information (http://wikiti.brandonw.net/index.php?title=83Plus:OS:84_Plus_USB_Information), not to mention existing code that uses USB.
Good luck! :D
Title: Re: USB Linking.
Post by: Builderboy on September 11, 2010, 03:03:56 pm
My question is, why are you sing the usb instead of the I/O cable?  All 84-83 series have an Io Port, so you have comparability, and the usb is crazy hard to manipulate if i remember correctly?  That being said, however, we have been lacking in usb multiplayer games, and there are a lot of people out there with only usb cables, so it might be to their advantage... hmmm
Title: Re: USB Linking.
Post by: calcdude84se on September 11, 2010, 03:43:17 pm
Most likely because 84+(SE)'s don't come with an I/O cable ;D
Title: Re: USB Linking.
Post by: Builderboy on September 11, 2010, 03:47:41 pm
Ahhhhhh yes that would be the reason.  I still wonder why TI put IO ports on the 84's but didnt supply an IO cable? o.O Either way, i hope USB can match the speed of IO!
Title: Re: USB Linking.
Post by: calcdude84se on September 11, 2010, 03:50:54 pm
I would assume for 83+(SE) compatibility :P
Yeah, I hope the speed can be comparable.
Title: Re: USB Linking.
Post by: BrandonW on September 11, 2010, 03:51:43 pm
There's some (admittedly old) code at http://brandonw.net/calcstuff/remote8x.zip that shows how to quickly talk back and forth between two calculators connected via direct USB. It does too much stuff between transfers so it's dog slow, but you get the idea.
Title: Re: USB Linking.
Post by: calcdude84se on September 11, 2010, 04:03:26 pm
Do you have any example code (or does anyone) of how to act as a peripheral, since one device would be host and the other would have to be control?
Good idea to link to Remote8x, though. :D
Title: Re: USB Linking.
Post by: matthias1992 on September 11, 2010, 04:06:34 pm
thanks all!

I had to 0x5 because I now understand why 0 of these games worked, we were trying them over USB, not over the IO port! Gosh that is stupid of me....It does solve the mistery though...

From the sparse information that I read it can be pretty fast up to 4KB a sec I think (I read that somewhere). Also whoever has tried to send a program from calc 1 to calc 2 over the USB will notice that it goes pretty fast. From PC->calc and vice versa is quite slow but that is because there is a whole interface and handshaking process involved which takes quite some time. Indeed this will be 84+ exclusive...

I'll think that I will release a library then with source to make USB link gaming more...ehr...available...
unless it is depressingly slow of course because then it wouldn't be really worth the effort.
Title: Re: USB Linking.
Post by: BrandonW on September 11, 2010, 04:10:14 pm
Do you have any example code (or does anyone) of how to act as a peripheral, since one device would be host and the other would have to be control?
Good idea to link to Remote8x, though. :D

Yeah, I just did link to the example code. The TI-OS will deal with who is host and who is peripheral through HNP (Host Negotiation Protocol) and make sure power is supplied to the port. You don't need to concern yourself with it.

If you mean truly act as an independent USB peripheral (like a USB keyboard, mouse, PS3 jailbreak stick, etc.), then look at periph8x at http://brandonw.net/svn/calcstuff/periph8x/trunk/ or http://brandonw.net/svn/calcstuff/PS3JB/trunk/
Title: Re: USB Linking.
Post by: matthias1992 on September 11, 2010, 04:23:14 pm
Code: [Select]
SendUSBData:
;Sends data over USB.
;Inputs:        HL => pointer in zone 1 (RAM pages 3\2) of data to send.
;               DE: number of bytes to send.
;Outputs:       DE bytes sent from HL.
;               Carry flag set if any issues.
SendUSBData:
        res 0,(iy+43h)
        bcall(50F2h)
        res 0,(iy+41h)
        res 5,(iy+41h)
        ret
what do you mean with this: "zone 1 (RAM pages 3\2)" especially the 3\2 part...
could you maybe give me a example with the Basic TI-OS variable 'A' (a ti-os real variable is 9 bytes right?) being send? (I think I understand the receiving code...) Thanks!
Title: Re: USB Linking.
Post by: BrandonW on September 11, 2010, 04:47:02 pm
Sending REAL variables is a lot more complicated, I don't have time to type up such an example. remote8x shows the direct USB link protocol that the OS uses to send and receive OS variables, and there's a text document out there ("DirectUSB.txt") somewhere that documents the entire thing fully.

"Zone 1" is just a convention I use to talk about the extra RAM pages. In the last two banks are usually RAM pages 1 and 0 (or "1\0"), which I consider zone 0.
Zone 1 is RAM pages 3 and 2.
Zone 2 is RAM pages 5 and 4.
Zone 3 is RAM pages 7 and 6.
Title: Re: USB Linking.
Post by: matthias1992 on September 11, 2010, 04:49:02 pm
Thanks! I understand it is a lot of work, I'll be looking for that file and link to it here if I find it..might be usefull to others as well...

edit:
Benjamin, mysterious as ever hehe...I now see that you were ironic about a DirectUSB.txt file being "somewhere" hehe. So that is your way to say 'Google is your friend' eh? well, yeah it is and I have skimmed trough your file before but I clearly must have misunderstood it because I thought it was 'bout calc>PC and vice versa, not calc-to-calc connection...

btw for anyone who needs it, here is the file: http://www.brandonw.org/calcstuff/DirectUSB.txt (just my way of saying BrandonW's cryptic references aren't as good as google :P)
Title: Re: USB Linking.
Post by: jnesselr on September 11, 2010, 05:06:31 pm
Isn't that for calc<->PC?
Title: Re: USB Linking.
Post by: matthias1992 on September 11, 2010, 05:09:10 pm
Isn't that for calc<->PC?
That is what I thought too, so I did see it properly? I am getting confused...
/me continues to study DirectUSB.txt
--------------------------------------------------------------------------------------------
All collected info thus far (thanks to brandonW):
http://www.brandonw.org/calcstuff/DirectUSB.txt
http://www.ticalc.org/archives/files/fileinfo/368/36828.html
--------------------------------------------------------------------------------------------
I made a small change here because the other link I listed turns out to be the same file...I was in the bad habit of not checking it first, sorry...