1 /* Sarien - A Sierra AGI resource interpreter engine 2 * Copyright (C) 1999-2001 Stuart George and Claudio Matsuoka 3 * 4 * $Id: sarien.h,v 1.79 2001/11/06 21:27:59 cmatsuoka Exp $ 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; see docs/COPYING for further details. 9 */ 10 11 #ifndef __SARIEN_H 12 #define __SARIEN_H 13 14 #ifdef __cplusplus 15 extern "C"{ 16 #endif 17 18 #ifdef DMALLOC 19 # include <stdlib.h> 20 # include <dmalloc.h> 21 #endif 22 23 /* Default features -- can be overriden in portdefs.h */ 24 #define USE_CONSOLE 25 #define USE_PCM_SOUND 26 #define USE_IIGS_SOUND 27 #define USE_HIRES 28 #define USE_COMMAND_LINE 29 #define USE_MOUSE 30 #define AGDS_SUPPORT 31 #define OPT_LIST_OBJECTS 32 #define OPT_PICTURE_VIEWER 33 #define OPT_LIST_DICT 34 #define FANCY_BOX 35 36 #include "console.h" 37 38 #define TITLE "Sarien" 39 40 #define DIR_ "dir." 41 #define LOGDIR "logdir" 42 #define PICDIR "picdir" 43 #define VIEWDIR "viewdir" 44 #define SNDDIR "snddir" 45 #define OBJECTS "object" 46 #define WORDS "words.tok" 47 48 #define MAX_DIRS 256 49 #define MAX_VARS 256 50 #define MAX_FLAGS (256 >> 3) 51 #define MAX_VIEWTABLE 64 52 #define MAX_WORDS 20 53 #define MAX_WORDS1 24 54 #define MAX_WORDS2 41 /* Last string is used by get.num */ 55 #ifndef MAX_PATH 56 #define MAX_PATH 260 57 #endif 58 59 #define _EMPTY 0xfffff 60 #define EGO_OWNED 0xff 61 62 #define CRYPT_KEY_SIERRA "Avis Durgan" 63 #define CRYPT_KEY_AGDS "Alex Simkin" 64 65 /* You'll need an ANSI terminal to use these :\ */ 66 #ifdef _TRACE 67 # include <stdio.h> 68 # ifdef __GNUC__ 69 # define _D_INFO "\x1b[33m" 70 # define _D_CRIT "\x1b[31m" 71 # define _D_WARN "\x1b[36m" 72 # define _D(args...) do { \ 73 printf("\x1b[33m" __PRETTY_FUNCTION__ " \x1b[37m[" __FILE__ \ 74 ":%d] " _D_INFO, __LINE__); printf (args); printf ("\x1b[0m\n"); \ 75 } while (0) 76 # else 77 # define _D_INFO "I: " 78 # define _D_CRIT "C: " 79 # define _D_WARN "W: " 80 # define _D fflush(stdout); printf("\n%s:%d: ", __FILE__, __LINE__); printf 81 # endif /* __GNUC__ */ 82 #else /* _TRACE */ 83 # define _D_INFO 84 # define _D_CRIT 85 # define _D_WARN 86 # ifdef __GNUC__ 87 # define _D(args...) 88 # else 89 # ifdef _D 90 # undef _D 91 # endif 92 void _D(char *, ...); 93 # endif /* __GNUC__ */ 94 #endif /* _TRACE */ 95 96 97 /* Include port-specific definitions 98 * 99 * In most C compiler implementation, quoted form of #include 100 * searches in the same folder first. On the contrary, angle-bracket 101 * form starts search in compiler predefined order. So, #include 102 * <portdefs.h> would be more correct. --Vasyl 103 */ 104 #include <portdefs.h> 105 106 107 #ifndef FALSE 108 # define FALSE 0 109 # define TRUE (!FALSE) 110 #endif 111 112 #ifndef INLINE 113 # define INLINE 114 #endif 115 116 #ifndef USE_PCM_SOUND 117 # undef USE_IIGS_SOUND 118 #endif 119 120 #ifdef FANCY_BOX 121 # define MSG_BOX_COLOUR 0x07 /* Grey */ 122 # define MENU_BG 0x07 /* Grey */ 123 #else 124 # define MSG_BOX_COLOUR 0x0f /* White */ 125 # define MENU_BG 0x0f /* White */ 126 #endif 127 128 #define MSG_BOX_TEXT 0x00 /* Black */ 129 #define MSG_BOX_LINE 0x04 /* Red */ 130 #define MENU_FG 0x00 /* Black */ 131 #define MENU_LINE 0x00 /* Black */ 132 #define STATUS_FG 0x00 /* Black */ 133 #define STATUS_BG 0x0f /* White */ 134 135 #define DISABLE_COPYPROTECTION /* only works on some games */ 136 137 138 UINT8 lohi_getbyte (UINT8 *); 139 UINT16 lohi_getword (UINT8 *); 140 UINT32 lohi_getpword (UINT8 *); 141 UINT32 lohi_getdword (UINT8 *); 142 UINT8 hilo_getbyte (UINT8 *); 143 UINT16 hilo_getword (UINT8 *); 144 UINT32 hilo_getpword (UINT8 *); 145 UINT32 hilo_getdword (UINT8 *); 146 int getflag (int); 147 void setflag (int, int); 148 void flipflag (int); 149 int getvar (int); 150 void setvar (int, int); 151 void decrypt (UINT8 *mem, int len); 152 void release_sprites (void); 153 int main_cycle (void); 154 int view_pictures (void); 155 int parse_cli (int, char **); 156 int run_game (void); 157 int init_machine (int, char **); 158 int deinit_machine (void); 159 int file_isthere (char *fname); /* Allegro has file_exists() */ 160 char* file_name (char *fname); 161 char* fixpath (int flag, char *fname); 162 int get_direction (int x, int y, int x0, int y0, int s); 163 void inventory (void); 164 void list_games (void); 165 int v2id_game (void); 166 int v3id_game (void); 167 void update_timer (void); 168 /* 169 * get_current_directory() returns the current working 170 * directory name in a platform independent manner. On 171 * Unix, DOS, and Win32, it just returns a "." string. 172 * On MacOS, there is no concept of a "." directory, so 173 * more detailed (and platform dependent) code would be 174 * needed there. Hence the need for abstraction. 175 * 176 * Return values from this function should be considered 177 * read-only, static, and non-thread safe. Assume that 178 * each call to this function will overwrite the previously 179 * returned data. 180 * 181 * Implementations of this function are in src/filesys/. 182 */ 183 char* get_current_directory (void); 184 char* get_config_file (void); 185 int get_app_dir (char *app_dir, unsigned int size); 186 187 188 enum { 189 NO_GAMEDIR = 0, 190 GAMEDIR 191 }; 192 193 enum error { 194 err_OK = 0, 195 err_DoNothing, 196 err_BadCLISwitch, 197 err_InvalidAGIFile, 198 err_BadFileOpen, 199 err_NotEnoughMemory, 200 err_BadResource, 201 err_UnknownAGIVersion, 202 err_RestartGame, 203 err_NoLoopsInView, 204 err_ViewDataError, 205 err_NoGameList, 206 207 err_Unk = 127 208 }; 209 210 /** 211 * AGI resources. 212 */ 213 enum { 214 rLOGIC = 1, 215 rSOUND, 216 rVIEW, 217 rPICTURE 218 }; 219 220 enum { 221 RES_LOADED = 1, 222 RES_CACHED = 2, 223 RES_COMPRESSED = 0x40 224 }; 225 226 enum { 227 lCOMMAND_MODE = 1, 228 lTEST_MODE 229 }; 230 231 enum { 232 eKEY_PRESS = 1, 233 eSCAN_CODE, 234 eMENU_PRESS 235 }; 236 237 enum { 238 GFX_MODE = 1, 239 TXT_MODE 240 }; 241 242 243 struct game_id_list { 244 struct game_id_list *next; 245 UINT32 version; 246 UINT32 crc; 247 char *gName; 248 char *switches; 249 }; 250 251 #ifdef USE_MOUSE 252 struct mouse { 253 int button; 254 unsigned int x; 255 unsigned int y; 256 }; 257 #endif 258 259 /** 260 * Command-line options. 261 */ 262 struct sarien_options { 263 int forceload; /**< force loading of all resources */ 264 int cache; /**< cache loaded resources */ 265 #define GAMERUN_RUNGAME 0 266 #define GAMERUN_PICVIEW 1 267 #define GAMERUN_WORDS 2 268 #define GAMERUN_OBJECTS 3 269 #define GAMERUN_GAMES 4 270 #define GAMERUN_CRC 5 271 int gamerun; /**< game run mode*/ 272 int emuversion; /**< AGI version to emulate */ 273 int scale; /**< window scale factor */ 274 int fixratio; /**< fix aspect ratio */ 275 int agds; /**< enable AGDS mode */ 276 int amiga; /**< enable Amiga mode */ 277 int fullscreen; /**< use full screen mode if available */ 278 int nosound; /**< disable sound */ 279 #ifdef MITSHM 280 int mitshm; /**< use shared memory extension */ 281 #endif 282 #ifdef XF86DGA 283 int dga; /**< use XFree86 DGA extension */ 284 #endif 285 #ifdef USE_HIRES 286 int hires; /**< use hi-res pictures */ 287 #endif 288 int soundemu; /**< sound emulation mode */ 289 int gfxhacks; /**< enable graphics driver optimizations */ 290 #ifdef USE_MOUSE 291 int agimouse; /**< AGI Mouse 1.0 emulation */ 292 #endif 293 }; 294 295 extern struct sarien_options opt; 296 extern UINT8 *exec_name; 297 298 extern volatile UINT32 clock_ticks; 299 extern volatile UINT32 clock_count; 300 extern volatile UINT32 msg_box_secs2; 301 302 #ifdef USE_CONSOLE 303 extern struct sarien_debug debug; 304 #endif 305 306 #ifdef USE_MOUSE 307 extern struct mouse mouse; 308 #endif 309 310 #ifdef __cplusplus 311 }; 312 #endif 313 314 #endif /* __SARIEN_H */ 315 316