Merge pull request #36 from DizzyEggg/decomp_egg_hatch

Decompile Egg Hatch
This commit is contained in:
yenatch 2017-09-23 13:50:55 -04:00 committed by GitHub
commit a57915fa5b
51 changed files with 3668 additions and 4532 deletions

View File

@ -30996,7 +30996,7 @@ _08056D0A:
movs r0, 0x2
adds r2, r6, 0
adds r3, r5, 0
bl do_choose_name_or_words_screen
bl DoNamingScreen
ldr r1, =gBattleCommunication
ldrb r0, [r1]
adds r0, 0x1

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
@ -2175,7 +2175,7 @@ _08070B34:
lsrs r0, 24
cmp r0, 0xFF
bne _08070BC0
bl sub_807228C
bl GetEggStepsToSubtract
lsls r0, 24
lsrs r6, r0, 24
movs r5, 0
@ -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

@ -2951,7 +2951,7 @@ task_new_game_prof_birch_speech_17: @ 8031090
str r0, [sp, 0x4]
movs r0, 0
movs r3, 0
bl do_choose_name_or_words_screen
bl DoNamingScreen
_080310EC:
add sp, 0x8
pop {r4,r5}

View File

@ -5,9 +5,9 @@
.text
thumb_func_start do_choose_name_or_words_screen
@ int do_choose_name_or_words_screen(u8 type, sav2 *sav2_ptr, s16 player_gender, s16 a4, int a5, void ( *after_finishing_callback)())
do_choose_name_or_words_screen: @ 80E2D78
thumb_func_start DoNamingScreen
@ int DoNamingScreen(u8 type, sav2 *sav2_ptr, s16 player_gender, s16 a4, int a5, void ( *after_finishing_callback)())
DoNamingScreen: @ 80E2D78
push {r4-r7,lr}
mov r7, r8
push {r7}
@ -65,7 +65,7 @@ _080E2DE2:
pop {r0}
bx r0
.pool
thumb_func_end do_choose_name_or_words_screen
thumb_func_end DoNamingScreen
thumb_func_start c2_choose_name_or_words_screen
c2_choose_name_or_words_screen: @ 80E2E04
@ -4197,7 +4197,7 @@ sub_80E5074: @ 80E5074
str r0, [sp, 0x4]
movs r0, 0
movs r3, 0
bl do_choose_name_or_words_screen
bl DoNamingScreen
add sp, 0x8
pop {r0}
bx r0
@ -4217,7 +4217,7 @@ sub_80E509C: @ 80E509C
str r0, [sp, 0x4]
movs r0, 0x1
movs r3, 0
bl do_choose_name_or_words_screen
bl DoNamingScreen
add sp, 0x8
pop {r0}
bx r0
@ -4237,7 +4237,7 @@ sub_80E50C4: @ 80E50C4
str r0, [sp, 0x4]
movs r0, 0x2
movs r3, 0
bl do_choose_name_or_words_screen
bl DoNamingScreen
add sp, 0x8
pop {r0}
bx r0
@ -4257,7 +4257,7 @@ sub_80E50EC: @ 80E50EC
str r0, [sp, 0x4]
movs r0, 0x3
movs r3, 0
bl do_choose_name_or_words_screen
bl DoNamingScreen
add sp, 0x8
pop {r0}
bx r0

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
@ -5433,7 +5433,7 @@ _080C9F1C:
movs r0, 0x1
movs r2, 0
movs r3, 0
bl do_choose_name_or_words_screen
bl DoNamingScreen
b _080C9F56
.pool
_080C9F48:

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

@ -7530,7 +7530,7 @@ sub_80EFDDC: @ 80EFDDC
mov r1, r10
adds r2, r5, 0
adds r3, r4, 0
bl do_choose_name_or_words_screen
bl DoNamingScreen
add sp, 0x8
pop {r3-r5}
mov r8, r3
@ -7604,7 +7604,7 @@ sub_80EFEC4: @ 80EFEC4
mov r1, r8
adds r2, r5, 0
adds r3, r4, 0
bl do_choose_name_or_words_screen
bl DoNamingScreen
add sp, 0x8
pop {r3}
mov r8, r3

View File

@ -22,7 +22,7 @@ walda_maybe: @ 81D99E4
adds r1, r4, 0
movs r2, 0
movs r3, 0
bl do_choose_name_or_words_screen
bl DoNamingScreen
add sp, 0x8
pop {r4}
pop {r0}
@ -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

File diff suppressed because it is too large Load Diff

585
data/data3_a0_A.s Normal file
View File

@ -0,0 +1,585 @@
@ the third big chunk of data
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
gUnknown_0832C0D0:: @ 832C0D0
.incbin "baserom.gba", 0x32c0d0, 0x8
gUnknown_0832C0D8:: @ 832C0D8
.incbin "baserom.gba", 0x32c0d8, 0x8
gUnknown_0832C0E0:: @ 832C0E0
.incbin "baserom.gba", 0x32c0e0, 0x8
gUnknown_0832C0E8:: @ 832C0E8
.incbin "baserom.gba", 0x32c0e8, 0x8
gUnknown_0832C0F0:: @ 832C0F0
.incbin "baserom.gba", 0x32c0f0, 0x8
gUnknown_0832C0F8:: @ 832C0F8
.incbin "baserom.gba", 0x32c0f8, 0x8
gUnknown_0832C100:: @ 832C100
.incbin "baserom.gba", 0x32c100, 0x8
gUnknown_0832C108:: @ 832C108
.incbin "baserom.gba", 0x32c108, 0x20
gUnknown_0832C128:: @ 832C128
.incbin "baserom.gba", 0x32c128, 0x18
gUnknown_0832C140:: @ 832C140
.incbin "baserom.gba", 0x32c140, 0x30
gUnknown_0832C170:: @ 832C170
.incbin "baserom.gba", 0x32c170, 0x30
gUnknown_0832C1A0:: @ 832C1A0
.incbin "baserom.gba", 0x32c1a0, 0x20
gUnknown_0832C1C0:: @ 832C1C0
.incbin "baserom.gba", 0x32c1c0, 0xcc
gUnknown_0832C28C:: @ 832C28C
.incbin "baserom.gba", 0x32c28c, 0x38
gUnknown_0832C2C4:: @ 832C2C4
.incbin "baserom.gba", 0x32c2c4, 0x8
gUnknown_0832C2CC:: @ 832C2CC
.incbin "baserom.gba", 0x32c2cc, 0x68
gUnknown_0832C334:: @ 832C334
.incbin "baserom.gba", 0x32c334, 0x8
gUnknown_0832C33C:: @ 832C33C
.incbin "baserom.gba", 0x32c33c, 0x8
gUnknown_0832C344:: @ 832C344
.incbin "baserom.gba", 0x32c344, 0x8
gUnknown_0832C34C:: @ 832C34C
.incbin "baserom.gba", 0x32c34c, 0x18
gUnknown_0832C364:: @ 832C364
.incbin "baserom.gba", 0x32c364, 0x30
gUnknown_0832C394:: @ 832C394
.incbin "baserom.gba", 0x32c394, 0x30
gUnknown_0832C3C4:: @ 832C3C4
.incbin "baserom.gba", 0x32c3c4, 0x14
gUnknown_0832C3D8:: @ 832C3D8
.incbin "baserom.gba", 0x32c3d8, 0x14
gUnknown_0832C3EC:: @ 832C3EC
.incbin "baserom.gba", 0x32c3ec, 0xc
gUnknown_0832C3F8:: @ 832C3F8
.incbin "baserom.gba", 0x32c3f8, 0x8
gUnknown_0832C400:: @ 832C400
.incbin "baserom.gba", 0x32c400, 0x60
gUnknown_0832C460:: @ 832C460
.incbin "baserom.gba", 0x32c460, 0x128
gUnknown_0832C588:: @ 832C588
.incbin "baserom.gba", 0x32c588, 0x138
gUnknown_0832C6C0:: @ 832C6C0
.incbin "baserom.gba", 0x32c6c0, 0x1fe
gUnknown_0832C8BE:: @ 832C8BE
.incbin "baserom.gba", 0x32c8be, 0x1fe
gUnknown_0832CABC:: @ 832CABC
.incbin "baserom.gba", 0x32cabc, 0x800
gUnknown_0832D2BC:: @ 832D2BC
.incbin "baserom.gba", 0x32d2bc, 0x800
gUnknown_0832DABC:: @ 832DABC
.incbin "baserom.gba", 0x32dabc, 0xb
gUnknown_0832DAC7:: @ 832DAC7
.incbin "baserom.gba", 0x32dac7, 0x2
gUnknown_0832DAC9:: @ 832DAC9
.incbin "baserom.gba", 0x32dac9, 0x2
gUnknown_0832DACB:: @ 832DACB
.incbin "baserom.gba", 0x32dacb, 0x7
gUnknown_0832DAD2:: @ 832DAD2
.incbin "baserom.gba", 0x32dad2, 0xd
gUnknown_0832DADF:: @ 832DADF
.incbin "baserom.gba", 0x32dadf, 0x6
gUnknown_0832DAE5:: @ 832DAE5
.incbin "baserom.gba", 0x32dae5, 0x157
gUnknown_0832DC3C:: @ 832DC3C
.incbin "baserom.gba", 0x32dc3c, 0x8
gUnknown_0832DC44:: @ 832DC44
.incbin "baserom.gba", 0x32dc44, 0x50
gUnknown_0832DC94:: @ 832DC94
.incbin "baserom.gba", 0x32dc94, 0x18
gUnknown_0832DCAC:: @ 832DCAC
.incbin "baserom.gba", 0x32dcac, 0x38
gUnknown_0832DCE4:: @ 832DCE4
.incbin "baserom.gba", 0x32dce4, 0x8
gUnknown_0832DCEC:: @ 832DCEC
.incbin "baserom.gba", 0x32dcec, 0x138
gUnknown_0832DE24:: @ 832DE24
.incbin "baserom.gba", 0x32de24, 0x1a
gUnknown_0832DE3E:: @ 832DE3E
.incbin "baserom.gba", 0x32de3e, 0x18
gUnknown_0832DE56:: @ 832DE56
.incbin "baserom.gba", 0x32de56, 0x3e
gUnknown_0832DE94:: @ 832DE94
.incbin "baserom.gba", 0x32de94, 0x18
gUnknown_0832DEAC:: @ 832DEAC
.incbin "baserom.gba", 0x32deac, 0x10
gUnknown_0832DEBC:: @ 832DEBC
.incbin "baserom.gba", 0x32debc, 0x24
gUnknown_0832DEE0:: @ 832DEE0
.incbin "baserom.gba", 0x32dee0, 0x4
gUnknown_0832DEE4:: @ 832DEE4
.incbin "baserom.gba", 0x32dee4, 0x10
gUnknown_0832DEF4:: @ 832DEF4
.incbin "baserom.gba", 0x32def4, 0x98
gUnknown_0832DF8C:: @ 832DF8C
.incbin "baserom.gba", 0x32df8c, 0x8
gUnknown_0832DF94:: @ 832DF94
.incbin "baserom.gba", 0x32df94, 0x5
gUnknown_0832DF99:: @ 832DF99
.incbin "baserom.gba", 0x32df99, 0x2027
gUnknown_0832FFC0:: @ 832FFC0
.incbin "baserom.gba", 0x32ffc0, 0x1fa0
gUnknown_08331F60:: @ 8331F60
.incbin "baserom.gba", 0x331f60, 0x1000
gUnknown_08332F60:: @ 8332F60
.incbin "baserom.gba", 0x332f60, 0x2840
gUnknown_083357A0:: @ 83357A0
.incbin "baserom.gba", 0x3357a0, 0x100
gUnknown_083358A0:: @ 83358A0
.incbin "baserom.gba", 0x3358a0, 0x100
gUnknown_083359A0:: @ 83359A0
.incbin "baserom.gba", 0x3359a0, 0x1000
gUnknown_083369A0:: @ 83369A0
.incbin "baserom.gba", 0x3369a0, 0x1000
gUnknown_083379A0:: @ 83379A0
.incbin "baserom.gba", 0x3379a0, 0x100
gUnknown_08337AA0:: @ 8337AA0
.incbin "baserom.gba", 0x337aa0, 0x200
gUnknown_08337CA0:: @ 8337CA0
.incbin "baserom.gba", 0x337ca0, 0x200
gUnknown_08337EA0:: @ 8337EA0
.incbin "baserom.gba", 0x337ea0, 0x20
gUnknown_08337EC0:: @ 8337EC0
.incbin "baserom.gba", 0x337ec0, 0x690
gUnknown_08338550:: @ 8338550
.incbin "baserom.gba", 0x338550, 0x7c8
gUnknown_08338D18:: @ 8338D18
.incbin "baserom.gba", 0x338d18, 0x8
gUnknown_08338D20:: @ 8338D20
.incbin "baserom.gba", 0x338d20, 0x8
gUnknown_08338D28:: @ 8338D28
.incbin "baserom.gba", 0x338d28, 0x48
gUnknown_08338D70:: @ 8338D70
.incbin "baserom.gba", 0x338d70, 0x8
gUnknown_08338D78:: @ 8338D78
.incbin "baserom.gba", 0x338d78, 0x8
gUnknown_08338D80:: @ 8338D80
.incbin "baserom.gba", 0x338d80, 0x8
gUnknown_08338D88:: @ 8338D88
.incbin "baserom.gba", 0x338d88, 0x38
gUnknown_08338DC0:: @ 8338DC0
.incbin "baserom.gba", 0x338dc0, 0x8
gUnknown_08338DC8:: @ 8338DC8
.incbin "baserom.gba", 0x338dc8, 0x2c
gUnknown_08338DF4:: @ 8338DF4
.incbin "baserom.gba", 0x338df4, 0x8
gUnknown_08338DFC:: @ 8338DFC
.incbin "baserom.gba", 0x338dfc, 0x70
gUnknown_08338E6C:: @ 8338E6C
.incbin "baserom.gba", 0x338e6c, 0x8
gUnknown_08338E74:: @ 8338E74
.incbin "baserom.gba", 0x338e74, 0x18
gUnknown_08338E8C:: @ 8338E8C
.incbin "baserom.gba", 0x338e8c, 0x18
gUnknown_08338EA4:: @ 8338EA4
.incbin "baserom.gba", 0x338ea4, 0x28
gUnknown_08338ECC:: @ 8338ECC
.incbin "baserom.gba", 0x338ecc, 0x4
gUnknown_08338ED0:: @ 8338ED0
.incbin "baserom.gba", 0x338ed0, 0xf0
gUnknown_08338FC0:: @ 8338FC0
.incbin "baserom.gba", 0x338fc0, 0x3c
gUnknown_08338FFC:: @ 8338FFC
.incbin "baserom.gba", 0x338ffc, 0x10
gUnknown_0833900C:: @ 833900C
.incbin "baserom.gba", 0x33900c, 0x8
gUnknown_08339014:: @ 8339014
.incbin "baserom.gba", 0x339014, 0x10
gUnknown_08339024:: @ 8339024
.incbin "baserom.gba", 0x339024, 0x6c
gUnknown_08339090:: @ 8339090
.incbin "baserom.gba", 0x339090, 0x44
gUnknown_083390D4:: @ 83390D4
.incbin "baserom.gba", 0x3390d4, 0x20
gUnknown_083390F4:: @ 83390F4
.incbin "baserom.gba", 0x3390f4, 0x400
gUnknown_083394F4:: @ 83394F4
.incbin "baserom.gba", 0x3394f4, 0x246
gUnknown_0833973A:: @ 833973A
.incbin "baserom.gba", 0x33973a, 0x61
gUnknown_0833979B:: @ 833979B
.incbin "baserom.gba", 0x33979b, 0x2
gUnknown_0833979D:: @ 833979D
.incbin "baserom.gba", 0x33979d, 0x33
gUnknown_083397D0:: @ 83397D0
.incbin "baserom.gba", 0x3397d0, 0x4a
gUnknown_0833981A:: @ 833981A
.incbin "baserom.gba", 0x33981a, 0x17
gUnknown_08339831:: @ 8339831
.incbin "baserom.gba", 0x339831, 0x27
gUnknown_08339858:: @ 8339858
.incbin "baserom.gba", 0x339858, 0x3e
gUnknown_08339896:: @ 8339896
.incbin "baserom.gba", 0x339896, 0x1a
gUnknown_083398B0:: @ 83398B0
.incbin "baserom.gba", 0x3398b0, 0x2d
gUnknown_083398DD:: @ 83398DD
.incbin "baserom.gba", 0x3398dd, 0x18
gUnknown_083398F5:: @ 83398F5
.incbin "baserom.gba", 0x3398f5, 0x1f
gUnknown_08339914:: @ 8339914
.incbin "baserom.gba", 0x339914, 0x7
gUnknown_0833991B:: @ 833991B
.incbin "baserom.gba", 0x33991b, 0x6
gUnknown_08339921:: @ 8339921
.incbin "baserom.gba", 0x339921, 0x7
gUnknown_08339928:: @ 8339928
.incbin "baserom.gba", 0x339928, 0x6
gUnknown_0833992E:: @ 833992E
.incbin "baserom.gba", 0x33992e, 0xe
gUnknown_0833993C:: @ 833993C
.incbin "baserom.gba", 0x33993c, 0x5
gUnknown_08339941:: @ 8339941
.incbin "baserom.gba", 0x339941, 0x2
gUnknown_08339943:: @ 8339943
.incbin "baserom.gba", 0x339943, 0x4
gUnknown_08339947:: @ 8339947
.incbin "baserom.gba", 0x339947, 0x8
gUnknown_0833994F:: @ 833994F
.incbin "baserom.gba", 0x33994f, 0xe
gUnknown_0833995D:: @ 833995D
.incbin "baserom.gba", 0x33995d, 0x13
gUnknown_08339970:: @ 8339970
.incbin "baserom.gba", 0x339970, 0x4
gUnknown_08339974:: @ 8339974
.incbin "baserom.gba", 0x339974, 0xc
gUnknown_08339980:: @ 8339980
.incbin "baserom.gba", 0x339980, 0x38
gUnknown_083399B8:: @ 83399B8
.incbin "baserom.gba", 0x3399b8, 0x8
gUnknown_083399C0:: @ 83399C0
.incbin "baserom.gba", 0x3399c0, 0x8
gUnknown_083399C8:: @ 83399C8
.incbin "baserom.gba", 0x3399c8, 0x8
gUnknown_083399D0:: @ 83399D0
.incbin "baserom.gba", 0x3399d0, 0xc
gUnknown_083399DC:: @ 83399DC
.incbin "baserom.gba", 0x3399dc, 0x8
gUnknown_083399E4:: @ 83399E4
.incbin "baserom.gba", 0x3399e4, 0x3
gUnknown_083399E7:: @ 83399E7
.incbin "baserom.gba", 0x3399e7, 0x5
gUnknown_083399EC:: @ 83399EC
.incbin "baserom.gba", 0x3399ec, 0xd4
gUnknown_08339AC0:: @ 8339AC0
.incbin "baserom.gba", 0x339ac0, 0x8
gUnknown_08339AC8:: @ 8339AC8
.incbin "baserom.gba", 0x339ac8, 0x8
gUnknown_08339AD0:: @ 8339AD0
.incbin "baserom.gba", 0x339ad0, 0x8
gUnknown_08339AD8:: @ 8339AD8
.incbin "baserom.gba", 0x339ad8, 0x60
gUnknown_08339B38:: @ 8339B38
.incbin "baserom.gba", 0x339b38, 0x8
gUnknown_08339B40:: @ 8339B40
.incbin "baserom.gba", 0x339b40, 0x98
gUnknown_08339BD8:: @ 8339BD8
.incbin "baserom.gba", 0x339bd8, 0x8
gUnknown_08339BE0:: @ 8339BE0
.incbin "baserom.gba", 0x339be0, 0x44
gUnknown_08339C24:: @ 8339C24
.incbin "baserom.gba", 0x339c24, 0x8
gUnknown_08339C2C:: @ 8339C2C
.incbin "baserom.gba", 0x339c2c, 0x2c
gUnknown_08339C58:: @ 8339C58
.incbin "baserom.gba", 0x339c58, 0x8
gUnknown_08339C60:: @ 8339C60
.incbin "baserom.gba", 0x339c60, 0x18
gUnknown_08339C78:: @ 8339C78
.incbin "baserom.gba", 0x339c78, 0x28
gUnknown_08339CA0:: @ 8339CA0
.incbin "baserom.gba", 0x339ca0, 0x1e
gUnknown_08339CBE:: @ 8339CBE
.incbin "baserom.gba", 0x339cbe, 0x5
gUnknown_08339CC3:: @ 8339CC3
.incbin "baserom.gba", 0x339cc3, 0x5
gUnknown_08339CC8:: @ 8339CC8
.incbin "baserom.gba", 0x339cc8, 0x4c
gUnknown_08339D14:: @ 8339D14
.incbin "baserom.gba", 0x339d14, 0x8
gContestWinnerPicDummy:: @ 8339D1C
.incbin "baserom.gba", 0x339d1c, 0x20
gUnknown_08339D3C:: @ 8339D3C
.incbin "baserom.gba", 0x339d3c, 0x28
gUnknown_08339D64:: @ 8339D64
.incbin "baserom.gba", 0x339d64, 0x48
gUnknown_08339DAC:: @ 8339DAC
.incbin "baserom.gba", 0x339dac, 0x10
gUnknown_08339DBC:: @ 8339DBC
.incbin "baserom.gba", 0x339dbc, 0xc
gUnknown_08339DC8:: @ 8339DC8
.incbin "baserom.gba", 0x339dc8, 0xc
gUnknown_08339DD4:: @ 8339DD4
.incbin "baserom.gba", 0x339dd4, 0x2c
gUnknown_08339E00:: @ 8339E00
.incbin "baserom.gba", 0x339e00, 0x8
@ 8339E08
.include "data/tilesets/tileset_graphics.inc"
@ 83960F0
.include "data/tilesets/metatiles.inc"
@ 83DF704
.include "data/tilesets/tilesets.inc"
@ 83DFE14
.incbin "baserom.gba", 0x3dfe14, 0xa1fc0
gUnknown_08481DD4:: @ 8481DD4
.incbin "baserom.gba", 0x481dd4, 0x47a4
gUnknown_08486578:: @ 8486578
.incbin "baserom.gba", 0x486578, 0x980
gUnknown_08486EF8:: @ 8486EF8
.incbin "baserom.gba", 0x486ef8, 0x4
gUnknown_08486EFC:: @ 8486EFC
.incbin "baserom.gba", 0x486efc, 0x10090
gUnknown_08496F8C:: @ 8496F8C
.incbin "baserom.gba", 0x496f8c, 0x14
gUnknown_08496FA0:: @ 8496FA0
.incbin "baserom.gba", 0x496fa0, 0x14
gUnknown_08496FB4:: @ 8496FB4
.incbin "baserom.gba", 0x496fb4, 0x1c0
gUnknown_08497174:: @ 8497174
.incbin "baserom.gba", 0x497174, 0x288
gUnknown_084973FC:: @ 84973FC
.incbin "baserom.gba", 0x4973fc, 0x48
gUnknown_08497444:: @ 8497444
.incbin "baserom.gba", 0x497444, 0x4c
gUnknown_08497490:: @ 8497490
.incbin "baserom.gba", 0x497490, 0xc
gUnknown_0849749C:: @ 849749C
.incbin "baserom.gba", 0x49749c, 0x14
gUnknown_084974B0:: @ 84974B0
.incbin "baserom.gba", 0x4974b0, 0x8
gUnknown_084974B8:: @ 84974B8
.incbin "baserom.gba", 0x4974b8, 0x20
gUnknown_084974D8:: @ 84974D8
.incbin "baserom.gba", 0x4974d8, 0x10
gUnknown_084974E8:: @ 84974E8
.incbin "baserom.gba", 0x4974e8, 0x10
gUnknown_084974F8:: @ 84974F8
.incbin "baserom.gba", 0x4974f8, 0x10
gUnknown_08497508:: @ 8497508
.incbin "baserom.gba", 0x497508, 0x2
gUnknown_0849750A:: @ 849750A
.incbin "baserom.gba", 0x49750a, 0x2
gUnknown_0849750C:: @ 849750C
.incbin "baserom.gba", 0x49750c, 0x14
gUnknown_08497520:: @ 8497520
.incbin "baserom.gba", 0x497520, 0x10
gUnknown_08497530:: @ 8497530
.incbin "baserom.gba", 0x497530, 0xc
gUnknown_0849753C:: @ 849753C
.incbin "baserom.gba", 0x49753c, 0x4
gUnknown_08497540:: @ 8497540
.incbin "baserom.gba", 0x497540, 0x10
gUnknown_08497550:: @ 8497550
.incbin "baserom.gba", 0x497550, 0x4
gUnknown_08497554:: @ 8497554
.incbin "baserom.gba", 0x497554, 0x8
gUnknown_0849755C:: @ 849755C
.incbin "baserom.gba", 0x49755c, 0x40
gUnknown_0849759C:: @ 849759C
.incbin "baserom.gba", 0x49759c, 0x6
gUnknown_084975A2:: @ 84975A2
.incbin "baserom.gba", 0x4975a2, 0x6
gUnknown_084975A8:: @ 84975A8
.incbin "baserom.gba", 0x4975a8, 0x2
gUnknown_084975AA:: @ 84975AA
.incbin "baserom.gba", 0x4975aa, 0x6
gUnknown_084975B0:: @ 84975B0
.incbin "baserom.gba", 0x4975b0, 0xc
gUnknown_084975BC:: @ 84975BC
.incbin "baserom.gba", 0x4975bc, 0x8

