CutterCross
Active member
We all (hopefully) know that the NES can only draw 8 hardware sprites per scanline, and only 64 hardware sprites total. But working with NESmaker's Game Objects or Monster Objects can kind of suck because all sprites, even if they're completely blank and are mainly used to help with 16x16 offsets when placing them on a screen, will draw. And blank sprites still eat up one of those precious slots in OAM, and on our 8 sprites per scanline limitation.
Here's an example:
Really only 7 sprites display actual graphics at any given time (not counting the player object), but those blank sprites for positioning are still taking up a lot of space!
So let's change that.
In doDrawSprites.asm, there's this section with the label doDrawSpritesLoop. (Should be around line 253.) It looks like this:
What we're going to do is add a conditional check so if the current sprite to be drawn is a certain tile index (which would be our blank tile), we skip drawing the sprite entirely.
So let's say our blank tile is tile number #$7F in our Game Objects tileset. All we need to do is check against tempC, which holds the tile index, and see if it's #$7F. If it is #$7F, branch around the DrawSprite macro.
And voila, now those blank sprites don't render anymore! And our OAM table is looking much cleaner now!
Just a bit of extra info: If your blank tile index is #$00 you don't even need the CMP. Hope you'll find this easy modification useful!
Here's an example:
Really only 7 sprites display actual graphics at any given time (not counting the player object), but those blank sprites for positioning are still taking up a lot of space!
So let's change that.
In doDrawSprites.asm, there's this section with the label doDrawSpritesLoop. (Should be around line 253.) It looks like this:
Code:
doDrawSpritesLoop:
LDA (temp16),y
clc
ADC temp3
STA tempC ;; the calculated table position, with offest.
;; tempC becomes the "tile to draw".
INY
LDA (temp16),y
STA tempD ;; the next value is the attribute to draw.
INY ;; increasing again sets us up for the next sprite.
;; now we can use tempA-D to draw our sprite using the macro.
DrawSprite tempA, tempB, tempC, tempD
What we're going to do is add a conditional check so if the current sprite to be drawn is a certain tile index (which would be our blank tile), we skip drawing the sprite entirely.
So let's say our blank tile is tile number #$7F in our Game Objects tileset. All we need to do is check against tempC, which holds the tile index, and see if it's #$7F. If it is #$7F, branch around the DrawSprite macro.
Code:
doDrawSpritesLoop:
LDA (temp16),y
clc
ADC temp3
STA tempC ;; the calculated table position, with offest.
;; tempC becomes the "tile to draw".
INY
LDA (temp16),y
STA tempD ;; the next value is the attribute to draw.
INY ;; increasing again sets us up for the next sprite.
;; now we can use tempA-D to draw our sprite using the macro.
LDA tempC
CMP #$7F
BEQ +
DrawSprite tempA, tempB, tempC, tempD
+
And voila, now those blank sprites don't render anymore! And our OAM table is looking much cleaner now!
Just a bit of extra info: If your blank tile index is #$00 you don't even need the CMP. Hope you'll find this easy modification useful!