From 6d73bb4b57efb3ff81dcc2aa0d00d5de380add9e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Dec 2017 10:23:05 -0500 Subject: [PATCH] Import function labels from Ruby --- asm/dewford_trend.s | 6 +- asm/easy_chat.s | 8 +- asm/field_screen.s | 6 +- asm/learn_move.s | 8 +- asm/link.s | 8 +- asm/main_menu.s | 2 +- asm/menu.s | 6 +- asm/menu_helpers.s | 2 +- asm/party_menu.s | 22 +- asm/player_pc.s | 2 +- asm/pokemon_storage_system.s | 8 +- asm/rom6.s | 34 ++- asm/script_menu.s | 2 +- asm/slot_machine.s | 2 +- asm/start_menu.s | 6 +- asm/trade.s | 4 +- asm/use_pokeblock.s | 2 +- data/scripts/maps/BattleFrontier_Lounge2.inc | 24 +- data/scripts/maps/BattleFrontier_Lounge3.inc | 20 +- data/scripts/players_house.inc | 2 +- data/specials.inc | 2 +- include/constants/vars.h | 13 +- include/dewford_trend.h | 2 +- include/field_screen.h | 2 +- include/menu.h | 2 +- include/rom6.h | 10 +- include/tv.h | 2 +- src/berry_blender.c | 2 +- src/clear_save_data_screen.c | 2 +- src/clock.c | 53 ++-- src/egg_hatch.c | 4 +- src/evolution_scene.c | 2 +- src/starter_choose.c | 2 +- src/tv.c | 2 +- src/wallclock.c | 279 ++++++++++--------- 35 files changed, 287 insertions(+), 266 deletions(-) diff --git a/asm/dewford_trend.s b/asm/dewford_trend.s index 89f89c4e0..7d9d67902 100644 --- a/asm/dewford_trend.s +++ b/asm/dewford_trend.s @@ -79,8 +79,8 @@ _08122522: .pool thumb_func_end InitDewfordTrend - thumb_func_start sub_8122580 -sub_8122580: @ 8122580 + thumb_func_start UpdateDewfordTrendPerDay +UpdateDewfordTrendPerDay: @ 8122580 push {r4-r7,lr} mov r7, r10 mov r6, r9 @@ -253,7 +253,7 @@ _081226BE: pop {r0} bx r0 .pool - thumb_func_end sub_8122580 + thumb_func_end UpdateDewfordTrendPerDay thumb_func_start sub_81226D8 sub_81226D8: @ 81226D8 diff --git a/asm/easy_chat.s b/asm/easy_chat.s index 602e7b3e7..3a359c9fa 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -1635,7 +1635,7 @@ _0811AF86: thumb_func_start sub_811AF8C sub_811AF8C: @ 811AF8C push {lr} - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -1684,7 +1684,7 @@ _0811AFE6: thumb_func_start sub_811AFEC sub_811AFEC: @ 811AFEC push {r4,lr} - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -1727,7 +1727,7 @@ _0811B03A: thumb_func_start sub_811B040 sub_811B040: @ 811B040 push {lr} - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -1832,7 +1832,7 @@ sub_811B0E8: @ 811B0E8 thumb_func_start sub_811B0F8 sub_811B0F8: @ 811B0F8 push {r4,lr} - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 diff --git a/asm/field_screen.s b/asm/field_screen.s index 497346f8a..a579efe73 100644 --- a/asm/field_screen.s +++ b/asm/field_screen.s @@ -7777,8 +7777,8 @@ _080AEFB6: bx r1 thumb_func_end sub_80AEEE8 - thumb_func_start sub_80AEFBC -sub_80AEFBC: @ 80AEFBC + thumb_func_start UpdateWeatherPerDay +UpdateWeatherPerDay: @ 80AEFBC lsls r0, 16 ldr r1, =gSaveBlock1Ptr ldr r2, [r1] @@ -7794,7 +7794,7 @@ sub_80AEFBC: @ 80AEFBC strb r1, [r2] bx lr .pool - thumb_func_end sub_80AEFBC + thumb_func_end UpdateWeatherPerDay thumb_func_start sub_80AEFDC sub_80AEFDC: @ 80AEFDC diff --git a/asm/learn_move.s b/asm/learn_move.s index 159b16f7e..acd9f4f98 100755 --- a/asm/learn_move.s +++ b/asm/learn_move.s @@ -353,7 +353,7 @@ _08160994: b _08160E88 .pool _081609A8: - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -433,7 +433,7 @@ _08160A50: b _08160E88 .pool _08160A64: - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -493,7 +493,7 @@ _08160ADC: b _08160E88 .pool _08160AEC: - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -551,7 +551,7 @@ _08160B6C: b _08160E88 .pool _08160B80: - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 diff --git a/asm/link.s b/asm/link.s index 2e6f3f8d3..953e1ac25 100644 --- a/asm/link.s +++ b/asm/link.s @@ -26142,7 +26142,7 @@ _080170E0: negs r0, r0 b _08017110 _080170F2: - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 movs r2, 0x80 @@ -29500,7 +29500,7 @@ _08018BD6: b _08018C3E .pool _08018BE4: - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r6, r0, 24 movs r1, 0x80 @@ -52112,7 +52112,7 @@ _0802426A: bl sub_8197930 b _080242D0 _08024270: - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r4, r0, 24 movs r0, 0x2 @@ -71033,7 +71033,7 @@ _0802DA84: thumb_func_start sub_802DA8C sub_802DA8C: @ 802DA8C push {lr} - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r0, 24 pop {r1} diff --git a/asm/main_menu.s b/asm/main_menu.s index 7b7ce49f7..52afc783e 100644 --- a/asm/main_menu.s +++ b/asm/main_menu.s @@ -3025,7 +3025,7 @@ task_new_game_prof_birch_speech_part2_4: @ 8031188 push {r4,r5,lr} lsls r0, 24 lsrs r5, r0, 24 - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 diff --git a/asm/menu.s b/asm/menu.s index e1102893a..64644504e 100755 --- a/asm/menu.s +++ b/asm/menu.s @@ -2266,8 +2266,8 @@ sub_8198C34: @ 8198C34 bx r0 thumb_func_end sub_8198C34 - thumb_func_start sub_8198C58 -sub_8198C58: @ 8198C58 + thumb_func_start ProcessMenuInputNoWrap_ +ProcessMenuInputNoWrap_: @ 8198C58 push {r4,lr} bl ProcessMenuInputNoWrapAround lsls r0, 24 @@ -2282,7 +2282,7 @@ _08198C6E: pop {r4} pop {r1} bx r1 - thumb_func_end sub_8198C58 + thumb_func_end ProcessMenuInputNoWrap_ thumb_func_start sub_8198C78 sub_8198C78: @ 8198C78 diff --git a/asm/menu_helpers.s b/asm/menu_helpers.s index 423f653d9..444632dc5 100644 --- a/asm/menu_helpers.s +++ b/asm/menu_helpers.s @@ -277,7 +277,7 @@ Task_CallYesOrNoCallback: @ 8121FDC push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 diff --git a/asm/party_menu.s b/asm/party_menu.s index 4ae689d4d..27ff4721c 100755 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -2554,7 +2554,7 @@ sub_81B1708: @ 81B1708 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -4010,7 +4010,7 @@ sub_81B227C: @ 81B227C push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -7952,7 +7952,7 @@ sub_81B43DC: @ 81B43DC push {r4-r6,lr} lsls r0, 24 lsrs r4, r0, 24 - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -8485,7 +8485,7 @@ sub_81B48DC: @ 81B48DC muls r1, r0 ldr r0, =gPlayerParty adds r4, r1, r0 - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -8777,7 +8777,7 @@ sub_81B4BA0: @ 81B4BA0 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -8883,7 +8883,7 @@ sub_81B4C94: @ 81B4C94 push {r7} lsls r0, 24 lsrs r5, r0, 24 - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -9691,7 +9691,7 @@ sub_81B5430: @ 81B5430 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -9985,7 +9985,7 @@ sub_81B56D8: @ 81B56D8 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -12970,7 +12970,7 @@ sub_81B7028: @ 81B7028 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -13272,7 +13272,7 @@ sub_81B72C8: @ 81B72C8 muls r1, r0 ldr r0, =gPlayerParty adds r4, r1, r0 - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r5, r0, 24 cmp r5, 0 @@ -15054,7 +15054,7 @@ sub_81B82D4: @ 81B82D4 push {r4-r7,lr} lsls r0, 24 lsrs r5, r0, 24 - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 diff --git a/asm/player_pc.s b/asm/player_pc.s index 2287d4123..c1bb4f632 100644 --- a/asm/player_pc.s +++ b/asm/player_pc.s @@ -1378,7 +1378,7 @@ sub_816B9D8: @ 816B9D8 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r0, 24 movs r1, 0x1 diff --git a/asm/pokemon_storage_system.s b/asm/pokemon_storage_system.s index c30cd7c28..2deae56ab 100755 --- a/asm/pokemon_storage_system.s +++ b/asm/pokemon_storage_system.s @@ -3409,7 +3409,7 @@ _080C8F0C: adds r0, 0x1 strb r0, [r1] _080C8F22: - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -4133,7 +4133,7 @@ _080C9584: b _080C9664 .pool _080C95A4: - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -4927,7 +4927,7 @@ _080C9C78: b _080C9CAA .pool _080C9C8C: - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -5058,7 +5058,7 @@ _080C9DAC: b _080C9DE0 .pool _080C9DC0: - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 diff --git a/asm/rom6.s b/asm/rom6.s index 430ed7ee9..0c464c14f 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -4188,6 +4188,8 @@ sp0C8_whiteout_maybe: @ 813787C .pool thumb_func_end sp0C8_whiteout_maybe +@ time_events.o + thumb_func_start sub_8137890 sub_8137890: @ 8137890 push {r4,lr} @@ -4244,8 +4246,8 @@ sub_81378E4: @ 81378E4 bx r0 thumb_func_end sub_81378E4 - thumb_func_start sub_8137904 -sub_8137904: @ 8137904 + thumb_func_start UpdateMirageRnd +UpdateMirageRnd: @ 8137904 push {r4,lr} lsls r0, 16 lsrs r4, r0, 16 @@ -4271,7 +4273,7 @@ _08137928: pop {r0} bx r0 .pool - thumb_func_end sub_8137904 + thumb_func_end UpdateMirageRnd thumb_func_start sub_813793C sub_813793C: @ 813793C @@ -4385,8 +4387,8 @@ sub_8137A0C: @ 8137A0C .pool thumb_func_end sub_8137A0C - thumb_func_start sub_8137A20 -sub_8137A20: @ 8137A20 + thumb_func_start UpdateBirchState +UpdateBirchState: @ 8137A20 push {r4,r5,lr} adds r4, r0, 0 lsls r4, 16 @@ -4405,7 +4407,9 @@ sub_8137A20: @ 8137A20 pop {r0} bx r0 .pool - thumb_func_end sub_8137A20 + thumb_func_end UpdateBirchState + +@ birch_pc.o thumb_func_start sub_8137A4C sub_8137A4C: @ 8137A4C @@ -7605,15 +7609,15 @@ _08139456: bx r1 thumb_func_end sub_81393FC - thumb_func_start sub_813945C -sub_813945C: @ 813945C + thumb_func_start SetShoalItemFlag +SetShoalItemFlag: @ 813945C push {lr} ldr r0, =0x000008bf bl FlagSet pop {r0} bx r0 .pool - thumb_func_end sub_813945C + thumb_func_end SetShoalItemFlag thumb_func_start sub_813946C sub_813946C: @ 813946C @@ -8934,8 +8938,8 @@ _08139EEE: bx r1 thumb_func_end sub_8139ED0 - thumb_func_start sub_8139EF4 -sub_8139EF4: @ 8139EF4 + thumb_func_start UpdateFrontierManiac +UpdateFrontierManiac: @ 8139EF4 push {r4,r5,lr} adds r4, r0, 0 lsls r4, 16 @@ -8954,7 +8958,7 @@ sub_8139EF4: @ 8139EF4 pop {r0} bx r0 .pool - thumb_func_end sub_8139EF4 + thumb_func_end UpdateFrontierManiac thumb_func_start sub_8139F20 sub_8139F20: @ 8139F20 @@ -10002,8 +10006,8 @@ _0813A7C6: .pool thumb_func_end sub_813A7B8 - thumb_func_start sub_813A7F4 -sub_813A7F4: @ 813A7F4 + thumb_func_start UpdateFrontierGambler +UpdateFrontierGambler: @ 813A7F4 push {r4,r5,lr} adds r4, r0, 0 lsls r4, 16 @@ -10022,7 +10026,7 @@ sub_813A7F4: @ 813A7F4 pop {r0} bx r0 .pool - thumb_func_end sub_813A7F4 + thumb_func_end UpdateFrontierGambler thumb_func_start sub_813A820 sub_813A820: @ 813A820 diff --git a/asm/script_menu.s b/asm/script_menu.s index be7cbfbc7..233a5e14c 100644 --- a/asm/script_menu.s +++ b/asm/script_menu.s @@ -444,7 +444,7 @@ task_yes_no_maybe: @ 80E215C b _080E21C4 .pool _080E2180: - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 movs r0, 0x1 diff --git a/asm/slot_machine.s b/asm/slot_machine.s index 6390ae992..24e755648 100644 --- a/asm/slot_machine.s +++ b/asm/slot_machine.s @@ -1581,7 +1581,7 @@ sub_812B158: @ 812B158 thumb_func_start sub_812B1B0 sub_812B1B0: @ 812B1B0 push {lr} - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 diff --git a/asm/start_menu.s b/asm/start_menu.s index 634425f80..787c0de23 100644 --- a/asm/start_menu.s +++ b/asm/start_menu.s @@ -1121,7 +1121,7 @@ sub_80A00EC: @ 80A00EC thumb_func_start sub_80A0108 sub_80A0108: @ 80A0108 push {lr} - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -1226,7 +1226,7 @@ sub_80A01D0: @ 80A01D0 thumb_func_start sub_80A01EC sub_80A01EC: @ 80A01EC push {lr} - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -1441,7 +1441,7 @@ sub_80A0388: @ 80A0388 thumb_func_start sub_80A03A4 sub_80A03A4: @ 80A03A4 push {lr} - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 diff --git a/asm/trade.s b/asm/trade.s index d36ae3c67..9f10faee2 100644 --- a/asm/trade.s +++ b/asm/trade.s @@ -3696,7 +3696,7 @@ _0807920E: thumb_func_start sub_8079218 sub_8079218: @ 8079218 push {lr} - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 @@ -3798,7 +3798,7 @@ _080792D8: thumb_func_start sub_80792E4 sub_80792E4: @ 80792E4 push {lr} - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 asrs r1, r0, 24 cmp r1, 0 diff --git a/asm/use_pokeblock.s b/asm/use_pokeblock.s index 3c580654c..f22fd9061 100755 --- a/asm/use_pokeblock.s +++ b/asm/use_pokeblock.s @@ -1240,7 +1240,7 @@ sub_8166D44: @ 8166D44 thumb_func_start sub_8166DE4 sub_8166DE4: @ 8166DE4 push {r4,lr} - bl sub_8198C58 + bl ProcessMenuInputNoWrap_ lsls r0, 24 lsrs r4, r0, 24 asrs r1, r0, 24 diff --git a/data/scripts/maps/BattleFrontier_Lounge2.inc b/data/scripts/maps/BattleFrontier_Lounge2.inc index 6b43747cc..bd20f13ac 100644 --- a/data/scripts/maps/BattleFrontier_Lounge2.inc +++ b/data/scripts/maps/BattleFrontier_Lounge2.inc @@ -17,29 +17,29 @@ BattleFrontier_Lounge2_EventScript_26065F:: @ 826065F end BattleFrontier_Lounge2_EventScript_26066D:: @ 826066D - compare_var_to_value VAR_0x402F, 0 + compare_var_to_value VAR_FRONTIER_MANIAC_FACILITY, 0 call_if 1, BattleFrontier_Lounge2_EventScript_26070A - compare_var_to_value VAR_0x402F, 1 + compare_var_to_value VAR_FRONTIER_MANIAC_FACILITY, 1 call_if 1, BattleFrontier_Lounge2_EventScript_26070F - compare_var_to_value VAR_0x402F, 2 + compare_var_to_value VAR_FRONTIER_MANIAC_FACILITY, 2 call_if 1, BattleFrontier_Lounge2_EventScript_260714 - compare_var_to_value VAR_0x402F, 3 + compare_var_to_value VAR_FRONTIER_MANIAC_FACILITY, 3 call_if 1, BattleFrontier_Lounge2_EventScript_260719 - compare_var_to_value VAR_0x402F, 4 + compare_var_to_value VAR_FRONTIER_MANIAC_FACILITY, 4 call_if 1, BattleFrontier_Lounge2_EventScript_26071E - compare_var_to_value VAR_0x402F, 5 + compare_var_to_value VAR_FRONTIER_MANIAC_FACILITY, 5 call_if 1, BattleFrontier_Lounge2_EventScript_260723 - compare_var_to_value VAR_0x402F, 6 + compare_var_to_value VAR_FRONTIER_MANIAC_FACILITY, 6 call_if 1, BattleFrontier_Lounge2_EventScript_260728 - compare_var_to_value VAR_0x402F, 7 + compare_var_to_value VAR_FRONTIER_MANIAC_FACILITY, 7 call_if 1, BattleFrontier_Lounge2_EventScript_26072D - compare_var_to_value VAR_0x402F, 8 + compare_var_to_value VAR_FRONTIER_MANIAC_FACILITY, 8 call_if 1, BattleFrontier_Lounge2_EventScript_260732 - compare_var_to_value VAR_0x402F, 9 + compare_var_to_value VAR_FRONTIER_MANIAC_FACILITY, 9 call_if 1, BattleFrontier_Lounge2_EventScript_260737 - compare_var_to_value VAR_0x402F, 3 + compare_var_to_value VAR_FRONTIER_MANIAC_FACILITY, 3 call_if 3, BattleFrontier_Lounge2_EventScript_2606F8 - compare_var_to_value VAR_0x402F, 4 + compare_var_to_value VAR_FRONTIER_MANIAC_FACILITY, 4 call_if 4, BattleFrontier_Lounge2_EventScript_260701 special sub_8139F20 waitmessage diff --git a/data/scripts/maps/BattleFrontier_Lounge3.inc b/data/scripts/maps/BattleFrontier_Lounge3.inc index 0612ccb8e..5fb7a8367 100644 --- a/data/scripts/maps/BattleFrontier_Lounge3.inc +++ b/data/scripts/maps/BattleFrontier_Lounge3.inc @@ -32,7 +32,7 @@ BattleFrontier_Lounge3_EventScript_261DAF:: @ 8261DAF BattleFrontier_Lounge3_EventScript_261DE9:: @ 8261DE9 multichoice 20, 4, 87, 0 - copyvar VAR_0x4032, VAR_RESULT + copyvar VAR_FRONTIER_GAMBLER_AMOUNT_BET, VAR_RESULT switch VAR_RESULT case 0, BattleFrontier_Lounge3_EventScript_261E30 case 1, BattleFrontier_Lounge3_EventScript_261E3B @@ -69,7 +69,7 @@ BattleFrontier_Lounge3_EventScript_261E51:: @ 8261E51 BattleFrontier_Lounge3_EventScript_261E75:: @ 8261E75 copyvar VAR_0x8004, VAR_0x8008 special sub_813A9A4 - setvar VAR_0x4033, 1 + setvar VAR_FRONTIER_GAMBLER_PLACED_BET_F, 1 special sub_813A8FC playse SE_REGI msgbox BattleFrontier_Lounge3_Text_262BE0, 4 @@ -113,37 +113,37 @@ BattleFrontier_Lounge3_EventScript_261EEB:: @ 8261EEB BattleFrontier_Lounge3_EventScript_261EF9:: @ 8261EF9 msgbox BattleFrontier_Lounge3_Text_26346B, 4 - compare_var_to_value VAR_0x4033, 1 + compare_var_to_value VAR_FRONTIER_GAMBLER_PLACED_BET_F, 1 goto_if 4, BattleFrontier_Lounge3_EventScript_261F12 goto BattleFrontier_Lounge3_EventScript_261DAF end BattleFrontier_Lounge3_EventScript_261F12:: @ 8261F12 - compare_var_to_value VAR_0x4033, 1 + compare_var_to_value VAR_FRONTIER_GAMBLER_PLACED_BET_F, 1 goto_eq BattleFrontier_Lounge3_EventScript_261F9E - compare_var_to_value VAR_0x4033, 2 + compare_var_to_value VAR_FRONTIER_GAMBLER_PLACED_BET_F, 2 goto_eq BattleFrontier_Lounge3_EventScript_261F2E goto BattleFrontier_Lounge3_EventScript_261F71 end BattleFrontier_Lounge3_EventScript_261F2E:: @ 8261F2E msgbox BattleFrontier_Lounge3_Text_263334, 4 - compare_var_to_value VAR_0x4032, 0 + compare_var_to_value VAR_FRONTIER_GAMBLER_AMOUNT_BET, 0 call_if 1, BattleFrontier_Lounge3_EventScript_261F80 - compare_var_to_value VAR_0x4032, 1 + compare_var_to_value VAR_FRONTIER_GAMBLER_AMOUNT_BET, 1 call_if 1, BattleFrontier_Lounge3_EventScript_261F8A - compare_var_to_value VAR_0x4032, 2 + compare_var_to_value VAR_FRONTIER_GAMBLER_AMOUNT_BET, 2 call_if 1, BattleFrontier_Lounge3_EventScript_261F94 msgbox BattleFrontier_Lounge3_Text_2633D4, 9 special sub_813A9D0 msgbox BattleFrontier_Lounge3_Text_2633F2, 4 - setvar VAR_0x4033, 0 + setvar VAR_FRONTIER_GAMBLER_PLACED_BET_F, 0 release end BattleFrontier_Lounge3_EventScript_261F71:: @ 8261F71 msgbox BattleFrontier_Lounge3_Text_263298, 4 - setvar VAR_0x4033, 0 + setvar VAR_FRONTIER_GAMBLER_PLACED_BET_F, 0 release end diff --git a/data/scripts/players_house.inc b/data/scripts/players_house.inc index 85952d9f0..05d93c35d 100644 --- a/data/scripts/players_house.inc +++ b/data/scripts/players_house.inc @@ -114,7 +114,7 @@ LittlerootTown_BrendansHouse_2F_EventScript_29283F:: @ 829283F LittlerootTown_BrendansHouse_2F_EventScript_292849:: @ 8292849 fadescreen 1 - special Special_StartWallClock + special StartWallClock waitstate return diff --git a/data/specials.inc b/data/specials.inc index 19adbae4d..04b38ffc6 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -164,7 +164,7 @@ gSpecials:: @ 81DBA64 def_special sub_8138B8C def_special sub_814FC9C def_special sub_8085784 - def_special Special_StartWallClock + def_special StartWallClock def_special Special_ViewWallClock def_special sub_80B1138 def_special sub_80B086C diff --git a/include/constants/vars.h b/include/constants/vars.h index 6828614bf..6dc8d0ccd 100644 --- a/include/constants/vars.h +++ b/include/constants/vars.h @@ -50,11 +50,14 @@ #define VAR_RESET_RTC_ENABLE 0x402C #define VAR_0x402D 0x402D #define VAR_0x402E 0x402E -#define VAR_0x402F 0x402F -#define VAR_0x4030 0x4030 -#define VAR_0x4031 0x4031 -#define VAR_0x4032 0x4032 -#define VAR_0x4033 0x4033 + +#define VAR_FRONTIER_MANIAC_FACILITY 0x402F + +#define VAR_FRONTIER_GAMBLER_FACILITY 0x4030 +#define VAR_FRONTIER_GAMBLER_SET_FACILITY_F 0x4031 +#define VAR_FRONTIER_GAMBLER_AMOUNT_BET 0x4032 +#define VAR_FRONTIER_GAMBLER_PLACED_BET_F 0x4033 + #define VAR_0x4034 0x4034 #define VAR_0x4035 0x4035 #define VAR_STORAGE_UNKNOWN 0x4036 diff --git a/include/dewford_trend.h b/include/dewford_trend.h index 3972ad143..dac5ea6c9 100644 --- a/include/dewford_trend.h +++ b/include/dewford_trend.h @@ -3,6 +3,6 @@ void InitDewfordTrend(void); void UpdateDewfordTrendPerDay(u16); -void sub_8122580(u16 days); +void UpdateDewfordTrendPerDay(u16 days); #endif // GUARD_DEWFORDTREND_H diff --git a/include/field_screen.h b/include/field_screen.h index f01760fcb..cfc0d081f 100644 --- a/include/field_screen.h +++ b/include/field_screen.h @@ -9,6 +9,6 @@ void pal_fill_black(void); bool8 sub_80ABDFC(void); void sub_80AF168(void); -void sub_80AEFBC(u16 days); +void UpdateWeatherPerDay(u16 days); #endif //GUARD_FIELD_SCREEN_H diff --git a/include/menu.h b/include/menu.h index 2052a8dad..99ff35adb 100644 --- a/include/menu.h +++ b/include/menu.h @@ -29,7 +29,7 @@ int decompress_and_copy_tile_data_to_vram(u8 bg_id, const void *src, int size, u bool8 free_temp_tile_data_buffers_if_possible(void); u64 sub_8198A50(struct WindowTemplate*, u8, u8, u8, u8, u8, u8, u16); // returns something but it isn't used, fix when menu.s is decomp'd void CreateYesNoMenu(const struct WindowTemplate *windowTemplate, u16 borderFirstTileNum, u8 borderPalette, u8 initialCursorPos); -s8 sub_8198C58(void); +s8 ProcessMenuInputNoWrap_(void); void do_scheduled_bg_tilemap_copies_to_vram(void); void clear_scheduled_bg_copies_to_vram(void); void AddTextPrinterParametrized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor *color, s8 speed, const u8 *str); diff --git a/include/rom6.h b/include/rom6.h index 014422b3d..6d20752e2 100644 --- a/include/rom6.h +++ b/include/rom6.h @@ -6,10 +6,10 @@ u8 GetLeadMonIndex(void); u8 GetSSTidalLocation(u8 *grp, u8 *num, s16 *x, s16 *y); void sub_813BADC(bool8); bool8 sub_813B9C0(void); -void sub_8137904(u16 days); -void sub_8137A20(u16 days); -void sub_8139EF4(u16 days); -void sub_813A7F4(u16 days); -void sub_813945C(u16 days); +void UpdateMirageRnd(u16 days); +void UpdateBirchState(u16 days); +void UpdateFrontierManiac(u16 days); +void UpdateFrontierGambler(u16 days); +void SetShoalItemFlag(u16 days); #endif //GUARD_ROM6_H diff --git a/include/tv.h b/include/tv.h index afa0ae930..eca11385e 100644 --- a/include/tv.h +++ b/include/tv.h @@ -15,6 +15,6 @@ void sub_80F14F8(TVShow *shows); size_t sub_80EF370(int value); bool8 Put3CheersForPokeblocksOnTheAir(const u8 *partnersName, u8 flavor, u8 unused, u8 sheen, u8 language); void SetPokemonAnglerSpecies(u16 species); -void sub_80ED888(u16 days); +void UpdateTVShowsPerDay(u16 days); #endif //GUARD_TV_H diff --git a/src/berry_blender.c b/src/berry_blender.c index b1d36e2d9..b1e8712a6 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -2444,7 +2444,7 @@ static void CB2_HandleBlenderEndGame(void) sBerryBlenderData->gameEndState++; break; case 10: - switch (sub_8198C58()) + switch (ProcessMenuInputNoWrap_()) { case 1: case -1: diff --git a/src/clear_save_data_screen.c b/src/clear_save_data_screen.c index d00944ac1..6d6a1545b 100755 --- a/src/clear_save_data_screen.c +++ b/src/clear_save_data_screen.c @@ -88,7 +88,7 @@ static void Task_DoClearSaveDataScreenYesNo(u8 taskId) static void Task_ClearSaveDataScreenYesNoChoice(u8 taskId) { - switch(sub_8198C58()) + switch(ProcessMenuInputNoWrap_()) { case 0: FillWindowPixelBuffer(0, 17); diff --git a/src/clock.c b/src/clock.c index 2ba42f70d..7cea30166 100644 --- a/src/clock.c +++ b/src/clock.c @@ -15,14 +15,14 @@ // static declarations -static void sub_809E7E8(struct Time *localTime); -static void sub_809E858(struct Time *localTime); +static void UpdatePerDay(struct Time *localTime); +static void UpdatePerMinute(struct Time *localTime); // rodata // text -static void sub_809E778(void) +static void InitTimeBasedEvents(void) { FlagSet(FLAG_SYS_CLOCK_SET); RtcCalcLocalTime(); @@ -35,38 +35,35 @@ void DoTimeBasedEvents(void) if (FlagGet(FLAG_SYS_CLOCK_SET) && !sub_813B9C0()) { RtcCalcLocalTime(); - sub_809E7E8(&gLocalTime); - sub_809E858(&gLocalTime); + UpdatePerDay(&gLocalTime); + UpdatePerMinute(&gLocalTime); } } -static void sub_809E7E8(struct Time *localTime) +static void UpdatePerDay(struct Time *localTime) { u16 *days = GetVarPointer(VAR_DAYS); u16 daysSince; - if (*days != localTime->days) + if (*days != localTime->days && *days <= localTime->days) { - if (*days <= localTime->days) - { - daysSince = localTime->days - *days; - ClearUpperFlags(); - sub_8122580(daysSince); - sub_80ED888(daysSince); - sub_80AEFBC(daysSince); - UpdatePartyPokerusTime(daysSince); - sub_8137904(daysSince); - sub_8137A20(daysSince); - sub_8139EF4(daysSince); - sub_813A7F4(daysSince); - sub_813945C(daysSince); - SetRandomLotteryNumber(daysSince); - *days = localTime->days; - } + daysSince = localTime->days - *days; + ClearUpperFlags(); + UpdateDewfordTrendPerDay(daysSince); + UpdateTVShowsPerDay(daysSince); + UpdateWeatherPerDay(daysSince); + UpdatePartyPokerusTime(daysSince); + UpdateMirageRnd(daysSince); + UpdateBirchState(daysSince); + UpdateFrontierManiac(daysSince); + UpdateFrontierGambler(daysSince); + SetShoalItemFlag(daysSince); + SetRandomLotteryNumber(daysSince); + *days = localTime->days; } } -static void sub_809E858(struct Time *localTime) +static void UpdatePerMinute(struct Time *localTime) { struct Time difference; int minutes; @@ -83,14 +80,14 @@ static void sub_809E858(struct Time *localTime) } } -void sub_809E8B4(void) +static void ReturnFromStartWallClock(void) { - sub_809E778(); + InitTimeBasedEvents(); SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); } -void Special_StartWallClock(void) +void StartWallClock(void) { SetMainCallback2(Cb2_StartWallClock); - gMain.savedCallback = sub_809E8B4; + gMain.savedCallback = ReturnFromStartWallClock; } diff --git a/src/egg_hatch.c b/src/egg_hatch.c index 032607806..a31eb0520 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -58,7 +58,7 @@ extern const u8 gText_HatchedFromEgg[]; extern const u8 gText_NickHatchPrompt[]; extern u8 sav1_map_get_name(void); -extern s8 sub_8198C58(void); +extern s8 ProcessMenuInputNoWrap_(void); extern void TVShowConvertInternationalString(u8* str1, u8* str2, u8); extern void sub_806A068(u16, u8); extern void fade_screen(u8, u8); @@ -669,7 +669,7 @@ static void CB2_EggHatch_1(void) } break; case 10: - switch (sub_8198C58()) + switch (ProcessMenuInputNoWrap_()) { case 0: GetMonNick(&gPlayerParty[sEggHatchData->eggPartyID], gStringVar3); diff --git a/src/evolution_scene.c b/src/evolution_scene.c index c17921b74..2b88fec3a 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -1168,7 +1168,7 @@ static void Task_TradeEvolutionScene(u8 taskID) } break; case 4: - switch (sub_8198C58()) + switch (ProcessMenuInputNoWrap_()) { case 0: sEvoCursorPos = 0; diff --git a/src/starter_choose.c b/src/starter_choose.c index 82f8f75f6..2d78af8fb 100644 --- a/src/starter_choose.c +++ b/src/starter_choose.c @@ -265,7 +265,7 @@ static void Task_StarterChoose5(u8 taskId) { u8 spriteId; - switch (sub_8198C58()) + switch (ProcessMenuInputNoWrap_()) { case 0: // YES // Return the starter choice and exit. diff --git a/src/tv.c b/src/tv.c index 1605be29c..205adbf4d 100644 --- a/src/tv.c +++ b/src/tv.c @@ -1793,7 +1793,7 @@ void EndMassOutbreak(void) gSaveBlock1Ptr->outbreakDaysLeft = 0; } -void sub_80ED888(u16 days) +void UpdateTVShowsPerDay(u16 days) { sub_80ED8B4(days); diff --git a/src/wallclock.c b/src/wallclock.c index ccec36739..892ef3f05 100644 --- a/src/wallclock.c +++ b/src/wallclock.c @@ -22,38 +22,38 @@ // static types -#define WALL_CLOCK_TASK_MINUTE_HAND_ANGLE 0 -#define WALL_CLOCK_TASK_HOUR_HAND_ANGLE 1 -#define WALL_CLOCK_TASK_HOUR 2 -#define WALL_CLOCK_TASK_MINUTE 3 -#define WALL_CLOCK_TASK_SET_COMMAND 4 -#define WALL_CLOCK_TASK_12HRCLOCK_AM_PM 5 -#define WALL_CLOCK_TASK_SET_SPEED 6 +#define tMinuteHandAngle data[0] +#define tHourHandAngle data[1] +#define tHours data[2] +#define tMinutes data[3] +#define tMvmtDir data[4] +#define tPeriod data[5] +#define tMvmtSpeed data[6] #define TAG_GFX_WALL_CLOCK_HAND 0x1000 #define TAG_PAL_WALL_CLOCK_HAND 0x1000 // static declarations -static void sub_8134C9C(void); -static void sub_8134CB8(u8 taskId); -static void sub_8134CE8(u8 taskId); -static void sub_8134DC4(u8 taskId); -static void c3_80BF560(u8 taskId); -static void sub_8134EA4(u8 taskId); -static void c2_080111BC(u8 taskId); -static void sub_8134F10(u8 taskId); -static void sub_8134F40(u8 taskId); -static void sub_8134F78(u8 taskId); -static void sub_8134FB0(u8 taskId); -static u16 GetClockHandAngle(u16 a0, u8 command, u8 a2); -static bool32 MoveClockHand(u8 taskId, u8 command); -static void _12HourClockFixAMPM(u8 taskId, u8 command); -static void sub_8135130(u8 taskId); -static void sub_81351AC(struct Sprite *sprite); -static void sub_8135244(struct Sprite *sprite); -static void sub_81352DC(struct Sprite *sprite); -static void sub_8135380(struct Sprite *sprite); +static void WallClockMainCallback(void); +static void Task_SetClock1(u8 taskId); +static void Task_SetClock2(u8 taskId); +static void Task_SetClock3(u8 taskId); +static void Task_SetClock4(u8 taskId); +static void Task_SetClock5(u8 taskId); +static void Task_SetClock6(u8 taskId); +static void Task_ViewClock1(u8 taskId); +static void Task_ViewClock2(u8 taskId); +static void Task_ViewClock3(u8 taskId); +static void Task_ViewClock4(u8 taskId); +static u16 CalcNewMinHandAngle(u16 a0, u8 command, u8 a2); +static bool32 AdvanceClock(u8 taskId, u8 command); +static void UpdateClockPeriod(u8 taskId, u8 command); +static void InitClockWithRtc(u8 taskId); +static void SpriteCB_MinuteHand(struct Sprite *sprite); +static void SpriteCB_HourHand(struct Sprite *sprite); +static void SpriteCB_AMIndicator(struct Sprite *sprite); +static void SpriteCB_PMIndicator(struct Sprite *sprite); // rodata @@ -122,7 +122,7 @@ static const struct SpriteTemplate gUnknown_085B2250 = { gUnknown_085B2248, NULL, gDummySpriteAffineAnimTable, - sub_81351AC + SpriteCB_MinuteHand }; static const struct SpriteTemplate gUnknown_085B2268 = { TAG_GFX_WALL_CLOCK_HAND, @@ -131,7 +131,7 @@ static const struct SpriteTemplate gUnknown_085B2268 = { gUnknown_085B224C, NULL, gDummySpriteAffineAnimTable, - sub_8135244 + SpriteCB_HourHand }; static const struct OamData Unknown_085B2280 = { .y = 0xa0, @@ -159,7 +159,7 @@ static const struct SpriteTemplate gUnknown_085B22A0 = { gUnknown_085B2298, NULL, gDummySpriteAffineAnimTable, - sub_81352DC + SpriteCB_AMIndicator }; static const struct SpriteTemplate gUnknown_085B22B8 = { TAG_GFX_WALL_CLOCK_HAND, @@ -168,7 +168,7 @@ static const struct SpriteTemplate gUnknown_085B22B8 = { gUnknown_085B229C, NULL, gDummySpriteAffineAnimTable, - sub_8135380 + SpriteCB_PMIndicator }; static const s8 sClockHandCoords[][2] = { { 0x00, -0x18}, @@ -535,14 +535,14 @@ static const s8 sClockHandCoords[][2] = { // text -static void sub_81347B4(void) +static void WallClockVblankCallback(void) { LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); } -void LoadWallClockGraphics(void) +static void LoadWallClockGraphics(void) { SetVBlankCallback(NULL); SetGpuReg(REG_OFFSET_DISPCNT, 0x0000); @@ -587,12 +587,12 @@ void LoadWallClockGraphics(void) LoadSpritePalettes(gUnknown_085B2218); } -void sub_813498C(void) +static void WallClockInit(void) { BeginNormalPaletteFade(-1, 0, 16, 0, 0); EnableInterrupts(INTR_FLAG_VBLANK); - SetVBlankCallback(sub_81347B4); - SetMainCallback2(sub_8134C9C); + SetVBlankCallback(WallClockVblankCallback); + SetMainCallback2(WallClockMainCallback); SetGpuReg(REG_OFFSET_BLDCNT, 0x0000); SetGpuReg(REG_OFFSET_BLDALPHA, 0x0000); SetGpuReg(REG_OFFSET_BLDY, 0x0000); @@ -609,29 +609,36 @@ void Cb2_StartWallClock(void) LoadWallClockGraphics(); LZ77UnCompVram(gUnknown_08DCC648, (u16 *)BG_SCREEN_ADDR(7)); - taskId = CreateTask(sub_8134CB8, 0); - gTasks[taskId].data[WALL_CLOCK_TASK_HOUR] = 10; - gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE] = 0; - gTasks[taskId].data[WALL_CLOCK_TASK_SET_COMMAND] = 0; - gTasks[taskId].data[WALL_CLOCK_TASK_12HRCLOCK_AM_PM] = 0; - gTasks[taskId].data[WALL_CLOCK_TASK_SET_SPEED] = 0; - gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE_HAND_ANGLE] = 0; - gTasks[taskId].data[WALL_CLOCK_TASK_HOUR_HAND_ANGLE] = 0x12c; + + taskId = CreateTask(Task_SetClock1, 0); + gTasks[taskId].tHours = 10; + gTasks[taskId].tMinutes = 0; + gTasks[taskId].tMvmtDir = 0; + gTasks[taskId].tPeriod = 0; + gTasks[taskId].tMvmtSpeed = 0; + gTasks[taskId].tMinuteHandAngle = 0; + gTasks[taskId].tHourHandAngle = 300; + spriteId = CreateSprite(&gUnknown_085B2250, 0x78, 0x50, 1); gSprites[spriteId].data[0] = taskId; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.matrixNum = 0; + spriteId = CreateSprite(&gUnknown_085B2268, 0x78, 0x50, 0); gSprites[spriteId].data[0] = taskId; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.matrixNum = 1; + spriteId = CreateSprite(&gUnknown_085B22A0, 0x78, 0x50, 2); gSprites[spriteId].data[0] = taskId; gSprites[spriteId].data[1] = 45; + spriteId = CreateSprite(&gUnknown_085B22B8, 0x78, 0x50, 2); gSprites[spriteId].data[0] = taskId; gSprites[spriteId].data[1] = 90; - sub_813498C(); + + WallClockInit(); + PrintTextOnWindow(1, 1, gText_Confirm3, 0, 1, 0, NULL); PutWindowTilemap(1); schedule_bg_copy_tilemap_to_vram(2); @@ -641,44 +648,51 @@ void Cb2_ViewWallClock(void) { u8 taskId; u8 spriteId; - u8 r10; - u8 spc; + u8 angle1; + u8 angle2; LoadWallClockGraphics(); LZ77UnCompVram(gUnknown_08DCC908, (u16 *)BG_SCREEN_ADDR(7)); - taskId = CreateTask(sub_8134F10, 0); - sub_8135130(taskId); - if (gTasks[taskId].data[WALL_CLOCK_TASK_12HRCLOCK_AM_PM] == 0) + + taskId = CreateTask(Task_ViewClock1, 0); + InitClockWithRtc(taskId); + if (gTasks[taskId].tPeriod == 0) { - r10 = 45; - spc = 90; + angle1 = 45; + angle2 = 90; } else { - r10 = 90; - spc = 135; + angle1 = 90; + angle2 = 135; } + spriteId = CreateSprite(&gUnknown_085B2250, 0x78, 0x50, 1); gSprites[spriteId].data[0] = taskId; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.matrixNum = 0; + spriteId = CreateSprite(&gUnknown_085B2268, 0x78, 0x50, 0); gSprites[spriteId].data[0] = taskId; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.matrixNum = 1; + spriteId = CreateSprite(&gUnknown_085B22A0, 0x78, 0x50, 2); gSprites[spriteId].data[0] = taskId; - gSprites[spriteId].data[1] = r10; + gSprites[spriteId].data[1] = angle1; + spriteId = CreateSprite(&gUnknown_085B22B8, 0x78, 0x50, 2); gSprites[spriteId].data[0] = taskId; - gSprites[spriteId].data[1] = spc; - sub_813498C(); + gSprites[spriteId].data[1] = angle2; + + WallClockInit(); + PrintTextOnWindow(1, 1, gText_Cancel4, 0, 1, 0, NULL); PutWindowTilemap(1); schedule_bg_copy_tilemap_to_vram(2); } -static void sub_8134C9C(void) +static void WallClockMainCallback(void) { RunTasks(); AnimateSprites(); @@ -687,92 +701,92 @@ static void sub_8134C9C(void) UpdatePaletteFade(); } -static void sub_8134CB8(u8 taskId) +static void Task_SetClock1(u8 taskId) { if (!gPaletteFade.active) { - gTasks[taskId].func = sub_8134CE8; + gTasks[taskId].func = Task_SetClock2; } } -static void sub_8134CE8(u8 taskId) +static void Task_SetClock2(u8 taskId) { - if (gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE_HAND_ANGLE] % 6) + if (gTasks[taskId].tMinuteHandAngle % 6) { - gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE_HAND_ANGLE] = GetClockHandAngle(gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE_HAND_ANGLE], gTasks[taskId].data[WALL_CLOCK_TASK_SET_COMMAND], gTasks[taskId].data[WALL_CLOCK_TASK_SET_SPEED]); + gTasks[taskId].tMinuteHandAngle = CalcNewMinHandAngle(gTasks[taskId].tMinuteHandAngle, gTasks[taskId].tMvmtDir, gTasks[taskId].tMvmtSpeed); } else { - gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE_HAND_ANGLE] = gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE] * 6; - gTasks[taskId].data[WALL_CLOCK_TASK_HOUR_HAND_ANGLE] = (gTasks[taskId].data[WALL_CLOCK_TASK_HOUR] % 12) * 30 + (gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE] / 10) * 5; + gTasks[taskId].tMinuteHandAngle = gTasks[taskId].tMinutes * 6; + gTasks[taskId].tHourHandAngle = (gTasks[taskId].tHours % 12) * 30 + (gTasks[taskId].tMinutes / 10) * 5; if (gMain.newKeys & A_BUTTON) { - gTasks[taskId].func = sub_8134DC4; + gTasks[taskId].func = Task_SetClock3; } else { - gTasks[taskId].data[WALL_CLOCK_TASK_SET_COMMAND] = 0; + gTasks[taskId].tMvmtDir = 0; if (gMain.heldKeys & DPAD_LEFT) { - gTasks[taskId].data[WALL_CLOCK_TASK_SET_COMMAND] = 1; + gTasks[taskId].tMvmtDir = 1; } if (gMain.heldKeys & DPAD_RIGHT) { - gTasks[taskId].data[WALL_CLOCK_TASK_SET_COMMAND] = 2; + gTasks[taskId].tMvmtDir = 2; } - if (gTasks[taskId].data[WALL_CLOCK_TASK_SET_COMMAND] != 0) + if (gTasks[taskId].tMvmtDir != 0) { - if (gTasks[taskId].data[WALL_CLOCK_TASK_SET_SPEED] <= 0xFE) + if (gTasks[taskId].tMvmtSpeed < 0xFF) { - gTasks[taskId].data[WALL_CLOCK_TASK_SET_SPEED]++; + gTasks[taskId].tMvmtSpeed++; } - gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE_HAND_ANGLE] = GetClockHandAngle(gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE_HAND_ANGLE], gTasks[taskId].data[WALL_CLOCK_TASK_SET_COMMAND], gTasks[taskId].data[WALL_CLOCK_TASK_SET_SPEED]); - MoveClockHand(taskId, gTasks[taskId].data[WALL_CLOCK_TASK_SET_COMMAND]); + gTasks[taskId].tMinuteHandAngle = CalcNewMinHandAngle(gTasks[taskId].tMinuteHandAngle, gTasks[taskId].tMvmtDir, gTasks[taskId].tMvmtSpeed); + AdvanceClock(taskId, gTasks[taskId].tMvmtDir); } else { - gTasks[taskId].data[WALL_CLOCK_TASK_SET_SPEED] = 0; + gTasks[taskId].tMvmtSpeed = 0; } } } } -static void sub_8134DC4(u8 taskId) +static void Task_SetClock3(u8 taskId) { SetWindowBorderStyle(0, FALSE, 0x250, 0x0d); PrintTextOnWindow(0, 1, gText_IsThisTheCorrectTime, 0, 1, 0, NULL); PutWindowTilemap(0); schedule_bg_copy_tilemap_to_vram(0); CreateYesNoMenu(&gUnknown_085B21F4, 0x250, 0x0d, 1); - gTasks[taskId].func = c3_80BF560; + gTasks[taskId].func = Task_SetClock4; } -static void c3_80BF560(u8 taskId) +static void Task_SetClock4(u8 taskId) { - switch (sub_8198C58()) + switch (ProcessMenuInputNoWrap_()) { case 0: PlaySE(SE_SELECT); - gTasks[taskId].func = sub_8134EA4; + gTasks[taskId].func = Task_SetClock5; break; case 1: case -1: PlaySE(SE_SELECT); sub_8198070(0, FALSE); ClearWindowTilemap(0); - gTasks[taskId].func = sub_8134CE8; + gTasks[taskId].func = Task_SetClock2; break; } } -static void sub_8134EA4(u8 taskId) +static void Task_SetClock5(u8 taskId) { - RtcInitLocalTimeOffset(gTasks[taskId].data[WALL_CLOCK_TASK_HOUR], gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE]); + RtcInitLocalTimeOffset(gTasks[taskId].tHours, gTasks[taskId].tMinutes); BeginNormalPaletteFade(-1, 0, 0, 16, 0); - gTasks[taskId].func = c2_080111BC; + gTasks[taskId].func = Task_SetClock6; } -static void c2_080111BC(u8 taskId) +static void Task_SetClock6(u8 taskId) { if (!gPaletteFade.active) { @@ -781,30 +795,30 @@ static void c2_080111BC(u8 taskId) } } -static void sub_8134F10(u8 taskId) +static void Task_ViewClock1(u8 taskId) { if (!gPaletteFade.active) { - gTasks[taskId].func = sub_8134F40; + gTasks[taskId].func = Task_ViewClock2; } } -static void sub_8134F40(u8 taskId) +static void Task_ViewClock2(u8 taskId) { - sub_8135130(taskId); + InitClockWithRtc(taskId); if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { - gTasks[taskId].func = sub_8134F78; + gTasks[taskId].func = Task_ViewClock3; } } -static void sub_8134F78(u8 taskId) +static void Task_ViewClock3(u8 taskId) { BeginNormalPaletteFade(-1, 0, 0, 16, 0); - gTasks[taskId].func = sub_8134FB0; + gTasks[taskId].func = Task_ViewClock4; } -static void sub_8134FB0(u8 taskId) +static void Task_ViewClock4(u8 taskId) { if (!gPaletteFade.active) { @@ -812,7 +826,7 @@ static void sub_8134FB0(u8 taskId) } } -static u8 GetClockHandAngleChange(u16 a0) +static u8 CalcMinHandDelta(u16 a0) { if (a0 > 60) { @@ -829,9 +843,9 @@ static u8 GetClockHandAngleChange(u16 a0) return 1; } -static u16 GetClockHandAngle(u16 a0, u8 command, u8 a2) +static u16 CalcNewMinHandAngle(u16 a0, u8 command, u8 a2) { - u8 r1 = GetClockHandAngleChange(a2); + u8 r1 = CalcMinHandDelta(a2); switch (command) { case 1: @@ -846,65 +860,65 @@ static u16 GetClockHandAngle(u16 a0, u8 command, u8 a2) return a0; } -static bool32 MoveClockHand(u8 taskId, u8 command) +static bool32 AdvanceClock(u8 taskId, u8 command) { switch (command) { case 1: - if (gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE] > 0) + if (gTasks[taskId].tMinutes > 0) { - gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE]--; + gTasks[taskId].tMinutes--; } else { - gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE] = 59; - if (gTasks[taskId].data[WALL_CLOCK_TASK_HOUR] > 0) + gTasks[taskId].tMinutes = 59; + if (gTasks[taskId].tHours > 0) { - gTasks[taskId].data[WALL_CLOCK_TASK_HOUR]--; + gTasks[taskId].tHours--; } else { - gTasks[taskId].data[WALL_CLOCK_TASK_HOUR] = 23; + gTasks[taskId].tHours = 23; } - _12HourClockFixAMPM(taskId, command); + UpdateClockPeriod(taskId, command); } break; case 2: - if (gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE] < 59) + if (gTasks[taskId].tMinutes < 59) { - gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE]++; + gTasks[taskId].tMinutes++; } else { - gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE] = 0; - if (gTasks[taskId].data[WALL_CLOCK_TASK_HOUR] < 23) + gTasks[taskId].tMinutes = 0; + if (gTasks[taskId].tHours < 23) { - gTasks[taskId].data[WALL_CLOCK_TASK_HOUR]++; + gTasks[taskId].tHours++; } else { - gTasks[taskId].data[WALL_CLOCK_TASK_HOUR] = 0; + gTasks[taskId].tHours = 0; } - _12HourClockFixAMPM(taskId, command); + UpdateClockPeriod(taskId, command); } break; } return FALSE; } -static void _12HourClockFixAMPM(u8 taskId, u8 command) +static void UpdateClockPeriod(u8 taskId, u8 command) { - u8 hours = gTasks[taskId].data[WALL_CLOCK_TASK_HOUR]; + u8 hours = gTasks[taskId].tHours; switch (command) { case 1: switch (hours) { case 11: - gTasks[taskId].data[WALL_CLOCK_TASK_12HRCLOCK_AM_PM] = FALSE; + gTasks[taskId].tPeriod = FALSE; break; case 23: - gTasks[taskId].data[WALL_CLOCK_TASK_12HRCLOCK_AM_PM] = TRUE; + gTasks[taskId].tPeriod = TRUE; break; } break; @@ -912,43 +926,45 @@ static void _12HourClockFixAMPM(u8 taskId, u8 command) switch (hours) { case 0: - gTasks[taskId].data[WALL_CLOCK_TASK_12HRCLOCK_AM_PM] = FALSE; + gTasks[taskId].tPeriod = FALSE; break; case 12: - gTasks[taskId].data[WALL_CLOCK_TASK_12HRCLOCK_AM_PM] = TRUE; + gTasks[taskId].tPeriod = TRUE; break; } break; } } -static void sub_8135130(u8 taskId) +static void InitClockWithRtc(u8 taskId) { RtcCalcLocalTime(); - gTasks[taskId].data[WALL_CLOCK_TASK_HOUR] = gLocalTime.hours; - gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE] = gLocalTime.minutes; - gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE_HAND_ANGLE] = gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE] * 6; - gTasks[taskId].data[WALL_CLOCK_TASK_HOUR_HAND_ANGLE] = (gTasks[taskId].data[WALL_CLOCK_TASK_HOUR] % 12) * 30 + (gTasks[taskId].data[WALL_CLOCK_TASK_MINUTE] / 10) * 5; + gTasks[taskId].tHours = gLocalTime.hours; + gTasks[taskId].tMinutes = gLocalTime.minutes; + gTasks[taskId].tMinuteHandAngle = gTasks[taskId].tMinutes * 6; + gTasks[taskId].tHourHandAngle = (gTasks[taskId].tHours % 12) * 30 + (gTasks[taskId].tMinutes / 10) * 5; if (gLocalTime.hours < 12) { - gTasks[taskId].data[WALL_CLOCK_TASK_12HRCLOCK_AM_PM] = FALSE; + gTasks[taskId].tPeriod = FALSE; } else { - gTasks[taskId].data[WALL_CLOCK_TASK_12HRCLOCK_AM_PM] = TRUE; + gTasks[taskId].tPeriod = TRUE; } } -static void sub_81351AC(struct Sprite *sprite) +static void SpriteCB_MinuteHand(struct Sprite *sprite) { - u16 angle = gTasks[sprite->data[0]].data[WALL_CLOCK_TASK_MINUTE_HAND_ANGLE]; + u16 angle = gTasks[sprite->data[0]].tMinuteHandAngle; s16 sin = Sin2(angle) / 16; s16 cos = Cos2(angle) / 16; u16 xhat; u16 yhat; + SetOamMatrix(0, cos, sin, -sin, cos); xhat = sClockHandCoords[angle][0]; yhat = sClockHandCoords[angle][1]; + if (xhat > 0x80) { xhat |= 0xff00; @@ -961,13 +977,14 @@ static void sub_81351AC(struct Sprite *sprite) sprite->pos2.y = yhat; } -static void sub_8135244(struct Sprite *sprite) +static void SpriteCB_HourHand(struct Sprite *sprite) { - u16 angle = gTasks[sprite->data[0]].data[WALL_CLOCK_TASK_HOUR_HAND_ANGLE]; + u16 angle = gTasks[sprite->data[0]].tHourHandAngle; s16 sin = Sin2(angle) / 16; s16 cos = Cos2(angle) / 16; u16 xhat; u16 yhat; + SetOamMatrix(1, cos, sin, -sin, cos); xhat = sClockHandCoords[angle][0]; yhat = sClockHandCoords[angle][1]; @@ -983,9 +1000,9 @@ static void sub_8135244(struct Sprite *sprite) sprite->pos2.y = yhat; } -static void sub_81352DC(struct Sprite *sprite) +static void SpriteCB_AMIndicator(struct Sprite *sprite) { - if (gTasks[sprite->data[0]].data[WALL_CLOCK_TASK_12HRCLOCK_AM_PM]) + if (gTasks[sprite->data[0]].tPeriod) { if (sprite->data[1] >= 60 && sprite->data[1] < 90) { @@ -1011,9 +1028,9 @@ static void sub_81352DC(struct Sprite *sprite) sprite->pos2.y = Sin2(sprite->data[1]) * 30 / 0x1000; } -static void sub_8135380(struct Sprite *sprite) +static void SpriteCB_PMIndicator(struct Sprite *sprite) { - if (gTasks[sprite->data[0]].data[WALL_CLOCK_TASK_12HRCLOCK_AM_PM]) + if (gTasks[sprite->data[0]].tPeriod) { if (sprite->data[1] >= 105 && sprite->data[1] < 135) {