1783
data/data3_a0_B.s Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2339,10 +2339,10 @@ gText_ByeBye:: @ 85ED44A
.string "My POKéMON and I help$"
.string "my fathers research.$"
gText_PkmnHatchedFromEgg:: @ 85ED5A5
gText_HatchedFromEgg:: @ 85ED5A5
.string "{STR_VAR_1} hatched from the EGG!$"
gText_NameHatchedPkmn:: @ 85ED5BE
gText_NickHatchPrompt:: @ 85ED5BE
.string "Would you like to nickname the newly\nhatched {STR_VAR_1}?$"
.align 2

BIN
graphics/misc/egg_hatch.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

BIN
graphics/misc/egg_shard.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B

View File

@ -1,23 +1,75 @@
#ifndef GUARD_bg_H
#define GUARD_bg_H
#ifndef GUARD_BG_H
#define GUARD_BG_H
struct BgTemplate {
u32 bg:2;
u32 charBaseIndex:2;
u32 mapBaseIndex:5;
u32 screenSize:2;
u32 paletteMode:1;
u32 priority:2;
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; // 0x1, 0x2 -> 0x3
u32 charBaseIndex:2; // 0x4, 0x8 -> 0xC
u32 mapBaseIndex:5; // 0x10, 0x20, 0x40, 0x80, 0x100 -> 0x1F0
u32 screenSize:2; // 0x200, 0x400 -> 0x600
u32 paletteMode:1; // 0x800
u32 priority:2; // 0x1000, 0x2000 > 0x3000
u32 baseTile:10;
};
void ResetBgsAndClearDma3BusyFlags(u32);
void InitBgsFromTemplates(u8, const struct BgTemplate *, u8);
u32 ChangeBgX(u8, u32, u8);
u32 ChangeBgY(u8, u32, u8);
void ResetBgs(void);
u8 GetBgMode(void);
void ResetBgControlStructs(void);
void Unused_ResetBgControlStruct(u8 bg);
void SetBgControlAttributes(u8 bg, u8 charBaseIndex, u8 mapBaseIndex, u8 screenSize, u8 paletteMode, u8 priority, u8 mosaic, u8 wraparound);
u16 GetBgControlAttribute(u8 bg, u8 attributeId);
u8 LoadBgVram(u8 bg, const void *src, u16 size, u16 destOffset, u8 mode);
void SetTextModeAndHideBgs(void);
bool8 IsInvalidBg(u8 bg);
int DummiedOutFireRedLeafGreenTileAllocFunc(int a1, int a2, int a3, int a4);
void ResetBgsAndClearDma3BusyFlags(u32 leftoverFireRedLeafGreenVariable);
void InitBgsFromTemplates(u8 bgMode, const struct BgTemplate *templates, u8 numTemplates);
void InitBgFromTemplate(const struct BgTemplate *template);
void SetBgMode(u8 bgMode);
u16 LoadBgTiles(u8 bg, const void* src, u16 size, u16 destOffset);
u16 LoadBgTilemap(u8 bg, const void *src, u16 size, u16 destOffset);
u16 Unused_LoadBgPalette(u8 bg, const void *src, u16 size, u16 destOffset);
bool8 IsDma3ManagerBusyWithBgCopy(void);
void ShowBg(u8 bg);
void HideBg(u8 bg);
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);
u8 Unused_AdjustBgMosaic(u8 a1, u8 a2);
void SetBgTilemapBuffer(u8 bg, void *tilemap);
void UnsetBgTilemapBuffer(u8 bg);
void* GetBgTilemapBuffer(u8 bg);
void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset);
void CopyBgTilemapBufferToVram(u8 bg);
void CopyToBgTilemapBufferRect(u8 bg, void* src, u8 destX, u8 destY, u8 width, u8 height);
void CopyToBgTilemapBufferRect_ChangePalette(u8 bg, void *src, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette);
void CopyRectToBgTilemapBufferRect(u8 bg, void* src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, u16 tileOffset, u16 palette2);
void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height);
void ShowBg(u8);
void HideBg(u8);
void CopyBgTilemapBufferToVram(u8);
void FillBgTilemapBufferRect(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height, u8 palette);
void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 width, u8 height, u8 paletteSlot, s16 tileNumDelta);
u16 GetBgMetricTextMode(u8 bg, u8 whichMetric);
u32 GetBgMetricAffineMode(u8 bg, u8 whichMetric);
u32 GetTileMapIndexFromCoords(s32 x, s32 y, s32 screenSize, u32 screenWidth, u32 screenHeight);
void CopyTileMapEntry(u16 *src, u16 *dest, s32 palette1, u32 tileOffset, u32 palette2);
u32 GetBgType(u8 bg);
bool32 IsInvalidBg32(u8 bg);
bool32 IsTileMapOutsideWram(u8 bg);
#endif //GUARD_bg_H
#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,8 @@ 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);
int CheckForSpaceForDma3Request(s16 index);
#endif
#endif // GUARD_DMA3_H

View File

@ -18,6 +18,14 @@ void memcpy(void *, const void *, size_t);
#define ARRAY_COUNT(array) (sizeof(array) / sizeof((array)[0]))
// useful math macros
// Converts a number to Q8.8 fixed-point format
#define Q_8_8(n) ((s16)((n) * 256))
// Converts a number to Q4.12 fixed-point format
#define Q_4_12(n) ((s16)((n) * 4096))
#define POKEMON_NAME_LENGTH 10
#define OT_NAME_LENGTH 7
@ -645,7 +653,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;
};

View File

@ -1,4 +1,3 @@
#ifndef GUARD_GPU_REGS_H
#define GUARD_GPU_REGS_H
@ -7,9 +6,14 @@
// Exported RAM declarations
// Exported ROM declarations
void DisableInterrupts(u16);
void EnableInterrupts(u16);
void SetGpuReg(u8, u16);
void InitGpuRegManager(void);
void CopyBufferedValuesToGpuRegs(void);
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

@ -620,4 +620,8 @@ bool8 IsPokeSpriteNotFlipped(u16 species);
bool8 IsMonShiny(struct Pokemon *mon);
bool8 IsShinyOtIdPersonality(u32 otId, u32 personality);
#include "sprite.h"
void DoMonFrontSpriteAnimation(struct Sprite* sprite, u16 species, bool8 noCry, u8 arg3);
#endif // GUARD_POKEMON_H

View File

@ -138,28 +138,37 @@ struct FontInfo
u8 shadowColor:4;
};
struct GlyphWidthFunc{
struct GlyphWidthFunc
{
u32 font_id;
u32 (*func)(u16 glyphId, bool32 isJapanese);
};
struct KeypadIcon {
struct KeypadIcon
{
u16 tile_offset;
u8 width;
u8 height;
};
struct __attribute__((packed)) TextColor
{
u8 fgColor;
u8 bgColor;
u8 shadowColor;
};
extern u8 gStringVar1[];
extern u8 gStringVar2[];
extern u8 gStringVar3[];
extern u8 gStringVar4[];
void SetFontsPointer(const struct FontInfo *fonts);
void DeactivateAllTextPrinters (void);
void DeactivateAllTextPrinters(void);
u16 PrintTextOnWindow(u8 windowId, u8 fontId, u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextSubPrinter *, u16));
bool16 AddTextPrinter(struct TextSubPrinter *textSubPrinter, u8 speed, void (*callback)(struct TextSubPrinter *, u16));
void RunTextPrinters(void);
bool8 IsTextPrinterActive(u8 id);
bool16 IsTextPrinterActive(u8 id);
u32 RenderFont(struct TextPrinter *textPrinter);
void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor);
void SaveTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor);

View File

