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
107
108
109
110
111
112
113
114
115
116
117
118
119
|
;
; player update code
;
cool_down:
.db 0
player_update:
ld x, [sp + 2]
ld a, [sp + 3]
; read controller 1
ld b, 0xf0
port b, b
inc x
bo
inc a
; x coord
ld y, [a : x]
; left
bit b, 4
bnz
jmp player_not_left
dec y
bo
ld y, 0
player_not_left:
; right
bit b, 5
bnz
jmp player_not_right
cmp y, 112
bz
jmp player_not_right
inc y
player_not_right:
ld [a : x], y
inc x
bo
inc a
; y coord
ld y, [a : x]
; up
bit b, 2
bnz
jmp player_not_up
cmp y, 16
bz
jmp player_not_up
dec y
player_not_up:
; down
bit b, 3
bnz
jmp player_not_down
cmp y, 112
bz
jmp player_not_down
inc y
player_not_down:
ld [a : x], y
; update frame
inc x
bo
inc a
; base frame
ld y, 0
push b
; both left and right
and b, 48
cmp b, 48
bz
jmp player_store_frame
; left
bit b, 4
bz
ld y, 2
; right
bit b, 5
bz
ld y, 1
player_store_frame:
ld [a : x], y
pop b
; fire
bit b, 0
bnz
ret
ld x, <cool_down
ld a, >cool_down
ld y, [a : x]
cmp y, 0
bz
jmp player_fire
dec y
ld [a : x], y
ret
player_fire:
add y, 10
ld [a : x], y
call bullet_player_new
ret
|