From 3004aa99f29d5ff148314ec737f5e9e6ec6dbe02 Mon Sep 17 00:00:00 2001 From: Will Scullin Date: Sun, 21 Feb 2021 21:26:07 -0800 Subject: [PATCH] Fix some edge cases --- js/canvas.ts | 2 +- js/cpu6502.ts | 4 ++++ js/gl.ts | 10 ---------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/js/canvas.ts b/js/canvas.ts index 3a3994d..bb10e73 100644 --- a/js/canvas.ts +++ b/js/canvas.ts @@ -775,7 +775,7 @@ export class HiresPage2D implements HiresPage { this._refreshing = true; const bb: bank = bank ? 0 : 1; for (let rr = addr - 1; rr <= addr + 1; rr++) { - const vv = this._buffer[bb][rr - 0x2000 * this.page]; + const vv = this._buffer[bb][rr & 0x1FFF]; this._write(rr >> 8, rr & 0xff, vv, bb); } this._refreshing = false; diff --git a/js/cpu6502.ts b/js/cpu6502.ts index 54ab765..1e06b61 100644 --- a/js/cpu6502.ts +++ b/js/cpu6502.ts @@ -839,6 +839,7 @@ export default class CPU6502 { this.readByte(this.pc); const oldPage = this.pc >> 8; this.pc += off > 127 ? off - 256 : off; + this.pc &= 0xffff; const newPage = this.pc >> 8; const newOff = this.pc & 0xff; if (newPage != oldPage) this.readByte(oldPage << 8 | newOff); @@ -851,6 +852,7 @@ export default class CPU6502 { this.readByte(this.pc); const oldPage = this.pc >> 8; this.pc += off > 127 ? off - 256 : off; + this.pc &= 0xffff; const newPage = this.pc >> 8; const newOff = this.pc & 0xff; if (newPage != oldPage) this.readByte(oldPage << 8 | newOff); @@ -870,6 +872,7 @@ export default class CPU6502 { const oldPage = oldPc >> 8; this.readByte(oldPc); this.pc += off > 127 ? off - 256 : off; + this.pc &= 0xffff; const newPage = this.pc >> 8; if (oldPage != newPage) { this.readByte(oldPc); @@ -888,6 +891,7 @@ export default class CPU6502 { const oldPage = oldPc >> 8; this.readByte(oldPc); this.pc += off > 127 ? off - 256 : off; + this.pc &= 0xffff; const newPage = this.pc >> 8; if (oldPage != newPage) { this.readByte(oldPc); diff --git a/js/gl.ts b/js/gl.ts index b1045ba..f014269 100644 --- a/js/gl.ts +++ b/js/gl.ts @@ -572,16 +572,6 @@ export class HiresPageGL implements Memory, Restorable { bits >>= 1; } } - - if (!this._refreshing) { - this._refreshing = true; - const bb: bank = bank ? 0 : 1; - for (let rr = addr - 1; rr <= addr + 1; rr++) { - const vv = this._buffer[bb][rr - 0x2000 * this.page]; - this._write(rr >> 8, rr & 0xff, vv, bb); - } - this._refreshing = false; - } } else { val = this._buffer[0][base]; const hbs = val & 0x80;