@ -24,6 +24,17 @@ struct WindowTemplate
u16 baseBlock;
};
#define DUMMY_WIN_TEMPLATE \
{ \
0xFF, \
0, \
0, \
0, \
0, \
0, \
0, \
}
struct Window
{
struct WindowTemplate window;

View File

@ -80,7 +80,7 @@ SECTIONS {
src/util.o(.text);
src/blend_palette.o(.text);
asm/daycare.o(.text);
asm/egg_hatch.o(.text);
src/egg_hatch.o(.text);
asm/battle_interface.o(.text);
asm/smokescreen.o(.text);
asm/pokeball.o(.text);
@ -340,8 +340,10 @@ SECTIONS {
src/trig.o(.rodata);
src/util.o(.rodata);
data/data3.o(.rodata);
src/egg_hatch.o(.rodata);
data/data3_a0_A.o(.rodata);
data/field_map_obj.o(.rodata);
data/data3.o(.rodata_b);
data/data3_a0_B.o(.rodata);
src/berry.o(.rodata);
data/data3_a1.o(.rodata);
src/pokemon_size_record.o(.rodata)

314
src/bg.c
View File

@ -1,21 +1,12 @@
#include "global.h"
#include "dma3.h"
#include "bg.h"
#include "dma3.h"
#include "gpu_regs.h"
#define DISPCNT_ALL_BG_AND_MODE_BITS 0x0F07
#define DISPCNT_ALL_BG_AND_MODE_BITS (DISPCNT_BG_ALL_ON | 0x7)
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 BgControl
{
struct BgConfig {
u16 visible:1;
u16 unknown_1:1;
@ -35,7 +26,8 @@ struct BgControl {
u16 bgVisibilityAndMode;
};
struct BgConfig2 {
struct BgConfig2
{
u32 baseTile:10;
u32 basePalette:4;
u32 unk_3:18;
@ -45,54 +37,36 @@ struct BgConfig2 {
u32 bg_y;
};
static struct BgControl gGpuBgConfigs;
static struct BgConfig2 gGpuBgConfigs2[4];
static u32 gDmaBusyBitfield[4];
static IWRAM_DATA struct BgControl sGpuBgConfigs;
static IWRAM_DATA struct BgConfig2 sGpuBgConfigs2[4];
static IWRAM_DATA u32 sDmaBusyBitfield[4];
u32 gUnneededFireRedVariable;
static const struct BgConfig gZeroedBgControlStruct = { 0 };
extern void SetGpuReg(u8 regOffset, u16 value);
extern void SetGpuReg_ForcedBlank(u8 regOffset, u16 value);
extern u16 GetGpuReg(u8 regOffset);
extern int CheckForSpaceForDma3Request(s16 index);
bool32 IsInvalidBg32(u8);
void ResetBgControlStructs();
u16 GetBgMetricTextMode(u8, u8);
u32 GetBgMetricAffineMode(u8, u8);
u32 GetBgType(u8);
void SetTextModeAndHideBgs();
bool8 IsInvalidBg(u8);
bool32 IsTileMapOutsideWram(u8);
void CopyRectToBgTilemapBufferRect(u8, void*, u8, u8, u8, u8, u8, u8, u8, u8, u8, u16, u16);
void CopyTileMapEntry(u16*, u16*, s32, u32, u32);
u32 GetTileMapIndexFromCoords(s32, s32, s32, u32, u32);
void WriteSequenceToBgTilemapBuffer(u8, u16, u8, u8, u8, u8, u8, s16);
static const struct BgConfig sZeroedBgControlStruct = { 0 };
void ResetBgs(void)
{
ResetBgControlStructs();
gGpuBgConfigs.bgVisibilityAndMode = 0;
sGpuBgConfigs.bgVisibilityAndMode = 0;
SetTextModeAndHideBgs();
}
void SetBgModeInternal(u8 bgMode)
static void SetBgModeInternal(u8 bgMode)
{
gGpuBgConfigs.bgVisibilityAndMode &= 0xFFF8;
gGpuBgConfigs.bgVisibilityAndMode |= bgMode;
sGpuBgConfigs.bgVisibilityAndMode &= 0xFFF8;
sGpuBgConfigs.bgVisibilityAndMode |= bgMode;
}
u8 GetBgMode(void)
{
return gGpuBgConfigs.bgVisibilityAndMode & 0x7;
return sGpuBgConfigs.bgVisibilityAndMode & 0x7;
}
void ResetBgControlStructs(void)
{
struct BgConfig* bgConfigs = &gGpuBgConfigs.configs[0];
struct BgConfig zeroedConfig = gZeroedBgControlStruct;
struct BgConfig* bgConfigs = &sGpuBgConfigs.configs[0];
struct BgConfig zeroedConfig = sZeroedBgControlStruct;
int i;
for (i = 0; i < 4; i++)
@ -105,7 +79,7 @@ void Unused_ResetBgControlStruct(u8 bg)
{
if (IsInvalidBg(bg) == FALSE)
{
gGpuBgConfigs.configs[bg] = gZeroedBgControlStruct;
sGpuBgConfigs.configs[bg] = sZeroedBgControlStruct;
}
}
@ -115,88 +89,88 @@ void SetBgControlAttributes(u8 bg, u8 charBaseIndex, u8 mapBaseIndex, u8 screenS
{
if (charBaseIndex != 0xFF)
{
gGpuBgConfigs.configs[bg].charBaseIndex = charBaseIndex & 0x3;
sGpuBgConfigs.configs[bg].charBaseIndex = charBaseIndex & 0x3;
}
if (mapBaseIndex != 0xFF)
{
gGpuBgConfigs.configs[bg].mapBaseIndex = mapBaseIndex & 0x1F;
sGpuBgConfigs.configs[bg].mapBaseIndex = mapBaseIndex & 0x1F;
}
if (screenSize != 0xFF)
{
gGpuBgConfigs.configs[bg].screenSize = screenSize & 0x3;
sGpuBgConfigs.configs[bg].screenSize = screenSize & 0x3;
}
if (paletteMode != 0xFF)
{
gGpuBgConfigs.configs[bg].paletteMode = paletteMode;
sGpuBgConfigs.configs[bg].paletteMode = paletteMode;
}
if (priority != 0xFF)
{
gGpuBgConfigs.configs[bg].priority = priority & 0x3;
sGpuBgConfigs.configs[bg].priority = priority & 0x3;
}
if (mosaic != 0xFF)
{
gGpuBgConfigs.configs[bg].mosaic = mosaic & 0x1;
sGpuBgConfigs.configs[bg].mosaic = mosaic & 0x1;
}
if (wraparound != 0xFF)
{
gGpuBgConfigs.configs[bg].wraparound = wraparound;
sGpuBgConfigs.configs[bg].wraparound = wraparound;
}
gGpuBgConfigs.configs[bg].unknown_2 = 0;
gGpuBgConfigs.configs[bg].unknown_3 = 0;
sGpuBgConfigs.configs[bg].unknown_2 = 0;
sGpuBgConfigs.configs[bg].unknown_3 = 0;
gGpuBgConfigs.configs[bg].visible = 1;
sGpuBgConfigs.configs[bg].visible = 1;
}
}
u16 GetBgControlAttribute(u8 bg, u8 attributeId)
{
if (IsInvalidBg(bg) == FALSE && gGpuBgConfigs.configs[bg].visible != FALSE)
if (IsInvalidBg(bg) == FALSE && sGpuBgConfigs.configs[bg].visible != FALSE)
{
switch (attributeId)
{
case BG_CTRL_ATTR_VISIBLE:
return gGpuBgConfigs.configs[bg].visible;
return sGpuBgConfigs.configs[bg].visible;
case BG_CTRL_ATTR_CHARBASEINDEX:
return gGpuBgConfigs.configs[bg].charBaseIndex;
return sGpuBgConfigs.configs[bg].charBaseIndex;
case BG_CTRL_ATTR_MAPBASEINDEX:
return gGpuBgConfigs.configs[bg].mapBaseIndex;
return sGpuBgConfigs.configs[bg].mapBaseIndex;
case BG_CTRL_ATTR_SCREENSIZE:
return gGpuBgConfigs.configs[bg].screenSize;
return sGpuBgConfigs.configs[bg].screenSize;
case BG_CTRL_ATTR_PALETTEMODE:
return gGpuBgConfigs.configs[bg].paletteMode;
return sGpuBgConfigs.configs[bg].paletteMode;
case BG_CTRL_ATTR_PRIORITY:
return gGpuBgConfigs.configs[bg].priority;
return sGpuBgConfigs.configs[bg].priority;
case BG_CTRL_ATTR_MOSAIC:
return gGpuBgConfigs.configs[bg].mosaic;
return sGpuBgConfigs.configs[bg].mosaic;
case BG_CTRL_ATTR_WRAPAROUND:
return gGpuBgConfigs.configs[bg].wraparound;
return sGpuBgConfigs.configs[bg].wraparound;
}
}
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;
if (IsInvalidBg(bg) == FALSE && gGpuBgConfigs.configs[bg].visible != FALSE)
if (IsInvalidBg(bg) == FALSE && sGpuBgConfigs.configs[bg].visible != FALSE)
{
switch (mode)
{
case 0x1:
offset = gGpuBgConfigs.configs[bg].charBaseIndex * BG_CHAR_SIZE;
offset = sGpuBgConfigs.configs[bg].charBaseIndex * BG_CHAR_SIZE;
break;
case 0x2:
offset = gGpuBgConfigs.configs[bg].mapBaseIndex * BG_SCREEN_SIZE;
offset = sGpuBgConfigs.configs[bg].mapBaseIndex * BG_SCREEN_SIZE;
break;
default:
cursor = -1;
@ -221,51 +195,51 @@ end:
return cursor;
}
void ShowBgInternal(u8 bg)
static void ShowBgInternal(u8 bg)
{
u16 value;
if (IsInvalidBg(bg) == FALSE && gGpuBgConfigs.configs[bg].visible != FALSE)
if (IsInvalidBg(bg) == FALSE && sGpuBgConfigs.configs[bg].visible != FALSE)
{
value = gGpuBgConfigs.configs[bg].priority |
(gGpuBgConfigs.configs[bg].charBaseIndex << 2) |
(gGpuBgConfigs.configs[bg].mosaic << 6) |
(gGpuBgConfigs.configs[bg].paletteMode << 7) |
(gGpuBgConfigs.configs[bg].mapBaseIndex << 8) |
(gGpuBgConfigs.configs[bg].wraparound << 13) |
(gGpuBgConfigs.configs[bg].screenSize << 14);
value = sGpuBgConfigs.configs[bg].priority |
(sGpuBgConfigs.configs[bg].charBaseIndex << 2) |
(sGpuBgConfigs.configs[bg].mosaic << 6) |
(sGpuBgConfigs.configs[bg].paletteMode << 7) |
(sGpuBgConfigs.configs[bg].mapBaseIndex << 8) |
(sGpuBgConfigs.configs[bg].wraparound << 13) |
(sGpuBgConfigs.configs[bg].screenSize << 14);
SetGpuReg((bg << 1) + 0x8, value);
gGpuBgConfigs.bgVisibilityAndMode |= 1 << (bg + 8);
gGpuBgConfigs.bgVisibilityAndMode &= DISPCNT_ALL_BG_AND_MODE_BITS;
sGpuBgConfigs.bgVisibilityAndMode |= 1 << (bg + 8);
sGpuBgConfigs.bgVisibilityAndMode &= DISPCNT_ALL_BG_AND_MODE_BITS;
}
}
void HideBgInternal(u8 bg)
static void HideBgInternal(u8 bg)
{
if (IsInvalidBg(bg) == FALSE)
{
gGpuBgConfigs.bgVisibilityAndMode &= ~(1 << (bg + 8));
gGpuBgConfigs.bgVisibilityAndMode &= DISPCNT_ALL_BG_AND_MODE_BITS;
sGpuBgConfigs.bgVisibilityAndMode &= ~(1 << (bg + 8));
sGpuBgConfigs.bgVisibilityAndMode &= DISPCNT_ALL_BG_AND_MODE_BITS;
}
}
void SyncBgVisibilityAndMode()
static void SyncBgVisibilityAndMode(void)
{
SetGpuReg(0, (GetGpuReg(0) & ~DISPCNT_ALL_BG_AND_MODE_BITS) | gGpuBgConfigs.bgVisibilityAndMode);
SetGpuReg(0, (GetGpuReg(0) & ~DISPCNT_ALL_BG_AND_MODE_BITS) | sGpuBgConfigs.bgVisibilityAndMode);
}
void SetTextModeAndHideBgs()
void SetTextModeAndHideBgs(void)
{
SetGpuReg(0, GetGpuReg(0) & ~DISPCNT_ALL_BG_AND_MODE_BITS);
}
void SetBgAffineInternal(u8 bg, u32 srcCenterX, u32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle)
static void SetBgAffineInternal(u8 bg, u32 srcCenterX, u32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle)
{
struct BgAffineSrcData src;
struct BgAffineDstData dest;
switch (gGpuBgConfigs.bgVisibilityAndMode & 0x7)
switch (sGpuBgConfigs.bgVisibilityAndMode & 0x7)
{
case 1:
if (bg != 2)
@ -320,7 +294,7 @@ void ResetBgsAndClearDma3BusyFlags(u32 leftoverFireRedLeafGreenVariable)
for (i = 0; i < 4; i++)
{
gDmaBusyBitfield[i] = 0;
sDmaBusyBitfield[i] = 0;
}
gUnneededFireRedVariable = leftoverFireRedLeafGreenVariable;
@ -347,13 +321,13 @@ void InitBgsFromTemplates(u8 bgMode, const struct BgTemplate *templates, u8 numT
0,
0);
gGpuBgConfigs2[bg].baseTile = templates[i].baseTile;
gGpuBgConfigs2[bg].basePalette = 0;
gGpuBgConfigs2[bg].unk_3 = 0;
sGpuBgConfigs2[bg].baseTile = templates[i].baseTile;
sGpuBgConfigs2[bg].basePalette = 0;
sGpuBgConfigs2[bg].unk_3 = 0;
gGpuBgConfigs2[bg].tilemap = NULL;
gGpuBgConfigs2[bg].bg_x = 0;
gGpuBgConfigs2[bg].bg_y = 0;
sGpuBgConfigs2[bg].tilemap = NULL;
sGpuBgConfigs2[bg].bg_x = 0;
sGpuBgConfigs2[bg].bg_y = 0;
}
}
}
@ -373,13 +347,13 @@ void InitBgFromTemplate(const struct BgTemplate *template)
0,
0);
gGpuBgConfigs2[bg].baseTile = template->baseTile;
gGpuBgConfigs2[bg].basePalette = 0;
gGpuBgConfigs2[bg].unk_3 = 0;
sGpuBgConfigs2[bg].baseTile = template->baseTile;
sGpuBgConfigs2[bg].basePalette = 0;
sGpuBgConfigs2[bg].unk_3 = 0;
gGpuBgConfigs2[bg].tilemap = NULL;
gGpuBgConfigs2[bg].bg_x = 0;
gGpuBgConfigs2[bg].bg_y = 0;
sGpuBgConfigs2[bg].tilemap = NULL;
sGpuBgConfigs2[bg].bg_x = 0;
sGpuBgConfigs2[bg].bg_y = 0;
}
}
@ -388,18 +362,18 @@ 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;
if (GetBgControlAttribute(bg, BG_CTRL_ATTR_PALETTEMODE) == 0)
{
tileOffset = (gGpuBgConfigs2[bg].baseTile + destOffset) * 0x20;
tileOffset = (sGpuBgConfigs2[bg].baseTile + destOffset) * 0x20;
}
else
{
tileOffset = (gGpuBgConfigs2[bg].baseTile + destOffset) * 0x40;
tileOffset = (sGpuBgConfigs2[bg].baseTile + destOffset) * 0x40;
}
cursor = LoadBgVram(bg, src, size, tileOffset, DISPCNT_MODE_1);
@ -409,7 +383,7 @@ u16 LoadBgTiles(u8 bg, void* src, u16 size, u16 destOffset)
return -1;
}
gDmaBusyBitfield[cursor / 0x20] |= (1 << (cursor % 0x20));
sDmaBusyBitfield[cursor / 0x20] |= (1 << (cursor % 0x20));
if (gUnneededFireRedVariable == 1)
{
@ -419,7 +393,7 @@ u16 LoadBgTiles(u8 bg, void* src, u16 size, u16 destOffset)
return cursor;
}
u16 LoadBgTilemap(u8 bg, void *src, u16 size, u16 destOffset)
u16 LoadBgTilemap(u8 bg, const void *src, u16 size, u16 destOffset)
{
u8 cursor;
@ -430,19 +404,19 @@ u16 LoadBgTilemap(u8 bg, void *src, u16 size, u16 destOffset)
return -1;
}
gDmaBusyBitfield[cursor / 0x20] |= (1 << (cursor % 0x20));
sDmaBusyBitfield[cursor / 0x20] |= (1 << (cursor % 0x20));
return cursor;
}
u16 Unused_LoadBgPalette(u8 bg, void *src, u16 size, u16 destOffset)
u16 Unused_LoadBgPalette(u8 bg, const void *src, u16 size, u16 destOffset)
{
u16 paletteOffset;
s8 cursor;
if (IsInvalidBg32(bg) == FALSE)
{
paletteOffset = (gGpuBgConfigs2[bg].basePalette * 0x20) + (destOffset * 2);
paletteOffset = (sGpuBgConfigs2[bg].basePalette * 0x20) + (destOffset * 2);
cursor = RequestDma3Copy(src, (void*)(paletteOffset + BG_PLTT), size, 0);
if (cursor == -1)
@ -455,7 +429,7 @@ u16 Unused_LoadBgPalette(u8 bg, void *src, u16 size, u16 destOffset)
return -1;
}
gDmaBusyBitfield[cursor / 0x20] |= (1 << (cursor % 0x20));
sDmaBusyBitfield[cursor / 0x20] |= (1 << (cursor % 0x20));
return (u8)cursor;
}
@ -474,7 +448,7 @@ bool8 IsDma3ManagerBusyWithBgCopy(void)
div = i / 0x20;
mod = i % 0x20;
if ((gDmaBusyBitfield[div] & (1 << mod)) != FALSE)
if ((sDmaBusyBitfield[div] & (1 << mod)) != FALSE)
{
reqSpace = CheckForSpaceForDma3Request(i);
if (reqSpace == -1)
@ -482,7 +456,7 @@ bool8 IsDma3ManagerBusyWithBgCopy(void)
return TRUE;
}
gDmaBusyBitfield[div] &= ~(1 << mod);
sDmaBusyBitfield[div] &= ~(1 << mod);
}
}
@ -508,7 +482,7 @@ _08001AE4:\n\
sub r0, r5, r0\n\
lsl r0, #24\n\
lsr r0, #24\n\
ldr r1, =gDmaBusyBitfield\n\
ldr r1, =sDmaBusyBitfield\n\
lsr r2, #22\n\
add r4, r2, r1\n\
mov r6, #0x1\n\
@ -614,7 +588,7 @@ u16 GetBgAttribute(u8 bg, u8 attributeId)
case 9:
return GetBgType(bg);
case 10:
return gGpuBgConfigs2[bg].baseTile;
return sGpuBgConfigs2[bg].baseTile;
default:
return -1;
}
@ -635,13 +609,13 @@ u32 ChangeBgX(u8 bg, u32 value, u8 op)
{
case 0:
default:
gGpuBgConfigs2[bg].bg_x = value;
sGpuBgConfigs2[bg].bg_x = value;
break;
case 1:
gGpuBgConfigs2[bg].bg_x += value;
sGpuBgConfigs2[bg].bg_x += value;
break;
case 2:
gGpuBgConfigs2[bg].bg_x -= value;
sGpuBgConfigs2[bg].bg_x -= value;
break;
}
@ -650,23 +624,23 @@ u32 ChangeBgX(u8 bg, u32 value, u8 op)
switch (bg)
{
case 0:
temp1 = gGpuBgConfigs2[0].bg_x >> 0x8;
temp1 = sGpuBgConfigs2[0].bg_x >> 0x8;
SetGpuReg(REG_OFFSET_BG0HOFS, temp1);
break;
case 1:
temp1 = gGpuBgConfigs2[1].bg_x >> 0x8;
temp1 = sGpuBgConfigs2[1].bg_x >> 0x8;
SetGpuReg(REG_OFFSET_BG1HOFS, temp1);
break;
case 2:
if (mode == 0)
{
temp1 = gGpuBgConfigs2[2].bg_x >> 0x8;
temp1 = sGpuBgConfigs2[2].bg_x >> 0x8;
SetGpuReg(REG_OFFSET_BG2HOFS, temp1);
}
else
{
temp1 = gGpuBgConfigs2[2].bg_x >> 0x10;
temp2 = gGpuBgConfigs2[2].bg_x & 0xFFFF;
temp1 = sGpuBgConfigs2[2].bg_x >> 0x10;
temp2 = sGpuBgConfigs2[2].bg_x & 0xFFFF;
SetGpuReg(REG_OFFSET_BG2X_H, temp1);
SetGpuReg(REG_OFFSET_BG2X_L, temp2);
}
@ -674,20 +648,20 @@ u32 ChangeBgX(u8 bg, u32 value, u8 op)
case 3:
if (mode == 0)
{
temp1 = gGpuBgConfigs2[3].bg_x >> 0x8;
temp1 = sGpuBgConfigs2[3].bg_x >> 0x8;
SetGpuReg(REG_OFFSET_BG3HOFS, temp1);
}
else if (mode == 2)
{
temp1 = gGpuBgConfigs2[3].bg_x >> 0x10;
temp2 = gGpuBgConfigs2[3].bg_x & 0xFFFF;
temp1 = sGpuBgConfigs2[3].bg_x >> 0x10;
temp2 = sGpuBgConfigs2[3].bg_x & 0xFFFF;
SetGpuReg(REG_OFFSET_BG3X_H, temp1);
SetGpuReg(REG_OFFSET_BG3X_L, temp2);
}
break;
}
return gGpuBgConfigs2[bg].bg_x;
return sGpuBgConfigs2[bg].bg_x;
}
u32 GetBgX(u8 bg)
@ -696,7 +670,7 @@ u32 GetBgX(u8 bg)
return -1;
if (GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0)
return -1;
return gGpuBgConfigs2[bg].bg_x;
return sGpuBgConfigs2[bg].bg_x;
}
u32 ChangeBgY(u8 bg, u32 value, u8 op)
@ -714,13 +688,13 @@ u32 ChangeBgY(u8 bg, u32 value, u8 op)
{
case 0:
default:
gGpuBgConfigs2[bg].bg_y = value;
sGpuBgConfigs2[bg].bg_y = value;
break;
case 1:
gGpuBgConfigs2[bg].bg_y += value;
sGpuBgConfigs2[bg].bg_y += value;
break;
case 2:
gGpuBgConfigs2[bg].bg_y -= value;
sGpuBgConfigs2[bg].bg_y -= value;
break;
}
@ -729,23 +703,23 @@ u32 ChangeBgY(u8 bg, u32 value, u8 op)
switch (bg)
{
case 0:
temp1 = gGpuBgConfigs2[0].bg_y >> 0x8;
temp1 = sGpuBgConfigs2[0].bg_y >> 0x8;
SetGpuReg(REG_OFFSET_BG0VOFS, temp1);
break;
case 1:
temp1 = gGpuBgConfigs2[1].bg_y >> 0x8;
temp1 = sGpuBgConfigs2[1].bg_y >> 0x8;
SetGpuReg(REG_OFFSET_BG1VOFS, temp1);
break;
case 2:
if (mode == 0)
{
temp1 = gGpuBgConfigs2[2].bg_y >> 0x8;
temp1 = sGpuBgConfigs2[2].bg_y >> 0x8;
SetGpuReg(REG_OFFSET_BG2VOFS, temp1);
}
else
{
temp1 = gGpuBgConfigs2[2].bg_y >> 0x10;
temp2 = gGpuBgConfigs2[2].bg_y & 0xFFFF;
temp1 = sGpuBgConfigs2[2].bg_y >> 0x10;
temp2 = sGpuBgConfigs2[2].bg_y & 0xFFFF;
SetGpuReg(REG_OFFSET_BG2Y_H, temp1);
SetGpuReg(REG_OFFSET_BG2Y_L, temp2);
}
@ -753,20 +727,20 @@ u32 ChangeBgY(u8 bg, u32 value, u8 op)
case 3:
if (mode == 0)
{
temp1 = gGpuBgConfigs2[3].bg_y >> 0x8;
temp1 = sGpuBgConfigs2[3].bg_y >> 0x8;
SetGpuReg(REG_OFFSET_BG3VOFS, temp1);
}
else if (mode == 2)
{
temp1 = gGpuBgConfigs2[3].bg_y >> 0x10;
temp2 = gGpuBgConfigs2[3].bg_y & 0xFFFF;
temp1 = sGpuBgConfigs2[3].bg_y >> 0x10;
temp2 = sGpuBgConfigs2[3].bg_y & 0xFFFF;
SetGpuReg(REG_OFFSET_BG3Y_H, temp1);
SetGpuReg(REG_OFFSET_BG3Y_L, temp2);
}
break;
}
return gGpuBgConfigs2[bg].bg_y;
return sGpuBgConfigs2[bg].bg_y;
}
u32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op)
@ -784,13 +758,13 @@ u32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op)
{
case 0:
default:
gGpuBgConfigs2[bg].bg_y = value;
sGpuBgConfigs2[bg].bg_y = value;
break;
case 1:
gGpuBgConfigs2[bg].bg_y += value;
sGpuBgConfigs2[bg].bg_y += value;
break;
case 2:
gGpuBgConfigs2[bg].bg_y -= value;
sGpuBgConfigs2[bg].bg_y -= value;
break;
}
@ -799,24 +773,24 @@ u32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op)
switch (bg)
{
case 0:
temp1 = gGpuBgConfigs2[0].bg_y >> 0x8;
temp1 = sGpuBgConfigs2[0].bg_y >> 0x8;
SetGpuReg_ForcedBlank(REG_OFFSET_BG0VOFS, temp1);
break;
case 1:
temp1 = gGpuBgConfigs2[1].bg_y >> 0x8;
temp1 = sGpuBgConfigs2[1].bg_y >> 0x8;
SetGpuReg_ForcedBlank(REG_OFFSET_BG1VOFS, temp1);
break;
case 2:
if (mode == 0)
{
temp1 = gGpuBgConfigs2[2].bg_y >> 0x8;
temp1 = sGpuBgConfigs2[2].bg_y >> 0x8;
SetGpuReg_ForcedBlank(REG_OFFSET_BG2VOFS, temp1);
}
else
{
temp1 = gGpuBgConfigs2[2].bg_y >> 0x10;
temp2 = gGpuBgConfigs2[2].bg_y & 0xFFFF;
temp1 = sGpuBgConfigs2[2].bg_y >> 0x10;
temp2 = sGpuBgConfigs2[2].bg_y & 0xFFFF;
SetGpuReg_ForcedBlank(REG_OFFSET_BG2Y_H, temp1);
SetGpuReg_ForcedBlank(REG_OFFSET_BG2Y_L, temp2);
}
@ -824,20 +798,20 @@ u32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op)
case 3:
if (mode == 0)
{
temp1 = gGpuBgConfigs2[3].bg_y >> 0x8;
temp1 = sGpuBgConfigs2[3].bg_y >> 0x8;
SetGpuReg_ForcedBlank(REG_OFFSET_BG3VOFS, temp1);
}
else if (mode == 2)
{
temp1 = gGpuBgConfigs2[3].bg_y >> 0x10;
temp2 = gGpuBgConfigs2[3].bg_y & 0xFFFF;
temp1 = sGpuBgConfigs2[3].bg_y >> 0x10;
temp2 = sGpuBgConfigs2[3].bg_y & 0xFFFF;
SetGpuReg_ForcedBlank(REG_OFFSET_BG3Y_H, temp1);
SetGpuReg_ForcedBlank(REG_OFFSET_BG3Y_L, temp2);
}
break;
}
return gGpuBgConfigs2[bg].bg_y;
return sGpuBgConfigs2[bg].bg_y;
}
u32 GetBgY(u8 bg)
@ -846,7 +820,7 @@ u32 GetBgY(u8 bg)
return -1;
if (GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0)
return -1;
return gGpuBgConfigs2[bg].bg_y;
return sGpuBgConfigs2[bg].bg_y;
}
void SetBgAffine(u8 bg, u32 srcCenterX, u32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle)
@ -933,7 +907,7 @@ void SetBgTilemapBuffer(u8 bg, void *tilemap)
{
if (IsInvalidBg32(bg) == FALSE && GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) != 0x0)
{
gGpuBgConfigs2[bg].tilemap = tilemap;
sGpuBgConfigs2[bg].tilemap = tilemap;
}
}
@ -941,7 +915,7 @@ void UnsetBgTilemapBuffer(u8 bg)
{
if (IsInvalidBg32(bg) == FALSE && GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) != 0x0)
{
gGpuBgConfigs2[bg].tilemap = NULL;
sGpuBgConfigs2[bg].tilemap = NULL;
}
}
@ -951,20 +925,20 @@ void* GetBgTilemapBuffer(u8 bg)
return NULL;
if (GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0)
return NULL;
return gGpuBgConfigs2[bg].tilemap;
return sGpuBgConfigs2[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)
{
if (mode != 0)
{
CpuCopy16(src, (void *)(gGpuBgConfigs2[bg].tilemap + (destOffset * 2)), mode);
CpuCopy16(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2)), mode);
}
else
{
LZ77UnCompWram(src, (void *)(gGpuBgConfigs2[bg].tilemap + (destOffset * 2)));
LZ77UnCompWram(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2)));
}
}
}
@ -987,7 +961,7 @@ void CopyBgTilemapBufferToVram(u8 bg)
sizeToLoad = 0;
break;
}
LoadBgVram(bg, gGpuBgConfigs2[bg].tilemap, sizeToLoad, 0, 2);
LoadBgVram(bg, sGpuBgConfigs2[bg].tilemap, sizeToLoad, 0, 2);
}
}
@ -1008,7 +982,7 @@ void CopyToBgTilemapBufferRect(u8 bg, void* src, u8 destX, u8 destY, u8 width, u
{
for (destX16 = destX; destX16 < (destX + width); destX16++)
{
((u16*)gGpuBgConfigs2[bg].tilemap)[((destY16 * 0x20) + destX16)] = *((u16*)srcCopy)++;
((u16*)sGpuBgConfigs2[bg].tilemap)[((destY16 * 0x20) + destX16)] = *((u16*)srcCopy)++;
}
}
break;
@ -1019,7 +993,7 @@ void CopyToBgTilemapBufferRect(u8 bg, void* src, u8 destX, u8 destY, u8 width, u
{
for (destX16 = destX; destX16 < (destX + width); destX16++)
{
((u8*)gGpuBgConfigs2[bg].tilemap)[((destY16 * mode) + destX16)] = *((u8*)srcCopy)++;
((u8*)sGpuBgConfigs2[bg].tilemap)[((destY16 * mode) + destX16)] = *((u8*)srcCopy)++;
}
}
break;
@ -1056,7 +1030,7 @@ void CopyRectToBgTilemapBufferRect(u8 bg, void* src, u8 srcX, u8 srcY, u8 srcWid
{
for (destX16 = destX; destX16 < (destX + rectWidth); destX16++)
{
CopyTileMapEntry(&((u16*)srcCopy)[(srcY * rectWidth) + srcX], &((u16*)gGpuBgConfigs2[bg].tilemap)[GetTileMapIndexFromCoords(destX16, destY16, attribute, mode, mode2)], palette1, tileOffset, palette2);
CopyTileMapEntry(&((u16*)srcCopy)[(srcY * rectWidth) + srcX], &((u16*)sGpuBgConfigs2[bg].tilemap)[GetTileMapIndexFromCoords(destX16, destY16, attribute, mode, mode2)], palette1, tileOffset, palette2);
}
}
break;
@ -1067,7 +1041,7 @@ void CopyRectToBgTilemapBufferRect(u8 bg, void* src, u8 srcX, u8 srcY, u8 srcWid
{
for (destX16 = destX; destX16 < (destX + rectWidth); destX16++)
{
CopyTileMapEntry(&((u16*)srcCopy)[(srcY * rectWidth) + srcX], &((u16*)gGpuBgConfigs2[bg].tilemap)[GetTileMapIndexFromCoords(destX16, destY16, attribute, mode, mode2)], palette1, tileOffset, palette2);
CopyTileMapEntry(&((u16*)srcCopy)[(srcY * rectWidth) + srcX], &((u16*)sGpuBgConfigs2[bg].tilemap)[GetTileMapIndexFromCoords(destX16, destY16, attribute, mode, mode2)], palette1, tileOffset, palette2);
}
}
break;
@ -1195,7 +1169,7 @@ _080025F8:\n\
bge _0800265A\n\
ldr r2, [sp, #0x4]\n\
lsl r0, r2, #4\n\
ldr r1, =gGpuBgConfigs2+4\n\
ldr r1, =sGpuBgConfigs2+4\n\
add r0, r1\n\
mov r10, r0\n\
ldr r7, [sp, #0x20]\n\
@ -1267,7 +1241,7 @@ _08002674:\n\
sub r2, r7, r2\n\
str r2, [sp, #0x34]\n\
str r0, [sp, #0x38]\n\
ldr r7, =gGpuBgConfigs2+4\n\
ldr r7, =sGpuBgConfigs2+4\n\
mov r10, r7\n\
ldr r0, [sp, #0x4]\n\
lsl r0, #4\n\
@ -1337,7 +1311,7 @@ void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width,
{
for (x16 = x; x16 < (x + width); x16++)
{
((u16*)gGpuBgConfigs2[bg].tilemap)[((y16 * 0x20) + x16)] = tileNum;
((u16*)sGpuBgConfigs2[bg].tilemap)[((y16 * 0x20) + x16)] = tileNum;
}
}
break;
@ -1347,7 +1321,7 @@ void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width,
{
for (x16 = x; x16 < (x + width); x16++)
{
((u8*)gGpuBgConfigs2[bg].tilemap)[((y16 * mode) + x16)] = tileNum;
((u8*)sGpuBgConfigs2[bg].tilemap)[((y16 * mode) + x16)] = tileNum;
}
}
break;
@ -1382,7 +1356,7 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt
{
for (x16 = x; x16 < (x + width); x16++)
{
CopyTileMapEntry(&firstTileNum, &((u16*)gGpuBgConfigs2[bg].tilemap)[(u16)GetTileMapIndexFromCoords(x16, y16, attribute, mode, mode2)], paletteSlot, 0, 0);
CopyTileMapEntry(&firstTileNum, &((u16*)sGpuBgConfigs2[bg].tilemap)[(u16)GetTileMapIndexFromCoords(x16, y16, attribute, mode, mode2)], paletteSlot, 0, 0);
firstTileNum = (firstTileNum & 0xFC00) + ((firstTileNum + tileNumDelta) & 0x3FF);
}
}
@ -1393,7 +1367,7 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt
{
for (x16 = x; x16 < (x + width); x16++)
{
((u8*)gGpuBgConfigs2[bg].tilemap)[(y16 * mode3) + x16] = firstTileNum;
((u8*)sGpuBgConfigs2[bg].tilemap)[(y16 * mode3) + x16] = firstTileNum;
firstTileNum = (firstTileNum & 0xFC00) + ((firstTileNum + tileNumDelta) & 0x3FF);
}
}
@ -1625,9 +1599,9 @@ bool32 IsInvalidBg32(u8 bg)
bool32 IsTileMapOutsideWram(u8 bg)
{
if (gGpuBgConfigs2[bg].tilemap > (void*)IWRAM_END)
if (sGpuBgConfigs2[bg].tilemap > (void*)IWRAM_END)
return TRUE;
if (gGpuBgConfigs2[bg].tilemap == 0x0)
if (sGpuBgConfigs2[bg].tilemap == 0x0)
return TRUE;
return FALSE;
}

View File

@ -91,8 +91,8 @@ void ProcessDma3Requests(void)
DmaFill16(3, gDma3Requests[gDma3RequestCursor].value, gDma3Requests[gDma3RequestCursor].dest, gDma3Requests[gDma3RequestCursor].size);
break;
}
gDma3Requests[gDma3RequestCursor].src = 0;
gDma3Requests[gDma3RequestCursor].dest = 0;
gDma3Requests[gDma3RequestCursor].src = NULL;
gDma3Requests[gDma3RequestCursor].dest = NULL;
gDma3Requests[gDma3RequestCursor].size = 0;
gDma3Requests[gDma3RequestCursor].mode = 0;
gDma3Requests[gDma3RequestCursor].value = 0;
@ -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;

893
src/egg_hatch.c Normal file
View File

@ -0,0 +1,893 @@
#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 "abilities.h"
#include "battle.h" // to get rid of later
struct EggHatchData
{
u8 eggSpriteID;
u8 pokeSpriteID;
u8 CB2_state;
u8 CB2_PalCounter;
u8 eggPartyID;
u8 unused_5;
u8 unused_6;
u8 eggShardVelocityID;
u8 windowId;
u8 unused_9;
u8 unused_A;
u16 species;
struct TextColor textColor;
};
extern struct SpriteTemplate gUnknown_0202499C;
extern void (*gFieldCallback)(void);
extern const struct CompressedSpriteSheet gMonFrontPicTable[];
extern const u8 gUnknown_08C00000[];
extern const u8 gUnknown_08C00524[];
extern const u8 gUnknown_08C004E0[];
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 const u8 gText_HatchedFromEgg[];
extern const u8 gText_NickHatchPrompt[];
extern u8* GetMonNick(struct Pokemon* mon, u8* dst);
extern u8* GetBoxMonNick(struct BoxPokemon* boxMon, u8* dst);
extern u8 sav1_map_get_name(void);
extern s8 sub_8198C58(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 sub_805F094(void);
extern void remove_some_task(void);
extern void reset_temp_tile_data_buffers(void);
extern void c2_exit_to_overworld_2_switch(void);
extern void play_some_sound(void);
extern void copy_decompressed_tile_data_to_vram_autofree(u8 bg_id, const void* src, u16 size, u16 offset, u8 mode);
extern void CreateYesNoMenu(const struct WindowTemplate*, u16, u8, u8);
extern void DoNamingScreen(u8, const u8*, u16, u8, u32, MainCallback);
extern void AddTextPrinterParametrized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor* colors, s8 speed, u8 *str);
extern u16 sub_80D22D0(void);
extern u8 sub_80C7050(u8);
static void Task_EggHatch(u8 taskID);
static void CB2_EggHatch_0(void);
static void CB2_EggHatch_1(void);
static void SpriteCB_Egg_0(struct Sprite* sprite);
static void SpriteCB_Egg_1(struct Sprite* sprite);
static void SpriteCB_Egg_2(struct Sprite* sprite);
static void SpriteCB_Egg_3(struct Sprite* sprite);
static void SpriteCB_Egg_4(struct Sprite* sprite);
static void SpriteCB_Egg_5(struct Sprite* sprite);
static void SpriteCB_EggShard(struct Sprite* sprite);
static void EggHatchPrintMessage(u8 windowId, u8* string, u8 x, u8 y, u8 speed);
static void CreateRandomEggShardSprite(void);
static void CreateEggShardSprite(u8 x, u8 y, s16 data1, s16 data2, s16 data3, u8 spriteAnimIndex);
// IWRAM bss
static IWRAM_DATA struct EggHatchData* sEggHatchData;
// rom data
static const u16 sEggPalette[] = INCBIN_U16("graphics/pokemon/palettes/egg_palette.gbapal");
static const u8 sEggHatchTiles[] = INCBIN_U8("graphics/misc/egg_hatch.4bpp");
static const u8 sEggShardTiles[] = INCBIN_U8("graphics/misc/egg_shard.4bpp");
static const struct OamData sOamData_EggHatch =
{
.y = 0,
.affineMode = 0,
.objMode = 0,
.mosaic = 0,
.bpp = 0,
.shape = 0,
.x = 0,
.matrixNum = 0,
.size = 2,
.tileNum = 0,
.priority = 1,
.paletteNum = 0,
.affineParam = 0,
};
static const union AnimCmd sSpriteAnim_EggHatch0[] =
{
ANIMCMD_FRAME(0, 5),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_EggHatch1[] =
{
ANIMCMD_FRAME(16, 5),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_EggHatch2[] =
{
ANIMCMD_FRAME(32, 5),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_EggHatch3[] =
{
ANIMCMD_FRAME(48, 5),
ANIMCMD_END
};
static const union AnimCmd *const sSpriteAnimTable_EggHatch[] =
{
sSpriteAnim_EggHatch0,
sSpriteAnim_EggHatch1,
sSpriteAnim_EggHatch2,
sSpriteAnim_EggHatch3,
};
static const struct SpriteSheet sEggHatch_Sheet =
{
.data = sEggHatchTiles,
.size = 2048,
.tag = 12345,
};
static const struct SpriteSheet sEggShards_Sheet =
{
.data = sEggShardTiles,
.size = 128,
.tag = 23456,
};
static const struct SpritePalette sEgg_SpritePalette =
{
.data = sEggPalette,
.tag = 54321
};
static const struct SpriteTemplate sSpriteTemplate_EggHatch =
{
.tileTag = 12345,
.paletteTag = 54321,
.oam = &sOamData_EggHatch,
.anims = sSpriteAnimTable_EggHatch,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
static const struct OamData sOamData_EggShard =
{
.y = 0,
.affineMode = 0,
.objMode = 0,
.mosaic = 0,
.bpp = 0,
.shape = 0,
.x = 0,
.matrixNum = 0,
.size = 0,
.tileNum = 0,
.priority = 2,
.paletteNum = 0,
.affineParam = 0,
};
static const union AnimCmd sSpriteAnim_EggShard0[] =
{
ANIMCMD_FRAME(0, 5),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_EggShard1[] =
{
ANIMCMD_FRAME(1, 5),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_EggShard2[] =
{
ANIMCMD_FRAME(2, 5),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_EggShard3[] =
{
ANIMCMD_FRAME(3, 5),
ANIMCMD_END
};
static const union AnimCmd *const sSpriteAnimTable_EggShard[] =
{
sSpriteAnim_EggShard0,
sSpriteAnim_EggShard1,
sSpriteAnim_EggShard2,
sSpriteAnim_EggShard3,
};
static const struct SpriteTemplate sSpriteTemplate_EggShard =
{
.tileTag = 23456,
.paletteTag = 54321,
.oam = &sOamData_EggShard,
.anims = sSpriteAnimTable_EggShard,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_EggShard
};
static const struct BgTemplate sBgTemplates_EggHatch[2] =
{
{
.bg = 0,
.charBaseIndex = 2,
.mapBaseIndex = 24,
.screenSize = 3,
.paletteMode = 0,
.priority = 0,
.baseTile = 0
},
{
.bg = 1,
.charBaseIndex = 0,
.mapBaseIndex = 8,
.screenSize = 1,
.paletteMode = 0,
.priority = 2,
.baseTile = 0
},
};
static const struct WindowTemplate sWinTemplates_EggHatch[2] =
{
{0, 2, 0xF, 0x1A, 4, 0, 0x40},
DUMMY_WIN_TEMPLATE
};
static const struct WindowTemplate sYesNoWinTemplate =
{
0, 0x15, 9, 5, 4, 0xF, 0x1A8
};
static const s16 sEggShardVelocities[][2] =
{
{Q_8_8(-1.5), Q_8_8(-3.75)},
{Q_8_8(-5), Q_8_8(-3)},
{Q_8_8(3.5), Q_8_8(-3)},
{Q_8_8(-4), Q_8_8(-3.75)},
{Q_8_8(2), Q_8_8(-1.5)},
{Q_8_8(-0.5), Q_8_8(-6.75)},
{Q_8_8(5), Q_8_8(-2.25)},
{Q_8_8(-1.5), Q_8_8(-3.75)},
{Q_8_8(4.5), Q_8_8(-1.5)},
{Q_8_8(-1), Q_8_8(-6.75)},
{Q_8_8(4), Q_8_8(-2.25)},
{Q_8_8(-3.5), Q_8_8(-3.75)},
{Q_8_8(1), Q_8_8(-1.5)},
{Q_8_8(-3.515625), Q_8_8(-6.75)},
{Q_8_8(4.5), Q_8_8(-2.25)},
{Q_8_8(-0.5), Q_8_8(-7.5)},
{Q_8_8(1), Q_8_8(-4.5)},
{Q_8_8(-2.5), Q_8_8(-2.25)},
{Q_8_8(2.5), Q_8_8(-7.5)},
};
// code
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;
}
static 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);
}
static 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;
}
static void VBlankCB_EggHatch(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
static void EggHatch(void)
{
ScriptContext2_Enable();
CreateTask(Task_EggHatch, 10);
fade_screen(1, 0);
}
static void Task_EggHatch(u8 taskID)
{
if (!gPaletteFade.active)
{
overworld_free_bg_tilemaps();
SetMainCallback2(CB2_EggHatch_0);
gFieldCallback = sub_80AF168;
DestroyTask(taskID);
}
}
static void CB2_EggHatch_0(void)
{
switch (gMain.state)
{
case 0:
SetGpuReg(REG_OFFSET_DISPCNT, 0);
sEggHatchData = Alloc(sizeof(struct EggHatchData));
init_uns_table_pokemon_copy();
sEggHatchData->eggPartyID = gSpecialVar_0x8004;
sEggHatchData->eggShardVelocityID = 0;
SetVBlankCallback(VBlankCB_EggHatch);
gSpecialVar_0x8005 = GetCurrentMapMusic();
reset_temp_tile_data_buffers();
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sBgTemplates_EggHatch, ARRAY_COUNT(sBgTemplates_EggHatch));
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(sWinTemplates_EggHatch);
sEggHatchData->windowId = 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(&sEggHatch_Sheet);
LoadSpriteSheet(&sEggShards_Sheet);
LoadSpritePalette(&sEgg_SpritePalette);
gMain.state++;
break;
case 4:
CopyBgTilemapBufferToVram(0);
AddHatchedMonToParty(sEggHatchData->eggPartyID);
gMain.state++;
break;
case 5:
EggHatchCreateMonSprite(0, 0, sEggHatchData->eggPartyID, &sEggHatchData->species);
gMain.state++;
break;
case 6:
sEggHatchData->pokeSpriteID = EggHatchCreateMonSprite(0, 1, sEggHatchData->eggPartyID, &sEggHatchData->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);
sEggHatchData->CB2_state = 0;
break;
}
RunTasks();
RunTextPrinters();
AnimateSprites();
BuildOamBuffer();
UpdatePaletteFade();
}
static void EggHatchSetMonNickname(void)
{
SetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_NICKNAME, gStringVar3);
sub_805F094();
Free(sEggHatchData);
SetMainCallback2(c2_exit_to_overworld_2_switch);
}
static void Task_EggHatchPlayBGM(u8 taskID)
{
if (gTasks[taskID].data[0] == 0)
{
StopMapMusic();
play_some_sound();
}
if (gTasks[taskID].data[0] == 1)
PlayBGM(376);
if (gTasks[taskID].data[0] > 60)
{
PlayBGM(377);
DestroyTask(taskID);
// UB: task is destroyed, yet the value is incremented
}
gTasks[taskID].data[0]++;
}
static void CB2_EggHatch_1(void)
{
u16 species;
u8 gender;
u32 personality;
switch (sEggHatchData->CB2_state)
{
case 0:
BeginNormalPaletteFade(-1, 0, 0x10, 0, 0);
sEggHatchData->eggSpriteID = CreateSprite(&sSpriteTemplate_EggHatch, 120, 75, 5);
ShowBg(0);
ShowBg(1);
sEggHatchData->CB2_state++;
CreateTask(Task_EggHatchPlayBGM, 5);
break;
case 1:
if (!gPaletteFade.active)
{
FillWindowPixelBuffer(sEggHatchData->windowId, 0);
sEggHatchData->CB2_PalCounter = 0;
sEggHatchData->CB2_state++;
}
break;
case 2:
if (++sEggHatchData->CB2_PalCounter > 30)
{
sEggHatchData->CB2_state++;
gSprites[sEggHatchData->eggSpriteID].callback = SpriteCB_Egg_0;
}
break;
case 3:
if (gSprites[sEggHatchData->eggSpriteID].callback == SpriteCallbackDummy)
{
species = GetMonData(&gPlayerParty[sEggHatchData->eggPartyID], MON_DATA_SPECIES);
DoMonFrontSpriteAnimation(&gSprites[sEggHatchData->pokeSpriteID], species, FALSE, 1);
sEggHatchData->CB2_state++;
}
break;
case 4:
if (gSprites[sEggHatchData->pokeSpriteID].callback == SpriteCallbackDummy)
{
sEggHatchData->CB2_state++;
}
break;
case 5:
GetMonNick(&gPlayerParty[sEggHatchData->eggPartyID], gStringVar1);
StringExpandPlaceholders(gStringVar4, gText_HatchedFromEgg);
EggHatchPrintMessage(sEggHatchData->windowId, gStringVar4, 0, 3, 0xFF);
PlayFanfare(371);
sEggHatchData->CB2_state++;
PutWindowTilemap(sEggHatchData->windowId);
CopyWindowToVram(sEggHatchData->windowId, 3);
break;
case 6:
if (IsFanfareTaskInactive())
sEggHatchData->CB2_state++;
break;
case 7:
if (IsFanfareTaskInactive())
sEggHatchData->CB2_state++;
break;
case 8:
GetMonNick(&gPlayerParty[sEggHatchData->eggPartyID], gStringVar1);
StringExpandPlaceholders(gStringVar4, gText_NickHatchPrompt);
EggHatchPrintMessage(sEggHatchData->windowId, gStringVar4, 0, 2, 1);
sEggHatchData->CB2_state++;
break;
case 9:
if (!IsTextPrinterActive(sEggHatchData->windowId))
{
sub_809882C(sEggHatchData->windowId, 0x140, 0xE0);
CreateYesNoMenu(&sYesNoWinTemplate, 0x140, 0xE, 0);
sEggHatchData->CB2_state++;
}
break;
case 10:
switch (sub_8198C58())
{
case 0:
GetMonNick(&gPlayerParty[sEggHatchData->eggPartyID], gStringVar3);
species = GetMonData(&gPlayerParty[sEggHatchData->eggPartyID], MON_DATA_SPECIES);
gender = GetMonGender(&gPlayerParty[sEggHatchData->eggPartyID]);
personality = GetMonData(&gPlayerParty[sEggHatchData->eggPartyID], MON_DATA_PERSONALITY, 0);
DoNamingScreen(3, gStringVar3, species, gender, personality, EggHatchSetMonNickname);
break;
case 1:
case -1:
sEggHatchData->CB2_state++;
}
break;
case 11:
BeginNormalPaletteFade(-1, 0, 0, 0x10, 0);
sEggHatchData->CB2_state++;
break;
case 12:
if (!gPaletteFade.active)
{
sub_805F094();
RemoveWindow(sEggHatchData->windowId);
UnsetBgTilemapBuffer(0);
UnsetBgTilemapBuffer(1);
Free(sEggHatchData);
SetMainCallback2(c2_exit_to_overworld_2_switch);
}
break;
}
RunTasks();
RunTextPrinters();
AnimateSprites();
BuildOamBuffer();
UpdatePaletteFade();
}
static void SpriteCB_Egg_0(struct Sprite* sprite)
{
if (++sprite->data0 > 20)
{
sprite->callback = SpriteCB_Egg_1;
sprite->data0 = 0;
}
else
{
sprite->data1 = (sprite->data1 + 20) & 0xFF;
sprite->pos2.x = Sin(sprite->data1, 1);
if (sprite->data0 == 15)
{
PlaySE(SE_BOWA);
StartSpriteAnim(sprite, 1);
CreateRandomEggShardSprite();
}
}
}
static void SpriteCB_Egg_1(struct Sprite* sprite)
{
if (++sprite->data2 > 30)
{
if (++sprite->data0 > 20)
{
sprite->callback = SpriteCB_Egg_2;
sprite->data0 = 0;
sprite->data2 = 0;
}
else
{
sprite->data1 = (sprite->data1 + 20) & 0xFF;
sprite->pos2.x = Sin(sprite->data1, 2);
if (sprite->data0 == 15)
{
PlaySE(SE_BOWA);
StartSpriteAnim(sprite, 2);
}
}
}
}
static void SpriteCB_Egg_2(struct Sprite* sprite)
{
if (++sprite->data2 > 30)
{
if (++sprite->data0 > 38)
{
u16 species;
sprite->callback = SpriteCB_Egg_3;
sprite->data0 = 0;
species = GetMonData(&gPlayerParty[sEggHatchData->eggPartyID], MON_DATA_SPECIES);
gSprites[sEggHatchData->pokeSpriteID].pos2.x = 0;
gSprites[sEggHatchData->pokeSpriteID].pos2.y = 0;
}
else
{
sprite->data1 = (sprite->data1 + 20) & 0xFF;
sprite->pos2.x = Sin(sprite->data1, 2);
if (sprite->data0 == 15)
{
PlaySE(SE_BOWA);
StartSpriteAnim(sprite, 2);
CreateRandomEggShardSprite();
CreateRandomEggShardSprite();
}
if (sprite->data0 == 30)
PlaySE(SE_BOWA);
}
}
}
static void SpriteCB_Egg_3(struct Sprite* sprite)
{
if (++sprite->data0 > 50)
{
sprite->callback = SpriteCB_Egg_4;
sprite->data0 = 0;
}
}
static void SpriteCB_Egg_4(struct Sprite* sprite)
{
s16 i;
if (sprite->data0 == 0)
BeginNormalPaletteFade(-1, -1, 0, 0x10, 0xFFFF);
if (sprite->data0 < 4u)
{
for (i = 0; i <= 3; i++)
CreateRandomEggShardSprite();
}
sprite->data0++;
if (!gPaletteFade.active)
{
PlaySE(SE_TAMAGO);
sprite->invisible = 1;
sprite->callback = SpriteCB_Egg_5;
sprite->data0 = 0;
}
}
static void SpriteCB_Egg_5(struct Sprite* sprite)
{
if (sprite->data0 == 0)
{
gSprites[sEggHatchData->pokeSpriteID].invisible = 0;
StartSpriteAffineAnim(&gSprites[sEggHatchData->pokeSpriteID], 1);
}
if (sprite->data0 == 8)
BeginNormalPaletteFade(-1, -1, 0x10, 0, 0xFFFF);
if (sprite->data0 <= 9)
gSprites[sEggHatchData->pokeSpriteID].pos1.y -= 1;
if (sprite->data0 > 40)
sprite->callback = SpriteCallbackDummy;
sprite->data0++;
}
static void SpriteCB_EggShard(struct Sprite* sprite)
{
sprite->data4 += sprite->data1;
sprite->data5 += sprite->data2;
sprite->pos2.x = sprite->data4 / 256;
sprite->pos2.y = sprite->data5 / 256;
sprite->data2 += sprite->data3;
if (sprite->pos1.y + sprite->pos2.y > sprite->pos1.y + 20 && sprite->data2 > 0)
DestroySprite(sprite);
}
static void CreateRandomEggShardSprite(void)
{
u16 spriteAnimIndex;
s16 velocity1 = sEggShardVelocities[sEggHatchData->eggShardVelocityID][0];
s16 velocity2 = sEggShardVelocities[sEggHatchData->eggShardVelocityID][1];
sEggHatchData->eggShardVelocityID++;
spriteAnimIndex = Random() % 4;
CreateEggShardSprite(120, 60, velocity1, velocity2, 100, spriteAnimIndex);
}
static void CreateEggShardSprite(u8 x, u8 y, s16 data1, s16 data2, s16 data3, u8 spriteAnimIndex)
{
u8 spriteID = CreateSprite(&sSpriteTemplate_EggShard, x, y, 4);
gSprites[spriteID].data1 = data1;
gSprites[spriteID].data2 = data2;
gSprites[spriteID].data3 = data3;
StartSpriteAnim(&gSprites[spriteID], spriteAnimIndex);
}
static void EggHatchPrintMessage(u8 windowId, u8* string, u8 x, u8 y, u8 speed)
{
FillWindowPixelBuffer(windowId, 0xFF);
sEggHatchData->textColor.fgColor = 0;
sEggHatchData->textColor.bgColor = 5;
sEggHatchData->textColor.shadowColor = 6;
AddTextPrinterParametrized2(windowId, 1, x, y, 0, 0, &sEggHatchData->textColor, speed, string);
}
u8 GetEggStepsToSubtract(void)
{
u8 count, i;
for (count = CalculatePlayerPartyCount(), i = 0; i < count; i++)
{
if (!GetMonData(&gPlayerParty[i], MON_DATA_SANITY_BIT3))
{
u8 ability = GetMonAbility(&gPlayerParty[i]);
if (ability == ABILITY_MAGMA_ARMOR || ability == ABILITY_FLAME_BODY)
return 2;
}
}
return 1;
}
u16 sub_80722E0(void)
{
u16 value = sub_80D22D0();
value += sub_80C7050(6);
return value;
}

View File

@ -1,4 +1,5 @@
#include "global.h"
#include "gpu_regs.h"
#define GPU_REG_BUF_SIZE 0x60
@ -14,14 +15,15 @@ static bool8 sShouldSyncRegIE;
static u16 sRegIE;
static void CopyBufferedValueToGpuReg(u8 regOffset);
static void SyncRegIE();
static void SyncRegIE(void);
static void UpdateRegDispstatIntrBits(u16 regIE);
void InitGpuRegManager()
void InitGpuRegManager(void)
{
s32 i;
for (i = 0; i < GPU_REG_BUF_SIZE; i++) {
for (i = 0; i < GPU_REG_BUF_SIZE; i++)
{
sGpuRegBuffer[i] = 0;
sGpuRegWaitingList[i] = EMPTY_SLOT;
}
@ -33,20 +35,25 @@ void InitGpuRegManager()
static void CopyBufferedValueToGpuReg(u8 regOffset)
{
if (regOffset == REG_OFFSET_DISPSTAT) {
if (regOffset == REG_OFFSET_DISPSTAT)
{
REG_DISPSTAT &= ~(DISPSTAT_HBLANK_INTR | DISPSTAT_VBLANK_INTR);
REG_DISPSTAT |= GPU_REG_BUF(REG_OFFSET_DISPSTAT);
} else {
}
else
{
GPU_REG(regOffset) = GPU_REG_BUF(regOffset);
}
}
void CopyBufferedValuesToGpuRegs()
void CopyBufferedValuesToGpuRegs(void)
{
if (!sGpuRegBufferLocked) {
if (!sGpuRegBufferLocked)
{
s32 i;
for (i = 0; i < GPU_REG_BUF_SIZE; i++) {
for (i = 0; i < GPU_REG_BUF_SIZE; i++)
{
u8 regOffset = sGpuRegWaitingList[i];
if (regOffset == EMPTY_SLOT)
return;
@ -135,7 +142,7 @@ void ClearGpuRegBits(u8 regOffset, u16 mask)
SetGpuReg(regOffset, regValue & ~mask);
}
static void SyncRegIE()
static void SyncRegIE(void)
{
if (sShouldSyncRegIE) {
u16 temp = REG_IME;

View File

@ -1511,8 +1511,6 @@ static void Task_PokemonSummaryAnimateAfterDelay(u8 taskId)
}
}
void DoMonFrontSpriteAnimation(struct Sprite* sprite, u16 species, bool8 noCry, u8 arg3);
void BattleAnimateFrontSprite(struct Sprite* sprite, u16 species, bool8 noCry, u8 arg3)
{
if (gHitMarker & HITMARKER_NO_ANIMATIONS && !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)))

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

@ -244,12 +244,11 @@ void RunTextPrinters(void)
}
}
bool8 IsTextPrinterActive(u8 id)
bool16 IsTextPrinterActive(u8 id)
{
return gTextPrinters[id].sub_union.sub.active;
}
u32 RenderFont(struct TextPrinter *textPrinter)
{
u32 ret;

View File

@ -1,12 +1,6 @@
#include "global.h"
#include "trig.h"
// Converts a number to Q8.8 fixed-point format
#define Q_8_8(n) ((s16)((n) * 256))
// Converts a number to Q4.12 fixed-point format
#define Q_4_12(n) ((s16)((n) * 4096))
// Values of sin(x*(π/128)) as Q8.8 fixed-point numbers from x = 0 to x = 319
const s16 gSineTable[] =
{

View File

@ -113,8 +113,9 @@ gUnknown_03000DD8: @ 3000DD8
gUnknown_03000DDC: @ 3000DDC
.space 0x4
gUnknown_03000DE0: @ 3000DE0
.space 0x8
.include "src/egg_hatch.o"
.space 0x4 @ why the gap?
gUnknown_03000DE8: @ 3000DE8
.space 0x10

View File

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