PRINCE: Room struct implementation and objects drawing fix
This commit is contained in:
parent
d5f2b97c3e
commit
3d590627ed
6 changed files with 77 additions and 23 deletions
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
namespace Prince {
|
namespace Prince {
|
||||||
|
|
||||||
Object::Object() : _surface(NULL), _x(0), _y(0), _z(0) {
|
Object::Object() : _surface(NULL), _x(0), _y(0), _z(0), _overlay(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Object::~Object() {
|
Object::~Object() {
|
||||||
|
@ -45,9 +45,11 @@ Object::~Object() {
|
||||||
|
|
||||||
void Object::loadSurface(Common::SeekableReadStream &stream) {
|
void Object::loadSurface(Common::SeekableReadStream &stream) {
|
||||||
stream.skip(4);
|
stream.skip(4);
|
||||||
|
int width = stream.readUint16LE();
|
||||||
|
int height = stream.readUint16LE();
|
||||||
_surface = new Graphics::Surface();
|
_surface = new Graphics::Surface();
|
||||||
_surface->create(stream.readUint16LE(), stream.readUint16LE(), Graphics::PixelFormat::createFormatCLUT8());
|
_surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
|
||||||
|
|
||||||
for (int h = 0; h < _surface->h; ++h) {
|
for (int h = 0; h < _surface->h; ++h) {
|
||||||
stream.read(_surface->getBasePtr(0, h), _surface->w);
|
stream.read(_surface->getBasePtr(0, h), _surface->w);
|
||||||
}
|
}
|
||||||
|
@ -71,11 +73,12 @@ bool Object::loadFromStream(Common::SeekableReadStream &stream) {
|
||||||
loadSurface(*obStream);
|
loadSurface(*obStream);
|
||||||
delete obStream;
|
delete obStream;
|
||||||
|
|
||||||
|
_overlay = stream.readUint16LE();
|
||||||
_z = stream.readUint16LE();
|
_z = stream.readUint16LE();
|
||||||
|
|
||||||
stream.seek(pos + 16);
|
stream.seek(pos + 16);
|
||||||
|
|
||||||
debug("Object x %d, y %d, z %d", _x, _y, _z);
|
debug("Object x %d, y %d, z %d overlay %d", _x, _y, _z, _overlay);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,12 +35,10 @@ public:
|
||||||
|
|
||||||
bool loadFromStream(Common::SeekableReadStream &stream);
|
bool loadFromStream(Common::SeekableReadStream &stream);
|
||||||
const Graphics::Surface *getSurface() const { return _surface; }
|
const Graphics::Surface *getSurface() const { return _surface; }
|
||||||
|
uint16 _x, _y, _z, _overlay;
|
||||||
private:
|
private:
|
||||||
void loadSurface(Common::SeekableReadStream &stream);
|
void loadSurface(Common::SeekableReadStream &stream);
|
||||||
|
|
||||||
Graphics::Surface *_surface;
|
Graphics::Surface *_surface;
|
||||||
uint16 _x, _y, _z;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ void PrinceEngine::debugEngine(const char *s, ...) {
|
||||||
|
|
||||||
PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc) :
|
PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc) :
|
||||||
Engine(syst), _gameDescription(gameDesc), _graph(nullptr), _script(nullptr), _interpreter(nullptr), _flags(nullptr),
|
Engine(syst), _gameDescription(gameDesc), _graph(nullptr), _script(nullptr), _interpreter(nullptr), _flags(nullptr),
|
||||||
_locationNr(0), _debugger(nullptr), _midiPlayer(nullptr),
|
_locationNr(0), _debugger(nullptr), _midiPlayer(nullptr), _room(nullptr),
|
||||||
_cameraX(0), _newCameraX(0), _frameNr(0), _cursor1(nullptr), _cursor2(nullptr), _font(nullptr),
|
_cameraX(0), _newCameraX(0), _frameNr(0), _cursor1(nullptr), _cursor2(nullptr), _font(nullptr),
|
||||||
_suitcaseBmp(nullptr), _roomBmp(nullptr), _cursorNr(0), _picWindowX(0), _picWindowY(0) {
|
_suitcaseBmp(nullptr), _roomBmp(nullptr), _cursorNr(0), _picWindowX(0), _picWindowY(0) {
|
||||||
|
|
||||||
|
@ -108,6 +108,7 @@ PrinceEngine::~PrinceEngine() {
|
||||||
delete _variaTxt;
|
delete _variaTxt;
|
||||||
delete[] _talkTxt;
|
delete[] _talkTxt;
|
||||||
delete _graph;
|
delete _graph;
|
||||||
|
delete _room;
|
||||||
|
|
||||||
for (uint i = 0; i < _objList.size(); i++) {
|
for (uint i = 0; i < _objList.size(); i++) {
|
||||||
delete _objList[i];
|
delete _objList[i];
|
||||||
|
@ -195,6 +196,8 @@ void PrinceEngine::init() {
|
||||||
|
|
||||||
_roomBmp = new Image::BitmapDecoder();
|
_roomBmp = new Image::BitmapDecoder();
|
||||||
|
|
||||||
|
_room = new Room();
|
||||||
|
|
||||||
_mainHero = new Hero(this, _graph);
|
_mainHero = new Hero(this, _graph);
|
||||||
_secondHero = new Hero(this, _graph);
|
_secondHero = new Hero(this, _graph);
|
||||||
|
|
||||||
|
@ -298,12 +301,6 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
|
||||||
|
|
||||||
_picWindowX = 0;
|
_picWindowX = 0;
|
||||||
|
|
||||||
_mainHero->_lightX = _script->getLightX(_locationNr);
|
|
||||||
_mainHero->_lightY = _script->getLightY(_locationNr);
|
|
||||||
_mainHero->setShadowScale(_script->getShadowScale(_locationNr));
|
|
||||||
debug("lightX: %d", _mainHero->_lightX);
|
|
||||||
debug("lightY: %d", _mainHero->_lightY);
|
|
||||||
|
|
||||||
_mobList.clear();
|
_mobList.clear();
|
||||||
Resource::loadResource(_mobList, "mob.lst", false);
|
Resource::loadResource(_mobList, "mob.lst", false);
|
||||||
|
|
||||||
|
@ -316,6 +313,12 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
|
||||||
_animList.clear();
|
_animList.clear();
|
||||||
Resource::loadResource(_animList, "anim.lst", false);
|
Resource::loadResource(_animList, "anim.lst", false);
|
||||||
|
|
||||||
|
_mainHero->_lightX = _script->getLightX(_locationNr);
|
||||||
|
_mainHero->_lightY = _script->getLightY(_locationNr);
|
||||||
|
_mainHero->setShadowScale(_script->getShadowScale(_locationNr));
|
||||||
|
|
||||||
|
_room->loadRoom(_script->getRoomOffset(_locationNr));
|
||||||
|
|
||||||
_graph->makeShadowTable(70, _graph->_shadowTable70);
|
_graph->makeShadowTable(70, _graph->_shadowTable70);
|
||||||
_graph->makeShadowTable(50, _graph->_shadowTable50);
|
_graph->makeShadowTable(50, _graph->_shadowTable50);
|
||||||
|
|
||||||
|
@ -688,10 +691,13 @@ void PrinceEngine::drawScreen() {
|
||||||
}
|
}
|
||||||
|
|
||||||
playNextFrame();
|
playNextFrame();
|
||||||
|
/*
|
||||||
//if (_objectList)
|
if (!_objList.empty()) {
|
||||||
// _graph->drawTransparent(_objectList->getSurface());
|
for (int i = 0; i < _objList.size(); i++) {
|
||||||
|
_graph->drawTransparent(_objList[i]->_x, _objList[i]->_y, _objList[i]->getSurface());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
hotspot();
|
hotspot();
|
||||||
|
|
||||||
showTexts();
|
showTexts();
|
||||||
|
|
|
@ -63,6 +63,7 @@ class MhwanhDecoder;
|
||||||
class Font;
|
class Font;
|
||||||
class Hero;
|
class Hero;
|
||||||
class Animation;
|
class Animation;
|
||||||
|
class Room;
|
||||||
|
|
||||||
struct Text {
|
struct Text {
|
||||||
const char *_str;
|
const char *_str;
|
||||||
|
@ -177,7 +178,7 @@ private:
|
||||||
Interpreter *_interpreter;
|
Interpreter *_interpreter;
|
||||||
Font *_font;
|
Font *_font;
|
||||||
MusicPlayer *_midiPlayer;
|
MusicPlayer *_midiPlayer;
|
||||||
|
Room *_room;
|
||||||
|
|
||||||
static const uint32 MAX_SAMPLES = 60;
|
static const uint32 MAX_SAMPLES = 60;
|
||||||
Common::SeekableReadStream *_voiceStream[MAX_SAMPLES];
|
Common::SeekableReadStream *_voiceStream[MAX_SAMPLES];
|
||||||
|
|
|
@ -40,6 +40,29 @@ static const uint16 NUM_OPCODES = 144;
|
||||||
|
|
||||||
Room::Room() {}
|
Room::Room() {}
|
||||||
|
|
||||||
|
bool Room::loadRoom(byte *roomData) {
|
||||||
|
int roomSize = 64;
|
||||||
|
Common::MemoryReadStream roomStream(roomData, roomSize);
|
||||||
|
|
||||||
|
_mobs = roomStream.readSint32LE();
|
||||||
|
_backAnim = roomStream.readSint32LE();
|
||||||
|
_obj = roomStream.readSint32LE();
|
||||||
|
_nak = roomStream.readSint32LE();
|
||||||
|
_itemUse = roomStream.readSint32LE();
|
||||||
|
_itemGive = roomStream.readSint32LE();
|
||||||
|
_walkTo = roomStream.readSint32LE();
|
||||||
|
_examine = roomStream.readSint32LE();
|
||||||
|
_pickup = roomStream.readSint32LE();
|
||||||
|
_use = roomStream.readSint32LE();
|
||||||
|
_pushOpen = roomStream.readSint32LE();
|
||||||
|
_pullClose = roomStream.readSint32LE();
|
||||||
|
_talk = roomStream.readSint32LE();
|
||||||
|
_give = roomStream.readSint32LE();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void Room::loadMobs(Common::SeekableReadStream &stream) {
|
void Room::loadMobs(Common::SeekableReadStream &stream) {
|
||||||
debug("loadMobs %d", stream.pos());
|
debug("loadMobs %d", stream.pos());
|
||||||
static const uint8 MAX_MOBS = 64;
|
static const uint8 MAX_MOBS = 64;
|
||||||
|
@ -73,7 +96,8 @@ void Room::loadPushOpen(Common::SeekableReadStream &stream) {}
|
||||||
void Room::loadPullClose(Common::SeekableReadStream &stream) {}
|
void Room::loadPullClose(Common::SeekableReadStream &stream) {}
|
||||||
void Room::loadTalk(Common::SeekableReadStream &stream) {}
|
void Room::loadTalk(Common::SeekableReadStream &stream) {}
|
||||||
void Room::loadGive(Common::SeekableReadStream &stream) {}
|
void Room::loadGive(Common::SeekableReadStream &stream) {}
|
||||||
|
*/
|
||||||
|
/*
|
||||||
void Room::nextLoadStep(Common::SeekableReadStream &stream, LoadingStep step) {
|
void Room::nextLoadStep(Common::SeekableReadStream &stream, LoadingStep step) {
|
||||||
uint32 offset = stream.readUint32LE();
|
uint32 offset = stream.readUint32LE();
|
||||||
uint32 pos = stream.pos();
|
uint32 pos = stream.pos();
|
||||||
|
@ -85,7 +109,8 @@ void Room::nextLoadStep(Common::SeekableReadStream &stream, LoadingStep step) {
|
||||||
|
|
||||||
stream.seek(pos);
|
stream.seek(pos);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
/*
|
||||||
bool Room::loadFromStream(Common::SeekableReadStream &stream) {
|
bool Room::loadFromStream(Common::SeekableReadStream &stream) {
|
||||||
|
|
||||||
uint32 pos = stream.pos();
|
uint32 pos = stream.pos();
|
||||||
|
@ -109,8 +134,9 @@ bool Room::loadFromStream(Common::SeekableReadStream &stream) {
|
||||||
static const uint8 ROOM_ENTRY_SIZE = 64;
|
static const uint8 ROOM_ENTRY_SIZE = 64;
|
||||||
stream.seek(pos + ROOM_ENTRY_SIZE);
|
stream.seek(pos + ROOM_ENTRY_SIZE);
|
||||||
|
|
||||||
return true;;
|
return true;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
Script::Script() : _data(nullptr), _dataSize(0) {
|
Script::Script() : _data(nullptr), _dataSize(0) {
|
||||||
}
|
}
|
||||||
|
@ -174,6 +200,10 @@ uint32 Script::getStartGameOffset() {
|
||||||
return _scriptInfo.startGame;
|
return _scriptInfo.startGame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8 *Script::getRoomOffset(int locationNr) {
|
||||||
|
return &_data[_scriptInfo.rooms + locationNr * 64]; // Room_Len (64?)
|
||||||
|
}
|
||||||
|
|
||||||
InterpreterFlags::InterpreterFlags() {
|
InterpreterFlags::InterpreterFlags() {
|
||||||
resetAllFlags();
|
resetAllFlags();
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,24 @@ namespace Detail {
|
||||||
class Room {
|
class Room {
|
||||||
public:
|
public:
|
||||||
Room();
|
Room();
|
||||||
|
int _mobs; // mob flag offset
|
||||||
|
int _backAnim; // offset to array of animation numbers
|
||||||
|
int _obj; // offset to array of object numbers
|
||||||
|
int _nak; // offset to array of overlays
|
||||||
|
int _itemUse;
|
||||||
|
int _itemGive;
|
||||||
|
int _walkTo; // offset to array of WALKTO events or 0
|
||||||
|
int _examine; // offset to array of EXAMINE events or 0
|
||||||
|
int _pickup;
|
||||||
|
int _use;
|
||||||
|
int _pushOpen;
|
||||||
|
int _pullClose;
|
||||||
|
int _talk;
|
||||||
|
int _give;
|
||||||
|
//Room_Pad db 64-(Room_Pad-Room_Mobs) dup (0) ???
|
||||||
|
|
||||||
bool loadFromStream(Common::SeekableReadStream &stream);
|
bool loadFromStream(Common::SeekableReadStream &stream);
|
||||||
|
bool loadRoom(byte *roomData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -109,11 +125,11 @@ public:
|
||||||
return Detail::LittleEndianReader<T>(&_data[address]);
|
return Detail::LittleEndianReader<T>(&_data[address]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//uint32 getRoomTableOffset();
|
|
||||||
uint32 getStartGameOffset();
|
uint32 getStartGameOffset();
|
||||||
int16 getLightX(int locationNr);
|
int16 getLightX(int locationNr);
|
||||||
int16 getLightY(int locationNr);
|
int16 getLightY(int locationNr);
|
||||||
int32 getShadowScale(int locationNr);
|
int32 getShadowScale(int locationNr);
|
||||||
|
uint8 *getRoomOffset(int locationNr);
|
||||||
|
|
||||||
const char *getString(uint32 offset) {
|
const char *getString(uint32 offset) {
|
||||||
return (const char *)(&_data[offset]);
|
return (const char *)(&_data[offset]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue