diff --git a/asm/menu.s b/asm/menu.s index ff5bec251..33be67990 100644 --- a/asm/menu.s +++ b/asm/menu.s @@ -5,804 +5,6 @@ .text - - thumb_func_start sub_8199D3C -sub_8199D3C: @ 8199D3C - push {r4-r7,lr} - adds r6, r0, 0 - adds r5, r1, 0 - ldr r0, [sp, 0x14] - adds r4, r2, 0 - muls r4, r3 - cmp r0, 0x1 - bne _08199D64 - adds r3, r6, 0 - movs r2, 0 - cmp r2, r4 - bge _08199D8C -_08199D54: - adds r1, r3, r2 - ldrb r0, [r1] - adds r0, r5 - strb r0, [r1] - adds r2, 0x1 - cmp r2, r4 - blt _08199D54 - b _08199D8C -_08199D64: - cmp r4, 0 - ble _08199D8C - movs r0, 0xFC - lsls r0, 8 - mov r12, r0 - ldr r0, =0x000003ff - adds r7, r0, 0 - adds r3, r6, 0 - adds r2, r4, 0 -_08199D76: - ldrh r0, [r3] - mov r1, r12 - ands r1, r0 - adds r0, r5 - ands r0, r7 - orrs r1, r0 - strh r1, [r3] - adds r3, 0x2 - subs r2, 0x1 - cmp r2, 0 - bne _08199D76 -_08199D8C: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8199D3C - - thumb_func_start sub_8199D98 -sub_8199D98: @ 8199D98 - push {lr} - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x2 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x3 - 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 ChangeBgY - movs r0, 0x2 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x3 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - pop {r0} - bx r0 - thumb_func_end sub_8199D98 - - thumb_func_start sub_8199DF0 -sub_8199DF0: @ 8199DF0 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - mov r8, r2 - mov r9, r3 - lsls r1, 24 - lsrs r6, r1, 24 - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r5, 0 - movs r1, 0x4 - bl GetBgAttribute - lsls r0, 16 - movs r7, 0x40 - cmp r0, 0 - bne _08199E16 - movs r7, 0x20 -_08199E16: - adds r0, r5, 0 - movs r1, 0x1 - bl GetBgAttribute - adds r4, r0, 0 - adds r0, r5, 0 - movs r1, 0xA - bl GetBgAttribute - lsls r4, 16 - lsrs r4, 2 - lsls r0, 16 - lsrs r0, 16 - add r0, r8 - muls r0, r7 - adds r4, r0 - lsls r0, r6, 24 - lsls r1, r6, 16 - orrs r0, r1 - lsls r1, r6, 8 - orrs r0, r1 - orrs r0, r6 - movs r1, 0xC0 - lsls r1, 19 - adds r4, r1 - mov r2, r9 - muls r2, r7 - lsls r2, 16 - lsrs r2, 16 - adds r1, r4, 0 - movs r3, 0x1 - bl RequestDma3Fill - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8199DF0 - - thumb_func_start box_print -box_print: @ 8199E64 - push {r4-r6,lr} - sub sp, 0x10 - adds r4, r1, 0 - ldr r6, [sp, 0x20] - ldr r5, [sp, 0x24] - ldr r1, [sp, 0x28] - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - str r1, [sp] - mov r1, sp - strb r0, [r1, 0x4] - mov r0, sp - strb r4, [r0, 0x5] - strb r2, [r0, 0x6] - strb r3, [r0, 0x7] - ldrb r0, [r0, 0x6] - strb r0, [r1, 0x8] - mov r0, sp - ldrb r0, [r0, 0x7] - strb r0, [r1, 0x9] - adds r0, r4, 0 - movs r1, 0x2 - bl GetFontAttribute - mov r1, sp - strb r0, [r1, 0xA] - adds r0, r4, 0 - movs r1, 0x3 - bl GetFontAttribute - mov r1, sp - strb r0, [r1, 0xB] - mov r3, sp - ldrb r2, [r3, 0xC] - movs r1, 0x10 - negs r1, r1 - adds r0, r1, 0 - ands r0, r2 - strb r0, [r3, 0xC] - mov r2, sp - ldrb r0, [r6, 0x1] - lsls r0, 4 - movs r4, 0xF - strb r0, [r2, 0xC] - ldrb r2, [r6] - adds r0, r4, 0 - ands r0, r2 - ldrb r2, [r3, 0xD] - ands r1, r2 - orrs r1, r0 - strb r1, [r3, 0xD] - mov r2, sp - ldrb r0, [r6, 0x2] - lsls r0, 4 - ands r1, r4 - orrs r1, r0 - strb r1, [r2, 0xD] - mov r0, sp - adds r1, r5, 0 - movs r2, 0 - bl AddTextPrinter - add sp, 0x10 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end box_print - - thumb_func_start AddTextPrinterParameterized2 -@ void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor *color, u8 speed, u8 *str) -AddTextPrinterParameterized2: @ 8199EEC - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - sub sp, 0x10 - adds r5, r1, 0 - ldr r1, [sp, 0x28] - mov r8, r1 - ldr r1, [sp, 0x2C] - mov r9, r1 - ldr r6, [sp, 0x30] - ldr r1, [sp, 0x34] - ldr r4, [sp, 0x38] - str r4, [sp] - mov r4, sp - strb r0, [r4, 0x4] - mov r0, sp - strb r5, [r0, 0x5] - strb r2, [r0, 0x6] - strb r3, [r0, 0x7] - mov r2, sp - ldrb r0, [r0, 0x6] - strb r0, [r2, 0x8] - mov r0, sp - ldrb r0, [r0, 0x7] - strb r0, [r2, 0x9] - mov r0, sp - mov r2, r8 - strb r2, [r0, 0xA] - mov r2, r9 - strb r2, [r0, 0xB] - ldrb r3, [r4, 0xC] - movs r2, 0x10 - negs r2, r2 - adds r0, r2, 0 - ands r0, r3 - strb r0, [r4, 0xC] - mov r3, sp - ldrb r0, [r6, 0x1] - lsls r0, 4 - movs r5, 0xF - strb r0, [r3, 0xC] - ldrb r3, [r6] - adds r0, r5, 0 - ands r0, r3 - ldrb r3, [r4, 0xD] - ands r2, r3 - orrs r2, r0 - strb r2, [r4, 0xD] - mov r3, sp - ldrb r0, [r6, 0x2] - lsls r0, 4 - ands r2, r5 - orrs r2, r0 - strb r2, [r3, 0xD] - lsls r1, 24 - lsrs r1, 24 - mov r0, sp - movs r2, 0 - bl AddTextPrinter - add sp, 0x10 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end AddTextPrinterParameterized2 - - thumb_func_start sub_8199F74 -sub_8199F74: @ 8199F74 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x10 - adds r6, r1, 0 - ldr r4, [sp, 0x2C] - ldr r1, [sp, 0x30] - mov r8, r1 - ldr r7, [sp, 0x34] - ldr r5, [sp, 0x38] - ldr r1, [sp, 0x3C] - mov r9, r1 - lsls r6, 24 - lsrs r6, 24 - lsls r3, 24 - lsrs r3, 24 - lsls r4, 24 - lsrs r4, 24 - mov r1, r8 - lsls r1, 24 - lsrs r1, 24 - mov r8, r1 - str r2, [sp] - mov r1, sp - strb r0, [r1, 0x4] - mov r0, sp - strb r6, [r0, 0x5] - strb r3, [r0, 0x6] - strb r4, [r0, 0x7] - strb r3, [r0, 0x8] - strb r4, [r0, 0x9] - strb r5, [r0, 0xA] - mov r1, r9 - strb r1, [r0, 0xB] - mov r2, sp - ldrb r1, [r2, 0xC] - movs r5, 0x10 - negs r5, r5 - adds r0, r5, 0 - ands r0, r1 - strb r0, [r2, 0xC] - adds r0, r6, 0 - movs r1, 0x5 - bl GetFontAttribute - mov r3, sp - lsls r0, 4 - ldrb r2, [r3, 0xC] - movs r4, 0xF - adds r1, r4, 0 - ands r1, r2 - orrs r1, r0 - strb r1, [r3, 0xC] - adds r0, r6, 0 - movs r1, 0x6 - bl GetFontAttribute - mov r2, sp - adds r1, r4, 0 - ands r1, r0 - ldrb r0, [r2, 0xD] - ands r5, r0 - orrs r5, r1 - strb r5, [r2, 0xD] - adds r0, r6, 0 - movs r1, 0x7 - bl GetFontAttribute - mov r2, sp - lsls r0, 4 - ldrb r1, [r2, 0xD] - ands r4, r1 - orrs r4, r0 - strb r4, [r2, 0xD] - mov r0, sp - mov r1, r8 - adds r2, r7, 0 - bl AddTextPrinter - add sp, 0x10 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8199F74 - - thumb_func_start sub_819A024 -sub_819A024: @ 819A024 - push {r4-r7,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r7, r0, 24 - lsls r2, 16 - lsrs r4, r2, 16 - lsls r3, 16 - lsrs r5, r3, 16 - movs r2, 0 - ldr r0, =gSaveBlock2Ptr - ldr r3, [r0] - ldrb r0, [r3] - ldr r6, =gStringVar4 - cmp r0, 0xFF - beq _0819A04C -_0819A042: - adds r2, 0x1 - adds r0, r3, r2 - ldrb r0, [r0] - cmp r0, 0xFF - bne _0819A042 -_0819A04C: - adds r0, r6, 0 - bl StringExpandPlaceholders - lsls r3, r4, 24 - lsrs r3, 24 - lsls r0, r5, 24 - lsrs r0, 24 - str r0, [sp] - movs r0, 0xFF - str r0, [sp, 0x4] - movs r0, 0 - str r0, [sp, 0x8] - adds r0, r7, 0 - movs r1, 0x1 - adds r2, r6, 0 - bl PrintTextOnWindow - add sp, 0xC - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_819A024 - - thumb_func_start sub_819A080 -sub_819A080: @ 819A080 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x28 - str r0, [sp] - str r1, [sp, 0x4] - ldr r0, [sp, 0x48] - ldr r4, [sp, 0x4C] - ldr r1, [sp, 0x50] - ldr r5, [sp, 0x54] - lsls r2, 16 - lsrs r2, 16 - str r2, [sp, 0x8] - lsls r3, 16 - lsrs r3, 16 - lsls r0, 16 - lsrs r0, 16 - str r0, [sp, 0xC] - lsls r4, 16 - lsrs r4, 16 - lsls r1, 16 - lsrs r1, 16 - lsls r5, 16 - lsrs r5, 16 - ldr r2, [sp, 0x4] - ldrh r0, [r2, 0x4] - ldr r2, [sp, 0xC] - subs r0, r2 - ldr r2, [sp, 0x8] - adds r2, r1, r2 - str r2, [sp, 0x10] - cmp r0, r1 - bge _0819A0CC - ldr r1, [sp, 0x8] - adds r0, r1 - str r0, [sp, 0x10] -_0819A0CC: - ldr r2, [sp, 0x4] - ldrh r1, [r2, 0x6] - subs r0, r1, r4 - cmp r0, r5 - bge _0819A0DE - adds r0, r3, r1 - subs r0, r4 - str r0, [sp, 0x14] - b _0819A0E2 -_0819A0DE: - adds r5, r3, r5 - str r5, [sp, 0x14] -_0819A0E2: - ldr r0, [sp] - ldrh r1, [r0, 0x4] - movs r2, 0x7 - adds r0, r1, 0 - ands r0, r2 - adds r1, r0 - asrs r1, 3 - str r1, [sp, 0x18] - ldr r0, [sp, 0x4] - ldrh r1, [r0, 0x4] - adds r0, r1, 0 - ands r0, r2 - adds r1, r0 - asrs r1, 3 - str r1, [sp, 0x1C] - mov r12, r3 - mov r8, r4 - ldr r1, [sp, 0x14] - cmp r12, r1 - blt _0819A10C - b _0819A24A -_0819A10C: - ldr r5, [sp, 0x8] - ldr r6, [sp, 0xC] - mov r2, r12 - adds r2, 0x1 - str r2, [sp, 0x20] - mov r0, r8 - adds r0, 0x1 - str r0, [sp, 0x24] - ldr r1, [sp, 0x10] - cmp r5, r1 - blt _0819A124 - b _0819A23A -_0819A124: - movs r7, 0x1 - movs r2, 0xF0 - mov r10, r2 - movs r0, 0xF - mov r9, r0 -_0819A12E: - asrs r0, r5, 1 - movs r1, 0x3 - ands r0, r1 - ldr r2, [sp] - ldr r1, [r2] - adds r1, r0 - asrs r0, r5, 3 - lsls r0, 5 - adds r1, r0 - mov r2, r12 - asrs r0, r2, 3 - ldr r2, [sp, 0x18] - muls r0, r2 - lsls r0, 5 - adds r1, r0 - mov r2, r12 - lsls r0, r2, 29 - lsrs r0, 27 - adds r3, r1, r0 - asrs r0, r6, 1 - movs r1, 0x3 - ands r0, r1 - ldr r2, [sp, 0x4] - ldr r1, [r2] - adds r1, r0 - asrs r0, r6, 3 - lsls r0, 5 - adds r1, r0 - mov r2, r8 - asrs r0, r2, 3 - ldr r2, [sp, 0x1C] - muls r0, r2 - lsls r0, 5 - adds r1, r0 - mov r2, r8 - lsls r0, r2, 29 - lsrs r0, 27 - adds r4, r1, r0 - adds r0, r4, 0 - ands r0, r7 - cmp r0, 0 - beq _0819A1DA - subs r4, 0x1 - adds r0, r6, 0 - ands r0, r7 - cmp r0, 0 - beq _0819A1B2 - ldrh r0, [r4] - ldr r2, =0x00000fff - ands r2, r0 - adds r0, r5, 0 - ands r0, r7 - cmp r0, 0 - beq _0819A1A8 - ldrb r1, [r3] - mov r0, r10 - ands r0, r1 - lsls r0, 8 - b _0819A22A - .pool -_0819A1A8: - ldrb r1, [r3] - mov r0, r9 - ands r0, r1 - lsls r0, 12 - b _0819A22A -_0819A1B2: - ldrh r0, [r4] - ldr r2, =0x0000f0ff - ands r2, r0 - adds r0, r5, 0 - ands r0, r7 - cmp r0, 0 - beq _0819A1D0 - ldrb r1, [r3] - mov r0, r10 - ands r0, r1 - lsls r0, 4 - b _0819A22A - .pool -_0819A1D0: - ldrb r1, [r3] - mov r0, r9 - ands r0, r1 - lsls r0, 8 - b _0819A22A -_0819A1DA: - adds r0, r6, 0 - ands r0, r7 - cmp r0, 0 - beq _0819A206 - ldrh r0, [r4] - ldr r2, =0x0000ff0f - ands r2, r0 - adds r0, r5, 0 - ands r0, r7 - cmp r0, 0 - beq _0819A1FC - ldrb r1, [r3] - mov r0, r10 - b _0819A228 - .pool -_0819A1FC: - ldrb r1, [r3] - mov r0, r9 - ands r0, r1 - lsls r0, 4 - b _0819A22A -_0819A206: - ldrh r0, [r4] - ldr r2, =0x0000fff0 - ands r2, r0 - adds r0, r5, 0 - ands r0, r7 - cmp r0, 0 - beq _0819A224 - ldrb r1, [r3] - mov r0, r10 - ands r0, r1 - lsrs r0, 4 - b _0819A22A - .pool -_0819A224: - ldrb r1, [r3] - mov r0, r9 -_0819A228: - ands r0, r1 -_0819A22A: - orrs r2, r0 - strh r2, [r4] - adds r5, 0x1 - adds r6, 0x1 - ldr r0, [sp, 0x10] - cmp r5, r0 - bge _0819A23A - b _0819A12E -_0819A23A: - ldr r1, [sp, 0x20] - mov r12, r1 - ldr r2, [sp, 0x24] - mov r8, r2 - ldr r0, [sp, 0x14] - cmp r12, r0 - bge _0819A24A - b _0819A10C -_0819A24A: - add sp, 0x28 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_819A080 - - thumb_func_start sub_819A25C -sub_819A25C: @ 819A25C - push {r4,lr} - adds r4, r0, 0 - adds r0, r1, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r0, 16 - lsrs r0, 16 - bl GetValidMonIconPalettePtr - adds r1, r4, 0 - movs r2, 0x20 - bl LoadPalette - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_819A25C - - thumb_func_start sub_819A27C -sub_819A27C: @ 819A27C - push {r4-r6,lr} - sub sp, 0x8 - adds r6, r0, 0 - adds r0, r1, 0 - adds r1, r2, 0 - adds r4, r3, 0 - ldr r5, [sp, 0x18] - lsls r6, 24 - lsrs r6, 24 - lsls r0, 16 - lsrs r0, 16 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 16 - lsrs r5, 16 - movs r2, 0x1 - bl GetMonIconPtr - adds r1, r0, 0 - movs r0, 0x20 - str r0, [sp] - str r0, [sp, 0x4] - adds r0, r6, 0 - adds r2, r4, 0 - adds r3, r5, 0 - bl BlitBitmapToWindow - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_819A27C - - thumb_func_start sub_819A2BC -sub_819A2BC: @ 819A2BC - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - lsls r1, 24 - lsrs r1, 24 - cmp r1, 0x1 - beq _0819A2DC - cmp r1, 0x1 - ble _0819A2D2 - cmp r1, 0x2 - beq _0819A2E4 -_0819A2D2: - ldr r0, =gFireRedMenuElements1_Pal - b _0819A2E6 - .pool -_0819A2DC: - ldr r0, =gFireRedMenuElements2_Pal - b _0819A2E6 - .pool -_0819A2E4: - ldr r0, =gFireRedMenuElements3_Pal -_0819A2E6: - adds r1, r2, 0 - movs r2, 0x20 - bl LoadPalette - pop {r0} - bx r0 - .pool - thumb_func_end sub_819A2BC - - thumb_func_start blit_move_info_icon -@ void blit_move_info_icon(u8 windowId, u8 a2, u16 x, u16 y) -blit_move_info_icon: @ 819A2F8 - push {r4,r5,lr} - sub sp, 0x18 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsls r2, 16 - lsrs r2, 16 - lsls r3, 16 - lsrs r3, 16 - ldr r4, =gUnknown_0860F0D4 - lsrs r1, 22 - adds r1, r4 - ldrh r5, [r1, 0x2] - lsls r5, 5 - ldr r4, =gFireRedMenuElements_Gfx - adds r5, r4 - movs r4, 0x80 - str r4, [sp] - str r4, [sp, 0x4] - str r2, [sp, 0x8] - str r3, [sp, 0xC] - ldrb r2, [r1] - str r2, [sp, 0x10] - ldrb r1, [r1, 0x1] - str r1, [sp, 0x14] - adds r1, r5, 0 - movs r2, 0 - movs r3, 0 - bl BlitBitmapRectToWindow - add sp, 0x18 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end blit_move_info_icon - thumb_func_start sub_819A344 sub_819A344: @ 819A344 push {r4-r7,lr} diff --git a/include/menu.h b/include/menu.h index efccde1e2..6c4a069e3 100644 --- a/include/menu.h +++ b/include/menu.h @@ -16,7 +16,7 @@ struct MenuAction } func; }; -void box_print(u8, u8, u8, u8, const void *, s8, const u8 *); +void box_print(u8 windowId, u8 fontId, u8 left, u8 top, const struct TextColor *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); void SetWindowBorderStyle(u8 windowId, bool8 copyToVram, u16 tileStart, u8 palette); diff --git a/include/window.h b/include/window.h index b630cd316..07c642a09 100644 --- a/include/window.h +++ b/include/window.h @@ -52,7 +52,7 @@ void PutWindowTilemap(u8 windowId); void PutWindowRectTilemapOverridePalette(u8 windowId, u8 x, u8 y, u8 width, u8 height, u8 palette); void ClearWindowTilemap(u8 windowId); void PutWindowRectTilemap(u8 windowId, u8 x, u8 y, u8 width, u8 height); -void BlitBitmapToWindow(u8 windowId, u8 *pixels, u16 x, u16 y, u16 width, u16 height); +void BlitBitmapToWindow(u8 windowId, const u8 *pixels, u16 x, u16 y, u16 width, u16 height); void BlitBitmapRectToWindow(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight); void FillWindowPixelRect(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 height); void CopyToWindowPixelBuffer(u8 windowId, const u8 *src, u16 size, u16 tileOffset); diff --git a/src/menu.c b/src/menu.c index b5ff565fe..bcbc21a3b 100644 --- a/src/menu.c +++ b/src/menu.c @@ -11,6 +11,8 @@ #include "malloc.h" #include "task.h" #include "dma3.h" +#include "string_util.h" +#include "pokemon_icon.h" struct SomeUnkStruct { @@ -45,7 +47,7 @@ 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 }; +const struct TextColor gUnknown_0860F0D0[] = { 15, 1, 2 }; const struct SomeUnkStruct gUnknown_0860F0D4[] = { { 12, 12, 0x00 }, @@ -78,6 +80,10 @@ const struct SomeUnkStruct gUnknown_0860F0D4[] = extern const u8 gText_SelectorArrow3[]; extern const u8 gText_YesNo[]; +extern const u16 gFireRedMenuElements1_Pal[16]; +extern const u16 gFireRedMenuElements2_Pal[16]; +extern const u16 gFireRedMenuElements3_Pal[16]; +extern const u8 gFireRedMenuElements_Gfx[]; extern void sub_8197BB4(u8, u8, u8, u8, u8, u8); extern void sub_8197E30(u8, u8, u8, u8, u8, u8); @@ -85,7 +91,7 @@ extern void DrawWindowBorder(u8, u8, u8, u8, u8, u8); extern void sub_81980A8(u8, u8, u8, u8, u8, u8); 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_8199F74(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8 letterSpacing, u8 lineSpacing); extern void sub_8198C78(void); extern void task_free_buf_after_copying_tile_data_to_vram(u8 taskId); @@ -687,7 +693,7 @@ void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 l printer.current_text_offset = strs[a8[i]].text; printer.y = (lineHeight * i) + top; printer.currentY = printer.y; - AddTextPrinter(&printer, 0xFF, 0); + AddTextPrinter(&printer, 0xFF, NULL); } CopyWindowToVram(windowId, 2); @@ -744,7 +750,7 @@ void sub_8198AF8(const struct WindowTemplate *window, u8 fontId, u8 left, u8 top printer.letterSpacing = GetFontAttribute(fontId, 2); printer.lineSpacing = GetFontAttribute(fontId, 3); - AddTextPrinter(&printer, 0xFF, 0); + AddTextPrinter(&printer, 0xFF, NULL); sub_81983AC(gUnknown_0203CD9F, fontId, left, top, GetFontAttribute(fontId, 1), 2, initialCursorPos); } @@ -811,7 +817,7 @@ void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u printer.y = (GetFontAttribute(fontId, 1) * i) + top; printer.currentX = printer.x; printer.currentY = printer.y; - AddTextPrinter(&printer, 0xFF, 0); + AddTextPrinter(&printer, 0xFF, NULL); } } @@ -1182,7 +1188,7 @@ void sub_81995E4(u8 windowId, u8 itemCount, const struct MenuAction *strs, const printer.current_text_offset = strs[a8[i]].text; printer.y = (i * 16) + 1; printer.currentY = (i * 16) + 1; - AddTextPrinter(&printer, 0xFF, 0); + AddTextPrinter(&printer, 0xFF, NULL); } CopyWindowToVram(windowId, 2); @@ -1209,7 +1215,7 @@ void CreateYesNoMenu(const struct WindowTemplate *window, u16 baseTileNum, u8 pa printer.letterSpacing = 0; printer.lineSpacing = 0; - AddTextPrinter(&printer, 0xFF, 0); + AddTextPrinter(&printer, 0xFF, NULL); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(gUnknown_0203CD9F, 2, initialCursorPos); } @@ -1251,7 +1257,7 @@ void sub_819983C(u8 windowId, u8 a4, u8 itemCount, u8 itemCount2, const struct M printer.y = (16 * i) + 1; printer.currentX = printer.x; printer.currentY = printer.y; - AddTextPrinter(&printer, 0xFF, 0); + AddTextPrinter(&printer, 0xFF, NULL); } } @@ -1436,18 +1442,435 @@ void sub_8199C30(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette) } } -void sub_8199CBC(u8 bgId, void *dest, u8 left, u8 top, u8 width, u8 height) +void sub_8199CBC(u8 bgId, u16 *dest, u8 left, u8 top, u8 width, u8 height) { u8 i; u8 j; - u16 *ptr = GetBgTilemapBuffer(bgId); - u16 *destAsU16 = dest; + const u16 *src = GetBgTilemapBuffer(bgId); for (i = 0; i < height; i++) { for (j = 0; j < width; j++) { - destAsU16[(i * height) + j] = ptr[(i * height) + j]; + dest[(i * width) + j] = src[(i + top) * 32 + j + left]; } } } + +void sub_8199D3C(void *ptr, int delta, int width, int height, bool32 is8BPP) +{ + int i; + int area = width * height; + if (is8BPP == TRUE) + { + u8 *as8BPP = ptr; + for (i = 0; i < area; i++) + { + as8BPP[i] += delta; + } + } + else + { + u16 *as4BPP = ptr; + for (i = 0; i < area; i++) + { + as4BPP[i] = (as4BPP[i] & 0xFC00) | ((as4BPP[i] + delta) & 0x3FF); + } + } +} + +void sub_8199D98(void) +{ + ChangeBgX(0, 0, 0); + ChangeBgX(1, 0, 0); + ChangeBgX(2, 0, 0); + ChangeBgX(3, 0, 0); + ChangeBgY(0, 0, 0); + ChangeBgY(1, 0, 0); + ChangeBgY(2, 0, 0); + ChangeBgY(3, 0, 0); +} + +void sub_8199DF0(u32 bg, u8 a1, int a2, int a3) +{ + int temp = (!GetBgAttribute(bg, 4)) ? 0x20 : 0x40; + void *addr = (void *)((GetBgAttribute(bg, 1) * 0x4000) + (GetBgAttribute(bg, 10) + a2) * temp); + RequestDma3Fill(a1 << 24 | a1 << 16 | a1 << 8 | a1, addr + VRAM, a3 * temp, 1); +} + +void box_print(u8 windowId, u8 fontId, u8 left, u8 top, const struct TextColor *color, s8 speed, const u8 *str) +{ + struct TextSubPrinter printer; + + printer.current_text_offset = str; + printer.windowId = windowId; + printer.fontId = fontId; + printer.x = left; + printer.y = top; + printer.currentX = printer.x; + printer.currentY = printer.y; + printer.letterSpacing = GetFontAttribute(fontId, 2); + printer.lineSpacing = GetFontAttribute(fontId, 3); + printer.fontColor_l = 0; + printer.fgColor = color->bgColor; + printer.bgColor = color->fgColor; + printer.shadowColor = color->shadowColor; + + AddTextPrinter(&printer, speed, NULL); +} + +void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineSpacing, const struct TextColor *color, s8 speed, const u8 *str) +{ + struct TextSubPrinter printer; + + printer.current_text_offset = str; + printer.windowId = windowId; + printer.fontId = fontId; + printer.x = left; + printer.y = top; + printer.currentX = printer.x; + printer.currentY = printer.y; + printer.letterSpacing = letterSpacing; + printer.lineSpacing = lineSpacing; + printer.fontColor_l = 0; + printer.fgColor = color->bgColor; + printer.bgColor = color->fgColor; + printer.shadowColor = color->shadowColor; + + AddTextPrinter(&printer, speed, NULL); +} + +void sub_8199F74(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8 letterSpacing, u8 lineSpacing) +{ + struct TextSubPrinter printer; + + printer.current_text_offset = str; + printer.windowId = windowId; + printer.fontId = fontId; + printer.x = left; + printer.y = top; + printer.currentX = left; + printer.currentY = top; + printer.letterSpacing = letterSpacing; + printer.lineSpacing = lineSpacing; + printer.fontColor_l = 0; + + printer.fgColor = GetFontAttribute(fontId, 5); + printer.bgColor = GetFontAttribute(fontId, 6); + printer.shadowColor = GetFontAttribute(fontId, 7); + + AddTextPrinter(&printer, speed, callback); +} + +void sub_819A024(u8 windowId, const u8 *src, u16 a2, u16 a3) +{ + int count = 0; + while (gSaveBlock2Ptr->playerName[count] != EOS) + count++; + + StringExpandPlaceholders(gStringVar4, src); + + PrintTextOnWindow(windowId, 1, gStringVar4, a2, a3, 0xFF, 0); +} + +//Screw this function, it's long and unreferenced and ugh +/*void sub_819A080(u16 *a0, u16 *a1, u16 a2, u16 a3, u16 a4, u16 a5, u16 a6, u16 a7) +{ + int v1 = ((a0[2] - a4) > a6) ? (a6 + a2) : (a0[2] - a4); + int v2; + + if (a0[3] - a5 < a7) + v2 = a3 + a0[3] - a5; + else + v2 = a3 + a7; + + +}*/ + +__attribute__((naked)) +void sub_819A080(u16 *a0, u16 *a1, u16 a2, u16 a3, u16 a4, u16 a5, u16 a6, u16 a7) +{ + asm("push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, #0x28\n\ + str r0, [sp]\n\ + str r1, [sp, #0x4]\n\ + ldr r0, [sp, #0x48]\n\ + ldr r4, [sp, #0x4C]\n\ + ldr r1, [sp, #0x50]\n\ + ldr r5, [sp, #0x54]\n\ + lsl r2, #16\n\ + lsr r2, #16\n\ + str r2, [sp, #0x8]\n\ + lsl r3, #16\n\ + lsr r3, #16\n\ + lsl r0, #16\n\ + lsr r0, #16\n\ + str r0, [sp, #0xC]\n\ + lsl r4, #16\n\ + lsr r4, #16\n\ + lsl r1, #16\n\ + lsr r1, #16\n\ + lsl r5, #16\n\ + lsr r5, #16\n\ + ldr r2, [sp, #0x4]\n\ + ldrh r0, [r2, #0x4]\n\ + ldr r2, [sp, #0xC]\n\ + sub r0, r2\n\ + ldr r2, [sp, #0x8]\n\ + add r2, r1, r2\n\ + str r2, [sp, #0x10]\n\ + cmp r0, r1\n\ + bge _0819A0CC\n\ + ldr r1, [sp, #0x8]\n\ + add r0, r1\n\ + str r0, [sp, #0x10]\n\ +_0819A0CC:\n\ + ldr r2, [sp, #0x4]\n\ + ldrh r1, [r2, #0x6]\n\ + sub r0, r1, r4\n\ + cmp r0, r5\n\ + bge _0819A0DE\n\ + add r0, r3, r1\n\ + sub r0, r4\n\ + str r0, [sp, #0x14]\n\ + b _0819A0E2\n\ +_0819A0DE:\n\ + add r5, r3, r5\n\ + str r5, [sp, #0x14]\n\ +_0819A0E2:\n\ + ldr r0, [sp]\n\ + ldrh r1, [r0, #0x4]\n\ + mov r2, #0x7\n\ + add r0, r1, #0\n\ + and r0, r2\n\ + add r1, r0\n\ + asr r1, #3\n\ + str r1, [sp, #0x18]\n\ + ldr r0, [sp, #0x4]\n\ + ldrh r1, [r0, #0x4]\n\ + add r0, r1, #0\n\ + and r0, r2\n\ + add r1, r0\n\ + asr r1, #3\n\ + str r1, [sp, #0x1C]\n\ + mov r12, r3\n\ + mov r8, r4\n\ + ldr r1, [sp, #0x14]\n\ + cmp r12, r1\n\ + blt _0819A10C\n\ + b _0819A24A\n\ +_0819A10C:\n\ + ldr r5, [sp, #0x8]\n\ + ldr r6, [sp, #0xC]\n\ + mov r2, r12\n\ + add r2, #0x1\n\ + str r2, [sp, #0x20]\n\ + mov r0, r8\n\ + add r0, #0x1\n\ + str r0, [sp, #0x24]\n\ + ldr r1, [sp, #0x10]\n\ + cmp r5, r1\n\ + blt _0819A124\n\ + b _0819A23A\n\ +_0819A124:\n\ + mov r7, #0x1\n\ + mov r2, #0xF0\n\ + mov r10, r2\n\ + mov r0, #0xF\n\ + mov r9, r0\n\ +_0819A12E:\n\ + asr r0, r5, #1\n\ + mov r1, #0x3\n\ + and r0, r1\n\ + ldr r2, [sp]\n\ + ldr r1, [r2]\n\ + add r1, r0\n\ + asr r0, r5, #3\n\ + lsl r0, #5\n\ + add r1, r0\n\ + mov r2, r12\n\ + asr r0, r2, #3\n\ + ldr r2, [sp, #0x18]\n\ + mul r0, r2\n\ + lsl r0, #5\n\ + add r1, r0\n\ + mov r2, r12\n\ + lsl r0, r2, #29\n\ + lsr r0, #27\n\ + add r3, r1, r0\n\ + asr r0, r6, #1\n\ + mov r1, #0x3\n\ + and r0, r1\n\ + ldr r2, [sp, #0x4]\n\ + ldr r1, [r2]\n\ + add r1, r0\n\ + asr r0, r6, #3\n\ + lsl r0, #5\n\ + add r1, r0\n\ + mov r2, r8\n\ + asr r0, r2, #3\n\ + ldr r2, [sp, #0x1C]\n\ + mul r0, r2\n\ + lsl r0, #5\n\ + add r1, r0\n\ + mov r2, r8\n\ + lsl r0, r2, #29\n\ + lsr r0, #27\n\ + add r4, r1, r0\n\ + add r0, r4, #0\n\ + and r0, r7\n\ + cmp r0, #0\n\ + beq _0819A1DA\n\ + sub r4, #0x1\n\ + add r0, r6, #0\n\ + and r0, r7\n\ + cmp r0, #0\n\ + beq _0819A1B2\n\ + ldrh r0, [r4]\n\ + ldr r2, =0x00000fff\n\ + and r2, r0\n\ + add r0, r5, #0\n\ + and r0, r7\n\ + cmp r0, #0\n\ + beq _0819A1A8\n\ + ldrb r1, [r3]\n\ + mov r0, r10\n\ + and r0, r1\n\ + lsl r0, #8\n\ + b _0819A22A\n\ + .pool\n\ +_0819A1A8:\n\ + ldrb r1, [r3]\n\ + mov r0, r9\n\ + and r0, r1\n\ + lsl r0, #12\n\ + b _0819A22A\n\ +_0819A1B2:\n\ + ldrh r0, [r4]\n\ + ldr r2, =0x0000f0ff\n\ + and r2, r0\n\ + add r0, r5, #0\n\ + and r0, r7\n\ + cmp r0, #0\n\ + beq _0819A1D0\n\ + ldrb r1, [r3]\n\ + mov r0, r10\n\ + and r0, r1\n\ + lsl r0, #4\n\ + b _0819A22A\n\ + .pool\n\ +_0819A1D0:\n\ + ldrb r1, [r3]\n\ + mov r0, r9\n\ + and r0, r1\n\ + lsl r0, #8\n\ + b _0819A22A\n\ +_0819A1DA:\n\ + add r0, r6, #0\n\ + and r0, r7\n\ + cmp r0, #0\n\ + beq _0819A206\n\ + ldrh r0, [r4]\n\ + ldr r2, =0x0000ff0f\n\ + and r2, r0\n\ + add r0, r5, #0\n\ + and r0, r7\n\ + cmp r0, #0\n\ + beq _0819A1FC\n\ + ldrb r1, [r3]\n\ + mov r0, r10\n\ + b _0819A228\n\ + .pool\n\ +_0819A1FC:\n\ + ldrb r1, [r3]\n\ + mov r0, r9\n\ + and r0, r1\n\ + lsl r0, #4\n\ + b _0819A22A\n\ +_0819A206:\n\ + ldrh r0, [r4]\n\ + ldr r2, =0x0000fff0\n\ + and r2, r0\n\ + add r0, r5, #0\n\ + and r0, r7\n\ + cmp r0, #0\n\ + beq _0819A224\n\ + ldrb r1, [r3]\n\ + mov r0, r10\n\ + and r0, r1\n\ + lsr r0, #4\n\ + b _0819A22A\n\ + .pool\n\ +_0819A224:\n\ + ldrb r1, [r3]\n\ + mov r0, r9\n\ +_0819A228:\n\ + and r0, r1\n\ +_0819A22A:\n\ + orr r2, r0\n\ + strh r2, [r4]\n\ + add r5, #0x1\n\ + add r6, #0x1\n\ + ldr r0, [sp, #0x10]\n\ + cmp r5, r0\n\ + bge _0819A23A\n\ + b _0819A12E\n\ +_0819A23A:\n\ + ldr r1, [sp, #0x20]\n\ + mov r12, r1\n\ + ldr r2, [sp, #0x24]\n\ + mov r8, r2\n\ + ldr r0, [sp, #0x14]\n\ + cmp r12, r0\n\ + bge _0819A24A\n\ + b _0819A10C\n\ +_0819A24A:\n\ + add sp, #0x28\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n"); +} + +void sub_819A25C(u8 palOffset, u16 speciesId) +{ + LoadPalette(GetValidMonIconPalettePtr(speciesId), palOffset, 0x20); +} + +void sub_819A27C(u8 windowId, u16 speciesId, u32 personality, u16 x, u16 y) +{ + BlitBitmapToWindow(windowId, GetMonIconPtr(speciesId, personality, 1), x, y, 32, 32); +} + +void sub_819A2BC(u8 palOffset, u8 palId) +{ + const u16 *palette; + + switch (palId) + { + case 0: + default: + palette = gFireRedMenuElements1_Pal; + break; + case 1: + palette = gFireRedMenuElements2_Pal; + break; + case 2: + palette = gFireRedMenuElements3_Pal; + break; + } + + LoadPalette(palette, palOffset, 0x20); +} + +void blit_move_info_icon(u8 windowId, u8 iconId, u16 x, u16 y) +{ + BlitBitmapRectToWindow(windowId, gFireRedMenuElements_Gfx + gUnknown_0860F0D4[iconId].unk3 * 32, 0, 0, 128, 128, x, y, gUnknown_0860F0D4[iconId].unk1, gUnknown_0860F0D4[iconId].unk2); +}