-
Notifications
You must be signed in to change notification settings - Fork 0
/
splash.c
executable file
·145 lines (122 loc) · 3.5 KB
/
splash.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
145
#include "splashImg.h"
#include "instructionsImg.h"
#include "walking_sprite.h"
#include "myLib.h"
void instructions();
void splash();
void initialize_vars();
extern int state;
extern int easyMode;
enum {SPLASH, INSTRUCTIONS, GAME_OVERWORLD, GAME_ARENA, PAUSE, WIN, LOSE};
// These are variables from the other game states. Used to reset their values
// when starting a new game.
extern int playerCol;
extern int projectile_available;
extern int battle_in_progress;
extern int player_damage;
extern int cloudOffset;
extern int loopCounter;
extern int playerHealth;
extern int dragonHealth;
extern int characterRow;
extern int characterCol;
extern int characterWidth;
extern int characterHeight;
extern int characterRVel;
extern int characterCVel;
extern int facingLeft;
extern int in_battle;
extern int points;
extern int selector_position;
extern int easyMode;
void splash() {
initialize_vars();
REG_DISPCTL = MODE0 | BG3_ENABLE;
REG_BG3CNT = CBB(0) | SBB(28) | BG_SIZE3 | COLOR256;
loadPalette(splashPal);
DMANow(3, (unsigned int*)splashTiles, &CHARBLOCKBASE[0], splashTilesLen);
DMANow(3, (unsigned int*)splashMap, &SCREENBLOCKBASE[28], splashMapLen);
//This loop keeps the background from being redrawn continously
int button_pushed = 0;
while (!button_pushed) {
key_poll();
if (key_hit(BUTTON_A) || (key_hit(BUTTON_B)))
button_pushed = 1;
}
if (key_hit(BUTTON_A))
state = INSTRUCTIONS;
if (key_hit(BUTTON_B))
state = PAUSE;
}
void instructions() {
OBJ_ATTR shadowOAM[128];
//Enables sprites
REG_DISPCTL = MODE0 | BG3_ENABLE | SPRITE_ENABLE;
REG_BG3CNT = CBB(0) | SBB(28) | BG_SIZE3 | COLOR256;
//Loads sprites into memory
DMANow(3, (unsigned int*)walking_spriteTiles, &CHARBLOCKBASE[4], walking_spriteTilesLen/2);
//Loads sprite palette into memory
DMANow(3, (unsigned int*)walking_spritePal, SPRITE_PALETTE, walking_spritePalLen/2);
//Loads background stuff
loadPalette(instructionsImgPal);
DMANow(3, (unsigned int*)instructionsImgTiles, &CHARBLOCKBASE[0], instructionsImgTilesLen);
DMANow(3, (unsigned int*)instructionsImgMap, &SCREENBLOCKBASE[28], instructionsImgMapLen);
//Hides all sprites
int i;
for (i=0; i<128; ++i) {
OAM[i].attr0 = ATTR0_HIDE;
}
shadowOAM[0].attr0 = 120 | ATTR0_8BPP | ATTR0_SQUARE;
shadowOAM[0].attr1 = 177 | ATTR1_SIZE16;
if (easyMode)
shadowOAM[0].attr2 = 656;
if (!easyMode)
shadowOAM[0].attr2 = 592;
//This loop keeps the background from being redrawn continously
int button_pushed = 0;
while (!button_pushed) {
OAM[0] = shadowOAM[0];
key_poll();
if (key_hit(BUTTON_START))
button_pushed = 1;
if (key_hit(BUTTON_SELECT) && easyMode) {
shadowOAM[0].attr2 = 592;
easyMode = 0;
}
else if (key_hit(BUTTON_SELECT) && !easyMode) {
shadowOAM[0].attr2 = 656;
easyMode = 1;
}
}
if (key_hit(BUTTON_START))
state = SPLASH;
loadPalette(splashPal);
}
void initialize_vars() {
//vars from game_arena.c
playerCol = 0;
projectile_available = 1;
battle_in_progress = 1;
player_damage = 1;
cloudOffset = 0;
loopCounter = 0;
playerHealth = 1;
dragonHealth = 10;
//vars from game_overworld.c
characterRow = 60;
characterCol = 10;
characterWidth = 32;
characterHeight = 32;
characterRVel = 1;
characterCVel = 1;
facingLeft = 0;
in_battle = 0;
//vars from pause.c
points = 5;
selector_position = 0;
//Disables all sprites
int i;
for (i=0; i<128; ++i) {
OAM[i].attr0 = ATTR0_HIDE;
}
}