Skip to content

Commit

Permalink
Merge pull request #131 from negativeExponent/hle_bios_fixes
Browse files Browse the repository at this point in the history
GBA BIOS: ArcTan/ArcTan2 fixes for HLE bios
  • Loading branch information
hizzlekizzle committed Aug 13, 2020
2 parents 850a9af + db5acc7 commit d83ddf3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/gba.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1361,18 +1361,23 @@ static inline int16_t fast_cos(uint8_t val)
return fast_sin(val + 0x40);
}

// 2020-08-12 negativeExponent
// ArcTan/ArcTan2 fixes based from mgba hle bios

static void BIOS_ArcTan (void)
{
s32 a = -(((s32)(bus.reg[0].I*bus.reg[0].I)) >> 14);
s32 i = bus.reg[0].I;
s32 a = -((i * i) >> 14);
s32 b = ((0xA9 * a) >> 14) + 0x390;
b = ((b * a) >> 14) + 0x91C;
b = ((b * a) >> 14) + 0xFB6;
b = ((b * a) >> 14) + 0x16AA;
b = ((b * a) >> 14) + 0x2081;
b = ((b * a) >> 14) + 0x3651;
b = ((b * a) >> 14) + 0xA2F9;
a = ((s32)bus.reg[0].I * b) >> 16;
bus.reg[0].I = a;
bus.reg[0].I = (i * b) >> 16;
bus.reg[1].I = a;
bus.reg[3].I = b;
}

static void BIOS_Div (void)
Expand Down Expand Up @@ -1423,6 +1428,7 @@ static void BIOS_ArcTan2 (void)
}
}
bus.reg[0].I = res;
bus.reg[3].I = 0x170;
}

static void BIOS_BitUnPack (void)
Expand Down

0 comments on commit d83ddf3

Please sign in to comment.