-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbehold.asm
1977 lines (1710 loc) · 41 KB
/
behold.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
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
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; ******************************************************
; BEHOLD demo
; Kane / Suspect
; started 26/11/2018 - 27/01/2019 (an hour here and there...)
; Continued in 1/08/2020 - 21/08/2021
; Presented at Silly Venture 2021 - ranked #1
; Copyright (C) 2021 Pawel Matusz. Distributed under the terms of the GNU GPL-3.0.
;
; This should run on a stock 65k Atari XL/XE.
; 2 POKEYs recommended but works on one
; ******************************************************
playsound = 1
;-------------
; between here and start of code some data can be copied after switching off the OS
lowmem = $400
roundlogo1 = lowmem
roundlogo2 = roundlogo1 + [.len roundlogo1Load]
longlogoCpy = roundlogo2 + [.len roundlogo2Load]
lowmemend = longlogo + [.len longlogoLoad]
.print "R1 logo: start: ", roundlogo1, " end: ", roundlogo1 + [.len roundlogo1Load], " (len: ", [.len roundlogo1Load], ")"
.print "R2 logo: start: ", roundlogo2, " end: ", roundlogo2 + [.len roundlogo2Load], " (len: ", [.len roundlogo2Load], ")"
.print "L logo: start: ", longlogoCpy, " end: ", longlogoCpy + [.len longlogoLoad], " (len: ", [.len longlogoLoad], ")"
.print "-------"
stablen = roundlogo_h // 50. This has to be tmax(roundlogo_h, roundlogo_w, longlogo_h), just for the sake of memory allocation
;-------------
; this is the area for dynamic data
data = $5F00
sscaled = data ; scaled sctetcher, max 64
stab = sscaled+[.len stretcher] ; 64
stabrows = stab + (stablen*2) ; 100 (50 addresses)
stabrowsend = stabrows + ((stablen)*(stablen+1)/2) ; (n)(n+1)/2 -> 50*51/2 = 1275
roundlogo1_inv = stabrowsend
roundlogo1_trans = roundlogo1_inv + (.len roundlogo1Load)
dataend1 = roundlogo1_trans + (.len roundlogo2Load)
;----
sinus1 = stabrowsend-$100 ; size: $40. Since the long logo is lower than the round one, there is some space in the stretcher tab here
sinus2 = sinus1+$40 ; size: $80
longlogo = stabrowsend
longlogoClear = longlogo + (.len longlogoLoad)
dataend2 = longlogoclear + (width_n+2)*height
;----
snakeConvTab = data
snakeSinX = data+256
snakeSinY = snakeSinX+256
snakeDataEnd = snakeSinY+256
;----
plasmConvTab = data ; 256
plasmSinMap = plasmConvTab + 256
plasmSin256 = plasmSinMap + 256
plasmSinA = plasmSin256 + 256
plasmSinB = plasmSinA + 256
plasmSinJump = plasmSinB + 256
plasmSinScroll = plasmSinJump + 256
clearLine = plasmSinScroll + 256 ; a(clearline) MUST have LSB set to 0, so don't change anything in front of it
dlCopy = clearLine + 256 ; 4*56*3 = $2a0
dlShow = dlCopy + $300 ; 4*56 addresses = $1c0
dlShowCopy = dlShow + $200 ; 4*56 addresses = $1c0
dataend3 = dlShowCopy + $200
;-------------
dlist = $8000
scr = $8400
scr2 = scr + width_n ; spare screens
scr3 = scr + 2*width_n
fontSet = $bc00 ; $400 out of which the last $200 can be re-used
;-------------
width_s = 32 ; narrow (small) playfield
width_n = 40 ; normal playfield
height = 56
sync = 1 ; vblank line to wait for
;-------------
icl "Includes/zeropage.asm"
icl "Includes/registers.asm"
icl "Includes/macros.asm"
; opt s+
// -----------------------------------------------------------------------------------
start = $2000
org start
// -----------------------------------------------------------------------------------
// main demo flow
jsr init_all
;jmp s
; show intro text
; WaitMsS 60
WaitMsS 50
jsr introtext
; explosion into "snakes"
; WaitMsS 100
WaitMsS 20
jsr snakes.init
jsr snakes.exec
; round logo effects
WaitMsS 10
jsr rotate_roundlogo_vert.init
; fade logo in
LdXY cols.collogoround1
jsr cols.fadein
; turn round logo up-down
WaitMsS 160
jsr rotate_roundlogo_vert.exec
; turn round logo left-right
WaitMsS 70
jsr rotate_roundlogo_horiz.init
jsr rotate_roundlogo_horiz.exec
; burn round logo
WaitMsS 180
jsr burn_round_logo
; suspect "kaboom" zoomer
WaitMsS 70
jsr kaboom
; scroll logo in and out
WaitMsS 125
jsr scroll_logo
; sine logo
WaitMsS 90
jsr sine_longlogo_vert.init
jsr sine_longlogo_vert.exec
; plasm credits
WaitMsS 50
jsr plasm.init_9cols
mwa #plasm.settings1 t1
jsr plasm.config_9cols
jsr plasm.exec_9cols
WaitMsS 35
mwa #plasm.settings2 t1
jsr plasm.config_9cols
jsr plasm.exec_9cols
WaitMsS 35
mwa #plasm.settings3 t1
jsr plasm.config_9cols
jsr plasm.exec_9cols
; advanced plasm
WaitMsS 50
jsr plasm.init_16cols
mwa #plasm.settings16_1 t1
jsr plasm.config_16cols
jsr plasm.exec_16cols
WaitMsS 20
jsr plasm.init_16cols
mwa #plasm.settings16_2 t1
jsr plasm.config_16cols
jsr plasm.exec_16cols
s
jsr plasm.init_16cols
mwa #plasm.settings16_3 t1
jsr plasm.config_16cols
jsr plasm.exec_16cols
WaitMsS 50
jmp theend
// -----------------------------------------------------------------------------------
init_all
// initialise (sound, interrupts, ...)
jsr disableScreen
mwa #dlblank SDLSTL ; blank DL to shadow
mwa #0 timerL ; initialise internal master timer
mva #255 COLDST
.ifdef playsound
jsr sound.initmod
.endif
jsr nmi.init
SetColors cols.colblack
mwa #dlblank DLISTL ; blank DL
mva #0 COLBK
; move some data to lower mem now that OS is off
MemCpy roundlogo1Load roundlogo1 [.len roundlogo1Load -1]
MemCpy roundlogo2Load roundlogo2 [.len roundlogo2Load -1]
MemCpy longlogoLoad longlogoCpy [.len longlogoLoad -1]
; move fonts to upper mem
MemCpy fontsLoaded fontSet [.len fontsLoaded -1]
; MemClr data [stabrowsend-data]
rts
// -----------------------------------------------------------------------------------
// Effects
// -----------------------------------------------------------------------------------
icl "introtext.asm"
icl "snakes.asm"
icl "fire.asm"
icl "kaboom.asm"
icl "theend.asm"
icl "misc.asm"
// ---------------------------------------------------------------------
.proc plasm
.proc init_16cols
mwa #dlblank DLISTL ; blank DL
mva #0 COLBK
jsr clear_screen
jsr create_dl_lower.no_scroll
jsr hscroll_shift_dl_fixed
;convtab sintab centre amp size
MakeSin plasmConvTab plasmSinMap 7 7 1
jsr double_col
InFill plasmSinMap $38 16 $ee ; small manual "fixes" in the colour mapping sine...
MakeSin plasmConvTab plasmSin256 127 127 1
MakeSin plasmConvTab plasmSinA 100 100 1
MakeSin plasmConvTab plasmSinB 40 40 1
MakeSin plasmConvTab plasmSinJump [>scr+17] 4 1
MakeSin plasmConvTab plasmSinScroll 5 5 1
MemClr clearLine 255
MemCpy dlist dlCopy [4*height*3]
// change dl addresses to point to an empty line, and also build showTab
ldx #4*height
mwa #dlShow t1
mwa #dlist+3 st2+1
st1 lda #>clearLine ; clearline MUST have LSB set to 0
st2 sta dlist+3 ; +1 empty line, +1 addr load, +1 LSB (always 0)
lda st2+1
ldy #0
sta (t1),y ; dl show is a list of offsets into the DLlist
lda st2+2
sec
sbc #>dlist
iny
sta (t1),y
adw t1 #2
adw st2+1 #3
dex
bne st1
MemCpy dlShow dlShowCopy [2*4*height]
vblank
mva #$22 DMACTL ; $21 = narrow playfield, $22 = normal
mva #$40 PRIOR ; 80: 9 cols (GTIA graphics 10) - 9 arbitrary colours | 40: 16 shades (GTIA graphics 9) - all shades of one background colour | C0: 16 cols (GTIA graphics 11 - all colours of the same luminance)
mva #$00 COLBK
mwa #dlist DLISTL
rts
.endp
; no direct input - init should have been called beforehand
.proc exec_16cols
mva #width_n t29 ; t29 scroller offset for proc3
mva #0 t30 ; jump sin
mva #0 t31 ; scroll sin
lda t7 ; t7 - proc #
bne sp2 ; scroll
jsr create_showtab_middle
mva #$20 t32
jsr col_anim.openhalf
mva #0 t18 ; 0 - first DLI, 1 - second
mwa #flagDli nmi.nmi.dliv ; DL interrupt to change screen palette
mva #$cf dlist+1+height/2*3*4
mva #$cf dlist+1+height*3*4-3
jmp spc
sp2 cmp #1
bne sp3 ; "silly venture"
MemCpy dlShowCopy dlShow [2*4*height]
jsr col_anim.open
jmp spc
sp3 ; no text
jsr create_showtab_random
jsr col_anim.open
spc
mwa #dlShow t33
mwa #0 t8 ; t8, t9 - time counter for this proc
draw
lda #90
jsr vblank.line
; vblank
ldx t28 ; set length of effect
stx nf1+1
inx
stx nf2+1
inc t8
lda t8
cmp #20 ; each H frame is 20 L frames
bne noh
lda #0
sta t8
inc t9
noh
lda t9
bne nofadein ; fade in in the first H frame
; jsr cols.fade_stepped.in
ldx #12
il1
cpw t33 #dlShow+2*4*height
beq iq1
ldy #0
lda (t33),y
sta is1+1
sta id1+1
ldy #1
lda #>dlCopy
clc
adc (t33),y
sta is1+2
lda #>dlist
clc
adc (t33),y
sta id1+2
is1 lda dlCopy
id1 sta dlist
adw t33 #2
ii1
dex
bne il1
iq1
jmp tcont
nofadein
nf1 cmp #11 ; fade out
; cmp #2
bne nofadeout
; jsr cols.fade_stepped.out
ldx #12
ol1
cpw t33 #dlShow
beq oq1
sbw t33 #2
ldy #0
lda (t33),y
sta od1+1
ldy #1
lda #>dlist
clc
adc (t33),y
sta od1+2
lda #>clearLine
od1 sta dlist
oi1
dex
bne ol1
oq1
jmp tcont
nofadeout
nf2 cmp #12 ; quit
bne tcont
lda t7 ; t7 - proc #
bne qp2 ; scroll
jsr nmi.remove_dli
jsr col_anim.closehalf
jmp qpc
qp2 cmp #1
bne qp3 ; "silly venture"
jsr col_anim.close
jmp qpc
qp3 ; no text
jsr col_anim.close
qpc
mwa #dlblank DLISTL ; blank DL
rts
;------------
tcont
adb t10 t11 ; Increase sin counters (src, add_val)
adb t12 t13
adb t14 t15
adb t16 t17
adb t20 t21 ; Increase 2nd sin counters (src, add_val)
adb t22 t23
adb t24 t25
adb t26 t27
ldx t10
mva plasmSin256,x t2
ldx t12
adb t2 plasmSinA,x ; t2 = starting point 1
ldx t20
mva plasmSin256,x t3
ldx t22
adb t3 plasmSinA,x ; t3 = starting point 2
// proc specific actions
lda t7 ; t7 - proc #
bne xp2 ;set jump address for the right X procedure
mwa #xproc3 xproc+1
// proc 3 requires scrolling
lda t9 ; local timer H
cmp #4
bmi xpc ; delayed scrolling start
lda t29
cmp #255-width_n ; stop before screen loops over
beq xpc
lda t30 ; jump
clc
adc #10
sta t30
tax
lda plasmSinJump,x
sta xproc3.y1+1 ; scroll y start
clc
adc #21
sta xproc3.y2+1 ; scroll y stop
inc t29 ; scroll
lda t31
clc
adc #13
sta t31
tax
lda plasmSinScroll,x
clc
adc t29
sta xproc3.xp3_1.sc0+1
jmp xpc
xp2 cmp #1
bne xp3
mwa #xproc2 xproc+1
jmp xpc
xp3
mwa #xproc1 xproc+1
xpc
lda #>scr2
sta xproc2.sc0+2 ; second start screen address
sta xproc3.xp3_1.sc0+2 ; second start screen address
lda #>scr
sta t1 ; Y counter
sta xproc1.sc1+2 ; start screen address
sta xproc2.sc1+2 ; start screen address
sta xproc3.xp3_1.sc1+2 ; start screen address
sta xproc3.xp3_2.sc1+2 ; start screen address
lpy
lda t1
clc
adc t14
tax
lda t2 ; Y start sin value
clc
adc plasmSinA,x
tay
lda t1
clc
adc t16
tax
tya
clc
adc plasmSinB,x ; X sin start
sta t4
ldy t7 ; omit for proc 0
beq xproc
lda t1
clc
adc t24
tax
lda t3 ; Y start sin value
clc
adc plasmSinA,x
tay
lda t1
clc
adc t26
tax
tya
clc
adc plasmSinB,x ; X sin start
sta t6
xproc
jmp xproc2
;-------------
.proc xproc1
ldx #width_n-1
lpx
ldy t4
iny
iny
iny
sty t4
lda plasmSinMap,y
ldy t6
iny
iny
sty t6
clc
adc plasmSinMap,y
sc1 sta scr,x
dex
bpl lpx
inc t1 ; move to next row
inc sc1+2 ; update row address
lda t1
cmp #>scr+height
bne lpy
jmp draw
.endp
;-------------
.proc xproc2
; tay
ldx #width_n-1
lpx
ldy t4
s1 iny
iny
iny
iny
sty t4
lda plasmSinMap,y
dec t6
ldy t6
; clc
adc plasmSinMap,y
clc
sc0 adc scr2,x
sc1 sta scr,x
dex
bpl lpx
inc t1 ; move to next row
inc sc1+2 ; update row address
inc sc0+2 ; update row address
lda t1
cmp #>scr+height
jne lpy
jmp draw
.endp
;-------------
.proc xproc3
tay
ldx #width_n-1
lda t1
y1 cmp #>scr+17
bmi xp3_2
y2 cmp #>scr+38
bpl xp3_2
.proc xp3_1 // part with scroll
lpx
iny
iny
iny
lda plasmSinMap,y
clc
sc0 adc scr2,x
sc1 sta scr,x
dex
bpl lpx
inc t1 ; move to next row
inc sc1+2 ; update row address
inc xp3_2.sc1+2 ; update row address
inc sc0+2 ; update row address
lda t1
cmp #>scr+height
jne lpy
jmp draw
.endp
.proc xp3_2 // part without scroll
lpx
iny
iny
iny
lda plasmSinMap,y
sc1 sta scr,x
dex
bpl lpx
inc t1 ; move to next row
inc sc1+2 ; update row address
inc xp3_1.sc1+2 ; update row address
lda t1
cmp #>scr+height
jne lpy
jmp draw
.endp
.endp // xproc3
.endp // exec
// configure the draw routine
; t1, t2 - settings addr
.proc config_16cols
mwa t1 t10
jsr clear_entire_screen
ldy #20
lda (t1),y ; font color shift
sta t20
ldy #1
lda (t1),y ; text nr
tax
ldy #2
lda (t1),y ; font multiplier
tay
jsr printer
mwa t10 t1
ldy #0
lda (t1),y ; palette addr
; sta COLBK ; this is gr16 so select palette by setting only the primary colour
sta t32
ldy #3
lda (t1),y
sta t7 // t7 - internal version of the X procedure
ldy #4
ldx #0
lp mva (t1),y t10,x // copy settings to t10-t17 an t20-t27
iny
inx
cpx #8
bne lp
ldx #0
lp2 mva (t1),y t20,x // copy settings to t10-t17 an t20-t27
iny
inx
cpx #8
bne lp2
ldy #21
lda (t1),y ; t28 - length
sta t28
rts
.endp // exec.init
// create a version of the showtab which starts from the middle
.proc create_showtab_middle
mwa #dlShow ea1+1
mwa #dlShowCopy+[4*height-2] a1+1
mwa #dlShowCopy+[4*height-1] a2+1
mwa #dlShowCopy+[4*height] a3+1
mwa #dlShowCopy+[4*height+1] a4+1
ldx #2*height
a1 lda dlShowCopy+[4*height-2]
jsr st_add_elem
sbw a1+1 #2
a2 lda dlShowCopy+[4*height-1]
jsr st_add_elem
sbw a2+1 #2
a3 lda dlShowCopy+[4*height]
jsr st_add_elem
adw a3+1 #2
a4 lda dlShowCopy+[4*height+1]
jsr st_add_elem
adw a4+1 #2
dex
bne a1
rts
st_add_elem
ea1 sta dlShow
inw ea1+1
rts
.endp
// create a radomised version of the showtab
.proc create_showtab_random
jsr create_showtab_middle
mwa #dlShow ea1+1
mwa #dlShow ea2+1
jsr st_randomise
jsr st_randomise
rts
st_randomise
ldy #2*height
a1 lda RANDOM
cmp #4*height
bmi a2
sec
sbc #4*height
a2 and #$fe
tax
jsr st_get_elem ; swap pair of 16-bit pointers
sta t8
lda dlShow,x
jsr st_add_elem
lda t8
sta dlShow,x
inx
jsr st_get_elem
sta t8
lda dlShow,x
jsr st_add_elem
lda t8
sta dlShow,x
dey
bne a1
rts
st_add_elem
ea1 sta dlShow
inw ea1+1
rts
st_get_elem
ea2 lda dlShow
inw ea2+1
rts
.endp
.proc flagDli
lda t18
bne k1
inc t18
lda #$20
jmp k2
k1: dec t18
lda #0
k2: sta COLBK
rts
.endp
; palette, text#, fontmulti#, inner proc version, params, font colur multiplier, length
; 0 1 2 3 4... 20 21
settings16_1 .byte $50, 6, 2, 2, 0,1, 40,3, 170,2, 20,1, 80,-3, 70,-1, 10,4, 23,3, 2, 4
settings16_2 .byte $40, 8, 2, 1, 130,-1, 0,-2, 170,2, 20,1, 80,-2, 70,-1, 0,1, 23,3, 2, 9
settings16_3 .byte $00, 10, 3, 0, 140,-2, 89,-1, 170,1, 23,4, 80,-2, 70,-1, 0,1, 23,3, 3, 17
// -----------------------------------------------
.proc init_9cols
vblank
mwa #dlblank DLISTL ; blank DL
jsr clear_screen
jsr create_dl_lower.no_scroll
;jsr hscroll_shift_dl_fixed
mva #$22 DMACTL ; $21 = narrow playfield, $22 = normal
mva #$80 PRIOR ; 80: 9 cols (GTIA graphics 10) - 9 arbitrary colours | 40: 16 shades (GTIA graphics 9) - all shades of one background colour | C0: 16 cols (GTIA graphics 11 - all colours of the same luminance)
mwa #dlist DLISTL
;convtab sintab centre amp size
MakeSin plasmConvTab plasmSinMap 4 3 1
InFill plasmSinMap $36 20 $77 ; small manual "fixes" in the colour mapping sine...
InFill plasmSinMap $b6 20 $00
MakeSin plasmConvTab plasmSin256 127 127 1
MakeSin plasmConvTab plasmSinA 90 90 1
MakeSin plasmConvTab plasmSinB 40 40 1
jsr double_col
rts
.endp
; no direct input - init should have been called beforehand
.proc exec_9cols
InFill lpx 0 4 $EA ; prefill inner X loop with NOPs
ldx t9 ; nr of "iny"
lda #$C8
fx1 sta lpx,x
dex
bpl fx1
mwa #0 t8 ; t8, t9 - time counter for this proc
draw
; lda #10
; jsr vblank.line
vblank
inc t8
lda t8
cmp #20 ; each H frame is 20 L frames
bne noh
lda #0
sta t8
inc t9
noh
lda t9
bne nofadein ; fade in in the first H frame
jsr cols.fade_stepped.in
tya
bne tcont
mva #$0f COLBK ; after the rest of the palette has been set, fix highest col to white (to avoid fade in artefacts)
jmp tcont
nofadein
cmp #7 ; fade out
bne nofadeout
jsr cols.fade_stepped.out
jmp tcont
nofadeout
cmp #8 ; quit
bne tcont
jmp fin
tcont
adb t10 t11 ; Increase sin counters (src, add_val)
adb t12 t13
adb t14 t15
adb t16 t17
ldx t10
mva plasmSin256,x t2
ldx t12
adb t2 plasmSinA,x ; t3 = starting point, combination of 2 sins
lda #>scr2
sta sc0+2 ; second start screen address
lda #>scr
sta t1 ; Y counter
sta sc1+2 ; start screen address
lpy
lda t1
clc
adc t14
tax
lda t2 ; Y start sin value
clc
adc plasmSinA,x
tay
lda t1
clc
adc t16
tax
tya
clc
adc plasmSinB,x ; X sin start
tay
ldx #width_n-1
lpx
iny
iny
iny
iny
lda plasmSinMap,y
clc
sc0 adc scr2,x
sc1 sta scr,x
dex
bpl lpx
inc t1 ; move to next row
inc sc1+2 ; update row address
inc sc0+2 ; update row address
lda t1
cmp #>scr+height
bne lpy
jmp draw
fin
rts
.endp // exec
// configure the draw routine
; t1, t2 - settings addr
.proc config_9cols
mwa t1 t10
jsr clear_entire_screen
ldy #13
lda (t1),y ; font color shift
sta t20
ldy #2
lda (t1),y ; text nr
tax
ldy #3
lda (t1),y ; font multiplier
tay
jsr printer
mwa t10 t1
ldy #1
lda (t1),y ; palette addr
tax
ldy #0
lda (t1),y
tay
;jsr cols.setcols
jsr cols.fade_stepped.init
ldy #4
lda (t1),y
sta t9 // t9 - nr to add in inner X loop
dec t9
ldy #5
ldx #0
lp mva (t1),y t10,x // copy settings to t10-t17
iny
inx
cpx #8
bne lp
rts
.endp // exec.init
palette1 .byte 0,$e0,$e2,$e4,$e6,$e8,$ea,$ec,$ef
;palette2 .byte 0,$10,$12,$14,$16,$18,$1a,$1c,$0f
palette2 .byte 0,$d0,$d2,$d4,$d6,$d8,$da,$dc,$df
palette3 .byte 0,$90,$92,$94,$96,$98,$9a,$9c,$9f
; palette, text#, fontmulti#, inner X iny#, params, font color bit shift
; 0 2 3 4 5... 13
settings1 .byte a(palette1), 0, 2, 4, 30,-1, 35,-3, 170,2, 20,1, 0
settings2 .byte a(palette2), 2, 2, 1, 10,2, 25,1, 0,4, 0,-1, 0
settings3 .byte a(palette3), 4, 2, 2, 0,-2, 135,-1, 10,-2, 23,-5, 0
.endp //plasm
// for every col in the tab, copy it also to the 4 upper bits
.proc double_col
ldx #0
lp lda plasmSinMap,x
sta t1
asl
asl
asl
asl
ora t1
sta plasmSinMap,x
inx
bne lp
rts
.endp
// ---------------------------------------------------------------------
// printer
; X - text index
; Y - font heigth multiplier (1, 2, 3...)
; t20 - font shift multiplier
.proc printer
mwa texts,x t1
sty t9
ldy #0
sty t8 ; text counter
loop
ldy t8
lda (t1),y
bpl l2
iny
lda (t1),y ; text X
jmi fin
clc
adc #<scr2 ; add offset of scr2
sta t3 ; text X
iny
lda (t1),y
clc
adc #>scr2
sta t4 ; text Y
iny
sty t8
bne loop
l2
iny
sty t8
tay ; just to set the N flag
jeq nextchar ; skip if 0 (space)
cmp #$20