mirror of https://github.com/snes9xgit/snes9x.git
gfx.cpp: memset less memory at once for FirstSprite+Y, accelerating sprite rendering if not all lines have sprites.
This commit is contained in:
parent
8384891515
commit
c64bfbf614
16
gfx.cpp
16
gfx.cpp
|
@ -900,7 +900,13 @@ static void SetupOBJ (void)
|
|||
{
|
||||
// First, find out which sprites are on which lines
|
||||
uint8 OBJOnLine[SNES_HEIGHT_EXTENDED][128];
|
||||
memset(OBJOnLine, 0, sizeof(OBJOnLine));
|
||||
// memset(OBJOnLine, 0, sizeof(OBJOnLine));
|
||||
/* Hold on here, that's a lot of bytes to initialise at once!
|
||||
* So we only initialise them per line, as needed. [Neb]
|
||||
* Bonus: We can quickly avoid looping if a line has no OBJs.
|
||||
*/
|
||||
bool8 AnyOBJOnLine[SNES_HEIGHT_EXTENDED];
|
||||
memset(AnyOBJOnLine, FALSE, sizeof(AnyOBJOnLine)); // better
|
||||
|
||||
for (S = 0; S < 128; S++)
|
||||
{
|
||||
|
@ -934,6 +940,11 @@ static void SetupOBJ (void)
|
|||
if (Y >= SNES_HEIGHT_EXTENDED)
|
||||
continue;
|
||||
|
||||
if (!AnyOBJOnLine[Y]) {
|
||||
memset(OBJOnLine[Y], 0, sizeof(OBJOnLine[Y]));
|
||||
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.
|
||||
|
@ -955,6 +966,8 @@ static void SetupOBJ (void)
|
|||
S = FirstSprite;
|
||||
j = 0;
|
||||
|
||||
if (AnyOBJOnLine[Y])
|
||||
{
|
||||
do
|
||||
{
|
||||
if (OBJOnLine[Y][S])
|
||||
|
@ -974,6 +987,7 @@ static void SetupOBJ (void)
|
|||
|
||||
S = (S + 1) & 0x7f;
|
||||
} while (S != FirstSprite);
|
||||
}
|
||||
|
||||
if (j < 32)
|
||||
GFX.OBJLines[Y].OBJ[j].Sprite = -1;
|
||||
|
|
Loading…
Reference in New Issue