Difference (Unl) shakes in my emulator

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: Difference (Unl) shakes in my emulator

Post by Zepper »

@fred - I added a delay of 3 PPU cycles, there's no flickering scores in those games. By the way, your test displays correct triangles if I press down and right a few times. Is this correct or... should be fine since the startup?
fred
Posts: 67
Joined: Fri Dec 30, 2011 7:15 am
Location: Sweden

Re: Difference (Unl) shakes in my emulator

Post by fred »

Pressing down and right makes the 2006 write happen later so it's likely it should be that way, yes. I don't know what an actual nes shows.

tepples: Neato image! Too bad i placed the tiles on row 0. I'll try to lower them, but adjusting any timing is a real pain, haha. Adjusting just about anything is a pain - I'd remove up/down and make left/right smarter and display the current dot offset if I could simply add it.
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: Difference (Unl) shakes in my emulator

Post by Zepper »

fred wrote:Pressing down and right makes the 2006 write happen later so it's likely it should be that way, yes. I don't know what an actual nes shows.
I got bad triangles in older versions of my emulator. I believe to be in the right way. ^_^;;
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Difference (Unl) shakes in my emulator

Post by zeroone »

fred wrote:Pressing down and right makes the 2006 write happen later so it's likely it should be that way, yes. I don't know what an actual nes shows.
Thanks for getting the ball rolling on this test ROM. Can we get it onto real hardware to see if the PPU v-register write delay actually exists? And, possibly to measure that delay?
fred
Posts: 67
Joined: Fri Dec 30, 2011 7:15 am
Location: Sweden

Re: Difference (Unl) shakes in my emulator

Post by fred »

Turns out it wasn't too bad to simplify the controls! Phew. Also managed to print the current offset. I'd still like to add an explanation in there and move the tiles down, but that's for another time.

Press right or left to increase or decrease the dot offset by one, respectively.

For example, in nintedulator: the second "sta 0x2006" starts at dots 236-237 at offset 0, and dots 244-245 at offset 8 (max).
Offset 0-5: t->v happens before the Y inc.
Offset 6: t->v happens both before and after the Y inc. (shakes)
Offset 7-8: t->v happens after the Y inc.

Do note that this is simply what nintendulator does, other emulators and hardware might differ.

As per usual, you can get the latest version from github (direct link to the rom).
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: Difference (Unl) shakes in my emulator

Post by Zepper »

fred wrote:For example, in nintedulator: the second "sta 0x2006" starts at dots 236-237 at offset 0, and dots 244-245 at offset 8 (max).
Offset 0-5: t->v happens before the Y inc.
Offset 6: t->v happens both before and after the Y inc. (shakes)
Offset 7-8: t->v happens after the Y inc.
Triangles are OK on offset 7 here.
Sour
Posts: 891
Joined: Sun Feb 07, 2016 6:16 pm

Re: Difference (Unl) shakes in my emulator

Post by Sour »

I made the change on Mesen to see the impact it could have.
It seems to fix Bart vs. the Space Mutants (USA), and doesn't break anything that I have noticed.

Out of the 223 automatic test roms I run on Mesen, only the following had a different visual output after the change:

Code: Select all

50) full_palette failed (477)
51) full_palette_smooth failed (325)
206) NEStress failed (80)
218) test_ppu_read_buffer failed (19)
Number in parenthesis = number of frames that do not match the original recording for the test.
Note that all 4 tests still pass, it's just that some frames have been affected by the change.

On top of the test roms, I also have 49 game test scenarios, a few of them have changes:

Code: Select all

