-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWave_PatternEditor.s
More file actions
1600 lines (1490 loc) · 26.2 KB
/
Wave_PatternEditor.s
File metadata and controls
1600 lines (1490 loc) · 26.2 KB
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
;Wave_PatternEditor.s
peTemp01
.byt 0
fpfTempX
.byt 0
fpfTempY
.byt 0
OldEditorID
.byt 0
PatternKeyDescriptionIDList
.byt 6,7,9,8,77,10,11,12,13,88,89,18,20,21,22,23
.byt 25,26,28,27,29,30,31,32,33,34,35,36,37
.byt 38,39,63,64,62
.byt 46,46,46,46,46,46,46,53,53,53,53,53,53,53,54
.byt 71,69,70,76,75,101
PatternKeyAreaIDList
.dsb 16,78
.dsb 13,80
.dsb 5,79
.dsb 15,81
.dsb 82,82,82,79,82
.byt 79
PatternKeyVectorLo
.byt <pe_Left
.byt <pe_Right
.byt <pe_Down
.byt <pe_Up
.byt <GenericHelp
.byt <pe_TrackLeft
.byt <pe_TrackRight
.byt <pe_PageUp
.byt <pe_PageDown
.byt <pe_PreviousPattern
.byt <pe_NextPattern
.byt <pe_SwitchList
.byt <pe_SwitchSample
.byt <pe_SwitchEffect
.byt <pe_SwitchOrnament
.byt <pe_SwitchMenu
.byt <pe_HighlightLeft
.byt <pe_HighlightRight
.byt <pe_HighlightDown
.byt <pe_HighlightUp
.byt <pe_HighlightAll
.byt <pe_Copy
.byt <pe_Cut
.byt <pe_Paste
.byt <pe_Merge
.byt <pe_Grab
.byt <pe_Drop
.byt <pe_CopyLast
.byt <pe_CopyNext
.byt <pe_Increment
.byt <pe_Decrement
.byt <pe_InsertGap
.byt <pe_DeleteGap
.byt <pe_Delete
.byt <pe_Octave
.byt <pe_Octave
.byt <pe_Octave
.byt <pe_Octave
.byt <pe_Octave
.byt <pe_Octave
.byt <pe_Octave
.byt <pe_Note
.byt <pe_Note
.byt <pe_Note
.byt <pe_Note
.byt <pe_Note
.byt <pe_Note
.byt <pe_Note
.byt <pe_Bar
.byt <pe_PlayRow
.byt <pe_PlayPattern
.byt <pe_PlayMusic
.byt <pe_DuplicatePattern
.byt <TurnOffMusic
.byt <pe_WipePattern
PatternKeyVectorHi
.byt >pe_Left
.byt >pe_Right
.byt >pe_Down
.byt >pe_Up
.byt >GenericHelp
.byt >pe_TrackLeft
.byt >pe_TrackRight
.byt >pe_PageUp
.byt >pe_PageDown
.byt >pe_PreviousPattern
.byt >pe_NextPattern
.byt >pe_SwitchList
.byt >pe_SwitchSample
.byt >pe_SwitchEffect
.byt >pe_SwitchOrnament
.byt >pe_SwitchMenu
.byt >pe_HighlightLeft
.byt >pe_HighlightRight
.byt >pe_HighlightDown
.byt >pe_HighlightUp
.byt >pe_HighlightAll
.byt >pe_Copy
.byt >pe_Cut
.byt >pe_Paste
.byt >pe_Merge
.byt >pe_Grab
.byt >pe_Drop
.byt >pe_CopyLast
.byt >pe_CopyNext
.byt >pe_Increment
.byt >pe_Decrement
.byt >pe_InsertGap
.byt >pe_DeleteGap
.byt >pe_Delete
.byt >pe_Octave
.byt >pe_Octave
.byt >pe_Octave
.byt >pe_Octave
.byt >pe_Octave
.byt >pe_Octave
.byt >pe_Octave
.byt >pe_Note
.byt >pe_Note
.byt >pe_Note
.byt >pe_Note
.byt >pe_Note
.byt >pe_Note
.byt >pe_Note
.byt >pe_Bar
.byt >pe_PlayRow
.byt >pe_PlayPattern
.byt >pe_PlayMusic
.byt >pe_DuplicatePattern
.byt >TurnOffMusic
.byt >pe_WipePattern
pe_WipePattern
ldx PatternID
jsr ErasePattern
jmp PatternPlot
pe_Left
lda PatternCursorX
.(
beq skip1
dec PatternCursorX
skip1 rts
.)
pe_Right
lda PatternCursorX
cmp #21
.(
bcs skip1
inc PatternCursorX
skip1 rts
.)
pe_Down ;Don't allow Cursor Below BAR?
lda PatternCursorY
cmp #63
.(
bcs skip1
inc PatternCursorY
skip1 rts
.)
pe_Up
lda PatternCursorY
.(
beq skip1
dec PatternCursorY
skip1 rts
.)
pe_TrackLeft
ldx PatternCursorX
lda NextLogicalChannelXLeft,x
sta PatternCursorX
rts
;04 Nm S Eg8 N N#O VOSCP N#O VOSCP N#O VOSCP
; 0 1 2 3 4 56789 1 11111 1 11122
; 0 12345 6 78901
;05 00 - --- - RST ----- RST ----- RST -----
NextLogicalChannelXLeft
.byt 16,0,0,1
.byt 3,4,4,4,4,4
.byt 4,10,10,10,10,10
.byt 10,16,16,16,16,16
pe_TrackRight
ldx PatternCursorX
lda NextLogicalChannelXRight,x
sta PatternCursorX
rts
;04 Nm S Eg8 N N#O VOSCP N#O VOSCP N#O VOSCP
; 0 1 2 3 4 56789 1 11111 1 11122
; 0 12345 6 78901
;05 00 - --- - RST ----- RST ----- RST -----
NextLogicalChannelXRight
.byt 1,3,3,4,10,10,10,10,10,10,16,16,16,16,16,16,0,0,0,0,0,0
pe_PageUp
lda PatternCursorY
sec
sbc #12
.(
bcs skip1
lda #00
skip1 sta PatternCursorY
.)
rts
pe_PageDown
lda PatternCursorY
clc
adc #12
cmp #64
.(
bcc skip1
lda #63
skip1 sta PatternCursorY
.)
rts
pe_PreviousPattern
lda PatternID
.(
beq skip1
dec PatternID
jsr DisplayPatternID
skip1 rts
.)
pe_NextPattern
ldx PatternID
;Cannot have more than 35 patterns
cpx #34
.(
bcs skip1
;If moving into extended patternS then ensure it is known and erase new pattern
inx
stx PatternID ;0-34
cpx mmUltimatePattern
bcc skip2
stx mmUltimatePattern
skip2 jsr DisplayPatternID
skip1 rts
.)
pe_SwitchList
lda #LISTEDITOR
sta EditorID
rts
pe_SwitchSample
;Select current Row sample as index in Sample
;if none present then leave alone
ldy PatternCursorY
jsr FetchPatternRowAddress
ldy #01
lda (source),y
and #7
.(
beq skip1
sta SampleCursorY
dec SampleCursorY
skip1 lda #SAMPLEVIEWER
.)
sta EditorID
rts
pe_SwitchOrnament
;Select current channels Ornament and set ornament to it
;if none selected then leave alone
ldy PatternCursorY
jsr FetchPatternRowAddress
ldx PatternCursorX
ldy PatternX2ChannelsNoteOffset,x
iny
lda (source),y
lsr
lsr
lsr
lsr
.(
beq skip1
sta OrnamentID
dec OrnamentID
;Display Ornament ID
jsr DisplayOrnamentID
jsr OrnamentPlot
skip1 lda #ORNAMENTEDITOR
.)
sta EditorID
rts
pe_SwitchEffect
;Select current channels Effect and set Effect to it
;if none selected then leave alone
ldy PatternCursorY
jsr FetchPatternRowAddress
ldx PatternCursorX
ldy PatternX2ChannelsNoteOffset,x
iny
lda (source),y
and #15
.(
beq skip1
sta EffectID
dec EffectID
;Display Ornament ID
jsr DisplayEffectID
jsr EffectPlot
skip1 lda #EFFECTEDITOR
.)
sta EditorID
rts
pe_SwitchMenu
lda #TOPMENU
sta EditorID
rts
;Highlighting
;One may highlight S,EGC,N or any of the three Chip channels.
;These are in groups so highlighting columns of chip parameters or just eg period is not possible.
;Copying or Cutting to the Copy buffer (704 Bytes) then pasting.
;Pasting protects against pasting to a destination that does not follow the same format. For example
;copying from S,EGC,N and pasting to Chip A will not happen.
pe_HighlightLeft
;Cannot begin to highlight by highlighting left
lda peHighlightingFlag
.(
beq skip1
;Recede highlight end to next logical track left
ldx PatternCursorX
cpx peHighlightStartX
beq skip1
lda NextLogicalChannelXLeft,x
sta PatternCursorX
tax
lda PatternCursorX2PatternFieldGroupEnd,x
sta peHighlightEndX
skip1 rts
.)
peHighlightingFlag .byt 0
peHighlightStartX .byt 0
peHighlightStartY .byt 0
peHighlightEndX .byt 0
peHighlightEndY .byt 0
CopyBufferContents .byt 128
PatternCursorX2PatternFieldGroupStart
.byt 0,1,1,3
.byt 4,4,4,4,4,4
.byt 10,10,10,10,10,10
.byt 16,16,16,16,16,16
PatternCursorX2PatternFieldGroupEnd
.byt 0,2,2,3
.byt 9,9,9,9,9,9
.byt 15,15,15,15,15,15
.byt 21,21,21,21,21,21
pe_HighlightRight
lda peHighlightingFlag
bne peContinueHighlightingRight
peInitialiseHighlighting
;Allign Highlight to Channel group start
ldx PatternCursorX
lda PatternCursorX2PatternFieldGroupStart,x
sta peHighlightStartX
lda PatternCursorX2PatternFieldGroupEnd,x
sta peHighlightEndX
lda PatternCursorY
sta peHighlightStartY
sta peHighlightEndY
lda #128
sta CopyBufferContents
lda #1
sta peHighlightingFlag
rts
peContinueHighlightingRight
;Track Right Pattern Cursor
ldx PatternCursorX
cpx #16
.(
bcs skip1
lda NextLogicalChannelXRight,x
sta PatternCursorX
tax
lda PatternCursorX2PatternFieldGroupEnd,x
sta peHighlightEndX
skip1 rts
.)
pe_HighlightDown
lda peHighlightingFlag
beq peInitialiseHighlighting
ldy PatternCursorY
cpy #63
.(
bcs skip1
iny
sty PatternCursorY
sty peHighlightEndY
skip1 rts
.)
pe_HighlightUp
lda peHighlightingFlag
.(
beq skip1
;Recede highlight end back up
ldy PatternCursorY
cpy peHighlightStartY
beq skip1
dec PatternCursorY
dec peHighlightEndY
skip1 rts
.)
pe_HighlightAll
lda #0
sta peHighlightStartX
sta peHighlightStartY
lda #20
sta peHighlightEndX
lda #63
sta peHighlightEndY
lda #1
sta peHighlightingFlag
rts
pe_Copy
lda peHighlightingFlag
.(
beq skip1
lda #0
jsr CopyHighlightedArea2CopyBuffer
lda #00
sta peHighlightingFlag
lda #1
sta CopyBufferContents
skip1 rts
.)
pe_Cut
lda peHighlightingFlag
.(
beq skip1
lda #1
jsr CopyHighlightedArea2CopyBuffer
lda #00
sta peHighlightingFlag
lda #1
sta CopyBufferContents
skip1 rts
.)
CopyHighlightedArea2CopyBuffer
sta CopyTypeFlag
ldy peHighlightStartY
.(
loop2 ldx peHighlightStartX
loop1 jsr peFetchPatternField
jsr peStoreField2Buffer
lda CopyTypeFlag
beq skip1
jsr peVoidPatternField
skip1 inx
cpx peHighlightEndX
beq loop1
bcc loop1
iny
cpy peHighlightEndY
beq loop2
bcc loop2
.)
rts
peFetchPatternField
stx fpfTempX
sty fpfTempY
jsr FetchPatternRowAddress
ldx fpfTempX
jsr FetchPatternFieldRange2
ldx fpfTempX
ldy fpfTempY
rts
peVoidPatternField
stx fpfTempX
sty fpfTempY
jsr FetchPatternRowAddress
;Fetch byte part
ldx fpfTempX
ldy CursorX2RowOffsetByte,x
;Byte written depends on X
lda #3+62*4
cpx #4
.(
beq skip1
cpx #5 ;This avoids setting note at same time as volume
beq skip2
cpx #10
beq skip1
cpx #11 ;This avoids setting note at same time as volume
beq skip2
cpx #16
beq skip1
cpx #17 ;This avoids setting note at same time as volume
beq skip2
lda #00
skip1 sta (source),y
skip2 ldx fpfTempX
.)
ldy fpfTempY
rts
peStoreField2Buffer
;If we treat buffer as pattern will we have problems pasting to another channel?
stx fpfTempX
sty fpfTempY
pha
;Fetch Buffer Row address
lda BufferRowAddressLo,y
sta source
lda BufferRowAddressHi,y
sta source+1
ldx fpfTempX
pla
jsr StorePatternFieldRange2
ldx fpfTempX
ldy fpfTempY
rts
pe_Paste
lda #0
jmp pe_Paste2
pe_Merge
lda #1
pe_Paste2 sta CopyTypeFlag
;Perform common checks
jsr peIsPasteValid
.(
bcc skip1
lda PatternCursorY
sta PasteY
lda peHighlightStartY
sta SourceY
loop2 lda PatternCursorX
sta PasteX
lda peHighlightStartX
sta SourceX
loop1 jsr peFetchBufferField
ldy CopyTypeFlag
beq skip3
jsr CheckPatternField
skip3 jsr peStoreBufferField
inc PasteX
;Check Destination X bounds
lda PasteX
cmp #22
bcs skip2
inc SourceX
;Check Source X bounds
lda SourceX
cmp peHighlightEndX
beq loop1
bcc loop1
skip2 inc PasteY
;Check Destination Y bounds
lda PasteY
cmp #64
bcs skip1
inc SourceY
;Check Source X bounds
lda SourceY
cmp peHighlightEndY
beq loop2
bcc loop2
skip1 rts
.)
peFetchBufferField
ldy SourceY
lda BufferRowAddressLo,y
sta source
lda BufferRowAddressHi,y
sta source+1
ldx SourceX
jmp FetchPatternFieldRange2
peStoreBufferField
ldy PasteY
pha
jsr FetchPatternRowAddress
ldx PasteX
pla
jmp StorePatternFieldRange2
CheckPatternField
sta cpfField1
ldy PasteY
jsr FetchPatternRowAddress
ldx PasteX
jsr FetchPatternFieldRange2
cpx #4
.(
beq skip1
cpx #10
beq skip1
cpx #16
beq skip1
cmp #0
bne skip2 ;Exit returning current field
;Exit returning new field
skip3 lda cpfField1
rts
skip1 sta cpfField2
lsr
lsr
cmp #62
beq skip3
lda cpfField2
skip2 rts
.)
peIsPasteValid
;Does buffer contain pattern data?
lda CopyBufferContents
cmp #PATTERNEDITOR
.(
bne skip1
;Is CursorX on Field group start?
ldx PatternCursorX
lda FieldGroupStartFlag,x
beq skip1
;Does highlight Start X point to the same type for Cursor X
ldx PatternCursorX
lda PatternCursorX2CommonType,x
ldx peHighlightStartX
cmp PatternCursorX2CommonType,x
bne skip1
sec
rts
skip1 clc
.)
rts
FieldGroupStartFlag
.byt 1,1,0,1
.byt 1,0,0,0,0,0
.byt 1,0,0,0,0,0
.byt 1,0,0,0,0,0
PatternCursorX2CommonType
.byt 0,1,1,2
.byt 3,3,3,3,3,3
.byt 3,3,3,3,3,3
.byt 3,3,3,3,3,3
BufferRowAddressLo
.byt <CopyBuffer
.byt <CopyBuffer+11*1
.byt <CopyBuffer+11*2
.byt <CopyBuffer+11*3
.byt <CopyBuffer+11*4
.byt <CopyBuffer+11*5
.byt <CopyBuffer+11*6
.byt <CopyBuffer+11*7
.byt <CopyBuffer+11*8
.byt <CopyBuffer+11*9
.byt <CopyBuffer+11*10
.byt <CopyBuffer+11*11
.byt <CopyBuffer+11*12
.byt <CopyBuffer+11*13
.byt <CopyBuffer+11*14
.byt <CopyBuffer+11*15
.byt <CopyBuffer+11*16
.byt <CopyBuffer+11*17
.byt <CopyBuffer+11*18
.byt <CopyBuffer+11*19
.byt <CopyBuffer+11*20
.byt <CopyBuffer+11*21
.byt <CopyBuffer+11*22
.byt <CopyBuffer+11*23
.byt <CopyBuffer+11*24
.byt <CopyBuffer+11*25
.byt <CopyBuffer+11*26
.byt <CopyBuffer+11*27
.byt <CopyBuffer+11*28
.byt <CopyBuffer+11*29
.byt <CopyBuffer+11*30
.byt <CopyBuffer+11*31
.byt <CopyBuffer+11*32
.byt <CopyBuffer+11*33
.byt <CopyBuffer+11*34
.byt <CopyBuffer+11*35
.byt <CopyBuffer+11*36
.byt <CopyBuffer+11*37
.byt <CopyBuffer+11*38
.byt <CopyBuffer+11*39
.byt <CopyBuffer+11*40
.byt <CopyBuffer+11*41
.byt <CopyBuffer+11*42
.byt <CopyBuffer+11*43
.byt <CopyBuffer+11*44
.byt <CopyBuffer+11*45
.byt <CopyBuffer+11*46
.byt <CopyBuffer+11*47
.byt <CopyBuffer+11*48
.byt <CopyBuffer+11*49
.byt <CopyBuffer+11*50
.byt <CopyBuffer+11*51
.byt <CopyBuffer+11*52
.byt <CopyBuffer+11*53
.byt <CopyBuffer+11*54
.byt <CopyBuffer+11*55
.byt <CopyBuffer+11*56
.byt <CopyBuffer+11*57
.byt <CopyBuffer+11*58
.byt <CopyBuffer+11*59
.byt <CopyBuffer+11*60
.byt <CopyBuffer+11*61
.byt <CopyBuffer+11*62
.byt <CopyBuffer+11*63
BufferRowAddressHi
.byt >CopyBuffer
.byt >CopyBuffer+11*1
.byt >CopyBuffer+11*2
.byt >CopyBuffer+11*3
.byt >CopyBuffer+11*4
.byt >CopyBuffer+11*5
.byt >CopyBuffer+11*6
.byt >CopyBuffer+11*7
.byt >CopyBuffer+11*8
.byt >CopyBuffer+11*9
.byt >CopyBuffer+11*10
.byt >CopyBuffer+11*11
.byt >CopyBuffer+11*12
.byt >CopyBuffer+11*13
.byt >CopyBuffer+11*14
.byt >CopyBuffer+11*15
.byt >CopyBuffer+11*16
.byt >CopyBuffer+11*17
.byt >CopyBuffer+11*18
.byt >CopyBuffer+11*19
.byt >CopyBuffer+11*20
.byt >CopyBuffer+11*21
.byt >CopyBuffer+11*22
.byt >CopyBuffer+11*23
.byt >CopyBuffer+11*24
.byt >CopyBuffer+11*25
.byt >CopyBuffer+11*26
.byt >CopyBuffer+11*27
.byt >CopyBuffer+11*28
.byt >CopyBuffer+11*29
.byt >CopyBuffer+11*30
.byt >CopyBuffer+11*31
.byt >CopyBuffer+11*32
.byt >CopyBuffer+11*33
.byt >CopyBuffer+11*34
.byt >CopyBuffer+11*35
.byt >CopyBuffer+11*36
.byt >CopyBuffer+11*37
.byt >CopyBuffer+11*38
.byt >CopyBuffer+11*39
.byt >CopyBuffer+11*40
.byt >CopyBuffer+11*41
.byt >CopyBuffer+11*42
.byt >CopyBuffer+11*43
.byt >CopyBuffer+11*44
.byt >CopyBuffer+11*45
.byt >CopyBuffer+11*46
.byt >CopyBuffer+11*47
.byt >CopyBuffer+11*48
.byt >CopyBuffer+11*49
.byt >CopyBuffer+11*50
.byt >CopyBuffer+11*51
.byt >CopyBuffer+11*52
.byt >CopyBuffer+11*53
.byt >CopyBuffer+11*54
.byt >CopyBuffer+11*55
.byt >CopyBuffer+11*56
.byt >CopyBuffer+11*57
.byt >CopyBuffer+11*58
.byt >CopyBuffer+11*59
.byt >CopyBuffer+11*60
.byt >CopyBuffer+11*61
.byt >CopyBuffer+11*62
.byt >CopyBuffer+11*63
CopyBuffer
.dsb 704,0
pe_Grab
ldy PatternCursorY
jsr FetchPatternFieldRange
sta Grabbed_PatternEntryByte
;also store type of field
ldx PatternCursorX
lda PatternRowFieldType,x
sta Grabbed_PatternEntryType
DisplayGrabbedPatternEntry
ldy #<$bb80+36+40*3
sty screen
ldy #>$bb80+36+40*3
sty screen+1
tay
;Type
;0 0 if 0 plot - else Subtract 1 and display 1dd
;1 1 if 0 plot -- else Subtract 1 and display 2dd
;2 2 plot from cycle text
;3 3 Display Denary
;4 4 Display note
;5 5 plot from volume table
;6 7 if 0 plot - else Subtract 1 and display 1dh
;7 7 if 0 plot - else Subtract 1 and display 1dh
;8 6 plot from command table
;9 3 Display Denary
lda geDisplayFormatCodeLo,y
.(
sta vector1+1
lda geDisplayFormatCodeHi,y
sta vector1+2
ldy #00
sec
lda Grabbed_PatternEntryByte
vector1 jsr $dead
loop1 iny
lda #8+128
sta (screen),y
cpy #3
bcc loop1
.)
rts
geDisplayFormatCodeLo
.byt <pgePlot0
.byt <pgePlot1
.byt <pgePlot2
.byt <pgePlot3
.byt <pgePlot4
.byt <pgePlot5
.byt <pgePlot7
.byt <pgePlot7
.byt <pgePlot6
.byt <pgePlot3
geDisplayFormatCodeHi
.byt >pgePlot0
.byt >pgePlot1
.byt >pgePlot2
.byt >pgePlot3
.byt >pgePlot4
.byt >pgePlot5
.byt >pgePlot7
.byt >pgePlot7
.byt >pgePlot6
.byt >pgePlot3
pgePlot0 ;0 0 if 0 plot - else Subtract 1 and display 1dd
beq geDisplayHyphen
sbc #1
clc
adc #48
ora #128
sta (screen),y
rts
geDisplayDoubleHyphen
lda #"-"
ora #128
sta (screen),y
iny
geDisplayHyphen
lda #"-"
ora #128
sta (screen),y
rts
pgePlot1 ;1 1 if 0 plot -- else Subtract 1 and display 2dd
beq geDisplayDoubleHyphen
sbc #1
ldx #128
jmp Display2DD
pgePlot2 ;2 2 plot from cycle text
tax
lda CycleCharacter,x
ora #128
sta (screen),y
rts
pgePlot3 ;3 3 Display Denary
cmp #10
.(
bcc skip1
adc #6
skip1 adc #48
.)
ora #128
sta (screen),y
rts
pgePlot4 ;4 4 Display note
tax
lda NoteText_Semitone,x
ora #128
sta (screen),y
iny
lda NoteText_Sharp,x
ora #128
sta (screen),y
iny
lda NoteText_Octave,x
ora #128
sta (screen),y
rts
pgePlot5 ;5 5 plot from volume table
tax
lda PatternVolumeDigit,x
ora #128
sta (screen),y
rts
pgePlot6 ;8 6 plot from command table
tax
lda CommandDigit,x
ora #128
sta (screen),y
rts
pgePlot7 ;7 7 if 0 plot - else Subtract 1 and display 1dh
beq geDisplayHyphen
sbc #1
jmp pgePlot3
PatternRowFieldType
.byt 0,1,2,3
.byt 4,5,6,7,8,9
.byt 4,5,6,7,8,9
.byt 4,5,6,7,8,9
pe_Drop
ldx PatternCursorX
lda PatternRowFieldType,x
cmp Grabbed_PatternEntryType
.(
bne skip1
ldy PatternCursorY
jsr FetchPatternFieldRange
lda Grabbed_PatternEntryByte
jsr StorePatternFieldRange
skip1 rts
.)
pe_CopyLast
ldy PatternCursorY
beq cn_skip1
dey
jmp cn_Rent1
pe_CopyNext
ldy PatternCursorY
cpy #63
beq cn_skip1
iny
cn_Rent1 jsr FetchPatternFieldRange
ldy PatternCursorY
pha
jsr FetchPatternRowAddress
pla
ldx PatternCursorX
jsr StorePatternFieldRange2
cn_skip1 rts
pe_Increment
; nop
; jmp pe_Increment
ldy PatternCursorY
jsr FetchPatternFieldRange
clc
adc #01
jmp StorePatternFieldRange
StorePatternFieldRange
jsr IsNoteField
bcs spfr_skip1
StorePatternFieldRange2