;ESQ.GEN
;E.L. MAI/JUNI 1987,	MOD 31-7-87
;BASIC-VERSJON, CX5M
;MOD 7-5-88 FOR YAMAHA DISKDRIVE
;FLYTTET #300 NED I MEMORY
;VERSION 1.4B
;-----------------------------------
;SENDER SYSEX CUR/ALL PRG.DUMP REQUEST
;  MOTTAR SYSEX CUR/ALL PRG.DUMP
;  OG LAGRER VED CURPCB ELLER ALPRGB
;DEKODER ESQ-FIL FRA CURPCB OG
;  SETTER OPP PARAMETER DISPLAY BLOKK
;  FOR ESQ-1 SYSEX
;
;DUMPER BLOKK TIL VRAM FOR DISPLAY
;
;DISPLAY ALLE PROG.NAVN
;
;SWAPS 2 PROGRAMMER, EVT. 2 BANKER
;
;SENDER CUR/ALL PRG FRA CURPCB ELLER
;  ALPRGB TIL ESQ-1
;
;SENDER SYSEX SEQUENCE DUMP REQUEST
;  MOTTAR SEQUENCE DUMP ALERT,SJEKKER
;  DATALENGDE,SENDER EVT. ACCEPT MESS
;  MOTTAR SEQUENCE DATA,LAGRER FRA
;  CURPCB TIL CURPCB+DATALENGDE
;
;
;SENDER SYSEX 1 SEQUENCE DUMP ALERT,
;  VENTER PAA ACCEPT MESSAGE FRA ESQ,
;  SENDER EVT. 1 SEQ DUMP PACKET,
;  ELLER SKRIVER FEILMELDING HVIS
;  ESQ NEKTER.
;
;SENDER SYSEX 1 SEQ DUMP REQUEST,
;	MOTTAR ALERT, SENDER ACCEPT,
;	MOTTAR DE 9 F0RSTE BYTES,
;	DEKODER OG SKRIVER UT SEQ STATUS
;----------------------------------
;
;----------------------------------
;ADRESSER:
STARTA	EQU  #9C00	;STARTADRESSE
CURPCB	EQU  #AC9A	;1-PRG BLOKK
ALPRGB	EQU	 #AD00	;40-PRG BLOKK
INTGR	EQU	 #F7F8	;PARAMETER->BASIC
MID_SR	EQU	 #3FF6	;MIDI.GEN
MID_DR	EQU  #3FF5	;MIDI.GEN
EXSLOT	EQU  #FFFF
VRAMST	EQU	 #0		;VRAMSTART
PPIA	EQU  #A8	;PORT A
;
;ROM BIOS RUTINER:
POSIT	EQU  #C6	;FLYTT CURSOR
LDIRVM	EQU	 #5C
LDIRMV	EQU	 #59
CHGET	EQU  #9F
CHPUT	EQU	 #A2
BEEP	EQU  #C0
ENASLT	EQU  #24		;?UBRUKT?
;
;MIDI:
SYSEX	EQU	 #F0
MAXSIZE	EQU	 #30	;H0BYT SEQLENGDE
;
;FEILKODER:
TOOBIG	EQU	 #F1   ;SEQ FOR LANG
MIDIERR	EQU	 #F0   ;MIDI ERROR
WRNGCOD	EQU	 #F2   ;GAL KODE
NOMEMOR	EQU	 #F5   ;FOR LITE MEMORY
NOFREE	EQU	 #FD   ;INGEN LEDIG SEQ.
;
;ANDRE KODER:
SWAP	EQU	 #10	;SWAP 2 PRGRMS
;
;MASKER:
SLMAPM	EQU  #03	;CX5M
SLMAPR	EQU  #00	;CX5M
;
;DIVERSE:
STAPOS	EQU	 #0601	;CSR STARTPOSISJON
HOME	EQU	 #0101	;  0VERST/VENSTRE
;-----------------------------------
		;
		;
		DEFB #FE	;MSX-DISK
		DEFW STARTA ;BLOAD
		DEFW ENDA	;HEADER
		DEFW STARTA ;
		ORG  STARTA
		;
		JP	 CPDST	;U1 CUR PRG DUMP
		JP	 APDST	;U3 ALL PRG DUMP
		JP	 CHKLEN	;U0 CHK SEQ LEN
		JP	 LOADST ;U2 CUR/ALL->ESQ
		JP	 CURDIS ;U5 CUR PRG DISPLAY
		JP	 ALPDIS ;U4 ALL PRG DISPLAY
		JP	 ALPRES	;U6 RESET ALPRGB
		JP	 SEQLST	;U7 SEQ CX->ESQ
		JP	 SEQDST	;U8 SEQ ESQ->CX
		JP	 SWAPST	;U9 SWAP 2 PRGRMS
		JP	 VELGST	;	VELG FIL
		;
;-----------------------------------
;DATA SAVE AREA:
DBFAD	DEFW CURPCB		;DATA ADR
DBFAD2	DEFW ALPRGB		;DATA2 ADR
DLEN	DEFW 102		;DATA LENGTH
DLEN2	DEFW 102		;DATA2 LENGTH
CSRPOS	DEFW STAPOS		;CSR POSISJON
;SWABUF	DEFB 0			;SWAP BUFFER
JOB		DEFB 2			;KODE/JOB
SAVESP	DEFW 0			;SP SAVE AREA
;-----------------------------------
;SYSTEM EXCLUSIVE HEADER:
SXHEAD	DEFB #F0	;SX STATUS BYTE
		DEFB #0F	;ENSONIQ I.D.
		DEFB #02	;ESQ I.D.
MCHAN	DEFB #00	;MIDI KANAL
REQUEST DEFB #0		;PROG.DUMP REQUEST
EOX		DEFB #F7	;END OF EXCLUSIVE
;-----------------------------------
;
;
;-----------------------------------
VELGST	CP	 3		;STRING?
		RET	 NZ		;HVIS IKKE,RETURN
		PUSH DE
		EX	 DE,HL	;STR LEN TIL HL
		LD	 C,(HL)	;	OG TIL BC
		LD	 B,0
		PUSH BC
		INC  HL
		LD	 E,(HL)	;STR ADR LABYT
		INC	 HL
		LD	 D,(HL)	;STR ADR H0BYT
		PUSH DE
		LD	 HL,HOME
		CALL VELGFIL
		CALL HL2ADR
		POP	 DE
		POP	 BC
		CALL LDIRMV
		POP	 DE
		RET
;-----------------------------------
;
;
;
;
;
;
;
;-----------------------------------
;CSRMOVE.LIB
;DISPLAY CURSOR,FLYTT CSR MED PILTASTER
;'RETURN' FOR AA AVLESE POSISJON
H0YRF	POP  HL
		LD	 A,H		;CSR LENGST
		CP	 20			; TIL H0YRE?
		JR	 NC,SAMMF	;IKKE FLYTT
		ADD	 A,13
		LD	 H,A
		JR	 SAMMF
VENSTRF	POP	 HL
		LD	 A,H
		CP	 5
		JR	 C,SAMMF
		SUB	 13
		LD	 H,A
		JR	 SAMMF
CSROPF	POP  HL
		LD	 A,L
		CP	 2
		JR	 C,SAMMF
		DEC	 A
		LD	 L,A
		JR	 SAMMF
CSRNEF	POP  HL
		LD	 A,L
		CP	 24
		JR	 NC,SAMMF
		INC	 A
		LD	 L,A
SAMMF	PUSH HL
		CALL POSIT
		JR	 CSRLPF
;	-	-	-	-	-	-	-
VELGFIL	PUSH HL			; START-
		CALL POSIT		; POSISJON
CSRLPF	CALL CHGET
		CP	 13			;RETURN?
		JR	 Z,TILBAKF
		CP	 28			;H0YRE?
		JR	 Z,H0YRF
		CP	 29			;VENSTRE?
		JR	 Z,VENSTRF
		CP	 30			;OPP?
		JR	 Z,CSROPF
		CP	 31			;NED?
		JR	 Z,CSRNEF
		JR	 CSRLPF
;	-	-	-	-	-	-	-
TILBAKF POP  HL
		RET				;TIL MAIN PRG
