GLK: TADS: Added Data class

This commit is contained in:
Paul Gilbert 2018-12-01 20:17:52 -08:00 committed by Paul Gilbert
parent f20d07381c
commit 14871c28bc
6 changed files with 222 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -23,6 +23,8 @@
#ifndef GLK_TADS_TADS2_TYPES
#define GLK_TADS_TADS2_TYPES
#include "common/stream.h"
namespace Glk {
namespace TADS {
namespace TADS2 {

View File

@ -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

View File

@ -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