]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/typdefst.h
fix bizarre near/far sprintf problem when gv->pee not initialized by just replacing the
[16.git] / src / lib / typdefst.h
index 8ee28a5ce6a64b981aa6a18a024219f836cc0b03..d6cc2b9a635d4de6a3b6b03bef390828b577a2be 100755 (executable)
@@ -1,5 +1,5 @@
 /* Project 16 Source Code~\r
- * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 &  joncampbell123\r
+ * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
  *\r
  * This file is part of Project 16.\r
  *\r
@@ -25,7 +25,6 @@
 \r
 #include "src/lib/types.h"\r
 \r
-\r
 #define AARED          "\x1b[41;31m"\r
 #define AABLUE         "\x1b[44;34m"\r
 #define AAGREEN        "\x1b[42;32m"\r
 #define AAMAGENTA      "\x1b[45;35m"\r
 #define AARESET        "\x1b[0m"\r
 \r
+#define MAXPAGE 4\r
+\r
 /*\r
  * typedefs of the game variables!\r
  */\r
 typedef struct {\r
-       byte huge *data;\r
+       byte *data;\r
        word width;\r
        word height;\r
        byte *palette;\r
@@ -70,25 +71,38 @@ typedef struct {
        word dy;                /* row we are viewing on the virtual screen */\r
        word sw;                /* screen width */\r
        word sh;                /* screen heigth */\r
-       word tilesw;            /* screen width in tiles */\r
-       word tilesh;            /* screen height in tiles */\r
+       word tw;                /* screen width in tiles */\r
+       word th;                /* screen height in tiles */\r
        word width;             /* virtual width of the page */\r
        word height;    /* virtual height of the page */\r
-       word tw;\r
-       word th;\r
+       word tilesw;            /* virtual screen width in tiles */\r
+       word tilesh;            /* virtual screen height in tiles */\r
        sword tilemidposscreenx;        /* middle tile position */\r
        sword tilemidposscreeny;        /* middle tile position */\r
        sword tileplayerposscreenx;     /* player position on screen */\r
        sword tileplayerposscreeny;     /* player position on screen */\r
-       iword pagesize;                 /* page size */\r
+       word stridew;                   /*width/4*/\r
+       word pagesize;                  /* page size */\r
+       word pi;                                /* incremention page by this much to preserve location */\r
 } page_t;\r
 \r
 typedef struct\r
 {\r
-//     int showmemhandle;\r
-       int                     profilehandle,debughandle;\r
+       //sprite ....\r
+       boolean wwww;\r
+} spri_t;\r
+\r
+typedef struct\r
+{\r
+       //vrs with sprite ....\r
+       spri_t *spri;\r
+} vrs_t;\r
+\r
+typedef struct\r
+{\r
+       int                     profilehandle,debughandle,showmemhandle;\r
        int heaphandle;\r
-} handle_t;\r
+} loghandle_t;\r
 \r
 typedef struct\r
 {\r
@@ -100,21 +114,231 @@ typedef struct
        boolean fpscap; //cap the fps var\r
 } kurokku_t;\r
 \r
+typedef struct\r
+{\r
+       word    pn;\r
+} pan_t;\r
+\r
+//video\r
+#define NUMCHUNKS      416     //keen\r
+\r
 typedef struct\r
 {\r
        char old_mode;          //old video mode before game!\r
-       page_t page[4];         //pointer to root page[0]\r
-       dword   vmem_remain;    //remaining video memory\r
+       byte grneeded[NUMCHUNKS];\r
+       page_t page[MAXPAGE];           //pointer to root page[0]\r
+       word vmem_remain;       //remaining video memory\r
        byte num_of_pages;      //number of actual pages\r
-       boolean p;                      //render page number\r
+       boolean __near p;                       //render page number\r
+       boolean __near r;                       //page flip if true\r
+       word pr[MAXPAGE][4];    //render sections of pages\r
+       //0000word startclk; float clk, tickclk;        //timer\r
 } video_t;\r
 \r
