9front - general discussion about 9front
 help / color / mirror / Atom feed
* games/gb: fix rtc register selection for mbc3
@ 2017-02-12  8:58 qwx
  0 siblings, 0 replies; only message in thread
From: qwx @ 2017-02-12  8:58 UTC (permalink / raw)
  To: 9front

games/gb: fix rtc register selection for mbc3

(v & 15) >= 8 means to select an rtc register rather than a ram bank,
but because of the modulo, such writes just selected a bank.  since
eramb was then non-nil, latched time data was never accessed.

diff -r 486703b2e27d sys/src/games/gb/mem.c
--- a/sys/src/games/gb/mem.c	Sun Feb 12 00:38:17 2017 +0100
+++ b/sys/src/games/gb/mem.c	Sun Feb 12 10:34:37 2017 +0200
@@ -384,7 +384,7 @@
 		b0 %= nrom >> 14;
 		romb = rom + (b0 << 14);
 		return 0;
-	case 2: b1 = v & 15; b1 %= nbackbank; break;
+	case 2: b1 = v & 15; break;
 	case 3:
 		if(latch == 0 && v == 1){
 			timerl = timer;
@@ -404,7 +404,7 @@
 		}
 		return 0;
 	}
-	eramb = ramen && b1 < 4 ? back + (b1 << 13) : nil;
+	eramb = ramen && b1 < nbackbank ? back + (b1 << 13) : nil;
 	return 0;
 }
 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-02-12  8:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-12  8:58 games/gb: fix rtc register selection for mbc3 qwx

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).