Try and emulate "false reads"

This commit is contained in:
Will Scullin 2019-09-18 19:46:15 -07:00
parent 8ee543619e
commit 86602a4eb7
No known key found for this signature in database
GPG Key ID: 9092A5C0A673416B
2 changed files with 26 additions and 18 deletions

View File

@ -314,7 +314,8 @@ export default function CPU6502(options)
addr = (addr + xr) & 0xffff;
page = addr >> 8;
if (page != oldPage) {
cycles++;
var off = addr & 0xff;
readByte(oldPage << 8 | off);
}
return readByte(addr);
}
@ -325,7 +326,8 @@ export default function CPU6502(options)
addr = (addr + yr) & 0xffff;
page = addr >> 8;
if (page != oldPage) {
cycles++;
var off = addr & 0xff;
readByte(oldPage << 8 | off);
}
return readByte(addr);
}
@ -357,7 +359,8 @@ export default function CPU6502(options)
addr = (addr + yr) & 0xffff;
page = addr >> 8;
if (page != oldPage) {
cycles++;
var off = addr & 0xff;
readByte(oldPage << 8 | off);
}
return readByte(addr);
}
@ -383,16 +386,20 @@ export default function CPU6502(options)
// $0000,X
function writeAbsoluteX(val) {
var address = (readWordPC() + xr) & 0xffff;
cycles++;
writeByte(address, val);
var addr = readWordPC(), oldPage = addr >> 8;
addr = (addr + xr) & 0xffff;
var off = addr & 0xff;
readByte(oldPage << 8 | off);
writeByte(addr, val);
}
// $0000,Y
function writeAbsoluteY(val) {
var address = (readWordPC() + yr) & 0xffff;
cycles++;
writeByte(address, val);
var addr = readWordPC(), oldPage = addr >> 8;
addr = (addr + yr) & 0xffff;
var off = addr & 0xff;
readByte(oldPage << 8 | off);
writeByte(addr, val);
}
// $00,X
@ -418,9 +425,11 @@ export default function CPU6502(options)
// ($00),Y
function writeZeroPageIndirectY(val) {
var address = (readZPWord(readBytePC()) + yr) & 0xffff;
cycles++;
writeByte(address, val);
var addr = readZPWord(readBytePC()), oldPage = addr >> 8;
addr = (addr + yr) & 0xffff;
var off = addr & 0xff;
readByte(oldPage << 8 | off);
writeByte(addr, val);
}
// ($00) (65C02)
@ -458,9 +467,9 @@ export default function CPU6502(options)
}
// $0000,X
function readAddrAbsoluteX() {
function readAddrAbsoluteX(opts) {
var addr = readWordPC();
if (!is65C02) {
if (!is65C02 || (opts && opts.inc)) {
readByte(addr);
} else {
cycles++;
@ -538,7 +547,7 @@ export default function CPU6502(options)
}
function inc(readAddrFn) {
var addr = readAddrFn();
var addr = readAddrFn({inc: true});
writeByte(addr, increment(readByte(addr)));
}
@ -558,7 +567,7 @@ export default function CPU6502(options)
}
function dec(readAddrFn) {
var addr = readAddrFn();
var addr = readAddrFn({inc: true});
writeByte(addr, decrement(readByte(addr)));
}
@ -1422,7 +1431,7 @@ export default function CPU6502(options)
}
},
/* IRQ - Interupt Request */
/* IRQ - Interrupt Request */
irq: function cpu_irq()
{
if ((sr & flags.I) === 0) {

View File

@ -227,7 +227,6 @@ function doLoadLocalDisk(drive, file) {
var name = parts.join('.');
if (disk2.setBinary(drive, name, ext, this.result)) {
drivelights.label(drive, name);
MicroModal.close('load-modal');
initGamepad();
}
};