decompile field_special_scene.c

This commit is contained in:
ProjectRevoTPP 2017-09-22 22:45:47 -04:00
parent 2ad419e4b9
commit 2448426183
10 changed files with 378 additions and 883 deletions

View File

@ -1467,7 +1467,7 @@ _0809CAF8:
cmp r0, 0x1
beq _0809CB28
movs r0, 0x1
bl sub_8137FC0
bl CountSSTidalStep
cmp r0, 0x1
bne _0809CB1C
ldr r0, =gUnknown_0823C050

View File

@ -1,282 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start sub_80FB59C
sub_80FB59C: @ 80FB59C
push {r4-r6,lr}
sub sp, 0xC
mov r4, sp
adds r4, 0x5
mov r5, sp
adds r5, 0x6
add r6, sp, 0x8
add r0, sp, 0x4
adds r1, r4, 0
adds r2, r5, 0
adds r3, r6, 0
bl sub_8137FFC
lsls r0, 24
cmp r0, 0
bne _080FB5DE
add r0, sp, 0x4
ldrb r0, [r0]
lsls r0, 24
asrs r0, 24
movs r1, 0
ldrsb r1, [r4, r1]
movs r2, 0x1
negs r2, r2
movs r3, 0
ldrsb r3, [r5, r3]
movs r4, 0
ldrsb r4, [r6, r4]
str r4, [sp]
bl warp1_set
movs r0, 0x1
b _080FB5E0
_080FB5DE:
movs r0, 0
_080FB5E0:
add sp, 0xC
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end sub_80FB59C
thumb_func_start sub_80FB5E8
sub_80FB5E8: @ 80FB5E8
push {r4-r7,lr}
lsls r0, 24
lsrs r5, r0, 24
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
ldr r1, =gTasks + 0x8
adds r4, r0, r1
ldr r0, =0x000040b4
bl GetVarPointer
adds r7, r0, 0
ldr r0, =gSaveBlock1Ptr
ldr r3, [r0]
adds r6, r3, 0x4
movs r0, 0
ldrsh r2, [r4, r0]
cmp r2, 0x1
beq _080FB648
cmp r2, 0x1
bgt _080FB624
cmp r2, 0
beq _080FB62E
b _080FB6E2
.pool
_080FB624:
cmp r2, 0x2
beq _080FB68A
cmp r2, 0x3
beq _080FB6C4
b _080FB6E2
_080FB62E:
ldr r0, =gPaletteFade
ldrb r1, [r0, 0x7]
movs r0, 0x80
ands r0, r1
cmp r0, 0
bne _080FB6E2
strh r2, [r4, 0x2]
movs r0, 0x2
strh r0, [r4]
b _080FB6E2
.pool
_080FB648:
ldr r0, =gMain
ldrh r1, [r0, 0x2E]
adds r0, r2, 0
ands r0, r1
cmp r0, 0
beq _080FB656
strh r2, [r4, 0x2]
_080FB656:
ldrb r1, [r6, 0x1]
ldrb r2, [r3, 0x4]
movs r0, 0xFF
bl sub_80D3340
lsls r0, 24
cmp r0, 0
beq _080FB6E2
movs r0, 0x1
bl sub_8137FC0
cmp r0, 0x1
bne _080FB686
ldrh r0, [r7]
cmp r0, 0x2
bne _080FB680
movs r0, 0x9
b _080FB682
.pool
_080FB680:
movs r0, 0xA
_080FB682:
strh r0, [r7]
b _080FB692
_080FB686:
movs r0, 0x2
strh r0, [r4]
_080FB68A:
movs r1, 0x2
ldrsh r0, [r4, r1]
cmp r0, 0
beq _080FB698
_080FB692:
movs r0, 0x3
strh r0, [r4]
b _080FB6E2
_080FB698:
ldrh r0, [r7]
cmp r0, 0x2
bne _080FB6AC
ldrb r1, [r6, 0x1]
ldrb r2, [r6]
ldr r3, =gUnknown_0858E8AB
b _080FB6B2
.pool
_080FB6AC:
ldrb r1, [r6, 0x1]
ldrb r2, [r6]
ldr r3, =gUnknown_0858E8AD
_080FB6B2:
movs r0, 0xFF
bl exec_movement
movs r0, 0x1
strh r0, [r4]
b _080FB6E2
.pool
_080FB6C4:
ldr r0, =0x00004001
bl FlagReset
movs r0, 0x80
lsls r0, 7
bl FlagReset
movs r0, 0
bl copy_saved_warp2_bank_and_enter_x_to_warp1
bl sp13E_warp_to_last_warp
adds r0, r5, 0
bl DestroyTask
_080FB6E2:
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_80FB5E8
thumb_func_start sub_80FB6EC
sub_80FB6EC: @ 80FB6EC
push {r4,lr}
sub sp, 0x4
ldr r1, =SpriteCallbackDummy
movs r0, 0
str r0, [sp]
movs r0, 0x8C
movs r2, 0x70
movs r3, 0x50
bl AddPseudoFieldObject
lsls r0, 24
lsrs r0, 24
ldr r2, =gSprites
lsls r1, r0, 4
adds r1, r0
lsls r1, 2
adds r4, r1, r2
adds r2, r4, 0
adds r2, 0x3E
ldrb r1, [r2]
movs r0, 0x3
negs r0, r0
ands r0, r1
strb r0, [r2]
ldr r0, =0x000040b4
bl VarGet
lsls r0, 16
lsrs r0, 16
cmp r0, 0x2
bne _080FB74C
movs r0, 0x4
bl FieldObjectDirectionToImageAnimId
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
adds r0, r4, 0
bl StartSpriteAnim
b _080FB75E
.pool
_080FB74C:
movs r0, 0x3
bl FieldObjectDirectionToImageAnimId
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
adds r0, r4, 0
bl StartSpriteAnim
_080FB75E:
add sp, 0x4
pop {r4}
pop {r0}
bx r0
thumb_func_end sub_80FB6EC
thumb_func_start sub_80FB768
sub_80FB768: @ 80FB768
push {lr}
bl sub_80FB6EC
ldr r2, =gMapObjects
ldr r0, =gPlayerAvatar
ldrb r1, [r0, 0x5]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
adds r0, r2
ldrb r1, [r0, 0x1]
movs r2, 0x20
orrs r1, r2
strb r1, [r0, 0x1]
bl pal_fill_black
ldr r0, =sub_80FB5E8
movs r1, 0x50
bl CreateTask
bl ScriptContext2_Enable
pop {r0}
bx r0
.pool
thumb_func_end sub_80FB768
thumb_func_start sub_80FB7A4
sub_80FB7A4: @ 80FB7A4
push {lr}
ldr r0, =0x0000088d
bl FlagSet
ldr r0, =0x00004001
bl FlagSet
movs r0, 0x80
lsls r0, 7
bl FlagSet
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
movs r1, 0x4
ldrsb r1, [r0, r1]
movs r2, 0x5
ldrsb r2, [r0, r2]
movs r3, 0x1
negs r3, r3
movs r0, 0
bl saved_warp2_set
bl sub_80FB59C
bl sub_80AF8B8
pop {r0}
bx r0
.pool
thumb_func_end sub_80FB7A4
.align 2, 0 @ Don't pad with nop.

