Closed cyberic99 closed 5 years ago
Sorry for the late response, got caught up over the past week.
Anyway, the serial port protocol for GBE+ is relatively simple for DMG/GBC communications. GBE+ expects to receive 2 bytes for each TCP transfer. The 1st byte is whatever data you want to send to GBE+. For serial I/O, the 1st byte is basically the 8-bit value shifted out via the Link Cable (the value of 0xFF01 aka SB). The 2nd byte specifies a command (if any) for GBE+ to process. Commands are limited and optional. They are:
0xFF - Stop Hard Sync - When "hard syncing" is enabled, GBE+ only runs for ~64 cycles (by default, but this is changeable via gbe.ini), then waits for this command. For netplay, this was intended to keep one instance of GBE+ from running faster than another and desyncing. It may be useful if GBE+ happens to run faster than something like the arduinoboy can handle. GBE+ basically pauses until it receives this command when hard syncing is enabled, so the aruinoboy would need to periodically send the bytes 0x00, 0xFF to tell GBE+ to continue emulation. Note that the 1st byte sent is completely ignored by GBE+.
0x80 - Disconnect Netplay - Tells GBE+ that netplay (and therefore all network communications) have been terminated by the sender. Again, the 1st byte is completely ignored, so the full command would look something like 0x00, 0x80.
Whenever GBE+ sends the 8-bit value for SB, it pauses (regardless if hard sync is enabled or not) until it receives a response. It expects the sender to give it a new value for SB. This is where GBE+ emulates the Game Boy completing a serial data transfer, where the two sides exchange 1 byte of data. During this transfer, there should be no commands used, just put the raw data into the 1st byte of the transfer like 0xAB, 0x00, where 0xAB is what you want to send to GBE+.
Basic communication flow would look something like this (assuming hard sync is on):
For more details, see https://github.com/shonumi/gbe-plus/blob/master/src/dmg/sio.cpp
OK, thanks a lot!
Hello
Is there a way to emulate a device plugged on the serial port, like the arduinoboy (https://github.com/trash80/Arduinoboy), via TCP/IP?
If the serial network protocol documented somewhere?
Thank you