From 3793152bc3666043764689af9821ef15da1243ae Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Mon, 29 Jan 2018 17:26:36 -0600 Subject: [PATCH] More work on menu --- asm/menu.s | 877 +------------------------ graphics/unused/intro_birch_beauty.png | Bin 2268 -> 2116 bytes include/dma3.h | 2 +- include/global.h | 2 +- include/menu.h | 4 +- src/dma3_manager.c | 2 +- src/menu.c | 275 +++++++- 7 files changed, 280 insertions(+), 882 deletions(-) diff --git a/asm/menu.s b/asm/menu.s index 9df53d5c10..ff5bec251a 100644 --- a/asm/menu.s +++ b/asm/menu.s @@ -5,882 +5,7 @@ .text - thumb_func_start CreateYesNoMenu -@ void CreateYesNoMenu(struct WindowTemplate *windowTemplate, u16 borderFirstTileNum, u8 borderPalette, u8 initialCursorPos) -CreateYesNoMenu: @ 81996C0 - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - sub sp, 0x10 - adds r4, r1, 0 - adds r5, r2, 0 - adds r6, r3, 0 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 24 - lsrs r5, 24 - lsls r6, 24 - lsrs r6, 24 - ldr r1, =gUnknown_0203CD9F - mov r8, r1 - bl AddWindow - mov r2, r8 - strb r0, [r2] - ldrb r0, [r2] - movs r1, 0x1 - adds r2, r4, 0 - adds r3, r5, 0 - bl SetWindowBorderStyle - ldr r0, =gText_YesNo - str r0, [sp] - mov r1, sp - mov r2, r8 - ldrb r0, [r2] - movs r2, 0 - mov r9, r2 - strb r0, [r1, 0x4] - mov r0, sp - movs r2, 0x1 - strb r2, [r0, 0x5] - movs r0, 0x8 - strb r0, [r1, 0x6] - mov r0, sp - strb r2, [r0, 0x7] - ldrb r0, [r0, 0x6] - strb r0, [r1, 0x8] - mov r0, sp - ldrb r0, [r0, 0x7] - strb r0, [r1, 0x9] - movs r0, 0x1 - movs r1, 0x5 - bl GetFontAttribute - mov r3, sp - lsls r0, 4 - ldrb r2, [r3, 0xC] - movs r5, 0xF - adds r1, r5, 0 - ands r1, r2 - orrs r1, r0 - strb r1, [r3, 0xC] - movs r0, 0x1 - movs r1, 0x6 - bl GetFontAttribute - mov r3, sp - adds r1, r5, 0 - ands r1, r0 - ldrb r2, [r3, 0xD] - movs r4, 0x10 - negs r4, r4 - adds r0, r4, 0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3, 0xD] - movs r0, 0x1 - movs r1, 0x7 - bl GetFontAttribute - mov r3, sp - lsls r0, 4 - ldrb r2, [r3, 0xD] - adds r1, r5, 0 - ands r1, r2 - orrs r1, r0 - strb r1, [r3, 0xD] - movs r0, 0x1 - movs r1, 0x4 - bl GetFontAttribute - mov r1, sp - ands r5, r0 - ldrb r0, [r1, 0xC] - ands r4, r0 - orrs r4, r5 - strb r4, [r1, 0xC] - mov r0, sp - mov r1, r9 - strb r1, [r0, 0xA] - strb r1, [r0, 0xB] - movs r1, 0xFF - movs r2, 0 - bl AddTextPrinter - mov r2, r8 - ldrb r0, [r2] - movs r1, 0x2 - adds r2, r6, 0 - bl InitMenuInUpperLeftCornerPlaySoundWhenAPressed - add sp, 0x10 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end CreateYesNoMenu - - thumb_func_start sub_81997AC -sub_81997AC: @ 81997AC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x14 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - lsls r1, 24 - lsrs r1, 24 - str r1, [sp, 0xC] - lsls r2, 24 - lsrs r6, r2, 24 - lsls r3, 24 - lsrs r3, 24 - str r3, [sp, 0x10] - movs r7, 0 - cmp r7, r3 - bcs _08199824 -_081997D4: - movs r4, 0 - adds r0, r7, 0x1 - mov r9, r0 - cmp r4, r6 - bcs _0819981C - lsls r0, r7, 4 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r5, 0x80 - lsls r5, 20 -_081997EC: - adds r0, r7, 0 - muls r0, r6 - adds r0, r4 - lsls r0, 3 - ldr r1, [sp, 0x34] - adds r0, r1 - ldr r2, [r0] - lsrs r3, r5, 24 - mov r0, r8 - str r0, [sp] - movs r0, 0xFF - str r0, [sp, 0x4] - movs r0, 0 - str r0, [sp, 0x8] - mov r0, r10 - movs r1, 0x1 - bl PrintTextOnWindow - ldr r1, [sp, 0xC] - lsls r0, r1, 24 - adds r5, r0 - adds r4, 0x1 - cmp r4, r6 - bcc _081997EC -_0819981C: - mov r7, r9 - ldr r4, [sp, 0x10] - cmp r7, r4 - bcc _081997D4 -_08199824: - mov r0, r10 - movs r1, 0x2 - bl CopyWindowToVram - add sp, 0x14 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81997AC - - thumb_func_start sub_819983C -sub_819983C: @ 819983C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x18 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x10] - lsls r1, 24 - lsrs r1, 24 - str r1, [sp, 0x14] - lsls r2, 24 - lsrs r2, 24 - mov r8, r2 - lsls r3, 24 - lsrs r3, 24 - mov r10, r3 - mov r0, sp - movs r6, 0 - ldrb r1, [r0, 0x10] - strb r1, [r0, 0x4] - mov r1, sp - movs r0, 0x1 - strb r0, [r1, 0x5] - movs r1, 0x5 - bl GetFontAttribute - mov r3, sp - lsls r0, 4 - ldrb r2, [r3, 0xC] - movs r5, 0xF - adds r1, r5, 0 - ands r1, r2 - orrs r1, r0 - strb r1, [r3, 0xC] - movs r0, 0x1 - movs r1, 0x6 - bl GetFontAttribute - mov r3, sp - adds r1, r5, 0 - ands r1, r0 - ldrb r2, [r3, 0xD] - movs r4, 0x10 - negs r4, r4 - adds r0, r4, 0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3, 0xD] - movs r0, 0x1 - movs r1, 0x7 - bl GetFontAttribute - mov r3, sp - lsls r0, 4 - ldrb r2, [r3, 0xD] - adds r1, r5, 0 - ands r1, r2 - orrs r1, r0 - strb r1, [r3, 0xD] - movs r0, 0x1 - movs r1, 0x4 - bl GetFontAttribute - mov r1, sp - ands r5, r0 - ldrb r0, [r1, 0xC] - ands r4, r0 - orrs r4, r5 - strb r4, [r1, 0xC] - mov r0, sp - strb r6, [r0, 0xA] - strb r6, [r0, 0xB] - movs r7, 0 - cmp r7, r10 - bcs _0819992A -_081998D6: - movs r5, 0 - adds r2, r7, 0x1 - mov r9, r2 - cmp r5, r8 - bcs _08199920 - mov r4, sp - lsls r0, r7, 4 - adds r6, r0, 0x1 -_081998E6: - mov r0, r8 - muls r0, r7 - adds r0, r5 - ldr r1, [sp, 0x3C] - adds r0, r1, r0 - ldrb r0, [r0] - lsls r0, 3 - ldr r2, [sp, 0x38] - adds r0, r2 - ldr r0, [r0] - str r0, [sp] - ldr r1, [sp, 0x14] - adds r0, r1, 0 - muls r0, r5 - adds r0, 0x8 - strb r0, [r4, 0x6] - strb r6, [r4, 0x7] - strb r0, [r4, 0x8] - strb r6, [r4, 0x9] - mov r0, sp - movs r1, 0xFF - movs r2, 0 - bl AddTextPrinter - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, r8 - bcc _081998E6 -_08199920: - mov r2, r9 - lsls r0, r2, 24 - lsrs r7, r0, 24 - cmp r7, r10 - bcc _081998D6 -_0819992A: - ldr r0, [sp, 0x10] - movs r1, 0x2 - bl CopyWindowToVram - add sp, 0x18 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_819983C - - thumb_func_start sub_8199944 -sub_8199944: @ 8199944 - push {r4-r7,lr} - ldr r4, [sp, 0x14] - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r3, 24 - lsls r4, 24 - lsrs r7, r4, 24 - ldr r6, =gUnknown_0203CD90 - movs r4, 0 - mov r12, r4 - mov r4, r12 - strb r4, [r6] - movs r5, 0x1 - strb r5, [r6, 0x1] - strb r4, [r6, 0x3] - adds r4, r2, 0 - muls r4, r3 - subs r4, 0x1 - strb r4, [r6, 0x4] - strb r0, [r6, 0x5] - strb r5, [r6, 0x6] - strb r1, [r6, 0x7] - movs r0, 0x10 - strb r0, [r6, 0x8] - strb r2, [r6, 0x9] - strb r3, [r6, 0xA] - cmp r7, 0 - blt _08199986 - movs r0, 0x4 - ldrsb r0, [r6, r0] - cmp r7, r0 - ble _08199990 -_08199986: - mov r0, r12 - strb r0, [r6, 0x2] - b _08199992 - .pool -_08199990: - strb r7, [r6, 0x2] -_08199992: - movs r0, 0 - movs r1, 0 - bl sub_8199134 - ldr r0, =gUnknown_0203CD90 - ldrb r0, [r0, 0x2] - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8199944 - - thumb_func_start clear_scheduled_bg_copies_to_vram -@ void clear_scheduled_bg_copies_to_vram() -clear_scheduled_bg_copies_to_vram: @ 81999A8 - push {lr} - ldr r0, =gUnknown_0203CDA4 - movs r1, 0 - movs r2, 0x4 - bl memset - pop {r0} - bx r0 - .pool - thumb_func_end clear_scheduled_bg_copies_to_vram - - thumb_func_start schedule_bg_copy_tilemap_to_vram -@ void schedule_bg_copy_tilemap_to_vram(u8 bg_id) -schedule_bg_copy_tilemap_to_vram: @ 81999BC - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0203CDA4 - adds r0, r1 - movs r1, 0x1 - strb r1, [r0] - bx lr - .pool - thumb_func_end schedule_bg_copy_tilemap_to_vram - - thumb_func_start do_scheduled_bg_tilemap_copies_to_vram -@ void do_scheduled_bg_tilemap_copies_to_vram() -do_scheduled_bg_tilemap_copies_to_vram: @ 81999D0 - push {r4,lr} - ldr r4, =gUnknown_0203CDA4 - ldrb r0, [r4] - cmp r0, 0x1 - bne _081999E4 - movs r0, 0 - bl CopyBgTilemapBufferToVram - movs r0, 0 - strb r0, [r4] -_081999E4: - ldrb r0, [r4, 0x1] - cmp r0, 0x1 - bne _081999F4 - movs r0, 0x1 - bl CopyBgTilemapBufferToVram - movs r0, 0 - strb r0, [r4, 0x1] -_081999F4: - ldrb r0, [r4, 0x2] - cmp r0, 0x1 - bne _08199A04 - movs r0, 0x2 - bl CopyBgTilemapBufferToVram - movs r0, 0 - strb r0, [r4, 0x2] -_08199A04: - ldrb r0, [r4, 0x3] - cmp r0, 0x1 - bne _08199A14 - movs r0, 0x3 - bl CopyBgTilemapBufferToVram - movs r0, 0 - strb r0, [r4, 0x3] -_08199A14: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end do_scheduled_bg_tilemap_copies_to_vram - - thumb_func_start reset_temp_tile_data_buffers -@ void reset_temp_tile_data_buffers() -reset_temp_tile_data_buffers: @ 8199A20 - push {lr} - ldr r3, =gUnknown_0203CDA8 - ldr r1, =gUnknown_0203CDAC - movs r2, 0 - adds r0, r1, 0 - adds r0, 0x7C -_08199A2C: - str r2, [r0] - subs r0, 0x4 - cmp r0, r1 - bge _08199A2C - movs r0, 0 - strh r0, [r3] - pop {r0} - bx r0 - .pool - thumb_func_end reset_temp_tile_data_buffers - - thumb_func_start free_temp_tile_data_buffers_if_possible -free_temp_tile_data_buffers_if_possible: @ 8199A44 - push {r4-r6,lr} - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _08199A88 - ldr r1, =gUnknown_0203CDA8 - ldrh r0, [r1] - cmp r0, 0 - beq _08199A7C - movs r4, 0 - ldrh r1, [r1] - cmp r4, r1 - bge _08199A76 - ldr r5, =gUnknown_0203CDAC - movs r6, 0 -_08199A64: - ldr r0, [r5] - bl Free - stm r5!, {r6} - adds r4, 0x1 - ldr r0, =gUnknown_0203CDA8 - ldrh r0, [r0] - cmp r4, r0 - blt _08199A64 -_08199A76: - ldr r1, =gUnknown_0203CDA8 - movs r0, 0 - strh r0, [r1] -_08199A7C: - movs r0, 0 - b _08199A8A - .pool -_08199A88: - movs r0, 0x1 -_08199A8A: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end free_temp_tile_data_buffers_if_possible - - thumb_func_start decompress_and_copy_tile_data_to_vram -@ int decompress_and_copy_tile_data_to_vram(u8 bg_id, int src, int size, u16 offset, u8 mode) -decompress_and_copy_tile_data_to_vram: @ 8199A90 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x8 - adds r4, r1, 0 - adds r5, r2, 0 - ldr r1, [sp, 0x24] - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r3, 16 - lsrs r3, 16 - mov r9, r3 - lsls r1, 24 - lsrs r7, r1, 24 - ldr r6, =gUnknown_0203CDA8 - ldrh r0, [r6] - cmp r0, 0x1F - bhi _08199AF8 - adds r0, r4, 0 - add r1, sp, 0x4 - bl malloc_and_decompress - adds r4, r0, 0 - cmp r5, 0 - bne _08199AC8 - ldr r5, [sp, 0x4] -_08199AC8: - cmp r4, 0 - beq _08199AEC - lsls r2, r5, 16 - lsrs r2, 16 - str r7, [sp] - mov r0, r8 - adds r1, r4, 0 - mov r3, r9 - bl copy_decompressed_tile_data_to_vram - ldr r2, =gUnknown_0203CDAC - ldrh r0, [r6] - adds r1, r0, 0x1 - strh r1, [r6] - lsls r0, 16 - lsrs r0, 14 - adds r0, r2 - str r4, [r0] -_08199AEC: - adds r0, r4, 0 - b _08199AFA - .pool -_08199AF8: - movs r0, 0 -_08199AFA: - add sp, 0x8 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end decompress_and_copy_tile_data_to_vram - - thumb_func_start copy_decompressed_tile_data_to_vram_autofree -@ void copy_decompressed_tile_data_to_vram_autofree(u8 bg_id, int src, u16 size, u16 offset, u8 mode) -copy_decompressed_tile_data_to_vram_autofree: @ 8199B08 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x8 - adds r5, r2, 0 - ldr r2, [sp, 0x24] - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r3, 16 - lsrs r3, 16 - mov r9, r3 - lsls r2, 24 - lsrs r7, r2, 24 - adds r0, r1, 0 - add r1, sp, 0x4 - bl malloc_and_decompress - adds r6, r0, 0 - cmp r5, 0 - bne _08199B36 - ldr r5, [sp, 0x4] -_08199B36: - cmp r6, 0 - beq _08199B6E - ldr r0, =task_free_buf_after_copying_tile_data_to_vram - movs r1, 0 - bl CreateTask - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r2, r5, 16 - lsrs r2, 16 - str r7, [sp] - mov r0, r8 - adds r1, r6, 0 - mov r3, r9 - bl copy_decompressed_tile_data_to_vram - ldr r2, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r2 - strh r0, [r1, 0x8] - adds r0, r4, 0 - movs r1, 0x1 - adds r2, r6, 0 - bl SetWordTaskArg -_08199B6E: - add sp, 0x8 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end copy_decompressed_tile_data_to_vram_autofree - - thumb_func_start task_free_buf_after_copying_tile_data_to_vram -@ void task_free_buf_after_copying_tile_data_to_vram(int task_id) -task_free_buf_after_copying_tile_data_to_vram: @ 8199B84 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - movs r1, 0x8 - ldrsh r0, [r0, r1] - bl CheckForSpaceForDma3Request - lsls r0, 16 - cmp r0, 0 - bne _08199BB4 - adds r0, r4, 0 - movs r1, 0x1 - bl GetWordTaskArg - bl Free - adds r0, r4, 0 - bl DestroyTask -_08199BB4: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task_free_buf_after_copying_tile_data_to_vram - - thumb_func_start malloc_and_decompress -@ void *malloc_and_decompress(void *src, int *size) -malloc_and_decompress: @ 8199BC0 - push {r4,r5,lr} - adds r5, r0, 0 - ldrb r0, [r5, 0x1] - strb r0, [r1] - ldrb r0, [r5, 0x2] - strb r0, [r1, 0x1] - ldrb r0, [r5, 0x3] - strb r0, [r1, 0x2] - movs r0, 0 - strb r0, [r1, 0x3] - ldr r0, [r1] - bl Alloc - adds r4, r0, 0 - cmp r4, 0 - beq _08199BE8 - adds r0, r5, 0 - adds r1, r4, 0 - bl LZ77UnCompWram -_08199BE8: - adds r0, r4, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end malloc_and_decompress - - thumb_func_start copy_decompressed_tile_data_to_vram -@ s16 copy_decompressed_tile_data_to_vram(u8 bg_id, int src, u16 size, u16 offset, u8 mode) -copy_decompressed_tile_data_to_vram: @ 8199BF0 - push {r4,lr} - adds r4, r1, 0 - ldr r1, [sp, 0x8] - lsls r0, 24 - lsrs r0, 24 - lsls r2, 16 - lsrs r2, 16 - lsls r3, 16 - lsrs r3, 16 - lsls r1, 24 - lsrs r1, 24 - cmp r1, 0 - beq _08199C18 - cmp r1, 0x1 - beq _08199C20 - ldr r0, =0x0000ffff - b _08199C2A - .pool -_08199C18: - adds r1, r4, 0 - bl LoadBgTiles - b _08199C26 -_08199C20: - adds r1, r4, 0 - bl LoadBgTilemap -_08199C26: - lsls r0, 16 - lsrs r0, 16 -_08199C2A: - pop {r4} - pop {r1} - bx r1 - thumb_func_end copy_decompressed_tile_data_to_vram - - thumb_func_start sub_8199C30 -sub_8199C30: @ 8199C30 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - adds r5, r2, 0 - ldr r4, [sp, 0x28] - ldr r2, [sp, 0x2C] - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - str r1, [sp] - lsls r5, 24 - lsrs r5, 24 - lsls r3, 24 - lsrs r3, 24 - str r3, [sp, 0x4] - lsls r4, 24 - lsrs r4, 24 - lsls r2, 24 - lsrs r2, 24 - mov r10, r2 - bl GetBgTilemapBuffer - mov r8, r0 - adds r0, r5, r4 - cmp r5, r0 - bge _08199CA8 - mov r9, r0 -_08199C6E: - ldr r3, [sp] - ldr r1, [sp, 0x4] - adds r0, r3, r1 - adds r7, r5, 0x1 - cmp r3, r0 - bge _08199CA0 - lsls r6, r5, 5 - ldr r1, =0x00000fff - mov r12, r1 - mov r1, r10 - lsls r5, r1, 12 - adds r4, r0, 0 -_08199C86: - adds r1, r6, r3 - lsls r1, 1 - add r1, r8 - ldrh r2, [r1] - mov r0, r12 - ands r0, r2 - orrs r0, r5 - strh r0, [r1] - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, r4 - blt _08199C86 -_08199CA0: - lsls r0, r7, 24 - lsrs r5, r0, 24 - cmp r5, r9 - blt _08199C6E -_08199CA8: - 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_8199C30 - - thumb_func_start sub_8199CBC -sub_8199CBC: @ 8199CBC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - mov r10, r1 - ldr r1, [sp, 0x24] - ldr r4, [sp, 0x28] - lsls r0, 24 - lsrs r0, 24 - lsls r2, 24 - lsrs r2, 24 - mov r9, r2 - lsls r3, 24 - lsrs r3, 24 - str r3, [sp] - lsls r1, 24 - lsrs r5, r1, 24 - lsls r4, 24 - lsrs r4, 24 - mov r8, r4 - bl GetBgTilemapBuffer - adds r7, r0, 0 - movs r0, 0 - cmp r0, r8 - bcs _08199D2A -_08199CF4: - movs r2, 0 - adds r6, r0, 0x1 - cmp r2, r5 - bcs _08199D22 - adds r4, r0, 0 - muls r4, r5 - ldr r1, [sp] - adds r0, r1 - lsls r3, r0, 5 -_08199D06: - adds r1, r4, r2 - lsls r1, 1 - add r1, r10 - adds r0, r3, r2 - add r0, r9 - lsls r0, 1 - adds r0, r7 - ldrh r0, [r0] - strh r0, [r1] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, r5 - bcc _08199D06 -_08199D22: - lsls r0, r6, 24 - lsrs r0, 24 - cmp r0, r8 - bcc _08199CF4 -_08199D2A: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8199CBC - + thumb_func_start sub_8199D3C sub_8199D3C: @ 8199D3C push {r4-r7,lr} diff --git a/graphics/unused/intro_birch_beauty.png b/graphics/unused/intro_birch_beauty.png index 817db46f7070722262e732863ddc89eac9a2eae2..85951c902a2e20ca60fbaee94a8b152c559834de 100644 GIT binary patch delta 2009 zcmV;~2PXL35yTLXB#|*-e+Q~bL_t(&-tC%iXcK1~#}AvhP!_@^eKi=;yMp4VC6`*A zP-~O3EkZXzuUiCL|ID-Xg`K4m-?{py$)=re8u7`Cv~M!FW2A3|)D8A(vytj_D0ZRX zn2^4>IcH0C4cT+KOPZ$nUAQOnh0y0kFXW!z=YG%Md%oY4dgn@Tf6NiQZ&bm;cNyJ& zvU@qWyxV|a8SNi^1>d#@+OjvYyKlfXKItD7FT4P6+b&!jqMI&+z#10u+tbVLHW2Xm z;s{OC%gb5t3H{M>y3Hn0sHf#Ky4?b-(dMuzL@h9MX*8tig1BTlf1wh`tW zJ;XIa6)dN3T;Ae!e>*e4IN5$3*?XLBdDhqnJz$U?+42Wn=V=89oO|!zbknn~jllhm zL00XgHjjrbUxPb`Z`01kT|fq-{caV|^pK-JEL)+*i^FNA`^)n27BR$gw3~L>AJ89^ zuhK=kom-g{kbtc}5b9=j{FHe>JAp<%a=V6y8cP9l)7rHoe|X_a_94^skfyf-&#?0x z!#*mZ+kf~-`^MH8$~s!-Qw+^c0stz-cXyX2@cz?jy}s=R<(SHF3+F{};ZNa0$VIgu>M97>I~3;dpC2&3SgBQo>?i{*!O}&FAtPgZOCr z1S6twDWMS0e>5S4;Qgdmi7JA421zIk#4|BJ5~e^vT!~16Fd$1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{s2k6s`DTK>i7>+_)L4~YL#yQ0000 gUnknown_0203CD90.maxCursorPos) + gUnknown_0203CD90.cursorPos = 0; + else + gUnknown_0203CD90.cursorPos = pos; + + sub_8199134(0, 0); + return gUnknown_0203CD90.cursorPos; +} + +void clear_scheduled_bg_copies_to_vram(void) +{ + memset(gUnknown_0203CDA4, 0, sizeof(gUnknown_0203CDA4)); +} + +void schedule_bg_copy_tilemap_to_vram(u8 bgId) +{ + gUnknown_0203CDA4[bgId] = TRUE; +} + +void do_scheduled_bg_tilemap_copies_to_vram(void) +{ + if (gUnknown_0203CDA4[0] == TRUE) + { + CopyBgTilemapBufferToVram(0); + gUnknown_0203CDA4[0] = FALSE; + } + if (gUnknown_0203CDA4[1] == TRUE) + { + CopyBgTilemapBufferToVram(1); + gUnknown_0203CDA4[1] = FALSE; + } + if (gUnknown_0203CDA4[2] == TRUE) + { + CopyBgTilemapBufferToVram(2); + gUnknown_0203CDA4[2] = FALSE; + } + if (gUnknown_0203CDA4[3] == TRUE) + { + CopyBgTilemapBufferToVram(3); + gUnknown_0203CDA4[3] = FALSE; + } +} + +void reset_temp_tile_data_buffers(void) +{ + int i; + for (i = 0; i < (s32)ARRAY_COUNT(gUnknown_0203CDAC); i++) + { + gUnknown_0203CDAC[i] = NULL; + } + gUnknown_0203CDA8 = 0; +} + +bool8 free_temp_tile_data_buffers_if_possible(void) +{ + int i; + + if (!IsDma3ManagerBusyWithBgCopy()) + { + if (gUnknown_0203CDA8) + { + for (i = 0; i < gUnknown_0203CDA8; i++) + { + FREE_AND_SET_NULL(gUnknown_0203CDAC[i]); + } + gUnknown_0203CDA8 = 0; + } + return FALSE; + } + else + { + return TRUE; + } +} + +void *decompress_and_copy_tile_data_to_vram(u8 bgId, const void *src, int size, u16 offset, u8 mode) +{ + int sizeOut; + if (gUnknown_0203CDA8 < ARRAY_COUNT(gUnknown_0203CDAC)) + { + void *ptr = malloc_and_decompress(src, &sizeOut); + if (!size) + size = sizeOut; + if (ptr) + { + copy_decompressed_tile_data_to_vram(bgId, ptr, size, offset, mode); + gUnknown_0203CDAC[gUnknown_0203CDA8++] = ptr; + } + return ptr; + } + return NULL; +} + +void copy_decompressed_tile_data_to_vram_autofree(u8 bgId, const void *src, int size, u16 offset, u8 mode) +{ + int sizeOut; + void *ptr = malloc_and_decompress(src, &sizeOut); + if (!size) + size = sizeOut; + if (ptr) + { + u8 taskId = CreateTask(task_free_buf_after_copying_tile_data_to_vram, 0); + gTasks[taskId].data[0] = copy_decompressed_tile_data_to_vram(bgId, ptr, size, offset, mode); + SetWordTaskArg(taskId, 1, (u32)ptr); + } +} + +void task_free_buf_after_copying_tile_data_to_vram(u8 taskId) +{ + if (!CheckForSpaceForDma3Request(gTasks[taskId].data[0])) + { + Free((void *)GetWordTaskArg(taskId, 1)); + DestroyTask(taskId); + } +} + +void *malloc_and_decompress(const void *src, int *size) +{ + void *ptr; + u8 *sizeAsBytes = (u8 *)size; + u8 *srcAsBytes = (u8 *)src; + + sizeAsBytes[0] = srcAsBytes[1]; + sizeAsBytes[1] = srcAsBytes[2]; + sizeAsBytes[2] = srcAsBytes[3]; + sizeAsBytes[3] = 0; + + ptr = Alloc(*size); + if (ptr) + LZ77UnCompWram(src, ptr); + return ptr; +} + +u16 copy_decompressed_tile_data_to_vram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode) +{ + switch (mode) + { + case 0: + return LoadBgTiles(bgId, src, size, offset); + case 1: + return LoadBgTilemap(bgId, src, size, offset); + default: + return -1; + } +} + +void sub_8199C30(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette) +{ + u8 i; + u8 j; + u16 *ptr = GetBgTilemapBuffer(bgId); + + for (i = top; i < top + height; i++) + { + for (j = left; j < left + width; j++) + { + ptr[(i * 32) + j] = (ptr[(i * 32) + j] & 0xFFF) | (palette << 12); + } + } +} + +void sub_8199CBC(u8 bgId, void *dest, u8 left, u8 top, u8 width, u8 height) +{ + u8 i; + u8 j; + u16 *ptr = GetBgTilemapBuffer(bgId); + u16 *destAsU16 = dest; + + for (i = 0; i < height; i++) + { + for (j = 0; j < width; j++) + { + destAsU16[(i * height) + j] = ptr[(i * height) + j]; + } + } +}