]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_mm.h
xcrollbroke
[16.git] / src / lib / 16_mm.h
index d351abfa8f868a004be425755ce6f2f37a5910a5..4516571d4f4492ef43ae7cea00b6c7c6f354cb32 100755 (executable)
@@ -1,38 +1,39 @@
-/* Catacomb Apocalypse Source Code\r
- * Copyright (C) 1993-2014 Flat Rock Software\r
+/* Project 16 Source Code~\r
+ * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
  *\r
- * This program is free software; you can redistribute it and/or modify\r
+ * This file is part of Project 16.\r
+ *\r
+ * Project 16 is free software; you can redistribute it and/or modify\r
  * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
+ * the Free Software Foundation; either version 3 of the License, or\r
  * (at your option) any later version.\r
  *\r
- * This program is distributed in the hope that it will be useful,\r
+ * Project 16 is distributed in the hope that it will be useful,\r
  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
  * GNU General Public License for more details.\r
  *\r
- * You should have received a copy of the GNU General Public License along\r
- * with this program; if not, write to the Free Software Foundation, Inc.,\r
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
+ * Fifth Floor, Boston, MA 02110-1301 USA.\r
+ *\r
  */\r
 \r
 // ID_MM.H\r
 \r
-#ifndef __16_EXMM__\r
-#define __16_EXMM__\r
+#ifndef __16_MM__\r
+#define __16_MM__\r
 \r
 #include <string.h>\r
-#include <malloc.h>\r
 #include "src/lib/16_head.h"\r
 #include "src/lib/16_hc.h"\r
-#include "src/lib/16_lib.h"\r
-//++++mh       #include "src/lib/16_in.h"\r
-\r
+#include "src/lib/16_tail.h"\r
 \r
 #ifdef __DEBUG__               // 1 == Debug/Dev  ;  0 == Production/final\r
 #define OUT_OF_MEM_MSG "MM_GetPtr: Out of memory!\nYou were short :%lu bytes\n"\r
 #else\r
-#define OUT_OF_MEM_MSG "\npee\n"\r
+#define OUT_OF_MEM_MSG "\n"\r
 #endif\r
 \r
 //#define GETNEWBLOCK {if(!(mmnew=mmfree))Quit("MM_GETNEWBLOCK: No free blocks!") ;mmfree=mmfree->next;}\r
 \r
 #define FREEBLOCK(x) {*x->useptr=NULL;x->next=gvar->mm.mmfree;gvar->mm.mmfree=x;}\r
 \r
-#define SAVENEARHEAP   0x200           // space to leave in data segment\r
-#define SAVEFARHEAP    0//x400                 // space to leave in far heap\r
+#define SAVENEARHEAP   0x400           // space to leave in data segment\r
+#define SAVEFARHEAP    0                       // space to leave in far heap\r
 \r
 #define        BUFFERSIZE              0x1000          // miscelanious, allways available buffer\r
 \r
-//moved to typdefst\r
+//moved to 16_tdef.h\r
 //#define MAXBLOCKS            1024\r
 \r
 \r
-\r
 //--------\r
 \r
 #define        EMS_INT                 0x67\r
+#define        EMM_INT                 0x21\r
 \r
 #define        EMS_STATUS              0x40\r
 #define        EMS_GETFRAME    0x41\r
 //--------\r
 \r
 #define        XMS_INT                 0x2f\r
-#define        XMSD                    dword XMSDriver=gvar->pm.xmm.XMSDriver;\r
+#define        XMS_CALL(v)             _AH = (v);\\r
+                                               __asm call [DWORD PTR XMSDriver]\r
+/*__asm { mov ah,[v]\*///}\r
 \r
 #define        XMS_VERSION             0x00\r
 \r
-#define        XMS_ALLOCHMA    0x01\r
+#define        XMS_ALLOCHMA            0x01\r
 #define        XMS_FREEHMA             0x02\r
 \r
 #define        XMS_GENABLEA20  0x03\r
 #define        XMS_GDISABLEA20 0x04\r
 #define        XMS_LENABLEA20  0x05\r
 #define        XMS_LDISABLEA20 0x06\r
-#define        XMS_QUERYA20    0x07\r
+#define        XMS_QUERYA20            0x07\r
 \r
 #define        XMS_QUERYFREE   0x08\r
 #define        XMS_ALLOC               0x09\r
