-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_cursor.asm
136 lines (128 loc) · 2.2 KB
/
game_cursor.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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
;Airaki! - FSE 2014
;Released under the GPL V3, see LICENSE.TXT
changecursor:
ld hl,sfxdata_curch
call sfx_play
ld a,(CURSOR_MODE)
or a
jr nz,++
;Change from H to V: correct position if needed (Y=8 ?)
ld a,(CURSOR_Y)
cp 8
jr nz,+
dec a
ld (CURSOR_Y),a
+:
ld a,1
ld (CURSOR_MODE),a
ret
++:
;Change from V to H: correct position if needed (X=6 ?)
ld a,(CURSOR_X)
cp 6
jr nz,+
dec a
ld (CURSOR_X),a
+:
xor a
ld (CURSOR_MODE),a
ret
rendercursor:
ld a,(FRAME)
and 8
srl a
srl a
srl a
ld c,a ;C is cursor shrink animation
ld a,(CURSOR_MODE)
or a
jr nz,+
;Render H
;Cursor left
ld a,(CURSOR_Y)
swap a
add 16
ldi (hl),a
ld a,(CURSOR_X)
swap a
add 8
sub c
ldi (hl),a
ld a,T_CURSORH
ldi (hl),a
xor a
ldi (hl),a
;Cursor right
ld a,(CURSOR_Y)
swap a
add 16
ldi (hl),a
ld a,(CURSOR_X)
swap a
add 8+24
add c
ldi (hl),a
ld a,T_CURSORH
ldi (hl),a
ld a,%00100000
ldi (hl),a
ret
+:
;Render V
;Cursor top left
ld a,(CURSOR_Y)
swap a
add 16
sub c
ldi (hl),a
ld a,(CURSOR_X)
swap a
add 8
ldi (hl),a
ld a,T_CURSORV
ldi (hl),a
xor a
ldi (hl),a
;Cursor top right
ld a,(CURSOR_Y)
swap a
add 16
sub c
ldi (hl),a
ld a,(CURSOR_X)
swap a
add 8+8
ldi (hl),a
ld a,T_CURSORV
ldi (hl),a
ld a,%00100000
ldi (hl),a
;Cursor bottom left
ld a,(CURSOR_Y)
swap a
add 16+16
add c
ldi (hl),a
ld a,(CURSOR_X)
swap a
add 8
ldi (hl),a
ld a,T_CURSORV
ldi (hl),a
ld a,%01000000
ldi (hl),a
;Cursor bottom right
ld a,(CURSOR_Y)
swap a
add 16+16
add c
ldi (hl),a
ld a,(CURSOR_X)
swap a
add 8+8
ldi (hl),a
ld a,T_CURSORV
ldi (hl),a
ld a,%01100000
ldi (hl),a
ret