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 accb9e1 commit 5357724
Show file tree
Hide file tree
Showing 12 changed files with 267 additions and 212 deletions.
23 changes: 23 additions & 0 deletions engines/prince/archive.cpp
@@ -0,0 +1,23 @@
/* 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.
*
*/

#include "prince/archive.h"
1 change: 1 addition & 0 deletions engines/prince/archive.h
Expand Up @@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#ifndef PRINCE_ARCHIVE_H
#define PRINCE_ARCHIVE_H

Expand Down
98 changes: 49 additions & 49 deletions engines/prince/debugger.cpp
Expand Up @@ -11,7 +11,7 @@
* 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
* 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
Expand All @@ -26,86 +26,86 @@
namespace Prince {

Debugger::Debugger(PrinceEngine *vm) : GUI::Debugger(), _vm(vm) {
DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit));
DCmd_Register("setflag", WRAP_METHOD(Debugger, Cmd_SetFlag));
DCmd_Register("getflag", WRAP_METHOD(Debugger, Cmd_GetFlag));
DCmd_Register("clearflag", WRAP_METHOD(Debugger, Cmd_ClearFlag));
DCmd_Register("viewflc", WRAP_METHOD(Debugger, Cmd_ViewFlc));
DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit));
DCmd_Register("setflag", WRAP_METHOD(Debugger, Cmd_SetFlag));
DCmd_Register("getflag", WRAP_METHOD(Debugger, Cmd_GetFlag));
DCmd_Register("clearflag", WRAP_METHOD(Debugger, Cmd_ClearFlag));
DCmd_Register("viewflc", WRAP_METHOD(Debugger, Cmd_ViewFlc));
}

static int strToInt(const char *s) {
if (!*s)
// No string at all
return 0;
else if (toupper(s[strlen(s) - 1]) != 'H')
// Standard decimal string
return atoi(s);
if (!*s)
// No string at all
return 0;
else if (toupper(s[strlen(s) - 1]) != 'H')
// Standard decimal string
return atoi(s);

// Hexadecimal string
uint tmp = 0;
int read = sscanf(s, "%xh", &tmp);
if (read < 1)
error("strToInt failed on string \"%s\"", s);
return (int)tmp;
// Hexadecimal string
uint tmp = 0;
int read = sscanf(s, "%xh", &tmp);
if (read < 1)
error("strToInt failed on string \"%s\"", s);
return (int)tmp;
}

/*
* This command sets a flag
*/
bool Debugger::Cmd_SetFlag(int argc, const char **argv) {
// Check for a flag to set
if (argc != 2) {
DebugPrintf("Usage: %s <flag number>\n", argv[0]);
return true;
}
// Check for a flag to set
if (argc != 2) {
DebugPrintf("Usage: %s <flag number>\n", argv[0]);
return true;
}

int flagNum = strToInt(argv[1]);
//g_globals->setFlag(flagNum);
return true;
int flagNum = strToInt(argv[1]);
//g_globals->setFlag(flagNum);
return true;
}

/*
* This command gets the value of a flag
*/
bool Debugger::Cmd_GetFlag(int argc, const char **argv) {
// Check for an flag to display
if (argc != 2) {
DebugPrintf("Usage: %s <flag number>\n", argv[0]);
return true;
}
// Check for an flag to display
if (argc != 2) {
DebugPrintf("Usage: %s <flag number>\n", argv[0]);
return true;
}

int flagNum = strToInt(argv[1]);
//DebugPrintf("Value: %d\n", g_globals->getFlag(flagNum));
return true;
int flagNum = strToInt(argv[1]);
//DebugPrintf("Value: %d\n", g_globals->getFlag(flagNum));
return true;
}

/*
* This command clears a flag
*/
bool Debugger::Cmd_ClearFlag(int argc, const char **argv) {
// Check for a flag to clear
if (argc != 2) {
DebugPrintf("Usage: %s <flag number>\n", argv[0]);
return true;
}
// Check for a flag to clear
if (argc != 2) {
DebugPrintf("Usage: %s <flag number>\n", argv[0]);
return true;
}

int flagNum = strToInt(argv[1]);
//g_globals->clearFlag(flagNum);
return true;
int flagNum = strToInt(argv[1]);
//g_globals->clearFlag(flagNum);
return true;
}

/*
* This command starts new flc anim
*/
bool Debugger::Cmd_ViewFlc(int argc, const char **argv) {
// Check for a flag to clear
if (argc != 2) {
DebugPrintf("Usage: %s <anim number>\n", argv[0]);
return true;
}
// Check for a flag to clear
if (argc != 2) {
DebugPrintf("Usage: %s <anim number>\n", argv[0]);
return true;
}

int flagNum = strToInt(argv[1]);
int flagNum = strToInt(argv[1]);
_vm->loadAnim(flagNum);
return true;
return true;
}
}
14 changes: 7 additions & 7 deletions engines/prince/debugger.h
Expand Up @@ -11,7 +11,7 @@
* 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
* 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
Expand All @@ -32,14 +32,14 @@ class PrinceEngine;

class Debugger : public GUI::Debugger {
public:
Debugger(PrinceEngine *vm);
virtual ~Debugger() {} // we need this for __SYMBIAN32__ archaic gcc/UIQ
Debugger(PrinceEngine *vm);
virtual ~Debugger() {} // we need this for __SYMBIAN32__ archaic gcc/UIQ

private:
bool Cmd_SetFlag(int argc, const char **argv);
bool Cmd_GetFlag(int argc, const char **argv);
bool Cmd_ClearFlag(int argc, const char **argv);
bool Cmd_ViewFlc(int argc, const char **argv);
bool Cmd_SetFlag(int argc, const char **argv);
bool Cmd_GetFlag(int argc, const char **argv);
bool Cmd_ClearFlag(int argc, const char **argv);
bool Cmd_ViewFlc(int argc, const char **argv);

PrinceEngine *_vm;
};
Expand Down
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

0 comments on commit 5357724

Please sign in to comment.