Class DOSDisk
In: lib/DOSDisk.rb
Parent: DSK
DOSDisk DSK dot/f_5.png
 Disk image with a standard Apple DOS 3.3 VTOC at track $11, sector $00

VTOC : Volume Table of Contents (from Beneath Apple DOS pp 4-2 & 4-3)

 00    not used
 01    track number of first catalog sector
 02    sector number of first catalog sector
 03    release number of DOS used to INIT this disk
 04-05 not used
 06    Diskette volume number (1-254)
 07-26 not used
 27    maximum number of track/sector pairs which will fit in one file track/sector
       list sector (122 for 256 byte sectors)
 28-2F not used
 30    last track where sectors were allocated
 31    direction of track allocation (+1 or -1)
 32-33 not used
 34    number of tracks per diskette (normally 35)
 35    number of sectors per track (13 or 16)
 36-37 number of bytes per sector (LO/HI format)
 38-3B bit map of free sectors in track 0
 3C-3F bit map of free sectors in track 1
 40-43 bit map of free sectors in track 2
       ...
 BC-BF bit map of free sectors in track 33
 CO-C3 bit map of free sectors in track 34
 C4-FF bit maps for additional tracks if there are more than 35 tracks per diskette

CATALOG (from Beneath Apple DOS p 4-6)

 00    Not Used
 01    track number of next catalog sector
 02    sector number of next catalog sector
 03-0A not used
 0B-2D First file descriptive entry
 2E-50 Second file descriptive entry
 51-73 Third file descriptive entry
 74-96 Fourth file descriptive entry
 97-B9 Fifth file descriptive entry
 BA-DC Sixth file descriptive entry
 DD-FF Seventh file descriptive entry

FILE DESCRIPTIVE ENTRY (from Beneath Apple DOS p 4-6)

 00    Track of first track/sector list sector, if this is a deleted file this contains FF
       and the original track number is copied to the last byte of the file name (BYTE 20)
       If this byte contains a 00, the entry is assumed to never have been used and is
       available for use. (This means track 0 can never be used for data even if the DOS image
       is 'wiped' from the disk)

 01    Sector of first track/sector list sector
 02    File type and flags:
       80+file type - file is locked
       00+file type - file is not locked

       00 - TEXT file
       01 - INTEGER BASIC file
       02 - APPLESOFT BASIC file
       04 - BINARY file
       08 - S type file
       10 - RELOCATABLE object module file
       20 - a type file
       40 - b type file

 03-20 File Name (30 characters)
 21-22 Length of file in sectors (LO/HI format)

TRACK/SECTOR LIST FORMAT (from Beneath Apple DOS p 4-6)

 00    Not used
 01    Track number of next T/S list of one is needed or zero if no more t/s list
 02    Sector number of next T/S list (if one is present)
 03-04 Not used
 05-06 Sector offset in file of the first sector described by this list
 07-oB Not used
 0C-0D Track and sector of first data sector or zeros
 0E-0F Track and sector of second data sector or zeros
 10-FF Up to 120 more track and sector pairs

Methods

Attributes

vtoc_sector_no  [RW] 
vtoc_track_no  [RW] 

Public Class methods

Public Instance methods

iterate through the CATALOG to find either the named file or (if nil is passed in) an empty slot

iterate through the sector usage bitmap, return a list of [track,sector] for sectors marked available

given a track and sector, treat it as a track/sector list and return an array containing track/sector pairs

default file type is TextFile Tokenisation not currently implemented

reads the VTOC, and populate the "files" array with files

[Validate]