diff --git a/asm/field_screen.s b/asm/field_screen.s index 08eaf949a..27627ac58 100644 --- a/asm/field_screen.s +++ b/asm/field_screen.s @@ -8656,7 +8656,7 @@ task_mpl_807E3C8: @ 80AF6B0 bl ScriptContext2_Disable adds r0, r4, 0 bl DestroyTask - bl sub_80984F4 + bl ScriptUnfreezeEventObjects _080AF6CC: pop {r4} pop {r0} diff --git a/asm/fldeff_80F9BCC.s b/asm/fldeff_80F9BCC.s index 840d38f64..3cfbe215a 100644 --- a/asm/fldeff_80F9BCC.s +++ b/asm/fldeff_80F9BCC.s @@ -467,7 +467,7 @@ _080F9F54: thumb_func_start sub_80F9F5C sub_80F9F5C: @ 80F9F5C push {lr} - ldr r0, =gUnknown_0203AB40 + ldr r0, =gPlayerFacingPosition ldr r1, =gMapHeader ldr r1, [r1, 0x4] bl sub_80E9608 @@ -572,7 +572,7 @@ sub_80FA004: @ 80FA004 lsrs r0, 24 cmp r0, 0x2 bne _080FA0AE - ldr r4, =gUnknown_0203AB40 + ldr r4, =gPlayerFacingPosition adds r1, r4, 0x2 adds r0, r4, 0 bl GetXYCoordsOneStepInFrontOfPlayer @@ -590,10 +590,10 @@ sub_80FA004: @ 80FA004 cmp r0, 0x1 bne _080FA070 bl sub_80F9F5C - ldr r1, =gUnknown_03005DB0 - ldr r0, =FieldCallback_Teleport + ldr r1, =gFieldCallback2 + ldr r0, =FieldCallback_PrepareFadeInFromMenu str r0, [r1] - ldr r1, =gUnknown_0203CEEC + ldr r1, =gPostMenuFieldCallback ldr r0, =sub_80FA0DC b _080FA0C0 .pool @@ -605,10 +605,10 @@ _080FA070: cmp r0, 0x1 bne _080FA0A0 bl sub_80F9F5C - ldr r1, =gUnknown_03005DB0 - ldr r0, =FieldCallback_Teleport + ldr r1, =gFieldCallback2 + ldr r0, =FieldCallback_PrepareFadeInFromMenu str r0, [r1] - ldr r1, =gUnknown_0203CEEC + ldr r1, =gPostMenuFieldCallback ldr r0, =sub_80FA1E8 b _080FA0C0 .pool @@ -624,10 +624,10 @@ _080FA0AE: b _080FA0C4 _080FA0B2: bl sub_80F9F5C - ldr r1, =gUnknown_03005DB0 - ldr r0, =FieldCallback_Teleport + ldr r1, =gFieldCallback2 + ldr r0, =FieldCallback_PrepareFadeInFromMenu str r0, [r1] - ldr r1, =gUnknown_0203CEEC + ldr r1, =gPostMenuFieldCallback ldr r0, =sub_80FA34C _080FA0C0: str r0, [r1] @@ -824,7 +824,7 @@ sub_80FA234: @ 80FA234 thumb_func_start sub_80FA248 sub_80FA248: @ 80FA248 push {r4,lr} - ldr r1, =gUnknown_0203AB40 + ldr r1, =gPlayerFacingPosition movs r2, 0 ldrsh r0, [r1, r2] movs r2, 0x2 diff --git a/asm/fldeff_cut.s b/asm/fldeff_cut.s deleted file mode 100644 index 19a29d729..000000000 --- a/asm/fldeff_cut.s +++ /dev/null @@ -1,1486 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_80D3718 -sub_80D3718: @ 80D3718 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x1C - movs r0, 0x52 - bl npc_before_player_of_type - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080D3754 - ldr r1, =gUnknown_03005DB0 - ldr r0, =FieldCallback_Teleport - str r0, [r1] - ldr r1, =gUnknown_0203CEEC - ldr r0, =sub_80D3A9C - str r0, [r1] - movs r0, 0x1 - b _080D3A2C - .pool -_080D3754: - ldr r0, =gUnknown_0203AB40 - adds r1, r0, 0x2 - bl PlayerGetDestCoords - bl GetCursorSelectionMonId - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - bl GetMonAbility - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0xC] - cmp r0, 0x34 - bne _080D3798 - ldr r1, =gUnknown_03001100 - movs r0, 0x5 - strb r0, [r1] - ldr r0, =gUnknown_03001101 - movs r1, 0x2 - b _080D37A2 - .pool -_080D3798: - ldr r1, =gUnknown_03001100 - movs r0, 0x3 - strb r0, [r1] - ldr r0, =gUnknown_03001101 - movs r1, 0x1 -_080D37A2: - strb r1, [r0] - ldr r0, =gUnknown_03001102 - strb r1, [r0] - movs r6, 0 - movs r1, 0 -_080D37AC: - mov r2, sp - adds r0, r2, r6 - strb r1, [r0] - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x8 - bls _080D37AC - movs r6, 0 - ldr r2, =gUnknown_03001108 - movs r1, 0 -_080D37C2: - adds r0, r6, r2 - strb r1, [r0] - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x18 - bls _080D37C2 - movs r3, 0 - str r3, [sp, 0x10] - movs r6, 0 -_080D37D6: - ldr r4, =0x0000ffff - adds r0, r6, r4 - ldr r1, =gUnknown_0203AB40 - ldrh r1, [r1, 0x2] - adds r0, r1 - movs r5, 0 - adds r2, r6, 0x1 - str r2, [sp, 0x18] - lsls r7, r6, 1 - lsls r0, 16 - str r0, [sp, 0x14] - asrs r0, 16 - mov r10, r0 - lsls r0, r6, 2 - adds r0, r6 - mov r9, r0 -_080D37F6: - ldr r3, =0x0000ffff - adds r0, r5, r3 - ldr r4, =gUnknown_0203AB40 - ldrh r4, [r4] - adds r0, r4 - lsls r0, 16 - lsrs r1, r0, 16 - mov r8, r1 - asrs r4, r0, 16 - adds r0, r4, 0 - mov r1, r10 - bl MapGridGetZCoordAt - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gUnknown_0203AB40 - movs r1, 0x4 - ldrsb r1, [r2, r1] - cmp r0, r1 - bne _080D38BC - adds r0, r4, 0 - mov r1, r10 - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl MetatileBehavior_IsPokeGrass - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080D3846 - adds r0, r4, 0 - bl MetatileBehavior_IsAsh - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080D3856 -_080D3846: - adds r0, r5, 0x6 - add r0, r9 - ldr r3, =gUnknown_03001108 - adds r0, r3 - movs r1, 0x1 - strb r1, [r0] - movs r0, 0x1 - str r0, [sp, 0x10] -_080D3856: - mov r1, r8 - lsls r0, r1, 16 - asrs r0, 16 - ldr r2, [sp, 0x14] - asrs r1, r2, 16 - bl MapGridIsImpassableAt - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080D3890 - adds r0, r7, r6 - adds r0, r5 - mov r3, sp - adds r1, r3, r0 - b _080D38C4 - .pool -_080D3890: - adds r0, r7, r6 - adds r0, r5 - mov r2, sp - adds r1, r2, r0 - movs r0, 0x1 - strb r0, [r1] - adds r0, r4, 0 - bl MetatileBehavior_IsCuttableGrass - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x1 - bne _080D38C8 - adds r0, r5, 0x6 - add r0, r9 - ldr r3, =gUnknown_03001108 - adds r0, r3 - strb r1, [r0] - b _080D38C8 - .pool -_080D38BC: - adds r0, r7, r6 - adds r0, r5 - mov r4, sp - adds r1, r4, r0 -_080D38C4: - movs r0, 0 - strb r0, [r1] -_080D38C8: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x2 - bls _080D37F6 - ldr r1, [sp, 0x18] - lsls r0, r1, 24 - lsrs r6, r0, 24 - cmp r6, 0x2 - bhi _080D38DE - b _080D37D6 -_080D38DE: - ldr r2, [sp, 0xC] - cmp r2, 0x34 - beq _080D38EE - ldr r3, [sp, 0x10] - cmp r3, 0x1 - beq _080D38EC - b _080D3A2A -_080D38EC: - b _080D3A1E -_080D38EE: - movs r6, 0 - ldr r4, =gUnknown_0203AB40 - mov r9, r4 - ldr r0, =gUnknown_0857C608 - mov r10, r0 -_080D38F8: - lsls r2, r6, 2 - mov r3, r10 - adds r1, r2, r3 - movs r0, 0 - ldrsb r0, [r1, r0] - mov r4, r9 - ldrh r4, [r4] - adds r0, r4 - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - movs r0, 0x1 - ldrsb r0, [r1, r0] - mov r1, r9 - ldrh r1, [r1, 0x2] - adds r0, r1 - lsls r0, 16 - lsrs r4, r0, 16 - movs r7, 0x1 - movs r5, 0 - ldr r3, =gUnknown_0857C608 + 2 - adds r0, r2, r3 - ldrb r0, [r0] - adds r6, 0x1 - str r6, [sp, 0x18] - adds r6, r2, 0 - cmp r0, 0 - beq _080D395A -_080D3930: - adds r1, r2, 0 - adds r0, r5, r2 - adds r0, r3 - ldrb r0, [r0] - subs r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - add r0, sp - ldrb r0, [r0] - cmp r0, 0 - beq _080D39F4 - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x1 - bhi _080D395A - adds r0, r5, r1 - adds r0, r3 - ldrb r0, [r0] - cmp r0, 0 - bne _080D3930 -_080D395A: - cmp r7, 0x1 - bne _080D3A0C - mov r1, r8 - lsls r0, r1, 16 - asrs r5, r0, 16 - lsls r0, r4, 16 - asrs r4, r0, 16 - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridGetZCoordAt - lsls r0, 24 - lsrs r0, 24 - mov r2, r9 - movs r1, 0x4 - ldrsb r1, [r2, r1] - cmp r0, r1 - bne _080D3A0C - mov r3, r10 - adds r2, r6, r3 - movs r1, 0x1 - ldrsb r1, [r2, r1] - lsls r0, r1, 2 - adds r0, r1 - adds r0, 0xC - ldrb r2, [r2] - adds r0, r2 - lsls r0, 24 - lsrs r6, r0, 24 - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl MetatileBehavior_IsPokeGrass - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080D39BC - adds r0, r4, 0 - bl MetatileBehavior_IsAsh - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080D39F8 -_080D39BC: - ldr r1, =gUnknown_03005DB0 - ldr r0, =FieldCallback_Teleport - str r0, [r1] - ldr r1, =gUnknown_0203CEEC - ldr r0, =hm2_ruin_valley - str r0, [r1] - ldr r0, =gUnknown_03001108 - adds r0, r6, r0 - strb r7, [r0] - movs r4, 0x1 - str r4, [sp, 0x10] - b _080D3A0C - .pool -_080D39F4: - movs r7, 0 - b _080D395A -_080D39F8: - adds r0, r4, 0 - bl MetatileBehavior_IsCuttableGrass - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x1 - bne _080D3A0C - ldr r0, =gUnknown_03001108 - adds r0, r6, r0 - strb r1, [r0] -_080D3A0C: - ldr r1, [sp, 0x18] - lsls r0, r1, 24 - lsrs r6, r0, 24 - cmp r6, 0xF - bhi _080D3A18 - b _080D38F8 -_080D3A18: - ldr r2, [sp, 0x10] - cmp r2, 0x1 - bne _080D3A2A -_080D3A1E: - ldr r1, =gUnknown_03005DB0 - ldr r0, =FieldCallback_Teleport - str r0, [r1] - ldr r1, =gUnknown_0203CEEC - ldr r0, =hm2_ruin_valley - str r0, [r1] -_080D3A2A: - ldr r0, [sp, 0x10] -_080D3A2C: - add sp, 0x1C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80D3718 - - thumb_func_start hm2_ruin_valley -hm2_ruin_valley: @ 80D3A50 - push {lr} - movs r0, 0x1 - bl FieldEffectStart - bl GetCursorSelectionMonId - ldr r1, =gFieldEffectArguments - lsls r0, 24 - lsrs r0, 24 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end hm2_ruin_valley - - thumb_func_start sub_80D3A6C -sub_80D3A6C: @ 80D3A6C - push {lr} - bl oei_task_add - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldr r2, =sub_80D3AEC - lsrs r0, r2, 16 - strh r0, [r1, 0x18] - strh r2, [r1, 0x1A] - movs r0, 0x12 - bl IncrementGameStat - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80D3A6C - - thumb_func_start sub_80D3A9C -sub_80D3A9C: @ 80D3A9C - push {lr} - bl GetCursorSelectionMonId - ldr r1, =gFieldEffectArguments - lsls r0, 24 - lsrs r0, 24 - str r0, [r1] - ldr r0, =Route103_EventScript_290705 - bl ScriptContext1_SetupScript - pop {r0} - bx r0 - .pool - thumb_func_end sub_80D3A9C - - thumb_func_start sub_80D3ABC -sub_80D3ABC: @ 80D3ABC - push {lr} - bl oei_task_add - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldr r2, =sub_80D4354 - lsrs r0, r2, 16 - strh r0, [r1, 0x18] - strh r2, [r1, 0x1A] - movs r0, 0x12 - bl IncrementGameStat - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80D3ABC - - thumb_func_start sub_80D3AEC -sub_80D3AEC: @ 80D3AEC - push {lr} - movs r0, 0x1 - bl FieldEffectActiveListRemove - movs r0, 0x3A - bl FieldEffectStart - pop {r0} - bx r0 - thumb_func_end sub_80D3AEC - - thumb_func_start sub_80D3B00 -sub_80D3B00: @ 80D3B00 - push {r4-r7,lr} - movs r6, 0 - movs r0, 0x80 - bl PlaySE - ldr r4, =gUnknown_0203AB40 - adds r1, r4, 0x2 - adds r0, r4, 0 - bl PlayerGetDestCoords - adds r7, r4, 0 -_080D3B16: - ldr r0, =gUnknown_03001108 - adds r0, r6, r0 - ldrb r0, [r0] - cmp r0, 0x1 - bne _080D3B64 - adds r0, r6, 0 - movs r1, 0x5 - bl __umodsi3 - adds r4, r0, 0 - subs r4, 0x2 - lsls r4, 24 - lsrs r4, 24 - adds r0, r6, 0 - movs r1, 0x5 - bl __udivsi3 - adds r5, r0, 0 - subs r5, 0x2 - lsls r4, 24 - asrs r4, 24 - ldrh r0, [r7] - adds r4, r0 - lsls r5, 24 - asrs r5, 24 - ldrh r2, [r7, 0x2] - adds r5, r2 - lsls r4, 16 - asrs r4, 16 - lsls r5, 16 - asrs r5, 16 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80D3C10 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_808E75C -_080D3B64: - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x18 - bls _080D3B16 - ldr r2, =gUnknown_0203AB40 - ldr r0, =gUnknown_03001101 - ldrb r1, [r0] - ldrh r0, [r2] - subs r0, r1 - lsls r0, 16 - asrs r0, 16 - ldr r1, =gUnknown_03001102 - ldrb r1, [r1] - mvns r1, r1 - ldrh r2, [r2, 0x2] - adds r1, r2 - lsls r1, 16 - asrs r1, 16 - bl sub_80D3D5C - bl DrawWholeMapView - ldr r4, =gUnknown_02039DD0 - movs r0, 0x8 - bl AllocZeroed - str r0, [r4] - movs r6, 0 - ldr r5, =gSprites -_080D3BA0: - ldr r0, =gPlayerAvatar - ldrb r1, [r0, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - ldrh r1, [r0, 0x2] - lsls r1, 23 - lsrs r1, 7 - movs r2, 0x80 - lsls r2, 12 - adds r1, r2 - asrs r1, 16 - ldrb r2, [r0] - adds r2, 0x14 - ldr r0, =gUnknown_0857C66C - movs r3, 0 - bl CreateSprite - ldr r1, [r4] - adds r1, r6 - strb r0, [r1] - ldr r0, [r4] - adds r0, r6 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - lsls r1, r6, 5 - strh r1, [r0, 0x32] - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x7 - bls _080D3BA0 - movs r0, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80D3B00 - - thumb_func_start sub_80D3C10 -sub_80D3C10: @ 80D3C10 - push {r4-r7,lr} - lsls r0, 16 - lsls r1, 16 - lsrs r6, r0, 16 - asrs r4, r0, 16 - lsrs r7, r1, 16 - asrs r5, r1, 16 - adds r0, r4, 0 - adds r1, r5, 0 - bl MapGridGetMetatileIdAt - adds r1, r0, 0 - ldr r0, =0x00000207 - cmp r1, r0 - bgt _080D3C5C - subs r0, 0x1 - cmp r1, r0 - bge _080D3CD4 - cmp r1, 0x25 - beq _080D3CF6 - cmp r1, 0x25 - bgt _080D3C4C - cmp r1, 0xD - beq _080D3C9C - cmp r1, 0x15 - beq _080D3C9C - b _080D3D00 - .pool -_080D3C4C: - movs r0, 0xE3 - lsls r0, 1 - cmp r1, r0 - beq _080D3CAC - adds r0, 0x1 - cmp r1, r0 - beq _080D3CB2 - b _080D3D00 -_080D3C5C: - ldr r0, =0x00000212 - cmp r1, r0 - beq _080D3CE4 - cmp r1, r0 - bgt _080D3C78 - subs r0, 0xA - cmp r1, r0 - beq _080D3C9C - adds r0, 0x2 - cmp r1, r0 - beq _080D3CE4 - b _080D3D00 - .pool -_080D3C78: - ldr r0, =0x00000282 - cmp r1, r0 - beq _080D3CC4 - cmp r1, r0 - bgt _080D3C90 - subs r0, 0x1 - cmp r1, r0 - beq _080D3CBC - b _080D3D00 - .pool -_080D3C90: - ldr r0, =0x00000283 - cmp r1, r0 - beq _080D3CCC - b _080D3D00 - .pool -_080D3C9C: - lsls r0, r6, 16 - asrs r0, 16 - lsls r1, r7, 16 - asrs r1, 16 - movs r2, 0x1 - bl MapGridSetMetatileIdAt - b _080D3D00 -_080D3CAC: - movs r2, 0xE7 - lsls r2, 1 - b _080D3CD6 -_080D3CB2: - ldr r2, =0x000001cf - b _080D3CD6 - .pool -_080D3CBC: - ldr r2, =0x00000279 - b _080D3CD6 - .pool -_080D3CC4: - ldr r2, =0x0000027a - b _080D3CD6 - .pool -_080D3CCC: - ldr r2, =0x0000027b - b _080D3CD6 - .pool -_080D3CD4: - ldr r2, =0x00000271 -_080D3CD6: - adds r0, r4, 0 - adds r1, r5, 0 - bl MapGridSetMetatileIdAt - b _080D3D00 - .pool -_080D3CE4: - lsls r0, r6, 16 - asrs r0, 16 - lsls r1, r7, 16 - asrs r1, 16 - movs r2, 0x86 - lsls r2, 2 - bl MapGridSetMetatileIdAt - b _080D3D00 -_080D3CF6: - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0xE - bl MapGridSetMetatileIdAt -_080D3D00: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80D3C10 - - thumb_func_start sub_80D3D08 -sub_80D3D08: @ 80D3D08 - push {lr} - lsls r0, 16 - asrs r0, 16 - lsls r1, 16 - asrs r1, 16 - bl MapGridGetMetatileIdAt - lsls r0, 16 - lsrs r1, r0, 16 - adds r2, r1, 0 - cmp r1, 0x1 - bne _080D3D24 - movs r0, 0x1 - b _080D3D56 -_080D3D24: - ldr r0, =0x00000279 - cmp r1, r0 - bne _080D3D34 - movs r0, 0x2 - b _080D3D56 - .pool -_080D3D34: - ldr r0, =0x0000027a - cmp r1, r0 - bne _080D3D44 - movs r0, 0x3 - b _080D3D56 - .pool -_080D3D44: - ldr r0, =0x0000027b - cmp r2, r0 - beq _080D3D54 - movs r0, 0 - b _080D3D56 - .pool -_080D3D54: - movs r0, 0x4 -_080D3D56: - pop {r1} - bx r1 - thumb_func_end sub_80D3D08 - - thumb_func_start sub_80D3D5C -sub_80D3D5C: @ 80D3D5C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - lsls r0, 16 - lsrs r0, 16 - mov r9, r0 - lsls r1, 16 - lsrs r1, 16 - mov r10, r1 - ldr r1, =gUnknown_03001100 - ldrb r2, [r1] - mov r3, r10 - adds r0, r2, r3 - lsls r0, 16 - lsrs r0, 16 - str r0, [sp] - movs r4, 0 - cmp r4, r2 - blt _080D3D8A - b _080D3EA0 -_080D3D8A: - lsls r0, r3, 16 - asrs r7, r0, 16 -_080D3D8E: - mov r1, r9 - lsls r0, r1, 16 - asrs r0, 16 - lsls r4, 16 - asrs r1, r4, 16 - adds r0, r1 - lsls r0, 16 - lsrs r6, r0, 16 - asrs r5, r0, 16 - adds r0, r5, 0 - adds r1, r7, 0 - bl MapGridGetMetatileIdAt - mov r8, r4 - cmp r0, 0x15 - bne _080D3E12 - adds r4, r7, 0x1 - lsls r1, r4, 16 - asrs r1, 16 - adds r0, r5, 0 - bl sub_80D3D08 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - beq _080D3DE8 - cmp r0, 0x2 - bgt _080D3DD0 - cmp r0, 0x1 - beq _080D3DDA - b _080D3E12 - .pool -_080D3DD0: - cmp r0, 0x3 - beq _080D3DF8 - cmp r0, 0x4 - beq _080D3E08 - b _080D3E12 -_080D3DDA: - adds r0, r5, 0 - adds r1, r4, 0 - movs r2, 0x82 - lsls r2, 2 - bl MapGridSetMetatileIdAt - b _080D3E12 -_080D3DE8: - adds r0, r5, 0 - adds r1, r4, 0 - ldr r2, =0x00000281 - bl MapGridSetMetatileIdAt - b _080D3E12 - .pool -_080D3DF8: - adds r0, r5, 0 - adds r1, r4, 0 - ldr r2, =0x00000282 - bl MapGridSetMetatileIdAt - b _080D3E12 - .pool -_080D3E08: - adds r0, r5, 0 - adds r1, r4, 0 - ldr r2, =0x00000283 - bl MapGridSetMetatileIdAt -_080D3E12: - lsls r0, r6, 16 - asrs r5, r0, 16 - ldr r3, [sp] - lsls r0, r3, 16 - asrs r4, r0, 16 - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridGetMetatileIdAt - cmp r0, 0x1 - bne _080D3E8C - adds r4, 0x1 - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridGetMetatileIdAt - movs r1, 0x82 - lsls r1, 2 - cmp r0, r1 - bne _080D3E44 - adds r0, r5, 0 - adds r1, r4, 0 - movs r2, 0x1 - bl MapGridSetMetatileIdAt -_080D3E44: - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridGetMetatileIdAt - ldr r1, =0x00000281 - cmp r0, r1 - bne _080D3E5C - adds r0, r5, 0 - adds r1, r4, 0 - ldr r2, =0x00000279 - bl MapGridSetMetatileIdAt -_080D3E5C: - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridGetMetatileIdAt - ldr r1, =0x00000282 - cmp r0, r1 - bne _080D3E74 - adds r0, r5, 0 - adds r1, r4, 0 - ldr r2, =0x0000027a - bl MapGridSetMetatileIdAt -_080D3E74: - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridGetMetatileIdAt - ldr r1, =0x00000283 - cmp r0, r1 - bne _080D3E8C - adds r0, r5, 0 - adds r1, r4, 0 - ldr r2, =0x0000027b - bl MapGridSetMetatileIdAt -_080D3E8C: - movs r1, 0x80 - lsls r1, 9 - add r1, r8 - lsrs r4, r1, 16 - asrs r1, 16 - ldr r0, =gUnknown_03001100 - ldrb r0, [r0] - cmp r1, r0 - bge _080D3EA0 - b _080D3D8E -_080D3EA0: - ldr r1, =gUnknown_03001100 - ldrb r0, [r1] - cmp r0, 0x5 - bne _080D3EC8 - mov r3, r9 - lsls r5, r3, 16 - asrs r5, 16 - mov r0, r10 - lsls r4, r0, 16 - asrs r4, 16 - movs r0, 0 - adds r1, r5, 0 - adds r2, r4, 0 - bl sub_80D3EF4 - movs r0, 0x1 - adds r1, r5, 0 - adds r2, r4, 0 - bl sub_80D3EF4 -_080D3EC8: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80D3D5C - - thumb_func_start sub_80D3EF4 -sub_80D3EF4: @ 80D3EF4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 16 - lsrs r5, r1, 16 - adds r3, r5, 0 - lsls r2, 16 - lsrs r2, 16 - mov r10, r2 - cmp r0, 0 - bne _080D3F2C - mov r2, sp - ldr r1, =gUnknown_03001108 - ldrb r0, [r1, 0x5] - strb r0, [r2] - ldrb r0, [r1, 0xA] - strb r0, [r2, 0x1] - ldrb r0, [r1, 0xF] - strb r0, [r2, 0x2] - mov r8, r5 - b _080D3F4E - .pool -_080D3F2C: - cmp r0, 0x1 - beq _080D3F32 - b _080D414A -_080D3F32: - mov r2, sp - ldr r1, =gUnknown_03001108 - ldrb r0, [r1, 0x9] - strb r0, [r2] - ldrb r0, [r1, 0xE] - strb r0, [r2, 0x1] - ldrb r0, [r1, 0x13] - strb r0, [r2, 0x2] - lsls r0, r3, 16 - movs r1, 0x80 - lsls r1, 11 - adds r0, r1 - lsrs r0, 16 - mov r8, r0 -_080D3F4E: - mov r0, sp - ldrb r0, [r0] - cmp r0, 0x1 - bne _080D3FC6 - mov r1, r8 - lsls r0, r1, 16 - asrs r5, r0, 16 - mov r1, r10 - lsls r0, r1, 16 - asrs r0, 16 - adds r4, r0, 0x3 - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridGetMetatileIdAt - movs r1, 0x82 - lsls r1, 2 - cmp r0, r1 - bne _080D3F7E - adds r0, r5, 0 - adds r1, r4, 0 - movs r2, 0x1 - bl MapGridSetMetatileIdAt -_080D3F7E: - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridGetMetatileIdAt - ldr r1, =0x00000281 - cmp r0, r1 - bne _080D3F96 - ldr r2, =0x00000279 - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridSetMetatileIdAt -_080D3F96: - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridGetMetatileIdAt - ldr r1, =0x00000282 - cmp r0, r1 - bne _080D3FAE - ldr r2, =0x0000027a - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridSetMetatileIdAt -_080D3FAE: - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridGetMetatileIdAt - ldr r1, =0x00000283 - cmp r0, r1 - bne _080D3FC6 - ldr r2, =0x0000027b - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridSetMetatileIdAt -_080D3FC6: - mov r0, sp - ldrb r0, [r0, 0x1] - cmp r0, 0x1 - bne _080D40C0 - mov r0, r8 - lsls r5, r0, 16 - asrs r6, r5, 16 - mov r1, r10 - lsls r4, r1, 16 - asrs r7, r4, 16 - adds r1, r7, 0x2 - adds r0, r6, 0 - bl MapGridGetMetatileIdAt - mov r9, r4 - cmp r0, 0x15 - bne _080D4056 - adds r4, r7, 0x3 - lsls r1, r4, 16 - asrs r1, 16 - adds r0, r6, 0 - bl sub_80D3D08 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - beq _080D4034 - cmp r0, 0x2 - bgt _080D4024 - cmp r0, 0x1 - beq _080D402E - b _080D4056 - .pool -_080D4024: - cmp r0, 0x3 - beq _080D403C - cmp r0, 0x4 - beq _080D404C - b _080D4056 -_080D402E: - movs r2, 0x82 - lsls r2, 2 - b _080D403E -_080D4034: - ldr r2, =0x00000281 - b _080D403E - .pool -_080D403C: - ldr r2, =0x00000282 -_080D403E: - adds r0, r6, 0 - adds r1, r4, 0 - bl MapGridSetMetatileIdAt - b _080D4056 - .pool -_080D404C: - ldr r2, =0x00000283 - adds r0, r6, 0 - adds r1, r4, 0 - bl MapGridSetMetatileIdAt -_080D4056: - asrs r5, 16 - mov r1, r9 - asrs r0, r1, 16 - adds r4, r0, 0x4 - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridGetMetatileIdAt - movs r1, 0x82 - lsls r1, 2 - cmp r0, r1 - bne _080D4078 - adds r0, r5, 0 - adds r1, r4, 0 - movs r2, 0x1 - bl MapGridSetMetatileIdAt -_080D4078: - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridGetMetatileIdAt - ldr r1, =0x00000281 - cmp r0, r1 - bne _080D4090 - ldr r2, =0x00000279 - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridSetMetatileIdAt -_080D4090: - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridGetMetatileIdAt - ldr r1, =0x00000282 - cmp r0, r1 - bne _080D40A8 - ldr r2, =0x0000027a - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridSetMetatileIdAt -_080D40A8: - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridGetMetatileIdAt - ldr r1, =0x00000283 - cmp r0, r1 - bne _080D40C0 - ldr r2, =0x0000027b - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridSetMetatileIdAt -_080D40C0: - mov r0, sp - ldrb r0, [r0, 0x2] - cmp r0, 0x1 - bne _080D414A - mov r1, r8 - lsls r0, r1, 16 - asrs r5, r0, 16 - mov r1, r10 - lsls r0, r1, 16 - asrs r4, r0, 16 - adds r1, r4, 0x3 - adds r0, r5, 0 - bl MapGridGetMetatileIdAt - cmp r0, 0x15 - bne _080D414A - adds r4, 0x4 - lsls r1, r4, 16 - asrs r1, 16 - adds r0, r5, 0 - bl sub_80D3D08 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - beq _080D4128 - cmp r0, 0x2 - bgt _080D4118 - cmp r0, 0x1 - beq _080D4122 - b _080D414A - .pool -_080D4118: - cmp r0, 0x3 - beq _080D4130 - cmp r0, 0x4 - beq _080D4140 - b _080D414A -_080D4122: - movs r2, 0x82 - lsls r2, 2 - b _080D4132 -_080D4128: - ldr r2, =0x00000281 - b _080D4132 - .pool -_080D4130: - ldr r2, =0x00000282 -_080D4132: - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridSetMetatileIdAt - b _080D414A - .pool -_080D4140: - ldr r2, =0x00000283 - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridSetMetatileIdAt -_080D414A: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80D3EF4 - - thumb_func_start objc_8097BA8 -objc_8097BA8: @ 80D4160 - movs r2, 0 - movs r1, 0x8 - strh r1, [r0, 0x2E] - strh r2, [r0, 0x30] - strh r2, [r0, 0x34] - ldr r1, =objc_8097BBC - str r1, [r0, 0x1C] - bx lr - .pool - thumb_func_end objc_8097BA8 - - thumb_func_start objc_8097BBC -objc_8097BBC: @ 80D4174 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x32 - ldrsh r0, [r4, r1] - movs r2, 0x2E - ldrsh r1, [r4, r2] - bl Sin - strh r0, [r4, 0x24] - movs r1, 0x32 - ldrsh r0, [r4, r1] - movs r2, 0x2E - ldrsh r1, [r4, r2] - bl Cos - strh r0, [r4, 0x26] - ldrh r0, [r4, 0x32] - adds r0, 0x8 - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x32] - ldrh r1, [r4, 0x2E] - adds r1, 0x1 - ldrh r2, [r4, 0x34] - lsls r0, r2, 16 - asrs r0, 18 - adds r1, r0 - strh r1, [r4, 0x2E] - adds r2, 0x1 - strh r2, [r4, 0x34] - ldrh r1, [r4, 0x30] - movs r2, 0x30 - ldrsh r0, [r4, r2] - cmp r0, 0x1C - beq _080D41C0 - adds r0, r1, 0x1 - strh r0, [r4, 0x30] - b _080D41C4 -_080D41C0: - ldr r0, =sub_80D41D0 - str r0, [r4, 0x1C] -_080D41C4: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end objc_8097BBC - - thumb_func_start sub_80D41D0 -sub_80D41D0: @ 80D41D0 - push {r4-r6,lr} - movs r4, 0x1 -_080D41D4: - ldr r6, =gUnknown_02039DD0 - ldr r0, [r6] - adds r0, r4 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r5, =gSprites - adds r0, r5 - bl DestroySprite - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x7 - bls _080D41D4 - ldr r0, [r6] - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - movs r1, 0x3A - bl FieldEffectStop - ldr r0, [r6] - bl Free - movs r0, 0 - str r0, [r6] - bl sub_80984F4 - bl ScriptContext2_Disable - bl unown_chamber_related - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080D422A - ldr r0, =FarawayIsland_Interior_EventScript_267EDB - bl ScriptContext1_SetupScript -_080D422A: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80D41D0 - - thumb_func_start sub_80D423C -sub_80D423C: @ 80D423C - push {r4,r5,lr} - lsls r0, 16 - asrs r5, r0, 16 - lsls r1, 16 - asrs r4, r1, 16 - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl MetatileBehavior_IsLongGrass_Duplicate - lsls r0, 24 - cmp r0, 0 - beq _080D42AE - adds r4, 0x1 - lsls r1, r4, 16 - asrs r1, 16 - adds r0, r5, 0 - bl sub_80D3D08 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - beq _080D428A - cmp r0, 0x2 - bgt _080D427A - cmp r0, 0x1 - beq _080D4284 - b _080D42AE -_080D427A: - cmp r0, 0x3 - beq _080D4294 - cmp r0, 0x4 - beq _080D42A4 - b _080D42AE -_080D4284: - movs r2, 0x82 - lsls r2, 2 - b _080D4296 -_080D428A: - ldr r2, =0x00000281 - b _080D4296 - .pool -_080D4294: - ldr r2, =0x00000282 -_080D4296: - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridSetMetatileIdAt - b _080D42AE - .pool -_080D42A4: - ldr r2, =0x00000283 - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridSetMetatileIdAt -_080D42AE: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80D423C - - thumb_func_start sub_80D42B8 -sub_80D42B8: @ 80D42B8 - push {r4,r5,lr} - lsls r0, 16 - asrs r4, r0, 16 - lsls r1, 16 - asrs r5, r1, 16 - adds r0, r4, 0 - adds r1, r5, 0 - bl MapGridGetMetatileIdAt - cmp r0, 0x1 - bne _080D434A - adds r5, 0x1 - adds r0, r4, 0 - adds r1, r5, 0 - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl MetatileBehavior_IsLongGrassSouthEdge - lsls r0, 24 - cmp r0, 0 - beq _080D434A - adds r0, r4, 0 - adds r1, r5, 0 - bl MapGridGetMetatileIdAt - adds r1, r0, 0 - ldr r0, =0x00000281 - cmp r1, r0 - beq _080D4328 - cmp r1, r0 - bgt _080D4308 - subs r0, 0x79 - cmp r1, r0 - beq _080D431C - b _080D434A - .pool -_080D4308: - ldr r0, =0x00000282 - cmp r1, r0 - beq _080D4330 - adds r0, 0x1 - cmp r1, r0 - beq _080D4340 - b _080D434A - .pool -_080D431C: - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x1 - bl MapGridSetMetatileIdAt - b _080D434A -_080D4328: - ldr r2, =0x00000279 - b _080D4332 - .pool -_080D4330: - ldr r2, =0x0000027a -_080D4332: - adds r0, r4, 0 - adds r1, r5, 0 - bl MapGridSetMetatileIdAt - b _080D434A - .pool -_080D4340: - ldr r2, =0x0000027b - adds r0, r4, 0 - adds r1, r5, 0 - bl MapGridSetMetatileIdAt -_080D434A: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80D42B8 - - thumb_func_start sub_80D4354 -sub_80D4354: @ 80D4354 - push {lr} - movs r0, 0x80 - bl PlaySE - movs r0, 0x2 - bl FieldEffectActiveListRemove - bl EnableBothScriptContexts - pop {r0} - bx r0 - thumb_func_end sub_80D4354 - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/party_menu.s b/asm/party_menu.s index 782d8ae31..6e90fa3c3 100644 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -10199,10 +10199,10 @@ _081B5714: movs r0, 0x5 bl PlaySE _081B571A: - ldr r0, =gUnknown_03005DB0 + ldr r0, =gFieldCallback2 movs r1, 0 str r1, [r0] - ldr r0, =gUnknown_0203CEEC + ldr r0, =gPostMenuFieldCallback str r1, [r0] adds r0, r4, 0 bl sub_81B1C1C @@ -10213,8 +10213,8 @@ _081B572A: .pool thumb_func_end sub_81B56D8 - thumb_func_start FieldCallback_Teleport -FieldCallback_Teleport: @ 81B5738 + thumb_func_start FieldCallback_PrepareFadeInFromMenu +FieldCallback_PrepareFadeInFromMenu: @ 81B5738 push {lr} bl pal_fill_black ldr r0, =task_launch_hm_phase_2 @@ -10224,7 +10224,7 @@ FieldCallback_Teleport: @ 81B5738 pop {r1} bx r1 .pool - thumb_func_end FieldCallback_Teleport + thumb_func_end FieldCallback_PrepareFadeInFromMenu thumb_func_start task_launch_hm_phase_2 task_launch_hm_phase_2: @ 81B5750 @@ -10241,7 +10241,7 @@ task_launch_hm_phase_2: @ 81B5750 lsls r0, 16 lsrs r0, 16 str r0, [r1] - ldr r0, =gUnknown_0203CEEC + ldr r0, =gPostMenuFieldCallback ldr r0, [r0] bl _call_via_r0 adds r0, r4, 0 @@ -10345,10 +10345,10 @@ sub_81B5820: @ 81B5820 lsrs r0, 24 cmp r0, 0x1 bne _081B585C - ldr r1, =gUnknown_03005DB0 - ldr r0, =FieldCallback_Teleport + ldr r1, =gFieldCallback2 + ldr r0, =FieldCallback_PrepareFadeInFromMenu str r0, [r1] - ldr r1, =gUnknown_0203CEEC + ldr r1, =gPostMenuFieldCallback ldr r0, =hm_surf_run_dp02scr str r0, [r1] movs r0, 0x1 @@ -10463,10 +10463,10 @@ hm_prepare_waterfall: @ 81B58F0 lsrs r0, 24 cmp r0, 0x1 bne _081B594C - ldr r1, =gUnknown_03005DB0 - ldr r0, =FieldCallback_Teleport + ldr r1, =gFieldCallback2 + ldr r0, =FieldCallback_PrepareFadeInFromMenu str r0, [r1] - ldr r1, =gUnknown_0203CEEC + ldr r1, =gPostMenuFieldCallback ldr r0, =hm2_waterfall str r0, [r1] movs r0, 0x1 @@ -10510,10 +10510,10 @@ sub_81B5974: @ 81B5974 b _081B599E .pool _081B5990: - ldr r1, =gUnknown_03005DB0 - ldr r0, =FieldCallback_Teleport + ldr r1, =gFieldCallback2 + ldr r0, =FieldCallback_PrepareFadeInFromMenu str r0, [r1] - ldr r1, =gUnknown_0203CEEC + ldr r1, =gPostMenuFieldCallback ldr r0, =sub_81B5958 str r0, [r1] movs r0, 0x1 @@ -17276,7 +17276,7 @@ sub_81B9354: @ 81B9354 sub sp, 0xC lsls r0, 24 lsrs r0, 24 - ldr r2, =gUnknown_03005DB0 + ldr r2, =gFieldCallback2 ldr r1, =hm_add_c3_without_phase_2 str r1, [r2] movs r1, 0 @@ -17308,7 +17308,7 @@ sub_81B9390: @ 81B9390 movs r0, 0xFF strh r0, [r4] _081B93A6: - ldr r0, =gUnknown_03005DB0 + ldr r0, =gFieldCallback2 ldr r1, =hm_add_c3_without_phase_2 str r1, [r0] ldr r0, =CB2_ReturnToField @@ -17417,7 +17417,7 @@ _081B9486: ldr r1, =gSpecialVar_0x8004 ldrb r0, [r2] strh r0, [r1] - ldr r1, =gUnknown_03005DB0 + ldr r1, =gFieldCallback2 ldr r0, =hm_add_c3_without_phase_2 str r0, [r1] ldr r0, =CB2_ReturnToField @@ -17553,7 +17553,7 @@ _081B95A4: lsrs r0, 24 strh r0, [r4] _081B95BA: - ldr r0, =gUnknown_03005DB0 + ldr r0, =gFieldCallback2 ldr r1, =hm_add_c3_without_phase_2 str r1, [r0] ldr r0, =CB2_ReturnToField diff --git a/asm/pokemon_summary_screen.s b/asm/pokemon_summary_screen.s index ff848df08..3d184e86f 100644 --- a/asm/pokemon_summary_screen.s +++ b/asm/pokemon_summary_screen.s @@ -2070,7 +2070,7 @@ sub_81C4F44: @ 81C4F44 cmp r0, 0 bne _081C4F6E bl overworld_free_bg_tilemaps - ldr r0, =gUnknown_03005DB0 + ldr r0, =gFieldCallback2 ldr r1, =hm_add_c3_without_phase_2 str r1, [r0] ldr r1, =CB2_ReturnToField diff --git a/asm/pokenav.s b/asm/pokenav.s index a9c1ec7e6..1e4cac5d7 100644 --- a/asm/pokenav.s +++ b/asm/pokenav.s @@ -26527,8 +26527,8 @@ _081D4A0E: bx r1 thumb_func_end EventObjectIsFarawayIslandMew - thumb_func_start unown_chamber_related -unown_chamber_related: @ 81D4A14 + thumb_func_start IsMewPlayingHideAndSeek +IsMewPlayingHideAndSeek: @ 81D4A14 push {lr} ldr r0, =gSaveBlock1Ptr ldr r0, [r0] @@ -26557,7 +26557,7 @@ _081D4A50: _081D4A52: pop {r1} bx r1 - thumb_func_end unown_chamber_related + thumb_func_end IsMewPlayingHideAndSeek thumb_func_start sub_81D4A58 sub_81D4A58: @ 81D4A58 diff --git a/common_syms/overworld.txt b/common_syms/overworld.txt index 687b67545..a3b97a759 100644 --- a/common_syms/overworld.txt +++ b/common_syms/overworld.txt @@ -1,5 +1,5 @@ gUnknown_03005DA8 gFieldCallback -gUnknown_03005DB0 +gFieldCallback2 gUnknown_03005DB4 gFieldLinkPlayerCount diff --git a/data/field_effect_scripts.s b/data/field_effect_scripts.s index 581b72e43..c0c74496f 100644 --- a/data/field_effect_scripts.s +++ b/data/field_effect_scripts.s @@ -78,11 +78,11 @@ gFieldEffectScript_ExclamationMarkIcon1:: @ 82DBAE0 field_eff_end gFieldEffectScript_UseCutOnTallGrass:: @ 82DBAE6 - field_eff_callnative sub_80D3A6C + field_eff_callnative FldEff_UseCutOnGrass field_eff_end gFieldEffectScript_UseCutOnTree:: @ 82DBAEC - field_eff_callnative sub_80D3ABC + field_eff_callnative FldEff_UseCutOnTree field_eff_end gFieldEffectScript_Shadow:: @ 82DBAF2 @@ -308,7 +308,7 @@ gFieldEffectScript_Unknown57:: @ 82DBCB8 field_eff_end gFieldEffectScript_Unknown58:: @ 82DBCC2 - field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo6, sub_80D3B00 + field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo6, FldEff_CutGrass field_eff_end gFieldEffectScript_FieldMoveShowMonInit:: @ 82DBCCC diff --git a/data/fldeff_cut.s b/data/fldeff_cut.s deleted file mode 100644 index ee5a09c37..000000000 --- a/data/fldeff_cut.s +++ /dev/null @@ -1,32 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2, 0 - -gUnknown_0857C608:: @ 857C608 - .byte 0xfe, 0xfe, 0x01, 0x00, 0xff, 0xfe, 0x01, 0x00, 0x00, 0xfe, 0x02, 0x00, 0x01, 0xfe, 0x03, 0x00, 0x02, 0xfe, 0x03, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0xff, 0x03, 0x00, 0xfe, 0x00, 0x04, 0x00, 0x02, 0x00 - .byte 0x06, 0x00, 0xfe, 0x01, 0x07, 0x00, 0x02, 0x01, 0x09, 0x00, 0xfe, 0x02, 0x07, 0x00, 0xff, 0x02, 0x07, 0x00, 0x00, 0x02, 0x08, 0x00, 0x01, 0x02, 0x09, 0x00, 0x02, 0x02, 0x09, 0x00 - -gUnknown_0857C648:: @ 857C648 - .2byte 0 - .2byte 0 - .2byte 0x1401 - .2byte 0 - -gUnknown_0857C650:: @ 857C650 - obj_image_anim_frame 0, 0x1E - obj_image_anim_jump 0 - -gUnknown_0857C658:: @ 857C658 - .4byte gUnknown_0857C650 - -gUnknown_0857C65C:: @ 857C65C - obj_frame_tiles gFieldEffectObjectPic_ShadowExtraLarge + 0x520, 32 - - .align 2 -gFieldEffectObjectPaletteInfo6:: @ 857C664 - obj_pal gFieldEffectObjectPalette6, 0x1000 - -gUnknown_0857C66C:: @ 857C66C - spr_template -1, 0x1000, gUnknown_0857C648, gUnknown_0857C658, gUnknown_0857C65C, gDummySpriteAffineAnimTable, objc_8097BA8 diff --git a/data/party_menu.s b/data/party_menu.s index ebd596870..eedcd4377 100644 --- a/data/party_menu.s +++ b/data/party_menu.s @@ -431,7 +431,7 @@ gUnknown_08615D7E:: @ 8615D7E .align 2 gUnknown_08615D9C:: @ 8615D9C - .4byte sub_80D3718, 0x00000007 + .4byte SetUpFieldMove_Cut, 0x00000007 .4byte SetUpFieldMove_Flash, 0x0000000d .4byte SetUpFieldMove_RockSmash, 0x0000000d .4byte SetUpFieldMove_Strength, 0x0000000d diff --git a/graphics/event_objects/pics/effects/cut_grass.png b/graphics/event_objects/pics/effects/cut_grass.png new file mode 100644 index 000000000..3c41d28b3 Binary files /dev/null and b/graphics/event_objects/pics/effects/cut_grass.png differ diff --git a/graphics/event_objects/pics/effects/unknown_4F6D38/0.png b/graphics/event_objects/pics/effects/unknown_4F6D38/0.png deleted file mode 100644 index 3ee87e1cd..000000000 Binary files a/graphics/event_objects/pics/effects/unknown_4F6D38/0.png and /dev/null differ diff --git a/include/field_effect.h b/include/field_effect.h index 800048605..9c9501bfa 100644 --- a/include/field_effect.h +++ b/include/field_effect.h @@ -78,8 +78,8 @@ enum FieldEffectScriptIdx }; extern s32 gFieldEffectArguments[8]; -extern void (*gUnknown_0203CEEC)(void); -extern bool8 (*gUnknown_03005DB0)(void); +extern void (*gPostMenuFieldCallback)(void); +extern bool8 (*gFieldCallback2)(void); u32 FieldEffectStart(u8); bool8 FieldEffectActiveListContains(u8 id); diff --git a/include/fldeff_cut.h b/include/fldeff_cut.h index f985fd82d..c89d3b6ca 100644 --- a/include/fldeff_cut.h +++ b/include/fldeff_cut.h @@ -1,7 +1,13 @@ #ifndef GUARD_FLDEFF_CUT_H #define GUARD_FLDEFF_CUT_H -void sub_80D423C(s16, s16); -void sub_80D42B8(s16, s16); +extern const struct SpritePalette gFieldEffectObjectPaletteInfo6; + +bool8 SetUpFieldMove_Cut(void); +bool8 FldEff_UseCutOnGrass(void); +bool8 FldEff_UseCutOnTree(void); +bool8 FldEff_CutGrass(void); +void sub_80D423C(s16 x, s16 y); +void sub_80D42B8(s16 x, s16 y); #endif // GUARD_FLDEFF_CUT_H diff --git a/include/global.h b/include/global.h index 5021e0410..7153ef260 100644 --- a/include/global.h +++ b/include/global.h @@ -873,7 +873,7 @@ struct MapPosition { s16 x; s16 y; - u8 height; + s8 height; }; struct UnkStruct_8054FF8 diff --git a/include/metatile_behavior.h b/include/metatile_behavior.h index 4b9fd2488..86a67ab3e 100644 --- a/include/metatile_behavior.h +++ b/include/metatile_behavior.h @@ -74,7 +74,7 @@ bool8 MetatileBehavior_IsPuddle(u8); bool8 MetatileBehavior_IsTallGrass(u8); bool8 MetatileBehavior_IsLongGrass(u8); bool8 MetatileBehavior_IsBerryTreeSoil(u8); -bool8 MetatileBehavior_IsAsh(u8); +bool8 MetatileBehavior_IsAshGrass(u8); bool8 MetatileBehavior_IsUnusedFootprintMetatile(u8); bool8 MetatileBehavior_IsBridge(u8); u8 MetatileBehavior_GetBridgeSth(u8); diff --git a/include/party_menu.h b/include/party_menu.h index c96eb0d9d..2cf17f1e4 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -28,7 +28,7 @@ void DoWallyTutorialBagMenu(void); u8 pokemon_ailments_get_primary(u32 status); u8 *GetMonNickname(struct Pokemon *mon, u8 *dst); u8 GetCursorSelectionMonId(void); -bool8 FieldCallback_Teleport(void); +bool8 FieldCallback_PrepareFadeInFromMenu(void); void sub_81B7F60(void); void sub_81B0FCC(u8 partyIdx, u8 a); diff --git a/include/rom6.h b/include/rom6.h index 058504fe2..96c3b3ca2 100644 --- a/include/rom6.h +++ b/include/rom6.h @@ -12,7 +12,7 @@ void UpdateFrontierManiac(u16 days); void UpdateFrontierGambler(u16 days); void SetShoalItemFlag(u16 days); -bool8 npc_before_player_of_type(u8); +bool8 CheckObjectGraphicsInFrontOfPlayer(u8); u8 oei_task_add(void); #endif //GUARD_ROM6_H diff --git a/ld_script.txt b/ld_script.txt index 566059e20..6d5e31a25 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -128,7 +128,7 @@ SECTIONS { asm/pokemon_storage_system.o(.text); src/pokemon_icon.o(.text); src/script_movement.o(.text); - asm/fldeff_cut.o(.text); + src/fldeff_cut.o(.text); src/mail_data.o(.text); src/map_name_popup.o(.text); src/item_menu_icons.o(.text); @@ -425,7 +425,7 @@ SECTIONS { src/pokemon_storage_system.o(.rodata); data/pokemon_storage_system.o(.rodata); src/pokemon_icon.o(.rodata); - data/fldeff_cut.o(.rodata); + src/fldeff_cut.o(.rodata); src/map_name_popup.o(.rodata); src/item_menu_icons.o(.rodata); data/contest.o(.rodata); diff --git a/src/data/field_event_obj/event_object_graphics.h b/src/data/field_event_obj/event_object_graphics.h index 3d4303189..b226b066a 100755 --- a/src/data/field_event_obj/event_object_graphics.h +++ b/src/data/field_event_obj/event_object_graphics.h @@ -1376,7 +1376,9 @@ const u32 gFieldEffectObjectPic_ShadowSmall[] = INCBIN_U32("graphics/event_objec const u32 gFieldEffectObjectPic_ShadowMedium[] = INCBIN_U32("graphics/event_objects/pics/effects/shadow_medium.4bpp"); const u32 gFieldEffectObjectPic_ShadowLarge[] = INCBIN_U32("graphics/event_objects/pics/effects/shadow_large.4bpp"); const u32 gFieldEffectObjectPic_ShadowExtraLarge[] = INCBIN_U32("graphics/event_objects/pics/effects/shadow_extra_large.4bpp"); -const u32 gUnknown_084F6D38[] = INCBIN_U32("graphics/event_objects/pics/effects/unknown_4F6D38/0.4bpp"); +const u32 filler_8368A08[0x48] = {}; +const u8 gFieldEffectPic_CutGrass[] = INCBIN_U8("graphics/event_objects/pics/effects/cut_grass.4bpp"); +const u32 gFieldEffectPic_CutGrass_Copy[] = INCBIN_U32("graphics/event_objects/pics/effects/cut_grass.4bpp"); const u16 gFieldEffectObjectPalette6[] = INCBIN_U16("graphics/event_objects/palettes/field_effect_object_palette_06.gbapal"); const u32 gFieldEffectObjectPic_Ripple_0[] = INCBIN_U32("graphics/event_objects/pics/effects/ripple/0.4bpp"); const u32 gFieldEffectObjectPic_Ripple_1[] = INCBIN_U32("graphics/event_objects/pics/effects/ripple/1.4bpp"); diff --git a/src/event_obj_lock.c b/src/event_obj_lock.c index efa498c0f..8c324ea82 100644 --- a/src/event_obj_lock.c +++ b/src/event_obj_lock.c @@ -87,7 +87,7 @@ void LockSelectedEventObject(void) } } -void sub_80984F4(void) +void ScriptUnfreezeEventObjects(void) { u8 objectId = GetEventObjectIdByLocalIdAndMap(0xFF, 0, 0); EventObjectClearHeldMovementIfFinished(&gEventObjects[objectId]); diff --git a/src/field_effect.c b/src/field_effect.c index 00814192e..f047c78a3 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -561,7 +561,7 @@ u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y) PreservePaletteInWeather(IndexOfSpritePaletteTag(gMonPaletteTable[species].tag) + 0x10); if (spriteId == 0xFFFF) return 0x40; - + return spriteId; } #else @@ -623,7 +623,7 @@ u8 CreateMonSprite_FieldMove(u16 species, u32 d, u32 g, s16 x, s16 y, u8 subprio PreservePaletteInWeather(IndexOfSpritePaletteTag(spritePalette->tag) + 0x10); if (spriteId == 0xFFFF) return 0x40; - + return spriteId; } diff --git a/src/field_tasks.c b/src/field_tasks.c index 3cc40ac9d..fc57585e5 100644 --- a/src/field_tasks.c +++ b/src/field_tasks.c @@ -623,7 +623,7 @@ static void PerStepCallback_8069F64(u8 taskId) { data[1] = x; data[2] = y; - if (MetatileBehavior_IsAsh(MapGridGetMetatileBehaviorAt(x, y))) + if (MetatileBehavior_IsAshGrass(MapGridGetMetatileBehaviorAt(x, y))) { if (MapGridGetMetatileIdAt(x, y) == 0x20a) { diff --git a/src/fldeff_cut.c b/src/fldeff_cut.c index 9929dd6f9..9de954e80 100644 --- a/src/fldeff_cut.c +++ b/src/fldeff_cut.c @@ -1,19 +1,683 @@ - -// Includes #include "global.h" +#include "fldeff_cut.h" +#include "field_camera.h" +#include "field_effect.h" +#include "event_object_movement.h" +#include "field_player_avatar.h" +#include "fieldmap.h" +#include "event_obj_lock.h" +#include "metatile_behavior.h" +#include "party_menu.h" +#include "overworld.h" +#include "script.h" +#include "sound.h" +#include "sprite.h" +#include "task.h" +#include "trig.h" +#include "malloc.h" +#include "constants/event_objects.h" +#include "constants/songs.h" +#include "constants/abilities.h" -// Static type declarations +extern bool8 CheckObjectGraphicsInFrontOfPlayer(u8); +extern u8 oei_task_add(void); +extern void ScriptUnfreezeEventObjects(void); +extern bool8 IsMewPlayingHideAndSeek(void); -// Static RAM declarations +extern struct MapPosition gPlayerFacingPosition; -IWRAM_DATA u8 gUnknown_03001100; -IWRAM_DATA u8 gUnknown_03001101; -IWRAM_DATA u8 gUnknown_03001102; -IWRAM_DATA u32 fldeff_cut_unused_03001104; -IWRAM_DATA u8 gUnknown_03001108[25]; +extern const u8 Route103_EventScript_290705[]; +extern const u8 FarawayIsland_Interior_EventScript_267EDB[]; -// Static ROM declarations +extern const u8 gFieldEffectPic_CutGrass[]; +extern const u16 gFieldEffectObjectPalette6[]; -// .rodata +// tileset 0 as first +#define METATILE_ID_GRASS 0x1 +#define METATILE_ID_POKE_GRASS 0xD -// .text +#define METATILE_ID_POKE_GRASS_TREE_UP 0x25 +#define METATILE_ID_GRASS_TREE_UP 0xE + +#define METATILE_ID_POKE_GRASS_TREE_LEFT 0x1C6 +#define METATILE_ID_POKE_GRASS_TREE_RIGHT 0x1C7 + +#define METATILE_ID_GRASS_TREE_LEFT 0x1CE +#define METATILE_ID_GRASS_TREE_RIGHT 0x1CF + +#define METATILE_ID_POKE_LONG_GRASS 0x15 + +// tileset 6 as second +#define METATILE_ID_POKE_STEP_LAVA_GRASS 0x206 +#define METATILE_ID_POKE_LAVA_GRASS 0x207 +#define METATILE_ID_LAVA_FIELD 0x271 + +// tileset 7 as second +#define METATILE_ID_POKE_ASH_GRASS 0x20A +#define METATILE_ID_POKE_STEP_ASH_GRASS 0x212 +#define METATILE_ID_ASH 0x218 + +// tileset 8 as second +#define METATILE_ID_POKE_LONG_GRASS_START 0x208 + +#define METATILE_ID_SECRET_BASE_LEFT_LONG_GRASS 0x279 +#define METATILE_ID_SECRET_BASE_CENTER_LONG_GRASS 0x27A +#define METATILE_ID_SECRET_BASE_RIGHT_LONG_GRASS 0x27B + +#define METATILE_ID_SECRET_BASE_LEFT_POKE_LONG_GRASS 0x281 +#define METATILE_ID_SECRET_BASE_CENTER_POKE_LONG_GRASS 0x282 +#define METATILE_ID_SECRET_BASE_RIGHT_POKE_LONG_GRASS 0x283 + +// cut 'square' defines +#define CUT_NORMAL_SIDE 3 +#define CUT_NORMAL_AREA CUT_NORMAL_SIDE * CUT_NORMAL_SIDE + +#define CUT_HYPER_SIDE 5 +#define CUT_HYPER_AREA CUT_HYPER_SIDE * CUT_HYPER_SIDE + +#define CUT_SPRITE_ARRAY_COUNT 8 + +struct HyperCutterUnk +{ + s8 x; + s8 y; + u8 unk2[2]; +}; + +// this file's functions +static void FieldCallback_CutTree(void); +static void FieldCallback_CutGrass(void); +static void StartCutTreeFieldEffect(void); +static void StartCutGrassFieldEffect(void); +static void SetCutGrassMetatile(s16, s16); +static void SetCutGrassMetatiles(s16, s16); +static void CutGrassSpriteCallback1(struct Sprite *); +static void CutGrassSpriteCallback2(struct Sprite *); +static void CutGrassSpriteCallbackEnd(struct Sprite *); +static void HandleLongGrassOnHyper(u8, s16, s16); + +// IWRAM variables +static IWRAM_DATA u8 sCutSquareSide; +static IWRAM_DATA u8 sTileCountFromPlayer_X; +static IWRAM_DATA u8 sTileCountFromPlayer_Y; +static IWRAM_DATA u32 sUnused; +static IWRAM_DATA bool8 sHyperCutTiles[CUT_HYPER_AREA]; + +// EWRAM variables +static EWRAM_DATA u8 *sCutGrassSpriteArrayPtr = NULL; + +// const rom data +static const struct HyperCutterUnk sHyperCutStruct[] = +{ + {-2, -2, {1}}, + {-1, -2, {1}}, + {0, -2, {2}}, + {1, -2, {3}}, + {2, -2, {3}}, + {-2, -1, {1}}, + {2, -1, {3}}, + {-2, 0, {4}}, + {2, 0, {6}}, + {-2, 1, {7}}, + {2, 1, {9}}, + {-2, 2, {7}}, + {-1, 2, {7}}, + {0, 2, {8}}, + {1, 2, {9}}, + {2, 2, {9}}, +}; + +static const struct OamData sOamData_CutGrass = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 0, + .tileNum = 1, + .priority = 1, + .paletteNum = 1, + .affineParam = 0, +}; + +static const union AnimCmd sSpriteAnim_CutGrass[] = +{ + ANIMCMD_FRAME(0, 30), + ANIMCMD_JUMP(0), +}; + +static const union AnimCmd *const sSpriteAnimTable_CutGrass[] = +{ + sSpriteAnim_CutGrass, +}; + +static const struct SpriteFrameImage sSpriteImageTable_CutGrass[] = +{ + {gFieldEffectPic_CutGrass, 0x20}, +}; + +const struct SpritePalette gFieldEffectObjectPaletteInfo6 = {gFieldEffectObjectPalette6, 0x1000}; + +static const struct SpriteTemplate sSpriteTemplate_CutGrass = +{ + .tileTag = 0xFFFF, + .paletteTag = 0x1000, + .oam = &sOamData_CutGrass, + .anims = sSpriteAnimTable_CutGrass, + .images = sSpriteImageTable_CutGrass, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = CutGrassSpriteCallback1, +}; + +// code +bool8 SetUpFieldMove_Cut(void) +{ + s16 x, y; + u8 i, j; + u8 tileBehavior; + u8 userAbility; + bool8 cutTiles[CUT_NORMAL_AREA]; + bool8 ret; + + if (CheckObjectGraphicsInFrontOfPlayer(EVENT_OBJ_GFX_CUTTABLE_TREE) == TRUE) + { + // Standing in front of cuttable tree. + gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; + gPostMenuFieldCallback = FieldCallback_CutTree; + return TRUE; + } + else + { + PlayerGetDestCoords(&gPlayerFacingPosition.x, &gPlayerFacingPosition.y); + userAbility = GetMonAbility(&gPlayerParty[GetCursorSelectionMonId()]); + if (userAbility == ABILITY_HYPER_CUTTER) + { + sCutSquareSide = CUT_HYPER_SIDE; + sTileCountFromPlayer_X = 2; + sTileCountFromPlayer_Y = 2; + } + else + { + sCutSquareSide = CUT_NORMAL_SIDE; + sTileCountFromPlayer_X = 1; + sTileCountFromPlayer_Y = 1; + } + + for (i = 0; i < CUT_NORMAL_AREA; i++) + cutTiles[i] = FALSE; + for (i = 0; i < CUT_HYPER_AREA; i++) + sHyperCutTiles[i] = FALSE; + + ret = FALSE; + + for (i = 0; i < CUT_NORMAL_SIDE; i++) + { + y = i - 1 + gPlayerFacingPosition.y; + for (j = 0; j < CUT_NORMAL_SIDE; j++) + { + x = j - 1 + gPlayerFacingPosition.x; + if (MapGridGetZCoordAt(x, y) == gPlayerFacingPosition.height) + { + tileBehavior = MapGridGetMetatileBehaviorAt(x, y); + if (MetatileBehavior_IsPokeGrass(tileBehavior) == TRUE + || MetatileBehavior_IsAshGrass(tileBehavior) == TRUE) + { + // Standing in front of grass. + sHyperCutTiles[6 + (i * 5) + j] = TRUE; + ret = TRUE; + } + if (MapGridIsImpassableAt(x, y) == TRUE) + { + cutTiles[i * 3 + j] = FALSE; + } + else + { + cutTiles[i * 3 + j] = TRUE; + if (MetatileBehavior_IsCuttableGrass(tileBehavior) == TRUE) + sHyperCutTiles[6 + (i * 5) + j] = TRUE; + } + } + else + { + cutTiles[i * 3 + j] = FALSE; + } + } + } + + if (userAbility != ABILITY_HYPER_CUTTER) + { + if (ret == TRUE) + { + gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; + gPostMenuFieldCallback = FieldCallback_CutGrass; + } + } + else + { + bool8 tileCuttable; + for (i = 0; i < 16; i++) + { + x = gPlayerFacingPosition.x + sHyperCutStruct[i].x; + y = gPlayerFacingPosition.y + sHyperCutStruct[i].y; + tileCuttable = TRUE; + + j = 0; + do + { + if (sHyperCutStruct[i].unk2[j] == 0) + break; + if (cutTiles[(u8)(sHyperCutStruct[i].unk2[j] - 1)] == FALSE) + { + tileCuttable = FALSE; + break; + } + } while (++j <= 1); + + if (tileCuttable == TRUE) + { + if (MapGridGetZCoordAt(x, y) == gPlayerFacingPosition.height) + { + u8 tileArrayId = ((sHyperCutStruct[i].y * 5) + 12) + (sHyperCutStruct[i].x); + tileBehavior = MapGridGetMetatileBehaviorAt(x, y); + if (MetatileBehavior_IsPokeGrass(tileBehavior) == TRUE + || MetatileBehavior_IsAshGrass(tileBehavior) == TRUE) + { + gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; + gPostMenuFieldCallback = FieldCallback_CutGrass; + sHyperCutTiles[tileArrayId] = TRUE; + ret = TRUE; + } + else + { + if (MetatileBehavior_IsCuttableGrass(tileBehavior) == TRUE) + sHyperCutTiles[tileArrayId] = TRUE; + } + } + } + } + + if (ret == TRUE) + { + gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; + gPostMenuFieldCallback = FieldCallback_CutGrass; + } + } + + return ret; + } +} + +static void FieldCallback_CutGrass(void) +{ + FieldEffectStart(FLDEFF_USE_CUT_ON_GRASS); + gFieldEffectArguments[0] = GetCursorSelectionMonId(); +} + +bool8 FldEff_UseCutOnGrass(void) +{ + u8 taskId = oei_task_add(); + + gTasks[taskId].data[8] = (u32)StartCutGrassFieldEffect >> 16; + gTasks[taskId].data[9] = (u32)StartCutGrassFieldEffect; + IncrementGameStat(GAME_STAT_USED_CUT); + return FALSE; +} + +static void FieldCallback_CutTree(void) +{ + gFieldEffectArguments[0] = GetCursorSelectionMonId(); + ScriptContext1_SetupScript(Route103_EventScript_290705); +} + +bool8 FldEff_UseCutOnTree(void) +{ + u8 taskId = oei_task_add(); + + gTasks[taskId].data[8] = (u32)StartCutTreeFieldEffect >> 16; + gTasks[taskId].data[9] = (u32)StartCutTreeFieldEffect; + IncrementGameStat(GAME_STAT_USED_CUT); + return FALSE; +} + +static void StartCutGrassFieldEffect(void) +{ + FieldEffectActiveListRemove(FLDEFF_USE_CUT_ON_GRASS); + FieldEffectStart(FLDEFF_CUT_GRASS); +} + +bool8 FldEff_CutGrass(void) +{ + s16 x, y; + u8 i = 0; + + PlaySE(SE_W015); + PlayerGetDestCoords(&gPlayerFacingPosition.x, &gPlayerFacingPosition.y); + for (i = 0; i < CUT_HYPER_AREA; i++) + { + if (sHyperCutTiles[i] == TRUE) + { + s8 xAdd = (i % 5) - 2; + s8 yAdd = (i / 5) - 2; + + x = xAdd + gPlayerFacingPosition.x; + y = yAdd + gPlayerFacingPosition.y; + + SetCutGrassMetatile(x, y); + sub_808E75C(x, y); + } + } + + SetCutGrassMetatiles(gPlayerFacingPosition.x - sTileCountFromPlayer_X, gPlayerFacingPosition.y - (1 + sTileCountFromPlayer_Y)); + DrawWholeMapView(); + sCutGrassSpriteArrayPtr = AllocZeroed(CUT_SPRITE_ARRAY_COUNT); + + // populate sprite ID array + for (i = 0; i < CUT_SPRITE_ARRAY_COUNT; i++) + { + sCutGrassSpriteArrayPtr[i] = CreateSprite(&sSpriteTemplate_CutGrass, + gSprites[gPlayerAvatar.spriteId].oam.x + 8, gSprites[gPlayerAvatar.spriteId].oam.y + 20, 0); + gSprites[sCutGrassSpriteArrayPtr[i]].data[2] = 32 * i; + } + + return FALSE; +} + +// set map grid metatile depending on x, y +static void SetCutGrassMetatile(s16 x, s16 y) +{ + s32 metatileId = MapGridGetMetatileIdAt(x, y); + + switch (metatileId) + { + case METATILE_ID_POKE_LONG_GRASS_START: + case METATILE_ID_POKE_LONG_GRASS: + case METATILE_ID_POKE_GRASS: + MapGridSetMetatileIdAt(x, y, METATILE_ID_GRASS); + break; + case METATILE_ID_POKE_GRASS_TREE_LEFT: + MapGridSetMetatileIdAt(x, y, METATILE_ID_GRASS_TREE_LEFT); + break; + case METATILE_ID_POKE_GRASS_TREE_RIGHT: + MapGridSetMetatileIdAt(x, y, METATILE_ID_GRASS_TREE_RIGHT); + break; + case METATILE_ID_SECRET_BASE_LEFT_POKE_LONG_GRASS: + MapGridSetMetatileIdAt(x, y, METATILE_ID_SECRET_BASE_LEFT_LONG_GRASS); + break; + case METATILE_ID_SECRET_BASE_CENTER_POKE_LONG_GRASS: + MapGridSetMetatileIdAt(x, y, METATILE_ID_SECRET_BASE_CENTER_LONG_GRASS); + break; + case METATILE_ID_SECRET_BASE_RIGHT_POKE_LONG_GRASS: + MapGridSetMetatileIdAt(x, y, METATILE_ID_SECRET_BASE_RIGHT_LONG_GRASS); + break; + case METATILE_ID_POKE_STEP_LAVA_GRASS: + case METATILE_ID_POKE_LAVA_GRASS: + MapGridSetMetatileIdAt(x, y, METATILE_ID_LAVA_FIELD); + break; + case METATILE_ID_POKE_STEP_ASH_GRASS: + case METATILE_ID_POKE_ASH_GRASS: + MapGridSetMetatileIdAt(x, y, METATILE_ID_ASH); + break; + case METATILE_ID_POKE_GRASS_TREE_UP: + MapGridSetMetatileIdAt(x, y, METATILE_ID_GRASS_TREE_UP); + break; + } +} + +enum +{ + LONG_GRASS_NONE, + LONG_GRASS_FIELD, + LONG_GRASS_BASE_LEFT, + LONG_GRASS_BASE_CENTER, + LONG_GRASS_BASE_RIGHT +}; + +static u8 GetLongGrassCaseAt(s16 x, s16 y) +{ + u16 metatileId = MapGridGetMetatileIdAt(x, y); + + if (metatileId == METATILE_ID_GRASS) + return LONG_GRASS_FIELD; + else if (metatileId == METATILE_ID_SECRET_BASE_LEFT_LONG_GRASS) + return LONG_GRASS_BASE_LEFT; + else if (metatileId == METATILE_ID_SECRET_BASE_CENTER_LONG_GRASS) + return LONG_GRASS_BASE_CENTER; + else if (metatileId == METATILE_ID_SECRET_BASE_RIGHT_LONG_GRASS) + return LONG_GRASS_BASE_RIGHT; + else + return LONG_GRASS_NONE; +} + +static void SetCutGrassMetatiles(s16 x, s16 y) +{ + s16 i; + s16 lowerY = y + sCutSquareSide; + + for (i = 0; i < sCutSquareSide; i++) + { + s16 currentX = x + i; + if (MapGridGetMetatileIdAt(currentX, y) == METATILE_ID_POKE_LONG_GRASS) + { + switch (GetLongGrassCaseAt(currentX, y + 1)) + { + case LONG_GRASS_FIELD: + MapGridSetMetatileIdAt(currentX, y + 1, METATILE_ID_POKE_LONG_GRASS_START); + break; + case LONG_GRASS_BASE_LEFT: + MapGridSetMetatileIdAt(currentX, y + 1, METATILE_ID_SECRET_BASE_LEFT_POKE_LONG_GRASS); + break; + case LONG_GRASS_BASE_CENTER: + MapGridSetMetatileIdAt(currentX, y + 1, METATILE_ID_SECRET_BASE_CENTER_POKE_LONG_GRASS); + break; + case LONG_GRASS_BASE_RIGHT: + MapGridSetMetatileIdAt(currentX, y + 1, METATILE_ID_SECRET_BASE_RIGHT_POKE_LONG_GRASS); + break; + } + } + if (MapGridGetMetatileIdAt(currentX, lowerY) == METATILE_ID_GRASS) + { + if (MapGridGetMetatileIdAt(currentX, lowerY + 1) == METATILE_ID_POKE_LONG_GRASS_START) + MapGridSetMetatileIdAt(currentX, lowerY + 1, METATILE_ID_GRASS); + if (MapGridGetMetatileIdAt(currentX, lowerY + 1) == METATILE_ID_SECRET_BASE_LEFT_POKE_LONG_GRASS) + MapGridSetMetatileIdAt(currentX, lowerY + 1, METATILE_ID_SECRET_BASE_LEFT_LONG_GRASS); + if (MapGridGetMetatileIdAt(currentX, lowerY + 1) == METATILE_ID_SECRET_BASE_CENTER_POKE_LONG_GRASS) + MapGridSetMetatileIdAt(currentX, lowerY + 1, METATILE_ID_SECRET_BASE_CENTER_LONG_GRASS); + if (MapGridGetMetatileIdAt(currentX, lowerY + 1) == METATILE_ID_SECRET_BASE_RIGHT_POKE_LONG_GRASS) + MapGridSetMetatileIdAt(currentX, lowerY + 1, METATILE_ID_SECRET_BASE_RIGHT_LONG_GRASS); + } + } + + if (sCutSquareSide == CUT_HYPER_SIDE) + { + HandleLongGrassOnHyper(0, x, y); + HandleLongGrassOnHyper(1, x, y); + } +} + +static void HandleLongGrassOnHyper(u8 caseId, s16 x, s16 y) +{ + s16 newX; + bool8 arr[3]; + + if (caseId == 0) + { + arr[0] = sHyperCutTiles[5]; + arr[1] = sHyperCutTiles[10]; + arr[2] = sHyperCutTiles[15]; + newX = x; + } + else if (caseId == 1) + { + arr[0] = sHyperCutTiles[9]; + arr[1] = sHyperCutTiles[14]; + arr[2] = sHyperCutTiles[19]; + newX = x + 4; + } + else // invalid case + { + return; + } + + if (arr[0] == TRUE) + { + if (MapGridGetMetatileIdAt(newX, y + 3) == METATILE_ID_POKE_LONG_GRASS_START) + MapGridSetMetatileIdAt(newX, y + 3, METATILE_ID_GRASS); + if (MapGridGetMetatileIdAt(newX, y + 3) == METATILE_ID_SECRET_BASE_LEFT_POKE_LONG_GRASS) + MapGridSetMetatileIdAt(newX, y + 3, METATILE_ID_SECRET_BASE_LEFT_LONG_GRASS); + if (MapGridGetMetatileIdAt(newX, y + 3) == METATILE_ID_SECRET_BASE_CENTER_POKE_LONG_GRASS) + MapGridSetMetatileIdAt(newX, y + 3, METATILE_ID_SECRET_BASE_CENTER_LONG_GRASS); + if (MapGridGetMetatileIdAt(newX, y + 3) == METATILE_ID_SECRET_BASE_RIGHT_POKE_LONG_GRASS) + MapGridSetMetatileIdAt(newX, y + 3, METATILE_ID_SECRET_BASE_RIGHT_LONG_GRASS); + } + if (arr[1] == TRUE) + { + if (MapGridGetMetatileIdAt(newX, y + 2) == METATILE_ID_POKE_LONG_GRASS) + { + switch (GetLongGrassCaseAt(newX, y + 3)) + { + case LONG_GRASS_FIELD: + MapGridSetMetatileIdAt(newX, y + 3, METATILE_ID_POKE_LONG_GRASS_START); + break; + case LONG_GRASS_BASE_LEFT: + MapGridSetMetatileIdAt(newX, y + 3, METATILE_ID_SECRET_BASE_LEFT_POKE_LONG_GRASS); + break; + case LONG_GRASS_BASE_CENTER: + MapGridSetMetatileIdAt(newX, y + 3, METATILE_ID_SECRET_BASE_CENTER_POKE_LONG_GRASS); + break; + case LONG_GRASS_BASE_RIGHT: + MapGridSetMetatileIdAt(newX, y + 3, METATILE_ID_SECRET_BASE_RIGHT_POKE_LONG_GRASS); + break; + } + } + + if (MapGridGetMetatileIdAt(newX, y + 4) == METATILE_ID_POKE_LONG_GRASS_START) + MapGridSetMetatileIdAt(newX, y + 4, METATILE_ID_GRASS); + if (MapGridGetMetatileIdAt(newX, y + 4) == METATILE_ID_SECRET_BASE_LEFT_POKE_LONG_GRASS) + MapGridSetMetatileIdAt(newX, y + 4, METATILE_ID_SECRET_BASE_LEFT_LONG_GRASS); + if (MapGridGetMetatileIdAt(newX, y + 4) == METATILE_ID_SECRET_BASE_CENTER_POKE_LONG_GRASS) + MapGridSetMetatileIdAt(newX, y + 4, METATILE_ID_SECRET_BASE_CENTER_LONG_GRASS); + if (MapGridGetMetatileIdAt(newX, y + 4) == METATILE_ID_SECRET_BASE_RIGHT_POKE_LONG_GRASS) + MapGridSetMetatileIdAt(newX, y + 4, METATILE_ID_SECRET_BASE_RIGHT_LONG_GRASS); + } + if (arr[2] == TRUE) + { + if (MapGridGetMetatileIdAt(newX, y + 3) == METATILE_ID_POKE_LONG_GRASS) + { + switch (GetLongGrassCaseAt(newX, y + 4)) + { + case LONG_GRASS_FIELD: + MapGridSetMetatileIdAt(newX, y + 4, METATILE_ID_POKE_LONG_GRASS_START); + break; + case LONG_GRASS_BASE_LEFT: + MapGridSetMetatileIdAt(newX, y + 4, METATILE_ID_SECRET_BASE_LEFT_POKE_LONG_GRASS); + break; + case LONG_GRASS_BASE_CENTER: + MapGridSetMetatileIdAt(newX, y + 4, METATILE_ID_SECRET_BASE_CENTER_POKE_LONG_GRASS); + break; + case LONG_GRASS_BASE_RIGHT: + MapGridSetMetatileIdAt(newX, y + 4, METATILE_ID_SECRET_BASE_RIGHT_POKE_LONG_GRASS); + break; + } + } + } +} + +static void CutGrassSpriteCallback1(struct Sprite *sprite) +{ + sprite->data[0] = 8; + sprite->data[1] = 0; + sprite->data[3] = 0; + sprite->callback = CutGrassSpriteCallback2; +} + +static void CutGrassSpriteCallback2(struct Sprite *sprite) +{ + sprite->pos2.x = Sin(sprite->data[2], sprite->data[0]); + sprite->pos2.y = Cos(sprite->data[2], sprite->data[0]); + + sprite->data[2] = (sprite->data[2] + 8) & 0xFF; + sprite->data[0] += 1 + (sprite->data[3] >> 2); // right shift by 2 is dividing by 4 + sprite->data[3]++; + + if (sprite->data[1] != 28) + sprite->data[1]++; + else + sprite->callback = CutGrassSpriteCallbackEnd; // done rotating the grass, execute clean up function +} + +static void CutGrassSpriteCallbackEnd(struct Sprite *sprite) +{ + u8 i; + + for (i = 1; i < CUT_SPRITE_ARRAY_COUNT; i++) + DestroySprite(&gSprites[sCutGrassSpriteArrayPtr[i]]); + + FieldEffectStop(&gSprites[sCutGrassSpriteArrayPtr[0]], FLDEFF_CUT_GRASS); + FREE_AND_SET_NULL(sCutGrassSpriteArrayPtr); + ScriptUnfreezeEventObjects(); + ScriptContext2_Disable(); + + if (IsMewPlayingHideAndSeek() == TRUE) + ScriptContext1_SetupScript(FarawayIsland_Interior_EventScript_267EDB); +} + +void sub_80D423C(s16 x, s16 y) +{ + u8 metatileBehavior = MapGridGetMetatileBehaviorAt(x, y); + if (MetatileBehavior_IsLongGrass_Duplicate(metatileBehavior)) + { + switch (GetLongGrassCaseAt(x, y + 1)) + { + case LONG_GRASS_FIELD: + MapGridSetMetatileIdAt(x, y + 1, METATILE_ID_POKE_LONG_GRASS_START); + break; + case LONG_GRASS_BASE_LEFT: + MapGridSetMetatileIdAt(x, y + 1, METATILE_ID_SECRET_BASE_LEFT_POKE_LONG_GRASS); + break; + case LONG_GRASS_BASE_CENTER: + MapGridSetMetatileIdAt(x, y + 1, METATILE_ID_SECRET_BASE_CENTER_POKE_LONG_GRASS); + break; + case LONG_GRASS_BASE_RIGHT: + MapGridSetMetatileIdAt(x, y + 1, METATILE_ID_SECRET_BASE_RIGHT_POKE_LONG_GRASS); + break; + } + } +} + +void sub_80D42B8(s16 x, s16 y) +{ + if (MapGridGetMetatileIdAt(x, y) == METATILE_ID_GRASS) + { + u8 metatileBehavior = MapGridGetMetatileBehaviorAt(x, y + 1); + if (MetatileBehavior_IsLongGrassSouthEdge(metatileBehavior)) + { + s32 metatileId = MapGridGetMetatileIdAt(x, y + 1); + switch (metatileId) + { + case METATILE_ID_POKE_LONG_GRASS_START: + MapGridSetMetatileIdAt(x, y + 1, METATILE_ID_GRASS); + break; + case METATILE_ID_SECRET_BASE_LEFT_POKE_LONG_GRASS: + MapGridSetMetatileIdAt(x, y + 1, METATILE_ID_SECRET_BASE_LEFT_LONG_GRASS); + break; + case METATILE_ID_SECRET_BASE_CENTER_POKE_LONG_GRASS: + MapGridSetMetatileIdAt(x, y + 1, METATILE_ID_SECRET_BASE_CENTER_LONG_GRASS); + break; + case METATILE_ID_SECRET_BASE_RIGHT_POKE_LONG_GRASS: + MapGridSetMetatileIdAt(x, y + 1, METATILE_ID_SECRET_BASE_RIGHT_LONG_GRASS); + break; + } + } + } +} + +static void StartCutTreeFieldEffect(void) +{ + PlaySE(SE_W015); + FieldEffectActiveListRemove(FLDEFF_USE_CUT_ON_TREE); + EnableBothScriptContexts(); +} diff --git a/src/fldeff_flash.c b/src/fldeff_flash.c index 4f3a091ce..654f02c23 100644 --- a/src/fldeff_flash.c +++ b/src/fldeff_flash.c @@ -78,14 +78,14 @@ bool8 SetUpFieldMove_Flash(void) if (ShouldDoBrailleFlyEffect()) { gSpecialVar_Result = GetCursorSelectionMonId(); - gUnknown_03005DB0 = FieldCallback_Teleport; - gUnknown_0203CEEC = sub_8179918; + gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; + gPostMenuFieldCallback = sub_8179918; return TRUE; } else if (gMapHeader.cave == TRUE && !FlagGet(FLAG_SYS_USE_FLASH)) { - gUnknown_03005DB0 = FieldCallback_Teleport; - gUnknown_0203CEEC = hm2_flash; + gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; + gPostMenuFieldCallback = hm2_flash; return TRUE; } diff --git a/src/fldeff_strength.c b/src/fldeff_strength.c index 162479c73..74eb100bc 100644 --- a/src/fldeff_strength.c +++ b/src/fldeff_strength.c @@ -6,6 +6,7 @@ #include "rom6.h" #include "script.h" #include "task.h" +#include "constants/event_objects.h" // static functions static void FldEff_UseStrength(void); @@ -14,11 +15,11 @@ static void sub_8145E74(void); // text bool8 SetUpFieldMove_Strength(void) { - if (npc_before_player_of_type(87) == TRUE) + if (CheckObjectGraphicsInFrontOfPlayer(EVENT_OBJ_GFX_PUSHABLE_BOULDER) == TRUE) { gSpecialVar_Result = GetCursorSelectionMonId(); - gUnknown_03005DB0 = FieldCallback_Teleport; - gUnknown_0203CEEC = FldEff_UseStrength; + gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; + gPostMenuFieldCallback = FldEff_UseStrength; return TRUE; } return FALSE; diff --git a/src/fldeff_sweetscent.c b/src/fldeff_sweetscent.c index 100e440a5..14da87eb3 100644 --- a/src/fldeff_sweetscent.c +++ b/src/fldeff_sweetscent.c @@ -24,8 +24,8 @@ void sub_81BE72C(void); bool8 SetUpFieldMove_SweetScent(void) { - gUnknown_03005DB0 = FieldCallback_Teleport; - gUnknown_0203CEEC = hm2_sweet_scent; + gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; + gPostMenuFieldCallback = hm2_sweet_scent; return TRUE; } diff --git a/src/fldeff_teleport.c b/src/fldeff_teleport.c index 1b88b42d7..e82a26cd1 100644 --- a/src/fldeff_teleport.c +++ b/src/fldeff_teleport.c @@ -11,8 +11,8 @@ bool8 SetUpFieldMove_Teleport(void) { if (Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE) { - gUnknown_03005DB0 = FieldCallback_Teleport; - gUnknown_0203CEEC = hm_teleport_run_dp02scr; + gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; + gPostMenuFieldCallback = hm_teleport_run_dp02scr; return TRUE; } return FALSE; diff --git a/src/item_use.c b/src/item_use.c index f3cb58069..6bdfe1c54 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -39,7 +39,7 @@ extern void sub_81C5B14(u8 taskId); extern u8 gText_DadsAdvice[]; extern u8 gText_CantDismountBike[]; extern void sub_8197434(u8 a, u8 b); -extern void sub_80984F4(void); +extern void ScriptUnfreezeEventObjects(void); extern void ItemUseOutOfBattle_TMHM(u8 a); extern void ItemUseOutOfBattle_EvolutionStone(u8 b); extern void bag_menu_mail_related(void); @@ -197,7 +197,7 @@ void CleanUpAfterFailingToUseRegisteredKeyItemOnField(u8 taskId) { sub_8197434(0, 1); DestroyTask(taskId); - sub_80984F4(); + ScriptUnfreezeEventObjects(); ScriptContext2_Disable(); } @@ -252,7 +252,7 @@ void ItemUseOnFieldCB_Bike(u8 taskId) GetOnOffBike(2); else GetOnOffBike(4); - sub_80984F4(); + ScriptUnfreezeEventObjects(); ScriptContext2_Disable(); DestroyTask(taskId); } @@ -358,7 +358,7 @@ void sub_80FD504(u8 taskId) void sub_80FD5CC(u8 taskId) { sub_8197434(0, 1); - sub_80984F4(); + ScriptUnfreezeEventObjects(); ScriptContext2_Disable(); DestroyTask(taskId); } diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index ad0062c20..a5e328e4a 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -846,7 +846,7 @@ bool8 MetatileBehavior_IsBerryTreeSoil(u8 var) return FALSE; } -bool8 MetatileBehavior_IsAsh(u8 var) +bool8 MetatileBehavior_IsAshGrass(u8 var) { if (var == MB_ASHGRASS) return TRUE; diff --git a/src/overworld.c b/src/overworld.c index 657ffd86a..d4cb25e6c 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -88,7 +88,7 @@ extern const u16 gUnknown_82EC7C4[]; u16 gUnknown_03005DA8; MainCallback gFieldCallback; -bool8 (*gUnknown_03005DB0)(void); +bool8 (*gFieldCallback2)(void); u8 gUnknown_03005DB4; u8 gFieldLinkPlayerCount; @@ -1518,15 +1518,15 @@ void sub_8085E94(void *a0) static bool8 map_post_load_hook_exec(void) { - if (gUnknown_03005DB0 != NULL) + if (gFieldCallback2 != NULL) { - if (!gUnknown_03005DB0()) + if (!gFieldCallback2()) { return FALSE; } else { - gUnknown_03005DB0 = NULL; + gFieldCallback2 = NULL; gFieldCallback = NULL; } } @@ -1554,7 +1554,7 @@ void CB2_NewGame(void) ScriptContext1_Init(); ScriptContext2_Disable(); gFieldCallback = ExecuteTruckSequence; - gUnknown_03005DB0 = NULL; + gFieldCallback2 = NULL; do_load_map_stuff_loop(&gMain.state); SetFieldVBlankCallback(); SetMainCallback1(CB1_Overworld); @@ -1684,7 +1684,7 @@ void c2_8056854(void) void CB2_ReturnToFieldWithOpenMenu(void) { FieldClearVBlankHBlankCallbacks(); - gUnknown_03005DB0 = sub_80AF6A4; + gFieldCallback2 = sub_80AF6A4; CB2_ReturnToField(); } diff --git a/src/rom6.c b/src/rom6.c index cdc1064dd..78cbbe2de 100644 --- a/src/rom6.c +++ b/src/rom6.c @@ -27,16 +27,16 @@ static void hm2_dig(void); static void sub_8135780(void); // extern RAM loc -extern struct MapPosition gUnknown_0203AB40; +extern struct MapPosition gPlayerFacingPosition; // text -bool8 npc_before_player_of_type(u8 a) +bool8 CheckObjectGraphicsInFrontOfPlayer(u8 a) { u8 eventObjId; - GetXYCoordsOneStepInFrontOfPlayer(&gUnknown_0203AB40.x, &gUnknown_0203AB40.y); - gUnknown_0203AB40.height = PlayerGetZCoord(); - eventObjId = GetEventObjectIdByXYZ(gUnknown_0203AB40.x, gUnknown_0203AB40.y, gUnknown_0203AB40.height); + GetXYCoordsOneStepInFrontOfPlayer(&gPlayerFacingPosition.x, &gPlayerFacingPosition.y); + gPlayerFacingPosition.height = PlayerGetZCoord(); + eventObjId = GetEventObjectIdByXYZ(gPlayerFacingPosition.x, gPlayerFacingPosition.y, gPlayerFacingPosition.height); if (gEventObjects[eventObjId].graphicsId != a) { return FALSE; @@ -50,7 +50,7 @@ bool8 npc_before_player_of_type(u8 a) u8 oei_task_add(void) { - GetXYCoordsOneStepInFrontOfPlayer(&gUnknown_0203AB40.x, &gUnknown_0203AB40.y); + GetXYCoordsOneStepInFrontOfPlayer(&gPlayerFacingPosition.x, &gPlayerFacingPosition.y); return CreateTask(task08_080C9820, 8); } @@ -118,17 +118,17 @@ static void sub_813561C(u8 taskId) bool8 SetUpFieldMove_RockSmash(void) { - if(ShouldDoBrailleStrengthEffect()) + if (ShouldDoBrailleStrengthEffect()) { gSpecialVar_Result = GetCursorSelectionMonId(); - gUnknown_03005DB0 = FieldCallback_Teleport; - gUnknown_0203CEEC = sub_8179834; + gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; + gPostMenuFieldCallback = sub_8179834; return TRUE; } - else if (npc_before_player_of_type(0x56) == TRUE) + else if (CheckObjectGraphicsInFrontOfPlayer(EVENT_OBJ_GFX_BREAKABLE_ROCK) == TRUE) { - gUnknown_03005DB0 = FieldCallback_Teleport; - gUnknown_0203CEEC = sub_81356C4; + gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; + gPostMenuFieldCallback = sub_81356C4; return TRUE; } else @@ -164,8 +164,8 @@ bool8 SetUpFieldMove_Dig(void) { if (CanUseEscapeRopeOnCurrMap() == TRUE) { - gUnknown_03005DB0 = FieldCallback_Teleport; - gUnknown_0203CEEC = hm2_dig; + gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; + gPostMenuFieldCallback = hm2_dig; return TRUE; } else diff --git a/src/start_menu.c b/src/start_menu.c index a83143d0b..e9f0cb1b4 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -90,7 +90,7 @@ extern void sub_80C4DDC(void (*)(void)); extern void sub_80C51C4(void (*)(void)); extern void sub_80C4E74(u8, void (*)(void)); extern void sub_81C4EFC(void); -extern void sub_80984F4(void); +extern void ScriptUnfreezeEventObjects(void); extern void sub_81A9EC8(void); extern void save_serialize_map(void); extern void sub_81A9E90(void); @@ -526,7 +526,7 @@ void sub_809FA18(void) // Called from field_screen.s { sUnknown_02037619[0] = 0; sUnknown_02037619[1] = 0; - gUnknown_03005DB0 = sub_809FA00; + gFieldCallback2 = sub_809FA00; } void sub_809FA34(u8 taskId) // Referenced in field_screen.s and rom_8011DC0.s @@ -769,7 +769,7 @@ static bool8 StartMenuBattlePyramidRetireCallback(void) void sub_809FDD4(void) // Called from battle_frontier_2.s { sub_8197DF8(0, FALSE); - sub_80984F4(); + ScriptUnfreezeEventObjects(); CreateStartMenuTask(sub_809FA34); ScriptContext2_Enable(); } @@ -811,7 +811,7 @@ static bool8 SaveCallback(void) case SAVE_SUCCESS: case SAVE_ERROR: // Close start menu sub_8197DF8(0, TRUE); - sub_80984F4(); + ScriptUnfreezeEventObjects(); ScriptContext2_Disable(); sub_81A9EC8(); return TRUE; @@ -848,7 +848,7 @@ static bool8 BattlePyramidRetireCallback(void) return FALSE; case SAVE_CANCELED: // Yes (Retire from battle pyramid) sub_8197DF8(0, TRUE); - sub_80984F4(); + ScriptUnfreezeEventObjects(); ScriptContext2_Disable(); ScriptContext1_SetupScript(BattleFrontier_BattlePyramidEmptySquare_EventScript_252C88); return TRUE; @@ -1405,7 +1405,7 @@ static void HideStartMenuWindow(void) { sub_819746C(GetStartMenuWindowId(), TRUE); RemoveStartMenuWindow(); - sub_80984F4(); + ScriptUnfreezeEventObjects(); ScriptContext2_Disable(); } diff --git a/sym_ewram.txt b/sym_ewram.txt index 4dff894f8..befef2273 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -379,10 +379,7 @@ gUnknown_02039D8C: @ 2039D8C .space 0x4 .include "src/script_movement.o" - -gUnknown_02039DD0: @ 2039DD0 - .space 0x4 - + .include "src/fldeff_cut.o" .include "src/map_name_popup.o" .include "src/item.o" @@ -602,7 +599,7 @@ gUnknown_0203AB34: @ 203AB34 .include "src/battle_ai_script_commands.o" .align 2 -gUnknown_0203AB40: @ 203AB40 +gPlayerFacingPosition: @ 203AB40 .space 0x8 .include "src/pokeblock.o" @@ -827,7 +824,7 @@ gUnknown_0203CEE8: @ 203CEE8 gUnknown_0203CEE9: @ 203CEE9 .space 0x3 -gUnknown_0203CEEC: @ 203CEEC +gPostMenuFieldCallback: @ 203CEEC .space 0x4 gUnknown_0203CEF0: @ 203CEF0