Skip to content

Commit

Permalink
GB: Prevent gbSpritesTicks from going out-of-bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
retro-wertz authored and rkitover committed Feb 1, 2019
1 parent f8c6953 commit 43647d3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/gb/gbGfx.cpp
Expand Up @@ -408,11 +408,12 @@ void gbDrawSpriteTile(int tile, int x, int y, int t, int flags,
bank1 = NULL;
}

int init = 0x0000;
int SpritesTicks = gbSpritesTicks[x + 8] * (gbSpeed ? 2 : 4);
int index = x + 11 + SpritesTicks;

for (int i = 0; i < 4; i++) {
gbObp0[i] = (gbObp0Line[x + 11 + gbSpritesTicks[x] * (gbSpeed ? 2 : 4)] >> (i << 1)) & 3;
gbObp1[i] = (gbObp1Line[x + 11 + gbSpritesTicks[x] * (gbSpeed ? 2 : 4)] >> (i << 1)) & 3;
gbObp0[i] = (gbObp0Line[index] >> (i << 1)) & 3;
gbObp1[i] = (gbObp1Line[index] >> (i << 1)) & 3;
}
uint8_t* pal = gbObp0;

Expand All @@ -428,7 +429,7 @@ void gbDrawSpriteTile(int tile, int x, int y, int t, int flags,

int prio = flags & 0x80;

int address = init + tile * 16 + 2 * t;
int address = tile * 16 + 2 * t;
int a = 0;
int b = 0;

Expand Down

0 comments on commit 43647d3

Please sign in to comment.