;-----------------------------------
;
;
;
;
;
;-----------------------------------
HL2ADR	LD	 DE,VRAMST
		EX	 DE,HL	;0-STILL HL,
		PUSH DE		;  KOORD. TIL DE
		LD	 B,E	;Y-KOORDINAT
		LD	 DE,40	;LINJELENGDE
FINNY	ADD	 HL,DE	;ADDER 40
		DJNZ FINNY	; Y-1 GANGER
		SBC	 HL,DE	;
		POP	 DE
		LD	 B,D	;X-KOORDINAT
FINNX	INC	 HL		;ADDER 1
		DJNZ FINNX	; X-1 GANGER
		DEC	 HL
		RET			;MED RIKTIG ADRESSE
;-----------------------------------
;
;
;
;-----------------------------------
SINGLE	LD	 A,1	;1 PRG DUMP
		JR	 SXSTOUT
ALPROG	LD	 A,2	;ALL PRG DUMP
		JR	 SXSTOUT
ALSALRT	LD	 A,3	;ALL SEQ ALERT
		JR	 SXSTOUT
SEQALRT	LD	 A,7	;1 SEQ ALERT
		JR	 SXSTOUT
ACCEPT	LD	 A,4	;SEQ ACCEPT
		JR	 SXOUT
REJECT	LD	 A,5	;SEQ REJECT
		JR	 SXOUT
ALSDUMP	LD	 A,6	;ALL SEQ DUMP
		JR	 SXSTOUT
SEQDUMP	LD	 A,8	;1 SEQ DUMP
		JR	 SXSTOUT
PRGREQ	LD	 A,9	;1 PRG REQUEST
		JR	 SXOUT
ALPREQ	LD	 A,10	;ALL PRG REQUEST
		JR	 SXOUT
ALSREQ	LD	 A,11	;ALL SEQ REQUEST
		JR	 SXOUT
SEQREQ	LD	 A,12	;1 SEQ REQUEST
		JR	 SXOUT
		;
SXSTOUT	LD	 BC,5
		JR	 SXUT
SXOUT	LD	 BC,6
SXUT	LD	 (REQUEST),A
		LD	 HL,SXHEAD
		CALL OMLP
		RET
;-----------------------------------
		;
		;
		;
		;
		;
		;
		;
;-----------------------------------
;CHECK SEQUENCE LENGTH
CHKLEN	CALL START
		CALL RESET
		CALL SEQREQ		;SEQDUMPREQ
		CALL INSIZE		;VENT ALERT
		CALL ACCEPT
		LD	 HL,SEQSTAT
		LD	 (DBFAD),HL
		LD	 BC,9		;SEQSTAT LEN
		LD	 (DLEN),BC
		CALL SXJUMP
		CALL IMIDI
		CALL BACK
		CALL SEQSDIS
		CALL ERROR		;EVT.ERROR?
		RET				;TIL BASIC
;-----------------------------------
SEQSTAT DEFS 9	;SEQ STATUS
;
;
;
;-----------------------------------
CPDST	CALL SETCUR
		CALL BEEP
		CALL START
		CALL RESET
		CALL PRGREQ
		CALL SXJUMP
		CALL IMIDI
		CALL BACK
		CALL DISPLAY
		CALL BEEP
		RET				;TIL BASIC
;-----------------------------------
;
;
;
;
;
;
;
;
;-----------------------------------
APDST	CALL SETALL
		CALL BEEP
		CALL START
		CALL RESET
		CALL ALPREQ
		CALL SXJUMP
		CALL IMIDI
		CALL BACK
		CALL ALPDIS
		CALL BEEP
		RET				;TIL BASIC
;-----------------------------------
		;
		;
		;
		;
		;
		;
		;
		;
;-----------------------------------
;1 SEQUENCE ESQ->CX
SEQDST	CALL START
		CALL RESET
		CALL SEQREQ		;SEQDUMPREQ
		CALL INSIZE		;VENT ALERT
		JR	 NC,DMPSEQ
		CALL REJECT
		JR	 SEQEXIT
DMPSEQ	CALL WRITLEN	;FOR BASIC
		CALL ACCEPT
		LD	 HL,CURPCB
		LD	 (DBFAD),HL
		CALL SXJUMP
		CALL IMIDI
SEQEXIT	CALL BACK
		CALL ERROR		;EVT.ERROR?
		RET				;TIL BASIC
;-----------------------------------
		;
;-----------------------------------
;INSIZE	LESER 1 SEQ DUMP ALERT PACKET
;LAGRER SEQSIZE I DLEN OG LAGRER
;FEILKODE HVIS SIZE > MAXSIZE
INSIZE	LD	 A,7		;1 SEQ ALERT
		LD	 (JOB),A	;		KODE
		CALL SXJUMP		;LES SXHEADER
		;
		LD	 HL,DLEN
		LD	 BC,2
		CALL IMPDLP
		CALL INMD		;LES EOX
		;
		LD	 A,(DLEN+1)	;H0BYT LENGDE
		CP	 MAXSIZE	;LEN>MAXSIZE?
		CCF
		RET	 NC
		LD	 A,TOOBIG	;FEILMELDING
		LD	 (JOB),A
		RET				;TIL SEQDST
;-----------------------------------
;
;
;-----------------------------------
;WRITLEN LESER DATALENGDE,
; REGNER UT SLUTTADRESSE
; OG SKRIVER DEN TIL INTGR (BASIC/
; MASKINKODE PARAMETER PASSING)
WRITLEN	LD	 BC,(DLEN)	;HENT DATALEN
		LD	 HL,CURPCB	;STARTADRESSE
		ADD	 HL,BC		;ENDADRESSE
		LD	 (INTGR),HL	;TIL BASIC
		RET
;-----------------------------------
		;
		;
		;
		;
		;
		;
		;
		;
;-----------------------------------
SEQLST	CALL SETCUR
		CALL START
		CALL RESET
		CALL UTSIZE
		LD	 A,4		;ACCEPT CODE
		LD	 (JOB),A
		CALL SXJUMP		;VENT SVAR
		JR	 Z,SEQLOAD	;JA,AKSEPTERT
		ADD	 A,#F0		;FEILKODE
		LD	 (HL),A		;TIL (JOB)
		JR	 SEQLEX
		;
SEQLOAD CALL SEQDUMP
		LD	 HL,(DBFAD)
		LD	 BC,(DLEN)
		CALL OMLPESQ
SEQLEX	CALL BACK
		CALL ERROR
		RET				;SEQ CX->ESQ
;----------------------------------
;
;----------------------------------
;UTSIZE	KOPIERER SEQSIZE FRA CURPCB
;TIL DLEN (SNUR H0Y/LAV BYTE),
;OG SENDER 1 SEQ DUMP ALERT PACKET
UTSIZE	LD	 HL,(CURPCB)
		LD	 DE,DLEN
		LD	 A,H		;LABYTE I H!
		LD	 (DE),A
		INC	 DE
		LD	 A,L		;H0BY I L!
		LD	 (DE),A
		CALL SEQALRT	;ALERT PACKET
		LD	 HL,DLEN	;SKRIV DATA-
		LD	 BC,2		;	LENGDE
		CALL OMLPESQ	;
		RET
;-----------------------------------
		;
		;
;
;
;-----------------------------------
LOADST	CALL CURDIS		;DISPL CURPRG
		CALL SELESC		;LOAD?
		JR	 C,ALPDST	;NEI,HOPP
		LD	 A,1		;1 PRG LOAD
		LD	 (REQUEST),A
		CALL PRGLOAD	;->ESQ
		JR	 LOADST		;REP. DISPLAY
ALPDST	CALL ALPDIS		;DISPL ALLPRG
		LD	 HL,STAPOS	;CSR TIL 5,0
VELGLP	CALL VELGPRG	;VELG
		RET	 NC
		CALL PRGLOAD
		JR	 VELGLP
		RET				;TIL BASIC
;-----------------------------------
;
;
;
;
;
;-----------------------------------
SETCUR	LD	 HL,CURPCB
		LD	 (DBFAD),HL
		LD	 BC,102
		LD	 (DLEN),BC
		RET
SETALL	LD	 HL,ALPRGB
		LD	 (DBFAD),HL
		LD	 BC,4080
		LD	 (DLEN),BC
		RET
