mirror of
https://github.com/pret/pokeheartgold.git
synced 2024-11-27 15:10:26 +00:00
Decompile error_message_reset
This commit is contained in:
parent
8e2195abec
commit
183344fc87
@ -1,291 +0,0 @@
|
||||
#include "constants/easy_chat.h"
|
||||
#include "constants/items.h"
|
||||
#include "constants/maps.h"
|
||||
#include "constants/moves.h"
|
||||
#include "constants/species.h"
|
||||
#include "msgdata/msg/msg_0041.h"
|
||||
.include "asm/macros.inc"
|
||||
.include "global.inc"
|
||||
|
||||
.bss
|
||||
|
||||
_021D43B4:
|
||||
.space 4
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start sub_02096318
|
||||
sub_02096318: ; 0x02096318
|
||||
ldr r3, _0209632C ; =OS_IRQTable
|
||||
ldr r1, _02096330 ; =0x00003FF8
|
||||
mov r0, #1
|
||||
ldr r2, [r3, r1]
|
||||
orr r0, r2
|
||||
str r0, [r3, r1]
|
||||
ldr r3, _02096334 ; =MI_WaitDma
|
||||
mov r0, #3
|
||||
bx r3
|
||||
nop
|
||||
_0209632C: .word OS_IRQTable
|
||||
_02096330: .word 0x00003FF8
|
||||
_02096334: .word MI_WaitDma
|
||||
thumb_func_end sub_02096318
|
||||
|
||||
thumb_func_start PrintErrorMessageAndReset
|
||||
PrintErrorMessageAndReset: ; 0x02096338
|
||||
push {r4, r5, r6, r7, lr}
|
||||
sub sp, #0x24
|
||||
ldr r0, _02096548 ; =_021D43B4
|
||||
ldr r1, [r0]
|
||||
cmp r1, #1
|
||||
bne _02096346
|
||||
b _02096544
|
||||
_02096346:
|
||||
mov r1, #1
|
||||
str r1, [r0]
|
||||
mov r0, #0
|
||||
bl OS_GetInitArenaHi
|
||||
add r1, r0, #0
|
||||
mov r0, #0
|
||||
bl OS_SetArenaHi
|
||||
mov r0, #0
|
||||
bl OS_GetInitArenaLo
|
||||
add r1, r0, #0
|
||||
mov r0, #0
|
||||
bl OS_SetArenaLo
|
||||
mov r1, #1
|
||||
ldr r0, _0209654C ; =_02108528
|
||||
add r2, r1, #0
|
||||
mov r3, #0
|
||||
bl InitHeapSystem
|
||||
mov r0, #0
|
||||
add r1, r0, #0
|
||||
bl sub_0200FBF4
|
||||
mov r0, #1
|
||||
mov r1, #0
|
||||
bl sub_0200FBF4
|
||||
mov r0, #1
|
||||
bl OS_DisableIrqMask
|
||||
ldr r1, _02096550 ; =sub_02096318
|
||||
mov r0, #1
|
||||
bl OS_SetIrqFunction
|
||||
mov r0, #1
|
||||
bl OS_EnableIrqMask
|
||||
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, _02096554 ; =0xFFFFE0FF
|
||||
and r1, r0
|
||||
str r1, [r2]
|
||||
ldr r2, _02096558 ; =0x04001000
|
||||
ldr r1, [r2]
|
||||
and r0, r1
|
||||
str r0, [r2]
|
||||
mov r0, #4
|
||||
mov r1, #8
|
||||
bl SetKeyRepeatTimers
|
||||
ldr r0, _0209655C ; =gSystem + 0x60
|
||||
mov r1, #0
|
||||
strb r1, [r0, #9]
|
||||
bl GX_SwapDisplay
|
||||
ldr r3, _02096560 ; =0x04000050
|
||||
mov r0, #0
|
||||
strh r0, [r3]
|
||||
ldr r2, _02096564 ; =0x04001050
|
||||
sub r3, #0x50
|
||||
strh r0, [r2]
|
||||
ldr r1, [r3]
|
||||
ldr r0, _02096568 ; =0xFFFF1FFF
|
||||
sub r2, #0x50
|
||||
and r1, r0
|
||||
str r1, [r3]
|
||||
ldr r1, [r2]
|
||||
and r0, r1
|
||||
str r0, [r2]
|
||||
ldr r0, _0209656C ; =_0210855C
|
||||
bl GX_SetBanks
|
||||
mov r0, #0
|
||||
bl BgConfig_Alloc
|
||||
str r0, [sp, #0x10]
|
||||
ldr r0, _02096570 ; =_02108530
|
||||
bl SetBothScreensModesAndDisable
|
||||
mov r1, #0
|
||||
ldr r0, [sp, #0x10]
|
||||
ldr r2, _02096574 ; =_02108540
|
||||
add r3, r1, #0
|
||||
bl InitBgFromTemplate
|
||||
ldr r0, [sp, #0x10]
|
||||
mov r1, #0
|
||||
bl BgClearTilemapBufferAndCommit
|
||||
mov r1, #0
|
||||
str r1, [sp]
|
||||
ldr r0, [sp, #0x10]
|
||||
ldr r2, _02096578 ; =0x000001F7
|
||||
mov r3, #2
|
||||
str r1, [sp, #4]
|
||||
bl sub_0200E3DC
|
||||
mov r0, #0
|
||||
mov r1, #0x20
|
||||
add r2, r0, #0
|
||||
bl sub_02003030
|
||||
mov r0, #0
|
||||
mov r1, #0x20
|
||||
add r2, r0, #0
|
||||
add r3, r0, #0
|
||||
bl BG_ClearCharDataRange
|
||||
ldr r1, _0209657C ; =0x00006C21
|
||||
mov r0, #0
|
||||
bl BG_SetMaskColor
|
||||
ldr r1, _0209657C ; =0x00006C21
|
||||
mov r0, #4
|
||||
bl BG_SetMaskColor
|
||||
mov r0, #1
|
||||
mov r1, #0x1b
|
||||
mov r2, #0x29
|
||||
mov r3, #0
|
||||
bl NewMsgDataFromNarc
|
||||
str r0, [sp, #0xc]
|
||||
mov r0, #6
|
||||
lsl r0, r0, #6
|
||||
mov r1, #0
|
||||
bl String_ctor
|
||||
add r4, r0, #0
|
||||
bl sub_02020080
|
||||
ldr r0, [sp, #0x10]
|
||||
ldr r2, _02096580 ; =_02108520
|
||||
add r1, sp, #0x14
|
||||
bl AddWindow
|
||||
mov r0, #0xd0
|
||||
str r0, [sp]
|
||||
mov r0, #0x90
|
||||
mov r2, #0
|
||||
str r0, [sp, #4]
|
||||
add r0, sp, #0x14
|
||||
mov r1, #0xf
|
||||
add r3, r2, #0
|
||||
bl FillWindowPixelRect
|
||||
ldr r2, _02096578 ; =0x000001F7
|
||||
add r0, sp, #0x14
|
||||
mov r1, #0
|
||||
mov r3, #2
|
||||
bl DrawFrameAndWindow1
|
||||
ldr r0, [sp, #0xc]
|
||||
mov r1, #msg_0041_00003
|
||||
add r2, r4, #0
|
||||
bl ReadMsgDataIntoString
|
||||
mov r1, #0
|
||||
str r1, [sp]
|
||||
str r1, [sp, #4]
|
||||
add r0, sp, #0x14
|
||||
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
|
||||
bl sub_02038D90
|
||||
mov r4, #1
|
||||
_020964D8:
|
||||
bl HandleDSLidAction
|
||||
bl sub_02036144
|
||||
bl sub_02039AA4
|
||||
cmp r0, #0
|
||||
bne _020964F2
|
||||
add r0, r4, #0
|
||||
add r1, r4, #0
|
||||
bl OS_WaitIrq
|
||||
b _020964D8
|
||||
_020964F2:
|
||||
ldr r5, _02096584 ; =0x04000130
|
||||
ldr r4, _02096588 ; =0x027FFFA8
|
||||
ldr r7, _0209658C ; =0x00002FFF
|
||||
mov r6, #1
|
||||
_020964FA:
|
||||
bl HandleDSLidAction
|
||||
ldrh r1, [r5]
|
||||
ldrh r0, [r4]
|
||||
orr r1, r0
|
||||
ldr r0, _0209658C ; =0x00002FFF
|
||||
eor r0, r1
|
||||
and r0, r7
|
||||
lsl r0, r0, #0x10
|
||||
lsr r0, r0, #0x10
|
||||
tst r0, r6
|
||||
bne _0209651C
|
||||
mov r0, #1
|
||||
add r1, r0, #0
|
||||
bl OS_WaitIrq
|
||||
b _020964FA
|
||||
_0209651C:
|
||||
ldr r1, _02096590 ; =0x00007FFF
|
||||
mov r0, #0
|
||||
bl sub_0200FBF4
|
||||
ldr r1, _02096590 ; =0x00007FFF
|
||||
mov r0, #1
|
||||
bl sub_0200FBF4
|
||||
add r0, sp, #0x14
|
||||
bl RemoveWindow
|
||||
ldr r0, [sp, #0xc]
|
||||
bl DestroyMsgData
|
||||
ldr r0, [sp, #0x10]
|
||||
bl FreeToHeap
|
||||
mov r0, #0
|
||||
bl OS_ResetSystem
|
||||
_02096544:
|
||||
add sp, #0x24
|
||||
pop {r4, r5, r6, r7, pc}
|
||||
.balign 4, 0
|
||||
_02096548: .word _021D43B4
|
||||
_0209654C: .word _02108528
|
||||
_02096550: .word sub_02096318
|
||||
_02096554: .word 0xFFFFE0FF
|
||||
_02096558: .word 0x04001000
|
||||
_0209655C: .word gSystem + 0x60
|
||||
_02096560: .word 0x04000050
|
||||
_02096564: .word 0x04001050
|
||||
_02096568: .word 0xFFFF1FFF
|
||||
_0209656C: .word _0210855C
|
||||
_02096570: .word _02108530
|
||||
_02096574: .word _02108540
|
||||
_02096578: .word 0x000001F7
|
||||
_0209657C: .word 0x00006C21
|
||||
_02096580: .word _02108520
|
||||
_02096584: .word 0x04000130
|
||||
_02096588: .word 0x027FFFA8
|
||||
_0209658C: .word 0x00002FFF
|
||||
_02096590: .word 0x00007FFF
|
||||
thumb_func_end PrintErrorMessageAndReset
|
||||
|
||||
.rodata
|
||||
|
||||
_02108520:
|
||||
.byte 0x00, 0x03, 0x03, 0x1A, 0x12, 0x01, 0x23, 0x00
|
||||
_02108528:
|
||||
.byte 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
_02108530:
|
||||
.byte 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
_02108540:
|
||||
.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
|
||||
_0210855C:
|
||||
.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
|
6
include/error_message_reset.h
Normal file
6
include/error_message_reset.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef POKEHEARTGOLD_ERROR_MESSAGE_RESET_H
|
||||
#define POKEHEARTGOLD_ERROR_MESSAGE_RESET_H
|
||||
|
||||
void PrintErrorMessageAndReset(void);
|
||||
|
||||
#endif //POKEHEARTGOLD_ERROR_MESSAGE_RESET_H
|
2
main.lsf
2
main.lsf
@ -300,7 +300,7 @@ Static main
|
||||
Object asm/unk_020932E0.o
|
||||
Object asm/unk_020957B0.o
|
||||
Object asm/unk_02095DF4.o
|
||||
Object asm/error_message_reset.o
|
||||
Object src/error_message_reset.o
|
||||
Object src/sin_vcount.o
|
||||
Object asm/unk_020965A4.o
|
||||
Object asm/unk_020968B0.o
|
||||
|
182
src/error_message_reset.c
Normal file
182
src/error_message_reset.c
Normal file
@ -0,0 +1,182 @@
|
||||
#include <nitro/gx/g2.h>
|
||||
#include <nitro/gx/gx_bgcnt.h>
|
||||
#include <nitro/pad/common/pad.h>
|
||||
#include "error_message_reset.h"
|
||||
#include "gx_layers.h"
|
||||
#include "main.h"
|
||||
#include "msgdata.h"
|
||||
#include "msgdata/msg.naix"
|
||||
#include "msgdata/msg/msg_0041.h"
|
||||
#include "pm_string.h"
|
||||
#include "system.h"
|
||||
#include "unk_0200FA24.h"
|
||||
#include "unk_02035900.h"
|
||||
#include "unk_02037C94.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 sErrorMessageBanksConfig = {
|
||||
.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 sErrorMessageBgModeSet = {
|
||||
.dispMode = GX_DISPMODE_GRAPHICS,
|
||||
.bgModeMain = GX_BGMODE_0,
|
||||
.bgModeSub = GX_BGMODE_0,
|
||||
._2d3dSwitch = GX_BG0_AS_2D,
|
||||
};
|
||||
|
||||
static const BGTEMPLATE sErrorMessageBgTemplate = {
|
||||
.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 sErrorMessageWindowTemplate = {
|
||||
.bgId = 0,
|
||||
.left = 3,
|
||||
.top = 3,
|
||||
.width = 26,
|
||||
.height = 18,
|
||||
.palette = 1,
|
||||
.baseBlock = 0x23,
|
||||
};
|
||||
|
||||
static const HEAP_PARAM sErrorMessageHeapParams = {
|
||||
.size = 0x20000,
|
||||
.arena = OS_ARENA_MAIN,
|
||||
};
|
||||
|
||||
static BOOL sErrorMessagePrinterLock;
|
||||
|
||||
static void VBlankIntr() {
|
||||
OS_SetIrqCheckFlag(OS_IE_VBLANK);
|
||||
MI_WaitDma(3);
|
||||
}
|
||||
|
||||
void PrintErrorMessageAndReset(void) {
|
||||
WINDOW window;
|
||||
|
||||
if (sErrorMessagePrinterLock == TRUE) {
|
||||
return;
|
||||
}
|
||||
|
||||
sErrorMessagePrinterLock = TRUE;
|
||||
|
||||
OS_SetArenaHi(OS_ARENA_MAIN, OS_GetInitArenaHi(OS_ARENA_MAIN));
|
||||
OS_SetArenaLo(OS_ARENA_MAIN, OS_GetInitArenaLo(OS_ARENA_MAIN));
|
||||
InitHeapSystem(&sErrorMessageHeapParams, 1, 1, 0);
|
||||
|
||||
sub_0200FBF4(0, 0);
|
||||
sub_0200FBF4(1, 0);
|
||||
|
||||
OS_DisableIrqMask(OS_IE_VBLANK);
|
||||
OS_SetIrqFunction(OS_IE_VBLANK, VBlankIntr);
|
||||
OS_EnableIrqMask(OS_IE_VBLANK);
|
||||
|
||||
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(&sErrorMessageBanksConfig);
|
||||
|
||||
BGCONFIG* bg_config = BgConfig_Alloc(0);
|
||||
SetBothScreensModesAndDisable(&sErrorMessageBgModeSet);
|
||||
InitBgFromTemplate(bg_config, 0, &sErrorMessageBgTemplate, GX_BGMODE_0);
|
||||
BgClearTilemapBufferAndCommit(bg_config, GF_BG_LYR_MAIN_0);
|
||||
sub_0200E3DC(bg_config, GF_BG_LYR_MAIN_0, 0x1F7, 2, 0, 0);
|
||||
sub_02003030(GF_BG_LYR_MAIN_0, 0x20, 0);
|
||||
BG_ClearCharDataRange(GF_BG_LYR_MAIN_0, 0x20, 0, 0);
|
||||
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_0041_bin, 0);
|
||||
STRING* error_str = String_ctor(384, 0);
|
||||
|
||||
sub_02020080();
|
||||
|
||||
AddWindow(bg_config, &window, &sErrorMessageWindowTemplate);
|
||||
FillWindowPixelRect(&window, 0xF, 0, 0, 208, 144);
|
||||
DrawFrameAndWindow1(&window, FALSE, 0x1F7, 2);
|
||||
|
||||
ReadMsgDataIntoString(error_msgdata, msg_0041_00003, 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);
|
||||
|
||||
sub_02038D90();
|
||||
|
||||
while (TRUE) {
|
||||
HandleDSLidAction();
|
||||
sub_02036144();
|
||||
|
||||
if (sub_02039AA4()) {
|
||||
break;
|
||||
}
|
||||
|
||||
OS_WaitIrq(TRUE, OS_IE_V_BLANK);
|
||||
}
|
||||
|
||||
while (TRUE) {
|
||||
HandleDSLidAction();
|
||||
|
||||
if (PAD_Read() & PAD_BUTTON_A) {
|
||||
break;
|
||||
}
|
||||
|
||||
OS_WaitIrq(TRUE, OS_IE_V_BLANK);
|
||||
}
|
||||
|
||||
sub_0200FBF4(0, 0x7FFF);
|
||||
sub_0200FBF4(1, 0x7FFF);
|
||||
|
||||
RemoveWindow(&window);
|
||||
DestroyMsgData(error_msgdata);
|
||||
FreeToHeap(bg_config);
|
||||
|
||||
OS_ResetSystem(0);
|
||||
}
|
Loading…
Reference in New Issue
Block a user