blob: 407b6e1acf10f00e16677debda583cc5bdbe621b (
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
|
define INPUT = 0xbffe;
define SCREEN = 0xbfff;
define TRUE = 1;
define FALSE = 0;
main() {
loop {
slp;
erase();
update();
draw();
}
}
update() {
input_update();
player_update();
}
erase() {
player_erase();
}
draw() {
player_draw();
}
global input_left;
global input_right;
global input_up;
global input_down;
input_update() {
local input;
input = [INPUT];
input_up = (input & 0x10) != 0;
input_down = (input & 0x20) != 0;
input_left = (input & 0x40) != 0;
input_right = (input & 0x80) != 0;
}
global player_x = 64;
global player_y = 64;
player_update() {
player_x = player_x + input_right - input_left;
player_y = player_y + input_down - input_up;
}
player_erase() {
pset(player_x, player_y, 0x1111);
}
player_draw() {
pset(player_x, player_y, 0xffff);
}
pset(x, y, c) {
[SCREEN + (x & 127) + (y & 127) * 128] = c;
}
|