$(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
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); \
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)
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#include <string.h>
#include "frotz.h"
extern void stream_char (zchar);
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 *);
#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
/*** Story file header data ***/
-
extern zbyte h_version;
extern zbyte h_config;
extern zword h_release;
#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 ***/
/* 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 */
/*
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;
+*/
*/
#include "../common/frotz.h"
+#include "../blorb/blorb.h"
#include "ux_setup.h"
#define MASTER_CONFIG "frotz.conf"
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);
#include <unistd.h>
#include <ctype.h>
+#include <signal.h>
/* We will use our own private getopt functions. */
#include "getopt.h"
-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\
/*
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 */
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;
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;
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
*
/*
- * 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
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)
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;
/* 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);
{\r
\r
#ifdef SOUND_SUPPORT\r
- reset_sound ();\r
+ dos_reset_sound ();\r
#endif\r
reset_pictures ();\r
\r
}/* 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 ();
sound_adr = 0;
}
-}/* reset_sound */
+}/* dos_reset_sound */
#endif /* SOUND_SUPPORT */
#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