-
Notifications
You must be signed in to change notification settings - Fork 0
/
XANADU.ELPC
879 lines (753 loc) · 21.4 KB
/
XANADU.ELPC
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
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
#output "xanadu-basic65"
'============
.declarations
'============
' music related vars
' ------------------
#declare music_chunk_index ' old t
#declare bar_index ' old tt
#declare map_bar_to_chunk(10) ' old m()
#declare v1$(4), v2$(4), v3$(4), v4$(4)
' palette
' -------
#declare default_red(32)
#declare default_green(32)
#declare default_blue(32)
#declare curr_red(32)
#declare curr_green(32)
#declare curr_blue(32)
#declare fadeval, tempval
' I/O
' ---
#define HOTREG_7 = $d05d
#define SCRNPTRLSB = $d060
#define SCRNPTRBNK = $d062
' misc
' ----
#declare k,m,n
#declare rainbowstr$
#declare rainbow_x, rainbow_y
#declare plen=0
#declare subtext$(2)
#declare subtext_idx = 0
subtext$(0) = "presents..."
subtext$(1) = "a tribute to the late olivia newton john..."
#declare pan_idx = 0
#declare pan_src_idx
#declare pan_dest_idx
#declare pan_y, pan_len
' petscii
' -------
#declare data_addr = $4270c
#declare max_frames
#declare frame_addr(64)
#declare frm_idx = 0
#declare frmw, frmh
#declare anims(4,100) ' anim_idx, anim_data
#declare aval,mark(3),gmarknum,gcount,bail,found,frameidx,framedur=0
#declare frmx, frmy, frmx1, frmy1, cdata_addr
#define FRM_STAND = 0
#define FRM_ARM_UP1 = 1
#define FRM_ARM_UP2 = 2
#define FRM_ARM_UP3 = 3
#define FRM_ARM_UP4 = 4
#define FRM_ARM_LEFT1 = 5
#define FRM_ARM_LEFT2 = 6
#define FRM_ARM_LEFT3 = 7
#define FRM_ARM_LEFT4 = 8
#define FRM_CLOSE_EYES = 9
#define FRM_OPEN_MOUTH = 10
#define FRM_CLOSE_MOUTH = 11
#define FRM_ARM_RIGHT1 = 12
#define FRM_ARM_RIGHT2 = 13
#define FRM_ARM_RIGHT3 = 14
#define FRM_ARM_RIGHT4 = 15
#define FRM_RETURN_PAINTBRUSH = 16
#define FRM_ARM_RIGHT5 = 17
#define FRM_ARM_RIGHT6 = 18
#define FRM_LIFT_PAPER1 = 19
#define FRM_LIFT_PAPER2 = 20
#define FRM_SHOCK_FACE = 21
#define FRM_CRINGE_FACE = 22
#define FRM_CROSS_FACE = 23
#define FRM_HORROR_FACE = 24
#define FRM_SAD_FACE = 25
#define FRM_NORM_FACE = 26
#define FRM_RIP1 = 27
#define FRM_RIP2 = 28
#define FRM_RIP3 = 29
#define FRM_RIP4 = 30
#define FRM_RIP5 = 31
#define FRM_RIP6 = 32
#define FRM_RIP7 = 33
#define FRM_RIP8 = 34
#define FRM_RIP9 = 35
#define FRM_RIP10 = 36
#define FRM_RIP11 = 37
#define FRM_PAPER = 38
#define FRM_PAINTING1 = 39
#define FRM_PAINTING2 = 40
#define FRM_PAINTING3 = 41
#define FRM_MURAL = 42
'====
.main
'====
gosub init
gosub bas_logo
gosub xanadu_title
gosub petscii_story
gosub ender
' backup palette to $48000
edma 0, $300, $ffd3100, $48000
' set all colours to black
edma 3, $300, 0, $ffd3100
'TODO: delete
if peek($d020)<>0 then border 2:gosub init_petscii_frames
frameidx=FRM_MURAL
gosub draw_petscii_frame
clr
dload "bigsprite"
end
' action names
#define TXTGREY=0
#define TXTCLEAR=1
#define TXTTALK=2
#define ANIM=3
#define PAINTING=4
#define REACTION=5
#define CLS=6
#define DRAWFRM=7
#define ENDER=8
' animations
#define ANM_PONDER=0
#define ANM_PAINT=1
#define ANM_LIFT=2
#define ANM_RIP=3
.init_petscii_frames
'-------------------
max_frames = peek(data_addr)
data_addr = data_addr + 1
do while frm_idx < max_frames
frame_addr(frm_idx) = data_addr
data_addr = data_addr + 2
frmw = peek(data_addr)
data_addr = data_addr + 1
frmh = peek(data_addr)
data_addr = data_addr + 1
data_addr = data_addr + frmw * frmh * 2
':print chr$(147);"frm_idx=";frm_idx
'frameidx=frm_idx
'gosub draw_petscii_frame
'getkey test2$
frm_idx = frm_idx + 1
loop
return
#declare animidx, animrepeatcount
'=============
.petscii_story
'=============
gosub switch_to_80x25_mode
gosub restore_screen_pointer
palette restore
background 0:border 0
print chr$(147);
gosub init_petscii_frames
gosub init_anims
#declare tstart, time, action, actanim=-1, actpainting
#declare actstr$, actx, acty, actdur, actreaction
#declare acttimer
tstart = ti
read time
action = -1
do while action <> ENDER
' time to switch to next action?
if (ti-tstart) >= time then begin
if action = TXTTALK then gosub clear_txt_talk
read action
acttimer=0
if action = TXTGREY then read actstr$, actx, acty
if action = TXTTALK then read actstr$, actdur
if action = TXTCLEAR then gosub clear_text
if action = ANIM then read actanim:animidx=0:animrepeatcount=0
if action = PAINTING then read actpainting:gosub draw_painting
if action = REACTION then read actstr$, actreaction, actdur:gosub init_reaction
if action = CLS then print "{x93}";
if action = DRAWFRM then read frameidx:gosub draw_petscii_frame
if action = ENDER then exit
tstart = ti
read time ' time for next action
bend
if action = TXTGREY then gosub draw_txt_grey
if action = TXTTALK then gosub draw_txt_talk
if action = REACTION then gosub draw_reaction
gosub poll_play
gosub poll_anim
loop
return
#define MARK1 = -1
#define MARK2 = -2
#define MARK3 = -3
#define REPEAT = -10
#define INFINITELY = -1
#define END_ANIM = -999
#define ALL_ANIMS_FINISHED = -1000
#declare frame_start
.poll_anim
'---------
if actanim = -1 then return
if framedur > 0 and (ti - frame_start) < framedur then return
framedur = 0
'cursor 0,1:print "poll_anim";
'cursor 0,2:print "actanim=";actanim;
'cursor 0,3:print "animidx=";animidx;
aval = anims(actanim,animidx)
animidx = animidx + 1
'print "{x13} {x13}animidx=";animidx;
found = 0
if aval = MARK1 then found=1:mark(1)=animidx
if aval = MARK2 then found=1:mark(2)=animidx
if aval = MARK3 then found=1:mark(3)=animidx
if aval = REPEAT then begin
found=1
' get mark number (in aval)
gmarknum = abs(anims(actanim,animidx))
animidx = animidx + 1
gcount = anims(actanim,animidx)
animidx = animidx + 1
bail=0
if animrepeatcount = 0 then begin
if gcount <> -1 then animrepeatcount = gcount
animidx = mark(gmarknum)
bail=1
bend
if bail=0 and animrepeatcount > 0 then begin
animrepeatcount = animrepeatcount -1
if animrepeatcount = 0 then bail=1
if bail=0 then animidx=mark(gmarknum)
bail=1
bend
'if bail=0 and animrepeatcount = INFINITELY then begin
' animidx=mark(gmarknum)
' bail=1
'bend
bend
if aval = END_ANIM then begin
found = 1
actanim = -1
bend
'cursor 0,8:print "found = ";found;
if found = 0 then begin ' we're drawing a petscii frame now?
frameidx = aval
'cursor 0,5:print "draw frameidx=";frameidx;
'input aval
gosub draw_petscii_frame
framedur = anims(actanim,animidx)
animidx = animidx + 1
frame_start = ti
bend
return
.clear_text
'-----------
edma 3,80,32,$800
return
.draw_txt_grey
'-------------
if acttimer = -1 then return
sleep .05
cursor actx + acttimer, acty
print "{x98}{x4}";mid$(actstr$,1+acttimer,1);
acttimer = acttimer + 1
if acttimer >= len(actstr$) then acttimer = -1
return
.draw_txt_talk
'-------------
if acttimer = -1 then return
sleep .05
actx=(80-len(actstr$))/2+7
acty=1
cursor actx + acttimer, acty
print "{x5}{x4}";mid$(actstr$,1+acttimer,1);
acttimer = acttimer + 1
if acttimer >= len(actstr$) then acttimer = -1
if mod(acttimer,2) = 0 then frameidx=FRM_OPEN_MOUTH:else frameidx=FRM_CLOSE_MOUTH
gosub draw_petscii_frame
return
.clear_txt_talk
'--------------
cursor 0,1:print chr$(27);"q";
return
.draw_petscii_frame
'------------------
data_addr = frame_addr(frameidx)
frmx = peek(data_addr)
data_addr = data_addr + 1
frmy = peek(data_addr)
data_addr = data_addr + 1
frmw = peek(data_addr)
data_addr = data_addr + 1
frmh = peek(data_addr)
data_addr = data_addr + 1
frmx1=frmx+frmw-1
frmy1=frmy+frmh-1
#declare yy, scraddr,clraddr
scraddr = $800 + frmx + frmy * 80
clraddr = $1f800 + frmx + frmy * 80
cdata_addr = data_addr + frmw * frmh
for yy=frmy to frmy1
edma 0, frmw, data_addr, scraddr
edma 0, frmw, cdata_addr, clraddr
data_addr = data_addr + frmw
cdata_addr = cdata_addr + frmw
scraddr = scraddr + 80
clraddr = clraddr + 80
next yy
return
.init_reaction
'-------------
print "{x93}";
frameidx = FRM_STAND:gosub draw_petscii_frame
frameidx = FRM_LIFT_PAPER1:gosub draw_petscii_frame
frameidx = FRM_LIFT_PAPER2:gosub draw_petscii_frame
return
.draw_reaction
'-------------
acttimer = acttimer + 1
sleep .1
if mod(acttimer,2) = 0 then frameidx=FRM_SHOCK_FACE:else frameidx=FRM_HORROR_FACE
gosub draw_petscii_frame
if acttimer > 10 then action = TXTTALK:acttimer = 0
return
.draw_painting
'-------------
print "{x93}";
frameidx = FRM_PAPER
gosub draw_petscii_frame
frameidx = FRM_PAINTING1 + actpainting - 1
gosub draw_petscii_frame
return
#declare rval, aidx, vidx
#declare test$
.init_anims
'----------
aidx = 0
vidx = 0
do
read rval
' print rval;", ";
if rval = ALL_ANIMS_FINISHED then exit
anims(aidx,vidx) = rval
vidx = vidx + 1
if rval = END_ANIM then aidx=aidx+1:vidx=0
loop
return
.anims
'-----
' ANM_PONDER
data FRM_STAND, .3, {x5F}
FRM_ARM_UP1, .3, {x5F}
FRM_ARM_UP2, .3, {x5F}
FRM_ARM_UP3, .3 ' raise arm to chin
data MARK1
data FRM_ARM_UP4, .5, {x5F}
FRM_ARM_UP3, .5, {x5F}
FRM_ARM_UP4, .5, {x5F}
FRM_ARM_UP3, .5 ' scratch chin
data FRM_CLOSE_EYES, 0 , {x5F}
FRM_ARM_UP4, .5, {x5F}
FRM_ARM_UP3, .5, {x5F}
FRM_ARM_UP4, .5, {x5F}
FRM_ARM_UP3, .5 ' close eyes & scratch chin
data FRM_CLOSE_MOUTH, .2 ' normal face
data REPEAT, MARK1, INFINITELY
data END_ANIM
' ANM_PAINT
data FRM_OPEN_MOUTH, 0 , {x5F}
FRM_ARM_LEFT1, 1 ' gaping mouth and finger point up
data FRM_CLOSE_MOUTH,.2, {x5F}
FRM_ARM_LEFT2, .2, {x5F}
FRM_ARM_LEFT3, .2, {x5F}
FRM_ARM_LEFT4, .2, {x5F}
FRM_ARM_RIGHT1, .2, {x5F}
FRM_ARM_RIGHT2, .2 ' get brush
data MARK1
data FRM_CLOSE_MOUTH, .1
data MARK2
data FRM_ARM_RIGHT3, .1, {x5F}
FRM_ARM_RIGHT4, .1
data REPEAT, MARK2, 5
data FRM_CLOSE_EYES, .5
data MARK3
data FRM_ARM_RIGHT3, .1, {x5F}
FRM_ARM_RIGHT4, .1
data REPEAT, MARK3, 5
data REPEAT, MARK1, INFINITELY
data END_ANIM
' ANM_LIFT
data FRM_ARM_RIGHT2, .25, {x5F}
FRM_ARM_RIGHT1, .25, {x5F}
FRM_RETURN_PAINTBRUSH, .5, {x5F}
FRM_ARM_RIGHT5, .25, {x5F}
FRM_ARM_RIGHT6, .25, {x5F}
FRM_LIFT_PAPER1, .25, {x5F}
FRM_LIFT_PAPER2, .25
data MARK1
data FRM_CRINGE_FACE, .1, {x5F}
FRM_CROSS_FACE, .1, {x5F}
REPEAT, MARK1, 5
data END_ANIM
' ANM_RIP
data FRM_NORM_FACE, .2, {x5F}
FRM_RIP1, .1, {x5F}
FRM_RIP2, .1, {x5F}
FRM_RIP3, .1, {x5F}
FRM_RIP4, .1, {x5F}
FRM_RIP5, .1, {x5F}
FRM_RIP6, .1, {x5F}
FRM_RIP7, .1, {x5F}
FRM_RIP8, .1, {x5F}
FRM_RIP9, .1, {x5F}
FRM_RIP10, .1, {x5F}
FRM_RIP11, .1
data END_ANIM
data ALL_ANIMS_FINISHED
.story_data
'----------
' timedelta action text x y dur(sec)
' Sonny: attempt #1
data 0, ANIM, ANM_PONDER
data 2, TXTGREY, "here's sonny...", 4, 0
data 1.5, TXTGREY, "a struggling artist...", 22, 0
data 1.7, TXTGREY, "searching for inspiration...", 47, 0
data 2, TXTCLEAR
data .5, TXTTALK, "hmm... what to draw today...", 3
data 2, ANIM, ANM_PAINT
data 1.5, TXTTALK, "i know!", 2
data 1, TXTCLEAR
data 3, ANIM, ANM_LIFT
data 4, PAINTING, 1
data 2, REACTION, "blech!", 1, 2
data 2, ANIM, ANM_RIP
data 1.5, CLS
data ., TXTGREY, "try again sonny...", 34, 12
data 2, CLS
' Sonny: attempt #2
data ., ANIM, ANM_PONDER
data 2, ANIM, ANM_PAINT
data 1.5, TXTTALK, "aha!", 2
data 1, TXTCLEAR
data 3, ANIM, ANM_LIFT
data 4, PAINTING, 2
data 2, REACTION, "yuck!", 1, 2
data 2, ANIM, ANM_RIP
data 1.5, CLS
data ., TXTGREY, "don't give up sonny!", 32, 12
data 2, CLS
' Sonny: attempt #3
data ., ANIM, ANM_PONDER
data 2, ANIM, ANM_PAINT
data 1.5, TXTTALK, "i got it!", 2
data 1, TXTCLEAR
data 3, ANIM, ANM_LIFT
data 4, PAINTING, 3
data 2, REACTION, "eww!", 1, 2
data 2, ANIM, ANM_RIP
data 1.5, DRAWFRM, FRM_SAD_FACE
data ., TXTGREY, "aww... poor sonny...", 32, 0
data 2, TXTCLEAR
data .1, TXTTALK, "guys like me shouldn't dream anyway...", 3.5
data 3.5, DRAWFRM, FRM_SAD_FACE
data 1, CLS
data .5, TXTGREY, "...and with that, sonny's dreams blew away with the wind...", 10, 12
data 3.5, CLS
data 1, ENDER
'=====
.ender
'=====
gosub switch_to_80x25_mode
gosub restore_screen_pointer
palette restore
return
'============
.xanadu_title
'============
print chr$(147);
background 0
border 0
' fill screen with black inverted spaces
edma 3,4000,0,$ff80000
edma 3,4000,160,$48000
gosub load_palette
gosub switch_to_80x50_mode
gosub set_screen_pointer
gosub pan_title
return
.switch_to_80x50_mode
'--------------------
bank 128
setbit HOTREG_7, 7
poke $d031, $e8 ' H640, FAST, ATTR, V400
return
.switch_to_80x25_mode
'--------------------
bank 128
poke $d031, $e0 ' H640, FAST, ATTR
return
.restore_screen_pointer
'----------------------
' to bank 0 - $0800
bank 128
wpoke SCRNPTRLSB, $0800
poke SCRNPTRBNK, 0
return
.set_screen_pointer
'------------------
' move to bank4 - $8000
bank 128
setbit HOTREG_7, 7
wpoke SCRNPTRLSB, $8000
poke SCRNPTRBNK, $04
return
.pan_title
'---------
for pan_idx = 0 to 196
if pan_idx > 79 then begin
pan_src_idx = pan_idx - 79
pan_dest_idx = 0
if pan_idx > 117 then begin
pan_len = 80 - (pan_idx - 117)
if pan_len < 1 then pan_len = 0
bend:else begin
pan_len = 80
bend
bend:else begin
pan_src_idx = 0
pan_dest_idx = 79 - pan_idx
pan_len=pan_idx + 1
bend
for pan_y = 0 to 49
edma 0,pan_len,$41000+pan_y*118+pan_src_idx,$ff80000+pan_y*80+pan_dest_idx
next pan_y
sleep .02
gosub poll_play
next pan_idx
return
.load_palette
'------------
#declare loc=$40fa0
for k = 0 to 31
poke $d100+k,peek(loc):loc=loc+1
poke $d200+k,peek(loc):loc=loc+1
poke $d300+k,peek(loc):loc=loc+1
next k
return
'========
.bas_logo
'========
gosub poll_play
gosub fade_to_white
gosub draw_logo
gosub fade_to_defaults
gosub cycle_alt_palette_loop
gosub fade_to_black
return
.cycle_alt_palette_loop
'----------------------
for m = 0 to 32*4
gosub cycle_alt_palette
gosub poll_play
gosub anim_draw_subtext
sleep .04
next m
return
.anim_draw_subtext
'-----------------
if m = 40 then begin
subtext_idx = 1
plen = 0
edma 3,80,32,$800+80*24
bend
if plen < len(subtext$(subtext_idx)) then begin
plen = plen + 1
rainbowstr$=left$(subtext$(subtext_idx),plen)
if subtext_idx = 0 then rainbow_x = 36:else rainbow_x = 21
rainbow_y = 24
gosub print_rainbow_str
bend
return
.print_rainbow_str
#declare rain_idx
cursor rainbow_x, rainbow_y
for rain_idx=1 to len(rainbowstr$)
foreground mod(rain_idx-1,16)+16
print mid$(rainbowstr$,rain_idx,1);
next rain_idx
return
.cycle_alt_palette
'-----------------
#declare tempr, tempg, tempb
tempr = peek($d100+16)
tempg = peek($d200+16)
tempb = peek($d300+16)
for k = 16 to 30
poke $d100+k, peek($d100+k+1)
poke $d200+k, peek($d200+k+1)
poke $d300+k, peek($d300+k+1)
next k
poke $d100+31, tempr
poke $d200+31, tempg
poke $d300+31, tempb
return
.draw_logo
'---------
background 1
border 1
edma 0, 2000, $40000, $800
edma 0, 2000, $407d0, $ff80000
return
.fade_to_white
'-------------
for fadeval=0 to 16
gosub fade_colours_to_white
sleep .05
next fadeval
return
.fade_to_black
'-------------
gosub store_curr_colours
for fadeval=0 to 16
gosub fade_colours_to_black
sleep .05
next fadeval
return
.fade_to_defaults
'----------------
gosub store_curr_colours
for fadeval=0 to 16
gosub fade_colours_to_defaults
sleep .05
next fadeval
return
'====
.init
'====
' switch back to upper-case
poke $d018, peek($d018) and $fd
^^bload "intro.dat",p($40000),r
' $4,0000 +------------------+ INTRO.DAT
' ! BAS logo chars !
' $4,07D0 +..................+
' ! BAS logo colors !
' $4,0FA0 +..................+
' ! 32 x RGB PALETTE !
' $4,1000 +..................+
' ! TITLE colors !
' $4,270C +..................+
' ! PETSCII frames !
' $4,54FC +------------------+
gosub init_music
gosub store_default_colours
return
.store_default_colours
'---------------------
for k = 0 to 31
default_red(k)=peek($d100+k)
default_green(k)=peek($d200+k)
default_blue(k)=peek($d300+k)
next k
return
.store_curr_colours
'------------------
for k = 0 to 31
curr_red(k)=peek($d100+k)
curr_green(k)=peek($d200+k)
curr_blue(k)=peek($d300+k)
next k
return
.fade_colours_to_white
'---------------------
'INPUT: fadeval=0 to 16
tempval = fadeval / 16
for k = 0 to 31
poke $d100+k, default_red(k) + (15 - default_red(k)) * tempval
poke $d200+k, default_green(k) + (15 - default_green(k)) * tempval
poke $d300+k, default_blue(k) + (15 - default_blue(k)) * tempval
next k
return
.fade_colours_to_defaults
'------------------------
'INPUT: fadeval=0 to 16
tempval = fadeval / 16
for k = 0 to 31
poke $d100+k, curr_red(k) + (default_red(k)-curr_red(k)) * tempval
poke $d200+k, curr_green(k) + (default_green(k)-curr_green(k)) * tempval
poke $d300+k, curr_blue(k) + (default_blue(k)-curr_blue(k)) * tempval
next k
return
.fade_colours_to_black
'---------------------
tempval = (16-fadeval) / 16
for k = 0 to 31
poke $d100+k, curr_red(k) * tempval
poke $d200+k, curr_green(k) * tempval
poke $d300+k, curr_blue(k) * tempval
next k
return
'==========
.init_music
'==========
play
bar_index=0
map_bar_to_chunk(0)=0
map_bar_to_chunk(1)=1
map_bar_to_chunk(2)=1
map_bar_to_chunk(3)=2
map_bar_to_chunk(4)=3
filter 1,100,1
filter 2,100,1
envelope 2,3,3,3,10,0
envelope 4,9,4,9,8
envelope 7,0,9,9,0,2,1100
envelope 8,0,12,3,5,2,1100
envelope 9,0,10,3,5,2,1100
' *** voice1 - guitar1 ***
' ------------------------
v1$(0)="t2o6m2 qdir qc.r qdir qc.r qdir qc.r qdir qc.r"
v1$(1)="t2o6m2 qdir qc.r qdir qc.r p9a ir qair p0idp9o5a o5iao6da q.g ido5a ibo6dg q.a igd o5bo6eg q.a ige o5ibo6dg q.a igd o5bo6egqa ig#fe "
v1$(2)="t2o6m2 qdir qc.r qdir qc.r iddfq.difd o5q.#aho6cir o5#aq#ao6hcir iddfhdir ddfq.difd o5q.#aho6cir o5#aq#ao6hcir o5q.a o6he ir
v1$(3)="t2o6m2 igg#ghgir o5q.g o6hd ir aa#aha ir a o6d #f qe i#f qd q.#f.edo6.g.#fe o5g i#a o6 qe o5i#a o6qe qdir qc.r qdir qc.r
v1$(3)=v1$(3)+"o6q.g.#fe o5g i#a o6qe o5i#a o6qe qdir qc.r qdir qc.r qdir qc.r qdir qc.r"
' *** voice2 - guitar2 ***
' ------------------------
v2$(0)="t2o5m4 qair q#g.r qair q#g.r qair q#g.r qair q#g.r"
v2$(1)="t2o5m4 qair q#g.r qair q#g.r o5 q.#c .d o6i#fd o5d#fao6q.d io5a#f egbo6q.e o5ibg eao6#cq.e i#co5a egbo6q.e o5ibg eao6#cqe id#cd"
v2$(2)="t2o5m4 qair q#g.r qair q#g.r iaao6co5q.aiga q.fhg ir ifqf hg ir iaao6co5ha ir aao6co5q.aiga q.fhg irfqf hg ir q.e .a o6e "
v2$(3)="t2o5m4 igg#g hg ir q.d hg ir ddghd ir ddaqgiaqd q.a.g#f .#a .a g o5qeigq#aig#ao6c qair q#g.r qair q#g.r q.#a .a g o5qeigq#aig#ao6c"
v2$(3)=v2$(3)+"qair q#g.r qair q#g.r qair q#g.r qair q#g.r"
' *** voice3 - bass ***
' ---------------------
v3$(0)="x1t7o2m1 id qr p1 icd qr icd sf#f qd ir o1ao2co1a o2id qr p1 icd qr icd sf#f qd ir o1ao2co1a"
v3$(1)="x1t7o2m1 id qr p1 icd qr icd sf#f qd qr ir o1a t8 o2q.#cqd ide#f q.#f o1a ia o2q#c o1q.e e iebg q.a a ia o2qc q.e e ie o1 qb q.a a o2ie qa"
v3$(2)="x1t7o2m1 id qr p1 icd qr icd sf#f qd ir o1ao2co1a"
v3$(2)=v3$(2)+"t9o2idddddddd o1#a#a#a#a#a#a#a#a #a#a#a#a#a#a#a#a o2ddfqdiddddddddddd o1#a#a#a#a#a#a#a#a #a#a#a t8o2qciccc o1q.aaiaaa"
v3$(3)="o2q.ddiddd o1q.ggi#aa#a q.#a#ai#aq#a q.aaiaqa o2q.ddio1go2qd q.eeieqe o1q.aaiaqa t7o2 id qr p1 icd qr icd sf#f qd ir o1ao2co1a"
v3$(3)=v3$(3)+"o2q.eeieqe o1q.aaiaqa t7o2 id qr p1 icd qr icd sf#f qd ir o1ao2co1a t7o2 id qr p1 icd qr icd sf#f qd ir o1ao2co1a"
' *** voice4 - melody ***
' -----------------------
v4$(0)=""
v4$(1)="t4o5p0 qr m2id m4qd p5 m1o4#g h.a iaqa o5q.e h#f ir #f#fa qg ig#f w m5 .g p9m2o4ia o5i.b.a sg#f agabab qg o4iab o5h#f sg#f q.e.d"
v4$(2)="o5t4p7wdhrq.ricp5o5iddfq.gifdq.fsedhciffaqgifdscp2h.dp5i.ricddfq.gifd q.f sed hc iffaqgifd igp1h.a p7ira"
v4$(3)="t4 io6dd#dqdico5#ah.#aq.r iaa#aqaiagp1wap7ir"
v4$(3)=v4$(3)+"hri#fgaq.gi#fg#fherir dhdrr ir#fgaq.gi#fg#fherir dhd"
return
'---------
.poll_play
'---------
if rplay(1) then return
music_chunk_index=map_bar_to_chunk(bar_index)
play v1$(music_chunk_index),v3$(music_chunk_index),v4$(music_chunk_index)
sleep .05
play ,,,v2$(music_chunk_index),v3$(music_chunk_index),v4$(music_chunk_index)
bar_index=bar_index+1
if bar_index=5 then bar_index=1
return
ÿ