Skip to content

Commit

Permalink
ACCESS: Start implementing loadEstablish
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Aug 23, 2014
1 parent f98d466 commit 955df7a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
34 changes: 30 additions & 4 deletions engines/access/access.cpp
Expand Up @@ -83,6 +83,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
_establishFlag = false;
_establishMode = 0;
_establishGroup = 0;
_establishCtrlTblOfs = 0;
Common::fill(&_help1[0], &_help1[366], 0);
Common::fill(&_help2[0], &_help2[366], 0);
Common::fill(&_help1[0], &_help3[366], 0);
Expand All @@ -102,6 +103,9 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
_screenVirtX = 0;
_lastTime = g_system->getMillis();
_curTime = 0;
_narateFile = 0;
_txtPages = 0;
_sndSubFile = 0;
}

AccessEngine::~AccessEngine() {
Expand Down Expand Up @@ -233,9 +237,31 @@ void AccessEngine::establishCenter(int esatabIndex, int sub) {
doEstablish(esatabIndex, sub);
}

byte *AccessEngine::loadEstablish(int sub) {
warning("TODO: loadEstablish");
return nullptr;
const char *const _estTable[] = { "ETEXT0.DAT", "ETEXT1.DAT", "ETEXT2.DAT", "ETEXT3.DAT" };

void AccessEngine::loadEstablish(int sub) {
if (!_files->existFile("ETEXT.DAT")) {
int oldGroup = _establishGroup;
_establishGroup = 0;

_eseg = _files->loadFile(_estTable[oldGroup]);
} else {
_eseg = _files->loadFile("ETEXT.DAT");
}

_establishCtrlTblOfs = READ_LE_UINT16(_eseg);

int ofs = _establishCtrlTblOfs + (sub * 2);
int idx = READ_LE_UINT16(_eseg + ofs);
_narateFile = READ_LE_UINT16(_eseg + idx);
_txtPages = READ_LE_UINT16(_eseg + idx + 2);

if (!_txtPages)
return;

_sndSubFile = READ_LE_UINT16(_eseg + idx + 4);
for (int i = 0; i < _txtPages; ++i)
_countTbl[i] = READ_LE_UINT16(_eseg + idx + 6 + (2 * i));
}

void AccessEngine::doEstablish(int esatabIndex, int sub) {
Expand All @@ -260,7 +286,7 @@ void AccessEngine::doEstablish(int esatabIndex, int sub) {

_bubbleBox->_maxChars = 37;
_fonts._printOrg = _fonts._printStart = Common::Point(48, 35);
_eseg = loadEstablish(sub);
loadEstablish(sub);
_et = sub;
warning("CHECKME: Use of di");
_printEnd = 155;
Expand Down
8 changes: 7 additions & 1 deletion engines/access/access.h
Expand Up @@ -73,6 +73,8 @@ enum AccessDebugChannels {

struct AccessGameDescription;

extern const char *const _estTable[];

class AccessEngine : public Engine {
private:
uint32 _lastTime, _curTime;
Expand Down Expand Up @@ -132,6 +134,7 @@ class AccessEngine : public Engine {
bool _establishFlag;
int _establishMode;
int _establishGroup;
int _establishCtrlTblOfs;
int _numAnimTimers;
TimerList _timers;
FontManager _fonts;
Expand Down Expand Up @@ -164,6 +167,9 @@ class AccessEngine : public Engine {
int _et;
int _printEnd;
int _txtPages;
int _narateFile;
int _sndSubFile;
int _countTbl[6];

// Fields that are included in savegames
int _conversation;
Expand Down Expand Up @@ -220,7 +226,7 @@ class AccessEngine : public Engine {
*/
void freeInactiveData();

byte *AccessEngine::loadEstablish(int sub);
void AccessEngine::loadEstablish(int sub);

void establish(int esatabIndex, int sub);

Expand Down
4 changes: 4 additions & 0 deletions engines/access/files.cpp
Expand Up @@ -82,6 +82,10 @@ byte *FileManager::loadFile(const Common::String &filename) {
return handleFile();
}

bool FileManager::existFile(const Common::String &filename) {
return _file.exists(filename);
}

void FileManager::openFile(const Common::String &filename) {
// Open up the file
_fileNumber = -1;
Expand Down
5 changes: 5 additions & 0 deletions engines/access/files.h
Expand Up @@ -63,6 +63,11 @@ class FileManager {
FileManager(AccessEngine *vm);
~FileManager();

/**
* Check the existence of a given file
*/
bool FileManager::existFile(const Common::String &filename);

/**
* Load a given subfile from a container file
*/
Expand Down

0 comments on commit 955df7a

Please sign in to comment.