Newsgroups: comp.sys.apple2.programmer Path: news.weeg.uiowa.edu!news.uiowa.edu!uunet!usc!elroy.jpl.nasa.gov!decwrl!waikato!comp.vuw.ac.nz!actrix.gen.nz!dempson From: dempson@actrix.gen.nz (David Empson) Subject: BLOAD info (was Re: Beneath Apple ProDOS --bugs) Message-ID: Organization: Actrix Information Exchange References: <2sd7mr$qtv@ausom.ausom.oz.au> <2shcr9$da9@nyx10.cs.du.edu> Date: Thu, 2 Jun 1994 11:22:37 GMT Lines: 126 In article <2shcr9$da9@nyx10.cs.du.edu>, Chris Deschu wrote: > > Hmm, while someone is looking at this particular book... > I'm writing a basic program which bloads arbitrary files > into memory at a constant location. I need to know the > length of the file after it has been BLOADed. I seem to > recall that the length is stored in two page zero bytes, > but I can't remember which one. Not on zero page, no. This information is available in the BASIC.SYSTEM global page, which starts at $BE00. There are several ProDOS Machine Language Interface parameters blocks used by BASIC.SYSTEM for all of its ProDOS calls. Included among these are the parameter blocks for the GET_EOF and READ calls, either of which will contain the file length after you've done a BLOAD (unless you used the L or E paramter to limit the number of bytes loaded, in which case the READ parameter block will reflect the number of bytes you loaded). The GET_FILE_INFO parameter block may also be useful. The following information came from the ProDOS-8 Technical Reference. The GET_EOF parameter block is at $BEC6 (several unrelated calls use the same parameter block), and the end of file value is at $BEC8 to $BECA, in the usual low-to-high order. (This is the total size of the file, in bytes) EOF = PEEK(48840) + 256 * PEEK(48841) + 65536 * PEEK(48842) EOF is the actual file size. The READ parameter block is at $BED5 (it is also used by WRITE). The address to which the data was loaded is at $BED7 and $BED8. The number of bytes requested is at $BED9 and $BEDA. The actual number of bytes transferred is at $BEDB and $BEDC. ADR = PEEK(48855) + 256 * PEEK(48856) RCNT = PEEK(48857) + 256 * PEEK(48858) TCNT = PEEK(48859) + 256 * PEEK(48860) ADR (address) is the load address, which may differ from the "default" load address if you used the A parameter. RCNT (request count) is the file size, unless you used the L or E parameter to limit the amount loaded. The GET_FILE_INFO parameter block is at $BEB4 (it is also used by SET_FILE_INFO). It includes the following fields: $BEB7 File access - bit fields, so it is difficult to interpret in BASIC. AC = PEEK(48823) $BEB8 File type FT = PEEK(48824) $BEB9 and $BEBA Auxiliary type For BIN files, this is the default load address. For a disk, this is the total number of blocks. AUX = PEEK(48825) + 256 * PEEK(48826) $BEBB Storage type (1 = seedling, 2 = sapling, 3 = tree, 4 = Pascal area, 5 = extended file with resource fork, 13 = directory, 15 = disk) ST = PEEK(48827) $BEBC and $BEBD Blocks used For a disk, this is the total number of blocks used by all files. BLKS = PEEK(48828) + 256 * PEEK(48829) $BEBE through $BEC1 File modification date and time $BEC2 through $BEC5 File creation date and time These fields are difficult to deal with from BASIC. An important point: the GET_FILE_INFO parameters are also valid after using the VERIFY command. If you know a file exists and want to get more information about it, you can use the following: PRINT D$;"VERIFY ";F$ then use the above PEEKs to get information about the file. If it doesn't exist, you will get a FILE NOT FOUND error, which can be trapped using ONERR GOTO. > Also, while you are at it, is the location for the same > information different in dos 3.3? These ones I know off by heart. Major assumption: you are running a "normal" version of DOS 3.3, not a version which has been copied into the language card (Pronto DOS and Diversi DOS can do this). The load address of a binary file is held in $AA72 and $AA73. ADR = PEEK(43634) + 256 * PEEK(43635) The size of the file (in bytes) is held in $AA60 and $AA61. FLN = PEEK(43616) + 256 * PEEK(43617) > How about a peek to tell if you are in dos 3.3 or prodos? Thanks! The best one to use here is the same method used by the Apple II Memory Expansion Card to identify the operating system. It relies on location $BF00 containing a JMP instruction for ProDOS, and something else for DOS 3.3 (which is true for all official versions, and I believe it is the case for all the third-party DOSes, including ones that have been moved into the language card). DOS33 = (PEEK(48896) <> 76) You can subsequently use tests like: IF DOS33 THEN ... or IF NOT DOS33 THEN ... -- David Empson dempson@actrix.gen.nz Snail mail: P.O. Box 27-103, Wellington, New Zealand