9front - general discussion about 9front
 help / color / mirror / Atom feed
From: qwx <qu7uux@gmail.com>
To: 9front@9front.org
Subject: games/gb: fix rtc register selection for mbc3
Date: Sun, 12 Feb 2017 10:58:33 +0200	[thread overview]
Message-ID: <20170212085833.GA79689@u14.my.domain> (raw)

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;
 }
 


                 reply	other threads:[~2017-02-12  8:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170212085833.GA79689@u14.my.domain \
    --to=qu7uux@gmail.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).