mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-25 19:24:16 +01:00
More work on menu
This commit is contained in:
parent
a3ed94dc69
commit
3793152bc3
877
asm/menu.s
877
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}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.1 KiB |
@ -5,6 +5,6 @@ void ClearDma3Requests(void);
|
||||
void ProcessDma3Requests(void);
|
||||
s16 RequestDma3Copy(const void *src, void *dest, u16 size, u8 mode);
|
||||
s16 RequestDma3Fill(s32 value, void *dest, u16 size, u8 mode);
|
||||
int CheckForSpaceForDma3Request(s16 index);
|
||||
s16 CheckForSpaceForDma3Request(s16 index);
|
||||
|
||||
#endif // GUARD_DMA3_H
|
||||
|
@ -24,7 +24,7 @@
|
||||
#define INCBIN_S32 {0}
|
||||
#endif // __APPLE__
|
||||
|
||||
#define ARRAY_COUNT(array) (sizeof(array) / sizeof((array)[0]))
|
||||
#define ARRAY_COUNT(array) (size_t)(sizeof(array) / sizeof((array)[0]))
|
||||
|
||||
// useful math macros
|
||||
|
||||
|
@ -28,7 +28,7 @@ s8 ProcessMenuInput(void);
|
||||
s8 ProcessMenuInputNoWrapAround(void);
|
||||
void blit_move_info_icon(u8 winId, u8 a2, u16 x, u16 y);
|
||||
void reset_temp_tile_data_buffers(void);
|
||||
int decompress_and_copy_tile_data_to_vram(u8 bg_id, const void *src, int size, u16 offset, u8 mode);
|
||||
void *decompress_and_copy_tile_data_to_vram(u8 bgId, const void *src, int size, u16 offset, u8 mode);
|
||||
bool8 free_temp_tile_data_buffers_if_possible(void);
|
||||
struct WindowTemplate sub_8198A50(u8, u8, u8, u8, u8, u8, u16);
|
||||
void CreateYesNoMenu(const struct WindowTemplate *windowTemplate, u16 borderFirstTileNum, u8 borderPalette, u8 initialCursorPos);
|
||||
@ -40,5 +40,7 @@ void sub_8197B1C(u8 windowId, bool8 copyToVram, u16 a2, u8 a3);
|
||||
void sub_81995E4(u8 windowId, u8 optionsNo, const struct MenuAction *actions, const u8 *actionIds);
|
||||
void sub_8197DF8(u8 windowId, bool8 copyToVram);
|
||||
u16 sub_8198AA4(u8, u8, u8, u8, u8, u8, u16);
|
||||
void *malloc_and_decompress(const void *src, int *sizeOut);
|
||||
u16 copy_decompressed_tile_data_to_vram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode);
|
||||
|
||||
#endif // GUARD_MENU_H
|
||||
|
@ -204,7 +204,7 @@ s16 RequestDma3Fill(s32 value, void *dest, u16 size, u8 mode)
|
||||
return -1; // no free DMA request was found
|
||||
}
|
||||
|
||||
int CheckForSpaceForDma3Request(s16 index)
|
||||
s16 CheckForSpaceForDma3Request(s16 index)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
|
275
src/menu.c
275
src/menu.c
@ -8,6 +8,9 @@
|
||||
#include "main.h"
|
||||
#include "sound.h"
|
||||
#include "menu_helpers.h"
|
||||
#include "malloc.h"
|
||||
#include "task.h"
|
||||
#include "dma3.h"
|
||||
|
||||
struct SomeUnkStruct
|
||||
{
|
||||
@ -37,6 +40,9 @@ extern EWRAM_DATA u16 gUnknown_0203CD9C;
|
||||
extern EWRAM_DATA u8 gUnknown_0203CD9E;
|
||||
extern EWRAM_DATA u8 gUnknown_0203CD9F;
|
||||
extern EWRAM_DATA u8 gUnknown_0203CDA0;
|
||||
extern EWRAM_DATA bool8 gUnknown_0203CDA4[4];
|
||||
extern EWRAM_DATA u16 gUnknown_0203CDA8;
|
||||
extern EWRAM_DATA void *gUnknown_0203CDAC[0x20];
|
||||
|
||||
const u16 gUnknown_0860F0B0[] = INCBIN_U16("graphics/interface/860F0B0.gbapal");
|
||||
const u8 gUnknown_0860F0D0[] = { 15, 1, 2 };
|
||||
@ -81,6 +87,7 @@ extern u8 MoveMenuCursor(s8);
|
||||
extern u8 sub_8199134(s8, s8);
|
||||
extern void sub_8199F74(u8, u8, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8, u8);
|
||||
extern void sub_8198C78(void);
|
||||
extern void task_free_buf_after_copying_tile_data_to_vram(u8 taskId);
|
||||
|
||||
void AddTextPrinterWithCallbackForMessage(bool8 a1, void (*callback)(struct TextSubPrinter *, u16))
|
||||
{
|
||||
@ -716,7 +723,7 @@ u16 sub_8198AA4(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16
|
||||
return AddWindow(&template);
|
||||
}
|
||||
|
||||
void sub_8198AF8(struct WindowTemplate *window, u8 fontId, u8 left, u8 top, u16 baseTileNum, u8 paletteNum, u8 initialCursorPos)
|
||||
void sub_8198AF8(const struct WindowTemplate *window, u8 fontId, u8 left, u8 top, u16 baseTileNum, u8 paletteNum, u8 initialCursorPos)
|
||||
{
|
||||
struct TextSubPrinter printer;
|
||||
|
||||
@ -742,7 +749,7 @@ void sub_8198AF8(struct WindowTemplate *window, u8 fontId, u8 left, u8 top, u16
|
||||
sub_81983AC(gUnknown_0203CD9F, fontId, left, top, GetFontAttribute(fontId, 1), 2, initialCursorPos);
|
||||
}
|
||||
|
||||
void sub_8198C34(struct WindowTemplate *window, u8 fontId, u16 baseTileNum, u8 paletteNum)
|
||||
void sub_8198C34(const struct WindowTemplate *window, u8 fontId, u16 baseTileNum, u8 paletteNum)
|
||||
{
|
||||
sub_8198AF8(window, fontId, 0, 1, baseTileNum, paletteNum, 0);
|
||||
}
|
||||
@ -1180,3 +1187,267 @@ void sub_81995E4(u8 windowId, u8 itemCount, const struct MenuAction *strs, const
|
||||
|
||||
CopyWindowToVram(windowId, 2);
|
||||
}
|
||||
|
||||
void CreateYesNoMenu(const struct WindowTemplate *window, u16 baseTileNum, u8 paletteNum, u8 initialCursorPos)
|
||||
{
|
||||
struct TextSubPrinter printer;
|
||||
|
||||
gUnknown_0203CD9F = AddWindow(window);
|
||||
SetWindowBorderStyle(gUnknown_0203CD9F, TRUE, baseTileNum, paletteNum);
|
||||
|
||||
printer.current_text_offset = gText_YesNo;
|
||||
printer.windowId = gUnknown_0203CD9F;
|
||||
printer.fontId = 1;
|
||||
printer.x = 8;
|
||||
printer.y = 1;
|
||||
printer.currentX = printer.x;
|
||||
printer.currentY = printer.y;
|
||||
printer.fgColor = GetFontAttribute(1, 5);
|
||||
printer.bgColor = GetFontAttribute(1, 6);
|
||||
printer.shadowColor = GetFontAttribute(1, 7);
|
||||
printer.fontColor_l = GetFontAttribute(1, 4);
|
||||
printer.letterSpacing = 0;
|
||||
printer.lineSpacing = 0;
|
||||
|
||||
AddTextPrinter(&printer, 0xFF, 0);
|
||||
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(gUnknown_0203CD9F, 2, initialCursorPos);
|
||||
}
|
||||
|
||||
void sub_81997AC(u8 windowId, u8 a4, u8 a6, u8 a7, const struct MenuAction *strs)
|
||||
{
|
||||
u32 i;
|
||||
u32 j;
|
||||
for (i = 0; i < a7; i++)
|
||||
{
|
||||
for (j = 0; j < a6; j++)
|
||||
{
|
||||
PrintTextOnWindow(windowId, 1, strs[(i * a6) + j].text, (a4 * j) + 8, (i * 16) + 1, 0xFF, NULL);
|
||||
}
|
||||
}
|
||||
CopyWindowToVram(windowId, 2);
|
||||
}
|
||||
|
||||
void sub_819983C(u8 windowId, u8 a4, u8 itemCount, u8 itemCount2, const struct MenuAction *strs, const u8 *a8)
|
||||
{
|
||||
u8 i;
|
||||
u8 j;
|
||||
struct TextSubPrinter printer;
|
||||
|
||||
printer.windowId = windowId;
|
||||
printer.fontId = 1;
|
||||
printer.fgColor = GetFontAttribute(1, 5);
|
||||
printer.bgColor = GetFontAttribute(1, 6);
|
||||
printer.shadowColor = GetFontAttribute(1, 7);
|
||||
printer.fontColor_l = GetFontAttribute(1, 4);
|
||||
printer.letterSpacing = 0;
|
||||
printer.lineSpacing = 0;
|
||||
|
||||
for (i = 0; i < itemCount2; i++)
|
||||
{
|
||||
for (j = 0; j < itemCount; j++)
|
||||
{
|
||||
printer.current_text_offset = strs[a8[(itemCount * i) + j]].text;
|
||||
printer.x = (a4 * j) + 8;
|
||||
printer.y = (16 * i) + 1;
|
||||
printer.currentX = printer.x;
|
||||
printer.currentY = printer.y;
|
||||
AddTextPrinter(&printer, 0xFF, 0);
|
||||
}
|
||||
}
|
||||
|
||||
CopyWindowToVram(windowId, 2);
|
||||
}
|
||||
|
||||
u8 sub_8199944(u8 windowId, u8 optionWidth, u8 horizontalCount, u8 verticalCount, u8 initialCursorPos)
|
||||
{
|
||||
s32 pos;
|
||||
|
||||
gUnknown_0203CD90.left = 0;
|
||||
gUnknown_0203CD90.top = 1;
|
||||
gUnknown_0203CD90.minCursorPos = 0;
|
||||
gUnknown_0203CD90.maxCursorPos = (horizontalCount * verticalCount) - 1;
|
||||
gUnknown_0203CD90.windowId = windowId;
|
||||
gUnknown_0203CD90.fontId = 1;
|
||||
gUnknown_0203CD90.optionWidth = optionWidth;
|
||||
gUnknown_0203CD90.optionHeight = 16;
|
||||
gUnknown_0203CD90.horizontalCount = horizontalCount;
|
||||
gUnknown_0203CD90.verticalCount = verticalCount;
|
||||
|
||||
pos = initialCursorPos;
|
||||
|
||||
if (pos < 0 || pos > 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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user