add important headers, const ptrs and egg hatch start

This commit is contained in:
DizzyEggg 2017-09-18 18:36:05 +02:00
parent 74bda5b680
commit c253bf5e75
37 changed files with 683 additions and 1000 deletions

View File

@ -585,7 +585,7 @@ sub_80B0AF8: @ 80B0AF8
_080B0B4C:
ldr r0, =c2_exit_to_overworld_2_switch
bl SetMainCallback2
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80AF6F0
str r0, [r1]
_080B0B58:

View File

@ -775,7 +775,7 @@ _08150340:
str r3, [r2, 0x8]
ldr r0, [r2, 0x8]
bl warp_in
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
str r4, [r0]
ldr r0, =c2_load_new_map
bl SetMainCallback2

View File

@ -5582,7 +5582,7 @@ sub_80DA830: @ 80DA830
bne _080DA860
adds r0, r2, 0
bl DestroyTask
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =sub_80DA874
str r1, [r0]
bl FreeAllWindowBuffers

View File

@ -5,8 +5,8 @@
.text
thumb_func_start pokemon_get_nick
pokemon_get_nick: @ 806FA2C
thumb_func_start GetMonNick
GetMonNick: @ 806FA2C
push {r4,lr}
sub sp, 0x14
adds r4, r1, 0
@ -20,10 +20,10 @@ pokemon_get_nick: @ 806FA2C
pop {r4}
pop {r1}
bx r1
thumb_func_end pokemon_get_nick
thumb_func_end GetMonNick
thumb_func_start pokemon_get_nick_
pokemon_get_nick_: @ 806FA4C
thumb_func_start GetBoxMonNick
GetBoxMonNick: @ 806FA4C
push {r4,lr}
sub sp, 0x14
adds r4, r1, 0
@ -37,7 +37,7 @@ pokemon_get_nick_: @ 806FA4C
pop {r4}
pop {r1}
bx r1
thumb_func_end pokemon_get_nick_
thumb_func_end GetBoxMonNick
thumb_func_start daycare_count_pokemon
daycare_count_pokemon: @ 806FA6C
@ -177,7 +177,7 @@ sub_806FB38: @ 806FB38
adds r4, 0x7C
adds r0, r6, 0
adds r1, r4, 0
bl pokemon_get_nick
bl GetMonNick
adds r0, r4, 0
bl StripExtCtrlCodes
adds r4, 0xB
@ -376,7 +376,7 @@ sub_806FCF8: @ 806FCF8
sub sp, 0x68
adds r5, r0, 0
ldr r1, =gStringVar1
bl pokemon_get_nick_
bl GetBoxMonNick
adds r0, r5, 0
movs r1, 0xB
bl GetBoxMonData
@ -547,7 +547,7 @@ sub_806FE54: @ 806FE54
bl ConvertIntToDecimalStringN
ldr r1, =gStringVar1
adds r0, r5, 0
bl pokemon_get_nick_
bl GetBoxMonNick
adds r0, r4, 0
pop {r4,r5}
pop {r1}
@ -565,7 +565,7 @@ sub_806FE88: @ 806FE88
lsrs r4, 24
ldr r1, =gStringVar1
adds r0, r5, 0
bl pokemon_get_nick_
bl GetBoxMonNick
movs r0, 0x64
muls r4, r0
adds r4, 0x64
@ -2280,7 +2280,7 @@ sub_8070C04: @ 8070C04
beq _08070C2E
ldr r1, =gStringVar1
adds r0, r4, 0
bl pokemon_get_nick_
bl GetBoxMonNick
adds r0, r4, 0
movs r1, 0x7
mov r2, sp
@ -2297,7 +2297,7 @@ _08070C2E:
beq _08070C44
ldr r1, =gStringVar2
adds r0, r4, 0
bl pokemon_get_nick_
bl GetBoxMonNick
_08070C44:
add sp, 0xC
pop {r4}
@ -2317,7 +2317,7 @@ sub_8070C58: @ 8070C58
ldr r4, =gPlayerParty
adds r0, r4
ldr r1, =gStringVar1
bl pokemon_get_nick_
bl GetBoxMonNick
bl brm_get_pokemon_selection
lsls r0, 24
lsrs r0, 24
@ -2788,7 +2788,7 @@ _08070FCC:
adds r5, r1, r0
adds r0, r4, 0
adds r1, r5, 0
bl pokemon_get_nick_
bl GetBoxMonNick
adds r0, r5, 0
adds r1, r4, 0
bl sub_8070F98
@ -2944,7 +2944,7 @@ sub_8071110: @ 8071110
adds r5, r0
adds r0, r5, 0
mov r1, sp
bl pokemon_get_nick_
bl GetBoxMonNick
mov r0, sp
adds r1, r5, 0
bl sub_8070F98

View File

@ -4149,7 +4149,7 @@ _08128C30:
bl sub_812A3C8
ldr r0, =0x00000be5
bl FreeSpritePaletteByTag
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_8128CD4
str r0, [r1]
ldr r0, =c2_exit_to_overworld_2_switch
@ -6907,7 +6907,7 @@ _0812A280:
.pool
_0812A29C:
bl sub_812A3C8
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =sub_812A334
str r1, [r0]
ldr r0, =c2_exit_to_overworld_2_switch

File diff suppressed because it is too large Load Diff

