Convert DOS interface to use z_header structure.
authorDavid Griffith <dave@661.org>
Wed, 2 Oct 2019 20:55:01 +0000 (13:55 -0700)
committerDavid Griffith <dave@661.org>
Wed, 2 Oct 2019 20:55:01 +0000 (13:55 -0700)
There is currently a problem with compiling with Turbo C 3.00

src\common\fastmem.c
Error src\common\fastmem.c 160: Ambiguous member name 'flags' in function
restart_header
Error src\common\fastmem.c 435: Ambiguous member name 'flags' in function
init_memory
*** 2 errors in Compile ***

        Available memory 4059444

** error 1 ** deleting src\common\fastmem.o
C:\FROTZ>

src/common/frotz.h
src/dos/bcinit.c
src/dos/bcinput.c
src/dos/bcsample.c
src/dos/bctext.c

index e858b9bd8a7010c572061fe7b4a6011a97efbdbf..246a989896dcebad9cc6d0cf98099cd90a0d449c 100644 (file)
@@ -17,9 +17,9 @@
 #endif
 
 /* This will be addressed later. */
-#ifndef MSDOS_16BIT
+//#ifndef MSDOS_16BIT
 #include "git_hash.h"
-#endif
+//#endif
 
 #ifndef __UNIX_PORT_FILE
 #include <signal.h>
index 4f7d8fcc03351c87e0ff6af78c4b1603cb3440ee..da5bd155489fe8995c1963d9e7dc405d0bb6bd1e 100644 (file)
@@ -29,6 +29,7 @@
 #include "bcblorb.h"
 
 f_setup_t f_setup;
+z_header_t z_header;
 
 static char information[] =
     "An interpreter for all Infocom and other Z-Machine games.\n"
@@ -232,7 +233,7 @@ static void interrupt fast_exit()
  */
 void os_fatal(const char *s, ...)
 {
-       if (h_interpreter_number)
+       if (z_header.interpreter_number)
                os_reset_screen();
 
        /* Display error message */
@@ -479,19 +480,19 @@ static void standard_palette(void)
  * (mouse, sound board). Set various OS depending story file header
  * entries:
  *
- *     h_config (aka flags 1)
- *     h_flags (aka flags 2)
- *     h_screen_cols (aka screen width in characters)
- *     h_screen_rows (aka screen height in lines)
- *     h_screen_width
- *     h_screen_height
- *     h_font_height (defaults to 1)
- *     h_font_width (defaults to 1)
- *     h_default_foreground
- *     h_default_background
- *     h_interpreter_number
- *     h_interpreter_version
- *     h_user_name (optional; not used by any game)
+ *     z_header.config (aka flags 1)
+ *     z_header.flags (aka flags 2)
+ *     z_header.screen_cols (aka screen width in characters)
+ *     z_header.screen_rows (aka screen height in lines)
+ *     z_header.screen_width
+ *     z_header.screen_height
+ *     z_header.font_height (defaults to 1)
+ *     z_header.font_width (defaults to 1)
+ *     z_header.default_foreground
+ *     z_header.default_background
+ *     z_header.interpreter_number
+ *     z_header.interpreter_version
+ *     z_header.user_name (optional; not used by any game)
  *
  * Finally, set reserve_mem to the amount of memory (in bytes) that
  * should not be used for multiple undo and reserved for later use.
@@ -563,7 +564,7 @@ static void standard_palette(void)
         if (display == -1) {
                if (old_video_mode == 7)
                        display = '0';
-               else if (h_version == V6 || (h_flags & GRAPHICS_FLAG))
+               else if (z_header.version == V6 || (z_header.flags & GRAPHICS_FLAG))
                        display = '5';
                else
                        display = '1';
@@ -634,7 +635,7 @@ static void standard_palette(void)
 #endif
 
        /* Amiga emulation under V6 needs special preparation. */
-       if (display == _AMIGA_ && h_version == V6) {
+       if (display == _AMIGA_ && z_header.version == V6) {
                user_reverse_fg = -1;
                user_reverse_bg = -1;
                zcolour[LIGHTGRAY] = LIGHTGREY_COLOUR;
@@ -645,84 +646,84 @@ static void standard_palette(void)
 
        /* Set various bits in the configuration byte. These bits tell
           the game which features are supported by the interpreter. */
-       if (h_version == V3 && user_tandy_bit != -1)
-               h_config |= CONFIG_TANDY;
-       if (h_version == V3)
-               h_config |= CONFIG_SPLITSCREEN;
-       if (h_version == V3
+       if (z_header.version == V3 && user_tandy_bit != -1)
+               z_header.config |= CONFIG_TANDY;
+       if (z_header.version == V3)
+               z_header.config |= CONFIG_SPLITSCREEN;
+       if (z_header.version == V3
            && (display == _MCGA_ || (display == _AMIGA_ && user_font != 0)))
-               h_config |= CONFIG_PROPORTIONAL;
-       if (h_version >= V4 && display != _MCGA_
+               z_header.config |= CONFIG_PROPORTIONAL;
+       if (z_header.version >= V4 && display != _MCGA_
            && (user_bold_typing != -1 || display <= _TEXT_))
-               h_config |= CONFIG_BOLDFACE;
-       if (h_version >= V4)
-               h_config |= CONFIG_EMPHASIS | CONFIG_FIXED | CONFIG_TIMEDINPUT;
-       if (h_version >= V5 && display != _MONO_ && display != _CGA_)
-               h_config |= CONFIG_COLOUR;
-       if (h_version >= V5 && display >= _CGA_ && init_pictures())
-               h_config |= CONFIG_PICTURES;
+               z_header.config |= CONFIG_BOLDFACE;
+       if (z_header.version >= V4)
+               z_header.config |= CONFIG_EMPHASIS | CONFIG_FIXED | CONFIG_TIMEDINPUT;
+       if (z_header.version >= V5 && display != _MONO_ && display != _CGA_)
+               z_header.config |= CONFIG_COLOUR;
+       if (z_header.version >= V5 && display >= _CGA_ && init_pictures())
+               z_header.config |= CONFIG_PICTURES;
 
        /* Handle various game flags. These flags are set if the game wants
           to use certain features. The flags must be cleared if the feature
           is not available. */
-       if (h_flags & GRAPHICS_FLAG)
+       if (z_header.flags & GRAPHICS_FLAG)
                if (display <= _TEXT_)
-                       h_flags &= ~GRAPHICS_FLAG;
-       if (h_version == V3 && (h_flags & OLD_SOUND_FLAG))
+                       z_header.flags &= ~GRAPHICS_FLAG;
+       if (z_header.version == V3 && (z_header.flags & OLD_SOUND_FLAG))
 #ifdef SOUND_SUPPORT
                if (!dos_init_sound())
 #endif
-                       h_flags &= ~OLD_SOUND_FLAG;
-       if (h_flags & SOUND_FLAG)
+                       z_header.flags &= ~OLD_SOUND_FLAG;
+       if (z_header.flags & SOUND_FLAG)
 #ifdef SOUND_SUPPORT
                if (!dos_init_sound())
 #endif
-                       h_flags &= ~SOUND_FLAG;
-       if (h_version >= V5 && (h_flags & UNDO_FLAG))
+                       z_header.flags &= ~SOUND_FLAG;
+       if (z_header.version >= V5 && (z_header.flags & UNDO_FLAG))
                if (!f_setup.undo_slots)
-                       h_flags &= ~UNDO_FLAG;
-       if (h_flags & MOUSE_FLAG)
+                       z_header.flags &= ~UNDO_FLAG;
+       if (z_header.flags & MOUSE_FLAG)
                if (subdisplay != -1 || !detect_mouse())
-                       h_flags &= ~MOUSE_FLAG;
-       if (h_flags & COLOUR_FLAG)
+                       z_header.flags &= ~MOUSE_FLAG;
+       if (z_header.flags & COLOUR_FLAG)
                if (display == _MONO_ || display == _CGA_)
-                       h_flags &= ~COLOUR_FLAG;
-       h_flags &= ~MENU_FLAG;
+                       z_header.flags &= ~COLOUR_FLAG;
+       z_header.flags &= ~MENU_FLAG;
 
        /* Set the screen dimensions, font size and default colour */
-       h_screen_width = info[display].width;
-       h_screen_height = info[display].height;
-       h_font_height = info[display].font_height;
-       h_font_width = info[display].font_width;
-       h_default_foreground = info[display].fg;
-       h_default_background = info[display].bg;
+       z_header.screen_width = info[display].width;
+       z_header.screen_height = info[display].height;
+       z_header.font_height = info[display].font_height;
+       z_header.font_width = info[display].font_width;
+       z_header.default_foreground = info[display].fg;
+       z_header.default_background = info[display].bg;
 
        if (subdisplay != -1) {
-               h_screen_width = subinfo[subdisplay].width;
-               h_screen_height = subinfo[subdisplay].height;
+               z_header.screen_width = subinfo[subdisplay].width;
+               z_header.screen_height = subinfo[subdisplay].height;
        }
 
        if (user_screen_width != -1)
-               h_screen_width = user_screen_width;
+               z_header.screen_width = user_screen_width;
        if (user_screen_height != -1)
-               h_screen_height = user_screen_height;
+               z_header.screen_height = user_screen_height;
 
-       h_screen_cols = h_screen_width / h_font_width;
-       h_screen_rows = h_screen_height / h_font_height;
+       z_header.screen_cols = z_header.screen_width / z_header.font_width;
+       z_header.screen_rows = z_header.screen_height / z_header.font_height;
 
        if (user_foreground != -1)
-               h_default_foreground = zcolour[user_foreground];
+               z_header.default_foreground = zcolour[user_foreground];
        if (user_background != -1)
-               h_default_background = zcolour[user_background];
+               z_header.default_background = zcolour[user_background];
 
        /* Set the interpreter number (a constant telling the game which
           operating system it runs on) and the interpreter version. The
           interpreter number has effect on V6 games and "Beyond Zork". */
-       h_interpreter_number = INTERP_MSDOS;
-       h_interpreter_version = 'F';
+       z_header.interpreter_number = INTERP_MSDOS;
+       z_header.interpreter_version = 'F';
 
        if (display == _AMIGA_)
-               h_interpreter_number = INTERP_AMIGA;
+               z_header.interpreter_number = INTERP_AMIGA;
 
        /* Install the fast_exit routine to handle the ctrl-break key */
        oldvect = getvect(0x1b);
index 79b7c8681d31fc15d080ec413085fbff49e1f616..6ca01e2d2e392738152f914e9b8f7607964e5039 100644 (file)
@@ -216,7 +216,7 @@ static int get_key(bool cursor)
        if (cursor)
                switch_cursor(TRUE);
 
-       if (h_flags & MOUSE_FLAG) {
+       if (z_header.flags & MOUSE_FLAG) {
                asm mov ax,1
                asm int 0x33
        }
@@ -290,7 +290,7 @@ static int get_key(bool cursor)
 
 exit_loop:
 
-       if (h_flags & MOUSE_FLAG) {
+       if (z_header.flags & MOUSE_FLAG) {
                asm mov ax,2
                asm int 0x33
        }
@@ -435,7 +435,7 @@ static void input_move(zchar newc, zchar oldc)
                os_erase_area (
                    cursor_y + 1,
                    cursor_x + 1,
-                   cursor_y + h_font_height,
+                   cursor_y + z_header.font_height,
                    cursor_x + oldwidth - newwidth,
                    -1);
        }
index f60c621571867cd6131d15192b5ec61bf5f32240..2914f210cc18bbea13ec92133684510f76a0b39b 100644 (file)
@@ -208,7 +208,7 @@ bool dos_init_sound(void)
  */
 void dos_reset_sound(void)
 {
-       os_stop_sample();
+       os_stop_sample(0);
 
        if (sample_data != NULL) {
                farfree(sample_data);
@@ -256,7 +256,7 @@ void os_prepare_sample(int number)
 {
 #ifdef SOUND_SUPPORT
 
-       os_stop_sample();
+       os_stop_sample(0);
 
        /* Exit if the sound board isn't set up properly */
        if (sample_data == NULL)
@@ -325,7 +325,7 @@ void os_start_sample(int number, int volume, int repeats, zword eos)
 #ifdef SOUND_SUPPORT
        eos = eos;              /* not used in DOS Frotz */
 
-       os_stop_sample();
+       os_stop_sample(0);
 
        /* Exit if the sound board isn't set up properly */
        if (sample_data == NULL)
@@ -374,7 +374,7 @@ void os_start_sample(int number, int volume, int repeats, zword eos)
  * Turn off the current sample.
  *
  */
-void os_stop_sample(void)
+void os_stop_sample(int UNUSED(id))
 {
 #ifdef SOUND_SUPPORT
        play_part = 0;
@@ -397,11 +397,11 @@ void os_stop_sample(void)
  * Remove the current sample from memory (if any).
  *
  */
-void os_finish_with_sample(void)
+void os_finish_with_sample(int UNUSED(id))
 {
 #ifdef SOUND_SUPPORT
 
-       os_stop_sample();       /* we keep 64KB allocated all the time */
+       os_stop_sample(0);      /* we keep 64KB allocated all the time */
 
 #endif /* SOUND_SUPPORT */
 } /* os_finish_with_sample */
index 289f4d15518cad9ce33338edc7f265c73ebf7c4f..d56f6962497922fe3db67aaafe019d3858770a4b 100644 (file)
@@ -122,8 +122,8 @@ void load_fonts(void)
 int os_font_data(int font, int *height, int *width)
 {
        /* All fonts of this interface have the same size */
-       *height = h_font_height;
-       *width = h_font_width;
+       *height = z_header.font_height;
+       *width = z_header.font_width;
 
        /* Not every font is available in every mode */
        if (font == TEXT_FONT)
@@ -215,7 +215,7 @@ static void adjust_style(void)
           of window 0 have changed. DAC register #79 holds the foreground,
           DAC register #64 the background colour. */
 
-       if (display == _AMIGA_ && h_version == V6 && cwin == 0) {
+       if (display == _AMIGA_ && z_header.version == V6 && cwin == 0) {
                if (fg < 16 && fg != palette_fg) {
                        byte R = amiga_palette[fg - 2][0];
                        byte G = amiga_palette[fg - 2][1];
@@ -253,7 +253,7 @@ static void adjust_style(void)
        if (fg < 16) {
                if (display == _MONO_)
                        fg = (fg == WHITE_COLOUR) ? LIGHTGRAY : BLACK;
-               else if (h_version == V6 && display == _AMIGA_)
+               else if (z_header.version == V6 && display == _AMIGA_)
                        fg = (palette_fg == fg) ? 15 : 0;
                else
                        fg = pc_colour[fg - 2];
@@ -263,7 +263,7 @@ static void adjust_style(void)
        if (bg < 16) {
                if (display == _MONO_)
                        bg = (bg == WHITE_COLOUR) ? LIGHTGRAY : BLACK;
-               else if (h_version == V6 && display == _AMIGA_)
+               else if (z_header.version == V6 && display == _AMIGA_)
                        bg = (palette_bg == bg) ? 0 : 15;
                else
                        bg = pc_colour[bg - 2];
@@ -432,7 +432,7 @@ void write_pattern(byte far * screen, byte val, byte mask)
 
        /* Handle accented characters */
        if (c >= ZC_LATIN1_MIN
-           && (story_id != BEYOND_ZORK || (h_flags & GRAPHICS_FLAG)))
+           && (story_id != BEYOND_ZORK || (z_header.flags & GRAPHICS_FLAG)))
                if (display == _CGA_ || display == _MCGA_) {
                        char *ptr = latin1_to_ascii + 3 * (c - ZC_LATIN1_MIN);
 
@@ -528,9 +528,9 @@ void write_pattern(byte far * screen, byte val, byte mask)
                        align = 0;
                        type = 3;
                } else if (display >= _EGA_) {
-                       table = (byte far *) getvect(0x43) + h_font_height * c;
+                       table = (byte far *) getvect(0x43) + z_header.font_height * c;
                        mask = 0xff;
-                       underline = h_font_height - 1;
+                       underline = z_header.font_height - 1;
                        boldface = (user_bold_typing != -1) ? 1 : -1;
                        align = 0;
                        type = 3;
@@ -556,13 +556,13 @@ void write_pattern(byte far * screen, byte val, byte mask)
                        outport(0x03ce, 0xff08);
                }
 
-               for (i = 0; i < h_font_height; i++) {
+               for (i = 0; i < z_header.font_height; i++) {
                        byte far *screen = get_scrnptr(cursor_y + i) + offset;
 
                        if (type == 1) {
                                val =
                                    *((byte far *) table +
-                                     8 * i / h_font_height);
+                                     8 * i / z_header.font_height);
                        }
                        if (type == 2)
                                val = *((word far *) table + i);
@@ -628,7 +628,7 @@ int os_char_width(zchar c)
 {
        /* Handle accented characters */
        if (c >= ZC_LATIN1_MIN
-           && (story_id != BEYOND_ZORK || (h_flags & GRAPHICS_FLAG)))
+           && (story_id != BEYOND_ZORK || (z_header.flags & GRAPHICS_FLAG)))
                if (display == _CGA_ || display == _MCGA_) {
 
                        const char *ptr =
@@ -765,7 +765,7 @@ void os_more_prompt(void)
        os_read_key(0, TRUE);
 
        os_erase_area(cursor_y + 1,
-                     saved_x + 1, cursor_y + h_font_height, cursor_x + 1, -1);
+                     saved_x + 1, cursor_y + z_header.font_height, cursor_x + 1, -1);
 
        cursor_x = saved_x;