Things to do on startup
Page 2 of 2

Author:  tepples [ Thu Aug 11, 2005 1:37 pm ]
Post subject: 

Bregalad wrote:
Also I don't know it it's needed to initialize the CPU ram between the two VBlank waits.

It's not. A lot of official games do the vblank waits one after another. It's just that the time between the vblanks is just a very convenient time to clear CPU RAM, as what else do you have to do during nearly 30,000 CPU cycles between vblank #1 and vblank #2?

About the $700-$702 stuff, I think he's just checking for particular value in theese 3 bytes, to check if it's the first boot or not. So, he doesn't clear $700-$7ff if it isn't the first boot.


Author:  tokumaru [ Thu Aug 11, 2005 4:47 pm ]
Post subject: 

I read somewhere that initializing the stack is quite pointless too... the explanation said that the SP value didn't matter at all, as the stack page is fixed and it warps around once we get to the end (or gegining) of the page...
So, you'll have your 256 stack bytes, no matter where the stack pointer points too in the begining of the program...

I don't know if this is true, but makes sense to me...

Author:  Quietust [ Thu Aug 11, 2005 5:05 pm ]
Post subject: 

If you're short on memory and know the maximum amount of stack space you're going to use, you can allocate variables within the empty space at the bottom of the stack.

Author:  Disch [ Thu Aug 11, 2005 5:08 pm ]
Post subject: 

Plus if your stack is split on the page boundary, you'll have problems with reading pushed values:

LDA $103,X  ; read 3rd-last pushed value -- will not work if SP wrapped

Author:  tokumaru [ Thu Aug 11, 2005 5:24 pm ]
Post subject: 

Ok, you might have problems if you are going to do direct manipulations to the stack. But if you just use push an pull you're safe, right?

I can understand why one might want to have the stack aligned to the memory page, but it's not mandatory to do so...

Author:  Memblers [ Thu Aug 11, 2005 5:46 pm ]
Post subject: 

Right, it's not mandatory. But considering that programs I've seen rarely go more than 16 bytes deep or so, the whole page is pretty much going to waste. And that's nearly 1/8th of the CPU's RAM.

Author:  Bregalad [ Fri Aug 12, 2005 12:40 am ]
Post subject: 

I just noticed, using FCEUltra, that Megaman and Megaman 2 doesn't write anything to $4017, but thoose two DOES use the triangle timer, wich is, I belive, based on the 4 steps or 5 steps sequences.

Author:  blargg [ Fri Aug 12, 2005 7:01 am ]
Post subject: 

On reset and power-up, $00 is internally written to $4017 before the CPU starts execution. This begins the 4-step sequence and enables the APU's frame IRQ flag (but the I flag is set so it won't occur until a CLI or equivalent).

Page 2 of 2 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group