From 1b303aeee87095400aae7c0d1ff9f94e83594691 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Wed, 7 Feb 2018 14:11:08 -0500 Subject: [PATCH 01/27] 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 08e0c3103..1aaef8697 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 345afb27f..19661fb56 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 8608159c2..f5e210b58 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/27] 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 8f4e9fb8a..ab2186a68 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 ed9fef53a..9ae3e6af0 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/27] 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 ab2186a68..000000000 --- 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 9e7eea3bc..1dfc0242b 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 7395270f9..f59dfab9b 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 1c9795d29..202e2a4d7 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 2046f7d2b..18d391317 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 d0baac810..694c01fd9 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 974f8f091..36198e124 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 82dfacf48..263839b19 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 6d569e57a..a3d2a2fb7 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 513bf2583..4998743ce 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 9ae3e6af0..f4241edb0 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/27] 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 39662c8c1..4eac25856 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 f4241edb0..c8a868251 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 fb7c7a4e7..d94cde788 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 0ca0ad1c63e49605d3a9dd28e5c40bca96a85710 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Mon, 12 Feb 2018 15:42:15 +0530 Subject: [PATCH 05/27] Decompile birch_pc.c --- asm/birch_pc.s | 234 ----------------------------------- data/battle_frontier_1.s | 42 +++---- data/text/pokedex_rating.inc | 42 +++---- ld_script.txt | 2 +- src/birch_pc.c | 114 +++++++++++++++++ 5 files changed, 157 insertions(+), 277 deletions(-) delete mode 100644 asm/birch_pc.s create mode 100644 src/birch_pc.c diff --git a/asm/birch_pc.s b/asm/birch_pc.s deleted file mode 100644 index 6665d9beb..000000000 --- a/asm/birch_pc.s +++ /dev/null @@ -1,234 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start ScriptGetPokedexInfo -ScriptGetPokedexInfo: @ 8137A4C - push {lr} - ldr r0, =gSpecialVar_0x8004 - ldrh r0, [r0] - cmp r0, 0 - bne _08137A70 - movs r0, 0 - bl sub_80C0844 - ldr r1, =gSpecialVar_0x8005 - strh r0, [r1] - movs r0, 0x1 - bl sub_80C0844 - b _08137A80 - .pool -_08137A70: - movs r0, 0 - bl pokedex_count - ldr r1, =gSpecialVar_0x8005 - strh r0, [r1] - movs r0, 0x1 - bl pokedex_count -_08137A80: - ldr r1, =gSpecialVar_0x8006 - strh r0, [r1] - bl IsNationalPokedexEnabled - lsls r0, 16 - lsrs r0, 16 - pop {r1} - bx r1 - .pool - thumb_func_end ScriptGetPokedexInfo - - thumb_func_start GetPokedexRatingText -GetPokedexRatingText: @ 8137A98 - push {lr} - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x9 - bhi _08137AA4 - b _08137BFC -_08137AA4: - cmp r0, 0x13 - bhi _08137AB0 - ldr r0, =gUnknown_082A5DAB - b _08137C06 - .pool -_08137AB0: - cmp r0, 0x1D - bhi _08137ABC - ldr r0, =gUnknown_082A5DF1 - b _08137C06 - .pool -_08137ABC: - cmp r0, 0x27 - bhi _08137AC8 - ldr r0, =gUnknown_082A5E34 - b _08137C06 - .pool -_08137AC8: - cmp r0, 0x31 - bhi _08137AD4 - ldr r0, =gUnknown_082A5E83 - b _08137C06 - .pool -_08137AD4: - cmp r0, 0x3B - bhi _08137AE0 - ldr r0, =gUnknown_082A5EB9 - b _08137C06 - .pool -_08137AE0: - cmp r0, 0x45 - bhi _08137AEC - ldr r0, =gUnknown_082A5EF4 - b _08137C06 - .pool -_08137AEC: - cmp r0, 0x4F - bhi _08137AF8 - ldr r0, =gUnknown_082A5F39 - b _08137C06 - .pool -_08137AF8: - cmp r0, 0x59 - bhi _08137B04 - ldr r0, =gUnknown_082A5F82 - b _08137C06 - .pool -_08137B04: - cmp r0, 0x63 - bhi _08137B10 - ldr r0, =gUnknown_082A5FB9 - b _08137C06 - .pool -_08137B10: - cmp r0, 0x6D - bhi _08137B1C - ldr r0, =gUnknown_082A6018 - b _08137C06 - .pool -_08137B1C: - cmp r0, 0x77 - bhi _08137B28 - ldr r0, =gUnknown_082A6061 - b _08137C06 - .pool -_08137B28: - cmp r0, 0x81 - bhi _08137B34 - ldr r0, =gUnknown_082A609C - b _08137C06 - .pool -_08137B34: - cmp r0, 0x8B - bhi _08137B40 - ldr r0, =gUnknown_082A60D5 - b _08137C06 - .pool -_08137B40: - cmp r0, 0x95 - bhi _08137B4C - ldr r0, =gUnknown_082A6124 - b _08137C06 - .pool -_08137B4C: - cmp r0, 0x9F - bhi _08137B58 - ldr r0, =gUnknown_082A616F - b _08137C06 - .pool -_08137B58: - cmp r0, 0xA9 - bhi _08137B64 - ldr r0, =gUnknown_082A61D6 - b _08137C06 - .pool -_08137B64: - cmp r0, 0xB3 - bhi _08137B70 - ldr r0, =gUnknown_082A623A - b _08137C06 - .pool -_08137B70: - cmp r0, 0xBD - bhi _08137B7C - ldr r0, =gUnknown_082A6287 - b _08137C06 - .pool -_08137B7C: - cmp r0, 0xC7 - bls _08137BEA - cmp r0, 0xC8 - bne _08137BB8 - ldr r0, =0x00000199 - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - bne _08137BEA - movs r0, 0xCD - lsls r0, 1 - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - bne _08137BEA - b _08137C04 - .pool -_08137BB8: - cmp r0, 0xC9 - bne _08137BF8 - ldr r0, =0x00000199 - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - beq _08137C04 - movs r0, 0xCD - lsls r0, 1 - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - beq _08137C04 -_08137BEA: - ldr r0, =gUnknown_082A62C9 - b _08137C06 - .pool -_08137BF8: - cmp r0, 0xCA - beq _08137C04 -_08137BFC: - ldr r0, =gUnknown_082A5D6C - b _08137C06 - .pool -_08137C04: - ldr r0, =gUnknown_082A6312 -_08137C06: - pop {r1} - bx r1 - .pool - thumb_func_end GetPokedexRatingText - - thumb_func_start ShowPokedexRatingMessage -ShowPokedexRatingMessage: @ 8137C10 - push {lr} - ldr r0, =gSpecialVar_0x8004 - ldrh r0, [r0] - bl GetPokedexRatingText - bl ShowFieldMessage - pop {r0} - bx r0 - .pool - thumb_func_end ShowPokedexRatingMessage diff --git a/data/battle_frontier_1.s b/data/battle_frontier_1.s index 34e8df6d2..e2eb99505 100644 --- a/data/battle_frontier_1.s +++ b/data/battle_frontier_1.s @@ -1872,24 +1872,24 @@ gUnknown_0860F010:: @ 860F010 .2byte FLAG_BADGE08_GET gUnknown_0860F020:: @ 860F020 - .4byte gUnknown_082A5D6C - .4byte gUnknown_082A5DAB - .4byte gUnknown_082A5DF1 - .4byte gUnknown_082A5E34 - .4byte gUnknown_082A5E83 - .4byte gUnknown_082A5EB9 - .4byte gUnknown_082A5EF4 - .4byte gUnknown_082A5F39 - .4byte gUnknown_082A5F82 - .4byte gUnknown_082A5FB9 - .4byte gUnknown_082A6018 - .4byte gUnknown_082A6061 - .4byte gUnknown_082A609C - .4byte gUnknown_082A60D5 - .4byte gUnknown_082A6124 - .4byte gUnknown_082A616F - .4byte gUnknown_082A61D6 - .4byte gUnknown_082A623A - .4byte gUnknown_082A6287 - .4byte gUnknown_082A62C9 - .4byte gUnknown_082A6312 + .4byte gBirchDexRatingText_LessThan10 + .4byte gBirchDexRatingText_LessThan20 + .4byte gBirchDexRatingText_LessThan30 + .4byte gBirchDexRatingText_LessThan40 + .4byte gBirchDexRatingText_LessThan50 + .4byte gBirchDexRatingText_LessThan60 + .4byte gBirchDexRatingText_LessThan70 + .4byte gBirchDexRatingText_LessThan80 + .4byte gBirchDexRatingText_LessThan90 + .4byte gBirchDexRatingText_LessThan100 + .4byte gBirchDexRatingText_LessThan110 + .4byte gBirchDexRatingText_LessThan120 + .4byte gBirchDexRatingText_LessThan130 + .4byte gBirchDexRatingText_LessThan140 + .4byte gBirchDexRatingText_LessThan150 + .4byte gBirchDexRatingText_LessThan160 + .4byte gBirchDexRatingText_LessThan170 + .4byte gBirchDexRatingText_LessThan180 + .4byte gBirchDexRatingText_LessThan190 + .4byte gBirchDexRatingText_LessThan200 + .4byte gBirchDexRatingText_DexCompleted diff --git a/data/text/pokedex_rating.inc b/data/text/pokedex_rating.inc index 735488b37..666c90867 100644 --- a/data/text/pokedex_rating.inc +++ b/data/text/pokedex_rating.inc @@ -12,99 +12,99 @@ gUnknown_082A5D2C:: @ 82A5D2C .string "So, you’ve seen {STR_VAR_1} POKéMON,\n" .string "and you’ve caught {STR_VAR_2} POKéMON…$" -gUnknown_082A5D6C:: @ 82A5D6C +gBirchDexRatingText_LessThan10:: @ 82A5D6C .string "Go into grassy areas more and look\n" .string "for POKéMON more carefully.$" -gUnknown_082A5DAB:: @ 82A5DAB +gBirchDexRatingText_LessThan20:: @ 82A5DAB .string "I guess you’re getting the hang\n" .string "of it. But, it gets harder from here.$" -gUnknown_082A5DF1:: @ 82A5DF1 +gBirchDexRatingText_LessThan30:: @ 82A5DF1 .string "Some POKéMON only appear in\n" .string "certain areas.\l" .string "You must be persistent.$" -gUnknown_082A5E34:: @ 82A5E34 +gBirchDexRatingText_LessThan40:: @ 82A5E34 .string "Well, it could use more quantity,\n" .string "but this is looking more like\l" .string "a POKéDEX now.$" -gUnknown_082A5E83:: @ 82A5E83 +gBirchDexRatingText_LessThan50:: @ 82A5E83 .string "This is coming along pretty good.\n" .string "Keep up the effort.$" -gUnknown_082A5EB9:: @ 82A5EB9 +gBirchDexRatingText_LessThan60:: @ 82A5EB9 .string "Are you using any RODS?\n" .string "There are many POKéMON in the sea.$" -gUnknown_082A5EF4:: @ 82A5EF4 +gBirchDexRatingText_LessThan70:: @ 82A5EF4 .string "Instead of just catching POKéMON,\n" .string "how about making them evolve, too?$" -gUnknown_082A5F39:: @ 82A5F39 +gBirchDexRatingText_LessThan80:: @ 82A5F39 .string "This is going to be a fantastic\n" .string "POKéDEX.\l" .string "That’s the feeling I’m getting.$" -gUnknown_082A5F82:: @ 82A5F82 +gBirchDexRatingText_LessThan90:: @ 82A5F82 .string "You’ve collected this many…\n" .string "Your talent is remarkable!$" -gUnknown_082A5FB9:: @ 82A5FB9 +gBirchDexRatingText_LessThan100:: @ 82A5FB9 .string "Have you visited the SAFARI ZONE?\p" .string "I hear there are some POKéMON that\n" .string "can only be caught there.$" -gUnknown_082A6018:: @ 82A6018 +gBirchDexRatingText_LessThan110:: @ 82A6018 .string "You’ve finally reached\n" .string "the 100-kind mark.\p" .string "This is an impressive POKéDEX!$" -gUnknown_082A6061:: @ 82A6061 +gBirchDexRatingText_LessThan120:: @ 82A6061 .string "There might be POKéMON that can be\n" .string "found using ROCK SMASH.$" -gUnknown_082A609C:: @ 82A609C +gBirchDexRatingText_LessThan130:: @ 82A609C .string "You should get some more POKéMON\n" .string "by trading with others.$" -gUnknown_082A60D5:: @ 82A60D5 +gBirchDexRatingText_LessThan140:: @ 82A60D5 .string "I’ve heard of POKéMON that evolve\n" .string "when they come to fully love their\l" .string "TRAINERS.$" -gUnknown_082A6124:: @ 82A6124 +gBirchDexRatingText_LessThan150:: @ 82A6124 .string "I had no idea that there were so\n" .string "many POKéMON species in the HOENN\l" .string "region.$" -gUnknown_082A616F:: @ 82A616F +gBirchDexRatingText_LessThan160:: @ 82A616F .string "On occasion, some POKéMON appear\n" .string "in large numbers like outbreaks.\p" .string "Don’t miss opportunities like\n" .string "those.$" -gUnknown_082A61D6:: @ 82A61D6 +gBirchDexRatingText_LessThan170:: @ 82A61D6 .string "One can get a very good idea about\n" .string "the POKéMON of the HOENN region\l" .string "by looking through your POKéDEX.$" -gUnknown_082A623A:: @ 82A623A +gBirchDexRatingText_LessThan180:: @ 82A623A .string "I would say you already qualify as\n" .string "a POKéMON PROFESSOR, and a good\l" .string "one, too!$" -gUnknown_082A6287:: @ 82A6287 +gBirchDexRatingText_LessThan190:: @ 82A6287 .string "With a POKéDEX this complete,\n" .string "you’re a real professional at this!$" -gUnknown_082A62C9:: @ 82A62C9 +gBirchDexRatingText_LessThan200:: @ 82A62C9 .string "You’re very close to completing\n" .string "this POKéDEX.\l" .string "I can feel it in my bones!$" -gUnknown_082A6312:: @ 82A6312 +gBirchDexRatingText_DexCompleted:: @ 82A6312 .string "Congratulations!\n" .string "Your POKéDEX is complete!$" diff --git a/ld_script.txt b/ld_script.txt index 81911e574..bf52fc49f 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -183,7 +183,7 @@ SECTIONS { asm/fldeff_flash.o(.text); asm/post_battle_event_funcs.o(.text); src/time_events.o(.text); - asm/birch_pc.o(.text); + src/birch_pc.o(.text); src/hof_pc.o(.text); asm/field_specials.o(.text); asm/battle_records.o(.text); diff --git a/src/birch_pc.c b/src/birch_pc.c new file mode 100644 index 000000000..bc8095592 --- /dev/null +++ b/src/birch_pc.c @@ -0,0 +1,114 @@ +#include "global.h" +#include "event_data.h" +#include "field_message_box.h" +#include "pokedex.h" +#include "constants/species.h" + +extern u16 gSpecialVar_0x8004; +extern u16 gSpecialVar_0x8005; +extern u16 gSpecialVar_0x8006; + +extern const u8 gBirchDexRatingText_LessThan10[]; +extern const u8 gBirchDexRatingText_LessThan20[]; +extern const u8 gBirchDexRatingText_LessThan30[]; +extern const u8 gBirchDexRatingText_LessThan40[]; +extern const u8 gBirchDexRatingText_LessThan50[]; +extern const u8 gBirchDexRatingText_LessThan60[]; +extern const u8 gBirchDexRatingText_LessThan70[]; +extern const u8 gBirchDexRatingText_LessThan80[]; +extern const u8 gBirchDexRatingText_LessThan90[]; +extern const u8 gBirchDexRatingText_LessThan100[]; +extern const u8 gBirchDexRatingText_LessThan110[]; +extern const u8 gBirchDexRatingText_LessThan120[]; +extern const u8 gBirchDexRatingText_LessThan130[]; +extern const u8 gBirchDexRatingText_LessThan140[]; +extern const u8 gBirchDexRatingText_LessThan150[]; +extern const u8 gBirchDexRatingText_LessThan160[]; +extern const u8 gBirchDexRatingText_LessThan170[]; +extern const u8 gBirchDexRatingText_LessThan180[]; +extern const u8 gBirchDexRatingText_LessThan190[]; +extern const u8 gBirchDexRatingText_LessThan200[]; +extern const u8 gBirchDexRatingText_DexCompleted[]; + +bool16 ScriptGetPokedexInfo(void) +{ + if (gSpecialVar_0x8004 == 0) // is national dex not present? + { + gSpecialVar_0x8005 = sub_80C0844(0); + gSpecialVar_0x8006 = sub_80C0844(1); + } + else + { + gSpecialVar_0x8005 = pokedex_count(0); + gSpecialVar_0x8006 = pokedex_count(1); + } + + return IsNationalPokedexEnabled(); +} + +// This shows your Hoenn Pokedex rating and not your National Dex. +const u8 *GetPokedexRatingText(u16 count) +{ + if (count < 10) + return gBirchDexRatingText_LessThan10; + if (count < 20) + return gBirchDexRatingText_LessThan20; + if (count < 30) + return gBirchDexRatingText_LessThan30; + if (count < 40) + return gBirchDexRatingText_LessThan40; + if (count < 50) + return gBirchDexRatingText_LessThan50; + if (count < 60) + return gBirchDexRatingText_LessThan60; + if (count < 70) + return gBirchDexRatingText_LessThan70; + if (count < 80) + return gBirchDexRatingText_LessThan80; + if (count < 90) + return gBirchDexRatingText_LessThan90; + if (count < 100) + return gBirchDexRatingText_LessThan100; + if (count < 110) + return gBirchDexRatingText_LessThan110; + if (count < 120) + return gBirchDexRatingText_LessThan120; + if (count < 130) + return gBirchDexRatingText_LessThan130; + if (count < 140) + return gBirchDexRatingText_LessThan140; + if (count < 150) + return gBirchDexRatingText_LessThan150; + if (count < 160) + return gBirchDexRatingText_LessThan160; + if (count < 170) + return gBirchDexRatingText_LessThan170; + if (count < 180) + return gBirchDexRatingText_LessThan180; + if (count < 190) + return gBirchDexRatingText_LessThan190; + if (count < 200) + return gBirchDexRatingText_LessThan200; + if (count == 200) + { + if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), 1) + || GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), 1)) // Jirachi or Deoxys is not counted towards the dex completion. If either of these flags are enabled, it means the actual count is less than 200. + return gBirchDexRatingText_LessThan200; + return gBirchDexRatingText_DexCompleted; + } + if (count == 201) + { + if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), 1) + && GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), 1)) // If both of these flags are enabled, it means the actual count is less than 200. + return gBirchDexRatingText_LessThan200; + return gBirchDexRatingText_DexCompleted; + } + if (count == 202) + return gBirchDexRatingText_DexCompleted; // Hoenn dex is considered complete, even though the hoenn dex count is 210. + return gBirchDexRatingText_LessThan10; +} + +void ShowPokedexRatingMessage(void) +{ + ShowFieldMessage(GetPokedexRatingText(gSpecialVar_0x8004)); +} From d52a54e64f73cb1e24e18da106ea9b69307b4509 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Mon, 12 Feb 2018 16:15:51 +0530 Subject: [PATCH 06/27] Updating pokedex count function labels --- asm/battle_frontier_1.s | 8 ++++---- asm/easy_chat.s | 4 ++-- asm/main_menu.s | 4 ++-- asm/pokedex.s | 24 ++++++++++++------------ asm/start_menu.s | 2 +- asm/trainer_card.s | 4 ++-- include/pokedex.h | 2 +- src/birch_pc.c | 8 ++++---- src/menu.c | 28 ++++++++++++++-------------- src/tv.c | 4 ++-- 10 files changed, 44 insertions(+), 44 deletions(-) diff --git a/asm/battle_frontier_1.s b/asm/battle_frontier_1.s index 60ac46859..6ea5ba051 100644 --- a/asm/battle_frontier_1.s +++ b/asm/battle_frontier_1.s @@ -15923,11 +15923,11 @@ sub_8197080: @ 8197080 b _0819715C _081970A2: movs r0, 0 - bl sub_80C0844 + bl GetHoennPokedexCount lsls r0, 16 lsrs r4, r0, 16 movs r0, 0x1 - bl sub_80C0844 + bl GetHoennPokedexCount lsls r0, 16 lsrs r6, r0, 16 ldr r0, =gStringVar1 @@ -15977,11 +15977,11 @@ _081970A2: strb r6, [r5] adds r5, 0x1 movs r0, 0 - bl pokedex_count + bl GetNationalPokedexCount lsls r0, 16 lsrs r4, r0, 16 movs r0, 0x1 - bl pokedex_count + bl GetNationalPokedexCount lsls r0, 16 lsrs r6, r0, 16 mov r0, r10 diff --git a/asm/easy_chat.s b/asm/easy_chat.s index db2ffac14..0cbe1f1ae 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -9252,7 +9252,7 @@ start_menu_is_selected_item_valid: @ 811EA6C cmp r0, 0 bne _0811EA84 movs r0, 0 - bl pokedex_count + bl GetNationalPokedexCount lsls r0, 16 lsrs r0, 16 b _0811EA9A @@ -10369,7 +10369,7 @@ sub_811F2D4: @ 811F2D4 movs r5, 0 strh r5, [r0] movs r0, 0 - bl pokedex_count + bl GetNationalPokedexCount lsls r0, 16 cmp r0, 0 beq _0811F2FC diff --git a/asm/main_menu.s b/asm/main_menu.s index 48d1411c5..d5a69d503 100644 --- a/asm/main_menu.s +++ b/asm/main_menu.s @@ -4654,12 +4654,12 @@ fmt_pokedex: @ 8031F7C cmp r0, 0 beq _08031FA4 movs r0, 0x1 - bl pokedex_count + bl GetNationalPokedexCount b _08031FAA .pool _08031FA4: movs r0, 0x1 - bl sub_80C0844 + bl GetHoennPokedexCount _08031FAA: lsls r0, 16 lsrs r7, r0, 16 diff --git a/asm/pokedex.s b/asm/pokedex.s index cb40f0eda..d28b54651 100644 --- a/asm/pokedex.s +++ b/asm/pokedex.s @@ -443,24 +443,24 @@ _080BB65E: cmp r0, 0 bne _080BB6D0 movs r0, 0 - bl sub_80C0844 + bl GetHoennPokedexCount ldr r1, [r4] ldr r2, =0x0000061a adds r1, r2 strh r0, [r1] movs r0, 0x1 - bl sub_80C0844 + bl GetHoennPokedexCount b _080BB6E4 .pool _080BB6D0: movs r0, 0 - bl pokedex_count + bl GetNationalPokedexCount ldr r1, [r4] ldr r2, =0x0000061a adds r1, r2 strh r0, [r1] movs r0, 0x1 - bl pokedex_count + bl GetNationalPokedexCount _080BB6E4: ldr r1, [r4] ldr r3, =0x0000061c @@ -5058,7 +5058,7 @@ _080BDF4C: movs r1, 0x1 bl StartSpriteAnim movs r0, 0 - bl sub_80C0844 + bl GetHoennPokedexCount lsls r0, 16 lsrs r6, r0, 16 movs r0, 0 @@ -5283,7 +5283,7 @@ _080BE198: lsrs r1, 24 bl StartSpriteAnim movs r0, 0x1 - bl sub_80C0844 + bl GetHoennPokedexCount lsls r0, 16 lsrs r6, r0, 16 movs r0, 0 @@ -9597,8 +9597,8 @@ _080C07E8: .pool thumb_func_end GetSetPokedexFlag - thumb_func_start pokedex_count -pokedex_count: @ 80C07F4 + thumb_func_start GetNationalPokedexCount +GetNationalPokedexCount: @ 80C07F4 push {r4-r7,lr} lsls r0, 24 lsrs r6, r0, 24 @@ -9641,10 +9641,10 @@ _080C0832: pop {r4-r7} pop {r1} bx r1 - thumb_func_end pokedex_count + thumb_func_end GetNationalPokedexCount - thumb_func_start sub_80C0844 -sub_80C0844: @ 80C0844 + thumb_func_start GetHoennPokedexCount +GetHoennPokedexCount: @ 80C0844 push {r4-r6,lr} lsls r0, 24 lsrs r6, r0, 24 @@ -9691,7 +9691,7 @@ _080C088C: pop {r4-r6} pop {r1} bx r1 - thumb_func_end sub_80C0844 + thumb_func_end GetHoennPokedexCount thumb_func_start sub_80C089C sub_80C089C: @ 80C089C diff --git a/asm/start_menu.s b/asm/start_menu.s index 23ac3710a..a57bbddc3 100644 --- a/asm/start_menu.s +++ b/asm/start_menu.s @@ -418,7 +418,7 @@ _0809FAFE: cmp r1, r0 bne _0809FB34 movs r0, 0 - bl pokedex_count + bl GetNationalPokedexCount lsls r0, 16 cmp r0, 0 beq _0809FBA0 diff --git a/asm/trainer_card.s b/asm/trainer_card.s index d7c96054d..a56dbd157 100644 --- a/asm/trainer_card.s +++ b/asm/trainer_card.s @@ -1925,11 +1925,11 @@ sub_80C376C: @ 80C376C cmp r0, 0 bne _080C377E movs r0, 0x1 - bl sub_80C0844 + bl GetHoennPokedexCount b _080C3784 _080C377E: movs r0, 0x1 - bl pokedex_count + bl GetNationalPokedexCount _080C3784: lsls r0, 16 lsrs r0, 16 diff --git a/include/pokedex.h b/include/pokedex.h index 236feac45..20eecf375 100644 --- a/include/pokedex.h +++ b/include/pokedex.h @@ -17,7 +17,7 @@ enum }; s8 GetSetPokedexFlag(u16 nationalNum, u8 caseId); -u16 pokedex_count(u8); +u16 GetNationalPokedexCount(u8); u16 sub_80C0844(u8); #endif // GUARD_POKEDEX_H diff --git a/src/birch_pc.c b/src/birch_pc.c index bc8095592..4b0025504 100644 --- a/src/birch_pc.c +++ b/src/birch_pc.c @@ -34,13 +34,13 @@ bool16 ScriptGetPokedexInfo(void) { if (gSpecialVar_0x8004 == 0) // is national dex not present? { - gSpecialVar_0x8005 = sub_80C0844(0); - gSpecialVar_0x8006 = sub_80C0844(1); + gSpecialVar_0x8005 = GetHoennPokedexCount(0); + gSpecialVar_0x8006 = GetHoennPokedexCount(1); } else { - gSpecialVar_0x8005 = pokedex_count(0); - gSpecialVar_0x8006 = pokedex_count(1); + gSpecialVar_0x8005 = GetNationalPokedexCount(0); + gSpecialVar_0x8006 = GetNationalPokedexCount(1); } return IsNationalPokedexEnabled(); diff --git a/src/menu.c b/src/menu.c index d06f950d3..b20ab5164 100644 --- a/src/menu.c +++ b/src/menu.c @@ -63,7 +63,7 @@ static EWRAM_DATA void *gUnknown_0203CDAC[0x20] = {NULL}; const u16 gUnknown_0860F074[] = INCBIN_U16("graphics/interface/860F074.gbapal"); static const u8 gUnknown_0860F094[] = { 8, 4, 1 }; -static const struct WindowTemplate gUnknown_0860F098[] = +static const struct WindowTemplate gUnknown_0860F098[] = { { 0x00, 0x02, 0x0F, 0x1B, 0x04, 0x0F, 0x194 }, DUMMY_WIN_TEMPLATE @@ -76,7 +76,7 @@ static const struct WindowTemplate gUnknown_0860F0A8 = const u16 gUnknown_0860F0B0[] = INCBIN_U16("graphics/interface/860F0B0.gbapal"); const u8 gUnknown_0860F0D0[] = { 15, 1, 2 }; -const struct SomeUnkStruct_60F0D4 gUnknown_0860F0D4[] = +const struct SomeUnkStruct_60F0D4 gUnknown_0860F0D4[] = { { 12, 12, 0x00 }, { 32, 12, 0x20 }, @@ -151,7 +151,7 @@ u16 sub_8197224(void) u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8 fgColor, u8 bgColor, u8 shadowColor) { struct TextSubPrinter printer; - + printer.current_text_offset = str; printer.windowId = windowId; printer.fontId = fontId; @@ -165,9 +165,9 @@ u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 speed, printer.fgColor = fgColor; printer.bgColor = bgColor; printer.shadowColor = shadowColor; - + gTextFlags.flag_1 = 0; - return AddTextPrinter(&printer, speed, callback); + return AddTextPrinter(&printer, speed, callback); } void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress) @@ -234,7 +234,7 @@ void sub_819746C(u8 windowId, bool8 copyToVram) void DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) { int i; - + FillBgTilemapBufferRect(bg, STD_WINDOW_BASE_TILE_NUM + 0, tilemapLeft - 1, @@ -256,7 +256,7 @@ void DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height 1, 1, STD_WINDOW_PALETTE_NUM); - + for (i = tilemapTop; i < tilemapTop + height; i++) { FillBgTilemapBufferRect(bg, @@ -274,7 +274,7 @@ void DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height 1, STD_WINDOW_PALETTE_NUM); } - + FillBgTilemapBufferRect(bg, STD_WINDOW_BASE_TILE_NUM + 6, tilemapLeft - 1, @@ -1941,7 +1941,7 @@ void box_print(u8 windowId, u8 fontId, u8 left, u8 top, const u8 *color, s8 spee printer.fgColor = color[1]; printer.bgColor = color[0]; printer.shadowColor = color[2]; - + AddTextPrinter(&printer, speed, NULL); } @@ -1962,7 +1962,7 @@ void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 left, u8 top, u8 le printer.fgColor = color[1]; printer.bgColor = color[0]; printer.shadowColor = color[2]; - + AddTextPrinter(&printer, speed, NULL); } @@ -2373,14 +2373,14 @@ void sub_819A344(u8 a0, u8 *a1, u8 a2) s32 flagCount; u8 *endOfString; u8 *string = a1; - + *(string++) = EXT_CTRL_CODE_BEGIN; *(string++) = EXT_CTRL_CODE_COLOR; *(string++) = a2; *(string++) = EXT_CTRL_CODE_BEGIN; *(string++) = EXT_CTRL_CODE_SHADOW; *(string++) = a2 + 1; - + switch (a0) { case 0: @@ -2388,9 +2388,9 @@ void sub_819A344(u8 a0, u8 *a1, u8 a2) break; case 1: if (IsNationalPokedexEnabled()) - string = ConvertIntToDecimalStringN(string, pokedex_count(1), 0, 3); + string = ConvertIntToDecimalStringN(string, GetNationalPokedexCount(1), 0, 3); else - string = ConvertIntToDecimalStringN(string, sub_80C0844(1), 0, 3); + string = ConvertIntToDecimalStringN(string, GetHoennPokedexCount(1), 0, 3); *string = EOS; break; case 2: diff --git a/src/tv.c b/src/tv.c index fbe39fde0..b0dbc0dbc 100644 --- a/src/tv.c +++ b/src/tv.c @@ -1957,11 +1957,11 @@ void sub_80EDB44(void) show->rivalTrainer.badgeCount = nBadges; if (IsNationalPokedexEnabled()) { - show->rivalTrainer.dexCount = pokedex_count(0x01); + show->rivalTrainer.dexCount = GetNationalPokedexCount(0x01); } else { - show->rivalTrainer.dexCount = sub_80C0844(0x01); + show->rivalTrainer.dexCount = GetHoennPokedexCount(0x01); } show->rivalTrainer.location = gMapHeader.regionMapSectionId; show->rivalTrainer.mapDataId = gMapHeader.mapDataId; From 185cf71842b82082280ec3b3185977892d8b4bbf Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Mon, 12 Feb 2018 16:17:57 +0530 Subject: [PATCH 07/27] Missing label --- include/pokedex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pokedex.h b/include/pokedex.h index 20eecf375..d3cb670c8 100644 --- a/include/pokedex.h +++ b/include/pokedex.h @@ -18,6 +18,6 @@ enum s8 GetSetPokedexFlag(u16 nationalNum, u8 caseId); u16 GetNationalPokedexCount(u8); -u16 sub_80C0844(u8); +u16 GetHoennPokedexCount(u8); #endif // GUARD_POKEDEX_H From 54922641af2712a8108c327ee3ce104c41a10a52 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Mon, 12 Feb 2018 16:44:04 +0530 Subject: [PATCH 08/27] Port smokescreen.s --- asm/smokescreen.s | 214 ---------------------------------------------- include/data2.h | 4 + ld_script.txt | 2 +- src/smokescreen.c | 73 ++++++++++++++++ 4 files changed, 78 insertions(+), 215 deletions(-) delete mode 100644 asm/smokescreen.s create mode 100644 src/smokescreen.c diff --git a/asm/smokescreen.s b/asm/smokescreen.s deleted file mode 100644 index 464e25c40..000000000 --- a/asm/smokescreen.s +++ /dev/null @@ -1,214 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_807521C -sub_807521C: @ 807521C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 16 - lsrs r6, r0, 16 - lsls r1, 16 - lsrs r7, r1, 16 - lsls r2, 24 - lsrs r4, r2, 24 - ldr r5, =gUnknown_0831C620 - ldrh r0, [r5, 0x6] - bl GetSpriteTileStartByTag - lsls r0, 16 - ldr r1, =0xffff0000 - cmp r0, r1 - bne _0807524E - adds r0, r5, 0 - bl LoadCompressedObjectPicUsingHeap - ldr r0, =gUnknown_0831C628 - bl LoadCompressedObjectPaletteUsingHeap -_0807524E: - ldr r0, =sub_8075370 - bl CreateInvisibleSpriteWithCallback - mov r8, r0 - mov r0, r8 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r5, r0, 4 - add r5, r8 - lsls r5, 2 - ldr r0, =gSprites - adds r5, r0 - strh r4, [r5, 0x30] - ldr r0, =gUnknown_0831C688 - mov r9, r0 - lsls r6, 16 - asrs r0, r6, 16 - mov r10, r0 - ldr r0, =0xfff00000 - adds r6, r0 - asrs r6, 16 - lsls r4, r7, 16 - asrs r7, r4, 16 - adds r4, r0 - asrs r4, 16 - mov r0, r9 - adds r1, r6, 0 - adds r2, r4, 0 - movs r3, 0x2 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - ldr r0, =gSprites - adds r1, r0 - mov r0, r8 - strh r0, [r1, 0x2E] - ldrh r0, [r5, 0x2E] - adds r0, 0x1 - strh r0, [r5, 0x2E] - adds r0, r1, 0 - bl AnimateSprite - mov r0, r9 - mov r1, r10 - adds r2, r4, 0 - movs r3, 0x2 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 4 - adds r4, r0 - lsls r4, 2 - ldr r0, =gSprites - adds r4, r0 - mov r0, r8 - strh r0, [r4, 0x2E] - ldrh r0, [r5, 0x2E] - adds r0, 0x1 - strh r0, [r5, 0x2E] - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAnim - adds r0, r4, 0 - bl AnimateSprite - mov r0, r9 - adds r1, r6, 0 - adds r2, r7, 0 - movs r3, 0x2 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 4 - adds r4, r0 - lsls r4, 2 - ldr r0, =gSprites - adds r4, r0 - mov r0, r8 - strh r0, [r4, 0x2E] - ldrh r0, [r5, 0x2E] - adds r0, 0x1 - strh r0, [r5, 0x2E] - adds r0, r4, 0 - movs r1, 0x2 - bl StartSpriteAnim - adds r0, r4, 0 - bl AnimateSprite - mov r0, r9 - mov r1, r10 - adds r2, r7, 0 - movs r3, 0x2 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 4 - adds r4, r0 - lsls r4, 2 - ldr r0, =gSprites - adds r4, r0 - mov r0, r8 - strh r0, [r4, 0x2E] - ldrh r0, [r5, 0x2E] - adds r0, 0x1 - strh r0, [r5, 0x2E] - adds r0, r4, 0 - movs r1, 0x3 - bl StartSpriteAnim - adds r0, r4, 0 - bl AnimateSprite - mov r0, r8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_807521C - - thumb_func_start sub_8075370 -sub_8075370: @ 8075370 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x2E - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _080753A8 - ldr r0, =gUnknown_0831C620 - ldrh r0, [r0, 0x6] - bl FreeSpriteTilesByTag - ldr r0, =gUnknown_0831C628 - ldrh r0, [r0, 0x4] - bl FreeSpritePaletteByTag - movs r1, 0x30 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _080753A4 - adds r0, r4, 0 - bl DestroySprite - b _080753A8 - .pool -_080753A4: - ldr r0, =SpriteCallbackDummy - str r0, [r4, 0x1C] -_080753A8: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8075370 - - thumb_func_start sub_80753B4 -sub_80753B4: @ 80753B4 - push {lr} - adds r3, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _080753DE - ldr r2, =gSprites - movs r0, 0x2E - ldrsh r1, [r3, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x2E] - subs r1, 0x1 - strh r1, [r0, 0x2E] - adds r0, r3, 0 - bl DestroySprite -_080753DE: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80753B4 - - .align 2, 0 @ Don't pad with nop. diff --git a/include/data2.h b/include/data2.h index be0f33ab8..df71f6e88 100644 --- a/include/data2.h +++ b/include/data2.h @@ -16,5 +16,9 @@ extern const u8 gSpeciesNames[][POKEMON_NAME_LENGTH + 1]; extern const u8 gMoveNames[][13]; extern const u8 gAbilityNames[][13]; extern const u8 gTypeNames[][7]; +extern struct CompressedSpriteSheet gUnknown_0831C620; +extern struct CompressedSpritePalette gUnknown_0831C628; +extern const struct SpriteTemplate gUnknown_0831C688; + #endif // GUARD_DATA2_H diff --git a/ld_script.txt b/ld_script.txt index bf52fc49f..e16a592cd 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -79,7 +79,7 @@ SECTIONS { src/daycare.o(.text); src/egg_hatch.o(.text); src/battle_interface.o(.text); - asm/smokescreen.o(.text); + src/smokescreen.o(.text); src/pokeball.o(.text); src/load_save.o(.text); asm/trade.o(.text); diff --git a/src/smokescreen.c b/src/smokescreen.c new file mode 100644 index 000000000..4b0e5d759 --- /dev/null +++ b/src/smokescreen.c @@ -0,0 +1,73 @@ +#include "global.h" +#include "data2.h" +#include "decompress.h" +#include "sprite.h" +#include "util.h" + + +static void sub_8075370(struct Sprite *); + + +u8 sub_807521C(s16 x, s16 y, u8 a3) +{ + u8 mainSpriteId; + u8 spriteId1, spriteId2, spriteId3, spriteId4; + struct Sprite *mainSprite; + + if (GetSpriteTileStartByTag(gUnknown_0831C620.tag) == 0xFFFF) + { + LoadCompressedObjectPicUsingHeap(&gUnknown_0831C620); + LoadCompressedObjectPaletteUsingHeap(&gUnknown_0831C628); + } + + mainSpriteId = CreateInvisibleSpriteWithCallback(sub_8075370); + mainSprite = &gSprites[mainSpriteId]; + mainSprite->data[1] = a3; + + spriteId1 = CreateSprite(&gUnknown_0831C688, x - 16, y - 16, 2); + gSprites[spriteId1].data[0] = mainSpriteId; + mainSprite->data[0]++; + AnimateSprite(&gSprites[spriteId1]); + + spriteId2 = CreateSprite(&gUnknown_0831C688, x, y - 16, 2); + gSprites[spriteId2].data[0] = mainSpriteId; + mainSprite->data[0]++; + StartSpriteAnim(&gSprites[spriteId2], 1); + AnimateSprite(&gSprites[spriteId2]); + + spriteId3 = CreateSprite(&gUnknown_0831C688, x - 16, y, 2); + gSprites[spriteId3].data[0] = mainSpriteId; + mainSprite->data[0]++; + StartSpriteAnim(&gSprites[spriteId3], 2); + AnimateSprite(&gSprites[spriteId3]); + + spriteId4 = CreateSprite(&gUnknown_0831C688, x, y, 2); + gSprites[spriteId4].data[0] = mainSpriteId; + mainSprite->data[0]++; + StartSpriteAnim(&gSprites[spriteId4], 3); + AnimateSprite(&gSprites[spriteId4]); + + return mainSpriteId; +} + +static void sub_8075370(struct Sprite *sprite) +{ + if (!sprite->data[0]) + { + FreeSpriteTilesByTag(gUnknown_0831C620.tag); + FreeSpritePaletteByTag(gUnknown_0831C628.tag); + if (!sprite->data[1]) + DestroySprite(sprite); + else + sprite->callback = SpriteCallbackDummy; + } +} + +void sub_80753B4(struct Sprite *sprite) +{ + if (sprite->animEnded) + { + gSprites[sprite->data[0]].data[0]--; + DestroySprite(sprite); + } +} From 382442c4c8754262c77acb50930df31c63a62355 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 12 Feb 2018 15:01:43 +0100 Subject: [PATCH 09/27] start decompiling overworld.s --- asm/battle_frontier_1.s | 2 +- asm/battle_frontier_2.s | 4 +- asm/battle_records.s | 6 +- asm/field_control_avatar.s | 2 +- asm/field_effect.s | 6 +- asm/field_screen.s | 4 +- asm/fieldmap.s | 2 +- asm/fldeff_flash.s | 2 +- asm/overworld.s | 1073 ++------------------------------- asm/party_menu.s | 4 +- asm/pokedex_area_screen.s | 6 +- asm/pokenav.s | 6 +- asm/post_battle_event_funcs.s | 2 +- asm/rom6.s | 2 +- asm/roulette.s | 2 +- data/event_scripts.s | 6 +- data/overworld.s | 52 -- include/constants/game_stat.h | 5 +- include/global.h | 19 +- include/overworld.h | 51 +- ld_script.txt | 3 +- src/battle_script_commands.c | 4 +- src/field_map_obj.c | 2 +- src/item_use.c | 4 +- src/overworld.c | 541 ++++++++++++++++- src/region_map.c | 12 +- sym_ewram.txt | 16 +- 27 files changed, 675 insertions(+), 1163 deletions(-) delete mode 100644 data/overworld.s diff --git a/asm/battle_frontier_1.s b/asm/battle_frontier_1.s index 60ac46859..43966b607 100644 --- a/asm/battle_frontier_1.s +++ b/asm/battle_frontier_1.s @@ -14665,7 +14665,7 @@ sub_819672C: @ 819672C ldrh r2, [r0, 0xA] ldrh r1, [r0, 0xC] adds r0, r2, 0 - bl get_mapheader_by_bank_and_number + bl Overworld_GetMapHeaderByGroupAndId ldrb r0, [r0, 0x14] pop {r1} bx r1 diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index 11220f369..491a87948 100644 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -18683,7 +18683,7 @@ _081A4294: adds r0, r3, r4 ldrh r1, [r0] movs r0, 0x20 - bl sav12_xor_set + bl SetGameStat ldr r1, [r7] adds r0, r1, r6 adds r0, r4 @@ -31002,7 +31002,7 @@ sub_81AA810: @ 81AA810 ldrb r1, [r3] adds r1, 0x2C movs r0, 0x19 - bl get_mapheader_by_bank_and_number + bl Overworld_GetMapHeaderByGroupAndId adds r5, r0, 0 movs r7, 0 ldr r1, [r5, 0x4] diff --git a/asm/battle_records.s b/asm/battle_records.s index f688144d9..b203f339b 100644 --- a/asm/battle_records.s +++ b/asm/battle_records.s @@ -45,13 +45,13 @@ _0813BFCA: bge _0813BFCA movs r0, 0x17 movs r1, 0 - bl sav12_xor_set + bl SetGameStat movs r0, 0x18 movs r1, 0 - bl sav12_xor_set + bl SetGameStat movs r0, 0x19 movs r1, 0 - bl sav12_xor_set + bl SetGameStat pop {r4,r5} pop {r0} bx r0 diff --git a/asm/field_control_avatar.s b/asm/field_control_avatar.s index 89e6efa6a..240437049 100644 --- a/asm/field_control_avatar.s +++ b/asm/field_control_avatar.s @@ -2006,7 +2006,7 @@ _0809CF20: bl sub_8084D5C ldrb r0, [r5, 0x7] ldrb r1, [r5, 0x6] - bl get_mapheader_by_bank_and_number + bl Overworld_GetMapHeaderByGroupAndId ldr r1, [r0, 0x4] ldrb r0, [r5, 0x5] ldr r1, [r1, 0x8] diff --git a/asm/field_effect.s b/asm/field_effect.s index 80f2030aa..6d35cca61 100644 --- a/asm/field_effect.s +++ b/asm/field_effect.s @@ -2008,7 +2008,7 @@ _080B6A64: lsls r0, 24 cmp r0, 0 bne _080B6A8A - bl flag_var_implications_of_teleport_ + bl Overworld_ResetStateAfterFly bl warp_in ldr r0, =c2_load_new_map bl SetMainCallback2 @@ -4881,7 +4881,7 @@ _080B81B8: lsrs r0, 24 cmp r0, 0x1 bne _080B81E6 - bl copy_saved_warp3_bank_and_enter_x_to_warp1 + bl Overworld_SetWarpDestToLastHealLoc bl warp_in ldr r0, =c2_load_new_map bl SetMainCallback2 @@ -5211,7 +5211,7 @@ _080B8484: thumb_func_start sub_80B849C sub_80B849C: @ 80B849C push {r4,lr} - bl sav1_map_get_light_level + bl Overworld_GetMapTypeOfSaveblockLocation lsls r0, 24 lsrs r0, 24 bl is_light_level_1_2_3_5_or_6 diff --git a/asm/field_screen.s b/asm/field_screen.s index 0943fe1e3..0839e4bac 100644 --- a/asm/field_screen.s +++ b/asm/field_screen.s @@ -7855,7 +7855,7 @@ pal_fill_for_maplights: @ 80AF040 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl sav1_map_get_light_level + bl Overworld_GetMapTypeOfSaveblockLocation adds r1, r0, 0 lsls r1, 24 lsrs r1, 24 @@ -7910,7 +7910,7 @@ pal_fill_black: @ 80AF0A0 thumb_func_start sub_80AF0B4 sub_80AF0B4: @ 80AF0B4 push {r4,lr} - bl sav1_map_get_light_level + bl Overworld_GetMapTypeOfSaveblockLocation adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 diff --git a/asm/fieldmap.s b/asm/fieldmap.s index dbb8a3fa3..21aea8ad7 100644 --- a/asm/fieldmap.s +++ b/asm/fieldmap.s @@ -11,7 +11,7 @@ mapconnection_get_mapheader: @ 8087D44 ldrb r2, [r0, 0x8] ldrb r1, [r0, 0x9] adds r0, r2, 0 - bl get_mapheader_by_bank_and_number + bl Overworld_GetMapHeaderByGroupAndId pop {r1} bx r1 thumb_func_end mapconnection_get_mapheader diff --git a/asm/fldeff_flash.s b/asm/fldeff_flash.s index d52ee34fc..e7e605abe 100644 --- a/asm/fldeff_flash.s +++ b/asm/fldeff_flash.s @@ -217,7 +217,7 @@ sub_8137304: @ 8137304 bl get_map_light_from_warp0 lsls r0, 24 lsrs r6, r0, 24 - bl sav1_map_get_light_level + bl Overworld_GetMapTypeOfSaveblockLocation lsls r0, 24 lsrs r5, r0, 24 movs r3, 0 diff --git a/asm/overworld.s b/asm/overworld.s index 64ee678df..25c479c10 100644 --- a/asm/overworld.s +++ b/asm/overworld.s @@ -5,1008 +5,9 @@ .text - thumb_func_start sub_8084620 -sub_8084620: @ 8084620 - push {r4,lr} - ldr r0, =EverGrandeCity_HallOfFame_EventScript_271857 - bl ScriptContext2_RunNewScript - ldr r0, =gSaveBlock1Ptr - ldr r4, [r0] - movs r0, 0x92 - lsls r0, 3 - adds r4, r0 - adds r0, r4, 0 - bl GetMoney - adds r1, r0, 0 - lsrs r1, 1 - adds r0, r4, 0 - bl SetMoney - bl HealPlayerParty - bl sub_8084720 - bl copy_saved_warp3_bank_and_enter_x_to_warp1 - bl warp_in - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8084620 - - thumb_func_start flag_var_implications_of_teleport_ -flag_var_implications_of_teleport_: @ 8084660 - push {lr} - bl player_avatar_init_params_reset - ldr r0, =0x0000088b - bl FlagClear - ldr r0, =0x0000088d - bl FlagClear - ldr r0, =0x0000088c - bl FlagClear - ldr r0, =0x00000889 - bl FlagClear - ldr r0, =0x00000888 - bl FlagClear - pop {r0} - bx r0 - .pool - thumb_func_end flag_var_implications_of_teleport_ - - thumb_func_start Overworld_ResetStateAfterTeleport -Overworld_ResetStateAfterTeleport: @ 808469C - push {lr} - bl player_avatar_init_params_reset - ldr r0, =0x0000088b - bl FlagClear - ldr r0, =0x0000088d - bl FlagClear - ldr r0, =0x0000088c - bl FlagClear - ldr r0, =0x00000889 - bl FlagClear - ldr r0, =0x00000888 - bl FlagClear - ldr r0, =EverGrandeCity_HallOfFame_EventScript_271862 - bl ScriptContext2_RunNewScript - pop {r0} - bx r0 - .pool - thumb_func_end Overworld_ResetStateAfterTeleport - - thumb_func_start flagmods_08054D70 -flagmods_08054D70: @ 80846E4 - push {lr} - bl player_avatar_init_params_reset - ldr r0, =0x0000088b - bl FlagClear - ldr r0, =0x0000088d - bl FlagClear - ldr r0, =0x0000088c - bl FlagClear - ldr r0, =0x00000889 - bl FlagClear - ldr r0, =0x00000888 - bl FlagClear - pop {r0} - bx r0 - .pool - thumb_func_end flagmods_08054D70 - - thumb_func_start sub_8084720 -sub_8084720: @ 8084720 - push {r4,lr} - bl player_avatar_init_params_reset - ldr r0, =0x0000088b - bl FlagClear - ldr r0, =0x0000088d - bl FlagClear - ldr r0, =0x0000088c - bl FlagClear - ldr r0, =0x00000889 - bl FlagClear - ldr r0, =0x00000888 - bl FlagClear - ldr r4, =0x00004039 - adds r0, r4, 0 - bl VarGet - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - bne _08084764 - adds r0, r4, 0 - movs r1, 0 - bl VarSet - ldr r0, =0x00004037 - movs r1, 0 - bl VarSet -_08084764: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8084720 - - thumb_func_start sub_8084788 -sub_8084788: @ 8084788 - push {lr} - ldr r0, =0x0000088c - bl FlagClear - bl sub_8085B2C - bl ResetCyclingRoadChallengeData - bl UpdateLocationHistoryForRoamer - bl RoamerMoveToOtherLocationSet - pop {r0} - bx r0 - .pool - thumb_func_end sub_8084788 - - thumb_func_start ResetGameStats -ResetGameStats: @ 80847A8 - push {r4,lr} - movs r4, 0 -_080847AC: - lsls r0, r4, 24 - lsrs r0, 24 - movs r1, 0 - bl sav12_xor_set - adds r4, 0x1 - cmp r4, 0x3F - ble _080847AC - pop {r4} - pop {r0} - bx r0 - thumb_func_end ResetGameStats - - thumb_func_start IncrementGameStat -@ void IncrementGameStat(u8 a1) -IncrementGameStat: @ 80847C4 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x33 - bhi _080847EC - adds r0, r4, 0 - bl GetGameStat - adds r1, r0, 0 - ldr r0, =0x00fffffe - cmp r1, r0 - bhi _080847E4 - adds r1, 0x1 - b _080847E6 - .pool -_080847E4: - ldr r1, =0x00ffffff -_080847E6: - adds r0, r4, 0 - bl sav12_xor_set -_080847EC: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end IncrementGameStat - - thumb_func_start GetGameStat -GetGameStat: @ 80847F8 - push {lr} - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x33 - bhi _08084828 - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - lsls r0, r1, 2 - ldr r1, =0x0000159c - adds r2, r1 - adds r2, r0 - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - adds r1, 0xAC - ldr r0, [r2] - ldr r1, [r1] - eors r0, r1 - b _0808482A - .pool -_08084828: - movs r0, 0 -_0808482A: - pop {r1} - bx r1 - thumb_func_end GetGameStat - - thumb_func_start sav12_xor_set -sav12_xor_set: @ 8084830 - push {lr} - adds r3, r1, 0 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x33 - bhi _08084854 - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - lsls r0, r2, 2 - ldr r2, =0x0000159c - adds r1, r2 - adds r1, r0 - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - adds r0, 0xAC - ldr r0, [r0] - eors r0, r3 - str r0, [r1] -_08084854: - pop {r0} - bx r0 - .pool - thumb_func_end sav12_xor_set - - thumb_func_start ApplyNewEncryptionKeyToGameStats -ApplyNewEncryptionKeyToGameStats: @ 8084864 - push {r4-r6,lr} - adds r5, r0, 0 - movs r4, 0 - ldr r6, =gSaveBlock1Ptr -_0808486C: - lsls r1, r4, 2 - ldr r0, =0x0000159c - adds r1, r0 - ldr r0, [r6] - adds r0, r1 - adds r1, r5, 0 - bl ApplyNewEncryptionKeyToWord - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x3F - bls _0808486C - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end ApplyNewEncryptionKeyToGameStats - - thumb_func_start CopyFieldObjectTemplatesToSav1 -@ void CopyFieldObjectTemplatesToSav1() -CopyFieldObjectTemplatesToSav1: @ 8084894 - push {r4,r5,lr} - sub sp, 0x4 - movs r0, 0 - str r0, [sp] - ldr r5, =gSaveBlock1Ptr - ldr r1, [r5] - movs r4, 0xC7 - lsls r4, 4 - adds r1, r4 - ldr r2, =0x05000180 - mov r0, sp - bl CpuSet - ldr r0, =gMapHeader - ldr r2, [r0, 0x4] - ldr r0, [r2, 0x4] - ldr r1, [r5] - adds r1, r4 - ldrb r3, [r2] - lsls r2, r3, 1 - adds r2, r3 - lsls r2, 1 - movs r3, 0x80 - lsls r3, 19 - orrs r2, r3 - bl CpuSet - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end CopyFieldObjectTemplatesToSav1 - - thumb_func_start CopyFieldObjectTemplateCoordsToSav1 -@ void CopyFieldObjectTemplateCoordsToSav1() -CopyFieldObjectTemplateCoordsToSav1: @ 80848E0 - push {lr} - ldr r0, =gMapHeader - ldr r1, [r0, 0x4] - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r2, [r1, 0x4] - movs r3, 0xC7 - lsls r3, 4 - adds r1, r0, r3 - movs r3, 0x3F -_080848F4: - ldr r0, [r2, 0x10] - str r0, [r1, 0x10] - adds r2, 0x18 - adds r1, 0x18 - subs r3, 0x1 - cmp r3, 0 - bge _080848F4 - pop {r0} - bx r0 - .pool - thumb_func_end CopyFieldObjectTemplateCoordsToSav1 - - thumb_func_start Overworld_SetMapObjTemplateCoords -Overworld_SetMapObjTemplateCoords: @ 8084910 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r1, 16 - lsrs r4, r1, 16 - lsls r2, 16 - lsrs r2, 16 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r1, 0 - movs r6, 0xC7 - lsls r6, 4 - adds r3, r0, r6 -_0808492A: - ldrb r0, [r3] - cmp r0, r5 - bne _0808493C - strh r4, [r3, 0x4] - strh r2, [r3, 0x6] - b _08084944 - .pool -_0808493C: - adds r3, 0x18 - adds r1, 0x1 - cmp r1, 0x3F - ble _0808492A -_08084944: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end Overworld_SetMapObjTemplateCoords - - thumb_func_start Overworld_SetMapObjTemplateMovementType -Overworld_SetMapObjTemplateMovementType: @ 808494C - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r1, 24 - lsrs r1, 24 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r3, 0 - movs r5, 0xC7 - lsls r5, 4 - adds r2, r0, r5 -_08084962: - ldrb r0, [r2] - cmp r0, r4 - bne _08084970 - strb r1, [r2, 0x9] - b _08084978 - .pool -_08084970: - adds r2, 0x18 - adds r3, 0x1 - cmp r3, 0x3F - ble _08084962 -_08084978: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end Overworld_SetMapObjTemplateMovementType - - thumb_func_start mapdata_load_assets_to_gpu_and_full_redraw -mapdata_load_assets_to_gpu_and_full_redraw: @ 8084980 - push {r4,lr} - bl move_tilemap_camera_to_upper_left_corner - ldr r4, =gMapHeader - ldr r0, [r4] - bl copy_map_tileset1_tileset2_to_vram - ldr r0, [r4] - bl apply_map_tileset1_tileset2_palette - bl DrawWholeMapView - bl cur_mapheader_run_tileset_funcs_after_some_cpuset - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end mapdata_load_assets_to_gpu_and_full_redraw - - thumb_func_start get_mapdata_header -@ mapdata_header *get_mapdata_header() -get_mapdata_header: @ 80849A8 - push {lr} - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldrh r1, [r0, 0x32] - cmp r1, 0 - bne _080849BC - movs r0, 0 - b _080849C6 - .pool -_080849BC: - ldr r0, =gMapAttributes - subs r1, 0x1 - lsls r1, 2 - adds r1, r0 - ldr r0, [r1] -_080849C6: - pop {r1} - bx r1 - .pool - thumb_func_end get_mapdata_header - - thumb_func_start warp_shift -@ void warp_shift() -warp_shift: @ 80849D0 - ldr r3, =gUnknown_020322DC - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - ldr r0, [r2, 0x4] - ldr r1, [r2, 0x8] - str r0, [r3] - str r1, [r3, 0x4] - ldr r0, =gUnknown_020322E4 - ldr r1, [r0, 0x4] - ldr r0, [r0] - str r0, [r2, 0x4] - str r1, [r2, 0x8] - ldr r2, =gUnknown_020322EC - ldr r0, =gUnknown_08339D3C - ldr r1, [r0, 0x4] - ldr r0, [r0] - str r0, [r2] - str r1, [r2, 0x4] - ldr r2, =gUnknown_020322F4 - str r0, [r2] - str r1, [r2, 0x4] - bx lr - .pool - thumb_func_end warp_shift - - thumb_func_start set_warp2_warp3_to_neg_1 -@ void set_warp2_warp3_to_neg_1() -set_warp2_warp3_to_neg_1: @ 8084A14 - ldr r2, =gUnknown_020322EC - ldr r0, =gUnknown_08339D3C - ldr r1, [r0, 0x4] - ldr r0, [r0] - str r0, [r2] - str r1, [r2, 0x4] - ldr r2, =gUnknown_020322F4 - str r0, [r2] - str r1, [r2, 0x4] - bx lr - .pool - thumb_func_end set_warp2_warp3_to_neg_1 - - thumb_func_start warp_set -@ void warp_set(warpdata *warp, char bank, char map, char warpid, char enter_x, char enter_y) -warp_set: @ 8084A34 - push {r4,r5,lr} - ldr r4, [sp, 0xC] - ldr r5, [sp, 0x10] - strb r1, [r0] - strb r2, [r0, 0x1] - strb r3, [r0, 0x2] - lsls r4, 24 - asrs r4, 24 - strh r4, [r0, 0x4] - lsls r5, 24 - asrs r5, 24 - strh r5, [r0, 0x6] - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end warp_set - - thumb_func_start warp_data_is_not_neg_1 -@ int warp_data_is_not_neg_1(warpdata *warp) -warp_data_is_not_neg_1: @ 8084A54 - push {lr} - adds r1, r0, 0 - movs r2, 0 - ldrsb r2, [r1, r2] - movs r0, 0x1 - negs r0, r0 - cmp r2, r0 - bne _08084A88 - movs r0, 0x1 - ldrsb r0, [r1, r0] - cmp r0, r2 - bne _08084A88 - movs r2, 0x2 - ldrsb r2, [r1, r2] - cmp r2, r0 - bne _08084A88 - movs r0, 0x4 - ldrsh r3, [r1, r0] - cmp r3, r2 - bne _08084A88 - movs r2, 0x6 - ldrsh r0, [r1, r2] - cmp r0, r3 - bne _08084A88 - movs r0, 0x1 - b _08084A8A -_08084A88: - movs r0, 0 -_08084A8A: - pop {r1} - bx r1 - thumb_func_end warp_data_is_not_neg_1 - - thumb_func_start get_mapheader_by_bank_and_number -@ struct mapheader *get_mapheader_by_bank_and_number(unsigned int bank, unsigned int num) -get_mapheader_by_bank_and_number: @ 8084A90 - lsls r0, 16 - lsls r1, 16 - ldr r2, =gMapGroups - lsrs r0, 14 - adds r0, r2 - ldr r0, [r0] - lsrs r1, 14 - adds r1, r0 - ldr r0, [r1] - bx lr - .pool - thumb_func_end get_mapheader_by_bank_and_number - - thumb_func_start warp1_get_mapheader -@ struct mapheader *warp1_get_mapheader() -warp1_get_mapheader: @ 8084AA8 - push {lr} - ldr r1, =gUnknown_020322E4 - movs r0, 0 - ldrsb r0, [r1, r0] - lsls r0, 16 - lsrs r0, 16 - ldrb r1, [r1, 0x1] - lsls r1, 24 - asrs r1, 24 - lsls r1, 16 - lsrs r1, 16 - bl get_mapheader_by_bank_and_number - pop {r1} - bx r1 - .pool - thumb_func_end warp1_get_mapheader - - thumb_func_start set_current_map_header_from_sav1_save_old_name -@ void set_current_map_header_from_sav1_save_old_name() -set_current_map_header_from_sav1_save_old_name: @ 8084ACC - push {r4-r6,lr} - ldr r1, =gUnknown_020322FC - ldr r4, =gMapHeader - ldrb r0, [r4, 0x14] - strh r0, [r1] - ldr r5, =gSaveBlock1Ptr - ldr r1, [r5] - movs r0, 0x4 - ldrsb r0, [r1, r0] - lsls r0, 16 - lsrs r0, 16 - ldrb r1, [r1, 0x5] - lsls r1, 24 - asrs r1, 24 - lsls r1, 16 - lsrs r1, 16 - bl get_mapheader_by_bank_and_number - adds r1, r4, 0 - ldm r0!, {r2,r3,r6} - stm r1!, {r2,r3,r6} - ldm r0!, {r2,r3,r6} - stm r1!, {r2,r3,r6} - ldr r0, [r0] - str r0, [r1] - ldr r1, [r5] - ldrh r0, [r4, 0x12] - strh r0, [r1, 0x32] - bl get_mapdata_header - str r0, [r4] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end set_current_map_header_from_sav1_save_old_name - - thumb_func_start set_current_map_header_from_sav1 -set_current_map_header_from_sav1: @ 8084B1C - push {r4,r5,lr} - ldr r4, =gMapHeader - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - movs r0, 0x4 - ldrsb r0, [r1, r0] - lsls r0, 16 - lsrs r0, 16 - ldrb r1, [r1, 0x5] - lsls r1, 24 - asrs r1, 24 - lsls r1, 16 - lsrs r1, 16 - bl get_mapheader_by_bank_and_number - adds r1, r4, 0 - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - ldr r0, [r0] - str r0, [r1] - bl get_mapdata_header - str r0, [r4] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end set_current_map_header_from_sav1 - - thumb_func_start update_camera_pos_from_warpid -@ void update_camera_pos_from_warpid() -update_camera_pos_from_warpid: @ 8084B5C - push {r4,r5,lr} - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - movs r1, 0x6 - ldrsb r1, [r2, r1] - adds r4, r0, 0 - cmp r1, 0 - blt _08084B94 - ldr r3, =gMapHeader - ldr r0, [r3, 0x4] - ldrb r5, [r0, 0x1] - cmp r1, r5 - bge _08084B94 - ldr r0, [r0, 0x8] - lsls r1, 3 - adds r0, r1, r0 - ldrh r0, [r0] - strh r0, [r2] - ldr r0, [r3, 0x4] - ldr r0, [r0, 0x8] - adds r1, r0 - ldrh r0, [r1, 0x2] - strh r0, [r2, 0x2] - b _08084BCC - .pool -_08084B94: - ldr r1, [r4] - ldrh r3, [r1, 0x8] - movs r2, 0x8 - ldrsh r0, [r1, r2] - cmp r0, 0 - blt _08084BB0 - ldrh r2, [r1, 0xA] - movs r5, 0xA - ldrsh r0, [r1, r5] - cmp r0, 0 - blt _08084BB0 - strh r3, [r1] - strh r2, [r1, 0x2] - b _08084BCC -_08084BB0: - ldr r3, [r4] - ldr r2, =gMapHeader - ldr r0, [r2] - ldr r0, [r0] - lsrs r1, r0, 31 - adds r0, r1 - asrs r0, 1 - strh r0, [r3] - ldr r0, [r2] - ldr r0, [r0, 0x4] - lsrs r1, r0, 31 - adds r0, r1 - asrs r0, 1 - strh r0, [r3, 0x2] -_08084BCC: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end update_camera_pos_from_warpid - - thumb_func_start warp_in -warp_in: @ 8084BD8 - push {lr} - bl warp_shift - bl set_current_map_header_from_sav1_save_old_name - bl update_camera_pos_from_warpid - pop {r0} - bx r0 - thumb_func_end warp_in - - thumb_func_start Overworld_SetWarpDestination -@ void Overworld_SetWarpDestination(char bank, char map, char warpid, char enter_x, char enter_y) -Overworld_SetWarpDestination: @ 8084BEC - push {r4-r6,lr} - sub sp, 0x8 - adds r4, r0, 0 - adds r5, r1, 0 - adds r6, r2, 0 - ldr r1, [sp, 0x18] - ldr r0, =gUnknown_020322E4 - lsls r4, 24 - asrs r4, 24 - lsls r5, 24 - asrs r5, 24 - lsls r6, 24 - asrs r6, 24 - lsls r3, 24 - asrs r3, 24 - str r3, [sp] - lsls r1, 24 - asrs r1, 24 - str r1, [sp, 0x4] - adds r1, r4, 0 - adds r2, r5, 0 - adds r3, r6, 0 - bl warp_set - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end Overworld_SetWarpDestination - - thumb_func_start warp1_set_2 -@ void warp1_set_2(char bank, char map, char warpid) -warp1_set_2: @ 8084C28 - push {lr} - sub sp, 0x4 - lsls r0, 24 - asrs r0, 24 - lsls r1, 24 - asrs r1, 24 - lsls r2, 24 - asrs r2, 24 - movs r3, 0x1 - negs r3, r3 - str r3, [sp] - bl Overworld_SetWarpDestination - add sp, 0x4 - pop {r0} - bx r0 - thumb_func_end warp1_set_2 - - thumb_func_start saved_warp2_set -@ void saved_warp2_set(char bank, char map, char warpid) -saved_warp2_set: @ 8084C48 - push {r4,r5,lr} - sub sp, 0x8 - ldr r0, =gSaveBlock1Ptr - ldr r5, [r0] - adds r0, r5, 0 - adds r0, 0x14 - lsls r1, 24 - asrs r1, 24 - lsls r2, 24 - asrs r2, 24 - lsls r3, 24 - asrs r3, 24 - movs r4, 0 - ldrsb r4, [r5, r4] - str r4, [sp] - movs r4, 0x2 - ldrsb r4, [r5, r4] - str r4, [sp, 0x4] - bl warp_set - add sp, 0x8 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end saved_warp2_set - - thumb_func_start saved_warp2_set_2 -saved_warp2_set_2: @ 8084C7C - push {r4,r5,lr} - sub sp, 0x8 - ldr r4, [sp, 0x14] - ldr r5, [sp, 0x18] - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - adds r0, 0x14 - lsls r1, 24 - asrs r1, 24 - lsls r2, 24 - asrs r2, 24 - lsls r3, 24 - asrs r3, 24 - lsls r4, 24 - asrs r4, 24 - str r4, [sp] - lsls r5, 24 - asrs r5, 24 - str r5, [sp, 0x4] - bl warp_set - add sp, 0x8 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end saved_warp2_set_2 - - thumb_func_start copy_saved_warp2_bank_and_enter_x_to_warp1 -copy_saved_warp2_bank_and_enter_x_to_warp1: @ 8084CB4 - ldr r2, =gUnknown_020322E4 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, [r0, 0x18] - ldr r0, [r0, 0x14] - str r0, [r2] - str r1, [r2, 0x4] - bx lr - .pool - thumb_func_end copy_saved_warp2_bank_and_enter_x_to_warp1 - - thumb_func_start sub_8084CCC -@ void sub_8084CCC(int a1) -sub_8084CCC: @ 8084CCC - push {r4,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - bl GetHealLocationPointer - adds r4, r0, 0 - cmp r4, 0 - beq _08084CFA - movs r0, 0 - ldrsb r0, [r4, r0] - movs r1, 0x1 - ldrsb r1, [r4, r1] - movs r2, 0x1 - negs r2, r2 - movs r3, 0x2 - ldrsb r3, [r4, r3] - ldrb r4, [r4, 0x4] - lsls r4, 24 - asrs r4, 24 - str r4, [sp] - bl Overworld_SetWarpDestination -_08084CFA: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8084CCC - - thumb_func_start copy_saved_warp3_bank_and_enter_x_to_warp1 -@ void copy_saved_warp3_bank_and_enter_x_to_warp1() -copy_saved_warp3_bank_and_enter_x_to_warp1: @ 8084D04 - ldr r2, =gUnknown_020322E4 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, [r0, 0x20] - ldr r0, [r0, 0x1C] - str r0, [r2] - str r1, [r2, 0x4] - bx lr - .pool - thumb_func_end copy_saved_warp3_bank_and_enter_x_to_warp1 - - thumb_func_start Overworld_SetHealLocationWarp -Overworld_SetHealLocationWarp: @ 8084D1C - push {r4,r5,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r0, 24 - bl GetHealLocationPointer - adds r5, r0, 0 - cmp r5, 0 - beq _08084D50 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - adds r0, 0x1C - movs r1, 0 - ldrsb r1, [r5, r1] - movs r2, 0x1 - ldrsb r2, [r5, r2] - movs r3, 0x1 - negs r3, r3 - movs r4, 0x2 - ldrsb r4, [r5, r4] - str r4, [sp] - movs r4, 0x4 - ldrsb r4, [r5, r4] - str r4, [sp, 0x4] - bl warp_set -_08084D50: - add sp, 0x8 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end Overworld_SetHealLocationWarp - - thumb_func_start sub_8084D5C -sub_8084D5C: @ 8084D5C - push {r4-r7,lr} - sub sp, 0x4 - lsls r0, 16 - lsrs r6, r0, 16 - lsls r1, 16 - lsrs r7, r1, 16 - bl sav1_map_get_light_level - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r1, =gUnknown_020322E4 - movs r0, 0 - ldrsb r0, [r1, r0] - ldrb r1, [r1, 0x1] - lsls r1, 24 - asrs r1, 24 - bl get_map_light_level_by_bank_and_number - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r4, 0 - bl is_light_level_1_2_3_5_or_6 - lsls r0, 24 - cmp r0, 0 - beq _08084DC4 - adds r0, r5, 0 - bl is_light_level_1_2_3_5_or_6 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08084DC4 - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - movs r0, 0x4 - ldrsb r0, [r1, r0] - ldrb r1, [r1, 0x5] - lsls r1, 24 - asrs r1, 24 - movs r2, 0x1 - negs r2, r2 - subs r3, r6, 0x7 - lsls r3, 24 - asrs r3, 24 - subs r4, r7, 0x6 - lsls r4, 24 - asrs r4, 24 - str r4, [sp] - bl sub_8084DD4 -_08084DC4: - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8084D5C - - thumb_func_start sub_8084DD4 -sub_8084DD4: @ 8084DD4 - push {r4-r6,lr} - sub sp, 0x8 - adds r4, r0, 0 - adds r5, r1, 0 - adds r6, r2, 0 - ldr r1, [sp, 0x18] - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - adds r0, 0x24 - lsls r4, 24 - asrs r4, 24 - lsls r5, 24 - asrs r5, 24 - lsls r6, 24 - asrs r6, 24 - lsls r3, 24 - asrs r3, 24 - str r3, [sp] - lsls r1, 24 - asrs r1, 24 - str r1, [sp, 0x4] - adds r1, r4, 0 - adds r2, r5, 0 - adds r3, r6, 0 - bl warp_set - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8084DD4 - thumb_func_start sub_8084E14 sub_8084E14: @ 8084E14 - ldr r2, =gUnknown_020322E4 + ldr r2, =gWarpDestination ldr r0, =gSaveBlock1Ptr ldr r0, [r0] ldr r1, [r0, 0x28] @@ -1041,7 +42,7 @@ sub_8084E2C: @ 8084E2C adds r1, r4, 0 adds r2, r5, 0 adds r3, r6, 0 - bl warp_set + bl SetWarpData add sp, 0x8 pop {r4-r6} pop {r0} @@ -1051,7 +52,7 @@ sub_8084E2C: @ 8084E2C thumb_func_start warp1_set_to_warp2 warp1_set_to_warp2: @ 8084E68 - ldr r2, =gUnknown_020322E4 + ldr r2, =gWarpDestination ldr r0, =gUnknown_020322EC ldr r1, [r0, 0x4] ldr r0, [r0] @@ -1085,7 +86,7 @@ sub_8084E80: @ 8084E80 adds r1, r4, 0 adds r2, r5, 0 adds r3, r6, 0 - bl warp_set + bl SetWarpData add sp, 0x8 pop {r4-r6} pop {r0} @@ -1106,7 +107,7 @@ sub_8084EBC: @ 8084EBC bl warp_data_is_not_neg_1 cmp r0, 0x1 bne _08084EF0 - ldr r2, =gUnknown_020322E4 + ldr r2, =gWarpDestination ldr r0, =gUnknown_020322DC ldr r1, [r0, 0x4] ldr r0, [r0] @@ -1136,7 +137,7 @@ _08084F0A: thumb_func_start warp1_set_to_sav1w warp1_set_to_sav1w: @ 8084F14 - ldr r2, =gUnknown_020322E4 + ldr r2, =gWarpDestination ldr r0, =gSaveBlock1Ptr ldr r0, [r0] ldr r1, [r0, 0x10] @@ -1173,7 +174,7 @@ sub_8084F2C: @ 8084F2C adds r1, r4, 0 adds r2, r5, 0 adds r3, r6, 0 - bl warp_set + bl SetWarpData add sp, 0x8 pop {r4-r6} pop {r0} @@ -1206,7 +207,7 @@ sub_8084F6C: @ 8084F6C movs r4, 0x4 ldrsb r4, [r5, r4] str r4, [sp, 0x4] - bl warp_set + bl SetWarpData _08084FA0: add sp, 0x8 pop {r4,r5} @@ -1372,9 +373,9 @@ mliX_load_map: @ 8085098 beq _080850C8 bl sub_8085810 _080850C8: - bl warp_shift + bl ApplyCurrentWarp bl set_current_map_header_from_sav1_save_old_name - bl CopyFieldObjectTemplatesToSav1 + bl LoadMapObjTemplatesFromHeader bl TrySetMapSaveWarpStatus bl ClearTempFieldEventData bl ResetCyclingRoadChallengeData @@ -1384,7 +385,7 @@ _080850C8: bl TryUpdateRandomTrainerRematches bl DoTimeBasedEvents bl SetSav1WeatherFromCurrMapHeader - bl sub_8085B2C + bl ChooseAmbientCrySpecies bl update_sav1_flash_used_on_map bl Overworld_ClearSavedMusic bl mapheader_run_script_with_tag_x3 @@ -1411,7 +412,7 @@ _08085116: ldrb r0, [r2, 0x14] cmp r0, 0x3A bne _0808514C - ldr r1, =gUnknown_020322FC + ldr r1, =gLastMapSectionId ldrh r1, [r1] cmp r0, r1 beq _08085150 @@ -1451,7 +452,7 @@ _08085190: bl sub_81D5DF8 b _080851A2 _0808519E: - bl CopyFieldObjectTemplatesToSav1 + bl LoadMapObjTemplatesFromHeader _080851A2: ldr r4, =gMapHeader ldrb r0, [r4, 0x17] @@ -1484,7 +485,7 @@ _080851A2: bl DoTimeBasedEvents _080851EE: bl SetSav1WeatherFromCurrMapHeader - bl sub_8085B2C + bl ChooseAmbientCrySpecies cmp r5, 0 beq _08085200 ldr r0, =0x00000888 @@ -1589,7 +590,7 @@ _080852CA: thumb_func_start sub_80852D4 sub_80852D4: @ 80852D4 push {r4-r7,lr} - bl sav1_map_get_light_level + bl Overworld_GetMapTypeOfSaveblockLocation adds r5, r0, 0 lsls r5, 24 lsrs r5, 24 @@ -2111,7 +1112,7 @@ _080856A4: ldrsb r1, [r4, r1] lsls r1, 16 lsrs r1, 16 - bl get_mapheader_by_bank_and_number + bl Overworld_GetMapHeaderByGroupAndId ldrh r0, [r0, 0x10] b _080856CE _080856CA: @@ -2175,7 +1176,7 @@ _08085730: thumb_func_start warp1_target_get_music warp1_target_get_music: @ 8085738 push {lr} - ldr r0, =gUnknown_020322E4 + ldr r0, =gWarpDestination bl warp_target_get_music lsls r0, 16 lsrs r1, r0, 16 @@ -2233,7 +1234,7 @@ Overworld_PlaySpecialMapMusic: @ 8085784 b _080857D6 .pool _080857B4: - bl sav1_map_get_light_level + bl Overworld_GetMapTypeOfSaveblockLocation lsls r0, 24 lsrs r0, 24 cmp r0, 0x5 @@ -2441,7 +1442,7 @@ music_something: @ 8085910 lsls r0, 3 cmp r2, r0 bne _08085972 - ldr r3, =gUnknown_020322E4 + ldr r3, =gWarpDestination ldrh r0, [r3] ands r1, r0 cmp r1, r2 @@ -2658,8 +1659,8 @@ _08085B20: bx r0 thumb_func_end wild_encounter_related - thumb_func_start sub_8085B2C -sub_8085B2C: @ 8085B2C + thumb_func_start ChooseAmbientCrySpecies +ChooseAmbientCrySpecies: @ 8085B2C push {lr} ldr r0, =gSaveBlock1Ptr ldr r0, [r0] @@ -2687,11 +1688,11 @@ _08085B62: pop {r0} bx r0 .pool - thumb_func_end sub_8085B2C + thumb_func_end ChooseAmbientCrySpecies - thumb_func_start get_map_light_level_by_bank_and_number -@ int get_map_light_level_by_bank_and_number(int bank, int number) -get_map_light_level_by_bank_and_number: @ 8085B74 + thumb_func_start GetMapTypeByGroupAndId +@ int GetMapTypeByGroupAndId(int bank, int number) +GetMapTypeByGroupAndId: @ 8085B74 push {lr} lsls r0, 24 asrs r0, 8 @@ -2699,11 +1700,11 @@ get_map_light_level_by_bank_and_number: @ 8085B74 lsls r1, 24 asrs r1, 8 lsrs r1, 16 - bl get_mapheader_by_bank_and_number + bl Overworld_GetMapHeaderByGroupAndId ldrb r0, [r0, 0x17] pop {r1} bx r1 - thumb_func_end get_map_light_level_by_bank_and_number + thumb_func_end GetMapTypeByGroupAndId thumb_func_start get_map_light_level_from_warp @ int get_map_light_level_from_warp(warpdata *warp) @@ -2714,15 +1715,15 @@ get_map_light_level_from_warp: @ 8085B8C movs r1, 0x1 ldrsb r1, [r0, r1] adds r0, r2, 0 - bl get_map_light_level_by_bank_and_number + bl GetMapTypeByGroupAndId lsls r0, 24 lsrs r0, 24 pop {r1} bx r1 thumb_func_end get_map_light_level_from_warp - thumb_func_start sav1_map_get_light_level -sav1_map_get_light_level: @ 8085BA4 + thumb_func_start Overworld_GetMapTypeOfSaveblockLocation +Overworld_GetMapTypeOfSaveblockLocation: @ 8085BA4 push {lr} ldr r0, =gSaveBlock1Ptr ldr r0, [r0] @@ -2733,7 +1734,7 @@ sav1_map_get_light_level: @ 8085BA4 pop {r1} bx r1 .pool - thumb_func_end sav1_map_get_light_level + thumb_func_end Overworld_GetMapTypeOfSaveblockLocation thumb_func_start get_map_light_from_warp0 get_map_light_from_warp0: @ 8085BBC @@ -2828,7 +1829,7 @@ sav1_saved_warp2_map_get_name: @ 8085C30 asrs r1, 24 lsls r1, 16 lsrs r1, 16 - bl get_mapheader_by_bank_and_number + bl Overworld_GetMapHeaderByGroupAndId ldrb r0, [r0, 0x14] pop {r1} bx r1 @@ -2849,7 +1850,7 @@ sav1_map_get_name: @ 8085C58 asrs r1, 24 lsls r1, 16 lsrs r1, 16 - bl get_mapheader_by_bank_and_number + bl Overworld_GetMapHeaderByGroupAndId ldrb r0, [r0, 0x14] pop {r1} bx r1 @@ -2870,7 +1871,7 @@ GetCurrentMapBattleScene: @ 8085C80 asrs r1, 24 lsls r1, 16 lsrs r1, 16 - bl get_mapheader_by_bank_and_number + bl Overworld_GetMapHeaderByGroupAndId ldrb r0, [r0, 0x1B] pop {r1} bx r1 @@ -3210,7 +2211,7 @@ CB2_WhiteOut: @ 8085F58 bl sub_808631C bl StopMapMusic bl ResetSafariZoneFlag_ - bl sub_8084620 + bl DoWhiteOut bl player_avatar_init_params_reset bl ScriptContext1_Init bl ScriptContext2_Disable @@ -3502,7 +2503,7 @@ sub_8086230: @ 8086230 bne _0808624A bl sub_81A3908 _0808624A: - bl set_current_map_header_from_sav1 + bl LoadSaveblockMapHeader bl set_warp2_warp3_to_neg_1 bl GetCurrentTrainerHillMapId lsls r0, 24 @@ -3523,7 +2524,7 @@ _08086278: bl sub_81D5F48 b _0808628A _08086286: - bl CopyFieldObjectTemplateCoordsToSav1 + bl LoadSaveblockMapObjScripts _0808628A: bl UnfreezeMapObjects bl DoTimeBasedEvents diff --git a/asm/party_menu.s b/asm/party_menu.s index 6e134d444..0827a5a12 100644 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -10032,7 +10032,7 @@ _081B557C: asrs r1, 24 lsls r1, 16 lsrs r1, 16 - bl get_mapheader_by_bank_and_number + bl Overworld_GetMapHeaderByGroupAndId adds r1, r0, 0 ldr r0, =gStringVar1 ldrb r1, [r1, 0x14] @@ -10057,7 +10057,7 @@ _081B55B8: asrs r1, 24 lsls r1, 16 lsrs r1, 16 - bl get_mapheader_by_bank_and_number + bl Overworld_GetMapHeaderByGroupAndId adds r1, r0, 0 ldr r0, =gStringVar1 ldrb r1, [r1, 0x14] diff --git a/asm/pokedex_area_screen.s b/asm/pokedex_area_screen.s index 5f9e01974..579788e14 100644 --- a/asm/pokedex_area_screen.s +++ b/asm/pokedex_area_screen.s @@ -308,7 +308,7 @@ _0813CCB8: ldr r1, [r5] ldrb r0, [r1, 0x10] ldrb r1, [r1, 0x11] - bl get_mapheader_by_bank_and_number + bl Overworld_GetMapHeaderByGroupAndId ldr r1, [r5] ldrb r0, [r0, 0x14] strh r0, [r1, 0x12] @@ -360,7 +360,7 @@ sub_813CD04: @ 813CD04 strb r3, [r1, 0x11] adds r0, r5, 0 adds r1, r3, 0 - bl get_mapheader_by_bank_and_number + bl Overworld_GetMapHeaderByGroupAndId ldrb r0, [r0, 0x14] bl CorrectSpecialMapSecId ldr r2, [r4] @@ -496,7 +496,7 @@ sub_813CE34: @ 813CE34 lsrs r0, 24 lsls r1, 24 lsrs r1, 24 - bl get_mapheader_by_bank_and_number + bl Overworld_GetMapHeaderByGroupAndId ldrb r0, [r0, 0x14] pop {r1} bx r1 diff --git a/asm/pokenav.s b/asm/pokenav.s index 680752c85..d98605dde 100644 --- a/asm/pokenav.s +++ b/asm/pokenav.s @@ -8095,7 +8095,7 @@ sub_81CB0C8: @ 81CB0C8 ldrh r2, [r0, 0xA] ldrh r1, [r0, 0xC] adds r0, r2, 0 - bl get_mapheader_by_bank_and_number + bl Overworld_GetMapHeaderByGroupAndId ldrb r0, [r0, 0x14] pop {r1} bx r1 @@ -30295,7 +30295,7 @@ sub_81D6120: @ 81D6120 push {lr} movs r0, 0x1A movs r1, 0x40 - bl get_mapheader_by_bank_and_number + bl Overworld_GetMapHeaderByGroupAndId ldr r0, [r0, 0x4] ldr r0, [r0, 0x8] adds r0, 0x8 @@ -30334,7 +30334,7 @@ _081D6162: adds r0, r1 ldrh r1, [r0] movs r0, 0x1A - bl get_mapheader_by_bank_and_number + bl Overworld_GetMapHeaderByGroupAndId ldr r0, [r0, 0x4] ldr r0, [r0, 0x8] _081D6176: diff --git a/asm/post_battle_event_funcs.s b/asm/post_battle_event_funcs.s index da84a6565..c6d4fd88f 100644 --- a/asm/post_battle_event_funcs.s +++ b/asm/post_battle_event_funcs.s @@ -44,7 +44,7 @@ _0813776C: ldrb r0, [r2, 0x11] orrs r1, r0 movs r0, 0x1 - bl sav12_xor_set + bl SetGameStat _0813778E: bl sub_8076D48 ldr r0, =gSaveBlock2Ptr diff --git a/asm/rom6.s b/asm/rom6.s index 297c81128..b103c0875 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -376,7 +376,7 @@ _0813574C: thumb_func_start hm2_dig hm2_dig: @ 8135760 push {lr} - bl flagmods_08054D70 + bl Overworld_ResetStateAfterDigEscRope movs r0, 0x26 bl FieldEffectStart bl GetCursorSelectionMonId diff --git a/asm/roulette.s b/asm/roulette.s index e03bbea91..ab873dd32 100644 --- a/asm/roulette.s +++ b/asm/roulette.s @@ -2570,7 +2570,7 @@ sub_8141800: @ 8141800 movs r0, 0x1E ldrsh r1, [r4, r0] movs r0, 0x1D - bl sav12_xor_set + bl SetGameStat _08141848: ldr r1, =sub_8141A18 ldr r2, =0x0000ffff diff --git a/data/event_scripts.s b/data/event_scripts.s index b2b895903..7b9d6519c 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -1287,12 +1287,12 @@ EverGrandeCity_HallOfFame_EventScript_271851:: @ 8271851 setvar VAR_0x40D3, 1 return -EverGrandeCity_HallOfFame_EventScript_271857:: @ 8271857 +EventScript_WhiteOut:: @ 8271857 call EverGrandeCity_HallOfFame_EventScript_2718CC - goto EverGrandeCity_HallOfFame_EventScript_271862 + goto EventScript_271862 end -EverGrandeCity_HallOfFame_EventScript_271862:: @ 8271862 +EventScript_271862:: @ 8271862 compare VAR_0x4096, 1 goto_eq EverGrandeCity_HallOfFame_EventScript_271884 compare VAR_0x4096, 2 diff --git a/data/overworld.s b/data/overworld.s deleted file mode 100644 index 186af6f44..000000000 --- a/data/overworld.s +++ /dev/null @@ -1,52 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2, 0 -gUnknown_08339D3C:: @ 8339D3C - .4byte 0xFFFFFF, 0xFFFFFFFF, 0x4B0, 0xE10, 0x4B0, 0x960, 0x32, 0x50, 0xFFFFFFD4, 0x2C - -gUnknown_08339D64:: @ 8339D64 - .4byte 0, 0 - .4byte 0, 1 - .4byte 0, -1 - .4byte -1, 0 - .4byte 1, 0 - .4byte -1, 1 - .4byte 1, 1 - .4byte -1, -1 - .4byte 1, -1 - -gUnknown_08339DAC:: @ 8339DAC - .4byte 0x1F8 - .4byte 0x11D1 - .4byte 0x21C2 - .4byte 0x31E3 - -gUnknown_08339DBC:: @ 8339DBC - .4byte REG_WIN0H - .4byte 0xa2600001 - .byte 1, 0 - - .align 2 -gUnknown_08339DC8:: @ 8339DC8 - .4byte sub_80879D8 - .4byte sub_80879F8 - .4byte sub_80879FC - -gUnknown_08339DD4:: @ 8339DD4 - .4byte sub_8087A1C - .4byte sub_8087A20 - .4byte sub_8087A20 - .4byte sub_8087A20 - .4byte sub_8087A20 - .4byte sub_8087A1C - .4byte sub_8087A1C - .4byte sub_8087A88 - .4byte sub_8087A88 - .4byte sub_8087A88 - .4byte sub_8087A88 - -gUnknown_08339E00:: @ 8339E00 - .4byte sub_8087AA0 - .4byte sub_8087AA8 diff --git a/include/constants/game_stat.h b/include/constants/game_stat.h index b1f3d4197..7ebf3501b 100644 --- a/include/constants/game_stat.h +++ b/include/constants/game_stat.h @@ -51,9 +51,10 @@ #define GAME_STAT_USED_DAYCARE 47 #define GAME_STAT_RODE_CABLE_CAR 48 #define GAME_STAT_ENTERED_HOT_SPRINGS 49 +#define GAME_STAT_50 50 +#define GAME_STAT_51 51 -/*TODO: add new stats added in Emerald*/ - +#define NUM_USED_GAME_STATS 52 #define NUM_GAME_STATS 64 #endif // GUARD_CONSTANTS_GAME_STAT_H diff --git a/include/global.h b/include/global.h index 4a71a8a87..8913432ba 100644 --- a/include/global.h +++ b/include/global.h @@ -618,7 +618,7 @@ struct SaveBlock1 /*0x04*/ struct WarpData location; /*0x0C*/ struct WarpData warp1; /*0x14*/ struct WarpData warp2; - /*0x1C*/ struct WarpData warp3; + /*0x1C*/ struct WarpData lastHealLocation; /*0x24*/ struct WarpData warp4; /*0x2C*/ u16 battleMusic; /*0x2E*/ u8 weather; @@ -705,6 +705,23 @@ struct SaveBlock1 extern struct SaveBlock1* gSaveBlock1Ptr; +struct MapPosition +{ + s16 x; + s16 y; + u8 height; +}; + +struct UnkStruct_8054FF8 +{ + u8 a; + u8 b; + u8 c; + u8 d; + struct MapPosition sub; + u16 field_C; +}; + struct Bitmap // TODO: Find a better spot for this { u8* pixels; diff --git a/include/overworld.h b/include/overworld.h index 630b0a617..904f61c8e 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -25,11 +25,49 @@ struct UCoords32 extern struct LinkPlayerMapObject gLinkPlayerMapObjects[4]; extern MainCallback gFieldCallback; +void DoWhiteOut(void); +void Overworld_ResetStateAfterFly(void); +void Overworld_ResetStateAfterTeleport(void); +void Overworld_ResetStateAfterDigEscRope(void); +void sub_8084788(void); +void ResetGameStats(void); +void IncrementGameStat(u8 index); +u32 GetGameStat(u8 index); +void SetGameStat(u8 index, u32 value); +void ApplyNewEncryptionKeyToGameStats(u32 newKey); +void LoadMapObjTemplatesFromHeader(void); +void LoadSaveblockMapObjScripts(void); +void Overworld_SetMapObjTemplateCoords(u8 localId, s16 x, s16 y); +void Overworld_SetMapObjTemplateMovementType(u8 localId, u8 movementType); +void mapdata_load_assets_to_gpu_and_full_redraw(void); +struct MapData *get_mapdata_header(void); +void ApplyCurrentWarp(void); +void set_warp2_warp3_to_neg_1(void); +void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); +bool32 warp_data_is_not_neg_1(struct WarpData *warp); +struct MapHeader *const Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum); +struct MapHeader *const warp1_get_mapheader(void); +void set_current_map_header_from_sav1_save_old_name(void); +void LoadSaveblockMapHeader(void); +void update_camera_pos_from_warpid(void); +void warp_in(void); +void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); +void warp1_set_2(s8 mapGroup, s8 mapNum, s8 warpId); +void saved_warp2_set(int unused, s8 mapGroup, s8 mapNum, s8 warpId); +void saved_warp2_set_2(int unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); +void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused); +void sub_8084CCC(u8 a1); +void Overworld_SetWarpDestToLastHealLoc(void); +void Overworld_SetHealLocationWarp(u8 healLocationId); +void sub_8084D5C(s16 a1, s16 a2); +void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); + +// to erase later +u8 GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum); +u8 Overworld_GetMapTypeOfSaveblockLocation(void); void Overworld_SetMapObjTemplateCoords(u8, s16, s16); void Overworld_SetMapObjTemplateMovementType(u8, u8); - void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); - void saved_warp2_set(int unused, s8 mapGroup, s8 mapNum, s8 warpId); void saved_warp2_set_2(int unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void Overworld_SetHealLocationWarp(u8); @@ -37,25 +75,18 @@ void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void sub_8084E2C(s8, s8, s8, s8, s8); void sub_8084E80(s8, s8, s8, s8, s8); void sub_8084EBC(s16, s16); - void player_avatar_init_params_reset(void); - bool8 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType); void Overworld_ResetStateAfterTeleport(void); - void Overworld_SetFlashLevel(s32 a1); //u8 Overworld_GetFlashLevel(void); void sub_8085524(u16); - void Overworld_SetSavedMusic(u16); void Overworld_ChangeMusicToDefault(void); void Overworld_ChangeMusicTo(u16); - bool32 is_c1_link_related_active(void); extern u16 gUnknown_03005DA8; - void strange_npc_table_clear(void); -const struct MapHeader *get_mapheader_by_bank_and_number(u16, u16); void FieldObjectMoveDestCoords(struct MapObject *, u32, s16 *, s16 *); void sub_8086230(void); void c2_exit_to_overworld_2_switch(void); @@ -71,13 +102,11 @@ void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused); void mapldr_default(void); u8 get_map_light_from_warp0(void); bool8 is_light_level_1_2_3_5_or_6(u8 a1); - bool32 sub_80875C8(void); bool32 sub_8087634(void); bool32 sub_808766C(void); void IncrementGameStat(u8); u32 GetGameStat(u8); - void CB2_OverworldBasic(void); #endif //GUARD_ROM4_H diff --git a/ld_script.txt b/ld_script.txt index 81911e574..bb015446f 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -86,6 +86,7 @@ SECTIONS { src/berry_blender.o(.text); src/play_time.o(.text); src/new_game.o(.text); + src/overworld.o(.text); asm/overworld.o(.text); asm/fieldmap.o(.text); src/metatile_behavior.o(.text); @@ -393,7 +394,7 @@ SECTIONS { data/trade.o(.rodata); src/berry_blender.o(.rodata); src/new_game.o(.rodata); - data/overworld.o(.rodata); + src/overworld.o(.rodata); data/tilesets.o(.rodata); data/maps.o(.rodata); data/fieldmap.o(.rodata); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 75f05e86f..2da48de49 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -76,7 +76,7 @@ extern bool8 sub_81B1250(void); // ? extern bool8 InBattlePike(void); extern bool8 InBattlePyramid(void); extern u16 GetBattlePyramidPickupItemId(void); -extern u8 sav1_map_get_light_level(void); +extern u8 Overworld_GetMapTypeOfSaveblockLocation(void); extern u8 sub_813B21C(void); extern u16 get_unknown_box_id(void); @@ -10578,7 +10578,7 @@ static void atkEF_handleballthrow(void) ballMultiplier = 10; break; case ITEM_DIVE_BALL: - if (sav1_map_get_light_level() == 5) + if (Overworld_GetMapTypeOfSaveblockLocation() == 5) ballMultiplier = 35; else ballMultiplier = 10; diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 906eff4b7..84613365c 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1673,7 +1673,7 @@ struct MapObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8 localId, u8 m } else { - mapHeader = get_mapheader_by_bank_and_number(mapGroup, mapNum); + mapHeader = Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum); templates = mapHeader->events->mapObjects; count = mapHeader->events->mapObjectCount; } diff --git a/src/item_use.c b/src/item_use.c index bcd453660..99dce9cbd 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -85,7 +85,7 @@ extern void sub_81C59BC(void); extern void sub_81AB9A8(u8); extern void sub_81ABA88(u8); extern void sub_80B7CC8(void); -extern void flagmods_08054D70(void); +extern void Overworld_ResetStateAfterDigEscRope(void); extern u8* sub_806CF78(u16); extern void sub_81B89F0(void); extern u8 GetItemEffectType(u16); @@ -904,7 +904,7 @@ void task08_080A1C44(u8 taskId) void re_escape_rope(u8 taskId) { - flagmods_08054D70(); + Overworld_ResetStateAfterDigEscRope(); sub_80FE058(); gTasks[taskId].data[0] = 0; DisplayItemMessageOnField(taskId, gStringVar4, task08_080A1C44); diff --git a/src/overworld.c b/src/overworld.c index c538595f2..5757ca20a 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -1,10 +1,82 @@ - -// Includes #include "global.h" +#include "overworld.h" +#include "battle_setup.h" +#include "berry.h" +// #include "cable_club.h" +#include "clock.h" +#include "event_data.h" +#include "field_camera.h" +// #include "field_control_avatar.h" +#include "field_effect.h" +#include "field_fadetransition.h" +#include "field_ground_effect.h" +#include "field_map_obj.h" +#include "field_map_obj_helpers.h" +#include "field_message_box.h" +#include "field_player_avatar.h" +#include "field_screen_effect.h" +// #include "field_special_scene.h" +#include "field_specials.h" +#include "field_tasks.h" +#include "field_weather.h" +#include "fieldmap.h" +// #include "fldeff_flash.h" +#include "heal_location.h" +#include "link.h" +#include "load_save.h" +#include "main.h" +#include "m4a.h" +#include "constants/maps.h" +#include "map_name_popup.h" +#include "menu.h" +#include "metatile_behavior.h" +#include "new_game.h" +#include "palette.h" +#include "play_time.h" +#include "random.h" +#include "roamer.h" +// #include "rotating_gate.h" +#include "safari_zone.h" +#include "script.h" +// #include "script_pokemon_80C4.h" +#include "secret_base.h" +#include "constants/songs.h" +#include "sound.h" +#include "constants/species.h" +#include "start_menu.h" +#include "task.h" +// #include "tileset_anim.h" +#include "time_events.h" +#include "tv.h" +#include "scanline_effect.h" +#include "wild_encounter.h" +#include "bg.h" +#include "money.h" -// Static type declarations +// event scripts +extern const u8 EventScript_WhiteOut[]; +extern const u8 EventScript_271862[]; -// Static RAM declarations +// vars +extern struct MapData * const gMapAttributes[]; +extern struct MapHeader * const * const gMapGroups[]; +extern s32 gMaxFlashLevel; + +// functions +extern void HealPlayerParty(void); +extern void move_tilemap_camera_to_upper_left_corner(void); +extern void cur_mapheader_run_tileset_funcs_after_some_cpuset(void); +extern void DrawWholeMapView(void); +extern void copy_map_tileset1_tileset2_to_vram(struct MapData *); +extern void apply_map_tileset1_tileset2_palette(struct MapData *); +extern void ResetCyclingRoadChallengeData(void); +extern void ApplyNewEncryptionKeyToWord(u32 *word, u32 newKey); + +// this file's functions +static void Overworld_ResetStateAfterWhiteOut(void); +void ChooseAmbientCrySpecies(void); + +// IWRAM bss vars IWRAM_DATA void *gUnknown_03000E0C; IWRAM_DATA u8 gUnknown_03000E10[4]; IWRAM_DATA u8 (*gUnknown_03000E14)(u32); @@ -12,8 +84,463 @@ IWRAM_DATA u8 gUnknown_03000E18; IWRAM_DATA u8 gUnknown_03000E19; IWRAM_DATA void *rom4_c_unused_03000e1c; -// Static ROM declarations +// EWRAM vars +EWRAM_DATA struct WarpData gUnknown_020322DC = {0}; +EWRAM_DATA struct WarpData gWarpDestination = {0}; // new warp position +EWRAM_DATA struct WarpData gUnknown_020322EC = {0}; +EWRAM_DATA struct WarpData gUnknown_020322F4 = {0}; +EWRAM_DATA u16 gLastMapSectionId = 0; +// EWRAM_DATA struct UnkPlayerStruct gUnknown_02029810 = {0}; +// EWRAM_DATA u16 sAmbientCrySpecies = 0; +// EWRAM_DATA bool8 sIsAmbientCryWaterMon = FALSE; +// EWRAM_DATA struct LinkPlayerMapObject gLinkPlayerMapObjects[4] = {0}; -// .rodata +// const rom data +const struct WarpData sDummyWarpData = +{ + .mapGroup = -1, + .mapNum = -1, + .warpId = -1, + .x = -1, + .y = -1, +}; -// .text +const u8 sUnusedData[] = +{ + 0xB0, 0x04, 0x00, 0x00, + 0x10, 0x0E, 0x00, 0x00, + 0xB0, 0x04, 0x00, 0x00, + 0x60, 0x09, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x00, 0x00, + 0xD4, 0xFF, 0xFF, 0xFF, + 0x2C, 0x00, 0x00, 0x00, +}; + +const struct UCoords32 gUnknown_08339D64[] = +{ + { 0, 0}, + { 0, 1}, + { 0, -1}, + {-1, 0}, + { 1, 0}, + {-1, 1}, + { 1, 1}, + {-1, -1}, + { 1, -1}, +}; + +const struct BgTemplate gUnknown_08339DAC[] = +{ + { + .bg = 0, + .charBaseIndex = 2, + .mapBaseIndex = 31, + .screenSize = 0, + .paletteMode = 0, + .priority = 0, + .baseTile = 0 + }, + { + .bg = 1, + .charBaseIndex = 0, + .mapBaseIndex = 29, + .screenSize = 0, + .paletteMode = 0, + .priority = 1, + .baseTile = 0 + }, + { + .bg = 2, + .charBaseIndex = 0, + .mapBaseIndex = 28, + .screenSize = 0, + .paletteMode = 0, + .priority = 2, + .baseTile = 0 + }, + { + .bg = 3, + .charBaseIndex = 0, + .mapBaseIndex = 30, + .screenSize = 0, + .paletteMode = 0, + .priority = 3, + .baseTile = 0 + } +}; + +const struct ScanlineEffectParams gUnknown_08339DBC = +{ + (void *)REG_ADDR_WIN0H, + ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1, + 1, + 0, +}; + +u8 sub_80879D8(struct LinkPlayerMapObject *, struct MapObject *, u8); +u8 sub_80879F8(struct LinkPlayerMapObject *, struct MapObject *, u8); +u8 sub_80879FC(struct LinkPlayerMapObject *, struct MapObject *, u8); + +u8 (*const gUnknown_08339DC8[])(struct LinkPlayerMapObject *, struct MapObject *, u8) = +{ + sub_80879D8, + sub_80879F8, + sub_80879FC, +}; + +u8 sub_8087A1C(struct LinkPlayerMapObject *, struct MapObject *, u8); +u8 sub_8087A20(struct LinkPlayerMapObject *, struct MapObject *, u8); +u8 sub_8087A88(struct LinkPlayerMapObject *, struct MapObject *, u8); + +u8 (*const gUnknown_08339DD4[])(struct LinkPlayerMapObject *, struct MapObject *, u8) = +{ + sub_8087A1C, + sub_8087A20, + sub_8087A20, + sub_8087A20, + sub_8087A20, + sub_8087A1C, + sub_8087A1C, + sub_8087A88, + sub_8087A88, + sub_8087A88, + sub_8087A88, +}; + +void sub_8087AA0(struct LinkPlayerMapObject *, struct MapObject *); +void sub_8087AA8(struct LinkPlayerMapObject *, struct MapObject *); + +void (*const gUnknown_08339E00[])(struct LinkPlayerMapObject *, struct MapObject *) = +{ + sub_8087AA0, + sub_8087AA8, +}; + +// code +void DoWhiteOut(void) +{ + ScriptContext2_RunNewScript(EventScript_WhiteOut); + SetMoney(&gSaveBlock1Ptr->money, GetMoney(&gSaveBlock1Ptr->money) / 2); + HealPlayerParty(); + Overworld_ResetStateAfterWhiteOut(); + Overworld_SetWarpDestToLastHealLoc(); + warp_in(); +} + +void Overworld_ResetStateAfterFly(void) +{ + player_avatar_init_params_reset(); + FlagClear(FLAG_SYS_CYCLING_ROAD); + FlagClear(FLAG_SYS_CRUISE_MODE); + FlagClear(FLAG_SYS_SAFARI_MODE); + FlagClear(FLAG_SYS_USE_STRENGTH); + FlagClear(FLAG_SYS_USE_FLASH); +} + +void Overworld_ResetStateAfterTeleport(void) +{ + player_avatar_init_params_reset(); + FlagClear(FLAG_SYS_CYCLING_ROAD); + FlagClear(FLAG_SYS_CRUISE_MODE); + FlagClear(FLAG_SYS_SAFARI_MODE); + FlagClear(FLAG_SYS_USE_STRENGTH); + FlagClear(FLAG_SYS_USE_FLASH); + ScriptContext2_RunNewScript(EventScript_271862); +} + +void Overworld_ResetStateAfterDigEscRope(void) +{ + player_avatar_init_params_reset(); + FlagClear(FLAG_SYS_CYCLING_ROAD); + FlagClear(FLAG_SYS_CRUISE_MODE); + FlagClear(FLAG_SYS_SAFARI_MODE); + FlagClear(FLAG_SYS_USE_STRENGTH); + FlagClear(FLAG_SYS_USE_FLASH); +} + +static void Overworld_ResetStateAfterWhiteOut(void) +{ + player_avatar_init_params_reset(); + FlagClear(FLAG_SYS_CYCLING_ROAD); + FlagClear(FLAG_SYS_CRUISE_MODE); + FlagClear(FLAG_SYS_SAFARI_MODE); + FlagClear(FLAG_SYS_USE_STRENGTH); + FlagClear(FLAG_SYS_USE_FLASH); + if (VarGet(VAR_0x4039) == 1) + { + VarSet(VAR_0x4039, 0); + VarSet(VAR_0x4037, 0); + } +} + +void sub_8084788(void) +{ + FlagClear(FLAG_SYS_SAFARI_MODE); + ChooseAmbientCrySpecies(); + ResetCyclingRoadChallengeData(); + UpdateLocationHistoryForRoamer(); + RoamerMoveToOtherLocationSet(); +} + +void ResetGameStats(void) +{ + s32 i; + + for (i = 0; i < NUM_GAME_STATS; i++) + SetGameStat(i, 0); +} + +void IncrementGameStat(u8 index) +{ + if (index < NUM_USED_GAME_STATS) + { + u32 statVal = GetGameStat(index); + if (statVal < 0xFFFFFF) + statVal++; + else + statVal = 0xFFFFFF; + + SetGameStat(index, statVal); + } +} + +u32 GetGameStat(u8 index) +{ + if (index >= NUM_USED_GAME_STATS) + return 0; + + return gSaveBlock1Ptr->gameStats[index] ^ gSaveBlock2Ptr->encryptionKey; +} + +void SetGameStat(u8 index, u32 value) +{ + if (index < NUM_USED_GAME_STATS) + gSaveBlock1Ptr->gameStats[index] = value ^ gSaveBlock2Ptr->encryptionKey; +} + +void ApplyNewEncryptionKeyToGameStats(u32 newKey) +{ + u8 i; + + for (i = 0; i < NUM_GAME_STATS; i++) + ApplyNewEncryptionKeyToWord(&gSaveBlock1Ptr->gameStats[i], newKey); +} + +void LoadMapObjTemplatesFromHeader(void) +{ + // Clear map object templates + CpuFill32(0, gSaveBlock1Ptr->mapObjectTemplates, sizeof(gSaveBlock1Ptr->mapObjectTemplates)); + + // Copy map header events to save block + CpuCopy32(gMapHeader.events->mapObjects, + gSaveBlock1Ptr->mapObjectTemplates, + gMapHeader.events->mapObjectCount * sizeof(struct MapObjectTemplate)); +} + +void LoadSaveblockMapObjScripts(void) +{ + struct MapObjectTemplate *mapHeaderObjTemplates = gMapHeader.events->mapObjects; + struct MapObjectTemplate *savObjTemplates = gSaveBlock1Ptr->mapObjectTemplates; + s32 i; + + for (i = 0; i < 64; i++) + savObjTemplates[i].script = mapHeaderObjTemplates[i].script; +} + +void Overworld_SetMapObjTemplateCoords(u8 localId, s16 x, s16 y) +{ + s32 i; + struct MapObjectTemplate *savObjTemplates = gSaveBlock1Ptr->mapObjectTemplates; + + for (i = 0; i < 64; i++) + { + struct MapObjectTemplate *mapObjectTemplate = &savObjTemplates[i]; + if (mapObjectTemplate->localId == localId) + { + mapObjectTemplate->x = x; + mapObjectTemplate->y = y; + return; + } + } +} + +void Overworld_SetMapObjTemplateMovementType(u8 localId, u8 movementType) +{ + s32 i; + + struct MapObjectTemplate *savObjTemplates = gSaveBlock1Ptr->mapObjectTemplates; + for (i = 0; i < 64; i++) + { + struct MapObjectTemplate *mapObjectTemplate = &savObjTemplates[i]; + if (mapObjectTemplate->localId == localId) + { + mapObjectTemplate->movementType = movementType; + return; + } + } +} + +void mapdata_load_assets_to_gpu_and_full_redraw(void) +{ + move_tilemap_camera_to_upper_left_corner(); + copy_map_tileset1_tileset2_to_vram(gMapHeader.mapData); + apply_map_tileset1_tileset2_palette(gMapHeader.mapData); + DrawWholeMapView(); + cur_mapheader_run_tileset_funcs_after_some_cpuset(); +} + +struct MapData *get_mapdata_header(void) +{ + u16 mapDataId = gSaveBlock1Ptr->mapDataId; + if (mapDataId) + return gMapAttributes[mapDataId - 1]; + return NULL; +} + +void ApplyCurrentWarp(void) +{ + gUnknown_020322DC = gSaveBlock1Ptr->location; + gSaveBlock1Ptr->location = gWarpDestination; + gUnknown_020322EC = sDummyWarpData; + gUnknown_020322F4 = sDummyWarpData; +} + +void set_warp2_warp3_to_neg_1(void) +{ + gUnknown_020322EC = sDummyWarpData; + gUnknown_020322F4 = sDummyWarpData; +} + +void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) +{ + warp->mapGroup = mapGroup; + warp->mapNum = mapNum; + warp->warpId = warpId; + warp->x = x; + warp->y = y; +} + +bool32 warp_data_is_not_neg_1(struct WarpData *warp) +{ + if (warp->mapGroup != -1) + return FALSE; + if (warp->mapNum != -1) + return FALSE; + if (warp->warpId != -1) + return FALSE; + if (warp->x != -1) + return FALSE; + if (warp->y != -1) + return FALSE; + return TRUE; +} + +struct MapHeader *const Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum) +{ + return gMapGroups[mapGroup][mapNum]; +} + +struct MapHeader *const warp1_get_mapheader(void) +{ + return Overworld_GetMapHeaderByGroupAndId(gWarpDestination.mapGroup, gWarpDestination.mapNum); +} + +void set_current_map_header_from_sav1_save_old_name(void) +{ + gLastMapSectionId = gMapHeader.regionMapSectionId; + gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum); + gSaveBlock1Ptr->mapDataId = gMapHeader.mapDataId; + gMapHeader.mapData = get_mapdata_header(); +} + +void LoadSaveblockMapHeader(void) +{ + gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum); + gMapHeader.mapData = get_mapdata_header(); +} + +void update_camera_pos_from_warpid(void) +{ + if (gSaveBlock1Ptr->location.warpId >= 0 && gSaveBlock1Ptr->location.warpId < gMapHeader.events->warpCount) + { + gSaveBlock1Ptr->pos.x = gMapHeader.events->warps[gSaveBlock1Ptr->location.warpId].x; + gSaveBlock1Ptr->pos.y = gMapHeader.events->warps[gSaveBlock1Ptr->location.warpId].y; + } + else if (gSaveBlock1Ptr->location.x >= 0 && gSaveBlock1Ptr->location.y >= 0) + { + gSaveBlock1Ptr->pos.x = gSaveBlock1Ptr->location.x; + gSaveBlock1Ptr->pos.y = gSaveBlock1Ptr->location.y; + } + else + { + gSaveBlock1Ptr->pos.x = gMapHeader.mapData->width / 2; + gSaveBlock1Ptr->pos.y = gMapHeader.mapData->height / 2; + } +} + +void warp_in(void) +{ + ApplyCurrentWarp(); + set_current_map_header_from_sav1_save_old_name(); + update_camera_pos_from_warpid(); +} + +void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) +{ + SetWarpData(&gWarpDestination, mapGroup, mapNum, warpId, x, y); +} + +void warp1_set_2(s8 mapGroup, s8 mapNum, s8 warpId) +{ + Overworld_SetWarpDestination(mapGroup, mapNum, warpId, -1, -1); +} + +void saved_warp2_set(int unused, s8 mapGroup, s8 mapNum, s8 warpId) +{ + SetWarpData(&gSaveBlock1Ptr->warp2, mapGroup, mapNum, warpId, gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y); +} + +void saved_warp2_set_2(int unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) +{ + SetWarpData(&gSaveBlock1Ptr->warp2, mapGroup, mapNum, warpId, x, y); +} + +void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused) +{ + gWarpDestination = gSaveBlock1Ptr->warp2; +} + +void sub_8084CCC(u8 a1) +{ + const struct HealLocation *warp = GetHealLocationPointer(a1); + + if (warp) + Overworld_SetWarpDestination(warp->group, warp->map, -1, warp->x, warp->y); +} + +void Overworld_SetWarpDestToLastHealLoc(void) +{ + gWarpDestination = gSaveBlock1Ptr->lastHealLocation; +} + +void Overworld_SetHealLocationWarp(u8 healLocationId) +{ + const struct HealLocation *healLocation = GetHealLocationPointer(healLocationId); + + if (healLocation != NULL) + SetWarpData(&gSaveBlock1Ptr->lastHealLocation, healLocation->group, healLocation->map, -1, healLocation->x, healLocation->y); +} + +void sub_8084D5C(s16 a1, s16 a2) +{ + u8 currMapType = Overworld_GetMapTypeOfSaveblockLocation(); + u8 destMapType = GetMapTypeByGroupAndId(gWarpDestination.mapGroup, gWarpDestination.mapNum); + if (is_light_level_1_2_3_5_or_6(currMapType) && is_light_level_1_2_3_5_or_6(destMapType) != TRUE) + sub_8084DD4(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, a1 - 7, a2 - 6); +} + +void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) +{ + SetWarpData(&gSaveBlock1Ptr->warp4, mapGroup, mapNum, warpId, x, y); +} diff --git a/src/region_map.c b/src/region_map.c index 086c0ba68..7f121d1de 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -881,7 +881,7 @@ static void RegionMap_InitializeStateBasedOnPlayerLocation(void) return; } - switch (get_map_light_level_by_bank_and_number(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum)) + switch (GetMapTypeByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum)) { default: case 1: @@ -904,7 +904,7 @@ static void RegionMap_InitializeStateBasedOnPlayerLocation(void) case 7: if (gMapHeader.flags & 0x02) { - mapHeader = get_mapheader_by_bank_and_number(gSaveBlock1Ptr->warp4.mapGroup, gSaveBlock1Ptr->warp4.mapNum); + mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->warp4.mapGroup, gSaveBlock1Ptr->warp4.mapNum); gRegionMap->mapSecId = mapHeader->regionMapSectionId; gRegionMap->playerIsInCave = TRUE; mapWidth = mapHeader->mapData->width; @@ -923,7 +923,7 @@ static void RegionMap_InitializeStateBasedOnPlayerLocation(void) } break; case 9: - mapHeader = get_mapheader_by_bank_and_number((u16)gSaveBlock1Ptr->warp2.mapGroup, (u16)gSaveBlock1Ptr->warp2.mapNum); + mapHeader = Overworld_GetMapHeaderByGroupAndId((u16)gSaveBlock1Ptr->warp2.mapGroup, (u16)gSaveBlock1Ptr->warp2.mapNum); gRegionMap->mapSecId = mapHeader->regionMapSectionId; gRegionMap->playerIsInCave = TRUE; mapWidth = mapHeader->mapData->width; @@ -937,12 +937,12 @@ static void RegionMap_InitializeStateBasedOnPlayerLocation(void) if (gRegionMap->mapSecId != MAPSEC_DYNAMIC) { storedWarp = &gSaveBlock1Ptr->warp4; - mapHeader = get_mapheader_by_bank_and_number(storedWarp->mapGroup, storedWarp->mapNum); + mapHeader = Overworld_GetMapHeaderByGroupAndId(storedWarp->mapGroup, storedWarp->mapNum); } else { storedWarp = &gSaveBlock1Ptr->warp2; - mapHeader = get_mapheader_by_bank_and_number(storedWarp->mapGroup, storedWarp->mapNum); + mapHeader = Overworld_GetMapHeaderByGroupAndId(storedWarp->mapGroup, storedWarp->mapNum); gRegionMap->mapSecId = mapHeader->regionMapSectionId; } if (RegionMap_IsPlayerInCave(gRegionMap->mapSecId)) @@ -1065,7 +1065,7 @@ static void RegionMap_InitializeStateBasedOnSSTidalLocation(void) break; default: case 0: - mapHeader = get_mapheader_by_bank_and_number(mapGroup, mapNum); + mapHeader = Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum); gRegionMap->mapSecId = mapHeader->regionMapSectionId; dimensionScale = mapHeader->mapData->width / gRegionMapEntries[gRegionMap->mapSecId].width; diff --git a/sym_ewram.txt b/sym_ewram.txt index 206fa96e8..ed231e96f 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -214,21 +214,9 @@ gUnknown_020322D5: @ 20322D5 gUnknown_020322D8: @ 20322D8 .space 0x4 -gUnknown_020322DC: @ 20322DC - .space 0x8 - -gUnknown_020322E4: @ 20322E4 - .space 0x8 - -gUnknown_020322EC: @ 20322EC - .space 0x8 - -gUnknown_020322F4: @ 20322F4 - .space 0x8 - -gUnknown_020322FC: @ 20322FC - .space 0x4 + .include "src/overworld.o" +.align 2 gUnknown_02032300: @ 2032300 .space 0x4 From f22be4d0105304147ca982a91c239b9e3a7d31aa Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 12 Feb 2018 18:26:26 +0100 Subject: [PATCH 10/27] more overworld work --- asm/cable_club.s | 2 +- asm/field_screen.s | 8 +- asm/field_tasks.s | 6 +- asm/map_name_popup.s | 8 +- asm/overworld.s | 1496 +---------------- data/field_screen.s | 2 +- ...attleFrontier_BattlePyramidEmptySquare.inc | 2 +- .../maps/BattleFrontier_BattlePyramidTop.inc | 2 +- data/specials.inc | 4 +- include/constants/vars.h | 2 +- include/global.h | 4 +- include/overworld.h | 8 + src/item_use.c | 4 +- src/overworld.c | 579 ++++++- sym_ewram.txt | 16 - 15 files changed, 613 insertions(+), 1530 deletions(-) diff --git a/asm/cable_club.s b/asm/cable_club.s index 3b5c392fc..885689e85 100644 --- a/asm/cable_club.s +++ b/asm/cable_club.s @@ -2156,7 +2156,7 @@ sub_80B360C: @ 80B360C negs r1, r1 ands r0, r1 str r0, [r2] - bl call_ResetMapMusic + bl Overworld_ResetMapMusic bl copy_player_party_from_sav1 bl copy_bags_and_unk_data_to_save_blocks bl sub_813BF10 diff --git a/asm/field_screen.s b/asm/field_screen.s index 0839e4bac..0caa07a1b 100644 --- a/asm/field_screen.s +++ b/asm/field_screen.s @@ -1884,8 +1884,8 @@ _080ABEF4: .pool thumb_func_end sub_80ABE18 - thumb_func_start sub_80ABF00 -sub_80ABF00: @ 80ABF00 + thumb_func_start ApplyWeatherGammaShiftToPal +ApplyWeatherGammaShiftToPal: @ 80ABF00 push {lr} lsls r0, 24 lsrs r0, 24 @@ -1900,7 +1900,7 @@ sub_80ABF00: @ 80ABF00 pop {r0} bx r0 .pool - thumb_func_end sub_80ABF00 + thumb_func_end ApplyWeatherGammaShiftToPal thumb_func_start sub_80ABF20 sub_80ABF20: @ 80ABF20 @@ -10478,7 +10478,7 @@ sub_80B058C: @ 80B058C thumb_func_start sub_80B05B4 sub_80B05B4: @ 80B05B4 push {lr} - bl sub_80859B0 + bl Overworld_FadeOutMapMusic ldr r0, =task50_0807F0C8 movs r1, 0x50 bl CreateTask diff --git a/asm/field_tasks.s b/asm/field_tasks.s index 4befe0ca7..79980ec46 100644 --- a/asm/field_tasks.s +++ b/asm/field_tasks.s @@ -182,8 +182,8 @@ _0809D9EA: bx r0 thumb_func_end ActivatePerStepCallback - thumb_func_start wild_encounter_reset_coro_args -wild_encounter_reset_coro_args: @ 809D9F0 + thumb_func_start ResetFieldTasksArgs +ResetFieldTasksArgs: @ 809D9F0 push {lr} ldr r0, =task_per_step_callback_manager bl FindTaskIdByFunc @@ -207,7 +207,7 @@ _0809DA1A: pop {r0} bx r0 .pool - thumb_func_end wild_encounter_reset_coro_args + thumb_func_end ResetFieldTasksArgs thumb_func_start nullsub_34 nullsub_34: @ 809DA2C diff --git a/asm/map_name_popup.s b/asm/map_name_popup.s index 9802c3151..76edd1f1f 100644 --- a/asm/map_name_popup.s +++ b/asm/map_name_popup.s @@ -9,14 +9,14 @@ sub_80D47D4: @ 80D47D4 push {lr} bl sub_80A0934 - bl AddMapNamePopUpWindowTask + bl ShowMapNamePopup movs r0, 0x1 pop {r1} bx r1 thumb_func_end sub_80D47D4 - thumb_func_start AddMapNamePopUpWindowTask -AddMapNamePopUpWindowTask: @ 80D47E4 + thumb_func_start ShowMapNamePopup +ShowMapNamePopup: @ 80D47E4 push {r4,lr} movs r0, 0x80 lsls r0, 7 @@ -83,7 +83,7 @@ _080D486C: pop {r0} bx r0 .pool - thumb_func_end AddMapNamePopUpWindowTask + thumb_func_end ShowMapNamePopup thumb_func_start Task_MapNamePopUpWindow Task_MapNamePopUpWindow: @ 80D487C diff --git a/asm/overworld.s b/asm/overworld.s index 25c479c10..d74a2674b 100644 --- a/asm/overworld.s +++ b/asm/overworld.s @@ -5,1482 +5,8 @@ .text - thumb_func_start sub_8084E14 -sub_8084E14: @ 8084E14 - ldr r2, =gWarpDestination - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, [r0, 0x28] - ldr r0, [r0, 0x24] - str r0, [r2] - str r1, [r2, 0x4] - bx lr - .pool - thumb_func_end sub_8084E14 - thumb_func_start sub_8084E2C -sub_8084E2C: @ 8084E2C - push {r4-r6,lr} - sub sp, 0x8 - adds r4, r0, 0 - adds r5, r1, 0 - adds r6, r2, 0 - ldr r1, [sp, 0x18] - ldr r0, =gUnknown_020322EC - lsls r4, 24 - asrs r4, 24 - lsls r5, 24 - asrs r5, 24 - lsls r6, 24 - asrs r6, 24 - lsls r3, 24 - asrs r3, 24 - str r3, [sp] - lsls r1, 24 - asrs r1, 24 - str r1, [sp, 0x4] - adds r1, r4, 0 - adds r2, r5, 0 - adds r3, r6, 0 - bl SetWarpData - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8084E2C - thumb_func_start warp1_set_to_warp2 -warp1_set_to_warp2: @ 8084E68 - ldr r2, =gWarpDestination - ldr r0, =gUnknown_020322EC - ldr r1, [r0, 0x4] - ldr r0, [r0] - str r0, [r2] - str r1, [r2, 0x4] - bx lr - .pool - thumb_func_end warp1_set_to_warp2 - - thumb_func_start sub_8084E80 -sub_8084E80: @ 8084E80 - push {r4-r6,lr} - sub sp, 0x8 - adds r4, r0, 0 - adds r5, r1, 0 - adds r6, r2, 0 - ldr r1, [sp, 0x18] - ldr r0, =gUnknown_020322F4 - lsls r4, 24 - asrs r4, 24 - lsls r5, 24 - asrs r5, 24 - lsls r6, 24 - asrs r6, 24 - lsls r3, 24 - asrs r3, 24 - str r3, [sp] - lsls r1, 24 - asrs r1, 24 - str r1, [sp, 0x4] - adds r1, r4, 0 - adds r2, r5, 0 - adds r3, r6, 0 - bl SetWarpData - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8084E80 - - thumb_func_start sub_8084EBC -sub_8084EBC: @ 8084EBC - push {r4-r6,lr} - sub sp, 0x4 - lsls r0, 16 - lsrs r5, r0, 16 - lsls r1, 16 - lsrs r6, r1, 16 - ldr r4, =gUnknown_020322F4 - adds r0, r4, 0 - bl warp_data_is_not_neg_1 - cmp r0, 0x1 - bne _08084EF0 - ldr r2, =gWarpDestination - ldr r0, =gUnknown_020322DC - ldr r1, [r0, 0x4] - ldr r0, [r0] - str r0, [r2] - str r1, [r2, 0x4] - b _08084F0A - .pool -_08084EF0: - movs r0, 0 - ldrsb r0, [r4, r0] - movs r1, 0x1 - ldrsb r1, [r4, r1] - movs r2, 0x1 - negs r2, r2 - lsls r3, r5, 24 - asrs r3, 24 - lsls r4, r6, 24 - asrs r4, 24 - str r4, [sp] - bl Overworld_SetWarpDestination -_08084F0A: - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8084EBC - - thumb_func_start warp1_set_to_sav1w -warp1_set_to_sav1w: @ 8084F14 - ldr r2, =gWarpDestination - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, [r0, 0x10] - ldr r0, [r0, 0xC] - str r0, [r2] - str r1, [r2, 0x4] - bx lr - .pool - thumb_func_end warp1_set_to_sav1w - - thumb_func_start sub_8084F2C -sub_8084F2C: @ 8084F2C - push {r4-r6,lr} - sub sp, 0x8 - adds r4, r0, 0 - adds r5, r1, 0 - adds r6, r2, 0 - ldr r1, [sp, 0x18] - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - adds r0, 0xC - lsls r4, 24 - asrs r4, 24 - lsls r5, 24 - asrs r5, 24 - lsls r6, 24 - asrs r6, 24 - lsls r3, 24 - asrs r3, 24 - str r3, [sp] - lsls r1, 24 - asrs r1, 24 - str r1, [sp, 0x4] - adds r1, r4, 0 - adds r2, r5, 0 - adds r3, r6, 0 - bl SetWarpData - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8084F2C - - thumb_func_start sub_8084F6C -sub_8084F6C: @ 8084F6C - push {r4,r5,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r0, 24 - bl GetHealLocationPointer - adds r5, r0, 0 - cmp r5, 0 - beq _08084FA0 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - adds r0, 0xC - movs r1, 0 - ldrsb r1, [r5, r1] - movs r2, 0x1 - ldrsb r2, [r5, r2] - movs r3, 0x1 - negs r3, r3 - movs r4, 0x2 - ldrsb r4, [r5, r4] - str r4, [sp] - movs r4, 0x4 - ldrsb r4, [r5, r4] - str r4, [sp, 0x4] - bl SetWarpData -_08084FA0: - add sp, 0x8 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8084F6C - - thumb_func_start sub_8084FAC -sub_8084FAC: @ 8084FAC - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - ldr r0, [r2, 0x14] - ldr r1, [r2, 0x18] - str r0, [r2, 0xC] - str r1, [r2, 0x10] - bx lr - .pool - thumb_func_end sub_8084FAC - - thumb_func_start sub_8084FC0 -sub_8084FC0: @ 8084FC0 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gMapHeader - ldr r0, [r0, 0xC] - ldr r3, [r0] - ldr r1, [r0, 0x4] - cmp r1, 0 - bne _08084FDC - b _08084FF0 - .pool -_08084FD8: - adds r0, r1, 0 - b _08084FF2 -_08084FDC: - movs r2, 0 - cmp r2, r3 - bge _08084FF0 -_08084FE2: - ldrb r0, [r1] - cmp r0, r4 - beq _08084FD8 - adds r2, 0x1 - adds r1, 0xC - cmp r2, r3 - blt _08084FE2 -_08084FF0: - movs r0, 0 -_08084FF2: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8084FC0 - - thumb_func_start sub_8084FF8 -sub_8084FF8: @ 8084FF8 - push {r4,r5,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 16 - lsrs r4, r1, 16 - lsls r2, 16 - lsrs r5, r2, 16 - bl sub_8084FC0 - adds r1, r0, 0 - cmp r1, 0 - beq _08085030 - movs r0, 0x8 - ldrsb r0, [r1, r0] - ldrb r1, [r1, 0x9] - lsls r1, 24 - asrs r1, 24 - movs r2, 0x1 - negs r2, r2 - lsls r3, r4, 24 - asrs r3, 24 - lsls r4, r5, 24 - asrs r4, 24 - str r4, [sp] - bl Overworld_SetWarpDestination - b _0808504C -_08085030: - bl mapheader_run_script_with_tag_x6 - ldr r0, =gUnknown_020322EC - bl warp_data_is_not_neg_1 - cmp r0, 0 - beq _08085048 - movs r0, 0 - b _0808504E - .pool -_08085048: - bl warp1_set_to_warp2 -_0808504C: - movs r0, 0x1 -_0808504E: - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8084FF8 - - thumb_func_start sub_8085058 -sub_8085058: @ 8085058 - push {lr} - adds r3, r0, 0 - adds r2, r1, 0 - lsls r3, 16 - lsrs r3, 16 - lsls r2, 16 - lsrs r2, 16 - movs r0, 0x6 - adds r1, r3, 0 - bl sub_8084FF8 - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - thumb_func_end sub_8085058 - - thumb_func_start sub_8085078 -sub_8085078: @ 8085078 - push {lr} - adds r3, r0, 0 - adds r2, r1, 0 - lsls r3, 16 - lsrs r3, 16 - lsls r2, 16 - lsrs r2, 16 - movs r0, 0x5 - adds r1, r3, 0 - bl sub_8084FF8 - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - thumb_func_end sub_8085078 - - thumb_func_start mliX_load_map -mliX_load_map: @ 8085098 - push {r4-r6,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - adds r6, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r5, r1, 0 - lsls r0, r6, 24 - asrs r0, 24 - lsls r1, r5, 24 - asrs r1, 24 - movs r3, 0x1 - negs r3, r3 - str r3, [sp] - adds r2, r3, 0 - bl Overworld_SetWarpDestination - ldr r4, =gMapHeader - ldrb r0, [r4, 0x14] - cmp r0, 0x3A - beq _080850C8 - bl sub_8085810 -_080850C8: - bl ApplyCurrentWarp - bl set_current_map_header_from_sav1_save_old_name - bl LoadMapObjTemplatesFromHeader - bl TrySetMapSaveWarpStatus - bl ClearTempFieldEventData - bl ResetCyclingRoadChallengeData - bl prev_quest_postbuffer_cursor_backup_reset - adds r0, r6, 0 - adds r1, r5, 0 - bl TryUpdateRandomTrainerRematches - bl DoTimeBasedEvents - bl SetSav1WeatherFromCurrMapHeader - bl ChooseAmbientCrySpecies - bl update_sav1_flash_used_on_map - bl Overworld_ClearSavedMusic - bl mapheader_run_script_with_tag_x3 - bl not_trainer_hill_battle_pyramid - ldr r0, [r4] - bl copy_map_tileset2_to_vram_2 - ldr r0, [r4] - bl apply_map_tileset2_palette - movs r4, 0x6 -_08085116: - lsls r0, r4, 24 - lsrs r0, 24 - bl sub_80ABF00 - adds r4, 0x1 - cmp r4, 0xC - ble _08085116 - bl sub_80A0A2C - bl UpdateLocationHistoryForRoamer - bl RoamerMove - bl DoCurrentWeather - bl wild_encounter_reset_coro_args - bl mapheader_run_script_with_tag_x5 - ldr r2, =gMapHeader - ldrb r0, [r2, 0x14] - cmp r0, 0x3A - bne _0808514C - ldr r1, =gLastMapSectionId - ldrh r1, [r1] - cmp r0, r1 - beq _08085150 -_0808514C: - bl AddMapNamePopUpWindowTask -_08085150: - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end mliX_load_map - - thumb_func_start mli0_load_map -mli0_load_map: @ 8085160 - push {r4-r7,lr} - adds r7, r0, 0 - bl set_current_map_header_from_sav1_save_old_name - ldr r0, =gUnknown_020322D8 - ldrb r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080851A2 - ldr r0, =gMapHeader - ldrh r1, [r0, 0x12] - ldr r0, =0x00000169 - cmp r1, r0 - bne _08085190 - bl sub_81AA1D8 - b _080851A2 - .pool -_08085190: - bl InTrainerHill - cmp r0, 0 - beq _0808519E - bl sub_81D5DF8 - b _080851A2 -_0808519E: - bl LoadMapObjTemplatesFromHeader -_080851A2: - ldr r4, =gMapHeader - ldrb r0, [r4, 0x17] - bl is_light_level_1_2_3_5_or_6 - lsls r0, 24 - lsrs r5, r0, 24 - ldrb r0, [r4, 0x17] - bl is_light_level_8_or_9 - lsls r0, 24 - lsrs r6, r0, 24 - bl sub_80EB218 - bl TrySetMapSaveWarpStatus - bl ClearTempFieldEventData - bl ResetCyclingRoadChallengeData - bl prev_quest_postbuffer_cursor_backup_reset - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - movs r0, 0x4 - ldrsb r0, [r1, r0] - lsls r0, 16 - lsrs r0, 16 - ldrb r1, [r1, 0x5] - lsls r1, 24 - asrs r1, 24 - lsls r1, 16 - lsrs r1, 16 - bl TryUpdateRandomTrainerRematches - cmp r7, 0x1 - beq _080851EE - bl DoTimeBasedEvents -_080851EE: - bl SetSav1WeatherFromCurrMapHeader - bl ChooseAmbientCrySpecies - cmp r5, 0 - beq _08085200 - ldr r0, =0x00000888 - bl FlagClear -_08085200: - bl update_sav1_flash_used_on_map - bl Overworld_ClearSavedMusic - bl mapheader_run_script_with_tag_x3 - bl UpdateLocationHistoryForRoamer - bl RoamerMoveToOtherLocationSet - ldrh r1, [r4, 0x12] - ldr r0, =0x00000169 - cmp r1, r0 - bne _08085234 - movs r0, 0 - bl battle_pyramid_map_load_related - b _08085246 - .pool -_08085234: - bl InTrainerHill - cmp r0, 0 - beq _08085242 - bl trainer_hill_map_load_related - b _08085246 -_08085242: - bl not_trainer_hill_battle_pyramid -_08085246: - cmp r7, 0x1 - beq _0808525E - cmp r6, 0 - beq _0808525E - ldr r1, =gUnknown_03005DC0 - ldr r0, [r1] - ldr r1, [r1, 0x4] - bl UpdateTVScreensOnMap - movs r0, 0x1 - bl sub_80E9238 -_0808525E: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end mli0_load_map - - thumb_func_start player_avatar_init_params_reset -player_avatar_init_params_reset: @ 8085268 - ldr r1, =gUnknown_02032300 - movs r0, 0x1 - strb r0, [r1, 0x1] - strb r0, [r1] - bx lr - .pool - thumb_func_end player_avatar_init_params_reset - - thumb_func_start walkrun_find_lowest_active_bit_in_bitfield -walkrun_find_lowest_active_bit_in_bitfield: @ 8085278 - push {r4,lr} - bl player_get_direction_lower_nybble - ldr r4, =gUnknown_02032300 - strb r0, [r4, 0x1] - movs r0, 0x2 - bl TestPlayerAvatarFlags - lsls r0, 24 - cmp r0, 0 - beq _08085298 - movs r0, 0x2 - b _080852CA - .pool -_08085298: - movs r0, 0x4 - bl TestPlayerAvatarFlags - lsls r0, 24 - cmp r0, 0 - beq _080852A8 - movs r0, 0x4 - b _080852CA -_080852A8: - movs r0, 0x8 - bl TestPlayerAvatarFlags - lsls r0, 24 - cmp r0, 0 - beq _080852B8 - movs r0, 0x8 - b _080852CA -_080852B8: - movs r0, 0x10 - bl TestPlayerAvatarFlags - lsls r0, 24 - cmp r0, 0 - beq _080852C8 - movs r0, 0x10 - b _080852CA -_080852C8: - movs r0, 0x1 -_080852CA: - strb r0, [r4] - pop {r4} - pop {r0} - bx r0 - thumb_func_end walkrun_find_lowest_active_bit_in_bitfield - - thumb_func_start sub_80852D4 -sub_80852D4: @ 80852D4 - push {r4-r7,lr} - bl Overworld_GetMapTypeOfSaveblockLocation - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - bl cur_mapdata_block_role_at_screen_center_acc_to_sav1 - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - ldr r6, =gUnknown_02032300 - adds r0, r6, 0 - adds r1, r4, 0 - adds r2, r5, 0 - bl sub_808532C - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - ldr r0, =0xffffff00 - ands r7, r0 - orrs r7, r1 - adds r0, r6, 0 - adds r2, r4, 0 - adds r3, r5, 0 - bl sub_808538C - lsls r0, 24 - lsrs r0, 16 - ldr r1, =0xffff00ff - ands r7, r1 - orrs r7, r0 - str r7, [r6] - adds r0, r6, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80852D4 - - thumb_func_start sub_808532C -sub_808532C: @ 808532C - push {r4-r6,lr} - adds r6, r0, 0 - lsls r1, 16 - lsrs r5, r1, 16 - lsls r2, 24 - lsrs r4, r2, 24 - cmp r4, 0x8 - beq _08085348 - ldr r0, =0x0000088d - bl FlagGet - lsls r0, 24 - cmp r0, 0 - bne _08085382 -_08085348: - cmp r4, 0x5 - bne _08085354 - movs r0, 0x10 - b _08085384 - .pool -_08085354: - lsls r0, r5, 24 - lsrs r0, 24 - bl MetatileBehavior_IsSurfableWaterOrUnderwater - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08085368 - movs r0, 0x8 - b _08085384 -_08085368: - bl sav1_map_is_biking_allowed - cmp r0, 0x1 - bne _08085382 - ldrb r0, [r6] - cmp r0, 0x2 - bne _0808537A - movs r0, 0x2 - b _08085384 -_0808537A: - cmp r0, 0x4 - bne _08085382 - movs r0, 0x4 - b _08085384 -_08085382: - movs r0, 0x1 -_08085384: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_808532C - - thumb_func_start sub_808538C -sub_808538C: @ 808538C - push {r4-r7,lr} - adds r6, r0, 0 - lsls r1, 24 - lsrs r7, r1, 24 - lsls r2, 16 - lsrs r4, r2, 16 - lsls r3, 24 - lsrs r5, r3, 24 - ldr r0, =0x0000088d - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _080853AC - cmp r5, 0x6 - beq _0808540C -_080853AC: - lsls r4, 24 - lsrs r5, r4, 24 - adds r0, r5, 0 - bl MetatileBehavior_IsDeepSouthWarp - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080853E8 - adds r0, r5, 0 - bl MetatileBehavior_IsNonAnimDoor - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08085442 - adds r0, r5, 0 - bl MetatileBehavior_IsDoor - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08085442 - adds r0, r5, 0 - bl MetatileBehavior_IsSouthArrowWarp - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080853F0 -_080853E8: - movs r0, 0x2 - b _08085448 - .pool -_080853F0: - adds r0, r5, 0 - bl MetatileBehavior_IsNorthArrowWarp - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08085442 - adds r0, r5, 0 - bl MetatileBehavior_IsWestArrowWarp - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08085410 -_0808540C: - movs r0, 0x4 - b _08085448 -_08085410: - adds r0, r5, 0 - bl MetatileBehavior_IsEastArrowWarp - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08085422 - movs r0, 0x3 - b _08085448 -_08085422: - ldrb r0, [r6] - cmp r0, 0x10 - bne _0808542C - cmp r7, 0x8 - beq _08085446 -_0808542C: - cmp r0, 0x8 - bne _08085434 - cmp r7, 0x10 - beq _08085446 -_08085434: - lsrs r0, r4, 24 - bl MetatileBehavior_IsLadder - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08085446 -_08085442: - movs r0, 0x1 - b _08085448 -_08085446: - ldrb r0, [r6, 0x1] -_08085448: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_808538C - - thumb_func_start cur_mapdata_block_role_at_screen_center_acc_to_sav1 -cur_mapdata_block_role_at_screen_center_acc_to_sav1: @ 8085450 - push {lr} - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - movs r2, 0 - ldrsh r0, [r1, r2] - adds r0, 0x7 - movs r2, 0x2 - ldrsh r1, [r1, r2] - adds r1, 0x7 - bl MapGridGetMetatileBehaviorAt - lsls r0, 16 - lsrs r0, 16 - pop {r1} - bx r1 - .pool - thumb_func_end cur_mapdata_block_role_at_screen_center_acc_to_sav1 - - thumb_func_start sav1_map_is_biking_allowed -sav1_map_is_biking_allowed: @ 8085474 - push {lr} - ldr r0, =gMapHeader - ldrb r1, [r0, 0x1A] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0808548C - movs r0, 0x1 - b _0808548E - .pool -_0808548C: - movs r0, 0 -_0808548E: - pop {r1} - bx r1 - thumb_func_end sav1_map_is_biking_allowed - - thumb_func_start update_sav1_flash_used_on_map -update_sav1_flash_used_on_map: @ 8085494 - push {lr} - ldr r0, =gMapHeader - ldrb r1, [r0, 0x15] - cmp r1, 0 - bne _080854B0 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - adds r0, 0x30 - strb r1, [r0] - b _080854DE - .pool -_080854B0: - ldr r0, =0x00000888 - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _080854D0 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - adds r0, 0x30 - movs r1, 0x1 - strb r1, [r0] - b _080854DE - .pool -_080854D0: - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldr r0, =gUnknown_0854FE78 - ldr r0, [r0] - subs r0, 0x1 - adds r1, 0x30 - strb r0, [r1] -_080854DE: - pop {r0} - bx r0 - .pool - thumb_func_end update_sav1_flash_used_on_map - - thumb_func_start Overworld_SetFlashLevel -Overworld_SetFlashLevel: @ 80854EC - push {lr} - adds r1, r0, 0 - cmp r1, 0 - blt _080854FC - ldr r0, =gUnknown_0854FE78 - ldr r0, [r0] - cmp r1, r0 - ble _080854FE -_080854FC: - movs r1, 0 -_080854FE: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - adds r0, 0x30 - strb r1, [r0] - pop {r0} - bx r0 - .pool - thumb_func_end Overworld_SetFlashLevel - - thumb_func_start Overworld_GetFlashLevel -Overworld_GetFlashLevel: @ 8085514 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - adds r0, 0x30 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end Overworld_GetFlashLevel - - thumb_func_start sub_8085524 -sub_8085524: @ 8085524 - push {lr} - ldr r1, =gSaveBlock1Ptr - ldr r1, [r1] - strh r0, [r1, 0x32] - bl get_mapdata_header - ldr r1, =gMapHeader - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end sub_8085524 - - thumb_func_start sub_8085540 -sub_8085540: @ 8085540 - ldr r1, =gUnknown_020322D8 - strb r0, [r1] - bx lr - .pool - thumb_func_end sub_8085540 - - thumb_func_start sub_808554C -sub_808554C: @ 808554C - ldr r0, =gUnknown_020322D8 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_808554C - - thumb_func_start sub_8085558 -sub_8085558: @ 8085558 - push {r4,lr} - adds r4, r0, 0 - ldr r0, =0x0000088a - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _080855AC - movs r0, 0 - ldrsb r0, [r4, r0] - cmp r0, 0 - bne _080855AC - movs r0, 0x1 - ldrsb r0, [r4, r0] - cmp r0, 0x5 - blt _08085584 - cmp r0, 0x8 - ble _0808559E - cmp r0, 0x2B - bgt _08085584 - cmp r0, 0x27 - bge _0808559E -_08085584: - ldr r0, =0x0000405e - bl VarGet - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x3 - bls _080855AC - movs r0, 0x1 - ldrsb r0, [r4, r0] - cmp r0, 0x2E - bgt _080855AC - cmp r0, 0x2C - blt _080855AC -_0808559E: - movs r0, 0x1 - b _080855AE - .pool -_080855AC: - movs r0, 0 -_080855AE: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8085558 - - thumb_func_start sub_80855B4 -sub_80855B4: @ 80855B4 - push {r4,lr} - adds r4, r0, 0 - ldr r0, =0x000040ca - bl VarGet - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - bne _080855D6 - movs r0, 0 - ldrsb r0, [r4, r0] - cmp r0, 0 - bne _080855D6 - movs r0, 0x1 - ldrsb r0, [r4, r0] - cmp r0, 0x7 - beq _080855E0 -_080855D6: - movs r0, 0 - b _080855E2 - .pool -_080855E0: - movs r0, 0x1 -_080855E2: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80855B4 - - thumb_func_start sub_80855E8 -sub_80855E8: @ 80855E8 - push {r4,lr} - adds r4, r0, 0 - ldr r0, =0x000040b3 - bl VarGet - lsls r0, 16 - cmp r0, 0 - bne _08085606 - movs r0, 0 - ldrsb r0, [r4, r0] - cmp r0, 0x20 - bne _08085606 - ldrb r0, [r4, 0x1] - cmp r0, 0x1 - bls _08085610 -_08085606: - movs r0, 0 - b _08085612 - .pool -_08085610: - movs r0, 0x1 -_08085612: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80855E8 - - thumb_func_start sub_8085618 -sub_8085618: @ 8085618 - push {r4,r5,lr} - adds r5, r0, 0 - ldr r4, =0x0000405d - adds r0, r4, 0 - bl VarGet - lsls r0, 16 - cmp r0, 0 - beq _0808564C - adds r0, r4, 0 - bl VarGet - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x2 - bhi _0808564C - movs r0, 0 - ldrsb r0, [r5, r0] - cmp r0, 0xE - bne _0808564C - ldrb r0, [r5, 0x1] - subs r0, 0x9 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bls _08085654 -_0808564C: - movs r0, 0 - b _08085656 - .pool -_08085654: - movs r0, 0x1 -_08085656: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8085618 - - thumb_func_start warp_target_get_music -warp_target_get_music: @ 808565C - push {r4,lr} - adds r4, r0, 0 - bl sub_80855B4 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - bne _08085674 - ldr r0, =0x0000ffff - b _080856CE - .pool -_08085674: - adds r0, r4, 0 - bl sub_8085558 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - bne _0808568C - ldr r0, =0x000001bb - b _080856CE - .pool -_0808568C: - adds r0, r4, 0 - bl sub_8085618 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - bne _080856A4 - ldr r0, =0x000001b9 - b _080856CE - .pool -_080856A4: - adds r0, r4, 0 - bl sub_80855E8 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - beq _080856CA - movs r0, 0 - ldrsb r0, [r4, r0] - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - ldrsb r1, [r4, r1] - lsls r1, 16 - lsrs r1, 16 - bl Overworld_GetMapHeaderByGroupAndId - ldrh r0, [r0, 0x10] - b _080856CE -_080856CA: - movs r0, 0xCB - lsls r0, 1 -_080856CE: - pop {r4} - pop {r1} - bx r1 - thumb_func_end warp_target_get_music - - thumb_func_start sav1_map_get_music -sav1_map_get_music: @ 80856D4 - push {r4,lr} - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldrh r1, [r0, 0x4] - movs r0, 0xD0 - lsls r0, 5 - cmp r1, r0 - bne _080856FC - bl GetSav1Weather - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x8 - bne _080856FC - ldr r0, =0x00000199 - b _08085730 - .pool -_080856FC: - ldr r4, =gSaveBlock1Ptr - ldr r0, [r4] - adds r0, 0x4 - bl warp_target_get_music - lsls r0, 16 - lsrs r1, r0, 16 - ldr r0, =0x00007fff - cmp r1, r0 - beq _0808571C - adds r0, r1, 0 - b _08085730 - .pool -_0808571C: - ldr r0, [r4] - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0x17 - ble _0808572C - movs r0, 0xC9 - lsls r0, 1 - b _08085730 -_0808572C: - movs r0, 0xB4 - lsls r0, 1 -_08085730: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sav1_map_get_music - - thumb_func_start warp1_target_get_music -warp1_target_get_music: @ 8085738 - push {lr} - ldr r0, =gWarpDestination - bl warp_target_get_music - lsls r0, 16 - lsrs r1, r0, 16 - ldr r0, =0x00007fff - cmp r1, r0 - beq _08085758 - adds r0, r1, 0 - b _08085774 - .pool -_08085758: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldrh r1, [r0, 0x4] - movs r0, 0x80 - lsls r0, 2 - cmp r1, r0 - beq _08085770 - subs r0, 0x6E - b _08085774 - .pool -_08085770: - movs r0, 0xB4 - lsls r0, 1 -_08085774: - pop {r1} - bx r1 - thumb_func_end warp1_target_get_music - - thumb_func_start call_ResetMapMusic -call_ResetMapMusic: @ 8085778 - push {lr} - bl ResetMapMusic - pop {r0} - bx r0 - thumb_func_end call_ResetMapMusic - - thumb_func_start Overworld_PlaySpecialMapMusic -Overworld_PlaySpecialMapMusic: @ 8085784 - push {r4,lr} - bl sav1_map_get_music - lsls r0, 16 - lsrs r4, r0, 16 - ldr r0, =0x000001bb - cmp r4, r0 - beq _080857D6 - ldr r0, =0x0000ffff - cmp r4, r0 - beq _080857D6 - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldrh r0, [r1, 0x2C] - cmp r0, 0 - beq _080857B4 - adds r4, r0, 0 - b _080857D6 - .pool -_080857B4: - bl Overworld_GetMapTypeOfSaveblockLocation - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x5 - bne _080857C8 - ldr r4, =0x0000019b - b _080857D6 - .pool -_080857C8: - movs r0, 0x8 - bl TestPlayerAvatarFlags - lsls r0, 24 - cmp r0, 0 - beq _080857D6 - ldr r4, =0x0000016d -_080857D6: - bl GetCurrentMapMusic - lsls r0, 16 - lsrs r0, 16 - cmp r4, r0 - beq _080857E8 - adds r0, r4, 0 - bl PlayNewMapMusic -_080857E8: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end Overworld_PlaySpecialMapMusic - - thumb_func_start Overworld_SetSavedMusic -Overworld_SetSavedMusic: @ 80857F4 - ldr r1, =gSaveBlock1Ptr - ldr r1, [r1] - strh r0, [r1, 0x2C] - bx lr - .pool - thumb_func_end Overworld_SetSavedMusic - - thumb_func_start Overworld_ClearSavedMusic -Overworld_ClearSavedMusic: @ 8085800 - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - movs r0, 0 - strh r0, [r1, 0x2C] - bx lr - .pool - thumb_func_end Overworld_ClearSavedMusic - - thumb_func_start sub_8085810 -sub_8085810: @ 8085810 - push {r4-r6,lr} - ldr r0, =0x00004001 - bl FlagGet - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08085890 - bl warp1_target_get_music - lsls r0, 16 - lsrs r4, r0, 16 - bl GetCurrentMapMusic - lsls r0, 16 - lsrs r5, r0, 16 - ldr r0, =0x000001bb - cmp r4, r0 - beq _08085856 - ldr r0, =0x0000ffff - cmp r4, r0 - beq _08085856 - ldr r0, =0x0000019b - cmp r5, r0 - beq _08085890 - ldr r6, =0x0000016d - cmp r5, r6 - beq _08085890 - movs r0, 0x8 - bl TestPlayerAvatarFlags - lsls r0, 24 - cmp r0, 0 - beq _08085856 - adds r4, r6, 0 -_08085856: - cmp r4, r5 - beq _08085890 - movs r0, 0x6 - bl TestPlayerAvatarFlags - lsls r0, 24 - cmp r0, 0 - beq _08085888 - adds r0, r4, 0 - movs r1, 0x4 - movs r2, 0x4 - bl FadeOutAndFadeInNewMapMusic - b _08085890 - .pool -_08085888: - adds r0, r4, 0 - movs r1, 0x8 - bl FadeOutAndPlayNewMapMusic -_08085890: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8085810 - - thumb_func_start Overworld_ChangeMusicToDefault -Overworld_ChangeMusicToDefault: @ 8085898 - push {r4,lr} - bl GetCurrentMapMusic - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - bl sav1_map_get_music - lsls r0, 16 - lsrs r0, 16 - cmp r4, r0 - beq _080858BE - bl sav1_map_get_music - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x8 - bl FadeOutAndPlayNewMapMusic -_080858BE: - pop {r4} - pop {r0} - bx r0 - thumb_func_end Overworld_ChangeMusicToDefault - - thumb_func_start Overworld_ChangeMusicTo -Overworld_ChangeMusicTo: @ 80858C4 - push {r4,lr} - lsls r0, 16 - lsrs r4, r0, 16 - bl GetCurrentMapMusic - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, r4 - beq _080858E4 - ldr r0, =0x000001bb - cmp r1, r0 - beq _080858E4 - adds r0, r4, 0 - movs r1, 0x8 - bl FadeOutAndPlayNewMapMusic -_080858E4: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end Overworld_ChangeMusicTo - - thumb_func_start is_warp1_light_level_8_or_9 -is_warp1_light_level_8_or_9: @ 80858F0 - push {lr} - bl warp1_get_mapheader - ldrb r0, [r0, 0x17] - bl is_light_level_8_or_9 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08085908 - movs r0, 0x4 - b _0808590A -_08085908: - movs r0, 0x2 -_0808590A: - pop {r1} - bx r1 - thumb_func_end is_warp1_light_level_8_or_9 - - thumb_func_start music_something -music_something: @ 8085910 - push {r4,r5,lr} - bl GetCurrentMapMusic - lsls r0, 16 - lsrs r5, r0, 16 - bl warp1_target_get_music - lsls r0, 16 - lsrs r4, r0, 16 - ldr r0, =0x00004001 - bl FlagGet - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0808597E - bl GetCurrentMapMusic - lsls r0, 16 - lsrs r0, 16 - cmp r4, r0 - beq _0808597E - ldr r0, =0x0000016d - cmp r5, r0 - bne _08085972 - ldr r0, =0x000040ca - bl VarGet - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x2 - bne _08085972 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x0000ffff - ldrh r2, [r0, 0x4] - movs r0, 0xE0 - lsls r0, 3 - cmp r2, r0 - bne _08085972 - ldr r3, =gWarpDestination - ldrh r0, [r3] - ands r1, r0 - cmp r1, r2 - bne _08085972 - ldr r1, [r3, 0x4] - ldr r0, =0x0035001d - cmp r1, r0 - beq _0808597E -_08085972: - bl is_warp1_light_level_8_or_9 - lsls r0, 24 - lsrs r0, 24 - bl FadeOutMapMusic -_0808597E: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end music_something - - thumb_func_start sub_80859A0 -sub_80859A0: @ 80859A0 - push {lr} - bl IsNotWaitingForBGMStop - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - thumb_func_end sub_80859A0 - - thumb_func_start sub_80859B0 -sub_80859B0: @ 80859B0 - push {lr} - movs r0, 0x4 - bl FadeOutMapMusic - pop {r0} - bx r0 - thumb_func_end sub_80859B0 thumb_func_start sub_80859BC sub_80859BC: @ 80859BC @@ -1491,7 +17,7 @@ sub_80859BC: @ 80859BC mov r0, sp adds r1, r4, 0 bl PlayerGetDestCoords - ldr r0, =gUnknown_02032306 + ldr r0, =sIsAmbientCryWaterMon ldrb r0, [r0] cmp r0, 0x1 bne _080859F0 @@ -1524,7 +50,7 @@ _080859F0: bl __umodsi3 adds r2, r0, 0 adds r2, 0x32 - ldr r0, =gUnknown_02032304 + ldr r0, =sAmbientCrySpecies ldrh r0, [r0] lsls r4, 24 asrs r4, 24 @@ -1567,7 +93,7 @@ _08085A60: .4byte _08085B0C .4byte _08085B20 _08085A74: - ldr r0, =gUnknown_02032304 + ldr r0, =sAmbientCrySpecies ldrh r0, [r0] cmp r0, 0 bne _08085A84 @@ -1673,17 +199,17 @@ ChooseAmbientCrySpecies: @ 8085B2C lsls r0, 24 cmp r0, 0 bne _08085B5C - ldr r1, =gUnknown_02032306 + ldr r1, =sIsAmbientCryWaterMon movs r0, 0x1 strb r0, [r1] bl GetLocalWaterMon b _08085B62 .pool _08085B5C: - ldr r0, =gUnknown_02032306 + ldr r0, =sIsAmbientCryWaterMon bl GetLocalWildMon _08085B62: - ldr r1, =gUnknown_02032304 + ldr r1, =sAmbientCrySpecies strh r0, [r1] pop {r0} bx r0 @@ -1796,8 +322,8 @@ _08085C10: bx r1 thumb_func_end Overworld_MapTypeAllowsTeleportAndFly - thumb_func_start is_light_level_8_or_9 -is_light_level_8_or_9: @ 8085C14 + thumb_func_start Overworld_MapTypeIsIndoors +Overworld_MapTypeIsIndoors: @ 8085C14 push {lr} lsls r0, 24 movs r1, 0xF8 @@ -1813,7 +339,7 @@ _08085C28: _08085C2A: pop {r1} bx r1 - thumb_func_end is_light_level_8_or_9 + thumb_func_end Overworld_MapTypeIsIndoors thumb_func_start sav1_saved_warp2_map_get_name sav1_saved_warp2_map_get_name: @ 8085C30 @@ -2483,7 +1009,7 @@ sub_8086204: @ 8086204 lsrs r0, 24 cmp r0, 0x1 bne _08086222 - bl AddMapNamePopUpWindowTask + bl ShowMapNamePopup _08086222: bl sub_80AF3C8 pop {r0} @@ -2899,7 +1425,7 @@ _080865F4: lsrs r0, 24 cmp r0, 0x1 bne _08086622 - bl AddMapNamePopUpWindowTask + bl ShowMapNamePopup b _08086622 .pool _08086618: diff --git a/data/field_screen.s b/data/field_screen.s index f95e7e0ec..968e2e7f3 100644 --- a/data/field_screen.s +++ b/data/field_screen.s @@ -483,7 +483,7 @@ gUnknown_0854FE64:: @ 854FE64 .2byte 0x00c8, 0x0048, 0x0040, 0x0038, 0x0030, 0x0028, 0x0020, 0x0018, 0x0000, 0x0000 .align 2 -gUnknown_0854FE78:: @ 854FE78 +gMaxFlashLevel:: @ 854FE78 .4byte 0x00000008 .align 2 diff --git a/data/scripts/maps/BattleFrontier_BattlePyramidEmptySquare.inc b/data/scripts/maps/BattleFrontier_BattlePyramidEmptySquare.inc index cff676124..c2b70944b 100644 --- a/data/scripts/maps/BattleFrontier_BattlePyramidEmptySquare.inc +++ b/data/scripts/maps/BattleFrontier_BattlePyramidEmptySquare.inc @@ -28,7 +28,7 @@ BattleFrontier_BattlePyramidEmptySquare_EventScript_252A77:: @ 8252A77 end BattleFrontier_BattlePyramidEmptySquare_EventScript_252A8F:: @ 8252A8F - special AddMapNamePopUpWindowTask + special ShowMapNamePopup setvar VAR_0x400F, 0 end diff --git a/data/scripts/maps/BattleFrontier_BattlePyramidTop.inc b/data/scripts/maps/BattleFrontier_BattlePyramidTop.inc index 6c44e0044..3ba3a5a6a 100644 --- a/data/scripts/maps/BattleFrontier_BattlePyramidTop.inc +++ b/data/scripts/maps/BattleFrontier_BattlePyramidTop.inc @@ -64,7 +64,7 @@ BattleFrontier_BattlePyramidTop_EventScript_255180:: @ 8255180 end BattleFrontier_BattlePyramidTop_EventScript_25518A:: @ 825518A - special AddMapNamePopUpWindowTask + special ShowMapNamePopup setvar VAR_0x400F, 0 end diff --git a/data/specials.inc b/data/specials.inc index a4bd17699..f9f7c97d7 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -417,8 +417,8 @@ gSpecials:: @ 81DBA64 def_special sub_813B880 def_special sub_81A085C def_special ShouldTryGetTrainerScript - def_special AddMapNamePopUpWindowTask - def_special AddMapNamePopUpWindowTask + def_special ShowMapNamePopup + def_special ShowMapNamePopup def_special sub_81BE994 def_special sub_81BE79C def_special sub_81BE7F4 diff --git a/include/constants/vars.h b/include/constants/vars.h index c0e3313b6..be21f1730 100644 --- a/include/constants/vars.h +++ b/include/constants/vars.h @@ -184,7 +184,7 @@ #define VAR_0x40B0 0x40B0 #define VAR_0x40B1 0x40B1 #define VAR_0x40B2 0x40B2 -#define VAR_0x40B3 0x40B3 +#define VAR_WEATHER_INSTITUTE_STATE 0x40B3 #define VAR_PORTHOLE 0x40B4 #define VAR_0x40B5 0x40B5 #define VAR_0x40B6 0x40B6 diff --git a/include/global.h b/include/global.h index 8913432ba..b815e1e5f 100644 --- a/include/global.h +++ b/include/global.h @@ -620,10 +620,10 @@ struct SaveBlock1 /*0x14*/ struct WarpData warp2; /*0x1C*/ struct WarpData lastHealLocation; /*0x24*/ struct WarpData warp4; - /*0x2C*/ u16 battleMusic; + /*0x2C*/ u16 savedMusic; /*0x2E*/ u8 weather; /*0x2F*/ u8 filler_2F; - /*0x30*/ u8 flashUsed; + /*0x30*/ u8 flashLevel; /*0x32*/ u16 mapDataId; /*0x34*/ u16 mapView[0x100]; /*0x234*/ u8 playerPartyCount; diff --git a/include/overworld.h b/include/overworld.h index 904f61c8e..cedad6266 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -63,6 +63,14 @@ void sub_8084D5C(s16 a1, s16 a2); void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); // to erase later +bool32 Overworld_IsBikingAllowed(void); +u8 sub_808532C(struct UnkPlayerStruct *playerStruct, u16 a2, u8 a3); +u8 sub_808538C(struct UnkPlayerStruct *playerStruct, u8 a2, u16 a3, u8 a4); +u16 cur_mapdata_block_role_at_screen_center_acc_to_sav1(void); +bool8 Overworld_MapTypeIsIndoors(u8 mapType); +void SetDefaultFlashLevel(void); +void Overworld_ClearSavedMusic(void); +void sub_8085810(void); u8 GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum); u8 Overworld_GetMapTypeOfSaveblockLocation(void); void Overworld_SetMapObjTemplateCoords(u8, s16, s16); diff --git a/src/item_use.c b/src/item_use.c index 99dce9cbd..bc70c5884 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -45,7 +45,7 @@ extern void ItemUseOutOfBattle_EvolutionStone(u8 b); extern void bag_menu_mail_related(void); extern void OpenPokeblockCase(u8 a, void(*b)(void)); extern void overworld_free_bg_tilemaps(void); -extern bool32 sav1_map_is_biking_allowed(void); +extern bool32 Overworld_IsBikingAllowed(void); extern bool8 IsPlayerFacingSurfableFishableWater(void); extern bool8 sub_81221AC(void); extern u8 gText_ItemFinderNothing[]; @@ -236,7 +236,7 @@ void ItemUseOutOfBattle_Bike(u8 taskId) DisplayCannotDismountBikeMessage(taskId, data[3]); else { - if (sav1_map_is_biking_allowed() == TRUE && IsBikingDisallowedByPlayer() == 0) + if (Overworld_IsBikingAllowed() == TRUE && IsBikingDisallowedByPlayer() == 0) { gUnknown_0203A0F4 = ItemUseOnFieldCB_Bike; SetUpItemUseOnFieldCallback(taskId); diff --git a/src/overworld.c b/src/overworld.c index 5757ca20a..f5457242d 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -52,15 +52,16 @@ #include "wild_encounter.h" #include "bg.h" #include "money.h" +#include "save_location.h" // event scripts extern const u8 EventScript_WhiteOut[]; extern const u8 EventScript_271862[]; // vars -extern struct MapData * const gMapAttributes[]; -extern struct MapHeader * const * const gMapGroups[]; -extern s32 gMaxFlashLevel; +extern struct MapData *const gMapAttributes[]; +extern struct MapHeader *const *const gMapGroups[]; +extern const s32 gMaxFlashLevel; // functions extern void HealPlayerParty(void); @@ -71,6 +72,22 @@ extern void copy_map_tileset1_tileset2_to_vram(struct MapData *); extern void apply_map_tileset1_tileset2_palette(struct MapData *); extern void ResetCyclingRoadChallengeData(void); extern void ApplyNewEncryptionKeyToWord(u32 *word, u32 newKey); +extern void mapheader_run_script_with_tag_x5(void); +extern void ResetFieldTasksArgs(void); +extern void sub_80A0A2C(void); +extern void not_trainer_hill_battle_pyramid(void); +extern void apply_map_tileset2_palette(struct MapData *); +extern void copy_map_tileset2_to_vram_2(struct MapData *); +extern void prev_quest_postbuffer_cursor_backup_reset(void); +extern void ShowMapNamePopup(void); +extern bool32 InTrainerHill(void); +extern void sub_81AA1D8(void); +extern void sub_81D5DF8(void); +extern void sub_80EB218(void); +extern void trainer_hill_map_load_related(void); +extern void battle_pyramid_map_load_related(u8); +extern void UpdateTVScreensOnMap(u32, u32); +extern void sub_80E9238(u8); // this file's functions static void Overworld_ResetStateAfterWhiteOut(void); @@ -85,15 +102,16 @@ IWRAM_DATA u8 gUnknown_03000E19; IWRAM_DATA void *rom4_c_unused_03000e1c; // EWRAM vars +EWRAM_DATA u8 gUnknown_020322D8 = 0; EWRAM_DATA struct WarpData gUnknown_020322DC = {0}; EWRAM_DATA struct WarpData gWarpDestination = {0}; // new warp position EWRAM_DATA struct WarpData gUnknown_020322EC = {0}; EWRAM_DATA struct WarpData gUnknown_020322F4 = {0}; EWRAM_DATA u16 gLastMapSectionId = 0; -// EWRAM_DATA struct UnkPlayerStruct gUnknown_02029810 = {0}; -// EWRAM_DATA u16 sAmbientCrySpecies = 0; -// EWRAM_DATA bool8 sIsAmbientCryWaterMon = FALSE; -// EWRAM_DATA struct LinkPlayerMapObject gLinkPlayerMapObjects[4] = {0}; +EWRAM_DATA struct UnkPlayerStruct gUnknown_02032300 = {0}; +EWRAM_DATA u16 sAmbientCrySpecies = 0; +EWRAM_DATA bool8 sIsAmbientCryWaterMon = FALSE; +EWRAM_DATA struct LinkPlayerMapObject gLinkPlayerMapObjects[4] = {0}; // const rom data const struct WarpData sDummyWarpData = @@ -544,3 +562,550 @@ void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) { SetWarpData(&gSaveBlock1Ptr->warp4, mapGroup, mapNum, warpId, x, y); } + +void sub_8084E14(void) +{ + gWarpDestination = gSaveBlock1Ptr->warp4; +} + +void sub_8084E2C(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) +{ + SetWarpData(&gUnknown_020322EC, mapGroup, mapNum, warpId, x, y); +} + +void warp1_set_to_warp2(void) +{ + gWarpDestination = gUnknown_020322EC; +} + +void sub_8084E80(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) +{ + SetWarpData(&gUnknown_020322F4, mapGroup, mapNum, warpId, x, y); +} + +void sub_8084EBC(s16 x, s16 y) +{ + if (warp_data_is_not_neg_1(&gUnknown_020322F4) == TRUE) + { + gWarpDestination = gUnknown_020322DC; + } + else + { + Overworld_SetWarpDestination(gUnknown_020322F4.mapGroup, gUnknown_020322F4.mapNum, -1, x, y); + } +} + +void warp1_set_to_sav1w(void) +{ + gWarpDestination = gSaveBlock1Ptr->warp1; +} + +void sub_8084F2C(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) +{ + SetWarpData(&gSaveBlock1Ptr->warp1, mapGroup, mapNum, warpId, x, y); +} + +void sub_8084F6C(u8 a1) +{ + const struct HealLocation *warp = GetHealLocationPointer(a1); + if (warp) + SetWarpData(&gSaveBlock1Ptr->warp1, warp->group, warp->map, -1, warp->x, warp->y); +} + +void sub_8084FAC(void) +{ + gSaveBlock1Ptr->warp1 = gSaveBlock1Ptr->warp2; +} + +struct MapConnection *GetMapConnection(u8 dir) +{ + s32 i; + s32 count = gMapHeader.connections->count; + struct MapConnection *connection = gMapHeader.connections->connections; + + if (connection == NULL) + return NULL; + + for(i = 0; i < count; i++, connection++) + if (connection->direction == dir) + return connection; + + return NULL; +} + +bool8 sub_8084FF8(u8 dir, u16 x, u16 y) +{ + struct MapConnection *connection = GetMapConnection(dir); + + if (connection != NULL) + { + Overworld_SetWarpDestination(connection->mapGroup, connection->mapNum, -1, x, y); + } + else + { + mapheader_run_script_with_tag_x6(); + if (warp_data_is_not_neg_1(&gUnknown_020322EC)) + return FALSE; + warp1_set_to_warp2(); + } + return TRUE; +} + +bool8 sub_8085058(u16 x, u16 y) +{ + return sub_8084FF8(CONNECTION_EMERGE, x, y); +} + +bool8 sub_8085078(u16 x, u16 y) +{ + return sub_8084FF8(CONNECTION_DIVE, x, y); +} + +void mliX_load_map(u8 mapGroup, u8 mapNum) +{ + s32 paletteIndex; + + Overworld_SetWarpDestination(mapGroup, mapNum, -1, -1, -1); + if (gMapHeader.regionMapSectionId != 0x3A) + sub_8085810(); + + ApplyCurrentWarp(); + set_current_map_header_from_sav1_save_old_name(); + LoadMapObjTemplatesFromHeader(); + TrySetMapSaveWarpStatus(); + ClearTempFieldEventData(); + ResetCyclingRoadChallengeData(); + prev_quest_postbuffer_cursor_backup_reset(); + TryUpdateRandomTrainerRematches(mapGroup, mapNum); + DoTimeBasedEvents(); + SetSav1WeatherFromCurrMapHeader(); + ChooseAmbientCrySpecies(); + SetDefaultFlashLevel(); + Overworld_ClearSavedMusic(); + mapheader_run_script_with_tag_x3(); + not_trainer_hill_battle_pyramid(); + copy_map_tileset2_to_vram_2(gMapHeader.mapData); + apply_map_tileset2_palette(gMapHeader.mapData); + + for (paletteIndex = 6; paletteIndex < 13; paletteIndex++) + ApplyWeatherGammaShiftToPal(paletteIndex); + + sub_80A0A2C(); + UpdateLocationHistoryForRoamer(); + RoamerMove(); + DoCurrentWeather(); + ResetFieldTasksArgs(); + mapheader_run_script_with_tag_x5(); + + if (gMapHeader.regionMapSectionId != 0x3A || gMapHeader.regionMapSectionId != gLastMapSectionId) + ShowMapNamePopup(); +} + +void mli0_load_map(u32 a1) +{ + bool8 v2; + bool8 indoors; + + set_current_map_header_from_sav1_save_old_name(); + if (!(gUnknown_020322D8 & 1)) + { + if (gMapHeader.mapDataId == 0x169) + sub_81AA1D8(); + else if (InTrainerHill()) + sub_81D5DF8(); + else + LoadMapObjTemplatesFromHeader(); + } + + v2 = is_light_level_1_2_3_5_or_6(gMapHeader.mapType); + indoors = Overworld_MapTypeIsIndoors(gMapHeader.mapType); + + sub_80EB218(); + TrySetMapSaveWarpStatus(); + ClearTempFieldEventData(); + ResetCyclingRoadChallengeData(); + prev_quest_postbuffer_cursor_backup_reset(); + TryUpdateRandomTrainerRematches(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum); + if (a1 != 1) + DoTimeBasedEvents(); + SetSav1WeatherFromCurrMapHeader(); + ChooseAmbientCrySpecies(); + if (v2) + FlagClear(FLAG_SYS_USE_FLASH); + SetDefaultFlashLevel(); + Overworld_ClearSavedMusic(); + mapheader_run_script_with_tag_x3(); + UpdateLocationHistoryForRoamer(); + RoamerMoveToOtherLocationSet(); + if (gMapHeader.mapDataId == 0x169) + battle_pyramid_map_load_related(0); + else if (InTrainerHill()) + trainer_hill_map_load_related(); + else + not_trainer_hill_battle_pyramid(); + + if (a1 != 1 && indoors) + { + UpdateTVScreensOnMap(gUnknown_03005DC0.width, gUnknown_03005DC0.height); + sub_80E9238(1); + } +} + +void player_avatar_init_params_reset(void) +{ + gUnknown_02032300.player_field_1 = 1; + gUnknown_02032300.player_field_0 = 1; +} + +void walkrun_find_lowest_active_bit_in_bitfield(void) +{ + gUnknown_02032300.player_field_1 = player_get_direction_lower_nybble(); + + if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE)) + gUnknown_02032300.player_field_0 = 2; + else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE)) + gUnknown_02032300.player_field_0 = 4; + else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) + gUnknown_02032300.player_field_0 = 8; + else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_4)) + gUnknown_02032300.player_field_0 = 16; + else + gUnknown_02032300.player_field_0 = 1; +} + +struct UnkPlayerStruct *sub_80852D4(void) +{ + struct UnkPlayerStruct playerStruct; + u8 mapType = Overworld_GetMapTypeOfSaveblockLocation(); + u16 v2 = cur_mapdata_block_role_at_screen_center_acc_to_sav1(); + u8 v4 = sub_808532C(&gUnknown_02032300, v2, mapType); + playerStruct.player_field_0 = v4; + playerStruct.player_field_1 = sub_808538C(&gUnknown_02032300, v4, v2, mapType); + gUnknown_02032300 = playerStruct; + return &gUnknown_02032300; +} + +u8 sub_808532C(struct UnkPlayerStruct *playerStruct, u16 a2, u8 a3) +{ + if (a3 != 8 && FlagGet(FLAG_SYS_CRUISE_MODE)) + return 1; + if (a3 == 5) + return 16; + if (MetatileBehavior_IsSurfableWaterOrUnderwater(a2) == 1) + return 8; + if (Overworld_IsBikingAllowed() != TRUE) + return 1; + if (playerStruct->player_field_0 == 2) + return 2; + if (playerStruct->player_field_0 != 4) + return 1; + return 4; +} + +u8 sub_808538C(struct UnkPlayerStruct *playerStruct, u8 a2, u16 a3, u8 a4) +{ + if (FlagGet(FLAG_SYS_CRUISE_MODE) && a4 == 6) + return 4; + if (MetatileBehavior_IsDeepSouthWarp(a3) == TRUE) + return 2; + if (MetatileBehavior_IsNonAnimDoor(a3) == TRUE || MetatileBehavior_IsDoor(a3) == TRUE) + return 1; + if (MetatileBehavior_IsSouthArrowWarp(a3) == TRUE) + return 2; + if (MetatileBehavior_IsNorthArrowWarp(a3) == TRUE) + return 1; + if (MetatileBehavior_IsWestArrowWarp(a3) == TRUE) + return 4; + if (MetatileBehavior_IsEastArrowWarp(a3) == TRUE) + return 3; + if ((playerStruct->player_field_0 == 16 && a2 == 8) + || (playerStruct->player_field_0 == 8 && a2 == 16)) + return playerStruct->player_field_1; + if (MetatileBehavior_IsLadder(a3) == TRUE) + return playerStruct->player_field_1; + return 1; +} + +u16 cur_mapdata_block_role_at_screen_center_acc_to_sav1(void) +{ + return MapGridGetMetatileBehaviorAt(gSaveBlock1Ptr->pos.x + 7, gSaveBlock1Ptr->pos.y + 7); +} + +bool32 Overworld_IsBikingAllowed(void) +{ + if (!(gMapHeader.flags & 1)) + return FALSE; + else + return TRUE; +} + +void SetDefaultFlashLevel(void) +{ + if (!gMapHeader.cave) + gSaveBlock1Ptr->flashLevel = 0; + else if (FlagGet(FLAG_SYS_USE_FLASH)) + gSaveBlock1Ptr->flashLevel = 1; + else + gSaveBlock1Ptr->flashLevel = gMaxFlashLevel - 1; +} + +void Overworld_SetFlashLevel(s32 flashLevel) +{ + if (flashLevel < 0 || flashLevel > gMaxFlashLevel) + flashLevel = 0; + gSaveBlock1Ptr->flashLevel = flashLevel; +} + +u8 Overworld_GetFlashLevel(void) +{ + return gSaveBlock1Ptr->flashLevel; +} + +void sub_8085524(u16 mapDataId) +{ + gSaveBlock1Ptr->mapDataId = mapDataId; + gMapHeader.mapData = get_mapdata_header(); +} + +void sub_8085540(u8 var) +{ + gUnknown_020322D8 = var; +} + +u8 sub_808554C(void) +{ + return gUnknown_020322D8; +} + +bool16 ShouldLegendaryMusicPlayAtLocation(struct WarpData *warp) +{ + if (!FlagGet(FLAG_SYS_WEATHER_CTRL)) + return FALSE; + if (warp->mapGroup == 0) + { + switch (warp->mapNum) + { + case MAP_NUM(LILYCOVE_CITY): + case MAP_NUM(MOSSDEEP_CITY): + case MAP_NUM(SOOTOPOLIS_CITY): + case MAP_NUM(EVER_GRANDE_CITY): + case MAP_NUM(ROUTE124): + case MAP_NUM(ROUTE125): + case MAP_NUM(ROUTE126): + case MAP_NUM(ROUTE127): + case MAP_NUM(ROUTE128): + return TRUE; + default: + if (VarGet(VAR_0x405E) < 4) + return FALSE; + switch (warp->mapNum) + { + case MAP_NUM(ROUTE129): + case MAP_NUM(ROUTE130): + case MAP_NUM(ROUTE131): + return TRUE; + } + } + } + return FALSE; +} + +bool16 NoMusicInSotopolisWithLegendaries(struct WarpData *warp) +{ + if (VarGet(VAR_0x40CA) != 1) + return FALSE; + if (warp->mapGroup != MAP_GROUP(SOOTOPOLIS_CITY)) + return FALSE; + if (warp->mapNum == MAP_NUM(SOOTOPOLIS_CITY)) + return TRUE; + return FALSE; +} + +bool16 IsInfiltratedWeatherInstitute(struct WarpData *warp) +{ + if (VarGet(VAR_WEATHER_INSTITUTE_STATE)) + return FALSE; + if (warp->mapGroup != MAP_GROUP(ROUTE119_WEATHER_INSTITUTE_1F)) + return FALSE; + if (warp->mapNum == MAP_NUM(ROUTE119_WEATHER_INSTITUTE_1F) + || warp->mapNum == MAP_NUM(ROUTE119_WEATHER_INSTITUTE_2F)) + return TRUE; + return FALSE; +} + +bool16 IsInflitratedSpaceCenter(struct WarpData *warp) +{ + if (VarGet(VAR_0x405D) == 0) + return FALSE; + if (VarGet(VAR_0x405D) > 2) + return FALSE; + if (warp->mapGroup != MAP_GROUP(MOSSDEEP_CITY_SPACE_CENTER_1F)) + return FALSE; + if (warp->mapNum == MAP_NUM(MOSSDEEP_CITY_SPACE_CENTER_1F) + || warp->mapNum == MAP_NUM(MOSSDEEP_CITY_SPACE_CENTER_2F)) + return TRUE; + return FALSE; +} + +u16 GetLocationMusic(struct WarpData *warp) +{ + if (NoMusicInSotopolisWithLegendaries(warp) == TRUE) + return 0xFFFF; + else if (ShouldLegendaryMusicPlayAtLocation(warp) == TRUE) + return MUS_OOAME; + else if (IsInflitratedSpaceCenter(warp) == TRUE) + return MUS_MGM0; + else if (IsInfiltratedWeatherInstitute(warp) == TRUE) + return MUS_TOZAN; + else + return Overworld_GetMapHeaderByGroupAndId(warp->mapGroup, warp->mapNum)->music; +} + +u16 GetCurrLocationDefaultMusic(void) +{ + u16 music; + + // Play the desert music only when the sandstorm is active on Route 111. + if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(ROUTE111) + && gSaveBlock1Ptr->location.mapNum == MAP_NUM(ROUTE111) + && GetSav1Weather() == 8) + return MUS_ASHROAD; + + music = GetLocationMusic(&gSaveBlock1Ptr->location); + if (music != 0x7FFF) + { + return music; + } + else + { + if (gSaveBlock1Ptr->pos.x < 24) + return MUS_DOORO_X1; + else + return MUS_GRANROAD; + } +} + +u16 GetWarpDestinationMusic(void) +{ + u16 music = GetLocationMusic(&gWarpDestination); + if (music != 0x7FFF) + { + return music; + } + else + { + if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(MAUVILLE_CITY) + && gSaveBlock1Ptr->location.mapNum == MAP_NUM(MAUVILLE_CITY)) + return MUS_DOORO_X1; + else + return MUS_GRANROAD; + } +} + +void Overworld_ResetMapMusic(void) +{ + ResetMapMusic(); +} + +void Overworld_PlaySpecialMapMusic(void) +{ + u16 music = GetCurrLocationDefaultMusic(); + + if (music != MUS_OOAME && music != 0xFFFF) + { + if (gSaveBlock1Ptr->savedMusic) + music = gSaveBlock1Ptr->savedMusic; + else if (Overworld_GetMapTypeOfSaveblockLocation() == MAP_TYPE_UNDERWATER) + music = MUS_DEEPDEEP; + else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) + music = MUS_NAMINORI; + } + + if (music != GetCurrentMapMusic()) + PlayNewMapMusic(music); +} + +void Overworld_SetSavedMusic(u16 songNum) +{ + gSaveBlock1Ptr->savedMusic = songNum; +} + +void Overworld_ClearSavedMusic(void) +{ + gSaveBlock1Ptr->savedMusic = 0; +} + +void sub_8085810(void) +{ + if (FlagGet(FLAG_SPECIAL_FLAG_0x4001) != TRUE) + { + u16 newMusic = GetWarpDestinationMusic(); + u16 currentMusic = GetCurrentMapMusic(); + if (newMusic != MUS_OOAME && newMusic != 0xFFFF) + { + if (currentMusic == MUS_DEEPDEEP || currentMusic == MUS_NAMINORI) + return; + if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) + newMusic = MUS_NAMINORI; + } + if (newMusic != currentMusic) + { + if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE)) + FadeOutAndFadeInNewMapMusic(newMusic, 4, 4); + else + FadeOutAndPlayNewMapMusic(newMusic, 8); + } + } +} + +void Overworld_ChangeMusicToDefault(void) +{ + u16 currentMusic = GetCurrentMapMusic(); + if (currentMusic != GetCurrLocationDefaultMusic()) + FadeOutAndPlayNewMapMusic(GetCurrLocationDefaultMusic(), 8); +} + +void Overworld_ChangeMusicTo(u16 newMusic) +{ + u16 currentMusic = GetCurrentMapMusic(); + if (currentMusic != newMusic && currentMusic != MUS_OOAME) + FadeOutAndPlayNewMapMusic(newMusic, 8); +} + +u8 GetMapMusicFadeoutSpeed(void) +{ + struct MapHeader *mapHeader = warp1_get_mapheader(); + if (Overworld_MapTypeIsIndoors(mapHeader->mapType) == TRUE) + return 2; + else + return 4; +} + +void music_something(void) +{ + u16 currentMusic = GetCurrentMapMusic(); + u16 warpMusic = GetWarpDestinationMusic(); + if (FlagGet(FLAG_SPECIAL_FLAG_0x4001) != TRUE && warpMusic != GetCurrentMapMusic()) + { + if (currentMusic == MUS_NAMINORI + && VarGet(VAR_0x40CA) == 2 + && gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(SOOTOPOLIS_CITY) + && gSaveBlock1Ptr->location.mapNum == MAP_NUM(SOOTOPOLIS_CITY) + && gWarpDestination.mapGroup == MAP_GROUP(SOOTOPOLIS_CITY) + && gWarpDestination.mapNum == MAP_NUM(SOOTOPOLIS_CITY) + && gWarpDestination.x == 0x1D + && gWarpDestination.y == 0x35) + return; + FadeOutMapMusic(GetMapMusicFadeoutSpeed()); + } +} + +bool8 sub_80859A0(void) +{ + return IsNotWaitingForBGMStop(); +} + +void Overworld_FadeOutMapMusic(void) +{ + FadeOutMapMusic(4); +} diff --git a/sym_ewram.txt b/sym_ewram.txt index ed231e96f..05118682e 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -211,24 +211,8 @@ gDifferentSaveFile: @ 20322D4 gUnknown_020322D5: @ 20322D5 .space 0x3 -gUnknown_020322D8: @ 20322D8 - .space 0x4 - .include "src/overworld.o" -.align 2 -gUnknown_02032300: @ 2032300 - .space 0x4 - -gUnknown_02032304: @ 2032304 - .space 0x2 - -gUnknown_02032306: @ 2032306 - .space 0x2 - -gLinkPlayerMapObjects: @ 2032308 - .space 0x10 - gUnknown_02032318: @ 2032318 .space 0x5000 From 7b360b2e338e4f2a008374a0114367dadf728484 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Tue, 13 Feb 2018 09:16:38 +0530 Subject: [PATCH 11/27] Review fixes --- include/text.h | 22 ++++++++++++++++++++++ src/birch_pc.c | 23 +---------------------- src/smokescreen.c | 2 -- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/include/text.h b/include/text.h index e073c3762..fde02cf2d 100644 --- a/include/text.h +++ b/include/text.h @@ -249,4 +249,26 @@ void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese); u32 GetGlyphWidthFont1(u16 glyphId, bool32 isJapanese); void DecompressGlyphFont9(u16 glyphId); +extern const u8 gBirchDexRatingText_LessThan10[]; +extern const u8 gBirchDexRatingText_LessThan20[]; +extern const u8 gBirchDexRatingText_LessThan30[]; +extern const u8 gBirchDexRatingText_LessThan40[]; +extern const u8 gBirchDexRatingText_LessThan50[]; +extern const u8 gBirchDexRatingText_LessThan60[]; +extern const u8 gBirchDexRatingText_LessThan70[]; +extern const u8 gBirchDexRatingText_LessThan80[]; +extern const u8 gBirchDexRatingText_LessThan90[]; +extern const u8 gBirchDexRatingText_LessThan100[]; +extern const u8 gBirchDexRatingText_LessThan110[]; +extern const u8 gBirchDexRatingText_LessThan120[]; +extern const u8 gBirchDexRatingText_LessThan130[]; +extern const u8 gBirchDexRatingText_LessThan140[]; +extern const u8 gBirchDexRatingText_LessThan150[]; +extern const u8 gBirchDexRatingText_LessThan160[]; +extern const u8 gBirchDexRatingText_LessThan170[]; +extern const u8 gBirchDexRatingText_LessThan180[]; +extern const u8 gBirchDexRatingText_LessThan190[]; +extern const u8 gBirchDexRatingText_LessThan200[]; +extern const u8 gBirchDexRatingText_DexCompleted[]; + #endif // GUARD_TEXT_H diff --git a/src/birch_pc.c b/src/birch_pc.c index 4b0025504..a682d15d9 100644 --- a/src/birch_pc.c +++ b/src/birch_pc.c @@ -3,33 +3,12 @@ #include "field_message_box.h" #include "pokedex.h" #include "constants/species.h" +#include "text.h" extern u16 gSpecialVar_0x8004; extern u16 gSpecialVar_0x8005; extern u16 gSpecialVar_0x8006; -extern const u8 gBirchDexRatingText_LessThan10[]; -extern const u8 gBirchDexRatingText_LessThan20[]; -extern const u8 gBirchDexRatingText_LessThan30[]; -extern const u8 gBirchDexRatingText_LessThan40[]; -extern const u8 gBirchDexRatingText_LessThan50[]; -extern const u8 gBirchDexRatingText_LessThan60[]; -extern const u8 gBirchDexRatingText_LessThan70[]; -extern const u8 gBirchDexRatingText_LessThan80[]; -extern const u8 gBirchDexRatingText_LessThan90[]; -extern const u8 gBirchDexRatingText_LessThan100[]; -extern const u8 gBirchDexRatingText_LessThan110[]; -extern const u8 gBirchDexRatingText_LessThan120[]; -extern const u8 gBirchDexRatingText_LessThan130[]; -extern const u8 gBirchDexRatingText_LessThan140[]; -extern const u8 gBirchDexRatingText_LessThan150[]; -extern const u8 gBirchDexRatingText_LessThan160[]; -extern const u8 gBirchDexRatingText_LessThan170[]; -extern const u8 gBirchDexRatingText_LessThan180[]; -extern const u8 gBirchDexRatingText_LessThan190[]; -extern const u8 gBirchDexRatingText_LessThan200[]; -extern const u8 gBirchDexRatingText_DexCompleted[]; - bool16 ScriptGetPokedexInfo(void) { if (gSpecialVar_0x8004 == 0) // is national dex not present? diff --git a/src/smokescreen.c b/src/smokescreen.c index 4b0e5d759..9b37cd234 100644 --- a/src/smokescreen.c +++ b/src/smokescreen.c @@ -4,10 +4,8 @@ #include "sprite.h" #include "util.h" - static void sub_8075370(struct Sprite *); - u8 sub_807521C(s16 x, s16 y, u8 a3) { u8 mainSpriteId; From ae321d6e7c99b557cafd594eb945e7ca1a566ba8 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Tue, 13 Feb 2018 09:32:40 +0530 Subject: [PATCH 12/27] move to strings.h --- include/strings.h | 23 +++++++++++++++++++++++ include/text.h | 22 ---------------------- src/birch_pc.c | 2 +- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/include/strings.h b/include/strings.h index 24b2d3e6f..6f4f27d0d 100644 --- a/include/strings.h +++ b/include/strings.h @@ -244,4 +244,27 @@ extern const u8 gText_Var1DotVar2[]; extern const u8 gText_ThreeMarks[]; extern const u8 gText_FirmSlash[]; +// pokedex rating text +extern const u8 gBirchDexRatingText_LessThan10[]; +extern const u8 gBirchDexRatingText_LessThan20[]; +extern const u8 gBirchDexRatingText_LessThan30[]; +extern const u8 gBirchDexRatingText_LessThan40[]; +extern const u8 gBirchDexRatingText_LessThan50[]; +extern const u8 gBirchDexRatingText_LessThan60[]; +extern const u8 gBirchDexRatingText_LessThan70[]; +extern const u8 gBirchDexRatingText_LessThan80[]; +extern const u8 gBirchDexRatingText_LessThan90[]; +extern const u8 gBirchDexRatingText_LessThan100[]; +extern const u8 gBirchDexRatingText_LessThan110[]; +extern const u8 gBirchDexRatingText_LessThan120[]; +extern const u8 gBirchDexRatingText_LessThan130[]; +extern const u8 gBirchDexRatingText_LessThan140[]; +extern const u8 gBirchDexRatingText_LessThan150[]; +extern const u8 gBirchDexRatingText_LessThan160[]; +extern const u8 gBirchDexRatingText_LessThan170[]; +extern const u8 gBirchDexRatingText_LessThan180[]; +extern const u8 gBirchDexRatingText_LessThan190[]; +extern const u8 gBirchDexRatingText_LessThan200[]; +extern const u8 gBirchDexRatingText_DexCompleted[]; + #endif //GUARD_STRINGS_H diff --git a/include/text.h b/include/text.h index fde02cf2d..e073c3762 100644 --- a/include/text.h +++ b/include/text.h @@ -249,26 +249,4 @@ void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese); u32 GetGlyphWidthFont1(u16 glyphId, bool32 isJapanese); void DecompressGlyphFont9(u16 glyphId); -extern const u8 gBirchDexRatingText_LessThan10[]; -extern const u8 gBirchDexRatingText_LessThan20[]; -extern const u8 gBirchDexRatingText_LessThan30[]; -extern const u8 gBirchDexRatingText_LessThan40[]; -extern const u8 gBirchDexRatingText_LessThan50[]; -extern const u8 gBirchDexRatingText_LessThan60[]; -extern const u8 gBirchDexRatingText_LessThan70[]; -extern const u8 gBirchDexRatingText_LessThan80[]; -extern const u8 gBirchDexRatingText_LessThan90[]; -extern const u8 gBirchDexRatingText_LessThan100[]; -extern const u8 gBirchDexRatingText_LessThan110[]; -extern const u8 gBirchDexRatingText_LessThan120[]; -extern const u8 gBirchDexRatingText_LessThan130[]; -extern const u8 gBirchDexRatingText_LessThan140[]; -extern const u8 gBirchDexRatingText_LessThan150[]; -extern const u8 gBirchDexRatingText_LessThan160[]; -extern const u8 gBirchDexRatingText_LessThan170[]; -extern const u8 gBirchDexRatingText_LessThan180[]; -extern const u8 gBirchDexRatingText_LessThan190[]; -extern const u8 gBirchDexRatingText_LessThan200[]; -extern const u8 gBirchDexRatingText_DexCompleted[]; - #endif // GUARD_TEXT_H diff --git a/src/birch_pc.c b/src/birch_pc.c index a682d15d9..0f44824f7 100644 --- a/src/birch_pc.c +++ b/src/birch_pc.c @@ -3,7 +3,7 @@ #include "field_message_box.h" #include "pokedex.h" #include "constants/species.h" -#include "text.h" +#include "strings.h" extern u16 gSpecialVar_0x8004; extern u16 gSpecialVar_0x8005; From e375606810395d3941f2866505c6516949393d2b Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Tue, 13 Feb 2018 21:52:33 +0530 Subject: [PATCH 13/27] [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 fdadd2aac..a0a3f932d 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 f91b34b4a..058504fe2 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 838c468ad..fcecdd4be 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 000000000..77fa0db35 --- /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 14/27] 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 a0a3f932d..000000000 --- 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 a54e0e463..103879101 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 7395270f9..6f5a9886f 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 fcecdd4be..386d63127 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 77fa0db35..9f649f56c 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 5b3492db0..e675ef0a5 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 94b47c0686d3f4c5da962011797cc89a2efdd88c Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 14 Feb 2018 00:58:22 +0100 Subject: [PATCH 15/27] decompile overworld --- asm/battle_frontier_1.s | 6 +- asm/battle_records.s | 2 +- asm/battle_tower.s | 2 +- asm/cable_car.s | 2 +- asm/cable_club.s | 10 +- asm/contest.s | 2 +- asm/contest_link_80F57C4.s | 2 +- asm/field_control_avatar.s | 14 +- asm/field_effect.s | 14 +- asm/field_screen.s | 6 +- asm/field_specials.s | 8 +- asm/field_tasks.s | 8 +- asm/item_menu.s | 8 +- asm/learn_move.s | 2 +- asm/main_menu.s | 2 +- asm/overworld.s | 4352 ----------------- asm/party_menu.s | 22 +- asm/player_pc.s | 6 +- asm/pokedex.s | 2 +- asm/pokemon_storage_system.s | 2 +- asm/pokemon_summary_screen.s | 4 +- asm/pokenav.s | 10 +- asm/rom_8011DC0.s | 30 +- asm/rotating_gate.s | 6 +- asm/roulette.s | 2 +- asm/script_pokemon_util_80F87D8.s | 6 +- asm/shop.s | 4 +- asm/start_menu.s | 10 +- asm/trade.s | 4 +- data/event_scripts.s | 1 - data/item_use.s | 2 +- data/scripts/cable_club.inc | 8 +- data/scripts/maps/FortreeCity_Gym.inc | 2 +- .../maps/Route110_TrickHousePuzzle6.inc | 2 +- data/scripts/maps/Route119.inc | 4 +- .../maps/Route119_WeatherInstitute_1F.inc | 4 +- .../maps/Route119_WeatherInstitute_2F.inc | 6 +- data/specials.inc | 2 +- include/field_camera.h | 9 + include/field_control_avatar.h | 41 + include/field_ground_effect.h | 2 + include/field_map_obj.h | 3 + include/field_player_avatar.h | 3 +- include/fieldmap.h | 1 + include/global.fieldmap.h | 6 +- include/global.h | 12 + include/overworld.h | 152 +- ld_script.txt | 1 - src/battle_setup.c | 20 +- src/battle_transition.c | 2 +- src/berry_blender.c | 6 +- src/clock.c | 2 +- src/daycare.c | 4 +- src/decoration.c | 4 +- src/egg_hatch.c | 6 +- src/field_map_obj.c | 2 +- src/hof_pc.c | 2 +- src/item_use.c | 4 +- src/lilycove_lady.c | 2 +- src/load_save.c | 4 +- src/naming_screen.c | 8 +- src/overworld.c | 2277 ++++++++- src/pokeblock.c | 4 +- src/region_map.c | 2 +- src/reset_save_heap.c | 2 +- src/safari_zone.c | 12 +- src/scrcmd.c | 2 +- src/secret_base.c | 6 +- src/tv.c | 4 +- src/walda_phrase.c | 4 +- sym_common.txt | 2 +- 71 files changed, 2501 insertions(+), 4689 deletions(-) delete mode 100644 asm/overworld.s create mode 100644 include/field_control_avatar.h diff --git a/asm/battle_frontier_1.s b/asm/battle_frontier_1.s index 43966b607..e3094b955 100644 --- a/asm/battle_frontier_1.s +++ b/asm/battle_frontier_1.s @@ -6481,7 +6481,7 @@ _0819218E: mov r0, r9 cmp r0, 0 bne _081921C4 - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music + ldr r0, =CB2_ReturnToFieldContinueScript bl SetMainCallback2 b _081921FC .pool @@ -9539,7 +9539,7 @@ _08193B84: ldr r0, [r4] bl Free str r6, [r4] - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music + ldr r0, =CB2_ReturnToFieldContinueScript bl SetMainCallback2 ldr r1, =gTasks lsls r0, r5, 2 @@ -11320,7 +11320,7 @@ _08194B24: ands r0, r1 cmp r0, 0 bne _08194B3C - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music + ldr r0, =CB2_ReturnToFieldContinueScript bl SetMainCallback2 adds r0, r4, 0 bl DestroyTask diff --git a/asm/battle_records.s b/asm/battle_records.s index b203f339b..1880e7b45 100644 --- a/asm/battle_records.s +++ b/asm/battle_records.s @@ -855,7 +855,7 @@ sub_813C664: @ 813C664 ands r0, r1 cmp r0, 0 bne _0813C694 - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music + ldr r0, =CB2_ReturnToFieldContinueScript bl SetMainCallback2 ldr r0, =gUnknown_0203AB78 ldr r0, [r0] diff --git a/asm/battle_tower.s b/asm/battle_tower.s index 13641fef0..eb89d4d79 100644 --- a/asm/battle_tower.s +++ b/asm/battle_tower.s @@ -3172,7 +3172,7 @@ _08163A3C: _08163A74: bl sub_816537C _08163A78: - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music + ldr r0, =CB2_ReturnToFieldContinueScript bl SetMainCallback2 add sp, 0x4 pop {r4-r6} diff --git a/asm/cable_car.s b/asm/cable_car.s index 6fd44dd9f..bfb96cb9b 100644 --- a/asm/cable_car.s +++ b/asm/cable_car.s @@ -777,7 +777,7 @@ _08150340: bl warp_in ldr r0, =gFieldCallback str r4, [r0] - ldr r0, =c2_load_new_map + ldr r0, =CB2_LoadMap bl SetMainCallback2 add sp, 0x8 pop {r3} diff --git a/asm/cable_club.s b/asm/cable_club.s index 885689e85..0bdda588e 100644 --- a/asm/cable_club.s +++ b/asm/cable_club.s @@ -736,7 +736,7 @@ _080B2984: .pool _080B2994: bl GetLinkPlayerCount_2 - ldr r4, =gUnknown_03005DB8 + ldr r4, =gFieldLinkPlayerCount strb r0, [r4] bl GetMultiplayerId ldr r1, =gUnknown_03005DB4 @@ -826,7 +826,7 @@ _080B2A4E: .pool _080B2A6C: bl GetLinkPlayerCount_2 - ldr r4, =gUnknown_03005DB8 + ldr r4, =gFieldLinkPlayerCount strb r0, [r4] bl GetMultiplayerId ldr r1, =gUnknown_03005DB4 @@ -2132,12 +2132,12 @@ _080B35E0: ldrb r0, [r0] cmp r0, 0 bne _080B35FE - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 b _080B35FE .pool _080B35F8: - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 _080B35FE: bl RunTasks @@ -2586,7 +2586,7 @@ sp02A_crash_sound: @ 80B39BC push {lr} ldr r0, =gSpecialVar_0x8006 ldrb r0, [r0] - ldr r1, =c2_exit_to_overworld_1_continue_scripts_restart_music + ldr r1, =CB2_ReturnToFieldContinueScript bl sub_80C4E74 pop {r0} bx r0 diff --git a/asm/contest.s b/asm/contest.s index 8ea0d2d94..327a80d75 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -5588,7 +5588,7 @@ sub_80DA830: @ 80DA830 bl FreeAllWindowBuffers bl sub_80D7A5C bl FreeMonSpritesGfx - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 _080DA860: pop {r0} diff --git a/asm/contest_link_80F57C4.s b/asm/contest_link_80F57C4.s index c07be821f..450a235d5 100644 --- a/asm/contest_link_80F57C4.s +++ b/asm/contest_link_80F57C4.s @@ -1825,7 +1825,7 @@ _080F6884: adds r0, r5, 0 bl DestroyTask bl FreeAllWindowBuffers - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music + ldr r0, =CB2_ReturnToFieldContinueScript bl SetMainCallback2 bl sub_80F7E64 _080F68A8: diff --git a/asm/field_control_avatar.s b/asm/field_control_avatar.s index 240437049..c1c96272f 100644 --- a/asm/field_control_avatar.s +++ b/asm/field_control_avatar.s @@ -5,8 +5,8 @@ .text - thumb_func_start sub_809BEDC -sub_809BEDC: @ 809BEDC + thumb_func_start FieldClearPlayerInput +FieldClearPlayerInput: @ 809BEDC push {r4,r5,lr} movs r1, 0x2 negs r1, r1 @@ -29,11 +29,11 @@ sub_809BEDC: @ 809BEDC pop {r4,r5} pop {r0} bx r0 - thumb_func_end sub_809BEDC + thumb_func_end FieldClearPlayerInput - thumb_func_start process_overworld_input -@ void process_overworld_input(overworld_input_data *input_data, char buttons_new, char buttons_held) -process_overworld_input: @ 809BF08 + thumb_func_start FieldGetPlayerInput +@ void FieldGetPlayerInput(overworld_input_data *input_data, char buttons_new, char buttons_held) +FieldGetPlayerInput: @ 809BF08 push {r4-r7,lr} mov r7, r9 mov r6, r8 @@ -176,7 +176,7 @@ _0809C006: pop {r4-r7} pop {r0} bx r0 - thumb_func_end process_overworld_input + thumb_func_end FieldGetPlayerInput thumb_func_start sub_809C014 @ int sub_809C014(overworld_input_data *input_data) diff --git a/asm/field_effect.s b/asm/field_effect.s index 6d35cca61..91cd0c972 100644 --- a/asm/field_effect.s +++ b/asm/field_effect.s @@ -1943,7 +1943,7 @@ _080B69D4: thumb_func_start sub_80B69DC sub_80B69DC: @ 80B69DC push {lr} - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 ldr r1, =gFieldCallback ldr r0, =mapldr_080842E8 @@ -2010,7 +2010,7 @@ _080B6A64: bne _080B6A8A bl Overworld_ResetStateAfterFly bl warp_in - ldr r0, =c2_load_new_map + ldr r0, =CB2_LoadMap bl SetMainCallback2 ldr r1, =gFieldCallback ldr r0, =mapldr_08084390 @@ -2764,7 +2764,7 @@ sub_80B7060: @ 80B7060 ldr r1, =gFieldCallback ldr r0, =sub_80B70B4 str r0, [r1] - ldr r0, =c2_load_new_map + ldr r0, =CB2_LoadMap bl SetMainCallback2 ldr r0, =sub_80B6E88 bl FindTaskIdByFunc @@ -3730,7 +3730,7 @@ sub_80B7814: @ 80B7814 ldr r1, =gFieldCallback ldr r0, =mapldr_080851BC str r0, [r1] - ldr r0, =c2_load_new_map + ldr r0, =CB2_LoadMap bl SetMainCallback2 ldr r0, =sub_80B75F0 bl FindTaskIdByFunc @@ -4205,7 +4205,7 @@ sub_80B7BF4: @ 80B7BF4 ldr r1, =gFieldCallback ldr r0, =sub_80B6B68 str r0, [r1] - ldr r0, =c2_load_new_map + ldr r0, =CB2_LoadMap bl SetMainCallback2 ldr r0, =sub_80B7A8C bl FindTaskIdByFunc @@ -4402,7 +4402,7 @@ _080B7D86: ldr r1, =gFieldCallback ldr r0, =mapldr_080859D4 str r0, [r1] - ldr r0, =c2_load_new_map + ldr r0, =CB2_LoadMap bl SetMainCallback2 ldr r0, =sub_80B7CE4 bl FindTaskIdByFunc @@ -4883,7 +4883,7 @@ _080B81B8: bne _080B81E6 bl Overworld_SetWarpDestToLastHealLoc bl warp_in - ldr r0, =c2_load_new_map + ldr r0, =CB2_LoadMap bl SetMainCallback2 ldr r1, =gFieldCallback ldr r0, =mapldr_08085D88 diff --git a/asm/field_screen.s b/asm/field_screen.s index 0caa07a1b..2a539d111 100644 --- a/asm/field_screen.s +++ b/asm/field_screen.s @@ -9015,7 +9015,7 @@ _080AF9D0: cmp r0, 0 bne _080AF9E8 bl warp_in - ldr r0, =c2_load_new_map + ldr r0, =CB2_LoadMap bl SetMainCallback2 adds r0, r5, 0 bl DestroyTask @@ -9087,7 +9087,7 @@ _080AFA64: b _080AFA7C _080AFA6C: bl warp_in - ldr r0, =c2_load_new_map + ldr r0, =CB2_LoadMap bl SetMainCallback2 adds r0, r6, 0 bl DestroyTask @@ -10060,7 +10060,7 @@ _080B0222: b _080B023A _080B022A: bl warp_in - ldr r0, =c2_load_new_map + ldr r0, =CB2_LoadMap bl SetMainCallback2 adds r0, r5, 0 bl DestroyTask diff --git a/asm/field_specials.s b/asm/field_specials.s index c1624cd0a..29c6dc800 100644 --- a/asm/field_specials.s +++ b/asm/field_specials.s @@ -20,7 +20,7 @@ Special_ShowDiploma: @ 8137CB4 Special_ViewWallClock: @ 8137CC8 push {lr} ldr r0, =gMain - ldr r1, =c2_exit_to_overworld_2_switch + ldr r1, =CB2_ReturnToField str r1, [r0, 0x8] ldr r0, =Cb2_ViewWallClock bl SetMainCallback2 @@ -1906,7 +1906,7 @@ _08138C7E: thumb_func_start CB2_FieldShowRegionMap CB2_FieldShowRegionMap: @ 8138C84 push {lr} - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music + ldr r0, =CB2_ReturnToFieldContinueScript bl sub_817018C pop {r0} bx r0 @@ -7153,14 +7153,14 @@ sub_813B7D8: @ 813B7D8 ldrh r0, [r0] cmp r0, 0 bne _0813B7F8 - ldr r2, =c2_exit_to_overworld_1_continue_scripts_restart_music + ldr r2, =CB2_ReturnToFieldContinueScript movs r0, 0 movs r1, 0x1 bl DoRayquazaScene b _0813B802 .pool _0813B7F8: - ldr r2, =c2_exit_to_overworld_1_continue_scripts_restart_music + ldr r2, =CB2_ReturnToFieldContinueScript movs r0, 0x1 movs r1, 0 bl DoRayquazaScene diff --git a/asm/field_tasks.s b/asm/field_tasks.s index 79980ec46..09f5bbc9b 100644 --- a/asm/field_tasks.s +++ b/asm/field_tasks.s @@ -88,7 +88,7 @@ sub_809D908: @ 809D908 bl sub_809D8B8 adds r0, r4, 0x2 adds r1, r4, 0x4 - bl wild_encounter_related + bl UpdateAmbientCry _0809D930: pop {r4} pop {r0} @@ -96,8 +96,8 @@ _0809D930: .pool thumb_func_end sub_809D908 - thumb_func_start overworld_ensure_per_step_coros_running -overworld_ensure_per_step_coros_running: @ 809D93C + thumb_func_start SetUpFieldTasks +SetUpFieldTasks: @ 809D93C push {r4,r5,lr} ldr r5, =task_per_step_callback_manager adds r0, r5, 0 @@ -142,7 +142,7 @@ _0809D992: pop {r0} bx r0 .pool - thumb_func_end overworld_ensure_per_step_coros_running + thumb_func_end SetUpFieldTasks thumb_func_start ActivatePerStepCallback ActivatePerStepCallback: @ 809D9A8 diff --git a/asm/item_menu.s b/asm/item_menu.s index 010e83c49..654729a94 100644 --- a/asm/item_menu.s +++ b/asm/item_menu.s @@ -31,7 +31,7 @@ ResetBagScrollPositions: @ 81AAB70 @ void CB2_BagMenuFromStartMenu() CB2_BagMenuFromStartMenu: @ 81AAB9C push {lr} - ldr r2, =sub_8086194 + ldr r2, =CB2_ReturnToFieldWithOpenMenu movs r0, 0 movs r1, 0x5 bl GoToBagMenu @@ -5747,7 +5747,7 @@ bag_menu_leave_maybe_3: @ 81ADE6C ldr r0, =gFieldCallback ldr r1, =sub_819FA50 str r1, [r0] - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 pop {r0} bx r0 @@ -5782,7 +5782,7 @@ bag_menu_leave_maybe_2: @ 81ADEBC ldr r0, =gFieldCallback ldr r1, =sub_818DEF4 str r1, [r0] - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 pop {r0} bx r0 @@ -5813,7 +5813,7 @@ bag_menu_leave_maybe: @ 81ADF00 ldr r0, =gFieldCallback ldr r1, =sub_818E564 str r1, [r0] - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 pop {r0} bx r0 diff --git a/asm/learn_move.s b/asm/learn_move.s index f42514e68..56f6f84c7 100644 --- a/asm/learn_move.s +++ b/asm/learn_move.s @@ -713,7 +713,7 @@ _08160CD8: b _08160E8A _08160CE6: bl sub_8160EA0 - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 b _08160E8A .pool diff --git a/asm/main_menu.s b/asm/main_menu.s index 48d1411c5..8ea65fbec 100644 --- a/asm/main_menu.s +++ b/asm/main_menu.s @@ -1480,7 +1480,7 @@ _08030444: strh r1, [r0] ldr r0, =gPlttBufferFaded strh r1, [r0] - ldr r0, =sub_8086230 + ldr r0, =CB2_ContinueSavedGame b _0803048A .pool _08030460: diff --git a/asm/overworld.s b/asm/overworld.s deleted file mode 100644 index d74a2674b..000000000 --- a/asm/overworld.s +++ /dev/null @@ -1,4352 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - - - - thumb_func_start sub_80859BC -sub_80859BC: @ 80859BC - push {r4,lr} - sub sp, 0x4 - mov r4, sp - adds r4, 0x2 - mov r0, sp - adds r1, r4, 0 - bl PlayerGetDestCoords - ldr r0, =sIsAmbientCryWaterMon - ldrb r0, [r0] - cmp r0, 0x1 - bne _080859F0 - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - movs r2, 0 - ldrsh r1, [r4, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl MetatileBehavior_IsSurfableWaterOrUnderwater - lsls r0, 24 - cmp r0, 0 - beq _08085A2C -_080859F0: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x58 - bl __umodsi3 - adds r4, r0, 0 - adds r4, 0xD4 - lsls r4, 24 - lsrs r4, 24 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1E - bl __umodsi3 - adds r2, r0, 0 - adds r2, 0x32 - ldr r0, =sAmbientCrySpecies - ldrh r0, [r0] - lsls r4, 24 - asrs r4, 24 - lsls r2, 24 - asrs r2, 24 - adds r1, r4, 0 - movs r3, 0x1 - bl PlayCry2 -_08085A2C: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80859BC - - thumb_func_start wild_encounter_related -wild_encounter_related: @ 8085A3C - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - adds r6, r0, 0 - adds r7, r1, 0 - movs r1, 0 - ldrsh r0, [r6, r1] - cmp r0, 0x4 - bhi _08085B20 - lsls r0, 2 - ldr r1, =_08085A60 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08085A60: - .4byte _08085A74 - .4byte _08085A88 - .4byte _08085AA4 - .4byte _08085B0C - .4byte _08085B20 -_08085A74: - ldr r0, =sAmbientCrySpecies - ldrh r0, [r0] - cmp r0, 0 - bne _08085A84 - movs r0, 0x4 - b _08085B1E - .pool -_08085A84: - movs r0, 0x1 - b _08085B1E -_08085A88: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x96 - lsls r1, 4 - bl __umodsi3 - movs r1, 0x96 - lsls r1, 3 - adds r0, r1 - strh r0, [r7] - movs r0, 0x3 - b _08085B1E -_08085AA4: - movs r0, 0x1 - mov r9, r0 - bl CalculatePlayerPartyCount - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r5, 0 - b _08085ABC -_08085AB6: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 -_08085ABC: - cmp r5, r8 - bcs _08085AE4 - movs r0, 0x64 - muls r0, r5 - ldr r4, =gPlayerParty - adds r0, r4 - movs r1, 0x6 - bl GetMonData - cmp r0, 0 - bne _08085AB6 - adds r0, r4, 0 - bl GetMonAbility - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x44 - bne _08085AB6 - movs r1, 0x2 - mov r9, r1 -_08085AE4: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r4, 0x96 - lsls r4, 3 - adds r1, r4, 0 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - adds r0, r4 - mov r1, r9 - bl __divsi3 - strh r0, [r7] - movs r0, 0x3 - b _08085B1E - .pool -_08085B0C: - ldrh r0, [r7] - subs r0, 0x1 - strh r0, [r7] - lsls r0, 16 - cmp r0, 0 - bne _08085B20 - bl sub_80859BC - movs r0, 0x2 -_08085B1E: - strh r0, [r6] -_08085B20: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end wild_encounter_related - - thumb_func_start ChooseAmbientCrySpecies -ChooseAmbientCrySpecies: @ 8085B2C - push {lr} - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldrh r1, [r0, 0x4] - movs r0, 0xB4 - lsls r0, 6 - cmp r1, r0 - bne _08085B5C - bl IsMirageIslandPresent - lsls r0, 24 - cmp r0, 0 - bne _08085B5C - ldr r1, =sIsAmbientCryWaterMon - movs r0, 0x1 - strb r0, [r1] - bl GetLocalWaterMon - b _08085B62 - .pool -_08085B5C: - ldr r0, =sIsAmbientCryWaterMon - bl GetLocalWildMon -_08085B62: - ldr r1, =sAmbientCrySpecies - strh r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end ChooseAmbientCrySpecies - - thumb_func_start GetMapTypeByGroupAndId -@ int GetMapTypeByGroupAndId(int bank, int number) -GetMapTypeByGroupAndId: @ 8085B74 - push {lr} - lsls r0, 24 - asrs r0, 8 - lsrs r0, 16 - lsls r1, 24 - asrs r1, 8 - lsrs r1, 16 - bl Overworld_GetMapHeaderByGroupAndId - ldrb r0, [r0, 0x17] - pop {r1} - bx r1 - thumb_func_end GetMapTypeByGroupAndId - - thumb_func_start get_map_light_level_from_warp -@ int get_map_light_level_from_warp(warpdata *warp) -get_map_light_level_from_warp: @ 8085B8C - push {lr} - movs r2, 0 - ldrsb r2, [r0, r2] - movs r1, 0x1 - ldrsb r1, [r0, r1] - adds r0, r2, 0 - bl GetMapTypeByGroupAndId - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - thumb_func_end get_map_light_level_from_warp - - thumb_func_start Overworld_GetMapTypeOfSaveblockLocation -Overworld_GetMapTypeOfSaveblockLocation: @ 8085BA4 - push {lr} - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - adds r0, 0x4 - bl get_map_light_level_from_warp - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - .pool - thumb_func_end Overworld_GetMapTypeOfSaveblockLocation - - thumb_func_start get_map_light_from_warp0 -get_map_light_from_warp0: @ 8085BBC - push {lr} - ldr r0, =gUnknown_020322DC - bl get_map_light_level_from_warp - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - .pool - thumb_func_end get_map_light_from_warp0 - - thumb_func_start is_light_level_1_2_3_5_or_6 -is_light_level_1_2_3_5_or_6: @ 8085BD0 - push {lr} - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - beq _08085BEA - cmp r0, 0x1 - beq _08085BEA - cmp r0, 0x5 - beq _08085BEA - cmp r0, 0x2 - beq _08085BEA - cmp r0, 0x6 - bne _08085BEE -_08085BEA: - movs r0, 0x1 - b _08085BF0 -_08085BEE: - movs r0, 0 -_08085BF0: - pop {r1} - bx r1 - thumb_func_end is_light_level_1_2_3_5_or_6 - - thumb_func_start Overworld_MapTypeAllowsTeleportAndFly -Overworld_MapTypeAllowsTeleportAndFly: @ 8085BF4 - push {lr} - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - beq _08085C0A - cmp r0, 0x1 - beq _08085C0A - cmp r0, 0x6 - beq _08085C0A - cmp r0, 0x2 - bne _08085C0E -_08085C0A: - movs r0, 0x1 - b _08085C10 -_08085C0E: - movs r0, 0 -_08085C10: - pop {r1} - bx r1 - thumb_func_end Overworld_MapTypeAllowsTeleportAndFly - - thumb_func_start Overworld_MapTypeIsIndoors -Overworld_MapTypeIsIndoors: @ 8085C14 - push {lr} - lsls r0, 24 - movs r1, 0xF8 - lsls r1, 24 - adds r0, r1 - lsrs r0, 24 - cmp r0, 0x1 - bls _08085C28 - movs r0, 0 - b _08085C2A -_08085C28: - movs r0, 0x1 -_08085C2A: - pop {r1} - bx r1 - thumb_func_end Overworld_MapTypeIsIndoors - - thumb_func_start sav1_saved_warp2_map_get_name -sav1_saved_warp2_map_get_name: @ 8085C30 - push {lr} - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - movs r0, 0x14 - ldrsb r0, [r1, r0] - lsls r0, 16 - lsrs r0, 16 - ldrb r1, [r1, 0x15] - lsls r1, 24 - asrs r1, 24 - lsls r1, 16 - lsrs r1, 16 - bl Overworld_GetMapHeaderByGroupAndId - ldrb r0, [r0, 0x14] - pop {r1} - bx r1 - .pool - thumb_func_end sav1_saved_warp2_map_get_name - - thumb_func_start sav1_map_get_name -sav1_map_get_name: @ 8085C58 - push {lr} - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - movs r0, 0x4 - ldrsb r0, [r1, r0] - lsls r0, 16 - lsrs r0, 16 - ldrb r1, [r1, 0x5] - lsls r1, 24 - asrs r1, 24 - lsls r1, 16 - lsrs r1, 16 - bl Overworld_GetMapHeaderByGroupAndId - ldrb r0, [r0, 0x14] - pop {r1} - bx r1 - .pool - thumb_func_end sav1_map_get_name - - thumb_func_start GetCurrentMapBattleScene -GetCurrentMapBattleScene: @ 8085C80 - push {lr} - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - movs r0, 0x4 - ldrsb r0, [r1, r0] - lsls r0, 16 - lsrs r0, 16 - ldrb r1, [r1, 0x5] - lsls r1, 24 - asrs r1, 24 - lsls r1, 16 - lsrs r1, 16 - bl Overworld_GetMapHeaderByGroupAndId - ldrb r0, [r0, 0x1B] - pop {r1} - bx r1 - .pool - thumb_func_end GetCurrentMapBattleScene - - thumb_func_start overworld_bg_setup -@ void overworld_bg_setup() -overworld_bg_setup: @ 8085CA8 - push {r4-r6,lr} - mov r6, r8 - push {r6} - ldr r1, =gUnknown_08339DAC - movs r0, 0 - movs r2, 0x4 - bl InitBgsFromTemplates - movs r0, 0x1 - movs r1, 0x5 - movs r2, 0x1 - bl SetBgAttribute - movs r0, 0x2 - movs r1, 0x5 - movs r2, 0x1 - bl SetBgAttribute - movs r0, 0x3 - movs r1, 0x5 - movs r2, 0x1 - bl SetBgAttribute - ldr r0, =gUnknown_03005DA0 - mov r8, r0 - movs r4, 0x80 - lsls r4, 4 - adds r0, r4, 0 - bl AllocZeroed - mov r1, r8 - str r0, [r1] - ldr r6, =gUnknown_03005D9C - adds r0, r4, 0 - bl AllocZeroed - str r0, [r6] - ldr r5, =gUnknown_03005DA4 - adds r0, r4, 0 - bl AllocZeroed - str r0, [r5] - mov r0, r8 - ldr r1, [r0] - movs r0, 0x1 - bl SetBgTilemapBuffer - ldr r1, [r6] - movs r0, 0x2 - bl SetBgTilemapBuffer - ldr r1, [r5] - movs r0, 0x3 - bl SetBgTilemapBuffer - bl sub_81971D0 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end overworld_bg_setup - - thumb_func_start overworld_free_bg_tilemaps -overworld_free_bg_tilemaps: @ 8085D34 - push {r4,lr} - bl sub_81BE72C - bl sub_81971F4 - ldr r4, =gUnknown_03005DA4 - ldr r0, [r4] - cmp r0, 0 - beq _08085D4E - bl Free - movs r0, 0 - str r0, [r4] -_08085D4E: - ldr r4, =gUnknown_03005D9C - ldr r0, [r4] - cmp r0, 0 - beq _08085D5E - bl Free - movs r0, 0 - str r0, [r4] -_08085D5E: - ldr r4, =gUnknown_03005DA0 - ldr r0, [r4] - cmp r0, 0 - beq _08085D6E - bl Free - movs r0, 0 - str r0, [r4] -_08085D6E: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end overworld_free_bg_tilemaps - - thumb_func_start ResetSafariZoneFlag_ -ResetSafariZoneFlag_: @ 8085D80 - push {lr} - bl ResetSafariZoneFlag - pop {r0} - bx r0 - thumb_func_end ResetSafariZoneFlag_ - - thumb_func_start is_c1_link_related_active -@ _BOOL4 is_c1_link_related_active() -is_c1_link_related_active: @ 8085D8C - push {lr} - ldr r0, =gMain - ldr r1, [r0] - ldr r0, =c1_link_related - cmp r1, r0 - beq _08085DA4 - movs r0, 0 - b _08085DA6 - .pool -_08085DA4: - movs r0, 0x1 -_08085DA6: - pop {r1} - bx r1 - thumb_func_end is_c1_link_related_active - - thumb_func_start c1_overworld_normal -@ void c1_overworld_normal(int buttons_new, int buttons_held) -c1_overworld_normal: @ 8085DAC - push {r4-r6,lr} - sub sp, 0x4 - lsls r0, 16 - lsrs r0, 16 - adds r5, r0, 0 - lsls r1, 16 - lsrs r1, 16 - adds r4, r1, 0 - bl sub_808B578 - mov r6, sp - mov r0, sp - bl sub_809BEDC - mov r0, sp - adds r1, r5, 0 - adds r2, r4, 0 - bl process_overworld_input - bl ScriptContext2_IsEnabled - lsls r0, 24 - cmp r0, 0 - bne _08085DFA - mov r0, sp - bl sub_809C014 - cmp r0, 0x1 - bne _08085DF0 - bl ScriptContext2_Enable - bl HideMapNamePopUpWindow - b _08085DFA -_08085DF0: - ldrb r0, [r6, 0x2] - adds r1, r5, 0 - adds r2, r4, 0 - bl player_step -_08085DFA: - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end c1_overworld_normal - - thumb_func_start c1_overworld -c1_overworld: @ 8085E04 - push {lr} - ldr r2, =gMain - ldr r1, [r2, 0x4] - ldr r0, =c2_overworld - cmp r1, r0 - bne _08085E18 - ldrh r0, [r2, 0x2E] - ldrh r1, [r2, 0x2C] - bl c1_overworld_normal -_08085E18: - pop {r0} - bx r0 - .pool - thumb_func_end c1_overworld - - thumb_func_start OverworldBasic -@ void OverworldBasic() -OverworldBasic: @ 8085E24 - push {lr} - bl ScriptContext2_RunScript - bl RunTasks - bl AnimateSprites - bl CameraUpdate - bl UpdateCameraPanning - bl BuildOamBuffer - bl UpdatePaletteFade - bl sub_80A0A38 - bl do_scheduled_bg_tilemap_copies_to_vram - pop {r0} - bx r0 - thumb_func_end OverworldBasic - - thumb_func_start CB2_OverworldBasic -CB2_OverworldBasic: @ 8085E50 - push {lr} - bl OverworldBasic - pop {r0} - bx r0 - thumb_func_end CB2_OverworldBasic - - thumb_func_start c2_overworld -c2_overworld: @ 8085E5C - push {r4,lr} - ldr r0, =gPaletteFade - ldrb r0, [r0, 0x7] - lsrs r0, 7 - adds r4, r0, 0 - cmp r4, 0 - beq _08085E70 - movs r0, 0 - bl SetVBlankCallback -_08085E70: - bl OverworldBasic - cmp r4, 0 - beq _08085E7C - bl SetFieldVBlankCallback -_08085E7C: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end c2_overworld - - thumb_func_start set_callback1 -set_callback1: @ 8085E88 - ldr r1, =gMain - str r0, [r1] - bx lr - .pool - thumb_func_end set_callback1 - - thumb_func_start sub_8085E94 -sub_8085E94: @ 8085E94 - ldr r1, =gUnknown_03000E0C - str r0, [r1] - bx lr - .pool - thumb_func_end sub_8085E94 - - thumb_func_start map_post_load_hook_exec -map_post_load_hook_exec: @ 8085EA0 - push {r4,lr} - ldr r4, =gUnknown_03005DB0 - ldr r0, [r4] - cmp r0, 0 - beq _08085ECC - bl _call_via_r0 - lsls r0, 24 - cmp r0, 0 - bne _08085EBC - movs r0, 0 - b _08085EEC - .pool -_08085EBC: - movs r1, 0 - str r1, [r4] - ldr r0, =gFieldCallback - str r1, [r0] - b _08085EEA - .pool -_08085ECC: - ldr r0, =gFieldCallback - ldr r0, [r0] - cmp r0, 0 - beq _08085EE0 - bl _call_via_r0 - b _08085EE4 - .pool -_08085EE0: - bl mapldr_default -_08085EE4: - ldr r1, =gFieldCallback - movs r0, 0 - str r0, [r1] -_08085EEA: - movs r0, 0x1 -_08085EEC: - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end map_post_load_hook_exec - - thumb_func_start CB2_NewGame -CB2_NewGame: @ 8085EF8 - push {lr} - bl sub_808631C - bl StopMapMusic - bl ResetSafariZoneFlag_ - bl NewGameInitData - bl player_avatar_init_params_reset - bl PlayTimeCounter_Start - bl ScriptContext1_Init - bl ScriptContext2_Disable - ldr r1, =gFieldCallback - ldr r0, =ExecuteTruckSequence - str r0, [r1] - ldr r1, =gUnknown_03005DB0 - movs r0, 0 - str r0, [r1] - ldr r0, =gMain+0x438 - bl do_load_map_stuff_loop - bl SetFieldVBlankCallback - ldr r0, =c1_overworld - bl set_callback1 - ldr r0, =c2_overworld - bl SetMainCallback2 - pop {r0} - bx r0 - .pool - thumb_func_end CB2_NewGame - - thumb_func_start CB2_WhiteOut -CB2_WhiteOut: @ 8085F58 - push {lr} - sub sp, 0x4 - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x77 - bls _08085FB0 - bl sub_808631C - bl StopMapMusic - bl ResetSafariZoneFlag_ - bl DoWhiteOut - bl player_avatar_init_params_reset - bl ScriptContext1_Init - bl ScriptContext2_Disable - ldr r1, =gFieldCallback - ldr r0, =sub_80AF3C8 - str r0, [r1] - mov r1, sp - movs r0, 0 - strb r0, [r1] - mov r0, sp - bl do_load_map_stuff_loop - bl SetFieldVBlankCallback - ldr r0, =c1_overworld - bl set_callback1 - ldr r0, =c2_overworld - bl SetMainCallback2 -_08085FB0: - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end CB2_WhiteOut - - thumb_func_start c2_load_new_map -c2_load_new_map: @ 8085FCC - push {lr} - bl sub_808631C - bl ScriptContext1_Init - bl ScriptContext2_Disable - movs r0, 0 - bl set_callback1 - ldr r0, =c2_change_map - bl SetMainCallback2 - ldr r1, =gMain - ldr r0, =c2_load_new_map_2 - str r0, [r1, 0x8] - pop {r0} - bx r0 - .pool - thumb_func_end c2_load_new_map - - thumb_func_start c2_load_new_map_2 -c2_load_new_map_2: @ 8085FFC - push {lr} - ldr r0, =gMain+0x438 - bl do_load_map_stuff_loop - bl SetFieldVBlankCallback - ldr r0, =c1_overworld - bl set_callback1 - ldr r0, =c2_overworld - bl SetMainCallback2 - pop {r0} - bx r0 - .pool - thumb_func_end c2_load_new_map_2 - - thumb_func_start sub_8086024 -sub_8086024: @ 8086024 - push {r4,lr} - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r4, r0, r1 - ldrb r0, [r4] - cmp r0, 0 - bne _08086046 - bl sub_808631C - bl ScriptContext1_Init - bl ScriptContext2_Disable - movs r0, 0 - bl set_callback1 -_08086046: - adds r0, r4, 0 - movs r1, 0x1 - bl load_map_stuff - cmp r0, 0 - beq _08086062 - bl SetFieldVBlankCallback - ldr r0, =c1_overworld - bl set_callback1 - ldr r0, =c2_overworld - bl SetMainCallback2 -_08086062: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8086024 - - thumb_func_start sub_8086074 -sub_8086074: @ 8086074 - push {lr} - bl sub_808631C - ldr r0, =gFieldCallback - ldr r1, =sub_80AF314 - str r1, [r0] - ldr r0, =c2_80567AC - bl SetMainCallback2 - pop {r0} - bx r0 - .pool - thumb_func_end sub_8086074 - - thumb_func_start c2_80567AC -c2_80567AC: @ 8086098 - push {lr} - ldr r0, =gMain+0x438 - bl map_loading_iteration_3 - cmp r0, 0 - beq _080860B8 - bl SetFieldVBlankCallback - ldr r0, =c1_link_related - bl set_callback1 - bl sub_8086C2C - ldr r0, =c2_overworld - bl SetMainCallback2 -_080860B8: - pop {r0} - bx r0 - .pool - thumb_func_end c2_80567AC - - thumb_func_start c2_exit_to_overworld_2_switch -c2_exit_to_overworld_2_switch: @ 80860C8 - push {lr} - bl is_c1_link_related_active - cmp r0, 0x1 - bne _080860E0 - ldr r0, =c2_exit_to_overworld_2_link - bl SetMainCallback2 - b _080860EA - .pool -_080860E0: - bl sub_808631C - ldr r0, =c2_exit_to_overworld_2_local - bl SetMainCallback2 -_080860EA: - pop {r0} - bx r0 - .pool - thumb_func_end c2_exit_to_overworld_2_switch - - thumb_func_start c2_exit_to_overworld_2_local -c2_exit_to_overworld_2_local: @ 80860F4 - push {lr} - ldr r0, =gMain+0x438 - bl sub_8086638 - cmp r0, 0 - beq _0808610A - bl SetFieldVBlankCallback - ldr r0, =c2_overworld - bl SetMainCallback2 -_0808610A: - pop {r0} - bx r0 - .pool - thumb_func_end c2_exit_to_overworld_2_local - - thumb_func_start c2_exit_to_overworld_2_link -c2_exit_to_overworld_2_link: @ 8086118 - push {lr} - bl sub_8087598 - cmp r0, 0 - bne _08086132 - ldr r0, =gMain+0x438 - bl map_loading_iteration_2_link - cmp r0, 0 - beq _08086132 - ldr r0, =c2_overworld - bl SetMainCallback2 -_08086132: - pop {r0} - bx r0 - .pool - thumb_func_end c2_exit_to_overworld_2_link - - thumb_func_start c2_8056854 -c2_8056854: @ 8086140 - push {lr} - bl sub_808631C - bl StopMapMusic - ldr r0, =c1_link_related - bl set_callback1 - bl sub_8086C2C - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - beq _08086174 - ldr r1, =gFieldCallback - ldr r0, =sub_80AF314 - b _08086178 - .pool -_08086174: - ldr r1, =gFieldCallback - ldr r0, =sub_80AF214 -_08086178: - str r0, [r1] - bl ScriptContext1_Init - bl ScriptContext2_Disable - bl c2_exit_to_overworld_2_switch - pop {r0} - bx r0 - .pool - thumb_func_end c2_8056854 - - thumb_func_start sub_8086194 -sub_8086194: @ 8086194 - push {lr} - bl sub_808631C - ldr r1, =gUnknown_03005DB0 - ldr r0, =sub_80AF6A4 - str r0, [r1] - bl c2_exit_to_overworld_2_switch - pop {r0} - bx r0 - .pool - thumb_func_end sub_8086194 - - thumb_func_start sub_80861B0 -sub_80861B0: @ 80861B0 - push {lr} - bl sub_808631C - ldr r1, =gFieldCallback - ldr r0, =sub_80AF188 - str r0, [r1] - bl c2_exit_to_overworld_2_switch - pop {r0} - bx r0 - .pool - thumb_func_end sub_80861B0 - - thumb_func_start c2_exit_to_overworld_1_continue_scripts_restart_music -c2_exit_to_overworld_1_continue_scripts_restart_music: @ 80861CC - push {lr} - bl sub_808631C - ldr r1, =gFieldCallback - ldr r0, =sub_80AF168 - str r0, [r1] - bl c2_exit_to_overworld_2_switch - pop {r0} - bx r0 - .pool - thumb_func_end c2_exit_to_overworld_1_continue_scripts_restart_music - - thumb_func_start sub_80861E8 -sub_80861E8: @ 80861E8 - push {lr} - bl sub_808631C - ldr r1, =gFieldCallback - ldr r0, =sub_80AF3C8 - str r0, [r1] - bl c2_exit_to_overworld_2_switch - pop {r0} - bx r0 - .pool - thumb_func_end sub_80861E8 - - thumb_func_start sub_8086204 -sub_8086204: @ 8086204 - push {lr} - ldr r0, =gMapHeader - ldrb r1, [r0, 0x1A] - movs r0, 0xF8 - ands r0, r1 - cmp r0, 0x8 - bne _08086222 - bl sub_80E909C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08086222 - bl ShowMapNamePopup -_08086222: - bl sub_80AF3C8 - pop {r0} - bx r0 - .pool - thumb_func_end sub_8086204 - - thumb_func_start sub_8086230 -sub_8086230: @ 8086230 - push {r4,lr} - bl sub_808631C - bl StopMapMusic - bl ResetSafariZoneFlag_ - ldr r0, =gSaveFileStatus - ldrh r0, [r0] - cmp r0, 0xFF - bne _0808624A - bl sub_81A3908 -_0808624A: - bl LoadSaveblockMapHeader - bl set_warp2_warp3_to_neg_1 - bl GetCurrentTrainerHillMapId - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gMapHeader - ldrh r1, [r0, 0x12] - ldr r0, =0x00000169 - cmp r1, r0 - bne _08086278 - bl sub_81AA2F8 - b _0808628A - .pool -_08086278: - cmp r4, 0 - beq _08086286 - cmp r4, 0x6 - beq _08086286 - bl sub_81D5F48 - b _0808628A -_08086286: - bl LoadSaveblockMapObjScripts -_0808628A: - bl UnfreezeMapObjects - bl DoTimeBasedEvents - bl sub_8084788 - ldr r0, =gMapHeader - ldrh r1, [r0, 0x12] - ldr r0, =0x00000169 - cmp r1, r0 - bne _080862B0 - movs r0, 0x1 - bl battle_pyramid_map_load_related - b _080862BE - .pool -_080862B0: - cmp r4, 0 - beq _080862BA - bl trainer_hill_map_load_related - b _080862BE -_080862BA: - bl sub_8087D74 -_080862BE: - bl PlayTimeCounter_Start - bl ScriptContext1_Init - bl ScriptContext2_Disable - bl sub_8195E10 - bl sav2_x1_query_bit1 - cmp r0, 0x1 - bne _080862F4 - bl sav2_x9_clear_bit1 - bl warp1_set_to_sav1w - bl warp_in - bl sub_80EDB44 - ldr r0, =c2_load_new_map - bl SetMainCallback2 - b _08086308 - .pool -_080862F4: - bl sub_80EDB44 - ldr r0, =gFieldCallback - ldr r1, =sub_8086204 - str r1, [r0] - ldr r0, =c1_overworld - bl set_callback1 - bl c2_exit_to_overworld_2_switch -_08086308: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8086230 - - thumb_func_start sub_808631C -@ void sub_808631C() -sub_808631C: @ 808631C - push {r4,lr} - bl warp0_in_pokecenter - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0808632E - bl CloseLink -_0808632E: - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - beq _08086348 - movs r0, 0xC5 - bl EnableInterrupts - movs r0, 0x2 - bl DisableInterrupts - b _08086362 - .pool -_08086348: - ldr r4, =0x04000208 - ldrh r3, [r4] - strh r0, [r4] - ldr r2, =0x04000200 - ldrh r1, [r2] - ldr r0, =0x0000fffd - ands r0, r1 - strh r0, [r2] - ldrh r0, [r2] - movs r1, 0x1 - orrs r0, r1 - strh r0, [r2] - strh r3, [r4] -_08086362: - movs r0, 0 - bl SetVBlankCallback - movs r0, 0 - bl SetHBlankCallback - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_808631C - - thumb_func_start SetFieldVBlankCallback -@ void SetFieldVBlankCallback() -SetFieldVBlankCallback: @ 8086380 - push {lr} - ldr r0, =VBlankCB_Field - bl SetVBlankCallback - pop {r0} - bx r0 - .pool - thumb_func_end SetFieldVBlankCallback - - thumb_func_start VBlankCB_Field -VBlankCB_Field: @ 8086390 - push {lr} - bl LoadOam - bl ProcessSpriteCopyRequests - bl ScanlineEffect_InitHBlankDmaTransfer - bl FieldUpdateBgTilemapScroll - bl TransferPlttBuffer - bl TransferTilesetAnimsBuffer - pop {r0} - bx r0 - thumb_func_end VBlankCB_Field - - thumb_func_start sub_80863B0 -sub_80863B0: @ 80863B0 - push {lr} - bl sub_81A9E6C - lsls r0, 24 - cmp r0, 0 - beq _080863D4 - bl door_upload_tiles - ldr r2, =gUnknown_08339DBC - ldr r0, [r2] - ldr r1, [r2, 0x4] - ldr r2, [r2, 0x8] - bl ScanlineEffect_SetParams - b _080863F0 - .pool -_080863D4: - bl Overworld_GetFlashLevel - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - beq _080863F0 - bl sub_80B00E8 - ldr r2, =gUnknown_08339DBC - ldr r0, [r2] - ldr r1, [r2, 0x4] - ldr r2, [r2, 0x8] - bl ScanlineEffect_SetParams -_080863F0: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80863B0 - - thumb_func_start map_loading_iteration_3 -map_loading_iteration_3: @ 80863F8 - push {r4,lr} - adds r4, r0, 0 - ldrb r0, [r4] - cmp r0, 0xD - bls _08086404 - b _08086512 -_08086404: - lsls r0, 2 - ldr r1, =_08086414 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08086414: - .4byte _0808644C - .4byte _08086462 - .4byte _0808646A - .4byte _08086472 - .4byte _08086484 - .4byte _08086492 - .4byte _08086498 - .4byte _080864A8 - .4byte _080864B8 - .4byte _080864D4 - .4byte _080864DA - .4byte _080864E0 - .4byte _080864FC - .4byte _0808650E -_0808644C: - bl overworld_bg_setup - bl ScriptContext1_Init - bl ScriptContext2_Disable - bl MoveSaveBlocks_ResetHeap_ - bl sub_80867D8 - b _08086506 -_08086462: - movs r0, 0x1 - bl mli0_load_map - b _08086506 -_0808646A: - movs r0, 0x1 - bl sub_8086988 - b _08086506 -_08086472: - bl sub_8086AE4 - bl sub_80869DC - bl sub_8086B14 - bl sub_8086AAC - b _08086506 -_08086484: - bl sub_80863B0 - bl map_loading_lcd_reset - bl sub_8197200 - b _08086506 -_08086492: - bl move_tilemap_camera_to_upper_left_corner - b _08086506 -_08086498: - ldr r0, =gMapHeader - ldr r0, [r0] - bl copy_map_tileset1_to_vram - b _08086506 - .pool -_080864A8: - ldr r0, =gMapHeader - ldr r0, [r0] - bl copy_map_tileset2_to_vram - b _08086506 - .pool -_080864B8: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08086512 - ldr r0, =gMapHeader - ldr r0, [r0] - bl apply_map_tileset1_tileset2_palette - b _08086506 - .pool -_080864D4: - bl DrawWholeMapView - b _08086506 -_080864DA: - bl cur_mapheader_run_tileset_funcs_after_some_cpuset - b _08086506 -_080864E0: - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - beq _08086506 - bl sub_800E0E8 - movs r0, 0 - movs r1, 0 - bl CreateWirelessStatusIndicatorSprite - b _08086506 - .pool -_080864FC: - bl map_post_load_hook_exec - lsls r0, 24 - cmp r0, 0 - beq _08086512 -_08086506: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - b _08086512 -_0808650E: - movs r0, 0x1 - b _08086514 -_08086512: - movs r0, 0 -_08086514: - pop {r4} - pop {r1} - bx r1 - thumb_func_end map_loading_iteration_3 - - thumb_func_start load_map_stuff -@ int load_map_stuff(u8 *a1, int a2) -load_map_stuff: @ 808651C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4] - cmp r0, 0xD - bls _0808652A - b _0808662E -_0808652A: - lsls r0, 2 - ldr r1, =_08086538 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08086538: - .4byte _08086570 - .4byte _0808657C - .4byte _08086586 - .4byte _0808658E - .4byte _08086598 - .4byte _080865A6 - .4byte _080865AC - .4byte _080865BC - .4byte _080865CC - .4byte _080865E8 - .4byte _080865EE - .4byte _080865F4 - .4byte _08086618 - .4byte _0808662A -_08086570: - bl sub_808631C - adds r0, r5, 0 - bl mli0_load_map - b _08086622 -_0808657C: - bl MoveSaveBlocks_ResetHeap_ - bl sub_80867D8 - b _08086622 -_08086586: - adds r0, r5, 0 - bl sub_8086988 - b _08086622 -_0808658E: - bl mli4_mapscripts_and_other - bl sub_8086A80 - b _08086622 -_08086598: - bl sub_80863B0 - bl map_loading_lcd_reset - bl sub_8197200 - b _08086622 -_080865A6: - bl move_tilemap_camera_to_upper_left_corner - b _08086622 -_080865AC: - ldr r0, =gMapHeader - ldr r0, [r0] - bl copy_map_tileset1_to_vram - b _08086622 - .pool -_080865BC: - ldr r0, =gMapHeader - ldr r0, [r0] - bl copy_map_tileset2_to_vram - b _08086622 - .pool -_080865CC: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0808662E - ldr r0, =gMapHeader - ldr r0, [r0] - bl apply_map_tileset1_tileset2_palette - b _08086622 - .pool -_080865E8: - bl DrawWholeMapView - b _08086622 -_080865EE: - bl cur_mapheader_run_tileset_funcs_after_some_cpuset - b _08086622 -_080865F4: - ldr r0, =gMapHeader - ldrb r1, [r0, 0x1A] - movs r0, 0xF8 - ands r0, r1 - cmp r0, 0x8 - bne _08086622 - bl sub_80E909C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08086622 - bl ShowMapNamePopup - b _08086622 - .pool -_08086618: - bl map_post_load_hook_exec - lsls r0, 24 - cmp r0, 0 - beq _0808662E -_08086622: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - b _0808662E -_0808662A: - movs r0, 0x1 - b _08086630 -_0808662E: - movs r0, 0 -_08086630: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end load_map_stuff - - thumb_func_start sub_8086638 -sub_8086638: @ 8086638 - push {r4,lr} - adds r4, r0, 0 - ldrb r0, [r4] - cmp r0, 0x1 - beq _0808666E - cmp r0, 0x1 - bgt _0808664C - cmp r0, 0 - beq _08086656 - b _0808668E -_0808664C: - cmp r0, 0x2 - beq _08086678 - cmp r0, 0x3 - beq _0808668A - b _0808668E -_08086656: - bl MoveSaveBlocks_ResetHeap_ - bl sub_80867D8 - movs r0, 0 - bl sub_8086988 - bl sub_8086A68 - bl sub_8086A80 - b _08086682 -_0808666E: - bl sub_8086860 - bl sub_81D64C0 - b _08086682 -_08086678: - bl map_post_load_hook_exec - lsls r0, 24 - cmp r0, 0 - beq _0808668E -_08086682: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - b _0808668E -_0808668A: - movs r0, 0x1 - b _08086690 -_0808668E: - movs r0, 0 -_08086690: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8086638 - - thumb_func_start map_loading_iteration_2_link -map_loading_iteration_2_link: @ 8086698 - push {r4,lr} - adds r4, r0, 0 - ldrb r0, [r4] - cmp r0, 0xD - bls _080866A4 - b _080867A8 -_080866A4: - lsls r0, 2 - ldr r1, =_080866B4 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080866B4: - .4byte _080866EC - .4byte _080866FA - .4byte _08086702 - .4byte _08086710 - .4byte _0808671E - .4byte _08086724 - .4byte _08086734 - .4byte _08086744 - .4byte _08086760 - .4byte _08086766 - .4byte _08086792 - .4byte _0808676C - .4byte _08086788 - .4byte _0808679A -_080866EC: - bl sub_808631C - bl MoveSaveBlocks_ResetHeap_ - bl sub_80867D8 - b _08086792 -_080866FA: - movs r0, 0x1 - bl sub_8086988 - b _08086792 -_08086702: - bl sub_8086B9C - bl sub_8086A68 - bl sub_8086AC8 - b _08086792 -_08086710: - bl sub_80863B0 - bl map_loading_lcd_reset - bl sub_8197200 - b _08086792 -_0808671E: - bl move_tilemap_camera_to_upper_left_corner - b _08086792 -_08086724: - ldr r0, =gMapHeader - ldr r0, [r0] - bl copy_map_tileset1_to_vram - b _08086792 - .pool -_08086734: - ldr r0, =gMapHeader - ldr r0, [r0] - bl copy_map_tileset2_to_vram - b _08086792 - .pool -_08086744: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080867A8 - ldr r0, =gMapHeader - ldr r0, [r0] - bl apply_map_tileset1_tileset2_palette - b _08086792 - .pool -_08086760: - bl DrawWholeMapView - b _08086792 -_08086766: - bl cur_mapheader_run_tileset_funcs_after_some_cpuset - b _08086792 -_0808676C: - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - beq _08086792 - bl sub_800E0E8 - movs r0, 0 - movs r1, 0 - bl CreateWirelessStatusIndicatorSprite - b _08086792 - .pool -_08086788: - bl map_post_load_hook_exec - lsls r0, 24 - cmp r0, 0 - beq _080867A8 -_08086792: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - b _080867A8 -_0808679A: - bl SetFieldVBlankCallback - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - movs r0, 0x1 - b _080867AA -_080867A8: - movs r0, 0 -_080867AA: - pop {r4} - pop {r1} - bx r1 - thumb_func_end map_loading_iteration_2_link - - thumb_func_start do_load_map_stuff_loop -do_load_map_stuff_loop: @ 80867B0 - push {r4,lr} - adds r4, r0, 0 -_080867B4: - adds r0, r4, 0 - movs r1, 0 - bl load_map_stuff - cmp r0, 0 - beq _080867B4 - pop {r4} - pop {r0} - bx r0 - thumb_func_end do_load_map_stuff_loop - - thumb_func_start MoveSaveBlocks_ResetHeap_ -MoveSaveBlocks_ResetHeap_: @ 80867C8 - push {lr} - bl sub_81BE6AC - bl MoveSaveBlocks_ResetHeap - pop {r0} - bx r0 - thumb_func_end MoveSaveBlocks_ResetHeap_ - - thumb_func_start sub_80867D8 -sub_80867D8: @ 80867D8 - push {r4-r7,lr} - sub sp, 0x4 - movs r0, 0 - movs r1, 0 - bl SetGpuReg - bl ScanlineEffect_Stop - ldr r2, =0x05000002 - mov r1, sp - movs r0, 0 - strh r0, [r1] - ldr r1, =0x040000d4 - mov r0, sp - str r0, [r1] - str r2, [r1, 0x4] - ldr r0, =0x810001ff - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - movs r2, 0xC0 - lsls r2, 19 - movs r3, 0xC0 - lsls r3, 9 - mov r4, sp - movs r6, 0 - movs r5, 0x80 - lsls r5, 5 - ldr r7, =0x81000800 - movs r0, 0x81 - lsls r0, 24 - mov r12, r0 -_08086816: - strh r6, [r4] - mov r0, sp - str r0, [r1] - str r2, [r1, 0x4] - str r7, [r1, 0x8] - ldr r0, [r1, 0x8] - adds r2, r5 - subs r3, r5 - cmp r3, r5 - bhi _08086816 - strh r6, [r4] - mov r0, sp - str r0, [r1] - str r2, [r1, 0x4] - lsrs r0, r3, 1 - mov r2, r12 - orrs r0, r2 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - movs r0, 0 - movs r1, 0x80 - bl ResetOamRange - bl LoadOam - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80867D8 - - thumb_func_start sub_8086860 -sub_8086860: @ 8086860 - push {lr} - bl sub_80863B0 - bl map_loading_lcd_reset - bl sub_8197200 - bl mapdata_load_assets_to_gpu_and_full_redraw - pop {r0} - bx r0 - thumb_func_end sub_8086860 - - thumb_func_start map_loading_lcd_reset -map_loading_lcd_reset: @ 8086878 - push {r4,lr} - bl clear_scheduled_bg_copies_to_vram - bl reset_temp_tile_data_buffers - movs r0, 0x4C - movs r1, 0 - bl SetGpuReg - ldr r1, =0x00001f1f - movs r0, 0x48 - bl SetGpuReg - ldr r1, =0x00000101 - movs r0, 0x4A - bl SetGpuReg - movs r0, 0x40 - movs r1, 0xFF - bl SetGpuReg - movs r0, 0x44 - movs r1, 0xFF - bl SetGpuReg - ldr r4, =0x0000ffff - movs r0, 0x42 - adds r1, r4, 0 - bl SetGpuReg - movs r0, 0x46 - adds r1, r4, 0 - bl SetGpuReg - ldr r0, =gUnknown_82EC7C4 - ldrh r1, [r0, 0x2] - ldrh r2, [r0, 0x4] - orrs r1, r2 - ldrh r0, [r0, 0x6] - orrs r1, r0 - movs r2, 0x82 - lsls r2, 5 - adds r0, r2, 0 - orrs r1, r0 - movs r0, 0x50 - bl SetGpuReg - ldr r1, =0x0000070d - movs r0, 0x52 - bl SetGpuReg - bl overworld_bg_setup - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x2 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x3 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x2 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x2 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x3 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x3 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - ldr r1, =0x00007060 - movs r0, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x3 - bl ShowBg - bl sub_8098128 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end map_loading_lcd_reset - - thumb_func_start sub_8086988 -sub_8086988: @ 8086988 - push {r4,lr} - adds r4, r0, 0 - bl ResetTasks - bl ResetSpriteData - bl ResetPaletteFade - bl ScanlineEffect_Clear - bl dp13_810BB8C - bl ResetCameraUpdateInfo - bl InstallCameraPanAheadCallback - cmp r4, 0 - bne _080869B4 - movs r0, 0 - bl npc_paltag_set_load - b _080869BA -_080869B4: - movs r0, 0x1 - bl npc_paltag_set_load -_080869BA: - bl FieldEffectActiveListClear - bl sub_80AAFA4 - bl sub_80AEE84 - cmp r4, 0 - bne _080869CE - bl overworld_ensure_per_step_coros_running -_080869CE: - bl mapheader_run_script_with_tag_x5 - bl sub_81BE6B8 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8086988 - - thumb_func_start sub_80869DC -sub_80869DC: @ 80869DC - push {lr} - ldr r0, =gUnknown_03005DEC - movs r1, 0 - strh r1, [r0] - ldr r0, =gUnknown_03005DE8 - strh r1, [r0] - bl sub_808D438 - movs r0, 0 - movs r1, 0 - bl SpawnFieldObjectsInView - bl mapheader_run_first_tag4_script_list_match - pop {r0} - bx r0 - .pool - thumb_func_end sub_80869DC - - thumb_func_start mli4_mapscripts_and_other -mli4_mapscripts_and_other: @ 8086A04 - push {r4,r5,lr} - sub sp, 0x4 - ldr r0, =gUnknown_03005DEC - movs r1, 0 - strh r1, [r0] - ldr r0, =gUnknown_03005DE8 - strh r1, [r0] - bl sub_808D438 - mov r4, sp - adds r4, 0x2 - mov r0, sp - adds r1, r4, 0 - bl sav1_camera_get_focus_coords - bl sub_80852D4 - adds r5, r0, 0 - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - movs r2, 0 - ldrsh r1, [r4, r2] - ldrb r2, [r5, 0x1] - ldr r3, =gSaveBlock2Ptr - ldr r3, [r3] - ldrb r3, [r3, 0x8] - bl InitPlayerAvatar - ldrb r0, [r5] - bl SetPlayerAvatarTransitionFlags - bl player_avatar_init_params_reset - movs r0, 0 - movs r1, 0 - bl SpawnFieldObjectsInView - bl mapheader_run_first_tag4_script_list_match - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end mli4_mapscripts_and_other - - thumb_func_start sub_8086A68 -sub_8086A68: @ 8086A68 - push {lr} - movs r0, 0 - movs r1, 0 - bl sub_808E16C - bl sub_80FBED0 - bl mapheader_run_script_with_tag_x7 - pop {r0} - bx r0 - thumb_func_end sub_8086A68 - - thumb_func_start sub_8086A80 -sub_8086A80: @ 8086A80 - push {lr} - ldr r2, =gMapObjects - ldr r3, =gPlayerAvatar - ldrb r1, [r3, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0, 0x1] - movs r2, 0x80 - orrs r1, r2 - strb r1, [r0, 0x1] - ldrb r0, [r3, 0x4] - bl InitCameraUpdateCallback - pop {r0} - bx r0 - .pool - thumb_func_end sub_8086A80 - - thumb_func_start sub_8086AAC -sub_8086AAC: @ 8086AAC - push {lr} - ldr r0, =gUnknown_03005DB4 - ldrb r0, [r0] - bl sub_8087858 - lsls r0, 24 - lsrs r0, 24 - bl InitCameraUpdateCallback - pop {r0} - bx r0 - .pool - thumb_func_end sub_8086AAC - - thumb_func_start sub_8086AC8 -sub_8086AC8: @ 8086AC8 - push {lr} - ldr r0, =gUnknown_03005DB4 - ldrb r0, [r0] - bl sub_8087858 - lsls r0, 24 - lsrs r0, 24 - bl InitCameraUpdateCallback - pop {r0} - bx r0 - .pool - thumb_func_end sub_8086AC8 - - thumb_func_start sub_8086AE4 -sub_8086AE4: @ 8086AE4 - push {r4,lr} - sub sp, 0x4 - mov r4, sp - adds r4, 0x2 - mov r0, sp - adds r1, r4, 0 - bl sav1_camera_get_focus_coords - mov r2, sp - ldr r0, =gUnknown_03005DB4 - ldrb r1, [r0] - ldrh r0, [r2] - adds r0, r1 - lsls r0, 16 - lsrs r0, 16 - ldrh r1, [r4] - bl sub_8088B3C - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8086AE4 - - thumb_func_start sub_8086B14 -sub_8086B14: @ 8086B14 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - mov r4, sp - adds r4, 0x2 - mov r0, sp - adds r1, r4, 0 - bl sav1_camera_get_focus_coords - mov r3, sp - mov r2, sp - ldr r0, =gUnknown_03005DB4 - ldrb r1, [r0] - ldrh r0, [r2] - subs r0, r1 - strh r0, [r3] - movs r6, 0 - ldr r0, =gUnknown_03005DB8 - mov r8, r4 - ldrb r0, [r0] - cmp r6, r0 - bcs _08086B7E - ldr r7, =gLinkPlayers -_08086B44: - lsls r5, r6, 24 - lsrs r5, 24 - mov r0, sp - ldrh r1, [r0] - adds r1, r6, r1 - lsls r1, 16 - asrs r1, 16 - mov r0, r8 - movs r3, 0 - ldrsh r2, [r0, r3] - lsls r4, r6, 3 - subs r4, r6 - lsls r4, 2 - adds r4, r7 - ldrb r3, [r4, 0x13] - adds r0, r5, 0 - bl sub_80876F0 - ldrb r1, [r4] - adds r0, r5, 0 - bl sub_8087BCC - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 - ldr r0, =gUnknown_03005DB8 - ldrb r0, [r0] - cmp r6, r0 - bcc _08086B44 -_08086B7E: - bl sub_8086C40 - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8086B14 - - thumb_func_start sub_8086B9C -sub_8086B9C: @ 8086B9C - push {r4,r5,lr} - movs r4, 0 - ldr r0, =gUnknown_03005DB8 - ldrb r0, [r0] - cmp r4, r0 - bcs _08086BCA - ldr r5, =gLinkPlayers -_08086BAA: - lsls r0, r4, 24 - lsrs r0, 24 - lsls r1, r4, 3 - subs r1, r4 - lsls r1, 2 - adds r1, r5 - ldrb r1, [r1] - bl sub_8087BCC - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - ldr r0, =gUnknown_03005DB8 - ldrb r0, [r0] - cmp r4, r0 - bcc _08086BAA -_08086BCA: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8086B9C - - thumb_func_start c1_link_related -c1_link_related: @ 8086BD8 - push {r4,lr} - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - beq _08086BF2 - bl sub_800F0B8 - cmp r0, 0 - beq _08086BF2 - bl sub_8009F3C - cmp r0, 0 - bne _08086C14 -_08086BF2: - ldr r0, =gUnknown_03005DB4 - ldrb r4, [r0] - ldr r0, =gLinkPartnersHeldKeys - adds r1, r4, 0 - bl sub_8086F38 - ldr r0, =gUnknown_03000E14 - ldr r1, [r0] - adds r0, r4, 0 - bl _call_via_r1 - lsls r0, 16 - lsrs r0, 16 - bl sub_8086FA0 - bl sub_8086C40 -_08086C14: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end c1_link_related - - thumb_func_start sub_8086C2C -sub_8086C2C: @ 8086C2C - push {lr} - bl sub_8086C90 - ldr r0, =sub_80870B0 - bl c1_link_related_func_set - pop {r0} - bx r0 - .pool - thumb_func_end sub_8086C2C - - thumb_func_start sub_8086C40 -sub_8086C40: @ 8086C40 - push {lr} - ldr r0, =gLinkPartnersHeldKeys - bl sub_808709C - pop {r0} - bx r0 - .pool - thumb_func_end sub_8086C40 - - thumb_func_start c1_link_related_func_set -c1_link_related_func_set: @ 8086C50 - ldr r2, =gUnknown_03000E19 - movs r1, 0 - strb r1, [r2] - ldr r1, =gUnknown_03000E14 - str r0, [r1] - bx lr - .pool - thumb_func_end c1_link_related_func_set - - thumb_func_start sub_8086C64 -sub_8086C64: @ 8086C64 - push {lr} - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - beq _08086C82 - ldr r1, =gUnknown_03000E19 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3C - bls _08086C82 - bl sub_8010198 -_08086C82: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8086C64 - - thumb_func_start sub_8086C90 -sub_8086C90: @ 8086C90 - push {lr} - ldr r1, =gUnknown_03000E10 - movs r2, 0x80 - adds r0, r1, 0x3 -_08086C98: - strb r2, [r0] - subs r0, 0x1 - cmp r0, r1 - bge _08086C98 - pop {r0} - bx r0 - .pool - thumb_func_end sub_8086C90 - - thumb_func_start sub_8086CA8 -sub_8086CA8: @ 8086CA8 - push {r4,lr} - lsls r0, 16 - lsrs r3, r0, 16 - ldr r0, =gUnknown_03005DB8 - ldrb r2, [r0] - movs r1, 0 - cmp r1, r2 - bge _08086CD6 - ldr r4, =gUnknown_03000E10 -_08086CBA: - adds r0, r1, r4 - ldrb r0, [r0] - cmp r0, r3 - beq _08086CD0 - movs r0, 0 - b _08086CD8 - .pool -_08086CD0: - adds r1, 0x1 - cmp r1, r2 - blt _08086CBA -_08086CD6: - movs r0, 0x1 -_08086CD8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8086CA8 - - thumb_func_start sub_8086CE0 -sub_8086CE0: @ 8086CE0 - push {r4,lr} - lsls r0, 16 - lsrs r3, r0, 16 - ldr r0, =gUnknown_03005DB8 - ldrb r2, [r0] - movs r1, 0 - cmp r1, r2 - bge _08086D0E - ldr r4, =gUnknown_03000E10 -_08086CF2: - adds r0, r1, r4 - ldrb r0, [r0] - cmp r0, r3 - bne _08086D08 - movs r0, 0x1 - b _08086D10 - .pool -_08086D08: - adds r1, 0x1 - cmp r1, r2 - blt _08086CF2 -_08086D0E: - movs r0, 0 -_08086D10: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8086CE0 - - thumb_func_start sub_8086D18 -sub_8086D18: @ 8086D18 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - adds r7, r0, 0 - adds r6, r2, 0 - mov r9, r3 - lsls r1, 16 - lsrs r1, 16 - mov r8, r1 - ldr r0, =gUnknown_03000E10 - adds r5, r7, r0 - ldrb r0, [r5] - cmp r0, 0x80 - beq _08086D38 - b _08086EB2 -_08086D38: - adds r0, r6, 0 - bl sub_8087370 - adds r4, r0, 0 - cmp r4, 0 - beq _08086D70 - bl sub_8087480 - mov r1, r9 - strh r0, [r1] - movs r0, 0x81 - strb r0, [r5] - ldrb r0, [r6, 0x1] - cmp r0, 0 - bne _08086D58 - b _08086F26 -_08086D58: - ldr r0, =sub_80870F8 - bl c1_link_related_func_set - adds r0, r4, 0 - bl sub_8087530 - b _08086F26 - .pool -_08086D70: - movs r0, 0x83 - bl sub_8086CE0 - cmp r0, 0x1 - bne _08086D98 - movs r0, 0x81 - strb r0, [r5] - ldrb r0, [r6, 0x1] - cmp r0, 0 - bne _08086D86 - b _08086F26 -_08086D86: - ldr r0, =sub_80870F8 - bl c1_link_related_func_set - bl sub_8087584 - b _08086F26 - .pool -_08086D98: - mov r0, r8 - subs r0, 0x12 - cmp r0, 0xA - bls _08086DA2 - b _08086EB2 -_08086DA2: - lsls r0, 2 - ldr r1, =_08086DB0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08086DB0: - .4byte _08086E08 - .4byte _08086EB2 - .4byte _08086EB2 - .4byte _08086EB2 - .4byte _08086EB2 - .4byte _08086EB2 - .4byte _08086DDC - .4byte _08086E34 - .4byte _08086EB2 - .4byte _08086E64 - .4byte _08086E90 -_08086DDC: - adds r0, r6, 0 - bl sub_8087358 - cmp r0, 0 - beq _08086EB2 - ldr r0, =gUnknown_03000E10 - adds r0, r7, r0 - movs r1, 0x81 - strb r1, [r0] - ldrb r0, [r6, 0x1] - cmp r0, 0 - beq _08086EB2 - ldr r0, =sub_80870F8 - bl c1_link_related_func_set - bl sub_808751C - b _08086EB2 - .pool -_08086E08: - adds r0, r6, 0 - bl sub_8087388 - cmp r0, 0x1 - bne _08086EB2 - ldr r0, =gUnknown_03000E10 - adds r0, r7, r0 - movs r1, 0x81 - strb r1, [r0] - ldrb r0, [r6, 0x1] - cmp r0, 0 - beq _08086EB2 - ldr r0, =sub_80870F8 - bl c1_link_related_func_set - bl sub_808754C - b _08086EB2 - .pool -_08086E34: - adds r0, r6, 0 - bl sub_80873B4 - adds r4, r0, 0 - cmp r4, 0 - beq _08086EB2 - ldr r0, =gUnknown_03000E10 - adds r0, r7, r0 - movs r1, 0x81 - strb r1, [r0] - ldrb r0, [r6, 0x1] - cmp r0, 0 - beq _08086EB2 - ldr r0, =sub_80870F8 - bl c1_link_related_func_set - adds r0, r4, 0 - bl sub_8087568 - b _08086EB2 - .pool -_08086E64: - adds r0, r6, 0 - bl sub_8087340 - cmp r0, 0 - beq _08086EB2 - ldr r0, =gUnknown_03000E10 - adds r0, r7, r0 - movs r1, 0x81 - strb r1, [r0] - ldrb r0, [r6, 0x1] - cmp r0, 0 - beq _08086EB2 - ldr r0, =sub_808711C - bl c1_link_related_func_set - bl sub_8087510 - b _08086EB2 - .pool -_08086E90: - adds r0, r6, 0 - bl sub_8087340 - cmp r0, 0 - beq _08086EB2 - ldr r0, =gUnknown_03000E10 - adds r0, r7, r0 - movs r1, 0x81 - strb r1, [r0] - ldrb r0, [r6, 0x1] - cmp r0, 0 - beq _08086EB2 - ldr r0, =sub_8087140 - bl c1_link_related_func_set - bl sub_8087510 -_08086EB2: - mov r0, r8 - cmp r0, 0x17 - beq _08086ED8 - cmp r0, 0x17 - bgt _08086ECC - cmp r0, 0x16 - beq _08086EE8 - b _08086F26 - .pool -_08086ECC: - mov r1, r8 - cmp r1, 0x1A - beq _08086EF8 - cmp r1, 0x1D - beq _08086F18 - b _08086F26 -_08086ED8: - ldr r0, =gUnknown_03000E10 - adds r0, r7, r0 - movs r1, 0x83 - strb r1, [r0] - b _08086F26 - .pool -_08086EE8: - ldr r0, =gUnknown_03000E10 - adds r0, r7, r0 - movs r1, 0x82 - strb r1, [r0] - b _08086F26 - .pool -_08086EF8: - ldr r0, =gUnknown_03000E10 - adds r0, r7, r0 - movs r1, 0x80 - strb r1, [r0] - ldrb r0, [r6, 0x1] - cmp r0, 0 - beq _08086F26 - ldr r0, =sub_80870B0 - bl c1_link_related_func_set - b _08086F26 - .pool -_08086F18: - ldr r0, =gUnknown_03000E10 - adds r1, r7, r0 - ldrb r0, [r1] - cmp r0, 0x82 - bne _08086F26 - movs r0, 0x81 - strb r0, [r1] -_08086F26: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8086D18 - - thumb_func_start sub_8086F38 -sub_8086F38: @ 8086F38 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x14 - mov r8, r1 - movs r6, 0 - add r5, sp, 0x10 - mov r9, r5 - adds r7, r0, 0 -_08086F4C: - ldrb r4, [r7] - movs r0, 0 - strh r0, [r5] - adds r0, r6, 0 - mov r1, r8 - mov r2, sp - bl sub_80872D8 - adds r0, r6, 0 - adds r1, r4, 0 - mov r2, sp - adds r3, r5, 0 - bl sub_8086D18 - ldr r0, =gUnknown_03000E10 - adds r0, r6, r0 - ldrb r0, [r0] - cmp r0, 0x80 - bne _08086F7C - adds r0, r4, 0 - bl sub_8087068 - mov r1, r9 - strh r0, [r1] -_08086F7C: - lsls r0, r6, 24 - lsrs r0, 24 - ldrb r1, [r5] - bl sub_808796C - adds r7, 0x2 - adds r6, 0x1 - cmp r6, 0x3 - ble _08086F4C - add sp, 0x14 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8086F38 - - thumb_func_start sub_8086FA0 -sub_8086FA0: @ 8086FA0 - push {r4,lr} - lsls r0, 16 - lsrs r4, r0, 16 - ldr r1, =0xffef0000 - adds r0, r1 - lsrs r0, 16 - cmp r0, 0xC - bhi _08086FC0 - ldr r0, =gUnknown_03005DA8 - strh r4, [r0] - b _08086FC6 - .pool -_08086FC0: - ldr r1, =gUnknown_03005DA8 - movs r0, 0x11 - strh r0, [r1] -_08086FC6: - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - beq _08086FFC - bl sub_8087690 - cmp r0, 0x1 - bls _08086FFC - bl is_c1_link_related_active - cmp r0, 0x1 - bne _08086FFC - bl sub_8009F3C - cmp r0, 0x1 - bne _08086FFC - cmp r4, 0x11 - blt _08086FFC - cmp r4, 0x15 - ble _08086FF6 - cmp r4, 0x19 - bgt _08086FFC - cmp r4, 0x18 - blt _08086FFC -_08086FF6: - ldr r1, =gUnknown_03005DA8 - movs r0, 0 - strh r0, [r1] -_08086FFC: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8086FA0 - - thumb_func_start sub_808700C -sub_808700C: @ 808700C - push {lr} - ldr r2, =gMain - ldrh r1, [r2, 0x2C] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _08087024 - movs r0, 0x13 - b _08087064 - .pool -_08087024: - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _08087030 - movs r0, 0x12 - b _08087064 -_08087030: - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _0808703C - movs r0, 0x14 - b _08087064 -_0808703C: - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _08087048 - movs r0, 0x15 - b _08087064 -_08087048: - ldrh r1, [r2, 0x2E] - movs r0, 0x8 - ands r0, r1 - cmp r0, 0 - beq _08087056 - movs r0, 0x18 - b _08087064 -_08087056: - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _08087062 - movs r0, 0x11 - b _08087064 -_08087062: - movs r0, 0x19 -_08087064: - pop {r1} - bx r1 - thumb_func_end sub_808700C - - thumb_func_start sub_8087068 -sub_8087068: @ 8087068 - push {lr} - lsls r0, 16 - lsrs r0, 16 - adds r1, r0, 0 - cmp r0, 0x13 - beq _0808708E - cmp r0, 0x13 - bgt _0808707E - cmp r0, 0x12 - beq _08087092 - b _08087096 -_0808707E: - cmp r1, 0x14 - beq _0808708A - cmp r1, 0x15 - bne _08087096 - movs r0, 0x4 - b _08087098 -_0808708A: - movs r0, 0x3 - b _08087098 -_0808708E: - movs r0, 0x1 - b _08087098 -_08087092: - movs r0, 0x2 - b _08087098 -_08087096: - movs r0, 0 -_08087098: - pop {r1} - bx r1 - thumb_func_end sub_8087068 - - thumb_func_start sub_808709C -sub_808709C: @ 808709C - push {lr} - movs r2, 0x11 - adds r1, r0, 0x6 -_080870A2: - strh r2, [r1] - subs r1, 0x2 - cmp r1, r0 - bge _080870A2 - pop {r0} - bx r0 - thumb_func_end sub_808709C - - thumb_func_start sub_80870B0 -sub_80870B0: @ 80870B0 - push {r4,lr} - adds r4, r0, 0 - bl ScriptContext2_IsEnabled - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080870C4 - movs r0, 0x11 - b _080870E6 -_080870C4: - bl sub_800B4DC - cmp r0, 0x4 - bls _080870D0 - movs r0, 0x1B - b _080870E6 -_080870D0: - bl sub_8087690 - cmp r0, 0x4 - bls _080870DC - movs r0, 0x1C - b _080870E6 -_080870DC: - adds r0, r4, 0 - bl sub_808700C - lsls r0, 16 - lsrs r0, 16 -_080870E6: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80870B0 - - thumb_func_start sub_80870EC -sub_80870EC: @ 80870EC - push {lr} - bl sub_8086C64 - movs r0, 0x11 - pop {r1} - bx r1 - thumb_func_end sub_80870EC - - thumb_func_start sub_80870F8 -sub_80870F8: @ 80870F8 - push {r4,lr} - bl ScriptContext2_IsEnabled - lsls r0, 24 - lsrs r0, 24 - movs r4, 0x11 - cmp r0, 0x1 - beq _08087110 - movs r4, 0x1A - ldr r0, =sub_80870EC - bl c1_link_related_func_set -_08087110: - adds r0, r4, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80870F8 - - thumb_func_start sub_808711C -sub_808711C: @ 808711C - push {r4,lr} - bl sub_800B4DC - movs r4, 0x11 - cmp r0, 0x2 - bhi _08087134 - movs r4, 0x1A - bl ScriptContext2_Disable - ldr r0, =sub_80870EC - bl c1_link_related_func_set -_08087134: - adds r0, r4, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_808711C - - thumb_func_start sub_8087140 -sub_8087140: @ 8087140 - push {r4,lr} - bl sub_8087690 - movs r4, 0x11 - cmp r0, 0x2 - bhi _08087158 - movs r4, 0x1A - bl ScriptContext2_Disable - ldr r0, =sub_80870EC - bl c1_link_related_func_set -_08087158: - adds r0, r4, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8087140 - - thumb_func_start sub_8087164 -sub_8087164: @ 8087164 - push {lr} - bl sub_8086C64 - movs r0, 0x11 - pop {r1} - bx r1 - thumb_func_end sub_8087164 - - thumb_func_start sub_8087170 -sub_8087170: @ 8087170 - push {lr} - ldr r1, =gUnknown_03000E10 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x82 - bne _080871A0 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _080871A4 - ldr r0, =sub_8087164 - bl c1_link_related_func_set - movs r0, 0x1D - b _080871A6 - .pool -_080871A0: - bl sub_8086C64 -_080871A4: - movs r0, 0x11 -_080871A6: - pop {r1} - bx r1 - thumb_func_end sub_8087170 - - thumb_func_start sub_80871AC -sub_80871AC: @ 80871AC - push {lr} - ldr r0, =sub_8087170 - bl c1_link_related_func_set - movs r0, 0x16 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80871AC - - thumb_func_start sub_80871C0 -sub_80871C0: @ 80871C0 - movs r0, 0x11 - bx lr - thumb_func_end sub_80871C0 - - thumb_func_start sub_80871C4 -sub_80871C4: @ 80871C4 - push {lr} - ldr r1, =gUnknown_03000E10 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x83 - beq _080871D4 - bl sub_8086C64 -_080871D4: - movs r0, 0x83 - bl sub_8086CA8 - cmp r0, 0x1 - bne _080871EA - ldr r0, =gUnknown_08277513 - bl ScriptContext1_SetupScript - ldr r0, =sub_80871C0 - bl c1_link_related_func_set -_080871EA: - movs r0, 0x11 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80871C4 - - thumb_func_start sub_80871FC -sub_80871FC: @ 80871FC - push {lr} - ldr r0, =sub_80871C4 - bl c1_link_related_func_set - movs r0, 0x17 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80871FC - - thumb_func_start sub_8087210 -sub_8087210: @ 8087210 - movs r0, 0x11 - bx lr - thumb_func_end sub_8087210 - - thumb_func_start sub_8087214 -sub_8087214: @ 8087214 - push {lr} - movs r0, 0x83 - bl sub_8086CE0 - cmp r0, 0x1 - beq _08087250 - ldr r0, =gUnknown_03000E14 - ldr r2, [r0] - ldr r1, =sub_8087170 - adds r3, r0, 0 - cmp r2, r1 - bne _0808723A - ldr r1, =gUnknown_03000E10 - ldr r0, =gUnknown_03005DB4 - ldrb r0, [r0] - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x82 - bne _08087272 -_0808723A: - ldr r1, [r3] - ldr r0, =sub_8087164 - cmp r1, r0 - bne _08087268 - ldr r1, =gUnknown_03000E10 - ldr r0, =gUnknown_03005DB4 - ldrb r0, [r0] - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x81 - bne _08087268 -_08087250: - movs r0, 0x2 - b _08087278 - .pool -_08087268: - movs r0, 0x82 - bl sub_8086CA8 - cmp r0, 0 - bne _08087276 -_08087272: - movs r0, 0 - b _08087278 -_08087276: - movs r0, 0x1 -_08087278: - pop {r1} - bx r1 - thumb_func_end sub_8087214 - - thumb_func_start sub_808727C -sub_808727C: @ 808727C - push {lr} - movs r0, 0x83 - bl sub_8086CE0 - pop {r1} - bx r1 - thumb_func_end sub_808727C - - thumb_func_start sub_8087288 -sub_8087288: @ 8087288 - push {lr} - ldr r0, =sub_80871AC - bl c1_link_related_func_set - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_8087288 - - thumb_func_start sub_808729C -sub_808729C: @ 808729C - push {lr} - ldr r0, =sub_80870F8 - bl c1_link_related_func_set - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_808729C - - thumb_func_start sub_80872B0 -sub_80872B0: @ 80872B0 - push {lr} - ldr r0, =sub_80871FC - bl c1_link_related_func_set - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80872B0 - - thumb_func_start sub_80872C4 -sub_80872C4: @ 80872C4 - push {lr} - ldr r0, =sub_8087210 - bl c1_link_related_func_set - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80872C4 - - thumb_func_start sub_80872D8 -sub_80872D8: @ 80872D8 - push {r4-r6,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r6, r2, 0 - strb r4, [r6] - movs r0, 0 - cmp r4, r1 - bne _080872EA - movs r0, 0x1 -_080872EA: - strb r0, [r6, 0x1] - ldr r1, =gLinkPlayerMapObjects - lsls r0, r4, 2 - adds r0, r1 - ldrb r0, [r0, 0x3] - strb r0, [r6, 0x2] - lsls r4, 24 - lsrs r4, 24 - adds r0, r4, 0 - bl sub_80878A0 - strb r0, [r6, 0x3] - mov r5, sp - adds r5, 0x2 - adds r0, r4, 0 - mov r1, sp - adds r2, r5, 0 - bl sub_8087878 - mov r0, sp - ldrh r0, [r0] - strh r0, [r6, 0x4] - ldrh r0, [r5] - strh r0, [r6, 0x6] - adds r0, r4, 0 - bl sub_80878C0 - strb r0, [r6, 0x8] - mov r0, sp - movs r1, 0 - ldrsh r0, [r0, r1] - movs r2, 0 - ldrsh r1, [r5, r2] - bl MapGridGetMetatileBehaviorAt - strh r0, [r6, 0xC] - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80872D8 - - thumb_func_start sub_8087340 -sub_8087340: @ 8087340 - push {lr} - ldrb r0, [r0, 0x2] - cmp r0, 0x2 - beq _0808734C - cmp r0, 0 - bne _08087350 -_0808734C: - movs r0, 0x1 - b _08087352 -_08087350: - movs r0, 0 -_08087352: - pop {r1} - bx r1 - thumb_func_end sub_8087340 - - thumb_func_start sub_8087358 -sub_8087358: @ 8087358 - push {lr} - ldrb r0, [r0, 0x2] - cmp r0, 0x2 - beq _08087364 - cmp r0, 0 - bne _08087368 -_08087364: - movs r0, 0x1 - b _0808736A -_08087368: - movs r0, 0 -_0808736A: - pop {r1} - bx r1 - thumb_func_end sub_8087358 - - thumb_func_start sub_8087370 -sub_8087370: @ 8087370 - push {lr} - adds r1, r0, 0 - ldrb r0, [r1, 0x2] - cmp r0, 0x2 - bne _08087382 - adds r0, r1, 0x4 - bl sub_809D0F4 - b _08087384 -_08087382: - movs r0, 0 -_08087384: - pop {r1} - bx r1 - thumb_func_end sub_8087370 - - thumb_func_start sub_8087388 -sub_8087388: @ 8087388 - push {r4,lr} - adds r4, r0, 0 - ldrb r0, [r4, 0x2] - cmp r0, 0x2 - beq _08087396 - cmp r0, 0 - bne _080873AC -_08087396: - ldrb r0, [r4, 0xC] - bl MetatileBehavior_IsSouthArrowWarp - lsls r0, 24 - cmp r0, 0 - beq _080873AC - ldrb r0, [r4, 0x3] - cmp r0, 0x1 - bne _080873AC - movs r0, 0x1 - b _080873AE -_080873AC: - movs r0, 0 -_080873AE: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8087388 - - thumb_func_start sub_80873B4 -sub_80873B4: @ 80873B4 - push {r4,lr} - sub sp, 0x8 - adds r4, r0, 0 - ldrb r0, [r4, 0x2] - cmp r0, 0 - beq _080873C8 - cmp r0, 0x2 - beq _080873C8 - movs r0, 0 - b _08087476 -_080873C8: - ldr r0, [r4, 0x4] - ldr r1, [r4, 0x8] - str r0, [sp] - str r1, [sp, 0x4] - ldr r3, =gUnknown_08339D64 - ldrb r0, [r4, 0x3] - lsls r0, 3 - adds r0, r3 - ldr r0, [r0] - mov r1, sp - ldrh r1, [r1] - adds r0, r1 - lsls r0, 16 - lsrs r0, 16 - ldr r1, =0xffff0000 - ldr r2, [sp] - ands r2, r1 - orrs r2, r0 - str r2, [sp] - asrs r1, r2, 16 - ldrb r0, [r4, 0x3] - lsls r0, 3 - adds r3, 0x4 - adds r0, r3 - ldr r0, [r0] - adds r0, r1 - lsls r0, 16 - ldr r1, =0x0000ffff - ands r1, r2 - orrs r1, r0 - str r1, [sp] - ldr r2, =0xffffff00 - ldr r0, [sp, 0x4] - ands r0, r2 - str r0, [sp, 0x4] - mov r0, sp - movs r2, 0 - ldrsh r0, [r0, r2] - asrs r1, 16 - bl sub_808790C - lsls r0, 24 - lsrs r1, r0, 24 - adds r2, r1, 0 - cmp r1, 0x4 - beq _0808746C - ldrb r0, [r4, 0x1] - cmp r0, 0 - beq _08087434 - ldr r0, =gUnknown_03000E10 - adds r0, r1, r0 - ldrb r0, [r0] - cmp r0, 0x80 - beq _08087450 -_08087434: - ldr r0, =gUnknown_0827749C - b _08087476 - .pool -_08087450: - adds r0, r2, 0 - bl sub_80B39D4 - cmp r0, 0 - bne _08087464 - ldr r0, =gUnknown_0827747E - b _08087476 - .pool -_08087464: - ldr r0, =gUnknown_0827748D - b _08087476 - .pool -_0808746C: - ldrb r1, [r4, 0xC] - ldrb r2, [r4, 0x3] - mov r0, sp - bl sub_809C2C8 -_08087476: - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80873B4 - - thumb_func_start sub_8087480 -sub_8087480: @ 8087480 - push {lr} - adds r1, r0, 0 - ldr r0, =gUnknown_08277388 - cmp r1, r0 - beq _080874C6 - ldr r0, =gUnknown_082773A3 - cmp r1, r0 - beq _08087508 - ldr r0, =gUnknown_082773BE - cmp r1, r0 - beq _080874C6 - ldr r0, =gUnknown_082773D9 - cmp r1, r0 - beq _08087508 - ldr r0, =gUnknown_0827741D - cmp r1, r0 - beq _080874C6 - ldr r0, =gUnknown_08277432 - cmp r1, r0 - beq _08087508 - ldr r0, =gUnknown_08277447 - cmp r1, r0 - beq _080874C6 - ldr r0, =gUnknown_0827745C - cmp r1, r0 - beq _08087508 - ldr r0, =gUnknown_08277374 - cmp r1, r0 - beq _080874C6 - ldr r0, =gUnknown_0827737E - cmp r1, r0 - beq _08087508 - ldr r0, =gUnknown_082773F5 - cmp r1, r0 - bne _080874F8 -_080874C6: - movs r0, 0xA - b _0808750A - .pool -_080874F8: - ldr r0, =gUnknown_082773FF - cmp r1, r0 - beq _08087508 - movs r0, 0 - b _0808750A - .pool -_08087508: - movs r0, 0x9 -_0808750A: - pop {r1} - bx r1 - thumb_func_end sub_8087480 - - thumb_func_start sub_8087510 -sub_8087510: @ 8087510 - push {lr} - bl ScriptContext2_Enable - pop {r0} - bx r0 - thumb_func_end sub_8087510 - - thumb_func_start sub_808751C -sub_808751C: @ 808751C - push {lr} - movs r0, 0x6 - bl PlaySE - bl sub_809FA9C - bl ScriptContext2_Enable - pop {r0} - bx r0 - thumb_func_end sub_808751C - - thumb_func_start sub_8087530 -sub_8087530: @ 8087530 - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x5 - bl PlaySE - adds r0, r4, 0 - bl ScriptContext1_SetupScript - bl ScriptContext2_Enable - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8087530 - - thumb_func_start sub_808754C -sub_808754C: @ 808754C - push {lr} - movs r0, 0x6 - bl PlaySE - ldr r0, =gUnknown_082774EF - bl ScriptContext1_SetupScript - bl ScriptContext2_Enable - pop {r0} - bx r0 - .pool - thumb_func_end sub_808754C - - thumb_func_start sub_8087568 -sub_8087568: @ 8087568 - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x5 - bl PlaySE - adds r0, r4, 0 - bl ScriptContext1_SetupScript - bl ScriptContext2_Enable - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8087568 - - thumb_func_start sub_8087584 -sub_8087584: @ 8087584 - push {lr} - ldr r0, =gUnknown_08277509 - bl ScriptContext1_SetupScript - bl ScriptContext2_Enable - pop {r0} - bx r0 - .pool - thumb_func_end sub_8087584 - - thumb_func_start sub_8087598 -sub_8087598: @ 8087598 - push {lr} - bl is_c1_link_related_active - cmp r0, 0 - bne _080875A6 - movs r0, 0 - b _080875C0 -_080875A6: - bl sub_800B4DC - cmp r0, 0x2 - bls _080875B8 - ldr r1, =gUnknown_03000E18 - movs r0, 0x1 - b _080875BC - .pool -_080875B8: - ldr r1, =gUnknown_03000E18 - movs r0, 0 -_080875BC: - strb r0, [r1] - ldrb r0, [r1] -_080875C0: - pop {r1} - bx r1 - .pool - thumb_func_end sub_8087598 - - thumb_func_start sub_80875C8 -sub_80875C8: @ 80875C8 - push {lr} - bl sub_800B4DC - cmp r0, 0x1 - bls _0808762C - bl is_c1_link_related_active - cmp r0, 0x1 - bne _0808762C - bl sub_8009F3C - cmp r0, 0x1 - bne _0808762C - ldr r0, =gUnknown_03000E14 - ldr r1, [r0] - ldr r0, =sub_808711C - cmp r1, r0 - beq _08087614 - ldr r0, =sub_80870F8 - cmp r1, r0 - bne _0808762C - ldr r0, =gUnknown_03000E18 - ldrb r2, [r0] - movs r1, 0 - strb r1, [r0] - cmp r2, 0x1 - beq _08087614 - ldr r2, =gPaletteFade - ldrb r1, [r2, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0808762C - ldrb r1, [r2, 0xA] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0808762C -_08087614: - movs r0, 0x1 - b _0808762E - .pool -_0808762C: - movs r0, 0 -_0808762E: - pop {r1} - bx r1 - thumb_func_end sub_80875C8 - - thumb_func_start sub_8087634 -sub_8087634: @ 8087634 - push {lr} - bl sub_8087690 - cmp r0, 0x1 - bls _08087658 - bl is_c1_link_related_active - cmp r0, 0x1 - bne _08087658 - bl sub_8009F3C - cmp r0, 0x1 - bne _08087658 - ldr r0, =gUnknown_03000E14 - ldr r1, [r0] - ldr r0, =sub_8087140 - cmp r1, r0 - beq _08087664 -_08087658: - movs r0, 0 - b _08087666 - .pool -_08087664: - movs r0, 0x1 -_08087666: - pop {r1} - bx r1 - thumb_func_end sub_8087634 - - thumb_func_start sub_808766C -sub_808766C: @ 808766C - push {lr} - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - bne _08087688 - bl sub_8009F3C - cmp r0, 0 - beq _08087688 - movs r0, 0x1 - b _0808768A - .pool -_08087688: - movs r0, 0 -_0808768A: - pop {r1} - bx r1 - thumb_func_end sub_808766C - - thumb_func_start sub_8087690 -sub_8087690: @ 8087690 - push {lr} - ldr r0, =gWirelessCommType - ldrb r0, [r0] - cmp r0, 0 - bne _080876B0 - ldr r0, =gLink - ldr r1, =0x00000339 - adds r0, r1 - ldrb r0, [r0] - b _080876B8 - .pool -_080876B0: - ldr r0, =gUnknown_03005000 - ldr r1, =0x00000c1a - adds r0, r1 - ldrb r0, [r0] -_080876B8: - pop {r1} - bx r1 - .pool - thumb_func_end sub_8087690 - - thumb_func_start sub_80876C4 -sub_80876C4: @ 80876C4 - movs r1, 0 - str r1, [r0] - bx lr - thumb_func_end sub_80876C4 - - thumb_func_start strange_npc_table_clear -strange_npc_table_clear: @ 80876CC - push {lr} - ldr r0, =gLinkPlayerMapObjects - movs r1, 0 - movs r2, 0x10 - bl memset - pop {r0} - bx r0 - .pool - thumb_func_end strange_npc_table_clear - - thumb_func_start sub_80876E0 -sub_80876E0: @ 80876E0 - push {lr} - movs r1, 0 - movs r2, 0x24 - bl memset - pop {r0} - bx r0 - thumb_func_end sub_80876E0 - - thumb_func_start sub_80876F0 -sub_80876F0: @ 80876F0 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - mov r9, r1 - mov r10, r2 - mov r8, r3 - lsls r0, 24 - lsrs r7, r0, 24 - mov r0, r9 - lsls r0, 16 - lsrs r0, 16 - mov r9, r0 - mov r1, r10 - lsls r1, 16 - lsrs r1, 16 - mov r10, r1 - mov r2, r8 - lsls r2, 24 - lsrs r2, 24 - mov r8, r2 - bl sub_808D4F4 - adds r6, r0, 0 - lsls r6, 24 - lsrs r6, 24 - lsls r4, r7, 2 - ldr r0, =gLinkPlayerMapObjects - adds r4, r0 - lsls r5, r6, 3 - adds r5, r6 - lsls r5, 2 - ldr r0, =gMapObjects - adds r5, r0 - adds r0, r4, 0 - bl sub_80876C4 - adds r0, r5, 0 - bl sub_80876E0 - movs r2, 0 - movs r1, 0x1 - movs r0, 0x1 - strb r0, [r4] - strb r7, [r4, 0x1] - strb r6, [r4, 0x2] - strb r2, [r4, 0x3] - ldrb r0, [r5] - orrs r0, r1 - mov r2, r8 - ands r2, r1 - lsls r2, 1 - movs r1, 0x3 - negs r1, r1 - ands r0, r1 - orrs r0, r2 - strb r0, [r5] - movs r0, 0x2 - strb r0, [r5, 0x19] - movs r0, 0x40 - strb r0, [r5, 0x4] - mov r0, r9 - lsls r0, 16 - asrs r0, 16 - mov r9, r0 - mov r1, r10 - lsls r1, 16 - asrs r1, 16 - mov r10, r1 - adds r0, r5, 0 - mov r1, r9 - mov r2, r10 - bl sub_808779C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80876F0 - - thumb_func_start sub_808779C -sub_808779C: @ 808779C - push {r4,lr} - adds r4, r0, 0 - adds r0, r1, 0 - adds r1, r2, 0 - lsls r0, 16 - lsrs r0, 16 - lsls r1, 16 - lsrs r1, 16 - strh r0, [r4, 0x10] - strh r1, [r4, 0x12] - strh r0, [r4, 0x14] - strh r1, [r4, 0x16] - lsls r0, 16 - asrs r0, 16 - lsls r1, 16 - asrs r1, 16 - adds r2, r4, 0 - adds r2, 0xC - adds r3, r4, 0 - adds r3, 0xE - bl sub_8093038 - ldrh r0, [r4, 0xC] - adds r0, 0x8 - strh r0, [r4, 0xC] - adds r0, r4, 0 - bl FieldObjectUpdateZCoord - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_808779C - - thumb_func_start sub_80877DC -sub_80877DC: @ 80877DC - push {lr} - lsls r0, 24 - lsls r1, 24 - lsrs r2, r1, 24 - ldr r1, =gLinkPlayerMapObjects - lsrs r0, 22 - adds r1, r0, r1 - ldrb r0, [r1] - cmp r0, 0 - beq _080877FE - ldrb r0, [r1, 0x2] - lsls r1, r0, 3 - adds r1, r0 - lsls r1, 2 - ldr r0, =gMapObjects - adds r1, r0 - strb r2, [r1, 0x19] -_080877FE: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80877DC - - thumb_func_start sub_808780C -sub_808780C: @ 808780C - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 22 - ldr r1, =gLinkPlayerMapObjects - adds r5, r0, r1 - ldrb r1, [r5, 0x2] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r4, r0, r1 - ldrb r0, [r4, 0x4] - cmp r0, 0x40 - beq _08087838 - adds r1, r0, 0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - bl DestroySprite -_08087838: - movs r0, 0 - strb r0, [r5] - ldrb r1, [r4] - subs r0, 0x2 - ands r0, r1 - strb r0, [r4] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_808780C - - thumb_func_start sub_8087858 -sub_8087858: @ 8087858 - lsls r0, 24 - ldr r1, =gLinkPlayerMapObjects - lsrs r0, 22 - adds r0, r1 - ldrb r1, [r0, 0x2] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r0, r1 - ldrb r0, [r0, 0x4] - bx lr - .pool - thumb_func_end sub_8087858 - - thumb_func_start sub_8087878 -sub_8087878: @ 8087878 - lsls r0, 24 - ldr r3, =gLinkPlayerMapObjects - lsrs r0, 22 - adds r0, r3 - ldrb r3, [r0, 0x2] - lsls r0, r3, 3 - adds r0, r3 - lsls r0, 2 - ldr r3, =gMapObjects - adds r0, r3 - ldrh r3, [r0, 0x10] - strh r3, [r1] - ldrh r0, [r0, 0x12] - strh r0, [r2] - bx lr - .pool - thumb_func_end sub_8087878 - - thumb_func_start sub_80878A0 -sub_80878A0: @ 80878A0 - lsls r0, 24 - ldr r1, =gLinkPlayerMapObjects - lsrs r0, 22 - adds r0, r1 - ldrb r1, [r0, 0x2] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r0, r1 - ldrb r0, [r0, 0x19] - bx lr - .pool - thumb_func_end sub_80878A0 - - thumb_func_start sub_80878C0 -sub_80878C0: @ 80878C0 - lsls r0, 24 - ldr r1, =gLinkPlayerMapObjects - lsrs r0, 22 - adds r0, r1 - ldrb r1, [r0, 0x2] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r0, r1 - ldrb r0, [r0, 0xB] - lsls r0, 28 - lsrs r0, 28 - bx lr - .pool - thumb_func_end sub_80878C0 - - thumb_func_start sub_80878E4 -sub_80878E4: @ 80878E4 - lsls r0, 24 - ldr r1, =gLinkPlayerMapObjects - lsrs r0, 22 - adds r0, r1 - ldrb r1, [r0, 0x2] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r0, r1 - adds r0, 0x21 - movs r1, 0 - ldrsb r1, [r0, r1] - movs r0, 0x10 - subs r0, r1 - bx lr - .pool - thumb_func_end sub_80878E4 - - thumb_func_start sub_808790C -sub_808790C: @ 808790C - push {r4-r6,lr} - movs r2, 0 - ldr r5, =gLinkPlayerMapObjects - lsls r0, 16 - asrs r4, r0, 16 - lsls r1, 16 - asrs r3, r1, 16 -_0808791A: - lsls r0, r2, 2 - adds r1, r0, r5 - ldrb r0, [r1] - cmp r0, 0 - beq _08087958 - ldrb r0, [r1, 0x3] - cmp r0, 0 - beq _0808792E - cmp r0, 0x2 - bne _08087958 -_0808792E: - ldrb r1, [r1, 0x2] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r1, r0, r1 - movs r6, 0x10 - ldrsh r0, [r1, r6] - cmp r0, r4 - bne _08087958 - movs r6, 0x12 - ldrsh r0, [r1, r6] - cmp r0, r3 - bne _08087958 - adds r0, r2, 0 - b _08087964 - .pool -_08087958: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x3 - bls _0808791A - movs r0, 0x4 -_08087964: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_808790C - - thumb_func_start sub_808796C -sub_808796C: @ 808796C - push {r4-r6,lr} - lsls r0, 24 - lsls r1, 24 - lsrs r3, r1, 24 - adds r2, r3, 0 - lsrs r0, 22 - ldr r1, =gLinkPlayerMapObjects - adds r5, r0, r1 - ldrb r1, [r5, 0x2] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r6, r0, r1 - ldrb r0, [r5] - cmp r0, 0 - beq _080879C8 - cmp r3, 0xA - bls _080879A4 - ldrb r0, [r6] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r6] - b _080879C8 - .pool -_080879A4: - ldr r4, =gUnknown_08339E00 - ldr r1, =gUnknown_08339DC8 - ldrb r0, [r5, 0x3] - lsls r0, 2 - adds r0, r1 - ldr r3, [r0] - adds r0, r5, 0 - adds r1, r6, 0 - bl _call_via_r3 - lsls r0, 24 - lsrs r0, 22 - adds r0, r4 - ldr r2, [r0] - adds r0, r5, 0 - adds r1, r6, 0 - bl _call_via_r2 -_080879C8: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_808796C - - thumb_func_start sub_80879D8 -sub_80879D8: @ 80879D8 - push {r4,lr} - lsls r2, 24 - lsrs r2, 24 - ldr r4, =gUnknown_08339DD4 - lsls r3, r2, 2 - adds r3, r4 - ldr r3, [r3] - bl _call_via_r3 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80879D8 - - thumb_func_start sub_80879F8 -sub_80879F8: @ 80879F8 - movs r0, 0x1 - bx lr - thumb_func_end sub_80879F8 - - thumb_func_start sub_80879FC -sub_80879FC: @ 80879FC - push {r4,lr} - lsls r2, 24 - lsrs r2, 24 - ldr r4, =gUnknown_08339DD4 - lsls r3, r2, 2 - adds r3, r4 - ldr r3, [r3] - bl _call_via_r3 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80879FC - - thumb_func_start sub_8087A1C -sub_8087A1C: @ 8087A1C - movs r0, 0 - bx lr - thumb_func_end sub_8087A1C - - thumb_func_start sub_8087A20 -sub_8087A20: @ 8087A20 - push {r4-r6,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - lsls r0, r2, 24 - lsrs r0, 24 - ldrb r1, [r5, 0x19] - bl npc_something3 - strb r0, [r5, 0x19] - ldrb r1, [r5, 0x19] - mov r6, sp - adds r6, 0x2 - adds r0, r5, 0 - mov r2, sp - adds r3, r6, 0 - bl FieldObjectMoveDestCoords - ldrb r0, [r4, 0x2] - ldrb r1, [r5, 0x19] - mov r2, sp - movs r3, 0 - ldrsh r2, [r2, r3] - movs r4, 0 - ldrsh r3, [r6, r4] - bl npc_080587EC - lsls r0, 24 - cmp r0, 0 - bne _08087A7E - adds r1, r5, 0 - adds r1, 0x21 - movs r0, 0x10 - strb r0, [r1] - mov r0, sp - movs r2, 0 - ldrsh r1, [r0, r2] - movs r3, 0 - ldrsh r2, [r6, r3] - adds r0, r5, 0 - bl npc_coords_shift - adds r0, r5, 0 - bl FieldObjectUpdateZCoord - movs r0, 0x1 - b _08087A80 -_08087A7E: - movs r0, 0 -_08087A80: - add sp, 0x4 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_8087A20 - - thumb_func_start sub_8087A88 -sub_8087A88: @ 8087A88 - push {r4,lr} - adds r4, r1, 0 - lsls r0, r2, 24 - lsrs r0, 24 - ldrb r1, [r4, 0x19] - bl npc_something3 - strb r0, [r4, 0x19] - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8087A88 - - thumb_func_start sub_8087AA0 -sub_8087AA0: @ 8087AA0 - movs r1, 0 - strb r1, [r0, 0x3] - bx lr - thumb_func_end sub_8087AA0 - - thumb_func_start sub_8087AA8 -sub_8087AA8: @ 8087AA8 - push {r4-r6,lr} - adds r6, r0, 0 - adds r4, r1, 0 - adds r5, r4, 0 - adds r5, 0x21 - ldrb r0, [r5] - subs r0, 0x1 - strb r0, [r5] - movs r0, 0x1 - strb r0, [r6, 0x3] - ldrb r0, [r4, 0x19] - adds r1, 0xC - adds r2, r4, 0 - adds r2, 0xE - bl MoveCoords - ldrb r0, [r5] - cmp r0, 0 - bne _08087AD8 - adds r0, r4, 0 - bl npc_coords_shift_still - movs r0, 0x2 - strb r0, [r6, 0x3] -_08087AD8: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8087AA8 - - thumb_func_start npc_something3 -npc_something3: @ 8087AE0 - push {lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r2, r1, 24 - subs r0, 0x1 - cmp r0, 0x9 - bhi _08087B38 - lsls r0, 2 - ldr r1, =_08087B00 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08087B00: - .4byte _08087B28 - .4byte _08087B2C - .4byte _08087B30 - .4byte _08087B34 - .4byte _08087B38 - .4byte _08087B38 - .4byte _08087B28 - .4byte _08087B2C - .4byte _08087B30 - .4byte _08087B34 -_08087B28: - movs r0, 0x2 - b _08087B3A -_08087B2C: - movs r0, 0x1 - b _08087B3A -_08087B30: - movs r0, 0x3 - b _08087B3A -_08087B34: - movs r0, 0x4 - b _08087B3A -_08087B38: - adds r0, r2, 0 -_08087B3A: - pop {r1} - bx r1 - thumb_func_end npc_something3 - - thumb_func_start npc_080587EC -npc_080587EC: @ 8087B40 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r2, 16 - lsrs r2, 16 - mov r12, r2 - lsls r3, 16 - movs r4, 0 - ldr r0, =gMapObjects - mov r9, r0 - lsrs r2, r3, 16 - mov r10, r2 - asrs r6, r3, 16 -_08087B64: - mov r7, r12 - lsls r3, r7, 16 - mov r0, r10 - lsls r5, r0, 16 - cmp r4, r8 - beq _08087BA8 - lsls r0, r4, 3 - adds r0, r4 - lsls r0, 2 - mov r2, r9 - adds r1, r0, r2 - movs r7, 0x10 - ldrsh r0, [r1, r7] - asrs r2, r3, 16 - cmp r0, r2 - bne _08087B8C - movs r7, 0x12 - ldrsh r0, [r1, r7] - cmp r0, r6 - beq _08087B9E -_08087B8C: - movs r7, 0x14 - ldrsh r0, [r1, r7] - cmp r0, r2 - bne _08087BA8 - movs r0, 0x16 - ldrsh r1, [r1, r0] - asrs r0, r5, 16 - cmp r1, r0 - bne _08087BA8 -_08087B9E: - movs r0, 0x1 - b _08087BBE - .pool -_08087BA8: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0xF - bls _08087B64 - asrs r0, r3, 16 - asrs r1, r5, 16 - bl MapGridIsImpassableAt - lsls r0, 24 - lsrs r0, 24 -_08087BBE: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end npc_080587EC - - thumb_func_start sub_8087BCC -sub_8087BCC: @ 8087BCC - push {r4,r5,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r5, r0, 24 - lsls r1, 24 - lsrs r3, r1, 24 - lsls r2, r5, 2 - ldr r0, =gLinkPlayerMapObjects - adds r2, r0 - ldrb r1, [r2, 0x2] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r4, r0, r1 - ldrb r0, [r2] - cmp r0, 0 - beq _08087C7A - subs r0, r3, 0x1 - cmp r0, 0x4 - bhi _08087C56 - lsls r0, 2 - ldr r1, =_08087C0C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08087C0C: - .4byte _08087C2C - .4byte _08087C2C - .4byte _08087C38 - .4byte _08087C20 - .4byte _08087C20 -_08087C20: - ldrb r0, [r4] - lsls r0, 30 - lsrs r0, 31 - bl sub_808BD6C - b _08087C44 -_08087C2C: - ldrb r0, [r4] - lsls r0, 30 - lsrs r0, 31 - bl sub_808BD7C - b _08087C44 -_08087C38: - ldrb r1, [r4] - lsls r1, 30 - lsrs r1, 31 - movs r0, 0 - bl GetRivalAvatarGraphicsIdByStateIdAndGender -_08087C44: - lsls r0, 24 - lsrs r0, 24 - ldr r1, =sub_8087C8C - movs r2, 0 - str r2, [sp] - movs r3, 0 - bl AddPseudoFieldObject - strb r0, [r4, 0x4] -_08087C56: - ldrb r1, [r4, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - adds r3, r0, 0 - adds r3, 0x3E - ldrb r1, [r3] - movs r2, 0x2 - orrs r1, r2 - strb r1, [r3] - strh r5, [r0, 0x2E] - ldrb r1, [r4] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r4] -_08087C7A: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8087BCC - - thumb_func_start sub_8087C8C -sub_8087C8C: @ 8087C8C - push {r4-r6,lr} - adds r5, r0, 0 - movs r0, 0x2E - ldrsh r4, [r5, r0] - lsls r4, 2 - ldr r0, =gLinkPlayerMapObjects - adds r4, r0 - ldrb r1, [r4, 0x2] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r6, r0, r1 - ldrh r0, [r6, 0xC] - strh r0, [r5, 0x20] - ldrh r0, [r6, 0xE] - strh r0, [r5, 0x22] - ldrb r0, [r6, 0xB] - lsrs r0, 4 - adds r1, r5, 0 - movs r2, 0x1 - bl SetObjectSubpriorityByZCoord - ldrb r0, [r6, 0xB] - lsrs r0, 4 - bl ZCoordToPriority - movs r1, 0x3 - ands r1, r0 - lsls r1, 2 - ldrb r2, [r5, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r5, 0x5] - ldrb r0, [r4, 0x3] - cmp r0, 0 - bne _08087CF8 - ldrb r0, [r6, 0x19] - bl FieldObjectDirectionToImageAnimId - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r5, 0 - bl StartSpriteAnim - b _08087D0A - .pool -_08087CF8: - ldrb r0, [r6, 0x19] - bl get_go_image_anim_num - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r5, 0 - bl StartSpriteAnimIfDifferent -_08087D0A: - adds r0, r5, 0 - movs r1, 0 - bl sub_80979D4 - ldrb r0, [r6] - lsls r0, 29 - cmp r0, 0 - bge _08087D3C - ldrh r0, [r5, 0x3C] - movs r1, 0x4 - ands r1, r0 - lsls r1, 16 - adds r3, r5, 0 - adds r3, 0x3E - lsrs r1, 18 - lsls r1, 2 - ldrb r2, [r3] - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3] - ldrh r0, [r5, 0x3C] - adds r0, 0x1 - strh r0, [r5, 0x3C] -_08087D3C: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8087C8C - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/party_menu.s b/asm/party_menu.s index 0827a5a12..b71804617 100644 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -10083,7 +10083,7 @@ _081B5614: .pool _081B5624: ldr r1, =gUnknown_0203CEC8 - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField _081B5628: str r0, [r1] adds r0, r6, 0 @@ -10189,7 +10189,7 @@ _081B56F8: b _081B572A _081B56FE: ldr r1, =gUnknown_0203CEC8 - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField str r0, [r1] adds r0, r4, 0 bl sub_81B12C0 @@ -10408,7 +10408,7 @@ sub_81B58A8: @ 81B58A8 str r0, [sp] ldr r0, =sub_81B1370 str r0, [sp, 0x4] - ldr r0, =sub_8086194 + ldr r0, =CB2_ReturnToFieldWithOpenMenu str r0, [sp, 0x8] movs r0, 0 movs r1, 0 @@ -14836,7 +14836,7 @@ CB2_PartyMenuFromStartMenu: @ 81B7F34 str r0, [sp] ldr r0, =sub_81B1370 str r0, [sp, 0x4] - ldr r0, =sub_8086194 + ldr r0, =CB2_ReturnToFieldWithOpenMenu str r0, [sp, 0x8] movs r0, 0 movs r1, 0 @@ -16021,7 +16021,7 @@ sub_81B892C: @ 81B892C str r0, [sp] ldr r0, =sub_81B1370 str r0, [sp, 0x4] - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music + ldr r0, =CB2_ReturnToFieldContinueScript str r0, [sp, 0x8] movs r0, 0 movs r1, 0 @@ -16042,7 +16042,7 @@ sub_81B8958: @ 81B8958 str r0, [sp] ldr r0, =sub_81B1370 str r0, [sp, 0x4] - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music + ldr r0, =CB2_ReturnToFieldContinueScript str r0, [sp, 0x8] movs r0, 0xB movs r1, 0 @@ -17283,7 +17283,7 @@ sub_81B9354: @ 81B9354 str r1, [sp] ldr r1, =sub_81B1370 str r1, [sp, 0x4] - ldr r1, =c2_exit_to_overworld_2_switch + ldr r1, =CB2_ReturnToField str r1, [sp, 0x8] movs r1, 0 movs r2, 0xB @@ -17311,7 +17311,7 @@ _081B93A6: ldr r0, =gUnknown_03005DB0 ldr r1, =hm_add_c3_without_phase_2 str r1, [r0] - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 pop {r4} pop {r0} @@ -17420,7 +17420,7 @@ _081B9486: ldr r1, =gUnknown_03005DB0 ldr r0, =hm_add_c3_without_phase_2 str r0, [r1] - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 pop {r0} bx r0 @@ -17556,7 +17556,7 @@ _081B95BA: ldr r0, =gUnknown_03005DB0 ldr r1, =hm_add_c3_without_phase_2 str r1, [r0] - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 pop {r4,r5} pop {r0} @@ -17660,7 +17660,7 @@ sub_81B968C: @ 81B968C subs r3, 0x1 lsls r3, 24 lsrs r3, 24 - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField str r0, [sp] movs r0, 0x3 bl sub_81BF8EC diff --git a/asm/player_pc.s b/asm/player_pc.s index 1ae5b4d14..8a329a2fe 100644 --- a/asm/player_pc.s +++ b/asm/player_pc.s @@ -586,7 +586,7 @@ sub_816B31C: @ 816B31C ldr r0, =gFieldCallback ldr r1, =mapldr_080EBC0C str r1, [r0] - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 pop {r0} bx r0 @@ -1279,7 +1279,7 @@ sub_816B900: @ 816B900 ldr r0, =gFieldCallback ldr r1, =pal_fill_for_maplights_or_black str r1, [r0] - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 pop {r0} bx r0 @@ -1538,7 +1538,7 @@ sub_816BB28: @ 816BB28 ldr r0, =gFieldCallback ldr r1, =sub_816BB48 str r1, [r0] - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 pop {r0} bx r0 diff --git a/asm/pokedex.s b/asm/pokedex.s index cb40f0eda..526188cca 100644 --- a/asm/pokedex.s +++ b/asm/pokedex.s @@ -1244,7 +1244,7 @@ _080BBE18: bl sub_80BC890 adds r0, r6, 0 bl DestroyTask - ldr r0, =sub_8086194 + ldr r0, =CB2_ReturnToFieldWithOpenMenu bl SetMainCallback2 ldr r0, =gMPlayInfo_BGM ldr r1, =0x0000ffff diff --git a/asm/pokemon_storage_system.s b/asm/pokemon_storage_system.s index 2ff444f56..a74538fb1 100644 --- a/asm/pokemon_storage_system.s +++ b/asm/pokemon_storage_system.s @@ -657,7 +657,7 @@ sub_80C7678: @ 80C7678 ldr r1, =gFieldCallback ldr r0, =mapldr_0808C6D8 str r0, [r1] - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 pop {r0} bx r0 diff --git a/asm/pokemon_summary_screen.s b/asm/pokemon_summary_screen.s index 6e7c3af57..14dc569fe 100644 --- a/asm/pokemon_summary_screen.s +++ b/asm/pokemon_summary_screen.s @@ -2024,7 +2024,7 @@ sub_81C4EEC: @ 81C4EEC thumb_func_start sub_81C4EFC sub_81C4EFC: @ 81C4EFC push {lr} - ldr r1, =sub_8086194 + ldr r1, =CB2_ReturnToFieldWithOpenMenu movs r0, 0 bl sub_81C4F98 pop {r0} @@ -2073,7 +2073,7 @@ sub_81C4F44: @ 81C4F44 ldr r0, =gUnknown_03005DB0 ldr r1, =hm_add_c3_without_phase_2 str r1, [r0] - ldr r1, =c2_exit_to_overworld_2_switch + ldr r1, =CB2_ReturnToField movs r0, 0x3 bl sub_81C4F98 adds r0, r4, 0 diff --git a/asm/pokenav.s b/asm/pokenav.s index d98605dde..99b99383c 100644 --- a/asm/pokenav.s +++ b/asm/pokenav.s @@ -14,7 +14,7 @@ CB2_PokeNav: @ 81C7250 str r0, [r4] cmp r0, 0 bne _081C7270 - ldr r0, =sub_8086194 + ldr r0, =CB2_ReturnToFieldWithOpenMenu bl SetMainCallback2 b _081C7292 .pool @@ -66,7 +66,7 @@ sub_81C72BC: @ 81C72BC str r0, [r4] cmp r0, 0 bne _081C72F0 - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music + ldr r0, =CB2_ReturnToFieldContinueScript bl SetMainCallback2 b _081C7320 .pool @@ -351,12 +351,12 @@ _081C752C: bl sub_81C7334 cmp r4, 0 beq _081C755C - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music + ldr r0, =CB2_ReturnToFieldContinueScript bl SetMainCallback2 b _081C7562 .pool _081C755C: - ldr r0, =sub_8086194 + ldr r0, =CB2_ReturnToFieldWithOpenMenu bl SetMainCallback2 _081C7562: pop {r4-r7} @@ -3757,7 +3757,7 @@ sub_81C8EF8: @ 81C8EF8 lsls r2, 2 add r2, r8 str r2, [r5, 0x44] - ldrh r3, [r2, 0x4] + ldrh r3, [r2( 0x4] lsls r1, r3, 22 lsrs r1, 22 adds r1, 0x2 diff --git a/asm/rom_8011DC0.s b/asm/rom_8011DC0.s index 80bc66f3f..b069ec58e 100644 --- a/asm/rom_8011DC0.s +++ b/asm/rom_8011DC0.s @@ -3116,7 +3116,7 @@ _08014070: movs r0, 0x6 strb r0, [r1, 0x1] ldr r1, =gMain - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField str r0, [r1, 0x8] ldr r0, =sub_807AE50 bl SetMainCallback2 @@ -3258,7 +3258,7 @@ _080141D4: eors r0, r1 lsls r0, 24 lsrs r0, 24 - ldr r1, =c2_exit_to_overworld_2_switch + ldr r1, =CB2_ReturnToField bl sub_80C4E74 _080141F2: bl RunTasks @@ -3399,7 +3399,7 @@ sub_8014304: @ 8014304 ldr r0, =0x00004087 bl VarSet bl GetLinkPlayerCount - ldr r1, =gUnknown_03005DB8 + ldr r1, =gFieldLinkPlayerCount strb r0, [r1] bl GetMultiplayerId ldr r1, =gUnknown_03005DB4 @@ -3757,7 +3757,7 @@ _08014714: bl GetCursorSelectionMonId lsls r0, 24 lsrs r0, 24 - ldr r1, =c2_load_new_map + ldr r1, =CB2_LoadMap bl sub_802A9A8 b _08014764 .pool @@ -3766,7 +3766,7 @@ _08014734: movs r1, 0x9 movs r2, 0x1 bl sub_8014290 - ldr r0, =c2_load_new_map + ldr r0, =CB2_LoadMap bl sub_8020C70 b _08014764 .pool @@ -3778,7 +3778,7 @@ _0801474C: bl GetCursorSelectionMonId lsls r0, 24 lsrs r0, 24 - ldr r1, =c2_load_new_map + ldr r1, =CB2_LoadMap bl sub_802493C _08014764: adds r0, r4, 0 @@ -6931,7 +6931,7 @@ _08016502: ldr r1, =gFieldCallback ldr r0, =sub_80AF128 str r0, [r1] - ldr r1, =c2_exit_to_overworld_2_switch + ldr r1, =CB2_ReturnToField movs r0, 0x8 bl sub_81B8904 b _08016878 @@ -7229,7 +7229,7 @@ _0801677E: ldr r1, =gFieldCallback ldr r0, =sub_80AF128 str r0, [r1] - ldr r1, =c2_exit_to_overworld_2_switch + ldr r1, =CB2_ReturnToField movs r0, 0x9 bl sub_81B8904 adds r0, r6, 0 @@ -14941,7 +14941,7 @@ _0801A58C: ldr r0, =gUnknown_03000DAC ldr r0, [r0] bl Free - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music + ldr r0, =CB2_ReturnToFieldContinueScript bl SetMainCallback2 pop {r4} pop {r0} @@ -16076,7 +16076,7 @@ _0801AF58: bl sub_801ABDC cmp r0, 0 beq _0801AFAE - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 b _0801AFAE .pool @@ -16102,7 +16102,7 @@ _0801AF98: bl sub_801ABDC cmp r0, 0 beq _0801AFAE - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 _0801AFAE: bl RunTasks @@ -23568,7 +23568,7 @@ _0801EBA8: bne _0801EBC2 bl sub_801F544 bl sub_801DE30 - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 _0801EBC2: add sp, 0x4 @@ -27694,7 +27694,7 @@ _08020C26: str r0, [r5] adds r0, r4, 0 bl SetMainCallback2 - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField cmp r4, r0 bne _08020C5A ldr r2, =gTextFlags @@ -27705,8 +27705,8 @@ _08020C26: movs r0, 0xC8 lsls r0, 1 bl PlayNewMapMusic - ldr r0, =c1_overworld - bl set_callback1 + ldr r0, =CB1_Overworld + bl SetMainCallback1 _08020C5A: movs r0, 0 _08020C5C: diff --git a/asm/rotating_gate.s b/asm/rotating_gate.s index da5e73034..9b57dc1b0 100644 --- a/asm/rotating_gate.s +++ b/asm/rotating_gate.s @@ -915,8 +915,8 @@ _080FBECA: bx r0 thumb_func_end RotatingGatePuzzleCameraUpdate - thumb_func_start sub_80FBED0 -sub_80FBED0: @ 80FBED0 + thumb_func_start RotatingGate_InitPuzzleAndGraphics +RotatingGate_InitPuzzleAndGraphics: @ 80FBED0 push {lr} bl GetCurrentMapRotatingGatePuzzleType cmp r0, 0 @@ -929,7 +929,7 @@ sub_80FBED0: @ 80FBED0 _080FBEEA: pop {r0} bx r0 - thumb_func_end sub_80FBED0 + thumb_func_end RotatingGate_InitPuzzleAndGraphics thumb_func_start CheckForRotatingGatePuzzleCollision CheckForRotatingGatePuzzleCollision: @ 80FBEF0 diff --git a/asm/roulette.s b/asm/roulette.s index ab873dd32..d3dd5fd9e 100644 --- a/asm/roulette.s +++ b/asm/roulette.s @@ -3276,7 +3276,7 @@ sub_8141E7C: @ 8141E7C ldr r1, =gFieldCallback ldr r0, =sub_80AF168 str r0, [r1] - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 adds r0, r5, 0 bl DestroyTask diff --git a/asm/script_pokemon_util_80F87D8.s b/asm/script_pokemon_util_80F87D8.s index 1869811c2..b241e3778 100644 --- a/asm/script_pokemon_util_80F87D8.s +++ b/asm/script_pokemon_util_80F87D8.s @@ -390,7 +390,7 @@ _080F8AB6: thumb_func_start sub_80F8ACC sub_80F8ACC: @ 80F8ACC push {lr} - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music + ldr r0, =CB2_ReturnToFieldContinueScript bl SetMainCallback2 pop {r0} bx r0 @@ -1559,7 +1559,7 @@ _080F9478: movs r0, 0x1 strh r0, [r1] _080F947E: - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music + ldr r0, =CB2_ReturnToFieldContinueScript bl SetMainCallback2 pop {r0} bx r0 @@ -1599,7 +1599,7 @@ _080F94D0: movs r0, 0x1 strh r0, [r1] _080F94D6: - ldr r0, =c2_exit_to_overworld_1_continue_scripts_restart_music + ldr r0, =CB2_ReturnToFieldContinueScript bl SetMainCallback2 pop {r0} bx r0 diff --git a/asm/shop.s b/asm/shop.s index 97dbd07c8..c42af8ef1 100644 --- a/asm/shop.s +++ b/asm/shop.s @@ -230,7 +230,7 @@ CB2_ExitSellMenu: @ 80DFC48 ldr r0, =gFieldCallback ldr r1, =MapPostLoadHook_ExitBuyOrSellMenu str r1, [r0] - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 pop {r0} bx r0 @@ -2706,7 +2706,7 @@ Task_ExitBuyMenu: @ 80E11B0 bne _080E11D6 bl RemoveMoneyLabelObject bl BuyMenuFreeMemory - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 adds r0, r4, 0 bl DestroyTask diff --git a/asm/start_menu.s b/asm/start_menu.s index 23ac3710a..03cb18341 100644 --- a/asm/start_menu.s +++ b/asm/start_menu.s @@ -591,7 +591,7 @@ StartMenu_PlayerName: @ 809FC8C cmp r0, 0 beq _0809FCC8 _0809FCB6: - ldr r0, =sub_8086194 + ldr r0, =CB2_ReturnToFieldWithOpenMenu bl sub_80C4DDC b _0809FCEA .pool @@ -601,12 +601,12 @@ _0809FCC8: lsls r0, 24 cmp r0, 0 beq _0809FCE4 - ldr r0, =sub_8086194 + ldr r0, =CB2_ReturnToFieldWithOpenMenu bl sub_80C51C4 b _0809FCEA .pool _0809FCE4: - ldr r0, =sub_8086194 + ldr r0, =CB2_ReturnToFieldWithOpenMenu bl sub_80C4DDC _0809FCEA: movs r0, 0x1 @@ -656,7 +656,7 @@ _0809FD38: ldr r0, =CB2_InitOptionMenu bl SetMainCallback2 ldr r1, =gMain - ldr r0, =sub_8086194 + ldr r0, =CB2_ReturnToFieldWithOpenMenu str r0, [r1, 0x8] movs r0, 0x1 _0809FD52: @@ -703,7 +703,7 @@ _0809FDA0: bl overworld_free_bg_tilemaps ldr r0, =gUnknown_03005DB4 ldrb r0, [r0] - ldr r1, =sub_8086194 + ldr r1, =CB2_ReturnToFieldWithOpenMenu bl sub_80C4E74 movs r0, 0x1 _0809FDB4: diff --git a/asm/trade.s b/asm/trade.s index f565cd7ba..7d3ec4a8a 100644 --- a/asm/trade.s +++ b/asm/trade.s @@ -10669,7 +10669,7 @@ _0807CF5C: bl Free str r4, [r7] _0807CFAA: - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 bl sub_807E784 _0807CFB4: @@ -12774,7 +12774,7 @@ _0807E3A8: bl Free str r4, [r7] _0807E3F6: - ldr r0, =c2_exit_to_overworld_2_switch + ldr r0, =CB2_ReturnToField bl SetMainCallback2 bl sub_807E784 _0807E400: diff --git a/data/event_scripts.s b/data/event_scripts.s index 7b9d6519c..6668f0d1f 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -8,7 +8,6 @@ .include "asm/macros.inc" .include "asm/macros/event.inc" .include "constants/constants.inc" - .section script_data, "aw", %progbits diff --git a/data/item_use.s b/data/item_use.s index d9bcc44f6..6c9affbc8 100644 --- a/data/item_use.s +++ b/data/item_use.s @@ -8,7 +8,7 @@ .align 2 gUnknown_085920D8:: @ 85920D8 .4byte sub_81B617C - .4byte c2_exit_to_overworld_2_switch + .4byte CB2_ReturnToField .4byte NULL .align 2 diff --git a/data/scripts/cable_club.inc b/data/scripts/cable_club.inc index b8aef7c3d..e5b330bf3 100644 --- a/data/scripts/cable_club.inc +++ b/data/scripts/cable_club.inc @@ -916,21 +916,21 @@ RecordCorner_EventScript_277471:: @ 8277471 releaseall end -gUnknown_0827747E:: @ 827747E +EventScript_TradeRoom_ReadTrainerCard1:: @ 827747E msgbox Text_278452, 4 fadescreen 1 special sp02A_crash_sound waitstate end -gUnknown_0827748D:: @ 827748D +EventScript_TradeRoom_ReadTrainerCard2:: @ 827748D msgbox Text_27847B, 4 fadescreen 1 special sp02A_crash_sound waitstate end -gUnknown_0827749C:: @ 827749C +EventScript_TradeRoom_TooBusyToNotice:: @ 827749C msgbox Text_27842E, 4 closemessage end @@ -983,7 +983,7 @@ gUnknown_08277509:: @ 8277509 special sub_80B371C end -gUnknown_08277513:: @ 8277513 +EventScript_277513:: @ 8277513 special sub_80B36EC special sub_80AF9F8 waitstate diff --git a/data/scripts/maps/FortreeCity_Gym.inc b/data/scripts/maps/FortreeCity_Gym.inc index fc069a8ee..01ce60717 100644 --- a/data/scripts/maps/FortreeCity_Gym.inc +++ b/data/scripts/maps/FortreeCity_Gym.inc @@ -12,7 +12,7 @@ FortreeCity_Gym_MapScript2_2165BA: @ 82165BA .2byte 0 FortreeCity_Gym_EventScript_2165C4:: @ 82165C4 - special sub_80FBED0 + special RotatingGate_InitPuzzleAndGraphics end FortreeCity_Gym_EventScript_2165C8:: @ 82165C8 diff --git a/data/scripts/maps/Route110_TrickHousePuzzle6.inc b/data/scripts/maps/Route110_TrickHousePuzzle6.inc index a043b2ec4..6b13cf8cb 100644 --- a/data/scripts/maps/Route110_TrickHousePuzzle6.inc +++ b/data/scripts/maps/Route110_TrickHousePuzzle6.inc @@ -12,7 +12,7 @@ Route110_TrickHousePuzzle6_MapScript2_26DDB6: @ 826DDB6 .2byte 0 Route110_TrickHousePuzzle6_EventScript_26DDC0:: @ 826DDC0 - special sub_80FBED0 + special RotatingGate_InitPuzzleAndGraphics end Route110_TrickHousePuzzle6_EventScript_26DDC4:: @ 826DDC4 diff --git a/data/scripts/maps/Route119.inc b/data/scripts/maps/Route119.inc index 72707186b..2f99f7c4e 100644 --- a/data/scripts/maps/Route119.inc +++ b/data/scripts/maps/Route119.inc @@ -18,7 +18,7 @@ Route119_EventScript_1F4439:: @ 81F4439 Route119_MapScript1_1F444D: @ 81F444D call Route119_EventScript_271ED7 call Route119_EventScript_271EFB - compare VAR_0x40B3, 1 + compare VAR_WEATHER_INSTITUTE_STATE, 1 call_if 1, Route119_EventScript_1F4466 special SetRoute119Weather end @@ -26,7 +26,7 @@ Route119_MapScript1_1F444D: @ 81F444D Route119_EventScript_1F4466:: @ 81F4466 setflag FLAG_0x37D clearflag FLAG_0x37C - setvar VAR_0x40B3, 2 + setvar VAR_WEATHER_INSTITUTE_STATE, 2 return Route119_EventScript_1F4472:: @ 81F4472 diff --git a/data/scripts/maps/Route119_WeatherInstitute_1F.inc b/data/scripts/maps/Route119_WeatherInstitute_1F.inc index 399692db3..b008f52c0 100644 --- a/data/scripts/maps/Route119_WeatherInstitute_1F.inc +++ b/data/scripts/maps/Route119_WeatherInstitute_1F.inc @@ -3,7 +3,7 @@ Route119_WeatherInstitute_1F_MapScripts:: @ 826FA86 .byte 0 Route119_WeatherInstitute_1F_MapScript1_26FA8C: @ 826FA8C - compare VAR_0x40B3, 0 + compare VAR_WEATHER_INSTITUTE_STATE, 0 call_if 1, Route119_WeatherInstitute_1F_EventScript_26FA98 end @@ -16,7 +16,7 @@ Route119_WeatherInstitute_1F_EventScript_26FAA4:: @ 826FAA4 lock faceplayer special GetPlayerBigGuyGirlString - compare VAR_0x40B3, 0 + compare VAR_WEATHER_INSTITUTE_STATE, 0 goto_eq Route119_WeatherInstitute_1F_EventScript_26FABE msgbox Route119_WeatherInstitute_1F_Text_26FCE5, 4 release diff --git a/data/scripts/maps/Route119_WeatherInstitute_2F.inc b/data/scripts/maps/Route119_WeatherInstitute_2F.inc index 38f79763d..c8f24f33d 100644 --- a/data/scripts/maps/Route119_WeatherInstitute_2F.inc +++ b/data/scripts/maps/Route119_WeatherInstitute_2F.inc @@ -3,9 +3,9 @@ Route119_WeatherInstitute_2F_MapScripts:: @ 826FF1E .byte 0 Route119_WeatherInstitute_2F_MapScript1_26FF24: @ 826FF24 - compare VAR_0x40B3, 0 + compare VAR_WEATHER_INSTITUTE_STATE, 0 call_if 1, Route119_WeatherInstitute_2F_EventScript_26FF44 - compare VAR_0x40B3, 1 + compare VAR_WEATHER_INSTITUTE_STATE, 1 call_if 1, Route119_WeatherInstitute_2F_EventScript_26FF50 checkflag FLAG_SYS_GAME_CLEAR call_if 1, Route119_WeatherInstitute_2F_EventScript_26FF5C @@ -62,7 +62,7 @@ Route119_WeatherInstitute_2F_EventScript_26FFC8:: @ 826FFC8 waitmovement 0 msgbox Route119_WeatherInstitute_2F_Text_2705DD, 4 closemessage - setvar VAR_0x40B3, 1 + setvar VAR_WEATHER_INSTITUTE_STATE, 1 clearflag FLAG_0x37D fadedefaultbgm fadescreen 1 diff --git a/data/specials.inc b/data/specials.inc index f9f7c97d7..62dd9717e 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -213,7 +213,7 @@ gSpecials:: @ 81DBA64 def_special sub_80F972C def_special sp0C8_whiteout_maybe def_special sub_80FBE90 - def_special sub_80FBED0 + def_special RotatingGate_InitPuzzleAndGraphics def_special SetSSTidalFlag def_special ResetSSTidalFlag def_special EnterSafariMode diff --git a/include/field_camera.h b/include/field_camera.h index 6daa9a8a2..6ff8ce006 100644 --- a/include/field_camera.h +++ b/include/field_camera.h @@ -26,5 +26,14 @@ void DrawWholeMapView(void); void CurrentMapDrawMetatileAt(int x, int y); void sub_8089C08(s16 *a0, s16 *a1); void DrawDoorMetatileAt(int x, int y, u16 *arr); +void move_tilemap_camera_to_upper_left_corner(void); +void sub_8057A58(void); +void ResetCameraUpdateInfo(void); +u32 InitCameraUpdateCallback(u8 a); +void CameraUpdate(void); +void SetCameraPanningCallback(void (*a)(void)); +void SetCameraPanning(s16 a, s16 b); +void InstallCameraPanAheadCallback(void); +void UpdateCameraPanning(void); #endif //GUARD_FIELD_CAMERA_H diff --git a/include/field_control_avatar.h b/include/field_control_avatar.h new file mode 100644 index 000000000..b915d1419 --- /dev/null +++ b/include/field_control_avatar.h @@ -0,0 +1,41 @@ +#ifndef GUARD_FIELDCONTROLAVATAR_H +#define GUARD_FIELDCONTROLAVATAR_H + +struct FieldInput +{ + u8 pressedAButton:1; + u8 input_field_0_1:1; + u8 pressedStartButton:1; + u8 pressedSelectButton:1; + u8 input_field_0_4:1; + u8 input_field_0_5:1; + u8 input_field_0_6:1; + u8 pressedBButton:1; + u8 input_field_1_0:1; + u8 input_field_1_1:1; + u8 input_field_1_2:1; + u8 input_field_1_3:1; + u8 input_field_1_4:1; + u8 input_field_1_5:1; + u8 input_field_1_6:1; + u8 input_field_1_7:1; + u8 dpadDirection; + u8 input_field_3; +}; + +void FieldClearPlayerInput(struct FieldInput *pStruct); +void FieldGetPlayerInput(struct FieldInput *pStruct, u16 keys, u16 heldKeys); +int sub_809C014(struct FieldInput *pStruct); +u8 *sub_80682A8(struct MapPosition *, u8, u8); +void overworld_poison_timer_set(void); +void prev_quest_postbuffer_cursor_backup_reset(void); +u8 *sub_8068E24(struct MapPosition *); +u8 *GetFieldObjectScriptPointerPlayerFacing(void); +bool8 mapheader_trigger_activate_at__run_now(struct MapPosition *); +bool8 sub_8068870(u16 a); +bool8 sub_8068894(void); +bool8 sub_8068A64(struct MapPosition *, u16); +u8 sub_8068F18(void); +bool8 dive_warp(struct MapPosition *position, u16 b); + +#endif // GUARD_FIELDCONTROLAVATAR_H diff --git a/include/field_ground_effect.h b/include/field_ground_effect.h index 63b67ceaf..89b14aed1 100644 --- a/include/field_ground_effect.h +++ b/include/field_ground_effect.h @@ -10,6 +10,8 @@ // Exported RAM declarations // Exported ROM declarations +u8 ZCoordToPriority(u8); +void FieldObjectUpdateZCoord(struct MapObject *pObject); void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8); void InitObjectPriorityByZCoord(struct Sprite *, u8); bool8 IsZCoordMismatchAt(u8, s16, s16); diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 198dd9759..8b7e296dd 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -25,6 +25,7 @@ enum SpinnerRunnerFollowPatterns { // Exported ROM declarations void sub_808D438(void); +u8 get_go_image_anim_num(u8); u8 GetFieldObjectIdByLocalIdAndMap(u8, u8, u8); bool8 TryGetFieldObjectIdByLocalIdAndMap(u8, u8, u8, u8 *); u8 GetFieldObjectIdByXY(s16, s16); @@ -88,6 +89,8 @@ bool8 FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(struct MapObject *ma u8 FieldObjectCheckIfSpecialAnimFinishedOrInactive(struct MapObject *mapObject); void sub_808F23C(const struct MapObject *mapObject, u8 movementType); void sub_808F208(const struct MapObject *mapObject); +void npc_coords_shift_still(struct MapObject *pObject); +void FieldObjectMoveDestCoords(struct MapObject *pObject, u32 unk_19, s16 *pInt, s16 *pInt1); // Exported data declarations diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index af602245b..de6db5d63 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -1,6 +1,7 @@ #ifndef GUARD_FIELD_PLAYER_AVATAR_H #define GUARD_FIELD_PLAYER_AVATAR_H +void player_step(u8 a, u16 b, u16 c); void ClearPlayerAvatarInfo(void); void SetPlayerAvatarExtraStateTransition(u8, u8); u8 GetPlayerAvatarGenderByGraphicsId(u8); @@ -31,7 +32,7 @@ u8 CheckForFieldObjectCollision(struct MapObject *a, s16 b, s16 c, u8 d, u8 e); u8 PlayerGetZCoord(void); void SetPlayerAvatarTransitionFlags(u16 a); void sub_808BCE8(void); - +void InitPlayerAvatar(s16 a, s16 b, u8 c, u8 d); void sub_808D074(u8); void GetXYCoordsOneStepInFrontOfPlayer(s16 *xPtr, s16 *yPtr); u8 GetRivalAvatarGraphicsIdByStateIdAndGender(u8, u8); diff --git a/include/fieldmap.h b/include/fieldmap.h index 06cb7cc77..23654f536 100644 --- a/include/fieldmap.h +++ b/include/fieldmap.h @@ -15,5 +15,6 @@ bool8 MapGridIsImpassableAt(s16, s16); s32 GetMapBorderIdAt(s16, s16); bool32 CanCameraMoveInDirection(u8); u16 GetBehaviorByMetatileId(u16 metatileId); +void sav1_camera_get_focus_coords(u16 *x, u16 *y); #endif //GUARD_FIELDMAP_H diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index b12febefd..6e262dc9c 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -162,10 +162,10 @@ struct MapConnections struct MapHeader { - /* 0x00 */ struct MapData *mapData; - /* 0x04 */ struct MapEvents *events; + /* 0x00 */ const struct MapData *mapData; + /* 0x04 */ const struct MapEvents *events; /* 0x08 */ u8 *mapScripts; - /* 0x0C */ struct MapConnections *connections; + /* 0x0C */ const struct MapConnections *connections; /* 0x10 */ u16 music; /* 0x12 */ u16 mapDataId; /* 0x14 */ u8 regionMapSectionId; diff --git a/include/global.h b/include/global.h index b815e1e5f..8c56c0a58 100644 --- a/include/global.h +++ b/include/global.h @@ -144,6 +144,18 @@ struct UCoords16 u16 y; }; +struct Coords32 +{ + s32 x; + s32 y; +}; + +struct UCoords32 +{ + u32 x; + u32 y; +}; + struct Time { /*0x00*/ s16 days; diff --git a/include/overworld.h b/include/overworld.h index cedad6266..7f0a1795f 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -1,7 +1,5 @@ -#ifndef GUARD_ROM4_H -#define GUARD_ROM4_H - -#include "main.h" +#ifndef GUARD_OVERWORLD_H +#define GUARD_OVERWORLD_H struct UnkPlayerStruct { @@ -17,19 +15,15 @@ struct LinkPlayerMapObject u8 mode; }; -struct UCoords32 -{ - u32 x, y; -}; - +extern struct WarpData gUnknown_020322DC; extern struct LinkPlayerMapObject gLinkPlayerMapObjects[4]; -extern MainCallback gFieldCallback; + +extern const struct UCoords32 gUnknown_08339D64[]; void DoWhiteOut(void); void Overworld_ResetStateAfterFly(void); void Overworld_ResetStateAfterTeleport(void); void Overworld_ResetStateAfterDigEscRope(void); -void sub_8084788(void); void ResetGameStats(void); void IncrementGameStat(u8 index); u32 GetGameStat(u8 index); @@ -39,82 +33,106 @@ void LoadMapObjTemplatesFromHeader(void); void LoadSaveblockMapObjScripts(void); void Overworld_SetMapObjTemplateCoords(u8 localId, s16 x, s16 y); void Overworld_SetMapObjTemplateMovementType(u8 localId, u8 movementType); -void mapdata_load_assets_to_gpu_and_full_redraw(void); -struct MapData *get_mapdata_header(void); +const struct MapData *get_mapdata_header(void); void ApplyCurrentWarp(void); void set_warp2_warp3_to_neg_1(void); void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); bool32 warp_data_is_not_neg_1(struct WarpData *warp); -struct MapHeader *const Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum); -struct MapHeader *const warp1_get_mapheader(void); +const struct MapHeader *Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum); +const struct MapHeader *warp1_get_mapheader(void); void set_current_map_header_from_sav1_save_old_name(void); void LoadSaveblockMapHeader(void); void update_camera_pos_from_warpid(void); void warp_in(void); void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void warp1_set_2(s8 mapGroup, s8 mapNum, s8 warpId); -void saved_warp2_set(int unused, s8 mapGroup, s8 mapNum, s8 warpId); -void saved_warp2_set_2(int unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); +void saved_warp2_set(s32 unused, s8 mapGroup, s8 mapNum, s8 warpId); +void saved_warp2_set_2(s32 unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused); void sub_8084CCC(u8 a1); void Overworld_SetWarpDestToLastHealLoc(void); void Overworld_SetHealLocationWarp(u8 healLocationId); void sub_8084D5C(s16 a1, s16 a2); void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); - -// to erase later -bool32 Overworld_IsBikingAllowed(void); -u8 sub_808532C(struct UnkPlayerStruct *playerStruct, u16 a2, u8 a3); -u8 sub_808538C(struct UnkPlayerStruct *playerStruct, u8 a2, u16 a3, u8 a4); -u16 cur_mapdata_block_role_at_screen_center_acc_to_sav1(void); -bool8 Overworld_MapTypeIsIndoors(u8 mapType); -void SetDefaultFlashLevel(void); -void Overworld_ClearSavedMusic(void); -void sub_8085810(void); -u8 GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum); -u8 Overworld_GetMapTypeOfSaveblockLocation(void); -void Overworld_SetMapObjTemplateCoords(u8, s16, s16); -void Overworld_SetMapObjTemplateMovementType(u8, u8); -void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); -void saved_warp2_set(int unused, s8 mapGroup, s8 mapNum, s8 warpId); -void saved_warp2_set_2(int unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); -void Overworld_SetHealLocationWarp(u8); -void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); -void sub_8084E2C(s8, s8, s8, s8, s8); -void sub_8084E80(s8, s8, s8, s8, s8); -void sub_8084EBC(s16, s16); +void sub_8084E14(void); +void sub_8084E2C(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); +void warp1_set_to_warp2(void); +void sub_8084E80(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); +void sub_8084EBC(s16 x, s16 y); +void warp1_set_to_sav1w(void); +void sub_8084F2C(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); +void sub_8084F6C(u8 a1); +void sub_8084FAC(void); +const struct MapConnection *GetMapConnection(u8 dir); +bool8 sub_8084FF8(u8 dir, u16 x, u16 y); +bool8 sub_8085058(u16 x, u16 y); +bool8 sub_8085078(u16 x, u16 y); +void mliX_load_map(u8 mapGroup, u8 mapNum); void player_avatar_init_params_reset(void); -bool8 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType); -void Overworld_ResetStateAfterTeleport(void); -void Overworld_SetFlashLevel(s32 a1); -//u8 Overworld_GetFlashLevel(void); -void sub_8085524(u16); -void Overworld_SetSavedMusic(u16); +void walkrun_find_lowest_active_bit_in_bitfield(void); +bool32 Overworld_IsBikingAllowed(void); +void SetDefaultFlashLevel(void); +void Overworld_SetFlashLevel(s32 flashLevel); +u8 Overworld_GetFlashLevel(void); +void sub_8085524(u16 mapDataId); +void sub_8085540(u8 var); +u8 sub_808554C(void); +u16 GetLocationMusic(struct WarpData *warp); +u16 GetCurrLocationDefaultMusic(void); +u16 GetWarpDestinationMusic(void); +void Overworld_ResetMapMusic(void); +void Overworld_PlaySpecialMapMusic(void); +void Overworld_SetSavedMusic(u16 songNum); +void Overworld_ClearSavedMusic(void); void Overworld_ChangeMusicToDefault(void); -void Overworld_ChangeMusicTo(u16); -bool32 is_c1_link_related_active(void); -extern u16 gUnknown_03005DA8; -void strange_npc_table_clear(void); -void FieldObjectMoveDestCoords(struct MapObject *, u32, s16 *, s16 *); -void sub_8086230(void); -void c2_exit_to_overworld_2_switch(void); -bool32 sub_8087598(void); -void c2_exit_to_overworld_1_continue_scripts_restart_music(void); -void warp_in(void); -u8 get_map_light_level_by_bank_and_number(s8 mapGroup, s8 mapNum); -void sub_8086194(void); -void sub_8084CCC(u8 spawn); -void warp1_set_2(s8 mapGroup, s8 mapNum, s8 warpNum); -void c2_load_new_map(void); -void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused); -void mapldr_default(void); +void Overworld_ChangeMusicTo(u16 newMusic); +u8 GetMapMusicFadeoutSpeed(void); +void music_something(void); +bool8 sub_80859A0(void); +void Overworld_FadeOutMapMusic(void); +void UpdateAmbientCry(s16 *state, u16 *delayCounter); +u8 GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum); +u8 GetMapTypeByWarpData(struct WarpData *warp); +u8 Overworld_GetMapTypeOfSaveblockLocation(void); u8 get_map_light_from_warp0(void); -bool8 is_light_level_1_2_3_5_or_6(u8 a1); +bool8 is_light_level_1_2_3_5_or_6(u8 mapType); +bool8 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType); +bool8 Overworld_MapTypeIsIndoors(u8 mapType); +u8 sav1_saved_warp2_map_get_name(void); +u8 sav1_map_get_name(void); +u8 GetCurrentMapBattleScene(void); +void overworld_free_bg_tilemaps(void); +bool32 is_c1_link_related_active(void); +void CB1_Overworld(void); +void CB2_OverworldBasic(void); +void CB2_Overworld(void); +void SetMainCallback1(void (*cb)(void)); +void sub_8085E94(void *a0); +void CB2_NewGame(void); +void CB2_WhiteOut(void); +void CB2_LoadMap(void); +void sub_8086024(void); +void sub_8086074(void); +void CB2_ReturnToField(void); +void CB2_ReturnToFieldLocal(void); +void CB2_ReturnToFieldLink(void); +void c2_8056854(void); +void CB2_ReturnToFieldWithOpenMenu(void); +void sub_80861B0(void); +void CB2_ReturnToFieldContinueScript(void); +void sub_80861E8(void); +void CB2_ContinueSavedGame(void); +void sub_8086C2C(void); +u32 sub_8087214(void); +bool32 sub_808727C(void); +u16 sub_8087288(void); +u16 sub_808729C(void); +u16 sub_80872B0(void); +u16 sub_80872C4(void); +bool32 sub_8087598(void); bool32 sub_80875C8(void); bool32 sub_8087634(void); bool32 sub_808766C(void); -void IncrementGameStat(u8); -u32 GetGameStat(u8); -void CB2_OverworldBasic(void); +void ZeroAllLinkPlayerMapObjects(void); -#endif //GUARD_ROM4_H +#endif // GUARD_OVERWORLD_H diff --git a/ld_script.txt b/ld_script.txt index bb015446f..c1bad970e 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -87,7 +87,6 @@ SECTIONS { src/play_time.o(.text); src/new_game.o(.text); src/overworld.o(.text); - asm/overworld.o(.text); asm/fieldmap.o(.text); src/metatile_behavior.o(.text); asm/field_camera.o(.text); diff --git a/src/battle_setup.c b/src/battle_setup.c index fdf6e77b6..6b981d0c5 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -472,7 +472,7 @@ void StartWallyTutorialBattle(void) { CreateMaleMon(&gEnemyParty[0], SPECIES_RALTS, 5); ScriptContext2_Enable(); - gMain.savedCallback = c2_exit_to_overworld_1_continue_scripts_restart_music; + gMain.savedCallback = CB2_ReturnToFieldContinueScript; gBattleTypeFlags = BATTLE_TYPE_WALLY_TUTORIAL; CreateBattleStartTask(B_TRANSITION_SLICE, 0); } @@ -601,7 +601,7 @@ static void CB2_EndWildBattle(void) } else { - SetMainCallback2(c2_exit_to_overworld_2_switch); + SetMainCallback2(CB2_ReturnToField); gFieldCallback = sub_80AF6F0; } } @@ -614,13 +614,13 @@ static void CB2_EndScriptedWildBattle(void) if (IsPlayerDefeated(gBattleOutcome) == TRUE) { if (InBattlePyramid()) - SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); + SetMainCallback2(CB2_ReturnToFieldContinueScript); else SetMainCallback2(CB2_WhiteOut); } else { - SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); + SetMainCallback2(CB2_ReturnToFieldContinueScript); } } @@ -937,7 +937,7 @@ static void CB2_StartFirstBattle(void) static void CB2_EndFirstBattle(void) { Overworld_ClearSavedMusic(); - SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); + SetMainCallback2(CB2_ReturnToFieldContinueScript); } static void sub_80B1218(void) @@ -1313,18 +1313,18 @@ static void CB2_EndTrainerBattle(void) { if (gTrainerBattleOpponent_A == SECRET_BASE_OPPONENT) { - SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); + SetMainCallback2(CB2_ReturnToFieldContinueScript); } else if (IsPlayerDefeated(gBattleOutcome) == TRUE) { if (InBattlePyramid() || sub_81D5C18()) - SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); + SetMainCallback2(CB2_ReturnToFieldContinueScript); else SetMainCallback2(CB2_WhiteOut); } else { - SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); + SetMainCallback2(CB2_ReturnToFieldContinueScript); if (!InBattlePyramid() && !sub_81D5C18()) { RegisterTrainerInMatchCall(); @@ -1337,7 +1337,7 @@ static void CB2_EndRematchBattle(void) { if (gTrainerBattleOpponent_A == SECRET_BASE_OPPONENT) { - SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); + SetMainCallback2(CB2_ReturnToFieldContinueScript); } else if (IsPlayerDefeated(gBattleOutcome) == TRUE) { @@ -1345,7 +1345,7 @@ static void CB2_EndRematchBattle(void) } else { - SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); + SetMainCallback2(CB2_ReturnToFieldContinueScript); RegisterTrainerInMatchCall(); SetBattledTrainersFlags(); HandleRematchVarsOnBattleEnd(); diff --git a/src/battle_transition.c b/src/battle_transition.c index e0d208f23..8b9b50140 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -919,7 +919,7 @@ static void CB2_TestBattleTransition(void) if (IsBattleTransitionDone()) { sTestingTransitionState = 0; - SetMainCallback2(c2_exit_to_overworld_2_switch); + SetMainCallback2(CB2_ReturnToField); } break; } diff --git a/src/berry_blender.c b/src/berry_blender.c index 23594ba46..1ac52dd6c 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -161,7 +161,7 @@ extern void copy_textbox_border_tile_patterns_to_vram(u8, u16, u8); extern void sub_81AABF0(void (*callback)(void)); extern void sub_800B4C0(void); extern void ClearLinkCallback(void); -extern void c2_exit_to_overworld_1_continue_scripts_restart_music(void); +extern void CB2_ReturnToFieldContinueScript(void); extern void sub_8153430(void); extern bool8 sub_8153474(void); extern void sub_80EECEC(void); @@ -2692,7 +2692,7 @@ static void CB2_HandlePlayerLinkPlayAgainChoice(void) if (gReceivedRemoteLinkPlayers == 0) { FREE_AND_SET_NULL(sBerryBlenderData); - SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); + SetMainCallback2(CB2_ReturnToFieldContinueScript); } break; } @@ -2742,7 +2742,7 @@ static void CB2_HandlePlayerPlayAgainChoice(void) if (sBerryBlenderData->playAgainState == PLAY_AGAIN_OK) SetMainCallback2(DoBerryBlending); else - SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); + SetMainCallback2(CB2_ReturnToFieldContinueScript); FreeAllWindowBuffers(); UnsetBgTilemapBuffer(2); diff --git a/src/clock.c b/src/clock.c index 7cea30166..71c433ed2 100644 --- a/src/clock.c +++ b/src/clock.c @@ -83,7 +83,7 @@ static void UpdatePerMinute(struct Time *localTime) static void ReturnFromStartWallClock(void) { InitTimeBasedEvents(); - SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); + SetMainCallback2(CB2_ReturnToFieldContinueScript); } void StartWallClock(void) diff --git a/src/daycare.c b/src/daycare.c index 89c0a48d8..36e8b208d 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -46,7 +46,7 @@ extern void sub_819746C(u8, bool8); extern void NewMenuHelpers_DrawStdWindowFrame(u8, bool8); extern void sub_81B9328(void); extern void sub_81AF078(u32, bool8, struct ListMenu *); -extern void c2_exit_to_overworld_2_switch(void); +extern void CB2_ReturnToField(void); // this file's functions static void ClearDaycareMonMisc(struct DaycareMiscMon *misc); @@ -1315,5 +1315,5 @@ void ShowDaycareLevelMenu(void) void ChooseSendDaycareMon(void) { sub_81B9328(); - gMain.savedCallback = c2_exit_to_overworld_2_switch; + gMain.savedCallback = CB2_ReturnToField; } diff --git a/src/decoration.c b/src/decoration.c index 8eb875560..aa2d3aef9 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -1682,7 +1682,7 @@ void c1_overworld_prev_quest(u8 taskId) sub_812A3C8(); FreeSpritePaletteByTag(OVERWORLD_PLACE_DECOR_SELECTOR_PAL_TAG); gFieldCallback = sub_8128CD4; - SetMainCallback2(c2_exit_to_overworld_2_switch); + SetMainCallback2(CB2_ReturnToField); DestroyTask(taskId); break; } @@ -2673,7 +2673,7 @@ void sub_812A25C(u8 taskId) case 1: sub_812A3C8(); gFieldCallback = sub_812A334; - SetMainCallback2(c2_exit_to_overworld_2_switch); + SetMainCallback2(CB2_ReturnToField); DestroyTask(taskId); break; } diff --git a/src/egg_hatch.c b/src/egg_hatch.c index b78b9433e..e64a98ab1 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -63,7 +63,7 @@ extern void FadeScreen(u8, u8); extern void overworld_free_bg_tilemaps(void); extern void sub_80AF168(void); extern void ScanlineEffect_Stop(void); -extern void c2_exit_to_overworld_2_switch(void); +extern void CB2_ReturnToField(void); extern void play_some_sound(void); extern void DoNamingScreen(u8, const u8*, u16, u8, u32, MainCallback); extern u16 sub_80D22D0(void); @@ -564,7 +564,7 @@ static void EggHatchSetMonNickname(void) SetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_NICKNAME, gStringVar3); FreeMonSpritesGfx(); Free(sEggHatchData); - SetMainCallback2(c2_exit_to_overworld_2_switch); + SetMainCallback2(CB2_ReturnToField); } static void Task_EggHatchPlayBGM(u8 taskID) @@ -688,7 +688,7 @@ static void CB2_EggHatch_1(void) UnsetBgTilemapBuffer(0); UnsetBgTilemapBuffer(1); Free(sEggHatchData); - SetMainCallback2(c2_exit_to_overworld_2_switch); + SetMainCallback2(CB2_ReturnToField); } break; } diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 84613365c..a5be62442 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -198,7 +198,7 @@ static void npcs_clear_ids_and_state(void) void sub_808D438(void) { - strange_npc_table_clear(); + ZeroAllLinkPlayerMapObjects(); npcs_clear_ids_and_state(); ClearPlayerAvatarInfo(); sub_808D450(); diff --git a/src/hof_pc.c b/src/hof_pc.c index e772f04e8..e5b6f96f8 100644 --- a/src/hof_pc.c +++ b/src/hof_pc.c @@ -25,7 +25,7 @@ void AccessHallOfFamePC(void) void ReturnFromHallOfFamePC(void) { - SetMainCallback2(c2_exit_to_overworld_2_switch); + SetMainCallback2(CB2_ReturnToField); gFieldCallback = ReshowPCMenuAfterHallOfFamePC; } diff --git a/src/item_use.c b/src/item_use.c index bc70c5884..b9d84ad95 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -637,7 +637,7 @@ void sub_80FDC00(u8 taskId) if (!gPaletteFade.active) { overworld_free_bg_tilemaps(); - OpenPokeblockCase(0, c2_exit_to_overworld_2_switch); + OpenPokeblockCase(0, CB2_ReturnToField); DestroyTask(taskId); } } @@ -678,7 +678,7 @@ void sub_80FDD10(u8 taskId) { gUnknown_0203A0F4 = sub_80FDD74; gFieldCallback = MapPostLoadHook_UseItem; - *gUnknown_0203CE54 = c2_exit_to_overworld_2_switch; + *gUnknown_0203CE54 = CB2_ReturnToField; unknown_ItemMenu_Confirm(taskId); } else diff --git a/src/lilycove_lady.c b/src/lilycove_lady.c index dcdf9b45a..81a10f8a4 100644 --- a/src/lilycove_lady.c +++ b/src/lilycove_lady.c @@ -1079,7 +1079,7 @@ void sub_818E914(void) void sub_818E92C(void) { - OpenPokeblockCase(3, c2_exit_to_overworld_2_switch); + OpenPokeblockCase(3, CB2_ReturnToField); } void sub_818E940(void) diff --git a/src/load_save.c b/src/load_save.c index a516c08c2..e3de66bb8 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -133,12 +133,12 @@ void MoveSaveBlocks_ResetHeap(void) } -u8 sav2_x1_query_bit1(void) +u32 GetSecretBase2Field_9(void) { return gSaveBlock2Ptr->specialSaveWarp & 1; } -void sav2_x9_clear_bit1(void) +void ClearSecretBase2Field_9(void) { gSaveBlock2Ptr->specialSaveWarp &= ~1; } diff --git a/src/naming_screen.c b/src/naming_screen.c index 47d8b8ad1..be306c765 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -1798,22 +1798,22 @@ static bool8 sub_80E503C(u8 character) static void sub_80E5074(void) { - DoNamingScreen(0, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, sub_8086194); + DoNamingScreen(0, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, CB2_ReturnToFieldWithOpenMenu); } static void sub_80E509C(void) { - DoNamingScreen(1, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, sub_8086194); + DoNamingScreen(1, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, CB2_ReturnToFieldWithOpenMenu); } static void sub_80E50C4(void) { - DoNamingScreen(2, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, sub_8086194); + DoNamingScreen(2, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, CB2_ReturnToFieldWithOpenMenu); } static void sub_80E50EC(void) { - DoNamingScreen(3, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, sub_8086194); + DoNamingScreen(3, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, CB2_ReturnToFieldWithOpenMenu); } //-------------------------------------------------- diff --git a/src/overworld.c b/src/overworld.c index f5457242d..5e6654cad 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -1,12 +1,13 @@ #include "global.h" #include "overworld.h" +#include "main.h" #include "battle_setup.h" #include "berry.h" // #include "cable_club.h" #include "clock.h" #include "event_data.h" #include "field_camera.h" -// #include "field_control_avatar.h" +#include "field_control_avatar.h" #include "field_effect.h" #include "field_fadetransition.h" #include "field_ground_effect.h" @@ -53,68 +54,229 @@ #include "bg.h" #include "money.h" #include "save_location.h" +#include "constants/abilities.h" +#include "malloc.h" +#include "gpu_regs.h" +#include "link_rfu.h" // event scripts extern const u8 EventScript_WhiteOut[]; extern const u8 EventScript_271862[]; +extern const u8 EventScript_277513[]; +extern const u8 EventScript_TradeRoom_TooBusyToNotice[]; +extern const u8 EventScript_TradeRoom_ReadTrainerCard1[]; +extern const u8 EventScript_TradeRoom_ReadTrainerCard2[]; +extern const u8 gUnknown_08277388[]; +extern const u8 gUnknown_082773A3[]; +extern const u8 gUnknown_082773BE[]; +extern const u8 gUnknown_082773D9[]; +extern const u8 gUnknown_0827741D[]; +extern const u8 gUnknown_08277432[]; +extern const u8 gUnknown_08277447[]; +extern const u8 gUnknown_0827745C[]; +extern const u8 gUnknown_08277374[]; +extern const u8 gUnknown_0827737E[]; +extern const u8 gUnknown_082773FF[]; +extern const u8 gUnknown_082773F5[]; +extern const u8 gUnknown_082774EF[]; +extern const u8 gUnknown_08277509[]; // vars -extern struct MapData *const gMapAttributes[]; -extern struct MapHeader *const *const gMapGroups[]; +extern const struct MapData *const gMapAttributes[]; +extern const struct MapHeader *const *const gMapGroups[]; extern const s32 gMaxFlashLevel; +extern const u16 gUnknown_82EC7C4[]; + +extern u16 gSaveFileStatus; +extern u16 gUnknown_03005DA8; +extern u8 *gUnknown_03005DA0; +extern u8 *gUnknown_03005D9C; +extern u8 *gUnknown_03005DA4; +extern bool8 (*gUnknown_03005DB0)(void); +extern u8 gUnknown_03005DB4; +extern u8 gFieldLinkPlayerCount; +extern MainCallback gFieldCallback; // functions extern void HealPlayerParty(void); extern void move_tilemap_camera_to_upper_left_corner(void); extern void cur_mapheader_run_tileset_funcs_after_some_cpuset(void); extern void DrawWholeMapView(void); -extern void copy_map_tileset1_tileset2_to_vram(struct MapData *); -extern void apply_map_tileset1_tileset2_palette(struct MapData *); +extern void copy_map_tileset1_tileset2_to_vram(const struct MapData *); +extern void apply_map_tileset1_tileset2_palette(const struct MapData *); extern void ResetCyclingRoadChallengeData(void); extern void ApplyNewEncryptionKeyToWord(u32 *word, u32 newKey); extern void mapheader_run_script_with_tag_x5(void); extern void ResetFieldTasksArgs(void); extern void sub_80A0A2C(void); extern void not_trainer_hill_battle_pyramid(void); -extern void apply_map_tileset2_palette(struct MapData *); -extern void copy_map_tileset2_to_vram_2(struct MapData *); +extern void apply_map_tileset2_palette(const struct MapData *); +extern void copy_map_tileset2_to_vram_2(const struct MapData *); extern void prev_quest_postbuffer_cursor_backup_reset(void); extern void ShowMapNamePopup(void); extern bool32 InTrainerHill(void); +extern bool32 sub_808651C(void); +extern bool8 sub_80AF6A4(void); +extern bool8 sub_81A9E6C(void); +extern bool8 sub_80E909C(void); extern void sub_81AA1D8(void); +extern void c2_change_map(void); extern void sub_81D5DF8(void); extern void sub_80EB218(void); +extern void sub_81BE72C(void); +extern void sub_80AF3C8(void); +extern void sub_81971F4(void); +extern void sub_808B578(void); +extern void sub_80AF314(void); +extern void sub_80AF214(void); +extern void sub_80AF188(void); +extern void door_upload_tiles(void); +extern void RotatingGate_InitPuzzleAndGraphics(void); +extern void sub_80AF168(void); +extern void sub_80AF3C8(void); +extern void ExecuteTruckSequence(void); +extern void sub_80A0A38(void); extern void trainer_hill_map_load_related(void); +extern void sub_8087D74(void); extern void battle_pyramid_map_load_related(u8); +extern void sub_80B00E8(u8); extern void UpdateTVScreensOnMap(u32, u32); extern void sub_80E9238(u8); +extern void sub_81A3908(void); +extern void sub_81AA2F8(void); +extern void sub_8195E10(void); +extern void sub_80EDB44(void); +extern void sub_81D64C0(void); +extern void sub_81BE6AC(void); +extern void sub_8098128(void); +extern void copy_map_tileset1_to_vram(const struct MapData *); +extern void copy_map_tileset2_to_vram(const struct MapData *); +extern void FieldUpdateBgTilemapScroll(void); +extern void TransferTilesetAnimsBuffer(void); +extern bool32 sub_81D5F48(void); +extern u8 GetCurrentTrainerHillMapId(void); +extern bool8 warp0_in_pokecenter(void); +extern void dp13_810BB8C(void); +extern void FieldEffectActiveListClear(void); +extern void SetUpFieldTasks(void); +extern void sub_81BE6B8(void); +extern void sub_80AAFA4(void); +extern void sub_809FA9C(void); +extern void sub_80AEE84(void); +extern void mapldr_default(void); +extern void npc_paltag_set_load(u8); +extern void sub_8088B3C(u16, u16); +extern bool32 sub_800F0B8(void); +extern bool32 sub_8009F3C(void); +extern void sub_8010198(void); +extern u32 sub_800B4DC(void); +extern bool32 sub_80B39D4(u8); +extern const u8* sub_809C2C8(struct MapPosition *a1, u8, u8); +extern u8 *sub_809D0F4(void*); +extern u8 sub_808BD6C(u8); +extern u8 sub_808BD7C(u8); +extern void sub_80979D4(struct Sprite*, u8); // this file's functions static void Overworld_ResetStateAfterWhiteOut(void); -void ChooseAmbientCrySpecies(void); +static void c2_80567AC(void); +static void CB2_LoadMap2(void); +static void VBlankCB_Field(void); +static void SpriteCB_LinkPlayer(struct Sprite *sprite); +static void ChooseAmbientCrySpecies(void); +static void do_load_map_stuff_loop(u8 *state); +static bool32 map_loading_iteration_3(u8 *state); +static bool32 sub_8086638(u8 *state); +static bool32 load_map_stuff(u8 *state, u32); +static bool32 map_loading_iteration_2_link(u8 *state); +static void mli4_mapscripts_and_other(void); +static void map_loading_lcd_reset(void); +static u8 sub_8087858(u8); +static u16 sub_80871C0(u32 a1); +static void sub_80867C8(void); +static void sub_80867D8(void); +static void sub_8086AE4(void); +static void sub_80869DC(void); +static void sub_8086B14(void); +static void sub_8086AAC(void); +static void sub_8086988(bool32 arg0); +static void sub_8086A80(void); +static void sub_8086A68(void); +static void sub_8086860(void); +static void sub_8086AC8(void); +static void sub_8086B9C(void); +static void sub_8086C40(void); +static void sub_8086C90(void); +static void sub_8086FA0(u16); +static void sub_8086F38(u16*, s32); +static u8 npc_something3(u8 a1, u8 a2); +static u8 LinkPlayerDetectCollision(u8 selfMapObjId, u8 a2, s16 x, s16 y); +static void CreateLinkPlayerSprite(u8 linkPlayerId, u8 gameVersion); +static void sub_8087878(u8 linkPlayerId, u16 *x, u16 *y); +static u8 sub_80878A0(u8 linkPlayerId); +static u8 sub_80878C0(u8 linkPlayerId); +static s32 sub_80878E4(u8 linkPlayerId); +static u8 GetLinkPlayerIdAt(s16 x, s16 y); +static void sub_808796C(u8 linkPlayerId, u8 a2); +static void ZeroMapObject(struct MapObject *mapObj); +static void SpawnLinkPlayerMapObject(u8 linkPlayerId, s16 x, s16 y, u8 a4); +static void InitLinkPlayerMapObjectPos(struct MapObject *mapObj, s16 x, s16 y); +static void sub_80877DC(u8 linkPlayerId, u8 a2); +static void sub_808780C(u8 linkPlayerId); +static u8 sub_8087858(u8 linkPlayerId); +static void sub_8087584(void); +static u32 sub_8087690(void); +static void ZeroLinkPlayerMapObject(struct LinkPlayerMapObject *linkPlayerMapObj); +static const u8 *sub_80873B4(struct UnkStruct_8054FF8 *a1); +static u16 sub_8087480(const u8 *script); +static void sub_8087510(void); +static void sub_808751C(void); +static void sub_8087530(const u8 *script); +static void sub_808754C(void); +static void sub_8087568(const u8 *script); +static void sub_80872D8(s32 linkPlayerId, s32 a2, struct UnkStruct_8054FF8 *a3); +static bool32 sub_8087340(struct UnkStruct_8054FF8 *a1); +static bool32 sub_8087358(struct UnkStruct_8054FF8 *a1); +static u8 *sub_8087370(struct UnkStruct_8054FF8 *a1); +static bool32 sub_8087388(struct UnkStruct_8054FF8 *a1); +static const u8 *sub_80873B4(struct UnkStruct_8054FF8 *a1); +static u16 sub_808711C(u32); +static u16 sub_8087140(u32); +static void sub_808709C(u16 *a1); +static u16 sub_80870B0(u32 a1); +static u16 sub_80870F8(u32 a1); +static u16 sub_8087068(u16 a1); +static void c1_link_related(void); +static void c1_link_related_func_set(u16 (*func)(u32)); +static void SetFieldVBlankCallback(void); +static void FieldClearVBlankHBlankCallbacks(void); +static void sub_8085810(void); +static u8 sub_808532C(struct UnkPlayerStruct *playerStruct, u16 a2, u8 a3); +static u8 sub_808538C(struct UnkPlayerStruct *playerStruct, u8 a2, u16 a3, u8 a4); +static u16 cur_mapdata_block_role_at_screen_center_acc_to_sav1(void); // IWRAM bss vars -IWRAM_DATA void *gUnknown_03000E0C; -IWRAM_DATA u8 gUnknown_03000E10[4]; -IWRAM_DATA u8 (*gUnknown_03000E14)(u32); -IWRAM_DATA u8 gUnknown_03000E18; -IWRAM_DATA u8 gUnknown_03000E19; -IWRAM_DATA void *rom4_c_unused_03000e1c; +IWRAM_DATA static void *sUnknown_03000E0C; +IWRAM_DATA static u8 sUnknown_03000E10[4]; +IWRAM_DATA static u16 (*sUnknown_03000E14)(u32); +IWRAM_DATA static u8 sUnknown_03000E18; +IWRAM_DATA static u8 sUnknown_03000E19; +IWRAM_DATA static u32 sUnusedVar; // EWRAM vars -EWRAM_DATA u8 gUnknown_020322D8 = 0; +EWRAM_DATA static u8 sUnknown_020322D8 = 0; EWRAM_DATA struct WarpData gUnknown_020322DC = {0}; -EWRAM_DATA struct WarpData gWarpDestination = {0}; // new warp position -EWRAM_DATA struct WarpData gUnknown_020322EC = {0}; -EWRAM_DATA struct WarpData gUnknown_020322F4 = {0}; -EWRAM_DATA u16 gLastMapSectionId = 0; -EWRAM_DATA struct UnkPlayerStruct gUnknown_02032300 = {0}; -EWRAM_DATA u16 sAmbientCrySpecies = 0; -EWRAM_DATA bool8 sIsAmbientCryWaterMon = FALSE; +EWRAM_DATA static struct WarpData sWarpDestination = {0}; // new warp position +EWRAM_DATA static struct WarpData sUnknown_020322EC = {0}; +EWRAM_DATA static struct WarpData sUnknown_020322F4 = {0}; +EWRAM_DATA static u16 sLastMapSectionId = 0; +EWRAM_DATA static struct UnkPlayerStruct sUnknown_02032300 = {0}; +EWRAM_DATA static u16 sAmbientCrySpecies = 0; +EWRAM_DATA static bool8 sIsAmbientCryWaterMon = FALSE; EWRAM_DATA struct LinkPlayerMapObject gLinkPlayerMapObjects[4] = {0}; // const rom data -const struct WarpData sDummyWarpData = +static const struct WarpData sDummyWarpData = { .mapGroup = -1, .mapNum = -1, @@ -123,7 +285,7 @@ const struct WarpData sDummyWarpData = .y = -1, }; -const u8 sUnusedData[] = +static const u8 sUnusedData[] = { 0xB0, 0x04, 0x00, 0x00, 0x10, 0x0E, 0x00, 0x00, @@ -148,7 +310,7 @@ const struct UCoords32 gUnknown_08339D64[] = { 1, -1}, }; -const struct BgTemplate gUnknown_08339DAC[] = +static const struct BgTemplate gUnknown_08339DAC[] = { { .bg = 0, @@ -188,7 +350,7 @@ const struct BgTemplate gUnknown_08339DAC[] = } }; -const struct ScanlineEffectParams gUnknown_08339DBC = +static const struct ScanlineEffectParams gUnknown_08339DBC = { (void *)REG_ADDR_WIN0H, ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1, @@ -196,22 +358,22 @@ const struct ScanlineEffectParams gUnknown_08339DBC = 0, }; -u8 sub_80879D8(struct LinkPlayerMapObject *, struct MapObject *, u8); -u8 sub_80879F8(struct LinkPlayerMapObject *, struct MapObject *, u8); -u8 sub_80879FC(struct LinkPlayerMapObject *, struct MapObject *, u8); +static u8 sub_80879D8(struct LinkPlayerMapObject *, struct MapObject *, u8); +static u8 sub_80879F8(struct LinkPlayerMapObject *, struct MapObject *, u8); +static u8 sub_80879FC(struct LinkPlayerMapObject *, struct MapObject *, u8); -u8 (*const gUnknown_08339DC8[])(struct LinkPlayerMapObject *, struct MapObject *, u8) = +static u8 (*const gUnknown_08339DC8[])(struct LinkPlayerMapObject *, struct MapObject *, u8) = { sub_80879D8, sub_80879F8, sub_80879FC, }; -u8 sub_8087A1C(struct LinkPlayerMapObject *, struct MapObject *, u8); -u8 sub_8087A20(struct LinkPlayerMapObject *, struct MapObject *, u8); -u8 sub_8087A88(struct LinkPlayerMapObject *, struct MapObject *, u8); +static u8 sub_8087A1C(struct LinkPlayerMapObject *, struct MapObject *, u8); +static u8 sub_8087A20(struct LinkPlayerMapObject *, struct MapObject *, u8); +static u8 sub_8087A88(struct LinkPlayerMapObject *, struct MapObject *, u8); -u8 (*const gUnknown_08339DD4[])(struct LinkPlayerMapObject *, struct MapObject *, u8) = +static u8 (*const gUnknown_08339DD4[])(struct LinkPlayerMapObject *, struct MapObject *, u8) = { sub_8087A1C, sub_8087A20, @@ -226,10 +388,10 @@ u8 (*const gUnknown_08339DD4[])(struct LinkPlayerMapObject *, struct MapObject * sub_8087A88, }; -void sub_8087AA0(struct LinkPlayerMapObject *, struct MapObject *); -void sub_8087AA8(struct LinkPlayerMapObject *, struct MapObject *); +static void sub_8087AA0(struct LinkPlayerMapObject *, struct MapObject *); +static void sub_8087AA8(struct LinkPlayerMapObject *, struct MapObject *); -void (*const gUnknown_08339E00[])(struct LinkPlayerMapObject *, struct MapObject *) = +static void (*const gUnknown_08339E00[])(struct LinkPlayerMapObject *, struct MapObject *) = { sub_8087AA0, sub_8087AA8, @@ -292,7 +454,7 @@ static void Overworld_ResetStateAfterWhiteOut(void) } } -void sub_8084788(void) +static void sub_8084788(void) { FlagClear(FLAG_SYS_SAFARI_MODE); ChooseAmbientCrySpecies(); @@ -399,7 +561,7 @@ void Overworld_SetMapObjTemplateMovementType(u8 localId, u8 movementType) } } -void mapdata_load_assets_to_gpu_and_full_redraw(void) +static void mapdata_load_assets_to_gpu_and_full_redraw(void) { move_tilemap_camera_to_upper_left_corner(); copy_map_tileset1_tileset2_to_vram(gMapHeader.mapData); @@ -408,7 +570,7 @@ void mapdata_load_assets_to_gpu_and_full_redraw(void) cur_mapheader_run_tileset_funcs_after_some_cpuset(); } -struct MapData *get_mapdata_header(void) +const struct MapData *get_mapdata_header(void) { u16 mapDataId = gSaveBlock1Ptr->mapDataId; if (mapDataId) @@ -419,15 +581,15 @@ struct MapData *get_mapdata_header(void) void ApplyCurrentWarp(void) { gUnknown_020322DC = gSaveBlock1Ptr->location; - gSaveBlock1Ptr->location = gWarpDestination; - gUnknown_020322EC = sDummyWarpData; - gUnknown_020322F4 = sDummyWarpData; + gSaveBlock1Ptr->location = sWarpDestination; + sUnknown_020322EC = sDummyWarpData; + sUnknown_020322F4 = sDummyWarpData; } void set_warp2_warp3_to_neg_1(void) { - gUnknown_020322EC = sDummyWarpData; - gUnknown_020322F4 = sDummyWarpData; + sUnknown_020322EC = sDummyWarpData; + sUnknown_020322F4 = sDummyWarpData; } void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) @@ -454,19 +616,19 @@ bool32 warp_data_is_not_neg_1(struct WarpData *warp) return TRUE; } -struct MapHeader *const Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum) +const struct MapHeader *Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum) { return gMapGroups[mapGroup][mapNum]; } -struct MapHeader *const warp1_get_mapheader(void) +const struct MapHeader *warp1_get_mapheader(void) { - return Overworld_GetMapHeaderByGroupAndId(gWarpDestination.mapGroup, gWarpDestination.mapNum); + return Overworld_GetMapHeaderByGroupAndId(sWarpDestination.mapGroup, sWarpDestination.mapNum); } void set_current_map_header_from_sav1_save_old_name(void) { - gLastMapSectionId = gMapHeader.regionMapSectionId; + sLastMapSectionId = gMapHeader.regionMapSectionId; gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum); gSaveBlock1Ptr->mapDataId = gMapHeader.mapDataId; gMapHeader.mapData = get_mapdata_header(); @@ -506,7 +668,7 @@ void warp_in(void) void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) { - SetWarpData(&gWarpDestination, mapGroup, mapNum, warpId, x, y); + SetWarpData(&sWarpDestination, mapGroup, mapNum, warpId, x, y); } void warp1_set_2(s8 mapGroup, s8 mapNum, s8 warpId) @@ -514,19 +676,19 @@ void warp1_set_2(s8 mapGroup, s8 mapNum, s8 warpId) Overworld_SetWarpDestination(mapGroup, mapNum, warpId, -1, -1); } -void saved_warp2_set(int unused, s8 mapGroup, s8 mapNum, s8 warpId) +void saved_warp2_set(s32 unused, s8 mapGroup, s8 mapNum, s8 warpId) { SetWarpData(&gSaveBlock1Ptr->warp2, mapGroup, mapNum, warpId, gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y); } -void saved_warp2_set_2(int unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) +void saved_warp2_set_2(s32 unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) { SetWarpData(&gSaveBlock1Ptr->warp2, mapGroup, mapNum, warpId, x, y); } void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused) { - gWarpDestination = gSaveBlock1Ptr->warp2; + sWarpDestination = gSaveBlock1Ptr->warp2; } void sub_8084CCC(u8 a1) @@ -539,7 +701,7 @@ void sub_8084CCC(u8 a1) void Overworld_SetWarpDestToLastHealLoc(void) { - gWarpDestination = gSaveBlock1Ptr->lastHealLocation; + sWarpDestination = gSaveBlock1Ptr->lastHealLocation; } void Overworld_SetHealLocationWarp(u8 healLocationId) @@ -553,7 +715,7 @@ void Overworld_SetHealLocationWarp(u8 healLocationId) void sub_8084D5C(s16 a1, s16 a2) { u8 currMapType = Overworld_GetMapTypeOfSaveblockLocation(); - u8 destMapType = GetMapTypeByGroupAndId(gWarpDestination.mapGroup, gWarpDestination.mapNum); + u8 destMapType = GetMapTypeByGroupAndId(sWarpDestination.mapGroup, sWarpDestination.mapNum); if (is_light_level_1_2_3_5_or_6(currMapType) && is_light_level_1_2_3_5_or_6(destMapType) != TRUE) sub_8084DD4(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, a1 - 7, a2 - 6); } @@ -565,39 +727,39 @@ void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) void sub_8084E14(void) { - gWarpDestination = gSaveBlock1Ptr->warp4; + sWarpDestination = gSaveBlock1Ptr->warp4; } void sub_8084E2C(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) { - SetWarpData(&gUnknown_020322EC, mapGroup, mapNum, warpId, x, y); + SetWarpData(&sUnknown_020322EC, mapGroup, mapNum, warpId, x, y); } void warp1_set_to_warp2(void) { - gWarpDestination = gUnknown_020322EC; + sWarpDestination = sUnknown_020322EC; } void sub_8084E80(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) { - SetWarpData(&gUnknown_020322F4, mapGroup, mapNum, warpId, x, y); + SetWarpData(&sUnknown_020322F4, mapGroup, mapNum, warpId, x, y); } void sub_8084EBC(s16 x, s16 y) { - if (warp_data_is_not_neg_1(&gUnknown_020322F4) == TRUE) + if (warp_data_is_not_neg_1(&sUnknown_020322F4) == TRUE) { - gWarpDestination = gUnknown_020322DC; + sWarpDestination = gUnknown_020322DC; } else { - Overworld_SetWarpDestination(gUnknown_020322F4.mapGroup, gUnknown_020322F4.mapNum, -1, x, y); + Overworld_SetWarpDestination(sUnknown_020322F4.mapGroup, sUnknown_020322F4.mapNum, -1, x, y); } } void warp1_set_to_sav1w(void) { - gWarpDestination = gSaveBlock1Ptr->warp1; + sWarpDestination = gSaveBlock1Ptr->warp1; } void sub_8084F2C(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) @@ -617,11 +779,11 @@ void sub_8084FAC(void) gSaveBlock1Ptr->warp1 = gSaveBlock1Ptr->warp2; } -struct MapConnection *GetMapConnection(u8 dir) +const struct MapConnection *GetMapConnection(u8 dir) { s32 i; s32 count = gMapHeader.connections->count; - struct MapConnection *connection = gMapHeader.connections->connections; + const struct MapConnection *connection = gMapHeader.connections->connections; if (connection == NULL) return NULL; @@ -635,7 +797,7 @@ struct MapConnection *GetMapConnection(u8 dir) bool8 sub_8084FF8(u8 dir, u16 x, u16 y) { - struct MapConnection *connection = GetMapConnection(dir); + const struct MapConnection *connection = GetMapConnection(dir); if (connection != NULL) { @@ -644,7 +806,7 @@ bool8 sub_8084FF8(u8 dir, u16 x, u16 y) else { mapheader_run_script_with_tag_x6(); - if (warp_data_is_not_neg_1(&gUnknown_020322EC)) + if (warp_data_is_not_neg_1(&sUnknown_020322EC)) return FALSE; warp1_set_to_warp2(); } @@ -697,17 +859,17 @@ void mliX_load_map(u8 mapGroup, u8 mapNum) ResetFieldTasksArgs(); mapheader_run_script_with_tag_x5(); - if (gMapHeader.regionMapSectionId != 0x3A || gMapHeader.regionMapSectionId != gLastMapSectionId) + if (gMapHeader.regionMapSectionId != 0x3A || gMapHeader.regionMapSectionId != sLastMapSectionId) ShowMapNamePopup(); } -void mli0_load_map(u32 a1) +static void mli0_load_map(u32 a1) { bool8 v2; bool8 indoors; set_current_map_header_from_sav1_save_old_name(); - if (!(gUnknown_020322D8 & 1)) + if (!(sUnknown_020322D8 & 1)) { if (gMapHeader.mapDataId == 0x169) sub_81AA1D8(); @@ -753,39 +915,39 @@ void mli0_load_map(u32 a1) void player_avatar_init_params_reset(void) { - gUnknown_02032300.player_field_1 = 1; - gUnknown_02032300.player_field_0 = 1; + sUnknown_02032300.player_field_1 = 1; + sUnknown_02032300.player_field_0 = 1; } void walkrun_find_lowest_active_bit_in_bitfield(void) { - gUnknown_02032300.player_field_1 = player_get_direction_lower_nybble(); + sUnknown_02032300.player_field_1 = player_get_direction_lower_nybble(); if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE)) - gUnknown_02032300.player_field_0 = 2; + sUnknown_02032300.player_field_0 = 2; else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE)) - gUnknown_02032300.player_field_0 = 4; + sUnknown_02032300.player_field_0 = 4; else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) - gUnknown_02032300.player_field_0 = 8; + sUnknown_02032300.player_field_0 = 8; else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_4)) - gUnknown_02032300.player_field_0 = 16; + sUnknown_02032300.player_field_0 = 16; else - gUnknown_02032300.player_field_0 = 1; + sUnknown_02032300.player_field_0 = 1; } -struct UnkPlayerStruct *sub_80852D4(void) +static struct UnkPlayerStruct *sub_80852D4(void) { struct UnkPlayerStruct playerStruct; u8 mapType = Overworld_GetMapTypeOfSaveblockLocation(); u16 v2 = cur_mapdata_block_role_at_screen_center_acc_to_sav1(); - u8 v4 = sub_808532C(&gUnknown_02032300, v2, mapType); + u8 v4 = sub_808532C(&sUnknown_02032300, v2, mapType); playerStruct.player_field_0 = v4; - playerStruct.player_field_1 = sub_808538C(&gUnknown_02032300, v4, v2, mapType); - gUnknown_02032300 = playerStruct; - return &gUnknown_02032300; + playerStruct.player_field_1 = sub_808538C(&sUnknown_02032300, v4, v2, mapType); + sUnknown_02032300 = playerStruct; + return &sUnknown_02032300; } -u8 sub_808532C(struct UnkPlayerStruct *playerStruct, u16 a2, u8 a3) +static u8 sub_808532C(struct UnkPlayerStruct *playerStruct, u16 a2, u8 a3) { if (a3 != 8 && FlagGet(FLAG_SYS_CRUISE_MODE)) return 1; @@ -802,7 +964,7 @@ u8 sub_808532C(struct UnkPlayerStruct *playerStruct, u16 a2, u8 a3) return 4; } -u8 sub_808538C(struct UnkPlayerStruct *playerStruct, u8 a2, u16 a3, u8 a4) +static u8 sub_808538C(struct UnkPlayerStruct *playerStruct, u8 a2, u16 a3, u8 a4) { if (FlagGet(FLAG_SYS_CRUISE_MODE) && a4 == 6) return 4; @@ -826,7 +988,7 @@ u8 sub_808538C(struct UnkPlayerStruct *playerStruct, u8 a2, u16 a3, u8 a4) return 1; } -u16 cur_mapdata_block_role_at_screen_center_acc_to_sav1(void) +static u16 cur_mapdata_block_role_at_screen_center_acc_to_sav1(void) { return MapGridGetMetatileBehaviorAt(gSaveBlock1Ptr->pos.x + 7, gSaveBlock1Ptr->pos.y + 7); } @@ -869,15 +1031,15 @@ void sub_8085524(u16 mapDataId) void sub_8085540(u8 var) { - gUnknown_020322D8 = var; + sUnknown_020322D8 = var; } u8 sub_808554C(void) { - return gUnknown_020322D8; + return sUnknown_020322D8; } -bool16 ShouldLegendaryMusicPlayAtLocation(struct WarpData *warp) +static bool16 ShouldLegendaryMusicPlayAtLocation(struct WarpData *warp) { if (!FlagGet(FLAG_SYS_WEATHER_CTRL)) return FALSE; @@ -910,7 +1072,7 @@ bool16 ShouldLegendaryMusicPlayAtLocation(struct WarpData *warp) return FALSE; } -bool16 NoMusicInSotopolisWithLegendaries(struct WarpData *warp) +static bool16 NoMusicInSotopolisWithLegendaries(struct WarpData *warp) { if (VarGet(VAR_0x40CA) != 1) return FALSE; @@ -921,7 +1083,7 @@ bool16 NoMusicInSotopolisWithLegendaries(struct WarpData *warp) return FALSE; } -bool16 IsInfiltratedWeatherInstitute(struct WarpData *warp) +static bool16 IsInfiltratedWeatherInstitute(struct WarpData *warp) { if (VarGet(VAR_WEATHER_INSTITUTE_STATE)) return FALSE; @@ -933,7 +1095,7 @@ bool16 IsInfiltratedWeatherInstitute(struct WarpData *warp) return FALSE; } -bool16 IsInflitratedSpaceCenter(struct WarpData *warp) +static bool16 IsInflitratedSpaceCenter(struct WarpData *warp) { if (VarGet(VAR_0x405D) == 0) return FALSE; @@ -987,7 +1149,7 @@ u16 GetCurrLocationDefaultMusic(void) u16 GetWarpDestinationMusic(void) { - u16 music = GetLocationMusic(&gWarpDestination); + u16 music = GetLocationMusic(&sWarpDestination); if (music != 0x7FFF) { return music; @@ -1035,7 +1197,7 @@ void Overworld_ClearSavedMusic(void) gSaveBlock1Ptr->savedMusic = 0; } -void sub_8085810(void) +static void sub_8085810(void) { if (FlagGet(FLAG_SPECIAL_FLAG_0x4001) != TRUE) { @@ -1074,7 +1236,7 @@ void Overworld_ChangeMusicTo(u16 newMusic) u8 GetMapMusicFadeoutSpeed(void) { - struct MapHeader *mapHeader = warp1_get_mapheader(); + const struct MapHeader *mapHeader = warp1_get_mapheader(); if (Overworld_MapTypeIsIndoors(mapHeader->mapType) == TRUE) return 2; else @@ -1091,10 +1253,10 @@ void music_something(void) && VarGet(VAR_0x40CA) == 2 && gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(SOOTOPOLIS_CITY) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(SOOTOPOLIS_CITY) - && gWarpDestination.mapGroup == MAP_GROUP(SOOTOPOLIS_CITY) - && gWarpDestination.mapNum == MAP_NUM(SOOTOPOLIS_CITY) - && gWarpDestination.x == 0x1D - && gWarpDestination.y == 0x35) + && sWarpDestination.mapGroup == MAP_GROUP(SOOTOPOLIS_CITY) + && sWarpDestination.mapNum == MAP_NUM(SOOTOPOLIS_CITY) + && sWarpDestination.x == 0x1D + && sWarpDestination.y == 0x35) return; FadeOutMapMusic(GetMapMusicFadeoutSpeed()); } @@ -1109,3 +1271,1920 @@ void Overworld_FadeOutMapMusic(void) { FadeOutMapMusic(4); } + +static void PlayAmbientCry(void) +{ + s16 x, y; + s8 pan; + s8 volume; + + PlayerGetDestCoords(&x, &y); + if (sIsAmbientCryWaterMon == TRUE + && !MetatileBehavior_IsSurfableWaterOrUnderwater(MapGridGetMetatileBehaviorAt(x, y))) + return; + pan = (Random() % 88) + 212; + volume = (Random() % 30) + 50; + PlayCry2(sAmbientCrySpecies, pan, volume, 1); +} + +void UpdateAmbientCry(s16 *state, u16 *delayCounter) +{ + u8 i, monsCount, divBy; + + switch (*state) + { + case 0: + if (sAmbientCrySpecies == SPECIES_NONE) + *state = 4; + else + *state = 1; + break; + case 1: + *delayCounter = (Random() % 2400) + 1200; + *state = 3; + break; + case 2: + divBy = 1; + monsCount = CalculatePlayerPartyCount(); + for (i = 0; i < monsCount; i++) + { + if (!GetMonData(&gPlayerParty[i], MON_DATA_SANITY_BIT3) + && GetMonAbility(&gPlayerParty[0]) == ABILITY_SWARM) + { + divBy = 2; + break; + } + } + *delayCounter = ((Random() % 1200) + 1200) / divBy; + *state = 3; + break; + case 3: + (*delayCounter)--; + if (*delayCounter == 0) + { + PlayAmbientCry(); + *state = 2; + } + break; + case 4: + break; + } +} + +static void ChooseAmbientCrySpecies(void) +{ + if ((gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(ROUTE130) + && gSaveBlock1Ptr->location.mapNum == MAP_NUM(ROUTE130)) + && !IsMirageIslandPresent()) + { + // Only play water pokemon cries on this route + // when Mirage Island is not present + sIsAmbientCryWaterMon = TRUE; + sAmbientCrySpecies = GetLocalWaterMon(); + } + else + { + sAmbientCrySpecies = GetLocalWildMon(&sIsAmbientCryWaterMon); + } +} + +u8 GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum) +{ + return Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum)->mapType; +} + +u8 GetMapTypeByWarpData(struct WarpData *warp) +{ + return GetMapTypeByGroupAndId(warp->mapGroup, warp->mapNum); +} + +u8 Overworld_GetMapTypeOfSaveblockLocation(void) +{ + return GetMapTypeByWarpData(&gSaveBlock1Ptr->location); +} + +u8 get_map_light_from_warp0(void) +{ + return GetMapTypeByWarpData(&gUnknown_020322DC); +} + +bool8 is_light_level_1_2_3_5_or_6(u8 mapType) +{ + if (mapType == MAP_TYPE_ROUTE + || mapType == MAP_TYPE_TOWN + || mapType == MAP_TYPE_UNDERWATER + || mapType == MAP_TYPE_CITY + || mapType == MAP_TYPE_6) + return TRUE; + else + return FALSE; +} + +bool8 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType) +{ + if (mapType == MAP_TYPE_ROUTE + || mapType == MAP_TYPE_TOWN + || mapType == MAP_TYPE_6 + || mapType == MAP_TYPE_CITY) + return TRUE; + else + return FALSE; +} + +bool8 Overworld_MapTypeIsIndoors(u8 mapType) +{ + if (mapType == MAP_TYPE_INDOOR + || mapType == MAP_TYPE_SECRET_BASE) + return TRUE; + else + return FALSE; +} + +u8 sav1_saved_warp2_map_get_name(void) +{ + return Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->warp2.mapGroup, gSaveBlock1Ptr->warp2.mapNum)->regionMapSectionId; +} + +u8 sav1_map_get_name(void) +{ + return Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum)->regionMapSectionId; +} + +u8 GetCurrentMapBattleScene(void) +{ + return Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum)->battleType; +} + +static void overworld_bg_setup(void) +{ + InitBgsFromTemplates(0, gUnknown_08339DAC, ARRAY_COUNT(gUnknown_08339DAC)); + SetBgAttribute(1, BG_CTRL_ATTR_PALETTEMODE, 1); + SetBgAttribute(2, BG_CTRL_ATTR_PALETTEMODE, 1); + SetBgAttribute(3, BG_CTRL_ATTR_PALETTEMODE, 1); + gUnknown_03005DA0 = AllocZeroed(0x800); + gUnknown_03005D9C = AllocZeroed(0x800); + gUnknown_03005DA4 = AllocZeroed(0x800); + SetBgTilemapBuffer(1, gUnknown_03005DA0); + SetBgTilemapBuffer(2, gUnknown_03005D9C); + SetBgTilemapBuffer(3, gUnknown_03005DA4); + sub_81971D0(); +} + +void overworld_free_bg_tilemaps(void) +{ + sub_81BE72C(); + sub_81971F4(); + if (gUnknown_03005DA4 != NULL) + FREE_AND_SET_NULL(gUnknown_03005DA4); + if (gUnknown_03005D9C != NULL) + FREE_AND_SET_NULL(gUnknown_03005D9C); + if (gUnknown_03005DA0 != NULL) + FREE_AND_SET_NULL(gUnknown_03005DA0); +} + +static void ResetSafariZoneFlag_(void) +{ + ResetSafariZoneFlag(); +} + +bool32 is_c1_link_related_active(void) +{ + if (gMain.callback1 == c1_link_related) + return TRUE; + else + return FALSE; +} + +static void DoCB1_Overworld(u16 newKeys, u16 heldKeys) +{ + struct FieldInput inputStruct; + + sub_808B578(); + FieldClearPlayerInput(&inputStruct); + FieldGetPlayerInput(&inputStruct, newKeys, heldKeys); + if (!ScriptContext2_IsEnabled()) + { + if (sub_809C014(&inputStruct) == 1) + { + ScriptContext2_Enable(); + HideMapNamePopUpWindow(); + } + else + { + player_step(inputStruct.dpadDirection, newKeys, heldKeys); + } + } +} + +void CB1_Overworld(void) +{ + if (gMain.callback2 == CB2_Overworld) + DoCB1_Overworld(gMain.newKeys, gMain.heldKeys); +} + +static void OverworldBasic(void) +{ + ScriptContext2_RunScript(); + RunTasks(); + AnimateSprites(); + CameraUpdate(); + UpdateCameraPanning(); + BuildOamBuffer(); + UpdatePaletteFade(); + sub_80A0A38(); + do_scheduled_bg_tilemap_copies_to_vram(); +} + +// This CB2 is used when starting +void CB2_OverworldBasic(void) +{ + OverworldBasic(); +} + +void CB2_Overworld(void) +{ + bool32 fading = (gPaletteFade.active != 0); + if (fading) + SetVBlankCallback(NULL); + OverworldBasic(); + if (fading) + SetFieldVBlankCallback(); +} + +void SetMainCallback1(MainCallback cb) +{ + gMain.callback1 = cb; +} + +void sub_8085E94(void *a0) +{ + sUnknown_03000E0C = a0; +} + +static bool8 map_post_load_hook_exec(void) +{ + if (gUnknown_03005DB0 != NULL) + { + if (!gUnknown_03005DB0()) + { + return FALSE; + } + else + { + gUnknown_03005DB0 = NULL; + gFieldCallback = NULL; + } + } + else + { + if (gFieldCallback != NULL) + gFieldCallback(); + else + mapldr_default(); + + gFieldCallback = NULL; + } + + return TRUE; +} + +void CB2_NewGame(void) +{ + FieldClearVBlankHBlankCallbacks(); + StopMapMusic(); + ResetSafariZoneFlag_(); + NewGameInitData(); + player_avatar_init_params_reset(); + PlayTimeCounter_Start(); + ScriptContext1_Init(); + ScriptContext2_Disable(); + gFieldCallback = ExecuteTruckSequence; + gUnknown_03005DB0 = NULL; + do_load_map_stuff_loop(&gMain.state); + SetFieldVBlankCallback(); + SetMainCallback1(CB1_Overworld); + SetMainCallback2(CB2_Overworld); +} + +void CB2_WhiteOut(void) +{ + u8 val; + + if (++gMain.state >= 120) + { + FieldClearVBlankHBlankCallbacks(); + StopMapMusic(); + ResetSafariZoneFlag_(); + DoWhiteOut(); + player_avatar_init_params_reset(); + ScriptContext1_Init(); + ScriptContext2_Disable(); + gFieldCallback = sub_80AF3C8; + val = 0; + do_load_map_stuff_loop(&val); + SetFieldVBlankCallback(); + SetMainCallback1(CB1_Overworld); + SetMainCallback2(CB2_Overworld); + } +} + +void CB2_LoadMap(void) +{ + FieldClearVBlankHBlankCallbacks(); + ScriptContext1_Init(); + ScriptContext2_Disable(); + SetMainCallback1(NULL); + SetMainCallback2(c2_change_map); + gMain.savedCallback = CB2_LoadMap2; +} + +static void CB2_LoadMap2(void) +{ + do_load_map_stuff_loop(&gMain.state); + SetFieldVBlankCallback(); + SetMainCallback1(CB1_Overworld); + SetMainCallback2(CB2_Overworld); +} + +void sub_8086024(void) +{ + if (!gMain.state) + { + FieldClearVBlankHBlankCallbacks(); + ScriptContext1_Init(); + ScriptContext2_Disable(); + SetMainCallback1(NULL); + } + if (load_map_stuff(&gMain.state, 1)) + { + SetFieldVBlankCallback(); + SetMainCallback1(CB1_Overworld); + SetMainCallback2(CB2_Overworld); + } +} + +void sub_8086074(void) +{ + FieldClearVBlankHBlankCallbacks(); + gFieldCallback = sub_80AF314; + SetMainCallback2(c2_80567AC); +} + +static void c2_80567AC(void) +{ + if (map_loading_iteration_3(&gMain.state)) + { + SetFieldVBlankCallback(); + SetMainCallback1(c1_link_related); + sub_8086C2C(); + SetMainCallback2(CB2_Overworld); + } +} + +void CB2_ReturnToField(void) +{ + if (is_c1_link_related_active() == TRUE) + { + SetMainCallback2(CB2_ReturnToFieldLink); + } + else + { + FieldClearVBlankHBlankCallbacks(); + SetMainCallback2(CB2_ReturnToFieldLocal); + } +} + +void CB2_ReturnToFieldLocal(void) +{ + if (sub_8086638(&gMain.state)) + { + SetFieldVBlankCallback(); + SetMainCallback2(CB2_Overworld); + } +} + +void CB2_ReturnToFieldLink(void) +{ + if (!sub_8087598() && map_loading_iteration_2_link(&gMain.state)) + SetMainCallback2(CB2_Overworld); +} + +void c2_8056854(void) +{ + FieldClearVBlankHBlankCallbacks(); + StopMapMusic(); + SetMainCallback1(c1_link_related); + sub_8086C2C(); + + if (gWirelessCommType) + gFieldCallback = sub_80AF314; + else + gFieldCallback = sub_80AF214; + + ScriptContext1_Init(); + ScriptContext2_Disable(); + CB2_ReturnToField(); +} + +void CB2_ReturnToFieldWithOpenMenu(void) +{ + FieldClearVBlankHBlankCallbacks(); + gUnknown_03005DB0 = sub_80AF6A4; + CB2_ReturnToField(); +} + +void sub_80861B0(void) +{ + FieldClearVBlankHBlankCallbacks(); + gFieldCallback = sub_80AF188; + CB2_ReturnToField(); +} + +void CB2_ReturnToFieldContinueScript(void) +{ + FieldClearVBlankHBlankCallbacks(); + gFieldCallback = sub_80AF168; + CB2_ReturnToField(); +} + +void sub_80861E8(void) +{ + FieldClearVBlankHBlankCallbacks(); + gFieldCallback = sub_80AF3C8; + CB2_ReturnToField(); +} + +static void sub_8086204(void) +{ + if ((gMapHeader.flags & 0xF8) == 8 && sub_80E909C() == TRUE) + ShowMapNamePopup(); + sub_80AF3C8(); +} + +void CB2_ContinueSavedGame(void) +{ + u8 trainerHillMapId; + + FieldClearVBlankHBlankCallbacks(); + StopMapMusic(); + ResetSafariZoneFlag_(); + if (gSaveFileStatus == 0xFF) + sub_81A3908(); + + LoadSaveblockMapHeader(); + set_warp2_warp3_to_neg_1(); + trainerHillMapId = GetCurrentTrainerHillMapId(); + if (gMapHeader.mapDataId == 0x169) + sub_81AA2F8(); + else if (trainerHillMapId != 0 && trainerHillMapId != 6) + sub_81D5F48(); + else + LoadSaveblockMapObjScripts(); + + UnfreezeMapObjects(); + DoTimeBasedEvents(); + sub_8084788(); + if (gMapHeader.mapDataId == 0x169) + battle_pyramid_map_load_related(1); + else if (trainerHillMapId != 0) + trainer_hill_map_load_related(); + else + sub_8087D74(); + + PlayTimeCounter_Start(); + ScriptContext1_Init(); + ScriptContext2_Disable(); + sub_8195E10(); + if (GetSecretBase2Field_9() == 1) + { + ClearSecretBase2Field_9(); + warp1_set_to_sav1w(); + warp_in(); + sub_80EDB44(); + SetMainCallback2(CB2_LoadMap); + } + else + { + sub_80EDB44(); + gFieldCallback = sub_8086204; + SetMainCallback1(CB1_Overworld); + CB2_ReturnToField(); + } +} + +static void FieldClearVBlankHBlankCallbacks(void) +{ + if (warp0_in_pokecenter() == TRUE) + CloseLink(); + + if (gWirelessCommType != 0) + { + EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_VCOUNT | INTR_FLAG_TIMER3 | INTR_FLAG_SERIAL); + DisableInterrupts(INTR_FLAG_HBLANK); + } + else + { + u16 savedIme = REG_IME; + REG_IME = 0; + REG_IE &= ~INTR_FLAG_HBLANK; + REG_IE |= INTR_FLAG_VBLANK; + REG_IME = savedIme; + } + + SetVBlankCallback(NULL); + SetHBlankCallback(NULL); +} + +static void SetFieldVBlankCallback(void) +{ + SetVBlankCallback(VBlankCB_Field); +} + +static void VBlankCB_Field(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + ScanlineEffect_InitHBlankDmaTransfer(); + FieldUpdateBgTilemapScroll(); + TransferPlttBuffer(); + TransferTilesetAnimsBuffer(); +} + +static void sub_80863B0(void) +{ + u8 val; + + if (sub_81A9E6C()) + { + door_upload_tiles(); + ScanlineEffect_SetParams(gUnknown_08339DBC); + } + else if ((val = Overworld_GetFlashLevel())) + { + sub_80B00E8(val); + ScanlineEffect_SetParams(gUnknown_08339DBC); + } +} + +static bool32 map_loading_iteration_3(u8 *state) +{ + switch (*state) + { + case 0: + overworld_bg_setup(); + ScriptContext1_Init(); + ScriptContext2_Disable(); + sub_80867C8(); + sub_80867D8(); + (*state)++; + break; + case 1: + mli0_load_map(1); + (*state)++; + break; + case 2: + sub_8086988(TRUE); + (*state)++; + break; + case 3: + sub_8086AE4(); + sub_80869DC(); + sub_8086B14(); + sub_8086AAC(); + (*state)++; + break; + case 4: + sub_80863B0(); + map_loading_lcd_reset(); + sub_8197200(); + (*state)++; + break; + case 5: + move_tilemap_camera_to_upper_left_corner(); + (*state)++; + break; + case 6: + copy_map_tileset1_to_vram(gMapHeader.mapData); + (*state)++; + break; + case 7: + copy_map_tileset2_to_vram(gMapHeader.mapData); + (*state)++; + break; + case 8: + if (free_temp_tile_data_buffers_if_possible() != TRUE) + { + apply_map_tileset1_tileset2_palette(gMapHeader.mapData); + (*state)++; + } + break; + case 9: + DrawWholeMapView(); + (*state)++; + break; + case 10: + cur_mapheader_run_tileset_funcs_after_some_cpuset(); + (*state)++; + break; + case 11: + if (gWirelessCommType != 0) + { + sub_800E0E8(); + CreateWirelessStatusIndicatorSprite(0, 0); + } + (*state)++; + break; + case 12: + if (map_post_load_hook_exec()) + (*state)++; + break; + case 13: + return TRUE; + } + + return FALSE; +} + +static bool32 load_map_stuff(u8 *state, u32 a2) +{ + switch (*state) + { + case 0: + FieldClearVBlankHBlankCallbacks(); + mli0_load_map(a2); + (*state)++; + break; + case 1: + sub_80867C8(); + sub_80867D8(); + (*state)++; + break; + case 2: + sub_8086988(a2); + (*state)++; + break; + case 3: + mli4_mapscripts_and_other(); + sub_8086A80(); + (*state)++; + break; + case 4: + sub_80863B0(); + map_loading_lcd_reset(); + sub_8197200(); + (*state)++; + break; + case 5: + move_tilemap_camera_to_upper_left_corner(); + (*state)++; + break; + case 6: + copy_map_tileset1_to_vram(gMapHeader.mapData); + (*state)++; + break; + case 7: + copy_map_tileset2_to_vram(gMapHeader.mapData); + (*state)++; + break; + case 8: + if (free_temp_tile_data_buffers_if_possible() != TRUE) + { + apply_map_tileset1_tileset2_palette(gMapHeader.mapData); + (*state)++; + } + break; + case 9: + DrawWholeMapView(); + (*state)++; + break; + case 10: + cur_mapheader_run_tileset_funcs_after_some_cpuset(); + (*state)++; + break; + case 11: + if ((gMapHeader.flags & 0xF8) == 8 && sub_80E909C() == 1) + ShowMapNamePopup(); + (*state)++; + break; + case 12: + if (map_post_load_hook_exec()) + (*state)++; + break; + case 13: + return TRUE; + } + + return FALSE; +} + +static bool32 sub_8086638(u8 *state) +{ + switch (*state) + { + case 0: + sub_80867C8(); + sub_80867D8(); + sub_8086988(0); + sub_8086A68(); + sub_8086A80(); + (*state)++; + break; + case 1: + sub_8086860(); + sub_81D64C0(); + (*state)++; + break; + case 2: + if (map_post_load_hook_exec()) + (*state)++; + break; + case 3: + return TRUE; + } + + return FALSE; +} + +static bool32 map_loading_iteration_2_link(u8 *state) +{ + switch (*state) + { + case 0: + FieldClearVBlankHBlankCallbacks(); + sub_80867C8(); + sub_80867D8(); + (*state)++; + break; + case 1: + sub_8086988(1); + (*state)++; + break; + case 2: + sub_8086B9C(); + sub_8086A68(); + sub_8086AC8(); + (*state)++; + break; + case 3: + sub_80863B0(); + map_loading_lcd_reset(); + sub_8197200(); + (*state)++; + break; + case 4: + move_tilemap_camera_to_upper_left_corner(); + (*state)++; + break; + case 5: + copy_map_tileset1_to_vram(gMapHeader.mapData); + (*state)++; + break; + case 6: + copy_map_tileset2_to_vram(gMapHeader.mapData); + (*state)++; + break; + case 7: + if (free_temp_tile_data_buffers_if_possible() != TRUE) + { + apply_map_tileset1_tileset2_palette(gMapHeader.mapData); + (*state)++; + } + break; + case 8: + DrawWholeMapView(); + (*state)++; + break; + case 9: + cur_mapheader_run_tileset_funcs_after_some_cpuset(); + (*state)++; + break; + case 11: + if (gWirelessCommType != 0) + { + sub_800E0E8(); + CreateWirelessStatusIndicatorSprite(0, 0); + } + (*state)++; + break; + case 12: + if (map_post_load_hook_exec()) + (*state)++; + break; + case 10: + (*state)++; + break; + case 13: + SetFieldVBlankCallback(); + (*state)++; + return TRUE; + } + + return FALSE; +} + +static void do_load_map_stuff_loop(u8 *state) +{ + while (!load_map_stuff(state, 0)); +} + +static void sub_80867C8(void) +{ + sub_81BE6AC(); + MoveSaveBlocks_ResetHeap(); +} + +static void sub_80867D8(void) +{ + SetGpuReg(REG_OFFSET_DISPCNT, 0); + ScanlineEffect_Stop(); + + DmaClear16(3, PLTT + 2, PLTT_SIZE - 2); + DmaFillLarge16(3, 0, (void *)(VRAM + 0x0), 0x18000, 0x1000); + ResetOamRange(0, 128); + LoadOam(); +} + +static void sub_8086860(void) +{ + sub_80863B0(); + map_loading_lcd_reset(); + sub_8197200(); + mapdata_load_assets_to_gpu_and_full_redraw(); +} + +static void map_loading_lcd_reset(void) +{ + clear_scheduled_bg_copies_to_vram(); + reset_temp_tile_data_buffers(); + SetGpuReg(REG_OFFSET_MOSAIC, 0); + SetGpuReg(REG_OFFSET_WININ, 0x1F1F); + SetGpuReg(REG_OFFSET_WINOUT, 0x101); + SetGpuReg(REG_OFFSET_WIN0H, 0xFF); + SetGpuReg(REG_OFFSET_WIN0V, 0xFF); + SetGpuReg(REG_OFFSET_WIN1H, 0xFFFF); + SetGpuReg(REG_OFFSET_WIN1V, 0xFFFF); + SetGpuReg(REG_OFFSET_BLDCNT, gUnknown_82EC7C4[1] | gUnknown_82EC7C4[2] | gUnknown_82EC7C4[3] | 0x1040); + SetGpuReg(REG_OFFSET_BLDALPHA, 0x70D); + overworld_bg_setup(); + schedule_bg_copy_tilemap_to_vram(1); + schedule_bg_copy_tilemap_to_vram(2); + schedule_bg_copy_tilemap_to_vram(3); + ChangeBgX(0, 0, 0); + ChangeBgY(0, 0, 0); + ChangeBgX(1, 0, 0); + ChangeBgY(1, 0, 0); + ChangeBgX(2, 0, 0); + ChangeBgY(2, 0, 0); + ChangeBgX(3, 0, 0); + ChangeBgY(3, 0, 0); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_WIN0_ON | DISPCNT_WIN1_ON | DISPCNT_OBJ_1D_MAP | 0x20); + ShowBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); + sub_8098128(); +} + +static void sub_8086988(u32 a1) +{ + ResetTasks(); + ResetSpriteData(); + ResetPaletteFade(); + ScanlineEffect_Clear(); + dp13_810BB8C(); + ResetCameraUpdateInfo(); + InstallCameraPanAheadCallback(); + if (!a1) + npc_paltag_set_load(0); + else + npc_paltag_set_load(1); + + FieldEffectActiveListClear(); + sub_80AAFA4(); + sub_80AEE84(); + if (!a1) + SetUpFieldTasks(); + mapheader_run_script_with_tag_x5(); + sub_81BE6B8(); +} + +static void sub_80869DC(void) +{ + gUnknown_03005DEC = 0; + gUnknown_03005DE8 = 0; + sub_808D438(); + SpawnFieldObjectsInView(0, 0); + mapheader_run_first_tag4_script_list_match(); +} + +static void mli4_mapscripts_and_other(void) +{ + s16 x, y; + struct UnkPlayerStruct *player; + + gUnknown_03005DEC = 0; + gUnknown_03005DE8 = 0; + sub_808D438(); + sav1_camera_get_focus_coords(&x, &y); + player = sub_80852D4(); + InitPlayerAvatar(x, y, player->player_field_1, gSaveBlock2Ptr->playerGender); + SetPlayerAvatarTransitionFlags(player->player_field_0); + player_avatar_init_params_reset(); + SpawnFieldObjectsInView(0, 0); + mapheader_run_first_tag4_script_list_match(); +} + +static void sub_8086A68(void) +{ + sub_808E16C(0, 0); + RotatingGate_InitPuzzleAndGraphics(); + mapheader_run_script_with_tag_x7(); +} + +static void sub_8086A80(void) +{ + gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_15 = 1; + InitCameraUpdateCallback(gPlayerAvatar.spriteId); +} + +static void sub_8086AAC(void) +{ + InitCameraUpdateCallback(sub_8087858(gUnknown_03005DB4)); +} + +static void sub_8086AC8(void) +{ + InitCameraUpdateCallback(sub_8087858(gUnknown_03005DB4)); +} + +static void sub_8086AE4(void) +{ + u16 x, y; + sav1_camera_get_focus_coords(&x, &y); + sub_8088B3C(x + gUnknown_03005DB4, y); +} + +static void sub_8086B14(void) +{ + u16 i; + u16 x, y; + + sav1_camera_get_focus_coords(&x, &y); + x -= gUnknown_03005DB4; + + for (i = 0; i < gFieldLinkPlayerCount; i++) + { + SpawnLinkPlayerMapObject(i, i + x, y, gLinkPlayers[i].gender); + CreateLinkPlayerSprite(i, gLinkPlayers[i].version); + } + + sub_8086C40(); +} + +static void sub_8086B9C(void) +{ + u16 i; + for (i = 0; i < gFieldLinkPlayerCount; i++) + CreateLinkPlayerSprite(i, gLinkPlayers[i].version); +} + +static void c1_link_related(void) +{ + if (gWirelessCommType == 0 || !sub_800F0B8() || !sub_8009F3C()) + { + u8 var = gUnknown_03005DB4; + sub_8086F38(gLinkPartnersHeldKeys, var); + sub_8086FA0(sUnknown_03000E14(var)); + sub_8086C40(); + } +} + +void sub_8086C2C(void) +{ + sub_8086C90(); + c1_link_related_func_set(sub_80870B0); +} + +static void sub_8086C40(void) +{ + sub_808709C(gLinkPartnersHeldKeys); +} + +static void c1_link_related_func_set(u16 (*func)(u32)) +{ + sUnknown_03000E19 = 0; + sUnknown_03000E14 = func; +} + +static void sub_8086C64(void) +{ + if (gWirelessCommType != 0) + { + if (++sUnknown_03000E19 > 60) + sub_8010198(); + } +} + +static void sub_8086C90(void) +{ + s32 i; + for (i = 0; i < 4; i++) + sUnknown_03000E10[i] = 0x80; +} + +static bool32 sub_8086CA8(u16 a1) +{ + s32 i; + s32 count = gFieldLinkPlayerCount; + + for (i = 0; i < count; i++) + if (sUnknown_03000E10[i] != a1) + return FALSE; + return TRUE; +} + +static bool32 sub_8086CE0(u16 a1) +{ + s32 i; + s32 count = gFieldLinkPlayerCount; + + for (i = 0; i < count; i++) + if (sUnknown_03000E10[i] == a1) + return TRUE; + return FALSE; +} + +static void sub_8086D18(u32 a1, u16 a2, struct UnkStruct_8054FF8 *a3, u16 *a4) +{ + const u8 *script; + + if (sUnknown_03000E10[a1] == 0x80) + { + script = sub_8087370(a3); + if (script) + { + *a4 = sub_8087480(script); + sUnknown_03000E10[a1] = 0x81; + if (a3->b) + { + c1_link_related_func_set(sub_80870F8); + sub_8087530(script); + } + return; + } + if (sub_8086CE0(0x83) == 1) + { + sUnknown_03000E10[a1] = 0x81; + if (a3->b) + { + c1_link_related_func_set(sub_80870F8); + sub_8087584(); + } + return; + } + switch (a2) + { + case 24: + if (sub_8087358(a3)) + { + sUnknown_03000E10[a1] = 0x81; + if (a3->b) + { + c1_link_related_func_set(sub_80870F8); + sub_808751C(); + } + } + break; + case 18: + if (sub_8087388(a3) == TRUE) + { + sUnknown_03000E10[a1] = 0x81; + if (a3->b) + { + c1_link_related_func_set(sub_80870F8); + sub_808754C(); + } + } + break; + case 25: + script = sub_80873B4(a3); + if (script) + { + sUnknown_03000E10[a1] = 0x81; + if (a3->b) + { + c1_link_related_func_set(sub_80870F8); + sub_8087568(script); + } + } + break; + case 27: + if (sub_8087340(a3)) + { + sUnknown_03000E10[a1] = 0x81; + if (a3->b) + { + c1_link_related_func_set(sub_808711C); + sub_8087510(); + } + } + break; + case 28: + if (sub_8087340(a3)) + { + sUnknown_03000E10[a1] = 0x81; + if (a3->b) + { + c1_link_related_func_set(sub_8087140); + sub_8087510(); + } + } + break; + } + } + + switch (a2) + { + case 23: + sUnknown_03000E10[a1] = 0x83; + break; + case 22: + sUnknown_03000E10[a1] = 0x82; + break; + case 26: + sUnknown_03000E10[a1] = 0x80; + if (a3->b) + c1_link_related_func_set(sub_80870B0); + break; + case 29: + if (sUnknown_03000E10[a1] == 0x82) + sUnknown_03000E10[a1] = 0x81; + break; + } +} + +static void sub_8086F38(u16 *a1, s32 a2) +{ + struct UnkStruct_8054FF8 st; + s32 i; + + for (i = 0; i < 4; i++) + { + u8 v5 = a1[i]; + u16 v8 = 0; + sub_80872D8(i, a2, &st); + sub_8086D18(i, v5, &st, &v8); + if (sUnknown_03000E10[i] == 0x80) + v8 = sub_8087068(v5); + sub_808796C(i, v8); + } +} + +static void sub_8086FA0(u16 a1) +{ + if (a1 >= 17 && a1 < 30) + gUnknown_03005DA8 = a1; + else + gUnknown_03005DA8 = 17; + + if (gWirelessCommType != 0 + && sub_8087690() > 1 + && is_c1_link_related_active() == TRUE + && sub_8009F3C() == TRUE) + { + switch (a1) + { + case 17: + case 18: + case 19: + case 20: + case 21: + case 24: + case 25: + gUnknown_03005DA8 = 0; + break; + } + } +} + +static u16 sub_808700C(u32 a1) +{ + if (gMain.heldKeys & DPAD_UP) + return 19; + else if (gMain.heldKeys & DPAD_DOWN) + return 18; + else if (gMain.heldKeys & DPAD_LEFT) + return 20; + else if (gMain.heldKeys & DPAD_RIGHT) + return 21; + else if (gMain.newKeys & START_BUTTON) + return 24; + else if (gMain.newKeys & A_BUTTON) + return 25; + else + return 17; +} + +static u16 sub_8087068(u16 a1) +{ + switch (a1) + { + case 21: + return 4; + case 20: + return 3; + case 19: + return 1; + case 18: + return 2; + default: + return 0; + } +} + +static void sub_808709C(u16 *a1) +{ + s32 i; + for (i = 0; i < 4; i++) + a1[i] = 17; +} + +static u16 sub_80870B0(u32 a1) +{ + if (ScriptContext2_IsEnabled() == 1) + return 17; + if (sub_800B4DC() > 4) + return 27; + if (sub_8087690() <= 4) + return sub_808700C(a1); + return 28; +} + +static u16 sub_80870EC(u32 a1) +{ + sub_8086C64(); + return 17; +} + +static u16 sub_80870F8(u32 a1) +{ + u16 retVal; + if (ScriptContext2_IsEnabled() == TRUE) + { + retVal = 17; + } + else + { + retVal = 26; + c1_link_related_func_set(sub_80870EC); + } + return retVal; +} + +static u16 sub_808711C(u32 a1) +{ + u16 retVal; + if (sub_800B4DC() > 2) + { + retVal = 17; + } + else + { + retVal = 26; + ScriptContext2_Disable(); + c1_link_related_func_set(sub_80870EC); + } + return retVal; +} + +static u16 sub_8087140(u32 a1) +{ + u16 retVal; + if (sub_8087690() > 2) + { + retVal = 17; + } + else + { + retVal = 26; + ScriptContext2_Disable(); + c1_link_related_func_set(sub_80870EC); + } + return retVal; +} + +static u16 sub_8087164(u32 a1) +{ + sub_8086C64(); + return 17; +} + +static u16 sub_8087170(u32 linkPlayerId) +{ + if (sUnknown_03000E10[linkPlayerId] == 0x82) + { + if (gMain.newKeys & B_BUTTON) + { + c1_link_related_func_set(sub_8087164); + return 29; + } + else + { + return 17; + } + } + else + { + sub_8086C64(); + return 17; + } +} + +static u16 sub_80871AC(u32 a1) +{ + c1_link_related_func_set(sub_8087170); + return 22; +} + +static u16 sub_80871C0(u32 a1) +{ + return 17; +} + +static u16 sub_80871C4(u32 a1) +{ + if (sUnknown_03000E10[a1] != 0x83) + sub_8086C64(); + if (sub_8086CA8(0x83) == TRUE) + { + ScriptContext1_SetupScript(EventScript_277513); + c1_link_related_func_set(sub_80871C0); + } + return 17; +} + +static u16 sub_80871FC(u32 a1) +{ + c1_link_related_func_set(sub_80871C4); + return 23; +} + +static u16 sub_8087210(u32 a1) +{ + return 17; +} + +u32 sub_8087214(void) +{ + if (sub_8086CE0(0x83) == TRUE) + return 2; + if (sUnknown_03000E14 == sub_8087170 && sUnknown_03000E10[gUnknown_03005DB4] != 0x82) + return 0; + if (sUnknown_03000E14 == sub_8087164 && sUnknown_03000E10[gUnknown_03005DB4] == 0x81) + return 2; + if (sub_8086CA8(0x82) != 0) + return 1; + return 0; +} + +bool32 sub_808727C(void) +{ + return sub_8086CE0(0x83); +} + +u16 sub_8087288(void) +{ + c1_link_related_func_set(sub_80871AC); + return 0; +} + +u16 sub_808729C(void) +{ + c1_link_related_func_set(sub_80870F8); + return 0; +} + +u16 sub_80872B0(void) +{ + c1_link_related_func_set(sub_80871FC); + return 0; +} + +u16 sub_80872C4(void) +{ + c1_link_related_func_set(sub_8087210); + return 0; +} + +static void sub_80872D8(s32 linkPlayerId, s32 a2, struct UnkStruct_8054FF8 *a3) +{ + s16 x, y; + + a3->a = linkPlayerId; + a3->b = (linkPlayerId == a2) ? 1 : 0; + a3->c = gLinkPlayerMapObjects[linkPlayerId].mode; + a3->d = sub_80878A0(linkPlayerId); + sub_8087878(linkPlayerId, &x, &y); + a3->sub.x = x; + a3->sub.y = y; + a3->sub.height = sub_80878C0(linkPlayerId); + a3->field_C = MapGridGetMetatileBehaviorAt(x, y); +} + +static bool32 sub_8087340(struct UnkStruct_8054FF8 *a1) +{ + u8 v1 = a1->c; + if (v1 == 2 || v1 == 0) + return TRUE; + else + return FALSE; +} + +static bool32 sub_8087358(struct UnkStruct_8054FF8 *a1) +{ + u8 v1 = a1->c; + if (v1 == 2 || v1 == 0) + return TRUE; + else + return FALSE; +} + +static u8 *sub_8087370(struct UnkStruct_8054FF8 *a1) +{ + if (a1->c != 2) + return 0; + return sub_809D0F4(&a1->sub); +} + +static bool32 sub_8087388(struct UnkStruct_8054FF8 *a1) +{ + if (a1->c != 2 && a1->c != 0) + return FALSE; + if (!MetatileBehavior_IsSouthArrowWarp(a1->field_C)) + return FALSE; + if (a1->d != 1) + return FALSE; + return TRUE; +} + +static const u8 *sub_80873B4(struct UnkStruct_8054FF8 *a1) +{ + struct MapPosition unkStruct; + u8 linkPlayerId; + + if (a1->c && a1->c != 2) + return 0; + + unkStruct = a1->sub; + unkStruct.x += gUnknown_08339D64[a1->d].x; + unkStruct.y += gUnknown_08339D64[a1->d].y; + unkStruct.height = 0; + linkPlayerId = GetLinkPlayerIdAt(unkStruct.x, unkStruct.y); + + if (linkPlayerId != 4) + { + if (!a1->b) + return EventScript_TradeRoom_TooBusyToNotice; + if (sUnknown_03000E10[linkPlayerId] != 0x80) + return EventScript_TradeRoom_TooBusyToNotice; + if (!sub_80B39D4(linkPlayerId)) + return EventScript_TradeRoom_ReadTrainerCard1; + else + return EventScript_TradeRoom_ReadTrainerCard2; + } + + return sub_809C2C8(&unkStruct, a1->field_C, a1->d); +} + +static u16 sub_8087480(const u8 *script) +{ + if (script == gUnknown_08277388) + return 10; + if (script == gUnknown_082773A3) + return 9; + if (script == gUnknown_082773BE) + return 10; + if (script == gUnknown_082773D9) + return 9; + if (script == gUnknown_0827741D) + return 10; + if (script == gUnknown_08277432) + return 9; + if (script == gUnknown_08277447) + return 10; + if (script == gUnknown_0827745C) + return 9; + if (script == gUnknown_08277374) + return 10; + if (script == gUnknown_0827737E) + return 9; + if (script == gUnknown_082773F5) + return 10; + if (script == gUnknown_082773FF) + return 9; + return 0; +} + +static void sub_8087510(void) +{ + ScriptContext2_Enable(); +} + +static void sub_808751C(void) +{ + PlaySE(SE_WIN_OPEN); + sub_809FA9C(); + ScriptContext2_Enable(); +} + +static void sub_8087530(const u8 *script) +{ + PlaySE(SE_SELECT); + ScriptContext1_SetupScript(script); + ScriptContext2_Enable(); +} + +static void sub_808754C(void) +{ + PlaySE(SE_WIN_OPEN); + ScriptContext1_SetupScript(gUnknown_082774EF); + ScriptContext2_Enable(); +} + +static void sub_8087568(const u8 *script) +{ + PlaySE(SE_SELECT); + ScriptContext1_SetupScript(script); + ScriptContext2_Enable(); +} + +static void sub_8087584(void) +{ + ScriptContext1_SetupScript(gUnknown_08277509); + ScriptContext2_Enable(); +} + +bool32 sub_8087598(void) +{ + if (!is_c1_link_related_active()) + return 0; + if (sub_800B4DC() >= 3) + sUnknown_03000E18 = 1; + else + sUnknown_03000E18 = 0; + return sUnknown_03000E18; +} + +bool32 sub_80875C8(void) +{ + u8 temp; + + if (sub_800B4DC() < 2) + return FALSE; + + if (is_c1_link_related_active() != TRUE) + return FALSE; + + if (sub_8009F3C() != TRUE) + return FALSE; + + if (sUnknown_03000E14 == sub_808711C) + return TRUE; + + if (sUnknown_03000E14 != sub_80870F8) + return FALSE; + + temp = sUnknown_03000E18; + sUnknown_03000E18 = 0; + + if (temp == TRUE) + return TRUE; + + if (gPaletteFade.active && gPaletteFade.softwareFadeFinishing) + return TRUE; + + return FALSE; +} + +bool32 sub_8087634(void) +{ + if (sub_8087690() < 2) + return FALSE; + + if (is_c1_link_related_active() != TRUE) + return FALSE; + + if (sub_8009F3C() != TRUE) + return FALSE; + + if (sUnknown_03000E14 == sub_8087140) + return TRUE; + + return FALSE; +} + +bool32 sub_808766C(void) +{ + if (gWirelessCommType != 0) + return FALSE; + if (!sub_8009F3C()) + return FALSE; + return TRUE; +} + +static u32 sub_8087690(void) +{ + if (gWirelessCommType != 0) + return gUnknown_03005000.unk_9e8.unk_232; + else + return gLink.sendQueue.count; +} + +static void ZeroLinkPlayerMapObject(struct LinkPlayerMapObject *linkPlayerMapObj) +{ + memset(linkPlayerMapObj, 0, sizeof(struct LinkPlayerMapObject)); +} + +void ZeroAllLinkPlayerMapObjects(void) +{ + memset(gLinkPlayerMapObjects, 0, sizeof(gLinkPlayerMapObjects)); +} + +static void ZeroMapObject(struct MapObject *mapObj) +{ + memset(mapObj, 0, sizeof(struct MapObject)); +} + +static void SpawnLinkPlayerMapObject(u8 linkPlayerId, s16 x, s16 y, u8 a4) +{ + u8 mapObjId = sub_808D4F4(); + struct LinkPlayerMapObject *linkPlayerMapObj = &gLinkPlayerMapObjects[linkPlayerId]; + struct MapObject *mapObj = &gMapObjects[mapObjId]; + + ZeroLinkPlayerMapObject(linkPlayerMapObj); + ZeroMapObject(mapObj); + + linkPlayerMapObj->active = 1; + linkPlayerMapObj->linkPlayerId = linkPlayerId; + linkPlayerMapObj->mapObjId = mapObjId; + linkPlayerMapObj->mode = 0; + + mapObj->active = 1; + mapObj->mapobj_bit_1 = a4; + mapObj->range.as_byte = 2; + mapObj->spriteId = 64; + + InitLinkPlayerMapObjectPos(mapObj, x, y); +} + +static void InitLinkPlayerMapObjectPos(struct MapObject *mapObj, s16 x, s16 y) +{ + mapObj->coords2.x = x; + mapObj->coords2.y = y; + mapObj->coords3.x = x; + mapObj->coords3.y = y; + sub_8093038(x, y, &mapObj->coords1.x, &mapObj->coords1.y); + mapObj->coords1.x += 8; + FieldObjectUpdateZCoord(mapObj); +} + +static void sub_80877DC(u8 linkPlayerId, u8 a2) +{ + if (gLinkPlayerMapObjects[linkPlayerId].active) + { + u8 mapObjId = gLinkPlayerMapObjects[linkPlayerId].mapObjId; + struct MapObject *mapObj = &gMapObjects[mapObjId]; + mapObj->range.as_byte = a2; + } +} + +static void sub_808780C(u8 linkPlayerId) +{ + struct LinkPlayerMapObject *linkPlayerMapObj = &gLinkPlayerMapObjects[linkPlayerId]; + u8 mapObjId = linkPlayerMapObj->mapObjId; + struct MapObject *mapObj = &gMapObjects[mapObjId]; + if (mapObj->spriteId != 64 ) + DestroySprite(&gSprites[mapObj->spriteId]); + linkPlayerMapObj->active = 0; + mapObj->active = 0; +} + +static u8 sub_8087858(u8 linkPlayerId) +{ + u8 mapObjId = gLinkPlayerMapObjects[linkPlayerId].mapObjId; + struct MapObject *mapObj = &gMapObjects[mapObjId]; + return mapObj->spriteId; +} + +static void sub_8087878(u8 linkPlayerId, u16 *x, u16 *y) +{ + u8 mapObjId = gLinkPlayerMapObjects[linkPlayerId].mapObjId; + struct MapObject *mapObj = &gMapObjects[mapObjId]; + *x = mapObj->coords2.x; + *y = mapObj->coords2.y; +} + +static u8 sub_80878A0(u8 linkPlayerId) +{ + u8 mapObjId = gLinkPlayerMapObjects[linkPlayerId].mapObjId; + struct MapObject *mapObj = &gMapObjects[mapObjId]; + return mapObj->range.as_byte; +} + +static u8 sub_80878C0(u8 linkPlayerId) +{ + u8 mapObjId = gLinkPlayerMapObjects[linkPlayerId].mapObjId; + struct MapObject *mapObj = &gMapObjects[mapObjId]; + return mapObj->mapobj_unk_0B_0; +} + +static s32 sub_80878E4(u8 linkPlayerId) +{ + u8 mapObjId = gLinkPlayerMapObjects[linkPlayerId].mapObjId; + struct MapObject *mapObj = &gMapObjects[mapObjId]; + return 16 - (s8)mapObj->mapobj_unk_21; +} + +static u8 GetLinkPlayerIdAt(s16 x, s16 y) +{ + u8 i; + for (i = 0; i < 4; i++) + { + if (gLinkPlayerMapObjects[i].active + && (gLinkPlayerMapObjects[i].mode == 0 || gLinkPlayerMapObjects[i].mode == 2)) + { + struct MapObject *mapObj = &gMapObjects[gLinkPlayerMapObjects[i].mapObjId]; + if (mapObj->coords2.x == x && mapObj->coords2.y == y) + return i; + } + } + return 4; +} + +static void sub_808796C(u8 linkPlayerId, u8 a2) +{ + struct LinkPlayerMapObject *linkPlayerMapObj = &gLinkPlayerMapObjects[linkPlayerId]; + u8 mapObjId = linkPlayerMapObj->mapObjId; + struct MapObject *mapObj = &gMapObjects[mapObjId]; + + if (linkPlayerMapObj->active) + { + if (a2 > 10) + mapObj->mapobj_bit_2 = 1; + else + gUnknown_08339E00[gUnknown_08339DC8[linkPlayerMapObj->mode](linkPlayerMapObj, mapObj, a2)](linkPlayerMapObj, mapObj); + } +} + +static u8 sub_80879D8(struct LinkPlayerMapObject *linkPlayerMapObj, struct MapObject *mapObj, u8 a3) +{ + return gUnknown_08339DD4[a3](linkPlayerMapObj, mapObj, a3); +} + +static u8 sub_80879F8(struct LinkPlayerMapObject *linkPlayerMapObj, struct MapObject *mapObj, u8 a3) +{ + return 1; +} + +static u8 sub_80879FC(struct LinkPlayerMapObject *linkPlayerMapObj, struct MapObject *mapObj, u8 a3) +{ + return gUnknown_08339DD4[a3](linkPlayerMapObj, mapObj, a3); +} + +static u8 sub_8087A1C(struct LinkPlayerMapObject *linkPlayerMapObj, struct MapObject *mapObj, u8 a3) +{ + return 0; +} + +static u8 sub_8087A20(struct LinkPlayerMapObject *linkPlayerMapObj, struct MapObject *mapObj, u8 a3) +{ + s16 x, y; + + mapObj->range.as_byte = npc_something3(a3, mapObj->range.as_byte); + FieldObjectMoveDestCoords(mapObj, mapObj->range.as_byte, &x, &y); + + if (LinkPlayerDetectCollision(linkPlayerMapObj->mapObjId, mapObj->range.as_byte, x, y)) + { + return 0; + } + else + { + mapObj->mapobj_unk_21 = 16; + npc_coords_shift(mapObj, x, y); + FieldObjectUpdateZCoord(mapObj); + return 1; + } +} + +static u8 sub_8087A88(struct LinkPlayerMapObject *linkPlayerMapObj, struct MapObject *mapObj, u8 a3) +{ + mapObj->range.as_byte = npc_something3(a3, mapObj->range.as_byte); + return 0; +} + +static void sub_8087AA0(struct LinkPlayerMapObject *linkPlayerMapObj, struct MapObject *mapObj) +{ + linkPlayerMapObj->mode = 0; +} + +static void sub_8087AA8(struct LinkPlayerMapObject *linkPlayerMapObj, struct MapObject *mapObj) +{ + mapObj->mapobj_unk_21--; + linkPlayerMapObj->mode = 1; + MoveCoords(mapObj->range.as_byte, &mapObj->coords1.x, &mapObj->coords1.y); + if (!mapObj->mapobj_unk_21) + { + npc_coords_shift_still(mapObj); + linkPlayerMapObj->mode = 2; + } +} + +static u8 npc_something3(u8 a1, u8 a2) +{ + switch (a1 - 1) + { + case 0: + case 6: + return 2; + case 1: + case 7: + return 1; + case 2: + case 8: + return 3; + case 3: + case 9: + return 4; + } + return a2; +} + +static u8 LinkPlayerDetectCollision(u8 selfMapObjId, u8 a2, s16 x, s16 y) +{ + u8 i; + for (i = 0; i < 16; i++) + { + if (i != selfMapObjId) + { + if ((gMapObjects[i].coords2.x == x && gMapObjects[i].coords2.y == y) + || (gMapObjects[i].coords3.x == x && gMapObjects[i].coords3.y == y)) + { + return 1; + } + } + } + return MapGridIsImpassableAt(x, y); +} + +static void CreateLinkPlayerSprite(u8 linkPlayerId, u8 gameVersion) +{ + struct LinkPlayerMapObject *linkPlayerMapObj = &gLinkPlayerMapObjects[linkPlayerId]; + u8 mapObjId = linkPlayerMapObj->mapObjId; + struct MapObject *mapObj = &gMapObjects[mapObjId]; + struct Sprite *sprite; + + if (linkPlayerMapObj->active) + { + switch (gameVersion) + { + case VERSION_FIRE_RED: + case VERSION_LEAF_GREEN: + mapObj->spriteId = AddPseudoFieldObject(sub_808BD6C(mapObj->mapobj_bit_1), SpriteCB_LinkPlayer, 0, 0, 0); + break; + case VERSION_RUBY: + case VERSION_SAPPHIRE: + mapObj->spriteId = AddPseudoFieldObject(sub_808BD7C(mapObj->mapobj_bit_1), SpriteCB_LinkPlayer, 0, 0, 0); + break; + case VERSION_EMERALD: + mapObj->spriteId = AddPseudoFieldObject(GetRivalAvatarGraphicsIdByStateIdAndGender(0, mapObj->mapobj_bit_1), SpriteCB_LinkPlayer, 0, 0, 0); + break; + } + + sprite = &gSprites[mapObj->spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->data[0] = linkPlayerId; + mapObj->mapobj_bit_2 = 0; + } +} + +static void SpriteCB_LinkPlayer(struct Sprite *sprite) +{ + struct LinkPlayerMapObject *linkPlayerMapObj = &gLinkPlayerMapObjects[sprite->data[0]]; + struct MapObject *mapObj = &gMapObjects[linkPlayerMapObj->mapObjId]; + sprite->pos1.x = mapObj->coords1.x; + sprite->pos1.y = mapObj->coords1.y; + SetObjectSubpriorityByZCoord(mapObj->elevation, sprite, 1); + sprite->oam.priority = ZCoordToPriority(mapObj->elevation); + + if (!linkPlayerMapObj->mode) + StartSpriteAnim(sprite, FieldObjectDirectionToImageAnimId(mapObj->range.as_byte)); + else + StartSpriteAnimIfDifferent(sprite, get_go_image_anim_num(mapObj->range.as_byte)); + + sub_80979D4(sprite, 0); + if (mapObj->mapobj_bit_2) + { + sprite->invisible = ((sprite->data[7] & 4) >> 2); + sprite->data[7]++; + } +} diff --git a/src/pokeblock.c b/src/pokeblock.c index b9d1d94c6..b9a1f6bf3 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -74,7 +74,7 @@ extern void (*gFieldCallback)(void); extern const u16 gUnknown_0860F074[]; -extern void c2_exit_to_overworld_2_switch(void); +extern void CB2_ReturnToField(void); extern bool8 sub_81221EC(void); extern void sub_809882C(u8, u16, u8); extern void copy_textbox_border_tile_patterns_to_vram(u8, u16, u8); @@ -374,7 +374,7 @@ void OpenPokeblockCaseInBattle(void) void OpenPokeblockCaseOnFeeder(void) { - OpenPokeblockCase(PBLOCK_CASE_FEEDER, c2_exit_to_overworld_2_switch); + OpenPokeblockCase(PBLOCK_CASE_FEEDER, CB2_ReturnToField); } static void CB2_PokeblockMenu(void) diff --git a/src/region_map.c b/src/region_map.c index 7f121d1de..f16787fc9 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -1581,7 +1581,7 @@ void MCB2_FlyMap(void) gUnknown_0203A148 = malloc(sizeof(*gUnknown_0203A148)); if (gUnknown_0203A148 == NULL) { - SetMainCallback2(sub_8086194); + SetMainCallback2(CB2_ReturnToFieldWithOpenMenu); } else { diff --git a/src/reset_save_heap.c b/src/reset_save_heap.c index 9950f6691..50692d356 100644 --- a/src/reset_save_heap.c +++ b/src/reset_save_heap.c @@ -26,5 +26,5 @@ void sub_81700F8(void) Sav2_ClearSetDefault(); SetPokemonCryStereo(gSaveBlock2Ptr->optionsSound); InitHeap(gHeap, HEAP_SIZE); - SetMainCallback2(sub_8086230); + SetMainCallback2(CB2_ContinueSavedGame); } diff --git a/src/safari_zone.c b/src/safari_zone.c index dd3cf3733..ab5c38f3a 100644 --- a/src/safari_zone.c +++ b/src/safari_zone.c @@ -30,9 +30,9 @@ extern void sub_80EE44C(u8, u8); extern void IncrementGameStat(u8 index); extern void ScriptContext1_SetupScript(u8*); extern void ScriptContext2_RunNewScript(u8*); -extern void c2_exit_to_overworld_2_switch(void); -extern void c2_exit_to_overworld_1_continue_scripts_restart_music(void); -extern void c2_load_new_map(void); +extern void CB2_ReturnToField(void); +extern void CB2_ReturnToFieldContinueScript(void); +extern void CB2_LoadMap(void); extern void sub_80AF6F0(void); extern void ScriptContext1_Stop(void); extern void warp_in(void); @@ -112,20 +112,20 @@ void CB2_EndSafariBattle(void) sSafariZoneCaughtMons++; if (gNumSafariBalls != 0) { - SetMainCallback2(c2_exit_to_overworld_2_switch); + SetMainCallback2(CB2_ReturnToField); } else if (gBattleOutcome == B_OUTCOME_NO_SAFARI_BALLS) { ScriptContext2_RunNewScript(EventScript_2A4B4C); warp_in(); gFieldCallback = sub_80AF6F0; - SetMainCallback2(c2_load_new_map); + SetMainCallback2(CB2_LoadMap); } else if (gBattleOutcome == B_OUTCOME_CAUGHT) { ScriptContext1_SetupScript(EventScript_2A4B9B); ScriptContext1_Stop(); - SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); + SetMainCallback2(CB2_ReturnToFieldContinueScript); } } diff --git a/src/scrcmd.c b/src/scrcmd.c index deb170c68..ef3fcbcac 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -2054,7 +2054,7 @@ bool8 ScrCmd_playslotmachine(struct ScriptContext *ctx) { u8 slotMachineIndex = VarGet(ScriptReadHalfword(ctx)); - PlaySlotMachine(slotMachineIndex, c2_exit_to_overworld_1_continue_scripts_restart_music); + PlaySlotMachine(slotMachineIndex, CB2_ReturnToFieldContinueScript); ScriptContext1_Stop(); return TRUE; } diff --git a/src/secret_base.c b/src/secret_base.c index e3c06a75d..63787c43c 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -386,7 +386,7 @@ void sub_80E8FD0(u8 taskId) sub_80E8F9C(); warp_in(); gFieldCallback = sub_80AF168; - SetMainCallback2(c2_load_new_map); + SetMainCallback2(CB2_LoadMap); DestroyTask(taskId); break; } @@ -444,7 +444,7 @@ void sub_80E916C(u8 taskId) Overworld_SetWarpDestination(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, gUnknown_0858CFE8[idx + 2], gUnknown_0858CFE8[idx + 3]); warp_in(); gFieldCallback = sub_80E9108; - SetMainCallback2(c2_load_new_map); + SetMainCallback2(CB2_LoadMap); DestroyTask(taskId); } } @@ -642,7 +642,7 @@ void sub_80E96A4(u8 taskId) copy_saved_warp2_bank_and_enter_x_to_warp1(0x7e); warp_in(); gFieldCallback = mapldr_default; - SetMainCallback2(c2_load_new_map); + SetMainCallback2(CB2_LoadMap); ScriptContext2_Disable(); DestroyTask(taskId); break; diff --git a/src/tv.c b/src/tv.c index fbe39fde0..d3fb20f79 100644 --- a/src/tv.c +++ b/src/tv.c @@ -3633,7 +3633,7 @@ void ChangePokemonNickname(void) void ChangePokemonNickname_CB(void) { SetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_NICKNAME, gStringVar2); - c2_exit_to_overworld_1_continue_scripts_restart_music(); + CB2_ReturnToFieldContinueScript(); } void ChangeBoxPokemonNickname(void) @@ -3649,7 +3649,7 @@ void ChangeBoxPokemonNickname(void) void ChangeBoxPokemonNickname_CB(void) { SetBoxMonNickFromAnyBox(gSpecialVar_MonBoxId, gSpecialVar_MonBoxPos, gStringVar2); - c2_exit_to_overworld_1_continue_scripts_restart_music(); + CB2_ReturnToFieldContinueScript(); } void TV_CopyNicknameToStringVar1AndEnsureTerminated(void) diff --git a/src/walda_phrase.c b/src/walda_phrase.c index 59fd3fedb..04789bfb5 100644 --- a/src/walda_phrase.c +++ b/src/walda_phrase.c @@ -14,7 +14,7 @@ extern const u8 gText_Peekaboo[]; extern u8 *GetWaldaPhrasePtr(void); extern bool32 IsWaldaPhraseEmpty(void); extern void sub_80AF168(void); -extern void c2_exit_to_overworld_2_switch(void); +extern void CB2_ReturnToField(void); extern void SetWaldaPhrase(const u8 *src); extern void SetWaldaWallpaperPatternId(u8 patternId); extern void SetWaldaWallpaperIconId(u8 iconId); @@ -80,7 +80,7 @@ static void CB2_HandleGivenWaldaPhrase(void) StringCopy(gStringVar1, GetWaldaPhrasePtr()); gFieldCallback = sub_80AF168; - SetMainCallback2(c2_exit_to_overworld_2_switch); + SetMainCallback2(CB2_ReturnToField); } static u32 GetWaldaPhraseInputCase(u8 *inputPtr) diff --git a/sym_common.txt b/sym_common.txt index 0249fc4e9..d179df671 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -51,7 +51,7 @@ gUnknown_03005DB0: @ 3005DB0 gUnknown_03005DB4: @ 3005DB4 .space 0x4 -gUnknown_03005DB8: @ 3005DB8 +gFieldLinkPlayerCount: @ 3005DB8 .space 0x8 gUnknown_03005DC0: @ 3005DC0 From 3762f27727b16521465165c17de59efce8716860 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 14 Feb 2018 01:19:25 +0100 Subject: [PATCH 16/27] make it compiler --- src/link.c | 2 ++ src/link_rfu.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/link.c b/src/link.c index 8f7aa71b6..292ffecf2 100644 --- a/src/link.c +++ b/src/link.c @@ -28,6 +28,8 @@ #include "link.h" #include "link_rfu.h" +extern u16 gUnknown_03005DA8; + // Static type declarations struct BlockTransfer diff --git a/src/link_rfu.c b/src/link_rfu.c index 186d54fd3..a1917ed24 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -16,6 +16,8 @@ #include "rom_8011DC0.h" #include "link_rfu.h" +extern u16 gUnknown_03005DA8; + // Static type declarations // Static RAM declarations From 6ed3da2eb8513b7aa0c6e94ab42b85b2dc848c8e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 13 Feb 2018 19:31:50 -0500 Subject: [PATCH 17/27] Update devkitARM to r47 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dda07ebb4..2067d0fdf 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 18/27] 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 2055f7069..000000000 --- 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 103879101..a835782ed 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 5b9a632fa..7517fb3b8 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 386d63127..7b8e27e47 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 000000000..ee5a39343 --- /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 19/27] 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 8b323799f..fd9c5c5a7 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 ed6b79e6a..bf282d533 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 20/27] 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 bf282d533..930580940 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 21/27] 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 1319ce5d8..9eae24ab9 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 cfc0d081f..02e0a0a91 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 000000000..685a6d27c --- /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 9f649f56c..c1965d983 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 ee5a39343..3dfcd640d 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(); } } From 64683e1473d8b3c99f9bb1eb846c0be6d43cbbcc Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Thu, 15 Feb 2018 15:29:26 +0530 Subject: [PATCH 22/27] [WIP] Decompile fledd_softboiled.h --- asm/fldeff_softboiled.s | 322 ++++++++++++++++++------------------ data/party_menu.s | 4 +- include/fldeff_softboiled.h | 7 + include/party_menu.h | 15 ++ ld_script.txt | 1 + src/fldeff_softboiled.c | 191 +++++++++++++++++++++ 6 files changed, 377 insertions(+), 163 deletions(-) create mode 100644 include/fldeff_softboiled.h create mode 100644 src/fldeff_softboiled.c diff --git a/asm/fldeff_softboiled.s b/asm/fldeff_softboiled.s index c3aa4f1ed..8d06c9c8f 100644 --- a/asm/fldeff_softboiled.s +++ b/asm/fldeff_softboiled.s @@ -5,169 +5,169 @@ .text - thumb_func_start hm_prepare_dive_probably -hm_prepare_dive_probably: @ 8161508 - push {r4-r6,lr} - bl GetCursorSelectionMonId - lsls r0, 24 - lsrs r0, 24 - movs r6, 0x64 - muls r0, r6 - ldr r4, =gPlayerParty - adds r0, r4 - movs r1, 0x3A - bl GetMonData - adds r5, r0, 0 - lsls r5, 16 - lsrs r5, 16 - bl GetCursorSelectionMonId - lsls r0, 24 - lsrs r0, 24 - muls r0, r6 - adds r0, r4 - movs r1, 0x39 - bl GetMonData - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - adds r0, r5, 0 - movs r1, 0x5 - bl __udivsi3 - lsls r0, 16 - lsrs r0, 16 - cmp r4, r0 - bhi _08161558 - movs r0, 0 - b _0816155A - .pool -_08161558: - movs r0, 0x1 -_0816155A: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end hm_prepare_dive_probably +// thumb_func_start hm_prepare_dive_probably +//hm_prepare_dive_probably: @ 8161508 +// push {r4-r6,lr} +// bl GetCursorSelectionMonId +// lsls r0, 24 +// lsrs r0, 24 +// movs r6, 0x64 +// muls r0, r6 +// ldr r4, =gPlayerParty +// adds r0, r4 +// movs r1, 0x3A +// bl GetMonData +// adds r5, r0, 0 +// lsls r5, 16 +// lsrs r5, 16 +// bl GetCursorSelectionMonId +// lsls r0, 24 +// lsrs r0, 24 +// muls r0, r6 +// adds r0, r4 +// movs r1, 0x39 +// bl GetMonData +// adds r4, r0, 0 +// lsls r4, 16 +// lsrs r4, 16 +// adds r0, r5, 0 +// movs r1, 0x5 +// bl __udivsi3 +// lsls r0, 16 +// lsrs r0, 16 +// cmp r4, r0 +// bhi _08161558 +// movs r0, 0 +// b _0816155A +// .pool +//_08161558: +// movs r0, 0x1 +//_0816155A: +// pop {r4-r6} +// pop {r1} +// bx r1 +// thumb_func_end hm_prepare_dive_probably - thumb_func_start sub_8161560 -sub_8161560: @ 8161560 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gUnknown_0203CEC8 - movs r1, 0xA - strb r1, [r0, 0xB] - ldrb r1, [r0, 0x9] - strb r1, [r0, 0xA] - bl GetCursorSelectionMonId - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x1 - bl sub_81B0FCC - movs r0, 0x5 - bl display_pokemon_menu_message - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_81B1370 - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8161560 +// thumb_func_start sub_8161560 +//sub_8161560: @ 8161560 +// push {r4,lr} +// adds r4, r0, 0 +// lsls r4, 24 +// lsrs r4, 24 +// ldr r0, =gUnknown_0203CEC8 +// movs r1, 0xA +// strb r1, [r0, 0xB] +// ldrb r1, [r0, 0x9] +// strb r1, [r0, 0xA] +// bl GetCursorSelectionMonId +// lsls r0, 24 +// lsrs r0, 24 +// movs r1, 0x1 +// bl sub_81B0FCC +// movs r0, 0x5 +// bl display_pokemon_menu_message +// ldr r1, =gTasks +// lsls r0, r4, 2 +// adds r0, r4 +// lsls r0, 3 +// adds r0, r1 +// ldr r1, =sub_81B1370 +// str r1, [r0] +// pop {r4} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end sub_8161560 - thumb_func_start sub_81615A8 -sub_81615A8: @ 81615A8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - str r4, [sp, 0x4] - ldr r1, =gUnknown_0203CEC8 - ldrb r7, [r1, 0x9] - mov r8, r7 - ldrb r0, [r1, 0xA] - adds r5, r0, 0 - cmp r5, 0x6 - bls _081615EC - movs r0, 0 - strb r0, [r1, 0xB] - bl display_pokemon_menu_message - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_81B1370 - str r1, [r0] - b _08161658 - .pool -_081615EC: - movs r0, 0x64 - mov r10, r0 - mov r0, r10 - muls r0, r5 - ldr r1, =gPlayerParty - mov r9, r1 - adds r6, r0, r1 - adds r0, r6, 0 - movs r1, 0x39 - bl GetMonData - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0 - beq _0816161A - cmp r7, r5 - beq _0816161A - adds r0, r6, 0 - movs r1, 0x3A - bl GetMonData - cmp r0, r4 - bne _08161628 -_0816161A: - ldr r0, [sp, 0x4] - bl sub_81617B8 - b _08161658 - .pool -_08161628: - movs r0, 0x1 - bl PlaySE - mov r1, r10 - mov r0, r8 - muls r0, r1 - add r0, r9 - movs r1, 0x3A - bl GetMonData - movs r1, 0x5 - bl __udivsi3 - adds r3, r0, 0 - lsls r3, 16 - asrs r3, 16 - movs r2, 0x1 - negs r2, r2 - ldr r0, =sub_816166C - str r0, [sp] - ldr r0, [sp, 0x4] - mov r1, r8 - bl sub_81B1F18 -_08161658: - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81615A8 +// thumb_func_start sub_81615A8 +//sub_81615A8: @ 81615A8 +// push {r4-r7,lr} +// mov r7, r10 +// mov r6, r9 +// mov r5, r8 +// push {r5-r7} +// sub sp, 0x8 +// lsls r0, 24 +// lsrs r4, r0, 24 +// str r4, [sp, 0x4] +// ldr r1, =gUnknown_0203CEC8 +// ldrb r7, [r1, 0x9] +// mov r8, r7 +// ldrb r0, [r1, 0xA] +// adds r5, r0, 0 +// cmp r5, 0x6 +// bls _081615EC +// movs r0, 0 +// strb r0, [r1, 0xB] +// bl display_pokemon_menu_message +// ldr r1, =gTasks +// lsls r0, r4, 2 +// adds r0, r4 +// lsls r0, 3 +// adds r0, r1 +// ldr r1, =sub_81B1370 +// str r1, [r0] +// b _08161658 +// .pool +//_081615EC: +// movs r0, 0x64 +// mov r10, r0 +// mov r0, r10 +// muls r0, r5 +// ldr r1, =gPlayerParty +// mov r9, r1 +// adds r6, r0, r1 +// adds r0, r6, 0 +// movs r1, 0x39 +// bl GetMonData +// lsls r0, 16 +// lsrs r4, r0, 16 +// cmp r4, 0 +// beq _0816161A +// cmp r7, r5 +// beq _0816161A +// adds r0, r6, 0 +// movs r1, 0x3A +// bl GetMonData +// cmp r0, r4 +// bne _08161628 +//_0816161A: +// ldr r0, [sp, 0x4] +// bl sub_81617B8 +// b _08161658 +// .pool +//_08161628: +// movs r0, 0x1 +// bl PlaySE +// mov r1, r10 +// mov r0, r8 +// muls r0, r1 +// add r0, r9 +// movs r1, 0x3A +// bl GetMonData +// movs r1, 0x5 +// bl __udivsi3 +// adds r3, r0, 0 +// lsls r3, 16 +// asrs r3, 16 +// movs r2, 0x1 +// negs r2, r2 +// ldr r0, =sub_816166C +// str r0, [sp] +// ldr r0, [sp, 0x4] +// mov r1, r8 +// bl sub_81B1F18 +//_08161658: +// add sp, 0x8 +// pop {r3-r5} +// mov r8, r3 +// mov r9, r4 +// mov r10, r5 +// pop {r4-r7} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end sub_81615A8 thumb_func_start sub_816166C sub_816166C: @ 816166C diff --git a/data/party_menu.s b/data/party_menu.s index 9eae24ab9..b60a1f927 100644 --- a/data/party_menu.s +++ b/data/party_menu.s @@ -442,8 +442,8 @@ gUnknown_08615D9C:: @ 8615D9C .4byte SetUpFieldMove_Teleport, 0x0000000d .4byte sub_813572C, 0x0000000d .4byte sub_80FA004, 0x0000000d - .4byte hm_prepare_dive_probably, 0x00000010 - .4byte hm_prepare_dive_probably, 0x00000010 + .4byte SetUpFieldMove_SoftBoiled, 0x00000010 + .4byte SetUpFieldMove_SoftBoiled, 0x00000010 .4byte SetUpFieldMove_SweetScent, 0x0000000d .align 2 diff --git a/include/fldeff_softboiled.h b/include/fldeff_softboiled.h new file mode 100644 index 000000000..065dcbf02 --- /dev/null +++ b/include/fldeff_softboiled.h @@ -0,0 +1,7 @@ +#ifndef GUARD_FLDEFF_SOFTBOILED_H +#define GUARD_FLDEFF_SOFTBOILED_H + +bool8 SetUpFieldMove_SoftBoiled(void); +void sub_8161560(u8 taskid); + +#endif // GUARD_FLDEFF_SOFTBOILED_H diff --git a/include/party_menu.h b/include/party_menu.h index 14aacce88..8f361663b 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -11,6 +11,17 @@ enum AILMENT_BRN }; +struct Struct203CEC8 +{ + u8 filler[0x9]; + u8 unk9; + u8 unkA; + u8 unkB; + u8 filler2[0x2]; +}; + +extern struct Struct203CEC8 gUnknown_0203CEC8; + bool8 pokemon_has_move(struct Pokemon *, u16); void sub_81B58A8(void); void DoWallyTutorialBagMenu(void); @@ -20,4 +31,8 @@ u8 GetCursorSelectionMonId(void); bool8 FieldCallback_Teleport(void); void sub_81B7F60(void); +void sub_81B0FCC(u8 partyMonId, u8 a); +void sub_81B1370(u8 taskId); +void display_pokemon_menu_message(u8 windowBorderId); + #endif // GUARD_PARTY_MENU_H diff --git a/ld_script.txt b/ld_script.txt index b084d866e..ae782a00b 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -210,6 +210,7 @@ SECTIONS { src/fldeff_sweetscent.o(.text); asm/battle_anim_815A0D4.o(.text); asm/learn_move.o(.text); + src/fldeff_softboiled.o(.text); asm/fldeff_softboiled.o(.text); src/decoration_inventory.o(.text); src/roamer.o(.text); diff --git a/src/fldeff_softboiled.c b/src/fldeff_softboiled.c new file mode 100644 index 000000000..8211cc77d --- /dev/null +++ b/src/fldeff_softboiled.c @@ -0,0 +1,191 @@ +#include "global.h" +#include "fldeff_softboiled.h" +#include "menu.h" +#include "party_menu.h" +#include "pokemon.h" +//#include "pokemon_menu.h" +#include "constants/songs.h" +#include "sound.h" +#include "sprite.h" +#include "strings.h" +#include "task.h" +//#include "ewram.h" + +/* +struct Struct2001000 { + u8 unk0; + u8 unk1; + u8 unk2; + u8 filler3[9]; + void *unkC; +}; + +struct Struct201C000 { + struct Pokemon *unk0; + u8 filler4[1]; + u8 unk5; + u16 unk6; + u8 filler8[4]; + s32 unkC; + void* unk10; + u8 filler14[26]; + s16 unk2E; +}; + +#if ENGLISH +#define WINDOW_LEFT 3 +#define WINDOW_RIGHT 26 +#elif GERMAN +#define WINDOW_LEFT 0 +#define WINDOW_RIGHT 29 +#endif +*/ +/* +// extern +extern u8 gUnknown_0202E8F6; +extern u8 gLastFieldPokeMenuOpened; +extern u8 gUnknown_0202E8F4; + +// Static +static void sub_8133D50(u8 taskId); +static void sub_8133E74(u8 taskId); +static void sub_8133EB8(u8 taskId); +static void sub_8133EF8(void); +*/ + +void sub_816166C(u8 taskId); +void sub_81617B8(u8 taskId); +void sub_81B1F18(u8 taskId, u8 pokemonIdx, s8 a, s16 hp, TaskFunc func); + +bool8 SetUpFieldMove_SoftBoiled(void) +{ + u16 maxHp; + u16 hp; + u16 minHp; + + maxHp = GetMonData(&gPlayerParty[GetCursorSelectionMonId()], MON_DATA_MAX_HP); + hp = GetMonData(&gPlayerParty[GetCursorSelectionMonId()], MON_DATA_HP); + + minHp = (maxHp / 5); + if (hp > minHp) + { + return TRUE; + } + return FALSE; +} + +void sub_8161560(u8 taskId) +{ + gUnknown_0203CEC8.unkB = 0xA; + gUnknown_0203CEC8.unkA = gUnknown_0203CEC8.unk9; + sub_81B0FCC(GetCursorSelectionMonId(), 0x1); + display_pokemon_menu_message(0x5); + gTasks[taskId].func = sub_81B1370; +} + +void sub_81615A8(u8 taskId) +{ + u16 hp; + + u8 unk9 = gUnknown_0203CEC8.unk9; + u8 pokemonIndex = gUnknown_0203CEC8.unkA; + if(pokemonIndex > 6) + { + gUnknown_0203CEC8.unkB = 0; + display_pokemon_menu_message(0x0); + gTasks[taskId].func = sub_81B1370; + return; + } + + hp = GetMonData(&gPlayerParty[pokemonIndex], MON_DATA_HP); + if(hp == 0 || unk9 == pokemonIndex || GetMonData(&gPlayerParty[pokemonIndex], MON_DATA_MAX_HP) == hp) + { + sub_81617B8(taskId); + return; + } + + PlaySE(SE_KAIFUKU); + sub_81B1F18(taskId, unk9, -1, GetMonData(&gPlayerParty[unk9], MON_DATA_MAX_HP)/5, sub_816166C); +} + +/* +void sub_8133D28(u8 taskid) { + EWRAM_1000.unkC = sub_8133D50; + EWRAM_1B000_2.unk272 = 3; + DoPokemonMenu_Switch(taskid); +} + +static void sub_8133D50(u8 taskId) { + u8 unk1, unk2; + u16 hp; + struct Pokemon *pokemon; + //struct Task *task; + + struct Sprite *sprites = gSprites; + + + unk1 = sprites[EWRAM_1000.unk1].data[0]; + unk2 = sprites[EWRAM_1000.unk2].data[0]; + + if (unk1 > 5 || unk2 > 5) + { + sub_806CD44(taskId); + return; + } + + EWRAM_1C000.unk0 = &gPlayerParty[sprites[EWRAM_1000.unk2].data[0]]; + hp = GetMonData(EWRAM_1C000.unk0, MON_DATA_HP); + + if (hp == 0 || unk1 == unk2 || GetMonData(EWRAM_1C000.unk0, MON_DATA_MAX_HP) == hp) + { + sub_8133EB8(taskId); + return; + } + + PlaySE(SE_KAIFUKU); + + EWRAM_1C000.unk5 = gSprites[EWRAM_1000.unk1].data[0]; + + pokemon = &gPlayerParty[EWRAM_1C000.unk5]; + EWRAM_1C000.unk0 = pokemon; + EWRAM_1C000.unk6 = 0; + EWRAM_1C000.unkC = -0x8000; + EWRAM_1C000.unk10 = sub_8133EF8; + + + gTasks[taskId].data[10] = GetMonData(EWRAM_1C000.unk0, MON_DATA_MAX_HP); + gTasks[taskId].data[11] = GetMonData(EWRAM_1C000.unk0, MON_DATA_HP); + gTasks[taskId].data[12] = gTasks[taskId].data[10] / 5; + + sub_806D5A4(); + gTasks[taskId].func = sub_806FA18; + EWRAM_1B000_2.unk282 = gTasks[taskId].data[11]; +} + +static void sub_8133E74(u8 taskId) { + if (gUnknown_0202E8F6) + { + return; + } + + MenuZeroFillWindowRect(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); + PrintPartyMenuPromptText(3, 0); + gTasks[taskId].func = HandlePartyMenuSwitchPokemonInput; +} + +static void sub_8133EB8(u8 taskId) { + gUnknown_0202E8F4 = 0; + sub_806D5A4(); + sub_806E834(gOtherText_CantUseOnPoke, 1); + gTasks[taskId].func = sub_8133E74; +} + +static void sub_8133EF8(void) { + sub_806CCE4(); + EWRAM_1B000_2.unk261 = 2; + DestroySprite(&gSprites[EWRAM_1000.unk1]); + MenuZeroFillWindowRect(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); + PrintPartyMenuPromptText(0, 0); + SwitchTaskToFollowupFunc(EWRAM_1000.unk0); +} +*/ From 44c1ea16b9ec4d4a1c285bdab84b514f376625cc Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Thu, 15 Feb 2018 16:05:27 +0530 Subject: [PATCH 23/27] Cleanup and one non-matching function --- asm/fldeff_softboiled.s | 70 ++++++++--------- src/fldeff_softboiled.c | 162 +++++++++++----------------------------- 2 files changed, 79 insertions(+), 153 deletions(-) diff --git a/asm/fldeff_softboiled.s b/asm/fldeff_softboiled.s index 8d06c9c8f..4af5a2592 100644 --- a/asm/fldeff_softboiled.s +++ b/asm/fldeff_softboiled.s @@ -169,41 +169,41 @@ // .pool // thumb_func_end sub_81615A8 - thumb_func_start sub_816166C -sub_816166C: @ 816166C - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x1 - bl PlaySE - ldr r5, =gUnknown_0203CEC8 - movs r1, 0x9 - ldrsb r1, [r5, r1] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - movs r1, 0x3A - bl GetMonData - movs r1, 0x5 - bl __udivsi3 - adds r3, r0, 0 - lsls r3, 16 - asrs r3, 16 - ldrb r1, [r5, 0xA] - ldr r0, =sub_81616C0 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x1 - bl sub_81B1F18 - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816166C +// thumb_func_start sub_816166C +//sub_816166C: @ 816166C +// push {r4,r5,lr} +// sub sp, 0x4 +// adds r4, r0, 0 +// lsls r4, 24 +// lsrs r4, 24 +// movs r0, 0x1 +// bl PlaySE +// ldr r5, =gUnknown_0203CEC8 +// movs r1, 0x9 +// ldrsb r1, [r5, r1] +// movs r0, 0x64 +// muls r0, r1 +// ldr r1, =gPlayerParty +// adds r0, r1 +// movs r1, 0x3A +// bl GetMonData +// movs r1, 0x5 +// bl __udivsi3 +// adds r3, r0, 0 +// lsls r3, 16 +// asrs r3, 16 +// ldrb r1, [r5, 0xA] +// ldr r0, =sub_81616C0 +// str r0, [sp] +// adds r0, r4, 0 +// movs r2, 0x1 +// bl sub_81B1F18 +// add sp, 0x4 +// pop {r4,r5} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end sub_816166C thumb_func_start sub_81616C0 sub_81616C0: @ 81616C0 diff --git a/src/fldeff_softboiled.c b/src/fldeff_softboiled.c index 8211cc77d..d4193b917 100644 --- a/src/fldeff_softboiled.c +++ b/src/fldeff_softboiled.c @@ -9,52 +9,10 @@ #include "sprite.h" #include "strings.h" #include "task.h" -//#include "ewram.h" - -/* -struct Struct2001000 { - u8 unk0; - u8 unk1; - u8 unk2; - u8 filler3[9]; - void *unkC; -}; - -struct Struct201C000 { - struct Pokemon *unk0; - u8 filler4[1]; - u8 unk5; - u16 unk6; - u8 filler8[4]; - s32 unkC; - void* unk10; - u8 filler14[26]; - s16 unk2E; -}; - -#if ENGLISH -#define WINDOW_LEFT 3 -#define WINDOW_RIGHT 26 -#elif GERMAN -#define WINDOW_LEFT 0 -#define WINDOW_RIGHT 29 -#endif -*/ -/* -// extern -extern u8 gUnknown_0202E8F6; -extern u8 gLastFieldPokeMenuOpened; -extern u8 gUnknown_0202E8F4; - -// Static -static void sub_8133D50(u8 taskId); -static void sub_8133E74(u8 taskId); -static void sub_8133EB8(u8 taskId); -static void sub_8133EF8(void); -*/ void sub_816166C(u8 taskId); void sub_81617B8(u8 taskId); +void sub_81616C0(u8 taskId); void sub_81B1F18(u8 taskId, u8 pokemonIdx, s8 a, s16 hp, TaskFunc func); bool8 SetUpFieldMove_SoftBoiled(void) @@ -108,84 +66,52 @@ void sub_81615A8(u8 taskId) sub_81B1F18(taskId, unk9, -1, GetMonData(&gPlayerParty[unk9], MON_DATA_MAX_HP)/5, sub_816166C); } -/* -void sub_8133D28(u8 taskid) { - EWRAM_1000.unkC = sub_8133D50; - EWRAM_1B000_2.unk272 = 3; - DoPokemonMenu_Switch(taskid); -} - -static void sub_8133D50(u8 taskId) { - u8 unk1, unk2; - u16 hp; - struct Pokemon *pokemon; - //struct Task *task; - - struct Sprite *sprites = gSprites; - - - unk1 = sprites[EWRAM_1000.unk1].data[0]; - unk2 = sprites[EWRAM_1000.unk2].data[0]; - - if (unk1 > 5 || unk2 > 5) - { - sub_806CD44(taskId); - return; - } - - EWRAM_1C000.unk0 = &gPlayerParty[sprites[EWRAM_1000.unk2].data[0]]; - hp = GetMonData(EWRAM_1C000.unk0, MON_DATA_HP); - - if (hp == 0 || unk1 == unk2 || GetMonData(EWRAM_1C000.unk0, MON_DATA_MAX_HP) == hp) - { - sub_8133EB8(taskId); - return; - } - +#ifdef NONMATCHING +void sub_816166C(u8 taskId) +{ PlaySE(SE_KAIFUKU); - - EWRAM_1C000.unk5 = gSprites[EWRAM_1000.unk1].data[0]; - - pokemon = &gPlayerParty[EWRAM_1C000.unk5]; - EWRAM_1C000.unk0 = pokemon; - EWRAM_1C000.unk6 = 0; - EWRAM_1C000.unkC = -0x8000; - EWRAM_1C000.unk10 = sub_8133EF8; - - - gTasks[taskId].data[10] = GetMonData(EWRAM_1C000.unk0, MON_DATA_MAX_HP); - gTasks[taskId].data[11] = GetMonData(EWRAM_1C000.unk0, MON_DATA_HP); - gTasks[taskId].data[12] = gTasks[taskId].data[10] / 5; - - sub_806D5A4(); - gTasks[taskId].func = sub_806FA18; - EWRAM_1B000_2.unk282 = gTasks[taskId].data[11]; + sub_81B1F18(taskId, gUnknown_0203CEC8.unkA, 1, GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_MAX_HP)/5, sub_81616C0); } +#else +__attribute__((naked)) +void sub_816166C(u8 taskId) +{ + asm(".syntax unified\n\ + push {r4,r5,lr}\n\ + sub sp, 0x4\n\ + adds r4, r0, 0\n\ + lsls r4, 24\n\ + lsrs r4, 24\n\ + movs r0, 0x1\n\ + bl PlaySE\n\ + ldr r5, =gUnknown_0203CEC8\n\ + movs r1, 0x9\n\ + ldrsb r1, [r5, r1]\n\ + movs r0, 0x64\n\ + muls r0, r1\n\ + ldr r1, =gPlayerParty\n\ + adds r0, r1\n\ + movs r1, 0x3A\n\ + bl GetMonData\n\ + movs r1, 0x5\n\ + bl __udivsi3\n\ + adds r3, r0, 0\n\ + lsls r3, 16\n\ + asrs r3, 16\n\ + ldrb r1, [r5, 0xA]\n\ + ldr r0, =sub_81616C0\n\ + str r0, [sp]\n\ + adds r0, r4, 0\n\ + movs r2, 0x1\n\ + bl sub_81B1F18\n\ + add sp, 0x4\n\ + pop {r4,r5}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided\n"); -static void sub_8133E74(u8 taskId) { - if (gUnknown_0202E8F6) - { - return; - } - - MenuZeroFillWindowRect(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); - PrintPartyMenuPromptText(3, 0); - gTasks[taskId].func = HandlePartyMenuSwitchPokemonInput; } +#endif -static void sub_8133EB8(u8 taskId) { - gUnknown_0202E8F4 = 0; - sub_806D5A4(); - sub_806E834(gOtherText_CantUseOnPoke, 1); - gTasks[taskId].func = sub_8133E74; -} -static void sub_8133EF8(void) { - sub_806CCE4(); - EWRAM_1B000_2.unk261 = 2; - DestroySprite(&gSprites[EWRAM_1000.unk1]); - MenuZeroFillWindowRect(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); - PrintPartyMenuPromptText(0, 0); - SwitchTaskToFollowupFunc(EWRAM_1000.unk0); -} -*/ From 4b4495f3fe2a65bdf0f2a21c650103c4dbeed514 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 15 Feb 2018 12:36:52 +0100 Subject: [PATCH 24/27] overworld review changes --- include/gba/io_reg.h | 35 ++++++----- src/overworld.c | 144 +++++++++++++++++++++---------------------- 2 files changed, 87 insertions(+), 92 deletions(-) diff --git a/include/gba/io_reg.h b/include/gba/io_reg.h index 1847b688f..c1abcc94c 100644 --- a/include/gba/io_reg.h +++ b/include/gba/io_reg.h @@ -501,23 +501,24 @@ // I/O register fields // DISPCNT -#define DISPCNT_MODE_0 0x0000 // BG0: text, BG1: text, BG2: text, BG3: text -#define DISPCNT_MODE_1 0x0001 // BG0: text, BG1: text, BG2: affine, BG3: off -#define DISPCNT_MODE_2 0x0002 // BG0: off, BG1: off, BG2: affine, BG3: affine -#define DISPCNT_MODE_3 0x0003 // Bitmap mode, 240x160, BGR555 color -#define DISPCNT_MODE_4 0x0004 // Bitmap mode, 240x160, 256 color palette -#define DISPCNT_MODE_5 0x0005 // Bitmap mode, 160x128, BGR555 color -#define DISPCNT_OBJ_1D_MAP 0x0040 -#define DISPCNT_FORCED_BLANK 0x0080 -#define DISPCNT_BG0_ON 0x0100 -#define DISPCNT_BG1_ON 0x0200 -#define DISPCNT_BG2_ON 0x0400 -#define DISPCNT_BG3_ON 0x0800 -#define DISPCNT_BG_ALL_ON 0x0F00 -#define DISPCNT_OBJ_ON 0x1000 -#define DISPCNT_WIN0_ON 0x2000 -#define DISPCNT_WIN1_ON 0x4000 -#define DISPCNT_OBJWIN_ON 0x8000 +#define DISPCNT_MODE_0 0x0000 // BG0: text, BG1: text, BG2: text, BG3: text +#define DISPCNT_MODE_1 0x0001 // BG0: text, BG1: text, BG2: affine, BG3: off +#define DISPCNT_MODE_2 0x0002 // BG0: off, BG1: off, BG2: affine, BG3: affine +#define DISPCNT_MODE_3 0x0003 // Bitmap mode, 240x160, BGR555 color +#define DISPCNT_MODE_4 0x0004 // Bitmap mode, 240x160, 256 color palette +#define DISPCNT_MODE_5 0x0005 // Bitmap mode, 160x128, BGR555 color +#define DISPCNT_HBLANK_INTERVAL 0x0020 // Allow access to OAM during H-Blank +#define DISPCNT_OBJ_1D_MAP 0x0040 +#define DISPCNT_FORCED_BLANK 0x0080 +#define DISPCNT_BG0_ON 0x0100 +#define DISPCNT_BG1_ON 0x0200 +#define DISPCNT_BG2_ON 0x0400 +#define DISPCNT_BG3_ON 0x0800 +#define DISPCNT_BG_ALL_ON 0x0F00 +#define DISPCNT_OBJ_ON 0x1000 +#define DISPCNT_WIN0_ON 0x2000 +#define DISPCNT_WIN1_ON 0x4000 +#define DISPCNT_OBJWIN_ON 0x8000 // DISPSTAT #define DISPSTAT_VBLANK 0x0001 // in V-Blank diff --git a/src/overworld.c b/src/overworld.c index 5e6654cad..fd1173ffc 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -748,13 +748,9 @@ void sub_8084E80(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) void sub_8084EBC(s16 x, s16 y) { if (warp_data_is_not_neg_1(&sUnknown_020322F4) == TRUE) - { sWarpDestination = gUnknown_020322DC; - } else - { Overworld_SetWarpDestination(sUnknown_020322F4.mapGroup, sUnknown_020322F4.mapNum, -1, x, y); - } } void warp1_set_to_sav1w(void) @@ -951,41 +947,43 @@ static u8 sub_808532C(struct UnkPlayerStruct *playerStruct, u16 a2, u8 a3) { if (a3 != 8 && FlagGet(FLAG_SYS_CRUISE_MODE)) return 1; - if (a3 == 5) + else if (a3 == 5) return 16; - if (MetatileBehavior_IsSurfableWaterOrUnderwater(a2) == 1) + else if (MetatileBehavior_IsSurfableWaterOrUnderwater(a2) == 1) return 8; - if (Overworld_IsBikingAllowed() != TRUE) + else if (Overworld_IsBikingAllowed() != TRUE) return 1; - if (playerStruct->player_field_0 == 2) + else if (playerStruct->player_field_0 == 2) return 2; - if (playerStruct->player_field_0 != 4) + else if (playerStruct->player_field_0 != 4) return 1; - return 4; + else + return 4; } static u8 sub_808538C(struct UnkPlayerStruct *playerStruct, u8 a2, u16 a3, u8 a4) { if (FlagGet(FLAG_SYS_CRUISE_MODE) && a4 == 6) return 4; - if (MetatileBehavior_IsDeepSouthWarp(a3) == TRUE) + else if (MetatileBehavior_IsDeepSouthWarp(a3) == TRUE) return 2; - if (MetatileBehavior_IsNonAnimDoor(a3) == TRUE || MetatileBehavior_IsDoor(a3) == TRUE) + else if (MetatileBehavior_IsNonAnimDoor(a3) == TRUE || MetatileBehavior_IsDoor(a3) == TRUE) return 1; - if (MetatileBehavior_IsSouthArrowWarp(a3) == TRUE) + else if (MetatileBehavior_IsSouthArrowWarp(a3) == TRUE) return 2; - if (MetatileBehavior_IsNorthArrowWarp(a3) == TRUE) + else if (MetatileBehavior_IsNorthArrowWarp(a3) == TRUE) return 1; - if (MetatileBehavior_IsWestArrowWarp(a3) == TRUE) + else if (MetatileBehavior_IsWestArrowWarp(a3) == TRUE) return 4; - if (MetatileBehavior_IsEastArrowWarp(a3) == TRUE) + else if (MetatileBehavior_IsEastArrowWarp(a3) == TRUE) return 3; - if ((playerStruct->player_field_0 == 16 && a2 == 8) + else if ((playerStruct->player_field_0 == 16 && a2 == 8) || (playerStruct->player_field_0 == 8 && a2 == 16)) return playerStruct->player_field_1; - if (MetatileBehavior_IsLadder(a3) == TRUE) + else if (MetatileBehavior_IsLadder(a3) == TRUE) return playerStruct->player_field_1; - return 1; + else + return 1; } static u16 cur_mapdata_block_role_at_screen_center_acc_to_sav1(void) @@ -1076,34 +1074,36 @@ static bool16 NoMusicInSotopolisWithLegendaries(struct WarpData *warp) { if (VarGet(VAR_0x40CA) != 1) return FALSE; - if (warp->mapGroup != MAP_GROUP(SOOTOPOLIS_CITY)) + else if (warp->mapGroup != MAP_GROUP(SOOTOPOLIS_CITY)) return FALSE; - if (warp->mapNum == MAP_NUM(SOOTOPOLIS_CITY)) + else if (warp->mapNum == MAP_NUM(SOOTOPOLIS_CITY)) return TRUE; - return FALSE; + else + return FALSE; } static bool16 IsInfiltratedWeatherInstitute(struct WarpData *warp) { if (VarGet(VAR_WEATHER_INSTITUTE_STATE)) return FALSE; - if (warp->mapGroup != MAP_GROUP(ROUTE119_WEATHER_INSTITUTE_1F)) + else if (warp->mapGroup != MAP_GROUP(ROUTE119_WEATHER_INSTITUTE_1F)) return FALSE; - if (warp->mapNum == MAP_NUM(ROUTE119_WEATHER_INSTITUTE_1F) + else if (warp->mapNum == MAP_NUM(ROUTE119_WEATHER_INSTITUTE_1F) || warp->mapNum == MAP_NUM(ROUTE119_WEATHER_INSTITUTE_2F)) return TRUE; - return FALSE; + else + return FALSE; } static bool16 IsInflitratedSpaceCenter(struct WarpData *warp) { if (VarGet(VAR_0x405D) == 0) return FALSE; - if (VarGet(VAR_0x405D) > 2) + else if (VarGet(VAR_0x405D) > 2) return FALSE; - if (warp->mapGroup != MAP_GROUP(MOSSDEEP_CITY_SPACE_CENTER_1F)) + else if (warp->mapGroup != MAP_GROUP(MOSSDEEP_CITY_SPACE_CENTER_1F)) return FALSE; - if (warp->mapNum == MAP_NUM(MOSSDEEP_CITY_SPACE_CENTER_1F) + else if (warp->mapNum == MAP_NUM(MOSSDEEP_CITY_SPACE_CENTER_1F) || warp->mapNum == MAP_NUM(MOSSDEEP_CITY_SPACE_CENTER_2F)) return TRUE; return FALSE; @@ -1676,7 +1676,7 @@ void c2_8056854(void) SetMainCallback1(c1_link_related); sub_8086C2C(); - if (gWirelessCommType) + if (gWirelessCommType != 0) gFieldCallback = sub_80AF314; else gFieldCallback = sub_80AF214; @@ -2123,7 +2123,8 @@ static void map_loading_lcd_reset(void) SetGpuReg(REG_OFFSET_WIN0V, 0xFF); SetGpuReg(REG_OFFSET_WIN1H, 0xFFFF); SetGpuReg(REG_OFFSET_WIN1V, 0xFFFF); - SetGpuReg(REG_OFFSET_BLDCNT, gUnknown_82EC7C4[1] | gUnknown_82EC7C4[2] | gUnknown_82EC7C4[3] | 0x1040); + SetGpuReg(REG_OFFSET_BLDCNT, gUnknown_82EC7C4[1] | gUnknown_82EC7C4[2] | gUnknown_82EC7C4[3] + | BLDCNT_TGT2_OBJ | BLDCNT_EFFECT_BLEND); SetGpuReg(REG_OFFSET_BLDALPHA, 0x70D); overworld_bg_setup(); schedule_bg_copy_tilemap_to_vram(1); @@ -2137,7 +2138,8 @@ static void map_loading_lcd_reset(void) ChangeBgY(2, 0, 0); ChangeBgX(3, 0, 0); ChangeBgY(3, 0, 0); - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_WIN0_ON | DISPCNT_WIN1_ON | DISPCNT_OBJ_1D_MAP | 0x20); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_WIN0_ON | DISPCNT_WIN1_ON + | DISPCNT_OBJ_1D_MAP | DISPCNT_HBLANK_INTERVAL); ShowBg(0); ShowBg(1); ShowBg(2); @@ -2278,11 +2280,8 @@ static void c1_link_related_func_set(u16 (*func)(u32)) static void sub_8086C64(void) { - if (gWirelessCommType != 0) - { - if (++sUnknown_03000E19 > 60) - sub_8010198(); - } + if (gWirelessCommType != 0 && ++sUnknown_03000E19 > 60) + sub_8010198(); } static void sub_8086C90(void) @@ -2720,11 +2719,12 @@ static bool32 sub_8087388(struct UnkStruct_8054FF8 *a1) { if (a1->c != 2 && a1->c != 0) return FALSE; - if (!MetatileBehavior_IsSouthArrowWarp(a1->field_C)) + else if (!MetatileBehavior_IsSouthArrowWarp(a1->field_C)) return FALSE; - if (a1->d != 1) + else if (a1->d != 1) return FALSE; - return TRUE; + else + return TRUE; } static const u8 *sub_80873B4(struct UnkStruct_8054FF8 *a1) @@ -2745,9 +2745,9 @@ static const u8 *sub_80873B4(struct UnkStruct_8054FF8 *a1) { if (!a1->b) return EventScript_TradeRoom_TooBusyToNotice; - if (sUnknown_03000E10[linkPlayerId] != 0x80) + else if (sUnknown_03000E10[linkPlayerId] != 0x80) return EventScript_TradeRoom_TooBusyToNotice; - if (!sub_80B39D4(linkPlayerId)) + else if (!sub_80B39D4(linkPlayerId)) return EventScript_TradeRoom_ReadTrainerCard1; else return EventScript_TradeRoom_ReadTrainerCard2; @@ -2760,29 +2760,30 @@ static u16 sub_8087480(const u8 *script) { if (script == gUnknown_08277388) return 10; - if (script == gUnknown_082773A3) + else if (script == gUnknown_082773A3) return 9; - if (script == gUnknown_082773BE) + else if (script == gUnknown_082773BE) return 10; - if (script == gUnknown_082773D9) + else if (script == gUnknown_082773D9) return 9; - if (script == gUnknown_0827741D) + else if (script == gUnknown_0827741D) return 10; - if (script == gUnknown_08277432) + else if (script == gUnknown_08277432) return 9; - if (script == gUnknown_08277447) + else if (script == gUnknown_08277447) return 10; - if (script == gUnknown_0827745C) + else if (script == gUnknown_0827745C) return 9; - if (script == gUnknown_08277374) + else if (script == gUnknown_08277374) return 10; - if (script == gUnknown_0827737E) + else if (script == gUnknown_0827737E) return 9; - if (script == gUnknown_082773F5) + else if (script == gUnknown_082773F5) return 10; - if (script == gUnknown_082773FF) + else if (script == gUnknown_082773FF) return 9; - return 0; + else + return 0; } static void sub_8087510(void) @@ -2841,17 +2842,13 @@ bool32 sub_80875C8(void) if (sub_800B4DC() < 2) return FALSE; - - if (is_c1_link_related_active() != TRUE) + else if (is_c1_link_related_active() != TRUE) return FALSE; - - if (sub_8009F3C() != TRUE) + else if (sub_8009F3C() != TRUE) return FALSE; - - if (sUnknown_03000E14 == sub_808711C) + else if (sUnknown_03000E14 == sub_808711C) return TRUE; - - if (sUnknown_03000E14 != sub_80870F8) + else if (sUnknown_03000E14 != sub_80870F8) return FALSE; temp = sUnknown_03000E18; @@ -2859,37 +2856,34 @@ bool32 sub_80875C8(void) if (temp == TRUE) return TRUE; - - if (gPaletteFade.active && gPaletteFade.softwareFadeFinishing) + else if (gPaletteFade.active && gPaletteFade.softwareFadeFinishing) return TRUE; - - return FALSE; + else + return FALSE; } bool32 sub_8087634(void) { if (sub_8087690() < 2) return FALSE; - - if (is_c1_link_related_active() != TRUE) + else if (is_c1_link_related_active() != TRUE) return FALSE; - - if (sub_8009F3C() != TRUE) + else if (sub_8009F3C() != TRUE) return FALSE; - - if (sUnknown_03000E14 == sub_8087140) + else if (sUnknown_03000E14 == sub_8087140) return TRUE; - - return FALSE; + else + return FALSE; } bool32 sub_808766C(void) { if (gWirelessCommType != 0) return FALSE; - if (!sub_8009F3C()) + else if (!sub_8009F3C()) return FALSE; - return TRUE; + else + return TRUE; } static u32 sub_8087690(void) From 301664db2f7459e6f819a5f6eceeefccc78f0414 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Thu, 15 Feb 2018 17:12:02 +0530 Subject: [PATCH 25/27] Matching the unmatched and another function --- asm/fldeff_softboiled.s | 72 ++++++++++++++++++------------------- include/fldeff_softboiled.h | 1 + include/party_menu.h | 10 +++--- include/strings.h | 4 +++ src/fldeff_softboiled.c | 51 +++++--------------------- 5 files changed, 56 insertions(+), 82 deletions(-) diff --git a/asm/fldeff_softboiled.s b/asm/fldeff_softboiled.s index 4af5a2592..9f5f6a26e 100644 --- a/asm/fldeff_softboiled.s +++ b/asm/fldeff_softboiled.s @@ -205,42 +205,42 @@ // .pool // thumb_func_end sub_816166C - thumb_func_start sub_81616C0 -sub_81616C0: @ 81616C0 - push {r4,r5,lr} - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r0, =gUnknown_0203CEC8 - movs r1, 0xA - ldrsb r1, [r0, r1] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - ldr r1, =gStringVar1 - bl GetMonNickname - ldr r4, =gStringVar4 - ldr r1, =gText_PkmnHPRestoredByVar2 - adds r0, r4, 0 - bl StringExpandPlaceholders - adds r0, r4, 0 - movs r1, 0 - bl sub_81B1B5C - movs r0, 0x2 - bl schedule_bg_copy_tilemap_to_vram - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_8161724 - str r1, [r0] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81616C0 +// thumb_func_start sub_81616C0 +//sub_81616C0: @ 81616C0 +// push {r4,r5,lr} +// adds r5, r0, 0 +// lsls r5, 24 +// lsrs r5, 24 +// ldr r0, =gUnknown_0203CEC8 +// movs r1, 0xA +// ldrsb r1, [r0, r1] +// movs r0, 0x64 +// muls r0, r1 +// ldr r1, =gPlayerParty +// adds r0, r1 +// ldr r1, =gStringVar1 +// bl GetMonNickname +// ldr r4, =gStringVar4 +// ldr r1, =gText_PkmnHPRestoredByVar2 +// adds r0, r4, 0 +// bl StringExpandPlaceholders +// adds r0, r4, 0 +// movs r1, 0 +// bl sub_81B1B5C +// movs r0, 0x2 +// bl schedule_bg_copy_tilemap_to_vram +// ldr r1, =gTasks +// lsls r0, r5, 2 +// adds r0, r5 +// lsls r0, 3 +// adds r0, r1 +// ldr r1, =sub_8161724 +// str r1, [r0] +// pop {r4,r5} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end sub_81616C0 thumb_func_start sub_8161724 sub_8161724: @ 8161724 diff --git a/include/fldeff_softboiled.h b/include/fldeff_softboiled.h index 065dcbf02..0e3b98a46 100644 --- a/include/fldeff_softboiled.h +++ b/include/fldeff_softboiled.h @@ -4,4 +4,5 @@ bool8 SetUpFieldMove_SoftBoiled(void); void sub_8161560(u8 taskid); + #endif // GUARD_FLDEFF_SOFTBOILED_H diff --git a/include/party_menu.h b/include/party_menu.h index 8f361663b..25c389493 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -1,6 +1,6 @@ #ifndef GUARD_PARTY_MENU_H #define GUARD_PARTY_MENU_H - +#include "task.h" enum { AILMENT_NONE, @@ -14,8 +14,8 @@ enum struct Struct203CEC8 { u8 filler[0x9]; - u8 unk9; - u8 unkA; + s8 unk9; + s8 unkA; u8 unkB; u8 filler2[0x2]; }; @@ -31,8 +31,10 @@ u8 GetCursorSelectionMonId(void); bool8 FieldCallback_Teleport(void); void sub_81B7F60(void); -void sub_81B0FCC(u8 partyMonId, u8 a); +void sub_81B0FCC(u8 partyIdx, u8 a); void sub_81B1370(u8 taskId); void display_pokemon_menu_message(u8 windowBorderId); +void sub_81B1F18(u8 taskId, u8 pokemonIdx, s8 a, s16 hp, TaskFunc func); +void sub_81B1B5C(void *a, u8 b); #endif // GUARD_PARTY_MENU_H diff --git a/include/strings.h b/include/strings.h index c9ebc175f..4632938da 100644 --- a/include/strings.h +++ b/include/strings.h @@ -348,6 +348,10 @@ extern const u8 gText_DepositedVar2Var1s[]; extern const u8 gText_NoRoomForItems[]; extern const u8 gText_ThreeDashes[]; +//party menu text +extern const u8 gText_PkmnHPRestoredByVar2[]; + +//birch dex rating text extern const u8 gBirchDexRatingText_LessThan10[]; extern const u8 gBirchDexRatingText_LessThan20[]; extern const u8 gBirchDexRatingText_LessThan30[]; diff --git a/src/fldeff_softboiled.c b/src/fldeff_softboiled.c index d4193b917..3420faed7 100644 --- a/src/fldeff_softboiled.c +++ b/src/fldeff_softboiled.c @@ -7,13 +7,14 @@ #include "constants/songs.h" #include "sound.h" #include "sprite.h" +#include "string_util.h" #include "strings.h" #include "task.h" void sub_816166C(u8 taskId); void sub_81617B8(u8 taskId); void sub_81616C0(u8 taskId); -void sub_81B1F18(u8 taskId, u8 pokemonIdx, s8 a, s16 hp, TaskFunc func); +void sub_8161724(u8 taskId); bool8 SetUpFieldMove_SoftBoiled(void) { @@ -66,52 +67,18 @@ void sub_81615A8(u8 taskId) sub_81B1F18(taskId, unk9, -1, GetMonData(&gPlayerParty[unk9], MON_DATA_MAX_HP)/5, sub_816166C); } -#ifdef NONMATCHING void sub_816166C(u8 taskId) { PlaySE(SE_KAIFUKU); sub_81B1F18(taskId, gUnknown_0203CEC8.unkA, 1, GetMonData(&gPlayerParty[gUnknown_0203CEC8.unk9], MON_DATA_MAX_HP)/5, sub_81616C0); } -#else -__attribute__((naked)) -void sub_816166C(u8 taskId) + +void sub_81616C0(u8 taskId) { - asm(".syntax unified\n\ - push {r4,r5,lr}\n\ - sub sp, 0x4\n\ - adds r4, r0, 0\n\ - lsls r4, 24\n\ - lsrs r4, 24\n\ - movs r0, 0x1\n\ - bl PlaySE\n\ - ldr r5, =gUnknown_0203CEC8\n\ - movs r1, 0x9\n\ - ldrsb r1, [r5, r1]\n\ - movs r0, 0x64\n\ - muls r0, r1\n\ - ldr r1, =gPlayerParty\n\ - adds r0, r1\n\ - movs r1, 0x3A\n\ - bl GetMonData\n\ - movs r1, 0x5\n\ - bl __udivsi3\n\ - adds r3, r0, 0\n\ - lsls r3, 16\n\ - asrs r3, 16\n\ - ldrb r1, [r5, 0xA]\n\ - ldr r0, =sub_81616C0\n\ - str r0, [sp]\n\ - adds r0, r4, 0\n\ - movs r2, 0x1\n\ - bl sub_81B1F18\n\ - add sp, 0x4\n\ - pop {r4,r5}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided\n"); - + GetMonNickname(&gPlayerParty[gUnknown_0203CEC8.unkA], gStringVar1); + StringExpandPlaceholders(gStringVar4, gText_PkmnHPRestoredByVar2); + sub_81B1B5C(gStringVar4, 0); + schedule_bg_copy_tilemap_to_vram(2); + gTasks[taskId].func = sub_8161724; } -#endif - From a200d9406b15f722b34775050f6fe73894d23629 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Thu, 15 Feb 2018 22:32:28 +0530 Subject: [PATCH 26/27] Finish fldeff_softboiled.c --- asm/fldeff_softboiled.s | 339 ------------------------------------ include/fldeff_softboiled.h | 8 - include/party_menu.h | 3 +- include/strings.h | 1 + ld_script.txt | 1 - src/fldeff_softboiled.c | 33 +++- 6 files changed, 32 insertions(+), 353 deletions(-) delete mode 100644 asm/fldeff_softboiled.s delete mode 100644 include/fldeff_softboiled.h diff --git a/asm/fldeff_softboiled.s b/asm/fldeff_softboiled.s deleted file mode 100644 index 9f5f6a26e..000000000 --- a/asm/fldeff_softboiled.s +++ /dev/null @@ -1,339 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - -// thumb_func_start hm_prepare_dive_probably -//hm_prepare_dive_probably: @ 8161508 -// push {r4-r6,lr} -// bl GetCursorSelectionMonId -// lsls r0, 24 -// lsrs r0, 24 -// movs r6, 0x64 -// muls r0, r6 -// ldr r4, =gPlayerParty -// adds r0, r4 -// movs r1, 0x3A -// bl GetMonData -// adds r5, r0, 0 -// lsls r5, 16 -// lsrs r5, 16 -// bl GetCursorSelectionMonId -// lsls r0, 24 -// lsrs r0, 24 -// muls r0, r6 -// adds r0, r4 -// movs r1, 0x39 -// bl GetMonData -// adds r4, r0, 0 -// lsls r4, 16 -// lsrs r4, 16 -// adds r0, r5, 0 -// movs r1, 0x5 -// bl __udivsi3 -// lsls r0, 16 -// lsrs r0, 16 -// cmp r4, r0 -// bhi _08161558 -// movs r0, 0 -// b _0816155A -// .pool -//_08161558: -// movs r0, 0x1 -//_0816155A: -// pop {r4-r6} -// pop {r1} -// bx r1 -// thumb_func_end hm_prepare_dive_probably - -// thumb_func_start sub_8161560 -//sub_8161560: @ 8161560 -// push {r4,lr} -// adds r4, r0, 0 -// lsls r4, 24 -// lsrs r4, 24 -// ldr r0, =gUnknown_0203CEC8 -// movs r1, 0xA -// strb r1, [r0, 0xB] -// ldrb r1, [r0, 0x9] -// strb r1, [r0, 0xA] -// bl GetCursorSelectionMonId -// lsls r0, 24 -// lsrs r0, 24 -// movs r1, 0x1 -// bl sub_81B0FCC -// movs r0, 0x5 -// bl display_pokemon_menu_message -// ldr r1, =gTasks -// lsls r0, r4, 2 -// adds r0, r4 -// lsls r0, 3 -// adds r0, r1 -// ldr r1, =sub_81B1370 -// str r1, [r0] -// pop {r4} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end sub_8161560 - -// thumb_func_start sub_81615A8 -//sub_81615A8: @ 81615A8 -// push {r4-r7,lr} -// mov r7, r10 -// mov r6, r9 -// mov r5, r8 -// push {r5-r7} -// sub sp, 0x8 -// lsls r0, 24 -// lsrs r4, r0, 24 -// str r4, [sp, 0x4] -// ldr r1, =gUnknown_0203CEC8 -// ldrb r7, [r1, 0x9] -// mov r8, r7 -// ldrb r0, [r1, 0xA] -// adds r5, r0, 0 -// cmp r5, 0x6 -// bls _081615EC -// movs r0, 0 -// strb r0, [r1, 0xB] -// bl display_pokemon_menu_message -// ldr r1, =gTasks -// lsls r0, r4, 2 -// adds r0, r4 -// lsls r0, 3 -// adds r0, r1 -// ldr r1, =sub_81B1370 -// str r1, [r0] -// b _08161658 -// .pool -//_081615EC: -// movs r0, 0x64 -// mov r10, r0 -// mov r0, r10 -// muls r0, r5 -// ldr r1, =gPlayerParty -// mov r9, r1 -// adds r6, r0, r1 -// adds r0, r6, 0 -// movs r1, 0x39 -// bl GetMonData -// lsls r0, 16 -// lsrs r4, r0, 16 -// cmp r4, 0 -// beq _0816161A -// cmp r7, r5 -// beq _0816161A -// adds r0, r6, 0 -// movs r1, 0x3A -// bl GetMonData -// cmp r0, r4 -// bne _08161628 -//_0816161A: -// ldr r0, [sp, 0x4] -// bl sub_81617B8 -// b _08161658 -// .pool -//_08161628: -// movs r0, 0x1 -// bl PlaySE -// mov r1, r10 -// mov r0, r8 -// muls r0, r1 -// add r0, r9 -// movs r1, 0x3A -// bl GetMonData -// movs r1, 0x5 -// bl __udivsi3 -// adds r3, r0, 0 -// lsls r3, 16 -// asrs r3, 16 -// movs r2, 0x1 -// negs r2, r2 -// ldr r0, =sub_816166C -// str r0, [sp] -// ldr r0, [sp, 0x4] -// mov r1, r8 -// bl sub_81B1F18 -//_08161658: -// add sp, 0x8 -// pop {r3-r5} -// mov r8, r3 -// mov r9, r4 -// mov r10, r5 -// pop {r4-r7} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end sub_81615A8 - -// thumb_func_start sub_816166C -//sub_816166C: @ 816166C -// push {r4,r5,lr} -// sub sp, 0x4 -// adds r4, r0, 0 -// lsls r4, 24 -// lsrs r4, 24 -// movs r0, 0x1 -// bl PlaySE -// ldr r5, =gUnknown_0203CEC8 -// movs r1, 0x9 -// ldrsb r1, [r5, r1] -// movs r0, 0x64 -// muls r0, r1 -// ldr r1, =gPlayerParty -// adds r0, r1 -// movs r1, 0x3A -// bl GetMonData -// movs r1, 0x5 -// bl __udivsi3 -// adds r3, r0, 0 -// lsls r3, 16 -// asrs r3, 16 -// ldrb r1, [r5, 0xA] -// ldr r0, =sub_81616C0 -// str r0, [sp] -// adds r0, r4, 0 -// movs r2, 0x1 -// bl sub_81B1F18 -// add sp, 0x4 -// pop {r4,r5} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end sub_816166C - -// thumb_func_start sub_81616C0 -//sub_81616C0: @ 81616C0 -// push {r4,r5,lr} -// adds r5, r0, 0 -// lsls r5, 24 -// lsrs r5, 24 -// ldr r0, =gUnknown_0203CEC8 -// movs r1, 0xA -// ldrsb r1, [r0, r1] -// movs r0, 0x64 -// muls r0, r1 -// ldr r1, =gPlayerParty -// adds r0, r1 -// ldr r1, =gStringVar1 -// bl GetMonNickname -// ldr r4, =gStringVar4 -// ldr r1, =gText_PkmnHPRestoredByVar2 -// adds r0, r4, 0 -// bl StringExpandPlaceholders -// adds r0, r4, 0 -// movs r1, 0 -// bl sub_81B1B5C -// movs r0, 0x2 -// bl schedule_bg_copy_tilemap_to_vram -// ldr r1, =gTasks -// lsls r0, r5, 2 -// adds r0, r5 -// lsls r0, 3 -// adds r0, r1 -// ldr r1, =sub_8161724 -// str r1, [r0] -// pop {r4,r5} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end sub_81616C0 - - thumb_func_start sub_8161724 -sub_8161724: @ 8161724 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - bl sub_81B1BD4 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08161772 - ldr r4, =gUnknown_0203CEC8 - movs r0, 0 - strb r0, [r4, 0xB] - ldrb r0, [r4, 0x9] - movs r1, 0 - bl sub_81B0FCC - ldrb r0, [r4, 0xA] - strb r0, [r4, 0x9] - ldrb r0, [r4, 0xA] - movs r1, 0x1 - bl sub_81B0FCC - movs r0, 0x6 - movs r1, 0 - bl sub_8198070 - movs r0, 0x6 - bl ClearWindowTilemap - movs r0, 0 - bl display_pokemon_menu_message - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_81B1370 - str r1, [r0] -_08161772: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8161724 - - thumb_func_start sub_8161784 -sub_8161784: @ 8161784 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl sub_81B1BD4 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _081617AA - movs r0, 0x5 - bl display_pokemon_menu_message - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_81B1370 - str r0, [r1] -_081617AA: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8161784 - - thumb_func_start sub_81617B8 -sub_81617B8: @ 81617B8 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x5 - bl PlaySE - ldr r0, =gText_CantBeUsedOnPkmn - movs r1, 0 - bl sub_81B1B5C - movs r0, 0x2 - bl schedule_bg_copy_tilemap_to_vram - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_8161784 - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81617B8 - - .align 2, 0 @ Don't pad with nop. diff --git a/include/fldeff_softboiled.h b/include/fldeff_softboiled.h deleted file mode 100644 index 0e3b98a46..000000000 --- a/include/fldeff_softboiled.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef GUARD_FLDEFF_SOFTBOILED_H -#define GUARD_FLDEFF_SOFTBOILED_H - -bool8 SetUpFieldMove_SoftBoiled(void); -void sub_8161560(u8 taskid); - - -#endif // GUARD_FLDEFF_SOFTBOILED_H diff --git a/include/party_menu.h b/include/party_menu.h index 25c389493..1ce12d98f 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -33,8 +33,9 @@ void sub_81B7F60(void); void sub_81B0FCC(u8 partyIdx, u8 a); void sub_81B1370(u8 taskId); -void display_pokemon_menu_message(u8 windowBorderId); +void display_pokemon_menu_message(u8 windowId); void sub_81B1F18(u8 taskId, u8 pokemonIdx, s8 a, s16 hp, TaskFunc func); void sub_81B1B5C(void *a, u8 b); +u8 sub_81B1BD4(); #endif // GUARD_PARTY_MENU_H diff --git a/include/strings.h b/include/strings.h index 4632938da..70b2777e1 100644 --- a/include/strings.h +++ b/include/strings.h @@ -350,6 +350,7 @@ extern const u8 gText_ThreeDashes[]; //party menu text extern const u8 gText_PkmnHPRestoredByVar2[]; +extern const u8 gText_CantBeUsedOnPkmn[]; //birch dex rating text extern const u8 gBirchDexRatingText_LessThan10[]; diff --git a/ld_script.txt b/ld_script.txt index ae782a00b..a6971b8d1 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -211,7 +211,6 @@ SECTIONS { asm/battle_anim_815A0D4.o(.text); asm/learn_move.o(.text); src/fldeff_softboiled.o(.text); - asm/fldeff_softboiled.o(.text); src/decoration_inventory.o(.text); src/roamer.o(.text); asm/battle_tower.o(.text); diff --git a/src/fldeff_softboiled.c b/src/fldeff_softboiled.c index 3420faed7..b61cf9f32 100644 --- a/src/fldeff_softboiled.c +++ b/src/fldeff_softboiled.c @@ -1,9 +1,7 @@ #include "global.h" -#include "fldeff_softboiled.h" #include "menu.h" #include "party_menu.h" #include "pokemon.h" -//#include "pokemon_menu.h" #include "constants/songs.h" #include "sound.h" #include "sprite.h" @@ -27,9 +25,7 @@ bool8 SetUpFieldMove_SoftBoiled(void) minHp = (maxHp / 5); if (hp > minHp) - { return TRUE; - } return FALSE; } @@ -82,3 +78,32 @@ void sub_81616C0(u8 taskId) gTasks[taskId].func = sub_8161724; } +void sub_8161724(u8 taskId) +{ + if(sub_81B1BD4() == 1) + return; + gUnknown_0203CEC8.unkB = 0x0; + sub_81B0FCC(gUnknown_0203CEC8.unk9, 0); + gUnknown_0203CEC8.unk9 = gUnknown_0203CEC8.unkA; + sub_81B0FCC(gUnknown_0203CEC8.unkA, 1); + sub_8198070(0x6, FALSE); + ClearWindowTilemap(0x6); + display_pokemon_menu_message(0); + gTasks[taskId].func = sub_81B1370; +} + +void sub_8161784(u8 taskId) +{ + if(sub_81B1BD4() == 1) + return; + display_pokemon_menu_message(0x5); + gTasks[taskId].func = sub_81B1370; +} + +void sub_81617B8(u8 taskId) +{ + PlaySE(SE_SELECT); + sub_81B1B5C(&gText_CantBeUsedOnPkmn, 0); + schedule_bg_copy_tilemap_to_vram(2); + gTasks[taskId].func = sub_8161784; +} From 824699f505d373b1cc1247347b9c69d6ef1ce8ca Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 15 Feb 2018 23:09:52 +0100 Subject: [PATCH 27/27] overworld review changes2 --- include/global.fieldmap.h | 2 +- src/overworld.c | 13 +++++++------ src/script.c | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index 6e262dc9c..94127c554 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -164,7 +164,7 @@ struct MapHeader { /* 0x00 */ const struct MapData *mapData; /* 0x04 */ const struct MapEvents *events; - /* 0x08 */ u8 *mapScripts; + /* 0x08 */ const u8 *mapScripts; /* 0x0C */ const struct MapConnections *connections; /* 0x10 */ u16 music; /* 0x12 */ u16 mapDataId; diff --git a/src/overworld.c b/src/overworld.c index fd1173ffc..6ee338cb8 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -605,15 +605,16 @@ bool32 warp_data_is_not_neg_1(struct WarpData *warp) { if (warp->mapGroup != -1) return FALSE; - if (warp->mapNum != -1) + else if (warp->mapNum != -1) return FALSE; - if (warp->warpId != -1) + else if (warp->warpId != -1) return FALSE; - if (warp->x != -1) + else if (warp->x != -1) return FALSE; - if (warp->y != -1) + else if (warp->y != -1) return FALSE; - return TRUE; + else + return TRUE; } const struct MapHeader *Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum) @@ -2125,7 +2126,7 @@ static void map_loading_lcd_reset(void) SetGpuReg(REG_OFFSET_WIN1V, 0xFFFF); SetGpuReg(REG_OFFSET_BLDCNT, gUnknown_82EC7C4[1] | gUnknown_82EC7C4[2] | gUnknown_82EC7C4[3] | BLDCNT_TGT2_OBJ | BLDCNT_EFFECT_BLEND); - SetGpuReg(REG_OFFSET_BLDALPHA, 0x70D); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(13, 7)); overworld_bg_setup(); schedule_bg_copy_tilemap_to_vram(1); schedule_bg_copy_tilemap_to_vram(2); diff --git a/src/script.c b/src/script.c index 5a1c5daa9..8c868128b 100644 --- a/src/script.c +++ b/src/script.c @@ -243,7 +243,7 @@ void ScriptContext2_RunNewScript(const u8 *ptr) u8 *mapheader_get_tagged_pointer(u8 tag) { - u8 *mapScripts = gMapHeader.mapScripts; + const u8 *mapScripts = gMapHeader.mapScripts; if (!mapScripts) return NULL;