•  Back 
  •  BIOS 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  %About 
  •  Show info about hypertext 
  •  View a new file 
Topic       : The ATARI Compendium
Author      : Scott Sanders / JAY Software
Version     : 1.25 (20/6/2003)
Subject     : Documentation
Nodes       : 1117
Index Size  : 32614
HCP-Version : 6
Compiled on : Atari
@charset    : UTF-8
@lang       : en
@default    : 
@help       : %About
@options    : +g -i -t4 +y +z
@width      : 100
View Ref-File
                                Media Change


The BIOS function Mediach() returns the current media-change status of
the drive specified. This state is used to determine if a disk has been
changed in removable media drives (floppies, removable hard drives, etc.

The Getbpb() incorrectly resets the media change state. Failure to
properly reset this state after calling Getbpb() can cause data loss. The
function _mediach(), shown below, forces the Mediach() function to return
a 'definitely changed' state and should always be called after calling
Getbpb() on removable media drives.

/*
 * _mediach(): force the media 'changed' state on a removable drive.
 *
 * Usage: errcode = _mediach( devno )   - returns 1 if an error occurs
 *
 * Inputs: devno - (0 = 'A:', 1 = 'B:', etc...)
 *
 */

            .globl  _mediach

_mediach:
            move.w  4(sp),d0
            move.w  d0,mydev
            add.b   #'A',d0
            move.b  d0,fspec        ; Set drive spec for search
loop:
            clr.l   -(sp)           ; Get supervisor mode, leave old SSP
            move.w  #$20,-(sp)      ; and "Super" function code on stack.
            trap    #1
            addq.l  #6,sp
            move.l  d0,-(sp)
            move.w  #$20,-(sp)

            move.l  $472,oldgetbpb
            move.l  $47e,oldmediach
            move.l  $476,oldrwabs

            move.l  #newgetbpb,$472
            move.l  #newmediach,$47e
            move.l  #newrwabs,$476

            ; Fopen a file on that drive
            move.w  #0,-(sp)
            move.l  #fspec,-(sp)
            move.w  #$3d,-(sp)
            trap    #1
            addq.l  #8,sp

            ; Fclose the handle
            tst.l   d0
            bmi.s   noclose

            move.w  d0,-(sp)
            move.w  #$3e,-(sp)
            trap    #1
            addq.l  #4,sp

noclose:
            moveq   #0,d7
            cmp.l   #newgetbpb,$472     ; still installed?
            bne.s   done

            move.l  oldgetbpb,$472      ; Error, restore vectors.
            move.l  oldmediach,$47e
            move.l  oldrwabs,$476

            trap    #1                  ; go back to user mode
            addq.l  #6,sp               ; restore sp

            moveq.l #1,d0               ; 1 = Error
            rts
done:
            trap    #1                  ; go back to user mode
            addq.l  #6,sp               ; from stack left above

            clr.l   d0                  ; No Error

            rts

/*
 * New Getbpb()...if it's the target device, uninstall vectors.
 * In any case, call normal Getbpb().
 */

newgetbpb:
            move.w  mydev,d0
            cmp.w   4(sp),d0
            bne.s   dooldg

            move.l  oldgetbpb,$472      ; Got target device so uninstall.
            move.l  oldmediach,$47e
            move.l  oldrwabs,$476
dooldg:     move.l  oldgetbpb,a0        ; Go to real Getbpb()
            jmp     (a0)

/*
 * New Mediach()...if it's the target device, return 2. Else call old.
 */

newmediach:
            move.w  mydev,d0
            cmp.w   4(sp),d0
            bne.s   dooldm
            moveq.l #2,d0               ; Target device, return 2

            rts

dooldm:
            move.l  oldmediach,a0       ; Call old
            jmp     (a0)

/*
 * New Rwabs()...if it's the target device, return E_CHG (-14)
 */

newrwabs:
            move.w  mydev,d0
            cmp.w   4(sp),d0
            bne.s   dooldr
            moveq.l #-14,d0
            rts

dooldr:
            move.l  oldrwabs,a0
            jmp     (a0)

            .data

fspec:      dc.b        "X:\\X",0
mydev:      ds.w        1
oldgetbpb:  ds.l        1
oldmediach: ds.l        1
oldrwabs:   ds.l        1

            .end