Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix crash for some MMC1 games

  • Loading branch information...
commit 612d36065502592372932a9e50b5e0f52ae6a66e 1 parent bc2bd05
Scott Ferguson authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 mmc1.go
5 mmc1.go
View
@@ -107,6 +107,7 @@ func (m *Mmc1) SetRegister(reg int, v int) {
case Size8k:
// Swap 8k VROM (in 8k mode, ignore first bit D0)
bank := v & 0xF
+ bank %= m.ChrRomCount
WriteVramBank(m.VromBanks, bank, 0x0000, Size4k)
WriteVramBank(m.VromBanks, bank+1, 0x1000, Size4k)
@@ -119,7 +120,7 @@ func (m *Mmc1) SetRegister(reg int, v int) {
} else {
bank = v & 0xF
}
- WriteVramBank(m.VromBanks, bank, 0x0, Size4k)
+ WriteVramBank(m.VromBanks, bank%m.ChrRomCount, 0x0, Size4k)
}
// CHR Bank 1
case 2:
@@ -137,7 +138,7 @@ func (m *Mmc1) SetRegister(reg int, v int) {
} else {
bank = v & 0xF
}
- WriteVramBank(m.VromBanks, bank, 0x1000, Size4k)
+ WriteVramBank(m.VromBanks, bank%m.ChrRomCount, 0x1000, Size4k)
}
// PRG Bank
case 3:
Please sign in to comment.
Something went wrong with that request. Please try again.