diff options
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/include/resource.h | 24 | ||||
-rw-r--r-- | engines/sci/scicore/tools.cpp | 43 | ||||
-rw-r--r-- | engines/sci/sfx/player/polled.cpp | 13 |
3 files changed, 28 insertions, 52 deletions
diff --git a/engines/sci/include/resource.h b/engines/sci/include/resource.h index bae718021b..ed9e420933 100644 --- a/engines/sci/include/resource.h +++ b/engines/sci/include/resource.h @@ -72,16 +72,6 @@ # include <fcntl.h> #endif -// FIXME: Get rid of G_DIR_SEPARATOR / G_DIR_SEPARATOR_S -#if _MSC_VER -# define G_DIR_SEPARATOR_S "\\" -# define G_DIR_SEPARATOR '\\' -#else -# define G_DIR_SEPARATOR_S "/" -# define G_DIR_SEPARATOR '/' -#endif - - #define GUINT16_SWAP_LE_BE_CONSTANT(val) ((((val) & 0x00ff) << 8) | (((val) & 0xff00) >> 8)) #define GUINT32_SWAP_LE_BE_CONSTANT(val) ( \ @@ -121,16 +111,13 @@ # define scimkdir(arg1,arg2) mkdir(arg1,arg2) #endif -#ifndef _GET_INT_16 -#define _GET_INT_16 - static inline gint16 getInt16(byte *d) { return (gint16)(*d | (d[1] << 8)); } #define getUInt16(d) (guint16)(getInt16(d)) -#endif + /* Turns a little endian 16 bit value into a machine-dependant 16 bit value ** Parameters: d: Pointer to the memory position from which to read ** Returns : (gint16) The (possibly converted) 16 bit value @@ -265,15 +252,6 @@ sci_file_size(const char *fname); ** Returns : (int) filesize of the file, -1 on error */ -char * -_fcaseseek(const char *fname, sci_dir_t *dir); -/* Returns the case-sensitive filename of a file. -** Expects *dir to be uninitialized and the caller to free it afterwards. -** Parameters: (const char *) fname: Name of file to get case-sensitive. -** (sci_dir_t *) dir: Directory to find file within. -** Returns : (char *) Case-sensitive filename of the file. -*/ - /* Simple heuristic to work around array handling peculiarity in SQ4: It uses StrAt() to read the individual elements, so we must determine whether a string is really a string or an array. */ diff --git a/engines/sci/scicore/tools.cpp b/engines/sci/scicore/tools.cpp index 981234fa6a..9b192cbf24 100644 --- a/engines/sci/scicore/tools.cpp +++ b/engines/sci/scicore/tools.cpp @@ -64,6 +64,17 @@ #include "sci/include/engine.h" + +// FIXME: Get rid of G_DIR_SEPARATOR / G_DIR_SEPARATOR_S +#if _MSC_VER +# define G_DIR_SEPARATOR_S "\\" +# define G_DIR_SEPARATOR '\\' +#else +# define G_DIR_SEPARATOR_S "/" +# define G_DIR_SEPARATOR '/' +#endif + + #ifdef HAVE_SYS_TIME_H # include <sys/time.h> #endif @@ -389,7 +400,6 @@ sci_mkpath(const char *path) { return 0; } - /*-- Yielding to the scheduler --*/ #ifdef HAVE_SCHED_YIELD @@ -423,13 +433,17 @@ sci_sched_yield() { #endif /* !HAVE_SCHED_YIELD */ -char * -_fcaseseek(const char *fname, sci_dir_t *dir) +/* Returns the case-sensitive filename of a file. +** Expects *dir to be uninitialized and the caller to free it afterwards. +** Parameters: (const char *) fname: Name of file to get case-sensitive. +** (sci_dir_t *) dir: Directory to find file within. +** Returns : (char *) Case-sensitive filename of the file. +*/ +char *_fcaseseek(const char *fname, sci_dir_t *dir) { /* Expects *dir to be uninitialized and the caller to ** free it afterwards */ -{ - char *buf, *iterator; - char _buf[14]; + + Common::String buf; char *retval = NULL, *name; #ifdef _MSC_VER @@ -441,23 +455,17 @@ _fcaseseek(const char *fname, sci_dir_t *dir) BREAKPOINT(); } - if (strlen(fname) > 12) /* not a DOS file? */ - buf = (char*)sci_malloc(strlen(fname) + 1); - else - buf = _buf; - sci_init_dir(dir); /* Replace all letters with '?' chars */ - strcpy(buf, fname); - iterator = buf; - while (*iterator) { + buf = fname; + + for (Common::String::iterator iterator = buf.begin(); iterator != buf.end(); ++iterator) { if (isalpha(*iterator)) *iterator = '?'; - iterator++; } - name = sci_find_first(dir, buf); + name = sci_find_first(dir, buf.c_str()); while (name && !retval) { if (!scumm_stricmp(fname, name)) @@ -466,9 +474,6 @@ _fcaseseek(const char *fname, sci_dir_t *dir) name = sci_find_next(dir); } - if (strlen(fname) > 12) - free(buf); - return retval; } diff --git a/engines/sci/sfx/player/polled.cpp b/engines/sci/sfx/player/polled.cpp index 7b32c8bee8..4eacb63d48 100644 --- a/engines/sci/sfx/player/polled.cpp +++ b/engines/sci/sfx/player/polled.cpp @@ -29,9 +29,7 @@ #include "sci/sfx/softseq.h" #include "sci/sfx/mixer.h" -#ifndef _MSC_VER -#include <unistd.h> // for close() -#endif +#include "common/file.h" static song_iterator_t *play_it; static int play_paused = 0; @@ -167,20 +165,15 @@ pp_set_option(char *name, char *value) { static int pp_init(resource_mgr_t *resmgr, int expected_latency) { resource_t *res = NULL, *res2 = NULL; - int fd; if (!mixer) return SFX_ERROR; /* FIXME Temporary hack to detect Amiga games. */ - fd = sci_open("bank.001", O_RDONLY); - - if (fd == SCI_INVALID_FD) + if (!Common::File::exists("bank.001")) seq = sfx_find_softseq(NULL); - else { - close(fd); + else seq = sfx_find_softseq("amiga"); - } if (!seq) { sciprintf("[sfx:seq:polled] Initialisation failed: Could not find software sequencer\n"); |