View File

@ -1939,7 +1939,7 @@ sub_8123C00: @ 8123C00
adds r1, r4, 0
adds r2, r5, 0
adds r3, r6, 0
bl sub_8137FFC
bl GetSSTidalLocation
lsls r0, 24
lsrs r0, 24
mov r10, r5

View File

@ -3175,7 +3175,7 @@ CB2_NewGame: @ 8085EF8
bl ScriptContext1_Init
bl ScriptContext2_Disable
ldr r1, =gUnknown_03005DAC
ldr r0, =sub_80FB4E0
ldr r0, =ExecuteTruckSequence
str r0, [r1]
ldr r1, =gUnknown_03005DB0
movs r0, 0

View File

@ -5062,8 +5062,8 @@ sub_8137FB0: @ 8137FB0
.pool
thumb_func_end sub_8137FB0
thumb_func_start sub_8137FC0
sub_8137FC0: @ 8137FC0
thumb_func_start CountSSTidalStep
CountSSTidalStep: @ 8137FC0
push {r4,lr}
lsls r0, 16
lsrs r4, r0, 16
@ -5091,10 +5091,10 @@ _08137FF6:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_8137FC0
thumb_func_end CountSSTidalStep
thumb_func_start sub_8137FFC
sub_8137FFC: @ 8137FFC
thumb_func_start GetSSTidalLocation
GetSSTidalLocation: @ 8137FFC
push {r4-r7,lr}
mov r7, r8
push {r7}
@ -5203,7 +5203,7 @@ _081380CE:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_8137FFC
thumb_func_end GetSSTidalLocation
thumb_func_start is_tile_that_overrides_player_control
is_tile_that_overrides_player_control: @ 81380D8

