\r
}/* os_init_setup */\r
\r
+\r
/*\r
* dectoi\r
*\r
* be NULL, but it must not be empty.\r
*\r
*/\r
-\r
int dectoi (const char *s)\r
{\r
int n = 0;\r
\r
}/* dectoi */\r
\r
+\r
/*\r
* hextoi\r
*\r
* NULL, but it must not be empty.\r
*\r
*/\r
-\r
int hextoi (const char *s)\r
{\r
int n = 0;\r
\r
}/* hextoi */\r
\r
+\r
/*\r
* basename\r
*\r
* interrupt pointers and return to the previous video mode.\r
*\r
*/\r
-\r
static void cleanup (void)\r
{\r
\r
\r
}/* cleanup */\r
\r
+\r
/*\r
* fast_exit\r
*\r
* Handler routine to be called when the crtl-break key is pressed.\r
*\r
*/\r
-\r
static void interrupt fast_exit ()\r
{\r
\r
\r
}/* fast_exit */\r
\r
+\r
/*\r
* os_fatal\r
*\r
\r
}/* os_fatal */\r
\r
+\r
/*\r
* parse_options\r
*\r
* Parse program options and set global flags accordingly.\r
*\r
*/\r
-\r
static void parse_options (int argc, char **argv)\r
{\r
int c;\r
\r
}/* parse_options */\r
\r
+\r
/*\r
* os_process_arguments\r
*\r
* The global pointer "story_name" is set to the story file name.\r
*\r
*/\r
-\r
void os_process_arguments (int argc, char *argv[])\r
{\r
const char *p;\r
}\r
}/* os_process_arguments */\r
\r
+\r
/*\r
* standard_palette\r
*\r
* use DAC registers #0 to #63.\r
*\r
*/\r
-\r
static void standard_palette (void)\r
{\r
\r
\r
}/* standard_palette */\r
\r
+\r
/*\r
* special_palette\r
*\r
* registers #64 to #127.\r
*\r
*/\r
-\r
static void special_palette (void)\r
{\r
\r
\r
}/* special_palette */\r
\r
+\r
/*\r
* os_init_screen\r
*\r
* should not be used for multiple undo and reserved for later use.\r
*\r
*/\r
-\r
void os_init_screen (void)\r
{\r
static byte zcolour[] = {\r
\r
}/* os_init_screen */\r
\r
+\r
/*\r
* os_reset_screen\r
*\r
* Reset the screen before the program stops.\r
*\r
*/\r
-\r
void os_reset_screen (void)\r
{\r
\r
\r
}/* os_reset_screen */\r
\r
+\r
/*\r
* os_restart_game\r
*\r
* RESTART_END - restart is complete\r
*\r
*/\r
-\r
void os_restart_game (int stage)\r
{\r
int x, y;\r
\r
}/* os_restart_game */\r
\r
+\r
/*\r
* os_random_seed\r
*\r
* 32767, possibly by using the current system time.\r
*\r
*/\r
-\r
int os_random_seed (void)\r
{\r
-\r
if (user_random_seed == -1) {\r
\r
/* Use the time of day as seed value */\r
}/* os_random_seed */\r
\r
\r
-\r
/*\r
* os_path_open\r
*\r
* if it is defined, otherwise search INFOCOM_PATH.\r
*\r
*/\r
-\r
FILE *os_path_open (const char *name, const char *mode)\r
{\r
FILE *fp;\r
return NULL;\r
}/* os_path_open */\r
\r
+\r
/*\r
* os_load_story\r
*\r
* defined, search INFOCOM_PATH.\r
*\r
*/\r
-\r
FILE *os_load_story(void)\r
{\r
FILE *fp;\r
return fp;\r
}\r
\r
+\r
int dos_init_blorb(void)\r
{\r
FILE *blorbfile;\r
return 0;\r
}\r
\r
+\r
/*\r
- * Seek into a storyfile, either a standalone file or the \r
+ * Seek into a storyfile, either a standalone file or the\r
* ZCODE chunk of a blorb file\r
*/\r
int os_storyfile_seek(FILE * fp, long offset, int whence)\r
{\r
+ int retval;\r
/* Is this a Blorb file containing Zcode? */\r
- if (exec_in_blorb)\r
- {\r
- switch (whence)\r
- {\r
- case SEEK_END:\r
- return fseek(fp, blorb_res.data.startpos + blorb_res.length + offset, SEEK_SET);\r
- break;\r
- case SEEK_CUR:\r
- return fseek(fp, offset, SEEK_CUR);\r
- break;\r
- case SEEK_SET:\r
- default:\r
- return fseek(fp, blorb_res.data.startpos + offset, SEEK_SET);\r
- break;\r
- }\r
- }\r
- else\r
- {\r
- return fseek(fp, offset, whence);\r
+ if (exec_in_blorb) {\r
+ switch (whence) {\r
+ case SEEK_END:\r
+ retval = fseek(fp, blorb_res.data.startpos + blorb_res.length + offset, SEEK_SET);\r
+ break;\r
+ case SEEK_CUR:\r
+ retval = fseek(fp, offset, SEEK_CUR);\r
+ break;\r
+ case SEEK_SET:\r
+ default:\r
+ retval = fseek(fp, blorb_res.data.startpos + offset, SEEK_SET);\r
+ break;\r
+ }\r
+ return retval;\r
}\r
-\r
+ return fseek(fp, offset, whence);\r
}\r
\r
+\r
/*\r
- * Tell the position in a storyfile, either a standalone file \r
+ * Tell the position in a storyfile, either a standalone file\r
* or the ZCODE chunk of a blorb file\r
*/\r
int os_storyfile_tell(FILE * fp)\r
{\r
/* Is this a Blorb file containing Zcode? */\r
if (exec_in_blorb)\r
- {\r
return ftell(fp) - blorb_res.data.startpos;\r
- }\r
- else\r
- {\r
- return ftell(fp);\r
- }\r
\r
+ return ftell(fp);\r
}\r
-\r
-#ifndef BLORB_H
-#define BLORB_H
-
-/* blorb.h: Header file for Blorb library, version 1.0.2.
- Designed by Andrew Plotkin <erkyrath@eblong.com>
- http://www.eblong.com/zarf/blorb/index.html
-
- This is the header that a Z-machine interpreter should include.
- It defines everything that the interpreter has to know.
-*/
-
-/* Things you (the porter) have to edit: */
-
-/* As you might expect, uint32 must be a 32-bit unsigned numeric type,
- and uint16 a 16-bit unsigned numeric type. You should also uncomment
- exactly one of the two ENDIAN definitions. */
-
-/* #define BLORB_BIG_ENDIAN */
-
-#define BLORB_LITTLE_ENDIAN
-typedef unsigned long uint32;
-typedef unsigned short uint16;
-
-/* End of things you have to edit. */
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-/* Error type and error codes */
-typedef int bb_err_t;
-
-#define bb_err_None (0)
-#define bb_err_CompileTime (1)
-#define bb_err_Alloc (2)
-#define bb_err_Read (3)
-#define bb_err_NotAMap (4)
-#define bb_err_Format (5)
-#define bb_err_NotFound (6)
-
-/* Methods for loading a chunk */
-#define bb_method_DontLoad (0)
-#define bb_method_Memory (1)
-#define bb_method_FilePos (2)
-
-/* Four-byte constants */
-
-/*#define bb_make_id(c1, c2, c3, c4) \
- (((c1) << 24) | ((c2) << 16) | ((c3) << 8) | (c4))
-*/
-#define bb_ID_Snd 1399743520
-#define bb_ID_Exec 1165518179
-#define bb_ID_Pict 1349084020
-#define bb_ID_Copyright 677587232
-#define bb_ID_AUTH 1096111176
-#define bb_ID_ANNO 1095650895
-
-#define bb_ID_ZCOD 1514360644
-
-/* bb_result_t: Result when you try to load a chunk. */
-typedef struct bb_result_struct {
- int chunknum; /* The chunk number (for use in bb_unload_chunk(), etc.) */
- union {
- void *ptr; /* A pointer to the data (if you used bb_method_Memory) */
- uint32 startpos; /* The position in the file (if you used bb_method_FilePos) */
- } data;
- uint32 length; /* The length of the data */
-} bb_result_t;
-
-/* bb_aux_sound_t: Extra data which may be associated with a sound. */
-typedef struct bb_aux_sound_struct {
- char repeats;
-} bb_aux_sound_t;
-
-/* bb_aux_pict_t: Extra data which may be associated with an image. */
-typedef struct bb_aux_pict_struct {
- uint32 ratnum, ratden;
- uint32 minnum, minden;
- uint32 maxnum, maxden;
-} bb_aux_pict_t;
-
-/* bb_resolution_t: The global resolution data. */
-typedef struct bb_resolution_struct {
- uint32 px, py;
- uint32 minx, miny;
- uint32 maxx, maxy;
-} bb_resolution_t;
-
-/* bb_color_t: Guess what. */
-typedef struct bb_color_struct {
- unsigned char red, green, blue;
-} bb_color_t;
-
-/* bb_palette_t: The palette data. */
-typedef struct bb_palette_struct {
- int isdirect;
- union {
- int depth; /* The depth (if isdirect is TRUE). Either 16 or 32. */
- struct {
- int numcolors;
- bb_color_t *colors;
- } table; /* The list of colors (if isdirect is FALSE). */
- } data;
-} bb_palette_t;
-
-/* bb_zheader_t: Information to identify a Z-code file. */
-typedef struct bb_zheader_struct {
- uint16 releasenum; /* Bytes $2-3 of header. */
- char serialnum[6]; /* Bytes $12-17 of header. */
- uint16 checksum; /* Bytes $1C-1D of header. */
- /* The initpc field is not used by Blorb. */
-} bb_zheader_t;
-
-/* bb_map_t: Holds the complete description of an open Blorb file.
- This type is opaque for normal interpreter use. */
-typedef struct bb_map_struct bb_map_t;
-
-/* Function declarations. These functions are of fairly general use;
- they would apply to any Blorb file. */
-
-extern bb_err_t bb_create_map(FILE *file, bb_map_t **newmap);
-extern bb_err_t bb_destroy_map(bb_map_t *map);
-
-extern char *bb_err_to_string(bb_err_t err);
-
-extern bb_err_t bb_load_chunk_by_type(bb_map_t *map, int method,
- bb_result_t *res, uint32 chunktype, int count);
-extern bb_err_t bb_load_chunk_by_number(bb_map_t *map, int method,
- bb_result_t *res, int chunknum);
-extern bb_err_t bb_unload_chunk(bb_map_t *map, int chunknum);
-
-extern bb_err_t bb_load_resource(bb_map_t *map, int method,
- bb_result_t *res, uint32 usage, int resnum);
-extern bb_err_t bb_count_resources(bb_map_t *map, uint32 usage,
- int *num, int *min, int *max);
-
-/* More function declarations. These functions are more or less
- specific to the Z-machine's use of Blorb. */
-
-extern uint16 bb_get_release_num(bb_map_t *map);
-extern bb_zheader_t *bb_get_zheader(bb_map_t *map);
-extern bb_resolution_t *bb_get_resolution(bb_map_t *map);
-extern bb_err_t bb_get_palette(bb_map_t *map, bb_palette_t **res);
-extern bb_err_t bb_load_resource_pict(bb_map_t *map, int method,
- bb_result_t *res, int resnum, bb_aux_pict_t **auxdata);
-extern bb_err_t bb_load_resource_snd(bb_map_t *map, int method,
- bb_result_t *res, int resnum, bb_aux_sound_t **auxdata);
-
-#endif /* BLORB_H */
+#ifndef BLORB_H\r
+#define BLORB_H\r
+\r
+/* blorb.h: Header file for Blorb library, version 1.0.2.\r
+ Designed by Andrew Plotkin <erkyrath@eblong.com>\r
+ http://www.eblong.com/zarf/blorb/index.html\r
+\r
+ This is the header that a Z-machine interpreter should include.\r
+ It defines everything that the interpreter has to know.\r
+*/\r
+\r
+/* Things you (the porter) have to edit: */\r
+\r
+/* As you might expect, uint32 must be a 32-bit unsigned numeric type,\r
+ and uint16 a 16-bit unsigned numeric type. You should also uncomment\r
+ exactly one of the two ENDIAN definitions. */\r
+\r
+/* #define BLORB_BIG_ENDIAN */\r
+\r
+#define BLORB_LITTLE_ENDIAN\r
+typedef unsigned long uint32;\r
+typedef unsigned short uint16;\r
+\r
+/* End of things you have to edit. */\r
+\r
+#ifndef TRUE\r
+#define TRUE 1\r
+#endif\r
+#ifndef FALSE\r
+#define FALSE 0\r
+#endif\r
+\r
+/* Error type and error codes */\r
+typedef int bb_err_t;\r
+\r
+#define bb_err_None (0)\r
+#define bb_err_CompileTime (1)\r
+#define bb_err_Alloc (2)\r
+#define bb_err_Read (3)\r
+#define bb_err_NotAMap (4)\r
+#define bb_err_Format (5)\r
+#define bb_err_NotFound (6)\r
+\r
+/* Methods for loading a chunk */\r
+#define bb_method_DontLoad (0)\r
+#define bb_method_Memory (1)\r
+#define bb_method_FilePos (2)\r
+\r
+/* Four-byte constants */\r
+\r
+/*#define bb_make_id(c1, c2, c3, c4) \\r
+ (((c1) << 24) | ((c2) << 16) | ((c3) << 8) | (c4))\r
+*/\r
+#define bb_ID_Snd 1399743520\r
+#define bb_ID_Exec 1165518179\r
+#define bb_ID_Pict 1349084020\r
+#define bb_ID_Copyright 677587232\r
+#define bb_ID_AUTH 1096111176\r
+#define bb_ID_ANNO 1095650895\r
+\r
+#define bb_ID_ZCOD 1514360644\r
+\r
+/* bb_result_t: Result when you try to load a chunk. */\r
+typedef struct bb_result_struct {\r
+ int chunknum; /* The chunk number (for use in bb_unload_chunk(), etc.) */\r
+ union {\r
+ void *ptr; /* A pointer to the data (if you used bb_method_Memory) */\r
+ uint32 startpos; /* The position in the file (if you used bb_method_FilePos) */\r
+ } data;\r
+ uint32 length; /* The length of the data */\r
+} bb_result_t;\r
+\r
+/* bb_aux_sound_t: Extra data which may be associated with a sound. */\r
+typedef struct bb_aux_sound_struct {\r
+ char repeats;\r
+} bb_aux_sound_t;\r
+\r
+/* bb_aux_pict_t: Extra data which may be associated with an image. */\r
+typedef struct bb_aux_pict_struct {\r
+ uint32 ratnum, ratden;\r
+ uint32 minnum, minden;\r
+ uint32 maxnum, maxden;\r
+} bb_aux_pict_t;\r
+\r
+/* bb_resolution_t: The global resolution data. */\r
+typedef struct bb_resolution_struct {\r
+ uint32 px, py;\r
+ uint32 minx, miny;\r
+ uint32 maxx, maxy;\r
+} bb_resolution_t;\r
+\r
+/* bb_color_t: Guess what. */\r
+typedef struct bb_color_struct {\r
+ unsigned char red, green, blue;\r
+} bb_color_t;\r
+\r
+/* bb_palette_t: The palette data. */\r
+typedef struct bb_palette_struct {\r
+ int isdirect;\r
+ union {\r
+ int depth; /* The depth (if isdirect is TRUE). Either 16 or 32. */\r
+ struct {\r
+ int numcolors;\r
+ bb_color_t *colors;\r
+ } table; /* The list of colors (if isdirect is FALSE). */\r
+ } data;\r
+} bb_palette_t;\r
+\r
+/* bb_zheader_t: Information to identify a Z-code file. */\r
+typedef struct bb_zheader_struct {\r
+ uint16 releasenum; /* Bytes $2-3 of header. */\r
+ char serialnum[6]; /* Bytes $12-17 of header. */\r
+ uint16 checksum; /* Bytes $1C-1D of header. */\r
+ /* The initpc field is not used by Blorb. */\r
+} bb_zheader_t;\r
+\r
+/* bb_map_t: Holds the complete description of an open Blorb file.\r
+ This type is opaque for normal interpreter use. */\r
+typedef struct bb_map_struct bb_map_t;\r
+\r
+/* Function declarations. These functions are of fairly general use;\r
+ they would apply to any Blorb file. */\r
+\r
+extern bb_err_t bb_create_map(FILE *file, bb_map_t **newmap);\r
+extern bb_err_t bb_destroy_map(bb_map_t *map);\r
+\r
+extern char *bb_err_to_string(bb_err_t err);\r
+\r
+extern bb_err_t bb_load_chunk_by_type(bb_map_t *map, int method,\r
+ bb_result_t *res, uint32 chunktype, int count);\r
+extern bb_err_t bb_load_chunk_by_number(bb_map_t *map, int method,\r
+ bb_result_t *res, int chunknum);\r
+extern bb_err_t bb_unload_chunk(bb_map_t *map, int chunknum);\r
+\r
+extern bb_err_t bb_load_resource(bb_map_t *map, int method,\r
+ bb_result_t *res, uint32 usage, int resnum);\r
+extern bb_err_t bb_count_resources(bb_map_t *map, uint32 usage,\r
+ int *num, int *min, int *max);\r
+\r
+/* More function declarations. These functions are more or less\r
+ specific to the Z-machine's use of Blorb. */\r
+\r
+extern uint16 bb_get_release_num(bb_map_t *map);\r
+extern bb_zheader_t *bb_get_zheader(bb_map_t *map);\r
+extern bb_resolution_t *bb_get_resolution(bb_map_t *map);\r
+extern bb_err_t bb_get_palette(bb_map_t *map, bb_palette_t **res);\r
+extern bb_err_t bb_load_resource_pict(bb_map_t *map, int method,\r
+ bb_result_t *res, int resnum, bb_aux_pict_t **auxdata);\r
+extern bb_err_t bb_load_resource_snd(bb_map_t *map, int method,\r
+ bb_result_t *res, int resnum, bb_aux_sound_t **auxdata);\r
+\r
+#endif /* BLORB_H */\r