From 2852f4f1b86f1a5fbfdceb296d184158068b5ad5 Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Fri, 13 Oct 2017 19:48:09 -0500 Subject: [PATCH] Continue attempt to decomp braillemessage --- include/menu.h | 1 + include/new_menu_helpers.h | 1 + src/scrcmd.c | 56 +++++++++++++++++++++++--------------- 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/include/menu.h b/include/menu.h index 766aa9d39c..66ac73e03b 100644 --- a/include/menu.h +++ b/include/menu.h @@ -19,5 +19,6 @@ void box_print(u8, u8, u8, u8, const void *, s8, const u8 *); 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); +void sub_8198A50(struct WindowTemplate*, u8, u8, u8, u8, u8, u8, u16); // returns something but it isn't used, fix when menu.s is decomp'd #endif // GUARD_MENU_H diff --git a/include/new_menu_helpers.h b/include/new_menu_helpers.h index a597fc9a27..6377897d34 100644 --- a/include/new_menu_helpers.h +++ b/include/new_menu_helpers.h @@ -4,5 +4,6 @@ void sub_81973A4(void); void sub_81973C4(u8, u8); void sub_819746C(u8 windowId, bool8 copyToVram); +void sub_81973FC(u8, u8); #endif // GUARD_NEW_MENU_HELPERS_H diff --git a/src/scrcmd.c b/src/scrcmd.c index f6039142cf..af314609c8 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -26,6 +26,7 @@ #include "lilycove_lady.h" #include "main.h" #include "map_obj_lock.h" +#include "menu.h" #include "money.h" #include "mystery_event_script.h" #include "new_menu_helpers.h" @@ -46,6 +47,7 @@ #include "sound.h" #include "string_util.h" #include "text.h" +#include "text_window.h" #include "trainer_see.h" #include "tv.h" #include "window.h" @@ -1483,46 +1485,56 @@ bool8 ScrCmd_drawcontestwinner(struct ScriptContext *ctx) return TRUE; } -// Temporary, will come back to this later. -/*bool8 ScrCmd_braillemessage(struct ScriptContext *ctx) +// Lots of math, can't figure it out. +/* +bool8 ScrCmd_braillemessage(struct ScriptContext *ctx) { u8 *ptr = (u8 *)ScriptReadWord(ctx); - u8 *localStringVar4; + struct WindowTemplate template1; + struct WindowTemplate template2; + int i; u8 width; u8 height; - u8 temp; + int temp1; + int temp2; + u8 x; + u8 y; - StringExpandPlaceholders(gStringVar4, ptr); + StringExpandPlaceholders(gStringVar4, ptr + 6); width = GetStringWidth(6, gStringVar4, -1) / 8; if (width > 0x1C) width = 0x1C; - height = 4; - localStringVar4 = gStringVar4; - temp = width + 2; - - for (; *localStringVar4 != 0xFF; localStringVar4++) + for (i = 0, height = 4; gStringVar4[i] != 0xFF;) { - if (*localStringVar4 == 0xFE) - height += 4; + if (gStringVar4[i++] == 0xFE) + height += 3; } if (height > 0x12) height = 0x12; - temp = 0x1E - temp; + x = width + 2; + temp1 = (0x1E - x) / 2; + x = temp1 + 1; + temp1 = ((x - temp1 - 1) * 8 + 3); - u8 v2 = ptr[0]; - u8 v3 = ptr[1]; - u8 v4 = ptr[2]; - u8 v5 = ptr[3]; - u8 v6 = ptr[4]; - u8 v7 = ptr[5]; - StringBraille(gStringVar4, ptr + 6); - MenuDrawTextWindow(v2, v3, v4, v5); - MenuPrint(gStringVar4, v6, v7); + y = height + 2; + temp2 = (0x14 - y) / 2; + y = temp2 + 2; + temp2 = ((y - temp2 - 1) * 8); + + sub_8198A50(&template1, 0, x, y, width, height, 0xF, 0x1); + template2 = template1; + gUnknown_03000F30 = AddWindow(&template2); + sub_809882C(gUnknown_03000F30, 0x214, 0xE0); + sub_81973FC(gUnknown_03000F30, 0); + PutWindowTilemap(gUnknown_03000F30); + FillWindowPixelBuffer(gUnknown_03000F30, 0x11); + PrintTextOnWindow(gUnknown_03000F30, 6, gStringVar4, temp1, temp2, 0xFF, 0x0); + CopyWindowToVram(gUnknown_03000F30, 3); return FALSE; }*/ __attribute__((naked))