Skip to content

Commit

Permalink
ADL: Add support for an early hires1 version
Browse files Browse the repository at this point in the history
  • Loading branch information
waltervn committed Feb 3, 2018
1 parent a063184 commit bdda344
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 72 deletions.
10 changes: 3 additions & 7 deletions engines/adl/adl.cpp
Expand Up @@ -74,10 +74,6 @@ AdlEngine::AdlEngine(OSystem *syst, const AdlGameDescription *gd) :
DebugMan.addDebugChannel(kDebugChannelScript, "Script", "Trace script execution");
}

Common::String AdlEngine::getDiskImageName(byte volume) const {
return Adl::getDiskImageName(_gameDescription->desc, volume);
}

bool AdlEngine::pollEvent(Common::Event &event) const {
_console->onFrame();

Expand Down Expand Up @@ -256,15 +252,15 @@ void AdlEngine::loadWords(Common::ReadStream &stream, WordMap &map, Common::Stri
break;

// WORKAROUND: Missing verb list terminator in hires3
if (_gameDescription->gameType == GAME_TYPE_HIRES3 && index == 72 && synonyms == 0)
if (getGameType() == GAME_TYPE_HIRES3 && index == 72 && synonyms == 0)
return;

// WORKAROUND: Missing noun list terminator in hires3
if (_gameDescription->gameType == GAME_TYPE_HIRES3 && index == 113)
if (getGameType() == GAME_TYPE_HIRES3 && index == 113)
return;

// WORKAROUND: Missing noun list terminator in hires5 region 15
if (_gameDescription->gameType == GAME_TYPE_HIRES5 && _state.region == 15 && index == 81)
if (getGameType() == GAME_TYPE_HIRES5 && _state.region == 15 && index == 81)
return;

for (uint i = 0; i < synonyms; ++i) {
Expand Down
5 changes: 4 additions & 1 deletion engines/adl/adl.h
Expand Up @@ -40,6 +40,7 @@
#include "adl/console.h"
#include "adl/disk.h"
#include "adl/sound.h"
#include "adl/detection.h"

namespace Common {
class ReadStream;
Expand Down Expand Up @@ -241,7 +242,9 @@ friend class Console;
Common::Error saveGameState(int slot, const Common::String &desc);
bool canSaveGameStateCurrently();

Common::String getDiskImageName(byte volume) const;
Common::String getDiskImageName(byte volume) const { return Adl::getDiskImageName(*_gameDescription, volume); }
GameType getGameType() const { return Adl::getGameType(*_gameDescription); }
GameVersion getGameVersion() const { return Adl::getGameVersion(*_gameDescription); }
virtual void gameLoop();
virtual void loadState(Common::ReadStream &stream);
virtual void saveState(Common::WriteStream &stream);
Expand Down
85 changes: 72 additions & 13 deletions engines/adl/detection.cpp
Expand Up @@ -87,8 +87,30 @@ static const PlainGameDescriptor adlGames[] = {
{ 0, 0 }
};

struct AdlGameDescription {
ADGameDescription desc;
GameType gameType;
GameVersion version;
};

static const AdlGameDescription gameFileDescriptions[] = {
{ // Hi-Res Adventure #1: Mystery House - Apple II - 1987 PD release
{ // Hi-Res Adventure #1: Mystery House - Apple II - 2nd release
{
"hires1", 0,
{
{ "ADVENTURE", 0, "22d9e63a11d69fa033ba1738715ad09a", 29952 },
{ "AUTO LOAD OBJ", 0, "f6a6ac60c04c6ba6dff68b92cc279ba2", 12291 },
AD_LISTEND
},
Common::EN_ANY,
Common::kPlatformApple2,
ADGF_NO_FLAGS,
GUIO2(GAMEOPTION_COLOR_DEFAULT_OFF, GAMEOPTION_SCANLINES)
},
GAME_TYPE_HIRES1,
GAME_VER_HR1_COARSE
},
{ // Hi-Res Adventure #1: Mystery House - Apple II - Roberta Williams Anthology
{
"hires1", 0,
{
Expand All @@ -102,9 +124,10 @@ static const AdlGameDescription gameFileDescriptions[] = {
ADGF_NO_FLAGS,
GUIO2(GAMEOPTION_COLOR_DEFAULT_OFF, GAMEOPTION_SCANLINES)
},
GAME_TYPE_HIRES1
GAME_TYPE_HIRES1,
GAME_VER_HR1_PD
},
{ AD_TABLE_END_MARKER, GAME_TYPE_NONE }
{ AD_TABLE_END_MARKER, GAME_TYPE_NONE, GAME_VER_NONE }
};

static const AdlGameDescription gameDiskDescriptions[] = {
Expand All @@ -120,7 +143,23 @@ static const AdlGameDescription gameDiskDescriptions[] = {
ADGF_NO_FLAGS,
GUIO2(GAMEOPTION_COLOR_DEFAULT_OFF, GAMEOPTION_SCANLINES)
},
GAME_TYPE_HIRES1
GAME_TYPE_HIRES1,
GAME_VER_HR1_PD
},
{ // Hi-Res Adventure #1: Mystery House - Apple II - 2nd release
{
"hires1", 0,
{
{ "mysthous", 0, "8df0b3b3e609a2e40237e2419c1cb767", 116480 },
AD_LISTEND
},
Common::EN_ANY,
Common::kPlatformApple2,
ADGF_NO_FLAGS,
GUIO2(GAMEOPTION_COLOR_DEFAULT_OFF, GAMEOPTION_SCANLINES)
},
GAME_TYPE_HIRES1,
GAME_VER_HR1_COARSE
},
{ // Hi-Res Adventure #2: Wizard and the Princess - Apple II - Roberta Williams Anthology
{
Expand All @@ -134,7 +173,8 @@ static const AdlGameDescription gameDiskDescriptions[] = {
ADGF_NO_FLAGS,
GUIO2(GAMEOPTION_COLOR_DEFAULT_ON, GAMEOPTION_SCANLINES)
},
GAME_TYPE_HIRES2
GAME_TYPE_HIRES2,
GAME_VER_NONE
},
{ // Hi-Res Adventure #0: Mission Asteroid - Apple II - Roberta Williams Anthology
{
Expand All @@ -148,7 +188,8 @@ static const AdlGameDescription gameDiskDescriptions[] = {
ADGF_NO_FLAGS,
GUIO2(GAMEOPTION_COLOR_DEFAULT_ON, GAMEOPTION_SCANLINES)
},
GAME_TYPE_HIRES0
GAME_TYPE_HIRES0,
GAME_VER_NONE
},
{ // Hi-Res Adventure #3: Cranston Manor - Apple II
{
Expand All @@ -162,7 +203,8 @@ static const AdlGameDescription gameDiskDescriptions[] = {
ADGF_NO_FLAGS,
GUIO2(GAMEOPTION_COLOR_DEFAULT_ON, GAMEOPTION_SCANLINES)
},
GAME_TYPE_HIRES3
GAME_TYPE_HIRES3,
GAME_VER_NONE
},
{ // Hi-Res Adventure #4: Ulysses and the Golden Fleece - Apple II - Load 'N' Go
{
Expand All @@ -177,7 +219,8 @@ static const AdlGameDescription gameDiskDescriptions[] = {
ADGF_NO_FLAGS,
GUIO2(GAMEOPTION_COLOR_DEFAULT_ON, GAMEOPTION_SCANLINES)
},
GAME_TYPE_HIRES4
GAME_TYPE_HIRES4,
GAME_VER_NONE
},
{ // Hi-Res Adventure #4: Ulysses and the Golden Fleece - Atari 8-bit - Re-release
{
Expand All @@ -194,7 +237,8 @@ static const AdlGameDescription gameDiskDescriptions[] = {
ADGF_UNSTABLE,
GUIO2(GAMEOPTION_COLOR_DEFAULT_ON, GAMEOPTION_SCANLINES)
},
GAME_TYPE_HIRES4
GAME_TYPE_HIRES4,
GAME_VER_NONE
},
{ // Hi-Res Adventure #5: Time Zone - Apple II - Version 1.1 - Roberta Williams Anthology
{
Expand All @@ -219,7 +263,8 @@ static const AdlGameDescription gameDiskDescriptions[] = {
ADGF_NO_FLAGS,
GUIO2(GAMEOPTION_COLOR_DEFAULT_ON, GAMEOPTION_SCANLINES)
},
GAME_TYPE_HIRES5
GAME_TYPE_HIRES5,
GAME_VER_NONE
},
{ // Hi-Res Adventure #6: The Dark Crystal - Apple II - Roberta Williams Anthology
{
Expand All @@ -236,9 +281,10 @@ static const AdlGameDescription gameDiskDescriptions[] = {
ADGF_NO_FLAGS,
GUIO2(GAMEOPTION_COLOR_DEFAULT_ON, GAMEOPTION_SCANLINES)
},
GAME_TYPE_HIRES6
GAME_TYPE_HIRES6,
GAME_VER_NONE
},
{ AD_TABLE_END_MARKER, GAME_TYPE_NONE }
{ AD_TABLE_END_MARKER, GAME_TYPE_NONE, GAME_VER_NONE }
};

struct DiskImageExt {
Expand Down Expand Up @@ -392,7 +438,8 @@ void AdlMetaEngine::removeSaveState(const char *target, int slot) const {
g_system->getSavefileManager()->removeSavefile(fileName);
}

Common::String getDiskImageName(const ADGameDescription &desc, byte volume) {
Common::String getDiskImageName(const AdlGameDescription &adlDesc, byte volume) {
const ADGameDescription &desc = adlDesc.desc;
for (uint i = 0; desc.filesDescriptions[i].fileName; ++i) {
const ADGameFileDescription &fDesc = desc.filesDescriptions[i];

Expand All @@ -413,6 +460,18 @@ Common::String getDiskImageName(const ADGameDescription &desc, byte volume) {
error("Disk volume %d not found", volume);
}

GameType getGameType(const AdlGameDescription &adlDesc) {
return adlDesc.gameType;
}

GameVersion getGameVersion(const AdlGameDescription &adlDesc) {
return adlDesc.version;
}

Common::Platform getPlatform(const AdlGameDescription &adlDesc) {
return adlDesc.desc.platform;
}

bool AdlMetaEngine::addFileProps(const FileMap &allFiles, Common::String fname, ADFilePropertiesMap &filePropsMap) const {
if (filePropsMap.contains(fname))
return true;
Expand Down
17 changes: 11 additions & 6 deletions engines/adl/detection.h
Expand Up @@ -23,8 +23,6 @@
#ifndef ADL_DETECTION_H
#define ADL_DETECTION_H

#include "engines/advancedDetector.h"

namespace Adl {

#define SAVEGAME_VERSION 0
Expand All @@ -41,12 +39,19 @@ enum GameType {
GAME_TYPE_HIRES6
};

struct AdlGameDescription {
ADGameDescription desc;
GameType gameType;
enum GameVersion {
GAME_VER_NONE = 0,
GAME_VER_HR1_SIMI = 0, // On-Line Systems (Simi Valley)
GAME_VER_HR1_COARSE, // On-Line Systems (Coarsegold)
GAME_VER_HR1_PD // Sierra On-Line PD release
};

Common::String getDiskImageName(const ADGameDescription &desc, byte volume);
struct AdlGameDescription;

Common::String getDiskImageName(const AdlGameDescription &adlDesc, byte volume);
GameType getGameType(const AdlGameDescription &desc);
GameVersion getGameVersion(const AdlGameDescription &desc);
Common::Platform getPlatform(const AdlGameDescription &desc);

} // End of namespace Adl

Expand Down
22 changes: 11 additions & 11 deletions engines/adl/disk.cpp
Expand Up @@ -405,15 +405,15 @@ Common::SeekableReadStream *Files_Plain::createReadStream(const Common::String &
return new Common::SeekableSubReadStream(f, offset, f->size(), DisposeAfterUse::YES);
}

Files_DOS33::~Files_DOS33() {
Files_AppleDOS::~Files_AppleDOS() {
delete _disk;
}

Files_DOS33::Files_DOS33() :
Files_AppleDOS::Files_AppleDOS() :
_disk(nullptr) {
}

void Files_DOS33::readSectorList(TrackSector start, Common::Array<TrackSector> &list) {
void Files_AppleDOS::readSectorList(TrackSector start, Common::Array<TrackSector> &list) {
TrackSector index = start;

while (index.track != 0) {
Expand Down Expand Up @@ -445,8 +445,8 @@ void Files_DOS33::readSectorList(TrackSector start, Common::Array<TrackSector> &
}
}

void Files_DOS33::readVTOC() {
Common::ScopedPtr<Common::SeekableReadStream> stream(_disk->createReadStream(0x11, 0x00));
void Files_AppleDOS::readVTOC(uint trackVTOC) {
Common::ScopedPtr<Common::SeekableReadStream> stream(_disk->createReadStream(trackVTOC, 0x00));
stream->readByte();
byte track = stream->readByte();
byte sector = stream->readByte();
Expand Down Expand Up @@ -491,11 +491,11 @@ void Files_DOS33::readVTOC() {
}
}

const DataBlockPtr Files_DOS33::getDataBlock(const Common::String &filename, uint offset) const {
const DataBlockPtr Files_AppleDOS::getDataBlock(const Common::String &filename, uint offset) const {
return Common::SharedPtr<Files::DataBlock>(new Files::DataBlock(this, filename, offset));
}

Common::SeekableReadStream *Files_DOS33::createReadStreamText(const TOCEntry &entry) const {
Common::SeekableReadStream *Files_AppleDOS::createReadStreamText(const TOCEntry &entry) const {
byte *buf = (byte *)malloc(entry.sectors.size() * kSectorSize);
byte *p = buf;

Expand All @@ -520,7 +520,7 @@ Common::SeekableReadStream *Files_DOS33::createReadStreamText(const TOCEntry &en
return new Common::MemoryReadStream(buf, p - buf, DisposeAfterUse::YES);
}

Common::SeekableReadStream *Files_DOS33::createReadStreamBinary(const TOCEntry &entry) const {
Common::SeekableReadStream *Files_AppleDOS::createReadStreamBinary(const TOCEntry &entry) const {
byte *buf = (byte *)malloc(entry.sectors.size() * kSectorSize);

Common::ScopedPtr<Common::SeekableReadStream> stream(_disk->createReadStream(entry.sectors[0].track, entry.sectors[0].sector));
Expand Down Expand Up @@ -553,7 +553,7 @@ Common::SeekableReadStream *Files_DOS33::createReadStreamBinary(const TOCEntry &
return new Common::MemoryReadStream(buf, size, DisposeAfterUse::YES);
}

Common::SeekableReadStream *Files_DOS33::createReadStream(const Common::String &filename, uint offset) const {
Common::SeekableReadStream *Files_AppleDOS::createReadStream(const Common::String &filename, uint offset) const {
if (!_toc.contains(filename))
error("Failed to locate '%s'", filename.c_str());

Expand All @@ -576,12 +576,12 @@ Common::SeekableReadStream *Files_DOS33::createReadStream(const Common::String &
return new Common::SeekableSubReadStream(stream, offset, stream->size(), DisposeAfterUse::YES);
}

bool Files_DOS33::open(const Common::String &filename) {
bool Files_AppleDOS::open(const Common::String &filename, uint trackVTOC) {
_disk = new DiskImage();
if (!_disk->open(filename))
return false;

readVTOC();
readVTOC(trackVTOC);
return true;
}

Expand Down
10 changes: 5 additions & 5 deletions engines/adl/disk.h
Expand Up @@ -128,12 +128,12 @@ class Files_Plain : public Files {
};

// Data in files contained in Apple DOS 3.3 disk image
class Files_DOS33 : public Files {
class Files_AppleDOS : public Files {
public:
Files_DOS33();
~Files_DOS33();
Files_AppleDOS();
~Files_AppleDOS();

bool open(const Common::String &filename);
bool open(const Common::String &filename, uint trackVTOC = 17);
const DataBlockPtr getDataBlock(const Common::String &filename, uint offset = 0) const;
Common::SeekableReadStream *createReadStream(const Common::String &filename, uint offset = 0) const;

Expand All @@ -160,7 +160,7 @@ class Files_DOS33 : public Files {
Common::Array<TrackSector> sectors;
};

void readVTOC();
void readVTOC(uint trackVTOC);
void readSectorList(TrackSector start, Common::Array<TrackSector> &list);
Common::SeekableReadStream *createReadStreamText(const TOCEntry &entry) const;
Common::SeekableReadStream *createReadStreamBinary(const TOCEntry &entry) const;
Expand Down

0 comments on commit bdda344

Please sign in to comment.