/[projet1]/public/oric/demos/buggy_boy/LcpIntro/tune_fr08.s
Defence Force logotype

Contents of /public/oric/demos/buggy_boy/LcpIntro/tune_fr08.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 903 - (show annotations)
Sun Jan 13 15:30:30 2013 UTC (6 years, 10 months ago) by dbug
File size: 11502 byte(s)
Added the Buggy Boy demo.
Please note that the building of the DSK file requires working versions of Tap2Dsk and Old2Mfm, they may not work on recent windows versions.
1 //1K music player
2
3 //music is arranged in a similar format to PT3 but reduced alot
4
5 #define via_portb $0300
6 #define via_t1cl $0304
7 #define via_t1ch $0305
8 #define via_t1ll $0306
9 #define via_t1lh $0307
10 #define via_t2ll $0308
11 #define via_t2ch $0309
12 #define via_sr $030A
13 #define via_acr $030b
14 #define via_pcr $030c
15 #define via_ifr $030D
16 #define via_ier $030E
17 #define via_porta $030f
18
19 #define FR08_WIDTH 205
20 #define FR08_HEIGHT 40
21
22 #define FR08_X0 120-(FR08_WIDTH/2)
23 #define FR08_Y0 100-(FR08_HEIGHT/2)
24
25 #define FR08_X1 120+(FR08_WIDTH/2)
26 #define FR08_Y1 100+(FR08_HEIGHT/2)
27
28 #define FR08_DECOUNT 8
29
30
31 .zero
32
33 // *=$00 //6
34
35 runtime_pattern_addresses .dsb 6 // $00 //00-05
36 period_counter .dsb 1 // $06 //06/08/0a
37 current_period .dsb 5 // $07 //07/09/0b
38 current_effect .dsb 3 // $0c //0c/0d/0e
39 effect_index .dsb 3 // $10 //10,11,12
40 event_index .dsb 1 // $0f //0f only
41 fade_flag .dsb 1 //
42
43
44 //.data
45 .text
46
47
48 // 0 1
49 // 3 2
50 Fr08_Table_X
51 .byt FR08_X0,FR08_X1,FR08_X1,FR08_X0,FR08_X0
52
53 Fr08_Table_Y
54 .byt FR08_Y0,FR08_Y0,FR08_Y1,FR08_Y1,FR08_Y0
55
56 Fr08_Counter
57 .byt FR08_DECOUNT
58
59 .text
60
61 _Sequence_Fr08
62 //jmp _Sequence_Fr08
63 .(
64 // Switch to hire resolution
65 // We need it to draw the rectangle
66 jsr _SwitchToHires
67 jsr _ClearHiresScreen
68
69 // Draw the FR08 progression bar rectangle
70 ldx #0
71 loop_draw_rectangle
72 lda Fr08_Table_X,x
73 sta _CurrentPixelX
74 lda Fr08_Table_Y,x
75 sta _CurrentPixelY
76
77 inx
78
79 lda Fr08_Table_X,x
80 sta _OtherPixelX
81 lda Fr08_Table_Y,x
82 sta _OtherPixelY
83
84 txa
85 pha
86 jsr _DrawLine
87 pla
88 tax
89
90 cpx #4
91 bne loop_draw_rectangle
92
93
94 //
95 // Init position
96 //
97 lda #FR08_X0+2
98 sta _CurrentPixelX
99 lda #FR08_Y0+2
100 sta _CurrentPixelY
101
102 lda #FR08_X0+2
103 sta _OtherPixelX
104 lda #FR08_Y1-2
105 sta _OtherPixelY
106
107
108
109 //init 6522 & ay
110 sei
111
112 /*
113 lda #$10
114 sta via_t1ll
115 lda #$27
116 sta via_t1lh
117 */
118 lda #<20000
119 sta via_t1ll
120 lda #>20000
121 sta via_t1lh
122
123
124 lda #%10000000
125 sta via_ier
126 lda #%11000000
127 sta via_ier
128 lda #<irq_player
129 sta $FFFE
130 lda #>irq_player
131 sta $FFFF
132 ldx #01
133 stx period_counter
134 stx period_counter+2
135 stx period_counter+4
136 dex
137 stx event_index
138 stx current_effect
139 stx current_effect+1
140 stx current_effect+2
141 stx fade_flag
142 ldx #0
143 stx _SystemEffectTrigger
144 jsr proc_events
145
146 ldx #04
147 irqd_01
148 jsr proc_pattern
149 dex
150 dex
151 bpl irqd_01
152
153 .(
154 cli
155 indefinate_loop
156 //
157 // Draw a line
158 //
159 dec Fr08_Counter
160 bne skip
161
162 lda #FR08_DECOUNT
163 sta Fr08_Counter
164
165 jsr _DrawLine
166
167 inc _CurrentPixelX
168 inc _OtherPixelX
169 skip
170 jsr _VSync
171
172 nop
173 nop
174 lda _SystemEffectTrigger
175 beq indefinate_loop
176 .)
177
178 //
179 // Reinstall a stupid IRQ
180 //
181 jsr _System_InstallIRQ_SimpleVbl
182 rts
183 .)
184
185
186
187 //redirect irq
188 //init music
189 //rts
190
191 //1kdemopats
192 //Existing format?
193 //Method of conversion...
194 //1)Save patterns to disc, then load and save memory range to tape
195 //2)Remove header/convert to hex dump
196 //3)Isolate real patterns (Each pattern is always 128 bytes long) for each chan
197 // arranged as 32 for A, then 32 for B then 32 for C
198 //4)replace "$fe,$00" with "rst" to easily isolate number of rests
199 //5)work through each pattern, using new format. Always use rests+1
200 // Keep a copy of original intact, incase of mistakes.
201
202 // Event Format (No offsets, no repeats)
203
204
205 // 00-31 Pattern Number
206 // +128 Begin Fade because this is the Last Event
207
208 EventsA
209 .byt 0,0,1,2,3
210 EventsB
211 .byt 0,0,0,0,0
212 EventsC
213 .byt 0,1,2,3,4+128
214
215 pattern_addressAlo
216 .byt <patternA0,<patternA1,<patternA2,<patternA3
217 pattern_addressAhi
218 .byt >patternA0,>patternA1,>patternA2,>patternA3
219 pattern_addressBlo
220 .byt <patternB0
221 pattern_addressBhi
222 .byt >patternB0
223 pattern_addressClo
224 .byt <patternC0,<patternC1,<patternC2,<patternC3,<patternC4
225 pattern_addressChi
226 .byt >patternC0,>patternC1,>patternC2,>patternC3,>patternC4
227
228
229 // Pattern format (30 bytes for this pattern!!)
230 // 000-127 Note
231 // 128-191 New Period
232 // 192-199 New Effect (0-7)
233 // 200-200 End of pattern
234
235 patternA0
236 .byt 128+6,192,$18,128+2,$1f
237 .byt 128+4,$1f,$18
238 .byt 128+6,$18,128+2,$1f
239 .byt 128+4,$1f,$18
240 .byt 128+6,$18,128+2,$1f
241 .byt 128+4,$1f,$18
242 .byt 128+6,$18,128+2,$1f
243 .byt 128+4,$1f,$13
244 .byt 200
245
246 patternA1
247 .byt 128+6,192,$21,128+2,$1c
248 .byt 128+4,$1c,$21
249 .byt 128+6,$21,128+2,$1c
250 .byt 128+4,$1c,$15
251 .byt 128+6,$1a,128+2,$1f
252 .byt 128+4,$1f,$1a
253 .byt 128+6,$1a,128+2,$1f
254 .byt 128+4,$1f,$0e
255 .byt 200
256
257 patternA2
258 .byt 128+6,192,$1d,128+2,$24
259 .byt 128+4,$24,$1d
260 .byt 128+6,$1d,128+2,$24
261 .byt 128+4,$24,$1d
262 .byt 128+6,$18,128+2,$1f
263 .byt 128+4,$1f,$18
264 .byt 128+6,$18,128+2,$1f
265 .byt 128+4,$1f,$1f
266 .byt 200
267
268 patternA3
269 .byt 128+6,192,$1f,128+2,$1a
270 .byt 128+4,$1a,$1f
271 .byt 128+6,$1f,128+2,$1a
272 .byt 128+4,$1a,$1f
273 .byt 128+6,$18,128+2,$1f
274 .byt 128+4,$1f,$18
275 .byt 128+6,$18,128+2,$1f
276 .byt 128+4,$1f,$1f
277 .byt 200
278
279 patternB0
280 .byt 128+4,192+2,$7d,192+1,$4e
281 .byt 192+2,$7d,192+1,128+2,$4e,$4e
282 .byt 192+2,$7d,$7d,128+4,192+1,$4e
283 .byt 192+2,$7d,128+2,192+1,$4e,$4e
284 .byt 192+2,128+4,$7d,192+1,$4e
285 .byt 192+2,$7d,128+2,192+1,$4e,$4e
286 .byt 192+2,$7d,$7d,128+4,192+1,$4e
287 .byt 192+2,$7d,128+2,192+1,$4e,$4e
288 .byt 200
289
290 patternC0
291 .byt 128+32,$7f,$7f,200
292
293 patternC1
294 .byt 192+0,128+4,$34,128+2,$30,128+20,$2b
295 .byt 128+2,$2b,$2d,128+4,$2e
296 .byt $30,$32
297 .byt 128+6,$34
298 .byt 128+4,$35,128+2,$37,128+4,$39
299 .byt 128+6,$3a
300 .byt 200
301
302 patternC2
303 .byt 128+2,192+0,$39,128+4,$37,128+20,$31
304 .byt 128+2,$32,128+4,$34
305 .byt $35,128+2,$37,128+4,$35
306 .byt 128+6,$34
307 .byt 128+2,$32,128+4,$34,$35
308 .byt 128+6,$37
309 .byt 200
310
311 patternC3
312 .byt 192+0,128+2,$38,128+4,$37,128+20,$35
313 .byt 128+2,$30,128+4,$32
314 .byt 128+2,$34,128+4,$35,128+20,$37
315 .byt 128+2,$34,$32,$30
316 .byt 200
317
318 patternC4
319 .byt 192+0,128+20,$37
320 .byt 128+2,$37,128+4,$39
321 .byt 128+2,$37,$33,$32
322 .byt 128+32,$30
323 .byt 200
324
325
326 effect_address_lo //3 effects for this demo
327 .byt <effect0,<effect1,<effect2
328 effect_address_hi //3 effects for this demo
329 .byt >effect0,>effect1,>effect2
330
331
332 effect0
333 .byt 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,16,0
334 effect1
335 .byt 15,5,16,0
336 effect2
337 .byt 15+16,14+16,13+16,12+16,11+16,10+16,9+16,8+16,7+16,6+16,5+16,4+16,3+16
338 .byt 2+16,1+16,16,0
339
340 /*
341 effect0
342 .byt 7,7,6,6,5,5,4,4,3,3,2,2,1,1,0,16,0
343 effect1
344 .byt 7,3,16,0
345 effect2
346 .byt 7+16,7+16,6+16,6+16,5+16,5+16,4+16,4+16,3+16,3+16,2+16,2+16,1+16
347 .byt 1+16,1+16,16,0
348 */
349
350
351 /*
352 effect0
353 .byt 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,16,0
354 effect1
355 .byt 15,5,16,0
356 effect2
357 .byt 15+16,14+16,13+16,12+16,11+16,10+16,9+16,8+16,7+16,6+16,5+16,4+16,3+16
358 .byt 2+16,1+16,16,0
359 */
360
361
362
363 irq_player
364 // reserve registers
365 // used to conserve bytes, not speed
366 pha
367 tya
368 pha
369 txa
370 pha
371
372 inc _VblCounter
373
374 // reset timer
375 lda via_t1cl
376 // delay music (10 tempo which equates to 25)
377 irqp_03
378 lda #00
379 clc
380 adc #51 // #25
381 sta irqp_03+1
382 bcc irqp_04
383 // process music
384 // Note - We use 4/2/0 index for two reasons...
385 // 1) we can use lda (,x) opcode to fetch pattern entry
386 // 2) we can directly index ay_table for pitch
387 ldx #04
388 irqp_01
389 dec period_counter,x
390 bne irqp_07
391 jsr proc_pattern
392
393 pha
394 lda _SystemEffectTrigger
395 beq continue
396 pla
397 jmp end_irq
398
399 continue
400 pla
401
402
403 irqp_07
404 dex
405 dex
406 bpl irqp_01
407 irqp_04
408 //Delay SFX (4 which equates as 64)
409 irqp_05
410 lda #00
411 adc #128
412 sta irqp_05+1
413 bcc irqp_06
414 jsr proc_sfx
415 //send_ay
416 irqp_06
417 ldx #$0a
418 irqp_02
419 stx via_porta
420 lda #$ff
421 sta via_pcr
422 ldy #$dd
423 sty via_pcr
424 lda ay_table,x
425 sta via_porta
426 lda #$fd
427 sta via_pcr
428 sty via_pcr
429 dex
430 bpl irqp_02
431
432 end_irq
433 //restore registers
434 pla
435 tax
436 pla
437 tay
438 pla
439 rti
440
441
442 proc_sfx
443 ldx #02
444 sfx_05
445 ldy current_effect,x
446 lda effect_address_lo,y
447 sta sfx_01+1
448 lda effect_address_hi,y
449 sta sfx_01+2
450 ldy effect_index,x
451 sfx_01
452 lda $bf00,y
453 pha
454 and #15
455 sta ay_table+8,x //Store volume
456 pla
457 beq sfx_04
458 and #%11110000
459 lsr
460 lsr
461 lsr
462 beq sfx_02
463 sta ay_table+6 //Store noise
464 lda ay_table+7 //fetch status
465 and bitmask,x //enable noise
466 jmp sfx_03
467 sfx_02
468 lda ay_table+7 //fetch status
469 ora bitpos,x //disable noise
470 sfx_03
471 sta ay_table+7
472 inc effect_index,x
473 sfx_04
474 //end
475 //Add Tremelo to pitch
476 txa
477 asl
478 tay
479 lda ay_table,y
480 eor #01
481 sta ay_table,y
482 dex
483 bpl sfx_05
484 rts
485
486 proc_pattern
487 pp_05
488 lda (runtime_pattern_addresses,x)
489 //lda (00,x) //xa doesn't like runtime_pattern_addresslo here
490 ldy #03
491 pp_01
492 cmp pattern_entity_range,y
493 bcs pp_02
494 dey
495 bpl pp_01
496 //On Error, increment base and move onto next channel
497 pp_02
498 pha
499 lda pattern_entity_range_vector_lo,y
500 sta pp_03+1
501 lda pattern_entity_range_vector_hi,y
502 sta pp_03+2
503 pla
504 sbc pattern_entity_range,y
505 pp_03
506 jsr $bf00
507 bcs pp_05
508 rts
509
510 inc_pattern_entry
511 inc runtime_pattern_addresses,x
512 bne pp_04
513 inc runtime_pattern_addresses+1,x
514 pp_04
515 rts
516
517 pattern_note
518 //This is because the note would usually be based from 64
519 //which is default event offset
520 // adc #32
521 and #127
522 ldy #$ff //Calculate pitch
523 sec
524 cp_01
525 iny
526 sbc #12
527 bcs cp_01
528 adc #12
529 //y is octave
530 //a is note
531 //convert note to base pitch
532 sty cp_02+1
533 tay
534 lda base_pitch_lo,y
535 sta cp_05+1
536 lda base_pitch_hi,y
537 //shift base pitch to octave
538 cp_02
539 ldy #00
540 beq cp_03
541 cp_04
542 lsr
543 ror cp_05+1
544 dey
545 bne cp_04
546 cp_03
547 sta ay_table+1,x
548 cp_05
549 lda #00
550 sta ay_table,x
551 lda current_period,x
552 sta period_counter,x
553 txa
554 lsr
555 tay
556 lda #00
557 sta effect_index,y
558 lda #15
559 //lda #7 // Reduced volume
560 sta ay_table+8,y
561 clc
562 jmp inc_pattern_entry
563 pattern_period
564 sta current_period,x
565 sec
566 jmp inc_pattern_entry
567 pattern_effect
568 pha
569 txa
570 lsr
571 tay
572 pla
573 sta current_effect,y
574 sec
575 jmp inc_pattern_entry
576 pattern_eop
577 stx peop_01+1
578 proc_events
579 ldx fade_flag
580 bne end_music
581 ldx event_index
582 ldy EventsA,x
583 lda pattern_addressAlo,y
584 sta runtime_pattern_addresses+0
585 lda pattern_addressAhi,y
586 sta runtime_pattern_addresses+1
587 ldy EventsB,x
588 lda pattern_addressBlo,y
589 sta runtime_pattern_addresses+2
590 lda pattern_addressBhi,y
591 sta runtime_pattern_addresses+3
592 lda EventsC,x
593 bpl peop_02
594 ldy #64
595 sty fade_flag
596 and #127
597 peop_02
598 tay
599 lda pattern_addressClo,y
600 sta runtime_pattern_addresses+4
601 lda pattern_addressChi,y
602 sta runtime_pattern_addresses+5
603 inc event_index
604 peop_01
605 ldx #00
606 rts
607
608 end_music
609 //jmp end_music
610 lda #255 //Trigger mem
611 sta _SystemEffectTrigger
612 clc
613 rts
614
615
616 // 000-127 Note
617 // 128-191 New Period
618 // 192-199 New Effect (0-7)
619 // 200-200 End of pattern
620 pattern_entity_range
621 .byt 0,128,192,200
622 pattern_entity_range_vector_lo
623 .byt <pattern_note,<pattern_period,<pattern_effect,<pattern_eop
624 pattern_entity_range_vector_hi
625 .byt >pattern_note,>pattern_period,>pattern_effect,>pattern_eop
626 ay_table
627 .byt 0,0 //a pitch lo/hi
628 .byt 0,0 //b pitch lo/hi
629 .byt 0,0 //c pitch lo/hi
630 .byt 0 //Noise
631 .byt 64+32+16+8 //Status (noise off by default)
632 .byt 0,0,0 //Volumes a,b,c
633 base_pitch_lo
634 .byt $ee,$16,$4c,$8e,$d8,$2e,$8e,$f6,$66,$e0,$60,$e8
635 base_pitch_hi
636 .byt $0e,$0e,$0d,$0c,$0b,$0b,$0a,$09,$09,$08,$08,$07
637 bitmask //for noise
638 .byt 255-8,255-16,255-32
639 bitpos //for noise
640 .byt 8,16,32
641
642 end_of_music
643 .byt 0
644
645
646
647

  ViewVC Help
Powered by ViewVC 1.1.26