AllDarnDavey
Active member
You may know that the NES can only display up to 8 sprites on a horizontal scanline. That's 8, 8x8 blocks, not 8 objects... so if enemies are just 2blocks wide after 4 in a row you get problems. Anything after the first 8 are just invisible and it isn't necessarily the first 8 left to right, it's the order they're drawn by the CPU.
You probably remember the flicker many NES games had. This is caused by sprite cycling. The flicker is mildly annoying, but it's tonnes better then getting killed by enemies or projectiles you can't see. Basically, you still only see 8 sprites per scanline, but you cycle the sprites being turned off to a different one every frame.
chronicleroflegends recently found and adjusted the code responsible for sprite draw order, and I used those changes as a base to add sprite cycling to it as well. I even borrowed the bit detecting the player to make it draw on top (to also keep the player from being part of the flicker cycle). It was actually a pretty small change to get it to work.
If you'd like to add Sprite Cycling to your NESmaker project.
Find the original UpdateDrawOrder section in HandleUpdateObjects.asm (around line 823, I also like to make a backup copy of the file first, just-in-case). Select the entire selection listed below:
Then replace with those lines with the new sprite cycling version.
EDIT: was having issues with sprites of different heights, should be fixed.
EDIT2: removed unnecessary draw sorting.
You probably remember the flicker many NES games had. This is caused by sprite cycling. The flicker is mildly annoying, but it's tonnes better then getting killed by enemies or projectiles you can't see. Basically, you still only see 8 sprites per scanline, but you cycle the sprites being turned off to a different one every frame.
chronicleroflegends recently found and adjusted the code responsible for sprite draw order, and I used those changes as a base to add sprite cycling to it as well. I even borrowed the bit detecting the player to make it draw on top (to also keep the player from being part of the flicker cycle). It was actually a pretty small change to get it to work.
If you'd like to add Sprite Cycling to your NESmaker project.
Find the original UpdateDrawOrder section in HandleUpdateObjects.asm (around line 823, I also like to make a backup copy of the file first, just-in-case). Select the entire selection listed below:
Code:
UpdateDrawOrder:
LDX #$1
OrderLoop:
LDY drawOrder,x
LDA Object_y_hi,y
STA temp
;;;; what would drawOrder-1 be? if it is 0, would would have to become 0f.
LDY drawOrder-1,x
LDA Object_y_hi,y
CMP temp
BCS doneWithSwapItem
LDA drawOrder,x
STA drawOrder-1,x
TYA
STA drawOrder,x
doneWithSwapItem:
INX
CPX #TOTAL_MAX_OBJECTS
BNE OrderLoop
RTS
Then replace with those lines with the new sprite cycling version.
Code:
UpdateDrawOrder:
;;Now with sprite cycling
LDX #$1
OrderLoop:
LDA drawOrder,x
LDY drawOrder-1,x
CPY player1_object ;; if previous is player object, don't swap them.
BEQ doneWithSwapItem
LDA drawOrder,x
STA drawOrder-1,x
TYA
STA drawOrder,x
doneWithSwapItem:
INX
CPX #TOTAL_MAX_OBJECTS
BNE OrderLoop
RTS
EDIT: was having issues with sprites of different heights, should be fixed.
EDIT2: removed unnecessary draw sorting.