From: David Griffith Date: Tue, 10 Jan 2012 09:58:15 +0000 (-0800) Subject: Begining re-adding 2.44 code (this time cleanly for DOS) X-Git-Url: https://scope-eye.net/git/?a=commitdiff_plain;h=61b4a83db5ac66bbe847d2be9947b556da9666c0;p=liskon_frotz.git Begining re-adding 2.44 code (this time cleanly for DOS) --- diff --git a/Makefile b/Makefile index 64b4d96..28e871c 100644 --- a/Makefile +++ b/Makefile @@ -150,29 +150,56 @@ DUMB_OBJECT = $(DUMB_DIR)/dumb_init.o \ $(DUMB_DIR)/dumb_output.o \ $(DUMB_DIR)/dumb_pic.o -TARGETS = $(COMMON_TARGET) $(CURSES_TARGET) +SDL_DIR = $(SRCDIR)/sdl +SDL_TARGET = $(SRCDIR)/frotz_sdl.a +SDL_OBJECT = $(SDL_DIR)/sf_aiffwav.o \ + $(SDL_DIR)/sf_deffont.o \ + $(SDL_DIR)/sf_font3.o \ + $(SDL_DIR)/sf_fonts.o \ + $(SDL_DIR)/sf_ftype.o \ + $(SDL_DIR)/sf_images.o \ + $(SDL_DIR)/sf_msg_en.o \ + $(SDL_DIR)/sf_osfdlg.o \ + $(SDL_DIR)/sf_resample.o \ + $(SDL_DIR)/sf_resource.o \ + $(SDL_DIR)/sf_sig.o \ + $(SDL_DIR)/sf_sound.o \ + $(SDL_DIR)/sf_util.o \ + $(SDL_DIR)/sf_video.o + +# Blorb file handling +# +BLORB_DIR = $(SRCDIR)/blorb +BLORB_TARGET = $(SRCDIR)/blorblib.a +BLORB_OBJECT = $(BLORB_DIR)/blorblib.o + + +TARGETS = $(COMMON_TARGET) $(CURSES_TARGET) $(BLORB_TARGET) OPT_DEFS = -DCONFIG_DIR="\"$(CONFIG_DIR)\"" $(CURSES_DEF) \ - -DVERSION="\"$(VERSION)\"" -DSOUND_DEV="\"$(SOUND_DEV)\"" + -DVERSION="\"$(VERSION)\"" -COMP_DEFS = $(OPT_DEFS) $(COLOR_DEFS) $(SOUND_DEFS) $(SOUNDCARD) \ +CURSES_DEFS = $(OPT_DEFS) $(COLOR_DEFS) $(SOUND_DEFS) $(SOUNDCARD) \ $(MEMMOVE_DEF) -FLAGS = $(OPTS) $(COMP_DEFS) $(INCL) +FLAGS = $(OPTS) $(CURSES_DEFS) $(INCL) $(NAME): $(NAME)-curses - -$(NAME)-curses: soundcard.h $(COMMON_TARGET) $(CURSES_TARGET) - $(CC) -o $(BINNAME)$(EXTENSION) $(TARGETS) $(LIB) $(CURSES) \ - $(SOUND_LIB) +curses: $(NAME)-curses +$(NAME)-curses: soundcard.h $(COMMON_TARGET) $(CURSES_TARGET) $(BLORB_TARGET) + $(CC) -o $(BINNAME)$(EXTENSION) $(TARGETS) $(LIB) $(CURSES) $(SOUND_LIB) all: $(NAME) d$(NAME) dumb: $(NAME)-dumb d$(NAME): $(NAME)-dumb $(NAME)-dumb: $(COMMON_TARGET) $(DUMB_TARGET) - $(CC) -o d$(BINNAME)$(EXTENSION) $(COMMON_TARGET) \ - $(DUMB_TARGET) $(LIB) + $(CC) -o d$(BINNAME)$(EXTENSION) $(COMMON_TARGET) $(DUMB_TARGET) $(LIB) + +sdl: $(NAME)-sdl +s$(NAME): $(NAME)-sdl +$(NAME)-sdl: $(COMMON_TARGET) $(SDL_TARGET) + $(CC) -o s$(BINNAME) $(COMMON_TARGET) $(SDL_TARGET) $(SDL_LIBS) .SUFFIXES: .SUFFIXES: .c .o .h @@ -207,6 +234,23 @@ $(DUMB_TARGET): $(DUMB_OBJECT) ranlib $(DUMB_TARGET) @echo +sdl_lib: $(SDL_TARGET) +$(SDL_TARGET): $(SDL_OBJECT) + @echo + @echo "Archiving SDL interface code..." + ar rc $(SDL_TARGET) $(SDL_OBJECT) + ranlib $(SDL_TARGET) + @echo + +blorb_lib: $(BLORB_TARGET) +$(BLORB_TARGET): $(BLORB_OBJECT) + @echo + @echo "Archiving Blorb file handling code..." + ar rc $(BLORB_TARGET) $(BLORB_OBJECT) + ranlib $(BLORB_TARGET) + @echo + + soundcard.h: @if [ ! -f $(SRCDIR)/soundcard.h ] ; then \ sh $(SRCDIR)/misc/findsound.sh $(SRCDIR); \ @@ -257,10 +301,10 @@ dist: distclean clean: rm -f $(SRCDIR)/*.h $(SRCDIR)/*.a - rm -f $(COMMON_DIR)/*.o $(CURSES_DIR)/*.o $(DUMB_DIR)/*.o + rm -f $(COMMON_DIR)/*.o $(CURSES_DIR)/*.o $(DUMB_DIR)/*.o $(BLORB_DIR)/*.o $(SDL_DIR)/*.o distclean: clean - rm -f $(BINNAME)$(EXTENSION) d$(BINNAME)$(EXTENSION) + rm -f $(BINNAME)$(EXTENSION) d$(BINNAME)$(EXTENSION) s$(BINNAME) rm -f $(BINNAME).exe $(BINNAME).bak $(BINNAME).lib rm -f *core $(SRCDIR)/*core -rm -rf $(distdir) diff --git a/src/blorb/blorblib.o b/src/blorb/blorblib.o deleted file mode 100644 index 4dfc2c9..0000000 Binary files a/src/blorb/blorblib.o and /dev/null differ diff --git a/src/common/buffer.c b/src/common/buffer.c index 5800a6b..1feb98b 100644 --- a/src/common/buffer.c +++ b/src/common/buffer.c @@ -18,6 +18,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include #include "frotz.h" extern void stream_char (zchar); diff --git a/src/common/fastmem.c b/src/common/fastmem.c index 12ab84b..694c421 100644 --- a/src/common/fastmem.c +++ b/src/common/fastmem.c @@ -58,6 +58,7 @@ extern void script_open (void); extern void script_close (void); extern FILE *os_path_open (const char *, const char *); +extern FILE *os_load_story (void); extern zword save_quetzal (FILE *, FILE *); extern zword restore_quetzal (FILE *, FILE *); diff --git a/src/common/frotz.h b/src/common/frotz.h index debcbe4..a1c1a41 100644 --- a/src/common/frotz.h +++ b/src/common/frotz.h @@ -65,6 +65,14 @@ typedef unsigned char zchar; #define STACK_SIZE 1024 #endif +/* Assorted filename extensions */ + +#define EXT_SAVE ".qzl" +#define EXT_SCRIPT ".scr" +#define EXT_BLORB ".blb" +#define EXT_COMMAND ".rec" +#define EXT_AUX ".aux" + #ifndef DEFAULT_SAVE_NAME #define DEFAULT_SAVE_NAME "story.sav" #endif @@ -371,7 +379,6 @@ extern zbyte *zmp; /*** Story file header data ***/ - extern zbyte h_version; extern zbyte h_config; extern zword h_release; @@ -631,6 +638,10 @@ void runtime_error (int); #define ERR_DEFAULT_REPORT_MODE ERR_REPORT_ONCE +/*** Assorted initialization functions ***/ +void init_buffer (void); +void init_process (void); +void init_sound (void); /*** Various global functions ***/ diff --git a/src/common/input.c b/src/common/input.c index 370d554..ae65d03 100644 --- a/src/common/input.c +++ b/src/common/input.c @@ -294,8 +294,14 @@ void z_read_char (void) /* Store key */ - store (translate_to_zscii (key)); - + /* For timeouts, make sure translate_to_zscii() won't try to convert + * 0x00. We should instead return 0x00 as is. + * Thanks to Peter Seebach. + */ + if (key == 0) + store(key); + else + store (translate_to_zscii (key)); }/* z_read_char */ /* diff --git a/src/common/setup.h b/src/common/setup.h index a9b9360..28e0d25 100644 --- a/src/common/setup.h +++ b/src/common/setup.h @@ -24,44 +24,47 @@ typedef struct frotz_setup_struct { extern f_setup_t f_setup; - +/*** Story file header data ***/ +/* typedef struct zcode_header_struct { - zbyte h_version; - zbyte h_config; - zword h_release; - zword h_resident_size; - zword h_start_pc; - zword h_dictionary; - zword h_objects; - zword h_globals; - zword h_dynamic_size; - zword h_flags; - zbyte h_serial[6]; - zword h_abbreviations; - zword h_file_size; - zword h_checksum; - zbyte h_interpreter_number; - zbyte h_interpreter_version; - zbyte h_screen_rows; - zbyte h_screen_cols; - zword h_screen_width; - zword h_screen_height; - zbyte h_font_height; - zbyte h_font_width; - zword h_functions_offset; - zword h_strings_offset; - zbyte h_default_background; - zbyte h_default_foreground; - zword h_terminating_keys; - zword h_line_width; - zbyte h_standard_high; - zbyte h_standard_low; - zword h_alphabet; - zword h_extension_table; - zbyte h_user_name[8]; + zbyte version; + zbyte config; + zword release; + zword resident_size; + zword start_pc; + zword dictionary; + zword objects; + zword globals; + zword dynamic_size; + zword flags; + zbyte serial[6]; + zword abbreviations; + zword file_size; + zword checksum; + zbyte interpreter_number; + zbyte interpreter_version; + zbyte screen_rows; + zbyte screen_cols; + zword screen_width; + zword screen_height; + zbyte font_height; + zbyte font_width; + zword functions_offset; + zword strings_offset; + zbyte default_background; + zbyte default_foreground; + zword terminating_keys; + zword line_width; + zbyte standard_high; + zbyte standard_low; + zword alphabet; + zword extension_table; + zbyte user_name[8]; zword hx_table_size; zword hx_mouse_x; zword hx_mouse_y; zword hx_unicode_table; } z_header_t; +extern z_header_t z_header; +*/ diff --git a/src/curses/ux_frotz.h b/src/curses/ux_frotz.h index f055b73..19855eb 100644 --- a/src/curses/ux_frotz.h +++ b/src/curses/ux_frotz.h @@ -6,6 +6,7 @@ */ #include "../common/frotz.h" +#include "../blorb/blorb.h" #include "ux_setup.h" #define MASTER_CONFIG "frotz.conf" @@ -78,15 +79,29 @@ extern f_setup_t f_setup; extern u_setup_t u_setup; +/*** Blorb related stuff ***/ +bb_err_t blorb_err; +bb_map_t *blorb_map; +bb_result_t blorb_res; + + /*** Functions specific to the Unix port of Frotz ***/ -bool unix_init_pictures(void); /* ux_pic */ +bool unix_init_pictures(void); /* ux_pic.c */ +bool unix_init_pictures(void); /* ux_pic.c */ +void unix_init_scrollback(void); /* ux_screen.c */ +void unix_save_screen(int); /* ux_screen.c */ +void unix_do_scrollback(void); /* ux_screen.c */ + + + int getconfig(char *); int geterrmode(char *); int getcolor(char *); int getbool(char *); FILE *pathopen(const char *, const char *, const char *, char *); -void sig_winch_handler(int); +void sigwinch_handler(int); +void sigint_handler(int); void redraw(void); diff --git a/src/curses/ux_init.c b/src/curses/ux_init.c index 9f5b12f..95cd6f7 100644 --- a/src/curses/ux_init.c +++ b/src/curses/ux_init.c @@ -30,6 +30,7 @@ #include #include +#include /* We will use our own private getopt functions. */ #include "getopt.h" @@ -55,9 +56,9 @@ Syntax: frotz [options] story-file\n\ -a watch attribute setting \t -O watch object locating\n\ -A watch attribute testing \t -p plain ASCII output only\n\ -b # background color \t -P alter piracy opcode\n\ - -c # context lines \t -r # right margin\n\ - -d disable color \t -q quiet (disable sound effects)\n\ - -e enable sound \t -Q use old-style save format\n\ + -c # context lines \t -q quiet (disable sound effects)\n\ + -d disable color \t -Q use old-style save format\n\ + -e enable sound \t -r # right margin\n\ -f # foreground color \t -s # random number seed value\n\ -F Force color mode \t -S # transscript width\n\ -h # screen height \t -t set Tandy bit\n\ @@ -161,9 +162,12 @@ void os_process_arguments (int argc, char *argv[]) /* if (signal(SIGWINCH, SIG_IGN) != SIG_IGN) - signal(SIGWINCH, sig_winch_handler); + signal(SIGWINCH, sigwinch_handler); */ + if (signal(SIGINT, SIG_IGN) != SIG_IGN) + signal(SIGINT, sigint_handler); + /* First check for a "$HOME/.frotzrc". */ /* If not found, look for CONFIG_DIR/frotz.conf */ /* $HOME/.frotzrc overrides CONFIG_DIR/frotz.conf */ @@ -188,6 +192,8 @@ void os_process_arguments (int argc, char *argv[]) case 'A': f_setup.attribute_testing = 1; break; case 'b': u_setup.background_color = atoi(optarg); + u_setup.force_color = 1; + u_setup.disable_color = 0; if ((u_setup.background_color < 2) || (u_setup.background_color > 9)) u_setup.background_color = -1; @@ -195,11 +201,15 @@ void os_process_arguments (int argc, char *argv[]) case 'c': f_setup.context_lines = atoi(optarg); break; case 'd': u_setup.disable_color = 1; break; case 'e': f_setup.sound = 1; break; - case 'f': u_setup.foreground_color = atoi(optarg); + case 'f': u_setup.foreground_color = getcolor(optarg); + u_setup.force_color = 1; + u_setup.disable_color = 0; if ((u_setup.foreground_color < 2) || (u_setup.foreground_color > 9)) - u_setup.foreground_color = -1; + u_setup.foreground_color = -1; break; + + case 'F': u_setup.force_color = 1; u_setup.disable_color = 0; break; @@ -529,6 +539,33 @@ FILE *os_path_open(const char *name, const char *mode) return NULL; /* give up */ } /* os_path_open() */ +/* + * os_load_story + * + * This is different from os_path_open() because we need to see if the + * story file is actually a chunk inside a blorb file. Right now we're + * looking only at the exact path we're given on the command line. + * + * Open a file in the current directory. If this fails, then search the + * directories in the ZCODE_PATH environmental variable. If that's not + * defined, search INFOCOM_PATH. + * + */ +FILE *os_load_story(void) +{ + FILE *fp; + + /* Did we build a valid blorb map? */ + if (u_setup.exec_in_blorb) { + fp = fopen(u_setup.blorb_file, "rb"); + fseek(fp, blorb_res.data.startpos, SEEK_SET); + } else { + fp = fopen(story_name, "rb"); + } + return fp; +} + + /* * pathopen * @@ -826,14 +863,14 @@ int geterrmode(char *value) /* - * sig_winch_handler + * sigwinch_handler * * Called whenever Frotz recieves a SIGWINCH signal to make curses * cleanly resize the window. * */ -void sig_winch_handler(int sig) +void sigwinch_handler(int sig) { /* There are some significant problems involved in getting resizes to work @@ -843,13 +880,22 @@ explaination for this. Because of this trouble, this function currently does nothing. */ +} + /* - signal(sig, SIG_DFL); - signal(sig, SIG_IGN); + * sigint_handler + * Sometimes the screen will be left in a weird state if the following + * is not done. + * + */ +void sigint_handler(int dummy) +{ + signal(SIGINT, sigint_handler); + scrollok(stdscr, TRUE); scroll(stdscr); + refresh(); endwin(); - signal(SIGWINCH, sig_winch_handler); -*/ + exit(1); } void redraw(void) diff --git a/src/curses/ux_setup.h b/src/curses/ux_setup.h index 1a16770..a332919 100644 --- a/src/curses/ux_setup.h +++ b/src/curses/ux_setup.h @@ -13,6 +13,11 @@ typedef struct unix_setup_struct { int current_color; /* ux_text.c ux_screen.c */ bool color_enabled; /* ux_init.c ux_pic.c ux_text.c */ + char *blorb_name; + char *blorb_file; + bool use_blorb; + bool exec_in_blorb; + int interpreter; /* see frotz.h */ } u_setup_t; diff --git a/src/dos/bcfrotz.h b/src/dos/bcfrotz.h index fe5f00e..26c642c 100644 --- a/src/dos/bcfrotz.h +++ b/src/dos/bcfrotz.h @@ -92,8 +92,8 @@ extern volatile int end_of_sound_flag; /* BCpic */ void reset_pictures (void); #ifdef SOUND_SUPPORT -/* BCsmpl */ bool init_sound (void); -/* BCsmpl */ void reset_sound (void); +/* BCsmpl */ bool dos_init_sound (void); +/* BCsmpl */ void dos_reset_sound (void); #endif /* BCtext */ void switch_scrn_attr (bool); /* BCtext */ void load_fonts (void); diff --git a/src/dos/bcinit.c b/src/dos/bcinit.c index 817708f..8136ba3 100644 --- a/src/dos/bcinit.c +++ b/src/dos/bcinit.c @@ -169,7 +169,7 @@ static void cleanup (void) { #ifdef SOUND_SUPPORT - reset_sound (); + dos_reset_sound (); #endif reset_pictures (); diff --git a/src/dos/bcsample.c b/src/dos/bcsample.c index fd1c44f..33c41a4 100644 --- a/src/dos/bcsample.c +++ b/src/dos/bcsample.c @@ -198,13 +198,13 @@ bool dos_init_sound (void) }/* init_sound */ /* - * reset_sound + * dos_reset_sound * * Free resources allocated for playing samples. * */ -void reset_sound (void) +void dos_reset_sound (void) { os_stop_sample (); @@ -218,7 +218,7 @@ void reset_sound (void) sound_adr = 0; } -}/* reset_sound */ +}/* dos_reset_sound */ #endif /* SOUND_SUPPORT */ diff --git a/src/sdl/sf_frotz.h b/src/sdl/sf_frotz.h index d1b9d71..393d697 100644 --- a/src/sdl/sf_frotz.h +++ b/src/sdl/sf_frotz.h @@ -1,8 +1,8 @@ #ifndef _SF_FROTZ_H #define _SF_FROTZ_H -#include "frotz.h" -#include "blorb.h" +#include "../common/frotz.h" +#include "../blorb/blorb.h" // version info #define SFROTZ_MAJOR 0