Skip to content

Commit

Permalink
Update NES to emit all button presses on first latch
Browse files Browse the repository at this point in the history
  • Loading branch information
narfman0 committed Dec 4, 2021
1 parent eed0189 commit 73b73e6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
14 changes: 14 additions & 0 deletions firmware/sketches/NES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

#include "NES.h"

void NESSpy::setup() {
firstLatchSignal = true;
}

void NESSpy::loop() {
noInterrupts();
updateState();
Expand Down Expand Up @@ -55,6 +59,16 @@ void NESSpy::updateState() {

WAIT_FALLING_EDGE(NES_LATCH);

if (firstLatchSignal == true) {
do {
WAIT_FALLING_EDGE(NES_CLOCK);
*rawDataPtr = 1;
++rawDataPtr;
} while (--bits > 0);
firstLatchSignal = false;
return;
}

do {
WAIT_FALLING_EDGE(NES_CLOCK);
*rawDataPtr = !PIN_READ(NES_DATA);
Expand Down
2 changes: 2 additions & 0 deletions firmware/sketches/NES.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@

class NESSpy : public ControllerSpy {
public:
void setup();
void loop();
void writeSerial();
void debugSerial();
void updateState();

private:
bool firstLatchSignal;
unsigned char rawData[NES_BITCOUNT * 3];
};

Expand Down
2 changes: 1 addition & 1 deletion firmware/sketches/firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// ---------- Uncomment one of these options to select operation mode ---------
//
//#define MODE_NES
#define MODE_NES
//#define MODE_POWERGLOVE
//#define MODE_SNES
//#define MODE_N64
Expand Down
10 changes: 2 additions & 8 deletions keybindings.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<keybindings>
<!--
The following example binding requires that both "r" and "l"
be pressed at the same time on the monitored gamepad in order to
send a HOME keypress to the OS.
<binding output-key="home">
<input button="r" />
<input button="l" />
<input button="right" />
<input button="left" />
</binding>
-->
</keybindings>

0 comments on commit 73b73e6

Please sign in to comment.