(sioerror) Port sioerror from FE6

This commit is contained in:
Eebit 2023-04-10 12:21:40 -04:00
parent af802c8141
commit a9cfa7a36a
6 changed files with 173 additions and 229 deletions

View File

@ -1,218 +0,0 @@
.INCLUDE "macro.inc"
.SYNTAX UNIFIED
THUMB_FUNC_START MinimalVBlankHandler
MinimalVBlankHandler: @ 0x0808DAE4
push {lr}
ldr r1, _0808DB04 @ gUnknown_03007FF8
movs r0, #1
strh r0, [r1]
bl FlushLCDControl
bl FlushBackgrounds
bl FlushTiles
bl m4aSoundVSync
bl m4aSoundMain
pop {r0}
bx r0
.align 2, 0
_0808DB04: .4byte gUnknown_03007FF8
THUMB_FUNC_END MinimalVBlankHandler
THUMB_FUNC_START sub_808DB08
sub_808DB08: @ 0x0808DB08
push {r4, lr}
ldr r4, _0808DB30 @ gKeyStatusPtr
ldr r0, [r4]
bl UpdateKeyStatus
ldr r0, [r4]
ldrh r1, [r0, #8]
movs r0, #9
ands r0, r1
cmp r0, #0
beq _0808DB24
movs r0, #0xff
bl SoftReset
_0808DB24:
bl VBlankIntrWait
pop {r4}
pop {r0}
bx r0
.align 2, 0
_0808DB30: .4byte gKeyStatusPtr
THUMB_FUNC_END sub_808DB08
THUMB_FUNC_START sub_808DB34
sub_808DB34: @ 0x0808DB34
push {r4, r5, r6, r7, lr}
mov r7, r8
push {r7}
sub sp, #0x7c
add r5, sp, #0x18
bl Font_InitForUIDefault
bl Font_LoadForDialogue
add r7, sp, #8
add r0, sp, #0x10
mov r8, r0
mov r4, sp
movs r6, #2
_0808DB50:
adds r0, r4, #0
movs r1, #0x16
bl Text_Init
adds r0, r4, #0
movs r1, #0
bl Text_SetColorId
adds r4, #8
subs r6, #1
cmp r6, #0
bge _0808DB50
movs r1, #0
str r1, [r5, #0x30]
mov r0, sp
str r0, [r5, #0x34]
str r7, [r5, #0x38]
mov r0, r8
str r0, [r5, #0x3c]
adds r0, r5, #0
adds r0, #0x5c
strh r1, [r0]
ldr r0, _0808DBC0 @ 0x0000088E
bl GetStringFromIndex
str r0, [r5, #0x2c]
adds r0, r5, #0
bl sub_8089EEC
ldr r4, _0808DBC4 @ gUnknown_02022E30
mov r0, sp
adds r1, r4, #0
bl Text_Draw
adds r1, r4, #0
adds r1, #0xc0
adds r0, r7, #0
bl Text_Draw
movs r0, #0xa0
lsls r0, r0, #1
adds r4, r4, r0
mov r0, r8
adds r1, r4, #0
bl Text_Draw
movs r0, #1
bl BG_EnableSyncByMask
add sp, #0x7c
pop {r3}
mov r8, r3
pop {r4, r5, r6, r7}
pop {r0}
bx r0
.align 2, 0
_0808DBC0: .4byte 0x0000088E
_0808DBC4: .4byte gUnknown_02022E30
THUMB_FUNC_END sub_808DB34
THUMB_FUNC_START sub_808DBC8
sub_808DBC8: @ 0x0808DBC8
push {r4, r5, lr}
sub sp, #8
movs r0, #0
bl SetupBackgrounds
bl m4aSoundInit
bl Proc_Init
movs r0, #0
movs r1, #0
movs r2, #0
bl BG_SetPosition
ldr r4, _0808DC60 @ gLCDControlBuffer
ldrb r0, [r4, #1]
movs r1, #1
orrs r0, r1
movs r1, #3
negs r1, r1
ands r0, r1
subs r1, #2
ands r0, r1
subs r1, #4
ands r0, r1
subs r1, #8
ands r0, r1
subs r1, #0x10
ands r0, r1
subs r1, #0x20
ands r0, r1
movs r1, #0x7f
ands r0, r1
strb r0, [r4, #1]
bl SetDefaultColorEffects
movs r0, #0
bl SetPrimaryHBlankHandler
movs r0, #0
strh r0, [r4, #0x38]
bl FlushLCDControl
movs r4, #0
str r4, [sp]
movs r1, #0xc0
lsls r1, r1, #0x13
ldr r5, _0808DC64 @ 0x01000008
mov r0, sp
adds r2, r5, #0
bl CpuFastSet
str r4, [sp, #4]
add r0, sp, #4
ldr r1, _0808DC68 @ 0x06008000
adds r2, r5, #0
bl CpuFastSet
bl sub_808DB34
ldr r0, _0808DC6C @ gPlaySt
adds r0, #0x41
ldrb r0, [r0]
lsls r0, r0, #0x1e
cmp r0, #0
blt _0808DC52
movs r0, #0x7b
bl m4aSongNumStart
_0808DC52:
ldr r0, _0808DC70 @ sub_808DB08
bl SetMainUpdateRoutine
add sp, #8
pop {r4, r5}
pop {r0}
bx r0
.align 2, 0
_0808DC60: .4byte gLCDControlBuffer
_0808DC64: .4byte 0x01000008
_0808DC68: .4byte 0x06008000
_0808DC6C: .4byte gPlaySt
_0808DC70: .4byte sub_808DB08
THUMB_FUNC_END sub_808DBC8
THUMB_FUNC_START sub_808DC74
sub_808DC74: @ 0x0808DC74
push {lr}
ldr r1, _0808DC9C @ 0x04000004
movs r0, #8
strh r0, [r1]
ldr r1, _0808DCA0 @ 0x04000208
movs r0, #1
strh r0, [r1]
movs r1, #0x80
lsls r1, r1, #0x13
movs r0, #0
strh r0, [r1]
ldr r0, _0808DCA4 @ MinimalVBlankHandler
bl SetInterrupt_LCDVBlank
ldr r0, _0808DCA8 @ sub_808DBC8
bl SetMainUpdateRoutine
pop {r0}
bx r0
.align 2, 0
_0808DC9C: .4byte 0x04000004
_0808DCA0: .4byte 0x04000208
_0808DCA4: .4byte MinimalVBlankHandler
_0808DCA8: .4byte sub_808DBC8
THUMB_FUNC_END sub_808DC74
.align 2, 0

View File

@ -861,7 +861,7 @@ _08041C5C:
adds r1, r1, r0
movs r0, #0
strb r0, [r1]
bl sub_808DC74
bl StartSioErrorScreen
_08041C76:
ldr r4, _08041CE8 @ gUnknown_085A92E0
ldr r0, [r4]
@ -879,7 +879,7 @@ _08041C76:
adds r0, #0xb
adds r0, r0, r1
strb r2, [r0]
bl sub_808DC74
bl StartSioErrorScreen
_08041C9C:
movs r4, #0
ldr r5, _08041CE8 @ gUnknown_085A92E0
@ -897,7 +897,7 @@ _08041CA0:
adds r0, r0, r4
movs r1, #0
strb r1, [r0]
bl sub_808DC74
bl StartSioErrorScreen
_08041CBE:
adds r4, #1
cmp r4, #3
@ -915,7 +915,7 @@ _08041CC4:
ldrb r0, [r1, #0x11]
cmp r0, #0x3c
bls _08041CEC
bl sub_808DC74
bl StartSioErrorScreen
ldr r1, [r4]
movs r0, #2
strh r0, [r1, #4]
@ -10571,7 +10571,7 @@ _0804673A:
lsls r0, r0, #2
cmp r1, r0
ble _0804674E
bl sub_808DC74
bl StartSioErrorScreen
_0804674E:
ldr r0, _080467A0 @ gUnknown_03004F0C
movs r1, #0x89

View File

@ -2180,11 +2180,6 @@ void sub_808AA04(int x_tile, int y_tile, int unk_index, ProcPtr parent);
// ??? sub_808BB44(???);
// ??? sub_808BB58(???);
void sub_808BB74(void); // ??? (also text related)
// ??? MinimalVBlankHandler(???);
// ??? sub_808DB08(???);
// ??? sub_808DB34(???);
// ??? sub_808DBC8(???);
// ??? sub_808DC74(???);
void sub_808E9D8(int);
// ??? sub_808E9F0(???);
// ??? sub_808EA1C(???);

10
include/sioerror.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef GUARD_SIOERROR_H
#define GUARD_SIOERROR_H
// ??? OnVBlank_SioError(???);
// ??? OnMain_SioErrorWait(???);
// ??? PutSioErrorMessage(???);
// ??? OnMain_SioError(???);
void StartSioErrorScreen(void);
#endif // GUARD_SIOERROR_H

View File

@ -168,7 +168,7 @@ SECTIONS
src/chapter_title.o(.text);
src/helpbox.o(.text);
src/player_interface.o(.text);
asm/code_808DAE4.o(.text);
src/sioerror.o(.text);
src/uichapterstatus.o(.text);
asm/code.o(.text);
src/prepscreen.o(.text);

157
src/sioerror.c Normal file
View File

@ -0,0 +1,157 @@
#include "global.h"
#include "hardware.h"
#include "m4a.h"
#include "soundwrapper.h"
#include "fontgrp.h"
#include "sioerror.h"
//! FE8U = 0x0808DAE4
void OnVBlank_SioError(void) {
INTR_CHECK = 1;
FlushLCDControl();
FlushBackgrounds();
FlushTiles();
m4aSoundVSync();
m4aSoundMain();
return;
}
//! FE8U = 0x0808DB08
void OnMain_SioErrorWait(void) {
UpdateKeyStatus(gKeyStatusPtr);
if (gKeyStatusPtr->newKeys & (A_BUTTON | START_BUTTON)) {
SoftReset(0xff);
}
VBlankIntrWait();
return;
}
struct HelpBoxScrollProc {
/* 00 */ PROC_HEADER;
/* 2C */ const char* unk_2c;
/* 30 */ struct Font* unk_30;
/* 34 */ struct TextHandle* unk_34[9]; // unknown size; 3?
/* 58 */ int unk_58;
/* 5C */ s16 unk_5c;
/* 5E */ s16 unk_5e;
/* 60 */ u16 unk_60;
///* 62 */ s16 unk_62; TODO - Harmonize with definition in "helpbox.c"
///* 64 */ s16 unk_64; TODO - Harmonize with definition in "helpbox.c"
};
void sub_8089EEC(struct HelpBoxScrollProc* proc);
//! FE8U = 0x0808DB34
void PutSioErrorMessage(void) {
int i;
struct TextHandle th[3];
struct HelpBoxScrollProc localProcSt;
struct HelpBoxScrollProc* proc = &localProcSt;
Font_InitForUIDefault();
Font_LoadForDialogue();
for (i = 0; i < 3; i++) {
Text_Init(&th[i], 22);
Text_SetColorId(&th[i], 0);
}
proc->unk_30 = NULL;
proc->unk_34[0] = &th[0];
proc->unk_34[1] = &th[1];
proc->unk_34[2] = &th[2];
proc->unk_5c = 0;
proc->unk_2c = GetStringFromIndex(0x88E);
/*
* TODO: msgid:
* "Linking error.
* Turn the power off, check[.]
* the connections, and retry.[.]"
*/
sub_8089EEC(proc);
Text_Draw(&th[0], gBG0TilemapBuffer + TILEMAP_INDEX(4, 6));
Text_Draw(&th[1], gBG0TilemapBuffer + TILEMAP_INDEX(4, 9));
Text_Draw(&th[2], gBG0TilemapBuffer + TILEMAP_INDEX(4, 11));
BG_EnableSyncByMask(1);
return;
}
//! FE8U = 0x0808DBC8
void OnMain_SioError(void) {
SetupBackgrounds(NULL);
m4aSoundInit();
Proc_Init();
BG_SetPosition(0, 0, 0);
gLCDControlBuffer.dispcnt.bg0_on = 1;
gLCDControlBuffer.dispcnt.bg1_on = 0;
gLCDControlBuffer.dispcnt.bg2_on = 0;
gLCDControlBuffer.dispcnt.bg3_on = 0;
gLCDControlBuffer.dispcnt.obj_on = 0;
gLCDControlBuffer.dispcnt.win0_on = 0;
gLCDControlBuffer.dispcnt.win1_on = 0;
gLCDControlBuffer.dispcnt.objWin_on = 0;
SetDefaultColorEffects();
SetPrimaryHBlankHandler(NULL);
gLCDControlBuffer.mosaic = 0;
FlushLCDControl();
#if NONMATCHING
CpuFastFill(0, (void*)0x06000000, 0x20);
CpuFastFill(0, (void*)0x06008000, 0x20);
#else // if !NONMATCHING
{
register int s asm("r4") = 0;
CpuFastFill(s, (void*)0x06000000, 0x20);
CpuFastFill(s, (void*)0x06008000, 0x20);
}
#endif // NONMATCHING
PutSioErrorMessage();
PlaySoundEffect(0x7b);
SetMainUpdateRoutine(OnMain_SioErrorWait);
return;
}
//! FE8U = 0x0808DC74
void StartSioErrorScreen(void) {
REG_DISPSTAT = DISPSTAT_VBLANK_INTR;
REG_IME = 1;
REG_DISPCNT = DISPCNT_MODE_0;
SetInterrupt_LCDVBlank(OnVBlank_SioError);
SetMainUpdateRoutine(OnMain_SioError);
return;
}