-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.c
112 lines (101 loc) · 1.95 KB
/
main.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
101
102
103
104
105
106
107
108
109
110
111
112
#include <gb/gb.h>
#include <gb/cgb.h>
#include "defines.h"
#include "gamestate.h"
#include "main.h"
#include "init.h"
#include "sound.h"
#include "mmlgb/driver/music.h"
#include "logos.h"
#include "intro.h"
#include "title.h"
#include "select.h"
#include "game.h"
#include "winscreen.h"
#include "highscore.h"
#include "unlocked.h"
#include "jukebox.h"
#include "ending.h"
#include "wipe.h"
#include "minigamescore.h"
void vbl_update() {
++vbl_count;
}
void main() {
DISPLAY_OFF;
disable_interrupts();
SWITCH_ROM_MBC1(INIT_BANK);
sgb_mode = sgb_check2();
if(sgb_mode) {
sgb_init();
}
initRAM(0U);
snd_init();
vbl_count = 0U;
joystate = oldjoystate = 0U;
unlocked_bits = 0U;
player_skin = 1U;
ending_flags = 0U;
last_highscore_level = 0U;
last_highscore_slot = 5U;
last_progress = 0U;
selection = level = 1U;
gamestate = GAMESTATE_LOGOS;
SWITCH_16_8_MODE_MBC1;
add_TIM(updateMusic);
add_VBL(vbl_update);
set_interrupts(TIM_IFLAG | VBL_IFLAG);
enable_interrupts();
while(1U) {
switch(gamestate) {
case GAMESTATE_LOGOS:
setGameBank(5U);
enterLogos();
break;
case GAMESTATE_INGAME:
setGameBank(1U);
enterGame();
break;
case GAMESTATE_TITLE:
setGameBank(6U);
enterTitle();
break;
case GAMESTATE_SELECT:
setGameBank(2U);
enterSelect();
break;
case GAMESTATE_HIGHSCORE:
setGameBank(2U);
enterHighscore();
break;
case GAMESTATE_UNLOCKED:
setGameBank(2U);
enterUnlocked();
break;
case GAMESTATE_INTRO:
setGameBank(3U);
enterIntro();
break;
case GAMESTATE_ENDING:
setGameBank(3U);
enterEnding();
break;
case GAMESTATE_JUKEBOX:
setGameBank(4U);
enterJukebox();
break;
case GAMESTATE_WINSCREEN:
setGameBank(5U);
enterWinscreen();
break;
case GAMESTATE_WIPE:
setGameBank(10U);
enterWipe();
break;
case GAMESTATE_MINIGAME_SCORE:
setGameBank(8U);
enterMinigamescore();
break;
}
}
}