/
sioerror.c
100 lines (77 loc) · 1.96 KB
/
sioerror.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "sioerror.h"
#include "hardware.h"
#include "move.h"
#include "sound.h"
#include "text.h"
#include "msg.h"
#include "helpbox.h"
#include "constants/msg.h"
#include "constants/songs.h"
#include "constants/videoalloc_global.h" // for CHR_SIZE
void OnVBlank_SioError(void)
{
// TODO: macro
(*(u16 volatile *)0x03007FF8) = 1;
SyncDispIo();
SyncBgsAndPal();
ApplyDataMoves();
m4aSoundVSync();
m4aSoundMain();
}
void OnMain_SioErrorWait(void)
{
RefreshKeySt(gKeySt);
if ((gKeySt->pressed & (KEY_BUTTON_A | KEY_BUTTON_START)) != 0)
SoftReset(GBA_RESET_ALL);
VBlankIntrWait();
}
void PutSioErrorMessage(void)
{
struct Text text[3];
struct HelpBoxPrintProc fake_proc;
int i;
struct HelpBoxPrintProc * const proc = &fake_proc;
ResetText();
InitTalkTextFont();
for (i = 0; i < (int) ARRAY_COUNT(text); i++)
{
InitText(&text[i], 22);
Text_SetColor(&text[i], TEXT_COLOR_0123);
}
proc->font = NULL;
proc->text[0] = &text[0];
proc->text[1] = &text[1];
proc->text[2] = &text[2];
proc->line = 0;
proc->str_it = DecodeMsg(MSG_C48);
func_fe6_08071308(proc);
PutText(&text[0], gBg0Tm + TM_OFFSET(4, 6));
PutText(&text[1], gBg0Tm + TM_OFFSET(4, 9));
PutText(&text[2], gBg0Tm + TM_OFFSET(4, 11));
EnableBgSync(BG0_SYNC_BIT);
}
void OnMain_SioError(void)
{
InitBgs(NULL);
m4aSoundInit();
InitProcs();
SetBgOffset(0, 0, 0);
SetDispEnable(1, 0, 0, 0, 0);
SetWinEnable(0, 0, 0);
SetBlendNone();
gDispIo.mosaic = 0;
SyncDispIo();
CpuFastFill(0, (void *) VRAM + 0x0000, CHR_SIZE);
CpuFastFill(0, (void *) VRAM + 0x8000, CHR_SIZE);
PutSioErrorMessage();
PlaySe(SONG_7B);
SetMainFunc(OnMain_SioErrorWait);
}
void StartSioErrorScreen(void)
{
REG_DISPSTAT = DISPSTAT_VBLANK_INT_ENABLE;
REG_IME = TRUE;
REG_DISPCNT = 0;
SetOnVBlank(OnVBlank_SioError);
SetMainFunc(OnMain_SioError);
}