[comp.sys.atari.st] Forcing a media change

dhollis@shiloh.UUCP (Dan Hollis @ 7819367) (07/08/90)

This message is primarily directed at Allan Pratt, and the TOS folks at
Atari corp. (but I would love a response from ANYONE!)..

Is there some way to 'fake out' TOS, and force a media change via software?
If so, is there a 'legal' way to do it?  If not a 'legal' way, then how do
you do it anyways?  Any responses would be appreciated...

csbrod@medusa.informatik.uni-erlangen.de (Claus Brod ) (07/09/90)

dhollis@shiloh.UUCP (Dan Hollis @ 7819367) writes:

>Is there some way to 'fake out' TOS, and force a media change via software?
>If so, is there a 'legal' way to do it?  If not a 'legal' way, then how do
>you do it anyways?  Any responses would be appreciated...

Simple. Link into the hdv vectors. Let them point to routines that return
2 (hdv_mediach), -14 (hdv_rw), or deinstall themselves (hdv_bpb), i.e.
something like this:

my_rw:
	move.w $e(a7),d0	; drive to read/write
	cmp.w  ourdrive(pc),d0	; drive to fake media change on?
	bne.s  rw2		; no, goon
	moveq  #-14,d0		; Media changed
	rts
rw2:
	move.l old_rw(pc),a0	; get old rw vector
	jmp    (a0)		; jump to the old routine

my_med:
	move.w 4(a7),d0		; drive to check media status
	cmp.w  ourdrive(pc),d0	; drive to fake media change on?
	bne.s  med2
	moveq  #2,d0		; media changed
	rts
med2:
	move.l old_media(pc),a0	; get old mediach vector
	jmp    (a0)

my_bpb:
	move.w 4(a7),d0		; drive to get BPB from
	cmp.w  ourdrive(pc),d0	; you know which drive-...
	bne.s  bpb2
	move.l old_rw(pc),hdv_rw	; restore vectors
	move.l old_media(pc),hdv_med
	move.l old_bpb(pc),hdv_bpb
	move.l old_bpb(pc),a0
	jmp    (a0)

After you've done that, do some dummy GEMDOS call like Fopen("X:\\YYYY")
where X is the drive where the media changed shall be faked on and YYYY
is a file name that may or may not exist. In this moment, GEMDOS calls
the BIOS routines: Mediach() and Rwabs() return 'changed', so GEMDOS
calls Getbpb() to reinitialize drive data. It also forgets all about
the drive, including folder info and things like this.

Remember to use XBRA when linking into the BIOS vectors (I omitted that
for reasons of brevity). The code above is not guaranteed to work -
it's 2 a.m. and I badly need to sleep.

By the way: You'll find a detailled description on how to this in
the TOS 1.4 release notes.

----------------------------------------------------------------------
Claus Brod, Am Felsenkeller 2,			Things. Take. Time.
D-8772 Marktheidenfeld, West Germany		(Piet Hein)
csbrod@medusa.informatik.uni-erlangen.de
----------------------------------------------------------------------

jhenders@van-bc.wimsey.bc.ca (John Henders) (07/09/90)

  Re: Forcing media change.
 There is a pd autoboot program around called FMC,I believe,which will force a 
media change on your floppy drives. If you need to do this in your own program,
I did it once by stealing the vector at $47e,then using this little routine to
replace it.
my_mc:
        move.w  4(a7),d0	        * drive?        
        move.l  sys_vec,a0
        cmp.w   #$c,d0  	        		* you talking to me?
        bne     .sk1 		           * no get lost
        cmp.w   #0,dc_flg1      * copied a disk lately?
        beq     .sk2            * no then use rd vec
        move.l  #ret_err,a0     * otherwise tell tos to look again
.sk1    jmp     (a0)
.sk2    move.l  sav_vec,a0
        jmp     (a0)    
ret_err:
  	      moveq.w #2,d0           * disk has definately been changed      
        move.w  #0,dc_flg1      * only need to check once
        rts
 Note that this was written to support loading a ramdisk (M) with a floppy
as a sort of an un-Turtle program. The system would not look at a ramdisk
for a media change as I loaded the ramdisk by using the ramdisk memory as a 
track buffer.

 

ljdickey@water.waterloo.edu (L.J.Dickey) (07/10/90)

In article <204@shiloh.UUCP> dhollis@shiloh.UUCP (Dan Hollis @ 7819367) writes:


>Is there some way to 'fake out' TOS, and force a media change via software?
>If so, is there a 'legal' way to do it?  If not a 'legal' way, then how do
>you do it anyways?  Any responses would be appreciated...

While browsing through some programs in the directory "diskutils"
at "terminator", I came across a program called "fmc"
(for Force Media Change).   I have not tried it, but this might be
just what you want.

I don't know how many or which versions of the OS this works for.