PAGE 66
TITLE ' MONITOR PROF-80 CPU KARTE VERSION 1.3 '

              ASEG
              .Z80

              ORG 00000H

 
; SYSTEMEQUATES

EPROM                   EQU  00000H
SYSTEMPAGE              EQU  0FF00H
P$RAM$TABLE             EQU  0DEH

; PARALLEL EINGABE PORT

P$TIME$IN               EQU  0DBH

P$IN$LS258$A            EQU  0DAH
P$IN$LS258$B            EQU  0DBH

MASK$RX                 EQU  001H
MASK$MOT                EQU  001H
MASK$CTS                EQU  010H
MASK$IO                 EQU  010H
MASK$INDEX              EQU  020H
MASK$BAUD               EQU  020H
MASK$CTSP               EQU  080H
TIME$DATA$MASK          EQU  080H

; PARALLEL AUSGABE PORT

P$TIME$OUT              EQU  0D8H
P$LS259                 EQU  0D8H
PAD$POLEN               EQU  070H
PAD$MOTOR               EQU  060H
PAD$INUSE               EQU  050H
PAD$CO                  EQU  000H 
PAD$CLK                 EQU  040H
PAD$READY               EQU  030H
PAD$RESF                EQU  0F0H
PAD$MINI                EQU  0F2H
PAD$STB                 EQU  0FCH
PAD$TX                  EQU  0F6H 
PAD$MOTAB               EQU  0F8H
PAD$RTS                 EQU  0F4H 
PAD$TXP                 EQU  0FAH
PAD$INIT                EQU  0FEH

; FLOPPY CONTROLLER

FDC                     EQU  0DCH
FDD                     EQU  0DDH
HLO                     EQU  0240D
SRT                     EQU  006D
HUT                     EQU  0240D
HLOS                    EQU  ((HLO)/2)*2
HUTS                    EQU  ((HUT)+15)/16
SRTS                    EQU  16-SRT

; GRIP PORTS

GRIPSTATUSPORT          EQU  0C0H
GRIPDATENPORT           EQU  0C1H

GRIPINSTATUSMASKE       EQU  080H 
GRIPOUTSTATUSMASKE      EQU  040H

BELL                    EQU  007H
CLRSCR                  EQU  01AH
PRNTBAUD                EQU  003H
TOLERANZ                EQU  040H

BOOTADR                 EQU  0FA00H
MSTACK                  EQU  0FEE6H
LSAVE                   EQU  0FEFAH
HSAVE                   EQU  0FEFBH
PSAVE                   EQU  0FEFCH
SSAVE                   EQU  0FEFEH

RWPOLL                  EQU  0FF00H
TEMP                    EQU  0FF03H
BAUD$JUMPERBYTE         EQU  0FF04H
CLKFLG                  EQU  0FF05H
DISKFLG                 EQU  0FF06H
SYSTEMTAKT              EQU  0FF07H
DISPADR                 EQU  0FF09H
EOTSAVE                 EQU  0FF0BH
EOTFLG                  EQU  0FF0CH
RWCMD                   EQU  0FF0DH
ERMSG                   EQU  0FF0EH

IO$JUMPERBYTE           EQU  0FF13H
PHYS$TIME               EQU  0FF14H       
SHIFT$CONT              EQU  0FF19H
SOFTVERZ                EQU  0FF1EH

TEST$TYPE               EQU  0FF23H
TEST$MSEK               EQU  0FF24H
TEST$TRACK              EQU  0FF25H
UMLEIT$NMI              EQU  0FF26H
BANK$ERR$BYTE           EQU  0FF29H
DMAADR                  EQU  0FF2AH
SECTCNT                 EQU  0FF2CH
UMLEIT$GETCM            EQU  0FF2DH

CMDTAB                  EQU  0FF33H
UNIT                    EQU  0FF34H
TRACK                   EQU  0FF35H
HEAD                    EQU  0FF36H
SECTOR                  EQU  0FF37H
SECSZ                   EQU  0FF38H
EOT                     EQU  0FF39H
GAPLL                   EQU  0FF3AH
DTLL                    EQU  0FF3BH
UMLEIT$CONST            EQU  0FF3CH
SEEKNR                  EQU  0FF3FH

REST                    EQU  0FF43H
UMLEIT$CONIN            EQU  0FF4AH
UMLEIT$CONOUT           EQU  0FF4DH

IN$BUFF$END             EQU  0FF53H
IN$BUFF$ZEIG            EQU  0FF5EH
DERMSG                  EQU  0FF63H
RWRETRY                 EQU  0FF64H
WRITE$PRECOM            EQU  0FF65H
KENNUNG                 EQU  0FF66H
MON$VERS                EQU  0FF6DH
COMMON$PAGE             EQU  0FF6EH
CURRENT$BANK            EQU  0FF6FH

SOFTPRNTVERZ            EQU  0FF73H
READY$BYTE              EQU  0FF75H
EPROMZ                  EQU  0FF76H
DRIVETIMING             EQU  0FF79H



MONITOR:      JP   INIT
	      JP   START
CS:	      JP   UMLEIT$CONST
CI:	      JP   UMLEIT$CONIN
CO:	      JP   UMLEIT$CONOUT
	      JP   SETSEC$CNT
	      JP   BOOTERR
	      JP   SETCMDT
	      JP   RECAL
	      JP   SELDSK
	      JP   SETTRK
	      JP   SETSEC
	      JP   SETDMA
	      JP   READ
	      JP   WRITE
	      JP   GETMINIMAX
	      JP   START
	      JP   CONST

SERNR:	      DB   047H,04AH

RSTART7:      JP   RST$VERTEILER
	      JP   CONIN
	      JP   CONOUT
	      JP   TEST
	      JP   MOTO
	      JP   CMFD
	      JP   RESULT
	      JP   SEEK
	      JP   NEXT
	      JP   MULTIP
	      JP   DIVIDE
	      JP   INT$SERVICE
	      JP   GRAFIN
	      JP   GRAFOUT
	      JP   GRAFIST

VERSIONNR:    DB   013H
	      
              JP   UMLEIT$NMI
	      JP   GRAFOST
	      JP   SOFTIN
	      JP   SOFTOUT
	      JP   SOFTIST
	      JP   SOFTOST
USER1IN:      JP   SOFTIN
USER1OUT:     JP   SOFTOUT
USER1IST:     JP   SOFTIST
USER1OST:     JP   SOFTOST
USER2IN:      JP   SOFTIN
USER2OUT:     JP   SOFTOUT
USER2IST:     JP   SOFTIST
USER2OST:     JP   SOFTOST
USERINIT:     RET
              NOP
	      NOP
              JP   DISKERR
	      JP   SOFTPRNOUT
	      JP   SOFTPRNOST
	      JP   SET$PHYS$TIME
	      JP   READ$PHYS$TIME
	      JP   SET$SHIFT
	      JP   SET$DUPLEX$BAUD
	      JP   SET$SIMPLEX$BAUD
              JP   01429H

;**************************************************************************

RST$VERTEILER:PUSH AF
	      LD   A,(IO$JUMPERBYTE)
	      DEC  A
	      JR   NZ,RST$V1
	      IN   A,(P$IN$LS258$A)
	      AND  MASK$RX
	      JR   Z,RST$V1
	      POP  AF
	      JP   INT$SERVICE
 
RST$V1:	      POP  AF
	      JP   START
 
START:	      LD   (LSAVE),HL
	      POP  HL
	      LD   (PSAVE),HL
	      LD   (SSAVE),SP
	      LD   SP,LSAVE
	      PUSH AF
	      PUSH BC
	      PUSH DE
	      PUSH IX
	      PUSH IY
	      EX   AF,AF'
	      EXX
	      PUSH AF
	      PUSH BC
	      PUSH DE
	      PUSH HL
	      EXX
	      EX   AF,AF'
	      LD   A,I
	      LD   B,A
	      LD   A,R
	      LD   C,A
	      PUSH BC
	      LD   HL,SGNON
	      CALL SOUT

GETCM:	      LD   HL,MSTACK 
	      LD   SP,HL
	      LD   C,':'
	      CALL ECHO

GTC03:	      CALL GETCH1
	      CALL ECHO
	      LD   D,C
	      LD   HL,CMDMSG

GTC01:	      LD   A,D
	      CP   (HL)
	      JR   Z,GTC04

GTC02:	      INC  HL
	      LD   A,(HL)
	      CP   000H
	      JP   Z,ERROR
	      CP   '$'
	      JR   NZ,GTC02
	      INC  HL
	      JR   GTC01
 
GTC04:	      INC  HL
	      CALL SOUT
	      LD   A,D
	      LD   C,D
	      LD   BC,NCMDS
	      LD   HL,CTAB

GTC05:	      CP   (HL)
	      JP   Z,GTC10	
              INC  HL
	      DEC  C
	      JP   NZ,GTC05
	      JP   ERROR
 
GTC10:	      LD   HL,CADR
	      ADD  HL,BC
	      ADD  HL,BC
	      LD   A,(HL)
	      INC  HL
	      LD   H,(HL)
	      LD   L,A
	      JP   (HL)

;**************************************************************************

; DIESES MODUL ENTHAELT ALLE MONITOR BEFEHLS-ROUTINEN
 
DCMD:	      CALL GETHX
	      LD   H,B
	      LD   L,C
	      LD   A,D
	      JR   C,DCM30
	      CP   00DH
	      LD   HL,(DISPADR)
	      JR   NZ,DCM33

DCM31:	      LD   DE,000FFH
	      PUSH HL
	      ADD  HL,DE
	      EX   DE,HL
	      POP  HL
	      JR   DCM05
 
DCM30:	      CP   00DH
	      JR   Z,DCM31

DCM33:	      CALL GETHX
	      LD   A,D
	      CP   00DH
	      JP   NZ,ERROR
	      LD   D,B
	      LD   E,C
	      CALL HILO
	      JR   NC,DCM05
	      LD   D,H
	      LD   E,L

DCM05:	      CALL CROUT
	      LD   A,H
	      CALL NMOUT
	      LD   A,L
	      CALL NMOUT
	      LD   B,000H

DCM10:	      INC  B
	      LD   C,020H
	      CALL ECHO
	      LD   A,(HL)
	      CALL NMOUT
	      CALL BREAK
	      JP   C,DCM12
	      CALL HILO
	      JP   NC,DCM15

DCM12:	      INC  HL
	      CALL DCM20
	      CALL CROUT
	      LD   (DISPADR),HL
	      JP   GETCM
 
DCM15:	      INC  HL
	      LD   A,L
	      AND  00FH
	      JP   NZ,DCM10
	      CALL DCM20
	      JR   DCM05
 
DCM20:	      PUSH DE
	      PUSH HL
	      LD   C,020H
	      CALL CO
	      LD   C,03EH
	      CALL CO
	      LD   C,B

DCM23:	      DEC  HL
	      DJNZ DCM23
	      LD   B,C

DCM21:	      LD   A,(HL)
	      CP   020H
	      JR   C,DCM22
	      CP   07FH
	      JR   NC,DCM22
	      JR   DCM24

DCM22:	      LD   A,02EH

DCM24:	      LD   C,A
	      CALL CO
	      INC  HL
	      DJNZ DCM21
	      POP  HL
	      POP  DE
	      RET

;**************************************************************************
 
GCMD:	      CALL GETHX
	      JP   NC,GCM05
	      LD   A,D
	      CP   00DH
	      JP   NZ,ERROR
	      LD   HL,PSAVE
	      LD   (HL),C
	      INC  HL
	      LD   (HL),B
	      JP   GCM10
 
GCM05:	      LD   A,D
	      CP   00DH
	      JP   NZ,ERROR

GCM10:	      JP   RSTTF
 
;**************************************************************************

MCMD:	      LD   C,003H
	      CALL GETNM
	      POP  BC
	      POP  HL
	      POP  DE

MCM05:	      PUSH HL
	      LD   H,D
	      LD   L,E
	      LD   A,(HL)
	      LD   H,B
	      LD   L,C
	      LD   (HL),A
	      INC  BC
	      LD   A,B
	      OR   C
	      JP   Z,GETCM
	      INC  DE
	      POP  HL
	      CALL HILO
	      JP   NC,GETCM
	      JP   MCM05
 
