]> 4ch.mooo.com Git - 16.git/commitdiff
Signed-off-by: sparky4 <sparky4@cock.li>
authorsparky4 <sparky4@cock.li>
Mon, 3 Aug 2015 20:52:25 +0000 (15:52 -0500)
committersparky4 <sparky4@cock.li>
Mon, 3 Aug 2015 20:52:25 +0000 (15:52 -0500)
28 files changed:
16.exe
DEBUG.16 [new file with mode: 0644]
HEAP.16 [new file with mode: 0644]
MMDUMP.16 [new file with mode: 0644]
PROFILE.16 [new file with mode: 0644]
bakapi.exe
exmmtest.exe
fmemtest.exe
fontgfx.exe
fonttest.exe
inputest.exe
makefile
maptest.exe
palettec.exe
pcxtest.exe
scroll.exe
sega.exe
sountest.exe
src/exmmtest.c
src/lib/16_hc.c [new file with mode: 0644]
src/lib/16_hc.h [new file with mode: 0644]
src/lib/16_head.c
src/lib/16_head.h
src/lib/16_mm.c
src/lib/16_mm.h
test.exe
test2.exe
tsthimem.exe

diff --git a/16.exe b/16.exe
index 48790e24366f002955d64918cf40722748db41d7..addb6416a5374faed99fe834a528edb068fa7746 100644 (file)
Binary files a/16.exe and b/16.exe differ
diff --git a/DEBUG.16 b/DEBUG.16
new file mode 100644 (file)
index 0000000..13e4d4d
--- /dev/null
+++ b/DEBUG.16
@@ -0,0 +1,8 @@
+0      Size:5194       Owner:0x0
+0      Size:5194       Owner:0x0
+144a   Size:256        Owner:0x4d02
+Seg:154a       Size:273        Owner:0x859a
+Seg:1bd1       Size:17 Owner:0x144d
+Seg:1bd1       Size:17 Owner:0x144d
+1dd2   Size:49710      Owner:0x11
+Seg:e000       Size:4294909951 Owner:0xc22b
diff --git a/HEAP.16 b/HEAP.16
new file mode 100644 (file)
index 0000000..9618578
--- /dev/null
+++ b/HEAP.16
@@ -0,0 +1,45 @@
+
+       == default ==
+
+  USED block at 1bd30016 of size 88
+  USED block at 1bd3009e of size 42
+  FREE block at 1bd300e0 of size 1f1e
+  USED block at 1bd31ffe of size 14
+  FREE block at 1bd32012 of size 1fea
+OK - end of heap
+
+       == near ==
+
+  USED block at 0 of size 0
+  USED block at 0 of size 0
+  USED block at 0 of size 0
+  USED block at 0 of size 0
+  USED block at 0 of size 0
+  USED block at 0 of size 0
+  USED block at 0 of size 0
+  USED block at 0 of size 0
+  USED block at 0 of size 0
+OK - end of heap
+
+       == far ==
+
+  USED block at 0 of size 0
+  USED block at 0 of size 0
+  USED block at 0 of size 0
+  USED block at 0 of size 0
+  USED block at 0 of size 0
+OK - end of heap
+
+Memory Type         Total      Used       Free
+----------------  --------   --------   --------
+Default                   16358        222     16136
+Near              31286        436     30850
+Far               16358        222     16136
+----------------  --------   --------   --------
+coreleft = 30848
+farcoreleft = 46788
+GetFreeSize = 15960
+GetNearFreeSize = 30850
+GetFarFreeSize = 15960
+memavl = 30848
+stackavail = 17135
diff --git a/MMDUMP.16 b/MMDUMP.16
new file mode 100644 (file)
index 0000000..b14aef4
Binary files /dev/null and b/MMDUMP.16 differ
diff --git a/PROFILE.16 b/PROFILE.16
new file mode 100644 (file)
index 0000000..e69de29
index e1c1f69d4d3888c58b7f4be6464892f2e74ecae1..de36892c93eae8fc5583fcb3ae6a65f08372a37d 100644 (file)
Binary files a/bakapi.exe and b/bakapi.exe differ
index eb7ba4e920d828ed103f2b8204a7b285d9e9fa01..d3de90c1bbc9e4fcaa9c7ee895a6bae25ca790e3 100644 (file)
Binary files a/exmmtest.exe and b/exmmtest.exe differ
index d67d4458a18e1e645bedab4afc7a0484690f4559..22b194327cb752c492053767bea8399b118cab01 100644 (file)
Binary files a/fmemtest.exe and b/fmemtest.exe differ
index 0b932c07c0f67fd4a2bed43ad10da41a0c3df933..b25350a2d9aa6f9405aad3e9e16939d3eceae259 100644 (file)
Binary files a/fontgfx.exe and b/fontgfx.exe differ
index 2d6c1c5b9dd85a72e80eecf29aa7cec9f351013a..abd57e7c8cdf2321fcfc1a0257afcd14c5718e46 100644 (file)
Binary files a/fonttest.exe and b/fonttest.exe differ
index b8e4f4f8bd88f958b015d95e74ae749e4c9af518..01fa65823c867379a9ccbe09c3f0fd6ea0e39ea4 100644 (file)
Binary files a/inputest.exe and b/inputest.exe differ
index 55ed3f26b354ff3fab60c166f4b3e8d539cfe001..faa97ac996ed42fd65727b4aff99a2ac8f5d6576 100644 (file)
--- a/makefile
+++ b/makefile
@@ -22,7 +22,7 @@ WCPULIB=$(SRCLIB)wcpu$(DIRSEP)
 
 16FLAGS=-fh=16.hed
 BAKAPIFLAGS=-fh=bakapi.hed
-SFLAGS=-sg -st -of+ -k32768#51200#49152#24576
+SFLAGS=-sg -st -of+ -k32768 -zu -zdp#51200#49152#24576
 DFLAGS=-DTARGET_MSDOS=16 -DMSDOS=1 $(SFLAGS)
 ZFLAGS=-zk0 -zq -zu -zc -zm# -zdp# -zp16
 CFLAGS=-mc -lr -l=dos -wo -x## -d2
@@ -31,7 +31,7 @@ FLAGS=$(OFLAGS) $(CFLAGS) $(DFLAGS) $(ZFLAGS)
 
 DOSLIBEXMMOBJ = himemsys.$(OBJ) emm.$(OBJ)
 DOSLIBOBJ = adlib.$(OBJ) 8254.$(OBJ) 8259.$(OBJ) dos.$(OBJ) cpu.$(OBJ)
