Skip to content

Commit

Permalink
Merge pull request #602 from bluegr/mm
Browse files Browse the repository at this point in the history
ACCESS: Work on Martian Memorandum
  • Loading branch information
bluegr committed Jul 23, 2015
2 parents afccba2 + ad0fc57 commit 7733054
Show file tree
Hide file tree
Showing 43 changed files with 2,522 additions and 569 deletions.
72 changes: 65 additions & 7 deletions engines/access/access.cpp
Expand Up @@ -52,11 +52,10 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
_destIn = nullptr;
_current = nullptr;
_mouseMode = 0;
_playerDataCount = 0;
_currentMan = 0;
_currentManOld = -1;
_converseMode = 0;
_startAboutBox = 0;
_startTravelBox = 0;
_numAnimTimers = 0;
_startup = 0;
_currentCharFlag = false;
Expand Down Expand Up @@ -97,11 +96,33 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
for (int i = 0; i < 100; i++)
_objectsTable[i] = nullptr;
_clearSummaryFlag = false;

for (int i = 0; i < 60; i++)
TRAVEL[i] = 0;
STARTTRAVELITEM = STARTTRAVELBOX = 0;
for (int i = 0; i < 33; i++)
ASK[i];
_startAboutItem = _startAboutBox = 0;
_byte26CB5 = 0;
BCNT = 0;
BOXDATASTART = 0;
BOXDATAEND = false;
BOXSELECTY = 0;
BOXSELECTYOLD = -1;
NUMBLINES = 0;
TEMPLIST = nullptr;
_pictureTaken = 0;

_vidEnd = false;
}