;**************************************************************************

SCMD:	      CALL GETHX
	      PUSH BC
	      POP  HL

SCM05:	      LD   A,D
	      CP   020H
	      JP   Z,SCM10
	      CP   02CH
	      JP   NZ,GETCM

SCM10:	      LD   A,(HL)
	      CALL NMOUT
	      LD   C,02DH
	      CALL ECHO
	      CALL GETHX
	      JP   NC,SCM15
	      LD   (HL),C

SCM15:	      INC  HL
	      JP   SCM05
 
;**************************************************************************

XCMD:	      CALL GETCH
	      LD   C,A
	      CALL ECHO
	      LD   A,C
	      CP   00DH
	      JP   NZ,XCM05
	      CALL REGDS
	      JP   GETCM
 
XCM05:	      LD   C,A
	      CALL RGADR
	      PUSH BC
	      POP  HL
	      LD   C,020H
	      CALL ECHO
	      LD   A,C
	      LD   (TEMP),A

XCM10:	      LD   A,(TEMP)
	      CP   020H
	      JP   Z,XCM15
	      CP   02CH
	      JP   NZ,GETCM

XCM15:	      LD   A,(HL)
	      OR   A
	      JP   NZ,XCM18
	      CALL CROUT
	      JP   GETCM
 
XCM18:	      PUSH HL
	      LD   E,(HL)
	      LD   D,0FEH
	      INC  HL
	      LD   B,(HL)
	      PUSH DE
	      PUSH DE
	      POP  HL
	      PUSH BC
	      LD   A,(HL)
	      CALL NMOUT
	      POP  AF
	      PUSH AF
	      OR   A
	      JP   Z,XCM20
	      DEC  HL
	      LD   A,(HL)
	      CALL NMOUT

XCM20:	      LD   C,02DH
	      CALL ECHO
	      CALL GETHX
	      JP   NC,XCM30
	      LD   A,D
	      LD   (TEMP),A
	      POP  AF
	      POP  HL
	      OR   A
	      JP   Z,XCM25
	      LD   (HL),B
	      DEC  HL

XCM25:	      LD   (HL),C

XCM27:	      LD   DE,003H
	      POP  HL
	      ADD  HL,DE
	      JP   XCM10
 
XCM30:	      LD   A,D
	      LD   (TEMP),A
	      POP  DE
	      POP  DE
	      JP   XCM27
 
;**************************************************************************

CCMD:	      CALL DISKDA
	      CALL SPECD
	      CALL GETCH1
              CALL ECHO
	      LD   A,C
	      SUB  'A'
	      JP   C,ERROR
	      CP   004H
	      JP   NC,ERROR
	      LD   C,A
	      LD   A,(UNIT)
	      PUSH AF
	      LD   A,C
	      LD   (UNIT),A
	      LD   B,005H

CCMD1:	      PUSH BC
	      LD   HL,(UNIT)
	      PUSH HL
	      CALL TEST
	      POP  HL
	      LD   (UNIT),HL
	      POP  BC
	      OR   A
	      JR   Z,CCMD2
	      DJNZ CCMD1
	      POP  AF
	      LD   (UNIT),A

CCMD5:	      LD   HL,CHKERR
	      CALL SOUT
	      JP   GETCM
 
CHKERR:	      DB   00DH,00AH,BELL,' Disk not correct',00DH,00AH,'$'

CCMD2:	      POP  AF
	      LD   HL,CTXT1
	      CALL SOUT
	      LD   A,(TEST$TYPE)
	      AND  020H
	      LD   HL,CTXT11
	      JR   Z,CCMD3
	      LD   HL,CTXT12

CCMD3:	      CALL SOUT
	      LD   HL,CTXT2
	      CALL SOUT
	      LD   A,(TEST$TYPE)
	      RLCA
	      AND  001H
	      ADD  A,031H
	      LD   C,A
	      CALL CO
	      LD   HL,CTXT3
	      CALL SOUT
	      LD   A,(TEST$TYPE)
	      LD   HL,CTXT31
	      AND  040H
	      JR   Z,CCMD4
	      LD   HL,CTXT32

CCMD4:	      CALL SOUT
	      LD   HL,CTXT4
	      CALL SOUT
	      LD   A,(TEST$TYPE)
	      AND  00FH
	      LD   H,000H
	      LD   L,A
	      ADD  HL,HL
	      ADD  HL,HL
	      ADD  HL,HL
	      LD   DE,SEKTXT
	      ADD  HL,DE
	      CALL SOUT
	      LD   HL,CTXT5
	      CALL SOUT
	      LD   A,(TEST$MSEK)
	      CALL DEZOUT
	      LD   HL,CTXT6
	      CALL SOUT
	      CALL READY$MASK
	      AND  00FH
	      LD   HL,CTXT62
	      JR   NZ,CCMD6
	      LD   HL,CTXT61

CCMD6:	      CALL SOUT
	      CALL SETCMDT
	      CALL CROUT
	      JP   GETCM
 
CTXT1:	      DB   00DH,00AH,' Disk format...: $'
CTXT2:	      DB   00DH,00AH,' Heads.........: $'
CTXT3:	      DB   00DH,00AH,' Density.......: $'
CTXT4:	      DB   00DH,00AH,' Sector size...: #$'
CTXT5:	      DB   00DH,00AH,' Sectors/Track.: #$'
CTXT6:	      DB   00DH,00AH,' Ready signal..: $'
CTXT31:	      DB   'single$'
CTXT32:	      DB   'double$'
SEKTXT:	      DB   '128    $'
              DB   '256    $'
              DB   '512    $'
              DB   '1024   $'
CTXT11:	      DB   'maxi$'
CTXT12:	      DB   'mini$'
CTXT61:	      DB   'yes$'
CTXT62:	      DB   'simulated by index$'

;**************************************************************************

OCMD:	      CALL GETHX
	      LD   A,D
	      CP   00DH
	      JP   Z,ERROR
	      PUSH BC
	      CALL GETHX
	      LD   A,D
	      CP   00DH
	      JP   NZ,ERROR
	      LD   L,C
	      POP  BC
	      OUT  (C),L
	      JP   GETCM
 
;**************************************************************************

RCMD:	      CALL DISKDA
	      CALL PRINT$DRIVE
	      CALL RWINP
	      CALL READ
	      JP   GETCM
 
;**************************************************************************

WCMD:	      CALL DISKDA
	      CALL PRINT$DRIVE
	      CALL RWINP
	      CALL WRITE
	      JP   GETCM
 
;**************************************************************************

ICMD:	      LD   C,001H
	      CALL GETNM
	      POP  BC
	      IN   A,(C)
	      LD   C,020H
	      PUSH AF
	      CALL CO
	      POP  AF
	      PUSH AF
	      CALL NMOUT
	      LD   C,020H
	      CALL CO
	      POP  AF
	      LD   D,A
	      CALL BITOUT
	      CALL CROUT
	      JP   GETCM
 
;**************************************************************************

ACMD:	      CALL DISKDA
	      CALL PRINT$DRIVE
	      LD   HL,ATXT1
	      CALL SOUT
	      LD   A,(TRACK)
	      CALL NMOUT
	      CALL ACMD4
	      JR   NC,ACMD1
	      LD   (TRACK),A

ACMD1:	      CALL ACMD5
	      LD   HL,ATXT2
	      CALL SOUT
	      LD   A,(HEAD)
	      CALL NMOUT
	      CALL ACMD4
	      JR   NC,ACMD2
	      AND  001H
	      LD   (HEAD),A

ACMD2:	      CALL ACMD5
	      LD   HL,ATXT3
	      CALL SOUT
	      LD   A,(SECTOR)
	      CALL NMOUT
	      CALL ACMD4
	      JR   NC,ACMD3
	      LD   (SECTOR),A

ACMD3:	      CALL ACMD5
	      CALL CROUT
	      JP   GETCM
 
ACMD4:	      LD   C,02DH
	      CALL ECHO
	      CALL GETHX
	      LD   A,C
	      RET
 
ACMD5:	      LD   A,D
	      CP   00DH
	      JP   Z,GETCM
	      RET
 
ATXT1:	      DB   00DH,00AH,' Track..: $'
ATXT2:	      DB   00DH,00AH,' Head...: $'
ATXT3:	      DB   00DH,00AH,' Sector.: $'

;**************************************************************************

BCMD:	      CALL DISKDA
	      XOR  A
	      LD   (TEST$TRACK),A

BCMD2:	      LD   (UNIT),A
              CALL 01429H
	      LD   B,005H

BCMD3:	      PUSH BC
	      CALL TEST
	      POP  BC
	      OR   A
	      JR   Z,BCMD4
	      DJNZ BCMD3
	      JP   CCMD5
 
BCMD4:	      CALL SETCMDT
	      XOR  A
	      LD   (TRACK),A
	      LD   (HEAD),A
	      INC  A
	      LD   (SECTOR),A
	      LD   HL,BOOTADR
	      LD   (DMAADR),HL
	      LD   A,001H
	      LD   (SECTCNT),A
	      CALL READ
	      OR   A
	      JP   NZ,BOOTERR
	      LD   HL,BOOTADR
	      LD   DE,BOOTADR + 0380H
	      LD   BC,00080H
	      LDIR
	      JP   BOOTADR + 0380H
 
;**************************************************************************

LCMD:	      LD   A,(CLKFLG)
	      OR   A
	      JP   Z,LCMD1
	      CALL DISP$TIME
	      JP   GETCM
 
LCMD1:	      LD   HL,CLKERR$TXT
	      CALL SOUT
	      JP   GETCM
 
CLKERR$TXT:   DB   00DH,00AH,BELL,' Clock failure',00DH,00AH,'$'

;**************************************************************************

NCMD:	      LD   A,(CLKFLG)
	      OR   A
	      JP   Z,LCMD1
	      LD   HL,CITXT1
	      CALL SOUT
	      CALL GETDEZ
	      CP   02FH
	      JP   NZ,ERROR
	      LD   A,L
	      CALL DEZHEX
	      RLCA
	      RLCA
	      RLCA
	      RLCA
	      AND  0F0H
	      CP   000H
	      JP   Z,ERROR
	      CP   0C1H
	      JP   NC,ERROR
	      LD   (PHYS$TIME + 004H),A
	      CALL GETDEZ
	      CP   02FH
	      JP   NZ,ERROR
	      LD   A,L
	      CP   000H
	      JP   Z,ERROR
	      CP   032H
	      JP   NC,ERROR
	      LD   (PHYS$TIME + 003H),A
	      CALL GETDEZ
	      CP   00DH
	      JP   NZ,ERROR
	      LD   A,L
	      CP   080H
	      JP   C,ERROR
	      CP   09AH
	      JP   NC,ERROR
	      LD   (TEMP),A
	      LD   HL,CITXT2
	      CALL SOUT
	      CALL GETDEZ
	      CP   03AH
	      JP   NZ,ERROR
	      LD   A,L
	      CP   024H
	      JP   NC,ERROR
	      LD   (PHYS$TIME + 002H),A
	      CALL GETDEZ
	      CP   03AH
	      JP   NZ,ERROR
	      LD   A,L
	      CP   060H
	      JP   NC,ERROR
	      LD   (PHYS$TIME + 001H),A
	      CALL GETDEZ
	      CP   00DH
	      JP   NZ,ERROR
	      LD   A,L
	      CP   060H
	      JP   NC,ERROR
	      LD   (PHYS$TIME),A
	      LD   HL,CITXT3
	      CALL SOUT
	      CALL GETCH
	      CALL SET$PHYS$TIME
	      LD   A,(TEMP)
	      CALL DEZHEX
	      SUB  050H
	      AND  01FH
	      LD   B,A
	      LD   A,(SHIFT$CONT + 004H)
	      AND  0E0H
	      OR   B
	      LD   (SHIFT$CONT + 004H),A
	      CALL SET$SHIFT
	      CALL CROUT
	      CALL CROUT
	      JP   GETCM
;
CITXT1:	      DB   00DH,00AH,00AH,' Enter today',027H,'s date (MM/DD/YY): $'
CITXT2:	      DB   ' Enter the time (HH:MM:SS):     $'
CITXT3:	      DB   ' Press any key to set time$'

