|
libjoybus
Joybus implementation for 32-bit MCUs
|
Interface for implementing N64 "Pak" behavior (Rumble Pak, Controller Pak, etc.) when attached to an N64 controller target. More...
Topics | |
| N64 Rumble Pak | |
| N64 pak implementation which emulates a Rumble Pak, providing a callback for motor state changes. | |
Data Structures | |
| struct | joybus_target_n64_pak_api |
| API for implementing an N64 pak. More... | |
| struct | joybus_target_n64_pak |
| An N64 pak, such as a Rumble Pak or Controller Pak. More... | |
Macros | |
| #define | JOYBUS_TARGET_N64_PAK(pak) |
| Macro to cast a concrete N64 pak instance to a generic N64 pak instance. | |
Interface for implementing N64 "Pak" behavior (Rumble Pak, Controller Pak, etc.) when attached to an N64 controller target.
A pak plugs into the expansion port (officially the "Joyport") on the back of an N64 controller, such as a Rumble Pak, Controller Pak, or Transfer Pak. The console reaches it indirectly: it sends read and write commands to the controller, which forwards them to whatever pak is attached.
Every pak presents a flat 16-bit address space, read and written 32 bytes at a time (JOYBUS_PAK_BLOCK_SIZE). It is up to the pak how it manages the address space, and what reads and writes to each address do. For example, a Controller Pak uses the address space to map to 32 KB of storage, but a Rumble Pak treats the addresses as control registers for the rumble motor.
The protocol details (command framing, the address checksum, and the data CRC) are handled by libjoybus, so pak implementations just need to implement the logic for responding to reads and writes at each address.
To create your own pak, define a struct whose first member is a joybus_target_n64_pak (so it can be cast through JOYBUS_TARGET_N64_PAK), point its api at a joybus_target_n64_pak_api table, and attach it with joybus_target_n64_controller_attach_pak().
| #define JOYBUS_TARGET_N64_PAK | ( | pak | ) |
Macro to cast a concrete N64 pak instance to a generic N64 pak instance.