blob: b8f2334b1914cdf67409c35a59d30e51527831d2 (
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
|
#include <string.h>
#include "common.h"
#include "gba-buttons.c"
#include "background-tiles.c"
#include "sprites.h"
//
// Main functions.
//
// TODO: Cleanup OBJ/OAM memory copying and access.
int main(void) {
// Load background palette.
memcpy(&PAL_BUFFER_BG[0], &bg_palette, 512);
memcpy(&TILE_MEM[0][0], bg_data, 3168);
memcpy(&SCREENBLOCK_MEM[30][0], bg_map, 2048);
// Configure BG0 to use 4bpp, 64x32 tile map in charblock 0 and screenblock
// 31.
BG_CTRL_0 = BG_CHARBLOCK(0) | BG_SCREENBLOCK(30) | BG_SIZE(0);
BG_H_SCROLL_0 = 0;
BG_V_SCROLL_0 = 0;
// 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();
int frame_counter = 0;
int x = 0;
int y = 0;
while(true) {
wait_vsync();
poll_keys();
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;
}
frame_counter++;
BG_H_SCROLL_0 = x;
BG_V_SCROLL_0 = y;
update_button_sprites();
};
return 0;
}
|