;**************************************************************************

FCMD:	      LD   C,003H
	      CALL GETNM
	      POP  BC
	      POP  DE
	      POP  HL

FCMD1:	      LD   (HL),C
	      CALL HILO
	      JP   C,GETCM
	      INC  HL
	      JP   FCMD1
 
;**************************************************************************

VCMD:	      LD   C,003H
	      CALL GETNM
	      POP  BC
	      POP  DE
	      POP  HL
 
VCMD1:	      LD   A,(BC)
	      CP   (HL)
	      CALL NZ,VCMD2
	      CALL HILO
	      JP   C,GETCM
	      INC  HL
	      INC  BC
	      JP   VCMD1
 
;**************************************************************************

TCMD:	      LD   C,002H
	      CALL GETNM
	      POP  DE
	      POP  HL

TCMD1:	      LD   C,(HL)
	      LD   A,C
	      CPL
	      LD   (HL),A
              LD   B,00FH

TCMD2:	      DJNZ TCMD2
	      LD   A,(HL)
	      LD   (HL),C
	      CPL
	      XOR  C
	      CALL NZ,FBYTOUT
	      CALL HILO
	      JP   C,GETCM
	      INC  HL
	      JR   TCMD1
 
;**************************************************************************

VCMD2:	      PUSH HL
	      PUSH DE
	      PUSH BC
	      CALL DISPMEM
	      LD   C,020H
	      CALL ECHO
	      POP  HL
	      PUSH HL
	      CALL DISPMEM
	      CALL CROUT
	      CALL BREAK
	      JP   C,GETCM
	      POP  BC
	      POP  DE
	      POP  HL
	      RET
 
;**************************************************************************

DISPMEM:      LD   A,H
	      CALL NMOUT
	      LD   A,L
	      CALL NMOUT
	      LD   C,03DH
	      CALL ECHO
	      LD   A,(HL)
	      CALL NMOUT
	      RET
 
FBYTOUT:      PUSH HL
	      PUSH DE
	      LD   D,A
	      LD   A,H
	      CALL NMOUT
	      LD   A,L
	      CALL NMOUT
	      LD   C,020H
	      CALL CO
	      CALL BITOUT
	      CALL CROUT
	      CALL BREAK
	      JP   C,GETCM
	      POP  DE
	      POP  HL
	      RET
 
BITOUT:	      LD   B,008H

BITOUT1:      RLC  D
	      LD   A,030H
	      LD   E,000H
	      ADC  A,E
	      LD   C,A
	      CALL CO
	      DJNZ BITOUT1
	      RET

;**************************************************************************

HCMD:	      LD   HL,HELPTXT
	      CALL SOUT
	      LD   HL,CMDMSG-1

HCMD2:	      INC  HL
	      CALL CROUT
	      LD   A,(HL)
	      OR   A
	      JP   Z,GETCM
	      LD   B,005H
	      LD   C,020H

HCMD3:	      CALL ECHO
	      DJNZ HCMD3
	      CALL SOUT
	      JR   Z,HCMD2

HELPTXT:      DB   00DH,00AH,00AH,'following commands are available:',000H,00AH,'$'

;**************************************************************************

ECMD:	      LD   HL,007E2H
              CALL 00FBBH
              LD   A,01DH
              CALL NMOUT
              LD   A,099H
              CALL NMOUT
              LD   HL,ETXT2
              CALL SOUT
              LD   HL,00000H
              LD   D,000H
              LD   BC,00000H

L08CB:        LD   A,(BC)
              LD   E,A
              ADD  HL,DE
              INC  BC
              LD   A,B
              CP   ' '
              JR   NZ,L08CB
              LD   A,H
              CALL NMOUT
              LD   A,L
              CALL NMOUT
              CALL CROUT
              JP   GETCM
        
ETXT1:        DB   00DH,00AH,'              end location.: $'
ETXT2:        DB   00DH,00AH,'              checksum.....: $'

;**************************************************************************

KCMD:         LD   HL,0083BH
              CALL SOUT

L0928:        CALL CI
              CP   003H
              JR   Z,L0935
              LD   C,A
              CALL CO
              JR   L0928
 
L0935:        CALL CROUT
              JP   GETCM

L093Eº        DB   § (escapå witè ^C)',00DH,00AH,00DH,00AH,'$'

;**************************************************************************

UCMD:         LD   HL,008F0H
              CALL SOUT
              CALL L08E5
              DEC  A

L095B:        LD   C,A
              AND  00F0H
              JP   NZ,ERROR
              LD   A,C
              CPL
              PUSH AF
              LD   HL,UTXT2
              CALL SOUT
              CALL L08E5
              RRCA
              RRCA
              RRCA
              RRCA
              AND  00FH
              LD   C,A
              POP  AF
              RLCA
              RLCA
              RLCA
              RLCA
              AND  0F0H
              OR   C
              LD   (0FF1BH),A
              LD   HL,UTXT3
              CALL SOUT
              CALL L08E5
              AND  0FEH
              PUSH AF
              LD   HL,UTXT4
              CALL SOUT
              CALL L08E5
              RRCA
              RRCA
              RRCA
              LD   C,A
              AND  001H
              LD   B,A
              POP  AF
              OR   B
              LD   (0FF1CH),A
              LD   A,(0FF1DH)
              AND  01FH
              LD   B,A
              LD   A,C
              AND  0E0H
              OR   B
              LD   (0FF1DH),A
              OR   01FH
              LD   HL,0FF1CH
              LD   B,003H

L09B4:        ADD  A,(HL)
              DEC  HL
              DJNZ L09B4
              CPL
              INC  A
              LD   (HL),A
              CALL L08CA
              CALL SPECD
              CALL SET$SHIFT
              CALL CROUT
              JP   GETCM

L08CA:        LD   HL,(0FF1BH)
              LD   A,H
              OR   001H
              LD   H,A
              LD   (0FF79H),HL
              LD   A,(0FF1CH)
              RRCA
              LD   A,(0FF1DH)
              RLA 
              RLA
              RLA
              RLA
              AND  00FH
              LD   (SEEKNR),A
              RET
        
L08E5:        CALL GETHX
              LD   A,D
              CP   00DH
              JP   Z,ERROR
              LD   A,C
              RET

UTXT1:        DEFB 00AH,00DH,' Steprate ...........: $'
UTXT2:        DEFB 00AH,00DH,' Head unload time ...: $'
UTXT3:        DEFB 00AH,00DH,' Head load time .....: $' 
UTXT4:        DEFB 00AH,00DH,' Double step vector .: $'

;**************************************************************************

;DIESES MODUL ENTHAELT DIE INTIALISIERUNGS-ROUTINEN

INIT:	      LD   HL,02EE0H

INIT7:	      DEC  HL
	      LD   A,PAD$TX OR 001H
	      OUT  (P$LS259),A
	      LD   A,PAD$RTS OR 001H
	      OUT  (P$LS259),A
	      LD   A,PAD$POLEN OR 080H
	      OUT  (P$LS259),A
	      LD   A,H
	      OR   L
	      JP   NZ,INIT7
	      LD   A,PAD$MOTOR OR 080H
	      OUT  (P$LS259),A
	      LD   A,PAD$MOTAB OR 001H
	      OUT  (P$LS259),A
	      LD   B,000H
	      LD   C,P$RAM$TABLE
	      LD   D,010H
	      LD   E,000H
	      OUT  (C),E
	      LD   A,D
	      ADD  A,B
	      LD   B,A
	      OUT  (C),E
	      LD   A,D
	      ADD  A,B
	      LD   B,A
	      LD   E,002H

INIT8:	      OUT  (C),E
	      LD   A,D
	      ADD  A,B
	      LD   B,A
	      CP   080H
	      JR   NZ,INIT16
	      LD   E,00AH

INIT16:	      OR   A
	      JR   NZ,INIT8
	      LD   A,PAD$INIT OR 001H
	      OUT  (P$LS259),A
	      LD   HL,MSTACK - 050H
	      XOR  A

INIT13:	      LD   (HL),A
	      INC  HL
	      INC  A
	      JR   NZ,INIT13
	      LD   HL,00000H

INIT15:	      DEC  HL
	      LD   A,H
	      OR   L
	      JR   NZ,INIT15
	      LD   HL,MSTACK - 050H
	      XOR  A

INIT12:	      CP   (HL)
	      JR   NZ,INIT9
	      INC  HL
	      INC  A
	      JR   NZ,INIT12
	      XOR  A
	      JR   INIT10
 
INIT9:	      LD   A,001H

INIT10:	      LD   I,A
	      LD   B,020H
	      LD   C,P$RAM$TABLE
	      LD   D,010H
	      LD   E,003H

INIT11:	      OUT  (C),E
	      LD   A,D
	      ADD  A,B
	      LD   B,A
	      CP   080H
	      JR   NZ,INIT27
	      LD   E,00BH

INIT27:	      OR   A
	      JR   NZ,INIT11
	      LD   HL,MSTACK - 050H
	      XOR  A

INIT17:	      LD   (HL),A
	      INC  HL
	      INC  A
	      JR   NZ,INIT17
	      LD   HL,00000H

INIT18:	      DEC  HL
	      LD   A,H
	      OR   L
	      JR   NZ,INIT18
	      LD   HL,MSTACK - 050H
	      XOR  A

INIT19:	      CP   (HL)
	      JR   NZ,INIT20
	      INC  HL
	      INC  A
	      JR   NZ,INIT19
	      LD   B,000H
	      JR   INIT21
 
INIT20:	      LD   B,002H

INIT21:	      LD   A,I
	      OR   B
	      LD   I,A
	      CP   003H
	      JR   Z,BLINK$LOOP
	      CP   001H
	      JR   Z,INIT22
	      LD   B,020H
	      LD   C,P$RAM$TABLE
	      LD   D,010H
	      LD   E,002H

INIT23:	      OUT  (C),E
	      LD   A,D
	      ADD  A,B
	      LD   B,A
	      CP   080H
	      JR   NZ,INIT24
	      LD   E,00AH

INIT24:	      OR   A
	      JR   NZ,INIT23

INIT22:	      JR   INIT14
 
BLINK$LOOP:   LD   B,080H
	      LD   C,PAD$INUSE
	      LD   HL,00000H
	      EXX
	      LD   B,MASK$RX
	      LD   C,MASK$CTS
	      LD   D,PAD$TX
	      LD   E,PAD$RTS
	      LD   H,001H
	      LD   L,0FFH
	      EXX

BLINK$LOOP1:  DEC  HL
	      LD   A,H
	      ADD  A,A
	      ADD  A,A
	      AND  B
	      OR   C
	      OUT  (P$LS259),A
	      EXX
	      IN   A,(P$IN$LS258$A)
	      AND  B
	      ADD  A,L
	      CCF
	      RLA
	      AND  H
	      OR   D
	      OUT  (P$LS259),A
	      IN   A,(P$IN$LS258$A)
	      AND  C
	      ADD  A,L
	      CCF
	      RLA
	      AND  H
	      OR   E
	      OUT  (P$LS259),A
	      IN   A,(P$IN$LS258$A)
	      AND  MASK$CTSP
	      ADD  A,L
	      CCF
	      RLA
	      AND  H
	      OR   PAD$TXP
	      OUT  (P$LS259),A
	      EXX
	      JR   BLINK$LOOP1
 
INIT14:	      LD   SP,MSTACK
	      LD   HL,DISKPAGE
	      LD   DE,RWPOLL
	      LD   BC,00100H
	      LDIR
	      LD   A,I
	      LD   (BANK$ERR$BYTE),A
	      CALL FLOPPY$RESET
	      LD   A,0C3H
	      LD   HL,GETCM
	      LD   (UMLEIT$GETCM),A
	      LD   (UMLEIT$GETCM + 001H),HL
	      LD   HL,CONST
	      LD   (UMLEIT$CONST),A
	      LD   (UMLEIT$CONST + 001H),HL
	      LD   HL,CONIN
	      LD   (UMLEIT$CONIN),A
	      LD   (UMLEIT$CONIN + 001H),HL
	      LD   HL,CONOUT
	      LD   (UMLEIT$CONOUT),A
	      LD   (UMLEIT$CONOUT + 001H),HL
	      LD   HL,START
	      LD   (UMLEIT$NMI),A
	      LD   (UMLEIT$NMI + 001H),HL
	      XOR  A
	      LD   (HEAD),A
	      LD   (SEEKNR),A
	      LD   (DERMSG),A
	      LD   A,001H
	      LD   (TEST$TRACK),A
	      LD   (TRACK),A
	      LD   (SECTOR),A
	      LD   A,002H
	      LD   (WRITE$PRECOM),A
	      LD   A,00AH
	      LD   (RWRETRY),A
	      LD   A,0FFH
	      LD   (READY$BYTE),A
	      LD   HL,00000H
	      LD   (DISPADR),HL
	      LD   HL,IN$BUFF$ZEIG
	      LD   (IN$BUFF$ZEIG),HL
	      LD   DE,KENNUNG
	      LD   HL,KENNUNGSEXT
	      LD   BC,00007H
	      LDIR
	      LD   A,(VERSIONNR)
	      LD   (MON$VERS),A
              LD   HL,0F1AFH
              LD   (DRIVETIMING),HL
	      CALL USERINIT
	      CALL GET$SPEED
	      LD   (CLKFLG),A
	      OR   A
	      JR   NZ,INIT3
	      LD   HL,09C40H

INIT3:	      LD   (SYSTEMTAKT),HL
	      CALL GET$IO$JUMPER
	      CALL GET$BAUD$JUMPER
	      CALL SET$SOFT$BAUD
	      LD   A,PRNTBAUD
	      CALL SET$SIMPLEX$BAUD
	      LD   HL,INITXT0
	      CALL SOUT
	      LD   A,(VERSIONNR)
	      RLCA
	      RLCA
	      RLCA
	      RLCA
	      AND  00FH
	      ADD  A,'0'
	      LD   C,A
	      CALL ECHO
	      LD   C,'.'
	      CALL ECHO
	      LD   A,(VERSIONNR)
	      AND  00FH
	      ADD  A,'0'
	      LD   C,A
	      CALL ECHO
	      LD   HL,INITXT8
	      CALL SOUT
	      LD   HL,(SERNR)
	      CALL PDEC
	      CALL CROUT
	      LD   A,(BANK$ERR$BYTE)
	      LD   HL,INITXT9
	      CP   000H
	      JR   Z,INIT26
	      LD   HL,INITXT6
	      CP   001H
	      JR   Z,INIT26
	      LD   HL,INITXT7

INIT26:	      CALL SOUT
	      LD   A,(CLKFLG)
	      OR   A
	      JR   Z,NOCLK
	      LD   HL,INITXT1
	      CALL SOUT
	      LD   HL,(SYSTEMTAKT)
	      CALL PDEC
	      LD   HL,INITXT2
	      CALL SOUT
	      CALL DISP$TIME
	      JR   NOCLK2
 
NOCLK:	      LD   HL,INITXT4
	      CALL SOUT

NOCLK2:	      IM   1
	      EI
	      LD   A,(IO$JUMPERBYTE)
	      DEC  A
	      JR   NZ,INIT28
	      LD   A,PAD$RTS
	      OUT  (P$LS259),A

INIT28:       LD   A,(CLKFLG)
              OR   A
              JP   Z,L0BA1
              LD   HL,0FF1DH
              LD   A,(HL)
              OR   01FH  
              LD   B,004H

L0C92:        DEC  HL
              ADD  A,(HL)
              DJNZ L0C92
              OR   A
              LD   A,000H
              JP   NZ,L0BA1
              CALL L08CA
              LD   A,0FFH

L0BA1:        LD   (TEMP),A 
	      CALL INIFDC
	      LD   A,(DISKFLG)
	      OR   A
	      JR   Z,INIT4
	      CALL SPECD
	      JR   INIT5
 
INIT4:	      LD   HL,INITXT5
	      CALL SOUT
	      JP   START
 
INIT5:	      LD   A,(TEMP)
              LD   HL,INITXT10
              INC  A
              CALL Z,SOUT
              LD   HL,INITXT3
	      CALL SOUT
	      CALL GETCH1
	      PUSH AF
	      CALL CROUT
	      POP  AF
	      CP   00DH
	      JP   NZ,BCMD
	      JP   START
 
INITXT0:      DB   CLRSCR,00DH,00AH
              DB   'PROF-80, EPROM version $'
INITXT8:      DB   '   serial no. #$'
INITXT1:      DB   00DH,00AH
              DB   'System speed $'
INITXT2:      DB   '00 (Hz)',0DH,0AH,'$'
INITXT10:     DB   00DH,00AH,'                      '
              DB   'user defined disk timing',00DH,00AH,'$' 
INITXT3:      DB   00DH,00AH
              DB   'press <RETURN> for MONITOR or insert disk into'
              DB   00DH,00AH
	      DB   'drive A  and push any other key for  CP/M boot$'
INITXT4:      DB   00DH,00AH
              DB   'Clock failure, 4 MHz system speed is assumed',00DH,00AH,'$'
INITXT5:      DB   00DH,00AH
              DB   'Floppy failure, no CP/M boot possible',00DH,00AH,'$'
INITXT6:      DB   00DH,00AH
	      DB   '    64K RAM (Bank 1 only)',00DH,00AH,'$'
INITXT7:      DB   00DH,0AH
              DB   '    64K RAM (Bank 0 only)',00DH,00AH,'$'
INITXT9:      DB   00DH,00AH
              DB   '    128K RAM',00DH,00AH,'$'

;**************************************************************************

; DIESES MODUL ENTHAELT DIE IO ROUTINEN 

GRAFIST:      IN   A,(GRIPSTATUSPORT)
	      AND  GRIPINSTATUSMASKE
	      RET  Z
	      LD   A,0FFH
	      OR   A
	      RET

GRAFOST:      IN   A,(GRIPSTATUSPORT)
	      AND  GRIPOUTSTATUSMASKE
	      RET  Z
	      LD   A,0FFH
	      OR   A
	      RET

GRAFIN:       IN   A,(GRIPSTATUSPORT)
	      AND  GRIPINSTATUSMASKE
	      JR   Z,GRAFIN
	      IN   A,(GRIPDATENPORT)
	      RET

GRAFOUT:      IN   A,(GRIPSTATUSPORT)
	      AND  GRIPOUTSTATUSMASKE
	      JR   Z,GRAFOUT
	      LD   A,C
	      OUT  (GRIPDATENPORT),A
	      RET

SOFTOUT:      PUSH BC
	      PUSH DE
	      PUSH HL
SOFTOUT4:     IN   A,(P$IN$LS258$A)
	      AND  MASK$CTS
	      JR   Z,SOFTOUT4
	      LD   A,PAD$RTS OR 1
	      OUT  (P$LS259),A
	      DI
	      RLC  C
	      LD   D,PAD$TX
	      XOR  A
	      LD   B,009H

SOFTOUT1:     AND  001H
	      OR   D
	      OUT  (P$LS259),A
	      LD   HL,(SOFTVERZ)

SOFTOUT2:     DEC  HL
	      LD   A,H
	      OR   L
	      JP   NZ,SOFTOUT2
	      RRC  C
	      LD   A,C
	      DJNZ SOFTOUT1
	      LD   A,PAD$TX OR 1
	      OUT  (P$LS259),A
	      LD   HL,(SOFTVERZ)
	      ADD  HL,HL

SOFTOUT3:     DEC  HL
	      LD   A,H
	      OR   L
	      JP   NZ,SOFTOUT3
	      EI
	      LD   A,(IO$JUMPERBYTE)
	      DEC  A
	      JR   NZ,SOFTOUT5
	      LD   A,PAD$RTS
	      OUT  (P$LS259),A

SOFTOUT5:     POP  HL
	      POP  DE
	      POP  BC
	      LD   A,C
	      RET

SOFTIN:	      PUSH BC
	      PUSH DE
	      PUSH HL
	      LD   A,(IO$JUMPERBYTE)
	      DEC  A
	      JR   Z,SOFTIN8
	      LD   A,PAD$RTS
	      OUT  (P$LS259),A
	      CALL SOFTIN1
	      PUSH AF
	      LD   A,PAD$RTS OR 1
	      OUT  (P$LS259),A
	      POP  AF
	      POP  HL
	      POP  DE
	      POP  BC
	      RET

SOFTIN8:      EI
	      LD   A,PAD$RTS
	      OUT  (P$LS259),A
	      LD   C,IN$BUFF$ZEIG AND 0FFH

SOFTIN9:      LD   A,(IN$BUFF$ZEIG) 
	      CP   C
	      JR   Z,SOFTIN9
	      LD   A,PAD$RTS OR 1
	      OUT  (P$LS259),A
	      DI
	      LD   A,(IN$BUFF$ZEIG - 001H)
	      LD   HL,(IN$BUFF$ZEIG)
	      INC  HL
	      LD   (IN$BUFF$ZEIG),HL
	      LD   DE,IN$BUFF$ZEIG-1
	      LD   HL,IN$BUFF$ZEIG-2
	      LD   BC,IN$BUFF$ZEIG-1-IN$BUFF$END
	      LDDR
	      EI
	      PUSH AF
	      LD   A,PAD$RTS
	      OUT  (P$LS259),A
	      POP  AF
	      POP  HL
	      POP  DE
	      POP  BC
	      RET

INT$SERVICE:  PUSH AF
	      PUSH BC
	      PUSH DE
	      PUSH HL
	      CALL SOFTIN2
	      LD   C,A
	      LD   HL,(IN$BUFF$ZEIG)
	      LD   A,IN$BUFF$END AND 0FFH
	      CP   L
	      JR   Z,INT$SERVICE1
	      DEC  HL
	      LD   (HL),C
	      LD   (IN$BUFF$ZEIG),HL

INT$SERVICE1: POP  HL
	      POP  DE
	      POP  BC
	      POP  AF
	      EI
	      RET

SOFTIN1:      IN   A,(P$IN$LS258$A)
	      AND  MASK$RX
	      JR   Z,SOFTIN1

SOFTIN2:      LD   HL,(SOFTVERZ)
	      SRL  H
	      RR   L

SOFTIN5:      DEC  HL
	      LD   A,H
	      OR   L
	      JP   NZ,SOFTIN5
	      LD   B,008H

SOFTIN3:      LD   HL,(SOFTVERZ)

SOFTIN4:      DEC  HL
	      LD   A,H
	      OR   L
	      JP   NZ,SOFTIN4
	      IN   A,(P$IN$LS258$A)
	      AND  MASK$RX
	      ADD  A,0FFH
	      RR   C
	      DJNZ SOFTIN3
	      LD   A,C
	      CPL

SOFTIN7:      AND  07FH
	      PUSH AF
	      LD   HL,(SOFTVERZ)

SOFTIN10:     DEC  HL
	      LD   A,H
	      OR   L
	      JP   NZ,SOFTIN10
	      POP  AF
	      RET

SOFTIST:      PUSH HL
	      PUSH DE
	      PUSH BC
	      LD   A,(IO$JUMPERBYTE)
	      DEC  A
	      JR   NZ,SOFTST1
	      LD   A,(IN$BUFF$ZEIG)
	      LD   C,IN$BUFF$ZEIG AND 0FFH
	      CP   C
	      JR   Z,SOFTST1
	      LD   A,0FFH
	      JR   SOFTST2

SOFTST1:      LD   A,000H

SOFTST2:      POP  HL
	      POP  DE
	      POP  HL
	      OR   A
	      RET

SOFTOST:      IN   A,(P$IN$LS258$A)
	      AND  MASK$CTS
	      RET  Z
	      LD   A,0FFH
	      OR   A
	      RET

SOFTPRNOST:   IN   A,(P$IN$LS258$A)
	      AND  MASK$CTSP
	      RET  Z
	      LD   A,0FFH
	      OR   A
	      RET

SOFTPRNOUT:   PUSH BC
	      PUSH DE
	      PUSH HL

