From 4b4f716ae0c582068928a4ae7b31d9d10ac89eb5 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 8 May 2017 23:13:04 -0700 Subject: finish decompiling mail_data.s --- src/mail_data.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mail_data.c b/src/mail_data.c index 0794d268d..f83484346 100644 --- a/src/mail_data.c +++ b/src/mail_data.c @@ -1,4 +1,5 @@ #include "global.h" +#include "items.h" #include "name_string_util.h" #include "pokemon.h" #include "species.h" @@ -72,8 +73,8 @@ u8 sub_80A2BC4(struct Pokemon *mon, u16 itemId) for (i = 0; i < 4; i++) gSaveBlock1.mail[id].trainerId[i] = gSaveBlock2.playerTrainerId[i]; - species = GetBoxMonData(mon, MON_DATA_SPECIES); - personality = GetBoxMonData(mon, MON_DATA_PERSONALITY); + species = GetBoxMonData(&mon->box, MON_DATA_SPECIES); + personality = GetBoxMonData(&mon->box, MON_DATA_PERSONALITY); gSaveBlock1.mail[id].species = sub_80A2D44(species, personality); gSaveBlock1.mail[id].itemId = _itemId; SetMonData(mon, MON_DATA_MAIL, &id); @@ -92,3 +93,115 @@ u16 sub_80A2D44(u16 species, u32 personality) return species; return ((sub_809D474(personality) << 16) + (30000 << 16)) >> 16; } + +u16 sub_80A2D64(u16 a1, u16 *a2) +{ + u16 result; + + if (a1 >= 30000 && a1 < (30000 + UNOWN_FORM_COUNT)) + { + result = SPECIES_UNOWN; + *a2 = a1 - 30000; + } + else + { + result = a1; + } + + return result; +} + +u8 sub_80A2D88(struct Pokemon *mon, struct MailStruct *mail) +{ + u8 heldItem[2]; + u16 itemId = mail->itemId; + u8 mailId = sub_80A2BC4(mon, itemId); + + if (mailId == 0xFF) + return 0xFF; + + gSaveBlock1.mail[mailId] = *mail; + + SetMonData(mon, MON_DATA_MAIL, &mailId); + + heldItem[0] = itemId; + heldItem[1] = itemId >> 8; + + SetMonData(mon, MON_DATA_HELD_ITEM, heldItem); + + return mailId; +} + +int unref_sub_80A2DF4(void) +{ + return 0; +} + +void sub_80A2DF8(struct Pokemon *mon) +{ + u8 heldItem[2]; + u8 mailId; + + if (sub_80A2B94(mon)) + { + mailId = GetMonData(mon, MON_DATA_MAIL); + gSaveBlock1.mail[mailId].itemId = 0; + mailId = 0xFF; + heldItem[0] = 0; + heldItem[1] = 0; + SetMonData(mon, MON_DATA_MAIL, &mailId); + SetMonData(mon, MON_DATA_HELD_ITEM, heldItem); + } +} + +void unref_sub_80A2E58(u8 mailId) +{ + gSaveBlock1.mail[mailId].itemId = 0; +} + +u8 sub_80A2E78(struct Pokemon *mon) +{ + u8 i; + u8 newHeldItem[2]; + u8 newMailId; + + newHeldItem[0] = 0; + newHeldItem[1] = 0; + newMailId = 0xFF; + + for (i = 6; i < 16; i++) + { + if (gSaveBlock1.mail[i].itemId == 0) + { + memcpy(&gSaveBlock1.mail[i], &gSaveBlock1.mail[GetMonData(mon, MON_DATA_MAIL)], sizeof(struct MailStruct)); + gSaveBlock1.mail[GetMonData(mon, MON_DATA_MAIL)].itemId = 0; + SetMonData(mon, MON_DATA_MAIL, &newMailId); + SetMonData(mon, MON_DATA_HELD_ITEM, newHeldItem); + return i; + } + } + + return 0xFF; +} + +bool8 itemid_is_mail(u16 itemId) +{ + switch (itemId) + { + case ITEM_ORANGE_MAIL: + case ITEM_HARBOR_MAIL: + case ITEM_GLITTER_MAIL: + case ITEM_MECH_MAIL: + case ITEM_WOOD_MAIL: + case ITEM_WAVE_MAIL: + case ITEM_BEAD_MAIL: + case ITEM_SHADOW_MAIL: + case ITEM_TROPIC_MAIL: + case ITEM_DREAM_MAIL: + case ITEM_FAB_MAIL: + case ITEM_RETRO_MAIL: + return TRUE; + default: + return FALSE; + } +} -- cgit v1.2.3 From 964b665d2a17295ae3a06be0439ef6ae5ccc3444 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Tue, 9 May 2017 00:24:51 -0700 Subject: name mail_data.c functions --- src/mail.c | 2 +- src/mail_data.c | 50 +++++++++++++++++++++++++++----------------------- src/new_game.c | 2 +- 3 files changed, 29 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/mail.c b/src/mail.c index 1bd4e73dc..9964f2a79 100644 --- a/src/mail.c +++ b/src/mail.c @@ -116,7 +116,7 @@ void HandleReadMail(struct MailStruct *arg0, MainCallback arg1, bool8 arg2) break; } - if (((sub_80A2D64(arg0->species, buffer) << 16) + 0xFFFF0000) <= (410 << 16)) + if (((MailSpeciesToSpecies(arg0->species, buffer) << 16) + 0xFFFF0000) <= (410 << 16)) { switch (ewram0.varFA) { diff --git a/src/mail_data.c b/src/mail_data.c index f83484346..23d22e21f 100644 --- a/src/mail_data.c +++ b/src/mail_data.c @@ -5,20 +5,20 @@ #include "species.h" #include "text.h" -void sub_80A2B40(struct MailStruct *); -u16 sub_80A2D44(u16, u32); -bool8 itemid_is_mail(u16); -u16 sub_809D474(u32); +void ClearMailStruct(struct MailStruct *); +u16 SpeciesToMailSpecies(u16, u32); +bool8 ItemIsMail(u16); +u16 GetUnownLetterByPersonality(u32); -void sub_80A2B18(void) +void ClearMailData(void) { u8 i; for (i = 0; i < 16; i++) - sub_80A2B40(&gSaveBlock1.mail[i]); + ClearMailStruct(&gSaveBlock1.mail[i]); } -void sub_80A2B40(struct MailStruct *mail) +void ClearMailStruct(struct MailStruct *mail) { int i; @@ -35,16 +35,16 @@ void sub_80A2B40(struct MailStruct *mail) mail->itemId = 0; } -bool8 sub_80A2B94(struct Pokemon *mon) +bool8 MonHasMail(struct Pokemon *mon) { u16 heldItem = GetMonData(mon, MON_DATA_HELD_ITEM); - if (itemid_is_mail(heldItem) && GetMonData(mon, MON_DATA_MAIL) != 0xFF) + if (ItemIsMail(heldItem) && GetMonData(mon, MON_DATA_MAIL) != 0xFF) return TRUE; else return FALSE; } -u8 sub_80A2BC4(struct Pokemon *mon, u16 itemId) +u8 GiveMailToMon(struct Pokemon *mon, u16 itemId) { u16 _itemId; u8 heldItem[2]; @@ -75,7 +75,7 @@ u8 sub_80A2BC4(struct Pokemon *mon, u16 itemId) species = GetBoxMonData(&mon->box, MON_DATA_SPECIES); personality = GetBoxMonData(&mon->box, MON_DATA_PERSONALITY); - gSaveBlock1.mail[id].species = sub_80A2D44(species, personality); + gSaveBlock1.mail[id].species = SpeciesToMailSpecies(species, personality); gSaveBlock1.mail[id].itemId = _itemId; SetMonData(mon, MON_DATA_MAIL, &id); SetMonData(mon, MON_DATA_HELD_ITEM, heldItem); @@ -87,14 +87,18 @@ u8 sub_80A2BC4(struct Pokemon *mon, u16 itemId) return -1; } -u16 sub_80A2D44(u16 species, u32 personality) +u16 SpeciesToMailSpecies(u16 species, u32 personality) { - if (species != SPECIES_UNOWN) - return species; - return ((sub_809D474(personality) << 16) + (30000 << 16)) >> 16; + if (species == SPECIES_UNOWN) + { + int mailSpecies = GetUnownLetterByPersonality(personality) + 30000; + return mailSpecies; + } + + return species; } -u16 sub_80A2D64(u16 a1, u16 *a2) +u16 MailSpeciesToSpecies(u16 a1, u16 *a2) { u16 result; @@ -111,11 +115,11 @@ u16 sub_80A2D64(u16 a1, u16 *a2) return result; } -u8 sub_80A2D88(struct Pokemon *mon, struct MailStruct *mail) +u8 GiveMailToMon2(struct Pokemon *mon, struct MailStruct *mail) { u8 heldItem[2]; u16 itemId = mail->itemId; - u8 mailId = sub_80A2BC4(mon, itemId); + u8 mailId = GiveMailToMon(mon, itemId); if (mailId == 0xFF) return 0xFF; @@ -137,12 +141,12 @@ int unref_sub_80A2DF4(void) return 0; } -void sub_80A2DF8(struct Pokemon *mon) +void TakeMailFromMon(struct Pokemon *mon) { u8 heldItem[2]; u8 mailId; - if (sub_80A2B94(mon)) + if (MonHasMail(mon)) { mailId = GetMonData(mon, MON_DATA_MAIL); gSaveBlock1.mail[mailId].itemId = 0; @@ -154,12 +158,12 @@ void sub_80A2DF8(struct Pokemon *mon) } } -void unref_sub_80A2E58(u8 mailId) +void DeleteMail(u8 mailId) { gSaveBlock1.mail[mailId].itemId = 0; } -u8 sub_80A2E78(struct Pokemon *mon) +u8 TakeMailFromMon2(struct Pokemon *mon) { u8 i; u8 newHeldItem[2]; @@ -184,7 +188,7 @@ u8 sub_80A2E78(struct Pokemon *mon) return 0xFF; } -bool8 itemid_is_mail(u16 itemId) +bool8 ItemIsMail(u16 itemId) { switch (itemId) { diff --git a/src/new_game.c b/src/new_game.c index 3b93d37cc..ca53ff15f 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -116,7 +116,7 @@ void NewGameInitData(void) sub_808C02C(); sub_8052DE4(); memset(&gSaveBlock1, 0, sizeof(gSaveBlock1)); - sub_80A2B18(); + ClearMailData(); gSaveBlock2.specialSaveWarp = 0; set_player_trainer_id(); PlayTimeCounter_Reset(); -- cgit v1.2.3 From 60cf06cccacb692bbd2270b08ad0d583a8a76090 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Tue, 9 May 2017 01:12:59 -0700 Subject: name new-game functions --- src/dewford_trend.c | 2 +- src/new_game.c | 24 ++++++++++++------------ src/pokedex.c | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/dewford_trend.c b/src/dewford_trend.c index b90100d90..fe9311655 100644 --- a/src/dewford_trend.c +++ b/src/dewford_trend.c @@ -19,7 +19,7 @@ static bool8 SB1ContainsWords(u16 *a); static bool8 IsEasyChatPairEqual(u16 *words1, u16 *words2); static s16 sub_80FA828(struct EasyChatPair *a, u16 b); -void sub_80FA17C(void) +void InitDewfordTrends(void) { u16 i; diff --git a/src/new_game.c b/src/new_game.c index ca53ff15f..8fa946748 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -47,7 +47,7 @@ void copy_word_to_mem(u8 *copyTo, u8 *copyFrom) copyTo[i] = copyFrom[i]; } -void set_player_trainer_id(void) +void InitPlayerTrainerId(void) { write_word_to_mem((Random() << 16) | Random(), gSaveBlock2.playerTrainerId); } @@ -113,21 +113,21 @@ void NewGameInitData(void) gDifferentSaveFile = 1; ZeroPlayerPartyMons(); ZeroEnemyPartyMons(); - sub_808C02C(); + ResetPokedex(); sub_8052DE4(); memset(&gSaveBlock1, 0, sizeof(gSaveBlock1)); ClearMailData(); gSaveBlock2.specialSaveWarp = 0; - set_player_trainer_id(); + InitPlayerTrainerId(); PlayTimeCounter_Reset(); ClearPokedexFlags(); InitEventData(); - sub_80BD7A8(); - sub_80BDAB4(); - sub_80BB5B4(); + ClearTVShowData(); + ResetGabbyAndTy(); + ResetSecretBases(); ClearBerryTrees(); gSaveBlock1.money = 3000; - sub_80AB1B0(); + ResetLinkContestBoolean(); ResetGameStats(); sub_8052DA8(); InitLinkBattleRecords(); @@ -135,18 +135,18 @@ void NewGameInitData(void) InitBarboachSizeRecord(); gPlayerPartyCount = 0; ZeroPlayerPartyMons(); - sub_80961D8(); + ResetPokemonStorageSystem(); ClearRoamerData(); ClearRoamerLocationData(); gSaveBlock1.registeredItem = 0; - sub_80A3714(); + ClearItems(); NewGameInitPCItems(); sub_810C994(); sub_8133F80(); - sub_80E6764(); + InitEasyChatPhrases(); SetMauvilleOldMan(); - sub_80FA17C(); - sub_810FA54(); + InitDewfordTrends(); + ResetFanClub(); ResetLotteryCorner(); WarpToTruck(); ScriptContext2_RunNewScript(gUnknown_0819FA81); diff --git a/src/pokedex.c b/src/pokedex.c index 3ef1de51e..d31d649e0 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -115,7 +115,7 @@ u16 NationalPokedexNumToSpecies(u16); // asm/pokedex_area_screen void ShowPokedexAreaScreen(u16 species, u8 *string); -void sub_808C02C(void) +void ResetPokedex(void) { u16 i; -- cgit v1.2.3 From 3ee2e8ce97c33eb9bc837779c8a46b546d805367 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Tue, 9 May 2017 01:56:49 -0700 Subject: name more functions --- src/field_control_avatar.c | 2 +- src/field_special_scene.c | 4 ++-- src/new_game.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 1f049c0bd..c5f2c08e7 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -517,7 +517,7 @@ bool8 sub_8068894(void) } if (SafariZoneTakeStep() == TRUE) return TRUE; - if (sub_810D9B0(1) == TRUE) + if (CountSSTidalStep(1) == TRUE) { ScriptContext1_SetupScript(gUnknown_0815FD0D); return TRUE; diff --git a/src/field_special_scene.c b/src/field_special_scene.c index fc4d96e18..59280b743 100644 --- a/src/field_special_scene.c +++ b/src/field_special_scene.c @@ -239,7 +239,7 @@ bool8 sub_80C7754(void) s8 mapGroup, mapNum; s16 x, y; - if (sub_810D9EC(&mapGroup, &mapNum, &x, &y)) + if (GetSSTidalLocation(&mapGroup, &mapNum, &x, &y)) { return FALSE; } @@ -270,7 +270,7 @@ void Task_HandlePorthole(u8 taskId) data[1] = 1; if (!sub_80A212C(0xFF, location->mapNum, location->mapGroup)) return; - if (sub_810D9B0(1) == TRUE) + if (CountSSTidalStep(1) == TRUE) { if (*var == 2) *var = 9; diff --git a/src/new_game.c b/src/new_game.c index 8fa946748..6d2722c44 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -139,10 +139,10 @@ void NewGameInitData(void) ClearRoamerData(); ClearRoamerLocationData(); gSaveBlock1.registeredItem = 0; - ClearItems(); + ClearBag(); NewGameInitPCItems(); - sub_810C994(); - sub_8133F80(); + ClearPokeblocks(); + ClearDecorationInventories(); InitEasyChatPhrases(); SetMauvilleOldMan(); InitDewfordTrends(); -- cgit v1.2.3 From ca3da9a99901a20aa1b32a2bd9063fb49bb8612a Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Tue, 9 May 2017 03:46:55 -0700 Subject: file renaming --- src/battle_setup.c | 2 +- src/field_effect.c | 2 +- src/field_fadetransition.c | 2 +- src/field_screeneffect.c | 368 --------------------------------------------- src/field_weather.c | 368 +++++++++++++++++++++++++++++++++++++++++++++ src/item_use.c | 2 +- src/player_pc.c | 2 +- src/rom4.c | 2 +- src/scrcmd.c | 2 +- src/shop.c | 2 +- src/start_menu.c | 2 +- 11 files changed, 377 insertions(+), 377 deletions(-) delete mode 100644 src/field_screeneffect.c create mode 100644 src/field_weather.c (limited to 'src') diff --git a/src/battle_setup.c b/src/battle_setup.c index abc0b978d..0753fba70 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -7,7 +7,7 @@ #include "field_map_obj_helpers.h" #include "field_message_box.h" #include "field_player_avatar.h" -#include "field_screeneffect.h" +#include "field_weather.h" #include "main.h" #include "map_constants.h" #include "metatile_behavior.h" diff --git a/src/field_effect.c b/src/field_effect.c index 1b2346a00..bbc1144c1 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -1,6 +1,6 @@ #include "global.h" #include "field_effect.h" -#include "field_screeneffect.h" +#include "field_weather.h" #include "sprite.h" #include "text.h" diff --git a/src/field_fadetransition.c b/src/field_fadetransition.c index f7d591c69..b5e6c1039 100644 --- a/src/field_fadetransition.c +++ b/src/field_fadetransition.c @@ -1,6 +1,6 @@ #include "global.h" #include "gba/syscall.h" -#include "field_screeneffect.h" +#include "field_weather.h" #include "global.fieldmap.h" #include "script.h" #include "task.h" diff --git a/src/field_screeneffect.c b/src/field_screeneffect.c deleted file mode 100644 index 6cae0c18a..000000000 --- a/src/field_screeneffect.c +++ /dev/null @@ -1,368 +0,0 @@ -#include "global.h" -#include "field_screeneffect.h" -#include "asm.h" -#include "palette.h" -#include "sprite.h" -#include "task.h" - -struct Weather -{ - u8 filler_000[0x200]; - u8 unknown_200[2][32]; - u8 filler_240[0x480]; - s8 unknown_6C0; - s8 unknown_6C1; - u8 unknown_6C2; - u8 unknown_6C3; - u16 unknown_6C4; - u8 unknown_6C6; - u8 unknown_6C7; - u8 unknown_6C8; - u8 unknown_6C9; - u8 unknown_6CA; - u8 unknown_6CB; - u8 filler_6CC[2]; - u16 unknown_6CE; - u8 unknown_6D0; - u8 unknown_6D1; - u8 filler_6D2[1]; - u8 unknown_6D3; - u8 unknown_6D4; - u8 unknown_6D5; - u8 filler_6D6[2]; - u8 unknown_6D8; - u8 filler_6D9[1]; - u8 unknown_6DA; - u8 filler_6DB[3]; - u8 unknown_6DE; - u8 filler_6DF[5]; - u8 unknown_6E4; - u8 filler_6E5[0x15]; - u8 unknown_6FA; - u8 unknown_6FB; - u8 filler_6FC[4]; - u8 unknown_700; - u8 filler_701[0x15]; - u8 unknown_716; - u8 unknown_717; - u8 filler_718[0xc]; - u8 unknown_724; - u8 filler_725[9]; - u8 unknown_72E; -}; - -#define gWeather gUnknown_0202F7E8 -extern struct Weather gWeather; -extern u8 *gUnknown_083970E8; -extern u8 (*gUnknown_08396FC8[][4])(void); -extern u8 (*gUnknown_083970B8[])(void); -extern u8 *gUnknown_030006DC; -extern u8 gUnknown_083970C8; -extern u8 (*gUnknown_0202FC48)[32]; -extern u8 gUnknown_0202F9E8[32]; - - -void sub_807C828(void) -{ - u8 index; - if (!FuncIsActiveTask(&sub_807CA34)) - { - index = AllocSpritePalette(0x1200); - CpuCopy32(&gUnknown_083970E8, &gPlttBufferUnfaded[0x100 + index * 16], 32); - sub_807CB10(); - gWeather.unknown_6D5 = index; - gWeather.unknown_6D4 = AllocSpritePalette(0x1201); - gWeather.unknown_6DA = 0; - gWeather.unknown_6D8 = 0; - gWeather.unknown_6DE = 0; - gWeather.unknown_6E4 = 0; - gWeather.unknown_700 = 0; - gWeather.unknown_6FB = 0; - gWeather.unknown_724 = 0; - gWeather.unknown_716 = 0; - gWeather.unknown_717 = 0; - gWeather.unknown_72E = 0; - gWeather.unknown_6FA = 0; - sub_807DB64(16, 0); - gWeather.unknown_6D0 = 0; - gWeather.unknown_6C6 = 3; - gWeather.unknown_6C8 = 0; - gWeather.unknown_6D3 = 1; - gWeather.unknown_6C9 = CreateTask(&sub_807C9E4, 80); - } -} - -void DoWeatherEffect(u8 effect) -{ - if (effect != 3 && effect != 5 && effect != 13) - { - PlayRainSoundEffect(); - } - if (gWeather.unknown_6D1 != effect && gWeather.unknown_6D0 == effect) - { - gUnknown_08396FC8[effect][0](); - } - gWeather.unknown_6D3 = 0; - gWeather.unknown_6D1 = effect; - gWeather.unknown_6CE = 0; -} - -void sub_807C988(u8 effect) -{ - PlayRainSoundEffect(); - gWeather.unknown_6D0 = effect; - gWeather.unknown_6D1 = effect; -} - -void sub_807C9B4(u8 effect) -{ - PlayRainSoundEffect(); - gWeather.unknown_6D0 = effect; - gWeather.unknown_6D1 = effect; - gWeather.unknown_6C8 = 1; -} - -void sub_807C9E4(u8 task) -{ - if (gWeather.unknown_6C8) - { - gUnknown_08396FC8[gWeather.unknown_6D0][2](); - gTasks[task].func = &sub_807CA34; - } -} - -void sub_807CA34(u8 task) -{ - u8 v1; - if (gWeather.unknown_6D0 != gWeather.unknown_6D1) - { - v1 = gUnknown_08396FC8[gWeather.unknown_6D0][3](); - if (!v1) - { - gUnknown_08396FC8[gWeather.unknown_6D1][0](); - gWeather.unknown_6C3 = 0; // compiler reuses v1 - gWeather.unknown_6C6 = 0; // compiler reuses v1 - gWeather.unknown_6D0 = gWeather.unknown_6D1; - gWeather.unknown_6D3 = 1; - } - } - else - { - gUnknown_08396FC8[gWeather.unknown_6D0][1](); - } - gUnknown_083970B8[gWeather.unknown_6C6](); -} - -void sub_807CAE8(void) -{ - gWeather.unknown_6C1 = 0; - gWeather.unknown_6C2 = 0; -} - -void nullsub_38(void) -{ -} - -u32 sub_807CB0C(void) -{ - return 0; -} - -void sub_807CB10(void) -{ - u16 v0; - u8(*v1)[32]; - u16 v2; - u16 v4; - u16 v5; - u16 v6; - u16 v9; - u32 v10; - u16 v11; - s16 dunno; - - gUnknown_030006DC = &gUnknown_083970C8; - for (v0 = 0; v0 <= 1; v0++) - { - if (v0 == 0) - { - v1 = &gUnknown_0202F9E8; - } - else - { - v1 = &gUnknown_0202F9E8 + 19; - } - for (v2 = 0; (u16)v2 <= 0x1f; v2++) - { - v4 = v2 << 8; - if (v0 == 0) - { - v5 = (v2 << 8) / 16; - } - else - { - v5 = 0; - } - v6 = 0; - for (; v6 <= 2; v6++) - { - v4 = (v4 - v5); - v1[v6][v2] = v4 >> 8; - } - v9 = v4; - v10 = 0x1f00 - v4; - if ((0x1f00 - v4) < 0) - { - v10 += 0xf; - } - v11 = v10 >> 4; - if (v2 <= 0xb) - { - for (; v6 <= 0x12; v6++) - { - v4 += v11; - dunno = v4 - v9; - if (dunno > 0) - { - v4 -= (dunno + ((u16)dunno >> 15)) >> 1; - } - v1[v6][v2] = v4 >> 8; - if (v1[v6][v2] > 0x1f) - { - v1[v6][v2] = 0x1f; - } - } - } - else - { - for (; v6 <= 0x12; v6++) - { - v4 += v11; - v1[v6][v2] = v4 >> 8; - if (v1[v6][v2] > 0x1f) - { - v1[v6][v2] = 0x1f; - } - } - } - } - } -} - -void sub_807CC24(void) -{ - if (gWeather.unknown_6C0 == gWeather.unknown_6C1) - { - gWeather.unknown_6C6 = 3; - } - else - { - if (++gWeather.unknown_6C3 >= gWeather.unknown_6C2) - { - gWeather.unknown_6C3 = 0; - if (gWeather.unknown_6C0 < gWeather.unknown_6C1) - { - gWeather.unknown_6C0++; - } - else - { - gWeather.unknown_6C0--; - } - sub_807CEBC(0, 0x20, gWeather.unknown_6C0); - } - } -} - -void sub_807CCAC(void) -{ - if (++gWeather.unknown_6CB > 1) - { - gWeather.unknown_6CA = 0; - } - switch (gWeather.unknown_6D0) - { - case 3: - case 4: - case 5: - case 11: - case 13: - if (sub_807CDC4() == 0) - { - gWeather.unknown_6C0 = 3; - gWeather.unknown_6C6 = 3; - } - break; - case 12: - if (sub_807CE24() == 0) - { - gWeather.unknown_6C0 = -6; - gWeather.unknown_6C6 = 3; - } - break; - case 6: - if (sub_807CE7C() == 0) - { - gWeather.unknown_6C0 = 0; - gWeather.unknown_6C6 = 3; - } - break; - case 7: - case 8: - case 9: - case 10: - default: - if (!gPaletteFade.active) - { - gWeather.unknown_6C0 = gWeather.unknown_6C1; - gWeather.unknown_6C6 = 3; - } - break; - } -} - -u8 sub_807CDC4(void) -{ - if (gWeather.unknown_6C7 == 0x10) - { - return 0; - } - if (++gWeather.unknown_6C7 >= 0x10) - { - sub_807CEBC(0, 0x20, 3); - gWeather.unknown_6C7 = 0x10; - return 0; - } - sub_807D1BC(0, 0x20, 3, 0x10 - gWeather.unknown_6C7, gWeather.unknown_6C4); - return 1; -} - -u8 sub_807CE24(void) -{ - if (gWeather.unknown_6C7 == 0x10) - { - return 0; - } - if (++gWeather.unknown_6C7 >= 0x10) - { - sub_807CEBC(0, 0x20, -6); - gWeather.unknown_6C7 = 0x10; - return 0; - } - sub_807D304(-6, 0x10 - gWeather.unknown_6C7, gWeather.unknown_6C4); - return 1; -} - -u8 sub_807CE7C(void) -{ - if (gWeather.unknown_6C7 == 0x10) - { - return 0; - } - ++gWeather.unknown_6C7; - sub_807D424(0x10 - gWeather.unknown_6C7, gWeather.unknown_6C4); - return 1; -} - -void nullsub_39(void) -{ -} diff --git a/src/field_weather.c b/src/field_weather.c new file mode 100644 index 000000000..ff5d5b507 --- /dev/null +++ b/src/field_weather.c @@ -0,0 +1,368 @@ +#include "global.h" +#include "field_weather.h" +#include "asm.h" +#include "palette.h" +#include "sprite.h" +#include "task.h" + +struct Weather +{ + u8 filler_000[0x200]; + u8 unknown_200[2][32]; + u8 filler_240[0x480]; + s8 unknown_6C0; + s8 unknown_6C1; + u8 unknown_6C2; + u8 unknown_6C3; + u16 unknown_6C4; + u8 unknown_6C6; + u8 unknown_6C7; + u8 unknown_6C8; + u8 unknown_6C9; + u8 unknown_6CA; + u8 unknown_6CB; + u8 filler_6CC[2]; + u16 unknown_6CE; + u8 unknown_6D0; + u8 unknown_6D1; + u8 filler_6D2[1]; + u8 unknown_6D3; + u8 unknown_6D4; + u8 unknown_6D5; + u8 filler_6D6[2]; + u8 unknown_6D8; + u8 filler_6D9[1]; + u8 unknown_6DA; + u8 filler_6DB[3]; + u8 unknown_6DE; + u8 filler_6DF[5]; + u8 unknown_6E4; + u8 filler_6E5[0x15]; + u8 unknown_6FA; + u8 unknown_6FB; + u8 filler_6FC[4]; + u8 unknown_700; + u8 filler_701[0x15]; + u8 unknown_716; + u8 unknown_717; + u8 filler_718[0xc]; + u8 unknown_724; + u8 filler_725[9]; + u8 unknown_72E; +}; + +#define gWeather gUnknown_0202F7E8 +extern struct Weather gWeather; +extern u8 *gUnknown_083970E8; +extern u8 (*gUnknown_08396FC8[][4])(void); +extern u8 (*gUnknown_083970B8[])(void); +extern u8 *gUnknown_030006DC; +extern u8 gUnknown_083970C8; +extern u8 (*gUnknown_0202FC48)[32]; +extern u8 gUnknown_0202F9E8[32]; + + +void sub_807C828(void) +{ + u8 index; + if (!FuncIsActiveTask(&sub_807CA34)) + { + index = AllocSpritePalette(0x1200); + CpuCopy32(&gUnknown_083970E8, &gPlttBufferUnfaded[0x100 + index * 16], 32); + sub_807CB10(); + gWeather.unknown_6D5 = index; + gWeather.unknown_6D4 = AllocSpritePalette(0x1201); + gWeather.unknown_6DA = 0; + gWeather.unknown_6D8 = 0; + gWeather.unknown_6DE = 0; + gWeather.unknown_6E4 = 0; + gWeather.unknown_700 = 0; + gWeather.unknown_6FB = 0; + gWeather.unknown_724 = 0; + gWeather.unknown_716 = 0; + gWeather.unknown_717 = 0; + gWeather.unknown_72E = 0; + gWeather.unknown_6FA = 0; + sub_807DB64(16, 0); + gWeather.unknown_6D0 = 0; + gWeather.unknown_6C6 = 3; + gWeather.unknown_6C8 = 0; + gWeather.unknown_6D3 = 1; + gWeather.unknown_6C9 = CreateTask(&sub_807C9E4, 80); + } +} + +void DoWeatherEffect(u8 effect) +{ + if (effect != 3 && effect != 5 && effect != 13) + { + PlayRainSoundEffect(); + } + if (gWeather.unknown_6D1 != effect && gWeather.unknown_6D0 == effect) + { + gUnknown_08396FC8[effect][0](); + } + gWeather.unknown_6D3 = 0; + gWeather.unknown_6D1 = effect; + gWeather.unknown_6CE = 0; +} + +void sub_807C988(u8 effect) +{ + PlayRainSoundEffect(); + gWeather.unknown_6D0 = effect; + gWeather.unknown_6D1 = effect; +} + +void sub_807C9B4(u8 effect) +{ + PlayRainSoundEffect(); + gWeather.unknown_6D0 = effect; + gWeather.unknown_6D1 = effect; + gWeather.unknown_6C8 = 1; +} + +void sub_807C9E4(u8 task) +{ + if (gWeather.unknown_6C8) + { + gUnknown_08396FC8[gWeather.unknown_6D0][2](); + gTasks[task].func = &sub_807CA34; + } +} + +void sub_807CA34(u8 task) +{ + u8 v1; + if (gWeather.unknown_6D0 != gWeather.unknown_6D1) + { + v1 = gUnknown_08396FC8[gWeather.unknown_6D0][3](); + if (!v1) + { + gUnknown_08396FC8[gWeather.unknown_6D1][0](); + gWeather.unknown_6C3 = 0; // compiler reuses v1 + gWeather.unknown_6C6 = 0; // compiler reuses v1 + gWeather.unknown_6D0 = gWeather.unknown_6D1; + gWeather.unknown_6D3 = 1; + } + } + else + { + gUnknown_08396FC8[gWeather.unknown_6D0][1](); + } + gUnknown_083970B8[gWeather.unknown_6C6](); +} + +void sub_807CAE8(void) +{ + gWeather.unknown_6C1 = 0; + gWeather.unknown_6C2 = 0; +} + +void nullsub_38(void) +{ +} + +u32 sub_807CB0C(void) +{ + return 0; +} + +void sub_807CB10(void) +{ + u16 v0; + u8(*v1)[32]; + u16 v2; + u16 v4; + u16 v5; + u16 v6; + u16 v9; + u32 v10; + u16 v11; + s16 dunno; + + gUnknown_030006DC = &gUnknown_083970C8; + for (v0 = 0; v0 <= 1; v0++) + { + if (v0 == 0) + { + v1 = &gUnknown_0202F9E8; + } + else + { + v1 = &gUnknown_0202F9E8 + 19; + } + for (v2 = 0; (u16)v2 <= 0x1f; v2++) + { + v4 = v2 << 8; + if (v0 == 0) + { + v5 = (v2 << 8) / 16; + } + else + { + v5 = 0; + } + v6 = 0; + for (; v6 <= 2; v6++) + { + v4 = (v4 - v5); + v1[v6][v2] = v4 >> 8; + } + v9 = v4; + v10 = 0x1f00 - v4; + if ((0x1f00 - v4) < 0) + { + v10 += 0xf; + } + v11 = v10 >> 4; + if (v2 <= 0xb) + { + for (; v6 <= 0x12; v6++) + { + v4 += v11; + dunno = v4 - v9; + if (dunno > 0) + { + v4 -= (dunno + ((u16)dunno >> 15)) >> 1; + } + v1[v6][v2] = v4 >> 8; + if (v1[v6][v2] > 0x1f) + { + v1[v6][v2] = 0x1f; + } + } + } + else + { + for (; v6 <= 0x12; v6++) + { + v4 += v11; + v1[v6][v2] = v4 >> 8; + if (v1[v6][v2] > 0x1f) + { + v1[v6][v2] = 0x1f; + } + } + } + } + } +} + +void sub_807CC24(void) +{ + if (gWeather.unknown_6C0 == gWeather.unknown_6C1) + { + gWeather.unknown_6C6 = 3; + } + else + { + if (++gWeather.unknown_6C3 >= gWeather.unknown_6C2) + { + gWeather.unknown_6C3 = 0; + if (gWeather.unknown_6C0 < gWeather.unknown_6C1) + { + gWeather.unknown_6C0++; + } + else + { + gWeather.unknown_6C0--; + } + sub_807CEBC(0, 0x20, gWeather.unknown_6C0); + } + } +} + +void sub_807CCAC(void) +{ + if (++gWeather.unknown_6CB > 1) + { + gWeather.unknown_6CA = 0; + } + switch (gWeather.unknown_6D0) + { + case 3: + case 4: + case 5: + case 11: + case 13: + if (sub_807CDC4() == 0) + { + gWeather.unknown_6C0 = 3; + gWeather.unknown_6C6 = 3; + } + break; + case 12: + if (sub_807CE24() == 0) + { + gWeather.unknown_6C0 = -6; + gWeather.unknown_6C6 = 3; + } + break; + case 6: + if (sub_807CE7C() == 0) + { + gWeather.unknown_6C0 = 0; + gWeather.unknown_6C6 = 3; + } + break; + case 7: + case 8: + case 9: + case 10: + default: + if (!gPaletteFade.active) + { + gWeather.unknown_6C0 = gWeather.unknown_6C1; + gWeather.unknown_6C6 = 3; + } + break; + } +} + +u8 sub_807CDC4(void) +{ + if (gWeather.unknown_6C7 == 0x10) + { + return 0; + } + if (++gWeather.unknown_6C7 >= 0x10) + { + sub_807CEBC(0, 0x20, 3); + gWeather.unknown_6C7 = 0x10; + return 0; + } + sub_807D1BC(0, 0x20, 3, 0x10 - gWeather.unknown_6C7, gWeather.unknown_6C4); + return 1; +} + +u8 sub_807CE24(void) +{ + if (gWeather.unknown_6C7 == 0x10) + { + return 0; + } + if (++gWeather.unknown_6C7 >= 0x10) + { + sub_807CEBC(0, 0x20, -6); + gWeather.unknown_6C7 = 0x10; + return 0; + } + sub_807D304(-6, 0x10 - gWeather.unknown_6C7, gWeather.unknown_6C4); + return 1; +} + +u8 sub_807CE7C(void) +{ + if (gWeather.unknown_6C7 == 0x10) + { + return 0; + } + ++gWeather.unknown_6C7; + sub_807D424(0x10 - gWeather.unknown_6C7, gWeather.unknown_6C4); + return 1; +} + +void nullsub_39(void) +{ +} diff --git a/src/item_use.c b/src/item_use.c index 762bb70f2..4047ade5c 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -6,7 +6,7 @@ #include "event_data.h" #include "field_map_obj_helpers.h" #include "field_player_avatar.h" -#include "field_screeneffect.h" +#include "field_weather.h" #include "fieldmap.h" #include "item.h" #include "items.h" diff --git a/src/player_pc.c b/src/player_pc.c index 02a2dc1a2..f0f0709b1 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -1,6 +1,6 @@ #include "global.h" #include "asm.h" -#include "field_screeneffect.h" +#include "field_weather.h" #include "item.h" #include "items.h" #include "main.h" diff --git a/src/rom4.c b/src/rom4.c index 5beb698ab..79ac6d769 100644 --- a/src/rom4.c +++ b/src/rom4.c @@ -13,7 +13,7 @@ #include "field_map_obj_helpers.h" #include "field_message_box.h" #include "field_player_avatar.h" -#include "field_screeneffect.h" +#include "field_weather.h" #include "field_special_scene.h" #include "heal_location.h" #include "link.h" diff --git a/src/scrcmd.c b/src/scrcmd.c index 7569462e6..136181bd3 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -13,7 +13,7 @@ #include "field_map_obj_helpers.h" #include "field_message_box.h" #include "field_player_avatar.h" -#include "field_screeneffect.h" +#include "field_weather.h" #include "item.h" #include "main.h" #include "map_obj_lock.h" diff --git a/src/shop.c b/src/shop.c index c78771be7..780dff02a 100644 --- a/src/shop.c +++ b/src/shop.c @@ -1,7 +1,7 @@ #include "global.h" #include "asm.h" #include "decompress.h" -#include "field_screeneffect.h" +#include "field_weather.h" #include "main.h" #include "menu.h" #include "money.h" diff --git a/src/start_menu.c b/src/start_menu.c index 48217219d..4a3bcbbd3 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -4,7 +4,7 @@ #include "event_data.h" #include "field_map_obj_helpers.h" #include "field_player_avatar.h" -#include "field_screeneffect.h" +#include "field_weather.h" #include "load_save.h" #include "main.h" #include "map_obj_lock.h" -- cgit v1.2.3 From 171ded2af0646249f1696aeac001a2c7ebe7d82c Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Tue, 9 May 2017 15:01:27 +0200 Subject: Decompile sub_80F700C --- src/pokenav.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/pokenav.c (limited to 'src') diff --git a/src/pokenav.c b/src/pokenav.c new file mode 100644 index 000000000..60e7c73e1 --- /dev/null +++ b/src/pokenav.c @@ -0,0 +1,45 @@ +#include "global.h" +#include "battle.h" +#include "string_util.h" + +struct UnkPokenavStruct_Sub { + /*0x0*/ u16 unk0; + /*0x2*/ u8 filler2[6]; +}; + + +struct UnkPokenavStruct { + /*0x0000*/ u8 filler0000[0xCEE8]; + /*0xCEE8*/ struct UnkPokenavStruct_Sub unkCEE8[78]; + /*0xD158*/ u16 unkD158; + +}; + +extern struct UnkPokenavStruct *gUnknown_083DFEC4; + +extern const struct Trainer gTrainers[]; +extern const u8 gTrainerClassNames[][13]; + +void sub_80F700C(u8 *arg0, u16 arg1) { + struct Trainer *trainer; + u8 *ptr; + + trainer = (struct Trainer *) &gTrainers[gUnknown_083DFEC4->unkCEE8[arg1].unk0]; + + ptr = arg0; + if (arg1 < gUnknown_083DFEC4->unkD158) + { + ptr = StringCopy(ptr, gTrainerClassNames[trainer->trainerClass]); + + ptr[0] = 0xFC; + ptr[1] = 0x13; + ptr[2] = 0x4B; + ptr += 3; + ptr = StringCopy(ptr, trainer->trainerName); + } + + ptr[0] = 0xFC; + ptr[1] = 0x13; + ptr[2] = 0x80; + ptr[3] = 0xFF; +} -- cgit v1.2.3 From 26be659edab6f15d8aec2c563d61318ac186aa90 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Tue, 9 May 2017 15:01:40 +0200 Subject: Decompile sub_80BC190 --- src/secret_base.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/secret_base.c (limited to 'src') diff --git a/src/secret_base.c b/src/secret_base.c new file mode 100644 index 000000000..572dfaa1d --- /dev/null +++ b/src/secret_base.c @@ -0,0 +1,18 @@ +#include "global.h" +#include "string_util.h" +#include "strings.h" +#include "text.h" + +u8 sub_80BB8A8(void *); + +u8 *sub_80BC190(u8 *dest, u8 arg1) { + u8 local1; + u8 *str; + + local1 = sub_80BB8A8(gSaveBlock1.secretBases[arg1].sbr_field_2); + + str = StringCopyN(dest, gSaveBlock1.secretBases[arg1].sbr_field_2, local1); + str[0] = EOS; + + return StringAppend(dest, gOtherText_PlayersBase); +} -- cgit v1.2.3 From 53a02e080f973071a92c141c031eb912f6ad119d Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Tue, 9 May 2017 18:50:48 +0200 Subject: Decompile some slot_machine functions --- src/battle_anim.c | 1 - src/slot_machine.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 src/slot_machine.c (limited to 'src') diff --git a/src/battle_anim.c b/src/battle_anim.c index b9aa5b898..bdb34365f 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -65,7 +65,6 @@ extern u8 sub_8078874(u8); extern void sub_8078914(); extern u8 sub_80AEB1C(); extern void sub_80E4EF8(int, int, int, int, u16, u8, int); -extern void sub_800D238(); extern u8 sub_80789BC(); extern void sub_80AB2AC(void); extern void sub_800D7B8(void); diff --git a/src/slot_machine.c b/src/slot_machine.c new file mode 100644 index 000000000..c087bf6b4 --- /dev/null +++ b/src/slot_machine.c @@ -0,0 +1,154 @@ +#include "global.h" +#include "decompress.h" +#include "palette.h" +#include "task.h" + +struct UnkStruct2000000 { + /*0x00*/ u8 filler00[61]; + /*0x3D*/ u8 unk3D; +}; + +struct UnkStruct1 { + /*0x00*/ u8 unk00; + /*0x01*/ u8 unk01; + /*0x02*/ s16 unk02; +}; + +extern struct UnkStruct2000000 unk_2000000; + +extern struct UnkStruct1 *gUnknown_083ED048[]; +extern const u16 gPalette_83EDE24[]; + +extern const u8 gSlotMachine_Gfx[]; +#if ENGLISH +#define SLOTMACHINE_GFX_TILES 233 +#elif GERMAN +#define SLOTMACHINE_GFX_TILES 236 +#endif + +extern const u16 gUnknown_08E95A18[]; + +extern u16 gUnknown_08E95AB8[]; +extern u16 gUnknown_08E95FB8[]; + + +void sub_8104DA4(void); + +u8 sub_8105BB4(u8, u8, s16); + +static void LoadSlotMachineWheelOverlay(void); + +void sub_8104CAC(u8 arg0) { + u8 i; + struct Task *task; + + sub_8104DA4(); + + task = &gTasks[unk_2000000.unk3D]; + task->data[1] = arg0; + + i = 0; + while (gUnknown_083ED048[arg0][i].unk00 != 0xFF) + { + u8 spriteId; + spriteId = sub_8105BB4( + gUnknown_083ED048[arg0][i].unk00, + gUnknown_083ED048[arg0][i].unk01, + gUnknown_083ED048[arg0][i].unk02 + ); + task->data[4 + i] = spriteId; + +#ifdef GERMAN + if (arg0 == 5 && i <= 2) + { + gSprites[spriteId].invisible = TRUE; + } +#endif + + i += 1; + } +} + +asm(".section .text_b"); + +void sub_8106448(void) { + u32 offsetRead, offsetWrite; + u32 size; + + sub_800D238(gSlotMachine_Gfx, (void *) 0x02010000); + + offsetRead = 0x02010000; + offsetWrite = BG_VRAM; + size = SLOTMACHINE_GFX_TILES * 32; + while (TRUE) + { + DmaCopy16(3, offsetRead, (void *) (offsetWrite), 0x1000); + offsetRead += 0x1000; + offsetWrite += 0x1000; + size -= 0x1000; + if (size <= 0x1000) + { + DmaCopy16(3, offsetRead, (void *) (offsetWrite), size); + break; + } + } + + LoadPalette(gUnknown_08E95A18, 0, 160); + LoadPalette(gPalette_83EDE24, 208, 32); +} + +void sub_81064B8(void) { + CpuCopy16(gUnknown_08E95AB8, (void *) BG_SCREEN_ADDR(29), 20 * 32 * 2); + LoadSlotMachineWheelOverlay(); +} + +static void LoadSlotMachineWheelOverlay(void) { + s16 x, y, dx; + u16 *screen; + + screen = (u16 *) BG_SCREEN_ADDR(30); + + for (x = 4; x < 18; x += 5) + { + for (dx = 0; dx < 4; dx++) + { + screen[5 * 32 + dx + x] = 0x2051; + screen[13 * 32 + dx + x] = 0x2851; + screen[6 * 32 + dx + x] = 0x2061; + screen[12 * 32 + dx + x] = 0x2861; + } + + screen[6 * 32 + x] = 0x20BE; + screen[12 * 32 + x] = 0x28BE; + + for (y = 7; y <= 11; y++) + { + screen[y * 32 + x] = 0x20BF; + } + } +} + +void sub_81065A8(s16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4) { + u16 *vram = (u16 *) BG_SCREEN_ADDR(29); + + vram[15 * 32 + arg0] = arg1; + vram[15 * 32 + 1 + arg0] = arg2; + vram[16 * 32 + arg0] = arg3; + vram[16 * 32 + 1 + arg0] = arg4; +} + +void sub_81065DC(void) { + s16 y, x; + u16 *screen; + + CpuCopy16(gUnknown_08E95FB8, (void *) BG_SCREEN_ADDR(29), 20 * 32 * 2); + + screen = (u16 *) BG_SCREEN_ADDR(30); + for (y = 0; y < 20; y++) + { + for (x = 0; x < 30; x++) + { + screen[x + y * 32] = 0; + } + } +} -- cgit v1.2.3 From fbebe08ae94b8e165ba120d71959554765307ce3 Mon Sep 17 00:00:00 2001 From: Cameron Hall Date: Tue, 9 May 2017 12:52:39 -0500 Subject: use macros to set DISPCNT and BG*CNT registers (#286) * use macros to set DISPCNT and BG*CNT registers * add a few more --- src/berry_tag_screen.c | 6 +++--- src/clear_save_data_menu.c | 6 +++--- src/contest_painting.c | 6 +++--- src/credits.c | 8 ++++---- src/diploma.c | 2 +- src/field_region_map.c | 4 ++-- src/link.c | 8 ++++---- src/mail.c | 8 ++++---- src/main_menu.c | 9 +++++---- src/matsuda_debug_menu.c | 4 ++-- src/mystery_event_menu.c | 2 +- src/naming_screen.c | 8 ++++---- src/pokedex.c | 30 +++++++++++++++--------------- src/save_failed_screen.c | 6 +++--- src/start_menu.c | 2 +- src/starter_choose.c | 6 +++--- src/wallclock.c | 4 ++-- 17 files changed, 60 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/berry_tag_screen.c b/src/berry_tag_screen.c index 103f0a85e..511b88c5a 100644 --- a/src/berry_tag_screen.c +++ b/src/berry_tag_screen.c @@ -178,9 +178,9 @@ void BerryTagScreen_814625C(u8 taskId) static void sub_8146288(void) { - REG_BG1CNT = 0x502; - REG_BG2CNT = 0x600; - REG_BG3CNT = 0x703; + REG_BG1CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(5) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG2CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(6) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; gUnknown_030041B4 = 0; } diff --git a/src/clear_save_data_menu.c b/src/clear_save_data_menu.c index 6b0cc821a..21cd643ef 100644 --- a/src/clear_save_data_menu.c +++ b/src/clear_save_data_menu.c @@ -41,7 +41,7 @@ static void Task_InitMenu(u8 taskId) { ResetSpriteData(); - REG_DISPCNT = DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; SetVBlankCallback(VBlankCB_ClearSaveDataScreen); MenuDrawTextWindow(2, 14, 27, 19); @@ -148,8 +148,8 @@ static u8 InitClearSaveDataScreen(void) SetVBlankCallback(VBlankCB_InitClearSaveDataScreen); - REG_BG3CNT = 0x0703; - REG_DISPCNT = 0x0900; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_BG0_ON | DISPCNT_BG3_ON; gMain.state = 1; return 0; case 1: diff --git a/src/contest_painting.c b/src/contest_painting.c index 08244597e..2ef50ee17 100644 --- a/src/contest_painting.c +++ b/src/contest_painting.c @@ -336,8 +336,8 @@ static void ContestPaintingInitBG(void) { REG_DISPCNT = 0; REG_IE |= INTR_FLAG_VBLANK; - REG_BG0CNT = 0x0C42; - REG_BG1CNT = 0x0A45; + REG_BG0CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(12) | BGCNT_MOSAIC | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(1) | BGCNT_SCREENBASE(10) | BGCNT_MOSAIC | BGCNT_16COLOR | BGCNT_TXT256x256; REG_BLDCNT = 0; REG_BLDALPHA = 0; REG_BLDY = 0; @@ -367,7 +367,7 @@ static void ContestPaintingMosaic(void) return; } - REG_BG1CNT = 0xA45; + REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(1) | BGCNT_SCREENBASE(10) | BGCNT_MOSAIC | BGCNT_16COLOR | BGCNT_TXT256x256; gUnknown_03000752 = gUnknown_03000754 / 2; REG_MOSAIC = (gUnknown_03000752 << 12) | (gUnknown_03000752 << 8) | (gUnknown_03000752 << 4) | (gUnknown_03000752 << 0); diff --git a/src/credits.c b/src/credits.c index 17d3507aa..01af78bce 100644 --- a/src/credits.c +++ b/src/credits.c @@ -474,8 +474,8 @@ void task_a_8143D04(u8 taskIdA) BeginNormalPaletteFade(-1, 0, 16, 0, 0); REG_BG3HOFS = 0; REG_BG3VOFS = 32; - REG_BG3CNT = 0x703; - REG_DISPCNT = 0x1940; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; gMain.state = 0; gUnknown_0203935C = 0; @@ -518,13 +518,13 @@ static void task_a_8143F3C(u8 taskIdA) FreeAllSpritePalettes(); BeginNormalPaletteFade(-1, 8, 16, 0, 0); - REG_BG0CNT = 0x700; + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; backup = REG_IME; REG_IME = 0; REG_IE |= INTR_FLAG_VBLANK; REG_IME = backup; REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; - REG_DISPCNT = 0x140; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON; gTasks[taskIdA].data[TDA_0] = 0x100; gTasks[taskIdA].func = task_a_8143FDC; diff --git a/src/diploma.c b/src/diploma.c index 112647956..c32b72a70 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -87,7 +87,7 @@ void sub_8145D88(void) REG_BLDCNT = 0; REG_BLDALPHA = 0; REG_BLDY = 0; - REG_BG3CNT = 0x4603; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(6) | BGCNT_16COLOR | BGCNT_TXT512x256; REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; CreateTask(Task_DiplomaFadeIn, 0); diff --git a/src/field_region_map.c b/src/field_region_map.c index db12eb6a5..ec630ad00 100644 --- a/src/field_region_map.c +++ b/src/field_region_map.c @@ -64,7 +64,7 @@ void CB2_FieldInitRegionMap(void) SetUpWindowConfig(&gWindowConfig_81E709C); InitMenuWindow(&gWindowConfig_81E709C); MenuZeroFillScreen(); - REG_BG0CNT = 7936; + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(31) | BGCNT_16COLOR | BGCNT_TXT256x256; MenuDrawTextWindow(21, 0, 29, 3); sub_8072BD8(gOtherText_Hoenn, 0x16, 1, 0x38); MenuDrawTextWindow(16, 16, 29, 19); @@ -94,7 +94,7 @@ void sub_813EFDC(void) switch (unk_2000000.unk888) { case 0: - REG_DISPCNT = 5441; + REG_DISPCNT = DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_ON; unk_2000000.unk888++; break; case 1: diff --git a/src/link.c b/src/link.c index 336616f1a..224c0ae1c 100644 --- a/src/link.c +++ b/src/link.c @@ -207,13 +207,13 @@ static void InitLinkTestBG(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 charB switch (bgNum) { case 1: - REG_BG1CNT = 1 | (screenBaseBlock << 8) | (charBaseBlock << 2); + REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_SCREENBASE(screenBaseBlock) | BGCNT_CHARBASE(charBaseBlock); break; case 2: - REG_BG2CNT = 1 | (screenBaseBlock << 8) | (charBaseBlock << 2); + REG_BG2CNT = BGCNT_PRIORITY(1) | BGCNT_SCREENBASE(screenBaseBlock) | BGCNT_CHARBASE(charBaseBlock); break; case 3: - REG_BG3CNT = 1 | (screenBaseBlock << 8) | (charBaseBlock << 2); + REG_BG3CNT = BGCNT_PRIORITY(1) | BGCNT_SCREENBASE(screenBaseBlock) | BGCNT_CHARBASE(charBaseBlock); break; } } @@ -255,7 +255,7 @@ void LinkTestScreen(void) } InitLinkTestBG(0, 2, 4, 0); - REG_DISPCNT = DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_1D_MAP; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_1D_MAP; CreateTask(Task_DestroySelf, 0); RunTasks(); AnimateSprites(); diff --git a/src/mail.c b/src/mail.c index 9964f2a79..807864332 100644 --- a/src/mail.c +++ b/src/mail.c @@ -273,11 +273,11 @@ static u8 sub_80F8A28(void) RETURN_SKIP_STATE; case 18: - REG_BG0CNT = 0x9F08; - REG_BG1CNT = 0x0801; - REG_BG2CNT = 0x0902; + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(31) | BGCNT_16COLOR | BGCNT_TXT256x512; + REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(8) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG2CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(9) | BGCNT_16COLOR | BGCNT_TXT256x256; REG_BLDCNT = 0; - REG_DISPCNT = DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_ON; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_ON; BeginNormalPaletteFade(-1, 0, 16, 0, 0); gPaletteFade.bufferTransferDisabled = 0; ewram0.varF0 = sub_80F8F58; diff --git a/src/main_menu.c b/src/main_menu.c index 294d33620..50fefc471 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -250,7 +250,8 @@ u32 InitMainMenu(u8 a1) SetVBlankCallback(VBlankCB_MainMenu); SetMainCallback2(CB2_MainMenu); - REG_DISPCNT = DISPCNT_OBJ_1D_MAP + REG_DISPCNT = DISPCNT_MODE_0 + | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON; @@ -747,8 +748,8 @@ static void Task_NewGameSpeech1(u8 taskId) FreeAllSpritePalettes(); AddBirchSpeechObjects(taskId); BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); - REG_BG1CNT = 0x00000703; - REG_DISPCNT = DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP; + REG_BG1CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP; gTasks[taskId].data[TD_BGHOFS] = 0; gTasks[taskId].func = Task_NewGameSpeech2; gTasks[taskId].data[TD_TRAINER_SPRITE_ID] = 0xFF; @@ -1391,7 +1392,7 @@ void CB_ContinueNewGameSpeechPart2() SetVBlankCallback(VBlankCB_MainMenu); SetMainCallback2(CB2_MainMenu); - REG_BG1CNT = 1795; + REG_BG1CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_ON; } diff --git a/src/matsuda_debug_menu.c b/src/matsuda_debug_menu.c index 39c338658..57769db23 100644 --- a/src/matsuda_debug_menu.c +++ b/src/matsuda_debug_menu.c @@ -290,7 +290,7 @@ static void sub_80A9F10(u8 taskId) static void sub_80A9F50(void) { - REG_DISPCNT = DISPCNT_OBJ_1D_MAP; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP; REG_DISPCNT |= DISPCNT_OBJ_ON | DISPCNT_BG0_ON; SetUpWindowConfig(&gWindowConfig_81E6C3C); InitWindowFromConfig(&gMenuWindow, &gWindowConfig_81E6C3C); @@ -1073,7 +1073,7 @@ void unref_sub_80AB084(u8 *text) REG_WIN0V = 0; REG_WIN1H = 0; REG_WIN1V = 0; - REG_DISPCNT = 0x1F40; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON; savedIme = REG_IME; REG_IME = 0; diff --git a/src/mystery_event_menu.c b/src/mystery_event_menu.c index 693b28948..97deb348c 100644 --- a/src/mystery_event_menu.c +++ b/src/mystery_event_menu.c @@ -54,7 +54,7 @@ void CB2_InitMysteryEventMenu(void) SetUpWindowConfig(&gWindowConfig_81E6CE4); InitMenuWindow(&gWindowConfig_81E6CE4); MenuZeroFillScreen(); - REG_DISPCNT = 320; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON; REG_BLDCNT = 0; CreateTask(Task_DestroySelf, 0); StopMapMusic(); diff --git a/src/naming_screen.c b/src/naming_screen.c index f00a9bd3e..b14c690e2 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -298,10 +298,10 @@ static void NamingScreen_SetUpVideoRegs(void) REG_BG2VOFS = 0; REG_BG3HOFS = 0; REG_BG3VOFS = 0; - REG_BG0CNT = 0x1F00; - REG_BG1CNT = 0x1C01; - REG_BG2CNT = 0x1D0A; - REG_BG3CNT = 0x1E03; + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(31) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(28) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG2CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(29) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(30) | BGCNT_16COLOR | BGCNT_TXT256x256; REG_BLDCNT = 0x640; REG_BLDALPHA = 0x80C; } diff --git a/src/pokedex.c b/src/pokedex.c index d31d649e0..5ea1f9938 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -789,10 +789,10 @@ bool8 sub_808D344(u8 a) REG_BLDCNT = 0; REG_BLDALPHA = 0; REG_BLDY = 0; - REG_BG3CNT = 0xF03; - REG_BG1CNT = 0xD01; - REG_BG0CNT = 0xC00; - REG_DISPCNT = 0x9F40; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(15) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(13) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(12) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON | DISPCNT_OBJWIN_ON; gMain.state++; break; case 6: @@ -2296,8 +2296,8 @@ void Task_InitPageScreenMultistep(u8 taskId) REG_BLDCNT = 0; REG_BLDALPHA = 0; REG_BLDY = 0; - REG_BG3CNT = 0xF03; - REG_BG1CNT = 0xD00; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(15) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG1CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(13) | BGCNT_16COLOR | BGCNT_TXT256x256; REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; gMain.state++; break; @@ -2422,7 +2422,7 @@ void Task_InitAreaScreenMultistep(u8 taskId) sub_8090540(0xD); sub_8090644(1, 0xD); sub_808D640(); - REG_BG1CNT = 0xD00; + REG_BG1CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(13) | BGCNT_16COLOR | BGCNT_TXT256x256; gMain.state++; break; case 2: @@ -2544,10 +2544,10 @@ void Task_InitCryScreenMultistep(u8 taskId) REG_BLDCNT = 0; REG_BLDALPHA = 0; REG_BLDY = 0; - REG_BG2CNT = 0xE02; - REG_BG0CNT = 0x1F07; - REG_BG1CNT = 0xD00; - REG_DISPCNT = 0x1F07 + 0x39; + REG_BG2CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(14) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG0CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(1) | BGCNT_SCREENBASE(31) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG1CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(13) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON; gMain.state++; break; case 10: @@ -2715,8 +2715,8 @@ void Task_InitSizeScreenMultistep(u8 taskId) REG_BLDCNT = 0; REG_BLDALPHA = 0; REG_BLDY = 0; - REG_BG2CNT = 0xE03; - REG_DISPCNT = 0x1E40; + REG_BG2CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(14) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; gMain.state++; break; case 9: @@ -3156,8 +3156,8 @@ void sub_8090750(u8 taskId) REG_BLDCNT = 0; REG_BLDALPHA = 0; REG_BLDY = 0; - REG_BG3CNT = 0xF07; - REG_DISPCNT = 0x1C40; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(1) | BGCNT_SCREENBASE(15) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG2_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; gTasks[taskId].data[0]++; break; case 6: diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index 102909779..d46abc74d 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -150,9 +150,9 @@ static void CB2_SaveFailedScreen(void) REG_IME = ime; REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; SetVBlankCallback(VBlankCB); - REG_BG3CNT = 0x703; - REG_BG2CNT = 0x602; - REG_BG0CNT = 0x1f08; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG2CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(6) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(31) | BGCNT_16COLOR | BGCNT_TXT256x256; REG_DISPCNT = DISPCNT_OBJ_ON | DISPCNT_BG3_ON | DISPCNT_BG2_ON | DISPCNT_BG0_ON | DISPCNT_OBJ_1D_MAP | DISPCNT_MODE_0; gMain.state++; break; diff --git a/src/start_menu.c b/src/start_menu.c index 4a3bcbbd3..37d361c0b 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -782,7 +782,7 @@ static bool32 sub_80719FC(u8 *step) case 2: SetUpWindowConfig(&gWindowConfig_81E6CE4); InitMenuWindow(&gWindowConfig_81E6CE4); - REG_DISPCNT = 0x100; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_BG0_ON; break; case 3: { diff --git a/src/starter_choose.c b/src/starter_choose.c index 63d153ebd..6ef410d21 100644 --- a/src/starter_choose.c +++ b/src/starter_choose.c @@ -325,9 +325,9 @@ void CB2_ChooseStarter(void) REG_BLDCNT = 0xFE; REG_BLDALPHA = 0; REG_BLDY = 0x7; - REG_BG3CNT = 0x703; - REG_BG2CNT = 0x602; - REG_BG0CNT = 0x1F08; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG2CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(6) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(31) | BGCNT_16COLOR | BGCNT_TXT256x256; REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG2_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON; taskId = CreateTask(Task_StarterChoose1, 0); diff --git a/src/wallclock.c b/src/wallclock.c index 2f4d694a6..0f3665c65 100644 --- a/src/wallclock.c +++ b/src/wallclock.c @@ -256,8 +256,8 @@ static void WallClockInit(void) REG_BLDCNT = 0; REG_BLDALPHA = 0; REG_BLDY = 0; - REG_BG3CNT = 0x701; - REG_BG0CNT = 0x1F08; + REG_BG3CNT = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(31) | BGCNT_16COLOR | BGCNT_TXT256x256; REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; } -- cgit v1.2.3 From ec2abbf46a9037eac81a152bae408d026648561d Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Tue, 9 May 2017 20:10:33 +0200 Subject: Decompile sub_8098898 --- src/pokemon_storage_system.c | 93 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 src/pokemon_storage_system.c (limited to 'src') diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c new file mode 100644 index 000000000..679ec0bc4 --- /dev/null +++ b/src/pokemon_storage_system.c @@ -0,0 +1,93 @@ +#include "global.h" +#include "menu.h" +#include "string_util.h" + +struct StorageAction { + u8 *text; + u8 format; +}; + +extern const struct StorageAction gUnknown_083B6DF4[]; + +extern const u8 unk_2000000[]; + +#define gUnk2002694 (u8 *)(&unk_2000000[0x2694]) +#define gUnk20026A6 (u8 *)(&unk_2000000[0x26a6]) +#define gUnk20011fa (u8 *)(&unk_2000000[0x11fa]) +#define gUnk20026e4 (u8 *)(&unk_2000000[0x26e4]) + +void sub_8098898(u8 index) { + u8 *ptr; + + MenuDrawTextWindow(10, 16, 29, 19); + + switch (gUnknown_083B6DF4[index].format) + { + + case 2: + ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text); + ptr = StringCopy(ptr, gUnk20011fa); + break; + + case 5: + ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text); + ptr = StringCopy(ptr, gUnk20026e4); + break; + + case 1: + // {var} + " is selected." + ptr = StringCopy(gUnk2002694, gUnk20011fa); + ptr = StringCopy(ptr, gUnknown_083B6DF4[index].text); + break; + + case 4: + // TODO: fix for German + // {var} + " was released." + ptr = StringCopy(gUnk2002694, gUnk20026e4); + ptr = StringCopy(ptr, gUnknown_083B6DF4[index].text); + break; + + case 3: + { + u8 *stringLength; + u8 *text; + + text = gUnknown_083B6DF4[index].text; + stringLength = &text[StringLength(text)] + 1; + + ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text); + ptr = StringCopy(ptr, gUnk20011fa); + ptr = StringCopy(ptr, stringLength); + } + break; + + case 6: + // "Bye-bye, ".substr(0, -1) + {var} + "Bye-bye, !".substr(-1, 1) + { + u8 *stringLength; + u8 *text; + + text = gUnknown_083B6DF4[index].text; + stringLength = &text[StringLength(text)] - 1; + + ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text); + ptr = StringCopy(ptr - 1, gUnk20026e4); + ptr = StringCopy(ptr, stringLength); + } + break; + + case 0: + default: + ptr = StringCopy(gUnk2002694, gUnknown_083B6DF4[index].text); + break; + } + + while (ptr < gUnk20026A6) + { + ptr[0] = CHAR_SPACE; + ptr++; + } + + ptr[0] = EOS; + MenuPrint(gUnk2002694, 11, 17); +} -- cgit v1.2.3 From c0c3d2c52ad839450041d1ca6a29691efc5c5d35 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 10 May 2017 00:13:21 +0200 Subject: Decompile some cable_club functions --- src/battle_811DA74.c | 1 - src/cable_club.c | 304 +++++++++++++++++++++++++++++++++++++++++++++++ src/matsuda_debug_menu.c | 1 - src/record_mixing.c | 2 - src/rom3.c | 1 - 5 files changed, 304 insertions(+), 5 deletions(-) create mode 100644 src/cable_club.c (limited to 'src') diff --git a/src/battle_811DA74.c b/src/battle_811DA74.c index 4d66910ba..328b45f49 100644 --- a/src/battle_811DA74.c +++ b/src/battle_811DA74.c @@ -69,7 +69,6 @@ extern void c3_0802FDF4(u8); extern void sub_8031F88(); extern void sub_8141828(); extern void c2_8011A1C(void); -extern void sub_800832C(); extern void dp01_prepare_buffer_wireless_probably(); extern void dp01_build_cmdbuf_x1D_1D_numargs_varargs(int, u16, void *); diff --git a/src/cable_club.c b/src/cable_club.c new file mode 100644 index 000000000..45fb347f3 --- /dev/null +++ b/src/cable_club.c @@ -0,0 +1,304 @@ +#include "global.h" +#include "asm.h" +#include "field_message_box.h" +#include "link.h" +#include "main.h" +#include "script.h" +#include "songs.h" +#include "sound.h" +#include "string_util.h" +#include "task.h" +#include "text.h" +#include "trainer_card.h" + +extern u16 gScriptResult; +extern struct TrainerCard gTrainerCards[4]; + +extern u8 gUnknown_03004860; +extern u8 gFieldLinkPlayerCount; + +extern u8 gUnknown_081A4932[]; +extern const u8 gUnknown_081A4975[]; + +void sub_8082D4C(); +void sub_8082D60(u8, u8); +u16 sub_8082D9C(u8, u8); +u32 sub_8082DF4(u8); +u32 sub_8082E28(u8); +u32 sub_8082EB8(u8); +void sub_8082FEC(u8 taskId); +static void sub_80830E4(u8 taskId); +void sub_8083188(u8 taskId); +static void sub_8083288(u8 taskId); +static void sub_8083314(u8 taskId); +void sub_80833C4(u8 taskId); +void sub_8083418(u8 taskId); +u8 sub_8083444(u8 taskId); + +void sub_808303C(u8 taskId) { + s32 linkPlayerCount; + s16 *taskData; + + taskData = gTasks[taskId].data; + + linkPlayerCount = GetLinkPlayerCount_2(); + + if (sub_8082E28(taskId) == 1 || + sub_8082EB8(taskId) == 1 || + sub_8082DF4(taskId) == 1) + { + return; + } + + sub_8082D60(taskId, linkPlayerCount); + + if (!(gMain.newKeys & A_BUTTON)) + { + return; + } + + if (linkPlayerCount < taskData[1]) + { + return; + } + + sub_80081C8(linkPlayerCount); + sub_8082D4C(); + ConvertIntToDecimalStringN(gStringVar1, linkPlayerCount, STR_CONV_MODE_LEFT_ALIGN, 1); // r5 + ShowFieldAutoScrollMessage((u8 *) gUnknown_081A4975); + gTasks[taskId].func = sub_80830E4; +} + +#ifdef NONMATCHING +static void sub_80830E4(u8 taskId) { + if (sub_8082E28(taskId) == 1 || + sub_8082EB8(taskId) == 1 || + sub_8082DF4(taskId) == 1 || + GetFieldMessageBoxMode()) + { + return; + } + + if (sub_800820C() == GetLinkPlayerCount_2() && + !(gMain.heldKeys & B_BUTTON)) + { + ShowFieldAutoScrollMessage(gUnknown_081A4932); + gTasks[taskId].func = sub_8082FEC; + return; + } + + if (gMain.heldKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + sub_8007F4C(); + gTasks[(u32) taskId].func = sub_8083188; + } +} +#else +__attribute__((naked)) +static void sub_80830E4(u8 taskId) { + asm(".syntax unified\n\ + push {r4-r6,lr}\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + adds r6, r5, 0\n\ + adds r0, r5, 0\n\ + bl sub_8082E28\n\ + cmp r0, 0x1\n\ + beq _08083178\n\ + adds r0, r5, 0\n\ + bl sub_8082EB8\n\ + cmp r0, 0x1\n\ + beq _08083178\n\ + adds r0, r5, 0\n\ + bl sub_8082DF4\n\ + cmp r0, 0x1\n\ + beq _08083178\n\ + bl GetFieldMessageBoxMode\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _08083178\n\ + bl sub_800820C\n\ + adds r4, r0, 0\n\ + bl GetLinkPlayerCount_2\n\ + lsls r4, 24\n\ + lsls r0, 24\n\ + cmp r4, r0\n\ + bne _08083132\n\ + ldr r0, _08083148 @ =gMain\n\ + ldrh r1, [r0, 0x2C]\n\ + movs r0, 0x2\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08083158\n\ +_08083132:\n\ + ldr r0, _0808314C @ =gUnknown_081A4932\n\ + bl ShowFieldAutoScrollMessage\n\ + ldr r1, _08083150 @ =gTasks\n\ + lsls r0, r5, 2\n\ + adds r0, r5\n\ + lsls r0, 3\n\ + adds r0, r1\n\ + ldr r1, _08083154 @ =sub_8082FEC\n\ + str r1, [r0]\n\ + b _08083178\n\ + .align 2, 0\n\ +_08083148: .4byte gMain\n\ +_0808314C: .4byte gUnknown_081A4932\n\ +_08083150: .4byte gTasks\n\ +_08083154: .4byte sub_8082FEC\n\ +_08083158:\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08083178\n\ + movs r0, 0x5\n\ + bl PlaySE\n\ + bl sub_8007F4C\n\ + ldr r0, _08083180 @ =gTasks\n\ + lsls r1, r6, 2\n\ + adds r1, r6\n\ + lsls r1, 3\n\ + adds r1, r0\n\ + ldr r0, _08083184 @ =sub_8083188\n\ + str r0, [r1]\n\ +_08083178:\n\ + pop {r4-r6}\n\ + pop {r0}\n\ + bx r0\n\ + .align 2, 0\n\ +_08083180: .4byte gTasks\n\ +_08083184: .4byte sub_8083188\n\ + .syntax divided\n"); +} +#endif + +void sub_8083188(u8 taskId) { + u8 local1, local2; + u16 *result; + + local1 = gTasks[taskId].data[1]; + local2 = gTasks[taskId].data[2]; + + + if (sub_8082DF4(taskId) == 1 || + sub_8083444(taskId) == 1) + { + return; + } + + if (GetLinkPlayerCount_2() != sub_800820C()) + { + gTasks[taskId].func = sub_8083418; + return; + } + + result = &gScriptResult; + *result = sub_8082D9C(local1, local2); + if (*result) + { + gTasks[taskId].func = sub_8083288; + } +} + +void sub_80831F8(u8 taskId) { + u8 local1, local2; + u16 *result; + + local1 = gTasks[taskId].data[1]; + local2 = gTasks[taskId].data[2]; + + if (sub_8082E28(taskId) == 1 || + sub_8082DF4(taskId) == 1) + { + return; + } + + result = &gScriptResult; + *result = sub_8082D9C(local1, local2); + if (*result == 0) + { + return; + } + + + if (*result == 3) + { + sub_800832C(); + HideFieldMessageBox(); + gTasks[taskId].func = sub_80833C4; + } + else + { + gFieldLinkPlayerCount = GetLinkPlayerCount_2(); + gUnknown_03004860 = GetMultiplayerId(); + sub_80081C8(gFieldLinkPlayerCount); + sub_8093390((struct TrainerCard *) gBlockSendBuffer); + gTasks[taskId].func = sub_8083314; + } +} + +static void sub_8083288(u8 taskId) { + if (sub_8082DF4(taskId) == 1) + { + return; + } + + if (gScriptResult == 3) + { + sub_800832C(); + HideFieldMessageBox(); + gTasks[taskId].func = sub_80833C4; + } + else + { + gFieldLinkPlayerCount = GetLinkPlayerCount_2(); + gUnknown_03004860 = GetMultiplayerId(); + sub_80081C8(gFieldLinkPlayerCount); + sub_8093390((struct TrainerCard *) gBlockSendBuffer); + gTasks[taskId].func = sub_8083314; + sub_8007E9C(2); + } +} + +static void sub_8083314(u8 taskId) { + u8 index; + + struct TrainerCard *trainerCards; + + if (sub_8082DF4(taskId) == 1) + { + return; + } + + if (GetBlockReceivedStatus() != sub_8008198()) + { + return; + } + + index = 0; + trainerCards = gTrainerCards; + for (index = 0; index < GetLinkPlayerCount(); index++) + { + void *src; + src = gBlockRecvBuffer[index]; + memcpy(&trainerCards[index], src, sizeof(struct TrainerCard)); + } + + SetSuppressLinkErrorMessage(FALSE); + ResetBlockReceivedFlags(); + HideFieldMessageBox(); + + if (gScriptResult == 1) + { + u16 linkType; + linkType = gLinkType; + sub_8082D4C(0x00004411, linkType); + EnableBothScriptContexts(); + DestroyTask(taskId); + return; + } + + sub_800832C(); + gTasks[taskId].func = sub_80833C4; +} diff --git a/src/matsuda_debug_menu.c b/src/matsuda_debug_menu.c index 57769db23..d2ca754bb 100644 --- a/src/matsuda_debug_menu.c +++ b/src/matsuda_debug_menu.c @@ -64,7 +64,6 @@ extern u8* gMatsudaDebugMenuTextList3[]; extern u8 gMatsudaDebugMenuContestTopLeft[][2]; extern bool8 gReceivedRemoteLinkPlayers; -extern u16 gBlockRecvBuffer[MAX_LINK_PLAYERS][BLOCK_BUFFER_SIZE / 2]; extern struct MenuAction gMatsudaDebugMenuActions[]; diff --git a/src/record_mixing.c b/src/record_mixing.c index c08128637..76fe13059 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -31,8 +31,6 @@ extern u8 gUnknown_0300071C[]; extern u8 gOtherText_MixingComplete[]; extern u8 gOtherText_MixingRecordsWithFriend[]; extern bool8 gReceivedRemoteLinkPlayers; -extern u8 gBlockSendBuffer[BLOCK_BUFFER_SIZE]; -extern u16 gBlockRecvBuffer[MAX_LINK_PLAYERS][BLOCK_BUFFER_SIZE / 2]; #define BUFFER_CHUNK_SIZE 200 diff --git a/src/rom3.c b/src/rom3.c index b0ef7f088..126248705 100644 --- a/src/rom3.c +++ b/src/rom3.c @@ -13,7 +13,6 @@ extern u8 unk_2000000[]; #define EWRAM_15000 ((u8 *)(unk_2000000 + 0x15000)) extern u16 gBattleTypeFlags; -extern u16 gBlockRecvBuffer[MAX_LINK_PLAYERS][BLOCK_BUFFER_SIZE / 2]; extern const u32 gBitTable[]; extern u16 gBattleWeather; extern const struct BattleMove gBattleMoves[]; -- cgit v1.2.3 From b7efd72ac411800d709082dab220470544541c90 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Tue, 9 May 2017 19:33:43 -0700 Subject: name daily event functions --- src/clock.c | 16 ++++++++-------- src/dewford_trend.c | 6 +++--- src/new_game.c | 2 +- src/rom_800D42C.c | 2 +- src/tv.c | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/clock.c b/src/clock.c index 4ec49807c..48f937989 100644 --- a/src/clock.c +++ b/src/clock.c @@ -8,13 +8,13 @@ #include "rtc.h" #include "wallclock.h" -extern void sub_80FA220(u16); -extern void sub_80BE8C4(u16); -extern void sub_8080834(u16); +extern void UpdateDewfordTrendPerDay(u16); +extern void UpdateTVShowsPerDay(u16); +extern void UpdateWeatherPerDay(u16); extern void UpdatePartyPokerusTime(u16); extern void UpdateMirageRnd(u16); extern void UpdateBirchState(u16); -extern void sub_810F618(u16); +extern void SetShoalItemFlag(u16); static void InitTimeBasedEvents(void); static void UpdatePerDay(struct Time *time); @@ -49,13 +49,13 @@ static void UpdatePerDay(struct Time *time) { newDays = time->days - days; ClearUpperFlags(); - sub_80FA220(newDays); - sub_80BE8C4(newDays); - sub_8080834(newDays); + UpdateDewfordTrendPerDay(newDays); + UpdateTVShowsPerDay(newDays); + UpdateWeatherPerDay(newDays); UpdatePartyPokerusTime(newDays); UpdateMirageRnd(newDays); UpdateBirchState(newDays); - sub_810F618(newDays); + SetShoalItemFlag(newDays); SetRandomLotteryNumber(newDays); *varPtr = time->days; } diff --git a/src/dewford_trend.c b/src/dewford_trend.c index fe9311655..d69baef7f 100644 --- a/src/dewford_trend.c +++ b/src/dewford_trend.c @@ -19,7 +19,7 @@ static bool8 SB1ContainsWords(u16 *a); static bool8 IsEasyChatPairEqual(u16 *words1, u16 *words2); static s16 sub_80FA828(struct EasyChatPair *a, u16 b); -void InitDewfordTrends(void) +void InitDewfordTrend(void) { u16 i; @@ -39,7 +39,7 @@ void InitDewfordTrends(void) } #ifdef NONMATCHING -void sub_80FA220(u16 a) +void UpdateDewfordTrendPerDay(u16 a) { u16 i; u32 sp0; @@ -103,7 +103,7 @@ void sub_80FA220(u16 a) #else __attribute__((naked)) -void sub_80FA220(u16 a) +void UpdateDewfordTrendPerDay(u16 a) { asm(".syntax unified\n\ push {r4-r7,lr}\n\ diff --git a/src/new_game.c b/src/new_game.c index 6d2722c44..12e04a4ef 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -145,7 +145,7 @@ void NewGameInitData(void) ClearDecorationInventories(); InitEasyChatPhrases(); SetMauvilleOldMan(); - InitDewfordTrends(); + InitDewfordTrend(); ResetFanClub(); ResetLotteryCorner(); WarpToTruck(); diff --git a/src/rom_800D42C.c b/src/rom_800D42C.c index 93fbce556..ac564eddd 100644 --- a/src/rom_800D42C.c +++ b/src/rom_800D42C.c @@ -34,7 +34,7 @@ extern u8 BattleText_Tie[]; #define PRINT_MESSAGE_LEFT(text, tileDataStartOffset) PRINT_MESSAGE(text, tileDataStartOffset, LEFT_MESSAGE_X) #define PRINT_MESSAGE_RIGHT(text, tileDataStartOffset) PRINT_MESSAGE(text, tileDataStartOffset, RIGHT_MESSAGE_X) -void sub_800DC24(void) +void PrintLinkBattleWinLossTie(void) { if (gUnknown_02024D26 == 3) diff --git a/src/tv.c b/src/tv.c index dd523594d..c0d4bde4d 100644 --- a/src/tv.c +++ b/src/tv.c @@ -256,7 +256,7 @@ void EndMassOutbreak(void) gSaveBlock1.outbreakUnk5 = 0; } -void sub_80BE8C4(u16 arg0) +void UpdateTVShowsPerDay(u16 arg0) { sub_80BE8EC(arg0); UpdateMassOutbreakTimeLeft(arg0); -- cgit v1.2.3 From 242af849cb56ce0c4469c4e2be82a3ad5dbd3434 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Tue, 9 May 2017 20:39:43 -0700 Subject: minutes, not seconds --- src/berry.c | 22 +++++++++++----------- src/clock.c | 16 ++++++++-------- 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/berry.c b/src/berry.c index 6c12af053..257248e5c 100644 --- a/src/berry.c +++ b/src/berry.c @@ -1130,7 +1130,7 @@ bool32 BerryTreeGrow(struct BerryTree *tree) return TRUE; } -void BerryTreeTimeUpdate(int time) +void BerryTreeTimeUpdate(s32 minutes) { int i; struct BerryTree *tree; @@ -1141,27 +1141,27 @@ void BerryTreeTimeUpdate(int time) if (tree->berry && tree->stage && !tree->growthSparkle) { - if (time >= GetStageDurationByBerryType(tree->berry) * 71) + if (minutes >= GetStageDurationByBerryType(tree->berry) * 71) { *tree = gBlankBerryTree; } else { - int time2 = time; + s32 time = minutes; - while (time2 != 0) + while (time != 0) { - if (tree->secondsUntilNextStage > time2) + if (tree->minutesUntilNextStage > time) { - tree->secondsUntilNextStage -= time2; + tree->minutesUntilNextStage -= time; break; } - time2 -= tree->secondsUntilNextStage; - tree->secondsUntilNextStage = GetStageDurationByBerryType(tree->berry); + time -= tree->minutesUntilNextStage; + tree->minutesUntilNextStage = GetStageDurationByBerryType(tree->berry); if (!BerryTreeGrow(tree)) break; if (tree->stage == 5) - tree->secondsUntilNextStage *= 4; + tree->minutesUntilNextStage *= 4; } } } @@ -1174,12 +1174,12 @@ void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 sparkle) *tree = gBlankBerryTree; tree->berry = berry; - tree->secondsUntilNextStage = GetStageDurationByBerryType(berry); + tree->minutesUntilNextStage = GetStageDurationByBerryType(berry); tree->stage = stage; if (stage == 5) { tree->berryYield = CalcBerryYield(tree); - tree->secondsUntilNextStage *= 4; + tree->minutesUntilNextStage *= 4; } if (!sparkle) { diff --git a/src/clock.c b/src/clock.c index 48f937989..b263e99ae 100644 --- a/src/clock.c +++ b/src/clock.c @@ -18,7 +18,7 @@ extern void SetShoalItemFlag(u16); static void InitTimeBasedEvents(void); static void UpdatePerDay(struct Time *time); -static void UpdatePerSecond(struct Time *time); +static void UpdatePerMinute(struct Time *time); static void ReturnFromStartWallClock(void); static void InitTimeBasedEvents(void) @@ -35,7 +35,7 @@ void DoTimeBasedEvents(void) { RtcCalcLocalTime(); UpdatePerDay(&gLocalTime); - UpdatePerSecond(&gLocalTime); + UpdatePerMinute(&gLocalTime); } } @@ -61,20 +61,20 @@ static void UpdatePerDay(struct Time *time) } } -static void UpdatePerSecond(struct Time *time) +static void UpdatePerMinute(struct Time *time) { struct Time newTime; - s32 totalSeconds; + s32 minutes; CalcTimeDifference(&newTime, &gSaveBlock2.lastBerryTreeUpdate, time); - totalSeconds = 1440 * newTime.days + 60 * newTime.hours + newTime.minutes; + minutes = 1440 * newTime.days + 60 * newTime.hours + newTime.minutes; // there's no way to get the correct assembly other than with this nested if check. so dumb. - if (totalSeconds != 0) + if (minutes != 0) { - if (totalSeconds >= 0) + if (minutes >= 0) { - BerryTreeTimeUpdate(totalSeconds); + BerryTreeTimeUpdate(minutes); gSaveBlock2.lastBerryTreeUpdate = *time; } } -- cgit v1.2.3