View File

@ -1,589 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start sub_80FB0B0
sub_80FB0B0: @ 80FB0B0
push {r4,lr}
adds r4, r0, 0
movs r1, 0x78
bl __modsi3
cmp r0, 0
bne _080FB0C4
movs r0, 0x1
negs r0, r0
b _080FB0D6
_080FB0C4:
adds r0, r4, 0
movs r1, 0xA
bl __modsi3
cmp r0, 0x4
ble _080FB0D4
movs r0, 0
b _080FB0D6
_080FB0D4:
movs r0, 0x1
_080FB0D6:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_80FB0B0
thumb_func_start sub_80FB0DC
sub_80FB0DC: @ 80FB0DC
push {lr}
adds r0, 0x78
movs r1, 0xB4
bl __modsi3
cmp r0, 0
beq _080FB0EE
movs r0, 0
b _080FB0F2
_080FB0EE:
movs r0, 0x1
negs r0, r0
_080FB0F2:
pop {r1}
bx r1
thumb_func_end sub_80FB0DC
thumb_func_start sub_80FB0F8
sub_80FB0F8: @ 80FB0F8
push {r4,r5,lr}
sub sp, 0x4
lsls r0, 24
lsrs r0, 24
lsls r1, r0, 2
adds r1, r0
lsls r1, 3
ldr r0, =gTasks + 0x8
adds r5, r1, r0
movs r1, 0
ldrsh r0, [r5, r1]
adds r0, 0x1E
bl sub_80FB0DC
ldr r4, =gSaveBlock1Ptr
ldr r2, [r4]
ldrb r1, [r2, 0x5]
ldrb r2, [r2, 0x4]
lsls r0, 18
movs r3, 0xC0
lsls r3, 10
orrs r0, r3
asrs r0, 16
str r0, [sp]
movs r0, 0x1
movs r3, 0x3
bl sub_808E82C
movs r3, 0
ldrsh r0, [r5, r3]
bl sub_80FB0DC
ldr r2, [r4]
ldrb r1, [r2, 0x5]
ldrb r2, [r2, 0x4]
lsls r0, 17
ldr r3, =0xfffd0000
adds r0, r3
asrs r0, 16
str r0, [sp]
movs r0, 0x2
movs r3, 0
bl sub_808E82C
movs r1, 0
ldrsh r0, [r5, r1]
bl sub_80FB0DC
ldr r2, [r4]
ldrb r1, [r2, 0x5]
ldrb r2, [r2, 0x4]
movs r4, 0
movs r3, 0x3
negs r3, r3
lsls r0, 18
asrs r0, 16
str r0, [sp]
movs r0, 0x3
bl sub_808E82C
ldrh r0, [r5]
adds r0, 0x1
strh r0, [r5]
lsls r0, 16
ldr r1, =0x75300000
cmp r0, r1
bne _080FB180
strh r4, [r5]
_080FB180:
movs r3, 0
ldrsh r0, [r5, r3]
bl sub_80FB0B0
adds r1, r0, 0
lsls r1, 16
asrs r1, 16
movs r0, 0
bl SetCameraPanning
add sp, 0x4
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_80FB0F8
thumb_func_start sub_80FB1AC
sub_80FB1AC: @ 80FB1AC
push {r4-r7,lr}
sub sp, 0x4
lsls r0, 24
lsrs r2, r0, 24
lsls r0, r2, 2
adds r0, r2
lsls r3, r0, 3
ldr r4, =gTasks + 0x8
adds r7, r3, r4
ldrh r1, [r7]
adds r1, 0x1
strh r1, [r7]
ldrh r0, [r7, 0x4]
adds r0, 0x1
strh r0, [r7, 0x4]
lsls r1, 16
asrs r1, 16
cmp r1, 0x5
ble _080FB1DC
movs r0, 0
strh r0, [r7]
ldrh r0, [r7, 0x2]
adds r0, 0x1
strh r0, [r7, 0x2]
_080FB1DC:
ldrh r0, [r7, 0x2]
cmp r0, 0x13
bne _080FB1F0
adds r0, r2, 0
bl DestroyTask
b _080FB2A8
.pool
_080FB1F0:
ldr r2, =gUnknown_0858E898
movs r1, 0x2
ldrsh r0, [r7, r1]
adds r0, r2
ldrb r0, [r0]
lsls r0, 24
asrs r0, 24
cmp r0, 0x2
bne _080FB20C
adds r0, r4, 0
subs r0, 0x8
adds r0, r3, r0
ldr r1, =sub_80FB2C0
str r1, [r0]
_080FB20C:
movs r4, 0x2
ldrsh r0, [r7, r4]
adds r0, r2
movs r5, 0
ldrsb r5, [r0, r5]
lsls r5, 16
lsrs r5, 16
movs r1, 0x4
ldrsh r0, [r7, r1]
bl sub_80FB0B0
adds r1, r0, 0
lsls r5, 16
asrs r5, 16
lsls r1, 16
asrs r1, 16
adds r0, r5, 0
bl SetCameraPanning
movs r4, 0x4
ldrsh r0, [r7, r4]
adds r0, 0x1E
bl sub_80FB0DC
ldr r6, =gSaveBlock1Ptr
ldr r2, [r6]
ldrb r1, [r2, 0x5]
ldrb r2, [r2, 0x4]
movs r3, 0x3
subs r3, r5
lsls r3, 16
asrs r3, 16
lsls r0, 18
movs r4, 0xC0
lsls r4, 10
orrs r0, r4
asrs r0, 16
str r0, [sp]
movs r0, 0x1
bl sub_808E82C
movs r1, 0x4
ldrsh r0, [r7, r1]
bl sub_80FB0DC
ldr r2, [r6]
ldrb r1, [r2, 0x5]
ldrb r2, [r2, 0x4]
negs r3, r5
lsls r3, 16
asrs r3, 16
lsls r0, 17
ldr r4, =0xfffd0000
adds r0, r4
asrs r0, 16
str r0, [sp]
movs r0, 0x2
bl sub_808E82C
movs r1, 0x4
ldrsh r0, [r7, r1]
bl sub_80FB0DC
ldr r2, [r6]
ldrb r1, [r2, 0x5]
ldrb r2, [r2, 0x4]
movs r4, 0x3
negs r4, r4
adds r3, r4, 0
subs r3, r5
lsls r3, 16
asrs r3, 16
lsls r0, 18
asrs r0, 16
str r0, [sp]
movs r0, 0x3
bl sub_808E82C
_080FB2A8:
add sp, 0x4
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_80FB1AC
thumb_func_start sub_80FB2C0
sub_80FB2C0: @ 80FB2C0
push {r4-r6,lr}
mov r6, r8
push {r6}
sub sp, 0x4
lsls r0, 24
lsrs r0, 24
adds r3, r0, 0
lsls r0, r3, 2
adds r0, r3
lsls r0, 3
ldr r1, =gTasks + 0x8
adds r2, r0, r1
ldrh r0, [r2]
adds r0, 0x1
strh r0, [r2]
lsls r0, 16
asrs r0, 16
cmp r0, 0x5
ble _080FB2F0
movs r0, 0
strh r0, [r2]
ldrh r0, [r2, 0x2]
adds r0, 0x1
strh r0, [r2, 0x2]
_080FB2F0:
ldrh r0, [r2, 0x2]
cmp r0, 0x13
bne _080FB304
adds r0, r3, 0
bl DestroyTask
b _080FB358
.pool
_080FB304:
ldr r1, =gUnknown_0858E898
movs r3, 0x2
ldrsh r0, [r2, r3]
adds r0, r1
movs r1, 0
mov r8, r1
movs r6, 0
ldrsb r6, [r0, r6]
adds r0, r6, 0
bl SetCameraPanning
ldr r5, =gSaveBlock1Ptr
ldr r0, [r5]
ldrb r1, [r0, 0x5]
ldrb r2, [r0, 0x4]
movs r3, 0x3
subs r3, r6
movs r0, 0x3
str r0, [sp]
movs r0, 0x1
bl sub_808E82C
ldr r0, [r5]
ldrb r1, [r0, 0x5]
ldrb r2, [r0, 0x4]
negs r3, r6
mov r4, r8
subs r4, 0x3
str r4, [sp]
movs r0, 0x2
bl sub_808E82C
ldr r0, [r5]
ldrb r1, [r0, 0x5]
ldrb r2, [r0, 0x4]
subs r4, r6
mov r3, r8
str r3, [sp]
movs r0, 0x3
adds r3, r4, 0
bl sub_808E82C
_080FB358:
add sp, 0x4
pop {r3}
mov r8, r3
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_80FB2C0
thumb_func_start sub_80FB36C
sub_80FB36C: @ 80FB36C
push {r4,r5,lr}
lsls r0, 24
lsrs r5, r0, 24
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
ldr r1, =gTasks + 0x8
adds r4, r0, r1
movs r1, 0
ldrsh r0, [r4, r1]
cmp r0, 0x5
bls _080FB386
b _080FB4D8
_080FB386:
lsls r0, 2
ldr r1, =_080FB398
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_080FB398:
.4byte _080FB3B0
.4byte _080FB3E8
.4byte _080FB404
.4byte _080FB450
.4byte _080FB474
.4byte _080FB492
_080FB3B0:
ldrh r0, [r4, 0x2]
adds r0, 0x1
strh r0, [r4, 0x2]
lsls r0, 16
asrs r0, 16
cmp r0, 0x5A
beq _080FB3C0
b _080FB4D8
_080FB3C0:
movs r0, 0
bl SetCameraPanningCallback
movs r0, 0
strh r0, [r4, 0x2]
ldr r0, =sub_80FB0F8
movs r1, 0xA
bl CreateTask
lsls r0, 24
lsrs r0, 24
strh r0, [r4, 0x4]
movs r0, 0x1
strh r0, [r4]
movs r0, 0x31
bl PlaySE
b _080FB4D8
.pool
_080FB3E8:
ldrh r0, [r4, 0x2]
adds r0, 0x1
strh r0, [r4, 0x2]
lsls r0, 16
asrs r0, 16
cmp r0, 0x96
bne _080FB4D8
bl pal_fill_black
movs r0, 0
strh r0, [r4, 0x2]
movs r0, 0x2
strh r0, [r4]
b _080FB4D8
_080FB404:
ldrh r0, [r4, 0x2]
adds r3, r0, 0x1
strh r3, [r4, 0x2]
ldr r0, =gPaletteFade
ldrb r1, [r0, 0x7]
movs r0, 0x80
ands r0, r1
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0
bne _080FB4D8
lsls r1, r3, 16
movs r0, 0x96
lsls r0, 17
cmp r1, r0
ble _080FB4D8
strh r2, [r4, 0x2]
ldrb r0, [r4, 0x4]
bl DestroyTask
ldr r0, =sub_80FB1AC
movs r1, 0xA
bl CreateTask
lsls r0, 24
lsrs r0, 24
strh r0, [r4, 0x6]
movs r0, 0x3
strh r0, [r4]
movs r0, 0x32
bl PlaySE
b _080FB4D8
.pool
_080FB450:
ldr r2, =gTasks
movs r0, 0x6
ldrsh r1, [r4, r0]
lsls r0, r1, 2
adds r0, r1
lsls r0, 3
adds r0, r2
ldrb r5, [r0, 0x4]
cmp r5, 0
bne _080FB4D8
bl InstallCameraPanAheadCallback
strh r5, [r4, 0x2]
movs r0, 0x4
strh r0, [r4]
b _080FB4D8
.pool
_080FB474:
ldrh r0, [r4, 0x2]
adds r0, 0x1
strh r0, [r4, 0x2]
lsls r0, 16
asrs r0, 16
cmp r0, 0x5A
bne _080FB4D8
movs r0, 0x33
bl PlaySE
movs r0, 0
strh r0, [r4, 0x2]
movs r0, 0x5
strh r0, [r4]
b _080FB4D8
_080FB492:
ldrh r0, [r4, 0x2]
adds r0, 0x1
strh r0, [r4, 0x2]
lsls r0, 16
asrs r0, 16
cmp r0, 0x78
bne _080FB4D8
movs r2, 0x82
lsls r2, 2
movs r0, 0xB
movs r1, 0x8
bl MapGridSetMetatileIdAt
movs r2, 0x84
lsls r2, 2
movs r0, 0xB
movs r1, 0x9
bl MapGridSetMetatileIdAt
movs r2, 0x86
lsls r2, 2
movs r0, 0xB
movs r1, 0xA
bl MapGridSetMetatileIdAt
bl DrawWholeMapView
movs r0, 0x34
bl PlaySE
adds r0, r5, 0
bl DestroyTask
bl ScriptContext2_Disable
_080FB4D8:
pop {r4,r5}
pop {r0}
bx r0
thumb_func_end sub_80FB36C
thumb_func_start sub_80FB4E0
sub_80FB4E0: @ 80FB4E0
push {lr}
sub sp, 0x4
ldr r2, =0x0000020d
movs r0, 0xB
movs r1, 0x8
bl MapGridSetMetatileIdAt
ldr r2, =0x00000215
movs r0, 0xB
movs r1, 0x9
bl MapGridSetMetatileIdAt
ldr r2, =0x0000021d
movs r0, 0xB
movs r1, 0xA
bl MapGridSetMetatileIdAt
bl DrawWholeMapView
bl ScriptContext2_Enable
movs r0, 0
str r0, [sp]
ldr r1, =gPlttBufferFaded
ldr r2, =0x01000100
mov r0, sp
bl CpuFastSet
ldr r0, =sub_80FB36C
movs r1, 0xA
bl CreateTask
add sp, 0x4
pop {r0}
bx r0
.pool
thumb_func_end sub_80FB4E0
thumb_func_start sub_80FB540
sub_80FB540: @ 80FB540
push {r4-r6,lr}
sub sp, 0x4
ldr r0, =sub_80FB36C
bl FuncIsActiveTask
lsls r0, 24
lsrs r6, r0, 24
cmp r6, 0
bne _080FB58A
ldr r4, =gSaveBlock1Ptr
ldr r0, [r4]
ldrb r1, [r0, 0x5]
ldrb r2, [r0, 0x4]
movs r0, 0x3
str r0, [sp]
movs r0, 0x1
movs r3, 0x3
bl sub_808E82C
ldr r0, [r4]
ldrb r1, [r0, 0x5]
ldrb r2, [r0, 0x4]
movs r5, 0x3
negs r5, r5
str r5, [sp]
movs r0, 0x2
movs r3, 0
bl sub_808E82C
ldr r0, [r4]
ldrb r1, [r0, 0x5]
ldrb r2, [r0, 0x4]
str r6, [sp]
movs r0, 0x3
adds r3, r5, 0
bl sub_808E82C
_080FB58A:
add sp, 0x4
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_80FB540
.align 2, 0 @ Don't pad with nop.

