From efad45497dfb69cf2879d0bf2e318eaf8fc2252f Mon Sep 17 00:00:00 2001 From: jiangzhengwenjz Date: Mon, 24 Jun 2019 14:37:45 +0800 Subject: through AddTextPrinterParameterized2() --- src/new_menu_helpers.c | 281 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 src/new_menu_helpers.c (limited to 'src/new_menu_helpers.c') diff --git a/src/new_menu_helpers.c b/src/new_menu_helpers.c new file mode 100644 index 000000000..7abe277e1 --- /dev/null +++ b/src/new_menu_helpers.c @@ -0,0 +1,281 @@ +#include "global.h" +#include "malloc.h" +#include "dma3.h" +#include "task.h" +#include "bg.h" +#include "gpu_regs.h" +#include "window.h" +#include "menu.h" +#include "menu_helpers.h" +#include "new_menu_helpers.h" +#include "quest_log.h" +#include "text.h" + +static EWRAM_DATA bool8 gUnknown_203AB58[4] = {FALSE}; // knizz: bgmaps_that_need_syncing + +EWRAM_DATA u16 gUnknown_203AB5C; +EWRAM_DATA void *gUnknown_203AB60[0x20]; +extern const struct WindowTemplate sStandardTextBox_WindowTemplates[]; +EWRAM_DATA u8 sStartMenuWindowId; + +u16 CopyDecompressedTileDataToVram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode); +void TaskFreeBufAfterCopyingTileDataToVram(u8 taskId); + +void ClearScheduledBgCopiesToVram(void) +{ + memset(gUnknown_203AB58, 0, sizeof(gUnknown_203AB58)); +} + +void ScheduleBgCopyTilemapToVram(u8 bgId) +{ + gUnknown_203AB58[bgId] = TRUE; +} + +void DoScheduledBgTilemapCopiesToVram(void) +{ + if (gUnknown_203AB58[0] == TRUE) + { + CopyBgTilemapBufferToVram(0); + gUnknown_203AB58[0] = FALSE; + } + if (gUnknown_203AB58[1] == TRUE) + { + CopyBgTilemapBufferToVram(1); + gUnknown_203AB58[1] = FALSE; + } + if (gUnknown_203AB58[2] == TRUE) + { + CopyBgTilemapBufferToVram(2); + gUnknown_203AB58[2] = FALSE; + } + if (gUnknown_203AB58[3] == TRUE) + { + CopyBgTilemapBufferToVram(3); + gUnknown_203AB58[3] = FALSE; + } +} + +void ResetTempTileDataBuffers(void) +{ + int i; + for (i = 0; i < (s32)ARRAY_COUNT(gUnknown_203AB60); i++) + { + gUnknown_203AB60[i] = NULL; + } + gUnknown_203AB5C = 0; +} + +bool8 FreeTempTileDataBuffersIfPossible(void) +{ + int i; + + if (!IsDma3ManagerBusyWithBgCopy()) + { + if (gUnknown_203AB5C) + { + for (i = 0; i < gUnknown_203AB5C; i++) + { + FREE_AND_SET_NULL(gUnknown_203AB60[i]); + } + gUnknown_203AB5C = 0; + } + return FALSE; + } + else + { + return TRUE; + } +} + +void *DecompressAndCopyTileDataToVram(u8 bgId, const void *src, u32 size, u16 offset, u8 mode) +{ + u32 sizeOut; + if (gUnknown_203AB5C < ARRAY_COUNT(gUnknown_203AB60)) + { + void *ptr = MallocAndDecompress(src, &sizeOut); + if (!size) + size = sizeOut; + if (ptr) + { + CopyDecompressedTileDataToVram(bgId, ptr, size, offset, mode); + gUnknown_203AB60[gUnknown_203AB5C++] = ptr; + } + return ptr; + } + return NULL; +} + +void *DecompressAndCopyTileDataToVram2(u8 bgId, const void *src, u32 size, u16 offset, u8 mode) +{ + u32 sizeOut; + if (gUnknown_203AB5C < ARRAY_COUNT(gUnknown_203AB60)) + { + void *ptr = MallocAndDecompress(src, &sizeOut); + if (sizeOut > size) + sizeOut = size; + if (ptr) + { + CopyDecompressedTileDataToVram(bgId, ptr, sizeOut, offset, mode); + gUnknown_203AB60[gUnknown_203AB5C++] = ptr; + } + return ptr; + } + return NULL; +} + +void DecompressAndLoadBgGfxUsingHeap(u8 bgId, const void *src, u32 size, u16 offset, u8 mode) +{ + u32 sizeOut; + void *ptr = MallocAndDecompress(src, &sizeOut); + if (!size) + size = sizeOut; + if (ptr) + { + u8 taskId = CreateTask(TaskFreeBufAfterCopyingTileDataToVram, 0); + gTasks[taskId].data[0] = CopyDecompressedTileDataToVram(bgId, ptr, size, offset, mode); + SetWordTaskArg(taskId, 1, (u32)ptr); + } +} + +void DecompressAndLoadBgGfxUsingHeap2(u8 bgId, const void *src, u32 size, u16 offset, u8 mode) +{ + u32 sizeOut; + void *ptr = MallocAndDecompress(src, &sizeOut); + if (sizeOut > size) + sizeOut = size; + if (ptr) + { + u8 taskId = CreateTask(TaskFreeBufAfterCopyingTileDataToVram, 0); + gTasks[taskId].data[0] = CopyDecompressedTileDataToVram(bgId, ptr, sizeOut, offset, mode); + SetWordTaskArg(taskId, 1, (u32)ptr); + } +} + +void TaskFreeBufAfterCopyingTileDataToVram(u8 taskId) +{ + if (!CheckForSpaceForDma3Request(gTasks[taskId].data[0])) + { + Free((void *)GetWordTaskArg(taskId, 1)); + DestroyTask(taskId); + } +} + +void *MallocAndDecompress(const void *src, u32 *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 CopyDecompressedTileDataToVram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode) +{ + switch (mode) + { // different to EM + case 1: + break; + case 0: + default: + return LoadBgTiles(bgId, src, size, offset); + } + return LoadBgTilemap(bgId, src, size, offset); +} + +void SetBgRectPal(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 CopyRectIntoAltRect(u8 bgId, u16 *dest, u8 left, u8 top, u8 width, u8 height) +{ + u8 i; + u8 j; + const u16 *src = GetBgTilemapBuffer(bgId); + + for (i = 0; i < height; i++) + { + for (j = 0; j < width; j++) + { + dest[(i * width) + j] = src[(i + top) * 32 + j + left]; + } + } +} + +void ResetBgPositions(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 InitStandardTextBoxWindows(void) +{ + InitWindows(sStandardTextBox_WindowTemplates); + sStartMenuWindowId = 0xFF; + MapNamePopupWindowIdSetDummy(); +} + +void FreeAllOverworldWindowBuffers(void) +{ + FreeAllWindowBuffers(); +} + +void ResetBg0(void) +{ + ChangeBgX(0, 0, 0); + ChangeBgY(0, 0, 0); + DeactivateAllTextPrinters(); + sub_80F6E9C(); +} + +u16 RunTextPrinters_CheckPrinter0Active(void) +{ + RunTextPrinters(); + return IsTextPrinterActive(0); +} + +u16 AddTextPrinterParameterized2(u8 windowId, u8 fontId, const u8 *str, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16), u8 fgColor, u8 bgColor, u8 shadowColor) +{ + struct TextPrinterTemplate printer; + + printer.currentChar = str; + printer.windowId = windowId; + printer.fontId = fontId; + printer.x = 0; + printer.y = 1; + printer.currentX = 0; + printer.currentY = 1; + printer.letterSpacing = 1; // different to EM + printer.lineSpacing = 1; // different to EM + printer.unk = 0; + printer.fgColor = fgColor; + printer.bgColor = bgColor; + printer.shadowColor = shadowColor; + gTextFlags.useAlternateDownArrow = 0; + return AddTextPrinter(&printer, speed, callback); +} + -- cgit v1.2.3 From d64ddf09450a4119017e7e2ecf2bcb2061b6a241 Mon Sep 17 00:00:00 2001 From: jiangzhengwenjz Date: Mon, 24 Jun 2019 15:47:06 +0800 Subject: through AddTextPrinterWithCustomSpeedForMessage --- src/new_menu_helpers.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) (limited to 'src/new_menu_helpers.c') diff --git a/src/new_menu_helpers.c b/src/new_menu_helpers.c index 7abe277e1..c4e8ab284 100644 --- a/src/new_menu_helpers.c +++ b/src/new_menu_helpers.c @@ -10,11 +10,12 @@ #include "new_menu_helpers.h" #include "quest_log.h" #include "text.h" +#include "field_specials.h" static EWRAM_DATA bool8 gUnknown_203AB58[4] = {FALSE}; // knizz: bgmaps_that_need_syncing +static EWRAM_DATA u16 gUnknown_203AB5C = {0}; +static EWRAM_DATA void *gUnknown_203AB60[0x20] = {NULL}; -EWRAM_DATA u16 gUnknown_203AB5C; -EWRAM_DATA void *gUnknown_203AB60[0x20]; extern const struct WindowTemplate sStandardTextBox_WindowTemplates[]; EWRAM_DATA u8 sStartMenuWindowId; @@ -181,10 +182,10 @@ u16 CopyDecompressedTileDataToVram(u8 bgId, const void *src, u16 size, u16 offse { switch (mode) { // different to EM - case 1: - break; - case 0: - default: + case 1: + break; + case 0: + default: return LoadBgTiles(bgId, src, size, offset); } return LoadBgTilemap(bgId, src, size, offset); @@ -279,3 +280,29 @@ u16 AddTextPrinterParameterized2(u8 windowId, u8 fontId, const u8 *str, u8 speed return AddTextPrinter(&printer, speed, callback); } +void AddTextPrinterDiffStyle(bool8 allowSkippingDelayWithButtonPress) +{ + u8 result; + void *nptr = NULL; // This is required for matching + + gTextFlags.canABSpeedUpPrint = allowSkippingDelayWithButtonPress; + result = ContextNpcGetTextColor(); + if (!result) + AddTextPrinterParameterized2(0, 4, gStringVar4, GetTextSpeedSetting(), nptr, 8, 1, 3); + else if (result == 1) + AddTextPrinterParameterized2(0, 5, gStringVar4, GetTextSpeedSetting(), nptr, 4, 1, 3); + else + AddTextPrinterParameterized2(0, 2, gStringVar4, GetTextSpeedSetting(), nptr, 2, 1, 3); +} + +void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress) +{ + gTextFlags.canABSpeedUpPrint = allowSkippingDelayWithButtonPress; + AddTextPrinterParameterized2(0, 2, gStringVar4, GetTextSpeedSetting(), NULL, 2, 1, 3); +} + +void AddTextPrinterWithCustomSpeedForMessage(bool8 allowSkippingDelayWithButtonPress, u8 speed) +{ + gTextFlags.canABSpeedUpPrint = allowSkippingDelayWithButtonPress; + AddTextPrinterParameterized2(0, 2, gStringVar4, speed, NULL, 2, 1, 3); +} -- cgit v1.2.3 From cc937d33b4ae33312d543269f78207037f86b4c3 Mon Sep 17 00:00:00 2001 From: jiangzhengwenjz Date: Tue, 25 Jun 2019 04:51:59 +0800 Subject: thru WindowFunc_ClearDialogWindowAndFrame() --- src/new_menu_helpers.c | 161 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 157 insertions(+), 4 deletions(-) (limited to 'src/new_menu_helpers.c') diff --git a/src/new_menu_helpers.c b/src/new_menu_helpers.c index c4e8ab284..f3f9f65b9 100644 --- a/src/new_menu_helpers.c +++ b/src/new_menu_helpers.c @@ -11,6 +11,13 @@ #include "quest_log.h" #include "text.h" #include "field_specials.h" +#include "text_window.h" +#include "script.h" + +#define DLG_WINDOW_PALETTE_NUM 15 +#define DLG_WINDOW_BASE_TILE_NUM 0x200 +#define STD_WINDOW_PALETTE_NUM 14 +#define STD_WINDOW_BASE_TILE_NUM 0x214 static EWRAM_DATA bool8 gUnknown_203AB58[4] = {FALSE}; // knizz: bgmaps_that_need_syncing static EWRAM_DATA u16 gUnknown_203AB5C = {0}; @@ -19,8 +26,12 @@ static EWRAM_DATA void *gUnknown_203AB60[0x20] = {NULL}; extern const struct WindowTemplate sStandardTextBox_WindowTemplates[]; EWRAM_DATA u8 sStartMenuWindowId; -u16 CopyDecompressedTileDataToVram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode); -void TaskFreeBufAfterCopyingTileDataToVram(u8 taskId); +static u16 CopyDecompressedTileDataToVram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode); +static void WindowFunc_DrawDialogueFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); +static void WindowFunc_DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); +static void WindowFunc_ClearDialogWindowAndFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); +static void WindowFunc_ClearStdWindowAndFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); +static void TaskFreeBufAfterCopyingTileDataToVram(u8 taskId); void ClearScheduledBgCopiesToVram(void) { @@ -152,7 +163,7 @@ void DecompressAndLoadBgGfxUsingHeap2(u8 bgId, const void *src, u32 size, u16 of } } -void TaskFreeBufAfterCopyingTileDataToVram(u8 taskId) +static void TaskFreeBufAfterCopyingTileDataToVram(u8 taskId) { if (!CheckForSpaceForDma3Request(gTasks[taskId].data[0])) { @@ -178,7 +189,7 @@ void *MallocAndDecompress(const void *src, u32 *size) return ptr; } -u16 CopyDecompressedTileDataToVram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode) +static u16 CopyDecompressedTileDataToVram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode) { switch (mode) { // different to EM @@ -306,3 +317,145 @@ void AddTextPrinterWithCustomSpeedForMessage(bool8 allowSkippingDelayWithButtonP gTextFlags.canABSpeedUpPrint = allowSkippingDelayWithButtonPress; AddTextPrinterParameterized2(0, 2, gStringVar4, speed, NULL, 2, 1, 3); } + +void sub_80F6E9C(void) +{ + if (gUnknown_203ADFA == 2) + { + gTextFlags.autoScroll = 1; + TextWindow_LoadTilesStdFrame1(0, 0x200); + } + else + { + sub_80F77B8(); + TextWindow_LoadResourcesStdFrame0(0, 0x200, 0xF0); + } + TextWindow_SetUserSelectedFrame(0, 0x214, 0xE0); +} + +void DrawDialogueFrame(u8 windowId, bool8 copyToVram) +{ + CallWindowFunction(windowId, WindowFunc_DrawDialogueFrame); + FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); + PutWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +void DrawStdWindowFrame(u8 windowId, bool8 copyToVram) +{ + CallWindowFunction(windowId, WindowFunc_DrawStandardFrame); + FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); + PutWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +void ClearDialogWindowAndFrame(u8 windowId, bool8 copyToVram) +{ + CallWindowFunction(windowId, WindowFunc_ClearDialogWindowAndFrame); + FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); + ClearWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); + if (gUnknown_203ADFA == 2) + sub_8111134(); +} + +void ClearStdWindowAndFrame(u8 windowId, bool8 copyToVram) +{ + CallWindowFunction(windowId, WindowFunc_ClearStdWindowAndFrame); + FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); + ClearWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +static void WindowFunc_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, tilemapTop - 1, 1, 1, STD_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, STD_WINDOW_BASE_TILE_NUM + 1, tilemapLeft, tilemapTop - 1, width, 1, STD_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, STD_WINDOW_BASE_TILE_NUM + 2, tilemapLeft + width, tilemapTop - 1, 1, 1, STD_WINDOW_PALETTE_NUM); + for (i = tilemapTop; i < tilemapTop + height; i++) + { + FillBgTilemapBufferRect(bg, STD_WINDOW_BASE_TILE_NUM + 3, tilemapLeft - 1, i, 1, 1, STD_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, STD_WINDOW_BASE_TILE_NUM + 5, tilemapLeft + width, i, 1, 1, STD_WINDOW_PALETTE_NUM); + } + FillBgTilemapBufferRect(bg, STD_WINDOW_BASE_TILE_NUM + 6, tilemapLeft - 1, tilemapTop + height, 1, 1, STD_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, STD_WINDOW_BASE_TILE_NUM + 7, tilemapLeft, tilemapTop + height, width, 1, STD_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, STD_WINDOW_BASE_TILE_NUM + 8, tilemapLeft + width, tilemapTop + height, 1, 1, STD_WINDOW_PALETTE_NUM); +} + +static void WindowFunc_DrawDialogueFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + if (!IsMsgSignPost() || gUnknown_203ADFA == 2) + { + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 0, tilemapLeft - 2, tilemapTop - 1, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 1, tilemapLeft - 1, tilemapTop - 1, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 2, tilemapLeft, tilemapTop - 1, width, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 3, tilemapLeft + width, tilemapTop - 1, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 4, tilemapLeft + width + 1, tilemapTop - 1, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 5, tilemapLeft - 2, tilemapTop, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 6, tilemapLeft - 1, tilemapTop, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 8, tilemapLeft + width, tilemapTop, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 9, tilemapLeft + width + 1, tilemapTop, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 10, tilemapLeft - 2, tilemapTop + 1, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 11, tilemapLeft - 1, tilemapTop + 1, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 12, tilemapLeft + width, tilemapTop + 1, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 13, tilemapLeft + width + 1, tilemapTop + 1, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 10), tilemapLeft - 2, tilemapTop + 2, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 11), tilemapLeft - 1, tilemapTop + 2, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 12), tilemapLeft + width, tilemapTop + 2, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 13), tilemapLeft + width + 1, tilemapTop + 2, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 5), tilemapLeft - 2, tilemapTop + 3, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 6), tilemapLeft - 1, tilemapTop + 3, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 8), tilemapLeft + width, tilemapTop + 3, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 9), tilemapLeft + width + 1, tilemapTop + 3, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 0), tilemapLeft - 2, tilemapTop + 4, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 1), tilemapLeft - 1, tilemapTop + 4, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 2), tilemapLeft, tilemapTop + 4, width, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 3), tilemapLeft + width, tilemapTop + 4, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 4), tilemapLeft + width + 1, tilemapTop + 4, 1, 1, DLG_WINDOW_PALETTE_NUM); + } + else + { + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 0, tilemapLeft - 2, tilemapTop - 1, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 1, tilemapLeft - 1, tilemapTop - 1, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 2, tilemapLeft, tilemapTop - 1, width, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 3, tilemapLeft + width, tilemapTop - 1, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 4, tilemapLeft + width + 1, tilemapTop - 1, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 5, tilemapLeft - 2, tilemapTop, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 6, tilemapLeft - 1, tilemapTop, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 8, tilemapLeft + width, tilemapTop, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 9, tilemapLeft + width + 1, tilemapTop, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 10, tilemapLeft - 2, tilemapTop + 1, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 11, tilemapLeft - 1, tilemapTop + 1, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 12, tilemapLeft + width, tilemapTop + 1, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 13, tilemapLeft + width + 1, tilemapTop + 1, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 5), tilemapLeft - 2, tilemapTop + 2, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 6), tilemapLeft - 1, tilemapTop + 2, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 8), tilemapLeft + width, tilemapTop + 2, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 9), tilemapLeft + width + 1, tilemapTop + 2, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 10), tilemapLeft - 2, tilemapTop + 3, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 11), tilemapLeft - 1, tilemapTop + 3, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 12), tilemapLeft + width, tilemapTop + 3, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 13), tilemapLeft + width + 1, tilemapTop + 3, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 0), tilemapLeft - 2, tilemapTop + 4, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 1), tilemapLeft - 1, tilemapTop + 4, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 2), tilemapLeft, tilemapTop + 4, width, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 3), tilemapLeft + width, tilemapTop + 4, 1, 1, DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 4), tilemapLeft + width + 1, tilemapTop + 4, 1, 1, DLG_WINDOW_PALETTE_NUM); + } +} + +static void WindowFunc_ClearStdWindowAndFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + FillBgTilemapBufferRect(bg, 0, tilemapLeft - 1, tilemapTop - 1, width + 2, height + 2, STD_WINDOW_PALETTE_NUM); +} + +static void WindowFunc_ClearDialogWindowAndFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + FillBgTilemapBufferRect(bg, 0, tilemapLeft - 2, tilemapTop - 1, width + 4, height + 2, STD_WINDOW_PALETTE_NUM); +} -- cgit v1.2.3 From 0d46c60b383d5feca05950e57bb05dc392f815cc Mon Sep 17 00:00:00 2001 From: jiangzhengwenjz Date: Tue, 25 Jun 2019 05:47:01 +0800 Subject: thru DisplayYesNoMenuDefaultNo() --- src/new_menu_helpers.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 4 deletions(-) (limited to 'src/new_menu_helpers.c') diff --git a/src/new_menu_helpers.c b/src/new_menu_helpers.c index f3f9f65b9..5f7451eb6 100644 --- a/src/new_menu_helpers.c +++ b/src/new_menu_helpers.c @@ -13,6 +13,8 @@ #include "field_specials.h" #include "text_window.h" #include "script.h" +#include "graphics.h" +#include "palette.h" #define DLG_WINDOW_PALETTE_NUM 15 #define DLG_WINDOW_BASE_TILE_NUM 0x200 @@ -24,6 +26,7 @@ static EWRAM_DATA u16 gUnknown_203AB5C = {0}; static EWRAM_DATA void *gUnknown_203AB60[0x20] = {NULL}; extern const struct WindowTemplate sStandardTextBox_WindowTemplates[]; +extern const struct WindowTemplate sYesNo_WindowTemplate; EWRAM_DATA u8 sStartMenuWindowId; static u16 CopyDecompressedTileDataToVram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode); @@ -323,14 +326,14 @@ void sub_80F6E9C(void) if (gUnknown_203ADFA == 2) { gTextFlags.autoScroll = 1; - TextWindow_LoadTilesStdFrame1(0, 0x200); + TextWindow_LoadTilesStdFrame1(0, DLG_WINDOW_BASE_TILE_NUM); } else { - sub_80F77B8(); - TextWindow_LoadResourcesStdFrame0(0, 0x200, 0xF0); + Menu_LoadStdPal(); + TextWindow_LoadResourcesStdFrame0(0, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM * 0x10); } - TextWindow_SetUserSelectedFrame(0, 0x214, 0xE0); + TextWindow_SetUserSelectedFrame(0, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM * 0x10); } void DrawDialogueFrame(u8 windowId, bool8 copyToVram) @@ -459,3 +462,69 @@ static void WindowFunc_ClearDialogWindowAndFrame(u8 bg, u8 tilemapLeft, u8 tilem { FillBgTilemapBufferRect(bg, 0, tilemapLeft - 2, tilemapTop - 1, width + 4, height + 2, STD_WINDOW_PALETTE_NUM); } + +void sub_80F771C(bool8 copyToVram) +{ + FillBgTilemapBufferRect(0, 0, 0, 0, 0x20, 0x20, 0x11); + if (copyToVram == TRUE) + CopyBgTilemapBufferToVram(0); +} + +void SetStdWindowBorderStyle(u8 windowId, bool8 copyToVram) +{ + SetWindowBorderStyle(windowId, copyToVram, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM); +} + +void sub_80F7768(u8 windowId, bool8 copyToVram) +{ + if (gUnknown_203ADFA == 2) + { + gTextFlags.autoScroll = 1; + TextWindow_LoadTilesStdFrame1(0, DLG_WINDOW_BASE_TILE_NUM); + } + else + { + TextWindow_LoadResourcesStdFrame0(windowId, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM * 0x10); + } + DrawDialogFrameWithCustomTileAndPalette(windowId, copyToVram, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM); +} + +void Menu_LoadStdPal(void) +{ + LoadPalette(gTMCaseMainWindowPalette, STD_WINDOW_PALETTE_NUM * 0x10, 0x14); +} + +void Menu_LoadStdPalAt(u16 offset) +{ + LoadPalette(gTMCaseMainWindowPalette, offset, 0x14); +} + +static const u16 *GetTmCaseMainWindowPalette(void) +{ + return gTMCaseMainWindowPalette; +} + +static u16 GetStdPalColor(u8 colorNum) +{ + if (colorNum > 0xF) + colorNum = 0; + return gTMCaseMainWindowPalette[colorNum]; +} + +void DisplayItemMessageOnField(u8 taskId, u8 bgId, const u8 *string, TaskFunc callback) +{ + sub_80F6E9C(); + DisplayMessageAndContinueTask(taskId, 0, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM, bgId, GetTextSpeedSetting(), string, callback); + CopyWindowToVram(0, 3); +} + +void DisplayYesNoMenuDefaultYes(void) +{ + CreateYesNoMenu(&sYesNo_WindowTemplate, 2, 0, 2, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM, 0); +} + +void DisplayYesNoMenuDefaultNo(void) +{ + CreateYesNoMenu(&sYesNo_WindowTemplate, 2, 0, 2, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM, 1); +} + -- cgit v1.2.3 From 2a870d54fca85b6f4501cff857837c3f2940fd7d Mon Sep 17 00:00:00 2001 From: jiangzhengwenjz Date: Tue, 25 Jun 2019 06:50:48 +0800 Subject: All Done --- src/new_menu_helpers.c | 241 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 238 insertions(+), 3 deletions(-) (limited to 'src/new_menu_helpers.c') diff --git a/src/new_menu_helpers.c b/src/new_menu_helpers.c index 5f7451eb6..9ee172f0f 100644 --- a/src/new_menu_helpers.c +++ b/src/new_menu_helpers.c @@ -24,10 +24,139 @@ static EWRAM_DATA bool8 gUnknown_203AB58[4] = {FALSE}; // knizz: bgmaps_that_need_syncing static EWRAM_DATA u16 gUnknown_203AB5C = {0}; static EWRAM_DATA void *gUnknown_203AB60[0x20] = {NULL}; +static EWRAM_DATA u8 sStartMenuWindowId = {0}; -extern const struct WindowTemplate sStandardTextBox_WindowTemplates[]; -extern const struct WindowTemplate sYesNo_WindowTemplate; -EWRAM_DATA u8 sStartMenuWindowId; +static const u8 gUnknown_841F428[] = { 8, 4, 1, 0, }; + +static const struct WindowTemplate sStandardTextBox_WindowTemplates[] = +{ + { + .bg = 0, + .tilemapLeft = 0x2, + .tilemapTop = 0xF, + .width = 0x1A, + .height = 0x4, + .paletteNum = DLG_WINDOW_PALETTE_NUM, + .baseBlock = 0x198, + }, + DUMMY_WIN_TEMPLATE, +}; + +static const struct WindowTemplate sYesNo_WindowTemplate = +{ + .bg = 0, + .tilemapLeft = 0x15, + .tilemapTop = 0x9, + .width = 0x6, + .height = 0x4, + .paletteNum = DLG_WINDOW_PALETTE_NUM, + .baseBlock = 0x125, +}; + +static const struct FontInfo gFontInfos[] = +{ + { + .fontFunction = Font0Func, + .maxLetterWidth = 0x8, + .maxLetterHeight = 0xD, + .letterSpacing = 0x0, + .lineSpacing = 0x0, + .unk = 0x0, + .fgColor = 0x2, + .bgColor = 0x1, + .shadowColor = 0x3, + }, + { + .fontFunction = Font1Func, + .maxLetterWidth = 0x8, + .maxLetterHeight = 0xE, + .letterSpacing = 0x0, + .lineSpacing = 0x0, + .unk = 0x0, + .fgColor = 0x2, + .bgColor = 0x1, + .shadowColor = 0x3, + }, + { + .fontFunction = Font2Func, + .maxLetterWidth = 0xA, + .maxLetterHeight = 0xE, + .letterSpacing = 0x1, + .lineSpacing = 0x0, + .unk = 0x0, + .fgColor = 0x2, + .bgColor = 0x1, + .shadowColor = 0x3, + }, + { + .fontFunction = Font3Func, + .maxLetterWidth = 0xA, + .maxLetterHeight = 0xE, + .letterSpacing = 0x1, + .lineSpacing = 0x0, + .unk = 0x0, + .fgColor = 0x2, + .bgColor = 0x1, + .shadowColor = 0x3, + }, + { + .fontFunction = Font4Func, + .maxLetterWidth = 0xA, + .maxLetterHeight = 0xE, + .letterSpacing = 0x0, + .lineSpacing = 0x0, + .unk = 0x0, + .fgColor = 0x2, + .bgColor = 0x1, + .shadowColor = 0x3, + }, + { + .fontFunction = Font5Func, + .maxLetterWidth = 0xA, + .maxLetterHeight = 0xE, + .letterSpacing = 0x0, + .lineSpacing = 0x0, + .unk = 0x0, + .fgColor = 0x2, + .bgColor = 0x1, + .shadowColor = 0x3, + }, + { + .fontFunction = Font6Func, + .maxLetterWidth = 0x8, + .maxLetterHeight = 0x10, + .letterSpacing = 0x0, + .lineSpacing = 0x2, + .unk = 0x0, + .fgColor = 0x2, + .bgColor = 0x1, + .shadowColor = 0x3, + }, + { + .fontFunction = NULL, + .maxLetterWidth = 0x8, + .maxLetterHeight = 0x8, + .letterSpacing = 0x0, + .lineSpacing = 0x0, + .unk = 0x0, + .fgColor = 0x1, + .bgColor = 0x2, + .shadowColor = 0xF, + }, +}; + + +static const u8 gMenuCursorDimensions[][2] = +{ + { 0x8, 0xD, }, + { 0x8, 0xE, }, + { 0x8, 0xE, }, + { 0x8, 0xE, }, + { 0x8, 0xE, }, + { 0x8, 0xE, }, + { 0x8, 0x10, }, + { 0x0, 0x0, }, +}; static u16 CopyDecompressedTileDataToVram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode); static void WindowFunc_DrawDialogueFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); @@ -528,3 +657,109 @@ void DisplayYesNoMenuDefaultNo(void) CreateYesNoMenu(&sYesNo_WindowTemplate, 2, 0, 2, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM, 1); } +u8 GetTextSpeedSetting(void) +{ + u32 speed; + if (gSaveBlock2Ptr->optionsTextSpeed > OPTIONS_TEXT_SPEED_FAST) + gSaveBlock2Ptr->optionsTextSpeed = OPTIONS_TEXT_SPEED_MID; + return gUnknown_841F428[gSaveBlock2Ptr->optionsTextSpeed]; +} + +u8 sub_80F78E0(u8 height) +{ + if (sStartMenuWindowId == 0xFF) + { + struct WindowTemplate wTemp1, wTemp2; + SetWindowTemplateFields(&wTemp1, 0, 0x16, 1, 7, height * 2 - 1, DLG_WINDOW_PALETTE_NUM, 0x13D); + wTemp2 = wTemp1; // This is required for matching + sStartMenuWindowId = AddWindow(&wTemp2); + PutWindowTilemap(sStartMenuWindowId); + } + return sStartMenuWindowId; +} + +u8 GetStartMenuWindowId(void) +{ + return sStartMenuWindowId; +} + +void RemoveStartMenuWindow(void) +{ + if (sStartMenuWindowId != 0xFF) + { + RemoveWindow(sStartMenuWindowId); + sStartMenuWindowId = 0xFF; + } +} + +static u16 GetDlgWindowBaseTileNum(void) +{ + return DLG_WINDOW_BASE_TILE_NUM; +} + +u16 GetStdWindowBaseTileNum(void) +{ + return STD_WINDOW_BASE_TILE_NUM; +} + +void sub_80F7974(const u8 * text) +{ + sub_814FE6C(sub_8112EB4(), DLG_WINDOW_BASE_TILE_NUM, 0x10 * DLG_WINDOW_PALETTE_NUM); + sub_8113018(text, 2); +} + +void sub_80F7998(void) +{ + sub_8112EDC(2); +} + +void sub_80F79A4(void) +{ + Menu_LoadStdPal(); + sub_814FEEC(0, DLG_WINDOW_BASE_TILE_NUM, 0x10 * DLG_WINDOW_PALETTE_NUM); + TextWindow_SetUserSelectedFrame(0, STD_WINDOW_BASE_TILE_NUM, 0x10 * STD_WINDOW_PALETTE_NUM); +} + +void SetDefaultFontsPointer(void) +{ + SetFontsPointer(&gFontInfos[0]); +} + +u8 GetFontAttribute(u8 fontId, u8 attributeId) +{ + int result = 0; + + switch (attributeId) + { + case FONTATTR_MAX_LETTER_WIDTH: + result = gFontInfos[fontId].maxLetterWidth; + break; + case FONTATTR_MAX_LETTER_HEIGHT: + result = gFontInfos[fontId].maxLetterHeight; + break; + case FONTATTR_LETTER_SPACING: + result = gFontInfos[fontId].letterSpacing; + break; + case FONTATTR_LINE_SPACING: + result = gFontInfos[fontId].lineSpacing; + break; + case FONTATTR_UNKNOWN: + result = gFontInfos[fontId].unk; + break; + case FONTATTR_COLOR_FOREGROUND: + result = gFontInfos[fontId].fgColor; + break; + case FONTATTR_COLOR_BACKGROUND: + result = gFontInfos[fontId].bgColor; + break; + case FONTATTR_COLOR_SHADOW: + result = gFontInfos[fontId].shadowColor; + break; + } + return result; +} + +u8 GetMenuCursorDimensionByFont(u8 fontId, u8 whichDimension) +{ + return gMenuCursorDimensions[fontId][whichDimension]; +} -- cgit v1.2.3 From 56dabd4626f2acb6bc8ce1a4d615a2fe54a64737 Mon Sep 17 00:00:00 2001 From: jiangzhengwenjz Date: Tue, 25 Jun 2019 07:50:29 +0800 Subject: multiple fixes --- src/new_menu_helpers.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src/new_menu_helpers.c') diff --git a/src/new_menu_helpers.c b/src/new_menu_helpers.c index 9ee172f0f..c8b9e22b8 100644 --- a/src/new_menu_helpers.c +++ b/src/new_menu_helpers.c @@ -26,7 +26,7 @@ static EWRAM_DATA u16 gUnknown_203AB5C = {0}; static EWRAM_DATA void *gUnknown_203AB60[0x20] = {NULL}; static EWRAM_DATA u8 sStartMenuWindowId = {0}; -static const u8 gUnknown_841F428[] = { 8, 4, 1, 0, }; +static const u8 gUnknown_841F428[] = { 8, 4, 1 }; static const struct WindowTemplate sStandardTextBox_WindowTemplates[] = { @@ -39,7 +39,7 @@ static const struct WindowTemplate sStandardTextBox_WindowTemplates[] = .paletteNum = DLG_WINDOW_PALETTE_NUM, .baseBlock = 0x198, }, - DUMMY_WIN_TEMPLATE, + DUMMY_WIN_TEMPLATE }; static const struct WindowTemplate sYesNo_WindowTemplate = @@ -142,20 +142,20 @@ static const struct FontInfo gFontInfos[] = .fgColor = 0x1, .bgColor = 0x2, .shadowColor = 0xF, - }, + } }; static const u8 gMenuCursorDimensions[][2] = { - { 0x8, 0xD, }, - { 0x8, 0xE, }, - { 0x8, 0xE, }, - { 0x8, 0xE, }, - { 0x8, 0xE, }, - { 0x8, 0xE, }, - { 0x8, 0x10, }, - { 0x0, 0x0, }, + { 0x8, 0xD }, + { 0x8, 0xE }, + { 0x8, 0xE }, + { 0x8, 0xE }, + { 0x8, 0xE }, + { 0x8, 0xE }, + { 0x8, 0x10 }, + { 0x0, 0x0 } }; static u16 CopyDecompressedTileDataToVram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode); @@ -202,7 +202,7 @@ void DoScheduledBgTilemapCopiesToVram(void) void ResetTempTileDataBuffers(void) { int i; - for (i = 0; i < (s32)ARRAY_COUNT(gUnknown_203AB60); i++) + for (i = 0; i < (s32)NELEMS(gUnknown_203AB60); i++) { gUnknown_203AB60[i] = NULL; } @@ -234,7 +234,7 @@ bool8 FreeTempTileDataBuffersIfPossible(void) void *DecompressAndCopyTileDataToVram(u8 bgId, const void *src, u32 size, u16 offset, u8 mode) { u32 sizeOut; - if (gUnknown_203AB5C < ARRAY_COUNT(gUnknown_203AB60)) + if (gUnknown_203AB5C < NELEMS(gUnknown_203AB60)) { void *ptr = MallocAndDecompress(src, &sizeOut); if (!size) @@ -252,7 +252,7 @@ void *DecompressAndCopyTileDataToVram(u8 bgId, const void *src, u32 size, u16 of void *DecompressAndCopyTileDataToVram2(u8 bgId, const void *src, u32 size, u16 offset, u8 mode) { u32 sizeOut; - if (gUnknown_203AB5C < ARRAY_COUNT(gUnknown_203AB60)) + if (gUnknown_203AB5C < NELEMS(gUnknown_203AB60)) { void *ptr = MallocAndDecompress(src, &sizeOut); if (sizeOut > size) @@ -285,8 +285,8 @@ void DecompressAndLoadBgGfxUsingHeap2(u8 bgId, const void *src, u32 size, u16 of { u32 sizeOut; void *ptr = MallocAndDecompress(src, &sizeOut); - if (sizeOut > size) - sizeOut = size; + if (sizeOut > size) + sizeOut = size; if (ptr) { u8 taskId = CreateTask(TaskFreeBufAfterCopyingTileDataToVram, 0); @@ -308,7 +308,7 @@ void *MallocAndDecompress(const void *src, u32 *size) { void *ptr; u8 *sizeAsBytes = (u8 *)size; - u8 *srcAsBytes = (u8 *)src; + const u8 *srcAsBytes = src; sizeAsBytes[0] = srcAsBytes[1]; sizeAsBytes[1] = srcAsBytes[2]; @@ -324,7 +324,7 @@ void *MallocAndDecompress(const void *src, u32 *size) static u16 CopyDecompressedTileDataToVram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode) { switch (mode) - { // different to EM + { case 1: break; case 0: @@ -413,8 +413,8 @@ u16 AddTextPrinterParameterized2(u8 windowId, u8 fontId, const u8 *str, u8 speed printer.y = 1; printer.currentX = 0; printer.currentY = 1; - printer.letterSpacing = 1; // different to EM - printer.lineSpacing = 1; // different to EM + printer.letterSpacing = 1; + printer.lineSpacing = 1; printer.unk = 0; printer.fgColor = fgColor; printer.bgColor = bgColor; @@ -426,11 +426,11 @@ u16 AddTextPrinterParameterized2(u8 windowId, u8 fontId, const u8 *str, u8 speed void AddTextPrinterDiffStyle(bool8 allowSkippingDelayWithButtonPress) { u8 result; - void *nptr = NULL; // This is required for matching + void *nptr = NULL; gTextFlags.canABSpeedUpPrint = allowSkippingDelayWithButtonPress; result = ContextNpcGetTextColor(); - if (!result) + if (result == 0) AddTextPrinterParameterized2(0, 4, gStringVar4, GetTextSpeedSetting(), nptr, 8, 1, 3); else if (result == 1) AddTextPrinterParameterized2(0, 5, gStringVar4, GetTextSpeedSetting(), nptr, 4, 1, 3); @@ -671,7 +671,7 @@ u8 sub_80F78E0(u8 height) { struct WindowTemplate wTemp1, wTemp2; SetWindowTemplateFields(&wTemp1, 0, 0x16, 1, 7, height * 2 - 1, DLG_WINDOW_PALETTE_NUM, 0x13D); - wTemp2 = wTemp1; // This is required for matching + wTemp2 = wTemp1; sStartMenuWindowId = AddWindow(&wTemp2); PutWindowTilemap(sStartMenuWindowId); } -- cgit v1.2.3 From 9260240931d7584a8a2007f0f24a33ba9d82140c Mon Sep 17 00:00:00 2001 From: jiangzhengwenjz Date: Wed, 26 Jun 2019 08:19:45 +0800 Subject: clean up --- src/new_menu_helpers.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/new_menu_helpers.c') diff --git a/src/new_menu_helpers.c b/src/new_menu_helpers.c index c8b9e22b8..1939154da 100644 --- a/src/new_menu_helpers.c +++ b/src/new_menu_helpers.c @@ -145,7 +145,6 @@ static const struct FontInfo gFontInfos[] = } }; - static const u8 gMenuCursorDimensions[][2] = { { 0x8, 0xD }, @@ -202,6 +201,7 @@ void DoScheduledBgTilemapCopiesToVram(void) void ResetTempTileDataBuffers(void) { int i; + for (i = 0; i < (s32)NELEMS(gUnknown_203AB60); i++) { gUnknown_203AB60[i] = NULL; @@ -234,6 +234,7 @@ bool8 FreeTempTileDataBuffersIfPossible(void) void *DecompressAndCopyTileDataToVram(u8 bgId, const void *src, u32 size, u16 offset, u8 mode) { u32 sizeOut; + if (gUnknown_203AB5C < NELEMS(gUnknown_203AB60)) { void *ptr = MallocAndDecompress(src, &sizeOut); @@ -252,6 +253,7 @@ void *DecompressAndCopyTileDataToVram(u8 bgId, const void *src, u32 size, u16 of void *DecompressAndCopyTileDataToVram2(u8 bgId, const void *src, u32 size, u16 offset, u8 mode) { u32 sizeOut; + if (gUnknown_203AB5C < NELEMS(gUnknown_203AB60)) { void *ptr = MallocAndDecompress(src, &sizeOut); @@ -270,6 +272,7 @@ void *DecompressAndCopyTileDataToVram2(u8 bgId, const void *src, u32 size, u16 o void DecompressAndLoadBgGfxUsingHeap(u8 bgId, const void *src, u32 size, u16 offset, u8 mode) { u32 sizeOut; + void *ptr = MallocAndDecompress(src, &sizeOut); if (!size) size = sizeOut; @@ -284,6 +287,7 @@ void DecompressAndLoadBgGfxUsingHeap(u8 bgId, const void *src, u32 size, u16 off void DecompressAndLoadBgGfxUsingHeap2(u8 bgId, const void *src, u32 size, u16 offset, u8 mode) { u32 sizeOut; + void *ptr = MallocAndDecompress(src, &sizeOut); if (sizeOut > size) sizeOut = size; @@ -336,8 +340,7 @@ static u16 CopyDecompressedTileDataToVram(u8 bgId, const void *src, u16 size, u1 void SetBgRectPal(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette) { - u8 i; - u8 j; + u8 i, j; u16 *ptr = GetBgTilemapBuffer(bgId); for (i = top; i < top + height; i++) @@ -351,8 +354,7 @@ void SetBgRectPal(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette) void CopyRectIntoAltRect(u8 bgId, u16 *dest, u8 left, u8 top, u8 width, u8 height) { - u8 i; - u8 j; + u8 i,j; const u16 *src = GetBgTilemapBuffer(bgId); for (i = 0; i < height; i++) -- cgit v1.2.3 From e0e81c5fbe6a0c0bdcbb5a1de5e16dfb1ffdc091 Mon Sep 17 00:00:00 2001 From: jiangzhengwenjz Date: Tue, 9 Jul 2019 14:07:19 +0800 Subject: finished menu (1 failed attempt) --- src/new_menu_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/new_menu_helpers.c') diff --git a/src/new_menu_helpers.c b/src/new_menu_helpers.c index 1939154da..8ef515006 100644 --- a/src/new_menu_helpers.c +++ b/src/new_menu_helpers.c @@ -603,7 +603,7 @@ void sub_80F771C(bool8 copyToVram) void SetStdWindowBorderStyle(u8 windowId, bool8 copyToVram) { - SetWindowBorderStyle(windowId, copyToVram, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM); + DrawStdFrameWithCustomTileAndPalette(windowId, copyToVram, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM); } void sub_80F7768(u8 windowId, bool8 copyToVram) -- cgit v1.2.3 From bcf27c2de147b1a04c32f8f9e5dd8a5eca657455 Mon Sep 17 00:00:00 2001 From: jiangzhengwenjz Date: Wed, 10 Jul 2019 03:19:28 +0800 Subject: resolved SetWindowTemplateFields --- src/new_menu_helpers.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/new_menu_helpers.c') diff --git a/src/new_menu_helpers.c b/src/new_menu_helpers.c index 8ef515006..5e2452e14 100644 --- a/src/new_menu_helpers.c +++ b/src/new_menu_helpers.c @@ -671,10 +671,9 @@ u8 sub_80F78E0(u8 height) { if (sStartMenuWindowId == 0xFF) { - struct WindowTemplate wTemp1, wTemp2; - SetWindowTemplateFields(&wTemp1, 0, 0x16, 1, 7, height * 2 - 1, DLG_WINDOW_PALETTE_NUM, 0x13D); - wTemp2 = wTemp1; - sStartMenuWindowId = AddWindow(&wTemp2); + struct WindowTemplate template; + template = SetWindowTemplateFields(0, 0x16, 1, 7, height * 2 - 1, DLG_WINDOW_PALETTE_NUM, 0x13D); + sStartMenuWindowId = AddWindow(&template); PutWindowTilemap(sStartMenuWindowId); } return sStartMenuWindowId; -- cgit v1.2.3 From 9d539994652736c50a054c8d3c6beb8f221f3428 Mon Sep 17 00:00:00 2001 From: jiangzhengwenjz Date: Wed, 10 Jul 2019 03:21:34 +0800 Subject: polish and bug fix --- src/new_menu_helpers.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/new_menu_helpers.c') diff --git a/src/new_menu_helpers.c b/src/new_menu_helpers.c index 5e2452e14..9d2a5c883 100644 --- a/src/new_menu_helpers.c +++ b/src/new_menu_helpers.c @@ -671,8 +671,7 @@ u8 sub_80F78E0(u8 height) { if (sStartMenuWindowId == 0xFF) { - struct WindowTemplate template; - template = SetWindowTemplateFields(0, 0x16, 1, 7, height * 2 - 1, DLG_WINDOW_PALETTE_NUM, 0x13D); + struct WindowTemplate template = SetWindowTemplateFields(0, 0x16, 1, 7, height * 2 - 1, DLG_WINDOW_PALETTE_NUM, 0x13D); sStartMenuWindowId = AddWindow(&template); PutWindowTilemap(sStartMenuWindowId); } -- cgit v1.2.3