SOFTPRNTOUT4: IN   A,(P$IN$LS258$A)
	      AND  MASK$CTSP
	      JR   Z,SOFTPRNTOUT4
	      LD   A,PAD$RTS OR 001H
	      OUT  (P$LS259),A
	      DI
	      RLC  C
	      LD   D,PAD$TXP
	      XOR  A
	      LD   B,009H

SOFTPRNTOUT1: AND  001H
	      OR   D
	      OUT  (P$LS259),A
	      LD   HL,(SOFTPRNTVERZ)

SOFTPRNTOUT2: DEC  HL
	      LD   A,H
	      OR   L
	      JP   NZ,SOFTPRNTOUT2
	      RRC  C
	      LD   A,C
	      DJNZ SOFTPRNTOUT1
	      LD   A,PAD$TXP OR 001H
	      OUT  (P$LS259),A
	      LD   HL,(SOFTPRNTVERZ)
	      ADD  HL,HL

SOFTPRNTOUT3: DEC  HL
	      LD   A,H
	      OR   L
	      JP   NZ,SOFTPRNTOUT3
	      EI
	      LD   A,PAD$RTS
	      OUT  (P$LS259),A
	      POP  HL
	      POP  DE
	      POP  BC
	      LD   A,C
	      RET

GET$BAUD$JUMPER:
              LD   A,000H
	      CALL SEND$PRECOM
	      IN   A,(P$IN$LS258$B)
	      AND  MASK$BAUD
	      LD   A,000H
	      JR   Z,GET$BAUD$JUMPER1
	      LD   A,007H
	      CALL SEND$PRECOM
	      IN   A,(P$IN$LS258$B)
	      AND  MASK$BAUD
	      LD   A,001H
	      JR   NZ,GET$BAUD$JUMPER1
	      LD   A,001H
	      CALL SEND$PRECOM
	      IN   A,(P$IN$LS258$B)
	      AND  MASK$BAUD
	      LD   A,002H
	      JR   Z,GET$BAUD$JUMPER1
	      LD   A,002H
	      CALL SEND$PRECOM
	      IN   A,(P$IN$LS258$B)
	      AND  MASK$BAUD
	      LD   A,003H
	      JR   Z,GET$BAUD$JUMPER1
	      LD   A,004H

GET$BAUD$JUMPER1:
              LD   (BAUD$JUMPERBYTE),A
	      RET

GET$IO$JUMPER:LD   A,000H
	      CALL SEND$PRECOM
	      IN   A,(P$IN$LS258$B)
	      AND  MASK$IO
	      LD   A,000H
	      JR   Z,GET$IO$JUMPER1
	      LD   A,007H
	      CALL SEND$PRECOM
	      IN   A,(P$IN$LS258$B)
	      AND  MASK$IO
	      LD   A,001H
	      JR   NZ,GET$IO$JUMPER1
	      LD   A,001H
	      CALL SEND$PRECOM
	      IN   A,(P$IN$LS258$B)
	      AND  MASK$IO 
	      LD   A,002H
	      JR   Z,GET$IO$JUMPER1
	      LD   A,002H
	      CALL SEND$PRECOM
	      IN   A,(P$IN$LS258$B)
	      AND  MASK$IO
	      LD   A,003H
	      JR   Z,GET$IO$JUMPER1
	      LD   A,004H

GET$IO$JUMPER1:
              LD   (IO$JUMPERBYTE),A
	      RET

CONST:        LD   A,(IO$JUMPERBYTE)
              CALL VERTEILER
	      
              DW   GRAFIST
              DW   SOFTIST
              DW   USER1IST
              DW   USER2IST
              DW   DUMMYIST

CONIN:        LD   A,(IO$JUMPERBYTE)
	      CALL VERTEILER
	
              DW   GRAFIN
              DW   SOFTIN
              DW   USER1IN
              DW   USER2IN
              DW   DUMMYIN
CONOUT:       LD   A,(IO$JUMPERBYTE)
	      CALL VERTEILER
	
              DW   GRAFOUT
              DW   SOFTOUT
              DW   USER1OUT
              DW   USER2OUT
              DW   DUMMYOUT

VERTEILER:    EX   (SP),HL

VERTEILER1:   DEC  A
	      JP   M,VERTEILER2
	      INC  HL
	      INC  HL
	      JR   VERTEILER1

VERTEILER2:   LD   A,(HL)
	      INC  HL
	      LD   H,(HL)
	      LD   L,A
	      EX   (SP),HL
	      RET

DUMMYIST:     LD   A,0FFH
	      OR   A
	      RET

DUMMYIN:      LD   A,'7'
	      RET

DUMMYOUT:     LD   A,C
	      RET
  
;**************************************************************************

BREAK:	      CALL CS
	      JP   Z,FRET
	      CALL CI
	      AND  07FH
	      CP   01BH
	      JP   Z,SRET

BREAK1:	      CALL CS
	      JR   Z,BREAK1
	      CALL CI
	      AND  07FH
	      CP   01BH
	      JP   Z,SRET
	      JP   FRET
 
CNVBN:	      LD   A,C
	      SUB  '0'
	      CP   00AH
	      RET  M
	      SUB  007H
	      RET
 
SOUT:	      LD   A,(HL)
	      CP   '$'
	      RET  Z
	      LD   C,A
	      CALL CO
	      INC  HL
	      JR   SOUT
 
CROUT:	      PUSH BC
	      LD   C,00DH
	      CALL ECHO
	      POP  BC
	      RET
 
ECHO:	      PUSH BC
	      LD   B,C
	      LD   A,01BH
	      CP   B  
	      JR   NZ,ECHO5
	      LD   C,'$'

ECHO5:	      CALL CO
	      LD   A,00DH
	      CP   B
	      JR   NZ,ECHO10
	      LD   C,00AH
	      CALL CO

ECHO10:	      POP  BC
	      LD   A,C
	      RET
 
ERROR:	      LD   HL,SYNERRTXT
	      CALL SOUT
	      JP   GETCM
 
SYNERRTXT:    DB   ' What?',BELL,00DH,00AH,'$'

FRET:	      SCF
	      CCF
	      RET

GETCH1:	      CALL CI
	      AND  07FH
	      LD   C,A
	      CP   'a'
	      RET  C
	      SUB  'a' - 'A'
	      LD   C,A
	      RET
 
GETCH:	      CALL CI
	      AND  07FH
	      LD   C,A
	      RET
 
GETHX:	      PUSH HL
	      LD   HL,00000H
	      LD   E,000H

LO228:	      CALL GETCH1
	      LD   C,A
	      CALL VALDL
	      JP   NC,LO241
	      CALL ECHO
	      LD   D,C
	      PUSH HL
	      POP  BC
	      POP  HL
	      LD   A,E
	      OR   A
	      JP   NZ,SRET
	      JP   Z,FRET

LO241:	      CALL VALDG
	      JP   NC,LO228
	      CALL ECHO
	      CALL CNVBN
	      LD   E,0FFH
	      ADD  HL,HL
	      ADD  HL,HL
	      ADD  HL,HL
	      ADD  HL,HL
	      LD   B,000H
	      LD   C,A
	      ADD  HL,BC
	      JP   LO228
 
GETDEZ:	      LD   B,000H
	      LD   HL,00000H

GETDEZ1:      CALL GETCH1
	      CP   '/'
	      JR   Z,GETDEZ2
	      CP   ':'
	      JR   Z,GETDEZ2
	      CP   00DH
	      JR   Z,GETDEZ2
	      SUB  '0'
	      JR   C,GETDEZ1
	      CP   00AH
	      JR   NC,GETDEZ1
	      LD   C,A
	      ADD  HL,HL
	      ADD  HL,HL
	      ADD  HL,HL
	      ADD  HL,HL
	      ADD  HL,BC
	      LD   A,'0'
	      ADD  A,C
	      LD   C,A
	      CALL ECHO
	      JR   GETDEZ1
 
GETDEZ2:      LD   C,A
	      CALL ECHO
	      LD   A,C
	      RET
 
DEZHEX:	      PUSH BC
	      CP   000H
	      JR   Z,DEZHEX1
	      LD   B,000H

DEZHEX2:      INC  B
	      DEC  A
	      DAA
	      JP   NZ,DEZHEX2
	      LD   A,B

DEZHEX1:      POP  BC
	      RET
 
GETNM:	      LD   L,003H
	      LD   A,C
	      AND  003H
	      RET  Z
	      LD   H,A

LO25E:	      CALL GETHX
	      JP   NC,ERROR
	      PUSH BC
	      DEC  L
	      DEC  H
	      JP   Z,LO273
	      LD   A,D
	      CP   00DH
	      JP   Z,ERROR
	      JP   LO25E
 
LO273:	      LD   A,D
	      CP   00DH
	      JP   NZ,ERROR
	      LD   BC,0FFFFH
	      LD   A,L
	      OR   A
	      JP   Z,LO286

LO281:	      PUSH BC
	      DEC  L
	      JP   NZ,LO281

LO286:	      POP  BC
	      POP  DE
	      POP  HL
	      CALL HILO
	      JP   NC,LO291
	      LD   D,H
	      LD   E,L

LO291:	      EX   (SP),HL
	      PUSH DE
	      PUSH BC
	      PUSH HL

LO295:	      DEC  A
	      RET  M
	      POP  HL
	      EX   (SP),HL
	      JP   LO295
 
HILO:	      PUSH BC
	      LD   B,A
	      PUSH HL
	      LD   A,D
	      OR   E
	      JP   Z,LO2BD
	      INC  HL
	      LD   A,H
	      OR   L
	      JP   Z,LO2BD
	      POP  HL
	      PUSH DE
	      LD   A,0FFH
	      XOR  D
	      LD   D,A
	      LD   A,0FFH
	      XOR  E
	      LD   E,A
	      INC  DE
	      LD   A,L
	      ADD  A,E
	      LD   A,H
	      ADC  A,D
	      POP  DE
	      LD   A,B
	      POP  BC
	      RET
 
LO2BD:	      POP  HL
	      LD   A,B
	      POP  BC
	      JP   SRET
 
PDEC:	      LD   BC,TABLE10
	      LD   DE,-10000

PNEXT:	      LD   A,'0' - 1

PDECL:	      PUSH HL
	      INC  A
	      ADD  HL,DE
	      JR   NC,STOPLOOP
	      INC  SP
	      INC  SP
	      JR   PDECL
 
STOPLOOP:     PUSH DE
	      PUSH BC
	      LD   C,A
	      CALL ECHO
	      POP  BC
	      POP  DE

NEXTDIGIT:    POP  HL
	      LD   A,(BC)
	      LD   E,A
	      INC  BC
	      LD   A,(BC)
	      LD   D,A
	      INC  BC
	      LD   A,E
	      OR   D
	      JR   NZ,PNEXT
	      RET
 
TABLE10:      DW   -1000,-100,-10,-1,0

DEZOUT:	      OR   A
	      JR   Z,DEZOUT2
              LD   B,A
	      XOR  A

DEZOUT1:      INC  A
	      DAA
	      DJNZ DEZOUT1

DEZOUT2:      CALL NMOUT
	      RET
 
NMOUT:	      PUSH HL
	      PUSH BC
	      PUSH AF
	      RRCA
	      RRCA
	      RRCA
	      RRCA
	      AND  00FH
	      LD   C,A
	      CALL PRVAL
	      CALL ECHO
	      POP  AF
	      AND  00FH
	      LD   C,A
	      CALL PRVAL
	      CALL ECHO
	      POP  BC
	      POP  HL
	      RET
 
SET$SOFT$BAUD:LD   A,(BAUD$JUMPERBYTE)

SET$DUPLEX$BAUD:
	      LD   H,000H
	      LD   L,A
	      LD   DE,SOFT$BAUD$TAB
	      ADD  HL,HL
	      ADD  HL,DE
	      LD   E,(HL)
	      INC  HL
	      LD   D,(HL)
	      LD   BC,(SYSTEMTAKT)
	      CALL MULTIP
	      LD   (SOFTVERZ),HL
	      RET
 
SET$SIMPLEX$BAUD:
	      LD   H,000H
	      LD   L,A
	      LD   DE,SOFT$BAUD$TAB
	      ADD  HL,HL
	      ADD  HL,DE
	      LD   E,(HL)
	      INC  HL
	      LD   D,(HL)
	      LD   BC,(SYSTEMTAKT)
	      CALL MULTIP
	      LD   (SOFTPRNTVERZ),HL
	      RET
 
MULTIP:	      LD   HL,00000H
	      LD   A,-16

MUL7:	      ADD  HL,HL
	      EX   DE,HL
	      ADC  HL,HL
	      EX   DE,HL
	      JR   NC,MUL2
	      ADD  HL,BC
	      JR   NC,MUL2
	      INC  DE

MUL2:	      INC  A
	      JP   M,MUL7
	      EX   DE,HL
	      RET
 
DIVIDE:	      PUSH HL
	      LD   HL,00001H
	      EX   (SP),HL
	      LD   A,D
	      CPL
	      LD   D,A
	      LD   A,E
	      CPL
	      LD   E,A
	      INC  DE
	      PUSH HL
	      ADD  HL,DE
	      JR   C,DIV1

DIV2:	      POP  HL
	      JR   C,DIV3
	      RL   C
	      RL   B
	      RL   L
	      RL   H
	      JR   C,DIV4
	      PUSH HL
	      ADD  HL,DE
	      INC  SP
	      INC  SP
	      JR   C,DIV5
	      POP  HL
	      ADD  HL,HL

DIV6:	      PUSH HL
	      DEC  SP
	      DEC  SP
	      JR   DIV2
 
DIV4:	      ADD  HL,DE

DIV5:	      PUSH HL
	      INC  SP
	      INC  SP
	      POP  HL
	      ADD  HL,HL
	      INC  HL
	      JR   DIV6
 
DIV3:	      EX   (SP),HL
	      POP  BC
	      XOR  A
	      RET
 
DIV1:	      POP  HL
	      INC  SP
	      INC  SP
	      RET
 
PRVAL:	      PUSH AF
	      LD   A,C
	      OR   0F0H
	      DAA
	      ADD  A,0A0H
	      ADC  A,040H
	      LD   C,A
	      POP  AF
	      RET
 
RWINP:	      CALL GETHX
	      JP   NC,ERROR
	      LD   A,D
	      CP   00DH
	      JP   Z,ERROR
	      LD   (DMAADR),BC
	      CALL GETHX
	      JP   NC,ERROR
	      LD   A,D
	      CP   00DH
	      JP   NZ,ERROR
	      LD   A,C
	      LD   (SECTCNT),A
	      RET
 
PRINT$DRIVE:  LD   A,(UNIT)
	      AND  003H
	      ADD  A,'A'
	      LD   C,A
	      CALL CO
	      LD   C,' '
	      CALL CO
	      RET
 
REGDS:	      LD   HL,RTAB

LO2E9:	      LD   C,(HL)
	      LD   A,C
	      OR   A
	      JP   NZ,LO2F3
	      CALL CROUT
	      RET
 
LO2F3:	      CP   'a'
	      JR   NZ,REGDS1
	      PUSH AF
	      PUSH BC
	      CALL CROUT
	      POP  BC
	      POP  AF

REGDS1:	      CALL ECHO
	      LD   C,'='
	      CALL ECHO
	      INC  HL
	      LD   E,(HL)
	      LD   D,0FEH
	      INC  HL
	      LD   A,(DE)
	      CALL NMOUT
	      LD   A,(HL)
	      OR   A
	      JP   Z,L030E
	      DEC  DE
	      LD   A,(DE)
	      CALL NMOUT

L030E:	      LD   C,' '
	      CALL ECHO
	      INC  HL
	      JP   LO2E9
 
RGADR:	      LD   HL,RTAB
	      LD   DE,00003H

L031D:	      LD   A,(HL)
	      OR   A
	      JP   Z,ERROR
	      CP   C
	      JP   Z,L032A
	      ADD  HL,DE
	      JP   L031D
 
L032A:	      INC  HL
	      LD   B,H
	      LD   C,L
	      RET
 
RSTTF:	      DI
	      LD   SP,MSTACK
	      POP  BC
	      LD   A,C
	      LD   R,A
	      LD   A,B
	      LD   I,A
	      EXX
	      EX   AF,AF'
	      POP  HL
	      POP  DE
	      POP  BC
	      POP  AF
	      EX   AF,AF'
	      EXX
	      POP  IY
	      POP  IX
	      POP  DE
	      POP  BC
	      POP  AF
	      LD   SP,(SSAVE)
	      LD   HL,(PSAVE)
	      PUSH HL
	      LD   HL,(LSAVE)
	      EI
	      RET
 
SETCMDT:      LD   A,(TEST$MSEK)
	      LD   (EOT),A
	      LD   A,(TEST$TYPE)
	      LD   C,A
	      AND  040H
	      LD   (CMDTAB),A
	      LD   A,C
	      AND  00FH
	      LD   (SECSZ),A
	      OR   A
	      LD   A,0FFH
	      JR   NZ,CMDS1
	      LD   A,080H

CMDS1:	      LD   (DTLL),A
	      LD   A,C
	      AND  00FH
	      LD   C,A
	      LD   B,000H
	      LD   HL,GAPTAB
	      ADD  HL,BC
	      LD   A,(HL)
	      LD   (GAPLL),A
	      RET
 
GAPTAB:	      DB   007H
              DB   00EH
              DB   01BH
              DB   035H
              
SRET:	      SCF
	      RET
 
VALDG:	      LD   A,C
	      CP   '0'
	      JP   M,FRET
	      CP   '9'
	      JP   M,SRET
	      JP   Z,SRET
	      CP   'A'
	      JP   M,FRET
	      CP   'G'
	      JP   P,FRET
	      JP   SRET
 
VALDL:	      LD   A,C
	      CP   ','
	      JP   Z,SRET
	      CP   00DH
	      JP   Z,SRET
	      CP   ' '
	      JP   Z,SRET
	      JP   FRET
 
DISK$PAGE$OVERLAY:
	      LD   B,000H
	      LD   HL,DISKPAGE
	      LD   DE,RWPOLL

$DISK$PAGE$OVERLAY$LOOP:
	      LD   A,(HL)
	      CP   0FFH
	      JR   Z,@DISK$PAGE$OVERLAY1
	      LD   (DE),A

@DISK$PAGE$OVERLAY1:
	      INC  HL
	      INC  DE
	      DJNZ $DISK$PAGE$OVERLAY$LOOP
	      RET
 
DISP$TIME:    CALL READ$PHYS$TIME
	      LD   HL,TIMTXT1
	      CALL SOUT
	      LD   A,(PHYS$TIME + 004H)
	      RRCA
	      RRCA
	      RRCA
	      RRCA
	      AND  00FH
	      DEC  A
	      CP   12
	      JR   C,DISP$TIME1
	      XOR  A

DISP$TIME1:   LD   L,A
	      LD   H,000H
	      ADD  HL,HL
	      ADD  HL,HL
	      LD   BC,MONTXT
	      ADD  HL,BC
	      CALL SOUT
	      LD   C,' '
	      CALL ECHO
	      LD   A,(PHYS$TIME + 003H)
	      CALL NMOUT
	      LD   C,' '
	      CALL ECHO
	      LD   A,019H
	      CALL NMOUT
	      LD   A,(SHIFT$CONT + 004H)
	      AND  01FH
	      LD   B,050H
	      ADD  A,B
	      CALL DEZOUT
	      LD   HL,TIMTXT2
	      CALL SOUT
	      LD   A,(PHYS$TIME + 002H)
	      CALL NMOUT
	      LD   C,':'
	      CALL ECHO
	      LD   A,(PHYS$TIME + 001H)
	      CALL NMOUT
	      LD   C,':'
	      CALL ECHO
	      LD   A,(PHYS$TIME)
	      CALL NMOUT
	      CALL CROUT
              LD   A,(IO$JUMPERBYTE)
              OR   A
              RET  NZ
              LD   HL,TIMTXT0
              CALL SOUT
              LD   A,(0FF16H)
              ADD  A,' '
              LD   C,A
              CALL ECHO
 
L1479:        LD   A,(0FF15H)
              ADD  A,' '
              LD   C,A
              CALL ECHO

L1482:        LD   A,(PHYS$TIME)
              ADD  A,' '
              LD   C,A
              CALL ECHO
	      RET

TIMTXT0:      DB   01BH,01BH,055H,'$'
TIMTXT1:      DB   00DH,00AH,'              Date  $'
TIMTXT2:      DB   00DH,00AH,'              Time  $'
MONTXT:	      DB   'Jan$'
              DB   'Feb$'
              DB   'Mar$'
	      DB   'Apr$'
	      DB   'May$'
	      DB   'Jun$'
	      DB   'Jul$'
	      DB   'Aug$'
	      DB   'Sep$'
	      DB   'Oct$'
	      DB   'Nov$'
	      DB   'Dec$'

;**************************************************************************

; DIESES MODUL ENTHAELT DIE FLOPPY-ROUTINEN

SETSEC$CNT:   LD   A,C
	      LD   (SECTCNT),A
	      RET
 
SELDSK:	      LD   A,C
	      LD   (UNIT),A
	      RET
 
SETTRK:	      LD   A,C
	      LD   (TRACK),A
	      RET
 
SETSEC:	      LD   A,C
	      LD   (SECTOR),A
	      RET
 
SETDMA:	      LD   (DMAADR),BC
	      RET
 
GETMINIMAX:   LD   A,(TEST$TYPE)
	      AND  020H
	      RET  Z
	      LD   A,0FFH
	      RET

BOOTERR:      LD   HL,BERRMSG
	      CALL SOUT
	      JP   GETCM
 
BERRMSG:      DEFM ' Can not boot',00DH,00AH,'$'

SPECD:        LD   HL,(UNIT)
	      PUSH HL
	      LD   HL,(DRIVETIMING)
              LD   A,001H
              OR   H
              LD   H,A
	      LD   BC,00303H
	      LD   (UNIT),HL
	      CALL CMFD
	      POP  HL
	      LD   (UNIT),HL
	      RET
 
FLOPPY$RESET: PUSH BC
	      LD   A,PAD$RESF OR 001H
	      OUT  (P$LS259),A
	      LD   B,014H

FLOPPY$RESET1:DJNZ FLOPPY$RESET1
	      LD   A,PAD$RESF
	      OUT  (P$LS259),A
	      POP  BC
	      RET
 
INIFDC:       LD   A,0FFH
	      LD   (DISKFLG),A
	      LD   HL,00000H

INIFDC1:      DEC  H
	      IN   A,(FDC)
	      CP   080H
	      RET  Z
	      IN   A,(FDD)
	      LD   A,H
	      OR   L
	      JR   NZ,INIFDC1
	      LD   (DISKFLG),A
	      RET
 
RECAL:        LD   B,004H

RECAL2:       PUSH BC
	      CALL RECAL1
	      CALL SENSD
	      AND  010H
	      POP  BC
	      RET  NZ
	      DJNZ RECAL2
	      RET
 
RECAL1:       LD   BC,00207H
	      CALL MOTO
	      JP   SEEK2
 
NODISK:	      DB   00DH,00AH,BELL,' Drive access not possible$'

DISKDA:	      LD   A,(DISKFLG)
	      OR   A
	      RET  NZ
	      LD   HL,NODISK
	      CALL SOUT
	      CALL CROUT
	      JP   GETCM

READY$MASK:   CALL UNIT$MASK
	      LD   A,(READY$BYTE)
	      AND  B
	      RET
 
UNIT$MASK:    LD   A,(UNIT)
	      AND  003H
	      INC  A
	      LD   B,A
	      LD   A,088H

UNIMASK:      RLCA
	      DJNZ UNIMASK
	      LD   B,A
	      RET
 
SEEK3:        CALL UNIT$MASK
	      LD   A,(SEEKNR)
	      AND  B
	      AND  00FH
	      RET
 
SEEK:         CALL SEEK3
	      JR   Z,SEEK1
	      LD   A,(TRACK)
	      PUSH AF
	      ADD  A,A
	      LD   (TRACK),A

SEEK1:        LD   BC,0030FH
	      CALL MOTO
	      CALL SEEK3
	      JR   Z,SEEK2
	      POP  AF
	      LD   (TRACK),A

