1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2024-12-13 01:29:57 +00:00

Also fix zero page wrap for bus reads.

This commit is contained in:
Radosław Kujawa 2018-03-28 14:18:50 +02:00
parent b35323cb3d
commit 4f299a6f36
3 changed files with 20 additions and 2 deletions

View File

@ -353,8 +353,7 @@ instruction_data_read_1(rk65c02emu_t *e, instrdef_t *id, instruction_t *i)
rv = bus_read_1(e->bus, i->op1); rv = bus_read_1(e->bus, i->op1);
break; break;
case ZPX: case ZPX:
/* XXX: wraps around zero page? */ rv = bus_read_1(e->bus, (uint8_t) (i->op1 + e->regs.X));
rv = bus_read_1(e->bus, i->op1 + e->regs.X);
break; break;
case ZPY: case ZPY:
rv = bus_read_1(e->bus, i->op1 + e->regs.Y); rv = bus_read_1(e->bus, i->op1 + e->regs.Y);

View File

@ -1409,6 +1409,7 @@ ATF_TC_BODY(emul_wrap_zpx, tc)
{ {
rk65c02emu_t e; rk65c02emu_t e;
bus_t b; bus_t b;
uint16_t i;
b = bus_init_with_default_devs(); b = bus_init_with_default_devs();
e = rk65c02_init(&b); e = rk65c02_init(&b);
@ -1422,6 +1423,13 @@ ATF_TC_BODY(emul_wrap_zpx, tc)
ATF_CHECK(bus_read_1(&b, 0x00) == 0xAA); ATF_CHECK(bus_read_1(&b, 0x00) == 0xAA);
ATF_CHECK(bus_read_1(&b, 0x01) == 0xAA); ATF_CHECK(bus_read_1(&b, 0x01) == 0xAA);
ATF_CHECK(bus_read_1(&b, 0x7E) == 0xAA); ATF_CHECK(bus_read_1(&b, 0x7E) == 0xAA);
i = 0x200;
while (i < 0x205) {
ATF_CHECK(bus_read_1(&b, i) == 0xAA);
i++;
}
} }
ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TCS(tp)

View File

@ -3,5 +3,16 @@ start: sta 0x10,X
sta 0x81,X sta 0x81,X
sta 0x82,X sta 0x82,X
sta 0xFF,X sta 0xFF,X
ldy 0x10,X
sty 0x200
ldy 0x80,X
sty 0x201
ldy 0x81,X
sty 0x202
ldy 0x82,X
sty 0x203
ldy 0xFF,X
sty 0x204
stp stp