;-----------------------------------
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;-----------------------------------
;SWAP/COPY 2 PROGRAMS OR 2 BANKS:
SWAPST	LD	 A,(INTGR)	;SWAP/COPY?
		LD	 (JOB),A
SWAPREP	CALL SEL2PRG	;VELG 2 PRGRMS
		RET  NC			;INGEN VALGT
		LD	 HL,(DBFAD2)
		LD	 DE,(DBFAD)
		LD	 BC,(DLEN)
		LD	 A,(JOB)	;SWAP/COPY?
		CP	 0
		JR	 Z,SWAPLP
		LDIR			;KOPIERER
		JR	 SWAPREP	;NESTE COPY
;	-	-	-	-	-	-
SWAPLP	LD	 A,(HL)
		PUSH AF
		LD	 A,(DE)
		LD	 (HL),A
		POP	 AF
		LD	 (DE),A
		INC  HL
		INC  DE
		DEC  BC
		LD	 A,B
		OR	 C
		JR	 NZ,SWAPLP
		JR	 SWAPREP
;------------------------------------
;
;
;
;
;
;
;
;-----------------------------------
PRGLOAD	PUSH HL
		CALL BEEP
		CALL START
		CALL RESET
		LD	 HL,SXHEAD
		LD	 BC,5
		CALL OMLP
		LD	 HL,(DBFAD)
		LD	 BC,(DLEN)
		CALL OMLPESQ
		CALL BACK
		POP	 HL
		RET
;-----------------------------------
;
;
;
;
;-----------------------------------
SEL2PRG	CALL BEEP
		CALL ALPDIS		;DISPLAY PRGRMS
		LD	 HL,STAPOS
		CALL VELGPRG	;VELG PRG 1
		RET  NC			;INGEN VALGT
		LD	 HL,(DBFAD)	;SAVE ADRESSE
		LD	 (DBFAD2),HL; OG LENGDE
		LD	 HL,(DLEN)
		LD	 (DLEN2),HL
		LD	 HL,(CSRPOS)
		CALL VELGPRG	;VELG PRG 2
		RET  NC
		LD	 HL,(DLEN)
		LD	 BC,(DLEN2)
		OR	 A			;RESET CY-FLAG
		SBC	 HL,BC		;SAMME
		LD	 A,H		; DATALENGDE?
		OR	 L			; HVIS IKKE,
		JR	 NZ,SEL2PRG	; PR0V IGJEN.
		SCF				;SET CY-FLAG
		RET
;-----------------------------------
;
;
;
;-----------------------------------
OMLPESQ	CALL OPMDESQ
		INC  HL
		DEC  BC
		LD	 A,B
		OR	 C
		JR	 NZ,OMLPESQ
		LD	 HL,EOX
		CALL OPMD
		RET				;TIL CPLST
;-----------------------------------
;
;
;
;
;
;
;
;-----------------------------------
OPMDESQ	LD	 D,(HL)		;SAVE DATA
		LD	 A,(MID_SR)
		BIT  0,A
		JR	 Z,OPMDESQ
		RRD				;LANIB(HL)->A
		AND	 #0F	   ;MASK BIT 7654
		LD	 (MID_DR),A	;SEND UT
OPMDES2	LD	 A,(MID_SR)
		BIT  0,A
		JR	 Z,OPMDES2
		RRD				;LANIB(HL)->A
		AND	 #0F	   ;MASK BIT 7654
		LD	 (MID_DR),A	;SEND UT
		LD	 (HL),D		;HENT DATA
		RET				;TIL OMLPESQ
;-----------------------------------
;
;-----------------------------------
;PRGFIND.GEN, CSRMOVE.LIB
;DISPLAY CURSOR,FLYTT CSR MED PILTASTER
;'ESCAPE' FOR RETURN
;'SELECT' FOR AA AVLESE POSISJON
H0YRE	POP  HL
		LD	 A,H		;CSR LENGST
		CP	 30			; TIL H0YRE?
		JR	 NC,SAMME	;IKKE FLYTT
		CP	 5			;TIL VENSTRE?
		JR	 C,H0YR5	;FLYTT 5 POS
		ADD	 A,7
		JR	 H0YRPOS
H0YR5	ADD  A,5
H0YRPOS	LD	 H,A
		JR	 SAMME
VENSTRE	POP	 HL
		LD	 A,H
		CP	 5
		JR	 C,SAMME
		CP	 10
		JR	 C,VENS5
		SUB	 7
		JR	 VENSPOS
VENS5	SUB  5
VENSPOS LD	 H,A
		JR	 SAMME
CSROPP	POP  HL
		LD	 A,L
		CP	 2
		JR	 C,SAMME
		DEC	 A
		LD	 L,A
		JR	 SAMME
CSRNED	POP  HL
		LD	 A,L
		CP	 24
		JR	 NC,SAMME
		INC	 A
		LD	 L,A
SAMME	PUSH HL
		CALL POSIT
		JR	 CSRLOOP
;	-	-	-	-	-	-	-
VELGPRG	PUSH HL			; START-
		CALL POSIT		; POSISJON
CSRLOOP	CALL CHGET
		CP	 27			;ESCAPE?
		JR	 Z,TILBAK
		CP	 24			;SELECT
		JR	 Z,REGPOS
		CP	 28			;H0YRE?
		JR	 Z,H0YRE
		CP	 29			;VENSTRE?
		JR	 Z,VENSTRE
		CP	 30			;OPP?
		JR	 Z,CSROPP
		CP	 31			;NED?
		JR	 Z,CSRNED
		JR	 CSRLOOP
;	-	-	-	-	-	-	-
TILBAK	OR	 A			;RESET C-FLAG
TILBAKE POP  HL
		LD	 (CSRPOS),HL;SAVE POSISJON
		RET				;TIL MAIN PRG
;
;
;	-	-	-	-	-	-	-
REGPOS	POP  HL
		PUSH HL
		LD	 A,H		;X-POS
		CP	 5			;BANK?
		JR	 C,BNKFIND
		DEC  L			;LINJENR-1
		LD	 A,L		;TIL A-REG
		RLCA			;*2
		RLCA			;*4
		ADD	 A,L		;*5
		LD	 B,A		;0,5,10,15..
		LD	 A,H		;X-POS
		SUB  5
XLOOP	INC  B			;PRGNR+1
		SUB  7
		JR	 NC,XLOOP
		LD	 DE,102
		LD	 HL,CURPCB
PRGLOOP	ADD  HL,DE
		DJNZ PRGLOOP
		LD	 A,1		;1PRG LOAD
		JR	 VALGT
BNKFIND LD	 A,L		;HENT LINJENR
		LD	 DE,4080
		LD	 HL,ALPRGB
		CP	 9			;BANK 1?
		JR	 C,BNK1
		CP	 17			;BANK 2?
		JR	 C,BNK2
		ADD  HL,DE		;BANK 3
BNK2	ADD	 HL,DE
BNK1	LD	 A,2		;ALLPRG LOAD
VALGT	LD	 (DBFAD),HL
		LD	 (DLEN),DE
		LD	 (REQUEST),A
		SCF				;SET C-FLAG
		JR	 TILBAKE
		;
;-----------------------------------
;ALPDIS2.GEN
ALPDIS	LD	 HL,HOME
		CALL POSIT
		LD	 HL,INT		;INT MESSG.
		LD	 B,4		;3 BOKSTAVER
		CALL SKRIVLP	;SKRIV
		LD	 HL,ALPRGB	;HENT BL.ADR.
		CALL ALPLP1		;SKRIV 40 PRG
		PUSH HL			;SAVE
		LD	 HL,CRTA
		LD	 B,4
		CALL SKRIVUT
		POP	 HL
		CALL ALPLP1
		PUSH HL
		LD	 HL,CRTB
		LD	 B,4
		CALL SKRIVUT
		POP	 HL
		CALL ALPLP1
		RET				;TIL MAIN PRG
;-----------------------------------
ALPLP1	LD   B,8		;8 LINJER
		PUSH BC			;SAVE
ALPLP2	LD	 B,5		;5 NAVN/LINJE
ALPLP3	PUSH BC			;SAVE
		LD	 B,6		;6 BOKST/PRG
		CALL SKRIVUT	;SKRIV
		LD	 BC,96		;NXT NAME
		ADD	 HL,BC		;OPPDAT. HL
		POP	 BC			;NAVNTELLER
		DJNZ ALPLP3		;LINE END?
		POP  BC			;LINJETELLER
		DJNZ ALPLP2A	;BANK END?
		RET				;TIL ALPDIS
ALPLP2A	PUSH BC
		PUSH HL
		LD	 B,4		;LINE START
		LD	 HL,MELLOMR
		CALL SKRIVUT
		POP  HL
		JR	 ALPLP2
;-----------------------------------
SKRIVUT	LD	 A,#20		;MELLOMROM
		CALL CHPUT
SKRIVLP	LD	 A,(HL)		;HENT TEGN
		CP	 #20		;CTRL CHAR?
		JR	 NC,GREIT	;NEI,SKRIV
		LD	 A,#20		;JA,SKRIV " "
GREIT	CALL CHPUT		;SKRIV DET
		INC	 HL			;NESTE TEGN
		DJNZ SKRIVLP
		RET
;	-	-	-	-	-
CRLF	LD	 A,#D		;CARR.RETURN
		CALL CHPUT
		LD	 A,#A		;LINE FEED
		CALL CHPUT
		RET
;-----------------------------------
INT		DEFM "Bnk1"
CRTA	DEFM "Bnk2"
CRTB	DEFM "Bnk3"
MELLOMR DEFM "    "
;-----------------------------------
;
;
;
;-----------------------------------
ERROR	LD	 A,(JOB)	;HENT KODE
		BIT	 7,A		;>7F?
		RET	 Z			;INGEN FEIL
		CP	 TOOBIG
		JR	 Z,TOOBERR
		CP	 WRNGCOD
		JR	 Z,CODEERR
		CP	 MIDIERR
		JR	 Z,MDERR
		CP	 NOMEMOR
		JR	 Z,MEMERR
		CP	 NOFREE
		JR	 Z,SEQERR
		JR	 CODEERR
		RET
;	-	-	-	-	-	-	-
TOOBERR	LD	 HL,FORSTOR
		LD	 B,13
		CALL SKRIVLP
		RET
		;	-	-	-	-	-
MDERR	LD	 HL,MDFEIL
		LD	 B,10
		CALL SKRIVLP
		RET
		;	-	-	-	-	-
CODEERR LD	 HL,GALKODE
		LD	 B,10
		CALL SKRIVLP
		RET
		;	-	-	-	-	-
MEMERR	LD	 HL,FULLMEM
		LD	 B,17
		CALL SKRIVLP
		RET
		;	-	-	-	-	-
SEQERR	LD	 HL,FULLSEQ
		LD	 B,16
		CALL SKRIVLP
		RET
		;	-	-	-	-	-
		;
FORSTOR	DEFM "Seq too large"
MDFEIL	DEFM "MIDI error"
GALKODE DEFM "Wrong code"
FULLMEM	DEFM "Not enough memory"
FULLSEQ	DEFM "No free sequence"
;-----------------------------------
;
;
;
;
;
;
;
;
;-----------------------------------
;MIDI.GEN (FRA YAMAHA,G0TEBORG)
		;
;CHANGE SLOT:
		;
START	DI
		LD	 (SAVESP),SP
		IN	 A,(PPIA)
		OR	 SLMAPM
		OUT  (PPIA),A
		RET
		;
		;
;BACK TO MAIN PROGRAM:
		;
BACK	LD	 A,SLMAPR
		OUT  (PPIA),A
		LD	 SP,(SAVESP)
		EI
		RET
		;
		;
;RESET MIDI
RESET	LD	 A,#80
		LD	 (MID_SR),A
		LD	 A,#05
		LD	 (MID_SR),A
		XOR  A
		RET
		;
		;
;REQUEST SEND & RECEIVE DATA
OIMIDI	CALL OMIDI
		CALL SXJUMP
		CALL IMIDI
		RET
		;
		;
;OUTPUT 1 BYTE DATA TO MIDI
O1MIDI	INC  HL
		INC  HL
		CALL OPMD
		RET
		;
		;
;INPUT DATA FROM MIDI:
SXJUMP	CALL INMD
		RET  C
		LD	 A,D
		CP	 SYSEX		;SYS EX?
		JR	 NZ,SXJUMP
		LD	 B,4
SXLOOP	CALL INMD
		RET  C
		DJNZ SXLOOP
		LD	 HL,JOB		;HENT
		LD	 A,D		;	KODE
		CP	 (HL)	;RIKTIG MESSAGE?
		RET
		;
		;
		;
		;
		;
		;
IMIDI	LD	 HL,(DBFAD)	;SET BUFADRESS
		LD	 BC,(DLEN)	;OG LENGDE
IMPDLP	CALL INMD		;HENT DATA
		RET  C			;
		LD	 A,D		;LANIB A TIL
		RRD				;H0NIB (HL)
		CALL INMD		;NEXT NIBBLE
		RET  C
		LD	 A,D
		RRD
		INC  HL
		DEC  BC			;TELL NED
		LD	 A,B		;BC=0?
		OR	 C
		JR	 NZ,IMPDLP
		RET
		;
		;
		;
		;
		;
;INPUT MIDI TO D-REG
;DATA:D		X:A
;
INMD	LD	 A,(MID_SR)
		BIT	 5,A		;?????????
		JR	 NZ,FE
		BIT  1,A
		JR	 Z,INMD
		LD	 A,(MID_DR)
		LD	 D,A
		AND  #F8
		CP	 #F8		;CANCEL
		JR	 Z,INMD		; REALTIME
		AND  A			;NO ERROR
		RET
;
FE		LD	 A,#F0
		LD	 (JOB),A
		SCF
		RET				;ERROR
;
;
;OUTPUT DATA TO MIDI
;
OMIDI	LD	 HL,(DBFAD)
		LD	 BC,(DLEN)
OMLP	CALL OPMD
		INC  HL
		DEC  BC
		LD	 A,B
		OR	 C
		JR	 NZ,OMLP
		RET
		;
OPMD	LD	 A,(MID_SR)
		BIT  0,A
		JR	 Z,OPMD
		LD	 A,(HL)
		LD	 (MID_DR),A
		RET
;
;
;SUM CHECK
;
SUMCHK	LD	 HL,(DBFAD)
		LD	 BC,(DLEN)
		LD	 D,0
SULP	LD	 A,(HL)
		ADD  A,D
		LD	 D,A
		INC  HL
		DEC  BC
		LD	 A,B
		OR	 C
		JR	 NZ,SULP
		LD	 A,D
		LD	 (JOB),A
		RET
		;
		;			;END MIDI.GEN
;-----------------------------------
;
;
;
;-----------------------------------
SELESC	CALL CHGET		;VENT
		CP	 24			;SELECT?
		JR	 Z,SELRET
		CP	 27			;ESCAPE?
		JR	 NZ,SELESC
		SCF				;SETT C-FLAGG
SELRET	RET
;-----------------------------------
ALPRES	LD	 HL,CURPCB	;(=MFILL.LIB)
		LD	 A,#2D		;"-"
		LD	 BC,4080*3+102	;BLOKKLENGDE
		LD	 (HL),A
		LD	 D,H
		LD	 E,L
		INC	 DE
		DEC	 BC
		LDIR
		RET
;-----------------------------------
SQSTRES LD	 H,D
		LD	 L,E
		LD	 A," "	;RESET SEQ STATUS
		LD	 B,25	;	BUFFER
SSRESLP	LD	 (HL),A
		INC	 HL
		DJNZ SSRESLP
		RET
;-----------------------------------
SEQSDIS	LD	 IX,SEQSTAT
		LD	 DE,SQSTBUF
		PUSH DE
		CALL SQSTRES	;RESET BUFFER
		LD	 A,(IX+4)	;SEQ NR.
		INC	 A		  ;(START PAA 1)
		CALL BINDEC2
		INC	 DE
		INC	 DE
		LD	 A,(IX+7)	;TAKTARTNR.
		CALL SQDEK1
		LD	 B,(IX+2)	;BARS H0BYT
		LD	 C,(IX+3)	;BARS LABYT
		CALL SQDEK2
		INC	 DE
		INC	 DE
		LD	 A,(IX+8)	;TEMPO
		CALL BINDEC3
		INC	 DE
		INC	 DE
		LD	 B,(IX+0)	;LEN H0BYT
		LD	 C,(IX+1)	;LEN LABYT
		CALL SQDEK2
		CALL CRLF
		LD	 B,25		;SQSTBUF LEN
		POP	 HL
		CALL SKRIVLP
		RET
;-----------------------------------
SQDEK2	PUSH DE
		LD	 D,B
		LD	 E,C
		LD	 HL,DECIBUF
		CALL BN2DEC
		POP	 DE
		LD	 A,5
		SUB	 (HL)	;DECIMALTALL LEN
		JR	 Z,SQD2
		LD	 B,A
SQ2LP	INC	 DE
		DJNZ SQ2LP
SQD2	LD	 B,(HL)
SQ2LP2	INC	 HL
		LD	 A,(HL)
		LD	 (DE),A
		INC	 DE
		DJNZ SQ2LP2
		RET
;-----------------------------------
SQDEK1	AND	 #1F	;MASK 765
		LD	 B,A	;TAKTARTNR.->B
		INC	 B		;START FRA 1
		LD	 HL,TAKTART-4
TAKTLP	INC	 HL
		INC	 HL
		INC	 HL
		INC	 HL
		DJNZ TAKTLP
		LD	 BC,4
		LDIR
		RET
;	-	-	-	-	-	-	-
TAKTART	DEFM " 1/8 1/4 2/8 3/8"
		DEFM " 2/4 4/8 5/8 3/4"
		DEFM " 6/8 7/8 4/4 8/8"
		DEFM " 9/8 5/410/811/8"
		DEFM " 6/412/813/8 7/4"
		DEFM "14/815/8 8/416/8"
		DEFM "17/8 9/418/819/8"
		DEFM "10/420/821/8"
;-----------------------------------
SQSTBUF	DEFS 25	;SEQ STATUS BUFFER
;
DECIBUF DEFS 7	;BIN->DESIMAL BUFFER
;-----------------------------------
;BN2DEC	Z80 ALS P.178
;KONV. 16-BIT BIN TIL ASCII-STRING
;INN:BIN I DE,ADR.TIL UTBUFFER I HL
;UT :BUFFER ADR. AV HL:
;	 1.BYTE:LENGDE, 2.BYTE EVT."-",
;	 ASCII-SIFRE
;REGISTRE:AF,BC,DE,HL
		;
		;
BN2DEC	LD	 (BUFPTR),HL
		EX	 DE,HL
		LD	 A,0
		LD	 (CURLEN),A
		LD	 A,H
		LD	 (NGFLAG),A
		OR	 A
		JP	 P,CNVERT
		EX	 DE,HL
		LD	 HL,0
		OR	 A
		SBC	 HL,DE
CNVERT	LD	 E,0
		LD	 B,16
		OR	 A
DVLOOP	RL	 L
		RL	 H
		RL	 E
		LD	 A,E
		SUB	 10
		CCF
		JR	 NC,DECCNT
		LD	 E,A
DECCNT	DJNZ DVLOOP
		RL	 L
		RL	 H
CHINS	LD	 A,E
		ADD	 A,"0"
		CALL INSERT
		LD	 A,H
		OR	 L
		JR	 NZ,CNVERT
EXIT	LD	 A,(NGFLAG)
		OR	 A
		JP	 P,POS
		LD	 A,"-"
		CALL INSERT
POS		EX	 DE,HL	;FEIL I BOKA?
		RET
		;
INSERT	PUSH HL
		PUSH AF
		LD	 HL,(BUFPTR)
		LD	 D,H
		LD	 E,L
		INC	 DE
		LD	 (BUFPTR),DE
		LD	 A,(CURLEN)
		OR	 A
		JR	 Z,EXITMR
		LD	 C,A
		LD	 B,0
		LDDR
EXITMR	LD	 A,(CURLEN)
		INC	 A
		LD	 (CURLEN),A
		LD	 (HL),A
		EX	 DE,HL
		POP	 AF
		LD	 (HL),A
		POP	 HL
		RET
		;
BUFPTR	DEFS	 2
CURLEN	DEFS	 1
NGFLAG	DEFS	 1
		;
		;
;-----------------------------------
CURDIS	CALL SETCUR
DISPLAY	LD	 HL,(DBFAD)	;ESQ FIL
		LD	 IX,PARPEK	;PAR.DISP PEKERTABELL
		CALL FRSTPAR
		CALL DEKNAM		;NAVN
		;
		LD	 B,4		;4* ENV BLK
ENVLOOP	PUSH BC			;SAVE
		CALL DEKOD1		;L1
		CALL DEKOD1		;L2
		CALL DEKOD1		;L3
		CALL DEKOD2		;T1
		CALL DEKOD2		;T2
		CALL DEKOD2		;T3
		CALL DEKOD2		;T4
		CALL DEKOD3		;LV
		CALL DEKOD2		;T1-V
		CALL DEKOD2		;TK
		POP  BC
		DJNZ ENVLOOP
		;
		LD	 B,3		;3*LFO BLK
LFOLOOP PUSH BC
		CALL DEKOD5		;WAVE
		DEC  HL			;SAMME BYTE
		CALL DEKOD2		;FREQ
		CALL DEKOD4		;MOD SRC
		DEC  HL			;SAMME BYTE
		CALL DEKOD2		;L1
		CALL DEKOD2		;L2
		CALL DEKOD7		;RESET
		DEC  HL			;SAMME BYTE
		CALL DEKOD6		;HUMAN
		DEC  HL			;SAMME BYTE
		CALL DEKOD2		;DELAY
		POP  BC
		DJNZ LFOLOOP
		;
		;
		;
		;
		;
		LD	 B,3		;3*OSC BLK
OSCLOOP PUSH BC
		CALL DEKOD16	;OCT/SEMITONE
		CALL DEKOD10	;FINE
		CALL DEKOD9		;MOD SRC 2
		DEC  HL			;SAMME BYTE
		CALL DEKOD8		;MOD SRC 1
		CALL DEKOD1		;MOD AMT 1
		CALL DEKOD1		;MOD AMT 2
		CALL DEKOD17	;WAVEFORM
		CALL DEKOD7		;DCA ENABLE
		DEC  HL			;SAMME BYTE
		CALL DEKOD12	;DCA LEVEL
		CALL DEKOD9		;DCA MODSRC2
		DEC  HL			;SAMME BYTE
		CALL DEKOD8		;DCA MODSRC1
		CALL DEKOD1		;DCA MODAMT1
		CALL DEKOD1		;DCA MODAMT2
		POP	 BC
		DJNZ OSCLOOP
		;
		CALL DEKOD7		;AM
		DEC  HL
		CALL DEKOD12	;DCA4 MOD AMT
		CALL DEKOD7		;SYNC
		DEC  HL			;SAMME BYTE
		CALL DEKOD13	;FILTER
		CALL DEKOD11	;Q
		CALL DEKOD9		;MOD SRC 2
		DEC  HL			;SAMME BYTE
		CALL DEKOD8		;MOD SRC 1
		CALL DEKOD7		;ROTATE
		DEC  HL			;SAMME BYTE
		CALL DEKOD14	;MOD AMT 1
		CALL DEKOD7		;MONO
		DEC  HL			;SAMME BYTE
		CALL DEKOD14	;MOD AMT 2
		CALL DEKOD7		;ENV RES
		DEC  HL			;SAMME BYTE
		CALL DEKOD12	;MOD AMT 3
		CALL DEKOD7		;OSC W RES
		DEC  HL			;SAMME BYTE
		CALL DEKOD2		;GLIDE
		CALL DEKOD15	;SPL DIR
		DEC  HL
		CALL DEKOD13	;SPL PNT
		CALL DEKOD7		;LAYER FLAGG
		DEC  HL
		CALL DEKOD13	;LAY PRG
		CALL DEKOD13	;SPL PRG
		CALL DEKOD7		;S/L FLAGG
		DEC  HL
		CALL DEKOD13	;S/L PRG
		CALL DEKOD18	;PAN
		DEC  HL
		CALL DEKOD8		;PAN MOD SRC
		CALL DEKOD7		;CYCLE
		DEC  HL
		CALL DEKOD14	;PAN MOD AMT
		;
		;
		;
		;
DISPAR	LD	 HL,PARBLK
		LD	 DE,0
		LD	 BC,#03C0
		CALL LDIRVM
		RET
;	-	-	-	-	-	-	-	-
		;
		;
		;
;DEKOD.LIB
;DEKOD-SUBRUTINER FOR ESQ-1
;PROGRAMCONTROL-BLOKK
;TIL DISPAR-BLOKK
		;
		;
DEKNAM	LD	 BC,6		;NAVNLENGDE
		LDIR
		CALL FRSTPAR
		RET
		;
DEKOD1	LD	 A,(HL)
		RRCA			;BIT 0 UBRUKT
		AND	 #7F		;MASKER BIT 7
		CALL TEGN6		;SJEKK FORTEGN
		AND  #3F		;MASK BIT 7&6
		CALL BINDEC2	;KONV. TIL
		CALL NXTPAR
		RET				;2-SIFR ASCII
		;
DEKOD12	LD	 A,(HL)
		JR	 DEK2312
DEKOD2	LD	 A,(HL)
		JR	 DEKOD23
DEKOD3	LD	 A,(HL)
		RRCA			;BIT 765432
DEK2312	RRCA			;TIL 543210
DEKOD23	AND  #3F		;MASK BIT 7&6
		CALL BINDEC2	;KONV. TIL
		CALL NXTPAR
		RET				;2-SIFR ASCII
		;
DEKOD4	LD	 A,(HL)
		AND  #C0		;MASK 543210
		LD	 B,A		;SAVE
		INC  HL			;NESTE BITS
		LD	 A,(HL)		;ER I NESTE B
		AND  #C0		;MASK 543210
		RRCA			;BIT 7&6
		RRCA			;TIL 5&4
		OR	 B			;HENT BIT 5&4
		RRCA
		RRCA
		RRCA			;BIT 7654
		RRCA			;TIL 3210
		DEC  HL			;GML VERDI
		LD	 BC,MODTAB	;TABELLADRESSE
		CALL BINMOD		;MOD NR. I A
		RET
		;
DEKOD5	LD	 A,(HL)
		RLCA			;BIT 7&6
		RLCA			;TIL 1&0
		AND	 #03		;MASK RESTEN
		LD	 BC,LFWATAB	;LFO WAVETAB
		CALL BINMOD		;WAVEFRM NR.
		RET				;I A-REG
		;
DEKOD6	BIT	 6,(HL)		;TEST FLAGG
		JR	 DEKOD67
DEKOD7	BIT	 7,(HL)
DEKOD67 PUSH HL
		JR	 Z,AV67		;FLAGG=0 ?
		LD	 HL,SON		;STR.ADRESSE
		JR	 PAA67
AV67	LD	 HL,SOFF
PAA67	LD	 BC,3		;STR.LENGDE
		LDIR			;FLYTT STRENG
		POP  HL
		CALL NXTPAR
		RET				;TIL(DE)
		;
DEKOD15	BIT	 7,(HL)
		PUSH HL
		JR	 Z,LOVER	;FLAGG=0 ?
		LD	 HL,SUPPER	;STR.ADRESSE
		JR	 UPER
LOVER	LD	 HL,SLOWER
UPER	EX	 (SP),HL	;SAVE STR.ADR
		INC  HL			;HOPP 2 BYTES
		INC  HL			;TIL NESTE
		BIT  7,(HL)		;FLAGGTEST
		EX	 (SP),HL	;HENT STR.ADR
		JR	 NZ,PAA15	;HOPP HVIS ON
		LD	 HL,SOFF
PAA15	LD	 BC,5		;STR.LENGDE
		LDIR			;FLYTT STRENG
		POP  HL			;HENT PCB-ADR
		DEC  HL			;HOPP TILBAKE
		DEC  HL			;2 BYTES
		CALL NXTPAR
		RET				;TIL(DE)
		;
DEKOD8	LD	 A,(HL)
		JR	 DEKOD89
DEKOD9	LD	 A,(HL)
		RRCA			;BIT 7654
		RRCA			;TIL 3210
		RRCA
		RRCA
DEKOD89 AND  #0F		;MASK 7654
		LD	 BC,MODTAB	;TABELLADRESSE
		CALL BINMOD		;KONV.TIL
		RET				;STRENG
		;
DEKOD11 LD	 A,(HL)
		JR	 DEK1011
DEKOD10 LD	 A,(HL)
		RRCA			;BIT 76543
		RRCA			;TIL 43210
		RRCA
DEK1011	AND	 #1F		;MASK 765
		CALL BINDEC2	;KONV. TIL
		CALL NXTPAR
		RET				;2-SIF ASCII
		;
DEKOD13 LD	 A,(HL)
		AND	 #7F		;MASK BIT 7
		CALL BINDEC3	;KONV. TIL
		CALL NXTPAR
		RET				;3-SIFR ASCII
		;
DEKOD14 LD	 A,(HL)
		CALL TEGN6		;SJEKK TEGN
		AND	 #3F		;MASK BIT 7&6
		CALL BINDEC2	;KONV. TIL
		CALL NXTPAR
		RET				;2-SIFR ASCII
		;
DEKOD18 LD	 A,(HL)
		RRCA			;BIT 7654
		RRCA			;TIL 3210
		RRCA
		RRCA
		AND  #0F		;MASK 7654
		CALL BINDEC2	;2-SIF ASCII
		CALL NXTPAR
		RET
		;
DEKOD16 LD	 A,(HL)
		AND  #7F		;MASK BIT 7
		CALL BINOCT		;OKTAV OG
		RET				;SEMITONE
		;
DEKOD17	LD	 A,(HL)
		AND  #1F		;MASK 765
		LD	 BC,WAVTAB	;TABELLADRESSE
		CALL BINWAV		;KONV.TIL
		RET				;STRENG
		;
		;
BINDEC3 LD	 B,#FF		;100-SIFFER
D100LP	INC	 B			;NULLSTILLES
		SUB	 100		;A<100 ?
		JR	 NC,D100LP	;HVIS IKKE,
		ADD	 A,100		;+100
		CALL ASC2DE		;SKRIV 100SIF
BINDEC2 LD	 B,#FF		;10-SIFFER
D10LP	INC  B			;NULLSTILLES
		SUB  10			;A<10 ?
		JR	 NC,D10LP	;HVIS IKKE,
		ADD  A,10		;+10
		CALL ASC2DE		;SKRIV 10SIF
BINDEC1 LD	 B,A		;1-SIFRET
		CALL ASC2DE		;SKRIVES
		RET
		;
BINOCT	LD	 B,#FC		;= -4
DOCTLP	INC	 B			;NEDERSTE OKT
		SUB	 12			;A<12 ?
		JR	 NC,DOCTLP	;HVIS IKKE,
		ADD	 A,12		;+12
		PUSH AF			;SAVE
		LD	 A,B		;OCT TIL A
		CALL TEGN7		;TEST FORTEGN
		LD	 B,A		;OCT TIL B
		CALL ASC2DE		;SKRIV OCT
		INC  DE			;LAG MELLOMROM
		POP  AF			;HENT
		LD	 B,#FF		;10-SIFFER
DSEMLP	INC  B			;NULLSTILLES
		SUB  10			;A<10 ?
		JR	 NC,DSEMLP	;HVIS IKKE,
		ADD  A,10		;+10
		CALL ASC2DE		;SKRIV 10SIF
		LD	 B,A		;1-SIFRET
		CALL ASC2DE		;SKRIVES
		CALL NXTPAR		;DIREKTE
		RET
		;
ASC2DE	LD	 C,A		;SAVE A
		LD	 A,B		;SIFF FRA B
		ADD  A,"0"		;KONV TIL ASC
		LD	 (DE),A		;OG SKRIV UT
		INC  DE			;NESTE ADR.
		LD	 A,C		;HENT A
		RET
		;
		;
