diff options
author | yenatch <yenatch@gmail.com> | 2017-03-22 02:01:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-22 02:01:55 -0400 |
commit | e3c26e52ae6ab881ade913ca1fad2cd9629bbcb1 (patch) | |
tree | 291912dbcf0f77d6c88b7e691efa18dcd9d4bc53 /src | |
parent | 515ae5e00f2661559583a4720d9944755e23d141 (diff) | |
parent | d507cdcebb39e2ec43c4d0f756570a5734fcb42e (diff) |
Merge pull request #241 from ProjectRevoTPP/master
decompile fldeff_cut.c, script_pokemon_util_80C4BF0.c, document save.c, move data to C files, decompile the next 3 functions in item_use.c, and a lot of labeling
Diffstat (limited to 'src')
49 files changed, 3327 insertions, 933 deletions
diff --git a/src/agb_flash.c b/src/agb_flash.c index 34fb4e84a..340d469a7 100644 --- a/src/agb_flash.c +++ b/src/agb_flash.c @@ -217,7 +217,7 @@ u32 VerifyFlashSector(u16 sectorNum, u8 *src) tgt = FLASH_BASE + (sectorNum << gFlash->sector.shift); size = gFlash->sector.size; - return verifyFlashSector_Core(src, tgt, size); + return verifyFlashSector_Core(src, tgt, size); // return 0 if verified. } u32 VerifyFlashSectorNBytes(u16 sectorNum, u8 *src, u32 n) @@ -256,12 +256,12 @@ u32 VerifyFlashSectorNBytes(u16 sectorNum, u8 *src, u32 n) return verifyFlashSector_Core(src, tgt, n); } -u32 ProgramFlashSectorAndVerify(u16 sectorNum, u8 *src) +u32 ProgramFlashSectorAndVerify(u16 sectorNum, u8 *src) // 3rd is unused { u8 i; u32 result; - for (i = 0; i < 3; i++) + for (i = 0; i < 3; i++) // 3 attempts { result = ProgramFlashSector(sectorNum, src); if (result != 0) @@ -272,7 +272,7 @@ u32 ProgramFlashSectorAndVerify(u16 sectorNum, u8 *src) break; } - return result; + return result; // return 0 if verified and programmed. } u32 ProgramFlashSectorAndVerifyNBytes(u16 sectorNum, u8 *src, u32 n) diff --git a/src/battle_ai.c b/src/battle_ai.c index ceab60ca0..07f319e40 100644 --- a/src/battle_ai.c +++ b/src/battle_ai.c @@ -8,29 +8,10 @@ #include "rng.h" #include "species.h" #include "moves.h" - -#define AIScriptRead32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24) -#define AIScriptRead16(ptr) ((ptr)[0] | (ptr)[1] << 8) -#define AIScriptRead8(ptr) ((ptr)[0]) -#define AIScriptReadPtr(ptr) (u8*) AIScriptRead32(ptr) +#include "battle_ai.h" extern void sub_801CAF8(u8, u8); -enum -{ - TARGET, - USER -}; - -// AI states -enum -{ - AIState_SettingUp, - AIState_Processing, - AIState_FinishedProcessing, - AIState_DoNotProcess -}; - extern void move_effectiveness_something(u16, u8, u8); extern u16 gBattleTypeFlags; @@ -283,12 +264,6 @@ const u16 sDiscouragedPowerfulMoveEffects[] = 0xFFFF }; -void BattleAI_SetupAIData(void); -void BattleAI_DoAIProcessing(void); -void sub_810745C(void); -void AIStackPushVar(u8 *); -u8 AIStackPop(void); - // if the AI is a Link battle, safari, battle tower, or ereader, it will ignore considering item uses. void BattleAI_HandleItemUseBeforeAISetup(void) { diff --git a/src/battle_anim.c b/src/battle_anim.c index 4cc337a0c..c381f4f87 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -6,55 +6,7 @@ #include "sound.h" #include "sprite.h" #include "task.h" - -#define SCRIPT_READ_8(ptr) ((ptr)[0]) -#define SCRIPT_READ_16(ptr) ((ptr)[0] | ((ptr)[1] << 8)) -#define SCRIPT_READ_32(ptr) ((ptr)[0] + ((ptr)[1] << 8) + ((ptr)[2] << 16) + ((ptr)[3] << 24)) - -#define REG_BGnCNT_BITFIELD(n) (*(struct BGCntrlBitfield *)REG_ADDR_BG##n##CNT) -#define REG_BG1CNT_BITFIELD REG_BGnCNT_BITFIELD(1) -#define REG_BG2CNT_BITFIELD REG_BGnCNT_BITFIELD(2) - -#define EWRAM_14800 ((u16 *)(unk_2000000 + 0x14800)) -#define EWRAM_17800 ((struct UnknownStruct1 *)(unk_2000000 + 0x17800)) -#define EWRAM_17810 ((struct UnknownStruct3 *)(unk_2000000 + 0x17810)) -#define EWRAM_18000 ((u16 *)(unk_2000000 + 0x18000)) -#define EWRAM_19348 (*(u16 *)(unk_2000000 + 0x19348)) - -struct BGCntrlBitfield -{ - volatile u16 priority:2; - volatile u16 charBaseBlock:2; - volatile u16 field_0_2:4; - volatile u16 field_1_0:5; - volatile u16 areaOverflowMode:1; - volatile u16 screenSize:2; -}; - -struct BattleAnimBackground -{ - void *image; - void *palette; - void *tilemap; -}; - -struct UnknownStruct1 -{ - u8 unk0; -}; - -struct UnknownStruct2 -{ - void *unk0; - u16 *unk4; - u8 unk8; -}; - -struct UnknownStruct3 -{ - u8 unk0; - u8 filler1[0xB]; -}; +#include "battle_anim.h" extern u8 unk_2000000[]; extern u16 gUnknown_02024A6A[4]; @@ -117,7 +69,6 @@ extern void sub_800D7B8(void); extern u8 obj_id_for_side_relative_to_move(); extern u8 battle_get_per_side_status_permutated(); -void move_something(const u8 *const moveAnims[], u16 b, u8 c); static void sub_80759D0(void); static void ScriptCmd_loadsprite(void); static void ScriptCmd_unloadsprite(void); @@ -130,8 +81,6 @@ static void ScriptCmd_hang2(void); static void ScriptCmd_end(void); static void ScriptCmd_playse(void); static void ScriptCmd_monbg(void); -bool8 b_side_obj__get_some_boolean(u8 a); -void sub_8076034(u8, u8); static void sub_8076380(void); static void task_pA_ma0A_obj_to_bg_pal(u8); static void ScriptCmd_clearmonbg(void); @@ -148,7 +97,6 @@ static void ScriptCmd_setvar(void); static void ScriptCmd_ifelse(void); static void ScriptCmd_jumpif(void); static void ScriptCmd_jump(void); -bool8 sub_8076BE0(void); static void ScriptCmd_fadetobg(void); static void ScriptCmd_fadetobg_25(void); static void task_p5_load_battle_screen_elements(u8); diff --git a/src/battle_anim_80A7E7C.c b/src/battle_anim_80A7E7C.c index 8cb6fdf9c..474d268a0 100644 --- a/src/battle_anim_80A7E7C.c +++ b/src/battle_anim_80A7E7C.c @@ -2,6 +2,7 @@ #include "sprite.h" #include "task.h" #include "trig.h" +#include "battle_anim.h" #define TASK gTasks[task] #define SPRITE gSprites[TASK.data[0]] @@ -16,7 +17,6 @@ extern u8 gUnknown_0202F7C9; extern u8 obj_id_for_side_relative_to_move(u8 side); extern void move_anim_task_del(u8 task); -extern bool8 b_side_obj__get_some_boolean(u8 side); extern u8 battle_get_side_with_given_state(u8 state); extern u8 battle_side_get_owner(u8 side); extern void oamt_set_x3A_32(struct Sprite *sprite, void(*callback)(struct Sprite*)); @@ -27,7 +27,6 @@ extern void sub_80784A8(struct Sprite *sprite); extern void sub_8078E70(u8 sprite, u8); extern void obj_id_set_rotscale(u8 sprite, int, int, u16); extern void sub_8078F40(u8 sprite); -extern bool8 sub_8076BE0(); extern void sub_8078F9C(u8 sprite); static void sub_80A7EF0(u8 task); diff --git a/src/battle_party_menu.c b/src/battle_party_menu.c index dab97db9b..2d47f4e7d 100644 --- a/src/battle_party_menu.c +++ b/src/battle_party_menu.c @@ -11,19 +11,6 @@ #include "text.h" #include "battle_party_menu.h" -struct PartyMenuItem -{ - const u8 *text; - TaskFunc func; -}; - -struct PartyPopupMenu -{ - u8 unk0; - u8 unk1; - const u8 *unk4; -}; - extern u8 IsLinkDoubleBattle(void); extern void TryCreatePartyMenuMonIcon(u8, u8, struct Pokemon *); extern void LoadHeldItemIconGraphics(void); diff --git a/src/battle_setup.c b/src/battle_setup.c index 858b6cca1..c9839bb87 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -23,61 +23,12 @@ #include "weather.h" #include "map_constants.h" #include "opponent_constants.h" - -#define NUM_TRAINER_EYE_TRAINERS 56 -#define TRAINER_REMATCH_STEPS 255 +#include "script_pokemon_80C4.h" +#include "field_map_obj_helpers.h" +#include "field_control_avatar.h" extern u16 gScriptResult; -// IV + LEVEL + SPECIES -struct TrainerPartyMember0 -{ - u16 iv; - u8 level; - u16 species; -}; - -// IV + LEVEL + SPECIES + MOVES -struct TrainerPartyMember1 -{ - u16 iv; - u8 level; - u16 species; - u16 moves[4]; -}; - -// IV + LEVEL + SPECIES + ITEMS -struct TrainerPartyMember2 -{ - u16 iv; - u8 level; - u16 species; - u16 heldItem; -}; - -// IV + LEVEL + SPECIES + ITEMS + MOVES -struct TrainerPartyMember3 -{ - u16 iv; - u8 level; - u16 species; - u16 heldItem; - u16 moves[4]; -}; - -struct TrainerBattleSpec -{ - void *ptr; - u8 ptrType; -}; - -struct TrainerEyeTrainer -{ - u16 trainerNums[5]; - u16 mapGroup; - u16 mapNum; -}; - extern void (*gUnknown_0300485C)(void); extern struct Pokemon gEnemyParty[]; @@ -1158,7 +1109,7 @@ u8 *sub_8082700(void) return gUnknown_081C6C02; } -void sub_8082718() +void sub_8082718(void) { ShowFieldMessage(sub_8082880()); } diff --git a/src/berry.c b/src/berry.c index 2f8f6a799..e81c7a5ff 100644 --- a/src/berry.c +++ b/src/berry.c @@ -6,6 +6,7 @@ #include "main.h" #include "rng.h" #include "text.h" +#include "field_control_avatar.h" #define BERRY_NAME_LENGTH 6 diff --git a/src/bike.c b/src/bike.c index a1a3fded9..7693c7539 100644 --- a/src/bike.c +++ b/src/bike.c @@ -8,20 +8,10 @@ #include "songs.h" #include "sound.h" #include "rom4.h" +#include "bike.h" extern u8 sub_80608A4(u8); -struct UnknownStruct1 -{ - u32 unk0; - u32 unk4; - u32 unk8; - u32 unkC; - const u8 *unk10; - const u8 *unk14; - u32 unk18; -}; - extern u8 gUnknown_02039250; extern u8 gUnknown_02039251; extern u8 gUnknown_0202E854; @@ -84,36 +74,6 @@ static void (*const gUnknown_083DB5A4[])(u8) = sub_80593F4, }; -// Player speeds -enum -{ - SPEED_STANDING, - SPEED_NORMAL, - SPEED_FAST, - SPEED_FASTER, - SPEED_FASTEST, -}; - -//Acro bike states -enum -{ - ACRO_STATE_NORMAL, - ACRO_STATE_TURNING, - ACRO_STATE_WHEELIE_STANDING, - ACRO_STATE_BUNNY_HOP, - ACRO_STATE_WHEELIE_MOVING, - ACRO_STATE_5, - ACRO_STATE_6, -}; - -//Acro bike transitions -enum -{ - ACRO_TRANS_FACE_DIRECTION, - ACRO_TRANS_NORMAL_TO_WHEELIE = 3, - ACRO_TRANS_WHEELIE_TO_NORMAL, -}; - static void (*const sAcroBikeTransitions[])(u8) = { AcroBikeTransition_FaceDirection, diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c index 8bbd1ce13..94643691c 100644 --- a/src/braille_puzzles.c +++ b/src/braille_puzzles.c @@ -12,19 +12,15 @@ #include "species.h" #include "task.h" #include "text.h" +#include "braille_puzzles.h" +#include "rom6.h" extern u8 gPlayerPartyCount; -extern u8 gUnknown_03005CE0; +extern u8 gLastFieldPokeMenuOpened; extern u32 gUnknown_0202FF84[]; -extern u8 gUnknown_0815EF19[]; - -void UseFlyAncientTomb_Callback(void); -void UseFlyAncientTomb_Finish(void); -void Task_BrailleWait(u8 taskId); -bool32 BrailleWait_CheckButtonPress(void); -void SealedChamberShakingEffect(u8 taskId); +extern u8 gIslandCave_EventScript_OpenRegiiceChamber[]; // regiice event script bool8 ShouldDoBrailleDigEffect(void) { @@ -110,7 +106,7 @@ bool8 ShouldDoBrailleFlyEffect(void) void DoBrailleFlyEffect(void) { - gUnknown_0202FF84[0] = gUnknown_03005CE0; + gUnknown_0202FF84[0] = gLastFieldPokeMenuOpened; FieldEffectStart(0x3C); } @@ -196,7 +192,7 @@ void Task_BrailleWait(u8 taskId) break; case 4: sub_8064E2C(); - ScriptContext1_SetupScript(gUnknown_0815EF19); + ScriptContext1_SetupScript(gIslandCave_EventScript_OpenRegiiceChamber); DestroyTask(taskId); break; } diff --git a/src/clock.c b/src/clock.c index 85188cd19..fd9e6915a 100644 --- a/src/clock.c +++ b/src/clock.c @@ -6,6 +6,7 @@ #include "rom4.h" #include "rtc.h" #include "wallclock.h" +#include "clock.h" extern void sub_80FA220(u16); extern void sub_80BE8C4(u16); diff --git a/src/contest_painting.c b/src/contest_painting.c index 556456814..41f6afabf 100644 --- a/src/contest_painting.c +++ b/src/contest_painting.c @@ -8,91 +8,21 @@ #include "sprite.h" #include "string_util.h" #include "text.h" - -#define MOSAIC_BIT_BG_HSIZE (0) -#define MOSAIC_BIT_BG_VSIZE (4) -#define MOSAIC_BIT_OBJ_HSIZE (8) -#define MOSAIC_BIT_OBJ_VSIZE (12) - -enum -{ - CONTEST_COOL, - CONTEST_BEAUTY, - CONTEST_CUTE, - CONTEST_SMART, - CONTEST_TOUGH, -}; - -enum -{ - CONTESTRESULT_COOL = 9, - CONTESTRESULT_BEAUTY = 13, - CONTESTRESULT_CUTE = 2, - CONTESTRESULT_SMART = 36, - CONTESTRESULT_TOUGH = 6, -}; - -struct Unk2015E00 -{ - u16 unk2015e00[128][32]; - u16 unk2017e00[0]; -}; - -struct ContestEntry -{ - /*0x00*/ u8 var0; - /*0x04*/ u32 var4; - /*0x08*/ u16 var8; - /*0x0A*/ u8 contestType; - /*0x0B*/ u8 pokemon_name[POKEMON_NAME_LENGTH]; - /*0x15*/ u8 pad15; - /*0x16*/ u8 trainer_name[OT_NAME_LENGTH]; -}; - -struct Unk3000756 -{ - /*0x00*/ u8 var_0; -}; - -struct LabelPair -{ - const u8 *prefix; - const u8 *suffix; -}; - -struct Unk03005E20 -{ - u8 var_0; - u8 pad1[3]; - u16 (*var_4)[][32]; - u16 (*var_8)[]; - u8 pad0C[4]; - u32 var_10; - u16 var_14; - u16 var_16; - u8 var_18; - u8 var_19; - u8 var_1A; - u8 var_1B; - u8 var_1C; - u8 var_1D; - u8 var_1E; - u8 var_1F; -}; +#include "contest_painting.h" extern u8 unk_2000000[]; -extern struct ContestEntry unk_2015de0; -extern struct Unk2015E00 unk_2015e00; extern u8 gUnknown_03000750; extern u16 gUnknown_03000752; extern u16 gUnknown_03000754; -extern struct Unk3000756 gUnknown_03000756; extern u16 (*gUnknown_03005E10)[][32]; -extern struct Unk03005E20 gUnknown_03005E20; extern u8 gUnknown_03005E40[]; -extern struct ContestEntry *gUnknown_03005E8C; extern u16 (*gUnknown_03005E90)[]; +extern struct ContestEntry unk_2015de0; +extern struct Unk2015E00 unk_2015e00; +extern struct Unk3000756 gUnknown_03000756; +extern struct Unk03005E20 gUnknown_03005E20; +extern struct ContestEntry *gUnknown_03005E8C; extern const struct SpriteSheet gMonFrontPicTable[]; extern const struct MonCoords gMonFrontPicCoords[]; extern const struct SpriteSheet gMonBackPicTable[]; @@ -112,7 +42,7 @@ extern const u8 OtherText_Terminator8[]; extern const u8 OtherText_CenturyLastVenus[]; extern const u8 OtherText_Terminator9[]; extern const u8 OtherText_Terminator10[]; -extern const u8 OtherText_DazzlingSlime[]; +extern const u8 OtherText_DazzlingSmile[]; extern const u8 OtherText_PokeCenterIdol[]; extern const u8 OtherText_Terminator11[]; extern const u8 OtherText_LovelyAndSweet[]; @@ -174,7 +104,7 @@ const struct LabelPair gUnknown_083F60C0[] = {OtherText_GoodLookingPoke, OtherText_Terminator7}, {OtherText_MarvelousGreat, OtherText_Terminator8}, {OtherText_CenturyLastVenus, OtherText_Terminator9}, - {OtherText_Terminator10, OtherText_DazzlingSlime}, + {OtherText_Terminator10, OtherText_DazzlingSmile}, {OtherText_PokeCenterIdol, OtherText_Terminator11}, {OtherText_LovelyAndSweet, OtherText_Terminator12}, {OtherText_ThePretty, OtherText_WinningPortrait}, diff --git a/src/dewford_trend.c b/src/dewford_trend.c index 751d6c416..b2a8e81da 100644 --- a/src/dewford_trend.c +++ b/src/dewford_trend.c @@ -4,12 +4,10 @@ #include "link.h" #include "rng.h" #include "text.h" +#include "dewford_trend.h" extern u8 unk_2000000[]; -#define ARRAY_2007800 ((struct EasyChatPair *)(unk_2000000 + 0x7800)) -#define ARRAY_2007900 ((struct EasyChatPair *)(unk_2000000 + 0x7900)) - extern u16 gScriptResult; extern u16 gSpecialVar_0x8004; diff --git a/src/diploma.c b/src/diploma.c index 270d69ce1..649f4a33d 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -10,9 +10,6 @@ #include "task.h" #include "text.h" -extern u8 gDiplomaTiles[]; -extern u8 gDiplomaTilemap[]; -extern u8 gDiplomaPalettes[]; extern u8 gOtherText_NationalDex[]; extern u8 gOtherText_HoennDex[]; extern u8 gOtherText_DiplomaCertificationGameFreak[]; @@ -24,6 +21,15 @@ static void Task_DiplomaWaitForKeyPress(u8); static void Task_DiplomaFadeOut(u8); static void DisplayDiplomaText(void); +static const u16 gDiplomaPalettes[][16] = +{ + INCBIN_U16("graphics/misc/diploma_national.gbapal"), + INCBIN_U16("graphics/misc/diploma_hoenn.gbapal"), +}; + +static const u8 gDiplomaTilemap[] = INCBIN_U8("graphics/misc/diploma_map.bin.lz"); +static const u8 gDiplomaTiles[] = INCBIN_U8("graphics/misc/diploma.4bpp.lz"); + static void VBlankCB(void) { LoadOam(); diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 992e461eb..9bff65004 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -13,6 +13,8 @@ #include "trainer_see.h" #include "vars.h" #include "wild_encounter.h" +#include "bike.h" +#include "field_control_avatar.h" struct Coords32 { @@ -336,13 +338,13 @@ static u8 *TryGetInvisibleMapObjectScript(struct MapPosition *position, u8 unuse if (bgEvent == NULL) return NULL; - if (bgEvent->script == NULL) + if (bgEvent->bgUnion.script == NULL) return gUnknown_081C6C02; switch (bgEvent->kind) { case 0: default: - return bgEvent->script; + return bgEvent->bgUnion.script; case 1: if (c != 2) return NULL; @@ -362,21 +364,21 @@ static u8 *TryGetInvisibleMapObjectScript(struct MapPosition *position, u8 unuse case 5: case 6: case 7: - gSpecialVar_0x8004 = ((u32)bgEvent->script >> 16) + 0x258; - gSpecialVar_0x8005 = (u32)bgEvent->script; + gSpecialVar_0x8004 = ((u32)bgEvent->bgUnion.script >> 16) + 0x258; + gSpecialVar_0x8005 = (u32)bgEvent->bgUnion.script; if (FlagGet(gSpecialVar_0x8004) == TRUE) return NULL; return HiddenItemScript; case 8: if (c == 2) { - gSpecialVar_0x8004 = (u32)bgEvent->script; + gSpecialVar_0x8004 = (u32)bgEvent->bgUnion.script; if (sub_80BC050()) return gUnknown_081A2C51; } return NULL; } - return bgEvent->script; + return bgEvent->bgUnion.script; } static u8 *sub_8068500(struct MapPosition *position, u8 b, u8 c) diff --git a/src/field_door.c b/src/field_door.c index f527681ac..4b1390d11 100644 --- a/src/field_door.c +++ b/src/field_door.c @@ -3,20 +3,7 @@ #include "field_camera.h" #include "metatile_behavior.h" #include "task.h" - -struct DoorGraphics -{ - u16 metatileNum; - u8 unk2; - void *tiles; - void *palette; -}; - -struct DoorAnimFrame -{ - u8 time; - u16 offset; -}; +#include "field_door.h" extern struct DoorAnimFrame gDoorOpenAnimFrames[]; extern struct DoorAnimFrame gDoorCloseAnimFrames[]; diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index d52a68271..53bbf013b 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -16,19 +16,15 @@ #include "task.h" #include "wild_encounter.h" #include "map_object_constants.h" +#include "bike.h" +#include "field_map_obj_helpers.h" extern u8 gOtherText_OhABite[]; extern u8 gOtherText_PokeOnHook[]; extern u8 gOtherText_NotEvenANibble[]; extern u8 gOtherText_ItGotAway[]; -extern struct -{ - s32 x; - s32 y; - u32 unk8; - u32 unkC; -} gUnknown_0202FF84; +extern u32 gUnknown_0202FF84[]; //Functions static u32 sub_80587D8(void); @@ -731,9 +727,9 @@ void PlayerAvatarTransition_Surfing(struct MapObject *a) sub_805B980(a, GetPlayerAvatarGraphicsIdByStateId(3)); FieldObjectTurn(a, a->placeholder18); SetPlayerAvatarStateMask(8); - gUnknown_0202FF84.x = a->coords2.x; - gUnknown_0202FF84.y = a->coords2.y; - gUnknown_0202FF84.unk8 = gPlayerAvatar.mapObjectId; + gUnknown_0202FF84[0] = a->coords2.x; + gUnknown_0202FF84[1] = a->coords2.y; + gUnknown_0202FF84[2] = gPlayerAvatar.mapObjectId; unk = FieldEffectStart(8); a->mapobj_unk_1A = unk; sub_8127ED0(unk, 1); @@ -1291,10 +1287,10 @@ u8 sub_8059EA4(struct Task *task, struct MapObject *b, struct MapObject *c) FieldObjectClearAnimIfSpecialAnimFinished(c); FieldObjectSetSpecialAnim(b, GetStepInPlaceDelay16AnimId(task->data[2])); FieldObjectSetSpecialAnim(c, GetSimpleGoAnimId(task->data[2])); - gUnknown_0202FF84.x = c->coords2.x; - gUnknown_0202FF84.y = c->coords2.y; - gUnknown_0202FF84.unk8 = c->elevation; - gUnknown_0202FF84.unkC = gSprites[c->spriteId].oam.priority; + gUnknown_0202FF84[0] = c->coords2.x; + gUnknown_0202FF84[1] = c->coords2.y; + gUnknown_0202FF84[2] = c->elevation; + gUnknown_0202FF84[3] = gSprites[c->spriteId].oam.priority; FieldEffectStart(10); PlaySE(SE_W070); task->data[0]++; diff --git a/src/field_special_scene.c b/src/field_special_scene.c index 819a4ab5f..fe7daea0a 100644 --- a/src/field_special_scene.c +++ b/src/field_special_scene.c @@ -11,6 +11,17 @@ #include "sprite.h" #include "task.h" +#define SECONDS(value) ((signed) (60.0 * value + 0.5)) + +// porthole states +enum +{ + INIT_PORTHOLE, + IDLE_CHECK, + EXECUTE_MOVEMENT, + EXIT_PORTHOLE, +}; + extern s8 gTruckCamera_HorizontalTable[]; extern u8 gUnknown_083D295F[]; @@ -44,20 +55,18 @@ void Task_Truck1(u8 taskId) u8 mapNum, mapGroup; register s16 zero asm("r4"); - box1 = GetTruckBoxMovement(data[0] + 30) * 4; // box 1 happens 30 frames earlier than the other 2. + box1 = GetTruckBoxMovement(data[0] + 30) * 4; // top box. sub_805BD90(1, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 3, box1 + 3); - box2 = GetTruckBoxMovement(data[0]) * 2; + box2 = GetTruckBoxMovement(data[0]) * 2; // bottom left box. sub_805BD90(2, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 0, box2 - 3); - box3 = GetTruckBoxMovement(data[0]) * 4; + box3 = GetTruckBoxMovement(data[0]) * 4; // bottom right box. mapNum = gSaveBlock1.location.mapNum; mapGroup = gSaveBlock1.location.mapGroup; zero = 0; sub_805BD90(3, mapNum, mapGroup, -3, box3); - data[0]++; - - if (data[0] == 0x7530) // timer? - data[0] = zero; + if (++data[0] == SECONDS(500)) // this will never run + data[0] = zero; // reset the timer if it gets stuck. cameraYpan = GetTruckCameraBobbingY(data[0]); SetCameraPanning(0, cameraYpan); @@ -142,7 +151,7 @@ void Task_HandleTruckSequence(u8 taskId) */ case 0: data[1]++; - if (data[1] == 90) + if (data[1] == SECONDS(1.5)) { SetCameraPanningCallback(0); data[1] = 0; // reset the timer. @@ -153,7 +162,7 @@ void Task_HandleTruckSequence(u8 taskId) break; case 1: data[1]++; - if (data[1] == 150) + if (data[1] == SECONDS(2.5)) { pal_fill_black(); data[1] = 0; @@ -162,7 +171,7 @@ void Task_HandleTruckSequence(u8 taskId) break; case 2: data[1]++; - if (!gPaletteFade.active && data[1] > 300) + if (!gPaletteFade.active && data[1] > SECONDS(5)) { data[1] = 0; DestroyTask(data[2]); @@ -241,22 +250,22 @@ bool8 sub_80C7754(void) } } -void sub_80C77A0(u8 taskId) +void Task_HandlePorthole(u8 taskId) { s16 *data = gTasks[taskId].data; - u16 *var = GetVarPointer(0x40B4); + u16 *var = GetVarPointer(VAR_PORTHOLE); struct WarpData *location = &gSaveBlock1.location; switch (data[0]) { - case 0: + case INIT_PORTHOLE: // finish fading before making porthole finish. if (!gPaletteFade.active) { data[1] = 0; - data[0] = 2; + data[0] = EXECUTE_MOVEMENT; // execute movement before checking if should be exited. strange? } break; - case 1: + case IDLE_CHECK: // idle and move. if (gMain.newKeys & A_BUTTON) data[1] = 1; if (!sub_80A212C(0xFF, location->mapNum, location->mapGroup)) @@ -271,25 +280,25 @@ void sub_80C77A0(u8 taskId) return; } data[0] = 2; - case 2: + case EXECUTE_MOVEMENT: // execute movement. if (data[1]) { - data[0] = 3; + data[0] = EXIT_PORTHOLE; // exit porthole. return; } - - if (*var == 2) + // run this once. + if (*var == 2) // which direction? { exec_movement(0xFF, location->mapNum, location->mapGroup, gUnknown_083D295F); - data[0] = 1; + data[0] = IDLE_CHECK; // run case 1. } else { exec_movement(0xFF, location->mapNum, location->mapGroup, gUnknown_083D2961); - data[0] = 1; + data[0] = IDLE_CHECK; // run case 1. } break; - case 3: + case EXIT_PORTHOLE: // exit porthole. FlagReset(0x4001); FlagReset(0x4000); copy_saved_warp2_bank_and_enter_x_to_warp1(0); @@ -320,7 +329,7 @@ void sub_80C791C(void) sub_80C78A0(); gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_13 = TRUE; pal_fill_black(); - CreateTask(sub_80C77A0, 80); + CreateTask(Task_HandlePorthole, 80); ScriptContext2_Enable(); } diff --git a/src/fieldmap.c b/src/fieldmap.c index 7a24897c4..b34a51bdc 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -1,5 +1,6 @@ #include "global.h" #include "palette.h" +#include "fieldmap.h" struct BackupMapData { diff --git a/src/fldeff_cut.c b/src/fldeff_cut.c new file mode 100644 index 000000000..f432027ab --- /dev/null +++ b/src/fldeff_cut.c @@ -0,0 +1,300 @@ +#include "global.h" +#include "asm.h" +#include "metatile_behavior.h" +#include "metatile_behaviors.h" +#include "field_player_avatar.h" +#include "field_effect.h" +#include "rom4.h" +#include "script.h" +#include "rom6.h" +#include "sound.h" +#include "field_camera.h" +#include "sprite.h" +#include "songs.h" +#include "trig.h" +#include "map_obj_lock.h" + +extern u8 gCutGrassSpriteArray[8]; // seems to be an array of 8 sprite IDs + +extern void (*gUnknown_0300485C)(void); +extern void (*gUnknown_03005CE4)(void); + +extern struct SpriteTemplate gSpriteTemplate_CutGrass; + +extern struct MapPosition gUnknown_0203923C; + +extern u8 gLastFieldPokeMenuOpened; +extern u32 gUnknown_0202FF84[]; + +extern u8 UseCutScript; + +extern void sub_808AB90(void); // unknown args +extern void sub_805BCC0(s16 x, s16 y); + +void sub_80A2634(void); +void sub_80A25E8(void); +void sub_80A2684(void); +void sub_80A27A8(s16, s16); +void sub_80A28F4(s16, s16); +void objc_8097BBC(struct Sprite *sprite); +void sub_80A2AB8(void); +void sub_80A2B00(void); // unknown args + +bool8 SetUpFieldMove_Cut(void) +{ + s16 x, y; + u8 i, j; + u8 tileBehavior; + + if(npc_before_player_of_type(0x52) == TRUE) // is in front of tree? + { + gUnknown_0300485C = sub_808AB90; + gUnknown_03005CE4 = sub_80A2634; + return TRUE; + } + else // is in ash or grass to cut? + { + PlayerGetDestCoords(&gUnknown_0203923C.x, &gUnknown_0203923C.y); + for(i = 0; i < 3; i++) + { + y = i - 1 + gUnknown_0203923C.y; + for(j = 0; j < 3; j++) + { + x = j - 1 + gUnknown_0203923C.x; + if(MapGridGetZCoordAt(x, y) == (s8)gUnknown_0203923C.height) + { + tileBehavior = MapGridGetMetatileBehaviorAt(x, y); + if(MetatileBehavior_IsPokeGrass(tileBehavior) == TRUE + || MetatileBehavior_IsAshGrass(tileBehavior) == TRUE) + { + gUnknown_0300485C = sub_808AB90; + gUnknown_03005CE4 = sub_80A25E8; + return TRUE; + } + } + } + } + return FALSE; // do not use cut + } +} + +void sub_80A25E8(void) +{ + FieldEffectStart(1); + gUnknown_0202FF84[0] = gLastFieldPokeMenuOpened; +} + +bool8 FldEff_UseCutOnGrass(void) +{ + u8 taskId = oei_task_add(); + + gTasks[taskId].data[8] = (u32)sub_80A2684 >> 16; + gTasks[taskId].data[9] = (u32)sub_80A2684; + IncrementGameStat(0x12); + return FALSE; +} + +void sub_80A2634(void) +{ + gUnknown_0202FF84[0] = gLastFieldPokeMenuOpened; + ScriptContext1_SetupScript(&UseCutScript); +} + +bool8 FldEff_UseCutOnTree(void) +{ + u8 taskId = oei_task_add(); + + gTasks[taskId].data[8] = (u32)sub_80A2B00 >> 16; + gTasks[taskId].data[9] = (u32)sub_80A2B00; + IncrementGameStat(0x12); + return FALSE; +} + +void sub_80A2684(void) +{ + FieldEffectActiveListRemove(1); + FieldEffectStart(0x3A); +} + +bool8 FldEff_CutGrass(void) +{ + s16 x, y; + u8 tileBehavior; + u8 i, j; // not in for loop? + + for(i = 0, PlaySE(SE_W015), PlayerGetDestCoords(&gUnknown_0203923C.x, &gUnknown_0203923C.y); i < 3; i++) + { + y = i - 1 + gUnknown_0203923C.y; + for(j = 0; j < 3; j++) + { + x = j - 1 + gUnknown_0203923C.x; + if(MapGridGetZCoordAt(x, y) == (s8)gUnknown_0203923C.height) + { + tileBehavior = MapGridGetMetatileBehaviorAt(x, y); + if(MetatileBehavior_IsCuttableGrass(tileBehavior) == TRUE) + { + sub_80A27A8(x, y); + sub_805BCC0(x, y); + } + } + } + } + sub_80A28F4(gUnknown_0203923C.x - 1, gUnknown_0203923C.y - 2); + DrawWholeMapView(); + + // populate sprite ID array + for(i = 0; i < 8; i++) + { + gCutGrassSpriteArray[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; + } + return 0; +} + +// set map grid metatile depending on x, y +// TODO: enum for metatile IDs +void sub_80A27A8(s16 x, s16 y) +{ + int metatileId = MapGridGetMetatileIdAt(x, y); + + switch(metatileId) + { + case 0x208: + case 0x15: + case 0xD: + MapGridSetMetatileIdAt(x, y, 0x1); + break; + case 0x1C6: + MapGridSetMetatileIdAt(x, y, 0x1CE); + break; + case 0x1C7: + MapGridSetMetatileIdAt(x, y, 0x1CF); + break; + case 0x281: + MapGridSetMetatileIdAt(x, y, 0x279); + break; + case 0x282: + MapGridSetMetatileIdAt(x, y, 0x27A); + break; + case 0x283: + MapGridSetMetatileIdAt(x, y, 0x27B); + break; + case 0x206: + case 0x207: + MapGridSetMetatileIdAt(x, y, 0x271); + break; + case 0x212: + case 0x20A: + MapGridSetMetatileIdAt(x, y, 0x218); + break; + case 0x25: + MapGridSetMetatileIdAt(x, y, 0xE); + break; + } +} + +s32 sub_80A28A0(s16 x, s16 y) +{ + u16 metatileId = MapGridGetMetatileIdAt(x, y); + + if(metatileId == 1) + return 1; + else if(metatileId == 633) + return 2; + else if(metatileId == 634) + return 3; + else if(metatileId == 635) + return 4; + else + return 0; +} + +void sub_80A28F4(s16 x, s16 y) +{ + s16 i; + u16 lowerY = y + 3; + + for(i = 0; i < 3; i++) + { + u16 currentX = x + i; + s16 currentXsigned = x + i; + if(MapGridGetMetatileIdAt(currentXsigned, y) == 21) + { + switch((u8)sub_80A28A0(currentXsigned, y + 1)) + { + case 1: + MapGridSetMetatileIdAt(currentXsigned, y + 1, 0x208); + break; + case 2: + MapGridSetMetatileIdAt(currentXsigned, y + 1, 0x281); + break; + case 3: + MapGridSetMetatileIdAt(currentXsigned, y + 1, 0x282); + break; + case 4: + MapGridSetMetatileIdAt(currentXsigned, y + 1, 0x283); + break; + } + } + if(MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY) == 1) + { + if(MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY + 1) == 0x208) + MapGridSetMetatileIdAt((s16)currentX, (s16)lowerY + 1, 0x1); + if(MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY + 1) == 0x281) + MapGridSetMetatileIdAt((s16)currentX, (s16)lowerY + 1, 0x279); + if(MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY + 1) == 0x282) + MapGridSetMetatileIdAt((s16)currentX, (s16)lowerY + 1, 0x27A); + if(MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY + 1) == 0x283) + MapGridSetMetatileIdAt((s16)currentX, (s16)lowerY + 1, 0x27B); + } + } +} + +void sub_80A2A48(struct Sprite *sprite) +{ + sprite->data0 = 8; + sprite->data1 = 0; + sprite->data3 = 0; + sprite->callback = (void *)objc_8097BBC; +} + +void objc_8097BBC(struct Sprite *sprite) +{ + u16 tempdata; + u16 tempdata2; + + sprite->pos2.x = Sin(sprite->data2, sprite->data0); + sprite->pos2.y = Cos(sprite->data2, sprite->data0); + + sprite->data2 = (sprite->data2 + 8) & 0xFF; + sprite->data0 += ((tempdata2 = sprite->data3) << 16 >> 18) + 1; // what? + sprite->data3 = tempdata2 + 1; + + tempdata = sprite->data1; + if((s16)tempdata != 28) // done rotating the grass, execute clean up function + sprite->data1++; + else + sprite->callback = (void *)sub_80A2AB8; +} + +void sub_80A2AB8(void) +{ + u8 i; + + for(i = 1; i < 8; i++) + { + DestroySprite(&gSprites[gCutGrassSpriteArray[i]]); + } + + FieldEffectStop(&gSprites[gCutGrassSpriteArray[0]], 0x3A); + sub_8064E2C(); + ScriptContext2_Disable(); +} + +void sub_80A2B00(void) +{ + PlaySE(0x80); + FieldEffectActiveListRemove(2); + EnableBothScriptContexts(); +} diff --git a/src/fldeff_strength.c b/src/fldeff_strength.c index dedb62a90..e7e7473d0 100644 --- a/src/fldeff_strength.c +++ b/src/fldeff_strength.c @@ -5,14 +5,16 @@ #include "script.h" #include "task.h" #include "text.h" +#include "braille_puzzles.h" +#include "rom6.h" static void sub_811AA18(void); static void sub_811AA38(void); static void sub_811AA9C(void); -extern u32 gUnknown_0202FF84; +extern u32 gUnknown_0202FF84[]; -extern u8 gUnknown_03005CE0; +extern u8 gLastFieldPokeMenuOpened; extern u16 gScriptResult; extern void (*gUnknown_0300485C)(void); extern void (*gUnknown_03005CE4)(void); @@ -23,7 +25,7 @@ bool8 SetUpFieldMove_Strength(void) { if (ShouldDoBrailleStrengthEffect()) { - gScriptResult = gUnknown_03005CE0; + gScriptResult = gLastFieldPokeMenuOpened; gUnknown_0300485C = sub_808AB90; gUnknown_03005CE4 = sub_811AA38; } @@ -31,7 +33,7 @@ bool8 SetUpFieldMove_Strength(void) { if (npc_before_player_of_type(87) != TRUE) return 0; - gScriptResult = gUnknown_03005CE0; + gScriptResult = gLastFieldPokeMenuOpened; gUnknown_0300485C = sub_808AB90; gUnknown_03005CE4 = sub_811AA18; } @@ -41,13 +43,13 @@ bool8 SetUpFieldMove_Strength(void) static void sub_811AA18(void) { - gUnknown_0202FF84 = gUnknown_03005CE0; + gUnknown_0202FF84[0] = gLastFieldPokeMenuOpened; ScriptContext1_SetupScript(UseStrengthScript); } static void sub_811AA38(void) { - gUnknown_0202FF84 = gUnknown_03005CE0; + gUnknown_0202FF84[0] = gLastFieldPokeMenuOpened; FieldEffectStart(40); } @@ -57,7 +59,7 @@ bool8 FldEff_UseStrength(void) gTasks[taskId].data[8] = (u32)sub_811AA9C >> 16; gTasks[taskId].data[9] = (u32)sub_811AA9C; - GetMonNickname(&gPlayerParty[gUnknown_0202FF84], gStringVar1); + GetMonNickname(&gPlayerParty[gUnknown_0202FF84[0]], gStringVar1); return FALSE; } diff --git a/src/fldeff_teleport.c b/src/fldeff_teleport.c index afa5ea997..0e6933649 100644 --- a/src/fldeff_teleport.c +++ b/src/fldeff_teleport.c @@ -3,13 +3,14 @@ #include "field_effect.h" #include "field_player_avatar.h" #include "rom4.h" +#include "rom6.h" extern void sub_8087BA8(void); -extern u32 gUnknown_0202FF84; +extern u32 gUnknown_0202FF84[]; extern void (*gUnknown_0300485C)(void); -extern u8 gUnknown_03005CE0; +extern u8 gLastFieldPokeMenuOpened; extern void (*gUnknown_03005CE4)(void); void hm_teleport_run_dp02scr(void); @@ -31,7 +32,7 @@ void hm_teleport_run_dp02scr(void) { new_game(); FieldEffectStart(63); - gUnknown_0202FF84 = gUnknown_03005CE0; + gUnknown_0202FF84[0] = gLastFieldPokeMenuOpened; } bool8 FldEff_UseTeleport(void) diff --git a/src/intro.c b/src/intro.c index 72478b773..fd0a3316e 100644 --- a/src/intro.c +++ b/src/intro.c @@ -34,7 +34,7 @@ extern u16 gUnknown_0203931A; extern u16 gUnknown_02039358; extern u16 gUnknown_0203935A; extern u32 gIntroFrameCounter; -extern struct GcmbStruct gUnknown_03005EE0; +extern struct GcmbStruct gMultibootProgramStruct; extern u16 gSaveFileStatus; extern u8 gReservedSpritePaletteCount; extern struct SpriteSheet gMonFrontPicTable[]; @@ -851,7 +851,7 @@ static void LoadCopyrightGraphics(u16 a1, u16 a2, u16 a3) static void SerialCb_CopyrightScreen(void) { - GameCubeMultiBoot_HandleSerialInterrupt(&gUnknown_03005EE0); + GameCubeMultiBoot_HandleSerialInterrupt(&gMultibootProgramStruct); } static u8 SetUpCopyrightScreen(void) @@ -892,15 +892,15 @@ static u8 SetUpCopyrightScreen(void) SetVBlankCallback(VBlankCB_Intro); REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON; SetSerialCallback(SerialCb_CopyrightScreen); - GameCubeMultiBoot_Init(&gUnknown_03005EE0); + GameCubeMultiBoot_Init(&gMultibootProgramStruct); default: UpdatePaletteFade(); gMain.state++; - GameCubeMultiBoot_Main(&gUnknown_03005EE0); + GameCubeMultiBoot_Main(&gMultibootProgramStruct); break; case 140: - GameCubeMultiBoot_Main(&gUnknown_03005EE0); - if (gUnknown_03005EE0.gcmb_field_2 != 1) + GameCubeMultiBoot_Main(&gMultibootProgramStruct); + if (gMultibootProgramStruct.gcmb_field_2 != 1) { BeginNormalPaletteFade(0xFFFFFFFFu, 0, 0, 0x10, 0); gMain.state++; @@ -911,9 +911,9 @@ static u8 SetUpCopyrightScreen(void) break; CreateTask(Task_IntroLoadPart1Graphics, 0); SetMainCallback2(MainCB2_Intro); - if (gUnknown_03005EE0.gcmb_field_2) + if (gMultibootProgramStruct.gcmb_field_2) { - GameCubeMultiBoot_ExecuteProgram(&gUnknown_03005EE0); + GameCubeMultiBoot_ExecuteProgram(&gMultibootProgramStruct); } else { @@ -931,7 +931,7 @@ void c2_copyright_1(void) if (!SetUpCopyrightScreen()) { sub_8052E4C(); - sub_81251B8(); + ResetSaveCounters(); sub_8125EC8(0); if (gSaveFileStatus == 0 || gSaveFileStatus == 2) ClearSav2(); diff --git a/src/item_use.c b/src/item_use.c index 344a3bc0d..b68b72b26 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -16,6 +16,7 @@ #include "string_util.h" #include "task.h" #include "weather.h" +#include "fieldmap.h" extern void (* const gExitToOverworldFuncList[])(); extern void (* gUnknown_03005D00)(u8); @@ -38,6 +39,7 @@ extern u8 GetPlayerDirectionTowardsHiddenItem(s16, s16); extern void SetPlayerDirectionTowardsItem(u8); extern void DisplayItemRespondingMessageAndExitItemfinder(u8); extern void RotatePlayerAndExitItemfinder(u8); +extern void sub_80C9838(u8, s16, s16); extern u8 gOtherText_DadsAdvice[]; extern u8 gOtherText_CantGetOffBike[]; @@ -47,9 +49,10 @@ extern u8 gItemFinderDirections[]; extern u16 gScriptItemId; -bool8 ItemfinderCheckForHiddenItems(struct MapEvents *events, int); +bool8 ItemfinderCheckForHiddenItems(struct MapEvents *events, u8 taskId); void RunItemfinderResults(u8); void ExitItemfinder(u8); +void sub_80C9720(u8); void ExecuteSwitchToOverworldFromItemUse(u8 taskId) { @@ -88,9 +91,9 @@ void SetUpItemUseOnFieldCallback(u8 taskId) gUnknown_03005D00(taskId); } -void HandleDeniedItemUseMessage(u8 var1, u8 playerMenuStatus, const u8 *var3) +void HandleDeniedItemUseMessage(u8 var1, u8 playerMenuStatus, const u8 *text) { - StringExpandPlaceholders(gStringVar4, var3); + StringExpandPlaceholders(gStringVar4, text); switch (playerMenuStatus) { @@ -290,125 +293,96 @@ void ExitItemfinder(u8 taskId) DestroyTask(taskId); } -// too much struct math. -__attribute__((naked)) -bool8 ItemfinderCheckForHiddenItems(struct MapEvents *events, int var) +bool8 ItemfinderCheckForHiddenItems(struct MapEvents *events, u8 taskId) { - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r9\n\ - mov r6, r8\n\ - push {r6,r7}\n\ - sub sp, 0x4\n\ - adds r5, r0, 0\n\ - lsls r1, 24\n\ - lsrs r6, r1, 24\n\ - mov r4, sp\n\ - adds r4, 0x2\n\ - mov r0, sp\n\ - adds r1, r4, 0\n\ - bl PlayerGetDestCoords\n\ - ldr r1, _080C9618 @ =gTasks\n\ - lsls r0, r6, 2\n\ - adds r0, r6\n\ - lsls r0, 3\n\ - adds r0, r1\n\ - movs r1, 0\n\ - strh r1, [r0, 0xC]\n\ - movs r3, 0\n\ - mov r9, r4\n\ - ldrb r0, [r5, 0x3]\n\ - cmp r3, r0\n\ - bge _080C95FC\n\ - subs r1, 0x5\n\ - mov r8, r1\n\ -_080C9580:\n\ - lsls r3, 16\n\ - asrs r1, r3, 16\n\ - ldr r2, [r5, 0x10]\n\ - lsls r0, r1, 1\n\ - adds r0, r1\n\ - lsls r4, r0, 2\n\ - adds r1, r4, r2\n\ - ldrb r0, [r1, 0x5]\n\ - adds r7, r3, 0\n\ - cmp r0, 0x7\n\ - bne _080C95EC\n\ - movs r2, 0x96\n\ - lsls r2, 2\n\ - adds r0, r2, 0\n\ - ldrh r1, [r1, 0xA]\n\ - adds r0, r1\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - bl FlagGet\n\ - lsls r0, 24\n\ - cmp r0, 0\n\ - bne _080C95EC\n\ - ldr r1, [r5, 0x10]\n\ - adds r1, r4, r1\n\ - ldrh r2, [r1]\n\ - adds r2, 0x7\n\ - mov r0, sp\n\ - ldrh r0, [r0]\n\ - subs r2, r0\n\ - ldrh r0, [r1, 0x2]\n\ - adds r0, 0x7\n\ - mov r3, r9\n\ - ldrh r1, [r3]\n\ - subs r0, r1\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - lsls r2, 16\n\ - asrs r1, r2, 16\n\ - movs r3, 0xE0\n\ - lsls r3, 11\n\ - adds r2, r3\n\ - lsrs r2, 16\n\ - cmp r2, 0xE\n\ - bhi _080C95EC\n\ - lsls r0, 16\n\ - asrs r2, r0, 16\n\ - cmp r2, r8\n\ - blt _080C95EC\n\ - cmp r2, 0x5\n\ - bgt _080C95EC\n\ - adds r0, r6, 0\n\ - bl sub_80C9838\n\ -_080C95EC:\n\ - movs r1, 0x80\n\ - lsls r1, 9\n\ - adds r0, r7, r1\n\ - lsrs r3, r0, 16\n\ - asrs r0, 16\n\ - ldrb r2, [r5, 0x3]\n\ - cmp r0, r2\n\ - blt _080C9580\n\ -_080C95FC:\n\ - adds r0, r6, 0\n\ - bl sub_80C9720\n\ - ldr r0, _080C9618 @ =gTasks\n\ - lsls r1, r6, 2\n\ - adds r1, r6\n\ - lsls r1, 3\n\ - adds r1, r0\n\ - movs r3, 0xC\n\ - ldrsh r0, [r1, r3]\n\ - cmp r0, 0x1\n\ - beq _080C961C\n\ - movs r0, 0\n\ - b _080C961E\n\ - .align 2, 0\n\ -_080C9618: .4byte gTasks\n\ -_080C961C:\n\ - movs r0, 0x1\n\ -_080C961E:\n\ - add sp, 0x4\n\ - pop {r3,r4}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - pop {r4-r7}\n\ - pop {r1}\n\ - bx r1\n\ - .syntax divided"); + int distanceX, distanceY; + u16 x, y; + s16 newDistanceX, newDistanceY, i; + + PlayerGetDestCoords(&x, &y); + gTasks[taskId].data[2] = FALSE; + + for (i = 0; i < events->bgEventCount; i++) + { + if ((events -> bgEvents[i].kind == 7) && !FlagGet(events -> bgEvents[i].bgUnion.hiddenItem.hiddenItemId + 600)) + { + // do a distance lookup of each item so long as the index remains less than the objects on the current map. + distanceX = (u16)events -> bgEvents[i].x + 7; + newDistanceX = distanceX - x; + distanceY = (u16)events -> bgEvents[i].y + 7; + newDistanceY = distanceY - y; + + // is item in range? + if ((u16)(newDistanceX + 7) < 15 && (newDistanceY >= -5) && (newDistanceY < 6)) + sub_80C9838(taskId, newDistanceX, newDistanceY); // send coordinates of the item relative to the player + } + } + sub_80C9720(taskId); + + // hidden item detected? + if(gTasks[taskId].data[2] == TRUE) + return TRUE; + else + return FALSE; +} + +bool8 HiddenItemAtPos(struct MapEvents *events, s16 x, s16 y) +{ + u8 bgEventCount = events->bgEventCount; + struct BgEvent *bgEvent = events->bgEvents; + int i; + + for(i = 0; i < bgEventCount; i++) + { + if(bgEvent[i].kind == 7 && x == (u16)bgEvent[i].x && y == (u16)bgEvent[i].y) // hidden item and coordinates matches x and y passed? + { + if(!FlagGet(bgEvent[i].bgUnion.hiddenItem.hiddenItemId + 600)) + return TRUE; + else + return FALSE; + } + } + return FALSE; +} + +bool8 sub_80C9688(struct MapConnection *connection, int x, int y) +{ + struct MapHeader *mapHeader; + u16 localX, localY; + u32 localOffset; + s32 localLength; + + mapHeader = mapconnection_get_mapheader(connection); + + switch(connection->direction) + { + // same weird temp variable behavior seen in HiddenItemAtPos + case 2: + localOffset = connection->offset + 7; + localX = x - localOffset; + localLength = mapHeader->mapData->height - 7; + localY = localLength + y; // additions are reversed for some reason + break; + case 1: + localOffset = connection->offset + 7; + localX = x - localOffset; + localLength = gMapHeader.mapData->height + 7; + localY = y - localLength; + break; + case 3: + localLength = mapHeader->mapData->width - 7; + localX = localLength + x; // additions are reversed for some reason + localOffset = connection->offset + 7; + localY = y - localOffset; + break; + case 4: + localLength = gMapHeader.mapData->width + 7; + localX = x - localLength; + localOffset = connection->offset + 7; + localY = y - localOffset; + break; + default: + return FALSE; + } + return HiddenItemAtPos(mapHeader->events, localX, localY); } diff --git a/src/link.c b/src/link.c index 3a3e9eebf..783f6aecd 100644 --- a/src/link.c +++ b/src/link.c @@ -402,7 +402,7 @@ static void LinkTestProcessKeyInput(void) if (gMain.newKeys & START_BUTTON) SetSuppressLinkErrorMessage(TRUE); if (gMain.newKeys & R_BUTTON) - sub_8125D44(1); + TrySavingData(LINK_SAVE); if (gMain.newKeys & SELECT_BUTTON) sub_800832C(); if (gLinkTestDebugValuesEnabled) diff --git a/src/load_save.c b/src/load_save.c index 0642c4cb3..0add1b0e3 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -1,4 +1,5 @@ #include "global.h" +#include "gba/flash_internal.h" #include "load_save.h" #include "asm.h" #include "main.h" diff --git a/src/mail.c b/src/mail.c index 466a64c9c..97c8dab5b 100644 --- a/src/mail.c +++ b/src/mail.c @@ -9,6 +9,7 @@ #include "string_util.h" #include "task.h" #include "text.h" +#include "name_string_util.h" struct UnkMailStruct { diff --git a/src/main_menu.c b/src/main_menu.c index f47b3bb47..3c8df52d4 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -17,6 +17,7 @@ #include "task.h" #include "text.h" #include "title_screen.h" +#include "naming_screen.h" #define BirchSpeechUpdateWindowText() ((u8)MenuUpdateWindowText_OverrideLineLength(24)) diff --git a/src/map_obj_lock.c b/src/map_obj_lock.c index b1e7bb3df..e500deca0 100644 --- a/src/map_obj_lock.c +++ b/src/map_obj_lock.c @@ -3,6 +3,7 @@ #include "asm.h" #include "field_player_avatar.h" #include "task.h" +#include "field_map_obj_helpers.h" extern u16 gScriptFacing; diff --git a/src/matsuda_debug_menu.c b/src/matsuda_debug_menu.c index 66e865ed6..6177d9edb 100644 --- a/src/matsuda_debug_menu.c +++ b/src/matsuda_debug_menu.c @@ -10,8 +10,8 @@ #include "string_util.h" #include "task.h" #include "text.h" - -#define BIT(n) (1 << (n)) +#include "contest.h" +#include "matsuda_debug_menu.h" extern u8 gUnknown_0203856C; extern u8 gUnknown_0203857D[][64]; @@ -63,24 +63,6 @@ extern u8* gMatsudaDebugMenuTextList2[]; extern u8* gMatsudaDebugMenuTextList3[]; extern u8 gMatsudaDebugMenuContestTopLeft[][2]; -struct ContestPokemon -{ - /* 0x00 */ u16 species; - /* 0x02 */ u8 nickname[POKEMON_NAME_LENGTH]; - /* 0x0D */ u8 trainerName[8]; - /* 0x15 */ u8 filler15[9]; - /* 0x1E */ u16 moves[4]; // moves - /* 0x26 */ u8 cool; // cool - /* 0x27 */ u8 beauty; // beauty - /* 0x28 */ u8 cute; // cute - /* 0x29 */ u8 smart; // smart - /* 0x2A */ u8 tough; // tough - /* 0x2B */ u8 sheen; // sheen - /* 0x2C */ u8 filler2C[20]; -}; - -extern struct ContestPokemon gContestMons[]; - extern bool8 gReceivedRemoteLinkPlayers; extern u16 gBlockRecvBuffer[MAX_LINK_PLAYERS][BLOCK_BUFFER_SIZE / 2]; @@ -103,7 +85,6 @@ static void sub_80AA10C(void); static void sub_80AA5BC(u8); static void sub_80AA614(u8, u8); static void sub_80AAD08(struct Sprite *, s8); -extern void sub_80AB184(void); extern void sub_80AB47C(void); extern int sub_80B2A7C(u8); //Don't know return type size @@ -431,7 +412,7 @@ static void sub_80AA10C(void) gSprites[spriteId].data3 = zero; // only this assignment of zero is necessary. other replacements of 0 with zero do not change the asm, compiler will treat it the same. } -void sub_80AA280(u8 var) +void sub_80AA280(u8 var) // no? { u8 i; diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index 9a049bb40..a7fb5abef 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -1,7 +1,251 @@ #include "global.h" #include "metatile_behaviors.h" -extern u8 gUnknown_08308E2C[]; +#define TILE_ATTRIBUTES(three, two, one) (((one) ? 1 : 0) | ((two) ? 2 : 0) | ((three) ? 4 : 0)) + +static const u8 sTileBitAttributes[] = +{ + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, TRUE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, TRUE), + TILE_ATTRIBUTES(TRUE, TRUE, TRUE), + TILE_ATTRIBUTES(TRUE, TRUE, TRUE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, TRUE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, TRUE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + TILE_ATTRIBUTES(FALSE, FALSE, FALSE) +}; bool8 MetatileBehavior_IsWaterfall(u8); @@ -13,7 +257,7 @@ bool8 MetatileBehavior_IsATile(u8 var) bool8 MetatileBehavior_IsEncounterTile(u8 var) { - if ((gUnknown_08308E2C[var] & 1) != 0) + if ((sTileBitAttributes[var] & 1) != 0) return TRUE; else return FALSE; @@ -149,7 +393,7 @@ bool8 MetatileBehavior_IsDeepSouthWarp(u8 var) bool8 MetatileBehavior_IsSurfableWaterOrUnderwater(u8 var) { - if ((gUnknown_08308E2C[var] & 2) != 0) + if ((sTileBitAttributes[var] & 2) != 0) return TRUE; else return FALSE; @@ -582,9 +826,9 @@ bool8 MetatileBehavior_IsBerryTreeSoil(u8 var) return FALSE; } -bool8 MetatileBehavior_IsAsh(u8 var) +bool8 MetatileBehavior_IsAshGrass(u8 var) { - if (var == MB_ASH) + if (var == MB_ASHGRASS) return TRUE; else return FALSE; @@ -992,9 +1236,9 @@ bool8 MetatileBehavior_IsRunningDisallowed(u8 var) return FALSE; } -bool8 sub_80578F8(u8 var) +bool8 MetatileBehavior_IsCuttableGrass(u8 var) { - if (var == MB_TALL_GRASS || var == MB_LONG_GRASS || var == MB_ASH || var == MB_LONG_GRASS_SOUTH_EDGE) + if (var == MB_TALL_GRASS || var == MB_LONG_GRASS || var == MB_ASHGRASS || var == MB_LONG_GRASS_SOUTH_EDGE) return TRUE; else return FALSE; diff --git a/src/mystery_event_menu.c b/src/mystery_event_menu.c index 3c867fb01..693b28948 100644 --- a/src/mystery_event_menu.c +++ b/src/mystery_event_menu.c @@ -295,7 +295,7 @@ static void CB2_MysteryEventMenu(void) unkVal = sub_812613C(unk_2000000); CpuFill32(0, unk_2000000, 0x7D4); if (!GetEventLoadMessage(gStringVar4, unkVal)) - sub_8125D44(0); + TrySavingData(NORMAL_SAVE); gMain.state++; break; case 12: diff --git a/src/naming_screen.c b/src/naming_screen.c index aa8066eb5..54a796264 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -10,64 +10,13 @@ #include "task.h" #include "text.h" #include "trig.h" +#include "naming_screen.h" extern u8 GetRivalAvatarGraphicsIdByStateIdAndGender(u8, u8); extern u8 CreateMonIcon(); extern void sub_809D51C(void); extern void MultiplyInvertedPaletteRGBComponents(u16, u8, u8, u8); -enum -{ - NAMING_SCREEN_TEMPLATE_PLAYER_NAME, - NAMING_SCREEN_TEMPLATE_BOX_NAME, - NAMING_SCREEN_TEMPLATE_MON_NAME, -}; - -struct NamingScreenTemplate -{ - u8 unk0; - u8 maxChars; - u8 unk2; - u8 unk3; - u8 unk4; //mode? - u8 unk5; - u8 unk6; - u8 unk7; - const u8 *title; -}; - -struct NamingScreenData -{ - u8 state; - u8 templateNum; - u16 unk2; - u16 bg1vOffset; - u16 bg2vOffset; - u16 unk8; - u16 unkA; - u8 unkC; - u8 unkD; - u8 currentPage; - u8 cursorSpriteId; - u8 unk10; - u8 textBuffer[0x10]; - u8 filler21[0x13]; - const struct NamingScreenTemplate *template; - u8 *destBuffer; - u16 unk3C; //savedKeyRepeatStartDelay - u16 unk3E; - u16 unk40; - u32 unk44; - MainCallback returnCallback; -}; - -enum -{ - PAGE_UPPER, - PAGE_LOWER, - PAGE_OTHERS, -}; - extern u16 gKeyRepeatStartDelay; extern u8 unk_2000000[]; @@ -140,7 +89,7 @@ static void sub_80B6CA8(void); static void sub_80B6D04(void); static void sub_80B6E44(void); static void InputInit(void); -static void sub_80B6438(void); +static void sub_80B6438(void); static void sub_80B5E50(void); static void Task_NamingScreenMain(u8); static void SetInputState(u8); @@ -188,31 +137,6 @@ static void sub_80B76E0(); static void nullsub_20(u8, u8); static void PrintKeyboardCharacters(u8); -enum -{ - MAIN_STATE_BEGIN_FADE_IN, - MAIN_STATE_WAIT_FADE_IN, - MAIN_STATE_HANDLE_INPUT, - MAIN_STATE_MOVE_TO_OK_BUTTON, - MAIN_STATE_START_PAGE_SWAP, - MAIN_STATE_WAIT_PAGE_SWAP, - MAIN_STATE_6, - MAIN_STATE_UPDATE_SENT_TO_PC_MESSAGE, - MAIN_STATE_BEGIN_FADE_OUT, -}; - -enum -{ - INPUT_STATE_DISABLED, - INPUT_STATE_ENABLED, -}; - -#define KBEVENT_NONE 0 -#define KBEVENT_PRESSED_A 5 -#define KBEVENT_PRESSED_B 6 -#define KBEVENT_PRESSED_SELECT 8 -#define KBEVENT_PRESSED_START 9 - void DoNamingScreen(u8 templateNum, u8 *destBuffer, u16 c, u16 d, u32 e, MainCallback returnCallback) { StoreNamingScreenParameters(templateNum, destBuffer, c, d, e, returnCallback); @@ -307,7 +231,7 @@ static void GetNamingScreenParameters(void) namingScreenData.templateNum = task->data[0]; namingScreenData.unk3E = task->data[1]; namingScreenData.unk40 = task->data[2]; - namingScreenData.unk44 = (task->data[3] << 16) | (u16)task->data[4]; + namingScreenData.unk42 = (task->data[3] << 16) | (u16)task->data[4]; LoadWordFromTwoHalfwords(&task->data[5], (u32 *)&namingScreenData.destBuffer); LoadWordFromTwoHalfwords(&task->data[7], (u32 *)&namingScreenData.returnCallback); DestroyTask(taskId); @@ -1406,7 +1330,7 @@ static void sub_80B6EFC(void) u8 spriteId; sub_809D51C(); - spriteId = CreateMonIcon(namingScreenData.unk3E, SpriteCallbackDummy, 0x34, 0x18, 0, namingScreenData.unk44); + spriteId = CreateMonIcon(namingScreenData.unk3E, SpriteCallbackDummy, 0x34, 0x18, 0, namingScreenData.unk42); gSprites[spriteId].oam.priority = 3; } @@ -1476,7 +1400,7 @@ static bool8 sub_80B7004(void) return FALSE; } -static void sub_80B7090(void) +static void sub_80B7090(void) // DoInput? { u8 r5; u8 r4; diff --git a/src/new_game.c b/src/new_game.c index 99c7839eb..82a26b52b 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -11,8 +11,9 @@ #include "rom4.h" #include "rtc.h" #include "script.h" +#include "dewford_trend.h" -extern u8 gUnknown_020297EC; +extern u8 gDifferentSaveFile; extern u8 gPlayerPartyCount; extern u8 gUnknown_03005CE8; @@ -22,8 +23,9 @@ extern u8 gUnknown_0819FA81[]; const struct SB1_2EFC_Struct gUnknown_08216604 = { - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, + 0x0000, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, } @@ -73,7 +75,7 @@ void sub_8052DA8(void) sub_80B2D1C(); for (i = 0; i < 5; i++) - gSaveBlock1.sb1_2EFC_struct[i] = gUnknown_08216604; + gSaveBlock1.sbStruct.unkSB1.sb1_2EFC_struct[i] = gUnknown_08216604; } void sub_8052DE4(void) @@ -95,7 +97,7 @@ void ClearSav2(void) void sub_8052E4C(void) { - gUnknown_020297EC = 0; + gDifferentSaveFile = 0; sub_808C0A0(); ZeroPlayerPartyMons(); ZeroEnemyPartyMons(); @@ -104,9 +106,10 @@ void sub_8052E4C(void) void NewGameInitData(void) { - if (!gSaveFileStatus || gSaveFileStatus == 2) + if (gSaveFileStatus == 0 || gSaveFileStatus == 2) RtcReset(); - gUnknown_020297EC = 1; + + gDifferentSaveFile = 1; ZeroPlayerPartyMons(); ZeroEnemyPartyMons(); sub_808C02C(); diff --git a/src/record_mixing.c b/src/record_mixing.c index b148fa644..57a6790f1 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -10,6 +10,7 @@ #include "sound.h" #include "string_util.h" #include "task.h" +#include "dewford_trend.h" extern void *recordMixingSecretBases; extern void *recordMixingTvShows; diff --git a/src/rom4.c b/src/rom4.c index 37c6b84ad..9d7fec115 100644 --- a/src/rom4.c +++ b/src/rom4.c @@ -30,6 +30,10 @@ #include "tileset_anim.h" #include "weather.h" #include "wild_encounter.h" +#include "script_pokemon_80C4.h" +#include "clock.h" +#include "field_map_obj_helpers.h" +#include "field_control_avatar.h" #ifdef SAPPHIRE #define LEGENDARY_MUSIC BGM_OOAME // Heavy Rain @@ -465,16 +469,10 @@ struct MapConnection *sub_8053818(u8 dir) if (connection == NULL) return NULL; - - i = 0; - - while (i < count) - { - if (connection->direction == dir) + + for(i = 0; i < count; i++, connection++) + if (connection->direction == dir) return connection; - i++; - connection++; - } return NULL; } diff --git a/src/rom6.c b/src/rom6.c index 581bd46b4..037516489 100644 --- a/src/rom6.c +++ b/src/rom6.c @@ -8,19 +8,17 @@ #include "sound.h" #include "sprite.h" #include "task.h" +#include "rom6.h" +#include "braille_puzzles.h" extern u16 gScriptLastTalked; extern u32 gUnknown_0202FF84[]; extern struct MapPosition gUnknown_0203923C; extern void (*gUnknown_0300485C)(void); -extern u8 gUnknown_03005CE0; +extern u8 gLastFieldPokeMenuOpened; extern void (*gUnknown_03005CE4)(void); extern u8 UseRockSmashScript[]; -extern bool8 ShouldDoBrailleDigEffect(void); -extern void DoBrailleDigEffect(void); -extern void sub_8053014(void); -extern void sub_8059BF4(void); extern void sub_808AB90(void); extern void task08_080A1C44(u8); extern u8 sub_80CA1C8(void); @@ -136,7 +134,7 @@ bool8 SetUpFieldMove_RockSmash(void) static void sub_810B53C(void) { - gUnknown_0202FF84[0] = gUnknown_03005CE0; + gUnknown_0202FF84[0] = gLastFieldPokeMenuOpened; ScriptContext1_SetupScript(UseRockSmashScript); } @@ -175,7 +173,7 @@ static void sub_810B5D8(void) { sub_8053014(); FieldEffectStart(0x26); - gUnknown_0202FF84[0] = gUnknown_03005CE0; + gUnknown_0202FF84[0] = gLastFieldPokeMenuOpened; } int FldEff_UseDig(void) diff --git a/src/save.c b/src/save.c index 9d70bfffd..b5934e231 100644 --- a/src/save.c +++ b/src/save.c @@ -1,58 +1,83 @@ #include "global.h" +#include "gba/flash_internal.h" #include "gba/gba.h" #include "save.h" #include "asm.h" -#include "gba/flash_internal.h" #include "load_save.h" #include "rom4.h" #include "save_failed_screen.h" -extern struct SaveSection unk_2000000; - -extern u32 gUnknown_02039284; - -extern u16 gUnknown_03005E9C; -extern u32 gUnknown_03005EA0; -extern u16 gUnknown_03005EA4; -extern u32 gUnknown_03005EA8; -extern u32 gUnknown_03005EAC; -extern struct SaveSection *gUnknown_03005EB0; +extern u32 gLastSaveSectorStatus; // used but in an unferenced function, so unused +extern u16 gLastWrittenSector; +extern u32 gLastSaveCounter; +extern u16 gLastKnownGoodSector; +extern u32 gDamagedSaveSectors; +extern u32 gSaveCounter; +extern struct SaveSection unk_2000000; // slow save RAM +extern struct SaveSection *gFastSaveSection; // the pointer is in fast IWRAM but may sometimes point to the slower EWRAM. extern u16 gUnknown_03005EB4; extern u16 gSaveFileStatus; -extern u32 gUnknown_03005EBC; +extern u32 gGameContinueCallback; -extern struct SaveSectionLocation gSaveSectionLocations[]; -extern struct SaveSectionLocation gHallOfFameSaveSectionLocations[]; -extern u8 gUnknown_08401E24[]; +extern struct PokemonStorage gPokemonStorage; +extern struct HallOfFame gHallOfFame; + +const struct SaveSectionLocation gSaveSectionLocations[] = +{ + {((u8 *) &gSaveBlock2), 0x890}, + {((u8 *) &gSaveBlock1) + 0xF80 * 0, 0xF80}, + {((u8 *) &gSaveBlock1) + 0xF80 * 1, 0xF80}, + {((u8 *) &gSaveBlock1) + 0xF80 * 2, 0xF80}, + {((u8 *) &gSaveBlock1) + 0xF80 * 3, 0xC40}, + {((u8 *) &gPokemonStorage) + 0xF80 * 0, 0xF80}, + {((u8 *) &gPokemonStorage) + 0xF80 * 1, 0xF80}, + {((u8 *) &gPokemonStorage) + 0xF80 * 2, 0xF80}, + {((u8 *) &gPokemonStorage) + 0xF80 * 3, 0xF80}, + {((u8 *) &gPokemonStorage) + 0xF80 * 4, 0xF80}, + {((u8 *) &gPokemonStorage) + 0xF80 * 5, 0xF80}, + {((u8 *) &gPokemonStorage) + 0xF80 * 6, 0xF80}, + {((u8 *) &gPokemonStorage) + 0xF80 * 7, 0xF80}, + {((u8 *) &gPokemonStorage) + 0xF80 * 8, 0x7D0} +}; + +const struct SaveSectionLocation gHallOfFameSaveSectionLocations[] = +{ + {((u8 *) &gHallOfFame) + 0xF80 * 0, 0xF80}, + {((u8 *) &gHallOfFame) + 0xF80 * 1, 0xF80} +}; + +const u8 gFlashSectors[] = { 0x1E, 0x1F }; void ClearSaveData(void) { u16 i; - for (i = 0; i < 32; i++) + + for (i = 0; i < NUM_SECTORS; i++) EraseFlashSector(i); } -void sub_81251B8(void) +// ResetSaveCounters +void ResetSaveCounters(void) { - gUnknown_03005EAC = 0; - gUnknown_03005E9C = 0; - gUnknown_03005EA8 = 0; + gSaveCounter = 0; + gLastWrittenSector = 0; + gDamagedSaveSectors = 0; } -bool32 sub_81251D4(u8 op, u8 bit) +bool32 SetDamagedSectorBits(u8 op, u8 bit) { bool32 retVal = FALSE; switch (op) { - case 0: - gUnknown_03005EA8 |= 1 << bit; + case ENABLE: + gDamagedSaveSectors |= (1 << bit); break; - case 1: - gUnknown_03005EA8 &= ~(1 << bit); + case DISABLE: + gDamagedSaveSectors &= ~(1 << bit); break; - case 2: - if (gUnknown_03005EA8 & (1 << bit)) + case CHECK: // unused + if (gDamagedSaveSectors & (1 << bit)) retVal = TRUE; break; } @@ -60,67 +85,70 @@ bool32 sub_81251D4(u8 op, u8 bit) return retVal; } -u8 save_write_to_flash(u16 a1, struct SaveSectionLocation *a2) +u8 save_write_to_flash(u16 a1, const struct SaveSectionLocation *location) { u32 retVal; u16 i; - gUnknown_03005EB0 = &unk_2000000; + gFastSaveSection = &unk_2000000; - if (a1 != 0xFFFF) + if (a1 != 0xFFFF) // for link { - retVal = sub_81252D8(a1, a2); + retVal = HandleWriteSector(a1, location); } else { - gUnknown_03005EA4 = gUnknown_03005E9C; - gUnknown_03005EA0 = gUnknown_03005EAC; - gUnknown_03005E9C++; - gUnknown_03005E9C = gUnknown_03005E9C % 14; - gUnknown_03005EAC++; + gLastKnownGoodSector = gLastWrittenSector; // backup the current written sector before attempting to write. + gLastSaveCounter = gSaveCounter; + gLastWrittenSector++; + gLastWrittenSector = gLastWrittenSector % 14; + gSaveCounter++; retVal = 1; + for (i = 0; i < 14; i++) - sub_81252D8(i, a2); - if (gUnknown_03005EA8) + HandleWriteSector(i, location); + + if (gDamagedSaveSectors != 0) // skip the damaged sector. { retVal = 0xFF; - gUnknown_03005E9C = gUnknown_03005EA4; - gUnknown_03005EAC = gUnknown_03005EA0; + gLastWrittenSector = gLastKnownGoodSector; + gSaveCounter = gLastSaveCounter; } } return retVal; } -u8 sub_81252D8(u16 a1, struct SaveSectionLocation *a2) +u8 HandleWriteSector(u16 a1, const struct SaveSectionLocation *location) { u16 i; u16 sector; u8 *data; u16 size; - sector = a1 + gUnknown_03005E9C; + sector = a1 + gLastWrittenSector; sector %= 14; - sector += 14 * (gUnknown_03005EAC % 2); + sector += 14 * (gSaveCounter % 2); - data = a2[a1].data; - size = a2[a1].size; + data = location[a1].data; + size = location[a1].size; + // clear save section. for (i = 0; i < sizeof(struct SaveSection); i++) - ((char *)gUnknown_03005EB0)[i] = 0; + ((char *)gFastSaveSection)[i] = 0; - gUnknown_03005EB0->id = a1; - gUnknown_03005EB0->unknown = 0x8012025; - gUnknown_03005EB0->counter = gUnknown_03005EAC; + gFastSaveSection->id = a1; + gFastSaveSection->security = UNKNOWN_CHECK_VALUE; + gFastSaveSection->counter = gSaveCounter; for (i = 0; i < size; i++) - gUnknown_03005EB0->data[i] = data[i]; + gFastSaveSection->data[i] = data[i]; - gUnknown_03005EB0->checksum = sub_8125C10(data, size); - return sub_8125440(sector, gUnknown_03005EB0->data); + gFastSaveSection->checksum = CalculateChecksum(data, size); + return TryWriteSector(sector, gFastSaveSection->data); } -u8 sub_81253C8(u8 sector, u8 *data, u16 size) +u8 HandleWriteSectorNBytes(u8 sector, u8 *data, u16 size) { u16 i; struct SaveSection *section = &unk_2000000; @@ -128,66 +156,66 @@ u8 sub_81253C8(u8 sector, u8 *data, u16 size) for (i = 0; i < sizeof(struct SaveSection); i++) ((char *)section)[i] = 0; - section->unknown = 0x8012025; + section->security = UNKNOWN_CHECK_VALUE; for (i = 0; i < size; i++) section->data[i] = data[i]; - section->id = sub_8125C10(data, size); // id instead of checksum? - return sub_8125440(sector, section->data); + section->id = CalculateChecksum(data, size); // though this appears to be incorrect, it might be some sector checksum instead of a whole save checksum and only appears to be relevent to HOF data, if used. + return TryWriteSector(sector, section->data); } -u8 sub_8125440(u8 sector, u8 *data) +u8 TryWriteSector(u8 sector, u8 *data) { - if (ProgramFlashSectorAndVerify(sector, data)) + if (ProgramFlashSectorAndVerify(sector, data) != 0) // is damaged? { - sub_81251D4(0, sector); + SetDamagedSectorBits(ENABLE, sector); // set damaged sector bits. return 0xFF; } else { - sub_81251D4(1, sector); + SetDamagedSectorBits(DISABLE, sector); // unset damaged sector bits. it's safe now. return 1; } } -u32 sub_812546C(struct SaveSectionLocation *a1) +u32 RestoreSaveBackupVarsAndIncrement(const struct SaveSectionLocation *location) // location is unused { - gUnknown_03005EB0 = &unk_2000000; - gUnknown_03005EA4 = gUnknown_03005E9C; - gUnknown_03005EA0 = gUnknown_03005EAC; - gUnknown_03005E9C++; - gUnknown_03005E9C = gUnknown_03005E9C % 14; - gUnknown_03005EAC++; + gFastSaveSection = &unk_2000000; + gLastKnownGoodSector = gLastWrittenSector; + gLastSaveCounter = gSaveCounter; + gLastWrittenSector++; + gLastWrittenSector = gLastWrittenSector % 14; + gSaveCounter++; gUnknown_03005EB4 = 0; - gUnknown_03005EA8 = 0; + gDamagedSaveSectors = 0; return 0; } -u32 sub_81254C8(struct SaveSectionLocation *a1) +u32 RestoreSaveBackupVars(const struct SaveSectionLocation *location) // only ever called once, and gSaveBlock2 is passed to this function. location is unused { - gUnknown_03005EB0 = &unk_2000000; - gUnknown_03005EA4 = gUnknown_03005E9C; - gUnknown_03005EA0 = gUnknown_03005EAC; + gFastSaveSection = &unk_2000000; + gLastKnownGoodSector = gLastWrittenSector; + gLastSaveCounter = gSaveCounter; gUnknown_03005EB4 = 0; - gUnknown_03005EA8 = 0; + gDamagedSaveSectors = 0; return 0; } -u8 sub_812550C(u16 a1, struct SaveSectionLocation *a2) +u8 sub_812550C(u16 a1, const struct SaveSectionLocation *location) { u8 retVal; if (gUnknown_03005EB4 < a1 - 1) { retVal = 1; - sub_81252D8(gUnknown_03005EB4, a2); + HandleWriteSector(gUnknown_03005EB4, location); gUnknown_03005EB4++; - if (gUnknown_03005EA8) + if (gDamagedSaveSectors) { retVal = 0xFF; - gUnknown_03005E9C = gUnknown_03005EA4; - gUnknown_03005EAC = gUnknown_03005EA0; + gLastWrittenSector = gLastKnownGoodSector; + gSaveCounter = gLastSaveCounter; } } else @@ -198,20 +226,22 @@ u8 sub_812550C(u16 a1, struct SaveSectionLocation *a2) return retVal; } -u8 sub_812556C(u16 a1, struct SaveSectionLocation *a2) +u8 sub_812556C(u16 a1, const struct SaveSectionLocation *location) { u8 retVal = 1; - sub_81255B8(a1 - 1, a2); - if (gUnknown_03005EA8) + + sub_81255B8(a1 - 1, location); + + if (gDamagedSaveSectors) { retVal = 0xFF; - gUnknown_03005E9C = gUnknown_03005EA4; - gUnknown_03005EAC = gUnknown_03005EA0; + gLastWrittenSector = gLastKnownGoodSector; + gSaveCounter = gLastSaveCounter; } return retVal; } -u8 sub_81255B8(u16 a1, struct SaveSectionLocation *a2) +u8 sub_81255B8(u16 a1, const struct SaveSectionLocation *location) { u16 i; u16 sector; @@ -219,32 +249,35 @@ u8 sub_81255B8(u16 a1, struct SaveSectionLocation *a2) u16 size; u8 status; - sector = a1 + gUnknown_03005E9C; + sector = a1 + gLastWrittenSector; sector %= 14; - sector += 14 * (gUnknown_03005EAC % 2); + sector += 14 * (gSaveCounter % 2); - data = a2[a1].data; - size = a2[a1].size; + data = location[a1].data; + size = location[a1].size; + // clear temp save section. for (i = 0; i < sizeof(struct SaveSection); i++) - ((char *)gUnknown_03005EB0)[i] = 0; + ((char *)gFastSaveSection)[i] = 0; - gUnknown_03005EB0->id = a1; - gUnknown_03005EB0->unknown = 0x8012025; - gUnknown_03005EB0->counter = gUnknown_03005EAC; + gFastSaveSection->id = a1; + gFastSaveSection->security = UNKNOWN_CHECK_VALUE; + gFastSaveSection->counter = gSaveCounter; + // set temp section's data. for (i = 0; i < size; i++) - gUnknown_03005EB0->data[i] = data[i]; + gFastSaveSection->data[i] = data[i]; - gUnknown_03005EB0->checksum = sub_8125C10(data, size); + // calculate checksum. + gFastSaveSection->checksum = CalculateChecksum(data, size); EraseFlashSector(sector); status = 1; - for (i = 0; i < 0xFF8; i++) + for (i = 0; i < sizeof(struct UnkSaveSection); i++) { - if (ProgramFlashByte(sector, i, ((u8 *)gUnknown_03005EB0)[i])) + if (ProgramFlashByte(sector, i, ((u8 *)gFastSaveSection)[i])) { status = 0xFF; break; @@ -253,7 +286,7 @@ u8 sub_81255B8(u16 a1, struct SaveSectionLocation *a2) if (status == 0xFF) { - sub_81251D4(0, sector); + SetDamagedSectorBits(ENABLE, sector); return 0xFF; } else @@ -262,7 +295,7 @@ u8 sub_81255B8(u16 a1, struct SaveSectionLocation *a2) for (i = 0; i < 7; i++) { - if (ProgramFlashByte(sector, 0xFF9 + i, ((u8 *)gUnknown_03005EB0)[0xFF9 + i])) + if (ProgramFlashByte(sector, 0xFF9 + i, ((u8 *)gFastSaveSection)[0xFF9 + i])) { status = 0xFF; break; @@ -271,105 +304,107 @@ u8 sub_81255B8(u16 a1, struct SaveSectionLocation *a2) if (status == 0xFF) { - sub_81251D4(0, sector); + SetDamagedSectorBits(ENABLE, sector); return 0xFF; } else { - sub_81251D4(1, sector); + SetDamagedSectorBits(DISABLE, sector); return 1; } } } -u8 sub_8125758(u16 a1, struct SaveSectionLocation *a2) +u8 sub_8125758(u16 a1, const struct SaveSectionLocation *location) { u16 sector; - sector = a1 + gUnknown_03005E9C - 1; + sector = a1 + gLastWrittenSector - 1; sector %= 14; - sector += 14 * (gUnknown_03005EAC % 2); + sector += 14 * (gSaveCounter % 2); - if (ProgramFlashByte(sector, 0xFF8, ((u8 *)gUnknown_03005EB0)[0xFF8])) + if (ProgramFlashByte(sector, sizeof(struct UnkSaveSection), ((u8 *)gFastSaveSection)[sizeof(struct UnkSaveSection)])) { - sub_81251D4(0, sector); - gUnknown_03005E9C = gUnknown_03005EA4; - gUnknown_03005EAC = gUnknown_03005EA0; + // sector is damaged, so enable the bit in gDamagedSaveSectors and restore the last written sector and save counter. + SetDamagedSectorBits(ENABLE, sector); + gLastWrittenSector = gLastKnownGoodSector; + gSaveCounter = gLastSaveCounter; return 0xFF; } else { - sub_81251D4(1u, sector); + SetDamagedSectorBits(DISABLE, sector); return 1; } } -u8 sub_81257F0(u16 a1, struct SaveSectionLocation *a2) +u8 sub_81257F0(u16 a1, const struct SaveSectionLocation *location) { u16 sector; - sector = a1 + gUnknown_03005E9C - 1; + sector = a1 + gLastWrittenSector - 1; sector %= 14; - sector += 14 * (gUnknown_03005EAC % 2); + sector += 14 * (gSaveCounter % 2); - if (ProgramFlashByte(sector, 0xFF8, 0x25)) + if (ProgramFlashByte(sector, sizeof(struct UnkSaveSection), 0x25)) { - sub_81251D4(0, sector); - gUnknown_03005E9C = gUnknown_03005EA4; - gUnknown_03005EAC = gUnknown_03005EA0; + // sector is damaged, so enable the bit in gDamagedSaveSectors and restore the last written sector and save counter. + SetDamagedSectorBits(ENABLE, sector); + gLastWrittenSector = gLastKnownGoodSector; + gSaveCounter = gLastSaveCounter; return 0xFF; } else { - sub_81251D4(1u, sector); + SetDamagedSectorBits(DISABLE, sector); return 1; } } -u8 sub_812587C(u16 a1, struct SaveSectionLocation *a2) +u8 sub_812587C(u16 a1, const struct SaveSectionLocation *location) { u8 retVal; - gUnknown_03005EB0 = &unk_2000000; + gFastSaveSection = &unk_2000000; if (a1 != 0xFFFF) { retVal = 0xFF; } else { - retVal = sub_8125974(a2); - sub_81258BC(0xFFFF, a2); + retVal = sub_8125974(location); + sub_81258BC(0xFFFF, location); } return retVal; } -u8 sub_81258BC(u16 a1, struct SaveSectionLocation *a2) +u8 sub_81258BC(u16 a1, const struct SaveSectionLocation *location) { u16 i; u16 checksum; - u16 v3 = 14 * (gUnknown_03005EAC % 2); + u16 v3 = 14 * (gSaveCounter % 2); u16 id; for (i = 0; i < 14; i++) { - sub_8125BF8(i + v3, gUnknown_03005EB0); - id = gUnknown_03005EB0->id; + sub_8125BF8(i + v3, gFastSaveSection); + id = gFastSaveSection->id; if (id == 0) - gUnknown_03005E9C = i; - checksum = sub_8125C10(gUnknown_03005EB0->data, a2[id].size); - if (gUnknown_03005EB0->unknown == 0x8012025 - && gUnknown_03005EB0->checksum == checksum) + gLastWrittenSector = i; + checksum = CalculateChecksum(gFastSaveSection->data, location[id].size); + if (gFastSaveSection->security == UNKNOWN_CHECK_VALUE + && gFastSaveSection->checksum == checksum) { u16 j; - for (j = 0; j < a2[id].size; j++) - ((u8 *)a2[id].data)[j] = gUnknown_03005EB0->data[j]; + for (j = 0; j < location[id].size; j++) + ((u8 *)location[id].data)[j] = gFastSaveSection->data[j]; } } return 1; } -u8 sub_8125974(struct SaveSectionLocation *a1) +u8 sub_8125974(const struct SaveSectionLocation *location) { u16 i; u16 checksum; @@ -385,15 +420,15 @@ u8 sub_8125974(struct SaveSectionLocation *a1) for (i = 0; i < 14; i++) { - sub_8125BF8(i, gUnknown_03005EB0); - if (gUnknown_03005EB0->unknown == 0x8012025) + sub_8125BF8(i, gFastSaveSection); + if (gFastSaveSection->security == UNKNOWN_CHECK_VALUE) { v5 = TRUE; - checksum = sub_8125C10(gUnknown_03005EB0->data, a1[gUnknown_03005EB0->id].size); - if (gUnknown_03005EB0->checksum == checksum) + checksum = CalculateChecksum(gFastSaveSection->data, location[gFastSaveSection->id].size); + if (gFastSaveSection->checksum == checksum) { - v2 = gUnknown_03005EB0->counter; - v4 |= 1 << gUnknown_03005EB0->id; + v2 = gFastSaveSection->counter; + v4 |= 1 << gFastSaveSection->id; } } } @@ -415,15 +450,15 @@ u8 sub_8125974(struct SaveSectionLocation *a1) for (i = 0; i < 14; i++) { - sub_8125BF8(i + 14, gUnknown_03005EB0); - if (gUnknown_03005EB0->unknown == 0x8012025) + sub_8125BF8(i + 14, gFastSaveSection); + if (gFastSaveSection->security == UNKNOWN_CHECK_VALUE) { v5 = TRUE; - checksum = sub_8125C10(gUnknown_03005EB0->data, a1[gUnknown_03005EB0->id].size); - if (gUnknown_03005EB0->checksum == checksum) + checksum = CalculateChecksum(gFastSaveSection->data, location[gFastSaveSection->id].size); + if (gFastSaveSection->checksum == checksum) { - v3 = gUnknown_03005EB0->counter; - v4 |= 1 << gUnknown_03005EB0->id; + v3 = gFastSaveSection->counter; + v4 |= 1 << gFastSaveSection->id; } } } @@ -446,22 +481,22 @@ u8 sub_8125974(struct SaveSectionLocation *a1) { if ((unsigned)(v2 + 1) < (unsigned)(v3 + 1)) { - gUnknown_03005EAC = v3; + gSaveCounter = v3; } else { - gUnknown_03005EAC = v2; + gSaveCounter = v2; } } else { if (v2 < v3) { - gUnknown_03005EAC = v3; + gSaveCounter = v3; } else { - gUnknown_03005EAC = v2; + gSaveCounter = v2; } } return 1; @@ -469,7 +504,7 @@ u8 sub_8125974(struct SaveSectionLocation *a1) if (v14 == 1) { - gUnknown_03005EAC = v2; + gSaveCounter = v2; if (v10 == 255) return 255; return 1; @@ -477,7 +512,7 @@ u8 sub_8125974(struct SaveSectionLocation *a1) if (v10 == 1) { - gUnknown_03005EAC = v3; + gSaveCounter = v3; if (v14 == 255) return 255; return 1; @@ -485,13 +520,13 @@ u8 sub_8125974(struct SaveSectionLocation *a1) if (v14 == 0 && v10 == 0) { - gUnknown_03005EAC = 0; - gUnknown_03005E9C = 0; + gSaveCounter = 0; + gLastWrittenSector = 0; return 0; } - gUnknown_03005EAC = 0; - gUnknown_03005E9C = 0; + gSaveCounter = 0; + gLastWrittenSector = 0; return 2; } @@ -500,9 +535,9 @@ u8 sub_8125B88(u8 a1, u8 *data, u16 size) u16 i; struct SaveSection *section = &unk_2000000; sub_8125BF8(a1, section); - if (section->unknown == 0x8012025) + if (section->security == UNKNOWN_CHECK_VALUE) { - u16 checksum = sub_8125C10(section->data, size); + u16 checksum = CalculateChecksum(section->data, size); if (section->id == checksum) { for (i = 0; i < size; i++) @@ -522,11 +557,11 @@ u8 sub_8125B88(u8 a1, u8 *data, u16 size) u8 sub_8125BF8(u8 sector, struct SaveSection *section) { - ReadFlash(sector, 0, section->data, 0x1000); + ReadFlash(sector, 0, section->data, sizeof(struct SaveSection)); return 1; } -u16 sub_8125C10(void *data, u16 size) +u16 CalculateChecksum(void *data, u16 size) { u16 i; u32 checksum = 0; @@ -537,37 +572,37 @@ u16 sub_8125C10(void *data, u16 size) return ((checksum >> 16) + checksum); } -u8 sub_8125C3C(u8 a1) +u8 HandleSavingData(u8 saveType) { u8 i; - switch (a1) + switch (saveType) { - case 5: + case HOF_DELETE_SAVE: // deletes save before HOF case. unused for (i = 28; i < 32; i++) EraseFlashSector(i); - case 3: + case HOF_SAVE: // hall of fame. if (GetGameStat(10) < 999) IncrementGameStat(10); for (i = 0; i < 2; i++) - sub_81253C8(28 + i, gHallOfFameSaveSectionLocations[i].data, gHallOfFameSaveSectionLocations[i].size); + HandleWriteSectorNBytes(28 + i, gHallOfFameSaveSectionLocations[i].data, gHallOfFameSaveSectionLocations[i].size); SaveSerializedGame(); save_write_to_flash(0xFFFF, gSaveSectionLocations); break; - case 0: + case NORMAL_SAVE: // normal save. default: SaveSerializedGame(); save_write_to_flash(0xFFFF, gSaveSectionLocations); break; - case 1: + case LINK_SAVE: // link save. update only the pokemon, i think. SaveSerializedGame(); for (i = 0; i < 5; i++) save_write_to_flash(i, gSaveSectionLocations); break; - case 2: + case EREADER_SAVE: // used in mossdeep "game corner" before/after battling old man e-reader trainer SaveSerializedGame(); save_write_to_flash(0, gSaveSectionLocations); break; - case 4: + case DIFFERENT_FILE_SAVE: // there is a different file, so erase the file and overwrite it completely. for (i = 28; i < 32; i++) EraseFlashSector(i); SaveSerializedGame(); @@ -577,49 +612,49 @@ u8 sub_8125C3C(u8 a1) return 0; } -u8 sub_8125D44(u8 a1) +u8 TrySavingData(u8 saveType) // TrySave { if (gFlashMemoryPresent != TRUE) return 0xFF; - sub_8125C3C(a1); - if (!gUnknown_03005EA8) + HandleSavingData(saveType); + if (!gDamagedSaveSectors) return 1; - DoSaveFailedScreen(a1); + DoSaveFailedScreen(saveType); return 0xFF; } -u8 sub_8125D80(void) +u8 sub_8125D80(void) // trade.s save { if (gFlashMemoryPresent != TRUE) return 1; SaveSerializedGame(); - sub_812546C(gSaveSectionLocations); + RestoreSaveBackupVarsAndIncrement(gSaveSectionLocations); return 0; } -bool8 sub_8125DA8(void) +bool8 sub_8125DA8(void) // trade.s save { - u8 v0 = sub_812550C(14, gSaveSectionLocations); - if (gUnknown_03005EA8) + u8 retVal = sub_812550C(14, gSaveSectionLocations); + if (gDamagedSaveSectors) DoSaveFailedScreen(0); - if (v0 == 0xFF) + if (retVal == 0xFF) return 1; else return 0; } -u8 sub_8125DDC(void) +u8 sub_8125DDC(void) // trade.s save { sub_812556C(14, gSaveSectionLocations); - if (gUnknown_03005EA8) + if (gDamagedSaveSectors) DoSaveFailedScreen(0); return 0; } -u8 sub_8125E04(void) +u8 sub_8125E04(void) // trade.s save { sub_8125758(14, gSaveSectionLocations); - if (gUnknown_03005EA8) + if (gDamagedSaveSectors) DoSaveFailedScreen(0); return 0; } @@ -630,7 +665,7 @@ u8 sub_8125E2C(void) return 1; SaveSerializedGame(); - sub_81254C8(gSaveSectionLocations); + RestoreSaveBackupVars(gSaveSectionLocations); sub_812556C(gUnknown_03005EB4 + 1, gSaveSectionLocations); return 0; } @@ -649,7 +684,7 @@ u8 sub_8125E6C(void) sub_81257F0(val, gSaveSectionLocations); retVal = 1; } - if (gUnknown_03005EA8) + if (gDamagedSaveSectors) DoSaveFailedScreen(1); return retVal; } @@ -671,7 +706,7 @@ u8 sub_8125EC8(u8 a1) result = sub_812587C(0xFFFF, gSaveSectionLocations); LoadSerializedGame(); gSaveFileStatus = result; - gUnknown_03005EBC = 0; + gGameContinueCallback = 0; break; case 3: result = sub_8125B88(28, gHallOfFameSaveSectionLocations[0].data, gHallOfFameSaveSectionLocations[0].size); @@ -688,12 +723,12 @@ bool8 unref_sub_8125F4C(struct UnkSaveSection *a1) u16 i; char *raw = (char *)a1; - for (i = 0; i < 0x1000; i++) + for (i = 0; i < sizeof(struct SaveSection); i++) raw[i] = 0; - ReadFlash(gUnknown_08401E24[0], 0, a1->data, 4096); + ReadFlash(gFlashSectors[0], 0, a1->data, 4096); - if (a1->unknown != 0x8012025) + if (a1->security != UNKNOWN_CHECK_VALUE) return FALSE; return TRUE; @@ -702,10 +737,10 @@ bool8 unref_sub_8125F4C(struct UnkSaveSection *a1) u8 unref_sub_8125FA0(void) { u16 i; - u8 v0 = sub_8125D44(0); + u8 v0 = TrySavingData(0); for (i = 0; i < 2; i++) - EraseFlashSector(gUnknown_08401E24[i]); + EraseFlashSector(gFlashSectors[i]); if (v0 == 255) { @@ -727,25 +762,25 @@ u8 unref_sub_8125FF0(u8 *data, u16 size) u16 i; struct UnkSaveSection *section = (struct UnkSaveSection *)&unk_2000000; - for (i = 0; i < 0x1000; i++) + for (i = 0; i < sizeof(struct SaveSection); i++) ((char *)section)[i] = 0; - section->unknown = 0x8012025; + section->security = UNKNOWN_CHECK_VALUE; for (i = 0; i < size; i++) section->data[i] = data[i]; - gUnknown_02039284 = ProgramFlashSectorAndVerifyNBytes(gUnknown_08401E24[0], (u8 *)section, 0x1000); + gLastSaveSectorStatus = ProgramFlashSectorAndVerifyNBytes(gFlashSectors[0], (u8 *)section, sizeof(struct SaveSection)); - if (gUnknown_02039284) - return 255; + if (gLastSaveSectorStatus) + return 0xFF; else return 1; } u8 unref_sub_8126068(u8 sector, u8 *data, u32 size) { - if (ProgramFlashSectorAndVerify(sector, data, size)) + if (ProgramFlashSectorAndVerify(sector, data)) return 255; else return 1; @@ -753,6 +788,6 @@ u8 unref_sub_8126068(u8 sector, u8 *data, u32 size) u8 unref_sub_8126080(u8 sector, u8 *data) { - ReadFlash(sector, 0, data, 0x1000); + ReadFlash(sector, 0, data, sizeof(struct SaveSection)); return 1; } diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index 1e2651aa6..dd0e1b966 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -20,18 +20,19 @@ #define CLOCK_WIN_TOP (MSG_WIN_TOP - 4) -struct SaveFailedStruct +struct SaveFailedClockStruct { - u16 unk0; - u16 unk2; + bool16 clockRunning; + u16 timer; // appears to be unused, the only case its "used" cannot be reached normally + u8 unused[0xE]; // appears to be unused space. alternatively, there could have been multiple clock structs. however, neither of these cases are fulfilled, so the purpose of this space is unknown. one theory is that there is room for 3 more clock structs (2 16-bit values), so its possible GF intended there to be support for link-based save failed screens in case the synchronization failed, or it in fact was present in an earlier build but taken out for reasons. }; extern u8 unk_2000000[]; -extern u16 gUnknown_0203933C; -extern struct SaveFailedStruct gUnknown_0203933E; -extern u32 gUnknown_03005EA8; -extern u32 gUnknown_03005EBC; +extern u16 gSaveFailedType; +extern struct SaveFailedClockStruct gSaveFailedClockInfo; +extern u32 gDamagedSaveSectors; +extern u32 gGameContinueCallback; extern u8 gBirchHelpGfx[]; @@ -44,10 +45,7 @@ extern u8 gSystemText_GameplayEnded[]; extern u8 gBirchGrassTilemap[]; extern u8 gBirchBagTilemap[]; - -extern const u8 gSaveFailedClockGfx[]; -extern const u8 gSaveFailedClockPal[]; -extern u8 gBirchBagGrassPal[]; +extern u8 gBirchBagGrassPal[0x40]; static const struct OamData sClockOamData = { @@ -78,6 +76,9 @@ static const u8 sClockFrames[8][3] = { 5, 1, 0 }, }; +static const u8 gSaveFailedClockPal[] = INCBIN_U8("graphics/misc/clock_small.gbapal"); +static const u8 gSaveFailedClockGfx[] = INCBIN_U8("graphics/misc/clock_small.4bpp.lz"); + static void VBlankCB(void); static void CB2_SaveFailedScreen(void); static void CB2_WipeSave(void); @@ -89,11 +90,11 @@ static bool8 VerifySectorWipe(u16 sector); static bool8 WipeSector(u16 sector); static bool8 WipeSectors(u32 sectorBits); -void DoSaveFailedScreen(u8 var) +void DoSaveFailedScreen(u8 saveType) { SetMainCallback2(CB2_SaveFailedScreen); - gUnknown_0203933C = var; - gUnknown_0203933E.unk0 = 0; + gSaveFailedType = saveType; + gSaveFailedClockInfo.clockRunning = FALSE; } static void VBlankCB(void) @@ -135,8 +136,8 @@ static void CB2_SaveFailedScreen(void) ResetSpriteData(); ResetTasks(); ResetPaletteFade(); - LoadPalette(&gBirchBagGrassPal, 0, 0x40); - LoadPalette(&gSaveFailedClockPal, 0x100, 0x20); + LoadPalette(&gBirchBagGrassPal, 0, sizeof(gBirchBagGrassPal)); + LoadPalette(&gSaveFailedClockPal, 0x100, sizeof(gSaveFailedClockPal)); SetUpWindowConfig(&gWindowConfig_81E6C3C); InitMenuWindow(&gWindowConfig_81E6CE4); MenuDrawTextWindow(13, CLOCK_WIN_TOP, 16, CLOCK_WIN_TOP + 3); // clock window @@ -169,11 +170,11 @@ static void CB2_WipeSave(void) { u8 wipeTries = 0; - gUnknown_0203933E.unk0 = 1; + gSaveFailedClockInfo.clockRunning = TRUE; - while (gUnknown_03005EA8 && wipeTries < 3) + while (gDamagedSaveSectors != 0 && wipeTries < 3) // while there are still attempts left, keep trying to fix the save sectors. { - if (WipeSectors(gUnknown_03005EA8)) + if (WipeSectors(gDamagedSaveSectors) != FALSE) { MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); MenuPrint(gSystemText_BackupDamagedGameContinue, 2, MSG_WIN_TOP + 1); @@ -183,9 +184,9 @@ static void CB2_WipeSave(void) MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); MenuPrint(gSystemText_CheckCompleteSaveAttempt, 2, MSG_WIN_TOP + 1); - sub_8125C3C(gUnknown_0203933C); + HandleSavingData(gSaveFailedType); - if (gUnknown_03005EA8) + if (gDamagedSaveSectors != 0) { #ifdef BUGFIX_SAVEFAILEDSCREEN2 MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); @@ -206,9 +207,10 @@ static void CB2_WipeSave(void) { MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); - if (!gUnknown_03005EBC) // cant continue game. + // no callback exists, so the game cannot continue. + if (gGameContinueCallback == 0) MenuPrint(gSystemText_SaveCompletedGameEnd, 2, MSG_WIN_TOP + 1); - else // can continue game. + else // callback exists, so continue MenuPrint(gSystemText_SaveCompletedPressA, 2, MSG_WIN_TOP + 1); } @@ -217,7 +219,7 @@ static void CB2_WipeSave(void) static void CB2_GameplayCannotBeContinued(void) { - gUnknown_0203933E.unk0 = 0; + gSaveFailedClockInfo.clockRunning = FALSE; if (gMain.newKeys & A_BUTTON) { @@ -230,13 +232,11 @@ static void CB2_GameplayCannotBeContinued(void) static void CB2_FadeAndReturnToTitleScreen(void) { - u8 zero; - - gUnknown_0203933E.unk0 = zero = 0; + gSaveFailedClockInfo.clockRunning = FALSE; if (gMain.newKeys & A_BUTTON) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, zero, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); SetVBlankCallback(VBlankCB); SetMainCallback2(CB2_ReturnToTitleScreen); } @@ -246,14 +246,14 @@ static void CB2_ReturnToTitleScreen(void) { if (!UpdatePaletteFade()) { - if (!gUnknown_03005EBC) + if (gGameContinueCallback == 0) // no callback exists, so do a soft reset. { DoSoftReset(); } else { - SetMainCallback2((MainCallback)gUnknown_03005EBC); - gUnknown_03005EBC = 0; + SetMainCallback2((MainCallback)gGameContinueCallback); + gGameContinueCallback = 0; } } } @@ -266,7 +266,7 @@ static void VBlankCB_UpdateClockGraphics(void) gMain.oamBuffer[0].x = 112; gMain.oamBuffer[0].y = (CLOCK_WIN_TOP + 1) * 8; - if (gUnknown_0203933E.unk0) + if (gSaveFailedClockInfo.clockRunning != FALSE) { gMain.oamBuffer[0].tileNum = sClockFrames[n][0]; gMain.oamBuffer[0].matrixNum = (sClockFrames[n][2] << 4) | (sClockFrames[n][1] << 3); @@ -278,8 +278,8 @@ static void VBlankCB_UpdateClockGraphics(void) CpuFastCopy(gMain.oamBuffer, (void *)OAM, 4); - if (gUnknown_0203933E.unk2) - gUnknown_0203933E.unk2--; + if (gSaveFailedClockInfo.timer) // maybe was used for debugging? + gSaveFailedClockInfo.timer--; } static bool8 VerifySectorWipe(u16 sector) diff --git a/src/save_menu_util.c b/src/save_menu_util.c index 7790bbb1b..7899fabb1 100644 --- a/src/save_menu_util.c +++ b/src/save_menu_util.c @@ -81,22 +81,18 @@ void PrintSaveMapName(s16 x, s16 y) void PrintSaveBadges(s16 x, s16 y) { char badges[16]; - u8 badgeCount; MenuPrint(gOtherText_Badges, x, y); - badgeCount = GetBadgeCount(); - ConvertIntToDecimalString(badges, badgeCount); + ConvertIntToDecimalString(badges, GetBadgeCount()); MenuPrint_RightAligned(badges, x + 12, y); } void PrintSavePokedexCount(s16 x, s16 y) { char pokedex[16]; - u16 pokedexCount; MenuPrint(gOtherText_Pokedex, x, y); - pokedexCount = GetPokedexSeenCount(); - ConvertIntToDecimalStringN(pokedex, pokedexCount, 1, 3); + ConvertIntToDecimalStringN(pokedex, GetPokedexSeenCount(), 1, 3); MenuPrint_RightAligned(pokedex, x + 12, y); } diff --git a/src/scrcmd.c b/src/scrcmd.c index a13a42e87..b780cc6b4 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -9,6 +9,8 @@ #include "field_effect.h" #include "field_message_box.h" #include "field_player_avatar.h" +#include "field_map_obj_helpers.h" +#include "field_door.h" #include "item.h" #include "main.h" #include "map_obj_lock.h" @@ -23,6 +25,11 @@ #include "sound.h" #include "string_util.h" #include "weather.h" +#include "script_menu.h" +#include "script_pokemon_80F9.h" +#include "script_pokemon_80C4.h" +#include "clock.h" +#include "contest_painting.h" typedef u16 (*SpecialFunc)(void); typedef void (*NativeFunc)(void); diff --git a/src/script_menu.c b/src/script_menu.c index 51230b66b..de3dd7269 100644 --- a/src/script_menu.c +++ b/src/script_menu.c @@ -6,35 +6,576 @@ #include "sound.h" #include "sprite.h" #include "task.h" +#include "strings.h" +#include "script_menu.h" -struct MultichoiceListStruct +// multichoice lists +const struct MenuAction MultichoiceList_00[] = { - struct MenuAction *list; - u8 count; + {(u8 *)OtherText_Petalburg, 0}, + {(u8 *)OtherText_Slateport, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, }; -extern const struct MultichoiceListStruct gMultichoiceLists[]; +const struct MenuAction MultichoiceList_02[] = +{ + {(u8 *)OtherText_Enter, 0}, + {(u8 *)OtherText_Info3, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; -extern u16 gScriptResult; +const struct MenuAction MultichoiceList_03[] = +{ + {(u8 *)OtherText_WhatsAContest, 0}, + {(u8 *)OtherText_TypesOfContest, 0}, + {(u8 *)OtherText_Ranks, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; -extern void FreeResourcesAndDestroySprite(struct Sprite *sprite); -extern u8 CreateMonSprite_PicBox(u16, s16, s16, u8); -extern u8 sub_80B59AC(void); +const struct MenuAction MultichoiceList_04[] = +{ + {(u8 *)OtherText_CoolContest, 0}, + {(u8 *)OtherText_BeautyContest, 0}, + {(u8 *)OtherText_CuteContest, 0}, + {(u8 *)OtherText_SmartContest, 0}, + {(u8 *)OtherText_ToughContest, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_06[] = +{ + {(u8 *)OtherText_Decoration, 0}, + {(u8 *)OtherText_PackUp, 0}, + {(u8 *)OtherText_Registry, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_05[] = +{ + {(u8 *)OtherText_Decoration, 0}, + {(u8 *)OtherText_PackUp, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_07[] = +{ + {(u8 *)OtherText_Register, 0}, + {(u8 *)OtherText_Registry, 0}, + {(u8 *)OtherText_Information, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_12[] = +{ + {(u8 *)OtherText_Mach, 0}, + {(u8 *)OtherText_Acro, 0}, +}; + +const struct MenuAction MultichoiceList_13[] = +{ + {(u8 *)OtherText_Poison, 0}, + {(u8 *)OtherText_Paralysis, 0}, + {(u8 *)OtherText_Sleep, 0}, + {(u8 *)OtherText_Burn, 0}, + {(u8 *)OtherText_Frozen, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_14[] = +{ + {(u8 *)OtherText_Dewford, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_16[] = +{ + {(u8 *)OtherText_SawIt, 0}, + {(u8 *)OtherText_NotYet, 0}, +}; + +const struct MenuAction MultichoiceList_17[] = +{ + {(u8 *)OtherText_Yes, 0}, + {(u8 *)OtherText_No, 0}, + {(u8 *)OtherText_Info3, 0}, +}; + +const struct MenuAction MultichoiceList_18[] = +{ + {(u8 *)OtherText_SingleBattle, 0}, + {(u8 *)OtherText_DoubleBattle, 0}, + {(u8 *)OtherText_MultiBattle, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_19[] = +{ + {(u8 *)OtherText_Littleroot, 0}, + {(u8 *)OtherText_Slateport, 0}, + {(u8 *)OtherText_Lilycove, 0}, +}; + +const struct MenuAction MultichoiceList_20[] = +{ + {(u8 *)OtherText_Yes, 0}, + {(u8 *)OtherText_No, 0}, + {(u8 *)OtherText_Info3, 0}, +}; + +const struct MenuAction MultichoiceList_23[] = +{ + {(u8 *)OtherText_MakeAChallenge, 0}, + {(u8 *)OtherText_ObtainInformation, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_24[] = +{ + {(u8 *)OtherText_Lv50_2, 0}, + {(u8 *)OtherText_Lv100_2, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_25[] = +{ + {(u8 *)OtherText_Zigzagoon, 0}, + {(u8 *)OtherText_Nincada, 0}, + {(u8 *)OtherText_Poochyena, 0}, +}; + +const struct MenuAction MultichoiceList_26[] = +{ + {(u8 *)OtherText_Nincada2, 0}, + {(u8 *)OtherText_Lotad, 0}, + {(u8 *)OtherText_Roselia, 0}, +}; + +const struct MenuAction MultichoiceList_27[] = +{ + {(u8 *)OtherText_Shroomish, 0}, + {(u8 *)OtherText_Nincada3, 0}, + {(u8 *)OtherText_Surskit, 0}, +}; + +const struct MenuAction MultichoiceList_28[] = +{ + {(u8 *)OtherText_Treecko, 0}, + {(u8 *)OtherText_Torchic, 0}, + {(u8 *)OtherText_Mudkip, 0}, +}; + +const struct MenuAction MultichoiceList_29[] = +{ + {(u8 *)OtherText_Seedot, 0}, + {(u8 *)OtherText_Shroomish2, 0}, + {(u8 *)OtherText_Spinda, 0}, +}; + +const struct MenuAction MultichoiceList_30[] = +{ + {(u8 *)OtherText_Shroomish3, 0}, + {(u8 *)OtherText_Zigzagoon2, 0}, + {(u8 *)OtherText_Wurmple, 0}, +}; + +const struct MenuAction MultichoiceList_31[] = +{ + {(u8 *)OtherText_PokeBall, 0}, + {(u8 *)OtherText_SuperPotion, 0}, + {(u8 *)OtherText_SamePrice, 0}, +}; + +const struct MenuAction MultichoiceList_32[] = +{ + {(u8 *)OtherText_Yen135, 0}, + {(u8 *)OtherText_Yen155, 0}, + {(u8 *)OtherText_Yen175, 0}, +}; + +const struct MenuAction MultichoiceList_33[] = +{ + {(u8 *)OtherText_CostMore, 0}, + {(u8 *)OtherText_CostLess, 0}, + {(u8 *)OtherText_SamePrice2, 0}, +}; + +const struct MenuAction MultichoiceList_34[] = +{ + {(u8 *)OtherText_MaleSymbol, 0}, + {(u8 *)OtherText_FemaleSymbol, 0}, + {(u8 *)OtherText_Neither, 0}, +}; + +const struct MenuAction MultichoiceList_35[] = +{ + {(u8 *)OtherText_Males, 0}, + {(u8 *)OtherText_Females, 0}, + {(u8 *)OtherText_SameNumber, 0}, +}; + +const struct MenuAction MultichoiceList_36[] = +{ + {(u8 *)OtherText_Male, 0}, + {(u8 *)OtherText_Female, 0}, + {(u8 *)OtherText_ItDepends, 0}, +}; + +const struct MenuAction MultichoiceList_37[] = +{ + {(u8 *)OtherText_Six2, 0}, + {(u8 *)OtherText_Eight2, 0}, + {(u8 *)OtherText_Ten, 0}, +}; + +const struct MenuAction MultichoiceList_38[] = +{ + {(u8 *)OtherText_One, 0}, + {(u8 *)OtherText_Two, 0}, + {(u8 *)OtherText_Three, 0}, +}; + +const struct MenuAction MultichoiceList_39[] = +{ + {(u8 *)OtherText_Six, 0}, + {(u8 *)OtherText_Seven, 0}, + {(u8 *)OtherText_Eight, 0}, +}; + +const struct MenuAction MultichoiceList_42[] = +{ + {(u8 *)OtherText_FreshWater, 0}, + {(u8 *)OtherText_SodaPop, 0}, + {(u8 *)OtherText_Lemonade, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_43[] = +{ + {(u8 *)OtherText_HowToRide, 0}, + {(u8 *)OtherText_HowToTurn, 0}, + {(u8 *)OtherText_SandySlopes, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_44[] = +{ + {(u8 *)OtherText_Wheelies, 0}, + {(u8 *)OtherText_BunnyHops, 0}, + {(u8 *)OtherText_Jumping, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_45[] = +{ + {(u8 *)OtherText_Satisfied, 0}, + {(u8 *)OtherText_Dissatisfied, 0}, +}; + +const struct MenuAction MultichoiceList_46[] = +{ + {(u8 *)OtherText_Deepseatooth, 0}, + {(u8 *)OtherText_Deepseascale, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_47[] = +{ + {(u8 *)OtherText_BlueFlute2, 0}, + {(u8 *)OtherText_YellowFlute2, 0}, + {(u8 *)OtherText_RedFlute2, 0}, + {(u8 *)OtherText_WhiteFlute2, 0}, + {(u8 *)OtherText_BlackFlute2, 0}, + {(u8 *)OtherText_GlassChair, 0}, + {(u8 *)OtherText_GlassDesk, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_48[] = +{ + {(u8 *)OtherText_TreeckoDoll, 0}, + {(u8 *)OtherText_TorchicDoll, 0}, + {(u8 *)OtherText_MudkipDoll, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_55[] = +{ + {(u8 *)OtherText_TM32, 0}, + {(u8 *)OtherText_TM29, 0}, + {(u8 *)OtherText_TM35, 0}, + {(u8 *)OtherText_TM24, 0}, + {(u8 *)OtherText_TM13, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_49[] = +{ + {(u8 *)OtherText_50Coins, 0}, + {(u8 *)OtherText_500Coins, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_50[] = +{ + {(u8 *)OtherText_Excellent, 0}, + {(u8 *)OtherText_NotSoHot, 0}, +}; + +const struct MenuAction MultichoiceList_52[] = +{ + {(u8 *)OtherText_Lilycove, 0}, + {(u8 *)OtherText_BattleTower, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_53[] = +{ + {(u8 *)OtherText_Slateport, 0}, + {(u8 *)OtherText_Lilycove, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_54[] = +{ + {(u8 *)OtherText_Right, 0}, + {(u8 *)OtherText_Left, 0}, +}; + +const struct MenuAction MultichoiceList_56[] = +{ + {(u8 *)OtherText_Slateport, 0}, + {(u8 *)OtherText_BattleTower, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_57[] = +{ + {(u8 *)OtherText_1F_2, 0}, + {(u8 *)OtherText_2F_2, 0}, + {(u8 *)OtherText_3F_2, 0}, + {(u8 *)OtherText_4F_2, 0}, + {(u8 *)OtherText_5F_2, 0}, +}; + +const struct MenuAction MultichoiceList_58[] = +{ + {(u8 *)OtherText_RedShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_59[] = +{ + {(u8 *)OtherText_YellowShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_60[] = +{ + {(u8 *)OtherText_RedShard, 0}, + {(u8 *)OtherText_YellowShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_61[] = +{ + {(u8 *)OtherText_BlueShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_62[] = +{ + {(u8 *)OtherText_RedShard, 0}, + {(u8 *)OtherText_BlueShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_63[] = +{ + {(u8 *)OtherText_YellowShard, 0}, + {(u8 *)OtherText_BlueShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_64[] = +{ + {(u8 *)OtherText_RedShard, 0}, + {(u8 *)OtherText_YellowShard, 0}, + {(u8 *)OtherText_BlueShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_65[] = +{ + {(u8 *)OtherText_GreenShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_66[] = +{ + {(u8 *)OtherText_RedShard, 0}, + {(u8 *)OtherText_GreenShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_67[] = +{ + {(u8 *)OtherText_YellowShard, 0}, + {(u8 *)OtherText_GreenShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_68[] = +{ + {(u8 *)OtherText_RedShard, 0}, + {(u8 *)OtherText_YellowShard, 0}, + {(u8 *)OtherText_GreenShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_69[] = +{ + {(u8 *)OtherText_BlueShard, 0}, + {(u8 *)OtherText_GreenShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_70[] = +{ + {(u8 *)OtherText_RedShard, 0}, + {(u8 *)OtherText_BlueShard, 0}, + {(u8 *)OtherText_GreenShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_71[] = +{ + {(u8 *)OtherText_YellowShard, 0}, + {(u8 *)OtherText_BlueShard, 0}, + {(u8 *)OtherText_GreenShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_72[] = +{ + {(u8 *)OtherText_RedShard, 0}, + {(u8 *)OtherText_YellowShard, 0}, + {(u8 *)OtherText_BlueShard, 0}, + {(u8 *)OtherText_GreenShard, 0}, + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MenuAction MultichoiceList_01[] = +{ + {(u8 *)gOtherText_CancelNoTerminator, 0}, +}; + +const struct MultichoiceListStruct gMultichoiceLists[] = +{ + {(struct MenuAction *)MultichoiceList_00, 3}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_02, 3}, + {(struct MenuAction *)MultichoiceList_03, 4}, + {(struct MenuAction *)MultichoiceList_04, 6}, + {(struct MenuAction *)MultichoiceList_05, 3}, + {(struct MenuAction *)MultichoiceList_06, 4}, + {(struct MenuAction *)MultichoiceList_07, 4}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_12, 2}, + {(struct MenuAction *)MultichoiceList_13, 6}, + {(struct MenuAction *)MultichoiceList_14, 2}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_16, 2}, + {(struct MenuAction *)MultichoiceList_17, 3}, + {(struct MenuAction *)MultichoiceList_18, 4}, + {(struct MenuAction *)MultichoiceList_19, 3}, + {(struct MenuAction *)MultichoiceList_20, 3}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_23, 3}, + {(struct MenuAction *)MultichoiceList_24, 3}, + {(struct MenuAction *)MultichoiceList_25, 3}, + {(struct MenuAction *)MultichoiceList_26, 3}, + {(struct MenuAction *)MultichoiceList_27, 3}, + {(struct MenuAction *)MultichoiceList_28, 3}, + {(struct MenuAction *)MultichoiceList_29, 3}, + {(struct MenuAction *)MultichoiceList_30, 3}, + {(struct MenuAction *)MultichoiceList_31, 3}, + {(struct MenuAction *)MultichoiceList_32, 3}, + {(struct MenuAction *)MultichoiceList_33, 3}, + {(struct MenuAction *)MultichoiceList_34, 3}, + {(struct MenuAction *)MultichoiceList_35, 3}, + {(struct MenuAction *)MultichoiceList_36, 3}, + {(struct MenuAction *)MultichoiceList_37, 3}, + {(struct MenuAction *)MultichoiceList_38, 3}, + {(struct MenuAction *)MultichoiceList_39, 3}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_42, 4}, + {(struct MenuAction *)MultichoiceList_43, 4}, + {(struct MenuAction *)MultichoiceList_44, 4}, + {(struct MenuAction *)MultichoiceList_45, 2}, + {(struct MenuAction *)MultichoiceList_46, 3}, + {(struct MenuAction *)MultichoiceList_47, 8}, + {(struct MenuAction *)MultichoiceList_48, 4}, + {(struct MenuAction *)MultichoiceList_49, 3}, + {(struct MenuAction *)MultichoiceList_50, 2}, + {(struct MenuAction *)MultichoiceList_01, 1}, + {(struct MenuAction *)MultichoiceList_52, 3}, + {(struct MenuAction *)MultichoiceList_53, 3}, + {(struct MenuAction *)MultichoiceList_54, 2}, + {(struct MenuAction *)MultichoiceList_55, 6}, + {(struct MenuAction *)MultichoiceList_56, 3}, + {(struct MenuAction *)MultichoiceList_57, 5}, + {(struct MenuAction *)MultichoiceList_58, 2}, + {(struct MenuAction *)MultichoiceList_59, 2}, + {(struct MenuAction *)MultichoiceList_60, 3}, + {(struct MenuAction *)MultichoiceList_61, 2}, + {(struct MenuAction *)MultichoiceList_62, 3}, + {(struct MenuAction *)MultichoiceList_63, 3}, + {(struct MenuAction *)MultichoiceList_64, 4}, + {(struct MenuAction *)MultichoiceList_65, 2}, + {(struct MenuAction *)MultichoiceList_66, 3}, + {(struct MenuAction *)MultichoiceList_67, 3}, + {(struct MenuAction *)MultichoiceList_68, 4}, + {(struct MenuAction *)MultichoiceList_69, 3}, + {(struct MenuAction *)MultichoiceList_70, 4}, + {(struct MenuAction *)MultichoiceList_71, 4}, + {(struct MenuAction *)MultichoiceList_72, 5} +}; + +const struct TextStruct gUnknown_083CE048[] = +{ + OtherText_Cool2, + OtherText_Beauty3, + OtherText_Cute2, + OtherText_Smart2, + OtherText_Tough2, + OtherText_Normal, + OtherText_Super, + OtherText_Hyper, + OtherText_Master, + OtherText_Cool3, + OtherText_Beauty4, + OtherText_Cute3, + OtherText_Smart3, + OtherText_Tough3, + OtherText_Items, + OtherText_KeyItems, + OtherText_Balls, + OtherText_TMsHMs, + OtherText_Berries, +}; -extern u8 gPCText_PlayersPC[]; -extern u8 gPCText_SomeonesPC[]; -extern u8 gPCText_HallOfFame[]; -extern u8 gPCText_LogOff[]; -extern u8 gPCText_LanettesPC[]; extern u8 gPCText_WhichPCShouldBeAccessed[]; -void DrawMultichoiceMenu(u8, u8, u8, struct MenuAction *list, u8, u8); -void sub_80B53B4(u8, u8, u8, struct MenuAction *list, u8); -void sub_80B52B4(u8); -void sub_80B5230(u8, u8, u8, u8, u8, u8); -void task_yes_no_maybe(u8); -void sub_80B5684(u8); -void CreatePCMenu(void); +extern u16 gScriptResult; + +// field_effect +extern void FreeResourcesAndDestroySprite(struct Sprite *sprite); +extern u8 CreateMonSprite_PicBox(u16, s16, s16, u8); bool8 sub_80B5054(u8 left, u8 top, u8 var3, u8 var4) { @@ -60,7 +601,7 @@ bool8 sub_80B50B0(u8 left, u8 top, u8 var3, u8 var4, u8 var5) } } -u16 GetStringWidthInTilesForScriptMenu(u8 *str) +u16 GetStringWidthInTilesForScriptMenu(const u8 *str) { // each tile on screen is 8x8, so it needs the number of tiles and not pixels, hence the division by 8. return (GetStringWidthGivenWindowConfig((struct WindowConfig *)&gWindowConfig_81E6CE4, str) + 7) / 8; diff --git a/src/script_movement.c b/src/script_movement.c index 781235986..dcd772d5f 100644 --- a/src/script_movement.c +++ b/src/script_movement.c @@ -1,6 +1,7 @@ #include "global.h" #include "asm.h" #include "task.h" +#include "field_map_obj_helpers.h" extern const u32 gBitTable[]; extern u8 *gUnknown_020384F8[]; diff --git a/src/script_pokemon_util_80C4BF0.c b/src/script_pokemon_util_80C4BF0.c new file mode 100644 index 000000000..ba1545861 --- /dev/null +++ b/src/script_pokemon_util_80C4BF0.c @@ -0,0 +1,722 @@ +#include "global.h" +#include "contest.h" +#include "rom4.h" +#include "main.h" +#include "battle.h" +#include "event_data.h" +#include "pokemon.h" +#include "task.h" +#include "menu.h" +#include "decompress.h" +#include "link.h" +#include "rng.h" +#include "pokedex.h" +#include "asm.h" +#include "species.h" +#include "berry.h" +#include "items.h" +#include "load_save.h" +#include "script_pokemon_80C4.h" + +#define CONTEST_ENTRY_PIC_LEFT 10 +#define CONTEST_ENTRY_PIC_TOP 3 + +extern const struct SpriteSheet gMonFrontPicTable[]; +extern struct MonCoords gMonFrontPicCoords[]; + +extern void sub_80C46EC(void); +extern void sub_80C4740(void); +extern void sub_80C48F4(void); +extern void sub_80B2A7C(u8); +extern void sub_80AAF30(void); // matsuda debug? +extern u8 sub_80B2C4C(u8, u8); +extern void CB2_ContestPainting(void); +extern void sub_8042044(struct Pokemon *mon, u16, u8); +extern void sub_8121E10(void); +extern void sub_8121E34(void); + +extern void *gUnknown_081FAF4C[]; +extern struct SpriteTemplate gUnknown_02024E8C; +extern struct SpritePalette *sub_80409C8(u16, u32, u32); + +extern u8 gContestPlayerMonIndex; +extern u8 gIsLinkContest; +extern u8 gPlayerPartyCount; +extern u8 gSelectedOrderFromParty[]; + +extern u16 gSpecialVar_0x8004; +extern u16 gSpecialVar_0x8005; +extern u16 gSpecialVar_0x8006; + +extern u16 gScriptContestCategory; +extern u16 gScriptContestRank; +extern u16 gScriptResult; + +extern u32 gUnknown_03005D28; + +extern u8 gUnknown_02038694; +extern u8 gUnknown_0203856C; +extern u8 gUnknown_02038690[]; +extern u16 gUnknown_02038678[]; + +void sub_80C4BF0(void) +{ + gSaveBlock1.vars[0x10] = gContestMons[0].unk16; + gSaveBlock1.vars[0x11] = gContestMons[1].unk16; + gSaveBlock1.vars[0x12] = gContestMons[2].unk16; +} + +void sub_80C4C28(void) +{ + u16 var; + u8 specialVar = gSpecialVar_0x8005; + + switch(specialVar) + { + case 0: + var = 3; + break; + case 1: + var = 4; + break; + case 2: + var = 5; + break; + default: + var = 100; + break; + } + gSpecialVar_0x8004 = var; +} + +void sub_80C4C64(void) +{ + sub_80C46EC(); + sub_80C4740(); + sub_80C48F4(); +} + +void sub_80C4C78(void) +{ + u16 var; + u16 returnVar; + + switch(gScriptContestCategory) + { + case 0: + var = 8; + break; + case 1: + var = 9; + break; + case 2: + var = 10; + break; + case 3: + var = 11; + break; + case 4: + default: + var = 12; + break; + } + + returnVar = gSaveBlock1.sbStruct.unkSB2.sb1_2EFC_struct2[var].var; + + if(returnVar == 0) + gSpecialVar_0x8004 = returnVar; + else + gSpecialVar_0x8004 = 1; +} + +void sub_80C4CEC(void) +{ + sub_80B2A7C(0xFF); +} + +void sub_80C4CF8(void) +{ + if(!gUnknown_02038690[gContestPlayerMonIndex] + && gScriptContestRank == 3 + && (s16)gUnknown_02038678[gContestPlayerMonIndex] >= 800) + { + gSpecialVar_0x8004 = 1; + } + else + { + gSpecialVar_0x8004 = 0; + } +} + +u8 sub_80C4D50(void) +{ + u8 retVar = 0; + int i; + + for (i = 0; i < 5; i++) + if (gSaveBlock1.sbStruct.unkSB2.sb1_2EFC_struct2[i + 8].var) + retVar++; + + return retVar; +} + +// nope. too hard +__attribute__((naked)) +void sub_80C4D80(void) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x8\n\ + ldr r0, _080C4EA0 @ =gUnknown_02038670\n\ + mov r12, r0\n\ + ldr r1, _080C4EA4 @ =gSpecialVar_0x8006\n\ + mov r8, r1\n\ + ldr r2, _080C4EA8 @ =gStringVar1\n\ + mov r9, r2\n\ + mov r2, r12\n\ + mov r1, sp\n\ + movs r6, 0x3\n\ +_080C4D9E:\n\ + ldrh r0, [r2]\n\ + strh r0, [r1]\n\ + adds r2, 0x2\n\ + adds r1, 0x2\n\ + subs r6, 0x1\n\ + cmp r6, 0\n\ + bge _080C4D9E\n\ + movs r6, 0\n\ +_080C4DAE:\n\ + movs r1, 0x3\n\ + cmp r1, r6\n\ + ble _080C4DD8\n\ +_080C4DB4:\n\ + subs r4, r1, 0x1\n\ + lsls r0, r4, 1\n\ + mov r5, sp\n\ + adds r3, r5, r0\n\ + lsls r0, r1, 1\n\ + adds r2, r5, r0\n\ + ldrh r5, [r3]\n\ + movs r7, 0\n\ + ldrsh r1, [r3, r7]\n\ + movs r7, 0\n\ + ldrsh r0, [r2, r7]\n\ + cmp r1, r0\n\ + bge _080C4DD2\n\ + strh r5, [r2]\n\ + strh r0, [r3]\n\ +_080C4DD2:\n\ + adds r1, r4, 0\n\ + cmp r1, r6\n\ + bgt _080C4DB4\n\ +_080C4DD8:\n\ + adds r6, 0x1\n\ + cmp r6, 0x2\n\ + ble _080C4DAE\n\ + mov r2, r8\n\ + ldrh r0, [r2]\n\ + lsls r0, 1\n\ + add r0, sp\n\ + ldrh r0, [r0]\n\ + movs r2, 0\n\ + movs r7, 0\n\ + movs r6, 0\n\ + lsls r0, 16\n\ + asrs r4, r0, 16\n\ + adds r3, r0, 0\n\ + mov r1, sp\n\ +_080C4DF6:\n\ + movs r5, 0\n\ + ldrsh r0, [r1, r5]\n\ + cmp r0, r4\n\ + bne _080C4E12\n\ + lsls r0, r2, 24\n\ + movs r2, 0x80\n\ + lsls r2, 17\n\ + adds r0, r2\n\ + lsrs r2, r0, 24\n\ + mov r5, r8\n\ + ldrh r5, [r5]\n\ + cmp r6, r5\n\ + bne _080C4E12\n\ + adds r7, r2, 0\n\ +_080C4E12:\n\ + adds r1, 0x2\n\ + adds r6, 0x1\n\ + cmp r6, 0x3\n\ + ble _080C4DF6\n\ + movs r6, 0\n\ + mov r0, sp\n\ + movs r1, 0\n\ + ldrsh r0, [r0, r1]\n\ + asrs r1, r3, 16\n\ + lsls r2, 24\n\ + mov r10, r2\n\ + cmp r0, r1\n\ + beq _080C4E40\n\ + adds r2, r1, 0\n\ + mov r1, sp\n\ +_080C4E30:\n\ + adds r1, 0x2\n\ + adds r6, 0x1\n\ + cmp r6, 0x3\n\ + bgt _080C4E40\n\ + movs r4, 0\n\ + ldrsh r0, [r1, r4]\n\ + cmp r0, r2\n\ + bne _080C4E30\n\ +_080C4E40:\n\ + lsls r0, r6, 24\n\ + lsrs r4, r0, 24\n\ + adds r2, r7, 0\n\ + movs r6, 0\n\ + asrs r5, r3, 16\n\ + mov r8, r5\n\ + mov r1, r12\n\ + movs r5, 0\n\ + ldrsh r0, [r1, r5]\n\ + cmp r8, r0\n\ + bne _080C4E60\n\ + cmp r7, 0x1\n\ + beq _080C4E78\n\ +_080C4E5A:\n\ + subs r0, r2, 0x1\n\ + lsls r0, 24\n\ + lsrs r2, r0, 24\n\ +_080C4E60:\n\ + adds r6, 0x1\n\ + cmp r6, 0x3\n\ + bgt _080C4E78\n\ + lsls r0, r6, 1\n\ + add r0, r12\n\ + asrs r1, r3, 16\n\ + movs r5, 0\n\ + ldrsh r0, [r0, r5]\n\ + cmp r1, r0\n\ + bne _080C4E60\n\ + cmp r2, 0x1\n\ + bne _080C4E5A\n\ +_080C4E78:\n\ + lsls r1, r6, 24\n\ + lsrs r1, 24\n\ + mov r0, r9\n\ + bl sub_80C4698\n\ + ldr r0, _080C4EAC @ =gIsLinkContest\n\ + ldrb r1, [r0]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080C4EB8\n\ + ldr r0, _080C4EB0 @ =gStringVar2\n\ + lsls r1, r6, 3\n\ + subs r1, r6\n\ + lsls r1, 2\n\ + ldr r2, _080C4EB4 @ =gLinkPlayers + 0x8\n\ + adds r1, r2\n\ + bl sub_80C4674\n\ + b _080C4EC4\n\ + .align 2, 0\n\ +_080C4EA0: .4byte gUnknown_02038670\n\ +_080C4EA4: .4byte gSpecialVar_0x8006\n\ +_080C4EA8: .4byte gStringVar1\n\ +_080C4EAC: .4byte gIsLinkContest\n\ +_080C4EB0: .4byte gStringVar2\n\ +_080C4EB4: .4byte gLinkPlayers + 0x8\n\ +_080C4EB8:\n\ + ldr r0, _080C4ED8 @ =gStringVar2\n\ + lsls r1, r6, 6\n\ + ldr r2, _080C4EDC @ =gUnknown_0203857D\n\ + adds r1, r2\n\ + bl sub_80C4674\n\ +_080C4EC4:\n\ + mov r1, r10\n\ + asrs r0, r1, 24\n\ + cmp r0, 0x1\n\ + beq _080C4ED0\n\ + cmp r7, r0\n\ + bne _080C4EE4\n\ +_080C4ED0:\n\ + ldr r0, _080C4EE0 @ =gSpecialVar_0x8006\n\ + strh r4, [r0]\n\ + b _080C4EEA\n\ + .align 2, 0\n\ +_080C4ED8: .4byte gStringVar2\n\ +_080C4EDC: .4byte gUnknown_0203857D\n\ +_080C4EE0: .4byte gSpecialVar_0x8006\n\ +_080C4EE4:\n\ + ldr r1, _080C4EFC @ =gSpecialVar_0x8006\n\ + adds r0, r4, 0x4\n\ + strh r0, [r1]\n\ +_080C4EEA:\n\ + add sp, 0x8\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_080C4EFC: .4byte gSpecialVar_0x8006\n\ + .syntax divided"); +} + +void ShowContestWinnerCleanup(void) +{ + SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); +} + +void ShowContestWinner(void) +{ + if(gUnknown_0203856C) + { + sub_80AAF30(); + BATTLE_STRUCT->unk15DDF = 1; + BATTLE_STRUCT->unk15DDE = sub_80B2C4C(254, 0); + sub_80B2A7C(3); + gUnknown_0203856C = 0; + } + SetMainCallback2(CB2_ContestPainting); + gMain.savedCallback = ShowContestWinnerCleanup; +} + +void sub_80C4F70(void) +{ + VarSet(0x4010, gContestMons[0].unk16); + VarSet(0x4011, gContestMons[1].unk16); + VarSet(0x4012, gContestMons[2].unk16); + VarSet(0x4013, gContestMons[3].unk16); +} + +bool8 GiveMonArtistRibbon(void) +{ + u8 ribbon = GetMonData(&gPlayerParty[gUnknown_02038694], MON_DATA_ARTIST_RIBBON); + + if(ribbon == FALSE + && gUnknown_02038690[gContestPlayerMonIndex] == 0 + && gScriptContestRank == 3 + && (s16)gUnknown_02038678[gContestPlayerMonIndex] >= 800) + { + ribbon = TRUE; + SetMonData(&gPlayerParty[gUnknown_02038694], MON_DATA_ARTIST_RIBBON, &ribbon); + return TRUE; + } + else + { + return FALSE; + } +} + +u8 sub_80C5044(void) +{ + return gUnknown_0203856C; +} + +void ShowContestEntryMonPic(void) +{ + struct SpritePalette *paletteData; + u32 var1, var2; + u16 species; + u8 spriteId; + u8 taskId; + + if(FindTaskIdByFunc(sub_80C5190) == 0xFF) + { + u8 left = CONTEST_ENTRY_PIC_LEFT; + u8 top = CONTEST_ENTRY_PIC_TOP; + + MenuDrawTextWindow(left, top, 19, 13); + species = gContestMons[gSpecialVar_0x8006].species; + var1 = gContestMons[gSpecialVar_0x8006].unk38; // v2 + var2 = gContestMons[gSpecialVar_0x8006].unk3C; // v3 + taskId = CreateTask(sub_80C5190, 0x50); + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = species; + HandleLoadSpecialPokePic((struct SpriteSheet *)&gMonFrontPicTable[species].data, + gMonFrontPicCoords[species].x, gMonFrontPicCoords[species].y, + (u32)gUnknown_081FAF4C[0], gUnknown_081FAF4C[1], species, var1); + paletteData = sub_80409C8(species, var2, var1); + LoadCompressedObjectPalette(paletteData); + GetMonSpriteTemplate_803C56C(species, 1); + gUnknown_02024E8C.paletteTag = paletteData->tag; + spriteId = CreateSprite(&gUnknown_02024E8C, 0x78, 0x40, 0); + gTasks[taskId].data[2] = spriteId; + gTasks[taskId].data[3] = left; + gTasks[taskId].data[4] = top; + gSprites[spriteId].callback = SpriteCallbackDummy; + gSprites[spriteId].oam.priority = 0; + } +} + +void sub_80C5164(void) +{ + u8 taskId = FindTaskIdByFunc(sub_80C5190); + + if(taskId != 0xFF) + gTasks[taskId].data[0]++; +} + +void sub_80C5190(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + struct Sprite *sprite; + + switch(task->data[0]) + { + case 2: + sprite = &gSprites[task->data[2]]; + FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(sprite->oam.paletteNum)); + + if(sprite->oam.affineMode) + FreeOamMatrix(sprite->oam.matrixNum); + + DestroySprite(sprite); + task->data[0]++; + break; + case 0: + task->data[0]++; + break; + case 3: + MenuZeroFillWindowRect(task->data[3], task->data[4], task->data[3] + 9, task->data[4] + 10); + DestroyTask(taskId); + break; + case 1: + default: + break; + } +} + +void ScriptGetMultiplayerId(void) +{ + if(gIsLinkContest & 1) + gScriptResult = GetMultiplayerId(); + else + gScriptResult = 4; +} + +void ScriptRandom(void) +{ + u16 random; + u16 *scriptPtr; + + if(gIsLinkContest & 1) + { + gUnknown_03005D28 = 1103515245 * gUnknown_03005D28 + 24691; + random = gUnknown_03005D28 >> 16; + scriptPtr = &gScriptResult; + } + else + { + scriptPtr = &gScriptResult; + random = Random(); + } + *scriptPtr = random % *scriptPtr; +} + +void HealPlayerParty(void) +{ + u8 i, j; + u8 ppBonuses; + u8 arg[4]; + + // restore HP. + for(i = 0; i < gPlayerPartyCount; i++) + { + u16 maxHP = GetMonData(&gPlayerParty[i], MON_DATA_MAX_HP); + arg[0] = maxHP; + arg[1] = maxHP >> 8; + SetMonData(&gPlayerParty[i], MON_DATA_HP, arg); + ppBonuses = GetMonData(&gPlayerParty[i], MON_DATA_PP_BONUSES); + + // restore PP. + for(j = 0; j < 4; j++) + { + arg[0] = CalculatePPWithBonus(GetMonData(&gPlayerParty[i], MON_DATA_MOVE1 + j), ppBonuses, j); + SetMonData(&gPlayerParty[i], MON_DATA_PP1 + j, arg); + } + + // since status is u32, the four 0 assignments here are probably for safety to prevent undefined data from reaching SetMonData. + arg[0] = 0; + arg[1] = 0; + arg[2] = 0; + arg[3] = 0; + SetMonData(&gPlayerParty[i], MON_DATA_STATUS, arg); + } +} + +u8 ScriptGiveMon(u16 species, u8 var, u16 item, u32 var3, u32 var4, u8 var5) +{ + u16 nationalSpecies; + int sentToPc; + u8 array[2]; + struct Pokemon mon; + + CreateMon(&mon, species, var, 32, 0, 0, 0, 0); + array[0] = item; + array[1] = item >> 8; + SetMonData(&mon, MON_DATA_HELD_ITEM, array); + sentToPc = GiveMonToPlayer(&mon); + nationalSpecies = SpeciesToNationalPokedexNum(species); + + // nested if check to fool compiler + if(sentToPc < 2) + { + if(sentToPc >= 0) + { + // set both the seen and caught flags + sub_8090D90(nationalSpecies, 2); + sub_8090D90(nationalSpecies, 3); + } + } + return sentToPc; +} + +u8 ScriptGiveEgg(u16 value) +{ + struct Pokemon mon; + u8 data; + + sub_8042044(&mon, value, 1); + data = 1; + SetMonData(&mon, MON_DATA_IS_EGG, &data); + + return GiveMonToPlayer(&mon); +} + +void CheckForAlivePartyMons(void) +{ + u8 var = sub_803DAA0(); + + switch(var) + { + case 1: + gScriptResult = var; + break; + case 0: + gScriptResult = var; + break; + case 2: + gScriptResult = var; + break; + } +} + +bool8 CheckPartyMonHasHeldItem(u16 item) +{ + int i; + + for(i = 0; i < 6; i++) + { + u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + if(species != SPECIES_NONE && species != SPECIES_EGG && GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) == item) + return TRUE; + } + return FALSE; +} + +bool8 GetNameOfEnigmaBerryInPlayerParty(void) +{ + bool8 hasItem = CheckPartyMonHasHeldItem(ITEM_ENIGMA_BERRY); + + if(hasItem == TRUE) + GetBerryNameByBerryType(ItemIdToBerryType(ITEM_ENIGMA_BERRY), gStringVar1); + + return hasItem; +} + +void ScriptWildBattle(u16 species, u8 level, u16 item) +{ + u8 data[2]; + + ZeroEnemyPartyMons(); + CreateMon(&gEnemyParty[0], species, level, 0x20, 0, 0, 0, 0); + + if(item) + { + data[0] = item; + data[1] = item >> 8; + SetMonData(&gEnemyParty[0], MON_DATA_HELD_ITEM, data); + } +} + +void ScriptSetMonMoveSlot(u8 monIndex, u16 move, u8 slot) +{ + if(monIndex > 6) + monIndex = gPlayerPartyCount - 1; + + SetMonMoveSlot(&gPlayerParty[monIndex], move, slot); +} + +void sub_80C5568(void) +{ + gMain.savedCallback = sub_80C5580; + sub_8121E10(); +} + +void sub_80C5580(void) +{ + u8 var = gSelectedOrderFromParty[0]; + + switch(var) + { + case 0: + gScriptResult = 0; + break; + default: + gScriptResult = 1; + break; + } + + SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); +} + +void ChooseBattleTowerPlayerParty(void) +{ + gMain.savedCallback = SetBattleTowerPlayerParty; + sub_8121E34(); +} + +void SetBattleTowerPlayerParty(void) +{ + u8 var = gSelectedOrderFromParty[0]; + + switch(var) + { + case 0: // player quit battle tower? + LoadPlayerParty(); + gScriptResult = 0; + break; + default: // load battle tower. + ReducePlayerPartyToThree(); + gScriptResult = 1; + break; + } + + SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); +} + +void ReducePlayerPartyToThree(void) +{ + struct Pokemon party[3]; + int i; + + CpuFill32(0, party, sizeof party); + + // copy the selected pokemon according to the order. + for(i = 0; i < 3; i++) + if(gSelectedOrderFromParty[i]) // as long as the order keeps going (did the player select 1 mon? 2? 3?), do not stop + party[i] = gPlayerParty[gSelectedOrderFromParty[i] - 1]; // index is 0 based, not literal + + // delete the last 3 pokemon + CpuFill32(0, gPlayerParty, sizeof gPlayerParty); + + // overwrite the first 3 with the order copied to. + for(i = 0; i < 3; i++) + gPlayerParty[i] = party[i]; + + CalculatePlayerPartyCount(); +} diff --git a/src/script_pokemon_util_80F99CC.c b/src/script_pokemon_util_80F99CC.c index 5e57ef84b..1a848c665 100644 --- a/src/script_pokemon_util_80F99CC.c +++ b/src/script_pokemon_util_80F99CC.c @@ -9,6 +9,7 @@ #include "pokemon.h" #include "text.h" #include "string_util.h" +#include "script_pokemon_80F9.h" extern u8 gPlayerPartyCount; extern u16 gSpecialVar_0x8004; @@ -36,18 +37,6 @@ extern void sub_8123138(u8); extern u8 sub_8040574(struct Pokemon *party); extern void sub_809D9F0(struct Pokemon *party, u8, u8, void *, u32); -void sub_80F9A8C(u8); -void sub_80F9C00(void); -void sub_80F9E1C(void); - -struct UnknownStruct2018000 -{ - u8 filler0[0x8]; - u8 unk8; -}; - -extern struct UnknownStruct2018000 unk_2018000; - void sub_80F99CC(void) { u8 taskId; diff --git a/src/start_menu.c b/src/start_menu.c index 9c10c4cae..d1344ce90 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -22,6 +22,7 @@ #include "task.h" #include "trainer_card.h" #include "weather.h" +#include "field_map_obj_helpers.h" //Menu actions enum { @@ -41,7 +42,7 @@ static u8 (*saveDialogCallback)(void); static u8 saveDialogTimer; //Number of frames to keep the window on screen after save was completed static bool8 savingComplete; -extern bool8 gUnknown_020297EC; +extern bool8 gDifferentSaveFile; extern u16 gSaveFileStatus; extern u16 gScriptResult; extern u8 (*gCallback_03004AE8)(void); @@ -586,7 +587,6 @@ static u8 SaveDialogCB_DisplayConfirmMessage(void) { MenuZeroFillScreen(); HandleDrawSaveWindowInfo(0, 0); - //"Would you like to save the game?" DisplaySaveMessageWithCallback(gSaveText_WouldYouLikeToSave, SaveDialogCB_DisplayConfirmYesNoMenu); return SAVE_IN_PROGRESS; } @@ -608,7 +608,7 @@ static u8 SaveDialogCB_ProcessConfirmYesNoMenu(void) { case 0: case 2: - if (gUnknown_020297EC == FALSE) + if (gDifferentSaveFile == FALSE) { saveDialogCallback = SaveDialogCB_SaveFileExists; return SAVE_IN_PROGRESS; @@ -632,7 +632,7 @@ static u8 SaveDialogCB_ProcessConfirmYesNoMenu(void) static u8 SaveDialogCB_SaveFileExists(void) { DisplaySaveMessageWithCallback( - gUnknown_020297EC == TRUE ? gSaveText_ThereIsADifferentFile : gSaveText_ThereIsAlreadyAFile, + gDifferentSaveFile == TRUE ? gSaveText_ThereIsADifferentFile : gSaveText_ThereIsAlreadyAFile, SaveDialogCB_DisplayOverwriteYesNoMenu); return SAVE_IN_PROGRESS; } @@ -670,20 +670,20 @@ static u8 SaveDialogCB_DisplaySavingMessage(void) static u8 SaveDialogCB_DoSave(void) { - u8 a; + bool8 saveSucceeded; IncrementGameStat(0); - if (gUnknown_020297EC == TRUE) + if (gDifferentSaveFile == TRUE) { - a = sub_8125D44(4); - gUnknown_020297EC = FALSE; + saveSucceeded = TrySavingData(DIFFERENT_FILE_SAVE); + gDifferentSaveFile = FALSE; } else { - a = sub_8125D44(0); + saveSucceeded = TrySavingData(NORMAL_SAVE); } - if (a == 1) + if (saveSucceeded == TRUE) { //"(Player) saved the game." DisplaySaveMessageWithCallback(gSaveText_PlayerSavedTheGame, SaveDialogCB_SaveSuccess); diff --git a/src/strings.c b/src/strings.c new file mode 100644 index 000000000..fed0c86e2 --- /dev/null +++ b/src/strings.c @@ -0,0 +1,923 @@ +#include "global.h" + +// placeholder strings +const u8 gExpandedPlaceholder_Empty[] = _(""); +const u8 gExpandedPlaceholder_Kun[] = _(""); +const u8 gExpandedPlaceholder_Chan[] = _(""); +const u8 gExpandedPlaceholder_Sapphire[] = _("SAPPHIRE"); +const u8 gExpandedPlaceholder_Ruby[] = _("RUBY"); +const u8 gExpandedPlaceholder_Aqua[] = _("AQUA"); +const u8 gExpandedPlaceholder_Magma[] = _("MAGMA"); +const u8 gExpandedPlaceholder_Archie[] = _("ARCHIE"); +const u8 gExpandedPlaceholder_Maxie[] = _("MAXIE"); +const u8 gExpandedPlaceholder_Kyogre[] = _("KYOGRE"); +const u8 gExpandedPlaceholder_Groudon[] = _("GROUDON"); +const u8 gExpandedPlaceholder_Brendan[] = _("BRENDAN"); +const u8 gExpandedPlaceholder_May[] = _("MAY"); + +// system text +const u8 gSystemText_Egg[] = _("EGG"); +const u8 gSystemText_Pokemon2[] = _("POKéMON"); + +// main menu text +const u8 gMainMenuString_NewGame[] = _("NEW GAME"); +const u8 gMainMenuString_Continue[] = _("CONTINUE"); +const u8 gMainMenuString_Option[] = _("OPTION"); +const u8 gMainMenuString_MysteryEvents[] = _("MYSTERY EVENTS"); + +// system text 2 +const u8 SystemText_UpdatingSaveExternal[] = _("Updating save file using external\ndata. Please wait."); +const u8 SystemText_SaveUpdated[] = _("The save file has been updated."); +const u8 SystemText_SaveUpdatedExchangeBackup[] = _("The save file has been updated.\pFurther game data cannot be saved\nto the backup memory.\pPlease exchange the backup memory.\pFor details, please contact the\nNintendo Service Center."); +const u8 SystemText_SaveNotUpdated[] = _("The save file could not be updated.\pPlease exchange the backup\nmemory.\pFor details, please contact the\nNintendo Service Center."); + +// save file text +const u8 gSaveFileCorruptMessage[] = _("The save file is corrupt. The\nprevious save file will be loaded."); +const u8 gSaveFileDeletedMessage[] = _(" The save file has been deleted..."); + +// system text 3 +const u8 gBoardNotInstalledMessage[] = _("The 1M sub-circuit board is\nnot installed."); +const u8 gBatteryDryMessage[] = _("The internal battery has run dry.\nThe game can be played.\pHowever, clock-based events will\nno longer occur."); + +// main menu text 2 +const u8 gMainMenuString_Player[] = _("PLAYER"); +const u8 gMainMenuString_Pokedex[] = _("POKéDEX"); +const u8 gMainMenuString_Time[] = _("TIME"); +const u8 gMainMenuString_Badges[] = _("BADGES"); + +// birch text +const u8 gBirchText_Boy[] = _("BOY"); +const u8 gBirchText_Girl[] = _("GIRL"); +const u8 gBirchText_NewName[] = _("NEW NAME"); + +#ifdef SAPPHIRE +const u8 gDefaultBoyName1[] = _("SEAN"); +#else +const u8 gDefaultBoyName1[] = _("LANDON"); +#endif +const u8 gDefaultBoyName2[] = _("TERRY"); +const u8 gDefaultBoyName3[] = _("SETH"); +const u8 gDefaultBoyName4[] = _("TOM"); + +#ifdef SAPPHIRE +const u8 gDefaultGirlName1[] = _("MARINA"); +#else +const u8 gDefaultGirlName1[] = _("TERRA"); +#endif +const u8 gDefaultGirlName2[] = _("KIMMY"); +const u8 gDefaultGirlName3[] = _("NICOLA"); +const u8 gDefaultGirlName4[] = _("SARA"); + +const u8 gSystemText_IntroWeCall[] = _("This is what we call\na POKéMON."); +const u8 gSystemText_NewPara[] = _("\p"); + +const u8 gDexText_UnknownPoke[] = _(" ????? POKéMON"); +const u8 gDexText_UnknownHeight[] = _("{CLEAR_TO 0x0C}??’??”"); +const u8 gDexText_UnknownWeight[] = _("????.? lbs.$"); // extra terminator? +const u8 gDexText_CryOf[] = _("{CLEAR_TO 2}CRY OF$"); // extra terminator? +const u8 gDexText_SizeComparedTo[] = _("SIZE COMPARED TO "); +const u8 gDexText_RegisterComplete[] = _("POKéDEX registration completed."); +const u8 gDexText_Searching[] = _("Searching...\nPlease wait."); +const u8 gDexText_SearchComplete[] = _("Search completed."); +const u8 gDexText_NoMatching[] = _("No matching POKéMON were found."); + +const u8 DexText_SearchForPoke[] = _("Search for POKéMON based on\nselected parameters."); +const u8 DexText_SwitchDex[] = _("Switch POKéDEX listings."); +const u8 DexText_ReturnToDex[] = _("Return to the POKéDEX."); +const u8 DexText_SelectDexMode[] = _("Select the POKéDEX mode."); +const u8 DexText_SelectDexList[] = _("Select the POKéDEX listing mode."); +const u8 DexText_ListByABC[] = _("List by the first letter in the name.\n/Spotted POKéMON only."); +const u8 DexText_ListByColor[] = _("List by body color.\n/Spotted POKéMON only."); +const u8 DexText_ListByType[] = _("List by type.\n/Owned POKéMON only."); +const u8 DexText_ExecuteSearchSwitch[] = _("Execute search/switch."); +const u8 DexText_HoennDex[] = _("HOENN DEX"); +const u8 DexText_NationalDex[] = _("NATIONAL DEX"); +const u8 DexText_NumericalMode[] = _("NUMERICAL MODE"); +const u8 DexText_ABCMode[] = _("A TO Z MODE"); +const u8 DexText_HeaviestMode[] = _("HEAVIEST MODE"); +const u8 DexText_LightestMode[] = _("LIGHTEST MODE"); +const u8 DexText_TallestMode[] = _("TALLEST MODE"); +const u8 DexText_SmallestMode[] = _("SMALLEST MODE"); +const u8 DexText_ABC[] = _("ABC"); +const u8 DexText_DEF[] = _("DEF"); +const u8 DexText_GHI[] = _("GHI"); +const u8 DexText_JKL[] = _("JKL"); +const u8 DexText_MNO[] = _("MNO"); +const u8 DexText_PQR[] = _("PQR"); +const u8 DexText_STU[] = _("STU"); +const u8 DexText_VWX[] = _("VWX"); +const u8 DexText_YZ[] = _("YZ"); +const u8 DexText_Red[] = _("RED"); +const u8 DexText_Blue[] = _("BLUE"); +const u8 DexText_Yellow[] = _("YELLOW"); +const u8 DexText_Green[] = _("GREEN"); +const u8 DexText_Black[] = _("BLACK"); +const u8 DexText_Brown[] = _("BROWN"); +const u8 DexText_Purple[] = _("PURPLE"); +const u8 DexText_Gray[] = _("GRAY"); +const u8 DexText_White[] = _("WHITE"); +const u8 DexText_Pink[] = _("PINK"); +const u8 DexText_HoennDex2[] = _("HOENN region’s POKéDEX"); +const u8 DexText_NationalDex2[] = _("National edition POKéDEX"); +const u8 DexText_ListByNumber[] = _("POKéMON are listed according to their\nnumber."); +const u8 DexText_ListByABC2[] = _("Spotted and owned POKéMON are listed\nalphabetically."); +const u8 DexText_ListByHeavyToLightest[] = _("Owned POKéMON are listed from the\nheaviest to the lightest."); +const u8 DexText_ListByLightToHeaviest[] = _("Owned POKéMON are listed from the\nlightest to the heaviest."); +const u8 DexText_ListByTallToSmallest[] = _("Owned POKéMON are listed from the\ntallest to the smallest."); +const u8 DexText_ListBySmallToTallest[] = _("Owned POKéMON are listed from the\nsmallest to the tallest."); +const u8 DexText_Terminator5[] = _(""); +const u8 DexText_DontSpecify[] = _("DON’T SPECIFY."); +const u8 DexText_None[] = _("NONE"); +const u8 DexText_RightPointingTriangle[] = _("▶"); // right pointing triangle +const u8 DexText_Terminator6[] = _(" "); + +const u8 gMenuText_WelcomeToHOFAndDexRating[] = _("Welcome to the HALL OF FAME!$Spotted POKéMON: {STR_VAR_1}!\nOwned POKéMON: {STR_VAR_2}!\pPROF. BIRCH’s POKéDEX rating!\pPROF. BIRCH: Let’s see...\p"); +const u8 gMenuText_HOFSaving[] = _("SAVING...\nDON’T TURN OFF THE POWER."); +const u8 gMenuText_HOFCorrupt[] = _("The HALL OF FAME data is corrupt."); +const u8 gMenuText_HOFNumber[] = _("HALL OF FAME No. "); +const u8 gMenuText_HOFCongratulations[] = _("LEAGUE CHAMPION!\nCONGRATULATIONS!"); + +const u8 gOtherText_Number2[] = _("No. "); +const u8 gOtherText_Level3[] = _("Lv. "); +const u8 gOtherText_IDNumber[] = _("IDNo. /"); +const u8 gOtherText_Name[] = _("NAME /"); +const u8 gOtherText_IDNumber2[] = _("IDNo. /"); +const u8 gOtherText_BirchInTrouble[] = _("{HIGHLIGHT WHITE2}{COLOR DARK_GREY}PROF. BIRCH is in trouble!\nRelease a POKéMON and rescue him!"); +const u8 gOtherText_DoYouChoosePoke[] = _("{HIGHLIGHT WHITE2}{COLOR DARK_GREY}Do you choose this POKéMON?"); +const u8 gOtherText_Poke[] = _("POKéMON"); + +const u8 gSystemText_SaveErrorExchangeBackup[] = _("Save error.\pPlease exchange the\nbackup memory."); +const u8 gOtherText_FlyToWhere[] = _("FLY to where?"); + +const u8 OtherText_Use[] = _("USE"); +const u8 OtherText_Toss[] = _("TOSS"); +const u8 OtherText_Register[] = _("REGISTER"); +const u8 OtherText_Give2[] = _("GIVE"); +const u8 OtherText_CheckTag[] = _("CHECK TAG"); +const u8 OtherText_Confirm[] = _("CONFIRM"); +const u8 gOtherText_Walk[] = _("WALK"); + +const u8 gUnknownText_Exit[] = _("EXIT"); +const u8 gOtherText_CancelNoTerminator[] = _("CANCEL"); +const u8 gOtherText_CancelWithTerminator[] = _("$CANCEL"); // with terminator at beginning? + +const u8 OtherText_Item[] = _("ITEM"); +const u8 OtherText_Mail[] = _("MAIL"); +const u8 OtherText_Take2[] = _("TAKE"); +const u8 OtherText_Store[] = _("STORE"); + +const u8 gOtherText_Check[] = _("CHECK"); +const u8 gOtherText_None[] = _("NONE"); + +const u8 gOtherText_ThreeQuestions2[] = _("???"); + +const u8 gOtherText_FiveQuestionsAndSlash[] = _("?????$/"); + +const u8 gOtherText_OneDash[] = _("-"); +const u8 gOtherText_TwoDashes[] = _("--"); +const u8 gOtherText_ThreeDashes2[] = _("---"); +const u8 gOtherText_MaleSymbol2[] = _("♂"); +const u8 gOtherText_FemaleSymbolAndLv[] = _("♀$Lv."); +const u8 gOtherText_TallPlusAndRightArrow[] = _("{TALL_PLUS}${RIGHT_ARROW}"); +const u8 gMenuText_GoBackToPrev[] = _("Go back to the\nprevious menu."); +const u8 gOtherText_WhatWillYouDo[] = _("What would you like to do?"); + +const u8 gOtherText_xString1[] = _("×{STR_VAR_1}"); +const u8 gOtherText_Berry2[] = _(" BERRY"); +const u8 gOtherText_Coins2[] = _("{STR_VAR_1} COINS"); +const u8 gOtherText_CloseBag[] = _("CLOSE BAG"); + +const u8 OtherText_TheField3[] = _("the field."); +const u8 OtherText_TheBattle[] = _("the battle."); +const u8 OtherText_ThePokeList[] = _("the POKéMON LIST."); +const u8 OtherText_TheShop[] = _("the shop."); +const u8 OtherText_TheField[] = _("the field."); +const u8 OtherText_TheField2[] = _("the field."); +const u8 OtherText_ThePC[] = _("the PC."); + +const struct TextStruct gUnknown_0840E740[7] = +{ + OtherText_TheField3, + OtherText_TheBattle, + OtherText_ThePokeList, + OtherText_TheShop, + OtherText_TheField, + OtherText_TheField2, + OtherText_ThePC, +}; + +const u8 gOtherText_ReturnTo[] = _("Return to"); +const u8 gOtherText_WhatWillYouDo2[] = _("What would you\nlike to do?"); +const u8 gOtherText_CantWriteMail[] = _("You can’t write\nMAIL here."); +const u8 gOtherText_NoPokemon[] = _("There is no\nPOKéMON.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_SwitchWhichItem[] = _("Switch with which\nitem?"); +const u8 gOtherText_CantBeHeld[] = _("{STR_VAR_1} can’t be held."); +const u8 gOtherText_CantBeHeldHere[] = _("{STR_VAR_1} can’t be held here."); +const u8 gOtherText_HowManyToDeposit[] = _("How many do you\nwant to deposit?"); +const u8 gOtherText_DepositedItems[] = _("Deposited {STR_VAR_2}\n{STR_VAR_1}(s)."); +const u8 gOtherText_NoRoomForItems[] = _("There’s no room to\nstore items."); +const u8 gOtherText_CantStoreSomeoneItem[] = _("You can’t store\nsomeone else’s item\nin the PC."); +const u8 gOtherText_TooImportant[] = _("That’s much too\nimportant to toss\nout!"); +const u8 gOtherText_HowManyToToss[] = _("Toss out how many?"); +const u8 gOtherText_ThrewAwayItem[] = _("Threw away {STR_VAR_2}\n{STR_VAR_1}(s)."); +const u8 gOtherText_OkayToThrowAwayPrompt[] = _("Is it okay to\nthrow away {STR_VAR_2}\n{STR_VAR_1}(s)?"); +const u8 gOtherText_DadsAdvice[] = _("DAD’s advice...\n{PLAYER}, there’s a time and place for\leverything!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_CantGetOffBike[] = _("You can’t dismount your BIKE here.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ItemfinderResponding[] = _("Oh!\nThe machine’s responding!\pThere’s an item buried around here!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ItemfinderItemUnderfoot[] = _("The machine’s indicating something\nright underfoot!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_NoResponse[] = _("... ... ... ... Nope!\nThere’s no response.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_Coins3[] = _("Your COINS:\n{STR_VAR_1}{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_BootedTM[] = _("Booted up a TM."); +const u8 gOtherText_BootedHM[] = _("Booted up an HM."); +const u8 gOtherText_ContainsMove[] = _("It contained\n{STR_VAR_1}.\pTeach {STR_VAR_1}\nto a POKéMON?"); +const u8 gOtherText_UsedItem[] = _("{PLAYER} used the\n{STR_VAR_2}.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_RepelLingers[] = _("But the effects of a REPEL lingered\nfrom earlier.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_UsedFlute[] = _("{PLAYER} used the\n{STR_VAR_2}.\pWild POKéMON will be lured.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_UsedRepel[] = _("{PLAYER} used the\n{STR_VAR_2}.\pWild POKéMON will be repelled.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_BoxIsFull[] = _("The BOX is full.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_Size[] = _("SIZE /"); +const u8 gOtherText_Firm[] = _("FIRM /"); + +const u8 gContestStatsText_Unknown1[] = _("{STR_VAR_1}.{STR_VAR_2}”"); + +const u8 ContestStatsText_VerySoft[] = _("Very soft"); +const u8 ContestStatsText_Soft[] = _("Soft"); +const u8 ContestStatsText_Hard[] = _("Hard"); +const u8 ContestStatsText_VeryHard[] = _("Very hard"); +const u8 ContestStatsText_SuperHard[] = _("Super hard"); + +const u8 ContestStatsText_RedPokeBlock[] = _("RED {POKEBLOCK}"); +const u8 ContestStatsText_BluePokeBlock[] = _("BLUE {POKEBLOCK}"); +const u8 ContestStatsText_PinkPokeBlock[] = _("PINK {POKEBLOCK}"); +const u8 ContestStatsText_GreenPokeBlock[] = _("GREEN {POKEBLOCK}"); +const u8 ContestStatsText_YellowPokeBlock[] = _("YELLOW {POKEBLOCK}"); +const u8 ContestStatsText_PurplePokeBlock[] = _("PURPLE {POKEBLOCK}"); +const u8 ContestStatsText_IndigoPokeBlock[] = _("INDIGO {POKEBLOCK}"); +const u8 ContestStatsText_BrownPokeBlock[] = _("BROWN {POKEBLOCK}"); +const u8 ContestStatsText_LiteBluePokeBlock[] = _("LITEBLUE {POKEBLOCK}"); +const u8 ContestStatsText_OlivePokeBlock[] = _("OLIVE {POKEBLOCK}"); +const u8 ContestStatsText_GrayPokeBlock[] = _("GRAY {POKEBLOCK}"); +const u8 ContestStatsText_BlackPokeBlock[] = _("BLACK {POKEBLOCK}"); +const u8 ContestStatsText_WhitePokeBlock[] = _("WHITE {POKEBLOCK}"); +const u8 ContestStatsText_GoldPokeBlock[] = _("GOLD {POKEBLOCK}"); + +const u8 gContestStatsText_Spicy[] = _("SPICY"); +const u8 gContestStatsText_Dry[] = _("DRY"); +const u8 gContestStatsText_Sweet[] = _("SWEET"); +const u8 gContestStatsText_Bitter[] = _("BITTER"); +const u8 gContestStatsText_Sour[] = _("SOUR$TASTY$FEEL"); // tasty is unused, feel might not be + +const u8 gContestStatsText_StowCase[] = _("Stow CASE."); +const u8 gContestStatsText_ThrowAwayPrompt[] = _("Throw away this\n{STR_VAR_1}?"); +const u8 gContestStatsText_WasThrownAway[] = _("The {STR_VAR_1}\nwas thrown away."); +const u8 gContestStatsText_NormallyAte[] = _("{STR_VAR_1} ate the\n{STR_VAR_2}.{PAUSE_UNTIL_PRESS}"); +const u8 gContestStatsText_HappilyAte[] = _("{STR_VAR_1} happily ate the\n{STR_VAR_2}.{PAUSE_UNTIL_PRESS}"); +const u8 gContestStatsText_DisdainfullyAte[] = _("{STR_VAR_1} disdainfully ate the\n{STR_VAR_2}.{PAUSE_UNTIL_PRESS}"); + +const u8 MartText_Buy[] = _("BUY"); +const u8 MartText_Sell[] = _("SELL"); +const u8 MartText_Quit2[] = _("QUIT"); + +const u8 gOtherText_QuitShopping[] = _("Quit shopping."); + +const u8 gOtherText_HowManyYouWant[] = _("{STR_VAR_1}? Certainly.\nHow many would you like?"); +const u8 gOtherText_ThatWillBe[] = _("{STR_VAR_1}? And you wanted {STR_VAR_2}?\nThat will be ¥{STR_VAR_3}."); +const u8 gOtherText_ThatWillBe2[] = _("{STR_VAR_1}, is it?\nThat’ll be ¥{STR_VAR_2}. Do you want it?"); +const u8 gOtherText_ThatWillBe3[] = _("You wanted {STR_VAR_1}?\nThat’ll be ¥{STR_VAR_2}. Will that be okay?"); +const u8 gOtherText_HereYouGo[] = _("Here you go!\nThank you very much."); +const u8 gOtherText_HereYouGo2[] = _("Thank you!\nI’ll send it to your home PC."); +const u8 gOtherText_HereYouGo3[] = _("Thanks!\nI’ll send it to your PC at home."); +const u8 gOtherText_NotEnoughMoney[] = _("You don’t have enough money.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_NoRoomFor[] = _("You have no more room for items.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_SpaceForIsFull[] = _("The space for {STR_VAR_1} is full.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_AnythingElse[] = _("Is there anything else I can help\nyou with?"); +const u8 gOtherText_CanIHelpYou[] = _("Can I help you with anything else?"); +const u8 gOtherText_FreePremierBall[] = _("I’ll throw in a PREMIER BALL, too.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_CantBuyThat[] = _("{STR_VAR_2}? Oh, no.\nI can’t buy that.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_HowManyToSell[] = _("{STR_VAR_2}?\nHow many would you like to sell?"); +const u8 gOtherText_CanPay[] = _("I can pay ¥{STR_VAR_1}.\nWould that be okay?"); +const u8 gOtherText_SoldItem[] = _("Turned over the {STR_VAR_2}\nand received ¥{STR_VAR_1}."); + +const u8 OtherText_Money[] = _("¥{STR_VAR_1}"); +const u8 OtherText_Shift[] = _("SHIFT"); +const u8 OtherText_SendOut[] = _("SEND OUT"); +const u8 OtherText_Switch2[] = _("SWITCH"); +const u8 OtherText_Summary[] = _("SUMMARY"); +const u8 OtherText_Moves[] = _("MOVES"); +const u8 OtherText_Enter2[] = _("ENTER"); +const u8 OtherText_NoEntry[] = _("NO ENTRY"); +const u8 OtherText_Take[] = _("TAKE"); +const u8 OtherText_Read2[] = _("READ"); + +const u8 gOtherText_Hp2[] = _("HP"); +const u8 gOtherText_SpAtk2[] = _("SP. ATK"); +const u8 gOtherText_SpDef2[] = _("SP. DEF"); +const u8 gOtherText_WontHaveAnyEffect[] = _("It won’t have any effect.{PAUSE_UNTIL_PRESS}"); + +#if REVISION >= 1 +const u8 gOtherText_CantUseOnPoke[] = _("This can’t be used on\nthat POKéMON.{PAUSE_UNTIL_PRESS}"); +#else +const u8 gOtherText_CantUseOnPoke[] = _("This item can’t be used on\nthat POKéMON.{PAUSE_UNTIL_PRESS}"); +#endif + +const u8 gOtherText_CantBeSwitched[] = _("{STR_VAR_1} can’t be switched\nout!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_AlreadyBattle[] = _("{STR_VAR_1} is already\nin battle!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_AlreadySelected[] = _("{STR_VAR_1} has already been\nselected.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_NoEnergyLeft[] = _("{STR_VAR_1} has no energy\nleft to battle!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_CantSwitchPokeWithYours[] = _("You can’t switch {STR_VAR_1}’s\nPOKéMON with one of yours!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_EGGCantBattle[] = _("An EGG can’t battle!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_CantBeUsedBadge[] = _("This can’t be used until a new\nBADGE is obtained."); +const u8 gOtherText_NoMoreThreePoke[] = _("No more than three POKéMON\nmay enter."); +const u8 gOtherText_SendRemovedMailPrompt[] = _("Send the removed MAIL to\nyour PC?"); +const u8 gOtherText_MailWasSent[] = _("The MAIL was sent to your PC.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_MailboxIsFull[] = _("Your PC’s MAILBOX is full.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_MailRemovedMessageLost[] = _("If the MAIL is removed, the\nmessage will be lost. Okay?"); +const u8 gOtherText_MailMustBeRemoved[] = _("MAIL must be removed before\nholding an item.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_WasGivenToHold[] = _("{STR_VAR_1} was given the\n{STR_VAR_2} to hold.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_AlreadyHolding[] = _("{STR_VAR_1} is already holding\none {STR_VAR_2}.\pWould you like to switch the\ntwo items?"); +const u8 gOtherText_NotHoldingAnything[] = _("{STR_VAR_1} isn’t\nholding anything.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ReceivedTheThingFrom[] = _("Received the {STR_VAR_2}\nfrom {STR_VAR_1}.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_MailTaken[] = _("MAIL was taken from the\nPOKéMON.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_TakenAndReplaced[] = _("The {STR_VAR_2} was taken and\nreplaced with the {STR_VAR_1}.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_PokeHoldingItemCantMail[] = _("This POKéMON is holding an item.\nIt cannot hold MAIL.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_MailTransferredMailbox[] = _("MAIL was transferred from\nthe MAILBOX.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_BagFullCannotRemoveItem[] = _("The BAG is full. The POKéMON’s\nitem could not be removed.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_LearnedMove[] = _("{STR_VAR_1} learned\n{STR_VAR_2}!"); +const u8 gOtherText_NotCompatible[] = _("{STR_VAR_1} and {STR_VAR_2}\nare not compatible.\p{STR_VAR_2} can’t be learned.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_WantsToLearn[] = _("{STR_VAR_1} wants to learn the\nmove {STR_VAR_2}.\pHowever, {STR_VAR_1} already\nknows four moves.\pShould a move be deleted and\nreplaced with {STR_VAR_2}?"); +const u8 gOtherText_StopTryingTo[] = _("Stop trying to teach\n{STR_VAR_2}?"); +const u8 gOtherText_DidNotLearnMove2[] = _("{STR_VAR_1} did not learn the\nmove {STR_VAR_2}.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_WhichMoveToForget2[] = _("Which move should be forgotten?{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ForgetMove123_2[] = _("{PAUSE 32}1, {PAUSE 15}2, and{PAUSE 15}... {PAUSE 15}... {PAUSE 15}... {PAUSE 15}{PLAY_SE SE_KON}Poof!\p{STR_VAR_1} forgot how to\nuse {STR_VAR_2}.\pAnd...{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_AlreadyKnows[] = _("{STR_VAR_1} already knows\n{STR_VAR_2}.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_HPRestoredBy[] = _("{STR_VAR_1}’s HP was restored by\n{STR_VAR_2} points.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_CuredPoisoning[] = _("{STR_VAR_1} was cured of its\npoisoning.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_CuredParalysis[] = _("{STR_VAR_1} was cured of\nparalysis.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_WokeUp[] = _("{STR_VAR_1} woke up.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_BurnHealed[] = _("{STR_VAR_1}’s burn was healed.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ThawedOut[] = _("{STR_VAR_1} was thawed out.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_PPRestored[] = _("PP was restored.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_RegainedHealth[] = _("{STR_VAR_1} regained health.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_BecameHealthy[] = _("{STR_VAR_1} became healthy.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_PPIncreased[] = _("{STR_VAR_1}’s PP increased.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ElevatedTo[] = _("{STR_VAR_1} was elevated to\nLv. {STR_VAR_2}."); +const u8 gOtherText_WasRaised[] = _("{STR_VAR_1}’s {STR_VAR_2} was\nraised.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_SnapConfusion[] = _("{STR_VAR_1} snapped out of its\nconfusion.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_GotOverLove[] = _("{STR_VAR_1} got over its\ninfatuation.{PAUSE_UNTIL_PRESS}"); +const u8 OtherText_ChoosePoke[] = _("Choose a POKéMON."); +const u8 OtherText_MovePokeTo[] = _("Move to where?"); +const u8 OtherText_TeachWhat[] = _("Teach which POKéMON?"); +const u8 OtherText_UseWhat[] = _("Use on which POKéMON?"); +const u8 OtherText_GiveWhat[] = _("Give to which POKéMON?"); +const u8 OtherText_DoWhat[] = _("Do what with {STR_VAR_1}?"); +const u8 OtherText_NothingToCut[] = _("There’s nothing to CUT."); +const u8 OtherText_CantSurf[] = _("You can’t SURF here."); +const u8 OtherText_AlreadySurfing[] = _("You’re already SURFING."); +const u8 OtherText_CantUseThatHere[] = _("Can’t use that here."); +const u8 OtherText_RestoreWhatMove[] = _("Restore which move?"); +const u8 OtherText_BoostPP[] = _("Boost PP of which move?"); +const u8 OtherText_DoWhatWithItem[] = _("Do what with an item?"); +const u8 OtherText_NoPokeForBattle[] = _("No POKéMON for battle!"); +const u8 OtherText_ChoosePoke2[] = _("Choose a POKéMON."); +const u8 OtherText_NotEnoughHP[] = _("Not enough HP..."); +const u8 OtherText_ThreePokeNeeded[] = _("Three POKéMON are needed."); +const u8 OtherText_PokeCantBeSame[] = _("POKéMON can’t be the same."); +const u8 OtherText_NoIdenticalHoldItems[] = _("No identical hold items."); +const u8 OtherText_TeachWhichPoke[] = _("Teach which POKéMON?"); +const u8 gOtherText_Attack[] = _("ATTACK"); +const u8 gOtherText_Defense[] = _("DEFENSE"); +const u8 gOtherText_SpAtk[] = _("SP. ATK"); +const u8 gOtherText_SpDef[] = _("SP. DEF"); +const u8 gOtherText_Speed[] = _("SPEED"); +const u8 gOtherText_HP[] = _("HP"); +const u8 gOtherText_Terminator18[] = _(""); +const u8 gOtherText_OriginalTrainer[] = _("OT/"); +const u8 gOtherText_Type2[] = _("TYPE/"); +const u8 gOtherText_Power2[] = _("POWER"); +const u8 gOtherText_Accuracy2[] = _("ACCURACY"); +const u8 gOtherText_Appeal2[] = _("APPEAL"); +const u8 gOtherText_Jam2[] = _("JAM"); +const u8 gOtherText_Status[] = _("STATUS"); +const u8 gOtherText_ExpPoints[] = _("EXP. POINTS"); +const u8 gOtherText_NextLv[] = _("NEXT LV."); +const u8 gOtherText_Ribbons00[] = _("RIBBONS: 00"); + +const u8 OtherText_Event[] = _("EVENT"); +const u8 OtherText_Switch[] = _("SWITCH"); +const u8 OtherText_PokeInfo[] = _("POKéMON INFO"); +const u8 OtherText_PokeSkills[] = _("POKéMON SKILLS"); +const u8 OtherText_BattleMoves[] = _("BATTLE MOVES"); +const u8 OtherText_ContestMoves[] = _("C0NTEST MOVES"); // why the l33t 0, that's stupid +const u8 OtherText_Info[] = _("INFO"); + +const u8 gOtherText_EggLongTime[] = _("It looks like this EGG will\ntake a long time to hatch."); +const u8 gOtherText_EggSomeTime[] = _("What will hatch from this?\nIt will take some time."); +const u8 gOtherText_EggSoon[] = _("It moves occasionally.\nIt should hatch soon."); +const u8 gOtherText_EggAbout[] = _("It’s making sounds.\nIt’s about to hatch!"); +const u8 gOtherText_CantForgetHMs[] = _("HM moves can’t be\nforgotten now."); +const u8 gOtherText_PlayersBase[] = _("’s BASE"); +const u8 gOtherText_OkayToDeleteFromRegistry[] = _("Is it okay to delete {STR_VAR_1}\nfrom the REGISTRY?"); +const u8 gOtherText_RegisteredDataDeleted[] = _("The registered data was deleted.{PAUSE_UNTIL_PRESS}"); + +const u8 gSecretBaseText_NoRegistry[] = _("There is no REGISTRY.{PAUSE_UNTIL_PRESS}"); +const u8 SecretBaseText_DelRegist[] = _("DEL REGIST."); +const u8 SecretBaseText_Decorate[] = _("DECORATE"); +const u8 SecretBaseText_PutAway[] = _("PUT AWAY"); +const u8 SecretBaseText_Toss[] = _("TOSS"); +const u8 SecretBaseText_PutOutDecor[] = _("Put out the selected decoration item."); +const u8 SecretBaseText_StoreChosenDecor[] = _("Store the chosen decoration in the PC."); +const u8 SecretBaseText_ThrowAwayDecor[] = _("Throw away unwanted decorations."); +const u8 gSecretBaseText_NoDecors[] = _("There are no decorations.{PAUSE_UNTIL_PRESS}"); +const u8 SecretBaseText_Desk[] = _("DESK"); +const u8 SecretBaseText_Chair[] = _("CHAIR"); +const u8 SecretBaseText_Plant[] = _("PLANT"); +const u8 SecretBaseText_Ornament[] = _("ORNAMENT"); +const u8 SecretBaseText_Mat[] = _("MAT"); +const u8 SecretBaseText_Poster[] = _("POSTER"); +const u8 SecretBaseText_Doll[] = _("DOLL"); +const u8 SecretBaseText_Cushion[] = _("CUSHION"); +const u8 gSecretBaseText_GoldRank[] = _("GOLD"); +const u8 gSecretBaseText_SilverRank[] = _("SILVER"); +const u8 gSecretBaseText_PlaceItHere[] = _("Place it here?"); +const u8 gSecretBaseText_CantBePlacedHere[] = _("It can’t be placed here."); +const u8 gSecretBaseText_CancelDecorating[] = _("Cancel decorating?"); +const u8 gSecretBaseText_InUseAlready[] = _("This is in use already."); +const u8 gSecretBaseText_NoMoreDecor[] = _("No more decorations can be placed.\nThe most that can be placed is {STR_VAR_1}."); +const u8 gSecretBaseText_NoMoreDecor2[] = _("No more decorations can be placed.\nThe most that can be placed is {STR_VAR_1}.$This can’t be placed here.\nIt must be on a DESK, etc."); +const u8 gSecretBaseText_DecorCantPlace[] = _("This decoration can’t be placed in\nyour own room."); +const u8 gSecretBaseText_DecorInUse[] = _("This decoration is in use.\nIt can’t be thrown away."); +const u8 gSecretBaseText_WillBeDiscarded[] = _("This {STR_VAR_1} will be discarded.\nIs that okay?"); +const u8 gSecretBaseText_DecorThrownAway[] = _("The decoration item was thrown away."); +const u8 gSecretBaseText_StopPuttingAwayDecor[] = _("Stop putting away decorations?"); +const u8 gSecretBaseText_NoDecor[] = _("There is no decoration item here."); +const u8 gSecretBaseText_ReturnDecor[] = _("Return this decoration to the PC?"); +const u8 gSecretBaseText_DecorReturned[] = _("The decoration was returned to the PC."); +const u8 gSecretBaseText_NoDecorInUse[] = _("There are no decorations in use.{PAUSE_UNTIL_PRESS}"); +const u8 SecretBaseText_Tristan[] = _("TRISTAN"); +const u8 SecretBaseText_Philip[] = _("PHILIP"); +const u8 SecretBaseText_Dennis[] = _("DENNIS"); +const u8 SecretBaseText_Roberto[] = _("ROBERTO"); +const u8 SecretBaseText_TurnOff[] = _("TURN OFF"); +const u8 SecretBaseText_Decoration[] = _("DECORATION"); +const u8 SecretBaseText_ItemStorage[] = _("ITEM STORAGE"); + +const u8 gPCText_Mailbox[] = _("MAILBOX"); +const u8 PCText_DepositItem[] = _("DEPOSIT ITEM"); +const u8 PCText_WithdrawItem[] = _("WITHDRAW ITEM"); +const u8 PCText_TossItem[] = _("TOSS ITEM"); +const u8 PCText_StoreItems[] = _("Store items in the PC."); +const u8 PCText_TakeOutItems[] = _("Take out items from the PC."); +const u8 PCText_ThrowAwayItems[] = _("Throw away items stored in the PC."); + +const u8 gOtherText_NoItems[] = _("There are no items.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_NoMoreRoom[] = _("There is no more\nroom in the BAG."); +const u8 gOtherText_HowManyToWithdraw[] = _("How many do you\nwant to withdraw?"); +const u8 gOtherText_WithdrewThing[] = _("Withdrew {STR_VAR_2}\n{STR_VAR_1}(s)."); +const u8 OtherText_Read[] = _("READ"); +const u8 gOtherText_MoveToBag[] = _("MOVE TO BAG"); +const u8 OtherText_Give[] = _("GIVE"); +const u8 gOtherText_NoMailHere[] = _("There’s no MAIL here.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_WhatWillYouDoMail[] = _("What would you like to do with\n{STR_VAR_1}’s MAIL?"); +const u8 gOtherText_MessageWillBeLost[] = _("The message will be lost.\nIs that okay?"); +const u8 gOtherText_BagIsFull[] = _("The BAG is full.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_MailWasReturned[] = _("The MAIL was returned to the BAG\nwith its message erased.{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_Dad[] = _("DAD"); +const u8 gOtherText_Mom[] = _("MOM"); +const u8 gOtherText_Wallace[] = _("WALLACE"); +const u8 gOtherText_Steven[] = _("STEVEN"); +const u8 gOtherText_Brawly[] = _("BRAWLY"); +const u8 gOtherText_Winona[] = _("WINONA"); +const u8 gOtherText_Phoebe[] = _("PHOEBE"); +const u8 gOtherText_Glacia[] = _("GLACIA"); +const u8 gContestText_ContestWinner[] = _("CONTEST WINNER\n"); +const u8 gOtherText_Unknown1[] = _("’s "); +const u8 OtherText_Cool[] = _("COOL "); +const u8 OtherText_Beauty2[] = _("BEAUTY "); +const u8 OtherText_Cute[] = _("CUTE "); +const u8 OtherText_Smart[] = _("SMART "); +const u8 OtherText_Tough[] = _("TOUGH "); +const u8 OtherText_NonstopSuperCool[] = _("Nonstop super-cool -\nthe inestimable "); +const u8 OtherText_Terminator6[] = _(""); +const u8 OtherText_GoodLookingPoke[] = _("Hey, there!\nThe good-looking POKéMON "); +const u8 OtherText_Terminator7[] = _(""); +const u8 OtherText_MarvelousGreat[] = _("The marvelous, wonderful, and\nvery great "); +const u8 OtherText_Terminator8[]= _(""); +const u8 OtherText_CenturyLastVenus[]= _("This century’s last Venus -\nthe beautiful "); +const u8 OtherText_Terminator9[]= _(""); +const u8 OtherText_Terminator10[]= _(""); +const u8 OtherText_DazzlingSmile[]= _("’s dazzling,\nglittering smile"); +const u8 OtherText_PokeCenterIdol[]= _("POKéMON CENTER’s super idol -\nthe incomparable "); +const u8 OtherText_Terminator11[]= _(""); +const u8 OtherText_LovelyAndSweet[]= _("The lovely and sweet "); +const u8 OtherText_Terminator12[]= _(""); +const u8 OtherText_ThePretty[]= _("The pretty "); +const u8 OtherText_WinningPortrait[] = _("’s\nwinning portrait"); +const u8 OtherText_GiveUsWink[] = _("Give us a wink!\nThe cutie POKéMON "); +const u8 OtherText_Terminator13[] = _(""); +const u8 OtherText_SmartnessMaestro[] = _("The smartness maestro -\nThe wise POKéMON "); +const u8 OtherText_Terminator14[] = _(""); +const u8 OtherText_ChosenPokeAmong[] = _("The chosen POKéMON -\nThe one among POKéMON "); +const u8 OtherText_Terminator15[] = _(""); +const u8 OtherText_TheExcellent[] = _("The excellent "); +const u8 OtherText_ItsMomentOfElegance[] = _("’s\nmoment of elegance"); +const u8 OtherText_PowerfullyMuscular[] = _("The powerfully muscular\nspeedster "); +const u8 OtherText_Terminator16[] = _(""); +const u8 OtherText_StrongErEst[] = _("The strong, stronger, and\nstrongest "); +const u8 OtherText_Terminator17[] = _(""); +const u8 OtherText_MightyTough[] = _("The mighty tough\nhyper POKéMON "); +const u8 OtherText_Exclamation[] = _("!"); +const u8 OtherText_Petalburg[] = _("PETALBURG"); +const u8 OtherText_Slateport[] = _("SLATEPORT"); +const u8 OtherText_Littleroot[] = _("LITTLEROOT"); // unused contest location? +const u8 OtherText_Lilycove[] = _("LILYCOVE"); +const u8 OtherText_Dewford[] = _("DEWFORD"); +const u8 OtherText_Enter[] = _("ENTER"); +const u8 OtherText_Info3[] = _("INFO"); +const u8 OtherText_WhatsAContest[] = _("What’s a CONTEST?"); +const u8 OtherText_TypesOfContest[] = _("Types of CONTESTS"); +const u8 OtherText_Ranks[] = _("Ranks"); +const u8 OtherText_Judging[] = _("Judging"); +const u8 OtherText_CoolContest[] = _("COOL CONTEST"); +const u8 OtherText_BeautyContest[] = _("BEAUTY CONTEST"); +const u8 OtherText_CuteContest[] = _("CUTE CONTEST"); +const u8 OtherText_SmartContest[] = _("SMART CONTEST"); +const u8 OtherText_ToughContest[] = _("TOUGH CONTEST"); +const u8 OtherText_Decoration[] = _("DECORATION"); +const u8 OtherText_PackUp[] = _("PACK UP"); +const u8 OtherText_Count[] = _("COUNT"); +const u8 OtherText_Registry[] = _("REGISTRY"); +const u8 OtherText_Information[] = _("INFORMATION"); +const u8 OtherText_Mach[] = _("MACH"); +const u8 OtherText_Acro[] = _("ACRO"); +const u8 OtherText_Poison[] = _("PSN"); +const u8 OtherText_Paralysis[] = _("PAR"); +const u8 OtherText_Sleep[] = _("SLP"); +const u8 OtherText_Burn[] = _("BRN"); +const u8 OtherText_Frozen[] = _("FRZ"); +const u8 OtherText_Quit[] = _("QUIT"); +const u8 OtherText_SawIt[] = _("Saw it"); +const u8 OtherText_NotYet[] = _("Not yet"); +const u8 OtherText_Yes[] = _("YES"); +const u8 OtherText_No[] = _("NO"); +const u8 OtherText_Info2[] = _("INFO"); +const u8 OtherText_SingleBattle[] = _("SINGLE BATTLE"); +const u8 OtherText_DoubleBattle[] = _("DOUBLE BATTLE"); +const u8 OtherText_MultiBattle[] = _("MULTI BATTLE"); +const u8 OtherText_MrBriney[] = _("MR. BRINEY"); +const u8 OtherText_MakeAChallenge[] = _("Make a challenge."); +const u8 OtherText_ObtainInformation[] = _("Obtain information."); +const u8 OtherText_Lv50_2[] = _("LV. 50"); +const u8 OtherText_Lv100_2[] = _("LV. 100"); +const u8 OtherText_Zigzagoon[] = _("ZIGZAGOON"); +const u8 OtherText_Nincada[] = _("NINCADA"); +const u8 OtherText_Poochyena[] = _("POOCHYENA"); +const u8 OtherText_Nincada2[] = _("NINCADA"); +const u8 OtherText_Lotad[] = _("LOTAD"); +const u8 OtherText_Roselia[] = _("ROSELIA"); +const u8 OtherText_Shroomish[] = _("SHROOMISH"); +const u8 OtherText_Nincada3[] = _("NINCADA"); +const u8 OtherText_Surskit[] = _("SURSKIT"); +const u8 OtherText_Treecko[] = _("TREECKO"); +const u8 OtherText_Torchic[] = _("TORCHIC"); +const u8 OtherText_Mudkip[] = _("MUDKIP"); +const u8 OtherText_Seedot[] = _("SEEDOT"); +const u8 OtherText_Shroomish2[] = _("SHROOMISH"); +const u8 OtherText_Spinda[] = _("SPINDA"); +const u8 OtherText_Shroomish3[] = _("SHROOMISH"); +const u8 OtherText_Zigzagoon2[] = _("ZIGZAGOON"); +const u8 OtherText_Wurmple[] = _("WURMPLE"); +const u8 OtherText_PokeBall[] = _("POKé BALL"); +const u8 OtherText_SuperPotion[] = _("SUPER POTION"); +const u8 OtherText_SamePrice[] = _("Same price"); +const u8 OtherText_Yen135[] = _("¥135"); +const u8 OtherText_Yen155[] = _("¥155"); +const u8 OtherText_Yen175[] = _("¥175"); +const u8 OtherText_CostMore[] = _("They will cost more."); +const u8 OtherText_CostLess[] = _("They will cost less."); +const u8 OtherText_SamePrice2[] = _("Same price"); +const u8 OtherText_MaleSymbol[] = _("♂"); +const u8 OtherText_FemaleSymbol[] = _("♀"); +const u8 OtherText_Neither[] = _("Neither"); +const u8 OtherText_Males[] = _("Males"); +const u8 OtherText_Females[] = _("Females"); +const u8 OtherText_SameNumber[] = _("Same number"); +const u8 OtherText_Male[] = _("Male"); +const u8 OtherText_Female[] = _("Female"); +const u8 OtherText_ItDepends[] = _("It depends"); +const u8 OtherText_Six2[] = _("6"); +const u8 OtherText_Eight2[] = _("8"); +const u8 OtherText_Ten[] = _("10"); +const u8 OtherText_One[] = _("1"); +const u8 OtherText_Two[] = _("2"); +const u8 OtherText_Three[] = _("3"); +const u8 OtherText_Six[] = _("6"); +const u8 OtherText_Seven[] = _("7"); +const u8 OtherText_Eight[] = _("8"); +const u8 OtherText_FreshWater[] = _("FRESH WATER{CLEAR_TO 0x48}¥200"); +const u8 OtherText_SodaPop[] = _("SODA POP{CLEAR_TO 0x48}¥300"); +const u8 OtherText_Lemonade[] = _("LEMONADE{CLEAR_TO 0x48}¥350"); +const u8 OtherText_HowToRide[] = _("HOW TO RIDE"); +const u8 OtherText_HowToTurn[] = _("HOW TO TURN"); +const u8 OtherText_SandySlopes[] = _("SANDY SLOPES"); +const u8 OtherText_Wheelies[] = _("WHEELIES"); +const u8 OtherText_BunnyHops[] = _("BUNNY-HOPS"); +const u8 OtherText_Jumping[] = _("JUMPING"); +const u8 OtherText_Satisfied[] = _("Satisfied"); +const u8 OtherText_Dissatisfied[] = _("Dissatisfied"); +const u8 OtherText_Deepseatooth[] = _("DEEPSEATOOTH"); +const u8 OtherText_Deepseascale[] = _("DEEPSEASCALE"); +const u8 OtherText_BlueFlute2[] = _("BLUE FLUTE"); +const u8 OtherText_YellowFlute2[] = _("YELLOW FLUTE"); +const u8 OtherText_RedFlute2[] = _("RED FLUTE"); +const u8 OtherText_WhiteFlute2[] = _("WHITE FLUTE"); +const u8 OtherText_BlackFlute2[] = _("BLACK FLUTE"); +const u8 OtherText_GlassChair[] = _("GLASS CHAIR"); +const u8 OtherText_GlassDesk[] = _("GLASS DESK"); +const u8 OtherText_TreeckoDoll[] = _("TREECKO DOLL 1,000 COINS"); +const u8 OtherText_TorchicDoll[] = _("TORCHIC DOLL 1,000 COINS"); +const u8 OtherText_MudkipDoll[] = _("MUDKIP DOLL 1,000 COINS"); +const u8 OtherText_50Coins[] = _(" 50 COINS ¥1,000"); +const u8 OtherText_500Coins[] = _("500 COINS ¥10,000"); +const u8 OtherText_Excellent[] = _("Excellent!"); +const u8 OtherText_NotSoHot[] = _("Not so hot"); +const u8 OtherText_RedShard[] = _("RED SHARD"); +const u8 OtherText_YellowShard[] = _("YELLOW SHARD"); +const u8 OtherText_BlueShard[] = _("BLUE SHARD"); +const u8 OtherText_GreenShard[] = _("GREEN SHARD"); +const u8 OtherText_BattleTower[] = _("BATTLE TOWER"); +const u8 OtherText_Right[] = _("Right"); +const u8 OtherText_Left[] = _("Left"); +const u8 OtherText_TM32[] = _("TM32 1,500 COINS"); +const u8 OtherText_TM29[] = _("TM29 3,500 COINS"); +const u8 OtherText_TM35[] = _("TM35 4,000 COINS"); +const u8 OtherText_TM24[] = _("TM24 4,000 COINS"); +const u8 OtherText_TM13[] = _("TM13 4,000 COINS"); +const u8 OtherText_1F_2[] = _("1F"); +const u8 OtherText_2F_2[] = _("2F"); +const u8 OtherText_3F_2[] = _("3F"); +const u8 OtherText_4F_2[] = _("4F"); +const u8 OtherText_5F_2[] = _("5F"); +const u8 OtherText_Cool2[] = _("COOL"); +const u8 OtherText_Beauty3[] = _("BEAUTY"); +const u8 OtherText_Cute2[] = _("CUTE"); +const u8 OtherText_Smart2[] = _("SMART"); +const u8 OtherText_Tough2[] = _("TOUGH"); +const u8 OtherText_Normal[] = _("NORMAL"); +const u8 OtherText_Super[] = _("SUPER"); +const u8 OtherText_Hyper[] = _("HYPER"); +const u8 OtherText_Master[] = _("MASTER"); +const u8 OtherText_Cool3[] = _("COOL"); +const u8 OtherText_Beauty4[] = _("BEAUTY"); +const u8 OtherText_Cute3[] = _("CUTE"); +const u8 OtherText_Smart3[] = _("SMART"); +const u8 OtherText_Tough3[] = _("TOUGH"); +const u8 OtherText_Items[] = _("ITEMS"); +const u8 OtherText_KeyItems[] = _("KEY ITEMS"); +const u8 OtherText_Balls[] = _("BALLS"); +const u8 OtherText_TMsHMs[] = _("TMs & HMs"); +const u8 OtherText_Berries[] = _("BERRIES"); + +const u8 gPCText_SomeonesPC[] = _("SOMEONE’S PC"); +const u8 gPCText_LanettesPC[] = _("LANETTE’S PC"); +const u8 gPCText_PlayersPC[] = _("{PLAYER}’s PC"); +const u8 gPCText_HallOfFame[] = _("HALL OF FAME"); +const u8 gPCText_LogOff[] = _("LOG OFF"); + +const u8 gOtherText_99Times[] = _("99 times +"); +const u8 gOtherText_1Minute[] = _("1 minute +"); +const u8 gOtherText_Seconds[] = _(" seconds"); +const u8 gOtherText_Times[] = _(" times$."); +const u8 gOtherText_BigGuy[] = _("Big guy"); +const u8 gOtherText_BigGirl[] = _("Big girl"); +const u8 gOtherText_Son[] = _("son"); +const u8 gOtherText_Daughter[] = _("daughter"); +const u8 OtherText_BlueFlute[] = _("BLUE FLUTE"); +const u8 OtherText_YellowFlute[] = _("YELLOW FLUTE"); +const u8 OtherText_RedFlute[] = _("RED FLUTE"); +const u8 OtherText_WhiteFlute[] = _("WHITE FLUTE"); +const u8 OtherText_BlackFlute[] = _("BLACK FLUTE"); +const u8 OtherText_PrettyChair[] = _("PRETTY CHAIR"); +const u8 OtherText_PrettyDesk[] = _("PRETTY DESK"); +const u8 OtherText_1F[] = _("1F"); +const u8 OtherText_2F[] = _("2F"); +const u8 OtherText_3F[] = _("3F"); +const u8 OtherText_4F[] = _("4F"); +const u8 OtherText_5F[] = _("5F"); +const u8 OtherText_6F[] = _("6F"); +const u8 OtherText_7F[] = _("7F"); +const u8 OtherText_8F[] = _("8F"); +const u8 OtherText_9F[] = _("9F"); +const u8 OtherText_10F[] = _("10F"); +const u8 OtherText_11F[] = _("11F"); +const u8 OtherText_B1F[] = _("B1F"); +const u8 OtherText_B2F[] = _("B2F"); +const u8 OtherText_B3F[] = _("B3F"); +const u8 OtherText_B4F[] = _("B4F"); +const u8 OtherText_Rooftop[] = _("ROOFTOP"); + +const u8 gOtherText_NowOn[] = _("Now on:"); + +const u8 gPCText_Cancel[] = _("CANCEL"); + +const u8 PCText_ExitBox[] = _("Exit from the BOX."); +const u8 PCText_WhatYouDo[] = _("What would you like to do?"); +const u8 PCText_PickATheme[] = _("Please pick a theme."); +const u8 PCText_PickAWallpaper[] = _("Please pick out wallpaper."); +const u8 PCText_IsSelected[] = _(" is selected."); +const u8 PCText_JumpToWhichBox[] = _("Jump to which BOX?"); +const u8 PCText_DepositInWhichBox[] = _("Deposit in which BOX?"); +const u8 PCText_WasDeposited[] = _(" was deposited."); +const u8 PCText_BoxIsFull[] = _("The BOX is full."); +const u8 PCText_ReleasePoke[] = _("Release this POKéMON?"); +const u8 PCText_WasReleased[] = _(" was released."); +const u8 PCText_ByeBye[] = _("Bye-bye, !"); +const u8 PCText_MarkPoke[] = _("Mark your POKéMON."); +const u8 PCText_LastPoke[] = _("That’s your last POKéMON!"); +const u8 PCText_PartyFull[] = _("Your party’s full!"); +const u8 PCText_HoldingPoke[] = _("You’re holding a POKéMON!"); +const u8 PCText_WhichOneWillTake[] = _("Which one will you take?"); +const u8 PCText_CantReleaseEgg[] = _("You can’t release an EGG."); +const u8 PCText_ContinueBox[] = _("Continue BOX operations?"); +const u8 PCText_CameBack[] = _(" came back!"); +const u8 PCText_Worried[] = _("Was it worried about you?"); +const u8 PCText_Surprise[] = _("... ... ... ... ...!"); +const u8 PCText_PleaseRemoveMail[] = _("Please remove the MAIL."); +const u8 PCText_Cancel2[] = _("CANCEL"); +const u8 PCText_Deposit[] = _("DEPOSIT"); +const u8 PCText_Withdraw[] = _("WITHDRAW"); +const u8 PCText_Switch[] = _("SWITCH"); +const u8 PCText_Move[] = _("MOVE"); +const u8 PCText_Place[] = _("PLACE"); +const u8 PCText_Summary[] = _("SUMMARY"); +const u8 PCText_Release[] = _("RELEASE"); +const u8 PCText_Mark[] = _("MARK"); +const u8 PCText_Name[] = _("NAME"); +const u8 PCText_Jump[] = _("JUMP"); +const u8 PCText_Wallpaper[] = _("WALLPAPER"); +const u8 PCText_Scenery1[] = _("SCENERY 1"); +const u8 PCText_Scenery2[] = _("SCENERY 2"); +const u8 PCText_Scenery3[] = _("SCENERY 3"); +const u8 PCText_Etc[] = _("ETCETERA"); +const u8 PCText_Forest[] = _("FOREST"); +const u8 PCText_City[] = _("CITY"); +const u8 PCText_Desert[] = _("DESERT"); +const u8 PCText_Savanna[] = _("SAVANNA"); +const u8 PCText_Crag[] = _("CRAG"); +const u8 PCText_Volcano[] = _("VOLCANO"); +const u8 PCText_Snow[] = _("SNOW"); +const u8 PCText_Cave[] = _("CAVE"); +const u8 PCText_Beach[] = _("BEACH"); +const u8 PCText_Seafloor[] = _("SEAFLOOR"); +const u8 PCText_River[] = _("RIVER"); +const u8 PCText_Sky[] = _("SKY"); +const u8 PCText_Polka[] = _("POLKA-DOT"); +const u8 PCText_PokeCenter[] = _("POKéCENTER"); +const u8 PCText_Machine[] = _("MACHINE"); +const u8 PCText_Plain[] = _("PLAIN"); +const u8 PCText_WhatDoYouWant[] = _("What do you want?"); +const u8 PCText_WithdrawPoke[] = _("WITHDRAW POKéMON"); +const u8 PCText_DepositPoke[] = _("DEPOSIT POKéMON"); +const u8 PCText_MovePoke[] = _("MOVE POKéMON"); +const u8 PCText_SeeYa[] = _("SEE YA!"); +const u8 PCText_MovePokeToParty[] = _("Move POKéMON stored in BOXES to\nyour party."); +const u8 PCText_StorePokeInBox[] = _("Store POKéMON in your party in BOXES."); +const u8 PCText_OrganizeBoxesParty[] = _("Organize the POKéMON in BOXES and\nin your party."); +const u8 PCText_ReturnToPrevMenu[] = _("Return to the previous menu."); + +const u8 gPCText_OnlyOne[] = _("There is just one POKéMON with you."); +const u8 gPCText_PartyFull2[] = _("Your party is full!"); +const u8 gPCText_BOX[] = _("BOX"); + +// pokenav +const u8 PCText_CheckMap[] = _("{CLEAR 0}Check the map of the HOENN region."); +const u8 PCText_CheckPoke[] = _("{CLEAR 0}Check POKéMON in detail."); +const u8 PCText_CheckTrainer[] = _("{CLEAR 0}Check TRAINER information."); +const u8 PCText_CheckRibbons[] = _("{CLEAR 0}Check obtained RIBBONS."); +const u8 PCText_PutAwayNav[] = _("{CLEAR 0}Put away the POKéNAV."); +const u8 PCText_NoRibbonWin[] = _("{CLEAR 0}There are no RIBBON winners."); +const u8 PCText_NoTrainers[] = _("{CLEAR 0}No TRAINERS are registered."); +const u8 PCText_CheckParty[] = _("{CLEAR 0}Check party POKéMON in detail."); +const u8 PCText_CheckPokeAll[] = _("{CLEAR 0}Check all POKéMON in detail."); +const u8 PCText_ReturnToNav[] = _("{CLEAR 0}Return to the POKéNAV menu."); +const u8 PCText_FindCool[] = _("{CLEAR 0}Find cool POKéMON."); +const u8 PCText_FindBeauty[] = _("{CLEAR 0}Find beautiful POKéMON."); +const u8 PCText_FindCute[] = _("{CLEAR 0}Find cute POKéMON."); +const u8 PCText_FindSmart[] = _("{CLEAR 0}Find smart POKéMON."); +const u8 PCText_FindTough[] = _("{CLEAR 0}Find tough POKéMON."); +const u8 PCText_ReturnToCondition[] = _("{CLEAR 0}Return to the CONDITION menu."); + +const u8 gOtherText_NumberRegistered[] = _("No. registered"); +const u8 gOtherText_NumberBattles[] = _("No. of battles"); +const u8 gOtherText_Strategy[] = _("{PALETTE 5}STRATEGY"); +const u8 gOtherText_TrainersPokemon[] = _("{PALETTE 5}TRAINER’S POKéMON"); +const u8 gOtherText_SelfIntroduction[] = _("{PALETTE 5}SELF-INTRODUCTION"); +const u8 gOtherText_Nature2[] = _("NATURE/"); +const u8 gOtherText_InParty[] = _("IN PARTY"); +const u8 gOtherText_Number[] = _("No. "); +const u8 gOtherText_Ribbons[] = _("RIBBONS"); +const u8 OtherText_MakeProfilePage1[] = _("Make your profile by combining"); +const u8 OtherText_MakeProfilePage2[] = _("four words or phrases."); +const u8 OtherText_MakeMessagePage1[] = _("Make a message with 6 phrases."); +const u8 OtherText_MakeMessagePage2[] = _("Max. two 12-letter phrases/line."); +const u8 OtherText_DescribeFeelingsPage1[] = _("Find words that describe your"); +const u8 OtherText_DescribeFeelingsPage2[] = _("feelings right now."); +const u8 OtherText_WithFourPhrases[] = _("With four phrases,"); +const u8 OtherText_CombineNinePhrasesPage1[] = _("Combine nine phrases and"); +const u8 OtherText_CombineNinePhrasesPage2[] = _("make a message."); +const u8 OtherText_ImproveBardSongPage1[] = _("Change just one word or phrase"); +const u8 OtherText_ImproveBardSongPage2[] = _("and improve the BARD’s song."); +const u8 OtherText_YourProfile[] = _("Your profile "); +const u8 OtherText_YourFeelingBattle[] = _("Your feeling at the battle’s start"); +const u8 OtherText_SetWinMessage[] = _("What you say if you win a battle"); +const u8 OtherText_SetLossMessage[] = _("What you say if you lose a battle"); +const u8 OtherText_TheAnswer[] = _("The answer"); +const u8 OtherText_MailMessage[] = _("The MAIL message"); +const u8 OtherText_MailSalutation[] = _("The MAIL salutation"); +const u8 OtherText_NewSong[] = _("The new song"); +const u8 OtherText_CombineTwoPhrasesPage1[] = _("Combine two phrases and"); +const u8 OtherText_CombineTwoPhrasesPage2[] = _("make a trendy saying."); +const u8 OtherText_ConfirmTrendyPage1[] = _("The trendy saying"); +const u8 OtherText_ConfirmTrendyPage2[] = _("is as shown. Okay?"); +const u8 OtherText_HipsterPage1[] = _("I’ll combine two phrases and"); +const u8 OtherText_HipsterPage2[] = _("teach you a good saying."); + +const u8 gOtherText_TextDeletedConfirmPage1[] = _("All the text being edited will"); +const u8 gOtherText_TextDeletedConfirmPage2[] = _("be deleted. Is that okay?"); +const u8 gOtherText_QuitEditing[] = _("Quit editing?"); +const u8 gOtherText_EditedTextNoSavePage1[] = _("The edited text will not be saved."); +const u8 gOtherText_EditedTextNoSavePage2[] = _("Is that okay?"); +const u8 gOtherText_EnterAPhraseOrWord[] = _("Please enter a phrase or word."); +const u8 gOtherText_TextNoDelete[] = _("The entire text can’t be deleted."); +const u8 gOtherText_OnlyOnePhrase[] = _("Only one phrase may be changed."); +const u8 gOtherText_OriginalSongRestored[] = _("The original song will be restored."); +const u8 gOtherText_TrendyAlready[] = _("That’s trendy already!"); +const u8 gOtherText_CombineTwoPhrases[] = _("Combine two words or phrases."); +const u8 gOtherText_QuitGivingInfo[] = _("Quit giving information?"); +const u8 gOtherText_StopGivingMail[] = _("Stop giving the POKéMON MAIL?"); +const u8 gOtherText_Profile[] = _("PROFILE"); +const u8 gOtherText_AtBattleStart[] = _("At the battle’s start."); +const u8 gOtherText_UponWinningBattle[] = _("Upon winning a battle."); +const u8 gOtherText_UponLosingBattle[] = _("Upon losing a battle."); + +// mauville_old_man? +const u8 gOtherText_TheBardsSong[] = _("The BARD’s Song"); +const u8 gOtherText_WhatsHipHappening[] = _("What’s hip and happening?"); +const u8 gOtherText_Interview[] = _("Interview"); +const u8 gOtherText_GoodSaying[] = _("Good saying"); +const u8 OtherText_SoPretty[] = _(" so pretty!"); +const u8 OtherText_SoDarling[] = _(" so darling!"); +const u8 OtherText_SoRelaxed[] = _(" so relaxed!"); +const u8 OtherText_SoSunny[] = _(" so sunny!"); +const u8 OtherText_SoDesirable[] = _(" so desirable!"); +const u8 OtherText_SoExciting[] = _(" so exciting!"); +const u8 OtherText_SoAmusing[] = _(" so amusing!"); +const u8 OtherText_SoMagical[] = _(" so magical!"); + +const u8 gOtherText_Is[] = _(" is"); +const u8 gOtherText_DontYouAgree[] = _("\nDon’t you agree?"); + +const u8 OtherText_WantVacationNicePlace[] = _("I so want to go on a vacation.\nWould you happen to know a nice place?"); +const u8 OtherText_BoughtCrayonsIsNice[] = _("I bought crayons with 120 colors!\nDon’t you think that’s nice?"); +const u8 OtherText_IfWeCouldFloat[] = _("Wouldn’t it be nice if we could float\naway on a cloud of bubbles?"); +const u8 OtherText_SandWashesAwayMakeSad[] = _("When you write on a sandy beach,\nthey wash away. It makes me sad."); +const u8 OtherText_WhatsBottomSeaLike[] = _("What’s the bottom of the sea like?\nJust once I would so love to go!"); +const u8 OtherText_SeeSettingSun[] = _("When you see the setting sun, does it\nmake you want to go home?"); +const u8 OtherText_LyingInGreenGrass[] = _("Lying back in the green grass...\nOh, it’s so, so nice!"); +const u8 OtherText_SecretBasesWonderful[] = _("SECRET BASES are so wonderful!\nCan’t you feel the excitement?"); + +const u8 OtherText_PokeLeague[] = _("POKéMON LEAGUE"); +const u8 OtherText_PokeCenter[] = _("POKéMON CENTER"); + +const u8 gOtherText_GetsAPokeBlock[] = _(" gets a {POKEBLOCK}?"); + +const u8 OtherText_Coolness[] = _("Coolness "); +const u8 OtherText_Beauty[] = _("Beauty "); +const u8 OtherText_Cuteness[] = _("Cuteness "); +const u8 OtherText_Smartness[] = _("Smartness "); +const u8 OtherText_Toughness[] = _("Toughness "); + +const u8 gOtherText_WasEnhanced[] = _("was enhanced!"); +const u8 gOtherText_NothingChanged[] = _("Nothing changed!"); +const u8 gOtherText_WontEat[] = _("It won’t eat anymore..."); + +const u8 gSystemText_SaveFailedBackupCheck[] = _("Save failed.\nChecking the backup memory...\nPlease wait.\n{COLOR RED}“Time required: 1 minute”"); +const u8 gSystemText_BackupDamagedGameContinue[] = _("The backup memory is damaged or\nthe internal battery has run dry.\nThe game can be played. However,\nprogress cannot be saved."); +const u8 gSystemText_GameplayEnded[] = _("{COLOR RED}“Gameplay cannot be continued.\nReturning to the title screen...”"); +const u8 gSystemText_CheckCompleteSaveAttempt[] = _("Check completed.\nAttempting to save again.\nPlease wait."); +const u8 gSystemText_SaveCompletedGameEnd[] = _("Save completed.\n{COLOR RED}“Gameplay cannot be continued.\nReturning to the title screen.”"); +const u8 gSystemText_SaveCompletedPressA[] = _("Save completed.\n{COLOR RED}“Please press the A Button.”"); + +const u8 gOtherText_Ferry[] = _("FERRY"); +const u8 gOtherText_SecretBase[] = _("SECRET BASE"); +const u8 gOtherText_Hideout[] = _("HIDEOUT"); + +const u8 gSystemText_ResetRTCPrompt[] = _("Reset RTC?\nA: Confirm, B: Cancel"); +const u8 gSystemText_PresentTime[] = _("Present time in game"); +const u8 gSystemText_PreviousTime[] = _("Previous time in game"); +const u8 gSystemText_PleaseResetTime[] = _("Please reset the time."); +const u8 gSystemText_ClockResetDataSave[] = _("The clock has been reset.\nData will be saved. Please wait."); +const u8 gSystemText_SaveCompleted[] = _("Save completed."); +const u8 gSystemText_SaveFailed[] = _("Save failed..."); +const u8 gSystemText_NoSaveFileNoTime[] = _("There is no save file, so the time\ncan’t be set."); +const u8 gSystemText_ClockAdjustmentUsable[] = _("The in-game clock adjustment system\nis now useable."); +const u8 gSystemText_Saving[] = _("SAVING...\nDON’T TURN OFF THE POWER."); diff --git a/src/task.c b/src/task.c index e79929c63..3c28a66d9 100644 --- a/src/task.c +++ b/src/task.c @@ -1,48 +1,48 @@ #include "global.h" #include "task.h" -#define NUM_TASKS 16 - +#define ACTIVE_SENTINEL 0x10 #define HEAD_SENTINEL 0xFE #define TAIL_SENTINEL 0xFF -struct Task gTasks[NUM_TASKS]; +// gTasks is a queue of the active 16 tasks +struct Task gTasks[ACTIVE_SENTINEL]; static void InsertTask(u8 newTaskId); static u8 FindFirstActiveTask(); void ResetTasks() { - u8 i; + u8 taskId; - for (i = 0; i < NUM_TASKS; i++) + for (taskId = 0; taskId < ACTIVE_SENTINEL; taskId++) { - gTasks[i].isActive = FALSE; - gTasks[i].func = TaskDummy; - gTasks[i].prev = i; - gTasks[i].next = i + 1; - gTasks[i].priority = -1; - memset(gTasks[i].data, 0, sizeof(gTasks[i].data)); + gTasks[taskId].isActive = FALSE; + gTasks[taskId].func = TaskDummy; + gTasks[taskId].prev = taskId; + gTasks[taskId].next = taskId + 1; + gTasks[taskId].priority = -1; + memset(gTasks[taskId].data, 0, sizeof(gTasks[taskId].data)); } gTasks[0].prev = HEAD_SENTINEL; - gTasks[NUM_TASKS - 1].next = TAIL_SENTINEL; + gTasks[ACTIVE_SENTINEL - 1].next = TAIL_SENTINEL; } u8 CreateTask(TaskFunc func, u8 priority) { - u8 i; + u8 taskId; - for (i = 0; i < NUM_TASKS; i++) + for (taskId = 0; taskId < ACTIVE_SENTINEL; taskId++) { - if (!gTasks[i].isActive) + if (!gTasks[taskId].isActive) { - gTasks[i].func = func; - gTasks[i].priority = priority; - InsertTask(i); - memset(gTasks[i].data, 0, sizeof(gTasks[i].data)); - gTasks[i].isActive = TRUE; - return i; + gTasks[taskId].func = func; + gTasks[taskId].priority = priority; + InsertTask(taskId); + memset(gTasks[taskId].data, 0, sizeof(gTasks[taskId].data)); + gTasks[taskId].isActive = TRUE; + return taskId; } } @@ -53,9 +53,9 @@ static void InsertTask(u8 newTaskId) { u8 taskId = FindFirstActiveTask(); - if (taskId == NUM_TASKS) + if (taskId == ACTIVE_SENTINEL) { - // The new task is the only task. + // The task system inserts from the top downwards starting from the end (0xFF) to 0. If FindFirstActiveTask returned the value equivalent to ACTIVE_SENTINEL, it means it is the only task because it searched the entire queue. gTasks[newTaskId].prev = HEAD_SENTINEL; gTasks[newTaskId].next = TAIL_SENTINEL; return; @@ -69,12 +69,14 @@ static void InsertTask(u8 newTaskId) // so we insert the new task before it. gTasks[newTaskId].prev = gTasks[taskId].prev; gTasks[newTaskId].next = taskId; + if (gTasks[taskId].prev != HEAD_SENTINEL) - gTasks[gTasks[taskId].prev].next = newTaskId; + gTasks[gTasks[taskId].prev].next = newTaskId; // as long as we are not at the end, insert the newTask appropriately. + gTasks[taskId].prev = newTaskId; return; } - if (gTasks[taskId].next == TAIL_SENTINEL) + if (gTasks[taskId].next == TAIL_SENTINEL) // we did not find a space for the task, so overwrite the last task as it is the lowest priority. { // We've reached the end. gTasks[newTaskId].prev = taskId; @@ -82,7 +84,7 @@ static void InsertTask(u8 newTaskId) gTasks[taskId].next = newTaskId; return; } - taskId = gTasks[taskId].next; + taskId = gTasks[taskId].next; // neither the priority was lower, nor the end. check the next task. } } @@ -112,11 +114,11 @@ void DestroyTask(u8 taskId) } } -void RunTasks() +void RunTasks(void) { u8 taskId = FindFirstActiveTask(); - if (taskId != NUM_TASKS) + if (taskId != ACTIVE_SENTINEL) { do { @@ -126,11 +128,11 @@ void RunTasks() } } -static u8 FindFirstActiveTask() +static u8 FindFirstActiveTask(void) { u8 taskId; - for (taskId = 0; taskId < NUM_TASKS; taskId++) + for (taskId = 0; taskId < ACTIVE_SENTINEL; taskId++) if (gTasks[taskId].isActive == TRUE && gTasks[taskId].prev == HEAD_SENTINEL) break; @@ -173,7 +175,7 @@ bool8 FuncIsActiveTask(TaskFunc func) { u8 i; - for (i = 0; i < NUM_TASKS; i++) + for (i = 0; i < ACTIVE_SENTINEL; i++) if (gTasks[i].isActive == TRUE && gTasks[i].func == func) return TRUE; @@ -184,19 +186,19 @@ u8 FindTaskIdByFunc(TaskFunc func) { s32 i; - for (i = 0; i < NUM_TASKS; i++) + for (i = 0; i < ACTIVE_SENTINEL; i++) if (gTasks[i].isActive == TRUE && gTasks[i].func == func) return (u8)i; return -1; } -u8 GetTaskCount() +u8 GetTaskCount(void) { u8 i; u8 count = 0; - for (i = 0; i < NUM_TASKS; i++) + for (i = 0; i < ACTIVE_SENTINEL; i++) if (gTasks[i].isActive == TRUE) count++; diff --git a/src/trainer_card.c b/src/trainer_card.c index 5239c6c90..0070e8a9a 100644 --- a/src/trainer_card.c +++ b/src/trainer_card.c @@ -14,6 +14,7 @@ #include "sprite.h" #include "string_util.h" #include "task.h" +#include "script_pokemon_80C4.h" typedef void (*Callback)(void); diff --git a/src/trainer_see.c b/src/trainer_see.c index 9d58faab8..56085f9be 100644 --- a/src/trainer_see.c +++ b/src/trainer_see.c @@ -1,5 +1,4 @@ #include "global.h" -#include "trainer_see.h" #include "asm.h" #include "asm_fieldmap.h" #include "battle_setup.h" @@ -9,6 +8,7 @@ #include "script.h" #include "sprite.h" #include "task.h" +#include "trainer_see.h" extern bool8 (*gIsTrainerInRange[])(struct MapObject *, u16, s16, s16); extern bool8 (*gTrainerSeeFuncList[])(u8, struct Task *, struct MapObject *); |