-
Notifications
You must be signed in to change notification settings - Fork 3
/
MM-PTxPlay.asm
1743 lines (1573 loc) · 28.1 KB
/
MM-PTxPlay.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
;Universal PT2 and PT3 player for ZX Spectrum and MSX
;(c)2004-2007 S.V.Bulba <vorobey@mail.khstu.ru>
;http://bulba.untergrund.net (http://bulba.at.kz)
;Release number
Release EQU "1"
;Conditional assembly
;1) Version of ROUT (ZX or MSX standards)
ZX=0
MSX=0
RC=1
;2) Current position counter at (START+11)
CurPosCounter=0
;3) Allow channels allocation bits at (START+10)
ACBBAC=0
;4) Allow loop checking and disabling
LoopChecker=1
;5) Insert official identificator
Id=1
;Features
;--------
;-Can be compiled at any address (i.e. no need rounding ORG
; address).
;-Variables (VARS) can be located at any address (not only after
;code block).
;-INIT subprogram checks PT3-module version and rightly
; generates both note and volume tables outside of code block
; (in VARS).
;-Two portamento (spc. command 3xxx) algorithms (depending of
; PT3 module version).
;-New 1.XX and 2.XX special command behaviour (only for PT v3.7
; and higher).
;-Any Tempo value are accepted (including Tempo=1 and Tempo=2).
;-Fully compatible with Ay_Emul PT3 and PT2 players codes.
;-See also notes at the end of this source code.
;Limitations
;-----------
;-Can run in RAM only (self-modified code is used).
;-PT2 position list must be end by #FF marker only.
;Warning!!! PLAY subprogram can crash if no module are loaded
;into RAM or INIT subprogram was not called before.
;Call MUTE or INIT one more time to mute sound after stopping
;playing
boot equ #0000
bdos equ #0005
fcb1 equ #005c
sfcb equ fcb1
sfcbcr equ sfcb+#20 ;should point to CURRENT RECORD byte in SFCB
dbuff equ #0080
printf equ 9
openf equ 15
closef equ 16
readf equ 20
todma equ #80 ;this is the size of the read to DMA buffer
;stack equ MDLADDR+#5000
ORG #100
ld (oldstack),sp
ld sp,stack
ld de,sfcb ;name of file and drive are stored here
call open
ld de,nofile ;just in case of error
inc a
jr z,badfile ;no file found if zero
ld a,0 ;have to do this every file open
ld (sfcbcr),a ;set current record to 0 as CP/M does not
ld de,MDLADDR ;it is there but got corrupted for some reason
ld (next_dest),de ;we now have where the file is copied too and where it is expected.
r_loop
ld de,sfcb ;fcb needed prior to the call
call read
or a ;this will set zero flag unless it is eofile.....
jr nz,eofile
ld hl,dbuff ;ok we need to copy from DMA to where PTX-player expects it to be
ld de,(next_dest) ;sets the de to current end of address
ld bc,todma ;CP/M only gives us 128 bytes at a time
ldir ;ldir does the xfer for us
ld (next_dest),de ;DE is now 128 bytes higher, and, we can use to show where we got to
jr r_loop
eofile ld de,sfcb
call close
finis ld de,success ;message at this location
ld c,printf ;print it
call bdos
ld sp,(oldstack) ;put stack back to how we found it
jp begin ;and start PTX-player
badfile ld de,nofile
ld c,printf
call bdos
ld sp,(oldstack) ;put stack back to how we found it
ld c,#0 ;this is the CP/M proper exit call
jp bdos
open ld c,openf
jp bdos
close ld c,closef
jp bdos
read ld c,readf
jp bdos
nofile db "no file of that name",13,10,#24
success db "file read to memory, will play now",13,10,10,10,#24
next_dest DW MDLADDR
oldstack dw #0000
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;some of this gets overwritten for some strange reason.
stack ds #80
; END OF MM additions
; ld hl, startupstr
; call print
;Test codes (commented)
begin ;LD A,2 ;PT2,ABC,Looped
LD A, 0
LD (START+10),A
CALL START
ld hl, startupstr
call print
; EI
;_LP HALT
_LP CALL START+5
call pause
; XOR A
; IN A,(#FE)
; CPL
; AND 15
JR _LP
ld hl, endstr
call print
JR START+8
TonA EQU 0
TonB EQU 2
TonC EQU 4
Noise EQU 6
Mixer EQU 7
AmplA EQU 8
AmplB EQU 9
AmplC EQU 10
Env EQU 11
EnvTp EQU 13
;Entry and other points
;START initialize playing of module at MDLADDR
;START+3 initialization with module address in HL
;START+5 play one quark
;START+8 mute
;START+10 setup and status flags
;START+11 current position value (byte) (optional)
START
LD HL,MDLADDR
JR INIT
JP PLAY
JR MUTE
SETUP DB 0 ;set bit0, if you want to play without looping
;(optional);
;set bit1 for PT2 and reset for PT3 before
;calling INIT;
;bits2-3: %00-ABC, %01 ACB, %10 BAC (optional);
;bits4-6 are not used
;bit7 is set each time, when loop point is passed
;(optional)
IF CurPosCounter
CurPos DB 0 ;for visualization only (i.e. no need for playing)
ENDIF
;Identifier
IF Id
DB "=Uni PT2 and PT3 Player r.",Release,"="
ENDIF
IF LoopChecker
CHECKLP LD HL,SETUP
SET 7,(HL)
BIT 0,(HL)
RET Z
POP HL
LD HL,DelyCnt
INC (HL)
LD HL,ChanA+CHP.NtSkCn
INC (HL)
ENDIF
MUTE XOR A
LD H,A
LD L,A
LD (AYREGS+AmplA),A
LD (AYREGS+AmplB),HL
JP ROUT
INIT
;HL - AddressOfModule
LD A,(START+10)
AND 2
JR NZ,INITPT2
CALL SETMDAD
PUSH HL
LD DE,100
ADD HL,DE
LD A,(HL)
LD (Delay),A
PUSH HL
POP IX
ADD HL,DE
LD (CrPsPtr),HL
LD E,(IX+102-100)
INC HL
IF CurPosCounter
LD A,L
LD (PosSub+1),A
ENDIF
ADD HL,DE
LD (LPosPtr),HL
POP DE
LD L,(IX+103-100)
LD H,(IX+104-100)
ADD HL,DE
LD (PatsPtr),HL
LD HL,169
ADD HL,DE
LD (OrnPtrs),HL
LD HL,105
ADD HL,DE
LD (SamPtrs),HL
LD A,(IX+13-100) ;EXTRACT VERSION NUMBER
SUB #30
JR C,L20
CP 10
JR C,L21
L20 LD A,6
L21 LD (Version),A
PUSH AF ;VolTable version
CP 4
LD A,(IX+99-100) ;TONE TABLE NUMBER
RLA
AND 7
PUSH AF ;NoteTable number
LD HL,(e_-SamCnv-2)*256+#18
LD (SamCnv),HL
LD A,#BA
LD (OrnCP),A
LD (SamCP),A
LD A,#7B
LD (OrnLD),A
LD (SamLD),A
LD A,#87
LD (SamClc2),A
LD BC,PT3PD
LD HL,0
LD DE,PT3EMPTYORN
JR INITCOMMON
INITPT2 LD A,(HL)
LD (Delay),A
PUSH HL
PUSH HL
PUSH HL
INC HL
INC HL
LD A,(HL)
INC HL
LD (SamPtrs),HL
LD E,(HL)
INC HL
LD D,(HL)
POP HL
AND A
SBC HL,DE
CALL SETMDAD
POP HL
LD DE,67
ADD HL,DE
LD (OrnPtrs),HL
LD E,32
ADD HL,DE
LD C,(HL)
INC HL
LD B,(HL)
LD E,30
ADD HL,DE
LD (CrPsPtr),HL
LD E,A
INC HL
IF CurPosCounter
LD A,L
LD (PosSub+1),A
ENDIF
ADD HL,DE
LD (LPosPtr),HL
POP HL
ADD HL,BC
LD (PatsPtr),HL
LD A,5
LD (Version),A
PUSH AF
LD A,2
PUSH AF
LD HL,#51CB
LD (SamCnv),HL
LD A,#BB
LD (OrnCP),A
LD (SamCP),A
LD A,#7A
LD (OrnLD),A
LD (SamLD),A
LD A,#80
LD (SamClc2),A
LD BC,PT2PD
LD HL,#8687
LD DE,PT2EMPTYORN
INITCOMMON
LD (PTDECOD+1),BC
LD (PsCalc),HL
PUSH DE
;note table data depacker
;(c) Ivan Roshin
LD DE,T_PACK
LD BC,T1_+(2*49)-1
TP_0 LD A,(DE)
INC DE
CP 15*2
JR NC,TP_1
LD H,A
LD A,(DE)
LD L,A
INC DE
JR TP_2
TP_1 PUSH DE
LD D,0
LD E,A
ADD HL,DE
ADD HL,DE
POP DE
TP_2 LD A,H
LD (BC),A
DEC BC
LD A,L
LD (BC),A
DEC BC
SUB #F8*2
JR NZ,TP_0
IF LoopChecker
LD HL,SETUP
RES 7,(HL)
IF CurPosCounter
INC HL
LD (HL),A
ENDIF
ELSE
IF CurPosCounter
LD (CurPos),A
ENDIF
ENDIF
LD HL,VARS
LD (HL),A
LD DE,VARS+1
LD BC,VAR0END-VARS-1
LDIR
LD (AdInPtA),HL ;ptr to zero
INC A
LD (DelyCnt),A
LD HL,#F001 ;H - CHP.Volume, L - CHP.NtSkCn
LD (ChanA+CHP.NtSkCn),HL
LD (ChanB+CHP.NtSkCn),HL
LD (ChanC+CHP.NtSkCn),HL
POP HL
LD (ChanA+CHP.OrnPtr),HL
LD (ChanB+CHP.OrnPtr),HL
LD (ChanC+CHP.OrnPtr),HL
POP AF
;NoteTableCreator (c) Ivan Roshin
;A - NoteTableNumber*2+VersionForNoteTable
;(xx1b - 3.xx..3.4r, xx0b - 3.4x..3.6x..VTII1.0)
LD HL,NT_DATA
PUSH DE
LD D,B
ADD A,A
LD E,A
ADD HL,DE
LD E,(HL)
INC HL
SRL E
SBC A,A
AND #A7 ;#00 (NOP) or #A7 (AND A)
LD (L3),A
EX DE,HL
POP BC ;BC=T1_
ADD HL,BC
LD A,(DE)
ADD A,T_
LD C,A
ADC A,T_/256
SUB C
LD B,A
PUSH BC
LD DE,NT_
PUSH DE
LD B,12
L1 PUSH BC
LD C,(HL)
INC HL
PUSH HL
LD B,(HL)
PUSH DE
EX DE,HL
LD DE,23
LD IXH,8
L2 SRL B
RR C
L3 DB #19 ;AND A or NOP
LD A,C
ADC A,D ;=ADC 0
LD (HL),A
INC HL
LD A,B
ADC A,D
LD (HL),A
ADD HL,DE
DEC IXH
JR NZ,L2
POP DE
INC DE
INC DE
POP HL
INC HL
POP BC
DJNZ L1
POP HL
POP DE
LD A,E
CP TCOLD_1
JR NZ,CORR_1
LD A,#FD
LD (NT_+#2E),A
CORR_1 LD A,(DE)
AND A
JR Z,TC_EXIT
RRA
PUSH AF
ADD A,A
LD C,A
ADD HL,BC
POP AF
JR NC,CORR_2
DEC (HL)
DEC (HL)
CORR_2 INC (HL)
AND A
SBC HL,BC
INC DE
JR CORR_1
TC_EXIT
POP AF
;VolTableCreator (c) Ivan Roshin
;A - VersionForVolumeTable (0..4 - 3.xx..3.4x;
;5.. - 2.x,3.5x..3.6x..VTII1.0)
CP 5
LD HL,#11
LD D,H
LD E,H
LD A,#17
JR NC,M1
DEC L
LD E,L
XOR A
M1 LD (M2),A
LD IX,VT_+16
LD C,#F
INITV2 PUSH HL
ADD HL,DE
EX DE,HL
SBC HL,HL
LD B,#10
INITV1 LD A,L
M2 DB #7D
LD A,H
ADC A,0
LD (IX),A
INC IX
ADD HL,DE
DJNZ INITV1
POP HL
LD A,E
CP #77
JR NZ,M3
INC E
M3 DEC C
JR NZ,INITV2
JP ROUT
SETMDAD LD (MODADDR),HL
LD (MDADDR1),HL
LD (MDADDR2),HL
RET
PTDECOD JP #C3C3
;PT2 pattern decoder
PD2_SAM CALL SETSAM
JR PD2_LOOP
PD2_EOff LD (IX-12+CHP.Env_En),A
JR PD2_LOOP
PD2_ENV LD (IX-12+CHP.Env_En),16
LD (AYREGS+EnvTp),A
LD A,(BC)
INC BC
LD L,A
LD A,(BC)
INC BC
LD H,A
LD (EnvBase),HL
JR PD2_LOOP
PD2_ORN CALL SETORN
JR PD2_LOOP
PD2_SKIP INC A
LD (IX-12+CHP.NNtSkp),A
JR PD2_LOOP
PD2_VOL RRCA
RRCA
RRCA
RRCA
LD (IX-12+CHP.Volume),A
JR PD2_LOOP
PD2_DEL CALL C_DELAY
JR PD2_LOOP
PD2_GLIS SET 2,(IX-12+CHP.Flags)
INC A
LD (IX-12+CHP.TnSlDl),A
LD (IX-12+CHP.TSlCnt),A
LD A,(BC)
INC BC
LD (IX-12+CHP.TSlStp),A
ADD A,A
SBC A,A
LD (IX-12+CHP.TSlStp+1),A
SCF
JR PD2_LP2
PT2PD AND A
PD2_LP2 EX AF,AF'
PD2_LOOP LD A,(BC)
INC BC
ADD A,#20
JR Z,PD2_REL
JR C,PD2_SAM
ADD A,96
JR C,PD2_NOTE
INC A
JR Z,PD2_EOff
ADD A,15
JP Z,PD_FIN
JR C,PD2_ENV
ADD A,#10
JR C,PD2_ORN
ADD A,#40
JR C,PD2_SKIP
ADD A,#10
JR C,PD2_VOL
INC A
JR Z,PD2_DEL
INC A
JR Z,PD2_GLIS
INC A
JR Z,PD2_PORT
INC A
JR Z,PD2_STOP
LD A,(BC)
INC BC
LD (IX-12+CHP.CrNsSl),A
JR PD2_LOOP
PD2_PORT RES 2,(IX-12+CHP.Flags)
LD A,(BC)
INC BC
INC BC ;ignoring precalc delta to right sound
INC BC
SCF
JR PD2_LP2
PD2_STOP LD (IX-12+CHP.TSlCnt),A
JR PD2_LOOP
PD2_REL LD (IX-12+CHP.Flags),A
JR PD2_EXIT
PD2_NOTE LD L,A
LD A,(IX-12+CHP.Note)
LD (PrNote+1),A
LD (IX-12+CHP.Note),L
XOR A
LD (IX-12+CHP.TSlCnt),A
SET 0,(IX-12+CHP.Flags)
EX AF,AF'
JR NC,NOGLIS2
BIT 2,(IX-12+CHP.Flags)
JR NZ,NOPORT2
LD (LoStep),A
ADD A,A
SBC A,A
EX AF,AF'
LD H,A
LD L,A
INC A
CALL SETPORT
NOPORT2 LD (IX-12+CHP.TSlCnt),1
NOGLIS2 XOR A
PD2_EXIT LD (IX-12+CHP.PsInSm),A
LD (IX-12+CHP.PsInOr),A
LD (IX-12+CHP.CrTnSl),A
LD (IX-12+CHP.CrTnSl+1),A
JP PD_FIN
;PT3 pattern decoder
PD_OrSm LD (IX-12+CHP.Env_En),0
CALL SETORN
PD_SAM_ LD A,(BC)
INC BC
RRCA
PD_SAM CALL SETSAM
JR PD_LOOP
PD_VOL RRCA
RRCA
RRCA
RRCA
LD (IX-12+CHP.Volume),A
JR PD_LP2
PD_EOff LD (IX-12+CHP.Env_En),A
LD (IX-12+CHP.PsInOr),A
JR PD_LP2
PD_SorE DEC A
JR NZ,PD_ENV
LD A,(BC)
INC BC
LD (IX-12+CHP.NNtSkp),A
JR PD_LP2
PD_ENV CALL SETENV
JR PD_LP2
PD_ORN CALL SETORN
JR PD_LOOP
PD_ESAM LD (IX-12+CHP.Env_En),A
LD (IX-12+CHP.PsInOr),A
CALL NZ,SETENV
JR PD_SAM_
PT3PD LD A,(IX-12+CHP.Note)
LD (PrNote+1),A
LD L,(IX-12+CHP.CrTnSl)
LD H,(IX-12+CHP.CrTnSl+1)
LD (PrSlide+1),HL
PD_LOOP LD DE,#2010
PD_LP2 LD A,(BC)
INC BC
ADD A,E
JR C,PD_OrSm
ADD A,D
JR Z,PD_FIN
JR C,PD_SAM
ADD A,E
JR Z,PD_REL
JR C,PD_VOL
ADD A,E
JR Z,PD_EOff
JR C,PD_SorE
ADD A,96
JR C,PD_NOTE
ADD A,E
JR C,PD_ORN
ADD A,D
JR C,PD_NOIS
ADD A,E
JR C,PD_ESAM
ADD A,A
LD E,A
LD HL,SPCCOMS+#FF20-#2000
ADD HL,DE
LD E,(HL)
INC HL
LD D,(HL)
PUSH DE
JR PD_LOOP
PD_NOIS LD (Ns_Base),A
JR PD_LP2
PD_REL RES 0,(IX-12+CHP.Flags)
JR PD_RES
PD_NOTE LD (IX-12+CHP.Note),A
SET 0,(IX-12+CHP.Flags)
XOR A
PD_RES LD (PDSP_+1),SP
LD SP,IX
LD H,A
LD L,A
PUSH HL
PUSH HL
PUSH HL
PUSH HL
PUSH HL
PUSH HL
PDSP_ LD SP,#3131
PD_FIN LD A,(IX-12+CHP.NNtSkp)
LD (IX-12+CHP.NtSkCn),A
RET
C_PORTM LD A,(BC)
INC BC
;SKIP PRECALCULATED TONE DELTA (BECAUSE
;CANNOT BE RIGHT AFTER PT3 COMPILATION)
INC BC
INC BC
EX AF,AF'
LD A,(BC) ;SIGNED TONE STEP
INC BC
LD (LoStep),A
LD A,(BC)
INC BC
AND A
EX AF,AF'
LD L,(IX-12+CHP.CrTnSl)
LD H,(IX-12+CHP.CrTnSl+1)
;Set portamento variables
;A - Delay; A' - Hi(Step); ZF' - (A'=0); HL - CrTnSl
SETPORT RES 2,(IX-12+CHP.Flags)
LD (IX-12+CHP.TnSlDl),A
LD (IX-12+CHP.TSlCnt),A
PUSH HL
LD DE,NT_
LD A,(IX-12+CHP.Note)
LD (IX-12+CHP.SlToNt),A
ADD A,A
LD L,A
LD H,0
ADD HL,DE
LD A,(HL)
INC HL
LD H,(HL)
LD L,A
PUSH HL
PrNote LD A,#3E
LD (IX-12+CHP.Note),A
ADD A,A
LD L,A
LD H,0
ADD HL,DE
LD E,(HL)
INC HL
LD D,(HL)
POP HL
SBC HL,DE
LD (IX-12+CHP.TnDelt),L
LD (IX-12+CHP.TnDelt+1),H
POP DE
Version EQU $+1
LD A,#3E
CP 6
JR C,OLDPRTM ;Old 3xxx for PT v3.5-
PrSlide LD DE,#1111
LD (IX-12+CHP.CrTnSl),E
LD (IX-12+CHP.CrTnSl+1),D
LoStep EQU $+1
OLDPRTM LD A,#3E
EX AF,AF'
JR Z,NOSIG
EX DE,HL
NOSIG SBC HL,DE
JP P,SET_STP
CPL
EX AF,AF'
NEG
EX AF,AF'
SET_STP LD (IX-12+CHP.TSlStp+1),A
EX AF,AF'
LD (IX-12+CHP.TSlStp),A
LD (IX-12+CHP.COnOff),0
RET
C_GLISS SET 2,(IX-12+CHP.Flags)
LD A,(BC)
INC BC
LD (IX-12+CHP.TnSlDl),A
AND A
JR NZ,GL36
LD A,(Version) ;AlCo PT3.7+
CP 7
SBC A,A
INC A
GL36 LD (IX-12+CHP.TSlCnt),A
LD A,(BC)
INC BC
EX AF,AF'
LD A,(BC)
INC BC
JR SET_STP
C_SMPOS LD A,(BC)
INC BC
LD (IX-12+CHP.PsInSm),A
RET
C_ORPOS LD A,(BC)
INC BC
LD (IX-12+CHP.PsInOr),A
RET
C_VIBRT LD A,(BC)
INC BC
LD (IX-12+CHP.OnOffD),A
LD (IX-12+CHP.COnOff),A
LD A,(BC)
INC BC
LD (IX-12+CHP.OffOnD),A
XOR A
LD (IX-12+CHP.TSlCnt),A
LD (IX-12+CHP.CrTnSl),A
LD (IX-12+CHP.CrTnSl+1),A
RET
C_ENGLS LD A,(BC)
INC BC
LD (Env_Del),A
LD (CurEDel),A
LD A,(BC)
INC BC
LD L,A
LD A,(BC)
INC BC
LD H,A
LD (ESldAdd),HL
RET
C_DELAY LD A,(BC)
INC BC
LD (Delay),A
RET
SETENV LD (IX-12+CHP.Env_En),E
LD (AYREGS+EnvTp),A
LD A,(BC)
INC BC
LD H,A
LD A,(BC)
INC BC
LD L,A
LD (EnvBase),HL
XOR A
LD (IX-12+CHP.PsInOr),A
LD (CurEDel),A
LD H,A
LD L,A
LD (CurESld),HL
C_NOP RET
SETORN ADD A,A
LD E,A
LD D,0
LD (IX-12+CHP.PsInOr),D
OrnPtrs EQU $+1
LD HL,#2121
ADD HL,DE
LD E,(HL)
INC HL
LD D,(HL)
MDADDR2 EQU $+1
LD HL,#2121
ADD HL,DE
LD (IX-12+CHP.OrnPtr),L
LD (IX-12+CHP.OrnPtr+1),H
RET
SETSAM ADD A,A
LD E,A
LD D,0
SamPtrs EQU $+1
LD HL,#2121
ADD HL,DE
LD E,(HL)
INC HL
LD D,(HL)
MDADDR1 EQU $+1
LD HL,#2121
ADD HL,DE
LD (IX-12+CHP.SamPtr),L
LD (IX-12+CHP.SamPtr+1),H
RET
;ALL 16 ADDRESSES TO PROTECT FROM BROKEN PT3 MODULES
SPCCOMS DW C_NOP
DW C_GLISS
DW C_PORTM
DW C_SMPOS
DW C_ORPOS
DW C_VIBRT
DW C_NOP
DW C_NOP
DW C_ENGLS
DW C_DELAY
DW C_NOP
DW C_NOP
DW C_NOP
DW C_NOP
DW C_NOP
DW C_NOP
CHREGS XOR A
LD (Ampl),A
BIT 0,(IX+CHP.Flags)
PUSH HL
JP Z,CH_EXIT
LD (CSP_+1),SP
LD L,(IX+CHP.OrnPtr)
LD H,(IX+CHP.OrnPtr+1)
LD SP,HL
POP DE
LD H,A
LD A,(IX+CHP.PsInOr)
LD L,A
ADD HL,SP
INC A
;PT2 PT3
OrnCP INC A ;CP E CP D
JR C,CH_ORPS
OrnLD DB 1 ;LD A,D LD A,E
CH_ORPS LD (IX+CHP.PsInOr),A
LD A,(IX+CHP.Note)
ADD A,(HL)
JP P,CH_NTP