View File

@ -1945,7 +1945,7 @@ sub_80B69DC: @ 80B69DC
push {lr}
ldr r0, =c2_exit_to_overworld_2_switch
bl SetMainCallback2
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =mapldr_080842E8
str r0, [r1]
pop {r0}
@ -1962,7 +1962,7 @@ mapldr_080842E8: @ 80B69FC
bl CreateTask
bl ScriptContext2_Enable
bl player_bitmagic
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
movs r0, 0
str r0, [r1]
pop {r0}
@ -2012,7 +2012,7 @@ _080B6A64:
bl warp_in
ldr r0, =c2_load_new_map
bl SetMainCallback2
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =mapldr_08084390
str r0, [r1]
adds r0, r5, 0
@ -2058,7 +2058,7 @@ mapldr_08084390: @ 80B6AA4
_080B6AE6:
bl ScriptContext2_Enable
bl player_bitmagic
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
movs r0, 0
str r0, [r1]
pop {r4}
@ -2120,7 +2120,7 @@ sub_80B6B68: @ 80B6B68
ldr r0, =sub_80B6B94
movs r1, 0
bl CreateTask
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
movs r0, 0
str r0, [r1]
pop {r0}
@ -2761,7 +2761,7 @@ sub_80B7060: @ 80B7060
bne _080B709C
bl sub_80E1570
bl warp_in
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80B70B4
str r0, [r1]
ldr r0, =c2_load_new_map
@ -2786,7 +2786,7 @@ sub_80B70B4: @ 80B70B4
ldr r0, =sub_80B70DC
movs r1, 0
bl CreateTask
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
movs r0, 0
str r0, [r1]
pop {r0}
@ -3727,7 +3727,7 @@ sub_80B7814: @ 80B7814
cmp r0, 0x1
bne _080B784C
bl warp_in
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =mapldr_080851BC
str r0, [r1]
ldr r0, =c2_load_new_map
@ -3750,7 +3750,7 @@ mapldr_080851BC: @ 80B7868
bl sub_8085784
bl pal_fill_for_maplights
bl ScriptContext2_Enable
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
movs r1, 0
str r1, [r0]
ldr r0, =sub_80B7890
@ -4202,7 +4202,7 @@ sub_80B7BF4: @ 80B7BF4
cmp r0, 0x1
bne _080B7C2C
bl warp_in
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80B6B68
str r0, [r1]
ldr r0, =c2_load_new_map
@ -4399,7 +4399,7 @@ _080B7D86:
bl FieldObjectSetDirection
bl sub_8084E14
bl warp_in
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =mapldr_080859D4
str r0, [r1]
ldr r0, =c2_load_new_map
@ -4462,7 +4462,7 @@ mapldr_080859D4: @ 80B7E48
bl pal_fill_for_maplights
bl ScriptContext2_Enable
bl player_bitmagic
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
movs r0, 0
str r0, [r1]
ldr r2, =gMapObjects
@ -4885,7 +4885,7 @@ _080B81B8:
bl warp_in
ldr r0, =c2_load_new_map
bl SetMainCallback2
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =mapldr_08085D88
str r0, [r1]
ldr r0, =sub_80B7FDC
@ -4907,7 +4907,7 @@ mapldr_08085D88: @ 80B8200
bl pal_fill_for_maplights
bl ScriptContext2_Enable
bl player_bitmagic
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
movs r0, 0
str r0, [r1]
ldr r2, =gMapObjects

View File

@ -8725,7 +8725,7 @@ sub_80AF734: @ 80AF734
bl play_some_sound
movs r0, 0x9
bl PlaySE
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =mapldr_default
str r1, [r0]
ldr r0, =sub_80AFA0C
@ -8743,7 +8743,7 @@ sp13E_warp_to_last_warp: @ 80AF76C
bl music_something
bl sub_80AF0B4
bl play_some_sound
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =mapldr_default
str r1, [r0]
ldr r0, =sub_80AFA0C
@ -8763,7 +8763,7 @@ sub_80AF79C: @ 80AF79C
movs r1, 0x8
bl fade_screen
bl play_some_sound
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =sub_80AF3B0
str r1, [r0]
ldr r0, =sub_80AFA0C
@ -8778,7 +8778,7 @@ sub_80AF79C: @ 80AF79C
sub_80AF7D0: @ 80AF7D0
push {lr}
bl ScriptContext2_Enable
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =mapldr_default
str r1, [r0]
ldr r0, =sub_80AFA88
@ -8793,7 +8793,7 @@ sub_80AF7D0: @ 80AF7D0
sp13F_fall_to_last_warp: @ 80AF7F4
push {lr}
bl sp13E_warp_to_last_warp
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80B6B68
str r0, [r1]
pop {r0}
@ -8847,7 +8847,7 @@ sub_80AF848: @ 80AF848
ldr r0, =sub_80AFA0C
movs r1, 0xA
bl CreateTask
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80AF3E8
str r0, [r1]
pop {r0}
@ -8869,7 +8869,7 @@ sub_80AF87C: @ 80AF87C
ldr r0, =sub_80AFA0C
movs r1, 0xA
bl CreateTask
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80AF40C
str r0, [r1]
pop {r0}
@ -8885,7 +8885,7 @@ sub_80AF8B8: @ 80AF8B8
ldr r0, =sub_80AFA0C
movs r1, 0xA
bl CreateTask
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80FB768
str r0, [r1]
pop {r0}
@ -9328,7 +9328,7 @@ sub_80AFC60: @ 80AFC60
bl play_some_sound
movs r0, 0x9
bl PlaySE
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =sub_80AF3C8
str r1, [r0]
ldr r0, =task0A_fade_n_map_maybe
@ -10078,7 +10078,7 @@ sub_80B0244: @ 80B0244
ldr r0, =sub_80AFA0C
movs r1, 0xA
bl CreateTask
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80AF3E8
str r0, [r1]
pop {r0}
@ -10090,7 +10090,7 @@ sub_80B0244: @ 80B0244
sub_80B0268: @ 80B0268
push {lr}
bl ScriptContext2_Enable
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =mapldr_default
str r1, [r0]
ldr r0, =sub_80B01BC

