home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug097.arc
/
BDOS.MAC
< prev
next >
Wrap
Text File
|
1979-12-31
|
25KB
|
2,072 lines
;************ B D O S **********
SERNO2: DB 0,0,0,0,0,0
BDOSIN: JP L4611
ERRM1: DW L4699
ERRM2: DW L46A5
ERRM3: DW L46AB
ERRM4: DW L46B1
L4611: EX DE,HL
LD (ENTRDE),HL
EX DE,HL
LD A,E
LD (ENTRYE),A
LD HL,0
LD (RETNDE),HL
ADD HL,SP
LD (L490F),HL
LD SP,RAS2
XOR A
LD (L53E0),A
LD (L53DE),A
LD HL,L5374
PUSH HL
LD A,C
CP 29
RET NC
LD C,E
LD HL,CVECS
LD E,A
LD D,0
ADD HL,DE
ADD HL,DE
LD E,(HL)
INC HL
LD D,(HL)
LD HL,(ENTRDE)
EX DE,HL
JP (HL)
CVECS: DW wboote
DW VEC1
DW VEC2
DW VEC3
DW PUNCHO
DW PRNTR
DW VEC6
DW VEC7
DW VEC8
DW VEC9
DW VEC10
DW VEC11
DW VEC12
DW VEC13
DW VEC14
DW VEC15
DW VEC16
DW VEC17
DW VEC18
DW VEC19
DW VEC20
DW VEC21
DW VEC22
DW VEC23
DW VEC24
DW VEC25
DW VEC26
DW VEC27
DW VEC28
DW VEC29
DW VEC30
DW VEC31
DW VEC32
DW VEC33
DW VEC34
DW VEC35
DW VEC36
DW VEC37
DW RETURN
DW RETURN
DW VEC40
L4699: LD HL,L46CA
CALL L46E5
CP 3
JP Z,0
RET
L46A5: LD HL,L46D5
JP L46B4
L46AB: LD HL,L46E1
JP L46B4
L46B1: LD HL,L46DC
L46B4: CALL L46E5
JP 0
L46BA: DEFM 'CP/M Err On : $'
L46CA: DEFM 'Bad Sector$'
L46D5: DEFM 'Select$'
L46DC: DEFM 'File '
L46E1: DEFM 'R/O$'
L46E5: PUSH HL
CALL CRLF2
LD A,(L4942)
ADD A,41
LD (L46BA+0C),A
LD BC,L46BA
CALL PSTRNG
POP BC
CALL PSTRNG
CHIN2: LD HL,L490E
LD A,(HL)
LD (HL),0
OR A
RET NZ
JP CONIN
CHNECH: CALL CHIN2
CALL L4714
RET C
PUSH AF
LD C,A
CALL VEC2
POP AF
RET
L4714: CP 0DH
RET Z
CP 0AH
RET Z
CP 9
RET Z
CP 8
RET Z
CP 20
RET
L4723: LD A,(L490E)
OR A
JP NZ,L4745
CALL INSTAT
AND 1
RET Z
CALL CONIN
CP 13
JP NZ,L4742
CALL CONIN
CP 3
JP Z,0
XOR A
RET
L4742: LD (L490E),A
L4745: LD A,1
RET
COUT3: LD A,(IOFLAG)
OR A
JP NZ,L4762
PUSH BC
CALL L4723
POP BC
PUSH BC
CALL bconout
POP BC
PUSH BC
LD A,(PTRFLG)
OR A
CALL NZ,PRNTR
POP BC
L4762: LD A,C
LD HL,LNEPOS
CP 7FH
RET Z
INC (HL)
CP 20
RET NC
DEC (HL)
LD A,(HL)
OR A
RET Z
LD A,C
CP 8
JP NZ,L4779
DEC (HL)
RET
L4779: CP 0AH
RET NZ
LD (HL),0
RET
; ^X format char out
L477F: LD A,C
CALL L4714
JP NC,VEC2 ;not control code
PUSH AF
LD C,'^' ;Show as ^X
CALL COUT3
POP AF
OR 40
LD C,A
VEC2: LD A,C
CP 9
JP NZ,COUT3
EXPTAB: LD C,20 ;Expand tabs
CALL COUT3
LD A,(LNEPOS)
AND 7
JP NZ,EXPTAB
RET
DESTBS: CALL NDBSPC
LD C,20
CALL bconout
NDBSPC: LD C,8
JP bconout
L47B1: LD C,'#'
CALL COUT3
CALL CRLF2
L47B9: LD A,(LNEPOS)
LD HL,L490B
CP (HL)
RET NC
LD C,20
CALL COUT3
JP L47B9
CRLF2: LD C,0DH
CALL COUT3
LD C,0AH
JP COUT3
PSTRNG: LD A,(BC)
CP '$'
RET Z
INC BC
PUSH BC
LD C,A
CALL VEC2
POP BC
JP PSTRNG
; Create line buffer
VEC10: LD A,(LNEPOS)
LD (L490B),A
LD HL,(ENTRDE)
LD C,(HL)
INC HL
PUSH HL
LD B,0
L47EF: PUSH BC
PUSH HL
L47F1: CALL CHIN2
AND 7FH
POP HL
POP BC
CP 0DH
JP Z,L48C1
CP 0AH
JP Z,L48C1
CP 8
JP NZ,L4816
LD A,B
OR A
JP Z,L47EF
DEC B
LD A,(LNEPOS)
LD (IOFLAG),A
JP L4870
L4816: CP 7FH
JP NZ,L4826
LD A,B
OR A
JP Z,L47EF
LD A,(HL)
DEC B
DEC HL
JP L48A9
L4826: CP 5
JP NZ,L4837
PUSH BC
PUSH HL
CALL CRLF2
XOR A
LD (L490B),A
JP L47F1
L4837: CP 10
JP NZ,L4848
PUSH HL
LD HL,PTRFLG
LD A,1
SUB (HL)
LD (HL),A
POP HL
JP L47EF
L4848: CP 18
JP NZ,L485F
POP HL
L484E: LD A,(L490B)
LD HL,LNEPOS
CP (HL)
JP NC,VEC10
DEC (HL)
CALL DESTBS
JP L484E
; Delete line
L485F: CP 15
JP NZ,L486B
CALL L47B1
POP HL
JP VEC10
; Reprint line
L486B: CP 12
JP NZ,L48A6
L4870: PUSH BC
CALL L47B1
POP BC
POP HL
PUSH HL
PUSH BC
L4878: LD A,B
OR A
JP Z,L488A
INC HL
LD C,(HL)
DEC B
PUSH BC
PUSH HL
CALL L477F
POP HL
POP BC
JP L4878
L488A: PUSH HL
LD A,(IOFLAG)
OR A
JP Z,L47F1
LD HL,LNEPOS
SUB (HL)
LD (IOFLAG),A
L4899: CALL DESTBS
LD HL,IOFLAG
DEC (HL)
JP NZ,L4899
JP L47F1
L48A6: INC HL
LD (HL),A
INC B
L48A9: PUSH BC
PUSH HL
LD C,A
CALL L477F
POP HL
POP BC
LD A,(HL)
CP 3
LD A,B
JP NZ,L48BD
CP 1
JP Z,0
L48BD: CP C
JP C,L47EF
L48C1: POP HL
LD (HL),B
LD C,0DH
JP COUT3
; Character in with echo
VEC1: CALL CHNECH
JP RECOVR
; PUNCH input
VEC3: CALL PUNCHI
JP RECOVR
; Direct console I/O
VEC6: LD A,C
INC A
JP Z,L48E0
INC A
JP Z,INSTAT
JP bconout
L48E0: CALL INSTAT
OR A
JP Z,L5391
CALL CONIN
JP RECOVR
; Get I/O byte
VEC7: LD A,(IOBYTE)
JP RECOVR
; Set I/O byte
VEC8: LD HL,IOBYTE
LD (HL),C
RET
; Print string term by "$"
VEC9: EX DE,HL
LD C,L
LD B,H
JP PSTRNG
; Get console status
VEC11: CALL L4723
RECOVR: LD (RETNDE),A
RETURN: RET
RETN1: LD A,1
JP RECOVR
IOFLAG: DB 0 ;COMPCOL true if computing column posn
L490B: DB 0 ;starting col posn after read
LNEPOS: DB 0 ;column position
PTRFLG: DB 0 ;listing toggle
L490E: DB 0 ;initial key char
L490F: DW 0 ;entry stack pointer
; local stack
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
RAS2:
USRLVL: db 0 ;current user number
L4942: db 0 ;current disk number
ENTRDE: DW 0 ;information address
RETNDE: DW 0 ;address value to return
L4947: LD HL,ERRM2
PRTERR: LD E,(HL)
INC HL
LD D,(HL)
EX DE,HL
JP (HL)
COPYC: INC C
L4950: DEC C
RET Z
LD A,(DE)
LD (HL),A
INC DE
INC HL
JP L4950
L4959: LD A,(L4942)
LD C,A
CALL SELDSK
LD A,H
OR L
RET Z
LD E,(HL)
INC HL
LD D,(HL)
INC HL
LD (DPBSV1),HL ;Unpack returned DPBASE vectors
INC HL
INC HL
LD (DPBSV2),HL
INC HL
INC HL
LD (DPBSV3),HL
INC HL
INC HL
EX DE,HL
LD (SKWPTR),HL ;Set pointer to skew table
LD HL,DPBSV4
LD C,8
CALL COPYC
LD HL,(DPBSV5)
EX DE,HL
LD HL,L53C1
LD C,0FH
CALL COPYC
LD HL,(L53C6)
LD A,H
LD HL,L53DD
LD (HL),0FFH
OR A
JP Z,L499D
LD (HL),0
L499D: LD A,0FFH
OR A
RET
L49A1: CALL HOME
XOR A
LD HL,(DPBSV2)
LD (HL),A
INC HL
LD (HL),A
LD HL,(DPBSV3)
LD (HL),A
INC HL
LD (HL),A
RET
L49B2: CALL READ
JP L49BB
L49B8: CALL WRITE
L49BB: OR A
RET Z
LD HL,ERRM1
JP PRTERR
L49C3: LD HL,(L53EA)
LD C,2
CALL HLDIV2
LD (L53E5),HL
LD (L53EC),HL
L49D1: LD HL,L53E5
LD C,(HL)
INC HL
LD B,(HL)
LD HL,(DPBSV3)
LD E,(HL)
INC HL
LD D,(HL)
LD HL,(DPBSV2)
LD A,(HL)
INC HL
LD H,(HL)
LD L,A
L49E4: LD A,C
SUB E
LD A,B
SBC A,D
JP NC,L49FA
PUSH HL
LD HL,(L53C1)
LD A,E
SUB L
LD E,A
LD A,D
SBC A,H
LD D,A
POP HL
DEC HL
JP L49E4
L49FA: PUSH HL
LD HL,(L53C1)
ADD HL,DE
JP C,L4A0F
LD A,C
SUB L
LD A,B
SBC A,H
JP C,L4A0F
EX DE,HL
POP HL
INC HL
JP L49FA
L4A0F: POP HL
PUSH BC
PUSH DE
PUSH HL
EX DE,HL
LD HL,(L53CE)
ADD HL,DE
LD B,H
LD C,L
CALL SETTRK
POP DE
LD HL,(DPBSV2)
LD (HL),E
INC HL
LD (HL),D
POP DE
LD HL,(DPBSV3)
LD (HL),E
INC HL
LD (HL),D
POP BC
LD A,C
SUB E
LD C,A
LD A,B
SBC A,D
LD B,A
LD HL,(SKWPTR)
EX DE,HL
CALL L5430
LD C,L
LD B,H
JP SETSEC
L4A3E: LD HL,L53C3
LD C,(HL)
LD A,(L53E3)
L4A45: OR A
RRA
DEC C
JP NZ,L4A45
LD B,A
LD A,8
SUB (HL)
LD C,A
LD A,(L53E2)
L4A53: DEC C
JP Z,L4A5C
OR A
RLA
JP L4A53
L4A5C: ADD A,B
RET
L4A5E: LD HL,(ENTRDE)
LD DE,10
ADD HL,DE
ADD HL,BC
LD A,(L53DD)
OR A
JP Z,L4A71
LD L,(HL)
LD H,0
RET
L4A71: ADD HL,BC
LD E,(HL)
INC HL
LD D,(HL)
EX DE,HL
RET
L4A77: CALL L4A3E
LD C,A
LD B,0
CALL L4A5E
LD (L53E5),HL
RET
L4A84: LD HL,(L53E5)
LD A,L
OR H
RET
L4A8A: LD A,(L53C3)
LD HL,(L53E5)
L4A90: ADD HL,HL
DEC A
JP NZ,L4A90
LD (L53E7),HL
LD A,(L53C4)
LD C,A
LD A,(L53E3)
AND C
OR L
LD L,A
LD (L53E5),HL
RET
L4AA6: LD HL,(ENTRDE)
LD DE,0CH
ADD HL,DE
RET
L4AAE: LD HL,(ENTRDE)
LD DE,0FH
ADD HL,DE
EX DE,HL
LD HL,11
ADD HL,DE
RET
L4ABB: CALL L4AAE
LD A,(HL)
LD (L53E3),A
EX DE,HL
LD A,(HL)
LD (L53E1),A
CALL L4AA6
LD A,(L53C5)
AND (HL)
LD (L53E2),A
RET
L4AD2: CALL L4AAE
LD A,(L53D5)
CP 2
JP NZ,L4ADE
XOR A
L4ADE: LD C,A
LD A,(L53E3)
ADD A,C
LD (HL),A
EX DE,HL
LD A,(L53E1)
LD (HL),A
RET
HLDIV2: INC C
HDLUP: DEC C
RET Z
LD A,H
OR A
RRA
LD H,A
LD A,L
RRA
LD L,A
JP HDLUP
CSMSEC: LD C,80
LD HL,(DPBSV4)
XOR A
CSMLUP: ADD A,(HL)
INC HL
DEC C
JP NZ,CSMLUP
RET
HLMUL2: INC C
HMLUP: DEC C
RET Z
ADD HL,HL
JP HMLUP
SETBIT: PUSH BC
LD A,(L4942)
LD C,A
LD HL,0001
CALL HLMUL2
POP BC
LD A,C
OR L
LD L,A
LD A,B
OR H
LD H,A
RET
L4B1E: LD HL,(DROVEC)
LD A,(L4942)
LD C,A
CALL HLDIV2
LD A,L
AND 1
RET
; Write protect disk
VEC28: LD HL,DROVEC
LD C,(HL)
INC HL
LD B,(HL)
CALL SETBIT
LD (DROVEC),HL
LD HL,(L53C8)
INC HL
EX DE,HL
LD HL,(DPBSV1)
LD (HL),E
INC HL
LD (HL),D
RET
L4B44: CALL L4B5E
L4B47: LD DE,9
ADD HL,DE
LD A,(HL)
RLA
RET NC
LD HL,ERRM4
JP PRTERR
; Check disk for read only status
RONLY?: CALL L4B1E
RET Z
LD HL,ERRM3 ;"R/O"
JP PRTERR
L4B5E: LD HL,(DPBSV4)
LD A,(L53E9)
HLINCA: ADD A,L
LD L,A
RET NC
INC H
RET
GETS2: LD HL,(ENTRDE)
LD DE,0EH
ADD HL,DE
LD A,(HL)
RET
CLERS2: CALL GETS2
LD (HL),0
RET
SIGNS2: CALL GETS2
OR 80
LD (HL),A
RET
L4B7F: LD HL,(L53EA)
EX DE,HL
LD HL,(DPBSV1)
LD A,E
SUB (HL)
INC HL
LD A,D
SBC A,(HL)
RET
L4B8C: CALL L4B7F
RET C
INC DE
LD (HL),D
DEC HL
LD (HL),E
RET
L4B95: LD A,E
SUB L
LD L,A
LD A,D
SBC A,H
LD H,A
RET
L4B9C: LD C,0FFH
L4B9E: LD HL,(L53EC)
EX DE,HL
LD HL,(L53CC)
CALL L4B95
RET NC
PUSH BC
CALL CSMSEC
LD HL,(DPBSV6)
EX DE,HL
LD HL,(L53EC)
ADD HL,DE
POP BC
INC C
JP Z,L4BC4
CP (HL)
RET Z
CALL L4B7F
RET NC
CALL VEC28
RET
L4BC4: LD (HL),A
RET
L4BC6: CALL L4B9C
CALL L4BE0
LD C,1
CALL L49B8
JP L4BDA
L4BD4: CALL L4BE0
CALL L49B2
L4BDA: LD HL,LDMADR
JP L4BE3
L4BE0: LD HL,DPBSV4
L4BE3: LD C,(HL)
INC HL
LD B,(HL)
JP bsetdma
L4BE9: LD HL,(DPBSV4)
EX DE,HL
LD HL,(LDMADR)
LD C,80
JP COPYC
L4BF5: LD HL,L53EA
LD A,(HL)
INC HL
CP (HL)
RET NZ
INC A
RET
L4BFE: LD HL,-1
LD (L53EA),HL
RET
L4C05: LD HL,(L53C8)
EX DE,HL
LD HL,(L53EA)
INC HL
LD (L53EA),HL
CALL L4B95
JP NC,L4C19
JP L4BFE
L4C19: LD A,(L53EA)
AND 3
LD B,5
L4C20: ADD A,A
DEC B
JP NZ,L4C20
LD (L53E9),A
OR A
RET NZ
PUSH BC
CALL L49C3
CALL L4BD4
POP BC
JP L4B9E
L4C35: LD A,C
AND 7
INC A
LD E,A
LD D,A
LD A,C
RRCA
RRCA
RRCA
AND 1FH
LD C,A
LD A,B
ADD A,A
ADD A,A
ADD A,A
ADD A,A
ADD A,A
OR C
LD C,A
LD A,B
RRCA
RRCA
RRCA
AND 1FH
LD B,A
LD HL,(DPBSV7)
ADD HL,BC
LD A,(HL)
L4C56: RLCA
DEC E
JP NZ,L4C56
RET
L4C5C: PUSH DE
CALL L4C35
AND 0FEH
POP BC
OR C
L4C64: RRCA
DEC D
JP NZ,L4C64
LD (HL),A
RET
L4C6B: CALL L4B5E
LD DE,10
ADD HL,DE
PUSH BC
LD C,11
L4C75: POP DE
DEC C
RET Z
PUSH DE
LD A,(L53DD)
OR A
JP Z,L4C88
PUSH BC
PUSH HL
LD C,(HL)
LD B,0
JP L4C8E
L4C88: DEC C
PUSH BC
LD C,(HL)
INC HL
LD B,(HL)
PUSH HL
L4C8E: LD A,C
OR B
JP Z,L4C9D
LD HL,(L53C6)
LD A,L
SUB C
LD A,H
SBC A,B
CALL NC,L4C5C
L4C9D: POP HL
INC HL
POP BC
JP L4C75
L4CA3: LD HL,(L53C6)
LD C,3
CALL HLDIV2
INC HL
LD B,H
LD C,L
LD HL,(DPBSV7)
L4CB1: LD (HL),0
INC HL
DEC BC
LD A,B
OR C
JP NZ,L4CB1
LD HL,(L53CA)
EX DE,HL
LD HL,(DPBSV7)
LD (HL),E
INC HL
LD (HL),D
CALL L49A1
LD HL,(DPBSV1)
LD (HL),3
INC HL
LD (HL),0
CALL L4BFE
L4CD2: LD C,0FFH
CALL L4C05
CALL L4BF5
RET Z
CALL L4B5E
LD A,0E5
CP (HL)
JP Z,L4CD2
LD A,(USRLVL)
CP (HL)
JP NZ,L4CF6
INC HL
LD A,(HL)
SUB 24
JP NZ,L4CF6
DEC A
LD (RETNDE),A
L4CF6: LD C,1
CALL L4C6B
CALL L4B8C
JP L4CD2
L4D01: LD A,(L53D4)
JP RECOVR
L4D07: PUSH BC
PUSH AF
LD A,(L53C5)
CPL
LD B,A
LD A,C
AND B
LD C,A
POP AF
AND B
SUB C
AND 1FH
POP BC
RET
L4D18: LD A,0FFH
LD (L53D4),A
LD HL,L53D8
LD (HL),C
LD HL,(ENTRDE)
LD (L53D9),HL
CALL L4BFE
CALL L49A1
L4D2D: LD C,0
CALL L4C05
CALL L4BF5
JP Z,L4D94
LD HL,(L53D9)
EX DE,HL
LD A,(DE)
CP 0E5
JP Z,L4D4A
PUSH DE
CALL L4B7F
POP DE
JP NC,L4D94
L4D4A: CALL L4B5E
LD A,(L53D8)
LD C,A
LD B,0
L4D53: LD A,C
OR A
JP Z,L4D83
LD A,(DE)
CP 3FH
JP Z,L4D7C
LD A,B
CP 0DH
JP Z,L4D7C
CP 0CH
LD A,(DE)
JP Z,L4D73
SUB (HL)
AND 7FH
JP NZ,L4D2D
JP L4D7C
L4D73: PUSH BC
LD C,(HL)
CALL L4D07
POP BC
JP NZ,L4D2D
L4D7C: INC DE
INC HL
INC B
DEC C
JP L4D53
L4D83: LD A,(L53EA)
AND 3
LD (RETNDE),A
LD HL,L53D4
LD A,(HL)
RLA
RET NC
XOR A
LD (HL),A
RET
L4D94: CALL L4BFE
LD A,0FFH
JP RECOVR
L4D9C: CALL RONLY?
LD C,0CH
CALL L4D18
L4DA4: CALL L4BF5
RET Z
CALL L4B44
CALL L4B5E
LD (HL),0E5
LD C,0
CALL L4C6B
CALL L4BC6
CALL L4D2D
JP L4DA4
L4DBE: LD D,B
LD E,C
L4DC0: LD A,C
OR B
JP Z,L4DD1
DEC BC
PUSH DE
PUSH BC
CALL L4C35
RRA
JP NC,L4DEC
POP BC
POP DE
L4DD1: LD HL,(L53C6)
LD A,E
SUB L
LD A,D
SBC A,H
JP NC,L4DF4
INC DE
PUSH BC
PUSH DE
LD B,D
LD C,E
CALL L4C35
RRA
JP NC,L4DEC
POP DE
POP BC
JP L4DC0
L4DEC: RLA
INC A
CALL L4C64
POP HL
POP DE
RET
L4DF4: LD A,C
OR B
JP NZ,L4DC0
LD HL,0
RET
L4DFD: LD C,0
LD E,20
L4E01: PUSH DE
LD B,0
LD HL,(ENTRDE)
ADD HL,BC
EX DE,HL
CALL L4B5E
POP BC
CALL COPYC
L4E10: CALL L49C3
JP L4BC6
L4E16: CALL RONLY?
LD C,0CH
CALL L4D18
LD HL,(ENTRDE)
LD A,(HL)
LD DE,10
ADD HL,DE
LD (HL),A
L4E27: CALL L4BF5
RET Z
CALL L4B44
LD C,10
LD E,0CH
CALL L4E01
CALL L4D2D
JP L4E27
L4E3B: LD C,0CH
CALL L4D18
L4E40: CALL L4BF5
RET Z
LD C,0
LD E,0CH
CALL L4E01
CALL L4D2D
JP L4E40
L4E51: LD C,0FH
CALL L4D18
CALL L4BF5
RET Z
L4E5A: CALL L4AA6
LD A,(HL)
PUSH AF
PUSH HL
CALL L4B5E
EX DE,HL
LD HL,(ENTRDE)
LD C,20
PUSH DE
CALL COPYC
CALL SIGNS2
POP DE
LD HL,0CH
ADD HL,DE
LD C,(HL)
LD HL,0FH
ADD HL,DE
LD B,(HL)
POP HL
POP AF
LD (HL),A
LD A,C
CP (HL)
LD A,B
JP Z,L4E8B
LD A,0
JP C,L4E8B
LD A,80
L4E8B: LD HL,(ENTRDE)
LD DE,0FH
ADD HL,DE
LD (HL),A
RET
L4E94: LD A,(HL)
INC HL
OR (HL)
DEC HL
RET NZ
LD A,(DE)
LD (HL),A
INC DE
INC HL
LD A,(DE)
LD (HL),A
DEC DE
DEC HL
RET
L4EA2: XOR A
LD (RETNDE),A
LD (L53EA),A
LD (L53EB),A
CALL L4B1E
RET NZ
CALL GETS2
AND 80
RET NZ
LD C,0FH
CALL L4D18
CALL L4BF5
RET Z
LD BC,10
CALL L4B5E
ADD HL,BC
EX DE,HL
LD HL,(ENTRDE)
ADD HL,BC
LD C,10
L4ECD: LD A,(L53DD)
OR A
JP Z,L4EE8
LD A,(HL)
OR A
LD A,(DE)
JP NZ,L4EDB
LD (HL),A
L4EDB: OR A
JP NZ,L4EE1
LD A,(HL)
LD (DE),A
L4EE1: CP (HL)
JP NZ,L4F1F
JP L4EFD
L4EE8: CALL L4E94
EX DE,HL
CALL L4E94
EX DE,HL
LD A,(DE)
CP (HL)
JP NZ,L4F1F
INC DE
INC HL
LD A,(DE)
CP (HL)
JP NZ,L4F1F
DEC C
L4EFD: INC DE
INC HL
DEC C
JP NZ,L4ECD
LD BC,-14H
ADD HL,BC
EX DE,HL
ADD HL,BC
LD A,(DE)
CP (HL)
JP C,L4F17
LD (HL),A
LD BC,3
ADD HL,BC
EX DE,HL
ADD HL,BC
LD A,(HL)
LD (DE),A
L4F17: LD A,0FFH
LD (L53D2),A
JP L4E10
L4F1F: LD HL,RETNDE
DEC (HL)
RET
L4F24: CALL RONLY?
LD HL,(ENTRDE)
PUSH HL
LD HL,L53AC
LD (ENTRDE),HL
LD C,1
CALL L4D18
CALL L4BF5
POP HL
LD (ENTRDE),HL
RET Z
EX DE,HL
LD HL,0FH
ADD HL,DE
LD C,11
XOR A
L4F46: LD (HL),A
INC HL
DEC C
JP NZ,L4F46
LD HL,0DH
ADD HL,DE
LD (HL),A
CALL L4B8C
CALL L4DFD
JP SIGNS2
L4F5A: XOR A
LD (L53D2),A
CALL L4EA2
CALL L4BF5
RET Z
LD HL,(ENTRDE)
LD BC,0CH
ADD HL,BC
LD A,(HL)
INC A
AND 1FH
LD (HL),A
JP Z,L4F83
LD B,A
LD A,(L53C5)
AND B
LD HL,L53D2
AND (HL)
JP Z,L4F8E
JP L4FAC
L4F83: LD BC,2
ADD HL,BC
INC (HL)
LD A,(HL)
AND 0FH
JP Z,L4FB6
L4F8E: LD C,0FH
CALL L4D18
CALL L4BF5
JP NZ,L4FAC
LD A,(L53D3)
INC A
JP Z,L4FB6
CALL L4F24
CALL L4BF5
JP Z,L4FB6
JP L4FAF
L4FAC: CALL L4E5A
L4FAF: CALL L4ABB
XOR A
JP RECOVR
L4FB6: CALL RETN1
JP SIGNS2
RDSEQ1: LD A,1
LD (L53D5),A
L4FC1: LD A,0FFH
LD (L53D3),A
CALL L4ABB
LD A,(L53E3)
LD HL,L53E1
CP (HL)
JP C,L4FE6
CP 80
JP NZ,L4FFB
CALL L4F5A
XOR A
LD (L53E3),A
LD A,(RETNDE)
OR A
JP NZ,L4FFB
L4FE6: CALL L4A77
CALL L4A84
JP Z,L4FFB
CALL L4A8A
CALL L49D1
CALL L49B2
JP L4AD2
L4FFB: JP RETN1
WRSEQ1: LD A,1
LD (L53D5),A
L5003: LD A,0
LD (L53D3),A
CALL RONLY?
LD HL,(ENTRDE)
CALL L4B47
CALL L4ABB
LD A,(L53E3)
CP 80
JP NC,RETN1
CALL L4A77
CALL L4A84
LD C,0
JP NZ,L506E
CALL L4A3E
LD (L53D7),A
LD BC,0
OR A
JP Z,L503B
LD C,A
DEC BC
CALL L4A5E
LD B,H
LD C,L
L503B: CALL L4DBE
LD A,L
OR H
JP NZ,L5048
LD A,2
JP RECOVR
L5048: LD (L53E5),HL
EX DE,HL
LD HL,(ENTRDE)
LD BC,10
ADD HL,BC
LD A,(L53DD)
OR A
LD A,(L53D7)
JP Z,L5064
CALL HLINCA
LD (HL),E
JP L506C
L5064: LD C,A
LD B,0
ADD HL,BC
ADD HL,BC
LD (HL),E
INC HL
LD (HL),D
L506C: LD C,2
L506E: LD A,(RETNDE)
OR A
RET NZ
PUSH BC
CALL L4A8A
LD A,(L53D5)
DEC A
DEC A
JP NZ,L50BB
POP BC
PUSH BC
LD A,C
DEC A
DEC A
JP NZ,L50BB
PUSH HL
LD HL,(DPBSV4)
LD D,A
L508C: LD (HL),A
INC HL
INC D
JP P,L508C
CALL L4BE0
LD HL,(L53E7)
LD C,2
L509A: LD (L53E5),HL
PUSH BC
CALL L49D1
POP BC
CALL L49B8
LD HL,(L53E5)
LD C,0
LD A,(L53C4)
LD B,A
AND L
CP B
INC HL
JP NZ,L509A
POP HL
LD (L53E5),HL
CALL L4BDA
L50BB: CALL L49D1
POP BC
PUSH BC
CALL L49B8
POP BC
LD A,(L53E3)
LD HL,L53E1
CP (HL)
JP C,L50D2
LD (HL),A
INC (HL)
LD C,2
; Patch 01 goes next !!!
L50D2: DB 0,0,0,0,0
PUSH AF
CALL GETS2
AND 7FH
LD (HL),A
POP AF
CP 7FH
JP NZ,L5100
LD A,(L53D5)
CP 1
JP NZ,L5100
CALL L4AD2
CALL L4F5A
LD HL,RETNDE
LD A,(HL)
OR A
JP NZ,L50FE
DEC A
LD (L53E3),A
L50FE: LD (HL),0
L5100: JP L4AD2
L5103: XOR A
LD (L53D5),A
L5107: PUSH BC
LD HL,(ENTRDE)
EX DE,HL
LD HL,21
ADD HL,DE
LD A,(HL)
AND 7FH
PUSH AF
LD A,(HL)
RLA
INC HL
LD A,(HL)
RLA
AND 1FH
LD C,A
LD A,(HL)
RRA
RRA
RRA
RRA
AND 0FH
LD B,A
POP AF
INC HL
LD L,(HL)
INC L
DEC L
LD L,6
JP NZ,L518B
LD HL,20
ADD HL,DE
LD (HL),A
LD HL,0CH
ADD HL,DE
LD A,C
SUB (HL)
JP NZ,L5147
LD HL,0EH
ADD HL,DE
LD A,B
SUB (HL)
AND 7FH
JP Z,L517F
L5147: PUSH BC
PUSH DE
CALL L4EA2
POP DE
POP BC
LD L,3
LD A,(RETNDE)
INC A
JP Z,L5184
LD HL,0CH
ADD HL,DE
LD (HL),C
LD HL,0EH
ADD HL,DE
LD (HL),B
CALL L4E51
LD A,(RETNDE)
INC A
JP NZ,L517F
POP BC
PUSH BC
LD L,4
INC C
JP Z,L5184
CALL L4F24
LD L,5
LD A,(RETNDE)
INC A
JP Z,L5184
L517F: POP BC
XOR A
JP RECOVR
L5184: PUSH HL
CALL GETS2
LD (HL),0C0
POP HL
L518B: POP BC
LD A,L
LD (RETNDE),A
JP SIGNS2
L5193: LD C,0FFH
CALL L5103
CALL Z,L4FC1
RET
L519C: LD C,0
CALL L5103
CALL Z,L5003
RET
L51A5: EX DE,HL
ADD HL,DE
LD C,(HL)
LD B,0
LD HL,0CH
ADD HL,DE
LD A,(HL)
RRCA
AND 80
ADD A,C
LD C,A
LD A,0
ADC A,B
LD B,A
LD A,(HL)
RRCA
AND 0FH
ADD A,B
LD B,A
LD HL,0EH
ADD HL,DE
LD A,(HL)
ADD A,A
ADD A,A
ADD A,A
ADD A,A
PUSH AF
ADD A,B
LD B,A
PUSH AF
POP HL
LD A,L
POP HL
OR L
AND 1
RET
L51D2: LD C,0CH
CALL L4D18
LD HL,(ENTRDE)
LD DE,21
ADD HL,DE
PUSH HL
LD (HL),D
INC HL
LD (HL),D
INC HL
LD (HL),D
L51E4: CALL L4BF5
JP Z,L520C
CALL L4B5E
LD DE,0FH
CALL L51A5
POP HL
PUSH HL
LD E,A
LD A,C
SUB (HL)
INC HL
LD A,B
SBC A,(HL)
INC HL
LD A,E
SBC A,(HL)
JP C,L5206
LD (HL),E
DEC HL
LD (HL),B
DEC HL
LD (HL),C
L5206: CALL L4D2D
JP L51E4
L520C: POP HL
RET
; Set random record
VEC36: LD HL,(ENTRDE)
LD DE,20
CALL L51A5
LD HL,21
ADD HL,DE
LD (HL),C
INC HL
LD (HL),B
INC HL
LD (HL),A
RET
L5221: LD HL,(LOGINV)
LD A,(L4942)
LD C,A
CALL HLDIV2
PUSH HL
EX DE,HL
CALL L4959
POP HL
CALL Z,L4947
LD A,L
RRA
RET C
LD HL,(LOGINV)
LD C,L
LD B,H
CALL SETBIT
LD (LOGINV),HL
JP L4CA3
; Select disk
VEC14: LD A,(ENTRYE)
LD HL,L4942
CP (HL)
RET Z
LD (HL),A
JP L5221
FCBDRV: LD A,0FFH
LD (L53DE),A
LD HL,(ENTRDE)
LD A,(HL)
AND 1FH
DEC A
LD (ENTRYE),A
CP 1EH
JP NC,L5275
LD A,(L4942)
LD (L53DF),A
LD A,(HL)
LD (L53E0),A
AND 0E0
LD (HL),A
CALL VEC14
L5275: LD A,(USRLVL)
LD HL,(ENTRDE)
OR (HL)
LD (HL),A
RET
; Return version number
VEC12: LD A,22
JP RECOVR
; Reset disk system
VEC13: LD HL,0
LD (DROVEC),HL
LD (LOGINV),HL
XOR A
LD (L4942),A
LD HL,DBUFF
LD (LDMADR),HL
CALL L4BDA
JP L5221
; Open file
VEC15: CALL CLERS2
CALL FCBDRV
JP L4E51
; Close file
VEC16: CALL FCBDRV
JP L4EA2
; Search for first match of FCB
VEC17: LD C,0
EX DE,HL
LD A,(HL)
CP 3FH
JP Z,L52C2
CALL L4AA6
LD A,(HL)
CP 3FH
CALL NZ,CLERS2
CALL FCBDRV
LD C,0FH
L52C2: CALL L4D18
JP L4BE9
; Search for next match
VEC18: LD HL,(L53D9)
LD (ENTRDE),HL
CALL FCBDRV
CALL L4D2D
JP L4BE9
; Delete file
VEC19: CALL dbuff_clr ;also calls FCBDRV
CALL L4D9C
JP L4D01
; Read sequential
VEC20: CALL FCBDRV
JP RDSEQ1
; Write sequential
VEC21: CALL FCBDRV
JP WRSEQ1
; Make file
VEC22: CALL CLERS2
CALL FCBDRV
JP L4F24
; Rename file
VEC23: CALL dbuff_clr ;also calls FCBDRV
CALL L4E16
JP L4D01
; Return log in vector
VEC24: LD HL,(LOGINV)
JP L5329
; Return current disk number
VEC25: LD A,(L4942)
JP RECOVR
; Set DMA address
VEC26: EX DE,HL
LD (LDMADR),HL
JP L4BDA
; Get address allocation
VEC27: LD HL,(DPBSV7)
JP L5329
; Get R/O vector
VEC29: LD HL,(DROVEC)
JP L5329
; Set file attributes
VEC30: CALL FCBDRV
CALL L4E3B
JP L4D01
; Get disk addr parms
VEC31: LD HL,(DPBSV5)
L5329: LD (RETNDE),HL
RET
; Get/Set user
VEC32: LD A,(ENTRYE)
CP 0FFH
JP NZ,L533B
LD A,(USRLVL)
JP RECOVR
L533B: AND 1FH
LD (USRLVL),A
RET
; Read random
VEC33: CALL FCBDRV
JP L5193
; Write random
VEC34: CALL FCBDRV
JP L519C
; Compute file size
VEC35: CALL FCBDRV
JP L51D2
; Reset drive
VEC37: LD HL,(ENTRDE)
LD A,L
CPL
LD E,A
LD A,H
CPL
LD HL,(LOGINV)
AND H
LD D,A
LD A,L
AND E
LD E,A
LD HL,(DROVEC)
EX DE,HL
LD (LOGINV),HL
LD A,L
AND E
LD L,A
LD A,H
AND D
LD H,A
LD (DROVEC),HL
RET
; Recover after service CVECS
L5374: LD A,(L53DE)
OR A
JP Z,L5391
LD HL,(ENTRDE)
LD (HL),0
LD A,(L53E0)
OR A
JP Z,L5391
LD (HL),A
LD A,(L53DF)
LD (ENTRYE),A
CALL VEC14
L5391: LD HL,(L490F)
LD SP,HL
LD HL,(RETNDE)
LD A,L
LD B,H
RET
; Write random with fill 0
VEC40: CALL FCBDRV
LD A,2
LD (L53D5),A
LD C,0
CALL L5107
CALL Z,L5003
RET
;
L53AC: DB 0E5H
; all set to zero (that's what they should be)
DROVEC: DW 0 ;R/O drives (16 bits)
LOGINV: DW 0 ;On line drives (16 bits)
LDMADR: DW 0080H ;Initial DMA address
DPBSV1: DW 0
DPBSV2: DW 0
DPBSV3: DW 0
DPBSV4: DW 0
DPBSV5: DW 0
DPBSV6: DW 0
DPBSV7: DW 0
L53C1: DW 0
L53C3: DB 0
L53C4: DB 0
L53C5: DB 0
L53C6: DW 0
L53C8: DW 0
L53CA: DW 0
L53CC: DW 0
L53CE: DW 0
SKWPTR: DW 0 ;Pointer to curr dsk skew table
L53D2: DB 0
L53D3: DB 0
L53D4: DB 0
L53D5: DB 0
ENTRYE: DB 0
L53D7: DB 0
L53D8: DB 0
L53D9: DW 0
DB 0,0
L53DD: DB 0
L53DE: DB 0
L53DF: DB 0
L53E0: DB 0
L53E1: DB 0
L53E2: DB 0
L53E3: DB 0
DB 0
L53E5: DW 0
L53E7: DB 0,0
; Local variables for directory access
L53E9: DB 0 ;directory pointer 0,1,2,3
L53EA: DB 0 ;directory counter 0..dirmax
L53EB: DB 0
L53EC: DW 0 ;directory record 0..dirmax/4
; My patch to kill directory buffers before DELETE, RENAME
; 11 bytes
dbuff_clr:
call fcbdrv ;puts disk being used in CURDSK
ld a,(l4942) ;CURDSK by another name
ld c,a ;disk to purge
ld a,7 ;purge directory buffer function
rst 28H ;extended BIOS call
ret
; defb 0,0,0,0,0,0,0,0,0,0,0
defb 0,0,0,0,0,0,0
if ($-serno2) ne 0E00h
error BDOS wrong size !!!
dw $-serno2+zero
endif