diff --git a/gfx.cpp b/gfx.cpp index 1189700a..edaf3b4d 100644 --- a/gfx.cpp +++ b/gfx.cpp @@ -604,6 +604,7 @@ static void SetupOBJ (void) int Height; uint8 S; + int sprite_limit = (Settings.MaxSpriteTilesPerLine == 128) ? 128 : 32; if (!PPU.OAMPriorityRotation || !(PPU.OAMFlip & PPU.OAMAddr & 1)) // normal case { @@ -614,7 +615,7 @@ static void SetupOBJ (void) { GFX.OBJLines[i].RTOFlags = 0; GFX.OBJLines[i].Tiles = Settings.MaxSpriteTilesPerLine; - for (int j = 0; j < 32; j++) + for (int j = 0; j < sprite_limit; j++) GFX.OBJLines[i].OBJ[j].Sprite = -1; } @@ -653,7 +654,7 @@ static void SetupOBJ (void) if (Y >= SNES_HEIGHT_EXTENDED) continue; - if (LineOBJ[Y] >= 32) + if (LineOBJ[Y] >= sprite_limit) { GFX.OBJLines[Y].RTOFlags |= 0x40; continue; @@ -757,7 +758,7 @@ static void SetupOBJ (void) { if (OBJOnLine[Y][S]) { - if (j >= 32) + if (j >= sprite_limit) { GFX.OBJLines[Y].RTOFlags |= 0x40; break; @@ -774,7 +775,7 @@ static void SetupOBJ (void) } while (S != FirstSprite); } - if (j < 32) + if (j < sprite_limit) GFX.OBJLines[Y].OBJ[j].Sprite = -1; } } @@ -794,13 +795,14 @@ static void DrawOBJS (int D) int PixWidth = IPPU.DoubleWidthPixels ? 2 : 1; BG.InterlaceLine = GFX.InterlaceFrame ? 8 : 0; GFX.Z1 = 2; - + int sprite_limit = (Settings.MaxSpriteTilesPerLine == 128) ? 128 : 32; + for (uint32 Y = GFX.StartY, Offset = Y * GFX.PPL; Y <= GFX.EndY; Y++, Offset += GFX.PPL) { int I = 0; int tiles = GFX.OBJLines[Y].Tiles; - for (int S = GFX.OBJLines[Y].OBJ[I].Sprite; S >= 0 && I < 32; S = GFX.OBJLines[Y].OBJ[++I].Sprite) + for (int S = GFX.OBJLines[Y].OBJ[I].Sprite; S >= 0 && I < sprite_limit; S = GFX.OBJLines[Y].OBJ[++I].Sprite) { tiles += GFX.OBJVisibleTiles[S]; if (tiles <= 0) diff --git a/gfx.h b/gfx.h index 38bd796b..9b4f6d74 100644 --- a/gfx.h +++ b/gfx.h @@ -47,7 +47,7 @@ struct SGFX { int8 Sprite; uint8 Line; - } OBJ[32]; + } OBJ[128]; } OBJLines[SNES_HEIGHT_EXTENDED]; void (*DrawBackdropMath) (uint32, uint32, uint32);