mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-07 18:31:37 +00:00
TITANIC: Beginnings of TTWord hierarchy
This commit is contained in:
parent
71179e3763
commit
9ce6391a94
@ -467,7 +467,8 @@ MODULE_OBJS := \
|
||||
true_talk/tt_scripts.o \
|
||||
true_talk/tt_string.o \
|
||||
true_talk/tt_talker.o \
|
||||
true_talk/tt_title_script.o
|
||||
true_talk/tt_title_script.o \
|
||||
true_talk/tt_word.o
|
||||
|
||||
# This module can be built as a plugin
|
||||
ifeq ($(ENABLE_TITANIC), DYNAMIC_PLUGIN)
|
||||
|
@ -24,10 +24,13 @@
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
void CFileReader::reset() {
|
||||
_file.close();
|
||||
_field18 = 0;
|
||||
CFileReader::CFileReader() : _owner(nullptr), _field4(0), _field8(0),
|
||||
_fieldC(0), _field10(0), _field14(0), _field18(0) {
|
||||
}
|
||||
|
||||
void CFileReader::reset(CScriptHandler *owner, int val1, int val2) {
|
||||
_owner = owner;
|
||||
_field18 = val2;
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
@ -27,12 +27,21 @@
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CScriptHandler;
|
||||
|
||||
class CFileReader {
|
||||
public:
|
||||
Common::File _file;
|
||||
CScriptHandler *_owner;
|
||||
int _field4;
|
||||
int _field8;
|
||||
int _fieldC;
|
||||
int _field10;
|
||||
int _field14;
|
||||
int _field18;
|
||||
public:
|
||||
void reset();
|
||||
CFileReader();
|
||||
|
||||
void reset(CScriptHandler *owner, int val1, int val2);
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
@ -354,6 +354,29 @@ void SimpleFile::writeClassEnd(int indent) {
|
||||
write("}\n", 2);
|
||||
}
|
||||
|
||||
bool SimpleFile::scanf(const char *format, ...) {
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
char c;
|
||||
|
||||
CString formatStr(format);
|
||||
while (!formatStr.empty()) {
|
||||
if (formatStr.hasPrefix(" ")) {
|
||||
formatStr.deleteChar(0);
|
||||
safeRead(&c, 1);
|
||||
|
||||
if (!Common::isSpace(c))
|
||||
return false;
|
||||
} else if (formatStr.hasPrefix("%d")) {
|
||||
formatStr = CString(formatStr.c_str() + 2);
|
||||
int *param = (int *)va_arg(va, int *);
|
||||
*param = readNumber();
|
||||
}
|
||||
}
|
||||
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void StdCWadFile::open(const CString &name) {
|
||||
|
@ -121,6 +121,11 @@ public:
|
||||
*/
|
||||
void readBuffer(char *buffer = nullptr, size_t count = 0);
|
||||
|
||||
/**
|
||||
* Scan in values from the file
|
||||
*/
|
||||
bool scanf(const char *format, ...);
|
||||
|
||||
/**
|
||||
* Write a string line
|
||||
*/
|
||||
@ -197,6 +202,14 @@ public:
|
||||
* Write out the ending footer for a class definition
|
||||
*/
|
||||
void writeClassEnd(int indent);
|
||||
|
||||
/**
|
||||
* Return true if the stream has finished being read
|
||||
*/
|
||||
bool eos() const {
|
||||
assert(_inStream);
|
||||
return _inStream->eos();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -53,10 +53,14 @@ ScriptChangedResult CScriptHandler::scriptChanged(TTRoomScript *roomScript, TTNp
|
||||
|
||||
void CScriptHandler::processInput(TTRoomScript *roomScript, TTNpcScript *npcScript,
|
||||
const TTString &line) {
|
||||
if (!roomScript || line.empty())
|
||||
if (!roomScript || !line.isValid())
|
||||
return;
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
SimpleFile *CScriptHandler::openResource(const CString &name) {
|
||||
return _owner->open(name);
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
@ -85,6 +85,11 @@ public:
|
||||
|
||||
void processInput(TTRoomScript *roomScript, TTNpcScript *npcScript,
|
||||
const TTString &line);
|
||||
|
||||
/**
|
||||
* Open a resource for access
|
||||
*/
|
||||
SimpleFile *openResource(const CString &name);
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
@ -20,18 +20,32 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/file.h"
|
||||
#include "titanic/true_talk/st_vocab.h"
|
||||
#include "titanic/titanic.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
STVocab::STVocab(int val): _field0(0), _field4(0), _field8(0),
|
||||
STVocab::STVocab(int val): _field0(0), _field4(0), _vocab(nullptr),
|
||||
_fieldC(0), _field10(0), _field18(val) {
|
||||
_field14 = load("STvocab.txt");
|
||||
}
|
||||
|
||||
int STVocab::load(const CString &name) {
|
||||
// TODO
|
||||
return 0;
|
||||
SimpleFile *file = g_vm->_fileReader._owner->openResource(name);
|
||||
int result = 0;
|
||||
|
||||
while (!file->eos()) {
|
||||
int mode = file->readNumber();
|
||||
|
||||
switch (mode) {
|
||||
case 0:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete file;
|
||||
return result;
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
@ -24,6 +24,8 @@
|
||||
#define TITANIC_ST_VOCAB_H
|
||||
|
||||
#include "titanic/support/string.h"
|
||||
#include "titanic/true_talk/tt_string.h"
|
||||
#include "titanic/true_talk/tt_word.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
@ -31,7 +33,7 @@ class STVocab {
|
||||
private:
|
||||
int _field0;
|
||||
int _field4;
|
||||
int _field8;
|
||||
TTString *_vocab;
|
||||
int _fieldC;
|
||||
int _field10;
|
||||
int _field14;
|
||||
|
@ -64,14 +64,13 @@ void STtitleEngine::dump(int val1, int val2) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void STtitleEngine::open(const CString &name) {
|
||||
_stream = _resources.getResource(Common::WinResourceID("Text"),
|
||||
name);
|
||||
}
|
||||
|
||||
void STtitleEngine::close() {
|
||||
delete _stream;
|
||||
_stream = nullptr;
|
||||
SimpleFile *STtitleEngine::open(const CString &name) {
|
||||
Common::SeekableReadStream *stream = _resources.getResource(
|
||||
Common::WinResourceID("Text"), name);
|
||||
|
||||
SimpleFile *file = new SimpleFile();
|
||||
file->open(stream);
|
||||
return file;
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
@ -32,6 +32,13 @@
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CTitleEngine;
|
||||
|
||||
class CTitleStream : public SimpleFile {
|
||||
public:
|
||||
CTitleStream() : SimpleFile() {}
|
||||
};
|
||||
|
||||
class CTitleEngine {
|
||||
public:
|
||||
CScriptHandler *_scriptHandler;
|
||||
@ -56,12 +63,7 @@ public:
|
||||
/**
|
||||
* Open a designated file
|
||||
*/
|
||||
virtual void open(const CString &name) = 0;
|
||||
|
||||
/**
|
||||
* Close the file
|
||||
*/
|
||||
virtual void close() = 0;
|
||||
virtual SimpleFile *open(const CString &name) = 0;
|
||||
};
|
||||
|
||||
class STtitleEngine : public CTitleEngine {
|
||||
@ -96,12 +98,7 @@ public:
|
||||
/**
|
||||
* Open a designated file
|
||||
*/
|
||||
virtual void open(const CString &name);
|
||||
|
||||
/**
|
||||
* Close the file
|
||||
*/
|
||||
virtual void close();
|
||||
virtual SimpleFile *open(const CString &name);
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
@ -24,4 +24,42 @@
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
TTString::TTString() : _status(SS_VALID) {
|
||||
_data = new TTStringData();
|
||||
}
|
||||
|
||||
TTString::TTString(const char *str) : _status(SS_VALID) {
|
||||
_data = new TTStringData(str);
|
||||
}
|
||||
|
||||
TTString::TTString(const CString &str) {
|
||||
if (_status != SS_VALID) {
|
||||
_status = SS_5;
|
||||
_data = nullptr;
|
||||
} else {
|
||||
_status = SS_VALID;
|
||||
_data = new TTStringData(str);
|
||||
}
|
||||
}
|
||||
|
||||
TTString::TTString(TTString &str) {
|
||||
if (_status != SS_VALID) {
|
||||
_status = SS_5;
|
||||
_data = nullptr;
|
||||
} else {
|
||||
_status = SS_VALID;
|
||||
_data = str._data;
|
||||
_data->_referenceCount++;
|
||||
}
|
||||
}
|
||||
|
||||
TTString::~TTString() {
|
||||
if (--_data->_referenceCount == 0)
|
||||
delete _data;
|
||||
}
|
||||
|
||||
bool TTString::isValid() const {
|
||||
return _status == SS_VALID;
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
@ -27,18 +27,41 @@
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class TTString: public CString {
|
||||
class TTStringData {
|
||||
private:
|
||||
CString _string;
|
||||
public:
|
||||
int _status;
|
||||
int _referenceCount;
|
||||
public:
|
||||
TTString() : CString(), _status(0) {}
|
||||
TTString(const char *str) : CString(str), _status(0) {}
|
||||
TTString(const CString &str) : CString(str), _status(0) {}
|
||||
virtual ~TTString() {}
|
||||
TTStringData() : _referenceCount(1) {}
|
||||
TTStringData(const char *str) : _string(str), _referenceCount(1) {}
|
||||
TTStringData(const CString &str) : _string(str), _referenceCount(1) {}
|
||||
};
|
||||
|
||||
bool isValid() const { return !_status; }
|
||||
enum TTStringStatus { SS_VALID = 0, SS_5 = 5, SS_7 = 7 };
|
||||
|
||||
class TTString {
|
||||
private:
|
||||
TTStringData *_data;
|
||||
TTStringStatus _status;
|
||||
public:
|
||||
TTString();
|
||||
TTString(const char *str);
|
||||
TTString(const CString &str);
|
||||
TTString(TTString &str);
|
||||
virtual ~TTString();
|
||||
|
||||
/**
|
||||
* Returns true if the string is valid
|
||||
*/
|
||||
bool isValid() const;
|
||||
|
||||
/**
|
||||
* Get the status of the string
|
||||
*/
|
||||
TTStringStatus getStatus() const { return _status; }
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_TT_OBJ8_H */
|
||||
#endif /* TITANIC_TT_STRING_H */
|
||||
|
75
engines/titanic/true_talk/tt_word.cpp
Normal file
75
engines/titanic/true_talk/tt_word.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
/* 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 "titanic/true_talk/tt_word.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
TTWord::TTWord(TTString &str, int val1, int val2) : _string(str),
|
||||
_field18(val1), _field1C(val2), _fieldC(0), _field10(0),
|
||||
_field20(0), _field24(0), _field28(0) {
|
||||
_status = str.getStatus() == SS_VALID ? SS_VALID : SS_5;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void TTWord::readSyn(SimpleFile *file) {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
TTWord1::TTWord1(TTString &str, int val1, int val2, int val3) :
|
||||
TTWord(str, val1, val2), _field2C(val3) {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
TTWord2::TTWord2(TTString &str, int val1, int val2, int val3, int val4) :
|
||||
TTWord1(str, val1, val2, val3), _field30(val4) {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
TTWord3::TTWord3(TTString &str, int val1, int val2, int val3, int val4, int val5, int val6) :
|
||||
TTWord1(str, val1, val2, val4), _field34(val3), _field30(val5), _field3C(val6),
|
||||
_field38(0) {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
TTWord4::TTWord4(TTString &str, int val1, int val2, int val3, int val4) :
|
||||
TTWord1(str, val1, val2, val3) {
|
||||
if (val4 >= 0 && val4 <= 9) {
|
||||
_field30 = val4;
|
||||
} else {
|
||||
_field30 = 0;
|
||||
_status = SS_5;
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
TTWord5::TTWord5(TTString &str, int val1, int val2, int val3, int val4) :
|
||||
TTWord1(str, val1, val2, val3), _field30(val4) {
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
88
engines/titanic/true_talk/tt_word.h
Normal file
88
engines/titanic/true_talk/tt_word.h
Normal file
@ -0,0 +1,88 @@
|
||||
/* 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 TITANIC_TT_WORD_H
|
||||
#define TITANIC_TT_WORD_H
|
||||
|
||||
#include "titanic/support/simple_file.h"
|
||||
#include "titanic/true_talk/tt_string.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class TTWord {
|
||||
protected:
|
||||
TTString _string;
|
||||
int _fieldC;
|
||||
int _field10;
|
||||
TTStringStatus _status;
|
||||
int _field18;
|
||||
int _field1C;
|
||||
int _field20;
|
||||
int _field24;
|
||||
int _field28;
|
||||
public:
|
||||
TTWord(TTString &str, int val1, int val2);
|
||||
|
||||
void readSyn(SimpleFile *file);
|
||||
};
|
||||
|
||||
class TTWord1 : public TTWord {
|
||||
protected:
|
||||
int _field2C;
|
||||
public:
|
||||
TTWord1(TTString &str, int val1, int val2, int val3);
|
||||
};
|
||||
|
||||
class TTWord2 : public TTWord1 {
|
||||
protected:
|
||||
int _field30;
|
||||
public:
|
||||
TTWord2(TTString &str, int val1, int val2, int val3, int val4);
|
||||
};
|
||||
|
||||
class TTWord3 : public TTWord1 {
|
||||
protected:
|
||||
int _field30;
|
||||
int _field34;
|
||||
int _field38;
|
||||
int _field3C;
|
||||
public:
|
||||
TTWord3(TTString &str, int val1, int val2, int val3, int val4, int val5, int val6);
|
||||
};
|
||||
|
||||
class TTWord4 : public TTWord1 {
|
||||
protected:
|
||||
int _field30;
|
||||
public:
|
||||
TTWord4(TTString &str, int val1, int val2, int val3, int val4);
|
||||
};
|
||||
|
||||
class TTWord5 : public TTWord1 {
|
||||
protected:
|
||||
int _field30;
|
||||
public:
|
||||
TTWord5(TTString &str, int val1, int val2, int val3, int val4);
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_TT_WORD_H */
|
Loading…
Reference in New Issue
Block a user