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

Serial Transfer to share High Scores in Part 2 #42

Open
leinacc opened this issue Jan 14, 2023 · 12 comments
Open

Serial Transfer to share High Scores in Part 2 #42

leinacc opened this issue Jan 14, 2023 · 12 comments

Comments

@leinacc
Copy link
Contributor

leinacc commented Jan 14, 2023

This lesson will introduce how to work with the 2 serial registers SB (0xff01) and SC (0xff02) in order to get a variety of multiplayer capability in the game.

  1. Basic sending and receiving of a byte
  2. Comms code considerations depending on if the current GB is master/slave, and how they would keep each other synced
  3. Timeouts to ensure that the communication doesn't just hang

As a starting use case, this code should be used to add a very simple multiplayer feature to Part 2: share the saved high scores between different Game Boys.

Note

When trying to transfer a bit when the other GB isn't connected, the bit received is 1. I don't think that's documented anywhere?

@eievui5
Copy link
Contributor

eievui5 commented Jan 14, 2023

I think this would be simple enough. We could have a “versus” mode where by doing well one player could send ships over to the other side like in some versions of Tetris. Both systems could also trade high scores when linked.

@ISSOtm

This comment was marked as off-topic.

@eievui5

This comment was marked as off-topic.

@ISSOtm

This comment was marked as off-topic.

@zlago

This comment was marked as off-topic.

@avivace avivace changed the title Part III, Serial Transfer Lesson Serial Transfer Lesson Mar 5, 2024
@avivace avivace pinned this issue Mar 5, 2024
@avivace avivace changed the title Serial Transfer Lesson Serial Transfer Lesson to share High Scores Mar 5, 2024
@avivace avivace changed the title Serial Transfer Lesson to share High Scores Serial Transfer to share High Scores Mar 5, 2024
@ISSOtm ISSOtm changed the title Serial Transfer to share High Scores Serial Transfer to share High Scores in Unbricked Mar 5, 2024
@avivace avivace changed the title Serial Transfer to share High Scores in Unbricked Serial Transfer to share High Scores to Part 2 Mar 5, 2024
@avivace avivace changed the title Serial Transfer to share High Scores to Part 2 Serial Transfer to share High Scores in Part 2 Mar 5, 2024
@avivace
Copy link
Sponsor Member

avivace commented Mar 5, 2024

@quinnyo maybe you're interested in this?

@quinnyo
Copy link
Contributor

quinnyo commented Mar 6, 2024

Yes, I'm keen to have a go at this.

To clarify the scope, let me know if I've got this right:

  • I'd be writing the prose and implementation/code to go with it
  • The code will be used to support the high score sharing feature (at least), but
  • this lesson is only concerned with the serial data transfer itself, not e.g. the high scores themselves or logic behind sharing/trading high scores

Also, maybe I'm missing something, but it looks like the score keeping for Part 2 hasn't been implemented yet?

@XoToM
Copy link

XoToM commented Mar 6, 2024

I've been slowly trying to crack this as well, but I don't have much experience with serial transfers...

Also, maybe I'm missing something, but it looks like the score keeping for Part 2 hasn't been implemented yet?

From what I've read this is most likely going to be implemented somewhere in #39

@avivace
Copy link
Sponsor Member

avivace commented Mar 7, 2024

I've been slowly trying to crack this as well, but I don't have much experience with serial transfers...

Also, maybe I'm missing something, but it looks like the score keeping for Part 2 hasn't been implemented yet?

From what I've read this is most likely going to be implemented somewhere in #39

I think that was the idea (to leave it to exercise to the reader) but I think it would be better at this point to leave #39 to focus on "introducing separate "scenes", and the transitions between them" while a proper score system can be presented in another lesson. I created #82 about that.

It also looks like a scoring system would require first some basic notions about rendering decimals etc so that could be a separate task as well, as suggested by @XoToM in #81.

In parallel, this task (Serial Transfer) can now give those details for granted and just "expect" to find high score data somewhere known and focus on the exchange/protocol/sync part.

@avivace
Copy link
Sponsor Member

avivace commented Mar 7, 2024

Yes, I'm keen to have a go at this.

To clarify the scope, let me know if I've got this right:

* I'd be writing the prose and implementation/code to go with it

* The code will be used to support the high score sharing feature (at least), but

* this lesson is only concerned with the serial data transfer itself, not e.g. the high scores themselves or logic behind sharing/trading high scores

Also, maybe I'm missing something, but it looks like the score keeping for Part 2 hasn't been implemented yet?

Yep, seems like a good plan, this issue shouldn't really care about the scoring system, we can just "imply" the values to "send" are stored somewhere and the one we'll received will be saved locally

@ISSOtm
Copy link
Member

ISSOtm commented Mar 10, 2024

  • this lesson is only concerned with the serial data transfer itself, not e.g. the high scores themselves or logic behind sharing/trading high scores

That alone I'm anticipating to be quite difficult: syncing two Game Boys is very error-prone in the face of any bit being possibly lost. Timeouts are essentially mandatory, since then the two GBs' very byte boundaries will get desynced—but I doubt any emulator supports that, further complicating testing.

Knowing myself, that would translate to a lot of bringing up edge cases, and thus more back-and-forth than usual on the implementation. Thus I'd suggest the following steps:

  1. In parallel to the below three1, writing the prose for the higher-level introduction to serial transfers.
  2. Writing the implementation
  3. Iterating on it in reviews
  4. Once the implementation is agreed upon, writing its description prose

Footnotes

  1. It may be a good idea to write about the higher-level concepts first, since clarifications at this stage could avoid some confusion in the next step. But OTOH, it's mostly independent from the rest, so it would make for something to work on while waiting for reviews on the implementation.

@quinnyo
Copy link
Contributor

quinnyo commented Mar 13, 2024

Thanks for the suggestions and advice!
Expecting a lot of back-and-forth and iterating on the implementation makes a lot of sense.

That alone I'm anticipating to be quite difficult: syncing two Game Boys is very error-prone

To be sure, I'm not expecting it to be easy. The error detection and handling will likely be one of the more significant parts of the impl/development. (The challenge of it is probably largely responsible for my interest in the subject.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants