From 61408456e82d3818fb8a7ab0e6b389c43ea47492 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 8 Nov 2017 18:05:47 +0100 Subject: [PATCH] starter choose file is decompiled --- asm/battle_frontier_2.s | 4 +- asm/battle_setup.s | 4 +- asm/credits.s | 2 +- asm/international_string_util.s | 6 +- asm/party_menu.s | 2 +- asm/pokedex.s | 4 +- asm/rom6.s | 2 +- asm/starter_choose.s | 985 ---------------------------- asm/wallclock.s | 2 +- data/data4.s | 10 +- include/international_string_util.h | 2 +- include/pokedex.h | 2 +- include/starter_choose.h | 7 + include/text_window.h | 2 +- ld_script.txt | 2 +- src/mail.c | 2 +- src/starter_choose.c | 391 +++++++++++ src/text_window.c | 4 +- sym_bss.txt | 2 +- 19 files changed, 424 insertions(+), 1011 deletions(-) delete mode 100644 asm/starter_choose.s create mode 100644 include/starter_choose.h create mode 100644 src/starter_choose.c diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index ac92b3c2a8..074e81a5b9 100755 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -2801,7 +2801,7 @@ sub_819BCF8: @ 819BCF8 lsls r0, 16 lsrs r0, 16 add r1, sp, 0xC - bl sub_81DB468 + bl CopyMonCategoryText movs r0, 0x1 add r1, sp, 0xC movs r2, 0x76 @@ -8831,7 +8831,7 @@ _0819EFF2: lsls r0, 16 lsrs r0, 16 add r1, sp, 0xC - bl sub_81DB468 + bl CopyMonCategoryText movs r0, 0x1 add r1, sp, 0xC movs r2, 0x76 diff --git a/asm/battle_setup.s b/asm/battle_setup.s index 5c71965799..2e3f5ab920 100644 --- a/asm/battle_setup.s +++ b/asm/battle_setup.s @@ -1328,7 +1328,7 @@ _080B1120: thumb_func_start sub_80B1138 sub_80B1138: @ 80B1138 push {lr} - ldr r0, =set_256color_bg_bg0 + ldr r0, =CB2_ChooseStarter bl SetMainCallback2 ldr r1, =gMain ldr r0, =sub_80B1158 @@ -1348,7 +1348,7 @@ sub_80B1158: @ 80B1158 ldrh r1, [r2] strh r1, [r0] ldrh r0, [r2] - bl sub_8133EDC + bl GetStarterPokemon lsls r0, 16 lsrs r0, 16 movs r1, 0 diff --git a/asm/credits.s b/asm/credits.s index 0b2da16b81..38383cd2f8 100644 --- a/asm/credits.s +++ b/asm/credits.s @@ -3675,7 +3675,7 @@ sub_8177388: @ 8177388 bl VarGet lsls r0, 16 lsrs r0, 16 - bl sub_8133EDC + bl GetStarterPokemon lsls r0, 16 lsrs r0, 16 bl SpeciesToNationalPokedexNum diff --git a/asm/international_string_util.s b/asm/international_string_util.s index 817a1d5e4e..08e4352492 100755 --- a/asm/international_string_util.s +++ b/asm/international_string_util.s @@ -52,8 +52,8 @@ _081DB462: bx r1 thumb_func_end sub_81DB41C - thumb_func_start sub_81DB468 -sub_81DB468: @ 81DB468 + thumb_func_start CopyMonCategoryText +CopyMonCategoryText: @ 81DB468 push {lr} adds r2, r0, 0 adds r0, r1, 0 @@ -70,7 +70,7 @@ sub_81DB468: @ 81DB468 pop {r0} bx r0 .pool - thumb_func_end sub_81DB468 + thumb_func_end CopyMonCategoryText thumb_func_start sub_81DB494 sub_81DB494: @ 81DB494 diff --git a/asm/party_menu.s b/asm/party_menu.s index 3d2af7e7d1..61dc8a4247 100755 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -4211,7 +4211,7 @@ _081B23E8: movs r1, 0x4F movs r2, 0xD0 bl sub_809882C - bl sub_8098C64 + bl GetOverworldTextboxPalettePtr movs r1, 0xE0 movs r2, 0x20 bl LoadPalette diff --git a/asm/pokedex.s b/asm/pokedex.s index 3d69281c2a..5d07e38e16 100644 --- a/asm/pokedex.s +++ b/asm/pokedex.s @@ -2311,7 +2311,7 @@ _080BC870: movs r2, 0xBE bl LoadPalette _080BC87A: - bl sub_8098C64 + bl GetOverworldTextboxPalettePtr movs r1, 0xF0 movs r2, 0x20 bl LoadPalette @@ -8950,7 +8950,7 @@ _080C028E: add r4, sp, 0x10 adds r0, r6, 0 adds r1, r4, 0 - bl sub_81DB468 + bl CopyMonCategoryText adds r0, r4, 0 b _080C02AE .pool diff --git a/asm/rom6.s b/asm/rom6.s index 87b780ba5c..decc596919 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -7673,7 +7673,7 @@ sub_81394D8: @ 81394D8 bl VarGet lsls r0, 16 lsrs r0, 16 - bl sub_8133EDC + bl GetStarterPokemon lsls r0, 16 lsrs r6, r0, 16 bl CalculatePlayerPartyCount diff --git a/asm/starter_choose.s b/asm/starter_choose.s deleted file mode 100644 index da42959ead..0000000000 --- a/asm/starter_choose.s +++ /dev/null @@ -1,985 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_8133EDC -sub_8133EDC: @ 8133EDC - push {lr} - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0x3 - bls _08133EE8 - movs r1, 0 -_08133EE8: - ldr r0, =gUnknown_085B1DF8 - lsls r1, 1 - adds r1, r0 - ldrh r0, [r1] - pop {r1} - bx r1 - .pool - thumb_func_end sub_8133EDC - - thumb_func_start sub_8133EF8 -sub_8133EF8: @ 8133EF8 - push {lr} - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - pop {r0} - bx r0 - thumb_func_end sub_8133EF8 - - thumb_func_start set_256color_bg_bg0 -set_256color_bg_bg0: @ 8133F0C - push {r4-r6,lr} - mov r6, r10 - mov r5, r9 - mov r4, r8 - push {r4-r6} - sub sp, 0xC - movs r0, 0 - bl SetVBlankCallback - movs r0, 0 - movs r1, 0 - bl SetGpuReg - movs r0, 0xE - movs r1, 0 - bl SetGpuReg - movs r0, 0xC - movs r1, 0 - bl SetGpuReg - movs r0, 0xA - movs r1, 0 - bl SetGpuReg - movs r0, 0x8 - movs r1, 0 - bl SetGpuReg - 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, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x2 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x2 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x3 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x3 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - add r1, sp, 0x4 - movs r0, 0 - strh r0, [r1] - ldr r2, =0x040000d4 - str r1, [r2] - movs r1, 0xC0 - lsls r1, 19 - str r1, [r2, 0x4] - ldr r0, =0x8100c000 - str r0, [r2, 0x8] - ldr r0, [r2, 0x8] - movs r0, 0 - mov r9, r0 - str r0, [sp, 0x8] - add r0, sp, 0x8 - str r0, [r2] - movs r0, 0xE0 - lsls r0, 19 - str r0, [r2, 0x4] - ldr r0, =0x85000100 - str r0, [r2, 0x8] - ldr r0, [r2, 0x8] - add r0, sp, 0x4 - mov r3, r9 - strh r3, [r0] - str r0, [r2] - movs r0, 0xA0 - lsls r0, 19 - str r0, [r2, 0x4] - ldr r0, =0x81000200 - str r0, [r2, 0x8] - ldr r0, [r2, 0x8] - ldr r0, =gBirchHelpGfx - bl LZ77UnCompVram - ldr r0, =gBirchBagTilemap - ldr r1, =0x06003000 - bl LZ77UnCompVram - ldr r0, =gBirchGrassTilemap - ldr r1, =0x06003800 - bl LZ77UnCompVram - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_085B1E00 - movs r0, 0 - movs r2, 0x3 - bl InitBgsFromTemplates - ldr r0, =gUnknown_085B1DCC - bl InitWindows - bl DeactivateAllTextPrinters - movs r1, 0xAA - lsls r1, 2 - movs r0, 0 - movs r2, 0xD0 - bl sub_809882C - bl clear_scheduled_bg_copies_to_vram - bl remove_some_task - bl ResetTasks - bl ResetSpriteData - bl ResetPaletteFade - bl FreeAllSpritePalettes - bl dp13_810BB8C - bl sub_8098C64 - movs r1, 0xE0 - movs r2, 0x20 - bl LoadPalette - ldr r0, =gBirchBagGrassPal - movs r1, 0 - movs r2, 0x40 - bl LoadPalette - ldr r0, =gUnknown_085B1ED8 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_085B1EE8 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_085B1EF8 - bl LoadSpritePalettes - movs r0, 0x1 - negs r0, r0 - mov r1, r9 - str r1, [sp] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - movs r0, 0x1 - bl EnableInterrupts - ldr r0, =sub_8133EF8 - bl SetVBlankCallback - ldr r0, =sub_81341E0 - bl SetMainCallback2 - movs r0, 0x48 - movs r1, 0x3F - bl SetGpuReg - movs r0, 0x4A - movs r1, 0x1F - bl SetGpuReg - movs r0, 0x40 - movs r1, 0 - bl SetGpuReg - movs r0, 0x44 - movs r1, 0 - bl SetGpuReg - movs r0, 0x50 - movs r1, 0xFE - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0x7 - bl SetGpuReg - movs r1, 0xC1 - lsls r1, 6 - movs r0, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x3 - bl ShowBg - ldr r0, =sub_81341FC - movs r1, 0 - bl CreateTask - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - movs r3, 0x1 - mov r10, r3 - mov r1, r10 - strh r1, [r0, 0x8] - ldr r0, =gUnknown_085B1F10 - movs r1, 0x78 - movs r2, 0x38 - movs r3, 0x2 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - ldr r3, =gSprites - mov r8, r3 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - add r1, r8 - strh r4, [r1, 0x2E] - ldr r6, =gUnknown_085B1F28 - ldr r5, =gUnknown_085B1DEC - ldrb r1, [r5] - ldrb r2, [r5, 0x1] - adds r0, r6, 0 - movs r3, 0x2 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - add r1, r8 - strh r4, [r1, 0x2E] - mov r0, r9 - strh r0, [r1, 0x30] - ldrb r1, [r5, 0x2] - ldrb r2, [r5, 0x3] - adds r0, r6, 0 - movs r3, 0x2 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - add r1, r8 - strh r4, [r1, 0x2E] - mov r3, r10 - strh r3, [r1, 0x30] - ldrb r1, [r5, 0x4] - ldrb r2, [r5, 0x5] - adds r0, r6, 0 - movs r3, 0x2 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - add r1, r8 - strh r4, [r1, 0x2E] - movs r0, 0x2 - strh r0, [r1, 0x30] - ldr r1, =gUnknown_030011F8 - movs r0, 0xFF - strh r0, [r1] - add sp, 0xC - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end set_256color_bg_bg0 - - thumb_func_start sub_81341E0 -sub_81341E0: @ 81341E0 - push {lr} - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl do_scheduled_bg_tilemap_copies_to_vram - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end sub_81341E0 - - thumb_func_start sub_81341FC -sub_81341FC: @ 81341FC - push {r4,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gTasks - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - adds r4, r1 - ldrb r0, [r4, 0x8] - bl sub_81344C8 - movs r2, 0xAA - lsls r2, 2 - movs r0, 0 - movs r1, 0 - movs r3, 0xD - bl SetWindowBorderStyle - ldr r2, =gText_BirchInTrouble - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - movs r1, 0x1 - movs r3, 0 - bl PrintTextOnWindow - movs r0, 0 - bl PutWindowTilemap - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldr r0, =sub_813425C - str r0, [r4] - add sp, 0xC - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81341FC - - thumb_func_start sub_813425C -sub_813425C: @ 813425C - push {r4-r7,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r2, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r6, r0, r2 - ldrh r7, [r6, 0x8] - ldrb r4, [r6, 0x8] - ldr r1, =gMain - ldrh r3, [r1, 0x2E] - movs r0, 0x1 - ands r0, r3 - cmp r0, 0 - beq _081342F8 - bl sub_8134604 - ldr r0, =gUnknown_085B1F40 - ldr r1, =gUnknown_085B1DEC - lsls r2, r4, 1 - adds r3, r2, r1 - ldrb r5, [r3] - adds r1, 0x1 - adds r2, r1 - ldrb r4, [r2] - adds r1, r5, 0 - adds r2, r4, 0 - movs r3, 0x1 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r6, 0xC] - ldrh r0, [r6, 0x8] - bl sub_8133EDC - lsls r0, 16 - lsrs r0, 16 - adds r1, r5, 0 - adds r2, r4, 0 - bl sub_8134690 - lsls r0, 24 - lsrs r0, 24 - ldr r4, =gSprites - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r2, r4, 0 - adds r2, 0x10 - adds r2, r1, r2 - ldr r3, =gUnknown_085B1ED0 - str r3, [r2] - adds r4, 0x1C - adds r1, r4 - ldr r2, =sub_8134774 - str r2, [r1] - strh r0, [r6, 0xA] - ldr r0, =sub_8134340 - str r0, [r6] - b _08134334 - .pool -_081342F8: - movs r0, 0x20 - ands r0, r3 - cmp r0, 0 - beq _08134314 - cmp r4, 0 - beq _08134314 - subs r0, r7, 0x1 - strh r0, [r6, 0x8] - ldr r0, =sub_8134640 - str r0, [r6] - b _08134334 - .pool -_08134314: - ldrh r1, [r1, 0x2E] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _08134334 - cmp r4, 0x1 - bhi _08134334 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r2 - ldrh r1, [r0, 0x8] - adds r1, 0x1 - strh r1, [r0, 0x8] - ldr r1, =sub_8134640 - str r1, [r0] -_08134334: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_813425C - - thumb_func_start sub_8134340 -sub_8134340: @ 8134340 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r3, =gSprites - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r2, r1, r2 - movs r0, 0xC - ldrsh r1, [r2, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r0, r3 - adds r0, r1, 0 - adds r0, 0x3F - ldrb r0, [r0] - lsls r0, 26 - cmp r0, 0 - bge _0813437E - movs r3, 0x20 - ldrsh r0, [r1, r3] - cmp r0, 0x78 - bne _0813437E - movs r3, 0x22 - ldrsh r0, [r1, r3] - cmp r0, 0x40 - bne _0813437E - ldr r0, =sub_8134390 - str r0, [r2] -_0813437E: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8134340 - - thumb_func_start sub_8134390 -sub_8134390: @ 8134390 - push {r4,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gTasks - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - adds r4, r1 - ldrh r0, [r4, 0x8] - bl sub_8133EDC - lsls r0, 16 - lsrs r0, 16 - movs r1, 0 - bl PlayCry1 - movs r0, 0 - movs r1, 0x11 - bl FillWindowPixelBuffer - ldr r2, =gText_ConfirmStarterChoice - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - movs r1, 0x1 - movs r3, 0 - bl PrintTextOnWindow - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldr r0, =gUnknown_085B1DDC - movs r1, 0xAA - lsls r1, 2 - movs r2, 0xD - movs r3, 0 - bl CreateYesNoMenu - ldr r0, =sub_8134400 - str r0, [r4] - add sp, 0xC - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8134390 - - thumb_func_start sub_8134400 -sub_8134400: @ 8134400 - push {r4-r6,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl sub_8198C58 - lsls r0, 24 - asrs r1, r0, 24 - cmp r1, 0 - beq _08134426 - cmp r1, 0 - bgt _08134420 - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _08134450 - b _0813449A -_08134420: - cmp r1, 0x1 - beq _08134450 - b _0813449A -_08134426: - ldr r2, =gScriptResult - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldrh r0, [r0, 0x8] - strh r0, [r2] - bl dp13_810BB8C - ldr r0, =gMain - ldr r0, [r0, 0x8] - bl SetMainCallback2 - b _0813449A - .pool -_08134450: - movs r0, 0x5 - bl PlaySE - ldr r0, =gTasks - lsls r5, r4, 2 - adds r5, r4 - lsls r5, 3 - adds r5, r0 - ldrb r4, [r5, 0xA] - ldr r6, =gSprites - lsls r0, r4, 4 - adds r0, r4 - lsls r0, 2 - adds r0, r6 - ldrb r0, [r0, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - adds r0, r4, 0 - bl sub_818D820 - ldrb r0, [r5, 0xC] - lsls r4, r0, 4 - adds r4, r0 - lsls r4, 2 - adds r4, r6 - ldrb r0, [r4, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - adds r0, r4, 0 - bl DestroySprite - ldr r0, =sub_81344AC - str r0, [r5] -_0813449A: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8134400 - - thumb_func_start sub_81344AC -sub_81344AC: @ 81344AC - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldr r0, =sub_81341FC - str r0, [r1] - bx lr - .pool - thumb_func_end sub_81344AC - - thumb_func_start sub_81344C8 -sub_81344C8: @ 81344C8 - push {r4-r6,lr} - mov r6, r10 - mov r5, r9 - mov r4, r8 - push {r4-r6} - sub sp, 0x34 - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - adds r0, r5, 0 - bl sub_8133EDC - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - adds r0, r4, 0 - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - add r1, sp, 0xC - bl sub_81DB468 - movs r0, 0xB - adds r1, r4, 0 - muls r1, r0 - mov r9, r1 - ldr r0, =gSpeciesNames - add r9, r0 - ldr r0, =gUnknown_085B1DE4 - ldr r1, [r0, 0x4] - ldr r0, [r0] - str r0, [sp, 0x2C] - str r1, [sp, 0x30] - ldr r3, =gUnknown_085B1DF2 - lsls r5, 1 - adds r2, r5, r3 - mov r10, r2 - ldrb r0, [r2] - lsls r0, 8 - ldr r1, =0xffff00ff - ldr r2, [sp, 0x2C] - ands r2, r1 - orrs r2, r0 - str r2, [sp, 0x2C] - adds r3, 0x1 - adds r5, r3 - ldrb r1, [r5] - lsls r1, 16 - ldr r0, =0xff00ffff - ands r0, r2 - orrs r0, r1 - str r0, [sp, 0x2C] - add r0, sp, 0x2C - bl AddWindow - ldr r4, =gUnknown_030011F8 - strh r0, [r4] - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0x7 - add r1, sp, 0xC - movs r2, 0x68 - bl GetStringCenterAlignXOffset - adds r2, r0, 0 - ldrb r0, [r4] - lsls r2, 24 - lsrs r2, 24 - ldr r1, =gUnknown_085B1E0C - mov r8, r1 - str r1, [sp] - movs r6, 0 - str r6, [sp, 0x4] - add r1, sp, 0xC - str r1, [sp, 0x8] - movs r1, 0x7 - movs r3, 0x1 - bl box_print - movs r0, 0x1 - mov r1, r9 - movs r2, 0x68 - bl GetStringCenterAlignXOffset - adds r2, r0, 0 - ldrb r0, [r4] - lsls r2, 24 - lsrs r2, 24 - mov r1, r8 - str r1, [sp] - str r6, [sp, 0x4] - mov r1, r9 - str r1, [sp, 0x8] - movs r1, 0x1 - movs r3, 0x11 - bl box_print - ldrb r0, [r4] - bl PutWindowTilemap - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - mov r2, r10 - ldrb r1, [r2] - lsls r0, r1, 27 - movs r2, 0xFC - lsls r2, 24 - adds r0, r2 - adds r1, 0xD - lsls r1, 3 - adds r1, 0x4 - lsls r1, 24 - ldrb r4, [r5] - lsls r5, r4, 27 - lsrs r5, 24 - adds r4, 0x4 - lsls r4, 27 - lsrs r4, 24 - lsrs r1, 8 - orrs r1, r0 - lsrs r1, 16 - movs r0, 0x40 - bl SetGpuReg - lsls r5, 8 - orrs r5, r4 - movs r0, 0x44 - adds r1, r5, 0 - bl SetGpuReg - add sp, 0x34 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81344C8 - - thumb_func_start sub_8134604 -sub_8134604: @ 8134604 - push {r4,lr} - ldr r4, =gUnknown_030011F8 - ldrb r0, [r4] - movs r1, 0 - bl FillWindowPixelBuffer - ldrb r0, [r4] - bl ClearWindowTilemap - ldrb r0, [r4] - bl RemoveWindow - movs r0, 0xFF - strh r0, [r4] - movs r0, 0x40 - movs r1, 0 - bl SetGpuReg - movs r0, 0x44 - movs r1, 0 - bl SetGpuReg - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8134604 - - thumb_func_start sub_8134640 -sub_8134640: @ 8134640 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - bl sub_8134604 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_8134668 - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8134640 - - thumb_func_start sub_8134668 -sub_8134668: @ 8134668 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gTasks - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - adds r4, r1 - ldrb r0, [r4, 0x8] - bl sub_81344C8 - ldr r0, =sub_813425C - str r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8134668 - - thumb_func_start sub_8134690 -sub_8134690: @ 8134690 - push {lr} - sub sp, 0x10 - lsls r0, 16 - lsrs r0, 16 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - str r1, [sp] - str r2, [sp, 0x4] - movs r1, 0xE - str r1, [sp, 0x8] - ldr r1, =0x0000ffff - str r1, [sp, 0xC] - movs r1, 0x8 - movs r2, 0 - movs r3, 0x1 - bl sub_818D3E4 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gSprites - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - adds r2, r1 - ldrb r3, [r2, 0x5] - movs r1, 0xD - negs r1, r1 - ands r1, r3 - strb r1, [r2, 0x5] - add sp, 0x10 - pop {r1} - bx r1 - .pool - thumb_func_end sub_8134690 - - thumb_func_start sub_81346DC -sub_81346DC: @ 81346DC - push {r4,lr} - adds r4, r0, 0 - ldr r2, =gUnknown_085B1E28 - ldr r3, =gTasks - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r3 - movs r1, 0x8 - ldrsh r0, [r0, r1] - lsls r0, 1 - adds r0, r2 - ldrb r0, [r0] - strh r0, [r4, 0x20] - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r3 - movs r1, 0x8 - ldrsh r0, [r0, r1] - lsls r0, 1 - adds r2, 0x1 - adds r0, r2 - ldrb r0, [r0] - strh r0, [r4, 0x22] - movs r1, 0x30 - ldrsh r0, [r4, r1] - movs r1, 0x8 - bl Sin - strh r0, [r4, 0x26] - ldrh r0, [r4, 0x30] - lsls r0, 24 - lsrs r0, 24 - adds r0, 0x4 - strh r0, [r4, 0x30] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81346DC - - thumb_func_start sub_813473C -sub_813473C: @ 813473C - push {lr} - adds r3, r0, 0 - ldr r2, =gTasks - movs r0, 0x2E - ldrsh r1, [r3, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - movs r2, 0x8 - ldrsh r1, [r0, r2] - movs r2, 0x30 - ldrsh r0, [r3, r2] - cmp r1, r0 - bne _08134768 - adds r0, r3, 0 - movs r1, 0x1 - bl StartSpriteAnimIfDifferent - b _08134770 - .pool -_08134768: - adds r0, r3, 0 - movs r1, 0 - bl StartSpriteAnimIfDifferent -_08134770: - pop {r0} - bx r0 - thumb_func_end sub_813473C - - thumb_func_start sub_8134774 -sub_8134774: @ 8134774 - push {lr} - adds r1, r0, 0 - ldrh r2, [r1, 0x20] - movs r3, 0x20 - ldrsh r0, [r1, r3] - cmp r0, 0x78 - ble _08134786 - subs r0, r2, 0x4 - strh r0, [r1, 0x20] -_08134786: - ldrh r2, [r1, 0x20] - movs r3, 0x20 - ldrsh r0, [r1, r3] - cmp r0, 0x77 - bgt _08134794 - adds r0, r2, 0x4 - strh r0, [r1, 0x20] -_08134794: - ldrh r2, [r1, 0x22] - movs r3, 0x22 - ldrsh r0, [r1, r3] - cmp r0, 0x40 - ble _081347A2 - subs r0, r2, 0x2 - strh r0, [r1, 0x22] -_081347A2: - ldrh r2, [r1, 0x22] - movs r3, 0x22 - ldrsh r0, [r1, r3] - cmp r0, 0x3F - bgt _081347B0 - adds r0, r2, 0x2 - strh r0, [r1, 0x22] -_081347B0: - pop {r0} - bx r0 - thumb_func_end sub_8134774 - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/wallclock.s b/asm/wallclock.s index f8cc87fe8e..5c818212c9 100644 --- a/asm/wallclock.s +++ b/asm/wallclock.s @@ -153,7 +153,7 @@ _081348FC: movs r2, 0x20 bl LoadPalette _08134906: - bl sub_8098C64 + bl GetOverworldTextboxPalettePtr movs r1, 0xE0 movs r2, 0x20 bl LoadPalette diff --git a/data/data4.s b/data/data4.s index e98518b738..33d3df864e 100644 --- a/data/data4.s +++ b/data/data4.s @@ -35,13 +35,13 @@ gUnknown_085B1DDC:: @ 85B1DDC gUnknown_085B1DE4:: @ 85B1DE4 .incbin "baserom.gba", 0x5b1de4, 0x8 -gUnknown_085B1DEC:: @ 85B1DEC +sPokeballCoords:: @ 85B1DEC .incbin "baserom.gba", 0x5b1dec, 0x6 -gUnknown_085B1DF2:: @ 85B1DF2 +gStarterChoose_LabelCoords:: @ 85B1DF2 .incbin "baserom.gba", 0x5b1df2, 0x6 -gUnknown_085B1DF8:: @ 85B1DF8 +sStarterMons:: @ 85B1DF8 .incbin "baserom.gba", 0x5b1df8, 0x8 gUnknown_085B1E00:: @ 85B1E00 @@ -65,10 +65,10 @@ gUnknown_085B1EE8:: @ 85B1EE8 gUnknown_085B1EF8:: @ 85B1EF8 .incbin "baserom.gba", 0x5b1ef8, 0x18 -gUnknown_085B1F10:: @ 85B1F10 +sSpriteTemplate_Hand:: @ 85B1F10 .incbin "baserom.gba", 0x5b1f10, 0x18 -gUnknown_085B1F28:: @ 85B1F28 +sSpriteTemplate_PokeBall:: @ 85B1F28 .incbin "baserom.gba", 0x5b1f28, 0x18 gUnknown_085B1F40:: @ 85B1F40 diff --git a/include/international_string_util.h b/include/international_string_util.h index 9d9735a524..e7876162ee 100644 --- a/include/international_string_util.h +++ b/include/international_string_util.h @@ -12,7 +12,7 @@ s32 GetStringWidthDifference(s32 fontId, const u8 *str, s32 totalWidth, s32 lett s32 GetMaxWidthInMenuTable(const struct MenuAction *str, s32 arg1); s32 sub_81DB3D8(const struct MenuAction *str, u8* arg1, s32 arg2); // sub_81DB41C -// sub_81DB468 +// CopyMonCategoryText // sub_81DB494 // sub_81DB4DC // sub_81DB554 diff --git a/include/pokedex.h b/include/pokedex.h index 79721899f2..236feac45c 100644 --- a/include/pokedex.h +++ b/include/pokedex.h @@ -2,7 +2,7 @@ #define GUARD_POKEDEX_H void ResetPokedex(void); -const u8 *GetPokemonCategory(u16); +void CopyMonCategoryText(u16 species, u8 *dst); u16 GetPokedexHeightWeight(u16 dexNum, u8 data); u16 GetNationalPokedexCount(u8); u16 GetHoennPokedexCount(u8); diff --git a/include/starter_choose.h b/include/starter_choose.h new file mode 100644 index 0000000000..61bc177357 --- /dev/null +++ b/include/starter_choose.h @@ -0,0 +1,7 @@ +#ifndef GUARD_STARTER_CHOOSE_H +#define GUARD_STARTER_CHOOSE_H + +u16 GetStarterPokemon(u16 chosenStarterId); +void CB2_ChooseStarter(void); + +#endif // GUARD_STARTER_CHOOSE_H diff --git a/include/text_window.h b/include/text_window.h index 0cefeea8ed..da3fb301ec 100644 --- a/include/text_window.h +++ b/include/text_window.h @@ -16,7 +16,7 @@ void sub_8098858(u8 windowId, u16 tileNum, u8 palNum); void sub_80989E0(u8 windowId, u16 tileNum, u8 palNum); void rbox_fill_rectangle(u8 windowId); const u16* stdpal_get(u8 id); -const u16* sub_8098C64(void); +const u16* GetOverworldTextboxPalettePtr(void); void sub_8098C6C(u8 bg, u16 destOffset, u8 palOffset); #endif // GUARD_TEXT_WINDOW_H diff --git a/ld_script.txt b/ld_script.txt index c8d31c846f..7664f36860 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -175,7 +175,7 @@ SECTIONS { asm/contest_painting.o(.text); src/battle_ai_script_commands.o(.text); asm/trader.o(.text); - asm/starter_choose.o(.text); + src/starter_choose.o(.text); asm/wallclock.o(.text); asm/rom6.o(.text); asm/battle_records.o(.text); diff --git a/src/mail.c b/src/mail.c index 1060d73bdf..1ceb1be1aa 100644 --- a/src/mail.c +++ b/src/mail.c @@ -386,7 +386,7 @@ bool8 sub_81215EC(void) CopyBgTilemapBufferToVram(2); break; case 12: - LoadPalette(sub_8098C64(), 240, 32); + LoadPalette(GetOverworldTextboxPalettePtr(), 240, 32); gPlttBufferUnfaded[250] = gUnknown_0859F2B8[gUnknown_0203A134->mailType].color10; gPlttBufferFaded[250] = gUnknown_0859F2B8[gUnknown_0203A134->mailType].color10; gPlttBufferUnfaded[251] = gUnknown_0859F2B8[gUnknown_0203A134->mailType].color12; diff --git a/src/starter_choose.c b/src/starter_choose.c new file mode 100644 index 0000000000..c730e0978b --- /dev/null +++ b/src/starter_choose.c @@ -0,0 +1,391 @@ +#include "global.h" +#include "starter_choose.h" +#include "palette.h" +#include "sprite.h" +#include "pokemon.h" +#include "task.h" +#include "bg.h" +#include "gpu_regs.h" +#include "main.h" +#include "window.h" +#include "text.h" +#include "decompress.h" +#include "menu.h" +#include "sound.h" +#include "songs.h" +#include "event_data.h" +#include "pokedex.h" +#include "data2.h" +#include "international_string_util.h" +#include "trig.h" + +#define STARTER_MON_COUNT 3 + +// Position of the sprite of the selected starter Pokemon +#define STARTER_PKMN_POS_X 120 +#define STARTER_PKMN_POS_Y 64 + +extern u16 sStarterChooseWindowId; + +// graphics +extern const u32 gBirchHelpGfx[]; +extern const u32 gBirchBagTilemap[]; +extern const u32 gBirchGrassTilemap[]; +extern const u16 gBirchBagGrassPal[]; + +// text +extern const u8 gText_BirchInTrouble[]; +extern const u8 gText_ConfirmStarterChoice[]; + +extern const u16 sStarterMons[STARTER_MON_COUNT]; +extern const struct BgTemplate gUnknown_085B1E00[3]; +extern const struct WindowTemplate gUnknown_085B1DCC[]; +extern const struct WindowTemplate gUnknown_085B1DDC; +extern const struct CompressedSpriteSheet gUnknown_085B1ED8[]; +extern const struct CompressedSpriteSheet gUnknown_085B1EE8[]; +extern const struct SpritePalette gUnknown_085B1EF8[]; +extern const struct SpriteTemplate sSpriteTemplate_PokeBall; +extern const struct SpriteTemplate sSpriteTemplate_Hand; +extern const struct SpriteTemplate gUnknown_085B1F40; +extern const union AffineAnimCmd *const gUnknown_085B1ED0; +extern const u8 sPokeballCoords[STARTER_MON_COUNT][2]; +extern const struct WindowTemplate gUnknown_085B1DE4; +extern const u8 gStarterChoose_LabelCoords[][2]; +extern const u8 gUnknown_085B1E0C[]; +extern const u8 gUnknown_085B1E28[][2]; + +extern void sub_809882C(u8, u16, u8); +extern void remove_some_task(void); +extern void clear_scheduled_bg_copies_to_vram(void); +extern void dp13_810BB8C(void); +extern void do_scheduled_bg_tilemap_copies_to_vram(void); +extern u16 sub_818D820(u16); +extern const u16 *GetOverworldTextboxPalettePtr(void); +extern u8 sub_818D3E4(u16 species, u32 trainerId, u32 personality, u8 flags, s16 x, s16 y, u8, u16); + +// this file's functions +static void MainCallback2_StarterChoose(void); +static void sub_8134604(void); +static void Task_StarterChoose1(u8 taskId); +static void Task_StarterChoose2(u8 taskId); +static void Task_StarterChoose3(u8 taskId); +static void Task_StarterChoose4(u8 taskId); +static void Task_StarterChoose5(u8 taskId); +static void Task_StarterChoose6(u8 taskId); +static void Task_MoveStarterChooseCursor(u8 taskId); +static void sub_8134668(u8 taskId); +static void CreateStarterPokemonLabel(u8 selection); +static u8 CreatePokemonFrontSprite(u16 species, u8 x, u8 y); +static void StarterPokemonSpriteCallback(struct Sprite *sprite); + +u16 GetStarterPokemon(u16 chosenStarterId) +{ + if (chosenStarterId > STARTER_MON_COUNT) + chosenStarterId = 0; + return sStarterMons[chosenStarterId]; +} + +static void VblankCB_StarterChoose(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +#define tStarterSelection data[0] +#define tPkmnSpriteId data[1] +#define tCircleSpriteId data[2] + +void CB2_ChooseStarter(void) +{ + u16 savedIme; + u8 taskId; + u8 spriteId; + + SetVBlankCallback(NULL); + + SetGpuReg(REG_OFFSET_DISPCNT, 0); + SetGpuReg(REG_OFFSET_BG3CNT, 0); + SetGpuReg(REG_OFFSET_BG2CNT, 0); + SetGpuReg(REG_OFFSET_BG1CNT, 0); + SetGpuReg(REG_OFFSET_BG0CNT, 0); + + ChangeBgX(0, 0, 0); + ChangeBgY(0, 0, 0); + ChangeBgX(1, 0, 0); + ChangeBgY(1, 0, 0); + ChangeBgX(2, 0, 0); + ChangeBgY(2, 0, 0); + ChangeBgX(3, 0, 0); + ChangeBgY(3, 0, 0); + + DmaFill16(3, 0, VRAM, VRAM_SIZE); + DmaFill32(3, 0, OAM, OAM_SIZE); + DmaFill16(3, 0, PLTT, PLTT_SIZE); + + LZ77UnCompVram(&gBirchHelpGfx, (void *)VRAM); + LZ77UnCompVram(&gBirchBagTilemap, (void *)(VRAM + 0x3000)); + LZ77UnCompVram(&gBirchGrassTilemap, (void *)(VRAM + 0x3800)); + + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_085B1E00, ARRAY_COUNT(gUnknown_085B1E00)); + InitWindows(gUnknown_085B1DCC); + + DeactivateAllTextPrinters(); + sub_809882C(0, 0x2A8, 0xD0); + clear_scheduled_bg_copies_to_vram(); + remove_some_task(); + ResetTasks(); + ResetSpriteData(); + ResetPaletteFade(); + FreeAllSpritePalettes(); + dp13_810BB8C(); + + LoadPalette(GetOverworldTextboxPalettePtr(), 0xE0, 0x20); + LoadPalette(gBirchBagGrassPal, 0, 0x40); + LoadCompressedObjectPic(&gUnknown_085B1ED8[0]); + LoadCompressedObjectPic(&gUnknown_085B1EE8[0]); + LoadSpritePalettes(gUnknown_085B1EF8); + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + + EnableInterrupts(DISPSTAT_VBLANK); + SetVBlankCallback(VblankCB_StarterChoose); + SetMainCallback2(MainCallback2_StarterChoose); + + SetGpuReg(REG_OFFSET_WININ, 0x3F); + SetGpuReg(REG_OFFSET_WINOUT, 0x1F); + SetGpuReg(REG_OFFSET_WIN0H, 0); + SetGpuReg(REG_OFFSET_WIN0V, 0); + SetGpuReg(REG_OFFSET_BLDCNT, 0xFE); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 7); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); + + ShowBg(0); + ShowBg(2); + ShowBg(3); + + taskId = CreateTask(Task_StarterChoose1, 0); + gTasks[taskId].tStarterSelection = 1; + + // Create hand sprite + spriteId = CreateSprite(&sSpriteTemplate_Hand, 120, 56, 2); + gSprites[spriteId].data0 = taskId; + + // Create three Pokeball sprites + spriteId = CreateSprite(&sSpriteTemplate_PokeBall, sPokeballCoords[0][0], sPokeballCoords[0][1], 2); + gSprites[spriteId].data0 = taskId; + gSprites[spriteId].data1 = 0; + + spriteId = CreateSprite(&sSpriteTemplate_PokeBall, sPokeballCoords[1][0], sPokeballCoords[1][1], 2); + gSprites[spriteId].data0 = taskId; + gSprites[spriteId].data1 = 1; + + spriteId = CreateSprite(&sSpriteTemplate_PokeBall, sPokeballCoords[2][0], sPokeballCoords[2][1], 2); + gSprites[spriteId].data0 = taskId; + gSprites[spriteId].data1 = 2; + + sStarterChooseWindowId = 0xFF; +} + +static void MainCallback2_StarterChoose(void) +{ + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + do_scheduled_bg_tilemap_copies_to_vram(); + UpdatePaletteFade(); +} + +static void Task_StarterChoose1(u8 taskId) +{ + CreateStarterPokemonLabel(gTasks[taskId].tStarterSelection); + SetWindowBorderStyle(0, FALSE, 0x2A8, 0xD); + PrintTextOnWindow(0, 1, gText_BirchInTrouble, 0, 1, 0, NULL); + PutWindowTilemap(0); + schedule_bg_copy_tilemap_to_vram(0); + gTasks[taskId].func = Task_StarterChoose2; +} + +static void Task_StarterChoose2(u8 taskId) +{ + u8 selection = gTasks[taskId].tStarterSelection; + + if (gMain.newKeys & A_BUTTON) + { + u8 spriteId; + + sub_8134604(); + + // Create white circle background + spriteId = CreateSprite(&gUnknown_085B1F40, sPokeballCoords[selection][0], sPokeballCoords[selection][1], 1); + gTasks[taskId].tCircleSpriteId = spriteId; + + // Create Pokemon sprite + spriteId = CreatePokemonFrontSprite(GetStarterPokemon(gTasks[taskId].tStarterSelection), sPokeballCoords[selection][0], sPokeballCoords[selection][1]); + gSprites[spriteId].affineAnims = &gUnknown_085B1ED0; + gSprites[spriteId].callback = StarterPokemonSpriteCallback; + + gTasks[taskId].tPkmnSpriteId = spriteId; + gTasks[taskId].func = Task_StarterChoose3; + } + else if ((gMain.newKeys & DPAD_LEFT) && selection > 0) + { + gTasks[taskId].tStarterSelection--; + gTasks[taskId].func = Task_MoveStarterChooseCursor; + } + else if ((gMain.newKeys & DPAD_RIGHT) && selection < (STARTER_MON_COUNT - 1)) + { + gTasks[taskId].tStarterSelection++; + gTasks[taskId].func = Task_MoveStarterChooseCursor; + } +} + +static void Task_StarterChoose3(u8 taskId) +{ + if (gSprites[gTasks[taskId].tCircleSpriteId].affineAnimEnded && + gSprites[gTasks[taskId].tCircleSpriteId].pos1.x == STARTER_PKMN_POS_X && + gSprites[gTasks[taskId].tCircleSpriteId].pos1.y == STARTER_PKMN_POS_Y) + { + gTasks[taskId].func = Task_StarterChoose4; + } +} + +static void Task_StarterChoose4(u8 taskId) +{ + PlayCry1(GetStarterPokemon(gTasks[taskId].tStarterSelection), 0); + FillWindowPixelBuffer(0, 0x11); + PrintTextOnWindow(0, 1, gText_ConfirmStarterChoice, 0, 1, 0, NULL); + schedule_bg_copy_tilemap_to_vram(0); + CreateYesNoMenu(&gUnknown_085B1DDC, 0x2A8, 0xD, 0); + gTasks[taskId].func = Task_StarterChoose5; +} + +static void Task_StarterChoose5(u8 taskId) +{ + u8 spriteId; + + switch (sub_8198C58()) + { + case 0: // YES + // Return the starter choice and exit. + gScriptResult = gTasks[taskId].tStarterSelection; + dp13_810BB8C(); + SetMainCallback2(gMain.savedCallback); + break; + case 1: // NO + case -1: // B button + PlaySE(SE_SELECT); + spriteId = gTasks[taskId].tPkmnSpriteId; + FreeOamMatrix(gSprites[spriteId].oam.matrixNum); + sub_818D820(spriteId); + + spriteId = gTasks[taskId].tCircleSpriteId; + FreeOamMatrix(gSprites[spriteId].oam.matrixNum); + DestroySprite(&gSprites[spriteId]); + gTasks[taskId].func = Task_StarterChoose6; + break; + } +} + +static void Task_StarterChoose6(u8 taskId) +{ + gTasks[taskId].func = Task_StarterChoose1; +} + +static void CreateStarterPokemonLabel(u8 selection) +{ + u8 text[32]; + struct WindowTemplate winTemplate; + const u8 *speciesName; + s32 width; + u8 labelLeft, labelRight, labelTop, labelBottom; + + u16 species = GetStarterPokemon(selection); + CopyMonCategoryText(SpeciesToNationalPokedexNum(species), text); + speciesName = gSpeciesNames[species]; + + winTemplate = gUnknown_085B1DE4; + winTemplate.tilemapLeft = gStarterChoose_LabelCoords[selection][0]; + winTemplate.tilemapTop = gStarterChoose_LabelCoords[selection][1]; + + sStarterChooseWindowId = AddWindow(&winTemplate); + FillWindowPixelBuffer(sStarterChooseWindowId, 0); + + width = GetStringCenterAlignXOffset(7, text, 0x68); + box_print(sStarterChooseWindowId, 7, width, 1, gUnknown_085B1E0C, 0, text); + + width = GetStringCenterAlignXOffset(1, speciesName, 0x68); + box_print(sStarterChooseWindowId, 1, width, 0x11, gUnknown_085B1E0C, 0, speciesName); + + PutWindowTilemap(sStarterChooseWindowId); + schedule_bg_copy_tilemap_to_vram(0); + + labelLeft = gStarterChoose_LabelCoords[selection][0] * 8 - 4; + labelRight = (gStarterChoose_LabelCoords[selection][0] + 13) * 8 + 4; + labelTop = gStarterChoose_LabelCoords[selection][1] * 8; + labelBottom = (gStarterChoose_LabelCoords[selection][1] + 4) * 8; + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(labelLeft, labelRight)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(labelTop, labelBottom)); +} + +static void sub_8134604(void) +{ + FillWindowPixelBuffer(sStarterChooseWindowId, 0); + ClearWindowTilemap(sStarterChooseWindowId); + RemoveWindow(sStarterChooseWindowId); + sStarterChooseWindowId = 0xFF; + SetGpuReg(REG_OFFSET_WIN0H, 0); + SetGpuReg(REG_OFFSET_WIN0V, 0); + schedule_bg_copy_tilemap_to_vram(0); +} + +static void Task_MoveStarterChooseCursor(u8 taskId) +{ + sub_8134604(); + gTasks[taskId].func = sub_8134668; +} + +static void sub_8134668(u8 taskId) +{ + CreateStarterPokemonLabel(gTasks[taskId].tStarterSelection); + gTasks[taskId].func = Task_StarterChoose2; +} + +static u8 CreatePokemonFrontSprite(u16 species, u8 x, u8 y) +{ + u8 spriteId; + + spriteId = sub_818D3E4(species, 8, 0, 1, x, y, 0xE, 0xFFFF); + gSprites[spriteId].oam.priority = 0; + return spriteId; +} + +static void sub_81346DC(struct Sprite *sprite) +{ + sprite->pos1.x = gUnknown_085B1E28[gTasks[sprite->data0].tStarterSelection][0]; + sprite->pos1.y = gUnknown_085B1E28[gTasks[sprite->data0].tStarterSelection][1]; + sprite->pos2.y = Sin(sprite->data1, 8); + sprite->data1 = (u8)(sprite->data1) + 4; +} + +static void sub_813473C(struct Sprite *sprite) +{ + if (gTasks[sprite->data0].tStarterSelection == sprite->data1) + StartSpriteAnimIfDifferent(sprite, 1); + else + StartSpriteAnimIfDifferent(sprite, 0); +} + +static void StarterPokemonSpriteCallback(struct Sprite *sprite) +{ + //Move sprite to upper center of screen + if (sprite->pos1.x > STARTER_PKMN_POS_X) + sprite->pos1.x -= 4; + if (sprite->pos1.x < STARTER_PKMN_POS_X) + sprite->pos1.x += 4; + if (sprite->pos1.y > STARTER_PKMN_POS_Y) + sprite->pos1.y -= 2; + if (sprite->pos1.y < STARTER_PKMN_POS_Y) + sprite->pos1.y += 2; +} diff --git a/src/text_window.c b/src/text_window.c index 55aedf688c..336536c046 100644 --- a/src/text_window.c +++ b/src/text_window.c @@ -23,7 +23,7 @@ const struct TilesPal* sub_8098758(u8 id) void copy_textbox_border_tile_patterns_to_vram(u8 windowId, u16 destOffset, u8 palOffset) { LoadBgTiles(GetWindowAttribute(windowId, WINDOW_PRIORITY), gUnknown_08DDD748, 0x1C0, destOffset); - LoadPalette(sub_8098C64(), palOffset, 0x20); + LoadPalette(GetOverworldTextboxPalettePtr(), palOffset, 0x20); } void box_border_load_tiles_and_pal(u8 windowId, u16 destOffset, u8 palOffset) @@ -113,7 +113,7 @@ const u16* stdpal_get(u8 id) return &gUnknown_0851017C[id]; } -const u16* sub_8098C64(void) +const u16* GetOverworldTextboxPalettePtr(void) { return gUnknown_08DDD728; } diff --git a/sym_bss.txt b/sym_bss.txt index db7495182e..bb9e213597 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -55,7 +55,7 @@ gUnknown_030011F6: @ 30011F6 gUnknown_030011F7: @ 30011F7 .space 0x1 -gUnknown_030011F8: @ 30011F8 +sStarterChooseWindowId: @ 30011F8 .space 0x4 gUnknown_030011FC: @ 30011FC