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

DMC DMA read corruption working incorrectly #308

Open
Fiskbit opened this issue Nov 24, 2018 · 2 comments
Open

DMC DMA read corruption working incorrectly #308

Fiskbit opened this issue Nov 24, 2018 · 2 comments

Comments

@Fiskbit
Copy link

Fiskbit commented Nov 24, 2018

DMC DMA read corruption occurs in Nestopia UE on even cycles when it should occur on odd cycles. I'd like to use even-cycle joypad reads to avoid having to spend cycles reading joypads 2 or more times, as discussed here: https://forums.nesdev.com/viewtopic.php?f=2&t=14319. This issue can be tested with dma_sync_test; version 1, with separate even-cycle and odd-cycle versions, can be found on the first page of that thread, while v2 (with just even-cycle) is on page 2 and on the Nesdev "Emulator tests" page. The tests display a black screen until a right input is observed, turning the screen white. The v1 even-cycle and v2 tests are expected to not turn white until the user presses right, while the v1 odd-cycle test is expected to show a white screen almost immediately. While other emulators I've tested that emulate this corruption (Mesen 0.9.7, puNES 0.100, Nintendulator 0.975) match expected behavior, Nestopia UE's behavior is inverted, indicating the cycle alignment is wrong. I've tested on versions 1.47 and 1.49.

@Fiskbit
Copy link
Author

Fiskbit commented Nov 28, 2018

Given the environments in which Nestopia runs, I expect old versions with this bug to be floating around for quite some time and I'd like to still be able to support them. Unfortunately, this problem is difficult to detect directly, so I've identified a separate accuracy test that is currently failed by Nestopia but is passed by Mesen, puNES, and Nintendulator: cpu_dummy_writes/cpu_dummy_writes_ppumem. Specifically, Nestopia does not emulate PPU open bus behavior correctly across 4 writes to $2004. By writing #$7F to $2004 four times and comparing against the value read from $2000 each time, Nestopia can be identified among this pool of emulators by one failed comparison. This test is easy and reliable.

I ask that you fix this PPU open bus issue at the same time as the DMC read corruption issue so I can use this to reliably identify whether I need to wait an extra cycle in my input routine to maintain compatibility with older versions of Nestopia. My hope is that there are not other emulators of any note that both correctly handle DMC read corruption and have this same open bus issue (I'm not aware of any).

@carmiker
Copy link

carmiker commented Oct 1, 2023

I believe I have fixed this problem in the upstream repository now. Some other details regarding DMC DMA are not quite perfect yet, but the odd/even cycle problem is at least fixed, and it was a simple and obvious fix in hindsight. The next tagged release should be able to close this issue.

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