I've got a gme that works fine on my NTSC NES units, fine in emulators like Nintendulator and FCEU, but on some people's NTSC NES systems they see weird PPU problems. I've tried walking it line by line and I dont see anything glaring. And since I dont have a system to reproduce these problems, its difficult to know if I am on the right track.
How do you guys track down bugs in your games?
Does anyone have a lint like tool to detect possible run time problems?
Does anyone have a list of proper coding practices (like read 2002 before writing to 2006)?
Is Patrick Diskin's (Aug 2004) NesDoc.pdf the best resource for me to track down my problems?
Does anyone know an emulator that can be put in a more unpredictable mode (random values in uninitialized memory, etc..) to more readily create these types of real world problems?
Al
Are you using Powerpak to test it on other people's consoles? That could be the problem.
So far I've been testing using a dev cart made from an NROM donor, as well as using emulators. I didnt use PowerPak because I wanted to eliminate that as a factor (I don have the resisterized version yet)
I believe my problem/situation is this:
The screen is currently displaying name table 2000
I wish to write an entire 1024K name table to 2800.
I do the following in my NMI handler.
- I turn off display (writing 0 to $2000 and $2001),
- I entirely write the name table data to 2800
- I turn back on the display and begin scrolling (display is at 2000 and I vertically scroll to 2800)
I'm guessing something I am doing is illegal.
Perhaps I need to wait after turning off $2000 and $2001, or I need to wait for vlank before turning them back on.
I'll try to post some code snippets. I was just looking for some ideas on hw you guys deal with unusual bugs.
Al
Are you waiting for the PPU to warm up?
Games generally turn off the PPU then wait for at least 1 full frame before doing other PPU stuff.
Code:
LDA #$00
STA $2000
STA $2001
: LDA $2002
BPL :-
: LDA $2002
BPL :-
; now safe to start drawing
If you do this at srartup... and you're doing all your drawing with the PPU off, you should be okay.
EDIT:
Also... yeah you should wait until VBlank before you switch the PPU back on or else the screen might be scrolled to all the wrong spot for the first frame.
I think thats at least one of my problems.
I was just turning display back on without doing the wait for vblank
:lda $2002
bpl :-
Without this, the screen appeared to flicker (although the flicker went away). Maybe the behaviour varies depending on when I turn it on, and can last more than one frame.
I assume I only need the 2 cycle warmup in my reset handler, and not everytime I turn off the PPU.
Al
If your game is a vertical scroller, consider updating nametables 1 line at a time, as each line scrolls into view, rather than updating the whole nametable at once. This way, you don't have to turn off the screen during updates since there's plenty of VBlank time to update a single row of tiles per frame.
Display should only be turned on/off during VBlank. Also, you should always use NMI to detect VBlank instead of $2002 polling (except on power-up).
OK, makes sense.
The scrolling is just to transition from the title screen to the main screen so I dont mind the brief screen turn off.
I'm actually in my NMI when I turn display off (which turns off further NMI calls), I just wasnt waiting for another vblank after writing all that data.
Thanks for the help guys.
Al