spieglt / nestur

The NES (emulator) you left outside in the rain but let dry and still kind of works
541 stars 18 forks source link

Emulation Timing Issues and Sprite Zero Hit Inaccuracies #8

Open s-rah opened 2 years ago

s-rah commented 2 years ago

Hi!

I spent some time last night diving into some nes test roms for my fuzzer, and uncovered the following small issues. With these issues fixed games like Mega Man reproduce much better (although there are still some NMI timing issues I have yet to look into)

Given https://github.com/christopherpow/nes-test-roms/tree/master/cpu_timing_test6 the following opcodes report inaccuracies:

I've fixed this in my fuzzer by adding offsets to JMP and RTI, and adding a before_clock parameter to report a complete offset for STA in those 2 special cases (see: https://git.openprivacy.ca/sarah/nesfuzz/commit/f7110dcd50da9680d79d7253c436989818c39609) - but this is kinda hacky and you may or may not want to use a different approach.

Given https://github.com/christopherpow/nes-test-roms/tree/master/sprite_hit_tests_2005.10.05

Note: 09/10/11 will all fail until cpu cycle issues documented above are fixed.

Given https://github.com/christopherpow/nes-test-roms/tree/master/blargg_ppu_tests_2005.09.15b

spieglt commented 2 years ago

Awesome, thanks! Will look into these soon.

s-rah commented 2 years ago

A couple more, that I found last night:

branch_page_cross should be +1 not +2

In CPU step the number of clock cycles returned needs to include the number of cycles due to interrupts.

With those 2 changes. the Megaman game end glitch, and the Kirby game end glitch both reproduce 100%. In addition all the Branch Basics test roms will pass, in addition to a few other instruction timing test roms.

spieglt commented 2 years ago

Still plenty to do but got the CPU timing test passing last night