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/diploma.c') 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/diploma.c') 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/diploma.c') 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/diploma.c') 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/diploma.c') 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/diploma.c') 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/diploma.c') 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 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/diploma.c') 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