+//from 16_mm\r
+//==========================================================================\r
+\r
+#define MAXBLOCKS              1024\r
+#define MAXUMBS                12\r
+\r
+typedef struct mmblockstruct\r
+{\r
+       word    start,length;\r
+       //word  start;  dword length;\r
+       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
+typedef struct\r
+{\r
+       dword   nearheap,farheap,EMSmem,XMSmem,mainmem;\r
+//     boolean         PMStarted, MainPresent, EMSPresent, XMSPresent;\r
+} mminfotype;\r
+\r
 typedef struct\r
 {\r
-       video_t video;  // video settings variable\r
-       byte *pee;              // message for fps\r
-       handle_t handle;        //handles for file logging\r
+       memptr bufferseg;\r
+       boolean         mmstarted, bombonerror, mmerror;\r
+       //huge void huge        *farheap;\r
+       void far        *farheap;\r
+#ifdef __BORLANDC__\r
+       void    *nearheap;\r
+#endif\r
+#ifdef __WATCOMC__\r
+       void __near     *nearheap;\r
+#endif\r
+       unsigned int            EMSVer;\r
+       word numUMBs,UMBbase[MAXUMBS];\r
+       word                    totalEMSpages, freeEMSpages, EMSpagesmapped, EMSHandle, EMSPageFrame;\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
+//==========================================================================\r
+\r
+\r
+//from 16_pm\r
+//==========================================================================\r
+\r
+//     NOTE! PMPageSize must be an even divisor of EMSPageSize, and >= 1024\r
+#define        EMSPageSize             16384\r
+#define        EMSPageSizeSeg  (EMSPageSize >> 4)\r
+#define        EMSPageSizeKB   (EMSPageSize >> 10)\r
+#define        EMSFrameCount   4\r
+#define        PMPageSize              4096\r
+#define        PMPageSizeSeg   (PMPageSize >> 4)\r
+#define        PMPageSizeKB    (PMPageSize >> 10)\r
+#define        PMEMSSubPage    (EMSPageSize / PMPageSize)\r
+\r
+#define        PMMinMainMem    10                      // Min acceptable # of pages from main\r
+#define        PMMaxMainMem    100                     // Max number of pages in main memory\r
+\r
+#define        PMThrashThreshold       1       // Number of page thrashes before panic mode\r
+#define        PMUnThrashThreshold     5       // Number of non-thrashing frames before leaving panic mode\r
+\r
+typedef        enum\r
+               {\r
+                       pml_Unlocked,\r
+                       pml_Locked\r
+               } PMLockType;\r
+\r
+typedef        enum\r
+               {\r
+                       pmba_Unused = 0,\r
+                       pmba_Used = 1,\r
+                       pmba_Allocated = 2\r
+               } PMBlockAttr;\r
+\r
+typedef        struct\r
+               {\r
+                       dword   offset;         // Offset of chunk into file\r
+                       word            length;         // Length of the chunk\r
+\r
+                       int                     xmsPage;        // If in XMS, (xmsPage * PMPageSize) gives offset into XMS handle\r
+\r
+                       PMLockType      locked;         // If set, this page can't be purged\r
+                       int                     emsPage;        // If in EMS, logical page/offset into page\r
+                       int                     mainPage;       // If in Main, index into handle array\r
+\r
+                       dword   lastHit;        // Last frame number of hit\r
+               } PageListStruct;\r
+\r
+typedef        struct\r
+               {\r
+                       int                     baseEMSPage;    // Base EMS page for this phys frame\r
+                       dword   lastHit;                // Last frame number of hit\r
+               } EMSListStruct;\r
+\r
+//     Main Mem specific variables\r
+typedef struct\r
+{\r
+       boolean                 MainPresent;\r
+       memptr                  MainMemPages[PMMaxMainMem];\r
+       PMBlockAttr             MainMemUsed[PMMaxMainMem];\r
+       int                             MainPagesAvail;\r
+} pm_mmi_t;\r
+\r
+//     EMS specific variables\r
+typedef struct\r
+{\r
+       boolean                 EMSPresent;\r
+       unsigned int                    EMSVer;\r
+       word                    EMSAvail,EMSPagesAvail,EMSHandle,\r
+                                       EMSPageFrame,EMSPhysicalPage;\r
+       word                    totalEMSpages, freeEMSpages, EMSpagesmapped;\r
+       EMSListStruct   EMSList[EMSFrameCount];\r
+} pm_emmi_t;\r
+\r
+//     XMS specific variables\r
+typedef struct\r
+{\r
+       boolean                 XMSPresent;\r
+       word                    XMSAvail,XMSPagesAvail,XMSHandle;//,XMSVer;\r
+       dword                   XMSDriver;\r
+       int                             XMSProtectPage;// = -1;\r
+} pm_xmmi_t;\r
+\r
+//     File specific variables\r
+typedef struct\r
+{\r
+       char                    PageFileName[13];// = {"VSWAP."};\r
+       int                             PageFile;// = -1;\r
+       word                    ChunksInFile;\r
+       word                    PMSpriteStart,PMSoundStart;\r
+} pm_fi_t;\r
+\r
+//     General usage variables\r
+typedef struct\r
+{\r
+       boolean                 PMStarted,\r
+                                       PMPanicMode,\r
+                                       PMThrashing;\r
+       word                    XMSPagesUsed,\r
+                                       EMSPagesUsed,\r
+                                       MainPagesUsed,\r
+                                       PMNumBlocks;\r
+       long                    PMFrameCount;\r
+       PageListStruct  far *PMPages;\r
+       __SEGA *PMSegPages;\r
+       pm_mmi_t        mm;\r
+       pm_emmi_t       emm;\r
+       pm_xmmi_t       xmm;\r
+       pm_fi_t fi;\r
+} pm_t;\r
+\r
+//==========================================================================\r
+\r
+//from 16_ca\r
+//==========================================================================\r
+\r
+#define NUMMAPS                4//39\r
+#define MAPPLANES              3\r
+\r
+typedef struct\r
+{\r
+  word bit0,bit1;      // 0-255 is a character, > is a pointer to a node\r
+} huffnode;\r
+\r
+typedef struct\r
+{\r
+       int             mapon, mapnum;\r
+       __SEGA  *mapsegs[4];\r
+       __SEGA  *mapheaderseg[NUMMAPS];\r
+       __SEGA  *tinf;\r
+} ca_mapinfo_t;\r
+\r
+typedef struct\r
+{\r
+       int                     maphandle[4];           // handle to MAPTEMP / GAMEMAPS\r
+} ca_handle_t;\r
+\r
+typedef struct\r
+{\r
+       byte            ca_levelbit,ca_levelnum;\r
+       ca_handle_t     file;           //files to open\r
+       ca_mapinfo_t    camap;\r
+       __SEGA  *grsegs[NUMCHUNKS];\r
+       byte            far     grneeded[NUMCHUNKS];\r
+       huffnode huffnode;\r
+} ca_t;\r
+\r
+//==========================================================================\r
+\r
+//actual global game varables!\r
+typedef struct\r
+{\r
+       video_t video;  // video settings variable\r
+       ca_t            ca;     // ca stuff\r
+       pm_t            pm;     // pm stuff\r
+       loghandle_t handle;     //handles for file logging\r
        kurokku_t kurokku;      //clock struct\r
+       mminfo_t mm; mminfotype mmi;\r
 } global_game_variables_t;\r
 \r
+extern char global_temp_status_text[512];\r
+\r
 #endif /* _TYPEDEFSTRUCT_H_ */\r