Repository navigation
Add support for GameCube Game Boy Advance cable (DOL-011) and Multi Boot - #11
marian-m12l wants to merge 1 commit into
Conversation
|
While working on this API I noticed that the GameCube Game Boy Advance protocol is not greatly documented. I fixed the GBA Read/Write Joybus commands on n64brew.dev wiki, but I'm unsure whether a detailed documentation for Multi Boot over Joybus fits the wiki. Here is my draft for such a documentation. GBA Multi Boot protocolWhen powering on a GBA, its BIOS listens to incoming serial data on several wire protocols, including JoyBus. The host console (GameCube or N64) can load a so-called Multi Boot ROM (with a specific additional header) up to 256 KiB large into the GBA WRAM, using commands 0x14 and 0x15. The steps for the Multi Boot protocol are listed below. Multi Boot ROMAny ROM sent over Multi Boot must be designed specifically. It must reside in WRAM, and contain an additional header:
GBA ReadinessThe GBA BIOS cycles through its supported protocols, and may not respond to the JoyBus Info command (0x00). Read key AFirst, emit command 0x14 to read a 4-bytes word from the GBA. The response is a random session key that must be used to cipher the payload later on. Compute key BKey B is calculated on the host console. It is not random, but computed from the payload length and logo configuration.
Color takes a value between 0 and 6 and determines the "base" color for the animation. Animation takes a values between -4 and 4. A value of 0 results in a fixed logo. Negative and positive values result in the logo switching between two colors: the base color and the following color. Sign indicates whether the animation starts from the base color (positive value) or from the following color (negative value). The higher the value, the faster the animation. The table below summarizes the possible values and their visible result:
Logo configuration is encoded over 6 bits, depending on the sign of the animation setting, as shown in the table below:
The table below shows how all these elements are mangled in the 4-byte word:
Finally, key B is obtained by XOR'ing with secret key, chosen from the value of bit 9 ("sedo" (0x7365646f) if bit 9 is set, "Kawa" (0x4b617761) otherwise). Emit command 0x15 to write the 4-bytes key B to the GBA. Send clear headerThe ROM header (i.e. the first 0xc0 bytes of the ROM) is sent as cleartext. Simply emit commands 0x15 to write each 4-bytes word to the GBA. Send the remaining of the payloadThe remaining of the ROM, starting from offset 0xC0, up to the payload length rounded up to the nearest 8-bytes boundary, is ciphered using key A. For each 4-bytes word remaining in the ROM, follow the algorithm (in pseudo-code): Ciphertext is sent to the GBA by emitting 0x15 commands. A CRC is calculated on the cleartext data during this phase. Its initial value is 0x15a0. For each 4-bytes word, CRC is updated using the following algorithm (in pseudo-code): Send CRCAfter the ROM payload has been transferred, the CRC is combined with the payload length and ciphered before being sent to the GBA. Read and check dummy wordAt this point, the GBA will boot into the uploaded ROM. It is however possible to read a "dummy" word using command 0x14. The value received from the GBA should match one of :
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
What is this, GBA to N64 compatibility? |
Yes, you can make an adapter to plug the GameCube GBA Link Cable into the N64 Controller Port: https://github.com/meeq/joybus-adapter |
|
would that mean an N64 game communicates with a GBA game to unlock stuff on the former? |
It means you have a (slow) serial link that the N64 can use to communicate with the GBA via read/write commands. What you do with it is up to you. Notably, the GBA BIOS can receive a specially-crafted rom over Joybus, so you can upload the rom directly from the N64, no cartridge needed on the GBA. |
|
ok, so game in the Boy Advancee is optional, just like on GameCube. |
This is my attempt at designing an API to support the GameCube Game Boy Advance cable (DOL-011).
The PR contains:
gba_linkwith support for basic GBA Link Cable support (status, read/write Joybus commands)gba_link_multibootfor Multi Boot support (to upload a rom to a GBA while it's booting; this is a feature of the GBA BIOS)gbalinkthat demonstrates the APIs, including a very basic GBA romI believe @meeq is also working on a similar API, but I still wanted to give it a go on my own. Feel free to dismiss the PR, but hopefully it's helpful to some degree.