Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emulation Timing Issues and Sprite Zero Hit Inaccuracies #8

Open
s-rah opened this issue Nov 23, 2021 · 3 comments
Open

Emulation Timing Issues and Sprite Zero Hit Inaccuracies #8

s-rah opened this issue Nov 23, 2021 · 3 comments

Comments

@s-rah
Copy link

s-rah commented Nov 23, 2021

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:

  • JMP in ABS mode (1 cycle too long)
  • RTI (2 cycles too long)
  • STA in Indirect Indexed Mode (should be 6)
  • STA in Absolute Y mode (should be 5)

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

  • 06.right_edge fails (Should always miss when X = 255) - can be fixed with a check in src/ppu/rendering.rs
  • 07.screen_bottom ( Should always miss when Y = 255) - this seems to be related to PPU timing issues.

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

  • cpu writes to 0x4014, OAMDATA should start at the address in OAMADDR and wrap rather than replace OAM entirely.
@spieglt
Copy link
Owner

spieglt commented Nov 23, 2021

Awesome, thanks! Will look into these soon.

@s-rah
Copy link
Author

s-rah commented Nov 24, 2021

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
Copy link
Owner

spieglt commented Dec 1, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants