; align 256
;CMbuf DB -1 ;USED ORNS+SMPS
; DS 16+31
;t1buf DB -1,-1,-1,-1,0
MACRO IYAi
LD (IY),A
INC IY
ENDM
MACRO IYNi par
LD (IY),par
INC IY
ENDM
MACRO IYLi
LD (IY),L
INC IY
ENDM
MACRO IYHi
LD (IY),H
INC IY
ENDM
PatDisp
LD A,(IX-0) ;-8
patdisp=$-1
IYAi
LD A,(IX-0) ;-7
patdisp1=$-1
IYAi
RET
PUTIY
PUSH AF
CALL OUT7
PUSH HL
LD HL,(pnter)
LD A,LY
SUB ptmod&0xff
LD (HL),A
INC HL
LD A,HY
SBC A,ptmod/256
LD (HL),A
INC HL
LD (pnter),HL
POP HL
POP AF
RET
cMPILE
LD (CMsmpU0),A
LD (CMornU0),A
XOR A
LD (CMPcnt),A
DI
CALL CMPIL
CALL CMPso
;LD IY,23610
EI
IF process
CALL CLOSWIN
LD A,205
ld (MHEXFNT+2),A
CALL OUT7
ENDIF
sngE=$+1
LD HL,lce84
LD DE,ptmod
;OR A
SBC HL,DE
ex de,hl
RET
;1
CMPIL
IF process
CALL PROCESS
ENDIF
IF 0==portres
LD A,97
LD (t1not),A
LD (po2not),A
ENDIF
;DI
LD HL,CMbuf+1
LD DE,CMbuf+2
LD BC,16+31-1
LD (HL),B
LDIR
LD DE,l5b00+1
LD H,D
ld L,B
LD C,250
LD (HL),L
LDIR
CALL OUT7
LD HL,TPROTR
LD DE,ptmod
LD C,99
LDIR
LD H,D
ld L,E
INC DE
LD (HL),B
LD B,3 ;на всякий случ trks
LDIR
LD A,(FRQn)
LD (lce84),A
LD A,(TEMPO)
LD (lce85),A
LD A,(LENG)
LD (lce86),A
LD B,A
LD A,(LOOP)
CP B
jr C,$+3
XOR A
LD (lce87),A
LD HL,TPOSS
LD DE,lceea
CMPpos LD A,(HL)
ADD A,A
ADD A,(HL)
LD (DE),A
INC L
INC DE
DJNZ CMPpos
LD A,-1
LD (DE),A
INC DE
ex de,hl
LD (sngCUR),HL
LD DE,-ptmod
ADD HL,DE
LD (lce88),HL
LD A,(LENG)
LD C,A
LD A,PATS-1
CMPmax LD B,C
LD HL,TPOSS
CP (HL)
jr Z,CMPmaxQ
INC L
DJNZ $-4
DEC A
JP P,CMPmax
CMPmaxQ INC A
LD (CMPlst),A
LD B,A
ADD A,A
ADD A,B
LD L,A
ld H,0
ADD HL,HL
;LD DE,6
;LD H,D,L,D
;ADD HL,DE
;DJNZ $-1
sngCUR=$+1
LD DE,0
ADD HL,DE
LD (sngE),HL
PUSH DE
LD B,3
CMP00 XOR A
;PUSH DE
CMP0
IF portres
LD (CMporeA),A
ENDIF
PUSH AF
PUSH BC
CALL CMPP
POP BC
POP AF
INC A
CMPlst=$+1
CP 0
IF process
jr Z,CMP0Q
;PUSH AF
PUSH BC
BIT 0,B
;A<>0: bar увеличивается на 1
CALL Z,PROBAR
POP BC
;POP AF
;LD L,A
JR CMP0
ELSE
jr NZ,CMP0
ENDIF
CMP0Q
;POP HL
;INC HL,HL
;LD (sngCUR),HL
;ex de,hl
LD A,B
ADD A,5
LD B,A
CP 13+5
jr C,CMP00
POP HL
PUSH HL
LD DE,BUF
LD B,3
LDIR
LD HL,BUF
POP DE
LD B,3
CMPRE60
LD A,(CMPlst)
PUSH DE
CMPRE61
LDI
INC BC
LDI
INC BC
INC DE
inc DE
inc DE
inc DE
DEC A
jr NZ,CMPRE61
POP DE
INC DE
inc DE
DJNZ CMPRE60
IF process
JP CMPQ
ELSE
RET
ENDIF
CMPP
PUSH BC
LD L,A
ld H,TPATSZ/256
LD A,(HL)
ld (CMPPlen),A
LD A,L
CALL PATtoBUF ;делает OUT7
LD IY,(sngE)
IF portres
LD A,97
LD (t1not),A
LD (po2not),A
ENDIF
POP AF ;3/8/13
CALL CMt
LD (sngE),IY
RET
CMt
LD IX,BUF
LD C,A
ld B,0
ADD IX,BC
NEG
LD (patdisp),A
INC A
LD (patdisp1),A
SUB -8+1
jr Z,$+4
LD A,DJt1Nn
LD (CMisb-1),A
LD (CMt2IY),IY ;начало трека
PUSH IX
LD HL,t1buf+4
XOR A
;LD (CMoldT),A
LD (CMoldN),A
LD (HL),A
DEC HL
LD (HL),A
DEC HL
DEC A
LD (HL),A
DEC HL
LD (HL),A
DEC HL
LD (HL),A
CMPPlen=$+1
LD A,0
INC A
CMt10 ex af,af'
LD A,(t1not)
CP 96
jr NC,$+5
LD (po2not),A
LD HL,t1buf
LD A,(IX)
LD C,A
AND #7F
jr NZ,CMt1NZ
LD A,97
ld (t1not),A
JP CMt1IG
CMt1NZ
DEC A
LD (t1not),A
SLA C
LD A,(IX+3)
RRA
RRA
RRA
RRA
AND 31
jr Z,$+3
CP (HL)
jr Z,CMt1IG
LD (HL),A
SUB -#D0
LD (t1smp),A
INC L
inc L
LD A,(IX+3)
AND #F
;jr Z,CMt1Nt1
LD C,A
LD A,(IX+4)
AND #F0
CP C
jr Z,CMt1Nt1
RRCA
RRCA
RRCA
RRCA
CP (HL)
jr Z,CMt1No1
LD (HL),A
INC C
DEC C
jr NZ,CMseFx
LD A,(t1smp)
IYAi
LD A,(HL)
DEC L
SUB -#40
JR CMt1G
CMseFx
DEC L
LD (HL),#F
SUB -#F0
IYAi
LD A,(t1smp)
SUB -#30
ADD A,A
JR CMt1G
CMt1No1
DEC L
LD A,C
OR A
jr Z,CMt1Nt2
CP #F
jr NZ,CMt1Yt
CP (HL)
jr Z,CMt1Nt2
LD (HL),A
XOR A
JR $+3
CMt1Yt LD (HL),A
SUB -#10
IYAi
SUB #10
;JZ CMt1NE1
CALL NZ,PatDisp
CMt1NE1 LD A,(t1smp)
SUB -#30
ADD A,A
IYAi
JR CMt1INE
CMt1Nt1
LD A,(t1smp)
JR CMt1Yo2
t1smp=$+1
CMt1Nt2
LD A,0
CMt1G IYAi
DEC L
CMt1IG INC L
LD A,(IX+3)
;INC L
AND #F
LD C,A
jr Z,CMt1INE
;jr Z,CMt1INo
;DEC L
CP #F
jr NZ,$+5
CP (HL)
jr Z,CMt1INE
LD (HL),A
INC A
AND #F
SUB -#B0
IYAi
SUB #B0
;jr Z,CMt1INE ;B0
;Bx,Henv,Lenv
CALL NZ,PatDisp
CMt1INE INC L
LD A,(IX+4)
AND #F0
CP C
jr Z,CMt1INo
RRCA
RRCA
RRCA
RRCA
CP (HL)
jr Z,CMt1INo
LD (HL),A
SUB -#40
CMt1Yo2 IYAi
CMt1INo INC L
LD A,(IX+4)
AND #F
jr Z,CMt1Nv
CP (HL)
jr Z,CMt1Nv
LD (HL),A
SUB 64
IYAi
CMt1Nv INC L
JR CMt1Nn
CMisb
LD A,(IX-6)
AND 31
CP (HL)
jr Z,CMt1Nn
LD (HL),A
SUB -#20
IYAi
DJt1Nn=$-CMisb
CMt1Nn LD A,(IX+1)
AND #F0
CALL NZ,CMcom
CALL CMt1PP
LD A,C
CMoldN=$+1
CP 0
jr Z,CMt1Nb
IYNi #B1
LD (CMoldN),A
IYAi
CMt1Nb CALL CMnot
CMt1Q LD H,CMbuf/256
LD A,(t1buf+2)
LD L,A
RLA
jr C,$+4
LD (HL),-1
LD A,(t1buf)
ADD A,16
jr C,$+5
LD L,A
LD (HL),-1
ex af,af'
OR A
JP NZ,CMt10
IYAi ;#0=end of track
POP IX
PUSH IY
;CMPcnt=$+1
LD A,(CMPcnt)
OR A
jr Z,CMt2Q
;LD (CMt2L),A ;кол-во сделанных треков
;LD IX,lce88 ;начало треков
;LD E,(IX)
;LD D,(IX+1)
;LD HL,ptmod
;ADD HL,DE
;PUSH HL
;POP IX
LD IX,(lce88)
LD DE,ptmod
ADD IX,DE
;LD IY,(CMt2IY) ;начало текущего трека
XOR A
CMt20 LD E,A
ADD A,A
LD L,A
LD H,l5b00/256
LD C,(HL)
INC L
LD B,(HL) ;длина старого трека
LD A,E
ex af,af'
LD L,(IX)
INC IX
LD H,(IX)
LD (CMt2HL),HL ;смещ. старого трека
INC IX
LD DE,ptmod
ADD HL,DE
;PUSH IY
;POP DE ;начало текущего трека
LD DE,(CMt2IY) ;начало текущего трека
LD A,B
OR C
jr Z,CMt2Ncp
CMt2cp LD A,(DE)
CP (HL)
jr NZ,CMt2Ncp
INC HL
inc DE
DEC BC
LD A,B
OR C
jr NZ,CMt2cp
CMt2Ycp POP HL ;бывший IY
CMt2HL=$+1
LD DE,0 ;смещ. старого трека (к-й такой же, как новый)
LD HL,CMPcnt
INC (HL)
LD HL,(sngCUR)
LD (HL),E
INC HL
LD (HL),D
INC HL
;INC HL,HL,HL,HL
LD (sngCUR),HL
CMt2IY=$+2
LD IY,0 ;как было до компиляции трека
RET
CMt2Ncp
BIT 7,D
jr NZ,CMtNeMEM
LD A,6
OUT (-2),A
JR CMt2Ycp ;память кончилась
CMtNeMEM
ex af,af'
INC A
CMPcnt=$+1
CP 0 ;кол-во сделанных треков
jr NZ,CMt20
CMt2Q LD HL,CMPcnt
LD B,(HL)
INC (HL) ;кол-во сделанных треков
LD HL,(CMt2IY)
PUSH HL
LD DE,-ptmod
ADD HL,DE
ex de,hl
LD HL,(sngCUR)
LD (HL),E
INC HL
LD (HL),D
INC HL
;INC HL,HL,HL,HL
LD (sngCUR),HL
POP DE ;начало текущего трека
POP HL ;бывший IY=после конца трека
PUSH HL
POP IY
OR A
SBC HL,DE
ex de,hl
LD L,B ;кол-во сделанных треков
ADD HL,HL
LD H,l5b00/256
LD (HL),E
INC L
LD (HL),D ;длина трека
RET
CMPso
LD HL,lce8a
LD (pnter),HL
LD IY,(sngE)
XOR A
CMPs PUSH AF
CALL CMPsmp
POP AF
INC A
AND 31
jr NZ,CMPs
LD HL,lceca
LD (pnter),HL
CMPo PUSH AF
CALL CMPorn
POP AF
INC A
AND 15
jr NZ,CMPo
LD (sngE),IY
RET
CMPsmp
LD L,0
PUSH AF
ADD A,SMPS/256
LD H,A
CALL OUT4
LD DE,BUF
PUSH DE
POP IX
LD BC,256
LDIR
POP AF
LD B,A
ADD A,16
LD H,CMbuf/256
LD L,A
LD A,(HL)
LD L,B
ADD HL,HL
LD H,TSMPSZ/256
OR A
jr NZ,CMsmpU
OR (HL)
jr NZ,CMsmpU0
INC A
INC HL
SUB (HL)
DEC HL
jr NZ,CMsmpU0
LD A,(IX+2)
XOR 64
OR (IX)
OR (IX+1)
jr NZ,CMsmpU0
LD A,(IX+3)
CP 15
CMsmpU0 jr Z,pntii ;
CMsmpU
CALL PUTIY
LD A,(HL)
IYAi
INC HL
LD A,(HL)
IYAi
LD B,A
CMPS0 LD A,(IX+2)
LD C,A
AND 31
RLCA
LD D,A
LD A,C
AND #20
jr Z,$+4
LD A,1
OR D
LD D,A
LD A,(IX+3)
AND #C0
OR D
IYAi
LD A,C
RLCA
AND #80
LD D,A
LD A,C
RRCA
RRCA
RRCA
AND #10
OR D
LD D,A
LD A,(IX+3)
LD E,A
AND #F
OR D
LD D,A
LD A,E
RLCA
AND #60
OR D
IYAi
LD A,(IX)
IYAi
LD A,(IX+1)
IYAi
LD DE,4
ADD IX,DE
DJNZ CMPS0
RET
pnter=$+1
pntii
LD HL,0
INC HL
inc HL
LD (pnter),HL
RET
CMPorn
PUSH AF
CALL HLOR3
CALL OUT4
LD DE,BUF
LD BC,64
LDIR
POP AF
LD L,A
ld H,CMbuf/256
LD C,(HL)
LD HL,TORNSZ
ADD A,A
ADD A,L
LD L,A
LD A,C
OR A
jr NZ,CMornU
OR (HL)
jr NZ,CMornU0
INC A
INC HL
SUB (HL)
DEC HL
jr NZ,CMornU0
LD A,(BUF)
OR A
CMornU0 jr Z,pntii ;
CMornU
CALL PUTIY
PUSH IY
POP DE
LDI
INC BC
LD A,(HL)
LD (DE),A
INC DE
LD C,A
LD HL,BUF
LDIR
PUSH DE
POP IY
RET
t1not=$+1
CMnot
LD A,0
LD H,#D0
CP 97
jr Z,CMnotQ
LD H,#C0
CP 96
jr Z,CMnotQ
SUB #B0
LD H,A
CMnotQ IYHi
PUSH IX
CMnotIX=$+2
LD IX,0
CMjp=$+1
CALL CMret
LD HL,CMret
ld (CMjp),HL
POP IX
CMret RET
CMcom
LD C,16
SUB C
jr Z,CMglD
SUB C
jr Z,CMglU
SUB C
jr Z,CMpor
SUB C
JP Z,CMso
SUB C
JP Z,CMoo
SUB C
JP Z,CMvib
IF gs
SUB 32
JP Z,CMgs
SUB C
ELSE
SUB 48
ENDIF
jr Z,CMenD
SUB C
jr Z,CMenU
SUB C
RET NZ
LD A,(IX+2)
;CMoldT=$+1
;CP 0
;RET Z
OR A
RET Z
LD A,9
LD HL,CMtm2
JR CMenDQ
CMglD
LD HL,CMgD2
JR $+5
CMglU
LD HL,CMgU2
LD A,1
JR CMenDQ
CMgD2
LD A,(IX+1)
AND #F
LD H,A
JR CMpoQ
CMgU2
LD A,(IX+1)
AND #F
LD H,A
SCF
JR CMpoQ
CMenU
LD HL,CMgU2
JR $+5
CMenD
LD HL,CMgD2
LD A,8
CMenDQ IYAi
LD (CMjp),HL
RET
CMpor
IF portres
LD A,(po2not)
CP 96
CALL NC,CMpores
LD (po2not),A
ENDIF
LD A,(t1not)
CP 96
RET NC
po2not=$+1
CP 0
RET Z
LD A,2
LD HL,CMpo2
JR CMenDQ
CMpo2
LD A,(IX+1)
AND #F
IYAi
LD A,(po2not)
LD HL,FrTab
ADD A,A
ADD A,L
LD L,A
LD E,(HL)
INC L
LD D,(HL)
LD A,(t1not)
ADD A,A
ADD A,FrTab&0xff
LD L,A
LD A,(HL)
INC L
LD H,(HL)
LD L,A
SBC HL,DE
PUSH AF
CALL C,NEGHL
POP AF
IYLi
CMpoQ
IYHi
LD L,(IX+2)
ld H,0
CALL C,NEGHL
IYLi
IYHi
RET
CMoo
LD A,4
JR CMsoQ
CMso
LD A,3
CMsoQ LD HL,CMof
JR CMenDQ
CMvib
LD A,5
LD HL,CMv2
JR CMenDQ
CMof
LD A,(IX+2)
AND 63
IYAi
RET
CMtm2
LD A,(IX+2)
;LD (CMoldT),A
IYAi
RET
IF gs
CMgs
LD A,7
LD HL,CMgs2
JP CMenDQ
CMgs2
LD A,(IX+1)
AND #F ;smp
IYAi
JR CMtm2
ENDIF
CMv2
LD A,(IX+2)
LD C,A
AND #F0
RRCA
RRCA
RRCA
RRCA
IYAi
LD A,C
AND #F
IYAi
RET
CMt1PP
LD (CMnotIX),IX
ex af,af'
LD B,A
ex af,af'
DJNZ CMisnot
ex af,af'
DEC A
ex af,af'
LD A,(CMoldN)
DEC A
jr Z,CMt1PPQ
IYNi #B1
IYNi 1
CMt1PPQ CALL CMnot
POP HL
JP CMt1Q
;COUNT blS
CMisnot
LD C,1
CMisno0 LD DE,18
ADD IX,DE
LD HL,t1buf+1
LD A,(IX)
AND #7F
jr NZ,CMisnoQ
LD A,(IX+1)
AND #F0
jr NZ,CMisnoQ
INC L
LD A,(IX+3)
AND #F
LD E,A
jr Z,CMisn0x
;jr Z,CMisnNE
CP #F
jr NZ,CMisnoQ
DEC L
CP (HL)
jr NZ,CMisnoQ
CMisn0x LD A,(IX+4)
AND #F0
CP E
jr Z,CMisnNE
RRCA
RRCA
RRCA
RRCA
INC L
CP (HL)
jr NZ,CMisnoQ
CMisnNE LD A,(IX+4)
INC L
AND #F
jr Z,$+5
CP (HL)
jr NZ,CMisnoQ
INC L
LD A,(CMisb-1)
OR A
jr NZ,CMisnNQ
LD A,(IX-6)
CP (HL)
jr NZ,CMisnoQ
CMisnNQ INC C
DJNZ CMisno0
CMisnoQ ex af,af'
SUB C
ex af,af'
RET
LDPT3PP
CALL cs_8026 ;CS=merge
jr NC,PT3PP2
CALL CLPATS
CALL CLORNSM
LD DE,TPATSZ+1
LD BC,PATS-1
LD H,D
ld L,B
LD (HL),63
LDIR
PT3PP2
;DI
CALL OUT7
LD A,(lce84)
ld (FRQn),A
LD A,(lce85)
ld (TEMPO),A
LD A,(lce87)
ld (LOOP),A
LD H,l5b00/256
LD BC,PATS*256
Mdiv3 LD A,C
ADD A,A
add A,C
LD L,A
LD (HL),C
INC C
DJNZ Mdiv3
CALL CLPOS
LD A,(lce86)
ld (LENG),A
LD B,A
LD IX,lceea
LD H,l5b00/256
LD DE,TPOSS
PT3POS LD L,(IX)
LD A,(HL)
ld (DE),A
INC E
INC IX
DJNZ PT3POS
XOR A
LD (DE),A
INC E
jr NZ,$-2
LD HL,lce3f
LD DE,TTITLE
LD C,32
LDIR
LD HL,lce63
LD DE,TAUTHOR
LD C,33;32 ;3.7 for TS
LDIR
CALL PT3PATS
CALL PT3SMP
CALL PT3ORN
JP GETPATLEN
;LD HL,(TPOSS),H,'TPATSZ
;LD A,(HL),(PATLEN),A
;IF process
;LD IY,23610
;ENDIF
;RET
IF process
PROCESS
LD A,201
ld (MHEXFNT+2),A
XOR A
LD (PROBARX),A
LD BC,mPROCES
CALL WINDUM
LD HL,tPROCES
JP PRMENU
mPROCES DB 4,#C,#1C,#10,#47
tPROCES DB 6,#11,0,"PROCESSIN",#C7
CMPQ
XOR A
;2
PROBAR
PUSH AF
PROBARY=$+1
PROBARX=$+2
LD DE,1
OR A ;A=0: 100%
LD B,1
jr NZ,PROBAR0
LD A,#2A ;?
SUB D
jr C,PROBARQ
jr Z,PROBARQ
LD B,A
PROBAR0 LD A,'0'
CALL PRADD
INC D
DJNZ PROBAR0
LD (PROBARY),DE
PROBARQ POP AF
RET
ENDIF
IF portres
CMpores
CMporeA=$+1
LD A,0
LD HL,TPOSS
LD B,(HL)
INC L
cMpore0 CP (HL)
jr Z,$+6
LD B,(HL)
INC L
jr NZ,cMpore0
LD A,B ;пред.паттерн
CALL AtoPAT
LD HL,(patdisp)
ld H,0
ADD HL,DE
LD B,#40
LD DE,18
LD A,(HL)
AND #7F
DEC A
LD C,A
cMpore1 LD A,(HL)
AND #7F
jr Z,cMpore2
DEC A
CP 96
jr Z,$+3
LD C,A
cMpore2 ADD HL,DE
DJNZ cMpore1
CALL OUT7
LD A,C
RET
ENDIF
LDPT2PP
LD A,32
LD (ts48),A
LD A,1
ld (FRQn),A
CALL CLPATS
CALL CLSMPS ;DICLos? CLORNSM?
CALL CLORNS
LD DE,TPATSZ+1
LD BC,PATS-1
LD H,D
ld L,B
LD (HL),63
LDIR
CALL PT2PP2
XOR A
LD (POS),A
RET
PT2PP2
CALL OUT7
LD HL,ptmod
LD A,(HL)
ld (TEMPO),A
INC HL
LD A,(HL)
ld (LENG),A
INC HL
PUSH AF
LD A,(HL)
ld (LOOP),A
LD HL,_ce86
LD DE,TTITLE
LD BC,30
LDIR
LD A,' '
LD (DE),A
INC DE
LD (DE),A
LD HL,TAUTHOR
LD DE,TAUTHOR+1
LD (HL),A
LD C,31
LDIR
POP AF
LD C,A
LD HL,_cea4
LD DE,TPOSS
LDIR
XOR A
LD (DE),A
INC E
jr NZ,$-2
CALL PT2SMP
CALL PT2ORN
CALL PT2PATS
GETPATLEN
LD HL,(TPOSS)
ld H,TPATSZ/256
LD A,(HL)
ld (PATLEN),A
RET
PT3PATS
CALL OUT7
LD B,PATS-1
PT3P0 LD HL,TPOSS
PT3P1 LD A,(HL)
CP B
jr Z,PT3P0Q
INC L
jr NZ,PT3P1
DJNZ PT3P0
PT3P0Q LD A,B
ld (PT3Plst),A
LD HL,(lce88)
LD DE,ptmod
ADD HL,DE
XOR A
PT3P2 PUSH AF
CALL KILLBUF
LD E,(HL)
INC HL
LD D,(HL)
INC HL
PUSH HL
LD A,3
ld (PT3Edsp),A
LD IX,BUF+3
CALL PT3PAPP
POP HL
LD E,(HL)
INC HL
LD D,(HL)
INC HL
PUSH HL
LD A,8
ld (PT3Edsp),A
;LD (PT3putN+1),A ;noise ON
LD IX,BUF+8
CALL PT3PAPP
POP HL
LD E,(HL)
INC HL
LD D,(HL)
INC HL
PUSH HL
;XOR A
;LD (PT3putN+1),A ;noise OFF
LD A,13
ld (PT3Edsp),A
LD IX,BUF+13
CALL PT3PAPP
POP HL
POP AF
;D=patlen-1
CALL PATfrBUF
PT3Plst=$+1
CP 0
RET Z
INC A
JR PT3P2
;на 99% совпадает с PT3PATS
PT2PATS
CALL OUT7
LD B,31
PT2P0 LD HL,TPOSS
PT2P1 LD A,(HL)
CP B
jr Z,PT2P0Q
INC L
jr NZ,PT2P1
DJNZ PT2P0
PT2P0Q LD A,B
ld (PT2Plst),A
LD HL,(_ce84)
LD DE,ptmod
ADD HL,DE
XOR A
PT2P2 PUSH AF
CALL KILLBUF
LD E,(HL)
INC HL
LD D,(HL)
INC HL
PUSH HL
LD A,3
LD IX,BUF+3
CALL PT2PAPP
POP HL
LD E,(HL)
INC HL
LD D,(HL)
INC HL
PUSH HL
LD A,8
LD IX,BUF+8
CALL PT2PAPP
POP HL
LD E,(HL)
INC HL
LD D,(HL)
INC HL
PUSH HL
LD A,13
LD IX,BUF+13
CALL PT2PAPP
POP HL
POP AF
CALL PATfrBUF
PT2Plst=$+1
CP 0
RET Z
INC A
JR PT2P2
PT3PAPP
ex de,hl
LD DE,ptmod
ADD HL,DE
XOR A
LD (PT3orN),A
LD (PT3n),A
LD D,A
PT3PAP0 LD BC,#1020
LD A,(HL)
INC HL
OR A
RET Z
ADD A,B
jr C,PT3orn
ADD A,C
jr C,PT3smp
ADD A,B
JP C,PT3vol
ADD A,B
JP C,PT3Et
ADD A,96
jr C,PT3note
ADD A,B
JP C,PT3newO
ADD A,C
JP C,PT3nois
ADD A,B
JP C,PT3Etyp
ADD A,B
JP PT3com
PT3blN
LD A,(HL)
INC HL
DEC A
LD (PT3bls),A
JR PT3PAP0
PT3bls=$+1
PT3blQ
LD A,0
OR A
jr Z,PT3PAP0
LD E,A
LD BC,18
PT3bl0 INC D
CALL PT3putN
ADD IX,BC
DEC E
jr NZ,PT3bl0
JR PT3PAP0
PT3note
INC D
INC A
LD B,A
LD A,(IX)
AND #80
OR B
LD (IX),A
CALL PT3putN
CALL PT3cU
LD BC,18
ADD IX,BC
JR PT3blQ
PT3orn
;Fx,smp*2
RRCA
RRCA
RRCA
RRCA
LD (PT3orN),A
OR (IX+4)
LD (IX+4),A
LD A,#F
;LD (PT3typ),A
LD (IX+3),A
PT3oQ LD A,(HL)
INC HL
RLCA
RLCA
LD B,A
AND #80
LD (IX),A
LD A,B
RLA
OR (IX+3)
LD (IX+3),A
JP PT3PAP0
PT3smp
jr Z,PT3bl ;end of note
CP 16
jr C,$+6
SET 7,(IX)
AND #F
RLCA
RLCA
RLCA
RLCA
OR (IX+3)
LD (IX+3),A
JP PT3PAP0
PT3bl
INC D
CALL PT3putN
CALL PT3cU
LD BC,18 ;см. то же выше
ADD IX,BC
JP PT3blQ
PT3vol
jr Z,PT3res
OR (IX+4)
LD (IX+4),A
JP PT3PAP0
PT3res
LD A,(IX)
AND #80
OR 97
LD (IX),A
CALL PT3putN
CALL PT3cU
LD BC,18
ADD IX,BC ;см. то же выше
INC D
JP PT3blQ
PT3Et
jr NZ,PT3nEof
;B0=envoff
LD A,#F
;LD (PT3typ),A
OR (IX+3)
LD (IX+3),A
JP PT3eQ
PT3nEof DEC A
JP Z,PT3blN
;LD (PT3typ),A
LD B,A
LD A,(IX+3)
AND #F0
OR B
LD (IX+3),A
CALL PT3env
PT3orN=$+1
PT3eQ LD A,0
OR (IX+4)
LD (IX+4),A
JP PT3PAP0
PT3env
PUSH HL
PUSH IX
POP HL
PT3Edsp=$+1
LD BC,0
OR A
SBC HL,BC
LD B,H
LD C,L
POP HL
LD A,(HL)
INC HL
LD (BC),A
INC BC
LD A,(HL)
INC HL
LD (BC),A
RET
PT3newO
RLCA
RLCA
RLCA
RLCA
LD (PT3orN),A
LD B,A
jr NZ,PT3nXF0X
LD A,(IX+3)
AND #F
jr NZ,PT3nXF0X
LD A,(IX+3)
OR #F
LD (IX+3),A ;env off - см. выше такой же
PT3nXF0X
LD A,(IX+4)
AND #F
OR B
LD (IX+4),A
;PT3typ=$+1
;LD A,0
;OR (IX+3)
;LD (IX+3),A
JP PT3PAP0
PT3nois
LD (PT3n),A
JP PT3PAP0
;4
PT3putN
;LD A,0
;OR A
;RET Z
LD A,LX ;проверяем channel=B
RRA
RET C
LD (IX-6),0
PT3n=$-1
RET
PT3Etyp
jr NZ,PT3EnO
LD A,#F
;LD (PT3typ),A
OR (IX+3)
LD (IX+3),A
JR PT3EtyQ
PT3EnO ;LD (PT3typ),A
OR (IX+3)
LD (IX+3),A
CALL PT3env
PT3EtyQ LD A,(PT3orN)
OR (IX+4)
LD (IX+4),A
JP PT3oQ
PT3jp=$+1
PT3cU
CALL PT3ret
PUSH HL
LD HL,PT3ret
LD (PT3jp),HL
POP HL
PT3ret RET
PT3com
PUSH HL
DEC A
LD HL,PT3glis
jr Z,PT3cQ
DEC A
LD HL,PT3port
jr Z,PT3cQ
DEC A
LD HL,PT3so
jr Z,PT3cQ
DEC A
LD HL,PT3oo
jr Z,PT3cQ
DEC A
LD HL,PT3vib
jr Z,PT3cQ
IF gs
SUB 2
LD HL,PT3gs
jr Z,PT3cQ
DEC A
ELSE
SUB 3
ENDIF
LD HL,PT3egl
jr Z,$+5
LD HL,PT3tmp
PT3cQ LD (PT3jp),HL
POP HL
JP PT3PAP0
PT3tmp
LD A,(HL)
INC HL
LD (IX+1),#B0
LD (IX+2),A
RET
PT3port
LD A,(HL)
OR #30
LD (IX+1),A
INC HL
inc HL
inc HL
PUSH DE
LD E,(HL)
INC HL
LD D,(HL)
INC HL
ex de,hl
LD A,H
OR A
;JP P,$+6
CALL M,NEGHL
XIX2EPOP
ex de,hl
IF goodpak
LD (IX+2),E
POP DE
RET
ELSE
LD A,E
POP DE
IX2A LD (IX+2),A
RET
ENDIF
PT3so
LD A,(HL)
INC HL
LD (IX+1),#40
IF goodpak
LD (IX+2),A
RET
ELSE
JR IX2A
ENDIF
PT3oo
LD A,(HL)
INC HL
LD (IX+1),#50
IF goodpak
LD (IX+2),A
RET
ELSE
JR IX2A
ENDIF
PT3vib
LD A,(HL)
RRCA
RRCA
RRCA
RRCA
INC HL
OR (HL)
INC HL
LD (IX+1),#60
IF goodpak
LD (IX+2),A
RET
ELSE
JR IX2A
ENDIF
PT3glis
PUSH DE
LD A,(HL)
OR #10
LD C,A
INC HL
LD E,(HL)
INC HL
LD D,(HL)
INC HL
ex de,hl
;LD A,H
;OR A
LD (IX+1),C
BIT 7,H
jr Z,PT3gl1
;JP P,PT3gl1
CALL NEGHL
LD A,C
AND #F
OR #20
LD (IX+1),A
PT3gl1 ex de,hl
LD (IX+2),E
POP DE
RET
PT3egl
PUSH DE
LD A,(HL)
OR #90
LD C,A
INC HL
LD E,(HL)
INC HL
LD D,(HL)
INC HL
ex de,hl
;LD A,H
;OR A
LD (IX+1),C
BIT 7,H
jr Z,PT3egl9
;JP P,PT3egl9
CALL NEGHL
LD A,C
AND #F
OR #A0
LD (IX+1),A
PT3egl9
IF goodpak
ex de,hl
LD (IX+2),E
POP DE
RET
ELSE
JR XIX2EPOP
ENDIF
IF gs
PT3gs
LD A,(HL)
INC HL
OR #80
LD (IX+1),A
LD A,(HL)
INC HL
LD (IX+2),A
RET
ENDIF
PT2orn
RLCA
RLCA
RLCA
RLCA
LD (PT2orN),A
LD B,A
LD A,(IX+4)
AND #F
OR B
LD (IX+4),A
PT2typ=$+1
LD A,0
OR (IX+3)
LD (IX+3),A
JR PT2PAP0
PT2blN
LD (PT2bls),A
JR PT2PAP0
PT2vol
OR (IX+4)
LD (IX+4),A
JR PT2PAP0
PT2tmp
LD (IX+1),#B0
LD A,(HL)
JR IX2P2P
PT2port
LD (IX+1),#31
LD A,(HL)
INC HL
INC HL
OR A
JP P,IX2P2P
NEG
JR IX2P2P
PT2glis
LD (IX+1),#11
LD A,(HL)
BIT 7,A
jr Z,$+8
LD (IX+1),#21
NEG
IX2P2P LD (IX+2),A
INC HL
JR PT2PAP0
PT2PAPP
LD (PT2Edsp),A
ex de,hl
LD DE,ptmod
ADD HL,DE
XOR A
LD (PT2typ),A
LD (PT2orN),A
LD D,A
PT2PAP0 LD C,16
LD A,(HL)
INC HL
OR A
RET Z
ADD A,32
jr C,PT2smp
ADD A,96
jr C,PT2note
ADD A,C
JP C,PT2env
ADD A,C
jr C,PT2orn
ADD A,64
jr C,PT2blN
ADD A,C
jr C,PT2vol
INC A
jr Z,PT2tmp
INC A
jr Z,PT2glis
INC A
jr Z,PT2port
INC A
jr Z,PT2PAP0
LD A,(HL)
INC HL
PUSH HL
LD BC,(PT2Edsp)
DEC BC,BC
PUSH IX
POP HL
SBC HL,BC
PT2NOI LD (HL),A ;noise
LD BC,18
ADD HL,BC
LD BC,BUF+#480
SBC HL,BC
ADD HL,BC
jr C,PT2NOI
POP HL
JR PT2PAP0
PT2smp
jr Z,PT2res
CP 16
jr C,$+6
SET 7,(IX)
AND #F
RLCA
RLCA
RLCA
RLCA
OR (IX+3)
LD (IX+3),A
JR PT2PAP0
PT2res
LD A,96
PT2note INC A
LD B,A
LD A,(IX)
AND #80
OR B
LD (IX),A
PT2bl INC D
LD BC,18
ADD IX,BC
PT2bls=$+1
LD A,0
OR A
jr Z,PT2PAP0
INC D
ADD IX,BC
DEC A
jr NZ,$-4
JR PT2PAP0
PT2env
jr Z,PT2bl
CP #F
LD (PT2typ),A
jr NZ,PT2norn
OR (IX+3)
LD (IX+3),A
JR PT2eQ
PT2norn OR (IX+3)
LD (IX+3),A
PUSH HL
PUSH IX
POP HL
PT2Edsp=$+1
LD BC,0
OR A
SBC HL,BC
LD B,H
ld C,L
INC BC
POP HL
LD A,(HL)
INC HL
LD (BC),A
DEC BC
LD A,(HL)
INC HL
LD (BC),A
PT2orN=$+1
PT2eQ LD A,0
OR (IX+4)
LD (IX+4),A
JP PT2PAP0
PT3SMP
LD A,1
LD HL,lce8a+2
PT3SMP0 PUSH AF
CALL OUT7
LD E,(HL)
INC HL
LD D,(HL)
INC HL
EX (SP),HL
PUSH HL ;AF
LD A,E
OR D
jr Z,PT3SMPQ
LD HL,ptmod
ADD HL,DE
LD DE,BUF
PUSH DE
POP IX
LD B,2;BC,258
LDIR
POP AF
PUSH AF
ADD A,A
LD L,A
ld H,TSMPSZ/256
LD A,(IX)
ld (HL),A
INC L
LD B,(IX+1)
ld (HL),B
POP AF
PUSH AF
ADD A,SMPS/256
LD H,A
XOR A
LD L,A
CP B
jr Z,PT3SMPQ
CALL OUT4
PT3SMP1 LD A,(IX+2+2)
ld (HL),A
INC HL
LD A,(IX+3+2)
ld (HL),A
INC HL
LD A,(IX+0+2)
ld D,A
AND #3F
RRA ;SRL A
jr NC,$+4
OR #20
LD C,A
LD A,(IX+1+2)
ld E,A
AND #F
INC HL
LD (HL),A
LD A,D;(IX+0+2)
AND #C0
OR (HL)
LD (HL),A
LD A,E
AND #80
RRCA
OR C
LD C,A
LD A,E
AND #10
RLCA
RLCA
RLCA
OR C
DEC HL
LD (HL),A
INC HL
LD A,E
RRCA
AND #30
OR (HL)
LD (HL),A
INC HL
LD DE,4
ADD IX,DE
DJNZ PT3SMP1
PT3SMPQ POP AF
POP HL
INC A
AND 31
jr NZ,PT3SMP0
RET
PT2SMP
LD A,1
LD HL,_ce26
PT2SMP0 PUSH AF
CALL OUT7
LD E,(HL)
INC HL
LD D,(HL)
INC HL
EX (SP),HL
PUSH HL ;AF
LD A,E
OR D
jr Z,PT2SMPQ
LD HL,ptmod
ADD HL,DE
LD DE,BUF
PUSH DE
POP IX
LD B,2;BC,#C6
LDIR
POP AF
PUSH AF
ADD A,A
LD L,A
ld H,TSMPSZ/256
LD A,(IX+1)
ld (HL),A
INC L
LD B,(IX)
ld (HL),B
POP AF
PUSH AF
ADD A,SMPS/256
LD H,A
XOR A
LD L,A
CALL OUT4
PT2SMP1 LD A,(IX+0+2)
LD C,A
RRCA
RRCA
RRCA
AND 31
INC HL
inc HL
LD (HL),A
BIT 1,C;(IX+0+2)
jr Z,$+4
SET 7,(HL)
LD A,(IX+1+2)
;AND #F0
;RRCA
;RRCA
;RRCA
;RRCA
INC HL
LD (HL),A
XOR A
RRD
;LD A,(IX+1+2)
;AND #F
LD D,A ;(IX+1+2)�F
DEC HL
BIT 0,C;(IX+0+2)
jr Z,PT2SMPN
LD A,(HL)
OR #40
AND #E0
LD (HL),A
PT2SMPN LD E,(IX+2+2)
;LD A,(IX+1+2)
;AND #F
;LD H,A
BIT 2,C;(IX+0+2)
ex de,hl
CALL Z,NEGHL
ex de,hl
DEC HL,HL
LD (HL),E
INC HL
LD (HL),D
LD DE,3
ADD IX,DE
ADD HL,DE
DJNZ PT2SMP1
PT2SMPQ POP AF
POP HL
INC A
AND 31
jr NZ,PT2SMP0
RET
PT2ORN
LD HL,_ce66
SCF
JR PT23ORN
PT3ORN
LD HL,lceca+2
OR A
PT23ORN LD A,1
PT3ORN0 PUSH AF
CALL OUT7
LD E,(HL)
INC HL
LD D,(HL)
INC HL
EX (SP),HL
PUSH HL ;AF
LD A,D
OR E
jr Z,PT3ORNQ
LD HL,ptmod
ADD HL,DE
LD DE,BUF
PUSH DE
LD B,2;BC,66
LDIR
POP DE
POP AF
PUSH AF
CALL HLOR3
ex de,hl
LD C,A
ld B,TORNSZ/256
CALL OUT4
POP AF
PUSH AF
jr NC,PT3ORN3
INC L
LD A,(HL)
ld (BC),A
DEC L
LD A,(HL)
INC L
JR $+6
PT3ORN3 LD A,(HL)
ld (BC),A
INC L
LD A,(HL)
INC C
LD (BC),A
INC L
LD C,A
ld B,0
LDIR
PT3ORNQ POP AF
POP HL
INC A
BIT 4,A
jr Z,PT3ORN0
RET