This repository has been archived by the owner on Oct 31, 2022. It is now read-only.
forked from Yoshimaster96/N64BrewGameJam2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
144 lines (139 loc) · 2.69 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
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
#include "main.h"
/////////
//INPUT//
/////////
u8 joy1Pattern;
NUContData joy1Data;
u16 joy1ButtonPrev,joy1ButtonDown,joy1ButtonUp;
void update_input() {
//Update input
if(joy1Pattern&1) {
//Save previous buttons
joy1ButtonPrev = joy1Data.button;
//Get new buttons
nuContDataGetEx(&joy1Data,0);
//Get button up/down status
joy1ButtonDown = joy1Data.button&(~joy1ButtonPrev) ;
joy1ButtonUp = joy1ButtonPrev &(~joy1Data.button);
}
}
//////////////
//GAME MODES//
//////////////
volatile int gameMode = 0;
int gameSubmode = 0;
void gm_title(int pendingGfx) {
//Update graphics
if(pendingGfx<2) {
gm_title_disp();
update_input();
gm_title_proc();
}
}
void gm_play(int pendingGfx) {
//Update graphics
if(pendingGfx<2) {
gm_play_disp();
update_input();
gm_play_proc();
}
}
void gm_over(int pendingGfx) {
//Update graphics
if(pendingGfx<2) {
gm_over_disp();
update_input();
gm_over_proc();
}
}
void gm_ending(int pendingGfx) {
//Update graphics
if(pendingGfx<2) {
gm_ending_disp();
update_input();
gm_ending_proc();
}
}
void gm_debug(int pendingGfx) {
//Update graphics
if(pendingGfx<2) {
gm_debug_disp();
update_input();
gm_debug_proc();
}
}
////////////////
//MAIN PROGRAM//
////////////////
//Entry point
void mainproc() {
//Init banks
bank_init();
bank_load(1);
//Init GFX
nuGfxInit();
//Init controller
joy1Pattern = nuContInit();
//Init audio
nuAuInit();
/*nuAuSeqPlayerBankSet(_bgmbankSegmentRomStart,
_bgmbankSegmentRomEnd-_bgmbankSegmentRomStart,
_bgmtableSegmentRomStart);
nuAuSndPlayerBankSet(_sebankSegmentRomStart,
_sebankSegmentRomEnd-_sebankSegmentRomStart,
_setableSegmentRomStart);
nuAuSeqPlayerSeqSet(_bgmSegmentRomStart);*/
//Main game loop
while(1) {
//Init current stage
switch(gameMode) {
//Title
case 0: {
gameMode = -1;
//nuAuSeqPlayerSetNo(0,0);
//nuAuSeqPlayerPlay(0);
nuGfxFuncSet((NUGfxFunc)gm_title);
nuGfxDisplayOn();
break;
}
//Main gameplay
case 1: {
gameMode = -1;
//nuAuSeqPlayerSetNo(1,0);
//nuAuSeqPlayerPlay(0);
nuGfxFuncSet((NUGfxFunc)gm_play);
nuGfxDisplayOn();
break;
}
//Game over
case 2: {
gameMode = -1;
//nuAuSeqPlayerSetNo(2,0);
//nuAuSeqPlayerPlay(0);
nuGfxFuncSet((NUGfxFunc)gm_over);
nuGfxDisplayOn();
break;
}
//Ending
case 3: {
gameMode = -1;
//nuAuSeqPlayerSetNo(3,0);
//nuAuSeqPlayerPlay(0);
nuGfxFuncSet((NUGfxFunc)gm_ending);
nuGfxDisplayOn();
break;
}
//Debug
case 4: {
gameMode = -1;
//nuAuSeqPlayerStop(0);
nuGfxFuncSet((NUGfxFunc)gm_debug);
nuGfxDisplayOn();
break;
}
}
//Wait for next stage
while(gameMode == -1);
nuGfxDisplayOff();
}
}