Debian Codegraph @

terps/hugo/source/heheader.h

raw symbols SCIP
1 /*
2 HEHEADER.H
3
4 contains definitions and prototypes
5 for the Hugo Engine
6
7 Copyright (c) 1995-2009 by Kent Tessman
8 */
9
10
11 #define HEVERSION 3
12 #define HEREVISION 1
13 #if !defined (COMPILE_V25)
14 #define HEINTERIM ".06"
15 #else
16 #define HEINTERIM ".06 (2.5)"
17 #endif
18
19 #include <string.h>
20
21 #include <ctype.h>
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <time.h>
25
26 /* The Hugo token set and their respective values are contained
27 separately in htokens.h
28 */
29 #include "htokens.h"
30 extern char *token[];
31
32
33 /* Define the compiler being used (or library) as one of:
34
35 ACORN
36 AMIGA
37 BEOS
38 DJGPP
39 GCC_OS2
40 GCC_UNIX
41 GCC_BEOS
42 GLK (Glk portable interface)
43 PALMOS (Palm OS built with CodeWarrior)
44 QUICKC
45 RISCOS
46 WIN32 (Microsoft Visual C++)
47 WXWINDOWS (wxWindows for Mac or Gtk)
48
49 (although this is typically done in the makefile)
50 */
51
52 /*---------------------------------------------------------------------------
53 Definitions for the Acorn Archimedes & RPC
54 using Acorn C Compiler (v4)
55
56 by Colin Turnbull
57 ---------------------------------------------------------------------------*/
58
59 #if defined (ACORN)
60
61 #define PORT_NAME "Acorn"
62 #define PORTER_NAME "ct"
63
64 #define HUGO_FOPEN arc_fopen
65
66 #define MAXPATH 256
67 #define MAXFILENAME 64 /* We _could_ be using LongFilenames */
68 #define MAXDRIVE 32 /* arcfs#SCSIFS::harddisc4 ? */
69 #define MAXDIR 256
70 #define MAXEXT 32
71
72 #define isascii(c) ((unsigned int)(c)<0x80)
73 #define toascii(c) ((c)&0x7f)
74
75 #define DEF_PRN ""
76
77 #define DEF_FCOLOR 7
78 #define DEF_BGCOLOR 0
79 #define DEF_SLFCOLOR 15
80 #define DEF_SLBGCOLOR 1
81
82 #define MAXBUFFER 255
83
84 /* Added these functions for the Acorn port: */
85 FILE *arc_fopen(const char *, const char *);
86 void arc_colour(unsigned char n, unsigned int c);
87
88 #endif /* defined (ACORN) */
89
90
91 /*---------------------------------------------------------------------------
92 Definitions for the djgpp/Allegro build(s)
93
94 by Kent Tessman
95 ---------------------------------------------------------------------------*/
96
97 #if defined (DJGPP) && !defined (GCC_UNIX)
98 #include <unistd.h>
99 #include <dir.h>
100
101 #define PORT_NAME "32-bit"
102 #define PORTER_NAME "Kent Tessman"
103
104 #define EXTRA_STRING_FUNCTIONS
105
106 #define DEF_PRN "LPT1"
107
108 /* MAXPATH, MAXDRIVE, MAXDIR, MAXEXT defined in <dir.h> */
109 #define MAXFILENAME MAXFILE
110
111 #define DEF_FCOLOR 7
112 #define DEF_BGCOLOR 0
113 #define DEF_SLFCOLOR 15
114 #define DEF_SLBGCOLOR 1
115
116 #define MAXBUFFER 255
117
118 #define HUGO_INLINE static __inline
119
120 #if defined (ALLEGRO)
121 #define FRONT_END
122 #define GRAPHICS_SUPPORTED
123 #define SOUND_SUPPORTED
124 #undef PORT_NAME
125 #define PORT_NAME "32-bit Allegro"
126
127 #if !defined (PROGRAM_NAME) && !defined (DEBUGGER)
128 #define PROGRAM_NAME "hegr"
129 #elif defined (DEBUGGER)
130 #define PROGRAM_NAME "hdgr"
131 #endif
132 #endif /* defined (ALLEGRO) */
133
134 #endif /* defined (DJGPP) */
135
136
137 /*---------------------------------------------------------------------------
138 Definitions for the Amiga port
139
140 by David Kinder
141 ---------------------------------------------------------------------------*/
142
143 #if defined (AMIGA)
144
145 #define PORT_NAME "Amiga"
146 #define PORTER_NAME "David Kinder"
147
148 #define MAXPATH 256
149 #define MAXFILENAME 256
150 #define MAXDRIVE 256
151 #define MAXDIR 256
152 #define MAXEXT 256
153
154 #define DEF_PRN "PRT:"
155
156 #define DEF_FCOLOR 7
157 #define DEF_BGCOLOR 0
158 #define DEF_SLFCOLOR 15
159 #define DEF_SLBGCOLOR 1
160
161 #define MAXBUFFER 255
162
163 #endif /* defined (AMIGA) */
164
165
166 /*---------------------------------------------------------------------------
167 Definitions for the GCC Unix port
168
169 Originally by Bill Lash
170 ---------------------------------------------------------------------------*/
171
172 #if defined (GCC_UNIX) || defined (GCC_BEOS)
173
174 #include <unistd.h>
175
176 #ifndef GCC_BEOS
177 #define PORT_NAME "Unix"
178 #ifndef DEBUGGER
179 #define PORTER_NAME "Bill Lash"
180 #else
181 #define PORTER_NAME "Kent Tessman"
182 #endif /* DEBUGGER */
183 #else
184 #define PORT_NAME "BeOS"
185 #define PORTER_NAME "Kent Tessman"
186 #endif /* GCC_BEOS */
187
188 #define EXTRA_STRING_FUNCTIONS
189
190 #define MAXPATH 256
191 #define MAXFILENAME 256
192 #define MAXDRIVE 256
193 #define MAXDIR 256
194 #define MAXEXT 256
195
196 #define DEF_PRN "/dev/lp" /* Bill suggests this is perhaps
197 a less-than-ideal choice for
198 the default printer */
199 #define DEF_FCOLOR 7
200 #define DEF_BGCOLOR 0
201 #define DEF_SLFCOLOR 15
202 #define DEF_SLBGCOLOR 1
203
204 #define MAXBUFFER 255
205
206 #define HUGO_INLINE static __inline
207
208 #endif /* defined (GCC_UNIX) */
209
210
211 /*---------------------------------------------------------------------------
212 Definitions for the GCC OS/2 port
213
214 by Gerald Bostock
215 ---------------------------------------------------------------------------*/
216
217 #if defined (GCC_OS2)
218
219 #define PORT_NAME "OS/2"
220 #define PORTER_NAME "Gerald Bostock"
221
222 #define EXTRA_STRING_FUNCTIONS
223
224 #define MAXPATH 256
225 #define MAXFILENAME 256
226 #define MAXDRIVE 256
227 #define MAXDIR 256
228 #define MAXEXT 256
229
230 #define DEF_PRN "LPT1"
231 #define DEF_FCOLOR 7
232 #define DEF_BGCOLOR 0
233 #define DEF_SLFCOLOR 15
234 #define DEF_SLBGCOLOR 1
235
236 #define MAXBUFFER 255
237
238 #define HUGO_INLINE static __inline
239
240 #endif /* defined (GCC_OS2) */
241
242
243 /*---------------------------------------------------------------------------
244 Definitions for the MacOS Glk port
245
246 by Andrew Plotkin
247 ---------------------------------------------------------------------------*/
248
249 #if defined (GLK) && defined (__MACOS__)
250
251 #define BUILD_RANDOM
252 #define RANDOM random
253 #define SRANDOM srandom
254
255 /* Some symbol redefinitions necessary on the Mac, due to conflicts
256 with Mac Toolbox names
257 */
258 #define GetString HugoGetString
259 #define FindWord HugoFindWord
260
261 #endif /* Mac Glk */
262
263 #if defined (GLK) && defined (__APPLE__)
264
265 #define GetString HugoGetString
266 #define FindWord HugoFindWord
267
268 #endif /* Mac OS X Glk */
269
270 /*---------------------------------------------------------------------------
271 Definitions for the Glk port
272
273 by Kent Tessman and Andrew Plotkin
274 ---------------------------------------------------------------------------*/
275
276 #if defined (GLK)
277
278 #include "glk.h"
279
280 #ifdef HUGO_GLKUNIX
281 extern char *hugo_path_to_game;
282 #endif
283
284 #define PORT_NAME "Glk"
285 #define PORTER_NAME "Kent Tessman and Andrew Plotkin"
286
287 #define HUGO_FILE strid_t
288 #define MAXPATH 256
289 #define MAXFILENAME 256
290 #define MAXDRIVE 256
291 #define MAXDIR 256
292 #define MAXEXT 256
293
294 #define DEF_PRN ""
295 #define DEF_FCOLOR 0
296 #define DEF_BGCOLOR 15
297 #define DEF_SLFCOLOR 15
298 #define DEF_SLBGCOLOR 1
299
300 #define MAXBUFFER 1280 /* larger than normal since Glk doesn't
301 break up paragraphs (1024+256)*/
302
303 #ifndef HUGO_INLINE
304 #define HUGO_INLINE __inline
305 #endif
306
307 #define FRONT_END
308 #define MINIMAL_INTERFACE
309
310 int heglk_get_linelength(void);
311 #define ACTUAL_LINELENGTH() heglk_get_linelength()
312 int heglk_get_screenheight(void);
313 #define ACTUAL_SCREENHEIGHT() heglk_get_screenheight()
314
315 void heglk_printfatalerror(char *err);
316 #define PRINTFATALERROR(a) heglk_printfatalerror(a)
317
318 #define EXTRA_STRING_FUNCTIONS
319
320 #ifndef isascii
321 #define isascii(c) (1)
322 #endif
323 #undef tolower
324 #undef toupper
325 #define tolower(c) (glk_char_to_lower((unsigned char)c))
326 #define toupper(c) (glk_char_to_upper((unsigned char)c))
327
328 /* Must always close Glk via glk_exit() */
329 #define exit(n) (glk_exit())
330
331 /* Glk doesn't use stdio; mapping these will cut radically down on
332 #ifdef sections in the source:
333 */
334 #undef fclose
335 #define fclose(f) (glk_stream_close(f, NULL), 0)
336 #undef ferror
337 #define ferror(f) (0) /* No ferror() equivalent */
338 #undef fgetc
339 #define fgetc(f) (glk_get_char_stream(f))
340 #undef fgets
341 #define fgets(a, n, f) (glk_get_line_stream(f, a, n))
342 #undef fread
343 #define fread(a,s,n,f) (glk_get_buffer_stream(f, (char *)a, n))
344 #undef fprintf
345 #define fprintf(f,s,a) (glk_put_string_stream(f, a), 0)
346 #undef fputc
347 #define fputc(c, f) (glk_put_char_stream(f, (unsigned char)(c)), 0)
348 #undef fputs
349 #define fputs(s, f) (glk_put_buffer_stream(f, s, strlen(s)), 0)
350 #undef ftell
351 #define ftell(f) (glk_stream_get_position(f))
352 #undef fseek
353 #define fseek(f, p, m) (glk_stream_set_position(f, p, m), 0)
354 #undef SEEK_SET
355 #define SEEK_SET seekmode_Start
356 #undef SEEK_END
357 #define SEEK_END seekmode_End
358
359 #endif /* defined (GLK) */
360
361
362 /*---------------------------------------------------------------------------
363 Definitions for Palm OS (built with CodeWarrior)
364
365 by Kent Tessman
366 ---------------------------------------------------------------------------*/
367
368 #if defined (PALMOS)
369
370 #include "palm_stdio.h"
371 #include "palm_ctype.h"
372 #include "palm_stdlib.h"
373 #include "palm_string.h"
374 #include "palm_time.h"
375
376 #define PORT_NAME "Palm OS"
377 #define PORTER_NAME "Kent Tessman"
378
379 #define HUGO_FILE PH_FILE*
380 #define HUGO_FOPEN ph_fopen
381
382 #define MAXFILENAME MAXPATH
383 /* No such thing as drive, directory, or extension in Palm OS */
384 #define MAXDRIVE 1
385 #define MAXDIR 1
386 #define MAXEXT 1
387
388 #define DEF_PRN ""
389
390 #define DEF_FCOLOR 16
391 #define DEF_BGCOLOR 17
392 #define DEF_SLFCOLOR 18
393 #define DEF_SLBGCOLOR 19
394
395 #define MAXBUFFER 256 /* max. input/output line length */
396
397 #define HUGO_INLINE __inline
398
399 #define NO_TERMINAL_LINEFEED
400 #define MINIMAL_WINDOWING
401 #define FRONT_END
402 #define SCROLLBACK_DEFINED
403 #define USE_TEXTBUFFER
404 #define TEXTBUFFER_FORMATTING
405 #define MAX_TEXTBUFFER_COUNT 100
406 #define USE_SMARTFORMATTING
407
408 extern void PopupMessage(char *title, char *msg);
409 extern char ph_debug;
410
411 #define PRINTFATALERROR PrintFatalError
412 #define PROMPTMORE_REPLACED
413 #define LOADGAMEDATA_REPLACED
414 #define RESTOREGAMEDATA_REPLACED
415 #define SAVEGAMEDATA_REPLACED
416 #define MEM(addr) GetMemValue(addr)
417 #define SETMEM(addr, n) SetMemValue(addr, n)
418 unsigned char GetMemValue(long addr);
419 void SetMemValue(long addr, unsigned char n);
420
421 #endif /* defined (PALMOS) */
422
423
424 /*---------------------------------------------------------------------------
425 Definitions for the RISC OS port
426
427 by Julian Arnold
428 ---------------------------------------------------------------------------*/
429
430 #if defined (RISCOS)
431
432 #define PORT_NAME "RISC OS"
433 #define PORTER_NAME "Julian Arnold"
434
435 #define MAXPATH 256
436 #define MAXFILENAME 256
437 #define MAXDRIVE 256
438 #define MAXDIR 256
439 #define MAXEXT 256
440
441 #define DEF_PRN ""
442
443 #define DEF_FCOLOR 7
444 #define DEF_BGCOLOR 0
445 #define DEF_SLFCOLOR 0
446 #define DEF_SLBGCOLOR 7
447
448 #define MAXBUFFER 255
449
450 #define isascii(c) ((unsigned int)(c)<0x80)
451 extern FILE *hugo_fopen (char *filename, char *mode);
452 #define HUGO_FOPEN hugo_fopen
453
454 #endif /* defined (RISCOS) */
455
456
457 /*---------------------------------------------------------------------------
458 MS-DOS specific definitions for Microsoft QuickC
459
460 by Kent Tessman
461 ---------------------------------------------------------------------------*/
462
463 #if defined (QUICKC)
464
465 #include <conio.h>
466
467 #define PORT_NAME "16-bit"
468 #define PORTER_NAME "Kent Tessman"
469
470 #define MATH_16BIT
471
472 #define MAXPATH _MAX_PATH /* maximum allowable lengths */
473 #define MAXFILENAME _MAX_FNAME
474 #define MAXDRIVE _MAX_DRIVE
475 #define MAXDIR _MAX_DIR
476 #define MAXEXT _MAX_EXT
477
478 #define DEF_PRN "LPT1" /* default printer */
479
480 #define DEF_FCOLOR 7 /* default colors, fore and back */
481 #define DEF_BGCOLOR 0
482 #define DEF_SLFCOLOR 15 /* statusline */
483 #define DEF_SLBGCOLOR 1
484
485 #define OMIT_EXTRA_STRING_FUNCTIONS
486
487 #define MAXBUFFER 255 /* max. input/output line length */
488
489 #endif /* defined (QUICKC) */
490
491
492 /*---------------------------------------------------------------------------
493 Definitions for Win32 (Microsoft Visual C++)
494 and WinCE (eVC++ 4.0/WCE SDK)
495
496 by Kent Tessman
497 ---------------------------------------------------------------------------*/
498
499 // For some reason, CMake defines WIN32 when building with MSVC, even though
500 // MSVC itself defines _WIN32, which is sufficient for determining if you're
501 // on Windows. All these ports really ought to be mututally exclusive, but
502 // for the time being, just don't do Windows-specific stuff here with Glk.
503 #if defined (WIN32) && !defined (WXWINDOWS) && !defined (GLK)
504
505 #ifdef UNDER_CE
506 #define PORT_NAME "WinCE"
507 #else
508 #define PORT_NAME "Win32"
509 #endif
510 #define PORTER_NAME "Kent Tessman"
511
512 #define DEF_PRN ""
513
514 #ifdef UNDER_CE
515 #define MAXPATH 260
516 #define MAXFILENAME 256
517 #define MAXDRIVE 3
518 #define MAXDIR 256
519 #define MAXEXT 256
520 #define getenv(a) ""
521 #else
522 #define MAXPATH _MAX_PATH
523 #define MAXFILENAME _MAX_FNAME
524 #define MAXDRIVE _MAX_DRIVE
525 #define MAXDIR _MAX_DIR
526 #define MAXEXT _MAX_EXT
527 #endif
528
529 #ifdef UNDER_CE
530 #define DEF_FCOLOR 0
531 #define DEF_BGCOLOR 15
532 #define DEF_SLFCOLOR 15
533 #define DEF_SLBGCOLOR 1
534 #else
535 #define DEF_FCOLOR 7
536 #define DEF_BGCOLOR 1
537 #define DEF_SLFCOLOR 15
538 #define DEF_SLBGCOLOR 0
539 #endif
540
541 #define MAXBUFFER 255
542 #define MAXUNDO 1024
543
544 #define HUGO_INLINE __inline
545
546 #define NO_TERMINAL_LINEFEED
547 #define BUILD_RANDOM
548 #define FRONT_END
549 #define USE_TEXTBUFFER
550 #define SCROLLBACK_DEFINED
551
552 #ifndef UNDER_CE
553 #ifndef USE_NT_SOUND_ONLY
554 #define SPEECH_ENABLED
555 #endif
556 #define USE_SMARTFORMATTING
557 #else
558 #define MINIMAL_WINDOWING
559 #endif // UNDER_CE
560
561 #undef FindResource
562
563 void PrintFatalError(char *a);
564 #define PRINTFATALERROR(a) PrintFatalError(a);
565
566 #endif /* defined (WIN32) */
567
568
569 /*---------------------------------------------------------------------------
570 Definitions for the wxWindows builds (wxGTK, wxMac, etc.)
571 and BeOS
572
573 by Kent Tessman
574 ---------------------------------------------------------------------------*/
575
576 /* Metrowerks compiler shortcomings */
577 #if defined (__POWERPC__) && defined (__MWERKS__) && !defined (__MACOS__)
578 #define BEOS
579 #define isascii(c) (((c) & ~0x7f) == 0) /* If c is a 7 bit value */
580 #define resource_type hugo_resource_type
581 #endif
582
583 #if defined (WXWINDOWS) || (defined (BEOS) && !defined (GCC_UNIX) && !defined(GCC_BEOS))
584
585 #ifdef __MACOS__
586 #define GetString HugoGetString
587 #define FindWord HugoFindWord
588 #endif
589 #if defined (__MACOS__) || defined (BEOS)
590 #define USE_SMARTFORMATTING
591 #endif
592
593 #define PORTER_NAME "Kent Tessman"
594 #if defined (WXWINDOWS)
595 #define PORT_NAME "wxWindows"
596 #define PROGRAM_NAME "hewx"
597 #else
598 #define PORT_NAME "BeOS"
599 #define PROGRAM_NAME "BeHugo"
600 void exit_he_thread(int n);
601 #define exit(n) exit_he_thread(n)
602 #undef DEBUGGER
603 #endif
604
605 #define DEF_PRN ""
606
607 #define MAXPATH 256
608 #define MAXDRIVE 256
609 #define MAXDIR 256
610 #define MAXFILENAME 256
611 #define MAXEXT 256
612
613 #define DEF_FCOLOR 0
614 #define DEF_BGCOLOR 15
615 #define DEF_SLFCOLOR 15
616 #define DEF_SLBGCOLOR 1
617
618 #define MAXBUFFER 255
619 #define MAXUNDO 1024
620
621 #define HUGO_INLINE static __inline
622
623 #define NO_TERMINAL_LINEFEED
624 #define FRONT_END
625 #define USE_TEXTBUFFER
626 #ifndef __WXMAC__
627 #define SCROLLBACK_DEFINED
628 #endif
629
630 extern void PrintFatalError(char *a);
631 #define PRINTFATALERROR(a) PrintFatalError(a);
632
633 #endif /* defined (WXWINDOWS) || defined (BEOS) */
634
635
636 /*-------------------------------------------------------------------------*/
637
638 #if !defined (PROGRAM_NAME) && !defined (DEBUGGER)
639 #define PROGRAM_NAME "he"
640 #endif
641
642 #if !defined (MEM)
643 #define MEM(addr) (mem[addr])
644 #endif
645
646 #if !defined (SETMEM)
647 #define SETMEM(addr, n) (mem[addr] = n)
648 #endif
649
650 #if !defined (GETMEMADDR)
651 #define GETMEMADDR(addr) (&mem[addr])
652 #endif
653
654 #if !defined (HUGO_PTR)
655 #define HUGO_PTR
656 #endif
657
658 #if !defined (HUGO_FILE)
659 #define HUGO_FILE FILE*
660 #endif
661
662 #if !defined (HUGO_FOPEN)
663 #define HUGO_FOPEN fopen
664 #endif
665
666 #ifndef HUGO_INLINE
667 #define NO_INLINE_MEM_FUNCTIONS
668 #define HUGO_INLINE static
669 #endif
670
671 #if defined (BUILD_RANDOM)
672 extern int random(void);
673 extern void srandom(int);
674 #endif
675
676 #if !defined (PRINTFATALERROR)
677 #define PRINTFATALERROR(a) fprintf(stderr, "%s", a)
678 #endif
679
680 #ifndef OMIT_EXTRA_STRING_FUNCTIONS
681 #define EXTRA_STRING_FUNCTIONS
682 #endif
683
684 #ifdef LOADGAMEDATA_REPLACED
685 /* If LOADGAMEDATA_REPLACED is #defined, LoadGameData() is called by
686 both LoadGame() and RunRestart(). RunRestart() sets the reload flag
687 to true.
688 */
689 int LoadGameData(char reload);
690 #endif
691
692 /* To be used with caution; obviously, not all non-zero values are "true"
693 in this usage.
694 */
695 #ifndef __cplusplus
696 #define true 1
697 #define false 0
698 #endif
699
700 /* These static values are not changeable--they depend largely on internals
701 of the Engine.
702 */
703 #define MAXATTRIBUTES 128
704 #define MAXGLOBALS 240
705 #define MAXLOCALS 16
706 #define MAXPOBJECTS 256 /* contenders for disambiguation */
707 #define MAXWORDS 32 /* in an input line */
708 #define MAXSTACKDEPTH 256 /* for nesting {...} */
709
710 #if !defined (MAXUNDO)
711 #define MAXUNDO 4096 /* number of undoable operations */
712 #endif
713
714 #if !defined (COMPILE_V25)
715 #define MAX_CONTEXT_COMMANDS 32
716 #endif
717
718 enum ERROR_TYPE /* fatal errors */
719 {
720 MEMORY_E = 1, /* out of memory */
721 OPEN_E, /* error opening file */
722 READ_E, /* error reading from file */
723 WRITE_E, /* error writing to file */
724 EXPECT_VAL_E, /* expecting value */
725 UNKNOWN_OP_E, /* unknown operation */
726 ILLEGAL_OP_E, /* illegal operation */
727 OVERFLOW_E, /* overflow */
728 DIVIDE_E /* divide by zero */
729 };
730
731 /* The positions of various data in the header: */
732 #define H_GAMEVERSION 0x00
733 #define H_ID 0x01
734 #define H_SERIAL 0x03
735 #define H_CODESTART 0x0B
736
737 #define H_OBJTABLE 0x0D /* data tables */
738 #define H_PROPTABLE 0x0F
739 #define H_EVENTTABLE 0x11
740 #define H_ARRAYTABLE 0x13
741 #define H_DICTTABLE 0x15
742 #define H_SYNTABLE 0x17
743
744 #define H_INIT 0x19 /* junction routines */
745 #define H_MAIN 0x1B
746 #define H_PARSE 0x1D
747 #define H_PARSEERROR 0x1F
748 #define H_FINDOBJECT 0x21
749 #define H_ENDGAME 0x23
750 #define H_SPEAKTO 0x25
751 #define H_PERFORM 0x27
752
753 #define H_TEXTBANK 0x29
754
755 /* additional debugger header information */
756 #define H_DEBUGGABLE 0x3A
757 #define H_DEBUGDATA 0x3B
758 #define H_DEBUGWORKSPACE 0x3E
759
760 /* Printing control codes--embedded in strings printed by AP(). */
761 #define FONT_CHANGE 1
762 #define COLOR_CHANGE 2
763 #define NO_CONTROLCHAR 3
764 #define NO_NEWLINE 30
765 #define FORCED_SPACE 31 /* Can't be <= # colors/font codes + 1
766 (See AP() for the reason) */
767
768 /* Font control codes--these bitmasks follow FONT_CHANGE codes. */
769 #define NORMAL_FONT 0
770 #define BOLD_FONT 1
771 #define ITALIC_FONT 2
772 #define UNDERLINE_FONT 4
773 #define PROP_FONT 8
774
775 /* CHAR_TRANSLATION is simply a value that is added to an ASCII character
776 in order to encode the text, i.e., make it unreadable to casual
777 browsing.
778 */
779 #define CHAR_TRANSLATION 0x14
780
781 /* Passed to GetWord() */
782 #define PARSE_STRING_VAL 0xFFF0
783 #define SERIAL_STRING_VAL 0xFFF1
784
785 /* Returned by FindWord() */
786 #define UNKNOWN_WORD 0xFFFF
787
788 /* Bitmasks for certain qualities of properties */
789 #define ADDITIVE_FLAG 1
790 #define COMPLEX_FLAG 2
791
792 /* Property-table indicators */
793 #define PROP_END 255
794 #define PROP_ROUTINE 255
795
796 enum RESOURCE_TYPE
797 {
798 JPEG_R, /* JPEG image */
799 WAVE_R, /* RIFF WAVE audio sample */
800 MOD_R, /* MOD music module */
801 S3M_R, /* S3M music module */
802 XM_R, /* XM music module */
803 MIDI_R, /* MIDI music */
804 MP3_R, /* MP3 audio layer */
805 AVI_R, /* Video for Windows */
806 MPEG_R, /* MPEG video */
807 UNKNOWN_R
808 };
809
810 /* A structure used for disambiguation in MatchObject(): */
811 struct pobject_structure
812 {
813 int obj; /* the actual object number */
814 char type; /* referred to by noun or adjective */
815 };
816
817 /* Structure used for navigating {...} blocks: */
818 struct CODE_BLOCK
819 {
820 int type; /* see #defines, below */
821 long brk; /* break address, or 0 to indicate NOP */
822 long returnaddr; /* used only for do-while loops */
823 #if defined (DEBUGGER)
824 int dbnest; /* for recovering from 'break' */
825 #endif
826 };
827
828 #define RESET_STACK_DEPTH (-1)
829
830 #define RUNROUTINE_BLOCK 1
831 #define CONDITIONAL_BLOCK 2
832 #define DOWHILE_BLOCK 3
833
834 #define TAIL_RECURSION_ROUTINE (-1)
835 #define TAIL_RECURSION_PROPERTY (-2)
836
837
838 /*-------------------------------------------------------------------------*/
839
840 /* (The following values are defined in he.c:) */
841
842 /* Library/engine globals */
843 extern const int object;
844 extern const int xobject;
845 extern const int self;
846 extern const int wordcount;
847 extern const int player;
848 extern const int actor;
849 extern const int location;
850 extern const int verbroutine;
851 extern const int endflag;
852 extern const int prompt;
853 extern const int objectcount;
854 extern const int system_status;
855
856 /* Library/engine properties */
857 extern const int before;
858 extern const int after;
859 extern const int noun;
860 extern const int adjective;
861 extern const int article;
862
863 /* "display" object properties */
864 extern const int screenwidth;
865 extern const int screenheight;
866 extern const int linelength;
867 extern const int windowlines;
868 extern const int cursor_column;
869 extern const int cursor_row;
870 extern const int hasgraphics;
871 extern const int title_caption;
872 extern const int hasvideo;
873 extern const int needs_repaint;
874 extern const int pointer_x;
875 extern const int pointer_y;
876
877 void *hugo_blockalloc(long num);
878 void hugo_blockfree(void *block);
879 int hugo_hasgraphics(void);
880 int hugo_charwidth(char a);
881 void hugo_cleanup_screen(void);
882 void hugo_clearfullscreen(void);
883 void hugo_clearwindow(void);
884 void hugo_closefiles(void);
885 void hugo_font(int f);
886 void hugo_getfilename(char *a, char *b);
887 int hugo_getkey(void);
888 void hugo_getline(char *p);
889 void hugo_init_screen(void);
890 void hugo_makepath(char *path, char *drive, char *dir, char *fname, char *ext);
891 int hugo_overwrite(char *f);
892 void hugo_print(char *a);
893 void hugo_scrollwindowup(void);
894 void hugo_setbackcolor(int c);
895 void hugo_setgametitle(char *t);
896 void hugo_settextcolor(int c);
897 void hugo_settextmode(void);
898 void hugo_settextpos(int x, int y);
899 void hugo_settextwindow(int left, int top, int right, int bottom);
900 void hugo_splitpath(char *path, char *drive, char *dir, char *fname, char *ext);
901 int hugo_strlen(char *a);
902 int hugo_textwidth(char *a);
903 int hugo_waitforkey(void);
904 int hugo_iskeywaiting(void);
905 int hugo_timewait(int n);
906 #if defined (SCROLLBACK_DEFINED)
907 void hugo_sendtoscrollback(char *a);
908 #endif
909 #if !defined (COMPILE_V25)
910 int hugo_hasvideo(void);
911 #endif
912
913
914 /* he.c */
915 #if !defined (FRONT_END)
916 int main(int argc, char *argv[]);
917 #else
918 int he_main(int argc, char *argv[]);
919 #endif
920 void Banner(void);
921
922 extern int address_scale;
923 extern char program_path[];
924
925
926 /* hebuffer.c */
927 #ifdef USE_TEXTBUFFER
928 void TB_Init(void);
929 int TB_AddWord(char *w, int, int, int, int);
930 void TB_Remove(int n);
931 void TB_Scroll();
932 void TB_Clear(int, int, int, int);
933 char *TB_FindWord(int x, int y);
934 int TB_FirstCell(void);
935 #ifdef TEXTBUFFER_SAVEALL
936 int TB_AddWin(int, int, int, int);
937 #endif
938
939 extern int tb_selected;
940 extern char allow_text_selection;
941 #endif
942
943
944 /* heexpr.c */
945 int EvalExpr(int ptr);
946 int GetValue(void);
947 int Increment(int v, char inctype);
948 char IsIncrement(long addr);
949 void SetupExpr(void);
950
951 extern int var[];
952 extern int incdec;
953 extern char getaddress;
954 extern char inexpr;
955 extern char inobj;
956
957
958 /* hemisc.c */
959 void AP(char *a);
960 int CallRoutine(unsigned int addr);
961 void ContextCommand(void);
962 unsigned int Dict(void);
963 void FatalError(int e);
964 void FileIO(void);
965 void Flushpbuffer(void);
966 void GetCommand(void);
967 char *GetString(long addr);
968 char *GetText(long textaddr);
969 char *GetWord(unsigned int a);
970 void HandleTailRecursion(long addr);
971 void InitGame(void);
972 void LoadGame(void);
973 void ParseCommandLine(int argc, char *argv[]);
974 void PassLocals(int n);
975 #ifdef NO_INLINE_MEM_FUNCTIONS
976 unsigned char Peek(long a);
977 unsigned int PeekWord(long a);
978 void Poke(unsigned int a, unsigned char v);
979 void PokeWord(unsigned int a, unsigned int v);
980 #endif
981 char *PrintHex(long a);
982 void Printout(char *a);
983 /* void PrintSetting(int t, int a, int b, int c, int d); */
984 void PromptMore(void);
985 int RecordCommands(void);
986 void SaveUndo(int t, int a, int b, int c, int d);
987 void SetStackFrame(int depth, int type, long brk, long returnaddr);
988 void SetupDisplay(void);
989 char SpecialChar(char *a, int *i);
990 HUGO_FILE TrytoOpen(char *f, char *p, char *d);
991 int Undo(void);
992
993 extern int game_version;
994 extern int object_size;
995 extern HUGO_FILE game;
996 extern HUGO_FILE script;
997 extern HUGO_FILE save;
998 extern HUGO_FILE playback;
999 extern HUGO_FILE record;
1000 extern HUGO_FILE io; extern char ioblock; extern char ioerror;
1001 extern char gamefile[];
1002 extern char gamepath[];
1003 #if !defined (GLK)
1004 extern char scriptfile[];
1005 extern char savefile[];
1006 extern char recordfile[];
1007 #endif
1008 extern char id[];
1009 extern char serial[];
1010 extern unsigned int codestart;
1011 extern unsigned int objtable;
1012 extern unsigned int eventtable;
1013 extern unsigned int proptable;
1014 extern unsigned int arraytable;
1015 extern unsigned int dicttable;
1016 extern unsigned int syntable;
1017 extern unsigned int initaddr;
1018 extern unsigned int mainaddr;
1019 extern unsigned int parseaddr;
1020 extern unsigned int parseerroraddr;
1021 extern unsigned int findobjectaddr;
1022 extern unsigned int endgameaddr;
1023 extern unsigned int speaktoaddr;
1024 extern unsigned int performaddr;
1025 extern int objects;
1026 extern int events;
1027 extern int dictcount;
1028 extern int syncount;
1029 #if !defined (COMPILE_V25)
1030 extern char context_command[][64];
1031 extern int context_commands;
1032 #endif
1033 extern unsigned char *mem;
1034 extern int loaded_in_memory;
1035 extern unsigned int defseg;
1036 extern unsigned int gameseg;
1037 extern long codeptr;
1038 extern long codeend;
1039 extern char pbuffer[];
1040 extern int currentpos;
1041 extern int currentline;
1042 extern int full;
1043 extern signed char def_fcolor, def_bgcolor, def_slfcolor, def_slbgcolor;
1044 extern signed char fcolor, bgcolor, icolor, default_bgcolor;
1045 extern int currentfont;
1046 extern char capital;
1047 extern unsigned int textto;
1048 extern int SCREENWIDTH, SCREENHEIGHT;
1049 extern int physical_windowwidth, physical_windowheight,
1050 physical_windowtop, physical_windowleft,
1051 physical_windowbottom, physical_windowright;
1052 extern int inwindow;
1053 extern int charwidth, lineheight, FIXEDCHARWIDTH, FIXEDLINEHEIGHT;
1054 extern int current_text_x, current_text_y;
1055 extern int undostack[][5];
1056 extern int undoptr;
1057 extern int undoturn;
1058 extern char undoinvalid;
1059 extern char undorecord;
1060 #ifdef USE_SMARTFORMATTING
1061 extern int smartformatting;
1062 extern char leftquote;
1063 #endif
1064
1065 /* heobject.c */
1066 int Child(int obj);
1067 int Children(int obj);
1068 int Elder(int obj);
1069 unsigned long GetAttributes(int obj, int attribute_set);
1070 int GetProp(int obj, int p, int n, char s);
1071 int GrandParent(int obj);
1072 void MoveObj(int obj, int p);
1073 char *Name(int obj);
1074 int Parent(int obj);
1075 unsigned int PropAddr(int obj, int p, unsigned int offset);
1076 void PutAttributes(int obj, unsigned long a, int attribute_set);
1077 void SetAttribute(int obj, int attr, int c);
1078 int Sibling(int obj);
1079 int TestAttribute(int obj, int attr, int nattr);
1080 int Youngest(int obj);
1081
1082 extern int display_object;
1083 extern char display_needs_repaint;
1084 extern int display_pointer_x, display_pointer_y;
1085
1086
1087 /* heparse.c */
1088 int Available(int obj, char non_grammar);
1089 void CallLibraryParse(void);
1090 void FindObjProp(int obj);
1091 unsigned int FindWord(char *a);
1092 void KillWord(int a);
1093 int MatchCommand(void);
1094 int ObjWord(int obj, unsigned int w);
1095 int Parse(void);
1096 void ParseError(int e, int a);
1097 void RemoveWord(int a);
1098 void SeparateWords(void);
1099 int ValidObj(int obj);
1100
1101 extern char buffer[];
1102 extern char full_buffer;
1103 extern char errbuf[];
1104 extern char line[];
1105 extern int words; extern char *word[];
1106 extern unsigned int wd[], parsed_number;
1107 extern char parse_called_twice;
1108 extern char punc_string[];
1109 extern signed char remaining;
1110 extern char parseerr[];
1111 extern char parsestr[];
1112 extern char xverb;
1113 extern unsigned int grammaraddr;
1114 extern char *obj_parselist;
1115 extern int domain, odomain;
1116 extern int objlist[];
1117 extern char objcount;
1118 extern char parse_allflag;
1119 extern struct pobject_structure pobjlist[];
1120 extern int pobjcount;
1121 extern int pobj;
1122 extern int obj_match_state;
1123 extern char object_is_number;
1124 extern unsigned int objgrammar;
1125 extern int objstart;
1126 extern int objfinish;
1127 extern char addflag;
1128 extern int speaking;
1129 extern char oops[];
1130 extern int oopscount;
1131
1132
1133 /* heres.c */
1134 void DisplayPicture(void);
1135 long FindResource(char *filename, char *resname);
1136 void PlayMusic(void);
1137 void PlaySample(void);
1138 void PlayVideo(void);
1139
1140 extern HUGO_FILE resource_file;
1141 extern char loaded_filename[];
1142 extern char loaded_resname[];
1143 extern char resource_type;
1144
1145
1146 /* herun.c */
1147 void RunDo(void);
1148 void RunEvents(void);
1149 void RunGame(void);
1150 void RunIf(char override);
1151 void RunInput(void);
1152 void RunMove(void);
1153 void RunPrint(void);
1154 int RunRestart(void);
1155 int RunRestore(void);
1156 void RunRoutine(long addr);
1157 int RunSave(void);
1158 int RunScriptSet(void);
1159 void RunSet(int gotvalue);
1160 int RunString(void);
1161 int RunSystem(void);
1162 void RunWindow(void);
1163
1164 extern char during_player_input;
1165 extern int passlocal[];
1166 extern int arguments_passed;
1167 extern int ret; extern char retflag;
1168 extern char game_reset;
1169 extern struct CODE_BLOCK code_block[];
1170 extern int stack_depth;
1171 extern int tail_recursion;
1172 extern long tail_recursion_addr;
1173 extern int last_window_top, last_window_bottom,
1174 last_window_left, last_window_right;
1175 extern char just_left_window;
1176
1177
1178 /* heset.c */
1179 extern char game_title[];
1180 extern char arrexpr;
1181 extern char multiprop;
1182
1183
1184 /* stringfn.c */
1185 char *Left(char *a, int l);
1186 char *Ltrim(char *a);
1187 char *Mid(char *a, int pos, int n);
1188 char *Right(char *a, int l);
1189 char *Rtrim(char *a);
1190 #if defined (EXTRA_STRING_FUNCTIONS)
1191 char *itoa(int a, char *buf, int base);
1192 char *strlwr(char *s);
1193 char *strnset(char *s, int c, size_t l);
1194 char *strupr(char *s);
1195 #endif
1196
1197 #ifdef MINIMAL_WINDOWING
1198 extern unsigned char minimal_windowing, illegal_window;
1199 #endif
1200
1201
1202 /*-------------------------------------------------------------------------*/
1203
1204 #ifndef NO_INLINE_MEM_FUNCTIONS
1205
1206 HUGO_INLINE unsigned char Peek(long a)
1207 { return MEM(defseg * 16L + a); }
1208
1209 HUGO_INLINE unsigned int PeekWord(long a)
1210 { return (unsigned char)MEM(defseg*16L+a) + (unsigned char)MEM(defseg*16L+a+1)*256; }
1211
1212 HUGO_INLINE void Poke(unsigned int a, unsigned char v)
1213 { SETMEM(defseg * 16L + a, v); }
1214
1215 HUGO_INLINE void PokeWord(unsigned int a, unsigned int v)
1216 { SETMEM(defseg * 16L + a, (char)(v%256));
1217 SETMEM(defseg * 16L + a + 1, (char)(v/256)); }
1218
1219 #endif
1220
1221
1222 /*-------------------------------------------------------------------------*/
1223
1224 /* DEBUGGER should be defined (at the start of this file or in the makefile)
1225 to build the debugging version of the engine
1226 */
1227 #if defined (DEBUGGER)
1228 #include "hdinter.h"
1229 #endif
1230