Revert changed I accidentally commited *sigh*

svn-id: r38435
This commit is contained in:
Max Horn 2009-02-17 18:21:27 +00:00
parent 471f630c2e
commit e77e56bec1
3 changed files with 37 additions and 26 deletions

View file

@ -870,8 +870,7 @@ run_vm(state_t *s, int restoring) {
} }
// TODO: Replace the following by an opcode table, and several methods for
// each opcode.
switch (opnumber) { switch (opnumber) {
case 0x00: /* bnot */ case 0x00: /* bnot */

View file

@ -35,6 +35,12 @@ typedef struct _gfx_res_pattern {
int min, max; int min, max;
} gfx_res_pattern_t; } 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 */ /* GFX resource assignments */
typedef struct { typedef struct {

View file

@ -26,9 +26,9 @@
#include "sci/include/sci_memory.h" #include "sci/include/sci_memory.h"
#include "sci/include/sciresource.h" #include "sci/include/sciresource.h"
#include "sci/include/resource.h" #include "sci/include/resource.h"
#ifdef HAVE_UNISTD_H
#include "common/file.h" # include <unistd.h>
#endif
#define RESOURCE_MAP_FILENAME "resource.map" #define RESOURCE_MAP_FILENAME "resource.map"
@ -37,13 +37,13 @@
#define SCI11_RESMAP_ENTRIES_SIZE 5 #define SCI11_RESMAP_ENTRIES_SIZE 5
static int static int
detect_odd_sci01(Common::File &file) { detect_odd_sci01(int fh) {
byte buf[6]; byte buf[6];
int files_ok = 1; int files_ok = 1;
int fsize, resources_nr, read_ok; int fsize, resources_nr, tempfh, read_ok;
char filename[14]; char filename[14];
fsize = file.size(); fsize = sci_fd_size(fh);
if (fsize < 0) { if (fsize < 0) {
perror("Error occured while trying to get filesize of resource.map"); perror("Error occured while trying to get filesize of resource.map");
return SCI_ERROR_RESMAP_NOT_FOUND; return SCI_ERROR_RESMAP_NOT_FOUND;
@ -52,21 +52,22 @@ detect_odd_sci01(Common::File &file) {
resources_nr = fsize / SCI0_RESMAP_ENTRIES_SIZE; resources_nr = fsize / SCI0_RESMAP_ENTRIES_SIZE;
while (resources_nr-- > 1) { while (resources_nr-- > 1) {
read_ok = file.read(&buf, SCI0_RESMAP_ENTRIES_SIZE); read_ok = read(fh, &buf, SCI0_RESMAP_ENTRIES_SIZE);
if (read_ok) { if (read_ok) {
sprintf(filename, "resource.%03i", SCI0_RESFILE_GET_FILE(buf + 2)); sprintf(filename, "resource.%03i", SCI0_RESFILE_GET_FILE(buf + 2));
Common::File temp; tempfh = sci_open(filename, O_RDONLY | O_BINARY);
// FIXME: Maybe better to use File::exists here? if (tempfh == SCI_INVALID_FD) {
if (!temp.open(filename)) {
files_ok = 0; files_ok = 0;
break; break;
} }
close(tempfh);
} }
} }
file.seek(0, SEEK_SET); lseek(fh, 0, SEEK_SET);
return files_ok; return files_ok;
} }
@ -147,9 +148,10 @@ 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 fsize;
Common::File file; int fd;
resource_t *resources; resource_t *resources;
int resources_nr; int resources_nr;
int resource_index = 0; int resource_index = 0;
@ -158,11 +160,12 @@ int sci0_read_resource_map(resource_mgr_t *mgr, resource_source_t *map, resource
int max_resfile_nr = 0; int max_resfile_nr = 0;
byte buf[SCI0_RESMAP_ENTRIES_SIZE]; byte buf[SCI0_RESMAP_ENTRIES_SIZE];
fd = sci_open(map->location.file.name, O_RDONLY | O_BINARY);
if (!file.open(map->location.file.name)) if (!IS_VALID_FD(fd))
return SCI_ERROR_RESMAP_NOT_FOUND; return SCI_ERROR_RESMAP_NOT_FOUND;
file.read(&buf, 4); read(fd, &buf, 4);
/* Theory: An SCI1 map file begins with an index that allows us to seek quickly /* 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 to a particular resource type. The entries are three bytes long; one byte
@ -183,12 +186,13 @@ int sci0_read_resource_map(resource_mgr_t *mgr, resource_source_t *map, resource
if ((buf[0] == 0x80) && if ((buf[0] == 0x80) &&
(buf[1] % 3 == 0) && (buf[1] % 3 == 0) &&
(buf[3] == 0x81)) { (buf[3] == 0x81)) {
close(fd);
return SCI_ERROR_INVALID_RESMAP_ENTRY; return SCI_ERROR_INVALID_RESMAP_ENTRY;
} }
file.seek(0, SEEK_SET); lseek(fd, 0, SEEK_SET);
switch (detect_odd_sci01(file)) { switch (detect_odd_sci01(fd)) {
case 0 : /* Odd SCI01 */ case 0 : /* Odd SCI01 */
if (*sci_version == SCI_VERSION_AUTODETECT) if (*sci_version == SCI_VERSION_AUTODETECT)
*sci_version = SCI_VERSION_01_VGA_ODD; *sci_version = SCI_VERSION_01_VGA_ODD;
@ -201,8 +205,7 @@ int sci0_read_resource_map(resource_mgr_t *mgr, resource_source_t *map, resource
return SCI_ERROR_RESMAP_NOT_FOUND; return SCI_ERROR_RESMAP_NOT_FOUND;
} }
fsize = file.size(); if ((fsize = sci_fd_size(fd)) < 0) {
if (fsize < 0) {
perror("Error occured while trying to get filesize of resource.map"); perror("Error occured while trying to get filesize of resource.map");
return SCI_ERROR_RESMAP_NOT_FOUND; return SCI_ERROR_RESMAP_NOT_FOUND;
} }
@ -213,7 +216,7 @@ int sci0_read_resource_map(resource_mgr_t *mgr, resource_source_t *map, resource
/* Sets valid default values for most entries */ /* Sets valid default values for most entries */
do { do {
int read_ok = file.read(&buf, SCI0_RESMAP_ENTRIES_SIZE); int read_ok = read(fd, &buf, SCI0_RESMAP_ENTRIES_SIZE);
next_entry = 1; next_entry = 1;
if (read_ok < 0) { if (read_ok < 0) {
@ -232,6 +235,7 @@ int sci0_read_resource_map(resource_mgr_t *mgr, resource_source_t *map, resource
if (sci_res_read_entry(mgr, map, buf, resources + resource_index, *sci_version)) { if (sci_res_read_entry(mgr, map, buf, resources + resource_index, *sci_version)) {
free(resources); free(resources);
close(fd);
return SCI_ERROR_RESMAP_NOT_FOUND; return SCI_ERROR_RESMAP_NOT_FOUND;
} }
@ -259,7 +263,7 @@ int sci0_read_resource_map(resource_mgr_t *mgr, resource_source_t *map, resource
} while (next_entry); } while (next_entry);
file.close(); close(fd);
if (!resource_index) { if (!resource_index) {
sciprintf("resource.map was empty!\n"); sciprintf("resource.map was empty!\n");
@ -276,12 +280,14 @@ int sci0_read_resource_map(resource_mgr_t *mgr, resource_source_t *map, resource
/* Check whether the highest resfile used exists */ /* Check whether the highest resfile used exists */
char filename_buf[14]; char filename_buf[14];
sprintf(filename_buf, "resource.%03d", max_resfile_nr); sprintf(filename_buf, "resource.%03d", max_resfile_nr);
fd = sci_open(filename_buf, O_RDONLY);
if (!file.open(filename_buf) { if (!IS_VALID_FD(fd)) {
_scir_free_resources(resources, resources_nr); _scir_free_resources(resources, resources_nr);
sciprintf("'%s' requested by resource.map, but not found\n", filename_buf); sciprintf("'%s' requested by resource.map, but not found\n", filename_buf);
return SCI_ERROR_INVALID_RESMAP_ENTRY; return SCI_ERROR_INVALID_RESMAP_ENTRY;
} } else
close(fd);
#endif #endif
} }