-#define        XMS_FREE                0x0A\r
-#define        XMS_MOVE                0x0B\r
-#define        XMS_LOCK                0x0C\r
+#define        XMS_FREE                        0x0A\r
+#define        XMS_MOVE                        0x0B\r
+#define        XMS_LOCK                        0x0C\r
 #define        XMS_UNLOCK              0x0D\r
 #define        XMS_GETINFO             0x0E\r
 #define        XMS_RESIZE              0x0F\r
 \r
-#define        XMS_ALLOCUMB    0x10\r
+#define        XMS_ALLOCUMB            0x10\r
 #define        XMS_FREEUMB             0x11\r
 \r
 //==========================================================================\r
 \r
 extern void            (* beforesort) (void);\r
 extern void            (* aftersort) (void);\r
-extern void            (* XMSaddr) (void);             // far pointer to XMS driver\r
+//extern       void            (* XMSaddr) (void);             // far pointer to XMS driver\r
+extern dword   XMSDriver;\r
+extern word            XMSVer;\r
 \r
 //==========================================================================\r
 \r
@@ -132,7 +137,6 @@ extern void         (* XMSaddr) (void);             // far pointer to XMS driver
        word    blob;   //for data larger than 64k\r
        unsigned        attributes;\r
        memptr          *useptr;        // pointer to the segment start\r
-       //huge struct mmblockstruct huge *next;\r
        struct mmblockstruct far *next;\r
 } mmblocktype;\r
 \r
@@ -141,7 +145,6 @@ typedef struct
 {\r
        memptr bufferseg;\r
        boolean         mmstarted, bombonerror, mmerror;\r
-       //huge void huge        *farheap;\r
        void far        *farheap;\r
 #ifdef __BORLANDC__\r
        void    *nearheap;\r
@@ -154,7 +157,6 @@ typedef struct
        unsigned int EMSVer;\r
        word numUMBs,UMBbase[MAXUMBS];\r
        //dword numUMBs,UMBbase[MAXUMBS];\r
-       //huge mmblocktype      huge mmblocks[MAXBLOCKS],huge *mmhead,huge *mmfree,huge *mmrover,huge *mmnew;\r
        mmblocktype     far mmblocks[MAXBLOCKS],far *mmhead,far *mmfree,far *mmrover,far *mmnew;\r
 } mminfo_t;*/\r
 \r
@@ -180,13 +182,13 @@ typedef struct
 boolean MML_CheckForEMS(void);\r
 //byte MML_SetupEMS(mminfo_t *mm);\r
 //void MML_ShutdownEMS(mminfo_t *mm);\r
-byte MM_MapEMS(global_game_variables_t *gvar);\r
-byte MM_MapXEMS(global_game_variables_t *gvar);\r
-//boolean MML_CheckForXMS(mminfo_t *mm);\r
+//byte MM_MapEMS(global_game_variables_t *gvar);\r
+//byte MM_MapXEMS(global_game_variables_t *gvar);\r
+boolean MML_CheckForXMS(void);\r
 //void MML_SetupXMS(mminfo_t *mm, mminfotype *mmi);\r
 //void MML_ShutdownXMS(mminfo_t *mm);\r
-void MML_UseSpace(word segstart, dword seglength, global_game_variables_t *gvar);\r
-void MML_ClearBlock(global_game_variables_t *gvar);\r
+ void MML_UseSpace (unsigned segstart, unsigned seglength, global_game_variables_t *gvar);\r
+ void MML_ClearBlock (global_game_variables_t *gvar);\r
 \r
 void MM_Startup(global_game_variables_t *gvar);\r
 void MM_Shutdown(global_game_variables_t *gvar);\r
@@ -205,7 +207,7 @@ void MM_Report_(global_game_variables_t *gvar);
 void MM_BombOnError(boolean bomb, global_game_variables_t *gvar);\r
 //void MM_GetNewBlock(mminfo_t *mm);\r
 //void MM_FreeBlock(mmblocktype *x, mminfo_t *mm);\r
-void   XMS_CALL(byte v, global_game_variables_t *gvar);\r
+void xms_call(byte v, global_game_variables_t *gvar);\r
 \r
 //==========================================================================\r
 \r