BINMOD	PUSH HL			;BASEADR.I BC
		PUSH DE			;MOD.NR. I A
		ADD  A,A		;DOBLER NR.
		LD	 L,A		;KONV.TIL
		LD	 H,0		;16-BIT
		ADD  HL,BC		;RETT ADRESSE
		LD	 E,(HL)		;STRINGADR.
		INC  HL			;TIL DE
		LD	 D,(HL)		;OG DERETTER
		EX	 DE,HL		;TIL HL
		POP  DE			;DEST.ADRESSE
		LD	 BC,5		;STR.LENGDE
		LDIR			;SKRIV STRENG
		POP	 HL
		CALL NXTPAR
		RET
		;
		;
BINWAV	PUSH HL			;BASEADR.I BC
		PUSH DE			;WAVE NR. I A
		ADD  A,A		;DOBLER NR.
		LD	 L,A		;KONV.TIL
		LD	 H,0		;16-BIT
		ADD  HL,BC		;RETT ADRESSE
		LD	 E,(HL)		;STRINGADR.
		INC  HL			;TIL DE
		LD	 D,(HL)		;OG DERETTER
		EX	 DE,HL		;TIL HL
		POP  DE			;DEST.ADRESSE
		LD	 BC,6		;STR.LENGDE
		LDIR			;SKRIV STRENG
		POP	 HL
		CALL NXTPAR
		RET
			;
TEGN6	BIT	 6,A		;TEST FORTEGN
		JR	 TEGN67
TEGN7	BIT  7,A		;HOPP HVIS
TEGN67	JR	 Z,PLUSS	;FLAGG=0
		NEG				;KONV.TIL +
		LD	 C,A		;SAVE A
		LD	 A,"-"		;SKRIV UT
		JR	 MINUS		;MINUSTEGN
PLUSS	LD	 C,A
		LD	 A,"+"		;ELLER
MINUS	LD	 (DE),A		;PLUSSTEGN
		INC  DE			;OPPDATER
		LD	 A,C		;HENT DATA
		RET
		;
		;
NXTPAR  INC  HL			;NY PCB-BYTE
FRSTPAR LD	 E,(IX+0)	;HENT NY
		INC  IX			;PARBLK-ADRES.
		LD	 D,(IX+0)
		INC  IX
		RET
		;
;STABLES.LIB
;STRING TABELLER
		;
MODTAB	DEFW SLFO1
		DEFW SLFO2
		DEFW SLFO3
		DEFW SENV1
		DEFW SENV2
		DEFW SENV3
		DEFW SENV4
		DEFW SVEL
		DEFW SVEL2
		DEFW SKBD
		DEFW SKBD2
 		DEFW SWHEEL
		DEFW SPEDAL
		DEFW SXCTRL
		DEFW SPRESS
		DEFW S_OFF_
		;
SLFO1	DEFM "LFO1 "
SLFO2	DEFM "LFO2 "
SLFO3	DEFM "LFO3 "
SENV1	DEFM "Env1 "
SENV2	DEFM "Env2 "
SENV3	DEFM "Env3 "
SENV4	DEFM "Env4 "
SVEL	DEFM "Vel  "
SVEL2	DEFM "Vel2 "
SKBD	DEFM "Kbd  "
SKBD2	DEFM "Kbd2 "
SWHEEL	DEFM "Wheel"
SPEDAL	DEFM "Pedal"
SXCTRL	DEFM "Xctrl"
SPRESS	DEFM "Press"
S_OFF_	DEFM "*Off*"
		;
LFWATAB DEFW STRI
		DEFW SSAW
		DEFW SSQR
		DEFW SNOI
		;
STRI	DEFM "Tri  "
SSAW	DEFM "Saw  "
SSQR	DEFM "Sqr  "
SNOI	DEFM "Noi  "
		;
WAVTAB	DEFW SSAWW
		DEFW SBELL
		DEFW SSINE
		DEFW SSQUARE
		DEFW SPULSE
		DEFW SNOISE1
		DEFW SNOISE2
		DEFW SNOISE3
		DEFW SBASS
		DEFW SPIANO
		DEFW SEL_PNO
		DEFW SVOICE1
		DEFW SVOICE2
		DEFW SKICK
		DEFW SREED
		DEFW SORGAN
		DEFW SSYNTH1
		DEFW SSYNTH2
		DEFW SSYNTH3
		DEFW SFORMT1
		DEFW SFORMT2
		DEFW SFORMT3
		DEFW SFORMT4
		DEFW SFORMT5
		DEFW SPULSE2
		DEFW SSQR_2
		DEFW S4_OCTS
		DEFW SPRIME
		DEFW SBASS_2
		DEFW SE_PNO2
		DEFW SOCTAVE
		DEFW SOCT_5
		;
SSAWW	DEFM "Saw   "
SBELL	DEFM "Bell  "
SSINE	DEFM "Sine  "
SSQUARE	DEFM "Sqare "
SPULSE	DEFM "Pulse "
SNOISE1	DEFM "Noise1"
SNOISE2	DEFM "Noise2"
SNOISE3	DEFM "Noise3"
SBASS	DEFM "Bass  "
SPIANO	DEFM "Piano "
SEL_PNO	DEFM "El Pno"
SVOICE1	DEFM "Voice1"
SVOICE2	DEFM "Voice2"
SKICK	DEFM "Kick  "
SREED	DEFM "Reed  "
SORGAN	DEFM "Organ "
SSYNTH1	DEFM "Synth1"
SSYNTH2	DEFM "Synth2"
SSYNTH3	DEFM "Synth3"
SFORMT1	DEFM "Formt1"
SFORMT2	DEFM "Formt2"
SFORMT3	DEFM "Formt3"
SFORMT4	DEFM "Formt4"
SFORMT5	DEFM "Formt5"
SPULSE2	DEFM "Pulse2"
SSQR_2	DEFM "Sqr 2 "
S4_OCTS	DEFM "4 Octs"
SPRIME	DEFM "Prime "
SBASS_2	DEFM "Bass 2"
SE_PNO2	DEFM "ElPno2"
SOCTAVE	DEFM "Octave"
SOCT_5	DEFM "Oct+5 "
		;
SON		DEFM "On   "
SOFF	DEFM "Off  "
		;
SUPPER	DEFM "Upper"
SLOWER	DEFM "Lower"
		;
PARPEK	DEFW PROGNAM;NAVN
		DEFW PAR0	;ENV1
		DEFW PAR1
		DEFW PAR2
		DEFW PAR5
		DEFW PAR6
		DEFW PAR7
		DEFW PAR8
		DEFW PAR3
		DEFW PAR4
		DEFW PAR9
		;
		DEFW PAR10	;ENV2
		DEFW PAR11
		DEFW PAR12
		DEFW PAR15
		DEFW PAR16
		DEFW PAR17
		DEFW PAR18
		DEFW PAR13
		DEFW PAR14
		DEFW PAR19
		;
		DEFW PAR20	;ENV3
		DEFW PAR21
		DEFW PAR22
		DEFW PAR25
		DEFW PAR26
		DEFW PAR27
		DEFW PAR28
		DEFW PAR23
		DEFW PAR24
		DEFW PAR29
		;
		DEFW PAR30	;ENV4
		DEFW PAR31
		DEFW PAR32
		DEFW PAR35
		DEFW PAR36
		DEFW PAR37
		DEFW PAR38
		DEFW PAR33
		DEFW PAR34
		DEFW PAR39
		;
		DEFW PAR43	;LFO1
		DEFW PAR40
		DEFW PAR47
		DEFW PAR44
		DEFW PAR46
		DEFW PAR41
		DEFW PAR42
		DEFW PAR45
		;
		DEFW PAR51	;LFO2
		DEFW PAR48
		DEFW PAR55
		DEFW PAR52
		DEFW PAR54
		DEFW PAR49
		DEFW PAR50
		DEFW PAR53
		;
		DEFW PAR59	;LFO3
		DEFW PAR56
		DEFW PAR63
		DEFW PAR60
		DEFW PAR62
		DEFW PAR57
		DEFW PAR58
		DEFW PAR61
		;
		DEFW PAR64	;OSC1
		DEFW PAR66
		DEFW PAR70
		DEFW PAR68
		DEFW PAR69
		DEFW PAR71
		DEFW PAR67
		;
		DEFW PAR89	;DCA1
		DEFW PAR88
		DEFW PAR92
		DEFW PAR90
		DEFW PAR91
		DEFW PAR93
		;
		DEFW PAR72	;OSC2
		DEFW PAR74
		DEFW PAR78
		DEFW PAR76
		DEFW PAR77
		DEFW PAR79
		DEFW PAR75
		;
		DEFW PAR95	;DCA2
		DEFW PAR94
		DEFW PAR98
		DEFW PAR96
		DEFW PAR97
		DEFW PAR99
		;
		DEFW PAR80	;OSC3
		DEFW PAR82
		DEFW PAR86
		DEFW PAR84
		DEFW PAR85
		DEFW PAR87
		DEFW PAR83
		;
		DEFW PAR101	;DCA3
		DEFW PAR100
		DEFW PAR104
		DEFW PAR102
		DEFW PAR103
		DEFW PAR105
		;
		DEFW PAR117	;AM
		DEFW PAR106	;DCA4
		DEFW PAR120 ;SYNC
		DEFW PAR110 ;FILTER
		DEFW PAR111 ;Q
		DEFW PAR115 ;FMODSRC 2
		DEFW PAR113 ;FMODSRC 1
		DEFW PAR121 ;ROT
		DEFW PAR114 ;FMODA 1
		DEFW PAR119 ;MONO
		DEFW PAR116 ;FMODA 2
		DEFW PAR122 ;ENV RES
		DEFW PAR112 ;FMODA 3
		DEFW PAR123 ;OSC RES
		DEFW PAR118 ;GLIDE
		DEFW PAR129 ;SPL DIR
		DEFW PAR131 ;SPL PNT
		DEFW PAR125 ;LAY FLAGG
		DEFW PAR126 ;LAY PRG
		DEFW PAR130 ;SPL PRG
		DEFW PAR127 ;S/L FLAGG
		DEFW PAR128 ;S/L PRG
		DEFW PAR107 ;PAN
		DEFW PAR108 ;PAN MOD SRC
		DEFW PAR124 ;CYCLE
		DEFW PAR109 ;PAN MOD AMT
		;
