Serial Data Transfer clock internal vs. external

Discussion of programming and development for the original Game Boy and Game Boy Color.
Post Reply
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Serial Data Transfer clock internal vs. external

Post by zeroone »

When you link 2 Game Boys together, how do they coordinate which of them clocks the channel? Is it based off of menu selections (e.g. Connect as player 1 vs connect as player 2)?
Shonumi
Posts: 342
Joined: Sun Jan 26, 2014 9:31 am

Re: Serial Data Transfer clock internal vs. external

Post by Shonumi »

Typically, both Game Boys will set themselves up to receive data on an external clock, meaning they can't initiate a transfer. One Game Boy will switch to an internal clock when prompted by user input (pressing A or START on a given menu), then it will send a byte and wait for a response from the other GB. The one using the external clock would be the "slave" and the one using an internal clock is "master", since "master" will be the one driving communications.

It's possible for two GBs to switch to internal clocks at the same time during the user input phase for selecting multiplayer. In that case, some games have "master" and "slave" bytes they exchange. By default, the slave byte is put into register SB. Only when they switch to internal clocks do they setup the master code. If one GB tries to become master, but it receives a master byte, something went wrong, and the game will prompt users to try again.
Post Reply