From 471f630c2e2da507cf4c0d52e55279e1d20177c1 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 17 Feb 2009 18:17:01 +0000 Subject: SCI: Moved sfx_pcm_urat_t from include/sfx_pcm.h to sfx/mixer.h svn-id: r38434 --- engines/sci/engine/vm.cpp | 3 +- engines/sci/include/gfx_res_options.h | 6 ---- engines/sci/include/sfx_pcm.h | 7 ----- engines/sci/scicore/resource_map.cpp | 54 ++++++++++++++++------------------- engines/sci/sfx/mixer.h | 10 ++++++- 5 files changed, 35 insertions(+), 45 deletions(-) (limited to 'engines') diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index c3cf243807..622fad8920 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -870,7 +870,8 @@ run_vm(state_t *s, int restoring) { } - + // TODO: Replace the following by an opcode table, and several methods for + // each opcode. switch (opnumber) { case 0x00: /* bnot */ diff --git a/engines/sci/include/gfx_res_options.h b/engines/sci/include/gfx_res_options.h index ee008e03dd..f22989437d 100644 --- a/engines/sci/include/gfx_res_options.h +++ b/engines/sci/include/gfx_res_options.h @@ -35,12 +35,6 @@ typedef struct _gfx_res_pattern { int min, max; } gfx_res_pattern_t; -typedef struct _gfx_res_pattern_list { - gfx_res_pattern_t pattern; - struct _gfx_res_pattern_list *next; -} gfx_res_pattern_list_t; - - /* GFX resource assignments */ typedef struct { diff --git a/engines/sci/include/sfx_pcm.h b/engines/sci/include/sfx_pcm.h index 02ebba7e99..f275fd3f03 100644 --- a/engines/sci/include/sfx_pcm.h +++ b/engines/sci/include/sfx_pcm.h @@ -63,13 +63,6 @@ #define SFX_PCM_FRAME_SIZE(conf) ((conf).stereo? 2 : 1) * (((conf).format & SFX_PCM_FORMAT_16)? 2 : 1) -typedef struct { - int nom, den; - int val; - - /* Total value: val + nom/den, where (nom < den) guaranteed. */ -} sfx_pcm_urat_t; /* Finitary unsigned rational numbers */ - typedef struct { int rate; /* Sampling rate */ int stereo; /* The stereo mode used (SFX_PCM_MONO or SFX_PCM_STEREO_*) */ diff --git a/engines/sci/scicore/resource_map.cpp b/engines/sci/scicore/resource_map.cpp index 7e033c05b2..c47d07a2f0 100644 --- a/engines/sci/scicore/resource_map.cpp +++ b/engines/sci/scicore/resource_map.cpp @@ -26,9 +26,9 @@ #include "sci/include/sci_memory.h" #include "sci/include/sciresource.h" #include "sci/include/resource.h" -#ifdef HAVE_UNISTD_H -# include -#endif + +#include "common/file.h" + #define RESOURCE_MAP_FILENAME "resource.map" @@ -37,13 +37,13 @@ #define SCI11_RESMAP_ENTRIES_SIZE 5 static int -detect_odd_sci01(int fh) { +detect_odd_sci01(Common::File &file) { byte buf[6]; int files_ok = 1; - int fsize, resources_nr, tempfh, read_ok; + int fsize, resources_nr, read_ok; char filename[14]; - fsize = sci_fd_size(fh); + fsize = file.size(); if (fsize < 0) { perror("Error occured while trying to get filesize of resource.map"); return SCI_ERROR_RESMAP_NOT_FOUND; @@ -52,22 +52,21 @@ detect_odd_sci01(int fh) { resources_nr = fsize / SCI0_RESMAP_ENTRIES_SIZE; while (resources_nr-- > 1) { - read_ok = read(fh, &buf, SCI0_RESMAP_ENTRIES_SIZE); + read_ok = file.read(&buf, SCI0_RESMAP_ENTRIES_SIZE); if (read_ok) { sprintf(filename, "resource.%03i", SCI0_RESFILE_GET_FILE(buf + 2)); - tempfh = sci_open(filename, O_RDONLY | O_BINARY); - - if (tempfh == SCI_INVALID_FD) { + Common::File temp; + + // FIXME: Maybe better to use File::exists here? + if (!temp.open(filename)) { files_ok = 0; break; } - - close(tempfh); } } - lseek(fh, 0, SEEK_SET); + file.seek(0, SEEK_SET); return files_ok; } @@ -148,10 +147,9 @@ int sci1_parse_header(int fd, int *types, int *lastrt) { -int -sci0_read_resource_map(resource_mgr_t *mgr, resource_source_t *map, resource_t **resource_p, int *resource_nr_p, int *sci_version) { +int sci0_read_resource_map(resource_mgr_t *mgr, resource_source_t *map, resource_t **resource_p, int *resource_nr_p, int *sci_version) { int fsize; - int fd; + Common::File file; resource_t *resources; int resources_nr; int resource_index = 0; @@ -160,12 +158,11 @@ sci0_read_resource_map(resource_mgr_t *mgr, resource_source_t *map, resource_t * int max_resfile_nr = 0; byte buf[SCI0_RESMAP_ENTRIES_SIZE]; - fd = sci_open(map->location.file.name, O_RDONLY | O_BINARY); - if (!IS_VALID_FD(fd)) + if (!file.open(map->location.file.name)) return SCI_ERROR_RESMAP_NOT_FOUND; - read(fd, &buf, 4); + file.read(&buf, 4); /* Theory: An SCI1 map file begins with an index that allows us to seek quickly to a particular resource type. The entries are three bytes long; one byte @@ -186,13 +183,12 @@ sci0_read_resource_map(resource_mgr_t *mgr, resource_source_t *map, resource_t * if ((buf[0] == 0x80) && (buf[1] % 3 == 0) && (buf[3] == 0x81)) { - close(fd); return SCI_ERROR_INVALID_RESMAP_ENTRY; } - lseek(fd, 0, SEEK_SET); + file.seek(0, SEEK_SET); - switch (detect_odd_sci01(fd)) { + switch (detect_odd_sci01(file)) { case 0 : /* Odd SCI01 */ if (*sci_version == SCI_VERSION_AUTODETECT) *sci_version = SCI_VERSION_01_VGA_ODD; @@ -205,7 +201,8 @@ sci0_read_resource_map(resource_mgr_t *mgr, resource_source_t *map, resource_t * return SCI_ERROR_RESMAP_NOT_FOUND; } - if ((fsize = sci_fd_size(fd)) < 0) { + fsize = file.size(); + if (fsize < 0) { perror("Error occured while trying to get filesize of resource.map"); return SCI_ERROR_RESMAP_NOT_FOUND; } @@ -216,7 +213,7 @@ sci0_read_resource_map(resource_mgr_t *mgr, resource_source_t *map, resource_t * /* Sets valid default values for most entries */ do { - int read_ok = read(fd, &buf, SCI0_RESMAP_ENTRIES_SIZE); + int read_ok = file.read(&buf, SCI0_RESMAP_ENTRIES_SIZE); next_entry = 1; if (read_ok < 0) { @@ -235,7 +232,6 @@ sci0_read_resource_map(resource_mgr_t *mgr, resource_source_t *map, resource_t * if (sci_res_read_entry(mgr, map, buf, resources + resource_index, *sci_version)) { free(resources); - close(fd); return SCI_ERROR_RESMAP_NOT_FOUND; } @@ -263,7 +259,7 @@ sci0_read_resource_map(resource_mgr_t *mgr, resource_source_t *map, resource_t * } while (next_entry); - close(fd); + file.close(); if (!resource_index) { sciprintf("resource.map was empty!\n"); @@ -280,14 +276,12 @@ sci0_read_resource_map(resource_mgr_t *mgr, resource_source_t *map, resource_t * /* Check whether the highest resfile used exists */ char filename_buf[14]; sprintf(filename_buf, "resource.%03d", max_resfile_nr); - fd = sci_open(filename_buf, O_RDONLY); - if (!IS_VALID_FD(fd)) { + if (!file.open(filename_buf) { _scir_free_resources(resources, resources_nr); sciprintf("'%s' requested by resource.map, but not found\n", filename_buf); return SCI_ERROR_INVALID_RESMAP_ENTRY; - } else - close(fd); + } #endif } diff --git a/engines/sci/sfx/mixer.h b/engines/sci/sfx/mixer.h index 69580d4767..2dbff557bc 100644 --- a/engines/sci/sfx/mixer.h +++ b/engines/sci/sfx/mixer.h @@ -32,6 +32,14 @@ #define SFX_PCM_FEED_MODE_ALIVE 0 #define SFX_PCM_FEED_MODE_DEAD 1 +/** Finitary unsigned rational numbers */ +struct sfx_pcm_urat_t { + int nom, den; + int val; + + /* Total value: val + nom/den, where (nom < den) guaranteed. */ +}; + struct twochannel_data { int left, right; }; @@ -49,7 +57,7 @@ typedef struct { int mode; /* Whether the feed is alive or pending destruction */ int pending_review; /* Timestamp needs to be checked for this stream */ - struct twochannel_data ch_old, ch_new; /* Intermediate results of output computation */ + twochannel_data ch_old, ch_new; /* Intermediate results of output computation */ } sfx_pcm_feed_state_t; -- cgit v1.2.3