Merge branch 'unk_02052F30' into pikalax_work

This commit is contained in:
PikalaxALT 2022-03-16 19:45:08 -04:00
commit 505506dffc
25 changed files with 561 additions and 966 deletions

View File

@ -18,7 +18,7 @@ As with the compiler, the Nitro SDK is proprietary and cannot be distributed her
#### Linux
Building the ROM requires the following packages:
Building the ROM requires the following packages. If you cannot find one or more of these using your package distribution, it may be under a different name.
* make
* git
@ -28,7 +28,7 @@ Building the ROM requires the following packages:
* python3 (for asm preprocessor)
* libpng-devel (libpng-dev on Ubuntu)
* pkg-config
* pugixml
* pugixml (libpugixml-dev on Ubuntu)
NOTE: If you are using Arch/Manjaro or Void you will only need base-devel instead of build-essentials or make or git. You will still need wine.

View File

@ -5945,7 +5945,7 @@ ScrCmd_181: ; 0x020436C4
bl Save_FlyPoints_get
add r5, r0, #0
mov r1, #0xc
bl sub_0203B98C
bl FlyPoints_SetWeatherType
add r0, r5, #0
bl sub_0203B984
add r4, #0x80

View File

@ -3,938 +3,36 @@
.rodata
.public _020FC5CC
_020FC5CC:
.byte 0x01, 0x00, 0x10, 0x00
.byte 0x00, 0x40, 0x0C, 0x00, 0x21, 0x00, 0x10, 0x00, 0x00, 0x40, 0x0C, 0x00, 0x03, 0x00, 0x10, 0x00
.byte 0x00, 0x40, 0x0C, 0x00, 0x11, 0x01, 0x11, 0x01, 0x00, 0x40, 0x0C, 0x00, 0x11, 0x01, 0x11, 0x01
.byte 0x00, 0x00, 0x0A, 0x00, 0x06, 0x00, 0x10, 0x00, 0x00, 0x40, 0x0C, 0x00
.word 0x00100001
.byte 0x00, 0x40, 0x0C, 0x00
.word 0x00100021
.byte 0x00, 0x40, 0x0C, 0x00
.word 0x00100003
.byte 0x00, 0x40, 0x0C, 0x00
.word 0x01110111
.byte 0x00, 0x40, 0x0C, 0x00
.word 0x01110111
.byte 0x00, 0x00, 0x0A, 0x00
.word 0x00100006
.byte 0x00, 0x40, 0x0C, 0x00
.text
thumb_func_start sub_02052F30
sub_02052F30: ; 0x02052F30
ldr r1, [r0, #0x20]
ldr r3, _02052F8C ; =0x0000010F
ldr r1, [r1]
mov r2, #0
cmp r1, r3
bgt _02052F5C
sub r3, r3, #6
sub r3, r1, r3
bmi _02052F6A
add r3, r3, r3
add r3, pc
ldrh r3, [r3, #6]
lsl r3, r3, #0x10
asr r3, r3, #0x10
add pc, r3
_02052F4E: ; jump table
.short _02052F68 - _02052F4E - 2 ; case 0
.short _02052F68 - _02052F4E - 2 ; case 1
.short _02052F68 - _02052F4E - 2 ; case 2
.short _02052F68 - _02052F4E - 2 ; case 3
.short _02052F68 - _02052F4E - 2 ; case 4
.short _02052F68 - _02052F4E - 2 ; case 5
.short _02052F68 - _02052F4E - 2 ; case 6
_02052F5C:
ldr r3, _02052F90 ; =0x00000165
cmp r1, r3
bne _02052F6A
mov r1, #1
str r1, [r0, #0x70]
bx lr
_02052F68:
mov r2, #1
_02052F6A:
ldr r1, [r0, #0x70]
cmp r1, #1
bne _02052F74
mov r1, #0
str r1, [r0, #0x70]
_02052F74:
cmp r2, #0
bne _02052F82
ldr r1, [r0, #0x70]
cmp r1, #4
bne _02052F82
mov r1, #0
str r1, [r0, #0x70]
_02052F82:
cmp r2, #0
beq _02052F8A
mov r1, #4
str r1, [r0, #0x70]
_02052F8A:
bx lr
.balign 4, 0
_02052F8C: .word 0x0000010F
_02052F90: .word 0x00000165
thumb_func_end sub_02052F30
thumb_func_start sub_02052F94
sub_02052F94: ; 0x02052F94
push {r4, r5, r6, lr}
add r5, r0, #0
ldr r0, [r5, #0xc]
add r4, r1, #0
bl Save_FlyPoints_get
add r6, r0, #0
bl sub_0203B960
add r2, r0, #0
cmp r4, #0
beq _02052FC8
ldr r3, [r5, #0x20]
ldmia r3!, {r0, r1}
stmia r2!, {r0, r1}
ldmia r3!, {r0, r1}
stmia r2!, {r0, r1}
ldr r0, [r3]
str r0, [r2]
ldr r2, [r5, #0x20]
ldmia r4!, {r0, r1}
stmia r2!, {r0, r1}
ldmia r4!, {r0, r1}
stmia r2!, {r0, r1}
ldr r0, [r4]
str r0, [r2]
_02052FC8:
ldr r1, [r5, #0x20]
add r0, r5, #0
ldr r1, [r1]
bl Field_InitMapEvents
ldr r0, [r5, #0x20]
ldr r1, [r0, #4]
mov r0, #0
mvn r0, r0
cmp r1, r0
beq _02053016
add r0, r5, #0
bl Field_GetWarpEventI
ldrh r2, [r0]
ldr r1, [r5, #0x20]
str r2, [r1, #8]
ldrh r2, [r0, #2]
ldr r1, [r5, #0x20]
str r2, [r1, #0xc]
ldrh r1, [r0, #6]
mov r0, #1
lsl r0, r0, #8
cmp r1, r0
bne _02053016
add r0, r6, #0
bl FlyPoints_GetDynamicWarp
add r4, r0, #0
add r0, r6, #0
bl sub_0203B95C
add r2, r0, #0
ldmia r2!, {r0, r1}
stmia r4!, {r0, r1}
ldmia r2!, {r0, r1}
stmia r4!, {r0, r1}
ldr r0, [r2]
str r0, [r4]
_02053016:
pop {r4, r5, r6, pc}
thumb_func_end sub_02052F94
thumb_func_start sub_02053018
sub_02053018: ; 0x02053018
push {r4, lr}
add r4, r0, #0
ldr r0, [r4, #0x70]
cmp r0, #6
blt _02053026
bl GF_AssertFail
_02053026:
ldr r0, [r4, #0x74]
ldr r0, [r0]
lsl r0, r0, #0x10
lsr r1, r0, #0x1c
ldr r0, _02053034 ; =gSystem + 0x60
strb r1, [r0, #9]
pop {r4, pc}
.balign 4, 0
_02053034: .word gSystem + 0x60
thumb_func_end sub_02053018
thumb_func_start sub_02053038
sub_02053038: ; 0x02053038
push {r3, r4, r5, r6, r7, lr}
sub sp, #8
add r4, r0, #0
ldr r0, [r4, #0x20]
add r6, r1, #0
ldr r7, [r0]
ldr r0, [r4, #0xc]
bl Save_FlyPoints_get
str r0, [sp, #4]
add r0, r4, #0
bl sub_02054F4C
add r0, r4, #0
add r0, #0xac
ldr r0, [r0]
cmp r0, #0
bne _02053062
add r0, r4, #0
bl ClearTempFieldEventData
_02053062:
cmp r6, #0
bne _0205306E
add r0, r4, #0
bl sub_02067AE4
b _02053074
_0205306E:
add r0, r4, #0
bl sub_02067A88
_02053074:
add r0, r4, #0
add r0, #0xac
ldr r0, [r0]
cmp r0, #0
bne _02053088
cmp r6, #0
bne _02053088
add r0, r4, #0
bl FieldSys_StartBugContestTimer
_02053088:
cmp r6, #0
bne _020530A6
ldr r0, [r4, #0xc]
bl Sav2_GetGymmickPtr
bl SavGymmick_Clear
ldr r0, [r4, #0xc]
add r1, r7, #0
bl ShouldUseAlternateLakeOfRage
add r1, r0, #0
ldr r0, [r4, #0x30]
bl SetLakeOfRageWaterLevel
_020530A6:
ldr r0, [r4, #0xc]
bl SavArray_Flags_get
str r0, [sp]
add r0, r4, #0
add r1, r7, #0
bl sub_0203BBB4
lsl r0, r0, #0x10
lsr r5, r0, #0x10
ldr r0, [sp]
mov r1, #1
bl sub_02066C74
cmp r0, #0
beq _020530CC
cmp r7, #0x58
bne _020530CC
mov r5, #0
_020530CC:
cmp r5, #9
bne _020530DC
ldr r0, [sp]
bl CheckFlag974
cmp r0, #1
bne _020530DC
mov r5, #0
_020530DC:
cmp r5, #0xb
bne _020530EC
ldr r0, [sp]
bl CheckFlag973
cmp r0, #1
bne _020530EC
mov r5, #0xc
_020530EC:
ldr r0, [sp, #4]
add r1, r5, #0
bl sub_0203B98C
cmp r6, #0
beq _02053110
ldr r0, [sp, #4]
bl FlyPoints_GetCameraType
add r5, r0, #0
add r0, r7, #0
bl MapHeader_GetCameraType
cmp r5, r0
beq _0205311E
bl GF_AssertFail
b _0205311E
_02053110:
add r0, r7, #0
bl MapHeader_GetCameraType
add r1, r0, #0
ldr r0, [sp, #4]
bl FlyPoints_SetCameraType
_0205311E:
cmp r6, #0
bne _02053134
add r0, r7, #0
bl MapHeader_GetSpawnIdForDeathWarp
lsl r0, r0, #0x10
lsr r1, r0, #0x10
beq _02053134
ldr r0, [sp, #4]
bl FlyPoints_SetDeathSpawn
_02053134:
add r0, r4, #0
mov r1, #2
bl TryStartMapScriptByType
add r0, r4, #0
mov r1, #0
add r0, #0x7e
strh r1, [r0]
add r0, r4, #0
add r0, #0x7c
strh r1, [r0]
add r0, r4, #0
add r0, #0x78
strh r1, [r0]
ldr r0, [r4, #0xc]
bl Sav2_FollowPoke_get
mov r1, #0
bl SavFollowPoke_SetInhibitFlagState
ldr r0, [r4, #0xc]
bl SavArray_Flags_get
bl ClearFlag99A
add sp, #8
pop {r3, r4, r5, r6, r7, pc}
.balign 4, 0
thumb_func_end sub_02053038
thumb_func_start sub_0205316C
sub_0205316C: ; 0x0205316C
push {r3, r4, r5, lr}
sub sp, #0x10
add r4, r0, #0
add r1, r4, #0
add r1, #0xac
ldr r1, [r1]
cmp r1, #0
beq _020531B2
ldr r0, [r4, #0xc]
bl Sav2_PlayerData_GetProfileAddr
bl PlayerProfile_GetTrainerGender
add r5, r0, #0
ldr r0, [r4, #0xc]
bl Save_FlyPoints_get
bl sub_0203B9B4
ldr r3, [r4, #0x20]
ldr r1, [r0, #4]
str r1, [sp]
str r5, [sp, #4]
mov r1, #2
str r1, [sp, #8]
str r0, [sp, #0xc]
ldr r0, [r4, #0x3c]
ldr r1, [r3, #8]
ldr r2, [r3, #0xc]
ldr r3, [r3, #0x10]
bl sub_0205C390
add sp, #0x10
str r0, [r4, #0x40]
pop {r3, r4, r5, pc}
_020531B2:
mov r1, #0x40
mov r2, #5
bl sub_0205E0BC
str r0, [r4, #0x3c]
ldr r0, [r4, #0xc]
bl Sav2_PlayerData_GetProfileAddr
bl PlayerProfile_GetTrainerGender
add r5, r0, #0
ldr r0, [r4, #0xc]
bl Save_FlyPoints_get
bl sub_0203B9B4
ldr r3, [r4, #0x20]
ldr r1, [r0, #4]
str r1, [sp]
str r5, [sp, #4]
mov r1, #2
str r1, [sp, #8]
str r0, [sp, #0xc]
ldr r0, [r4, #0x3c]
ldr r1, [r3, #8]
ldr r2, [r3, #0xc]
ldr r3, [r3, #0x10]
bl sub_0205C390
str r0, [r4, #0x40]
ldr r3, [r4, #0x20]
ldr r0, [r3]
str r0, [sp]
ldr r0, [r4, #0x3c]
ldr r1, [r3, #8]
ldr r2, [r3, #0xc]
ldr r3, [r3, #0x10]
bl sub_020699F8
add r0, r4, #0
bl Field_InitMapObjectsFromZoneEventData
ldr r0, [r4, #0x3c]
bl sub_0205F55C
add sp, #0x10
pop {r3, r4, r5, pc}
thumb_func_end sub_0205316C
thumb_func_start sub_02053210
sub_02053210: ; 0x02053210
push {r4, lr}
add r4, r0, #0
add r0, #0xac
ldr r0, [r0]
cmp r0, #0
beq _02053224
ldr r0, [r4, #0x40]
bl sub_0205C4CC
pop {r4, pc}
_02053224:
bl sub_02056E38
ldr r0, [r4, #0x40]
bl sub_0205C4C4
ldr r0, [r4, #0x3c]
bl sub_0205E494
ldr r0, [r4, #0x3c]
bl sub_0205E0E8
pop {r4, pc}
thumb_func_end sub_02053210
thumb_func_start sub_0205323C
sub_0205323C: ; 0x0205323C
push {r3, r4, r5, lr}
add r4, r0, #0
mov r1, #0x40
mov r2, #5
bl sub_0205E0BC
str r0, [r4, #0x3c]
add r0, r4, #0
bl sub_0203B9F4
ldr r0, [r4, #0xc]
bl Save_FlyPoints_get
bl sub_0203B9B4
add r5, r0, #0
ldr r0, [r4, #0xc]
bl Sav2_PlayerData_GetProfileAddr
bl PlayerProfile_GetTrainerGender
add r2, r0, #0
ldr r0, [r4, #0x3c]
add r1, r5, #0
bl sub_0205C408
str r0, [r4, #0x40]
ldr r1, [r4, #0x20]
ldr r0, [r4, #0x3c]
ldr r1, [r1]
bl sub_02069B74
ldr r0, [r4, #0x3c]
bl sub_0205F55C
pop {r3, r4, r5, pc}
thumb_func_end sub_0205323C
thumb_func_start sub_02053284
sub_02053284: ; 0x02053284
push {r3, r4, r5, lr}
add r4, r0, #0
bl sub_02052F30
ldr r0, [r4, #0x60]
cmp r0, #0
beq _02053296
bl GF_AssertFail
_02053296:
ldr r0, [r4, #0x20]
ldr r1, [r4, #0x30]
ldr r0, [r0]
bl MapMatrix_Load
ldr r0, [r4, #0xc]
bl SavArray_Flags_get
mov r1, #0
add r5, r0, #0
bl sub_02066C74
cmp r0, #0
beq _020532B8
ldr r0, [r4, #0x30]
bl RemoveMahoganyTownAntennaTree
_020532B8:
add r0, r5, #0
mov r1, #1
bl sub_02066C74
add r1, r0, #0
ldr r0, [r4, #0x30]
bl SetLakeOfRageWaterLevel
ldr r0, [r4, #0x30]
ldr r1, [r4, #0xc]
bl PlaceSafariZoneAreas
ldr r0, [r4, #0x70]
cmp r0, #6
blt _020532DA
bl GF_AssertFail
_020532DA:
ldr r0, [r4, #0x70]
ldr r1, _02053320 ; =_020FC5CC
lsl r0, r0, #3
add r0, r1, r0
str r0, [r4, #0x74]
ldr r0, [r0]
lsl r0, r0, #0x18
lsr r0, r0, #0x1c
str r0, [r4, #0x64]
ldr r0, [r4, #0x74]
ldr r0, [r0]
lsl r0, r0, #0x1c
lsr r0, r0, #0x1c
str r0, [r4, #0x18]
ldr r1, [r4, #0x74]
add r0, r4, #0
ldr r1, [r1]
add r0, #0x60
lsl r1, r1, #0x14
lsr r1, r1, #0x1c
bl sub_0205489C
ldr r0, [r4, #0x74]
ldr r1, [r0]
lsl r0, r1, #0xc
lsr r0, r0, #0x1c
beq _0205331C
lsr r1, r1, #0x18
lsl r1, r1, #0x18
add r0, r4, #0
lsr r1, r1, #0x18
bl sub_02054514
_0205331C:
pop {r3, r4, r5, pc}
nop
_02053320: .word _020FC5CC
thumb_func_end sub_02053284
thumb_func_start sub_02053324
sub_02053324: ; 0x02053324
push {r4, lr}
add r4, r0, #0
ldr r0, [r4, #0x60]
cmp r0, #0
bne _02053332
bl GF_AssertFail
_02053332:
mov r0, #0
str r0, [r4, #0x60]
mov r0, #7
str r0, [r4, #0x18]
ldr r0, [r4, #0x74]
ldr r0, [r0]
lsl r0, r0, #0xc
lsr r0, r0, #0x1c
beq _0205334A
add r0, r4, #0
bl sub_0205453C
_0205334A:
mov r0, #0
str r0, [r4, #0x74]
pop {r4, pc}
thumb_func_end sub_02053324
thumb_func_start sub_02053350
sub_02053350: ; 0x02053350
push {r4, r5, r6, lr}
add r4, r1, #0
add r5, r0, #0
ldr r0, [r4, #0x40]
bl GetPlayerYCoord
add r6, r0, #0
ldr r0, [r4, #0x40]
bl GetPlayerXCoord
ldr r1, [r4, #0x20]
ldr r1, [r1]
str r1, [r5]
mov r1, #0
mvn r1, r1
str r1, [r5, #4]
str r0, [r5, #8]
str r6, [r5, #0xc]
mov r0, #1
str r0, [r5, #0x10]
pop {r4, r5, r6, pc}
.balign 4, 0
thumb_func_end sub_02053350
thumb_func_start sub_0205337C
sub_0205337C: ; 0x0205337C
push {r4, lr}
add r4, r0, #0
ldr r0, [r4, #0x20]
ldr r0, [r0]
bl MapHeader_MapIsPokemonCenter
cmp r0, #0
beq _0205339E
ldr r1, [r4, #0x20]
ldr r0, [r1, #8]
cmp r0, #6
bne _0205339E
ldr r0, [r1, #0xc]
cmp r0, #6
bne _0205339E
mov r0, #1
pop {r4, pc}
_0205339E:
ldr r0, [r4, #0x20]
ldr r0, [r0]
bl MapHeader_MapIsPokemonLeagueLobby
cmp r0, #0
beq _020533BC
ldr r1, [r4, #0x20]
ldr r0, [r1, #8]
cmp r0, #3
bne _020533BC
ldr r0, [r1, #0xc]
cmp r0, #0xf
bne _020533BC
mov r0, #1
pop {r4, pc}
_020533BC:
mov r0, #0
pop {r4, pc}
thumb_func_end sub_0205337C
thumb_func_start sub_020533C0
sub_020533C0: ; 0x020533C0
push {r3, r4, r5, lr}
add r5, r0, #0
ldr r0, [r5, #0xc]
bl Save_FlyPoints_get
bl FlyPoints_GetDynamicWarp
add r4, r0, #0
ldr r0, [r5, #0xc]
bl SavArray_Flags_get
ldr r0, [r5, #0x20]
ldr r0, [r0]
bl MapHeader_MapIsPokemonLeagueLobby
cmp r0, #1
ldr r0, [r5, #0x20]
bne _020533FC
ldr r0, [r0]
str r0, [r4]
mov r0, #0
mvn r0, r0
str r0, [r4, #4]
mov r0, #4
str r0, [r4, #8]
mov r0, #0xb
str r0, [r4, #0xc]
mov r0, #1
str r0, [r4, #0x10]
pop {r3, r4, r5, pc}
_020533FC:
ldr r0, [r0]
str r0, [r4]
mov r0, #0
mvn r0, r0
str r0, [r4, #4]
mov r0, #7
str r0, [r4, #8]
mov r0, #2
str r0, [r4, #0xc]
mov r0, #1
str r0, [r4, #0x10]
pop {r3, r4, r5, pc}
thumb_func_end sub_020533C0
thumb_func_start sub_02053414
sub_02053414: ; 0x02053414
push {r4, r5, r6, lr}
add r6, r0, #0
bl TaskManager_GetSys
add r5, r0, #0
add r0, r6, #0
bl TaskManager_GetStatePtr
add r4, r0, #0
ldr r0, [r4]
cmp r0, #0
beq _02053436
cmp r0, #1
beq _0205345A
cmp r0, #2
beq _02053468
b _0205346C
_02053436:
ldr r1, [r5, #0x20]
add r0, r5, #0
bl sub_02052F94
add r0, r5, #0
bl sub_02053284
add r0, r5, #0
mov r1, #0
bl sub_02053038
add r0, r5, #0
bl sub_0205316C
ldr r0, [r4]
add r0, r0, #1
str r0, [r4]
b _0205346C
_0205345A:
add r0, r6, #0
bl sub_02055408
ldr r0, [r4]
add r0, r0, #1
str r0, [r4]
b _0205346C
_02053468:
mov r0, #1
pop {r4, r5, r6, pc}
_0205346C:
mov r0, #0
pop {r4, r5, r6, pc}
thumb_func_end sub_02053414
thumb_func_start CallFieldTask_NewGame
CallFieldTask_NewGame: ; 0x02053470
push {r4, lr}
add r4, r0, #0
mov r1, #0
str r1, [r4, #0x70]
bl RunInitScript
ldr r1, _02053488 ; =sub_02053414
add r0, r4, #0
mov r2, #0
bl FieldSys_CreateTask
pop {r4, pc}
.balign 4, 0
_02053488: .word sub_02053414
thumb_func_end CallFieldTask_NewGame
thumb_func_start sub_0205348C
sub_0205348C: ; 0x0205348C
push {r3, r4, r5, r6, r7, lr}
add r6, r0, #0
bl TaskManager_GetSys
add r4, r0, #0
ldr r0, [r4, #0xc]
bl SavArray_Flags_get
add r7, r0, #0
add r0, r6, #0
bl TaskManager_GetStatePtr
add r5, r0, #0
ldr r0, [r5]
cmp r0, #0
beq _020534B6
cmp r0, #2
beq _02053528
cmp r0, #3
beq _02053534
b _02053538
_020534B6:
add r0, r7, #0
bl CheckFlag966
cmp r0, #0
beq _02053502
ldr r0, [r4, #0xc]
bl Save_FlyPoints_get
add r6, r0, #0
add r0, r4, #0
bl sub_0205337C
cmp r0, #0
beq _020534D8
add r0, r4, #0
bl sub_020533C0
_020534D8:
add r0, r7, #0
bl ClearFlag966
add r0, r6, #0
bl FlyPoints_GetDynamicWarp
add r1, r0, #0
add r0, r4, #0
bl sub_02052F94
add r0, r4, #0
bl sub_02053284
add r0, r4, #0
mov r1, #0
bl sub_02053038
add r0, r4, #0
bl sub_0205316C
b _0205351C
_02053502:
add r0, r4, #0
mov r1, #0
bl sub_02052F94
add r0, r4, #0
bl sub_02053284
add r0, r4, #0
bl FieldSys_StartBugContestTimer
add r0, r4, #0
bl sub_0205323C
_0205351C:
add r0, r4, #0
bl sub_02067BE8
mov r0, #2
str r0, [r5]
b _02053538
_02053528:
add r0, r6, #0
bl sub_02055408
mov r0, #3
str r0, [r5]
b _02053538
_02053534:
mov r0, #1
pop {r3, r4, r5, r6, r7, pc}
_02053538:
mov r0, #0
pop {r3, r4, r5, r6, r7, pc}
thumb_func_end sub_0205348C
thumb_func_start CallFieldTask_ContinueGame_Normal
CallFieldTask_ContinueGame_Normal: ; 0x0205353C
ldr r3, _02053548 ; =FieldSys_CreateTask
mov r2, #0
str r2, [r0, #0x70]
ldr r1, _0205354C ; =sub_0205348C
bx r3
nop
_02053548: .word FieldSys_CreateTask
_0205354C: .word sub_0205348C
thumb_func_end CallFieldTask_ContinueGame_Normal
thumb_func_start sub_02053550
sub_02053550: ; 0x02053550
push {r3, r4, r5, r6, r7, lr}
add r7, r0, #0
bl TaskManager_GetSys
add r5, r0, #0
add r0, r7, #0
bl TaskManager_GetEnv
add r6, r0, #0
ldr r0, [r5, #0xc]
bl SavArray_Flags_get
add r0, r7, #0
bl TaskManager_GetStatePtr
add r4, r0, #0
ldr r0, [r4]
cmp r0, #5
bhi _0205361C
add r1, r0, r0
add r1, pc
ldrh r1, [r1, #6]
lsl r1, r1, #0x10
asr r1, r1, #0x10
add pc, r1
_02053582: ; jump table
.short _0205358E - _02053582 - 2 ; case 0
.short _020535A6 - _02053582 - 2 ; case 1
.short _020535CA - _02053582 - 2 ; case 2
.short _020535F2 - _02053582 - 2 ; case 3
.short _02053606 - _02053582 - 2 ; case 4
.short _02053612 - _02053582 - 2 ; case 5
_0205358E:
mov r0, #0
add r1, r0, #0
bl sub_0200FBF4
mov r0, #1
mov r1, #0
bl sub_0200FBF4
ldr r0, [r4]
add r0, r0, #1
str r0, [r4]
b _0205361C
_020535A6:
add r0, r5, #0
add r1, r6, #4
bl sub_02052F94
add r0, r5, #0
bl sub_02053284
add r0, r5, #0
mov r1, #0
bl sub_02053038
add r0, r5, #0
bl sub_0205316C
ldr r0, [r4]
add r0, r0, #1
str r0, [r4]
b _0205361C
_020535CA:
add r0, r5, #0
bl sub_02059DB0
add r1, r5, #0
add r1, #0x80
str r0, [r1]
add r0, r5, #0
add r0, #0x80
ldr r0, [r0]
bl sub_0205AC88
add r5, #0x84
str r0, [r5]
add r0, r7, #0
bl sub_020552A4
ldr r0, [r4]
add r0, r0, #1
str r0, [r4]
b _0205361C
_020535F2:
mov r1, #0
str r1, [r6]
add r0, r5, #0
add r2, r6, #0
bl ov01_021F35C4
ldr r0, [r4]
add r0, r0, #1
str r0, [r4]
b _0205361C
_02053606:
ldr r1, [r6]
cmp r1, #0
beq _0205361C
add r0, r0, #1
str r0, [r4]
b _0205361C
_02053612:
add r0, r6, #0
bl FreeToHeap
mov r0, #1
pop {r3, r4, r5, r6, r7, pc}
_0205361C:
mov r0, #0
pop {r3, r4, r5, r6, r7, pc}
thumb_func_end sub_02053550
thumb_func_start CallFieldTask_ContinueGame_CommError
CallFieldTask_ContinueGame_CommError: ; 0x02053620
push {r3, r4, r5, lr}
add r4, r0, #0
ldr r0, [r4, #0x20]
ldr r0, [r0]
bl MapHeader_MapIsUnionRoom
cmp r0, #0
bne _02053658
add r0, r4, #0
bl sub_0205337C
cmp r0, #0
beq _02053650
ldr r0, [r4, #0xc]
bl SavArray_Flags_get
add r5, r0, #0
add r0, r4, #0
bl sub_020533C0
add r0, r5, #0
bl SetFlag966
b _02053658
_02053650:
add r0, r4, #0
bl CallFieldTask_ContinueGame_Normal
pop {r3, r4, r5, pc}
_02053658:
mov r0, #0xb
mov r1, #0x18
bl AllocFromHeapAtEnd
add r2, r0, #0
mov r3, #0
mov r1, #2
str r3, [r2]
str r1, [r2, #4]
sub r0, r1, #3
str r0, [r2, #8]
mov r0, #8
str r0, [r2, #0xc]
mov r0, #0xe
str r0, [r2, #0x10]
str r3, [r2, #0x14]
str r1, [r4, #0x70]
ldr r1, _02053684 ; =sub_02053550
add r0, r4, #0
bl FieldSys_CreateTask
pop {r3, r4, r5, pc}
.balign 4, 0
_02053684: .word sub_02053550
thumb_func_end CallFieldTask_ContinueGame_CommError
.public sub_02052F30
.public sub_02052F94
.public sub_02053018
.public sub_0205316C
.public sub_02053210
.public sub_0205323C
.public sub_02053284
.public sub_02053324
.public sub_02053350
.public sub_0205337C
.public sub_020533C0
.public sub_02053414
.public sub_0205348C
.public sub_02053550
thumb_func_start sub_02053688
sub_02053688: ; 0x02053688

View File

@ -28157,7 +28157,7 @@ FS_EXTERN_OVERLAY(OV_101)
.public FlyPoints_SetDynamicWarp
.public sub_0203B980
.public sub_0203B984
.public sub_0203B98C
.public FlyPoints_SetWeatherType
.public FlyPoints_GetDeathSpawn
.public FlyPoints_SetDeathSpawn
.public FlyPoints_GetCameraType
@ -28176,7 +28176,7 @@ FS_EXTERN_OVERLAY(OV_101)
.public MapHeader_GetSpawnIdForDeathWarp
.public sub_0203BB50
.public FlypointFlagAction
.public sub_0203BBB4
.public Fsys_GetWeather_HandleDiamondDust
.public sub_0203BC10
.public sub_0203BC28
.public sub_0203BCDC

View File

@ -23,8 +23,8 @@
typedef struct MonthDay {
u8 month;
u8 day;
};
} MonthDay;
u32 sub_0203BBB4(FieldSystem* fsys, u32 mapId);
u32 Fsys_GetWeather_HandleDiamondDust(FieldSystem* fsys, u32 mapId);
#endif //POKEHEARTGOLD_DIAMOND_DUST_H

View File

@ -87,5 +87,9 @@ void sub_0205F6E0(LocalMapObject *mapObject, BOOL enable_bit);
void sub_0205E5EC(FieldSystem *fsys, MapObjectMan *mapObjectMan, struct SavStructUnk10Sub *a2, int a3);
void sub_0205E648(MapObjectMan *mapObjectMan, struct SavStructUnk10Sub *a2, int a3);
struct SavStructUnk10Sub *sub_0205FD00(struct SavStructUnk10Sub *a0, int a1, u16 a2);
MapObjectMan *sub_0205E0BC(FieldSystem*fsys, int num, HeapID heapId);
void sub_0205F55C(MapObjectMan *man);
void sub_0205E494(MapObjectMan *man);
void sub_0205E0E8(MapObjectMan *man);
#endif //POKEHEARTGOLD_FIELD_MAP_OBJECT_H

View File

@ -2,6 +2,7 @@
#define POKEHEARTGOLD_FIELD_PLAYER_AVATAR_H
typedef struct FIELD_PLAYER_AVATAR FIELD_PLAYER_AVATAR;
typedef struct MapObjectMan MapObjectMan;
struct FlypointsPlayerSub {
u16 unk0;
@ -14,5 +15,9 @@ void sub_0205C7BC(struct FlypointsPlayerSub *vec);
int GetPlayerXCoord(FIELD_PLAYER_AVATAR *avatar);
int GetPlayerYCoord(FIELD_PLAYER_AVATAR *avatar);
u32 sub_0205C700(FIELD_PLAYER_AVATAR *avatar);
FIELD_PLAYER_AVATAR *sub_0205C390(MapObjectMan *man, int x, int y, int direction, int a4, int gender, int a6, struct FlypointsPlayerSub *a7);
FIELD_PLAYER_AVATAR *sub_0205C408(MapObjectMan *man, struct FlypointsPlayerSub *a1, int gender);
void sub_0205C4CC(FIELD_PLAYER_AVATAR *avatar);
void sub_0205C4C4(FIELD_PLAYER_AVATAR *avatar);
#endif //POKEHEARTGOLD_FIELD_PLAYER_AVATAR_H

View File

@ -6,24 +6,25 @@
#include "heap.h"
#include "map_header.h"
u32 Field_GetNumBgEvents(const FieldSystem *fsys);
BG_EVENT *Field_GetBgEvents(FieldSystem *fsys);
u8 *MapEvents_GetScriptHeader(FieldSystem *fsys);
void Field_AllocateMapEvents(FieldSystem *work, HeapID heapId);
void Field_FreeMapEvents(FieldSystem *work);
void Field_InitMapEvents(FieldSystem *work, u32 mapno);
void MapEvents_ReadFromNarc(MAP_EVENTS *events, u32 mapno);
void Field_InitMapObjectsFromZoneEventData(FieldSystem *fsys);
BG_EVENT *Field_GetBgEvents(FieldSystem *fsys);
u32 Field_GetNumBgEvents(const FieldSystem *fsys);
const WARP_EVENT *Field_GetWarpEventI(const FieldSystem *fsys, u32 warpno);
int Field_GetWarpEventAtXYPos(const FieldSystem *fsys, int x, int y);
u32 Field_GetNumCoordEvents(const FieldSystem *fsys);
const COORD_EVENT *Field_GetCoordEvents(const FieldSystem *fsys);
u32 Field_GetNumObjectEvents(const FieldSystem *fsys);
const OBJECT_EVENT *Field_GetObjectEvents(const FieldSystem *fsys);
BOOL Field_SetObjectEventXYPos(FieldSystem *fsys, int id, u16 x, u16 y);
BOOL Field_SetObjectEventFacing(FieldSystem *fsys, int id, u16 dirn);
BOOL Field_SetObjectEventMovement(FieldSystem *fsys, int id, u16 mvt);
BOOL Field_SetWarpXYPos(FieldSystem *fsys, int warpno, u16 x, u16 y);
BOOL Field_SetBgEventXYPos(FieldSystem *fsys, int bgno, u32 x, u32 y);
void MapEvents_ComputeRamHeader(MAP_EVENTS *events);
void WildEncounters_ReadFromNarc(ENC_DATA *encData, u32 mapno);
void MapScriptHeader_ReadFromNarc(MAP_EVENTS *events, u32 mapno);
ENC_DATA *MapEvents_GetLoadedEncTable(FieldSystem *fsys);
u8 *MapEvents_GetScriptHeader(FieldSystem *fsys);
#endif //POKEHEARTGOLD_MAP_EVENTS_H

13
include/overlay_01.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef POKEHEARTGOLD_OVERLAY_01_H
#define POKEHEARTGOLD_OVERLAY_01_H
#include "script.h"
struct ErrorContinueEnv {
int unk0;
Location location;
};
void ov01_021F35C4(FieldSystem *fsys, int a1, struct ErrorContinueEnv *env);
#endif //POKEHEARTGOLD_OVERLAY_01_H

View File

@ -19,11 +19,11 @@ Location *FlyPoints_GetDynamicWarp(FLYPOINTS_SAVE *flypointsSave);
void FlyPoints_SetDynamicWarp(FLYPOINTS_SAVE *flypointsSave, const Location *location);
u16 *sub_0203B980(FLYPOINTS_SAVE *flypointsSave);
u16 sub_0203B984(FLYPOINTS_SAVE *flypointsSave);
void sub_0203B98C(FLYPOINTS_SAVE *flypointsSave, const u16 a1);
void FlyPoints_SetWeatherType(FLYPOINTS_SAVE *flypointsSave, const u16 a1);
u16 FlyPoints_GetDeathSpawn(FLYPOINTS_SAVE *flypointsSave);
void FlyPoints_SetDeathSpawn(FLYPOINTS_SAVE *flypointsSave, const u16 spawn);
u8 FlyPoints_GetCameraType(FLYPOINTS_SAVE *flypointsSave);
void FlyPoints_SetCameraType(FLYPOINTS_SAVE *flypointsSave, const u8 a1);
u32 FlyPoints_GetCameraType(FLYPOINTS_SAVE *flypointsSave);
void FlyPoints_SetCameraType(FLYPOINTS_SAVE *flypointsSave, const u32 cameraType);
struct FlypointsPlayerSub *sub_0203B9B4(FLYPOINTS_SAVE *flypointsSave);
u16 *FlyPoints_GetSafariBallsCounter(FLYPOINTS_SAVE *flypointsSave);
u16 *FlyPoints_GetSafariStepsCounter(FLYPOINTS_SAVE *flypointsSave);

View File

@ -175,6 +175,22 @@ struct FieldSystemUnkSub0 {
BOOL unkC;
};
struct UnkStruct_020FC5CC {
u32 unk0_00:4;
u32 unk0_04:4;
u32 unk0_08:4;
u32 unk0_0C:4;
u32 unk0_10:4;
u32 unk0_14:4;
u32 unk0_18:8;
u8 unk_4;
u8 unk_5;
u8 unk_6;
};
struct UnkStruct_02059E1C;
struct UnkStruct_0205AC88;
struct FieldSystem {
struct FieldSystemUnkSub0 *unk0;
void *unk4;
@ -182,16 +198,28 @@ struct FieldSystem {
SAVEDATA* savedata;
TaskManager* taskman;
MAP_EVENTS* map_events;
u8 unk18[0x8];
int unk18;
int unk1C;
Location* location;
u8 unk24[0xC];
u8 filler24[0xC];
MAPMATRIX* map_matrix;
u8 unk34[0x8];
u8 filler34[0x8];
MapObjectMan* unk3C;
FIELD_PLAYER_AVATAR *playerAvatar;
u8 unk44[0x28];
u8 filler44[0x1C];
u32 unk60;
int unk64;
int unk68;
u32 unk6C;
u8 filler_70[0x3C];
int unk70;
const struct UnkStruct_020FC5CC *unk74;
u16 unk78;
u16 unk7A;
u16 unk7C;
u16 unk7E;
struct UnkStruct_02059E1C *unk80;
struct UnkStruct_0205AC88 *unk84;
u8 filler_88[0x24];
u32 unkAC;
u8 unkB0[0x4];
s64 unkB4;

View File

@ -6,5 +6,6 @@
u16 GetMomSpawnId(void);
void GetDeathWarpData(u16 spawnId, Location *dest);
void GetSpecialSpawnWarpData(u16 spawnId, Location *dest);
u32 MapHeader_GetSpawnIdForDeathWarp(u32 mapId);
#endif //POKEHEARTGOLD_UNK_0203BA5C_H

9
include/unk_02054514.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef POKEHEARTGOLD_UNK_02054514_H
#define POKEHEARTGOLD_UNK_02054514_H
#include "script.h"
void sub_02054514(FieldSystem *fsys, u8 a1);
void sub_0205453C(FieldSystem *fsys);
#endif //POKEHEARTGOLD_UNK_02054514_H

6
include/unk_02054648.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef POKEHEARTGOLD_UNK_02054648_H
#define POKEHEARTGOLD_UNK_02054648_H
void sub_0205489C(u32 *a0, int a1);
#endif //POKEHEARTGOLD_UNK_02054648_H

View File

@ -1,6 +1,9 @@
#ifndef POKEHEARTGOLD_UNK_02054E00_H
#define POKEHEARTGOLD_UNK_02054E00_H
#include "script.h"
void sub_02054F14(void);
void sub_02054F4C(FieldSystem *fsys);
#endif //POKEHEARTGOLD_UNK_02054E00_H

8
include/unk_02055244.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef POKEHEARTGOLD_UNK_02055244_H
#define POKEHEARTGOLD_UNK_02055244_H
#include "task.h"
void sub_02055408(TaskManager *taskManager);
#endif //POKEHEARTGOLD_UNK_02055244_H

6
include/unk_02056D7C.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef POKEHEARTGOLD_UNK_02056D7C_H
#define POKEHEARTGOLD_UNK_02056D7C_H
void sub_02056E38(void);
#endif //POKEHEARTGOLD_UNK_02056D7C_H

8
include/unk_02058AEC.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef POKEHEARTGOLD_UNK_02058AEC_H
#define POKEHEARTGOLD_UNK_02058AEC_H
#include "script.h"
struct UnkStruct_02059E1C *sub_02059DB0(FieldSystem *fsys);
#endif //POKEHEARTGOLD_UNK_02058AEC_H

8
include/unk_0205AC88.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef POKEHEARTGOLD_UNK_0205AC88_H
#define POKEHEARTGOLD_UNK_0205AC88_H
#include "script.h"
struct UnkStruct_0205AC88 *sub_0205AC88(struct UnkStruct_02059E1C *a0);
#endif //POKEHEARTGOLD_UNK_0205AC88_H

View File

@ -4,5 +4,8 @@
#include "script.h"
void Fsys_ClearFollowingTrainer(FieldSystem *fsys);
void sub_02067AE4(FieldSystem *fsys);
void sub_02067A88(FieldSystem *fsys);
void sub_02067BE8(FieldSystem *fsys);
#endif //POKEHEARTGOLD_UNK_0206793C_H

View File

@ -184,7 +184,8 @@ Static main
Object asm/unk_020518D8.o
Object src/field_black_out.o
Object asm/unk_0205298C.o
Object asm/unk_02052F30.o
Object src/unk_02052F30.o
Object asm/unk_02052F30_s.o
Object src/script_pokemon_util.o
Object asm/unk_02054514.o
Object asm/unk_02054648.o

View File

@ -3,7 +3,7 @@
#include "unk_02055418.h"
#include "constants/maps.h"
const struct MonthDay DiamondDustDates[] = {
const MonthDay DiamondDustDates[] = {
{ JANUARY, 1 },
{ JANUARY, 31 },
{ FEBRUARY, 1 },
@ -14,7 +14,7 @@ const struct MonthDay DiamondDustDates[] = {
{ DECEMBER, 31 },
}; //_020FA09C
u32 sub_0203BBB4(FieldSystem* fsys, u32 mapId) {
u32 Fsys_GetWeather_HandleDiamondDust(FieldSystem* fsys, u32 mapId) {
u8 c;
u32 weatherType = MapHeader_GetWeatherType(mapId);

View File

@ -2,10 +2,9 @@
#include "filesystem.h"
#include "encounter_tables_narc.h"
void MapEvents_ReadFromNarc(MAP_EVENTS *events, u32 mapno);
void MapEvents_ComputeRamHeader(MAP_EVENTS *events);
void WildEncounters_ReadFromNarc(ENC_DATA *encounters, u32 mapno);
void MapScriptHeader_ReadFromNarc(MAP_EVENTS *events, u32 mapno);
static void MapEvents_ReadFromNarc(MAP_EVENTS *events, u32 mapno);
static void MapEvents_ComputeRamHeader(MAP_EVENTS *events);
static void MapScriptHeader_ReadFromNarc(MAP_EVENTS *events, u32 mapno);
extern void InitMapObjectsFromEventTemplates(MapObjectMan*, int, u32, OBJECT_EVENT*);
@ -27,7 +26,7 @@ void Field_InitMapEvents(FieldSystem *work, u32 mapno) {
MapScriptHeader_ReadFromNarc(work->map_events, mapno);
}
void MapEvents_ReadFromNarc(MAP_EVENTS *events, u32 mapno) {
static void MapEvents_ReadFromNarc(MAP_EVENTS *events, u32 mapno) {
int bank = MapHeader_GetEventsBank(mapno);
GF_ASSERT(GetNarcMemberSizeByIdPair(NARC_fielddata_eventdata_zone_event, bank) < sizeof(events->event_data));
ReadWholeNarcMemberByIdPair(events->event_data, NARC_fielddata_eventdata_zone_event, bank);
@ -149,7 +148,7 @@ BOOL Field_SetBgEventXYPos(FieldSystem *fsys, int bgno, u32 x, u32 y) {
return TRUE;
}
void MapEvents_ComputeRamHeader(MAP_EVENTS *events) {
static void MapEvents_ComputeRamHeader(MAP_EVENTS *events) {
u8 *ptr = events->event_data;
events->num_bg_events = *(u32 *)ptr;
@ -200,7 +199,7 @@ ENC_DATA *MapEvents_GetLoadedEncTable(FieldSystem *fsys) {
return &fsys->map_events->wildEncounters;
}
void MapScriptHeader_ReadFromNarc(MAP_EVENTS *events, u32 mapno) {
static void MapScriptHeader_ReadFromNarc(MAP_EVENTS *events, u32 mapno) {
int bank = MapHeader_GetScriptHeaderBank(mapno);
MI_CpuClearFast(events->script_header, sizeof(events->script_header));
GF_ASSERT(GetNarcMemberSizeByIdPair(NARC_fielddata_script_scr_seq, bank) < sizeof(events->script_header));

View File

@ -12,7 +12,7 @@ struct FLYPOINTS_SAVE {
Location dynamicWarp;
Location specialSpawn;
u16 unk64;
u16 unk66;
u16 weather;
u16 lastSpawn;
u8 cameraType;
struct FlypointsPlayerSub unk6C;
@ -73,11 +73,11 @@ u16 *sub_0203B980(FLYPOINTS_SAVE *flypointsSave) {
}
u16 sub_0203B984(FLYPOINTS_SAVE *flypointsSave) {
return flypointsSave->unk66;
return flypointsSave->weather;
}
void sub_0203B98C(FLYPOINTS_SAVE *flypointsSave, const u16 a1) {
flypointsSave->unk66 = a1;
void FlyPoints_SetWeatherType(FLYPOINTS_SAVE *flypointsSave, const u16 a1) {
flypointsSave->weather = a1;
}
u16 FlyPoints_GetDeathSpawn(FLYPOINTS_SAVE *flypointsSave) {
@ -88,11 +88,11 @@ void FlyPoints_SetDeathSpawn(FLYPOINTS_SAVE *flypointsSave, const u16 spawn) {
flypointsSave->lastSpawn = spawn;
}
u8 FlyPoints_GetCameraType(FLYPOINTS_SAVE *flypointsSave) {
u32 FlyPoints_GetCameraType(FLYPOINTS_SAVE *flypointsSave) {
return flypointsSave->cameraType;
}
void FlyPoints_SetCameraType(FLYPOINTS_SAVE *flypointsSave, const u8 cameraType) {
void FlyPoints_SetCameraType(FLYPOINTS_SAVE *flypointsSave, const u32 cameraType) {
flypointsSave->cameraType = cameraType;
}

394
src/unk_02052F30.c Normal file
View File

@ -0,0 +1,394 @@
#include "script.h"
#include "save_flypoints.h"
#include "map_events.h"
#include "system.h"
#include "bug_contest.h"
#include "event_data.h"
#include "sys_vars.h"
#include "sys_flags.h"
#include "save_follow_poke.h"
#include "unk_02054E00.h"
#include "unk_0206793C.h"
#include "unk_0203BA5C.h"
#include "field_map_object.h"
#include "field_follow_poke.h"
#include "unk_02056D7C.h"
#include "diamond_dust.h"
#include "task.h"
#include "unk_02055244.h"
#include "unk_02054514.h"
#include "unk_02054648.h"
#include "unk_0200FA24.h"
#include "unk_020552A4.h"
#include "unk_02058AEC.h"
#include "unk_0205AC88.h"
#include "overlay_01.h"
#include "constants/maps.h"
extern const struct UnkStruct_020FC5CC _020FC5CC[6];
void sub_02052F30(FieldSystem *fsys) {
BOOL r2 = FALSE;
switch (fsys->location->mapId) {
case MAP_D47R0102:
fsys->unk70 = 1;
return;
case MAP_D31R0201:
case MAP_D31R0202:
case MAP_D31R0203:
case MAP_D31R0204:
case MAP_D31R0205:
case MAP_D31R0206:
case MAP_D31R0207:
r2 = TRUE;
break;
}
if (fsys->unk70 == 1) {
fsys->unk70 = 0;
}
if (!r2 && fsys->unk70 == 4) {
fsys->unk70 = 0;
}
if (r2) {
fsys->unk70 = 4;
}
}
void sub_02052F94(FieldSystem *fsys, Location *location) {
FLYPOINTS_SAVE *flypointsSave = Save_FlyPoints_get(fsys->savedata);
Location *r2 = sub_0203B960(flypointsSave);
const WARP_EVENT *warp;
if (location != NULL) {
*r2 = *fsys->location;
*fsys->location = *location;
}
Field_InitMapEvents(fsys, fsys->location->mapId);
if (fsys->location->warpId != -1) {
warp = Field_GetWarpEventI(fsys, fsys->location->warpId);
fsys->location->x = warp->x;
fsys->location->z = warp->y;
if (warp->anchor == 0x100) {
*FlyPoints_GetDynamicWarp(flypointsSave) = *sub_0203B95C(flypointsSave);
}
}
}
void sub_02053018(FieldSystem *fsys) {
GF_ASSERT(fsys->unk70 < 6);
gSystem.screensFlipped = fsys->unk74->unk0_0C;
}
void sub_02053038(FieldSystem *fsys, BOOL isConnection) {
u32 mapId = fsys->location->mapId;
FLYPOINTS_SAVE *flyPoints = Save_FlyPoints_get(fsys->savedata);
SCRIPT_STATE *scriptState;
u16 weather;
u16 spawnId;
sub_02054F4C(fsys);
if (!fsys->unkAC) {
ClearTempFieldEventData(fsys);
}
if (!isConnection) {
sub_02067AE4(fsys);
} else {
sub_02067A88(fsys);
}
if (!fsys->unkAC && !isConnection) {
FieldSys_StartBugContestTimer(fsys);
}
if (!isConnection) {
SavGymmick_Clear(Sav2_GetGymmickPtr(fsys->savedata));
SetLakeOfRageWaterLevel(fsys->map_matrix, ShouldUseAlternateLakeOfRage(fsys->savedata, mapId));
}
scriptState = SavArray_Flags_get(fsys->savedata);
weather = Fsys_GetWeather_HandleDiamondDust(fsys, mapId);
if (sub_02066C74(scriptState, 1) && mapId == MAP_T29) {
weather = 0;
}
if (weather == 9 && CheckFlag974(scriptState) == TRUE) {
weather = 0;
}
if (weather == 11 && CheckFlag973(scriptState) == TRUE) {
weather = 12;
}
FlyPoints_SetWeatherType(flyPoints, weather);
if (isConnection) {
GF_ASSERT(FlyPoints_GetCameraType(flyPoints) == MapHeader_GetCameraType(mapId));
} else {
FlyPoints_SetCameraType(flyPoints, MapHeader_GetCameraType(mapId));
}
if (!isConnection) {
spawnId = MapHeader_GetSpawnIdForDeathWarp(mapId);
if (spawnId != 0) {
FlyPoints_SetDeathSpawn(flyPoints, spawnId);
}
}
TryStartMapScriptByType(fsys, 2);
fsys->unk7E = 0;
fsys->unk7C = 0;
fsys->unk78 = 0;
SavFollowPoke_SetInhibitFlagState(Sav2_FollowPoke_get(fsys->savedata), FALSE);
ClearFlag99A(SavArray_Flags_get(fsys->savedata));
}
void sub_0205316C(FieldSystem *fsys) {
u32 gender;
struct FlypointsPlayerSub *avatar_sub;
if (fsys->unkAC) {
gender = PlayerProfile_GetTrainerGender(Sav2_PlayerData_GetProfileAddr(fsys->savedata));
avatar_sub = sub_0203B9B4(Save_FlyPoints_get(fsys->savedata));
fsys->playerAvatar = sub_0205C390(fsys->unk3C, fsys->location->x, fsys->location->z, fsys->location->direction, avatar_sub->unk4, gender, 2, avatar_sub);
} else {
fsys->unk3C = sub_0205E0BC(fsys, 64, 5);
gender = PlayerProfile_GetTrainerGender(Sav2_PlayerData_GetProfileAddr(fsys->savedata));
avatar_sub = sub_0203B9B4(Save_FlyPoints_get(fsys->savedata));
fsys->playerAvatar = sub_0205C390(fsys->unk3C, fsys->location->x, fsys->location->z, fsys->location->direction, avatar_sub->unk4, gender, 2, avatar_sub);
sub_020699F8(fsys->unk3C, fsys->location->x, fsys->location->z, fsys->location->direction, fsys->location->mapId);
Field_InitMapObjectsFromZoneEventData(fsys);
sub_0205F55C(fsys->unk3C);
}
}
void sub_02053210(FieldSystem *fsys) {
if (fsys->unkAC) {
sub_0205C4CC(fsys->playerAvatar);
} else {
sub_02056E38();
sub_0205C4C4(fsys->playerAvatar);
sub_0205E494(fsys->unk3C);
sub_0205E0E8(fsys->unk3C);
}
}
void sub_0205323C(FieldSystem *fsys) {
u32 gender;
struct FlypointsPlayerSub *avatar_sub;
fsys->unk3C = sub_0205E0BC(fsys, 64, 5);
sub_0203B9F4(fsys);
avatar_sub = sub_0203B9B4(Save_FlyPoints_get(fsys->savedata));
gender = PlayerProfile_GetTrainerGender(Sav2_PlayerData_GetProfileAddr(fsys->savedata));
fsys->playerAvatar = sub_0205C408(fsys->unk3C, avatar_sub, gender);
sub_02069B74(fsys->unk3C, fsys->location->mapId);
sub_0205F55C(fsys->unk3C);
}
void sub_02053284(FieldSystem *fsys) {
SCRIPT_STATE *scriptState;
sub_02052F30(fsys);
GF_ASSERT(fsys->unk60 == 0);
MapMatrix_Load(fsys->location->mapId, fsys->map_matrix);
scriptState = SavArray_Flags_get(fsys->savedata);
if (sub_02066C74(scriptState, 0)) {
RemoveMahoganyTownAntennaTree(fsys->map_matrix);
}
SetLakeOfRageWaterLevel(fsys->map_matrix, sub_02066C74(scriptState, 1));
PlaceSafariZoneAreas(fsys->map_matrix, fsys->savedata);
GF_ASSERT(fsys->unk70 < 6);
fsys->unk74 = &_020FC5CC[fsys->unk70];
fsys->unk64 = fsys->unk74->unk0_04;
fsys->unk18 = fsys->unk74->unk0_00;
sub_0205489C(&fsys->unk60, fsys->unk74->unk0_08);
if (fsys->unk74->unk0_10) {
sub_02054514(fsys, fsys->unk74->unk0_18);
}
}
void sub_02053324(FieldSystem *fsys) {
GF_ASSERT(fsys->unk60 != 0);
fsys->unk60 = 0;
fsys->unk18 = 7;
if (fsys->unk74->unk0_10) {
sub_0205453C(fsys);
}
fsys->unk74 = NULL;
}
void sub_02053350(Location *location, FieldSystem *fsys) {
int x, y;
y = GetPlayerYCoord(fsys->playerAvatar);
x = GetPlayerXCoord(fsys->playerAvatar);
location->mapId = fsys->location->mapId;
location->warpId = -1;
location->x = x;
location->z = y;
location->direction = 1;
}
// Is player standing in front of Union Room reception?
BOOL sub_0205337C(FieldSystem *fsys) {
if (MapHeader_MapIsPokemonCenter(fsys->location->mapId)
&& fsys->location->x == 6 && fsys->location->z == 6) {
return TRUE;
}
if (MapHeader_MapIsPokemonLeagueLobby(fsys->location->mapId)
&& fsys->location->x == 3 && fsys->location->z == 15) {
return TRUE;
}
return FALSE;
}
// Set dynamic warp to union room exit
void sub_020533C0(FieldSystem *fsys) {
Location *dynamicWarp = FlyPoints_GetDynamicWarp(Save_FlyPoints_get(fsys->savedata));
SCRIPT_STATE *scriptState = SavArray_Flags_get(fsys->savedata); // unused
if (MapHeader_MapIsPokemonLeagueLobby(fsys->location->mapId) == TRUE) {
dynamicWarp->mapId = fsys->location->mapId;
dynamicWarp->warpId = -1;
dynamicWarp->x = 4;
dynamicWarp->z = 11;
dynamicWarp->direction = 1;
} else {
dynamicWarp->mapId = fsys->location->mapId;
dynamicWarp->warpId = -1;
dynamicWarp->x = 7;
dynamicWarp->z = 2;
dynamicWarp->direction = 1;
}
}
BOOL sub_02053414(TaskManager *taskManager) {
FieldSystem *fsys = TaskManager_GetSys(taskManager);
u32 *state_p = TaskManager_GetStatePtr(taskManager);
switch (*state_p) {
case 0:
sub_02052F94(fsys, fsys->location);
sub_02053284(fsys);
sub_02053038(fsys, FALSE);
sub_0205316C(fsys);
(*state_p)++;
break;
case 1:
sub_02055408(taskManager);
(*state_p)++;
break;
case 2:
return TRUE;
}
return FALSE;
}
TaskManager *CallFieldTask_NewGame(FieldSystem *fsys) {
fsys->unk70 = 0;
RunInitScript(fsys);
return FieldSys_CreateTask(fsys, sub_02053414, NULL);
}
BOOL sub_0205348C(TaskManager *taskManager) {
FieldSystem *fsys = TaskManager_GetSys(taskManager);
SCRIPT_STATE *scriptState = SavArray_Flags_get(fsys->savedata);
FLYPOINTS_SAVE *flypointsSave;
u32 *state_p = TaskManager_GetStatePtr(taskManager);
switch (*state_p) {
case 0:
if (CheckFlag966(scriptState)) {
flypointsSave = Save_FlyPoints_get(fsys->savedata);
if (sub_0205337C(fsys)) {
sub_020533C0(fsys);
}
ClearFlag966(scriptState);
sub_02052F94(fsys, FlyPoints_GetDynamicWarp(flypointsSave));
sub_02053284(fsys);
sub_02053038(fsys, FALSE);
sub_0205316C(fsys);
} else {
sub_02052F94(fsys, NULL);
sub_02053284(fsys);
FieldSys_StartBugContestTimer(fsys);
sub_0205323C(fsys);
}
sub_02067BE8(fsys);
*state_p = 2;
break;
case 2:
sub_02055408(taskManager);
*state_p = 3;
break;
case 3:
return TRUE;
}
return FALSE;
}
TaskManager *CallFieldTask_ContinueGame_Normal(FieldSystem *fsys) {
fsys->unk70 = 0;
return FieldSys_CreateTask(fsys, sub_0205348C, NULL);
}
BOOL sub_02053550(TaskManager *taskManager) {
FieldSystem *fsys = TaskManager_GetSys(taskManager);
struct ErrorContinueEnv *env = TaskManager_GetEnv(taskManager);
SCRIPT_STATE *scriptState = SavArray_Flags_get(fsys->savedata);
FLYPOINTS_SAVE *flypointsSave;
u32 *state_p = TaskManager_GetStatePtr(taskManager);
switch (*state_p) {
case 0:
sub_0200FBF4(0, 0);
sub_0200FBF4(1, 0);
(*state_p)++;
break;
case 1:
sub_02052F94(fsys, &env->location);
sub_02053284(fsys);
sub_02053038(fsys, FALSE);
sub_0205316C(fsys);
(*state_p)++;
break;
case 2:
fsys->unk80 = sub_02059DB0(fsys);
fsys->unk84 = sub_0205AC88(fsys->unk80);
sub_020552A4(taskManager);
(*state_p)++;
break;
case 3:
env->unk0 = 0;
ov01_021F35C4(fsys, 0, env);
(*state_p)++;
break;
case 4:
if (env->unk0) {
(*state_p)++;
}
break;
case 5:
FreeToHeap(env);
return TRUE;
}
return FALSE;
}
TaskManager *CallFieldTask_ContinueGame_CommError(FieldSystem *fsys) {
SCRIPT_STATE *scriptState;
struct ErrorContinueEnv *env;
if (!MapHeader_MapIsUnionRoom(fsys->location->mapId)) {
if (sub_0205337C(fsys)) {
scriptState = SavArray_Flags_get(fsys->savedata);
sub_020533C0(fsys);
SetFlag966(scriptState);
} else {
return CallFieldTask_ContinueGame_Normal(fsys);
}
}
env = AllocFromHeapAtEnd(11, sizeof(struct ErrorContinueEnv));
env->unk0 = 00;
env->location.mapId = MAP_UNION;
env->location.warpId = -1;
env->location.x = 8;
env->location.z = 14;
env->location.direction = 0;
fsys->unk70 = 2;
return FieldSys_CreateTask(fsys, sub_02053550, env);
}