From 1b303aeee87095400aae7c0d1ff9f94e83594691 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Wed, 7 Feb 2018 14:11:08 -0500 Subject: [PATCH 01/11] decompiled up to task_new_game_prof_birch_speech_3 --- asm/main_menu.s | 2095 ----------------------------------------------- ld_script.txt | 1 + src/main_menu.c | 880 ++++++++++++++++++++ 3 files changed, 881 insertions(+), 2095 deletions(-) diff --git a/asm/main_menu.s b/asm/main_menu.s index 08e0c3103f..1aaef86976 100644 --- a/asm/main_menu.s +++ b/asm/main_menu.s @@ -5,2101 +5,6 @@ .text - thumb_func_start CB2_MainMenu -@ void CB2_MainMenu() -CB2_MainMenu: @ 802F6B0 - push {lr} - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end CB2_MainMenu - - thumb_func_start VBlankCB_MainMenu -@ void VBlankCB_MainMenu() -VBlankCB_MainMenu: @ 802F6C8 - push {lr} - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - pop {r0} - bx r0 - thumb_func_end VBlankCB_MainMenu - - thumb_func_start CB2_InitMainMenu -@ void CB2_InitMainMenu() -CB2_InitMainMenu: @ 802F6DC - push {lr} - movs r0, 0 - bl InitMainMenu - pop {r0} - bx r0 - thumb_func_end CB2_InitMainMenu - - thumb_func_start CB2_ReinitMainMenu -@ void CB2_ReinitMainMenu() -CB2_ReinitMainMenu: @ 802F6E8 - push {lr} - movs r0, 0x1 - bl InitMainMenu - pop {r0} - bx r0 - thumb_func_end CB2_ReinitMainMenu - - thumb_func_start InitMainMenu -@ void InitMainMenu(bool8 affects_palette_maybe) -InitMainMenu: @ 802F6F4 - push {r4,r5,lr} - sub sp, 0xC - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0 - bl SetVBlankCallback - movs r0, 0 - 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, 0x18 - movs r1, 0 - bl SetGpuReg - movs r0, 0x1A - movs r1, 0 - bl SetGpuReg - movs r0, 0x14 - movs r1, 0 - bl SetGpuReg - movs r0, 0x16 - movs r1, 0 - bl SetGpuReg - movs r0, 0x10 - movs r1, 0 - bl SetGpuReg - movs r0, 0x12 - movs r1, 0 - bl SetGpuReg - add r1, sp, 0x4 - movs r0, 0 - strh r0, [r1] - ldr r1, =0x040000d4 - add r0, sp, 0x4 - str r0, [r1] - movs r0, 0xC0 - lsls r0, 19 - str r0, [r1, 0x4] - ldr r0, =0x8100c000 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - movs r5, 0 - str r5, [sp, 0x8] - add r0, sp, 0x8 - str r0, [r1] - movs r0, 0xE0 - lsls r0, 19 - str r0, [r1, 0x4] - ldr r0, =0x85000100 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - add r0, sp, 0x4 - strh r5, [r0] - str r0, [r1] - ldr r0, =0x05000002 - str r0, [r1, 0x4] - ldr r0, =0x810001ff - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - bl ResetPaletteFade - ldr r0, =gMainMenuBgPal - movs r1, 0 - movs r2, 0x20 - bl LoadPalette - ldr r0, =gMainMenuTextPal - movs r1, 0xF0 - movs r2, 0x20 - bl LoadPalette - bl ScanlineEffect_Stop - bl ResetTasks - bl ResetSpriteData - bl FreeAllSpritePalettes - cmp r4, 0 - beq _0802F7EC - movs r0, 0x1 - negs r0, r0 - str r5, [sp] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - b _0802F7FE - .pool -_0802F7EC: - movs r0, 0x1 - negs r0, r0 - ldr r1, =0x0000ffff - str r1, [sp] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade -_0802F7FE: - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_082FF0E8 - movs r0, 0 - movs r2, 0x2 - bl InitBgsFromTemplates - 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 - ldr r0, =gUnknown_082FF038 - bl InitWindows - bl DeactivateAllTextPrinters - ldr r1, =0x000001d5 - movs r0, 0 - bl LoadMainMenuWindowFrameTiles - movs r0, 0x40 - movs r1, 0 - bl SetGpuReg - movs r0, 0x44 - movs r1, 0 - bl SetGpuReg - movs r0, 0x48 - movs r1, 0 - bl SetGpuReg - movs r0, 0x4A - movs r1, 0 - bl SetGpuReg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - movs r0, 0x1 - bl EnableInterrupts - ldr r0, =VBlankCB_MainMenu - bl SetVBlankCallback - ldr r0, =CB2_MainMenu - bl SetMainCallback2 - movs r1, 0xC1 - lsls r1, 6 - movs r0, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl HideBg - ldr r0, =Task_MainMenuCheckSaveFile - movs r1, 0 - bl CreateTask - movs r0, 0 - add sp, 0xC - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end InitMainMenu - - thumb_func_start Task_MainMenuCheckSaveFile -@ void Task_MainMenuCheckSaveFile(u8 taskId) -Task_MainMenuCheckSaveFile: @ 802F8D8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r6, r0, 24 - lsls r0, r6, 2 - adds r0, r6 - lsls r7, r0, 3 - ldr r0, =gTasks + 0x8 - mov r8, r0 - adds r4, r7, r0 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - beq _0802F900 - b _0802FA4E -_0802F900: - movs r0, 0x40 - movs r1, 0 - bl SetGpuReg - movs r0, 0x44 - movs r1, 0 - bl SetGpuReg - movs r0, 0x48 - movs r1, 0x11 - bl SetGpuReg - movs r0, 0x4A - movs r1, 0x31 - bl SetGpuReg - movs r0, 0x50 - movs r1, 0xC1 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0x7 - bl SetGpuReg - bl sub_80093CC - lsls r0, 24 - cmp r0, 0 - beq _0802F946 - movs r0, 0x1 - strh r0, [r4, 0x1E] -_0802F946: - ldr r0, =gSaveFileStatus - ldrh r0, [r0] - cmp r0, 0x2 - beq _0802F990 - cmp r0, 0x2 - bgt _0802F968 - cmp r0, 0 - beq _0802F9D0 - cmp r0, 0x1 - beq _0802F972 - b _0802F9D0 - .pool -_0802F968: - cmp r0, 0x4 - beq _0802F9EC - cmp r0, 0xFF - beq _0802F9A4 - b _0802F9D0 -_0802F972: - strh r0, [r4] - bl IsMysteryGiftEnabled - cmp r0, 0 - beq _0802F982 - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] -_0802F982: - mov r0, r8 - subs r0, 0x8 - adds r0, r7, r0 - ldr r1, =Task_MainMenuCheckBattery - b _0802F9FC - .pool -_0802F990: - ldr r0, =gText_SaveFileErased - bl CreateMainMenuErrorWindow - strh r5, [r4] - mov r0, r8 - subs r0, 0x8 - adds r0, r7, r0 - b _0802F9FA - .pool -_0802F9A4: - ldr r0, =gText_SaveFileCorrupted - bl CreateMainMenuErrorWindow - mov r0, r8 - subs r0, 0x8 - adds r0, r7, r0 - ldr r1, =Task_WaitForSaveFileErrorWindow - str r1, [r0] - movs r0, 0x1 - strh r0, [r4] - bl IsMysteryGiftEnabled - cmp r0, 0x1 - bne _0802F9FE - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - b _0802F9FE - .pool -_0802F9D0: - movs r0, 0 - strh r0, [r4] - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r0, r1 - ldr r1, =Task_MainMenuCheckBattery - b _0802F9FC - .pool -_0802F9EC: - ldr r0, =gJPText_No1MSubCircuit - bl CreateMainMenuErrorWindow - mov r0, r8 - subs r0, 0x8 - adds r0, r7, r0 - strh r5, [r0, 0x8] -_0802F9FA: - ldr r1, =Task_WaitForSaveFileErrorWindow -_0802F9FC: - str r1, [r0] -_0802F9FE: - ldr r2, =gUnknown_02022D06 - ldrh r1, [r2] - movs r0, 0x80 - lsls r0, 8 - ands r0, r1 - cmp r0, 0 - beq _0802FA3E - movs r1, 0 - ldrsh r0, [r4, r1] - cmp r0, 0x2 - beq _0802FA36 - cmp r0, 0x2 - ble _0802FA2C - cmp r0, 0x3 - beq _0802FA3A - b _0802FA3E - .pool -_0802FA2C: - cmp r0, 0 - blt _0802FA3E - ldrh r0, [r4] - adds r0, 0x1 - b _0802FA3C -_0802FA36: - movs r0, 0x3 - b _0802FA3C -_0802FA3A: - movs r0, 0x4 -_0802FA3C: - strh r0, [r2] -_0802FA3E: - ldrh r1, [r2] - ldr r0, =0x00007fff - ands r0, r1 - strh r0, [r2] - strh r0, [r4, 0x2] - ldrh r0, [r4] - adds r0, 0x2 - strh r0, [r4, 0x18] -_0802FA4E: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end Task_MainMenuCheckSaveFile - - thumb_func_start Task_WaitForSaveFileErrorWindow -@ void Task_WaitForSaveFileErrorWindow(u8 taskId) -Task_WaitForSaveFileErrorWindow: @ 802FA5C - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl RunTextPrinters - movs r0, 0x7 - bl IsTextPrinterActive - lsls r0, 16 - cmp r0, 0 - bne _0802FA98 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0802FA98 - movs r0, 0x7 - bl ClearWindowTilemap - ldr r0, =gUnknown_082FF070 - bl sub_8032250 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =Task_MainMenuCheckBattery - str r1, [r0] -_0802FA98: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end Task_WaitForSaveFileErrorWindow - - thumb_func_start Task_MainMenuCheckBattery -@ void Task_MainMenuCheckBattery(u8 taskId) -Task_MainMenuCheckBattery: @ 802FAB0 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r5, r4, 0 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0802FB3C - movs r0, 0x40 - movs r1, 0 - bl SetGpuReg - movs r0, 0x44 - movs r1, 0 - bl SetGpuReg - movs r0, 0x48 - movs r1, 0x11 - bl SetGpuReg - movs r0, 0x4A - movs r1, 0x31 - bl SetGpuReg - movs r0, 0x50 - movs r1, 0xC1 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0x7 - bl SetGpuReg - bl RtcGetErrorStatus - movs r1, 0xFF - lsls r1, 4 - ands r1, r0 - cmp r1, 0 - bne _0802FB28 - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =Task_DisplayMainMenu - str r0, [r1] - b _0802FB3C - .pool -_0802FB28: - ldr r0, =gText_BatteryRunDry - bl CreateMainMenuErrorWindow - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - ldr r1, =Task_WaitForBatteryDryErrorWindow - str r1, [r0] -_0802FB3C: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end Task_MainMenuCheckBattery - - thumb_func_start Task_WaitForBatteryDryErrorWindow -@ void Task_WaitForBatteryDryErrorWindow(u8 taskId) -Task_WaitForBatteryDryErrorWindow: @ 802FB50 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl RunTextPrinters - movs r0, 0x7 - bl IsTextPrinterActive - lsls r0, 16 - cmp r0, 0 - bne _0802FB8C - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0802FB8C - movs r0, 0x7 - bl ClearWindowTilemap - ldr r0, =gUnknown_082FF070 - bl sub_8032250 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =Task_DisplayMainMenu - str r1, [r0] -_0802FB8C: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end Task_WaitForBatteryDryErrorWindow - - thumb_func_start Task_DisplayMainMenu -@ void Task_DisplayMainMenu(u8 taskId) -Task_DisplayMainMenu: @ 802FBA4 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x10 - lsls r0, 24 - lsrs r7, r0, 24 - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r6, r0, r1 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - beq _0802FBCE - b _0803006C -_0802FBCE: - movs r0, 0x40 - movs r1, 0 - bl SetGpuReg - movs r0, 0x44 - movs r1, 0 - bl SetGpuReg - movs r0, 0x48 - movs r1, 0x11 - bl SetGpuReg - movs r0, 0x4A - movs r1, 0x31 - bl SetGpuReg - movs r0, 0x50 - movs r1, 0xC1 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0x7 - bl SetGpuReg - add r0, sp, 0xC - strh r4, [r0] - movs r1, 0xFE - movs r2, 0x2 - bl LoadPalette - add r1, sp, 0xC - ldr r2, =0x00007fff - adds r0, r2, 0 - strh r0, [r1] - adds r0, r1, 0 - movs r1, 0xFA - movs r2, 0x2 - bl LoadPalette - add r1, sp, 0xC - ldr r2, =0x0000318c - adds r0, r2, 0 - strh r0, [r1] - adds r0, r1, 0 - movs r1, 0xFB - movs r2, 0x2 - bl LoadPalette - add r1, sp, 0xC - ldr r2, =0x0000675a - adds r0, r2, 0 - strh r0, [r1] - adds r0, r1, 0 - movs r1, 0xFC - movs r2, 0x2 - bl LoadPalette - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldrb r0, [r0, 0x8] - cmp r0, 0 - bne _0802FC84 - add r1, sp, 0xC - ldr r2, =0x00007e04 - adds r0, r2, 0 - strh r0, [r1] - adds r0, r1, 0 - movs r1, 0xF1 - movs r2, 0x2 - bl LoadPalette - b _0802FC96 - .pool -_0802FC84: - add r1, sp, 0xC - ldr r2, =0x0000547f - adds r0, r2, 0 - strh r0, [r1] - adds r0, r1, 0 - movs r1, 0xF1 - movs r2, 0x2 - bl LoadPalette -_0802FC96: - ldr r0, =gTasks - mov r8, r0 - lsls r1, r7, 2 - adds r0, r1, r7 - lsls r0, 3 - add r0, r8 - movs r2, 0x8 - ldrsh r0, [r0, r2] - mov r9, r1 - cmp r0, 0x1 - beq _0802FD44 - cmp r0, 0x1 - ble _0802FCBC - cmp r0, 0x2 - bne _0802FCB6 - b _0802FE00 -_0802FCB6: - cmp r0, 0x3 - bne _0802FCBC - b _0802FEFC -_0802FCBC: - movs r0, 0 - movs r1, 0xAA - bl FillWindowPixelBuffer - movs r0, 0x1 - movs r1, 0xAA - bl FillWindowPixelBuffer - ldr r5, =gUnknown_082FF0E0 - str r5, [sp] - movs r4, 0x1 - negs r4, r4 - str r4, [sp, 0x4] - ldr r0, =gText_MainMenuNewGame - str r0, [sp, 0x8] - movs r0, 0 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x1 - bl box_print - str r5, [sp] - str r4, [sp, 0x4] - ldr r0, =gText_MainMenuOption - str r0, [sp, 0x8] - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x1 - bl box_print - movs r0, 0 - bl PutWindowTilemap - movs r0, 0x1 - bl PutWindowTilemap - movs r0, 0 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x1 - movs r1, 0x2 - bl CopyWindowToVram - ldr r4, =gUnknown_082FF038 - ldr r5, =0x000001d5 - adds r0, r4, 0 - adds r1, r5, 0 - bl DrawMainMenuWindowBorder - adds r4, 0x8 - b _0802FED4 - .pool -_0802FD44: - movs r0, 0x2 - movs r1, 0xAA - bl FillWindowPixelBuffer - movs r0, 0x3 - movs r1, 0xAA - bl FillWindowPixelBuffer - movs r0, 0x4 - movs r1, 0xAA - bl FillWindowPixelBuffer - ldr r5, =gUnknown_082FF0E0 - str r5, [sp] - movs r4, 0x1 - negs r4, r4 - str r4, [sp, 0x4] - ldr r0, =gText_MainMenuContinue - str r0, [sp, 0x8] - movs r0, 0x2 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x1 - bl box_print - str r5, [sp] - str r4, [sp, 0x4] - ldr r0, =gText_MainMenuNewGame - str r0, [sp, 0x8] - movs r0, 0x3 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x1 - bl box_print - str r5, [sp] - str r4, [sp, 0x4] - ldr r0, =gText_MainMenuOption - str r0, [sp, 0x8] - movs r0, 0x4 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x1 - bl box_print - bl fmt_savegame - movs r0, 0x2 - bl PutWindowTilemap - movs r0, 0x3 - bl PutWindowTilemap - movs r0, 0x4 - bl PutWindowTilemap - movs r0, 0x2 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x3 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x4 - movs r1, 0x2 - bl CopyWindowToVram - ldr r4, =gUnknown_082FF048 - ldr r5, =0x000001d5 - adds r0, r4, 0 - adds r1, r5, 0 - bl DrawMainMenuWindowBorder - adds r0, r4, 0 - adds r0, 0x8 - adds r1, r5, 0 - bl DrawMainMenuWindowBorder - adds r4, 0x10 - b _0802FED4 - .pool -_0802FE00: - movs r0, 0x2 - movs r1, 0xAA - bl FillWindowPixelBuffer - movs r0, 0x3 - movs r1, 0xAA - bl FillWindowPixelBuffer - movs r0, 0x4 - movs r1, 0xAA - bl FillWindowPixelBuffer - movs r0, 0x5 - movs r1, 0xAA - bl FillWindowPixelBuffer - ldr r5, =gUnknown_082FF0E0 - str r5, [sp] - movs r4, 0x1 - negs r4, r4 - str r4, [sp, 0x4] - ldr r0, =gText_MainMenuContinue - str r0, [sp, 0x8] - movs r0, 0x2 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x1 - bl box_print - str r5, [sp] - str r4, [sp, 0x4] - ldr r0, =gText_MainMenuNewGame - str r0, [sp, 0x8] - movs r0, 0x3 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x1 - bl box_print - str r5, [sp] - str r4, [sp, 0x4] - ldr r0, =gText_MainMenuMysteryGift - str r0, [sp, 0x8] - movs r0, 0x4 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x1 - bl box_print - str r5, [sp] - str r4, [sp, 0x4] - ldr r0, =gText_MainMenuOption - str r0, [sp, 0x8] - movs r0, 0x5 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x1 - bl box_print - bl fmt_savegame - movs r0, 0x2 - bl PutWindowTilemap - movs r0, 0x3 - bl PutWindowTilemap - movs r0, 0x4 - bl PutWindowTilemap - movs r0, 0x5 - bl PutWindowTilemap - movs r0, 0x2 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x3 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x4 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x5 - movs r1, 0x2 - bl CopyWindowToVram - ldr r4, =gUnknown_082FF048 - ldr r5, =0x000001d5 - adds r0, r4, 0 - adds r1, r5, 0 - bl DrawMainMenuWindowBorder - adds r0, r4, 0 - adds r0, 0x8 - adds r1, r5, 0 - bl DrawMainMenuWindowBorder - adds r0, r4, 0 - adds r0, 0x10 - adds r1, r5, 0 - bl DrawMainMenuWindowBorder - adds r4, 0x18 -_0802FED4: - adds r0, r4, 0 - adds r1, r5, 0 - bl DrawMainMenuWindowBorder - b _0803005E - .pool -_0802FEFC: - movs r0, 0x2 - movs r1, 0xAA - bl FillWindowPixelBuffer - movs r0, 0x3 - movs r1, 0xAA - bl FillWindowPixelBuffer - movs r0, 0x4 - movs r1, 0xAA - bl FillWindowPixelBuffer - movs r0, 0x5 - movs r1, 0xAA - bl FillWindowPixelBuffer - movs r0, 0x6 - movs r1, 0xAA - bl FillWindowPixelBuffer - ldr r5, =gUnknown_082FF0E0 - str r5, [sp] - movs r4, 0x1 - negs r4, r4 - str r4, [sp, 0x4] - ldr r0, =gText_MainMenuContinue - str r0, [sp, 0x8] - movs r0, 0x2 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x1 - bl box_print - str r5, [sp] - str r4, [sp, 0x4] - ldr r0, =gText_MainMenuNewGame - str r0, [sp, 0x8] - movs r0, 0x3 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x1 - bl box_print - str r5, [sp] - str r4, [sp, 0x4] - ldr r0, =gText_MainMenuMysteryGift2 - str r0, [sp, 0x8] - movs r0, 0x4 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x1 - bl box_print - str r5, [sp] - str r4, [sp, 0x4] - ldr r0, =gText_MainMenuMysteryEvents - str r0, [sp, 0x8] - movs r0, 0x5 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x1 - bl box_print - str r5, [sp] - str r4, [sp, 0x4] - ldr r0, =gText_MainMenuOption - str r0, [sp, 0x8] - movs r0, 0x6 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x1 - bl box_print - bl fmt_savegame - movs r0, 0x2 - bl PutWindowTilemap - movs r0, 0x3 - bl PutWindowTilemap - movs r0, 0x4 - bl PutWindowTilemap - movs r0, 0x5 - bl PutWindowTilemap - movs r0, 0x6 - bl PutWindowTilemap - movs r0, 0x2 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x3 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x4 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x5 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0x6 - movs r1, 0x2 - bl CopyWindowToVram - ldr r5, =gUnknown_082FF048 - ldr r4, =0x000001d5 - adds r0, r5, 0 - adds r1, r4, 0 - bl DrawMainMenuWindowBorder - adds r0, r5, 0 - adds r0, 0x8 - adds r1, r4, 0 - bl DrawMainMenuWindowBorder - adds r0, r5, 0 - adds r0, 0x10 - adds r1, r4, 0 - bl DrawMainMenuWindowBorder - adds r0, r5, 0 - adds r0, 0x18 - adds r1, r4, 0 - bl DrawMainMenuWindowBorder - adds r0, r5, 0 - adds r0, 0x20 - adds r1, r4, 0 - bl DrawMainMenuWindowBorder - ldr r0, =gUnknown_082FF0F4 - ldr r4, =gUnknown_02022D06 - adds r1, r4, 0 - bl AddScrollIndicatorArrowPair - lsls r0, 24 - lsrs r0, 24 - strh r0, [r6, 0x1A] - movs r0, 0x1A - ldrsh r1, [r6, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - add r0, r8 - ldr r1, =Task_ScrollIndicatorArrowPairOnMainMenu - str r1, [r0] - ldrh r0, [r4] - cmp r0, 0x4 - bne _0803005E - movs r4, 0x80 - lsls r4, 6 - movs r0, 0 - adds r1, r4, 0 - movs r2, 0x1 - bl ChangeBgY - movs r0, 0x1 - adds r1, r4, 0 - movs r2, 0x1 - bl ChangeBgY - movs r0, 0x1 - strh r0, [r6, 0x1C] - movs r2, 0x1A - ldrsh r1, [r6, r2] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - add r0, r8 - movs r1, 0x1 - strh r1, [r0, 0x26] -_0803005E: - ldr r0, =gTasks - mov r2, r9 - adds r1, r2, r7 - lsls r1, 3 - adds r1, r0 - ldr r0, =Task_HighlightSelectedMainMenuItem - str r0, [r1] -_0803006C: - add sp, 0x10 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end Task_DisplayMainMenu - - thumb_func_start Task_HighlightSelectedMainMenuItem -@ void Task_HighlightSelectedMainMenuItem(u8 taskId) -Task_HighlightSelectedMainMenuItem: @ 80300B0 - 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] - ldrb r1, [r4, 0xA] - movs r3, 0x24 - ldrsh r2, [r4, r3] - bl HighlightSelectedMainMenuItem - ldr r0, =Task_HandleMainMenuInput - str r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end Task_HighlightSelectedMainMenuItem - - thumb_func_start HandleMainMenuInput -@ u8 HandleMainMenuInput(u8 taskId) -HandleMainMenuInput: @ 80300E0 - push {r4-r7,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r4, r1, 3 - ldr r7, =gTasks + 0x8 - adds r5, r4, r7 - ldr r1, =gMain - ldrh r2, [r1, 0x2E] - movs r0, 0x1 - ands r0, r2 - cmp r0, 0 - beq _08030130 - movs r0, 0x5 - bl PlaySE - bl sub_80093CC - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - adds r0, r7, 0 - subs r0, 0x8 - adds r0, r4, r0 - ldr r1, =Task_HandleMainMenuAPressed - str r1, [r0] - b _08030240 - .pool -_08030130: - movs r0, 0x2 - ands r0, r2 - lsls r0, 16 - lsrs r6, r0, 16 - cmp r6, 0 - beq _08030178 - movs r0, 0x5 - bl PlaySE - movs r0, 0x1 - negs r0, r0 - ldr r1, =0x0000ffff - str r1, [sp] - movs r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - movs r0, 0x40 - movs r1, 0xF0 - bl SetGpuReg - movs r0, 0x44 - movs r1, 0xA0 - bl SetGpuReg - adds r0, r7, 0 - subs r0, 0x8 - adds r0, r4, r0 - ldr r1, =Task_HandleMainMenuBPressed - str r1, [r0] - b _08030240 - .pool -_08030178: - movs r0, 0x40 - ands r0, r2 - cmp r0, 0 - beq _080301CA - movs r0, 0x2 - ldrsh r2, [r5, r0] - cmp r2, 0 - ble _080301CA - movs r1, 0 - ldrsh r0, [r5, r1] - cmp r0, 0x3 - bne _080301C4 - movs r1, 0x1C - ldrsh r0, [r5, r1] - cmp r0, 0x1 - bne _080301C4 - cmp r2, 0x1 - bne _080301C4 - movs r4, 0x80 - lsls r4, 6 - movs r0, 0 - adds r1, r4, 0 - movs r2, 0x2 - bl ChangeBgY - movs r0, 0x1 - adds r1, r4, 0 - movs r2, 0x2 - bl ChangeBgY - movs r2, 0x1A - ldrsh r1, [r5, r2] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r7, r0 - strh r6, [r5, 0x1C] - strh r6, [r0, 0x1E] -_080301C4: - ldrh r0, [r5, 0x2] - subs r0, 0x1 - b _0803022C -_080301CA: - ldrh r1, [r1, 0x2E] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _08030240 - movs r0, 0x2 - ldrsh r1, [r5, r0] - movs r2, 0x18 - ldrsh r0, [r5, r2] - subs r0, 0x1 - cmp r1, r0 - bge _08030240 - movs r1, 0 - ldrsh r0, [r5, r1] - cmp r0, 0x3 - bne _08030228 - movs r2, 0x2 - ldrsh r0, [r5, r2] - cmp r0, 0x3 - bne _08030228 - movs r1, 0x1C - ldrsh r0, [r5, r1] - cmp r0, 0 - bne _08030228 - movs r4, 0x80 - lsls r4, 6 - movs r0, 0 - adds r1, r4, 0 - movs r2, 0x1 - bl ChangeBgY - movs r0, 0x1 - adds r1, r4, 0 - movs r2, 0x1 - bl ChangeBgY - ldr r2, =gTasks - movs r0, 0x1A - ldrsh r1, [r5, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - movs r1, 0x1 - strh r1, [r5, 0x1C] - movs r1, 0x1 - strh r1, [r0, 0x26] -_08030228: - ldrh r0, [r5, 0x2] - adds r0, 0x1 -_0803022C: - strh r0, [r5, 0x2] - ldr r1, =gUnknown_02022D06 - strh r0, [r1] - movs r0, 0x1 - b _08030242 - .pool -_08030240: - movs r0, 0 -_08030242: - add sp, 0x4 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end HandleMainMenuInput - - thumb_func_start Task_HandleMainMenuInput -@ void Task_HandleMainMenuInput(u8 taskId) -Task_HandleMainMenuInput: @ 803024C - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl HandleMainMenuInput - lsls r0, 24 - cmp r0, 0 - beq _0803026C - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =Task_HighlightSelectedMainMenuItem - str r0, [r1] -_0803026C: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end Task_HandleMainMenuInput - - thumb_func_start Task_HandleMainMenuAPressed -@ void Task_HandleMainMenuAPressed(int task_id) -Task_HandleMainMenuAPressed: @ 803027C - push {r4-r7,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _08030292 - b _08030536 -_08030292: - ldr r2, =gTasks - lsls r1, r6, 2 - adds r0, r1, r6 - lsls r0, 3 - adds r4, r0, r2 - movs r2, 0x8 - ldrsh r0, [r4, r2] - adds r7, r1, 0 - cmp r0, 0x3 - bne _080302B0 - ldrh r0, [r4, 0x22] - lsls r0, 24 - lsrs r0, 24 - bl RemoveScrollIndicatorArrowPair -_080302B0: - movs r0, 0 - movs r1, 0x1 - bl sub_819746C - movs r0, 0x1 - movs r1, 0x1 - bl sub_819746C - movs r0, 0x2 - movs r1, 0x1 - bl sub_819746C - movs r0, 0x3 - movs r1, 0x1 - bl sub_819746C - movs r0, 0x4 - movs r1, 0x1 - bl sub_819746C - movs r0, 0x5 - movs r1, 0x1 - bl sub_819746C - movs r0, 0x6 - movs r1, 0x1 - bl sub_819746C - movs r0, 0x7 - movs r1, 0x1 - bl sub_819746C - bl sub_80093CC - lsls r0, 24 - lsrs r2, r0, 24 - movs r3, 0x8 - ldrsh r0, [r4, r3] - cmp r0, 0x1 - beq _08030324 - cmp r0, 0x1 - ble _0803030C - cmp r0, 0x2 - beq _08030336 - cmp r0, 0x3 - beq _08030358 -_0803030C: - movs r1, 0xA - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _08030388 - cmp r0, 0x1 - bne _08030388 - b _080303D8 - .pool -_08030324: - movs r2, 0xA - ldrsh r0, [r4, r2] - cmp r0, 0x1 - beq _08030388 - cmp r0, 0x1 - ble _08030384 - cmp r0, 0x2 - bne _08030384 - b _080303D8 -_08030336: - movs r3, 0xA - ldrsh r0, [r4, r3] - cmp r0, 0x1 - beq _08030388 - cmp r0, 0x1 - ble _08030384 - cmp r0, 0x2 - beq _0803034C - cmp r0, 0x3 - beq _080303D8 - b _08030384 -_0803034C: - movs r5, 0x3 - cmp r2, 0 - bne _080303DA - movs r5, 0x6 - strh r2, [r4, 0x8] - b _080303DA -_08030358: - movs r1, 0xA - ldrsh r0, [r4, r1] - cmp r0, 0x4 - bhi _08030384 - lsls r0, 2 - ldr r1, =_08030370 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08030370: - .4byte _08030384 - .4byte _08030388 - .4byte _0803038C - .4byte _080303BC - .4byte _080303D8 -_08030384: - movs r5, 0x1 - b _080303DA -_08030388: - movs r5, 0 - b _080303DA -_0803038C: - ldr r0, =gTasks - adds r1, r7, r6 - lsls r1, 3 - adds r1, r0 - movs r3, 0x26 - ldrsh r0, [r1, r3] - cmp r0, 0 - beq _080303AC - movs r5, 0x3 - cmp r2, 0 - bne _080303DA - movs r5, 0x6 - strh r2, [r1, 0x8] - b _080303DA - .pool -_080303AC: - cmp r2, 0 - beq _080303B8 - movs r5, 0x6 - movs r0, 0x1 - strh r0, [r1, 0x8] - b _080303DA -_080303B8: - movs r5, 0x5 - b _080303DA -_080303BC: - cmp r2, 0 - beq _080303D4 - movs r5, 0x6 - ldr r0, =gTasks - adds r1, r7, r6 - lsls r1, 3 - adds r1, r0 - movs r0, 0x2 - strh r0, [r1, 0x8] - b _080303DA - .pool -_080303D4: - movs r5, 0x4 - b _080303DA -_080303D8: - movs r5, 0x2 -_080303DA: - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - cmp r5, 0x6 - bhi _0803041C - lsls r0, r5, 2 - ldr r1, =_08030400 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08030400: - .4byte _0803041C - .4byte _08030444 - .4byte _08030460 - .4byte _08030478 - .4byte _08030480 - .4byte _08030488 - .4byte _0803049C -_0803041C: - ldr r0, =gPlttBufferUnfaded - movs r1, 0 - strh r1, [r0] - ldr r0, =gPlttBufferFaded - strh r1, [r0] - ldr r1, =gTasks - adds r0, r7, r6 - lsls r0, 3 - adds r0, r1 - ldr r1, =task_new_game_prof_birch_speech_1 - str r1, [r0] - b _08030514 - .pool -_08030444: - ldr r0, =gPlttBufferUnfaded - movs r1, 0 - strh r1, [r0] - ldr r0, =gPlttBufferFaded - strh r1, [r0] - ldr r0, =sub_8086230 - b _0803048A - .pool -_08030460: - ldr r0, =gMain - ldr r1, =CB2_ReinitMainMenu - str r1, [r0, 0x8] - ldr r0, =CB2_InitOptionMenu - b _0803048A - .pool -_08030478: - ldr r0, =c2_mystery_gift - b _0803048A - .pool -_08030480: - ldr r0, =CB2_InitMysteryEventMenu - b _0803048A - .pool -_08030488: - ldr r0, =sub_801867C -_0803048A: - bl SetMainCallback2 - adds r0, r6, 0 - bl DestroyTask - b _08030514 - .pool -_0803049C: - ldr r1, =gTasks - adds r0, r7, r6 - lsls r0, 3 - adds r0, r1 - movs r4, 0 - strh r4, [r0, 0xA] - ldr r1, =Task_DisplayMainMenuInvalidActionError - str r1, [r0] - ldr r0, =gPlttBufferUnfaded - movs r2, 0xF1 - lsls r2, 1 - adds r0, r2 - ldr r1, =0x00007fff - strh r1, [r0] - ldr r0, =gPlttBufferFaded - adds r0, r2 - strh r1, [r0] - movs r0, 0x18 - movs r1, 0 - bl SetGpuReg - movs r0, 0x1A - movs r1, 0 - bl SetGpuReg - movs r0, 0x14 - movs r1, 0 - bl SetGpuReg - movs r0, 0x16 - movs r1, 0 - bl SetGpuReg - movs r0, 0x10 - movs r1, 0 - bl SetGpuReg - movs r0, 0x12 - movs r1, 0 - bl SetGpuReg - movs r0, 0x1 - negs r0, r0 - str r4, [sp] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - b _08030536 - .pool -_08030514: - bl FreeAllWindowBuffers - cmp r5, 0x2 - beq _08030528 - ldr r1, =gUnknown_02022D06 - movs r0, 0 - strh r0, [r1] - b _08030536 - .pool -_08030528: - ldr r0, =gUnknown_02022D06 - ldrh r1, [r0] - movs r3, 0x80 - lsls r3, 8 - adds r2, r3, 0 - orrs r1, r2 - strh r1, [r0] -_08030536: - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end Task_HandleMainMenuAPressed - - thumb_func_start Task_HandleMainMenuBPressed -@ void Task_HandleMainMenuBPressed(u8 taskId) -Task_HandleMainMenuBPressed: @ 8030544 - push {r4,r5,lr} - lsls r0, 24 - lsrs r2, r0, 24 - adds r5, r2, 0 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - bne _0803058C - ldr r0, =gTasks - lsls r1, r2, 2 - adds r1, r2 - lsls r1, 3 - adds r1, r0 - movs r2, 0x8 - ldrsh r0, [r1, r2] - cmp r0, 0x3 - bne _08030578 - ldrh r0, [r1, 0x22] - lsls r0, 24 - lsrs r0, 24 - bl RemoveScrollIndicatorArrowPair -_08030578: - ldr r0, =gUnknown_02022D06 - strh r4, [r0] - bl FreeAllWindowBuffers - ldr r0, =c2_title_screen_1 - bl SetMainCallback2 - adds r0, r5, 0 - bl DestroyTask -_0803058C: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end Task_HandleMainMenuBPressed - - thumb_func_start Task_DisplayMainMenuInvalidActionError -@ void Task_DisplayMainMenuInvalidActionError(u8 taskId) -Task_DisplayMainMenuInvalidActionError: @ 80305A4 - push {r4,r5,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r1 - movs r0, 0xA - ldrsh r1, [r4, r0] - cmp r1, 0x1 - beq _0803063C - cmp r1, 0x1 - bgt _080305CC - cmp r1, 0 - beq _080305D6 - b _08030688 - .pool -_080305CC: - cmp r1, 0x2 - beq _0803064C - cmp r1, 0x3 - beq _08030664 - b _08030688 -_080305D6: - movs r0, 0x1E - str r0, [sp] - movs r0, 0x14 - str r0, [sp, 0x4] - movs r0, 0 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl FillBgTilemapBufferRect_Palette0 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _08030610 - cmp r0, 0x1 - bgt _080305FC - cmp r0, 0 - beq _08030602 - b _08030622 -_080305FC: - cmp r0, 0x2 - beq _0803061C - b _08030622 -_08030602: - ldr r0, =gText_WirelessNotConnected - bl CreateMainMenuErrorWindow - b _08030622 - .pool -_08030610: - ldr r0, =gText_MysteryGiftCantUse - bl CreateMainMenuErrorWindow - b _08030622 - .pool -_0803061C: - ldr r0, =gText_MysteryEventsCantUse - bl CreateMainMenuErrorWindow -_08030622: - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0xA] - adds r0, 0x1 - strh r0, [r1, 0xA] - b _08030688 - .pool -_0803063C: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - b _08030658 - .pool -_0803064C: - bl RunTextPrinters - movs r0, 0x7 - bl IsTextPrinterActive - lsls r0, 16 -_08030658: - cmp r0, 0 - bne _08030688 - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] - b _08030688 -_08030664: - ldr r0, =gMain - ldrh r0, [r0, 0x2E] - ands r1, r0 - cmp r1, 0 - beq _08030688 - movs r0, 0x5 - bl PlaySE - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r0, =Task_HandleMainMenuBPressed - str r0, [r4] -_08030688: - add sp, 0x8 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end Task_DisplayMainMenuInvalidActionError - - thumb_func_start HighlightSelectedMainMenuItem -@ void HighlightSelectedMainMenuItem(u8 a1, u8 selectedMenuItem, u16 a3) -HighlightSelectedMainMenuItem: @ 8030698 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r1, 24 - lsrs r4, r1, 24 - lsls r2, 16 - lsrs r6, r2, 16 - ldr r1, =0x000009e7 - movs r0, 0x40 - bl SetGpuReg - cmp r5, 0x1 - beq _080306DC - cmp r5, 0x1 - ble _080306BE - cmp r5, 0x2 - beq _08030700 - cmp r5, 0x3 - beq _08030728 -_080306BE: - cmp r4, 0 - beq _080306C6 - cmp r4, 0x1 - beq _080306D4 -_080306C6: - ldr r1, =0x0000011f - b _0803078E - .pool -_080306D4: - ldr r1, =0x0000213f - b _0803078E - .pool -_080306DC: - cmp r4, 0x1 - beq _080306F0 - cmp r4, 0x1 - ble _080306E8 - cmp r4, 0x2 - beq _080306F8 -_080306E8: - ldr r1, =0x0000013f - b _0803078E - .pool -_080306F0: - ldr r1, =0x0000415f - b _0803078E - .pool -_080306F8: - ldr r1, =0x0000617f - b _0803078E - .pool -_08030700: - cmp r4, 0x1 - beq _08030718 - cmp r4, 0x1 - ble _08030710 - cmp r4, 0x2 - beq _08030720 - cmp r4, 0x3 - beq _0803078C -_08030710: - ldr r1, =0x0000013f - b _0803078E - .pool -_08030718: - ldr r1, =0x0000415f - b _0803078E - .pool -_08030720: - ldr r1, =0x0000617f - b _0803078E - .pool -_08030728: - cmp r4, 0x4 - bhi _08030750 - lsls r0, r4, 2 - ldr r1, =_0803073C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0803073C: - .4byte _08030750 - .4byte _08030758 - .4byte _0803076C - .4byte _08030780 - .4byte _0803079C -_08030750: - ldr r1, =0x0000013f - b _0803078E - .pool -_08030758: - cmp r6, 0 - beq _08030764 - ldr r1, =0x0000213f - b _0803078E - .pool -_08030764: - ldr r1, =0x0000415f - b _0803078E - .pool -_0803076C: - cmp r6, 0 - beq _08030778 - ldr r1, =0x0000415f - b _0803078E - .pool -_08030778: - ldr r1, =0x0000617f - b _0803078E - .pool -_08030780: - cmp r6, 0 - beq _0803078C - ldr r1, =0x0000617f - b _0803078E - .pool -_0803078C: - ldr r1, =0x0000819f -_0803078E: - movs r0, 0x44 - bl SetGpuReg - b _080307A4 - .pool -_0803079C: - ldr r1, =0x0000819f - movs r0, 0x44 - bl SetGpuReg -_080307A4: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end HighlightSelectedMainMenuItem - - thumb_func_start task_new_game_prof_birch_speech_1 -@ void task_new_game_prof_birch_speech_1(int task_id) -task_new_game_prof_birch_speech_1: @ 80307B0 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0 - movs r1, 0 - bl SetGpuReg - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - ldr r0, =gUnknown_082FF0F0 - bl InitBgFromTemplate - movs r0, 0x40 - movs r1, 0 - bl SetGpuReg - movs r0, 0x44 - movs r1, 0 - bl SetGpuReg - movs r0, 0x48 - movs r1, 0 - bl SetGpuReg - movs r0, 0x4A - movs r1, 0 - bl SetGpuReg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - ldr r0, =gBirchIntroShadowGfx - movs r1, 0xC0 - lsls r1, 19 - bl LZ77UnCompVram - ldr r0, =gUnknown_082FEEF0 - ldr r1, =0x06003800 - bl LZ77UnCompVram - ldr r0, =gUnknown_082FECFC - movs r1, 0 - movs r2, 0x40 - bl LoadPalette - ldr r0, =gUnknown_082FF028 - movs r1, 0x1 - movs r2, 0x10 - bl LoadPalette - bl ScanlineEffect_Stop - bl ResetSpriteData - bl FreeAllSpritePalettes - bl dp13_810BB8C - adds r0, r4, 0 - bl AddBirchSpeechObjects - movs r0, 0x1 - negs r0, r0 - movs r5, 0 - str r5, [sp] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - strh r5, [r0, 0x10] - ldr r1, =task_new_game_prof_birch_speech_2 - str r1, [r0] - movs r1, 0xFF - strh r1, [r0, 0xC] - strh r1, [r0, 0xE] - movs r1, 0xD8 - strh r1, [r0, 0x16] - movs r0, 0xBB - lsls r0, 1 - bl PlayBGM - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_1 - - thumb_func_start task_new_game_prof_birch_speech_2 -task_new_game_prof_birch_speech_2: @ 80308B0 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r1 - ldrh r1, [r4, 0x16] - movs r2, 0x16 - ldrsh r0, [r4, r2] - cmp r0, 0 - beq _080308D4 - subs r0, r1, 0x1 - strh r0, [r4, 0x16] - b _0803091A - .pool -_080308D4: - ldrb r0, [r4, 0x18] - ldr r2, =gSprites - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - movs r0, 0x88 - strh r0, [r1, 0x20] - movs r0, 0x3C - strh r0, [r1, 0x22] - adds r3, r1, 0 - adds r3, 0x3E - ldrb r2, [r3] - subs r0, 0x41 - ands r0, r2 - strb r0, [r3] - ldrb r2, [r1, 0x1] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - movs r2, 0x4 - orrs r0, r2 - strb r0, [r1, 0x1] - adds r0, r5, 0 - movs r1, 0xA - bl sub_8031BAC - adds r0, r5, 0 - movs r1, 0x14 - bl sub_8031D34 - movs r0, 0x50 - strh r0, [r4, 0x16] - ldr r0, =task_new_game_prof_birch_speech_3 - str r0, [r4] -_0803091A: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_2 - - thumb_func_start task_new_game_prof_birch_speech_3 -@ int task_new_game_prof_birch_speech_3() -task_new_game_prof_birch_speech_3: @ 8030928 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r4, r1, r2 - movs r1, 0x12 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _080309B6 - ldr r2, =gSprites - movs r1, 0x18 - ldrsh r0, [r4, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r2, [r1, 0x1] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x1] - ldrh r1, [r4, 0x16] - movs r2, 0x16 - ldrsh r0, [r4, r2] - cmp r0, 0 - beq _08030970 - subs r0, r1, 0x1 - strh r0, [r4, 0x16] - b _080309B6 - .pool -_08030970: - ldr r0, =gUnknown_082FF080 - bl InitWindows - movs r0, 0 - movs r1, 0xF3 - bl LoadMainMenuWindowFrameTiles - movs r0, 0 - movs r1, 0xFC - movs r2, 0xF0 - bl copy_textbox_border_tile_patterns_to_vram - movs r0, 0 - movs r1, 0x1 - bl unknown_rbox_to_vram - movs r0, 0 - bl PutWindowTilemap - movs r0, 0 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0 - bl sub_8032318 - ldr r0, =gStringVar4 - ldr r1, =gUnknown_082C897B - bl StringExpandPlaceholders - movs r0, 0x1 - bl AddTextPrinterForMessage - ldr r0, =task_new_game_prof_birch_speech_4 - str r0, [r4] -_080309B6: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_3 - thumb_func_start task_new_game_prof_birch_speech_4 task_new_game_prof_birch_speech_4: @ 80309CC push {r4,lr} diff --git a/ld_script.txt b/ld_script.txt index 345afb27fc..19661fb56a 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -54,6 +54,7 @@ SECTIONS { src/string_util.o(.text); asm/link.o(.text); src/rtc.o(.text); + src/main_menu.o(.text); asm/main_menu.o(.text); src/battle_controllers.o(.text); src/decompress.o(.text); diff --git a/src/main_menu.c b/src/main_menu.c index 8608159c27..f5e210b580 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -1,11 +1,34 @@ // Includes #include "global.h" +#include "bg.h" +#include "constants/rgb.h" +#include "constants/songs.h" +#include "decompress.h" +#include "event_data.h" +#include "gpu_regs.h" +#include "main.h" +#include "menu.h" +#include "menu_indicators.h" +#include "new_menu_helpers.h" +#include "palette.h" +#include "rtc.h" +#include "save.h" +#include "scanline_effect.h" +#include "sound.h" +#include "sprite.h" +#include "string.h" +#include "string_util.h" +#include "task.h" +#include "text.h" +#include "text_window.h" +#include "window.h" // Static type declarations // Static RAM declarations + IWRAM_DATA u8 gUnknown_03000DD0; // Static ROM declarations @@ -13,3 +36,860 @@ IWRAM_DATA u8 gUnknown_03000DD0; // .rodata // .text + +enum +{ + HAS_NO_SAVED_GAME, //NEW GAME, OPTION + HAS_SAVED_GAME, //CONTINUE, NEW GAME, OPTION + HAS_MYSTERY_GIFT, //CONTINUE, NEW GAME, MYSTERY EVENTS, OPTION + HAS_MYSTERY_EVENTS, +}; + +struct ArrowStruct { + u8 unk0[6]; + u16 unk6[5]; +}; + +extern u16 gMainMenuBgPal[]; +extern u16 gMainMenuTextPal[]; +extern struct BgTemplate gUnknown_082FF0E8[]; +extern struct WindowTemplate gUnknown_082FF038[]; +extern u8 gText_SaveFileErased[]; +extern u8 gText_SaveFileCorrupted[]; +extern u8 gJPText_No1MSubCircuit[]; +extern u16 gUnknown_02022D06; +extern struct WindowTemplate gUnknown_082FF070[]; +extern u8 gText_BatteryRunDry[]; +extern struct TextColor gUnknown_082FF0E0; +extern u8 gText_MainMenuNewGame[]; +extern struct WindowTemplate gUnknown_082FF048[]; +extern struct ArrowStruct gUnknown_082FF0F4; +extern u8 gText_MainMenuOption[]; +extern u8 gText_MainMenuContinue[]; +extern u8 gText_MainMenuMysteryGift2[]; +extern u8 gText_MainMenuMysteryEvents[]; +extern u8 gText_MainMenuMysteryGift[]; +extern u8 gText_WirelessNotConnected[]; +extern u8 gText_MysteryGiftCantUse[]; +extern u8 gText_MysteryEventsCantUse[]; +extern struct BgTemplate gUnknown_082FF0F0; +extern u8 gBirchIntroShadowGfx[]; +extern u8 gUnknown_082FEEF0[]; +extern u16 gUnknown_082FECFC[]; +extern u16 gUnknown_082FF028[]; +extern struct WindowTemplate gUnknown_082FF080[]; +extern u8 gUnknown_082C897B[]; + +u32 InitMainMenu(bool8); +void Task_MainMenuCheckSaveFile(u8); +void Task_MainMenuCheckBattery(u8); +void Task_WaitForSaveFileErrorWindow(u8); +void CreateMainMenuErrorWindow(u8*); +void sub_8032250(struct WindowTemplate*); +void Task_DisplayMainMenu(u8); +void Task_WaitForBatteryDryErrorWindow(u8); +void fmt_savegame(void); +u8 AddScrollIndicatorArrowPair(struct ArrowStruct*, u16*); +void HighlightSelectedMainMenuItem(u8, u8, s16); +void Task_HandleMainMenuInput(u8); +void Task_HandleMainMenuAPressed(u8); +void Task_HandleMainMenuBPressed(u8); +void task_new_game_prof_birch_speech_1(u8); +void Task_DisplayMainMenuInvalidActionError(u8); +void AddBirchSpeechObjects(u8); +void task_new_game_prof_birch_speech_2(u8); +void sub_8031BAC(u8, u8); +void sub_8031D34(u8, u8); +void task_new_game_prof_birch_speech_3(u8); +void unknown_rbox_to_vram(u8, u8); +void sub_8032318(u8); +void task_new_game_prof_birch_speech_4(u8); + +extern void LoadMainMenuWindowFrameTiles(u8, u16); +extern bool8 sub_80093CC(void); +extern void Task_ScrollIndicatorArrowPairOnMainMenu(u8); +extern void Task_HighlightSelectedMainMenuItem(u8); +extern void DrawMainMenuWindowBorder(struct WindowTemplate*, u16); +extern void sub_819746C(u8, u8); +extern void sub_8086230(void); +extern void CB2_InitOptionMenu(void); +extern void c2_mystery_gift(void); +extern void CB2_InitMysteryEventMenu(void); +extern void sub_801867C(void); +extern void c2_title_screen_1(void); +extern void dp13_810BB8C(void); + +void CB2_MainMenu(void) +{ + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +void VBlankCB_MainMenu(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +void CB2_InitMainMenu(void) +{ + InitMainMenu(FALSE); +} + +void CB2_ReinitMainMenu(void) +{ + InitMainMenu(TRUE); +} + +u32 InitMainMenu(bool8 affects_palette_maybe) +{ + SetVBlankCallback(NULL); + + SetGpuReg(REG_OFFSET_DISPCNT, 0); + SetGpuReg(REG_OFFSET_BG2CNT, 0); + SetGpuReg(REG_OFFSET_BG1CNT, 0); + SetGpuReg(REG_OFFSET_BG0CNT, 0); + SetGpuReg(REG_OFFSET_BG2HOFS, 0); + SetGpuReg(REG_OFFSET_BG2VOFS, 0); + SetGpuReg(REG_OFFSET_BG1HOFS, 0); + SetGpuReg(REG_OFFSET_BG1VOFS, 0); + SetGpuReg(REG_OFFSET_BG0HOFS, 0); + SetGpuReg(REG_OFFSET_BG0VOFS, 0); + + DmaFill16(3, 0, (void *)VRAM, VRAM_SIZE); + DmaFill32(3, 0, (void *)OAM, OAM_SIZE); + DmaFill16(3, 0, (void *)(PLTT + 2), PLTT_SIZE - 2); + + ResetPaletteFade(); + LoadPalette(gMainMenuBgPal, 0, 32); + LoadPalette(gMainMenuTextPal, 0xF0, 32); + ScanlineEffect_Stop(); + ResetTasks(); + ResetSpriteData(); + FreeAllSpritePalettes(); + if (affects_palette_maybe) + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0x0000); // fade to black + else + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0xFFFF); // fade to white + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_082FF0E8, 2); + ChangeBgX(0, 0, 0); + ChangeBgY(0, 0, 0); + ChangeBgX(1, 0, 0); + ChangeBgY(1, 0, 0); + InitWindows(gUnknown_082FF038); + DeactivateAllTextPrinters(); + LoadMainMenuWindowFrameTiles(0, 0x1D5); + + SetGpuReg(REG_OFFSET_WIN0H, 0); + SetGpuReg(REG_OFFSET_WIN0V, 0); + SetGpuReg(REG_OFFSET_WININ, 0); + SetGpuReg(REG_OFFSET_WINOUT, 0); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + + EnableInterrupts(1); + SetVBlankCallback(VBlankCB_MainMenu); + SetMainCallback2(CB2_MainMenu); + SetGpuReg(REG_OFFSET_DISPCNT, 0x3040); + ShowBg(0); + HideBg(1); + CreateTask(Task_MainMenuCheckSaveFile, 0); + + return 0; +} + +void Task_MainMenuCheckSaveFile(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + if (!gPaletteFade.active) + { + SetGpuReg(REG_OFFSET_WIN0H, 0); + SetGpuReg(REG_OFFSET_WIN0V, 0); + SetGpuReg(REG_OFFSET_WININ, 17); + SetGpuReg(REG_OFFSET_WINOUT, 0x31); + SetGpuReg(REG_OFFSET_BLDCNT, 0xC1); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 7); + + if (sub_80093CC()) + data[15] = 1; + switch (gSaveFileStatus) + { + case 1: + data[0] = HAS_SAVED_GAME; + if (IsMysteryGiftEnabled()) + data[0]++; + gTasks[taskId].func = Task_MainMenuCheckBattery; + break; + case 2: + CreateMainMenuErrorWindow(gText_SaveFileErased); + data[0] = 0; + gTasks[taskId].func = Task_WaitForSaveFileErrorWindow; + break; + case 0xFF: + CreateMainMenuErrorWindow(gText_SaveFileCorrupted); + gTasks[taskId].func = Task_WaitForSaveFileErrorWindow; + data[0] = HAS_SAVED_GAME; + if (IsMysteryGiftEnabled() == TRUE) + data[0]++; + break; + case 0: + default: + data[0] = HAS_NO_SAVED_GAME; + gTasks[taskId].func = Task_MainMenuCheckBattery; + break; + case 4: + CreateMainMenuErrorWindow(gJPText_No1MSubCircuit); + gTasks[taskId].data[0] = HAS_NO_SAVED_GAME; + gTasks[taskId].func = Task_WaitForSaveFileErrorWindow; + break; + } + if (gUnknown_02022D06 & 0x8000) + { + switch (data[0]) + { + case HAS_NO_SAVED_GAME: + case HAS_SAVED_GAME: + gUnknown_02022D06 = data[0] + 1; + break; + case HAS_MYSTERY_GIFT: + gUnknown_02022D06 = 3; + break; + case 3: + gUnknown_02022D06 = 4; + break; + } + } + gUnknown_02022D06 &= 0x7FFF; + data[1] = gUnknown_02022D06; + data[12] = data[0] + 2; + } +} + +void Task_WaitForSaveFileErrorWindow(u8 taskId) +{ + RunTextPrinters(); + if (!IsTextPrinterActive(7) && (gMain.newKeys & A_BUTTON)) + { + ClearWindowTilemap(7); + sub_8032250(gUnknown_082FF070); + gTasks[taskId].func = Task_MainMenuCheckBattery; + } +} + +void Task_MainMenuCheckBattery(u8 taskId) +{ + if (!gPaletteFade.active) + { + SetGpuReg(REG_OFFSET_WIN0H, 0); + SetGpuReg(REG_OFFSET_WIN0V, 0); + SetGpuReg(REG_OFFSET_WININ, 17); + SetGpuReg(REG_OFFSET_WINOUT, 0x31); + SetGpuReg(REG_OFFSET_BLDCNT, 0xC1); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 7); + + if (!(RtcGetErrorStatus() & RTC_ERR_FLAG_MASK)) + gTasks[taskId].func = Task_DisplayMainMenu; + else + { + CreateMainMenuErrorWindow(gText_BatteryRunDry); + gTasks[taskId].func = Task_WaitForBatteryDryErrorWindow; + } + } +} + +void Task_WaitForBatteryDryErrorWindow(u8 taskId) +{ + RunTextPrinters(); + if (!IsTextPrinterActive(7) && (gMain.newKeys & A_BUTTON)) + { + ClearWindowTilemap(7); + sub_8032250(gUnknown_082FF070); + gTasks[taskId].func = Task_DisplayMainMenu; + } +} + +void Task_DisplayMainMenu(u8 taskId) +{ + s16* data = gTasks[taskId].data; + u16 palette; + + if (!gPaletteFade.active) + { + SetGpuReg(REG_OFFSET_WIN0H, 0); + SetGpuReg(REG_OFFSET_WIN0V, 0); + SetGpuReg(REG_OFFSET_WININ, 17); + SetGpuReg(REG_OFFSET_WINOUT, 0x31); + SetGpuReg(REG_OFFSET_BLDCNT, 0xC1); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 7); + + palette = RGB_BLACK; + LoadPalette(&palette, 254, 2); + + palette = RGB_WHITE; + LoadPalette(&palette, 250, 2); + + palette = RGB(12, 12, 12); + LoadPalette(&palette, 251, 2); + + palette = RGB(26, 26, 25); + LoadPalette(&palette, 252, 2); + + if (gSaveBlock2Ptr->playerGender == MALE) + { + palette = RGB(4, 16, 31); + LoadPalette(&palette, 241, 2); + } + else + { + palette = RGB(31, 3, 21); + LoadPalette(&palette, 241, 2); + } + + + + switch (gTasks[taskId].data[0]) + { + case HAS_NO_SAVED_GAME: + default: + FillWindowPixelBuffer(0, 0xAA); + FillWindowPixelBuffer(1, 0xAA); + box_print(0, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuNewGame); + box_print(1, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuOption); + PutWindowTilemap(0); + PutWindowTilemap(1); + CopyWindowToVram(0, 2); + CopyWindowToVram(1, 2); + DrawMainMenuWindowBorder(gUnknown_082FF038, 0x1D5); + DrawMainMenuWindowBorder(&gUnknown_082FF038[1], 0x1D5); + break; + case HAS_SAVED_GAME: + FillWindowPixelBuffer(2, 0xAA); + FillWindowPixelBuffer(3, 0xAA); + FillWindowPixelBuffer(4, 0xAA); + box_print(2, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuContinue); + box_print(3, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuNewGame); + box_print(4, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuOption); + fmt_savegame(); + PutWindowTilemap(2); + PutWindowTilemap(3); + PutWindowTilemap(4); + CopyWindowToVram(2, 2); + CopyWindowToVram(3, 2); + CopyWindowToVram(4, 2); + DrawMainMenuWindowBorder(gUnknown_082FF048, 0x1D5); + DrawMainMenuWindowBorder(&gUnknown_082FF048[1], 0x1D5); + DrawMainMenuWindowBorder(&gUnknown_082FF048[2], 0x1D5); + break; + case HAS_MYSTERY_GIFT: + FillWindowPixelBuffer(2, 0xAA); + FillWindowPixelBuffer(3, 0xAA); + FillWindowPixelBuffer(4, 0xAA); + FillWindowPixelBuffer(5, 0xAA); + box_print(2, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuContinue); + box_print(3, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuNewGame); + box_print(4, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuMysteryGift); + box_print(5, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuOption); + fmt_savegame(); + PutWindowTilemap(2); + PutWindowTilemap(3); + PutWindowTilemap(4); + PutWindowTilemap(5); + CopyWindowToVram(2, 2); + CopyWindowToVram(3, 2); + CopyWindowToVram(4, 2); + CopyWindowToVram(5, 2); + DrawMainMenuWindowBorder(gUnknown_082FF048, 0x1D5); + DrawMainMenuWindowBorder(&gUnknown_082FF048[1], 0x1D5); + DrawMainMenuWindowBorder(&gUnknown_082FF048[2], 0x1D5); + DrawMainMenuWindowBorder(&gUnknown_082FF048[3], 0x1D5); + break; + case HAS_MYSTERY_EVENTS: + FillWindowPixelBuffer(2, 0xAA); + FillWindowPixelBuffer(3, 0xAA); + FillWindowPixelBuffer(4, 0xAA); + FillWindowPixelBuffer(5, 0xAA); + FillWindowPixelBuffer(6, 0xAA); + box_print(2, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuContinue); + box_print(3, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuNewGame); + box_print(4, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuMysteryGift2); + box_print(5, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuMysteryEvents); + box_print(6, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuOption); + fmt_savegame(); + PutWindowTilemap(2); + PutWindowTilemap(3); + PutWindowTilemap(4); + PutWindowTilemap(5); + PutWindowTilemap(6); + CopyWindowToVram(2, 2); + CopyWindowToVram(3, 2); + CopyWindowToVram(4, 2); + CopyWindowToVram(5, 2); + CopyWindowToVram(6, 2); + DrawMainMenuWindowBorder(gUnknown_082FF048, 0x1D5); + DrawMainMenuWindowBorder(&gUnknown_082FF048[1], 0x1D5); + DrawMainMenuWindowBorder(&gUnknown_082FF048[2], 0x1D5); + DrawMainMenuWindowBorder(&gUnknown_082FF048[3], 0x1D5); + DrawMainMenuWindowBorder(&gUnknown_082FF048[4], 0x1D5); + data[13] = AddScrollIndicatorArrowPair(&gUnknown_082FF0F4, &gUnknown_02022D06); + gTasks[data[13]].func = Task_ScrollIndicatorArrowPairOnMainMenu; + if (gUnknown_02022D06 == 4) + { + ChangeBgY(0, 0x2000, 1); + ChangeBgY(1, 0x2000, 1); + data[14] = 1; + gTasks[data[13]].data[15] = 1; + } + break; + } + gTasks[taskId].func = Task_HighlightSelectedMainMenuItem; + } +} + +void Task_HighlightSelectedMainMenuItem(u8 taskId) +{ + HighlightSelectedMainMenuItem(gTasks[taskId].data[0], gTasks[taskId].data[1], gTasks[taskId].data[14]); + gTasks[taskId].func = Task_HandleMainMenuInput; +} + +bool8 HandleMainMenuInput(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + sub_80093CC(); + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0x0000); + gTasks[taskId].func = Task_HandleMainMenuAPressed; + } + else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0xFFFF); + SetGpuReg(REG_OFFSET_WIN0H, 0xF0); + SetGpuReg(REG_OFFSET_WIN0V, 0xA0); + gTasks[taskId].func = Task_HandleMainMenuBPressed; + } + else if ((gMain.newKeys & DPAD_UP) && data[1] > 0) + { + if (data[0] == 3 && data[14] == 1 && data[1] == 1) + { + ChangeBgY(0, 0x2000, 2); + ChangeBgY(1, 0x2000, 2); + gTasks[data[13]].data[15] = data[14] = 0; + } + data[1]--; + gUnknown_02022D06 = data[1]; + return TRUE; + } + else if ((gMain.newKeys & DPAD_DOWN) && data[1] < data[12] - 1) + { + if (data[0] == 3 && data[1] == 3 && data[14] == 0) + { + ChangeBgY(0, 0x2000, 1); + ChangeBgY(1, 0x2000, 1); + gTasks[data[13]].data[15] = data[14] = 1; + } + data[1]++; + gUnknown_02022D06 = data[1]; + return TRUE; + } + return FALSE; +} + +void Task_HandleMainMenuInput(u8 taskId) +{ + if (HandleMainMenuInput(taskId)) + gTasks[taskId].func = Task_HighlightSelectedMainMenuItem; +} + +void Task_HandleMainMenuAPressed(u8 taskId) +{ + bool8 r2; + u8 action; + + if (!gPaletteFade.active) + { + if (gTasks[taskId].data[0] == 3) + RemoveScrollIndicatorArrowPair(gTasks[taskId].data[13]); + sub_819746C(0, 1); + sub_819746C(1, 1); + sub_819746C(2, 1); + sub_819746C(3, 1); + sub_819746C(4, 1); + sub_819746C(5, 1); + sub_819746C(6, 1); + sub_819746C(7, 1); + r2 = sub_80093CC(); + switch (gTasks[taskId].data[0]) + { + case HAS_NO_SAVED_GAME: + default: + switch (gTasks[taskId].data[1]) + { + case 0: + default: + action = 0; + break; + case 1: + action = 2; + break; + } + break; + case HAS_SAVED_GAME: + switch (gTasks[taskId].data[1]) + { + case 0: + default: + action = 1; + break; + case 1: + action = 0; + break; + case 2: + action = 2; + break; + } + break; + case HAS_MYSTERY_GIFT: + switch (gTasks[taskId].data[1]) + { + case 0: + default: + action = 1; + break; + case 1: + action = 0; + break; + case 2: + action = 3; + if (r2 == FALSE) + { + action = 6; + gTasks[taskId].data[0] = 0; + } + break; + case 3: + action = 2; + break; + } + break; + case HAS_MYSTERY_EVENTS: + switch (gTasks[taskId].data[1]) + { + case 0: + default: + action = 1; + break; + case 1: + action = 0; + break; + case 2: + if (gTasks[taskId].data[15]) + { + action = 3; + if (r2 == FALSE) + { + action = 6; + gTasks[taskId].data[0] = 0; + } + } + else if (r2) + { + action = 6; + gTasks[taskId].data[0] = 1; + } + else + action = 5; + break; + case 3: + if (r2) + { + action = 6; + gTasks[taskId].data[0] = 2; + } + else + action = 4; + break; + case 4: + action = 2; + break; + } + break; + } + ChangeBgY(0, 0, 0); + ChangeBgY(1, 0, 0); + switch (action) + { + case 0: + default: + gPlttBufferUnfaded[0] = RGB_BLACK; + gPlttBufferFaded[0] = RGB_BLACK; + gTasks[taskId].func = task_new_game_prof_birch_speech_1; + break; + case 1: + gPlttBufferUnfaded[0] = RGB_BLACK; + gPlttBufferFaded[0] = RGB_BLACK; + SetMainCallback2(sub_8086230); + DestroyTask(taskId); + break; + case 2: + gMain.savedCallback = CB2_ReinitMainMenu; + SetMainCallback2(CB2_InitOptionMenu); + DestroyTask(taskId); + break; + case 3: + SetMainCallback2(c2_mystery_gift); + DestroyTask(taskId); + break; + case 4: + SetMainCallback2(CB2_InitMysteryEventMenu); + DestroyTask(taskId); + break; + case 5: + SetMainCallback2(sub_801867C); + DestroyTask(taskId); + break; + case 6: + gTasks[taskId].data[1] = 0; + gTasks[taskId].func = Task_DisplayMainMenuInvalidActionError; + gPlttBufferUnfaded[0xF1] = RGB_WHITE; + gPlttBufferFaded[0xF1] = RGB_WHITE; + SetGpuReg(REG_OFFSET_BG2HOFS, 0); + SetGpuReg(REG_OFFSET_BG2VOFS, 0); + SetGpuReg(REG_OFFSET_BG1HOFS, 0); + SetGpuReg(REG_OFFSET_BG1VOFS, 0); + SetGpuReg(REG_OFFSET_BG0HOFS, 0); + SetGpuReg(REG_OFFSET_BG0VOFS, 0); + BeginNormalPaletteFade(-1, 0, 16, 0, 0); + return; + } + FreeAllWindowBuffers(); + if (action != 2) + gUnknown_02022D06 = 0; + else + gUnknown_02022D06 |= 0x8000; + } +} + +void Task_HandleMainMenuBPressed(u8 taskId) +{ + if (!gPaletteFade.active) + { + if (gTasks[taskId].data[0] == 3) + RemoveScrollIndicatorArrowPair(gTasks[taskId].data[13]); + gUnknown_02022D06 = 0; + FreeAllWindowBuffers(); + SetMainCallback2(c2_title_screen_1); + DestroyTask(taskId); + } +} + +void Task_DisplayMainMenuInvalidActionError(u8 taskId) +{ + switch (gTasks[taskId].data[1]) + { + case 0: + FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20); + switch (gTasks[taskId].data[0]) + { + case 0: + CreateMainMenuErrorWindow(gText_WirelessNotConnected); + break; + case 1: + CreateMainMenuErrorWindow(gText_MysteryGiftCantUse); + break; + case 2: + CreateMainMenuErrorWindow(gText_MysteryEventsCantUse); + break; + } + gTasks[taskId].data[1]++; + break; + case 1: + if (!gPaletteFade.active) + gTasks[taskId].data[1]++; + break; + case 2: + RunTextPrinters(); + if (!IsTextPrinterActive(7)) + gTasks[taskId].data[1]++; + break; + case 3: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + PlaySE(SE_SELECT); + BeginNormalPaletteFade(-1, 0, 0, 16, 0); + gTasks[taskId].func = Task_HandleMainMenuBPressed; + } + } +} + +void HighlightSelectedMainMenuItem(u8 menuType, u8 selectedMenuItem, s16 a) +{ + SetGpuReg(REG_OFFSET_WIN0H, 0x9E7); + + switch (menuType) + { + case HAS_NO_SAVED_GAME: + default: + switch (selectedMenuItem) + { + case 0: + default: + SetGpuReg(REG_OFFSET_WIN0V, 0x11F); + break; + case 1: + SetGpuReg(REG_OFFSET_WIN0V, 0x213F); + break; + } + break; + case HAS_SAVED_GAME: + switch (selectedMenuItem) + { + case 0: + default: + SetGpuReg(REG_OFFSET_WIN0V, 0x13F); + break; + case 1: + SetGpuReg(REG_OFFSET_WIN0V, 0x415F); + break; + case 2: + SetGpuReg(REG_OFFSET_WIN0V, 0x617F); + break; + } + break; + case HAS_MYSTERY_GIFT: + switch (selectedMenuItem) + { + case 0: + default: + SetGpuReg(REG_OFFSET_WIN0V, 0x13F); + break; + case 1: + SetGpuReg(REG_OFFSET_WIN0V, 0x415F); + break; + case 2: + SetGpuReg(REG_OFFSET_WIN0V, 0x617F); + break; + case 3: + SetGpuReg(REG_OFFSET_WIN0V, 0x819F); + break; + } + break; + case HAS_MYSTERY_EVENTS: + switch (selectedMenuItem) + { + case 0: + default: + SetGpuReg(REG_OFFSET_WIN0V, 0x13F); + break; + case 1: + if (a) + SetGpuReg(REG_OFFSET_WIN0V, 0x213F); + else + SetGpuReg(REG_OFFSET_WIN0V, 0x415F); + break; + case 2: + if (a) + SetGpuReg(REG_OFFSET_WIN0V, 0x415F); + else + SetGpuReg(REG_OFFSET_WIN0V, 0x617F); + break; + case 3: + if (a) + SetGpuReg(REG_OFFSET_WIN0V, 0x617F); + else + SetGpuReg(REG_OFFSET_WIN0V, 0x819F); + break; + case 4: + SetGpuReg(REG_OFFSET_WIN0V, 0x819F); + break; + } + break; + } +} + +void task_new_game_prof_birch_speech_1(u8 taskId) +{ + SetGpuReg(REG_OFFSET_DISPCNT, 0); + SetGpuReg(REG_OFFSET_DISPCNT, 0x1040); + InitBgFromTemplate(&gUnknown_082FF0F0); + SetGpuReg(REG_OFFSET_WIN0H, 0); + SetGpuReg(REG_OFFSET_WIN0V, 0); + SetGpuReg(REG_OFFSET_WININ, 0); + SetGpuReg(REG_OFFSET_WINOUT, 0); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + + LZ77UnCompVram(gBirchIntroShadowGfx, (void*)VRAM); + LZ77UnCompVram(gUnknown_082FEEF0, (void*)(VRAM + 0x3800)); + LoadPalette(gUnknown_082FECFC, 0, 64); + LoadPalette(gUnknown_082FF028, 1, 16); + ScanlineEffect_Stop(); + ResetSpriteData(); + FreeAllSpritePalettes(); + dp13_810BB8C(); + AddBirchSpeechObjects(taskId); + BeginNormalPaletteFade(-1, 0, 16, 0, 0); + gTasks[taskId].data[4] = 0; + gTasks[taskId].func = task_new_game_prof_birch_speech_2; + gTasks[taskId].data[2] = 0xFF; + gTasks[taskId].data[3] = 0xFF; + gTasks[taskId].data[7] = 0xD8; + PlayBGM(MUS_DOORO_X4); + ShowBg(0); + ShowBg(1); +} + +void task_new_game_prof_birch_speech_2(u8 taskId) +{ + u8 spriteId; + + if (gTasks[taskId].data[7]) + gTasks[taskId].data[7]--; + else + { + spriteId = gTasks[taskId].data[8]; + gSprites[spriteId].pos1.x = 0x88; + gSprites[spriteId].pos1.y = 0x3C; + gSprites[spriteId].invisible = 0; + gSprites[spriteId].oam.objMode = 1; + sub_8031BAC(taskId, 10); + sub_8031D34(taskId, 20); + gTasks[taskId].data[7] = 0x50; + gTasks[taskId].func = task_new_game_prof_birch_speech_3; + } +} + +void task_new_game_prof_birch_speech_3(u8 taskId) +{ + if (gTasks[taskId].data[5]) + { + gSprites[gTasks[taskId].data[8]].oam.objMode = 0; + if (gTasks[taskId].data[7]) + gTasks[taskId].data[7]--; + else + { + InitWindows(gUnknown_082FF080); + LoadMainMenuWindowFrameTiles(0, 0xF3); + copy_textbox_border_tile_patterns_to_vram(0, 0xFC, 0xF0); + unknown_rbox_to_vram(0, 1); + PutWindowTilemap(0); + CopyWindowToVram(0, 2); + sub_8032318(0); + StringExpandPlaceholders(gStringVar4, gUnknown_082C897B); + AddTextPrinterForMessage(1); + gTasks[taskId].func = task_new_game_prof_birch_speech_4; + } + } +} From 368a63d5a74dee114797218d443b2cb0db68b9ea Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Thu, 8 Feb 2018 16:01:24 -0500 Subject: [PATCH 02/11] decompiled up to task_new_game_prof_birch_speech_10 --- asm/main_menu.s | 435 ------------------------------------------------ src/main_menu.c | 172 +++++++++++++++++-- 2 files changed, 156 insertions(+), 451 deletions(-) diff --git a/asm/main_menu.s b/asm/main_menu.s index 8f4e9fb8a4..ab2186a681 100644 --- a/asm/main_menu.s +++ b/asm/main_menu.s @@ -5,441 +5,6 @@ .text - thumb_func_start task_new_game_prof_birch_speech_5 -task_new_game_prof_birch_speech_5: @ 8030A2C - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl sub_8197224 - lsls r0, 16 - cmp r0, 0 - bne _08030A58 - ldr r0, =gStringVar4 - ldr r1, =gUnknown_082C8A1F - bl StringExpandPlaceholders - movs r0, 0x1 - bl AddTextPrinterForMessage - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =task_new_game_prof_birch_speech_6 - str r1, [r0] -_08030A58: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_5 - - thumb_func_start sub_8030A70 -sub_8030A70: @ 8030A70 - push {r4-r6,lr} - mov r6, r8 - push {r6} - sub sp, 0x14 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r6, =gTasks - ldr r0, =gUnknown_03000DD0 - mov r8, r0 - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r6 - ldrb r0, [r0, 0x1A] - ldr r1, =gSprites - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - adds r2, r1 - movs r5, 0 - movs r1, 0x64 - strh r1, [r2, 0x20] - movs r1, 0x4B - strh r1, [r2, 0x22] - movs r1, 0x3E - adds r1, r2 - mov r12, r1 - ldrb r3, [r1] - movs r1, 0x5 - negs r1, r1 - ands r1, r3 - mov r3, r12 - strb r1, [r3] - strh r5, [r2, 0x2E] - ldrb r1, [r2, 0x5] - lsrs r1, 4 - str r5, [sp] - str r5, [sp, 0x4] - movs r2, 0x20 - str r2, [sp, 0x8] - ldr r2, =0x0000ffff - str r2, [sp, 0xC] - ldr r2, =0x00000127 - str r2, [sp, 0x10] - movs r2, 0x70 - movs r3, 0x3A - bl CreatePokeballSpriteToReleaseMon - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r6 - ldr r1, =sub_8030B14 - str r1, [r0] - mov r0, r8 - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r6 - strh r5, [r0, 0x16] - add sp, 0x14 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8030A70 - - thumb_func_start sub_8030B14 -sub_8030B14: @ 8030B14 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r5, r0, r1 - subs r1, 0x8 - mov r8, r1 - ldr r2, =gUnknown_03000DD0 - ldrb r1, [r2] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - mov r1, r8 - adds r6, r0, r1 - movs r0, 0x1A - ldrsh r1, [r6, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r3, r0, r1 - movs r1, 0 - ldrsh r0, [r5, r1] - adds r7, r2, 0 - cmp r0, 0 - beq _08030B64 - cmp r0, 0x1 - beq _08030B7C - b _08030B98 - .pool -_08030B64: - ldr r1, [r3, 0x1C] - ldr r0, =SpriteCallbackDummy - cmp r1, r0 - bne _08030BBA - ldrb r1, [r3, 0x1] - movs r0, 0x4 - negs r0, r0 - ands r0, r1 - strb r0, [r3, 0x1] - b _08030B98 - .pool -_08030B7C: - movs r1, 0x16 - ldrsh r0, [r6, r1] - cmp r0, 0x5F - ble _08030BBA - adds r0, r4, 0 - bl DestroyTask - ldrb r1, [r7] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - mov r1, r8 - adds r2, r0, r1 - b _08030BAA -_08030B98: - ldrh r0, [r5] - adds r0, 0x1 - strh r0, [r5] - ldr r2, =gTasks - ldrb r1, [r7] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r2, r0, r2 -_08030BAA: - ldrh r3, [r2, 0x16] - movs r0, 0x16 - ldrsh r1, [r2, r0] - ldr r0, =0x00003fff - cmp r1, r0 - bgt _08030BBA - adds r0, r3, 0x1 - strh r0, [r2, 0x16] -_08030BBA: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8030B14 - - thumb_func_start task_new_game_prof_birch_speech_6 -task_new_game_prof_birch_speech_6: @ 8030BCC - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl sub_8197224 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0 - bne _08030BFE - ldr r0, =gUnknown_02022D04 - strb r1, [r0] - ldr r0, =gStringVar4 - ldr r1, =gUnknown_082C8BD0 - bl StringExpandPlaceholders - movs r0, 0x1 - bl AddTextPrinterForMessage - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =task_new_game_prof_birch_speech_7 - str r1, [r0] -_08030BFE: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_6 - - thumb_func_start task_new_game_prof_birch_speech_7 -task_new_game_prof_birch_speech_7: @ 8030C18 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - bl sub_8197224 - lsls r0, 16 - cmp r0, 0 - bne _08030C7C - ldr r5, =gSprites - ldr r0, =gTasks - lsls r4, r6, 2 - adds r4, r6 - lsls r4, 3 - adds r4, r0 - movs r1, 0x18 - ldrsh r0, [r4, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r5 - ldrb r3, [r1, 0x1] - movs r2, 0xD - negs r2, r2 - adds r0, r2, 0 - ands r0, r3 - movs r3, 0x4 - orrs r0, r3 - strb r0, [r1, 0x1] - movs r0, 0x1A - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - ldrb r1, [r0, 0x1] - ands r2, r1 - orrs r2, r3 - strb r2, [r0, 0x1] - adds r0, r6, 0 - movs r1, 0x2 - bl sub_8031ACC - adds r0, r6, 0 - movs r1, 0x1 - bl sub_8031C88 - movs r0, 0x40 - strh r0, [r4, 0x16] - ldr r0, =task_new_game_prof_birch_speech_8 - str r0, [r4] -_08030C7C: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_7 - - thumb_func_start task_new_game_prof_birch_speech_8 -task_new_game_prof_birch_speech_8: @ 8030C90 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r2, r1, r2 - ldrh r3, [r2, 0x10] - movs r0, 0x10 - ldrsh r1, [r2, r0] - movs r0, 0x3C - negs r0, r0 - cmp r1, r0 - beq _08030CC0 - subs r0, r3, 0x2 - strh r0, [r2, 0x10] - ldrh r1, [r2, 0x10] - movs r0, 0x14 - bl SetGpuReg - b _08030CC8 - .pool -_08030CC0: - ldr r0, =0x0000ffc4 - strh r0, [r2, 0x10] - ldr r0, =task_new_game_prof_birch_speech_9 - str r0, [r2] -_08030CC8: - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_8 - - thumb_func_start task_new_game_prof_birch_speech_9 -task_new_game_prof_birch_speech_9: @ 8030CD4 - push {r4-r7,lr} - lsls r0, 24 - lsrs r0, 24 - adds r5, r0, 0 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r1 - movs r1, 0x12 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _08030D7A - ldr r2, =gSprites - movs r0, 0x18 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x3E - ldrb r1, [r0] - movs r7, 0x4 - orrs r1, r7 - strb r1, [r0] - movs r0, 0x1A - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x3E - ldrb r1, [r0] - orrs r1, r7 - strb r1, [r0] - ldrh r0, [r4, 0x16] - movs r1, 0x16 - ldrsh r6, [r4, r1] - cmp r6, 0 - beq _08030D34 - subs r0, 0x1 - strh r0, [r4, 0x16] - b _08030D7A - .pool -_08030D34: - ldrb r3, [r4, 0x1C] - lsls r1, r3, 4 - adds r1, r3 - lsls r1, 2 - adds r1, r2 - movs r0, 0xB4 - strh r0, [r1, 0x20] - movs r0, 0x3C - strh r0, [r1, 0x22] - movs r2, 0x3E - adds r2, r1 - mov r12, r2 - ldrb r2, [r2] - subs r0, 0x41 - ands r0, r2 - mov r2, r12 - strb r0, [r2] - ldrb r2, [r1, 0x1] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - orrs r0, r7 - strb r0, [r1, 0x1] - strh r3, [r4, 0xC] - strh r6, [r4, 0x14] - adds r0, r5, 0 - movs r1, 0x2 - bl sub_8031BAC - adds r0, r5, 0 - movs r1, 0x1 - bl sub_8031D34 - ldr r0, =task_new_game_prof_birch_speech_10 - str r0, [r4] -_08030D7A: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_9 - - thumb_func_start task_new_game_prof_birch_speech_10 -task_new_game_prof_birch_speech_10: @ 8030D84 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r3, r1, r2 - movs r1, 0x12 - ldrsh r0, [r3, r1] - cmp r0, 0 - beq _08030DB8 - ldr r2, =gSprites - movs r1, 0xC - ldrsh r0, [r3, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r2, [r1, 0x1] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x1] - ldr r0, =task_new_game_prof_birch_speech_11 - str r0, [r3] -_08030DB8: - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_10 - thumb_func_start task_new_game_prof_birch_speech_11 task_new_game_prof_birch_speech_11: @ 8030DC8 push {r4,lr} diff --git a/src/main_menu.c b/src/main_menu.c index ed9fef53a5..9ae3e6af03 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -4,14 +4,15 @@ #include "bg.h" #include "constants/rgb.h" #include "constants/songs.h" +#include "constants/species.h" #include "decompress.h" #include "event_data.h" #include "gpu_regs.h" #include "main.h" #include "menu.h" #include "menu_indicators.h" -#include "new_menu_helpers.h" #include "palette.h" +#include "pokeball.h" #include "rtc.h" #include "save.h" #include "scanline_effect.h" @@ -60,7 +61,7 @@ extern u8 gJPText_No1MSubCircuit[]; extern u16 gUnknown_02022D06; extern struct WindowTemplate gUnknown_082FF070[]; extern u8 gText_BatteryRunDry[]; -extern struct TextColor gUnknown_082FF0E0; +extern u8 gUnknown_082FF0E0[]; extern u8 gText_MainMenuNewGame[]; extern struct WindowTemplate gUnknown_082FF048[]; extern struct ArrowStruct gUnknown_082FF0F4; @@ -80,6 +81,9 @@ extern u16 gUnknown_082FF028[]; extern struct WindowTemplate gUnknown_082FF080[]; extern u8 gUnknown_082C897B[]; extern u8 gText_ThisIsAPokemon[]; +extern u8 gUnknown_082C8A1F[]; +extern u8 gUnknown_02022D04; +extern u8 gUnknown_082C8BD0[]; u32 InitMainMenu(bool8); void Task_MainMenuCheckSaveFile(u8); @@ -107,6 +111,15 @@ void sub_8032318(u8); void task_new_game_prof_birch_speech_4(u8); void task_new_game_prof_birch_speech_5(u8); void sub_80323A0(struct TextPrinter*, u16); +void task_new_game_prof_birch_speech_6(u8); +void sub_8030B14(u8); +void task_new_game_prof_birch_speech_7(u8); +void sub_8031ACC(u8, u8); +void sub_8031C88(u8, u8); +void task_new_game_prof_birch_speech_8(u8); +void task_new_game_prof_birch_speech_9(u8); +void task_new_game_prof_birch_speech_10(u8); +void task_new_game_prof_birch_speech_11(u8); extern void LoadMainMenuWindowFrameTiles(u8, u16); extern bool8 sub_80093CC(void); @@ -367,8 +380,8 @@ void Task_DisplayMainMenu(u8 taskId) default: FillWindowPixelBuffer(0, 0xAA); FillWindowPixelBuffer(1, 0xAA); - box_print(0, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuNewGame); - box_print(1, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuOption); + box_print(0, 1, 0, 1, gUnknown_082FF0E0, -1, gText_MainMenuNewGame); + box_print(1, 1, 0, 1, gUnknown_082FF0E0, -1, gText_MainMenuOption); PutWindowTilemap(0); PutWindowTilemap(1); CopyWindowToVram(0, 2); @@ -380,9 +393,9 @@ void Task_DisplayMainMenu(u8 taskId) FillWindowPixelBuffer(2, 0xAA); FillWindowPixelBuffer(3, 0xAA); FillWindowPixelBuffer(4, 0xAA); - box_print(2, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuContinue); - box_print(3, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuNewGame); - box_print(4, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuOption); + box_print(2, 1, 0, 1, gUnknown_082FF0E0, -1, gText_MainMenuContinue); + box_print(3, 1, 0, 1, gUnknown_082FF0E0, -1, gText_MainMenuNewGame); + box_print(4, 1, 0, 1, gUnknown_082FF0E0, -1, gText_MainMenuOption); fmt_savegame(); PutWindowTilemap(2); PutWindowTilemap(3); @@ -399,10 +412,10 @@ void Task_DisplayMainMenu(u8 taskId) FillWindowPixelBuffer(3, 0xAA); FillWindowPixelBuffer(4, 0xAA); FillWindowPixelBuffer(5, 0xAA); - box_print(2, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuContinue); - box_print(3, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuNewGame); - box_print(4, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuMysteryGift); - box_print(5, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuOption); + box_print(2, 1, 0, 1, gUnknown_082FF0E0, -1, gText_MainMenuContinue); + box_print(3, 1, 0, 1, gUnknown_082FF0E0, -1, gText_MainMenuNewGame); + box_print(4, 1, 0, 1, gUnknown_082FF0E0, -1, gText_MainMenuMysteryGift); + box_print(5, 1, 0, 1, gUnknown_082FF0E0, -1, gText_MainMenuOption); fmt_savegame(); PutWindowTilemap(2); PutWindowTilemap(3); @@ -423,11 +436,11 @@ void Task_DisplayMainMenu(u8 taskId) FillWindowPixelBuffer(4, 0xAA); FillWindowPixelBuffer(5, 0xAA); FillWindowPixelBuffer(6, 0xAA); - box_print(2, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuContinue); - box_print(3, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuNewGame); - box_print(4, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuMysteryGift2); - box_print(5, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuMysteryEvents); - box_print(6, 1, 0, 1, &gUnknown_082FF0E0, -1, gText_MainMenuOption); + box_print(2, 1, 0, 1, gUnknown_082FF0E0, -1, gText_MainMenuContinue); + box_print(3, 1, 0, 1, gUnknown_082FF0E0, -1, gText_MainMenuNewGame); + box_print(4, 1, 0, 1, gUnknown_082FF0E0, -1, gText_MainMenuMysteryGift2); + box_print(5, 1, 0, 1, gUnknown_082FF0E0, -1, gText_MainMenuMysteryEvents); + box_print(6, 1, 0, 1, gUnknown_082FF0E0, -1, gText_MainMenuOption); fmt_savegame(); PutWindowTilemap(2); PutWindowTilemap(3); @@ -909,3 +922,130 @@ void task_new_game_prof_birch_speech_4(u8 taskId) gUnknown_03000DD0 = taskId; } } + +void task_new_game_prof_birch_speech_5(u8 taskId) +{ + if (!sub_8197224()) + { + StringExpandPlaceholders(gStringVar4, gUnknown_082C8A1F); + AddTextPrinterForMessage(1); + gTasks[taskId].func = task_new_game_prof_birch_speech_6; + } +} + +void sub_8030A70(u8 taskId) +{ + u8 spriteId = gTasks[gUnknown_03000DD0].data[9]; + + gSprites[spriteId].pos1.x = 0x64; + gSprites[spriteId].pos1.y = 0x4B; + gSprites[spriteId].invisible = 0; + gSprites[spriteId].data[0] = 0; + + CreatePokeballSpriteToReleaseMon(spriteId, gSprites[spriteId].oam.paletteNum, 0x70, 0x3A, 0, 0, 0x20, 0xFFFF, SPECIES_LOTAD); + gTasks[taskId].func = sub_8030B14; + gTasks[gUnknown_03000DD0].data[7] = 0; +} + +void sub_8030B14(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + struct Sprite *sprite = &gSprites[gTasks[gUnknown_03000DD0].data[9]]; + + switch (data[0]) + { + case 0: + if (sprite->callback == SpriteCallbackDummy) + { + sprite->oam.affineMode = 0; + goto _08030B98_inc_data0; + } + break; + case 1: + if (gTasks[gUnknown_03000DD0].data[7] >= 0x60) + { + DestroyTask(taskId); + if (gTasks[gUnknown_03000DD0].data[7] < 0x4000) + gTasks[gUnknown_03000DD0].data[7]++; + } + break; + _08030B98_inc_data0: + default: + data[0]++; + if (gTasks[gUnknown_03000DD0].data[7] < 0x4000) + gTasks[gUnknown_03000DD0].data[7]++; + break; + } +} + +void task_new_game_prof_birch_speech_6(u8 taskId) +{ + if (!sub_8197224()) + { + gUnknown_02022D04 = 0; + StringExpandPlaceholders(gStringVar4, gUnknown_082C8BD0); + AddTextPrinterForMessage(1); + gTasks[taskId].func = task_new_game_prof_birch_speech_7; + } +} + +void task_new_game_prof_birch_speech_7(u8 taskId) +{ + if (!sub_8197224()) + { + gSprites[gTasks[taskId].data[8]].oam.objMode = 1; + gSprites[gTasks[taskId].data[9]].oam.objMode = 1; + sub_8031ACC(taskId, 2); + sub_8031C88(taskId, 1); + gTasks[taskId].data[7] = 0x40; + gTasks[taskId].func = task_new_game_prof_birch_speech_8; + } +} + +void task_new_game_prof_birch_speech_8(u8 taskId) +{ + if (gTasks[taskId].data[4] != -60) + { + gTasks[taskId].data[4] -= 2; + SetGpuReg(REG_OFFSET_BG1HOFS, gTasks[taskId].data[4]); + } + else + { + gTasks[taskId].data[4] = -60; + gTasks[taskId].func = task_new_game_prof_birch_speech_9; + } +} + +void task_new_game_prof_birch_speech_9(u8 taskId) +{ + if (gTasks[taskId].data[5]) + { + gSprites[gTasks[taskId].data[8]].invisible = 1; + gSprites[gTasks[taskId].data[9]].invisible = 1; + if (gTasks[taskId].data[7]) + gTasks[taskId].data[7]--; + else + { + u8 spriteId = gTasks[taskId].data[10]; + + gSprites[spriteId].pos1.x = 0xB4; + gSprites[spriteId].pos1.y = 0x3C; + gSprites[spriteId].invisible = 0; + gSprites[spriteId].oam.objMode = 1; + gTasks[taskId].data[2] = spriteId; + gTasks[taskId].data[6] = 0; + sub_8031BAC(taskId, 2); + sub_8031D34(taskId, 1); + gTasks[taskId].func = task_new_game_prof_birch_speech_10; + } + } +} + +void task_new_game_prof_birch_speech_10(u8 taskId) +{ + if (gTasks[taskId].data[5]) + { + gSprites[gTasks[taskId].data[2]].oam.objMode = 0; + gTasks[taskId].func = task_new_game_prof_birch_speech_11; + } +} From 601a942db45bd5697d15ae2fd8ab10c8259410b4 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Sun, 11 Feb 2018 17:19:36 -0500 Subject: [PATCH 03/11] decompile main_menu --- asm/main_menu.s | 2910 ------------------------------------ data/text/birch_speech.inc | 18 +- include/field_effect.h | 1 + include/link.h | 4 + include/menu.h | 1 + include/menu_indicators.h | 1 + include/overworld.h | 1 + include/pokemon_3.h | 1 + include/strings.h | 28 + ld_script.txt | 1 - src/main_menu.c | 901 ++++++++++- 11 files changed, 908 insertions(+), 2959 deletions(-) delete mode 100644 asm/main_menu.s diff --git a/asm/main_menu.s b/asm/main_menu.s deleted file mode 100644 index ab2186a681..0000000000 --- a/asm/main_menu.s +++ /dev/null @@ -1,2910 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start task_new_game_prof_birch_speech_11 -task_new_game_prof_birch_speech_11: @ 8030DC8 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0 - bl sub_8032318 - ldr r0, =gStringVar4 - ldr r1, =gUnknown_082C8BDD - bl StringExpandPlaceholders - movs r0, 0x1 - bl AddTextPrinterForMessage - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =task_new_game_prof_birch_speech_12 - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_11 - - thumb_func_start task_new_game_prof_birch_speech_12 -task_new_game_prof_birch_speech_12: @ 8030E08 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl sub_8197224 - lsls r0, 16 - cmp r0, 0 - bne _08030E2A - bl sub_8031D74 - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =task_new_game_prof_birch_speech_13 - str r0, [r1] -_08030E2A: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_12 - - thumb_func_start task_new_game_prof_birch_speech_13 -task_new_game_prof_birch_speech_13: @ 8030E38 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - bl sub_8031DB4 - lsls r0, 24 - asrs r4, r0, 24 - cmp r4, 0 - beq _08030E52 - cmp r4, 0x1 - beq _08030E52 - lsls r4, r5, 2 - b _08030E76 -_08030E52: - movs r0, 0x5 - bl PlaySE - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - strb r4, [r0, 0x8] - movs r0, 0x1 - movs r1, 0x1 - bl sub_80322E0 - ldr r1, =gTasks - lsls r2, r5, 2 - adds r0, r2, r5 - lsls r0, 3 - adds r0, r1 - ldr r1, =task_new_game_prof_birch_speech_14 - str r1, [r0] - adds r4, r2, 0 -_08030E76: - bl GetMenuCursorPos - lsls r0, 24 - lsrs r3, r0, 24 - ldr r1, =gTasks - adds r0, r4, r5 - lsls r0, 3 - adds r4, r0, r1 - movs r1, 0x14 - ldrsh r0, [r4, r1] - cmp r3, r0 - beq _08030EB8 - strh r3, [r4, 0x14] - ldr r2, =gSprites - movs r0, 0xC - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r2, [r0, 0x1] - movs r1, 0xD - negs r1, r1 - ands r1, r2 - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0, 0x1] - adds r0, r5, 0 - movs r1, 0 - bl sub_8031ACC - ldr r0, =sub_8030ED4 - str r0, [r4] -_08030EB8: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_13 - - thumb_func_start sub_8030ED4 -sub_8030ED4: @ 8030ED4 - push {r4-r7,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r4, r0, r1 - ldrb r5, [r4, 0xC] - movs r2, 0x12 - ldrsh r0, [r4, r2] - adds r7, r1, 0 - cmp r0, 0 - bne _08030F0C - ldr r0, =gSprites - lsls r1, r5, 4 - adds r1, r5 - lsls r1, 2 - adds r1, r0 - ldrh r0, [r1, 0x20] - adds r0, 0x4 - strh r0, [r1, 0x20] - b _08030F72 - .pool -_08030F0C: - ldr r3, =gSprites - lsls r0, r5, 4 - adds r0, r5 - lsls r0, 2 - adds r0, r3 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - movs r1, 0x14 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _08030F30 - ldrb r5, [r4, 0x1E] - b _08030F32 - .pool -_08030F30: - ldrb r5, [r4, 0x1C] -_08030F32: - lsls r2, r5, 4 - adds r2, r5 - lsls r2, 2 - adds r2, r3 - movs r0, 0xF0 - strh r0, [r2, 0x20] - movs r0, 0x3C - strh r0, [r2, 0x22] - adds r3, r2, 0 - adds r3, 0x3E - ldrb r1, [r3] - subs r0, 0x41 - ands r0, r1 - strb r0, [r3] - lsls r4, r6, 2 - adds r4, r6 - lsls r4, 3 - adds r4, r7 - strh r5, [r4, 0xC] - ldrb r1, [r2, 0x1] - movs r0, 0xD - negs r0, r0 - ands r0, r1 - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2, 0x1] - adds r0, r6, 0 - movs r1, 0 - bl sub_8031BAC - ldr r0, =sub_8030F7C - str r0, [r4] -_08030F72: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8030ED4 - - thumb_func_start sub_8030F7C -sub_8030F7C: @ 8030F7C - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r3, r1, r2 - ldrb r1, [r3, 0xC] - ldr r2, =gSprites - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r2, r0, r2 - ldrh r1, [r2, 0x20] - movs r4, 0x20 - ldrsh r0, [r2, r4] - cmp r0, 0xB4 - ble _08030FB0 - subs r0, r1, 0x4 - strh r0, [r2, 0x20] - b _08030FCA - .pool -_08030FB0: - movs r0, 0xB4 - strh r0, [r2, 0x20] - movs r1, 0x12 - ldrsh r0, [r3, r1] - cmp r0, 0 - beq _08030FCA - ldrb r0, [r2, 0x1] - movs r1, 0xD - negs r1, r1 - ands r1, r0 - strb r1, [r2, 0x1] - ldr r0, =task_new_game_prof_birch_speech_13 - str r0, [r3] -_08030FCA: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8030F7C - - thumb_func_start task_new_game_prof_birch_speech_14 -task_new_game_prof_birch_speech_14: @ 8030FD4 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0 - bl sub_8032318 - ldr r0, =gStringVar4 - ldr r1, =gUnknown_082C8BFF - bl StringExpandPlaceholders - movs r0, 0x1 - bl AddTextPrinterForMessage - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =task_new_game_prof_birch_speech_15 - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_14 - - thumb_func_start task_new_game_prof_birch_speech_15 -task_new_game_prof_birch_speech_15: @ 8031014 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl sub_8197224 - lsls r0, 16 - cmp r0, 0 - bne _08031032 - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =task_new_game_prof_birch_speech_16 - str r0, [r1] -_08031032: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_15 - - thumb_func_start task_new_game_prof_birch_speech_16 -task_new_game_prof_birch_speech_16: @ 8031040 - push {r4,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _0803105C - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0803107A -_0803105C: - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =task_new_game_prof_birch_speech_17 - str r1, [r0] -_0803107A: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_16 - - thumb_func_start task_new_game_prof_birch_speech_17 -task_new_game_prof_birch_speech_17: @ 8031090 - push {r4,r5,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - bne _080310EC - bl FreeAllWindowBuffers - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldrh r0, [r0, 0x1A] - bl sub_818D820 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x14 - bl __umodsi3 - lsls r0, 24 - lsrs r0, 24 - bl set_default_player_name - adds r0, r4, 0 - bl DestroyTask - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - ldrb r2, [r1, 0x8] - str r5, [sp] - ldr r0, =new_game_prof_birch_speech_part2_start - str r0, [sp, 0x4] - movs r0, 0 - movs r3, 0 - bl DoNamingScreen -_080310EC: - add sp, 0x8 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_17 - - thumb_func_start task_new_game_prof_birch_speech_part2_2 -task_new_game_prof_birch_speech_part2_2: @ 8031104 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0 - bl sub_8032318 - ldr r0, =gStringVar4 - ldr r1, =gUnknown_082C8C1C - bl StringExpandPlaceholders - movs r0, 0x1 - bl AddTextPrinterForMessage - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =task_new_game_prof_birch_speech_part2_3 - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_part2_2 - - thumb_func_start task_new_game_prof_birch_speech_part2_3 -task_new_game_prof_birch_speech_part2_3: @ 8031144 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - bl sub_8197224 - lsls r0, 16 - cmp r0, 0 - bne _08031178 - movs r0, 0x2 - str r0, [sp] - movs r0, 0xF - str r0, [sp, 0x4] - movs r0, 0x2 - movs r1, 0x1 - movs r2, 0xF3 - movs r3, 0xDF - bl sub_80323CC - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =task_new_game_prof_birch_speech_part2_4 - str r1, [r0] -_08031178: - add sp, 0x8 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_part2_3 - - thumb_func_start task_new_game_prof_birch_speech_part2_4 -task_new_game_prof_birch_speech_part2_4: @ 8031188 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - bl ProcessMenuInputNoWrap_ - lsls r0, 24 - asrs r1, r0, 24 - cmp r1, 0 - beq _080311AE - cmp r1, 0 - bgt _080311A8 - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _080311FC - b _08031210 -_080311A8: - cmp r1, 0x1 - beq _080311FC - b _08031210 -_080311AE: - movs r0, 0x5 - bl PlaySE - ldr r2, =gSprites - ldr r0, =gTasks - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - adds r4, r0 - movs r0, 0xC - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r2, [r0, 0x1] - movs r1, 0xD - negs r1, r1 - ands r1, r2 - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0, 0x1] - adds r0, r5, 0 - movs r1, 0x2 - bl sub_8031ACC - adds r0, r5, 0 - movs r1, 0x1 - bl sub_8031C88 - ldr r0, =task_new_game_prof_birch_speech_part2_5 - str r0, [r4] - b _08031210 - .pool -_080311FC: - movs r0, 0x5 - bl PlaySE - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldr r0, =task_new_game_prof_birch_speech_11 - str r0, [r1] -_08031210: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_part2_4 - - thumb_func_start task_new_game_prof_birch_speech_part2_5 -task_new_game_prof_birch_speech_part2_5: @ 8031220 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldrh r2, [r1, 0x10] - movs r3, 0x10 - ldrsh r0, [r1, r3] - cmp r0, 0 - beq _0803124C - adds r0, r2, 0x2 - strh r0, [r1, 0x10] - ldrh r1, [r1, 0x10] - movs r0, 0x14 - bl SetGpuReg - b _08031250 - .pool -_0803124C: - ldr r0, =task_new_game_prof_birch_speech_part2_6 - str r0, [r1] -_08031250: - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_part2_5 - - thumb_func_start task_new_game_prof_birch_speech_part2_6 -task_new_game_prof_birch_speech_part2_6: @ 8031258 - push {r4-r7,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r7, r0, r1 - movs r1, 0x12 - ldrsh r0, [r7, r1] - cmp r0, 0 - beq _08031320 - ldr r5, =gSprites - movs r2, 0x1C - ldrsh r1, [r7, r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x3E - ldrb r1, [r0] - movs r3, 0x4 - mov r12, r3 - mov r2, r12 - orrs r1, r2 - strb r1, [r0] - movs r3, 0x1E - ldrsh r1, [r7, r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - adds r0, 0x3E - ldrb r1, [r0] - orrs r1, r2 - strb r1, [r0] - ldrb r0, [r7, 0x18] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r5 - movs r0, 0x88 - strh r0, [r1, 0x20] - movs r0, 0x3C - strh r0, [r1, 0x22] - adds r3, r1, 0 - adds r3, 0x3E - ldrb r2, [r3] - movs r4, 0x5 - negs r4, r4 - adds r0, r4, 0 - ands r0, r2 - strb r0, [r3] - ldrb r3, [r1, 0x1] - movs r2, 0xD - negs r2, r2 - adds r0, r2, 0 - ands r0, r3 - mov r3, r12 - orrs r0, r3 - strb r0, [r1, 0x1] - ldrb r1, [r7, 0x1A] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - movs r1, 0x64 - strh r1, [r0, 0x20] - movs r1, 0x4B - strh r1, [r0, 0x22] - adds r3, r0, 0 - adds r3, 0x3E - ldrb r1, [r3] - ands r4, r1 - strb r4, [r3] - ldrb r1, [r0, 0x1] - ands r2, r1 - mov r1, r12 - orrs r2, r1 - strb r2, [r0, 0x1] - adds r0, r6, 0 - movs r1, 0x2 - bl sub_8031BAC - adds r0, r6, 0 - movs r1, 0x1 - bl sub_8031D34 - movs r0, 0 - bl sub_8032318 - ldr r0, =gStringVar4 - ldr r1, =gUnknown_082C8C2A - bl StringExpandPlaceholders - movs r0, 0x1 - bl AddTextPrinterForMessage - ldr r0, =task_new_game_prof_birch_speech_part2_7 - str r0, [r7] -_08031320: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_part2_6 - - thumb_func_start task_new_game_prof_birch_speech_part2_7 -task_new_game_prof_birch_speech_part2_7: @ 803133C - push {r4-r7,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r1 - movs r1, 0x12 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _080313D2 - ldr r7, =gSprites - movs r1, 0x18 - ldrsh r0, [r4, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r7 - ldrb r2, [r1, 0x1] - movs r6, 0xD - negs r6, r6 - adds r0, r6, 0 - ands r0, r2 - strb r0, [r1, 0x1] - movs r1, 0x1A - ldrsh r0, [r4, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r7 - ldrb r2, [r1, 0x1] - adds r0, r6, 0 - ands r0, r2 - strb r0, [r1, 0x1] - bl sub_8197224 - lsls r0, 16 - cmp r0, 0 - bne _080313D2 - movs r0, 0x18 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrb r2, [r0, 0x1] - adds r1, r6, 0 - ands r1, r2 - movs r3, 0x4 - orrs r1, r3 - strb r1, [r0, 0x1] - movs r1, 0x1A - ldrsh r0, [r4, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r7 - ldrb r2, [r1, 0x1] - adds r0, r6, 0 - ands r0, r2 - orrs r0, r3 - strb r0, [r1, 0x1] - adds r0, r5, 0 - movs r1, 0x2 - bl sub_8031ACC - adds r0, r5, 0 - movs r1, 0x1 - bl sub_8031C88 - movs r0, 0x40 - strh r0, [r4, 0x16] - ldr r0, =task_new_game_prof_birch_speech_part2_8 - str r0, [r4] -_080313D2: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_part2_7 - - thumb_func_start task_new_game_prof_birch_speech_part2_8 -task_new_game_prof_birch_speech_part2_8: @ 80313E4 - push {r4-r7,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r4, r0, r1 - movs r2, 0x12 - ldrsh r0, [r4, r2] - adds r7, r1, 0 - cmp r0, 0 - beq _080314B0 - ldr r2, =gSprites - movs r3, 0x18 - ldrsh r1, [r4, r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x3E - ldrb r1, [r0] - movs r3, 0x4 - orrs r1, r3 - strb r1, [r0] - movs r0, 0x1A - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x3E - ldrb r1, [r0] - orrs r1, r3 - strb r1, [r0] - ldrh r1, [r4, 0x16] - movs r3, 0x16 - ldrsh r0, [r4, r3] - cmp r0, 0 - beq _08031444 - subs r0, r1, 0x1 - strh r0, [r4, 0x16] - b _080314B0 - .pool -_08031444: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldrb r0, [r0, 0x8] - cmp r0, 0 - beq _08031458 - ldrb r5, [r4, 0x1E] - b _0803145A - .pool -_08031458: - ldrb r5, [r4, 0x1C] -_0803145A: - lsls r1, r5, 4 - adds r1, r5 - lsls r1, 2 - adds r1, r2 - movs r0, 0x78 - strh r0, [r1, 0x20] - movs r0, 0x3C - strh r0, [r1, 0x22] - adds r3, r1, 0 - adds r3, 0x3E - ldrb r2, [r3] - subs r0, 0x41 - ands r0, r2 - strb r0, [r3] - ldrb r2, [r1, 0x1] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - movs r2, 0x4 - orrs r0, r2 - strb r0, [r1, 0x1] - lsls r4, r6, 2 - adds r4, r6 - lsls r4, 3 - adds r4, r7 - strh r5, [r4, 0xC] - adds r0, r6, 0 - movs r1, 0x2 - bl sub_8031BAC - adds r0, r6, 0 - movs r1, 0x1 - bl sub_8031D34 - ldr r0, =gStringVar4 - ldr r1, =gUnknown_082C8C7A - bl StringExpandPlaceholders - movs r0, 0x1 - bl AddTextPrinterForMessage - ldr r0, =task_new_game_prof_birch_speech_part2_9 - str r0, [r4] -_080314B0: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_part2_8 - - thumb_func_start task_new_game_prof_birch_speech_part2_9 -task_new_game_prof_birch_speech_part2_9: @ 80314C4 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r6, r1, r2 - movs r1, 0x12 - ldrsh r0, [r6, r1] - cmp r0, 0 - beq _0803155C - ldr r7, =gSprites - movs r1, 0xC - ldrsh r0, [r6, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r7 - ldrb r2, [r1, 0x1] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x1] - bl sub_8197224 - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - cmp r0, 0 - bne _0803155C - ldrb r0, [r6, 0xC] - lsls r4, r0, 4 - adds r4, r0 - lsls r4, 2 - adds r5, r4, r7 - ldrb r1, [r5, 0x1] - movs r0, 0x4 - negs r0, r0 - ands r0, r1 - movs r1, 0x1 - orrs r0, r1 - strb r0, [r5, 0x1] - adds r0, r7, 0 - adds r0, 0x10 - adds r0, r4, r0 - ldr r1, =gUnknown_082FF114 - str r1, [r0] - adds r0, r5, 0 - bl InitSpriteAffineAnim - adds r0, r5, 0 - movs r1, 0 - bl StartSpriteAffineAnim - adds r0, r7, 0 - adds r0, 0x1C - adds r4, r0 - ldr r0, =sub_80318D8 - str r0, [r4] - ldr r0, =0x0000ffff - mov r1, r8 - str r1, [sp] - movs r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - movs r0, 0x4 - bl FadeOutBGM - ldr r0, =task_new_game_prof_birch_speech_part2_10 - str r0, [r6] -_0803155C: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_part2_9 - - thumb_func_start task_new_game_prof_birch_speech_part2_10 -task_new_game_prof_birch_speech_part2_10: @ 8031580 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r3, r1, r2 - ldrb r1, [r3, 0xC] - ldr r2, =gSprites - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x3F - ldrb r0, [r0] - lsls r0, 26 - cmp r0, 0 - bge _080315AA - ldr r0, =task_new_game_prof_birch_speech_part2_11 - str r0, [r3] -_080315AA: - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_part2_10 - - thumb_func_start task_new_game_prof_birch_speech_part2_11 -task_new_game_prof_birch_speech_part2_11: @ 80315BC - push {r4,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0803160A - ldr r0, =gTasks - lsls r4, r2, 2 - adds r4, r2 - lsls r4, 3 - adds r4, r0 - ldrb r2, [r4, 0xC] - ldr r1, =gSprites - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r1, 0x1C - adds r0, r1 - ldr r1, =nullsub_11 - str r1, [r0] - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - ldr r0, =0xffff0000 - ldr r1, =0x0000ffff - str r1, [sp] - movs r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r0, =task_new_game_prof_birch_speech_part2_12 - str r0, [r4] -_0803160A: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_part2_11 - - thumb_func_start task_new_game_prof_birch_speech_part2_12 -task_new_game_prof_birch_speech_part2_12: @ 8031630 - 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 _08031666 - bl FreeAllWindowBuffers - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldrh r0, [r0, 0x1A] - bl sub_818D820 - bl dp13_810BB8C - ldr r0, =CB2_NewGame - bl SetMainCallback2 - adds r0, r4, 0 - bl DestroyTask -_08031666: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_part2_12 - - thumb_func_start new_game_prof_birch_speech_part2_start -new_game_prof_birch_speech_part2_start: @ 8031678 - push {r4,r5,lr} - sub sp, 0xC - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - movs r0, 0 - movs r1, 0 - bl SetGpuReg - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - ldr r1, =gUnknown_082FF0E8 - movs r0, 0 - movs r2, 0x2 - bl InitBgsFromTemplates - ldr r0, =gUnknown_082FF0F0 - bl InitBgFromTemplate - movs r0, 0 - bl SetVBlankCallback - 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, 0x18 - movs r1, 0 - bl SetGpuReg - movs r0, 0x1A - movs r1, 0 - bl SetGpuReg - movs r0, 0x14 - movs r1, 0 - bl SetGpuReg - movs r0, 0x16 - movs r1, 0 - bl SetGpuReg - movs r0, 0x10 - movs r1, 0 - bl SetGpuReg - movs r0, 0x12 - movs r1, 0 - bl SetGpuReg - add r0, sp, 0x4 - movs r4, 0 - strh r4, [r0] - ldr r1, =0x040000d4 - str r0, [r1] - movs r4, 0xC0 - lsls r4, 19 - str r4, [r1, 0x4] - ldr r0, =0x8100c000 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - movs r2, 0 - str r2, [sp, 0x8] - add r0, sp, 0x8 - str r0, [r1] - movs r0, 0xE0 - lsls r0, 19 - str r0, [r1, 0x4] - ldr r0, =0x85000100 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - add r0, sp, 0x4 - strh r2, [r0] - str r0, [r1] - movs r0, 0xA0 - lsls r0, 19 - str r0, [r1, 0x4] - ldr r0, =0x81000200 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - bl ResetPaletteFade - ldr r0, =gBirchIntroShadowGfx - adds r1, r4, 0 - bl LZ77UnCompVram - ldr r0, =gUnknown_082FEEF0 - ldr r1, =0x06003800 - bl LZ77UnCompVram - ldr r0, =gUnknown_082FECFC - movs r1, 0 - movs r2, 0x40 - bl LoadPalette - ldr r0, =gUnknown_082FF018+2 - movs r1, 0x1 - movs r2, 0x10 - bl LoadPalette - bl ResetTasks - ldr r0, =task_new_game_prof_birch_speech_part2_1 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r1 - movs r0, 0x5 - strh r0, [r4, 0x16] - ldr r0, =0x0000ffc4 - strh r0, [r4, 0x10] - bl ScanlineEffect_Stop - bl ResetSpriteData - bl FreeAllSpritePalettes - bl dp13_810BB8C - adds r0, r5, 0 - bl AddBirchSpeechObjects - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldrb r0, [r0, 0x8] - cmp r0, 0 - beq _080317DC - movs r0, 0x1 - strh r0, [r4, 0x14] - ldrb r3, [r4, 0x1E] - b _080317E0 - .pool -_080317DC: - strh r0, [r4, 0x14] - ldrb r3, [r4, 0x1C] -_080317E0: - ldr r0, =gSprites - lsls r1, r3, 4 - adds r1, r3 - lsls r1, 2 - adds r1, r0 - movs r4, 0 - movs r0, 0xB4 - strh r0, [r1, 0x20] - movs r0, 0x3C - strh r0, [r1, 0x22] - adds r1, 0x3E - ldrb r2, [r1] - subs r0, 0x41 - ands r0, r2 - strb r0, [r1] - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - strh r3, [r0, 0xC] - ldr r1, =0x0000ffc4 - movs r0, 0x14 - bl SetGpuReg - movs r0, 0x1 - negs r0, r0 - str r4, [sp] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - movs r0, 0x40 - movs r1, 0 - bl SetGpuReg - movs r0, 0x44 - movs r1, 0 - bl SetGpuReg - movs r0, 0x48 - movs r1, 0 - bl SetGpuReg - movs r0, 0x4A - movs r1, 0 - bl SetGpuReg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - ldr r3, =0x04000208 - ldrh r2, [r3] - strh r4, [r3] - ldr r4, =0x04000200 - ldrh r0, [r4] - movs r1, 0x1 - orrs r0, r1 - strh r0, [r4] - strh r2, [r3] - ldr r0, =VBlankCB_MainMenu - bl SetVBlankCallback - ldr r0, =CB2_MainMenu - bl SetMainCallback2 - ldr r0, =gUnknown_082FF080 - bl InitWindows - movs r0, 0 - movs r1, 0xF3 - bl LoadMainMenuWindowFrameTiles - movs r0, 0 - movs r1, 0xFC - movs r2, 0xF0 - bl copy_textbox_border_tile_patterns_to_vram - movs r0, 0 - bl PutWindowTilemap - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end new_game_prof_birch_speech_part2_start - - thumb_func_start nullsub_11 -nullsub_11: @ 80318D4 - bx lr - thumb_func_end nullsub_11 - - thumb_func_start sub_80318D8 -sub_80318D8: @ 80318D8 - movs r2, 0x22 - ldrsh r1, [r0, r2] - lsls r1, 16 - movs r3, 0x2E - ldrsh r2, [r0, r3] - adds r1, r2 - movs r2, 0xC0 - lsls r2, 8 - adds r1, r2 - lsrs r2, r1, 16 - strh r2, [r0, 0x22] - strh r1, [r0, 0x2E] - bx lr - thumb_func_end sub_80318D8 - - thumb_func_start sub_80318F4 -sub_80318F4: @ 80318F4 - push {lr} - sub sp, 0x10 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - ldr r2, =0x00000127 - str r0, [sp] - str r1, [sp, 0x4] - movs r0, 0xE - str r0, [sp, 0x8] - ldr r0, =0x0000ffff - str r0, [sp, 0xC] - adds r0, r2, 0 - movs r1, 0x8 - movs r2, 0 - movs r3, 0x1 - bl sub_818D3E4 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x10 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80318F4 - - thumb_func_start AddBirchSpeechObjects -@ void AddBirchSpeechObjects(u8 taskId) -AddBirchSpeechObjects: @ 803192C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x88 - movs r1, 0x3C - movs r2, 0x1 - bl AddNewGameBirchObject - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gSprites - mov r9, r1 - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - movs r3, 0x1C - add r3, r9 - mov r8, r3 - adds r1, r2, r3 - ldr r7, =nullsub_11 - str r7, [r1] - add r2, r9 - ldrb r3, [r2, 0x5] - movs r6, 0xD - negs r6, r6 - adds r1, r6, 0 - ands r1, r3 - strb r1, [r2, 0x5] - adds r2, 0x3E - ldrb r1, [r2] - movs r3, 0x4 - mov r10, r3 - mov r3, r10 - orrs r1, r3 - strb r1, [r2] - ldr r1, =gTasks - lsls r5, r4, 2 - adds r5, r4 - lsls r5, 3 - adds r5, r1 - strh r0, [r5, 0x18] - movs r0, 0x64 - movs r1, 0x4B - bl sub_80318F4 - lsls r0, 24 - lsrs r0, 24 - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - mov r4, r8 - adds r1, r2, r4 - str r7, [r1] - add r2, r9 - ldrb r3, [r2, 0x5] - adds r1, r6, 0 - ands r1, r3 - strb r1, [r2, 0x5] - adds r2, 0x3E - ldrb r1, [r2] - mov r3, r10 - orrs r1, r3 - strb r1, [r2] - strh r0, [r5, 0x1A] - movs r0, 0x3C - bl sub_806EFF0 - lsls r0, 24 - lsrs r0, 24 - ldr r4, =0x0201c000 - str r4, [sp] - movs r1, 0x78 - movs r2, 0x3C - movs r3, 0 - bl CreateTrainerSprite - lsls r0, 24 - lsrs r0, 24 - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - mov r3, r8 - adds r1, r2, r3 - str r7, [r1] - add r2, r9 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r1, [r3] - mov r4, r10 - orrs r1, r4 - strb r1, [r3] - ldrb r3, [r2, 0x5] - adds r1, r6, 0 - ands r1, r3 - strb r1, [r2, 0x5] - strh r0, [r5, 0x1C] - movs r0, 0x3F - bl sub_806EFF0 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =0x0201c000 - movs r2, 0x80 - lsls r2, 4 - adds r4, r1, r2 - str r4, [sp] - movs r1, 0x78 - movs r2, 0x3C - movs r3, 0 - bl CreateTrainerSprite - lsls r0, 24 - lsrs r0, 24 - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - add r8, r2 - mov r3, r8 - str r7, [r3] - add r2, r9 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r1, [r3] - mov r4, r10 - orrs r1, r4 - strb r1, [r3] - ldrb r1, [r2, 0x5] - ands r6, r1 - strb r6, [r2, 0x5] - strh r0, [r5, 0x1E] - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end AddBirchSpeechObjects - - thumb_func_start sub_8031A5C -sub_8031A5C: @ 8031A5C - push {r4,r5,lr} - lsls r0, 24 - lsrs r3, r0, 24 - ldr r4, =gTasks - lsls r0, r3, 2 - adds r0, r3 - lsls r0, 3 - adds r2, r0, r4 - ldrh r1, [r2, 0xA] - movs r5, 0xA - ldrsh r0, [r2, r5] - cmp r0, 0 - bne _08031A94 - movs r1, 0x8 - ldrsh r0, [r2, r1] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r4 - movs r0, 0x1 - strh r0, [r1, 0x12] - adds r0, r3, 0 - bl DestroyTask - b _08031AC4 - .pool -_08031A94: - ldrh r3, [r2, 0x10] - movs r4, 0x10 - ldrsh r0, [r2, r4] - cmp r0, 0 - beq _08031AA4 - subs r0, r3, 0x1 - strh r0, [r2, 0x10] - b _08031AC4 -_08031AA4: - ldrh r0, [r2, 0xE] - strh r0, [r2, 0x10] - subs r1, 0x1 - strh r1, [r2, 0xA] - ldrh r0, [r2, 0xC] - adds r0, 0x1 - strh r0, [r2, 0xC] - movs r5, 0xC - ldrsh r0, [r2, r5] - lsls r0, 8 - adds r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg -_08031AC4: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8031A5C - - thumb_func_start sub_8031ACC -sub_8031ACC: @ 8031ACC - push {r4-r6,lr} - mov r6, r8 - push {r6} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - movs r1, 0x94 - lsls r1, 2 - movs r0, 0x50 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0x10 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - ldr r0, =gTasks - mov r8, r0 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - add r0, r8 - movs r6, 0 - strh r6, [r0, 0x12] - ldr r0, =sub_8031A5C - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - add r1, r8 - strh r4, [r1, 0x8] - movs r0, 0x10 - strh r0, [r1, 0xA] - strh r6, [r1, 0xC] - strh r5, [r1, 0xE] - strh r5, [r1, 0x10] - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8031ACC - - thumb_func_start sub_8031B3C -sub_8031B3C: @ 8031B3C - push {r4,r5,lr} - lsls r0, 24 - lsrs r3, r0, 24 - ldr r4, =gTasks - lsls r0, r3, 2 - adds r0, r3 - lsls r0, 3 - adds r2, r0, r4 - ldrh r1, [r2, 0xA] - movs r5, 0xA - ldrsh r0, [r2, r5] - cmp r0, 0x10 - bne _08031B74 - movs r1, 0x8 - ldrsh r0, [r2, r1] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r4 - movs r0, 0x1 - strh r0, [r1, 0x12] - adds r0, r3, 0 - bl DestroyTask - b _08031BA4 - .pool -_08031B74: - ldrh r3, [r2, 0x10] - movs r4, 0x10 - ldrsh r0, [r2, r4] - cmp r0, 0 - beq _08031B84 - subs r0, r3, 0x1 - strh r0, [r2, 0x10] - b _08031BA4 -_08031B84: - ldrh r0, [r2, 0xE] - strh r0, [r2, 0x10] - adds r1, 0x1 - strh r1, [r2, 0xA] - ldrh r0, [r2, 0xC] - subs r0, 0x1 - strh r0, [r2, 0xC] - movs r5, 0xC - ldrsh r0, [r2, r5] - lsls r0, 8 - adds r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg -_08031BA4: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8031B3C - - thumb_func_start sub_8031BAC -sub_8031BAC: @ 8031BAC - push {r4-r6,lr} - mov r6, r8 - push {r6} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - movs r1, 0x94 - lsls r1, 2 - movs r0, 0x50 - bl SetGpuReg - movs r1, 0x80 - lsls r1, 5 - movs r0, 0x52 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - ldr r0, =gTasks - mov r8, r0 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - add r0, r8 - movs r6, 0 - strh r6, [r0, 0x12] - ldr r0, =sub_8031B3C - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - add r1, r8 - strh r4, [r1, 0x8] - strh r6, [r1, 0xA] - movs r0, 0x10 - strh r0, [r1, 0xC] - strh r5, [r1, 0xE] - strh r5, [r1, 0x10] - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8031BAC - - thumb_func_start sub_8031C1C -sub_8031C1C: @ 8031C1C - push {r4,lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r1, =gTasks - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r1, r0, r1 - ldrh r3, [r1, 0xC] - movs r4, 0xC - ldrsh r0, [r1, r4] - cmp r0, 0 - beq _08031C40 - subs r0, r3, 0x1 - strh r0, [r1, 0xC] - b _08031C7C - .pool -_08031C40: - ldrh r3, [r1, 0xA] - movs r4, 0xA - ldrsh r0, [r1, r4] - cmp r0, 0x8 - bne _08031C52 - adds r0, r2, 0 - bl DestroyTask - b _08031C7C -_08031C52: - ldrh r2, [r1, 0x10] - movs r4, 0x10 - ldrsh r0, [r1, r4] - cmp r0, 0 - beq _08031C62 - subs r0, r2, 0x1 - strh r0, [r1, 0x10] - b _08031C7C -_08031C62: - ldrh r0, [r1, 0xE] - strh r0, [r1, 0x10] - adds r0, r3, 0x1 - strh r0, [r1, 0xA] - movs r2, 0xA - ldrsh r0, [r1, r2] - lsls r0, 1 - ldr r1, =gUnknown_082FF018 - adds r0, r1 - movs r1, 0x1 - movs r2, 0x10 - bl LoadPalette -_08031C7C: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8031C1C - - thumb_func_start sub_8031C88 -sub_8031C88: @ 8031C88 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - ldr r0, =sub_8031C1C - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - movs r0, 0 - strh r4, [r1, 0x8] - strh r0, [r1, 0xA] - movs r0, 0x8 - strh r0, [r1, 0xC] - strh r5, [r1, 0xE] - strh r5, [r1, 0x10] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8031C88 - - thumb_func_start sub_8031CC8 -sub_8031CC8: @ 8031CC8 - push {r4,lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r1, =gTasks - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r1, r0, r1 - ldrh r3, [r1, 0xC] - movs r4, 0xC - ldrsh r0, [r1, r4] - cmp r0, 0 - beq _08031CEC - subs r0, r3, 0x1 - strh r0, [r1, 0xC] - b _08031D28 - .pool -_08031CEC: - ldrh r3, [r1, 0xA] - movs r4, 0xA - ldrsh r0, [r1, r4] - cmp r0, 0 - bne _08031CFE - adds r0, r2, 0 - bl DestroyTask - b _08031D28 -_08031CFE: - ldrh r2, [r1, 0x10] - movs r4, 0x10 - ldrsh r0, [r1, r4] - cmp r0, 0 - beq _08031D0E - subs r0, r2, 0x1 - strh r0, [r1, 0x10] - b _08031D28 -_08031D0E: - ldrh r0, [r1, 0xE] - strh r0, [r1, 0x10] - subs r0, r3, 0x1 - strh r0, [r1, 0xA] - movs r2, 0xA - ldrsh r0, [r1, r2] - lsls r0, 1 - ldr r1, =gUnknown_082FF018 - adds r0, r1 - movs r1, 0x1 - movs r2, 0x10 - bl LoadPalette -_08031D28: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8031CC8 - - thumb_func_start sub_8031D34 -sub_8031D34: @ 8031D34 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - ldr r0, =sub_8031CC8 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - strh r4, [r1, 0x8] - movs r0, 0x8 - strh r0, [r1, 0xA] - strh r0, [r1, 0xC] - strh r5, [r1, 0xE] - strh r5, [r1, 0x10] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8031D34 - - thumb_func_start sub_8031D74 -sub_8031D74: @ 8031D74 - push {lr} - ldr r0, =gUnknown_082FF088 - movs r1, 0xF3 - bl DrawMainMenuWindowBorder - movs r0, 0x1 - movs r1, 0x11 - bl FillWindowPixelBuffer - ldr r2, =gUnknown_082FF118 - movs r0, 0x1 - movs r1, 0x2 - bl PrintMenuTable - movs r0, 0x1 - movs r1, 0x2 - movs r2, 0 - bl InitMenuInUpperLeftCornerPlaySoundWhenAPressed - movs r0, 0x1 - bl PutWindowTilemap - movs r0, 0x1 - movs r1, 0x3 - bl CopyWindowToVram - pop {r0} - bx r0 - .pool - thumb_func_end sub_8031D74 - - thumb_func_start sub_8031DB4 -sub_8031DB4: @ 8031DB4 - push {lr} - bl ProcessMenuInputNoWrapAround - lsls r0, 24 - asrs r0, 24 - pop {r1} - bx r1 - thumb_func_end sub_8031DB4 - - thumb_func_start set_default_player_name -@ void set_default_player_name(int name_id) -set_default_player_name: @ 8031DC4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r1, =gSaveBlock2Ptr - ldr r0, [r1] - ldrb r0, [r0, 0x8] - adds r5, r1, 0 - cmp r0, 0 - bne _08031DE4 - ldr r1, =gMalePresetNames - b _08031DE6 - .pool -_08031DE4: - ldr r1, =gFemalePresetNames -_08031DE6: - lsls r0, r2, 2 - adds r0, r1 - ldr r3, [r0] - movs r2, 0 - ldr r4, =gSaveBlock2Ptr -_08031DF0: - ldr r1, [r4] - adds r1, r2 - adds r0, r3, r2 - ldrb r0, [r0] - strb r0, [r1] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x6 - bls _08031DF0 - ldr r1, [r5] - movs r0, 0xFF - strb r0, [r1, 0x7] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end set_default_player_name - - thumb_func_start CreateMainMenuErrorWindow -@ void CreateMainMenuErrorWindow(u8 *str) -CreateMainMenuErrorWindow: @ 8031E18 - push {r4,lr} - sub sp, 0xC - adds r4, r0, 0 - movs r0, 0x7 - movs r1, 0x11 - bl FillWindowPixelBuffer - movs r0, 0x1 - str r0, [sp] - movs r0, 0x2 - str r0, [sp, 0x4] - movs r0, 0 - str r0, [sp, 0x8] - movs r0, 0x7 - movs r1, 0x1 - adds r2, r4, 0 - movs r3, 0 - bl PrintTextOnWindow - movs r0, 0x7 - bl PutWindowTilemap - movs r0, 0x7 - movs r1, 0x2 - bl CopyWindowToVram - ldr r0, =gUnknown_082FF070 - ldr r1, =0x000001d5 - bl DrawMainMenuWindowBorder - ldr r1, =0x000009e7 - movs r0, 0x40 - bl SetGpuReg - ldr r1, =0x0000719f - movs r0, 0x44 - bl SetGpuReg - add sp, 0xC - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end CreateMainMenuErrorWindow - - thumb_func_start fmt_savegame -fmt_savegame: @ 8031E7C - push {lr} - bl fmt_time - bl fmt_pokedex - bl fmt_player - bl fmt_badges - pop {r0} - bx r0 - thumb_func_end fmt_savegame - - thumb_func_start fmt_time -fmt_time: @ 8031E94 - push {r4-r6,lr} - sub sp, 0xC - ldr r4, =gStringVar4 - ldr r1, =gText_ContinueMenuPlayer - adds r0, r4, 0 - bl StringExpandPlaceholders - ldr r6, =gUnknown_082FF0E3 - str r6, [sp] - movs r5, 0x1 - negs r5, r5 - str r5, [sp, 0x4] - str r4, [sp, 0x8] - movs r0, 0x2 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x11 - bl box_print - ldr r4, =gSaveBlock2Ptr - ldr r1, [r4] - movs r0, 0x1 - movs r2, 0x64 - bl GetStringRightAlignXOffset - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - str r6, [sp] - str r5, [sp, 0x4] - ldr r0, [r4] - str r0, [sp, 0x8] - movs r0, 0x2 - movs r1, 0x1 - movs r3, 0x11 - bl box_print - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end fmt_time - - thumb_func_start fmt_player -fmt_player: @ 8031EF8 - push {r4-r6,lr} - sub sp, 0x2C - ldr r4, =gStringVar4 - ldr r1, =gText_ContinueMenuTime - adds r0, r4, 0 - bl StringExpandPlaceholders - ldr r6, =gUnknown_082FF0E3 - str r6, [sp] - movs r5, 0x1 - negs r5, r5 - str r5, [sp, 0x4] - str r4, [sp, 0x8] - movs r0, 0x2 - movs r1, 0x1 - movs r2, 0x6C - movs r3, 0x11 - bl box_print - ldr r4, =gSaveBlock2Ptr - ldr r0, [r4] - ldrh r1, [r0, 0xE] - add r0, sp, 0xC - movs r2, 0 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - movs r1, 0xF0 - strb r1, [r0] - adds r0, 0x1 - ldr r1, [r4] - ldrb r1, [r1, 0x10] - movs r2, 0x2 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - movs r0, 0x1 - add r1, sp, 0xC - movs r2, 0xD0 - bl GetStringRightAlignXOffset - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - str r6, [sp] - str r5, [sp, 0x4] - add r0, sp, 0xC - str r0, [sp, 0x8] - movs r0, 0x2 - movs r1, 0x1 - movs r3, 0x11 - bl box_print - add sp, 0x2C - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end fmt_player - - thumb_func_start fmt_pokedex -fmt_pokedex: @ 8031F7C - push {r4-r7,lr} - sub sp, 0x2C - ldr r0, =0x00000861 - bl FlagGet - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08031FFE - bl IsNationalPokedexEnabled - cmp r0, 0 - beq _08031FA4 - movs r0, 0x1 - bl pokedex_count - b _08031FAA - .pool -_08031FA4: - movs r0, 0x1 - bl sub_80C0844 -_08031FAA: - lsls r0, 16 - lsrs r7, r0, 16 - ldr r4, =gStringVar4 - ldr r1, =gText_ContinueMenuPokedex - adds r0, r4, 0 - bl StringExpandPlaceholders - ldr r6, =gUnknown_082FF0E3 - str r6, [sp] - movs r5, 0x1 - negs r5, r5 - str r5, [sp, 0x4] - str r4, [sp, 0x8] - movs r0, 0x2 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x21 - bl box_print - add r0, sp, 0xC - adds r1, r7, 0 - movs r2, 0 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - movs r0, 0x1 - add r1, sp, 0xC - movs r2, 0x64 - bl GetStringRightAlignXOffset - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - str r6, [sp] - str r5, [sp, 0x4] - add r0, sp, 0xC - str r0, [sp, 0x8] - movs r0, 0x2 - movs r1, 0x1 - movs r3, 0x21 - bl box_print -_08031FFE: - add sp, 0x2C - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end fmt_pokedex - - thumb_func_start fmt_badges -fmt_badges: @ 8032014 - push {r4-r7,lr} - sub sp, 0x2C - movs r7, 0 - ldr r4, =0x00000867 -_0803201C: - lsls r0, r4, 16 - lsrs r0, 16 - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _08032030 - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 -_08032030: - adds r4, 0x1 - ldr r0, =0x0000086e - cmp r4, r0 - bls _0803201C - ldr r4, =gStringVar4 - ldr r1, =gText_ContinueMenuBadges - adds r0, r4, 0 - bl StringExpandPlaceholders - ldr r6, =gUnknown_082FF0E3 - str r6, [sp] - movs r5, 0x1 - negs r5, r5 - str r5, [sp, 0x4] - str r4, [sp, 0x8] - movs r0, 0x2 - movs r1, 0x1 - movs r2, 0x6C - movs r3, 0x21 - bl box_print - add r0, sp, 0xC - adds r1, r7, 0 - movs r2, 0x2 - movs r3, 0x1 - bl ConvertIntToDecimalStringN - movs r0, 0x1 - add r1, sp, 0xC - movs r2, 0xD0 - bl GetStringRightAlignXOffset - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - str r6, [sp] - str r5, [sp, 0x4] - add r0, sp, 0xC - str r0, [sp, 0x8] - movs r0, 0x2 - movs r1, 0x1 - movs r3, 0x21 - bl box_print - add sp, 0x2C - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end fmt_badges - - thumb_func_start LoadMainMenuWindowFrameTiles -@ void LoadMainMenuWindowFrameTiles(u8 bgId, u16 tileOffset) -LoadMainMenuWindowFrameTiles: @ 80320A4 - push {r4-r6,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 16 - lsrs r5, 16 - ldr r6, =gSaveBlock2Ptr - ldr r0, [r6] - ldrb r0, [r0, 0x14] - lsrs r0, 3 - bl GetWindowFrameTilesPal - ldr r1, [r0] - movs r2, 0x90 - lsls r2, 1 - adds r0, r4, 0 - adds r3, r5, 0 - bl LoadBgTiles - ldr r0, [r6] - ldrb r0, [r0, 0x14] - lsrs r0, 3 - bl GetWindowFrameTilesPal - ldr r0, [r0, 0x4] - movs r1, 0x20 - movs r2, 0x20 - bl LoadPalette - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end LoadMainMenuWindowFrameTiles - - thumb_func_start DrawMainMenuWindowBorder -@ void DrawMainMenuWindowBorder(struct WindowTemplate *template, u16 baseTileNum) -DrawMainMenuWindowBorder: @ 80320EC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x1C - adds r4, r0, 0 - lsls r6, r1, 16 - movs r0, 0x80 - lsls r0, 9 - adds r0, r6 - lsrs r0, 16 - mov r9, r0 - movs r1, 0x80 - lsls r1, 10 - adds r1, r6 - lsrs r1, 16 - mov r10, r1 - movs r7, 0xC0 - lsls r7, 10 - adds r1, r6, r7 - lsrs r1, 16 - str r1, [sp, 0x18] - movs r0, 0xA0 - lsls r0, 11 - adds r1, r6, r0 - lsrs r1, 16 - str r1, [sp, 0xC] - movs r7, 0xC0 - lsls r7, 11 - adds r1, r6, r7 - lsrs r1, 16 - str r1, [sp, 0x10] - movs r0, 0xE0 - lsls r0, 11 - adds r1, r6, r0 - lsrs r1, 16 - str r1, [sp, 0x14] - lsrs r1, r6, 16 - movs r7, 0x80 - lsls r7, 12 - adds r6, r7 - lsrs r6, 16 - ldrb r0, [r4] - ldrb r2, [r4, 0x1] - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - ldrb r3, [r4, 0x2] - subs r3, 0x1 - lsls r3, 24 - lsrs r3, 24 - movs r5, 0x1 - str r5, [sp] - str r5, [sp, 0x4] - movs r7, 0x2 - mov r8, r7 - str r7, [sp, 0x8] - bl FillBgTilemapBufferRect - ldrb r0, [r4] - ldrb r2, [r4, 0x1] - ldrb r3, [r4, 0x2] - subs r3, 0x1 - lsls r3, 24 - lsrs r3, 24 - ldrb r1, [r4, 0x3] - str r1, [sp] - str r5, [sp, 0x4] - str r7, [sp, 0x8] - mov r1, r9 - bl FillBgTilemapBufferRect - ldrb r0, [r4] - ldrb r2, [r4, 0x3] - ldrb r1, [r4, 0x1] - adds r2, r1 - lsls r2, 24 - lsrs r2, 24 - ldrb r3, [r4, 0x2] - subs r3, 0x1 - lsls r3, 24 - lsrs r3, 24 - str r5, [sp] - str r5, [sp, 0x4] - str r7, [sp, 0x8] - mov r1, r10 - bl FillBgTilemapBufferRect - ldrb r0, [r4] - ldrb r2, [r4, 0x1] - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - ldrb r3, [r4, 0x2] - str r5, [sp] - ldrb r1, [r4, 0x4] - str r1, [sp, 0x4] - str r7, [sp, 0x8] - ldr r1, [sp, 0x18] - bl FillBgTilemapBufferRect - ldrb r0, [r4] - ldrb r2, [r4, 0x3] - ldrb r7, [r4, 0x1] - adds r2, r7 - lsls r2, 24 - lsrs r2, 24 - ldrb r3, [r4, 0x2] - str r5, [sp] - ldrb r1, [r4, 0x4] - str r1, [sp, 0x4] - mov r1, r8 - str r1, [sp, 0x8] - ldr r1, [sp, 0xC] - bl FillBgTilemapBufferRect - ldrb r0, [r4] - ldrb r2, [r4, 0x1] - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - ldrb r3, [r4, 0x4] - ldrb r7, [r4, 0x2] - adds r3, r7 - lsls r3, 24 - lsrs r3, 24 - str r5, [sp] - str r5, [sp, 0x4] - mov r1, r8 - str r1, [sp, 0x8] - ldr r1, [sp, 0x10] - bl FillBgTilemapBufferRect - ldrb r0, [r4] - ldrb r2, [r4, 0x1] - ldrb r3, [r4, 0x4] - ldrb r7, [r4, 0x2] - adds r3, r7 - lsls r3, 24 - lsrs r3, 24 - ldrb r1, [r4, 0x3] - str r1, [sp] - str r5, [sp, 0x4] - mov r1, r8 - str r1, [sp, 0x8] - ldr r1, [sp, 0x14] - bl FillBgTilemapBufferRect - ldrb r0, [r4] - ldrb r2, [r4, 0x3] - ldrb r7, [r4, 0x1] - adds r2, r7 - lsls r2, 24 - lsrs r2, 24 - ldrb r3, [r4, 0x4] - ldrb r1, [r4, 0x2] - adds r3, r1 - lsls r3, 24 - lsrs r3, 24 - str r5, [sp] - str r5, [sp, 0x4] - mov r7, r8 - str r7, [sp, 0x8] - adds r1, r6, 0 - bl FillBgTilemapBufferRect - ldrb r0, [r4] - bl CopyBgTilemapBufferToVram - add sp, 0x1C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end DrawMainMenuWindowBorder - - thumb_func_start sub_8032250 -sub_8032250: @ 8032250 - push {r4-r6,lr} - sub sp, 0xC - adds r6, r0, 0 - ldrb r0, [r6] - ldrb r1, [r6, 0x1] - subs r2, r1, 0x1 - lsls r2, 24 - lsrs r2, 24 - ldrb r4, [r6, 0x2] - subs r3, r4, 0x1 - lsls r3, 24 - lsrs r3, 24 - ldrb r5, [r6, 0x3] - adds r1, r5 - adds r1, 0x1 - lsls r1, 24 - lsrs r1, 24 - str r1, [sp] - ldrb r1, [r6, 0x4] - adds r4, r1 - adds r4, 0x1 - lsls r4, 24 - lsrs r4, 24 - str r4, [sp, 0x4] - movs r1, 0x2 - str r1, [sp, 0x8] - movs r1, 0 - bl FillBgTilemapBufferRect - ldrb r0, [r6] - bl CopyBgTilemapBufferToVram - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8032250 - - thumb_func_start sub_8032298 -sub_8032298: @ 8032298 - push {r4,r5,lr} - sub sp, 0xC - adds r4, r1, 0 - adds r5, r2, 0 - ldr r1, [sp, 0x18] - lsls r0, 24 - lsrs r0, 24 - lsls r4, 24 - lsls r5, 24 - lsls r3, 24 - lsls r1, 24 - movs r2, 0xFF - lsls r2, 24 - adds r4, r2 - lsrs r4, 24 - adds r5, r2 - lsrs r5, 24 - movs r2, 0x80 - lsls r2, 18 - adds r3, r2 - lsrs r3, 24 - str r3, [sp] - adds r1, r2 - lsrs r1, 24 - str r1, [sp, 0x4] - movs r1, 0x2 - str r1, [sp, 0x8] - movs r1, 0 - adds r2, r4, 0 - adds r3, r5, 0 - bl FillBgTilemapBufferRect - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8032298 - - thumb_func_start sub_80322E0 -sub_80322E0: @ 80322E0 - push {r4,r5,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r5, r0, 24 - lsls r4, 24 - lsrs r4, 24 - ldr r1, =sub_8032298 - adds r0, r5, 0 - bl CallWindowFunction - adds r0, r5, 0 - movs r1, 0x11 - bl FillWindowPixelBuffer - adds r0, r5, 0 - bl ClearWindowTilemap - cmp r4, 0x1 - bne _0803230E - adds r0, r5, 0 - movs r1, 0x3 - bl CopyWindowToVram -_0803230E: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80322E0 - - thumb_func_start sub_8032318 -sub_8032318: @ 8032318 - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - sub sp, 0x8 - adds r6, r0, 0 - lsls r6, 24 - lsrs r6, 24 - movs r0, 0x1 - movs r1, 0x6 - bl GetFontAttribute - mov r9, r0 - mov r0, r9 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - movs r0, 0x1 - movs r1, 0 - bl GetFontAttribute - mov r8, r0 - mov r0, r8 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r0, 0x1 - movs r1, 0x1 - bl GetFontAttribute - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - adds r0, r6, 0 - movs r1, 0x3 - bl GetWindowAttribute - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - adds r0, r6, 0 - movs r1, 0x4 - bl GetWindowAttribute - lsls r0, 24 - lsrs r0, 24 - mov r1, r8 - muls r1, r4 - str r1, [sp] - muls r0, r5 - str r0, [sp, 0x4] - adds r0, r6, 0 - mov r1, r9 - movs r2, 0 - movs r3, 0 - bl FillWindowPixelRect - adds r0, r6, 0 - movs r1, 0x2 - bl CopyWindowToVram - add sp, 0x8 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8032318 - - thumb_func_start sub_80323A0 -sub_80323A0: @ 80323A0 - push {lr} - ldr r0, [r0] - subs r0, 0x2 - ldrb r0, [r0] - cmp r0, 0x8 - bne _080323C0 - ldr r1, =gUnknown_02022D04 - ldrb r0, [r1] - cmp r0, 0 - bne _080323C0 - movs r0, 0x1 - strb r0, [r1] - ldr r0, =sub_8030A70 - movs r1, 0 - bl CreateTask -_080323C0: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80323A0 - - thumb_func_start sub_80323CC -sub_80323CC: @ 80323CC - push {r4-r6,lr} - mov r6, r8 - push {r6} - sub sp, 0x20 - adds r4, r0, 0 - adds r5, r1, 0 - mov r8, r2 - ldr r6, [sp, 0x34] - ldr r1, [sp, 0x38] - lsls r4, 24 - lsls r5, 24 - mov r0, r8 - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - lsls r3, 16 - lsrs r3, 16 - lsls r6, 24 - lsrs r6, 24 - lsls r1, 24 - lsrs r1, 24 - movs r0, 0x80 - lsls r0, 17 - adds r4, r0 - lsrs r4, 24 - adds r5, r0 - lsrs r5, 24 - movs r0, 0x5 - str r0, [sp] - movs r0, 0x4 - str r0, [sp, 0x4] - str r1, [sp, 0x8] - str r3, [sp, 0xC] - add r0, sp, 0x10 - movs r1, 0 - adds r2, r4, 0 - adds r3, r5, 0 - bl sub_8198A50 - ldr r0, [sp, 0x10] - ldr r1, [sp, 0x14] - str r0, [sp, 0x18] - str r1, [sp, 0x1C] - add r0, sp, 0x18 - mov r1, r8 - adds r2, r6, 0 - movs r3, 0 - bl CreateYesNoMenu - add sp, 0x20 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_80323CC - - thumb_func_start unknown_rbox_to_vram -unknown_rbox_to_vram: @ 803243C - push {r4,r5,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r5, r0, 24 - lsls r4, 24 - lsrs r4, 24 - ldr r1, =sub_8032474 - adds r0, r5, 0 - bl CallWindowFunction - adds r0, r5, 0 - movs r1, 0x11 - bl FillWindowPixelBuffer - adds r0, r5, 0 - bl PutWindowTilemap - cmp r4, 0x1 - bne _0803246A - adds r0, r5, 0 - movs r1, 0x3 - bl CopyWindowToVram -_0803246A: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end unknown_rbox_to_vram - - thumb_func_start sub_8032474 -sub_8032474: @ 8032474 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x20 - mov r8, r0 - adds r5, r2, 0 - mov r9, r3 - ldr r0, [sp, 0x40] - ldr r6, [sp, 0x44] - mov r2, r8 - lsls r2, 24 - lsrs r2, 24 - mov r8, r2 - lsls r1, 24 - lsls r5, 24 - mov r2, r9 - lsls r2, 24 - lsrs r2, 24 - mov r9, r2 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x10] - lsls r6, 24 - lsrs r6, 24 - lsrs r0, r1, 24 - str r0, [sp, 0xC] - movs r2, 0xFE - lsls r2, 24 - adds r1, r2 - lsrs r1, 24 - str r1, [sp, 0x14] - lsrs r0, r5, 24 - mov r10, r0 - movs r2, 0xFF - lsls r2, 24 - adds r5, r2 - lsrs r5, 24 - movs r4, 0x1 - str r4, [sp] - str r4, [sp, 0x4] - str r6, [sp, 0x8] - mov r0, r8 - movs r1, 0xFD - ldr r2, [sp, 0x14] - adds r3, r5, 0 - bl FillBgTilemapBufferRect - ldr r0, [sp, 0xC] - subs r0, 0x1 - lsls r2, r0, 24 - lsrs r2, 24 - str r2, [sp, 0x18] - str r4, [sp] - str r4, [sp, 0x4] - str r6, [sp, 0x8] - mov r0, r8 - movs r1, 0xFF - adds r3, r5, 0 - bl FillBgTilemapBufferRect - movs r1, 0x80 - lsls r1, 1 - mov r0, r9 - str r0, [sp] - str r4, [sp, 0x4] - str r6, [sp, 0x8] - mov r0, r8 - ldr r2, [sp, 0xC] - adds r3, r5, 0 - bl FillBgTilemapBufferRect - ldr r1, =0x00000101 - ldr r7, [sp, 0xC] - add r7, r9 - subs r0, r7, 0x1 - lsls r2, r0, 24 - lsrs r2, 24 - str r2, [sp, 0x1C] - str r4, [sp] - str r4, [sp, 0x4] - str r6, [sp, 0x8] - mov r0, r8 - adds r3, r5, 0 - bl FillBgTilemapBufferRect - movs r1, 0x81 - lsls r1, 1 - lsls r2, r7, 24 - lsrs r7, r2, 24 - str r4, [sp] - str r4, [sp, 0x4] - str r6, [sp, 0x8] - mov r0, r8 - adds r2, r7, 0 - adds r3, r5, 0 - bl FillBgTilemapBufferRect - ldr r1, =0x00000103 - str r4, [sp] - movs r5, 0x5 - str r5, [sp, 0x4] - str r6, [sp, 0x8] - mov r0, r8 - ldr r2, [sp, 0x14] - mov r3, r10 - bl FillBgTilemapBufferRect - ldr r1, =0x00000105 - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp] - str r5, [sp, 0x4] - str r6, [sp, 0x8] - mov r0, r8 - ldr r2, [sp, 0x18] - mov r3, r10 - bl FillBgTilemapBufferRect - movs r1, 0x83 - lsls r1, 1 - str r4, [sp] - str r5, [sp, 0x4] - str r6, [sp, 0x8] - mov r0, r8 - adds r2, r7, 0 - mov r3, r10 - bl FillBgTilemapBufferRect - ldr r1, =0x000008fd - ldr r2, [sp, 0x10] - add r10, r2 - mov r0, r10 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - str r4, [sp] - str r4, [sp, 0x4] - str r6, [sp, 0x8] - mov r0, r8 - ldr r2, [sp, 0x14] - mov r3, r10 - bl FillBgTilemapBufferRect - ldr r1, =0x000008ff - str r4, [sp] - str r4, [sp, 0x4] - str r6, [sp, 0x8] - mov r0, r8 - ldr r2, [sp, 0x18] - mov r3, r10 - bl FillBgTilemapBufferRect - movs r1, 0x90 - lsls r1, 4 - movs r2, 0x1 - negs r2, r2 - add r9, r2 - mov r0, r9 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp] - str r4, [sp, 0x4] - str r6, [sp, 0x8] - mov r0, r8 - ldr r2, [sp, 0xC] - mov r3, r10 - bl FillBgTilemapBufferRect - ldr r1, =0x00000901 - str r4, [sp] - str r4, [sp, 0x4] - str r6, [sp, 0x8] - mov r0, r8 - ldr r2, [sp, 0x1C] - mov r3, r10 - bl FillBgTilemapBufferRect - ldr r1, =0x00000902 - str r4, [sp] - str r4, [sp, 0x4] - str r6, [sp, 0x8] - mov r0, r8 - adds r2, r7, 0 - mov r3, r10 - bl FillBgTilemapBufferRect - add sp, 0x20 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8032474 - - thumb_func_start task_new_game_prof_birch_speech_part2_1 -task_new_game_prof_birch_speech_part2_1: @ 803261C - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r4, r1, r2 - ldrh r0, [r4, 0x16] - subs r1, r0, 0x1 - strh r1, [r4, 0x16] - lsls r0, 16 - cmp r0, 0 - bgt _08032644 - movs r0, 0 - movs r1, 0x1 - bl unknown_rbox_to_vram - ldr r0, =task_new_game_prof_birch_speech_part2_2 - str r0, [r4] -_08032644: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task_new_game_prof_birch_speech_part2_1 - - .align 2, 0 @ Don't pad with nop. diff --git a/data/text/birch_speech.inc b/data/text/birch_speech.inc index 9e7eea3bcc..1dfc0242bb 100644 --- a/data/text/birch_speech.inc +++ b/data/text/birch_speech.inc @@ -1,4 +1,4 @@ -gUnknown_082C897B:: @ 82C897B +gText_Birch_Welcome:: @ 82C897B .string "Hi! Sorry to keep you waiting!\p" .string "Welcome to the world of POKéMON!\p" .string "My name is BIRCH.\p" @@ -6,12 +6,12 @@ gUnknown_082C897B:: @ 82C897B .string "PROFESSOR.\p" .string "$" -gUnknown_082C89FB:: @ 82C89FB +gText_Birch_Pokemon:: @ 82C89FB .string "This is what we call a “POKéMON.”\p" .string "\n" .string "$" -gUnknown_082C8A1F:: @ 82C8A1F +gText_Birch_MainSpeech:: @ 82C8A1F .string "This world is widely inhabited by\n" .string "creatures known as POKéMON.\p" .string "We humans live alongside POKéMON,\n" @@ -28,28 +28,28 @@ gUnknown_082C8A1F:: @ 82C8A1F .string "That’s what I do.\p" .string "$" -gUnknown_082C8BD0:: @ 82C8BD0 +gText_Birch_AndYouAre:: @ 82C8BD0 .string "And you are?$" -gUnknown_082C8BDD:: @ 82C8BDD +gText_Birch_BoyOrGirl:: @ 82C8BDD .string "Are you a boy?\n" .string "Or are you a girl?$" -gUnknown_082C8BFF:: @ 82C8BFF +gText_Birch_WhatsYourName:: @ 82C8BFF .string "All right.\n" .string "What’s your name?$" -gUnknown_082C8C1C:: @ 82C8C1C +gText_Birch_SoItsPlayer:: @ 82C8C1C .string "So it’s {PLAYER}{KUN}?$" -gUnknown_082C8C2A:: @ 82C8C2A +gText_Birch_YourePlayer:: @ 82C8C2A .string "Ah, okay!\p" .string "You’re {PLAYER}{KUN} who’s moving to my\n" .string "hometown of LITTLEROOT.\l" .string "I get it now!\p" .string "$" -gUnknown_082C8C7A:: @ 82C8C7A +gText_Birch_AreYouReady:: @ 82C8C7A .string "All right, are you ready?\p" .string "Your very own adventure is about\n" .string "to unfold.\p" diff --git a/include/field_effect.h b/include/field_effect.h index 7395270f91..f59dfab9b0 100644 --- a/include/field_effect.h +++ b/include/field_effect.h @@ -74,6 +74,7 @@ extern u32 gFieldEffectArguments[8]; u32 FieldEffectStart(u8); bool8 FieldEffectActiveListContains(u8 id); void sub_80B69DC(void); +u8 AddNewGameBirchObject(s16, s16, u8); void FieldEffectStop(struct Sprite *sprite, u8 id); u8 CreateTrainerSprite(u8 trainerSpriteID, s16 x, s16 y, u8 subpriority, u8 *buffer); void sub_80B7FC8(void); diff --git a/include/link.h b/include/link.h index 1c9795d29e..202e2a4d70 100644 --- a/include/link.h +++ b/include/link.h @@ -145,6 +145,10 @@ extern bool8 gReceivedRemoteLinkPlayers; extern bool8 gLinkVSyncDisabled; extern u32 gLinkStatus; + +void c2_mystery_gift(void); +void sub_801867C(void); +bool8 sub_80093CC(void); void Task_DestroySelf(u8 taskId); void OpenLink(void); void CloseLink(void); diff --git a/include/menu.h b/include/menu.h index 2046f7d2bd..18d3913178 100644 --- a/include/menu.h +++ b/include/menu.h @@ -32,6 +32,7 @@ void sub_8197930(void); u8 GetPlayerTextSpeed(void); void sub_81978B0(u16 arg0); +void AddTextPrinterWithCallbackForMessage(bool8 a1, void (*callback)(struct TextSubPrinter *, u16)); void box_print(u8 windowId, u8 fontId, u8 left, u8 top, const u8 *color, s8 speed, const u8 *str); void sub_8198070(u8 windowId, bool8 copyToVram); void SetWindowTemplateFields(struct WindowTemplate* template, u8 priority, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 palNum, u16 baseBlock); diff --git a/include/menu_indicators.h b/include/menu_indicators.h index d0baac810d..694c01fd96 100644 --- a/include/menu_indicators.h +++ b/include/menu_indicators.h @@ -6,6 +6,7 @@ // Exported RAM declarations // Exported ROM declarations +void Task_ScrollIndicatorArrowPairOnMainMenu(u8); u8 AddScrollIndicatorArrowPairParametrized(u8, u8, u8, u8, s32, u16, u16, u16 *); void RemoveScrollIndicatorArrowPair(u8); diff --git a/include/overworld.h b/include/overworld.h index 974f8f091d..36198e124a 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -55,6 +55,7 @@ void Overworld_ChangeMusicTo(u16); bool32 is_c1_link_related_active(void); +void CB2_NewGame(void); void strange_npc_table_clear(void); const struct MapHeader *get_mapheader_by_bank_and_number(u16, u16); void FieldObjectMoveDestCoords(struct MapObject *, u32, s16 *, s16 *); diff --git a/include/pokemon_3.h b/include/pokemon_3.h index 82dfacf48b..263839b198 100644 --- a/include/pokemon_3.h +++ b/include/pokemon_3.h @@ -1,6 +1,7 @@ #ifndef GUARD_POKEMON_3_H #define GUARD_POKEMON_3_H +u16 sub_806EFF0(u16); const u8* GetTrainerClassNameFromId(u16 trainerId); const u8* GetTrainerNameFromId(u16 trainerId); void PlayMapChosenOrBattleBGM(u16 song); diff --git a/include/strings.h b/include/strings.h index 6d569e57a4..a3d2a2fb72 100644 --- a/include/strings.h +++ b/include/strings.h @@ -218,6 +218,34 @@ extern const u8 gText_FemaleSymbol[]; extern const u8 gText_SelectorArrow3[]; extern const u8 gText_YesNo[]; +// main menu/birch speech text +extern const u8 gText_SaveFileErased[]; +extern const u8 gText_SaveFileCorrupted[]; +extern const u8 gJPText_No1MSubCircuit[]; +extern const u8 gText_BatteryRunDry[]; +extern const u8 gText_MainMenuNewGame[]; +extern const u8 gText_MainMenuOption[]; +extern const u8 gText_MainMenuContinue[]; +extern const u8 gText_MainMenuMysteryGift2[]; +extern const u8 gText_MainMenuMysteryEvents[]; +extern const u8 gText_MainMenuMysteryGift[]; +extern const u8 gText_WirelessNotConnected[]; +extern const u8 gText_MysteryGiftCantUse[]; +extern const u8 gText_MysteryEventsCantUse[]; +extern const u8 gText_Birch_Welcome[]; +extern const u8 gText_ThisIsAPokemon[]; +extern const u8 gText_Birch_MainSpeech[]; +extern const u8 gText_Birch_AndYouAre[]; +extern const u8 gText_Birch_BoyOrGirl[]; +extern const u8 gText_Birch_WhatsYourName[]; +extern const u8 gText_Birch_SoItsPlayer[]; +extern const u8 gText_Birch_YourePlayer[]; +extern const u8 gText_Birch_AreYouReady[]; +extern const u8 gText_ContinueMenuPlayer[]; +extern const u8 gText_ContinueMenuTime[]; +extern const u8 gText_ContinueMenuPokedex[]; +extern const u8 gText_ContinueMenuBadges[]; + // mystery event menu text extern const u8 gText_EventSafelyLoaded[]; extern const u8 gText_LoadErrorEndingSession[]; diff --git a/ld_script.txt b/ld_script.txt index 513bf25838..4998743ce5 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -55,7 +55,6 @@ SECTIONS { asm/link.o(.text); src/rtc.o(.text); src/main_menu.o(.text); - asm/main_menu.o(.text); src/battle_controllers.o(.text); src/decompress.o(.text); asm/rom_8034C54.o(.text); diff --git a/src/main_menu.c b/src/main_menu.c index 9ae3e6af03..f4241edb07 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -1,34 +1,50 @@ // Includes #include "global.h" +#include "battle_dome_cards.h" #include "bg.h" +#include "constants/flags.h" #include "constants/rgb.h" #include "constants/songs.h" #include "constants/species.h" #include "decompress.h" #include "event_data.h" +#include "field_effect.h" #include "gpu_regs.h" +#include "international_string_util.h" +#include "link.h" #include "main.h" #include "menu.h" #include "menu_indicators.h" +#include "mystery_event_menu.h" +#include "naming_screen.h" +#include "option_menu.h" +#include "overworld.h" #include "palette.h" #include "pokeball.h" +#include "pokedex.h" +#include "pokemon_3.h" +#include "random.h" #include "rtc.h" #include "save.h" #include "scanline_effect.h" #include "sound.h" #include "sprite.h" #include "string.h" +#include "strings.h" #include "string_util.h" #include "task.h" #include "text.h" #include "text_window.h" +#include "title_screen.h" #include "window.h" // Static type declarations // Static RAM declarations +extern u8 gUnknown_02022D04; +extern u16 gUnknown_02022D06; IWRAM_DATA u8 gUnknown_03000DD0; @@ -55,35 +71,23 @@ extern u16 gMainMenuBgPal[]; extern u16 gMainMenuTextPal[]; extern struct BgTemplate gUnknown_082FF0E8[]; extern struct WindowTemplate gUnknown_082FF038[]; -extern u8 gText_SaveFileErased[]; -extern u8 gText_SaveFileCorrupted[]; -extern u8 gJPText_No1MSubCircuit[]; -extern u16 gUnknown_02022D06; extern struct WindowTemplate gUnknown_082FF070[]; -extern u8 gText_BatteryRunDry[]; extern u8 gUnknown_082FF0E0[]; -extern u8 gText_MainMenuNewGame[]; extern struct WindowTemplate gUnknown_082FF048[]; extern struct ArrowStruct gUnknown_082FF0F4; -extern u8 gText_MainMenuOption[]; -extern u8 gText_MainMenuContinue[]; -extern u8 gText_MainMenuMysteryGift2[]; -extern u8 gText_MainMenuMysteryEvents[]; -extern u8 gText_MainMenuMysteryGift[]; -extern u8 gText_WirelessNotConnected[]; -extern u8 gText_MysteryGiftCantUse[]; -extern u8 gText_MysteryEventsCantUse[]; extern struct BgTemplate gUnknown_082FF0F0; extern u8 gBirchIntroShadowGfx[]; extern u8 gUnknown_082FEEF0[]; extern u16 gUnknown_082FECFC[]; extern u16 gUnknown_082FF028[]; extern struct WindowTemplate gUnknown_082FF080[]; -extern u8 gUnknown_082C897B[]; -extern u8 gText_ThisIsAPokemon[]; -extern u8 gUnknown_082C8A1F[]; -extern u8 gUnknown_02022D04; -extern u8 gUnknown_082C8BD0[]; +extern const union AffineAnimCmd *const gUnknown_082FF114[]; +extern u16 gUnknown_082FF018[]; +extern struct WindowTemplate gUnknown_082FF088[]; +extern const struct MenuAction gUnknown_082FF118[]; +extern u8* gMalePresetNames[]; +extern u8* gFemalePresetNames[]; +extern u8 gUnknown_082FF0E3[]; u32 InitMainMenu(bool8); void Task_MainMenuCheckSaveFile(u8); @@ -110,7 +114,7 @@ void unknown_rbox_to_vram(u8, u8); void sub_8032318(u8); void task_new_game_prof_birch_speech_4(u8); void task_new_game_prof_birch_speech_5(u8); -void sub_80323A0(struct TextPrinter*, u16); +void sub_80323A0(struct TextSubPrinter *printer, u16 a); void task_new_game_prof_birch_speech_6(u8); void sub_8030B14(u8); void task_new_game_prof_birch_speech_7(u8); @@ -120,22 +124,41 @@ void task_new_game_prof_birch_speech_8(u8); void task_new_game_prof_birch_speech_9(u8); void task_new_game_prof_birch_speech_10(u8); void task_new_game_prof_birch_speech_11(u8); - -extern void LoadMainMenuWindowFrameTiles(u8, u16); -extern bool8 sub_80093CC(void); -extern void Task_ScrollIndicatorArrowPairOnMainMenu(u8); -extern void Task_HighlightSelectedMainMenuItem(u8); -extern void DrawMainMenuWindowBorder(struct WindowTemplate*, u16); -extern void sub_819746C(u8, u8); -extern void sub_8086230(void); -extern void CB2_InitOptionMenu(void); -extern void c2_mystery_gift(void); -extern void CB2_InitMysteryEventMenu(void); -extern void sub_801867C(void); -extern void CB2_InitTitleScreen(void); -extern void dp13_810BB8C(void); -extern bool16 sub_8197224(void); -extern void AddTextPrinterWithCallbackForMessage(u8, void(*callback)(struct TextPrinter*, u16)); +void LoadMainMenuWindowFrameTiles(u8, u16); +void DrawMainMenuWindowBorder(struct WindowTemplate*, u16); +void Task_HighlightSelectedMainMenuItem(u8); +void task_new_game_prof_birch_speech_12(u8); +void task_new_game_prof_birch_speech_13(u8); +void sub_8031D74(void); +s8 sub_8031DB4(void); +void sub_80322E0(u8, u8); +void task_new_game_prof_birch_speech_14(u8); +void sub_8030ED4(u8); +void sub_8030F7C(u8); +void task_new_game_prof_birch_speech_15(u8); +void task_new_game_prof_birch_speech_16(u8); +void task_new_game_prof_birch_speech_17(u8); +void new_game_prof_birch_speech_part2_start(void); +void set_default_player_name(u8); +void task_new_game_prof_birch_speech_part2_3(u8); +void task_new_game_prof_birch_speech_part2_4(u8); +void sub_80323CC(u8, u8, u16, u16, u8, u8); +void task_new_game_prof_birch_speech_part2_5(u8); +void task_new_game_prof_birch_speech_part2_6(u8); +void task_new_game_prof_birch_speech_part2_7(u8); +void task_new_game_prof_birch_speech_part2_8(u8); +void task_new_game_prof_birch_speech_part2_9(u8); +void sub_80318D8(struct Sprite*); +void task_new_game_prof_birch_speech_part2_10(u8); +void task_new_game_prof_birch_speech_part2_11(u8); +void task_new_game_prof_birch_speech_part2_12(u8); +void nullsub_11(); +void task_new_game_prof_birch_speech_part2_1(u8); +void fmt_time(void); +void fmt_pokedex(void); +void fmt_player(void); +void fmt_badges(void); +void sub_8032474(u8, u8, u8, u8, u8, u8); void CB2_MainMenu(void) { @@ -314,7 +337,9 @@ void Task_MainMenuCheckBattery(u8 taskId) SetGpuReg(REG_OFFSET_BLDY, 7); if (!(RtcGetErrorStatus() & RTC_ERR_FLAG_MASK)) + { gTasks[taskId].func = Task_DisplayMainMenu; + } else { CreateMainMenuErrorWindow(gText_BatteryRunDry); @@ -627,7 +652,9 @@ void Task_HandleMainMenuAPressed(u8 taskId) gTasks[taskId].data[0] = 1; } else + { action = 5; + } break; case 3: if (r2) @@ -636,7 +663,9 @@ void Task_HandleMainMenuAPressed(u8 taskId) gTasks[taskId].data[0] = 2; } else + { action = 4; + } break; case 4: action = 2; @@ -874,7 +903,9 @@ void task_new_game_prof_birch_speech_2(u8 taskId) u8 spriteId; if (gTasks[taskId].data[7]) + { gTasks[taskId].data[7]--; + } else { spriteId = gTasks[taskId].data[8]; @@ -895,7 +926,9 @@ void task_new_game_prof_birch_speech_3(u8 taskId) { gSprites[gTasks[taskId].data[8]].oam.objMode = 0; if (gTasks[taskId].data[7]) + { gTasks[taskId].data[7]--; + } else { InitWindows(gUnknown_082FF080); @@ -905,7 +938,7 @@ void task_new_game_prof_birch_speech_3(u8 taskId) PutWindowTilemap(0); CopyWindowToVram(0, 2); sub_8032318(0); - StringExpandPlaceholders(gStringVar4, gUnknown_082C897B); + StringExpandPlaceholders(gStringVar4, gText_Birch_Welcome); AddTextPrinterForMessage(1); gTasks[taskId].func = task_new_game_prof_birch_speech_4; } @@ -927,7 +960,7 @@ void task_new_game_prof_birch_speech_5(u8 taskId) { if (!sub_8197224()) { - StringExpandPlaceholders(gStringVar4, gUnknown_082C8A1F); + StringExpandPlaceholders(gStringVar4, gText_Birch_MainSpeech); AddTextPrinterForMessage(1); gTasks[taskId].func = task_new_game_prof_birch_speech_6; } @@ -983,7 +1016,7 @@ void task_new_game_prof_birch_speech_6(u8 taskId) if (!sub_8197224()) { gUnknown_02022D04 = 0; - StringExpandPlaceholders(gStringVar4, gUnknown_082C8BD0); + StringExpandPlaceholders(gStringVar4, gText_Birch_AndYouAre); AddTextPrinterForMessage(1); gTasks[taskId].func = task_new_game_prof_birch_speech_7; } @@ -1023,7 +1056,9 @@ void task_new_game_prof_birch_speech_9(u8 taskId) gSprites[gTasks[taskId].data[8]].invisible = 1; gSprites[gTasks[taskId].data[9]].invisible = 1; if (gTasks[taskId].data[7]) + { gTasks[taskId].data[7]--; + } else { u8 spriteId = gTasks[taskId].data[10]; @@ -1049,3 +1084,791 @@ void task_new_game_prof_birch_speech_10(u8 taskId) gTasks[taskId].func = task_new_game_prof_birch_speech_11; } } + +void task_new_game_prof_birch_speech_11(u8 taskId) +{ + sub_8032318(0); + StringExpandPlaceholders(gStringVar4, gText_Birch_BoyOrGirl); + AddTextPrinterForMessage(1); + gTasks[taskId].func = task_new_game_prof_birch_speech_12; +} + +void task_new_game_prof_birch_speech_12(u8 taskId) +{ + if (!sub_8197224()) + { + sub_8031D74(); + gTasks[taskId].func = task_new_game_prof_birch_speech_13; + } +} + +void task_new_game_prof_birch_speech_13(u8 taskId) +{ + int gender = sub_8031DB4(); + int r3; + + switch (gender) + { + case MALE: + PlaySE(SE_SELECT); + gSaveBlock2Ptr->playerGender = gender; + sub_80322E0(1, 1); + gTasks[taskId].func = task_new_game_prof_birch_speech_14; + break; + case FEMALE: + PlaySE(SE_SELECT); + gSaveBlock2Ptr->playerGender = gender; + sub_80322E0(1, 1); + gTasks[taskId].func = task_new_game_prof_birch_speech_14; + break; + } + r3 = GetMenuCursorPos(); + if (r3 != gTasks[taskId].data[6]) + { + gTasks[taskId].data[6] = r3; + gSprites[gTasks[taskId].data[2]].oam.objMode = 1; + sub_8031ACC(taskId, 0); + gTasks[taskId].func = sub_8030ED4; + } +} + +void sub_8030ED4(u8 taskId) +{ + u8 spriteId = gTasks[taskId].data[2]; + if (gTasks[taskId].data[5] == 0) + { + gSprites[spriteId].pos1.x += 4; + } + else + { + gSprites[spriteId].invisible = 1; + if (gTasks[taskId].data[6]) + spriteId = gTasks[taskId].data[11]; + else + spriteId = gTasks[taskId].data[10]; + gSprites[spriteId].pos1.x = 0xF0; + gSprites[spriteId].pos1.y = 0x3C; + gSprites[spriteId].invisible = 0; + gTasks[taskId].data[2] = spriteId; + gSprites[spriteId].oam.objMode = 1; + sub_8031BAC(taskId, 0); + gTasks[taskId].func = sub_8030F7C; + } +} + +void sub_8030F7C(u8 taskId) +{ + u8 spriteId = gTasks[taskId].data[2]; + + if (gSprites[spriteId].pos1.x > 0xB4) + { + gSprites[spriteId].pos1.x -= 4; + } + else + { + gSprites[spriteId].pos1.x = 0xB4; + if (gTasks[taskId].data[5]) + { + gSprites[spriteId].oam.objMode = 0; + gTasks[taskId].func = task_new_game_prof_birch_speech_13; + } + } +} + +void task_new_game_prof_birch_speech_14(u8 taskId) +{ + sub_8032318(0); + StringExpandPlaceholders(gStringVar4, gText_Birch_WhatsYourName); + AddTextPrinterForMessage(1); + gTasks[taskId].func = task_new_game_prof_birch_speech_15; +} + +void task_new_game_prof_birch_speech_15(u8 taskId) +{ + if (!sub_8197224()) + gTasks[taskId].func = task_new_game_prof_birch_speech_16; +} + +void task_new_game_prof_birch_speech_16(u8 taskId) +{ + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + { + BeginNormalPaletteFade(-1, 0, 0, 16, 0); + gTasks[taskId].func = task_new_game_prof_birch_speech_17; + } +} + +void task_new_game_prof_birch_speech_17(u8 taskId) +{ + if (!gPaletteFade.active) + { + FreeAllWindowBuffers(); + sub_818D820(gTasks[taskId].data[9]); + set_default_player_name(Random() % 20); + DestroyTask(taskId); + DoNamingScreen(0, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, new_game_prof_birch_speech_part2_start); + } +} + +void task_new_game_prof_birch_speech_part2_2(u8 taskId) +{ + sub_8032318(0); + StringExpandPlaceholders(gStringVar4, gText_Birch_SoItsPlayer); + AddTextPrinterForMessage(1); + gTasks[taskId].func = task_new_game_prof_birch_speech_part2_3; +} + +void task_new_game_prof_birch_speech_part2_3(u8 taskId) +{ + if (!sub_8197224()) + { + sub_80323CC(2, 1, 0xF3, 0xDF, 2, 15); + gTasks[taskId].func = task_new_game_prof_birch_speech_part2_4; + } +} + +void task_new_game_prof_birch_speech_part2_4(u8 taskId) +{ + switch (ProcessMenuInputNoWrap_()) + { + case 0: + PlaySE(SE_SELECT); + gSprites[gTasks[taskId].data[2]].oam.objMode = 1; + sub_8031ACC(taskId, 2); + sub_8031C88(taskId, 1); + gTasks[taskId].func = task_new_game_prof_birch_speech_part2_5; + break; + case -1: + case 1: + PlaySE(SE_SELECT); + gTasks[taskId].func = task_new_game_prof_birch_speech_11; + } +} + +void task_new_game_prof_birch_speech_part2_5(u8 taskId) +{ + if (gTasks[taskId].data[4]) + { + gTasks[taskId].data[4] += 2; + SetGpuReg(REG_OFFSET_BG1HOFS, gTasks[taskId].data[4]); + } + else + { + gTasks[taskId].func = task_new_game_prof_birch_speech_part2_6; + } +} + +void task_new_game_prof_birch_speech_part2_6(u8 taskId) +{ + u8 spriteId; + + if (gTasks[taskId].data[5]) + { + gSprites[gTasks[taskId].data[10]].invisible = 1; + gSprites[gTasks[taskId].data[11]].invisible = 1; + spriteId = gTasks[taskId].data[8]; + gSprites[spriteId].pos1.x = 0x88; + gSprites[spriteId].pos1.y = 0x3C; + gSprites[spriteId].invisible = 0; + gSprites[spriteId].oam.objMode = 1; + spriteId = gTasks[taskId].data[9]; + gSprites[spriteId].pos1.x = 0x64; + gSprites[spriteId].pos1.y = 0x4B; + gSprites[spriteId].invisible = 0; + gSprites[spriteId].oam.objMode = 1; + sub_8031BAC(taskId, 2); + sub_8031D34(taskId, 1); + sub_8032318(0); + StringExpandPlaceholders(gStringVar4, gText_Birch_YourePlayer); + AddTextPrinterForMessage(1); + gTasks[taskId].func = task_new_game_prof_birch_speech_part2_7; + } +} + +void task_new_game_prof_birch_speech_part2_7(u8 taskId) +{ + if (gTasks[taskId].data[5]) + { + gSprites[gTasks[taskId].data[8]].oam.objMode = 0; + gSprites[gTasks[taskId].data[9]].oam.objMode = 0; + if (!sub_8197224()) + { + gSprites[gTasks[taskId].data[8]].oam.objMode = 1; + gSprites[gTasks[taskId].data[9]].oam.objMode = 1; + sub_8031ACC(taskId, 2); + sub_8031C88(taskId, 1); + gTasks[taskId].data[7] = 64; + gTasks[taskId].func = task_new_game_prof_birch_speech_part2_8; + } + } +} + +void task_new_game_prof_birch_speech_part2_8(u8 taskId) +{ + u8 spriteId; + + if (gTasks[taskId].data[5]) + { + gSprites[gTasks[taskId].data[8]].invisible = 1; + gSprites[gTasks[taskId].data[9]].invisible = 1; + if (gTasks[taskId].data[7]) + { + gTasks[taskId].data[7]--; + return; + } + if (gSaveBlock2Ptr->playerGender != MALE) + spriteId = gTasks[taskId].data[11]; + else + spriteId = gTasks[taskId].data[10]; + gSprites[spriteId].pos1.x = 0x78; + gSprites[spriteId].pos1.y = 0x3C; + gSprites[spriteId].invisible = 0; + gSprites[spriteId].oam.objMode = 1; + gTasks[taskId].data[2] = spriteId; + sub_8031BAC(taskId, 2); + sub_8031D34(taskId, 1); + StringExpandPlaceholders(gStringVar4, gText_Birch_AreYouReady); + AddTextPrinterForMessage(1); + gTasks[taskId].func = task_new_game_prof_birch_speech_part2_9; + } +} + +void task_new_game_prof_birch_speech_part2_9(u8 taskId) +{ + u8 spriteId; + + if (gTasks[taskId].data[5]) + { + gSprites[gTasks[taskId].data[2]].oam.objMode = 0; + if (!sub_8197224()) + { + spriteId = gTasks[taskId].data[2]; + gSprites[spriteId].oam.affineMode = 1; + gSprites[spriteId].affineAnims = gUnknown_082FF114; + InitSpriteAffineAnim(&gSprites[spriteId]); + StartSpriteAffineAnim(&gSprites[spriteId], 0); + gSprites[spriteId].callback = sub_80318D8; + BeginNormalPaletteFade(0xFFFF, 0, 0, 16, 0); + FadeOutBGM(4); + gTasks[taskId].func = task_new_game_prof_birch_speech_part2_10; + } + } +} + +void task_new_game_prof_birch_speech_part2_10(u8 taskId) +{ + u8 spriteId = gTasks[taskId].data[2]; + + if (gSprites[spriteId].affineAnimEnded) + gTasks[taskId].func = task_new_game_prof_birch_speech_part2_11; +} + +void task_new_game_prof_birch_speech_part2_11(u8 taskId) +{ + u8 spriteId; + + if (!gPaletteFade.active) + { + spriteId = gTasks[taskId].data[2]; + gSprites[spriteId].callback = nullsub_11; + SetGpuReg(REG_OFFSET_DISPCNT, 0x1040); + BeginNormalPaletteFade(-0x10000, 0, 0, 16, -1); + gTasks[taskId].func = task_new_game_prof_birch_speech_part2_12; + } +} + +void task_new_game_prof_birch_speech_part2_12(u8 taskId) +{ + if (!gPaletteFade.active) + { + FreeAllWindowBuffers(); + sub_818D820(gTasks[taskId].data[9]); + dp13_810BB8C(); + SetMainCallback2(CB2_NewGame); + DestroyTask(taskId); + } +} + +void new_game_prof_birch_speech_part2_start(void) +{ + u8 taskId; + u8 spriteId; + u16 savedIme; + + ResetBgsAndClearDma3BusyFlags(0); + SetGpuReg(REG_OFFSET_DISPCNT, 0); + SetGpuReg(REG_OFFSET_DISPCNT, 0x1040); + InitBgsFromTemplates(0, gUnknown_082FF0E8, 2); + InitBgFromTemplate(&gUnknown_082FF0F0); + SetVBlankCallback(NULL); + SetGpuReg(REG_OFFSET_BG2CNT, 0); + SetGpuReg(REG_OFFSET_BG1CNT, 0); + SetGpuReg(REG_OFFSET_BG0CNT, 0); + SetGpuReg(REG_OFFSET_BG2HOFS, 0); + SetGpuReg(REG_OFFSET_BG2VOFS, 0); + SetGpuReg(REG_OFFSET_BG1HOFS, 0); + SetGpuReg(REG_OFFSET_BG1VOFS, 0); + SetGpuReg(REG_OFFSET_BG0HOFS, 0); + SetGpuReg(REG_OFFSET_BG0VOFS, 0); + DmaFill16(3, 0, VRAM, VRAM_SIZE); + DmaFill32(3, 0, OAM, OAM_SIZE); + DmaFill16(3, 0, PLTT, PLTT_SIZE); + ResetPaletteFade(); + LZ77UnCompVram(gBirchIntroShadowGfx, (u8*)VRAM); + LZ77UnCompVram(gUnknown_082FEEF0, (u8*)(VRAM + 0x3800)); + LoadPalette(gUnknown_082FECFC, 0, 64); + LoadPalette(&gUnknown_082FF018[1], 1, 16); + ResetTasks(); + taskId = CreateTask(task_new_game_prof_birch_speech_part2_1, 0); + gTasks[taskId].data[7] = 5; + gTasks[taskId].data[4] = -60; + ScanlineEffect_Stop(); + ResetSpriteData(); + FreeAllSpritePalettes(); + dp13_810BB8C(); + AddBirchSpeechObjects(taskId); + if (gSaveBlock2Ptr->playerGender != MALE) + { + gTasks[taskId].data[6] = FEMALE; + spriteId = gTasks[taskId].data[11]; + } + else + { + gTasks[taskId].data[6] = MALE; + spriteId = gTasks[taskId].data[10]; + } + gSprites[spriteId].pos1.x = 0xB4; + gSprites[spriteId].pos1.y = 0x3C; + gSprites[spriteId].invisible = 0; + gTasks[taskId].data[2] = spriteId; + SetGpuReg(REG_OFFSET_BG1HOFS, -60); + BeginNormalPaletteFade(-1, 0, 16, 0, 0); + SetGpuReg(REG_OFFSET_WIN0H, 0); + SetGpuReg(REG_OFFSET_WIN0V, 0); + SetGpuReg(REG_OFFSET_WININ, 0); + SetGpuReg(REG_OFFSET_WINOUT, 0); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + ShowBg(0); + ShowBg(1); + savedIme = REG_IME; + REG_IME = 0; + REG_IE |= 1; + REG_IME = savedIme; + SetVBlankCallback(VBlankCB_MainMenu); + SetMainCallback2(CB2_MainMenu); + InitWindows(gUnknown_082FF080); + LoadMainMenuWindowFrameTiles(0, 0xF3); + copy_textbox_border_tile_patterns_to_vram(0, 0xFC, 0xF0); + PutWindowTilemap(0); + CopyWindowToVram(0, 3); +} + +void nullsub_11(struct Sprite *sprite) +{ +} + +void sub_80318D8(struct Sprite *sprite) +{ + u32 y; + + y = (sprite->pos1.y << 16) + sprite->data[0] + 0xC000; + sprite->pos1.y = y >> 16; + sprite->data[0] = y; +} + +u8 sub_80318F4(u8 a, u8 b) +{ + return sub_818D3E4(SPECIES_LOTAD, 8, 0, 1, a, b, 14, -1); +} + +void AddBirchSpeechObjects(u8 taskId) +{ + u8 spriteId = AddNewGameBirchObject(0x88, 0x3C, 1); + u8 spriteId2; + u8 spriteId3; + u8 spriteId4; + + gSprites[spriteId].callback = nullsub_11; + gSprites[spriteId].oam.priority = 0; + gSprites[spriteId].invisible = 1; + gTasks[taskId].data[8] = spriteId; + spriteId2 = sub_80318F4(100, 0x4B); + gSprites[spriteId2].callback = nullsub_11; + gSprites[spriteId2].oam.priority = 0; + gSprites[spriteId2].invisible = 1; + gTasks[taskId].data[9] = spriteId2; + spriteId3 = CreateTrainerSprite(sub_806EFF0(0x3C), 0x78, 0x3C, 0, gDecompressionBuffer); + gSprites[spriteId3].callback = nullsub_11; + gSprites[spriteId3].invisible = 1; + gSprites[spriteId3].oam.priority = 0; + gTasks[taskId].data[10] = spriteId3; + spriteId4 = CreateTrainerSprite(sub_806EFF0(0x3F), 0x78, 0x3C, 0, &gDecompressionBuffer[0x800]); + gSprites[spriteId4].callback = nullsub_11; + gSprites[spriteId4].invisible = 1; + gSprites[spriteId4].oam.priority = 0; + gTasks[taskId].data[11] = spriteId4; +} + +void sub_8031A5C(u8 taskId) +{ + int alpha; + + if (gTasks[taskId].data[1] == 0) + { + gTasks[gTasks[taskId].data[0]].data[5] = 1; + DestroyTask(taskId); + } + else if (gTasks[taskId].data[4]) + { + gTasks[taskId].data[4]--; + } + else + { + gTasks[taskId].data[4] = gTasks[taskId].data[3]; + gTasks[taskId].data[1]--; + gTasks[taskId].data[2]++; + alpha = gTasks[taskId].data[2] << 8; + SetGpuReg(REG_OFFSET_BLDALPHA, gTasks[taskId].data[1] + alpha); + } +} + +void sub_8031ACC(u8 taskId, u8 a) +{ + u8 taskId2; + + SetGpuReg(REG_OFFSET_BLDCNT, 0x250); + SetGpuReg(REG_OFFSET_BLDALPHA, 16); + SetGpuReg(REG_OFFSET_BLDY, 0); + gTasks[taskId].data[5] = 0; + taskId2 = CreateTask(sub_8031A5C, 0); + gTasks[taskId2].data[0] = taskId; + gTasks[taskId2].data[1] = 16; + gTasks[taskId2].data[2] = 0; + gTasks[taskId2].data[3] = a; + gTasks[taskId2].data[4] = a; +} + +void sub_8031B3C(u8 taskId) +{ + int alpha; + + if (gTasks[taskId].data[1] == 16) + { + gTasks[gTasks[taskId].data[0]].data[5] = 1; + DestroyTask(taskId); + } + else if (gTasks[taskId].data[4]) + { + gTasks[taskId].data[4]--; + } + else + { + gTasks[taskId].data[4] = gTasks[taskId].data[3]; + gTasks[taskId].data[1]++; + gTasks[taskId].data[2]--; + alpha = gTasks[taskId].data[2] << 8; + SetGpuReg(REG_OFFSET_BLDALPHA, gTasks[taskId].data[1] + alpha); + } +} + +void sub_8031BAC(u8 taskId, u8 a) +{ + u8 taskId2; + + SetGpuReg(REG_OFFSET_BLDCNT, 0x250); + SetGpuReg(REG_OFFSET_BLDALPHA, 0x1000); + SetGpuReg(REG_OFFSET_BLDY, 0); + gTasks[taskId].data[5] = 0; + taskId2 = CreateTask(sub_8031B3C, 0); + gTasks[taskId2].data[0] = taskId; + gTasks[taskId2].data[1] = 0; + gTasks[taskId2].data[2] = 16; + gTasks[taskId2].data[3] = a; + gTasks[taskId2].data[4] = a; +} + +void sub_8031C1C(u8 taskId) +{ + if (gTasks[taskId].data[2]) + { + gTasks[taskId].data[2]--; + } + else if (gTasks[taskId].data[1] == 8) + { + DestroyTask(taskId); + } + else if (gTasks[taskId].data[4]) + { + gTasks[taskId].data[4]--; + } + else + { + gTasks[taskId].data[4] = gTasks[taskId].data[3]; + gTasks[taskId].data[1]++; + LoadPalette(&gUnknown_082FF018[gTasks[taskId].data[1]], 1, 16); + } +} + +void sub_8031C88(u8 taskId, u8 a) +{ + u8 taskId2; + + taskId2 = CreateTask(sub_8031C1C, 0); + gTasks[taskId2].data[0] = taskId; + gTasks[taskId2].data[1] = 0; + gTasks[taskId2].data[2] = 8; + gTasks[taskId2].data[3] = a; + gTasks[taskId2].data[4] = a; +} + +void sub_8031CC8(u8 taskId) +{ + if (gTasks[taskId].data[2]) + { + gTasks[taskId].data[2]--; + } + else if (gTasks[taskId].data[1] == 0) + { + DestroyTask(taskId); + } + else if (gTasks[taskId].data[4]) + { + gTasks[taskId].data[4]--; + } + else + { + gTasks[taskId].data[4] = gTasks[taskId].data[3]; + gTasks[taskId].data[1]--; + LoadPalette(&gUnknown_082FF018[gTasks[taskId].data[1]], 1, 16); + } +} + +void sub_8031D34(u8 taskId, u8 a) +{ + u8 taskId2; + + taskId2 = CreateTask(sub_8031CC8, 0); + gTasks[taskId2].data[0] = taskId; + gTasks[taskId2].data[1] = 8; + gTasks[taskId2].data[2] = 8; + gTasks[taskId2].data[3] = a; + gTasks[taskId2].data[4] = a; +} + +void sub_8031D74(void) +{ + DrawMainMenuWindowBorder(gUnknown_082FF088, 0xF3); + FillWindowPixelBuffer(1, 17); + PrintMenuTable(1, 2, gUnknown_082FF118); + InitMenuInUpperLeftCornerPlaySoundWhenAPressed(1, 2, 0); + PutWindowTilemap(1); + CopyWindowToVram(1, 3); +} + +s8 sub_8031DB4(void) +{ + return ProcessMenuInputNoWrapAround(); +} + +void set_default_player_name(u8 nameId) +{ + u8* name; + u8 i; + + if (gSaveBlock2Ptr->playerGender == MALE) + name = gMalePresetNames[nameId]; + else + name = gFemalePresetNames[nameId]; + for (i = 0; i < 7; i++) + gSaveBlock2Ptr->playerName[i] = name[i]; + gSaveBlock2Ptr->playerName[7] = 0xFF; +} + +void CreateMainMenuErrorWindow(u8* str) +{ + FillWindowPixelBuffer(7, 17); + PrintTextOnWindow(7, 1, str, 0, 1, 2, 0); + PutWindowTilemap(7); + CopyWindowToVram(7, 2); + DrawMainMenuWindowBorder(gUnknown_082FF070, 0x1D5); + SetGpuReg(REG_OFFSET_WIN0H, 0x9E7); + SetGpuReg(REG_OFFSET_WIN0V, 0x719F); +} + +void fmt_savegame(void) +{ + fmt_time(); + fmt_pokedex(); + fmt_player(); + fmt_badges(); +} + +void fmt_time(void) +{ + StringExpandPlaceholders(gStringVar4, gText_ContinueMenuPlayer); + box_print(2, 1, 0, 17, gUnknown_082FF0E3, -1, gStringVar4); + box_print(2, 1, GetStringRightAlignXOffset(1, gSaveBlock2Ptr->playerName, 100), 17, gUnknown_082FF0E3, -1, gSaveBlock2Ptr->playerName); +} + +void fmt_player(void) +{ + u8 str[0x20]; + u8* ptr; + + StringExpandPlaceholders(gStringVar4, gText_ContinueMenuTime); + box_print(2, 1, 0x6C, 17, gUnknown_082FF0E3, -1, gStringVar4); + ptr = ConvertIntToDecimalStringN(str, gSaveBlock2Ptr->playTimeHours, 0, 3); + *ptr = 0xF0; + ConvertIntToDecimalStringN(ptr + 1, gSaveBlock2Ptr->playTimeMinutes, 2, 2); + box_print(2, 1, GetStringRightAlignXOffset(1, str, 0xD0), 17, gUnknown_082FF0E3, -1, str); +} + +void fmt_pokedex(void) +{ + u8 str[0x20]; + u16 dexCount; + + if (FlagGet(FLAG_SYS_POKEDEX_GET) == TRUE) + { + if (IsNationalPokedexEnabled()) + dexCount = pokedex_count(1); + else + dexCount = sub_80C0844(1); + StringExpandPlaceholders(gStringVar4, gText_ContinueMenuPokedex); + box_print(2, 1, 0, 33, gUnknown_082FF0E3, -1, gStringVar4); + ConvertIntToDecimalStringN(str, dexCount, 0, 3); + box_print(2, 1, GetStringRightAlignXOffset(1, str, 100), 33, gUnknown_082FF0E3, -1, str); + } +} + +void fmt_badges(void) +{ + u8 str[0x20]; + u8 badgeCount = 0; + u32 i; + + for (i = FLAG_BADGE01_GET; i <= FLAG_BADGE08_GET; i++) + { + if (FlagGet(i)) + badgeCount++; + } + StringExpandPlaceholders(gStringVar4, gText_ContinueMenuBadges); + box_print(2, 1, 0x6C, 33, gUnknown_082FF0E3, -1, gStringVar4); + ConvertIntToDecimalStringN(str, badgeCount, 2, 1); + box_print(2, 1, GetStringRightAlignXOffset(1, str, 0xD0), 33, gUnknown_082FF0E3, -1, str); +} + +void LoadMainMenuWindowFrameTiles(u8 bgId, u16 tileOffset) +{ + LoadBgTiles(bgId, GetWindowFrameTilesPal(gSaveBlock2Ptr->optionsWindowFrameType)->tiles, 0x120, tileOffset); + LoadPalette(GetWindowFrameTilesPal(gSaveBlock2Ptr->optionsWindowFrameType)->pal, 32, 32); +} + +void DrawMainMenuWindowBorder(struct WindowTemplate *template, u16 baseTileNum) +{ + u16 r9 = 1 + baseTileNum; + u16 r10 = 2 + baseTileNum; + u16 sp18 = 3 + baseTileNum; + u16 spC = 5 + baseTileNum; + u16 sp10 = 6 + baseTileNum; + u16 sp14 = 7 + baseTileNum; + u16 r6 = 8 + baseTileNum; + + FillBgTilemapBufferRect(template->priority, baseTileNum, template->tilemapLeft - 1, template->tilemapTop - 1, 1, 1, 2); + FillBgTilemapBufferRect(template->priority, r9, template->tilemapLeft, template->tilemapTop - 1, template->width, 1, 2); + FillBgTilemapBufferRect(template->priority, r10, template->tilemapLeft + template->width, template->tilemapTop - 1, 1, 1, 2); + FillBgTilemapBufferRect(template->priority, sp18, template->tilemapLeft - 1, template->tilemapTop, 1, template->height, 2); + FillBgTilemapBufferRect(template->priority, spC, template->tilemapLeft + template->width, template->tilemapTop, 1, template->height, 2); + FillBgTilemapBufferRect(template->priority, sp10, template->tilemapLeft - 1, template->tilemapTop + template->height, 1, 1, 2); + FillBgTilemapBufferRect(template->priority, sp14, template->tilemapLeft, template->tilemapTop + template->height, template->width, 1, 2); + FillBgTilemapBufferRect(template->priority, r6, template->tilemapLeft + template->width, template->tilemapTop + template->height, 1, 1, 2); + CopyBgTilemapBufferToVram(template->priority); +} + +void sub_8032250(struct WindowTemplate *template) +{ + FillBgTilemapBufferRect(template->priority, 0, template->tilemapLeft - 1, template->tilemapTop - 1, template->tilemapLeft + template->width + 1, template->tilemapTop + template->height + 1, 2); + CopyBgTilemapBufferToVram(template->priority); +} + +void sub_8032298(u8 a, u8 b, u8 c, u8 d, u8 e, u8 unused) +{ + FillBgTilemapBufferRect(a, 0, b + 0xFF, c + 0xFF, d + 2, e + 2, 2); +} + +void sub_80322E0(u8 windowId, u8 a) +{ + CallWindowFunction(windowId, sub_8032298); + FillWindowPixelBuffer(windowId, 17); + ClearWindowTilemap(windowId); + if (a == 1) + CopyWindowToVram(windowId, 3); +} + +void sub_8032318(u8 a) +{ + u8 fontAttribute = GetFontAttribute(1, 6); + u8 fontAttribute2 = GetFontAttribute(1, 0); + u8 fontAttribute3 = GetFontAttribute(1, 1); + u8 windowAttribute = GetWindowAttribute(a, 3); + u8 windowAttribute2 = GetWindowAttribute(a, 4); + + FillWindowPixelRect(a, fontAttribute, 0, 0, fontAttribute2 * windowAttribute, fontAttribute3 * windowAttribute2); + CopyWindowToVram(a, 2); +} + +void sub_80323A0(struct TextSubPrinter *printer, u16 a) +{ + if (*(printer->current_text_offset - 2) == 8 && gUnknown_02022D04 == 0) + { + gUnknown_02022D04 = 1; + CreateTask(sub_8030A70, 0); + } +} + +void sub_80323CC(u8 a, u8 b, u16 c, u16 d, u8 e, u8 f) +{ + struct WindowTemplate sp; + struct WindowTemplate sp2; + + sp = sub_8198A50(0, a + 1, b + 1, 5, 4, f, d); + sp2 = sp; + CreateYesNoMenu(&sp2, c, e, 0); +} + +void unknown_rbox_to_vram(u8 windowId, u8 a) +{ + CallWindowFunction(windowId, sub_8032474); + FillWindowPixelBuffer(windowId, 17); + PutWindowTilemap(windowId); + if (a == 1) + CopyWindowToVram(windowId, 3); +} + +void sub_8032474 (u8 a, u8 b, u8 c, u8 d, u8 e, u8 f) +{ + FillBgTilemapBufferRect(a, 0xFD, b-2, c-1, 1, 1, f); + FillBgTilemapBufferRect(a, 0xFF, b-1, c-1, 1, 1, f); + FillBgTilemapBufferRect(a, 0x100, b, c-1, d, 1, f); + FillBgTilemapBufferRect(a, 0x101, b+d-1, c-1, 1, 1, f); + FillBgTilemapBufferRect(a, 0x102, b+d, c-1, 1, 1, f); + FillBgTilemapBufferRect(a, 0x103, b-2, c, 1, 5, f); + FillBgTilemapBufferRect(a, 0x105, b-1, c, d+1, 5, f); + FillBgTilemapBufferRect(a, 0x106, b+d, c, 1, 5, f); + FillBgTilemapBufferRect(a, 0x8FD, b-2, c+e, 1, 1, f); + FillBgTilemapBufferRect(a, 0x8FF, b-1, c+e, 1, 1, f); + FillBgTilemapBufferRect(a, 0x900, b, c+e, d-1, 1, f); + FillBgTilemapBufferRect(a, 0x901, b+d-1, c+e, 1, 1, f); + FillBgTilemapBufferRect(a, 0x902, b+d, c+e, 1, 1, f); +} + +void task_new_game_prof_birch_speech_part2_1(u8 taskId) +{ + if (gTasks[taskId].data[7]-- <= 0) + { + unknown_rbox_to_vram(0, 1); + gTasks[taskId].func = task_new_game_prof_birch_speech_part2_2; + } +} From 42cfbcb197bb271e675a4b2b9e70a2647bd65532 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Sun, 11 Feb 2018 18:00:45 -0500 Subject: [PATCH 04/11] some fixes --- include/graphics.h | 9 +++++++++ src/main_menu.c | 16 +++++----------- sym_ewram.txt | 5 +---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/graphics.h b/include/graphics.h index 39662c8c1f..4eac258565 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -2713,6 +2713,15 @@ extern const u8 gRaySceneHushBg_Pal[]; extern const u8 gRaySceneHushBg_Gfx[]; extern const u8 gRaySceneHushRing_Gfx[]; +//main menu/birch graphics +extern const u16 gMainMenuBgPal[]; +extern const u16 gMainMenuTextPal[]; +extern const u16 gUnknown_082FECFC[]; +extern const u16 gUnknown_082FF028[]; +extern const u16 gUnknown_082FF018[]; +extern const u8 gBirchIntroShadowGfx[]; +extern const u8 gUnknown_082FEEF0[]; + //menu graphics extern const u16 gFireRedMenuElements1_Pal[16]; extern const u16 gFireRedMenuElements2_Pal[16]; diff --git a/src/main_menu.c b/src/main_menu.c index f4241edb07..c8a8682519 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -11,6 +11,7 @@ #include "event_data.h" #include "field_effect.h" #include "gpu_regs.h" +#include "graphics.h" #include "international_string_util.h" #include "link.h" #include "main.h" @@ -43,8 +44,8 @@ // Static RAM declarations -extern u8 gUnknown_02022D04; -extern u16 gUnknown_02022D06; +EWRAM_DATA u8 gUnknown_02022D04 = 0; +EWRAM_DATA u16 gUnknown_02022D06 = 0; IWRAM_DATA u8 gUnknown_03000DD0; @@ -67,8 +68,6 @@ struct ArrowStruct { u16 unk6[5]; }; -extern u16 gMainMenuBgPal[]; -extern u16 gMainMenuTextPal[]; extern struct BgTemplate gUnknown_082FF0E8[]; extern struct WindowTemplate gUnknown_082FF038[]; extern struct WindowTemplate gUnknown_082FF070[]; @@ -76,13 +75,8 @@ extern u8 gUnknown_082FF0E0[]; extern struct WindowTemplate gUnknown_082FF048[]; extern struct ArrowStruct gUnknown_082FF0F4; extern struct BgTemplate gUnknown_082FF0F0; -extern u8 gBirchIntroShadowGfx[]; -extern u8 gUnknown_082FEEF0[]; -extern u16 gUnknown_082FECFC[]; -extern u16 gUnknown_082FF028[]; extern struct WindowTemplate gUnknown_082FF080[]; extern const union AffineAnimCmd *const gUnknown_082FF114[]; -extern u16 gUnknown_082FF018[]; extern struct WindowTemplate gUnknown_082FF088[]; extern const struct MenuAction gUnknown_082FF118[]; extern u8* gMalePresetNames[]; @@ -93,7 +87,7 @@ u32 InitMainMenu(bool8); void Task_MainMenuCheckSaveFile(u8); void Task_MainMenuCheckBattery(u8); void Task_WaitForSaveFileErrorWindow(u8); -void CreateMainMenuErrorWindow(u8*); +void CreateMainMenuErrorWindow(const u8*); void sub_8032250(struct WindowTemplate*); void Task_DisplayMainMenu(u8); void Task_WaitForBatteryDryErrorWindow(u8); @@ -1686,7 +1680,7 @@ void set_default_player_name(u8 nameId) gSaveBlock2Ptr->playerName[7] = 0xFF; } -void CreateMainMenuErrorWindow(u8* str) +void CreateMainMenuErrorWindow(const u8* str) { FillWindowPixelBuffer(7, 17); PrintTextOnWindow(7, 1, str, 0, 1, 2, 0); diff --git a/sym_ewram.txt b/sym_ewram.txt index fb7c7a4e7b..d94cde7884 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -179,10 +179,7 @@ gUnknown_02022D00: @ 2022D00 .space 0x4 gUnknown_02022D04: @ 2022D04 - .space 0x2 - -gUnknown_02022D06: @ 2022D06 - .space 0x2 + .include "src/main_menu.o" gUnknown_02022D08: @ 2022D08 .space 0x1 From e375606810395d3941f2866505c6516949393d2b Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Tue, 13 Feb 2018 21:52:33 +0530 Subject: [PATCH 05/11] [Do not Merge] fldeff_strength.s --- asm/fldeff_strength.s | 88 +++++++++++++++++----------------- include/rom6.h | 2 + ld_script.txt | 1 + src/fldeff_strength.c | 109 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 156 insertions(+), 44 deletions(-) create mode 100644 src/fldeff_strength.c diff --git a/asm/fldeff_strength.s b/asm/fldeff_strength.s index fdadd2aacb..a0a3f932d6 100644 --- a/asm/fldeff_strength.s +++ b/asm/fldeff_strength.s @@ -5,51 +5,51 @@ .text - thumb_func_start hm_prepare_rocksmash -hm_prepare_rocksmash: @ 8145DC4 - push {r4,lr} - movs r0, 0x57 - bl npc_before_player_of_type - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08145DD8 - movs r0, 0 - b _08145DF2 -_08145DD8: - ldr r4, =gSpecialVar_Result - bl GetCursorSelectionMonId - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4] - ldr r1, =gUnknown_03005DB0 - ldr r0, =FieldCallback_Teleport - str r0, [r1] - ldr r1, =gUnknown_0203CEEC - ldr r0, =sub_8145E0C - str r0, [r1] - movs r0, 0x1 -_08145DF2: - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end hm_prepare_rocksmash +// thumb_func_start hm_prepare_rocksmash +//hm_prepare_rocksmash: @ 8145DC4 +// push {r4,lr} +// movs r0, 0x57 +// bl npc_before_player_of_type +// lsls r0, 24 +// lsrs r0, 24 +// cmp r0, 0x1 +// beq _08145DD8 +// movs r0, 0 +// b _08145DF2 +//_08145DD8: +// ldr r4, =gSpecialVar_Result +// bl GetCursorSelectionMonId +// lsls r0, 24 +// lsrs r0, 24 +// strh r0, [r4] +// ldr r1, =gUnknown_03005DB0 +// ldr r0, =FieldCallback_Teleport +// str r0, [r1] +// ldr r1, =gUnknown_0203CEEC +// ldr r0, =sub_8145E0C +// str r0, [r1] +// movs r0, 0x1 +//_08145DF2: +// pop {r4} +// pop {r1} +// bx r1 +// .pool +// thumb_func_end hm_prepare_rocksmash - thumb_func_start sub_8145E0C -sub_8145E0C: @ 8145E0C - push {lr} - bl GetCursorSelectionMonId - ldr r1, =gFieldEffectArguments - lsls r0, 24 - lsrs r0, 24 - str r0, [r1] - ldr r0, =FieryPath_EventScript_2908FD - bl ScriptContext1_SetupScript - pop {r0} - bx r0 - .pool - thumb_func_end sub_8145E0C +// thumb_func_start sub_8145E0C +//sub_8145E0C: @ 8145E0C +// push {lr} +// bl GetCursorSelectionMonId +// ldr r1, =gFieldEffectArguments +// lsls r0, 24 +// lsrs r0, 24 +// str r0, [r1] +// ldr r0, =FieryPath_EventScript_2908FD +// bl ScriptContext1_SetupScript +// pop {r0} +// bx r0 +// .pool +// thumb_func_end sub_8145E0C thumb_func_start sub_8145E2C sub_8145E2C: @ 8145E2C diff --git a/include/rom6.h b/include/rom6.h index f91b34b4a7..058504fe24 100644 --- a/include/rom6.h +++ b/include/rom6.h @@ -11,6 +11,8 @@ void UpdateBirchState(u16 days); void UpdateFrontierManiac(u16 days); void UpdateFrontierGambler(u16 days); void SetShoalItemFlag(u16 days); + +bool8 npc_before_player_of_type(u8); u8 oei_task_add(void); #endif //GUARD_ROM6_H diff --git a/ld_script.txt b/ld_script.txt index 838c468adb..fcecdd4beb 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -193,6 +193,7 @@ SECTIONS { asm/pokedex_cry_screen.o(.text); src/coins.o(.text); src/landmark.o(.text); + src/fldeff_strength.o(.text); asm/fldeff_strength.o(.text); src/battle_transition.o(.text); src/battle_controller_link_partner.o(.text); diff --git a/src/fldeff_strength.c b/src/fldeff_strength.c new file mode 100644 index 0000000000..77fa0db359 --- /dev/null +++ b/src/fldeff_strength.c @@ -0,0 +1,109 @@ +#include "global.h" +#include "field_effect.h" +#include "rom6.h" +#include "party_menu.h" + +#include "script.h" + +extern u16 gSpecialVar_Result; +extern void (*gUnknown_0203CEEC)(void); +extern bool8 (*gUnknown_03005DB0)(void); +static void sub_8145E0C(void); + +extern u8 FieryPath_EventScript_2908FD[]; + +bool8 hm_prepare_rocksmash(void) +{ + if (npc_before_player_of_type(87) == TRUE) + { + gSpecialVar_Result = GetCursorSelectionMonId(); + gUnknown_03005DB0 = FieldCallback_Teleport; + gUnknown_0203CEEC = sub_8145E0C; + return TRUE; + } + return FALSE; +} + +static void sub_8145E0C(void) +{ + gFieldEffectArguments[0] = GetCursorSelectionMonId(); + ScriptContext1_SetupScript(FieryPath_EventScript_2908FD); +} + +/* +#include "braille_puzzles.h" +#include "field_effect.h" +#include "party_menu.h" +#include "pokemon.h" +#include "pokemon_menu.h" + +#include "script.h" +#include "task.h" +#include "text.h" + +static void sub_811AA18(void); +static void sub_811AA38(void); +static void sub_811AA9C(void); + +extern u8 gLastFieldPokeMenuOpened; +extern u16 gSpecialVar_Result; +extern void (*gFieldCallback)(void); +extern void (*gUnknown_03005CE4)(void); + +extern u8 S_UseStrength[]; + +bool8 SetUpFieldMove_Strength(void) +{ + if (ShouldDoBrailleStrengthEffect()) + { + gSpecialVar_Result = gLastFieldPokeMenuOpened; + gFieldCallback = FieldCallback_Teleport; + gUnknown_03005CE4 = sub_811AA38; + } + else + { + if (npc_before_player_of_type(87) != TRUE) + return 0; + gSpecialVar_Result = gLastFieldPokeMenuOpened; + gFieldCallback = FieldCallback_Teleport; + gUnknown_03005CE4 = sub_811AA18; + } + + return TRUE; +} + +static void sub_811AA18(void) +{ + gFieldEffectArguments[0] = gLastFieldPokeMenuOpened; + ScriptContext1_SetupScript(S_UseStrength); +} + +static void sub_811AA38(void) +{ + gFieldEffectArguments[0] = gLastFieldPokeMenuOpened; + FieldEffectStart(FLDEFF_USE_STRENGTH); +} + +bool8 FldEff_UseStrength(void) +{ + u8 taskId = oei_task_add(); + + gTasks[taskId].data[8] = (u32)sub_811AA9C >> 16; + gTasks[taskId].data[9] = (u32)sub_811AA9C; + GetMonNickname(&gPlayerParty[gFieldEffectArguments[0]], gStringVar1); + return FALSE; +} + +static void sub_811AA9C(void) +{ + if (ShouldDoBrailleStrengthEffect()) + { + DoBrailleStrengthEffect(); + } + else + { + FieldEffectActiveListRemove(40); + EnableBothScriptContexts(); + } +} +*/ From c959dc11748f3548d5356526f29bc64e355deca9 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Tue, 13 Feb 2018 23:08:54 +0530 Subject: [PATCH 06/11] Finish fldeff_strength.s --- asm/fldeff_strength.s | 93 ----------------------------------------- include/event_scripts.h | 2 + include/field_effect.h | 2 + ld_script.txt | 3 +- src/fldeff_strength.c | 91 ++++++---------------------------------- src/fldeff_teleport.c | 7 +--- 6 files changed, 20 insertions(+), 178 deletions(-) delete mode 100644 asm/fldeff_strength.s diff --git a/asm/fldeff_strength.s b/asm/fldeff_strength.s deleted file mode 100644 index a0a3f932d6..0000000000 --- a/asm/fldeff_strength.s +++ /dev/null @@ -1,93 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - -// thumb_func_start hm_prepare_rocksmash -//hm_prepare_rocksmash: @ 8145DC4 -// push {r4,lr} -// movs r0, 0x57 -// bl npc_before_player_of_type -// lsls r0, 24 -// lsrs r0, 24 -// cmp r0, 0x1 -// beq _08145DD8 -// movs r0, 0 -// b _08145DF2 -//_08145DD8: -// ldr r4, =gSpecialVar_Result -// bl GetCursorSelectionMonId -// lsls r0, 24 -// lsrs r0, 24 -// strh r0, [r4] -// ldr r1, =gUnknown_03005DB0 -// ldr r0, =FieldCallback_Teleport -// str r0, [r1] -// ldr r1, =gUnknown_0203CEEC -// ldr r0, =sub_8145E0C -// str r0, [r1] -// movs r0, 0x1 -//_08145DF2: -// pop {r4} -// pop {r1} -// bx r1 -// .pool -// thumb_func_end hm_prepare_rocksmash - -// thumb_func_start sub_8145E0C -//sub_8145E0C: @ 8145E0C -// push {lr} -// bl GetCursorSelectionMonId -// ldr r1, =gFieldEffectArguments -// lsls r0, 24 -// lsrs r0, 24 -// str r0, [r1] -// ldr r0, =FieryPath_EventScript_2908FD -// bl ScriptContext1_SetupScript -// pop {r0} -// bx r0 -// .pool -// thumb_func_end sub_8145E0C - - thumb_func_start sub_8145E2C -sub_8145E2C: @ 8145E2C - push {lr} - bl oei_task_add - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldr r2, =sub_8145E74 - lsrs r0, r2, 16 - strh r0, [r1, 0x18] - strh r2, [r1, 0x1A] - ldr r0, =gFieldEffectArguments - ldr r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - ldr r1, =gStringVar1 - bl GetMonNickname - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_8145E2C - - thumb_func_start sub_8145E74 -sub_8145E74: @ 8145E74 - push {lr} - movs r0, 0x28 - bl FieldEffectActiveListRemove - bl EnableBothScriptContexts - pop {r0} - bx r0 - thumb_func_end sub_8145E74 - - .align 2, 0 @ Don't pad with nop. diff --git a/include/event_scripts.h b/include/event_scripts.h index a54e0e463a..1038791019 100644 --- a/include/event_scripts.h +++ b/include/event_scripts.h @@ -380,4 +380,6 @@ extern const u8 SecretBase_RedCave1_Text_274E75[]; extern const u8 SecretBase_RedCave1_Text_2751E1[]; extern const u8 SecretBase_RedCave1_Text_2754F6[]; extern const u8 SecretBase_RedCave1_Text_2758CC[]; + +extern const u8 FieryPath_EventScript_2908FD[]; #endif //GUARD_EVENT_SCRIPTS_H diff --git a/include/field_effect.h b/include/field_effect.h index 7395270f91..6f5a9886f2 100644 --- a/include/field_effect.h +++ b/include/field_effect.h @@ -79,5 +79,7 @@ u8 CreateTrainerSprite(u8 trainerSpriteID, s16 x, s16 y, u8 subpriority, u8 *buf void sub_80B7FC8(void); void FieldEffectActiveListRemove(u8 id); void MultiplyInvertedPaletteRGBComponents(u16, u8, u8, u8); +extern void (*gUnknown_0203CEEC)(void); +extern bool8 (*gUnknown_03005DB0)(void); #endif //GUARD_FIELD_EFFECTS_H diff --git a/ld_script.txt b/ld_script.txt index fcecdd4beb..386d631271 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -193,8 +193,7 @@ SECTIONS { asm/pokedex_cry_screen.o(.text); src/coins.o(.text); src/landmark.o(.text); - src/fldeff_strength.o(.text); - asm/fldeff_strength.o(.text); + src/fldeff_strength.o(.text); src/battle_transition.o(.text); src/battle_controller_link_partner.o(.text); src/battle_message.o(.text); diff --git a/src/fldeff_strength.c b/src/fldeff_strength.c index 77fa0db359..9f649f56cc 100644 --- a/src/fldeff_strength.c +++ b/src/fldeff_strength.c @@ -1,16 +1,14 @@ #include "global.h" +#include "event_data.h" +#include "event_scripts.h" #include "field_effect.h" -#include "rom6.h" #include "party_menu.h" - +#include "rom6.h" #include "script.h" +#include "task.h" -extern u16 gSpecialVar_Result; -extern void (*gUnknown_0203CEEC)(void); -extern bool8 (*gUnknown_03005DB0)(void); -static void sub_8145E0C(void); - -extern u8 FieryPath_EventScript_2908FD[]; +void sub_8145E0C(void); +void sub_8145E74(void); bool8 hm_prepare_rocksmash(void) { @@ -24,86 +22,23 @@ bool8 hm_prepare_rocksmash(void) return FALSE; } -static void sub_8145E0C(void) +void sub_8145E0C(void) { gFieldEffectArguments[0] = GetCursorSelectionMonId(); ScriptContext1_SetupScript(FieryPath_EventScript_2908FD); } -/* -#include "braille_puzzles.h" -#include "field_effect.h" -#include "party_menu.h" -#include "pokemon.h" -#include "pokemon_menu.h" - -#include "script.h" -#include "task.h" -#include "text.h" - -static void sub_811AA18(void); -static void sub_811AA38(void); -static void sub_811AA9C(void); - -extern u8 gLastFieldPokeMenuOpened; -extern u16 gSpecialVar_Result; -extern void (*gFieldCallback)(void); -extern void (*gUnknown_03005CE4)(void); - -extern u8 S_UseStrength[]; - -bool8 SetUpFieldMove_Strength(void) -{ - if (ShouldDoBrailleStrengthEffect()) - { - gSpecialVar_Result = gLastFieldPokeMenuOpened; - gFieldCallback = FieldCallback_Teleport; - gUnknown_03005CE4 = sub_811AA38; - } - else - { - if (npc_before_player_of_type(87) != TRUE) - return 0; - gSpecialVar_Result = gLastFieldPokeMenuOpened; - gFieldCallback = FieldCallback_Teleport; - gUnknown_03005CE4 = sub_811AA18; - } - - return TRUE; -} - -static void sub_811AA18(void) -{ - gFieldEffectArguments[0] = gLastFieldPokeMenuOpened; - ScriptContext1_SetupScript(S_UseStrength); -} - -static void sub_811AA38(void) -{ - gFieldEffectArguments[0] = gLastFieldPokeMenuOpened; - FieldEffectStart(FLDEFF_USE_STRENGTH); -} - -bool8 FldEff_UseStrength(void) +bool8 sub_8145E2C(void) { u8 taskId = oei_task_add(); - - gTasks[taskId].data[8] = (u32)sub_811AA9C >> 16; - gTasks[taskId].data[9] = (u32)sub_811AA9C; + gTasks[taskId].data[8] = (u32)sub_8145E74 >> 16; + gTasks[taskId].data[9] = (u32)sub_8145E74; GetMonNickname(&gPlayerParty[gFieldEffectArguments[0]], gStringVar1); return FALSE; } -static void sub_811AA9C(void) +void sub_8145E74(void) { - if (ShouldDoBrailleStrengthEffect()) - { - DoBrailleStrengthEffect(); - } - else - { - FieldEffectActiveListRemove(40); - EnableBothScriptContexts(); - } + FieldEffectActiveListRemove(40); + EnableBothScriptContexts(); } -*/ diff --git a/src/fldeff_teleport.c b/src/fldeff_teleport.c index 5b3492db03..e675ef0a58 100644 --- a/src/fldeff_teleport.c +++ b/src/fldeff_teleport.c @@ -7,17 +7,14 @@ #include "rom6.h" #include "task.h" -extern bool8 (*gUnknown_03005DB0)(void); -extern void (*gUnknown_0203CEEC)(void); - bool8 SetUpFieldMove_Teleport(void) { if (Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE) { gUnknown_03005DB0 = FieldCallback_Teleport; - gUnknown_0203CEEC = hm_teleport_run_dp02scr; + gUnknown_0203CEEC = hm_teleport_run_dp02scr; return TRUE; - } + } return FALSE; } From 6ed3da2eb8513b7aa0c6e94ab42b85b2dc848c8e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 13 Feb 2018 19:31:50 -0500 Subject: [PATCH 07/11] Update devkitARM to r47 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dda07ebb4d..2067d0fdfb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ cache: apt: true install: - pushd $HOME - - travis_retry wget http://download.sourceforge.net/devkitpro/devkitARM_r46-x86_64-linux.tar.bz2 + - travis_retry wget http://download.sourceforge.net/devkitpro/devkitARM_r47-x86_64-linux.tar.bz2 - tar xf devkitARM*.tar.bz2 - travis_retry git clone https://github.com/pret/agbcc.git - cd agbcc && ./build.sh && ./install.sh $TRAVIS_BUILD_DIR From deeaac2bf17479b671d989cd50e236dd39f6e52c Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Wed, 14 Feb 2018 17:24:31 +0530 Subject: [PATCH 08/11] Decompile fldeff_sweetsecent.c --- asm/fldeff_sweetscent.s | 220 ---------------------------------- include/event_scripts.h | 1 + include/field_player_avatar.h | 1 + ld_script.txt | 2 +- src/fldeff_sweetscent.c | 98 +++++++++++++++ 5 files changed, 101 insertions(+), 221 deletions(-) delete mode 100644 asm/fldeff_sweetscent.s create mode 100644 src/fldeff_sweetscent.c diff --git a/asm/fldeff_sweetscent.s b/asm/fldeff_sweetscent.s deleted file mode 100644 index 2055f70696..0000000000 --- a/asm/fldeff_sweetscent.s +++ /dev/null @@ -1,220 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start SetUpFieldMove_SweetScent -SetUpFieldMove_SweetScent: @ 8159EF0 - ldr r1, =gUnknown_03005DB0 - ldr r0, =FieldCallback_Teleport - str r0, [r1] - ldr r1, =gUnknown_0203CEEC - ldr r0, =hm2_sweet_scent - str r0, [r1] - movs r0, 0x1 - bx lr - .pool - thumb_func_end SetUpFieldMove_SweetScent - - thumb_func_start hm2_sweet_scent -hm2_sweet_scent: @ 8159F10 - push {lr} - movs r0, 0x33 - bl FieldEffectStart - bl GetCursorSelectionMonId - ldr r1, =gFieldEffectArguments - lsls r0, 24 - lsrs r0, 24 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end hm2_sweet_scent - - thumb_func_start FldEff_SweetScent -FldEff_SweetScent: @ 8159F2C - push {lr} - bl sub_80AC3D0 - bl oei_task_add - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldr r2, =sub_8159F5C - lsrs r0, r2, 16 - strh r0, [r1, 0x18] - strh r2, [r1, 0x1A] - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end FldEff_SweetScent - - thumb_func_start sub_8159F5C -sub_8159F5C: @ 8159F5C - push {r4,r5,lr} - sub sp, 0x4 - movs r0, 0xEC - bl PlaySE - ldr r5, =gPlttBufferUnfaded - ldr r1, =gPaletteDecompressionBuffer - movs r4, 0x80 - lsls r4, 1 - adds r0, r5, 0 - adds r2, r4, 0 - bl CpuFastSet - ldr r0, =gPlttBufferFaded - adds r1, r5, 0 - adds r2, r4, 0 - bl CpuFastSet - bl GetPlayerAvatarObjectId - ldr r2, =gSprites - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r1, [r1, 0x5] - lsrs r1, 4 - adds r1, 0x10 - movs r0, 0x1 - lsls r0, r1 - mvns r0, r0 - movs r1, 0x1F - str r1, [sp] - movs r1, 0x4 - movs r2, 0 - movs r3, 0x8 - bl BeginNormalPaletteFade - ldr r0, =sub_8159FEC - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - movs r0, 0 - strh r0, [r1, 0x8] - movs r0, 0x33 - bl FieldEffectActiveListRemove - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8159F5C - - thumb_func_start sub_8159FEC -sub_8159FEC: @ 8159FEC - push {r4-r6,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0 - bne _0815A088 - bl sub_81BE72C - movs r0, 0x40 - movs r1, 0x8 - movs r2, 0x1F - bl BlendPalettes - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r4, r1, r0 - ldrh r1, [r4, 0x8] - movs r2, 0x8 - ldrsh r0, [r4, r2] - cmp r0, 0x40 - bne _0815A084 - strh r6, [r4, 0x8] - bl SweetScentWildEncounter - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0815A044 - adds r0, r5, 0 - bl DestroyTask - b _0815A088 - .pool -_0815A044: - ldr r0, =sub_815A090 - str r0, [r4] - bl GetPlayerAvatarObjectId - ldr r2, =gSprites - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r1, [r1, 0x5] - lsrs r1, 4 - adds r1, 0x10 - movs r0, 0x1 - lsls r0, r1 - mvns r0, r0 - movs r1, 0x1F - str r1, [sp] - movs r1, 0x4 - movs r2, 0x8 - movs r3, 0 - bl BeginNormalPaletteFade - bl sub_81BE6B8 - b _0815A088 - .pool -_0815A084: - adds r0, r1, 0x1 - strh r0, [r4, 0x8] -_0815A088: - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8159FEC - - thumb_func_start sub_815A090 -sub_815A090: @ 815A090 - 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 _0815A0BE - ldr r0, =gPaletteDecompressionBuffer - ldr r1, =gPlttBufferUnfaded - movs r2, 0x80 - lsls r2, 1 - bl CpuFastSet - bl sub_80AC3E4 - ldr r0, =EventScript_290CAE - bl ScriptContext1_SetupScript - adds r0, r4, 0 - bl DestroyTask -_0815A0BE: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_815A090 - - .align 2, 0 @ Don't pad with nop. - diff --git a/include/event_scripts.h b/include/event_scripts.h index 1038791019..a835782ed2 100644 --- a/include/event_scripts.h +++ b/include/event_scripts.h @@ -382,4 +382,5 @@ extern const u8 SecretBase_RedCave1_Text_2754F6[]; extern const u8 SecretBase_RedCave1_Text_2758CC[]; extern const u8 FieryPath_EventScript_2908FD[]; +extern const u8 EventScript_290CAE[]; #endif //GUARD_EVENT_SCRIPTS_H diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index 5b9a632fa3..7517fb3b85 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -5,6 +5,7 @@ void ClearPlayerAvatarInfo(void); void SetPlayerAvatarExtraStateTransition(u8, u8); u8 GetPlayerAvatarGenderByGraphicsId(u8); bool8 TestPlayerAvatarFlags(u8); +u8 GetPlayerAvatarObjectId(void); void PlayerGetDestCoords(s16 *, s16 *); u8 player_get_direction_lower_nybble(void); u8 player_get_direction_upper_nybble(void); diff --git a/ld_script.txt b/ld_script.txt index 386d631271..7b8e27e476 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -207,7 +207,7 @@ SECTIONS { asm/contest_ai.o(.text); asm/battle_anim_sound_tasks.o(.text); src/battle_controller_safari.o(.text); - asm/fldeff_sweetscent.o(.text); + src/fldeff_sweetscent.o(.text); asm/battle_anim_815A0D4.o(.text); asm/learn_move.o(.text); asm/fldeff_softboiled.o(.text); diff --git a/src/fldeff_sweetscent.c b/src/fldeff_sweetscent.c new file mode 100644 index 0000000000..ee5a393433 --- /dev/null +++ b/src/fldeff_sweetscent.c @@ -0,0 +1,98 @@ +#include "global.h" +#include "event_data.h" +#include "event_scripts.h" +#include "field_effect.h" +#include "field_player_avatar.h" +#include "palette.h" +#include "party_menu.h" +#include "rom6.h" +#include "script.h" +#include "sound.h" +#include "sprite.h" +#include "task.h" +#include "wild_encounter.h" + +extern void sub_81BE72C(void); +extern void sub_81BE6B8(void); +extern void sub_80AC3D0(void); +extern void sub_80AC3E4(void); + +void hm2_sweet_scent(void); +void sub_8159F5C(void); +void sub_8159FEC(u8 taskId); +void sub_815A090(u8 taskId); + +bool8 SetUpFieldMove_SweetScent(void) +{ + gUnknown_03005DB0 = FieldCallback_Teleport; + gUnknown_0203CEEC = hm2_sweet_scent; + return TRUE; +} + +void hm2_sweet_scent(void) +{ + FieldEffectStart(FLDEFF_SWEET_SCENT); + gFieldEffectArguments[0] = GetCursorSelectionMonId(); +} + +bool8 FldEff_SweetScent() +{ + u8 taskId; + + sub_80AC3D0(); + taskId = oei_task_add(); + gTasks[taskId].data[8] = (u32)sub_8159F5C >> 16; + gTasks[taskId].data[9] = (u32)sub_8159F5C; + return FALSE; +} + +void sub_8159F5C(void) +{ + u8 taskId; + + PlaySE(0xEC); + CpuFastSet(gPlttBufferUnfaded, gPaletteDecompressionBuffer, 0x100); + CpuFastSet(gPlttBufferFaded, gPlttBufferUnfaded, 0x100); + BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 0, 8, 0x1F); + taskId = CreateTask(sub_8159FEC, 0); + gTasks[taskId].data[0] = 0; + FieldEffectActiveListRemove(FLDEFF_SWEET_SCENT); +} + +void sub_8159FEC(u8 taskId) +{ + if (!gPaletteFade.active) + { + sub_81BE72C(); + BlendPalettes(64, 8, 0x1F); + if (gTasks[taskId].data[0] == 64) + { + gTasks[taskId].data[0] = 0; + if (SweetScentWildEncounter() == TRUE) + { + DestroyTask(taskId); + } + else + { + gTasks[taskId].func = sub_815A090; + BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 8, 0, 0x1F); + sub_81BE6B8(); + } + } + else + { + gTasks[taskId].data[0]++; + } + } +} + +void sub_815A090(u8 taskId) +{ + if (!gPaletteFade.active) + { + CpuFastSet(gPaletteDecompressionBuffer, gPlttBufferUnfaded, 0x100); + sub_80AC3E4(); + ScriptContext1_SetupScript(EventScript_290CAE); + DestroyTask(taskId); + } +} From c3c30417efdeb26a9b5f16b65aff8557e94ff438 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Wed, 14 Feb 2018 20:45:27 -0500 Subject: [PATCH 09/11] fixes --- include/constants/rgb.h | 1 + src/main_menu.c | 114 ++++++++++++++++++++++++---------------- 2 files changed, 69 insertions(+), 46 deletions(-) diff --git a/include/constants/rgb.h b/include/constants/rgb.h index 8b323799fd..fd9c5c5a73 100644 --- a/include/constants/rgb.h +++ b/include/constants/rgb.h @@ -12,5 +12,6 @@ #define RGB_YELLOW RGB(31, 31, 0) #define RGB_MAGENTA RGB(31, 0, 31) #define RGB_CYAN RGB(0, 31, 31) +#define RGB_WHITEALPHA RGB_WHITE | 0x8000 #endif // GUARD_RGB_H diff --git a/src/main_menu.c b/src/main_menu.c index ed6b79e6a7..bf282d5331 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -165,11 +165,35 @@ const u8 gUnknown_082FF0E0[] = {10, 11, 12}; const u8 gUnknown_082FF0E3[] = {10, 1, 12}; const struct BgTemplate gUnknown_082FF0E8[] = { - {0, 2, 30, 0, 0, 0, 0}, - {1, 0, 7, 0, 0, 3, 0} + { + .bg = 0, + .charBaseIndex = 2, + .mapBaseIndex = 30, + .screenSize = 0, + .paletteMode = 0, + .priority = 0, + .baseTile = 0 + }, + { + .bg = 1, + .charBaseIndex = 0, + .mapBaseIndex = 7, + .screenSize = 0, + .paletteMode = 0, + .priority = 3, + .baseTile = 0 + } }; -const struct BgTemplate gUnknown_082FF0F0 = {0, 3, 30, 0, 0, 0, 0}; +const struct BgTemplate gUnknown_082FF0F0 = { + .bg = 0, + .charBaseIndex = 3, + .mapBaseIndex = 30, + .screenSize = 0, + .paletteMode = 0, + .priority = 0, + .baseTile = 0 +}; const struct ArrowStruct gUnknown_082FF0F4 = {2, 0x78, 8, 3, 0x78, 0x98, 3, 4, 1, 1, 0}; @@ -241,6 +265,8 @@ enum HAS_MYSTERY_EVENTS, }; +#define MAIN_MENU_BORDER_TILE 0x1D5 + void CB2_MainMenu(void) { RunTasks(); @@ -266,7 +292,7 @@ void CB2_ReinitMainMenu(void) InitMainMenu(TRUE); } -u32 InitMainMenu(bool8 affects_palette_maybe) +u32 InitMainMenu(bool8 returningFromOptionsMenu) { SetVBlankCallback(NULL); @@ -292,7 +318,7 @@ u32 InitMainMenu(bool8 affects_palette_maybe) ResetTasks(); ResetSpriteData(); FreeAllSpritePalettes(); - if (affects_palette_maybe) + if (returningFromOptionsMenu) BeginNormalPaletteFade(-1, 0, 0x10, 0, 0x0000); // fade to black else BeginNormalPaletteFade(-1, 0, 0x10, 0, 0xFFFF); // fade to white @@ -304,7 +330,7 @@ u32 InitMainMenu(bool8 affects_palette_maybe) ChangeBgY(1, 0, 0); InitWindows(gUnknown_082FF038); DeactivateAllTextPrinters(); - LoadMainMenuWindowFrameTiles(0, 0x1D5); + LoadMainMenuWindowFrameTiles(0, MAIN_MENU_BORDER_TILE); SetGpuReg(REG_OFFSET_WIN0H, 0); SetGpuReg(REG_OFFSET_WIN0V, 0); @@ -478,8 +504,6 @@ void Task_DisplayMainMenu(u8 taskId) LoadPalette(&palette, 241, 2); } - - switch (gTasks[taskId].data[0]) { case HAS_NO_SAVED_GAME: @@ -492,8 +516,8 @@ void Task_DisplayMainMenu(u8 taskId) PutWindowTilemap(1); CopyWindowToVram(0, 2); CopyWindowToVram(1, 2); - DrawMainMenuWindowBorder(gUnknown_082FF038, 0x1D5); - DrawMainMenuWindowBorder(&gUnknown_082FF038[1], 0x1D5); + DrawMainMenuWindowBorder(gUnknown_082FF038, MAIN_MENU_BORDER_TILE); + DrawMainMenuWindowBorder(&gUnknown_082FF038[1], MAIN_MENU_BORDER_TILE); break; case HAS_SAVED_GAME: FillWindowPixelBuffer(2, 0xAA); @@ -509,9 +533,9 @@ void Task_DisplayMainMenu(u8 taskId) CopyWindowToVram(2, 2); CopyWindowToVram(3, 2); CopyWindowToVram(4, 2); - DrawMainMenuWindowBorder(gUnknown_082FF048, 0x1D5); - DrawMainMenuWindowBorder(&gUnknown_082FF048[1], 0x1D5); - DrawMainMenuWindowBorder(&gUnknown_082FF048[2], 0x1D5); + DrawMainMenuWindowBorder(gUnknown_082FF048, MAIN_MENU_BORDER_TILE); + DrawMainMenuWindowBorder(&gUnknown_082FF048[1], MAIN_MENU_BORDER_TILE); + DrawMainMenuWindowBorder(&gUnknown_082FF048[2], MAIN_MENU_BORDER_TILE); break; case HAS_MYSTERY_GIFT: FillWindowPixelBuffer(2, 0xAA); @@ -531,10 +555,10 @@ void Task_DisplayMainMenu(u8 taskId) CopyWindowToVram(3, 2); CopyWindowToVram(4, 2); CopyWindowToVram(5, 2); - DrawMainMenuWindowBorder(gUnknown_082FF048, 0x1D5); - DrawMainMenuWindowBorder(&gUnknown_082FF048[1], 0x1D5); - DrawMainMenuWindowBorder(&gUnknown_082FF048[2], 0x1D5); - DrawMainMenuWindowBorder(&gUnknown_082FF048[3], 0x1D5); + DrawMainMenuWindowBorder(gUnknown_082FF048, MAIN_MENU_BORDER_TILE); + DrawMainMenuWindowBorder(&gUnknown_082FF048[1], MAIN_MENU_BORDER_TILE); + DrawMainMenuWindowBorder(&gUnknown_082FF048[2], MAIN_MENU_BORDER_TILE); + DrawMainMenuWindowBorder(&gUnknown_082FF048[3], MAIN_MENU_BORDER_TILE); break; case HAS_MYSTERY_EVENTS: FillWindowPixelBuffer(2, 0xAA); @@ -558,11 +582,11 @@ void Task_DisplayMainMenu(u8 taskId) CopyWindowToVram(4, 2); CopyWindowToVram(5, 2); CopyWindowToVram(6, 2); - DrawMainMenuWindowBorder(gUnknown_082FF048, 0x1D5); - DrawMainMenuWindowBorder(&gUnknown_082FF048[1], 0x1D5); - DrawMainMenuWindowBorder(&gUnknown_082FF048[2], 0x1D5); - DrawMainMenuWindowBorder(&gUnknown_082FF048[3], 0x1D5); - DrawMainMenuWindowBorder(&gUnknown_082FF048[4], 0x1D5); + DrawMainMenuWindowBorder(gUnknown_082FF048, MAIN_MENU_BORDER_TILE); + DrawMainMenuWindowBorder(&gUnknown_082FF048[1], MAIN_MENU_BORDER_TILE); + DrawMainMenuWindowBorder(&gUnknown_082FF048[2], MAIN_MENU_BORDER_TILE); + DrawMainMenuWindowBorder(&gUnknown_082FF048[3], MAIN_MENU_BORDER_TILE); + DrawMainMenuWindowBorder(&gUnknown_082FF048[4], MAIN_MENU_BORDER_TILE); data[13] = AddScrollIndicatorArrowPair(&gUnknown_082FF0F4, &gUnknown_02022D06); gTasks[data[13]].func = Task_ScrollIndicatorArrowPairOnMainMenu; if (gUnknown_02022D06 == 4) @@ -592,13 +616,13 @@ bool8 HandleMainMenuInput(u8 taskId) { PlaySE(SE_SELECT); sub_80093CC(); - BeginNormalPaletteFade(-1, 0, 0, 0x10, 0x0000); + BeginNormalPaletteFade(-1, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].func = Task_HandleMainMenuAPressed; } else if (gMain.newKeys & B_BUTTON) { PlaySE(SE_SELECT); - BeginNormalPaletteFade(-1, 0, 0, 0x10, 0xFFFF); + BeginNormalPaletteFade(-1, 0, 0, 0x10, RGB_WHITEALPHA); SetGpuReg(REG_OFFSET_WIN0H, 0xF0); SetGpuReg(REG_OFFSET_WIN0V, 0xA0); gTasks[taskId].func = Task_HandleMainMenuBPressed; @@ -855,7 +879,7 @@ void Task_DisplayMainMenuInvalidActionError(u8 taskId) if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { PlaySE(SE_SELECT); - BeginNormalPaletteFade(-1, 0, 0, 16, 0); + BeginNormalPaletteFade(-1, 0, 0, 16, RGB_BLACK); gTasks[taskId].func = Task_HandleMainMenuBPressed; } } @@ -1274,7 +1298,7 @@ void task_new_game_prof_birch_speech_16(u8 taskId) { if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) { - BeginNormalPaletteFade(-1, 0, 0, 16, 0); + BeginNormalPaletteFade(-1, 0, 0, 16, RGB_BLACK); gTasks[taskId].func = task_new_game_prof_birch_speech_17; } } @@ -1345,17 +1369,17 @@ void task_new_game_prof_birch_speech_part2_6(u8 taskId) if (gTasks[taskId].data[5]) { - gSprites[gTasks[taskId].data[10]].invisible = 1; - gSprites[gTasks[taskId].data[11]].invisible = 1; + gSprites[gTasks[taskId].data[10]].invisible = TRUE; + gSprites[gTasks[taskId].data[11]].invisible = TRUE; spriteId = gTasks[taskId].data[8]; gSprites[spriteId].pos1.x = 0x88; gSprites[spriteId].pos1.y = 0x3C; - gSprites[spriteId].invisible = 0; + gSprites[spriteId].invisible = FALSE; gSprites[spriteId].oam.objMode = 1; spriteId = gTasks[taskId].data[9]; gSprites[spriteId].pos1.x = 0x64; gSprites[spriteId].pos1.y = 0x4B; - gSprites[spriteId].invisible = 0; + gSprites[spriteId].invisible = FALSE; gSprites[spriteId].oam.objMode = 1; sub_8031BAC(taskId, 2); sub_8031D34(taskId, 1); @@ -1429,7 +1453,7 @@ void task_new_game_prof_birch_speech_part2_9(u8 taskId) InitSpriteAffineAnim(&gSprites[spriteId]); StartSpriteAffineAnim(&gSprites[spriteId], 0); gSprites[spriteId].callback = sub_80318D8; - BeginNormalPaletteFade(0xFFFF, 0, 0, 16, 0); + BeginNormalPaletteFade(0x0000FFFF, 0, 0, 16, RGB_BLACK); FadeOutBGM(4); gTasks[taskId].func = task_new_game_prof_birch_speech_part2_10; } @@ -1453,7 +1477,7 @@ void task_new_game_prof_birch_speech_part2_11(u8 taskId) spriteId = gTasks[taskId].data[2]; gSprites[spriteId].callback = nullsub_11; SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); - BeginNormalPaletteFade(-0x10000, 0, 0, 16, -1); + BeginNormalPaletteFade(-0x10000, 0, 0, 16, RGB_WHITEALPHA); gTasks[taskId].func = task_new_game_prof_birch_speech_part2_12; } } @@ -1573,21 +1597,21 @@ void AddBirchSpeechObjects(u8 taskId) gSprites[spriteId].callback = nullsub_11; gSprites[spriteId].oam.priority = 0; - gSprites[spriteId].invisible = 1; + gSprites[spriteId].invisible = TRUE; gTasks[taskId].data[8] = spriteId; spriteId2 = sub_80318F4(100, 0x4B); gSprites[spriteId2].callback = nullsub_11; gSprites[spriteId2].oam.priority = 0; - gSprites[spriteId2].invisible = 1; + gSprites[spriteId2].invisible = TRUE; gTasks[taskId].data[9] = spriteId2; spriteId3 = CreateTrainerSprite(FacilityClassToPicIndex(0x3C), 0x78, 0x3C, 0, gDecompressionBuffer); gSprites[spriteId3].callback = nullsub_11; - gSprites[spriteId3].invisible = 1; + gSprites[spriteId3].invisible = TRUE; gSprites[spriteId3].oam.priority = 0; gTasks[taskId].data[10] = spriteId3; spriteId4 = CreateTrainerSprite(FacilityClassToPicIndex(0x3F), 0x78, 0x3C, 0, &gDecompressionBuffer[0x800]); gSprites[spriteId4].callback = nullsub_11; - gSprites[spriteId4].invisible = 1; + gSprites[spriteId4].invisible = TRUE; gSprites[spriteId4].oam.priority = 0; gTasks[taskId].data[11] = spriteId4; } @@ -1773,7 +1797,7 @@ void CreateMainMenuErrorWindow(const u8* str) PrintTextOnWindow(7, 1, str, 0, 1, 2, 0); PutWindowTilemap(7); CopyWindowToVram(7, 2); - DrawMainMenuWindowBorder(gUnknown_082FF070, 0x1D5); + DrawMainMenuWindowBorder(gUnknown_082FF070, MAIN_MENU_BORDER_TILE); SetGpuReg(REG_OFFSET_WIN0H, 0x9E7); SetGpuReg(REG_OFFSET_WIN0V, 0x719F); } @@ -1882,7 +1906,7 @@ void sub_8032298(u8 a, u8 b, u8 c, u8 d, u8 e, u8 unused) void sub_80322E0(u8 windowId, u8 a) { CallWindowFunction(windowId, sub_8032298); - FillWindowPixelBuffer(windowId, 17); + FillWindowPixelBuffer(windowId, 0x11); ClearWindowTilemap(windowId); if (a == 1) CopyWindowToVram(windowId, 3); @@ -1912,11 +1936,9 @@ void sub_80323A0(struct TextSubPrinter *printer, u16 a) void sub_80323CC(u8 a, u8 b, u16 c, u16 d, u8 e, u8 f) { struct WindowTemplate sp; - struct WindowTemplate sp2; sp = sub_8198A50(0, a + 1, b + 1, 5, 4, f, d); - sp2 = sp; - CreateYesNoMenu(&sp2, c, e, 0); + CreateYesNoMenu(&sp, c, e, 0); } void unknown_rbox_to_vram(u8 windowId, u8 a) @@ -1938,11 +1960,11 @@ void sub_8032474 (u8 a, u8 b, u8 c, u8 d, u8 e, u8 f) FillBgTilemapBufferRect(a, 0x103, b-2, c, 1, 5, f); FillBgTilemapBufferRect(a, 0x105, b-1, c, d+1, 5, f); FillBgTilemapBufferRect(a, 0x106, b+d, c, 1, 5, f); - FillBgTilemapBufferRect(a, 0x8FD, b-2, c+e, 1, 1, f); - FillBgTilemapBufferRect(a, 0x8FF, b-1, c+e, 1, 1, f); - FillBgTilemapBufferRect(a, 0x900, b, c+e, d-1, 1, f); - FillBgTilemapBufferRect(a, 0x901, b+d-1, c+e, 1, 1, f); - FillBgTilemapBufferRect(a, 0x902, b+d, c+e, 1, 1, f); + FillBgTilemapBufferRect(a, BG_TILE_V_FLIP(0xFD), b-2, c+e, 1, 1, f); + FillBgTilemapBufferRect(a, BG_TILE_V_FLIP(0xFF), b-1, c+e, 1, 1, f); + FillBgTilemapBufferRect(a, BG_TILE_V_FLIP(0x100), b, c+e, d-1, 1, f); + FillBgTilemapBufferRect(a, BG_TILE_V_FLIP(0x101), b+d-1, c+e, 1, 1, f); + FillBgTilemapBufferRect(a, BG_TILE_V_FLIP(0x102), b+d, c+e, 1, 1, f); } void task_new_game_prof_birch_speech_part2_1(u8 taskId) From ce28fa900b8931082f80ec21ae7deb9d9321631d Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Wed, 14 Feb 2018 22:11:31 -0500 Subject: [PATCH 10/11] fixes --- src/main_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main_menu.c b/src/main_menu.c index bf282d5331..930580940c 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -1477,7 +1477,7 @@ void task_new_game_prof_birch_speech_part2_11(u8 taskId) spriteId = gTasks[taskId].data[2]; gSprites[spriteId].callback = nullsub_11; SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); - BeginNormalPaletteFade(-0x10000, 0, 0, 16, RGB_WHITEALPHA); + BeginNormalPaletteFade(0xFFFF0000, 0, 0, 16, RGB_WHITEALPHA); gTasks[taskId].func = task_new_game_prof_birch_speech_part2_12; } } From 2fb78b5ca8e24e895b66170806871d60164df554 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Thu, 15 Feb 2018 09:47:42 +0530 Subject: [PATCH 11/11] Fix reviewed points. --- data/party_menu.s | 2 +- include/field_screen.h | 2 ++ include/fldeff_groundshake.h | 7 +++++++ src/fldeff_strength.c | 10 +++++----- src/fldeff_sweetscent.c | 17 ++++++++--------- 5 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 include/fldeff_groundshake.h diff --git a/data/party_menu.s b/data/party_menu.s index 1319ce5d80..9eae24ab9c 100644 --- a/data/party_menu.s +++ b/data/party_menu.s @@ -434,7 +434,7 @@ gUnknown_08615D9C:: @ 8615D9C .4byte sub_80D3718, 0x00000007 .4byte SetUpFieldMove_Flash, 0x0000000d .4byte sub_8135654, 0x0000000d - .4byte hm_prepare_rocksmash, 0x0000000d + .4byte SetUpFieldMove_Strength, 0x0000000d .4byte sub_81B5820, 0x00000008 .4byte sub_81B5884, 0x0000000d .4byte sub_81B5974, 0x0000000d diff --git a/include/field_screen.h b/include/field_screen.h index cfc0d081f5..02e0a0a918 100644 --- a/include/field_screen.h +++ b/include/field_screen.h @@ -10,5 +10,7 @@ void pal_fill_black(void); bool8 sub_80ABDFC(void); void sub_80AF168(void); void UpdateWeatherPerDay(u16 days); +void sub_80AC3D0(void); +void sub_80AC3E4(void); #endif //GUARD_FIELD_SCREEN_H diff --git a/include/fldeff_groundshake.h b/include/fldeff_groundshake.h new file mode 100644 index 0000000000..685a6d27cd --- /dev/null +++ b/include/fldeff_groundshake.h @@ -0,0 +1,7 @@ +#ifndef GUARD_FLDEFF_GROUNDSHAKE_H +#define GUARD_FLDEFF_GROUNDSHAKE_H + +void sub_81BE6B8(void); +void sub_81BE72C(void); + +#endif // GUARD_FLDEFF_GROUNDSHAKE_H diff --git a/src/fldeff_strength.c b/src/fldeff_strength.c index 9f649f56cc..c1965d9839 100644 --- a/src/fldeff_strength.c +++ b/src/fldeff_strength.c @@ -7,22 +7,22 @@ #include "script.h" #include "task.h" -void sub_8145E0C(void); +void FldEff_UseStrength(void); void sub_8145E74(void); -bool8 hm_prepare_rocksmash(void) +bool8 SetUpFieldMove_Strength(void) { if (npc_before_player_of_type(87) == TRUE) { gSpecialVar_Result = GetCursorSelectionMonId(); gUnknown_03005DB0 = FieldCallback_Teleport; - gUnknown_0203CEEC = sub_8145E0C; + gUnknown_0203CEEC = FldEff_UseStrength; return TRUE; } return FALSE; } -void sub_8145E0C(void) +void FldEff_UseStrength(void) { gFieldEffectArguments[0] = GetCursorSelectionMonId(); ScriptContext1_SetupScript(FieryPath_EventScript_2908FD); @@ -39,6 +39,6 @@ bool8 sub_8145E2C(void) void sub_8145E74(void) { - FieldEffectActiveListRemove(40); + FieldEffectActiveListRemove(FLDEFF_USE_STRENGTH); EnableBothScriptContexts(); } diff --git a/src/fldeff_sweetscent.c b/src/fldeff_sweetscent.c index ee5a393433..3dfcd640d9 100644 --- a/src/fldeff_sweetscent.c +++ b/src/fldeff_sweetscent.c @@ -1,8 +1,12 @@ #include "global.h" +#include "constants/rgb.h" +#include "constants/songs.h" #include "event_data.h" #include "event_scripts.h" #include "field_effect.h" #include "field_player_avatar.h" +#include "field_screen.h" +#include "fldeff_groundshake.h" #include "palette.h" #include "party_menu.h" #include "rom6.h" @@ -12,11 +16,6 @@ #include "task.h" #include "wild_encounter.h" -extern void sub_81BE72C(void); -extern void sub_81BE6B8(void); -extern void sub_80AC3D0(void); -extern void sub_80AC3E4(void); - void hm2_sweet_scent(void); void sub_8159F5C(void); void sub_8159FEC(u8 taskId); @@ -50,10 +49,10 @@ void sub_8159F5C(void) { u8 taskId; - PlaySE(0xEC); + PlaySE(SE_W230); CpuFastSet(gPlttBufferUnfaded, gPaletteDecompressionBuffer, 0x100); CpuFastSet(gPlttBufferFaded, gPlttBufferUnfaded, 0x100); - BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 0, 8, 0x1F); + BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 0, 8, RGB_RED); taskId = CreateTask(sub_8159FEC, 0); gTasks[taskId].data[0] = 0; FieldEffectActiveListRemove(FLDEFF_SWEET_SCENT); @@ -64,7 +63,7 @@ void sub_8159FEC(u8 taskId) if (!gPaletteFade.active) { sub_81BE72C(); - BlendPalettes(64, 8, 0x1F); + BlendPalettes(0x00000040, 8, RGB_RED); if (gTasks[taskId].data[0] == 64) { gTasks[taskId].data[0] = 0; @@ -75,7 +74,7 @@ void sub_8159FEC(u8 taskId) else { gTasks[taskId].func = sub_815A090; - BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 8, 0, 0x1F); + BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 8, 0, RGB_RED); sub_81BE6B8(); } }