diff options
author | Paul Gilbert | 2018-12-01 16:34:48 -0800 |
---|---|---|
committer | Paul Gilbert | 2018-12-08 19:05:59 -0800 |
commit | f20d07381cfdbb625550167e259a2ea58f81fcd9 (patch) | |
tree | 8e58805e2fa5d3aa83aaa317d9fe58a3442a0c29 /engines/glk/tads/tads2/tads2.h | |
parent | d3c46f7078c05fc38bde26d38f6d767167c54c6f (diff) | |
download | scummvm-rg350-f20d07381cfdbb625550167e259a2ea58f81fcd9.tar.gz scummvm-rg350-f20d07381cfdbb625550167e259a2ea58f81fcd9.tar.bz2 scummvm-rg350-f20d07381cfdbb625550167e259a2ea58f81fcd9.zip |
GLK: TADS: Added cmap file
Diffstat (limited to 'engines/glk/tads/tads2/tads2.h')
-rw-r--r-- | engines/glk/tads/tads2/tads2.h | 128 |
1 files changed, 121 insertions, 7 deletions
diff --git a/engines/glk/tads/tads2/tads2.h b/engines/glk/tads/tads2/tads2.h index 2c799a36e7..f0c42b3574 100644 --- a/engines/glk/tads/tads2/tads2.h +++ b/engines/glk/tads/tads2/tads2.h @@ -31,27 +31,75 @@ namespace TADS { namespace TADS2 { /** + * map a native character (read externally) into an internal character + */ +#define cmap_n2i(c) (G_cmap_input[(unsigned char)(c)]) + +/** + * map an internal character into a native character (for display) + */ +#define cmap_i2n(c) (G_cmap_output[(unsigned char)(c)]) + +/** + * the full name (for display purposes) of the loaded character set + */ +#define CMAP_LDESC_MAX_LEN 40 + +/** + * Maximum expansion for an HTML entity mapping + */ +#define CMAP_MAX_ENTITY_EXPANSION 50 + + +/** * TADS 2 game interpreter */ class TADS2 : public OS { private: // STUBS void os_printz(const Common::String &s) {} -public: + void tio_set_html_expansion(unsigned int html_char_val, + const char *expansion, size_t expansion_len) {} +private: /** - * Constructor + * \defgroup cmap + * @{ */ - TADS2(OSystem *syst, const GlkGameDescription &gameDesc); /** - * Execute the game + * flag: true -> a character set has been explicitly loaded, so we + * should ignore any game character set setting */ - virtual void runGame(Common::SeekableReadStream *gameFile) override; + bool S_cmap_loaded; /** - * Returns the running interpreter type + * input-mapping table - for native character 'n', cmap_input[n] yields + * the internal character code + */ + unsigned char G_cmap_input[256]; + + /** + * output-mapping table - for internal character 'n', cmap_output[n] + * yields the output character code + */ + unsigned char G_cmap_output[256]; + + /** + * the ID of the loaded character set + */ + char G_cmap_id[5]; + + /** + * the full name (for display purposes) of the loaded character set + */ + char G_cmap_ldesc[CMAP_LDESC_MAX_LEN + 1]; + + /**@}*/ +private: + /** + * \defgroup trd + * @{ */ - virtual InterpreterType getInterpreterType() const override { return INTERPRETER_TADS2; } void trdmain1(errcxdef *errctx); @@ -59,6 +107,72 @@ public: * printf-style formatting */ void trdptf(const char *fmt, ...); + + /**@}*/ + + /** + * \defgroup cmap + * @{ + */ + + /** + * Initialize the default character mappings. If no mapping file is to + * be read, this function will establish identify mappings that leave + * characters untranslated. + */ + void cmap_init_default(); + + /** + * Load a character map file. Returns zero on success, non-zero on + * failure. If filename is null, we'll use the default mapping. + */ + int cmap_load(const char *filename); + + /** + * Turn off character translation. This overrides any game character + * set that we find and simply uses the default translation. + */ + void cmap_override(void); + + /** + * Set the game's internal character set. This should be called when a + * game is loaded, and the game specifies an internal character set. If + * there is no character map file explicitly loaded, we will attempt to + * load a character mapping file that maps this character set to the + * current native character set. Signals an error on failure. This + * routine will succeed (without doing anything) if a character set has + * already been explicitly loaded, since an explicitly-loaded character + * set overrides the automatic character set selection that we attempt + * when loading a game. + * + * argv0 must be provided so that we know where to look for our mapping + * file on systems where mapping files are stored in the same directory + * as the TADS executables. + */ + void cmap_set_game_charset(errcxdef *errctx, const char *internal_id, + const char *internal_ldesc, const char *argv0); + + /** + * Internal routine to load a character map from a file + */ + int cmap_load_internal(const char *filename); + + /**@}*/ +public: + /** + * Constructor + */ + TADS2(OSystem *syst, const GlkGameDescription &gameDesc); + + /** + * Execute the game + */ + virtual void runGame(Common::SeekableReadStream *gameFile) override; + + /** + * Returns the running interpreter type + */ + virtual InterpreterType getInterpreterType() const override { return INTERPRETER_TADS2; } }; typedef TADS2 appctxdef; |