From: sparky4 Date: Wed, 28 Sep 2016 17:18:45 +0000 (-0500) Subject: ====XMS MOSTLY translated but crashes EXMMTEST.EXE ==== X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=5965823c934f177a5ef1cd30ae9ee5dda2a95154;p=16.git ====XMS MOSTLY translated but crashes EXMMTEST.EXE ==== --- diff --git a/DEBUG.16B b/DEBUG.16B deleted file mode 100755 index a8fa9d1d..00000000 --- a/DEBUG.16B +++ /dev/null @@ -1,8 +0,0 @@ -Seg:0 Size:3552 Owner:0xc8eb -+++++++++++++++++++++++++++++++++++++++++++++0 -Seg:de0 Size:256 Owner:0xcf79 -++++0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -Seg:9fde Size:28706 Owner:0x0 - -Seg:9ffe Size:24577 Owner:0x0 -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file diff --git a/DEBUG.16W b/DEBUG.16W index 3a8eca69..5aadb17d 100755 --- a/DEBUG.16W +++ b/DEBUG.16W @@ -1,210 +1,210 @@ -Seg:0 Size:9835 Owner:0x0 +Seg:0 Size:9818 Owner:0x0 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++0 -Seg:266b Size:256 Owner:0x18a8 -+++++ -Seg:27e8 Size:53 Owner:0x0 +Seg:265a Size:256 Owner:0x18a8 +++++ +Seg:27d7 Size:44 Owner:0x0 ++ -Seg:281d Size:256 Owner:0x1696 +Seg:2803 Size:256 Owner:0x1696 +++++ +Seg:2903 Size:256 Owner:0x1698 ++++ -Seg:291d Size:256 Owner:0x1698 +Seg:2a03 Size:256 Owner:0x169a ++++ -Seg:2a1d Size:256 Owner:0x169a +Seg:2b03 Size:256 Owner:0x169c ++++ -Seg:2b1d Size:256 Owner:0x169c +Seg:2c03 Size:256 Owner:0x169e +++++ -Seg:2c1d Size:256 Owner:0x169e +Seg:2d03 Size:256 Owner:0x16a0 ++++ -Seg:2d1d Size:256 Owner:0x16a0 +Seg:2e03 Size:256 Owner:0x16a2 ++++ -Seg:2e1d Size:256 Owner:0x16a2 +Seg:2f03 Size:256 Owner:0x16a4 ++++ -Seg:2f1d Size:256 Owner:0x16a4 +Seg:3003 Size:256 Owner:0x16a6 ++++ -Seg:301d Size:256 Owner:0x16a6 +Seg:3103 Size:256 Owner:0x16a8 +++++ -Seg:311d Size:256 Owner:0x16a8 +Seg:3203 Size:256 Owner:0x16aa ++++ -Seg:321d Size:256 Owner:0x16aa +Seg:3303 Size:256 Owner:0x16ac ++++ -Seg:331d Size:256 Owner:0x16ac +Seg:3403 Size:256 Owner:0x16ae ++++ -Seg:341d Size:256 Owner:0x16ae +Seg:3503 Size:256 Owner:0x16b0 ++++ -Seg:351d Size:256 Owner:0x16b0 +Seg:3603 Size:256 Owner:0x16b2 +++++ -Seg:361d Size:256 Owner:0x16b2 +Seg:3703 Size:256 Owner:0x16b4 ++++ -Seg:371d Size:256 Owner:0x16b4 +Seg:3803 Size:256 Owner:0x16b6 ++++ -Seg:381d Size:256 Owner:0x16b6 +Seg:3903 Size:256 Owner:0x16b8 ++++ -Seg:391d Size:256 Owner:0x16b8 +Seg:3a03 Size:256 Owner:0x16ba ++++ -Seg:3a1d Size:256 Owner:0x16ba +Seg:3b03 Size:256 Owner:0x16bc +++++ -Seg:3b1d Size:256 Owner:0x16bc +Seg:3c03 Size:256 Owner:0x16be ++++ -Seg:3c1d Size:256 Owner:0x16be +Seg:3d03 Size:256 Owner:0x16c0 ++++ -Seg:3d1d Size:256 Owner:0x16c0 +Seg:3e03 Size:256 Owner:0x16c2 ++++ -Seg:3e1d Size:256 Owner:0x16c2 +Seg:3f03 Size:256 Owner:0x16c4 ++++ -Seg:3f1d Size:256 Owner:0x16c4 +Seg:4003 Size:256 Owner:0x16c6 +++++ -Seg:401d Size:256 Owner:0x16c6 +Seg:4103 Size:256 Owner:0x16c8 ++++ -Seg:411d Size:256 Owner:0x16c8 +Seg:4203 Size:256 Owner:0x16ca ++++ -Seg:421d Size:256 Owner:0x16ca +Seg:4303 Size:256 Owner:0x16cc ++++ -Seg:431d Size:256 Owner:0x16cc +Seg:4403 Size:256 Owner:0x16ce ++++ -Seg:441d Size:256 Owner:0x16ce +Seg:4503 Size:256 Owner:0x16d0 +++++ -Seg:451d Size:256 Owner:0x16d0 +Seg:4603 Size:256 Owner:0x16d2 ++++ -Seg:461d Size:256 Owner:0x16d2 +Seg:4703 Size:256 Owner:0x16d4 ++++ -Seg:471d Size:256 Owner:0x16d4 +Seg:4803 Size:256 Owner:0x16d6 ++++ -Seg:481d Size:256 Owner:0x16d6 +Seg:4903 Size:256 Owner:0x16d8 ++++ -Seg:491d Size:256 Owner:0x16d8 +Seg:4a03 Size:256 Owner:0x16da +++++ -Seg:4a1d Size:256 Owner:0x16da +Seg:4b03 Size:256 Owner:0x16dc ++++ -Seg:4b1d Size:256 Owner:0x16dc +Seg:4c03 Size:256 Owner:0x16de ++++ -Seg:4c1d Size:256 Owner:0x16de +Seg:4d03 Size:256 Owner:0x16e0 ++++ -Seg:4d1d Size:256 Owner:0x16e0 +Seg:4e03 Size:256 Owner:0x16e2 ++++ -Seg:4e1d Size:256 Owner:0x16e2 +Seg:4f03 Size:256 Owner:0x16e4 +++++ -Seg:4f1d Size:256 Owner:0x16e4 +Seg:5003 Size:256 Owner:0x16e6 ++++ -Seg:501d Size:256 Owner:0x16e6 +Seg:5103 Size:256 Owner:0x16e8 ++++ -Seg:511d Size:256 Owner:0x16e8 +Seg:5203 Size:256 Owner:0x16ea ++++ -Seg:521d Size:256 Owner:0x16ea +Seg:5303 Size:256 Owner:0x16ec ++++ -Seg:531d Size:256 Owner:0x16ec +Seg:5403 Size:256 Owner:0x16ee +++++ -Seg:541d Size:256 Owner:0x16ee +Seg:5503 Size:256 Owner:0x16f0 ++++ -Seg:551d Size:256 Owner:0x16f0 +Seg:5603 Size:256 Owner:0x16f2 ++++ -Seg:561d Size:256 Owner:0x16f2 +Seg:5703 Size:256 Owner:0x16f4 ++++ -Seg:571d Size:256 Owner:0x16f4 +Seg:5803 Size:256 Owner:0x16f6 ++++ -Seg:581d Size:256 Owner:0x16f6 +Seg:5903 Size:256 Owner:0x16f8 +++++ -Seg:591d Size:256 Owner:0x16f8 +Seg:5a03 Size:256 Owner:0x16fa ++++ -Seg:5a1d Size:256 Owner:0x16fa +Seg:5b03 Size:256 Owner:0x16fc ++++ -Seg:5b1d Size:256 Owner:0x16fc +Seg:5c03 Size:256 Owner:0x16fe ++++ -Seg:5c1d Size:256 Owner:0x16fe +Seg:5d03 Size:256 Owner:0x1700 ++++ -Seg:5d1d Size:256 Owner:0x1700 +Seg:5e03 Size:256 Owner:0x1702 +++++ -Seg:5e1d Size:256 Owner:0x1702 +Seg:5f03 Size:256 Owner:0x1704 ++++ -Seg:5f1d Size:256 Owner:0x1704 +Seg:6003 Size:256 Owner:0x1706 ++++ -Seg:601d Size:256 Owner:0x1706 +Seg:6103 Size:256 Owner:0x1708 ++++ -Seg:611d Size:256 Owner:0x1708 +Seg:6203 Size:256 Owner:0x170a ++++ -Seg:621d Size:256 Owner:0x170a +Seg:6303 Size:256 Owner:0x170c +++++ -Seg:631d Size:256 Owner:0x170c +Seg:6403 Size:256 Owner:0x170e ++++ -Seg:641d Size:256 Owner:0x170e +Seg:6503 Size:256 Owner:0x1710 ++++ -Seg:651d Size:256 Owner:0x1710 +Seg:6603 Size:256 Owner:0x1712 ++++ -Seg:661d Size:256 Owner:0x1712 +Seg:6703 Size:256 Owner:0x1714 ++++ -Seg:671d Size:256 Owner:0x1714 +Seg:6803 Size:256 Owner:0x1716 +++++ -Seg:681d Size:256 Owner:0x1716 +Seg:6903 Size:256 Owner:0x1718 ++++ -Seg:691d Size:256 Owner:0x1718 +Seg:6a03 Size:256 Owner:0x171a ++++ -Seg:6a1d Size:256 Owner:0x171a +Seg:6b03 Size:256 Owner:0x171c ++++ -Seg:6b1d Size:256 Owner:0x171c +Seg:6c03 Size:256 Owner:0x171e ++++ -Seg:6c1d Size:256 Owner:0x171e +Seg:6d03 Size:256 Owner:0x1720 +++++ -Seg:6d1d Size:256 Owner:0x1720 +Seg:6e03 Size:256 Owner:0x1722 ++++ -Seg:6e1d Size:256 Owner:0x1722 +Seg:6f03 Size:256 Owner:0x1724 ++++ -Seg:6f1d Size:256 Owner:0x1724 +Seg:7003 Size:256 Owner:0x1726 ++++ -Seg:701d Size:256 Owner:0x1726 +Seg:7103 Size:256 Owner:0x1728 ++++ -Seg:711d Size:256 Owner:0x1728 +Seg:7203 Size:256 Owner:0x172a +++++ -Seg:721d Size:256 Owner:0x172a +Seg:7303 Size:256 Owner:0x172c ++++ -Seg:731d Size:256 Owner:0x172c +Seg:7403 Size:256 Owner:0x172e ++++ -Seg:741d Size:256 Owner:0x172e +Seg:7503 Size:256 Owner:0x1730 ++++ -Seg:751d Size:256 Owner:0x1730 +Seg:7603 Size:256 Owner:0x1732 ++++ -Seg:761d Size:256 Owner:0x1732 +Seg:7703 Size:256 Owner:0x1734 +++++ -Seg:771d Size:256 Owner:0x1734 +Seg:7803 Size:256 Owner:0x1736 ++++ -Seg:781d Size:256 Owner:0x1736 +Seg:7903 Size:256 Owner:0x1738 ++++ -Seg:791d Size:256 Owner:0x1738 +Seg:7a03 Size:256 Owner:0x173a ++++ -Seg:7a1d Size:256 Owner:0x173a +Seg:7b03 Size:256 Owner:0x173c ++++ -Seg:7b1d Size:256 Owner:0x173c +Seg:7c03 Size:256 Owner:0x173e +++++ -Seg:7c1d Size:256 Owner:0x173e +Seg:7d03 Size:256 Owner:0x1740 ++++ -Seg:7d1d Size:256 Owner:0x1740 +Seg:7e03 Size:256 Owner:0x1742 ++++ -Seg:7e1d Size:256 Owner:0x1742 +Seg:7f03 Size:256 Owner:0x1744 ++++ -Seg:7f1d Size:256 Owner:0x1744 +Seg:8003 Size:256 Owner:0x1746 ++++ -Seg:801d Size:256 Owner:0x1746 +Seg:8103 Size:256 Owner:0x1748 +++++ -Seg:811d Size:256 Owner:0x1748 +Seg:8203 Size:256 Owner:0x174a ++++ -Seg:821d Size:256 Owner:0x174a +Seg:8303 Size:256 Owner:0x174c ++++ -Seg:831d Size:256 Owner:0x174c +Seg:8403 Size:256 Owner:0x174e ++++ -Seg:841d Size:256 Owner:0x174e +Seg:8503 Size:256 Owner:0x1750 ++++ -Seg:851d Size:256 Owner:0x1750 +Seg:8603 Size:256 Owner:0x1752 +++++ -Seg:861d Size:256 Owner:0x1752 +Seg:8703 Size:256 Owner:0x1754 ++++ -Seg:871d Size:256 Owner:0x1754 +Seg:8803 Size:256 Owner:0x1756 ++++ -Seg:881d Size:256 Owner:0x1756 +Seg:8903 Size:256 Owner:0x1758 ++++ -Seg:891d Size:256 Owner:0x1758 +Seg:8a03 Size:256 Owner:0x175a ++++ -Seg:8a1d Size:256 Owner:0x175a +Seg:8b03 Size:256 Owner:0x175c +++++ -Seg:8b1d Size:256 Owner:0x175c -++++ -Seg:8c1d Size:273 Owner:0xe3f0 +Seg:8c03 Size:273 Owner:0xe3f0 ++++ -Seg:b81d Size:18402 Owner:0x0 -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file +Seg:b803 Size:18428 Owner:0x0 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file diff --git a/HEAP.16W b/HEAP.16W index eee55bfd..59a1b45b 100755 --- a/HEAP.16W +++ b/HEAP.16W @@ -1,35 +1,35 @@ == default == - USED block at 280a0016 of size 66 - USED block at 280a0058 of size 66 - USED block at 280a009a of size 136 - FREE block at 280a0122 of size 18 - USED block at 280a0134 of size 20 - FREE block at 280a0148 of size 7860 + USED block at 27f90016 of size 66 + USED block at 27f90058 of size 66 + FREE block at 27f9009a of size 18 + USED block at 27f900ac of size 136 + USED block at 27f90134 of size 20 + FREE block at 27f90148 of size 7860 OK - end of heap == near == - USED block at 1809e426 of size 12 - USED block at 1809e432 of size 332 - USED block at 1809e57e of size 52 - USED block at 1809e5b2 of size 20 - USED block at 1809e5c6 of size 20 - USED block at 1809e5da of size 20 - USED block at 1809e5ee of size 20 - USED block at 1809e602 of size 20 - USED block at 1809e616 of size 6630 + USED block at 17f8e426 of size 12 + USED block at 17f8e432 of size 332 + USED block at 17f8e57e of size 52 + USED block at 17f8e5b2 of size 20 + USED block at 17f8e5c6 of size 20 + USED block at 17f8e5da of size 20 + USED block at 17f8e5ee of size 20 + USED block at 17f8e602 of size 20 + USED block at 17f8e616 of size 6630 OK - end of heap == far == - USED block at 280a0016 of size 66 - USED block at 280a0058 of size 66 - USED block at 280a009a of size 136 - USED block at 280a0122 of size 18 - USED block at 280a0134 of size 20 - USED block at 280a0148 of size 7860 + USED block at 27f90016 of size 66 + USED block at 27f90058 of size 66 + USED block at 27f9009a of size 18 + USED block at 27f900ac of size 136 + USED block at 27f90134 of size 20 + USED block at 27f90148 of size 7860 OK - end of heap Memory Type Total Used Free diff --git a/MMDUMP.16B b/MMDUMP.16B index 98f569f2..a2763a15 100755 Binary files a/MMDUMP.16B and b/MMDUMP.16B differ diff --git a/bcexmm.dsk b/bcexmm.dsk index 2bd2d3e6..1fb336b1 100755 Binary files a/bcexmm.dsk and b/bcexmm.dsk differ diff --git a/bcexmm.exe b/bcexmm.exe index 47d175b7..ba460567 100755 Binary files a/bcexmm.exe and b/bcexmm.exe differ diff --git a/bcexmm.prj b/bcexmm.prj index 2abea17e..4b0799a7 100755 Binary files a/bcexmm.prj and b/bcexmm.prj differ diff --git a/makefile b/makefile index e8aa09fc..e58e6e58 100755 --- a/makefile +++ b/makefile @@ -107,7 +107,7 @@ LIBFLAGS=$(WLIBQ) -b -n # VGMSNDOBJ = vgmSnd.$(OBJ) 16_snd.$(OBJ) GFXLIBOBJS = modex16.$(OBJ) bitmap.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16render.$(OBJ) 16_vrs.$(OBJ) 16_sprit.$(OBJ) -16LIBOBJS = 16_mm.$(OBJ) 16_pm.$(OBJ) 16_ca.$(OBJ) 16_lib.$(OBJ) 16_in.$(OBJ) 16_head.$(OBJ) 16_dbg.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ) wcpu.$(OBJ) 16_timer.$(OBJ) +16LIBOBJS = 16_mm.$(OBJ) 16_pm.$(OBJ) 16_ca.$(OBJ) 16_tail.$(OBJ) 16_in.$(OBJ) 16_head.$(OBJ) 16_dbg.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ) wcpu.$(OBJ) 16_timer.$(OBJ) #16planar.$(OBJ) planar.$(OBJ) DOSLIBOBJ = adlib.$(OBJ) 8254.$(OBJ) 8259.$(OBJ) dos.$(OBJ) cpu.$(OBJ) !ifeq DEBUGSERIAL 1 @@ -292,7 +292,7 @@ mapread.$(OBJ): $(SRCLIB)/mapread.c $(SRCLIB)/mapread.h 16_dbg.$(OBJ): $(SRCLIB)/16_dbg.c $(SRCLIB)/16_dbg.h midi.$(OBJ): $(SRCLIB)/midi.c $(SRCLIB)/midi.h 16_head.$(OBJ): $(SRCLIB)/16_head.c $(SRCLIB)/16_head.h -16_lib.$(OBJ): $(SRCLIB)/16_lib.c $(SRCLIB)/16_lib.h +16_tail.$(OBJ): $(SRCLIB)/16_tail.c $(SRCLIB)/16_tail.h 16_hc.$(OBJ): $(SRCLIB)/16_hc.c $(SRCLIB)/16_hc.h 16_snd.$(OBJ): $(SRCLIB)/16_snd.c $(SRCLIB)/16_snd.h jsmn.$(OBJ): $(JSMNLIB)/jsmn.c $(JSMNLIB)/jsmn.h diff --git a/src/exmmtest.c b/src/exmmtest.c index 46095449..aaf10f56 100755 --- a/src/exmmtest.c +++ b/src/exmmtest.c @@ -27,7 +27,7 @@ #include "src/lib/16_ca.h" #include "src/lib/16_mm.h" #include "src/lib/16_hc.h" -#include "src/lib/16_lib.h" +#include "src/lib/16_tail.h" //#include "src/lib/modex16.h" #pragma hdrstop @@ -97,19 +97,21 @@ 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"); + //printf("ok\n"); +#ifdef __WATCOMC__ if(debugpm>0) { PM_Startup(&gvar); - printf("pmstarted ok\n"); + //printf("pmstarted ok\n"); //PM_CheckMainMem(&gvar); PM_UnlockMainMem(&gvar); } +#endif CA_Startup(&gvar); // printf(" done!\n"); - PRINTBB; + //0000PRINTBB; // printf("press any key to continue!\n"); // getch(); #ifdef FILEREAD @@ -140,10 +142,7 @@ for(w=0;w<2;w++) //printf("medium blue = non purgable\n"); //printf("red = locked\n"); printf("press any key to continue!\n"); - getch(); - MM_ShowMemory(&gvar); - MM_DumpData(&gvar); - MM_Report_(&gvar); + DebugMemory_(&gvar, 1); if(baka) printf("\nyay!\n"); else printf("\npoo!\n"); printf("press any key to continue!\n"); @@ -151,11 +150,16 @@ for(w=0;w<2;w++) #ifdef FILEREAD } #endif - printf("bakapee1=%s\n", bakapee1); - printf("bakapee2=%s\n", bakapee2); + DebugMemory_(&gvar, 1); + MM_DumpData(&gvar); + MM_Report_(&gvar); + //printf("bakapee1=%s\n", bakapee1); + //printf("bakapee2=%s\n", bakapee2); MM_FreePtr(&bigbuffer, &gvar); +#ifdef __WATCOMC__ if(debugpm>0) PM_Shutdown(&gvar); +#endif CA_Shutdown(&gvar); MM_Shutdown(&gvar); free(bakapee1); free(bakapee2); diff --git a/src/lib/16_in.c b/src/lib/16_in.c index 6df6d06a..85153939 100755 --- a/src/lib/16_in.c +++ b/src/lib/16_in.c @@ -1155,6 +1155,9 @@ IN_Ack() { word i; + if (!inst.IN_Started) + return; + IN_ClearKey(inpu.LastScan); inpu.LastScan = sc_None; diff --git a/src/lib/16_mm.c b/src/lib/16_mm.c index d1e2759d..16b65aa6 100755 --- a/src/lib/16_mm.c +++ b/src/lib/16_mm.c @@ -140,7 +140,7 @@ boolean MML_CheckForEMS(void) return(emmcfems); } - +#ifndef __16_PM__ /* ====================== = @@ -424,7 +424,7 @@ byte MM_MapXEMS(global_game_variables_t *gvar) gvar->mmi.EMSmem = (i)*0x4000lu; return 0; } - +#endif //========================================================================== /* @@ -459,7 +459,7 @@ boolean MML_CheckForXMS(global_game_variables_t *gvar) else return true; } - +#ifndef __16_PM__ /* ====================== = @@ -546,7 +546,7 @@ void MML_ShutdownXMS(global_game_variables_t *gvar) } } } - +#endif //========================================================================== /* @@ -817,12 +817,13 @@ void MM_Startup(global_game_variables_t *gvar) //printf("_FARCORELEFT %lu\n", _FCORELEFT); #ifdef __WATCOMC__ _fheapgrow(); + length=_FCORELEFT;//_fcoreleft();//(dword)GetFarFreeSize();//0xffffUL*4UL; #endif #ifdef __BORLANDC__ printf("farcoreleft() %lu\n", farcoreleft()); printf("(farcoreleft()+32)-_FCORELEFT %d\n", (sword)((farcoreleft()+32)-_FCORELEFT)); + length=farcoreleft();//_fcoreleft();//(dword)GetFarFreeSize();//0xffffUL*4UL; #endif - length=_FCORELEFT;//_fcoreleft();//(dword)GetFarFreeSize();//0xffffUL*4UL; start = gvar->mm.farheap = _fmalloc(length); //start = gvar->mm.farheap = halloc(length, 1); length -= 16-(FP_OFF(start)&15); @@ -864,7 +865,7 @@ void MM_Startup(global_game_variables_t *gvar) if(MML_CheckForEMS()) { MML_SetupEMS(gvar); // allocate space - //TODO: EMS4! AND EMS 3.2 MASSIVE DATA HANDLMENT! + //16_PM: EMS4! AND EMS 3.2 MASSIVE DATA HANDLMENT! MML_UseSpace(gvar->mm.EMSPageFrame,(MAPPAGES)*0x4000lu, gvar); //if(gvar->pm.emm.EMSVer<0x40) MM_MapEMS(gvar); // map in used pages @@ -1626,11 +1627,13 @@ void MM_Report_(global_game_variables_t *gvar) printf(" XMS\n"); 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("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"); + 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); - printf(" UnusedMemory: %lu\n", MM_UnusedMemory(gvar)); + //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); + //printf(" UnusedMemory: %lu\n", MM_UnusedMemory(gvar)); + } //========================================================================== diff --git a/src/lib/16_mm.h b/src/lib/16_mm.h index d858c0f1..7c681255 100755 --- a/src/lib/16_mm.h +++ b/src/lib/16_mm.h @@ -25,7 +25,7 @@ #include #include "src/lib/16_head.h" #include "src/lib/16_hc.h" -#include "src/lib/16_lib.h" +#include "src/lib/16_tail.h" //++++mh #include "src/lib/16_in.h" #ifdef __DEBUG__ // 1 == Debug/Dev ; 0 == Production/final @@ -68,11 +68,11 @@ extern boolean debugpm; #define XMS_INT 0x2f #define XMS_CALL(v) _AH = (v);\ __asm call [WORD PTR XMSDriver] -/*__asm { //mov (v),ah*/ +/*__asm { mov ah,[v]\*///} #define XMS_VERSION 0x00 -#define XMS_ALLOCHMA 0x01 +#define XMS_ALLOCHMA 0x01 #define XMS_FREEHMA 0x02 #define XMS_GENABLEA20 0x03 @@ -83,14 +83,14 @@ extern boolean debugpm; #define XMS_QUERYFREE 0x08 #define XMS_ALLOC 0x09 -#define XMS_FREE 0x0A -#define XMS_MOVE 0x0B -#define XMS_LOCK 0x0C +#define XMS_FREE 0x0A +#define XMS_MOVE 0x0B +#define XMS_LOCK 0x0C #define XMS_UNLOCK 0x0D #define XMS_GETINFO 0x0E #define XMS_RESIZE 0x0F -#define XMS_ALLOCUMB 0x10 +#define XMS_ALLOCUMB 0x10 #define XMS_FREEUMB 0x11 //========================================================================== diff --git a/src/lib/16_pm.c b/src/lib/16_pm.c index 2f21482d..10ee7b6d 100755 --- a/src/lib/16_pm.c +++ b/src/lib/16_pm.c @@ -98,7 +98,7 @@ PML_MapEMS(word logical, byte physical, global_game_variables_t *gvar) int EMS_INT or ah,ah jnz error - jmp End + jmp End #ifdef __BORLANDC__ } #endif @@ -156,50 +156,50 @@ PML_StartupEMS(global_game_variables_t *gvar) mov dx,OFFSET emmname //fix by andrius4669 mov ax,0x3d00 int EMS_INT // try to open EMMXXXX0 device - jc error1 + jc erroreu mov bx,ax mov ax,0x4400 int EMS_INT // get device info - jc error1 + jc erroreu and dx,0x80 - jz error1 + jz erroreu mov ax,0x4407 int EMS_INT // get status - jc error1 + jc erroreu or al,al - jz error1 + jz erroreu mov ah,0x3e int EMS_INT // close handle - jc error1 + jc erroreu mov ah,EMS_STATUS int EMS_INT - jc error1 // make sure EMS hardware is present + jc erroreu // make sure EMS hardware is present mov ah,EMS_VERSION int EMS_INT // only work on EMS 3.2 or greater (silly, but...) or ah,ah - jnz error1 + jnz erroreu mov [EMSVer],ax // set EMSVer cmp al,0x32 // only work on ems 3.2 or greater - jb error1 + jb erroreu mov ah,EMS_GETFRAME int EMS_INT // find the page frame address or ah,ah - jnz error1 + jnz erroreu mov [EMSPageFrame],bx mov ah,EMS_GETPAGES int EMS_INT // find out how much EMS is there or ah,ah - jnz error1 + jnz erroreu or bx,bx jz noEMS // no EMS at all to allocate cmp bx,2 @@ -207,22 +207,22 @@ PML_StartupEMS(global_game_variables_t *gvar) mov [totalEMSpages],dx mov [freeEMSpages],bx mov [EMSAvail],bx - jmp End1 + jmp Endeu #ifdef __BORLANDC__ } #endif - error1: + erroreu: #ifdef __BORLANDC__ __asm { #endif mov err,ah mov errorflag,1 - jmp End1 + jmp Endeu #ifdef __BORLANDC__ } #endif -noEMS: -End1: + noEMS: + Endeu: #ifdef __WATCOMC__ } #endif @@ -243,30 +243,31 @@ End1: mov bx,[EMSAvail]; int EMS_INT or ah,ah - jnz error2 + jnz erroreuu mov [EMSHandle],dx - jmp End2 + jmp Endeuu #ifdef __BORLANDC__ } #endif - error2: + erroreuu: #ifdef __BORLANDC__ __asm { #endif mov err,ah mov errorflag,1 - jmp End2 + jmp Endeuu #ifdef __BORLANDC__ } #endif -End2: + Endeuu: #ifdef __WATCOMC__ } #endif if(errorflag==false) { - gvar->mmi.EMSmem = EMSAvail * (dword)EMSPageSize; + gvar->pm.emm.EMSAvail = EMSAvail; + gvar->mmi.EMSmem = gvar->pm.emm.EMSAvail * (dword)EMSPageSize; // Initialize EMS mapping cache for (i = 0;i < EMSFrameCount;i++) @@ -283,7 +284,6 @@ End2: gvar->pm.emm.EMSPresent = true; // We have EMS gvar->pm.emm.EMSPageFrame = EMSPageFrame; - gvar->pm.emm.EMSAvail = EMSAvail; gvar->pm.emm.EMSVer = EMSVer; gvar->pm.emm.EMSHandle = EMSHandle; gvar->pm.emm.freeEMSpages = freeEMSpages; @@ -311,22 +311,22 @@ PML_ShutdownEMS(global_game_variables_t *gvar) mov ah,EMS_FREEPAGES mov dx,[EMSHandle] int EMS_INT - jc errors - jmp Ends + jc errores + jmp Endes #ifdef __BORLANDC__ } #endif - errors: + errores: #ifdef __BORLANDC__ __asm { #endif mov err,ah mov errorflag,1 - jmp Ends + jmp Endes #ifdef __BORLANDC__ } #endif - Ends: + Endes: #ifdef __WATCOMC__ } #endif @@ -356,44 +356,86 @@ PML_ShutdownEMS(global_game_variables_t *gvar) boolean PML_StartupXMS(global_game_variables_t *gvar) { - gvar->pm.xmm.XMSPresent = false; // Assume failure - gvar->pm.xmm.XMSAvail = 0; - - _AX=0x4300; - geninterrupt(XMS_INT); // Check for presence of XMS driver - if (_AL != 0x80) - goto error; - + boolean errorflag; + word XMSAvail, XMSHandle; + errorflag=gvar->pm.xmm.XMSPresent = false; // Assume failure + XMSAvail = gvar->pm.xmm.XMSAvail = 0; __asm { + mov ax,0x4300 + int XMS_INT // Check for presence of XMS driver + cmp al,0x80 + jne errorxu + 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 - } - - 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; + //XMS_CALL(XMS_QUERYFREE); // Find out how much XMS is available + mov ah,XMS_QUERYFREE + call [WORD PTR XMSDriver] + mov [XMSAvail],ax + or ax,ax // AJR: bugfix 10/8/92 + jz errorxu + jmp Endxu +#ifdef __BORLANDC__ + } +#endif + errorxu: +#ifdef __BORLANDC__ + __asm { +#endif + //mov err,ah + mov errorflag,1 + jmp Endxu +#ifdef __BORLANDC__ + } +#endif + Endxu: +#ifdef __WATCOMC__ + } +#endif 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; + __asm { + mov dx,[XMSAvail] + //XMS_CALL(XMS_ALLOC); // And do the allocation + mov ah,XMS_ALLOC + call [WORD PTR XMSDriver] + mov [XMSHandle],dx + or ax,ax // AJR: bugfix 10/8/92 + jz errorxuu + jmp Endxuu +#ifdef __BORLANDC__ + } +#endif + errorxuu: +#ifdef __BORLANDC__ + __asm { +#endif + //mov err,ah + mov [XMSAvail],0 + mov errorflag,1 + jmp Endxuu +#ifdef __BORLANDC__ + } +#endif + Endxuu: +#ifdef __WATCOMC__ } +#endif - gvar->mmi.XMSmem += gvar->pm.xmm.XMSAvail * 1024; + if(errorflag==false) + { + gvar->pm.xmm.XMSAvail = XMSAvail; + gvar->mmi.XMSmem += gvar->pm.xmm.XMSAvail * 1024; + gvar->pm.xmm.XMSHandle = XMSHandle; - gvar->pm.xmm.XMSPresent = true; + gvar->pm.xmm.XMSPresent = true; + } error: return(gvar->pm.xmm.XMSPresent); } @@ -475,11 +517,36 @@ PML_CopyFromXMS(byte far *target,int sourcepage,word length, global_game_variabl void PML_ShutdownXMS(global_game_variables_t *gvar) { + boolean errorflag=false; + word XMSHandle = gvar->pm.xmm.XMSHandle; if (gvar->pm.xmm.XMSPresent) { - _DX = gvar->pm.xmm.XMSHandle; - XMS_CALL(XMS_FREE); - if (_BL) + __asm { + mov dx,[XMSHandle] + //XMS_CALL(XMS_FREE); + mov ah,XMS_FREE + call [WORD PTR XMSDriver] + or bl,bl + jz errorxs + jmp Endxs +#ifdef __BORLANDC__ + } +#endif + errorxs: +#ifdef __BORLANDC__ + __asm { +#endif + //mov err,ah + mov errorflag,1 + jmp Endxs +#ifdef __BORLANDC__ + } +#endif + Endxs: +#ifdef __WATCOMC__ + } +#endif + if(errorflag==true) { Quit("PML_ShutdownXMS: Error freeing XMS"); //return; @@ -611,9 +678,6 @@ PML_StartupMainMem(global_game_variables_t *gvar) gvar->pm.mm.MainPagesAvail = 0; gvar->pm.mm.MainPresent = false; MM_BombOnError(false, gvar); - printf("PML_StartupMainMem()\n"); - printf(" p=%04x MainMemPages=%04x\n", p, gvar->pm.mm.MainMemPages); - printf(" p=%Fp MainMemPages=%Fp\n", p, gvar->pm.mm.MainMemPages); for (i = 0,p = gvar->pm.mm.MainMemPages;i < PMMaxMainMem;i++,p++) { MM_GetPtr(p,PMPageSize, gvar); @@ -1402,12 +1466,17 @@ PM_Startup(global_game_variables_t *gvar) } } - //0000++++PML_OpenPageFile(gvar); + //0000+=+=PML_OpenPageFile(gvar); if (!noems) PML_StartupEMS(gvar); - if (!noxms) - //++++PML_StartupXMS(gvar); //TODO: convert + /*if (!noxms) + { + //++++ + printf("PML_StartupXMS "); + PML_StartupXMS(gvar); //TODO: convert + printf("ok!\n"); + }*/ if (!nomain && !gvar->pm.emm.EMSPresent) { diff --git a/src/lib/16_lib.c b/src/lib/16_tail.c similarity index 72% rename from src/lib/16_lib.c rename to src/lib/16_tail.c index 12a4288b..f9f6fb56 100755 --- a/src/lib/16_lib.c +++ b/src/lib/16_tail.c @@ -23,7 +23,7 @@ * 16 library */ -#include "src/lib/16_lib.h" +#include "src/lib/16_tail.h" //=========================================================================== @@ -35,7 +35,7 @@ ================== */ -void DebugMemory (global_game_variables_t *gvar) +void DebugMemory_(global_game_variables_t *gvar, boolean q) { /*VW_FixRefreshBuffer (); US_CenterWindow (16,7); @@ -50,10 +50,24 @@ void DebugMemory (global_game_variables_t *gvar) US_PrintUnsigned (MM_TotalFree()/1024); US_Print ("k\n"); VW_UpdateScreen();*/ + if(q){ + printf("========================================\n"); + printf(" DebugMemory_\n"); + printf("========================================\n");} + if(q) { printf("Memory Usage\n"); + printf("------------\n"); }else printf(" "); + printf("Total: "); if(q) printf(" "); printf("%uk", gvar->mmi.mainmem/1024); + if(q) printf("\n"); else printf(" "); + printf("Free: "); if(q) printf(" "); printf("%uk", MM_UnusedMemory(gvar)/1024); + if(q) printf("\n"); else printf(" "); + printf("With purge:"); if(q) printf(" "); printf("%uk\n", MM_TotalFree(gvar)/1024); + if(q) printf("------------\n"); +#ifdef __WATCOMC__ IN_Ack (); - MM_ShowMemory (gvar); +#endif + if(q) MM_ShowMemory (gvar); } - +#ifdef __WATCOMC__ /* ========================== = @@ -111,5 +125,6 @@ void Quit (char *error) exit(0); } +#endif //=========================================================================== diff --git a/src/lib/16_lib.h b/src/lib/16_tail.h similarity index 86% rename from src/lib/16_lib.h rename to src/lib/16_tail.h index 5529ec62..76916aeb 100755 --- a/src/lib/16_lib.h +++ b/src/lib/16_tail.h @@ -20,14 +20,16 @@ * */ -#ifndef __16_LIB__ -#define __16_LIB__ +#ifndef __16_TAIL__ +#define __16_TAIL__ #include "src/lib/16_head.h" #include "src/lib/16_mm.h" #include "src/lib/16_in.h" -void DebugMemory (global_game_variables_t *gvar); +void DebugMemory_(global_game_variables_t *gvar, boolean q); +#ifdef __WATCOMC__ void Quit (char *error); +#endif #endif