From: David Griffith Date: Mon, 25 May 2015 07:31:19 +0000 (-0700) Subject: Additions and tweaks to make Frotz compile with the Turbo C IDE. X-Git-Url: https://scope-eye.net/git/?a=commitdiff_plain;h=a1582155afa5f13a14fb2535b4c211a58ecc4143;p=liskon_frotz.git Additions and tweaks to make Frotz compile with the Turbo C IDE. --- diff --git a/.gitignore b/.gitignore index 3e9c5c1..d2ce7c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,11 @@ frotz dfrotz *.o +*.O +*.OBJ +*.BAK +*.SWP +*.DSK *.a defines.h + diff --git a/Makefile b/Makefile index 31f271f..9755675 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,7 @@ CURSES = -lcurses #MEMMOVE_DEF = -DNO_MEMMOVE # Uncomment this if for some wacky reason you want to compile Unix Frotz -# under Cygwin under Windoze. This sort of thing is not reccomended. +# under Cygwin under Windoze. This sort of thing is not recomended. # #EXTENSION = .exe @@ -323,13 +323,14 @@ dist: distclean clean: rm -f $(SRCDIR)/*.h $(SRCDIR)/*.a - find . -name *.o -exec rm -f {} \; - find . -name *.O -exec rm -f {} \; + find . -iname *.o -exec rm -f {} \; + find . -iname *.obj -exec rm -f {} \; distclean: clean rm -f $(BINNAME)$(EXTENSION) d$(BINNAME)$(EXTENSION) s$(BINNAME) - rm -f *.EXE *.BAK *.LIB - rm -f *.exe *.bak *.lib + find . -iname *.exe -exec rm -f {} \; + find . -iname *.bak -exec rm -f {} \; + find . -iname *.lib -exec rm -f {} \; rm -f *core $(SRCDIR)/*core -rm -rf $(distdir) -rm -f $(distdir).tar $(distdir).tar.gz diff --git a/frotz.prj b/frotz.prj new file mode 100644 index 0000000..5d0bd28 Binary files /dev/null and b/frotz.prj differ diff --git a/src/dos/bcinit.c b/src/dos/bcinit.c index 57a0af7..d6f19cc 100644 --- a/src/dos/bcinit.c +++ b/src/dos/bcinit.c @@ -109,6 +109,7 @@ void os_init_setup(void) }/* os_init_setup */ + /* * dectoi * @@ -116,7 +117,6 @@ void os_init_setup(void) * be NULL, but it must not be empty. * */ - int dectoi (const char *s) { int n = 0; @@ -133,6 +133,7 @@ int dectoi (const char *s) }/* dectoi */ + /* * hextoi * @@ -140,7 +141,6 @@ int dectoi (const char *s) * NULL, but it must not be empty. * */ - int hextoi (const char *s) { int n = 0; @@ -160,6 +160,7 @@ int hextoi (const char *s) }/* hextoi */ + /* * basename * @@ -188,7 +189,6 @@ char *basename(const char *path) * interrupt pointers and return to the previous video mode. * */ - static void cleanup (void) { @@ -205,13 +205,13 @@ static void cleanup (void) }/* cleanup */ + /* * fast_exit * * Handler routine to be called when the crtl-break key is pressed. * */ - static void interrupt fast_exit () { @@ -219,6 +219,7 @@ static void interrupt fast_exit () }/* fast_exit */ + /* * os_fatal * @@ -244,13 +245,13 @@ void os_fatal (const char *s, ...) }/* os_fatal */ + /* * parse_options * * Parse program options and set global flags accordingly. * */ - static void parse_options (int argc, char **argv) { int c; @@ -329,6 +330,7 @@ static void parse_options (int argc, char **argv) }/* parse_options */ + /* * os_process_arguments * @@ -351,7 +353,6 @@ static void parse_options (int argc, char **argv) * The global pointer "story_name" is set to the story file name. * */ - void os_process_arguments (int argc, char *argv[]) { const char *p; @@ -416,6 +417,7 @@ void os_process_arguments (int argc, char *argv[]) } }/* os_process_arguments */ + /* * standard_palette * @@ -423,7 +425,6 @@ void os_process_arguments (int argc, char *argv[]) * use DAC registers #0 to #63. * */ - static void standard_palette (void) { @@ -446,6 +447,7 @@ static void standard_palette (void) }/* standard_palette */ + /* * special_palette * @@ -453,7 +455,6 @@ static void standard_palette (void) * registers #64 to #127. * */ - static void special_palette (void) { @@ -476,6 +477,7 @@ static void special_palette (void) }/* special_palette */ + /* * os_init_screen * @@ -501,7 +503,6 @@ static void special_palette (void) * should not be used for multiple undo and reserved for later use. * */ - void os_init_screen (void) { static byte zcolour[] = { @@ -756,13 +757,13 @@ void os_init_screen (void) }/* os_init_screen */ + /* * os_reset_screen * * Reset the screen before the program stops. * */ - void os_reset_screen (void) { @@ -775,6 +776,7 @@ void os_reset_screen (void) }/* os_reset_screen */ + /* * os_restart_game * @@ -786,7 +788,6 @@ void os_reset_screen (void) * RESTART_END - restart is complete * */ - void os_restart_game (int stage) { int x, y; @@ -821,6 +822,7 @@ void os_restart_game (int stage) }/* os_restart_game */ + /* * os_random_seed * @@ -828,10 +830,8 @@ void os_restart_game (int stage) * 32767, possibly by using the current system time. * */ - int os_random_seed (void) { - if (user_random_seed == -1) { /* Use the time of day as seed value */ @@ -846,7 +846,6 @@ int os_random_seed (void) }/* os_random_seed */ - /* * os_path_open * @@ -855,7 +854,6 @@ int os_random_seed (void) * if it is defined, otherwise search INFOCOM_PATH. * */ - FILE *os_path_open (const char *name, const char *mode) { FILE *fp; @@ -883,6 +881,7 @@ FILE *os_path_open (const char *name, const char *mode) return NULL; }/* os_path_open */ + /* * os_load_story * @@ -895,7 +894,6 @@ FILE *os_path_open (const char *name, const char *mode) * defined, search INFOCOM_PATH. * */ - FILE *os_load_story(void) { FILE *fp; @@ -910,6 +908,7 @@ FILE *os_load_story(void) return fp; } + int dos_init_blorb(void) { FILE *blorbfile; @@ -945,51 +944,43 @@ int dos_init_blorb(void) return 0; } + /* - * Seek into a storyfile, either a standalone file or the + * Seek into a storyfile, either a standalone file or the * ZCODE chunk of a blorb file */ int os_storyfile_seek(FILE * fp, long offset, int whence) { + int retval; /* Is this a Blorb file containing Zcode? */ - if (exec_in_blorb) - { - switch (whence) - { - case SEEK_END: - return fseek(fp, blorb_res.data.startpos + blorb_res.length + offset, SEEK_SET); - break; - case SEEK_CUR: - return fseek(fp, offset, SEEK_CUR); - break; - case SEEK_SET: - default: - return fseek(fp, blorb_res.data.startpos + offset, SEEK_SET); - break; - } - } - else - { - return fseek(fp, offset, whence); + if (exec_in_blorb) { + switch (whence) { + case SEEK_END: + retval = fseek(fp, blorb_res.data.startpos + blorb_res.length + offset, SEEK_SET); + break; + case SEEK_CUR: + retval = fseek(fp, offset, SEEK_CUR); + break; + case SEEK_SET: + default: + retval = fseek(fp, blorb_res.data.startpos + offset, SEEK_SET); + break; + } + return retval; } - + return fseek(fp, offset, whence); } + /* - * Tell the position in a storyfile, either a standalone file + * Tell the position in a storyfile, either a standalone file * or the ZCODE chunk of a blorb file */ int os_storyfile_tell(FILE * fp) { /* Is this a Blorb file containing Zcode? */ if (exec_in_blorb) - { return ftell(fp) - blorb_res.data.startpos; - } - else - { - return ftell(fp); - } + return ftell(fp); } - diff --git a/src/dos/blorb.h b/src/dos/blorb.h index 5a0694c..aecc3fc 100644 --- a/src/dos/blorb.h +++ b/src/dos/blorb.h @@ -1,152 +1,152 @@ -#ifndef BLORB_H -#define BLORB_H - -/* blorb.h: Header file for Blorb library, version 1.0.2. - Designed by Andrew Plotkin - 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 +#define BLORB_H + +/* blorb.h: Header file for Blorb library, version 1.0.2. + Designed by Andrew Plotkin + 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 */