From b7867f01cc9bc4fbcec6281afcfecbbc3304b861 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Sun, 30 Dec 2012 14:34:12 -0500 Subject: Memory access optimisations in sprite rendering. --- source/gfx.cpp | 54 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 19 deletions(-) (limited to 'source') diff --git a/source/gfx.cpp b/source/gfx.cpp index 3303fb9..611ec0a 100644 --- a/source/gfx.cpp +++ b/source/gfx.cpp @@ -981,7 +981,6 @@ void S9xSetupOBJ () for(int i=0; i=SNES_HEIGHT_EXTENDED) continue; + if (!AnyOBJOnLine[Y]) { + memset(OBJOnLine[Y], 0, 128); + AnyOBJOnLine[Y] = TRUE; + } if(PPU.OBJ[S].VFlip){ // Yes, Width not Height. It so happens that the // sprites with H=2*W flip as two WxW sprites. @@ -1074,24 +1087,27 @@ void S9xSetupOBJ () GFX.OBJLines[Y].RTOFlags=Y?0:GFX.OBJLines[Y-1].RTOFlags; GFX.OBJLines[Y].Tiles=34; - uint8 FirstSprite=(PPU.FirstSprite+Y)&0x7F; - S=FirstSprite; j=0; - do { - if(OBJOnLine[Y][S]){ - if(j>=32){ - GFX.OBJLines[Y].RTOFlags|=0x40; -#ifdef MK_DEBUG_RTO - if(Settings.BGLayering) fprintf(stderr, "%d: OBJ %02x ranged over\n", Y, S); -#endif - break; + j=0; + if (AnyOBJOnLine[Y]) { + uint8 FirstSprite=(PPU.FirstSprite+Y)&0x7F; + S=FirstSprite; + do { + if(OBJOnLine[Y][S]){ + if(j>=32){ + GFX.OBJLines[Y].RTOFlags|=0x40; + #ifdef MK_DEBUG_RTO + if(Settings.BGLayering) fprintf(stderr, "%d: OBJ %02x ranged over\n", Y, S); + #endif + break; + } + GFX.OBJLines[Y].Tiles-=GFX.OBJVisibleTiles[S]; + if(GFX.OBJLines[Y].Tiles<0) GFX.OBJLines[Y].RTOFlags|=0x80; + GFX.OBJLines[Y].OBJ[j].Sprite=S; + GFX.OBJLines[Y].OBJ[j++].Line=OBJOnLine[Y][S]&~0x80; } - GFX.OBJLines[Y].Tiles-=GFX.OBJVisibleTiles[S]; - if(GFX.OBJLines[Y].Tiles<0) GFX.OBJLines[Y].RTOFlags|=0x80; - GFX.OBJLines[Y].OBJ[j].Sprite=S; - GFX.OBJLines[Y].OBJ[j++].Line=OBJOnLine[Y][S]&~0x80; - } - S=(S+1)&0x7F; - } while(S!=FirstSprite); + S=(S+1)&0x7F; + } while(S!=FirstSprite); + } if(j<32) GFX.OBJLines[Y].OBJ[j].Sprite=-1; } } -- cgit v1.2.3