nesdev.com
http://forums.nesdev.com/

Problem with nestest
http://forums.nesdev.com/viewtopic.php?f=3&t=7051
Page 1 of 4

Author:  Vash [ Sat Oct 16, 2010 3:36 pm ]
Post subject:  Problem with nestest

Hi guys!

I'm developing a nes emulator. I tested it with nestest on automation (I don't have any PPU, just the CPU working). I got a problem with this line :
Quote:
CDAD BA TSX A:00 X:00 Y:99 P:27 SP:FB CYC: 58 SL:257

The result is that the X register has the value : 0xFB.

It's not working on my emulator because the value 0xFB is never pulled on the stack. Even with the log I can't find where it's pulled.

So can someone tell me what I miss there?

Thanks.

Author:  tepples [ Sat Oct 16, 2010 3:37 pm ]
Post subject: 

TSX copies the stack pointer itself, not any specific value from the stack, into X.

SP:FB + TSX = X:FB

Author:  Vash [ Sun Oct 17, 2010 12:03 am ]
Post subject: 

Ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh!!!!!!!!!!!!!!!!!!

Now it makes sense.

Thanks for your help. I would have never figured it out by myself, I was so focused on the fact that everything was about push and pop that I didn't even read the doc correctly.

Author:  Vash [ Thu Oct 21, 2010 9:18 am ]
Post subject: 

Ok now all the opcodes work correctly but can someone explain me what is CYC and SL in the nestest log. First I thought that CYC was the number of cycle but it doesn't seem to be that.

Thanks for your help.

Author:  tokumaru [ Thu Oct 21, 2010 10:08 am ]
Post subject: 

Vash wrote:
can someone explain me what is CYC and SL in the nestest log.

Given that CYC wraps around at 341, I'd say that's the PPU cycle within the scanline, which is what SL means.

Author:  blargg [ Thu Oct 21, 2010 10:15 am ]
Post subject: 

That log really shouldn't be like that. It should either have just a cycle counter that never rolls over, or no cycles at all, since it's not a timing test anyway.

Author:  Vash [ Thu Oct 21, 2010 10:16 am ]
Post subject: 

Thank you for your answer.

So if I got it right, the CYC is the number of cycle of the opcodes wraped around at 341.
I don't understand how SL is calculated cause in the nestest log, it begins at 241 and sometimes goes back to -1.

Author:  tokumaru [ Thu Oct 21, 2010 10:43 am ]
Post subject: 

Vash wrote:
So if I got it right, the CYC is the number of cycle of the opcodes wraped around at 341.

Each scanline is 341 PPU cycles long, no matter if the console is NTSC (where each CPU cycle equals 3 PPU cycles) or PAL (where each CPU cycle equals 3.2 PPU cycles).

Quote:
I don't understand how SL is calculated cause in the nestest log, it begins at 241 and sometimes goes back to -1.

There are 262 scanlines in a frame, 240 of those are visible. The log probably starts at 241 because that's the start of VBlank. The one numbered -1 is the pre-render scanline.

Author:  blargg [ Thu Oct 21, 2010 11:30 pm ]
Post subject: 

I was going to remove that from the log (and zip it), but then I noticed that it has a disassembly, and even shows what is read from memory by read instructions. We really should have a log that just shows PC, A, X, Y, P, S, with no disassembly or anything else. That'd be much easier to generate for someone just getting their CPU core working.

Author:  tepples [ Fri Oct 22, 2010 4:21 am ]
Post subject: 

blargg wrote:
We really should have a log that just shows PC, A, X, Y, P, S, with no disassembly or anything else.

It looks like a job for a Perl one-liner.

Author:  blargg [ Fri Oct 22, 2010 5:37 am ]
Post subject: 

Well, yeah, it's simple to do with a regexp-style replacement. But we must first agree on the format before updating it. Here's one I used to give the following format:
Code:
find: (....)  ............................              (.........................)[^\r]+
replace: PC:\1 \2


Also went and made these replaceents, since P doesn't implement bits 4 and 5:

" P:2" " P:0"
" P:6" " P:4"
" P:A" " P:8"
" P:E" " P:C"

Changed SP to S, since S is the proper name of the register.

Changed : to = sign, the proper mathematical symbol.

We end up with this:

PC=C000 A=00 X=00 Y=00 P=04 S=FD

Any other changes before I update the Wiki with this one?

Author:  tepples [ Fri Oct 22, 2010 5:51 am ]
Post subject: 

blargg wrote:
Well, yeah, it's simple to do with a regexp-style replacement. But we must first agree on the format before updating it.

My idea was that each emulator author would make his own RE to thin the log down to the data he needs. On the other hand, the ability to disassemble is a good first step toward making a debugger.

Author:  blargg [ Fri Oct 22, 2010 7:17 am ]
Post subject: 

OK, maybe I'll post a zip of the full log, and this condensed version. No reason not to provide the latter, as a starter that's trivial to compare with.

Author:  Vash [ Fri Oct 22, 2010 9:36 am ]
Post subject: 

Well now I have my CPU working so I will start the PPU now but there is something I don't understand.

When is frame rendered?

Author:  tepples [ Fri Oct 22, 2010 9:57 am ]
Post subject: 

The PPU renders continuously, from line 0 through line 239, at one dot per CYC in the log (three dots per NTSC CPU cycle). A few fetches for line 0 are performed at the start of line -1.

Page 1 of 4 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/