MMC1: multiple shift register and mirroring bugs
- Dominant language
- JavaScript
- Stars
- 6.4k
- Forks
- 857
- PR merge metrics
- No merged PRs in 30d
Description
## Summary
The MMC1 (Mapper 1) implementation has several correctness issues:
### 1. Bit-7 reset is conditional on address (mapper1.js:50)
```javascript
if (this.getRegNumber(address) === 0) {
this.prgSwitchingArea = 1;
this.prgSwitchingSize = 1;
}
```
Per nesdev, writing with bit 7 set should **unconditionally** set control register bits 2-3 (PRG bank mode 3) regardless of the write address. A reset write to `$C000` or `$E000` should still update PRG switching mode.
### 2. Missing consecutive-write filtering
Real MMC1 ignores writes on consecutive CPU cycles. RMW instructions (INC, DEC, etc.) write twice — the first write (with bit 7 set) resets the shift register, and the second write must be ignored. Without filtering, games like **Bill & Ted's Excellent Adventure** and **Shinsenden** crash.
### 3. Single-screen mirroring ignores page select (mapper1.js:85)
```javascript
if ((this.mirroring & 2) === 0) {
this.nes.ppu.setMirroring(this.nes.rom.SINGLESCREEN_MIRRORING);
}
```
Mirroring value 0 should select lower bank (page 0), value 1 should select upper bank (page 1). Both currently map to the same page.
## References
- [MMC1 wiki](https://www.nesdev.org/wiki/MMC1)
- [MMC1 consecutive write behavior](https://forums.nesdev.org/viewtopic.php?t=12195)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in mapper1.js at the reset logic around line 50 and mirroring logic around line 85, then read the linked MMC1 references. Verify reset writes update PRG mode regardless of address, consecutive writes are filtered, and single-screen mirroring selects the requested page; confirm the affected games no longer crash.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100