X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_mm.h;h=23daa0bb1b231b090f967b4acfa729b713800f61;hb=3905085894af7601c6c590f051dc20ca3db08bd9;hp=bb1301012c63873bd8fab61dff6f7395c1899572;hpb=af4abf6b0b6545e71d65e6e5325c4ea8da2a56e5;p=16.git diff --git a/src/lib/16_mm.h b/src/lib/16_mm.h old mode 100644 new mode 100755 index bb130101..23daa0bb --- a/src/lib/16_mm.h +++ b/src/lib/16_mm.h @@ -1,19 +1,19 @@ -/* Catacomb Apocalypse Source Code - * Copyright (C) 1993-2014 Flat Rock Software - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +/* Catacomb Apocalypse Source Code + * Copyright (C) 1993-2014 Flat Rock Software + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ // ID_MM.H @@ -23,22 +23,39 @@ #include #include -#include "src/lib/lib_head.h" +#include "src/lib/16_head.h" +#include "src/lib/16_hc.h" +//#include "src/lib/modex16.h" //++++mh #include "src/lib/16_in.h" #ifdef __DEBUG__ // 1 == Debug/Dev ; 0 == Production/final -#define OUT_OF_MEM_MSG "MM_GetPtr: Out of memory!\nYou were short :%ld bytes" +#define OUT_OF_MEM_MSG "MM_GetPtr: Out of memory!\nYou were short :%lu bytes\n" #else #define OUT_OF_MEM_MSG "\npee\n" #endif +//#define GETNEWBLOCK {if(!(mmnew=mmfree))Quit("MM_GETNEWBLOCK: No free blocks!") ;mmfree=mmfree->next;} +#define GETNEWBLOCK {if(!mm->mmfree)MML_ClearBlock(mm);mm->mmnew=mm->mmfree;mm->mmfree=mm->mmfree->next;} -#define SAVENEARHEAP 0x400 // space to leave in data segment -#define SAVEFARHEAP 0 // space to leave in far heap +#define FREEBLOCK(x) {*x->useptr=NULL;x->next=mm->mmfree;mm->mmfree=x;} + +#define AARED "\x1b[41;31m" +#define AABLUE "\x1b[44;34m" +#define AAGREEN "\x1b[42;32m" +#define AAYELLOW "\x1b[43;33m" +#define AAGREY "\x1b[47;37m" +#define AABLACK "\x1b[40;30m" +#define AAWHITE "\x1b[47;37m" +#define AAMAGENTA "\x1b[45;35m" +#define AARESET "\x1b[0m" + +#define SAVENEARHEAP 0x200 // space to leave in data segment +#define SAVEFARHEAP 0//x400 // space to leave in far heap #define BUFFERSIZE 0x1000 // miscelanious, allways available buffer -#define MAXBLOCKS 600 +#define MAXBLOCKS 1024 + //-------- @@ -50,6 +67,7 @@ #define EMS_GETPAGES 0x42 #define EMS_ALLOCPAGES 0x43 #define EMS_MAPPAGE 0x44 +#define EMS_MAPXPAGE 0x50 #define EMS_FREEPAGES 0x45 #define EMS_VERSION 0x46 @@ -79,24 +97,17 @@ #define XMS_FREEUMB 0x11 //========================================================================== -//I hope this is correct! -//__segment seg; -typedef void __based(__self) * memptr; //__based(seg) * memptr; typedef struct { dword nearheap,farheap,EMSmem,XMSmem,mainmem; - boolean mmstarted, bombonerror, mmerror; } mminfotype; //========================================================================== -/*extern mminfotype mminfo; -extern memptr bufferseg; -extern boolean mmerror; - extern void (* beforesort) (void); -extern void (* aftersort) (void);*/ +extern void (* aftersort) (void); +extern void (* XMSaddr) (void); // far pointer to XMS driver //========================================================================== @@ -113,20 +124,41 @@ extern void (* aftersort) (void);*/ #define PURGEMASK 0xfffc #define BASEATTRIBUTES 0 // unlocked, non purgable -#define MAXUMBS 10 +#define MAXUMBS 12 +#define MAPPAGES 4//mm->EMSpagesmapped typedef struct mmblockstruct { - unsigned start,length; + word start,length; + //word start; dword length; + word blob; //for data larger than 64k unsigned attributes; memptr *useptr; // pointer to the segment start + //huge struct mmblockstruct huge *next; struct mmblockstruct far *next; } mmblocktype; -//#define GETNEWBLOCK {if(!(mmnew=mmfree))Quit("MM_GETNEWBLOCK: No free blocks!");mmfree=mmfree->next;} -#define GETNEWBLOCK {if(!mmfree)MML_ClearBlock();mmnew=mmfree;mmfree=mmfree->next;} -#define FREEBLOCK(x) {*x->useptr=NULL;x->next=mmfree;mmfree=x;} +typedef struct +{ + memptr bufferseg; + boolean mmstarted, bombonerror, mmerror; + //huge void huge *farheap; + void far *farheap; +#ifdef __BORLANDC__ + void *nearheap; +#endif +#ifdef __WATCOMC__ + void __near *nearheap; +#endif + //byte EMS_status; + unsigned totalEMSpages,freeEMSpages,EMSpageframe,EMSpagesmapped,EMShandle; + unsigned int EMSVer; + word numUMBs,UMBbase[MAXUMBS]; + //dword numUMBs,UMBbase[MAXUMBS]; + //huge mmblocktype huge mmblocks[MAXBLOCKS],huge *mmhead,huge *mmfree,huge *mmrover,huge *mmnew; + mmblocktype far mmblocks[MAXBLOCKS],far *mmhead,far *mmfree,far *mmrover,far *mmnew; +} mminfo_t; /* ============================================================================= @@ -136,11 +168,6 @@ typedef struct mmblockstruct ============================================================================= */ -/*static mminfotype mminfo; -static memptr bufferseg; - -static void (* beforesort) (void); -static void (* aftersort) (void);*/ /* ============================================================================= @@ -150,56 +177,36 @@ static void (* aftersort) (void);*/ ============================================================================= */ -/*static void huge *hugeheap; -static void far *farheap; -static void *nearheap; - -static mmblocktype far mmblocks[MAXBLOCKS] - ,far *mmhead,far *mmfree,far *mmrover,far *mmnew; - - -static unsigned totalEMSpages,freeEMSpages,EMSpageframe,EMSpagesmapped,EMShandle; -static unsigned int EMSVer; - -static void (* XMSaddr) (void); // far pointer to XMS driver - -static unsigned numUMBs,UMBbase[MAXUMBS];*/ - -//========================================================================== - -void MM_Startup (void); -void MM_Shutdown (void); - -void MM_GetPtr (memptr *baseptr,dword size); -void MM_FreePtr (memptr *baseptr); - -void MM_SetPurge (memptr *baseptr, int purge); -void MM_SetLock (memptr *baseptr, boolean locked); -void MM_SortMem (void); - -void MM_ShowMemory (void); - -dword MM_UnusedMemory (void); -dword MM_TotalFree (void); -void MM_Report(void); -//int MM_EMSVer(void); - -void MM_BombOnError (boolean bomb); - //========================================================================== -// -// local prototypes -// - -boolean MML_CheckForEMS (void); -unsigned MML_SetupEMS (void); -void MML_ShutdownEMS (void); -unsigned MM_MapEMS (void); -boolean MML_CheckForXMS (void); -void MML_ShutdownXMS (void); -void MML_UseSpace (unsigned segstart, unsigned seglength); -void MML_ClearBlock (void); +boolean MML_CheckForEMS(void); +byte MML_SetupEMS(mminfo_t *mm); +void MML_ShutdownEMS(mminfo_t *mm); +byte MM_MapEMS(mminfo_t *mm, mminfotype *mmi); +byte MM_MapXEMS(mminfo_t *mm, mminfotype *mmi); +boolean MML_CheckForXMS(mminfo_t *mm); +void MML_SetupXMS(mminfo_t *mm, mminfotype *mmi); +void MML_ShutdownXMS(mminfo_t *mm); +void MML_UseSpace(word segstart, dword seglength, mminfo_t *mm); +void MML_ClearBlock(mminfo_t *mm); + +void MM_Startup(mminfo_t *mm, mminfotype *mmi); +void MM_Shutdown(mminfo_t *mm); + +void MM_GetPtr(memptr *baseptr,dword size, mminfo_t *mm, mminfotype *mmi); +void MM_FreePtr(memptr *baseptr, mminfo_t *mm); +void MM_SetPurge(memptr *baseptr, int purge, mminfo_t *mm); +void MM_SetLock(memptr *baseptr, boolean locked, mminfo_t *mm); +void MM_SortMem(mminfo_t *mm); +void MM_ShowMemory(global_game_variables_t *gvar,/*page_t *page, */mminfo_t *mm); +void MM_DumpData(mminfo_t *mm); +dword MM_UnusedMemory(mminfo_t *mm); +dword MM_TotalFree(mminfo_t *mm); +void MM_Report(/*page_t *page, */mminfo_t *mm, mminfotype *mmi); +static void MM_EMSerr(byte *stri, byte err); +void MM_BombOnError(boolean bomb, mminfo_t *mm); +//void MM_GetNewBlock(mminfo_t *mm); +//void MM_FreeBlock(mmblocktype *x, mminfo_t *mm); //==========================================================================