コミットメタ情報

リビジョン7546211d6de190a33b63eca728777c8b79d00550 (tree)
日時2018-07-13 03:35:02
作者sparky4 <sparky4@cock...>
コミッターsparky4

ログメッセージ

eh i am too tired to experiment with this wwww

変更サマリ

差分

--- a/16/fd-dbg.c
+++ /dev/null
@@ -1,77 +0,0 @@
1-/*
2- * Defines the functions only necessary while debugging is active
3- */
4-
5-#include "config.h"
6-
7-#ifdef DEBUG
8-
9-#include <conio.h>
10-#include <stdarg.h>
11-#include <stdlib.h>
12-#include <stdio.h>
13-#include <alloc.h>
14-
15-#include "command.h"
16-
17-FILE *dbg_logfile = stdout;
18-char *dbg_logname = 0;
19-unsigned firstMem = 0;
20-
21-void dbg_print(const char * const fmt, ...)
22-{ va_list ap;
23-
24- va_start(ap, fmt);
25- vfprintf(dbg_logfile, fmt, ap);
26- va_end(ap);
27- fflush(dbg_logfile);
28-}
29-
30-void dbg_outc(int ch)
31-{ putc(ch, dbg_logfile);
32-}
33-void dbg_outs(const char * const s)
34-{ if(s) fputs(s, dbg_logfile);
35- fflush(dbg_logfile);
36-}
37-void dbg_outsn(const char * const s)
38-{ if(s) fputs(s, dbg_logfile);
39- putc('\n', dbg_logfile);
40- fflush(dbg_logfile);
41-}
42-
43-
44-void dbg_printmem(void)
45-{ static unsigned nearLast = 0;
46- static unsigned long farLast = 0;
47-
48- unsigned nearThis;
49- unsigned long farThis;
50-
51- switch(heapcheck()) {
52- case _HEAPCORRUPT:
53- cputs("HEAP CORRUPTED. Cannot proceed!\r\n");
54- abort();
55- case _HEAPEMPTY:
56- cputs("NO HEAP. Cannot proceed!\r\n");
57- abort();
58- default:
59- cputs("Unknown heapcheck() error. Cannot proceed!\r\n");
60- abort();
61- case _HEAPOK:
62- break;
63- }
64-
65- nearThis = coreleft();
66- farThis = farcoreleft();
67-
68- dprintf(("[free memory: near=%6u far=%13lu]\n", nearThis, farThis));
69- if(nearLast)
70- dprintf(("[changed : near=%6d far=%13ld]\n"
71- , nearThis - nearLast , farThis - farLast));
72-
73- nearLast = nearThis;
74- farLast = farThis;
75-}
76-
77-#endif /* defined(DEBUG) */
--- a/makefile
+++ b/makefile
@@ -229,6 +229,7 @@ UTILEXEC = &
229229 palbomb.exe &
230230 palettec.exe &
231231 ps.exe
232+# fd-dbg.exe
232233 !ifdef __LINUX__
233234 SPRIUTILEXEC = &
234235 pcx2vrl &
@@ -312,6 +313,7 @@ exmmtest.exe: exmmtest.$(OBJ) $(16LIB) gfx.lib $(DOSLIB)
312313 vgmtest.exe: vgmtest.$(OBJ) vgmsnd.lib $(16LIB) $(DOSLIB) gfx.lib
313314 db.exe: db.$(OBJ)
314315 ps.exe: ps.$(OBJ) 16_head.$(OBJ)
316+fd-dbg.exe: fd-dbg.$(OBJ) 16_head.$(OBJ) 16_hc.$(OBJ) kitten.$(OBJ)
315317 wcpu.exe: wcpu.$(OBJ) $(16LIB) $(DOSLIB)
316318
317319 #
@@ -353,6 +355,7 @@ exmmtest.$(OBJ):$(SRC)/exmmtest.c
353355 vgmtest.$(OBJ):$(SRC)/vgmtest.c
354356 db.$(OBJ): $(UTIL)/db.c
355357 ps.$(OBJ): $(SRC)/ps.c
358+fd-dbg.$(OBJ): $(SRC)/fd-dbg.c
356359
357360 #
358361 # non executable objects libraries
--- /dev/null
+++ b/src/fd-dbg.c
@@ -0,0 +1,147 @@
1+/* $Id: dbg_mem.c 1807 2018-04-17 02:47:19Z bartoldeman $
2+
3+ * Defines the functions only necessary while debugging is active
4+
5+ This file bases on DEBUG.C of FreeCOM v0.81 beta 1.
6+
7+ $Log$
8+ Revision 1.5 2006/09/11 00:07:22 blairdude
9+ Fixed compilation completely with Turbo C
10+
11+ Revision 1.4 2004/02/01 13:52:17 skaus
12+ add/upd: CVS $id$ keywords to/of files
13+
14+ Revision 1.3 2001/06/11 20:45:38 skaus
15+ fix: dbg_printmem() #if must be #ifdef
16+
17+ Revision 1.2 2001/06/11 20:33:37 skaus
18+ fix: dbg_printmem() if compiled in Large memory model, near is invalid
19+
20+ Revision 1.1 2001/04/12 00:33:53 skaus
21+ chg: new structure
22+ chg: If DEBUG enabled, no available commands are displayed on startup
23+ fix: PTCHSIZE also patches min extra size to force to have this amount
24+ of memory available on start
25+ bugfix: CALL doesn't reset options
26+ add: PTCHSIZE to patch heap size
27+ add: VSPAWN, /SWAP switch, .SWP resource handling
28+ bugfix: COMMAND.COM A:\
29+ bugfix: CALL: if swapOnExec == ERROR, no change of swapOnExec allowed
30+ add: command MEMORY
31+ bugfix: runExtension(): destroys command[-2]
32+ add: clean.bat
33+ add: localized CRITER strings
34+ chg: use LNG files for hard-coded strings (hangForEver(), init.c)
35+ via STRINGS.LIB
36+ add: DEL.C, COPY.C, CBREAK.C: STRINGS-based prompts
37+ add: fixstrs.c: prompts & symbolic keys
38+ add: fixstrs.c: backslash escape sequences
39+ add: version IDs to DEFAULT.LNG and validation to FIXSTRS.C
40+ chg: splitted code apart into LIB\*.c and CMD\*.c
41+ bugfix: IF is now using error system & STRINGS to report errors
42+ add: CALL: /N
43+
44+ */
45+
46+//#include "../config.h"
47+#include "src/lib/16_hc.h"
48+
49+//#ifdef DEBUG
50+
51+#include <conio.h> /* cputs */
52+#ifdef __WATCOMC__
53+#include <malloc.h> /* _heapchk */
54+#else
55+#include <alloc.h> /* heapcheck, coreleft, farcoreleft */
56+#endif
57+#include <stdlib.h> /* abort */
58+
59+#if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
60+#define DISP_NEAR
61+#endif
62+
63+void dbg_printmem (void) {
64+#ifdef DISP_NEAR
65+ static unsigned nearLast = 0;
66+#endif
67+ static unsigned long farLast = 0;
68+
69+#ifdef DISP_NEAR
70+ unsigned nearThis;
71+#endif
72+// unsigned long farThis;
73+ unsigned int farThis;
74+
75+#if __TURBOC__ > 0x201 || defined(__WATCOMC__)
76+#ifdef __WATCOMC__
77+ switch(_heapchk())
78+#else
79+ switch(heapcheck())
80+#endif
81+ {
82+#ifdef __WATCOMC__
83+ case _HEAPBADBEGIN:
84+ case _HEAPBADNODE:
85+ case _HEAPEND:
86+ case _HEAPBADPTR:
87+#else
88+ case _HEAPCORRUPT:
89+#endif
90+ cputs("HEAP CORRUPTED. Cannot proceed!\r\n");
91+ abort();
92+ case _HEAPEMPTY:
93+// cputs("NO HEAP. Cannot proceed!\r\n");
94+// abort();
95+ break;
96+ default:
97+ cputs("Unknown heapcheck() error. Cannot proceed!\r\n");
98+ abort();
99+ case _HEAPOK:
100+ break;
101+ }
102+#endif
103+
104+#ifdef __WATCOMC__
105+#ifdef DISP_NEAR
106+ nearThis = _memavl();
107+#endif
108+ _dos_allocmem(0xffff, &farThis);
109+ farThis <<= 4;
110+#else
111+#ifdef DISP_NEAR
112+ nearThis = coreleft();
113+#endif
114+ farThis = farcoreleft();
115+#endif
116+
117+#ifdef DISP_NEAR
118+// dprintf(("[free memory: near=%6u far=%13lu]\n", nearThis, farThis));
119+ printf("[free memory: near=%6u far=%13lu]\n", nearThis, farThis);
120+ if(nearLast)
121+// dprintf(("[changed : near=%6d far=%13ld]\n" , nearThis - nearLast , farThis - farLast));
122+ printf("[changed : near=%6d far=%13ld]\n" , nearThis - nearLast , farThis - farLast);
123+#else
124+// dprintf(("[free memory: far=%13lu]\n", farThis));
125+ printf("[free memory: far=%13lu]\n", (unsigned long)farThis);
126+ if(farLast)
127+// dprintf(("[changed : far=%13ld]\n", farThis - farLast));
128+ printf("[changed : far=%13d]\n", (farThis - farLast));
129+#endif
130+ printf("farcoreleft()=%lu\n", farcoreleft());
131+ printf("HC_farcoreleft()=%lu\n", HC_farcoreleft());
132+
133+#ifdef DISP_NEAR
134+ nearLast = nearThis;
135+#endif
136+ farLast = farThis;
137+}
138+
139+void main()
140+{
141+// static global_game_variables_t gvar;
142+ int pee; pee=1;
143+ dbg_printmem ();
144+// dbg_printmem ();
145+}
146+
147+//#endif /* DEBUG */
旧リポジトリブラウザで表示