diff --git a/asm/battle_setup.s b/asm/battle_setup.s index 608d7843c0..752e4adf14 100644 --- a/asm/battle_setup.s +++ b/asm/battle_setup.s @@ -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: diff --git a/asm/cable_car.s b/asm/cable_car.s index 9307c54ff1..ba228b729b 100644 --- a/asm/cable_car.s +++ b/asm/cable_car.s @@ -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 diff --git a/asm/contest.s b/asm/contest.s index 76effb4e79..a380164cba 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -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 diff --git a/asm/daycare.s b/asm/daycare.s index 711d63e423..282a7b22cd 100644 --- a/asm/daycare.s +++ b/asm/daycare.s @@ -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 diff --git a/asm/decoration.s b/asm/decoration.s index 4efc70e047..48a76a8f95 100644 --- a/asm/decoration.s +++ b/asm/decoration.s @@ -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 diff --git a/asm/egg_hatch.s b/asm/egg_hatch.s index d646dbb737..d97fc8c65a 100644 --- a/asm/egg_hatch.s +++ b/asm/egg_hatch.s @@ -5,728 +5,9 @@ .text - thumb_func_start sub_8071348 -sub_8071348: @ 8071348 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x50 - adds r5, r0, 0 - adds r6, r1, 0 - movs r1, 0xB - bl GetMonData - lsls r0, 16 - lsrs r0, 16 - str r0, [sp, 0x3C] - movs r4, 0 - add r7, sp, 0x18 - add r0, sp, 0x30 - mov r8, r0 - movs r1, 0x31 - add r1, sp - mov r10, r1 - mov r0, sp - adds r0, 0x32 - str r0, [sp, 0x40] - mov r1, sp - adds r1, 0x34 - str r1, [sp, 0x48] - adds r0, 0x1 - str r0, [sp, 0x44] - adds r1, 0x4 - str r1, [sp, 0x4C] -_08071386: - adds r1, r4, 0 - adds r1, 0xD - adds r0, r5, 0 - bl GetMonData - lsls r1, r4, 1 - add r1, sp - adds r1, 0x10 - strh r0, [r1] - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x3 - bls _08071386 - adds r0, r5, 0 - movs r1, 0 - bl GetMonData - mov r9, r0 - movs r4, 0 -_080713AE: - adds r1, r4, 0 - adds r1, 0x27 - adds r0, r5, 0 - bl GetMonData - lsls r1, r4, 2 - adds r1, r7, r1 - str r0, [r1] - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x5 - bls _080713AE - adds r0, r5, 0 - movs r1, 0x3 - bl GetMonData - mov r1, r8 - strb r0, [r1] - adds r0, r5, 0 - movs r1, 0x25 - bl GetMonData - mov r1, r10 - strb r0, [r1] - adds r0, r5, 0 - movs r1, 0x8 - bl GetMonData - ldr r1, [sp, 0x40] - strb r0, [r1] - adds r0, r5, 0 - movs r1, 0x22 - bl GetMonData - str r0, [sp, 0x38] - adds r0, r5, 0 - movs r1, 0x50 - bl GetMonData - ldr r1, [sp, 0x48] - strb r0, [r1] - movs r0, 0x1 - str r0, [sp] - mov r0, r9 - str r0, [sp, 0x4] - movs r0, 0 - str r0, [sp, 0x8] - str r0, [sp, 0xC] - adds r0, r6, 0 - ldr r1, [sp, 0x3C] - movs r2, 0x5 - movs r3, 0x20 - bl CreateMon - movs r4, 0 -_0807141E: - adds r1, r4, 0 - adds r1, 0xD - lsls r0, r4, 1 - mov r2, sp - adds r2, r0 - adds r2, 0x10 - adds r0, r6, 0 - bl SetMonData - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x3 - bls _0807141E - movs r4, 0 -_0807143C: - adds r1, r4, 0 - adds r1, 0x27 - lsls r2, r4, 2 - adds r2, r7, r2 - adds r0, r6, 0 - bl SetMonData - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x5 - bls _0807143C - movs r0, 0x2 - mov r1, r8 - strb r0, [r1] - adds r0, r6, 0 - movs r1, 0x3 - mov r2, r8 - bl SetMonData - adds r0, r6, 0 - movs r1, 0x25 - mov r2, r10 - bl SetMonData - adds r0, r6, 0 - movs r1, 0x8 - ldr r2, [sp, 0x40] - bl SetMonData - movs r0, 0x78 - ldr r1, [sp, 0x44] - strb r0, [r1] - adds r0, r6, 0 - movs r1, 0x20 - ldr r2, [sp, 0x44] - bl SetMonData - adds r0, r6, 0 - movs r1, 0x22 - ldr r2, [sp, 0x4C] - bl SetMonData - adds r0, r6, 0 - movs r1, 0x50 - ldr r2, [sp, 0x48] - bl SetMonData - adds r0, r5, 0 - adds r1, r6, 0 - movs r2, 0x64 - bl memcpy - add sp, 0x50 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8071348 - thumb_func_start sub_80714B8 -sub_80714B8: @ 80714B8 - push {r4,r5,lr} - sub sp, 0x14 - lsls r0, 24 - lsrs r0, 24 - add r4, sp, 0xC - movs r1, 0x46 - strb r1, [r4] - movs r1, 0x64 - adds r5, r0, 0 - muls r5, r1 - ldr r0, =gPlayerParty - adds r5, r0 - ldr r1, =gEnemyParty - adds r0, r5, 0 - bl sub_8071348 - adds r0, r5, 0 - movs r1, 0x2D - adds r2, r4, 0 - bl SetMonData - adds r0, r5, 0 - movs r1, 0xB - bl GetMonData - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - mov r0, sp - adds r1, r4, 0 - bl GetSpeciesName - adds r0, r5, 0 - movs r1, 0x2 - mov r2, sp - bl SetMonData - adds r0, r4, 0 - bl SpeciesToNationalPokedexNum - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - adds r0, r4, 0 - movs r1, 0x2 - bl GetSetPokedexFlag - adds r0, r4, 0 - movs r1, 0x3 - bl GetSetPokedexFlag - ldr r1, =gStringVar1 - adds r0, r5, 0 - bl pokemon_get_nick - mov r2, sp - adds r2, 0xE - movs r0, 0x4 - strh r0, [r2] - adds r0, r5, 0 - movs r1, 0x26 - bl SetMonData - add r2, sp, 0x10 - movs r0, 0 - strh r0, [r2] - adds r0, r5, 0 - movs r1, 0x24 - bl SetMonData - bl sav1_map_get_name - mov r2, sp - adds r2, 0x12 - strb r0, [r2] - adds r0, r5, 0 - movs r1, 0x23 - bl SetMonData - adds r0, r5, 0 - bl MonRestorePP - adds r0, r5, 0 - bl CalculateMonStats - add sp, 0x14 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80714B8 - - thumb_func_start sub_8071578 -sub_8071578: @ 8071578 - push {lr} - ldr r0, =gSpecialVar_0x8004 - ldrb r0, [r0] - bl sub_80714B8 - pop {r0} - bx r0 - .pool - thumb_func_end sub_8071578 - - thumb_func_start sub_807158C -sub_807158C: @ 807158C - push {r4-r6,lr} - sub sp, 0x20 - lsls r1, 24 - lsrs r1, 24 - movs r2, 0x8C - muls r1, r2 - adds r4, r0, r1 - adds r0, r4, 0 - mov r1, sp - bl pokemon_get_nick_ - adds r0, r4, 0 - adds r0, 0x70 - ldrh r0, [r0] - cmp r0, 0 - beq _08071608 - adds r6, r4, 0 - adds r6, 0x7C - mov r0, sp - adds r1, r6, 0 - bl StringCompareWithoutExtCtrlCodes - adds r5, r4, 0 - adds r5, 0x74 - cmp r0, 0 - bne _080715CE - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - adds r1, r5, 0 - bl StringCompareWithoutExtCtrlCodes - cmp r0, 0 - beq _08071608 -_080715CE: - ldr r0, =gStringVar1 - mov r1, sp - bl StringCopy - ldr r0, =gStringVar2 - adds r4, 0x87 - ldrb r2, [r4] - lsls r2, 28 - lsrs r2, 28 - adds r1, r5, 0 - bl sub_81DB5E8 - ldr r0, =gStringVar3 - ldrb r2, [r4] - lsrs r2, 4 - adds r1, r6, 0 - bl sub_81DB5E8 - movs r0, 0x1 - b _0807160A - .pool -_08071608: - movs r0, 0 -_0807160A: - add sp, 0x20 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_807158C - - thumb_func_start sub_8071614 -sub_8071614: @ 8071614 - push {lr} - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00003030 - adds r0, r1 - ldr r1, =gSpecialVar_0x8004 - ldrb r1, [r1] - bl sub_807158C - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - .pool - thumb_func_end sub_8071614 - - thumb_func_start sub_807163C -sub_807163C: @ 807163C - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - mov r9, r3 - lsls r0, 24 - lsrs r3, r0, 24 - mov r8, r3 - lsls r1, 24 - lsrs r6, r1, 24 - lsls r2, 24 - lsrs r1, r2, 24 - adds r2, r1, 0 - movs r4, 0 - movs r7, 0 - movs r5, 0 - cmp r3, 0 - bne _0807166A - movs r0, 0x64 - muls r1, r0 - ldr r0, =gPlayerParty - adds r5, r1, r0 - movs r4, 0x1 -_0807166A: - cmp r3, 0x1 - bne _0807167A - movs r0, 0x64 - adds r1, r2, 0 - muls r1, r0 - ldr r0, =gPlayerParty - adds r5, r1, r0 - movs r4, 0x3 -_0807167A: - cmp r6, 0 - beq _08071688 - cmp r6, 0x1 - beq _080716D8 - b _08071712 - .pool -_08071688: - adds r0, r5, 0 - movs r1, 0xB - bl GetMonData - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - adds r0, r5, 0 - movs r1, 0 - bl GetMonData - adds r3, r0, 0 - lsls r0, r4, 3 - ldr r1, =gMonFrontPicTable - adds r0, r1 - ldr r1, =gBattleSpritesGfx - ldr r2, [r1] - mov r6, r8 - lsls r1, r6, 1 - adds r1, 0x1 - lsls r1, 2 - adds r2, 0x4 - adds r2, r1 - ldr r1, [r2] - adds r2, r4, 0 - bl HandleLoadSpecialPokePic_DontHandleDeoxys - adds r0, r5, 0 - bl sub_806E794 - bl LoadCompressedObjectPalette - mov r0, r9 - strh r4, [r0] - b _08071712 - .pool -_080716D8: - adds r0, r5, 0 - bl sub_806E794 - ldrh r0, [r0, 0x4] - adds r1, r4, 0 - bl sub_806A068 - ldr r0, =gUnknown_0202499C - movs r1, 0x78 - movs r2, 0x4B - movs r3, 0x6 - bl CreateSprite - lsls r0, 24 - lsrs r7, r0, 24 - ldr r4, =gSprites - lsls r1, r7, 4 - adds r1, r7 - lsls r1, 2 - adds r2, r1, r4 - adds r2, 0x3E - ldrb r0, [r2] - movs r3, 0x4 - orrs r0, r3 - strb r0, [r2] - adds r4, 0x1C - adds r1, r4 - ldr r0, =SpriteCallbackDummy - str r0, [r1] -_08071712: - adds r0, r7, 0 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_807163C - - thumb_func_start sub_807172C -sub_807172C: @ 807172C - push {lr} - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - pop {r0} - bx r0 - thumb_func_end sub_807172C - - thumb_func_start sub_8071740 -sub_8071740: @ 8071740 - push {lr} - bl ScriptContext2_Enable - ldr r0, =sub_8071760 - movs r1, 0xA - bl CreateTask - movs r0, 0x1 - movs r1, 0 - bl fade_screen - pop {r0} - bx r0 - .pool - thumb_func_end sub_8071740 - - thumb_func_start sub_8071760 -sub_8071760: @ 8071760 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08071788 - bl overworld_free_bg_tilemaps - ldr r0, =c1_hatching_egg - bl SetMainCallback2 - ldr r1, =gUnknown_03005DAC - ldr r0, =sub_80AF168 - str r0, [r1] - adds r0, r4, 0 - bl DestroyTask -_08071788: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8071760 - - thumb_func_start c1_hatching_egg -c1_hatching_egg: @ 80717A0 - push {r4,lr} - sub sp, 0x4 - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x8 - bls _080717B4 - b _080719D6 -_080717B4: - lsls r0, 2 - ldr r1, =_080717C8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080717C8: - .4byte _080717EC - .4byte _080718B8 - .4byte _080718D0 - .4byte _08071904 - .4byte _08071924 - .4byte _0807193C - .4byte _08071954 - .4byte _08071970 - .4byte _080719C8 -_080717EC: - movs r0, 0 - movs r1, 0 - bl SetGpuReg - ldr r4, =gUnknown_03000DE0 - movs r0, 0x14 - bl Alloc - str r0, [r4] - bl init_uns_table_pokemon_copy - ldr r2, [r4] - ldr r0, =gSpecialVar_0x8004 - ldrh r0, [r0] - movs r1, 0 - strb r0, [r2, 0x4] - ldr r0, [r4] - strb r1, [r0, 0x7] - ldr r0, =sub_807172C - bl SetVBlankCallback - bl GetCurrentMapMusic - ldr r1, =gSpecialVar_0x8005 - strh r0, [r1] - bl reset_temp_tile_data_buffers - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_0832C064 - movs r0, 0 - movs r2, 0x2 - bl InitBgsFromTemplates - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x1 - movs r1, 0x7 - movs r2, 0x2 - bl SetBgAttribute - movs r0, 0x80 - lsls r0, 5 - bl Alloc - adds r1, r0, 0 - movs r0, 0x1 - bl SetBgTilemapBuffer - movs r0, 0x80 - lsls r0, 6 - bl Alloc - adds r1, r0, 0 - movs r0, 0 - bl SetBgTilemapBuffer - bl DeactivateAllTextPrinters - bl ResetPaletteFade - bl FreeAllSpritePalettes - bl ResetSpriteData - bl ResetTasks - bl remove_some_task - bl m4aSoundVSyncOn - b _080719A6 - .pool -_080718B8: - ldr r0, =gUnknown_0832C06C - bl InitWindows - ldr r0, =gUnknown_03000DE0 - ldr r1, [r0] - movs r0, 0 - strb r0, [r1, 0x8] - b _080719A6 - .pool -_080718D0: - ldr r1, =gUnknown_08C00000 - movs r0, 0 - str r0, [sp] - movs r2, 0 - movs r3, 0 - bl copy_decompressed_tile_data_to_vram_autofree - ldr r1, =gUnknown_08C00524 - movs r0, 0 - movs r2, 0 - movs r3, 0 - bl CopyToBgTilemapBuffer - ldr r0, =gUnknown_08C004E0 - movs r1, 0 - movs r2, 0x20 - bl LoadCompressedPalette - b _080719A6 - .pool -_08071904: - ldr r0, =gUnknown_0832BFE4 - bl LoadSpriteSheet - ldr r0, =gUnknown_0832BFEC - bl LoadSpriteSheet - ldr r0, =gUnknown_0832BFF4 - bl LoadSpritePalette - b _080719A6 - .pool -_08071924: - movs r0, 0 - bl CopyBgTilemapBufferToVram - ldr r0, =gUnknown_03000DE0 - ldr r0, [r0] - ldrb r0, [r0, 0x4] - bl sub_80714B8 - b _080719A6 - .pool -_0807193C: - ldr r0, =gUnknown_03000DE0 - ldr r3, [r0] - ldrb r2, [r3, 0x4] - adds r3, 0xC - movs r0, 0 - movs r1, 0 - bl sub_807163C - b _080719A6 - .pool -_08071954: - ldr r4, =gUnknown_03000DE0 - ldr r3, [r4] - ldrb r2, [r3, 0x4] - adds r3, 0xC - movs r0, 0 - movs r1, 0x1 - bl sub_807163C - ldr r1, [r4] - strb r0, [r1, 0x1] - b _080719A6 - .pool -_08071970: - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - ldr r0, =gUnknown_08DD7300 - movs r1, 0x10 - movs r2, 0xA0 - bl LoadPalette - ldr r1, =gUnknown_08DD7360 - movs r2, 0xA1 - lsls r2, 5 - movs r0, 0x1 - movs r3, 0 - bl LoadBgTiles - ldr r1, =gUnknown_08331F60 - movs r2, 0x80 - lsls r2, 5 - movs r0, 0x1 - movs r3, 0 - bl CopyToBgTilemapBuffer - movs r0, 0x1 - bl CopyBgTilemapBufferToVram -_080719A6: - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _080719D6 - .pool -_080719C8: - ldr r0, =sub_8071A94 - bl SetMainCallback2 - ldr r0, =gUnknown_03000DE0 - ldr r1, [r0] - movs r0, 0 - strb r0, [r1, 0x2] -_080719D6: - bl RunTasks - bl RunTextPrinters - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end c1_hatching_egg - - thumb_func_start sub_80719FC -sub_80719FC: @ 80719FC + thumb_func_start EggHatchSetMonNickname +EggHatchSetMonNickname: @ 80719FC push {lr} ldr r0, =gSpecialVar_0x8004 ldrh r1, [r0] @@ -738,7 +19,7 @@ sub_80719FC: @ 80719FC movs r1, 0x2 bl SetMonData bl sub_805F094 - ldr r0, =gUnknown_03000DE0 + ldr r0, =gEggHatchData ldr r0, [r0] bl Free ldr r0, =c2_exit_to_overworld_2_switch @@ -746,10 +27,10 @@ sub_80719FC: @ 80719FC pop {r0} bx r0 .pool - thumb_func_end sub_80719FC + thumb_func_end EggHatchSetMonNickname - thumb_func_start c3_080472E4 -c3_080472E4: @ 8071A3C + thumb_func_start Task_EggHatchPlayBGM +Task_EggHatchPlayBGM: @ 8071A3C push {r4,r5,lr} lsls r0, 24 lsrs r5, r0, 24 @@ -789,16 +70,16 @@ _08071A80: pop {r0} bx r0 .pool - thumb_func_end c3_080472E4 + thumb_func_end Task_EggHatchPlayBGM - thumb_func_start sub_8071A94 -sub_8071A94: @ 8071A94 + thumb_func_start CB2_EggHatch_1 +CB2_EggHatch_1: @ 8071A94 push {r4-r7,lr} mov r7, r9 mov r6, r8 push {r6,r7} sub sp, 0x8 - ldr r1, =gUnknown_03000DE0 + ldr r1, =gEggHatchData ldr r0, [r1] ldrb r0, [r0, 0x2] adds r5, r1, 0 @@ -840,7 +121,7 @@ _08071AF4: movs r2, 0x4B movs r3, 0x5 bl CreateSprite - ldr r4, =gUnknown_03000DE0 + ldr r4, =gEggHatchData ldr r1, [r4] strb r0, [r1] movs r0, 0 @@ -851,7 +132,7 @@ _08071AF4: ldrb r0, [r1, 0x2] adds r0, 0x1 strb r0, [r1, 0x2] - ldr r0, =c3_080472E4 + ldr r0, =Task_EggHatchPlayBGM movs r1, 0x5 bl CreateTask b _08071E06 @@ -899,7 +180,7 @@ _08071B7A: lsls r0, 2 adds r2, 0x1C adds r0, r2 - ldr r1, =sub_8071E34 + ldr r1, =SpriteCB_Egg_0 str r1, [r0] b _08071E06 .pool @@ -969,7 +250,7 @@ _08071C24: ldr r1, =gPlayerParty adds r0, r1 ldr r1, =gStringVar1 - bl pokemon_get_nick + bl GetMonNick ldr r4, =gStringVar4 ldr r1, =gUnknown_085ED5A5 adds r0, r4, 0 @@ -1021,7 +302,7 @@ _08071CA4: ldr r1, =gPlayerParty adds r0, r1 ldr r1, =gStringVar1 - bl pokemon_get_nick + bl GetMonNick ldr r4, =gStringVar4 ldr r1, =gUnknown_085ED5BE adds r0, r4, 0 @@ -1079,7 +360,7 @@ _08071D36: beq _08071DC4 b _08071E06 _08071D3C: - ldr r0, =gUnknown_03000DE0 + ldr r0, =gEggHatchData mov r8, r0 ldr r0, [r0] ldrb r0, [r0, 0x4] @@ -1089,7 +370,7 @@ _08071D3C: adds r0, r5 ldr r1, =gStringVar3 mov r9, r1 - bl pokemon_get_nick + bl GetMonNick mov r1, r8 ldr r0, [r1] ldrb r0, [r0, 0x4] @@ -1117,7 +398,7 @@ _08071D3C: movs r2, 0 bl GetMonData str r0, [sp] - ldr r0, =sub_80719FC + ldr r0, =EggHatchSetMonNickname str r0, [sp, 0x4] movs r0, 0x3 mov r1, r9 @@ -1135,7 +416,7 @@ _08071DB4: movs r3, 0x10 bl BeginNormalPaletteFade _08071DC4: - ldr r0, =gUnknown_03000DE0 + ldr r0, =gEggHatchData ldr r1, [r0] _08071DC8: ldrb r0, [r1, 0x2] @@ -1151,7 +432,7 @@ _08071DD4: cmp r0, 0 bne _08071E06 bl sub_805F094 - ldr r4, =gUnknown_03000DE0 + ldr r4, =gEggHatchData ldr r0, [r4] ldrb r0, [r0, 0x8] bl RemoveWindow @@ -1177,10 +458,10 @@ _08071E06: pop {r0} bx r0 .pool - thumb_func_end sub_8071A94 + thumb_func_end CB2_EggHatch_1 - thumb_func_start sub_8071E34 -sub_8071E34: @ 8071E34 + thumb_func_start SpriteCB_Egg_0 +SpriteCB_Egg_0: @ 8071E34 push {r4,lr} adds r4, r0, 0 ldrh r0, [r4, 0x2E] @@ -1190,7 +471,7 @@ sub_8071E34: @ 8071E34 asrs r0, 16 cmp r0, 0x14 ble _08071E54 - ldr r0, =sub_8071E8C + ldr r0, =SpriteCB_Egg_1 str r0, [r4, 0x1C] movs r0, 0 strh r0, [r4, 0x2E] @@ -1216,15 +497,15 @@ _08071E54: adds r0, r4, 0 movs r1, 0x1 bl StartSpriteAnim - bl sub_8072140 + bl CreateRandomEggShardSprite _08071E84: pop {r4} pop {r0} bx r0 - thumb_func_end sub_8071E34 + thumb_func_end SpriteCB_Egg_0 - thumb_func_start sub_8071E8C -sub_8071E8C: @ 8071E8C + thumb_func_start SpriteCB_Egg_1 +SpriteCB_Egg_1: @ 8071E8C push {r4,lr} adds r4, r0, 0 ldrh r0, [r4, 0x32] @@ -1242,7 +523,7 @@ sub_8071E8C: @ 8071E8C asrs r0, 16 cmp r0, 0x14 ble _08071EBC - ldr r0, =sub_8071EF0 + ldr r0, =SpriteCB_Egg_2 str r0, [r4, 0x1C] strh r1, [r4, 0x2E] strh r1, [r4, 0x32] @@ -1272,10 +553,10 @@ _08071EE8: pop {r4} pop {r0} bx r0 - thumb_func_end sub_8071E8C + thumb_func_end SpriteCB_Egg_1 - thumb_func_start sub_8071EF0 -sub_8071EF0: @ 8071EF0 + thumb_func_start SpriteCB_Egg_2 +SpriteCB_Egg_2: @ 8071EF0 push {r4,r5,lr} adds r4, r0, 0 ldrh r0, [r4, 0x32] @@ -1293,10 +574,10 @@ sub_8071EF0: @ 8071EF0 asrs r0, 16 cmp r0, 0x26 ble _08071F5C - ldr r0, =sub_8071FA4 + ldr r0, =SpriteCB_Egg_3 str r0, [r4, 0x1C] strh r5, [r4, 0x2E] - ldr r4, =gUnknown_03000DE0 + ldr r4, =gEggHatchData ldr r0, [r4] ldrb r1, [r0, 0x4] movs r0, 0x64 @@ -1341,8 +622,8 @@ _08071F5C: adds r0, r4, 0 movs r1, 0x2 bl StartSpriteAnim - bl sub_8072140 - bl sub_8072140 + bl CreateRandomEggShardSprite + bl CreateRandomEggShardSprite _08071F90: movs r1, 0x2E ldrsh r0, [r4, r1] @@ -1354,10 +635,10 @@ _08071F9E: pop {r4,r5} pop {r0} bx r0 - thumb_func_end sub_8071EF0 + thumb_func_end SpriteCB_Egg_2 - thumb_func_start sub_8071FA4 -sub_8071FA4: @ 8071FA4 + thumb_func_start SpriteCB_Egg_3 +SpriteCB_Egg_3: @ 8071FA4 push {lr} adds r1, r0, 0 ldrh r0, [r1, 0x2E] @@ -1367,7 +648,7 @@ sub_8071FA4: @ 8071FA4 asrs r0, 16 cmp r0, 0x32 ble _08071FBE - ldr r0, =sub_8071FC8 + ldr r0, =SpriteCB_Egg_4 str r0, [r1, 0x1C] movs r0, 0 strh r0, [r1, 0x2E] @@ -1375,10 +656,10 @@ _08071FBE: pop {r0} bx r0 .pool - thumb_func_end sub_8071FA4 + thumb_func_end SpriteCB_Egg_3 - thumb_func_start sub_8071FC8 -sub_8071FC8: @ 8071FC8 + thumb_func_start SpriteCB_Egg_4 +SpriteCB_Egg_4: @ 8071FC8 push {r4,r5,lr} sub sp, 0x4 adds r5, r0, 0 @@ -1400,7 +681,7 @@ _08071FE8: bhi _08072004 movs r4, 0 _08071FF0: - bl sub_8072140 + bl CreateRandomEggShardSprite lsls r0, r4, 16 movs r1, 0x80 lsls r1, 9 @@ -1429,7 +710,7 @@ _08072004: movs r1, 0x4 orrs r0, r1 strb r0, [r2] - ldr r0, =sub_8072048 + ldr r0, =SpriteCB_Egg_5 str r0, [r5, 0x1C] strh r4, [r5, 0x2E] _08072032: @@ -1438,10 +719,10 @@ _08072032: pop {r0} bx r0 .pool - thumb_func_end sub_8071FC8 + thumb_func_end SpriteCB_Egg_4 - thumb_func_start sub_8072048 -sub_8072048: @ 8072048 + thumb_func_start SpriteCB_Egg_5 +SpriteCB_Egg_5: @ 8072048 push {r4,r5,lr} sub sp, 0x4 adds r5, r0, 0 @@ -1450,7 +731,7 @@ sub_8072048: @ 8072048 cmp r0, 0 bne _08072084 ldr r4, =gSprites - ldr r3, =gUnknown_03000DE0 + ldr r3, =gEggHatchData ldr r0, [r3] ldrb r1, [r0, 0x1] lsls r0, r1, 4 @@ -1490,7 +771,7 @@ _0807209E: cmp r0, 0x9 bgt _080720BC ldr r2, =gSprites - ldr r0, =gUnknown_03000DE0 + ldr r0, =gEggHatchData ldr r0, [r0] ldrb r1, [r0, 0x1] lsls r0, r1, 4 @@ -1516,10 +797,10 @@ _080720CA: pop {r0} bx r0 .pool - thumb_func_end sub_8072048 + thumb_func_end SpriteCB_Egg_5 - thumb_func_start sub_80720E8 -sub_80720E8: @ 80720E8 + thumb_func_start SpriteCB_EggShard +SpriteCB_EggShard: @ 80720E8 push {r4,lr} adds r2, r0, 0 ldrh r0, [r2, 0x30] @@ -1566,14 +847,14 @@ _0807213A: pop {r4} pop {r0} bx r0 - thumb_func_end sub_80720E8 + thumb_func_end SpriteCB_EggShard - thumb_func_start sub_8072140 -sub_8072140: @ 8072140 + thumb_func_start CreateRandomEggShardSprite +CreateRandomEggShardSprite: @ 8072140 push {r4-r6,lr} sub sp, 0x8 ldr r2, =gUnknown_0832C084 - ldr r0, =gUnknown_03000DE0 + ldr r0, =gEggHatchData ldr r6, [r0] ldrb r3, [r6, 0x7] lsls r0, r3, 2 @@ -1601,16 +882,16 @@ sub_8072140: @ 8072140 movs r1, 0x3C adds r2, r5, 0 adds r3, r4, 0 - bl sub_8072194 + bl CreateEggShardSprite add sp, 0x8 pop {r4-r6} pop {r0} bx r0 .pool - thumb_func_end sub_8072140 + thumb_func_end CreateRandomEggShardSprite - thumb_func_start sub_8072194 -sub_8072194: @ 8072194 + thumb_func_start CreateEggShardSprite +CreateEggShardSprite: @ 8072194 push {r4-r6,lr} mov r6, r10 mov r5, r9 @@ -1670,7 +951,7 @@ sub_8072194: @ 8072194 pop {r0} bx r0 .pool - thumb_func_end sub_8072194 + thumb_func_end CreateEggShardSprite thumb_func_start sub_8072214 sub_8072214: @ 8072214 @@ -1697,7 +978,7 @@ sub_8072214: @ 8072214 adds r0, r5, 0 movs r1, 0xFF bl FillWindowPixelBuffer - ldr r3, =gUnknown_03000DE0 + ldr r3, =gEggHatchData ldr r0, [r3] movs r2, 0 strb r2, [r0, 0xE] diff --git a/asm/field_effect.s b/asm/field_effect.s index c400989938..3e218e7db4 100644 --- a/asm/field_effect.s +++ b/asm/field_effect.s @@ -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 diff --git a/asm/field_screen.s b/asm/field_screen.s index e304086542..13f418f172 100644 --- a/asm/field_screen.s +++ b/asm/field_screen.s @@ -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 diff --git a/asm/item_menu.s b/asm/item_menu.s index 914fdf2b31..f3eefb7b96 100755 --- a/asm/item_menu.s +++ b/asm/item_menu.s @@ -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 diff --git a/asm/item_use.s b/asm/item_use.s index a2488b6df0..f3086ae5f7 100644 --- a/asm/item_use.s +++ b/asm/item_use.s @@ -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 diff --git a/asm/learn_move.s b/asm/learn_move.s index c2ef763509..2fd4a3a337 100755 --- a/asm/learn_move.s +++ b/asm/learn_move.s @@ -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 diff --git a/asm/link.s b/asm/link.s index 9ee94412d1..42d24b53d4 100644 --- a/asm/link.s +++ b/asm/link.s @@ -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 diff --git a/asm/party_menu.s b/asm/party_menu.s index cf00d63c18..5d57831169 100755 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -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 diff --git a/asm/player_pc.s b/asm/player_pc.s index 7f4ab354cc..8cf0ee3325 100644 --- a/asm/player_pc.s +++ b/asm/player_pc.s @@ -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 diff --git a/asm/pokemon_storage_system.s b/asm/pokemon_storage_system.s index df90540e8d..3aca5c92df 100755 --- a/asm/pokemon_storage_system.s +++ b/asm/pokemon_storage_system.s @@ -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 diff --git a/asm/rom4.s b/asm/rom4.s index 9e4e9f108e..4ec39325ee 100644 --- a/asm/rom4.s +++ b/asm/rom4.s @@ -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 diff --git a/asm/rom6.s b/asm/rom6.s index c5e0265a01..1b1be36c72 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -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} diff --git a/asm/roulette.s b/asm/roulette.s index 5742e089f7..009f30717f 100644 --- a/asm/roulette.s +++ b/asm/roulette.s @@ -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 diff --git a/asm/secret_base.s b/asm/secret_base.s index 2188e634df..2e87a74197 100644 --- a/asm/secret_base.s +++ b/asm/secret_base.s @@ -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 diff --git a/asm/shop.s b/asm/shop.s index 9e03399fc4..c79250a436 100644 --- a/asm/shop.s +++ b/asm/shop.s @@ -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 diff --git a/asm/trade.s b/asm/trade.s index 3f93239715..bfe1695f9c 100644 --- a/asm/trade.s +++ b/asm/trade.s @@ -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 diff --git a/asm/walda_phrase.s b/asm/walda_phrase.s index 2f1f7da60b..dd5f300497 100755 --- a/asm/walda_phrase.s +++ b/asm/walda_phrase.s @@ -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 diff --git a/include/bg.h b/include/bg.h new file mode 100644 index 0000000000..ca21070e04 --- /dev/null +++ b/include/bg.h @@ -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 diff --git a/include/dma3.h b/include/dma3.h index beb00745df..ea31716623 100644 --- a/include/dma3.h +++ b/include/dma3.h @@ -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 diff --git a/include/global.h b/include/global.h index e694a59743..f4b2a83492 100644 --- a/include/global.h +++ b/include/global.h @@ -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; }; diff --git a/include/gpu_regs.h b/include/gpu_regs.h new file mode 100644 index 0000000000..684578f43c --- /dev/null +++ b/include/gpu_regs.h @@ -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 diff --git a/include/m4a.h b/include/m4a.h index b6c8f90727..8c3380dd81 100644 --- a/include/m4a.h +++ b/include/m4a.h @@ -4,6 +4,7 @@ #include "gba/m4a_internal.h" void m4aSoundVSync(void); +void m4aSoundVSyncOn(void); void m4aSoundInit(void); void m4aSoundMain(void); diff --git a/include/text.h b/include/text.h index 73e6e54372..5aadaac329 100644 --- a/include/text.h +++ b/include/text.h @@ -155,7 +155,7 @@ 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); diff --git a/include/window.h b/include/window.h index 36a71a1e04..20e5fefa38 100644 --- a/include/window.h +++ b/include/window.h @@ -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); diff --git a/ld_script.txt b/ld_script.txt index d6b3953fed..9b03844271 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -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); diff --git a/src/bg.c b/src/bg.c index 8979eaecd9..9f6d120623 100644 --- a/src/bg.c +++ b/src/bg.c @@ -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; @@ -22,33 +12,23 @@ struct BgControl { u16 priority:2; u16 mosaic:1; u16 wraparound:1; - + u16 charBaseIndex:2; u16 mapBaseIndex:5; u16 paletteMode:1; - + u8 unknown_2; u8 unknown_3; } configs[4]; - - 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; + u16 bgVisibilityAndMode; }; struct BgConfig2 { u32 baseTile:10; u32 basePalette:4; u32 unk_3:18; - + void* tilemap; u32 bg_x; u32 bg_y; @@ -103,7 +83,7 @@ void ResetBgControlStructs(void) struct BgConfig* bgConfigs = &gGpuBgConfigs.configs[0]; struct BgConfig zeroedConfig = gZeroedBgControlStruct; int i; - + for (i = 0; i < 4; i++) { bgConfigs[i] = zeroedConfig; @@ -126,40 +106,40 @@ void SetBgControlAttributes(u8 bg, u8 charBaseIndex, u8 mapBaseIndex, u8 screenS { gGpuBgConfigs.configs[bg].charBaseIndex = charBaseIndex & 0x3; } - + if (mapBaseIndex != 0xFF) { gGpuBgConfigs.configs[bg].mapBaseIndex = mapBaseIndex & 0x1F; } - + if (screenSize != 0xFF) { gGpuBgConfigs.configs[bg].screenSize = screenSize & 0x3; } - + if (paletteMode != 0xFF) { gGpuBgConfigs.configs[bg].paletteMode = paletteMode; } - + if (priority != 0xFF) { gGpuBgConfigs.configs[bg].priority = priority & 0x3; } - + if (mosaic != 0xFF) { gGpuBgConfigs.configs[bg].mosaic = mosaic & 0x1; } - + if (wraparound != 0xFF) { gGpuBgConfigs.configs[bg].wraparound = wraparound; } - + gGpuBgConfigs.configs[bg].unknown_2 = 0; gGpuBgConfigs.configs[bg].unknown_3 = 0; - + gGpuBgConfigs.configs[bg].visible = 1; } } @@ -188,15 +168,15 @@ u16 GetBgControlAttribute(u8 bg, u8 attributeId) return gGpuBgConfigs.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) { switch (mode) @@ -211,11 +191,11 @@ u8 LoadBgVram(u8 bg, void *src, u16 size, u16 destOffset, u8 mode) cursor = -1; goto end; } - + offset = destOffset + offset; - + cursor = RequestDma3Copy(src, (void*)(offset + BG_VRAM), size, 0); - + if (cursor == -1) { return -1; @@ -225,7 +205,7 @@ u8 LoadBgVram(u8 bg, void *src, u16 size, u16 destOffset, u8 mode) { return -1; } - + end: return cursor; } @@ -242,9 +222,9 @@ void ShowBgInternal(u8 bg) (gGpuBgConfigs.configs[bg].mapBaseIndex << 8) | (gGpuBgConfigs.configs[bg].wraparound << 13) | (gGpuBgConfigs.configs[bg].screenSize << 14); - + SetGpuReg((bg << 1) + 0x8, value); - + gGpuBgConfigs.bgVisibilityAndMode |= 1 << (bg + 8); gGpuBgConfigs.bgVisibilityAndMode &= DISPCNT_ALL_BG_AND_MODE_BITS; } @@ -273,7 +253,7 @@ void SetBgAffineInternal(u8 bg, u32 srcCenterX, u32 srcCenterY, s16 dispCenterX, { struct BgAffineSrcData src; struct BgAffineDstData dest; - + switch (gGpuBgConfigs.bgVisibilityAndMode & 0x7) { case 1: @@ -288,7 +268,7 @@ void SetBgAffineInternal(u8 bg, u32 srcCenterX, u32 srcCenterY, s16 dispCenterX, default: return; } - + src.texX = srcCenterX; src.texY = srcCenterY; src.scrX = dispCenterX; @@ -296,7 +276,7 @@ void SetBgAffineInternal(u8 bg, u32 srcCenterX, u32 srcCenterY, s16 dispCenterX, src.sx = scaleX; src.sy = scaleY; src.alpha = rotationAngle; - + BgAffineSet(&src, &dest, 1); SetGpuReg(REG_OFFSET_BG2PA, dest.pa); @@ -326,20 +306,20 @@ void ResetBgsAndClearDma3BusyFlags(u32 leftoverFireRedLeafGreenVariable) { int i; ResetBgs(); - + for (i = 0; i < 4; i++) { gDmaBusyBitfield[i] = 0; } - + 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; - + SetBgModeInternal(bgMode); ResetBgControlStructs(); @@ -355,11 +335,11 @@ void InitBgsFromTemplates(u8 bgMode, struct BgTemplate *templates, u8 numTemplat templates[i].priority, 0, 0); - + gGpuBgConfigs2[bg].baseTile = templates[i].baseTile; gGpuBgConfigs2[bg].basePalette = 0; gGpuBgConfigs2[bg].unk_3 = 0; - + gGpuBgConfigs2[bg].tilemap = NULL; gGpuBgConfigs2[bg].bg_x = 0; gGpuBgConfigs2[bg].bg_y = 0; @@ -370,7 +350,7 @@ void InitBgsFromTemplates(u8 bgMode, struct BgTemplate *templates, u8 numTemplat void InitBgFromTemplate(struct BgTemplate *template) { u8 bg = template->bg; - + if (bg < 4) { SetBgControlAttributes(bg, @@ -381,11 +361,11 @@ void InitBgFromTemplate(struct BgTemplate *template) template->priority, 0, 0); - + gGpuBgConfigs2[bg].baseTile = template->baseTile; gGpuBgConfigs2[bg].basePalette = 0; gGpuBgConfigs2[bg].unk_3 = 0; - + gGpuBgConfigs2[bg].tilemap = NULL; gGpuBgConfigs2[bg].bg_x = 0; gGpuBgConfigs2[bg].bg_y = 0; @@ -397,11 +377,11 @@ 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; @@ -410,37 +390,37 @@ u16 LoadBgTiles(u8 bg, void* src, u16 size, u16 destOffset) { tileOffset = (gGpuBgConfigs2[bg].baseTile + destOffset) * 0x40; } - + cursor = LoadBgVram(bg, src, size, tileOffset, DISPCNT_MODE_1); - + if (cursor == 0xFF) { return -1; } - + gDmaBusyBitfield[cursor / 0x20] |= (1 << (cursor % 0x20)); - + if (gUnneededFireRedVariable == 1) { DummiedOutFireRedLeafGreenTileAllocFunc(bg, tileOffset / 0x20, size / 0x20, 1); } - + return cursor; } u16 LoadBgTilemap(u8 bg, void *src, u16 size, u16 destOffset) { u8 cursor; - + cursor = LoadBgVram(bg, src, size, destOffset * 2, DISPCNT_MODE_2); - + if (cursor == 0xFF) { return -1; } - + gDmaBusyBitfield[cursor / 0x20] |= (1 << (cursor % 0x20)); - + return cursor; } @@ -448,12 +428,12 @@ u16 Unused_LoadBgPalette(u8 bg, void *src, u16 size, u16 destOffset) { u16 paletteOffset; s8 cursor; - + if (IsInvalidBg32(bg) == FALSE) { paletteOffset = (gGpuBgConfigs2[bg].basePalette * 0x20) + (destOffset * 2); cursor = RequestDma3Copy(src, (void*)(paletteOffset + BG_PLTT), size, 0); - + if (cursor == -1) { return -1; @@ -475,14 +455,14 @@ bool8 IsDma3ManagerBusyWithBgCopy(void) u8 mod; u8 div; s8 reqSpace; - + int i; - + for (i = 0; i < 0x80; i++) { div = i / 0x20; mod = i % 0x20; - + if ((gDmaBusyBitfield[div] & (1 << mod)) != FALSE) { reqSpace = CheckForSpaceForDma3Request(i); @@ -490,7 +470,7 @@ bool8 IsDma3ManagerBusyWithBgCopy(void) { return TRUE; } - + gDmaBusyBitfield[div] &= ~(1 << mod); } } @@ -634,12 +614,12 @@ u32 ChangeBgX(u8 bg, u32 value, u8 op) u8 mode; u16 temp1; u16 temp2; - + if (IsInvalidBg32(bg) != FALSE || GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0) { return -1; } - + switch (op) { case 0: @@ -653,9 +633,9 @@ u32 ChangeBgX(u8 bg, u32 value, u8 op) gGpuBgConfigs2[bg].bg_x -= value; break; } - + mode = GetBgMode(); - + switch (bg) { case 0: @@ -695,7 +675,7 @@ u32 ChangeBgX(u8 bg, u32 value, u8 op) } break; } - + return gGpuBgConfigs2[bg].bg_x; } @@ -713,12 +693,12 @@ u32 ChangeBgY(u8 bg, u32 value, u8 op) u8 mode; u16 temp1; u16 temp2; - + if (IsInvalidBg32(bg) != FALSE || GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0) { return -1; } - + switch (op) { case 0: @@ -732,9 +712,9 @@ u32 ChangeBgY(u8 bg, u32 value, u8 op) gGpuBgConfigs2[bg].bg_y -= value; break; } - + mode = GetBgMode(); - + switch (bg) { case 0: @@ -774,7 +754,7 @@ u32 ChangeBgY(u8 bg, u32 value, u8 op) } break; } - + return gGpuBgConfigs2[bg].bg_y; } @@ -783,12 +763,12 @@ u32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op) u8 mode; u16 temp1; u16 temp2; - + if (IsInvalidBg32(bg) != FALSE || GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0) { return -1; } - + switch (op) { case 0: @@ -802,9 +782,9 @@ u32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op) gGpuBgConfigs2[bg].bg_y -= value; break; } - + mode = GetBgMode(); - + switch (bg) { case 0: @@ -820,7 +800,7 @@ u32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op) { temp1 = gGpuBgConfigs2[2].bg_y >> 0x8; SetGpuReg_ForcedBlank(REG_OFFSET_BG2VOFS, temp1); - + } else { @@ -845,7 +825,7 @@ u32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op) } break; } - + return gGpuBgConfigs2[bg].bg_y; } @@ -868,13 +848,13 @@ u8 Unused_AdjustBgMosaic(u8 a1, u8 a2) u16 result; s16 test1; s16 test2; - + result = GetGpuReg(REG_OFFSET_MOSAIC); - + test1 = result & 0xF; test2 = (result >> 4) & 0xF; result &= 0xFF00; - + switch (a2) { case 0: @@ -929,12 +909,12 @@ u8 Unused_AdjustBgMosaic(u8 a1, u8 a2) } break; } - + result |= ((test2 << 0x4) & 0xF0); result |= (test1 & 0xF); - + SetGpuReg(REG_OFFSET_MOSAIC, result); - + return result; } @@ -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) { @@ -981,7 +961,7 @@ void CopyToBgTilemapBuffer(u8 bg, void *src, u16 mode, u16 destOffset) void CopyBgTilemapBufferToVram(u8 bg) { u16 sizeToLoad; - + if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE) { switch (GetBgType(bg)) @@ -1006,7 +986,7 @@ void CopyToBgTilemapBufferRect(u8 bg, void* src, u8 destX, u8 destY, u8 width, u u16 destX16; u16 destY16; u16 mode; - + if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE) { switch (GetBgType(bg)) @@ -1047,11 +1027,11 @@ void CopyRectToBgTilemapBufferRect(u8 bg, void* src, u8 srcX, u8 srcY, u8 srcWid u16 attribute; u16 mode; u16 mode2; - + void* srcCopy; u16 destX16; u16 destY16; - + if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE) { attribute = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE); @@ -1336,7 +1316,7 @@ void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u16 x16; u16 y16; u16 mode; - + if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE) { switch (GetBgType(bg)) @@ -1375,10 +1355,10 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt u16 mode2; u16 attribute; u16 mode3; - + u16 x16; u16 y16; - + if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE) { attribute = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE); @@ -1414,9 +1394,9 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt u16 GetBgMetricTextMode(u8 bg, u8 whichMetric) { u8 attribute; - + attribute = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE); - + switch (whichMetric) { case 0: @@ -1462,9 +1442,9 @@ u16 GetBgMetricTextMode(u8 bg, u8 whichMetric) u32 GetBgMetricAffineMode(u8 bg, u8 whichMetric) { u8 attribute; - + attribute = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE); - + switch (whichMetric) { case 0: @@ -1491,7 +1471,7 @@ u32 GetTileMapIndexFromCoords(s32 x, s32 y, s32 screenSize, u32 screenWidth, u32 { x = x & (screenWidth - 1); y = y & (screenHeight - 1); - + switch (screenSize) { case 0: @@ -1526,7 +1506,7 @@ void CopyTileMapEntry(u16 *src, u16 *dest, s32 palette1, u32 tileOffset, u32 pal test = ((*dest & 0xFC00) + (palette2 << 12)) | ((*src + tileOffset) & 0x3FF); break; } - + *dest = test; } #else @@ -1586,10 +1566,10 @@ _08002B3C:\n\ u32 GetBgType(u8 bg) { u8 mode; - + mode = GetBgMode(); - - + + switch (bg) { case 0: @@ -1621,7 +1601,7 @@ u32 GetBgType(u8 bg) } break; } - + return 0xFFFF; } diff --git a/src/dma3_manager.c b/src/dma3_manager.c index 6d12dec05a..0d3cf264be 100644 --- a/src/dma3_manager.c +++ b/src/dma3_manager.c @@ -14,7 +14,7 @@ void ClearDma3Requests(void) gDma3Requests[i].src = 0; gDma3Requests[i].dest = 0; } - + gDma3ManagerLocked = FALSE; } @@ -24,7 +24,7 @@ void ProcessDma3Requests(void) // NOTE: the fillerA member of the DMA struct is actually u32 value; // NOTE: gUnknown_0300001C is just a pointer inside the gDma3Requests structure, not a true symbol; feel free to remove u16 total_size; - + if (gDma3ManagerLocked) return; @@ -34,7 +34,7 @@ void ProcessDma3Requests(void) while (gDma3Requests[gDma3RequestCursor].size) { total_size += gDma3Requests[gDma3RequestCursor].size; - + if (total_size > 0xA000) return; // don't do too much at once @@ -90,14 +90,14 @@ 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].size = 0; gDma3Requests[gDma3RequestCursor].mode = 0; gDma3Requests[gDma3RequestCursor].value = 0; gDma3RequestCursor++; - + if (gDma3RequestCursor >= 128) // loop back to the first DMA request gDma3RequestCursor = 0; } @@ -419,13 +419,13 @@ _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; - + gDma3ManagerLocked = 1; - + cursor = gDma3RequestCursor; while(1) { @@ -434,12 +434,12 @@ int RequestDma3Copy(void *src, void *dest, u16 size, u8 mode) gDma3Requests[cursor].src = src; gDma3Requests[cursor].dest = dest; gDma3Requests[cursor].size = size; - + if(mode == 1) gDma3Requests[cursor].mode = mode; else gDma3Requests[cursor].mode = 3; - + gDma3ManagerLocked = FALSE; return (s16)cursor; } @@ -460,10 +460,10 @@ int RequestDma3Fill(s32 value, void *dest, u16 size, u8 mode) { int cursor; int var = 0; - + cursor = gDma3RequestCursor; gDma3ManagerLocked = 1; - + while(1) { if(!gDma3Requests[cursor].size) @@ -477,7 +477,7 @@ int RequestDma3Fill(s32 value, void *dest, u16 size, u8 mode) gDma3Requests[cursor].mode = 2; else gDma3Requests[cursor].mode = 4; - + gDma3ManagerLocked = FALSE; return (s16)cursor; } @@ -503,9 +503,9 @@ int CheckForSpaceForDma3Request(s16 index) for (; current < 0x80; current ++) if (gDma3Requests[current].size) return -1; - + return 0; - } + } if (gDma3Requests[index].size) return -1; diff --git a/src/egg_hatch.c b/src/egg_hatch.c new file mode 100644 index 0000000000..0b924fced4 --- /dev/null +++ b/src/egg_hatch.c @@ -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(); +} diff --git a/src/safari_zone.c b/src/safari_zone.c index fdfdd961a5..3e25468bf7 100644 --- a/src/safari_zone.c +++ b/src/safari_zone.c @@ -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) diff --git a/src/window.c b/src/window.c index 574b13aa04..164031bee7 100644 --- a/src/window.c +++ b/src/window.c @@ -35,7 +35,7 @@ static void nullsub_8(void) } -bool16 InitWindows(struct WindowTemplate *templates) +bool16 InitWindows(const struct WindowTemplate *templates) { int i; void *bgTilemapBuffer; diff --git a/sym_bss.txt b/sym_bss.txt index 070e7e5f97..c9128c7a44 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -113,7 +113,7 @@ gUnknown_03000DD8: @ 3000DD8 gUnknown_03000DDC: @ 3000DDC .space 0x4 -gUnknown_03000DE0: @ 3000DE0 +gEggHatchData: @ 3000DE0 .space 0x8 gUnknown_03000DE8: @ 3000DE8 diff --git a/sym_common.txt b/sym_common.txt index cf737c3909..23809c1a73 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -269,7 +269,7 @@ gUnknown_03005DA4: @ 3005DA4 gUnknown_03005DA8: @ 3005DA8 .space 0x4 -gUnknown_03005DAC: @ 3005DAC +gFieldCallback: @ 3005DAC .space 0x4 gUnknown_03005DB0: @ 3005DB0