-16LIBOBJS = bakapee.$(OBJ) 16_in.$(OBJ) 16_mm.$(OBJ) wcpu.$(OBJ) 16_head.$(OBJ) scroll16.$(OBJ) 16_ca.$(OBJ) timer.$(OBJ) kitten.$(OBJ)
+16LIBOBJS = bakapee.$(OBJ) 16_in.$(OBJ) 16_mm.$(OBJ) wcpu.$(OBJ) 16_head.$(OBJ) scroll16.$(OBJ) 16_ca.$(OBJ) timer.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ)
 GFXLIBOBJS = modex16.$(OBJ) bitmap.$(OBJ) planar.$(OBJ) 16text.$(OBJ)
 
 TESTEXEC =  exmmtest.exe test.exe pcxtest.exe test2.exe palettec.exe maptest.exe fmemtest.exe fonttest.exe fontgfx.exe sountest.exe tsthimem.exe inputest.exe scroll.exe sega.exe
@@ -267,6 +267,9 @@ emm.$(OBJ): $(DOSLIB)emm.h $(DOSLIB)emm.c
 16_head.$(OBJ): $(SRCLIB)16_head.h $(SRCLIB)16_head.c
        wcl $(FLAGS) -c $(SRCLIB)16_head.c
 
+16_hc.$(OBJ): $(SRCLIB)16_hc.h $(SRCLIB)16_hc.c
+       wcl $(FLAGS) -c $(SRCLIB)16_hc.c
+
 jsmn.$(OBJ): $(JSMNLIB)jsmn.h $(JSMNLIB)jsmn.c
        wcl $(FLAGS) -c $(JSMNLIB)jsmn.c
 
index 6ad044742c1f2f004d59b12f8934ab7d33cead6e..a1237bb194553fea6e77351231c7cfe1ef24d629 100644 (file)
Binary files a/maptest.exe and b/maptest.exe differ
index b38c6f72cf81684a53b614438a9bc79fbd7f91b1..e4ad17d409eedc814ea976fe3100c2ed4af27080 100644 (file)
Binary files a/palettec.exe and b/palettec.exe differ
index 87b9f8e48325762dc514a33ec6f4795174bfc2fb..a8ebf8a95f19ae7d5ac43a3c69f845d4518a4754 100644 (file)
Binary files a/pcxtest.exe and b/pcxtest.exe differ
index d360c998e18c832ba8e2900e3b6ad2e5cc3df800..534f03b32e89aaf77740d382af9451a02f64d675 100644 (file)
Binary files a/scroll.exe and b/scroll.exe differ
index 9ed4ba3667632677042ea56936e2b8d497af5043..7d1e0dda5fa7020992c0205813a0ea37c5ac5330 100644 (file)
Binary files a/sega.exe and b/sega.exe differ
index 6df13ea9f8e96440d1653e678c34e4a75daef800..8c9ac9b773f6b3977846197bce72fe06df4a2a2c 100644 (file)
Binary files a/sountest.exe and b/sountest.exe differ
index c0bbc33224d18064f33429a29e8cf753144a2a9e..bee5e1dcf697c4df2cdccd17329b25b2ccafd168 100644 (file)
@@ -28,6 +28,7 @@
 #include "src/lib/16_head.h"\r
 #include "src/lib/16_ca.h"\r
 #include "src/lib/16_mm.h"\r
+#include "src/lib/16_hc.h"\r
 //#include "src/lib/modex16.h"\r
 #pragma hdrstop\r
 \r
@@ -85,7 +86,7 @@ main(int argc, char *argv[])
        printf("&bigbuffer=     %Fp\n", &bigbuffer);\r
        printf("bigbuffer=      %04x\n", bigbuffer);\r
        printf("&bigbuffer=     %04x\n", &bigbuffer);\r
-       getch();\r
+//     getch();\r
 #ifdef FILERL\r
 //     bakapeehandle = open(bakapee,O_RDONLY | O_BINARY, S_IREAD);\r
 //     printf("size of big buffer~=%u\n", _bmsize(segu, bigbuffer));\r
@@ -132,15 +133,15 @@ main(int argc, char *argv[])
        printf("&bigbuffer=     %Fp\n", &bigbuffer);\r
        printf("bigbuffer=      %04x\n", bigbuffer);\r
        printf("&bigbuffer=     %04x\n", &bigbuffer);\r
-       printf("\n\n");\r
+       /*printf("\n\n");\r
        printf("Total free:                     %lu\n", (dword)(GetFreeSize()));\r
        printf("Total near free:                %lu\n", (dword)(GetNearFreeSize()));\r
        printf("Total far free:                 %lu\n", (dword)(GetFarFreeSize()));\r
-       getch();\r
+       getch();*/\r
        printf("\n");\r
        heapdump();\r
-       printf("core left:                      %lu\n", (dword)_coreleft());\r
-       printf("far core left:                  %lu\n", (dword)_farcoreleft());\r
+       //printf("core left:                    %lu\n", (dword)_coreleft());\r
+       //printf("far core left:                        %lu\n", (dword)_farcoreleft());\r
        //printf("based core left:                      %lu\n", (dword)_basedcoreleft());\r
        //printf("huge core left:                       %lu\n", (dword)_hugecoreleft());\r
 }\r
