home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Oakland CPM Archive
/
oakcpm.iso
/
cpm
/
packet
/
rli120.ark
/
MAKESYS.MAC
< prev
next >
Wrap
Text File
|
1986-08-12
|
5KB
|
347 lines
; MAKESYS.MAC - 3/9/86 - Create Xerox system disk.
.z80
maclib TNC.LIB
entry makesy
bdosdef
asciictl
true equ 0ffffh
false equ not true
maclib BIOSCPM.INC ; CP/M addresses
maclib BIOSDSKE.INC ; Disk equates
fcblen equ 33 ; Length of file control block
ldrec equ 3 ; Length of load record
dseg
wb: jp $-$
const: jp $-$
conin: jp $-$
conot: jp $-$
jp $-$
jp $-$
jp $-$
home: jp $-$
jp $-$
settrk: jp $-$
setsec: jp $-$
setadr: jp $-$
jp $-$
wrtsec: jp $-$
cseg
makesy: ld sp,stack
; Move the BIOS jumps down here.
ld hl,(1)
ld de,wb
ld bc,42
ldir
; Get current drive.
dodosv ckcur
ld (cdrvn),a
; Find out which drive to put the boot onto.
ld hl,5ch
ld a,(hl)
dec a
jp p,gotdrv
ld a,(cdrvn)
gotdrv: ld (bdrvn),a
add a,'A'
ld (bdrvnam),a
; Find out if it has boot tracks.
dodosv seldsk,bdrvn
dodosv getdpb
push hl
dodosv seldsk,cdrvn
pop hl
ld a,l
or h
jr z,bserr
ld de,13
add hl,de
ld e,(hl)
inc hl
ld d,(hl)
ld (restrk),de
ld a,d
or e
jr z,nterr
; Put the boot tracks on the disk.
call putb
jr nz,exit
done: dodosa bufout,dnmsg
jr exit
bserr: dodosa bufout,bsmsg
jr exit
nterr: dodosa bufout,ntmsg
jr exit
exit: jp 0
; Put boot tracks on disk
putb: dodosa bufout,pbmsg
ld hl,cfiles
ld (rfile),hl
ld hl,wloc
ld (wfile),hl
putba: ld hl,(wfile)
ld a,(hl)
or a
ret z
inc hl
ld a,(hl)
ld (track),a
inc hl
ld a,(hl)
ld (sector),a
; Go get the file into memory.
ld hl,(rfile) ; Point to fcb
call rdfile
ret nz
ld a,(nrec)
ld hl,(wfile)
ld (hl),a
call wrmem ; Write it to disk.
ret nz
ld hl,(wfile)
ld a,(hl)
ld de,ldrec
add hl,de
ld (wfile),hl
ld hl,secmsg+1
call prhex
dodosa bufout,secmsg
ld hl,(rfile)
ld de,fcblen
add hl,de
ld (rfile),hl
jr putba
; Have the file read into memory, now write it to the disk.
wrmem: dodosv seldsk,bdrvn
ld a,(track)
ld (wtrk),a
ld a,(sector)
ld (wsec),a
ld hl,($memry)
ld (dmaadr),hl
ld a,(nrec)
inc a
or a ; Clear carry
rra
ld (wtrec),a
call wrmemd
jr nz,wrmemc
ld a,(track)
ld b,a
ld a,(sector)
inc a
cp spt+1
jr c,wrmema
inc b
ld a,1
wrmema: ld (wsec),a
ld a,b
ld (wtrk),a
ld hl,($memry)
ld de,128
add hl,de
ld (dmaadr),hl
ld a,(nrec)
or a ; Clear carry
rra
or a ; Set flags
jr z,wrmemb ; Was only one
ld (wtrec),a
call wrmemd
jr nz,wrmemc
wrmemb: dodosv seldsk,cdrvn
retz
wrmemc: dodosv seldsk,cdrvn
dodosa bufout,wtmsg
retnz
wrmemd: ld a,(wtrk)
ld c,a
ld a,(restrk)
cp c
jr nz,wrmeme
dodosa bufout,tbmsg
retnz
wrmeme: call settrk
ld a,(wsec)
ld c,a
call setsec
ld bc,(dmaadr)
call setadr
call wrtsec
ret nz
ld hl,wtrec
dec (hl)
ret z
ld hl,(dmaadr)
ld bc,256
add hl,bc
ld (dmaadr),hl
ld a,(wsec)
inc a
inc a
ld (wsec),a
sub spt+1
jr c,wrmemd
inc a
ld (wsec),a
ld hl,wtrk
inc (hl)
jr wrmemd
dseg
wtrk: ds 1
wsec: ds 1
wtrec: ds 1
cseg
; Read a file in.
rdfile: call openf
ret nz
xor a
ld (nrec),a
ld hl,($memry)
ld (bufptr),hl
rdfla: ld de,(bufptr)
dodosa setdma
ld de,(rfile)
dodosa read
or a
jr z,rdflb
retz
rdflb: ld hl,(bufptr)
ld de,128
add hl,de
ld (bufptr),hl
ld hl,nrec
inc (hl)
jr rdfla
; Open a file.
openf: ld hl,(rfile)
call prfile
ex de,hl
dodosa open
inc a
jr z,openfa
retz
openfa: dodosa bufout,nfmsg
retnz
; Print file name.
prfile: push hl
push de
push bc
push af
ld a,(cdrvn)
add a,'A'
ld hl,drvmsg+2
ld (hl),a
dodosa bufout,drvmsg
ld hl,(rfile)
ld de,12
add hl,de
ld a,(hl)
push af ; Save whatever was after file name.
push hl
ld (hl),'$'
ld de,(rfile)
inc hl
dodosa bufout
pop hl
pop af ; Restore whatever was after file name.
ld (hl),a
pop af
pop bc
pop de
pop hl
ret
; Translate (A) to hex and store at (HL).
prhex: push af
rrca
rrca
rrca
rrca
call prhexa
pop af
prhexa: and 0fh
add a,90h
daa
adc a,40h
daa
ld (hl),a
inc hl
ret
; Files that make up the Xerox CP/M boot tracks.
dseg
cfiles: db 0,'XCPM COM'
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,'SBIOS COM'
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,'BOOT COM'
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
; Where they go on the Xerox boot tracks.
wloc: db 1,cpmtrk,cpmsec
db 1,biostrk,biossec
db 1,boottrk,bootsec
db 0,0,0
dnmsg: db cr,lf,lf,'New system now on '
bdrvnam: db ' $' ; Must follow dnmsg.
nfmsg: db ' not found.$'
secmsg: db ' H Sectors written.$'
tbmsg: db cr,lf,'Bootstrap would not fit on reserved tracks.$'
wtmsg: db ' Error writing.$'
ntmsg: db cr,lf,'Target drive has no reserved bootstrap tracks.$'
drvmsg: db cr,lf,' :$'
pbmsg: db cr,lf,'Writing to the bootstrap tracks...',cr,lf,'$'
bsmsg: db cr,lf,'Cannot select target drive.$'
bdrvn: ds 1
cdrvn: ds 1
restrk: ds 2 ; # reserved tracks on target drive.
nrec: ds 1
track: ds 1
sector: ds 1
dmaadr: ds 2
rfile: ds 2 ; Pointer to files to read - for rdfile
wfile: ds 2 ; Pointer to file to write on copys
hexcnt: ds 1
bufptr: ds 2
$memry: ds 2
ds 128
stack equ $
end