Commit 205ab41
Zapper v2 (#216)
* Use a SNES pad's A and B in games, not its B and Y
A SNES controller wired to a NES controller port shifts out B and Y
where a NES pad has A and B, so those two buttons drove NES A and B
while physical A did nothing at all. Every other input names its
buttons instead: a USB pad's A reaches NES A through Button::A, and so
does a Wii Classic pad's, whose bit0 is A. The GPIO port was the only
place where the button that launches a ROM was dead once the game
started.
Its four face buttons are now named too, using the pad type that
nespad_decode() records: physical A drives NES A, physical B drives
NES B, and X/Y/L/R are ignored as they are on USB and Wii pads. Rapid
fire and the SELECT+START+UP+A bootsel combo follow, since both work on
the merged NES word. NES pads and SNES->NES adapter cables that report
NES buttons keep the previous mapping, bit for bit.
Bumps pico_shared for the matching menu fix, which also carries three
earlier commits that had not been recorded here yet.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* Add NES Zapper (light gun) support on the custom PCB
Reads NES controller port 2's two extra data lines into bits 3 and 4 of
$4017, the way a real NES does: D3 (light sensor) on GPIO28, D4 (trigger)
on GPIO27, as routed by PCB design v2.1 and later. Enabled for HW_CONFIG 2
only; every other board already uses one or both of those GPIOs, so the
feature compiles away there.
The levels are sampled inside the $4017 read rather than latched once per
frame, because the games measure where in the frame light appears. Only
bits 3 and 4 are overlaid, so the pad-2 serial data in bit 0 survives and a
controller can share the port with the gun. The bits are deliberately kept
out of InfoNES_PadState(), where bit 3 is START and bit 4 is UP and would
fire the hotkey combinations on every shot.
The light line is inverted in software and the trigger line is not. The NES
inverts the light line between the connector and the CPU bus, so $4017 bit 3
reads 0 for "light detected" while the pin is high when the sensor sees
light; the PCB wires the port straight to the Pico. Verified on hardware by
covering the sensor. Both lines have ZAPPER_INVERT_* build options.
Presence is detected automatically and latched sticky, since a Zapper holds
its trigger line low while the trigger is released.
Also adds two off-by-default diagnostics: ZAPPER_DEBUG (bit mask, 1 = UART
trace, 2 = on-screen readout) and ZAPPER_MEASURE, which blacks out the
picture, flashes it white and times the light line to measure end-to-end
display lag. Both disturb light gun detection and are for bring-up only.
Measured on RP2040/picoDVI with a Tomee Zapp Gun: 19-27 ms end-to-end lag,
and a single white frame is detected only about half the time while three
consecutive frames always are.
Known limitation: verified on RP2040/picoDVI. On RP2350/HSTX the patched
Duck Hunt menu advances on its own, which is still to be investigated.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* Update subproject commit reference in pico_lib
* Add NES Zapper (light gun) support on the custom PCB
Reads NES controller port 2's two extra data lines into bits 3 and 4 of
$4017, the way a real NES does: D3 (light sensor) on GPIO28, D4 (trigger)
on GPIO27, as routed by PCB design v2.1 and later. Enabled for HW_CONFIG 2
only; every other board already uses one or both of those GPIOs, so the
feature compiles away there.
The levels are sampled inside the $4017 read rather than latched once per
frame, because the games measure where in the frame light appears. Only
bits 3 and 4 are overlaid, so the pad-2 serial data in bit 0 survives and a
controller can share the port with the gun. The bits are deliberately kept
out of InfoNES_PadState(), where bit 3 is START and bit 4 is UP and would
fire the hotkey combinations on every shot.
The light line is inverted in software and the trigger line is not. The NES
inverts the light line between the connector and the CPU bus, so $4017 bit 3
reads 0 for "light detected" while the pin is high when the sensor sees
light; the PCB wires the port straight to the Pico. Verified on hardware by
covering the sensor. Both lines have ZAPPER_INVERT_* build options.
Presence is detected automatically and latched sticky, since a Zapper holds
its trigger line low while the trigger is released.
Also adds two off-by-default diagnostics. ZAPPER_DEBUG is a bit mask: 1 is a
UART trace of the pin levels, how often the game reads $4016/$4017, what it
was told, and hardware edge counts on both lines; 2 draws the same on screen.
ZAPPER_MEASURE blacks out the picture, flashes it white and times the light
line to measure end-to-end display lag. All of them disturb light gun
detection and are for bring-up only.
Verified on RP2040 with picoDVI and on RP2350 with both HSTX and DVI.
Measured on RP2040 with a Tomee Zapp Gun: 19-27 ms end-to-end display lag,
and a single white frame is detected only about half the time while three
consecutive frames always are - the panel cannot reach full brightness in one
frame, which is why screen brightness matters more than anything else.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* Correct the Zapper D3/D4 pin mapping and note board limitations
The PCB routes port 2's D3 (light sensor) to GPIO27 and D4 (trigger) to
GPIO28, not the other way round as the PCB README stated. That README was
written from the v2.1 silkscreen, which labels the two pads the wrong way
round: what is printed as D3 is the physical D4 line and vice versa. Only the
printing is affected, so the routing is identical on v2.1 and v2.6 and one
firmware default serves both. v2.6 corrects the labels.
Swaps the HW_CONFIG 2 defaults to ZAPPER_D3=27 and ZAPPER_D4=28 and updates
every place the mapping was documented. Line polarity is unchanged: the macros
name the lines by function, so ZAPPER_INVERT_D3 still applies to the light
line wherever it lands. Anyone who wired a breadboard the other way can build
with -DZAPPER_D3=28 -DZAPPER_D4=27.
Also records that the Zapper cannot be used on the Murmulator M1 and M2
boards, whose PCBs leave D3 and D4 of the controller ports unconnected, so
the gun's lines never reach the board at all.
Verified on a breadboard and on the PCB, on RP2040 with picoDVI and on RP2350
with HSTX.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* Update subproject commit reference in pico_lib
* Update subproject commit reference in pico_shared
* update CHANGELOG
* Update README
* Update CHANGELOG
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent 33e3548 commit 205ab41
13 files changed
Lines changed: 1176 additions & 94 deletions
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
56 | 126 | | |
57 | | - | |
| 127 | + | |
58 | 128 | | |
59 | 129 | | |
60 | 130 | | |
| |||
113 | 183 | | |
114 | 184 | | |
115 | 185 | | |
| 186 | + | |
116 | 187 | | |
117 | 188 | | |
118 | 189 | | |
| |||
185 | 256 | | |
186 | 257 | | |
187 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
188 | 266 | | |
189 | 267 | | |
190 | 268 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
3 | 88 | | |
4 | 89 | | |
5 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
| |||
0 commit comments