home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Oakland CPM Archive
/
oakcpm.iso
/
cpm
/
bye5
/
kmdrsx.lbr
/
KMDRSX.MQC
/
KMDRSX.MAC
Wrap
Text File
|
1986-08-05
|
4KB
|
183 lines
; KMDRSX.MAC 07/22/86
;
; Copyright (c) 1986 Jim Lopushinsky
;
; This RSX was written to add 2 features to KMD for CP/M+ RCP/Ms.
; It will attach to any version of KMD running under BYE509 or
; newer. See the DOC file for details.
.z80
NO EQU 0
YES EQU NOT NO
TOUCH EQU YES ; Yes, to write first record back
; during a KMD S or L option to force
; an update time-stamp.
maxdrv equ 'C' ; Max drive for 'Touching' for KMD S
bdos equ 5
fcb equ 5ch
wheel equ 3eh ; ZCPR wheel
maxusr equ 3fh ; ZCPR max user
;
; RSX header
;
dw 0,0,0
entry: jp ftest
next: jp 0
prev: dw 0
remove: db 0ffh
db 0
db 'KMDRSX '
db 0,0,0
ftest:
pop hl ; Get return address
push hl
ld a,(next-1) ; Get our page
cp h ; Are we called from above?
jp c,next ; Ignore calls from higher RSX's
ld a,(fcb+1) ; Get option
cp 'R' ; Is it receive?
jp z,dor
IF TOUCH
cp 'S' ; Is it send?
jp z,dos
cp 'L' ; Is it library send?
jp z,dos
ENDIF ; TOUCH
delus: ; Here to delete this RSX. We will no
; longer intercept anything
call remrsx ; Delete this RSX
jp bdos ; Have to do this, because our vectors
; will no longer be in place
dor: ; Process Receive file
push de
push bc
ld de,delrsx
ld c,60
call next ; BYE will delete all RSX's (including
; this one)
pop bc
pop de
jp bdos ; Onward. We will no longer intercept
IF TOUCH
dos: ; Process Send file
ld (sflag),a ; Set send file flag
ld a,(wheel) ; Get wheel byte
or a ; Is it set?
jp nz,delus ; Go delete this RSX if set.
push de
push bc
ld de,scbpb
ld c,49
call next ; Return address of SCB for later calls
ld (scbbase),hl ; Save SCB
pop bc
pop de
ld hl,stest ; entry for subsequent intercepts
ld (entry+1),hl ; Modify JP FTEST to JP STEST
stest: ; Here to test function during send
ld a,c ; Get function
cp 33 ; Random read?
jp z,isread ; Jump if read
cp 20 ; Read file?
jp nz,next ; Ignore if not
ld a,(sflag) ; Get option
cp 'S' ; Is it send?
jp nz,next ; Ignore if not
ld a,c
isread:
ld (function),a ; Save read function
ld hl,(scbbase) ; Get SCB address
ld l,0e0h ; Point to user number
ld a,(hl) ; Get it
ld hl,(maxusr) ; Point to ZCPR max user
cp (hl) ; Out of range?
jp nc,delus ; Ignore if user > max user
ld a,(de) ; Get drive code
dec a ; Default?
jp p,isdrive
ld hl,(scbbase)
ld l,0dah ; Point to current drive
ld a,(hl) ; Get it
isdrive:
cp maxdrv-40h ; Out of range?
jp nc,delus ; Go delete this RSX and continue
push de ; Save FCB addr
ld hl,ourfcb
ld b,36
call move ; Move a copy of FCB for us
pop de ; Restore FCB addr
call next ; Attempt read file
or a ; Any errors?
jp z,noerror ; Jump if no errors
push hl ; Save error code
call remrsx ; Remove this RSX
pop hl ; Restore error code
ld a,l
ld b,h
ret
noerror:
ld hl,(scbbase)
ld l,0e7h ; Point to error mode
push hl ; Save addr for later
ld (hl),0ffh ; Set error mode to return so that we don't
; abort in case of read-only file.
ld de,ourfcb ; Point to our FCB
ld a,(function) ; Get read function
inc a ; Convert to write function
ld c,a
call next ; Write first record back to cause an
; update time stamp.
pop hl ; Get addr of error mode
ld (hl),0 ; Reset error mode
call remrsx ; Remove this RSX (no longer needed)
ld hl,0 ; Restore read return codes
ld a,h
ld b,a
ret ; Back to KMD
ENDIF ; TOUCH
remrsx:
push de
push bc
ld de,0
ld c,59
call next ; Loader will delete this RSX
pop bc
pop de
ret
IF TOUCH
move:
ld a,(de)
ld (hl),a
inc de
inc hl
dec b
jp nz,move
ret
ENDIF ; TOUCH
delrsx: db 11 ; Delete RSX's function for BYE
IF TOUCH
sflag: db 0 ; Send option flag
scbbase: ds 2 ; Address of SCB
scbpb: db 3ah ; To return SCB address
db 0 ; Get op
ourfcb: ds 36 ; Our FCB
function: ds 1 ; Read function
ENDIF ; TOUCH
end