home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG097.ARC
/
FKEY.MAC
< prev
next >
Wrap
Text File
|
1979-12-31
|
6KB
|
422 lines
;
;
; FKEY : Function key load/save for 512k O/S
;
;
bdos equ 5
cr equ 13
lf equ 10
tab equ 9
bell equ 7
rst_00h equ 0C7h
move_stuff_dest equ 8000h
command_line equ 80h
fcb equ 5Ch
curr_r equ fcb+32
fcb_2 equ 6Ch
bios_start equ 0E700h
id equ 218h
id_val equ 0AA55h
swap_a_m equ 21Bh
cursor_key_tab equ 26Bh
num_fkeys equ 12
fkey_spot equ 8000h-(num_fkeys*128)
fkey_buffer equ 0A000h
sys_page equ 5
normal_map equ 4
map_port equ 50h
aseg
org 100h
ld de,start_mesg
ld c,9
call bdos
ld hl,(bios_start+id)
ld de,id_val
or a
sbc hl,de
jp nz,get_lost
ld hl,move_stuff_src
ld de,move_stuff_dest
ld bc,move_stuff_len
ldir
ld hl,command_line
ld a,(hl)
or a
jr z,save_def
ld b,a
parse:
inc hl
ld a,(hl)
cp 'S'
jr z,save
cp 'L'
jp z,load
cp ' '
jp nz,show_use
djnz parse
save_def:
ld hl,fcb_def+1
ld de,fcb+1
ld bc,16-1
ldir
ld a,(bios_start+swap_a_m)
and 'M'-'A'
add a,1
ld (fcb),a
jr save_1
save:
call check_file_name
jr z,save_def
call set_up_fcb
save_1:
ld de,save_drive
call print_f_name
ld de,save_mesg
ld c,9
call bdos
; ld a,rst_00h
; ld (ret_inst),a
call zero_fcb_stuff
; See if file is already there
ld de,fcb
ld c,15
call bdos
cp 0FFh
jr z,s_not_there
; Was so delete it
ld de,fcb
ld c,19
call bdos
s_not_there:
call zero_fcb_stuff
; Open new file
ld de,fcb
ld c,22
call bdos
cp 0FFh
jp z,prt_err
; Get function keys out of system page
call get_f_keys
; Set up file header
ld hl,header+6
ld b,128-6
s_1:
ld (hl),0
inc hl
djnz s_1
; Copy in cursor keys
ld hl,bios_start+cursor_key_tab
ld de,header+40h
ld bc,16
ldir
; Write header to file
ld de,header
ld c,26
call bdos
ld de,fcb
ld c,21
call bdos
or a
jp nz,prt_err
; Write buffer out to file, 1 record at a time
ld b,num_fkeys ; = number of records
ld de,fkey_buffer
save_loop:
push bc
push de
; Set buffer address
ld c,26
call bdos
; Write record
ld de,fcb
ld c,21
call bdos
pop de
pop bc
or a
jp nz,prt_err
ld hl,128
add hl,de
ex de,hl
djnz save_loop
; Close file
ld de,fcb
ld c,16
call bdos
cp 0FFh
jp z,prt_err
ret
load_def:
ld hl,fcb_def
ld de,fcb
ld bc,16
ldir
ld a,(bios_start+swap_a_m)
and 'M'-'A'
add a,1
ld (fcb),a
jr load_1
load:
call check_file_name
jr z,load_def
call set_up_fcb
load_1:
ld de,load_drive
call print_f_name
ld de,load_mesg
ld c,9
call bdos
; ld a,rst_00h
; ld (ret_inst),a
call zero_fcb_stuff
; See if file is there
ld de,fcb
ld c,15
call bdos
cp 0FFh
jr z,prt_err
; Read header from file
ld de,header
ld c,26
call bdos
ld de,fcb
ld c,20
call bdos
or a
jr nz,prt_err
; Read buffer from file, 1 record at a time
ld b,num_fkeys ; = number of records
ld de,fkey_buffer
load_loop:
push bc
push de
; Set buffer address
ld c,26
call bdos
; Read record
ld de,fcb
ld c,20
call bdos
pop de
pop bc
or a
jr nz,prt_err
ld hl,128
add hl,de
ex de,hl
djnz load_loop
; Copy function keys to system page
call put_f_keys
; Copy cursor keys to table
ld hl,header+40h
ld de,bios_start+cursor_key_tab
ld bc,16
ldir
; Close file
ld de,fcb
ld c,16
call bdos
cp 0FFh
jr z,prt_err
ret
err_qm:
pop hl ; return address
prt_err:
ld de,err_mesg
jr prt_ret
show_use:
ld de,use_mesg
prt_ret:
ld c,9
call bdos
ret_inst:
ret
get_lost:
ld de,wb_mesg
jr prt_ret
zero_fcb_stuff:
ld hl,fcb+16
ld b,20
zf_1:
ld (hl),0
inc hl
djnz zf_1
ret
set_up_fcb:
ld hl,fcb_2
ld de,fcb
ld bc,9
ldir
ld hl,fcb_def_tail
ld c,7
ldir
; Check for ?'s in fcb
ld hl,fcb
ld b,9
sf_1:
ld a,(hl)
cp '?'
jr z,err_qm
inc hl
djnz sf_1
ret
; Check if there seems to be a file name on command line (following S/L)
; Return : NZ if there is, Z if not
check_file_name:
dec b
ret z
; Skip past any non space characters
cf_2:
inc hl
ld a,(hl)
cp ' '
jr z,cf_3
djnz cf_2
xor a
ret
cf_3:
dec b
ret z
cf_1:
inc hl
ld a,(hl)
cp ' '
ret nz
djnz cf_1
xor a
ret
; Put file drive and name into print line
print_f_name:
ld hl,fcb
ld a,(hl)
or a
jr nz,pf_4
ld (de),a
inc de
ld (de),a
jr pf_5
pf_4:
add a,'A'-1
ld (de),a
inc de
pf_5:
inc de
inc hl
ld b,8
pf_1:
ld a,(hl)
cp ' '
jr z,pf_2
ld (de),a
inc hl
inc de
djnz pf_1
ret
pf_2:
ld a,0
pf_3:
ld (de),a
inc de
djnz pf_3
ret
move_stuff_src equ $
.phase move_stuff_dest
get_f_keys:
ld a,sys_page
out (map_port),a
ld hl,fkey_spot
ld de,fkey_buffer
ld bc,num_fkeys*128
ldir
ld a,normal_map
out (map_port),a
ret
put_f_keys:
ld a,sys_page
out (map_port),a
ld hl,fkey_buffer
ld de,fkey_spot
ld bc,num_fkeys*128
ldir
ld a,normal_map
out (map_port),a
ret
move_stuff_len equ $-move_stuff_dest
.dephase
start_mesg:
db cr,lf,'Microbee 512k Enhanced Operating System v2.2,'
db ' (c) 1987 Peter Broughton.',cr,lf
db 'FKEY : Save/load function and cursor keys.',cr,lf,lf,'$'
wb_mesg:
db bell,'Wrong operating system !!',cr,lf,lf,'$'
use_mesg:
db 'Use : FKEY',cr,lf
db tab,'- Save function keys to A:DEFAULT.FK',cr,lf
db 'Use : FKEY S/L [[d:]filename] (no extension)',cr,lf
db tab,'S - Save function keys to d:filename.FK,',cr,lf
db tab,'L - Load function keys from d:filename.FK,',cr,lf
db tab,'If no filename is supplied then A:DEFAULT.FK'
db ' is assumed.',cr,lf,lf,'$'
err_mesg:
db bell,'File error !!',cr,lf,lf,'$'
save_mesg:
db 'Saving function keys to '
save_drive:
db 'A:'
save_name:
db 'DEFAULT',0,'.FK',cr,lf,lf,'$'
load_mesg:
db 'Loading function keys from '
load_drive:
db 'A:'
load_name:
db 'DEFAULT',0,'.FK',cr,lf,lf,'$'
fcb_def:
db 1,'DEFAULT '
fcb_def_tail:
db 'FK ',0,0,0,0
; This MUST be the last thing in the file
header:
dw 8000h,8000h-(num_fkeys*128),num_fkeys*128
if ($ and 7Fh) ne 0
ds 80h-($ and 7Fh)
endif
end