2013-10-30 02:28:07 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PRINCE_H
|
|
|
|
#define PRINCE_H
|
|
|
|
|
|
|
|
#include "common/random.h"
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "common/debug.h"
|
|
|
|
#include "common/debug-channels.h"
|
|
|
|
#include "common/textconsole.h"
|
|
|
|
#include "common/rect.h"
|
|
|
|
#include "common/events.h"
|
2014-05-31 20:57:46 +02:00
|
|
|
#include "common/endian.h"
|
2013-10-30 02:28:07 +00:00
|
|
|
|
2014-03-29 22:23:20 +01:00
|
|
|
#include "image/bmp.h"
|
2013-10-30 02:28:07 +00:00
|
|
|
|
|
|
|
#include "gui/debugger.h"
|
|
|
|
|
|
|
|
#include "engines/engine.h"
|
|
|
|
#include "engines/util.h"
|
|
|
|
|
|
|
|
#include "audio/mixer.h"
|
|
|
|
|
|
|
|
#include "video/flic_decoder.h"
|
|
|
|
|
2013-11-08 23:17:20 +00:00
|
|
|
#include "prince/mob.h"
|
|
|
|
#include "prince/object.h"
|
2014-06-01 20:44:04 +02:00
|
|
|
#include "prince/pscr.h"
|
2013-11-08 23:17:20 +00:00
|
|
|
|
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
namespace Prince {
|
2013-11-10 22:49:34 +00:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
struct PrinceGameDescription;
|
|
|
|
|
|
|
|
class PrinceEngine;
|
|
|
|
class GraphicsMan;
|
|
|
|
class Script;
|
2013-12-10 00:26:42 +00:00
|
|
|
class Interpreter;
|
|
|
|
class InterpreterFlags;
|
2013-10-30 02:28:07 +00:00
|
|
|
class Debugger;
|
|
|
|
class MusicPlayer;
|
|
|
|
class VariaTxt;
|
2013-11-05 21:20:46 +00:00
|
|
|
class Cursor;
|
|
|
|
class MhwanhDecoder;
|
|
|
|
class Font;
|
2013-12-03 14:46:24 +00:00
|
|
|
class Hero;
|
2014-04-04 16:16:15 +02:00
|
|
|
class Animation;
|
2014-05-17 23:25:31 +02:00
|
|
|
class Room;
|
2014-06-01 20:44:04 +02:00
|
|
|
class Pscr;
|
2013-10-30 02:28:07 +00:00
|
|
|
|
2013-11-02 01:29:26 +00:00
|
|
|
struct Text {
|
|
|
|
const char *_str;
|
|
|
|
uint16 _x, _y;
|
|
|
|
uint16 _time;
|
|
|
|
uint32 _color;
|
|
|
|
|
|
|
|
Text() : _str(NULL), _x(0), _y(0), _time(0), _color(255){
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-12-05 00:02:31 +00:00
|
|
|
struct AnimListItem {
|
2014-05-24 16:35:16 +02:00
|
|
|
uint16 _type; // type of animation - for background anims RND of frame
|
2013-12-05 00:02:31 +00:00
|
|
|
uint16 _fileNumber;
|
2014-05-24 16:35:16 +02:00
|
|
|
uint16 _startPhase; // first phase number
|
2013-12-05 00:02:31 +00:00
|
|
|
uint16 _endPhase;
|
|
|
|
uint16 _loopPhase;
|
|
|
|
int16 _x;
|
|
|
|
int16 _y;
|
|
|
|
uint16 _loopType;
|
2014-05-24 16:35:16 +02:00
|
|
|
uint16 _nextAnim; // number of animation to do for loop = 3
|
2014-05-30 23:36:49 +02:00
|
|
|
uint16 _flags; // byte 0 - draw masks, byte 1 - draw in front of mask, byte 2 - load but turn off drawing
|
2013-12-05 00:02:31 +00:00
|
|
|
bool loadFromStream(Common::SeekableReadStream &stream);
|
|
|
|
};
|
|
|
|
|
2014-05-22 19:52:38 +02:00
|
|
|
struct BAS {
|
|
|
|
int32 _type; // type of sequence
|
|
|
|
int32 _data; // additional data
|
|
|
|
int32 _anims; // number of animations
|
|
|
|
int32 _current; // actual number of animation
|
|
|
|
int32 _counter; // time counter for animation
|
|
|
|
int32 _currRelative; //actual relative number for animation
|
|
|
|
int32 _data2; // additional data for measurements
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BASA {
|
|
|
|
int16 _num; // animation number
|
|
|
|
int16 _start; // initial frame
|
|
|
|
int16 _end; // final frame
|
|
|
|
int16 _pad; // fulfilment to 8 bytes
|
|
|
|
};
|
|
|
|
|
|
|
|
// background and normal animation
|
|
|
|
struct Anim {
|
2014-05-26 19:16:31 +02:00
|
|
|
BASA _basaData;
|
2014-05-22 19:52:38 +02:00
|
|
|
int32 _addr; //animation adress
|
|
|
|
int16 _usage;
|
|
|
|
int16 _state; // state of animation: 0 - turning on, 1 - turning off
|
|
|
|
int16 _flags;
|
|
|
|
int16 _frame; // number of phase to show
|
|
|
|
int16 _lastFrame; // last phase
|
|
|
|
int16 _loopFrame; // first frame of loop
|
|
|
|
int16 _showFrame; // actual visible frame of animation
|
|
|
|
int16 _loopType; // type of loop (0 - last frame; 1 - normal loop (begin from _loopFrame); 2 - no loop; 3 - load new animation)
|
|
|
|
int16 _nextAnim; // number of next animation to load after actual
|
|
|
|
int16 _x;
|
|
|
|
int16 _y;
|
|
|
|
int32 _currFrame;
|
|
|
|
int16 _currX;
|
|
|
|
int16 _currY;
|
|
|
|
int16 _currW;
|
|
|
|
int16 _currH;
|
|
|
|
int16 _packFlag;
|
|
|
|
int32 _currShadowFrame;
|
|
|
|
int16 _packShadowFlag;
|
|
|
|
int32 _shadowBack;
|
|
|
|
int16 _relX;
|
|
|
|
int16 _relY;
|
|
|
|
Animation *_animData;
|
|
|
|
Animation *_shadowData;
|
|
|
|
};
|
|
|
|
|
2014-05-23 21:24:05 +02:00
|
|
|
struct BackgroundAnim {
|
|
|
|
BAS _seq;
|
|
|
|
Common::Array<Anim> backAnims;
|
|
|
|
};
|
|
|
|
|
2014-05-30 22:05:40 +02:00
|
|
|
// Nak (PL - Nakladka)
|
2014-05-30 23:36:49 +02:00
|
|
|
struct Mask {
|
2014-05-30 22:05:40 +02:00
|
|
|
int16 _state; // visible / invisible
|
2014-05-30 23:36:49 +02:00
|
|
|
int16 _flags; // turning on / turning off of an mask
|
2014-05-30 22:05:40 +02:00
|
|
|
int16 _x1;
|
|
|
|
int16 _y1;
|
|
|
|
int16 _x2;
|
|
|
|
int16 _y2;
|
|
|
|
int16 _z;
|
|
|
|
int16 _number; // number of mask for background recreating
|
2014-05-31 16:45:10 +02:00
|
|
|
int16 _width;
|
|
|
|
int16 _height;
|
2014-05-30 23:36:49 +02:00
|
|
|
byte *_data;
|
2014-05-31 16:45:10 +02:00
|
|
|
|
2014-05-31 23:24:36 +02:00
|
|
|
int16 getX() const {
|
2014-05-31 16:45:10 +02:00
|
|
|
return READ_LE_UINT16(_data);
|
|
|
|
}
|
|
|
|
|
2014-05-31 23:24:36 +02:00
|
|
|
int16 getY() const {
|
2014-05-31 16:45:10 +02:00
|
|
|
return READ_LE_UINT16(_data + 2);
|
|
|
|
}
|
|
|
|
|
2014-05-31 23:24:36 +02:00
|
|
|
int16 getWidth() const {
|
2014-05-31 16:45:10 +02:00
|
|
|
return READ_LE_UINT16(_data + 4);
|
|
|
|
}
|
|
|
|
|
2014-05-31 23:24:36 +02:00
|
|
|
int16 getHeight() const {
|
2014-05-31 16:45:10 +02:00
|
|
|
return READ_LE_UINT16(_data + 6);
|
|
|
|
}
|
2014-06-01 02:58:27 +02:00
|
|
|
|
2014-05-31 23:24:36 +02:00
|
|
|
byte *getMask() const {
|
2014-05-31 16:45:10 +02:00
|
|
|
return (byte *)(_data + 8);
|
|
|
|
}
|
2014-05-30 22:05:40 +02:00
|
|
|
};
|
|
|
|
|
2014-06-06 00:01:08 +02:00
|
|
|
struct InvItem {
|
|
|
|
Graphics::Surface *_surface;
|
|
|
|
Graphics::Surface *getSurface() const { return _surface; }
|
|
|
|
};
|
|
|
|
|
2014-06-02 18:19:02 +02:00
|
|
|
struct DrawNode {
|
|
|
|
int posX;
|
|
|
|
int posY;
|
|
|
|
int posZ;
|
|
|
|
int32 width;
|
|
|
|
int32 height;
|
|
|
|
Graphics::Surface *s;
|
|
|
|
Graphics::Surface *originalRoomSurface;
|
|
|
|
byte *data;
|
|
|
|
bool freeSurfaceSMemory;
|
|
|
|
void (*drawFunction)(Graphics::Surface *, DrawNode *);
|
|
|
|
};
|
|
|
|
|
2013-11-02 01:29:26 +00:00
|
|
|
struct DebugChannel {
|
|
|
|
|
|
|
|
enum Type {
|
|
|
|
kScript,
|
|
|
|
kEngine
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
class PrinceEngine : public Engine {
|
|
|
|
protected:
|
|
|
|
Common::Error run();
|
|
|
|
|
|
|
|
public:
|
|
|
|
PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc);
|
|
|
|
virtual ~PrinceEngine();
|
|
|
|
|
|
|
|
virtual bool hasFeature(EngineFeature f) const;
|
|
|
|
|
|
|
|
int getGameType() const;
|
|
|
|
const char *getGameId() const;
|
|
|
|
uint32 getFeatures() const;
|
|
|
|
Common::Language getLanguage() const;
|
|
|
|
|
|
|
|
const PrinceGameDescription *_gameDescription;
|
|
|
|
Video::FlicDecoder _flicPlayer;
|
|
|
|
VariaTxt *_variaTxt;
|
|
|
|
|
|
|
|
uint32 _talkTxtSize;
|
|
|
|
byte *_talkTxt;
|
|
|
|
|
|
|
|
bool loadLocation(uint16 locationNr);
|
|
|
|
bool loadAnim(uint16 animNr, bool loop);
|
2013-12-03 14:46:24 +00:00
|
|
|
bool loadVoice(uint32 textSlot, uint32 sampleSlot, const Common::String &name);
|
|
|
|
bool loadSample(uint32 sampleSlot, const Common::String &name);
|
2014-05-30 20:15:00 +02:00
|
|
|
bool loadZoom(byte *zoomBitmap, uint32 dataSize, const char *resourceName);
|
2014-05-15 15:12:56 +02:00
|
|
|
bool loadShadow(byte *shadowBitmap, uint32 dataSize, const char *resourceName1, const char *resourceName2);
|
2013-11-05 22:15:55 +00:00
|
|
|
|
|
|
|
void playSample(uint16 sampleId, uint16 loopType);
|
|
|
|
void stopSample(uint16 sampleId);
|
2013-10-30 02:28:07 +00:00
|
|
|
|
|
|
|
virtual GUI::Debugger *getDebugger();
|
|
|
|
|
|
|
|
void changeCursor(uint16 curId);
|
2013-11-02 01:29:26 +00:00
|
|
|
void printAt(uint32 slot, uint8 color, const char *s, uint16 x, uint16 y);
|
2013-10-30 02:28:07 +00:00
|
|
|
|
2013-11-02 01:29:26 +00:00
|
|
|
static const uint8 MAXTEXTS = 32;
|
|
|
|
Text _textSlots[MAXTEXTS];
|
2013-10-30 02:28:07 +00:00
|
|
|
|
2013-11-02 15:28:56 +00:00
|
|
|
uint64 _frameNr;
|
2014-05-07 21:55:25 +02:00
|
|
|
Hero *_mainHero;
|
|
|
|
Hero *_secondHero;
|
2013-11-02 15:28:56 +00:00
|
|
|
|
2014-05-04 18:02:53 +02:00
|
|
|
uint16 _sceneWidth;
|
2014-05-27 21:19:24 +02:00
|
|
|
int32 _picWindowX;
|
|
|
|
int32 _picWindowY;
|
2014-05-14 00:21:59 +02:00
|
|
|
Image::BitmapDecoder *_roomBmp;
|
2014-05-04 18:02:53 +02:00
|
|
|
|
2014-05-22 19:52:38 +02:00
|
|
|
Common::Array<AnimListItem> _animList;
|
2014-05-23 21:24:05 +02:00
|
|
|
Common::Array<BackgroundAnim> _backAnimList;
|
2014-05-22 19:52:38 +02:00
|
|
|
|
2014-05-26 19:16:31 +02:00
|
|
|
Common::RandomSource _randomSource;
|
|
|
|
|
2014-05-27 16:29:08 +02:00
|
|
|
static const int16 kNormalWidth = 640;
|
|
|
|
static const int16 kNormalHeight = 480;
|
2014-06-01 04:26:41 +02:00
|
|
|
static const int16 kMaxPicWidth = 1280;
|
|
|
|
static const int16 kMaxPicHeight = 480;
|
2014-05-27 16:29:08 +02:00
|
|
|
|
2014-05-30 23:36:49 +02:00
|
|
|
void checkMasks(int x1, int y1, int sprWidth, int sprHeight, int z);
|
2014-06-02 18:19:02 +02:00
|
|
|
void insertMasks(Graphics::Surface *originalRoomSurface);
|
|
|
|
void showMask(int maskNr, Graphics::Surface *originalRoomSurface);
|
2014-06-01 14:35:50 +02:00
|
|
|
void clsMasks();
|
2014-05-30 22:05:40 +02:00
|
|
|
|
2014-06-06 00:01:08 +02:00
|
|
|
static const int16 kMaxInv = 90; // max amount of inventory items in whole game
|
|
|
|
|
2014-06-05 21:09:43 +02:00
|
|
|
uint32 _invTxtSize;
|
|
|
|
byte *_invTxt;
|
|
|
|
|
|
|
|
int _invLineX;
|
|
|
|
int _invLineY;
|
2014-06-06 00:01:08 +02:00
|
|
|
int _invLine; // number of items in one line
|
|
|
|
int _invLines; // number of lines with inventory items
|
2014-06-05 21:09:43 +02:00
|
|
|
int _invLineW;
|
|
|
|
int _invLineH;
|
|
|
|
int _maxInvW;
|
|
|
|
int _invLineSkipX;
|
|
|
|
int _invLineSkipY;
|
|
|
|
|
2014-06-06 00:01:08 +02:00
|
|
|
bool loadAllInv();
|
2014-06-05 21:09:43 +02:00
|
|
|
void rememberScreenInv();
|
|
|
|
void prepareInventoryToView();
|
2014-06-06 00:01:08 +02:00
|
|
|
void drawInvItems();
|
2014-06-05 21:09:43 +02:00
|
|
|
void displayInventory();
|
|
|
|
|
2014-05-22 19:52:38 +02:00
|
|
|
int testAnimNr;
|
|
|
|
int testAnimFrame;
|
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
private:
|
|
|
|
bool playNextFrame();
|
|
|
|
void keyHandler(Common::Event event);
|
|
|
|
void hotspot();
|
|
|
|
void drawScreen();
|
2013-11-02 01:29:26 +00:00
|
|
|
void showTexts();
|
2013-11-08 23:17:20 +00:00
|
|
|
void init();
|
|
|
|
void showLogo();
|
2014-05-23 21:24:05 +02:00
|
|
|
void showBackAnims();
|
2014-05-30 19:44:43 +02:00
|
|
|
void clearBackAnimList();
|
2014-05-31 20:57:46 +02:00
|
|
|
bool spriteCheck(int sprWidth, int sprHeight, int destX, int destY);
|
2014-06-02 18:19:02 +02:00
|
|
|
void showSprite(Graphics::Surface *spriteSurface, int destX, int destY, int destZ, bool freeSurfaceMemory);
|
|
|
|
void showSpriteShadow(Graphics::Surface *shadowSurface, int destX, int destY, int destZ, bool freeSurfaceMemory);
|
2014-06-01 02:58:27 +02:00
|
|
|
void showObjects();
|
2014-06-01 20:44:04 +02:00
|
|
|
void showParallax();
|
2014-06-02 18:19:02 +02:00
|
|
|
static bool compareDrawNodes(DrawNode d1, DrawNode d2);
|
|
|
|
void runDrawNodes();
|
|
|
|
void freeDrawNodes();
|
2014-05-02 22:31:18 +02:00
|
|
|
void makeShadowTable(int brightness);
|
2013-10-30 02:28:07 +00:00
|
|
|
|
|
|
|
uint32 getTextWidth(const char *s);
|
2013-11-05 18:45:40 +00:00
|
|
|
void debugEngine(const char *s, ...);
|
2013-10-30 02:28:07 +00:00
|
|
|
|
|
|
|
uint16 _locationNr;
|
2013-11-11 12:00:19 +00:00
|
|
|
uint8 _cursorNr;
|
2013-10-30 02:28:07 +00:00
|
|
|
|
2013-11-05 21:20:46 +00:00
|
|
|
Common::RandomSource *_rnd;
|
|
|
|
Cursor *_cursor1;
|
|
|
|
Cursor *_cursor2;
|
2014-05-07 21:55:25 +02:00
|
|
|
MhwanhDecoder *_suitcaseBmp;
|
2013-10-30 02:28:07 +00:00
|
|
|
Debugger *_debugger;
|
|
|
|
GraphicsMan *_graph;
|
|
|
|
Script *_script;
|
2013-12-10 00:26:42 +00:00
|
|
|
InterpreterFlags *_flags;
|
|
|
|
Interpreter *_interpreter;
|
2013-11-05 21:20:46 +00:00
|
|
|
Font *_font;
|
2013-10-30 02:28:07 +00:00
|
|
|
MusicPlayer *_midiPlayer;
|
2014-05-17 23:25:31 +02:00
|
|
|
Room *_room;
|
2013-12-03 14:46:24 +00:00
|
|
|
|
|
|
|
static const uint32 MAX_SAMPLES = 60;
|
|
|
|
Common::SeekableReadStream *_voiceStream[MAX_SAMPLES];
|
|
|
|
Audio::SoundHandle _soundHandle[MAX_SAMPLES];
|
|
|
|
|
2014-04-04 16:16:15 +02:00
|
|
|
Animation *_zoom;
|
2014-06-01 20:44:04 +02:00
|
|
|
Common::Array<PScr *> _pscrList;
|
2013-11-09 23:07:40 +00:00
|
|
|
Common::Array<Mob> _mobList;
|
2013-11-14 14:44:24 +00:00
|
|
|
Common::Array<Object *> _objList;
|
2014-05-30 23:36:49 +02:00
|
|
|
Common::Array<Mask> _maskList;
|
2014-06-02 18:19:02 +02:00
|
|
|
Common::Array<DrawNode> _drawNodeList;
|
2014-06-06 00:01:08 +02:00
|
|
|
Common::Array<InvItem> _allInvList;
|
2014-06-05 21:09:43 +02:00
|
|
|
Common::Array<Mob> _invMobList;
|
2014-06-02 18:19:02 +02:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
bool _flicLooped;
|
|
|
|
|
|
|
|
void mainLoop();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Prince
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* vim: set tabstop=4 noexpandtab: */
|