SEEK2:        LD   BC,00108H
	      CALL CMFD
	      CALL NEXT
	      PUSH AF
	      CP   080H
	      CALL NZ,NEXT
	      POP  AF
	      AND  020H
	      JP   Z,SEEK2
	      LD   A,PAD$MOTOR OR 080H
	      OUT  (P$LS259),A
	      RET
 
RESULT:	      LD   B,006H
	      CALL NEXT
	      LD   HL,REST
	      LD   (HL),A
	      AND  0C0H
	      LD   C,A

RESLOP:	      CALL NEXT
	      INC  HL
	      LD   (HL),A
	      DJNZ RESLOP
	      LD   A,PAD$READY
	      OUT  (P$LS259),A
	      LD   A,PAD$MOTOR OR 080H
	      OUT  (P$LS259),A
	      LD   A,C
	      OR   A
	      RET
 
READY$TEST:   CALL SPEED$CONST
	      JR   NZ,RTST1
	      CALL NRDYERR
	      JR   NZ,READY$TEST
	      JP   UMLEIT$GETCM
 
RTST1:	      CALL SENSD
	      AND  020H
	      PUSH AF
	      CALL UNIT$MASK
	      CPL
	      LD   B,A
	      POP  AF
	      LD   A,00FH
	      JR   Z,RTST2
	      LD   A,000H

RTST2:	      OR   B
	      LD   B,A
	      LD   A,(READY$BYTE)
	      AND  B
	      LD   (READY$BYTE),A
	      RET
 
SPEED$CONST:  LD   BC,00204H
	      CALL CMFD
	      LD   A,PAD$MOTOR
	      OUT  (P$LS259),A
	      LD   DE,00000H
	      LD   B,10

SPEEDC1:      EX   DE,HL
	      LD   DE,TOLERANZ
	      ADD  HL,DE
	      EX   DE,HL
	      CALL CDRIVE$SPEED
	      JR   Z,SPEEDC3
	      EX   DE,HL
	      SBC  HL,DE
	      LD   A,H
	      CP   000H
	      JR   NZ,SPEEDC2
	      LD   A,L
	      CP   TOLERANZ * 2
	      JR   NC,SPEEDC2
	      CALL CDRIVE$SPEED
	      CALL CDRIVE$SPEED
	      CALL NEXT
	      LD   A,PAD$MOTOR OR 080H
	      OUT  (P$LS259),A
	      LD   A,0FFH
	      OR   A
	      RET
 
SPEEDC2:      DJNZ SPEEDC1

SPEEDC3:      CALL NEXT
	      LD   A,PAD$MOTOR OR 080H
	      OUT  (P$LS259),A
	      XOR  A
	      RET
 
CDRIVE$SPEED: IN   A,(P$IN$LS258$A)
	      AND  MASK$INDEX
	      JR   Z,DSPEED1
	      LD   HL,00000H

DSPEED2:      INC  HL
	      LD   A,H 
	      OR   L
	      RET  Z
	      IN   A,(P$IN$LS258$A)
	      AND  MASK$INDEX
	      JR   NZ,DSPEED2

DSPEED1:      LD   HL,00000H

DSPEED3:      INC  HL
	      LD   A,H
	      OR   L
	      RET  Z
	      IN   A,(P$IN$LS258$A)
	      AND  MASK$INDEX
	      JR   Z,DSPEED3
	      LD   HL,00000H

DSPEED4:      INC  HL
	      LD   A,H
	      OR   L
	      RET  Z
	      IN   A,(P$IN$LS258$A)
	      AND  MASK$INDEX
	      JR   NZ,DSPEED4
	      LD   A,0FFH
	      OR   A
	      RET
 
NOREADY$MOTO: IN   A,(P$IN$LS258$B)
	      AND  MASK$MOT
	      JR   Z,NREDY1

NREDY2:	      CALL SPEED$CONST
	      JR   NZ,NREDY1
	      CALL NRDYERR
	      JR   NZ,NREDY2
	      JP   UMLEIT$GETCM
 
NREDY1:	      LD   A,PAD$MOTOR
	      OUT  (P$LS259),A
	      LD   A,PAD$READY  OR 080H
	      OUT  (P$LS259),A
	      JP   MOTO1
 
MOTO:	      PUSH BC
	      CALL READY$MASK
	      AND  0F0H
	      CALL NZ,READY$TEST
	      CALL READY$MASK
	      AND  00FH
	      JP   NZ,NOREADY$MOTO
	      LD   A,PAD$MOTOR
	      OUT  (P$LS259),A

MOTO2:	      LD   HL,00FFFH

MOTO3:	      PUSH HL
	      LD   BC,00204H
	      CALL CMFD
	      CALL NEXT
	      POP  HL
	      AND  020H
	      JR   NZ,MOTO1
	      DEC  HL
	      LD   A,H
	      OR   L
	      JR   NZ,MOTO3
	      CALL NRDYERR
	      JR   NZ,MOTO2
	      LD   A,PAD$MOTOR OR 080H
	      OUT  (P$LS259),A
	      JP   UMLEIT$GETCM
;
NRDYERR:      LD   HL,NREADY1
	      CALL SOUT
	      CALL PRINT$DRIVE
	      LD   HL,NREADY2
	      CALL SOUT
	      CALL GETCH1
	      LD   C,A
	      CALL ECHO
	      CALL CROUT
	      LD   A,C
	      CP   'N'
	      RET
 
NREADY1:      DB   00DH,00AH,BELL,' Drive $'
NREADY2:      DB   'not ready, retry (Y/N) ? $'

MOTO1:	      POP  BC

CMFD:	      LD   HL,CMDTAB

CMFD1:	      LD   A,01EH

CMFD2:	      DEC  A
	      JR   NZ,CMFD2
	      IN   A,(FDC)
	      AND  0C0H
	      CP   080H
	      JR   NZ,CMFD1
	      LD   A,C
	      OUT  (FDD),A
	      INC  HL
	      LD   C,(HL)
	      DJNZ CMFD1  
	      RET
 
NEXT:	      LD   A,006H

NEXT1:	      DEC  A
	      JR   NZ,NEXT1
	      IN   A,(FDC)
	      AND  0C0H
	      CP   0C0H
	      JP   NZ,NEXT
	      IN   A,(FDD)
	      RET
 
WRITE:	      CALL DISK$PAGE$OVERLAY
	      LD   A,005H
	      LD   HL,TXTWR
	      JP   RWCOM
 
READ:	      CALL DISK$PAGE$OVERLAY
	      LD   A,006H
	      LD   HL,TXTRD
	      JP   RWCOM
 
RWCOM:	      LD   (RWCMD),A
	      LD   (ERMSG),HL
	      LD   A,(SECTCNT) 
	      DEC  A
	      CP   0FFH
	      RET  Z
	      LD   C,A
	      LD   A,(EOT)
	      LD   (EOTSAVE),A
	      LD   B,A
	      LD   A,(SECTOR)
	      ADD  A,C
	      LD   (EOT),A
	      LD   C,A
	      LD   A,B
	      LD   B,000H
	      SUB  C
	      JR   NC,RW5   
	      LD   B,080H
	      LD   A,(EOTSAVE)
	      LD   (EOT),A
RW5:	      LD   A,B
	      LD   (EOTFLG),A
	      LD   A,PAD$RTS OR 001H
	      OUT  (P$LS259),A
	      DI
	      CALL SEEK
	      CALL SETHEAD
	      LD   A,(WRITE$PRECOM)
	      CALL SEND$PRECOM
	      LD   A,(RWRETRY)
	      LD   B,A

RW4:	      PUSH BC
	      LD   B,009H
	      LD   A,(RWCMD)
	      LD   C,A
	      LD   A,(CMDTAB)
	      AND  040H
	      OR   C
	      LD   C,A
	      CALL MOTO
	      EXX
	      LD   HL,(DMAADR)
	      LD   C,FDD
	      EXX
	      LD   HL,RWPOLL
	      LD   C,FDC
	      CALL RWPOLL
	      CALL RESULT
	      LD   A,(REST + 001H)
	      AND  07FH
	      LD   (REST + 001H),A
	      LD   C,A
	      LD   A,(REST + 002H)
	      OR   C
	      POP  BC
	      JR   Z,RW7
	      DJNZ RW4

RW7:	      LD   A,(EOTFLG)
	      LD   C,A
	      LD   A,(REST + 001H)
	      OR   C
	      LD   (REST + 001H),A
	      LD   C,A
	      LD   A,(REST + 002H)
	      OR   C
	      PUSH AF
	      CALL NZ,DISKERR
	      LD   A,(EOTSAVE)
	      LD   (EOT),A
	      EI
	      LD   A,(IO$JUMPERBYTE)
	      DEC  A
	      JR   NZ,RW1
	      LD   A,0F4H
	      OUT  (P$LS259),A

RW1:	      POP  AF
	      RET
 
SETHEAD:      LD   A,(HEAD) 
	      RLCA
	      RLCA
	      AND  004H
	      LD   C,A
	      LD   A,(UNIT)
	      AND  003H
	      OR   C
	      LD   (UNIT),A
	      RET
 
TEST:	      CALL RECAL
	      LD   A,(UNIT)
	      AND  003H
	      LD   (UNIT),A
	      LD   A,(TEST$TRACK)
	      LD   (TRACK),A
	      CALL SEEK
	      LD   A,000H
	      LD   (TEST$TYPE),A
	      CALL MAXI$SET
	      CALL READID
	      JP   Z,TEST1
	      LD   A,040H
	      LD   (TEST$TYPE),A
	      CALL READID
	      JP   Z,TEST1
	      LD   A,020H
	      LD   (TEST$TYPE),A
	      CALL MINI$SET
	      CALL READID
	      JP   Z,TEST1
	      LD   A,060H
	      LD   (TEST$TYPE),A
	      CALL READID
	      JP   Z,TEST1

TEST2:	      LD   A,0FFH
	      RET

TEST1:        CALL READID
              JR   NZ,TEST2
              LD   A,(0FF48H)

L189D:        LD   D,A
              LD   C,A
              LD   B,'4'

L18A1:        PUSH BC
              PUSH DE
              CALL READID
              POP  DE
              POP  BC
              JR   NZ,TEST2
              LD   A,(0FF48H)
              CP   D
              JR   Z,L18B8
              CP   C
              JR   C,L18B4
              LD   C,A

L18B4:        DJNZ L18A1
              JR   TEST2

L18B8:        LD   A,C
              LD   (TEST$MSEK),A
 
TEST4:	      LD   A,(REST + 006H)
	      AND  00FH
	      LD   C,A
	      LD   A,(TEST$TYPE)
	      OR   C
	      LD   (TEST$TYPE),A
	      CALL SENSD
	      RLCA
	      RLCA
	      RLCA
	      RLCA
	      AND  080H
	      LD   C,A
	      LD   A,(TEST$TYPE)
	      OR   C
	      LD   (TEST$TYPE),A 
	      LD   A,000H
	      RET
;
READID:	      LD   BC,0020AH
	      LD   A,(TEST$TYPE)
	      AND  040H
	      OR   C
	      LD   C,A
	      CALL MOTO
	      CALL RESULT
	      OR   A
	      RET
 
MAXI$SET:     PUSH AF
	      LD   A,PAD$MINI
	      OUT  (P$LS259),A
	      POP  AF
	      RET
 
MINI$SET:     PUSH AF
	      LD   A,PAD$MINI OR 001H
	      OUT  (P$LS259),A
	      POP  AF
	      RET 
SENSD:	      LD   BC,00204H
	      CALL CMFD
	      CALL NEXT
	      RET
 
DISKERR:      LD   A,(DERMSG) 
	      INC  A
	      RET  Z
	      LD   HL,(ERMSG)
	      CALL SOUT
	      LD   A,(REST)
	      AND  003H
	      ADD  A,'A'
	      LD   C,A
	      CALL ECHO
              LD   HL,TXT1
	      CALL SOUT
	      LD   A,(REST + 003H)
	      CALL DEZOUT
	      LD   HL,TXT2
	      CALL SOUT
	      LD   A,(REST + 004H)
	      ADD  A,'0'
	      LD   C,A
	      CALL ECHO
	      LD   HL,TXT3
	      CALL SOUT
	      LD   A,(REST + 005H)
	      CALL DEZOUT
	      LD   DE,ERROR$TABLE
	      LD   A,(REST + 001H)
	      LD   H,A
	      LD   A,(REST + 002H)
	      LD   L,A

