AUTOS
LD HL,AUTO1
LD A,4
LD DE,0x0e08;#E0A
CALL EDTXT
AUTOSu LD HL,AUTO1
LD DE,AUTO2
LD A,(HL)
CP 'G'
jr C,AUT0s
CP 'W'
jr NC,AUT0s
SUB 'G'
OR #80
LD (DE),A
INC DE
inc HL
JR AUTO0-2
AUT0s CALL D0TO_
LD (DE),A
INC DE
inc HL
LD B,3
AUTO0 CALL D0TO_
LD (DE),A
INC DE
inc HL
DJNZ AUTO0
LD HL,AUTO1
LD DE,0x0e08;#E0A
LD B,4
JP PRTXADD
BYS
LD HL,TAUTHOR
ld DE,0x060b;D
JR $+8
TITLES
LD HL,TTITLE
ld DE,0x060a;C
LD A,#20
JP EDTXT
COPYSMP
CALL OUT4
SMP2=$+1
smp=$+2
LD BC,#101
LD A,B
ADD A,SMPS/256
LD H,A
SUB B
ADD A,C
LD D,A
PUSH BC
LD BC,256
LD L,C
ld E,C
LDIR
POP BC
LD A,B
ADD A,A
LD L,A
ld H,TSMPSZ/256
LD E,(HL)
INC L
LD D,(HL)
LD A,C
ADD A,A
LD L,A
LD (HL),E
INC L
LD (HL),D
JP PROK
DECSMP
LD A,31
JR $+4
INCSMP
LD A,1
ONCSMP LD HL,smp
LD DE,#2F06
LD B,A
ADD A,(HL)
AND 31
jr NZ,$+3
ADD A,B
LD (HL),A
CALL D2HEX
LD A,(digit)
ld (EDSMPN),A
RET
DECSMP2
LD A,31
JR $+4
INCSMP2
LD A,1
ONCSMP2 LD HL,SMP2
LD DE,#3906
LD B,A
ADD A,(HL)
AND 31
JR IORN2U
DECORN
LD A,15
JR $+4
INCORN
LD A,1
ONCORN LD HL,ORN
LD DE,#2F07
LD B,A
ADD A,(HL)
AND 15
jr NZ,$+3
ADD A,B
LD (HL),A
CALL D2HEX
digit=$+1
LD A,'1'
LD (EDORNN),A
RET
DECORN2
LD A,15
JR $+4
INCORN2
LD A,1
ONCORN2 LD HL,ORN2
LD DE,#3907
LD B,A
ADD A,(HL)
AND 15
IORN2U jr NZ,$+3
ADD A,B
LD (HL),A
JP D2HEX
COPYORN
CALL OUT4
CALL HLORN
LD D,A
PUSH HL
ORN2=$+1
LD A,0
CALL HLOR3
LD E,A
ex de,hl
EX (SP),HL
LD BC,64
LDIR
POP BC
LD L,B
ld H,TORNSZ/256
LD E,(HL)
INC L
LD D,(HL)
LD L,C
LD (HL),E
INC L
LD (HL),D
JP PROK
IF about
ABOUT
CALL PIANAY
LD BC,mABOUT
CALL WINDUM
LD HL,tABOUT
LD DE,0
CALL PRMENU
ABOUT0
CALL TSTFIRH
jr NC,ABOUT0
ld a,(focuslost)
or a
jr nz,ABOUT0
JP CLOSWIN
ENDIF
HOMEtra
XOR A
jr Z,ITRAQ
INCTRA
LD A,(transp)
INC A
ITRAQ LD C,0
JP P,$+7
NEG
LD C,-1
AND #3F
LD B,A
INC C
jr NZ,$+4
NEG
LD (transp),A
DEC C
LD A,'+'
jr Z,$+4
LD A,'-'
LD DE,0x1d09;#360D
CALL PRADD
LD A,B
INC D
JP toOO
DECTRA LD A,(transp)
DEC A
JR ITRAQ
pat1=$+1
INCPAT1 LD A,0
INC A
LD B,0
IPAT1Q CP PATS
jr C,$+3
LD A,B
iPATq LD (pat1),A
LD DE,0x4917;#4937 ;screen addr
JP PRF8
DECPAT1 LD A,(pat1)
LD B,PATS-1
DEC A
JR IPAT1Q
pat2=$+1
INCPAT2 LD A,0
INC A
LD B,0
IPAT2Q CP PATS
jr C,$+3
LD A,B
iPAT2q LD (pat2),A
LD DE,0x491c;#493C ;screen addr
JP PRF8
DECPAT2 LD A,(pat2)
LD B,PATS-1
DEC A
JR IPAT2Q
HOMEcop
XOR A
LD (beg1),A
CALL IBEGq
XOR A
LD (beg2),A
CALL IBEG2q
LD A,63
JR IENDQ
ENDcur
LD A,(CURY)
JR IENDQ
INCEND
LD A,(fromEND)
INC A
IENDQ AND 63
LD (fromEND),A
LD DE,0x2e0b;#2E0C
JP toOO
DECEND
LD A,(fromEND)
DEC A
JR IENDQ
PLSONG
POS=$+1
LD DE,TPOSS
LD A,(DE)
ld (EPAT),A
LD E,A
INC D
LD A,(DE)
ld (PATLEN),A
LD A,-1
PLPaSo LD HL,ESNGon
LD B,(HL)
PUSH BC
push HL
LD (HL),A
CALL PATFON ;для PLPAT не надо,но можно
CALL PRPAT
LD HL,PLEXT
ld (PLJP),HL
CALL INICHAN
IF pttfc
LD A,pttfc
CALL OUTME
LD HL,tfmmuz
CALL tfmini
CALL tfm ;первый фрейм пуст
LD A,1
LD (tfcplayon),A
ENDIF
CALL PLAYER
IF pttfc
XOR A
LD (tfcplayon),A
LD A,pttfc
CALL OUTME
CALL tfmshut
ENDIF
POP HL,BC
LD (HL),B
RET
PLPAT
XOR A
JR PLPaSo
;1(PRPAT)
INITPLY
LD A,#F
LD (Avol),A
LD (Bvol),A
LD (Cvol),A
cpl;LD A,#F0
LD (Avol2),A
LD (Bvol2),A
LD (Cvol2),A
LD HL,ORNS
LD (Aorn),HL
LD (Born),HL
LD (Corn),HL
IF ts
LD HL,ayblock
LD DE,ayblock2
LD BC,szayblock
LDIR
ENDIF
;3(EPENT,PLPAT,PLSONG)
INICHAN LD A,-1
LD (Achan),A
LD (Bchan),A
LD (Cchan),A
IF ts
LD (Achan+szayblock),A
LD (Bchan+szayblock),A
LD (Cchan+szayblock),A
ENDIF
RET
PATLENS
LD A,(PATLEN)
CALL FILLENS
CALL PROK
PRPAT
XOR A
LD (CURY),A
PRPATU
CALL PIANAY
CALL INITPLY
PRPATUU
CALL CHKTS ;3.7
LD A,(CURY)
LD HL,PATLEN
CP (HL)
jr C,$+3
LD A,(HL)
LD (CURY),A
PUSH AF
CALL PRCU7
LD A,(POS)
ex af,af'
LD HL,(EPAT)
LD B,L
LD H,TPATSZ/256
LD C,(HL) ;0..63
POP AF ;line#
patSUB=$+1
LD E,PATTOPLINES;4 ;5 для UPROLL
IF 1 ;см IFN ниже
SUB E
jr NC,$+3
ADC A,C
ELSE
;глючит печать 0-й позиции, т.к.идем на посл.поз., потом на LOOP
;а надо на 0-ю
;т.е. на средней строке надо вспоминать тек.позицию
PRPATu0
DEC A
JP P,PRPATuY
LD A,(ESNGon)
OR A
jr Z,PRPATuP
PUSH DE
ex af,af' ;A=pos
CALL ROLprPO ;будет A'=pos
LD B,E ;pat ;глючит при ssQ!!!???
LD A,(DE) ;patsz
LD C,A ;0..63
POP DE
PRPATuP LD A,C
PRPATuY DEC E
jr NZ,PRPATu0
ENDIF
;A=line#
;B=pat
INC C
;C=patsz 1..64
ex af,af'
LD D,A
ex af,af'
;D=POS
;patHGT=$+1
LD L,PATVIEWLINES;9
LD E,PATTOPLINE;#F
PRPAT0 PUSH HL
push DE
CALL STROKA
POP DE
INC E
inc A
POP HL
CP C
jr NZ,PRPATNE
LD A,(ESNGon)
INC A
jr NZ,PRPATE
IF 1 ;см IFN выше
LD A,E
CP #14
jr C,PRPATE
ENDIF
LD B,E
LD A,D
CALL GETnPAA
LD D,E
LD E,B
LD B,A
LD A,L
LD L,B
LD H,TPATSZ/256
LD C,(HL)
INC C
LD L,A
PRPATE XOR A
PRPATNE
DEC L
jr NZ,PRPAT0
CALL FILLATR
JP PLREAD
CLPATS
XOR A
CLPATS0 PUSH AF
CALL CLPAT
POP AF
INC A
CP PATS
jr NZ,CLPATS0
RET
EDSONGCS
CALL cs_8026
JP NC,ONOFFTS
EDSONG
CALL MELINV
LD HL,ESNGon
LD A,(HL)
CPL
LD (HL),A
LD A,(POS)
LD E,A
ld D,TPOSS/256
LD A,(DE)
ld (EPAT),A
LD E,A
INC D
LD A,(DE)
ld (PATLEN),A
CALL PATFON
CALL PRPATU
LD A,(editON)
OR A ;0=не редактируем
RET NZ ;редактируем
JP EDPATu ;включаем редактирование
curfla=$+1
FLACUR LD A,1
DEC A
RET NZ
PRCUR
ld a,(focuslost)
or a
jr nz,PRCURnoflash
curon=$+1
LD A,0
CPL
LD (curon),A
PRCURnoflash
LD A,(CURX)
CP 6
jr Z,CUR2
CP 11+4
jr Z,CUR2
CP 16+8
jr Z,CUR2
LD HL,TEDCURX
ADD A,L
LD L,A
LD A,(HL)
lineX=$+1
ADD A,0
SRL A
LD C,#F0
jr NC,$+4
LD C,#F
LD D,A
ld E,#13
CALL DE2SCR
LD B,8
LD A,(HL)
XOR C
LD (HL),A
INC H
DJNZ $-4
CURQ LD A,6
RET
CUR2 LD HL,TEDCURX
ADD A,L
LD L,A
LD A,(HL)
RRA
LD D,A
ld E,#13
CALL DE2SCR
LD BC,#8F0
cUR3 LD A,(HL)
CPL
LD (HL),A
INC L
LD A,(HL)
XOR C
LD (HL),A
DEC L
INC H
DJNZ cUR3
JR CURQ
PRCU7 LD A,(curon)
OR A
RET Z
JR PRCUR
EDPATQ CALL JPITEM
;LD A,#6F
;LD (DOWNM),A
call DOWNMER
JR EDPAT0
INCROLL
roll=$+1
LD A,0
INC A
CP 9
jr C,$+3
XOR A
IROLQ LD (roll),A
LD DE,0x3900;#D09
JP PRBCD ;edit step
if 1==0
DECROLL LD A,(roll)
DEC A
JP P,IROLQ
LD A,8
JR IROLQ
endif
EPss LD A,C
JR IROLQ
EPDOWN
CALL PRCU7
LD L,1
CALL ROLLPATFON
EPDQ JP SHOLK
if 1==0
EPEXT
CALL PRCU7
XOR A
LD (editON),A
LD HL,ESNGon
CP (HL)
LD (HL),A
CALL NZ,MELINV
POP AF
JP WAITNOK
endif
EPUP
CALL PRCU7
LD L,1
CALL UPROLL
JR EPDQ
;3(ini,NLOOP,MENUUSE)
EDPAT
editON=$+1
LD A,0
OR A
;если не редактировали(0), то входим на EDPATu
jr Z,EDPATu
;иначе
;если был EDSONG, то на EDSONG
LD A,(ESNGon)
INC A
JP Z,EDSONG
RET
EDPATu LD A,-1
LD (editON),A
XOR A
LD (CURY),A
CALL PRPAT
EDPAT0
CALL RESHALT
CALL FLACUR
LD HL,EDPATQ
PUSH HL
LD (curfla),A
CALL BIT5
RET Z
LD HL,tSS
LD BC,9
CPIR
jr Z,EPss
CP kW;'W'
JP Z,EDSONGCS
IF bemol
CP kBEM
JP Z,EPbem
ENDIF
CP kssA
JP Z,SSA
CP kssR
JP Z,EPssr
CP kIns
JP Z,EPins
CP kssE
JP Z,EPsse
CP kDelLn
JP Z,EPdelln
CP kHom
jr Z,EPHOME
CP kEnd
jr Z,EPEND
IF tab
CP kTab
JP Z,JCUR
CP kTabL
JP Z,JCURL
ENDIF
IF ts
CP kChip
JP Z,SWPSONG
ENDIF
CP kSmp
JP Z,EDSMP
CP kOrn
JP Z,EDORN
cp key_pgup;SUB 4
JP Z,DECPOSU
cp key_pgdown;DEC A
JP Z,INCPOSU
cp key_left;SUB 3
jr Z,LCUR
cp key_right;DEC A
jr Z,RCUR
cp key_down;DEC A
JP Z,EPDOWN
cp key_up;DEC A
JP Z,EPUP
;DEC A
;dec A
cp key_enter
JP Z,EPENT
;cp key_tab;DEC A ;???
;JP Z,EPEXT
;CALL cs_8026
;jr C,NCAPCOM
LD A,(iycurkey);(23560)
CP kAON
JP Z,AUTOON
CP kEON
JP Z,ENVON
CP kTRA
JP Z,TRANSP
CP kBEG
JP Z,BEGcur
CP kEND
JP Z,ENDcur
CP kCOP
JP Z,COPcur
CP kORD
JP Z,POSEDIT
NCAPCOM CALL TSTNOTE
CALL XPPSCF
JP Z,TSTOCT
RET
EPHOME
XOR A
LD HL,CURY
CP (HL)
jr NZ,ePGQ
DEC H
EPEND
LD HL,(EPAT)
LD H,TPATSZ/256
LD A,(HL)
jr Z,$+4
INC A
RRA
ePGQ LD (CURY),A
JP PRPATU
LCUR
CALL PRCU7
CURX=$+1
LD A,6
DEC A
JP P,LCURQM3
LD A,20+12
JP LCURQM3
RCUR
CALL PRCU7
LD A,(CURX)
INC A
CP 21+12
jr C,$+3
XOR A
LCURQM3 LD (CURX),A
LCURQ CALL PRCUR
JP SHOLK
EPENT
playon=$+1
LD A,-1
OR A
JP NZ,EPENTi
LD A,(CURX)
CP 6
jr Z,EPENTi
CP 11
jr Z,EPENTi
CP 16
JP NZ,PLNOTE
EPENTi LD A,(NOTENV)
LD (env),A
LD HL,PLCANC
LD (PLJP),HL
CALL INICHAN
JP PLAYER
IF tab
JCUR
CALL PRCU7
LD BC,TJP
JR JCUROK
JCURL
CALL PRCU7
LD BC,TJPLEFT
JCUROK LD HL,(CURX)
ld H,0
ADD HL,BC
LD A,(HL)
JP LCURQM3
ENDIF
ROLLPATFON
CALL ROLL
JP PATFON
;3
ROLL
;L=на сколько строк (для autoscroll)
PUSH HL
CALL PRCU7
ROLnRE LD A,(EPAT)
LD (nPAT),A
POP HL
ROL0
;идем на строчку вниз
LD A,(PATLEN)
INC A
LD C,A
LD A,(CURY)
INC A
CP C
jr NZ,ROLNZ
LD A,(ESNGon)
OR A
CALL NZ,ROLnxPO ;C тоже корректируется
XOR A
ROLNZ LD (CURY),A
;ищем +4-ю строчку
ex af,af'
LD A,(POS)
ex af,af'
LD B,PATBOTTOMLINES;4
ROLnx0 INC A
CP C ;patsz=1..64
jr NZ,ROLnx4
ESNGon=$+1
LD A,0
OR A
jr Z,ROLnxY
ex af,af'
CALL GETnPAA;T ;(DE)->A->(nPAT)
ex af,af'
LD A,E
ex af,af'
LD E,A
INC D ;TPATSZ
LD A,(DE)
INC A
LD C,A
ROLnxY XOR A
ROLnx4 DJNZ ROLnx0
;печатаем +4-ю строчку
PUSH HL
CALL scrolST ;DI;не портит регистры
LD HL,(POS)
PUSH HL
ex af,af'
LD (POS),A
ex af,af'
nPAT=$+1
LD B,0
LD E,#17
CALL STROKA ;A=line#,E=scrY
POP HL
LD (POS),HL
POP HL
DEC L
jr NZ,ROL0
rOLQ
JP FILLATR ;DI..EI ;3200t
;JP PATFON ;3000t
UPROLL
CALL PRCU7
PATLEN=$+1
UPRnRE LD C,63
LD A,(CURY)
DEC A
CP C
jr C,UPRNZ
LD A,(ESNGon)
OR A
jr NZ,UPRnxPO
LD A,C
UPRNZ LD (CURY),A
LD B,PATTOPLINES;4
UPRnx4 DEC A
CP C
jr C,$+3
LD A,C
DJNZ UPRnx4
LD E,PATTOPLINE;#F
LD BC,(EPAT-1)
CALL scrol2 ;не портит регистры,не DI
CALL STROKA
uPRQ JR rOLQ
UPRnxPO
PUSH AF
LD A,(POS)
CALL ROLprPO
LD (EPAT),A
ex af,af'
LD (POS),A
POP AF
RET C;pgUp
LD A,(DE)
LD (PATLEN),A
LD (CURY),A
; PUSH AF ;!
;LD A,PATBOTTOMLINES;5
;LD (patHGT),A
;LD (patSUB),A
;CALL scrol2 ;не портит регистры,не DI
CALL PRPATU ;PRPAT
CALL POSFON ;3+699
; POP AF
; LD (CURY),A
;LD A,PATTOPLINES;4
;ld (patSUB),A
;LD A,PATVIEWLINES
;ld (patHGT),A
JR uPRQ
PLAYER
IF hidearr
LD A,1
LD (ARROWt),A
ENDIF
LD A,18
ld (options),A
LD A,(TEMPO)
LD (temp1),A
LD (tempCNT),A
XOR A
LD (Acom),A
LD (Bcom),A
LD (Ccom),A
CALL PLREAD
IF ts
;5
tson=$+1
LD A,0
OR A
jr Z,PLnots1
;LD A,#FE
CALL SWPAYPP
XOR A
LD (Acom),A
LD (Bcom),A
LD (Ccom),A
CALL PLREAD
;LD A,#FF
CALL SWPAYPP
PLnots1
ENDIF
CALL ARROW ;1700
LD A,(temp1)
LD (tempCNT),A ;иначе игнорит темп на line0
PLAYER0
IF shadplay
LD A,#C9
LD (scrolST),A
ENDIF
LD A,(tempCNT)
DEC A
LD L,1
CALL Z,ROLL ;35500
IF shadplay
LD A,#F3
LD (scrolST),A
ENDIF
CALL HALTnAR ;10000
CALL JPITEM ;стрелка выкл.
CALL PATFON ;3000
;при вых.после перекл.POS будет READ,ROLL
CALL ARROW ;1700
CALL OUT4 ;100
CALL PLnOUT ;5400
IF ts
LD A,(tson)
OR A
jr Z,PLnots2
LD A,(tempCNT)
DEC A
CALL Z,PLREAD ;2100
;LD A,#FE
CALL SWPAYPP ;7700;6881
CALL OUT4 ;100
CALL PLnOUT ;5400
PLnots2
ENDIF
tempCNT=$+1
LD A,0
DEC A
jr NZ,PLnoNL
CALL PLREAD ;2100
temp1=$+1
LD A,0
PLnoNL LD (tempCNT),A
IF ts
LD A,(tson)
OR A
;LD A,#FF
CALL NZ,SWPAYPP;7700;6881
ENDIF
;CALL RE ;1000
;CALL JPITEM
IF pttfc
tfcplayon=$+1
LD A,0
OR A
jr Z,tfcplayno
LD A,pttfc
CALL OUTME
CALL tfm
tfcplayno
ENDIF
PLJP=$+1
JP PLCANC ;or PLEXT (ed.song)
PLCANC
CALL CANCEL
jr NC,PLAYER0
JR PLQ
PLEXT
CALL CANCEL2
jr NC,PLQ
;CALL cs_8026
;jr C,PLAYER0
;CALL cs_8020
;RRA
;jr C,PLAYER0
CALL BIT5
jr z,PLAYER0
cp key_esc
jr nz,PLAYER0
PLQ LD A,mains
LD (options),A
CALL RE ;1000
CALL PIAN2AY
IF shadplay
CALL PRPATU
ENDIF
JP WAITNOK
PLREAD
LD A,(CURY)
ld C,A
LD A,(EPAT)
ld B,A
CALL GETnADR
LD A,(HL)
ld (ENV+1),A
INC HL
LD A,(HL)
ld (ENV),A
INC HL
LD A,(HL)
ld (DNOIS),A
INC HL
PUSH HL
POP IX
LD IY,Achan
CALL USEchan
LD IY,Bchan
;LD BC,5
;ADD IX,BC
CALL plreadadd5usechan;USEchan
LD IY,Cchan
plreadadd5usechan
LD BC,5
ADD IX,BC
jp USEchan
;LD IY,23610
;RET
USEchan
LD C,(IX+3)
LD A,(IX)
AND #7F
DEC A
JP M,USEbl
CP 96
jr NZ,USEnR
LD (IY+#E),0
LD A,-1
JR uSEnNOT
USEnR LD B,(IY+#B)
LD (IY+#B),A
LD (IY+#12),B
XOR A
LD (IY+#1C),A
LD (IY+#18),A
LD (IY+#19),A ;
LD (IY+#1A),A ;shift
LD (IY+#1B),A
LD (IY+#E),A
LD L,(IY+#13)
LD H,(IY+#14)
LD (usedisp),HL
LD (IY+#13),A
LD (IY+#14),A
LD (IY+4),A
LD (IY+9),A
uSEnNOT LD (IY),A
LD A,(IX)
RLA
LD A,C
RRA
RRA
RRA
RRA
AND 31
jr Z,USEbl
LD L,A
ADD HL,HL
LD H,TSMPSZ/256
LD B,(HL)
LD (IY+#A),B
INC L
LD B,(HL)
LD (IY+8),B
LD (IY+6),0
ADD A,SMPS/256
LD (IY+7),A
USEbl LD A,C
LD B,#F
AND B
LD C,A
;FX:B=F
;?X:B=1F
;0X:не менять
jr Z,USE0x
;JZ USEoldE
CP B
jr Z,USEnE
LD (NOTENV),A
LD (env),A
XOR A
LD L,A
ld H,A
LD (Efrq),HL
LD (EstCNT),A
LD HL,(ENV)
ld (BASENV),HL
LD B,31
USEnE
LD (IY+#D),B ;vol|envmask
USE0x
LD A,(IX+4)
AND #F0
CP C
jr Z,USEoldE
RRCA
RRCA
RRCA
RRCA
CALL HLOR3
LD (IY+4),0
LD (IY+1),L
LD (IY+2),H
LD L,A
ld H,TORNSZ/256
LD A,(HL)
ld (IY+5),A
INC L
LD A,(HL)
ld (IY+3),A
USEoldE LD A,(IX+4)
AND #F
jr Z,USEnV
ADD A,A
add A,A
add A,A
add A,A
LD (IY+#C),A
USEnV LD A,(IX+1)
AND #F0
RET Z
LD C,16
SUB C
jr Z,dncom
SUB C
jr Z,upcom
SUB C
jr Z,portcom
SUB C
jr Z,smpcom
SUB C
jr Z,orncom
SUB C
JP Z,vibcom
SUB C
RET Z
SUB C
IF gs
JP Z,gscom ;"8snn"
ELSE
RET Z
ENDIF
SUB C
JP Z,edcom
SUB C
JP Z,eucom
SUB C
RET NZ
LD A,(IX+2)
CP 1
RET C
;LD (tempCNT),A ;v3+698
LD (temp1),A
RET
upcom
LD A,(IX+1)
AND #F
upcomQ LD (IY+#F),A ;delay
LD (IY+#E),1 ;com.type
LD (IY+#10),A ;count
IF fixtoENV
PUSH AF
ENDIF
LD L,(IX+2)
LD H,0
CALL NC,NEGHL
LD (IY+#11),L
LD (IY+#15),H
IF fixtoENV
POP AF
RET NZ
OR H
or L
RET Z ;3!699(глючили 1000,2000)
LD (IY+#13),L
LD (IY+#14),H
ENDIF
RET
dncom
LD A,(IX+1)
AND #F
SCF
JR upcomQ
smpcom
LD A,(IX+2)
ld (IY+9),A
RET
orncom
LD A,(IX+2)
ld (IY+4),A
RET
vibcom
LD (IY+#E),3
LD A,(IX+2)
ld B,A
AND #F
LD (IY+#17),A
LD A,B
AND #F0
RRCA
RRCA
RRCA
RRCA
LD (IY+#16),A
LD (IY+#10),A
RET
portcom
LD A,(IX)
AND #7F
DEC A
CP 96
RET NC
LD A,(IX+1)
AND #F
LD (IY+#F),A
LD (IY+#10),A
LD A,(IX+2)
LD (IY+#11),A
LD (IY+#15),0
LD (IY+#E),2
LD A,(IY+#12)
ld C,A
LD HL,FrTab
ADD A,A
ADD A,L
LD L,A
LD E,(HL)
INC L
LD D,(HL)
PUSH DE
LD HL,(usedisp)
LD (IY+#13),L
LD (IY+#14),H
ADD HL,DE
ex de,hl
LD A,(IY+#B)
LD (IY+#12),A
LD (IY+#B),C
LD HL,FrTab
ADD A,A
ADD A,L
LD L,A
LD A,(HL)
INC L
LD H,(HL)
ld L,A
PUSH HL
;OR A
SBC HL,DE
POP HL
POP DE
jr NC,portUP
ex de,hl
PUSH HL
LD L,(IY+#11)
LD H,(IY+#15)
CALL NEGHL
LD (IY+#11),L
LD (IY+#15),H
POP HL
portUP OR A
SBC HL,DE
LD (IY+#16),L
LD (IY+#17),H
RET
edcom
LD A,(IX+1)
AND #F
LD (EstCNT),A
LD (EiniCNT),A
LD L,(IX+2)
ld H,0
LD (Estep),HL
RET
eucom
CALL edcom
CALL NEGHL
LD (Estep),HL
RET
IF gs
gscom
;"8snn"
LD A,(IX+1)
AND #F ;smp
OUT (GSDAT),A
;SC #39
;WC
;SC #80
LD A,LY
SUB Achan&0xff
jr Z,$+9
SUB Bchan-Achan
jr Z,$+4
LD A,1
INC A
ADD A,#98 ;play FX
OUT (GSCOM),A
WC
LD A,(IX+2)
OUT (GSDAT),A ;note
WD
SD #40 ;vol
WD
RET
ENDIF
;2:TSTNQ,EPENT(nu)
PLNOTE
IF ts
LD A,(tson)
OR A
jr Z,PLnotsP
;LD A,#FE
CALL SWPAYPP
CALL PLNOTPP
;LD A,#FF
CALL SWPAYPP
PLnotsP
ENDIF
CALL PLNOTPP
PLNOTE0 CALL HALTER
CALL OUT4
IF ts
LD A,(tson)
OR A
jr Z,PLnotsP2
;LD A,#FE
CALL SWPAYPP
CALL PLnOUT
;LD A,#FF
CALL SWPAYPP
PLnotsP2
ENDIF
CALL PLnOUT
call isnotepressed ;NZ=pressed
jr NZ,PLNOTE0 ;нажато что-то (кроме CS,SS,Space) - держим ноту
PIAN2AY
IF ts
LD A,(tson)
OR A
JP Z,PIANAY
;LD A,#FE
CALL SWPAYPP
CALL PIANAY
;LD A,#FF
CALL SWPAYPP
ENDIF
JP PIANAY
;2 тут
PLNOTPP
LD A,(NOTENV)
LD (env),A
XOR A
LD (Acom),A
LD (Bcom),A
LD (Ccom),A
CPL
LD (Achan),A
LD (Bchan),A
LD (Cchan),A
JP PLREAD
FILLATR
;EI
;RET
DI
LD HL,LINESon
LD A,(PATLEN)
LD C,A
INC C
LD DE,#FF00 ;;;
LD A,(CURY)
LD B,PATTOPLINES;4
SUB B
FATR0 OR A
JP P,FATR0Q
LD (HL),D
INC HL
INC A
DJNZ FATR0
JR FATR1Q
FATR0Q LD (HL),E
INC HL
DJNZ $-2
FATR1Q INC HL
LD B,PATBOTTOMLINES;4
LD A,(CURY)
FATR2 INC A
CP C
jr Z,FATR2Q
LD (HL),E
INC HL
DJNZ FATR2
JR FATR3Q
FATR2Q LD (HL),D
INC HL
DJNZ $-2
FATR3Q LD (FATRSP),SP
LD IX,PATVIEWTOPATTR;#59FF
LD IY,LINESon
LD A,PATVIEWLINES;9
FATRFIL ex af,af'
col1=$+1
LD HL,#606
col2=$+1
LD DE,#707
LD BC,#744
LD A,(IY)
CP #7F
jr Z,FATRNO
OR A
jr Z,FATRPUS
LD HL,0
LD D,L
ld E,L
LD C,L
FATRPUS LD SP,IX
PUSH HL
DEC SP
PUSH HL,HL
DEC SP
PUSH HL
DEC SP
PUSH HL,HL
DEC SP
PUSH HL
DEC SP
PUSH HL,HL
DEC SP
PUSH DE,HL
DEC SP
PUSH BC
FATRNO INC IY
LD BC,32
ADD IX,BC
ex af,af'
DEC A
jr NZ,FATRFIL
FATRSP=$+1
LD SP,0
;LD IY,23610
EI
RET
PLnOUT
XOR A
LD (mix),A
LD IY,Achan
LD A,(IY)
INC A
jr Z,PLnAres
CALL iSMPORN
LD DE,(Adfrq)
ADD HL,DE
LD (frqA),HL
CALL ADDVOL
LD A,B
CALL GLOVOL1
PLoffA=$+1
AND -1
PLnAres LD (volA),A
CALL PLcoms
LD IY,Bchan
LD A,(IY)
INC A
jr Z,PLnBres
CALL iSMPORN
LD DE,(Bdfrq)
ADD HL,DE
LD (frqB),HL
CALL ADDVOL
RLC B
CALL GLOVOL
PLoffB=$+1
AND -1
PLnBres LD (volB),A
CALL PLcoms
LD IY,Cchan
LD A,(IY)
INC A
jr Z,PLnCres
CALL iSMPORN
LD DE,(Cdfrq)
ADD HL,DE
LD (frqC),HL
CALL ADDVOL
RLC B
rlc B
CALL GLOVOL
PLoffC=$+1
AND -1
PLnCres LD (volC),A
CALL PLcoms
LD HL,(BASENV)
LD A,(Edfrq)
ADD A,L
LD L,A
LD DE,(Efrq)
ADD HL,DE
LD (frqE),HL
LD A,(EstCNT)
DEC A
JP M,EstOFF
jr NZ,EstNZ
LD HL,(Estep)
ADD HL,DE
LD (Efrq),HL
LD A,(EiniCNT)
EstNZ LD (EstCNT),A
EstOFF XOR A
LD (Edfrq),A
;LD IY,23610
JP OUTAY
GLOVOL
LD A,(mix)
OR B
GLOVOL1 LD (mix),A
LD H,TVOL/256
ld L,(IY+#C)
ADD HL,DE
LD E,(HL)
glovol=$+1
LD L,#F0
ADD HL,DE
LD A,(HL)
OR C
AND (IY+#D)
RET
PLcoms LD A,(IY+#E)
DEC A
RET M
jr NZ,PLcomNG
DEC (IY+#10)
RET NZ
PLcomG LD A,(IY+#F)
ld (IY+#10),A
LD L,(IY+#13)
LD H,(IY+#14)
LD E,(IY+#11)
LD D,(IY+#15)
ADD HL,DE
LD (IY+#13),L
LD (IY+#14),H
RET
PLcomNG DEC A
jr NZ,PLcomNP
DEC (IY+#10)
RET NZ
CALL PLcomG
LD A,D
ex de,hl
LD L,(IY+#16)
LD H,(IY+#17)
RLA
jr NC,PLportA
ADD HL,DE
add HL,DE
PLportA SBC HL,DE
INC H
RET NZ
LD A,(IY+#12)
ld (IY+#B),A
XOR A
LD (IY+#E),A
LD (IY+#13),A
LD (IY+#14),A
RET
PLcomNP DEC A
RET NZ
DEC (IY+#10)
RET NZ
LD A,(IY)
XOR -1
LD (IY),A
LD A,(IY+#16)
jr Z,$+5
LD A,(IY+#17)
LD (IY+#10),A
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
COPcur
LD A,(CURY)
ld (beg2),A
XOR A
CALL IBEG2q
LD A,(EPAT)
CALL iPAT2q
CALL XPP2
LD A,C
CALL ICHN2Q
LD HL,TSTNROL
PUSH HL
COPY
CALL FROMSZ
LD DE,(pat2)
ld D,A
LD HL,(beg1)
beg2=$+1
LD H,0
CALL CHN1PP
chn2=$+1
LD A,1
LD B,3
DEC A
jr Z,COP2X
LD B,8
DEC A
jr Z,$+4
LD B,13
COP2X LD A,(pat1)
IF opcompl
SCF
ENDIF
COPYU
;A=patfrom
;D=lines
;E=patto
;B=chnto(3/8/13)
;C=chnfrom
;H=lineto
;L=linefrom
IF opcompl
PUSH AF
ENDIF
PUSH DE
push DE
push HL
PUSH BC
CALL PATtoBUF ;делает OUT7
POP BC
LD A,C
ADD A,3
LD (DISPc1),A
LD A,B
INC A
LD (DISPc2),A
POP HL
LD A,H
ADD HL,HL
LD H,TLINES/256
LD E,(HL)
INC L
LD D,(HL)
LD HL,BUF
ADD HL,DE
LD E,C
ld D,0
LD C,A
LD A,(chnall)
OR A
jr NZ,noall1
ADD HL,DE
noall1
EX (SP),HL
LD A,L
CALL AtoPAT ;DE
LD L,C
ADD HL,HL
LD H,TLINES/256
LD A,(HL)
INC L
LD H,(HL)
ld L,A
ADD HL,DE
LD A,(chnall)
OR A
jr NZ,noall2
LD E,B
ld D,0
ADD HL,DE
noall2
LD A,64
SUB C
POP DE
ex de,hl
LD C,A
POP AF
CP C
jr C,$+3
LD A,C
chnall=$+1
LD C,0 ;не0=все каналы
INC C
DEC C
jr Z,COPSCF
;копирование всех каналов
COPYAL0 LD BC,18
LDIR
DEC A
jr NZ,COPYAL0
JR COPYALQ
;копирование 1 канала
;1
COPSCF SCF ;NC=9 on
COPY0
PUSH HL
push DE
jr C,COPyN
ex af,af'
LD A,(HL)
AND #7F
jr Z,COPnN
COPyN PUSH DE
push HL
LDI
INC HL
inc DE
INC HL
inc DE
LDI
LDI
POP HL
pop DE
COPnN
INC HL
inc DE
jr C,COPyC
LD A,(HL)
AND #F0
jr Z,COPnC
ex af,af'
COPyC ex af,af'
LDI
LDD
COPnC
INC HL
inc HL
LD A,(HL)
AND #F
jr Z,COPnE
XOR #F
jr Z,COPnE
DISPc2=$+1
LD BC,0
ex de,hl
SBC HL,BC
ex de,hl
DISPc1=$+1
LD C,0
SBC HL,BC
LDI
LDI
COPnE
POP HL
LD BC,18;B портится
ADD HL,BC
ex de,hl
POP HL
ADD HL,BC
ex af,af'
DEC A
jr NZ,COPY0
COPYALQ
IF opcompl
POP AF
CALL C,PROK
ENDIF
COPQJP
JP PRPATU
FROMSZ
fromEND=$+1
LD A,63
beg1=$+1
LD C,0
SUB C
INC A
RET NC
POP AF
IF opcompl
PRERR LD HL,TERROR
JR PROKU
ELSE
RET
ENDIF
;5
PROK
IF opcompl
LD HL,TCOMPLE
PROKU
LD (PROKHL),HL
ENDIF
LD BC,mOK
CALL WINDUM
PROKHL=$+1
LD HL,TCOMPLE
LD DE,0
CALL PRMENU
CALL DOWNMER
CALL WAITNOK
YIELD;HALT
XOR A
CALL checkmarginkeys ;a=0 ;out: NC=pressed
jr C,$-5
JP CLOSWIN
CLEARS
XOR A
LD (patcled),A
LD HL,CLEACOO
LD DE,CLEAUSE
LD BC,mCLEAR
CALL WINDOW
LD HL,tCLEAR
LD DE,0
CALL PRMENU
CLELOOP
CALL HALTER
CALL JPITEM
CALL TSTFIRE
jr NC,CLELOOP
CLEARSQ CALL CLOSWIN
CALL POSFON
patcled=$+1
LD A,0
OR A
CALL NZ,PRPAT
RET
clPAT
CALL SURE
DEC A
jr Z,clPATS
LD A,(EPAT)
CALL CLPAT
LD A,-1
LD (patcled),A
JR clQ
clSONG CALL SURE
CALL CLORNSM
clPATS CALL CLPATS
CALL CLPOS
XOR A
LD (LOOP),A
LD (POS),A
LD (EPAT),A
INC A
LD (LENG),A
LD A,63
;LD BC,PATS-1
;LD DE,TPATSZ+1
;LD H,D,L,B
;LD (HL),A
;LDIR
CALL FILLENS
LD (patcled),A
LD (PATLEN),A
clQ POP HL
JR CLEARSQ
clPOS CALL SURE
CALL CLPOS
XOR A
LD (LOOP),A
JR clQ
clSMP CALL SURE
DEC A
CALL Z,CLSMPS
LD A,(smp)
CALL CLSMP
JR clQ
clORN CALL SURE
DEC A
CALL Z,CLORNS
LD A,(ORN)
CALL CLORN
JR clQ
SURE LD HL,SURECOO
LD DE,SUREUSE
LD BC,mSURE
CALL WINDOW
LD HL,tSURE
LD DE,0
CALL PRMENU
SURE0
CALL HALTER
CALL JPITEM
CALL TSTFIRE
jr NC,SURE0
LD C,1
SUREQ CALL CLOSWIN
LD A,C
DEC A
RET NZ
POP AF
JP clQ
YES
LD A,(ITEM)
DEC A
LD C,A
POP HL
JR SUREQ
TRANSP
CALL TransPP
TRNS0 LD A,(HL)
AND #80
LD D,A
XOR (HL)
jr Z,TRNSNO
CP 97
jr Z,TRNSNO
DEC A
ADD A,C
CP 96
jr C,$+3
SUB C
INC A
TRNSNO OR D
LD (HL),A
LD DE,18
ADD HL,DE
DJNZ TRNS0
PRPATO CALL PROK
JP PRPATU
TRANVOL
CALL TransPP
INC HL
inc HL
inc HL
inc HL
TRNV0 LD A,(HL)
AND #F0
LD D,A
XOR (HL)
jr Z,TRNVNO
ADD A,C
jr Z,TRNV1
CP 16
jr C,TRNVNO
CPL ;
RLA ;
SBC A,A ;будет
AND #0F ;F
TRNV1 OR 1 ;или 1
TRNVNO OR D
LD (HL),A
LD DE,18
ADD HL,DE
DJNZ TRNV0
JR PRPATO
TransPP
CALL FROMSZ
PUSH AF
LD A,(pat1)
CALL AtoPAT
CALL CHN1PP
LD A,(beg1)
ADD A,A
LD L,A
ld H,TLINES/256
LD A,(HL)
INC L
LD H,(HL)
ld L,A
ADD HL,DE
add HL,BC
POP BC
transp=$+1
LD C,0
RET
;edsmp/orn
PIANO
XOR A
LD H,A
ld L,A
LD (piCURv),HL
LD (piCURv+2),HL
LD (mix),A
LD (DNOIS),A
LD HL,piaSMP
LD D,(HL)
ld (HL),A
LD (piSLIN),A
LD (piOLIN),A
LD A,D
ADD A,SMPS/256
INC HL
LD (HL),A
LD A,(piaORN)
CALL HLOR3
LD (piaORN),HL
CALL NOTEKEY
LD A,D
DEC A
CP 24
RET NC
pIANO0
push de
CALL NotOct ;D(NOTEKEY) -> D
DEC A
LD L,A
LD IY,pianRG
LD DE,(piaORN)
ld (ORNADR),DE
LD BC,(piOLIN)
LD A,C
INC A
CP B
jr C,$+5
LD A,(piOLOOP)
LD (piOLIN),A
LD IX,(piaSMP)
LD A,(piSEND)
ld B,A
LD A,(piSLIN)
ld E,A
INC A
CP B
jr C,$+5
LD A,(piSLOOP)
LD (piSLIN),A
LD A,E
ld B,0
CALL SAMPLER
LD (frqB),HL
CALL ADDVOL
LD (volB),A
LD A,B
RLCA
LD (mix),A
CALL OUTAY
;LD IY,23610
;LD (IY-52),1 ;???
;LD (IY-56),1 ;???
CALL RESHALT ;???
;CALL NOTEKEY
;LD A,D
;DEC A
;CP 24
call isnotepressed ;NZ=pressed
pop de
jr nz,pIANO0 ;нажато что-то (кроме CS,SS,Space) - держим ноту
;6
PIANAY
LD HL,pianRG
JR $+5
;2
OUTAY LD HL,frqA
LD DE,#00BF
LD A,#D
OUTAY0 LD BC,-3
OUT (C),D
LD B,E
OUTI
INC D
DEC A
jr NZ,OUTAY0
LD B,-1
OUT (C),D
LD B,E
LD D,(HL)
CP D
LD (env),A
RET Z
OUT (C),D
RET
NOTEKEY
CALL BIT5
jr Z,NOTEKYQ
cp 'A'
jr c,notekey_nocaps
cp 'Z'+1
jr nc,notekey_nocaps
or 0x20
notekey_nocaps
LD BC,TNOTEKE-TNOTEKY
PUSH HL
LD HL,TNOTEKY
CPIR
POP HL
LD D,C
RET Z
LD D,97
CP kR;'R'
RET Z
INC D
CP kssL
RET Z
INC D
CP kK
RET Z
NOTEKYQ LD D,-1
RET
ADDVOL
ADD A,(IY+#18)
JP P,$+6
XOR A
JR PLnAv
CP 16
jr C,$+4
LD A,#F
PLnAv LD D,0
ld E,A
RET
iSMPORN
LD E,(IY+1)
LD D,(IY+2)
LD (ORNADR),DE
LD B,(IY+3) ;len
LD A,(IY+4) ;pos
LD C,A
INC A
CP B
jr C,$+5
LD A,(IY+5) ;loop
LD (IY+4),A
LD L,(IY+6) ;
LD H,(IY+7) ;smpadr
PUSH HL
POP IX
LD B,(IY+8) ;len
LD A,(IY+9)
ld E,A
INC A
CP B
jr C,$+5
LD A,(IY+10) ;loop
LD (IY+9),A ;pos
LD A,E ;oldpos
LD L,(IY+11) ;note
SAMPLER
;L=note
;C=posinORN
;A=posinSMP
ADD A,A
add A,A
LD LX,A ;+smpadr
CALL OUT4
LD A,(IX+2)
ld E,A
LD B,8
AND #40
jr NZ,NOnois
LD B,A
LD A,(IX+2)
ADD A,(IY+#1B)
BIT 4,(IX+3)
jr Z,$+5
LD (IY+#1B),A
LD D,A
LD A,(DNOIS)
ADD A,D
LD (nois),A
JR NOdenv
NOnois LD A,(Edfrq)
ld H,A
LD A,(IX+2)
AND 31
CP 16
jr C,$+4
OR #F0
ADD A,(IY+#1C)
BIT 4,(IX+3)
jr Z,$+5
LD (IY+#1C),A
ADD A,H
LD (Edfrq),A
NOdenv LD A,E
AND #80
jr Z,$+4
SET 0,B
LD A,E
AND #20
LD E,C
ld D,0
LD C,16
jr Z,$+3
LD C,D
LD A,L ;note
ORNADR=$+1
LD HL,0
ADD HL,DE
ADD A,(HL)
add A,A
jr NC,$+3
XOR A
LD HL,FrTab
LD E,A
ADD HL,DE
LD A,(HL)
INC HL
LD H,(HL)
ld L,A
LD D,(IX+1)
LD E,(IX) ;shift в smp
BIT 5,(IX+3)
jr Z,NOdfrq
PUSH HL
LD L,(IY+#19)
LD H,(IY+#1A)
ADD HL,DE
LD (IY+#19),L
LD (IY+#1A),H ;shift
LD DE,0
POP HL
NOdfrq ADD HL,DE
LD E,(IY+#19)
LD D,(IY+#1A) ;shift
ADD HL,DE
LD A,(IX+3)
ld D,A
AND #80
jr Z,NOdvol
LD A,D
AND #40
CPL
jr Z,$+4
LD A,1
ADD A,(IY+#18)
CP 16
jr Z,YEdvol
INC A
CP -17
jr Z,$+3
YEdvol DEC A
LD (IY+#18),A
NOdvol LD A,D
AND #F
RET
;4
;Z=NOTE
XPPSCF
SCF
;2
;Z=SMP
XPP
LD A,(CURX)
ADC A,-7
LD BC,#C04
RET Z
RET NC
SUB 9
RET C
LD BC,#1609
SCF
RET Z
SUB 9
RET C
LD BC,#200E
SCF
RET Z
SUB 9
RET
;4
XPP2
LD A,(CURX)
LD C,1
SUB 11+4
RET C
INC C
SUB 5+4
RET C
INC C
RET