/
main.c
74 lines (54 loc) · 1.2 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
#include <gb/gb.h>
#include "alpha.c"
#include "helloWorld.c"
#include "blankScreen.c"
#include "corvid.c"
#include "menu.c"
#include "weather.c"
void init();
void checkInput();
void updateSwitches();
void main() {
init();
while(1) {
checkInput(); // Check for user input (and act on it)
updateSwitches(); // Make sure the SHOW_SPRITES and SHOW_BKG switches are on each loop
wait_vbl_done(); // Wait until VBLANK to avoid corrupting memory
}
}
void init() {
DISPLAY_ON;// Turn on the display
// Switch to VRAM
VBK_REG = 1;
// Switch out of VRAM
VBK_REG = 0;
// Set screen x,y pos to 0,0 and draw the map 20,18(size of the screen)
set_bkg_data(0,255,birdTitle_tile_data);
set_bkg_tiles(0,0,20,18,birdTitle_map_data);
// Show the background
SHOW_BKG;
}
void updateSwitches() {
HIDE_WIN;
SHOW_SPRITES;
SHOW_BKG;
}
void menu() {
set_bkg_data(0,255,birdWelcomeSM_tile_data);
set_bkg_tiles(0,0,20,18,birdWelcomeSM_map_data);
}
void weather() {
set_bkg_data(0,255,sun2_tile_data);
set_bkg_tiles(0,0,20,18,sun2_map_data);
if (joypad() & J_B) {
menu();
}
}
void checkInput() {
if (joypad() & J_A) {
menu();
}
if (joypad() & J_LEFT) {
weather();
}
}