Closed Mark-Platts closed 3 years ago
I can't remember if I did it there, obviously I should have. It's done on at least one other place. And I more or less did what you have. I'll check where it is tomorrow so you can compare if you're interested.
The way I get page number from address is by shifting right by eight bytes, like this:
Byte page = address >> 8;
That effectively chops off the smaller eight bytes leaving only the eight bytes corresponding to page number. Your method does isolate the page number so it certainly works too.
Good tip on the branches of branches, that never occurred to me.
The references I'm using for the opcodes don't mention an extra cycle for STA_ABSOLUTE_Y. Are you sure it's necessary?
For an example of an instruction that might need extra cycles you can look at BNE_RELATIVE. Like I said though, it's done basically the same way you've described.
If it doesn't mention it for STA then no worries. I assumed it would be the same for all ops where page boundaries are a concern.
Added and tested the AND op with absolute, x address mode.
I looked up how other people do multiple branches and this time I've made this branch from the previous branch. Hopefully this means that git will know the changes are in series, not parallel.
Also, just in case I didn't figure it out again: With your STA_ABSOLUTE_Y, are you doing anything to check for the extra cycle needed if the page boundary is crossed?
I've used (address & 0xFF00) to get the 'page number' before and after adding X, then if there's a change I add an extra sem.wait()