PARBLK	DEFM "          "
		DEFM "Program: "
PROGNAM DEFM "------"
		DEFM "               "
		DEFM "     OctSemFin  Wave      Modulators    "
		DEFM "Osc1 "
PAR64	DEFM "+0 "
PAR65	DEFM "00 "
PAR66	DEFM "00  "
PAR67	DEFM "------ "
PAR68	DEFM "*Off*"
PAR69	DEFM "+00 "
PAR70	DEFM "*Off*"
PAR71	DEFM "+00 "
		DEFM "Osc2 "
PAR72	DEFM "+0 "
PAR73	DEFM "00 "
PAR74	DEFM "00  "
PAR75	DEFM "------ "
PAR76	DEFM "*Off*"
PAR77	DEFM "+00 "
PAR78	DEFM "*Off*"
PAR79	DEFM "+00 "
		DEFM "Osc3 "
PAR80	DEFM "+0 "
PAR81	DEFM "00 "
PAR82	DEFM "00  "
PAR83	DEFM "------ "
PAR84	DEFM "*Off*"
PAR85	DEFM "+00 "
PAR86	DEFM "*Off*"
PAR87	DEFM "+00 "
		;
		DEFM "DCA1 Level:"
PAR88	DEFM "00  "
PAR89	DEFM "Off "
		DEFM "   "
PAR90	DEFM "*Off*"
PAR91	DEFM "+00 "
PAR92	DEFM "*Off*"
PAR93	DEFM "+00 "
		;
		DEFM "DCA2 Level:"
PAR94	DEFM "00  "
PAR95	DEFM "Off "
		DEFM "   "
PAR96	DEFM "*Off*"
PAR97	DEFM "+00 "
PAR98	DEFM "*Off*"
PAR99	DEFM "+00 "
		;
		DEFM "DCA3 Level:"
PAR100	DEFM "00  "
PAR101	DEFM "Off "
		DEFM "   "
PAR102	DEFM "*Off*"
PAR103	DEFM "+00 "
PAR104	DEFM "*Off*"
PAR105	DEFM "+00 "
		;
		DEFM "FiFrq:"
PAR110	DEFM "000 "
		DEFM "Q:"
PAR111	DEFM "00 "
		DEFM "Kbd:"
PAR112	DEFM "00 "
PAR113	DEFM "*Off*"
PAR114	DEFM "+00 "
PAR115	DEFM "*Off*"
PAR116	DEFM "+00 "
		;
		DEFM "DCA4 Env4:"
PAR106	DEFM "00 "
		DEFM "    Pan:"
PAR107	DEFM "00 "
		DEFM "PanMod:"
PAR108	DEFM "*Off*"
PAR109	DEFM "+00 "
		;
		DEFM "     Freq Res Hum Wave  L1 Del L2 Mod   "
		DEFM "LFO1  "
PAR40	DEFM "00  "
PAR41	DEFM "Off "
PAR42	DEFM "Off "
PAR43	DEFM "---   "
PAR44	DEFM "00  "
PAR45	DEFM "00 "
PAR46	DEFM "00 "
PAR47	DEFM "*Off* "
		;
		DEFM "LFO2  "
PAR48	DEFM "00  "
PAR49	DEFM "Off "
PAR50	DEFM "Off "
PAR51	DEFM "---   "
PAR52	DEFM "00  "
PAR53	DEFM "00 "
PAR54	DEFM "00 "
PAR55	DEFM "*Off* "
		;
		DEFM "LFO3  "
PAR56	DEFM "00  "
PAR57	DEFM "Off "
PAR58	DEFM "Off "
PAR59	DEFM "---   "
PAR60	DEFM "00  "
PAR61	DEFM "00 "
PAR62	DEFM "00 "
PAR63	DEFM "*Off* "
		;
		DEFM "      L1  L2  L3 LV T1V T1 T2 T3 T4 TK  "
		DEFM "Env1 "
PAR0	DEFM "+00 "
PAR1	DEFM "+00 "
PAR2	DEFM "+00 "
PAR3	DEFM "00  "
PAR4	DEFM "00 "
PAR5	DEFM "00 "
PAR6	DEFM "00 "
PAR7	DEFM "00 "
PAR8	DEFM "00 "
PAR9	DEFM "00  "
		;
		DEFM "Env2 "
PAR10	DEFM "+00 "
PAR11	DEFM "+00 "
PAR12	DEFM "+00 "
PAR13	DEFM "00  "
PAR14	DEFM "00 "
PAR15	DEFM "00 "
PAR16	DEFM "00 "
PAR17	DEFM "00 "
PAR18	DEFM "00 "
PAR19	DEFM "00  "
		;
		DEFM "Env3 "
PAR20	DEFM "+00 "
PAR21	DEFM "+00 "
PAR22	DEFM "+00 "
PAR23	DEFM "00  "
PAR24	DEFM "00 "
PAR25	DEFM "00 "
PAR26	DEFM "00 "
PAR27	DEFM "00 "
PAR28	DEFM "00 "
PAR29	DEFM "00  "
		;
		DEFM "Env4 "
PAR30	DEFM "+00 "
PAR31	DEFM "+00 "
PAR32	DEFM "+00 "
PAR33	DEFM "00  "
PAR34	DEFM "00 "
PAR35	DEFM "00 "
PAR36	DEFM "00 "
PAR37	DEFM "00 "
PAR38	DEFM "00 "
PAR39	DEFM "00  "
		;
		DEFM "     Sync AM Mono Glide Vc  Env Osc Cyc "
		DEFM "Modes "
PAR120	DEFM "Off "
PAR117	DEFM "Off "
PAR119	DEFM "Off   "
PAR118	DEFM "00  "
PAR121	DEFM "Off "
PAR122	DEFM "Off "
PAR123	DEFM "Off "
PAR124	DEFM "Off "
		;
		DEFM "Split/Layer:"
PAR127	DEFM "Off "
PAR128	DEFM "------ "
		DEFM "Layer:"
PAR125	DEFM "Off "
PAR126	DEFM "------ "
		DEFM "    Split:"
PAR129	DEFM "Off   "
PAR130	DEFM "------ "
		DEFM " SplitKey:"
PAR131	DEFM "060    "
		;
		DEFM "                                        "
;-----------------------------------
ENDA	NOP
;-----------------------------------
