-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.asm
232 lines (202 loc) · 4.87 KB
/
demo.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
; ROLLING DEMO
; This works by playing a game with certain elements in a different mode:
; * A different tune selection is chosen
; * The tet maker always collects next tet from the list
; * The inputs aren't taken from the keyboard, but from a list of movements and delays
; * When the end token for the demo is reached, it performs a fade-out and exits the game
;----------------------------------------------
demo.tet_list: ; List of blocks delivered in demo mode
db tet.i,tet.z,tet.j,tet.l,tet.z,tet.t,tet.o,tet.s,tet.t,tet.i,tet.t,tet.z,-1
@left: equ %00010000
@right: equ %00001000
@down: equ %00000100
@rotateC: equ %10000000
@rotateAC: equ %00000001
@no_input: equ 0
demo.move_list:
; List of moves and delays after move made
; # frames input, input type. Termination happens after x frames have elapsed
; Note to self: This is an awful way to make a 'natural' looking demo, better to record a real player in future.
db 13,@no_input ; Initial delay to start
db 30,@no_input ; tet.i
db 0,@left
db 9,@no_input
db 0,@left
db 12,@no_input
db 0,@left
db 30,@no_input
db 32,@down
db 38,@no_input ; tet.z
db 40,@down
db 27,@no_input ; tet.j
db 2,@rotateAC
db 14,@no_input
db 2,@rotateAC
db 18,@no_input
db 0,@left
db 12,@no_input
db 0,@left
db 14,@no_input
db 0,@left
db 20,@no_input
db 28,@down
db 40,@no_input ; tet.l
db 0,@right
db 14,@no_input
db 0,@right
db 16,@no_input
db 2,@rotateAC
db 20,@no_input
db 2,@rotateAC
db 14,@no_input
db 18,@down
db 20,@no_input
db 10,@down
db 30,@no_input ; tet.z
db 1,@right
db 14,@no_input
db 1,@left
db 17,@no_input
db 1,@left
db 14,@no_input
db 1,@left
db 15,@no_input
db 1,@left
db 15,@no_input
db 1,@left
db 14,@no_input
db 25,@down
db 35,@no_input ; tet.t
db 2,@rotateC
db 12,@no_input
db 2,@rotateC
db 26,@no_input
db 12,@down
db 1,@right
db 15,@no_input
db 12,@down
db 44,@no_input ; tet.o
db 0,@right
db 12,@no_input
db 0,@right
db 16,@no_input
db 0,@right
db 22,@no_input
db 30,@down
db 36,@no_input ; tet.s
db 0,@right
db 18,@no_input
db 26,@down
db 24,@no_input ; tet.t
db 0,@left
db 24,@no_input
db 26,@down
db 36,@no_input ; tet.i
db 1,@right
db 12,@no_input
db 0,@rotateAC
db 20,@no_input
db 1,@right
db 12,@no_input
db 1,@right
db 50,@no_input
db 20,@down
db 80,@no_input ; tet.t
db 2,@rotateAC
db 14,@no_input
db 2,@rotateAC
db 18,@no_input
db 1,@left
db 30,@no_input
db 1,@left
db 18,@no_input
db 1,@left
db 14,@no_input
db 18,@down
db 10,@no_input ; tet.z
db 255,@no_input
db 255,@no_input
demo.time: equ 50*30 ; Amount of frames demo plays for
;----------------------------------------------
demo.reset_tet:
; Reset position of tet feed in demo mode
ld hl,demo.tet_list
ld (@+tet_pos+1),hl
ret
demo.get_tet:
; Return A with next tet from recorded list.
@tet_pos: ld hl,0
ld a,(hl)
inc hl
ld (@-tet_pos+1),hl
@test_fade_out: ; Fade out music if next tet is blank
ex af,af'
ld a,(hl)
cp -1
jr nz,@+skip
@start_fade:
ld a,Yes
ld (music.fade.on),a
@skip:
ex af,af'
ret
;----------------------------------------------
demo.reset_input:
; Reset feed of key input in demo mode
ld hl,demo.move_list
ld (@+move_pos+1),hl
xor a
ld (@+input_timer+1),a
ret
demo.get_input:
; Return A with processed key input for next frame
@update_timer:
@input_timer: ld a,0
or a
jr z,@+new_move
dec a
ld (@-input_timer+1),a
xor a
ret
@new_move:
@age_moves:
ld a,(keys.curr)
ld (keys.prev),a
@move_pos: ld hl,0
ld a,(hl)
ld (@-input_timer+1),a
inc hl
ld a,(hl)
inc hl
ld (@-move_pos+1),hl
ld (keys.curr),a
call keys.process
ret
;----------------------------------------------
demo.reset_timer:
ld hl,demo.time
ld (@+timer+1),hl
ret
demo.update_timer:
; Update overall segment timer, return Z if timer run out
ld a,(demo.mode.on)
cp On
ret nz
@test_input: ; Check for any keypresses
call keys.collect
or a
jr z,@+update_timer
@quit: ; On any keypress, quit back to main attract mode
pop hl
call music.off
call attract.demo_off
call house.clear_screens
jp main.attract_mode
@update_timer:
@timer: ld hl,demo.time
dec hl
ld (@-timer+1),hl
ld a,h
or l
or a
ret