Skip to main content

Module controller

Module controller 

Source
Expand description

SNES controller-port peripherals beyond the standard gamepad: Mouse, Super Scope, and Super Multitap (v0.9.0, Phase 7’s “niche peripherals” exit criterion).

Ported from ares’ sfc/controller/{mouse,super-scope,super-multitap} — real hardware’s 2-bit-per-clock (data1/data2) serial-shift-register protocol per controller port, selected via PortDevice. PortDevice::Gamepad (the default, both ports) is this project’s original, unchanged single-bit 16-bit-shift-register model (crate::Bus’s own joypad field) — every other device is opt-in, selected explicitly via crate::Bus::set_port_device, and touches no code on the default path.

Each device here owns exactly the same two operations real hardware’s controller-port pin 2 (clock/latch) and pins 4-5 (data1/data2) expose: latch(strobe) (the $4016 bit-0 write, wired to BOTH ports simultaneously on real hardware — there is only one physical strobe line) reloads/repacks the device’s shift register from its latest host-supplied input; clock() shifts one bit (or, for MultitapState, one bit from each of two sub-pads at once) out MSB first, refilling with 1 past the real bit count — matching every real SNES serial peripheral’s floating/pulled-high behavior once its shift register empties.

Modules§

scope
Super Scope button bitmask constants for crate::Bus::set_superscope — real, independent physical switches, not mutually-exclusive states, hence a bitmask rather than an enum.

Enums§

PortDevice
Which peripheral occupies a controller port (0 = port 1, 1 = port 2).