PINK: Initial commit

Implemented skeleton of engine, detection, broFile and started orbFile
implementation.
This commit is contained in:
whitertandrek 2018-03-15 22:02:52 +02:00 committed by Eugene Sandulenko
parent a95d133e54
commit 280b249657
8 changed files with 546 additions and 0 deletions

View File

@ -0,0 +1,3 @@
# This file is included from the main "configure" script
# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
add_engine pink "Pink Panther" no "" "" ""

41
engines/pink/console.h Normal file
View File

@ -0,0 +1,41 @@
/* 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 PINK_CONSOLE_H
#define PINK_CONSOLE_H
#include "gui/debugger.h"
namespace Pink {
class PinkEngine;
class Console : public GUI::Debugger {
public:
Console(PinkEngine *vm) {}
virtual ~Console(void) {}
};
} // End of namespace Pink
#endif

View File

@ -0,0 +1,96 @@
/* 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 <gui/EventRecorder.h>
#include "pink.h"
static const PlainGameDescriptor pinkGames[] = {
{"peril", "The Pink Panther: Passport to Peril"},
{"pokus", "The Pink Panther: Hokus Pokus Pink"},
{0, 0}
};
namespace Pink {
static const ADGameDescription gameDescriptions[] = {
{
"peril",
0,{
{"PPTP.ORB", NULL, NULL, -1},
{"PPTP.BRO", NULL, NULL, -1},
AD_LISTEND},
Common::RU_RUS,
Common::kPlatformWindows,
ADGF_UNSTABLE,
GUIO1(GUIO_NONE)
},
{
"peril",
0,
AD_ENTRY1s("hpp.ORB", NULL, -1),
Common::RU_RUS,
Common::kPlatformWindows,
ADGF_UNSTABLE,
GUIO1(GUIO_NONE)
},
AD_TABLE_END_MARKER
};
} // End of namespace Pink
class PinkMetaEngine : public AdvancedMetaEngine {
public:
PinkMetaEngine() : AdvancedMetaEngine(Pink::gameDescriptions, sizeof(ADGameDescription), pinkGames) {
_gameIds = pinkGames;
}
virtual const char *getName() const {
return "Pink Panther Engine";
}
virtual const char *getOriginalCopyright() const {
return "Pink Panther Engine (C) Wanderlust Interactive";
}
//virtual bool hasFeature(MetaEngineFeature f) const;
//virtual int getMaximumSaveSlot() const { return 0; }
//virtual SaveStateList listSaves(const char *target) const;
//virtual void removeSaveState(const char *target, int slot) const;
//virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
};
bool PinkMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
if (desc) {
*engine = new Pink::PinkEngine(syst, desc);
}
return desc != 0;
}
#if PLUGIN_ENABLED_DYNAMIC(PINK)
REGISTER_PLUGIN_DYNAMIC(PINK, PLUGIN_TYPE_ENGINE, PinkMetaEngine);
#else
REGISTER_PLUGIN_STATIC(PINK, PLUGIN_TYPE_ENGINE, PinkMetaEngine);
#endif

120
engines/pink/file.cpp Normal file
View File

@ -0,0 +1,120 @@
/* 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 <common/str.h>
#include "pink.h"
namespace Pink {
OrbFile::OrbFile()
: File(), _timestamp(0),
_tableOffset(0),
_tableSize(0),
_table(nullptr)
{}
OrbFile::~OrbFile() {
delete[] _table;
}
bool OrbFile::open(Common::String &name) {
if (!File::open(name))
return false;
if (readUint32BE() != 'ORB\0'){
close();
return false;
}
uint16 minor = readUint16LE();
uint16 major = readUint16LE();
//output
if (minor || major != 2){
return false;
}
_timestamp = readUint32LE();
if (!_timestamp){
return false;
}
//convert to date
//output into debug
_tableOffset = readUint32LE();
_tableSize = readUint32LE();
_table = new ObjectDescription[_tableSize];
for (size_t i = 0; i < _tableSize; ++i) {
_table[i].deserialize(*this);
}
return true;
}
void OrbFile::LoadGame(PinkEngine *game) {
}
void OrbFile::LoadObject(void *obj, Common::String &name) {
}
uint32 OrbFile::getTimestamp() {
return _timestamp;
}
bool BroFile::open(Common::String &name, uint32 orbTimestamp) {
if (!File::open(name) || readUint32BE() != 'BRO\0')
return false;
uint16 minor = readUint16LE();
uint16 major = readUint16LE();
// do output
if (minor || major != 1){
return false;
}
uint32 _timestamp = readUint32LE();
return _timestamp == orbTimestamp;
}
void ObjectDescription::deserialize(Common::File &file) {
file.read(name, sizeof(name));
file.read(&objectsOffset, sizeof(objectsOffset));
file.read(&objectsCount, sizeof(objectsCount));
file.read(&resourcesOffset, sizeof(resourcesOffset));
file.read(&resourcesCount, sizeof(resourcesCount));
}
void ResourseDescription::deserialize(Common::File &file) {
file.read(name, sizeof(name));
file.read(&offset, sizeof(offset));
file.read(&size, sizeof(offset));
uint16 temp;
file.read(&temp, sizeof(temp));
InBro = temp ? true : false;
}
} // End of namespace Pink

81
engines/pink/file.h Normal file
View File

@ -0,0 +1,81 @@
/* 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 PINK_FILE_H
#define PINK_FILE_H
#include <common/file.h>
namespace Pink {
struct ObjectDescription {
void deserialize(Common::File &file);
char name[16];
uint32 objectsOffset;
uint32 objectsCount;
uint32 resourcesOffset;
uint32 resourcesCount;
};
struct ResourseDescription {
void deserialize(Common::File &file);
char name[16];
uint32 offset;
uint32 size;
bool InBro; // in original it is short.
// Don't know what's better to use.(Perhaps no diffrence because of padding)
};
class PinkEngine;
class OrbFile : public Common::File {
public:
OrbFile();
virtual ~OrbFile();
virtual bool open(Common::String &name);
void LoadGame(PinkEngine *game);
void LoadObject(void *obj, Common::String &name);
uint32 getTimestamp();
private:
uint32 _timestamp;
uint32 _tableOffset;
uint32 _tableSize;
ObjectDescription *_table;
};
class BroFile : public Common::File {
public:
BroFile() = default;
virtual ~BroFile() = default;
virtual bool open(Common::String &name, uint32 orbId);
};
} // End of namespace Pink
#endif

18
engines/pink/module.mk Normal file
View File

@ -0,0 +1,18 @@
MODULE := engines/pink
MODULE_OBJS = \
pink.o \
console.o \
detection.o \
director.o \
sound.o \
file.o \
# This module can be built as a plugin
ifeq ($(ENABLE_PLUMBERS), DYNAMIC_PLUGIN)
PLUGIN := 1
endif
# Include common rules
include $(srcdir)/rules.mk

103
engines/pink/pink.cpp Normal file
View File

@ -0,0 +1,103 @@
/* 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 "pink.h"
#include "console.h"
#include <audio/mixer.h>
#include <engines/util.h>
namespace Pink {
Pink::PinkEngine::PinkEngine(OSystem *system, const ADGameDescription *desc)
: Engine(system), _rnd("pink"), _desc(*desc),
_bro(nullptr)
{
/* TODO
* setup debug channels
*
*/
}
Pink::PinkEngine::~PinkEngine() {
delete _console;
delete _bro;
}
Common::Error PinkEngine::init() {
initGraphics(640, 480);
_console = new Console(this);
if (_desc.filesDescriptions[1].fileName){
_bro = new BroFile();
}
Common::String orbName = _desc.filesDescriptions[0].fileName;
Common::String broName = _desc.filesDescriptions[1].fileName;
if (!_orb.open(orbName) || (_bro && !_bro->open(broName, _orb.getTimestamp()))){
return Common::kNoGameDataFoundError;
}
return Common::kNoError;
}
Common::Error Pink::PinkEngine::run() {
Common::Error error = init();
if (error.getCode() != Common::kNoError){
return error;
}
while(!shouldQuit()){
Common::Event event;
while(_eventMan->pollEvent(event)){
switch (event.type){
case Common::EVENT_QUIT:
case Common::EVENT_RTL:
return Common::kNoError;
case Common::EVENT_MOUSEMOVE:
break;
case Common::EVENT_LBUTTONDOWN:
break;
// don't know why it is used in orginal
case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONDOWN:
case Common::EVENT_KEYDOWN:
break;
default:
break;
}
}
//update();
g_system->updateScreen();
g_system->delayMillis(10);
}
return Common::kNoError;
}
}

84
engines/pink/pink.h Normal file
View File

@ -0,0 +1,84 @@
/* 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 PINK_PINK_H
#define PINK_PINK_H
#include "common/random.h"
#include "engines/engine.h"
#include "gui/EventRecorder.h"
#include "gui/debugger.h"
#include "file.h"
/*
* This is the namespace of the Pink engine.
*
* Status of this engine: In Development
*
* Internal name of original name: OxCart Runtime
*
* Games using this engine:
* - The Pink Panther: Passport to Peril
* - The Pink Panther: Hokus Pokus Pink
*/
namespace Pink {
class Console;
enum {
kPinkDebugGeneral = 1 << 0,
kPinkDebugLoading = 1 << 1,
kPinkDebugSound = 1 << 2
};
class PinkEngine : public Engine {
public:
PinkEngine(OSystem *system, const ADGameDescription *desc);
~PinkEngine();
virtual Common::Error run();
private:
Common::Error init();
void handleEvent(Common::Event &event);
void update();
Console *_console;
Common::RandomSource _rnd;
Common::String _nextModule;
Common::String _nextPage;
OrbFile _orb;
BroFile *_bro;
const ADGameDescription _desc;
};
} // End of namespace Pink
#endif