From 63e49696b8fdc02ca1a5c079f00045a950c072d4 Mon Sep 17 00:00:00 2001 From: Will Scullin Date: Mon, 8 Mar 2021 19:28:52 -0800 Subject: [PATCH] Goose slot detection code --- js/apple2io.ts | 4 +++- js/mmu.ts | 8 ++++++++ js/util.ts | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/js/apple2io.ts b/js/apple2io.ts index c9b127f..551e8fb 100644 --- a/js/apple2io.ts +++ b/js/apple2io.ts @@ -11,7 +11,7 @@ import CPU6502 from './cpu6502'; import { Card, Memory, MemoryPages, TapeData, byte, Restorable } from './types'; -import { debug } from './util'; +import { debug, garbage } from './util'; type slot = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7; type button = 0 | 1 | 2; @@ -364,6 +364,8 @@ export default class Apple2IO implements MemoryPages, Restorable } if (card) { result = card.read(page, off); + } else { + result = garbage(); } break; default: diff --git a/js/mmu.ts b/js/mmu.ts index 631199a..94fc665 100644 --- a/js/mmu.ts +++ b/js/mmu.ts @@ -392,17 +392,25 @@ export default class MMU implements Memory, Restorable { if (this._intcxrom) { for (let idx = 0xc1; idx < 0xd0; idx++) { this._readPages[idx] = this._pages[idx][1]; + this._writePages[idx] = this._pages[idx][1]; + } + if (this._slot3rom) { + this._readPages[0xc3] = this._pages[0xc3][0]; + this._writePages[0xc3] = this._pages[0xc3][0]; } } else { for (let idx = 0xc1; idx < 0xd0; idx++) { this._readPages[idx] = this._pages[idx][0]; + this._writePages[idx] = this._pages[idx][0]; } if (!this._slot3rom) { this._readPages[0xc3] = this._pages[0xc3][1]; + this._writePages[0xc3] = this._pages[0xc3][1]; } if (this._intc8rom) { for (let idx = 0xc8; idx < 0xd0; idx++) { this._readPages[idx] = this._pages[idx][1]; + this._writePages[idx] = this._pages[idx][1]; } } } diff --git a/js/util.ts b/js/util.ts index b3213eb..ffb3f83 100644 --- a/js/util.ts +++ b/js/util.ts @@ -17,7 +17,7 @@ const hex_digits = '0123456789ABCDEF'; const bin_digits = '01'; /** Returns a random byte. */ -function garbage(): byte { +export function garbage(): byte { return (Math.random() * 0x100) & 0xff; }