Skip to content

Commit

Permalink
#368 GBA fix out of range of Ordering Table for sprites, fix build fo…
Browse files Browse the repository at this point in the history
…r WIN, TNS and DOS
  • Loading branch information
XProger committed Aug 7, 2021
1 parent c9a91e0 commit f8cd4cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/platform/gba/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ int32 fpsCounter = 0;
return GetTickCount();
}

void osJoyVibrate(int32 index, int32 L, int32 R) {}

#elif defined(__GBA__)
void paletteSet(const uint16* palette)
{
Expand Down Expand Up @@ -128,6 +130,8 @@ int32 fpsCounter = 0;
return *timerCLK / 33;
}

void osJoyVibrate(int32 index, int32 L, int32 R) {}

void paletteSet(const uint16* palette)
{
memcpy((uint16*)0xC0000200, palette, 256 * 2);
Expand Down Expand Up @@ -300,6 +304,8 @@ int32 fpsCounter = 0;
{
return 0;
}

void osJoyVibrate(int32 index, int32 L, int32 R) {}
#endif

EWRAM_DATA ALIGN16 uint8 soundBufferA[2 * SND_SAMPLES + 32]; // 32 bytes of silence for DMA overrun while interrupt
Expand Down
9 changes: 6 additions & 3 deletions src/platform/gba/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,8 @@ void drawGlyph(const Sprite *sprite, int32 x, int32 y)

X_INLINE Face* faceAdd(int32 depth)
{
ASSERT(depth < OT_SIZE);
ASSERT(depth >= 0 && depth < OT_SIZE);

Face* face = gFaces + gFacesCount++;
face->next = otFaces[depth];
otFaces[depth] = face;
Expand Down Expand Up @@ -647,6 +648,8 @@ void faceAddSprite(int32 vx, int32 vy, int32 vz, int32 vg, int32 index)
return;
}

ASSERT(gFacesCount < MAX_FACES);

int32 x = DP43c(m[0], vx, vy, vz);
int32 y = DP43c(m[1], vx, vy, vz);

Expand Down Expand Up @@ -703,9 +706,9 @@ void faceAddSprite(int32 vx, int32 vy, int32 vz, int32 vg, int32 index)
ASSERT(v2.x >= v1.x);
ASSERT(v2.y >= v1.y);

fogZ -= 128;
int32 depth = X_MAX(0, fogZ - 128); // depth hack

Face* f = faceAdd(fogZ >> OT_SHIFT);
Face* f = faceAdd(depth >> OT_SHIFT);
f->flags = uint16(FACE_SPRITE);
f->indices[0] = gVerticesCount - 2;
f->indices[1] = index;
Expand Down

0 comments on commit f8cd4cd

Please sign in to comment.