ranger@ecsvax.UUCP (Rick N. Fincher) (05/07/87)
Apple II ProD TN #5: Block Device Preparation Routine Written: 1/85 Modified by: Pete McDonald 10/85 This technical note describes the FORMATTER routine that is available through Apple's licensing department. The routine is supplied as a text file of assembly source. It can be assembled with the ProDOS version of EdASM, Apple's editor/assembler. This routine is a superset of the former FORMATTER and BUILDDISK routines that were previously available through software licensing. This routine will format and and write out the necessary blocks to support the ProDOS directory structure on any ProDOS block device. Additionally it can be called to provide size and type information on any given ProDOS device number. General Information There are two entry points to FORMATTER; ENTRY 1: (ORG + $10), will do all that is necessary to prepare the device you specify for use with ProDOS. It will format the device if the device supports formatting (including DISK II's). It will then proceed to write the boot blocks, virgin directory, and bitmap, for any ProDOS device. ENTRY 2: (ORG + $13), will return the number of blocks on the specified device. It will also return whether the device is a DISK II, the ProDOS /RAM volume, or "other" type. Note : Entry 2, does not do any writing to the device. It ONLY returns size and type information. FORMATTER follows the guidelines in ProDOS Technical Note #16 to identify ProDOS disk devices. Disk II's, are recognized by their signature bytes in $CN00. The ProDOS /RAM disk is recognized by a driver address of $FF00. ROM based devices are recognized by having their driver address in $CN00. Anything else is considered a RAM based driver. Instructions for Use ENTRY 1: Upon entry at ENTRY 1 (ORG + $10), the accumulator must contain the DEVNUM. DEVNUM in this case, is defined as containing zeros in the low nibble, and the slot number in bits 4,5,6 and the hi-bit set to zero for drive 1 or set to one for drive 2. Further X and Y must have the address of a 512 byte buffer (X-lo, Y-hi), and DUMMYNAM and DUMSIZE must be filled in with the desired volume name and name length if a name other than DEFAULT.NAME is desired. NOTE: The volume name MUST be entered in UPPER case ASCII codes, with the HI-BIT CLEAR. IF ALL OF THE LETTERS IN THE VOLUME NAME ARE NOT IN UPPERCASE, THEN ProDOS WILL NOT RECOGNIZE IT. ProDOS itself always upshifts the letters in the volume name before comparisons are done. ENTRY 2: Upon entry at ENTRY 2 (ORG + $13), the accumulator must contain the DEVNUM; DEVNUM in this case, is defined as containing zeros in the low nibble, the slot number in bits 4,5,6, and the hi-bit set to zero for drive 1 or set to one for drive 2. Further X and Y must have the address of a 512 byte buffer (X-lo, Y-hi). Exit Conditions ENTRY 1: ENTRY 1 (ORG + $10) leaves zero-page intact, except for the bytes from $42 thru $47 which are defined for use when making requests to device drivers and could be altered. If the process is successfull, the A-reg, will contain 0, and the carry flag will be clear. ENTRY 2: ENTRY 2 (ORG + $13), will leave zero page intact, except for locations $42-$47, which are defined for use when making calls to device drivers, and could be altered. If the process is successful, the carry flag will be clear, and the X-register will contain the the low byte of the number of blocks on the device, the Y register will contain the high byte of the number of blocks on the device, and the A register will contain; - 0 if the unit is a DISK II. - 1 if the unit is the ProDOS /RAM volume. - 2 if the unit is of some other type. In the cases of both ENTRY 1, and ENTRY 2: If an error is detected, the X, and Y registers are undefined. The carry flag will be set, and the standard ProDOS error codes that may be returned in the A-Reg are: $27 - I/O Error, $28 - No device connected, $2B - Write Protected, $33 - Drive too Slow, $34 - Drive too Fast. Memory Usage. FORMATTER is $C3A bytes Long, and may be assembled to run in any location in main memory, between $800, and $B2C4.