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
/
BEEHIVE
/
UTILITYS
/
SYSGENSC.ARC
/
SYSGEN.Z80
< prev
Wrap
Text File
|
1990-07-21
|
3KB
|
174 lines
abs
;-----------------------------------------------------------------------------
;
; Program : Sysgen
; Machine : Apple 2 with PCPI Applicard CP/M adapter
; Synopsis : A program which reads in CP/M image from a specified file, and
; writes this image onto the boot tracks
; Assembler : ZASM
; Author : Stephen Ma
; Date : Sometime in July
;
;-----------------------------------------------------------------------------
;
; Bdos stuff etc.
;
boot equ 0
bdos equ 5
conin equ 1
conout equ 2
openfil equ 15
closefil equ 16
rdsec equ 20
wrtsec equ 21
setrdma equ 26
cr equ 0dh
lf equ 0ah
deffcb equ 5ch
arglen equ 80h
bios equ 0f300h
settrk equ bios+1eh
setsec equ bios+21h
setdma equ bios+24h
readsec equ bios+27h
writesec equ bios+2ah
lasttrk equ 3
lastsec equ 20h
;
; Begin........
;
org 100h
call ilprnt
db 'Sysgen for Apple 2 & Starcard',cr,lf,lf,lf,0
ld a,(arglen)
or a
jr nz,getbin
;
; give help msg
;
call ilprnt
db 'Usage: SYSGEN cpm_image_file_name',cr,lf,0
jp boot
;
; read in binary file
;
getbin: ld de,deffcb
ld c,openfil
call bdos
cp 0ffh
jr nz,filok
call ilprnt
db 'CP/M image file not found',cr,lf,0
jp boot
;
; Read in image
;
filok: ld h,(databeg/256)+1
ld l,0
rdlp: push hl
ex de,hl
ld c,setrdma
call bdos
ld de,deffcb
ld c,rdsec
call bdos
pop hl
or a
jr nz,finrd
ld de,80h
add hl,de
jr rdlp
;
; File read in OK - close itt
;
finrd: ld de,deffcb
ld c,closefil
call bdos
pop hl
ld (endaddr),hl
;
; Write image to disk
;
ld h,0 ; start on track 0,sector 0
ld l,0 ; (begin at the beginning.....)
ld d,(databeg/256)+1
ld e,0
ritelp: push hl
push de
call putsec
pop hl
ld de,80h
add hl,de
ld de,(endaddr)
ld a,h
cp d
jp nz,notlst
ld a,l
cp e
jp z,fini
notlst: ex de,hl
pop hl
inc l
ld a,l
cp lastsec
jr nz,ritelp
ld l,0
inc h
ld a,h
cp lasttrk
jr nz,ritelp
;
; Finished.......
;
fini: call ilprnt
db 'Done.',cr,lf,0
jp boot
;
; Subroutines
;
; In line print routine
;
ilprnt: pop hl
ld a,(hl)
inc hl
push hl
or a
ret z
ld c,conout
ld e,a
call bdos
jr ilprnt
;
; Write sector
;
putsec: push hl
push de
ld c,h
call settrk
pop bc
call setdma
pop bc
call xlater
call setsec
call writesec
ret
;
; Translate sector no.
;
xlater: ld hl,xlate
ld b,0
add hl,bc
ld c,(hl)
ret
;
; sector retranslate table - for tracks 0,1,2
;
xlate: db 00h,01h,0ch,0dh,18h,19h,04h,05h
db 10h,11h,1ch,1dh,08h,09h,14h,15h
db 16h,17h,02h,03h,0eh,0fh,1ah,1bh
db 06h,07h,12h,13h,1eh,1fh,0ah,0bh
endaddr ds 2
databeg equ $
end