Difference (Unl) shakes in my emulator

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Difference (Unl) shakes in my emulator

Post by zeroone »

GoodNES3.23b includes an unlicensed ROM called Difference. It's an MMC3 ROM and, as you can see in the animated GIF below, the green bar at the bottom shakes.

Image

This does not appear to happen in any other emulator. I never noticed issues with other MMC3 ROMs. Any suggestions for how to track down the source of this problem?
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 »

It's a race condition between $2006 and the Y-increment at PPU scanline cycle 256. If the $2006 write occurs a bit before cycle 256 (here after 254th), the Y-increment should NOT occur.
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:It's a race condition between $2006 and the Y-increment at PPU scanline cycle 256. If the $2006 write occurs a bit before cycle 256 (here after 254th), the Y-increment should NOT occur.
Interesting. What about if it coincides with an X-increment? Do you have a link to more information about this race condition?

Edit: Also, a $2006 write might not affect the v register. What if it only updates the t register?
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 »

The only information is in this discussion, here.
Alyosha_TAS
Posts: 173
Joined: Wed Jun 15, 2016 11:49 am

Re: Difference (Unl) shakes in my emulator

Post by Alyosha_TAS »

Interesting, I'm not getting any shaking with or without accounting for the $2006 race condition.
Are you sure it's not an IRQ timing 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 »

Alyosha_TAS wrote:Interesting, I'm not getting any shaking with or without accounting for the $2006 race condition.
Are you sure it's not an IRQ timing issue?
Unless the MMC3 test ROMs are not enough... My emulator passes in all tests.
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 »

It does not shake in Nintendulator 970. Here is the write $2006 code for that version:

Code: Select all

static	void	__fastcall	Write6 (int Val)
{
	if (HVTog)
	{
		IntReg &= 0x00FF;
		IntReg |= (Val & 0x3F) << 8;
	}
	else
	{
		IntReg &= 0x7F00;
		IntReg |= Val;
		VRAMAddr = IntReg;
	}
	HVTog = !HVTog;
}
It updates the v register (VRAMAddr), the t register (IntReg) and the w register (HVTog) immediately. There is no indication of write suppression that I can see.

I will carefullly read through your thread. I see it mentions Kick Master title screen issues, but I never noticed any.
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: There is no indication of write suppression that I can see.
Who said "write suppression"? I said that a write to $2006 may occur a few PPU cycles before the Y-increment at PPU cycle 256. If such write was done, the Y-increment should NOT occur. Otherwise, we'll have $2006 scroll value PLUS 1.
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:Who said "write suppression"? I said that a write to $2006 may occur a few PPU cycles before the Y-increment at PPU cycle 256. If such write was done, the Y-increment should NOT occur. Otherwise, we'll have $2006 scroll value PLUS 1.
Here's the Nintendulator 970 code for the Y-increment:

Code: Select all

			if ((VRAMAddr & 0x7000) == 0x7000)
				{
					register int YScroll = VRAMAddr & 0x3E0;
					VRAMAddr &= 0xFFF;
					if (YScroll == 0x3A0)
						VRAMAddr ^= 0xBA0;
					else if (YScroll == 0x3E0)
						VRAMAddr ^= 0x3E0;
					else	VRAMAddr += 0x20;
				}
				else	VRAMAddr += 0x1000;
There is no check to see if a $2006 write occurred shortly before or after.
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 »

I didn't take such thing from Nintendulator. You're looking for something NULL. Don't be boring.
I already told you what's the issue regarding the score shaking. Probably it's an hack. Feel free to analyze a Nintendulator CPU log and compare it with yours... or ask Q directly.
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:I didn't take such thing from Nintendulator. You're looking for something NULL. Don't be boring.
I already told you what's the issue regarding the score shaking. Probably it's an hack. Feel free to analyze a Nintendulator CPU log and compare it with yours... or ask Q directly.
The green bar does not shake in Nintendulator. If it is a race condition, I would expect a similar check required in the Nintendulator code.

I prefer not to add in hacks to make specific games function. Even if the test ROMs pass, it may break some other games.
Alyosha_TAS
Posts: 173
Joined: Wed Jun 15, 2016 11:49 am

Re: Difference (Unl) shakes in my emulator

Post by Alyosha_TAS »

I'm not logging any $2006 race condition cases from Difference.
The log shows plenty from Kick Master so I'm pretty sure I'm logging and emualting it correctly.

I've never quite been confident in MMC3 IRQs so to me this is an interesting new test case. I'll try to see if there is any combination of things I can do to reproduce this shaking.
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:I prefer not to add in hacks to make specific games function. Even if the test ROMs pass, it may break some other games.
You're misunderstanding the things again. It's unrelated with the MMC3 IRQ test ROMs!
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 »

This game does not appear to run correctly in NO$NES. The green bar does not render properly.
fred
Posts: 67
Joined: Fri Dec 30, 2011 7:15 am
Location: Sweden

Re: Difference (Unl) shakes in my emulator

Post by fred »

I very briefly tested writes to 0x2006 a while back in visual nes. It did seem like setting vramaddr_v to vramaddr_t in the second write was delayed a few ticks (~3?). I don't know the inner workings of the ppu enough to tell for certain.

The status bar in bart vs the space mutants that relies on a 6-5-5-6 series of writes stops shaking in my emulator if i delay the v = t effect for 3 ppu ticks. My cpu-ppu sync is not good enough to prove anything though, as evident by battletoads stage 2 crashing even faster with this change.
Post Reply