]> 4ch.mooo.com Git - 16.git/blob - src/lib/16_pm.h
i did some minor things including commenting out some joy stick timing stuff and...
[16.git] / src / lib / 16_pm.h
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
3  *\r
4  * This file is part of Project 16.\r
5  *\r
6  * Project 16 is free software; you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation; either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * Project 16 is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
19  * Fifth Floor, Boston, MA 02110-1301 USA.\r
20  *\r
21  */\r
22 \r
23 #ifndef __16_PM__\r
24 #define __16_PM__\r
25 \r
26 //\r
27 //      ID_PM.H\r
28 //      Header file for Id Engine's Page Manager\r
29 //\r
30 \r
31 #include "src/lib/16_head.h"\r
32 #include "src/lib/16_hc.h"\r
33 #include "src/lib/16_mm.h"\r
34 #include "src/lib/16_ca.h"\r
35 #include <dos.h>\r
36 \r
37 //#define __PM__NOHOGEMS__\r
38 /*//    NOTE! PMPageSize must be an even divisor of EMSPageSize, and >= 1024\r
39 #define EMSPageSize             16384\r
40 #define EMSPageSizeSeg  (EMSPageSize >> 4)\r
41 #define EMSPageSizeKB   (EMSPageSize >> 10)\r
42 #define EMSFrameCount   4\r
43 #define PMPageSize              4096\r
44 #define PMPageSizeSeg   (PMPageSize >> 4)\r
45 #define PMPageSizeKB    (PMPageSize >> 10)\r
46 #define PMEMSSubPage    (EMSPageSize / PMPageSize)\r
47 \r
48 #define PMMinMainMem    10                      // Min acceptable # of pages from main\r
49 #define PMMaxMainMem    100                     // Max number of pages in main memory\r
50 \r
51 #define PMThrashThreshold       1       // Number of page thrashes before panic mode\r
52 #define PMUnThrashThreshold     5       // Number of non-thrashing frames before leaving panic mode\r
53 \r
54 typedef enum\r
55                 {\r
56                         pml_Unlocked,\r
57                         pml_Locked\r
58                 } PMLockType;\r
59 \r
60 typedef enum\r
61                 {\r
62                         pmba_Unused = 0,\r
63                         pmba_Used = 1,\r
64                         pmba_Allocated = 2\r
65                 } PMBlockAttr;\r
66 \r
67 typedef struct\r
68                 {\r
69                         dword   offset;         // Offset of chunk into file\r
70                         word            length;         // Length of the chunk\r
71 \r
72                         int                     xmsPage;        // If in XMS, (xmsPage * PMPageSize) gives offset into XMS handle\r
73 \r
74                         PMLockType      locked;         // If set, this page can't be purged\r
75                         int                     emsPage;        // If in EMS, logical page/offset into page\r
76                         int                     mainPage;       // If in Main, index into handle array\r
77 \r
78                         dword   lastHit;        // Last frame number of hit\r
79                 } PageListStruct;\r
80 \r
81 typedef struct\r
82                 {\r
83                         int                     baseEMSPage;    // Base EMS page for this phys frame\r
84                         dword   lastHit;                // Last frame number of hit\r
85                 } EMSListStruct;\r
86 \r
87 extern  boolean                 XMSPresent,EMSPresent;\r
88 extern  word                    XMSPagesAvail,EMSPagesAvail;\r
89 \r
90 extern  word                    ChunksInFile,\r
91                                                 PMSpriteStart,PMSoundStart;\r
92 extern  PageListStruct  far *PMPages;*///moved to src/lib/typdefst.h\r
93 \r
94 #define PM_GetSoundPage(v)      PM_GetPage(gvar->pm.fi.PMSoundStart + (v), gvar)\r
95 #define PM_GetSpritePage(v)     PM_GetPage(gvar->pm.fi.PMSpriteStart + (v), gvar)\r
96 \r
97 #define PM_LockMainMem(gvar)    PM_SetMainMemPurge(0, gvar)\r
98 #define PM_UnlockMainMem(gvar)  PM_SetMainMemPurge(3, gvar)\r
99 \r
100 \r
101 extern  char    PageFileName[13];\r
102 \r
103 \r
104 extern  void    PM_Startup(global_game_variables_t *gvar),\r
105                                 PM_Shutdown(global_game_variables_t *gvar),\r
106                                 PM_Reset(global_game_variables_t *gvar),\r
107                                 PM_Preload(boolean (*update)(word current,word total), global_game_variables_t *gvar),\r
108                                 PM_NextFrame(global_game_variables_t *gvar),\r
109                                 PM_SetPageLock(int pagenum,PMLockType lock, global_game_variables_t *gvar),\r
110                                 PM_SetMainPurge(int level),\r
111                                 PM_CheckMainMem(global_game_variables_t *gvar);\r
112 extern  memptr  PM_GetPageAddress(int pagenum, global_game_variables_t *gvar),\r
113                                 PM_GetPage(int pagenum, global_game_variables_t *gvar);         // Use this one to cache page\r
114 \r
115 void PM_SetMainMemPurge(int level, global_game_variables_t *gvar);\r
116 void PML_StartupMainMem(global_game_variables_t *gvar);\r
117 #endif\r