View File

@ -5744,7 +5744,7 @@ unknown_ItemMenu_Show: @ 81ADE38
thumb_func_start bag_menu_leave_maybe_3
bag_menu_leave_maybe_3: @ 81ADE6C
push {lr}
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =sub_819FA50
str r1, [r0]
ldr r0, =c2_exit_to_overworld_2_switch
@ -5779,7 +5779,7 @@ unknown_ItemMenu_Give2: @ 81ADE8C
thumb_func_start bag_menu_leave_maybe_2
bag_menu_leave_maybe_2: @ 81ADEBC
push {lr}
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =sub_818DEF4
str r1, [r0]
ldr r0, =c2_exit_to_overworld_2_switch
@ -5810,7 +5810,7 @@ unknown_ItemMenu_Confirm2: @ 81ADEDC
thumb_func_start bag_menu_leave_maybe
bag_menu_leave_maybe: @ 81ADF00
push {lr}
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =sub_818E564
str r1, [r0]
ldr r0, =c2_exit_to_overworld_2_switch

View File

@ -77,7 +77,7 @@ SetUpItemUseOnFieldCallback: @ 80FD0DC
ldrsh r0, [r0, r1]
cmp r0, 0x1
beq _080FD110
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =MapPostLoadHook_UseItem
str r0, [r1]
adds r0, r2, 0
@ -1477,7 +1477,7 @@ _080FDB98:
b _080FDBDA
.pool
_080FDBC8:
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =sub_80AF6D4
str r1, [r0]
movs r0, 0x1
@ -1630,7 +1630,7 @@ sub_80FDD10: @ 80FDD10
ldr r1, =gUnknown_0203A0F4
ldr r0, =sub_80FDD74
str r0, [r1]
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =MapPostLoadHook_UseItem
str r0, [r1]
ldr r0, =gUnknown_0203CE54

View File

@ -49,7 +49,7 @@ sub_8160664: @ 8160664
bne _08160688
ldr r0, =sub_81606A0
bl SetMainCallback2
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80AF168
str r0, [r1]
adds r0, r4, 0

View File

@ -24689,7 +24689,7 @@ _08016502:
ldr r1, =gUnknown_02022C40
movs r0, 0x1
strh r0, [r1]
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80AF128
str r0, [r1]
ldr r1, =c2_exit_to_overworld_2_switch
@ -24987,7 +24987,7 @@ _0801677E:
lsls r0, 22
lsrs r0, 22
strh r0, [r2]
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80AF128
str r0, [r1]
ldr r1, =c2_exit_to_overworld_2_switch

View File

@ -17478,7 +17478,7 @@ sub_81B968C: @ 81B968C
str r0, [sp]
movs r0, 0x3
bl sub_81BF8EC
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80AF168
str r0, [r1]
add sp, 0x4

View File

@ -583,7 +583,7 @@ _0816B310:
thumb_func_start sub_816B31C
sub_816B31C: @ 816B31C
push {lr}
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =mapldr_080EBC0C
str r1, [r0]
ldr r0, =c2_exit_to_overworld_2_switch
@ -1276,7 +1276,7 @@ _0816B8E6:
thumb_func_start sub_816B900
sub_816B900: @ 816B900
push {lr}
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =pal_fill_for_maplights_or_black
str r1, [r0]
ldr r0, =c2_exit_to_overworld_2_switch
@ -1535,7 +1535,7 @@ _0816BB1C:
thumb_func_start sub_816BB28
sub_816BB28: @ 816BB28
push {lr}
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =sub_816BB48
str r1, [r0]
ldr r0, =c2_exit_to_overworld_2_switch

View File

@ -870,7 +870,7 @@ sub_80C7678: @ 80C7678
bl sub_80CAEA0
ldr r1, =gUnknown_02039D00
strb r0, [r1]
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =mapldr_0808C6D8
str r0, [r1]
ldr r0, =c2_exit_to_overworld_2_switch

View File

