blob: 3bd5865bd0d7d2c17e1c7e5620f3988f39ef71f1 (
plain)
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
|
#include <string.h>
#include "common.h"
#include "gba-buttons.c"
#include "background-tiles.c"
#include "sprites.h"
#include "text.h"
//
// Main functions.
//
// TODO: Cleanup OBJ/OAM memory copying and access.
//
int main(void) {
// Configure the display in mode 0 to show OBJs, where tile memory is
// sequential.
DISP_CTRL = DISP_ENABLE_SPRITES | DISP_MODE_0 | DISP_BG_0;
// Initialize sprite button overlay.
init_sprite_pal(0, COLOR_WHITE);
init_sprites(0);
init_button_sprites();
// Initialize text engine.
txt_init(0, COLOR_RED, 0);
txt_position(0, 6);
txt_printf("Strings: %s\n", "Hello World");
txt_printf("Signed ints: %d\n", -100000);
txt_printf("Unsigned ints: %u\n", 1234567);
txt_printf("Hex values: 0x%x\n", 1024);
int frame_counter = 0;
int x = 0;
int y = 0;
while(true) {
wait_vsync();
poll_keys();
txt_position(0, 0);
txt_printf("Frame counter: %d\n", frame_counter);
if (key_hold(KEY_DOWN)) {
y += 3;
}
if (key_hold(KEY_UP)) {
y -= 3;
}
if (key_hold(KEY_LEFT)) {
x -= 3;
}
if (key_hold(KEY_RIGHT)) {
x += 3;
}
if (key_pressed(KEY_A)) {
txt_clear_line();
txt_printf("Pressed key: A");
}
if (key_pressed(KEY_B)) {
txt_clear_line();
txt_printf("Pressed key: B");
}
if (key_pressed(KEY_L)) {
txt_clear_line();
txt_printf("Pressed key: L");
}
if (key_pressed(KEY_R)) {
txt_clear_line();
txt_printf("Pressed key: R");
}
if (key_pressed(KEY_START)) {
txt_clear_line();
txt_printf("Pressed key: Start");
}
if (key_pressed(KEY_SELECT)) {
txt_clear_line();
txt_printf("Pressed key: Select");
}
if (key_pressed(KEY_UP)) {
txt_clear_line();
txt_printf("Pressed key: Up");
}
if (key_pressed(KEY_DOWN)) {
txt_clear_line();
txt_printf("Pressed key: Down");
}
if (key_pressed(KEY_LEFT)) {
txt_clear_line();
txt_printf("Pressed key: Left");
}
if (key_pressed(KEY_RIGHT)) {
txt_clear_line();
txt_printf("Pressed key: Right");
}
frame_counter++;
// BG_H_SCROLL_0 = x;
// BG_V_SCROLL_0 = y;
update_button_sprites();
};
return 0;
}
|