Skip to content

Commit

Permalink
TEENAGENT: Further symbol migration associated with saveStates.
Browse files Browse the repository at this point in the history
  • Loading branch information
digitall committed Jul 16, 2012
1 parent 28c3aa3 commit d7dcbb2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
3 changes: 2 additions & 1 deletion engines/teenagent/detection.cpp
Expand Up @@ -26,6 +26,7 @@
#include "base/plugins.h"

#include "engines/advancedDetector.h"
#include "teenagent/resources.h"
#include "teenagent/teenagent.h"
#include "graphics/thumbnail.h"

Expand Down Expand Up @@ -168,7 +169,7 @@ class TeenAgentMetaEngine : public AdvancedMetaEngine {

Common::String desc = buf;

in->seek(0x777a);
in->seek(TeenAgent::saveStateSize);
if (!Graphics::checkThumbnailHeader(*in))
return SaveStateDescriptor(slot, desc);

Expand Down
11 changes: 10 additions & 1 deletion engines/teenagent/resources.h
Expand Up @@ -49,8 +49,17 @@ const uint16 dsAddr_rejectMsg = 0x339e;
const uint16 dsAddr_saveState = 0x6478;
const uint16 saveStateSize = 0x777a;

// Save Description String (24 bytes) : 0x6478 to 0x648f

// Ego (Mark) position in scene : 0x64af to 0x64b2
const uint16 dsAddr_egoX = 0x64af; // 2 bytes
const uint16 dsAddr_egoY = 0x64b1; // 2 bytes

// Current Scene Id : 0xb4f3
const uint16 dsAddr_currentScene = 0xb4f3; // 1 byte

// Current Music Id Playing : 0xdb90
const uint16 dsAddr_currentMusic = 0xdb90;
const uint16 dsAddr_currentMusic = 0xdb90; // 1 byte

class Resources {
public:
Expand Down
17 changes: 9 additions & 8 deletions engines/teenagent/teenagent.cpp
Expand Up @@ -250,8 +250,8 @@ Common::Error TeenAgentEngine::loadGameState(int slot) {

setMusic(res->dseg.get_byte(dsAddr_currentMusic));

int id = res->dseg.get_byte(0xb4f3);
uint16 x = res->dseg.get_word(0x64af), y = res->dseg.get_word(0x64b1);
int id = res->dseg.get_byte(dsAddr_currentScene);
uint16 x = res->dseg.get_word(dsAddr_egoX), y = res->dseg.get_word(dsAddr_egoY);
scene->loadObjectData();
scene->init(id, Common::Point(x, y));
scene->setPalette(4);
Expand All @@ -265,13 +265,14 @@ Common::Error TeenAgentEngine::saveGameState(int slot, const Common::String &des
if (!out)
return Common::kWritingFailed;

res->dseg.set_byte(0xb4f3, scene->getId());
res->dseg.set_byte(dsAddr_currentScene, scene->getId());
Common::Point pos = scene->getPosition();
res->dseg.set_word(0x64af, pos.x);
res->dseg.set_word(0x64b1, pos.y);
res->dseg.set_word(dsAddr_egoX, pos.x);
res->dseg.set_word(dsAddr_egoY, pos.y);

assert(res->dseg.size() >= dsAddr_saveState + saveStateSize);
strncpy((char *)res->dseg.ptr(dsAddr_saveState), desc.c_str(), 0x16);
// FIXME: Description string is 24 bytes and null based on detection.cpp code, not 22?
strncpy((char *)res->dseg.ptr(dsAddr_saveState), desc.c_str(), 22);
out->write(res->dseg.ptr(dsAddr_saveState), saveStateSize);
if (!Graphics::saveThumbnail(*out))
warning("saveThumbnail failed");
Expand Down Expand Up @@ -307,7 +308,7 @@ bool TeenAgentEngine::showCDLogo() {
if (!cdlogo.exists("cdlogo.res") || !cdlogo.open("cdlogo.res"))
return true;

const uint bgSize = 0xfa00;
const uint bgSize = 320 * 200;
const uint paletteSize = 3 * 256;

byte *bg = (byte *)malloc(bgSize);
Expand Down Expand Up @@ -353,7 +354,7 @@ bool TeenAgentEngine::showLogo() {
if (!frame)
return true;

const uint bgSize = 0xfa00;
const uint bgSize = 320 * 200;
const uint paletteSize = 3 * 256;

byte *bg = (byte *)malloc(bgSize);
Expand Down

0 comments on commit d7dcbb2

Please sign in to comment.