Debian Codegraph @

terps/hugo/source/he.c

raw symbols SCIP
1 /*
2 -------------------------------------------
3 HUGO ENGINE by Kent Tessman
4 Copyright (c) 1995-2009
5
6 The General Coffee Company Film Productions
7 -------------------------------------------
8
9 This source code is provided to allow porting of the Hugo Engine
10 to different operating systems. It may be distributed as is,
11 providing that there has been no modification or alteration of
12 the material contained therein; distribution of modified source code
13 is prohibited by the copyright holder.
14 */
15
16 #include "heheader.h"
17
18 /* Library/engine globals */
19 const int object = 0;
20 const int xobject = 1;
21 const int self = 2;
22 const int wordcount = 3;
23 const int player = 4;
24 const int actor = 5;
25 const int location = 6;
26 const int verbroutine = 7;
27 const int endflag = 8;
28 const int prompt = 9;
29 const int objectcount = 10;
30 const int system_status = 11;
31
32 /* Library/engine properties */
33 const int before = 1;
34 const int after = 2;
35 const int noun = 3;
36 const int adjective = 4;
37 const int article = 5;
38
39 /* "display" object properties */
40 const int screenwidth = 1;
41 const int screenheight = 2;
42 const int linelength = 3;
43 const int windowlines = 4;
44 const int cursor_column = 5;
45 const int cursor_row = 6;
46 const int hasgraphics = 7;
47 const int title_caption = 8;
48 const int hasvideo = 9;
49 const int needs_repaint = 10;
50 const int pointer_x = 11;
51 const int pointer_y = 12;
52
53 /* address_scale refers to the factor by which addresses are multiplied to
54 get the "real" address. In this way, a 16-bit integer can reference
55 64K * 16 = 1024K of memory.
56 */
57 int address_scale = 16;
58
59 static char **my_argv = NULL;
60 char program_path[MAXPATH] = "";
61
62 void MakeProgramPath(char *path);
63
64
65 /* MAIN
66
67 If FRONT_END is defined, the external main() function can pass the
68 calling parameters argc and argv to he_main.
69 */
70
71 #if !defined (FRONT_END)
72 int main(int argc, char *argv[])
73 #else
74 int he_main(int argc, char *argv[])
75 #endif
76 {
77 time_t seed;
78
79 my_argv = argv;
80
81 if (!strcmp(program_path, "") && argv) MakeProgramPath(argv[0]);
82
83 /* Seed the random number generator */
84 #if !defined (RANDOM)
85 srand((unsigned int)time((time_t *)&seed));
86 #else
87 SRANDOM((unsigned int)time((time_t *)&seed));
88 #endif
89
90 #if !defined (GLK) /* no command line under Glk */
91 ParseCommandLine(argc, argv);
92 #endif
93
94 hugo_init_screen();
95
96 #if defined (DEBUGGER)
97 debug_getinvocationpath(argv[0]);
98 SwitchtoGame();
99 #endif
100 SetupDisplay();
101
102 strcpy(pbuffer, "");
103
104 gameseg = 0;
105
106 LoadGame();
107
108 #if defined (DEBUGGER)
109 LoadDebuggableFile();
110 StartDebugger();
111 #endif
112
113 RunGame();
114
115 hugo_cleanup_screen();
116
117 hugo_blockfree(mem);
118 mem = NULL;
119 hugo_closefiles();
120
121 return 0;
122 }
123
124
125 void Banner(void)
126 {
127 printf("HUGO %s v%d.%d%s by Kent Tessman (c) 1995-2009\n",
128 #if defined (DEBUGGER)
129 "DEBUGGER",
130 #else
131 "ENGINE",
132 #endif
133 HEVERSION, HEREVISION, HEINTERIM);
134
135 printf("The General Coffee Company Film Productions\n");
136 #if defined (PORT_NAME)
137 printf("%s port by %s\n", PORT_NAME, PORTER_NAME);
138 #endif
139 #if defined(GCC_UNIX) && defined(DO_COLOR)
140 printf("SYNTAX: %s [switches] filename[%s]\n", my_argv?my_argv[0]:PROGRAM_NAME,
141 #else
142 printf("SYNTAX: %s filename[%s]\n", my_argv?my_argv[0]:PROGRAM_NAME,
143 #endif
144 #if defined (DEBUGGER)
145 ".HDX");
146 #else
147 ".HEX");
148 #if defined(GCC_UNIX) && defined(DO_COLOR)
149 printf("SWITCHES:\n");
150 printf(" Hugo colour values [0-15]:\n");
151 printf("\t-f n foreground colour\n");
152 printf("\t-b n background colour\n");
153 printf("\t-F n status foreground colour\n");
154 printf("\t-B n status background colour\n");
155 #endif
156 #endif
157 }
158
159 void MakeProgramPath(char *path)
160 {
161 #ifndef GLK
162 char drive[MAXDRIVE], dir[MAXDIR], fname[MAXFILENAME], ext[MAXEXT];
163
164 hugo_splitpath(path, drive, dir, fname, ext);
165 hugo_makepath(program_path, drive, dir, "", "");
166 #endif
167 }