diff --git a/data/field_effect_scripts.s b/data/field_effect_scripts.s index 6850154d3..23b184122 100644 --- a/data/field_effect_scripts.s +++ b/data/field_effect_scripts.s @@ -52,8 +52,8 @@ gFieldEffectScriptPointers:: @ 82DB9D4 .4byte gFieldEffectScript_UseDive @ FLDEFF_USE_DIVE .4byte gFieldEffectScript_Pokeball @ FLDEFF_POKEBALL .4byte gFieldEffectScript_HeartIcon @ FLDEFF_HEART_ICON - .4byte gFieldEffectScript_Unknown47 @ FLDEFF_NOP_47 - .4byte gFieldEffectScript_Unknown48 @ FLDEFF_NOP_48 + .4byte gFieldEffectScript_Nop47 @ FLDEFF_NOP_47 + .4byte gFieldEffectScript_Nop48 @ FLDEFF_NOP_48 .4byte gFieldEffectScript_AshPuff @ FLDEFF_ASH_PUFF .4byte gFieldEffectScript_AshLaunch @ FLDEFF_ASH_LAUNCH .4byte gFieldEffectScript_SweetScent @ FLDEFF_SWEET_SCENT @@ -263,12 +263,12 @@ gFieldEffectScript_HeartIcon:: @ 82DBC56 field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo0, FldEff_HeartIcon field_eff_end -gFieldEffectScript_Unknown47:: @ 82DBC60 - field_eff_callnative FldEff_NopA6FC +gFieldEffectScript_Nop47:: @ 82DBC60 + field_eff_callnative FldEff_Nop47 field_eff_end -gFieldEffectScript_Unknown48:: @ 82DBC66 - field_eff_callnative FldEff_NopA700 +gFieldEffectScript_Nop48:: @ 82DBC66 + field_eff_callnative FldEff_Nop48 field_eff_end gFieldEffectScript_AshPuff:: @ 82DBC6C @@ -284,7 +284,7 @@ gFieldEffectScript_SweetScent:: @ 82DBC80 field_eff_end gFieldEffectScript_SandPillar:: @ 82DBC86 - field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo9, FldEff_SandPillar + field_eff_loadfadedpal_callnative gSpritePalette_SandPillar, FldEff_SandPillar field_eff_end gFieldEffectScript_Bubbles:: @ 82DBC90 @@ -296,15 +296,15 @@ gFieldEffectScript_Sparkle:: @ 82DBC9A field_eff_end gFieldEffectScript_ShowSecretPowerCave:: @ 82DBCA4 - field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo7, FldEff_SecretPowerCave + field_eff_loadfadedpal_callnative gSpritePalette_SecretPower_Cave, FldEff_SecretPowerCave field_eff_end gFieldEffectScript_ShowSecretPowerTree:: @ 82DBCAE - field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo8, FldEff_SecretPowerTree + field_eff_loadfadedpal_callnative gSpritePalette_SecretPower_Plant, FldEff_SecretPowerTree field_eff_end gFieldEffectScript_ShowSecretPowerShrub:: @ 82DBCB8 - field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo8, FldEff_SecretPowerShrub + field_eff_loadfadedpal_callnative gSpritePalette_SecretPower_Plant, FldEff_SecretPowerShrub field_eff_end gFieldEffectScript_ShowCutGrass:: @ 82DBCC2 diff --git a/data/scripts/field_move_scripts.inc b/data/scripts/field_move_scripts.inc index 56e3297b6..c5647daa4 100644 --- a/data/scripts/field_move_scripts.inc +++ b/data/scripts/field_move_scripts.inc @@ -77,7 +77,7 @@ EventScript_RockSmash:: @ 82907A6 goto EventScript_SmashRock end -EventScript_FldEffRockSmash:: @ 82907F0 +EventScript_RockSmashFromPartyMenu:: @ 82907F0 lockall dofieldeffect FLDEFF_USE_ROCK_SMASH waitstate @@ -89,10 +89,10 @@ EventScript_SmashRock:: @ 82907FB waitmovement 0 removeobject VAR_LAST_TALKED specialvar VAR_RESULT, TryUpdateRusturfTunnelState - compare VAR_RESULT, 1 + compare VAR_RESULT, TRUE goto_if_eq EventScript_EndSmash special RockSmashWildEncounter - compare VAR_RESULT, 0 + compare VAR_RESULT, FALSE goto_if_eq EventScript_EndSmash waitstate releaseall diff --git a/graphics/unknown/unknown_58E82C.pal b/graphics/field_effects/palettes/record_mix_lights.pal similarity index 100% rename from graphics/unknown/unknown_58E82C.pal rename to graphics/field_effects/palettes/record_mix_lights.pal diff --git a/graphics/field_effects/pics/record_mix_lights.png b/graphics/field_effects/pics/record_mix_lights.png new file mode 100644 index 000000000..b6d3d6537 Binary files /dev/null and b/graphics/field_effects/pics/record_mix_lights.png differ diff --git a/graphics/field_effects/pics/sand_pillar.png b/graphics/field_effects/pics/sand_pillar.png new file mode 100644 index 000000000..1f56c00fc Binary files /dev/null and b/graphics/field_effects/pics/sand_pillar.png differ diff --git a/graphics/unknown/858E674/0.png b/graphics/field_effects/pics/sand_pillar/0.png similarity index 100% rename from graphics/unknown/858E674/0.png rename to graphics/field_effects/pics/sand_pillar/0.png diff --git a/graphics/unknown/858E674/1.png b/graphics/field_effects/pics/sand_pillar/1.png similarity index 100% rename from graphics/unknown/858E674/1.png rename to graphics/field_effects/pics/sand_pillar/1.png diff --git a/graphics/unknown/858E674/2.png b/graphics/field_effects/pics/sand_pillar/2.png similarity index 100% rename from graphics/unknown/858E674/2.png rename to graphics/field_effects/pics/sand_pillar/2.png diff --git a/graphics/field_effects/pics/secret_power_cave.png b/graphics/field_effects/pics/secret_power_cave.png new file mode 100644 index 000000000..445b275f3 Binary files /dev/null and b/graphics/field_effects/pics/secret_power_cave.png differ diff --git a/graphics/field_effects/pics/secret_power_shrub.png b/graphics/field_effects/pics/secret_power_shrub.png new file mode 100644 index 000000000..322643372 Binary files /dev/null and b/graphics/field_effects/pics/secret_power_shrub.png differ diff --git a/graphics/field_effects/pics/secret_power_tree.png b/graphics/field_effects/pics/secret_power_tree.png new file mode 100644 index 000000000..879741784 Binary files /dev/null and b/graphics/field_effects/pics/secret_power_tree.png differ diff --git a/graphics/unknown/858E588/0.png b/graphics/unknown/858E588/0.png deleted file mode 100644 index 70b0774b0..000000000 Binary files a/graphics/unknown/858E588/0.png and /dev/null differ diff --git a/graphics/unknown/858E588/1.png b/graphics/unknown/858E588/1.png deleted file mode 100644 index e176b5f73..000000000 Binary files a/graphics/unknown/858E588/1.png and /dev/null differ diff --git a/graphics/unknown/858E588/2.png b/graphics/unknown/858E588/2.png deleted file mode 100644 index c006bb660..000000000 Binary files a/graphics/unknown/858E588/2.png and /dev/null differ diff --git a/graphics/unknown/858E588/3.png b/graphics/unknown/858E588/3.png deleted file mode 100644 index 67a3cf769..000000000 Binary files a/graphics/unknown/858E588/3.png and /dev/null differ diff --git a/graphics/unknown/858E588/4.png b/graphics/unknown/858E588/4.png deleted file mode 100644 index e2a5aec4f..000000000 Binary files a/graphics/unknown/858E588/4.png and /dev/null differ diff --git a/graphics/unknown/858E5B0/0.png b/graphics/unknown/858E5B0/0.png deleted file mode 100644 index afd104d7c..000000000 Binary files a/graphics/unknown/858E5B0/0.png and /dev/null differ diff --git a/graphics/unknown/858E5B0/1.png b/graphics/unknown/858E5B0/1.png deleted file mode 100644 index 026b9b7af..000000000 Binary files a/graphics/unknown/858E5B0/1.png and /dev/null differ diff --git a/graphics/unknown/858E5B0/2.png b/graphics/unknown/858E5B0/2.png deleted file mode 100644 index 360e2ab63..000000000 Binary files a/graphics/unknown/858E5B0/2.png and /dev/null differ diff --git a/graphics/unknown/858E5B0/3.png b/graphics/unknown/858E5B0/3.png deleted file mode 100644 index 88672c182..000000000 Binary files a/graphics/unknown/858E5B0/3.png and /dev/null differ diff --git a/graphics/unknown/858E5B0/4.png b/graphics/unknown/858E5B0/4.png deleted file mode 100644 index 660ad331d..000000000 Binary files a/graphics/unknown/858E5B0/4.png and /dev/null differ diff --git a/graphics/unknown/858E5B0/5.png b/graphics/unknown/858E5B0/5.png deleted file mode 100644 index 7006e9cc9..000000000 Binary files a/graphics/unknown/858E5B0/5.png and /dev/null differ diff --git a/graphics/unknown/858E5D8/0.png b/graphics/unknown/858E5D8/0.png deleted file mode 100644 index 110b1dd0a..000000000 Binary files a/graphics/unknown/858E5D8/0.png and /dev/null differ diff --git a/graphics/unknown/858E5D8/1.png b/graphics/unknown/858E5D8/1.png deleted file mode 100644 index f50079de7..000000000 Binary files a/graphics/unknown/858E5D8/1.png and /dev/null differ diff --git a/graphics/unknown/858E5D8/2.png b/graphics/unknown/858E5D8/2.png deleted file mode 100644 index a54bb3d12..000000000 Binary files a/graphics/unknown/858E5D8/2.png and /dev/null differ diff --git a/graphics/unknown/858E5D8/3.png b/graphics/unknown/858E5D8/3.png deleted file mode 100644 index 0ea6e43c9..000000000 Binary files a/graphics/unknown/858E5D8/3.png and /dev/null differ diff --git a/graphics/unknown/858E5D8/4.png b/graphics/unknown/858E5D8/4.png deleted file mode 100644 index 4b4e300bb..000000000 Binary files a/graphics/unknown/858E5D8/4.png and /dev/null differ diff --git a/graphics/unknown/858E84C/0.png b/graphics/unknown/858E84C/0.png deleted file mode 100644 index 4673403e0..000000000 Binary files a/graphics/unknown/858E84C/0.png and /dev/null differ diff --git a/graphics/unknown/858E84C/1.png b/graphics/unknown/858E84C/1.png deleted file mode 100644 index c55f2146d..000000000 Binary files a/graphics/unknown/858E84C/1.png and /dev/null differ diff --git a/graphics/unknown/858E84C/2.png b/graphics/unknown/858E84C/2.png deleted file mode 100644 index 4f03b50ae..000000000 Binary files a/graphics/unknown/858E84C/2.png and /dev/null differ diff --git a/include/event_scripts.h b/include/event_scripts.h index dad746126..8495b7ee1 100644 --- a/include/event_scripts.h +++ b/include/event_scripts.h @@ -375,7 +375,7 @@ extern const u8 SecretBase_Text_Trainer9Defeated[]; extern const u8 EventScript_FldEffStrength[]; extern const u8 EventScript_FailSweetScent[]; extern const u8 EventScript_FldEffFlash[]; -extern const u8 EventScript_FldEffRockSmash[]; +extern const u8 EventScript_RockSmashFromPartyMenu[]; //player pc extern const u8 LittlerootTown_BrendansHouse_2F_EventScript_TurnOffPlayerPC[]; diff --git a/include/fldeff_misc.h b/include/fldeff_misc.h index 6fd15c1ea..4acca7944 100644 --- a/include/fldeff_misc.h +++ b/include/fldeff_misc.h @@ -1,10 +1,10 @@ #ifndef GUARD_FLDEFF_MISC_H #define GUARD_FLDEFF_MISC_H -void sub_80F9BCC(u16 a0, u16 a1, u8 a2); -void sub_80F9BF4(u16 a0, u16 a1, u8 a2); -bool8 sub_80F9C1C(void); -bool8 sub_80F9C30(void); +void ComputerScreenOpenEffect(u16 a0, u16 a1, u8 a2); +void ComputerScreenCloseEffect(u16 a0, u16 a1, u8 a2); +bool8 IsComputerScreenOpenEffectActive(void); +bool8 IsComputerScreenCloseEffectActive(void); bool8 SetUpFieldMove_SecretPower(void); bool8 FldEff_UseSecretPowerCave(void); bool8 FldEff_SecretPowerCave(void); @@ -15,22 +15,22 @@ bool8 FldEff_SecretPowerShrub(void); bool8 FldEff_SecretBasePCTurnOn(void); void DoSecretBasePCTurnOffEffect(void); void PopSecretBaseBalloon(s16 metatileId, s16 x, s16 y); -bool8 FldEff_NopA6FC(void); -bool8 FldEff_NopA700(void); +bool8 FldEff_Nop47(void); +bool8 FldEff_Nop48(void); void ShatterSecretBaseBreakableDoor(s16 x, s16 y); void PlaySecretBaseMusicNoteMatSound(s16 metatileId); void DoSecretBaseGlitterMatSparkle(void); bool8 FldEff_SandPillar(void); void InteractWithShieldOrTVDecoration(void); -bool8 sub_80FADE4(u16 arg0, u8 arg1); +bool8 IsLargeBreakableDecoration(u16 arg0, u8 arg1); void FldEffPoison_Start(void); bool32 FldEffPoison_IsActive(void); void DoWateringBerryTreeAnim(void); -u8 CreateRecordMixingSprite(void); -void DestroyRecordMixingSprite(void); +u8 CreateRecordMixingLights(void); +void DestroyRecordMixingLights(void); -extern const struct SpritePalette gFieldEffectObjectPaletteInfo7; -extern const struct SpritePalette gFieldEffectObjectPaletteInfo8; +extern const struct SpritePalette gSpritePalette_SecretPower_Cave; +extern const struct SpritePalette gSpritePalette_SecretPower_Plant; extern const struct SpritePalette gFieldEffectObjectPaletteInfo9; extern const u16 gTilesetPalettes_SecretBase[][16]; diff --git a/spritesheet_rules.mk b/spritesheet_rules.mk index 3fb32aa54..1c858899c 100644 --- a/spritesheet_rules.mk +++ b/spritesheet_rules.mk @@ -662,3 +662,18 @@ $(FLDEFFGFXDIR)/small_sparkle.4bpp: %.4bpp: %.png $(FLDEFFGFXDIR)/unused_grass_3.4bpp: %.4bpp: %.png $(GFX) $< $@ -mwidth 2 -mheight 2 + +$(FLDEFFGFXDIR)/secret_power_cave.4bpp: %.4bpp: %.png + $(GFX) $< $@ -mwidth 2 -mheight 2 + +$(FLDEFFGFXDIR)/secret_power_shrub.4bpp: %.4bpp: %.png + $(GFX) $< $@ -mwidth 2 -mheight 2 + +$(FLDEFFGFXDIR)/secret_power_tree.4bpp: %.4bpp: %.png + $(GFX) $< $@ -mwidth 2 -mheight 2 + +$(FLDEFFGFXDIR)/sand_pillar.4bpp: %.4bpp: %.png + $(GFX) $< $@ -mwidth 2 -mheight 4 + +$(FLDEFFGFXDIR)/record_mix_lights.4bpp: %.4bpp: %.png + $(GFX) $< $@ -mwidth 4 -mheight 1 diff --git a/src/field_effect.c b/src/field_effect.c index fbf6bd10c..b681fc70e 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -2229,7 +2229,7 @@ void StartEscapeRopeFieldEffect(void) { ScriptContext2_Enable(); FreezeObjectEvents(); - CreateTask(Task_EscapeRopeWarpOut, 0x50); + CreateTask(Task_EscapeRopeWarpOut, 80); } static void Task_EscapeRopeWarpOut(u8 taskId) @@ -2598,8 +2598,8 @@ static void FieldMoveShowMonOutdoorsEffect_Init(struct Task *task) task->data[11] = REG_WININ; task->data[12] = REG_WINOUT; StoreWordInTwoHalfwords(&task->data[13], (u32)gMain.vblankCallback); - task->tWinHoriz = WIN_RANGE(240, 241); - task->tWinVert = WIN_RANGE(80, 81); + task->tWinHoriz = WIN_RANGE(DISPLAY_WIDTH, DISPLAY_WIDTH + 1); + task->tWinVert = WIN_RANGE(DISPLAY_HEIGHT / 2, DISPLAY_HEIGHT / 2 + 1); task->tWinIn = WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR; task->tWinOut = WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR; SetGpuReg(REG_OFFSET_WIN0H, task->tWinHoriz); @@ -2637,15 +2637,15 @@ static void FieldMoveShowMonOutdoorsEffect_CreateBanner(struct Task *task) if (horiz < 0) horiz = 0; - if (vertHi < 40) - vertHi = 40; + if (vertHi < DISPLAY_HEIGHT / 4) + vertHi = DISPLAY_HEIGHT / 4; - if (vertLo > 120) - vertLo = 120; + if (vertLo > DISPLAY_WIDTH / 2) + vertLo = DISPLAY_WIDTH / 2; task->tWinHoriz = (horiz << 8) | (task->tWinHoriz & 0xff); task->tWinVert = (vertHi << 8) | vertLo; - if (horiz == 0 && vertHi == 40 && vertLo == 120) + if (horiz == 0 && vertHi == DISPLAY_HEIGHT / 4 && vertLo == DISPLAY_WIDTH / 2) { gSprites[task->tMonSpriteId].callback = SpriteCB_FieldMoveMonSlideOnscreen; task->tState++; @@ -2670,15 +2670,15 @@ static void FieldMoveShowMonOutdoorsEffect_ShrinkBanner(struct Task *task) vertHi += 6; vertLo -= 6; - if (vertHi > 80) - vertHi = 80; + if (vertHi > DISPLAY_HEIGHT / 2) + vertHi = DISPLAY_HEIGHT / 2; - if (vertLo < 81) - vertLo = 81; + if (vertLo < DISPLAY_HEIGHT / 2 + 1) + vertLo = DISPLAY_HEIGHT / 2 + 1; task->tWinVert = (vertHi << 8) | vertLo; - if (vertHi == 80 && vertLo == 81) + if (vertHi == DISPLAY_HEIGHT / 2 && vertLo == DISPLAY_HEIGHT / 2 + 1) task->tState++; } @@ -2686,8 +2686,8 @@ static void FieldMoveShowMonOutdoorsEffect_RestoreBg(struct Task *task) { u16 bg0cnt = (REG_BG0CNT >> 8) << 11; CpuFill32(0, (void *)VRAM + bg0cnt, 0x800); - task->tWinHoriz = 241; - task->tWinVert = 161; + task->tWinHoriz = DISPLAY_WIDTH + 1; + task->tWinVert = DISPLAY_HEIGHT + 1; task->tWinIn = task->data[11]; task->tWinOut = task->data[12]; task->tState++; @@ -2787,8 +2787,8 @@ static void FieldMoveShowMonIndoorsEffect_SlideBannerOn(struct Task *task) { if (SlideIndoorBannerOnscreen(task)) { - SetGpuReg(REG_OFFSET_WIN1H, 0x00f0); - SetGpuReg(REG_OFFSET_WIN1V, 0x2878); + SetGpuReg(REG_OFFSET_WIN1H, WIN_RANGE(0, DISPLAY_WIDTH)); + SetGpuReg(REG_OFFSET_WIN1V, WIN_RANGE(DISPLAY_HEIGHT / 4, DISPLAY_HEIGHT - DISPLAY_HEIGHT / 4)); gSprites[task->tMonSpriteId].callback = SpriteCB_FieldMoveMonSlideOnscreen; task->tState++; } @@ -2807,8 +2807,8 @@ static void FieldMoveShowMonIndoorsEffect_RestoreBg(struct Task *task) AnimateIndoorShowMonBg(task); task->tBgOffsetIdx = task->tBgHoriz & 7; task->tBgOffset = 0; - SetGpuReg(REG_OFFSET_WIN1H, 0xffff); - SetGpuReg(REG_OFFSET_WIN1V, 0xffff); + SetGpuReg(REG_OFFSET_WIN1H, WIN_RANGE(0xFF, 0xFF)); + SetGpuReg(REG_OFFSET_WIN1V, WIN_RANGE(0xFF, 0xFF)); task->tState++; } @@ -2917,7 +2917,7 @@ static u8 InitFieldMoveMonSprite(u32 species, u32 otId, u32 personality) struct Sprite *sprite; v0 = (species & 0x80000000) >> 16; species &= 0x7fffffff; - monSprite = CreateMonSprite_FieldMove(species, otId, personality, 0x140, 0x50, 0); + monSprite = CreateMonSprite_FieldMove(species, otId, personality, 320, 80, 0); sprite = &gSprites[monSprite]; sprite->callback = SpriteCallbackDummy; sprite->oam.priority = 0; @@ -2928,9 +2928,9 @@ static u8 InitFieldMoveMonSprite(u32 species, u32 otId, u32 personality) static void SpriteCB_FieldMoveMonSlideOnscreen(struct Sprite *sprite) { - if ((sprite->pos1.x -= 20) <= 120) + if ((sprite->pos1.x -= 20) <= DISPLAY_WIDTH / 2) { - sprite->pos1.x = 120; + sprite->pos1.x = DISPLAY_WIDTH / 2; sprite->sOnscreenTimer = 30; sprite->callback = SpriteCB_FieldMoveMonWaitAfterCry; if (sprite->data[6]) @@ -2947,21 +2947,15 @@ static void SpriteCB_FieldMoveMonSlideOnscreen(struct Sprite *sprite) static void SpriteCB_FieldMoveMonWaitAfterCry(struct Sprite *sprite) { if ((--sprite->sOnscreenTimer) == 0) - { sprite->callback = SpriteCB_FieldMoveMonSlideOffscreen; - } } static void SpriteCB_FieldMoveMonSlideOffscreen(struct Sprite *sprite) { if (sprite->pos1.x < -64) - { sprite->sSlidOffscreen = TRUE; - } else - { sprite->pos1.x -= 20; - } } #undef tState @@ -3311,7 +3305,7 @@ static void StartFlyBirdSwoopDown(u8 spriteId) struct Sprite *sprite; sprite = &gSprites[spriteId]; sprite->callback = SpriteCB_FlyBirdSwoopDown; - sprite->pos1.x = 120; + sprite->pos1.x = DISPLAY_WIDTH / 2; sprite->pos1.y = 0; sprite->pos2.x = 0; sprite->pos2.y = 0; diff --git a/src/fieldmap.c b/src/fieldmap.c index 5eb00ad27..8e45add3f 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -939,7 +939,7 @@ static bool8 SkipCopyingMetatileFromSavedMap(u16* mapMetatilePtr, u16 mapWidth, else mapMetatilePtr += mapWidth; - if (sub_80FADE4(*mapMetatilePtr & METATILE_ID_MASK, yMode) == 1) + if (IsLargeBreakableDecoration(*mapMetatilePtr & METATILE_ID_MASK, yMode) == TRUE) return TRUE; return FALSE; } diff --git a/src/fldeff_cut.c b/src/fldeff_cut.c index 2c9151598..efd533d08 100644 --- a/src/fldeff_cut.c +++ b/src/fldeff_cut.c @@ -355,36 +355,36 @@ static void SetCutGrassMetatile(s16 x, s16 y) switch (metatileId) { - case METATILE_ID(Fortree, LongGrass_Root): - case METATILE_ID(General, LongGrass): - case METATILE_ID(General, TallGrass): - MapGridSetMetatileIdAt(x, y, METATILE_ID(General, Grass)); + case METATILE_Fortree_LongGrass_Root: + case METATILE_General_LongGrass: + case METATILE_General_TallGrass: + MapGridSetMetatileIdAt(x, y, METATILE_General_Grass); break; - case METATILE_ID(General, TallGrass_TreeLeft): - MapGridSetMetatileIdAt(x, y, METATILE_ID(General, Grass_TreeLeft)); + case METATILE_General_TallGrass_TreeLeft: + MapGridSetMetatileIdAt(x, y, METATILE_General_Grass_TreeLeft); break; - case METATILE_ID(General, TallGrass_TreeRight): - MapGridSetMetatileIdAt(x, y, METATILE_ID(General, Grass_TreeRight)); + case METATILE_General_TallGrass_TreeRight: + MapGridSetMetatileIdAt(x, y, METATILE_General_Grass_TreeRight); break; - case METATILE_ID(Fortree, SecretBase_LongGrass_BottomLeft): - MapGridSetMetatileIdAt(x, y, METATILE_ID(Fortree, SecretBase_LongGrass_TopLeft)); + case METATILE_Fortree_SecretBase_LongGrass_BottomLeft: + MapGridSetMetatileIdAt(x, y, METATILE_Fortree_SecretBase_LongGrass_TopLeft); break; - case METATILE_ID(Fortree, SecretBase_LongGrass_BottomMid): - MapGridSetMetatileIdAt(x, y, METATILE_ID(Fortree, SecretBase_LongGrass_TopMid)); + case METATILE_Fortree_SecretBase_LongGrass_BottomMid: + MapGridSetMetatileIdAt(x, y, METATILE_Fortree_SecretBase_LongGrass_TopMid); break; - case METATILE_ID(Fortree, SecretBase_LongGrass_BottomRight): - MapGridSetMetatileIdAt(x, y, METATILE_ID(Fortree, SecretBase_LongGrass_TopRight)); + case METATILE_Fortree_SecretBase_LongGrass_BottomRight: + MapGridSetMetatileIdAt(x, y, METATILE_Fortree_SecretBase_LongGrass_TopRight); break; - case METATILE_ID(Lavaridge, NormalGrass): - case METATILE_ID(Lavaridge, AshGrass): - MapGridSetMetatileIdAt(x, y, METATILE_ID(Lavaridge, LavaField)); + case METATILE_Lavaridge_NormalGrass: + case METATILE_Lavaridge_AshGrass: + MapGridSetMetatileIdAt(x, y, METATILE_Lavaridge_LavaField); break; - case METATILE_ID(Fallarbor, NormalGrass): - case METATILE_ID(Fallarbor, AshGrass): - MapGridSetMetatileIdAt(x, y, METATILE_ID(Fallarbor, AshField)); + case METATILE_Fallarbor_NormalGrass: + case METATILE_Fallarbor_AshGrass: + MapGridSetMetatileIdAt(x, y, METATILE_Fallarbor_AshField); break; - case METATILE_ID(General, TallGrass_TreeUp): - MapGridSetMetatileIdAt(x, y, METATILE_ID(General, Grass_TreeUp)); + case METATILE_General_TallGrass_TreeUp: + MapGridSetMetatileIdAt(x, y, METATILE_General_Grass_TreeUp); break; } } @@ -402,13 +402,13 @@ static u8 GetLongGrassCaseAt(s16 x, s16 y) { u16 metatileId = MapGridGetMetatileIdAt(x, y); - if (metatileId == METATILE_ID(General, Grass)) + if (metatileId == METATILE_General_Grass) return LONG_GRASS_FIELD; - else if (metatileId == METATILE_ID(Fortree, SecretBase_LongGrass_TopLeft)) + else if (metatileId == METATILE_Fortree_SecretBase_LongGrass_TopLeft) return LONG_GRASS_BASE_LEFT; - else if (metatileId == METATILE_ID(Fortree, SecretBase_LongGrass_TopMid)) + else if (metatileId == METATILE_Fortree_SecretBase_LongGrass_TopMid) return LONG_GRASS_BASE_CENTER; - else if (metatileId == METATILE_ID(Fortree, SecretBase_LongGrass_TopRight)) + else if (metatileId == METATILE_Fortree_SecretBase_LongGrass_TopRight) return LONG_GRASS_BASE_RIGHT; else return LONG_GRASS_NONE; @@ -422,34 +422,34 @@ static void SetCutGrassMetatiles(s16 x, s16 y) for (i = 0; i < sCutSquareSide; i++) { s16 currentX = x + i; - if (MapGridGetMetatileIdAt(currentX, y) == METATILE_ID(General, LongGrass)) + if (MapGridGetMetatileIdAt(currentX, y) == METATILE_General_LongGrass) { switch (GetLongGrassCaseAt(currentX, y + 1)) { case LONG_GRASS_FIELD: - MapGridSetMetatileIdAt(currentX, y + 1, METATILE_ID(Fortree, LongGrass_Root)); + MapGridSetMetatileIdAt(currentX, y + 1, METATILE_Fortree_LongGrass_Root); break; case LONG_GRASS_BASE_LEFT: - MapGridSetMetatileIdAt(currentX, y + 1, METATILE_ID(Fortree, SecretBase_LongGrass_BottomLeft)); + MapGridSetMetatileIdAt(currentX, y + 1, METATILE_Fortree_SecretBase_LongGrass_BottomLeft); break; case LONG_GRASS_BASE_CENTER: - MapGridSetMetatileIdAt(currentX, y + 1, METATILE_ID(Fortree, SecretBase_LongGrass_BottomMid)); + MapGridSetMetatileIdAt(currentX, y + 1, METATILE_Fortree_SecretBase_LongGrass_BottomMid); break; case LONG_GRASS_BASE_RIGHT: - MapGridSetMetatileIdAt(currentX, y + 1, METATILE_ID(Fortree, SecretBase_LongGrass_BottomRight)); + MapGridSetMetatileIdAt(currentX, y + 1, METATILE_Fortree_SecretBase_LongGrass_BottomRight); break; } } - if (MapGridGetMetatileIdAt(currentX, lowerY) == METATILE_ID(General, Grass)) + if (MapGridGetMetatileIdAt(currentX, lowerY) == METATILE_General_Grass) { - if (MapGridGetMetatileIdAt(currentX, lowerY + 1) == METATILE_ID(Fortree, LongGrass_Root)) - MapGridSetMetatileIdAt(currentX, lowerY + 1, METATILE_ID(General, Grass)); - if (MapGridGetMetatileIdAt(currentX, lowerY + 1) == METATILE_ID(Fortree, SecretBase_LongGrass_BottomLeft)) - MapGridSetMetatileIdAt(currentX, lowerY + 1, METATILE_ID(Fortree, SecretBase_LongGrass_TopLeft)); - if (MapGridGetMetatileIdAt(currentX, lowerY + 1) == METATILE_ID(Fortree, SecretBase_LongGrass_BottomMid)) - MapGridSetMetatileIdAt(currentX, lowerY + 1, METATILE_ID(Fortree, SecretBase_LongGrass_TopMid)); - if (MapGridGetMetatileIdAt(currentX, lowerY + 1) == METATILE_ID(Fortree, SecretBase_LongGrass_BottomRight)) - MapGridSetMetatileIdAt(currentX, lowerY + 1, METATILE_ID(Fortree, SecretBase_LongGrass_TopRight)); + if (MapGridGetMetatileIdAt(currentX, lowerY + 1) == METATILE_Fortree_LongGrass_Root) + MapGridSetMetatileIdAt(currentX, lowerY + 1, METATILE_General_Grass); + if (MapGridGetMetatileIdAt(currentX, lowerY + 1) == METATILE_Fortree_SecretBase_LongGrass_BottomLeft) + MapGridSetMetatileIdAt(currentX, lowerY + 1, METATILE_Fortree_SecretBase_LongGrass_TopLeft); + if (MapGridGetMetatileIdAt(currentX, lowerY + 1) == METATILE_Fortree_SecretBase_LongGrass_BottomMid) + MapGridSetMetatileIdAt(currentX, lowerY + 1, METATILE_Fortree_SecretBase_LongGrass_TopMid); + if (MapGridGetMetatileIdAt(currentX, lowerY + 1) == METATILE_Fortree_SecretBase_LongGrass_BottomRight) + MapGridSetMetatileIdAt(currentX, lowerY + 1, METATILE_Fortree_SecretBase_LongGrass_TopRight); } } @@ -486,62 +486,62 @@ static void HandleLongGrassOnHyper(u8 caseId, s16 x, s16 y) if (arr[0] == TRUE) { - if (MapGridGetMetatileIdAt(newX, y + 3) == METATILE_ID(Fortree, LongGrass_Root)) - MapGridSetMetatileIdAt(newX, y + 3, METATILE_ID(General, Grass)); - if (MapGridGetMetatileIdAt(newX, y + 3) == METATILE_ID(Fortree, SecretBase_LongGrass_BottomLeft)) - MapGridSetMetatileIdAt(newX, y + 3, METATILE_ID(Fortree, SecretBase_LongGrass_TopLeft)); - if (MapGridGetMetatileIdAt(newX, y + 3) == METATILE_ID(Fortree, SecretBase_LongGrass_BottomMid)) - MapGridSetMetatileIdAt(newX, y + 3, METATILE_ID(Fortree, SecretBase_LongGrass_TopMid)); - if (MapGridGetMetatileIdAt(newX, y + 3) == METATILE_ID(Fortree, SecretBase_LongGrass_BottomRight)) - MapGridSetMetatileIdAt(newX, y + 3, METATILE_ID(Fortree, SecretBase_LongGrass_TopRight)); + if (MapGridGetMetatileIdAt(newX, y + 3) == METATILE_Fortree_LongGrass_Root) + MapGridSetMetatileIdAt(newX, y + 3, METATILE_General_Grass); + if (MapGridGetMetatileIdAt(newX, y + 3) == METATILE_Fortree_SecretBase_LongGrass_BottomLeft) + MapGridSetMetatileIdAt(newX, y + 3, METATILE_Fortree_SecretBase_LongGrass_TopLeft); + if (MapGridGetMetatileIdAt(newX, y + 3) == METATILE_Fortree_SecretBase_LongGrass_BottomMid) + MapGridSetMetatileIdAt(newX, y + 3, METATILE_Fortree_SecretBase_LongGrass_TopMid); + if (MapGridGetMetatileIdAt(newX, y + 3) == METATILE_Fortree_SecretBase_LongGrass_BottomRight) + MapGridSetMetatileIdAt(newX, y + 3, METATILE_Fortree_SecretBase_LongGrass_TopRight); } if (arr[1] == TRUE) { - if (MapGridGetMetatileIdAt(newX, y + 2) == METATILE_ID(General, LongGrass)) + if (MapGridGetMetatileIdAt(newX, y + 2) == METATILE_General_LongGrass) { switch (GetLongGrassCaseAt(newX, y + 3)) { case LONG_GRASS_FIELD: - MapGridSetMetatileIdAt(newX, y + 3, METATILE_ID(Fortree, LongGrass_Root)); + MapGridSetMetatileIdAt(newX, y + 3, METATILE_Fortree_LongGrass_Root); break; case LONG_GRASS_BASE_LEFT: - MapGridSetMetatileIdAt(newX, y + 3, METATILE_ID(Fortree, SecretBase_LongGrass_BottomLeft)); + MapGridSetMetatileIdAt(newX, y + 3, METATILE_Fortree_SecretBase_LongGrass_BottomLeft); break; case LONG_GRASS_BASE_CENTER: - MapGridSetMetatileIdAt(newX, y + 3, METATILE_ID(Fortree, SecretBase_LongGrass_BottomMid)); + MapGridSetMetatileIdAt(newX, y + 3, METATILE_Fortree_SecretBase_LongGrass_BottomMid); break; case LONG_GRASS_BASE_RIGHT: - MapGridSetMetatileIdAt(newX, y + 3, METATILE_ID(Fortree, SecretBase_LongGrass_BottomRight)); + MapGridSetMetatileIdAt(newX, y + 3, METATILE_Fortree_SecretBase_LongGrass_BottomRight); break; } } - if (MapGridGetMetatileIdAt(newX, y + 4) == METATILE_ID(Fortree, LongGrass_Root)) - MapGridSetMetatileIdAt(newX, y + 4, METATILE_ID(General, Grass)); - if (MapGridGetMetatileIdAt(newX, y + 4) == METATILE_ID(Fortree, SecretBase_LongGrass_BottomLeft)) - MapGridSetMetatileIdAt(newX, y + 4, METATILE_ID(Fortree, SecretBase_LongGrass_TopLeft)); - if (MapGridGetMetatileIdAt(newX, y + 4) == METATILE_ID(Fortree, SecretBase_LongGrass_BottomMid)) - MapGridSetMetatileIdAt(newX, y + 4, METATILE_ID(Fortree, SecretBase_LongGrass_TopMid)); - if (MapGridGetMetatileIdAt(newX, y + 4) == METATILE_ID(Fortree, SecretBase_LongGrass_BottomRight)) - MapGridSetMetatileIdAt(newX, y + 4, METATILE_ID(Fortree, SecretBase_LongGrass_TopRight)); + if (MapGridGetMetatileIdAt(newX, y + 4) == METATILE_Fortree_LongGrass_Root) + MapGridSetMetatileIdAt(newX, y + 4, METATILE_General_Grass); + if (MapGridGetMetatileIdAt(newX, y + 4) == METATILE_Fortree_SecretBase_LongGrass_BottomLeft) + MapGridSetMetatileIdAt(newX, y + 4, METATILE_Fortree_SecretBase_LongGrass_TopLeft); + if (MapGridGetMetatileIdAt(newX, y + 4) == METATILE_Fortree_SecretBase_LongGrass_BottomMid) + MapGridSetMetatileIdAt(newX, y + 4, METATILE_Fortree_SecretBase_LongGrass_TopMid); + if (MapGridGetMetatileIdAt(newX, y + 4) == METATILE_Fortree_SecretBase_LongGrass_BottomRight) + MapGridSetMetatileIdAt(newX, y + 4, METATILE_Fortree_SecretBase_LongGrass_TopRight); } if (arr[2] == TRUE) { - if (MapGridGetMetatileIdAt(newX, y + 3) == METATILE_ID(General, LongGrass)) + if (MapGridGetMetatileIdAt(newX, y + 3) == METATILE_General_LongGrass) { switch (GetLongGrassCaseAt(newX, y + 4)) { case LONG_GRASS_FIELD: - MapGridSetMetatileIdAt(newX, y + 4, METATILE_ID(Fortree, LongGrass_Root)); + MapGridSetMetatileIdAt(newX, y + 4, METATILE_Fortree_LongGrass_Root); break; case LONG_GRASS_BASE_LEFT: - MapGridSetMetatileIdAt(newX, y + 4, METATILE_ID(Fortree, SecretBase_LongGrass_BottomLeft)); + MapGridSetMetatileIdAt(newX, y + 4, METATILE_Fortree_SecretBase_LongGrass_BottomLeft); break; case LONG_GRASS_BASE_CENTER: - MapGridSetMetatileIdAt(newX, y + 4, METATILE_ID(Fortree, SecretBase_LongGrass_BottomMid)); + MapGridSetMetatileIdAt(newX, y + 4, METATILE_Fortree_SecretBase_LongGrass_BottomMid); break; case LONG_GRASS_BASE_RIGHT: - MapGridSetMetatileIdAt(newX, y + 4, METATILE_ID(Fortree, SecretBase_LongGrass_BottomRight)); + MapGridSetMetatileIdAt(newX, y + 4, METATILE_Fortree_SecretBase_LongGrass_BottomRight); break; } } @@ -595,16 +595,16 @@ void FixLongGrassMetatilesWindowTop(s16 x, s16 y) switch (GetLongGrassCaseAt(x, y + 1)) { case LONG_GRASS_FIELD: - MapGridSetMetatileIdAt(x, y + 1, METATILE_ID(Fortree, LongGrass_Root)); + MapGridSetMetatileIdAt(x, y + 1, METATILE_Fortree_LongGrass_Root); break; case LONG_GRASS_BASE_LEFT: - MapGridSetMetatileIdAt(x, y + 1, METATILE_ID(Fortree, SecretBase_LongGrass_BottomLeft)); + MapGridSetMetatileIdAt(x, y + 1, METATILE_Fortree_SecretBase_LongGrass_BottomLeft); break; case LONG_GRASS_BASE_CENTER: - MapGridSetMetatileIdAt(x, y + 1, METATILE_ID(Fortree, SecretBase_LongGrass_BottomMid)); + MapGridSetMetatileIdAt(x, y + 1, METATILE_Fortree_SecretBase_LongGrass_BottomMid); break; case LONG_GRASS_BASE_RIGHT: - MapGridSetMetatileIdAt(x, y + 1, METATILE_ID(Fortree, SecretBase_LongGrass_BottomRight)); + MapGridSetMetatileIdAt(x, y + 1, METATILE_Fortree_SecretBase_LongGrass_BottomRight); break; } } @@ -612,7 +612,7 @@ void FixLongGrassMetatilesWindowTop(s16 x, s16 y) void FixLongGrassMetatilesWindowBottom(s16 x, s16 y) { - if (MapGridGetMetatileIdAt(x, y) == METATILE_ID(General, Grass)) + if (MapGridGetMetatileIdAt(x, y) == METATILE_General_Grass) { u8 metatileBehavior = MapGridGetMetatileBehaviorAt(x, y + 1); if (MetatileBehavior_IsLongGrassSouthEdge(metatileBehavior)) @@ -620,17 +620,17 @@ void FixLongGrassMetatilesWindowBottom(s16 x, s16 y) s32 metatileId = MapGridGetMetatileIdAt(x, y + 1); switch (metatileId) { - case METATILE_ID(Fortree, LongGrass_Root): - MapGridSetMetatileIdAt(x, y + 1, METATILE_ID(General, Grass)); + case METATILE_Fortree_LongGrass_Root: + MapGridSetMetatileIdAt(x, y + 1, METATILE_General_Grass); break; - case METATILE_ID(Fortree, SecretBase_LongGrass_BottomLeft): - MapGridSetMetatileIdAt(x, y + 1, METATILE_ID(Fortree, SecretBase_LongGrass_TopLeft)); + case METATILE_Fortree_SecretBase_LongGrass_BottomLeft: + MapGridSetMetatileIdAt(x, y + 1, METATILE_Fortree_SecretBase_LongGrass_TopLeft); break; - case METATILE_ID(Fortree, SecretBase_LongGrass_BottomMid): - MapGridSetMetatileIdAt(x, y + 1, METATILE_ID(Fortree, SecretBase_LongGrass_TopMid)); + case METATILE_Fortree_SecretBase_LongGrass_BottomMid: + MapGridSetMetatileIdAt(x, y + 1, METATILE_Fortree_SecretBase_LongGrass_TopMid); break; - case METATILE_ID(Fortree, SecretBase_LongGrass_BottomRight): - MapGridSetMetatileIdAt(x, y + 1, METATILE_ID(Fortree, SecretBase_LongGrass_TopRight)); + case METATILE_Fortree_SecretBase_LongGrass_BottomRight: + MapGridSetMetatileIdAt(x, y + 1, METATILE_Fortree_SecretBase_LongGrass_TopRight); break; } } diff --git a/src/fldeff_misc.c b/src/fldeff_misc.c index bb5bd65d7..50feaf368 100644 --- a/src/fldeff_misc.c +++ b/src/fldeff_misc.c @@ -28,68 +28,54 @@ EWRAM_DATA struct MapPosition gPlayerFacingPosition = {0}; -static void sub_80F9C90(u8); -static void sub_80F9DFC(u8); +static void Task_ComputerScreenOpenEffect(u8); +static void Task_ComputerScreenCloseEffect(u8); +static void CreateComputerScreenEffectTask(TaskFunc, u16, u16, u8); static void Task_SecretBasePCTurnOn(u8); static void Task_PopSecretBaseBalloon(u8); static void DoBalloonSoundEffect(s16); -static void Task_WateringBerryTreeAnim_1(u8); -static void Task_WateringBerryTreeAnim_2(u8); -static void Task_WateringBerryTreeAnim_3(u8); - -static void sub_80F9C44(TaskFunc, u16, u16, u8); +static void Task_WateringBerryTreeAnim_Start(u8); +static void Task_WateringBerryTreeAnim_Continue(u8); +static void Task_WateringBerryTreeAnim_End(u8); static void FieldCallback_SecretBaseCave(void); -static void CaveEntranceSpriteCallback1(struct Sprite *); -static void CaveEntranceSpriteCallback2(struct Sprite *); -static void CaveEntranceSpriteCallbackEnd(struct Sprite *); +static void SpriteCB_CaveEntranceInit(struct Sprite *); +static void SpriteCB_CaveEntranceOpen(struct Sprite *); +static void SpriteCB_CaveEntranceEnd(struct Sprite *); static void StartSecretBaseCaveFieldEffect(void); static void FieldCallback_SecretBaseTree(void); -static void TreeEntranceSpriteCallback1(struct Sprite *); -static void TreeEntranceSpriteCallback2(struct Sprite *); -static void TreeEntranceSpriteCallbackEnd(struct Sprite *); +static void SpriteCB_TreeEntranceInit(struct Sprite *); +static void SpriteCB_TreeEntranceOpen(struct Sprite *); +static void SpriteCB_TreeEntranceEnd(struct Sprite *); static void StartSecretBaseTreeFieldEffect(void); static void FieldCallback_SecretBaseShrub(void); -static void ShrubEntranceSpriteCallback1(struct Sprite *); -static void ShrubEntranceSpriteCallback2(struct Sprite *); -static void ShrubEntranceSpriteCallbackEnd(struct Sprite *); +static void SpriteCB_ShrubEntranceInit(struct Sprite *); +static void SpriteCB_ShrubEntranceOpen(struct Sprite *); +static void SpriteCB_ShrubEntranceEnd(struct Sprite *); static void StartSecretBaseShrubFieldEffect(void); -static void SpriteCB_SandPillar_0(struct Sprite *); -static void SpriteCB_SandPillar_1(struct Sprite *); -static void SpriteCB_SandPillar_2(struct Sprite *); +static void SpriteCB_SandPillar_BreakTop(struct Sprite *); +static void SpriteCB_SandPillar_BreakBase(struct Sprite *); +static void SpriteCB_SandPillar_End(struct Sprite *); -static const u8 gSpriteImage_858D978[] = INCBIN_U8("graphics/unknown/858E588/0.4bpp"); -static const u8 gSpriteImage_858D9F8[] = INCBIN_U8("graphics/unknown/858E588/1.4bpp"); -static const u8 gSpriteImage_858DA78[] = INCBIN_U8("graphics/unknown/858E588/2.4bpp"); -static const u8 gSpriteImage_858DAF8[] = INCBIN_U8("graphics/unknown/858E588/3.4bpp"); -static const u8 gSpriteImage_858DB78[] = INCBIN_U8("graphics/unknown/858E588/4.4bpp"); +static const u8 sSecretPowerCave_Gfx[] = INCBIN_U8("graphics/field_effects/pics/secret_power_cave.4bpp"); +static const u8 sFiller[32] = {0}; +static const u16 sSecretPowerCave_Pal[] = INCBIN_U16("graphics/field_effects/palettes/07.gbapal"); +static const u8 sSecretPowerShrub_Gfx[] = INCBIN_U8("graphics/field_effects/pics/secret_power_shrub.4bpp"); +static const u8 sSecretPowerTree_Gfx[] = INCBIN_U8("graphics/field_effects/pics/secret_power_tree.4bpp"); +static const u16 sSecretPowerPlant_Pal[] = INCBIN_U16("graphics/field_effects/palettes/08.gbapal"); -static const u8 gUnusedEmptySpace_858DBF8[32] = {0}; +// TODO: These should also be combined into a single image +static const u8 sSandPillar0_Gfx[] = INCBIN_U8("graphics/field_effects/pics/sand_pillar/0.4bpp"); +static const u8 sSandPillar1_Gfx[] = INCBIN_U8("graphics/field_effects/pics/sand_pillar/1.4bpp"); +static const u8 sSandPillar2_Gfx[] = INCBIN_U8("graphics/field_effects/pics/sand_pillar/2.4bpp"); -static const u16 gFieldEffectObjectPalette7[] = INCBIN_U16("graphics/field_effects/palettes/07.gbapal"); -static const u8 gSpriteImage_858DC38[] = INCBIN_U8("graphics/unknown/858E5D8/0.4bpp"); -static const u8 gSpriteImage_858DCB8[] = INCBIN_U8("graphics/unknown/858E5D8/1.4bpp"); -static const u8 gSpriteImage_858DD38[] = INCBIN_U8("graphics/unknown/858E5D8/2.4bpp"); -static const u8 gSpriteImage_858DDB8[] = INCBIN_U8("graphics/unknown/858E5D8/3.4bpp"); -static const u8 gSpriteImage_858DE38[] = INCBIN_U8("graphics/unknown/858E5D8/4.4bpp"); -static const u8 gSpriteImage_858DEB8[] = INCBIN_U8("graphics/unknown/858E5B0/0.4bpp"); -static const u8 gSpriteImage_858DF38[] = INCBIN_U8("graphics/unknown/858E5B0/1.4bpp"); -static const u8 gSpriteImage_858DFB8[] = INCBIN_U8("graphics/unknown/858E5B0/2.4bpp"); -static const u8 gSpriteImage_858E038[] = INCBIN_U8("graphics/unknown/858E5B0/3.4bpp"); -static const u8 gSpriteImage_858E0B8[] = INCBIN_U8("graphics/unknown/858E5B0/4.4bpp"); -static const u8 gSpriteImage_858E138[] = INCBIN_U8("graphics/unknown/858E5B0/5.4bpp"); -static const u16 gFieldEffectObjectPalette8[] = INCBIN_U16("graphics/field_effects/palettes/08.gbapal"); -static const u8 gSpriteImage_858E1D8[] = INCBIN_U8("graphics/unknown/858E674/0.4bpp"); -static const u8 gSpriteImage_858E2D8[] = INCBIN_U8("graphics/unknown/858E674/1.4bpp"); -static const u8 gSpriteImage_858E3D8[] = INCBIN_U8("graphics/unknown/858E674/2.4bpp"); - -static const struct OamData gOamData_858E4D8 = +static const struct OamData sOam_SecretPower = { .y = 0, .x = 0, @@ -101,7 +87,7 @@ static const struct OamData gOamData_858E4D8 = .priority = 2, }; -static const union AnimCmd gSpriteAnim_858E4E0[] = +static const union AnimCmd sAnim_SecretPowerCave[] = { ANIMCMD_FRAME(0, 8), ANIMCMD_FRAME(1, 8), @@ -111,7 +97,7 @@ static const union AnimCmd gSpriteAnim_858E4E0[] = ANIMCMD_END, }; -static const union AnimCmd gSpriteAnim_858E4F8[] = +static const union AnimCmd sAnim_VineDropLeft[] = { ANIMCMD_FRAME(0, 8), ANIMCMD_FRAME(1, 8), @@ -121,7 +107,7 @@ static const union AnimCmd gSpriteAnim_858E4F8[] = ANIMCMD_END, }; -static const union AnimCmd gSpriteAnim_858E510[] = +static const union AnimCmd sAnim_VineRiseLeft[] = { ANIMCMD_FRAME(4, 8), ANIMCMD_FRAME(3, 8), @@ -131,7 +117,7 @@ static const union AnimCmd gSpriteAnim_858E510[] = ANIMCMD_END, }; -static const union AnimCmd gSpriteAnim_858E528[] = +static const union AnimCmd sAnim_VineDropRight[] = { ANIMCMD_FRAME(0, 8, .hFlip = TRUE), ANIMCMD_FRAME(1, 8, .hFlip = TRUE), @@ -141,7 +127,7 @@ static const union AnimCmd gSpriteAnim_858E528[] = ANIMCMD_END, }; -static const union AnimCmd gSpriteAnim_858E540[] = +static const union AnimCmd sAnim_VineRiseRight[] = { ANIMCMD_FRAME(4, 8, .hFlip = TRUE), ANIMCMD_FRAME(3, 8, .hFlip = TRUE), @@ -151,7 +137,7 @@ static const union AnimCmd gSpriteAnim_858E540[] = ANIMCMD_END, }; -static const union AnimCmd gSpriteAnim_858E558[] = +static const union AnimCmd sAnim_SecretPowerShrub[] = { ANIMCMD_FRAME(0, 8), ANIMCMD_FRAME(1, 8), @@ -161,88 +147,89 @@ static const union AnimCmd gSpriteAnim_858E558[] = ANIMCMD_END, }; -static const union AnimCmd *const gSpriteAnimTable_858E570[] = +static const union AnimCmd *const sAnimTable_SecretPowerCave[] = { - gSpriteAnim_858E4E0, + sAnim_SecretPowerCave, }; -static const union AnimCmd *const gSpriteAnimTable_858E574[] = +static const union AnimCmd *const sAnimTable_SecretPowerTree[] = { - gSpriteAnim_858E4F8, - gSpriteAnim_858E510, - gSpriteAnim_858E528, - gSpriteAnim_858E540, + sAnim_VineDropLeft, + sAnim_VineRiseLeft, + sAnim_VineDropRight, + sAnim_VineRiseRight, }; -static const union AnimCmd *const gSpriteAnimTable_858E584[] = +static const union AnimCmd *const sAnimTable_SecretPowerShrub[] = { - gSpriteAnim_858E558, + sAnim_SecretPowerShrub, }; -static const struct SpriteFrameImage gUnknown_858E588[] = +static const struct SpriteFrameImage sPicTable_SecretPowerCave[] = { - {gSpriteImage_858D978, 0x80}, - {gSpriteImage_858D9F8, 0x80}, - {gSpriteImage_858DA78, 0x80}, - {gSpriteImage_858DAF8, 0x80}, - {gSpriteImage_858DB78, 0x80}, + overworld_frame(sSecretPowerCave_Gfx, 2, 2, 0), + overworld_frame(sSecretPowerCave_Gfx, 2, 2, 1), + overworld_frame(sSecretPowerCave_Gfx, 2, 2, 2), + overworld_frame(sSecretPowerCave_Gfx, 2, 2, 3), + overworld_frame(sSecretPowerCave_Gfx, 2, 2, 4), }; -static const struct SpriteFrameImage gUnknown_858E5B0[] = +static const struct SpriteFrameImage sPicTable_SecretPowerTree[] = { - {gSpriteImage_858DEB8, 0x80}, - {gSpriteImage_858DF38, 0x80}, - {gSpriteImage_858DFB8, 0x80}, - {gSpriteImage_858E038, 0x80}, - {gSpriteImage_858E0B8, 0x80}, + overworld_frame(sSecretPowerTree_Gfx, 2, 2, 0), + overworld_frame(sSecretPowerTree_Gfx, 2, 2, 1), + overworld_frame(sSecretPowerTree_Gfx, 2, 2, 2), + overworld_frame(sSecretPowerTree_Gfx, 2, 2, 3), + overworld_frame(sSecretPowerTree_Gfx, 2, 2, 4), + // 6th frame exists but isnt accessed, the tree vine metatile is used instead }; -static const struct SpriteFrameImage gUnknown_858E5D8[] = +static const struct SpriteFrameImage sPicTable_SecretPowerShrub[] = { - {gSpriteImage_858DC38, 0x80}, - {gSpriteImage_858DCB8, 0x80}, - {gSpriteImage_858DD38, 0x80}, - {gSpriteImage_858DDB8, 0x80}, - {gSpriteImage_858DE38, 0x80}, + overworld_frame(sSecretPowerShrub_Gfx, 2, 2, 0), + overworld_frame(sSecretPowerShrub_Gfx, 2, 2, 1), + overworld_frame(sSecretPowerShrub_Gfx, 2, 2, 2), + overworld_frame(sSecretPowerShrub_Gfx, 2, 2, 3), + overworld_frame(sSecretPowerShrub_Gfx, 2, 2, 4), }; -static const struct SpriteTemplate gUnknown_0858E600 = +static const struct SpriteTemplate sSpriteTemplate_SecretPowerCave = { .tileTag = 0xFFFF, .paletteTag = FLDEFF_PAL_TAG_3, - .oam = &gOamData_858E4D8, - .anims = gSpriteAnimTable_858E570, - .images = gUnknown_858E588, + .oam = &sOam_SecretPower, + .anims = sAnimTable_SecretPowerCave, + .images = sPicTable_SecretPowerCave, .affineAnims = gDummySpriteAffineAnimTable, - .callback = CaveEntranceSpriteCallback1, + .callback = SpriteCB_CaveEntranceInit, }; -static const struct SpriteTemplate gUnknown_0858E618 = +static const struct SpriteTemplate sSpriteTemplate_SecretPowerTree = { .tileTag = 0xFFFF, .paletteTag = FLDEFF_PAL_TAG_8, - .oam = &gOamData_858E4D8, - .anims = gSpriteAnimTable_858E574, - .images = gUnknown_858E5B0, + .oam = &sOam_SecretPower, + .anims = sAnimTable_SecretPowerTree, + .images = sPicTable_SecretPowerTree, .affineAnims = gDummySpriteAffineAnimTable, - .callback = TreeEntranceSpriteCallback1, + .callback = SpriteCB_TreeEntranceInit, }; -static const struct SpriteTemplate gUnknown_0858E630 = +static const struct SpriteTemplate sSpriteTemplate_SecretPowerShrub = { .tileTag = 0xFFFF, .paletteTag = FLDEFF_PAL_TAG_8, - .oam = &gOamData_858E4D8, - .anims = gSpriteAnimTable_858E584, - .images = gUnknown_858E5D8, + .oam = &sOam_SecretPower, + .anims = sAnimTable_SecretPowerShrub, + .images = sPicTable_SecretPowerShrub, .affineAnims = gDummySpriteAffineAnimTable, - .callback = ShrubEntranceSpriteCallback1, + .callback = SpriteCB_ShrubEntranceInit, }; -const struct SpritePalette gFieldEffectObjectPaletteInfo7 = {gFieldEffectObjectPalette7, FLDEFF_PAL_TAG_3}; -const struct SpritePalette gFieldEffectObjectPaletteInfo8 = {gFieldEffectObjectPalette8, FLDEFF_PAL_TAG_8}; +const struct SpritePalette gSpritePalette_SecretPower_Cave = {sSecretPowerCave_Pal, FLDEFF_PAL_TAG_3}; +const struct SpritePalette gSpritePalette_SecretPower_Plant = {sSecretPowerPlant_Pal, FLDEFF_PAL_TAG_8}; -static const struct OamData gOamData_858E658 = +static const struct OamData sOam_SandPillar = { .x = 0, .y = 0, @@ -254,7 +241,7 @@ static const struct OamData gOamData_858E658 = .priority = 2, }; -static const union AnimCmd gSpriteAnim_858E660[] = +static const union AnimCmd sAnim_SandPillar[] = { ANIMCMD_FRAME(0, 6), ANIMCMD_FRAME(1, 6), @@ -262,47 +249,45 @@ static const union AnimCmd gSpriteAnim_858E660[] = ANIMCMD_END, }; -static const union AnimCmd *const gSpriteAnimTable_858E670[] = +static const union AnimCmd *const sAnimTable_SandPillar[] = { - gSpriteAnim_858E660, + sAnim_SandPillar, }; -static const struct SpriteFrameImage gUnknown_0858E674[] = +static const struct SpriteFrameImage sPicTable_SandPillar[] = { - {gSpriteImage_858E1D8, 0x100}, - {gSpriteImage_858E2D8, 0x100}, - {gSpriteImage_858E3D8, 0x100}, + {sSandPillar0_Gfx, 0x100}, + {sSandPillar1_Gfx, 0x100}, + {sSandPillar2_Gfx, 0x100}, }; -static const struct SpriteTemplate gUnknown_0858E68C = +static const struct SpriteTemplate sSpriteTemplate_SandPillar = { .tileTag = 0xFFFF, .paletteTag = FLDEFF_PAL_TAG_14, - .oam = &gOamData_858E658, - .anims = gSpriteAnimTable_858E670, - .images = gUnknown_0858E674, + .oam = &sOam_SandPillar, + .anims = sAnimTable_SandPillar, + .images = sPicTable_SandPillar, .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCB_SandPillar_0, + .callback = SpriteCB_SandPillar_BreakTop, }; // This uses one of the secret base palettes, so there is no "graphics/field_effects/palettes/09.pal" file. -const struct SpritePalette gFieldEffectObjectPaletteInfo9 = {gTilesetPalettes_SecretBase[5], FLDEFF_PAL_TAG_14}; +const struct SpritePalette gSpritePalette_SandPillar = {gTilesetPalettes_SecretBase[5], FLDEFF_PAL_TAG_14}; -static const u8 gSpriteImage_858E6AC[] = INCBIN_U8("graphics/unknown/858E84C/0.4bpp"); -static const u8 gSpriteImage_858E72C[] = INCBIN_U8("graphics/unknown/858E84C/1.4bpp"); -static const u8 gSpriteImage_858E7AC[] = INCBIN_U8("graphics/unknown/858E84C/2.4bpp"); -static const u16 gUnknown_0858E82C[] = INCBIN_U16("graphics/unknown/unknown_58E82C.gbapal"); +static const u8 sRecordMixLights_Gfx[] = INCBIN_U8("graphics/field_effects/pics/record_mix_lights.4bpp"); +static const u16 sRecordMixLights_Pal[] = INCBIN_U16("graphics/field_effects/palettes/record_mix_lights.gbapal"); -static const struct SpriteFrameImage gUnknown_0858E84C[] = +static const struct SpriteFrameImage sPicTable_RecordMixLights[] = { - {gSpriteImage_858E6AC, sizeof(gSpriteImage_858E6AC)}, - {gSpriteImage_858E72C, sizeof(gSpriteImage_858E72C)}, - {gSpriteImage_858E7AC, sizeof(gSpriteImage_858E7AC)}, + overworld_frame(sRecordMixLights_Gfx, 4, 1, 0), + overworld_frame(sRecordMixLights_Gfx, 4, 1, 1), + overworld_frame(sRecordMixLights_Gfx, 4, 1, 2), }; -static const struct SpritePalette gUnknown_0858E864 = {gUnknown_0858E82C, FLDEFF_PAL_TAG_0}; +static const struct SpritePalette sSpritePalette_RecordMixLights = {sRecordMixLights_Pal, FLDEFF_PAL_TAG_0}; -static const union AnimCmd gSpriteAnim_858E86C[] = +static const union AnimCmd sAnim_RecordMixLights[] = { ANIMCMD_FRAME(0, 30), ANIMCMD_FRAME(1, 30), @@ -310,173 +295,182 @@ static const union AnimCmd gSpriteAnim_858E86C[] = ANIMCMD_JUMP(0), }; -static const union AnimCmd *const gSpriteAnimTable_858E87C[] = +static const union AnimCmd *const sAnimTable_RecordMixLights[] = { - gSpriteAnim_858E86C, + sAnim_RecordMixLights, }; -static const struct SpriteTemplate gUnknown_0858E880 = +static const struct SpriteTemplate sSpriteTemplate_RecordMixLights = { .tileTag = 0xFFFF, .paletteTag = FLDEFF_PAL_TAG_0, .oam = &gObjectEventBaseOam_32x8, - .anims = gSpriteAnimTable_858E87C, - .images = gUnknown_0858E84C, + .anims = sAnimTable_RecordMixLights, + .images = sPicTable_RecordMixLights, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy, }; -void sub_80F9BCC(u16 a0, u16 a1, u8 a2) +// For accessing pokemon storage PC or the Hall of Fame PC +void ComputerScreenOpenEffect(u16 increment, u16 unused, u8 priority) { - sub_80F9C44(sub_80F9C90, a0, a1, a2); + CreateComputerScreenEffectTask(Task_ComputerScreenOpenEffect, increment, unused, priority); } -void sub_80F9BF4(u16 a0, u16 a1, u8 a2) +void ComputerScreenCloseEffect(u16 increment, u16 unused, u8 priority) { - sub_80F9C44(sub_80F9DFC, a0, a1, a2); + CreateComputerScreenEffectTask(Task_ComputerScreenCloseEffect, increment, unused, priority); } -bool8 sub_80F9C1C(void) +bool8 IsComputerScreenOpenEffectActive(void) { - return FuncIsActiveTask(sub_80F9C90); + return FuncIsActiveTask(Task_ComputerScreenOpenEffect); } -bool8 sub_80F9C30(void) +bool8 IsComputerScreenCloseEffectActive(void) { - return FuncIsActiveTask(sub_80F9DFC); + return FuncIsActiveTask(Task_ComputerScreenCloseEffect); } -static void sub_80F9C44(void (*taskfunc) (u8), u16 a1, u16 a2, u8 a3) -{ - u8 taskId = CreateTask(taskfunc, a3); +#define tState data[0] +#define tHorzIncrement data[1] +#define tVertIncrement data[2] +#define tWinLeft data[3] +#define tWinRight data[4] +#define tWinTop data[5] +#define tWinBottom data[6] +#define tBlendCnt data[7] +#define tBlendY data[8] - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[1] = a1 == 0 ? 16 : a1; - gTasks[taskId].data[2] = a1 == 0 ? 20 : a1; +static void CreateComputerScreenEffectTask(void (*taskfunc) (u8), u16 increment, u16 unused, u8 priority) +{ + u8 taskId = CreateTask(taskfunc, priority); + + gTasks[taskId].tState = 0; + gTasks[taskId].tHorzIncrement = increment == 0 ? 16 : increment; + gTasks[taskId].tVertIncrement = increment == 0 ? 20 : increment; gTasks[taskId].func(taskId); } -static void sub_80F9C90(u8 taskId) +static void Task_ComputerScreenOpenEffect(u8 taskId) { struct Task *task = &gTasks[taskId]; - switch (task->data[0]) + switch (task->tState) { case 0: - task->data[3] = 0x78; - task->data[4] = 0x78; - task->data[5] = 0x50; - task->data[6] = 0x51; + task->tWinLeft = DISPLAY_WIDTH / 2; + task->tWinRight = DISPLAY_WIDTH / 2; + task->tWinTop = DISPLAY_HEIGHT / 2; + task->tWinBottom = DISPLAY_HEIGHT / 2 + 1; SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->data[3], task->data[4])); - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[6])); - SetGpuReg(REG_OFFSET_WININ, 0x3F); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->tWinLeft, task->tWinRight)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom)); + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR); SetGpuReg(REG_OFFSET_WINOUT, 0); break; case 1: - task->data[7] = GetGpuReg(REG_OFFSET_BLDCNT); - task->data[8] = GetGpuReg(REG_OFFSET_BLDY); + task->tBlendCnt = GetGpuReg(REG_OFFSET_BLDCNT); + task->tBlendY = GetGpuReg(REG_OFFSET_BLDY); SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_ALL | BLDCNT_EFFECT_LIGHTEN); - SetGpuReg(REG_OFFSET_BLDY, 0x10); + SetGpuReg(REG_OFFSET_BLDY, 16); break; case 2: - task->data[3] -= task->data[1]; - task->data[4] += task->data[1]; + task->tWinLeft -= task->tHorzIncrement; + task->tWinRight += task->tHorzIncrement; - if (task->data[3] < 1 || task->data[4] > 0xEF) + if (task->tWinLeft < 1 || task->tWinRight > DISPLAY_WIDTH - 1) { - task->data[3] = 0; - task->data[4] = 0xF0; + task->tWinLeft = 0; + task->tWinRight = DISPLAY_WIDTH; SetGpuReg(REG_OFFSET_BLDY, 0); - SetGpuReg(REG_OFFSET_BLDCNT, task->data[7]); + SetGpuReg(REG_OFFSET_BLDCNT, task->tBlendCnt); BlendPalettes(0xFFFFFFFF, 0, 0); gPlttBufferFaded[0] = 0; } - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->data[3], task->data[4])); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->tWinLeft, task->tWinRight)); - if (task->data[3] != 0) + if (task->tWinLeft != 0) return; break; case 3: - task->data[5] -= task->data[2]; - task->data[6] += task->data[2]; + task->tWinTop -= task->tVertIncrement; + task->tWinBottom += task->tVertIncrement; - if (task->data[5] < 1 || task->data[6] > 0x9F) + if (task->tWinTop < 1 || task->tWinBottom > DISPLAY_HEIGHT - 1) { - task->data[5] = 0; - task->data[6] = 0xA0; + task->tWinTop = 0; + task->tWinBottom = DISPLAY_HEIGHT; ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); } - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[6])); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom)); - if (task->data[5] != 0) + if (task->tWinTop != 0) return; break; default: - SetGpuReg(REG_OFFSET_BLDCNT, task->data[7]); + SetGpuReg(REG_OFFSET_BLDCNT, task->tBlendCnt); DestroyTask(taskId); return; } - task->data[0]++; + task->tState++; } -static void sub_80F9DFC(u8 taskId) +static void Task_ComputerScreenCloseEffect(u8 taskId) { struct Task *task = &gTasks[taskId]; - int temp = task->data[0]; - - switch (temp) + switch (task->tState) { case 0: - gPlttBufferFaded[0] = temp; + gPlttBufferFaded[0] = 0; break; case 1: - task->data[3] = 0; - task->data[4] = 0xF0; - task->data[5] = 0; - task->data[6] = 0xA0; + task->tWinLeft = 0; + task->tWinRight = DISPLAY_WIDTH; + task->tWinTop = 0; + task->tWinBottom = DISPLAY_HEIGHT; SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->data[3], task->data[4])); - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[6])); - SetGpuReg(REG_OFFSET_WININ, 0x3F); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->tWinLeft, task->tWinRight)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom)); + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR); SetGpuReg(REG_OFFSET_WINOUT, 0); break; case 2: - task->data[5] += task->data[2]; - task->data[6] -= task->data[2]; + task->tWinTop += task->tVertIncrement; + task->tWinBottom -= task->tVertIncrement; - if (task->data[5] > 0x4F || task->data[6] < 0x52) + if (task->tWinTop >= DISPLAY_HEIGHT / 2 || task->tWinBottom <= DISPLAY_HEIGHT / 2 + 1) { - task->data[5] = 0x50; - task->data[6] = 0x51; + task->tWinTop = DISPLAY_HEIGHT / 2; + task->tWinBottom = DISPLAY_HEIGHT / 2 + 1; SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_ALL | BLDCNT_EFFECT_LIGHTEN); - SetGpuReg(REG_OFFSET_BLDY, 0x10); + SetGpuReg(REG_OFFSET_BLDY, 16); } - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[6])); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom)); - if (task->data[5] != 0x50) + if (task->tWinTop != DISPLAY_HEIGHT / 2) return; break; case 3: - task->data[3] += task->data[1]; - task->data[4] -= task->data[1]; + task->tWinLeft += task->tHorzIncrement; + task->tWinRight -= task->tHorzIncrement; - if (task->data[3] > 0x77 || task->data[4] < 0x79) + if (task->tWinLeft >= DISPLAY_WIDTH / 2 || task->tWinRight <= DISPLAY_WIDTH / 2) { - task->data[3] = 0x78; - task->data[4] = 0x78; - BlendPalettes(-1, 0x10, 0); + task->tWinLeft = DISPLAY_WIDTH / 2; + task->tWinRight = DISPLAY_WIDTH / 2; + BlendPalettes(-1, 16, 0); gPlttBufferFaded[0] = 0; } - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->data[3], task->data[4])); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->tWinLeft, task->tWinRight)); - if (task->data[3] != 0x78) + if (task->tWinLeft != DISPLAY_WIDTH / 2) return; break; default: @@ -486,9 +480,19 @@ static void sub_80F9DFC(u8 taskId) DestroyTask(taskId); return; } - task->data[0]++; + task->tState++; } +#undef tState +#undef tHorzIncrement +#undef tVertIncrement +#undef tWinLeft +#undef tWinRight +#undef tWinTop +#undef tWinBottom +#undef tBlendCnt +#undef tBlendY + static void SetCurrentSecretBase(void) { SetCurSecretBaseIdFromPosition(&gPlayerFacingPosition, gMapHeader.events); @@ -607,22 +611,22 @@ static void StartSecretBaseCaveFieldEffect(void) bool8 FldEff_SecretPowerCave(void) { AdjustSecretPowerSpritePixelOffsets(); - CreateSprite(&gUnknown_0858E600, + CreateSprite(&sSpriteTemplate_SecretPowerCave, gSprites[gPlayerAvatar.spriteId].oam.x + gFieldEffectArguments[5], gSprites[gPlayerAvatar.spriteId].oam.y + gFieldEffectArguments[6], 148); return FALSE; } -static void CaveEntranceSpriteCallback1(struct Sprite *sprite) +static void SpriteCB_CaveEntranceInit(struct Sprite *sprite) { PlaySE(SE_W088); sprite->data[0] = 0; - sprite->callback = CaveEntranceSpriteCallback2; + sprite->callback = SpriteCB_CaveEntranceOpen; } -static void CaveEntranceSpriteCallback2(struct Sprite *sprite) +static void SpriteCB_CaveEntranceOpen(struct Sprite *sprite) { if (sprite->data[0] < 40) { @@ -632,11 +636,11 @@ static void CaveEntranceSpriteCallback2(struct Sprite *sprite) else { sprite->data[0] = 0; - sprite->callback = CaveEntranceSpriteCallbackEnd; + sprite->callback = SpriteCB_CaveEntranceEnd; } } -static void CaveEntranceSpriteCallbackEnd(struct Sprite *sprite) +static void SpriteCB_CaveEntranceEnd(struct Sprite *sprite) { FieldEffectStop(sprite, FLDEFF_SECRET_POWER_CAVE); EnableBothScriptContexts(); @@ -676,7 +680,7 @@ bool8 FldEff_SecretPowerTree(void) AdjustSecretPowerSpritePixelOffsets(); - CreateSprite(&gUnknown_0858E618, + CreateSprite(&sSpriteTemplate_SecretPowerTree, gSprites[gPlayerAvatar.spriteId].oam.x + gFieldEffectArguments[5], gSprites[gPlayerAvatar.spriteId].oam.y + gFieldEffectArguments[6], 148); @@ -687,16 +691,16 @@ bool8 FldEff_SecretPowerTree(void) return FALSE; } -static void TreeEntranceSpriteCallback1(struct Sprite *sprite) +static void SpriteCB_TreeEntranceInit(struct Sprite *sprite) { PlaySE(SE_W010); sprite->animNum = gFieldEffectArguments[7]; sprite->data[0] = 0; - sprite->callback = TreeEntranceSpriteCallback2; + sprite->callback = SpriteCB_TreeEntranceOpen; } -static void TreeEntranceSpriteCallback2(struct Sprite *sprite) +static void SpriteCB_TreeEntranceOpen(struct Sprite *sprite) { sprite->data[0]++; @@ -706,11 +710,11 @@ static void TreeEntranceSpriteCallback2(struct Sprite *sprite) ToggleSecretBaseEntranceMetatile(); sprite->data[0] = 0; - sprite->callback = TreeEntranceSpriteCallbackEnd; + sprite->callback = SpriteCB_TreeEntranceEnd; } } -static void TreeEntranceSpriteCallbackEnd(struct Sprite *sprite) +static void SpriteCB_TreeEntranceEnd(struct Sprite *sprite) { FieldEffectStop(sprite, FLDEFF_SECRET_POWER_TREE); EnableBothScriptContexts(); @@ -742,7 +746,7 @@ bool8 FldEff_SecretPowerShrub(void) { AdjustSecretPowerSpritePixelOffsets(); - CreateSprite(&gUnknown_0858E630, + CreateSprite(&sSpriteTemplate_SecretPowerShrub, gSprites[gPlayerAvatar.spriteId].oam.x + gFieldEffectArguments[5], gSprites[gPlayerAvatar.spriteId].oam.y + gFieldEffectArguments[6], 148); @@ -750,15 +754,15 @@ bool8 FldEff_SecretPowerShrub(void) return FALSE; } -static void ShrubEntranceSpriteCallback1(struct Sprite *sprite) +static void SpriteCB_ShrubEntranceInit(struct Sprite *sprite) { PlaySE(SE_W077); sprite->data[0] = 0; - sprite->callback = ShrubEntranceSpriteCallback2; + sprite->callback = SpriteCB_ShrubEntranceOpen; } -static void ShrubEntranceSpriteCallback2(struct Sprite *sprite) +static void SpriteCB_ShrubEntranceOpen(struct Sprite *sprite) { if (sprite->data[0] < 40) { @@ -770,16 +774,20 @@ static void ShrubEntranceSpriteCallback2(struct Sprite *sprite) else { sprite->data[0] = 0; - sprite->callback = ShrubEntranceSpriteCallbackEnd; + sprite->callback = SpriteCB_ShrubEntranceEnd; } } -static void ShrubEntranceSpriteCallbackEnd(struct Sprite *sprite) +static void SpriteCB_ShrubEntranceEnd(struct Sprite *sprite) { FieldEffectStop(sprite, FLDEFF_SECRET_POWER_SHRUB); EnableBothScriptContexts(); } +#define tX data[0] +#define tY data[1] +#define tState data[2] + bool8 FldEff_SecretBasePCTurnOn(void) { s16 x, y; @@ -788,9 +796,9 @@ bool8 FldEff_SecretBasePCTurnOn(void) GetXYCoordsOneStepInFrontOfPlayer(&x, &y); taskId = CreateTask(Task_SecretBasePCTurnOn, 0); - gTasks[taskId].data[0] = x; - gTasks[taskId].data[1] = y; - gTasks[taskId].data[2] = 0; + gTasks[taskId].tX = x; + gTasks[taskId].tY = y; + gTasks[taskId].tState = 0; return FALSE; } @@ -799,30 +807,34 @@ static void Task_SecretBasePCTurnOn(u8 taskId) { s16 *data = gTasks[taskId].data; - switch (data[2]) + switch (tState) { case 4: case 12: - MapGridSetMetatileIdAt(data[0], data[1], METATILE_SecretBase_PC_On); - CurrentMapDrawMetatileAt(data[0], data[1]); + MapGridSetMetatileIdAt(tX, tY, METATILE_SecretBase_PC_On); + CurrentMapDrawMetatileAt(tX, tY); break; case 8: case 16: - MapGridSetMetatileIdAt(data[0], data[1], METATILE_SecretBase_PC); - CurrentMapDrawMetatileAt(data[0], data[1]); + MapGridSetMetatileIdAt(tX, tY, METATILE_SecretBase_PC); + CurrentMapDrawMetatileAt(tX, tY); break; case 20: - MapGridSetMetatileIdAt(data[0], data[1], METATILE_SecretBase_PC_On); - CurrentMapDrawMetatileAt(data[0], data[1]); + MapGridSetMetatileIdAt(tX, tY, METATILE_SecretBase_PC_On); + CurrentMapDrawMetatileAt(tX, tY); FieldEffectActiveListRemove(FLDEFF_PCTURN_ON); EnableBothScriptContexts(); DestroyTask(taskId); return; } - data[2]++; + tState++; } +#undef tX +#undef tY +#undef tState + void DoSecretBasePCTurnOffEffect(void) { s16 x, y; @@ -892,12 +904,12 @@ static void DoBalloonSoundEffect(s16 metatileId) } } -bool8 FldEff_NopA6FC(void) +bool8 FldEff_Nop47(void) { return FALSE; } -bool8 FldEff_NopA700(void) +bool8 FldEff_Nop48(void) { return FALSE; } @@ -1034,7 +1046,7 @@ bool8 FldEff_SandPillar(void) switch (GetPlayerFacingDirection()) { case DIR_SOUTH: - CreateSprite(&gUnknown_0858E68C, + CreateSprite(&sSpriteTemplate_SandPillar, gSprites[gPlayerAvatar.spriteId].oam.x + 8, gSprites[gPlayerAvatar.spriteId].oam.y + 32, 0); @@ -1042,7 +1054,7 @@ bool8 FldEff_SandPillar(void) break; case DIR_NORTH: - CreateSprite(&gUnknown_0858E68C, + CreateSprite(&sSpriteTemplate_SandPillar, gSprites[gPlayerAvatar.spriteId].oam.x + 8, gSprites[gPlayerAvatar.spriteId].oam.y, 148); @@ -1050,7 +1062,7 @@ bool8 FldEff_SandPillar(void) break; case DIR_WEST: - CreateSprite(&gUnknown_0858E68C, + CreateSprite(&sSpriteTemplate_SandPillar, gSprites[gPlayerAvatar.spriteId].oam.x - 8, gSprites[gPlayerAvatar.spriteId].oam.y + 16, 148); @@ -1058,7 +1070,7 @@ bool8 FldEff_SandPillar(void) break; case DIR_EAST: - CreateSprite(&gUnknown_0858E68C, + CreateSprite(&sSpriteTemplate_SandPillar, gSprites[gPlayerAvatar.spriteId].oam.x + 24, gSprites[gPlayerAvatar.spriteId].oam.y + 16, 148); @@ -1069,7 +1081,7 @@ bool8 FldEff_SandPillar(void) return FALSE; } -static void SpriteCB_SandPillar_0(struct Sprite *sprite) +static void SpriteCB_SandPillar_BreakTop(struct Sprite *sprite) { PlaySE(SE_W088); @@ -1083,10 +1095,10 @@ static void SpriteCB_SandPillar_0(struct Sprite *sprite) CurrentMapDrawMetatileAt(gFieldEffectArguments[5], gFieldEffectArguments[6]); sprite->data[0] = 0; - sprite->callback = SpriteCB_SandPillar_1; + sprite->callback = SpriteCB_SandPillar_BreakBase; } -static void SpriteCB_SandPillar_1(struct Sprite *sprite) +static void SpriteCB_SandPillar_BreakBase(struct Sprite *sprite) { if (sprite->data[0] < 18) { @@ -1097,11 +1109,11 @@ static void SpriteCB_SandPillar_1(struct Sprite *sprite) MapGridSetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6], METATILE_SecretBase_SandOrnament_BrokenBase | METATILE_COLLISION_MASK); CurrentMapDrawMetatileAt(gFieldEffectArguments[5], gFieldEffectArguments[6]); sprite->data[0] = 0; - sprite->callback = SpriteCB_SandPillar_2; + sprite->callback = SpriteCB_SandPillar_End; } } -static void SpriteCB_SandPillar_2(struct Sprite *sprite) +static void SpriteCB_SandPillar_End(struct Sprite *sprite) { FieldEffectStop(sprite, FLDEFF_SAND_PILLAR); EnableBothScriptContexts(); @@ -1167,12 +1179,13 @@ void InteractWithShieldOrTVDecoration(void) } } -bool8 sub_80FADE4(u16 metatileId, u8 arg1) +// As opposed to a small one (single metatile) like the balloons +bool8 IsLargeBreakableDecoration(u16 metatileId, bool8 checkBase) { if (!CurMapIsSecretBase()) return FALSE; - if (!arg1) + if (!checkBase) { if (metatileId == METATILE_SecretBase_SandOrnament_Top || metatileId == METATILE_SecretBase_SandOrnament_TopWall) return TRUE; @@ -1224,25 +1237,26 @@ bool32 FldEffPoison_IsActive(void) return FuncIsActiveTask(Task_FieldPoisonEffect); } -static void Task_WateringBerryTreeAnim_0(u8 taskId) +static void Task_WateringBerryTreeAnim(u8 taskId) { - gTasks[taskId].func = Task_WateringBerryTreeAnim_1; + gTasks[taskId].func = Task_WateringBerryTreeAnim_Start; } -static void Task_WateringBerryTreeAnim_1(u8 taskId) +static void Task_WateringBerryTreeAnim_Start(u8 taskId) { struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; if (!ObjectEventIsMovementOverridden(playerObjEvent) || ObjectEventClearHeldMovementIfFinished(playerObjEvent)) { + // Start watering SetPlayerAvatarWatering(GetPlayerFacingDirection()); ObjectEventSetHeldMovement(playerObjEvent, GetWalkInPlaceNormalMovementAction(GetPlayerFacingDirection())); - gTasks[taskId].func = Task_WateringBerryTreeAnim_2; + gTasks[taskId].func = Task_WateringBerryTreeAnim_Continue; } } -static void Task_WateringBerryTreeAnim_2(u8 taskId) +static void Task_WateringBerryTreeAnim_Continue(u8 taskId) { struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; @@ -1250,15 +1264,15 @@ static void Task_WateringBerryTreeAnim_2(u8 taskId) { s16 value = gTasks[taskId].data[1]++; + // Continue holding watering action 10 times, then end if (value < 10) ObjectEventSetHeldMovement(playerObjEvent, GetWalkInPlaceNormalMovementAction(GetPlayerFacingDirection())); - else - gTasks[taskId].func = Task_WateringBerryTreeAnim_3; + gTasks[taskId].func = Task_WateringBerryTreeAnim_End; } } -static void Task_WateringBerryTreeAnim_3(u8 taskId) +static void Task_WateringBerryTreeAnim_End(u8 taskId) { SetPlayerAvatarTransitionFlags(GetPlayerAvatarFlags()); DestroyTask(taskId); @@ -1267,16 +1281,17 @@ static void Task_WateringBerryTreeAnim_3(u8 taskId) void DoWateringBerryTreeAnim(void) { - CreateTask(Task_WateringBerryTreeAnim_0, 80); + CreateTask(Task_WateringBerryTreeAnim, 80); } -u8 CreateRecordMixingSprite(void) +// The lights that blink on the counter when mixing records in the cable club +u8 CreateRecordMixingLights(void) { u8 spriteId; - LoadSpritePalette(&gUnknown_0858E864); + LoadSpritePalette(&sSpritePalette_RecordMixLights); - spriteId = CreateSprite(&gUnknown_0858E880, 0, 0, 82); + spriteId = CreateSprite(&sSpriteTemplate_RecordMixLights, 0, 0, 82); if (spriteId == MAX_SPRITES) { @@ -1293,13 +1308,13 @@ u8 CreateRecordMixingSprite(void) return spriteId; } -void DestroyRecordMixingSprite(void) +void DestroyRecordMixingLights(void) { int i; for (i = 0; i < MAX_SPRITES; i++) { - if (gSprites[i].template == &gUnknown_0858E880) + if (gSprites[i].template == &sSpriteTemplate_RecordMixLights) { FreeSpritePalette(&gSprites[i]); DestroySprite(&gSprites[i]); diff --git a/src/fldeff_rocksmash.c b/src/fldeff_rocksmash.c index 4d7dcb66e..ec8e64012 100644 --- a/src/fldeff_rocksmash.c +++ b/src/fldeff_rocksmash.c @@ -20,13 +20,13 @@ #include "constants/songs.h" // static functions -static void Task_DoFieldMove_0(u8 taskId); -static void Task_DoFieldMove_1(u8 taskId); -static void Task_DoFieldMove_2(u8 taskId); -static void Task_DoFieldMove_3(u8 taskId); +static void Task_DoFieldMove_Init(u8 taskId); +static void Task_DoFieldMove_ShowMonAfterPose(u8 taskId); +static void Task_DoFieldMove_WaitForMon(u8 taskId); +static void Task_DoFieldMove_RunFunc(u8 taskId); static void FieldCallback_RockSmash(void); -static void sub_8135714(void); +static void FieldMove_RockSmash(void); // text bool8 CheckObjectGraphicsInFrontOfPlayer(u8 graphicsId) @@ -50,10 +50,10 @@ bool8 CheckObjectGraphicsInFrontOfPlayer(u8 graphicsId) u8 CreateFieldMoveTask(void) { GetXYCoordsOneStepInFrontOfPlayer(&gPlayerFacingPosition.x, &gPlayerFacingPosition.y); - return CreateTask(Task_DoFieldMove_0, 8); + return CreateTask(Task_DoFieldMove_Init, 8); } -static void Task_DoFieldMove_0(u8 taskId) +static void Task_DoFieldMove_Init(u8 taskId) { u8 objEventId; @@ -65,28 +65,30 @@ static void Task_DoFieldMove_0(u8 taskId) { if (gMapHeader.mapType == MAP_TYPE_UNDERWATER) { + // Skip field move pose underwater FieldEffectStart(FLDEFF_FIELD_MOVE_SHOW_MON_INIT); - gTasks[taskId].func = Task_DoFieldMove_2; + gTasks[taskId].func = Task_DoFieldMove_WaitForMon; } else { + // Do field move pose SetPlayerAvatarFieldMove(); ObjectEventSetHeldMovement(&gObjectEvents[objEventId], MOVEMENT_ACTION_START_ANIM_IN_DIRECTION); - gTasks[taskId].func = Task_DoFieldMove_1; + gTasks[taskId].func = Task_DoFieldMove_ShowMonAfterPose; } } } -static void Task_DoFieldMove_1(u8 taskId) +static void Task_DoFieldMove_ShowMonAfterPose(u8 taskId) { if (ObjectEventCheckHeldMovementStatus(&gObjectEvents[gPlayerAvatar.objectEventId]) == TRUE) { FieldEffectStart(FLDEFF_FIELD_MOVE_SHOW_MON_INIT); - gTasks[taskId].func = Task_DoFieldMove_2; + gTasks[taskId].func = Task_DoFieldMove_WaitForMon; } } -static void Task_DoFieldMove_2(u8 taskId) +static void Task_DoFieldMove_WaitForMon(u8 taskId) { if (!FieldEffectActiveListContains(FLDEFF_FIELD_MOVE_SHOW_MON)) { @@ -102,19 +104,22 @@ static void Task_DoFieldMove_2(u8 taskId) ObjectEventSetGraphicsId(&gObjectEvents[gPlayerAvatar.objectEventId], GetPlayerAvatarGraphicsIdByCurrentState()); StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], gFieldEffectArguments[2]); FieldEffectActiveListRemove(FLDEFF_FIELD_MOVE_SHOW_MON); - gTasks[taskId].func = Task_DoFieldMove_3; + gTasks[taskId].func = Task_DoFieldMove_RunFunc; } } -static void Task_DoFieldMove_3(u8 taskId) +static void Task_DoFieldMove_RunFunc(u8 taskId) { - void (*func)(void) = (void (*)(void))(((u16)gTasks[taskId].data[8] << 16) | (u16)gTasks[taskId].data[9]); + // The function for the field move to do is stored in halves across data[8] and data[9] + void (*fieldMoveFunc)(void) = (void (*)(void))(((u16)gTasks[taskId].data[8] << 16) | (u16)gTasks[taskId].data[9]); - func(); + fieldMoveFunc(); gPlayerAvatar.preventStep = FALSE; DestroyTask(taskId); } +// Called when Rock Smash is used from the party menu +// For interacting with a smashable rock in the field, see EventScript_RockSmash bool8 SetUpFieldMove_RockSmash(void) { // In Ruby and Sapphire, Regirock's tomb is opened by using Strength. In Emerald, @@ -141,20 +146,21 @@ bool8 SetUpFieldMove_RockSmash(void) static void FieldCallback_RockSmash(void) { gFieldEffectArguments[0] = GetCursorSelectionMonId(); - ScriptContext1_SetupScript(EventScript_FldEffRockSmash); + ScriptContext1_SetupScript(EventScript_RockSmashFromPartyMenu); } bool8 FldEff_UseRockSmash(void) { u8 taskId = CreateFieldMoveTask(); - gTasks[taskId].data[8] = (u32)sub_8135714 >> 16; - gTasks[taskId].data[9] = (u32)sub_8135714; + gTasks[taskId].data[8] = (u32)FieldMove_RockSmash >> 16; + gTasks[taskId].data[9] = (u32)FieldMove_RockSmash; IncrementGameStat(GAME_STAT_USED_ROCK_SMASH); return FALSE; } -static void sub_8135714(void) +// The actual rock smashing is handled by EventScript_SmashRock, so this function does very little +static void FieldMove_RockSmash(void) { PlaySE(SE_W088); FieldEffectActiveListRemove(FLDEFF_USE_ROCK_SMASH); diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 5405b7c42..b4745ff4e 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -799,7 +799,7 @@ void CB2_DoHallOfFamePC(void) { struct HallofFameTeam *fameTeam = (struct HallofFameTeam*)(gDecompressionBuffer); fameTeam->mon[0] = sDummyFameMon; - sub_80F9BCC(0, 0, 0); + ComputerScreenOpenEffect(0, 0, 0); SetVBlankCallback(VBlankCB_HallOfFame); gMain.state++; } @@ -809,7 +809,7 @@ void CB2_DoHallOfFamePC(void) AnimateSprites(); BuildOamBuffer(); UpdatePaletteFade(); - if (!sub_80F9C1C()) + if (!IsComputerScreenOpenEffectActive()) gMain.state++; break; case 5: @@ -1023,13 +1023,13 @@ static void Task_HofPC_HandlePaletteOnExit(u8 taskId) CpuCopy16(gPlttBufferFaded, gPlttBufferUnfaded, 0x400); fameTeam = (struct HallofFameTeam*)(gDecompressionBuffer); fameTeam->mon[0] = sDummyFameMon; - sub_80F9BF4(0, 0, 0); + ComputerScreenCloseEffect(0, 0, 0); gTasks[taskId].func = Task_HofPC_HandleExit; } static void Task_HofPC_HandleExit(u8 taskId) { - if (!sub_80F9C30()) + if (!IsComputerScreenCloseEffectActive()) { u8 i; diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 104f92c73..31cb47965 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -2360,11 +2360,11 @@ static void Cb_ShowPSS(u8 taskId) { case 0: PlaySE(SE_PC_LOGIN); - sub_80F9BCC(0x14, 0, 1); + ComputerScreenOpenEffect(20, 0, 1); sPSSData->state++; break; case 1: - if (!sub_80F9C1C()) + if (!IsComputerScreenOpenEffectActive()) SetPSSCallback(Cb_MainPSS); break; } @@ -3781,11 +3781,11 @@ static void Cb_OnCloseBoxPressed(u8 taskId) } break; case 3: - sub_80F9BF4(0x14, 0, 1); + ComputerScreenCloseEffect(20, 0, 1); sPSSData->state++; break; case 4: - if (!sub_80F9C30()) + if (!IsComputerScreenCloseEffectActive()) { sub_80CABE0(); gPlayerPartyCount = CalculatePlayerPartyCount(); @@ -3842,11 +3842,11 @@ static void Cb_OnBPressed(u8 taskId) } break; case 3: - sub_80F9BF4(0x14, 0, 0); + ComputerScreenCloseEffect(20, 0, 0); sPSSData->state++; break; case 4: - if (!sub_80F9C30()) + if (!IsComputerScreenCloseEffectActive()) { sub_80CABE0(); gPlayerPartyCount = CalculatePlayerPartyCount(); diff --git a/src/record_mixing.c b/src/record_mixing.c index 3a93d72f8..54b527216 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -327,7 +327,7 @@ static void Task_RecordMixing_Main(u8 taskId) VarSet(VAR_TEMP_0, 1); gUnknown_03001130 = FALSE; PrepareExchangePacket(); - CreateRecordMixingSprite(); + CreateRecordMixingLights(); tState = 1; data[10] = CreateTask(Task_MixingRecordsRecv, 80); tSndEffTaskId = CreateTask(Task_RecordMixing_SoundEffect, 81); @@ -337,7 +337,7 @@ static void Task_RecordMixing_Main(u8 taskId) { tState = 2; FlagSet(FLAG_SYS_MIX_RECORD); - DestroyRecordMixingSprite(); + DestroyRecordMixingLights(); DestroyTask(tSndEffTaskId); } break;