1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
/* Copyright (c) 1996-98, Timothy Mann */
/* $Id: load_cmd.h,v 1.3 2008/06/26 04:39:56 mann Exp $ */
/* This software may be copied, modified, and used for any purpose
* without fee, provided that (1) the above copyright notice is
* retained, and (2) modified versions are clearly marked as having
* been modified, with the modifier's name and the date included. */
/* TRS-80 DOS /cmd file loader */
#include <stdio.h> /* FILE */
#define LOAD_CMD_OK 0
#define LOAD_CMD_EOF -1
#define LOAD_CMD_NOT_FOUND -2
#define LOAD_CMD_ISAM -3
#define LOAD_CMD_PDS -4
#define VERBOSITY_QUIET 0
#define VERBOSITY_TEXT 1
#define VERBOSITY_MAP 2
#define VERBOSITY_DETAILED 3
#define ISAM_NONE -1
/* Load the /cmd file f into the given memory, optionally selecting
* out an ISAM or PDS member. Return LOAD_CMD_OK for success if f was a
* normal /cmd file, LOAD_CMD_ISAM for success if it was an ISAM file,
* LOAD_CMD_PDS for success if this was a PDS file, LOAD_CMD_EOF for
* failure due to premature end of file, LOAD_CMD_NOT_FOUND for ISAM
* or PDF member not found, or a positive number B for an unknown or
* badly formatted load block of typecode B (load file format error).
*
* Optional flags:
*
* If loadmap is not NULL, it must point to an array of 2**16
* bytes. Each byte in the return value will have a count (mod 256)
* of the number of times that memory location was loaded. Usually each
* count will be 0 or 1, of course.
*
* If verbosity is VERBOSITY_QUIET, print nothing. If verbosity is
* VERBOSITY_TEXT, print module headers, PDS headers, patch names, and
* copyright notices. If verbosity is VERBOSITY_MAP, also print load
* map information as we go along, but coalesce adjacent blocks that
* load contiguously into memory. If verbosity is VERBOSITY_DETAILED,
* don't coalesce.
*
* If isam is not -1, search for the given isam member number and load
* it instead of loading the whole file.
*
* If pds is not NULL, search for the given pds member name and
* load it instead of loading the whole file. isam and pds cannot
* both be used.
*
* If xferaddr is not NULL, return the transfer address there, or if
* there is no transfer address, return -1.
*
* If stopxfer is 1, stop loading when a transfer address is seen; if
* 0, continue loading. stopxfer = 0 is needed if you want to parse
* a PDS file with a front end loader. stopxfer = 1 is useful to deal
* with ordinary /cmd files that have extra garbage at the end, as
* sometimes happens. stopxfer = 0 should be considered the default.
*/
int
load_cmd(FILE* f, unsigned char memory[65536],
unsigned char* loadmap, int verbosity, FILE* outf,
int isam, char* pds, int* xferaddr, int stopxfer);
|