1 /* $Id: dbg_mem.c 1807 2018-04-17 02:47:19Z bartoldeman $
\r
3 * Defines the functions only necessary while debugging is active
\r
5 This file bases on DEBUG.C of FreeCOM v0.81 beta 1.
\r
8 Revision 1.5 2006/09/11 00:07:22 blairdude
\r
9 Fixed compilation completely with Turbo C
\r
11 Revision 1.4 2004/02/01 13:52:17 skaus
\r
12 add/upd: CVS $id$ keywords to/of files
\r
14 Revision 1.3 2001/06/11 20:45:38 skaus
\r
15 fix: dbg_printmem() #if must be #ifdef
\r
17 Revision 1.2 2001/06/11 20:33:37 skaus
\r
18 fix: dbg_printmem() if compiled in Large memory model, near is invalid
\r
20 Revision 1.1 2001/04/12 00:33:53 skaus
\r
22 chg: If DEBUG enabled, no available commands are displayed on startup
\r
23 fix: PTCHSIZE also patches min extra size to force to have this amount
\r
24 of memory available on start
\r
25 bugfix: CALL doesn't reset options
\r
26 add: PTCHSIZE to patch heap size
\r
27 add: VSPAWN, /SWAP switch, .SWP resource handling
\r
28 bugfix: COMMAND.COM A:\
\r
29 bugfix: CALL: if swapOnExec == ERROR, no change of swapOnExec allowed
\r
31 bugfix: runExtension(): destroys command[-2]
\r
33 add: localized CRITER strings
\r
34 chg: use LNG files for hard-coded strings (hangForEver(), init.c)
\r
36 add: DEL.C, COPY.C, CBREAK.C: STRINGS-based prompts
\r
37 add: fixstrs.c: prompts & symbolic keys
\r
38 add: fixstrs.c: backslash escape sequences
\r
39 add: version IDs to DEFAULT.LNG and validation to FIXSTRS.C
\r
40 chg: splitted code apart into LIB\*.c and CMD\*.c
\r
41 bugfix: IF is now using error system & STRINGS to report errors
\r
46 //#include "../config.h"
\r
47 #include "src/lib/16_hc.h"
\r
51 #include <conio.h> /* cputs */
\r
53 #include <malloc.h> /* _heapchk */
\r
55 #include <alloc.h> /* heapcheck, coreleft, farcoreleft */
\r
57 #include <stdlib.h> /* abort */
\r
59 #if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
\r
63 void dbg_printmem (void) {
\r
65 static unsigned nearLast = 0;
\r
67 static unsigned long farLast = 0;
\r
72 // unsigned long farThis;
\r
73 unsigned int farThis;
\r
75 #if __TURBOC__ > 0x201 || defined(__WATCOMC__)
\r
90 cputs("HEAP CORRUPTED. Cannot proceed!\r\n");
\r
93 // cputs("NO HEAP. Cannot proceed!\r\n");
\r
97 cputs("Unknown heapcheck() error. Cannot proceed!\r\n");
\r
106 nearThis = _memavl();
\r
108 _dos_allocmem(0xffff, &farThis);
\r
112 nearThis = coreleft();
\r
114 farThis = farcoreleft();
\r
118 // dprintf(("[free memory: near=%6u far=%13lu]\n", nearThis, farThis));
\r
119 printf("[free memory: near=%6u far=%13lu]\n", nearThis, farThis);
\r
121 // dprintf(("[changed : near=%6d far=%13ld]\n" , nearThis - nearLast , farThis - farLast));
\r
122 printf("[changed : near=%6d far=%13ld]\n" , nearThis - nearLast , farThis - farLast);
\r
124 // dprintf(("[free memory: far=%13lu]\n", farThis));
\r
125 printf("[free memory: far=%13lu]\n", (unsigned long)farThis);
\r
127 // dprintf(("[changed : far=%13ld]\n", farThis - farLast));
\r
128 printf("[changed : far=%13d]\n", (farThis - farLast));
\r
130 printf("farcoreleft()=%lu\n", farcoreleft());
\r
131 printf("HC_farcoreleft()=%lu\n", HC_farcoreleft());
\r
134 nearLast = nearThis;
\r
141 // static global_game_variables_t gvar;
\r
144 // dbg_printmem ();
\r
147 //#endif /* DEBUG */
\r