-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathmain.h
163 lines (143 loc) · 3.88 KB
/
main.h
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#ifndef MAIN_H
#define MAIN_H
#include "global.h"
#include "structures.h"
#include "room.h"
#include "script.h"
#include "screen.h"
/** File signature */
#define SIGNATURE 'MCZ3'
/** Maximum message speed. */
#define MAX_MSG_SPEED 3
/** Number of save slots */
#define NUM_SAVE_SLOTS 3
/** Maximum brightness. */
#define MAX_BRIGHTNESS 3
/** Supported game languages. */
typedef enum {
LANGUAGE_JP,
LANGUAGE_EN,
LANGUAGE_FR,
LANGUAGE_DE,
LANGUAGE_ES,
LANGUAGE_IT,
NUM_LANGUAGES,
} Language;
#ifdef ENGLISH
#define GAME_LANGUAGE LANGUAGE_EN
#else
#define GAME_LANGUAGE LANGUAGE_JP
#endif
/** Program tasks. */
typedef enum {
TASK_TITLE, /**< Title task. This is the first task to be entered. */
TASK_FILE_SELECT, /**< File selection task. */
TASK_GAME, /**< Gameplay task. Overworld, menus, cutscenes are all contained here. */
TASK_GAMEOVER, /**< Gameover task. */
TASK_STAFFROLL, /**< Staffroll task. Only accessible through the script played during the game ending. */
TASK_DEBUG, /**< Debug task. Inaccessible in normal gameplay. */
} Task;
/** System sleep status. */
typedef enum {
DEFAULT,
SLEEP,
} SleepStatus;
/**
* Main system structure.
*/
typedef struct {
vu8 interruptFlag;
u8 sleepStatus;
u8 task; /**< Current #Task. */
u8 state; /**< State of the current #Task. */
u8 substate; /**< Substate of the current #Task. */
u8 field_0x5;
u8 muteAudio; /**< Mute audio. */
u8 field_0x7;
u8 pauseFrames; /**< Number of frames to pause. */
u8 pauseCount; /**< Number of pauses to make. */
u8 pauseInterval; /**< Number of frames to play between each pause. */
u8 pad; // TODO actually used in CopyOAM()
u16 ticks; /**< Current time. */
} Main;
/**
* HUD structure.
*/
// TODO Rather a structure more generally about gfx?
typedef struct {
/*0x000*/ u8 nextToLoad;
/*0x001*/ u8 _1;
/*0x002*/ u8 lastState;
/*0x003*/ u8 field_0x3;
/*0x004*/ u8 state;
/*0x005*/ u8 field_0x5;
/*0x006*/ bool8 loadGfxOnRestore; // used in Subtask_FadeOut to determine the loadGfx parameter of RestoreGameTask.
/*0x007*/ u8 pauseFadeIn;
/*0x008*/ u16 fadeType;
/*0x00A*/ u16 fadeInTime;
/*0x00C*/ u8 controlMode;
/*0x00D*/ u8 unk_d;
/*0x00E*/ u8 unk_e;
/*0x00F*/ u8 unk_f;
/*0x010*/ void** currentRoomProperties;
/*0x014*/ BgSettings* mapBottomBgSettings;
/*0x018*/ BgSettings* mapTopBgSettings;
/*0x01C*/ RoomControls roomControls;
/*0x054*/ GfxSlotList gfxSlotList;
/*0x268*/ Palette palettes[0x10];
/*0x2A8*/ u8 unk_2a8[0x100];
/*0x3A8*/ ActiveScriptInfo activeScriptInfo;
} UI;
static_assert(sizeof(UI) == 0x3b4);
extern Main gMain; /**< Main instance. */
extern UI gUI; /**< UI instance. */
/**
* Program entry point.
*/
void AgbMain(void);
/**
* Begin a new task.
*
* @param task #Task to begin.
*/
void SetTask(u32 task);
/**
* Initialize the DMA system.
*/
void InitDMA(void);
/**
* Soft reset the system.
*/
void DoSoftReset(void);
/**
* Put the system into sleep mode.
*/
void SetSleepMode(void);
/**
* Sets a DMA to be performed at next VBlank.
*/
extern void SetVBlankDMA(u16* src, u16* dest, u32 size);
extern void InitVBlankDMA(void);
extern void ResetPalettes(void);
extern void VBlankIntrWait();
extern void VBlankInterruptWait(void);
extern void DisableInterruptsAndDMA(void);
extern void EnableVBlankIntr(void);
extern void DisableVBlankDMA(void);
/** @name Task entrypoints */
///@{
/** Task entrypoint. */
extern void TitleTask(void);
extern void FileSelectTask(void);
extern void GameTask(void);
extern void GameOverTask(void);
extern void StaffrollTask(void);
extern void DebugTask(void);
#ifdef DEMO_USA
extern void DemoTask(void);
#endif
/// @}
extern u8 gUnk_03003DE4[0xC];
extern u16 gPaletteBuffer[];
extern u32 CheckRegionsOnScreen(const u16* arr);
#endif // MAIN_H