How do you find bugs in your emulator?

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
MottZilla
Posts: 2832
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla » Tue Jun 07, 2011 7:30 pm

oRBIT2002 wrote: Another strange bug I've got is that "Balloon Fight (E)", plays a song during titlescreen (the (US) doesn't, neither the (E) version in any other emulator). How do you bughunt such a thing? :)
Maybe it is related to the Power-Up state of your emulator? Try randomizing WRAM on power-up (not reset) rather than possibly zeroing all of RAM. Maybe be mindful of initial register states? Just some ideas.

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

Post by Zepper » Tue Jun 07, 2011 7:44 pm

It has a strong chance of reading RAM or any other PPU/CPU register.

albailey
Posts: 177
Joined: Thu Jul 13, 2006 3:15 pm

Post by albailey » Wed Jun 08, 2011 5:17 pm

I tried running lots of different test roms.
I found that I might pass a test, then implement something new (like IRQ) and end up breaking those earlier ROMs. Then I'd add APU (and its IRQ) and re-break things again.

Galaxian and Super Mario Bros (title screen) are 2 games I could never diagnose.

Maybe someday I'll go back and try some more. I got tired of spending my evenings and not seeing any progress (or making things worse).

Al

User avatar
oRBIT2002
Posts: 623
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Post by oRBIT2002 » Wed Jun 08, 2011 10:58 pm

albailey wrote:I tried running lots of different test roms.
I found that I might pass a test, then implement something new (like IRQ) and end up breaking those earlier ROMs. Then I'd add APU (and its IRQ) and re-break things again.

Galaxian and Super Mario Bros (title screen) are 2 games I could never diagnose.

Maybe someday I'll go back and try some more. I got tired of spending my evenings and not seeing any progress (or making things worse).

Al
"Super Mario Bros" stores some of it's titlescreen data in CHRROM so if your PPU-reading code is broken, this is a good title to verify that. :)

User avatar
oRBIT2002
Posts: 623
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Post by oRBIT2002 » Thu Jun 09, 2011 8:48 am

Have anyone tested the NESStress ROM on a real NES? Would be interesting to see the results...

tepples
Posts: 22050
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Thu Jun 09, 2011 8:53 am

I can run it tonight on my PowerPak if it doesn't depend on power-up state.

User avatar
oRBIT2002
Posts: 623
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Post by oRBIT2002 » Thu Jun 09, 2011 9:14 am

tepples wrote:I can run it tonight on my PowerPak if it doesn't depend on power-up state.
That'd be great!

tepples
Posts: 22050
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Thu Jun 09, 2011 1:12 pm

This is very strange.


PPU Test 1: 11/11
7 rows of digits 0-9, except the 5 is missing in the second.
Most rows "Ok". Palette readback is "DPjr", but once I managed to get it to say "Error".

PPU Test 2: 11/13
I am Error, five times.

PPU Test 3: 12/14
Bit 7 cleared after read: Ok

pAPU: 0/0

CPU test: 48/48
All Ok

On the controller test screens, player 2's controller doesn't respond.
On the second, only up, down, left, and right work, not Se, St, B, or A.
I haven't tried it with a Four Score because I don't own one.

On the menus, sometimes pressing and holding select results in glitching, as if the TV momentarily loses sync.

But I'd take this result with a grain of salt. The controller test screen somehow causes writes back to the PowerPak's CHR RAM, even though this tester is supposed to be using CHR ROM (that is, write-protecting CHR RAM).

6T4
Posts: 48
Joined: Sat Feb 19, 2011 8:56 pm

Post by 6T4 » Thu Jun 09, 2011 9:27 pm

I have some comments and questions about the NEStress test rom. First, I have been trying it on many emulators... three of which I'm going to talk about here: Nestopia, Nintendulator, and FCEUX. Nestopia and Nintendulator performed almost exactly the same as tepples described. I enabled four-score in Nestopia and two-players in Nintendulator, they both only read from player 1. FCEUX had differences in the PPU and Controller Tests. In, the PPU, it gave Error for PPU Palette Write/Read and Ok for Sprite Collision and Sprite Limiter. For controllers with four-score enabled, it read ports 1 and 3 (which are both $4016) but not 2 and 4.

Now I have some questions. First, what's with all the 4's? If you don't know what I'm talking about, run the Controller Test in one of the 3 emulators I mentioned. For the $4016 reads, you should get 4040404040404040. However, some other emulators (such as Nestreme) display all zeroes. The 0s are what change when you press the corresponding button. Also, why is this a 16-digit number instead of 8, corresponding to the 8 bits? Is it hexadecimal?

The next thing I have to ask isn't specific to the NEStress ROM, but the Controller Test really makes it noticeable: Signature Bits. I have found very little information about this in the documentation on this site and wondered if anyone knew how these bits change for all the different peripherals.

And some questions for tepples: What model of the NES did you run NEStress.nes on? And how did you manage to get the Palette readback to say Error?

NickMass
Posts: 15
Joined: Tue Mar 30, 2010 7:59 pm

Post by NickMass » Thu Jun 09, 2011 11:00 pm

