[Scummvm-cvs-logs] CVS: scummvm/queen logic.cpp,NONE,1.1 logic.h,NONE,1.1 module.mk,NONE,1.1 queen.cpp,NONE,1.1 queen.h,NONE,1.1 resource.cpp,NONE,1.1 resource.h,NONE,1.1 restables.cpp,NONE,1.1 version.cpp,NONE,1.1
Joost Peters
joostp at users.sourceforge.net
Sun Sep 28 08:50:10 CEST 2003
Update of /cvsroot/scummvm/scummvm/queen
In directory sc8-pr-cvs1:/tmp/cvs-serv1030/queen
Added Files:
logic.cpp logic.h module.mk queen.cpp queen.h resource.cpp
resource.h restables.cpp version.cpp
Log Message:
queen initial import
--- NEW FILE: logic.cpp ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2003 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: /cvsroot/scummvm/scummvm/queen/logic.cpp,v 1.1 2003/09/28 15:48:54 joostp Exp $
*
*/
#include "queen/logic.h"
QueenLogic::QueenLogic(QueenResource *resource) {
_resource = resource;
_jas = _resource->loadJAS();
initialise();
}
QueenLogic::~QueenLogic() {
free (_jas);
//free(_graphicData);
}
void QueenLogic::initialise() {
uint8 *ptr = _jas;
//_display->loadFont();
_numRooms = READ_BE_UINT16(ptr);
ptr += 2;
_numNames = READ_BE_UINT16(ptr);
ptr += 2;
_numObjects = READ_BE_UINT16(ptr);
ptr += 2;
_numDescriptions = READ_BE_UINT16(ptr);
ptr += 2;
//Object data
_objectData = (uint16 (*)[8])malloc((_numObjects + 1) * sizeof(_objectData[0]));
//clear first object
for (uint16 j = 0; j < 8; j++)
_objectData[0][j] = 0;
for (uint16 i = 1; i < (_numObjects + 1); i++)
for (uint16 j = 0; j < 8; j++) {
_objectData[i][j] = READ_BE_UINT16(ptr);
ptr += 2;
}
//Room data
_roomData = (uint16 *)malloc((_numRooms + 2) * sizeof(_roomData[0]));
for (uint16 i = 1; i < (_numRooms + 2); i++) {
_roomData[i] = READ_BE_UINT16(ptr);
ptr += 2;
}
_roomData[_numRooms + 1] = _numObjects;
//SFX Name
_sfxName = (uint16 *)malloc((_numRooms + 1) * sizeof(_sfxName[0]));
for (uint16 i = 0; i < (_numRooms + 1); i++) {
_sfxName[i] = READ_BE_UINT16(ptr);
ptr += 2;
}
//Item information
_numItems = READ_BE_UINT16(ptr);
ptr += 2;
_itemData = (uint16 (*)[5])malloc((_numItems + 1) * sizeof(_itemData[0]));
for (uint16 i = 1; i < (_numItems + 1); i++) {
_itemData[i][0] = READ_BE_UINT16(ptr);
ptr += 2;
for (uint16 j = 1; j < 5; j++) {
_itemData[i][j] = READ_BE_UINT16(ptr);
ptr += 2;
}
}
//Graphic Image Data
_numGraphics = READ_BE_UINT16(ptr);
ptr += 2;
_graphicData = (uint16 (*)[5])malloc((_numGraphics + 1) * sizeof(_graphicData[0]));
for (uint16 i = 1; i < _numGraphics; i++)
for (uint16 j = 0; j < 5; j++) {
_graphicData[i][j] = READ_BE_UINT16(ptr);
ptr += 2;
}
_objMax = (uint16 *)malloc((_numRooms + 1) * sizeof(_objMax[0]));
_areaMax = (uint16 *)malloc((_numRooms + 1) * sizeof(_areaMax[0]));
_area = (uint16 (*)[11][8])malloc((_numRooms + 1) * sizeof(_area[0]));
/*
for (uint16 i = 1; i < (_numRooms + 1); i++) {
_objMax[i] = READ_BE_UINT16(ptr);
ptr += 2;
_areaMax[i] = READ_BE_UINT16(ptr);
ptr += 2;
for (uint16 j = 1; j < (_areaMax[i] + 1); j++)
for (uint16 k = 0; k < 8; k++) {
_area[i][j][k] = READ_BE_UINT16(ptr);
ptr += 2;
}
}
_objectBox = (uint16 (*)[4])malloc((_numObjects + 1) * sizeof(_objectBox[0]));
for (uint16 i = 1; i < (_numObjects + 1); i++)
for (uint16 j = 0; j < 4; j++) {
_objectBox[i][j] = READ_BE_UINT16(ptr);
ptr += 2;
}
*/
}
uint16 QueenLogic::currentRoom() {
return _currentRoom;
}
--- NEW FILE: logic.h ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2003 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: /cvsroot/scummvm/scummvm/queen/logic.h,v 1.1 2003/09/28 15:48:54 joostp Exp $
*
*/
#ifndef QUEENLOGIC_H
#define QUEENLOGIC_H
#include "queen/queen.h"
class QueenLogic {
public:
QueenLogic(QueenResource *resource);
~QueenLogic();
uint16 currentRoom();
protected:
uint8 *_jas;
uint16 _numRooms;
uint16 _currentRoom;
uint16 _oldRoom;
uint16 _newRoom;
uint16 _numNames;
uint16 _numObjects;
uint16 _numDescriptions;
uint16 _numItems;
uint16 _numGraphics;
uint16 *_roomData;
uint16 *_sfxName;
uint16 *_objMax;
uint16 *_areaMax;
uint16 (*_objectBox)[4];
uint16 (*_itemData)[5];
uint16 (*_graphicData)[5];
uint16 (*_objectData)[8];
uint16 (*_actorData)[12];
uint16 (*_area)[11][8];
QueenResource *_resource;
void initialise();
};
#endif
--- NEW FILE: module.mk ---
MODULE := queen
MODULE_OBJS = \
queen/logic.o \
queen/resource.o \
queen/restables.o \
queen/queen.o \
queen/version.o \
# Include common rules
include common.rules
--- NEW FILE: queen.cpp ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2003 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: /cvsroot/scummvm/scummvm/queen/queen.cpp,v 1.1 2003/09/28 15:48:54 joostp Exp $
*
*/
#include "stdafx.h"
#include "queen/queen.h"
#include "common/file.h"
#include "base/gameDetector.h"
extern uint16 _debugLevel;
#ifdef _WIN32_WCE
extern bool toolbar_drawn;
extern bool draw_keyboard;
#endif
static const TargetSettings queen_settings[] = {
/* Flight of the Amazon Queen */
{ "queen", "Flight of the Amazon Queen", GID_QUEEN_FIRST, 99, MDT_ADLIB | MDT_NATIVE | MDT_PREFER_NATIVE, 0, "queen.1" },
{ NULL, NULL, 0, 0, MDT_NONE, 0, NULL}
};
const TargetSettings *Engine_QUEEN_targetList() {
return queen_settings;
}
Engine *Engine_QUEEN_create(GameDetector *detector, OSystem *syst) {
return new QueenEngine(detector, syst);
}
QueenEngine::QueenEngine(GameDetector *detector, OSystem *syst)
: Engine(detector, syst) {
_game = detector->_game.id;
if (!_mixer->bindToSystem(syst))
warning("Sound initialisation failed.");
_mixer->setVolume(detector->_sfx_volume);
_debugMode = detector->_debugMode;
_debugLevel = detector->_debugLevel;
_detector = detector;
_fastMode = 0;
_system->init_size(320, 200);
}
QueenEngine::~QueenEngine() {
delete _queenLogic;
delete _queenResource;
//delete _queenDisplay;
}
void QueenEngine::errorString(const char *buf1, char *buf2) {
strcpy(buf2, buf1);
}
void QueenEngine::go() {
if (!_dump_file)
_dump_file = stdout;
initialise();
while (1) { //main loop
delay(1000);
}
}
void QueenEngine::initialise(void) {
OSystem::Property prop;
_queenResource = new QueenResource(_gameDataPath);
_queenLogic = new QueenLogic(_queenResource);
//_queenSound = new QueenSound(_mixer, _detector->_sfx_volume);
// Override global scaler with any game-specific define
if (g_config->get("gfx_mode")) {
prop.gfx_mode = _detector->parseGraphicsMode(g_config->get("gfx_mode"));
_system->property(OSystem::PROP_SET_GFX_MODE, &prop);
}
// Override global fullscreen setting with any game-specific define
if (g_config->getBool("fullscreen", false)) {
if (!_system->property(OSystem::PROP_GET_FULLSCREEN, 0))
_system->property(OSystem::PROP_TOGGLE_FULLSCREEN, 0);
}
}
void QueenEngine::delay(uint amount) {
OSystem::Event event;
uint32 start = _system->get_msecs();
uint32 cur = start;
_key_pressed = 0; //reset
do {
while (_system->poll_event(&event)) {
switch (event.event_code) {
case OSystem::EVENT_KEYDOWN:
if (event.kbd.flags == OSystem::KBD_CTRL) {
if (event.kbd.keycode == 'f') {
_fastMode ^= 1;
break;
}
if (event.kbd.keycode == 'g') {
_fastMode ^= 2;
break;
}
}
// Make sure backspace works right (this fixes a small issue on OS X)
if (event.kbd.keycode == 8)
_key_pressed = 8;
else
_key_pressed = (byte)event.kbd.ascii;
break;
case OSystem::EVENT_MOUSEMOVE:
_sdl_mouse_x = event.mouse.x;
_sdl_mouse_y = event.mouse.y;
break;
case OSystem::EVENT_LBUTTONDOWN:
#ifdef _WIN32_WCE
_sdl_mouse_x = event.mouse.x;
_sdl_mouse_y = event.mouse.y;
#endif
break;
case OSystem::EVENT_RBUTTONDOWN:
break;
case OSystem::EVENT_QUIT:
_system->quit();
break;
default:
break;
}
}
if (amount == 0)
break;
{
uint this_delay = 20; // 1?
if (this_delay > amount)
this_delay = amount;
_system->delay_msecs(this_delay);
}
cur = _system->get_msecs();
} while (cur < start + amount);
}
--- NEW FILE: queen.h ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2003 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: /cvsroot/scummvm/scummvm/queen/queen.h,v 1.1 2003/09/28 15:48:54 joostp Exp $
*
*/
#ifndef QUEEN_H
#define QUEEN_H
#include <stdio.h>
#include "base/engine.h"
#include "common/util.h"
#include "common/timer.h"
#include "sound/mixer.h"
#include "queen/resource.h"
#include "queen/logic.h"
#include "common/config-file.h"
class QueenLogic;
class QueenEngine : public Engine {
void errorString(const char *buf_input, char *buf_output);
protected:
byte _game;
byte _key_pressed;
bool _quickLaunch; // set when starting with -x
uint16 _debugMode;
int _numScreenUpdates;
int _number_of_savegames;
int _sdl_mouse_x, _sdl_mouse_y;
QueenResource *_queenResource;
QueenLogic *_queenLogic;
GameDetector *_detector; // necessary for music
public:
QueenEngine(GameDetector *detector, OSystem *syst);
virtual ~QueenEngine();
protected:
byte _fastMode;
void delay(uint amount);
void go();
void initialise();
static int CDECL game_thread_proc(void *param);
};
#endif
--- NEW FILE: resource.cpp ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2003 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: /cvsroot/scummvm/scummvm/queen/resource.cpp,v 1.1 2003/09/28 15:48:54 joostp Exp $
*
*/
#include "queen/queen.h"
#include "queen/resource.h"
#define DEMO_JAS_VERSION_OFFSET 0x119A8
#define JAS_VERSION_OFFSET 0x12484
static const char *dataFilename = "queen.1";
QueenResource::QueenResource(char *datafilePath) {
_datafilePath = datafilePath;
_resourceFile = new File();
_resourceFile->open(dataFilename, _datafilePath);
if (_resourceFile->isOpen() == false)
error("Could not open resource file '%s%s'", _datafilePath, dataFilename);
//detect game version based on resource file size.
//we try to verify that it is indeed the version we think it is later on
switch(_resourceFile->size()) {
case 3724538:
_gameVersion = &_gameVersionPE100v1;
break;
case 3732177:
_gameVersion = &_gameVersionPE100v2;
break;
case 22677657:
_gameVersion = &_gameVersionPEM10;
break;
case 190787021:
_gameVersion = &_gameVersionCEM10;
break;
default:
error("Unknown/unsupported FOTAQ version");
}
debug(5, "Detected game version: %s, which has %d resource entries", _gameVersion->versionString, _gameVersion->resourceEntries);
if (strcmp(_gameVersion->versionString, JASVersion()))
error("Verifying game version failed! (expected: '%s', found: '%s')", _gameVersion->versionString, JASVersion());
}
QueenResource::~QueenResource() {
_resourceFile->close();
}
int32 QueenResource::resourceIndex(const char *filename) {
char entryName[14];
char *ptr = entryName;
assert(strlen(filename));
strcpy(entryName, filename);
do
*ptr = toupper(*ptr);
while (*ptr++);
/*
for (uint32 i = 0; i < _gameVersion->resourceEntries; i++)
if (!(strcmp(entryName, _gameVersion->resourceTable[i].filename)))
return i;
return -1;
*/
uint32 low = 0;
uint32 high = _gameVersion->resourceEntries - 1;
if (!strcmp(entryName, _gameVersion->resourceTable[low].filename))
return low;
if (!strcmp(entryName, _gameVersion->resourceTable[high].filename))
return high;
//Use simple binary search to locate file
for(;;) {
uint32 cur = (low + high) / 2;
int32 diff = strcmp(entryName, _gameVersion->resourceTable[cur].filename);
if (!diff)
return cur;
if ((cur == low) || (cur == high))
break;
if (diff > 0)
low = cur;
else
high = cur;
}
error("Couldn't find file '%s'", entryName);
return -1;
}
uint32 QueenResource::fileSize(const char *filename) {
return _gameVersion->resourceTable[resourceIndex(filename)].size;
}
uint32 QueenResource::fileOffset(const char *filename) {
return _gameVersion->resourceTable[resourceIndex(filename)].offset;
}
uint8 *QueenResource::loadJAS() {
uint32 size = fileSize("QUEEN.JAS");
uint8 *jas = (uint8 *)malloc(size);
_resourceFile->seek(fileOffset("QUEEN.JAS") + 20, SEEK_SET);
_resourceFile->read(jas, size - 20);
return jas;
}
const char *QueenResource::JASVersion() {
static char versionStr[6];
if (_gameVersion->isDemo)
_resourceFile->seek(fileOffset("QUEEN.JAS") + DEMO_JAS_VERSION_OFFSET, SEEK_SET );
else
_resourceFile->seek(fileOffset("QUEEN.JAS") + JAS_VERSION_OFFSET, SEEK_SET);
_resourceFile->read(versionStr, 6);
return versionStr;
}
--- NEW FILE: resource.h ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2003 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: /cvsroot/scummvm/scummvm/queen/resource.h,v 1.1 2003/09/28 15:48:54 joostp Exp $
*
*/
#ifndef QUEENRESOURCE_H
#define QUEENRESOURCE_H
#include "common/file.h"
struct ResourceEntry {
char filename[13];
uint8 inBundle;
uint32 offset;
uint32 size;
};
struct GameVersion {
char versionString[6];
uint32 resourceEntries;
bool isFloppy;
bool isDemo;
const struct ResourceEntry *resourceTable;
};
class QueenResource {
public:
QueenResource(char *datafilePath);
~QueenResource(void);
uint8 *loadJAS();
protected:
File *_resourceFile;
char *_datafilePath;
const struct GameVersion *_gameVersion;
static const struct GameVersion _gameVersionPE100v1;
static const struct GameVersion _gameVersionPE100v2;
static const struct GameVersion _gameVersionPEM10;
static const struct GameVersion _gameVersionCEM10;
static const struct ResourceEntry _resourceTablePE100v1[];
static const struct ResourceEntry _resourceTablePE100v2[];
static const struct ResourceEntry _resourceTablePEM10[];
static const struct ResourceEntry _resourceTableCEM10[];
int32 resourceIndex(const char *filename);
uint32 fileSize(const char *filename);
uint32 fileOffset(const char *filename);
const char *JASVersion();
};
#endif
--- NEW FILE: restables.cpp ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2003 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: /cvsroot/scummvm/scummvm/queen/restables.cpp,v 1.1 2003/09/28 15:48:54 joostp Exp $
*
[...9057 lines suppressed...]
{ "X5.BBK", 1, 0x0b4b4ed5, 0x000075a0 },
{ "X5.PCX", 1, 0x0b4bc475, 0x0000adeb },
{ "X5_SPARK.ACT", 1, 0x0b4c7260, 0x00006e5a },
{ "X6.BAK", 1, 0x0b4ce0ba, 0x0000f95a },
{ "X6.BBK", 1, 0x0b4dda14, 0x0001889e },
{ "X6.PCX", 1, 0x0b4f62b2, 0x0000be75 },
{ "X6_HUGH.ACT", 1, 0x0b502127, 0x0000c25a },
{ "X7.BBK", 1, 0x0b50e381, 0x00002ada },
{ "X7.PCX", 1, 0x0b510e5b, 0x00009456 },
{ "X7A.SAM", 1, 0x0b51a2b1, 0x0001b7cb },
{ "X7B.SAM", 1, 0x0b535a7c, 0x0003b107 },
{ "X8.BBK", 1, 0x0b570b83, 0x00032a14 },
{ "X8.PCX", 1, 0x0b5a3597, 0x00013d4f },
{ "X9.BBK", 1, 0x0b5b72e6, 0x00028337 },
{ "X9.PCX", 1, 0x0b5df61d, 0x0000a31c },
{ "ZOMBIE.ACT", 1, 0x0b5e9939, 0x000078ea },
{ "ZOMBIE1.DOG", 1, 0x0b5f1223, 0x00000f6a },
{ "ZOMBIE2.DOG", 1, 0x0b5f218d, 0x00000c40 }
};
--- NEW FILE: version.cpp ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2003 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: /cvsroot/scummvm/scummvm/queen/version.cpp,v 1.1 2003/09/28 15:48:54 joostp Exp $
*
*/
#include "queen/resource.h"
//English Floppy Demo v1
const GameVersion QueenResource::_gameVersionPE100v1 = {
"PE100",
155,
true,
true,
_resourceTablePE100v1
};
//English Floppy Demo v2
const GameVersion QueenResource::_gameVersionPE100v2 = {
"PE100",
155,
true,
true,
_resourceTablePE100v2
};
//English Floppy
const GameVersion QueenResource::_gameVersionPEM10 = {
"PEM10",
1076,
true,
false,
_resourceTablePEM10
};
//English CD Talkie
const GameVersion QueenResource::_gameVersionCEM10 = {
"CEM10",
7671,
false,
false,
_resourceTableCEM10
};
More information about the Scummvm-git-logs
mailing list