From: sparky4 Date: Tue, 27 Sep 2016 16:27:12 +0000 (-0500) Subject: ====PM WORKS! XMS PORTING IS NEXT!==== X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=42ffe9b467059d82fecbd350cbf000e6b1ddf1a9;p=16.git ====PM WORKS! XMS PORTING IS NEXT!==== --- diff --git a/DEBUG.16W b/DEBUG.16W index b3ed514b..d3ab7a60 100755 --- a/DEBUG.16W +++ b/DEBUG.16W @@ -1,12 +1,210 @@ -Seg:0 Size:8558 Owner:0x1 -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++0 -Seg:216e Size:256 Owner:0x5448 -+++++ -Seg:226e Size:273 Owner:0x94a0 +Seg:0 Size:9821 Owner:0x0 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++0 +Seg:265d Size:256 Owner:0x18a8 ++++ -Seg:27e0 Size:44 Owner:0x0 -++0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -Seg:b80c Size:10228 Owner:0x0 -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -Seg:e000 Size:8191 Owner:0x0 -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file +Seg:27d9 Size:53 Owner:0x0 +++ +Seg:280e Size:256 Owner:0x1696 +++++ +Seg:290e Size:256 Owner:0x1698 +++++ +Seg:2a0e Size:256 Owner:0x169a +++++ +Seg:2b0e Size:256 Owner:0x169c +++++ +Seg:2c0e Size:256 Owner:0x169e ++++++ +Seg:2d0e Size:256 Owner:0x16a0 +++++ +Seg:2e0e Size:256 Owner:0x16a2 +++++ +Seg:2f0e Size:256 Owner:0x16a4 +++++ +Seg:300e Size:256 Owner:0x16a6 +++++ +Seg:310e Size:256 Owner:0x16a8 ++++++ +Seg:320e Size:256 Owner:0x16aa +++++ +Seg:330e Size:256 Owner:0x16ac +++++ +Seg:340e Size:256 Owner:0x16ae +++++ +Seg:350e Size:256 Owner:0x16b0 +++++ +Seg:360e Size:256 Owner:0x16b2 ++++++ +Seg:370e Size:256 Owner:0x16b4 +++++ +Seg:380e Size:256 Owner:0x16b6 +++++ +Seg:390e Size:256 Owner:0x16b8 +++++ +Seg:3a0e Size:256 Owner:0x16ba +++++ +Seg:3b0e Size:256 Owner:0x16bc ++++++ +Seg:3c0e Size:256 Owner:0x16be +++++ +Seg:3d0e Size:256 Owner:0x16c0 +++++ +Seg:3e0e Size:256 Owner:0x16c2 +++++ +Seg:3f0e Size:256 Owner:0x16c4 +++++ +Seg:400e Size:256 Owner:0x16c6 ++++++ +Seg:410e Size:256 Owner:0x16c8 +++++ +Seg:420e Size:256 Owner:0x16ca +++++ +Seg:430e Size:256 Owner:0x16cc +++++ +Seg:440e Size:256 Owner:0x16ce +++++ +Seg:450e Size:256 Owner:0x16d0 ++++++ +Seg:460e Size:256 Owner:0x16d2 +++++ +Seg:470e Size:256 Owner:0x16d4 +++++ +Seg:480e Size:256 Owner:0x16d6 +++++ +Seg:490e Size:256 Owner:0x16d8 +++++ +Seg:4a0e Size:256 Owner:0x16da ++++++ +Seg:4b0e Size:256 Owner:0x16dc +++++ +Seg:4c0e Size:256 Owner:0x16de +++++ +Seg:4d0e Size:256 Owner:0x16e0 +++++ +Seg:4e0e Size:256 Owner:0x16e2 +++++ +Seg:4f0e Size:256 Owner:0x16e4 ++++++ +Seg:500e Size:256 Owner:0x16e6 +++++ +Seg:510e Size:256 Owner:0x16e8 +++++ +Seg:520e Size:256 Owner:0x16ea +++++ +Seg:530e Size:256 Owner:0x16ec +++++ +Seg:540e Size:256 Owner:0x16ee ++++++ +Seg:550e Size:256 Owner:0x16f0 +++++ +Seg:560e Size:256 Owner:0x16f2 +++++ +Seg:570e Size:256 Owner:0x16f4 +++++ +Seg:580e Size:256 Owner:0x16f6 +++++ +Seg:590e Size:256 Owner:0x16f8 ++++++ +Seg:5a0e Size:256 Owner:0x16fa +++++ +Seg:5b0e Size:256 Owner:0x16fc +++++ +Seg:5c0e Size:256 Owner:0x16fe +++++ +Seg:5d0e Size:256 Owner:0x1700 +++++ +Seg:5e0e Size:256 Owner:0x1702 ++++++ +Seg:5f0e Size:256 Owner:0x1704 +++++ +Seg:600e Size:256 Owner:0x1706 +++++ +Seg:610e Size:256 Owner:0x1708 +++++ +Seg:620e Size:256 Owner:0x170a +++++ +Seg:630e Size:256 Owner:0x170c ++++++ +Seg:640e Size:256 Owner:0x170e +++++ +Seg:650e Size:256 Owner:0x1710 +++++ +Seg:660e Size:256 Owner:0x1712 +++++ +Seg:670e Size:256 Owner:0x1714 +++++ +Seg:680e Size:256 Owner:0x1716 ++++++ +Seg:690e Size:256 Owner:0x1718 +++++ +Seg:6a0e Size:256 Owner:0x171a +++++ +Seg:6b0e Size:256 Owner:0x171c +++++ +Seg:6c0e Size:256 Owner:0x171e +++++ +Seg:6d0e Size:256 Owner:0x1720 ++++++ +Seg:6e0e Size:256 Owner:0x1722 +++++ +Seg:6f0e Size:256 Owner:0x1724 +++++ +Seg:700e Size:256 Owner:0x1726 +++++ +Seg:710e Size:256 Owner:0x1728 +++++ +Seg:720e Size:256 Owner:0x172a ++++++ +Seg:730e Size:256 Owner:0x172c +++++ +Seg:740e Size:256 Owner:0x172e +++++ +Seg:750e Size:256 Owner:0x1730 +++++ +Seg:760e Size:256 Owner:0x1732 +++++ +Seg:770e Size:256 Owner:0x1734 ++++++ +Seg:780e Size:256 Owner:0x1736 +++++ +Seg:790e Size:256 Owner:0x1738 +++++ +Seg:7a0e Size:256 Owner:0x173a +++++ +Seg:7b0e Size:256 Owner:0x173c +++++ +Seg:7c0e Size:256 Owner:0x173e ++++++ +Seg:7d0e Size:256 Owner:0x1740 +++++ +Seg:7e0e Size:256 Owner:0x1742 +++++ +Seg:7f0e Size:256 Owner:0x1744 +++++ +Seg:800e Size:256 Owner:0x1746 +++++ +Seg:810e Size:256 Owner:0x1748 ++++++ +Seg:820e Size:256 Owner:0x174a +++++ +Seg:830e Size:256 Owner:0x174c +++++ +Seg:840e Size:256 Owner:0x174e +++++ +Seg:850e Size:256 Owner:0x1750 +++++ +Seg:860e Size:256 Owner:0x1752 ++++++ +Seg:870e Size:256 Owner:0x1754 +++++ +Seg:880e Size:256 Owner:0x1756 +++++ +Seg:890e Size:256 Owner:0x1758 +++++ +Seg:8a0e Size:256 Owner:0x175a +++++ +Seg:8b0e Size:256 Owner:0x175c ++++++ +Seg:8c0e Size:273 Owner:0xe400 +++++ +Seg:b80e Size:18417 Owner:0x0 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file diff --git a/HEAP.16W b/HEAP.16W index 2b94206e..b777259b 100755 --- a/HEAP.16W +++ b/HEAP.16W @@ -1,47 +1,47 @@ == default == - USED block at 28020016 of size 66 - USED block at 28020058 of size 66 - FREE block at 2802009a of size 18 - USED block at 280200ac of size 136 - USED block at 28020134 of size 20 - FREE block at 28020148 of size 7860 + USED block at 27fb0016 of size 66 + USED block at 27fb0058 of size 66 + USED block at 27fb009a of size 136 + FREE block at 27fb0122 of size 18 + USED block at 27fb0134 of size 20 + FREE block at 27fb0148 of size 7860 OK - end of heap == near == - USED block at 180194d6 of size 12 - USED block at 180194e2 of size 332 - USED block at 1801962e of size 52 - USED block at 18019662 of size 20 - USED block at 18019676 of size 20 - USED block at 1801968a of size 20 - USED block at 1801969e of size 20 - USED block at 180196b2 of size 20 - USED block at 180196c6 of size 26934 + USED block at 17fae436 of size 12 + USED block at 17fae442 of size 332 + USED block at 17fae58e of size 52 + USED block at 17fae5c2 of size 20 + USED block at 17fae5d6 of size 20 + USED block at 17fae5ea of size 20 + USED block at 17fae5fe of size 20 + USED block at 17fae612 of size 20 + USED block at 17fae626 of size 6614 OK - end of heap == far == - USED block at 28020016 of size 66 - USED block at 28020058 of size 66 - USED block at 2802009a of size 18 - USED block at 280200ac of size 136 - USED block at 28020134 of size 20 - USED block at 28020148 of size 7860 + USED block at 27fb0016 of size 66 + USED block at 27fb0058 of size 66 + USED block at 27fb009a of size 136 + USED block at 27fb0122 of size 18 + USED block at 27fb0134 of size 20 + USED block at 27fb0148 of size 7860 OK - end of heap Memory Type Total Used Free ---------------- -------- -------- -------- Default 8166 288 7878 -Near 27430 496 26934 -Far 8166 288 7878 +Near 7110 496 6614 +Far 8166 0 7878 ---------------- -------- -------- -------- -coreleft = 26932 -farcoreleft = 51040 +coreleft = 6612 +farcoreleft = 30720 GetFreeSize = 24128 -GetNearFreeSize = 26934 +GetNearFreeSize = 6614 GetFarFreeSize = 24128 -memavl = 26932 -stackavail = 11268 +memavl = 6612 +stackavail = 31588 diff --git a/MMDUMP.16W b/MMDUMP.16W index 2f5e7ecf..cb01f5be 100755 Binary files a/MMDUMP.16W and b/MMDUMP.16W differ diff --git a/src/exmmtest.c b/src/exmmtest.c index 905bdc15..b57a6f05 100755 --- a/src/exmmtest.c +++ b/src/exmmtest.c @@ -67,7 +67,7 @@ void main(int argc, char *argv[]) { byte w=1; - global_game_variables_t gvar; + static global_game_variables_t gvar; #ifdef __WATCOMC__ __segment sega; #endif @@ -86,7 +86,7 @@ main(int argc, char *argv[]) //file name // gvar.mm.mmstarted=0; - debugpm=1; + debugpm=1; //debug pm //PRINTBB if(argv[1]){ bakapee1 = argv[1]; @@ -96,11 +96,13 @@ main(int argc, char *argv[]) bakapee1 = "data/koishi~.pcx"; bakapee2 = "data/test.map"; } - //printf("main()=%Fp start MM\n", *argv[0]); + printf("main()=%Fp start MM\n", *argv[0]); MM_Startup(&gvar); + printf("ok\n"); if(debugpm>0) { PM_Startup(&gvar); + printf("pmstarted ok\n"); //PM_CheckMainMem(&gvar); PM_UnlockMainMem(&gvar); } diff --git a/src/lib/16_head.h b/src/lib/16_head.h index 2d080d52..aab4c033 100755 --- a/src/lib/16_head.h +++ b/src/lib/16_head.h @@ -152,7 +152,7 @@ static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ extern int profilehandle,debughandle; //make it into game global #define __DEBUG__ -#define __DEBUG_PM__ +//#define __DEBUG_PM__ //#define __DEBUG_MM__ #define nil ((void *)0) diff --git a/src/lib/16_lib.c b/src/lib/16_lib.c index 57a06217..12a4288b 100755 --- a/src/lib/16_lib.c +++ b/src/lib/16_lib.c @@ -88,7 +88,7 @@ void Quit (char *error) if (error && *error) { - movedata ((unsigned)screen,7,0xb800,0,7*160); + //movedata ((unsigned)screen,7,0xb800,0,7*160); //gotoxy (10,4); fprintf(stderr, "%s\n", error); //gotoxy (1,8); diff --git a/src/lib/16_mm.c b/src/lib/16_mm.c index 859a5b4a..8d93438a 100755 --- a/src/lib/16_mm.c +++ b/src/lib/16_mm.c @@ -836,9 +836,8 @@ void MM_Startup(global_game_variables_t *gvar) gvar->mmi.mainmem = gvar->mmi.nearheap + gvar->mmi.farheap; -#ifdef __DEBUG__ +#ifndef __16_PM__ if(!debugpm) { -#endif // // detect EMS and allocate up to 64K at page frame // @@ -903,7 +902,7 @@ goto xmsskip;//0000 { MML_SetupXMS(gvar); // allocate as many UMBs as possible } -#ifdef __DEBUG__ + } #endif // @@ -1619,9 +1618,9 @@ void MM_Report_(global_game_variables_t *gvar) if(MML_CheckForEMS()) { printf(" LIMEMS\n"); - printf(" EMM v%x.%x available\n", gvar->mm.EMSVer>>4,gvar->mm.EMSVer&0x0F); - printf(" totalEMSpages: %u ", gvar->mm.totalEMSpages); printf("freeEMSpages: %u\n", gvar->mm.freeEMSpages); - printf(" EMSPageFrame: %x\n", gvar->mm.EMSPageFrame); + printf(" EMM v%x.%x available\n", gvar->pm.emm.EMSVer>>4,gvar->pm.emm.EMSVer&0x0F); + printf(" totalEMSpages: %u ", gvar->pm.emm.totalEMSpages); printf("freeEMSpages: %u\n", gvar->pm.emm.freeEMSpages); + printf(" EMSPageFrame: %x\n", gvar->pm.emm.EMSPageFrame); } if(MML_CheckForXMS(gvar)) { @@ -1629,7 +1628,7 @@ void MM_Report_(global_game_variables_t *gvar) printf(" XMSaddr: %X\n", *XMSaddr); } printf("near: %lu ", gvar->mmi.nearheap); printf("far: %lu\n", gvar->mmi.farheap); if(MML_CheckForEMS()) - printf("EMSmem: %lu ", gvar->mmi.EMSmem); if(MML_CheckForXMS(gvar)) printf("XMSmem: %lu", gvar->mmi.XMSmem); printf("\n"); + printf("EMSmem: %lu ", gvar->pm.emm.EMSAvail/*gvar->mmi.EMSmem*/); if(MML_CheckForXMS(gvar)) printf("XMSmem: %lu", gvar->mmi.XMSmem); printf("\n"); //printf("mainmem: %lu\n", gvar->mmi.mainmem); printf("Total convmem: %lu ", gvar->mmi.mainmem); printf("TotalFree: %lu ", MM_TotalFree(gvar)); printf("TotalUsed: %lu\n", gvar->mmi.mainmem+gvar->mmi.EMSmem+gvar->mmi.XMSmem+gvar->mmi.XMSmem); printf(" UnusedMemory: %lu\n", MM_UnusedMemory(gvar)); diff --git a/src/lib/16_pm.c b/src/lib/16_pm.c index 22cd7ea5..ef2d6d5a 100755 --- a/src/lib/16_pm.c +++ b/src/lib/16_pm.c @@ -34,20 +34,20 @@ boolean debugpm=0; #endif // Main Mem specific variables -/* boolean MainPresent; - memptr MainMemPages[PMMaxMainMem]; + boolean MainPresent; +/* memptr MainMemPages[PMMaxMainMem]; PMBlockAttr gvar->pm.mm.MainMemUsed[PMMaxMainMem]; - int gvar->pm.mm.MainPagesAvail; + int gvar->pm.mm.MainPagesAvail;*/ // EMS specific variables boolean EMSPresent; - word gvar->pm.emm.EMSAvail,gvar->pm.emm.EMSPagesAvail,gvar->pm.emm.EMSHandle, +/* word gvar->pm.emm.EMSAvail,gvar->pm.emm.EMSPagesAvail,gvar->pm.emm.EMSHandle, gvar->pm.emm.EMSPageFrame,gvar->pm.emm.EMSPhysicalPage; - gvar->pm.emm.EMSListStruct gvar->pm.emm.EMSList[EMSFrameCount]; + gvar->pm.emm.EMSListStruct gvar->pm.emm.EMSList[EMSFrameCount];*/ // XMS specific variables boolean XMSPresent; - word gvar->pm.xmm.XMSAvail,gvar->pm.xmm.XMSPagesAvail,gvar->pm.xmm.XMSHandle;*/ + //word gvar->pm.xmm.XMSAvail,gvar->pm.xmm.XMSPagesAvail,gvar->pm.xmm.XMSHandle; word XMSDriver; /* int gvar->pm.xmm.XMSProtectPage = -1; @@ -55,10 +55,10 @@ boolean debugpm=0; char gvar->pm.fi.PageFileName[13] = {"VSWAP."}; int PageFile = -1; word gvar->pm.fi.ChunksInFile; - word PMSpriteStart,PMSoundStart; + word PMSpriteStart,PMSoundStart;*/ // General usage variables - boolean PMStarted, + boolean PMStarted;/*, gvar->pm.PMPanicMode, gvar->pm.PMThrashing; word gvar->pm.XMSPagesUsed, @@ -67,9 +67,8 @@ boolean debugpm=0; gvar->pm.PMNumBlocks; long PMFrameCount; PageListStruct far *gvar->pm.PMPages, - _seg *gvar->pm.PMSegPages; -*/ -boolean PMStarted, MainPresent, EMSPresent, XMSPresent; + _seg *gvar->pm.PMSegPages;*/ + static char *ParmStrings[] = {"nomain","noems","noxms",nil}; ///////////////////////////////////////////////////////////////////////////// @@ -141,7 +140,7 @@ PML_StartupEMS(global_game_variables_t *gvar) { int i; long size; - byte str[160]; + byte str[64]; byte err; boolean errorflag=0; @@ -226,6 +225,7 @@ End1: #ifdef __WATCOMC__ } #endif +/* if(errorflag==false) { // Don't hog all available EMS @@ -236,7 +236,7 @@ End1: gvar->pm.emm.EMSAvail = size / EMSPageSize; } } - +*/ __asm { mov ah,EMS_ALLOCPAGES mov bx,[EMSAvail]; @@ -285,6 +285,8 @@ End2: gvar->pm.emm.EMSAvail = EMSAvail; gvar->pm.emm.EMSVer = EMSVer; gvar->pm.emm.EMSHandle = EMSHandle; + gvar->pm.emm.freeEMSpages = freeEMSpages; + gvar->pm.emm.totalEMSpages = totalEMSpages; return(EMSPresent); } @@ -296,6 +298,10 @@ void PML_ShutdownEMS(global_game_variables_t *gvar) { word EMSHandle; + byte err; + byte str[64]; + boolean errorflag=false; + EMSHandle=gvar->pm.emm.EMSHandle; if (EMSPresent) @@ -304,9 +310,30 @@ PML_ShutdownEMS(global_game_variables_t *gvar) mov ah,EMS_FREEPAGES mov dx,[EMSHandle] int EMS_INT + jc errors + jmp Ends +#ifdef __BORLANDC__ + } +#endif + errors: +#ifdef __BORLANDC__ + __asm { +#endif + mov err,ah + mov errorflag,1 + jmp Ends +#ifdef __BORLANDC__ } - if (_AH) +#endif + Ends: +#ifdef __WATCOMC__ + } +#endif + if(errorflag==true) { + strcpy(str,"PML_ShutdownEMS: Error freeing EMS "); + MM_EMSerr(str, err); + printf("%s\n",str); Quit("PML_ShutdownEMS: Error freeing EMS\n"); //return; } @@ -480,11 +507,7 @@ PM_SetMainMemPurge(int level, global_game_variables_t *gvar) { #ifdef __DEBUG_PM__ printf("PM_SetMainMemPurge() info of gvar->pm.mm.MainMemPages[i]\n"); - //printf(" %Fp, %Fp\n", gvar->pm.mm.MainMemPages[i], (gvar->pm.mm.MainMemPages[i])); printf("& %Fp, %Fp\n", &gvar->pm.mm.MainMemPages[i], &(gvar->pm.mm.MainMemPages[i])); - //MM_ShowMemory(gvar); - //MM_DumpData(gvar); - //MM_Report_(gvar); #endif if (gvar->pm.mm.MainMemPages[i]) MM_SetPurge(&(gvar->pm.mm.MainMemPages[i]),level, gvar); @@ -492,9 +515,7 @@ PM_SetMainMemPurge(int level, global_game_variables_t *gvar) else { - printf("MainPresent IS NULL\n"); - printf("%x ", MainPresent); - exit(-4); + Quit("MainPresent IS NULL\n"); } } @@ -679,10 +700,7 @@ PML_OpenPageFile(global_game_variables_t *gvar) gvar->pm.fi.PageFile = open(gvar->pm.fi.PageFileName,O_RDONLY + O_BINARY); if (gvar->pm.fi.PageFile == -1) { - //Quit("PML_OpenPageFile: Unable to open page file"); - printf("PML_OpenPageFile: Unable to open page file"); - printf(": %s\n", gvar->pm.fi.PageFileName); - exit(-1); + Quit("PML_OpenPageFile: Unable to open page file"); //return; } @@ -1383,19 +1401,18 @@ PM_Startup(global_game_variables_t *gvar) } } - PML_OpenPageFile(gvar); + //0000++++PML_OpenPageFile(gvar); if (!noems) PML_StartupEMS(gvar); if (!noxms) - PML_StartupXMS(gvar); + //++++PML_StartupXMS(gvar); //TODO: convert - if (nomain && !EMSPresent) + if (!nomain && !EMSPresent) { Quit("PM_Startup: No main or EMS\n"); //return; } - printf("PML_StartupMainMem\n"); PML_StartupMainMem(gvar); PM_Reset(gvar);