Skip to content

Commit 1f5ce9e

Browse files
committed
fix to prev, now all ROMs are happy
1 parent a3d4db6 commit 1f5ce9e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/boards/addrlatch.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,25 @@ static void M227Sync(void) {
353353
uint32 p = ((latche >> 2) & 0x1F) + ((latche & 0x100) >> 3);
354354
uint32 L = (latche >> 9) & 1;
355355

356+
// ok, according to nesdev wiki (refrenced to the nesdev dumping thread) there is a CHR write protection bit7.
357+
// however, this bit clearly determined a specific PRG layout for some game but does not meant to have additional
358+
// functionality. as I see from the menu code, it disables the chr writing before run an actual game.
359+
// this fix here makes happy both waixing rpgs and multigame menus at once. can't veryfy it on a hardware
360+
// but if I find some i'll definitly do this.
361+
362+
if ((latche & 0xF000) == 0xF000)
363+
SetupCartCHRMapping(0, CHRptr[0], 0x2000, 0);
364+
else
365+
SetupCartCHRMapping(0, CHRptr[0], 0x2000, 1);
366+
356367
if ((latche >> 7) & 1) {
357-
SetupCartCHRMapping(0, CHRptr[0], 0x2000, 0); // hacky hacky write protection for CHR
358368
if (S) {
359369
setprg32(0x8000, p >> 1);
360370
} else {
361371
setprg16(0x8000, p);
362372
setprg16(0xC000, p);
363373
}
364374
} else {
365-
SetupCartCHRMapping(0, CHRptr[0], 0x2000, 1); // hacky hacky write protection for CHR
366375
if (S) {
367376
if (L) {
368377
setprg16(0x8000, p & 0x3E);

0 commit comments

Comments
 (0)