diff options
Diffstat (limited to 'src/battle')
-rw-r--r-- | src/battle/battle_2.c | 145 | ||||
-rw-r--r-- | src/battle/battle_3.c | 30 | ||||
-rw-r--r-- | src/battle/battle_4.c | 100 | ||||
-rw-r--r-- | src/battle/battle_7.c | 41 | ||||
-rw-r--r-- | src/battle/battle_ai.c | 8 | ||||
-rw-r--r-- | src/battle/battle_anim.c | 2 | ||||
-rw-r--r-- | src/battle/battle_anim_807B69C.c | 1 | ||||
-rw-r--r-- | src/battle/battle_controller_linkopponent.c | 1 | ||||
-rw-r--r-- | src/battle/battle_controller_linkpartner.c | 1 | ||||
-rw-r--r-- | src/battle/battle_controller_opponent.c | 11 | ||||
-rw-r--r-- | src/battle/battle_controller_player.c | 7 | ||||
-rw-r--r-- | src/battle/battle_controller_safari.c | 1 | ||||
-rw-r--r-- | src/battle/battle_controller_wally.c | 57 | ||||
-rw-r--r-- | src/battle/battle_interface.c | 11 | ||||
-rw-r--r-- | src/battle/battle_message.c | 3 | ||||
-rw-r--r-- | src/battle/battle_party_menu.c | 6 | ||||
-rw-r--r-- | src/battle/battle_transition.c | 7 | ||||
-rw-r--r-- | src/battle/calculate_base_damage.c | 4 | ||||
-rw-r--r-- | src/battle/pokeball.c | 1 | ||||
-rw-r--r-- | src/battle/reshow_battle_screen.c | 4 |
20 files changed, 184 insertions, 257 deletions
diff --git a/src/battle/battle_2.c b/src/battle/battle_2.c index 1aec075db..14afc1537 100644 --- a/src/battle/battle_2.c +++ b/src/battle/battle_2.c @@ -29,6 +29,7 @@ #include "items.h" #include "hold_effects.h" #include "battle_move_effects.h" +#include "ewram.h" struct UnknownStruct6 { @@ -62,48 +63,6 @@ struct UnknownStruct12 extern const u16 gUnknown_08D004E0[]; extern const struct MonCoords gCastformFrontSpriteCoords[]; -extern u8 ewram[]; -#define ewram0 (*(struct UnknownStruct7 *)(ewram + 0x0)) -#define ewram4 (*(struct UnknownStruct8 *)(ewram + 0x4)) -#define ewram16000 (ewram[0x16000]) -#define ewram16001 (ewram[0x16001]) -#define ewram16002 (ewram[0x16002]) -#define ewram16003 (ewram[0x16003]) -#define ewram1600C (ewram[0x1600C]) -#define ewram1600E (ewram[0x1600E]) -#define ewram1601B (ewram[0x1601B]) -#define ewram16020 ((u8 *)(ewram + 0x16020)) -#define ewram16056 (ewram[0x16056]) -#define ewram16058 (ewram[0x16058]) -#define ewram16059 (ewram[0x16059]) -#define ewram16078 (ewram[0x16078]) -#define ewram16084 (ewram[0x16084]) -#define ewram16086 (ewram[0x16086]) -#define ewram16087 (ewram[0x16087]) -#define ewram16088 (ewram[0x16088]) -#define ewram16089 (ewram[0x16089]) -#define ewram160A1 (ewram[0x160A1]) -#define ewram160A6 (ewram[0x160A6]) -#define ewram160AC ((u8 *)(ewram + 0x160AC)) -#define ewram160BC ((u16 *)(ewram + 0x160BC)) // hp -#define ewram160C8 (ewram[0x160C8]) -#define ewram160C9 (ewram[0x160C9]) -#define ewram160CB (ewram[0x160CB]) -#define ewram160CC ((u8 *)(ewram + 0x160CC)) -#define ewram160E6 (ewram[0x160E6]) -#define ewram160E8 ((u8 *)(ewram + 0x160E8)) -#define ewram160F0 ((u8 *)(ewram + 0x160F0)) -#define ewram160F9 (ewram[0x160F9]) -#define ewram16100 ((u8 *)(ewram + 0x16100)) -#define ewram16108 ((u8 *)(ewram + 0x16108)) -#define ewram16110 (ewram[0x16110]) -#define ewram16111 (ewram[0x16111]) -#define ewram16113 (ewram[0x16113]) -#define ewram17100 ((u32 *)(ewram + 0x17100)) -#define ewram17130 (ewram[0x17130]) -#define ewram17160 (ewram[0x17160]) -#define ewram1D000 ((struct Pokemon *)(ewram + 0x1D000)) - extern struct UnknownPokemonStruct2 gUnknown_02023A00[]; extern u8 gBattleBufferB[][0x200]; extern u8 gActiveBank; @@ -294,8 +253,8 @@ void sub_800E9EC(void) if (species != SPECIES_EGG && hp == 0) r6 |= 3 << i * 2; } - ewram0.unk2 = r6; - ewram0.unk3 = r6 >> 8; + BATTLE_STRUCT->unk2 = r6; + BATTLE_STRUCT->unk3 = r6 >> 8; } void sub_800EAAC(void) @@ -391,11 +350,11 @@ void sub_800EC9C(void) { if (gReceivedRemoteLinkPlayers != 0 && sub_8007ECC()) { - ewram0.unk0 = 1; - ewram0.unk1 = 1; + BATTLE_STRUCT->unk0 = 1; + BATTLE_STRUCT->unk1 = 1; sub_800E9EC(); sub_800EAAC(); - SendBlock(bitmask_all_link_players_but_self(), &ewram0, 32); + SendBlock(bitmask_all_link_players_but_self(), BATTLE_STRUCT, 32); gBattleCommunication[0] = 1; } } @@ -451,7 +410,7 @@ void sub_800EC9C(void) gTasks[taskId].data[1] = 0x10E; gTasks[taskId].data[2] = 0x5A; gTasks[taskId].data[5] = 0; - gTasks[taskId].data[3] = ewram0.unk2 | (ewram0.unk3 << 8); + gTasks[taskId].data[3] = BATTLE_STRUCT->unk2 | (BATTLE_STRUCT->unk3 << 8); gTasks[taskId].data[4] = gBlockRecvBuffer[enemyId][1]; gBattleCommunication[0]++; } @@ -551,7 +510,7 @@ void sub_800F02C(void) if (gUnknown_02023A00[i].language != 1) PadNameString(nickname, 0); } - memcpy(ewram, gUnknown_02023A00, 0x60); + memcpy(gSharedMem, gUnknown_02023A00, 0x60); } void sub_800F104(void) @@ -563,8 +522,8 @@ void sub_800F104(void) playerId = GetMultiplayerId(); ewram160CB = playerId; // Seriously, Game Freak? - pSavedCallback = (MainCallback *)(ewram + 0x160C4); - pSavedBattleTypeFlags = (u16 *)(ewram + 0x160C2); + pSavedCallback = ewram160C4_Callback; + pSavedBattleTypeFlags = ewram160C2_Flags; RunTasks(); AnimateSprites(); BuildOamBuffer(); @@ -575,7 +534,7 @@ void sub_800F104(void) if (gReceivedRemoteLinkPlayers != 0 && sub_8007ECC()) { sub_800F02C(); - SendBlock(bitmask_all_link_players_but_self(), ewram, 0x60); + SendBlock(bitmask_all_link_players_but_self(), gSharedMem, 0x60); gBattleCommunication[0]++; } break; @@ -634,11 +593,11 @@ void sub_800F298(void) case 0: if (gReceivedRemoteLinkPlayers != 0 && sub_8007ECC()) { - ewram0.unk0 = 1; - ewram0.unk1 = 1; + BATTLE_STRUCT->unk0 = 1; + BATTLE_STRUCT->unk1 = 1; sub_800E9EC(); sub_800EAAC(); - SendBlock(bitmask_all_link_players_but_self(), ewram, 0x20); + SendBlock(bitmask_all_link_players_but_self(), gSharedMem, 0x20); gBattleCommunication[0]++; } break; @@ -904,7 +863,7 @@ void sub_800F828(struct Sprite *sprite) void sub_800F838(struct Sprite *sprite) { - u16 *arr = (u16 *)ewram; + u16 *arr = (u16 *)gSharedMem; switch (sprite->data0) { @@ -1578,7 +1537,7 @@ void sub_8010874(void) gUnknown_02024C5C[i] = 0xFF; gLockedMove[i] = 0; gUnknown_02024C2C[i] = 0; - ewram17100[i] = 0; + eFlashFireArr.arr[i] = 0; } for (i = 0; i < 2; i++) @@ -1622,12 +1581,12 @@ void sub_8010874(void) for (i = 0; i < 8; i++) { - ewram[i + 0x160AC] = 0; - ewram[i + 0x160CC] = 0; - ewram[i + 0x160E8] = 0; - ewram[i + 0x160F0] = 0; - ewram[i + 0x16100] = 0; - ewram[i + 0x16108] = 0; + ewram160ACarr(i) = 0; + ewram160CCarr(i) = 0; + ewram160E8arr(i) = 0; + ewram160F0arr(i) = 0; + ewram16100arr(i) = 0; + ewram16108arr(i) = 0; } ewram160C8 = 6; @@ -1662,7 +1621,6 @@ void SwitchInClearStructs(void) struct DisableStruct sp0 = gDisableStructs[gActiveBank]; s32 i; u8 *ptr; - u32 *ptr2; if (gBattleMoves[gCurrentMove].effect != EFFECT_BATON_PASS) { @@ -1707,7 +1665,7 @@ void SwitchInClearStructs(void) { if (gUnknown_02024AD0[i].unk0 & (gBitTable[gActiveBank] << 16)) gUnknown_02024AD0[i].unk0 &= ~(gBitTable[gActiveBank] << 16); - if ((gUnknown_02024AD0[i].unk0 & 0xE000) && ewram[0x16020 + i] == gActiveBank) + if ((gUnknown_02024AD0[i].unk0 & 0xE000) && ewram16020arr(i) == gActiveBank) gUnknown_02024AD0[i].unk0 &= ~0xE000; } @@ -1732,17 +1690,16 @@ void SwitchInClearStructs(void) gUnknown_02024C2C[gActiveBank] = 0; gUnknown_02024C5C[gActiveBank] = 0xFF; - ewram[0x160AC + gActiveBank * 2 + 0] = 0; - ewram[0x160AC + gActiveBank * 2 + 1] = 0; - ewram[0x16100 + gActiveBank * 4 + 0] = 0; - ewram[0x16100 + gActiveBank * 4 + 1] = 0; - ewram[0x16100 + gActiveBank * 4 + 2] = 0; - ewram[0x16100 + gActiveBank * 4 + 3] = 0; - ewram[0x160E8 + gActiveBank * 2 + 0] = 0; - ewram[0x160E8 + gActiveBank * 2 + 1] = 0; + ewram160ACarr2(0, gActiveBank) = 0; + ewram160ACarr2(1, gActiveBank) = 0; + ewram16100arr2(0, gActiveBank) = 0; + ewram16100arr2(1, gActiveBank) = 0; + ewram16100arr2(2, gActiveBank) = 0; + ewram16100arr2(3, gActiveBank) = 0; + ewram160E8arr2(0, gActiveBank) = 0; + ewram160E8arr2(1, gActiveBank) = 0; - ptr2 = (u32 *)(ewram + 0x17100); - ptr2[gActiveBank] = 0; + eFlashFireArr.arr[gActiveBank] = 0; gCurrentMove = 0; } @@ -1751,7 +1708,6 @@ void UndoEffectsAfterFainting(void) { s32 i; u8 *ptr; - u32 *ptr2; for (i = 0; i < 8; i++) gBattleMons[gActiveBank].statStages[i] = 6; @@ -1763,7 +1719,7 @@ void UndoEffectsAfterFainting(void) gBattleMons[i].status2 &= ~STATUS2_ESCAPE_PREVENTION; if (gBattleMons[i].status2 & (gBitTable[gActiveBank] << 16)) gBattleMons[i].status2 &= ~(gBitTable[gActiveBank] << 16); - if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && ewram[0x16020 + i] == gActiveBank) + if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && ewram16020arr(i) == gActiveBank) gBattleMons[i].status2 &= ~STATUS2_WRAPPED; } gActionSelectionCursor[gActiveBank] = 0; @@ -1798,17 +1754,16 @@ void UndoEffectsAfterFainting(void) gUnknown_02024C2C[gActiveBank] = 0; gUnknown_02024C5C[gActiveBank] = 0xFF; - ewram[0x160E8 + gActiveBank * 2 + 0] = 0; - ewram[0x160E8 + gActiveBank * 2 + 1] = 0; - ewram[0x160AC + gActiveBank * 2 + 0] = 0; - ewram[0x160AC + gActiveBank * 2 + 1] = 0; - ewram[0x16100 + gActiveBank * 4 + 0] = 0; - ewram[0x16100 + gActiveBank * 4 + 1] = 0; - ewram[0x16100 + gActiveBank * 4 + 2] = 0; - ewram[0x16100 + gActiveBank * 4 + 3] = 0; + ewram160E8arr2(0, gActiveBank) = 0; + ewram160E8arr2(1, gActiveBank) = 0; + ewram160ACarr2(0, gActiveBank) = 0; + ewram160ACarr2(1, gActiveBank) = 0; + ewram16100arr2(0, gActiveBank) = 0; + ewram16100arr2(1, gActiveBank) = 0; + ewram16100arr2(2, gActiveBank) = 0; + ewram16100arr2(3, gActiveBank) = 0; - ptr2 = (u32 *)(ewram + 0x17100); - ptr2[gActiveBank] = 0; + eFlashFireArr.arr[gActiveBank] = 0; gBattleMons[gActiveBank].type1 = gBaseStats[gBattleMons[gActiveBank].species].type1; gBattleMons[gActiveBank].type2 = gBaseStats[gBattleMons[gActiveBank].species].type2; @@ -2169,7 +2124,7 @@ void BattleBeginFirstTurn(void) ; for (i = 0; i < 4; i++) { - ewram[0x16068 + i] = 6; + ewram16068arr(i) = 6; gActionForBanks[i] = 0xFF; gChosenMovesByBanks[i] = 0; } @@ -2261,7 +2216,7 @@ void BattleTurnPassed(void) gChosenMovesByBanks[i] = 0; } for (i = 0; i < 4; i++) - ewram[0x16068 + i] = 6; + ewram16068arr(i) = 6; ewram160A6 = gAbsentBankFlags; gBattleMainFunc = sub_8012324; gRandomTurnNumber = Random(); @@ -2335,23 +2290,23 @@ void sub_8012258(u8 a) u8 r1; for (i = 0; i < 3; i++) - gUnknown_02038470[i] = ewram[0x1606C + i + a * 3]; + gUnknown_02038470[i] = ewram1606Carr(i, a); r4 = pokemon_order_func(gBattlePartyID[a]); - r1 = pokemon_order_func(ewram[0x16068 + a]); + r1 = pokemon_order_func(ewram16068arr(a)); sub_8094C98(r4, r1); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { for (i = 0; i < 3; i++) { - ewram[0x1606C + i + a * 3] = gUnknown_02038470[i]; - ewram[0x1606C + i + (a ^ 2) * 3] = gUnknown_02038470[i]; + ewram1606Carr(i, a) = gUnknown_02038470[i]; + ewram1606Carr(i, (a ^ 2)) = gUnknown_02038470[i]; } } else { for (i = 0; i < 3; i++) { - ewram[0x1606C + i + a * 3] = gUnknown_02038470[i]; + ewram1606Carr(i, a) = gUnknown_02038470[i]; } } } @@ -2370,7 +2325,7 @@ void sub_8012324(void) switch (gBattleCommunication[gActiveBank]) { case 0: - ewram[0x016068 + gActiveBank] = 6; + ewram16068arr(gActiveBank) = 6; if (!(gBattleTypeFlags & 0x40) && (r5 & 2) && !(ewram160A6 & gBitTable[GetBankByPlayerAI(r5 ^ 2)]) diff --git a/src/battle/battle_3.c b/src/battle/battle_3.c index 346ca6d79..f37111af5 100644 --- a/src/battle/battle_3.c +++ b/src/battle/battle_3.c @@ -13,6 +13,7 @@ #include "battle_move_effects.h" #include "string_util.h" #include "flags.h" +#include "ewram.h" extern u8* gBattlescriptCurrInstr; extern u8 gActiveBank; @@ -198,8 +199,6 @@ extern u8 gUnknown_081D996F[]; //disobedient, uses a random move extern u8 gUnknown_081D9989[]; //disobedient, went to sleep extern u8 gUnknown_081D99A0[]; //disobedient, hits itself -#define CHOICED_MOVE(bank)(((u16*)(&ewram[bank * 2 + 0x160e8]))) - //array entries for battle communication #define MOVE_EFFECT_BYTE 0x3 #define MULTISTRING_CHOOSER 0x5 @@ -722,12 +721,12 @@ u8 TurnBasedEffects(void) gBattleMons[gActiveBank].status2 -= 0x2000; if (gBattleMons[gActiveBank].status2 & STATUS2_WRAPPED) // damaged by wrap { - BATTLE_STRUCT->animArg1 = ewram[gActiveBank * 2 + 0x16004]; - BATTLE_STRUCT->animArg2 = ewram[gActiveBank * 2 + 0x16005]; + BATTLE_STRUCT->animArg1 = ewram16004arr(0, gActiveBank); + BATTLE_STRUCT->animArg2 = ewram16004arr(1, gActiveBank); gBattleTextBuff1[0] = 0xFD; gBattleTextBuff1[1] = 2; - gBattleTextBuff1[2] = ewram[gActiveBank * 2 + 0x16004]; - gBattleTextBuff1[3] = ewram[gActiveBank * 2 + 0x16005]; + gBattleTextBuff1[2] = ewram16004arr(0, gActiveBank); + gBattleTextBuff1[3] = ewram16004arr(1, gActiveBank); gBattleTextBuff1[4] = EOS; gBattlescriptCurrInstr = BattleScript_WrapTurnDmg; gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 16; @@ -738,8 +737,8 @@ u8 TurnBasedEffects(void) { gBattleTextBuff1[0] = 0xFD; gBattleTextBuff1[1] = 2; - gBattleTextBuff1[2] = ewram[gActiveBank * 2 + 0x16004]; - gBattleTextBuff1[3] = ewram[gActiveBank * 2 + 0x16005]; + gBattleTextBuff1[2] = ewram16004arr(0, gActiveBank); + gBattleTextBuff1[3] = ewram16004arr(1, gActiveBank); gBattleTextBuff1[4] = EOS; gBattlescriptCurrInstr = BattleScript_WrapEnds; } @@ -1378,7 +1377,7 @@ bool8 sub_8018018(u8 bank, u8 r1, u8 r2) r2 = gBattlePartyID[r6]; for (i = 0; i < 6; i++) { - if (GetMonData(&party[i], MON_DATA_HP) && GetMonData(&party[i], MON_DATA_SPECIES2) && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG && i != r1 && i != r2 && i != ewram[r7 + 0x16068] && i != ewram[r6 + 0x16068]) + if (GetMonData(&party[i], MON_DATA_HP) && GetMonData(&party[i], MON_DATA_SPECIES2) && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG && i != r1 && i != r2 && i != ewram16068arr(r7) && i != ewram16068arr(r6)) break; } return (i == 6); @@ -1434,13 +1433,6 @@ u8 CastformDataTypeChange(u8 bank) return formChange; } -struct Struct2017100 -{ - u32 arr[4]; -}; - -#define ewram17100 (*(struct Struct2017100 *)(ewram + 0x17100)) - u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { u8 effect = 0; @@ -1726,14 +1718,14 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) case ABILITY_FLASH_FIRE: if (moveType == TYPE_FIRE && !(gBattleMons[bank].status1 & STATUS_FREEZE)) { - if (!(ewram17100.arr[bank] & 1)) + if (!(eFlashFireArr.arr[bank] & 1)) { gBattleCommunication[MULTISTRING_CHOOSER] = 0; if (gProtectStructs[gBankAttacker].notFirstStrike) gBattlescriptCurrInstr = BattleScript_FlashFireBoost; else gBattlescriptCurrInstr = BattleScript_FlashFireBoost_PPLoss; - ewram17100.arr[bank] |= 1; + eFlashFireArr.arr[bank] |= 1; effect = 2; } else @@ -3131,7 +3123,7 @@ u8 GetMoveTarget(u16 move, u8 useMoveTarget) //get move target targetBank = gBankAttacker; break; } - ewram[gBankAttacker + 0x16010] = targetBank; + ewram16010arr(gBankAttacker) = targetBank; return targetBank; } diff --git a/src/battle/battle_4.c b/src/battle/battle_4.c index 65e0458a2..d7ca298c3 100644 --- a/src/battle/battle_4.c +++ b/src/battle/battle_4.c @@ -19,6 +19,7 @@ #include "task.h" #include "decompress.h" #include "naming_screen.h" +#include "ewram.h" //extern needed variables extern u8 gCritMultiplier; @@ -259,8 +260,6 @@ extern u8 gUnknown_081D9468[]; #define sBYTE2_32(value)(( (u8) (((s32)(value) & (0x00FF0000)) >> 0x10))) #define sBYTE3_32(value)(( (u8) (((s32)(value) & (0xFF000000)) >> 0x18))) -#define USED_HELD_ITEM(bank)((((u16*)(&unk_2000000[bank * 2 + 0x160cc])))) - #define RecordAbilitySetField6(ability, fieldValue) \ (gLastUsedAbility = ability, gBattleCommunication[6] = fieldValue, RecordAbilityBattle(gBankTarget, ability)) @@ -2640,7 +2639,7 @@ void SetMoveEffect(bool8 primary, u8 certainArg) {gBattlescriptCurrInstr++; return;} gLastUsedItem = gBattleMons[gBankTarget].item; - unk_2000000[gBankAttacker * 2 + 0x160cc] = gLastUsedItem; + USED_HELD_ITEM(bank) = gLastUsedItem; gBattleMons[gBankTarget].item = 0; gActiveBank = gBankAttacker; @@ -2654,8 +2653,7 @@ void SetMoveEffect(bool8 primary, u8 certainArg) b_movescr_stack_push(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_ItemSteal; - ewram[gBankTarget * 2 + 0x160e8] = 0; - //STORE_CHOICEMOVE(gBankTarget, 0); + CHOICED_MOVE(gBankTarget) = 0; } break; case 32: //escape prevention @@ -2730,8 +2728,7 @@ void SetMoveEffect(bool8 primary, u8 certainArg) b_movescr_stack_push(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_KnockedOff; - ewram[gEffectBank * 2 + 0x160e8] = 0; - //STORE_CHOICEMOVE(gEffectBank, 0); + CHOICED_MOVE(gEffectBank) = 0; } break; case 59: //overheat @@ -4999,12 +4996,12 @@ static void atk19_faint_pokemon(void) if (!(gAbsentBankFlags & gBitTable[gActiveBank]) && gBattleMons[gActiveBank].hp == 0) { - ewram[0x160AC + bank * 2 + 0] = 0; - ewram[0x160AC + bank * 2 + 1] = 0; - ewram[0x16100 + bank * 4 + 0] = 0; - ewram[0x16100 + bank * 4 + 1] = 0; - ewram[0x16100 + bank * 4 + 2] = 0; - ewram[0x16100 + bank * 4 + 3] = 0; + ewram160ACarr2(0, bank) = 0; + ewram160ACarr2(1, bank) = 0; + ewram16100arr2(0, bank) = 0; + ewram16100arr2(1, bank) = 0; + ewram16100arr2(2, bank) = 0; + ewram16100arr2(3, bank) = 0; gHitMarker |= HITMARKER_FAINTED(gActiveBank); b_movescr_stack_push(gBattlescriptCurrInstr + 7); @@ -5040,7 +5037,7 @@ static void atk19_faint_pokemon(void) && gBattleMons[gBankAttacker].hp != 0 && gCurrentMove != MOVE_STRUGGLE) { - u8 moveIndex = ewram[0x1608C + gBankAttacker]; + u8 moveIndex = ewram1608Carr(gBankAttacker); gBattleMons[gBankAttacker].pp[moveIndex] = 0; b_movescr_stack_push(gBattlescriptCurrInstr); @@ -5123,7 +5120,7 @@ static void atk1E_jumpifability(void) gLastUsedAbility = ability; gBattlescriptCurrInstr = jump_loc; RecordAbilityBattle(bank -1, gLastUsedAbility); - unk_2000000[0x160f8] = bank - 1; + ewram160F8 = bank - 1; } else gBattlescriptCurrInstr += 7; @@ -5136,7 +5133,7 @@ static void atk1E_jumpifability(void) gLastUsedAbility = ability; gBattlescriptCurrInstr = jump_loc; RecordAbilityBattle(bank - 1, gLastUsedAbility); - unk_2000000[0x160f8] = bank - 1; + ewram160F8 = bank - 1; } else gBattlescriptCurrInstr += 7; @@ -5149,7 +5146,7 @@ static void atk1E_jumpifability(void) gLastUsedAbility = ability; gBattlescriptCurrInstr = jump_loc; RecordAbilityBattle(bank, gLastUsedAbility); - unk_2000000[0x160f8] = bank; + ewram160F8 = bank; } else gBattlescriptCurrInstr += 7; @@ -7327,11 +7324,10 @@ static void atk43_jumpifabilitypresent(void) static void atk44(void) { - unk_2000000[gBankAttacker + 0x16060] = 1; + ewram16060(gBankAttacker) = 1; } #ifdef NONMATCHING - static void atk45_playanimation(void) { #define ANIMATION_ID T2_READ_8(gBattlescriptCurrInstr + 2) @@ -9522,7 +9518,7 @@ static void atk4C_copy_poke_data(void) gActiveBank = GetBattleBank(T2_READ_8(gBattlescriptCurrInstr + 1)); - gBattlePartyID[gActiveBank] = unk_2000000[0x16068 + gActiveBank]; + gBattlePartyID[gActiveBank] = ewram16068arr(gActiveBank); EmitGetAttributes(0, 0, gBitTable[gBattlePartyID[gActiveBank]]); MarkBufferBankForExecution(gActiveBank); @@ -9672,8 +9668,7 @@ static void atk4F_jump_if_cannot_switch(void) void sub_8022A3C(u8 unkown) { - //BATTLE_STRUCT->unk16064[gActiveBank] = gBattlePartyID[gActiveBank]; - ewram[gActiveBank + 0x16064] = gBattlePartyID[gActiveBank]; + BATTLE_PARTY_ID(gActiveBank) = gBattlePartyID[gActiveBank]; EmitChoosePokemon(0, 1, unkown, 0, BATTLE_STRUCT->unk1606C[gActiveBank]); MarkBufferBankForExecution(gActiveBank); } @@ -10761,7 +10756,7 @@ static void atk51_switch_handle_order(void) for (i = 0; i < gNoOfAllBanks; i++) { if (gBattleBufferB[i][0] == 0x22) - ewram[i + 0x16068] = gBattleBufferB[i][1]; + ewram16068arr(i) = gBattleBufferB[i][1]; } break; case 1: @@ -10770,17 +10765,15 @@ static void atk51_switch_handle_order(void) break; case 2: gBattleCommunication[0] = gBattleBufferB[gActiveBank][1]; - ewram[gActiveBank + 0x16068] = gBattleBufferB[gActiveBank][1]; + ewram16068arr(gActiveBank) = gBattleBufferB[gActiveBank][1]; if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - - ewram[(gActiveBank) * 3 + (0x1606C + 0)] &= 0xF; - ewram[(gActiveBank) * 3 + (0x1606C + 0)] |= (gBattleBufferB[gActiveBank][2] & 0xF0); - ewram[(gActiveBank) * 3 + (0x1606C + 1)] = gBattleBufferB[gActiveBank][3]; - - ewram[(gActiveBank ^ 2) * 3 + (0x1606C + 0)] &= (0xF0); - ewram[(gActiveBank ^ 2) * 3 + (0x1606C + 0)] |= (gBattleBufferB[gActiveBank][2] & 0xF0) >> 4; - ewram[(gActiveBank ^ 2) * 3 + (0x1606C + 2)] = gBattleBufferB[gActiveBank][3]; + ewram1606Carr(0, gActiveBank) &= 0xF; + ewram1606Carr(0, gActiveBank) |= (gBattleBufferB[gActiveBank][2] & 0xF0); + ewram1606Carr(1, gActiveBank) = gBattleBufferB[gActiveBank][3]; + ewram1606Carr(0, (gActiveBank ^ 2)) &= (0xF0); + ewram1606Carr(0, (gActiveBank ^ 2)) |= (gBattleBufferB[gActiveBank][2] & 0xF0) >> 4; + ewram1606Carr(2, (gActiveBank ^ 2)) = gBattleBufferB[gActiveBank][3]; } else sub_8012258(gActiveBank); @@ -11640,7 +11633,6 @@ static void atk69_dmg_adjustment2(void) //literally a copy of atk07 except there void atk6A_removeitem(void) { gActiveBank = GetBattleBank(T2_READ_8(gBattlescriptCurrInstr + 1)); - #define USED_HELD_ITEMS(bank) (*(u16 *)&ewram[0x160CC + 2 * (bank)]) USED_HELD_ITEMS(gActiveBank) = gBattleMons[gActiveBank].item; gBattleMons[gActiveBank].item = 0; @@ -12170,7 +12162,7 @@ static void atk74_hp_thresholds2(void) { gActiveBank = GetBattleBank(T2_READ_8(gBattlescriptCurrInstr + 1)); opposing_bank = gActiveBank ^ 1; - hp_switchout = ewram[2 * GetBankSide(opposing_bank) + 0x160bc]; //BATTLE_STRUCT->HP_OnSwitchout[GetBankSide(opposing_bank)]; + hp_switchout = ewram160BCarr(GetBankSide(opposing_bank)); //BATTLE_STRUCT->HP_OnSwitchout[GetBankSide(opposing_bank)]; result = (hp_switchout - gBattleMons[opposing_bank].hp) * 100 / hp_switchout; if (gBattleMons[opposing_bank].hp >= hp_switchout) @@ -12244,7 +12236,7 @@ static void atk76_various(void) else gActiveBank = 2; - choiced_move = (u16*)(&ewram[gActiveBank * 2 + 0x160e8]); + choiced_move = CHOICED_MOVE(gActiveBank); for (i = 0; i < 4; i++) { if (gBattleMons[gActiveBank].moves[i] == *choiced_move) @@ -12384,11 +12376,11 @@ static void atk7B_healhalfHP_if_possible(void) static void atk7C_8025508(void) { - u16 r7 = ewram[gBankAttacker * 2 + 0x160ac] | (ewram[gBankAttacker * 2 + 0x160ad] << 8); - u16 r6 = ewram[gBankAttacker * 4 + 0x16100] | (ewram[gBankAttacker * 4 + 0x16101] << 8); - u16 r5 = ewram[gBankAttacker * 4 + 0x16102] | (ewram[gBankAttacker * 4 + 0x16103] << 8); + u16 r7 = ewram160ACarr2(0, gBankAttacker) | (ewram160ACarr2(1, gBankAttacker) << 8); + u16 r6 = ewram16100arr2(0, gBankAttacker) | (ewram16100arr2(1, gBankAttacker) << 8); + u16 r5 = ewram16100arr2(2, gBankAttacker) | (ewram16100arr2(3, gBankAttacker) << 8); - if (r7 !=0 && r7 != 0xFFFF) + if (r7 != 0 && r7 != 0xFFFF) { gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gCurrentMove = r7; @@ -13467,12 +13459,12 @@ static void atk8D_setmultihit_counter(void) static void atk8E_prepare_multihit(void) { - ewram[0x160e0] = 0xFD; - ewram[0x160e1] = 1; - ewram[0x160e2] = 1; - ewram[0x160e3] = 1; - ewram[0x160e4] = 0; - ewram[0x160e5] = 0xFF; + ewram160E0(0) = 0xFD; + ewram160E0(1) = 1; + ewram160E0(2) = 1; + ewram160E0(3) = 1; + ewram160E0(4) = 0; + ewram160E0(5) = 0xFF; gBattlescriptCurrInstr++; } @@ -13480,7 +13472,7 @@ static bool8 sub_80264C0(void) { if (gBattleMons[gBankAttacker].level >= gBattleMons[gBankTarget].level) { - ewram[gBankTarget + 0x16064] = gBattlePartyID[gBankTarget]; + ewram16064arr(gBankTarget) = gBattlePartyID[gBankTarget]; } else { @@ -13490,7 +13482,7 @@ static bool8 sub_80264C0(void) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); return 0; } - ewram[gBankTarget + 0x16064] = gBattlePartyID[gBankTarget]; + ewram16064arr(gBankTarget) = gBattlePartyID[gBankTarget]; } gBattlescriptCurrInstr = gUnknown_081D90FC; return 1; @@ -13571,7 +13563,7 @@ static void atk8F_forcerandomswitch(void) } while (i == gBattlePartyID[gBankTarget] || !MON_CAN_BATTLE(&party[i])); } } - ewram[gBankTarget + 0x16068] = i; + ewram16068arr(gBankTarget) = i; if (!IsLinkDoubleBattle()) sub_8012258(gBankTarget); sub_8094B6C(gBankTarget, i, 0); @@ -15432,7 +15424,7 @@ static void atkBA_jumpifnopursuitswitchdmg(void) gBankTarget = GetBankByPlayerAI(2); } - if (gActionForBanks[gBankTarget] == 0 && gBankAttacker == ewram[gBankTarget + 0x16010] && !(gBattleMons[gBankTarget].status1 & (STATUS_SLEEP | STATUS_FREEZE)) + if (gActionForBanks[gBankTarget] == 0 && gBankAttacker == ewram16010arr(gBankTarget) && !(gBattleMons[gBankTarget].status1 & (STATUS_SLEEP | STATUS_FREEZE)) && gBattleMons[gBankAttacker].hp && !gDisableStructs[gBankTarget].truantCounter && gChosenMovesByBanks[gBankTarget] == MOVE_PURSUIT) { int i; @@ -15501,11 +15493,11 @@ static void atkBE_breakfree(void) //rapid spin if (gBattleMons[gBankAttacker].status2 & STATUS2_WRAPPED) { gBattleMons[gBankAttacker].status2 &= ~(STATUS2_WRAPPED); - gBankTarget = ewram[gBankAttacker + 0x16020]; + gBankTarget = ewram16020arr(gBankAttacker); gBattleTextBuff1[0] = 0xFD; gBattleTextBuff1[1] = 2; - gBattleTextBuff1[2] = ewram[gBankAttacker * 2 + 0x16004]; - gBattleTextBuff1[3] = ewram[gBankAttacker * 2 + 0x16005]; + gBattleTextBuff1[2] = ewram16004arr(0, gBankAttacker); + gBattleTextBuff1[3] = ewram16004arr(1, gBankAttacker); gBattleTextBuff1[4] = 0xFF; b_movescr_stack_push_cursor(); gBattlescriptCurrInstr = BattleScript_WrapFree; @@ -16985,7 +16977,7 @@ static void atkE1_intimidate_string_loader(void) { u8 side; - BATTLE_STRUCT->scriptingActive = ewram[0x160dd]; + BATTLE_STRUCT->scriptingActive = ewram160DD; side = GetBankSide(BATTLE_STRUCT->scriptingActive); gBattleTextBuff1[0] = 0xFD; gBattleTextBuff1[1] = 9; @@ -17013,7 +17005,7 @@ static void atkE2_switchout_abilities(void) { case ABILITY_NATURAL_CURE: gBattleMons[gActiveBank].status1 = 0; - EmitSetAttributes(0, REQUEST_STATUS_BATTLE, gBitTable[ewram[gActiveBank + 0x16064]], 4, &gBattleMons[gActiveBank].status1); + EmitSetAttributes(0, REQUEST_STATUS_BATTLE, gBitTable[ewram16064arr(gActiveBank)], 4, &gBattleMons[gActiveBank].status1); MarkBufferBankForExecution(gActiveBank); break; } diff --git a/src/battle/battle_7.c b/src/battle/battle_7.c index 1d68386aa..ceac8ff24 100644 --- a/src/battle/battle_7.c +++ b/src/battle/battle_7.c @@ -18,16 +18,7 @@ #include "task.h" #include "text.h" #include "gba/m4a_internal.h" - -struct Struct2019348 -{ - u8 filler0[2]; - u16 unk2; - u8 filler4[4]; - u32 unk8; - u32 unkC; - u32 unk10; -}; +#include "ewram.h" extern u8 gBattleBufferA[][0x200]; extern u8 gActiveBank; @@ -71,8 +62,6 @@ extern const struct CompressedSpriteSheet gUnknown_0820A4B4[]; extern const struct SpritePalette gUnknown_0820A4D4[]; extern const u8 gUnknown_08D09C48[]; -#define ewram19348 (*(struct Struct2019348 *)(ewram + 0x19348)) - extern void c3_0802FDF4(u8); extern void sub_80440EC(); extern void sub_804777C(); @@ -304,14 +293,14 @@ void BattleLoadOpponentMonSprite(struct Pokemon *pkmn, u8 b) lzPaletteData = GetMonSpritePal(pkmn); else lzPaletteData = GetMonSpritePalFromOtIdPersonality(species, otId, personalityValue); - LZDecompressWram(lzPaletteData, ewram); - LoadPalette(ewram, paletteOffset, 0x20); - LoadPalette(ewram, 0x80 + b * 16, 0x20); + LZDecompressWram(lzPaletteData, gSharedMem); + LoadPalette(gSharedMem, paletteOffset, 0x20); + LoadPalette(gSharedMem, 0x80 + b * 16, 0x20); if (species == SPECIES_CASTFORM) { paletteOffset = 0x100 + b * 16; - LZDecompressWram(lzPaletteData, ewram + 0x16400); - LoadPalette(ewram + 0x16400 + gBattleMonForms[b] * 32, paletteOffset, 0x20); + LZDecompressWram(lzPaletteData, ewram16400); + LoadPalette(ewram16400 + gBattleMonForms[b] * 32, paletteOffset, 0x20); } if (ewram17800[b].transformedSpecies != 0) { @@ -356,14 +345,14 @@ void BattleLoadPlayerMonSprite(struct Pokemon *pkmn, u8 b) lzPaletteData = GetMonSpritePal(pkmn); else lzPaletteData = GetMonSpritePalFromOtIdPersonality(species, otId, personalityValue); - LZDecompressWram(lzPaletteData, ewram); - LoadPalette(ewram, paletteOffset, 0x20); - LoadPalette(ewram, 0x80 + b * 16, 0x20); + LZDecompressWram(lzPaletteData, gSharedMem); + LoadPalette(gSharedMem, paletteOffset, 0x20); + LoadPalette(gSharedMem, 0x80 + b * 16, 0x20); if (species == SPECIES_CASTFORM) { paletteOffset = 0x100 + b * 16; - LZDecompressWram(lzPaletteData, ewram + 0x16400); - LoadPalette(ewram + 0x16400 + gBattleMonForms[b] * 32, paletteOffset, 0x20); + LZDecompressWram(lzPaletteData, ewram16400); + LoadPalette(ewram16400 + gBattleMonForms[b] * 32, paletteOffset, 0x20); } if (ewram17800[b].transformedSpecies != 0) { @@ -623,7 +612,7 @@ void sub_8031FC4(u8 a, u8 b, bool8 c) { StartSpriteAnim(&gSprites[gObjectBankIDs[a]], ewram17840.unk0); paletteOffset = 0x100 + a * 16; - LoadPalette(ewram + 0x16400 + ewram17840.unk0 * 32, paletteOffset, 32); + LoadPalette(ewram16400 + ewram17840.unk0 * 32, paletteOffset, 32); gBattleMonForms[a] = ewram17840.unk0; if (ewram17800[a].transformedSpecies != 0) { @@ -691,11 +680,11 @@ void sub_8031FC4(u8 a, u8 b, bool8 c) DmaCopy32(3, src, dst, 0x800); paletteOffset = 0x100 + a * 16; lzPaletteData = GetMonSpritePalFromOtIdPersonality(species, otId, personalityValue); - LZDecompressWram(lzPaletteData, ewram); - LoadPalette(ewram, paletteOffset, 32); + LZDecompressWram(lzPaletteData, gSharedMem); + LoadPalette(gSharedMem, paletteOffset, 32); if (species == SPECIES_CASTFORM) { - u16 *paletteSrc = (u16 *)(ewram + 0x16400); + u16 *paletteSrc = (u16 *)ewram16400; // TODO: avoid casting? LZDecompressWram(lzPaletteData, paletteSrc); LoadPalette(paletteSrc + gBattleMonForms[b] * 16, paletteOffset, 32); diff --git a/src/battle/battle_ai.c b/src/battle/battle_ai.c index 9c6d2bec4..5145d4980 100644 --- a/src/battle/battle_ai.c +++ b/src/battle/battle_ai.c @@ -11,6 +11,7 @@ #include "rom_8077ABC.h" #include "species.h" #include "util.h" +#include "ewram.h" extern u16 gBattleTypeFlags; extern u16 gBattleWeather; @@ -952,8 +953,8 @@ static void BattleAICmd_is_most_powerful_move(void) && sDiscouragedPowerfulMoveEffects[i] == 0xFFFF) { gDynamicBasePower = 0; - ewram[0x1601C] = 0; // why is this a manual array? - ewram[0x1601F] = 1; + eDynamicMoveType = 0; + eDmgMultiplier = 1; gBattleMoveFlags = 0; gCritMultiplier = 1; @@ -1998,8 +1999,7 @@ static void BattleAICmd_get_used_item(void) else 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 = ewram[MULTI_DIM_ARR(index, B_16, 0x160CC)]; + AI_THINKING_STRUCT->funcResult = AI_ARRAY_160CC(index); gAIScriptPtr += 2; } diff --git a/src/battle/battle_anim.c b/src/battle/battle_anim.c index eac16ee18..408a21f86 100644 --- a/src/battle/battle_anim.c +++ b/src/battle/battle_anim.c @@ -12,11 +12,11 @@ #include "sound.h" #include "sprite.h" #include "task.h" +#include "ewram.h" // sprites start at 10000 and thus must be subtracted of 10000 to account for the true index. #define GET_TRUE_SPRITE_INDEX(i) (i - 10000) -extern u8 unk_2000000[]; extern u16 gBattlePartyID[4]; extern u8 gObjectBankIDs[]; extern u8 gBankAttacker; diff --git a/src/battle/battle_anim_807B69C.c b/src/battle/battle_anim_807B69C.c index 9acc7bd46..7fcd1e23f 100644 --- a/src/battle/battle_anim_807B69C.c +++ b/src/battle/battle_anim_807B69C.c @@ -7,6 +7,7 @@ #include "sprite.h" #include "task.h" #include "trig.h" +#include "ewram.h" extern u8 gBattleAnimBankAttacker; extern u8 gBattleAnimBankTarget; diff --git a/src/battle/battle_controller_linkopponent.c b/src/battle/battle_controller_linkopponent.c index ff4df81e4..107c374a0 100644 --- a/src/battle/battle_controller_linkopponent.c +++ b/src/battle/battle_controller_linkopponent.c @@ -15,6 +15,7 @@ #include "task.h" #include "text.h" #include "util.h" +#include "ewram.h" struct UnknownStruct3 { diff --git a/src/battle/battle_controller_linkpartner.c b/src/battle/battle_controller_linkpartner.c index a874190aa..25deebf78 100644 --- a/src/battle/battle_controller_linkpartner.c +++ b/src/battle/battle_controller_linkpartner.c @@ -19,6 +19,7 @@ #include "task.h" #include "text.h" #include "util.h" +#include "ewram.h" struct UnknownStruct1 { diff --git a/src/battle/battle_controller_opponent.c b/src/battle/battle_controller_opponent.c index 392e80f08..823d6702a 100644 --- a/src/battle/battle_controller_opponent.c +++ b/src/battle/battle_controller_opponent.c @@ -20,6 +20,7 @@ #include "task.h" #include "text.h" #include "util.h" +#include "ewram.h" struct UnknownStruct3 { @@ -1673,7 +1674,7 @@ _0803558A:\n\ void OpponentHandleOpenBag(void) { // What is this? - Emitcmd35(1, ewram[0x160D4 + gActiveBank / 2 * 2]); + Emitcmd35(1, ewram160D4(gActiveBank)); OpponentBufferExecCompleted(); } @@ -1681,7 +1682,7 @@ void OpponentHandlecmd22(void) { s32 r4; - if (ewram[0x160C8 + GetBankIdentity(gActiveBank) / 2] == 6) + if (ewram160C8arr(GetBankIdentity(gActiveBank)) == 6) { u8 r6; u8 r5; @@ -1710,10 +1711,10 @@ void OpponentHandlecmd22(void) } else { - r4 = ewram[0x160C8 + GetBankIdentity(gActiveBank) / 2]; - ewram[0x160C8 + GetBankIdentity(gActiveBank) / 2] = 6; + r4 = ewram160C8arr(GetBankIdentity(gActiveBank)); + ewram160C8arr(GetBankIdentity(gActiveBank)) = 6; } - ewram[0x16068 + gActiveBank] = r4; + ewram16068arr(gActiveBank) = r4; Emitcmd34(1, r4, 0); OpponentBufferExecCompleted(); } diff --git a/src/battle/battle_controller_player.c b/src/battle/battle_controller_player.c index 136c31841..1aa73e90c 100644 --- a/src/battle/battle_controller_player.c +++ b/src/battle/battle_controller_player.c @@ -19,6 +19,7 @@ #include "task.h" #include "text.h" #include "util.h" +#include "ewram.h" //Possibly PokemonSubstruct1 struct UnknownStruct3 @@ -2644,9 +2645,9 @@ void PlayerHandlecmd22(void) gUnknown_0300434C[gActiveBank] = CreateTask(TaskDummy, 0xFF); gTasks[gUnknown_0300434C[gActiveBank]].data[0] = gBattleBufferA[gActiveBank][1] & 0xF; - ewram[0x16054] = gBattleBufferA[gActiveBank][1] >> 4; - ewram[0x1609D] = gBattleBufferA[gActiveBank][2]; - ewram[0x160C0] = gBattleBufferA[gActiveBank][3]; + ewram16054 = gBattleBufferA[gActiveBank][1] >> 4; + EWRAM_1609D = gBattleBufferA[gActiveBank][2]; + ewram160C0 = gBattleBufferA[gActiveBank][3]; for (i = 0; i < 3; i++) gUnknown_02038470[i] = gBattleBufferA[gActiveBank][4 + i]; BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); diff --git a/src/battle/battle_controller_safari.c b/src/battle/battle_controller_safari.c index 2fcdf7548..5b89cf9ba 100644 --- a/src/battle/battle_controller_safari.c +++ b/src/battle/battle_controller_safari.c @@ -12,6 +12,7 @@ #include "sound.h" #include "text.h" #include "util.h" +#include "ewram.h" extern struct Window gUnknown_03004210; extern u8 gDisplayedStringBattle[]; diff --git a/src/battle/battle_controller_wally.c b/src/battle/battle_controller_wally.c index 9d70ca557..9392832d7 100644 --- a/src/battle/battle_controller_wally.c +++ b/src/battle/battle_controller_wally.c @@ -17,6 +17,7 @@ #include "task.h" #include "text.h" #include "util.h" +#include "ewram.h" //Possibly PokemonSubstruct1 struct UnknownStruct3 @@ -239,10 +240,10 @@ void unref_sub_8137220(void) void SetBankFuncToWallyBufferRunCommand(void) { gBattleBankFunc[gActiveBank] = WallyBufferRunCommand; - ewram[0x160A8] = 0; - ewram[0x160A9] = 0; - ewram[0x160AA] = 0; - ewram[0x160AB] = 0; + ewram160A8 = 0; + ewram160A9 = 0; + ewram160AA = 0; + ewram160AB = 0; } void WallyBufferRunCommand(void) @@ -260,59 +261,59 @@ void sub_81372BC(void) { u8 r4; - switch (ewram[0x160A8]) + switch (ewram160A8) { case 0: - ewram[0x160AA] = 64; - ewram[0x160A8]++; + ewram160AA = 64; + ewram160A8++; // fall through case 1: - r4 = --ewram[0x160AA]; + r4 = --ewram160AA; if (r4 == 0) { PlaySE(SE_SELECT); Emitcmd33(1, 0, 0); WallyBufferExecCompleted(); - ewram[0x160A8]++; - ewram[0x160A9] = r4; - ewram[0x160AA] = 64; + ewram160A8++; + ewram160A9 = r4; + ewram160AA = 64; } break; case 2: - r4 = --ewram[0x160AA]; + r4 = --ewram160AA; if (r4 == 0) { PlaySE(SE_SELECT); Emitcmd33(1, 0, 0); WallyBufferExecCompleted(); - ewram[0x160A8]++; - ewram[0x160A9] = r4; - ewram[0x160AA] = 64; + ewram160A8++; + ewram160A9 = r4; + ewram160AA = 64; } break; case 3: - r4 = --ewram[0x160AA]; + r4 = --ewram160AA; if (r4 == 0) { Emitcmd33(1, 9, 0); WallyBufferExecCompleted(); - ewram[0x160A8]++; - ewram[0x160A9] = r4; - ewram[0x160AA] = 64; + ewram160A8++; + ewram160A9 = r4; + ewram160AA = 64; } break; case 4: - if (--ewram[0x160AA] == 0) + if (--ewram160AA == 0) { PlaySE(SE_SELECT); nullsub_8(0); sub_802E3E4(1, 0); - ewram[0x160AA] = 64; - ewram[0x160A8]++; + ewram160AA = 64; + ewram160A8++; } break; case 5: - if (--ewram[0x160AA] == 0) + if (--ewram160AA == 0) { PlaySE(SE_SELECT); DestroyMenuCursor(); @@ -1290,16 +1291,16 @@ void WallyHandlecmd19(void) void WallyHandlecmd20(void) { - switch (ewram[0x160A9]) + switch (ewram160A9) { case 0: sub_80304A8(); - ewram[0x160A9]++; - ewram[0x160AB] = 80; + ewram160A9++; + ewram160AB = 80; // fall through case 1: - ewram[0x160AB]--; - if (ewram[0x160AB] == 0) + ewram160AB--; + if (ewram160AB == 0) { DestroyMenuCursor(); PlaySE(SE_SELECT); diff --git a/src/battle/battle_interface.c b/src/battle/battle_interface.c index 10962c025..09837bfee 100644 --- a/src/battle/battle_interface.c +++ b/src/battle/battle_interface.c @@ -13,6 +13,7 @@ #include "string_util.h" #include "task.h" #include "text.h" +#include "ewram.h" struct UnknownStruct5 { @@ -28,12 +29,6 @@ struct UnknownStruct7 u8 filler0[0x180]; }; -extern u8 ewram[]; -#define ewram520 ((struct UnknownStruct7 *)(ewram + 0x00520)) -#define ewram16088 (*(u8 *) (ewram + 0x16088)) -#define ewram16089 (*(u8 *) (ewram + 0x16089)) -#define ewram17850 ((struct UnknownStruct5 *)(ewram + 0x17850)) - extern u8 gDisplayedStringBattle[]; extern u8 gNoOfAllBanks; extern u16 gBattlePartyID[]; @@ -1000,8 +995,8 @@ void sub_8044338(u8 a, struct Pokemon *pkmn) } //_08044486 r5 = gSprites[a].data5; - ConvertIntToDecimalStringN(str + 6, ewram[0x16089], 1, 2); - ConvertIntToDecimalStringN(str + 9, ewram[0x16088], 1, 2); + ConvertIntToDecimalStringN(str + 6, ewram16089, 1, 2); + ConvertIntToDecimalStringN(str + 9, ewram16088, 1, 2); str[5] = 0; str[8] = 0xBA; sub_80034D4((u8 *)0x02000000, str); diff --git a/src/battle/battle_message.c b/src/battle/battle_message.c index 79855a614..4e8067a49 100644 --- a/src/battle/battle_message.c +++ b/src/battle/battle_message.c @@ -12,6 +12,7 @@ #include "battle_setup.h" #include "battle_tower.h" #include "flags.h" +#include "ewram.h" #define BATTLESTRING_TO_SUB 12 #define BATTLESTRINGS_NO 351 @@ -651,7 +652,7 @@ u32 StrCpyDecodeBattle(const u8* src, u8* dst) if (gTrainerBattleOpponent == 0x400) { memset(text, 0xFF, 8); - memcpy(text, &ewram[0x17002], 7); + memcpy(text, ewram17002, 7); toCpy = text; } else if (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) diff --git a/src/battle/battle_party_menu.c b/src/battle/battle_party_menu.c index 2f6dc6816..97e9dc0fc 100644 --- a/src/battle/battle_party_menu.c +++ b/src/battle/battle_party_menu.c @@ -18,9 +18,7 @@ #include "strings.h" #include "task.h" #include "text.h" - -extern u8 ewram[]; -#define UNK_201606C_ARRAY (ewram + 0x1606C) // lazy define but whatever. +#include "ewram.h" extern u8 sub_806BD58(u8, u8); extern void PartyMenuPrintMonsLevelOrStatus(void); @@ -206,7 +204,7 @@ void sub_8094B6C(u8 a, u8 b, u8 c) if (IsLinkDoubleBattle()) { - u8 *arr = ewram + 0x1606C + a * 3; + u8 *arr = &ewram1606Carr(0, a); for (i = 0, j = 0; i < 3; i++) { diff --git a/src/battle/battle_transition.c b/src/battle/battle_transition.c index 53d32d03a..d0a9bfb92 100644 --- a/src/battle/battle_transition.c +++ b/src/battle/battle_transition.c @@ -12,11 +12,11 @@ #include "songs.h" #include "trainer.h" #include "field_camera.h" +#include "ewram.h" void sub_807DE10(void); void dp12_8087EA4(void); -extern u8 ewram[]; extern u16 gUnknown_03005560[]; extern u16 gUnknown_03004DE0[][0x3C0]; @@ -45,7 +45,6 @@ struct TransitionData s16 data[11]; }; -#define TRANSITION_STRUCT (*(struct TransitionData *) (ewram + 0xC000)) typedef bool8 (*TransitionState)(struct Task* task); typedef bool8 (*TransitionSpriteCallback)(struct Sprite* sprite); @@ -1734,8 +1733,8 @@ static void Mugshots_CreateOpponentPlayerSprites(struct Task* task) task->tMugshotOpponentID = CreateTrainerSprite(sMugshotsTrainerPicIDsTable[mugshotID], sMugshotsOpponentCoords[mugshotID][0] - 32, sMugshotsOpponentCoords[mugshotID][1] + 42, - 0, &ewram[0xC03C]); - task->tMugshotPlayerID = CreateTrainerSprite(gSaveBlock2.playerGender, 272, 106, 0, &ewram[0xC03C]); + 0, ewramC03C); + task->tMugshotPlayerID = CreateTrainerSprite(gSaveBlock2.playerGender, 272, 106, 0, ewramC03C); opponentSprite = &gSprites[task->tMugshotOpponentID]; playerSprite = &gSprites[task->tMugshotPlayerID]; diff --git a/src/battle/calculate_base_damage.c b/src/battle/calculate_base_damage.c index f5c679876..42c26dee0 100644 --- a/src/battle/calculate_base_damage.c +++ b/src/battle/calculate_base_damage.c @@ -11,8 +11,8 @@ #include "species.h" #include "moves.h" #include "battle_move_effects.h" +#include "ewram.h" -extern u32 dword_2017100[]; extern u16 gBattleTypeFlags; extern struct BattlePokemon gBattleMons[4]; extern u16 gCurrentMove; @@ -301,7 +301,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de } // flash fire triggered - if ((dword_2017100[bankAtk] & 1) && type == TYPE_FIRE) + if ((eFlashFireArr.arr[bankAtk] & 1) && type == TYPE_FIRE) damage = (15 * damage) / 10; } diff --git a/src/battle/pokeball.c b/src/battle/pokeball.c index ee3b95678..afdf47979 100644 --- a/src/battle/pokeball.c +++ b/src/battle/pokeball.c @@ -14,6 +14,7 @@ #include "task.h" #include "trig.h" #include "util.h" +#include "ewram.h" extern struct MusicPlayerInfo gMPlay_BGM; extern u16 gBattleTypeFlags; diff --git a/src/battle/reshow_battle_screen.c b/src/battle/reshow_battle_screen.c index 343c8f183..396c4435e 100644 --- a/src/battle/reshow_battle_screen.c +++ b/src/battle/reshow_battle_screen.c @@ -7,6 +7,7 @@ #include "text.h" #include "rom_8077ABC.h" #include "data2.h" +#include "ewram.h" extern struct SpriteTemplate gUnknown_02024E8C; extern struct Window gUnknown_03004210; @@ -55,9 +56,6 @@ static void sub_807B184(u8 bank); static void sub_807B508(u8 bank); static void sub_807B06C(void); -#define gReshowState ewram[0x1FFFF] -#define gHelperState ewram[0x1FFFE] - void nullsub_14(void) { |