From: sparky4 Date: Thu, 29 Sep 2016 15:50:20 +0000 (-0500) Subject: xms still being worked on X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=149a7c8a35cbf5f9eb19793b4c923ad1017ec426;p=16.git xms still being worked on --- diff --git a/DEBUG.16W b/DEBUG.16W index 6bbbce7f..66a0f5a3 100755 --- a/DEBUG.16W +++ b/DEBUG.16W @@ -1,210 +1,210 @@ -Seg:0 Size:9834 Owner:0x0 -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++0 -Seg:266a Size:256 Owner:0x18a8 -+++++ -Seg:27e6 Size:44 Owner:0x0 +Seg:0 Size:9845 Owner:0x0 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++0 +Seg:2675 Size:256 Owner:0x18a8 +++++ +Seg:27f1 Size:44 Owner:0x0 ++ -Seg:2812 Size:256 Owner:0x1696 +Seg:281d Size:256 Owner:0x1696 ++++ -Seg:2912 Size:256 Owner:0x1698 +Seg:291d Size:256 Owner:0x1698 ++++ -Seg:2a12 Size:256 Owner:0x169a +Seg:2a1d Size:256 Owner:0x169a ++++ -Seg:2b12 Size:256 Owner:0x169c +Seg:2b1d Size:256 Owner:0x169c +++++ -Seg:2c12 Size:256 Owner:0x169e +Seg:2c1d Size:256 Owner:0x169e ++++ -Seg:2d12 Size:256 Owner:0x16a0 +Seg:2d1d Size:256 Owner:0x16a0 ++++ -Seg:2e12 Size:256 Owner:0x16a2 +Seg:2e1d Size:256 Owner:0x16a2 ++++ -Seg:2f12 Size:256 Owner:0x16a4 +Seg:2f1d Size:256 Owner:0x16a4 ++++ -Seg:3012 Size:256 Owner:0x16a6 +Seg:301d Size:256 Owner:0x16a6 +++++ -Seg:3112 Size:256 Owner:0x16a8 +Seg:311d Size:256 Owner:0x16a8 ++++ -Seg:3212 Size:256 Owner:0x16aa +Seg:321d Size:256 Owner:0x16aa ++++ -Seg:3312 Size:256 Owner:0x16ac +Seg:331d Size:256 Owner:0x16ac ++++ -Seg:3412 Size:256 Owner:0x16ae +Seg:341d Size:256 Owner:0x16ae ++++ -Seg:3512 Size:256 Owner:0x16b0 +Seg:351d Size:256 Owner:0x16b0 +++++ -Seg:3612 Size:256 Owner:0x16b2 +Seg:361d Size:256 Owner:0x16b2 ++++ -Seg:3712 Size:256 Owner:0x16b4 +Seg:371d Size:256 Owner:0x16b4 ++++ -Seg:3812 Size:256 Owner:0x16b6 +Seg:381d Size:256 Owner:0x16b6 ++++ -Seg:3912 Size:256 Owner:0x16b8 +Seg:391d Size:256 Owner:0x16b8 ++++ -Seg:3a12 Size:256 Owner:0x16ba +Seg:3a1d Size:256 Owner:0x16ba +++++ -Seg:3b12 Size:256 Owner:0x16bc +Seg:3b1d Size:256 Owner:0x16bc ++++ -Seg:3c12 Size:256 Owner:0x16be +Seg:3c1d Size:256 Owner:0x16be ++++ -Seg:3d12 Size:256 Owner:0x16c0 +Seg:3d1d Size:256 Owner:0x16c0 ++++ -Seg:3e12 Size:256 Owner:0x16c2 +Seg:3e1d Size:256 Owner:0x16c2 ++++ -Seg:3f12 Size:256 Owner:0x16c4 +Seg:3f1d Size:256 Owner:0x16c4 +++++ -Seg:4012 Size:256 Owner:0x16c6 +Seg:401d Size:256 Owner:0x16c6 ++++ -Seg:4112 Size:256 Owner:0x16c8 +Seg:411d Size:256 Owner:0x16c8 ++++ -Seg:4212 Size:256 Owner:0x16ca +Seg:421d Size:256 Owner:0x16ca ++++ -Seg:4312 Size:256 Owner:0x16cc +Seg:431d Size:256 Owner:0x16cc ++++ -Seg:4412 Size:256 Owner:0x16ce +Seg:441d Size:256 Owner:0x16ce +++++ -Seg:4512 Size:256 Owner:0x16d0 +Seg:451d Size:256 Owner:0x16d0 ++++ -Seg:4612 Size:256 Owner:0x16d2 +Seg:461d Size:256 Owner:0x16d2 ++++ -Seg:4712 Size:256 Owner:0x16d4 +Seg:471d Size:256 Owner:0x16d4 ++++ -Seg:4812 Size:256 Owner:0x16d6 +Seg:481d Size:256 Owner:0x16d6 ++++ -Seg:4912 Size:256 Owner:0x16d8 +Seg:491d Size:256 Owner:0x16d8 +++++ -Seg:4a12 Size:256 Owner:0x16da +Seg:4a1d Size:256 Owner:0x16da ++++ -Seg:4b12 Size:256 Owner:0x16dc +Seg:4b1d Size:256 Owner:0x16dc ++++ -Seg:4c12 Size:256 Owner:0x16de +Seg:4c1d Size:256 Owner:0x16de ++++ -Seg:4d12 Size:256 Owner:0x16e0 +Seg:4d1d Size:256 Owner:0x16e0 ++++ -Seg:4e12 Size:256 Owner:0x16e2 +Seg:4e1d Size:256 Owner:0x16e2 +++++ -Seg:4f12 Size:256 Owner:0x16e4 +Seg:4f1d Size:256 Owner:0x16e4 ++++ -Seg:5012 Size:256 Owner:0x16e6 +Seg:501d Size:256 Owner:0x16e6 ++++ -Seg:5112 Size:256 Owner:0x16e8 +Seg:511d Size:256 Owner:0x16e8 ++++ -Seg:5212 Size:256 Owner:0x16ea +Seg:521d Size:256 Owner:0x16ea ++++ -Seg:5312 Size:256 Owner:0x16ec +Seg:531d Size:256 Owner:0x16ec +++++ -Seg:5412 Size:256 Owner:0x16ee +Seg:541d Size:256 Owner:0x16ee ++++ -Seg:5512 Size:256 Owner:0x16f0 +Seg:551d Size:256 Owner:0x16f0 ++++ -Seg:5612 Size:256 Owner:0x16f2 +Seg:561d Size:256 Owner:0x16f2 ++++ -Seg:5712 Size:256 Owner:0x16f4 +Seg:571d Size:256 Owner:0x16f4 ++++ -Seg:5812 Size:256 Owner:0x16f6 +Seg:581d Size:256 Owner:0x16f6 +++++ -Seg:5912 Size:256 Owner:0x16f8 +Seg:591d Size:256 Owner:0x16f8 ++++ -Seg:5a12 Size:256 Owner:0x16fa +Seg:5a1d Size:256 Owner:0x16fa ++++ -Seg:5b12 Size:256 Owner:0x16fc +Seg:5b1d Size:256 Owner:0x16fc ++++ -Seg:5c12 Size:256 Owner:0x16fe +Seg:5c1d Size:256 Owner:0x16fe ++++ -Seg:5d12 Size:256 Owner:0x1700 +Seg:5d1d Size:256 Owner:0x1700 +++++ -Seg:5e12 Size:256 Owner:0x1702 +Seg:5e1d Size:256 Owner:0x1702 ++++ -Seg:5f12 Size:256 Owner:0x1704 +Seg:5f1d Size:256 Owner:0x1704 ++++ -Seg:6012 Size:256 Owner:0x1706 +Seg:601d Size:256 Owner:0x1706 ++++ -Seg:6112 Size:256 Owner:0x1708 +Seg:611d Size:256 Owner:0x1708 ++++ -Seg:6212 Size:256 Owner:0x170a +Seg:621d Size:256 Owner:0x170a +++++ -Seg:6312 Size:256 Owner:0x170c +Seg:631d Size:256 Owner:0x170c ++++ -Seg:6412 Size:256 Owner:0x170e +Seg:641d Size:256 Owner:0x170e ++++ -Seg:6512 Size:256 Owner:0x1710 +Seg:651d Size:256 Owner:0x1710 ++++ -Seg:6612 Size:256 Owner:0x1712 +Seg:661d Size:256 Owner:0x1712 ++++ -Seg:6712 Size:256 Owner:0x1714 +Seg:671d Size:256 Owner:0x1714 +++++ -Seg:6812 Size:256 Owner:0x1716 +Seg:681d Size:256 Owner:0x1716 ++++ -Seg:6912 Size:256 Owner:0x1718 +Seg:691d Size:256 Owner:0x1718 ++++ -Seg:6a12 Size:256 Owner:0x171a +Seg:6a1d Size:256 Owner:0x171a ++++ -Seg:6b12 Size:256 Owner:0x171c +Seg:6b1d Size:256 Owner:0x171c ++++ -Seg:6c12 Size:256 Owner:0x171e +Seg:6c1d Size:256 Owner:0x171e +++++ -Seg:6d12 Size:256 Owner:0x1720 +Seg:6d1d Size:256 Owner:0x1720 ++++ -Seg:6e12 Size:256 Owner:0x1722 +Seg:6e1d Size:256 Owner:0x1722 ++++ -Seg:6f12 Size:256 Owner:0x1724 +Seg:6f1d Size:256 Owner:0x1724 ++++ -Seg:7012 Size:256 Owner:0x1726 +Seg:701d Size:256 Owner:0x1726 ++++ -Seg:7112 Size:256 Owner:0x1728 +Seg:711d Size:256 Owner:0x1728 +++++ -Seg:7212 Size:256 Owner:0x172a +Seg:721d Size:256 Owner:0x172a ++++ -Seg:7312 Size:256 Owner:0x172c +Seg:731d Size:256 Owner:0x172c ++++ -Seg:7412 Size:256 Owner:0x172e +Seg:741d Size:256 Owner:0x172e ++++ -Seg:7512 Size:256 Owner:0x1730 +Seg:751d Size:256 Owner:0x1730 ++++ -Seg:7612 Size:256 Owner:0x1732 +Seg:761d Size:256 Owner:0x1732 +++++ -Seg:7712 Size:256 Owner:0x1734 +Seg:771d Size:256 Owner:0x1734 ++++ -Seg:7812 Size:256 Owner:0x1736 +Seg:781d Size:256 Owner:0x1736 ++++ -Seg:7912 Size:256 Owner:0x1738 +Seg:791d Size:256 Owner:0x1738 ++++ -Seg:7a12 Size:256 Owner:0x173a +Seg:7a1d Size:256 Owner:0x173a ++++ -Seg:7b12 Size:256 Owner:0x173c +Seg:7b1d Size:256 Owner:0x173c +++++ -Seg:7c12 Size:256 Owner:0x173e +Seg:7c1d Size:256 Owner:0x173e ++++ -Seg:7d12 Size:256 Owner:0x1740 +Seg:7d1d Size:256 Owner:0x1740 ++++ -Seg:7e12 Size:256 Owner:0x1742 +Seg:7e1d Size:256 Owner:0x1742 ++++ -Seg:7f12 Size:256 Owner:0x1744 +Seg:7f1d Size:256 Owner:0x1744 ++++ -Seg:8012 Size:256 Owner:0x1746 +Seg:801d Size:256 Owner:0x1746 +++++ -Seg:8112 Size:256 Owner:0x1748 +Seg:811d Size:256 Owner:0x1748 ++++ -Seg:8212 Size:256 Owner:0x174a +Seg:821d Size:256 Owner:0x174a ++++ -Seg:8312 Size:256 Owner:0x174c +Seg:831d Size:256 Owner:0x174c ++++ -Seg:8412 Size:256 Owner:0x174e +Seg:841d Size:256 Owner:0x174e ++++ -Seg:8512 Size:256 Owner:0x1750 +Seg:851d Size:256 Owner:0x1750 +++++ -Seg:8612 Size:256 Owner:0x1752 +Seg:861d Size:256 Owner:0x1752 ++++ -Seg:8712 Size:256 Owner:0x1754 +Seg:871d Size:256 Owner:0x1754 ++++ -Seg:8812 Size:256 Owner:0x1756 +Seg:881d Size:256 Owner:0x1756 ++++ -Seg:8912 Size:256 Owner:0x1758 +Seg:891d Size:256 Owner:0x1758 ++++ -Seg:8a12 Size:256 Owner:0x175a +Seg:8a1d Size:256 Owner:0x175a +++++ -Seg:8b12 Size:256 Owner:0x175c +Seg:8b1d Size:256 Owner:0x175c ++++ -Seg:8c12 Size:273 Owner:0xe400 +Seg:8c1d Size:273 Owner:0xe400 ++++ -Seg:b812 Size:18413 Owner:0x0 +Seg:b81d Size:18402 Owner:0x0 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file diff --git a/HEAP.16W b/HEAP.16W index bb4671ba..c61787ab 100755 --- a/HEAP.16W +++ b/HEAP.16W @@ -1,35 +1,35 @@ == default == - USED block at 28080016 of size 66 - USED block at 28080058 of size 66 - FREE block at 2808009a of size 18 - USED block at 280800ac of size 136 - USED block at 28080134 of size 20 - FREE block at 28080148 of size 7860 + USED block at 28130016 of size 66 + USED block at 28130058 of size 66 + FREE block at 2813009a of size 18 + USED block at 281300ac of size 136 + USED block at 28130134 of size 20 + FREE block at 28130148 of size 7860 OK - end of heap == near == - USED block at 1807e436 of size 12 - USED block at 1807e442 of size 332 - USED block at 1807e58e of size 52 - USED block at 1807e5c2 of size 20 - USED block at 1807e5d6 of size 20 - USED block at 1807e5ea of size 20 - USED block at 1807e5fe of size 20 - USED block at 1807e612 of size 20 - USED block at 1807e626 of size 6614 + USED block at 1812e436 of size 12 + USED block at 1812e442 of size 332 + USED block at 1812e58e of size 52 + USED block at 1812e5c2 of size 20 + USED block at 1812e5d6 of size 20 + USED block at 1812e5ea of size 20 + USED block at 1812e5fe of size 20 + USED block at 1812e612 of size 20 + USED block at 1812e626 of size 6614 OK - end of heap == far == - USED block at 28080016 of size 66 - USED block at 28080058 of size 66 - USED block at 2808009a of size 18 - USED block at 280800ac of size 136 - USED block at 28080134 of size 20 - USED block at 28080148 of size 7860 + USED block at 28130016 of size 66 + USED block at 28130058 of size 66 + USED block at 2813009a of size 18 + USED block at 281300ac of size 136 + USED block at 28130134 of size 20 + USED block at 28130148 of size 7860 OK - end of heap Memory Type Total Used Free diff --git a/src/exmmtest.c b/src/exmmtest.c index 47a13ea4..26bfc964 100755 --- a/src/exmmtest.c +++ b/src/exmmtest.c @@ -23,11 +23,11 @@ exmm test */ #include "src/lib/16_head.h" +#include "src/lib/16_tail.h" #include "src/lib/16_pm.h" #include "src/lib/16_ca.h" #include "src/lib/16_mm.h" #include "src/lib/16_hc.h" -#include "src/lib/16_tail.h" //#include "src/lib/modex16.h" #pragma hdrstop diff --git a/src/lib/16_mm.c b/src/lib/16_mm.c index a8c07017..c8cb9251 100755 --- a/src/lib/16_mm.c +++ b/src/lib/16_mm.c @@ -437,10 +437,9 @@ byte MM_MapXEMS(global_game_variables_t *gvar) ======================= */ -boolean MML_CheckForXMS(global_game_variables_t *gvar) +boolean MML_CheckForXMS(void) { boolean errorflag=false; - gvar->mm.numUMBs = 0; __asm { mov ax,0x4300 @@ -898,7 +897,7 @@ goto xmsskip;//0000 ,ParmStringsexmm) == 0) goto xmsskip; // param NOXMS } - if(MML_CheckForXMS(gvar)) + if(MML_CheckForXMS()) { MML_SetupXMS(gvar); // allocate as many UMBs as possible } @@ -942,7 +941,7 @@ void MM_Shutdown(global_game_variables_t *gvar) if(!dbg_debugpm) { #endif if(MML_CheckForEMS()){ MML_ShutdownEMS(gvar); }//printf(" EMS freed\n"); } - if(MML_CheckForXMS(gvar)){ MML_ShutdownXMS(gvar); }//printf(" XMS freed\n"); } + if(MML_CheckForXMS()){ MML_ShutdownXMS(gvar); }//printf(" XMS freed\n"); } #ifdef __DEBUG__ } #endif @@ -1622,13 +1621,13 @@ void MM_Report_(global_game_variables_t *gvar) 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)) + if(MML_CheckForXMS()) { printf(" XMS\n"); - printf(" XMSDriver: %X\n", XMSDriver); + printf(" XMSDriver: %X\n", gvar->pm.xmm.XMSDriver); } printf("nearheap: %lu ", gvar->mmi.nearheap); printf("farheap: %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"); + if(MML_CheckForEMS()) printf("EMSmem: %lu ", gvar->mmi.EMSmem); if(MML_CheckForXMS()) printf("XMSmem: %lu", gvar->mmi.XMSmem); printf("\n"); printf("convmem:\n"); DebugMemory_(gvar, 0); //printf("mainmem: %lu\n", gvar->mmi.mainmem); //printf("Total convmem: %lu ", gvar->mmi.mainmem); printf("TotalFree: %lu ", MM_TotalFree(gvar)+gvar->mmi.EMSmem+gvar->mmi.XMSmem+gvar->mmi.XMSmem); printf("TotalUsed: %lu\n", gvar->mmi.mainmem); @@ -1803,6 +1802,15 @@ void MM_FreeBlock(mmblocktype *x, global_game_variables_t *gvar) gvar->mm.mmfree=x; }*/ +void xms_call(byte v, global_game_variables_t *gvar) +{ + dword XMSDriver = gvar->pm.xmm.XMSDriver; + __asm { + mov ah,[v] + call [DWORD PTR XMSDriver] + } +} + /*void MM_seguin(void) { __asm { diff --git a/src/lib/16_mm.h b/src/lib/16_mm.h index e4f41b4c..f7927dbc 100755 --- a/src/lib/16_mm.h +++ b/src/lib/16_mm.h @@ -67,7 +67,7 @@ extern boolean dbg_debugpm; #define XMS_INT 0x2f #define XMS_CALL(v) _AH = (v);\ - __asm call [WORD PTR XMSDriver] + __asm call [DWORD PTR XMSDriver] /*__asm { mov ah,[v]\*///} #define XMS_VERSION 0x00 @@ -185,7 +185,7 @@ boolean MML_CheckForEMS(void); //void MML_ShutdownEMS(mminfo_t *mm); byte MM_MapEMS(global_game_variables_t *gvar); //byte MM_MapXEMS(global_game_variables_t *gvar); -boolean MML_CheckForXMS(global_game_variables_t *gvar); +boolean MML_CheckForXMS(void); //void MML_SetupXMS(mminfo_t *mm, mminfotype *mmi); //void MML_ShutdownXMS(mminfo_t *mm); void MML_UseSpace(word segstart, dword seglength, global_game_variables_t *gvar); @@ -208,6 +208,7 @@ void MM_Report_(global_game_variables_t *gvar); void MM_BombOnError(boolean bomb, global_game_variables_t *gvar); //void MM_GetNewBlock(mminfo_t *mm); //void MM_FreeBlock(mmblocktype *x, mminfo_t *mm); +void xms_call(byte v, global_game_variables_t *gvar); //========================================================================== diff --git a/src/lib/16_pm.c b/src/lib/16_pm.c index a5bbb601..ae14303f 100755 --- a/src/lib/16_pm.c +++ b/src/lib/16_pm.c @@ -83,11 +83,11 @@ static char *ParmStrings[] = {"nomain","noems","noxms",nil}; byte PML_MapEMS(word logical, byte physical, global_game_variables_t *gvar) { - byte str[160]; + byte err, str[160]; unsigned EMShandle; - byte err; - boolean errorflag=false; int i; + + boolean errorflag=false; EMShandle=gvar->pm.emm.EMSHandle; __asm { @@ -139,11 +139,10 @@ boolean PML_StartupEMS(global_game_variables_t *gvar) { int i; - long size; - byte str[64]; - byte err; + //long size; + byte err, str[64]; - boolean errorflag=0; + boolean errorflag=false; static char emmname[] = "EMMXXXX0"; //fix by andrius4669 unsigned int EMSVer = 0; unsigned totalEMSpages,freeEMSpages,EMSPageFrame,EMSHandle,EMSAvail; @@ -299,10 +298,9 @@ void PML_ShutdownEMS(global_game_variables_t *gvar) { word EMSHandle; - byte err; - byte str[64]; - boolean errorflag=false; + byte err,str[64]; + boolean errorflag=false; EMSHandle=gvar->pm.emm.EMSHandle; if (gvar->pm.emm.EMSPresent) @@ -357,7 +355,12 @@ boolean PML_StartupXMS(global_game_variables_t *gvar) { boolean errorflag; - word XMSAvail, XMSHandle; + byte err; + word /*XMSAvail,*/ XMSHandle; + + word XMSAvail1, XMSAvail2, XMSAvail3, XMSAvail4; + + word e=0; errorflag=gvar->pm.xmm.XMSPresent = false; // Assume failure gvar->pm.xmm.XMSAvail = gvar->mmi.XMSmem = 0; @@ -365,83 +368,139 @@ PML_StartupXMS(global_game_variables_t *gvar) mov ax,0x4300 int XMS_INT // Check for presence of XMS driver cmp al,0x80 - jne errorxu + jne error1 + mov e,1 mov ax,0x4310 int XMS_INT // Get address of XMS driver mov [WORD PTR XMSDriver],bx mov [WORD PTR XMSDriver+2],es // function pointer to XMS driver + mov e,2 //XMS_CALL(XMS_QUERYFREE); // Find out how much XMS is available - mov ah,XMS_QUERYFREE + mov ah,XMS_QUERYFREE // Find out how much XMS is available call [DWORD PTR XMSDriver] - mov [XMSAvail],ax - or ax,ax // AJR: bugfix 10/8/92 - jz errorxu - jmp Endxu + //mov [XMSAvail],ax + //mov XMSAvail1,ax + //mov ax,XMSAvail2 + //mov [XMSAvail3],ax + mov ax,[XMSAvail4] + mov err,bl + cmp ax,0 // AJR: bugfix 10/8/92 + je error1 + mov e,3 + jmp End1 #ifdef __BORLANDC__ } #endif - errorxu: + error1: #ifdef __BORLANDC__ __asm { #endif - //mov err,ah + mov err,bl mov errorflag,1 - jmp Endxu + jmp End1 #ifdef __BORLANDC__ } #endif - Endxu: +End1: #ifdef __WATCOMC__ } #endif - XMSAvail &= ~(PMPageSizeKB - 1); // Round off to nearest page size - if (XMSAvail < (PMPageSizeKB * 2)){ // Need at least 2 pages - printf("PISS! %u\n", XMSAvail); + +// XMS_CALL(XMS_QUERYFREE); // Find out how much XMS is available +// XMSAvail = _AX; +// if (!_AX) // AJR: bugfix 10/8/92 +// goto error; + + printf(" XMSAvail=%u e=%u\n", XMSAvail4, e); + //printf(" %u %u %u %u\n", XMSAvail1, XMSAvail2, XMSAvail3, XMSAvail4); + XMSAvail4 &= ~(PMPageSizeKB - 1); // Round off to nearest page size + if (XMSAvail4 < (PMPageSizeKB * 2)){ // Need at least 2 pages + printf("PISS! %u\n", XMSAvail4); goto error; } __asm { - mov dx,[XMSAvail] + mov dx,XMSAvail4 //XMS_CALL(XMS_ALLOC); // And do the allocation mov ah,XMS_ALLOC - call [WORD PTR XMSDriver] - mov [XMSHandle],dx + call [DWORD PTR XMSDriver] + mov XMSHandle,dx or ax,ax // AJR: bugfix 10/8/92 - jz errorxuu - jmp Endxuu + jz error2 + mov e,4 + jmp End2 #ifdef __BORLANDC__ - } + } #endif - errorxuu: + error2: #ifdef __BORLANDC__ __asm { #endif - //mov err,ah - mov [XMSAvail],0 + mov err,bl mov errorflag,1 - jmp Endxuu + jmp End2 #ifdef __BORLANDC__ } #endif - Endxuu: +End2: #ifdef __WATCOMC__ } #endif if(errorflag==false) { - gvar->pm.xmm.XMSAvail = XMSAvail; - gvar->mmi.XMSmem += gvar->pm.xmm.XMSAvail * (dword)1024; + gvar->mmi.XMSmem = XMSAvail4 * (dword)1024; + gvar->pm.xmm.XMSAvail = XMSAvail4; gvar->pm.xmm.XMSHandle = XMSHandle; gvar->pm.xmm.XMSPresent = true; - printf(" %u %u %u\n", gvar->mmi.XMSmem, gvar->pm.xmm.XMSAvail, XMSAvail); + printf(" %u %u %u\n", gvar->mmi.XMSmem, gvar->pm.xmm.XMSAvail, XMSAvail4); getch(); - }else printf(" errorflag\n"); + }else printf(" %u errorflag=%02X\n", XMSAvail4, err); error: return(gvar->pm.xmm.XMSPresent); +/* + gvar->pm.xmm.XMSPresent = false; // Assume failure + gvar->pm.xmm.XMSAvail = 0; + +__asm mov ax,0x4300 +__asm int XMS_INT // Check for presence of XMS driver + if (_AL != 0x80) + goto error; + + +__asm mov ax,0x4310 +__asm int XMS_INT // Get address of XMS driver +__asm mov [WORD PTR XMSDriver],bx +__asm mov [WORD PTR XMSDriver+2],es // function pointer to XMS driver + + XMS_CALL(XMS_QUERYFREE); // Find out how much XMS is available + gvar->pm.xmm.XMSAvail = _AX; + if (!_AX) // AJR: bugfix 10/8/92 + goto error; + + gvar->pm.xmm.XMSAvail &= ~(PMPageSizeKB - 1); // Round off to nearest page size + if (gvar->pm.xmm.XMSAvail < (PMPageSizeKB * 2)) // Need at least 2 pages + goto error; + + _DX = gvar->pm.xmm.XMSAvail; + XMS_CALL(XMS_ALLOC); // And do the allocation + gvar->pm.xmm.XMSHandle = _DX; + + if (!_AX) // AJR: bugfix 10/8/92 + { + gvar->pm.xmm.XMSAvail = 0; + goto error; + } + + gvar->mmi.XMSmem = gvar->pm.xmm.XMSAvail * 1024; + + gvar->pm.xmm.XMSPresent = true; +error: + printf("XMSstart %u %u\n", gvar->mmi.XMSmem, gvar->pm.xmm.XMSAvail); + return(gvar->pm.xmm.XMSPresent);*/ } // @@ -529,7 +588,7 @@ PML_ShutdownXMS(global_game_variables_t *gvar) mov dx,[XMSHandle] //XMS_CALL(XMS_FREE); mov ah,XMS_FREE - call [WORD PTR XMSDriver] + call [DWORD PTR XMSDriver] or bl,bl jz errorxs jmp Endxs @@ -1474,7 +1533,7 @@ PM_Startup(global_game_variables_t *gvar) if (!noems && MML_CheckForEMS()) PML_StartupEMS(gvar); - if (!noxms && MML_CheckForXMS(gvar)) + if (!noxms && MML_CheckForXMS()) PML_StartupXMS(gvar); if (!nomain && !gvar->pm.emm.EMSPresent) @@ -1496,7 +1555,7 @@ PM_Startup(global_game_variables_t *gvar) void PM_Shutdown(global_game_variables_t *gvar) { - if(MML_CheckForXMS(gvar)) PML_ShutdownXMS(gvar); + if(MML_CheckForXMS()) PML_ShutdownXMS(gvar); if(MML_CheckForEMS()) PML_ShutdownEMS(gvar); if (!gvar->pm.PMStarted) diff --git a/src/lib/typdefst.h b/src/lib/typdefst.h index 6aeed524..119d8677 100755 --- a/src/lib/typdefst.h +++ b/src/lib/typdefst.h @@ -258,7 +258,7 @@ typedef struct { boolean XMSPresent; word XMSAvail,XMSPagesAvail,XMSHandle; - dword XMSDriver; //TODO: changed to word + dword XMSDriver; int XMSProtectPage;// = -1; } pm_xmmi_t; diff --git a/src/vrstest.c b/src/vrstest.c index 05db59e1..5dd2ffef 100755 --- a/src/vrstest.c +++ b/src/vrstest.c @@ -22,11 +22,13 @@ #include "src/lib/modex16.h" #include "src/lib/16_sprit.h" +#include "src/lib/16_tail.h" +#include "src/lib/16_pm.h" #include "src/lib/16_ca.h" #include "src/lib/16_mm.h" void main() { - global_game_variables_t gvar; + static global_game_variables_t gvar; __segment sega; memptr bigbuffer; int i; @@ -73,6 +75,8 @@ void main() { gvar.mm.mmstarted=0; MM_Startup(&gvar); + PM_Startup(&gvar); + PM_UnlockMainMem(&gvar); CA_Startup(&gvar); // What should be done by read_vrs: //sega = (mm.bufferseg); @@ -157,6 +161,7 @@ void main() { free(spri.sprite_vrl_cont); MM_FreePtr(&bigbuffer, &gvar); //MM_FreePtr(&((void __based(sega)*)spri.spritesheet->buffer), &mm); + PM_Shutdown(&gvar); CA_Shutdown(&gvar); MM_Shutdown(&gvar); //printf("CPU to VGA: %f\n", t1);