diff options
author | Paul Gilbert | 2018-12-01 20:17:52 -0800 |
---|---|---|
committer | Paul Gilbert | 2018-12-08 19:05:59 -0800 |
commit | 14871c28bc9ec1b210412a072f0ab292febfd368 (patch) | |
tree | 41b98caf23fcbe08c0cd69ca086a961cb4515017 | |
parent | f20d07381cfdbb625550167e259a2ea58f81fcd9 (diff) | |
download | scummvm-rg350-14871c28bc9ec1b210412a072f0ab292febfd368.tar.gz scummvm-rg350-14871c28bc9ec1b210412a072f0ab292febfd368.tar.bz2 scummvm-rg350-14871c28bc9ec1b210412a072f0ab292febfd368.zip |
GLK: TADS: Added Data class
-rw-r--r-- | engines/glk/module.mk | 2 | ||||
-rw-r--r-- | engines/glk/tads/tads2/data.cpp | 72 | ||||
-rw-r--r-- | engines/glk/tads/tads2/data.h | 69 | ||||
-rw-r--r-- | engines/glk/tads/tads2/types.h | 2 | ||||
-rw-r--r-- | engines/glk/tads/tads2/vocabulary.cpp | 33 | ||||
-rw-r--r-- | engines/glk/tads/tads2/vocabulary.h | 44 |
6 files changed, 222 insertions, 0 deletions
diff --git a/engines/glk/module.mk b/engines/glk/module.mk index 5c17362a0d..003f8dcb6e 100644 --- a/engines/glk/module.mk +++ b/engines/glk/module.mk @@ -45,11 +45,13 @@ MODULE_OBJS := \ scott/scott.o \ tads/detection.o \ tads/tads.o \ + tads/tads2/data.o \ tads/tads2/ler.o \ tads/tads2/os.o \ tads/tads2/regex.o \ tads/tads2/tads2.o \ tads/tads2/tads2_cmap.o \ + tads/tads2/vocabulary.o \ tads/tads3/tads3.o # This module can be built as a plugin diff --git a/engines/glk/tads/tads2/data.cpp b/engines/glk/tads/tads2/data.cpp new file mode 100644 index 0000000000..e142f37310 --- /dev/null +++ b/engines/glk/tads/tads2/data.cpp @@ -0,0 +1,72 @@ +/* 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 "engines/glk/tads/tads2/data.h" +#include "engines/glk/tads/tads2/types.h" +#include "engines/glk/tads/tads2/vocabulary.h" +#include "common/algorithm.h" + +namespace Glk { +namespace TADS { +namespace TADS2 { + +Data::Data(DataType type) : _type(type) { +} + +size_t Data::size() const { + switch (_type) { + case DAT_NUMBER: + return 4; // numbers are in 4-byte lsb-first format + + case DAT_OBJECT: + return 2; // object numbers are in 2-byte lsb-first format + + case DAT_SSTRING: + case DAT_DSTRING: + case DAT_LIST: + return osrp2(_ptr); + + case DAT_NIL: + case DAT_TRUE: + return 0; + + case DAT_PROPNUM: + case DAT_SYN: + case DAT_FNADDR: + case DAT_REDIR: + return 2; + + case DAT_TPL: + // template is counted array of 10-byte entries, plus length byte */ + return 1 + ((*(uchar *)_ptr) * VOCTPLSIZ); + + case DAT_TPL2: + return 1 + ((*(uchar *)_ptr) * VOCTPL2SIZ); + + default: + return 0; + } +} + +} // End of namespace TADS2 +} // End of namespace TADS +} // Engine of namespace GLK diff --git a/engines/glk/tads/tads2/data.h b/engines/glk/tads/tads2/data.h new file mode 100644 index 0000000000..b2d8df6159 --- /dev/null +++ b/engines/glk/tads/tads2/data.h @@ -0,0 +1,69 @@ +/* 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 GLK_TADS_TADS2_DATA +#define GLK_TADS_TADS2_DATA + +namespace Glk { +namespace TADS { +namespace TADS2 { + +enum DataType { + DAT_NUMBER = 1, + DAT_OBJECT = 2, + DAT_SSTRING = 3, + DAT_BASEPTR = 4, + DAT_NIL = 5, ///< nil, as in FALSE or empty list + DAT_CODE = 6, + DAT_LIST = 7, + DAT_TRUE = 8, ///< inverse of nil + DAT_DSTRING = 9, + DAT_FNADDR = 10, ///< a function address + DAT_TPL = 11, ///< template list pointer + DAT_PROPNUM = 13, ///< a property number + DAT_DEMAND = 14, ///< special flag: use callback to set on use + DAT_SYN = 15, ///< synonym to indicated property value + DAT_REDIR = 16, ///< redirection to different object + DAT_TPL2 = 17 ///< new-style template +}; + +class Data { +private: + DataType _type; + void *_ptr; +public: + /** + * Constructor + */ + Data(DataType type); + + /** + * Return the size of the data + */ + size_t size() const; +}; + +} // End of namespace TADS2 +} // End of namespace TADS +} // Engine of namespace Glk + +#endif diff --git a/engines/glk/tads/tads2/types.h b/engines/glk/tads/tads2/types.h index 52a530939b..5da759fda7 100644 --- a/engines/glk/tads/tads2/types.h +++ b/engines/glk/tads/tads2/types.h @@ -23,6 +23,8 @@ #ifndef GLK_TADS_TADS2_TYPES #define GLK_TADS_TADS2_TYPES +#include "common/stream.h" + namespace Glk { namespace TADS { namespace TADS2 { diff --git a/engines/glk/tads/tads2/vocabulary.cpp b/engines/glk/tads/tads2/vocabulary.cpp new file mode 100644 index 0000000000..4647b1bd30 --- /dev/null +++ b/engines/glk/tads/tads2/vocabulary.cpp @@ -0,0 +1,33 @@ +/* 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 "glk/tads/tads2/vocabulary.h" + +namespace Glk { +namespace TADS { +namespace TADS2 { + +// TODO: Rest of vocabulary stuff + +} // End of namespace TADS2 +} // End of namespace TADS +} // End of namespace Glk diff --git a/engines/glk/tads/tads2/vocabulary.h b/engines/glk/tads/tads2/vocabulary.h new file mode 100644 index 0000000000..b4079932a5 --- /dev/null +++ b/engines/glk/tads/tads2/vocabulary.h @@ -0,0 +1,44 @@ +/* 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. + * + */ + +/* + * Defines TADS vocabulary (player command parser) functionality + */ + +#ifndef GLK_TADS_TADS2_OS +#define GLK_TADS_TADS2_OS + +#include "glk/tads/tads2/types.h" + +namespace Glk { +namespace TADS { +namespace TADS2 { + +// TODO: Rest of vocabulary stuff +#define VOCTPLSIZ 10 +#define VOCTPL2SIZ 16 + +} // End of namespace TADS2 +} // End of namespace TADS +} // End of namespace Glk + +#endif |