diff options
author | tgsm <doodrabbit@hotmail.com> | 2021-07-07 06:59:31 -0500 |
---|---|---|
committer | tgsm <doodrabbit@hotmail.com> | 2021-07-07 06:59:31 -0500 |
commit | eef820ba4669a78a62d106ea1ddb0380bd28ef20 (patch) | |
tree | 8e6647f154d64e8e45cf1b874191afb2fe5e4aee /arm9/src | |
parent | d62768df00ac272f38b09e90d0889caa59f7ff73 (diff) |
Decompile unk_02033F50 -> communication_error
Diffstat (limited to 'arm9/src')
-rw-r--r-- | arm9/src/communication_error.c | 159 | ||||
-rw-r--r-- | arm9/src/main.c | 9 | ||||
-rw-r--r-- | arm9/src/unk_02031734.c | 6 |
3 files changed, 166 insertions, 8 deletions
diff --git a/arm9/src/communication_error.c b/arm9/src/communication_error.c new file mode 100644 index 00000000..0ea26458 --- /dev/null +++ b/arm9/src/communication_error.c @@ -0,0 +1,159 @@ +#include "global.h" +#include "bg_window.h" +#include "communication_error.h" +#include "game_init.h" +#include "MI_dma.h" +#include "msgdata.h" +#include "msgdata/msg.naix" +#include "text.h" + +extern void FUN_02002ED0(enum GFBgLayer layer, u32 base_addr, u32 heap_id); +extern void FUN_0200A274(fx32 brightness, fx32, u32); +extern void FUN_0200CB00(struct BgConfig* bg_config, enum GFBgLayer layer, u32 num_tiles, u32, u8, u32 heap_id); +extern void FUN_0200CCA4(struct Window* window, BOOL copy_to_vram, u16 fill_value, u32 palette_num); +extern void FUN_0200E394(BOOL set_brightness_on_bottom_screen); +extern void FUN_0200E3A0(BOOL set_brightness_on_bottom_screen, s32); + +static const struct WindowTemplate sCommunicationErrorWindowTemplate = { + .bgId = GF_BG_LYR_MAIN_0, + .tilemapLeft = 3, + .tilemapTop = 3, + .width = 26, + .height = 18, + .paletteNum = 0x01, + .baseTile = 0x23, +}; + +static const struct GraphicsModes sCommunicationErrorGraphicsModes = { + .dispMode = GX_DISPMODE_GRAPHICS, + .bgMode = GX_BGMODE_0, + .subMode = GX_BGMODE_0, + ._2d3dMode = GX_BG0_AS_2D, +}; + +static const struct BgTemplate sCommunicationErrorBgTemplate = { + .x = 0, + .y = 0, + .bufferSize = 0x800, + .baseTile = 0, + .size = GF_BG_SCR_SIZE_256x256, + .colorMode = GX_BG_COLORMODE_16, + .screenBase = GX_BG_SCRBASE_0x0000, + .charBase = GX_BG_CHARBASE_0x18000, + .bgExtPltt = GX_BG_EXTPLTT_01, + .priority = 1, + .areaOver = GX_BG_AREAOVER_XLU, + .unk17 = 0, + .mosaic = FALSE, +}; + +static const struct GraphicsBanks sCommunicationErrorGraphicsBanks = { + .bg = 3, + .bgextpltt = 0, + .subbg = 0, + .subbgextpltt = 0, + .obj = 0, + .objextpltt = 0, + .subobj = 0, + .subobjextpltt = 0, + .tex = 0, + .texpltt = 0, +}; + +THUMB_FUNC void FUN_02033F50(void) +{ + DTCM.intr_check |= 1; + MI_WaitDma(3); +} + +THUMB_FUNC void ShowCommunicationError(u32 heap_id, u32 error, u32 error_code) +{ + struct Window window; + + u32 error_message_no; + switch (error) + { + default: + case 0: + error_message_no = 1; + break; + case 1: + error_message_no = 2; + break; + case 2: + error_message_no = 3; + break; + case 3: + error_message_no = 4; + break; + case 4: + error_message_no = 5; + break; + } + + FUN_0200E3A0(PM_LCD_TOP, 0); + FUN_0200E3A0(PM_LCD_BOTTOM, 0); + + OS_DisableIrqMask(OS_IE_V_BLANK); + OS_SetIrqFunction(OS_IE_V_BLANK, FUN_02033F50); + OS_EnableIrqMask(OS_IE_V_BLANK); + + Main_SetVBlankIntrCB(NULL, NULL); + FUN_02015F34(NULL, NULL); + + GX_DisableEngineALayers(); + GX_DisableEngineBLayers(); + reg_GX_DISPCNT &= ~REG_GX_DISPCNT_DISPLAY_MASK; + reg_GXS_DB_DISPCNT &= ~REG_GX_DISPCNT_DISPLAY_MASK; + + SetKeyRepeatTimers(4, 8); + + gMain.unk65 = 0; + + GX_SwapDisplay(); + reg_G2_BLDCNT = 0; + reg_G2S_DB_BLDCNT = 0; + reg_GX_DISPCNT &= ~(REG_GX_DISPCNT_OW_MASK | REG_GX_DISPCNT_W1_MASK | REG_GX_DISPCNT_W0_MASK); + reg_GXS_DB_DISPCNT &= ~(REG_GXS_DB_DISPCNT_OW_MASK | REG_GXS_DB_DISPCNT_W1_MASK | REG_GXS_DB_DISPCNT_W0_MASK); + GX_SetBanks(&sCommunicationErrorGraphicsBanks); + + struct BgConfig* bg_config = BgConfig_Alloc(heap_id); + + SetBothScreensModesAndDisable(&sCommunicationErrorGraphicsModes); + + InitBgFromTemplate(bg_config, 0, &sCommunicationErrorBgTemplate, 0); + BgClearTilemapBufferAndCommit(bg_config, 0); + FUN_0200CB00(bg_config, GF_BG_LYR_MAIN_0, 0x01F7, 2, 0, heap_id); + FUN_02002ED0(GF_BG_LYR_MAIN_0, 0x20, heap_id); + BG_ClearCharDataRange(GF_BG_LYR_MAIN_0, 0x20, 0, heap_id); + BG_SetMaskColor(GF_BG_LYR_MAIN_0, 0x6C21); + BG_SetMaskColor(GF_BG_LYR_SUB_0, 0x6C21); + + struct MsgData* error_message_data = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0200_bin, heap_id); + struct String* error_message_str = String_ctor(384, heap_id); + struct String* tmp_str = String_ctor(384, heap_id); + FUN_0201BD5C(); + struct ScrStrBufs* mgr = ScrStrBufs_new(heap_id); + + AddWindow(bg_config, &window, &sCommunicationErrorWindowTemplate); + FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144); + FUN_0200CCA4(&window, FALSE, 0x01F7, 2); + + BufferIntegerAsString(mgr, 0, (s32)error_code, 5, 2, 1); + ReadMsgDataIntoString(error_message_data, error_message_no, tmp_str); + StringExpandPlaceholders(mgr, error_message_str, tmp_str); + + AddTextPrinterParameterized(&window, 0, error_message_str, 0, 0, 0, NULL); + String_dtor(error_message_str); + // BUG: tmp_str is never destroyed. + + GX_BothDispOn(); + FUN_0200E394(PM_LCD_TOP); + FUN_0200E394(PM_LCD_BOTTOM); + FUN_0200A274(0, 0x3F, 3); + + RemoveWindow(&window); + DestroyMsgData(error_message_data); + ScrStrBufs_delete(mgr); + FreeToHeap(bg_config); +} diff --git a/arm9/src/main.c b/arm9/src/main.c index d1a60190..fb4f8707 100644 --- a/arm9/src/main.c +++ b/arm9/src/main.c @@ -5,6 +5,7 @@ #include "CARD_backup.h" #include "CARD_pullOut.h" #include "CTRDG_common.h" +#include "communication_error.h" #include "PAD_pad.h" #include "main.h" #include "game_init.h" @@ -226,21 +227,19 @@ THUMB_FUNC void DoSoftReset(u32 parameter) } while (1); } -extern void FUN_02033F70(int, int, int); - THUMB_FUNC void FUN_02000F4C(u32 arg0, u32 arg1) { if (arg1 == 3) { - FUN_02033F70(0, 3, 0); + ShowCommunicationError(0, 3, 0); } else if (arg0 == 0) { - FUN_02033F70(0, 2, 0); + ShowCommunicationError(0, 2, 0); } else { - FUN_02033F70(0, 0, 0); + ShowCommunicationError(0, 0, 0); } FUN_02032DAC(); while (1) diff --git a/arm9/src/unk_02031734.c b/arm9/src/unk_02031734.c index 7d3b4c03..e6a1514b 100644 --- a/arm9/src/unk_02031734.c +++ b/arm9/src/unk_02031734.c @@ -1,6 +1,7 @@ #include "global.h" #include "unk_02031734.h" #include "MI_memory.h" +#include "communication_error.h" #include "game_init.h" #include "heap.h" #include "player_data.h" @@ -52,7 +53,6 @@ extern void MOD04_021DD6F0(); extern s32 MOD04_021D76AC(); extern MOD05_021D74E0(struct SaveBlock2 *sav2, u32 param1); extern void MOD04_021D83A8(void (*param0)(s32)); -extern void FUN_02033F70(int, int, int); extern void FUN_0200541C(); THUMB_FUNC void FUN_02031734(struct SaveBlock2 *sav2, u8 param1) @@ -2090,7 +2090,7 @@ THUMB_FUNC u8 FUN_020335B8() THUMB_FUNC void FUN_020335D0(s32 param0) { - FUN_02033F70(0, 1, param0); + ShowCommunicationError(0, 1, param0); while (TRUE) { } @@ -2098,7 +2098,7 @@ THUMB_FUNC void FUN_020335D0(s32 param0) THUMB_FUNC void FUN_020335E0() { - FUN_02033F70(0, 4, 0); + ShowCommunicationError(0, 4, 0); while (TRUE) { } |