gb-asm-tutorial
gb-asm-tutorial copied to clipboard
Part 2 serial IO lesson
This PR adds a lesson on the serial port to resolve #42.
Still a draft because the lesson text needs to be updated.
About the implementation:
Sio (sio.asm) is a kind of multi-byte version of the underlying GB serial API.
- implements the timeout for the externally clocked device
- implements the clock provider's "catchup delay"
- a data integrity test for received packets is included, using a rather simple checksum
main.asm is based on the BCD unbricked code.
- each peer sends its current score to the other and the remote peer's score is displayed below the local one.
- an initial handshake is performed to establish the connection (automatically determines the clock provider)
- there's no attempt made to guarantee delivery of packets but if a corrupt or non-sequential packet arrives, the connection is terminated.
- To build it you just need to compile and link both main.asm and sio.asm.
demo.asm is a standalone test rom I used to test and debug the serial transfer implementation. It isn't part of the lesson and can be removed if necessary, but it provides more debug information than the integration with unbricked.
The code has been updated a bit. I updated the PR comment to reflect the changes. I don't think there are any glaring holes in the implementation and it works consistently in my simple test program. (so I need to improve the test!)
I'm not sure how this should be integrated with the unbricked code, or if I need to provide something more significant for testing purposes?
I didn't want to add test code to this repo, so I've been working on the impl in a standalone project (https://github.com/quinnyo/gbserial). sio.asm in this PR should be the same as in that repo at time of writing.
The current program is a simple test where the two devices yell at each other. You first need to press START to toggle clock source on one GB. You get a tick if the checksum of the received packet checks OK, F for uhh, "big Fail" (timed out / incomplete packet). The relevant test bits are in sio_demo.asm.
The code has been updated a bit. I updated the PR comment to reflect the changes. I don't think there are any glaring holes in the implementation and it works consistently in my simple test program. (so I need to improve the test!)
I'm not sure how this should be integrated with the unbricked code, or if I need to provide something more significant for testing purposes?
I didn't want to add test code to this repo, so I've been working on the impl in a standalone project (https://github.com/quinnyo/gbserial).
sio.asmin this PR should be the same as in that repo at time of writing. The current program is a simple test where the two devices yell at each other. You first need to press START to toggle clock source on one GB. You get a tick if the checksum of the received packet checks OK,Ffor uhh, "big Fail" (timed out / incomplete packet). The relevant test bits are insio_demo.asm.
Not sure about more significant testing, but I'd start thinking about how to integrate it in Ubricked for the simple "share high scores" case (although I really like @eievui5 idea here, maybe for a further improvement).
Maybe start the paragraph explaining sio.asm then hooking the "share high score" routine when e.g. pressing select on the game over screen?
To be honest, I don't think having an independent, standalone ROM only to showcase the serial feature is a bad idea, so I'd merge that as well.