Merge pull request #429 from tgsm/communication_error

Decompile unk_02033F50 -> communication_error
This commit is contained in:
Akira Akashi
2021-07-10 00:27:50 +01:00
committed by GitHub
10 changed files with 188 additions and 289 deletions
+1 -1
View File
@@ -138,7 +138,7 @@ Static arm9
Object unk_020337E8.o
Object unk_02033874.o
Object unk_02033B68.o
Object unk_02033F50.o
Object communication_error.o
Object wfc_user_info_warning.o
Object map_matrix.o
Object map_header.o
-266
View File
@@ -1,266 +0,0 @@
.include "asm/macros.inc"
.include "global.inc"
.extern gMain
.section .rodata
.global UNK_020EEC9C
UNK_020EEC9C: ; 0x020EEC9C
.byte 0x00, 0x03, 0x03, 0x1A, 0x12, 0x01, 0x23, 0x00
.global UNK_020EECA4
UNK_020EECA4: ; 0x020EECA4
.byte 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.global UNK_020EECB4
UNK_020EECB4: ; 0x020EECB4
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.global UNK_020EECD0
UNK_020EECD0: ; 0x020EECD0
.byte 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.text
thumb_func_start FUN_02033F50
FUN_02033F50: ; 0x02033F50
ldr r3, _02033F64 ; =0x027E0000
ldr r1, _02033F68 ; =0x00003FF8
mov r0, #0x1
ldr r2, [r3, r1]
orr r0, r2
str r0, [r3, r1]
ldr r3, _02033F6C ; =MI_WaitDma
mov r0, #0x3
bx r3
nop
_02033F64: .word 0x027E0000
_02033F68: .word 0x00003FF8
_02033F6C: .word MI_WaitDma
thumb_func_start FUN_02033F70
FUN_02033F70: ; 0x02033F70
push {r3-r7, lr}
sub sp, #0x28
add r4, r0, #0x0
str r2, [sp, #0xc]
cmp r1, #0x4
bhi _02033F92
add r0, r1, r1
add r0, pc
ldrh r0, [r0, #0x6]
lsl r0, r0, #0x10
asr r0, r0, #0x10
add pc, r0
_02033F88: ; jump table (using 16-bit offset)
.short _02033F92 - _02033F88 - 2; case 0
.short _02033F96 - _02033F88 - 2; case 1
.short _02033F9A - _02033F88 - 2; case 2
.short _02033F9E - _02033F88 - 2; case 3
.short _02033FA2 - _02033F88 - 2; case 4
_02033F92:
mov r5, #0x1
b _02033FA4
_02033F96:
mov r5, #0x2
b _02033FA4
_02033F9A:
mov r5, #0x3
b _02033FA4
_02033F9E:
mov r5, #0x4
b _02033FA4
_02033FA2:
mov r5, #0x5
_02033FA4:
mov r0, #0x0
add r1, r0, #0x0
bl FUN_0200E3A0
mov r0, #0x1
mov r1, #0x0
bl FUN_0200E3A0
mov r0, #0x1
bl OS_DisableIrqMask
ldr r1, _02034154 ; =FUN_02033F50
mov r0, #0x1
bl OS_SetIrqFunction
mov r0, #0x1
bl OS_EnableIrqMask
mov r0, #0x0
add r1, r0, #0x0
bl Main_SetVBlankIntrCB
mov r0, #0x0
add r1, r0, #0x0
bl FUN_02015F34
bl GX_DisableEngineALayers
bl GX_DisableEngineBLayers
mov r2, #0x1
lsl r2, r2, #0x1a
ldr r1, [r2, #0x0]
ldr r0, _02034158 ; =0xFFFFE0FF
and r1, r0
str r1, [r2, #0x0]
ldr r2, _0203415C ; =0x04001000
ldr r1, [r2, #0x0]
and r0, r1
str r0, [r2, #0x0]
mov r0, #0x4
mov r1, #0x8
bl SetKeyRepeatTimers
ldr r0, _02034160 ; =gMain + 0x60
mov r1, #0x0
strb r1, [r0, #0x5]
bl GX_SwapDisplay
ldr r3, _02034164 ; =0x04000050
mov r1, #0x0
strh r1, [r3, #0x0]
ldr r0, _02034168 ; =0x04001050
sub r3, #0x50
strh r1, [r0, #0x0]
ldr r2, [r3, #0x0]
ldr r1, _0203416C ; =0xFFFF1FFF
sub r0, #0x50
and r2, r1
str r2, [r3, #0x0]
ldr r2, [r0, #0x0]
and r1, r2
str r1, [r0, #0x0]
ldr r0, _02034170 ; =UNK_020EECD0
bl GX_SetBanks
add r0, r4, #0x0
bl BgConfig_Alloc
add r6, r0, #0x0
ldr r0, _02034174 ; =UNK_020EECA4
bl SetBothScreensModesAndDisable
mov r1, #0x0
ldr r2, _02034178 ; =UNK_020EECB4
add r0, r6, #0x0
add r3, r1, #0x0
bl InitBgFromTemplate
add r0, r6, #0x0
mov r1, #0x0
bl BgClearTilemapBufferAndCommit
mov r1, #0x0
str r1, [sp, #0x0]
ldr r2, _0203417C ; =0x000001F7
add r0, r6, #0x0
mov r3, #0x2
str r4, [sp, #0x4]
bl FUN_0200CB00
mov r0, #0x0
mov r1, #0x20
add r2, r4, #0x0
bl FUN_02002ED0
mov r0, #0x0
mov r1, #0x20
add r2, r0, #0x0
add r3, r4, #0x0
bl BG_ClearCharDataRange
ldr r1, _02034180 ; =0x00006C21
mov r0, #0x0
bl BG_SetMaskColor
ldr r1, _02034180 ; =0x00006C21
mov r0, #0x4
bl BG_SetMaskColor
mov r0, #0x1
mov r1, #0x1a
mov r2, #0xc8
add r3, r4, #0x0
bl NewMsgDataFromNarc
str r0, [sp, #0x10]
mov r0, #0x6
lsl r0, r0, #0x6
add r1, r4, #0x0
bl String_ctor
add r7, r0, #0x0
mov r0, #0x6
lsl r0, r0, #0x6
add r1, r4, #0x0
bl String_ctor
str r0, [sp, #0x14]
bl FUN_0201BD5C
add r0, r4, #0x0
bl ScrStrBufs_new
add r4, r0, #0x0
ldr r2, _02034184 ; =UNK_020EEC9C
add r0, r6, #0x0
add r1, sp, #0x18
bl AddWindow
mov r0, #0xd0
str r0, [sp, #0x0]
mov r0, #0x90
mov r2, #0x0
str r0, [sp, #0x4]
add r0, sp, #0x18
mov r1, #0xf
add r3, r2, #0x0
bl FillWindowPixelRect
ldr r2, _0203417C ; =0x000001F7
add r0, sp, #0x18
mov r1, #0x0
mov r3, #0x2
bl FUN_0200CCA4
mov r0, #0x2
str r0, [sp, #0x0]
mov r0, #0x1
str r0, [sp, #0x4]
ldr r2, [sp, #0xc]
add r0, r4, #0x0
mov r1, #0x0
mov r3, #0x5
bl BufferIntegerAsString
ldr r0, [sp, #0x10]
ldr r2, [sp, #0x14]
add r1, r5, #0x0
bl ReadMsgDataIntoString
ldr r2, [sp, #0x14]
add r0, r4, #0x0
add r1, r7, #0x0
bl StringExpandPlaceholders
mov r1, #0x0
str r1, [sp, #0x0]
str r1, [sp, #0x4]
add r0, sp, #0x18
add r2, r7, #0x0
add r3, r1, #0x0
str r1, [sp, #0x8]
bl AddTextPrinterParameterized
add r0, r7, #0x0
bl String_dtor
bl GX_BothDispOn
mov r0, #0x0
bl FUN_0200E394
mov r0, #0x1
bl FUN_0200E394
mov r0, #0x0
mov r1, #0x3f
mov r2, #0x3
bl FUN_0200A274
add r0, sp, #0x18
bl RemoveWindow
ldr r0, [sp, #0x10]
bl DestroyMsgData
add r0, r4, #0x0
bl ScrStrBufs_delete
add r0, r6, #0x0
bl FreeToHeap
add sp, #0x28
pop {r3-r7, pc}
nop
_02034154: .word FUN_02033F50
_02034158: .word 0xFFFFE0FF
_0203415C: .word 0x04001000
_02034160: .word gMain + 0x60
_02034164: .word 0x04000050
_02034168: .word 0x04001050
_0203416C: .word 0xFFFF1FFF
_02034170: .word UNK_020EECD0
_02034174: .word UNK_020EECA4
_02034178: .word UNK_020EECB4
_0203417C: .word 0x000001F7
_02034180: .word 0x00006C21
_02034184: .word UNK_020EEC9C
+1 -1
View File
@@ -2471,7 +2471,7 @@
.extern FUN_02033EEC
.extern FUN_02033F04
.extern FUN_02033F20
.extern FUN_02033F70
.extern ShowCommunicationError
.extern ShowWFCUserInfoWarning
.extern MapMatrix_New
.extern MapMatrix_Load
+1 -1
View File
@@ -15323,7 +15323,7 @@ _02234FFC:
mov r0, #3
mov r1, #1
mov r2, #0
bl FUN_02033F70
bl ShowCommunicationError
_02235006:
mov r0, #3
pop {r3, r4, r5, pc}
+159
View File
@@ -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);
}
-12
View File
@@ -16,18 +16,6 @@
extern void FUN_02022450(void);
typedef volatile struct
{
u8 sys_and_irq_stack[0x3F80];
u8 svc_stack[0x40];
u8 reserved[0x38];
u32 intr_check;
void * intr_vector;
}
OS_DTCM;
#define DTCM (*(OS_DTCM *)HW_DTCM)
static struct {
void * contents;
u32 name_hash;
+4 -5
View File
@@ -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)
+3 -3
View File
@@ -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)
{
}
+7
View File
@@ -0,0 +1,7 @@
#ifndef POKEDIAMOND_COMMUNICATION_ERROR_H
#define POKEDIAMOND_COMMUNICATION_ERROR_H
void FUN_02033F50(void);
void ShowCommunicationError(u32 heap_id, u32 error, u32 error_code);
#endif
+12
View File
@@ -3,6 +3,18 @@
#include "main.h"
typedef volatile struct
{
u8 sys_and_irq_stack[0x3F80];
u8 svc_stack[0x40];
u8 reserved[0x38];
u32 intr_check;
void * intr_vector;
}
OS_DTCM;
#define DTCM (*(OS_DTCM *)HW_DTCM)
void FUN_02015EA0(void);
void FUN_02015ED4(void);
void FUN_02015EF4(void);