-
Notifications
You must be signed in to change notification settings - Fork 0
/
huby1943.asm
445 lines (413 loc) · 14.3 KB
/
huby1943.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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
;1943 - Huby engine.
;;converted over to Aquarius by Bushy.
;Assembled to $e000 with Pasmo Assembler.
;
;
;Load in Binary file : "huby1943.bin"
;at memory $E000
;usr Execution at $0000
;Then back at basic, run X=USR(0)
;
;---------------
; *****************************************************************************
; * Huby beeper music engine by Shiru (shiru@mail.ru) 04'11
; * updated 99b version 11'13
; * By Shiru
; *
; * Tempo mod by Chris Cowley
; *
; * Produced by Beepola v1.08.01
; ******************************************************************************
;
;
; ! Assemble with PASMO !
; ! pasmo --alocal %1.asm %1.bin
;
;
; org $4000 ; Aquarius 4k cassette.
; org $c000 ; Aquarius lower 8k cartridge
org $e000 ; Aquarius upper 8k cartridge
db 98, 117, 115, 104
db 121, 156, 50, 176
db 48, 108, 50, 100
db 50, 168, 183, 112
START:
di
LD HL,MUSICDATA
CALL HUBY_PLAY
; Only loop back to start if a key is not pressed, otherwise RETurn
; IN A,($FE)
; CPL
; AND $1F
; JR Z,START
RET
OP_INCL: EQU $2C
HUBY_PLAY: LD C,(HL) ; Read the tempo word
INC HL
LD B,(HL)
INC HL
LD E,(HL) ; Offset to pattern data is
INC HL ; kept in DE always.
LD D,(HL) ; And HL = current position in song layout.
READPOS: INC HL
LD A,(HL) ; Read the pattern number for channel 1
INC HL
OR A
RET Z ; Zero signifies the end of the song
; This code is for handling Tempo changes in the middle of a song.
; As the song data specified in Beepola (see MUSICDATA below) doesn't
; have any tempo changes, this code has been commented out to save 9
; bytes. Uncomment it if you want to use this routine to play tunes
; that contain mid-song tempo changes...
; CP $FF ; $FF signifies SET TEMPO
; JR NZ,NOT_TEMPO
; LD C,(HL)
; INC HL
; LD B,(HL)
; JR READPOS
NOT_TEMPO: PUSH HL ; Store the layout pointer
PUSH DE ; Store the pattern offset pointer
PUSH BC ; Store current tempo
LD L,(HL) ; Read the pattern number for channel 2
LD B,2 ; DJNZ through following code twice (1x for each channel)
CALC_ADR: LD H,0 ; Multiply pattern number by 8...
ADD HL,HL ; x2
ADD HL,HL ; x4
ADD HL,HL ; x8
ADD HL,DE ; Add the offset to the pattern data
PUSH HL ; Store the address of pattern data
LD L,A
DJNZ CALC_ADR ; Do the same thing for channel 2
EXX
POP HL
POP DE
LD B,8 ; Fixed pattern length = 8 rows
READ_ROW: LD A,(DE) ; Read note for channel 1
INC DE ; inc channel 1 row pointer
EXX
LD H,A
LD D,A
EXX
LD A,(HL) ; Read note for channel 2
INC HL ; inc channel 2 row pointer
EXX
LD L,A
LD E,A
CP OP_INCL ; If channel 1 note == $2C then play drum
JR Z,SET_DRUMSLIDE
XOR A
SET_DRUMSLIDE: LD (SND_SLIDE),A
POP BC ; Retrieve tempo
PUSH BC
DI
SOUND_LOOP: XOR A
DEC E
JR NZ,SND_LOOP1
LD E,L
SUB L
SND_SLIDE: NOP ; This is set to INC L for the drum sound
SND_LOOP1: DEC D
JR NZ,SND_LOOP2
LD D,H
SUB H
SND_LOOP2: SBC A,A
out ($fc),a ;11 ; Aquarius
; out ($fe),a ;11 ; ZX
; AND $21 ; VZ
; ld ($6800), a ; VZ
; out (2),a ;11 ; MICROBEE
DEC BC
LD A,B
OR C
JR NZ,SOUND_LOOP ; 113/123 Ts
SND_LOOP3: LD HL,$2758 ; Set HL' for returning to BASIC
EXX
EI
JR NZ,PATTERN_END
DJNZ READ_ROW
PATTERN_END: POP BC
POP DE
POP HL
JR Z,READPOS ; No key pressed, goto next pattern
RET ; Otherwise return
; ************************************************************************
; * Song data...
; ************************************************************************
BORDER_CLR: EQU $0
; *** DATA ***
MUSICDATA:
DEFW $09A0 ; Initial tempo
DEFW PATTDATA - 8 ; Ptr to start of pattern data - 8
DEFB $01
DEFB $02
DEFB $01
DEFB $03
DEFB $01
DEFB $04
DEFB $01
DEFB $05
DEFB $06
DEFB $07
DEFB $08
DEFB $09
DEFB $0A
DEFB $01
DEFB $0B
DEFB $01
DEFB $0C
DEFB $0D
DEFB $0E
DEFB $0F
DEFB $10
DEFB $11
DEFB $12
DEFB $13
DEFB $06
DEFB $07
DEFB $08
DEFB $09
DEFB $0A
DEFB $01
DEFB $0B
DEFB $01
DEFB $0C
DEFB $0D
DEFB $0E
DEFB $0F
DEFB $10
DEFB $11
DEFB $12
DEFB $13
DEFB $06
DEFB $14
DEFB $15
DEFB $01
DEFB $06
DEFB $01
DEFB $15
DEFB $01
DEFB $16
DEFB $17
DEFB $16
DEFB $18
DEFB $19
DEFB $1A
DEFB $19
DEFB $01
DEFB $1B
DEFB $1C
DEFB $1B
DEFB $1D
DEFB $16
DEFB $14
DEFB $16
DEFB $01
DEFB $1E
DEFB $1F
DEFB $1E
DEFB $20
DEFB $19
DEFB $1F
DEFB $19
DEFB $01
DEFB $21
DEFB $22
DEFB $21
DEFB $23
DEFB $24
DEFB $25
DEFB $26
DEFB $01
DEFB $16
DEFB $17
DEFB $16
DEFB $18
DEFB $19
DEFB $1A
DEFB $19
DEFB $01
DEFB $1B
DEFB $1C
DEFB $1B
DEFB $1D
DEFB $16
DEFB $14
DEFB $16
DEFB $01
DEFB $1E
DEFB $1F
DEFB $1E
DEFB $20
DEFB $19
DEFB $1F
DEFB $19
DEFB $01
DEFB $21
DEFB $22
DEFB $21
DEFB $27
DEFB $16
DEFB $25
DEFB $28
DEFB $01
DEFB $29
DEFB $01
DEFB $06
DEFB $01
DEFB $06
DEFB $07
DEFB $08
DEFB $09
DEFB $0A
DEFB $01
DEFB $0B
DEFB $01
DEFB $0C
DEFB $0D
DEFB $0E
DEFB $0F
DEFB $10
DEFB $11
DEFB $12
DEFB $13
DEFB $06
DEFB $07
DEFB $08
DEFB $2A
DEFB $0A
DEFB $01
DEFB $0B
DEFB $01
DEFB $0C
DEFB $07
DEFB $0C
DEFB $2B
DEFB $10
DEFB $2C
DEFB $2D
DEFB $2E
DEFB $06
DEFB $14
DEFB $15
DEFB $01
DEFB $06
DEFB $01
DEFB $15
DEFB $01
DEFB $16
DEFB $17
DEFB $16
DEFB $18
DEFB $19
DEFB $1A
DEFB $19
DEFB $01
DEFB $1B
DEFB $1C
DEFB $1B
DEFB $1D
DEFB $16
DEFB $14
DEFB $16
DEFB $01
DEFB $1E
DEFB $1F
DEFB $1E
DEFB $20
DEFB $19
DEFB $1F
DEFB $19
DEFB $01
DEFB $21
DEFB $22
DEFB $21
DEFB $23
DEFB $24
DEFB $25
DEFB $26
DEFB $01
DEFB $16
DEFB $17
DEFB $16
DEFB $18
DEFB $19
DEFB $1A
DEFB $19
DEFB $01
DEFB $1B
DEFB $1C
DEFB $1B
DEFB $1D
DEFB $16
DEFB $14
DEFB $16
DEFB $01
DEFB $1E
DEFB $1F
DEFB $1E
DEFB $20
DEFB $19
DEFB $1F
DEFB $19
DEFB $01
DEFB $21
DEFB $22
DEFB $21
DEFB $27
DEFB $16
DEFB $25
DEFB $28
DEFB $01
DEFB $29
DEFB $01
DEFB $06
DEFB $01
DEFB $00 ; End of song
PATTDATA:
DEFB $00, $00, $00, $00, $00, $00, $00, $00
DEFB $66, $00, $00, $00, $60, $00, $00, $00
DEFB $5B, $00, $00, $00, $56, $00, $00, $00
DEFB $51, $00, $00, $00, $4C, $00, $00, $00
DEFB $48, $00, $00, $00, $44, $00, $00, $00
DEFB $80, $00, $80, $00, $80, $00, $80, $00
DEFB $20, $00, $00, $00, $20, $00, $00, $00
DEFB $2C, $00, $80, $00, $2C, $00, $80, $00
DEFB $00, $00, $24, $00, $20, $00, $24, $00
DEFB $90, $00, $90, $00, $90, $00, $90, $00
DEFB $2C, $00, $90, $00, $2C, $00, $90, $00
DEFB $A1, $00, $A1, $00, $A1, $00, $A1, $00
DEFB $28, $00, $00, $00, $28, $00, $00, $00
DEFB $2C, $00, $A1, $00, $2C, $00, $A1, $00
DEFB $00, $00, $28, $00, $30, $00, $36, $00
DEFB $97, $00, $97, $00, $97, $00, $97, $00
DEFB $39, $00, $00, $40, $00, $00, $39, $00
DEFB $2C, $00, $88, $00, $88, $00, $88, $00
DEFB $39, $00, $00, $44, $00, $00, $39, $00
DEFB $19, $00, $00, $00, $00, $00, $00, $00
DEFB $80, $00, $80, $00, $80, $00, $90, $88
DEFB $40, $00, $80, $00, $80, $00, $40, $80
DEFB $33, $00, $00, $00, $00, $00, $00, $00
DEFB $00, $00, $00, $00, $30, $00, $2D, $00
DEFB $44, $00, $88, $00, $88, $00, $44, $88
DEFB $2B, $00, $00, $00, $00, $00, $00, $00
DEFB $4C, $00, $97, $00, $97, $00, $4C, $97
DEFB $26, $00, $00, $00, $00, $00, $00, $00
DEFB $00, $00, $22, $00, $20, $00, $1C, $00
DEFB $39, $00, $72, $00, $72, $00, $39, $72
DEFB $18, $00, $00, $00, $00, $00, $00, $00
DEFB $00, $00, $13, $00, $00, $00, $15, $00
DEFB $56, $00, $AB, $00, $AB, $00, $56, $AB
DEFB $1C, $00, $00, $00, $00, $00, $00, $00
DEFB $00, $00, $18, $00, $00, $00, $19, $00
DEFB $80, $00, $80, $40, $88, $00, $80, $40
DEFB $20, $00, $00, $00, $00, $00, $00, $00
DEFB $97, $00, $80, $40, $AB, $00, $80, $40
DEFB $2B, $00, $00, $00, $1C, $00, $00, $00
DEFB $40, $00, $80, $00, $40, $00, $40, $80
DEFB $80, $FF, $80, $FF, $80, $FF, $80, $FF
DEFB $1B, $00, $1C, $00, $20, $00, $24, $00
DEFB $1B, $00, $1C, $00, $20, $00, $1B, $00
DEFB $18, $00, $00, $20, $00, $00, $18, $00
DEFB $88, $00, $88, $00, $88, $00, $88, $00
DEFB $15, $00, $00, $1C, $00, $00, $15, $00
end