Skip to content

Commit

Permalink
PRINCE: code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Zbróg committed Oct 24, 2013
1 parent 29033e3 commit e64c3dc
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 85 deletions.
120 changes: 60 additions & 60 deletions engines/prince/detection.cpp
Expand Up @@ -28,67 +28,67 @@
namespace Prince {

struct PrinceGameDescription {
ADGameDescription desc;
ADGameDescription desc;

int gameType;
int gameType;
};

int PrinceEngine::getGameType() const {
return _gameDescription->gameType;
return _gameDescription->gameType;
}

const char *PrinceEngine::getGameId() const {
return _gameDescription->desc.gameid;
return _gameDescription->desc.gameid;
}

uint32 PrinceEngine::getFeatures() const {
return _gameDescription->desc.flags;
return _gameDescription->desc.flags;
}

Common::Language PrinceEngine::getLanguage() const {
return _gameDescription->desc.language;
return _gameDescription->desc.language;
}

}

static const PlainGameDescriptor princeGames[] = {
{"prince", "Prince Game"},
{0, 0}
{"prince", "Prince Game"},
{0, 0}
};

namespace Prince {

static const PrinceGameDescription gameDescriptions[] = {

// German
{
{
"prince",
"Galador",
AD_ENTRY1s("databank.ptc", "5fa03833177331214ec1354761b1d2ee", 3565031),
Common::DE_DEU,
Common::kPlatformWindows,
ADGF_NO_FLAGS,
GUIO1(GUIO_NONE)
},
0
},
{
{
"prince",
"Galador",
AD_ENTRY1s("databank.ptc", "5fa03833177331214ec1354761b1d2ee", 3565031),
Common::DE_DEU,
Common::kPlatformWindows,
ADGF_NO_FLAGS,
GUIO1(GUIO_NONE)
},
0
},
// Polish
{
{
"prince",
"Ksiaze i Tchorz",
AD_ENTRY1s("databank.ptc", "48ec9806bda9d152acbea8ce31c93c49", 3435298),
Common::PL_POL,
Common::kPlatformWindows,
ADGF_NO_FLAGS,
GUIO1(GUIO_NONE)
},
1
},


{ AD_TABLE_END_MARKER, 0 }
{
{
"prince",
"Ksiaze i Tchorz",
AD_ENTRY1s("databank.ptc", "48ec9806bda9d152acbea8ce31c93c49", 3435298),
Common::PL_POL,
Common::kPlatformWindows,
ADGF_NO_FLAGS,
GUIO1(GUIO_NONE)
},
1
},


{ AD_TABLE_END_MARKER, 0 }
};

} // End of namespace Prince
Expand All @@ -97,45 +97,45 @@ using namespace Prince;

// we match from data too, to stop detection from a non-top-level directory
const static char *directoryGlobs[] = {
"all",
0
"all",
0
};

class PrinceMetaEngine : public AdvancedMetaEngine {
public:
PrinceMetaEngine() : AdvancedMetaEngine(Prince::gameDescriptions, sizeof(Prince::PrinceGameDescription), princeGames) {
_singleid = "prince";
_maxScanDepth = 2;
_directoryGlobs = directoryGlobs;
}

virtual const char *getName() const {
return "Prince Engine";
}

virtual const char *getOriginalCopyright() const {
return "Copyright (C)";
}

virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
virtual bool hasFeature(MetaEngineFeature f) const;
PrinceMetaEngine() : AdvancedMetaEngine(Prince::gameDescriptions, sizeof(Prince::PrinceGameDescription), princeGames) {
_singleid = "prince";
_maxScanDepth = 2;
_directoryGlobs = directoryGlobs;
}

virtual const char *getName() const {
return "Prince Engine";
}

virtual const char *getOriginalCopyright() const {
return "Copyright (C)";
}

virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
virtual bool hasFeature(MetaEngineFeature f) const;
};

