-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
57 lines (48 loc) · 1.3 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
/**
* メインコード
*/
#include "header.h"
void main(void)
{
// Bank 5 (palette.bin) を用いてパレットを初期化
vgs0_dma(5);
vgs0_memcpy((uint16_t)VGS0_ADDR_PALETTE, (uint16_t)VGS0_ADDR_CHARACTER, 512);
// Bank 4 を Character Pattern Table ($A000) に転送 (DMA)
vgs0_dma(4);
// 画面中央付近 (10,12) に "HELLO,WORLD!" を描画
vgs0_bg_putstr(10, 12, 0x80, "HELLO,WORLD!");
// BGMを再生
vgs0_bgm_play(0);
uint8_t prevA = 0;
uint8_t prevB = 0;
while (1) {
vgs0_wait_vsync();
uint8_t pad = vgs0_joypad_get();
if (pad & VGS0_JOYPAD_LE) {
*VGS0_ADDR_BG_SCROLL_X += 1;
} else if (pad & VGS0_JOYPAD_RI) {
*VGS0_ADDR_BG_SCROLL_X -= 1;
}
if (pad & VGS0_JOYPAD_UP) {
*VGS0_ADDR_BG_SCROLL_Y += 1;
} else if (pad & VGS0_JOYPAD_DW) {
*VGS0_ADDR_BG_SCROLL_Y -= 1;
}
if (pad & VGS0_JOYPAD_T1) {
if (0 == prevA) {
vgs0_se_play(0);
}
prevA = 1;
} else {
prevA = 0;
}
if (pad & VGS0_JOYPAD_T2) {
if (0 == prevB) {
vgs0_se_play(1);
}
prevB = 1;
} else {
prevB = 0;
}
}
}