-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnake.asm
85 lines (77 loc) · 1.9 KB
/
snake.asm
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
; * WORK IN PROGRESS, PLEASE IGNORE.
; * This program makes use of the stack pointer, so it is first initialised to 0
; and is rarely (never?) written to explicitly.
; * The calling convention used in this program is as follows:
; * r0 through r9 are saved by the caller,
; * r10 through r13 are saved by the callee,
; * arguments are passed and results are returned in caller-saved registers.
start:
mov sp, 0 ; * Zero put sp.
mov r10, 0 ; * terminal should be connected to port 0.
bump r10 ; * Reset terminal.
.game:
mov r1, world
mov [r1+0x64], 1
mov [r1+0x65], 1
mov [r1+0x66], 1
send r10, 0x200F
send r10, 0x1064
send r10, 0x7F
send r10, 0x7F
send r10, 0x7F
mov r2, 0
mov r3, 6
mov r4, 6
.main_loop:
wait r10
jns .no_key
bump r10
.recv_loop:
recv r0, r10
jnc .recv_loop
cmp r0, 's'
je .key_s
jb .key_a_d
cmp r0, 'w'
jne .no_key
mov r2, 1
jmp .no_key
.key_s:
mov r2, 3
jmp .no_key
.key_a_d:
cmp r0, 'a'
je .key_a
cmp r0, 'd'
jne .no_key
mov r2, 0
jmp .no_key
.key_a:
mov r2, 2
.no_key:
mov r0, 1
test r2, 2
jz .no_ffff
mov r0, -1
.no_ffff:
test r2, 1
jz .add_to_r3
add r4, r0
jmp .added_to_r4
.add_to_r3:
add r3, r0
.added_to_r4:
jmp .main_loop
world: ; * 16*12 cells for the RT2812A.
dw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0