View File

@ -56,7 +56,7 @@ gUnknown_0858E864:: @ 858E864
gUnknown_0858E880:: @ 858E880
.incbin "baserom.gba", 0x58e880, 0x18
gUnknown_0858E898:: @ 858E898
gTruckCamera_HorizontalTable:: @ 858E898
.incbin "baserom.gba", 0x58e898, 0x13
gUnknown_0858E8AB:: @ 858E8AB

View File

@ -4,6 +4,8 @@
#define NUM_OBJECT_GRAPHICS_INFO 239
#define SPRITE_VAR 240
struct Sprite; // pika pls
// Exported struct declarations
enum SpinnerRunnerFollowPatterns {

View File

@ -158,8 +158,7 @@ SECTIONS {
asm/field_poison.o(.text);
src/pokemon_size_record.o(.text);
asm/fldeff_80F9BCC.o(.text);
asm/truck_scene.o(.text);
asm/porthole.o(.text);
src/field_special_scene.o(.text);
asm/rotating_gate.o(.text);
src/safari_zone.o(.text);
asm/contest_link_80FC4F4.o(.text);

365
src/field_special_scene.c Executable file
View File

@ -0,0 +1,365 @@
#include "global.h"
#include "task.h"
#include "field_map_obj.h"
#include "songs.h"
#include "sound.h"
#include "palette.h"
#include "script.h"
#include "vars.h"
#include "event_data.h"
#include "main.h"
#include "sprite.h"
#define SECONDS(value) ((signed) (60.0 * value + 0.5))
// porthole states
enum
{
INIT_PORTHOLE,
IDLE_CHECK,
EXECUTE_MOVEMENT,
EXIT_PORTHOLE,
};
extern void SetCameraPanning(s16 x, s16 y);
extern void SetCameraPanningCallback(void ( *callback)());
extern void InstallCameraPanAheadCallback();
extern void pal_fill_black(void);
extern void MapGridSetMetatileIdAt(s32 x, s32 y, u16 metatileId);
extern void DrawWholeMapView();
extern s8 gTruckCamera_HorizontalTable[];
extern u8 gUnknown_0858E8AB[];
extern u8 gUnknown_0858E8AD[];
void Task_Truck3(u8);
s32 GetTruckCameraBobbingY(int a1)
{
if (!(a1 % 120))
return -1;
else if ((a1 % 10) <= 4)
return 1;
return 0;
}
s32 GetTruckBoxMovement(int a1) // for the box movement?
{
if (!((a1 + 120) % 180))
return -1;
return 0;
}
// smh STILL BROKEN IN EMERALD
void Task_Truck1(u8 taskId)
{
s16 *data = gTasks[taskId].data;
s16 cameraYpan;
s16 box1 = 0;
s16 box2 = 0;
s16 box3 = 0;
u8 mapNum, mapGroup;
register s16 zero asm("r4");
box1 = GetTruckBoxMovement(data[0] + 30) * 4; // top box.
sub_808E82C(1, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 3, box1 + 3);
box2 = GetTruckBoxMovement(data[0]) * 2; // bottom left box.
sub_808E82C(2, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 0, box2 - 3);
box3 = GetTruckBoxMovement(data[0]) * 4; // bottom right box.
mapNum = gSaveBlock1Ptr->location.mapNum;
mapGroup = gSaveBlock1Ptr->location.mapGroup;
zero = 0;
sub_808E82C(3, mapNum, mapGroup, -3, box3);
if (++data[0] == SECONDS(500)) // this will never run
data[0] = zero; // reset the timer if it gets stuck.
cameraYpan = GetTruckCameraBobbingY(data[0]);
SetCameraPanning(0, cameraYpan);
}
void Task_Truck2(u8 taskId)
{
s16 *data = gTasks[taskId].data;
s16 cameraYpan;
s16 cameraXpan;
s16 box1;
s16 box2;
s16 box3;
data[0]++;
data[2]++;
if (data[0] > 5)
{
data[0] = 0;
data[1]++;
}
if ((u16)data[1] == 19)
{
DestroyTask(taskId);
}
else
{
if (gTruckCamera_HorizontalTable[data[1]] == 2)
gTasks[taskId].func = Task_Truck3;
cameraXpan = gTruckCamera_HorizontalTable[data[1]];
cameraYpan = GetTruckCameraBobbingY(data[2]);
SetCameraPanning(cameraXpan, cameraYpan);
box1 = GetTruckBoxMovement(data[2] + 30) * 4;
sub_808E82C(1, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 3 - cameraXpan, box1 + 3);
box2 = GetTruckBoxMovement(data[2]) * 2;
sub_808E82C(2, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -cameraXpan, box2 - 3);
box3 = GetTruckBoxMovement(data[2]) * 4;
sub_808E82C(3, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -3 - cameraXpan, box3);
}
}
void Task_Truck3(u8 taskId)
{
s16 *data = gTasks[taskId].data;
s16 cameraXpan;
s16 cameraYpan;
data[0]++;
if (data[0] > 5)
{
data[0] = 0;
data[1]++;
}
if ((u16)data[1] == 19)
{
DestroyTask(taskId);
}
else
{
cameraXpan = gTruckCamera_HorizontalTable[data[1]];
cameraYpan = 0;
SetCameraPanning(cameraXpan, 0);
sub_808E82C(1, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 3 - cameraXpan, cameraYpan + 3);
sub_808E82C(2, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -cameraXpan, cameraYpan - 3);
sub_808E82C(3, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -3 - cameraXpan, cameraYpan);
}
}
void Task_HandleTruckSequence(u8 taskId)
{
s16 *data = gTasks[taskId].data;
switch (data[0])
{
/*
Each case has a timer which is handled with data[1], incrementing
until it reaches the if function's condition, which sets the next task up.
*/
case 0:
data[1]++;
if (data[1] == SECONDS(1.5))
{
SetCameraPanningCallback(NULL);
data[1] = 0; // reset the timer.
data[2] = CreateTask(Task_Truck1, 0xA);
data[0] = 1; // run the next case.
PlaySE(SE_TRACK_MOVE);
}
break;
case 1:
data[1]++;
if (data[1] == SECONDS(2.5))
{
pal_fill_black();
data[1] = 0;
data[0] = 2;
}
break;
case 2:
data[1]++;
if (!gPaletteFade.active && data[1] > SECONDS(5))
{
data[1] = 0;
DestroyTask(data[2]);
data[3] = CreateTask(Task_Truck2, 0xA);
data[0] = 3;
PlaySE(SE_TRACK_STOP);
}
break;
case 3:
if (!gTasks[data[3]].isActive) // is Truck2 no longer active (is Truck3 active?)
{
InstallCameraPanAheadCallback();
data[1] = 0;
data[0] = 4;
}
break;
case 4:
data[1]++;
if (data[1] == 90)
{
PlaySE(SE_TRACK_HAIK);
data[1] = 0;
data[0] = 5;
}
break;
case 5:
data[1]++;
if (data[1] == 120)
{
MapGridSetMetatileIdAt(11, 8, 520);
MapGridSetMetatileIdAt(11, 9, 528);
MapGridSetMetatileIdAt(11, 10, 536);
DrawWholeMapView();
PlaySE(SE_TRACK_DOOR);
DestroyTask(taskId);
ScriptContext2_Disable();
}
break;
}
}
void ExecuteTruckSequence(void)
{
MapGridSetMetatileIdAt(11, 8, 525);
MapGridSetMetatileIdAt(11, 9, 533);
MapGridSetMetatileIdAt(11, 10, 541);
DrawWholeMapView();
ScriptContext2_Enable();
CpuFastFill(0, gPlttBufferFaded, 0x400);
CreateTask(Task_HandleTruckSequence, 0xA);
}
void EndTruckSequence(u8 taskId)
{
if (!FuncIsActiveTask(Task_HandleTruckSequence))
{
sub_808E82C(1, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 3, 3);
sub_808E82C(2, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 0, -3);
sub_808E82C(3, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -3, 0);
}
}
extern u8 GetSSTidalLocation(s8 *, s8 *, s16 *, s16 *); // should be in field_specials.h
extern void warp1_set(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
bool8 sub_80FB59C(void)
{
s8 mapGroup, mapNum;
s16 x, y;
if (GetSSTidalLocation(&mapGroup, &mapNum, &x, &y))
{
return FALSE;
}
else
{
warp1_set(mapGroup, mapNum, -1, x, y);
return TRUE;
}
}
extern bool8 sub_80D3340(u8, u8, u8);
extern bool32 CountSSTidalStep(u16);
extern bool8 exec_movement(u8, u8, u8, u8 *);
extern void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused);
extern void sp13E_warp_to_last_warp(void);
void Task_HandlePorthole(u8 taskId)
{
s16 *data = gTasks[taskId].data;
u16 *var = GetVarPointer(VAR_PORTHOLE);
struct WarpData *location = &gSaveBlock1Ptr->location;
switch (data[0])
{
case INIT_PORTHOLE: // finish fading before making porthole finish.
if (!gPaletteFade.active)
{
data[1] = 0;
data[0] = EXECUTE_MOVEMENT; // execute movement before checking if should be exited. strange?
}
break;
case IDLE_CHECK: // idle and move.
if (gMain.newKeys & A_BUTTON)
data[1] = 1;
if (!sub_80D3340(0xFF, location->mapNum, location->mapGroup))
return;
if (CountSSTidalStep(1) == TRUE)
{
if (*var == 2)
*var = 9;
else
*var = 10;
data[0] = 3;
return;
}
data[0] = 2;
case EXECUTE_MOVEMENT: // execute movement.
if (data[1])
{
data[0] = EXIT_PORTHOLE; // exit porthole.
return;
}
// run this once.
if (*var == 2) // which direction?
{
exec_movement(0xFF, location->mapNum, location->mapGroup, gUnknown_0858E8AB);
data[0] = IDLE_CHECK; // run case 1.
}
else
{
exec_movement(0xFF, location->mapNum, location->mapGroup, gUnknown_0858E8AD);
data[0] = IDLE_CHECK; // run case 1.
}
break;
case EXIT_PORTHOLE: // exit porthole.
FlagReset(0x4001);
FlagReset(0x4000);
copy_saved_warp2_bank_and_enter_x_to_warp1(0);
sp13E_warp_to_last_warp();
DestroyTask(taskId);
break;
}
}
void sub_80FB6EC(void)
{
u8 spriteId = AddPseudoFieldObject(0x8C, SpriteCallbackDummy, 112, 80, 0);
gSprites[spriteId].coordOffsetEnabled = FALSE;
if (VarGet(0x40B4) == 2)
{
StartSpriteAnim(&gSprites[spriteId], FieldObjectDirectionToImageAnimId(4));
}
else
{
StartSpriteAnim(&gSprites[spriteId], FieldObjectDirectionToImageAnimId(3));
}
}
void sub_80FB768(void)
{
sub_80FB6EC();
gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_13 = TRUE;
pal_fill_black();
CreateTask(Task_HandlePorthole, 80);
ScriptContext2_Enable();
}
extern void saved_warp2_set(int unused, s8 mapGroup, s8 mapNum, s8 warpId);
extern void sub_80AF8B8(void);
void sub_80FB7A4(void)
{
FlagSet(SYS_CRUISE_MODE);
FlagSet(0x4001);
FlagSet(0x4000);
saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);
sub_80FB59C();
sub_80AF8B8();
}