Skip to content

Commit

Permalink
Apply mask on DMEM address to avoid segmentation fault in Indiana Jones,
Browse files Browse the repository at this point in the history
see #2628
  • Loading branch information
gonetz committed Jan 8, 2022
1 parent 6275140 commit e9a6f25
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/uCodes/F5Indi_Naboo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ void F5INDI_DMA_Segmented(u32 _w0, u32 _w1)
static
void F5INDI_Lighting_Overlay1(u32 _w0, u32 _w1)
{
static bool showErrorMessage = true;
const u32 S = ((_SHIFTR(_w1, 24, 7) << 2) + 4) & 0xFFF8;
memset(DMEM + 0xD40, 0, S);

Expand Down Expand Up @@ -208,7 +209,12 @@ void F5INDI_Lighting_Overlay1(u32 _w0, u32 _w1)
++V;
s16 Z1 = (s16)_SHIFTR(*V, 16, 16);

V = CAST_DMEM(const u32*, 0x170 + offsetAddr[offsetAddrIdx^3]);
const u32 addr = 0x170 + offsetAddr[offsetAddrIdx ^ 3];
if (addr >= 0x1000 && showErrorMessage) {
dwnd().getDrawer().showMessage("Wrong data address detected!!! Please report to developers.\n", Milliseconds(5000));
showErrorMessage = false;
}
V = CAST_DMEM(const u32*, (addr&0x0FFC));
offsetAddrIdx++;
s16 X = (s16)_SHIFTR(*V, 16, 16);
s16 Y = (s16)_SHIFTR(*V, 0, 16);
Expand Down

0 comments on commit e9a6f25

Please sign in to comment.