10) Dragon Ball 3 - Gokuu Den (J) [!] failed (114)
17) Crisis Force (J) [!] failed (1)
29) Megaman III (U) [!] failed (293)
33) Super Mario Bros. 3 (J) (PRG1) [!] failed (3)
34) Castlevania III - Dracula's Curse (U) [!] failed (1)
36) Laser Invasion (U) [!] failed (1)
38) Klax (Tengen) [!] failed (2)
39) Skull & Crossbones (Tengen) [!] failed (178)
46) Fantastic Adventures of Dizzy, The (USA) failed (42)
48) MiG 29 - Soviet Fighter (USA) failed (222)
(Also: The Battletoads test is not affected by this change, but my test only covers the loading of level 1, it doesn't test the potential freezes on level 2)

I've checked all the games with a large amount of changed frames (>10) and visually, they appear to be no better or worse than before. All of these games have "glitches" on the screen due to imperfect screen splits, so I am assuming that the way the glitch displays may be slightly affected by this change.

Pre-fix, Mesen only displays the test's triangles properly at offset 7 & 8. (Offset 6 = unstable picture)
Post-fix, the triangles display properly for offsets 5, 6, 7 & 8. (Offset 4 = unstable picture)

So, this would still need to be validated on a NES, but it seems like the delay on the VRAM update after a $2006 write may actually be a thing.

Edit: It also fixes the screen shaking during the introduction sequence in Wizards & Warriors III (USA).
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Difference (Unl) shakes in my emulator

Post by zeroone »

Related to this discussion, does NMI suppression suggest that asserting NMI is actually delayed by a few PPU cycles? Meaning, the suppression is just a consequence of the delay (i.e. the flag is changed before the delay expired; so, it had no effect).
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: Difference (Unl) shakes in my emulator

Post by Zepper »

zeroone wrote:Related to this discussion, does NMI suppression suggest that asserting NMI is actually delayed by a few PPU cycles? Meaning, the suppression is just a consequence of the delay (i.e. the flag is changed before the delay expired; so, it had no effect).
What's the relationship between $2006 delay and... NMIs?
Last edited by Zepper on Fri May 04, 2018 2:24 pm, edited 1 time in total.
Sour
Posts: 891
Joined: Sun Feb 07, 2016 6:16 pm

Re: Difference (Unl) shakes in my emulator

Post by Sour »

Is there any chance someone could run fred's test on a NES and see what the results are? (i.e how are the triangles displayed for each of the 8 offset values)
The actual result is probably hidden on CRTs due to overscan, but I'm assuming capture cards should still be able to record it?

At the moment, (in Mesen) this change fixes Bart vs. the Space Mutants and Wizards & Warriors III. It also lets me remove an old patch I had implemented for Kick Master (and Kick Master still works correctly). Also, it makes blargg's full palette demo perfectly centered, instead of left aligned (and sometimes having 1 pixel cut off on the left side of the screen).
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Difference (Unl) shakes in my emulator

Post by zeroone »

The status bar in Bart vs. the Space Mutants and the castle scene in the intro of Wizards & Warriors III shake in Nintendulator 975, but they do not shake in Nintendulator 970. The primary difference between them is that version 970 contains a hack in which the X and Y increments occur 4 PPU cycles earlier than their actual scheduled times. It sounds likely that the delayed v-register write may fix that problem there also.

What was the Kick Master issue?
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: Difference (Unl) shakes in my emulator

Post by Zepper »

zeroone wrote:What was the Kick Master issue?
viewtopic.php?p=172287#p172287
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Difference (Unl) shakes in my emulator

Post by zeroone »

That link does not describe the Kick Masters issue. Was the title screen shaking?

Incredible Crash Dummies shakes in Nintendulator 975, but not in 970. The 970 hack actually seems to solve a lot of problems.
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: Difference (Unl) shakes in my emulator

Post by Zepper »

zeroone wrote:That link does not describe the Kick Masters issue. Was the title screen shaking?

Incredible Crash Dummies shakes in Nintendulator 975, but not in 970. The 970 hack actually seems to solve a lot of problems.
How so?
The Kick Master issue was caused by a race condition (write to $2006 at the same time as the cycle 256 Y scrolling increment). The game expects the $2006 value to win and the scrolling increment to be ignored (but it wasn't), which produced the weird effect on the title screen.

And... Crash Dummies is NOT a MMC3, but a Acclaim's MC-ACC chip with a different IRQ behaviour (clocked on falling A12).
Last edited by Zepper on Fri May 04, 2018 2:25 pm, edited 1 time in total.
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Difference (Unl) shakes in my emulator

Post by zeroone »

Zepper wrote:How so?
The Kick Master issue was caused by a race condition (write to $2006 at the same time as the cycle 256 Y scrolling increment). The game expects the $2006 value to win and the scrolling increment to be ignored (but it wasn't), which produced the weird effect on the title screen.


And... Crash Dummies is NOT a MMC3, but a submapper with a different IRQ behaviour.
Thanks. But, that describes the cause. I'm still unclear of the observed symptoms. Was the title screen shaking?
Post Reply