User:Clktmr
Jump to navigation
Jump to search
Joybus Command Layout
The PIF-NUS RAM can be filled with up to five joybus commands, one for each port. The first four ports are the controller ports on the front of the console. The fifth port is routed to the cartridge, typically connected to an EEPROM and/or RTC.
Each joybus command is prepended by a two byte header:
- First byte contains the Tx length in bits [0:5], which is at least one as it contains the command id. Bits 6 and 7 are flags:
- Bit 7 set: channel is skipped (identical behavior to 0x00)
- Bit 6 set: channel is reset (identical behavior to 0xfd)
- Second byte contain the Rx length in bits [0:5]. Bits 6 and 7 are error flags, set by the PIF. The assumed meanings of these bits are (need verification)
- Bit 6 set: joybus device's response was longer than expected
- Bit 7 set: general error. It's definitely set when no device is connected to the joybus port
Instead of a header+joybus command, single bytes with special functions can be inserted:
- 0x00: skip the joybus port
- 0xfd: reset the joybus port
- 0xfe: skips all following ports
- 0xff: nop
For iQue compatibiliy, which emulates the PIF-NUS, the header must be padded with a single nop (0xff) and then 8-byte aligned (to be verified).
More information: PIF-NUS, Serial Interface, Joybus Protocol, PIF-NUS Disassembly
Controller State Example:
The following will cause the PIF-NUS to write the first controller's state into the four RxData bytes:
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
---|---|---|---|---|---|---|---|---|
iQue Padding | PIF-NUS Header | Joybus Command | PIF-NUS special byte | |||||
Tx Size | Rx Size | Tx Data | Rx Data | Terminator | ||||
0xff | 0x01 | 0x04 | 0x01 | 0xff | 0xff | 0xff | 0xff | 0xfe |