From adae1a59e2b6b9f9024dc55bfb099c73d6eff4e0 Mon Sep 17 00:00:00 2001 From: David Griffith Date: Sat, 18 May 2019 21:52:20 -0700 Subject: [PATCH] DOS port now compiles and works. Issues #8 and #58 need revisiting. Loading an executable in a Blorb file works, but very slowly. Audio and graphics support through Blorb are not yet attempted, though sometimes old-style works. For instance, in Sherlock, blowing the sound of a cab approaching is heard (blow the whistle on the first move). However, playing the violin after you go upstairs is not. --- Makefile.tc | 23 +++++++++++++++++------ src/common/frotz.h | 5 ++++- src/dos/bcblorb.c | 4 ++-- src/dos/bcinput.c | 17 +++++++++++++++-- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/Makefile.tc b/Makefile.tc index f674c65..785dea0 100644 --- a/Makefile.tc +++ b/Makefile.tc @@ -14,10 +14,11 @@ RENAME = ren BINNAME = frotz.exe LIBRARY = frotz.lib -SOUND_DEF = -DSOUND_SUPPORT -DOS_DEF = -DMSDOS_16BIT +VERSION = "2.45pre" -DEFS = $(SOUND_DEF) $(DOS_DEF) +VER = -DVERSION=$(VERSION) + +DEFS = src\common\defs.h DOS_DIR = src\dos DOS_OBJECTS = $(DOS_DIR)\bcinit.o \ @@ -53,15 +54,25 @@ CORE_OBJECTS = $(CORE_DIR)\buffer.o \ .SUFFIXES: .c .o .h +all: defs frotz + +defs: $(DEFS) +$(DEFS): + @echo "** Generating $@" + @echo "#ifndef COMMON_DEFINES_H" > $@ + @echo "#define COMMON_DEFINES_H" >> $@ + @echo "#define MSDOS_16BIT" >> $@ + @echo "#define SOUND_SUPPORT" >> $@ + @echo "#endif /* COMMON_DEFINES_H */" >> $@ + .c.o: - $(CC) $(CFLAGS) $(DEFS) -I$(DOS_DIR) -I$(CORE_DIR) -c -o$@ $< + $(CC) $(CFLAGS) $(VER) -I$(DOS_DIR) -I$(CORE_DIR) -c -o$@ $< $(TLIB) $(LIBRARY) +-$@ -all: frotz - clean: $(RM) $(CORE_DIR)\*.o $(RM) $(DOS_DIR)\*.o + $(RM) $(DEFS) $(RM) *.lib $(RM) *.exe $(RM) *.bak diff --git a/src/common/frotz.h b/src/common/frotz.h index 395816e..6c27d38 100644 --- a/src/common/frotz.h +++ b/src/common/frotz.h @@ -8,11 +8,15 @@ #ifndef FROTZ_H_ #define FROTZ_H_ +#include "defs.h" + /* Unfortunately, frotz's bool definition conflicts with that of curses. But since no os_* function uses it, it's safe to let the frotz core see this definition, but have the unix port see the curses version. */ +#ifndef MSDOS_16BIT #include "git_hash.h" +#endif #ifndef __UNIX_PORT_FILE #include @@ -125,7 +129,6 @@ typedef struct { #include "setup.h" -#include "defs.h" #include "missing.h" #include "unused.h" diff --git a/src/dos/bcblorb.c b/src/dos/bcblorb.c index 0d0578b..be56cdf 100644 --- a/src/dos/bcblorb.c +++ b/src/dos/bcblorb.c @@ -56,8 +56,8 @@ static bb_err_t bb_initialize() } test; uint32 val; - if (sizeof(uint32) != 4 || sizeof(uint16) != 2) - return bb_err_CompileTime; /* Basic types are the wrong size. */ +// if (sizeof(uint32) != 4 || sizeof(uint16) != 2) +// return bb_err_CompileTime; /* Basic types are the wrong size. */ test.ch[0] = 0x13; test.ch[1] = 0x57; diff --git a/src/dos/bcinput.c b/src/dos/bcinput.c index d4231c0..0a5843d 100644 --- a/src/dos/bcinput.c +++ b/src/dos/bcinput.c @@ -918,7 +918,7 @@ zchar os_read_key (int timeout, bool cursor) * */ -int os_read_file_name (char *file_name, const char *default_name, int flag) +char *os_read_file_name (const char *default_name, int flag) { char *extension; FILE *fp; @@ -930,6 +930,7 @@ int os_read_file_name (char *file_name, const char *default_name, int flag) int i; char *tempname; + char file_name[FILENAME_MAX + 1]; /* Turn off playback and recording temporarily */ @@ -1015,6 +1016,18 @@ finished: istream_replay = saved_replay; ostream_record = saved_record; - return result; + if (!result) return NULL; + + return strdup(file_name); }/* os_read_file_name */ + + +/* + * Called regularly by the interpreter, at least every few instructions + * (only when interpreting: e.g., not when waiting for input). + */ +void os_tick(void) +{ + /* do nothing */ +} -- 2.34.1