6T4 wrote: Now I have some questions. First, what's with all the 4's? If you don't know what I'm talking about, run the Controller Test in one of the 3 emulators I mentioned. For the $4016 reads, you should get 4040404040404040. However, some other emulators (such as Nestreme) display all zeroes. The 0s are what change when you press the corresponding button. Also, why is this a 16-digit number instead of 8, corresponding to the 8 bits? Is it hexadecimal?
The NEStress controller readout displays 8 8-bit reads of the controller registers per row so 4040404040404040 is really the hexadecimal number 40 being read 8 times in a row. The reason it reads as 40 instead of 00 is because the upper 2 bits of the controller registers return open bus which in this case happens to have 40 on it.
6T4 wrote: The next thing I have to ask isn't specific to the NEStress ROM, but the Controller Test really makes it noticeable: Signature Bits. I have found very little information about this in the documentation on this site and wondered if anyone knew how these bits change for all the different peripherals.
The only input device I know of where signature bits are a factor is the Four Score and the details of the bits are covered on the wiki page here http://wiki.nesdev.com/w/index.php/Four_Score other input devices tend to just repeat a meaningless value over and over after the first 8 reads.

tepples
Posts: 22050
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Fri Jun 10, 2011 4:37 am

6T4 wrote:And some questions for tepples: What model of the NES did you run NEStress.nes on?
NES-001 (NTSC front loader). I haven't opened it up to see the revisions of the CPU and PPU.
And how did you manage to get the Palette readback to say Error?
I don't know how I did it. When I tried to reproduce, it went back to DPjr.

User avatar
oRBIT2002
Posts: 623
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Post by oRBIT2002 » Fri Jun 17, 2011 6:41 am

Now I am getting annoyed. Some games just refuse to run and just locks up.
Examples:
* Pro Wrestling (locks when pressing start)
* Rush'n Attack (locks up when pressing start)
* Jackal (blank screen)

I've done logs that traces the code but there's lots and lots of code executed (not just a cmp/bne loop that I was hoping for :)) which makes it difficult to trace.
My CPU core pass' the Nesstress-test, and I pass blaargs vbl_nmi_timing/framebasics-test aswell.

Anyone notices anything special about these games? Konami? Mapper 2? Anything else?

User avatar
cpow
NESICIDE developer
Posts: 1097
Joined: Mon Oct 13, 2008 7:55 pm
Location: Minneapolis, MN
Contact:

Post by cpow » Fri Jun 17, 2011 8:03 am

oRBIT2002 wrote:I've done logs that traces the code but there's lots and lots of code executed (not just a cmp/bne loop that I was hoping for :)) which makes it difficult to trace.
Is there absolutely *no* looping detectible in the log? Perhaps you could post the tail 100 entries or so, or PM me more than that? Then one of us could set up a breakpoint in our emulators at or around the address you're at and have at least a ballpark idea of where to start looking. Even with that, it still might be a needle in a haystack, but the haystack right now is the size of the universe. Narrow it down a bit, please!

User avatar
oRBIT2002
Posts: 623
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Post by oRBIT2002 » Fri Jun 17, 2011 10:30 am

Yes, repeatable code is detected. The link below links to a textfile (if anyone's interested) that buffer the last 2500 opcodes from my emulator.
The textfile looks like this (see below).
First two bytes are address, next byte, opcode + data after opcode (4 bytes per opcode).

Code: Select all

	DC.B	$D0,$ED,$0A,$90,$D0,$EE,$90,$09
	DC.B	$D0,$F9,$88,$C0,$D0,$FA,$C0,$FF
	DC.B	$D0,$FC,$D0,$EC,$D0,$EA,$B9,$AA
	DC.B	$D0,$ED,$0A,$90,$D0,$EE,$90,$09
	DC.B	$D0,$F9,$88,$C0,$D0,$FA,$C0,$FF
	DC.B	$D0,$FC,$D0,$EC,$D0,$EA,$B9,$AA
	DC.B	$D0,$ED,$0A,$90,$D0,$EE,$90,$09
By quickly browsing through the "code", repeatable patterns obviously are detected. I've tried debugging these locations with FCEUX or Nintendulator but haven't had much luck yet in locating the problem..

Here's the file how it looks when Start-button had been pressed on the "pro wrestling (E)" titlescreen and the game just halts (and music goes silent).
http://dl.dropbox.com/u/2590713/ProWrestlingDump.txt

By the way, lda $2002, bpl - kind of stuff isn't logged.

User avatar
cpow
NESICIDE developer
Posts: 1097
Joined: Mon Oct 13, 2008 7:55 pm
Location: Minneapolis, MN
Contact:

Post by cpow » Fri Jun 17, 2011 11:41 am

oRBIT2002 wrote: By the way, lda $2002, bpl - kind of stuff isn't logged.
Ur...why? Do you mean: "I log a single line if I detect such looping so as not to pollute my log." or "I don't log any lda $2002, bpl sequences or even an indication that it occurred."

Given that that sequence is probably, what, the second-most-common way (first-most-common being bit $2002, bpl) of testing for vblank or sprite 0 hit (well i suppose that would be bvc), hopefully you're logging *something* if it occurs?

Post Reply