diff --git a/asm/berry_blender.s b/asm/berry_blender.s index 816ae2d82..cc859f052 100644 --- a/asm/berry_blender.s +++ b/asm/berry_blender.s @@ -7675,7 +7675,7 @@ sub_80838AC: @ 80838AC adds r6, r1, 0 movs r0, 0xFF strb r0, [r6] - ldr r1, =gUnknown_085B262C + ldr r1, =gPokeblockNames ldrb r0, [r5] lsls r0, 2 adds r0, r1 diff --git a/asm/field_control_avatar.s b/asm/field_control_avatar.s index 181715261..e0345e188 100644 --- a/asm/field_control_avatar.s +++ b/asm/field_control_avatar.s @@ -1461,7 +1461,7 @@ _0809CAE4: b _0809CB28 .pool _0809CAF8: - bl safari_step + bl SafariZoneTakeStep lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 diff --git a/asm/fldeff_80F9BCC.s b/asm/fldeff_80F9BCC.s index b8ef7a164..7f8fdab68 100644 --- a/asm/fldeff_80F9BCC.s +++ b/asm/fldeff_80F9BCC.s @@ -590,7 +590,7 @@ sub_80FA004: @ 80FA004 cmp r0, 0x1 bne _080FA070 bl sub_80F9F5C - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_launch_phase_2 str r0, [r1] ldr r1, =gUnknown_0203CEEC @@ -605,7 +605,7 @@ _080FA070: cmp r0, 0x1 bne _080FA0A0 bl sub_80F9F5C - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_launch_phase_2 str r0, [r1] ldr r1, =gUnknown_0203CEEC @@ -624,7 +624,7 @@ _080FA0AE: b _080FA0C4 _080FA0B2: bl sub_80F9F5C - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_launch_phase_2 str r0, [r1] ldr r1, =gUnknown_0203CEEC diff --git a/asm/fldeff_strength.s b/asm/fldeff_strength.s index 67e4126b9..412eaff5d 100644 --- a/asm/fldeff_strength.s +++ b/asm/fldeff_strength.s @@ -22,7 +22,7 @@ _08145DD8: lsls r0, 24 lsrs r0, 24 strh r0, [r4] - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_launch_phase_2 str r0, [r1] ldr r1, =gUnknown_0203CEEC diff --git a/asm/fldeff_sweetscent.s b/asm/fldeff_sweetscent.s index d4036acd2..a297dd41d 100644 --- a/asm/fldeff_sweetscent.s +++ b/asm/fldeff_sweetscent.s @@ -7,7 +7,7 @@ thumb_func_start SetUpFieldMove_SweetScent SetUpFieldMove_SweetScent: @ 8159EF0 - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_launch_phase_2 str r0, [r1] ldr r1, =gUnknown_0203CEEC diff --git a/asm/fldeff_teleport.s b/asm/fldeff_teleport.s index b723f1cad..f3dc3ec9b 100644 --- a/asm/fldeff_teleport.s +++ b/asm/fldeff_teleport.s @@ -19,7 +19,7 @@ SetUpFieldMove_Teleport: @ 817C8BC b _0817C8E6 .pool _0817C8D8: - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_launch_phase_2 str r0, [r1] ldr r1, =gUnknown_0203CEEC diff --git a/asm/rom4.s b/asm/rom4.s index ab98f4b2d..8fb7ca8ad 100644 --- a/asm/rom4.s +++ b/asm/rom4.s @@ -3122,7 +3122,7 @@ sub_8085E94: @ 8085E94 thumb_func_start map_post_load_hook_exec map_post_load_hook_exec: @ 8085EA0 push {r4,lr} - ldr r4, =gFieldCallback + ldr r4, =gUnknown_03005DB0 ldr r0, [r4] cmp r0, 0 beq _08085ECC @@ -3177,7 +3177,7 @@ CB2_NewGame: @ 8085EF8 ldr r1, =gUnknown_03005DAC ldr r0, =sub_80FB4E0 str r0, [r1] - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 movs r0, 0 str r0, [r1] ldr r0, =gUnknown_030026F8 @@ -3420,7 +3420,7 @@ _08086178: sub_8086194: @ 8086194 push {lr} bl sub_808631C - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =sub_80AF6A4 str r0, [r1] bl c2_exit_to_overworld_2_switch diff --git a/asm/rom6.s b/asm/rom6.s index 242e1589d..5f604448d 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -267,7 +267,7 @@ sub_8135654: @ 8135654 lsls r0, 24 lsrs r0, 24 strh r0, [r4] - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_launch_phase_2 str r0, [r1] ldr r1, =gUnknown_0203CEEC @@ -284,7 +284,7 @@ _0813568C: movs r0, 0 b _081356AC _0813569E: - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_launch_phase_2 str r0, [r1] ldr r1, =gUnknown_0203CEEC @@ -360,7 +360,7 @@ sub_813572C: @ 813572C movs r0, 0 b _0813574C _0813573E: - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_launch_phase_2 str r0, [r1] ldr r1, =gUnknown_0203CEEC @@ -1205,7 +1205,7 @@ sub_8135F04: @ 8135F04 adds r1, r3 ldr r5, [r2] adds r5, r1 - ldr r2, =gUnknown_085B262C + ldr r2, =gPokeblockNames ldrb r1, [r5] lsls r1, 2 adds r1, r2 @@ -2583,7 +2583,7 @@ sub_8136AB4: @ 8136AB4 movs r1, 0 bl sub_8198070 ldr r0, =gStringVar1 - ldr r3, =gUnknown_085B262C + ldr r3, =gPokeblockNames ldr r1, =gSaveBlock1Ptr ldr r2, [r1] ldr r1, =gUnknown_0203CE7C @@ -2784,7 +2784,7 @@ sub_8136C8C: @ 8136C8C lsls r4, 16 lsrs r4, 16 ldr r0, =gBattleTextBuff1 - ldr r3, =gUnknown_085B262C + ldr r3, =gPokeblockNames ldr r2, [r5] ldrh r1, [r7] lsls r1, 3 @@ -2838,9 +2838,9 @@ sub_8136D2C: @ 8136D2C lsrs r4, 24 ldr r5, =gUnknown_0203CE7C ldrb r0, [r5] - bl sub_80FC3E8 + bl SafariZoneActivatePokeblockFeeder ldr r0, =gStringVar1 - ldr r3, =gUnknown_085B262C + ldr r3, =gPokeblockNames ldr r1, =gSaveBlock1Ptr ldr r2, [r1] ldrh r1, [r5] @@ -3236,7 +3236,7 @@ sub_8137044: @ 8137044 movs r1, 0 bl sub_8136F9C lsls r0, 24 - ldr r1, =gUnknown_085B262C + ldr r1, =gPokeblockNames lsrs r0, 22 adds r0, r1 ldr r1, [r0] @@ -3255,7 +3255,7 @@ sub_8137068: @ 8137068 lsls r0, 24 lsrs r5, r0, 24 movs r4, 0 - ldr r7, =gUnknown_085B262C + ldr r7, =gPokeblockNames _08137074: lsls r1, r4, 3 ldr r0, =gUnknown_085B2720 @@ -3338,7 +3338,7 @@ sub_81370FC: @ 81370FC lsls r0, 24 lsrs r0, 24 strh r0, [r4] - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_launch_phase_2 str r0, [r1] ldr r1, =gUnknown_0203CEEC @@ -3355,7 +3355,7 @@ _08137134: lsls r0, 24 cmp r0, 0 bne _08137170 - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_launch_phase_2 str r0, [r1] ldr r1, =gUnknown_0203CEEC diff --git a/asm/rom_80C6FA0.s b/asm/rom_80C6FA0.s index 163694549..c58388b92 100644 --- a/asm/rom_80C6FA0.s +++ b/asm/rom_80C6FA0.s @@ -24078,7 +24078,7 @@ sub_80D3718: @ 80D3718 lsrs r0, 24 cmp r0, 0x1 bne _080D3754 - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_launch_phase_2 str r0, [r1] ldr r1, =gUnknown_0203CEEC @@ -24380,7 +24380,7 @@ _080D395A: cmp r0, 0x1 bne _080D39F8 _080D39BC: - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_launch_phase_2 str r0, [r1] ldr r1, =gUnknown_0203CEEC @@ -24418,7 +24418,7 @@ _080D3A18: cmp r2, 0x1 bne _080D3A2A _080D3A1E: - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_launch_phase_2 str r0, [r1] ldr r1, =gUnknown_0203CEEC diff --git a/asm/rom_818E9AC.s b/asm/rom_818E9AC.s index e785eebde..89694f630 100644 --- a/asm/rom_818E9AC.s +++ b/asm/rom_818E9AC.s @@ -74275,7 +74275,7 @@ _081B5714: movs r0, 0x5 bl PlaySE _081B571A: - ldr r0, =gFieldCallback + ldr r0, =gUnknown_03005DB0 movs r1, 0 str r1, [r0] ldr r0, =gUnknown_0203CEEC @@ -74421,7 +74421,7 @@ sub_81B5820: @ 81B5820 lsrs r0, 24 cmp r0, 0x1 bne _081B585C - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_launch_phase_2 str r0, [r1] ldr r1, =gUnknown_0203CEEC @@ -74539,7 +74539,7 @@ hm_prepare_waterfall: @ 81B58F0 lsrs r0, 24 cmp r0, 0x1 bne _081B594C - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_launch_phase_2 str r0, [r1] ldr r1, =gUnknown_0203CEEC @@ -74586,7 +74586,7 @@ sub_81B5974: @ 81B5974 b _081B599E .pool _081B5990: - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_launch_phase_2 str r0, [r1] ldr r1, =gUnknown_0203CEEC @@ -81352,7 +81352,7 @@ sub_81B9354: @ 81B9354 sub sp, 0xC lsls r0, 24 lsrs r0, 24 - ldr r2, =gFieldCallback + ldr r2, =gUnknown_03005DB0 ldr r1, =hm_add_c3_without_phase_2 str r1, [r2] movs r1, 0 @@ -81384,7 +81384,7 @@ sub_81B9390: @ 81B9390 movs r0, 0xFF strh r0, [r4] _081B93A6: - ldr r0, =gFieldCallback + ldr r0, =gUnknown_03005DB0 ldr r1, =hm_add_c3_without_phase_2 str r1, [r0] ldr r0, =c2_exit_to_overworld_2_switch @@ -81493,7 +81493,7 @@ _081B9486: ldr r1, =gSpecialVar_0x8004 ldrb r0, [r2] strh r0, [r1] - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_without_phase_2 str r0, [r1] ldr r0, =c2_exit_to_overworld_2_switch @@ -81629,7 +81629,7 @@ _081B95A4: lsrs r0, 24 strh r0, [r4] _081B95BA: - ldr r0, =gFieldCallback + ldr r0, =gUnknown_03005DB0 ldr r1, =hm_add_c3_without_phase_2 str r1, [r0] ldr r0, =c2_exit_to_overworld_2_switch diff --git a/asm/rom_81BE66C.s b/asm/rom_81BE66C.s index bc723ee27..d7a5aac86 100644 --- a/asm/rom_81BE66C.s +++ b/asm/rom_81BE66C.s @@ -12059,7 +12059,7 @@ sub_81C4F44: @ 81C4F44 cmp r0, 0 bne _081C4F6E bl overworld_free_bg_tilemaps - ldr r0, =gFieldCallback + ldr r0, =gUnknown_03005DB0 ldr r1, =hm_add_c3_without_phase_2 str r1, [r0] ldr r1, =c2_exit_to_overworld_2_switch diff --git a/asm/safari_zone.s b/asm/safari_zone.s deleted file mode 100644 index 03c8e3613..000000000 --- a/asm/safari_zone.s +++ /dev/null @@ -1,524 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start GetSafariZoneFlag -GetSafariZoneFlag: @ 80FC0A0 - push {lr} - ldr r0, =0x0000088c - bl FlagGet - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - .pool - thumb_func_end GetSafariZoneFlag - - thumb_func_start SetSafariZoneFlag -SetSafariZoneFlag: @ 80FC0B4 - push {lr} - ldr r0, =0x0000088c - bl FlagSet - pop {r0} - bx r0 - .pool - thumb_func_end SetSafariZoneFlag - - thumb_func_start ResetSafariZoneFlag -ResetSafariZoneFlag: @ 80FC0C4 - push {lr} - ldr r0, =0x0000088c - bl FlagReset - pop {r0} - bx r0 - .pool - thumb_func_end ResetSafariZoneFlag - - thumb_func_start sub_80FC0D4 -sub_80FC0D4: @ 80FC0D4 - push {lr} - movs r0, 0x11 - bl IncrementGameStat - bl SetSafariZoneFlag - bl sub_80FC244 - ldr r1, =gNumSafariBalls - movs r0, 0x1E - strb r0, [r1] - ldr r1, =gUnknown_0203A04E - movs r2, 0xFA - lsls r2, 1 - adds r0, r2, 0 - strh r0, [r1] - ldr r0, =gUnknown_0203A050 - movs r1, 0 - strb r1, [r0] - ldr r0, =gUnknown_0203A051 - strb r1, [r0] - pop {r0} - bx r0 - .pool - thumb_func_end sub_80FC0D4 - - thumb_func_start sub_80FC114 -sub_80FC114: @ 80FC114 - push {lr} - ldr r0, =gUnknown_0203A050 - ldrb r0, [r0] - ldr r1, =gUnknown_0203A051 - ldrb r1, [r1] - bl sub_80EE44C - bl ResetSafariZoneFlag - bl sub_80FC244 - ldr r1, =gNumSafariBalls - movs r0, 0 - strb r0, [r1] - ldr r1, =gUnknown_0203A04E - movs r0, 0 - strh r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end sub_80FC114 - - thumb_func_start safari_step -safari_step: @ 80FC14C - push {lr} - bl GetSafariZoneFlag - cmp r0, 0 - beq _080FC168 - bl sub_80FC480 - ldr r1, =gUnknown_0203A04E - ldrh r0, [r1] - subs r0, 0x1 - strh r0, [r1] - lsls r0, 16 - cmp r0, 0 - beq _080FC170 -_080FC168: - movs r0, 0 - b _080FC178 - .pool -_080FC170: - ldr r0, =gUnknown_082A4B8A - bl ScriptContext1_SetupScript - movs r0, 0x1 -_080FC178: - pop {r1} - bx r1 - .pool - thumb_func_end safari_step - - thumb_func_start sub_80FC180 -sub_80FC180: @ 80FC180 - push {lr} - ldr r0, =gUnknown_082A4B6F - bl ScriptContext1_SetupScript - pop {r0} - bx r0 - .pool - thumb_func_end sub_80FC180 - - thumb_func_start sub_80FC190 -sub_80FC190: @ 80FC190 - push {lr} - ldr r1, =gUnknown_0203A051 - ldr r0, =gBattleResults - ldrb r0, [r0, 0x1F] - ldrb r2, [r1] - adds r0, r2 - strb r0, [r1] - ldr r2, =gBattleOutcome - ldrb r0, [r2] - cmp r0, 0x7 - bne _080FC1AE - ldr r1, =gUnknown_0203A050 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_080FC1AE: - ldr r0, =gNumSafariBalls - ldrb r0, [r0] - cmp r0, 0 - beq _080FC1D8 - ldr r0, =c2_exit_to_overworld_2_switch - bl SetMainCallback2 - b _080FC21C - .pool -_080FC1D8: - ldrb r0, [r2] - cmp r0, 0x8 - bne _080FC208 - ldr r0, =gUnknown_082A4B4C - bl ScriptContext2_RunNewScript - bl warp_in - ldr r1, =gUnknown_03005DAC - ldr r0, =sub_80AF6F0 - str r0, [r1] - ldr r0, =c2_load_new_map - bl SetMainCallback2 - b _080FC21C - .pool -_080FC208: - cmp r0, 0x7 - bne _080FC21C - ldr r0, =gUnknown_082A4B9B - bl ScriptContext1_SetupScript - bl script_env_2_set_ctx_paused - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music - bl SetMainCallback2 -_080FC21C: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80FC190 - - thumb_func_start sub_80FC228 -sub_80FC228: @ 80FC228 - push {lr} - lsls r0, 24 - lsrs r0, 20 - ldr r1, =gUnknown_0203A054 - adds r0, r1 - movs r1, 0 - movs r2, 0x10 - bl memset - pop {r0} - bx r0 - .pool - thumb_func_end sub_80FC228 - - thumb_func_start sub_80FC244 -sub_80FC244: @ 80FC244 - push {lr} - ldr r0, =gUnknown_0203A054 - movs r1, 0 - movs r2, 0xA0 - bl memset - pop {r0} - bx r0 - .pool - thumb_func_end sub_80FC244 - - thumb_func_start sub_80FC258 -sub_80FC258: @ 80FC258 - push {r4,r5,lr} - sub sp, 0x4 - mov r4, sp - adds r4, 0x2 - mov r0, sp - adds r1, r4, 0 - bl GetXYCoordsOneStepInFrontOfPlayer - movs r5, 0 -_080FC26A: - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - ldr r1, =gUnknown_0203A054 - lsls r0, r5, 4 - adds r3, r0, r1 - movs r1, 0x5 - ldrsb r1, [r2, r1] - movs r0, 0x4 - ldrsb r0, [r3, r0] - cmp r1, r0 - bne _080FC2C4 - mov r0, sp - movs r2, 0 - ldrsh r1, [r3, r2] - movs r2, 0 - ldrsh r0, [r0, r2] - cmp r1, r0 - bne _080FC2C4 - movs r0, 0x2 - ldrsh r1, [r3, r0] - movs r2, 0 - ldrsh r0, [r4, r2] - cmp r1, r0 - bne _080FC2C4 - ldr r0, =gScriptResult - strh r5, [r0] - ldr r1, =gUnknown_085B262C - ldrb r0, [r3, 0x8] - lsls r0, 2 - adds r0, r1 - ldr r1, [r0] - ldr r0, =gStringVar1 - bl StringCopy - b _080FC2D6 - .pool -_080FC2C4: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x9 - bls _080FC26A - ldr r1, =gScriptResult - ldr r2, =0x0000ffff - adds r0, r2, 0 - strh r0, [r1] -_080FC2D6: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80FC258 - - thumb_func_start sub_80FC2E8 -sub_80FC2E8: @ 80FC2E8 - push {r4-r7,lr} - sub sp, 0x4 - mov r4, sp - adds r4, 0x2 - mov r0, sp - adds r1, r4, 0 - bl PlayerGetDestCoords - movs r5, 0 - adds r6, r4, 0 - ldr r0, =gSaveBlock1Ptr - ldr r7, [r0] - mov r4, sp - ldr r0, =gUnknown_0203A054 - mov r12, r0 -_080FC306: - lsls r0, r5, 4 - mov r1, r12 - adds r3, r0, r1 - movs r1, 0x5 - ldrsb r1, [r7, r1] - movs r0, 0x4 - ldrsb r0, [r3, r0] - cmp r1, r0 - bne _080FC364 - ldrh r0, [r4] - ldrh r1, [r3] - subs r0, r1 - strh r0, [r4] - adds r2, r6, 0 - ldrh r0, [r2] - ldrh r1, [r3, 0x2] - subs r0, r1 - strh r0, [r2] - movs r1, 0 - ldrsh r0, [r4, r1] - cmp r0, 0 - bge _080FC336 - negs r0, r0 - strh r0, [r4] -_080FC336: - movs r1, 0 - ldrsh r0, [r2, r1] - cmp r0, 0 - bge _080FC342 - negs r0, r0 - strh r0, [r2] -_080FC342: - movs r2, 0 - ldrsh r0, [r4, r2] - movs r2, 0 - ldrsh r1, [r6, r2] - adds r0, r1 - cmp r0, 0x5 - bgt _080FC364 - ldr r0, =gScriptResult - strh r5, [r0] - b _080FC376 - .pool -_080FC364: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x9 - bls _080FC306 - ldr r1, =gScriptResult - ldr r2, =0x0000ffff - adds r0, r2, 0 - strh r0, [r1] -_080FC376: - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80FC2E8 - - thumb_func_start sub_80FC388 -sub_80FC388: @ 80FC388 - push {lr} - bl sub_80FC258 - ldr r2, =gScriptResult - ldrh r1, [r2] - ldr r0, =0x0000ffff - cmp r1, r0 - beq _080FC3B0 - adds r0, r1, 0 - lsls r0, 4 - ldr r1, =gUnknown_0203A05C - adds r0, r1 - b _080FC3B2 - .pool -_080FC3B0: - movs r0, 0 -_080FC3B2: - pop {r1} - bx r1 - thumb_func_end sub_80FC388 - - thumb_func_start sub_80FC3B8 -sub_80FC3B8: @ 80FC3B8 - push {lr} - bl sub_80FC2E8 - ldr r2, =gScriptResult - ldrh r1, [r2] - ldr r0, =0x0000ffff - cmp r1, r0 - beq _080FC3E0 - adds r0, r1, 0 - lsls r0, 4 - ldr r1, =gUnknown_0203A05C - adds r0, r1 - b _080FC3E2 - .pool -_080FC3E0: - movs r0, 0 -_080FC3E2: - pop {r1} - bx r1 - thumb_func_end sub_80FC3B8 - - thumb_func_start sub_80FC3E8 -sub_80FC3E8: @ 80FC3E8 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r1, 0 - ldr r2, =gUnknown_0203A054 - mov r6, sp - adds r6, 0x2 - movs r0, 0x8 - adds r0, r2 - mov r9, r0 - ldr r7, =gSaveBlock1Ptr -_080FC408: - lsls r5, r1, 4 - adds r4, r5, r2 - movs r0, 0x4 - ldrsb r0, [r4, r0] - cmp r0, 0 - bne _080FC468 - movs r3, 0 - ldrsh r0, [r4, r3] - cmp r0, 0 - bne _080FC468 - movs r3, 0x2 - ldrsh r0, [r4, r3] - cmp r0, 0 - bne _080FC468 - mov r0, sp - adds r1, r6, 0 - bl GetXYCoordsOneStepInFrontOfPlayer - ldr r0, [r7] - ldrb r0, [r0, 0x5] - strb r0, [r4, 0x4] - mov r0, r9 - adds r2, r5, r0 - ldr r0, [r7] - mov r3, r8 - lsls r1, r3, 3 - ldr r3, =0x00000848 - adds r0, r3 - adds r0, r1 - ldr r1, [r0, 0x4] - ldr r0, [r0] - str r0, [r2] - str r1, [r2, 0x4] - movs r0, 0x64 - strb r0, [r4, 0x5] - mov r0, sp - ldrh r0, [r0] - strh r0, [r4] - ldrh r0, [r6] - strh r0, [r4, 0x2] - b _080FC472 - .pool -_080FC468: - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x9 - bls _080FC408 -_080FC472: - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80FC3E8 - - thumb_func_start sub_80FC480 -sub_80FC480: @ 80FC480 - push {r4,r5,lr} - movs r4, 0 - ldr r5, =gUnknown_0203A054 -_080FC486: - lsls r0, r4, 4 - adds r1, r0, r5 - ldrb r0, [r1, 0x5] - cmp r0, 0 - beq _080FC4A0 - subs r0, 0x1 - strb r0, [r1, 0x5] - lsls r0, 24 - cmp r0, 0 - bne _080FC4A0 - adds r0, r4, 0 - bl sub_80FC228 -_080FC4A0: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x9 - bls _080FC486 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80FC480 - - thumb_func_start sub_80FC4B4 -sub_80FC4B4: @ 80FC4B4 - push {lr} - bl sub_80FC258 - ldr r3, =gScriptResult - ldrh r1, [r3] - ldr r0, =0x0000ffff - cmp r1, r0 - beq _080FC4EC - ldr r0, =gStringVar2 - ldr r2, =gUnknown_0203A054 - lsls r1, 4 - adds r1, r2 - ldrb r1, [r1, 0x5] - movs r2, 0x2 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - movs r0, 0x1 - b _080FC4EE - .pool -_080FC4EC: - movs r0, 0 -_080FC4EE: - pop {r1} - bx r1 - thumb_func_end sub_80FC4B4 - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/start_menu.s b/asm/start_menu.s index c96a471fa..44d477050 100644 --- a/asm/start_menu.s +++ b/asm/start_menu.s @@ -294,7 +294,7 @@ sub_809FA18: @ 809FA18 movs r0, 0 strb r0, [r1] strb r0, [r1, 0x1] - ldr r1, =gFieldCallback + ldr r1, =gUnknown_03005DB0 ldr r0, =sub_809FA00 str r0, [r1] bx lr @@ -680,7 +680,7 @@ StartMenu_SafariZoneRetire: @ 809FD74 push {lr} bl RemoveExtraStartMenuWindows bl sub_80A0934 - bl sub_80FC180 + bl SafariZoneRetirePrompt movs r0, 0x1 pop {r1} bx r1 diff --git a/asm/wild_encounter.s b/asm/wild_encounter.s index 3c7b7ba5a..2c628a5e4 100644 --- a/asm/wild_encounter.s +++ b/asm/wild_encounter.s @@ -670,7 +670,7 @@ sub_80B4D78: @ 80B4D78 lsrs r0, 16 cmp r0, 0x4F bhi _080B4E0E - bl sub_80FC3B8 + bl SafariZoneGetActivePokeblock adds r7, r0, 0 cmp r7, 0 beq _080B4E0E diff --git a/data/data4.s b/data/data4.s index 685badd5d..202b1ffe7 100644 --- a/data/data4.s +++ b/data/data4.s @@ -116,7 +116,7 @@ gPokeblockFlavorCompatibilityTable:: @ 85B25A0 gUnknown_085B2620:: @ 85B2620 .incbin "baserom.gba", 0x5b2620, 0xc -gUnknown_085B262C:: @ 85B262C +gPokeblockNames:: @ 85B262C .incbin "baserom.gba", 0x5b262c, 0x3c gUnknown_085B2668:: @ 85B2668 diff --git a/include/battle.h b/include/battle.h index 585f42b32..1db546de3 100644 --- a/include/battle.h +++ b/include/battle.h @@ -34,6 +34,15 @@ #define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000 | BATTLE_TYPE_PYRAMID) +#define BATTLE_WON 0x1 +#define BATTLE_LOST 0x2 +#define BATTLE_DREW 0x3 +#define BATTLE_RAN 0x4 +#define BATTLE_PLAYER_TELEPORTED 0x5 +#define BATTLE_POKE_FLED 0x6 +#define BATTLE_CAUGHT 0x7 +#define BATTLE_OPPONENT_TELEPORTED 0xA + #define STATUS_SLEEP 0x7 #define STATUS_POISON 0x8 #define STATUS_BURN 0x10 @@ -299,7 +308,8 @@ struct BattleResults u8 unk12; u8 battleTurnCounter; // 0x13 u8 pokeString2[10]; // 0x14 - u8 filler1E[2]; + u8 field_1E; // 0x1E + u8 field_1F; // 0x1F u16 lastOpponentSpecies; // 0x20 u16 lastUsedMove; // 0x22 u16 opponentMove; // 0x24 diff --git a/include/safari_zone.h b/include/safari_zone.h index 0649bab6a..9a81894b8 100644 --- a/include/safari_zone.h +++ b/include/safari_zone.h @@ -13,7 +13,6 @@ void ExitSafariMode(void); bool8 SafariZoneTakeStep(void); void SafariZoneRetirePrompt(void); -void SafariZoneGetPokeblockNameInFeeder(void); struct Pokeblock *SafariZoneGetActivePokeblock(void); void SafariZoneActivatePokeblockFeeder(u8 pokeblock_index); diff --git a/ld_script.txt b/ld_script.txt index eae182d93..d4af583ba 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -152,7 +152,7 @@ SECTIONS { asm/truck_scene.o(.text); asm/porthole.o(.text); asm/rotating_gate.o(.text); - asm/safari_zone.o(.text); + src/safari_zone.o(.text); asm/contest_link_80FC4F4.o(.text); asm/item_use.o(.text); asm/battle_anim_80FE840.o(.text); diff --git a/src/safari_zone.c b/src/safari_zone.c new file mode 100644 index 000000000..37ee664cd --- /dev/null +++ b/src/safari_zone.c @@ -0,0 +1,268 @@ +#include "global.h" +#include "safari_zone.h" +#include "event_data.h" +#include "game_stat.h" +#include "main.h" +#include "battle.h" +#include "string_util.h" + +struct PokeblockFeeder +{ + /*0x00*/ s16 x; + /*0x02*/ s16 y; + /*0x04*/ s8 mapNum; + /*0x05*/ u8 stepCounter; + /*0x08*/ struct Pokeblock pokeblock; +}; + +#define NUM_POKEBLOCK_FEEDERS 10 + +extern u8 gBattleOutcome; +extern void* gUnknown_03005DAC; + +extern u8 gUnknown_082A4B8A[]; +extern u8 gUnknown_082A4B6F[]; +extern u8 gUnknown_082A4B4C[]; +extern u8 gUnknown_082A4B9B[]; +extern const u8* const gPokeblockNames[]; + +extern void sub_80EE44C(u8, u8); +extern void IncrementGameStat(u8 index); +extern void ScriptContext1_SetupScript(u8*); +extern void ScriptContext2_RunNewScript(u8*); +extern void c2_exit_to_overworld_2_switch(void); +extern void c2_exit_to_overworld_1_continue_scripts_restart_music(void); +extern void c2_load_new_map(void); +extern void sub_80AF6F0(void); +extern void script_env_2_set_ctx_paused(void); +extern void warp_in(void); +extern void GetXYCoordsOneStepInFrontOfPlayer(s16* x, s16* y); +extern void PlayerGetDestCoords(s16* x, s16* y); + +EWRAM_DATA u8 gNumSafariBalls = 0; +EWRAM_DATA static u16 sSafariZoneStepCounter = 0; +EWRAM_DATA static u8 sSafariZoneCaughtMons = 0; +EWRAM_DATA static u8 sSafariZoneFleedMons = 0; +EWRAM_DATA static struct PokeblockFeeder sPokeblockFeeders[NUM_POKEBLOCK_FEEDERS] = {0}; + +static void ClearAllPokeblockFeeders(void); +static void DecrementFeederStepCounters(void); + +bool32 GetSafariZoneFlag(void) +{ + return FlagGet(SYS_SAFARI_MODE); +} + +void SetSafariZoneFlag(void) +{ + FlagSet(SYS_SAFARI_MODE); +} + +void ResetSafariZoneFlag(void) +{ + FlagReset(SYS_SAFARI_MODE); +} + +void EnterSafariMode(void) +{ + IncrementGameStat(GAME_STAT_ENTERED_SAFARI_ZONE); + SetSafariZoneFlag(); + ClearAllPokeblockFeeders(); + gNumSafariBalls = 30; + sSafariZoneStepCounter = 500; + sSafariZoneCaughtMons = 0; + sSafariZoneFleedMons = 0; +} + +void ExitSafariMode(void) +{ + sub_80EE44C(sSafariZoneCaughtMons, sSafariZoneFleedMons); + ResetSafariZoneFlag(); + ClearAllPokeblockFeeders(); + gNumSafariBalls = 0; + sSafariZoneStepCounter = 0; +} + +bool8 SafariZoneTakeStep(void) +{ + if (GetSafariZoneFlag() == FALSE) + { + return FALSE; + } + + DecrementFeederStepCounters(); + sSafariZoneStepCounter--; + if (sSafariZoneStepCounter == 0) + { + ScriptContext1_SetupScript(gUnknown_082A4B8A); + return TRUE; + } + return FALSE; +} + +void SafariZoneRetirePrompt(void) +{ + ScriptContext1_SetupScript(gUnknown_082A4B6F); +} + +void sub_80FC190(void) +{ + sSafariZoneFleedMons += gBattleResults.field_1F; + if (gBattleOutcome == BATTLE_CAUGHT) + sSafariZoneCaughtMons++; + if (gNumSafariBalls != 0) + { + SetMainCallback2(c2_exit_to_overworld_2_switch); + } + else if (gBattleOutcome == 8) + { + ScriptContext2_RunNewScript(gUnknown_082A4B4C); + warp_in(); + gUnknown_03005DAC = sub_80AF6F0; + SetMainCallback2(c2_load_new_map); + } + else if (gBattleOutcome == BATTLE_CAUGHT) + { + ScriptContext1_SetupScript(gUnknown_082A4B9B); + script_env_2_set_ctx_paused(); + SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); + } +} + +static void ClearPokeblockFeeder(u8 index) +{ + memset(&sPokeblockFeeders[index], 0, sizeof(struct PokeblockFeeder)); +} + +static void ClearAllPokeblockFeeders(void) +{ + memset(sPokeblockFeeders, 0, sizeof(sPokeblockFeeders)); +} + +static void GetPokeblockFeederInFront(void) +{ + s16 x, y; + u16 i; + + GetXYCoordsOneStepInFrontOfPlayer(&x, &y); + + for (i = 0; i < NUM_POKEBLOCK_FEEDERS; i++) + { + if (gSaveBlock1Ptr->location.mapNum == sPokeblockFeeders[i].mapNum + && sPokeblockFeeders[i].x == x + && sPokeblockFeeders[i].y == y) + { + gScriptResult = i; + StringCopy(gStringVar1, gPokeblockNames[sPokeblockFeeders[i].pokeblock.color]); + return; + } + } + + gScriptResult = -1; +} + +void GetPokeblockFeederWithinRange(void) +{ + s16 x, y; + u16 i; + + PlayerGetDestCoords(&x, &y); + + for (i = 0; i < NUM_POKEBLOCK_FEEDERS; i++) + { + if (gSaveBlock1Ptr->location.mapNum == sPokeblockFeeders[i].mapNum) + { + //Get absolute value of x and y distance from Pokeblock feeder on current map + x -= sPokeblockFeeders[i].x; + y -= sPokeblockFeeders[i].y; + if (x < 0) + x *= -1; + if (y < 0) + y *= -1; + if ((x + y) <= 5) + { + gScriptResult = i; + return; + } + } + } + + gScriptResult = -1; +} + +// unused +struct Pokeblock *SafariZoneGetPokeblockInFront(void) +{ + GetPokeblockFeederInFront(); + + if (gScriptResult == 0xFFFF) + return NULL; + else + return &sPokeblockFeeders[gScriptResult].pokeblock; +} + +struct Pokeblock *SafariZoneGetActivePokeblock(void) +{ + GetPokeblockFeederWithinRange(); + + if (gScriptResult == 0xFFFF) + return NULL; + else + return &sPokeblockFeeders[gScriptResult].pokeblock; +} + +void SafariZoneActivatePokeblockFeeder(u8 pkblId) +{ + s16 x, y; + u8 i; + + for (i = 0; i < NUM_POKEBLOCK_FEEDERS; i++) + { + // Find free entry in sPokeblockFeeders + if (sPokeblockFeeders[i].mapNum == 0 + && sPokeblockFeeders[i].x == 0 + && sPokeblockFeeders[i].y == 0) + { + // Initialize Pokeblock feeder + GetXYCoordsOneStepInFrontOfPlayer(&x, &y); + sPokeblockFeeders[i].mapNum = gSaveBlock1Ptr->location.mapNum; + sPokeblockFeeders[i].pokeblock = gSaveBlock1Ptr->pokeblocks[pkblId]; + sPokeblockFeeders[i].stepCounter = 100; + sPokeblockFeeders[i].x = x; + sPokeblockFeeders[i].y = y; + break; + } + } +} + +static void DecrementFeederStepCounters(void) +{ + u8 i; + + for (i = 0; i < NUM_POKEBLOCK_FEEDERS; i++) + { + if (sPokeblockFeeders[i].stepCounter != 0) + { + sPokeblockFeeders[i].stepCounter--; + if (sPokeblockFeeders[i].stepCounter == 0) + ClearPokeblockFeeder(i); + } + } +} + +// unused +bool8 GetInFrontFeederPokeblockAndSteps(void) +{ + GetPokeblockFeederInFront(); + + if (gScriptResult == 0xFFFF) + { + return FALSE; + } + + ConvertIntToDecimalStringN(gStringVar2, + sPokeblockFeeders[gScriptResult].stepCounter, + STR_CONV_MODE_LEADING_ZEROS, 3); + + return TRUE; +} diff --git a/sym_common.txt b/sym_common.txt index 24176cc61..0bca24003 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -272,7 +272,7 @@ gUnknown_03005DA8: @ 3005DA8 gUnknown_03005DAC: @ 3005DAC .space 0x4 -gFieldCallback: @ 3005DB0 +gUnknown_03005DB0: @ 3005DB0 .space 0x4 gUnknown_03005DB4: @ 3005DB4 diff --git a/sym_ewram.txt b/sym_ewram.txt index b1f2a8eaf..dda072481 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -1205,23 +1205,7 @@ gUnknown_0203A044: @ 203A044 gUnknown_0203A048: @ 203A048 .space 0x4 -gNumSafariBalls: @ 203A04C - .space 0x2 - -gUnknown_0203A04E: @ 203A04E - .space 0x2 - -gUnknown_0203A050: @ 203A050 - .space 0x1 - -gUnknown_0203A051: @ 203A051 - .space 0x3 - -gUnknown_0203A054: @ 203A054 - .space 0x8 - -gUnknown_0203A05C: @ 203A05C - .space 0x98 + .include "src/safari_zone.o" gUnknown_0203A0F4: @ 203A0F4 .space 0x4