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
/
GETBIN.Z80
< prev
next >
Wrap
Text File
|
1990-07-21
|
3KB
|
182 lines
abs
;----------------------------------------------------------------------------
;
; Program : Getbin
; Machine : Apple 2 with PCPI Applicard CP/M adapter
; Synopsis : Reads in CP/M system image from boot tracks, and writes the
; image into a specified file
; Assembler : ZASM
; Author : Stephen Ma
; Date : Sometime in July (or was it August, or September......)
;
;---------------------------------------------------------------------------
;
; Bdos stuff etc.
;
boot equ 0
bdos equ 5
conin equ 1
conout equ 2
opnfil equ 15
clsfil equ 16
delfil equ 19
rdsec equ 20
wrtsec equ 21
makfil equ 22
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
;
; Program entry:
;
org 100h
call ilprnt
db 'Getbin for Apple 2 & Starcard',cr,lf,lf,lf,0
ld a,(arglen)
or a
jr nz,filok
;
; give help msg
;
call ilprnt
db 'Usage: GETBIN cpm_image_file_name',cr,lf,0
jp boot
;
; Read in system image from tracks 0, 1 & 2
;
filok: ld hl,0 ; start on track 0,sector 0
ld d,(databeg/256)+1
ld e,0
readlp: push hl
push de
call getsect
pop hl
ld de,80h
add hl,de
ex de,hl
pop hl
inc l
ld a,l
cp 20h
jr nz,readlp
ld l,0
inc h
ld a,h
cp 3
jr nz,readlp
ex de,hl
ld (lastaddr),hl
;
; write out binary file
;
ld de,deffcb
ld c,delfil
call bdos
ld de,deffcb
ld c,makfil
call bdos
cp 0ffh
jr nz,opened
;
; Error.....
;
call ilprnt
db 'Error creating image file',cr,lf,0
jp boot
;
; Write image to file
;
opened: ld h,(databeg/256)+1
ld l,0
wrtlp: push hl
ex de,hl
ld c,setrdma
call bdos
ld de,deffcb
ld c,wrtsec
call bdos
pop hl
or a
jr nz,error
ld de,80h
add hl,de
ld de,(lastaddr)
ld a,h
cp d
jr nz,wrtlp
ld a,l
cp e
jr nz,wrtlp
;
; Done, close file and exit
;
exit: ld de,deffcb
ld c,clsfil
call bdos
call ilprnt
db 'Done.',cr,lf,0
jp boot
;
; Arrgh.... Error.....
;
error: call ilprnt
db 'Error writing file',cr,lf,0
jr exit
;
; Subroutines
;
; Inline 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
;
; Read in secotr
;
getsect: push hl
push de
ld c,h
call settrk
pop bc
call setdma
pop bc
call xlater
call setsec
call readsec
ret
;
; Translate sector number
;
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
lastaddr ds 2
databeg equ $
end