For example, recently I was trying to figure out how I could build a generic stack of PPU changes that can be popped off during the VBlank and be built outside of this time. This was my attempt at a solution:
Input Variables:
StackSize - 1 byte integer (0 to 255) that tracks how many elements are in the stack. (Assumed to be on Zero Page)
StartHiByte - 2 byte address that points to the start of stack for where the High Byte of the PPU address will be stored
StartLowByte - 2 byte address that points to the start of the stack where the Low Byte of the PPU address will be stored
StartValue - 2 byte address that points to the start of the stack where the Value Byte that will be stored at the PPU address
Algorithm:
Code: Select all
LDA $2002 ; Reset Hi/Low Bit
LDX StackSize ; Load Stack Size into X Register
NextLabel:
LDA StartHiByte, X;
STA $2006
LDA StartLowByte, X;
STA $2006
LDA StartValue, X;
STA $2007
DEX
BNE NextLabel:
ROM Cost: 26 Bytes
Cycle Cost: 6 + 29 * StackSize
At 2200 cycles available to make PPU changes that gives me about 75 value changes per VBlank.
I understand that if the changes are ordered, such as with Sprite RAM, I can DMA more efficiently.
So my questions for everyone are:
1. How does everyone else manage their PPU changes and VBlank Timing? Am I even in the ballpark?
2. And is there a single repository of algorithms somewhere (such as nametable compression).
3. What one tool would make programming NES games easier for you?
Thank you!
[EDIT:] Grammar