[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: DOS 3.3 Nibble Encoding
In article <2cirpf$obq@altitude.HIP.CAM.ORG> vandry@CAM.ORG (Phillip Vandry) writes:
>
> I've always been amazed that it is possible to read a file into memory
> from a program less than 512 bytes long. There's a lot to do! You need to
> read block 2 (which is a nontrivial task -- you can't just make a ReadBlock
> call, you need to implement one!). You may need to read more directory
> blocks. Then you need to handle the sapling storage type. You also have
> to convert tracks/sectors to blocks!!
>
> How can this possibily be done in 512 bytes? Is there some secret to it?
Yes. The ProDOS boot code for a 5.25" disk takes a copy of the boot
ROM and patches it. This takes care of reading sectors, and the code
in block 0 includes track stepping support.
It always reads the entire directory into memory, and searches through
it for the PRODOS file, then loads it. The ProDOS file is assumed to
be storage type 2 (sapling) - I discovered this the hard way when I
wrote a dummy PRODOS file which says "this disk isn't bootable" and
explains how to access the files on it. It didn't work unless it was
at least 513 bytes long. :-)
The same ProDOS boot code is used for booting from a 5.25" disk and
from other disks. There is a test early in the code which works out
whether it booted from a 5.25" drive or something else.
In the case of a 5.25" drive, it then goes to the code which reads
sector 2 at location $0900 (by changing some zero-page locations and
jumping into the middle of the Disk ][ boot code, at a standard entry
point). Execution returns to $0801 (sector 0), which checks if sector
2 was just loaded, and goes to the rest of the 5.25" code.
In the case of a non-5.25" drive, the ProDOS block driver in the ROM
is used for disk reads (pointed to by location $CxFF). For 5.25"
drives, a driver is synthesized so that the same code can be used to
read the directory and ProDOS file for all types of drives.
--
David Empson
dempson@swell.actrix.gen.nz
Snail mail: P.O. Box 27-103, Wellington, New Zealand