]> icculus.org git repositories - taylor/freespace2.git/blob - include/pstypes.h
a few NDEBUG updates.
[taylor/freespace2.git] / include / pstypes.h
1 /*
2  * $Logfile: /Freespace2/code/GlobalIncs/PsTypes.h $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * Header file containg global typedefs, constants and macros
8  *
9  * $Log$
10  * Revision 1.3  2002/06/01 07:12:32  relnev
11  * a few NDEBUG updates.
12  *
13  * removed a few warnings.
14  *
15  * Revision 1.2  2002/05/28 06:28:20  theoddone33
16  * Filesystem mods, actually reads some data files now
17  *
18  * Revision 1.1.1.1  2002/05/03 03:28:12  root
19  * Initial import.
20  *
21  * 
22  * 34    6/16/00 3:16p Jefff
23  * sim of the year dvd version changes, a few german soty localization
24  * fixes
25  * 
26  * 33    10/05/99 2:29p Danw
27  * 
28  * 32    10/01/99 9:10a Daveb
29  * V 1.1 PATCH
30  * 
31  * 31    9/13/99 12:22a Dave
32  * Minor build update.
33  * 
34  * 30    8/28/99 4:54p Dave
35  * Fixed directives display for multiplayer clients for wings with
36  * multiple waves. Fixed hud threat indicator rendering color.
37  * 
38  * 29    8/09/99 4:18p Andsager
39  * Make french and german defines, needed specifically to enable language
40  * under launcher misc. tab
41  * 
42  * 28    7/20/99 1:49p Dave
43  * Peter Drake build. Fixed some release build warnings.
44  * 
45  * 27    7/18/99 5:19p Dave
46  * Jump node icon. Fixed debris fogging. Framerate warning stuff.
47  * 
48  * 26    7/15/99 9:21a Andsager
49  * FS2_DEMO check in
50  * 
51  * 25    7/09/99 9:51a Dave
52  * Added thick polyline code.
53  * 
54  * 24    6/29/99 10:35a Dave
55  * Interface polygon bitmaps! Whee!
56  * 
57  * 23    6/14/99 10:45a Dave
58  * Made beam weapons specify accuracy by skill level in the weapons.tbl
59  * 
60  * 22    6/03/99 10:15p Dave
61  * Put in temporary main hall screen.
62  * 
63  * 21    5/09/99 8:57p Dave
64  * Final E3 build preparations.
65  * 
66  * 20    4/25/99 7:43p Dave
67  * Misc small bug fixes. Made sun draw properly.
68  * 
69  * 19    4/25/99 3:03p Dave
70  * Removed E3_BUILD from pstypes
71  * 
72  * 18    4/25/99 3:02p Dave
73  * Build defines for the E3 build.
74  * 
75  * 17    4/15/99 1:29p Dave
76  * Remove multiplayer beta build define.
77  * 
78  * 16    4/15/99 1:24p Dave
79  * Final Beta 1 checkin.
80  * 
81  * 15    4/14/99 5:28p Dave
82  * Minor bug fixes.
83  * 
84  * 14    4/12/99 2:22p Dave
85  * More checks for dogfight stats.
86  * 
87  * 13    4/09/99 2:21p Dave
88  * Multiplayer beta stuff. CD checking.
89  * 
90  * 12    2/25/99 4:19p Dave
91  * Added multiplayer_beta defines. Added cd_check define. Fixed a few
92  * release build warnings. Added more data to the squad war request and
93  * response packets.
94  * 
95  * 11    2/23/99 2:29p Dave
96  * First run of oldschool dogfight mode. 
97  * 
98  * 10    2/07/99 8:51p Andsager
99  * Add inner bound to asteroid field.  Inner bound tries to stay astroid
100  * free.  Wrap when within and don't throw at ships inside.
101  * 
102  * 9     1/15/99 11:29a Neilk
103  * Fixed D3D screen/texture pixel formatting problem. 
104  * 
105  * 8     1/08/99 2:08p Dave
106  * Fixed software rendering for pofview. Super early support for AWACS and
107  * beam weapons.
108  * 
109  * 7     1/06/99 2:24p Dave
110  * Stubs and release build fixes.
111  * 
112  * 6     11/30/98 1:07p Dave
113  * 16 bit conversion, first run.
114  * 
115  * 5     11/05/98 4:18p Dave
116  * First run nebula support. Beefed up localization a bit. Removed all
117  * conditional compiles for foreign versions. Modified mission file
118  * format.
119  * 
120  * 4     10/13/98 9:28a Dave
121  * Started neatening up freespace.h. Many variables renamed and
122  * reorganized. Added AlphaColors.[h,cpp]
123  * 
124  * 3     10/07/98 11:28a Dave
125  * 
126  * 2     10/07/98 10:52a Dave
127  * Initial checkin.
128  * 
129  * 1     10/07/98 10:48a Dave
130  * 
131  * 75    8/20/98 5:30p Dave
132  * Put in handy multiplayer logfile system. Now need to put in useful
133  * applications of it all over the code.
134  * 
135  * 74    6/17/98 11:01a Lawrance
136  * set correct offset for English special font chars
137  * 
138  * 73    6/12/98 4:52p Hoffoss
139  * Added support for special characters in in forgeign languages.
140  * 
141  * 72    6/09/98 6:49p Lawrance
142  * Comment out UK_BUILD
143  * 
144  * 71    6/09/98 5:15p Lawrance
145  * French/German localization
146  * 
147  * 70    6/09/98 12:12p Hoffoss
148  * Added XSTR localization code.
149  * 
150  * 69    6/05/98 9:49a Lawrance
151  * OEM changes
152  * 
153  * 68    5/22/98 3:13p Allender
154  * no Int3()'s and Asserts
155  * 
156  * 67    5/20/98 12:59p John
157  * Turned optimizations on for debug builds.   Also turning on automatic
158  * function inlining.  Turned off the unreachable code warning.
159  * 
160  * 66    5/04/98 1:49p Allender
161  * make Int3's do nothing when InterplayQA is defined
162  * 
163  * 65    4/25/98 11:55p Lawrance
164  * compile out Int3() and Assert() for release demo build
165  * 
166  *
167  * $NoKeywords: $
168  *
169  */
170
171 #ifndef _PSTYPES_H
172 #define _PSTYPES_H
173
174
175 // Build defines.  Comment in/out for whatever build is necessary:
176 // #define OEM_BUILD                                            // enable for OEM builds
177 // #define MULTIPLAYER_BETA_BUILD                               // enable for multiplayer beta build
178 // #define E3_BUILD                                                     // enable for 3dfx E3 build                                             
179 // #define PRESS_TOUR_BUILD                     // enable for press tour build
180 #define FS2_DEMO                                        // enable demo build for FS2
181 // #define PD_BUILD                                             // fred documentation/evaluation build
182 //      #define FRENCH_BUILD                            // build for French (obsolete)
183 // #define GERMAN_BUILD                         // build for German (this is now used)
184 //#define RELEASE_REAL                                  // this means that it is an actual release candidate, not just an optimized/release build
185
186 // uncomment this #define for DVD version (makes popups say DVD instead of CD 2 or whatever): JCF 5/10/2000
187 // #define DVD_MESSAGE_HACK
188
189
190 #if defined(MULTIPLAYER_BETA_BUILD) || defined(E3_BUILD) || defined(RELEASE_REAL)
191         #define GAME_CD_CHECK
192 #endif
193
194 // 4127 is constant conditional (assert)
195 // 4100 is unreferenced formal parameters,
196 // 4514 is unreferenced inline function removed, 
197 // 4201 is nameless struct extension used. (used by windows header files)
198 // 4410 illegal size for operand... ie...       fxch st(1)
199 // 4611 is _setjmp warning.  Since we use setjmp alot, and we don't really use constructors or destructors, this warning doesn't really apply to us.
200 // 4725 is the pentium division bug warning, and I can't seem to get rid of it, even with this pragma.
201 //      JS: I figured out the disabling 4725 works, but not on the first function in the module.
202 //      So to disable this, I add in a stub function at the top of each module that does nothing.
203 // 4710 is inline function not expanded (who cares?)
204 // 4711 tells us an inline function was expanded (who cares?)
205 // 4702 unreachable code.  I care, but too many to deal with
206 // 4201 nonstandard extension used : nameless struct/union (happens a lot in Windows include headers)
207 // 4390 emptry control statement (triggered by nprintf and mprintf's inside of one-line if's, etc)
208 #ifndef PLAT_UNIX
209 #pragma warning(disable: 4127 4100 4514 4201 4410 4611 4725 4710 4711 4702 4201 4390)
210 #endif
211
212 #include <stdio.h>      // For NULL, etc
213 #include <stdlib.h>
214 #include <memory.h>
215 #include <malloc.h>
216 #include <string.h>
217
218 #ifdef PLAT_UNIX
219 #include "unix.h"
220 #endif
221 // value to represent an uninitialized state in any int or uint
222 #define UNINITIALIZED 0x7f8e6d9c
223
224 #if defined(DEMO) || defined(OEM_BUILD) // no change for FS2_DEMO
225         #define MAX_PLAYERS     1
226 #else
227         #define MAX_PLAYERS     12
228 #endif
229
230 #define MAX_TEAMS               3
231
232 #define USE_INLINE_ASM 1                // Define this to use inline assembly
233 #define STRUCT_CMP(a, b) memcmp((void *) &a, (void *) &b, sizeof(a))
234
235 #define LOCAL static                    // make module local varilable static.
236
237 typedef __int64 longlong;
238 typedef long fix;
239 typedef unsigned char ubyte;
240 typedef unsigned short ushort;
241 typedef unsigned int uint;
242
243 #define HARDWARE_ONLY
244
245 //Stucture to store clipping codes in a word
246 typedef struct ccodes {
247         ubyte vor,vand; //or is low byte, and is high byte
248 } ccodes;
249
250 typedef struct vector {
251         union {
252                 struct {
253                         float x,y,z;
254                 };
255                 float a1d[3];
256         };
257 } vector;
258
259 // A vector referenced as an array
260 typedef struct vectora {
261         float   xyz[3];
262 } vectora;
263
264 typedef struct vec2d {
265         float i,j;
266 } vec2d;
267
268 // Used for some 2d primitives, like gr_poly
269 typedef struct vert2df {
270         float x, y;
271 } vert2df;
272
273 typedef struct angles {
274         float   p, b, h;
275 } angles_t;
276
277 typedef struct matrix {
278         union {
279                 struct {
280                         vector  rvec, uvec, fvec;
281                 };
282                 float a2d[3][3];
283                 float a1d[9];
284         };
285 } matrix;
286
287 typedef struct uv_pair {
288         float u,v;
289 } uv_pair;
290
291 // Used to store rotated points for mines.
292 // Has flag to indicate if projected.
293 typedef struct vertex {
294         float           x, y, z;                                // world space position
295         float           sx, sy, sw;                     // screen space position (sw == 1/z)
296         float           u, v;                                   // texture position
297         ubyte           r, g, b, a;                     // color.  Use b for darkening;
298         ubyte           codes;                          // what sides of view pyramid this point is on/off.  0 = Inside view pyramid.
299         ubyte           flags;                          // Projection flags.  Indicates whether it is projected or not or if projection overflowed.
300         ubyte           pad[2];                         // pad structure to be 4 byte aligned.
301 } vertex;
302
303 #define BMP_AABITMAP                    (1<<0)                          // antialiased bitmap
304 #define BMP_TEX_XPARENT         (1<<1)                          // transparent texture
305 #define BMP_TEX_NONDARK         (1<<2)                          // nondarkening texture
306 #define BMP_TEX_OTHER                   (1<<3)                          // so we can identify all "normal" textures
307
308 // any texture type
309 #define BMP_TEX_ANY                             ( BMP_TEX_XPARENT | BMP_TEX_NONDARK | BMP_TEX_OTHER )
310
311 // max res == 1024x768. max texture size == 256
312 #define MAX_BMAP_SECTIONS_X                             4
313 #define MAX_BMAP_SECTIONS_Y                             3
314 #define MAX_BMAP_SECTION_SIZE                           256
315 typedef struct bitmap_section_info {
316         ushort sx[MAX_BMAP_SECTIONS_X];         // x offset of each section
317         ushort sy[MAX_BMAP_SECTIONS_Y];         // y offset of each section
318
319         ubyte num_x, num_y;                                             // number of x and y sections
320 } bitmap_section_info;
321
322 typedef struct bitmap {
323         short   w, h;           // Width and height
324         short   rowsize;        // What you need to add to go to next row
325         ubyte   bpp;            // How many bits per pixel it is. (7,8,15,16,24,32)
326         ubyte   flags;  // See the BMP_???? defines for values
327         uint    data;           // Pointer to data, or maybe offset into VRAM.
328         ubyte *palette; // If bpp==8, this is pointer to palette.   If the BMP_NO_PALETTE_MAP flag
329                                                         // is not set, this palette just points to the screen palette. (gr_palette)
330
331         bitmap_section_info sections;
332 } bitmap;
333
334 //This are defined in MainWin.c
335 extern void _cdecl WinAssert(char * text,char *filename, int line);
336 extern void _cdecl Error( char * filename, int line, char * format, ... );
337 extern void _cdecl Warning( char * filename, int line, char * format, ... );
338
339 #include "outwnd.h"
340
341 // To debug printf do this:
342 // mprintf(( "Error opening %s\n", filename ));
343 #ifndef NDEBUG
344 #define mprintf(args) outwnd_printf2 args
345 #define nprintf(args) outwnd_printf args
346 #else
347 #define mprintf(args) 
348 #define nprintf(args) 
349 #endif
350
351 #define LOCATION __FILE__,__LINE__
352
353 // To flag an error, you can do this:
354 // Error( __FILE__, __LINE__, "Error opening %s", filename );
355 // or, 
356 // Error( LOCATION, "Error opening %s", filename );
357
358 #if defined(NDEBUG)
359 #define Assert(x) do {} while (0)
360 #else
361 void gr_activate(int);
362 #define Assert(x) do { if (!(x)){ gr_activate(0); WinAssert(#x,__FILE__,__LINE__); gr_activate(1); } } while (0)
363 #endif
364
365 //#define Int3() _asm { int 3 }
366
367 #ifdef INTERPLAYQA
368         // Interplay QA version of Int3
369         #define Int3() do { } while (0) 
370
371         // define to call from Warning function above since it calls Int3, so without this, we
372         // get put into infinite dialog boxes
373         #define AsmInt3() _asm { int 3 }
374
375 #else
376         #if defined(NDEBUG)
377                 // No debug version of Int3
378                 #define Int3() do { } while (0) 
379         #else
380                 void debug_int3();
381
382                 // Debug version of Int3
383                 #define Int3() debug_int3()
384         #endif  // NDEBUG && DEMO
385 #endif  // INTERPLAYQA
386
387 #define min(a,b) (((a) < (b)) ? (a) : (b))
388 #define max(a,b) (((a) > (b)) ? (a) : (b))
389
390 #define PI                                      3.141592654f
391 #define PI2                                     (3.141592654f*2.0f)     // PI*2
392 #define ANG_TO_RAD(x)   ((x)*PI/180)
393
394
395 extern int      Fred_running;  // Is Fred running, or FreeSpace?
396 extern int Pofview_running;
397 extern int Nebedit_running;
398
399
400 //======================================================================================
401 //======          D E B U G    C O N S O L E   S T U F F        ========================
402 //======================================================================================
403
404 // Here is a a sample command to toggle something that would
405 // be called by doing "toggle it" from the debug console command window/
406
407 /*
408 DCF(toggle_it,"description")
409 {
410         if (Dc_command) {
411                 This_var = !This_var;
412         }
413
414         if (Dc_help)    {
415                 dc_printf( "Usage: sample\nToggles This_var on/off.\n" );
416         }
417
418         if (Dc_status)  {
419                 dc_printf( "The status is %d.\n", This_var );
420         }
421 */
422
423 class debug_command {
424         public:
425         char *name;
426         char *help;
427         void (*func)();
428         debug_command(char *name,char *help,void (*func)());    // constructor
429 };
430
431 #define DCF(function_name,help_text)                    \
432                 void dcf_##function_name();     \
433                 debug_command dc_##function_name(#function_name,help_text,dcf_##function_name); \
434                 void dcf_##function_name()              
435
436 // Starts the debug console
437 extern void debug_console( void (*func)() = NULL );
438
439 // The next three variables tell your function what to do.  It should
440 // only change something if the dc_command is set.   A minimal function
441 // needs to process the dc_command.   Usually, these will be called in
442 // these combinations:
443 // dc_command=true, dc_status=true  means process it and show status
444 // dc_help=true means show help only
445 // dc_status=true means show status only
446 // I would recommend doing this in each function:
447 // if (dc_command) { process command }
448 // if (dc_help) { print out help }
449 // if (dc_status) { print out status }
450 // with the last two being optional
451
452 extern int Dc_command;  // If this is set, then process the command
453 extern int Dc_help;             // If this is set, then print out the help text in the form, "usage: ... \nLong description\n" );
454 extern int Dc_status;           // If this is set, then print out the current status of the command.
455
456 void dc_get_arg(uint flags);            // Gets the next argument.   If it doesn't match the flags, this function will print an error and not return.
457 extern char *Dc_arg;            // The (lowercased) string value of the argument retrieved from dc_arg
458 extern char *Dc_arg_org;        // Dc_arg before it got converted to lowercase
459 extern uint Dc_arg_type;        // The type of dc_arg.
460 extern char *Dc_command_line;           // The rest of the command line, from the end of the last processed arg on.
461 extern int Dc_arg_int;          // If Dc_arg_type & ARG_INT or ARG_HEX is set, then this is the value
462 extern float Dc_arg_float;      // If Dc_arg_type & ARG_FLOAT is set, then this is the value
463
464 // Outputs text to the console
465 void dc_printf( char *format, ... );
466
467 // Each dc_arg_type can have one or more of these flags set.
468 // This is because some things can fit into two catagories.
469 // Like 1 can be an integer, a float, a string, or a true boolean
470 // value.
471 #define ARG_NONE                (1<<0)  // no argument
472 #define ARG_ANY         0xFFFFFFFF      // Anything.
473 #define ARG_STRING      (1<<1)  // any valid string
474 #define ARG_QUOTE               (1<<2)  // a quoted string
475 #define ARG_INT         (1<<3)  // a valid integer
476 #define ARG_FLOAT               (1<<4)  // a valid floating point number
477
478 // some specific commonly used predefined types. Can add up to (1<<31)
479 #define ARG_HEX         (1<<5)  // a valid hexadecimal integer. Note that ARG_INT will always be set also in this case.
480 #define ARG_TRUE                (1<<6)  // on, true, non-zero number
481 #define ARG_FALSE               (1<<7)  // off, false, zero
482 #define ARG_PLUS                (1<<8)  // Plus sign
483 #define ARG_MINUS               (1<<9)  // Minus sign
484 #define ARG_COMMA               (1<<10) // a comma
485
486 // A shortcut for boolean only variables.
487 // Example:  
488 // DCF_BOOL( lighting, Show_lighting )
489 //
490 #define DCF_BOOL( function_name, bool_variable )        \
491         void dcf_##function_name();     \
492         debug_command dc_##function_name(#function_name,"Toggles "#bool_variable,dcf_##function_name ); \
493         void dcf_##function_name()      {       \
494         if ( Dc_command )       {       \
495                 dc_get_arg(ARG_TRUE|ARG_FALSE|ARG_NONE);                \
496                 if ( Dc_arg_type & ARG_TRUE )   bool_variable = 1;      \
497                 else if ( Dc_arg_type & ARG_FALSE ) bool_variable = 0;  \
498                 else if ( Dc_arg_type & ARG_NONE ) bool_variable ^= 1;  \
499         }       \
500         if ( Dc_help )  dc_printf( "Usage: %s [bool]\nSets %s to true or false.  If nothing passed, then toggles it.\n", #function_name, #bool_variable );      \
501         if ( Dc_status )        dc_printf( "%s is %s\n", #function_name, (bool_variable?"TRUE":"FALSE") );      \
502 }
503
504
505 //======================================================================================
506 //======================================================================================
507 //======================================================================================
508
509
510
511 #include "fix.h"
512 #include "floating.h"
513
514 // Some constants for stuff
515 #define MAX_FILENAME_LEN        32                      // Length for filenames, ie "title.pcx"
516 #define MAX_PATH_LEN                    128             // Length for pathnames, ie "c:\bitmaps\title.pcx"
517
518 // contants and defined for byteswapping routines (useful for mac)
519
520 #define SWAPSHORT(x)    (                                                       \
521                                                 ((ubyte)x << 8) |                                       \
522                                                 (((ushort)x) >> 8)                      \
523                                                 )
524                                                 
525 #define SWAPINT(x)              (                                                       \
526                                                 (x << 24) |                                     \
527                                                 (((ulong)x) >> 24) |            \
528                                                 ((x & 0x0000ff00) << 8) |       \
529                                                 ((x & 0x00ff0000) >> 8)         \
530                                                 )
531
532 #ifndef MACINTOSH
533 #define INTEL_INT(x)    x
534 #define INTEL_SHORT(x)  x
535 #else
536 #define INTEL_INT(x)    SWAPINT(x)
537 #define INTEL_SHORT(x)  SWAPSHORT(x)
538 #endif
539
540 #define TRUE    1
541 #define FALSE   0
542
543 int myrand();
544
545
546
547 // Callback Loading function. 
548 // If you pass a function to this, that function will get called
549 // around 10x per second, so you can update the screen.
550 // Pass NULL to turn it off.
551 // Call this with the name of a function.  That function will
552 // then get called around 10x per second.  The callback function
553 // gets passed a 'count' which is how many times game_busy has
554 // been called since the callback was set.   It gets called
555 // one last time with count=-1 when you turn off the callback
556 // by calling game_busy_callback(NULL).   Game_busy_callback
557 // returns the current count, so you can tell how many times
558 // game_busy got called.
559 // If delta_step is above 0, then it will also make sure it 
560 // calls the callback each time count steps 'delta_step' even
561 // if 1/10th of a second hasn't elapsed.
562 extern int game_busy_callback( void (*callback)(int count), int delta_step = -1 );
563
564 // Call whenever loading to display cursor
565 extern void game_busy();
566
567
568 //=========================================================
569 // Functions to monitor performance
570 #ifndef NDEBUG
571
572 class monitor {
573         public:
574         char    *name;                  
575         int     value;                  // Value that gets cleared to 0 each frame.
576         int     min, max, sum, cnt;             // Min & Max of value.  Sum is used to calculate average 
577         monitor(char *name);    // constructor
578 };
579
580 // Creates a monitor variable
581 #define MONITOR(function_name)                          monitor mon_##function_name(#function_name)
582
583 // Increments a monitor variable
584 #define MONITOR_INC(function_name,inc)          do { mon_##function_name.value+=(inc); } while(0)
585
586 // Call this once per frame to update monitor file
587 void monitor_update();
588
589 #else
590
591 #define MONITOR(function_name)
592
593 #define MONITOR_INC(function_name,inc)          do { } while(0)
594
595 // Call this once per frame to update monitor file
596 #define monitor_update() do { } while(0)
597
598 #endif
599
600 #define NOX(s) s
601
602 char *XSTR(char *str, int index);
603
604 // Caps V between MN and MX.
605 template <class T> void CAP( T& v, T mn, T mx )
606 {
607         if ( v < mn )   {
608                 v = mn;
609         } else if ( v > mx )    {
610                 v = mx;
611         }
612 }
613
614 // ========================================================
615 // stamp checksum stuff
616 // ========================================================
617
618 // here is the define for the stamp for this set of code
619 #define STAMP_STRING "\001\001\001\001\002\002\002\002Read the Foundation Novels from Asimov.  I liked them." 
620 #define STAMP_STRING_LENGTH     80
621 #define DEFAULT_CHECKSUM_STRING         "\001\001\001\001"
622 #define DEFAULT_TIME_STRING                     "\002\002\002\002"
623
624 // macro to calculate the checksum for the stamp.  Put here so that we can use different methods
625 // for different applications.  Requires the local variable 'checksum' to be defined!!!
626 #define CALCULATE_STAMP_CHECKSUM() do { \
627                 int i, found;   \
628                                                         \
629                 checksum = 0;   \
630                 for ( i = 0; i < (int)strlen(ptr); i++ ) {      \
631                         found = 0;      \
632                         checksum += ptr[i];     \
633                         if ( checksum & 0x01 )  \
634                                 found = 1;      \
635                         checksum = checksum >> 1;       \
636                         if (found)      \
637                                 checksum |= 0x80000000; \
638                 }       \
639                 checksum |= 0x80000000; \
640         } while (0) ;
641
642 //=========================================================
643 // Memory management functions
644 //=========================================================
645
646 #ifndef NDEBUG
647         // Debug versions
648
649         // Returns 0 if not enough RAM.
650         int vm_init(int min_heap_size);
651
652         // Allocates some RAM.
653         void *vm_malloc( int size, char *filename=NULL, int line=-1 );
654
655         // 
656         char *vm_strdup( const char *ptr, char *filename, int line );
657
658         // Frees some RAM. 
659         void vm_free( void *ptr, char *filename=NULL, int line=-1 );
660
661         // Frees all RAM.
662         void vm_free_all();
663
664         // Easy to use macros
665         #define VM_MALLOC(size) vm_malloc((size),__FILE__,__LINE__)
666         #define VM_FREE(ptr) vm_free((ptr),__FILE__,__LINE__)
667
668         #define malloc(size) vm_malloc((size),__FILE__,__LINE__)
669         #define free(ptr) vm_free((ptr),__FILE__,__LINE__)
670         #define strdup(ptr) vm_strdup((ptr),__FILE__,__LINE__)
671         
672 #else
673         // Release versions
674
675         // Returns 0 if not enough RAM.
676         int vm_init(int min_heap_size);
677
678         // Allocates some RAM.
679 //      void *vm_malloc( int size );
680
681         // 
682 //      char *vm_strdup( const char *ptr );
683
684         // Frees some RAM. 
685 //      void vm_free( void *ptr );
686
687         // Frees all RAM.
688         void vm_free_all();
689
690         // Easy to use macros
691         #define VM_MALLOC(size) vm_malloc(size)
692         #define VM_FREE(ptr) vm_free(ptr)
693
694 //      #define malloc(size) vm_malloc(size)
695 //      #define free(ptr) vm_free(ptr)
696 //      #define strdup(ptr) vm_strdup(ptr)
697         #define vm_malloc(size) malloc(size)
698         #define vm_free(ptr) free(ptr)
699         #define vm_strdup(ptr) strdup(ptr)
700 #endif
701
702
703 #endif          // PS_TYPES_H
704