Open decaby7e opened 6 years ago
This would indeed be cool to implement, however I expect it was already a planned feature for @calc84maniac. I would not expect results soon, however.
I know, right? USB is still being documented for the CE, so I guess we'll have to wait and see!
If this is implemented, it'd make the CE basically into a GameBoy 😝 .
Still leaves out sound. Nothing we can do about that.
USB audio is being implemented (earlier than linking anyway)
That's amazing.
If speed is not an issue, it may be possible to use the calculator's built in Send
and Get
. I'm no GameBoy developer but according to https://gbdev.gg8.se/wiki/articles/Serial_Data_Transfer_(Link_Cable) it's very likely that the process could look sort of like this:
A: 127 -> TIBoyLink1 // Equivalent of GB A storing 0x7F to SB
B: Get (TIBoyLink1) // Equivalent of GB B storing 0x80 to SC
A: Send(TIBoyLink1) // Equivalent of GB A storing 0x81 to SC
// GB B now has received TIBoyLink1
B: Send(TIBoyLink2) // GB B's return transfer
A: Get (TIBoyLink2) // GB A receives whatever GB B had in SB
// GB A and GB B have stored TIBoyLink2 and
// TIBoyLink1 respectively into their SBs
in a case where GB A wanted to send a 0x7F
byte and GB B was just receiving.
It might happen that GB B hasn't marked 0x80
to SC (explained in the above document) and is only checking for changes in SB. This means that it will not be explicitly looking for link transfers. As an effect, TI A might be Send(
ing and never have a Get(
to send to on TI B (as it is not explicitly looking for one).
Alternatively, it might happen that GB A marks 0x81
to SC and TI A doesn't find another calculator to Send(
to. Send(
doesn't have a timeout, only Get(
, so these calls would have to somehow execute asynchronously.
The tricky part is making the game recognize it as a linkup between the two calcs when it is looking for another gameboy.
Not really. Theoretically, TI Boy CE looks if the Game Boy is asking for a link, and if it is, asks for a calculator. That's as simple as checking when values are changed in SC and calling the appropriate calculator function. Game Boy linking is nothing more than a serial transmission; sending bits in and out.
The only difference I could foresee (unless the transmission should be 8 times slower) is that TI Boy CE would transmit the entire byte in and out of SB instead of bits at a time. Unless a game is specifically checking for this functionality (which makes no sense outside of anti-emulation purposes) this should not be any issue.
The lack of a serial port on the CE makes transmitting data that should be, well, serial, a much harder process than for other calculators.
For the record, it's not even remotely that simple because OS code (particularly interrupts) won't even run properly during TI Boy CE emulation due to the many cool tricks being used to make emulation fast. In any case, GetCalc
takes over 1.5 seconds for some reason so you won't get anywhere close to the expected 8Kb/s transfer rate. Luckily, the Universal Serial Bus hardware is well enough understood that it is actually simpler to use it directly than to try to go through OS routines, so the only issue is getting the time and/or motivation to actually implement everything.
Ah, ok. Makes sense. I didn't know what the lower bound on sending and getting data via those functions was.
How would I go about helping document the calculator's USB stuff?
You could look at all the USB stuff in here: https://github.com/CE-Programming/CEmu/tree/usb-host and here: https://github.com/CE-Programming/toolchain/tree/usbdrvce and see if you can find out anything else - but it's not an easy task :P
Interesting that there's plenty of code for the USB but very little documentation of it. I'm pretty busy this week but having link battles in Pokemon Red on calculators is something I want to see, so I'll work on it when I can.
Is there enough in the toolchain (on that branch at least) to get started on something in TI Boy CE? Or does more work need to be done on usbdrvce?
This may help for serial and sound: https://github.com/commandblockguy/CE-serial https://github.com/MCJack123/ticesnd Cheers
Any updates on this?
Nothing substantial. I've done a little bit of experimentation with linking in a standalone program and didn't get very promising results with regard to communication latency, which means maybe I'll have to experiment more. Maybe after I make the next release, I can start trying to implement something in TI-Boy even if it's going to end up slow at first.
Would it be easier to create something that allows trading between games? Like for instance the ability to use Time Machine thing in Pokemon silver and switch games to pokemon red and trade with yourself?
I don't think so, that would require emulating two Game Boys at the same time and the emulator core wasn't designed to do that (and there's likely not enough RAM in the calculator to be able to do so). The best way for now to do trading is to transfer your save data to PC, do the trade in a PC emulator, and transfer the save data back to the calculator.
oh... which emulator should I use? because none seem to accept .sav files...
I'm not sure if this would be fairly simple or enormously difficult to implement, but it would be awesome for games like Pokémon where calculators can be linked together for trading and what not.