@ -3136,12 +3136,12 @@ map_post_load_hook_exec: @ 8085EA0
_08085EBC:
movs r1, 0
str r1, [r4]
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
str r1, [r0]
b _08085EEA
.pool
_08085ECC:
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r0, [r0]
cmp r0, 0
beq _08085EE0
@ -3151,7 +3151,7 @@ _08085ECC:
_08085EE0:
bl mapldr_default
_08085EE4:
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
movs r0, 0
str r0, [r1]
_08085EEA:
@ -3174,7 +3174,7 @@ CB2_NewGame: @ 8085EF8
bl PlayTimeCounter_Start
bl ScriptContext1_Init
bl ScriptContext2_Disable
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80FB4E0
str r0, [r1]
ldr r1, =gUnknown_03005DB0
@ -3214,7 +3214,7 @@ c2_whiteout: @ 8085F58
bl player_avatar_init_params_reset
bl ScriptContext1_Init
bl ScriptContext2_Disable
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80AF3C8
str r0, [r1]
mov r1, sp
@ -3304,7 +3304,7 @@ _08086062:
sub_8086074: @ 8086074
push {lr}
bl sub_808631C
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =sub_80AF314
str r1, [r0]
ldr r0, =c2_80567AC
@ -3399,12 +3399,12 @@ c2_8056854: @ 8086140
ldrb r0, [r0]
cmp r0, 0
beq _08086174
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80AF314
b _08086178
.pool
_08086174:
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80AF214
_08086178:
str r0, [r1]
@ -3433,7 +3433,7 @@ sub_8086194: @ 8086194
sub_80861B0: @ 80861B0
push {lr}
bl sub_808631C
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80AF188
str r0, [r1]
bl c2_exit_to_overworld_2_switch
@ -3446,7 +3446,7 @@ sub_80861B0: @ 80861B0
c2_exit_to_overworld_1_continue_scripts_restart_music: @ 80861CC
push {lr}
bl sub_808631C
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80AF168
str r0, [r1]
bl c2_exit_to_overworld_2_switch
@ -3459,7 +3459,7 @@ c2_exit_to_overworld_1_continue_scripts_restart_music: @ 80861CC
sub_80861E8: @ 80861E8
push {lr}
bl sub_808631C
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80AF3C8
str r0, [r1]
bl c2_exit_to_overworld_2_switch
@ -3562,7 +3562,7 @@ _080862BE:
.pool
_080862F4:
bl sub_80EDB44
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =sub_8086204
str r1, [r0]
ldr r0, =c1_overworld

View File

@ -1984,7 +1984,7 @@ sub_8136524: @ 8136524
lsrs r0, 24
cmp r0, 0x1
bhi _0813655A
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80AF168
str r0, [r1]
_0813655A:
@ -4651,7 +4651,7 @@ sub_8137C3C: @ 8137C3C
push {lr}
ldr r0, =c2_exit_to_overworld_2_switch
bl SetMainCallback2
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =mapldr_080CA5C0
str r0, [r1]
pop {r0}

View File

@ -3273,7 +3273,7 @@ sub_8141E7C: @ 8141E7C
bl ResetPaletteFade
bl ResetSpriteData
bl sub_8140418
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80AF168
str r0, [r1]
ldr r0, =c2_exit_to_overworld_2_switch

View File

@ -686,7 +686,7 @@ _080E900C:
_080E9030:
bl sub_80E8F9C
bl warp_in
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =sub_80AF168
str r1, [r0]
ldr r0, =c2_load_new_map
@ -863,7 +863,7 @@ sub_80E916C: @ 80E916C
adds r0, r5, 0
bl warp1_set
bl warp_in
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80E9108
str r0, [r1]
ldr r0, =c2_load_new_map
@ -1486,7 +1486,7 @@ _080E96F4:
movs r0, 0x7E
bl copy_saved_warp2_bank_and_enter_x_to_warp1
bl warp_in
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =mapldr_default
str r1, [r0]
ldr r0, =c2_load_new_map

View File

@ -227,7 +227,7 @@ HandleShopMenuSell: @ 80DFC0C
@ int CB2_ExitSellMenu()
CB2_ExitSellMenu: @ 80DFC48
push {lr}
ldr r0, =gUnknown_03005DAC
ldr r0, =gFieldCallback
ldr r1, =MapPostLoadHook_ExitBuyOrSellMenu
str r1, [r0]
ldr r0, =c2_exit_to_overworld_2_switch
@ -2668,7 +2668,7 @@ ExitBuyMenu: @ 80E1168
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =MapPostLoadHook_ExitBuyOrSellMenu
str r0, [r1]
movs r0, 0x1

View File

@ -14195,7 +14195,7 @@ sub_807F110: @ 807F110
bne _0807F134
ldr r0, =sub_807B270
bl SetMainCallback2
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80AF168
str r0, [r1]
adds r0, r4, 0

View File

@ -70,7 +70,7 @@ _081D9A68:
adds r1, r0, 0
adds r0, r4, 0
bl StringCopy
ldr r1, =gUnknown_03005DAC
ldr r1, =gFieldCallback
ldr r0, =sub_80AF168
str r0, [r1]
ldr r0, =c2_exit_to_overworld_2_switch

43
include/bg.h Normal file
View File