AccessEngine::~AccessEngine() {
delete _animation;
delete _bubbleBox;
delete _helpBox;
delete _travelBox;
delete _invBox;
delete _aboutBox;
delete _char;
delete _debugger;
delete _events;
Expand Down Expand Up @@ -147,7 +168,18 @@ void AccessEngine::initialize() {

// Create sub-objects of the engine
_animation = new AnimationManager(this);
_bubbleBox = new BubbleBox(this);
_bubbleBox = new BubbleBox(this, TYPE_2, 64, 32, 130, 122, 0, 0, 0, 0, "");
if (getGameID() == GType_MartianMemorandum) {
_helpBox = new BubbleBox(this, TYPE_1, 64, 24, 146, 122, 1, 32, 2, 76, "HELP");
_travelBox = new BubbleBox(this, TYPE_1, 64, 32, 194, 122, 1, 24, 2, 74, "TRAVEL");
_invBox = new BubbleBox(this, TYPE_1, 64, 32, 146, 122, 1, 32, 2, 76, "INVENTORY");
_aboutBox = new BubbleBox(this, TYPE_1, 64, 32, 194, 122, 1, 32, 2, 76, "ASK ABOUT");
} else {
_helpBox = nullptr;
_travelBox = nullptr;
_invBox = nullptr;
_aboutBox = nullptr;
}
_char = new CharManager(this);
_debugger = Debugger::init(this);
_events = new EventsManager(this);
Expand Down Expand Up @@ -416,10 +448,6 @@ void AccessEngine::playVideo(int videoNum, const Common::Point &pt) {
}
}

void AccessEngine::doLoadSave() {
error("TODO: doLoadSave");
}

void AccessEngine::freeChar() {
_scripts->freeScriptData();
_animation->clearTimers();
Expand Down Expand Up @@ -572,6 +600,36 @@ void AccessEngine::writeSavegameHeader(Common::OutSaveFile *out, AccessSavegameH
out->writeUint32LE(_events->getFrameCounter());
}

void AccessEngine::SPRINTCHR(char c, int fontNum) {
warning("TODO: SPRINTCHR");
_fonts._font1.drawChar(_screen, c, _screen->_printOrg);
}

void AccessEngine::PRINTCHR(Common::String msg, int fontNum) {
_events->hideCursor();
warning("TODO: PRINTCHR - Handle fontNum");

for (int i = 0; msg[i]; i++) {
if (!(_fonts._charSet._hi & 8)) {
_fonts._font1.drawChar(_screen, msg[i], _screen->_printOrg);
continue;
} else if (_fonts._charSet._hi & 2) {
Common::Point oldPos = _screen->_printOrg;
int oldFontLo = _fonts._charFor._lo;

_fonts._charFor._lo = 0;
_screen->_printOrg.x++;
_screen->_printOrg.y++;
SPRINTCHR(msg[i], fontNum);

_screen->_printOrg = oldPos;
_fonts._charFor._lo = oldFontLo;
}
SPRINTCHR(msg[i], fontNum);
}
_events->showCursor();
}

bool AccessEngine::shouldQuitOrRestart() {
return shouldQuit() || _restartFl;
}
Expand Down
32 changes: 28 additions & 4 deletions engines/access/access.h
Expand Up @@ -137,6 +137,10 @@ class AccessEngine : public Engine {
public:
AnimationManager *_animation;
BubbleBox *_bubbleBox;
BubbleBox *_helpBox;
BubbleBox *_travelBox;
BubbleBox *_invBox;
BubbleBox *_aboutBox;
CharManager *_char;
Debugger *_debugger;
EventsManager *_events;
Expand Down Expand Up @@ -173,10 +177,9 @@ class AccessEngine : public Engine {
ImageEntryList _images;
int _mouseMode;

int _playerDataCount;
int _currentManOld;
int _converseMode;
int _startAboutBox;
int _startTravelBox;
bool _currentCharFlag;
bool _boxSelect;
int _scale;
Expand Down Expand Up @@ -204,6 +207,26 @@ class AccessEngine : public Engine {
uint32 _newDate;
int _flags[256];

// Fields used by MM
// TODO: Refactor
int TRAVEL[60];
int ASK[40];
int STARTTRAVELITEM;
int STARTTRAVELBOX;
int _startAboutItem;
int _startAboutBox;
int BOXDATASTART;
bool BOXDATAEND;
int BOXSELECTY;
int BOXSELECTYOLD;
int NUMBLINES;
byte _byte26CB5;
int BCNT;
byte *TEMPLIST;
int _pictureTaken;
//

bool _vidEnd;
bool _clearSummaryFlag;
bool _cheatFl;
bool _restartFl;
Expand Down Expand Up @@ -250,8 +273,6 @@ class AccessEngine : public Engine {

void copyBF2Vid();

void doLoadSave();

void freeChar();

/**
Expand Down Expand Up @@ -289,6 +310,9 @@ class AccessEngine : public Engine {
* Write out a savegame header
*/
void writeSavegameHeader(Common::OutSaveFile *out, AccessSavegameHeader &header);

void SPRINTCHR(char c, int fontNum);
void PRINTCHR(Common::String msg, int fontNum);
};

} // End of namespace Access
Expand Down
23 changes: 17 additions & 6 deletions engines/access/amazon/amazon_game.cpp
Expand Up @@ -260,13 +260,24 @@ void AmazonEngine::doEstablish(int screenId, int estabIndex) {
_screen->setIconPalette();
_screen->forceFadeIn();

_fonts._charSet._lo = 1;
_fonts._charSet._hi = 10;
_fonts._charFor._lo = 29;
_fonts._charFor._hi = 32;
if (getGameID() == GType_MartianMemorandum) {
_fonts._charSet._lo = 1;
_fonts._charSet._hi = 10;
_fonts._charFor._lo = 0xF7;
_fonts._charFor._hi = 0xFF;

_screen->_maxChars = 50;
_screen->_printOrg = _screen->_printStart = Common::Point(24, 18);
} else {
_fonts._charSet._lo = 1;
_fonts._charSet._hi = 10;
_fonts._charFor._lo = 29;
_fonts._charFor._hi = 32;

_screen->_maxChars = 37;
_screen->_printOrg = _screen->_printStart = Common::Point(48, 35);
}

_screen->_maxChars = 37;
_screen->_printOrg = _screen->_printStart = Common::Point(48, 35);
loadEstablish(estabIndex);
uint16 msgOffset;
if (!isCD())
Expand Down
2 changes: 1 addition & 1 deletion engines/access/amazon/amazon_logic.cpp
Expand Up @@ -1596,7 +1596,7 @@ void River::moveCanoe() {
moveCanoe2();
} else {
if (events._leftButton && pt.y >= 140) {
if (pt.x < RMOUSE[8][0]) {
if (pt.x < _vm->_room->_rMouse[8][0]) {
// Disk icon wasn't clicked
_vm->_scripts->printString(BAR_MESSAGE);
} else {
Expand Down
18 changes: 17 additions & 1 deletion engines/access/amazon/amazon_player.cpp
Expand Up @@ -48,7 +48,7 @@ void AmazonPlayer::load() {
_downDelta = -2;
_scrollConst = 2;

for (int i = 0; i < PLAYER_DATA_COUNT; ++i) {
for (int i = 0; i < _vm->_playerDataCount; ++i) {
_walkOffRight[i] = OVEROFFR[i];
_walkOffLeft[i] = OVEROFFL[i];
_walkOffUp[i] = OVEROFFU[i];
Expand Down Expand Up @@ -78,6 +78,22 @@ void AmazonPlayer::load() {
_diagDownWalkMin = 0;
_diagDownWalkMax = 5;
_game->_guard->setPosition(Common::Point(56, 190));
} else {
for (int i = 0; i < _vm->_playerDataCount; ++i) {
_walkOffRight[i] = SIDEOFFR[i];
_walkOffLeft[i] = SIDEOFFL[i];
_walkOffUp[i] = SIDEOFFU[i];
_walkOffDown[i] = SIDEOFFD[i];

_walkOffUR[i].x = DIAGOFFURX[i];
_walkOffUR[i].y = DIAGOFFURY[i];
_walkOffDR[i].x = DIAGOFFDRX[i];
_walkOffDR[i].y = DIAGOFFDRY[i];
_walkOffUL[i].x = DIAGOFFULX[i];
_walkOffUL[i].y = DIAGOFFULY[i];
_walkOffDL[i].x = DIAGOFFDLX[i];
_walkOffDL[i].y = DIAGOFFDLY[i];
}
}
}

Expand Down
20 changes: 19 additions & 1 deletion engines/access/amazon/amazon_resources.cpp
Expand Up @@ -72,6 +72,19 @@ const char *const FILENAMES_DEMO[] = {
"CHAPTER.AP", "MUSIC.AP", "SOUND.AP", "INV.AP"
};

const int SIDEOFFR[] = { 5, 5, 5, 5, 5, 5, 5, 5, 0 };
const int SIDEOFFL[] = { 5, 5, 5, 5, 5, 5, 5, 5, 0 };
const int SIDEOFFU[] = { 2, 2, 2, 2, 2, 2, 2, 2, 0 };
const int SIDEOFFD[] = { 2, 2, 2, 2, 2, 2, 2, 2, 0 };
const int DIAGOFFURX[] = { 4, 5, 2, 2, 3, 4, 2, 2, 0 };
const int DIAGOFFURY[] = { 2, 3, 2, 2, 2, 3, 1, 1, 0 };
const int DIAGOFFDRX[] = { 4, 5, 4, 3, 5, 4, 5, 1, 0 };
const int DIAGOFFDRY[] = { 3, 2, 1, 2, 2, 1, 2, 1, 0 };
const int DIAGOFFULX[] = { 4, 5, 4, 3, 3, 2, 2, 2, 0 };
const int DIAGOFFULY[] = { 3, 3, 1, 2, 2, 1, 1, 1, 0 };
const int DIAGOFFDLX[] = { 4, 5, 3, 3, 5, 4, 6, 1, 0 };
const int DIAGOFFDLY[] = { 2, 2, 1, 2, 3, 1, 2, 1, 0 };

const byte MOUSE0[] = {
// hotspot x and y, uint16 LE
0, 0, 0, 0,
Expand Down Expand Up @@ -2406,6 +2419,11 @@ const int CAST_END_OBJ1[4][4] = {
{ 3, 103, 1300, 10 }
};

} // End of namespace Amazon
const int RMOUSE[10][2] = {
{ 0, 35 }, { 0, 0 }, { 36, 70 }, { 71, 106 }, { 107, 141 },
{ 142, 177 }, { 178, 212 }, { 213, 248 }, { 249, 283 }, { 284, 318 }
};


} // End of namespace Amazon
} // End of namespace Access
17 changes: 15 additions & 2 deletions engines/access/amazon/amazon_resources.h
Expand Up @@ -45,6 +45,19 @@ struct RiverStruct {
extern const char *const FILENAMES[];
extern const char *const FILENAMES_DEMO[];

extern const int SIDEOFFR[];
extern const int SIDEOFFL[];
extern const int SIDEOFFU[];
extern const int SIDEOFFD[];
extern const int DIAGOFFURX[];
extern const int DIAGOFFURY[];
extern const int DIAGOFFDRX[];
extern const int DIAGOFFDRY[];
extern const int DIAGOFFULX[];
extern const int DIAGOFFULY[];
extern const int DIAGOFFDLX[];
extern const int DIAGOFFDLY[];

extern const byte *const CURSORS[10];

extern const int TRAVEL_POS[][2];
Expand Down Expand Up @@ -138,11 +151,11 @@ extern const int HELP1COORDS[2][4];
extern const int RIVER1OBJ[23][4];

extern const int CAST_END_OBJ[26][4];

extern const int CAST_END_OBJ1[4][4];

} // End of namespace Amazon
extern const int RMOUSE[10][2];

} // End of namespace Amazon
} // End of namespace Access

#endif /* ACCESS_AMAZON_RESOURCES_H */
6 changes: 4 additions & 2 deletions engines/access/amazon/amazon_scripts.cpp
Expand Up @@ -33,6 +33,8 @@ namespace Amazon {

AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) {
_game = (AmazonEngine *)_vm;

setOpcodes_v2();
}

void AmazonScripts::cLoop() {
Expand Down Expand Up @@ -379,7 +381,7 @@ typedef void(AmazonScripts::*AmazonScriptMethodPtr)();

void AmazonScripts::executeCommand(int commandIndex) {
static const AmazonScriptMethodPtr COMMAND_LIST[] = {
&AmazonScripts::cmdHelp, &AmazonScripts::cmdCycleBack,
&AmazonScripts::cmdHelp_v2, &AmazonScripts::cmdCycleBack,
&AmazonScripts::cmdChapter, &AmazonScripts::cmdSetHelp,
&AmazonScripts::cmdCenterPanel, &AmazonScripts::cmdMainPanel,
&AmazonScripts::CMDRETFLASH
Expand All @@ -391,7 +393,7 @@ void AmazonScripts::executeCommand(int commandIndex) {
Scripts::executeCommand(commandIndex);
}

void AmazonScripts::cmdHelp() {
void AmazonScripts::cmdHelp_v2() {
Common::String helpMessage = readString();

if (_game->_helpLevel == 0) {
Expand Down
2 changes: 1 addition & 1 deletion engines/access/amazon/amazon_scripts.h
Expand Up @@ -49,7 +49,7 @@ class AmazonScripts : public Scripts {
void setInactive();
void boatWalls(int param1, int param2);

void cmdHelp();
void cmdHelp_v2();
void cmdCycleBack();
void cmdChapter();
void cmdSetHelp();
Expand Down
21 changes: 21 additions & 0 deletions engines/access/asurface.cpp
Expand Up @@ -54,6 +54,12 @@ SpriteResource::~SpriteResource() {
SpriteFrame::SpriteFrame(AccessEngine *vm, Common::SeekableReadStream *stream, int frameSize) {
int xSize = stream->readUint16LE();
int ySize = stream->readUint16LE();

if (vm->getGameID() == GType_MartianMemorandum) {
int size = stream->readUint16LE();
if (size != frameSize)
warning("Unexpected file difference: framesize %d - size %d %d - unknown %d", frameSize, xSize, ySize, size);
}
create(xSize, ySize);

// Empty surface
Expand Down Expand Up @@ -312,6 +318,21 @@ void ASurface::drawRect() {
Graphics::Surface::fillRect(Common::Rect(_orgX1, _orgY1, _orgX2, _orgY2), _lColor);
}

void ASurface::drawLine(int x1, int y1, int x2, int y2, int col) {
Graphics::Surface::drawLine(x1, y1, x2, y2, col);
}

void ASurface::drawLine() {
Graphics::Surface::drawLine(_orgX1, _orgY1, _orgX2, _orgY1, _lColor);
}

void ASurface::drawBox() {
Graphics::Surface::drawLine(_orgX1, _orgY1, _orgX2, _orgY1, _lColor);
Graphics::Surface::drawLine(_orgX1, _orgY2, _orgX2, _orgY2, _lColor);
Graphics::Surface::drawLine(_orgX2, _orgY1, _orgX2, _orgY1, _lColor);
Graphics::Surface::drawLine(_orgX2, _orgY2, _orgX2, _orgY2, _lColor);
}

void ASurface::flipHorizontal(ASurface &dest) {
dest.create(this->w, this->h);
for (int y = 0; y < h; ++y) {
Expand Down

0 comments on commit 7733054

Please sign in to comment.