biiig checkin: removed more stuff from scumm.h; added new headers resource.h and object.h

svn-id: r4579
This commit is contained in:
Max Horn 2002-07-16 21:03:14 +00:00
parent 32e81beb45
commit 0843a2510c
21 changed files with 267 additions and 206 deletions

View file

@ -25,6 +25,7 @@
#include "actor.h"
#include "akos.h"
#include "costume.h"
#include "resource.h"
#include <math.h>

View file

@ -68,7 +68,7 @@ private:
int nkeys;
};
hashconfig::hashconfig (const char *dom):domain(dom ? Scumm::Strdup(dom) : 0),
hashconfig::hashconfig (const char *dom):domain(dom ? strdup(dom) : 0),
keys(0), values(0), nkeys(0)
{
}
@ -102,15 +102,15 @@ const char *hashconfig::set(const char *key, const char *value)
for (i = 0; i < nkeys; i++) {
if (!strcmp(key, keys[i])) {
xfree(values[i]);
return values[i] = value ? Scumm::Strdup(value) : 0;
return values[i] = value ? strdup(value) : 0;
}
}
nkeys++;
keys = (char **)realloc(keys, nkeys * sizeof(char *));
values = (char **)realloc(values, nkeys * sizeof(char *));
keys[nkeys - 1] = Scumm::Strdup(key);
return values[nkeys - 1] = value ? Scumm::Strdup(value) : 0;
keys[nkeys - 1] = strdup(key);
return values[nkeys - 1] = value ? strdup(value) : 0;
}
const char *hashconfig::getdomain() const
@ -138,7 +138,7 @@ void hashconfig::flush(FILE *cfg_file) const
void hashconfig::rename(const char *d)
{
xfree(domain);
domain = d ? Scumm::Strdup(d) : 0;
domain = d ? strdup(d) : 0;
}
void hashconfig::merge(const hashconfig *h)
@ -153,7 +153,7 @@ void hashconfig::merge(const hashconfig *h)
// The config-class itself.
Config::Config (const char *cfg, const char *d)
: filename(Scumm::Strdup(cfg)), domain(d ? Scumm::Strdup(d) : 0), hash(0), ndomains(0), willwrite(false)
: filename(strdup(cfg)), domain(d ? strdup(d) : 0), hash(0), ndomains(0), willwrite(false)
{
FILE *cfg_file;
char t[MAXLINELEN];
@ -279,7 +279,7 @@ void Config::set_domain(const char *d)
{
int i;
xfree(domain);
domain = d ? Scumm::Strdup(d) : 0;
domain = d ? strdup(d) : 0;
for (i = 0; i < ndomains; i++) {
if (hash[i]->is_domain(domain))
@ -346,7 +346,7 @@ void Config::delete_domain(const char *d)
void Config::change_filename(const char *f)
{
xfree(filename);
filename = f ? Scumm::Strdup(f) : 0;
filename = f ? strdup(f) : 0;
}
void Config::merge_config(const Config *c)

View file

@ -102,7 +102,7 @@ bool ScummDebugger::do_command()
printf("Current room: %d [%d]\n", _s->_currentRoom, _s->_roomResource);
} else {
int room = atoi(_parameters);
_s->actor[_s->_vars[_s->VAR_EGO]].room = room;
_s->_actors[_s->_vars[_s->VAR_EGO]].room = room;
_s->startScene(room, 0, 0);
_s->_fullRedraw = 1;
}
@ -286,7 +286,7 @@ void ScummDebugger::printActors(int act)
printf("+--+----+--------+----+---+-----+---+---+--+-----+-----+---+---+\n");
for (i = 1; i < _s->NUM_ACTORS; i++) {
if (act == -1 || act == i) {
a = &_s->actor[i];
a = &_s->_actors[i];
if (a->visible)
printf("|%2d|%4d|%3d %3d|%4d|%3d|%5d|%3d|%3d|%2d|%5d|%5d|%3d|%3d|\n",
i, a->room, a->x, a->y, a->elevation, a->costume, a->width,

View file

@ -109,7 +109,7 @@ void GameDetector::updateconfig()
_noSubtitles = false;
if ((val = scummcfg->get("path")))
_gameDataPath = Scumm::Strdup(val);
_gameDataPath = strdup(val);
if ((val = scummcfg->get("sfx_volume")))
_sfx_volume = atoi(val);
@ -459,9 +459,9 @@ char *GameDetector::getGameName()
if (_gameText == NULL) {
char buf[256];
sprintf(buf, "Unknown game: \"%s\"", _exe_name);
return Scumm::Strdup(buf);
return strdup(buf);
}
return Scumm::Strdup(_gameText);
return strdup(_gameText);
}
int GameDetector::detectMain(int argc, char **argv)
@ -541,7 +541,7 @@ int GameDetector::detectMain(int argc, char **argv)
if (!_gameDataPath) {
warning("No path was provided. Assuming the data files are in the current directory");
_gameDataPath = Scumm::Strdup("");
_gameDataPath = strdup("");
} else if (_gameDataPath[strlen(_gameDataPath)-1] != '/'
#ifdef __MORPHOS__
&& _gameDataPath[strlen(_gameDataPath)-1] != ':'

View file

@ -21,8 +21,9 @@
#include "stdafx.h"
#include "scumm.h"
#include "gui.h"
#include "actor.h"
#include "gui.h"
#include "resource.h"
void Scumm::getGraphicsPerformance()
{

View file

@ -30,6 +30,6 @@ Scumm::Scumm (void) {
}
Scumm::~Scumm (void) {
delete [] actor;
delete [] _actors;
delete _newgui;
}

View file

@ -23,9 +23,9 @@
#define NEED_SDL_HEADERS
#endif
#include "stdafx.h"
#include "scumm.h"
#include "smush.h"
//#define SWAP2(a) ((((a)>>24)&0xFF) | (((a)>>8)&0xFF00) | (((a)<<8)&0xFF0000) | (((a)<<24)&0xFF000000))
#define MAX_STREAMER 10

View file

@ -23,6 +23,8 @@
#include "stdafx.h"
#include "scumm.h"
#include "actor.h"
#include "object.h"
#include "resource.h"
bool Scumm::getClass(int obj, int cls)
{
@ -807,7 +809,7 @@ void Scumm::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, uint
if (findWhat & foCheckAlreadyLoaded && getObjectIndex(id) != -1) {
fo->obcd = obcdptr = getOBCDFromObject(id);
assert((byte *)obcdptr > (byte *)256);
fo->obim = obimptr = obcdptr + READ_BE_UINT32_UNALIGNED(&((ResHdr *)obcdptr)->size);
fo->obim = obimptr = obcdptr + RES_SIZE(obcdptr);
fo->cdhd = (CodeHeader *)findResourceData(MKID('CDHD'), obcdptr);
fo->imhd = (ImageHeader *)findResourceData(MKID('IMHD'), obimptr);
return;

122
object.h Normal file
View file

@ -0,0 +1,122 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2002 The ScummVM project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header$
*/
#ifndef OBJECT_H
#define OBJECT_H
#if !defined(__GNUC__)
#pragma START_PACK_STRUCTS
#endif
struct RoomHeader {
union {
struct {
uint32 version;
uint16 width, height;
uint16 numObjects;
} GCC_PACK v7;
struct {
uint16 width, height;
uint16 numObjects;
} GCC_PACK old;
} GCC_PACK;
} GCC_PACK;
struct CodeHeader {
union {
struct {
uint16 obj_id;
byte x, y, w, h;
byte flags;
byte parent;
int16 walk_x;
int16 walk_y;
byte actordir;
} GCC_PACK v5;
struct {
uint16 obj_id;
int16 x, y;
uint16 w, h;
byte flags, parent;
uint16 unk1;
uint16 unk2;
byte actordir;
} GCC_PACK v6;
struct {
uint32 version;
uint16 obj_id;
byte parent;
byte parentstate;
} GCC_PACK v7;
} GCC_PACK;
} GCC_PACK;
struct ImageHeader { /* file format */
union {
struct {
uint16 obj_id;
uint16 unk[5];
uint16 width;
uint16 height;
uint16 unk_2;
struct {
int16 x, y;
} GCC_PACK hotspot[15];
} GCC_PACK old;
struct {
uint32 version;
uint16 obj_id;
uint16 unk[1];
int16 x_pos, y_pos;
uint16 width, height;
byte unk2[3];
byte actordir;
uint16 unk_2;
struct {
int16 x, y;
} GCC_PACK hotspot[15];
} GCC_PACK v7;
} GCC_PACK;
} GCC_PACK;
#if !defined(__GNUC__)
#pragma END_PACK_STRUCTS
#endif
struct FindObjectInRoom {
CodeHeader *cdhd;
byte *obcd;
ImageHeader *imhd;
byte *obim;
byte *roomptr;
};
enum FindObjectWhat {
foCodeHeader = 1,
foImageHeader = 2,
foCheckAlreadyLoaded = 4
};
#endif

View file

@ -482,7 +482,7 @@ An example config file is as follows:
[scummvm]
gfx_mode=supereagle
fullscreen=true
savepath=C:\saves\
savepath=C:\saves\
[tentacle]
path=C:\tentacle\

View file

@ -22,8 +22,14 @@
#include "stdafx.h"
#include "scumm.h"
#include "resource.h"
#include <stdio.h>
uint16 newTag2Old(uint32 oldTag);
/* Open a room */
void Scumm::openRoom(int room)
{

58
resource.h Normal file
View file

@ -0,0 +1,58 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2002 The ScummVM project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header$
*/
#ifndef RESOURCE_H
#define RESOURCE_H
#if !defined(__GNUC__)
#pragma START_PACK_STRUCTS
#endif
struct ResHdr {
uint32 tag, size;
} GCC_PACK;
#if !defined(__GNUC__)
#pragma END_PACK_STRUCTS
#endif
#define RES_DATA(x) (((byte*)x) + sizeof(ResHdr))
#define RES_SIZE(x) (READ_BE_UINT32_UNALIGNED(&((ResHdr* )x)->size))
enum {
OF_OWNER_MASK = 0x0F,
OF_STATE_MASK = 0xF0,
OF_STATE_SHL = 4
};
enum {
RF_LOCK = 0x80,
RF_USAGE = 0x7F,
RF_USAGE_MAX = RF_USAGE
};
byte *findResource(uint32 tag, byte *searchin, int index);
byte *findResourceSmall(uint32 tag, byte *searchin, int index);
byte *findResource(uint32 tag, byte *searchin);
byte *findResourceSmall(uint32 tag, byte *searchin);
#endif

View file

@ -26,6 +26,7 @@
#include "sound/imuse.h"
#include "actor.h"
#include "config-file.h"
#include "resource.h"
#include "saveload.h"
struct SaveGameHeader {
@ -622,7 +623,7 @@ void Scumm::saveOrLoad(Serializer *s)
else
s->saveLoadEntries(this, mainEntriesV8);
s->saveLoadArrayOf(actor, NUM_ACTORS, sizeof(actor[0]), actorEntries);
s->saveLoadArrayOf(_actors, NUM_ACTORS, sizeof(_actors[0]), actorEntries);
if (_current_version < VER_V9)
s->saveLoadArrayOf(vm.slot, 25, sizeof(vm.slot[0]), scriptSlotEntries);

View file

@ -22,6 +22,16 @@
#ifndef SAVELOAD_H
#define SAVELOAD_H
enum {
sleByte = 1,
sleUint8 = 1,
sleInt8 = 1,
sleInt16 = 2,
sleUint16 = 3,
sleInt32 = 4,
sleUint32 = 5
};
struct SaveLoadEntry {
uint32 offs;
uint8 type;

View file

@ -23,6 +23,15 @@
#include "stdafx.h"
#include "scumm.h"
#include "actor.h"
#include "resource.h"
/* Script status type (slot.status) */
enum {
ssDead = 0,
ssPaused = 1,
ssRunning = 2
};
/* Start executing script 'script' with parameters 'a' and 'b' */
void Scumm::runScript(int script, int a, int b, int16 *lvarptr)

View file

@ -24,6 +24,7 @@
#include "stdafx.h"
#include "scumm.h"
#include "actor.h"
#include "smush.h"
#include "sound/mididrv.h"
#include "sound/imuse.h"
@ -1398,7 +1399,7 @@ void Scumm::o6_putActorInRoom()
void Scumm::o6_putActorAtObject()
{
int room, obj, x, y, dir;
int room, obj, x, y;
Actor *a;
obj = popRoomAndObj(&room);

151
scumm.h
View file

@ -41,6 +41,7 @@ class IMuse;
class Actor;
struct ScummDebugger;
struct Serializer;
struct FindObjectInRoom;
typedef void (Scumm::*OpcodeProc)();
@ -66,13 +67,6 @@ enum {
KEY_SET_OPTIONS = 3456 // WinCE
};
/* Script status type (slot.status) */
enum {
ssDead = 0,
ssPaused = 1,
ssRunning = 2
};
struct ScummPoint {
int x, y;
};
@ -81,97 +75,6 @@ struct MemBlkHeader {
uint32 size;
};
#if !defined(__GNUC__)
#pragma START_PACK_STRUCTS
#endif
struct ResHdr {
uint32 tag, size;
} GCC_PACK;
#define RES_DATA(x) (((byte*)x) + sizeof(ResHdr))
#define RES_SIZE(x) ( READ_BE_UINT32_UNALIGNED(&((ResHdr*)x)->size) )
struct RoomHeader {
union {
struct {
uint32 version;
uint16 width, height;
uint16 numObjects;
} GCC_PACK v7;
struct {
uint16 width, height;
uint16 numObjects;
} GCC_PACK old;
} GCC_PACK;
} GCC_PACK;
struct CodeHeader {
union {
struct {
uint16 obj_id;
byte x, y, w, h;
byte flags;
byte parent;
int16 walk_x;
int16 walk_y;
byte actordir;
} GCC_PACK v5;
struct {
uint16 obj_id;
int16 x, y;
uint16 w, h;
byte flags, parent;
uint16 unk1;
uint16 unk2;
byte actordir;
} GCC_PACK v6;
struct {
uint32 version;
uint16 obj_id;
byte parent;
byte parentstate;
} GCC_PACK v7;
} GCC_PACK;
} GCC_PACK;
struct ImageHeader { /* file format */
union {
struct {
uint16 obj_id;
uint16 unk[5];
uint16 width;
uint16 height;
uint16 unk_2;
struct {
int16 x, y;
} GCC_PACK hotspot[15];
} GCC_PACK old;
struct {
uint32 version;
uint16 obj_id;
uint16 unk[1];
int16 x_pos, y_pos;
uint16 width, height;
byte unk2[3];
byte actordir;
uint16 unk_2;
struct {
int16 x, y;
} GCC_PACK hotspot[15];
} GCC_PACK v7;
} GCC_PACK;
} GCC_PACK;
#if !defined(__GNUC__)
#pragma END_PACK_STRUCTS
#endif
struct VerbSlot {
int16 x, y;
int16 right, bottom;
@ -221,16 +124,6 @@ struct NestedScript {
uint8 slot;
};
enum {
sleByte = 1,
sleUint8 = 1,
sleInt8 = 1,
sleInt16 = 2,
sleUint16 = 3,
sleInt32 = 4,
sleUint32 = 5
};
enum ResTypes {
rtFirst = 1,
rtRoom = 1,
@ -262,13 +155,6 @@ enum {
LIGHTMODE_actor_color = 8
};
enum {
OF_OWNER_MASK = 0x0F,
OF_STATE_MASK = 0xF0,
OF_STATE_SHL = 4
};
enum {
MBS_LEFT_CLICK = 0x8000,
MBS_RIGHT_CLICK = 0x4000,
@ -276,12 +162,6 @@ enum {
MBS_MAX_KEY = 0x0200
};
enum {
RF_LOCK = 0x80,
RF_USAGE = 0x7F,
RF_USAGE_MAX = RF_USAGE
};
#define _maxRooms res.num[rtRoom]
#define _maxScripts res.num[rtScript]
#define _maxCostumes res.num[rtCostume]
@ -443,7 +323,6 @@ enum MouseButtonStatus {
#include "gfx.h"
#include "boxes.h"
#include "smush.h"
class Scumm {
public:
@ -540,7 +419,7 @@ public:
/* Core class/array definitions */
Gdi gdi;
Actor *actor; // Has MAX_ACTORS elements, see init.cpp
Actor *_actors; // Has MAX_ACTORS elements, see init.cpp
uint16 *_inventory;
byte *_arrays;
@ -750,19 +629,6 @@ public:
/* Should be in Object class */
byte OF_OWNER_ROOM;
struct FindObjectInRoom {
CodeHeader *cdhd;
byte *obcd;
ImageHeader *imhd;
byte *obim;
byte *roomptr;
};
enum FindObjectWhat {
foCodeHeader = 1,
foImageHeader = 2,
foCheckAlreadyLoaded = 4
};
int getInventorySlot();
void SamInventoryHack(int obj); // FIXME: Sam and Max hack
int findInventory(int owner, int index);
@ -918,7 +784,7 @@ public:
/* Should be in Actor class */
Actor *derefActor(int id);
Actor *derefActorSafe(int id, const char *errmsg);
Actor *getFirstActor() {return actor;}
Actor *getFirstActor() { return _actors; }
void putActor(Actor *a, int x, int y, byte room);
void showActors();
@ -1186,8 +1052,6 @@ public:
uint fileReadWordLE(void *handle);
uint fileReadWordBE(void *handle);
static char *Strdup(const char *);
/* Version 5 script opcodes */
void o5_actorFollowCamera();
void o5_actorFromPos();
@ -1621,11 +1485,8 @@ struct ScummDebugger {
void printScripts();
};
extern const uint32 IMxx_tags[];
extern const byte default_scale_table[768];
extern uint16 _debugLevel;
void outputdisplay2(Scumm *s, int disp);
extern const byte revBitMask[8];
//void blitToScreen(Scumm *s, byte *src, int x, int y, int w, int h);
@ -1639,11 +1500,5 @@ void CDECL warning(const char *s, ...);
void CDECL debug(int level, const char *s, ...);
void checkHeap();
void blit(byte *dst, byte *src, int w, int h);
byte *findResource(uint32 tag, byte *searchin, int index);
byte *findResourceSmall(uint32 tag, byte *searchin, int index);
byte *findResource(uint32 tag, byte *searchin);
byte *findResourceSmall(uint32 tag, byte *searchin);
void setWindowName(Scumm *s);
uint16 newTag2Old(uint32 oldTag);
#endif

View file

@ -24,11 +24,13 @@
#include "scumm.h"
#include "sound/mididrv.h"
#include "sound/imuse.h"
#include "gui.h"
#include "string.h"
#include "gameDetector.h"
#include "actor.h"
#include"newgui.h"
#include "gameDetector.h"
#include "gui.h"
#include "newgui.h"
#include "object.h"
#include "resource.h"
#include "string.h"
int autosave(int interval) /* Not in class to prevent being bound */
{
@ -78,7 +80,7 @@ void Scumm::scummInit()
setupCursor();
/* Allocate and initilise actors */
actor = new Actor[MAX_ACTORS];
_actors = new Actor[MAX_ACTORS];
for (i = 1, a = getFirstActor(); ++a, i < NUM_ACTORS; i++) {
a->number = i;
a->initActorClass(this);
@ -260,9 +262,7 @@ int Scumm::scummLoop(int delta)
_vars[VAR_MI1_TIMER] += 6;
}
}
} else if (_features & GF_OLD256)
{
} else if (_features & GF_OLD256) {
if(tempMusic == 3) {
tempMusic = 0;
@ -1027,7 +1027,7 @@ void Scumm::convertKeysToClicks()
Actor *Scumm::derefActor(int id)
{
return &actor[id];
return &_actors[id];
}
Actor *Scumm::derefActorSafe(int id, const char *errmsg)

24
sys.cpp
View file

@ -201,17 +201,6 @@ uint32 Scumm::fileReadDwordBE(void *handle)
return (b << 16) | a;
}
char *Scumm::Strdup(const char *s)
{
if (s) {
int l = strlen(s) + 1;
char *r = (char *)malloc(l);
memcpy(r, s, l);
return r;
}
return NULL;
}
bool Scumm::checkFixedDisk()
{
return true;
@ -221,11 +210,14 @@ bool Scumm::checkFixedDisk()
#ifdef NEED_STRDUP
char *strdup(const char *s)
{
int len = strlen(s) + 1;
char *d = (char *)malloc(len);
if (d)
memcpy(d, s, len);
return d;
if (s) {
int len = strlen(s) + 1;
char *d = (char *)malloc(len);
if (d)
memcpy(d, s, len);
return d;
}
return NULL;
}
#endif /* NEED_STRDUP */

View file

@ -22,6 +22,7 @@
#include "stdafx.h"
#include "scumm.h"
#include "resource.h"
void Scumm_v3::readIndexFile()
@ -43,22 +44,22 @@ void Scumm_v3::readIndexFile()
break;
switch (blocktype) {
case 0x4E52:
case 0x4E52: // 'NR'
fileReadWordLE();
break;
case 0x5230:
case 0x5230: // 'R0'
_numRooms = fileReadWordLE();
break;
case 0x5330:
case 0x5330: // 'S0'
_numScripts = fileReadWordLE();
break;
case 0x4E30:
case 0x4E30: // 'N0'
_numSounds = fileReadWordLE();
break;
case 0x4330:
case 0x4330: // 'C0'
_numCostumes = fileReadWordLE();
break;
case 0x4F30:
case 0x4F30: // 'O0'
_numGlobalObjects = fileReadWordLE();
break;
}
@ -98,27 +99,27 @@ void Scumm_v3::readIndexFile()
switch (blocktype) {
case 0x4E52:
case 0x4E52: // 'NR'
fileSeek(_fileHandle, itemsize - 6, SEEK_CUR);
break;
case 0x5230:
case 0x5230: // 'R0'
readResTypeList(rtRoom, MKID('ROOM'), "room");
break;
case 0x5330:
case 0x5330: // 'S0'
readResTypeList(rtScript, MKID('SCRP'), "script");
break;
case 0x4E30:
case 0x4E30: // 'N0'
readResTypeList(rtSound, MKID('SOUN'), "sound");
break;
case 0x4330:
case 0x4330: // 'C0'
readResTypeList(rtCostume, MKID('COST'), "costume");
break;
case 0x4F30:
case 0x4F30: // 'O0'
num = fileReadWordLE();
assert(num == _numGlobalObjects);
for (i = 0; i != num; i++) {

View file

@ -22,6 +22,8 @@
#include "stdafx.h"
#include "scumm.h"
#include "object.h"
#include "resource.h"
void Scumm::redrawVerbs()
{