diff options
Diffstat (limited to 'src/field')
-rw-r--r-- | src/field/battle_tower.c | 4 | ||||
-rw-r--r-- | src/field/berry_tag_screen.c | 22 | ||||
-rw-r--r-- | src/field/choose_party.c | 3 | ||||
-rw-r--r-- | src/field/decoration.c | 3 | ||||
-rw-r--r-- | src/field/dewford_trend.c | 3 | ||||
-rw-r--r-- | src/field/field_region_map.c | 26 | ||||
-rw-r--r-- | src/field/field_tasks.c | 4 | ||||
-rw-r--r-- | src/field/fldeff_cut.c | 11 | ||||
-rw-r--r-- | src/field/fldeff_softboiled.c | 7 | ||||
-rw-r--r-- | src/field/item_menu.c | 8 | ||||
-rw-r--r-- | src/field/party_menu.c | 6 | ||||
-rw-r--r-- | src/field/player_pc.c | 65 | ||||
-rw-r--r-- | src/field/pokeblock.c | 22 | ||||
-rw-r--r-- | src/field/region_map.c | 53 | ||||
-rw-r--r-- | src/field/shop.c | 7 | ||||
-rw-r--r-- | src/field/slot_machine.c | 4 | ||||
-rw-r--r-- | src/field/tv.c | 4 |
17 files changed, 110 insertions, 142 deletions
diff --git a/src/field/battle_tower.c b/src/field/battle_tower.c index 1b5759f49..3e60d3a9a 100644 --- a/src/field/battle_tower.c +++ b/src/field/battle_tower.c @@ -24,6 +24,7 @@ #include "trainer.h" #include "tv.h" #include "vars.h" +#include "ewram.h" #if ENGLISH #include "../data/battle_tower/trainers.h" @@ -278,9 +279,6 @@ extern u8 gBattleOutcome; extern struct Pokemon gUnknown_030042FC[]; extern struct BattlePokemon gBattleMons[]; -#define ewram160FB (ewram[0x160FB]) - - void sub_8134548(void) { u8 var1 = 0; diff --git a/src/field/berry_tag_screen.c b/src/field/berry_tag_screen.c index 1413a02ca..55405138d 100644 --- a/src/field/berry_tag_screen.c +++ b/src/field/berry_tag_screen.c @@ -28,7 +28,7 @@ struct Struct2000000 /*0x1FFFF*/ u8 var_1FFFF; }; -extern struct Struct2000000 unk_2000000; +extern struct Struct2000000 gSharedMem; extern u16 gUnknown_030041B4; static EWRAM_DATA u8 gUnknown_0203932C = 0; @@ -119,13 +119,13 @@ static bool8 sub_8146058(void) case 5: if (!MultistepInitMenuWindowContinue()) break; - unk_2000000.var_1FFFF = 0; + gSharedMem.var_1FFFF = 0; gMain.state += 1; break; case 6: if (!sub_81462B8()) break; - unk_2000000.var_1FFFF = 0; + gSharedMem.var_1FFFF = 0; gMain.state += 1; break; case 7: @@ -191,19 +191,19 @@ bool8 sub_81462B8(void) u16 i; void *addr; - switch (unk_2000000.var_1FFFF) + switch (gSharedMem.var_1FFFF) { case 0: LZDecompressVram(gBerryCheck_Gfx, (void *)VRAM); - unk_2000000.var_1FFFF += 1; + gSharedMem.var_1FFFF += 1; break; case 1: LZDecompressVram(gUnknown_08E788E4, (void *)VRAM + 0x2800); - unk_2000000.var_1FFFF += 1; + gSharedMem.var_1FFFF += 1; break; case 2: LZDecompressVram(gUnknown_08E78A84, (void *)VRAM + 0x3000); - unk_2000000.var_1FFFF += 1; + gSharedMem.var_1FFFF += 1; break; case 3: for (i = 0; i < 0x400; i++) @@ -215,19 +215,19 @@ bool8 sub_81462B8(void) } addr = (void *)(VRAM + 0x3800); DmaCopy16(3, gBGTilemapBuffers[2], addr, 0x800); - unk_2000000.var_1FFFF += 1; + gSharedMem.var_1FFFF += 1; break; case 4: LoadCompressedPalette(gBerryCheck_Pal, 0, 96 * 2); - unk_2000000.var_1FFFF += 1; + gSharedMem.var_1FFFF += 1; break; case 5: LoadCompressedObjectPic(&gUnknown_083C1F74); - unk_2000000.var_1FFFF += 1; + gSharedMem.var_1FFFF += 1; break; case 6: LoadCompressedObjectPalette(&gUnknown_083C1F7C); - unk_2000000.var_1FFFF = 0; + gSharedMem.var_1FFFF = 0; return TRUE; } 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..bdeaaf91d 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; @@ -1555,7 +1556,7 @@ const struct SpriteTemplate gSpriteTemplate_83ECA88 = { const struct YesNoFuncTable gUnknown_083ECAA0 = {.yesFunc = sub_8101848, .noFunc = sub_80FED3C}; -u8 *const unref_label_083ECAA8[] = {ewram}; +u8 *const unref_label_083ECAA8[] = {gSharedMem}; // text diff --git a/src/field/dewford_trend.c b/src/field/dewford_trend.c index aaf4dd66a..102784066 100644 --- a/src/field/dewford_trend.c +++ b/src/field/dewford_trend.c @@ -5,8 +5,7 @@ #include "link.h" #include "rng.h" #include "text.h" - -extern u8 unk_2000000[]; +#include "ewram.h" extern u16 gScriptResult; extern u16 gSpecialVar_0x8004; diff --git a/src/field/field_region_map.c b/src/field/field_region_map.c index 7cb22e5df..73e101d8f 100644 --- a/src/field/field_region_map.c +++ b/src/field/field_region_map.c @@ -7,6 +7,7 @@ #include "sprite.h" #include "strings2.h" #include "text.h" +#include "ewram.h" struct RegionMapStruct { @@ -24,14 +25,11 @@ struct UnkStruct u16 unk888; }; -extern u8 ewram[]; -#define unk_2000000 (*(struct UnkStruct *)(ewram)) - 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); } @@ -49,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); @@ -82,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()) @@ -100,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; } @@ -120,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/field/field_tasks.c b/src/field/field_tasks.c index da6f162c2..767753da2 100644 --- a/src/field/field_tasks.c +++ b/src/field/field_tasks.c @@ -1,7 +1,3 @@ -// - -// - #include "global.h" #include "task.h" #include "main.h" diff --git a/src/field/fldeff_cut.c b/src/field/fldeff_cut.c index 00643a979..00cabe5c0 100644 --- a/src/field/fldeff_cut.c +++ b/src/field/fldeff_cut.c @@ -16,8 +16,7 @@ #include "sprite.h" #include "task.h" #include "trig.h" - -extern u8 gCutGrassSpriteArray[8]; // seems to be an array of 8 sprite IDs +#include "ewram.h" extern void (*gFieldCallback)(void); extern void (*gUnknown_03005CE4)(void); @@ -135,9 +134,9 @@ bool8 FldEff_CutGrass(void) // populate sprite ID array for(i = 0; i < 8; i++) { - gCutGrassSpriteArray[i] = CreateSprite((struct SpriteTemplate *)&gSpriteTemplate_CutGrass, + eCutGrassSpriteArray[i] = CreateSprite((struct SpriteTemplate *)&gSpriteTemplate_CutGrass, gSprites[gPlayerAvatar.spriteId].oam.x + 8, gSprites[gPlayerAvatar.spriteId].oam.y + 20, 0); - gSprites[gCutGrassSpriteArray[i]].data2 = 32 * i; + gSprites[eCutGrassSpriteArray[i]].data2 = 32 * i; } return 0; } @@ -273,8 +272,8 @@ void sub_80A2AB8(void) u8 i; for (i = 1; i < 8; i++) - DestroySprite(&gSprites[gCutGrassSpriteArray[i]]); - FieldEffectStop(&gSprites[gCutGrassSpriteArray[0]], FLDEFF_CUT_GRASS); + DestroySprite(&gSprites[eCutGrassSpriteArray[i]]); + FieldEffectStop(&gSprites[eCutGrassSpriteArray[0]], FLDEFF_CUT_GRASS); sub_8064E2C(); ScriptContext2_Disable(); } diff --git a/src/field/fldeff_softboiled.c b/src/field/fldeff_softboiled.c index 22f9c13f5..b2c3d9bd1 100644 --- a/src/field/fldeff_softboiled.c +++ b/src/field/fldeff_softboiled.c @@ -9,6 +9,7 @@ #include "sprite.h" #include "strings.h" #include "task.h" +#include "ewram.h" struct Struct2001000 { u8 unk0; @@ -38,15 +39,9 @@ struct Struct201C000 { #define WINDOW_RIGHT 29 #endif -#define EWRAM_1000 (*(struct Struct2001000 *)(unk_2000000 + 0x1000)) -#define EWRAM_1B000_2 (*(struct Struct201B000 *)(unk_2000000 + 0x1B000)) -#define EWRAM_1C000 (*(struct Struct201C000 *)(unk_2000000 + 0x1C000)) - // extern extern u8 gUnknown_0202E8F6; extern u8 gLastFieldPokeMenuOpened; - -extern u8 unk_2000000[]; extern u8 gUnknown_0202E8F4; // Static diff --git a/src/field/item_menu.c b/src/field/item_menu.c index c508bcacf..09542cc6d 100644 --- a/src/field/item_menu.c +++ b/src/field/item_menu.c @@ -34,9 +34,9 @@ #include "task.h" #include "text.h" #include "unknown_task.h" +#include "ewram.h" // External stuff -extern u8 ewram[]; extern void gpu_pal_allocator_reset__manage_upper_four(void); extern void sub_80F9020(void); extern void sub_80F9988(); @@ -158,12 +158,6 @@ extern struct PocketScrollState gBagPocketScrollStates[]; extern struct ItemSlot *gCurrentBagPocketItemSlots; // selected pocket item slots extern const u8 Event_NoRegisteredItem[]; -#define ewramBerryPic (ewram + 0) -#define ewramBerryPicTemp (ewram + 0x1000) -#define ewramSavedItemsPocket ((struct ItemSlot *)(ewram + 0x1E000)) // saved items pocket (for Wally battle) -#define ewramSavedPokeballsPocket ((struct ItemSlot *)(ewram + 0x1F000)) // saved Pokeballs pocket (for Wally battle) -#define ewramBagSetupStep (ewram[0x1FFFF]) - extern const struct CompressedSpriteSheet sMaleBagSpriteSheet; extern const struct CompressedSpriteSheet sFemaleBagSpriteSheet; extern const struct CompressedSpritePalette sBagSpritePalette; diff --git a/src/field/party_menu.c b/src/field/party_menu.c index 7a519d737..25fd63463 100644 --- a/src/field/party_menu.c +++ b/src/field/party_menu.c @@ -25,7 +25,6 @@ #include "pokemon_summary_screen.h" #include "rom_8077ABC.h" #include "rom_8094928.h" -#include "script_pokemon_80F9.h" #include "songs.h" #include "sound.h" #include "species.h" @@ -35,6 +34,8 @@ #include "task.h" #include "unknown_task.h" #include "util.h" +#include "script_pokemon_80F9.h" +#include "ewram.h" struct Coords8 { @@ -483,9 +484,6 @@ struct Unk201FE00 u8 unkE02; }; -#define ewram1C000 (*(struct Unk201C000 *)(ewram + 0x1C000)) -#define ewram1FE00 (*(struct Unk201FE00 *)(ewram + 0x1FE00)) - extern u16 gBattleTypeFlags; extern u8 gTileBuffer[]; extern u8 gUnknown_0202E8F4; diff --git a/src/field/player_pc.c b/src/field/player_pc.c index d01829266..ce78a88d8 100644 --- a/src/field/player_pc.c +++ b/src/field/player_pc.c @@ -20,6 +20,7 @@ #include "mail.h" #include "overworld.h" #include "player_pc.h" +#include "ewram.h" extern void DisplayItemMessageOnField(u8, const u8*, TaskFunc, u16); extern void DoPlayerPCDecoration(u8); @@ -271,14 +272,14 @@ static void PlayerPC_ItemStorage(u8 taskId) static void PlayerPC_Mailbox(u8 taskId) { MenuZeroFillWindowRect(0, 0, 10, 9); - gMailboxInfo.count = GetMailboxMailCount(); + eMailboxInfo.count = GetMailboxMailCount(); - if (gMailboxInfo.count == 0) + if (eMailboxInfo.count == 0) DisplayItemMessageOnField(taskId, gOtherText_NoMailHere, ReshowPlayerPC, 0); else { - gMailboxInfo.cursorPos = 0; - gMailboxInfo.itemsAbove = 0; + eMailboxInfo.cursorPos = 0; + eMailboxInfo.itemsAbove = 0; Mailbox_UpdateMailList(); ItemStorage_SetItemAndMailCount(taskId); Mailbox_DrawMailboxMenu(taskId); @@ -442,10 +443,10 @@ static void ItemStorage_SetItemAndMailCount(u8 taskId) else NUM_PAGE_ITEMS = NUM_ITEMS + 1; // there are not enough items to fill a full page; take the # of items and add 1 for the cancel button. - if (gMailboxInfo.count > 7) - gMailboxInfo.pageItems = 8; + if (eMailboxInfo.count > 7) + eMailboxInfo.pageItems = 8; else - gMailboxInfo.pageItems = gMailboxInfo.count + 1; + eMailboxInfo.pageItems = eMailboxInfo.count + 1; } static void ItemStorage_ProcessInput(u8 taskId) @@ -1048,8 +1049,8 @@ static void Mailbox_UpdateMailList(void) static void Mailbox_DrawMailList(u8 taskId) // taskId is unused { u16 yCoord = 0; - u16 i = gMailboxInfo.itemsAbove; - register struct MailboxStruct *tempMailbox asm("r1") = &gMailboxInfo; + u16 i = eMailboxInfo.itemsAbove; + register struct MailboxStruct *tempMailbox asm("r1") = &eMailboxInfo; register struct MailboxStruct *mailbox asm("r6"); if(i < i + tempMailbox->pageItems) @@ -1076,10 +1077,10 @@ static void Mailbox_DrawMailList(u8 taskId) // taskId is unused } beforeLabel: - if(i - gMailboxInfo.itemsAbove != 8) + if(i - eMailboxInfo.itemsAbove != 8) MenuFillWindowRectWithBlankTile(0x15, yCoord + 4, 0x1C, 0x12); - switch(gMailboxInfo.itemsAbove) + switch(eMailboxInfo.itemsAbove) { default: CreateVerticalScrollIndicators(0, 0xC8, 8); @@ -1092,7 +1093,7 @@ weirdCase: break; } - if(gMailboxInfo.itemsAbove + gMailboxInfo.pageItems <= gMailboxInfo.count) + if(eMailboxInfo.itemsAbove + eMailboxInfo.pageItems <= eMailboxInfo.count) CreateVerticalScrollIndicators(1, 0xC8, 0x98); else DestroyVerticalScrollIndicator(1); @@ -1107,7 +1108,7 @@ static void Mailbox_DrawMailboxMenu(u8 taskId) MenuPrint(gPCText_Mailbox, 1, 1); MenuDrawTextWindow(0x14, 0, 0x1D, 0x13); Mailbox_DrawMailList(taskId); - InitMenu(0, 0x15, 2, gMailboxInfo.pageItems, gMailboxInfo.cursorPos, 8); + InitMenu(0, 0x15, 2, eMailboxInfo.pageItems, eMailboxInfo.cursorPos, 8); } // Mailbox_ProcessInput @@ -1117,29 +1118,29 @@ static void Mailbox_ProcessInput(u8 taskId) { if(gMain.newAndRepeatedKeys & DPAD_UP) { - if(gMailboxInfo.cursorPos != 0) + if(eMailboxInfo.cursorPos != 0) { PlaySE(SE_SELECT); - gMailboxInfo.cursorPos = MoveMenuCursor(-1); + eMailboxInfo.cursorPos = MoveMenuCursor(-1); } - else if(gMailboxInfo.itemsAbove != 0) + else if(eMailboxInfo.itemsAbove != 0) { PlaySE(SE_SELECT); - gMailboxInfo.itemsAbove--; + eMailboxInfo.itemsAbove--; Mailbox_DrawMailList(taskId); } } else if(gMain.newAndRepeatedKeys & DPAD_DOWN) { - if(gMailboxInfo.cursorPos != gMailboxInfo.pageItems - 1) + if(eMailboxInfo.cursorPos != eMailboxInfo.pageItems - 1) { PlaySE(SE_SELECT); - gMailboxInfo.cursorPos = MoveMenuCursor(1); + eMailboxInfo.cursorPos = MoveMenuCursor(1); } - else if(gMailboxInfo.itemsAbove + gMailboxInfo.cursorPos != gMailboxInfo.count) + else if(eMailboxInfo.itemsAbove + eMailboxInfo.cursorPos != eMailboxInfo.count) { PlaySE(SE_SELECT); - gMailboxInfo.itemsAbove++; + eMailboxInfo.itemsAbove++; Mailbox_DrawMailList(taskId); } } @@ -1148,7 +1149,7 @@ static void Mailbox_ProcessInput(u8 taskId) HandleDestroyMenuCursors(); PlaySE(SE_SELECT); - if(gMailboxInfo.itemsAbove + gMailboxInfo.cursorPos == gMailboxInfo.count) + if(eMailboxInfo.itemsAbove + eMailboxInfo.cursorPos == eMailboxInfo.count) { Mailbox_TurnOff(taskId); } @@ -1177,7 +1178,7 @@ static void Mailbox_CloseScrollIndicators(void) static void Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId) { MenuZeroFillWindowRect(0, 0, 0x1D, 0x13); - StringCopy(gStringVar1, gSaveBlock1.mail[gMailboxInfo.itemsAbove + 6 + gMailboxInfo.cursorPos].playerName); + StringCopy(gStringVar1, gSaveBlock1.mail[eMailboxInfo.itemsAbove + 6 + eMailboxInfo.cursorPos].playerName); SanitizeNameString(gStringVar1); StringExpandPlaceholders(gStringVar4, gOtherText_WhatWillYouDoMail); DisplayItemMessageOnField(taskId, gStringVar4, Mailbox_PrintMailOptions, 0); @@ -1237,7 +1238,7 @@ static void Mailbox_FadeAndReadMail(u8 taskId) { if(!gPaletteFade.active) { - HandleReadMail(&gSaveBlock1.mail[gMailboxInfo.itemsAbove + 6 + gMailboxInfo.cursorPos], Mailbox_ReturnToFieldFromReadMail, 1); + HandleReadMail(&gSaveBlock1.mail[eMailboxInfo.itemsAbove + 6 + eMailboxInfo.cursorPos], Mailbox_ReturnToFieldFromReadMail, 1); DestroyTask(taskId); } } @@ -1276,7 +1277,7 @@ static void Mailbox_DrawYesNoBeforeMove(u8 taskId) static void Mailbox_DoMailMoveToBag(u8 taskId) { - struct MailStruct *mail = &gSaveBlock1.mail[gMailboxInfo.itemsAbove + 6 + gMailboxInfo.cursorPos]; + struct MailStruct *mail = &gSaveBlock1.mail[eMailboxInfo.itemsAbove + 6 + eMailboxInfo.cursorPos]; MenuZeroFillWindowRect(0x14, 8, 0x1A, 0xD); @@ -1290,10 +1291,10 @@ static void Mailbox_DoMailMoveToBag(u8 taskId) ClearMailStruct(mail); Mailbox_UpdateMailList(); - gMailboxInfo.count--; + eMailboxInfo.count--; - if(gMailboxInfo.count < gMailboxInfo.pageItems + gMailboxInfo.itemsAbove && gMailboxInfo.itemsAbove != 0) - gMailboxInfo.itemsAbove--; + if(eMailboxInfo.count < eMailboxInfo.pageItems + eMailboxInfo.itemsAbove && eMailboxInfo.itemsAbove != 0) + eMailboxInfo.itemsAbove--; ItemStorage_SetItemAndMailCount(taskId); } @@ -1329,13 +1330,13 @@ static void Mailbox_DoGiveMailPokeMenu(u8 taskId) // Mailbox_DoGiveMailPokeMenu static void Mailbox_UpdateMailListAfterDeposit(void) { u8 taskId = CreateTask(Mailbox_HandleReturnToProcessInput, 0); - u8 oldCount = gMailboxInfo.count; + u8 oldCount = eMailboxInfo.count; - gMailboxInfo.count = GetMailboxMailCount(); + eMailboxInfo.count = GetMailboxMailCount(); Mailbox_UpdateMailList(); - if(oldCount != gMailboxInfo.count && gMailboxInfo.count < gMailboxInfo.pageItems + gMailboxInfo.itemsAbove && gMailboxInfo.itemsAbove != 0) // did the count update? - gMailboxInfo.itemsAbove--; + if(oldCount != eMailboxInfo.count && eMailboxInfo.count < eMailboxInfo.pageItems + eMailboxInfo.itemsAbove && eMailboxInfo.itemsAbove != 0) // did the count update? + eMailboxInfo.itemsAbove--; ItemStorage_SetItemAndMailCount(taskId); Mailbox_DrawMailboxMenu(taskId); diff --git a/src/field/pokeblock.c b/src/field/pokeblock.c index 2ee1a23ae..a4497295f 100644 --- a/src/field/pokeblock.c +++ b/src/field/pokeblock.c @@ -27,6 +27,7 @@ #include "safari_zone.h" #include "event_data.h" #include "pokeblock.h" +#include "ewram.h" struct UnkPokeblockStruct { @@ -36,9 +37,6 @@ struct UnkPokeblockStruct u8 unk3; }; -extern u8 ewram[]; - - static EWRAM_DATA u8 gUnknown_02039244 = 0; static EWRAM_DATA struct UnkPokeblockStruct gUnknown_02039248 = {0}; static EWRAM_DATA u8 gUnknown_0203924C = 0; @@ -301,7 +299,7 @@ static bool8 sub_810B6C0(void) case 10: if (MultistepInitMenuWindowContinue()) { - ewram[0x1ffff] = 0; + ewram1FFFF = 0; gMain.state++; } break; @@ -319,7 +317,7 @@ static bool8 sub_810B6C0(void) gMain.state++; break; case 13: - ewram[0x1fffe] = sub_810BA50(0x38, 0x40, 0); + ewram1FFFE = sub_810BA50(0x38, 0x40, 0); gMain.state++; break; case 14: @@ -371,27 +369,27 @@ void sub_810B96C(void) static bool8 sub_810B998(void) { - switch (ewram[0x1ffff]) + switch (ewram1FFFF) { case 0: LZDecompressVram(gMenuPokeblock_Gfx, BG_CHAR_ADDR(2)); - ewram[0x1ffff]++; + ewram1FFFF++; break; case 1: LZDecompressWram(gMenuPokeblock_Tilemap, gBGTilemapBuffers[2]); - ewram[0x1ffff]++; + ewram1FFFF++; break; case 2: LoadCompressedPalette(gMenuPokeblock_Pal, 0, 0xc0); - ewram[0x1ffff]++; + ewram1FFFF++; break; case 3: LoadCompressedObjectPic(&gUnknown_083F7F74); - ewram[0x1ffff]++; + ewram1FFFF++; break; case 4: LoadCompressedObjectPalette(&gUnknown_083F7F7C); - ewram[0x1ffff] = 0; + ewram1FFFF = 0; return TRUE; } return FALSE; @@ -613,7 +611,7 @@ static void sub_810BDAC(bool8 flag) static void sub_810BF38(bool8 flag) { PlaySE(SE_SELECT); - gSprites[ewram[0x1fffe]].callback = sub_810C8D4; + gSprites[ewram1FFFE].callback = sub_810C8D4; sub_810BDAC(flag); } diff --git a/src/field/region_map.c b/src/field/region_map.c index bfd2729c2..d643c373d 100644 --- a/src/field/region_map.c +++ b/src/field/region_map.c @@ -17,6 +17,7 @@ #include "string_util.h" #include "text.h" #include "trig.h" +#include "ewram.h" // Map Section IDs #define MAPSEC_LITTLEROOT_TOWN 0 @@ -1350,12 +1351,6 @@ struct UnknownStruct3 struct RegionMap regionMap; }; -extern u8 ewram[]; -#define ewram0 (*(struct UnknownStruct3 *)(ewram + 0)) -#define ewram888 (ewram + 0x888) -#define ewramA6E (ewram[0xA6E]) -#define ewramBlankMapName (ewram + 0xA48) - static const u16 sFlyRegionMapFrame_Pal[] = INCBIN_U16("graphics/pokenav/map_frame.gbapal"); static const u8 sFlyRegionMapFrame_ImageLZ[] = INCBIN_U8("graphics/pokenav/map_frame.4bpp.lz"); static const u8 sFlyRegionMapFrame_TilemapLZ[] = INCBIN_U8("graphics/pokenav/map_frame.bin.lz"); @@ -1431,7 +1426,7 @@ static const struct UnknownStruct4 sUnknown_083E79C0[1] = }; // XXX: what is this? -static u8 *const ewram_ = ewram; +static u8 *const ewram_ = gSharedMem; static const struct SpritePalette sFlyTargetIconSpritePalette = {sFlyTargetIcons_Pal, 2}; @@ -1552,10 +1547,10 @@ void CB2_InitFlyRegionMap(void) MenuZeroFillScreen(); break; case 3: - InitRegionMap(&ewram0.regionMap, 0); + InitRegionMap(&ewram0_3.regionMap, 0); CreateRegionMapCursor(0, 0); CreateRegionMapPlayerIcon(1, 1); - ewram0.unk6 = ewram0.regionMap.mapSecId; + ewram0_3.unk6 = ewram0_3.regionMap.mapSecId; StringFill(ewramBlankMapName, CHAR_SPACE, 12); PrintFlyTargetName(); break; @@ -1598,20 +1593,20 @@ static void VBlankCB_FlyRegionMap(void) static void CB2_FlyRegionMap(void) { - ewram0.unk0(); + ewram0_3.unk0(); AnimateSprites(); BuildOamBuffer(); } static void sub_80FC244(void (*func)(void)) { - ewram0.unk0 = func; - ewram0.unk4 = 0; + ewram0_3.unk0 = func; + ewram0_3.unk4 = 0; } static void PrintFlyTargetName(void) { - if (ewram0.regionMap.unk16 == 2 || ewram0.regionMap.unk16 == 4) + if (ewram0_3.regionMap.unk16 == 2 || ewram0_3.regionMap.unk16 == 4) { u16 i = 0; int zero; @@ -1620,13 +1615,13 @@ static void PrintFlyTargetName(void) { const struct UnknownStruct4 *r4 = &sUnknown_083E79C0[i]; - if (ewram0.regionMap.mapSecId == r4->mapSecId) + if (ewram0_3.regionMap.mapSecId == r4->mapSecId) { if (FlagGet(r4->flag)) { MenuDrawTextWindow(16, 14, 29, 19); - MenuPrint(ewram0.regionMap.mapSecName, 17, 15); - MenuPrint_RightAligned(r4->unk0[ewram0.regionMap.everGrandeCityArea], 29, 17); + MenuPrint(ewram0_3.regionMap.mapSecName, 17, 15); + MenuPrint_RightAligned(r4->unk0[ewram0_3.regionMap.everGrandeCityArea], 29, 17); return; } break; @@ -1637,7 +1632,7 @@ static void PrintFlyTargetName(void) if (zero == 0) { MenuDrawTextWindow(16, 16, 29, 19); - MenuPrint(ewram0.regionMap.mapSecName, 17, 17); + MenuPrint(ewram0_3.regionMap.mapSecName, 17, 17); MenuZeroFillWindowRect(16, 14, 29, 15); } } @@ -1738,7 +1733,7 @@ static void CreateSpecialAreaFlyTargetIcons(void) static void SpriteCB_FlyTargetIcons(struct Sprite *sprite) { // Blink if our mapSecId is the one selected on the map - if (ewram0.regionMap.mapSecId == sprite->data0) + if (ewram0_3.regionMap.mapSecId == sprite->data0) { // Toggle visibility every 16 frames sprite->data1++; @@ -1757,11 +1752,11 @@ static void SpriteCB_FlyTargetIcons(struct Sprite *sprite) static void sub_80FC5B4(void) { - switch (ewram0.unk4) + switch (ewram0_3.unk4) { case 0: BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); - ewram0.unk4++; + ewram0_3.unk4++; break; case 1: if (UpdatePaletteFade() != 0) @@ -1773,7 +1768,7 @@ static void sub_80FC5B4(void) static void sub_80FC600(void) { - if (ewram0.unk4 == 0) + if (ewram0_3.unk4 == 0) { switch (sub_80FAB60()) { @@ -1785,7 +1780,7 @@ static void sub_80FC600(void) PrintFlyTargetName(); break; case INPUT_EVENT_A_BUTTON: - if (ewram0.regionMap.unk16 == 2 || ewram0.regionMap.unk16 == 4) + if (ewram0_3.regionMap.unk16 == 2 || ewram0_3.regionMap.unk16 == 4) { m4aSongNumStart(SE_SELECT); ewramA6E = 1; @@ -1803,11 +1798,11 @@ static void sub_80FC600(void) static void sub_80FC69C(void) { - switch (ewram0.unk4) + switch (ewram0_3.unk4) { case 0: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); - ewram0.unk4++; + ewram0_3.unk4++; break; case 1: if (UpdatePaletteFade() != 0) @@ -1815,7 +1810,7 @@ static void sub_80FC69C(void) FreeRegionMapIconResources(); if (ewramA6E != 0) { - switch (ewram0.regionMap.mapSecId) + switch (ewram0_3.regionMap.mapSecId) { case MAPSEC_SOUTHERN_ISLAND: sub_8053538(22); @@ -1827,13 +1822,13 @@ static void sub_80FC69C(void) sub_8053538((gSaveBlock2.playerGender == MALE) ? 12 : 13); break; case MAPSEC_EVER_GRANDE_CITY: - sub_8053538((FlagGet(0x854) && ewram0.regionMap.everGrandeCityArea == 0) ? 20 : 11); + sub_8053538((FlagGet(0x854) && ewram0_3.regionMap.everGrandeCityArea == 0) ? 20 : 11); break; default: - if (sUnknown_083E7920[ewram0.regionMap.mapSecId][2] != 0) - sub_8053538(sUnknown_083E7920[ewram0.regionMap.mapSecId][2]); + if (sUnknown_083E7920[ewram0_3.regionMap.mapSecId][2] != 0) + sub_8053538(sUnknown_083E7920[ewram0_3.regionMap.mapSecId][2]); else - warp1_set_2(sUnknown_083E7920[ewram0.regionMap.mapSecId][0], sUnknown_083E7920[ewram0.regionMap.mapSecId][1], -1); + warp1_set_2(sUnknown_083E7920[ewram0_3.regionMap.mapSecId][0], sUnknown_083E7920[ewram0_3.regionMap.mapSecId][1], -1); break; } sub_80865BC(); diff --git a/src/field/shop.c b/src/field/shop.c index 375205935..67e9b006e 100644 --- a/src/field/shop.c +++ b/src/field/shop.c @@ -26,13 +26,10 @@ #include "overworld.h" #include "decoration_inventory.h" #include "field_camera.h" - -#define ewram18000 ((u16 *)(ewram + 0x18000)) -#define ewram18300 ((u16 *)(ewram + 0x18300)) +#include "ewram.h" extern bool8 sub_80A52C4(u8, u8); -extern u8 ewram[]; extern u8 gBuyMenuFrame_Gfx[]; extern u16 gBuyMenuFrame_Tilemap[]; extern u16 gMenuMoneyPal[16]; @@ -54,7 +51,7 @@ static struct MartInfo gMartInfo; // ewram EWRAM_DATA u32 gMartTotalCost = 0; -EWRAM_DATA s16 gUnknown_020386A4[16][4] = {0}; // game freak barely uses 2d arrays wtf? +EWRAM_DATA s16 gUnknown_020386A4[16][4] = {0}; EWRAM_DATA struct ItemSlot gUnknown_02038724[3] = {0}; // tv.c uses this, so it cant be static EWRAM_DATA u8 gUnknown_02038730 = 0; EWRAM_DATA u8 gUnknown_02038731 = 0; diff --git a/src/field/slot_machine.c b/src/field/slot_machine.c index 153970337..d6b20feaa 100644 --- a/src/field/slot_machine.c +++ b/src/field/slot_machine.c @@ -15,7 +15,7 @@ struct UnkStruct1 { /*0x02*/ s16 unk02; }; -extern struct UnkStruct2000000 unk_2000000; +extern struct UnkStruct2000000 gSharedMem; extern struct UnkStruct1 *gUnknown_083ED048[]; extern const u16 gPalette_83EDE24[]; @@ -40,7 +40,7 @@ void sub_8104CAC(u8 arg0) { sub_8104DA4(); - task = &gTasks[unk_2000000.unk3D]; + task = &gTasks[gSharedMem.unk3D]; task->data[1] = arg0; i = 0; diff --git a/src/field/tv.c b/src/field/tv.c index 87fc03065..a0287e7df 100644 --- a/src/field/tv.c +++ b/src/field/tv.c @@ -38,6 +38,7 @@ #include "string_util.h" #include "strings.h" #include "text.h" +#include "ewram.h" struct UnkTvStruct { @@ -95,9 +96,6 @@ extern u8 gBattleOutcome; extern u16 gLastUsedItem; -extern u8 ewram[]; -#define gUnknown_02007000 (*(ewramStruct_02007000 *)(ewram + 0x7000)) - static EWRAM_DATA u16 gUnknown_020387E0 = 0; static EWRAM_DATA u16 gUnknown_020387E2 = 0; static EWRAM_DATA u8 gUnknown_020387E4 = 0; |