summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/battle_ai.c294
-rw-r--r--src/play_time.c73
-rw-r--r--src/trig.c549
3 files changed, 769 insertions, 147 deletions
diff --git a/src/battle_ai.c b/src/battle_ai.c
index 37960f401..7c4b7604d 100644
--- a/src/battle_ai.c
+++ b/src/battle_ai.c
@@ -9,10 +9,10 @@
#define AIScriptRead8(ptr) ((ptr)[0])
#define AIScriptReadPtr(ptr) (u8*) AIScriptRead32(ptr)
-#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(gUnknown_020244A8->ai))
-#define UNK_2016A00_STRUCT ((struct UnknownStruct2 *)(gUnknown_020244A8->unk18))
-#define UNK_2016C00_STRUCT ((struct UnknownStruct4 *)(gUnknown_020244A8->unk1C))
-#define UNK_BATTLE_STRUCT ((struct UnknownStruct1 *)(gUnknown_020244A8))
+#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(gBattleResources->ai))
+#define UNK_2016A00_STRUCT ((struct UnknownStruct2 *)(gBattleResources->unk18))
+#define UNK_2016C00_STRUCT ((struct UnknownStruct4 *)(gBattleResources->unk1C))
+#define UNK_BATTLE_STRUCT ((struct UnknownStruct1 *)(gBattleResources))
#define AI_ACTION_UNK1 0x0001
#define AI_ACTION_UNK2 0x0002
@@ -158,7 +158,7 @@ struct UnknownStruct5
u8 filler17[0x4];
};
-extern struct UnknownStruct5 gUnknown_020242BC[];
+extern struct UnknownStruct5 gDisableStructs[];
/*
gAIScriptPtr is a pointer to the next battle AI cmd command to read.
@@ -170,38 +170,38 @@ AI scripts.
extern u8 *gAIScriptPtr;
extern u32 gBattleTypeFlags;
-extern u8 gUnknown_02024064;
+extern u8 gActiveBank;
extern struct BattlePokemon gBattleMons[];
-extern u16 gUnknown_020241EA;
-extern u8 gEnemyMonIndex;
-extern u8 gUnknown_02024210;
+extern u16 gCurrentMove;
+extern u8 gBankTarget;
+extern u8 gAbsentBankFlags;
extern u16 gUnknown_02024248[];
-extern u8 *gUnknown_0202449C;
-extern struct UnknownStruct1 *gUnknown_020244A8;
+extern u8 *gBattleStruct;
+extern struct UnknownStruct1 *gBattleResources;
extern u16 gUnknown_02038BCA;
extern u16 gUnknown_02038BCC;
extern u8 gPlayerMonIndex;
extern struct Trainer gTrainers[];
extern const u32 gBitTable[];
extern u8 *gUnknown_082DBEF8[];
-extern u32 gUnknown_020242AC[];
+extern u32 gStatuses3[];
extern u16 gUnknown_0202428E[];
extern struct BattleMove gBattleMoves[];
extern u8 gUnknown_03005D10[];
-extern u8 gUnknown_0202406E[][2];
+extern u8 gBattlePartyID[][2];
extern struct BaseStats gBaseStats[];
extern u16 gUnknown_02024400;
-extern u8 gUnknown_02024474[];
+extern u8 gBattleScripting[];
extern u8 gBattleMoveFlags;
extern int gBattleMoveDamage;
extern u8 gCritMultiplier;
extern u16 gBattleWeather;
-extern u8 battle_get_per_side_status(u8);
+extern u8 GetBankIdentity(u8);
extern u8 b_first_side(u8, u8, u8);
-extern u8 battle_get_side_with_given_state(u8);
+extern u8 GetBankByPlayerAI(u8);
extern void move_effectiveness_something(u16, u8, u8);
-extern u8 itemid_get_x12();
+extern u8 ItemId_GetHoldEffect();
extern void b_mc_stack_push(u8 *);
extern bool8 b_mc_stack_pop_cursor(void);
extern void sub_8046E7C(u8, u8);
@@ -212,7 +212,7 @@ extern const BattleAICmdFunc sBattleAICmdTable[];
extern u8 sub_803FECC();
extern u16 Random();
-extern u8 battle_side_get_owner();
+extern u8 GetBankSide();
extern u32 sub_8186438();
extern u32 sub_81A6FB4();
@@ -225,7 +225,7 @@ void BattleAI_DoAIProcessing(void);
void BattleAI_HandleItemUseBeforeAISetup(u8 a)
{
s32 i;
- u8 *data = (u8 *)gUnknown_020244A8->unk18;
+ u8 *data = (u8 *)gBattleResources->unk18;
for (i = 0; (u32)i < 0x54; i++)
data[i] = 0;
@@ -235,8 +235,8 @@ void BattleAI_HandleItemUseBeforeAISetup(u8 a)
{
if (gTrainers[gUnknown_02038BCA].items[i] != 0)
{
- gUnknown_020244A8->unk18->unk48[gUnknown_020244A8->unk18->unk50] = gTrainers[gUnknown_02038BCA].items[i];
- gUnknown_020244A8->unk18->unk50++;
+ gBattleResources->unk18->unk48[gBattleResources->unk18->unk50] = gTrainers[gUnknown_02038BCA].items[i];
+ gBattleResources->unk18->unk50++;
}
}
}
@@ -264,7 +264,7 @@ void BattleAI_SetupAIData(u8 a)
a >>= 1;
}
- r6 = sub_803FECC(gUnknown_02024064, 0, 0xFF);
+ r6 = sub_803FECC(gActiveBank, 0, 0xFF);
for (i = 0; i < 4; i++)
{
@@ -273,18 +273,18 @@ void BattleAI_SetupAIData(u8 a)
AI_THINKING_STRUCT->unk18[i] = 100 - (Random() % 16);
}
- gUnknown_020244A8->unk1C->unk20 = 0;
- gPlayerMonIndex = gUnknown_02024064;
+ gBattleResources->unk1C->unk20 = 0;
+ gPlayerMonIndex = gActiveBank;
if (gBattleTypeFlags & 1)
{
- gEnemyMonIndex = (Random() & 2) + ((u32)battle_side_get_owner(gUnknown_02024064) ^ 1);
- if (gUnknown_02024210 & gBitTable[gEnemyMonIndex])
- gEnemyMonIndex ^= 2;
+ gBankTarget = (Random() & 2) + ((u32)GetBankSide(gActiveBank) ^ 1);
+ if (gAbsentBankFlags & gBitTable[gBankTarget])
+ gBankTarget ^= 2;
}
else
{
//_08130A60
- gEnemyMonIndex = gPlayerMonIndex ^ 1;
+ gBankTarget = gPlayerMonIndex ^ 1;
}
//_08130A68
if (gBattleTypeFlags & 0x1000000)
@@ -309,7 +309,7 @@ void BattleAI_SetupAIData(u8 a)
u8 sub_8130BA4(void)
{
- u16 r4 = gUnknown_020241EA;
+ u16 r4 = gCurrentMove;
u8 ret;
if (!(gBattleTypeFlags & 1))
@@ -317,7 +317,7 @@ u8 sub_8130BA4(void)
else
ret = sub_8130CF4();
- gUnknown_020241EA = r4;
+ gCurrentMove = r4;
return ret;
}
@@ -404,11 +404,11 @@ u8 sub_8130CF4(void)
else
{
if (gBattleTypeFlags & 0x20000)
- BattleAI_SetupAIData(gUnknown_0202449C[0x92] >> 4);
+ BattleAI_SetupAIData(gBattleStruct[0x92] >> 4);
else
BattleAI_SetupAIData(0xF);
//_08130D76
- gEnemyMonIndex = i;
+ gBankTarget = i;
if ((i & 1) != (gPlayerMonIndex & 1))
sub_8131074();
//_08130D90
@@ -488,8 +488,8 @@ u8 sub_8130CF4(void)
r4_2 = 1;
}
}
- gEnemyMonIndex = sp8[Random() % r4_2];
- return spC[gEnemyMonIndex];
+ gBankTarget = sp8[Random() % r4_2];
+ return spC[gBankTarget];
}
#else
__attribute__((naked))
@@ -543,7 +543,7 @@ _08130D48:\n\
ands r0, r1\n\
cmp r0, 0\n\
beq _08130D70\n\
- ldr r0, =gUnknown_0202449C\n\
+ ldr r0, =gBattleStruct\n\
ldr r0, [r0]\n\
adds r0, 0x92\n\
ldrb r0, [r0]\n\
@@ -555,7 +555,7 @@ _08130D70:\n\
movs r0, 0xF\n\
bl BattleAI_SetupAIData\n\
_08130D76:\n\
- ldr r0, =gEnemyMonIndex\n\
+ ldr r0, =gBankTarget\n\
mov r1, r8\n\
strb r1, [r0]\n\
movs r1, 0x1\n\
@@ -568,7 +568,7 @@ _08130D76:\n\
beq _08130D90\n\
bl sub_8131074\n\
_08130D90:\n\
- ldr r2, =gUnknown_020244A8\n\
+ ldr r2, =gBattleResources\n\
ldr r0, [r2]\n\
ldr r0, [r0, 0x14]\n\
movs r1, 0\n\
@@ -731,7 +731,7 @@ _08130EC4:\n\
strb r0, [r2]\n\
movs r4, 0x1\n\
mov r8, r4\n\
- ldr r6, =gEnemyMonIndex\n\
+ ldr r6, =gBankTarget\n\
ldr r3, [sp, 0x18]\n\
mov r1, sp\n\
adds r1, 0x2\n\
@@ -838,12 +838,12 @@ void sub_8131074(void)
for (i = 0; i < 4; i++)
{
- if (gUnknown_020244A8->unk18->unk0[gEnemyMonIndex][i] == gUnknown_02024248[gEnemyMonIndex])
+ if (gBattleResources->unk18->unk0[gBankTarget][i] == gUnknown_02024248[gBankTarget])
break;
- if (gUnknown_020244A8->unk18->unk0[gEnemyMonIndex][i] != gUnknown_02024248[gEnemyMonIndex] //HACK: This redundant condition is a hack to make the asm match.
- && gUnknown_020244A8->unk18->unk0[gEnemyMonIndex][i] == 0)
+ if (gBattleResources->unk18->unk0[gBankTarget][i] != gUnknown_02024248[gBankTarget] //HACK: This redundant condition is a hack to make the asm match.
+ && gBattleResources->unk18->unk0[gBankTarget][i] == 0)
{
- gUnknown_020244A8->unk18->unk0[gEnemyMonIndex][i] = gUnknown_02024248[gEnemyMonIndex];
+ gBattleResources->unk18->unk0[gBankTarget][i] = gUnknown_02024248[gBankTarget];
break;
}
}
@@ -854,27 +854,27 @@ void sub_81310F0(u8 a)
s32 i;
for (i = 0; i < 4; i++)
- gUnknown_020244A8->unk18->unk0[a][i] = 0;
+ gBattleResources->unk18->unk0[a][i] = 0;
}
-void b_history__record_ability_usage_of_player(u8 a, u8 b)
+void RecordAbilityBattle(u8 a, u8 b)
{
- gUnknown_020244A8->unk18->unk40[a] = b;
+ gBattleResources->unk18->unk40[a] = b;
}
void sub_8131130(u8 a)
{
- gUnknown_020244A8->unk18->unk40[a] = 0;
+ gBattleResources->unk18->unk40[a] = 0;
}
void b_history__record_item_x12_of_player(u8 a, u8 b)
{
- gUnknown_020244A8->unk18->unk44[a] = b;
+ gBattleResources->unk18->unk44[a] = b;
}
void sub_8131160(u8 a)
{
- gUnknown_020244A8->unk18->unk44[a] = 0;
+ gBattleResources->unk18->unk44[a] = 0;
}
void BattleAICmd_if_random_less_than(void)
@@ -934,7 +934,7 @@ void BattleAICmd_if_hp_less_than(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
if ((u32)(100 * gBattleMons[index].hp / gBattleMons[index].maxHP) < gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
@@ -949,7 +949,7 @@ void BattleAICmd_if_hp_more_than(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
if ((u32)(100 * gBattleMons[index].hp / gBattleMons[index].maxHP) > gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
@@ -964,7 +964,7 @@ void BattleAICmd_if_hp_equal(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
if ((u32)(100 * gBattleMons[index].hp / gBattleMons[index].maxHP) == gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
@@ -979,7 +979,7 @@ void BattleAICmd_if_hp_not_equal(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
if ((u32)(100 * gBattleMons[index].hp / gBattleMons[index].maxHP) != gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
@@ -995,7 +995,7 @@ void BattleAICmd_if_status(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
arg = AIScriptRead32(gAIScriptPtr + 2);
@@ -1013,7 +1013,7 @@ void BattleAICmd_if_not_status(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
arg = AIScriptRead32(gAIScriptPtr + 2);
@@ -1031,7 +1031,7 @@ void BattleAICmd_if_status2(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
arg = AIScriptRead32(gAIScriptPtr + 2);
@@ -1049,7 +1049,7 @@ void BattleAICmd_if_not_status2(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
arg = AIScriptRead32(gAIScriptPtr + 2);
@@ -1067,11 +1067,11 @@ void BattleAICmd_if_status3(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
arg = AIScriptRead32(gAIScriptPtr + 2);
- if ((gUnknown_020242AC[index] & arg) != 0)
+ if ((gStatuses3[index] & arg) != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
@@ -1085,11 +1085,11 @@ void BattleAICmd_if_not_status3(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
arg = AIScriptRead32(gAIScriptPtr + 2);
- if ((gUnknown_020242AC[index] & arg) == 0)
+ if ((gStatuses3[index] & arg) == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
@@ -1103,9 +1103,9 @@ void BattleAICmd_if_status4(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
- arg1 = battle_get_per_side_status(index) & 1;
+ arg1 = GetBankIdentity(index) & 1;
arg2 = AIScriptRead32(gAIScriptPtr + 2);
if ((gUnknown_0202428E[arg1] & arg2) != 0)
@@ -1122,9 +1122,9 @@ void BattleAICmd_if_not_status4(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
- arg1 = battle_get_per_side_status(index) & 1;
+ arg1 = GetBankIdentity(index) & 1;
arg2 = AIScriptRead32(gAIScriptPtr + 2);
if ((gUnknown_0202428E[arg1] & arg2) == 0)
@@ -1337,13 +1337,13 @@ void BattleAICmd_get_type(void)
AI_THINKING_STRUCT->funcResult = gBattleMons[gPlayerMonIndex].type1;
break;
case 0: // enemy primary type
- AI_THINKING_STRUCT->funcResult = gBattleMons[gEnemyMonIndex].type1;
+ AI_THINKING_STRUCT->funcResult = gBattleMons[gBankTarget].type1;
break;
case 3: // player secondary type
AI_THINKING_STRUCT->funcResult = gBattleMons[gPlayerMonIndex].type2;
break;
case 2: // enemy secondary type
- AI_THINKING_STRUCT->funcResult = gBattleMons[gEnemyMonIndex].type2;
+ AI_THINKING_STRUCT->funcResult = gBattleMons[gBankTarget].type2;
break;
case 4: // type of move being pointed to
AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].type;
@@ -1361,11 +1361,11 @@ u8 sub_8131E70(u8 index)
return gPlayerMonIndex;
case 0:
default:
- return gEnemyMonIndex;
+ return gBankTarget;
case 3:
return gPlayerMonIndex ^ 2;
case 2:
- return gEnemyMonIndex ^ 2;
+ return gBankTarget ^ 2;
}
}
@@ -1406,7 +1406,7 @@ void BattleAICmd_is_most_powerful_move(void)
ldrh r1, [r0]\n\
ldr r5, =0x0000ffff\n\
ldr r6, =gBattleMoves\n\
- ldr r2, =gUnknown_020244A8\n\
+ ldr r2, =gBattleResources\n\
cmp r1, r5\n\
beq _08131F86\n\
ldr r0, [r2]\n\
@@ -1452,10 +1452,10 @@ _08131FAC:\n\
ldr r0, =gUnknown_02024400\n\
movs r1, 0\n\
strh r1, [r0]\n\
- ldr r0, =gUnknown_0202449C\n\
+ ldr r0, =gBattleStruct\n\
ldr r0, [r0]\n\
strb r1, [r0, 0x13]\n\
- ldr r0, =gUnknown_02024474\n\
+ ldr r0, =gBattleScripting\n\
movs r2, 0x1\n\
strb r2, [r0, 0xE]\n\
ldr r0, =gBattleMoveFlags\n\
@@ -1529,10 +1529,10 @@ _08132014:\n\
ldrb r0, [r1, 0x1]\n\
cmp r0, 0x1\n\
bls _081320C0\n\
- ldr r5, =gUnknown_020241EA\n\
+ ldr r5, =gCurrentMove\n\
strh r2, [r5]\n\
ldrb r0, [r7]\n\
- ldr r4, =gEnemyMonIndex\n\
+ ldr r4, =gBankTarget\n\
ldrb r1, [r4]\n\
bl sub_8046E7C\n\
ldrh r0, [r5]\n\
@@ -1542,7 +1542,7 @@ _08132014:\n\
mov r4, sp\n\
add r4, r8\n\
ldr r2, =gBattleMoveDamage\n\
- ldr r0, =gUnknown_020244A8\n\
+ ldr r0, =gBattleResources\n\
ldr r0, [r0]\n\
ldr r0, [r0, 0x14]\n\
adds r0, 0x18\n\
@@ -1571,7 +1571,7 @@ _081320C8:\n\
b _08131FD0\n\
_081320D0:\n\
movs r6, 0\n\
- ldr r2, =gUnknown_020244A8\n\
+ ldr r2, =gBattleResources\n\
ldr r0, [r2]\n\
ldr r0, [r0, 0x14]\n\
ldrb r0, [r0, 0x1]\n\
@@ -1640,7 +1640,7 @@ void BattleAICmd_get_move(void)
if (gAIScriptPtr[1] == USER)
AI_THINKING_STRUCT->funcResult = gUnknown_02024248[gPlayerMonIndex];
else
- AI_THINKING_STRUCT->funcResult = gUnknown_02024248[gEnemyMonIndex];
+ AI_THINKING_STRUCT->funcResult = gUnknown_02024248[gBankTarget];
gAIScriptPtr += 2;
}
@@ -1663,7 +1663,7 @@ void BattleAICmd_if_arg_not_equal(void)
void BattleAICmd_if_would_go_first(void)
{
- if (b_first_side(gPlayerMonIndex, gEnemyMonIndex, 1) == gAIScriptPtr[1])
+ if (b_first_side(gPlayerMonIndex, gBankTarget, 1) == gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
@@ -1671,7 +1671,7 @@ void BattleAICmd_if_would_go_first(void)
void BattleAICmd_if_would_not_go_first(void)
{
- if (b_first_side(gPlayerMonIndex, gEnemyMonIndex, 1) != gAIScriptPtr[1])
+ if (b_first_side(gPlayerMonIndex, gBankTarget, 1) != gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
@@ -1697,9 +1697,9 @@ void BattleAICmd_count_alive_pokemon(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
- if (battle_side_get_owner(index) == 0)
+ if (GetBankSide(index) == 0)
party = gPlayerParty;
else
party = gEnemyParty;
@@ -1707,14 +1707,14 @@ void BattleAICmd_count_alive_pokemon(void)
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
u32 status;
- var = gUnknown_0202406E[index][0];
- status = battle_get_per_side_status(index) ^ 2;
- var2 = gUnknown_0202406E[battle_get_side_with_given_state(status)][0];
+ var = gBattlePartyID[index][0];
+ status = GetBankIdentity(index) ^ 2;
+ var2 = gBattlePartyID[GetBankByPlayerAI(status)][0];
}
else
{
- var = gUnknown_0202406E[index][0];
- var2 = gUnknown_0202406E[index][0];
+ var = gBattlePartyID[index][0];
+ var2 = gBattlePartyID[index][0];
}
for (i = 0; i < 6; i++)
@@ -1750,9 +1750,9 @@ void BattleAICmd_get_ability(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
- if(gUnknown_02024064 != index)
+ if(gActiveBank != index)
{
if(UNK_2016A00_STRUCT->unk40[index] != 0)
{
@@ -1898,7 +1898,7 @@ void tai60_unk(void)
cmp r0, 0x2\n\
bne _081325BC\n\
_0813253A:\n\
- ldr r0, =gUnknown_020244A8\n\
+ ldr r0, =gBattleResources\n\
ldr r4, [r0]\n\
ldr r1, [r4, 0x18]\n\
adds r1, 0x40\n\
@@ -1968,7 +1968,7 @@ _081325BC:\n\
adds r0, r1\n\
adds r0, 0x20\n\
ldrb r3, [r0]\n\
- ldr r6, =gUnknown_020244A8\n\
+ ldr r6, =gBattleResources\n\
_081325CA:\n\
cmp r3, 0\n\
bne _081325E8\n\
@@ -2015,8 +2015,8 @@ void BattleAICmd_get_highest_possible_damage(void)
s32 i;
gUnknown_02024400 = 0;
- gUnknown_0202449C[0x13] = 0;
- gUnknown_02024474[0xE] = 1;
+ gBattleStruct[0x13] = 0;
+ gBattleScripting[0xE] = 1;
gBattleMoveFlags = 0;
gCritMultiplier = 1;
AI_THINKING_STRUCT->funcResult = 0;
@@ -2024,11 +2024,11 @@ void BattleAICmd_get_highest_possible_damage(void)
for (i = 0; i < 4; i++)
{
gBattleMoveDamage = 40;
- gUnknown_020241EA = gBattleMons[gPlayerMonIndex].moves[i];
+ gCurrentMove = gBattleMons[gPlayerMonIndex].moves[i];
- if (gUnknown_020241EA)
+ if (gCurrentMove)
{
- move_effectiveness_something(gUnknown_020241EA, gPlayerMonIndex, gEnemyMonIndex);
+ move_effectiveness_something(gCurrentMove, gPlayerMonIndex, gBankTarget);
// reduce by 1/3.
if (gBattleMoveDamage == 120)
@@ -2055,15 +2055,15 @@ void BattleAICmd_if_damage_bonus(void)
u8 damageVar;
gUnknown_02024400 = 0;
- gUnknown_0202449C[0x13] = 0;
- gUnknown_02024474[0xE] = 1;
+ gBattleStruct[0x13] = 0;
+ gBattleScripting[0xE] = 1;
gBattleMoveFlags = 0;
gCritMultiplier = 1;
gBattleMoveDamage = 40;
- gUnknown_020241EA = AI_THINKING_STRUCT->moveConsidered;
+ gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
- move_effectiveness_something(gUnknown_020241EA, gPlayerMonIndex, gEnemyMonIndex);
+ move_effectiveness_something(gCurrentMove, gPlayerMonIndex, gBankTarget);
if (gBattleMoveDamage == 120)
gBattleMoveDamage = 80;
@@ -2107,11 +2107,11 @@ void BattleAICmd_if_status_in_party(void)
index = gPlayerMonIndex;
break;
default:
- index = gEnemyMonIndex;
+ index = gBankTarget;
break;
}
- party = (battle_side_get_owner(index) == 0) ? gPlayerParty : gEnemyParty;
+ party = (GetBankSide(index) == 0) ? gPlayerParty : gEnemyParty;
statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2);
@@ -2144,11 +2144,11 @@ void BattleAICmd_if_status_not_in_party(void)
index = gPlayerMonIndex;
break;
default:
- index = gEnemyMonIndex;
+ index = gBankTarget;
break;
}
- party = (battle_side_get_owner(index) == 0) ? gPlayerParty : gEnemyParty;
+ party = (GetBankSide(index) == 0) ? gPlayerParty : gEnemyParty;
statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2);
@@ -2204,7 +2204,7 @@ void BattleAICmd_if_stat_level_less_than(void)
if (gAIScriptPtr[1] == USER)
party = gPlayerMonIndex;
else
- party = gEnemyMonIndex;
+ party = gBankTarget;
if (gBattleMons[party].statStages[gAIScriptPtr[2]] < gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
@@ -2219,7 +2219,7 @@ void BattleAICmd_if_stat_level_more_than(void)
if (gAIScriptPtr[1] == USER)
party = gPlayerMonIndex;
else
- party = gEnemyMonIndex;
+ party = gBankTarget;
if (gBattleMons[party].statStages[gAIScriptPtr[2]] > gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
@@ -2234,7 +2234,7 @@ void BattleAICmd_if_stat_level_equal(void)
if (gAIScriptPtr[1] == USER)
party = gPlayerMonIndex;
else
- party = gEnemyMonIndex;
+ party = gBankTarget;
if (gBattleMons[party].statStages[gAIScriptPtr[2]] == gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
@@ -2249,7 +2249,7 @@ void BattleAICmd_if_stat_level_not_equal(void)
if (gAIScriptPtr[1] == USER)
party = gPlayerMonIndex;
else
- party = gEnemyMonIndex;
+ party = gBankTarget;
if (gBattleMons[party].statStages[gAIScriptPtr[2]] != gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
@@ -2266,13 +2266,13 @@ void BattleAICmd_if_can_faint(void)
}
gUnknown_02024400 = 0;
- gUnknown_0202449C[0x13] = 0;
- gUnknown_02024474[0xE] = 1;
+ gBattleStruct[0x13] = 0;
+ gBattleScripting[0xE] = 1;
gBattleMoveFlags = 0;
gCritMultiplier = 1;
- gUnknown_020241EA = AI_THINKING_STRUCT->moveConsidered;
- sub_8046E7C(gPlayerMonIndex, gEnemyMonIndex);
- move_effectiveness_something(gUnknown_020241EA, gPlayerMonIndex, gEnemyMonIndex);
+ gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
+ sub_8046E7C(gPlayerMonIndex, gBankTarget);
+ move_effectiveness_something(gCurrentMove, gPlayerMonIndex, gBankTarget);
gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->unk18[AI_THINKING_STRUCT->movesetIndex] / 100;
@@ -2280,7 +2280,7 @@ void BattleAICmd_if_can_faint(void)
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
- if (gBattleMons[gEnemyMonIndex].hp <= gBattleMoveDamage)
+ if (gBattleMons[gBankTarget].hp <= gBattleMoveDamage)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
@@ -2295,19 +2295,19 @@ void BattleAICmd_if_cant_faint(void)
}
gUnknown_02024400 = 0;
- gUnknown_0202449C[0x13] = 0;
- gUnknown_02024474[0xE] = 1;
+ gBattleStruct[0x13] = 0;
+ gBattleScripting[0xE] = 1;
gBattleMoveFlags = 0;
gCritMultiplier = 1;
- gUnknown_020241EA = AI_THINKING_STRUCT->moveConsidered;
- sub_8046E7C(gPlayerMonIndex, gEnemyMonIndex);
- move_effectiveness_something(gUnknown_020241EA, gPlayerMonIndex, gEnemyMonIndex);
+ gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
+ sub_8046E7C(gPlayerMonIndex, gBankTarget);
+ move_effectiveness_something(gCurrentMove, gPlayerMonIndex, gBankTarget);
gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->unk18[AI_THINKING_STRUCT->movesetIndex] / 100;
// this macro is missing the damage 0 = 1 assumption.
- if (gBattleMons[gEnemyMonIndex].hp > gBattleMoveDamage)
+ if (gBattleMons[gBankTarget].hp > gBattleMoveDamage)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
@@ -2365,7 +2365,7 @@ void BattleAICmd_if_has_move(void)
case 2:
for (i = 0; i < 4; i++)
{
- if (UNK_2016A00_STRUCT->unk0[gEnemyMonIndex][i] == *temp_ptr)
+ if (UNK_2016A00_STRUCT->unk0[gBankTarget][i] == *temp_ptr)
break;
}
if (i == 4)
@@ -2409,7 +2409,7 @@ void BattleAICmd_if_dont_have_move(void)
case 2:
for (i = 0; i < 4; i++)
{
- if (UNK_2016A00_STRUCT->unk0[gEnemyMonIndex][i] == *temp_ptr)
+ if (UNK_2016A00_STRUCT->unk0[gBankTarget][i] == *temp_ptr)
break;
}
if (i != 4)
@@ -2447,7 +2447,7 @@ void BattleAICmd_if_move_effect(void)
case 2: // _08133090
for (i = 0; i < 4; i++)
{
- if (gBattleMons[gPlayerMonIndex].moves[i] != 0 && gBattleMoves[UNK_2016A00_STRUCT->unk0[gEnemyMonIndex][i]].effect == gAIScriptPtr[2])
+ if (gBattleMons[gPlayerMonIndex].moves[i] != 0 && gBattleMoves[UNK_2016A00_STRUCT->unk0[gBankTarget][i]].effect == gAIScriptPtr[2])
break;
}
if (i == 4)
@@ -2480,7 +2480,7 @@ void BattleAICmd_if_not_move_effect(void)
case 2: // _08133188
for (i = 0; i < 4; i++)
{
- if (UNK_2016A00_STRUCT->unk0[gEnemyMonIndex][i] && gBattleMoves[UNK_2016A00_STRUCT->unk0[gEnemyMonIndex][i]].effect == gAIScriptPtr[2])
+ if (UNK_2016A00_STRUCT->unk0[gBankTarget][i] && gBattleMoves[UNK_2016A00_STRUCT->unk0[gBankTarget][i]].effect == gAIScriptPtr[2])
break;
}
if (i != 4)
@@ -2498,11 +2498,11 @@ void BattleAICmd_if_last_move_did_damage(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
if (gAIScriptPtr[2] == 0)
{
- if (gUnknown_020242BC[index].unk4 == 0)
+ if (gDisableStructs[index].unk4 == 0)
{
gAIScriptPtr += 7;
return;
@@ -2515,7 +2515,7 @@ void BattleAICmd_if_last_move_did_damage(void)
gAIScriptPtr += 7;
return;
}
- else if (gUnknown_020242BC[index].unk6 != 0)
+ else if (gDisableStructs[index].unk6 != 0)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
return;
@@ -2528,7 +2528,7 @@ void BattleAICmd_if_encored(void)
switch (gAIScriptPtr[1])
{
case 0: // _08109348
- if (gUnknown_020242BC[gUnknown_02024064].unk4 == AI_THINKING_STRUCT->moveConsidered)
+ if (gDisableStructs[gActiveBank].unk4 == AI_THINKING_STRUCT->moveConsidered)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
return;
@@ -2536,7 +2536,7 @@ void BattleAICmd_if_encored(void)
gAIScriptPtr += 6;
return;
case 1: // _08109370
- if (gUnknown_020242BC[gUnknown_02024064].unk6 == AI_THINKING_STRUCT->moveConsidered)
+ if (gDisableStructs[gActiveBank].unk6 == AI_THINKING_STRUCT->moveConsidered)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
return;
@@ -2556,7 +2556,7 @@ void BattleAICmd_flee(void)
void BattleAICmd_if_random_100(void)
{
- u8 safariFleeRate = gUnknown_0202449C[0x7B] * 5; // safari flee rate, from 0-20
+ u8 safariFleeRate = gBattleStruct[0x7B] * 5; // safari flee rate, from 0-20
if ((u8)(Random() % 100) < safariFleeRate)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
@@ -2577,14 +2577,14 @@ void BattleAICmd_get_hold_effect(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
- if (gUnknown_02024064 != index)
+ if (gActiveBank != index)
{
- AI_THINKING_STRUCT->funcResult = itemid_get_x12(UNK_2016A00_STRUCT->unk44[index]);
+ AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(UNK_2016A00_STRUCT->unk44[index]);
}
else
- AI_THINKING_STRUCT->funcResult = itemid_get_x12(gBattleMons[index].item);
+ AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(gBattleMons[index].item);
gAIScriptPtr += 2;
}
@@ -2617,7 +2617,7 @@ void BattleAICmd_get_gender(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
AI_THINKING_STRUCT->funcResult = pokemon_species_get_gender_info(gBattleMons[index].species, gBattleMons[index].personality);
@@ -2631,9 +2631,9 @@ void BattleAICmd_is_first_turn(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
- AI_THINKING_STRUCT->funcResult = gUnknown_020242BC[index].unk16;
+ AI_THINKING_STRUCT->funcResult = gDisableStructs[index].unk16;
gAIScriptPtr += 2;
}
@@ -2645,9 +2645,9 @@ void BattleAICmd_get_stockpile_count(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
- AI_THINKING_STRUCT->funcResult = gUnknown_020242BC[index].unk9;
+ AI_THINKING_STRUCT->funcResult = gDisableStructs[index].unk9;
gAIScriptPtr += 2;
}
@@ -2666,10 +2666,10 @@ void BattleAICmd_get_item(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
// this hack and a half matches. whatever. i dont care. someone else fix this mess later. PS: still cant fix this.
- AI_THINKING_STRUCT->funcResult = gUnknown_0202449C[0xB8 + (index * 2)];
+ AI_THINKING_STRUCT->funcResult = gBattleStruct[0xB8 + (index * 2)];
gAIScriptPtr += 2;
}
@@ -2702,9 +2702,9 @@ void BattleAICmd_get_protect_count(void)
if (gAIScriptPtr[1] == USER)
index = gPlayerMonIndex;
else
- index = gEnemyMonIndex;
+ index = gBankTarget;
- AI_THINKING_STRUCT->funcResult = gUnknown_020242BC[index].unk8;
+ AI_THINKING_STRUCT->funcResult = gDisableStructs[index].unk8;
gAIScriptPtr += 2;
}
@@ -2755,7 +2755,7 @@ void BattleAICmd_if_level_cond(void)
switch (gAIScriptPtr[1])
{
case 0: // greater than
- if (gBattleMons[gPlayerMonIndex].level > gBattleMons[gEnemyMonIndex].level)
+ if (gBattleMons[gPlayerMonIndex].level > gBattleMons[gBankTarget].level)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
return;
@@ -2763,7 +2763,7 @@ void BattleAICmd_if_level_cond(void)
gAIScriptPtr += 6;
return;
case 1: // less than
- if (gBattleMons[gPlayerMonIndex].level < gBattleMons[gEnemyMonIndex].level)
+ if (gBattleMons[gPlayerMonIndex].level < gBattleMons[gBankTarget].level)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
return;
@@ -2771,7 +2771,7 @@ void BattleAICmd_if_level_cond(void)
gAIScriptPtr += 6;
return;
case 2: // equal
- if (gBattleMons[gPlayerMonIndex].level == gBattleMons[gEnemyMonIndex].level)
+ if (gBattleMons[gPlayerMonIndex].level == gBattleMons[gBankTarget].level)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
return;
@@ -2783,7 +2783,7 @@ void BattleAICmd_if_level_cond(void)
void BattleAICmd_if_taunted(void)
{
- if (gUnknown_020242BC[gEnemyMonIndex].taunt != 0)
+ if (gDisableStructs[gBankTarget].taunt != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
@@ -2791,7 +2791,7 @@ void BattleAICmd_if_taunted(void)
void BattleAICmd_if_not_taunted(void)
{
- if (gUnknown_020242BC[gEnemyMonIndex].taunt == 0)
+ if (gDisableStructs[gBankTarget].taunt == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
@@ -2799,7 +2799,7 @@ void BattleAICmd_if_not_taunted(void)
void tai5E_unk(void)
{
- if((gPlayerMonIndex & 1) == (gEnemyMonIndex & 1))
+ if((gPlayerMonIndex & 1) == (gBankTarget & 1))
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
diff --git a/src/play_time.c b/src/play_time.c
new file mode 100644
index 000000000..444c2c86c
--- /dev/null
+++ b/src/play_time.c
@@ -0,0 +1,73 @@
+#include "global.h"
+#include "play_time.h"
+
+enum
+{
+ STOPPED,
+ RUNNING,
+ MAXED_OUT
+};
+
+static u8 sPlayTimeCounterState;
+
+void PlayTimeCounter_Reset()
+{
+ sPlayTimeCounterState = STOPPED;
+
+ gSaveBlock2Ptr->playTimeHours = 0;
+ gSaveBlock2Ptr->playTimeMinutes = 0;
+ gSaveBlock2Ptr->playTimeSeconds = 0;
+ gSaveBlock2Ptr->playTimeVBlanks = 0;
+}
+
+void PlayTimeCounter_Start()
+{
+ sPlayTimeCounterState = RUNNING;
+
+ if (gSaveBlock2Ptr->playTimeHours > 999)
+ PlayTimeCounter_SetToMax();
+}
+
+void PlayTimeCounter_Stop()
+{
+ sPlayTimeCounterState = STOPPED;
+}
+
+void PlayTimeCounter_Update()
+{
+ if (sPlayTimeCounterState == RUNNING)
+ {
+ gSaveBlock2Ptr->playTimeVBlanks++;
+
+ if (gSaveBlock2Ptr->playTimeVBlanks > 59)
+ {
+ gSaveBlock2Ptr->playTimeVBlanks = 0;
+ gSaveBlock2Ptr->playTimeSeconds++;
+
+ if (gSaveBlock2Ptr->playTimeSeconds > 59)
+ {
+ gSaveBlock2Ptr->playTimeSeconds = 0;
+ gSaveBlock2Ptr->playTimeMinutes++;
+
+ if (gSaveBlock2Ptr->playTimeMinutes > 59)
+ {
+ gSaveBlock2Ptr->playTimeMinutes = 0;
+ gSaveBlock2Ptr->playTimeHours++;
+
+ if (gSaveBlock2Ptr->playTimeHours > 999)
+ PlayTimeCounter_SetToMax();
+ }
+ }
+ }
+ }
+}
+
+void PlayTimeCounter_SetToMax()
+{
+ sPlayTimeCounterState = MAXED_OUT;
+
+ gSaveBlock2Ptr->playTimeHours = 999;
+ gSaveBlock2Ptr->playTimeMinutes = 59;
+ gSaveBlock2Ptr->playTimeSeconds = 59;
+ gSaveBlock2Ptr->playTimeVBlanks = 59;
+}
diff --git a/src/trig.c b/src/trig.c
new file mode 100644
index 000000000..e16a69e63
--- /dev/null
+++ b/src/trig.c
@@ -0,0 +1,549 @@
+#include "global.h"
+#include "trig.h"
+
+// Converts a number to Q8.8 fixed-point format
+#define Q_8_8(n) ((s16)((n) * 256))
+
+// Converts a number to Q4.12 fixed-point format
+#define Q_4_12(n) ((s16)((n) * 4096))
+
+// Values of sin(x*(π/128)) as Q8.8 fixed-point numbers from x = 0 to x = 319
+const s16 gSineTable[] =
+{
+ Q_8_8(0), // sin(0*(π/128))
+ Q_8_8(0.0234375), // sin(1*(π/128))
+ Q_8_8(0.046875), // sin(2*(π/128))
+ Q_8_8(0.0703125), // sin(3*(π/128))
+ Q_8_8(0.09765625), // sin(4*(π/128))
+ Q_8_8(0.12109375), // sin(5*(π/128))
+ Q_8_8(0.14453125), // sin(6*(π/128))
+ Q_8_8(0.16796875), // sin(7*(π/128))
+ Q_8_8(0.19140625), // sin(8*(π/128))
+ Q_8_8(0.21875), // sin(9*(π/128))
+ Q_8_8(0.2421875), // sin(10*(π/128))
+ Q_8_8(0.265625), // sin(11*(π/128))
+ Q_8_8(0.2890625), // sin(12*(π/128))
+ Q_8_8(0.3125), // sin(13*(π/128))
+ Q_8_8(0.3359375), // sin(14*(π/128))
+ Q_8_8(0.359375), // sin(15*(π/128))
+ Q_8_8(0.37890625), // sin(16*(π/128))
+ Q_8_8(0.40234375), // sin(17*(π/128))
+ Q_8_8(0.42578125), // sin(18*(π/128))
+ Q_8_8(0.44921875), // sin(19*(π/128))
+ Q_8_8(0.46875), // sin(20*(π/128))
+ Q_8_8(0.4921875), // sin(21*(π/128))
+ Q_8_8(0.51171875), // sin(22*(π/128))
+ Q_8_8(0.53125), // sin(23*(π/128))
+ Q_8_8(0.5546875), // sin(24*(π/128))
+ Q_8_8(0.57421875), // sin(25*(π/128))
+ Q_8_8(0.59375), // sin(26*(π/128))
+ Q_8_8(0.61328125), // sin(27*(π/128))
+ Q_8_8(0.6328125), // sin(28*(π/128))
+ Q_8_8(0.65234375), // sin(29*(π/128))
+ Q_8_8(0.66796875), // sin(30*(π/128))
+ Q_8_8(0.6875), // sin(31*(π/128))
+ Q_8_8(0.70703125), // sin(32*(π/128))
+ Q_8_8(0.72265625), // sin(33*(π/128))
+ Q_8_8(0.73828125), // sin(34*(π/128))
+ Q_8_8(0.75390625), // sin(35*(π/128))
+ Q_8_8(0.76953125), // sin(36*(π/128))
+ Q_8_8(0.78515625), // sin(37*(π/128))
+ Q_8_8(0.80078125), // sin(38*(π/128))
+ Q_8_8(0.81640625), // sin(39*(π/128))
+ Q_8_8(0.828125), // sin(40*(π/128))
+ Q_8_8(0.84375), // sin(41*(π/128))
+ Q_8_8(0.85546875), // sin(42*(π/128))
+ Q_8_8(0.8671875), // sin(43*(π/128))
+ Q_8_8(0.87890625), // sin(44*(π/128))
+ Q_8_8(0.890625), // sin(45*(π/128))
+ Q_8_8(0.90234375), // sin(46*(π/128))
+ Q_8_8(0.9140625), // sin(47*(π/128))
+ Q_8_8(0.921875), // sin(48*(π/128))
+ Q_8_8(0.9296875), // sin(49*(π/128))
+ Q_8_8(0.94140625), // sin(50*(π/128))
+ Q_8_8(0.94921875), // sin(51*(π/128))
+ Q_8_8(0.953125), // sin(52*(π/128))
+ Q_8_8(0.9609375), // sin(53*(π/128))
+ Q_8_8(0.96875), // sin(54*(π/128))
+ Q_8_8(0.97265625), // sin(55*(π/128))
+ Q_8_8(0.98046875), // sin(56*(π/128))
+ Q_8_8(0.984375), // sin(57*(π/128))
+ Q_8_8(0.98828125), // sin(58*(π/128))
+ Q_8_8(0.9921875), // sin(59*(π/128))
+ Q_8_8(0.9921875), // sin(60*(π/128))
+ Q_8_8(0.99609375), // sin(61*(π/128))
+ Q_8_8(0.99609375), // sin(62*(π/128))
+ Q_8_8(0.99609375), // sin(63*(π/128))
+ Q_8_8(1), // sin(64*(π/128))
+ Q_8_8(0.99609375), // sin(65*(π/128))
+ Q_8_8(0.99609375), // sin(66*(π/128))
+ Q_8_8(0.99609375), // sin(67*(π/128))
+ Q_8_8(0.9921875), // sin(68*(π/128))
+ Q_8_8(0.9921875), // sin(69*(π/128))
+ Q_8_8(0.98828125), // sin(70*(π/128))
+ Q_8_8(0.984375), // sin(71*(π/128))
+ Q_8_8(0.98046875), // sin(72*(π/128))
+ Q_8_8(0.97265625), // sin(73*(π/128))
+ Q_8_8(0.96875), // sin(74*(π/128))
+ Q_8_8(0.9609375), // sin(75*(π/128))
+ Q_8_8(0.953125), // sin(76*(π/128))
+ Q_8_8(0.94921875), // sin(77*(π/128))
+ Q_8_8(0.94140625), // sin(78*(π/128))
+ Q_8_8(0.9296875), // sin(79*(π/128))
+ Q_8_8(0.921875), // sin(80*(π/128))
+ Q_8_8(0.9140625), // sin(81*(π/128))
+ Q_8_8(0.90234375), // sin(82*(π/128))
+ Q_8_8(0.890625), // sin(83*(π/128))
+ Q_8_8(0.87890625), // sin(84*(π/128))
+ Q_8_8(0.8671875), // sin(85*(π/128))
+ Q_8_8(0.85546875), // sin(86*(π/128))
+ Q_8_8(0.84375), // sin(87*(π/128))
+ Q_8_8(0.828125), // sin(88*(π/128))
+ Q_8_8(0.81640625), // sin(89*(π/128))
+ Q_8_8(0.80078125), // sin(90*(π/128))
+ Q_8_8(0.78515625), // sin(91*(π/128))
+ Q_8_8(0.76953125), // sin(92*(π/128))
+ Q_8_8(0.75390625), // sin(93*(π/128))
+ Q_8_8(0.73828125), // sin(94*(π/128))
+ Q_8_8(0.72265625), // sin(95*(π/128))
+ Q_8_8(0.70703125), // sin(96*(π/128))
+ Q_8_8(0.6875), // sin(97*(π/128))
+ Q_8_8(0.66796875), // sin(98*(π/128))
+ Q_8_8(0.65234375), // sin(99*(π/128))
+ Q_8_8(0.6328125), // sin(100*(π/128))
+ Q_8_8(0.61328125), // sin(101*(π/128))
+ Q_8_8(0.59375), // sin(102*(π/128))
+ Q_8_8(0.57421875), // sin(103*(π/128))
+ Q_8_8(0.5546875), // sin(104*(π/128))
+ Q_8_8(0.53125), // sin(105*(π/128))
+ Q_8_8(0.51171875), // sin(106*(π/128))
+ Q_8_8(0.4921875), // sin(107*(π/128))
+ Q_8_8(0.46875), // sin(108*(π/128))
+ Q_8_8(0.44921875), // sin(109*(π/128))
+ Q_8_8(0.42578125), // sin(110*(π/128))
+ Q_8_8(0.40234375), // sin(111*(π/128))
+ Q_8_8(0.37890625), // sin(112*(π/128))
+ Q_8_8(0.359375), // sin(113*(π/128))
+ Q_8_8(0.3359375), // sin(114*(π/128))
+ Q_8_8(0.3125), // sin(115*(π/128))
+ Q_8_8(0.2890625), // sin(116*(π/128))
+ Q_8_8(0.265625), // sin(117*(π/128))
+ Q_8_8(0.2421875), // sin(118*(π/128))
+ Q_8_8(0.21875), // sin(119*(π/128))
+ Q_8_8(0.19140625), // sin(120*(π/128))
+ Q_8_8(0.16796875), // sin(121*(π/128))
+ Q_8_8(0.14453125), // sin(122*(π/128))
+ Q_8_8(0.12109375), // sin(123*(π/128))
+ Q_8_8(0.09765625), // sin(124*(π/128))
+ Q_8_8(0.0703125), // sin(125*(π/128))
+ Q_8_8(0.046875), // sin(126*(π/128))
+ Q_8_8(0.0234375), // sin(127*(π/128))
+ Q_8_8(0), // sin(128*(π/128))
+ Q_8_8(-0.0234375), // sin(129*(π/128))
+ Q_8_8(-0.046875), // sin(130*(π/128))
+ Q_8_8(-0.0703125), // sin(131*(π/128))
+ Q_8_8(-0.09765625), // sin(132*(π/128))
+ Q_8_8(-0.12109375), // sin(133*(π/128))
+ Q_8_8(-0.14453125), // sin(134*(π/128))
+ Q_8_8(-0.16796875), // sin(135*(π/128))
+ Q_8_8(-0.19140625), // sin(136*(π/128))
+ Q_8_8(-0.21875), // sin(137*(π/128))
+ Q_8_8(-0.2421875), // sin(138*(π/128))
+ Q_8_8(-0.265625), // sin(139*(π/128))
+ Q_8_8(-0.2890625), // sin(140*(π/128))
+ Q_8_8(-0.3125), // sin(141*(π/128))
+ Q_8_8(-0.3359375), // sin(142*(π/128))
+ Q_8_8(-0.359375), // sin(143*(π/128))
+ Q_8_8(-0.37890625), // sin(144*(π/128))
+ Q_8_8(-0.40234375), // sin(145*(π/128))
+ Q_8_8(-0.42578125), // sin(146*(π/128))
+ Q_8_8(-0.44921875), // sin(147*(π/128))
+ Q_8_8(-0.46875), // sin(148*(π/128))
+ Q_8_8(-0.4921875), // sin(149*(π/128))
+ Q_8_8(-0.51171875), // sin(150*(π/128))
+ Q_8_8(-0.53125), // sin(151*(π/128))
+ Q_8_8(-0.5546875), // sin(152*(π/128))
+ Q_8_8(-0.57421875), // sin(153*(π/128))
+ Q_8_8(-0.59375), // sin(154*(π/128))
+ Q_8_8(-0.61328125), // sin(155*(π/128))
+ Q_8_8(-0.6328125), // sin(156*(π/128))
+ Q_8_8(-0.65234375), // sin(157*(π/128))
+ Q_8_8(-0.66796875), // sin(158*(π/128))
+ Q_8_8(-0.6875), // sin(159*(π/128))
+ Q_8_8(-0.70703125), // sin(160*(π/128))
+ Q_8_8(-0.72265625), // sin(161*(π/128))
+ Q_8_8(-0.73828125), // sin(162*(π/128))
+ Q_8_8(-0.75390625), // sin(163*(π/128))
+ Q_8_8(-0.76953125), // sin(164*(π/128))
+ Q_8_8(-0.78515625), // sin(165*(π/128))
+ Q_8_8(-0.80078125), // sin(166*(π/128))
+ Q_8_8(-0.81640625), // sin(167*(π/128))
+ Q_8_8(-0.828125), // sin(168*(π/128))
+ Q_8_8(-0.84375), // sin(169*(π/128))
+ Q_8_8(-0.85546875), // sin(170*(π/128))
+ Q_8_8(-0.8671875), // sin(171*(π/128))
+ Q_8_8(-0.87890625), // sin(172*(π/128))
+ Q_8_8(-0.890625), // sin(173*(π/128))
+ Q_8_8(-0.90234375), // sin(174*(π/128))
+ Q_8_8(-0.9140625), // sin(175*(π/128))
+ Q_8_8(-0.921875), // sin(176*(π/128))
+ Q_8_8(-0.9296875), // sin(177*(π/128))
+ Q_8_8(-0.94140625), // sin(178*(π/128))
+ Q_8_8(-0.94921875), // sin(179*(π/128))
+ Q_8_8(-0.953125), // sin(180*(π/128))
+ Q_8_8(-0.9609375), // sin(181*(π/128))
+ Q_8_8(-0.96875), // sin(182*(π/128))
+ Q_8_8(-0.97265625), // sin(183*(π/128))
+ Q_8_8(-0.98046875), // sin(184*(π/128))
+ Q_8_8(-0.984375), // sin(185*(π/128))
+ Q_8_8(-0.98828125), // sin(186*(π/128))
+ Q_8_8(-0.9921875), // sin(187*(π/128))
+ Q_8_8(-0.9921875), // sin(188*(π/128))
+ Q_8_8(-0.99609375), // sin(189*(π/128))
+ Q_8_8(-0.99609375), // sin(190*(π/128))
+ Q_8_8(-0.99609375), // sin(191*(π/128))
+ Q_8_8(-1), // sin(192*(π/128))
+ Q_8_8(-0.99609375), // sin(193*(π/128))
+ Q_8_8(-0.99609375), // sin(194*(π/128))
+ Q_8_8(-0.99609375), // sin(195*(π/128))
+ Q_8_8(-0.9921875), // sin(196*(π/128))
+ Q_8_8(-0.9921875), // sin(197*(π/128))
+ Q_8_8(-0.98828125), // sin(198*(π/128))
+ Q_8_8(-0.984375), // sin(199*(π/128))
+ Q_8_8(-0.98046875), // sin(200*(π/128))
+ Q_8_8(-0.97265625), // sin(201*(π/128))
+ Q_8_8(-0.96875), // sin(202*(π/128))
+ Q_8_8(-0.9609375), // sin(203*(π/128))
+ Q_8_8(-0.953125), // sin(204*(π/128))
+ Q_8_8(-0.94921875), // sin(205*(π/128))
+ Q_8_8(-0.94140625), // sin(206*(π/128))
+ Q_8_8(-0.9296875), // sin(207*(π/128))
+ Q_8_8(-0.921875), // sin(208*(π/128))
+ Q_8_8(-0.9140625), // sin(209*(π/128))
+ Q_8_8(-0.90234375), // sin(210*(π/128))
+ Q_8_8(-0.890625), // sin(211*(π/128))
+ Q_8_8(-0.87890625), // sin(212*(π/128))
+ Q_8_8(-0.8671875), // sin(213*(π/128))
+ Q_8_8(-0.85546875), // sin(214*(π/128))
+ Q_8_8(-0.84375), // sin(215*(π/128))
+ Q_8_8(-0.828125), // sin(216*(π/128))
+ Q_8_8(-0.81640625), // sin(217*(π/128))
+ Q_8_8(-0.80078125), // sin(218*(π/128))
+ Q_8_8(-0.78515625), // sin(219*(π/128))
+ Q_8_8(-0.76953125), // sin(220*(π/128))
+ Q_8_8(-0.75390625), // sin(221*(π/128))
+ Q_8_8(-0.73828125), // sin(222*(π/128))
+ Q_8_8(-0.72265625), // sin(223*(π/128))
+ Q_8_8(-0.70703125), // sin(224*(π/128))
+ Q_8_8(-0.6875), // sin(225*(π/128))
+ Q_8_8(-0.66796875), // sin(226*(π/128))
+ Q_8_8(-0.65234375), // sin(227*(π/128))
+ Q_8_8(-0.6328125), // sin(228*(π/128))
+ Q_8_8(-0.61328125), // sin(229*(π/128))
+ Q_8_8(-0.59375), // sin(230*(π/128))
+ Q_8_8(-0.57421875), // sin(231*(π/128))
+ Q_8_8(-0.5546875), // sin(232*(π/128))
+ Q_8_8(-0.53125), // sin(233*(π/128))
+ Q_8_8(-0.51171875), // sin(234*(π/128))
+ Q_8_8(-0.4921875), // sin(235*(π/128))
+ Q_8_8(-0.46875), // sin(236*(π/128))
+ Q_8_8(-0.44921875), // sin(237*(π/128))
+ Q_8_8(-0.42578125), // sin(238*(π/128))
+ Q_8_8(-0.40234375), // sin(239*(π/128))
+ Q_8_8(-0.37890625), // sin(240*(π/128))
+ Q_8_8(-0.359375), // sin(241*(π/128))
+ Q_8_8(-0.3359375), // sin(242*(π/128))
+ Q_8_8(-0.3125), // sin(243*(π/128))
+ Q_8_8(-0.2890625), // sin(244*(π/128))
+ Q_8_8(-0.265625), // sin(245*(π/128))
+ Q_8_8(-0.2421875), // sin(246*(π/128))
+ Q_8_8(-0.21875), // sin(247*(π/128))
+ Q_8_8(-0.19140625), // sin(248*(π/128))
+ Q_8_8(-0.16796875), // sin(249*(π/128))
+ Q_8_8(-0.14453125), // sin(250*(π/128))
+ Q_8_8(-0.12109375), // sin(251*(π/128))
+ Q_8_8(-0.09765625), // sin(252*(π/128))
+ Q_8_8(-0.0703125), // sin(253*(π/128))
+ Q_8_8(-0.046875), // sin(254*(π/128))
+ Q_8_8(-0.0234375), // sin(255*(π/128))
+ Q_8_8(0), // sin(256*(π/128))
+ Q_8_8(0.0234375), // sin(257*(π/128))
+ Q_8_8(0.046875), // sin(258*(π/128))
+ Q_8_8(0.0703125), // sin(259*(π/128))
+ Q_8_8(0.09765625), // sin(260*(π/128))
+ Q_8_8(0.12109375), // sin(261*(π/128))
+ Q_8_8(0.14453125), // sin(262*(π/128))
+ Q_8_8(0.16796875), // sin(263*(π/128))
+ Q_8_8(0.19140625), // sin(264*(π/128))
+ Q_8_8(0.21875), // sin(265*(π/128))
+ Q_8_8(0.2421875), // sin(266*(π/128))
+ Q_8_8(0.265625), // sin(267*(π/128))
+ Q_8_8(0.2890625), // sin(268*(π/128))
+ Q_8_8(0.3125), // sin(269*(π/128))
+ Q_8_8(0.3359375), // sin(270*(π/128))
+ Q_8_8(0.359375), // sin(271*(π/128))
+ Q_8_8(0.37890625), // sin(272*(π/128))
+ Q_8_8(0.40234375), // sin(273*(π/128))
+ Q_8_8(0.42578125), // sin(274*(π/128))
+ Q_8_8(0.44921875), // sin(275*(π/128))
+ Q_8_8(0.46875), // sin(276*(π/128))
+ Q_8_8(0.4921875), // sin(277*(π/128))
+ Q_8_8(0.51171875), // sin(278*(π/128))
+ Q_8_8(0.53125), // sin(279*(π/128))
+ Q_8_8(0.5546875), // sin(280*(π/128))
+ Q_8_8(0.57421875), // sin(281*(π/128))
+ Q_8_8(0.59375), // sin(282*(π/128))
+ Q_8_8(0.61328125), // sin(283*(π/128))
+ Q_8_8(0.6328125), // sin(284*(π/128))
+ Q_8_8(0.65234375), // sin(285*(π/128))
+ Q_8_8(0.66796875), // sin(286*(π/128))
+ Q_8_8(0.6875), // sin(287*(π/128))
+ Q_8_8(0.70703125), // sin(288*(π/128))
+ Q_8_8(0.72265625), // sin(289*(π/128))
+ Q_8_8(0.73828125), // sin(290*(π/128))
+ Q_8_8(0.75390625), // sin(291*(π/128))
+ Q_8_8(0.76953125), // sin(292*(π/128))
+ Q_8_8(0.78515625), // sin(293*(π/128))
+ Q_8_8(0.80078125), // sin(294*(π/128))
+ Q_8_8(0.81640625), // sin(295*(π/128))
+ Q_8_8(0.828125), // sin(296*(π/128))
+ Q_8_8(0.84375), // sin(297*(π/128))
+ Q_8_8(0.85546875), // sin(298*(π/128))
+ Q_8_8(0.8671875), // sin(299*(π/128))
+ Q_8_8(0.87890625), // sin(300*(π/128))
+ Q_8_8(0.890625), // sin(301*(π/128))
+ Q_8_8(0.90234375), // sin(302*(π/128))
+ Q_8_8(0.9140625), // sin(303*(π/128))
+ Q_8_8(0.921875), // sin(304*(π/128))
+ Q_8_8(0.9296875), // sin(305*(π/128))
+ Q_8_8(0.94140625), // sin(306*(π/128))
+ Q_8_8(0.94921875), // sin(307*(π/128))
+ Q_8_8(0.953125), // sin(308*(π/128))
+ Q_8_8(0.9609375), // sin(309*(π/128))
+ Q_8_8(0.96875), // sin(310*(π/128))
+ Q_8_8(0.97265625), // sin(311*(π/128))
+ Q_8_8(0.98046875), // sin(312*(π/128))
+ Q_8_8(0.984375), // sin(313*(π/128))
+ Q_8_8(0.98828125), // sin(314*(π/128))
+ Q_8_8(0.9921875), // sin(315*(π/128))
+ Q_8_8(0.9921875), // sin(316*(π/128))
+ Q_8_8(0.99609375), // sin(317*(π/128))
+ Q_8_8(0.99609375), // sin(318*(π/128))
+ Q_8_8(0.99609375), // sin(319*(π/128))
+};
+
+// values of sin(x) as Q4.12 fixed-point numbers from x = 0° to x = 179°
+const s16 gSineDegreeTable[] =
+{
+ Q_4_12(0), // sin(0°)
+ Q_4_12(0.017333984375), // sin(1°)
+ Q_4_12(0.034912109375), // sin(2°)
+ Q_4_12(0.05224609375), // sin(3°)
+ Q_4_12(0.06982421875), // sin(4°)
+ Q_4_12(0.087158203125), // sin(5°)
+ Q_4_12(0.1044921875), // sin(6°)
+ Q_4_12(0.121826171875), // sin(7°)
+ Q_4_12(0.13916015625), // sin(8°)
+ Q_4_12(0.156494140625), // sin(9°)
+ Q_4_12(0.173583984375), // sin(10°)
+ Q_4_12(0.19091796875), // sin(11°)
+ Q_4_12(0.2080078125), // sin(12°)
+ Q_4_12(0.224853515625), // sin(13°)
+ Q_4_12(0.241943359375), // sin(14°)
+ Q_4_12(0.2587890625), // sin(15°)
+ Q_4_12(0.275634765625), // sin(16°)
+ Q_4_12(0.29248046875), // sin(17°)
+ Q_4_12(0.30908203125), // sin(18°)
+ Q_4_12(0.32568359375), // sin(19°)
+ Q_4_12(0.342041015625), // sin(20°)
+ Q_4_12(0.3583984375), // sin(21°)
+ Q_4_12(0.37451171875), // sin(22°)
+ Q_4_12(0.390625), // sin(23°)
+ Q_4_12(0.40673828125), // sin(24°)
+ Q_4_12(0.422607421875), // sin(25°)
+ Q_4_12(0.4384765625), // sin(26°)
+ Q_4_12(0.4541015625), // sin(27°)
+ Q_4_12(0.469482421875), // sin(28°)
+ Q_4_12(0.48486328125), // sin(29°)
+ Q_4_12(0.5), // sin(30°)
+ Q_4_12(0.51513671875), // sin(31°)
+ Q_4_12(0.530029296875), // sin(32°)
+ Q_4_12(0.544677734375), // sin(33°)
+ Q_4_12(0.55908203125), // sin(34°)
+ Q_4_12(0.573486328125), // sin(35°)
+ Q_4_12(0.587890625), // sin(36°)
+ Q_4_12(0.601806640625), // sin(37°)
+ Q_4_12(0.61572265625), // sin(38°)
+ Q_4_12(0.62939453125), // sin(39°)
+ Q_4_12(0.642822265625), // sin(40°)
+ Q_4_12(0.656005859375), // sin(41°)
+ Q_4_12(0.669189453125), // sin(42°)
+ Q_4_12(0.681884765625), // sin(43°)
+ Q_4_12(0.694580078125), // sin(44°)
+ Q_4_12(0.70703125), // sin(45°)
+ Q_4_12(0.71923828125), // sin(46°)
+ Q_4_12(0.7314453125), // sin(47°)
+ Q_4_12(0.7431640625), // sin(48°)
+ Q_4_12(0.754638671875), // sin(49°)
+ Q_4_12(0.76611328125), // sin(50°)
+ Q_4_12(0.777099609375), // sin(51°)
+ Q_4_12(0.7880859375), // sin(52°)
+ Q_4_12(0.798583984375), // sin(53°)
+ Q_4_12(0.80908203125), // sin(54°)
+ Q_4_12(0.819091796875), // sin(55°)
+ Q_4_12(0.8291015625), // sin(56°)
+ Q_4_12(0.838623046875), // sin(57°)
+ Q_4_12(0.84814453125), // sin(58°)
+ Q_4_12(0.857177734375), // sin(59°)
+ Q_4_12(0.865966796875), // sin(60°)
+ Q_4_12(0.87451171875), // sin(61°)
+ Q_4_12(0.883056640625), // sin(62°)
+ Q_4_12(0.89111328125), // sin(63°)
+ Q_4_12(0.898681640625), // sin(64°)
+ Q_4_12(0.90625), // sin(65°)
+ Q_4_12(0.91357421875), // sin(66°)
+ Q_4_12(0.92041015625), // sin(67°)
+ Q_4_12(0.92724609375), // sin(68°)
+ Q_4_12(0.93359375), // sin(69°)
+ Q_4_12(0.939697265625), // sin(70°)
+ Q_4_12(0.945556640625), // sin(71°)
+ Q_4_12(0.951171875), // sin(72°)
+ Q_4_12(0.956298828125), // sin(73°)
+ Q_4_12(0.961181640625), // sin(74°)
+ Q_4_12(0.9658203125), // sin(75°)
+ Q_4_12(0.97021484375), // sin(76°)
+ Q_4_12(0.974365234375), // sin(77°)
+ Q_4_12(0.97802734375), // sin(78°)
+ Q_4_12(0.981689453125), // sin(79°)
+ Q_4_12(0.98486328125), // sin(80°)
+ Q_4_12(0.98779296875), // sin(81°)
+ Q_4_12(0.990234375), // sin(82°)
+ Q_4_12(0.992431640625), // sin(83°)
+ Q_4_12(0.994384765625), // sin(84°)
+ Q_4_12(0.99609375), // sin(85°)
+ Q_4_12(0.99755859375), // sin(86°)
+ Q_4_12(0.99853515625), // sin(87°)
+ Q_4_12(0.999267578125), // sin(88°)
+ Q_4_12(0.999755859375), // sin(89°)
+ Q_4_12(1), // sin(90°)
+ Q_4_12(0.999755859375), // sin(91°)
+ Q_4_12(0.999267578125), // sin(92°)
+ Q_4_12(0.99853515625), // sin(93°)
+ Q_4_12(0.99755859375), // sin(94°)
+ Q_4_12(0.99609375), // sin(95°)
+ Q_4_12(0.994384765625), // sin(96°)
+ Q_4_12(0.992431640625), // sin(97°)
+ Q_4_12(0.990234375), // sin(98°)
+ Q_4_12(0.98779296875), // sin(99°)
+ Q_4_12(0.98486328125), // sin(100°)
+ Q_4_12(0.981689453125), // sin(101°)
+ Q_4_12(0.97802734375), // sin(102°)
+ Q_4_12(0.974365234375), // sin(103°)
+ Q_4_12(0.97021484375), // sin(104°)
+ Q_4_12(0.9658203125), // sin(105°)
+ Q_4_12(0.961181640625), // sin(106°)
+ Q_4_12(0.956298828125), // sin(107°)
+ Q_4_12(0.951171875), // sin(108°)
+ Q_4_12(0.945556640625), // sin(109°)
+ Q_4_12(0.939697265625), // sin(110°)
+ Q_4_12(0.93359375), // sin(111°)
+ Q_4_12(0.92724609375), // sin(112°)
+ Q_4_12(0.92041015625), // sin(113°)
+ Q_4_12(0.91357421875), // sin(114°)
+ Q_4_12(0.90625), // sin(115°)
+ Q_4_12(0.898681640625), // sin(116°)
+ Q_4_12(0.89111328125), // sin(117°)
+ Q_4_12(0.883056640625), // sin(118°)
+ Q_4_12(0.87451171875), // sin(119°)
+ Q_4_12(0.865966796875), // sin(120°)
+ Q_4_12(0.857177734375), // sin(121°)
+ Q_4_12(0.84814453125), // sin(122°)
+ Q_4_12(0.838623046875), // sin(123°)
+ Q_4_12(0.8291015625), // sin(124°)
+ Q_4_12(0.819091796875), // sin(125°)
+ Q_4_12(0.80908203125), // sin(126°)
+ Q_4_12(0.798583984375), // sin(127°)
+ Q_4_12(0.7880859375), // sin(128°)
+ Q_4_12(0.777099609375), // sin(129°)
+ Q_4_12(0.76611328125), // sin(130°)
+ Q_4_12(0.754638671875), // sin(131°)
+ Q_4_12(0.7431640625), // sin(132°)
+ Q_4_12(0.7314453125), // sin(133°)
+ Q_4_12(0.71923828125), // sin(134°)
+ Q_4_12(0.70703125), // sin(135°)
+ Q_4_12(0.694580078125), // sin(136°)
+ Q_4_12(0.681884765625), // sin(137°)
+ Q_4_12(0.669189453125), // sin(138°)
+ Q_4_12(0.656005859375), // sin(139°)
+ Q_4_12(0.642822265625), // sin(140°)
+ Q_4_12(0.62939453125), // sin(141°)
+ Q_4_12(0.61572265625), // sin(142°)
+ Q_4_12(0.601806640625), // sin(143°)
+ Q_4_12(0.587890625), // sin(144°)
+ Q_4_12(0.573486328125), // sin(145°)
+ Q_4_12(0.55908203125), // sin(146°)
+ Q_4_12(0.544677734375), // sin(147°)
+ Q_4_12(0.530029296875), // sin(148°)
+ Q_4_12(0.51513671875), // sin(149°)
+ Q_4_12(0.5), // sin(150°)
+ Q_4_12(0.48486328125), // sin(151°)
+ Q_4_12(0.469482421875), // sin(152°)
+ Q_4_12(0.4541015625), // sin(153°)
+ Q_4_12(0.4384765625), // sin(154°)
+ Q_4_12(0.422607421875), // sin(155°)
+ Q_4_12(0.40673828125), // sin(156°)
+ Q_4_12(0.390625), // sin(157°)
+ Q_4_12(0.37451171875), // sin(158°)
+ Q_4_12(0.3583984375), // sin(159°)
+ Q_4_12(0.342041015625), // sin(160°)
+ Q_4_12(0.32568359375), // sin(161°)
+ Q_4_12(0.30908203125), // sin(162°)
+ Q_4_12(0.29248046875), // sin(163°)
+ Q_4_12(0.275634765625), // sin(164°)
+ Q_4_12(0.2587890625), // sin(165°)
+ Q_4_12(0.241943359375), // sin(166°)
+ Q_4_12(0.224853515625), // sin(167°)
+ Q_4_12(0.2080078125), // sin(168°)
+ Q_4_12(0.19091796875), // sin(169°)
+ Q_4_12(0.173583984375), // sin(170°)
+ Q_4_12(0.156494140625), // sin(171°)
+ Q_4_12(0.13916015625), // sin(172°)
+ Q_4_12(0.121826171875), // sin(173°)
+ Q_4_12(0.1044921875), // sin(174°)
+ Q_4_12(0.087158203125), // sin(175°)
+ Q_4_12(0.06982421875), // sin(176°)
+ Q_4_12(0.05224609375), // sin(177°)
+ Q_4_12(0.034912109375), // sin(178°)
+ Q_4_12(0.017333984375), // sin(179°)
+};
+
+// amplitude * sin(index*(π/128))
+s16 Sin(s16 index, s16 amplitude)
+{
+ return (amplitude * gSineTable[index]) >> 8;
+}
+
+// amplitude * cos(index*(π/128))
+s16 Cos(s16 index, s16 amplitude)
+{
+ return (amplitude * gSineTable[index + 64]) >> 8;
+}
+
+// angle in degrees
+s16 Sin2(u16 angle)
+{
+ s32 angleMod = angle % 180;
+ s32 negate = ((angle / 180) & 1);
+ s16 value = gSineDegreeTable[angleMod];
+
+ if (negate)
+ return -value;
+ else
+ return value;
+}
+
+// angle in degrees
+s16 Cos2(u16 angle)
+{
+ return Sin2(angle + 90);
+}