@ -0,0 +1,43 @@
#ifndef GUARD_BG_H
#define GUARD_BG_H
enum
{
BG_CTRL_ATTR_VISIBLE = 1,
BG_CTRL_ATTR_CHARBASEINDEX = 2,
BG_CTRL_ATTR_MAPBASEINDEX = 3,
BG_CTRL_ATTR_SCREENSIZE = 4,
BG_CTRL_ATTR_PALETTEMODE = 5,
BG_CTRL_ATTR_PRIORITY = 6,
BG_CTRL_ATTR_MOSAIC = 7,
BG_CTRL_ATTR_WRAPAROUND = 8,
};
struct BgTemplate
{
u32 bg:2;
u32 charBaseIndex:2;
u32 mapBaseIndex:5;
u32 screenSize:2;
u32 paletteMode:1;
u32 priority:2;
u32 baseTile:10;
};
void ResetBgsAndClearDma3BusyFlags(u32 leftoverFireRedLeafGreenVariable);
void InitBgsFromTemplates(u8 bgMode, const struct BgTemplate *templates, u8 numTemplates);
void SetBgAttribute(u8 bg, u8 attributeId, u8 value);
u16 GetBgAttribute(u8 bg, u8 attributeId);
u32 ChangeBgX(u8 bg, u32 value, u8 op);
u32 GetBgX(u8 bg);
u32 ChangeBgY(u8 bg, u32 value, u8 op);
u32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op);
u32 GetBgY(u8 bg);
void SetBgAffine(u8 bg, u32 srcCenterX, u32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle);
void SetBgTilemapBuffer(u8 bg, void *tilemap);
void UnsetBgTilemapBuffer(u8 bg);
void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset);
void CopyBgTilemapBufferToVram(u8 bg);
u16 LoadBgTiles(u8 bg, const void* src, u16 size, u16 destOffset);
#endif // GUARD_BG_H

View File

@ -6,7 +6,7 @@ extern u8 gDma3RequestCursor;
struct DmaRequestsStruct
{
/* 0x00 */ u8 *src;
/* 0x00 */ const u8 *src;
/* 0x04 */ u8 *dest;
/* 0x08 */ u16 size;
/* 0x0A */ u16 mode;
@ -17,7 +17,7 @@ extern struct DmaRequestsStruct gDma3Requests[128];
void ClearDma3Requests(void);
void ProcessDma3Requests(void);
int RequestDma3Copy(void *src, void *dest, u16 size, u8 mode);
int RequestDma3Copy(const void *src, void *dest, u16 size, u8 mode);
int RequestDma3Fill(s32 value, void *dest, u16 size, u8 mode);
#endif

View File

@ -639,7 +639,8 @@ struct DaycareMon
struct MailStruct mail;
u8 OT_name[OT_NAME_LENGTH + 1];
u8 monName[11];
u8 language;
u8 language_maybe : 4;
u8 unknown : 4;
u32 stepsTaken;
};

12
include/gpu_regs.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef GUARD_GPU_REGS_H
#define GUARD_GPU_REGS_H
void SetGpuReg(u8 regOffset, u16 value);
void SetGpuReg_ForcedBlank(u8 regOffset, u16 value);
u16 GetGpuReg(u8 regOffset);
void SetGpuRegBits(u8 regOffset, u16 mask);
void ClearGpuRegBits(u8 regOffset, u16 mask);
void EnableInterrupts(u16 mask);
void DisableInterrupts(u16 mask);
#endif // GUARD_GPU_REGS_H

View File

@ -4,6 +4,7 @@
#include "gba/m4a_internal.h"
void m4aSoundVSync(void);
void m4aSoundVSyncOn(void);
void m4aSoundInit(void);
void m4aSoundMain(void);

View File

@ -30,7 +30,7 @@ struct Window
u8 *tileData;
};
bool16 InitWindows(struct WindowTemplate *templates);
bool16 InitWindows(const struct WindowTemplate *templates);
u16 AddWindow(const struct WindowTemplate *template);
int AddWindowWithoutTileMap(struct WindowTemplate *template);
void RemoveWindow(u8 windowId);

View File