diff --git a/src/lib/16_hc.c b/src/lib/16_hc.c
new file mode 100644 (file)
index 0000000..af747fc
--- /dev/null
@@ -0,0 +1,489 @@
+/* Project 16 Source Code~
+ * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
+ *
+ * This file is part of Project 16.
+ *
+ * Project 16 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Project 16 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>, or
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+/*
+       heap test stuff
+*/
+
+#include "src/lib/16_hc.h"
+
+void __near* LargestFreeBlock(size_t* Size)
+{
+       size_t s0, s1;
+       void __near* p;
+
+       s0 = ~(size_t)0 ^ (~(size_t)0 >> 1);
+       while (s0 && (p = _nmalloc(s0)) == NULL)
+               s0 >>= 1;
+
+       if (p)
+               _nfree(p);
+
+       s1 = s0 >> 1;
+       while (s1)
+       {
+               if ((p = _nmalloc(s0 + s1)) != NULL)
+               {
+                       s0 += s1;
+                       _nfree(p);
+               }
+       s1 >>= 1;
+       }
+       while (s0 && (p = _nmalloc(s0)) == NULL)
+               s0 ^= s0 & -s0;
+
+       *Size = s0;
+       return p;
+}
+
+size_t _coreleft(void)
+{
+       size_t total = 0;
+       void __near* pFirst = NULL;
+       void __near* pLast = NULL;
+       for(;;)
+       {
+               size_t largest;
+               void __near* p = LargestFreeBlock(&largest);
+               if (largest < sizeof(void __near*))
+               {
+                       if (p != NULL)
+                       _nfree(p);
+                       break;
+               }
+               *(void __near* __near*)p = NULL;
+               total += largest;
+               if (pFirst == NULL)
+                       pFirst = p;
+
+               if (pLast != NULL)
+                       *(void __near* __near*)pLast = p;
+               pLast = p;
+       }
+
+       while (pFirst != NULL)
+       {
+               void __near* p = *(void __near* __near*)pFirst;
+               _nfree(pFirst);
+               pFirst = p;
+       }
+       return total;
+}
+
+void far* LargestFarFreeBlock(size_t* Size)
+{
+       size_t s0, s1;
+       void far* p;
+
+       s0 = ~(size_t)0 ^ (~(size_t)0 >> 1);
+       while (s0 && (p = _fmalloc(s0)) == NULL)
+               s0 >>= 1;
+
+       if (p)
+               _ffree(p);
+
+       s1 = s0 >> 1;
+       while (s1)
+       {
+               if ((p = _fmalloc(s0 + s1)) != NULL)
+               {
+                       s0 += s1;
+                       _ffree(p);
+               }
+       s1 >>= 1;
+       }
+       while (s0 && (p = _fmalloc(s0)) == NULL)
+               s0 ^= s0 & -s0;
+
+       *Size = s0;
+       return p;
+}
+
+size_t _farcoreleft(void)
+{
+       size_t total = 0;
+       void far* pFirst = NULL;
+       void far* pLast = NULL;
+       for(;;)
+       {
+               size_t largest;
+               void far* p = LargestFarFreeBlock(&largest);
+               if (largest < sizeof(void far*))
+               {
+                       if (p != NULL)
+                       _ffree(p);
+                       break;
+               }
+               *(void far* far*)p = NULL;
+               total += largest;
+               if (pFirst == NULL)
+                       pFirst = p;
+
+               if (pLast != NULL)
+                       *(void far* far*)pLast = p;
+               pLast = p;
+       }
+
+       while (pFirst != NULL)
+       {
+               void far* p = *(void far* far*)pFirst;
+               _ffree(pFirst);
+               pFirst = p;
+       }
+       return total;
+}
+
+void huge* LargestHugeFreeBlock(size_t* Size)
+{
+       size_t s0, s1;
+       void huge* p;
+
+       s0 = ~(size_t)0 ^ (~(size_t)0 >> 1);
+       while (s0 && (p = halloc((dword)s0, 1)) == NULL)
+               s0 >>= 1;
+
+       if (p)
+               hfree(p);
+
+       s1 = s0 >> 1;
+       while (s1)
+       {
+               if ((p = halloc((dword)(s0 + s1), 1)) != NULL)
+               {
+                       s0 += s1;
+                       hfree(p);
+               }
+       s1 >>= 1;
+       }
+       while (s0 && (p = halloc((dword)s0, 1)) == NULL)
+               s0 ^= s0 & -s0;
+
+       *Size = s0;
+       return p;
+}
+
+size_t _hugecoreleft(void)
+{
+       size_t total = 0;
+       void huge* pFirst = NULL;
+       void huge* pLast = NULL;
+       for(;;)
+       {
+               size_t largest;
+               void huge* p = LargestHugeFreeBlock(&largest);
+               if (largest < sizeof(void huge*))
+               {
+                       if (p != NULL)
+                       hfree(p);
+                       break;
+               }
+               *(void huge* huge*)p = NULL;
+               total += largest;
+               if (pFirst == NULL)
+                       pFirst = p;
+
+               if (pLast != NULL)
+                       *(void huge* huge*)pLast = p;
+               pLast = p;
+       }
+
+       while (pFirst != NULL)
+       {
+               void huge* p = *(void huge* huge*)pFirst;
+               hfree(pFirst);
+               pFirst = p;
+       }
+       return total;
+}
+
+/*void __based(__self)* LargestBasedFreeBlock(size_t* Size)
+{
+       __segment segu;
+       size_t s0, s1;
+       void __based(__self)* p;
+
+       s0 = ~(size_t)0 ^ (~(size_t)0 >> 1);
+       while (s0 && (p = _bmalloc(segu, s0)) == NULL)
+               s0 >>= 1;
+
+       if (p)
+               _ffree(p);
+
+       s1 = s0 >> 1;
+       while (s1)
+       {
+               if ((p = _bmalloc(segu, s0 + s1)) != NULL)
+               {
+                       s0 += s1;
+                       _ffree(p);
+               }
+       s1 >>= 1;
+       }
+       while (s0 && (p = _bmalloc(segu, s0)) == NULL)
+               s0 ^= s0 & -s0;
+
+       *Size = s0;
+       return p;
+}
+
+size_t _basedcoreleft(void)
+{
+       __segment segu;
+       size_t total = 0;
+       void __based(segu)* pFirst = NULL;
+       void __based(segu)* pLast = NULL;
+       // allocate based heap
+       segu = _bheapseg( 1024 );
+       if( segu == _NULLSEG ) {
+               printf( "Unable to allocate based heap\n" );
+               return 0;
+               //exit( 1 );
+       }
+       else
+
+       for(;;)
+       {
+               size_t largest;
+               void __based(segu)* p = LargestBasedFreeBlock(&largest);
+               if (largest < sizeof(void far*))
+               {
+                       if (p != NULL)
+                       _ffree(p);
+                       break;
+               }
+               *(void far* far*)p = NULL;
+               total += largest;
+               if (pFirst == NULL)
+                       pFirst = p;
+
+               if (pLast != NULL)
+                       *(void far* far*)pLast = p;
+               pLast = p;
+       }
+
+       while (pFirst != NULL)
+       {
+               void far* p = *(void far* far*)pFirst;
+               _ffree(pFirst);
+               pFirst = p;
+       }
+       return total;
+}*/
+
+size_t GetFreeSize(void)
+{
+       struct _heapinfo h_info;
+       int heap_status;
+       size_t h_free=0, h_total=0, h_used=0;
+
+       h_info._pentry = NULL;
+       for(;;) {
+               heap_status = _heapwalk( &h_info );
+               if( heap_status != _HEAPOK ) break;
+               if((h_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") h_free += h_info._size;
+               if((h_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") h_used += h_info._size;
+               h_total += h_info._size;
+       }
+       heapstat0(heap_status);
+       return h_free;
+}
+
+size_t GetFarFreeSize(void)
+{
+       struct _heapinfo fh_info;
+       int heap_status;
+       size_t fh_free=0, fh_total=0, fh_used=0;
+
+       fh_info._pentry = NULL;
+       for(;;) {
+               heap_status = _fheapwalk( &fh_info );
+               if( heap_status != _HEAPOK ) break;
+               if((fh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") fh_free += fh_info._size;
+               if((fh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") fh_used += fh_info._size;
+               fh_total += fh_info._size;
+       }
+       heapstat0(heap_status);
+       return fh_free;
+}
+
+size_t GetNearFreeSize(void)
+{
+       struct _heapinfo nh_info;
+       int heap_status;
+       size_t nh_free=0, nh_total=0, nh_used=0;
+
+       nh_info._pentry = NULL;
+       for(;;) {
+               heap_status = _nheapwalk( &nh_info );
+               if( heap_status != _HEAPOK ) break;
+               if((nh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") nh_free += nh_info._size;
+               if((nh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") nh_used += nh_info._size;
+               nh_total += nh_info._size;
+       }
+       heapstat0(heap_status);
+       return nh_free;
+}
+
+void heapdump(void)
+{
+       struct _heapinfo fh_info, nh_info, h_info;
+       int heap_status;
+       size_t h_free, nh_free, fh_free, h_total, nh_total, fh_total, h_used, nh_used, fh_used;
+       byte    scratch[1024],str[16];
+
+       HC_OpenDebug();
+
+       strcpy(scratch,"\n      == default ==\n\n");
+       write(heaphandle,scratch,strlen(scratch));
+       h_info._pentry = NULL;
+       h_free=0; h_total=0; h_used=0;
+       for(;;) {
+               heap_status = _heapwalk( &h_info );
+               if( heap_status != _HEAPOK ) break;
+
+               strcpy(scratch,"  "); strcat(scratch,(h_info._useflag == _USEDENTRY ? "USED" : "FREE")); strcat(scratch," block at "); ultoa((dword)h_info._pentry,str,16); strcat(scratch,str); strcat(scratch," of size "); ultoa(h_info._size,str,16); strcat(scratch,str); strcat(scratch,"\n");
+               if((h_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") h_free += h_info._size;
+               if((h_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") h_used += h_info._size;
+               h_total += h_info._size;
+               write(heaphandle,scratch,strlen(scratch));
+       }
+       heapstat(heap_status, &scratch);
+       
+       //near
+       strcpy(scratch,"\n      == near ==\n\n");
+       write(heaphandle,scratch,strlen(scratch));
+       nh_info._pentry = NULL;
+       nh_free=0; nh_total=0; nh_used=0;
+       for(;;) {
+               heap_status = _nheapwalk( &nh_info );
+               if( heap_status != _HEAPOK ) break;
+               
+               strcpy(scratch,"  "); strcat(scratch,(h_info._useflag == _USEDENTRY ? "USED" : "FREE")); strcat(scratch," block at "); ultoa((dword)h_info._pentry,str,16); strcat(scratch,str); strcat(scratch," of size "); ultoa(h_info._size,str,16); strcat(scratch,str); strcat(scratch,"\n");
+/*             printf( "  %s block at %Fp of size %4.4X\n",
+(nh_info._useflag == _USEDENTRY ? "USED" : "FREE"),
+nh_info._pentry, nh_info._size );*/
+               if((nh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") nh_free += nh_info._size;
+               if((nh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") nh_used += nh_info._size;
+               nh_total += nh_info._size;
+               write(heaphandle,scratch,strlen(scratch));
+       }
+       heapstat(heap_status, &scratch);
+
+       //far
+       strcpy(scratch,"\n      == far ==\n\n");
+       write(heaphandle,scratch,strlen(scratch));
+       fh_info._pentry = NULL;
+       fh_free=0; fh_total=0; fh_used=0;
+       for(;;) {
+               heap_status = _fheapwalk( &fh_info );
+               if( heap_status != _HEAPOK ) break;
+
+               strcpy(scratch,"  "); strcat(scratch,(h_info._useflag == _USEDENTRY ? "USED" : "FREE")); strcat(scratch," block at "); ultoa((dword)h_info._pentry,str,16); strcat(scratch,str); strcat(scratch," of size "); ultoa(h_info._size,str,16); strcat(scratch,str); strcat(scratch,"\n");
+               /*printf( "  %s block at %Fp of size %4.4X\n",
+(fh_info._useflag == _USEDENTRY ? "USED" : "FREE"),
+fh_info._pentry, fh_info._size );*/
+               if((fh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") fh_free += fh_info._size;
+               if((fh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") fh_used += fh_info._size;
+               fh_total += fh_info._size;
+               write(heaphandle,scratch,strlen(scratch));
+       }
+       heapstat(heap_status, &scratch);
+
+       strcpy(scratch,"\n");
+       strcat(scratch,kittengets(2,0,"Memory Type         Total      Used       Free\n"));
+       strcat(scratch,"----------------  --------   --------   --------\n");
+       printmeminfoline(&scratch, "Default", h_total, h_used, h_free);
+       printmeminfoline(&scratch, "Near", nh_total, nh_used, nh_free);
+       printmeminfoline(&scratch, "Far", fh_total, fh_used, fh_free);
+       strcat(scratch,"----------------  --------   --------   --------\n");
+       strcat(scratch,"coreleft = ");                  ultoa((dword)_coreleft(),str,10);               strcat(scratch,str);    strcat(scratch,"\n");
+       strcat(scratch,"farcoreleft = ");               ultoa((dword)_farcoreleft(),str,10);    strcat(scratch,str);    strcat(scratch,"\n");
+       strcat(scratch,"GetFreeSize = ");               ultoa((dword)GetFreeSize(),str,10);             strcat(scratch,str);    strcat(scratch,"\n");
+       strcat(scratch,"GetNearFreeSize = ");   ultoa((dword)GetNearFreeSize(),str,10); strcat(scratch,str);    strcat(scratch,"\n");
+       strcat(scratch,"GetFarFreeSize = ");    ultoa((dword)GetFarFreeSize(),str,10);  strcat(scratch,str);    strcat(scratch,"\n");
+       strcat(scratch,"memavl = ");                    ultoa((dword)_memavl(),str,10);                 strcat(scratch,str);    strcat(scratch,"\n");
+       strcat(scratch,"stackavail = ");                ultoa((dword)stackavail(),str,10);              strcat(scratch,str);    strcat(scratch,"\n");
+       write(heaphandle,scratch,strlen(scratch));
+       HC_CloseDebug();
+}
+
+void heapstat(int heap_status, byte *str)
+{
+       switch( heap_status ) {
+               case _HEAPEND:
+                       strcpy((str),"OK - end of heap\n");
+               break;
+               case _HEAPEMPTY:
+                       strcpy((str),"OK - heap is empty\n");
+                       
+               break;
+               case _HEAPBADBEGIN:
+                       strcpy((str),"ERROR - heap is damaged\n");
+               break;
+               case _HEAPBADPTR:
+                       strcpy((str),"ERROR - bad pointer to heap\n");
+               break;
+               case _HEAPBADNODE:
+                       strcpy((str),"ERROR - bad node in heap\n");
+       }
+       write(heaphandle,(str),strlen((str)));
+}
+
+void heapstat0(int heap_status)
+{
+       switch( heap_status ) {
+               case _HEAPEND:
+                       //printf("OK - end of heap\n");
+               break;
+               case _HEAPEMPTY:
+                       //printf("OK - heap is empty\n");
+                       
+               break;
+               case _HEAPBADBEGIN:
+                       printf("ERROR - heap is damaged\n");
+               break;
+               case _HEAPBADPTR:
+                       printf("ERROR - bad pointer to heap\n");
+               break;
+               case _HEAPBADNODE:
+                       printf("ERROR - bad node in heap\n");
+       }
+}
+
+/*
+============================
+=
+= HC_OpenDebug / HC_CloseDebug
+=
+= Opens a binary file with the handle "heaphandle"
+=
+============================
+*/
+void HC_OpenDebug()
+{
+       unlink("heap.16");
+       heaphandle = open("heap.16", O_CREAT | O_WRONLY | O_TEXT);
+}
+
+void HC_CloseDebug()
+{
+       close(heaphandle);
+}
diff --git a/src/lib/16_hc.h b/src/lib/16_hc.h
new file mode 100644 (file)
index 0000000..7959d29
--- /dev/null
@@ -0,0 +1,51 @@
+/* Project 16 Source Code~
+ * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
+ *
+ * This file is part of Project 16.
+ *
+ * Project 16 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Project 16 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>, or
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+/*
+       heap test stuff
+*/
+
+#ifndef __16HC__
+#define __16HC__
+
+#include "src/lib/16_head.h"
+
+int heaphandle;
+
+void __near* LargestFreeBlock(size_t* Size);
+size_t _coreleft(void);
+void far* LargestFarFreeBlock(size_t* Size);
+size_t _farcoreleft(void);
+void huge* LargestHugeFreeBlock(size_t* Size);
+size_t _hugecoreleft(void);
+//void __based(__self)* LargestBasedFreeBlock(size_t* Size);
+//size_t _basedcoreleft(void);
+size_t GetFreeSize(void);
+size_t GetFarFreeSize(void);
+size_t GetNearFreeSize(void);
+void heapdump(void);
+void heapstat(int heap_status, byte *str);
+void heapstat0(int heap_status);
+
+void HC_OpenDebug();
+void HC_CloseDebug();
+
+#endif /* __16HC__ */
index 95a9e688d4b1ac200b83f8dcef928299d87c9788..df0b31c7bdc7c1a061eb1736799dba9ae578bf43 100644 (file)
@@ -38,323 +38,6 @@ void wait(clock_t wait){
        while((goal > clock()) && !kbhit()) ;\r
 } /* End of wait */
 
-void __near* LargestFreeBlock(size_t* Size)
-{
-       size_t s0, s1;
-       void __near* p;
-
-       s0 = ~(size_t)0 ^ (~(size_t)0 >> 1);
-       while (s0 && (p = _nmalloc(s0)) == NULL)
-               s0 >>= 1;
-
-       if (p)
-               _nfree(p);
-
-       s1 = s0 >> 1;
-       while (s1)
-       {
-               if ((p = _nmalloc(s0 + s1)) != NULL)
-               {
-                       s0 += s1;
-                       _nfree(p);
-               }
-       s1 >>= 1;
-       }
-       while (s0 && (p = _nmalloc(s0)) == NULL)
-               s0 ^= s0 & -s0;
-
-       *Size = s0;
-       return p;
-}
-
-size_t _coreleft(void)
-{
-       size_t total = 0;
-       void __near* pFirst = NULL;
-       void __near* pLast = NULL;
-       for(;;)
-       {
-               size_t largest;
-               void __near* p = LargestFreeBlock(&largest);
-               if (largest < sizeof(void __near*))
-               {
-                       if (p != NULL)
-                       _nfree(p);
-                       break;
-               }
-               *(void __near* __near*)p = NULL;
-               total += largest;
-               if (pFirst == NULL)
-                       pFirst = p;
-
-               if (pLast != NULL)
-                       *(void __near* __near*)pLast = p;
-               pLast = p;
-       }
-
-       while (pFirst != NULL)
-       {
-               void __near* p = *(void __near* __near*)pFirst;
-               _nfree(pFirst);
-               pFirst = p;
-       }
-       return total;
-}
-
-void far* LargestFarFreeBlock(size_t* Size)
-{
-       size_t s0, s1;
-       void far* p;
-
-       s0 = ~(size_t)0 ^ (~(size_t)0 >> 1);
-       while (s0 && (p = _fmalloc(s0)) == NULL)
-               s0 >>= 1;
-
-       if (p)
-               _ffree(p);
-
-       s1 = s0 >> 1;
-       while (s1)
-       {
-               if ((p = _fmalloc(s0 + s1)) != NULL)
-               {
-                       s0 += s1;
-                       _ffree(p);
-               }
-       s1 >>= 1;
-       }
-       while (s0 && (p = _fmalloc(s0)) == NULL)
-               s0 ^= s0 & -s0;
-
-       *Size = s0;
-       return p;
-}
-
-size_t _farcoreleft(void)
-{
-       size_t total = 0;
-       void far* pFirst = NULL;
-       void far* pLast = NULL;
-       for(;;)
-       {
-               size_t largest;
-               void far* p = LargestFarFreeBlock(&largest);
-               if (largest < sizeof(void far*))
-               {
-                       if (p != NULL)
-                       _ffree(p);
-                       break;
-               }
-               *(void far* far*)p = NULL;
-               total += largest;
-               if (pFirst == NULL)
-                       pFirst = p;
-
-               if (pLast != NULL)
-                       *(void far* far*)pLast = p;
-               pLast = p;
-       }
-
-       while (pFirst != NULL)
-       {
-               void far* p = *(void far* far*)pFirst;
-               _ffree(pFirst);
-               pFirst = p;
-       }
-       return total;
-}
-
-void huge* LargestHugeFreeBlock(size_t* Size)
-{
-       size_t s0, s1;
-       void huge* p;
-
-       s0 = ~(size_t)0 ^ (~(size_t)0 >> 1);
-       while (s0 && (p = halloc((dword)s0, 1)) == NULL)
-               s0 >>= 1;
-
-       if (p)
-               hfree(p);
-
-       s1 = s0 >> 1;
-       while (s1)
-       {
-               if ((p = halloc((dword)(s0 + s1), 1)) != NULL)
-               {
-                       s0 += s1;
-                       hfree(p);
-               }
-       s1 >>= 1;
-       }
-       while (s0 && (p = halloc((dword)s0, 1)) == NULL)
-               s0 ^= s0 & -s0;
-
-       *Size = s0;
-       return p;
-}
-
-size_t _hugecoreleft(void)
-{
-       size_t total = 0;
-       void huge* pFirst = NULL;
-       void huge* pLast = NULL;
-       for(;;)
-       {
-               size_t largest;
-               void huge* p = LargestHugeFreeBlock(&largest);
-               if (largest < sizeof(void huge*))
-               {
-                       if (p != NULL)
-                       hfree(p);
-                       break;
-               }
-               *(void huge* huge*)p = NULL;
-               total += largest;
-               if (pFirst == NULL)
-                       pFirst = p;
-
-               if (pLast != NULL)
-                       *(void huge* huge*)pLast = p;
-               pLast = p;
-       }
-
-       while (pFirst != NULL)
-       {
-               void huge* p = *(void huge* huge*)pFirst;
-               hfree(pFirst);
-               pFirst = p;
-       }
-       return total;
-}
-
-/*void __based(__self)* LargestBasedFreeBlock(size_t* Size)
-{
-       __segment segu;
-       size_t s0, s1;
-       void __based(__self)* p;
-
-       s0 = ~(size_t)0 ^ (~(size_t)0 >> 1);
-       while (s0 && (p = _bmalloc(segu, s0)) == NULL)
-               s0 >>= 1;
-
-       if (p)
-               _ffree(p);
-
-       s1 = s0 >> 1;
-       while (s1)
-       {
-               if ((p = _bmalloc(segu, s0 + s1)) != NULL)
-               {
-                       s0 += s1;
-                       _ffree(p);
-               }
-       s1 >>= 1;
-       }
-       while (s0 && (p = _bmalloc(segu, s0)) == NULL)
-               s0 ^= s0 & -s0;
-
-       *Size = s0;
-       return p;
-}
-
-size_t _basedcoreleft(void)
-{
-       __segment segu;
-       size_t total = 0;
-       void __based(segu)* pFirst = NULL;
-       void __based(segu)* pLast = NULL;
-       // allocate based heap\r
-       segu = _bheapseg( 1024 );\r
-       if( segu == _NULLSEG ) {\r
-               printf( "Unable to allocate based heap\n" );
-               return 0;\r
-               //exit( 1 );\r
-       }
-       else
-
-       for(;;)
-       {
-               size_t largest;
-               void __based(segu)* p = LargestBasedFreeBlock(&largest);
-               if (largest < sizeof(void far*))
-               {
-                       if (p != NULL)
-                       _ffree(p);
-                       break;
-               }
-               *(void far* far*)p = NULL;
-               total += largest;
-               if (pFirst == NULL)
-                       pFirst = p;
-
-               if (pLast != NULL)
-                       *(void far* far*)pLast = p;
-               pLast = p;
-       }
-
-       while (pFirst != NULL)
-       {
-               void far* p = *(void far* far*)pFirst;
-               _ffree(pFirst);
-               pFirst = p;
-       }
-       return total;
-}*/
-
-size_t GetFreeSize(void)
-{
-       struct _heapinfo h_info;
-       int heap_status;
-       size_t h_free=0, h_total=0, h_used=0;
-
-       h_info._pentry = NULL;
-       for(;;) {
-               heap_status = _heapwalk( &h_info );
-               if( heap_status != _HEAPOK ) break;
-               if((h_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") h_free += h_info._size;
-               if((h_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") h_used += h_info._size;
-               h_total += h_info._size;
-       }
-       heapstat(heap_status);
-       return h_free;
-}
-
-size_t GetFarFreeSize(void)
-{
-       struct _heapinfo fh_info;
-       int heap_status;
-       size_t fh_free=0, fh_total=0, fh_used=0;
-
-       fh_info._pentry = NULL;
-       for(;;) {
-               heap_status = _fheapwalk( &fh_info );
-               if( heap_status != _HEAPOK ) break;
-               if((fh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") fh_free += fh_info._size;
-               if((fh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") fh_used += fh_info._size;
-               fh_total += fh_info._size;
-       }
-       heapstat(heap_status);
-       return fh_free;
-}
-
-size_t GetNearFreeSize(void)
-{
-       struct _heapinfo nh_info;
-       int heap_status;
-       size_t nh_free=0, nh_total=0, nh_used=0;
-
-       nh_info._pentry = NULL;
-       for(;;) {
-               heap_status = _nheapwalk( &nh_info );
-               if( heap_status != _HEAPOK ) break;
-               if((nh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") nh_free += nh_info._size;
-               if((nh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") nh_used += nh_info._size;
-               nh_total += nh_info._size;
-       }
-       heapstat(heap_status);
-       return nh_free;
-}
-
 long int
 filesize(FILE *fp)\r
 {\r
@@ -367,7 +50,14 @@ filesize(FILE *fp)
        return(size_of_file);\r
 }
 
-void print_normal_entry(char *text, dword total, dword used, dword free)
+void printmeminfoline(byte *strc, const byte *pee, size_t h_total, size_t h_used, size_t h_free)
+{
+       byte str[64];
+       strcat(strc,pee); strcat(strc,"            "); ultoa((dword)h_total,str,10); strcat(strc,str); strcat(strc,"    "); ultoa((dword)h_used,str,10); strcat(strc,str); strcat(strc,"        "); ultoa((dword)h_free,str,10); strcat(strc,str);
+       strcat(strc,"\n");
+}
+
+void print_normal_entry(char *text, dword total, dword used, dword free, byte *str)
 {
        printf("%-17s", text);
        convert("%8sB ", total);
@@ -415,96 +105,6 @@ void convert(const char *format, dword num)
     printf(format, des);
 }
 
-void heapdump(void)
-{
-       struct _heapinfo fh_info, nh_info, h_info;
-       int heap_status;
-       size_t h_free, nh_free, fh_free, h_total, nh_total, fh_total, h_used, nh_used, fh_used;
-
-       printf("\n      == default ==\n\n");
-       h_info._pentry = NULL;
-       h_free=0; h_total=0; h_used=0;
-       for(;;) {
-               heap_status = _heapwalk( &h_info );
-               if( heap_status != _HEAPOK ) break;
-               printf( "  %s block at %Fp of size %4.4X\n",
-(h_info._useflag == _USEDENTRY ? "USED" : "FREE"),
-h_info._pentry, h_info._size );
-               if((h_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") h_free += h_info._size;
-               if((h_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") h_used += h_info._size;
-               h_total += h_info._size;
-       }
-       heapstat(heap_status);
-
-       //near
-       printf("\n      == near ==\n\n");
-       nh_info._pentry = NULL;
-       nh_free=0; nh_total=0; nh_used=0;
-       for(;;) {
-               heap_status = _nheapwalk( &nh_info );
-               if( heap_status != _HEAPOK ) break;
-               printf( "  %s block at %Fp of size %4.4X\n",
-(nh_info._useflag == _USEDENTRY ? "USED" : "FREE"),
-nh_info._pentry, nh_info._size );
-               if((nh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") nh_free += nh_info._size;
-               if((nh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") nh_used += nh_info._size;
-               nh_total += nh_info._size;
-       }
-       heapstat(heap_status);
-
-       //far
-       printf("\n      == far ==\n\n");
-       fh_info._pentry = NULL;
-       fh_free=0; fh_total=0; fh_used=0;
-       for(;;) {
-               heap_status = _fheapwalk( &fh_info );
-               if( heap_status != _HEAPOK ) break;
-               printf( "  %s block at %Fp of size %4.4X\n",
-(fh_info._useflag == _USEDENTRY ? "USED" : "FREE"),
-fh_info._pentry, fh_info._size );
-               if((fh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") fh_free += fh_info._size;
-               if((fh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") fh_used += fh_info._size;
-               fh_total += fh_info._size;
-       }
-       heapstat(heap_status);
-
-printf("\n");
-printf(kittengets(2,0,"Memory Type         Total      Used       Free\n"));
-printf(      "----------------  --------   --------   --------\n");
-print_normal_entry(kittengets(2,1,"Default"), (dword)h_total, (dword)h_used, (dword)h_free);
-print_normal_entry(kittengets(2,1,"Near"), (dword)nh_total, (dword)nh_used, (dword)nh_free);
-print_normal_entry(kittengets(2,1,"Far"), (dword)fh_total, (dword)fh_used, (dword)fh_free);
-printf(      "----------------  --------   --------   --------\n");
-printf("coreleft = %lu\n", (dword)_coreleft());
-printf("farcoreleft = %lu\n", (dword)_farcoreleft());
-printf("GetFreeSize = %lu\n", (dword)GetFreeSize());
-printf("GetNearFreeSize = %lu\n", (dword)GetNearFreeSize());
-printf("GetFarFreeSize = %lu\n", (dword)GetFarFreeSize());
-printf("memavl = %lu\n", (dword)_memavl());
-printf("stackavail = %u\n", stackavail());
-}
-
-void heapstat(int heap_status)
-{
-       switch( heap_status ) {
-               case _HEAPEND:
-                       //printf( "OK - end of heap\n" );
-               break;
-               case _HEAPEMPTY:
-                       //printf( "OK - heap is empty\n" );
-               break;
-               case _HEAPBADBEGIN:
-                       printf( "ERROR - heap is damaged\n" );
-               break;
-               case _HEAPBADPTR:
-                       printf( "ERROR - bad pointer to heap\n" );
-               break;
-               case _HEAPBADNODE:
-                       printf( "ERROR - bad node in heap\n" );
-       }
-}
-
-
 ///////////////////////////////////////////////////////////////////////////\r
 //\r
 //      US_CheckParm() - checks to see if a string matches one of a set of\r
index 3589a821adbab8f6492b3db0dcc6601c49e4eb89..84a4a9eba1de7a53fba390ab1786bf4fa3d44577 100644 (file)
@@ -46,6 +46,7 @@
 #include "src/lib/nyan/kitten.h"\r
 #include "src/lib/types.h"\r
 \r
+//0000 test type def wwww\r
 struct list {\r
        struct list __based(__self) *next;\r
        int         value;\r
@@ -144,13 +145,10 @@ struct list {
 */\r
 \r
 static dword far* clockdw= (dword far*) 0x046C; /* 18.2hz clock */\r
-//static dword clockdw=0;\r
 extern int                     profilehandle,debughandle;      //make it into game global\r
 \r
 #define __DEBUG__\r
 \r
-//#define _SEGU(__p) ((unsigned)((unsigned long)(void __huge*)(__p) >> 16))\r
-\r
 #define        nil     ((void *)0)\r
 \r
 #define peekb(segm,ofs) (*(byte far*)MK_FP((segm),(ofs)))\r
@@ -164,9 +162,6 @@ typedef union REGPACK       regs_t;
 typedef        enum    {false,true}    boolean;\r
 //I hope this is correct!\r
 typedef void __based(__self) * memptr;\r
-//typedef sregs.w.es * memptr\r
-//typedef __segment * memptr;\r
-//typedef fenp.op_ptr_seg * memptr;\r
 typedef struct\r
 {\r
        int old_mode;   //old video mode before game!\r
@@ -174,26 +169,17 @@ typedef struct
        clock_t t;\r
        dword tiku;\r
        word far* clock;\r
+       //handles for log files of the game gose here if wwww\r
+       //int heaphandle;\r
 } global_game_variables_t;\r
 \r
 /* local function */\r
 void wait(clock_t wait);\r
-void __near* LargestFreeBlock(size_t* Size);\r
-size_t _coreleft(void);\r
-void far* LargestFarFreeBlock(size_t* Size);\r
-size_t _farcoreleft(void);\r
-void huge* LargestHugeFreeBlock(size_t* Size);\r
-size_t _hugecoreleft(void);\r
-//void __based(__self)* LargestBasedFreeBlock(size_t* Size);\r
-//size_t _basedcoreleft(void);\r
-size_t GetFreeSize(void);\r
-size_t GetFarFreeSize(void);\r
-size_t GetNearFreeSize(void);\r
+\r
 long int filesize(FILE *fp);\r
-void print_normal_entry(char *text, dword total, dword used, dword free);\r
+void printmeminfoline(byte *strc, const byte *pee, size_t h_total, size_t h_used, size_t h_free);\r
+void print_normal_entry(char *text, dword total, dword used, dword free, byte *str);\r
 void convert(const char *format, dword num);\r
-void heapdump(void);\r
-void heapstat(int heap_status);\r
 int US_CheckParm(char *parm,char **strings);\r
 \r
 extern void CA_OpenDebug (void);\r
index 1b887284b7a8a0257c1a65264fae9c96cfa7b653..bff437306c465da39c96dbe0e692b5858e165518 100644 (file)
@@ -684,7 +684,6 @@ void MM_Startup(mminfo_t *mm, mminfotype *mmi)
        mmi->nearheap = length;
        printf("start=%FP       segstart=%X     seglen=%lu      len=%lu\n", start, segstart, seglength, length);
        //heapdump();
-       //getch();
 
 //
 // get all available far conventional memory segments
@@ -706,7 +705,7 @@ void MM_Startup(mminfo_t *mm, mminfotype *mmi)
 
        mmi->mainmem = mmi->nearheap + mmi->farheap;
 
-       getch();
+//     getch();
 
 //goto xmsskip;
 
@@ -811,14 +810,15 @@ void MM_GetPtr(memptr *baseptr,dword size, mminfo_t *mm, mminfotype *mmi)
        unsigned        needed,startseg;
 
        needed = (size+15)/16;          // convert size from bytes to paragraphs
-
+printf(".");   //0000
        MM_GetNewBlock(mm);                             // fill in start and next after a spot is found
        mm->mmnew->length = needed;
        mm->mmnew->useptr = baseptr;
        mm->mmnew->attributes = BASEATTRIBUTES;
-
+printf(".");   //0000
        for(search = 0; search<3; search++)
        {
+printf("|[case]");     //0000
        //
        // first search:        try to allocate right after the rover, then on up
        // second search:       search from the head pointer up to the rover
@@ -829,16 +829,19 @@ void MM_GetPtr(memptr *baseptr,dword size, mminfo_t *mm, mminfotype *mmi)
                switch(search)
                {
                case 0:
+printf("0");   //0000
                        lastscan = mm->mmrover;
                        scan = mm->mmrover->next;
                        endscan = NULL;
                        break;
                case 1:
+printf("1");   //0000
                        lastscan = mm->mmhead;
                        scan = mm->mmhead->next;
                        endscan = mm->mmrover;
                        break;
                case 2:
+printf("2");   //0000
                        MM_SortMem(mm);
                        lastscan = mm->mmhead;
                        scan = mm->mmhead->next;
@@ -850,8 +853,10 @@ void MM_GetPtr(memptr *baseptr,dword size, mminfo_t *mm, mminfotype *mmi)
 
                while(scan != endscan)
                {
+printf(",");   //0000
                        if(scan->start - startseg >= needed)
                        {
+printf("\\");  //0000
                        //
                        // got enough space between the end of lastscan and
                        // the start of scan, so throw out anything in the middle
@@ -863,6 +868,7 @@ void MM_GetPtr(memptr *baseptr,dword size, mminfo_t *mm, mminfotype *mmi)
                                mm->mmnew->next = scan;
                                while(purge != scan)
                                {       // free the purgable block
+printf("               freeing block~\n");     //0000
                                        next = purge->next;
                                        MM_FreeBlock(purge, mm);
                                        purge = next;           // purge another if not at scan
@@ -877,6 +883,7 @@ void MM_GetPtr(memptr *baseptr,dword size, mminfo_t *mm, mminfotype *mmi)
                        if((scan->attributes & LOCKBIT)
                                || !(scan->attributes & PURGEBITS) )
                        {
+printf("/[lock]");     //0000
                                lastscan = scan;
                                startseg = lastscan->start + lastscan->length;
                        }
@@ -1208,7 +1215,7 @@ CA_OpenDebug ();
 */
 
 //****#if 0
-printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");    //bug!
+//printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");  //bug!
 strcpy(scratch,"Seg:");
 ultoa (scan->start,str,16);
 strcat (scratch,str);
index 4298adb0b43064bd1ac0e76557b0e38af1847075..010a26265d932149300e24804178c17c8cdb11b2 100644 (file)
@@ -25,6 +25,7 @@
 #include <malloc.h>
 //#include <bios.h>
 #include "src/lib/16_head.h"
+#include "src/lib/16_hc.h"
 #include "src/lib/modex16.h"
 //#include "src/lib/16_ca.h"
 //++++mh       #include "src/lib/16_in.h"
index c2fb85a4e9814abed3519ecfeb4cd381c82e8e46..cbb49da851dc5876ba334c03ff5eab9598d717e2 100644 (file)
Binary files a/test.exe and b/test.exe differ
index 1c8b210fe493d32b1d2c95417864f860d4bcad37..bd6ee77955e488f4c72d3b674f12347e638409d5 100644 (file)
Binary files a/test2.exe and b/test2.exe differ
index 8a00b50cab11b0320893fc840817776e74a28ef4..ddedc3e44c153d885f1c514d0812b4ab8ca90864 100644 (file)
Binary files a/tsthimem.exe and b/tsthimem.exe differ