+++ /dev/null
-/*\r
- * Defines the functions only necessary while debugging is active\r
- */\r
-\r
-#include "config.h"\r
-\r
-#ifdef DEBUG\r
-\r
-#include <conio.h>\r
-#include <stdarg.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-#include <alloc.h>\r
-\r
-#include "command.h"\r
-\r
-FILE *dbg_logfile = stdout;\r
-char *dbg_logname = 0;\r
-unsigned firstMem = 0;\r
-\r
-void dbg_print(const char * const fmt, ...)\r
-{ va_list ap;\r
-\r
- va_start(ap, fmt);\r
- vfprintf(dbg_logfile, fmt, ap);\r
- va_end(ap);\r
- fflush(dbg_logfile);\r
-}\r
-\r
-void dbg_outc(int ch)\r
-{ putc(ch, dbg_logfile);\r
-}\r
-void dbg_outs(const char * const s)\r
-{ if(s) fputs(s, dbg_logfile);\r
- fflush(dbg_logfile);\r
-}\r
-void dbg_outsn(const char * const s)\r
-{ if(s) fputs(s, dbg_logfile);\r
- putc('\n', dbg_logfile);\r
- fflush(dbg_logfile);\r
-}\r
-\r
-\r
-void dbg_printmem(void)\r
-{ static unsigned nearLast = 0;\r
- static unsigned long farLast = 0;\r
-\r
- unsigned nearThis;\r
- unsigned long farThis;\r
-\r
- switch(heapcheck()) {\r
- case _HEAPCORRUPT:\r
- cputs("HEAP CORRUPTED. Cannot proceed!\r\n");\r
- abort();\r
- case _HEAPEMPTY:\r
- cputs("NO HEAP. Cannot proceed!\r\n");\r
- abort();\r
- default:\r
- cputs("Unknown heapcheck() error. Cannot proceed!\r\n");\r
- abort();\r
- case _HEAPOK:\r
- break;\r
- }\r
-\r
- nearThis = coreleft();\r
- farThis = farcoreleft();\r
-\r
- dprintf(("[free memory: near=%6u far=%13lu]\n", nearThis, farThis));\r
- if(nearLast)\r
- dprintf(("[changed : near=%6d far=%13ld]\n"\r
- , nearThis - nearLast , farThis - farLast));\r
-\r
- nearLast = nearThis;\r
- farLast = farThis;\r
-}\r
-\r
-#endif /* defined(DEBUG) */\r
--- /dev/null
+/* $Id: dbg_mem.c 1807 2018-04-17 02:47:19Z bartoldeman $\r
+\r
+ * Defines the functions only necessary while debugging is active\r
+\r
+ This file bases on DEBUG.C of FreeCOM v0.81 beta 1.\r
+\r
+ $Log$\r
+ Revision 1.5 2006/09/11 00:07:22 blairdude\r
+ Fixed compilation completely with Turbo C\r
+\r
+ Revision 1.4 2004/02/01 13:52:17 skaus\r
+ add/upd: CVS $id$ keywords to/of files\r
+\r
+ Revision 1.3 2001/06/11 20:45:38 skaus\r
+ fix: dbg_printmem() #if must be #ifdef\r
+\r
+ Revision 1.2 2001/06/11 20:33:37 skaus\r
+ fix: dbg_printmem() if compiled in Large memory model, near is invalid\r
+\r
+ Revision 1.1 2001/04/12 00:33:53 skaus\r
+ chg: new structure\r
+ chg: If DEBUG enabled, no available commands are displayed on startup\r
+ fix: PTCHSIZE also patches min extra size to force to have this amount\r
+ of memory available on start\r
+ bugfix: CALL doesn't reset options\r
+ add: PTCHSIZE to patch heap size\r
+ add: VSPAWN, /SWAP switch, .SWP resource handling\r
+ bugfix: COMMAND.COM A:\\r
+ bugfix: CALL: if swapOnExec == ERROR, no change of swapOnExec allowed\r
+ add: command MEMORY\r
+ bugfix: runExtension(): destroys command[-2]\r
+ add: clean.bat\r
+ add: localized CRITER strings\r
+ chg: use LNG files for hard-coded strings (hangForEver(), init.c)\r
+ via STRINGS.LIB\r
+ add: DEL.C, COPY.C, CBREAK.C: STRINGS-based prompts\r
+ add: fixstrs.c: prompts & symbolic keys\r
+ add: fixstrs.c: backslash escape sequences\r
+ add: version IDs to DEFAULT.LNG and validation to FIXSTRS.C\r
+ chg: splitted code apart into LIB\*.c and CMD\*.c\r
+ bugfix: IF is now using error system & STRINGS to report errors\r
+ add: CALL: /N\r
+\r
+ */\r
+\r
+//#include "../config.h"\r
+#include "src/lib/16_hc.h"\r
+\r
+//#ifdef DEBUG\r
+\r
+#include <conio.h> /* cputs */\r
+#ifdef __WATCOMC__\r
+#include <malloc.h> /* _heapchk */\r
+#else\r
+#include <alloc.h> /* heapcheck, coreleft, farcoreleft */\r
+#endif\r
+#include <stdlib.h> /* abort */\r
+\r
+#if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)\r
+#define DISP_NEAR\r
+#endif\r
+\r
+void dbg_printmem (void) {\r
+#ifdef DISP_NEAR\r
+ static unsigned nearLast = 0;\r
+#endif\r
+ static unsigned long farLast = 0;\r
+\r
+#ifdef DISP_NEAR\r
+ unsigned nearThis;\r
+#endif\r
+// unsigned long farThis;\r
+ unsigned int farThis;\r
+\r
+#if __TURBOC__ > 0x201 || defined(__WATCOMC__)\r
+#ifdef __WATCOMC__\r
+ switch(_heapchk())\r
+#else\r
+ switch(heapcheck())\r
+#endif\r
+ {\r
+#ifdef __WATCOMC__\r
+ case _HEAPBADBEGIN:\r
+ case _HEAPBADNODE:\r
+ case _HEAPEND:\r
+ case _HEAPBADPTR:\r
+#else\r
+ case _HEAPCORRUPT:\r
+#endif\r
+ cputs("HEAP CORRUPTED. Cannot proceed!\r\n");\r
+ abort();\r
+ case _HEAPEMPTY:\r
+// cputs("NO HEAP. Cannot proceed!\r\n");\r
+// abort();\r
+ break;\r
+ default:\r
+ cputs("Unknown heapcheck() error. Cannot proceed!\r\n");\r
+ abort();\r
+ case _HEAPOK:\r
+ break;\r
+ }\r
+#endif\r
+\r
+#ifdef __WATCOMC__\r
+#ifdef DISP_NEAR\r
+ nearThis = _memavl();\r
+#endif\r
+ _dos_allocmem(0xffff, &farThis);\r
+ farThis <<= 4;\r
+#else\r
+#ifdef DISP_NEAR\r
+ nearThis = coreleft();\r
+#endif\r
+ farThis = farcoreleft();\r
+#endif\r
+\r
+#ifdef DISP_NEAR\r
+// dprintf(("[free memory: near=%6u far=%13lu]\n", nearThis, farThis));\r
+ printf("[free memory: near=%6u far=%13lu]\n", nearThis, farThis);\r
+ if(nearLast)\r
+// dprintf(("[changed : near=%6d far=%13ld]\n" , nearThis - nearLast , farThis - farLast));\r
+ printf("[changed : near=%6d far=%13ld]\n" , nearThis - nearLast , farThis - farLast);\r
+#else\r
+// dprintf(("[free memory: far=%13lu]\n", farThis));\r
+ printf("[free memory: far=%13lu]\n", (unsigned long)farThis);\r
+ if(farLast)\r
+// dprintf(("[changed : far=%13ld]\n", farThis - farLast));\r
+ printf("[changed : far=%13d]\n", (farThis - farLast));\r
+#endif\r
+ printf("farcoreleft()=%lu\n", farcoreleft());\r
+ printf("HC_farcoreleft()=%lu\n", HC_farcoreleft());\r
+\r
+#ifdef DISP_NEAR\r
+ nearLast = nearThis;\r
+#endif\r
+ farLast = farThis;\r
+}\r
+\r
+void main()\r
+{\r
+// static global_game_variables_t gvar;\r
+ int pee; pee=1;\r
+ dbg_printmem ();\r
+// dbg_printmem ();\r
+}\r
+\r
+//#endif /* DEBUG */\r