[Coco] OS-9 Raw copying disks - Or how to fool your OS-9

Luis Antoniosi (CoCoDemus) retrocanada76 at gmail.com
Sun Sep 15 01:43:20 EDT 2013


Hi,

I managed to make my OS-9 to copy raw dragon 40 track disks (like the FLEX
boot disk, Dragon DOS disk, RSDOs disks or any other coco/dragon 256-sector
byte disk) from floppy to DW and vice-versa. But I had to fool the OS-9
otherwise it will close the disk path as soon it reads or writes an alien
LSN0.

So I came up with this idea:

When transferring a disk from floppy to DW I ask the user to put a valid
OS-9 formatted disk with the same geometry and I read both LSN0s while
KEEPING BOTH PATHS OPENED.

Then I ask the user to switch the disks and OS-9 now will happily read all
remaining sectors from 1 to the end of the alien disk. After that I close
the the path and reopen it and read the source LSN0 and write to the target
disk.

Note that the disk change is only required for the source disk and not for
the target. The target disk must be pre-formatted in OS-9 for the same
geometry. If the source is a /Xn drive you need to change the valid OS-9
image on the server. You can use the toolshed to create an empty one.

I  copied a floppy disk like FLEX and any other using OS-9, syntax:

from floppy 1 to dw x1:

RAWCOPY /D0@ /X1@

and to copy back:

RAWCOPY /X1@ /D0@

So I don't need an old PC with internal floppy to transfer disks and making
it on coco is more fun :)


The code, it works for level 1 and 2:


***

 nam Rawcopy
ttl Rawcopy utility

use defsfile
tylg set Prgrm+Objct
atrv set ReEnt+rev
rev set $03
edition set 1
 mod eom,name,tylg,atrv,start,size
 org 0

srcpath rmb 1
dstpath rmb 1

argc rmb 2 ; number of args
args rmb 256 ; 128 max args
readbuf rmb 256
 size equ .

stdin equ 0
stdout equ 1
stderr equ 2

name fcs /Rawcopy/
fcb edition

start lbsr _getargs

leax SourceMsg,pcr
 ldy #1024
lda #1
 os9 I$WritLn
 leax readbuf,u
 ldy #1
lda #1
 os9 I$Read

ldx args,u
 lda #READ.
os9 I$Open
 lbcs _error
sta <srcpath

ldx args+2,u
lda #UPDAT.
 os9 I$Open
lbcs _error
 sta <dstpath

lda <srcpath
 ldy #256
leax readbuf,u
 os9 I$Read
lbcs _error

lda <dstpath
leax readbuf,u
 os9 I$Read
lbcs _error
 leax SwitchMsg,pcr
ldy #1024
 lda #1
os9 I$WritLn
 leax readbuf,u
ldy #1
 lda #1
os9 I$Read
 _loop lda <srcpath
ldy #256
 leax readbuf,u
os9 I$Read
 bcs _end
 lda <dstpath
 leax readbuf,u
os9 I$Write
 bcs _end
 bra _loop
 _end
lda <srcpath
os9 I$Close
 lda <dstpath
os9 I$Close

ldx args,u
lda #READ.
 os9 I$Open
lbcs _error
 sta <srcpath

ldx args+2,u
 lda #UPDAT.
os9 I$Open
 lbcs _error
sta <dstpath

lda <srcpath
ldy #256
 leax readbuf,u
os9 I$Read
 bcs _close
 lda <dstpath
 leax readbuf,u
os9 I$Write
 _close lda <srcpath
os9 I$Close
 lda <dstpath
os9 I$Close
 ldd #0
os9 F$Exit

_error clra
os9 F$Exit


_getargs clr argc,u
clr argc+1,u
 leay args,u
_pre tstb ; check arg string
 beq _noargs
decb
 lda ,x+
cmpa #13 ; linefeed ?
 beq _endargs
cmpa #32 ; space delimiter ?
 beq _pre
leax -1,x
 stx ,y++
leax 1,x
 inc argc+1,u ; inc arg count
_arg tstb
 beq _endargs ; has ended ?
decb
 lda ,x+
cmpa #13 ; linefeed ?
 beq _endargs
cmpa #32 ; space delimiter ?
 bne _arg
_endline leax -1,x
 clr ,x+ ; set null termination
bra _pre
_endargs clr -1,x
_noargs rts


SourceMsg fcc "RAWCOPY                         "
fcc "                                "
 fcc "Copy raw disks from and to files"
fcc "                                "
 fcc "If source is a raw floppy as    "
fcc "/D0@ put a valid OS-9 disk with "
 fcc "the same disk geometry first and"
fcc "press any key..."
 fcc "                                "
fcb     C$CR,C$LF
 SwitchMsg   fcc     "Now insert the source disk and  "
fcc "press any key..."
 fcc "                                "
fcb     C$CR,C$LF
 emod
eom equ   *
end
  ***

-- 
Long live the CoCo



More information about the Coco mailing list