Decompile save_data_read_error

This commit is contained in:
tgsm 2022-03-06 16:10:22 -06:00
parent 133507626d
commit b5ac907faf
4 changed files with 188 additions and 351 deletions

View File

@ -1,350 +0,0 @@
#include "constants/easy_chat.h"
#include "constants/items.h"
#include "constants/maps.h"
#include "constants/moves.h"
#include "constants/species.h"
.include "asm/macros.inc"
.include "global.inc"
.text
thumb_func_start ShowSaveDataReadError
ShowSaveDataReadError: ; 0x0209263C
push {r3, r4, r5, r6, lr}
sub sp, #0x1c
add r4, r0, #0
mov r0, #0
add r1, r0, #0
bl sub_0200FBF4
mov r0, #1
mov r1, #0
bl sub_0200FBF4
mov r0, #0
add r1, r0, #0
bl Main_SetVBlankIntrCB
mov r0, #0
add r1, r0, #0
bl Main_SetHBlankIntrCB
bl GX_DisableEngineALayers
bl GX_DisableEngineBLayers
mov r2, #1
lsl r2, r2, #0x1a
ldr r1, [r2]
ldr r0, _020927A0 ; =0xFFFFE0FF
and r1, r0
str r1, [r2]
ldr r2, _020927A4 ; =0x04001000
ldr r1, [r2]
and r0, r1
str r0, [r2]
mov r0, #4
mov r1, #8
bl SetKeyRepeatTimers
ldr r0, _020927A8 ; =gSystem + 0x60
mov r1, #0
strb r1, [r0, #9]
bl GX_SwapDisplay
ldr r3, _020927AC ; =0x04000050
mov r0, #0
strh r0, [r3]
ldr r2, _020927B0 ; =0x04001050
sub r3, #0x50
strh r0, [r2]
ldr r1, [r3]
ldr r0, _020927B4 ; =0xFFFF1FFF
sub r2, #0x50
and r1, r0
str r1, [r3]
ldr r1, [r2]
and r0, r1
str r0, [r2]
ldr r0, _020927B8 ; =_021082BC
bl GX_SetBanks
add r0, r4, #0
bl BgConfig_Alloc
add r5, r0, #0
ldr r0, _020927BC ; =_02108290
bl SetBothScreensModesAndDisable
mov r1, #0
ldr r2, _020927C0 ; =_021082A0
add r0, r5, #0
add r3, r1, #0
bl InitBgFromTemplate
add r0, r5, #0
mov r1, #0
bl BgClearTilemapBufferAndCommit
mov r1, #0
str r1, [sp]
ldr r2, _020927C4 ; =0x000001F7
add r0, r5, #0
mov r3, #2
str r4, [sp, #4]
bl sub_0200E3DC
mov r0, #0
mov r1, #0x20
add r2, r4, #0
bl sub_02003030
mov r0, #0
mov r1, #0x20
add r2, r0, #0
add r3, r4, #0
bl BG_ClearCharDataRange
ldr r1, _020927C8 ; =0x00006C21
mov r0, #0
bl BG_SetMaskColor
ldr r1, _020927C8 ; =0x00006C21
mov r0, #4
bl BG_SetMaskColor
mov r0, #1
mov r1, #0x1b
mov r2, #8
add r3, r4, #0
bl NewMsgDataFromNarc
add r6, r0, #0
mov r0, #6
lsl r0, r0, #6
add r1, r4, #0
bl String_ctor
add r4, r0, #0
bl sub_02020080
ldr r2, _020927CC ; =_02108288
add r0, r5, #0
add r1, sp, #0xc
bl AddWindow
mov r0, #0xd0
str r0, [sp]
mov r0, #0x90
mov r2, #0
str r0, [sp, #4]
add r0, sp, #0xc
mov r1, #0xf
add r3, r2, #0
bl FillWindowPixelRect
ldr r2, _020927C4 ; =0x000001F7
add r0, sp, #0xc
mov r1, #0
mov r3, #2
bl DrawFrameAndWindow1
add r0, r6, #0
mov r1, #0
add r2, r4, #0
bl ReadMsgDataIntoString
mov r1, #0
str r1, [sp]
str r1, [sp, #4]
add r0, sp, #0xc
add r2, r4, #0
add r3, r1, #0
str r1, [sp, #8]
bl AddTextPrinterParameterized
add r0, r4, #0
bl String_dtor
bl GX_BothDispOn
mov r0, #0
bl SetMasterBrightnessNeutral
mov r0, #1
bl SetMasterBrightnessNeutral
mov r0, #0
mov r1, #0x3f
mov r2, #3
bl SetBlendBrightness
mov r4, #1
_02092790:
bl HandleDSLidAction
add r0, r4, #0
add r1, r4, #0
bl OS_WaitIrq
b _02092790
nop
_020927A0: .word 0xFFFFE0FF
_020927A4: .word 0x04001000
_020927A8: .word gSystem + 0x60
_020927AC: .word 0x04000050
_020927B0: .word 0x04001050
_020927B4: .word 0xFFFF1FFF
_020927B8: .word _021082BC
_020927BC: .word _02108290
_020927C0: .word _021082A0
_020927C4: .word 0x000001F7
_020927C8: .word 0x00006C21
_020927CC: .word _02108288
thumb_func_end ShowSaveDataReadError
thumb_func_start ShowGBACartRemovedError
ShowGBACartRemovedError: ; 0x020927D0
push {r3, r4, r5, r6, lr}
sub sp, #0x1c
add r4, r0, #0
mov r0, #0
add r1, r0, #0
bl sub_0200FBF4
mov r0, #1
mov r1, #0
bl sub_0200FBF4
mov r0, #0
add r1, r0, #0
bl Main_SetVBlankIntrCB
mov r0, #0
add r1, r0, #0
bl Main_SetHBlankIntrCB
bl GX_DisableEngineALayers
bl GX_DisableEngineBLayers
mov r2, #1
lsl r2, r2, #0x1a
ldr r1, [r2]
ldr r0, _02092934 ; =0xFFFFE0FF
and r1, r0
str r1, [r2]
ldr r2, _02092938 ; =0x04001000
ldr r1, [r2]
and r0, r1
str r0, [r2]
mov r0, #4
mov r1, #8
bl SetKeyRepeatTimers
ldr r0, _0209293C ; =gSystem + 0x60
mov r1, #0
strb r1, [r0, #9]
bl GX_SwapDisplay
ldr r3, _02092940 ; =0x04000050
mov r0, #0
strh r0, [r3]
ldr r2, _02092944 ; =0x04001050
sub r3, #0x50
strh r0, [r2]
ldr r1, [r3]
ldr r0, _02092948 ; =0xFFFF1FFF
sub r2, #0x50
and r1, r0
str r1, [r3]
ldr r1, [r2]
and r0, r1
str r0, [r2]
ldr r0, _0209294C ; =_021082BC
bl GX_SetBanks
add r0, r4, #0
bl BgConfig_Alloc
add r5, r0, #0
ldr r0, _02092950 ; =_02108290
bl SetBothScreensModesAndDisable
mov r1, #0
ldr r2, _02092954 ; =_021082A0
add r0, r5, #0
add r3, r1, #0
bl InitBgFromTemplate
add r0, r5, #0
mov r1, #0
bl BgClearTilemapBufferAndCommit
mov r1, #0
str r1, [sp]
ldr r2, _02092958 ; =0x000001F7
add r0, r5, #0
mov r3, #2
str r4, [sp, #4]
bl sub_0200E3DC
mov r0, #0
mov r1, #0x20
add r2, r4, #0
bl sub_02003030
mov r0, #0
mov r1, #0x20
add r2, r0, #0
add r3, r4, #0
bl BG_ClearCharDataRange
ldr r1, _0209295C ; =0x00006C21
mov r0, #0
bl BG_SetMaskColor
ldr r1, _0209295C ; =0x00006C21
mov r0, #4
bl BG_SetMaskColor
mov r0, #1
mov r1, #0x1b
mov r2, #8
add r3, r4, #0
bl NewMsgDataFromNarc
add r6, r0, #0
mov r0, #6
lsl r0, r0, #6
add r1, r4, #0
bl String_ctor
add r4, r0, #0
bl sub_02020080
ldr r2, _02092960 ; =_02108288
add r0, r5, #0
add r1, sp, #0xc
bl AddWindow
mov r0, #0xd0
str r0, [sp]
mov r0, #0x90
mov r2, #0
str r0, [sp, #4]
add r0, sp, #0xc
mov r1, #0xf
add r3, r2, #0
bl FillWindowPixelRect
ldr r2, _02092958 ; =0x000001F7
add r0, sp, #0xc
mov r1, #0
mov r3, #2
bl DrawFrameAndWindow1
add r0, r6, #0
mov r1, #1
add r2, r4, #0
bl ReadMsgDataIntoString
mov r1, #0
str r1, [sp]
str r1, [sp, #4]
add r0, sp, #0xc
add r2, r4, #0
add r3, r1, #0
str r1, [sp, #8]
bl AddTextPrinterParameterized
add r0, r4, #0
bl String_dtor
bl GX_BothDispOn
mov r0, #0
bl SetMasterBrightnessNeutral
mov r0, #1
bl SetMasterBrightnessNeutral
mov r0, #0
mov r1, #0x3f
mov r2, #3
bl SetBlendBrightness
mov r4, #1
_02092924:
bl HandleDSLidAction
add r0, r4, #0
add r1, r4, #0
bl OS_WaitIrq
b _02092924
nop
_02092934: .word 0xFFFFE0FF
_02092938: .word 0x04001000
_0209293C: .word gSystem + 0x60
_02092940: .word 0x04000050
_02092944: .word 0x04001050
_02092948: .word 0xFFFF1FFF
_0209294C: .word _021082BC
_02092950: .word _02108290
_02092954: .word _021082A0
_02092958: .word 0x000001F7
_0209295C: .word 0x00006C21
_02092960: .word _02108288
thumb_func_end ShowGBACartRemovedError
.rodata
; File boundary
_02108288:
.byte 0x00, 0x03, 0x03, 0x1A, 0x12, 0x01
.short 0x0023
_02108290:
.byte 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
_021082A0:
.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
_021082BC:
.byte 0x03, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00

View File

@ -4,5 +4,6 @@
#include "heap.h"
void ShowSaveDataReadError(HeapID heapId);
void ShowGBACartRemovedError(HeapID heapId);
#endif //POKEHEARTGOLD_SAVE_DATA_READ_ERROR_H

View File

@ -290,7 +290,7 @@ Static main
Object asm/unk_02091880.o
Object asm/unk_02091CDC.o
Object asm/unk_020921A4.o
Object asm/save_data_read_error.o
Object src/save_data_read_error.o
Object asm/save_data_write_error.o
Object asm/unk_02092B04.o
Object asm/unk_02092BB8.o

186
src/save_data_read_error.c Normal file
View File

@ -0,0 +1,186 @@
#include <nitro/gx/g2.h>
#include <nitro/gx/gx_bgcnt.h>
#include "gx_layers.h"
#include "main.h"
#include "msgdata.h"
#include "msgdata/msg.naix"
#include "msgdata/msg/msg_0008.h"
#include "pm_string.h"
#include "save_data_read_error.h"
#include "system.h"
#include "unk_0200FA24.h"
#include "window.h"
extern void sub_0200E3DC(BGCONFIG* bg_config, enum GFBgLayer layer, u32 a2, u32 a3, u32 a4, HeapID heap_id);
extern void sub_02003030(enum GFBgLayer layer, u32 base_addr, HeapID heap_id);
extern void sub_02020080(void);
extern void DrawFrameAndWindow1(WINDOW* window, BOOL dont_copy_to_vram, u16 a2, u8 palette_num);
extern u16 AddTextPrinterParameterized(WINDOW* window, u8 font_id, STRING* text, u32 x, u32 y, u32 speed, void* callback);
extern void SetMasterBrightnessNeutral(u32 a0);
extern void SetBlendBrightness(fx32 brightness, fx32 surface_mask, u32 screen_mask);
static const GF_GXBanksConfig sDataReadErrorBanksConfig = {
.bg = GX_VRAM_BG_256_AB,
.bgextpltt = GX_VRAM_BGEXTPLTT_NONE,
.subbg = GX_VRAM_SUB_BG_NONE,
.subbgextpltt = GX_VRAM_SUB_BGEXTPLTT_NONE,
.obj = GX_VRAM_OBJ_NONE,
.objextpltt = GX_VRAM_OBJEXTPLTT_NONE,
.subobj = GX_VRAM_SUB_OBJ_NONE,
.subobjextpltt = GX_VRAM_SUB_OBJEXTPLTT_NONE,
.tex = GX_VRAM_TEX_NONE,
.texpltt = GX_VRAM_TEXPLTT_NONE,
};
static const struct GFBgModeSet sDataReadErrorBgModeSet = {
.dispMode = GX_DISPMODE_GRAPHICS,
.bgModeMain = GX_BGMODE_0,
.bgModeSub = GX_BGMODE_0,
._2d3dSwitch = GX_BG0_AS_2D,
};
static const BGTEMPLATE sDataReadErrorBgTemplate = {
.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,
.dummy = 0,
.mosaic = FALSE,
};
static const WINDOWTEMPLATE sDataReadErrorWindowTemplate = {
.bgId = 0,
.left = 3,
.top = 3,
.width = 26,
.height = 18,
.palette = 1,
.baseBlock = 0x23,
};
void ShowSaveDataReadError(HeapID heap_id) {
WINDOW window;
sub_0200FBF4(0, 0);
sub_0200FBF4(1, 0);
Main_SetVBlankIntrCB(NULL, NULL);
Main_SetHBlankIntrCB(NULL, NULL);
GX_DisableEngineALayers();
GX_DisableEngineBLayers();
GX_SetVisiblePlane(0);
GXS_SetVisiblePlane(0);
SetKeyRepeatTimers(4, 8);
gSystem.screensFlipped = FALSE;
GX_SwapDisplay();
G2_BlendNone();
G2S_BlendNone();
// TODO: are there SDK functions for these?
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(&sDataReadErrorBanksConfig);
BGCONFIG* bg_config = BgConfig_Alloc(heap_id);
SetBothScreensModesAndDisable(&sDataReadErrorBgModeSet);
InitBgFromTemplate(bg_config, 0, &sDataReadErrorBgTemplate, GX_BGMODE_0);
BgClearTilemapBufferAndCommit(bg_config, GF_BG_LYR_MAIN_0);
sub_0200E3DC(bg_config, GF_BG_LYR_MAIN_0, 0x1F7, 2, 0, heap_id);
sub_02003030(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, RGB(1, 1, 27));
BG_SetMaskColor(GF_BG_LYR_SUB_0, RGB(1, 1, 27));
MSGDATA* error_msgdata = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_msgdata_msg, NARC_msg_msg_0008_bin, heap_id);
STRING* error_str = String_ctor(384, heap_id);
sub_02020080();
AddWindow(bg_config, &window, &sDataReadErrorWindowTemplate);
FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144);
DrawFrameAndWindow1(&window, FALSE, 0x1F7, 2);
ReadMsgDataIntoString(error_msgdata, msg_0008_00000, error_str);
AddTextPrinterParameterized(&window, 0, error_str, 0, 0, 0, NULL);
String_dtor(error_str);
GX_BothDispOn();
SetMasterBrightnessNeutral(0);
SetMasterBrightnessNeutral(1);
SetBlendBrightness(0, 0x3F, 3);
while (TRUE) {
HandleDSLidAction();
OS_WaitIrq(TRUE, OS_IE_V_BLANK);
}
}
void ShowGBACartRemovedError(HeapID heap_id) {
WINDOW window;
sub_0200FBF4(0, 0);
sub_0200FBF4(1, 0);
Main_SetVBlankIntrCB(NULL, NULL);
Main_SetHBlankIntrCB(NULL, NULL);
GX_DisableEngineALayers();
GX_DisableEngineBLayers();
GX_SetVisiblePlane(0);
GXS_SetVisiblePlane(0);
SetKeyRepeatTimers(4, 8);
gSystem.screensFlipped = FALSE;
GX_SwapDisplay();
G2_BlendNone();
G2S_BlendNone();
// TODO: are there SDK functions for these?
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(&sDataReadErrorBanksConfig);
BGCONFIG* bg_config = BgConfig_Alloc(heap_id);
SetBothScreensModesAndDisable(&sDataReadErrorBgModeSet);
InitBgFromTemplate(bg_config, 0, &sDataReadErrorBgTemplate, GX_BGMODE_0);
BgClearTilemapBufferAndCommit(bg_config, GF_BG_LYR_MAIN_0);
sub_0200E3DC(bg_config, GF_BG_LYR_MAIN_0, 0x1F7, 2, 0, heap_id);
sub_02003030(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, RGB(1, 1, 27));
BG_SetMaskColor(GF_BG_LYR_SUB_0, RGB(1, 1, 27));
MSGDATA* error_msgdata = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_msgdata_msg, NARC_msg_msg_0008_bin, heap_id);
STRING* error_str = String_ctor(384, heap_id);
sub_02020080();
AddWindow(bg_config, &window, &sDataReadErrorWindowTemplate);
FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144);
DrawFrameAndWindow1(&window, FALSE, 0x1F7, 2);
ReadMsgDataIntoString(error_msgdata, msg_0008_00001, error_str);
AddTextPrinterParameterized(&window, 0, error_str, 0, 0, 0, NULL);
String_dtor(error_str);
GX_BothDispOn();
SetMasterBrightnessNeutral(0);
SetMasterBrightnessNeutral(1);
SetBlendBrightness(0, 0x3F, 3);
while (TRUE) {
HandleDSLidAction();
OS_WaitIrq(TRUE, OS_IE_V_BLANK);
}
}