        TITLE 'HJ[LPARE 4.3'
;
;       By  Kalle Lindstr|m  <837>
;           Allan Varcoe    <3435>
;           Gunnar Forssell <1631>
;           Niclas Wiberg   <1382>
;           Med flera...
;
; CHANGE & RENUM {r omskrivna versoner
; av programen NYCHANGE- & DELREN.UTL.
; Dessa fr}n b|rjan skrivna av Stig
; Johansson <664>.
;
; Detta {r k{llkoden till Hj{lparen
; version 4.3, skillnaden mot den
; som kom p} Kas. 12 {r att Kalle
; Lindstr|m har {ndrat VOMMEN till
; L\KARE ver 4.3.
;
; Denna k{llkod {r som synes okommen-
; terad, men jag kommer att skriva
; kommentarer.
;
; Allan Varcoe <3435>   1984-04-21
;
INCHAR  EQU  2
INLINE  EQU  5
OUTSTR  EQU  11
INBUF   EQU  21
AVBVEK  EQU  52
OPEN    EQU  62
LOOKUP  EQU  68
BAINIT  EQU  183
EEND    EQU  201
NOEND   EQU  204
EJMIN   EQU  244
INRAD   EQU  219
RUTJMP  EQU  314
BYERUT  EQU  378
SCROLL  EQU  564
NEDRUT  EQU  568
BREDD   EQU  590
BLANKL  EQU  615
CLEAR   EQU  630
CURXY   EQU  659
TANAVB  EQU  799
CTRLC?  EQU  830
DELTKN  EQU  859
CRTVEK  EQU  884
CASAVB  EQU  1428
ERRHND  EQU  1582
ERRHN2  EQU  1641
ERR6    EQU  1797
ERR21   EQU  1807
ERR29   EQU  1819
ERR31   EQU  1825
CRLF    EQU  1858
INSORT  EQU  1872
CLOSE   EQU  2192
INPUT   EQU  2195
WRTLIN  EQU  2198
BLKRD   EQU  2201
GAMKOM  EQU  2605
NEWRUT  EQU  2672
TAB1    EQU  3604
TAB2    EQU  3650
SYMTAB  EQU  3694
NKOD    EQU  3835
FNDLIN  EQU  3897
BCURHL  EQU  4118
DEURHL  EQU  4124
KOMTXT  EQU  4501
BEGIN   EQU  32768
RADANT  EQU  65033
SKOORD  EQU  65036
SLASK1  EQU  65040
SLASK2  EQU  65042
OLDINT  EQU  65046
BUF     EQU  65088
KOMBUF  EQU  65208
;
        ORG  BEGIN
;
        NOP
        JP   INIT
;
ENDRUT  CALL CHECK
        DEFW 2688
        DEFW 2689
;
LSTRUT  CALL CHECK
        DEFW 2799
        DEFW 2797
;
RENRUT  CALL CHECK
        DEFW 3329
        DEFW 3327
;
LOARUT  CALL CHECK
        DEFW 2984
        DEFW 2982
;
EXEKV   CALL CHECK
        DEFW 3433
        DEFW 3431
;
EXEKL   CALL CHECK
        DEFW 3494
        DEFW 3492
;
DMPFIL  DEFM 'PR: '
CRLFST  DEFB 13
        DEFB 10
;
        DEFW ENTRY
        DEFW CASAVB
;
FLAG    DEFB 0
STEPFL  DEFB 1
INKPL?  DEFB 0
INFLAG  DEFB 0
;
RUNRUT  CALL CHECK
        DEFW 3405
        DEFW 3403
;
RUNTST  CALL CHECK
        DEFW 3519
        DEFW 3517
;
ASCBI   CALL CHECK
        DEFW 6174
        DEFW 6172
;
BIASC   CALL CHECK
        DEFW 6242
        DEFW 6240
;
KOMVAR  CALL CHECK
        DEFW 6356
        DEFW 6354
;
RADCOM  CALL CHECK
        DEFW 6288
        DEFW 6286
;
RESTOR  CALL CHECK
        DEFW 8851
        DEFW 8849
;
SLUMP   CALL CHECK
        DEFW 8797
        DEFW 8795
;
CTRLC   CALL CHECK
        DEFW 8995
        DEFW 8993
;
ROWNUM  CALL CHECK
        DEFW 9007
        DEFW 9005
;
CVAR    CALL CHECK
        DEFW 9931
        DEFW 9929
;
STEPC1  CALL CHECK
        DEFW 10317
        DEFW 10315
;
STEPC2  CALL CHECK
        DEFW 13193
        DEFW 13184
;
CHECK   EX   (SP),HL
        PUSH AF
        LD   A,(25)
        CP   190
        JR   Z,JMPRUT
        INC  HL
        INC  HL
JMPRUT  LD   A,(HL)
        INC  HL
        LD   H,(HL)
        LD   L,A
        POP  AF
        EX   (SP),HL
        RET
;
INIT    LD   A,I
        LD   (OLDINT),A
        LD   A,(24576)
        CP   195
        JR   NZ,INIT1
        LD   HL,NEWBO1
        LD   A,136
        JR   INIT2
INIT1   LD   A,255
        LD   HL,NEWBOF
INIT2   LD   (65052),HL
        LD   (DISCMD),A
        LD   A,.HIGH.BEGIN
        LD   I,A
        LD   IY,65046
        XOR  A
        LD   (INKPL?),A
        LD   HL,VOMMEN
        LD   BC,VOMMSZ-VOMMEN
        CALL OUTSTR
        JP   BAINIT
VOMMEN  DEFB 12
        DEFB 27
        DEFB 61
        DEFB 32
        DEFB 42
        DEFM 'HJ[LPARE   ver 4.3'
        DEFB 27
        DEFB 61
        DEFB 34
        DEFB 32
VOMMSZ  EQU  $
;
AVBADR  DEFB 13
        DEFB 10
        DEFB 7
        DEFM 'Break at '
;
ENTRY   PUSH AF
        IN   A,(56)
        CP   159
        JR   Z,AVBROT
        CP   128
        JR   Z,PAUSE
        CP   148
        JR   Z,TRACEO
        CP   150
        JP   Z,BYTTKN
        CP   143
        JP   NZ,KOPPLA
        RES  4,(IY+15)
        JP   KOPPLA
;
TRACEO  SET  4,(IY+15)
        JP   KOPPLA
;
AVBROT  POP  AF
        LD   HL,AVBADR
        LD   BC,12
        CALL OUTSTR
        POP  HL
        CALL BIASC
        LD   HL,NOEND
        PUSH HL
        XOR  A
        LD   (INKPL?),A
        EI
        RETI
;
PRDUMP  PUSH IX
        PUSH DE
        LD   IX,65521
        ADD  IX,SP
        LD   SP,IX
        XOR  A
        LD   HL,DMPFIL
        CALL OPEN
        LD   HL,CRTVEK
        LD   B,24
NEXTLI  PUSH BC
        CALL DEURHL+1
        PUSH HL
        LD   BC,(BREDD)
        EX   DE,HL
        CALL WRTLIN
        LD   HL,CRLFST
        LD   BC,2
        CALL WRTLIN
        POP  HL
        POP  BC
        DJNZ NEXTLI
        LD   HL,CRLFST
        CALL WRTLIN
        CALL CLOSE
        LD   HL,15
        ADD  HL,SP
        LD   SP,HL
        POP  HL
        POP  IX
        JR   HIDEHO
;
PAUSE   PUSH HL
        PUSH BC
        PUSH DE
HIDEHO  LD   HL,(930)
        LD   BC,(BREDD)
        ADD  HL,BC
        DEC  HL
        LD   D,(HL)
        PUSH DE
        LD   (HL),196
        DEC  HL
        LD   D,(HL)
        PUSH DE
        LD   (HL),204
        DEC  HL
        LD   D,(HL)
        PUSH DE
        LD   (HL),207
        DEC  HL
        LD   D,(HL)
        PUSH DE
        LD   (HL),200
K[NNAV  IN   A,(56)
        CP   129
        JR   C,K[NNAV
        LD   B,4
LOADOL  POP  DE
        LD   (HL),D
        INC  HL
        DJNZ LOADOL
        CP   144
        JR   Z,PRDUMP
        POP  DE
        POP  BC
        POP  HL
        JR   KOPPLA
;
BYTTKN  LD   A,(BREDD)
        CP   40
        JR   Z,TILL80
        IN   A,(3)
        JR   KOPPLA
TILL80  IN   A,(4)
;
KOPPLA  LD   A,(INKPL?)
        AND  A
        JP   NZ,TANAVB
        PUSH HL
        LD   HL,(65063)
        DEC  HL
        DEC  HL
        DEC  HL
        LD   A,(HL)
        AND  A
        JR   NZ,NOT
        DEC  HL
        LD   A,(HL)
        CP   240
        JR   NZ,NOT
        LD   A,255
        LD   (INKPL?),A
        DEC  HL
        DEC  HL
        DEC  HL
        PUSH DE
        LD   DE,TECKEN+3
        LD   (HL),D
        DEC  HL
        LD   (HL),E
        POP  DE
        LD   HL,(65011)
        LD   (SKOORD),HL
NOT     POP  HL
        JP   TANAVB
;
GETLI   LD   DE,846
        LD   (65019),DE
        LD   B,C
ALL     CALL DELTKN
        JR   NZ,ALL
BACKA   CALL DELTKN
TECKEN  CALL INCHAR
        CP   ' '
        JR   NC,NOCTRL
        LD   DE,TECKEN
        PUSH DE
        ADD  A,A
        LD   D,0
        LD   E,A
        PUSH HL
        LD   HL,JP_TAB
        ADD  HL,DE
        PUSH AF
        LD   A,(HL)
        INC  HL
        LD   H,(HL)
        LD   L,A
        EX   DE,HL
        POP  AF
        POP  HL
        PUSH DE
        RET
NOCTRL  PUSH HL
        PUSH AF
        LD   A,(INFLAG)
        DEC  A
        CALL Z,PREC
LAGRA   LD   A,B
        CP   C
        JR   NZ,NEJFRS
        LD   HL,(65011)
        LD   (SKOORD),HL
NEJFRS  POP  AF
        POP  HL
        LD   (HL),A
        INC  HL
        LD   (DE),A
        INC  (IX+1)
        LD   A,(BREDD)
        CP   (IX+1)
        CALL Z,SCROLL
        LD   A,(FLAG)
        DEC  A
        RET  Z
        DJNZ TECKEN
KLART   LD   (HL),13
        XOR  A
        LD   (INKPL?),A
        LD   HL,(65063)
        LD   SP,HL
        CALL CTRLC?
        LD   HL,BUF
KLART1  RST  32
        CP   13
        JP   Z,INRAD
        LD   DE,KOMTAB
        CALL LOOKUP
        JP   NZ,EJMIN
        LD   BC,NOEND
        PUSH BC
        LD   DE,KOMADR
        JP   RUTJMP
;
INSERT  CALL CURXY
        LD   A,(DE)
        PUSH HL
        PUSH AF
        JP   LAGRA
;
H\GER   INC  (IX+1)
        LD   A,(BREDD)
        CP   (IX+1)
        CALL Z,SCROLL
        RET
;
V[NSTR  DEC  (IX+1)
        RET  P
        LD   A,(874)
        LD   (IX+1),A
        DEC  (IX+0)
        RET  P
        JR   HOME
;
UPP     DEC  (IX+0)
        RET  P
        LD   (IX+0),0
        RET
;
NED     JP   NEDRUT
;
HOME    LD   DE,0
        LD   (65011),DE
        RET
;
CLRAD   LD   B,C
        LD   HL,(SKOORD)
        LD   H,0
        LD   (65011),HL
        LD   HL,BUF
        RET
;
BACKSP  LD   A,B
        CP   C
        RET  Z
        INC  B
        DEC  HL
        JP   V[NSTR
;
FORMF   JP   CLEAR
;
CLRCRT  PUSH HL
        LD   HL,(65011)
        LD   (SLASK1),HL
R[KNA   CALL CURXY
        LD   A,' '
        LD   (DE),A
        INC  (IX+1)
        LD   A,(BREDD)
        CP   (IX+1)
        JR   NZ,R[KNA
        LD   (IX+1),0
        INC  (IX+0)
        LD   A,(IX+0)
        CP   24
        JR   NZ,R[KNA
        LD   HL,(SLASK1)
        LD   (65011),HL
        POP  HL
        RET
;
INSET   LD   A,(INFLAG)
        DEC  A
        JR   NZ,INP]
        XOR  A
        JR   INSET1
INP]    LD   A,1
INSET1  LD   (INFLAG),A
        RET
;
SKRUT   PUSH HL
        PUSH BC
        LD   HL,(SKOORD)
        LD   (65011),HL
        LD   HL,120
        LD   C,B
        LD   B,0
        AND  A
        SBC  HL,BC
        LD   B,H
        LD   C,L
        LD   HL,BUF
        CALL OUTSTR
        POP  BC
        POP  HL
        RET
;
PREC    PUSH HL
        PUSH BC
        PUSH DE
        PUSH IY
        LD   A,' '
        LD   (SLASK1),A
        CALL FIXRUT
PRERAD  LD   L,(IY+0)
        LD   H,(IY+1)
        LD   DE,(874)
        LD   D,0
        DEC  DE
        ADD  HL,DE
        LD   D,H
        LD   E,L
        INC  DE
        LD   A,(DE)
        LD   (RADANT),A
        LD   A,(874)
        SUB  (IX+1)
        LD   B,0
        LD   C,A
        JR   Z,NOPREC
        LDDR
NOPREC  LD   A,(SLASK1)
        LD   (DE),A
        LD   A,(RADANT)
        LD   (SLASK1),A
        INC  IY
        INC  IY
        LD   (IX+1),0
        INC  (IX+0)
        LD   A,(IX+0)
        CP   24
        JR   C,PRERAD
PRESLT  LD   HL,(SLASK2)
        LD   (65011),HL
        POP  IY
        POP  DE
        POP  BC
        POP  HL
        RET
;
DELET   PUSH HL
        PUSH BC
        PUSH DE
        PUSH IY
        CALL FIXRUT
        LD   DE,0
DELRAD  LD   L,(IY+0)
        LD   H,(IY+1)
        LD   B,0
        LD   C,(IX+1)
        ADD  HL,BC
        LD   A,(HL)
        LD   (DE),A
        LD   D,H
        LD   E,L
        INC  HL
        LD   A,(874)
        SUB  (IX+1)
        JR   Z,NODEL
        LD   B,0
        LD   C,A
        LDIR
NODEL   INC  IY
        INC  IY
        LD   (IX+1),0
        INC  (IX+0)
        LD   A,(IX+0)
        CP   24
        JR   C,DELRAD
        LD   A,' '
        LD   (DE),A
        LD   HL,(SLASK2)
        LD   (65011),HL
        POP  IY
        POP  DE
        POP  BC
        POP  HL
        RET
;
GETROW  LD   A,1
        LD   (FLAG),A
GETSCE  CALL INSERT
        PUSH BC
        CALL CURXY
        POP  BC
        LD   A,(DE)
        CP   ' '
        JR   Z,SPACE
        DEC  B
        JR   NZ,GETSCE
SPACE   XOR  A
        DEC  B
        LD   (FLAG),A
        RET
;
FIXRUT  LD   HL,(65011)
        LD   (SLASK2),HL
        LD   IY,CRTVEK
        LD   A,L
        ADD  A,L
        LD   D,0
        LD   E,A
        ADD  IY,DE
        RET
;
JP_TAB  DEFW TECKEN
        DEFW V[NSTR
        DEFW GETROW
        DEFW TECKEN
        DEFW DELET
        DEFW TECKEN
        DEFW TECKEN
        DEFW TECKEN
        DEFW BACKSP
        DEFW INSERT
        DEFW TECKEN
        DEFW TECKEN
        DEFW FORMF
        DEFW KLART
        DEFW TECKEN
        DEFW TECKEN
        DEFW PREC
        DEFW HOME
        DEFW TECKEN
        DEFW H\GER
        DEFW TECKEN
        DEFW SKRUT
        DEFW TECKEN
        DEFW UPP
        DEFW CLRAD
        DEFW TECKEN
        DEFW NED
        DEFW TECKEN
        DEFW CLRCRT
        DEFW TECKEN
        DEFW INSET
;
KOMTAB  DEFB 128
        DEFM 'HELP'
        DEFB 129
        DEFM 'EXIT'
        DEFB 130
        DEFM 'VAR'
        DEFB 131
        DEFM 'BYE'
        DEFB 132
        DEFM 'SYS'
        DEFB 133
        DEFM 'DEL'
        DEFB 134
        DEFM 'RUN'
        DEFB 135
        DEFM 'CON'
        DEFB 137
        DEFM 'FIND'
        DEFB 138
        DEFM 'LIST'
        DEFB 139
        DEFM 'OLD'
        DEFB 140
        DEFM 'AUTO'
        DEFB 141
        DEFM 'PEEK'
        DEFB 142
        DEFM 'STEP'
        DEFB 138
        DEFM '^'
        DEFB 144
        DEFM 'RAM'
        DEFB 145
        DEFM 'RENUM'
        DEFB 146
        DEFM 'CHANGE'
DISCMD  DEFB 136
        DEFM 'LIB'
        DEFB 147
        DEFM 'DISP'
        DEFB 255
;
KOMADR  DEFW HELP
        DEFW EXIT
        DEFW VAR
        DEFW BYE
        DEFW SYS
        DEFW DEL
        DEFW RUN
        DEFW CON
        DEFW LIB
        DEFW FIND
        DEFW LIST
        DEFW OLD
        DEFW AUTO
        DEFW PEEK
        DEFW STEP
        DEFW LIST
        DEFW RAM
        DEFW RENUM
        DEFW CHANGE
        DEFW DISP
;
SYS     LD   A,(HL)
        INC  HL
        CP   ' '
        JR   C,SYS1
        AND  223
        CP   'B'
        CALL Z,BOFA
        CP   'E'
        CALL Z,EOFA
        CP   'S'
        CALL Z,STACK
SYS1    CALL CRLF
        LD   HL,SYSTXT
        LD   BC,38
        CALL OUTSTR
        LD   HL,(65052)
        CALL UTSKR
        LD   HL,(65054)
        LD   B,6
        CALL UTSKR1
        LD   HL,(65056)
        LD   B,12
        CALL UTSKR1
        LD   HL,(65063)
        LD   B,18
        CALL UTSKR1
        LD   HL,(65054)
        LD   DE,(65052)
        LD   B,24
        CALL SUBUT
        LD   HL,(65063)
        LD   DE,(65056)
        LD   B,30
        CALL SUBUT
        CALL CRLF
        CALL CRLF
        LD   HL,DEVTXT
        LD   BC,8
        CALL OUTSTR
        CALL CRLF
        LD   HL,(65034)
NXTDEV  PUSH HL
        INC  HL
        INC  HL
        LD   BC,3
        CALL OUTSTR
        POP  HL
        CALL DEURHL+1
        EX   DE,HL
        LD   A,H
        OR   L
        JP   Z,CRLF
        PUSH HL
        LD   HL,KOMMA
        LD   BC,2
        CALL OUTSTR
        POP  HL
        JR   NXTDEV
;
SUBUT   AND  A
        SBC  HL,DE
UTSKR1  LD   (IX+1),B
UTSKR   CALL CURXY
        CALL BIASC
        RET
SYSTXT  DEFB 13
        DEFB 10
        DEFM 'BOFA  EOFA  HEAP  STACK '
        DEFM 'FILE  FREE'
        DEFB 13
        DEFB 10
DEVTXT  DEFM 'DEVICES:'
KOMMA   DEFM ', '
;
HELP    CALL CRLF
        LD   HL,KOMTAB
        CALL SKRKOM
        LD   HL,GAMKOM
        CALL SKRKOM
        JP   CRLF
SKRKOM  LD   A,(HL)
        CP   255
        RET  Z
        INC  HL
        PUSH HL
        LD   HL,BUF
        LD   DE,BUF+1
        LD   BC,7
        LD   (HL),' '
        LDIR
        POP  HL
        LD   DE,BUF
MOVKOM  LD   A,(HL)
        BIT  7,A
        JR   NZ,STRSLT
        LDI
        JR   MOVKOM
STRSLT  PUSH HL
        LD   HL,BUF
        LD   BC,8
        CALL OUTSTR
        POP  HL
        JR   SKRKOM
;
AUTO    LD   A,(HL)
        CP   13
        JR   NZ,O2
        LD   DE,65535
        CALL H2
        EX   DE,HL
        LD   BC,10
        ADD  HL,BC
        RET  C
        JR   P2
;
O2      CALL D2
        PUSH DE
        LD   BC,10
        CP   13
        JR   Z,Q2
        CP   ','
        JP   NZ,C2
        RST  24
        CALL D2
        CP   13
        JP   NZ,C2
        LD   B,D
        LD   C,E
Q2      POP  HL
P2      PUSH BC
        PUSH HL
        CALL CRLF
        LD   DE,BUF
        PUSH DE
        CALL BIASC
        EX   DE,HL
        LD   (HL),' '
        INC  HL
        POP  DE
        AND  A
        SBC  HL,DE
        LD   B,H
        LD   C,L
        LD   L,120
        SBC  HL,BC
        PUSH HL
        EX   DE,HL
        PUSH HL
        CALL OUTSTR
        POP  HL
        POP  BC
        PUSH HL
        CALL INLINE
        POP  HL
        RST  32
        CP   13
        JP   Z,NOEND
        CALL RADCOM
        JP   C,18
        POP  HL
        POP  BC
        LD   A,(IX+1)
        OR   (IX+2)
        JR   NZ,R2
        LD   (IX+1),L
        LD   (IX+2),H
        ADD  HL,BC
R2      PUSH AF
        PUSH BC
        PUSH HL
        CALL INSORT
        JP   C,18
        POP  HL
        POP  BC
        POP  AF
        JR   NC,P2
        RET
;
H2      LD   HL,(65052)
        LD   B,D
        LD   C,E
        LD   DE,0
        PUSH DE
B2      LD   A,(HL)
        CP   1
        JR   Z,L\1
        INC  HL
        LD   E,(HL)
        INC  HL
        LD   D,(HL)
        DEC  HL
        DEC  HL
        EX   DE,HL
        AND  A
        SBC  HL,BC
        EX   DE,HL
        JR   Z,A2
        JR   NC,L\1
        EX   DE,HL
        ADD  HL,BC
        EX   (SP),HL
        LD   H,0
        LD   L,A
        ADD  HL,DE
        JR   B2
;
L\1     OR   A
A2      POP  DE
        RET
;
D2      CALL ASCBI
        JR   C,C2
        LD   A,D
        OR   E
        JR   Z,C2
        LD   A,(HL)
        RET
;
C2      JP   ERR31
;
FIND    DEC  HL
        LD   A,(HL)
        AND  223
        CP   'D'
        JR   NZ,FIND
        INC  HL
        LD   A,(HL)
        CP   ' '
        JP   NZ,1825
        INC  HL
        EX   DE,HL
        CALL CRLF
        LD   BC,65208
        LD   HL,(65052)
RAD     LD   A,(HL)
        DEC  A
        RET  Z
        PUSH DE
        PUSH BC
        LD   D,B
        LD   E,C
        CALL KOMTXT
        POP  BC
        EX   (SP),HL
        PUSH DE
        LD   D,B
        LD   E,C
        PUSH BC
SEARCH  PUSH HL
        PUSH DE
J[MF\R  LD   A,(HL)
        CP   13
        JR   Z,FOUND?
        LD   A,(DE)
        CP   13
        JR   Z,HITTAT
        CP   (HL)
        INC  HL
        INC  DE
        JR   Z,J[MF\R
        POP  DE
        INC  DE
        POP  HL
        JR   SEARCH
;
HITTAT  AND  A
FOUND?  POP  HL
        POP  HL
        POP  DE
        EX   (SP),HL
        PUSH DE
        JR   NZ,NOTFND
        XOR  A
        SBC  HL,DE
        LD   B,H
        LD   C,L
        EX   DE,HL
        CALL OUTSTR
        CALL CRLF
        CALL INCHAR
        CP   13
NOTFND  POP  BC
        POP  DE
        POP  HL
        JR   NZ,RAD
        RET
;
RENUM   LD   A,(HL)
        CP   13
        JP   Z,ERR31
        LD   (RENBUF),HL
        CALL ASCBI
        JP   C,ERR31
        LD   HL,RENBUF+2
        LD   (HL),E
        INC  HL
        LD   (HL),D
        LD   HL,(RENBUF)
        CALL FNDLIN
        LD   (RENBUF+4),HL
        LD   HL,(RENBUF)
RENM1   LD   A,(HL)
        INC  HL
        CP   '-'
        JR   NZ,RENM1
        CALL ASCBI
        JP   C,ERR31
        INC  DE
        PUSH HL
        LD   HL,RENBUF+6
        LD   (HL),E
        INC  HL
        LD   (HL),D
        POP  HL
RENM2   LD   A,(HL)
        INC  HL
        CP   ','
        JR   NZ,RENM2
        CP   13
        JR   Z,RENM3
        CALL ASCBI
        LD   A,E
        OR   D
        JR   Z,RENM4
        LD   A,(HL)
        INC  HL
RENM3   CP   13
        JR   Z,RENM5
        CP   ','
        JP   NZ,ERR31
        CALL ASCBI
        JP   C,ERR31
        LD   A,D
        OR   E
RENM4   JP   Z,ERR31
RENM5   PUSH DE
        CALL RENRUT
        POP  BC
RENM6   LD   HL,RENBUF+2
        LD   E,(HL)
        INC  HL
        LD   D,(HL)
        LD   HL,(RENBUF+4)
RENM7   LD   A,(HL)
        DEC  A
        JR   Z,RENM9
        INC  HL
        PUSH AF
        PUSH BC
        CALL RENM15
        POP  BC
        CP   0
        JR   Z,RENM9
        POP  AF
        LD   (HL),E
        INC  HL
        LD   (HL),D
        DEC  A
        ADD  A,L
        LD   L,A
        JR   NC,RENM8
        INC  H
RENM8   EX   DE,HL
        ADD  HL,BC
        EX   DE,HL
        JR   NC,RENM7
        LD   BC,10
        PUSH BC
        JR   RENM6
RENM9   LD   HL,(65052)
        POP  AF
RENM10  LD   A,(HL)
        DEC  A
        JP   Z,NOEND
        INC  HL
        INC  HL
        INC  HL
RENM11  CALL NKOD
        JR   C,RENM10
        LD   A,(HL)
        LD   B,1
        CP   191
        JR   Z,RENM12
        CP   190
        JR   NZ,RENM11
        INC  HL
        LD   B,(HL)
RENM12  INC  HL
RENM13  PUSH HL
        INC  HL
        CALL DEURHL
        LD   A,E
        OR   D
        JR   Z,RENM14
        EX   (SP),HL
        INC  DE
        LD   A,(DE)
        LD   (HL),A
        INC  HL
        INC  DE
        LD   A,(DE)
        LD   (HL),A
RENM14  POP  HL
        DJNZ RENM13
        JR   RENM11
RENM15  PUSH HL
        INC  HL
        LD   A,(HL)
        INC  A
        LD   HL,RENBUF+7
        LD   C,(HL)
        INC  C
        POP  HL
        CP   C
        RET  C
        PUSH HL
        LD   A,(HL)
        INC  A
        LD   HL,RENBUF+6
        LD   C,(HL)
        INC  C
        POP  HL
        CP   C
        RET  C
        LD   A,0
        RET
RENBUF  DEFS 10
;
CHANGE  LD   A,(HL)
        CP   13
        JP   Z,ERR31
        PUSH HL
        CALL CONVER
        POP  HL
        PUSH HL
        LD   DE,CHABUF
        CALL KOMVAR
        POP  HL
        PUSH HL
CHA1    LD   A,(HL)
        CP   '-'
        JR   Z,CHA2
        CP   13
        JP   Z,ERR31
        INC  HL
        JR   CHA1
CHA2    INC  HL
        LD   DE,CHABUF+4
        CALL KOMVAR
        POP  HL
        LD   C,0
        LD   B,6
CHA3    LD   A,(HL)
        CP   '*'
        CALL Z,CHA9
        INC  HL
        DJNZ CHA3
        LD   A,(CHABUF+8)
        CP   2
        CALL NC,CHA10
        LD   HL,(65052)
CHA4    LD   A,(HL)
        PUSH HL
        LD   B,0
        LD   HL,CHABUF+1
        LD   C,(HL)
        POP  HL
        INC  HL
        CP   C
        JR   Z,CHA5
        CP   13
        JR   Z,CHA8
        JR   CHA4
CHA5    PUSH HL
        LD   HL,CHABUF+2
        LD   C,(HL)
        POP  HL
        LD   A,(HL)
        INC  HL
        CP   C
        JR   Z,CHA6
        JR   CHA4
CHA6    PUSH HL
        LD   HL,CHABUF+3
        LD   C,(HL)
        POP  HL
        LD   A,(HL)
        CP   C
        JR   Z,CHA7
        INC  HL
        JR   CHA4
CHA7    DEC  HL
        DEC  HL
        LD   A,(CHABUF+5)
        LD   (HL),A
        INC  HL
        LD   A,(CHABUF+6)
        LD   (HL),A
        INC  HL
        LD   A,(CHABUF+7)
        LD   (HL),A
        INC  HL
        JP   CHA4
CHA8    LD   A,(HL)
        CP   1
        JP   Z,ENDRUT
        JR   CHA4
CHA9    INC  C
        INC  C
        INC  C
        INC  C
        LD   A,C
        LD   (CHABUF+8),A
        RET
CHA10   LD   HL,CHABUF+1
        LD   A,(HL)
        ADD  A,C
        LD   (HL),A
        INC  HL
        LD   A,(HL)
        ADD  A,C
        LD   (HL),A
        LD   HL,CHABUF+5
        LD   A,(HL)
        ADD  A,C
        LD   (HL),A
        INC  HL
        LD   A,(HL)
        ADD  A,C
        LD   (HL),A
        RET
CONVER  LD   HL,BUF
CONV1   LD   A,(HL)
        CP   '('
        CALL Z,CONV3
        CP   ','
        CALL Z,CONV3
        CP   ' '
        CALL Z,CONV4
        CP   13
        RET  Z
CONV2   LD   (HL),A
        INC  HL
        JR   CONV1
CONV3   LD   A,'*'
        RET
CONV4   LD   A,' '
        RET
CHABUF  DEFS 10
;
STEP    LD   A,1
        LD   (STEPFL),A
        LD   A,(HL)
        CP   13
        JR   Z,STPDEF
        CALL ASCBI
        JP   NC,STPNUM
        CP   'A'
        CALL NC,LOARUT
STPDEF  CALL FIXPRG
        LD   (IY+14),0
        LD   DE,(65052)
ANUMB   LD   HL,(65063)
        LD   SP,HL
        LD   HL,ERR29
        PUSH HL
STEP1   LD   A,(DE)
        CP   1
        JP   Z,EEND
        LD   (65068),DE
        PUSH HL
        PUSH BC
        PUSH AF
        PUSH DE
        LD   A,(STEPFL)
        AND  A
        JR   Z,STEP2
        CALL INCHAR
        AND  223
        CP   'E'
        CALL Z,STEP10
        CP   'T'
        POP  DE
        PUSH DE
        CALL Z,ROWNUM
        CP   'L'
        CALL Z,STEP7
STEP2   POP  DE
        POP  AF
        POP  BC
        POP  HL
        LD   HL,0
        ADD  HL,SP
        LD   (65078),HL
        INC  DE
        INC  DE
        INC  DE
        CALL STEP3
        INC  DE
        JR   STEP1
STEP3   EX   DE,HL
        CALL CTRLC?
        JP   NZ,CTRLC
        EX   DE,HL
        LD   A,(DE)
        CP   13
        RET  Z
        CALL STEP4
        JR   STEP3
STEP4   LD   BC,TAB1
STEP5   LD   A,(DE)
        INC  DE
        CP   128
        JR   C,STEP5
        JR   Z,STEP8
        CP   129
        JP   Z,STEP9
        CP   134
        JR   Z,STEP6
        CP   144
        JR   Z,STEP9
        ADD  A,A
        LD   L,A
        LD   H,0
        JP   STEPC1
STEP6   LD   BC,TAB2
        JP   EXEKL
STEP7   LD   DE,BUF
        LD   HL,(65068)
        PUSH DE
        CALL KOMTXT
        EX   DE,HL
        POP  DE
        AND  A
        SBC  HL,DE
        LD   B,H
        LD   C,L
        EX   DE,HL
        CALL OUTSTR
        CALL CRLF
        RET
STEP8   CALL RUNTST
        INC  DE
        INC  DE
        EX   DE,HL
        CALL DEURHL
        POP  HL
        POP  HL
        JP   STEP1
STEP9   CALL RUNTST
        INC  DE
        INC  DE
        EX   DE,HL
        CALL DEURHL
        CALL STEPC2
        PUSH HL
        CALL STEP1
        POP  DE
        RET
;
STEP10  LD   A,0
        LD   (STEPFL),A
        RET
;
STPNUM  LD   A,(65062)
        AND  1
        JP   Z,NOTFIX
        LD   (IY+14),0
        CALL FNDLIN
        JP   NZ,ERR6
        EX   DE,HL
        CALL CRLF
        JP   ANUMB
;
RUN     LD   A,(HL)
        CP   '0'
        JP   C,RUNRUT
        CP   ':'
        JP   NC,RUNRUT
        CALL ASCBI
        JP   C,ERR31
        CALL FNDLIN
        JP   NZ,ERR6
        PUSH HL
        CALL FIXPRG
        LD   (IY+14),0
        POP  DE
        JP   EXEKV
;
FIXPRG  CALL CRLF
        CALL ENDRUT
        CALL SYMTAB
        CALL RESTOR
        CALL SLUMP
        RET
;
CON     LD   A,(65062)
        AND  1
        JR   Z,NOTFIX
        LD   DE,(65052)
        LD   (IY+14),0
        LD   A,(HL)
        CP   13
        JP   Z,EXEKV
        CALL ASCBI
        JP   C,ERR31
        CALL FNDLIN
        JP   NZ,ERR6
        EX   DE,HL
        JP   EXEKV
NOTFIX  RST  16
        DEFB 67+128
;
RAM     CALL ASCBI
        JP   C,RAMDEF
        CALL FNDLIN
        JP   NZ,ERR6
RAM1    CALL CRLF
        LD   IX,65011
        PUSH HL
        CALL DEURHL
        EX   DE,HL
        CALL UTSKR
        LD   A,5
        ADD  A,(IX+1)
        LD   (IX+1),A
        CALL CURXY
        EX   DE,HL
        LD   (HL),','
        INC  (IX+1)
        POP  HL
        PUSH HL
        CALL UTSKR
        CALL CRLF
        POP  HL
        LD   B,(HL)
GETBY   PUSH BC
        PUSH HL
        LD   A,(HL)
        LD   H,0
        LD   L,A
        CALL UTSKR
        LD   A,(IX+1)
        ADD  A,4
        LD   (IX+1),A
        LD   A,(BREDD)
        CP   (IX+1)
        CALL Z,ADDLIN
        POP  HL
        INC  HL
        POP  BC
        DJNZ GETBY
RADEND  CALL CRLF
        CALL INCHAR
        CP   13
        JP   Z,CRLF
        LD   A,(HL)
        DEC  A
        JP   Z,CRLF
        JP   RAM1
;
ADDLIN  PUSH BC
        CALL CRLF
        POP  BC
        RET
;
RAMDEF  LD   HL,(65052)
        LD   A,(HL)
        CP   1
        RET  Z
        JP   RAM1
;
LIST    LD   A,(HL)
        CP   '"'
        JP   Z,LSTRUT
        CP   ''''
        JP   Z,LSTRUT
        CP   'A'
        JP   NC,LSTRUT
LIST1   LD   A,15
        LD   (RADANT),A
        CALL CRLF
        CALL OPTION
        PUSH BC
        CALL FNDLIN
N[SRAD  POP  BC
        LD   A,(HL)
        XOR  1
        JR   Z,LSTSLT
        CALL CTRLC?
        JR   NZ,LSTSLT
        LD   D,H
        LD   E,L
        INC  HL
        LD   A,(HL)
        INC  HL
        LD   H,(HL)
        LD   L,A
        SBC  HL,BC
        JR   C,NEJSLT
        JR   NZ,LSTSLT
NEJSLT  EX   DE,HL
        PUSH BC
        LD   DE,BUF
        PUSH DE
        CALL KOMTXT
        EX   (SP),HL
        EX   DE,HL
        AND  A
        SBC  HL,DE
        EX   DE,HL
        LD   C,E
        DEC  C
CRTRAD  LD   A,(BREDD)
        LD   B,A
        PUSH BC
        CALL CURXY
        POP  BC
TKN     LDI
        LD   A,C
        AND  A
        JR   Z,RADSLT
        DJNZ TKN
        CALL STEPPA
        JR   CRTRAD
RADSLT  CALL STEPPA
        POP  HL
        JR   N[SRAD
STEPPA  PUSH BC
        CALL CRLF
        POP  BC
        LD   A,(RADANT)
        DEC  A
        JR   Z,STEG
        LD   (RADANT),A
        RET
STEG    CALL INCHAR
        CP   ' '
        RET  Z
STEG2   LD   HL,(65063)
        LD   SP,HL
        LD   A,255
        LD   (INKPL?),A
        LD   HL,BUF
        LD   C,120
        SET  7,(IX+2)
        JP   GETLI
;
LSTSLT  DEC  (IX+0)
        JP   NOEND
;
PEEK    LD   A,23
        LD   (RADANT),A
        LD   (SLASK1),A
        PUSH HL
        CALL CRLF
        POP  HL
        LD   A,(HL)
        CP   13
        JR   Z,PEEK3
        CALL ASCBI
        JP   C,ERR31
        EX   DE,HL
        LD   (SLASK2),HL
;
PEEK3   LD   HL,(SLASK2)
        PUSH HL
        CALL UTSKR
        POP  HL
        LD   IX,65011
        LD   (IX+1),6
        LD   A,(HL)
        PUSH HL
        LD   H,0
        LD   L,A
        CALL UTSKR
        LD   (IX+1),11
        CALL CURXY
        POP  HL
        LD   A,H
        CALL HEXBYT
        LD   A,L
        CALL HEXBYT
        INC  DE
        LD   A,(HL)
        CALL HEXBYT
        INC  DE
        INC  DE
        INC  DE
        LD   A,(HL)
        LD   (DE),A
        INC  DE
        PUSH AF
        LD   A,135
        LD   (DE),A
        POP  AF
        LD   (IX+1),25
        LD   A,(HL)
        INC  HL
        LD   H,(HL)
        LD   L,A
        CALL UTSKR
        CALL CRLF
        LD   A,(RADANT)
        CP   1
        JR   Z,PEEKA2
        LD   HL,(SLASK2)
        INC  HL
        LD   (SLASK2),HL
        LD   A,(RADANT)
        DEC  A
        LD   (RADANT),A
        JR   PEEK3
PEEKA2  LD   IX,65011
        LD   (IX+0),23
        LD   (IX+1),0
        CALL INCHAR
        CP   8
        JR   Z,PEEKBA
        CP   9
        JR   Z,PEEKFR
        CP   ' '
        JP   NZ,STEG2
PEEKFR  LD   A,(SLASK1)
        CP   23
        JR   Z,PEEKF2
        LD   HL,(SLASK2)
        LD   DE,22
        ADC  HL,DE
PEEKF3  LD   (SLASK2),HL
        LD   A,23
        LD   (SLASK1),A
        JP   PEEK3
PEEKF2  LD   HL,(SLASK2)
        INC  HL
        JR   PEEKF3
PEEKBA  CALL BSCROL
        LD   A,(SLASK1)
        CP   0
        JR   Z,PEEKB2
        LD   HL,(SLASK2)
        LD   DE,23
        SBC  HL,DE
PEEKB3  LD   (SLASK2),HL
        LD   IX,65011
        LD   (IX+0),0
        LD   (IX+1),0
        XOR  A
        LD   (SLASK1),A
        JP   PEEK3
PEEKB2  LD   HL,(SLASK2)
        DEC  HL
        JR   PEEKB3
;
HEXBYT  PUSH AF
        RRCA
        RRCA
        RRCA
        RRCA
        AND  15
        CALL HEXNYB
        POP  AF
        AND  15
HEXNYB  PUSH HL
        LD   HL,HEX
        LD   B,0
        LD   C,A
        ADD  HL,BC
        LDI
        POP  HL
        RET
;
HEX     DEFM '0123456789ABCDEF'
;
OPTION  LD   A,(HL)
        CP   13
        LD   DE,0
        LD   BC,65535
        JR   Z,NOOPTS
        CALL ASCBI
        PUSH DE
        LD   A,(HL)
        CP   13
        JR   Z,BAREN
        CP   '-'
        JR   Z,TILL
        CP   ','
        JP   NZ,ERR31
TILL    RST  24
        CALL ASCBI
        JR   NC,BAREN
        LD   DE,65535
BAREN   LD   B,D
        LD   C,E
        POP  DE
NOOPTS  RET
;
BSCROL  PUSH HL
        PUSH DE
        PUSH BC
        PUSH IX
        LD   B,22
        LD   IX,926
B2SCRL  PUSH BC
        LD   H,(IX+1)
        LD   L,(IX+0)
        LD   D,(IX+3)
        LD   E,(IX+2)
        LD   BC,(BREDD)
        LDIR
        DEC  IX
        DEC  IX
        POP  BC
        DJNZ B2SCRL
        LD   DE,(CRTVEK)
        CALL BLANKL
        POP  IX
        POP  BC
        POP  DE
        POP  HL
        RET
;
BOFA    LD   DE,65052
NYPEEK  LD   A,(HL)
        CP   '='
        JP   NZ,ERR31
        INC  HL
        PUSH DE
        AND  A
        CALL ASCBI
        JP   C,ERR31
        POP  HL
        LD   (HL),E
        INC  HL
        LD   (HL),D
        XOR  A
        RET
;
EOFA    LD   DE,65054
        JR   NYPEEK
;
STACK   LD   DE,65063
        JR   NYPEEK
;
DEL     CALL ASCBI
        PUSH DE
        LD   A,(HL)
        CP   ','
        JR   Z,DEL1
        CP   '-'
        JR   Z,DEL1
        RST  16
        CP   L
DEL1    RST  24
        CALL ASCBI
        JR   NC,DEL2
        DEC  DE
        DEC  DE
DEL2    INC  DE
        LD   A,(HL)
        CP   13
        JP   NZ,ERR31
        POP  HL
        EX   DE,HL
        PUSH HL
        DEC  HL
        AND  A
        SBC  HL,DE
        JP   C,ERR31
        CALL FNDLIN
        POP  DE
        PUSH HL
        CALL FNDLIN
        POP  DE
        LD   B,0
DEL3    LD   C,(HL)
        LD   A,C
        DEC  A
        JR   Z,DEL4
        LDIR
        JR   DEL3
DEL4    EX   DE,HL
        LD   (HL),C
        LD   (65054),HL
        RET
;
EXIT    LD   HL,HEJD]
        LD   BC,16
        CALL OUTSTR
        LD   A,(OLDINT)
        LD   I,A
        LD   HL,BEGIN
        LD   (65052),HL
        RET
HEJD]   DEFB 10
        DEFB 13
        DEFM 'Standard ABC80'
;
BYE     LD   HL,CMDINT
        XOR  A
        CALL OPEN
        CALL EXIT
        JP   BYERUT
CMDINT  DEFM 'CMDINT.SYS'
        DEFB 13
;
VAR     CALL CRLF
        RST  32
        CP   13
        JP   NZ,VARRAD
        XOR  A
        LD   (SLASK1),A
        CALL ENDRUT
        CALL SYMTAB
        LD   BC,0
        LD   HL,(65065)
VARSTA  LD   A,H
        OR   L
        RET  Z
        PUSH BC
        LD   DE,BUF
        LD   A,27
        LD   (DE),A
        INC  DE
        LD   A,61
        LD   (DE),A
        INC  DE
        LD   A,(65011)
        ADD  A,32
        LD   (DE),A
        INC  DE
        LD   A,(SLASK1)
        ADD  A,32
        LD   (DE),A
        INC  DE
        LD   A,(HL)
        INC  HL
        LDI
        LD   C,A
        RRCA
        RRCA
        RRCA
        RRCA
        AND  15
        CP   15
        JR   Z,NEJ
        ADD  A,48
        LD   (DE),A
        INC  DE
NEJ     LD   A,C
        AND  3
        JR   Z,FLYT
        XOR  39
        DEC  A
        LD   (DE),A
        INC  DE
FLYT    LD   A,C
        AND  12
        JR   Z,INGET
        LD   A,'('
        LD   (DE),A
        INC  DE
        BIT  3,C
        JR   Z,ETT
        LD   A,','
        LD   (DE),A
        INC  DE
ETT     LD   A,')'
        LD   (DE),A
        INC  DE
INGET   PUSH HL
        EX   DE,HL
        AND  A
        LD   DE,BUF
        SBC  HL,DE
        PUSH HL
        POP  BC
        LD   HL,BUF
        CALL OUTSTR
        POP  HL
        LD   A,(SLASK1)
        ADD  A,8
        PUSH HL
        LD   HL,(BREDD)
        CP   L
        POP  HL
        LD   (SLASK1),A
        JR   C,EJCRLF
        CALL CRLF
        XOR  A
        LD   (SLASK1),A
EJCRLF  LD   A,(HL)
        INC  HL
        LD   H,(HL)
        LD   L,A
        POP  BC
        LD   A,C
        CP   19
        JR   C,EJ
        LD   A,255
EJ      ADD  A,1
        LD   C,A
        JP   VARSTA
;
VARRAD  CALL CVAR
        JP   C,ERR31
        LD   A,(HL)
        CP   '('
        LD   E,0
        JR   NZ,SLUT
        RST  24
        CP   ','
        LD   E,1
        JR   NZ,PAR
        LD   E,2
        RST  24
PAR     CP   ')'
        JP   NZ,ERR31
        RST  24
SLUT    CP   13
        JP   NZ,ERR31
        LD   A,E
        ADD  A,A
        ADD  A,A
        OR   C
        LD   C,A
        LD   D,B
        LD   E,C
        XOR  A
        LD   (SLASK1),A
        EX   AF,AF'
        LD   HL,(65052)
B\RJA   LD   A,(HL)
        DEC  A
        RET  Z
        INC  HL
        PUSH HL
        LD   B,0
        LD   C,A
NEJJ    LD   A,E
        CPIR
        JR   Z,HITTA
        POP  BC
N[STA   JR   B\RJA
HITTA   LD   A,(HL)
        CP   D
        JR   NZ,NEJJ
        POP  HL
        PUSH HL
        PUSH DE
        LD   DE,BUF
        LD   A,27
        LD   (DE),A
        INC  DE
        LD   A,61
        LD   (DE),A
        INC  DE
        LD   A,(65011)
        ADD  A,32
        LD   (DE),A
        INC  DE
        LD   A,(SLASK1)
        ADD  A,32
        LD   (DE),A
        INC  DE
        LD   A,(HL)
        INC  HL
        LD   H,(HL)
        LD   L,A
        CALL BIASC
        EX   DE,HL
        AND  A
        LD   DE,BUF
        SBC  HL,DE
        PUSH HL
        POP  BC
        LD   HL,BUF
        CALL OUTSTR
        LD   A,(SLASK1)
        ADD  A,8
        LD   (SLASK1),A
        PUSH HL
        LD   HL,(BREDD)
        CP   L
        POP  HL
        JR   C,ECRLF1
        CALL CRLF
        LD   A,0
        LD   (SLASK1),A
ECRLF1  EX   AF,AF'
        INC  A
        CP   19
        JR   C,G
        XOR  A
G       EX   AF,AF'
        POP  DE
        POP  HL
        DEC  HL
        LD   B,0
        LD   C,(HL)
        AND  A
        ADD  HL,BC
        JR   N[STA
;
OLD     LD   A,(HL)
        CP   13
        JR   Z,OLD1
        CALL ASCBI
        JP   C,ERR31
        LD   (65052),DE
        LD   DE,0
OLD1    CALL FNDLIN
        PUSH HL
        LD   E,0
        LD   A,13
AGAIN   INC  E
        CPI
        JR   NZ,AGAIN
        POP  HL
        LD   (HL),E
        PUSH HL
        POP  BC
MORE    LD   A,13
        CPIR
        LD   A,1
        CP   (HL)
        JR   NZ,MORE
        LD   (65054),HL
        INC  HL
        LD   (65056),HL
        JP   CRLF
;
NEWBOF  EQU  $
;
;       BOFA UTAN FLOPPY
;
LIB     LD   A,(HL)
        CP   13
        JR   Z,B]DA
        LD   B,A
        RST  24
        CP   13
        JP   NZ,ERR31
        LD   A,B
        SUB  '0'
        AND  7
        JR   DIR
;
B]DA    LD   A,0
        CALL DIR
        LD   A,1
;
DIR     LD   (64769),A
        ADD  A,'0'
        PUSH AF
        LD   HL,DRIVE
        LD   BC,4
        CALL OUTSTR
        CALL CURXY
        POP  AF
        LD   (DE),A
        INC  DE
        LD   A,':'
        LD   (DE),A
        INC  (IX+1)
        INC  (IX+1)
        LD   DE,0
        CALL 24678
        LD   A,(64789)
        AND  A
        RET  NZ
        LD   BC,32
        LD   HL,62944
NAMN    LD   A,(HL)
        CP   ' '
        JR   C,EJGOD
        CP   97
        JR   C,JABRA
EJGOD   LD   A,C
        CP   8
        JR   Z,RDFRMM
        LD   C,8
        LD   HL,62968
        JR   NAMN
;
JABRA   CALL OUTSTR
RDFRMM  CALL CRLF
        CALL CRLF
;
        LD   DE,192
        CALL 24678
        LD   DE,62720
        LD   HL,0
        LD   B,160
SP]R    LD   A,(DE)
        PUSH BC
        LD   B,8
SEKTOR  SRL  A
        JR   C,UPPTAG
        INC  HL
UPPTAG  DJNZ SEKTOR
        POP  BC
        INC  DE
        DJNZ SP]R
        LD   (64955),HL
;
        LD   HL,62959
        LD   DE,64944
        LD   BC,8
        LDIR
;
        LD   HL,64944
        LD   DE,512
        LD   B,8
DIRSEK  PUSH DE
        PUSH BC
        PUSH HL
        LD   A,(HL)
        CP   1
        CALL NZ,24678
        POP  HL
        LD   B,(HL)
        INC  HL
        PUSH HL
        LD   HL,62736
        JP   MFILE
;
NOFILE  INC  B
        POP  HL
        LD   DE,16
        ADD  HL,DE
        JP   MFILE
FILE    PUSH HL
        LD   DE,4
        ADD  HL,DE
        LD   A,(HL)
        CP   94
        JR   NC,NOFILE
        CP   65
        JR   C,NOFILE
        PUSH BC
        LD   DE,BUF
        LD   BC,8
        LDIR
        LD   A,'.'
        LD   (DE),A
        INC  DE
        LD   BC,3
        LDIR
        LD   HL,BUF
        LD   BC,12
        CALL OUTSTR
        POP  BC
        POP  HL
        LD   DE,16
        ADD  HL,DE
        LD   A,(BREDD)
        CP   80
        LD   A,(65012)
        JR   Z,RUT80
        AND  A
        JR   Z,MFILE
        ADD  A,2
        LD   (65012),A
        JR   MFILE
;
RUT80   ADD  A,4
        CP   79
        PUSH BC
        CALL NC,CRLF
        POP  BC
        LD   (65012),A
MFILE   DJNZ FILE
        POP  HL
        POP  BC
        POP  DE
        LD   A,E
        ADD  A,32
        LD   E,A
        DJNZ DIRSEK
        LD   A,(65012)
        AND  A
        CALL NZ,CRLF
        CALL CRLF
;
        LD   HL,LEDIG
        LD   BC,25
        CALL OUTSTR
        LD   HL,(64955)
        CALL BIASC
        CALL CRLF
        RET
;
DRIVE   DEFB 13
        DEFB 10
        DEFM 'DR'
;
LEDIG   DEFM 'Antal lediga sektorer {r '
;
DISP    PUSH HL
SRC     LD   A,(HL)
        CP   '.'
        JR   Z,SRCEND
        CP   13
        JR   Z,DEFAUL
        INC  HL
        JR   SRC
DEFAUL  EX   DE,HL
        LD   HL,EXT
        LD   BC,5
        LDIR
SRCEND  POP  HL
        LD   IX,65521
        ADD  IX,SP
        LD   SP,IX
        LD   (SLASK1),IX
        LD   (SLASK2),HL
        CALL CRLF
        LD   IX,(SLASK1)
        XOR  A
        CALL OPEN
        XOR  A
        LD   IX,(SLASK1)
        CALL BLKRD
        LD   H,(IX+11)
        LD   L,(IX+10)
        LD   A,128
        CP   (HL)
        JR   NC,DISP3
        INC  HL
        JR   DISP2
;
DISP1   XOR  A
        LD   IX,(SLASK1)
        CALL BLKRD
        LD   H,(IX+11)
        LD   L,(IX+10)
DISP2   LD   A,(HL)
        PUSH AF
        PUSH HL
        EX   DE,HL
        LD   HL,65410
        ADD  HL,SP
        LD   SP,HL
        EX   DE,HL
        PUSH DE
        CALL KOMTXT
        EX   DE,HL
        POP  DE
        PUSH DE
        LD   (HL),10
        INC  HL
        SBC  HL,DE
        LD   B,H
        LD   C,L
        EX   DE,HL
        CALL OUTSTR
        POP  DE
        PUSH HL
        LD   HL,128
        ADD  HL,SP
        POP  DE
        LD   SP,HL
        EX   DE,HL
        CALL INCHAR
        CP   13
        JR   Z,DISP6
        POP  HL
        POP  AF
        ADD  A,L
        LD   L,A
        XOR  A
        CP   (HL)
        JR   Z,DISP1
        INC  A
        CP   (HL)
        JR   Z,DISP7
        JR   DISP2
;
DISP3   LD   IX,(SLASK1)
        CALL CLOSE
        XOR  A
        LD   HL,(SLASK2)
        LD   IX,(SLASK1)
        CALL OPEN
DISP4   LD   HL,BUF
        LD   C,119
        LD   IX,(SLASK1)
        PUSH HL
        CALL INPUT
        POP  HL
        JR   C,ERROR
        EX   DE,HL
        LD   (HL),10
        INC  HL
        SBC  HL,DE
        LD   B,H
        LD   C,L
        LD   HL,BUF
        CALL OUTSTR
        CALL INCHAR
        CP   13
        JR   Z,DISP7
        JR   DISP4
;
DISP6   POP  HL
        POP  AF
DISP7   LD   IX,(SLASK1)
        CALL CLOSE
        LD   HL,15
        ADD  HL,SP
        LD   SP,HL
        RET
;
ERROR   AND  A
        JR   Z,DISP7
        PUSH AF
        LD   IX,(SLASK1)
        CALL CLOSE
        POP  AF
        LD   HL,15
        ADD  HL,SP
        LD   SP,HL
        JP   ERRHN2
;
EXT     DEFM '.TXT'
        DEFB 13
;
NEWBO1  EQU  $
;
;       BOFA MED FLOPPY
;
        END
;
