From: sparky4 Date: Wed, 22 Jul 2015 17:12:30 +0000 (-0500) Subject: FICK!!!!! i need super legit help! X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=364d4b084428eeee1b6c510ff65241d3b92ccc5a;p=16.git FICK!!!!! i need super legit help! modified: 16.exe new file: 16.hed new file: DEBUG.16 deleted: DEBUG.TXT new file: MMDUMP.16 deleted: MMDUMP.TXT new file: PROFILE.16 modified: exmmtest.exe modified: fmemtest.exe modified: fontgfx.exe modified: fonttest.exe modified: inputest.exe modified: makefile modified: maptest.exe modified: palettec.exe modified: pcxtest.exe modified: sountest.exe modified: src/exmmtest.c modified: src/lib/16_ca.c modified: src/lib/16_ca.h modified: src/lib/16_head.c modified: src/lib/16_head.h modified: src/lib/16_mm.c modified: src/lib/16_mm.h modified: src/lib/16_pm.c modified: test.exe modified: test2.exe modified: tsthimem.exe --- diff --git a/16.exe b/16.exe index adda6ad1..9ebcb317 100644 Binary files a/16.exe and b/16.exe differ diff --git a/16.hed b/16.hed new file mode 100644 index 00000000..2b186fbe Binary files /dev/null and b/16.hed differ diff --git a/DEBUG.16 b/DEBUG.16 new file mode 100644 index 00000000..1f794e8f --- /dev/null +++ b/DEBUG.16 @@ -0,0 +1,6 @@ +Seg:0 Size:109104 Owner:0xfdba +Seg:1b9c Size:16 Owner:0xc31e +Seg:1b9d Size:4096 Owner:0xc25c +Seg:1f42 Size:789472 Owner:0xa8c + +MM_ShowMemory: Memory block order currupted! diff --git a/DEBUG.TXT b/DEBUG.TXT deleted file mode 100644 index 24bdfb82..00000000 --- a/DEBUG.TXT +++ /dev/null @@ -1,4 +0,0 @@ -Seg:0 Size:105952 Owner:0xfc46 -Seg:19de Size:4096 Owner:0x56f8 -Seg:218e Size:8080 Owner:0x46f6 -Seg:6385 Size:640928 Owner:0x2ef7 diff --git a/MMDUMP.16 b/MMDUMP.16 new file mode 100644 index 00000000..02fa2ec3 Binary files /dev/null and b/MMDUMP.16 differ diff --git a/MMDUMP.TXT b/MMDUMP.TXT deleted file mode 100644 index fb7e0999..00000000 Binary files a/MMDUMP.TXT and /dev/null differ diff --git a/PROFILE.16 b/PROFILE.16 new file mode 100644 index 00000000..e69de29b diff --git a/exmmtest.exe b/exmmtest.exe index 35859a07..5b068f6f 100644 Binary files a/exmmtest.exe and b/exmmtest.exe differ diff --git a/fmemtest.exe b/fmemtest.exe index 9d584f05..39ee9b81 100644 Binary files a/fmemtest.exe and b/fmemtest.exe differ diff --git a/fontgfx.exe b/fontgfx.exe index ac4912df..58132548 100644 Binary files a/fontgfx.exe and b/fontgfx.exe differ diff --git a/fonttest.exe b/fonttest.exe index b8327e4b..f812b28b 100644 Binary files a/fonttest.exe and b/fonttest.exe differ diff --git a/inputest.exe b/inputest.exe index 47311618..842c7b7d 100644 Binary files a/inputest.exe and b/inputest.exe differ diff --git a/makefile b/makefile index cd103e73..7e24fab5 100644 --- a/makefile +++ b/makefile @@ -12,9 +12,9 @@ TARGET_OS = dos #-zk0 = kanji support~ #-zkl = current codepage -ZFLAGS=-zk0 -zc# -zu -zm# -zdp# -zp16 -zq +ZFLAGS=-zk0 -zu -zc# -zm# -zdp# -zp16 -zq DFLAGS=-DTARGET_MSDOS=16 -DMSDOS=1 -CFLAGS=-wo -x -mc -wo -k32768#16384# +CFLAGS=-ei -wo -x -mc -r -fh=16.hed -k60000#16384# OFLAGS=-ot -ox -ob -oh -or -om -ol# -ol+ FLAGS=-0 -d2 -lr $(OFLAGS) $(CFLAGS) $(DFLAGS) $(ZFLAGS) SRC=src$(DIRSEP) diff --git a/maptest.exe b/maptest.exe index 7480d470..11ee1cb2 100644 Binary files a/maptest.exe and b/maptest.exe differ diff --git a/palettec.exe b/palettec.exe index 196f5244..1cb67ec6 100644 Binary files a/palettec.exe and b/palettec.exe differ diff --git a/pcxtest.exe b/pcxtest.exe index e2a70937..401a18c5 100644 Binary files a/pcxtest.exe and b/pcxtest.exe differ diff --git a/sountest.exe b/sountest.exe index 841f8170..04c88cd2 100644 Binary files a/sountest.exe and b/sountest.exe differ diff --git a/src/exmmtest.c b/src/exmmtest.c index ead23e78..9546bc17 100644 --- a/src/exmmtest.c +++ b/src/exmmtest.c @@ -35,8 +35,8 @@ #pragma warn -use //file load or read definition -//#define FILERL -//#define FILEREAD +#define FILERL +#define FILEREAD void main(int argc, char *argv[]) @@ -44,8 +44,9 @@ main(int argc, char *argv[]) mminfo_t mm; mminfotype mmi; __segment segu; #ifdef FILERL - memptr bigbuffer; - static char *bakapee; + memptr bigbuffer; + char *bakapee; +// int bakapeehandle; word baka; #endif //static page_t screen; @@ -77,6 +78,9 @@ main(int argc, char *argv[]) printf("main()=%Fp start MM\n", *argv[0]); MM_Startup(&mm, &mmi); + //PM_Startup(); + //PM_UnlockMainMem(); + CA_Startup(); printf(" done!\n"); /*if(FP_SEG(*argv[0])==0) { @@ -87,9 +91,12 @@ main(int argc, char *argv[]) exit(-5); }*/ printf("&main()=%Fp\n", *argv[0]); - printf("&segu=%p\n", (segu)); + printf("&segu=%p\n", (segu)); //printf("mmi.segu=%p\n", (mmi.segu)); #ifdef FILERL +// bakapeehandle = open(bakapee,O_RDONLY | O_BINARY, S_IREAD); + printf("size of big buffer~=%lu\n", _bmsize(segu, bigbuffer)); +// if(CA_FarRead(bakapeehandle,(void far *)&bigbuffer,sizeof(bigbuffer),&mm)) #ifdef FILEREAD printf(" read\n"); if(CA_ReadFile(bakapee, &bigbuffer, &mm)) @@ -100,6 +107,7 @@ main(int argc, char *argv[]) baka=1; else baka=0; +// close(bakapeehandle); //hmm functions in cache system use the buffered stuff printf("size of big buffer~=%lu\n", _bmsize(segu, bigbuffer)); #endif @@ -118,6 +126,8 @@ main(int argc, char *argv[]) #ifdef FILERL MM_FreePtr(&bigbuffer, &mm); #endif + //PM_Shutdown(); + CA_Shutdown(); MM_Shutdown(&mm); printf(" done!\n"); #ifdef FILERL diff --git a/src/lib/16_ca.c b/src/lib/16_ca.c index bf94bc8c..f74a5710 100644 --- a/src/lib/16_ca.c +++ b/src/lib/16_ca.c @@ -175,8 +175,8 @@ long GRFILEPOS(int c) */ void CA_OpenDebug(void) { - unlink("debug.txt"); - debughandle = open("debug.txt", O_CREAT | O_WRONLY | O_TEXT); + unlink("debug.16"); + debughandle = open("debug.16", O_CREAT | O_WRONLY | O_TEXT); } void CA_CloseDebug(void) @@ -330,7 +330,8 @@ End: boolean CA_ReadFile(char *filename, memptr *ptr, mminfo_t *mm) { int handle; - dword size; + dword size; + //long size; if((handle = open(filename,O_RDONLY | O_BINARY, S_IREAD)) == -1) return false; @@ -360,7 +361,8 @@ boolean CA_ReadFile(char *filename, memptr *ptr, mminfo_t *mm) boolean CA_LoadFile(char *filename, memptr *ptr, mminfo_t *mm, mminfotype *mmi) { int handle; - long size; + dword size; + //long size; if((handle = open(filename,O_RDONLY | O_BINARY, S_IREAD)) == -1) return false; @@ -1045,8 +1047,8 @@ asm mov ds,ax void CA_Startup(void) { #ifdef PROFILE - unlink("PROFILE.TXT"); - profilehandle = open("PROFILE.TXT", O_CREAT | O_WRONLY | O_TEXT); + unlink("profile.16"); + profilehandle = open("profile.16", O_CREAT | O_WRONLY | O_TEXT); #endif /*++++ // MDM begin - (GAMERS EDGE) diff --git a/src/lib/16_ca.h b/src/lib/16_ca.h index 29030c6a..77809387 100644 --- a/src/lib/16_ca.h +++ b/src/lib/16_ca.h @@ -36,7 +36,8 @@ //#define AUDIOHEADERLINKED //#define NUMMAPS 39 -//#define MAPPLANES 3 +//#define MAPPLANES 3 +#define PROFILE //=========================================================================== diff --git a/src/lib/16_head.c b/src/lib/16_head.c index 6ad9bcc1..008c6544 100644 --- a/src/lib/16_head.c +++ b/src/lib/16_head.c @@ -22,12 +22,6 @@ #include "src/lib/16_head.h" -/* local function */ -void wait(clock_t wait); -void* AllocateLargestFreeBlock(size_t* Size); -size_t GetFreeSize(void); -long int filesize(FILE *fp); - /* Function: Wait ********************************************************** * * Parameters: wait - time in microseconds @@ -117,6 +111,69 @@ size_t GetFreeSize(void) return total; } +void far* AllocateLargestFarFreeBlock(size_t far* 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 GetFarFreeSize(void) +{ + size_t total = 0; + void far* pFirst = NULL; + void far* pLast = NULL; + for(;;) + { + size_t largest; + void far* p = AllocateLargestFarFreeBlock(&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; +} + long int filesize(FILE *fp) { diff --git a/src/lib/16_head.h b/src/lib/16_head.h index 9e00e49d..da071b73 100644 --- a/src/lib/16_head.h +++ b/src/lib/16_head.h @@ -151,12 +151,14 @@ extern int profilehandle,debughandle; typedef union REGPACK regs_t; typedef enum {false,true} boolean; +/* local function */ void wait(clock_t wait); void* AllocateLargestFreeBlock(size_t* Size); size_t GetFreeSize(void); +void far *AllocateLargestFarFreeBlock(size_t far* Size); +size_t GetFarFreeSize(void); long int filesize(FILE *fp); int US_CheckParm(char *parm,char **strings); -//void Quit(char *error, ...); extern void CA_OpenDebug (void); extern void CA_CloseDebug (void); diff --git a/src/lib/16_mm.c b/src/lib/16_mm.c index 7b0b8334..138a31b4 100644 --- a/src/lib/16_mm.c +++ b/src/lib/16_mm.c @@ -47,9 +47,9 @@ Open Watcom port by sparky4 */ #include "src/lib/16_mm.h" -#pragma hdrstop - -#pragma warn -pro +#pragma hdrstop + +#pragma warn -pro #pragma warn -use /* @@ -671,10 +671,10 @@ void MM_Startup(mminfo_t *mm, mminfotype *mmi) // // get all available near conventional memory segments // - printf(" nearheap making!\n"); //---- length=coreleft(); + printf(" nearheap making!\n"); _heapgrow(); - length=_memmax(); + length=_memmax();//(dword)GetFreeSize(); start = (void huge *)(mm->nearheap = malloc(length)); length -= 16-(FP_OFF(start)&15); length -= SAVENEARHEAP; @@ -682,21 +682,7 @@ void MM_Startup(mminfo_t *mm, mminfotype *mmi) segstart = FP_SEG(start)+(FP_OFF(start)+15)/16; MML_UseSpace(segstart,seglength, mm); mmi->nearheap = length; - printf("start=%Fp segstart=%x seglen=%lu len=%lu\n", start, segstart, seglength, length); - /*switch( _nheapchk() ) { - case _HEAPOK: - printf( "OK - nearheap is good\n" ); - break; - case _HEAPEMPTY: - printf( "OK - nearheap is empty\n" ); - break; - case _HEAPBADBEGIN: - printf( "ERROR - nearheap is damaged\n" ); - break; - case _HEAPBADNODE: - printf( "ERROR - bad node in nearheap\n" ); - break; - }*/ + printf("start=%FP segstart=%X seglen=%lu len=%lu\n", start, segstart, seglength, length); printf(" near heap ok!\n"); // @@ -705,37 +691,26 @@ void MM_Startup(mminfo_t *mm, mminfotype *mmi) //---- length=farcoreleft(); printf(" farheap making!\n"); _fheapgrow(); - length=0xffffUL*4UL; - start = mm->farheap = halloc(length, sizeof(byte)); - //start = mm->farheap = _fmalloc(length); + length=(dword)GetFarFreeSize();//0xffffUL*4UL; + //start = mm->farheap = halloc(length, 1); + start = mm->farheap = _fmalloc(length); length -= 16-(FP_OFF(start)&15); length -= SAVEFARHEAP; seglength = length / 16; // now in paragraphs segstart = FP_SEG(start)+(FP_OFF(start)+15)/16; MML_UseSpace(segstart,seglength, mm); mmi->farheap = length; - mmi->mainmem = mmi->nearheap + mmi->farheap; - printf("start=%Fp segstart=%x seglen=%lu len=%lu\n", start, segstart, seglength, length); - /*switch( _fheapchk() ) { - case _HEAPOK: - printf( "OK - farheap is good\n" ); - break; - case _HEAPEMPTY: - printf( "OK - farheap is empty\n" ); - break; - case _HEAPBADBEGIN: - printf( "ERROR - farheap is damaged\n" ); - break; - case _HEAPBADNODE: - printf( "ERROR - bad node in farheap\n" ); - break; - }*/ + printf("start=%FP segstart=%X seglen=%lu len=%lu\n", start, segstart, seglength, length); printf(" far heap ok!\n"); + mmi->mainmem = mmi->nearheap + mmi->farheap; + + getch(); + // // detect EMS and allocate up to 64K at page frame // -/*printf(" EMS1\n"); +printf(" EMS1\n"); 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! mmi->EMSmem = 0; for(i = 1;i < __argc;i++) @@ -764,7 +739,7 @@ printf(" EMS4\n"); // // detect XMS and get upper memory blocks // -emsskip: +emsskip:/* mmi->XMSmem = 0; for(i = 1;i < __argc;i++) { @@ -784,8 +759,8 @@ printf(" XMS!\n"); // xmsskip:*/ /*mmi->nearheap = 0; -mmi->farheap = 0;*/ -mmi->EMSmem = 0; +mmi->farheap = 0; +mmi->EMSmem = 0;*/ mmi->XMSmem = 0; mm->mmrover = mm->mmhead; // start looking for space after low block @@ -809,12 +784,8 @@ void MM_Shutdown(mminfo_t *mm) if(!(mm->mmstarted)) return; - _ffree(mm->farheap); - printf(" far freed\n"); - free(mm->nearheap); - printf(" near freed\n"); - //hfree(mm->hugeheap); - //printf("huge freed\n"); + _ffree(mm->farheap); printf(" far freed\n"); + free(mm->nearheap); printf(" near freed\n"); if(MML_CheckForEMS()){ MML_ShutdownEMS(mm); printf(" EMS freed\n"); } if(MML_CheckForXMS(mm)){ MML_ShutdownXMS(mm); printf(" XMS freed\n"); } } @@ -914,7 +885,10 @@ void MM_GetPtr(memptr *baseptr,dword size, mminfo_t *mm, mminfotype *mmi) } if (mm->bombonerror) + { printf(OUT_OF_MEM_MSG,(size-mmi->nearheap)); + exit(-5); + } else mm->mmerror = true; } @@ -1278,9 +1252,9 @@ void MM_DumpData(mminfo_t *mm) //++++free(mm->nearheap); - dumpfile = fopen ("mmdump.txt","w"); + dumpfile = fopen ("mmdump.16","w"); if (!dumpfile){ - printf("MM_DumpData: Couldn't open MMDUMP.TXT!\n"); + printf("MM_DumpData: Couldn't open MMDUMP.16!\n"); return; } @@ -1321,7 +1295,7 @@ void MM_DumpData(mminfo_t *mm) } while (lowest != 0xffff); fclose(dumpfile); - printf("MMDUMP.TXT created.\n"); + printf("MMDUMP.16 created.\n"); } //========================================================================== @@ -1351,8 +1325,8 @@ dword MM_UnusedMemory(mminfo_t *mm) scan = scan->next; } - return free*16l; -// return free; +// return free*16l; + return free; } //========================================================================== @@ -1384,8 +1358,8 @@ dword MM_TotalFree(mminfo_t *mm) scan = scan->next; } - return free*16l; -// return free; +// return free*16l; + return free; } //========================================================================== diff --git a/src/lib/16_mm.h b/src/lib/16_mm.h index 2a37f372..7de1ef21 100644 --- a/src/lib/16_mm.h +++ b/src/lib/16_mm.h @@ -37,7 +37,7 @@ #define SAVENEARHEAP 0//x200 // space to leave in data segment -#define SAVEFARHEAP 0//x2000 // space to leave in far heap +#define SAVEFARHEAP 0x400 // space to leave in far heap #define BUFFERSIZE 0x1000 // miscelanious, allways available buffer diff --git a/src/lib/16_pm.c b/src/lib/16_pm.c index 57c15aaa..bc9ba74c 100644 --- a/src/lib/16_pm.c +++ b/src/lib/16_pm.c @@ -4,7 +4,7 @@ // Primary coder: Jason Blochowiak // -#include "ID_HEADS.H" +#include "src/lib/16_pm.h" #pragma hdrstop // Main Mem specific variables @@ -56,15 +56,19 @@ static char *ParmStrings[] = {"nomain","noems","noxms",nil}; // void PML_MapEMS(word logical,word physical) -{ - _AL = physical; - _BX = logical; - _DX = EMSHandle; - _AH = EMS_MAPPAGE; -asm int EMS_INT +{ + union REGS CPURegs; + CPURegs.h.al = physical; + CPURegs.x.bx = logical; + CPURegs.x.dx = EMSHandle; + CPURegs.h.ah = EMS_MAPPAGE; + __asm + { + int EMS_INT + } - if (_AH) - Quit("PML_MapEMS: Page mapping failed"); + if(CPURegs.h.ah) + printf("PML_MapEMS: Page mapping failed\n"); } // @@ -177,7 +181,7 @@ PML_ShutdownEMS(void) asm mov dx,[EMSHandle] asm int EMS_INT if (_AH) - Quit ("PML_ShutdownEMS: Error freeing EMS"); + printf("PML_ShutdownEMS: Error freeing EMS\n"); } } @@ -243,7 +247,7 @@ error: void PML_XMSCopy(boolean toxms,byte far *addr,word xmspage,word length) { - longword xoffset; + dword xoffset; struct { longword length; @@ -254,7 +258,7 @@ PML_XMSCopy(boolean toxms,byte far *addr,word xmspage,word length) } copy; if (!addr) - Quit("PML_XMSCopy: zero address"); + printf("PML_XMSCopy: zero address\n"); xoffset = (longword)xmspage * PMPageSize; @@ -1171,8 +1175,11 @@ PM_Startup(void) if (!noxms) PML_StartupXMS(); - if (nomain && !EMSPresent) - Quit("PM_Startup: No main or EMS"); + if (nomain && !EMSPresent) + { + printf("PM_Startup: No main or EMS\n"); + return; + } else PML_StartupMainMem(); diff --git a/test.exe b/test.exe index e04c291d..60ad10da 100644 Binary files a/test.exe and b/test.exe differ diff --git a/test2.exe b/test2.exe index 77e009f2..4131aea0 100644 Binary files a/test2.exe and b/test2.exe differ diff --git a/tsthimem.exe b/tsthimem.exe index 24c25b02..465bcca1 100644 Binary files a/tsthimem.exe and b/tsthimem.exe differ