]> 4ch.mooo.com Git - 16.git/blob - src/lib/16_pm.h
added a repository /home/sparky4
[16.git] / src / lib / 16_pm.h
1 //\r
2 //      ID_PM.H\r
3 //      Header file for Id Engine's Page Manager\r
4 //\r
5 \r
6 //      NOTE! PMPageSize must be an even divisor of EMSPageSize, and >= 1024\r
7 #define EMSPageSize             16384\r
8 #define EMSPageSizeSeg  (EMSPageSize >> 4)\r
9 #define EMSPageSizeKB   (EMSPageSize >> 10)\r
10 #define EMSFrameCount   4\r
11 #define PMPageSize              4096\r
12 #define PMPageSizeSeg   (PMPageSize >> 4)\r
13 #define PMPageSizeKB    (PMPageSize >> 10)\r
14 #define PMEMSSubPage    (EMSPageSize / PMPageSize)\r
15 \r
16 #define PMMinMainMem    10                      // Min acceptable # of pages from main\r
17 #define PMMaxMainMem    100                     // Max number of pages in main memory\r
18 \r
19 #define PMThrashThreshold       1       // Number of page thrashes before panic mode\r
20 #define PMUnThrashThreshold     5       // Number of non-thrashing frames before leaving panic mode\r
21 \r
22 typedef enum\r
23                 {\r
24                         pml_Unlocked,\r
25                         pml_Locked\r
26                 } PMLockType;\r
27 \r
28 typedef enum\r
29                 {\r
30                         pmba_Unused = 0,\r
31                         pmba_Used = 1,\r
32                         pmba_Allocated = 2\r
33                 } PMBlockAttr;\r
34 \r
35 typedef struct\r
36                 {\r
37                         longword        offset;         // Offset of chunk into file\r
38                         word            length;         // Length of the chunk\r
39 \r
40                         int                     xmsPage;        // If in XMS, (xmsPage * PMPageSize) gives offset into XMS handle\r
41 \r
42                         PMLockType      locked;         // If set, this page can't be purged\r
43                         int                     emsPage;        // If in EMS, logical page/offset into page\r
44                         int                     mainPage;       // If in Main, index into handle array\r
45 \r
46                         longword        lastHit;        // Last frame number of hit\r
47                 } PageListStruct;\r
48 \r
49 typedef struct\r
50                 {\r
51                         int                     baseEMSPage;    // Base EMS page for this phys frame\r
52                         longword        lastHit;                // Last frame number of hit\r
53                 } EMSListStruct;\r
54 \r
55 extern  boolean                 XMSPresent,EMSPresent;\r
56 extern  word                    XMSPagesAvail,EMSPagesAvail;\r
57 \r
58 extern  word                    ChunksInFile,\r
59                                                 PMSpriteStart,PMSoundStart;\r
60 extern  PageListStruct  far *PMPages;\r
61 \r
62 #define PM_GetSoundPage(v)      PM_GetPage(PMSoundStart + (v))\r
63 #define PM_GetSpritePage(v)     PM_GetPage(PMSpriteStart + (v))\r
64 \r
65 #define PM_LockMainMem()        PM_SetMainMemPurge(0)\r
66 #define PM_UnlockMainMem()      PM_SetMainMemPurge(3)\r
67 \r
68 \r
69 extern  char    PageFileName[13];\r
70 \r
71 \r
72 extern  void    PM_Startup(void),\r
73                                 PM_Shutdown(void),\r
74                                 PM_Reset(void),\r
75                                 PM_Preload(boolean (*update)(word current,word total)),\r
76                                 PM_NextFrame(void),\r
77                                 PM_SetPageLock(int pagenum,PMLockType lock),\r
78                                 PM_SetMainPurge(int level),\r
79                                 PM_CheckMainMem(void);\r
80 extern  memptr  PM_GetPageAddress(int pagenum),\r
81                                 PM_GetPage(int pagenum);                // Use this one to cache page\r
82 \r
83 void PM_SetMainMemPurge(int level);\r