diff options
33 files changed, 63 insertions, 55 deletions
diff --git a/include/battle.h b/include/battle.h index 692e1a981..c2e1063d3 100644 --- a/include/battle.h +++ b/include/battle.h @@ -234,7 +234,11 @@ struct AI_ThinkingStruct /* 0x2016800 */ struct BattleStruct /* 0x2000000 */ { - u8 filler0[0x15DDE]; + /*0x00000*/ u8 unk0; + /*0x00001*/ bool8 unk1; + /*0x00002*/ u8 unk2; + /*0x00003*/ bool8 unk3; + u8 filler4[0x15DDA]; /*0x15DDE*/ u8 unk15DDE; /*0x15DDF*/ u8 unk15DDF; /*0x15DE0*/ u8 filler15DE0[0x220]; @@ -530,6 +534,11 @@ struct BattleResults u8 unk36[10]; // usedBalls? }; +struct Struct2017100 +{ + u32 arr[4]; +}; + struct Struct2017800 { u8 invisible:1; @@ -668,8 +677,6 @@ extern struct WishFutureKnock gWishFutureKnock; extern struct AI_ThinkingStruct gAIThinkingSpace; extern struct Struct20238C8 gUnknown_020238C8; -#include "ewram.h" - // used in many battle files, it seems as though Hisashi Sogabe wrote // some sort of macro to replace the use of actually calling memset. // Perhaps it was thought calling memset was much slower? diff --git a/include/battle_anim.h b/include/battle_anim.h index 27683e866..d807a582a 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -7,8 +7,6 @@ #define REG_BG1CNT_BITFIELD REG_BGnCNT_BITFIELD(1) #define REG_BG2CNT_BITFIELD REG_BGnCNT_BITFIELD(2) -#include "ewram.h" - struct BGCntrlBitfield { volatile u16 priority:2; diff --git a/include/battle_party_menu.h b/include/battle_party_menu.h index d08c1e9ae..d7ad53eed 100644 --- a/include/battle_party_menu.h +++ b/include/battle_party_menu.h @@ -1,8 +1,6 @@ #ifndef GUARD_BATTLE_PARTY_MENU_H #define GUARD_BATTLE_PARTY_MENU_H -#include "ewram.h" - void HandleBattlePartyMenu(u8); bool8 SetUpBattlePartyMenu(void); diff --git a/include/decoration.h b/include/decoration.h index 414c02dad..8c651f967 100644 --- a/include/decoration.h +++ b/include/decoration.h @@ -204,8 +204,6 @@ struct UnkStruct_803EC860 extern const struct UnkStruct_803EC860 gUnknown_083EC860[]; -#include "ewram.h" - struct UnkStruct_02038900 { /*0x000; 0x02038900*/ const struct Decoration *decoration; diff --git a/include/dewford_trend.h b/include/dewford_trend.h index c4a1a142d..c12d0d740 100644 --- a/include/dewford_trend.h +++ b/include/dewford_trend.h @@ -1,8 +1,6 @@ #ifndef GUARD_DEWFORDTREND_H #define GUARD_DEWFORDTREND_H -#include "ewram.h" - void InitDewfordTrend(void); void sub_80FA4E4(void *, u32, u8); void UpdateDewfordTrendPerDay(u16); diff --git a/include/ewram.h b/include/ewram.h index 1b54a1ebc..2acf8d203 100755 --- a/include/ewram.h +++ b/include/ewram.h @@ -4,13 +4,12 @@ extern u8 ewram[]; #define BATTLE_STRUCT ((struct BattleStruct *) (ewram + 0x0)) -#define ewram0 (*(struct UnknownStruct7 *)(ewram + 0x0)) #define ewram0_2 (*(struct Struct2000000 *)(ewram + 0x0)) #define namingScreenData (*(struct NamingScreenData *)(ewram + 0x0)) -#define unk_2000000 (*(struct UnkStruct *)(ewram + 0x0)) #define ewramBerryPic (ewram + 0x0) #define ewram0_3 (*(struct UnknownStruct3 *)(ewram + 0x0)) #define ewram0_4 (*(struct Unk2000000 *)(ewram + 0x0)) +#define ewram0_5 (*(struct UnkStruct *)(ewram + 0x0)) #define ewram4 (*(struct UnknownStruct8 *)(ewram + 0x4)) #define ewram520 ((struct UnknownStruct7 *)(ewram + 0x00520)) #define ewram888 (ewram + 0x888) @@ -79,19 +78,18 @@ extern u8 ewram[]; #define UNK_2016A00_STRUCT ((struct UnkBattleStruct1 *) (ewram + 0x16A00)) #define AI_STACK ((struct AI_Stack *) (ewram + 0x16C00)) #define AI_ARRAY_160CC ((struct SmallItemStruct *) (ewram + 0x160CC)) -#define ewram17100_2 (*(struct Struct2017100 *)(ewram + 0x17100)) +#define ewram17000 ((u32 *) (ewram + 0x17100)) // this label is incorrect. +#define ewram17100 (*(struct Struct2017100 *)(ewram + 0x17100)) #define B_BATTLESCRIPTS_STACK ((struct scriptsStack *) (ewram + 0x17110)) +#define ewram17130 (ewram[0x17130]) #define B_FUNCTION_STACK ((struct funcStack *) (ewram + 0x17140)) +#define ewram17160 (ewram[0x17160]) #define ewram17800 ((struct Struct2017800 *) (ewram + 0x17800)) +#define EWRAM_17800 ((struct UnknownStruct1 *)(ewram + 0x17800)) #define ewram17810 ((struct Struct2017810 *) (ewram + 0x17810)) +#define EWRAM_17810 ((struct UnknownStruct3 *)(ewram + 0x17810)) #define ewram17840 (*(struct Struct2017840 *) (ewram + 0x17840)) #define ewram17850 ((struct UnknownStruct5 *)(ewram + 0x17850)) -#define ewram17000 ((u32 *) (ewram + 0x17100)) // this label is incorrect. -#define ewram17100 ((u32 *)(ewram + 0x17100)) -#define ewram17130 (ewram[0x17130]) -#define ewram17160 (ewram[0x17160]) -#define EWRAM_17800 ((struct UnknownStruct1 *)(ewram + 0x17800)) -#define EWRAM_17810 ((struct UnknownStruct3 *)(ewram + 0x17810)) #define unk_2018000 (*(struct PlayerRecords *)(ewram + 0x18000)) #define EWRAM_18000 ((u16 *)(ewram + 0x18000)) #define ewram18000 ((u16 *)(ewram + 0x18000)) diff --git a/include/party_menu.h b/include/party_menu.h index a60b90469..304389e78 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -101,8 +101,6 @@ struct UnknownPokemonStruct2 /*0x1D*/ u8 language; }; -#include "ewram.h" - void CB2_PartyMenuMain(void); void ChangeBattleTowerPartyMenuSelection(u8 taskId, s8 directionPressed); void SetPartyMenuSettings(u8 menuType, u8 battleTypeFlags, TaskFunc menuHandlerFunc, u8 textId); diff --git a/include/script_pokemon_80F9.h b/include/script_pokemon_80F9.h index 5e2b11f3c..eed32f5cf 100644 --- a/include/script_pokemon_80F9.h +++ b/include/script_pokemon_80F9.h @@ -7,8 +7,6 @@ struct UnknownStruct2018000 u8 unk8; }; -#include "ewram.h" // UNK_2018000_STRUCT requires this include. TODO: fix? - void OpenPartyMenuFromScriptContext(u8 taskId); void sub_80F9C00(void); void sub_80F9E1C(void); diff --git a/src/battle/battle_2.c b/src/battle/battle_2.c index 5a37a6169..26433b055 100644 --- a/src/battle/battle_2.c +++ b/src/battle/battle_2.c @@ -253,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) @@ -350,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; } } @@ -410,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]++; } @@ -593,8 +593,8 @@ 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); @@ -1537,7 +1537,7 @@ void sub_8010874(void) gUnknown_02024C5C[i] = 0xFF; gLockedMove[i] = 0; gUnknown_02024C2C[i] = 0; - ewram17100[i] = 0; + ewram17100.arr[i] = 0; } for (i = 0; i < 2; i++) @@ -1621,7 +1621,6 @@ void SwitchInClearStructs(void) struct DisableStruct sp0 = gDisableStructs[gActiveBank]; s32 i; u8 *ptr; - u32 *ptr2; if (gBattleMoves[gCurrentMove].effect != EFFECT_BATON_PASS) { @@ -1700,8 +1699,7 @@ void SwitchInClearStructs(void) ewram[0x160E8 + gActiveBank * 2 + 0] = 0; ewram[0x160E8 + gActiveBank * 2 + 1] = 0; - ptr2 = (u32 *)(ewram + 0x17100); - ptr2[gActiveBank] = 0; + ewram17100.arr[gActiveBank] = 0; gCurrentMove = 0; } diff --git a/src/battle/battle_3.c b/src/battle/battle_3.c index e8819781d..3f2b8d9e5 100644 --- a/src/battle/battle_3.c +++ b/src/battle/battle_3.c @@ -1433,11 +1433,6 @@ u8 CastformDataTypeChange(u8 bank) return formChange; } -struct Struct2017100 -{ - u32 arr[4]; -}; - u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { u8 effect = 0; @@ -1723,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_2.arr[bank] & 1)) + if (!(ewram17100.arr[bank] & 1)) { gBattleCommunication[MULTISTRING_CHOOSER] = 0; if (gProtectStructs[gBankAttacker].notFirstStrike) gBattlescriptCurrInstr = BattleScript_FlashFireBoost; else gBattlescriptCurrInstr = BattleScript_FlashFireBoost_PPLoss; - ewram17100_2.arr[bank] |= 1; + ewram17100.arr[bank] |= 1; effect = 2; } else diff --git a/src/battle/battle_4.c b/src/battle/battle_4.c index 3fee71a5f..5daadd4b5 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; diff --git a/src/battle/battle_ai.c b/src/battle/battle_ai.c index 9c6d2bec4..aeac41750 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; diff --git a/src/battle/battle_anim.c b/src/battle/battle_anim.c index 0c04ff9b8..408a21f86 100644 --- a/src/battle/battle_anim.c +++ b/src/battle/battle_anim.c @@ -12,6 +12,7 @@ #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) 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..94ae43461 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 { diff --git a/src/battle/battle_controller_player.c b/src/battle/battle_controller_player.c index 136c31841..f2fa16593 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 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..be065e071 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 diff --git a/src/battle/battle_message.c b/src/battle/battle_message.c index 79855a614..f98c065b0 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 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/engine/link.c b/src/engine/link.c index 86413cfbf..504b828a1 100644 --- a/src/engine/link.c +++ b/src/engine/link.c @@ -15,6 +15,7 @@ #include "strings2.h" #include "task.h" #include "text.h" +#include "ewram.h" #define SIO_MULTI_CNT ((struct SioMultiCnt *)REG_ADDR_SIOCNT) diff --git a/src/engine/trade.c b/src/engine/trade.c index b11b7e448..63571ecac 100644 --- a/src/engine/trade.c +++ b/src/engine/trade.c @@ -39,6 +39,7 @@ #include "util.h" #include "battle_interface.h" #include "trade.h" +#include "ewram.h" #ifdef ENGLISH #define sub_804A96C_alt sub_804A96C diff --git a/src/field/choose_party.c b/src/field/choose_party.c index adb210e7b..891ee48b8 100644 --- a/src/field/choose_party.c +++ b/src/field/choose_party.c @@ -17,6 +17,7 @@ #include "string_util.h" #include "task.h" #include "text.h" +#include "ewram.h" extern u8 gPlayerPartyCount; extern u8 gLastFieldPokeMenuOpened; @@ -34,7 +35,7 @@ extern void sub_806BC3C(u8, u8); extern void ShowPokemonSummaryScreen(struct Pokemon *, u8, u8, void (*)(void), int); extern u8 GetMonStatusAndPokerus(); extern void PartyMenuPrintHP(); -extern bool8 sub_80F9344(void); +extern bool8 sub_80F9344(void); static void ClearPartySelection(void); static bool8 IsMonAllowedInBattleTower(struct Pokemon *); diff --git a/src/field/decoration.c b/src/field/decoration.c index 59c19c20a..924c94b59 100644 --- a/src/field/decoration.c +++ b/src/field/decoration.c @@ -18,6 +18,7 @@ #include "event_data.h" #include "field_weather.h" #include "decoration.h" +#include "ewram.h" EWRAM_DATA u8 *gUnknown_020388D0 = NULL; EWRAM_DATA u8 gUnknown_020388D4 = 0; diff --git a/src/field/dewford_trend.c b/src/field/dewford_trend.c index f47dbba08..5f4d5abfe 100644 --- a/src/field/dewford_trend.c +++ b/src/field/dewford_trend.c @@ -5,6 +5,7 @@ #include "link.h" #include "rng.h" #include "text.h" +#include "ewram.h" extern u8 ewram[]; diff --git a/src/field/field_region_map.c b/src/field/field_region_map.c index e189fcf2c..73e101d8f 100644 --- a/src/field/field_region_map.c +++ b/src/field/field_region_map.c @@ -28,8 +28,8 @@ struct UnkStruct void FieldInitRegionMap(MainCallback callback) { SetVBlankCallback(NULL); - unk_2000000.unk888 = 0; - unk_2000000.callback = callback; + ewram0_5.unk888 = 0; + ewram0_5.callback = callback; SetMainCallback2(CB2_FieldInitRegionMap); } @@ -47,7 +47,7 @@ void CB2_FieldInitRegionMap(void) ResetSpriteData(); FreeAllSpritePalettes(); // TODO: remove this cast - InitRegionMap((void *)&unk_2000000.unk8, 0); + InitRegionMap((void *)&ewram0_5.unk8, 0); CreateRegionMapPlayerIcon(0, 0); CreateRegionMapCursor(1, 1); SetUpWindowConfig(&gWindowConfig_81E709C); @@ -80,15 +80,15 @@ void CB2_FieldRegionMap(void) void sub_813EFDC(void) { - switch (unk_2000000.unk888) + switch (ewram0_5.unk888) { case 0: REG_DISPCNT = DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_ON; - unk_2000000.unk888++; + ewram0_5.unk888++; break; case 1: if (!gPaletteFade.active) - unk_2000000.unk888++; + ewram0_5.unk888++; break; case 2: switch (sub_80FAB60()) @@ -98,18 +98,18 @@ void sub_813EFDC(void) break; case 4: case 5: - unk_2000000.unk888++; + ewram0_5.unk888++; } break; case 3: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); - unk_2000000.unk888++; + ewram0_5.unk888++; break; case 4: if (!gPaletteFade.active) { FreeRegionMapIconResources(); - SetMainCallback2(unk_2000000.callback); + SetMainCallback2(ewram0_5.callback); } break; } @@ -118,6 +118,6 @@ void sub_813EFDC(void) void sub_813F0C8(void) { MenuFillWindowRectWithBlankTile(17, 17, 28, 18); - if (unk_2000000.unk8.unk16) - MenuPrint(unk_2000000.unk8.str, 17, 17); + if (ewram0_5.unk8.unk16) + MenuPrint(ewram0_5.unk8.str, 17, 17); } diff --git a/src/pokemon/pokemon_3.c b/src/pokemon/pokemon_3.c index 9c2cb4730..19786e506 100644 --- a/src/pokemon/pokemon_3.c +++ b/src/pokemon/pokemon_3.c @@ -22,6 +22,7 @@ #include "string_util.h" #include "text.h" #include "util.h" +#include "ewram.h" extern u8 gPlayerPartyCount; extern u8 gEnemyPartyCount; diff --git a/src/pokemon/pokemon_menu.c b/src/pokemon/pokemon_menu.c index 7d70e7708..93a3dd797 100644 --- a/src/pokemon/pokemon_menu.c +++ b/src/pokemon/pokemon_menu.c @@ -29,6 +29,7 @@ #include "fieldmap.h" #include "item_menu.h" #include "player_pc.h" +#include "ewram.h" /* Pokemon menu: diff --git a/src/rom_800D42C.c b/src/rom_800D42C.c index f51779e65..bf6d03fb7 100644 --- a/src/rom_800D42C.c +++ b/src/rom_800D42C.c @@ -2,6 +2,7 @@ #include "battle.h" #include "link.h" #include "text.h" +#include "ewram.h" extern u16 gBattleTypeFlags; extern u8 gBattleOutcome; diff --git a/src/script_pokemon_util_80C4BF0.c b/src/script_pokemon_util_80C4BF0.c index f98293a90..011978a0c 100644 --- a/src/script_pokemon_util_80C4BF0.c +++ b/src/script_pokemon_util_80C4BF0.c @@ -22,6 +22,7 @@ #include "script_pokemon_80C4.h" #include "species.h" #include "task.h" +#include "ewram.h" #define CONTEST_ENTRY_PIC_LEFT 10 #define CONTEST_ENTRY_PIC_TOP 3 diff --git a/src/script_pokemon_util_80F99CC.c b/src/script_pokemon_util_80F99CC.c index b9c84b9e7..21ff220d2 100644 --- a/src/script_pokemon_util_80F99CC.c +++ b/src/script_pokemon_util_80F99CC.c @@ -17,6 +17,7 @@ #include "string_util.h" #include "task.h" #include "text.h" +#include "ewram.h" extern u8 gPlayerPartyCount; extern u16 gSpecialVar_0x8004; |