ERRLOP:	      ADD  HL,HL
	      PUSH HL
	      LD   A,(DE)
	      LD   L,A
	      INC  DE
	      LD   A,(DE)
	      LD   H,A
	      CALL C,SOUT
	      POP  HL
	      INC  DE
	      LD   A,H
	      OR   L
	      JR   NZ,ERRLOP
	      CALL CROUT
	      RET

;**************************************************************************

; DIESES MODUL ENTHAELT DIE ECHTZEITUHR-ROUTINEN

SEND$TIME$COM:CALL SEND$PRECOM
	      CALL SEND$STB
	      RET

SEND$PRECOM:  PUSH BC
	      LD   C,PAD$CO
	      LD   B,003H

SEND$TIME$COM$1:
              RRCA
	      PUSH AF
	      AND  080H
	      OR   C
	      OUT  (P$TIME$OUT),A
	      LD   A,010H
	      ADD  A,C
	      LD   C,A
	      POP  AF
	      DJNZ SEND$TIME$COM$1
	      POP  BC
	      RET

SEND$STB:     LD   A,PAD$STB OR 001H
	      OUT  (P$TIME$OUT),A
	      LD   A,00AH

SEND$STB1:    DEC  A
	      JR   NZ,SEND$STB1
	      LD   A,PAD$STB
	      OUT  (P$TIME$OUT),A
	      RET

SEND$CLK:     LD   A,PAD$CLK OR 080H
	      OUT  (P$TIME$OUT),A
	      LD   A,00AH

SEND$CLK1:    DEC  A
	      JR   NZ,SEND$CLK1
	      LD   A,040H
	      OUT  (P$TIME$OUT),A
	      RET

TIME$ENABLE:  RET

TIME$DISABLE: RET

READ$SHIFT:   LD   A, 01H
	      CALL SEND$TIME$COM
	      LD   B,005H

READ$SHIFT$1: LD   C,008H

READ$SHIFT$2: IN   A,(P$TIME$IN)
	      CPL
	      RLA
	      LD   A,D
	      RRA
	      LD   D,A
	      CALL SEND$CLK
	      DEC  C
	      JR   NZ,READ$SHIFT$2
	      LD   (HL),D
	      INC  HL
	      DJNZ READ$SHIFT$1
	      LD   A,000H
	      CALL SEND$TIME$COM
	      RET

WRITE$SHIFT:  LD   D,(HL)
	      LD   A,001H
	      CALL SEND$TIME$COM
	      LD   B,005H

WRITE$SHIFT$1:LD   C,008H

WRITE$SHIFT$2:LD   A,D
	      RRCA
	      AND  080H
	      OR   PAD$CO
	      OUT  (P$TIME$OUT),A
	      LD   A,D
	      RRA
	      LD   D,A
	      CALL SEND$CLK
	      DEC  C
	      JR   NZ,WRITE$SHIFT$2
	      INC  HL
	      LD   D,(HL)
	      DJNZ WRITE$SHIFT$1
              LD   A,000H

WRITE$SHIFT$3:CALL SEND$TIME$COM
	      RET

SET$PHYS$TIME:CALL TIME$ENABLE
	      LD   HL,SHIFT$CONT
	      CALL READ$SHIFT
	      LD   HL,PHYS$TIME
	      CALL WRITE$SHIFT
	      LD   A,002H
	      CALL SEND$TIME$COM
	      LD   HL,SHIFT$CONT
	      CALL WRITE$SHIFT
	      CALL TIME$DISABLE
	      RET

READ$PHYS$TIME:
              CALL TIME$ENABLE
	      LD   HL,SHIFT$CONT
	      CALL READ$SHIFT
	      LD   A,003H
	      CALL SEND$TIME$COM
	      LD   B,0FFH

$READ$PHYS$TIME:
              DJNZ $READ$PHYS$TIME
	      LD   HL,PHYS$TIME
	      CALL READ$SHIFT
	      LD   HL,SHIFT$CONT
	      CALL WRITE$SHIFT
	      CALL TIME$DISABLE
	      RET

SET$SHIFT:    CALL TIME$ENABLE
	      LD   HL,SHIFT$CONT
	      CALL WRITE$SHIFT
	      CALL TIME$DISABLE
	      RET

GET$SPEED:    CALL TIME$ENABLE
	      LD   A,000H
	      CALL SEND$TIME$COM
	      LD   HL,00000H
	      LD   DE,0FFFFH
	      IN   A,(P$TIME$IN)
	      AND  TIME$DATA$MASK
	      LD   B,A

GET$SPEED1:   IN   A,(P$TIME$IN)
	      AND  TIME$DATA$MASK
	      CP   B
	      JR   NZ,GET$SPEED2
	      LD   C,A
	      DEC  DE
	      LD   A,D
	      OR   E
	      JR   NZ,GET$SPEED1
	      CALL TIME$DISABLE
	      XOR  A
	      RET

GET$SPEED2:   LD   B,A
	      LD   C,TIME$DATA$MASK

GET$SPEED3:   IN   A,(P$TIME$IN)
	      AND  C
	      CP   B
	      JR   NZ,GET$SPEED4
	      INC  HL
	      NOP
	      NOP
	      JP   GET$SPEED3

GET$SPEED4:   CALL TIME$DISABLE
              LD   A,0FFH
              RET
   
;**************************************************************************

; DIESES MODUL ENTHAELT DIE MONITOR TABELLEN

TXT1:         DEFM ', track #$'
TXT2:         DEFM ', head #$'
TXT3:         DEFM ', sector #$'

ERROR$TABLE:  DW   B15MSG
	      DW   NOBMSG
	      DW   B13MSG
	      DW   B12MSG
	      DW   NOBMSG
	      DW   B10MSG
	      DW   B9MSG
	      DW   B8MSG
	      DW   NOBMSG
	      DW   B6MSG
	      DW   B5MSG
	      DW   B4MSG
	      DW   NOBMSG
	      DW   NOBMSG
	      DW   B1MSG
	      DW   B0MSG

NOBMSG:       DB   024H
B15MSG:       DB   00AH,00DH,' end of cylinder$'
B13MSG:       DB   00AH,00DH,' data error$'
B12MSG:       DB   00AH,00DH,' over run$'
B10MSG:       DB   00AH,00DH,' no data$'
B9MSG:        DB   00AH,00DH,' not writable$'
B8MSG:        DB   00AH,00DH,' missing address mark$'
B6MSG:        DB   00AH,00DH,' control mark$'
B5MSG:        DB   00AH,00DH,' data error in data field$'
B4MSG:        DB   00AH,00DH,' wrong cylinder$'
B1MSG:        DB   00AH,00DH,' bad cylinder$'
B0MSG:        DB   00AH,00DH,' missing address mark in data field$'

TXTRD:        DB   BELL,00DH,00AH,' Read error on $'
TXTWRº        DÂ   BELL,00DH,00AH,' Write error on $'

SOFT$BAUD$TAB:DW   00019H
	      DW   00035H
	      DW   0006EH
	      DW   000E0H
	      DW   0038BH
	      DW   007EBH
	      DW   00E35H
	      DW   00019H
	      DW   0000BH
	      DW   00023H
	      DW   00048H
	      DW   00094H
              DW   001C4H
	      DW   00719H
	      DW   009AFH
	      DW   01552H

SGNON:        DB   00DH,00AH,'Monitor',00DH,00AH,'$'

KENNUNGSEXT:  DEFM 'PROF-80'

CMDMSG:       DEFM 'Address for read (write) from (to) drive $'
	      DEFM 'Boot CP/M$'
	      DEFM 'Check drive $'
	      DEFM 'Display memory $'
	      DEFM 'EPROM test$'
	      DEFM 'Fill memory $'
	      DEFM 'Go to $'
	      DEFM 'Help$'
              DEFB 'Keyboard mode$'
	      DEFM 'In port $'
	      DEFM 'List time$'
	      DEFM 'Move memory $'
	      DEFM 'New date and time set$'
	      DEFM 'Out port $'
	      DEFM 'Read from drive $'
	      DEFM 'Substitute memory $'
	      DEFM 'Test memory $'
              DEFB 'User defined disk timing$'
	      DEFM 'Verify memory $'
	      DEFM 'Write to drive $'
	      DEFM 'X Register $'
              DB   000H

CADR:         DW   00000H
              DW   UCMD
              DW   KCMD        
	      DW   LCMD
	      DW   HCMD
	      DW   GCMD
	      DW   WCMD
	      DW   ACMD
	      DW   RCMD
	      DW   OCMD
	      DW   CCMD
	      DW   TCMD
	      DW   VCMD
	      DW   FCMD
	      DW   BCMD
	      DW   XCMD
	      DW   SCMD
	      DW   MCMD
	      DW   ICMD
	      DW   ECMD
	      DW   DCMD
	      DW   NCMD

CTAB:         DB   'N'
              DB   'D'
              DB   'E'
              DB   'I'
              DB   'M'
              DB   'S'
              DB   'X'
              DB   'B'
              DB   'F'
              DB   'V'
              DB   'T'
              DB   'C'
              DB   'O'
              DB   'R'
              DB   'A'
              DB   'W'
              DB   'G'
              DB   'H'
              DB   'L'
              DB   'K'
              DB   'U'

NCMDS         EQU  $ - CTAB

RTAB:         DB   'A',0F9H,000H
	      DB   'B',0F7H,000H
	      DB   'C',0F6H,000H
              DB   'D',0F5H,000H
	      DB   'E',0F4H,000H
	      DB   'F',0F8H,000H
	      DB   'H',0FBH,000H
	      DB   'L',0FAH,000H
	      DB   'M',0FBH,001H
	      DB   'P',0FDH,001H
	      DB   'S',0FFH,001H
	      DB   'a',0EFH,000H
	      DB   'b',0EDH,000H
	      DB   'c',0ECH,000H
	      DB   'd',0EBH,000H
	      DB   'e',0EAH,000H
	      DB   'f',0EEH,000H
	      DB   'h',0E9H,000H
	      DB   'l',0E8H,000H
	      DB   'm',0E9H,001H
	      DB   'X',0F3H,001H
	      DB   'Y',0F1H,001H
	      DB   'I',0E7H,000H
	      DB   'R',0E6H,000H
              DB   000H,000H           ;TABELLENENDE


DISKPAGE:     IN   L,(C)
              JP   (HL)

              DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
	      DB   0FFH,0FFH,0FFH,0FFH,0FFH

	      IN   L,(C)
              JP   (HL)	

              DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
              DB   0FFH,0FFH,0FFH,0FFH,0FFH

              IN   L,(C)
              JP   (HL)

              DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
	      DB   0FFH,0FFH,0FFH,0FFH,0FFH

              IN   L,(C)
              JP   (HL)

              DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
	      DB   0FFH,0FFH,0FFH,0FFH,0FFH

              IN   L,(C)
              JP   (HL)

              DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
	      DB   0FFH,0FFH,0FFH,0FFH,0FFH

              IN   L,(C)
       	      JP   (HL)

              DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
	      DB   0FFH,0FFH,0FFH,0FFH,0FFH

              IN   L,(C)
              JP   (HL)
 
              DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
	      DB   0FFH,0FFH,0FFH,0FFH,0FFH

              IN   L,(C)
              JP   (HL)

              DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
	      DB   0FFH,0FFH,0FFH,0FFH,0FFH

              RET

              DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
	      DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH

              RET

              DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
	      DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
      
              RET

              DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
	      DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH

              EXX
	      OUTI
	      EXX
	      IN   L,(C)
	      JP   (HL)

              DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
	      DB   0FFH

              RET

	      DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
	      DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH

              RET

              DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
	      DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
 
              RET

              DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
	      DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH

              EXX
	      INI
	      EXX
	      IN   L,(C)
	      JP   (HL)

              DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
              DB   0FFH

;*************************************************************************

                   REPT 01FFFH - $ 
                   DEFB   0FFH
                   ENDM

END