bool PrinceMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
using namespace Prince;
const PrinceGameDescription *gd = (const PrinceGameDescription *)desc;
if (gd) {
*engine = new PrinceEngine(syst, gd);
}
return gd != 0;
const PrinceGameDescription *gd = (const PrinceGameDescription *)desc;
if (gd) {
*engine = new PrinceEngine(syst, gd);
}
return gd != 0;
}

bool PrinceMetaEngine::hasFeature(MetaEngineFeature f) const {
return false;
return false;
}

bool Prince::PrinceEngine::hasFeature(EngineFeature f) const {
return false;//(f == kSupportsRTL);
return false;//(f == kSupportsRTL);
}

#if PLUGIN_ENABLED_DYNAMIC(PRINCE)
Expand Down
9 changes: 3 additions & 6 deletions engines/prince/graphics.cpp
Expand Up @@ -38,13 +38,10 @@ void GraphicsMan::draw(const Graphics::Surface *s)

void GraphicsMan::drawTransparent(const Graphics::Surface *s)
{
for (uint y = 0; y < 480; ++y)
{
for (uint x = 0; x < 640; ++x)
{
for (uint y = 0; y < 480; ++y) {
for (uint x = 0; x < 640; ++x) {
byte pixel = *((byte*)s->getBasePtr(x,y));
if (pixel != 255)
{
if (pixel != 255) {
*((byte*)_frontScreen->getBasePtr(x, y)) = pixel;
}
}
Expand Down
28 changes: 9 additions & 19 deletions engines/prince/prince.cpp
Expand Up @@ -67,13 +67,11 @@ PrinceEngine::~PrinceEngine() {
delete _debugger;
}

GUI::Debugger *PrinceEngine::getDebugger()
{
GUI::Debugger *PrinceEngine::getDebugger() {
return _debugger;
}

Common::Error PrinceEngine::run() {

_graph = new GraphicsMan(this);

const Common::FSNode gameDataDir(ConfMan.get("path"));
Expand Down Expand Up @@ -127,8 +125,7 @@ Common::Error PrinceEngine::run() {
return Common::kNoError;
}

bool PrinceEngine::loadLocation(uint16 locationNr)
{
bool PrinceEngine::loadLocation(uint16 locationNr) {
debug("PrinceEngine::loadLocation %d", locationNr);
const Common::FSNode gameDataDir(ConfMan.get("path"));
SearchMan.remove(Common::String::format("%02d", _locationNr));
Expand All @@ -141,14 +138,12 @@ bool PrinceEngine::loadLocation(uint16 locationNr)
// load location background
Common::SeekableReadStream *room = SearchMan.createReadStreamForMember("room");

if (!room)
{
if (!room) {
error("Can't load room bitmap");
return false;
}

if(_roomBmp.loadStream(*room))
{
if(_roomBmp.loadStream(*room)) {
debug("Room bitmap loaded");
_system->getPaletteManager()->setPalette(_roomBmp.getPalette(), 0, 256);
}
Expand All @@ -158,31 +153,26 @@ bool PrinceEngine::loadLocation(uint16 locationNr)
return true;
}

bool PrinceEngine::playNextFrame()
{
bool PrinceEngine::playNextFrame() {
const Graphics::Surface *s = _flicPlayer.decodeNextFrame();
if (s)
{
if (s) {
_graph->drawTransparent(s);
_graph->change();
}

return true;
}

bool PrinceEngine::loadAnim(uint16 animNr)
{
bool PrinceEngine::loadAnim(uint16 animNr) {
Common::String streamName = Common::String::format("AN%02d", animNr);
Common::SeekableReadStream * flicStream = SearchMan.createReadStreamForMember(streamName);

if (!flicStream)
{
if (!flicStream) {
error("Can't open %s", streamName.c_str());
return false;
}

if (!_flicPlayer.loadStream(flicStream))
{
if (!_flicPlayer.loadStream(flicStream)) {
error("Can't load flic stream %s", streamName.c_str());
}

Expand Down

0 comments on commit e64c3dc

Please sign in to comment.