From f8cd4cd10067462e6efd89ce048873159678a5ce Mon Sep 17 00:00:00 2001 From: XProger Date: Sat, 7 Aug 2021 06:13:46 +0300 Subject: [PATCH] #368 GBA fix out of range of Ordering Table for sprites, fix build for WIN, TNS and DOS --- src/platform/gba/main.cpp | 6 ++++++ src/platform/gba/render.cpp | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/platform/gba/main.cpp b/src/platform/gba/main.cpp index d51fa8e8..94db3600 100644 --- a/src/platform/gba/main.cpp +++ b/src/platform/gba/main.cpp @@ -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) { @@ -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); @@ -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 diff --git a/src/platform/gba/render.cpp b/src/platform/gba/render.cpp index e03e5744..f1cb52f3 100644 --- a/src/platform/gba/render.cpp +++ b/src/platform/gba/render.cpp @@ -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; @@ -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); @@ -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;