Joybus Protocol: Difference between revisions
m (A few subscripts were changed to superscripts.) |
(Expanded on the command details for command 0x01 and added wavedrom images to show what the data represents.) |
||
Line 50:
<small>'''{{sup|(2)}}''' ''Requires verification, might be offset by one.''</small>
==
While identical to 0x00 in what data is returned to the console, if a device has an intended reset function, it should be performed when this command is sent. The N64 controller for example will reset the internal position of its analog stick to (0, 0), essentially recalibrating it. Other devices may have similar functionality, or none at all, but either way they should still send back the same data as if the 0x00 command was sent.
This command requests information about the device. The N64 a 2-byte identifier and 1 byte of extra data.
{| class="wikitable"
Line 75:
<small>'''{{sup|(1)}}''' ''Requires verification yet.''</small>
The response for this command is always the same length of 4 bytes (32 bits), but the data it represents will change depending on the type of controller device. A Controller Stop Bit is always included after the response bytes.
==== Standard Controller ====
The most common is the standard N64 controller. In which case, the data is the current state of the inputs from the controller: the 14 buttons, the current position of the analog stick, and the reset (RST) bit. The default state of buttons and RST is Zero. If a button is pressed, it becomes One. If LT, RT, and Start are pressed, RST is One, Start becomes Zero, and the analog stick's position is reset to (0, 0). Each axis of the analog stick is a [[w:Two's complement|Two's Complement]] byte, giving a decimal value ranging from -128 to +127, even though a standard controller may not reach the full range due to physical limitations. The bit order from left to right, of the response data, is as follows:
[[File:Controller-response.svg|980px]]
==== Mouse ====
The mouse follows a similar format to the standard controller. However, it only uses the A and B buttons, and the x/y axis bytes represent the relative position of the mouse.
[[File:Mouse-response.svg|980px]]
==== Densha de Go ====
== References ==
|
Revision as of 19:50, 29 September 2020
The Joybus Protocol is a proprietary, non-standard, serial protocol by which the N64's Peripheral Interface (as well as the GameCube and Game Boy Advance) communicates with controllers, controller accessories (Controller Pak, Rumble Pak, etc.), keyboards, mice, game cartridges, and other devices plugged into the console.
Operation
The protocol utilizes four types of bits: Zero, One, the Console Stop Bit, and the Controller Stop Bit. Zero, One, and the Controller Stop Bits are 4μs long, while the Console Stop Bit is 3μs. Communication is always initiated by the console, by sending an 8 bit (one byte) command to the device plugged in (not necessarily always a standard controller). A Console Stop Bit will usually follow after this command byte unless there is more data.
The controller or device will read this command and any extra data, and then respond appropriately. For example, when the console wishes to write to a Controller Pak, it will send 0x03, followed by a 2 byte address, 32 bytes of data, and then the stop bit.
Command List
Because all commands are exactly 8 bits long, there can be a total of 256 commands. However, only about 16 are known for the N64, and a few more for GameCube and Game Boy Advance. Games also have the ability to define custom commands with or without extra data, but official controllers or devices will not understand them.
Command | Description | Console | Devices | Tx Bytes | Rx Bytes |
---|---|---|---|---|---|
0xFF | Reset & Info | N64, GC, GBA | All | 1 | 3 |
0x00 | Info | N64, GC, GBA | All | 1 | 3 |
0x01 | Controller State | N64 | Controller, Mouse | 1 | 4 |
0x02 | Read Controller Accessory | N64 | Transfer, Controller, Bio Sensor, and Rumble Paks | 3 | 33 |
0x03 | Write Controller Accessory | N64 | Transfer, Controller, Bio Sensor, and Rumble Paks | 35 | 1 |
0x04 | Read EEPROM | N64 | Cartridge | ? | ? |
0x05 | Write EEPROM | N64 | Cartridge | ? | ? |
0x06 | Read RTC(1) Status | N64 | 64DD, Animal Forest | ? | ? |
0x07 | Read RTC(1) Block | N64 | 64DD, Animal Forest | ? | ? |
0x08 | Write RTC(1) Block | N64 | 64DD, Animal Forest | ? | ? |
0x09-0x0D | Unknown | N64 | VRU | ? | ? |
0x0E | Reserved | ? | ? | ||
0x0F | Unknown | ? | ? | ||
0x10 | Reserved | ? | ? | ||
0x11 | Reserved | ? | ? | ||
0x12 | Reserved | ? | ? | ||
0x13(2) | Read Keypress | N64 | Randnet Keyboard | 2 | 7 |
0x14(2) | Read GBA[1] | GC, GBA | GBA | 3 | 33 |
0x15(2) | Write GBA[1] | GC, GBA | GBA | 35 | 1 |
0x16-0x2F | Unknown | ? | ? | ||
0x30 | Force Feedback | GC | Steering Wheel | ? | ? |
0x31-0x3F | Unknown | ? | ? | ||
0x40 | Short Poll | GC | Controller | ? | ? |
0x41 | Read Origin | GC | Controller | ? | ? |
0x42 | Calibrate | GC | Controller | ? | ? |
0x43 | Long Poll | GC | Controller | ? | ? |
0x44-0x53 | Unknown | ? | ? | ||
0x54 | Poll | GC | Keyboard | ? | ? |
0x55-0xFE | Unknown | ? | ? |
(1) Real Time Clock
(2) Requires verification, might be offset by one.
Command Details
0xFF - Reset / Info
While identical to 0x00 in what data is returned to the console, if a device has an intended reset function, it should be performed when this command is sent. The N64 controller for example will reset the internal position of its analog stick to (0, 0), essentially recalibrating it. Other devices may have similar functionality, or none at all, but either way they should still send back the same data as if the 0x00 command was sent.
0x00 - Info
This command requests information about the device. The N64 a 2-byte identifier and 1 byte of extra data.
Identifier | Console | Device |
---|---|---|
0x0500 | N64 | Controller |
0x0001 | N64 | VRU |
0x0200 | N64 | Mouse |
0x0002 | N64 | Randnet Keyboard |
0x2004(1) | N64 | Densha de Go |
0x0004 | GBA | Game Boy Advance |
0x0900(1) | GC | Controller |
0x8800(1) | GC | Receiver |
0x8B10(1) | GC | Wavebird |
0x0800(1) | GC | Steering Wheel |
0x0802(1) | GC | Keyboard |
0x0808(1) | GC | Dance Mat |
(1) Requires verification yet.
0x01 - Controller State
The response for this command is always the same length of 4 bytes (32 bits), but the data it represents will change depending on the type of controller device. A Controller Stop Bit is always included after the response bytes.
Standard Controller
The most common is the standard N64 controller. In which case, the data is the current state of the inputs from the controller: the 14 buttons, the current position of the analog stick, and the reset (RST) bit. The default state of buttons and RST is Zero. If a button is pressed, it becomes One. If LT, RT, and Start are pressed, RST is One, Start becomes Zero, and the analog stick's position is reset to (0, 0). Each axis of the analog stick is a Two's Complement byte, giving a decimal value ranging from -128 to +127, even though a standard controller may not reach the full range due to physical limitations. The bit order from left to right, of the response data, is as follows:
Mouse
The mouse follows a similar format to the standard controller. However, it only uses the A and B buttons, and the x/y axis bytes represent the relative position of the mouse.
Densha de Go
0x02 - Read Controller Accessory
0x03 - Write Controller Accessory
References
- ↑ 1.0 1.1 LuigiBlood (2019). Reverse enginnering the unreleased GameBoy Printer COLOR.