It is currently Mon Nov 18, 2019 1:56 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Tue Mar 11, 2008 11:56 am 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
I think I've got most of the PPU power/reset behavior and timing determined and verified with test ROMs (so you can test your emulator too). I put the findings on the NesDevWiki. As usual, full ca65 source code included.

ppu_power_reset3.zip

EDIT: added test for $2000 low two bits and updated Wiki and test ROMs. Thanks for the trick, dvdmth.


Last edited by blargg on Thu Mar 13, 2008 4:47 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 11, 2008 12:14 pm 
Offline

Joined: Wed Mar 22, 2006 8:00 am
Posts: 354
Quote:
- My devcart is locked to single-screen nametable mirroring, so I can't test the low two bits in $2000.

You can use the following $2005/2006 magic to test those two bits:
Code:
bit $2002
lda #0
sta $2005
sta $2005
sta $2005
sta $2006

This will make the active VRAM address either $0000, $0400, $0800, or $0C00, depedning on $2000 bits 0-1. The writes to $2005 cause all 15 bits of the "scroll latch" registers to become clear, except the nametable select bits. The fourth write (the one to $2006) forces the contents of the latch to be transferred to the VRAM address register. Bits 0-1 of $2000 correspond to bits 10-11 of the VRAM address.

_________________
"Last version was better," says Floyd. "More bugs. Bugs make game fun."


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 12, 2008 9:50 pm 
Offline
User avatar

Joined: Thu Mar 24, 2005 3:17 pm
Posts: 355
After implementing your recent findings, Tiger Heli (U), Kamen Rider Club (J), and maybe more, won't boot in my emu due to PPU register writes being ignored in the 1st frame. These do work by doing a reset afterwards though.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 13, 2008 10:39 am 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
Same here after implementing the ignored writes in my emulator. I extracted the init code from Tiger-Heli and sure enough, it fails to enable NMI often at power on my NES. On further testing, I found that if I power the NES down for several seconds between tests, then it works most of the time. So apparently the VBL flag is usually clear at power if the NES was off for a while, and often set if it was recently on. What's the other game that someone was saying needed the VBL flag set at power?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 13, 2008 11:01 am 
Offline
User avatar

Joined: Thu Mar 24, 2005 3:17 pm
Posts: 355
$2002 power on with $00 instead of $A0:
- Ironsword: locks up at titlescreen with "Ironswor" and no sword in his hands
- Cobra Triangle: locks up when starting game

btw1: I probably don't need to mention that a lot of homebrew stuff fails.
btw2: $2007 read buffer.nes usually succeeds if I leave $2007 read buffer unchanged after reset, instead of setting it to 0


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 13, 2008 11:23 am 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1849
Has emulation accuracy finally reached the point at which the user will have to reload ROMs or <s>blow in the cartridge, or</s> press Reset a bunch of times in order to get games to work? hahaha

Anyway, great work as usual, blargg! Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 13, 2008 11:28 am 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
Quote:
$2007 read buffer.nes usually succeeds if I leave $2007 read buffer unchanged after reset, instead of setting it to 0

Odd. Are you modifying it during rendering? It should only be modified when the 2A03 reads from $2007 (and its mirrors). The test sets PPUADDR to $0010, which is the beginning of a run of $FF bytes, then reads from PPUDATA, which should put $FF into the buffer. Then it goes into an infinite loop, so the buffer should still contain $FF after reset if your emulator isn't clearing it during reset.

On the hunch that maybe the VBL flag is getting cleared during the first frame, I tried delaying 26000 clocks then reading $2002 after power, and quickly powering off then on several times. I still got $80, so the VBL flag isn't getting cleared before it's next set at ~27384. Oh well.

We need someone with Tiger Heli, Ironsword, and Cobra Triangle (PowerPak won't suffice) to see how often they work when powering up the NES after being off for a while, and after being off for only a couple of seconds. I'm guessing some won't work all the time in these cases. I'm going to see if I can extract the init code from each and test it on my NES.

I found a couple of old threads dealing with this issue "Let's uncover power-up and reset behavior" and "APU Frame IRQ Flag and IRQ Timing".


Last edited by blargg on Thu Mar 13, 2008 11:48 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 13, 2008 11:42 am 
Offline
User avatar

Joined: Thu Mar 24, 2005 3:17 pm
Posts: 355
Quote:
Are you modifying it during rendering?
hmmmmm... *shameful yes*
none of your test roms cover it ;)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 13, 2008 11:46 am 
Offline
User avatar

Joined: Mon Sep 27, 2004 2:13 pm
Posts: 1668
I can't get Ironsword to not work on my Famicom.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 13, 2008 11:49 am 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
OK, Ironsword doesn't have the problem because the loop that clears APU registers reads the register first since it uses the STA $4000,x addressing mode. So that reads $4015 after the frame IRQ flag has been set. This game should work regardless of the VBL flag at power. Same issue for Cobra Triangle (I checked init code too).

hap wrote:
Quote:
Are you modifying it during rendering?
hmmmmm... *shameful yes*
none of your test roms cover it ;)

Yes indeed, I need to write one for this. So it's good you had this bug. :)


Last edited by blargg on Thu Mar 13, 2008 2:02 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 13, 2008 11:56 am 
Offline
User avatar

Joined: Thu Mar 24, 2005 3:17 pm
Posts: 355
Quote:
OK, Ironsword doesn't have the problem because the loop that clears APU registers reads the register first since it uses the STA $4000,x addressing mode. So that reads $4015 after the frame IRQ flag has been set.
Ah, good find, didn't know that that was an "RMW"? instruction. Maybe you could improve your NES CPU opcode test program to include such cases?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 13, 2008 12:16 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7747
Location: Chexbres, VD, Switzerland
I have the PAL Ironsword, but I have trouble to make it working right now, like everyother NES cartridge I have. I have to reset some 60 times or so to get a boot with very corrupted graphics. Seems like a bit of cleaning will be needed.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 13, 2008 1:20 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
I think the dummy read for STA ABS,X addressing mode solves the problem, so no NES tests are needed for Ironsword and Cobra Triangle. I still predict that Tiger-Heli will fail if powered down then up without a long delay between.

hap, here's a new test ROM that verifies that $2007 is unchanged during rendering: Rendering_and_$2007_buf.nes.zip


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 13, 2008 1:43 pm 
Offline
User avatar

Joined: Thu Mar 24, 2005 3:17 pm
Posts: 355
yeah, that test rom fails here (for now)
Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 13, 2008 3:14 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
Oh lovely, if I power the NES off for 20 seconds or so, at power PPUADDR is $0000, SPRADDR is $2F, and most registers work immediately, rather than being ignored until 29658. Time for more test rewriting.. maybe I can hit 40 or 50 test ROMs! Bleah.

EDIT: OK, got a big rewrite of the PPU power/reset test ROMs done, and covering these new findings ("only" 37 test ROMs). NesDevWiki page is updated as well. Main finding was that if the NES is off for 20 seconds or more, all registers work at power, and $2002, $2003, and $2006 are 0.

ppu_power_reset3.zip


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group