My emulator kept failing the abs_xy test of instr_test-v4 from blargg.
Read documentation about this over and over and over. Cannot figure why what went wrong.
Documentation for SHY is as follows:
Load "argument" address..
Extract high-byte of that argument address.
Increment it with 1
Write back to the Abs,X adressing anded with the y register.
But.. 07-abs_xy.nes file kept failing that instruction along with 0x9E (SHX)
Slowing going insane on that point until i found a video from "Official USB-NES Channel" on YT. ( https://www.youtube.com/watch?v=ErAJ2seSPMQ )
Which explained in detail what it does.
Everything what the documention said. But with ONE HUGE difference.
When abs,x or abs,y crosses a page boundary the high byte of the to be written address will be overwritten with (arg:hb+1 anded with y) totally changing the destination address.
Implemented that quirk in opcodes 0x9c and 09xe (0x9e is essentially 09xc but with regs x and y swapped)
finally I got through the 07-abs_xy.nes test. All tests passed.
Snippet how it looks in my code:For anyone who is also struggling with this. I hope this information relieves you from that struggle.
Read documentation about this over and over and over. Cannot figure why what went wrong.
Documentation for SHY is as follows:
Load "argument" address..
Extract high-byte of that argument address.
Increment it with 1
Write back to the Abs,X adressing anded with the y register.
But.. 07-abs_xy.nes file kept failing that instruction along with 0x9E (SHX)
Slowing going insane on that point until i found a video from "Official USB-NES Channel" on YT. ( https://www.youtube.com/watch?v=ErAJ2seSPMQ )
Which explained in detail what it does.
Everything what the documention said. But with ONE HUGE difference.
When abs,x or abs,y crosses a page boundary the high byte of the to be written address will be overwritten with (arg:hb+1 anded with y) totally changing the destination address.
Implemented that quirk in opcodes 0x9c and 09xe (0x9e is essentially 09xc but with regs x and y swapped)
finally I got through the 07-abs_xy.nes test. All tests passed.
Snippet how it looks in my code:
Code:
case 0x9c: {byte hb = (_mem_absolute >> 8);hb++;// check for boundary cross.word xadr = _mem_absolute_x;if ((_mem_absolute & 0xFF00) != (_mem_absolute_x & 0xFF00)) {// something weird happens too when a page boundary occurs.// value of the y register that effecting the high address line to be written.// this is the reason why it failed the 07-abs_xy.nes test.// thanking the video of "Official USB-NES Channel" on YT for deeply explaining// the behaiviour of the SHY $abs, X opcode.xadr = _mem_absolute & 0x00FF | ((regs.y & hb) << 8);xadr += regs.x;}devicebus->writememory(xadr, regs.y & hb);regs.pc += 2;actualticks += 5;break;}
Statistics: Posted by nIghtorius — Fri Feb 23, 2024 2:42 am — Replies 0 — Views 54