SERVICEASM;---	SERVICE.KCC	---
;
;Adressen: BE00 BFFF BFC3
;
;		` ml 29.12.90
;----------------------------
ARGN	EQU 0B781H
ARG1	EQU ARGN+1
ARG2	EQU ARG1+2
NUMVX	EQU 0B797H
PV1	EQU 0F003H
WAIT	EQU 14H
INLIN	EQU 17H
ERRM	EQU 19H
AHEX	EQU 1CH
OSTR	EQU 23H
OCHR	EQU 24H
;-------
	ORG 0BE00H
	CP 8
	RET NC		;wenn>8
	ADD A
	LD HL,TAB
	ADD L
	LD L,A
	LD A,M
	INC HL
	LD H,M
	LD L,A
	JP (HL)		;Ansprung
;-------
TAB	DEFW FLOAD
	DEFW FSAVE
	DEFW DIR
	DEFW STAT
	DEFW REN
	DEFW SETRO
	DEFW SETWR
	DEFW ERA
;-------
FLOAD	LD HL,0
	CALL NAMOUT
	JR FLO
;------------------
	DEFW 7F7FH
	DEFM 'FLOAD'
	DEFB 1
	CALL NAME
FLO	EX (SP),HL
	LD (NUMVX),HL
	EX (SP),HL
	LD A,9		;Lesen open
	CALL STEUER
	JR NZ,ERROR
	LD BC,90F2H
	IN A,(C)	;ARGN
	CP 2
	JR C,ERR2	;wenn<2
	CP 10
	JR NC,ERR2	;wenn>10
	INC B
	IN L,(C)
	INC B
	IN H,(C)	;HL=Ladeadr
	INC B
	IN E,(C)
	INC B
	IN D,(C)	;DE=Endadr
	CP 3
	JR C,NST1	;keine Startadr
	PUSH HL
	INC B
	IN L,(C)
	INC B
	IN H,(C)	;Startadr
	EX (SP),HL
NST1	PUSH AF
	LD A,(ARGN)
	AND A
	JR Z,NOFF	;ohne Offset
	LD BC,(ARG1)	;Offset
	ADD HL,BC
	POP AF
	JR C,NST2	;keine Startadr
	EX (SP),HL
	ADD HL,BC
	EX (SP),HL
NST2	EX DE,HL
	ADD HL,BC
	EX DE,HL
	PUSH AF
NOFF	POP AF
LST	LD A,1		;Lesen normal
	CALL STEUER
	JR Z,LOAD
ERROR	POP HL
	LD HL,(NUMVX)
	PUSH HL
ERR1	LD BC,81F3H
	IN A,(C)
	CALL PV1
	DEFB AHEX
ERR2	CALL PV1
	DEFB ERRM
	RET
;-------
LOAD	DEC C
LOA	INI
	INC B
	INC B
	PUSH HL
	SBC HL,DE
	POP HL
	RET NC		;wenn ENDE
	LD A,B
	AND A
	JR NZ,LOA
	JR LST
;-------
FSAVE	LD HL,0
	CALL NAMOUT
	JR FSA
;-------------------
	DEFW 7F7FH
	DEFM 'FSAVE'
	DEFB 1
	CALL NAME
FSA	LD A,(ARGN)
	CP 2
	JR C,ERR2	;wenn<2
	LD HL,ARGN
	LD DE,0B0BH	;Schreib open
	LD BC,91F2H
SAVE	OUTI
	INC B
	INC B
	DEC E
	JR NZ,SAVE
	LD A,D
	CALL STEUER
	LD A,0
	LD (ARGN),A
	JR Z,NERR
	JP ERR1
NERR	LD BC,81F2H
	BIT 3,D
	JR Z,SOPE	;wenn open
	LD HL,(ARG1)
SOPE	PUSH HL
	LD DE,(ARG2)
	AND A
	SBC HL,DE
	POP HL
	LD BC,81F2H
	LD DE,0380H	;Schreib normal
	JR NC,SCLO
	JR SAVE
SCLO	LD A,43H	;Schreib close
	CALL STEUER
	JP NZ,ERR1
	RET
;-------
	DEFW 0DDDDH	;f. EDAS
	DEFM 'DIR'
	DEFB 1
	JR DIR
;--------------------
	DEFW 7F7FH
	DEFM 'DIR'
	DEFB 1
DIR	LD A,0DH	;Directory open
WDI	CALL STEUER
	JP NZ,ERR1
	BIT 2,A		;Ende
	RET NZ
	LD E,38
	CALL ANZ
	LD A,05H	;Dir weiter
	JR WDI
;-------------------
	DEFW 7F7FH
	DEFM 'STAT'
	DEFB 1
STAT	LD A,15H	;Status
	CALL STEUER
	JP NZ,ERR1
	LD E,20
ANZ	LD B,82H
ANZW	IN A,(C)
	INC B
	PUSH DE
	PUSH BC
	CALL PV1
	DEFB OCHR
	POP BC
	POP DE
	DEC E
	JR NZ,ANZW
	RET
;-------------------
	DEFW 7F7FH
	DEFM 'REN'
	DEFB 1
REN	CALL NAME
	LD A,29H	;Ren old
	CALL STEUER
	CALL NAME
	LD A,21H	;Ren new
OUT	CALL STEUER
	JP NZ,ERR1
	RET
;-------------------
	DEFW 7F7FH
	DEFM 'ERA'
	DEFB 1
ERA	CALL NAME
	LD A,11H	;Era
	JR OUT
;-------------------
	DEFW 7F7FH
	DEFM 'SETRO'
	DEFB 1
SETRO	CALL NAME
	LD A,25H	;Setro
	JR OUT
;-------------------
	DEFW 7F7FH
	DEFM 'SETWR'
	DEFB 1
SETWR	CALL NAME
	LD A,31H	;Setwr
	JR OUT
;-------
NAME	CALL PV1
	DEFB OSTR
	DEFM 'Name :'
	DEFB 0
	CALL PV1
	DEFB INLIN
	LD HL,6
	ADD HL,DE
NAMOUT	LD E,12
	LD BC,82F3H
NAM	LD A,M
	OUT (C),A
	INC HL
	INC B
	DEC E
	JR NZ,NAM
	LD B,80H
	RET
;-------
STEUER	LD BC,80F3H
	OUT (C),A
STEU	PUSH BC
	LD A,1
	CALL PV1
	DEFB WAIT
	POP BC
	IN A,(C)
	BIT 0,A
	JR NZ,STEU	;fertig ?
	BIT 7,A		;Fehler ?
	RET
;-------
START	LD HL,BAS
	LD DE,00D8H	;f. BASIC
	LD BC,21H
	LDIR
	RET
;BASIC-Schnittstelle:
;--------------------
BAS	LD A,0	;CALL*D8
	DEFB 1		;LD BC,13EH
	LD A,1	;CALL*DB
	DEFB 1		;LD BC,23EH
	LD A,2	;CALL*DE
	DEFB 1		;LD BC,33EH
	LD A,3	;CALL*E1
	DEFB 1		;LD BC,43EH
	LD A,4	;CALL*E4
	DEFB 1		;LD BC,53EH
	LD A,5	;CALL*E7
	DEFB 1		;LD BC,63EH
	LD A,6	;CALL*EA
	DEFB 1		;LD BC,73EH
	LD A,7	;CALL*ED
	CALL 0F018H	;IRM ON
	CALL 0BE00H
	CALL 0F01BH	;IRM OFF
	RET
;BFF0H
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP		;>
	NOP		;=-> frei
	NOP		;>
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
;C000H
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