From 78925baf89a9c02745ed82125d44e5a4fffba1cd Mon Sep 17 00:00:00 2001 From: dheu Date: Mon, 8 Jul 2019 17:44:25 +0800 Subject: decompile: diploma.s --- src/diploma.c | 254 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 254 insertions(+) create mode 100644 src/diploma.c (limited to 'src') diff --git a/src/diploma.c b/src/diploma.c new file mode 100644 index 000000000..cffbe8df1 --- /dev/null +++ b/src/diploma.c @@ -0,0 +1,254 @@ +#include "gba/macro.h" +#include "global.h" +#include "gpu_regs.h" +#include "window.h" +#include "main.h" +#include "scanline_effect.h" +#include "task.h" +#include "unk_text_util.h" +#include "gpu_regs.h" +#include "text.h" +#include "bg.h" +#include "sound.h" +#include "malloc.h" +#include "sprite.h" +#include "palette.h" +#include "new_menu_helpers.h" +#include "menu.h" +#include "diploma.h" + +void sub_80568FC(void); +u16 sub_8088F84(void); + +void DiplomaBgInit(void); +void DiplomaPrintText(void); +u8 DiplomaLoadGfx(void); +void DiplomaVblankHandler(void); + +void CB2_DiplomaInit(void); + +void Task_WaitForExit(u8); +void Task_DiplomaInit(u8); +void Task_DiplomaReturnToOverworld(u8); + +extern const struct BgTemplate gUnknown_8415A08[2]; +extern const struct WindowTemplate gUnknown_8415A10[]; +extern const u8 gUnknown_8402650[]; +extern const u8 gUnknown_841B60E[]; +extern const u8 gUnknown_841B684[]; +extern u8 gUnknown_84147C0[]; +extern u8 gUnknown_8415954[]; +extern u8 gUnknown_841B698[]; +extern u8 gUnknown_841B68F[]; +extern u8 gUnknown_841B619[]; +extern u8 gUnknown_8415A04[]; + +struct Diploma +{ + u8 state; + u8 gfxStep; + u8 callbackStep; + u8 padding; + u8 tilemapBuffer[0x1000]; +} + *gDiploma = NULL; + +extern const u32 gUnknown_84154E8[]; + +void CB2_DiplomaOam(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +void DiplomaInit(void) +{ + gDiploma = AllocZeroed(sizeof(*gDiploma)); + gDiploma->state = 0; + gDiploma->gfxStep = 0; + gDiploma->callbackStep = 0; + DiplomaBgInit(); + CreateTask(Task_DiplomaInit, 0); + SetMainCallback2(CB2_DiplomaInit); +} + +void CB2_DiplomaInit(void) +{ + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +void Task_DiplomaInit(u8 taskId) +{ + switch (gDiploma->callbackStep) + { + case 0: + SetVBlankCallback(NULL); + break; + case 1: + DiplomaVblankHandler(); + break; + case 2: + if (!DiplomaLoadGfx()) + { + return; + } + break; + case 3: + CopyToBgTilemapBuffer(1, gUnknown_84154E8, 0, 0); + break; + case 4: + if (sub_8088F84()) + { + SetGpuReg(REG_OFFSET_BG1HOFS, 0x80 << 1); + } + else + { + SetGpuReg(REG_OFFSET_BG1HOFS, 0); + } + break; + case 5: + DiplomaPrintText(); + break; + case 6: + CopyBgTilemapBufferToVram(0); + CopyBgTilemapBufferToVram(1); + break; + case 7: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); + break; + case 8: + SetVBlankCallback(CB2_DiplomaOam); + break; + default: + if (gPaletteFade.active) + { + break; + } + PlayFanfareByFanfareNum(5); + gTasks[taskId].func = Task_WaitForExit; + } + gDiploma->callbackStep++; +} + +void Task_WaitForExit(u8 taskId) +{ + switch (gDiploma->state) + { + case 0: + if (WaitFanfare(0)) + { + gDiploma->state++; + } + break; + case 1: + if (JOY_NEW(A_BUTTON)) + { + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + gDiploma->state++; + } + break; + case 2: + Task_DiplomaReturnToOverworld(taskId); + break; + } +} + +void Task_DiplomaReturnToOverworld(u8 taskId) +{ + if (gPaletteFade.active) + return; + DestroyTask(taskId); + FreeAllWindowBuffers(); + FREE_AND_SET_NULL(gDiploma); + SetMainCallback2(sub_80568FC); +} + +void DiplomaBgInit(void) +{ + ResetSpriteData(); + ResetPaletteFade(); + FreeAllSpritePalettes(); + ResetTasks(); + ScanlineEffect_Stop(); +} + +void DiplomaVblankHandler(void) +{ + void *vram = (void *)VRAM; + DmaClearLarge16(3, vram, VRAM_SIZE, 0x1000); + DmaClear32(3, (void *)OAM, OAM_SIZE); + DmaClear16(3, (void *)PLTT, PLTT_SIZE); + SetGpuReg(REG_OFFSET_DISPCNT, 0); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_8415A08, 2); + ChangeBgX(0, 0, 0); + ChangeBgY(0, 0, 0); + ChangeBgX(1, 0, 0); + ChangeBgY(1, 0, 0); + ChangeBgX(2, 0, 0); + ChangeBgY(2, 0, 0); + ChangeBgX(3, 0, 0); + ChangeBgY(3, 0, 0); + InitWindows(gUnknown_8415A10); + DeactivateAllTextPrinters(); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); + SetBgTilemapBuffer(1, gDiploma->tilemapBuffer); + ShowBg(0); + ShowBg(1); + FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20); + FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, 30, 20); +} + +u8 DiplomaLoadGfx(void) +{ + switch (gDiploma->gfxStep) + { + case 0: + ResetTempTileDataBuffers(); + break; + case 1: + DecompressAndCopyTileDataToVram(1, gUnknown_84147C0, 0, 0, 0); + break; + case 2: + if (!(FreeTempTileDataBuffersIfPossible() == 1)) + { + break; + } + return 0; + case 3: + LoadPalette(gUnknown_8415954, 0, 0x40); + default: + return 1; + } + gDiploma->gfxStep++; + return 0; +} + +void DiplomaPrintText(void) +{ + u8 arr[160]; + uintptr_t len; + UnkTextUtil_Reset(); + UnkTextUtil_SetPtrI(0, gSaveBlock2Ptr->playerName); + if (sub_8088F84()) + { + UnkTextUtil_SetPtrI(1, gUnknown_841B68F); + } + else + { + UnkTextUtil_SetPtrI(1, gUnknown_841B698); + } + FillWindowPixelBuffer(0, 0); + UnkTextUtil_StringExpandPlaceholders(arr, gUnknown_841B60E); + len = (uintptr_t)GetStringWidth(2, arr, -1); + AddTextPrinterParameterized3(0, 2, 0x78 - (len / 2), 4, gUnknown_8415A04, -1, arr); + UnkTextUtil_StringExpandPlaceholders(arr, gUnknown_841B619); + len = (uintptr_t)GetStringWidth(2, arr, -1); + AddTextPrinterParameterized3(0, 0x2, 0x78 - (len / 2), 0x1E, gUnknown_8415A04, -1, arr); + AddTextPrinterParameterized3(0, 0x2, 0x78, 0x69, gUnknown_8415A04, 0, gUnknown_841B684); + PutWindowTilemap(0); +} -- cgit v1.2.3 From 2b92e8f9d4809d5dea009de5805bc1d8aa195f24 Mon Sep 17 00:00:00 2001 From: dheu Date: Mon, 8 Jul 2019 17:50:20 +0800 Subject: fix: ld_script.txt, tabs vs spaces & add: asmdiff.sh --- src/diploma.c | 224 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 112 insertions(+), 112 deletions(-) (limited to 'src') diff --git a/src/diploma.c b/src/diploma.c index cffbe8df1..056f23582 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -48,142 +48,142 @@ struct Diploma u8 state; u8 gfxStep; u8 callbackStep; - u8 padding; + u8 padding; u8 tilemapBuffer[0x1000]; } - *gDiploma = NULL; + *gDiploma = NULL; extern const u32 gUnknown_84154E8[]; void CB2_DiplomaOam(void) { - LoadOam(); - ProcessSpriteCopyRequests(); - TransferPlttBuffer(); + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); } void DiplomaInit(void) { - gDiploma = AllocZeroed(sizeof(*gDiploma)); - gDiploma->state = 0; - gDiploma->gfxStep = 0; - gDiploma->callbackStep = 0; - DiplomaBgInit(); - CreateTask(Task_DiplomaInit, 0); - SetMainCallback2(CB2_DiplomaInit); + gDiploma = AllocZeroed(sizeof(*gDiploma)); + gDiploma->state = 0; + gDiploma->gfxStep = 0; + gDiploma->callbackStep = 0; + DiplomaBgInit(); + CreateTask(Task_DiplomaInit, 0); + SetMainCallback2(CB2_DiplomaInit); } void CB2_DiplomaInit(void) { - RunTasks(); - AnimateSprites(); - BuildOamBuffer(); - UpdatePaletteFade(); + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); } void Task_DiplomaInit(u8 taskId) { - switch (gDiploma->callbackStep) - { - case 0: - SetVBlankCallback(NULL); - break; - case 1: - DiplomaVblankHandler(); - break; - case 2: - if (!DiplomaLoadGfx()) - { - return; - } - break; - case 3: - CopyToBgTilemapBuffer(1, gUnknown_84154E8, 0, 0); - break; - case 4: - if (sub_8088F84()) - { - SetGpuReg(REG_OFFSET_BG1HOFS, 0x80 << 1); - } - else - { - SetGpuReg(REG_OFFSET_BG1HOFS, 0); - } - break; - case 5: - DiplomaPrintText(); - break; - case 6: - CopyBgTilemapBufferToVram(0); - CopyBgTilemapBufferToVram(1); - break; - case 7: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); - break; - case 8: - SetVBlankCallback(CB2_DiplomaOam); - break; - default: - if (gPaletteFade.active) - { - break; - } - PlayFanfareByFanfareNum(5); - gTasks[taskId].func = Task_WaitForExit; - } - gDiploma->callbackStep++; + switch (gDiploma->callbackStep) + { + case 0: + SetVBlankCallback(NULL); + break; + case 1: + DiplomaVblankHandler(); + break; + case 2: + if (!DiplomaLoadGfx()) + { + return; + } + break; + case 3: + CopyToBgTilemapBuffer(1, gUnknown_84154E8, 0, 0); + break; + case 4: + if (sub_8088F84()) + { + SetGpuReg(REG_OFFSET_BG1HOFS, 0x80 << 1); + } + else + { + SetGpuReg(REG_OFFSET_BG1HOFS, 0); + } + break; + case 5: + DiplomaPrintText(); + break; + case 6: + CopyBgTilemapBufferToVram(0); + CopyBgTilemapBufferToVram(1); + break; + case 7: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); + break; + case 8: + SetVBlankCallback(CB2_DiplomaOam); + break; + default: + if (gPaletteFade.active) + { + break; + } + PlayFanfareByFanfareNum(5); + gTasks[taskId].func = Task_WaitForExit; + } + gDiploma->callbackStep++; } void Task_WaitForExit(u8 taskId) { switch (gDiploma->state) - { + { case 0: if (WaitFanfare(0)) - { - gDiploma->state++; - } + { + gDiploma->state++; + } break; case 1: if (JOY_NEW(A_BUTTON)) - { + { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gDiploma->state++; - } - break; + gDiploma->state++; + } + break; case 2: Task_DiplomaReturnToOverworld(taskId); - break; + break; } } void Task_DiplomaReturnToOverworld(u8 taskId) { - if (gPaletteFade.active) - return; - DestroyTask(taskId); - FreeAllWindowBuffers(); - FREE_AND_SET_NULL(gDiploma); - SetMainCallback2(sub_80568FC); + if (gPaletteFade.active) + return; + DestroyTask(taskId); + FreeAllWindowBuffers(); + FREE_AND_SET_NULL(gDiploma); + SetMainCallback2(sub_80568FC); } void DiplomaBgInit(void) { - ResetSpriteData(); - ResetPaletteFade(); - FreeAllSpritePalettes(); - ResetTasks(); - ScanlineEffect_Stop(); + ResetSpriteData(); + ResetPaletteFade(); + FreeAllSpritePalettes(); + ResetTasks(); + ScanlineEffect_Stop(); } void DiplomaVblankHandler(void) { - void *vram = (void *)VRAM; + void *vram = (void *)VRAM; DmaClearLarge16(3, vram, VRAM_SIZE, 0x1000); DmaClear32(3, (void *)OAM, OAM_SIZE); DmaClear16(3, (void *)PLTT, PLTT_SIZE); SetGpuReg(REG_OFFSET_DISPCNT, 0); - ResetBgsAndClearDma3BusyFlags(0); + ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, gUnknown_8415A08, 2); ChangeBgX(0, 0, 0); ChangeBgY(0, 0, 0); @@ -193,10 +193,10 @@ void DiplomaVblankHandler(void) ChangeBgY(2, 0, 0); ChangeBgX(3, 0, 0); ChangeBgY(3, 0, 0); - InitWindows(gUnknown_8415A10); - DeactivateAllTextPrinters(); - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); - SetBgTilemapBuffer(1, gDiploma->tilemapBuffer); + InitWindows(gUnknown_8415A10); + DeactivateAllTextPrinters(); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); + SetBgTilemapBuffer(1, gDiploma->tilemapBuffer); ShowBg(0); ShowBg(1); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20); @@ -205,27 +205,27 @@ void DiplomaVblankHandler(void) u8 DiplomaLoadGfx(void) { - switch (gDiploma->gfxStep) - { - case 0: - ResetTempTileDataBuffers(); - break; - case 1: - DecompressAndCopyTileDataToVram(1, gUnknown_84147C0, 0, 0, 0); - break; - case 2: - if (!(FreeTempTileDataBuffersIfPossible() == 1)) - { - break; - } - return 0; - case 3: - LoadPalette(gUnknown_8415954, 0, 0x40); - default: - return 1; - } - gDiploma->gfxStep++; - return 0; + switch (gDiploma->gfxStep) + { + case 0: + ResetTempTileDataBuffers(); + break; + case 1: + DecompressAndCopyTileDataToVram(1, gUnknown_84147C0, 0, 0, 0); + break; + case 2: + if (!(FreeTempTileDataBuffersIfPossible() == 1)) + { + break; + } + return 0; + case 3: + LoadPalette(gUnknown_8415954, 0, 0x40); + default: + return 1; + } + gDiploma->gfxStep++; + return 0; } void DiplomaPrintText(void) -- cgit v1.2.3 From 1a0186c3f692e5e07ef553e3292d9ca76c15a899 Mon Sep 17 00:00:00 2001 From: dheu Date: Mon, 8 Jul 2019 18:20:14 +0800 Subject: fix: diploma.c static --- src/diploma.c | 188 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 94 insertions(+), 94 deletions(-) (limited to 'src') diff --git a/src/diploma.c b/src/diploma.c index 056f23582..9f30e50f2 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -1,3 +1,4 @@ +#include "constants/fanfares.h" #include "gba/macro.h" #include "global.h" #include "gpu_regs.h" @@ -20,16 +21,16 @@ void sub_80568FC(void); u16 sub_8088F84(void); -void DiplomaBgInit(void); -void DiplomaPrintText(void); -u8 DiplomaLoadGfx(void); -void DiplomaVblankHandler(void); +static void DiplomaBgInit(void); +static void DiplomaPrintText(void); +static u8 DiplomaLoadGfx(void); +static void DiplomaVblankHandler(void); -void CB2_DiplomaInit(void); +static void CB2_DiplomaInit(void); -void Task_WaitForExit(u8); -void Task_DiplomaInit(u8); -void Task_DiplomaReturnToOverworld(u8); +static void Task_WaitForExit(u8); +static void Task_DiplomaInit(u8); +static void Task_DiplomaReturnToOverworld(u8); extern const struct BgTemplate gUnknown_8415A08[2]; extern const struct WindowTemplate gUnknown_8415A10[]; @@ -48,14 +49,13 @@ struct Diploma u8 state; u8 gfxStep; u8 callbackStep; - u8 padding; - u8 tilemapBuffer[0x1000]; + u16 tilemapBuffer[0x800]; } *gDiploma = NULL; extern const u32 gUnknown_84154E8[]; -void CB2_DiplomaOam(void) +static void CB2_DiplomaOam(void) { LoadOam(); ProcessSpriteCopyRequests(); @@ -73,7 +73,7 @@ void DiplomaInit(void) SetMainCallback2(CB2_DiplomaInit); } -void CB2_DiplomaInit(void) +static void CB2_DiplomaInit(void) { RunTasks(); AnimateSprites(); @@ -81,83 +81,83 @@ void CB2_DiplomaInit(void) UpdatePaletteFade(); } -void Task_DiplomaInit(u8 taskId) +static void Task_DiplomaInit(u8 taskId) { switch (gDiploma->callbackStep) { - case 0: - SetVBlankCallback(NULL); + case 0: + SetVBlankCallback(NULL); + break; + case 1: + DiplomaVblankHandler(); + break; + case 2: + if (!DiplomaLoadGfx()) + { + return; + } + break; + case 3: + CopyToBgTilemapBuffer(1, gUnknown_84154E8, 0, 0); + break; + case 4: + if (sub_8088F84()) + { + SetGpuReg(REG_OFFSET_BG1HOFS, 0x80 << 1); + } + else + { + SetGpuReg(REG_OFFSET_BG1HOFS, 0); + } + break; + case 5: + DiplomaPrintText(); + break; + case 6: + CopyBgTilemapBufferToVram(0); + CopyBgTilemapBufferToVram(1); + break; + case 7: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); + break; + case 8: + SetVBlankCallback(CB2_DiplomaOam); + break; + default: + if (gPaletteFade.active) + { break; - case 1: - DiplomaVblankHandler(); - break; - case 2: - if (!DiplomaLoadGfx()) - { - return; - } - break; - case 3: - CopyToBgTilemapBuffer(1, gUnknown_84154E8, 0, 0); - break; - case 4: - if (sub_8088F84()) - { - SetGpuReg(REG_OFFSET_BG1HOFS, 0x80 << 1); - } - else - { - SetGpuReg(REG_OFFSET_BG1HOFS, 0); - } - break; - case 5: - DiplomaPrintText(); - break; - case 6: - CopyBgTilemapBufferToVram(0); - CopyBgTilemapBufferToVram(1); - break; - case 7: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); - break; - case 8: - SetVBlankCallback(CB2_DiplomaOam); - break; - default: - if (gPaletteFade.active) - { - break; - } - PlayFanfareByFanfareNum(5); - gTasks[taskId].func = Task_WaitForExit; + } + PlayFanfareByFanfareNum(FANFARE_05); + gTasks[taskId].func = Task_WaitForExit; } gDiploma->callbackStep++; } -void Task_WaitForExit(u8 taskId) +static void Task_WaitForExit(u8 taskId) { switch (gDiploma->state) { - case 0: - if (WaitFanfare(0)) - { - gDiploma->state++; - } - break; - case 1: - if (JOY_NEW(A_BUTTON)) - { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gDiploma->state++; - } - break; - case 2: - Task_DiplomaReturnToOverworld(taskId); - break; + case 0: + if (WaitFanfare(0)) + { + gDiploma->state++; + } + break; + case 1: + if (JOY_NEW(A_BUTTON)) + { + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + gDiploma->state++; + } + break; + case 2: + Task_DiplomaReturnToOverworld(taskId); + break; } } -void Task_DiplomaReturnToOverworld(u8 taskId) +static void Task_DiplomaReturnToOverworld(u8 taskId) { if (gPaletteFade.active) return; @@ -167,7 +167,7 @@ void Task_DiplomaReturnToOverworld(u8 taskId) SetMainCallback2(sub_80568FC); } -void DiplomaBgInit(void) +static void DiplomaBgInit(void) { ResetSpriteData(); ResetPaletteFade(); @@ -176,7 +176,7 @@ void DiplomaBgInit(void) ScanlineEffect_Stop(); } -void DiplomaVblankHandler(void) +static void DiplomaVblankHandler(void) { void *vram = (void *)VRAM; DmaClearLarge16(3, vram, VRAM_SIZE, 0x1000); @@ -203,32 +203,32 @@ void DiplomaVblankHandler(void) FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, 30, 20); } -u8 DiplomaLoadGfx(void) +static u8 DiplomaLoadGfx(void) { switch (gDiploma->gfxStep) { - case 0: - ResetTempTileDataBuffers(); - break; - case 1: - DecompressAndCopyTileDataToVram(1, gUnknown_84147C0, 0, 0, 0); + case 0: + ResetTempTileDataBuffers(); + break; + case 1: + DecompressAndCopyTileDataToVram(1, gUnknown_84147C0, 0, 0, 0); + break; + case 2: + if (!(FreeTempTileDataBuffersIfPossible() == 1)) + { break; - case 2: - if (!(FreeTempTileDataBuffersIfPossible() == 1)) - { - break; - } - return 0; - case 3: - LoadPalette(gUnknown_8415954, 0, 0x40); - default: - return 1; + } + return 0; + case 3: + LoadPalette(gUnknown_8415954, 0, 0x40); + default: + return 1; } gDiploma->gfxStep++; return 0; } -void DiplomaPrintText(void) +static void DiplomaPrintText(void) { u8 arr[160]; uintptr_t len; -- cgit v1.2.3 From cc77a3ecbf453ed38ec2fcddae0ad506182b10d9 Mon Sep 17 00:00:00 2001 From: dheu Date: Mon, 8 Jul 2019 18:39:12 +0800 Subject: fix: ewram --- src/diploma.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/diploma.c b/src/diploma.c index 9f30e50f2..60a6d2fba 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -50,8 +50,9 @@ struct Diploma u8 gfxStep; u8 callbackStep; u16 tilemapBuffer[0x800]; -} - *gDiploma = NULL; +}; + +static EWRAM_DATA struct Diploma *gDiploma = NULL; extern const u32 gUnknown_84154E8[]; -- cgit v1.2.3 From 23a05eb6ac4118cb928d095a4f0c649d5f0bd3b0 Mon Sep 17 00:00:00 2001 From: dheu Date: Mon, 8 Jul 2019 19:02:28 +0800 Subject: fix: more fixes --- src/diploma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/diploma.c b/src/diploma.c index 60a6d2fba..1c3755526 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -56,14 +56,14 @@ static EWRAM_DATA struct Diploma *gDiploma = NULL; extern const u32 gUnknown_84154E8[]; -static void CB2_DiplomaOam(void) +static void VCBC_DiplomaOam(void) { LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); } -void DiplomaInit(void) +void CB2_ShowDiploma(void) { gDiploma = AllocZeroed(sizeof(*gDiploma)); gDiploma->state = 0; @@ -122,7 +122,7 @@ static void Task_DiplomaInit(u8 taskId) BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); break; case 8: - SetVBlankCallback(CB2_DiplomaOam); + SetVBlankCallback(VCBC_DiplomaOam); break; default: if (gPaletteFade.active) -- cgit v1.2.3 From 56b5fffe9d1252b6c94180dd5d49c7ebafede30c Mon Sep 17 00:00:00 2001 From: dheu Date: Mon, 8 Jul 2019 19:58:36 +0800 Subject: fix: move/rename declarations --- src/diploma.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/diploma.c b/src/diploma.c index 1c3755526..2fade0dcf 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -4,6 +4,7 @@ #include "gpu_regs.h" #include "window.h" #include "main.h" +#include "overworld.h" #include "scanline_effect.h" #include "task.h" #include "unk_text_util.h" @@ -12,15 +13,13 @@ #include "bg.h" #include "sound.h" #include "malloc.h" +#include "pokedex.h" #include "sprite.h" #include "palette.h" #include "new_menu_helpers.h" #include "menu.h" #include "diploma.h" -void sub_80568FC(void); -u16 sub_8088F84(void); - static void DiplomaBgInit(void); static void DiplomaPrintText(void); static u8 DiplomaLoadGfx(void); @@ -102,7 +101,7 @@ static void Task_DiplomaInit(u8 taskId) CopyToBgTilemapBuffer(1, gUnknown_84154E8, 0, 0); break; case 4: - if (sub_8088F84()) + if (HasAllKantoMons()) { SetGpuReg(REG_OFFSET_BG1HOFS, 0x80 << 1); } @@ -165,7 +164,7 @@ static void Task_DiplomaReturnToOverworld(u8 taskId) DestroyTask(taskId); FreeAllWindowBuffers(); FREE_AND_SET_NULL(gDiploma); - SetMainCallback2(sub_80568FC); + SetMainCallback2(CB2_Overworld); } static void DiplomaBgInit(void) @@ -232,10 +231,10 @@ static u8 DiplomaLoadGfx(void) static void DiplomaPrintText(void) { u8 arr[160]; - uintptr_t len; + u32 width; UnkTextUtil_Reset(); UnkTextUtil_SetPtrI(0, gSaveBlock2Ptr->playerName); - if (sub_8088F84()) + if (HasAllKantoMons()) { UnkTextUtil_SetPtrI(1, gUnknown_841B68F); } @@ -245,11 +244,11 @@ static void DiplomaPrintText(void) } FillWindowPixelBuffer(0, 0); UnkTextUtil_StringExpandPlaceholders(arr, gUnknown_841B60E); - len = (uintptr_t)GetStringWidth(2, arr, -1); - AddTextPrinterParameterized3(0, 2, 0x78 - (len / 2), 4, gUnknown_8415A04, -1, arr); + width = GetStringWidth(2, arr, -1); + AddTextPrinterParameterized3(0, 2, 0x78 - (width / 2), 4, gUnknown_8415A04, -1, arr); UnkTextUtil_StringExpandPlaceholders(arr, gUnknown_841B619); - len = (uintptr_t)GetStringWidth(2, arr, -1); - AddTextPrinterParameterized3(0, 0x2, 0x78 - (len / 2), 0x1E, gUnknown_8415A04, -1, arr); + width = GetStringWidth(2, arr, -1); + AddTextPrinterParameterized3(0, 0x2, 0x78 - (width / 2), 0x1E, gUnknown_8415A04, -1, arr); AddTextPrinterParameterized3(0, 0x2, 0x78, 0x69, gUnknown_8415A04, 0, gUnknown_841B684); PutWindowTilemap(0); } -- cgit v1.2.3 From 185cd074035c41d4550a150139b1eeb34541ace8 Mon Sep 17 00:00:00 2001 From: dheu Date: Thu, 11 Jul 2019 05:47:57 +0800 Subject: fix: renamed UnkTextUtil to DynamicPlaceholder versoins --- src/diploma.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/diploma.c b/src/diploma.c index 2fade0dcf..74343e82f 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -1,23 +1,23 @@ +#include "global.h" +#include "bg.h" #include "constants/fanfares.h" +#include "dynamic_placeholder_text_util.h" #include "gba/macro.h" -#include "global.h" #include "gpu_regs.h" -#include "window.h" +#include "gpu_regs.h" #include "main.h" +#include "malloc.h" +#include "menu.h" +#include "new_menu_helpers.h" #include "overworld.h" +#include "palette.h" +#include "pokedex.h" #include "scanline_effect.h" -#include "task.h" -#include "unk_text_util.h" -#include "gpu_regs.h" -#include "text.h" -#include "bg.h" #include "sound.h" -#include "malloc.h" -#include "pokedex.h" #include "sprite.h" -#include "palette.h" -#include "new_menu_helpers.h" -#include "menu.h" +#include "task.h" +#include "text.h" +#include "window.h" #include "diploma.h" static void DiplomaBgInit(void); @@ -232,21 +232,21 @@ static void DiplomaPrintText(void) { u8 arr[160]; u32 width; - UnkTextUtil_Reset(); - UnkTextUtil_SetPtrI(0, gSaveBlock2Ptr->playerName); + DynamicPlaceholderTextUtil_Reset(); + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gSaveBlock2Ptr->playerName); if (HasAllKantoMons()) { - UnkTextUtil_SetPtrI(1, gUnknown_841B68F); + DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, gUnknown_841B68F); } else { - UnkTextUtil_SetPtrI(1, gUnknown_841B698); + DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, gUnknown_841B698); } FillWindowPixelBuffer(0, 0); - UnkTextUtil_StringExpandPlaceholders(arr, gUnknown_841B60E); + DynamicPlaceholderTextUtil_ExpandPlaceholders(arr, gUnknown_841B60E); width = GetStringWidth(2, arr, -1); AddTextPrinterParameterized3(0, 2, 0x78 - (width / 2), 4, gUnknown_8415A04, -1, arr); - UnkTextUtil_StringExpandPlaceholders(arr, gUnknown_841B619); + DynamicPlaceholderTextUtil_ExpandPlaceholders(arr, gUnknown_841B619); width = GetStringWidth(2, arr, -1); AddTextPrinterParameterized3(0, 0x2, 0x78 - (width / 2), 0x1E, gUnknown_8415A04, -1, arr); AddTextPrinterParameterized3(0, 0x2, 0x78, 0x69, gUnknown_8415A04, 0, gUnknown_841B684); -- 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/bag.c | 10 +- src/berry_powder.c | 4 +- src/buy_menu_helpers.c | 4 +- src/coins.c | 6 +- src/fldeff_softboiled.c | 2 +- src/item_pc.c | 20 +- src/menu.c | 984 ++++++++++++++++++++++++++++++++++++++++++++++++ src/money.c | 4 +- src/new_menu_helpers.c | 2 +- src/oak_speech.c | 38 +- src/tm_case.c | 36 +- src/trainer_tower.c | 2 +- 12 files changed, 1048 insertions(+), 64 deletions(-) create mode 100644 src/menu.c (limited to 'src') diff --git a/src/bag.c b/src/bag.c index f4d29dfd4..710515099 100644 --- a/src/bag.c +++ b/src/bag.c @@ -240,7 +240,7 @@ void sub_810B958(const u8 * str) void sub_810B994(void) { u32 x; - SetWindowBorderStyle(2, FALSE, 0x081, 0x0C); + DrawStdFrameWithCustomTileAndPalette(2, FALSE, 0x081, 0x0C); x = 0x40 - GetStringWidth(0, gText_DepositItem, 0); AddTextPrinterParameterized(2, 0, gText_DepositItem, x / 2, 1, 0, NULL); } @@ -252,11 +252,11 @@ u8 sub_810B9DC(u8 a0, u8 a1) gUnknown_203AD34[a0] = AddWindow(&gUnknown_8453104[a0 + a1]); if (a0 != 6) { - SetWindowBorderStyle(gUnknown_203AD34[a0], FALSE, 0x064, 0x0E); + DrawStdFrameWithCustomTileAndPalette(gUnknown_203AD34[a0], FALSE, 0x064, 0x0E); } else { - SetWindowBorderStyle(gUnknown_203AD34[a0], FALSE, 0x081, 0x0C); + DrawStdFrameWithCustomTileAndPalette(gUnknown_203AD34[a0], FALSE, 0x081, 0x0C); } ScheduleBgCopyTilemapToVram(0); } @@ -265,7 +265,7 @@ u8 sub_810B9DC(u8 a0, u8 a1) void sub_810BA3C(u8 a0) { - ClearMenuWindow(gUnknown_203AD34[a0], FALSE); + ClearStdWindowAndFrameToTransparent(gUnknown_203AD34[a0], FALSE); ClearWindowTilemap(gUnknown_203AD34[a0]); RemoveWindow(gUnknown_203AD34[a0]); ScheduleBgCopyTilemapToVram(0); @@ -285,7 +285,7 @@ void sub_810BA9C(u8 a0) { if (gUnknown_203AD34[a0] != 0xFF) { - ClearMenuWindow_BorderThickness2(gUnknown_203AD34[a0], FALSE); + ClearDialogWindowAndFrameToTransparent(gUnknown_203AD34[a0], FALSE); ClearWindowTilemap(gUnknown_203AD34[a0]); RemoveWindow(gUnknown_203AD34[a0]); PutWindowTilemap(1); diff --git a/src/berry_powder.c b/src/berry_powder.c index b3069d697..9b50d6abc 100644 --- a/src/berry_powder.c +++ b/src/berry_powder.c @@ -97,7 +97,7 @@ void sub_815EFBC(u8 windowId, u32 powder, u8 x, u8 y, u8 speed) void sub_815F014(u8 windowId, u16 baseBlock, u8 palette, u32 powder) { - SetWindowBorderStyle(windowId, FALSE, baseBlock, palette); + DrawStdFrameWithCustomTileAndPalette(windowId, FALSE, baseBlock, palette); AddTextPrinterParameterized(windowId, 0, gOtherText_Powder, 0, 0, -1, NULL); sub_815EFBC(windowId, powder, 39, 12, 0); } @@ -127,6 +127,6 @@ void sub_815F094(void) void sub_815F114(void) { ClearWindowTilemap(gUnknown_203F464); - ClearMenuWindow(gUnknown_203F464, 1); + ClearStdWindowAndFrameToTransparent(gUnknown_203F464, 1); RemoveWindow(gUnknown_203F464); } diff --git a/src/buy_menu_helpers.c b/src/buy_menu_helpers.c index 4febb8209..4cdf90e4e 100644 --- a/src/buy_menu_helpers.c +++ b/src/buy_menu_helpers.c @@ -202,12 +202,12 @@ void BuyMenuDisplayMessage(u8 taskId, const u8 *text, TaskFunc callback) void BuyMenuQuantityBoxNormalBorder(u8 windowId, bool8 copyToVram) { - SetWindowBorderStyle(windowId, copyToVram, 0x1, 0xD); + DrawStdFrameWithCustomTileAndPalette(windowId, copyToVram, 0x1, 0xD); } void BuyMenuQuantityBoxThinBorder(u8 windowId, bool8 copyToVram) { - SetWindowBorderStyle(windowId, copyToVram, 0xA, 0xF); + DrawStdFrameWithCustomTileAndPalette(windowId, copyToVram, 0xA, 0xF); } void BuyMenuConfirmPurchase(u8 taskId, const struct YesNoFuncTable *yesNo) diff --git a/src/coins.c b/src/coins.c index 3a51f6813..a3c074b7c 100644 --- a/src/coins.c +++ b/src/coins.c @@ -61,7 +61,7 @@ void PrintCoinsString_Parameterized(u8 windowId, u32 coinAmount, u8 x, u8 y, u8 void sub_80D0674(u8 windowId, u16 tileStart, u8 palette, u32 coinAmount) { - SetWindowBorderStyle(windowId, FALSE, tileStart, palette); + DrawStdFrameWithCustomTileAndPalette(windowId, FALSE, tileStart, palette); AddTextPrinterParameterized(windowId, 2, gUnknown_8417C2D, 0, 0, 0xFF, 0); PrintCoinsString_Parameterized(windowId, coinAmount, 0x10, 0xC, 0); } @@ -88,7 +88,7 @@ void ShowCoinsWindow(u32 coinAmount, u8 x, u8 y) FillWindowPixelBuffer(sCoinsWindowId, 0); PutWindowTilemap(sCoinsWindowId); TextWindow_SetStdFrame0_WithPal(sCoinsWindowId, 0x21D, 0xD0); - SetWindowBorderStyle(sCoinsWindowId, FALSE, 0x21D, 0xD); + DrawStdFrameWithCustomTileAndPalette(sCoinsWindowId, FALSE, 0x21D, 0xD); AddTextPrinterParameterized(sCoinsWindowId, 2, gUnknown_8417C2D, 0, 0, 0xFF, 0); PrintCoinsString(coinAmount); } @@ -96,6 +96,6 @@ void ShowCoinsWindow(u32 coinAmount, u8 x, u8 y) void HideCoinsWindow(void) { ClearWindowTilemap(sCoinsWindowId); - ClearMenuWindow(sCoinsWindowId, TRUE); + ClearStdWindowAndFrameToTransparent(sCoinsWindowId, TRUE); RemoveWindow(sCoinsWindowId); } diff --git a/src/fldeff_softboiled.c b/src/fldeff_softboiled.c index 2a3d68e70..67000e315 100644 --- a/src/fldeff_softboiled.c +++ b/src/fldeff_softboiled.c @@ -85,7 +85,7 @@ static void sub_80E58A0(u8 taskId) sub_811F818(gUnknown_203B0A0.unk9, 0); gUnknown_203B0A0.unk9 = gUnknown_203B0A0.unkA; sub_811F818(gUnknown_203B0A0.unkA, 1); - ClearMenuWindow(6, 0); + ClearStdWindowAndFrameToTransparent(6, 0); ClearWindowTilemap(6); sub_8121D0C(0); gTasks[taskId].func = sub_811FB28; diff --git a/src/item_pc.c b/src/item_pc.c index abafaa8d9..8f1fd1cbf 100644 --- a/src/item_pc.c +++ b/src/item_pc.c @@ -845,7 +845,7 @@ static void Task_ItemPcSubmenuInit(u8 taskId) ItemPc_SetBorderStyleOnWindow(4); windowId = ItemPc_GetOrCreateSubwindow(0); PrintTextArray(4, 2, 8, 2, GetFontAttribute(2, FONTATTR_MAX_LETTER_HEIGHT) + 2, 3, sItemPcSubmenuOptions); - ProgramAndPlaceMenuCursorOnWindow(4, 2, 0, 2, GetFontAttribute(2, FONTATTR_MAX_LETTER_HEIGHT) + 2, 3, 0); + Menu_InitCursor(4, 2, 0, 2, GetFontAttribute(2, FONTATTR_MAX_LETTER_HEIGHT) + 2, 3, 0); CopyItemName(ItemPc_GetItemIdBySlotId(data[1]), gStringVar1); StringExpandPlaceholders(gStringVar4, gOtherText_StrVar1); ItemPc_AddTextPrinterParameterized(windowId, 2, gStringVar4, 0, 2, 1, 0, 0, 1); @@ -855,7 +855,7 @@ static void Task_ItemPcSubmenuInit(u8 taskId) static void Task_ItemPcSubmenuRun(u8 taskId) { - s8 input = ProcessMenuInputNoWrapAround(); + s8 input = Menu_ProcessInputNoWrapAround(); switch (input) { case -1: @@ -874,7 +874,7 @@ static void Task_ItemPcWithdraw(u8 taskId) { s16 * data = gTasks[taskId].data; - ClearMenuWindow(4, FALSE); + ClearStdWindowAndFrameToTransparent(4, FALSE); ItemPc_DestroySubwindow(0); ClearWindowTilemap(4); data[8] = 1; @@ -998,7 +998,7 @@ static void Task_ItemPcHandleWithdrawMultiple(u8 taskId) else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); - ClearMenuWindow(3, FALSE); + ClearStdWindowAndFrameToTransparent(3, FALSE); ItemPc_DestroySubwindow(1); ClearWindowTilemap(3); PutWindowTilemap(0); @@ -1014,7 +1014,7 @@ static void Task_ItemPcGive(u8 taskId) { if (CalculatePlayerPartyCount() == 0) { - ClearMenuWindow(4, FALSE); + ClearStdWindowAndFrameToTransparent(4, FALSE); ItemPc_DestroySubwindow(0); ClearWindowTilemap(4); PutWindowTilemap(0); @@ -1045,7 +1045,7 @@ static void gTask_ItemPcWaitButtonAndExitSubmenu(u8 taskId) if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); - ClearMenuWindow_BorderThickness2(5, 0); + ClearDialogWindowAndFrameToTransparent(5, 0); ClearWindowTilemap(5); PutWindowTilemap(1); ItemPc_PrintOrRemoveCursor(data[0], 1); @@ -1058,7 +1058,7 @@ static void Task_ItemPcCancel(u8 taskId) { s16 * data = gTasks[taskId].data; - ClearMenuWindow(4, FALSE); + ClearStdWindowAndFrameToTransparent(4, FALSE); ItemPc_DestroySubwindow(0); ClearWindowTilemap(4); PutWindowTilemap(0); @@ -1116,7 +1116,7 @@ static void ItemPc_AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 static void ItemPc_SetBorderStyleOnWindow(u8 windowId) { - SetWindowBorderStyle(windowId, FALSE, 0x3C0, 0x0E); + DrawStdFrameWithCustomTileAndPalette(windowId, FALSE, 0x3C0, 0x0E); } static u8 ItemPc_GetOrCreateSubwindow(u8 idx) @@ -1124,7 +1124,7 @@ static u8 ItemPc_GetOrCreateSubwindow(u8 idx) if (sSubmenuWindowIds[idx] == 0xFF) { sSubmenuWindowIds[idx] = AddWindow(&gUnknown_8453FD0[idx]); - SetWindowBorderStyle(sSubmenuWindowIds[idx], TRUE, 0x3A3, 0x0C); + DrawStdFrameWithCustomTileAndPalette(sSubmenuWindowIds[idx], TRUE, 0x3A3, 0x0C); } return sSubmenuWindowIds[idx]; @@ -1132,7 +1132,7 @@ static u8 ItemPc_GetOrCreateSubwindow(u8 idx) static void ItemPc_DestroySubwindow(u8 idx) { - ClearMenuWindow(sSubmenuWindowIds[idx], FALSE); + ClearStdWindowAndFrameToTransparent(sSubmenuWindowIds[idx], FALSE); ClearWindowTilemap(sSubmenuWindowIds[idx]); // redundant RemoveWindow(sSubmenuWindowIds[idx]); sSubmenuWindowIds[idx] = 0xFF; diff --git a/src/menu.c b/src/menu.c new file mode 100644 index 000000000..ac2e0160b --- /dev/null +++ b/src/menu.c @@ -0,0 +1,984 @@ +#include "global.h" +#include "bg.h" +#include "malloc.h" +#include "menu.h" +#include "menu_helpers.h" +#include "new_menu_helpers.h" +#include "string_util.h" +#include "strings.h" +#include "task.h" +#include "text_window.h" +#include "window.h" +#include "sound.h" +#include "palette.h" +#include "constants/songs.h" + +struct Menu +{ + u8 left; + u8 top; + s8 cursorPos; + s8 minCursorPos; + s8 maxCursorPos; + u8 windowId; + u8 fontId; + u8 optionWidth; + u8 optionHeight; + u8 columns; + u8 rows; + bool8 APressMuted; +}; + +static EWRAM_DATA struct Menu sMenu = {0}; +static EWRAM_DATA u16 sTileNum = 0; +static EWRAM_DATA u8 sPaletteNum = 0; +static EWRAM_DATA u8 sYesNoWindowId = 0; +static EWRAM_DATA u8 sTopBarWindowId = 0; + +static const struct TextColor gUnknown_8456618 = +{ + .fgColor = 15, + .bgColor = 1, + .shadowColor = 2, +}; + +static void WindowFunc_DrawDialogFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); +static void WindowFunc_ClearDialogWindowAndFrameNullPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); +static void WindowFunc_DrawStdFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); +static void WindowFunc_ClearStdWindowAndFrameToTransparent(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); +static u8 MultichoiceGridComputeNewCursorPos(s8 deltaX, s8 deltaY); +u8 Menu_MoveCursor(s8 cursorDelta); +void DestroyYesNoMenu(void); + +void DrawDialogFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 tileNum, u8 paletteNum) +{ + sTileNum = tileNum; + sPaletteNum = paletteNum; + CallWindowFunction(windowId, WindowFunc_DrawDialogFrameWithCustomTileAndPalette); + FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); + PutWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +// not used +static void DrawDialogFrameWithCustomTile(u8 windowId, bool8 copyToVram, u16 tileNum) +{ + sTileNum = tileNum; + sPaletteNum = GetWindowAttribute(windowId, WINDOW_PALETTE_NUM); + CallWindowFunction(windowId, WindowFunc_DrawDialogFrameWithCustomTileAndPalette); + FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); + PutWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +static void WindowFunc_DrawDialogFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + FillBgTilemapBufferRect(bg, sTileNum, tilemapLeft - 2, tilemapTop - 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 1, tilemapLeft - 1, tilemapTop - 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 2, tilemapLeft, tilemapTop - 1, width, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 3, tilemapLeft + width, tilemapTop - 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 4, tilemapLeft + width + 1, tilemapTop - 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 5, tilemapLeft - 2, tilemapTop, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 6, tilemapLeft - 1, tilemapTop, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 8, tilemapLeft + width, tilemapTop, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 9, tilemapLeft + width + 1, tilemapTop, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 10, tilemapLeft - 2, tilemapTop + 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 11, tilemapLeft - 1, tilemapTop + 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 12, tilemapLeft + width, tilemapTop + 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 13, tilemapLeft + width + 1, tilemapTop + 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 10), tilemapLeft - 2, tilemapTop + 2, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 11), tilemapLeft - 1, tilemapTop + 2, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 12), tilemapLeft + width, tilemapTop + 2, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 13), tilemapLeft + width + 1, tilemapTop + 2, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 5), tilemapLeft - 2, tilemapTop + 3, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 6), tilemapLeft - 1, tilemapTop + 3, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 8), tilemapLeft + width, tilemapTop + 3, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 9), tilemapLeft + width + 1, tilemapTop + 3, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum), tilemapLeft - 2, tilemapTop + 4, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 1), tilemapLeft - 1, tilemapTop + 4, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 2), tilemapLeft, tilemapTop + 4, width, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 3), tilemapLeft + width, tilemapTop + 4, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 4), tilemapLeft + width + 1, tilemapTop + 4, 1, 1, sPaletteNum); +} + +void ClearDialogWindowAndFrameToTransparent(u8 windowId, bool8 copyToVram) +{ + // The palette slot doesn't matter, since the tiles are transparent. + CallWindowFunction(windowId, WindowFunc_ClearDialogWindowAndFrameNullPalette); + FillWindowPixelBuffer(windowId, PIXEL_FILL(0)); + ClearWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +static void WindowFunc_ClearDialogWindowAndFrameNullPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + FillBgTilemapBufferRect(bg, 0, tilemapLeft - 2, tilemapTop - 1, width + 4, height + 2, 0); +} + +void DrawStdFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 baseTileNum, u8 paletteNum) +{ + sTileNum = baseTileNum; + sPaletteNum = paletteNum; + CallWindowFunction(windowId, WindowFunc_DrawStdFrameWithCustomTileAndPalette); + FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); + PutWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +// not used +static void DrawStdFrameWithCustomTile(u8 windowId, bool8 copyToVram, u16 baseTileNum) +{ + sTileNum = baseTileNum; + sPaletteNum = GetWindowAttribute(windowId, WINDOW_PALETTE_NUM); + CallWindowFunction(windowId, WindowFunc_DrawStdFrameWithCustomTileAndPalette); + FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); + PutWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +static void WindowFunc_DrawStdFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + FillBgTilemapBufferRect(bg, sTileNum, tilemapLeft - 1, tilemapTop - 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 1, tilemapLeft, tilemapTop - 1, width, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 2, tilemapLeft + width, tilemapTop - 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 3, tilemapLeft - 1, tilemapTop, 1, height, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 5, tilemapLeft + width, tilemapTop, 1, height, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 6, tilemapLeft - 1, tilemapTop + height, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 7, tilemapLeft, tilemapTop + height, width, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 8, tilemapLeft + width, tilemapTop + height, 1, 1, sPaletteNum); +} + +void ClearStdWindowAndFrameToTransparent(u8 windowId, bool8 copyToVram) +{ + CallWindowFunction(windowId, WindowFunc_ClearStdWindowAndFrameToTransparent); + FillWindowPixelBuffer(windowId, PIXEL_FILL(0)); + ClearWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +static void WindowFunc_ClearStdWindowAndFrameToTransparent(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + FillBgTilemapBufferRect(bg, 0, tilemapLeft - 1, tilemapTop - 1, width + 2, height + 2, 0); +} + +/* + The following functions are used for handling top bar window + in hall of fame screen and story mode screen before oak intro. + However, you can still designate a yPos value to place that bar + as well as the bar width. + The xPos is simply computed according to width (always right aligned). +*/ +u8 CreateTopBarWindowLoadPalette(u8 bg, u8 width, u8 yPos, u8 palette, u16 baseTile) +{ + struct WindowTemplate window; + + memset(&window, 0, sizeof(window)); + if (bg > 3) + window.bg = 0; + else + window.bg = bg; + window.tilemapTop = yPos; + window.height = 2; + window.tilemapLeft = 0x1E - width; + window.width = width; + window.paletteNum = palette; + window.baseBlock = baseTile; + sTopBarWindowId = AddWindow(&window); + if (palette > 15) + palette = 15 * 16; + else + palette *= 16; + LoadPalette(stdpal_get(2), palette, 0x20); + return sTopBarWindowId; +} + +void TopBarWindowPrintString(const u8 *string, u8 unUsed, bool8 copyToVram) +{ + s32 width; + + if (sTopBarWindowId != 0xFF) + { + PutWindowTilemap(sTopBarWindowId); + FillWindowPixelBuffer(sTopBarWindowId, PIXEL_FILL(15)); + width = GetStringWidth(0, string, 0); + AddTextPrinterParameterized3(sTopBarWindowId, 0, -20 - width, 1, &gUnknown_8456618, 0, string); + if (copyToVram) + CopyWindowToVram(sTopBarWindowId, 3); + } +} + + +void TopBarWindowPrintTwoStrings(const u8 *string, const u8 *string2, bool8 fgColorChooser, u8 notUsed, bool8 copyToVram) +{ + struct TextColor color; + s32 fgColor, width; + + if ( sTopBarWindowId != 0xFF ) + { + if (fgColorChooser) + { + color.fgColor = 0; + color.bgColor = 1; + color.shadowColor = 2; + } + else + { + color.fgColor = 15; + color.bgColor = 1; + color.shadowColor = 2; + } + + PutWindowTilemap(sTopBarWindowId); + FillWindowPixelBuffer(sTopBarWindowId, PIXEL_FILL(15)); + if (string2) + { + width = GetStringWidth(0, string2, 0); + AddTextPrinterParameterized3(sTopBarWindowId, 0, -20 - width, 1, &color, 0, string2); + } + AddTextPrinterParameterized4(sTopBarWindowId, 1, 4, 1, 0, 0, &color, 0, string); + if (copyToVram) + CopyWindowToVram(sTopBarWindowId, 3); + } +} + +// not used +static void Unused_CopyTopBarWindowToVram(void) +{ + if (sTopBarWindowId != 0xFF) + CopyWindowToVram(sTopBarWindowId, 3); +} + +void ClearTopBarWindow(void) +{ + if (sTopBarWindowId != 0xFF) + { + FillWindowPixelBuffer(sTopBarWindowId, PIXEL_FILL(15)); + CopyWindowToVram(sTopBarWindowId, 3); + } +} + +void DestroyTopBarWindow(void) +{ + if (sTopBarWindowId != 0xFF) + { + FillWindowPixelBuffer(sTopBarWindowId, PIXEL_FILL(0)); + ClearWindowTilemap(sTopBarWindowId); + CopyWindowToVram(sTopBarWindowId, 3); + RemoveWindow(sTopBarWindowId); + sTopBarWindowId = 0xFF; + } +} + +u8 Menu_InitCursorInternal(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 initialCursorPos, bool8 APressMuted) +{ + s32 pos; + + sMenu.left = left; + sMenu.top = top; + sMenu.minCursorPos = 0; + sMenu.maxCursorPos = numChoices - 1; + sMenu.windowId = windowId; + sMenu.fontId = fontId; + sMenu.optionHeight = cursorHeight; + sMenu.APressMuted = APressMuted; + pos = initialCursorPos; + if (pos < 0 || pos > sMenu.maxCursorPos) + sMenu.cursorPos = 0; + else + sMenu.cursorPos = pos; + + Menu_MoveCursor(0); + return sMenu.cursorPos; +} + +u8 Menu_InitCursor(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 initialCursorPos) +{ + return Menu_InitCursorInternal(windowId, fontId, left, top, cursorHeight, numChoices, initialCursorPos, 0); +} + +// not used +static u8 sub_810F818(u8 windowId, u8 fontId, u8 left, u8 top, u8 numChoices, u8 initialCursorPos) +{ + return Menu_InitCursor(windowId, fontId, left, top, GetMenuCursorDimensionByFont(fontId, 1), numChoices, initialCursorPos); +} + +void RedrawMenuCursor(u8 oldPos, u8 newPos) +{ + u8 width, height; + + width = GetMenuCursorDimensionByFont(sMenu.fontId, 0); + height = GetMenuCursorDimensionByFont(sMenu.fontId, 1); + FillWindowPixelRect(sMenu.windowId, 1, sMenu.left, sMenu.optionHeight * oldPos + sMenu.top, width, height); + AddTextPrinterParameterized(sMenu.windowId, sMenu.fontId, gFameCheckerText_ListMenuCursor, sMenu.left, sMenu.optionHeight * newPos + sMenu.top, 0, 0); +} + +u8 Menu_MoveCursor(s8 cursorDelta) +{ + u8 oldPos = sMenu.cursorPos; + s32 newPos = sMenu.cursorPos + cursorDelta; + + if (newPos < sMenu.minCursorPos) + sMenu.cursorPos = sMenu.maxCursorPos; + else if (newPos > sMenu.maxCursorPos) + sMenu.cursorPos = sMenu.minCursorPos; + else + sMenu.cursorPos += cursorDelta; + RedrawMenuCursor(oldPos, sMenu.cursorPos); + return sMenu.cursorPos; +} + +u8 Menu_MoveCursorNoWrapAround(s8 cursorDelta) +{ + u8 oldPos = sMenu.cursorPos; + s32 newPos = sMenu.cursorPos + cursorDelta; + + if (newPos < sMenu.minCursorPos) + sMenu.cursorPos = sMenu.minCursorPos; + else if (newPos > sMenu.maxCursorPos) + sMenu.cursorPos = sMenu.maxCursorPos; + else + sMenu.cursorPos += cursorDelta; + + RedrawMenuCursor(oldPos, sMenu.cursorPos); + return sMenu.cursorPos; +} + +u8 Menu_GetCursorPos(void) +{ + return sMenu.cursorPos; +} + +s8 Menu_ProcessInput(void) +{ + if (JOY_NEW(A_BUTTON)) + { + if (!sMenu.APressMuted) + PlaySE(SE_SELECT); + return sMenu.cursorPos; + } + else if (JOY_NEW(B_BUTTON)) + { + return MENU_B_PRESSED; + } + else if (JOY_NEW(DPAD_UP)) + { + PlaySE(SE_SELECT); + Menu_MoveCursor(-1); + return MENU_NOTHING_CHOSEN; + } + else if (JOY_NEW(DPAD_DOWN)) + { + PlaySE(SE_SELECT); + Menu_MoveCursor(1); + return MENU_NOTHING_CHOSEN; + } + return MENU_NOTHING_CHOSEN; +} + +s8 Menu_ProcessInputNoWrapAround(void) +{ + u8 oldPos = sMenu.cursorPos; + + if (JOY_NEW(A_BUTTON)) + { + if (!sMenu.APressMuted) + PlaySE(SE_SELECT); + return sMenu.cursorPos; + } + else if (JOY_NEW(B_BUTTON)) + { + return MENU_B_PRESSED; + } + else if (JOY_NEW(DPAD_UP)) + { + if (oldPos != Menu_MoveCursorNoWrapAround(-1)) + PlaySE(SE_SELECT); + return MENU_NOTHING_CHOSEN; + } + else if (JOY_NEW(DPAD_DOWN)) + { + if (oldPos != Menu_MoveCursorNoWrapAround(1)) + PlaySE(SE_SELECT); + return MENU_NOTHING_CHOSEN; + } + return MENU_NOTHING_CHOSEN; +} + +s8 Menu_ProcessInput_other(void) +{ + if (JOY_NEW(A_BUTTON)) + { + if (!sMenu.APressMuted) + PlaySE(SE_SELECT); + return sMenu.cursorPos; + } + else if (JOY_NEW(B_BUTTON)) + { + return MENU_B_PRESSED; + } + else if (JOY_REPT(DPAD_ANY) == DPAD_UP) + { + PlaySE(SE_SELECT); + Menu_MoveCursor(-1); + return MENU_NOTHING_CHOSEN; + } + else if (JOY_REPT(DPAD_ANY) == DPAD_DOWN) + { + PlaySE(SE_SELECT); + Menu_MoveCursor(1); + return MENU_NOTHING_CHOSEN; + } + return MENU_NOTHING_CHOSEN; +} + +s8 Menu_ProcessInputNoWrapAround_other(void) +{ + u8 oldPos = sMenu.cursorPos; + + if (JOY_NEW(A_BUTTON)) + { + if (!sMenu.APressMuted) + PlaySE(SE_SELECT); + return sMenu.cursorPos; + } + else if (JOY_NEW(B_BUTTON)) + { + return MENU_B_PRESSED; + } + else if (JOY_REPT(DPAD_ANY) == DPAD_UP) + { + if (oldPos != Menu_MoveCursorNoWrapAround(-1)) + PlaySE(SE_SELECT); + return MENU_NOTHING_CHOSEN; + } + else if (JOY_REPT(DPAD_ANY) == DPAD_DOWN) + { + if (oldPos != Menu_MoveCursorNoWrapAround(1)) + PlaySE(SE_SELECT); + return MENU_NOTHING_CHOSEN; + } + return MENU_NOTHING_CHOSEN; +} + +void PrintTextArray(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *strs) +{ + u8 i; + + for (i = 0; i < itemCount; i++) + AddTextPrinterParameterized(windowId, fontId, strs[i].text, left, (lineHeight * i) + top, 0xFF, NULL); + CopyWindowToVram(windowId, 2); +} + +void PrintMultichoiceListItems(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, u8 letterSpacing, u8 lineSpacing) +{ + u8 i; + + for (i = 0; i < itemCount; i++) + { + AddTextPrinterParameterized5(windowId, fontId, strs[i].text, left, (lineHeight * i) + top, 0xFF, NULL, letterSpacing, lineSpacing); + } + CopyWindowToVram(windowId, 2); +} + +void UnionRoomAndTradeMenuPrintOptions(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *strs) +{ + u8 left = GetMenuCursorDimensionByFont(fontId, 0); + + PrintTextArray(windowId, fontId, left, 0, lineHeight, itemCount, strs); +} + +void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, const u8 *orderArray) +{ + u8 i; + struct TextPrinterTemplate printer; + + printer.windowId = windowId; + printer.fontId = fontId; + printer.fgColor = GetFontAttribute(fontId, FONTATTR_COLOR_FOREGROUND); + printer.bgColor = GetFontAttribute(fontId, FONTATTR_COLOR_BACKGROUND); + printer.shadowColor = GetFontAttribute(fontId, FONTATTR_COLOR_SHADOW); + printer.unk = GetFontAttribute(fontId, FONTATTR_UNKNOWN); + printer.letterSpacing = letterSpacing; + printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING); + printer.x = left; + printer.currentX = left; + for (i = 0; i < itemCount; i++) + { + printer.currentChar = strs[orderArray[i]].text; + printer.y = (lineHeight * i) + top; + printer.currentY = printer.y; + AddTextPrinter(&printer, 0xFF, NULL); + } + CopyWindowToVram(windowId, 2); +} + +// not used +static void sub_810FDE4(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, const u8 *orderArray) +{ + AddItemMenuActionTextPrinters(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 0, GetFontAttribute(fontId, FONTATTR_LETTER_SPACING), lineHeight, itemCount, strs, orderArray); +} + +/* +struct WindowTemplateWithAttr SetWindowTemplateFields(struct WindowTemplate *template, u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock) +{ + struct WindowTemplate temp; + struct WindowTemplateWithAttr ret; + + temp.bg = bg; + temp.tilemapLeft = left; + temp.tilemapTop = top; + temp.width = width; + temp.height = height; + temp.paletteNum = paletteNum; + temp.baseBlock = baseBlock; + *template = temp; + ret.ptr = template; + ret.attr = *((u32*)&temp); + return ret; +} +*/ +NAKED +void SetWindowTemplateFields(struct WindowTemplate *template, u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock) +{ + asm_unified("\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x8\n\ + ldr r4, [sp, 0x28]\n\ + mov r12, r4\n\ + ldr r4, [sp, 0x2C]\n\ + mov r9, r4\n\ + ldr r4, [sp, 0x30]\n\ + mov r10, r4\n\ + ldr r7, [sp, 0x34]\n\ + lsls r1, 24\n\ + lsrs r1, 24\n\ + lsls r2, 24\n\ + lsls r3, 24\n\ + mov r4, r9\n\ + lsls r4, 24\n\ + lsrs r4, 24\n\ + mov r9, r4\n\ + mov r4, r10\n\ + lsls r4, 24\n\ + mov r10, r4\n\ + ldr r4, _0810FEF0 @ =0xffffff00\n\ + mov r8, r4\n\ + mov r5, r8\n\ + ldr r4, [sp]\n\ + ands r5, r4\n\ + orrs r5, r1\n\ + str r5, [sp]\n\ + lsrs r2, 16\n\ + ldr r6, _0810FEF4 @ =0xffff00ff\n\ + adds r4, r6, 0\n\ + ands r4, r5\n\ + orrs r4, r2\n\ + str r4, [sp]\n\ + lsrs r3, 8\n\ + ldr r1, _0810FEF8 @ =0xff00ffff\n\ + ands r1, r4\n\ + orrs r1, r3\n\ + str r1, [sp]\n\ + mov r2, r12\n\ + lsls r2, 24\n\ + mov r12, r2\n\ + ldr r2, _0810FEFC @ =0x00ffffff\n\ + ands r1, r2\n\ + mov r4, r12\n\ + orrs r4, r1\n\ + str r4, [sp]\n\ + ldr r1, [sp, 0x4]\n\ + mov r2, r8\n\ + ands r1, r2\n\ + mov r4, r9\n\ + orrs r1, r4\n\ + mov r8, r1\n\ + str r1, [sp, 0x4]\n\ + mov r1, r10\n\ + lsrs r1, 16\n\ + mov r2, r8\n\ + ands r6, r2\n\ + orrs r6, r1\n\ + str r6, [sp, 0x4]\n\ + lsls r2, r7, 16\n\ + ldr r1, _0810FF00 @ =0x0000ffff\n\ + ands r6, r1\n\ + orrs r6, r2\n\ + str r6, [sp, 0x4]\n\ + ldr r1, [sp]\n\ + ldr r2, [sp, 0x4]\n\ + str r1, [r0]\n\ + str r2, [r0, 0x4]\n\ + add sp, 0x8\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r2}\n\ + bx r2\n\ + .align 2, 0\n\ + _0810FEF0: .4byte 0xffffff00\n\ + _0810FEF4: .4byte 0xffff00ff\n\ + _0810FEF8: .4byte 0xff00ffff\n\ + _0810FEFC: .4byte 0x00ffffff\n\ + _0810FF00: .4byte 0x0000ffff\n\ + "); +} + +// not used +static u16 CreateWindowTemplate(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock) +{ + struct WindowTemplate template, temp; + + SetWindowTemplateFields(&template, bg, left, top, width, height, paletteNum, baseBlock); + temp = template; + return (u16)AddWindow(&temp); +} + +void CreateYesNoMenu(const struct WindowTemplate *window, u8 fontId, u8 left, u8 top, u16 baseTileNum, u8 paletteNum, u8 initialCursorPos) +{ + struct TextPrinterTemplate textSubPrinter; + + sYesNoWindowId = AddWindow(window); + DrawStdFrameWithCustomTileAndPalette(sYesNoWindowId, 1, baseTileNum, paletteNum); + textSubPrinter.currentChar = gUnknown_841623D; + textSubPrinter.windowId = sYesNoWindowId; + textSubPrinter.fontId = fontId; + textSubPrinter.x = GetMenuCursorDimensionByFont(fontId, 0) + left; + textSubPrinter.y = top; + textSubPrinter.currentX = textSubPrinter.x; + textSubPrinter.currentY = textSubPrinter.y; + textSubPrinter.fgColor = GetFontAttribute(fontId, FONTATTR_COLOR_FOREGROUND); + textSubPrinter.bgColor = GetFontAttribute(fontId, FONTATTR_COLOR_BACKGROUND); + textSubPrinter.shadowColor = GetFontAttribute(fontId, FONTATTR_COLOR_SHADOW); + textSubPrinter.unk = GetFontAttribute(fontId, FONTATTR_UNKNOWN); + textSubPrinter.letterSpacing = GetFontAttribute(fontId, FONTATTR_LETTER_SPACING); + textSubPrinter.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING); + AddTextPrinter(&textSubPrinter, 0xFF, NULL); + Menu_InitCursor(sYesNoWindowId, fontId, left, top, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_HEIGHT) + textSubPrinter.lineSpacing, 2, initialCursorPos); +} + +// not used +static void Unused_CreateYesNoMenu2(const struct WindowTemplate *window, u8 paletteNum, u16 baseTileNum, u8 initialCursorPos) +{ + CreateYesNoMenu(window, paletteNum, 0, 0, baseTileNum, initialCursorPos, 0); +} + +s8 Menu_ProcessInputNoWrapClearOnChoose(void) +{ + s8 result = Menu_ProcessInputNoWrapAround(); + if (result != MENU_NOTHING_CHOSEN) + DestroyYesNoMenu(); + return result; +} + +void DestroyYesNoMenu(void) +{ + ClearStdWindowAndFrameToTransparent(sYesNoWindowId, TRUE); + RemoveWindow(sYesNoWindowId); +} + +void MultichoiceGridPrintItems(u8 windowId, u8 fontId, u8 itemWidth, u8 itemHeight, u8 cols, u8 rows, const struct MenuAction *strs) +{ + u8 width, i, j, yOffset; + + fontId = fontId; + itemWidth = itemWidth; + itemHeight = itemHeight; + width = GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH); + yOffset = (16 - GetFontAttribute(fontId, FONTATTR_MAX_LETTER_HEIGHT)) / 2; + for (i = 0; i < rows; ++i) + for (j = 0; j < cols; ++j) + AddTextPrinterParameterized(windowId, fontId, strs[i * cols + j].text, itemWidth * j + width, yOffset + itemHeight * i, 0xFF, 0); + CopyWindowToVram(windowId, 2); +} + +//not used +static void Unused_MultichoiceGridPrintItemsCustomOrder(u8 windowId, u8 fontId, u8 itemWidth, u8 itemHeight, u8 cols, u8 rows, const struct MenuAction *strs, const u8 *orderArray) +{ + u8 width, i, j; + + fontId = fontId; + itemWidth = itemWidth; + itemHeight = itemHeight; + width = GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH); + for (i = 0; i < rows; ++i) + for (j = 0; j < cols; ++j) + AddTextPrinterParameterized(windowId, fontId, strs[orderArray[i * cols + j]].text, itemWidth * j + width, itemHeight * i, 0xFF, 0); + CopyWindowToVram(windowId, 2); +} + +static u8 MultichoiceGridInitCursorInternal(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth, u8 cursorHeight, u8 cols, u8 rows, u8 numChoices, u8 cursorPos) +{ + s32 pos; + + sMenu.left = left; + sMenu.top = top; + sMenu.minCursorPos = 0; + sMenu.maxCursorPos = numChoices - 1; + sMenu.windowId = windowId; + sMenu.fontId = fontId; + sMenu.optionWidth = optionWidth; + sMenu.optionHeight = cursorHeight; + sMenu.columns = cols; + sMenu.rows = rows; + pos = cursorPos; + if (pos < 0 || pos > sMenu.maxCursorPos) + sMenu.cursorPos = 0; + else + sMenu.cursorPos = pos; + MultichoiceGridComputeNewCursorPos(0, 0); + return sMenu.cursorPos; +} + +u8 MultichoiceGridInitCursor(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth, u8 cols, u8 rows, u8 cursorPos) +{ + s32 cursorHeight = 16; + u8 numChoices = cols * rows; + + return MultichoiceGridInitCursorInternal(windowId, fontId, left, top, optionWidth, cursorHeight, cols, rows, numChoices, cursorPos); +} + +static void MultichoiceGridUpdateCursorPos(u8 oldCursorPos, u8 newCursorPos) +{ + u8 cursorWidth = GetMenuCursorDimensionByFont(sMenu.fontId, 0); + u8 cursorHeight = GetMenuCursorDimensionByFont(sMenu.fontId, 1); + u8 xPos = (oldCursorPos % sMenu.columns) * sMenu.optionWidth + sMenu.left; + u8 yPos = (oldCursorPos / sMenu.columns) * sMenu.optionHeight + sMenu.top; + + FillWindowPixelRect(sMenu.windowId, PIXEL_FILL(1), xPos, yPos, cursorWidth, cursorHeight); + xPos = (newCursorPos % sMenu.columns) * sMenu.optionWidth + sMenu.left; + yPos = (newCursorPos / sMenu.columns) * sMenu.optionHeight + sMenu.top; + AddTextPrinterParameterized(sMenu.windowId, sMenu.fontId, gFameCheckerText_ListMenuCursor, xPos, yPos, 0, 0); +} + +static u8 MultichoiceGridComputeNewCursorPos(s8 deltaX, s8 deltaY) +{ + u8 oldPos = sMenu.cursorPos; + + if (deltaX) + { + if ((sMenu.cursorPos % sMenu.columns) + deltaX < 0) + sMenu.cursorPos += sMenu.columns - 1; + else if ((sMenu.cursorPos % sMenu.columns) + deltaX >= sMenu.columns) + sMenu.cursorPos = (sMenu.cursorPos / sMenu.columns) * sMenu.columns; + else + sMenu.cursorPos += deltaX; + } + if (deltaY) + { + if ((sMenu.cursorPos / sMenu.columns) + deltaY < 0) + sMenu.cursorPos += sMenu.columns * (sMenu.rows - 1); + else if ((sMenu.cursorPos / sMenu.columns) + deltaY >= sMenu.rows) + sMenu.cursorPos -= sMenu.columns * (sMenu.rows - 1); + else + sMenu.cursorPos += (sMenu.columns * deltaY); + } + if (sMenu.cursorPos > sMenu.maxCursorPos) + { + sMenu.cursorPos = oldPos; + return sMenu.cursorPos; + } + else + { + MultichoiceGridUpdateCursorPos(oldPos, sMenu.cursorPos); + return sMenu.cursorPos; + } +} + +static u8 MultichoiceGridComputeNewCursorPosIfValid(s8 deltaX, s8 deltaY) +{ + u8 oldPos = sMenu.cursorPos; + + if (deltaX) + { + if (((sMenu.cursorPos % sMenu.columns) + deltaX >= 0) && ((sMenu.cursorPos % sMenu.columns) + deltaX < sMenu.columns)) + sMenu.cursorPos += deltaX; + } + if (deltaY) + { + if (((sMenu.cursorPos / sMenu.columns) + deltaY >= 0) && ((sMenu.cursorPos / sMenu.columns) + deltaY < sMenu.rows)) + sMenu.cursorPos += (sMenu.columns * deltaY); + } + if (sMenu.cursorPos > sMenu.maxCursorPos) + { + sMenu.cursorPos = oldPos; + return sMenu.cursorPos; + } + else + { + MultichoiceGridUpdateCursorPos(oldPos, sMenu.cursorPos); + return sMenu.cursorPos; + } +} + +// not used +static s8 sub_81105A0(void) +{ + if (JOY_NEW(A_BUTTON)) + { + PlaySE(SE_SELECT); + return sMenu.cursorPos; + } + else if (JOY_NEW(B_BUTTON)) + { + return MENU_B_PRESSED; + } + else if (JOY_NEW(DPAD_UP)) + { + PlaySE(SE_SELECT); + MultichoiceGridComputeNewCursorPos(0, -1); + return MENU_NOTHING_CHOSEN; + } + else if (JOY_NEW(DPAD_DOWN)) + { + PlaySE(SE_SELECT); + MultichoiceGridComputeNewCursorPos(0, 1); + return MENU_NOTHING_CHOSEN; + } + else if (JOY_NEW(DPAD_LEFT) || GetLRKeysState() == 1) + { + PlaySE(SE_SELECT); + MultichoiceGridComputeNewCursorPos(-1, 0); + return MENU_NOTHING_CHOSEN; + } + else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysState() == 2) + { + PlaySE(SE_SELECT); + MultichoiceGridComputeNewCursorPos(1, 0); + return MENU_NOTHING_CHOSEN; + } + return MENU_NOTHING_CHOSEN; +} + +s8 Menu_ProcessInputGridLayout(void) +{ + u8 oldPos = sMenu.cursorPos; + + if (JOY_NEW(A_BUTTON)) + { + PlaySE(SE_SELECT); + return sMenu.cursorPos; + } + else if (JOY_NEW(B_BUTTON)) + { + return MENU_B_PRESSED; + } + else if (JOY_NEW(DPAD_UP)) + { + if (oldPos != MultichoiceGridComputeNewCursorPosIfValid(0, -1)) + PlaySE(SE_SELECT); + return MENU_NOTHING_CHOSEN; + } + else if (JOY_NEW(DPAD_DOWN)) + { + if (oldPos != MultichoiceGridComputeNewCursorPosIfValid(0, 1)) + PlaySE(SE_SELECT); + return MENU_NOTHING_CHOSEN; + } + else if (JOY_NEW(DPAD_LEFT) || GetLRKeysState() == 1) + { + if (oldPos != MultichoiceGridComputeNewCursorPosIfValid(-1, 0)) + PlaySE(SE_SELECT); + return MENU_NOTHING_CHOSEN; + } + else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysState() == 2) + { + if (oldPos != MultichoiceGridComputeNewCursorPosIfValid(1, 0)) + PlaySE(SE_SELECT); + return MENU_NOTHING_CHOSEN; + } + return MENU_NOTHING_CHOSEN; +} + +// not used +static s8 sub_81106F4(void) +{ + if (JOY_NEW(A_BUTTON)) + { + PlaySE(SE_SELECT); + return sMenu.cursorPos; + } + else if (JOY_NEW(B_BUTTON)) + { + return MENU_B_PRESSED; + } + else if (JOY_REPT(DPAD_ANY) == DPAD_UP) + { + PlaySE(SE_SELECT); + MultichoiceGridComputeNewCursorPos(0, -1); + return MENU_NOTHING_CHOSEN; + } + else if (JOY_REPT(DPAD_ANY) == DPAD_DOWN) + { + PlaySE(SE_SELECT); + MultichoiceGridComputeNewCursorPos(0, 1); + return MENU_NOTHING_CHOSEN; + } + else if (JOY_REPT(DPAD_ANY) == DPAD_LEFT || sub_80BF66C() == 1) + { + PlaySE(SE_SELECT); + MultichoiceGridComputeNewCursorPos(-1, 0); + return MENU_NOTHING_CHOSEN; + } + else if (JOY_REPT(DPAD_ANY) == DPAD_RIGHT || sub_80BF66C() == 2) + { + PlaySE(SE_SELECT); + MultichoiceGridComputeNewCursorPos(1, 0); + return MENU_NOTHING_CHOSEN; + } + + return MENU_NOTHING_CHOSEN; +} + +// not used +static s8 sub_81107A0(void) +{ + u8 oldPos = sMenu.cursorPos; + + if (JOY_NEW(A_BUTTON)) + { + PlaySE(SE_SELECT); + return sMenu.cursorPos; + } + else if (JOY_NEW(B_BUTTON)) + { + return MENU_B_PRESSED; + } + else if (JOY_REPT(DPAD_ANY) == DPAD_UP) + { + if (oldPos != MultichoiceGridComputeNewCursorPosIfValid(0, -1)) + PlaySE(SE_SELECT); + return MENU_NOTHING_CHOSEN; + } + else if (JOY_REPT(DPAD_ANY) == DPAD_DOWN) + { + if (oldPos != MultichoiceGridComputeNewCursorPosIfValid(0, 1)) + PlaySE(SE_SELECT); + return MENU_NOTHING_CHOSEN; + } + else if (JOY_REPT(DPAD_ANY) == DPAD_LEFT || sub_80BF66C() == 1) + { + if (oldPos != MultichoiceGridComputeNewCursorPosIfValid(-1, 0)) + PlaySE(SE_SELECT); + return MENU_NOTHING_CHOSEN; + } + else if (JOY_REPT(DPAD_ANY) == DPAD_RIGHT || sub_80BF66C() == 2) + { + if (oldPos != MultichoiceGridComputeNewCursorPosIfValid(1, 0)) + PlaySE(SE_SELECT); + return MENU_NOTHING_CHOSEN; + } + return MENU_NOTHING_CHOSEN; +} diff --git a/src/money.c b/src/money.c index ffaba2e29..616b448e1 100644 --- a/src/money.c +++ b/src/money.c @@ -109,7 +109,7 @@ void PrintMoneyAmount(u8 windowId, u8 x, u8 y, int amount, u8 speed) void PrintMoneyAmountInMoneyBoxWithBorder(u8 windowId, u16 tileStart, u8 pallete, int amount) { - SetWindowBorderStyle(windowId, FALSE, tileStart, pallete); + DrawStdFrameWithCustomTileAndPalette(windowId, FALSE, tileStart, pallete); AddTextPrinterParameterized(windowId, 2, gUnknown_8419CE7, 0, 0, 0xFF, 0); PrintMoneyAmountInMoneyBox(windowId, amount, 0); } @@ -134,7 +134,7 @@ void DrawMoneyBox(int amount, u8 x, u8 y) void HideMoneyBox(void) { - ClearMenuWindow(sMoneyBoxWindowId, FALSE); + ClearStdWindowAndFrameToTransparent(sMoneyBoxWindowId, FALSE); CopyWindowToVram(sMoneyBoxWindowId, 2); RemoveWindow(sMoneyBoxWindowId); } 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) diff --git a/src/oak_speech.c b/src/oak_speech.c index 14e7c87d0..eb5357e3a 100644 --- a/src/oak_speech.c +++ b/src/oak_speech.c @@ -546,7 +546,7 @@ static void Task_OaksSpeech1(u8 taskId) CopyBgTilemapBufferToVram(1); break; case 7: - CreateWindow_SnapRight_StdPal(0, 30, 0, 13, 0x1C4); + CreateTopBarWindowLoadPalette(0, 30, 0, 13, 0x1C4); FillBgTilemapBufferRect_Palette0(1, 0xD00F, 0, 0, 30, 2); FillBgTilemapBufferRect_Palette0(1, 0xD002, 0, 2, 30, 1); FillBgTilemapBufferRect_Palette0(1, 0xD00E, 0, 19, 30, 1); @@ -572,7 +572,7 @@ static void Task_OaksSpeech1(u8 taskId) static void CreateHelpDocsPage1(void) { - Menu_PrintHelpSystemUIHeader(gText_Controls, gText_ABUTTONNext, 0, 0, 1); + TopBarWindowPrintTwoStrings(gText_Controls, gText_ABUTTONNext, 0, 0, 1); sOakSpeechResources->unk_0014[0] = AddWindow(sHelpDocsWindowTemplatePtrs[sOakSpeechResources->unk_0012]); PutWindowTilemap(sOakSpeechResources->unk_0014[0]); FillWindowPixelBuffer(sOakSpeechResources->unk_0014[0], 0x00); @@ -592,7 +592,7 @@ static void Task_OakSpeech4(u8 taskId) } else { - PrintTextOnRightSnappedWindow(gText_ABUTTONNext_BBUTTONBack, 0, 1); + TopBarWindowPrintString(gText_ABUTTONNext_BBUTTONBack, 0, 1); for (i = 0; i < 3; i++) { sOakSpeechResources->unk_0014[i] = AddWindow(&sHelpDocsWindowTemplatePtrs[sOakSpeechResources->unk_0012][i]); @@ -716,8 +716,8 @@ static void Task_OakSpeech6(u8 taskId) else { PlayBGM(BGM_FRLG_GAME_EXPLANATION_MIDDLE); - sub_810F71C(); - PrintTextOnRightSnappedWindow(gText_ABUTTONNext, 0, 1); + ClearTopBarWindow(); + TopBarWindowPrintString(gText_ABUTTONNext, 0, 1); sOakSpeechResources->unk_0008 = MallocAndDecompress(sNewGameAdventureIntroTilemap, &sp14); CopyToBgTilemapBufferRect(1, sOakSpeechResources->unk_0008, 0, 2, 30, 19); CopyBgTilemapBufferToVram(1); @@ -793,13 +793,13 @@ static void Task_OakSpeech7(u8 taskId) AddTextPrinterParameterized4(data[14], 2, 3, 5, 1, 0, &sTextColor_OakSpeech, 0, sNewGameAdventureIntroTextPointers[sOakSpeechResources->unk_0012]); if (sOakSpeechResources->unk_0012 == 0) { - sub_810F71C(); - PrintTextOnRightSnappedWindow(gText_ABUTTONNext, 0, 1); + ClearTopBarWindow(); + TopBarWindowPrintString(gText_ABUTTONNext, 0, 1); } else { - sub_810F71C(); - PrintTextOnRightSnappedWindow(gText_ABUTTONNext_BBUTTONBack, 0, 1); + ClearTopBarWindow(); + TopBarWindowPrintString(gText_ABUTTONNext_BBUTTONBack, 0, 1); } gMain.state++; } @@ -846,7 +846,7 @@ static void Task_OakSpeech8(u8 taskId) if (!gPaletteFade.active) { - sub_810F740(); + DestroyTopBarWindow(); FillWindowPixelBuffer(data[14], 0x00); ClearWindowTilemap(data[14]); CopyWindowToVram(data[14], 3); @@ -1054,7 +1054,7 @@ static void Task_OakSpeech19(u8 taskId) { gTasks[taskId].data[13] = AddWindow(&sNewGameAdventureIntroWindowTemplates[1]); PutWindowTilemap(gTasks[taskId].data[13]); - SetWindowBorderStyle(gTasks[taskId].data[13], 1, GetStdWindowBaseTileNum(), 14); + DrawStdFrameWithCustomTileAndPalette(gTasks[taskId].data[13], 1, GetStdWindowBaseTileNum(), 14); FillWindowPixelBuffer(gTasks[taskId].data[13], 0x11); sOakSpeechResources->unk_001C[0] = 1; sOakSpeechResources->unk_001C[1] = 2; @@ -1064,7 +1064,7 @@ static void Task_OakSpeech19(u8 taskId) sOakSpeechResources->unk_001C[1] = 2; sOakSpeechResources->unk_001C[2] = 3; AddTextPrinterParameterized3(gTasks[taskId].data[13], 2, 8, 17, sOakSpeechResources->unk_001C, 0, gText_Girl); - ProgramAndPlaceMenuCursorOnWindow(gTasks[taskId].data[13], 2, 0, 1, GetFontAttribute(2, 1) + 2, 2, 0); + Menu_InitCursor(gTasks[taskId].data[13], 2, 0, 1, GetFontAttribute(2, 1) + 2, 2, 0); CopyWindowToVram(gTasks[taskId].data[13], 3); gTasks[taskId].func = Task_OakSpeech20; } @@ -1072,7 +1072,7 @@ static void Task_OakSpeech19(u8 taskId) static void Task_OakSpeech20(u8 taskId) { - s8 input = ProcessMenuInputNoWrapAround(); + s8 input = Menu_ProcessInputNoWrapAround(); switch (input) { case 0: @@ -1092,7 +1092,7 @@ static void Task_OakSpeech20(u8 taskId) static void Task_OakSpeech21(u8 taskId) { s16 * data = gTasks[taskId].data; - ClearMenuWindow(data[13], 1); + ClearStdWindowAndFrameToTransparent(data[13], 1); RemoveWindow(data[13]); data[13] = 0; ClearDialogWindowAndFrame(0, 1); @@ -1176,7 +1176,7 @@ static void Task_OakSpeech28(u8 taskId) static void Task_OakSpeech29(u8 taskId) { s16 * data = gTasks[taskId].data; - s8 input = ProcessMenuInput(); + s8 input = Menu_ProcessInput(); switch (input) { case 1: @@ -1184,7 +1184,7 @@ static void Task_OakSpeech29(u8 taskId) case 3: case 4: PlaySE(SE_SELECT); - ClearMenuWindow(data[13], TRUE); + ClearStdWindowAndFrameToTransparent(data[13], TRUE); RemoveWindow(data[13]); GetDefaultName(sOakSpeechResources->unk_0010, input - 1); data[15] = 1; @@ -1211,7 +1211,7 @@ static void Task_OakSpeech25(u8 taskId) } else { - ClearMenuWindow(gTasks[taskId].data[13], 1); + ClearStdWindowAndFrameToTransparent(gTasks[taskId].data[13], 1); RemoveWindow(gTasks[taskId].data[13]); DoNamingScreen(4, gSaveBlock1Ptr->rivalName, 0, 0, 0, CB2_ReturnFromNamingScreen); } @@ -1850,7 +1850,7 @@ static void PrintNameChoiceOptions(u8 taskId, u8 state) data[13] = AddWindow(&sNewGameAdventureIntroWindowTemplates[3]); PutWindowTilemap(data[13]); - SetWindowBorderStyle(data[13], 1, GetStdWindowBaseTileNum(), 14); + DrawStdFrameWithCustomTileAndPalette(data[13], 1, GetStdWindowBaseTileNum(), 14); FillWindowPixelBuffer(gTasks[taskId].data[13], 0x11); AddTextPrinterParameterized(data[13], 2, gOtherText_NewName, 8, 1, 0, NULL); if (state == 0) @@ -1861,7 +1861,7 @@ static void PrintNameChoiceOptions(u8 taskId, u8 state) { AddTextPrinterParameterized(data[13], 2, textPtrs[i], 8, 16 * (i + 1) + 1, 0, NULL); } - ProgramAndPlaceMenuCursorOnWindow(data[13], 2, 0, 1, 16, 5, 0); + Menu_InitCursor(data[13], 2, 0, 1, 16, 5, 0); CopyWindowToVram(data[13], 3); } diff --git a/src/tm_case.c b/src/tm_case.c index 0266f9c90..79e10bcfc 100644 --- a/src/tm_case.c +++ b/src/tm_case.c @@ -795,7 +795,7 @@ static void Task_SelectTMAction_FromFieldBag(u8 taskId) sTMCaseDynamicResources->numMenuActions = NELEMS(sMenuActionIndices_UnionRoom); } AddItemMenuActionTextPrinters(sTMCaseDynamicResources->contextMenuWindowId, 2, GetMenuCursorDimensionByFont(2, 0), 2, 0, GetFontAttribute(2, 1) + 2, sTMCaseDynamicResources->numMenuActions, sMenuActions_UseGiveExit, sTMCaseDynamicResources->menuActionIndices); - ProgramAndPlaceMenuCursorOnWindow(sTMCaseDynamicResources->contextMenuWindowId, 2, 0, 2, GetFontAttribute(2, 1) + 2, sTMCaseDynamicResources->numMenuActions, 0); + Menu_InitCursor(sTMCaseDynamicResources->contextMenuWindowId, 2, 0, 2, GetFontAttribute(2, 1) + 2, sTMCaseDynamicResources->numMenuActions, 0); strbuf = Alloc(256); GetTMNumberAndMoveString(strbuf, gSpecialVar_ItemId); StringAppend(strbuf, gText_IsSelected); @@ -817,7 +817,7 @@ static void Task_TMContextMenu_HandleInput(u8 taskId) if (sub_80BF72C() != TRUE) { - input = ProcessMenuInputNoWrapAround(); + input = Menu_ProcessInputNoWrapAround(); switch (input) { case -1: @@ -837,7 +837,7 @@ static void Task_TMContextMenu_HandleInput(u8 taskId) static void TMHMContextMenuAction_Use(u8 taskId) { RemoveTMContextMenu(&sTMCaseDynamicResources->contextMenuWindowId); - ClearMenuWindow(2, 0); + ClearStdWindowAndFrameToTransparent(2, 0); ClearWindowTilemap(2); PutWindowTilemap(0); ScheduleBgCopyTilemapToVram(0); @@ -859,7 +859,7 @@ static void TMHMContextMenuAction_Give(u8 taskId) s16 * data = gTasks[taskId].data; u16 itemId = BagGetItemIdByPocketPosition(POCKET_TM_CASE, data[1]); RemoveTMContextMenu(&sTMCaseDynamicResources->contextMenuWindowId); - ClearMenuWindow(2, 0); + ClearStdWindowAndFrameToTransparent(2, 0); ClearWindowTilemap(2); PutWindowTilemap(1); PutWindowTilemap(4); @@ -912,7 +912,7 @@ static void Subtask_CloseContextMenuAndReturnToMain(u8 taskId) DestroyListMenuTask(data[0], &sTMCaseStaticResources.scrollOffset, &sTMCaseStaticResources.selectedRow); data[0] = ListMenuInit(&gMultiuseListMenuTemplate, sTMCaseStaticResources.scrollOffset, sTMCaseStaticResources.selectedRow); PrintListMenuCursorByID_WithColorIdx(data[0], 1); - ClearMenuWindow_BorderThickness2(6, 0); + ClearDialogWindowAndFrameToTransparent(6, 0); ClearWindowTilemap(6); PutWindowTilemap(1); PutWindowTilemap(4); @@ -927,7 +927,7 @@ static void TMHMContextMenuAction_Exit(u8 taskId) s16 * data = gTasks[taskId].data; RemoveTMContextMenu(&sTMCaseDynamicResources->contextMenuWindowId); - ClearMenuWindow(2, 0); + ClearStdWindowAndFrameToTransparent(2, 0); ClearWindowTilemap(2); PutWindowTilemap(0); PrintListMenuCursorByID_WithColorIdx(data[0], 1); @@ -1016,8 +1016,8 @@ static void Task_SaleOfTMsCancelled(u8 taskId) { s16 * data = gTasks[taskId].data; - ClearMenuWindow(8, 0); - ClearMenuWindow_BorderThickness2(6, 0); + ClearStdWindowAndFrameToTransparent(8, 0); + ClearDialogWindowAndFrameToTransparent(6, 0); PutWindowTilemap(0); PutWindowTilemap(1); PutWindowTilemap(3); @@ -1065,7 +1065,7 @@ static void Task_QuantitySelect_HandleInput(u8 taskId) else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); - ClearMenuWindow(7, 0); + ClearStdWindowAndFrameToTransparent(7, 0); ScheduleBgCopyTilemapToVram(0); ScheduleBgCopyTilemapToVram(1); RemoveTMCaseScrollIndicatorArrowPair(); @@ -1074,9 +1074,9 @@ static void Task_QuantitySelect_HandleInput(u8 taskId) else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); - ClearMenuWindow(7, 0); - ClearMenuWindow(8, 0); - ClearMenuWindow_BorderThickness2(6, 0); + ClearStdWindowAndFrameToTransparent(7, 0); + ClearStdWindowAndFrameToTransparent(8, 0); + ClearDialogWindowAndFrameToTransparent(6, 0); PutWindowTilemap(3); PutWindowTilemap(0); PutWindowTilemap(1); @@ -1123,8 +1123,8 @@ static void Task_AfterSale_ReturnToList(u8 taskId) if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); - ClearMenuWindow(8, 0); - ClearMenuWindow_BorderThickness2(6, 0); + ClearStdWindowAndFrameToTransparent(8, 0); + ClearDialogWindowAndFrameToTransparent(6, 0); PutWindowTilemap(1); PutWindowTilemap(3); PutWindowTilemap(4); @@ -1249,7 +1249,7 @@ static void Task_TMCaseDude_Playback(u8 taskId) { FillBG2RowWithPalette_2timesNplus1(0); BeginNormalPaletteFade(0x00000400, 0, 6, 0, 0); - ClearMenuWindow_BorderThickness2(6, 0); + ClearDialogWindowAndFrameToTransparent(6, 0); ScheduleBgCopyTilemapToVram(1); data[8]++; } @@ -1322,12 +1322,12 @@ static void AddTextPrinterParameterized_ColorByIndex(u8 windowId, u8 fontId, con static void TMCase_SetWindowBorder1(u8 windowId) { - SetWindowBorderStyle(windowId, FALSE, 0x5B, 0x0E); + DrawStdFrameWithCustomTileAndPalette(windowId, FALSE, 0x5B, 0x0E); } static void TMCase_SetWindowBorder2(u8 windowId) { - SetWindowBorderStyle(windowId, FALSE, 0x78, 0x0D); + DrawStdFrameWithCustomTileAndPalette(windowId, FALSE, 0x78, 0x0D); } static void TMCase_PrintMessageWithFollowupTask(u8 taskId, u8 windowId, const u8 * str, TaskFunc func) @@ -1420,7 +1420,7 @@ static u8 AddTMContextMenu(u8 * a0, u8 a1) static void RemoveTMContextMenu(u8 * a0) { - ClearMenuWindow(*a0, FALSE); + ClearStdWindowAndFrameToTransparent(*a0, FALSE); ClearWindowTilemap(*a0); RemoveWindow(*a0); ScheduleBgCopyTilemapToVram(0); diff --git a/src/trainer_tower.c b/src/trainer_tower.c index 65d825dfe..b7b9c096d 100644 --- a/src/trainer_tower.c +++ b/src/trainer_tower.c @@ -1299,7 +1299,7 @@ void sub_815E720(void) void sub_815E88C(void) { u8 windowId = VarGet(VAR_0x4001); - ClearMenuWindow(windowId, TRUE); + ClearStdWindowAndFrameToTransparent(windowId, TRUE); RemoveWindow(windowId); } -- cgit v1.2.3 From 0c57132043eb432e3fdaaf0efd9b19fce50a92e2 Mon Sep 17 00:00:00 2001 From: jiangzhengwenjz Date: Tue, 9 Jul 2019 14:41:18 +0800 Subject: finished menu_helpers.h + more documentation --- src/menu_helpers.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/menu_helpers.c b/src/menu_helpers.c index 12837c099..fdcb9a56e 100644 --- a/src/menu_helpers.c +++ b/src/menu_helpers.c @@ -22,10 +22,10 @@ static EWRAM_DATA u8 gUnknown_20399D0 = {0}; static void Task_ContinueTaskAfterMessagePrints(u8 taskId); -void DisplayMessageAndContinueTask(u8 taskId, u8 windowId, u16 arg2, u8 arg3, u8 fontId, u8 textSpeed, const u8 *string, void *taskFunc) +void DisplayMessageAndContinueTask(u8 taskId, u8 windowId, u16 tileNum, u8 paletteNum, u8 fontId, u8 textSpeed, const u8 *string, void *taskFunc) { gUnknown_20399D0 = windowId; - DrawDialogFrameWithCustomTileAndPalette(windowId, TRUE, arg2, arg3); + DrawDialogFrameWithCustomTileAndPalette(windowId, TRUE, tileNum, paletteNum); if (string != gStringVar4) StringExpandPlaceholders(gStringVar4, string); @@ -64,9 +64,9 @@ static void Task_CallYesOrNoCallback(u8 taskId) } } -void CreateYesNoMenuWithCallbacks(u8 taskId, const struct WindowTemplate *template, u8 arg2, u8 arg3, u8 arg4, u16 tileStart, u8 palette, const struct YesNoFuncTable *yesNo) +void CreateYesNoMenuWithCallbacks(u8 taskId, const struct WindowTemplate *template, u8 fontId, u8 left, u8 top, u16 tileStart, u8 palette, const struct YesNoFuncTable *yesNo) { - CreateYesNoMenu(template, arg2, arg3, arg4, tileStart, palette, 0); + CreateYesNoMenu(template, fontId, left, top, tileStart, palette, 0); gUnknown_20399C8 = yesNo; gTasks[taskId].func = Task_CallYesOrNoCallback; } -- cgit v1.2.3 From eb1719afc6e04e0916ba2080fce9685b422980fa Mon Sep 17 00:00:00 2001 From: jiangzhengwenjz Date: Tue, 9 Jul 2019 15:05:58 +0800 Subject: updated menu.h --- src/bag.c | 1 + src/fldeff_softboiled.c | 1 + src/menu2.c | 2 +- src/mevent_8145654.c | 1 + src/oak_speech.c | 18 +++++++++--------- src/quest_log.c | 1 + 6 files changed, 14 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/bag.c b/src/bag.c index 710515099..a63f57702 100644 --- a/src/bag.c +++ b/src/bag.c @@ -6,6 +6,7 @@ #include "window.h" #include "text_window.h" #include "menu_helpers.h" +#include "new_menu_helpers.h" #include "menu.h" #include "money.h" #include "bag.h" diff --git a/src/fldeff_softboiled.c b/src/fldeff_softboiled.c index 67000e315..400a1d382 100644 --- a/src/fldeff_softboiled.c +++ b/src/fldeff_softboiled.c @@ -3,6 +3,7 @@ #include "sound.h" #include "string_util.h" #include "menu.h" +#include "new_menu_helpers.h" #include "constants/songs.h" #include "fldeff.h" diff --git a/src/menu2.c b/src/menu2.c index ffe5865e4..6a3668cfa 100644 --- a/src/menu2.c +++ b/src/menu2.c @@ -504,7 +504,7 @@ void sub_812E6DC(u8 windowId, const u8 * src, u16 x, u16 y) // Yeah, no, I'm not bothering with this NAKED -void sub_819A080(void * a0, void * a1, u16 a2, u16 a3, u16 a4, u16 a5, u16 a6, u16 a7) +static void sub_812E768(void * a0, void * a1, u16 a2, u16 a3, u16 a4, u16 a5, u16 a6, u16 a7) { asm_unified("\tpush {r4-r7,lr}\n" "\tmov r7, r10\n" diff --git a/src/mevent_8145654.c b/src/mevent_8145654.c index de6e1caa5..c67cd1358 100644 --- a/src/mevent_8145654.c +++ b/src/mevent_8145654.c @@ -6,6 +6,7 @@ #include "decompress.h" #include "malloc.h" #include "menu.h" +#include "new_menu_helpers.h" #include "pokemon_icon.h" #include "mystery_gift_menu.h" #include "menu_indicators.h" diff --git a/src/oak_speech.c b/src/oak_speech.c index eb5357e3a..26736604e 100644 --- a/src/oak_speech.c +++ b/src/oak_speech.c @@ -37,7 +37,7 @@ struct OakSpeechResources u16 unk_0010; u16 unk_0012; u16 unk_0014[4]; - u8 unk_001C[3]; + struct TextColor textColor; u8 textSpeed; u8 filler_0020[0x1800]; u8 bg2TilemapBuffer[0x400]; @@ -1056,14 +1056,14 @@ static void Task_OakSpeech19(u8 taskId) PutWindowTilemap(gTasks[taskId].data[13]); DrawStdFrameWithCustomTileAndPalette(gTasks[taskId].data[13], 1, GetStdWindowBaseTileNum(), 14); FillWindowPixelBuffer(gTasks[taskId].data[13], 0x11); - sOakSpeechResources->unk_001C[0] = 1; - sOakSpeechResources->unk_001C[1] = 2; - sOakSpeechResources->unk_001C[2] = 3; - AddTextPrinterParameterized3(gTasks[taskId].data[13], 2, 8, 1, sOakSpeechResources->unk_001C, 0, gText_Boy); - sOakSpeechResources->unk_001C[0] = 1; - sOakSpeechResources->unk_001C[1] = 2; - sOakSpeechResources->unk_001C[2] = 3; - AddTextPrinterParameterized3(gTasks[taskId].data[13], 2, 8, 17, sOakSpeechResources->unk_001C, 0, gText_Girl); + sOakSpeechResources->textColor.fgColor = 1; + sOakSpeechResources->textColor.bgColor = 2; + sOakSpeechResources->textColor.shadowColor = 3; + AddTextPrinterParameterized3(gTasks[taskId].data[13], 2, 8, 1, &sOakSpeechResources->textColor, 0, gText_Boy); + sOakSpeechResources->textColor.fgColor = 1; + sOakSpeechResources->textColor.bgColor = 2; + sOakSpeechResources->textColor.shadowColor = 3; + AddTextPrinterParameterized3(gTasks[taskId].data[13], 2, 8, 17, &sOakSpeechResources->textColor, 0, gText_Girl); Menu_InitCursor(gTasks[taskId].data[13], 2, 0, 1, GetFontAttribute(2, 1) + 2, 2, 0); CopyWindowToVram(gTasks[taskId].data[13], 3); gTasks[taskId].func = Task_OakSpeech20; diff --git a/src/quest_log.c b/src/quest_log.c index d08724a56..0d1cb7984 100644 --- a/src/quest_log.c +++ b/src/quest_log.c @@ -37,6 +37,7 @@ #include "link.h" #include "quest_log_8150454.h" #include "quest_log.h" +#include "new_menu_helpers.h" u8 gUnknown_3005E88; -- cgit v1.2.3 From 05371e58753668147ec9e4d4bd161e5a044c058b Mon Sep 17 00:00:00 2001 From: jiangzhengwenjz Date: Tue, 9 Jul 2019 23:54:05 +0800 Subject: fixed more header issue --- src/menu.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src') diff --git a/src/menu.c b/src/menu.c index ac2e0160b..844878017 100644 --- a/src/menu.c +++ b/src/menu.c @@ -47,8 +47,6 @@ static void WindowFunc_ClearDialogWindowAndFrameNullPalette(u8 bg, u8 tilemapLef static void WindowFunc_DrawStdFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); static void WindowFunc_ClearStdWindowAndFrameToTransparent(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); static u8 MultichoiceGridComputeNewCursorPos(s8 deltaX, s8 deltaY); -u8 Menu_MoveCursor(s8 cursorDelta); -void DestroyYesNoMenu(void); void DrawDialogFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 tileNum, u8 paletteNum) { @@ -213,7 +211,6 @@ void TopBarWindowPrintString(const u8 *string, u8 unUsed, bool8 copyToVram) } } - void TopBarWindowPrintTwoStrings(const u8 *string, const u8 *string2, bool8 fgColorChooser, u8 notUsed, bool8 copyToVram) { struct TextColor color; @@ -308,7 +305,7 @@ static u8 sub_810F818(u8 windowId, u8 fontId, u8 left, u8 top, u8 numChoices, u8 return Menu_InitCursor(windowId, fontId, left, top, GetMenuCursorDimensionByFont(fontId, 1), numChoices, initialCursorPos); } -void RedrawMenuCursor(u8 oldPos, u8 newPos) +static void RedrawMenuCursor(u8 oldPos, u8 newPos) { u8 width, height; @@ -480,9 +477,7 @@ void PrintMultichoiceListItems(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineH u8 i; for (i = 0; i < itemCount; i++) - { AddTextPrinterParameterized5(windowId, fontId, strs[i].text, left, (lineHeight * i) + top, 0xFF, NULL, letterSpacing, lineSpacing); - } CopyWindowToVram(windowId, 2); } -- 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/berry_powder.c | 6 +-- src/coins.c | 7 ++-- src/menu.c | 109 ++----------------------------------------------- src/money.c | 7 ++-- src/new_menu_helpers.c | 7 ++-- 5 files changed, 15 insertions(+), 121 deletions(-) (limited to 'src') diff --git a/src/berry_powder.c b/src/berry_powder.c index 9b50d6abc..9b3bbc17f 100644 --- a/src/berry_powder.c +++ b/src/berry_powder.c @@ -110,13 +110,11 @@ void sub_815F070(void) void sub_815F094(void) { struct WindowTemplate template; - struct WindowTemplate template2; if (sub_81119D4(sub_809D6D4) != TRUE) { - SetWindowTemplateFields(&template, 0, 1, 1, 8, 3, 15, 32); - template2 = template; - gUnknown_203F464 = AddWindow(&template2); + template = SetWindowTemplateFields(0, 1, 1, 8, 3, 15, 32); + gUnknown_203F464 = AddWindow(&template); FillWindowPixelBuffer(gUnknown_203F464, 0); PutWindowTilemap(gUnknown_203F464); TextWindow_SetStdFrame0_WithPal(gUnknown_203F464, 0x21D, 0xD0); diff --git a/src/coins.c b/src/coins.c index a3c074b7c..9de600e7f 100644 --- a/src/coins.c +++ b/src/coins.c @@ -80,11 +80,10 @@ void PrintCoinsString(u32 coinAmount) void ShowCoinsWindow(u32 coinAmount, u8 x, u8 y) { - struct WindowTemplate template, template2; + struct WindowTemplate template; - SetWindowTemplateFields(&template, 0, x + 1, y + 1, 8, 3, 0xF, 0x20); - template2 = template; // again, why... - sCoinsWindowId = AddWindow(&template2); + template = SetWindowTemplateFields(0, x + 1, y + 1, 8, 3, 0xF, 0x20); + sCoinsWindowId = AddWindow(&template); FillWindowPixelBuffer(sCoinsWindowId, 0); PutWindowTilemap(sCoinsWindowId); TextWindow_SetStdFrame0_WithPal(sCoinsWindowId, 0x21D, 0xD0); diff --git a/src/menu.c b/src/menu.c index 844878017..7d7f05032 100644 --- a/src/menu.c +++ b/src/menu.c @@ -519,11 +519,9 @@ static void sub_810FDE4(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, con AddItemMenuActionTextPrinters(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 0, GetFontAttribute(fontId, FONTATTR_LETTER_SPACING), lineHeight, itemCount, strs, orderArray); } -/* -struct WindowTemplateWithAttr SetWindowTemplateFields(struct WindowTemplate *template, u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock) +struct WindowTemplate SetWindowTemplateFields(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock) { struct WindowTemplate temp; - struct WindowTemplateWithAttr ret; temp.bg = bg; temp.tilemapLeft = left; @@ -532,113 +530,14 @@ struct WindowTemplateWithAttr SetWindowTemplateFields(struct WindowTemplate *tem temp.height = height; temp.paletteNum = paletteNum; temp.baseBlock = baseBlock; - *template = temp; - ret.ptr = template; - ret.attr = *((u32*)&temp); - return ret; -} -*/ -NAKED -void SetWindowTemplateFields(struct WindowTemplate *template, u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock) -{ - asm_unified("\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x8\n\ - ldr r4, [sp, 0x28]\n\ - mov r12, r4\n\ - ldr r4, [sp, 0x2C]\n\ - mov r9, r4\n\ - ldr r4, [sp, 0x30]\n\ - mov r10, r4\n\ - ldr r7, [sp, 0x34]\n\ - lsls r1, 24\n\ - lsrs r1, 24\n\ - lsls r2, 24\n\ - lsls r3, 24\n\ - mov r4, r9\n\ - lsls r4, 24\n\ - lsrs r4, 24\n\ - mov r9, r4\n\ - mov r4, r10\n\ - lsls r4, 24\n\ - mov r10, r4\n\ - ldr r4, _0810FEF0 @ =0xffffff00\n\ - mov r8, r4\n\ - mov r5, r8\n\ - ldr r4, [sp]\n\ - ands r5, r4\n\ - orrs r5, r1\n\ - str r5, [sp]\n\ - lsrs r2, 16\n\ - ldr r6, _0810FEF4 @ =0xffff00ff\n\ - adds r4, r6, 0\n\ - ands r4, r5\n\ - orrs r4, r2\n\ - str r4, [sp]\n\ - lsrs r3, 8\n\ - ldr r1, _0810FEF8 @ =0xff00ffff\n\ - ands r1, r4\n\ - orrs r1, r3\n\ - str r1, [sp]\n\ - mov r2, r12\n\ - lsls r2, 24\n\ - mov r12, r2\n\ - ldr r2, _0810FEFC @ =0x00ffffff\n\ - ands r1, r2\n\ - mov r4, r12\n\ - orrs r4, r1\n\ - str r4, [sp]\n\ - ldr r1, [sp, 0x4]\n\ - mov r2, r8\n\ - ands r1, r2\n\ - mov r4, r9\n\ - orrs r1, r4\n\ - mov r8, r1\n\ - str r1, [sp, 0x4]\n\ - mov r1, r10\n\ - lsrs r1, 16\n\ - mov r2, r8\n\ - ands r6, r2\n\ - orrs r6, r1\n\ - str r6, [sp, 0x4]\n\ - lsls r2, r7, 16\n\ - ldr r1, _0810FF00 @ =0x0000ffff\n\ - ands r6, r1\n\ - orrs r6, r2\n\ - str r6, [sp, 0x4]\n\ - ldr r1, [sp]\n\ - ldr r2, [sp, 0x4]\n\ - str r1, [r0]\n\ - str r2, [r0, 0x4]\n\ - add sp, 0x8\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r2}\n\ - bx r2\n\ - .align 2, 0\n\ - _0810FEF0: .4byte 0xffffff00\n\ - _0810FEF4: .4byte 0xffff00ff\n\ - _0810FEF8: .4byte 0xff00ffff\n\ - _0810FEFC: .4byte 0x00ffffff\n\ - _0810FF00: .4byte 0x0000ffff\n\ - "); + return temp; } // not used static u16 CreateWindowTemplate(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock) { - struct WindowTemplate template, temp; - - SetWindowTemplateFields(&template, bg, left, top, width, height, paletteNum, baseBlock); - temp = template; - return (u16)AddWindow(&temp); + struct WindowTemplate template = SetWindowTemplateFields(bg, left, top, width, height, paletteNum, baseBlock); + return AddWindow(&template); } void CreateYesNoMenu(const struct WindowTemplate *window, u8 fontId, u8 left, u8 top, u16 baseTileNum, u8 paletteNum, u8 initialCursorPos) diff --git a/src/money.c b/src/money.c index 616b448e1..39e5aaa32 100644 --- a/src/money.c +++ b/src/money.c @@ -121,11 +121,10 @@ void ChangeAmountInMoneyBox(int amount) void DrawMoneyBox(int amount, u8 x, u8 y) { - struct WindowTemplate template, template2; + struct WindowTemplate template; - SetWindowTemplateFields(&template, 0, x + 1, y + 1, 8, 3, 15, 8); - template2 = template; - sMoneyBoxWindowId = AddWindow(&template2); + template = SetWindowTemplateFields(0, x + 1, y + 1, 8, 3, 15, 8); + sMoneyBoxWindowId = AddWindow(&template); FillWindowPixelBuffer(sMoneyBoxWindowId, 0); PutWindowTilemap(sMoneyBoxWindowId); TextWindow_SetStdFrame0_WithPal(sMoneyBoxWindowId, 0x21D, 0xD0); 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/fldeff_sweetscent.c | 10 +++--- src/menu.c | 96 ++++++++++++++++++++++++------------------------- src/new_menu_helpers.c | 3 +- src/sound.c | 2 +- 4 files changed, 55 insertions(+), 56 deletions(-) (limited to 'src') diff --git a/src/fldeff_sweetscent.c b/src/fldeff_sweetscent.c index 9c6115044..aca56ef4c 100644 --- a/src/fldeff_sweetscent.c +++ b/src/fldeff_sweetscent.c @@ -52,8 +52,8 @@ static void StartSweetScentFieldEffect(void) u8 taskId; PlaySE(SE_W260); - gPaletteDecompressionBuffer = (u8 *)Alloc(0x400); - CpuFastSet(gPlttBufferUnfaded, gPaletteDecompressionBuffer, 0x100); + gUnknown_203AAB0 = (u8 *)Alloc(0x400); + CpuFastSet(gPlttBufferUnfaded, gUnknown_203AAB0, 0x100); CpuFastSet(gPlttBufferFaded, gPlttBufferUnfaded, 0x100); BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 0, 8, RGB(31, 0, 0)); taskId = CreateTask(TrySweetScentEncounter, 0); @@ -72,7 +72,7 @@ static void TrySweetScentEncounter(u8 taskId) data[0] = 0; if (SweetScentWildEncounter() == TRUE) { - Free(gPaletteDecompressionBuffer); + Free(gUnknown_203AAB0); DestroyTask(taskId); } else @@ -92,9 +92,9 @@ static void FailSweetScentEncounter(u8 taskId) { if (!gPaletteFade.active) { - CpuFastSet(gPaletteDecompressionBuffer, gPlttBufferUnfaded, 0x100); + CpuFastSet(gUnknown_203AAB0, gPlttBufferUnfaded, 0x100); sub_807B070(); - Free(gPaletteDecompressionBuffer); + Free(gUnknown_203AAB0); ScriptContext1_SetupScript(EventScript_FailSweetScent); DestroyTask(taskId); } diff --git a/src/menu.c b/src/menu.c index 7d7f05032..e73c73b08 100644 --- a/src/menu.c +++ b/src/menu.c @@ -35,6 +35,12 @@ static EWRAM_DATA u8 sPaletteNum = 0; static EWRAM_DATA u8 sYesNoWindowId = 0; static EWRAM_DATA u8 sTopBarWindowId = 0; +static void WindowFunc_DrawDialogFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); +static void WindowFunc_ClearDialogWindowAndFrameNullPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); +static void WindowFunc_DrawStdFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); +static void WindowFunc_ClearStdWindowAndFrameToTransparent(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); +static u8 MultichoiceGrid_MoveCursor(s8 deltaX, s8 deltaY); + static const struct TextColor gUnknown_8456618 = { .fgColor = 15, @@ -42,12 +48,6 @@ static const struct TextColor gUnknown_8456618 = .shadowColor = 2, }; -static void WindowFunc_DrawDialogFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); -static void WindowFunc_ClearDialogWindowAndFrameNullPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); -static void WindowFunc_DrawStdFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); -static void WindowFunc_ClearStdWindowAndFrameToTransparent(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum); -static u8 MultichoiceGridComputeNewCursorPos(s8 deltaX, s8 deltaY); - void DrawDialogFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 tileNum, u8 paletteNum) { sTileNum = tileNum; @@ -245,7 +245,7 @@ void TopBarWindowPrintTwoStrings(const u8 *string, const u8 *string2, bool8 fgCo } // not used -static void Unused_CopyTopBarWindowToVram(void) +static void CopyTopBarWindowToVram(void) { if (sTopBarWindowId != 0xFF) CopyWindowToVram(sTopBarWindowId, 3); @@ -305,7 +305,7 @@ static u8 sub_810F818(u8 windowId, u8 fontId, u8 left, u8 top, u8 numChoices, u8 return Menu_InitCursor(windowId, fontId, left, top, GetMenuCursorDimensionByFont(fontId, 1), numChoices, initialCursorPos); } -static void RedrawMenuCursor(u8 oldPos, u8 newPos) +static void Menu_RedrawCursor(u8 oldPos, u8 newPos) { u8 width, height; @@ -326,7 +326,7 @@ u8 Menu_MoveCursor(s8 cursorDelta) sMenu.cursorPos = sMenu.minCursorPos; else sMenu.cursorPos += cursorDelta; - RedrawMenuCursor(oldPos, sMenu.cursorPos); + Menu_RedrawCursor(oldPos, sMenu.cursorPos); return sMenu.cursorPos; } @@ -342,7 +342,7 @@ u8 Menu_MoveCursorNoWrapAround(s8 cursorDelta) else sMenu.cursorPos += cursorDelta; - RedrawMenuCursor(oldPos, sMenu.cursorPos); + Menu_RedrawCursor(oldPos, sMenu.cursorPos); return sMenu.cursorPos; } @@ -472,7 +472,7 @@ void PrintTextArray(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 i CopyWindowToVram(windowId, 2); } -void PrintMultichoiceListItems(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, u8 letterSpacing, u8 lineSpacing) +void MultichoiceList_PrintItems(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, u8 letterSpacing, u8 lineSpacing) { u8 i; @@ -521,16 +521,16 @@ static void sub_810FDE4(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, con struct WindowTemplate SetWindowTemplateFields(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock) { - struct WindowTemplate temp; + struct WindowTemplate template; - temp.bg = bg; - temp.tilemapLeft = left; - temp.tilemapTop = top; - temp.width = width; - temp.height = height; - temp.paletteNum = paletteNum; - temp.baseBlock = baseBlock; - return temp; + template.bg = bg; + template.tilemapLeft = left; + template.tilemapTop = top; + template.width = width; + template.height = height; + template.paletteNum = paletteNum; + template.baseBlock = baseBlock; + return template; } // not used @@ -564,7 +564,7 @@ void CreateYesNoMenu(const struct WindowTemplate *window, u8 fontId, u8 left, u8 } // not used -static void Unused_CreateYesNoMenu2(const struct WindowTemplate *window, u8 paletteNum, u16 baseTileNum, u8 initialCursorPos) +static void CreateYesNoMenu2(const struct WindowTemplate *window, u8 paletteNum, u16 baseTileNum, u8 initialCursorPos) { CreateYesNoMenu(window, paletteNum, 0, 0, baseTileNum, initialCursorPos, 0); } @@ -583,7 +583,7 @@ void DestroyYesNoMenu(void) RemoveWindow(sYesNoWindowId); } -void MultichoiceGridPrintItems(u8 windowId, u8 fontId, u8 itemWidth, u8 itemHeight, u8 cols, u8 rows, const struct MenuAction *strs) +void MultichoiceGrid_PrintItems(u8 windowId, u8 fontId, u8 itemWidth, u8 itemHeight, u8 cols, u8 rows, const struct MenuAction *strs) { u8 width, i, j, yOffset; @@ -599,7 +599,7 @@ void MultichoiceGridPrintItems(u8 windowId, u8 fontId, u8 itemWidth, u8 itemHeig } //not used -static void Unused_MultichoiceGridPrintItemsCustomOrder(u8 windowId, u8 fontId, u8 itemWidth, u8 itemHeight, u8 cols, u8 rows, const struct MenuAction *strs, const u8 *orderArray) +static void MultichoiceGrid_PrintItemsCustomOrder(u8 windowId, u8 fontId, u8 itemWidth, u8 itemHeight, u8 cols, u8 rows, const struct MenuAction *strs, const u8 *orderArray) { u8 width, i, j; @@ -613,7 +613,7 @@ static void Unused_MultichoiceGridPrintItemsCustomOrder(u8 windowId, u8 fontId, CopyWindowToVram(windowId, 2); } -static u8 MultichoiceGridInitCursorInternal(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth, u8 cursorHeight, u8 cols, u8 rows, u8 numChoices, u8 cursorPos) +static u8 MultichoiceGrid_InitCursorInternal(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth, u8 cursorHeight, u8 cols, u8 rows, u8 numChoices, u8 cursorPos) { s32 pos; @@ -632,19 +632,19 @@ static u8 MultichoiceGridInitCursorInternal(u8 windowId, u8 fontId, u8 left, u8 sMenu.cursorPos = 0; else sMenu.cursorPos = pos; - MultichoiceGridComputeNewCursorPos(0, 0); + MultichoiceGrid_MoveCursor(0, 0); return sMenu.cursorPos; } -u8 MultichoiceGridInitCursor(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth, u8 cols, u8 rows, u8 cursorPos) +u8 MultichoiceGrid_InitCursor(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth, u8 cols, u8 rows, u8 cursorPos) { s32 cursorHeight = 16; u8 numChoices = cols * rows; - return MultichoiceGridInitCursorInternal(windowId, fontId, left, top, optionWidth, cursorHeight, cols, rows, numChoices, cursorPos); + return MultichoiceGrid_InitCursorInternal(windowId, fontId, left, top, optionWidth, cursorHeight, cols, rows, numChoices, cursorPos); } -static void MultichoiceGridUpdateCursorPos(u8 oldCursorPos, u8 newCursorPos) +static void MultichoiceGrid_RedrawCursor(u8 oldCursorPos, u8 newCursorPos) { u8 cursorWidth = GetMenuCursorDimensionByFont(sMenu.fontId, 0); u8 cursorHeight = GetMenuCursorDimensionByFont(sMenu.fontId, 1); @@ -657,7 +657,7 @@ static void MultichoiceGridUpdateCursorPos(u8 oldCursorPos, u8 newCursorPos) AddTextPrinterParameterized(sMenu.windowId, sMenu.fontId, gFameCheckerText_ListMenuCursor, xPos, yPos, 0, 0); } -static u8 MultichoiceGridComputeNewCursorPos(s8 deltaX, s8 deltaY) +static u8 MultichoiceGrid_MoveCursor(s8 deltaX, s8 deltaY) { u8 oldPos = sMenu.cursorPos; @@ -686,12 +686,12 @@ static u8 MultichoiceGridComputeNewCursorPos(s8 deltaX, s8 deltaY) } else { - MultichoiceGridUpdateCursorPos(oldPos, sMenu.cursorPos); + MultichoiceGrid_RedrawCursor(oldPos, sMenu.cursorPos); return sMenu.cursorPos; } } -static u8 MultichoiceGridComputeNewCursorPosIfValid(s8 deltaX, s8 deltaY) +static u8 MultichoiceGrid_MoveCursorIfValid(s8 deltaX, s8 deltaY) { u8 oldPos = sMenu.cursorPos; @@ -712,7 +712,7 @@ static u8 MultichoiceGridComputeNewCursorPosIfValid(s8 deltaX, s8 deltaY) } else { - MultichoiceGridUpdateCursorPos(oldPos, sMenu.cursorPos); + MultichoiceGrid_RedrawCursor(oldPos, sMenu.cursorPos); return sMenu.cursorPos; } } @@ -732,25 +732,25 @@ static s8 sub_81105A0(void) else if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); - MultichoiceGridComputeNewCursorPos(0, -1); + MultichoiceGrid_MoveCursor(0, -1); return MENU_NOTHING_CHOSEN; } else if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); - MultichoiceGridComputeNewCursorPos(0, 1); + MultichoiceGrid_MoveCursor(0, 1); return MENU_NOTHING_CHOSEN; } else if (JOY_NEW(DPAD_LEFT) || GetLRKeysState() == 1) { PlaySE(SE_SELECT); - MultichoiceGridComputeNewCursorPos(-1, 0); + MultichoiceGrid_MoveCursor(-1, 0); return MENU_NOTHING_CHOSEN; } else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysState() == 2) { PlaySE(SE_SELECT); - MultichoiceGridComputeNewCursorPos(1, 0); + MultichoiceGrid_MoveCursor(1, 0); return MENU_NOTHING_CHOSEN; } return MENU_NOTHING_CHOSEN; @@ -771,25 +771,25 @@ s8 Menu_ProcessInputGridLayout(void) } else if (JOY_NEW(DPAD_UP)) { - if (oldPos != MultichoiceGridComputeNewCursorPosIfValid(0, -1)) + if (oldPos != MultichoiceGrid_MoveCursorIfValid(0, -1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } else if (JOY_NEW(DPAD_DOWN)) { - if (oldPos != MultichoiceGridComputeNewCursorPosIfValid(0, 1)) + if (oldPos != MultichoiceGrid_MoveCursorIfValid(0, 1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } else if (JOY_NEW(DPAD_LEFT) || GetLRKeysState() == 1) { - if (oldPos != MultichoiceGridComputeNewCursorPosIfValid(-1, 0)) + if (oldPos != MultichoiceGrid_MoveCursorIfValid(-1, 0)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysState() == 2) { - if (oldPos != MultichoiceGridComputeNewCursorPosIfValid(1, 0)) + if (oldPos != MultichoiceGrid_MoveCursorIfValid(1, 0)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } @@ -811,25 +811,25 @@ static s8 sub_81106F4(void) else if (JOY_REPT(DPAD_ANY) == DPAD_UP) { PlaySE(SE_SELECT); - MultichoiceGridComputeNewCursorPos(0, -1); + MultichoiceGrid_MoveCursor(0, -1); return MENU_NOTHING_CHOSEN; } else if (JOY_REPT(DPAD_ANY) == DPAD_DOWN) { PlaySE(SE_SELECT); - MultichoiceGridComputeNewCursorPos(0, 1); + MultichoiceGrid_MoveCursor(0, 1); return MENU_NOTHING_CHOSEN; } else if (JOY_REPT(DPAD_ANY) == DPAD_LEFT || sub_80BF66C() == 1) { PlaySE(SE_SELECT); - MultichoiceGridComputeNewCursorPos(-1, 0); + MultichoiceGrid_MoveCursor(-1, 0); return MENU_NOTHING_CHOSEN; } else if (JOY_REPT(DPAD_ANY) == DPAD_RIGHT || sub_80BF66C() == 2) { PlaySE(SE_SELECT); - MultichoiceGridComputeNewCursorPos(1, 0); + MultichoiceGrid_MoveCursor(1, 0); return MENU_NOTHING_CHOSEN; } @@ -852,25 +852,25 @@ static s8 sub_81107A0(void) } else if (JOY_REPT(DPAD_ANY) == DPAD_UP) { - if (oldPos != MultichoiceGridComputeNewCursorPosIfValid(0, -1)) + if (oldPos != MultichoiceGrid_MoveCursorIfValid(0, -1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } else if (JOY_REPT(DPAD_ANY) == DPAD_DOWN) { - if (oldPos != MultichoiceGridComputeNewCursorPosIfValid(0, 1)) + if (oldPos != MultichoiceGrid_MoveCursorIfValid(0, 1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } else if (JOY_REPT(DPAD_ANY) == DPAD_LEFT || sub_80BF66C() == 1) { - if (oldPos != MultichoiceGridComputeNewCursorPosIfValid(-1, 0)) + if (oldPos != MultichoiceGrid_MoveCursorIfValid(-1, 0)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } else if (JOY_REPT(DPAD_ANY) == DPAD_RIGHT || sub_80BF66C() == 2) { - if (oldPos != MultichoiceGridComputeNewCursorPosIfValid(1, 0)) + if (oldPos != MultichoiceGrid_MoveCursorIfValid(1, 0)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } 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); } diff --git a/src/sound.c b/src/sound.c index ba6511d1c..dc4b9f604 100644 --- a/src/sound.c +++ b/src/sound.c @@ -169,7 +169,7 @@ void FadeOutAndFadeInNewMapMusic(u16 songNum, u8 fadeOutSpeed, u8 fadeInSpeed) sMapMusicFadeInSpeed = fadeInSpeed; } -void FadeInNewMapMusic(u16 songNum, u8 speed) +static void FadeInNewMapMusic(u16 songNum, u8 speed) { FadeInNewBGM(songNum, speed); sCurrentMapMusic = songNum; -- cgit v1.2.3 From 9980f358943a44e85f933d7bfe6b69021dedfad2 Mon Sep 17 00:00:00 2001 From: jiangzhengwenjz Date: Fri, 12 Jul 2019 04:44:38 +0800 Subject: trivial fix --- src/menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/menu.c b/src/menu.c index e73c73b08..483790126 100644 --- a/src/menu.c +++ b/src/menu.c @@ -196,7 +196,7 @@ u8 CreateTopBarWindowLoadPalette(u8 bg, u8 width, u8 yPos, u8 palette, u16 baseT return sTopBarWindowId; } -void TopBarWindowPrintString(const u8 *string, u8 unUsed, bool8 copyToVram) +void TopBarWindowPrintString(const u8 *string, u8 unused, bool8 copyToVram) { s32 width; @@ -211,7 +211,7 @@ void TopBarWindowPrintString(const u8 *string, u8 unUsed, bool8 copyToVram) } } -void TopBarWindowPrintTwoStrings(const u8 *string, const u8 *string2, bool8 fgColorChooser, u8 notUsed, bool8 copyToVram) +void TopBarWindowPrintTwoStrings(const u8 *string, const u8 *string2, bool8 fgColorChooser, u8 unused, bool8 copyToVram) { struct TextColor color; s32 fgColor, width; -- cgit v1.2.3 From 7ec965bd24e363381d19139bd15f44093112815b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 12 Jul 2019 22:21:10 -0400 Subject: Port diploma data to C --- src/diploma.c | 75 +++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/diploma.c b/src/diploma.c index 74343e82f..3abef1474 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -15,45 +15,76 @@ #include "scanline_effect.h" #include "sound.h" #include "sprite.h" +#include "strings.h" #include "task.h" #include "text.h" #include "window.h" #include "diploma.h" +struct Diploma +{ + u8 state; + u8 gfxStep; + u8 callbackStep; + u16 tilemapBuffer[0x800]; +}; + +static EWRAM_DATA struct Diploma *gDiploma = NULL; + static void DiplomaBgInit(void); static void DiplomaPrintText(void); static u8 DiplomaLoadGfx(void); static void DiplomaVblankHandler(void); - static void CB2_DiplomaInit(void); - static void Task_WaitForExit(u8); static void Task_DiplomaInit(u8); static void Task_DiplomaReturnToOverworld(u8); -extern const struct BgTemplate gUnknown_8415A08[2]; -extern const struct WindowTemplate gUnknown_8415A10[]; -extern const u8 gUnknown_8402650[]; -extern const u8 gUnknown_841B60E[]; -extern const u8 gUnknown_841B684[]; -extern u8 gUnknown_84147C0[]; -extern u8 gUnknown_8415954[]; -extern u8 gUnknown_841B698[]; -extern u8 gUnknown_841B68F[]; -extern u8 gUnknown_841B619[]; -extern u8 gUnknown_8415A04[]; +static const u32 gUnknown_84147C0[] = INCBIN_U32("graphics/diploma/unk_84147C0.4bpp.lz"); +static const u32 gUnknown_84154E8[] = INCBIN_U32("graphics/diploma/unk_84154E8.bin.lz"); +static const u16 gUnknown_8415954[] = INCBIN_U16("graphics/diploma/unk_8415954.gbapal"); -struct Diploma -{ - u8 state; - u8 gfxStep; - u8 callbackStep; - u16 tilemapBuffer[0x800]; -}; +static const u8 gUnknown_8415994[] = _("{HIGHLIGHT TRANSPARENT}プレイヤー"); +static const u8 gUnknown_841599D[] = _("{HIGHLIGHT TRANSPARENT}さま"); +static const u8 gUnknown_84159A3[] = _("{HIGHLIGHT TRANSPARENT}ホウエン"); +static const u8 gUnknown_84159AB[] = _("{HIGHLIGHT TRANSPARENT}ぜんこく"); +static const u8 gUnknown_84159B3[] = _("{HIGHLIGHT TRANSPARENT}     ポケモンずかんを\nみごと かんせい させた\nいだいなこうせきを たたえ\nここに しょうめい します"); +static const u8 gUnknown_84159ED[] = _("{COLOR RED}{HIGHLIGHT TRANSPARENT}ゲームフリーク"); +static const u8 gUnknown_84159FB[] = _("{COLOR RED}{HIGHLIGHT TRANSPARENT}"); -static EWRAM_DATA struct Diploma *gDiploma = NULL; +static const ALIGNED(4) u8 gUnknown_8415A04[] = {0, 2, 3}; -extern const u32 gUnknown_84154E8[]; +static const struct BgTemplate gUnknown_8415A08[] = { + { + .bg = 0, + .charBaseIndex = 0, + .mapBaseIndex = 31, + .screenSize = 0, + .paletteMode = 0, + .priority = 0, + .baseTile = 1, + }, { + .bg = 1, + .charBaseIndex = 1, + .mapBaseIndex = 29, + .screenSize = 1, + .paletteMode = 0, + .priority = 1, + .baseTile = 0, + } +}; + +static const struct WindowTemplate gUnknown_8415A10[] = { + { + .bg = 0, + .tilemapLeft = 0, + .tilemapTop = 2, + .width = 29, + .height = 16, + .paletteNum = 15, + .baseBlock = 0x000 + }, DUMMY_WIN_TEMPLATE +}; static void VCBC_DiplomaOam(void) { -- cgit v1.2.3 From 19958a35c00e59d9d4f2471ffadcd36f7758b914 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 13 Jul 2019 09:15:20 -0400 Subject: Port cable_car_util from Ruby --- src/cable_car_util.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/cable_car_util.c (limited to 'src') diff --git a/src/cable_car_util.c b/src/cable_car_util.c new file mode 100644 index 000000000..7bad79079 --- /dev/null +++ b/src/cable_car_util.c @@ -0,0 +1,38 @@ +#include "global.h" + +void CableCarUtil_FillWrapped(void *dest, u16 value, u8 left, u8 top, u8 width, u8 height) +{ + u8 i; + u8 j; + u8 x; + u8 y; + + for (i = 0, y = top; i < height; i++) + { + for (x = left, j = 0; j < width; j++) + { + *(u16 *)&((u8 *)dest)[y * 64 + x * 2] = value; + x = (x + 1) % 32; + } + y = (y + 1) % 32; + } +} + +void CableCarUtil_CopyWrapped(void *dest, const u16 *src, u8 left, u8 top, u8 width, u8 height) +{ + u8 i; + u8 j; + u8 x; + u8 y; + const u16 *_src; + + for (i = 0, _src = src, y = top; i < height; i++) + { + for (x = left, j = 0; j < width; j++) + { + *(u16 *)&((u8 *)dest)[y * 64 + x * 2] = *_src++; + x = (x + 1) % 32; + } + y = (y + 1) % 32; + } +} -- cgit v1.2.3 From 7a307c90cfe6e6be6652fd5f5a0fd7f709867773 Mon Sep 17 00:00:00 2001 From: jiangzhengwenjz Date: Sun, 14 Jul 2019 22:48:39 +0800 Subject: align function args --- src/menu.c | 68 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/menu.c b/src/menu.c index 483790126..bef442d84 100644 --- a/src/menu.c +++ b/src/menu.c @@ -73,32 +73,32 @@ static void DrawDialogFrameWithCustomTile(u8 windowId, bool8 copyToVram, u16 til static void WindowFunc_DrawDialogFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) { - FillBgTilemapBufferRect(bg, sTileNum, tilemapLeft - 2, tilemapTop - 1, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 1, tilemapLeft - 1, tilemapTop - 1, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 2, tilemapLeft, tilemapTop - 1, width, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 3, tilemapLeft + width, tilemapTop - 1, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 4, tilemapLeft + width + 1, tilemapTop - 1, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 5, tilemapLeft - 2, tilemapTop, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 6, tilemapLeft - 1, tilemapTop, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 8, tilemapLeft + width, tilemapTop, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 9, tilemapLeft + width + 1, tilemapTop, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 10, tilemapLeft - 2, tilemapTop + 1, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 11, tilemapLeft - 1, tilemapTop + 1, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 12, tilemapLeft + width, tilemapTop + 1, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 13, tilemapLeft + width + 1, tilemapTop + 1, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 10), tilemapLeft - 2, tilemapTop + 2, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 11), tilemapLeft - 1, tilemapTop + 2, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 12), tilemapLeft + width, tilemapTop + 2, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 13), tilemapLeft + width + 1, tilemapTop + 2, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 5), tilemapLeft - 2, tilemapTop + 3, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 6), tilemapLeft - 1, tilemapTop + 3, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 8), tilemapLeft + width, tilemapTop + 3, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 9), tilemapLeft + width + 1, tilemapTop + 3, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum), tilemapLeft - 2, tilemapTop + 4, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 1), tilemapLeft - 1, tilemapTop + 4, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 2), tilemapLeft, tilemapTop + 4, width, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 3), tilemapLeft + width, tilemapTop + 4, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 4), tilemapLeft + width + 1, tilemapTop + 4, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum, tilemapLeft - 2, tilemapTop - 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 1, tilemapLeft - 1, tilemapTop - 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 2, tilemapLeft, tilemapTop - 1, width, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 3, tilemapLeft + width, tilemapTop - 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 4, tilemapLeft + width + 1, tilemapTop - 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 5, tilemapLeft - 2, tilemapTop, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 6, tilemapLeft - 1, tilemapTop, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 8, tilemapLeft + width, tilemapTop, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 9, tilemapLeft + width + 1, tilemapTop, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 10, tilemapLeft - 2, tilemapTop + 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 11, tilemapLeft - 1, tilemapTop + 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 12, tilemapLeft + width, tilemapTop + 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 13, tilemapLeft + width + 1, tilemapTop + 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 10), tilemapLeft - 2, tilemapTop + 2, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 11), tilemapLeft - 1, tilemapTop + 2, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 12), tilemapLeft + width, tilemapTop + 2, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 13), tilemapLeft + width + 1, tilemapTop + 2, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 5), tilemapLeft - 2, tilemapTop + 3, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 6), tilemapLeft - 1, tilemapTop + 3, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 8), tilemapLeft + width, tilemapTop + 3, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 9), tilemapLeft + width + 1, tilemapTop + 3, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum), tilemapLeft - 2, tilemapTop + 4, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 1), tilemapLeft - 1, tilemapTop + 4, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 2), tilemapLeft, tilemapTop + 4, width, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 3), tilemapLeft + width, tilemapTop + 4, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(sTileNum + 4), tilemapLeft + width + 1, tilemapTop + 4, 1, 1, sPaletteNum); } void ClearDialogWindowAndFrameToTransparent(u8 windowId, bool8 copyToVram) @@ -141,14 +141,14 @@ static void DrawStdFrameWithCustomTile(u8 windowId, bool8 copyToVram, u16 baseTi static void WindowFunc_DrawStdFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) { - FillBgTilemapBufferRect(bg, sTileNum, tilemapLeft - 1, tilemapTop - 1, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 1, tilemapLeft, tilemapTop - 1, width, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 2, tilemapLeft + width, tilemapTop - 1, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 3, tilemapLeft - 1, tilemapTop, 1, height, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 5, tilemapLeft + width, tilemapTop, 1, height, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 6, tilemapLeft - 1, tilemapTop + height, 1, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 7, tilemapLeft, tilemapTop + height, width, 1, sPaletteNum); - FillBgTilemapBufferRect(bg, sTileNum + 8, tilemapLeft + width, tilemapTop + height, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum, tilemapLeft - 1, tilemapTop - 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 1, tilemapLeft, tilemapTop - 1, width, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 2, tilemapLeft + width, tilemapTop - 1, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 3, tilemapLeft - 1, tilemapTop, 1, height, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 5, tilemapLeft + width, tilemapTop, 1, height, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 6, tilemapLeft - 1, tilemapTop + height, 1, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 7, tilemapLeft, tilemapTop + height, width, 1, sPaletteNum); + FillBgTilemapBufferRect(bg, sTileNum + 8, tilemapLeft + width, tilemapTop + height, 1, 1, sPaletteNum); } void ClearStdWindowAndFrameToTransparent(u8 windowId, bool8 copyToVram) -- cgit v1.2.3