1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef GLK_ZCODE_FROTZ_TYPES
24 #define GLK_ZCODE_FROTZ_TYPES
25 
26 #include "glk/glk_types.h"
27 #include "common/algorithm.h"
28 
29 namespace Glk {
30 namespace ZCode {
31 
32 #define MAX_UNDO_SLOTS 500
33 #define STACK_SIZE 32768
34 
35 #define lo(v)	(v & 0xff)
36 #define hi(v)	(v >> 8)
37 
38 /**
39  * Character codes
40  */
41 enum ZCodeKey {
42 	ZC_TIME_OUT      = 0x00,
43 	ZC_NEW_STYLE     = 0x01,
44 	ZC_NEW_FONT      = 0x02,
45 	ZC_BACKSPACE     = 0x08,
46 	ZC_INDENT        = 0x09,
47 	ZC_GAP           = 0x0b,
48 	ZC_RETURN        = 0x0d,
49 	ZC_HKEY_MIN      = 0x0e,
50 	ZC_HKEY_RECORD   = 0x0e,
51 	ZC_HKEY_PLAYBACK = 0x0f,
52 	ZC_HKEY_SEED     = 0x10,
53 	ZC_HKEY_UNDO     = 0x11,
54 	ZC_HKEY_RESTART  = 0x12,
55 	ZC_HKEY_QUIT     = 0x13,
56 	ZC_HKEY_DEBUG    = 0x14,
57 	ZC_HKEY_HELP     = 0x15,
58 	ZC_HKEY_MAX      = 0x15,
59 	ZC_ESCAPE        = 0x1b,
60 	ZC_ASCII_MIN     = 0x20,
61 	ZC_ASCII_MAX     = 0x7e,
62 	ZC_BAD           = 0x7f,
63 	ZC_ARROW_MIN     = 0x81,
64 	ZC_ARROW_UP      = 0x81,
65 	ZC_ARROW_DOWN    = 0x82,
66 	ZC_ARROW_LEFT    = 0x83,
67 	ZC_ARROW_RIGHT   = 0x84,
68 	ZC_ARROW_MAX     = 0x84,
69 	ZC_FKEY_MIN      = 0x85,
70 	ZC_FKEY_MAX      = 0x90,
71 	ZC_NUMPAD_MIN    = 0x91,
72 	ZC_NUMPAD_MAX    = 0x9a,
73 	ZC_SINGLE_CLICK  = 0x9b,
74 	ZC_DOUBLE_CLICK  = 0x9c,
75 	ZC_MENU_CLICK    = 0x9d,
76 	ZC_LATIN1_MIN    = 0xa0,
77 	ZC_LATIN1_MAX    = 0xff
78 };
79 
80 enum Story {
81 	BEYOND_ZORK,
82 	SHERLOCK,
83 	ZORK_ZERO,
84 	SHOGUN,
85 	ARTHUR,
86 	JOURNEY,
87 	LURKING_HORROR,
88 	MILLIWAYS,
89 	UNKNOWN
90 };
91 
92 enum Version {
93 	V1 = 1,
94 	V2 = 2,
95 	V3 = 3,
96 	V4 = 4,
97 	V5 = 5,
98 	V6 = 6,
99 	V7 = 7,
100 	V8 = 8,
101 	V9 = 9
102 };
103 
104 enum {
105 	TRANSPARENT_FLAG = 0x0001 ///< Game wants to use transparency     - V6
106 };
107 
108 enum ErrorCode {
109 	ERR_TEXT_BUF_OVF   = 1,		///< Text buffer overflow
110 	ERR_STORE_RANGE    = 2,		///< Store out of dynamic memory
111 	ERR_DIV_ZERO       = 3,		///< Division by zero
112 	ERR_ILL_OBJ        = 4,		///< Illegal object
113 	ERR_ILL_ATTR       = 5,		///< Illegal attribute
114 	ERR_NO_PROP        = 6,		///< No such property
115 	ERR_STK_OVF        = 7,		///< Stack overflow
116 	ERR_ILL_CALL_ADDR  = 8,		///< Call to illegal address
117 	ERR_CALL_NON_RTN   = 9,		///< Call to non-routine
118 	ERR_STK_UNDF       = 10,	///< Stack underflow
119 	ERR_ILL_OPCODE     = 11,	///< Illegal opcode
120 	ERR_BAD_FRAME      = 12,	///< Bad stack frame
121 	ERR_ILL_JUMP_ADDR  = 13,	///< Jump to illegal address
122 	ERR_SAVE_IN_INTER  = 14,	///< Can't save while in interrupt
123 	ERR_STR3_NESTING   = 15,	///< Nesting stream #3 too deep
124 	ERR_ILL_WIN        = 16,	///< Illegal window
125 	ERR_ILL_WIN_PROP   = 17,	///< Illegal window property
126 	ERR_ILL_PRINT_ADDR = 18,	///< Print at illegal address
127 	ERR_DICT_LEN       = 19,	///< Illegal dictionary word length
128 	ERR_MAX_FATAL      = 19,
129 
130 	// Less serious errors
131 	ERR_JIN_0            = 20,	///< @jin called with object 0
132 	ERR_GET_CHILD_0      = 21,	///< @get_child called with object 0
133 	ERR_GET_PARENT_0     = 22,	///< @get_parent called with object 0
134 	ERR_GET_SIBLING_0    = 23,	///< @get_sibling called with object 0
135 	ERR_GET_PROP_ADDR_0  = 24,	///< @get_prop_addr called with object 0
136 	ERR_GET_PROP_0       = 25,	///< @get_prop called with object 0
137 	ERR_PUT_PROP_0       = 26,	///< @put_prop called with object 0
138 	ERR_CLEAR_ATTR_0     = 27,	///< @clear_attr called with object 0
139 	ERR_SET_ATTR_0       = 28,	///< @set_attr called with object 0
140 	ERR_TEST_ATTR_0      = 29,	///< @test_attr called with object 0
141 	ERR_MOVE_OBJECT_0    = 30,	///< @move_object called moving object 0
142 	ERR_MOVE_OBJECT_TO_0 = 31,	///< @move_object called moving into object 0
143 	ERR_REMOVE_OBJECT_0  = 32,	///< @remove_object called with object 0
144 	ERR_GET_NEXT_PROP_0  = 33,	///< @get_next_prop called with object 0
145 	ERR_NUM_ERRORS       = 33
146 };
147 
148 enum FrotzInterp {
149 	INTERP_DEFAULT    =  0,
150 	INTERP_DEC_20     =  1,
151 	INTERP_APPLE_IIE  =  2,
152 	INTERP_MACINTOSH  =  3,
153 	INTERP_AMIGA      =  4,
154 	INTERP_ATARI_ST   =  5,
155 	INTERP_MSDOS      =  6,
156 	INTERP_CBM_128    =  7,
157 	INTERP_CBM_64     =  8,
158 	INTERP_APPLE_IIC  =  9,
159 	INTERP_APPLE_IIGS = 10,
160 	INTERP_TANDY      = 11
161 };
162 
163 enum Colour {
164 	BLACK_COLOUR       = 2,
165 	RED_COLOUR         = 3,
166 	GREEN_COLOUR       = 4,
167 	YELLOW_COLOUR      = 5,
168 	BLUE_COLOUR        = 6,
169 	MAGENTA_COLOUR     = 7,
170 	CYAN_COLOUR        = 8,
171 	WHITE_COLOUR       = 9,
172 	GREY_COLOUR        = 10,	///< INTERP_MSDOS only
173 	LIGHTGREY_COLOUR   = 10, 	///< INTERP_AMIGA only
174 	MEDIUMGREY_COLOUR  = 11, 	///< INTERP_AMIGA only
175 	DARKGREY_COLOUR    = 12,	///< INTERP_AMIGA only
176 	TRANSPARENT_COLOUR = 15		///< ZSpec 1.1
177 };
178 
179 enum Style {
180 	REVERSE_STYLE     = 1,
181 	BOLDFACE_STYLE    = 2,
182 	EMPHASIS_STYLE    = 4,
183 	FIXED_WIDTH_STYLE = 8
184 };
185 
186 enum FontStyle {
187 	PREVIOUS_FONT    = 0,
188 	TEXT_FONT        = 1,
189 	PICTURE_FONT     = 2,
190 	GRAPHICS_FONT    = 3,
191 	FIXED_WIDTH_FONT = 4
192 };
193 
194 /*** Constants for os_beep */
195 
196 #define BEEP_HIGH       1
197 #define BEEP_LOW        2
198 
199 /*** Constants for os_menu */
200 
201 #define MENU_NEW 0
202 #define MENU_ADD 1
203 #define MENU_REMOVE 2
204 
205 typedef byte zbyte;
206 typedef uint32 zchar;
207 typedef uint16 zword;
208 
209 #define MAX_NESTING 16
210 struct Redirect {
211 	zword _xSize;
212 	zword _table;
213 	zword _width;
214 	zword _total;
215 
RedirectRedirect216 	Redirect() : _xSize(0), _table(0), _width(0), _total(0) {}
217 	Redirect(zword xSize, zword table, zword width = 0, zword total = 0) :
_xSizeRedirect218 		_xSize(xSize), _table(table), _width(width), _total(total) {}
219 };
220 
221 } // End of namespace ZCode
222 } // End of namespace Glk
223 
224 #endif
225