home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug097.arc
/
CD.MAC
< prev
next >
Wrap
Text File
|
1979-12-31
|
6KB
|
459 lines
;
;
; CHDISK : Disk type select program for 512k O/S
;
;
bdos equ 5
cr equ 13
lf equ 10
tab equ 9
bell equ 7
rst_00h equ 0C7h
command_line equ 80h
bios_start equ 0E700h
id equ 218h
id_val equ 0AA55h
xltc equ 54
xltd equ 64
num_drives equ 12Bh
dpbase equ 44h
dpb_ptr equ 0Ah
spare_dpb equ 0CFh
dpb_base equ 087h
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,command_line
ld a,(hl)
or a
jp z,show_use
ld b,a
parse_disk:
inc hl
ld a,(hl)
cp '?'
jp z,display_types
cp 'L'
jr z,got_disk
cp 'A'
jr c,pd_1
cp 'D'+1
jr c,got_disk
pd_1:
cp ' '
jp nz,show_use
djnz parse_disk
jp show_use
got_disk:
ld e,a
ld a,(bios_start+num_drives)
ld d,a
ld a,e
ld (disk),a
cp 'L'
jr z,gd_1
sub 'A'
cp d
jr c,gd_2
gd_3:
ld de,no_drive_mesg
jp prt_ret
gd_1:
ld a,d
cp 4
jr z,gd_3
ld a,'D'-'A'
gd_2:
ld (disk_num),a
dec b
jp z,show_use
dec b
jp z,show_use
inc hl
skip_space:
inc hl
ld a,(hl)
cp ' '
jr nz,check_type
djnz skip_space
jp show_use
check_type:
ld ix,fmt_table
ld c,b
ld a,num_types
ct_1:
push hl
push af
ld e,(ix)
ld d,(ix+1)
ct_2:
ld a,(de)
cp 'a'-1
jr c,ct_3
res 5,a
ct_3:
cp (hl)
jr nz,ct_no_match
inc hl
inc de
djnz ct_2
; matches
pop af
pop hl
jr got_match
ct_no_match:
ld b,c
pop af
pop hl
ld de,5
add ix,de
dec a
jr nz,ct_1
jp show_use
got_match:
ld a,(disk_num)
ld l,a
ld h,0
add hl,hl
add hl,hl
add hl,hl
add hl,hl ; disk num * 16
add a,a ; disk num * 2
add a,l ; disk num * 18
ld c,a
ld b,h ; h=0
ld de,bios_start+dpbase+dpb_ptr
add hl,de ; --> dpb ptr in appropriate dph
ex de,hl
ld hl,bios_start+dpb_base ; --> appropriate dpb
add hl,bc
ex de,hl ; hl --> dpb ptr, de --> dpb
ld (hl),e
inc hl
ld (hl),d
dec de
dec de
dec de
ld l,(ix+3)
ld h,(ix+4) ; hl --> new dpb
ld c,18 ; b=0
ldir
ld a,rst_00h
ld (ret_inst),a
display_types:
ld ix,fmt_table
ld b,num_types
ld d,0
dt_1:
ld l,(ix)
ld h,(ix+1)
ld e,(ix+2)
add hl,de
ld (hl),'$'
ld e,5
add ix,de
djnz dt_1
ld iy,bios_start+dpbase
ld a,0
dt_2:
push af
add a,'A'
ld (drive_name),a
ld de,drive_mesg
ld c,9
call bdos
ld l,(iy+dpb_ptr)
ld h,(iy+dpb_ptr+1)
ld a,l
cp low (bios_start+spare_dpb)
jr nz,dt_3
dt_7:
; Disk set up by SETDISK etc.
ld de,custom_mesg
ld c,9
call bdos
jr dt_4
dt_3:
; Try to find matching format
ld ix,fmt_table
ld b,num_types
dec hl
dec hl
dec hl
dt_5:
ld e,(ix+3)
ld d,(ix+4)
push hl
push bc
ld b,18
dt_6:
ld a,(de)
cp (hl)
jr nz,dt_no_match
inc hl
inc de
djnz dt_6
; everything matched so found type
pop bc
pop hl
jr dt_match
dt_no_match:
pop bc
pop hl
ld de,5
add ix,de
djnz dt_5
; Nothing matched so print custom message
jr dt_7
dt_match:
; Have found matching type so print it's name
ld e,(ix)
ld d,(ix+1)
ld c,9
call bdos
dt_4:
ld de,16
add iy,de
pop af
inc a
ld hl,bios_start+num_drives
cp (hl)
jr c,dt_2
cp 4
jr nc,dt_8
ld a,'L'-'A'
ld iy,bios_start+dpbase+(16*3)
jr dt_2
dt_8:
ld de,lf_mesg
jr prt_ret
show_use:
ld de,use_mesg
jr prt_ret
get_lost:
ld de,wb_mesg
prt_ret:
ld c,9
call bdos
ret_inst:
ret
fmt_table:
; ss80
dw f1n
db f1l
dw f1d
; ds80
dw f2n
db f2l
dw f2d
; ds40
dw f3n
db f3l
dw f3d
; ds82
dw f4n
db f4l
dw f4d
; ds84
dw f5n
db f5l
dw f5d
; ds8b
dw f6n
db f6l
dw f6d
num_types equ ($-fmt_table) / 5
; Format data
; ss80
f1d equ $
db xltd
db 2
db 3
;
dw 40
db 4
db 15
db 1
dw 194
dw 127
db 192,0
dw 32
dw 2
; ds80
f2d equ $
db xltc
db 5
db 3
;
dw 40
db 5
db 31
db 3
dw 0C2h
dw 127
db 80h,0
dw 32
dw 4
; ds40
f3d equ $
db xltd
db 1
db 3
;
dw 40
db 4
db 15
db 1
dw 194
dw 127
db 192,0
dw 32
dw 2
; ds82
f4d equ $
db xltd
db 1
db 3
;
dw 40
db 4
db 15
db 0
dw 391
dw 255
db 0F0h,0
dw 64
dw 2
; ds84
f5d equ $
db xltd
db 1
db 3
;
dw 40
db 5
db 31
db 3
dw 196
dw 127
db 128,0
dw 32
dw 2
; ds8b
f6d equ $
db xltd
db 1
db 3
;
dw 40
db 4
db 15
db 0
dw 389
dw 127
db 0C0h,0
dw 32
dw 4
start_mesg:
db cr,lf,'Microbee 512k Enhanced Operating System v2.2,'
db ' (c) 1987 Peter Broughton.',cr,lf
db 'CD : Disk type selection.',cr,lf,lf,'$'
wb_mesg:
db bell,'Wrong operating system !!',cr,lf,lf,'$'
use_mesg:
db 'Use : CD d: type',cr,lf
db tab,'d: - drive to change, A: B: C: D: or L:,',cr,lf
db tab,'type - new disk type for that drive, one of :',cr,lf
db tab,tab
f1n equ $
db 'ss80 : 3.5" single sided, 80 track, 386k.',cr,lf
f1l equ $-f1n
db tab,tab
f2n equ $
db 'ds80 : 3.5" double sided, 80 track, 776k.',cr,lf
f2l equ $-f2n
db tab,tab
f3n equ $
db 'ds40 : 5.25" double sided, 40 track, 386k.',cr,lf
f3l equ $-f3n
db tab,tab
f4n equ $
db 'ds82 : Dreamdisk, double sided, 80 track, 782k.',cr,lf
f4l equ $-f4n
db tab,tab
f5n equ $
db 'ds84 : PJB''s format, double sided, 80 track, 784k.',cr,lf
f5l equ $-f5n
db tab,tab
f6n equ $
db 'ds8b : Beeboard, double sided, 80 track, 776k.',cr,lf
f6l equ $-f6n
db tab,'Note that the change only remains in effect'
db ' until next RESET.',cr,lf
db 'Use : CD ?',cr,lf
db tab,'Displays current selection.',cr,lf
db lf,'$'
no_drive_mesg:
db 'Drive '
disk:
db 'A: not connected to system.',cr,lf,lf,'$'
drive_mesg:
db 'Drive '
drive_name:
db 'A: - $'
custom_mesg:
db '???? : Custom format.',cr
lf_mesg:
db lf,'$'
disk_num equ $
if ($ and 7Fh) ne 0
ds 80h-($ and 7Fh)
endif
end