Fixing Nestest failiures

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
blargg
Posts: 3717
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg »

Every instruction failed, so it's some instruction or behavior that's causing them all to fail. I noticed I hadn't uploaded a newer version of the test that's more robust to emulator errors like this. instr_test-v2. This uses a pre-computed CRC table and makes extra sure the APU IRQ is turned off, even if an emulator handles it wrong in some ways.
User avatar
Zepper
Formerly Fx3
Posts: 3264
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper »

All 15 tests passed. Sweet. :)
User avatar
comegordas
Posts: 53
Joined: Sat Aug 14, 2010 7:12 pm

Post by comegordas »

Blargg, and what about this?

Code: Select all

DB9E  8D 00 03  STA $0300 = 01                  A:A9 X:07 Y:00 P:E5 SP:FB CYC:114 SL:63
DBA1  A9 AA     LDA #$AA                        A:A9 X:07 Y:00 P:E5 SP:FB CYC:126 SL:63
DBA3  8D 01 03  STA $0301 = 00                  A:AA X:07 Y:00 P:E5 SP:FB CYC:132 SL:63
DBA6  A9 60     LDA #$60                        A:AA X:07 Y:00 P:E5 SP:FB CYC:144 SL:63
DBA8  8D 02 03  STA $0302 = 00                  A:60 X:07 Y:00 P:65 SP:FB CYC:150 SL:63
DBAB  20 B5 DB  JSR $DBB5                       A:60 X:07 Y:00 P:65 SP:FB CYC:162 SL:63
DBB5  6C FF 02  JMP ($02FF) = A900              A:60 X:07 Y:00 P:65 SP:F9 CYC:180 SL:63
0300  A9 AA     LDA #$AA                        A:60 X:07 Y:00 P:65 SP:F9 CYC:195 SL:63
JMP ($02FF) = A900, and afther that the PC is at 0300, and not at A900. did i get wrong the indirect addressing mode?[/code]
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

Indirect jump is bugged on the 6502, it doesn't add 1 to the full 16-bit value when it reads the second byte, it adds 1 to the low byte only.
So JMP (03FF) reads from 3FF and 300, not 3FF and 400.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
comegordas
Posts: 53
Joined: Sat Aug 14, 2010 7:12 pm

Post by comegordas »

thanks Dwedit. didn't know that. why there's SO many errors on the doc's!? read severall 6502 docs and never found that :\
is there any errorless doc that you can point me to learn the correct behavior of the addressing modes? at this point there's no doc that i can trust in :(
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

Every ZP,X instruction does an 8-bit add, and wraps back to 00 if it exceeds FF. Hence why it's Zeropage,X. Same idea with Indirect,X addressing, it pulls the two address bytes entirely from within the zero page.

Some instructions have a one-cycle penalty for when computed addresses cross a 256-byte boundary (a 'page').
For example, lda 02FF,X takes one more cycle to execute if X >= 1, so it must adjust the high byte of the address.
Branch instructions (BNE, BEQ, etc) also have a penalty if the branch address target is on a different page than the address _after_ the branch instruction.

The document here lists what all the instructions do at each cycle:
http://nesdev.com/6502_cpu.txt

This document is also a nice summary for telling you which instructions have the cycle penalties (but has other errors, for example, is says that PLA doesn't affect flags when it does.)
http://www.masswerk.at/6502/6502_instruction_set.html
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
comegordas
Posts: 53
Joined: Sat Aug 14, 2010 7:12 pm

Post by comegordas »

thanks! :wink:
User avatar
comegordas
Posts: 53
Joined: Sat Aug 14, 2010 7:12 pm

Post by comegordas »

BTW, i'm having something strange with this rom. that tile "*" is not getting showed on my emulator, and i can't figure out why.

Nestest on FCEUX:

Image

Nestest on my emulator:

Image

i've loaded the rom in FCEUX and in VirtuaNES and then see what the Name Table Viewer shows, and in both emulators the tile "*" is marked as background data (not as sprite data). but anyway this tile doesn't shows up on my emulator as a background tile, neither as a sprite :(
Post Reply