Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Part 2 serial IO lesson #88

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

Conversation

quinnyo
Copy link
Contributor

@quinnyo quinnyo commented Apr 27, 2024

This is an early draft PR for the lesson/features discussed in #42. Currently this PR includes only the core serial implementation (sio.asm) and it is not integrated with any other code. There is no included way to build a demo/test here, but you can venture to my gbserial repo where I've been developing/testing this if you like. See comment below for more information on that.

A few questions and things I'm not sure of:

  1. I'm not sure about integrating this with the existing unbricked code. Other than the lack of actual score data, where does it go? How does the score sharing feature get started?
  2. I think using the serial interrupt here would be the first use/mention of interrupts (in reading order). Thoughts?

About the implementation:
Sio (sio.asm) is a kind of multi-byte version of the underlying GB serial API.
Buffers are provided for data in and out. Using SioTransferStart will transfer the whole buffer. Smaller batches are possible but don't have a nice way to start them.
Each byte transfer after the first is started from the serial interrupt.
The clock provider's "catchup delay" is implemented as a simple "sleep" loop executed before every byte transfer. The duration of this can be tuned.
SioTick is to be called regularly -- per-frame. This is most necessary to update the timeout timer for devices using the external clock source. The duration of the timeout is in "ticks" (calls to SioTick).
A simple data integrity test is implemented with the SioPacket functions. This takes the first two bytes of the buffer for a magic number and simple checksum. Sio itself doesn't do anything to handle the result of this test, it's expected that the controlling context (the app-specific protocol) will deal with it.

; :: / `--<[|]= |[ m ]|| ::
; :: \ .______ | ```` || ::
; :: / !| `````| | + oo|| ::
; :: ( ||[ ^u^]| | .. #|| ::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this!

unbricked/serial-link/sio.asm Outdated Show resolved Hide resolved
@quinnyo quinnyo force-pushed the part2pointserial branch from add7190 to 0352ed2 Compare May 9, 2024 17:34
@quinnyo quinnyo force-pushed the part2pointserial branch from 0352ed2 to 3a0e30d Compare June 26, 2024 22:23
@quinnyo quinnyo force-pushed the part2pointserial branch from 3a0e30d to 431baff Compare June 26, 2024 22:31
@quinnyo
Copy link
Contributor Author

quinnyo commented Jun 28, 2024

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.

@avivace avivace requested a review from Rangi42 July 7, 2024 19:32
@avivace
Copy link
Member

avivace commented Jul 12, 2024

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.

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.

quinnyo added 3 commits July 22, 2024 09:04
- work-in-progress lesson text
- most of core impl covered
- sio.asm: anchors and minor changes for tutorial friendliness
@avivace avivace requested a review from ISSOtm August 23, 2024 17:38
…dged by ID.

- errors: packet check failed, invalid message type
- display error counts
- tidier display layout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants