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_FROTZ_FROTZ_TYPES
24 #define GLK_FROTZ_FROTZ_TYPES
25 
26 #include "glk/glk_types.h"
27 #include "common/algorithm.h"
28 
29 namespace Glk {
30 namespace Frotz {
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 ZCode {
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 	UNKNOWN
89 };
90 
91 enum Version {
92 	V1 = 1,
93 	V2 = 2,
94 	V3 = 3,
95 	V4 = 4,
96 	V5 = 5,
97 	V6 = 6,
98 	V7 = 7,
99 	V8 = 8,
100 	V9 = 9
101 };
102 
103 enum {
104 	TRANSPARENT_FLAG = 0x0001 ///< Game wants to use transparency     - V6
105 };
106 
107 enum ErrorCode {
108 	ERR_TEXT_BUF_OVF   = 1,		///< Text buffer overflow
109 	ERR_STORE_RANGE    = 2,		///< Store out of dynamic memory
110 	ERR_DIV_ZERO       = 3,		///< Division by zero
111 	ERR_ILL_OBJ        = 4,		///< Illegal object
112 	ERR_ILL_ATTR       = 5,		///< Illegal attribute
113 	ERR_NO_PROP        = 6,		///< No such property
114 	ERR_STK_OVF        = 7,		///< Stack overflow
115 	ERR_ILL_CALL_ADDR  = 8,		///< Call to illegal address
116 	ERR_CALL_NON_RTN   = 9,		///< Call to non-routine
117 	ERR_STK_UNDF       = 10,	///< Stack underflow
118 	ERR_ILL_OPCODE     = 11,	///< Illegal opcode
119 	ERR_BAD_FRAME      = 12,	///< Bad stack frame
120 	ERR_ILL_JUMP_ADDR  = 13,	///< Jump to illegal address
121 	ERR_SAVE_IN_INTER  = 14,	///< Can't save while in interrupt
122 	ERR_STR3_NESTING   = 15,	///< Nesting stream #3 too deep
123 	ERR_ILL_WIN        = 16,	///< Illegal window
124 	ERR_ILL_WIN_PROP   = 17,	///< Illegal window property
125 	ERR_ILL_PRINT_ADDR = 18,	///< Print at illegal address
126 	ERR_DICT_LEN       = 19,	///< Illegal dictionary word length
127 	ERR_MAX_FATAL      = 19,
128 
129 	// Less serious errors
130 	ERR_JIN_0            = 20,	///< @jin called with object 0
131 	ERR_GET_CHILD_0      = 21,	///< @get_child called with object 0
132 	ERR_GET_PARENT_0     = 22,	///< @get_parent called with object 0
133 	ERR_GET_SIBLING_0    = 23,	///< @get_sibling called with object 0
134 	ERR_GET_PROP_ADDR_0  = 24,	///< @get_prop_addr called with object 0
135 	ERR_GET_PROP_0       = 25,	///< @get_prop called with object 0
136 	ERR_PUT_PROP_0       = 26,	///< @put_prop called with object 0
137 	ERR_CLEAR_ATTR_0     = 27,	///< @clear_attr called with object 0
138 	ERR_SET_ATTR_0       = 28,	///< @set_attr called with object 0
139 	ERR_TEST_ATTR_0      = 29,	///< @test_attr called with object 0
140 	ERR_MOVE_OBJECT_0    = 30,	///< @move_object called moving object 0
141 	ERR_MOVE_OBJECT_TO_0 = 31,	///< @move_object called moving into object 0
142 	ERR_REMOVE_OBJECT_0  = 32,	///< @remove_object called with object 0
143 	ERR_GET_NEXT_PROP_0  = 33,	///< @get_next_prop called with object 0
144 	ERR_NUM_ERRORS       = 33
145 };
146 
147 enum FrotzInterp {
148 	INTERP_DEFAULT    =  0,
149 	INTERP_DEC_20     =  1,
150 	INTERP_APPLE_IIE  =  2,
151 	INTERP_MACINTOSH  =  3,
152 	INTERP_AMIGA      =  4,
153 	INTERP_ATARI_ST   =  5,
154 	INTERP_MSDOS      =  6,
155 	INTERP_CBM_128    =  7,
156 	INTERP_CBM_64     =  8,
157 	INTERP_APPLE_IIC  =  9,
158 	INTERP_APPLE_IIGS = 10,
159 	INTERP_TANDY      = 11
160 };
161 
162 enum Colour {
163 	BLACK_COLOUR       = 2,
164 	RED_COLOUR         = 3,
165 	GREEN_COLOUR       = 4,
166 	YELLOW_COLOUR      = 5,
167 	BLUE_COLOUR        = 6,
168 	MAGENTA_COLOUR     = 7,
169 	CYAN_COLOUR        = 8,
170 	WHITE_COLOUR       = 9,
171 	GREY_COLOUR        = 10,	///< INTERP_MSDOS only
172 	LIGHTGREY_COLOUR   = 10, 	///< INTERP_AMIGA only
173 	MEDIUMGREY_COLOUR  = 11, 	///< INTERP_AMIGA only
174 	DARKGREY_COLOUR    = 12,	///< INTERP_AMIGA only
175 	TRANSPARENT_COLOUR = 15		///< ZSpec 1.1
176 };
177 
178 enum Style {
179 	REVERSE_STYLE     = 1,
180 	BOLDFACE_STYLE    = 2,
181 	EMPHASIS_STYLE    = 4,
182 	FIXED_WIDTH_STYLE = 8
183 };
184 
185 enum FontStyle {
186 	PREVIOUS_FONT    = 0,
187 	TEXT_FONT        = 1,
188 	PICTURE_FONT     = 2,
189 	GRAPHICS_FONT    = 3,
190 	FIXED_WIDTH_FONT = 4
191 };
192 
193 /*** Constants for os_beep */
194 
195 #define BEEP_HIGH       1
196 #define BEEP_LOW        2
197 
198 /*** Constants for os_menu */
199 
200 #define MENU_NEW 0
201 #define MENU_ADD 1
202 #define MENU_REMOVE 2
203 
204 typedef byte zbyte;
205 typedef uint32 zchar;
206 typedef uint16 zword;
207 
208 #define MAX_NESTING 16
209 struct Redirect {
210 	zword _xSize;
211 	zword _table;
212 	zword _width;
213 	zword _total;
214 
RedirectRedirect215 	Redirect() : _xSize(0), _table(0), _width(0), _total(0) {}
216 	Redirect(zword xSize, zword table, zword width = 0, zword total = 0) :
_xSizeRedirect217 		_xSize(xSize), _table(table), _width(width), _total(total) {}
218 };
219 
220 } // End of namespace Frotz
221 } // End of namespace Glk
222 
223 #endif
224