@ -80,6 +80,7 @@ SECTIONS {
src/util.o(.text);
src/blend_palette.o(.text);
asm/daycare.o(.text);
src/egg_hatch.o(.text);
asm/egg_hatch.o(.text);
asm/battle_interface.o(.text);
asm/smokescreen.o(.text);

View File

@ -1,19 +1,9 @@
#include "global.h"
#include "bg.h"
#include "dma3.h"
#define DISPCNT_ALL_BG_AND_MODE_BITS 0x0F07
enum {
BG_CTRL_ATTR_VISIBLE = 1,
BG_CTRL_ATTR_CHARBASEINDEX = 2,
BG_CTRL_ATTR_MAPBASEINDEX = 3,
BG_CTRL_ATTR_SCREENSIZE = 4,
BG_CTRL_ATTR_PALETTEMODE = 5,
BG_CTRL_ATTR_PRIORITY = 6,
BG_CTRL_ATTR_MOSAIC = 7,
BG_CTRL_ATTR_WRAPAROUND = 8,
};
struct BgControl {
struct BgConfig {
u16 visible:1;
@ -34,16 +24,6 @@ struct BgControl {
u16 bgVisibilityAndMode;
};
struct BgTemplate {
u32 bg:2;
u32 charBaseIndex:2;
u32 mapBaseIndex:5;
u32 screenSize:2;
u32 paletteMode:1;
u32 priority:2;
u32 baseTile:10;
};
struct BgConfig2 {
u32 baseTile:10;
u32 basePalette:4;
@ -192,7 +172,7 @@ u16 GetBgControlAttribute(u8 bg, u8 attributeId)
return 0xFF;
}
u8 LoadBgVram(u8 bg, void *src, u16 size, u16 destOffset, u8 mode)
u8 LoadBgVram(u8 bg, const void *src, u16 size, u16 destOffset, u8 mode)
{
u16 offset;
s8 cursor;
@ -335,7 +315,7 @@ void ResetBgsAndClearDma3BusyFlags(u32 leftoverFireRedLeafGreenVariable)
gUnneededFireRedVariable = leftoverFireRedLeafGreenVariable;
}
void InitBgsFromTemplates(u8 bgMode, struct BgTemplate *templates, u8 numTemplates)
void InitBgsFromTemplates(u8 bgMode, const struct BgTemplate *templates, u8 numTemplates)
{
int i;
u8 bg;
@ -397,7 +377,7 @@ void SetBgMode(u8 bgMode)
SetBgModeInternal(bgMode);
}
u16 LoadBgTiles(u8 bg, void* src, u16 size, u16 destOffset)
u16 LoadBgTiles(u8 bg, const void* src, u16 size, u16 destOffset)
{
u16 tileOffset;
u8 cursor;
@ -963,7 +943,7 @@ void* GetBgTilemapBuffer(u8 bg)
return gGpuBgConfigs2[bg].tilemap;
}
void CopyToBgTilemapBuffer(u8 bg, void *src, u16 mode, u16 destOffset)
void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset)
{
if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE)
{

View File

@ -419,7 +419,7 @@ _08000E46:\n\
}
#endif
int RequestDma3Copy(void *src, void *dest, u16 size, u8 mode)
int RequestDma3Copy(const void *src, void *dest, u16 size, u8 mode)
{
int cursor;
int var = 0;

364
src/egg_hatch.c Normal file
View File

@ -0,0 +1,364 @@
#include "global.h"
#include "pokemon.h"
#include "pokedex.h"
#include "items.h"
#include "script.h"
#include "decompress.h"
#include "task.h"
#include "palette.h"
#include "main.h"
#include "event_data.h"
#include "sound.h"
#include "songs.h"
#include "text.h"
#include "text_window.h"
#include "string_util.h"
#include "menu.h"
#include "trig.h"
#include "rng.h"
#include "malloc.h"
#include "dma3.h"
#include "gpu_regs.h"
#include "bg.h"
#include "m4a.h"
#include "window.h"
#include "battle.h" // to get rid of later
struct EggHatchData
{
u8 eggSpriteID;
u8 pokeSpriteID;
u8 CB2_state;
u8 CB2_PalCounter;
u8 eggPartyID;
u8 field_5;
u8 field_6;
u8 eggShardVelocityID;
u8 field_8;
u8 field_9;
u8 field_A;
u8 field_B;
u16 species;
u8 field_E;
u8 field_F;
u8 field_10;
u8 field_11;
u8 field_12;
u8 field_13;
};
extern struct EggHatchData* gEggHatchData;
extern struct SpriteTemplate gUnknown_0202499C;
extern void (*gFieldCallback)(void);
extern const struct CompressedSpriteSheet gMonFrontPicTable[];
extern const struct BgTemplate gUnknown_0832C064[2];
extern const struct WindowTemplate gUnknown_0832C06C[2];
extern const u8 gUnknown_08C00000[];
extern const u8 gUnknown_08C00524[];
extern const u8 gUnknown_08C004E0[];
extern const struct SpriteSheet gUnknown_0832BFE4; // hatching egg
extern const struct SpriteSheet gUnknown_0832BFEC; // egg shell
extern const struct SpritePalette gUnknown_0832BFF4; // hatching egg
extern const u16 gUnknown_08DD7300[]; // palette, gameboy advance
extern const u32 gUnknown_08DD7360[]; // tileset gameboy advance
extern const u32 gUnknown_08331F60[]; // tilemap gameboy circle
extern u8* GetMonNick(struct Pokemon* mon, u8* dst);
extern u8* GetBoxMonNick(struct BoxPokemon* boxMon, u8* dst);
extern u8 sav1_map_get_name(void);
extern void sub_81DB5E8(u8* str1, u8* str2, u8);
extern void sub_806A068(u16, u8);
extern void fade_screen(u8, u8);
extern void overworld_free_bg_tilemaps(void);
extern void sub_80AF168(void);
extern void init_uns_table_pokemon_copy(void);
extern void remove_some_task(void);
extern void reset_temp_tile_data_buffers(void);
extern void copy_decompressed_tile_data_to_vram_autofree(u8 bg_id, const void* src, u16 size, u16 offset, u8 mode);
void Task_EggHatch(u8 taskID);
void CB2_EggHatch_0(void);
void CB2_EggHatch_1(void);
void SpriteCB_Egg_0(struct Sprite* sprite);
void SpriteCB_Egg_1(struct Sprite* sprite);
void SpriteCB_Egg_2(struct Sprite* sprite);
void SpriteCB_Egg_3(struct Sprite* sprite);
void SpriteCB_Egg_4(struct Sprite* sprite);
void SpriteCB_Egg_5(struct Sprite* sprite);
void SpriteCB_EggShard(struct Sprite* sprite);
void EggHatchPrintMessage2(u8* src);
void EggHatchPrintMessage1(u8* src);
bool8 EggHatchUpdateWindowText(void);
void CreateRandomEggShardSprite(void);
void CreateEggShardSprite(u8 x, u8 y, s16 data1, s16 data2, s16 data3, u8 spriteAnimIndex);
static void CreatedHatchedMon(struct Pokemon *egg, struct Pokemon *temp)
{
u16 species;
u32 personality, pokerus;
u8 i, friendship, language, gameMet, markings, obedience;
u16 moves[4];
u32 ivs[6];
species = GetMonData(egg, MON_DATA_SPECIES);
for (i = 0; i < 4; i++)
{
moves[i] = GetMonData(egg, MON_DATA_MOVE1 + i);
}
personality = GetMonData(egg, MON_DATA_PERSONALITY);
for (i = 0; i < 6; i++)
{
ivs[i] = GetMonData(egg, MON_DATA_HP_IV + i);
}
language = GetMonData(egg, MON_DATA_LANGUAGE);
gameMet = GetMonData(egg, MON_DATA_MET_GAME);
markings = GetMonData(egg, MON_DATA_MARKINGS);
pokerus = GetMonData(egg, MON_DATA_POKERUS);
obedience = GetMonData(egg, MON_DATA_OBEDIENCE);
CreateMon(temp, species, 5, 32, TRUE, personality, 0, 0);
for (i = 0; i < 4; i++)
{
SetMonData(temp, MON_DATA_MOVE1 + i, &moves[i]);
}
for (i = 0; i < 6; i++)
{
SetMonData(temp, MON_DATA_HP_IV + i, &ivs[i]);
}
language = GAME_LANGUAGE;
SetMonData(temp, MON_DATA_LANGUAGE, &language);
SetMonData(temp, MON_DATA_MET_GAME, &gameMet);
SetMonData(temp, MON_DATA_MARKINGS, &markings);
friendship = 120;
SetMonData(temp, MON_DATA_FRIENDSHIP, &friendship);
SetMonData(temp, MON_DATA_POKERUS, &pokerus);
SetMonData(temp, MON_DATA_OBEDIENCE, &obedience);
*egg = *temp;
}
void AddHatchedMonToParty(u8 id)
{
u8 isEgg = 0x46; // ?
u16 pokeNum;
u8 name[12];
u16 ball;
u16 caughtLvl;
u8 mapNameID;
struct Pokemon* mon = &gPlayerParty[id];
CreatedHatchedMon(mon, &gEnemyParty[0]);
SetMonData(mon, MON_DATA_IS_EGG, &isEgg);
pokeNum = GetMonData(mon, MON_DATA_SPECIES);
GetSpeciesName(name, pokeNum);
SetMonData(mon, MON_DATA_NICKNAME, name);
pokeNum = SpeciesToNationalPokedexNum(pokeNum);
GetSetPokedexFlag(pokeNum, FLAG_SET_SEEN);
GetSetPokedexFlag(pokeNum, FLAG_SET_CAUGHT);
GetMonNick(mon, gStringVar1);
ball = ITEM_POKE_BALL;
SetMonData(mon, MON_DATA_POKEBALL, &ball);
caughtLvl = 0;
SetMonData(mon, MON_DATA_MET_LEVEL, &caughtLvl);
mapNameID = sav1_map_get_name();
SetMonData(mon, MON_DATA_MET_LOCATION, &mapNameID);
MonRestorePP(mon);
CalculateMonStats(mon);
}
void ScriptHatchMon(void)
{
AddHatchedMonToParty(gSpecialVar_0x8004);
}
static bool8 sub_807158C(struct DaycareData* daycare, u8 daycareId)
{
u8 nick[0x20];
struct DaycareMon* daycareMon = &daycare->mons[daycareId];
GetBoxMonNick(&daycareMon->mon, nick);
if (daycareMon->mail.itemId != 0
&& (StringCompareWithoutExtCtrlCodes(nick, daycareMon->monName) != 0
|| StringCompareWithoutExtCtrlCodes(gSaveBlock2Ptr->playerName, daycareMon->OT_name) != 0))
{
StringCopy(gStringVar1, nick);
sub_81DB5E8(gStringVar2, daycareMon->OT_name, daycareMon->language_maybe);
sub_81DB5E8(gStringVar3, daycareMon->monName, daycareMon->unknown);
return TRUE;
}
return FALSE;
}
bool8 sub_8071614(void)
{
return sub_807158C(&gSaveBlock1Ptr->daycare, gSpecialVar_0x8004);
}
u8 EggHatchCreateMonSprite(u8 a0, u8 switchID, u8 pokeID, u16* speciesLoc)
{
u8 r5 = 0;
u8 spriteID = 0;
struct Pokemon* mon = NULL;
if (a0 == 0)
{
mon = &gPlayerParty[pokeID];
r5 = 1;
}
if (a0 == 1)
{
mon = &gPlayerParty[pokeID];
r5 = 3;
}
switch (switchID)
{
case 0:
{
u16 species = GetMonData(mon, MON_DATA_SPECIES);
u32 pid = GetMonData(mon, MON_DATA_PERSONALITY);
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species],
gBattleSpritesGfx->sprites[(a0 * 2) + 1],
species, pid);
LoadCompressedObjectPalette(sub_806E794(mon));
*speciesLoc = species;
}
break;
case 1:
sub_806A068(sub_806E794(mon)->tag, r5);
spriteID = CreateSprite(&gUnknown_0202499C, 120, 75, 6);
gSprites[spriteID].invisible = 1;
gSprites[spriteID].callback = SpriteCallbackDummy;
break;
}
return spriteID;
}
void VBlankCB_EggHatch(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
void EggHatch(void)
{
ScriptContext2_Enable();
CreateTask(Task_EggHatch, 10);
fade_screen(1, 0);
}
void Task_EggHatch(u8 taskID)
{
if (!gPaletteFade.active)
{
overworld_free_bg_tilemaps();
SetMainCallback2(CB2_EggHatch_0);
gFieldCallback = sub_80AF168;
DestroyTask(taskID);
}
}
void CB2_EggHatch_0(void)
{
switch (gMain.state)
{
case 0:
SetGpuReg(REG_OFFSET_DISPCNT, 0);
gEggHatchData = Alloc(sizeof(struct EggHatchData));
init_uns_table_pokemon_copy();
gEggHatchData->eggPartyID = gSpecialVar_0x8004;
gEggHatchData->eggShardVelocityID = 0;
SetVBlankCallback(VBlankCB_EggHatch);
gSpecialVar_0x8005 = GetCurrentMapMusic();
reset_temp_tile_data_buffers();
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, gUnknown_0832C064, 2);
ChangeBgX(1, 0, 0);
ChangeBgY(1, 0, 0);
ChangeBgX(0, 0, 0);
ChangeBgY(0, 0, 0);
SetBgAttribute(1, BG_CTRL_ATTR_MOSAIC, 2);
SetBgTilemapBuffer(1, Alloc(0x1000));
SetBgTilemapBuffer(0, Alloc(0x2000));
DeactivateAllTextPrinters();
ResetPaletteFade();
FreeAllSpritePalettes();
ResetSpriteData();
ResetTasks();
remove_some_task();
m4aSoundVSyncOn();
gMain.state++;
break;
case 1:
InitWindows(gUnknown_0832C06C);
gEggHatchData->field_8 = 0;
gMain.state++;
break;
case 2:
copy_decompressed_tile_data_to_vram_autofree(0, gUnknown_08C00000, 0, 0, 0);
CopyToBgTilemapBuffer(0, gUnknown_08C00524, 0, 0);
LoadCompressedPalette(gUnknown_08C004E0, 0, 0x20);
gMain.state++;
break;
case 3:
LoadSpriteSheet(&gUnknown_0832BFE4);
LoadSpriteSheet(&gUnknown_0832BFEC);
LoadSpritePalette(&gUnknown_0832BFF4);
gMain.state++;
break;
case 4:
CopyBgTilemapBufferToVram(0);
AddHatchedMonToParty(gEggHatchData->eggPartyID);
gMain.state++;
break;
case 5:
EggHatchCreateMonSprite(0, 0, gEggHatchData->eggPartyID, &gEggHatchData->species);
gMain.state++;
break;
case 6:
gEggHatchData->pokeSpriteID = EggHatchCreateMonSprite(0, 1, gEggHatchData->eggPartyID, &gEggHatchData->species);
gMain.state++;
break;
case 7:
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
LoadPalette(gUnknown_08DD7300, 0x10, 0xA0);
LoadBgTiles(1, gUnknown_08DD7360, 0x1420, 0);
CopyToBgTilemapBuffer(1, gUnknown_08331F60, 0x1000, 0);
CopyBgTilemapBufferToVram(1);
gMain.state++;
break;
case 8:
SetMainCallback2(CB2_EggHatch_1);
gEggHatchData->CB2_state = 0;
break;
}
RunTasks();
RunTextPrinters();
AnimateSprites();
BuildOamBuffer();
UpdatePaletteFade();
}

View File

@ -18,7 +18,7 @@ struct PokeblockFeeder
#define NUM_POKEBLOCK_FEEDERS 10
extern u8 gBattleOutcome;
extern void* gUnknown_03005DAC;
extern void* gFieldCallback;
extern u8 gUnknown_082A4B8A[];
extern u8 gUnknown_082A4B6F[];
@ -118,7 +118,7 @@ void sub_80FC190(void)
{
ScriptContext2_RunNewScript(gUnknown_082A4B4C);
warp_in();
gUnknown_03005DAC = sub_80AF6F0;
gFieldCallback = sub_80AF6F0;
SetMainCallback2(c2_load_new_map);
}
else if (gBattleOutcome == BATTLE_CAUGHT)

View File

@ -35,7 +35,7 @@ static void nullsub_8(void)
}
bool16 InitWindows(struct WindowTemplate *templates)
bool16 InitWindows(const struct WindowTemplate *templates)
{
int i;
void *bgTilemapBuffer;

View File

@ -113,7 +113,7 @@ gUnknown_03000DD8: @ 3000DD8
gUnknown_03000DDC: @ 3000DDC
.space 0x4
gUnknown_03000DE0: @ 3000DE0
gEggHatchData: @ 3000DE0
.space 0x8
gUnknown_03000DE8: @ 3000DE8

View File

@ -269,7 +269,7 @@ gUnknown_03005DA4: @ 3005DA4
gUnknown_03005DA8: @ 3005DA8
.space 0x4
gUnknown_03005DAC: @ 3005DAC
gFieldCallback: @ 3005DAC
.space 0x4
gUnknown_03005DB0: @ 3005DB0