1 /*
2 
3   Platform specific project specific C functions
4 
5 */
6 
7 #include "3dc.h"
8 #include "module.h"
9 #include "inline.h"
10 
11 #include "gameplat.h"
12 #include "gamedef.h"
13 
14 #include "dynblock.h"
15 #include "dynamics.h"
16 #define UseLocalAssert No
17 #include "ourasert.h"
18 
19 /*
20 	Externs from pc\io.c
21 */
22 
23 extern int InputMode;
24 extern unsigned char KeyboardInput[];
25 
26 extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock;
27 extern unsigned char *ScreenBuffer;
28 
29 extern  unsigned char KeyASCII;
30 
31 
32 /* External functions */
33 
34 extern void D3D_Line(VECTOR2D* LineStart, VECTOR2D* LineEnd, int LineColour);
35 extern void Draw_Line_VMType_8(VECTOR2D* LineStart, VECTOR2D* LineEnd, int LineColour);
36 
37 // Prototypes
38 
39 int IDemandFireWeapon(void);
40 
41 int IDemandNextWeapon(void);
42 int IDemandPreviousWeapon(void);
43 
44 
45 // Functions
46 
47 
48 
catpathandextension(char * dst,char * src)49 void catpathandextension(char* dst, char* src)
50 {
51 	int len = lstrlen(dst);
52 
53 	if ((len > 0 && (dst[len-1] != '\\' && dst[len-1] != '/')) && *src != '.')
54 		{
55 			lstrcat(dst,"/");
56 		}
57 
58     lstrcat(dst,src);
59 
60 /*
61 	The second null here is to support the use
62 	of SHFileOperation, which is a Windows 95
63 	addition that is uncompilable under Watcom
64 	with ver 10.5, but will hopefully become
65 	available later...
66 */
67     len = lstrlen(dst);
68     dst[len+1] = 0;
69 
70 }
71 
72 
73 /* game platform definition of the Mouse Mode*/
74 
75 int MouseMode = MouseVelocityMode;
76 
77 /*
78 
79   Real PC control functions
80 
81 */
82 #if 1
IDemandLookUp(void)83 int IDemandLookUp(void)
84 {
85 	return No;
86 }
87 
88 
IDemandLookDown(void)89 int IDemandLookDown(void)
90 {
91 	return No;
92 }
93 
94 
IDemandTurnLeft(void)95 int IDemandTurnLeft(void)
96 {
97 	InputMode = Digital;
98 	if(KeyboardInput[KEY_LEFT])
99 		return Yes;
100 	return No;
101 }
102 
103 
IDemandTurnRight(void)104 int IDemandTurnRight(void)
105 {
106 	InputMode = Digital;
107 	if(KeyboardInput[KEY_RIGHT])
108 		return Yes;
109 	return No;
110 }
111 
112 
IDemandGoForward(void)113 int IDemandGoForward(void)
114 {
115 	InputMode = Digital;
116 	if(KeyboardInput[KEY_UP])
117 		return Yes;
118 	return No;
119 }
120 
121 
IDemandGoBackward(void)122 int IDemandGoBackward(void)
123 {
124 	InputMode = Digital;
125 	if(KeyboardInput[KEY_DOWN])
126 		return Yes;
127 	return No;
128 }
129 
130 
IDemandJump(void)131 int IDemandJump(void)
132 {
133 	InputMode = Digital;
134         if(KeyboardInput[KEY_CAPS])
135 		return Yes;
136 	return No;
137 }
138 
139 
140 
IDemandCrouch(void)141 int IDemandCrouch(void)
142 {
143 	InputMode = Digital;
144         if(KeyboardInput[KEY_Z])
145 		return Yes;
146 	return No;
147 }
148 
IDemandSelect(void)149 int IDemandSelect(void)
150 {
151 	InputMode = Digital;
152 
153     if(KeyboardInput[KEY_CR]) return Yes;
154     if(KeyboardInput[KEY_SPACE]) return Yes;
155 	else return No;
156 }
157 
IDemandStop(void)158 int IDemandStop(void)
159 {
160 	return No;
161 }
162 
163 
IDemandFaster(void)164 int IDemandFaster(void)
165 {
166 	InputMode = Digital;
167 	if(KeyboardInput[KEY_LEFTSHIFT])
168 		return Yes;
169 	return No;
170 }
171 
172 
IDemandSideStep(void)173 int IDemandSideStep(void)
174 {
175 	InputMode = Digital;
176 	if(KeyboardInput[KEY_LEFTALT])
177 		return Yes;
178 	return No;
179 }
180 
IDemandPickupItem(void)181 int IDemandPickupItem(void)
182 {
183 	InputMode = Digital;
184 	if(KeyboardInput[KEY_P])
185 		return Yes;
186 	return No;
187 }
188 
IDemandDropItem(void)189 int IDemandDropItem(void)
190 {
191 	InputMode = Digital;
192 	if(KeyboardInput[KEY_D])
193 		return Yes;
194 	return No;
195 }
196 
IDemandMenu(void)197 int IDemandMenu(void)
198 {
199 	InputMode = Digital;
200 	if(KeyboardInput[KEY_M])
201 		return Yes;
202 	return No;
203 }
204 
IDemandOperate(void)205 int IDemandOperate(void)
206 {
207 	InputMode = Digital;
208 	if(KeyboardInput[KEY_SPACE])
209 		return Yes;
210 	return No;
211 }
212 
213 
214 
IDemandFireWeapon(void)215 int IDemandFireWeapon(void)
216 {
217 	InputMode = Digital;
218         if(KeyboardInput[KEY_CR])
219 		return Yes;
220 	return No;
221 }
222 
223 /* KJL 11:29:12 10/07/96 - added by me */
IDemandPreviousWeapon(void)224 int IDemandPreviousWeapon(void)
225 {
226 	InputMode = Digital;
227    	if(KeyboardInput[KEY_1]) return Yes;
228     else return No;
229 }
IDemandNextWeapon(void)230 int IDemandNextWeapon(void)
231 {
232 	InputMode = Digital;
233    	if(KeyboardInput[KEY_2]) return Yes;
234     else return No;
235 }
236 #endif
237 
238 
IDemandChangeEnvironment()239 int IDemandChangeEnvironment()
240 {
241 	InputMode = Digital;
242 
243 	if(KeyboardInput[KEY_F1])
244 		return 0;
245 	else if(KeyboardInput[KEY_F2])
246 		return 1;
247 	else if(KeyboardInput[KEY_F3])
248 		return 2;
249 	else if(KeyboardInput[KEY_F4])
250 		return 3;
251 	else if(KeyboardInput[KEY_F5])
252 		return 4;
253 	else
254 		return(-1);
255 }
256 
257 
258 /* KJL 15:53:52 05/04/97 -
259 Loaders/Unloaders for language internationalization code in language.c */
260 
LoadTextFile(char * filename)261 char *LoadTextFile(char *filename)
262 {
263 	char *bufferPtr;
264 	long int save_pos, size_of_file;
265 	FILE *fp;
266 	fp = OpenGameFile(filename, FILEMODE_READONLY, FILETYPE_PERM);
267 
268 	if (!fp) goto error;
269 
270 	save_pos=ftell(fp);
271 	fseek(fp,0L,SEEK_END);
272 	size_of_file=ftell(fp);
273 
274 	bufferPtr = AllocateMem(size_of_file);
275 	if (!bufferPtr)
276 	{
277 		memoryInitialisationFailure = 1;
278 		goto error;
279 	}
280 
281 	fseek(fp,save_pos,SEEK_SET);
282 
283 
284 	if (!fread(bufferPtr, size_of_file,1,fp))
285 	{
286 		fclose(fp);
287 		goto error;
288 	}
289 
290 	fclose(fp);
291 	return bufferPtr;
292 
293 error:
294 	{
295 		/* error whilst trying to load file */
296 		textprint("Error! Can not load file %s.\n",filename);
297 		LOCALASSERT(0);
298 		return 0;
299 	}
300 }
301 
302 
UnloadTextFile(char * filename,char * bufferPtr)303 void UnloadTextFile(char *filename, char *bufferPtr)
304 {
305 	if (bufferPtr) DeallocateMem(bufferPtr);
306 }
307