]> 4ch.mooo.com Git - 16.git/blob - src/lib/16_tdef.h
XCROLL IS MYSTERIOUSLY NOT WORKING
[16.git] / src / lib / 16_tdef.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 _TYPEDEFSTRUCT_H_\r
24 #define _TYPEDEFSTRUCT_H_\r
25 \r
26 #include "src/lib/16_t.h"\r
27 \r
28 #define AARED           "\x1b[41;31m"\r
29 #define AABLUE          "\x1b[44;34m"\r
30 #define AAGREEN "\x1b[42;32m"\r
31 #define AAYELLOW        "\x1b[43;33m"\r
32 #define AAGREY          "\x1b[47;37m"\r
33 #define AABLACK "\x1b[40;30m"\r
34 #define AAWHITE         "\x1b[47;37m"\r
35 #define AAMAGENTA       "\x1b[45;35m"\r
36 #define AARESET "\x1b[0m"\r
37 \r
38 #define MAXPAGE 4\r
39 \r
40 #define BDOFSCONV (unsigned __near)\r
41 #define BOFS page[1].data\r
42 #define DOFS page[0].data\r
43 \r
44 #define CONFIGNAME "config.16"\r
45 \r
46 /*\r
47  * typedefs of the game variables!\r
48  */\r
49 typedef struct {\r
50         byte *data;\r
51         word width;\r
52         word height;\r
53         byte *palette;\r
54         word offset;\r
55 } bitmap_t;\r
56 \r
57 typedef struct {\r
58         byte far **data;\r
59         word ntiles;            // the number of tiles\r
60         word twidth;    // width of the tiles\r
61         word theight;   // height of the tiles\r
62         byte *palette;  // palette for the tile set\r
63 } tileset_t;\r
64 \r
65 typedef struct {\r
66         byte far *plane[4];     // 4 planes of image data\r
67         word width;                     // width of the image (spread across 4 planes)\r
68         word height;            // height of the image (spread across 4 planes)\r
69         word pwidth;            // the number of bytes in each plane\r
70         byte *palette;\r
71 } planar_buf_t;\r
72 \r
73 //from 16_sprit.h\r
74 #ifdef  __WATCOMC__\r
75 #include <hw/vga/vrl.h>\r
76 \r
77 typedef struct vrs_container{\r
78         // Size of a .vrs blob in memory\r
79         // minus header\r
80         dword data_size;\r
81         union{\r
82                 byte far *buffer;\r
83                 struct vrs_header far *vrs_hdr;\r
84         };\r
85         // Array of corresponding vrl line offsets\r
86         vrl1_vgax_offset_t **vrl_line_offsets;\r
87         //sprite buffer\r
88         byte far _seg *spribuff;\r
89 } vrs_container_t;\r
90 \r
91 typedef struct vrl_container{\r
92         // Size of a .vrl blob in memory\r
93         // minus header\r
94         dword data_size;\r
95         union{\r
96                 byte far *buffer;\r
97                 struct vrl1_vgax_header far *vrl_header;\r
98         };\r
99         // Pointer to a corresponding vrl line offsets struct\r
100         vrl1_vgax_offset_t *line_offsets;\r
101         //sprite buffer\r
102         byte far _seg *spribuff;\r
103 } vrl_container_t;\r
104 \r
105 typedef struct sprite\r
106 {\r
107         // VRS container from which we will extract animation and image data\r
108         vrs_container_t spritesheet;\r
109         // Container for a vrl sprite\r
110         vrl_container_t sprite_vrl_cont;\r
111         // Current sprite id\r
112         int curr_spri_id;\r
113         // Index of a current sprite in an animation sequence\r
114         int curr_anim_spri;\r
115         // Current animation sequence\r
116         struct vrs_animation_list_entry_t *curr_anim_list;\r
117         // Index of current animation in relevant VRS offsets table\r
118         int curr_anim;\r
119         // Delay in time units untill we should change sprite\r
120         int delay;\r
121         // Position of sprite on screen\r
122         int x, y;\r
123 } sprite_t;\r
124 #endif\r
125 \r
126 //newer structs\r
127 typedef struct\r
128 {\r
129         int x; //entity exact position on the viewable map\r
130         int y; //entity exact position on the viewable map\r
131         int tx; //entity tile position on the viewable map\r
132         int ty; //entity tile position on the viewable map\r
133         int triggerx; //entity's trigger box tile position on the viewable map\r
134         int triggery; //entity's trigger box tile position on the viewable map\r
135 //      int sheetsetx; //NOT USED YET! entity sprite sheet set on the image x\r
136 //      int sheetsety; //NOT USED YET! entity sprite sheet set on the image y\r
137         nibble d;               //direction to render sprite!! wwww\r
138         nibble pred;    //prev. direction for animation changing\r
139         word dire;              //sprite in use\r
140         nibble q;               //loop variable for anumation and locking the playing to compleate the animation cycle to prevent issues with misalignment www\r
141         word speed;             //entity speed!\r
142         word spt;               //speed per tile\r
143 #ifdef  __WATCOMC__\r
144         sprite_t spri; // sprite used by entity\r
145 #endif\r
146         sword hp; //hitpoints of the entity\r
147         nibble overdraww, overdrawh;    // how many pixels to "overdraw" so that moving sprites with edge pixels don't leave streaks.\r
148                                                 // if the sprite's edge pixels are clear anyway, you can set this to 0.\r
149         nibble /*int*/ persist_aniframe;    // gonna be increased to 1 before being used, so 0 is ok for default\r
150 } entity_t;\r
151 \r
152 typedef struct\r
153 {\r
154         int x; //entity exact position on the viewable map\r
155         int y; //entity exact position on the viewable map\r
156         int tx; //entity tile position on the viewable map\r
157         int ty; //entity tile position on the viewable map\r
158 \r
159 #ifdef  __WATCOMC__\r
160         sprite_t spri; // sprite used by entity\r
161 #endif\r
162         sword hp; //hitpoints of the entity\r
163 } static_map_entity_t;\r
164 \r
165 //===========================================================================//\r
166 \r
167 //TODO: 16_mm and 16_ca must handle this\r
168 typedef struct {\r
169 #ifdef  __WATCOMC__\r
170         sprite_t *spri;                 // I will probibaly use this --sparky4\r
171 #endif\r
172         word tileHeight, tileWidth;     //defined by mapfile\r
173         unsigned int rows, cols;\r
174         byte    imgname[8];             //image file of tileset (set to 8 because DOS ^^;)\r
175 } tiles_t;      //seems to be the tileset properties\r
176 \r
177 //TODO: 16_mm and 16_ca must handle this\r
178 //TODO: add variables from 16_ca\r
179 typedef struct {\r
180         byte    layername[8];\r
181         byte    *data;                  //TODO: 16_mm and 16_ca must handle this\r
182 } mapl_t;       //map layer array type def\r
183 \r
184 #define MAPPLANES               3\r
185 typedef struct {\r
186         //long          planestart[3];\r
187         //unsigned      planelength[3];\r
188         mapl_t layerdata[MAPPLANES];    // mapdata for multilayer (map index values for rendering which image on the tile)\r
189         tiles_t *tiles;         //TODO: 16_mm and 16_ca must handle this        // tilesets for layers (currently ony 4 can be loaded wwww)\r
190         int width, height;              //this has to be signed!\r
191         byte name[16];\r
192 } map_t;\r
193 \r
194 //===================================//\r
195 \r
196 typedef struct{\r
197         word tw;                                /* screen width in tiles */\r
198         word th;                                /* screen height in tiles */\r
199         word tilesw;                            /* virtual screen width in tiles */\r
200         word tilesh;                            /* virtual screen height in tiles */\r
201         sword tilemidposscreenx;        /* middle tile x position */    /* needed for scroll system to work accordingly */\r
202         sword tilemidposscreeny;        /* middle tile y position */    /* needed for scroll system to work accordingly */\r
203         sword tileplayerposscreenx;     /* player position on screen */ /* needed for scroll and map system to work accordingly */\r
204         sword tileplayerposscreeny;     /* player position on screen */ /* needed for scroll and map system to work accordingly */\r
205 } pagetileinfo_t;\r
206 \r
207 typedef struct {\r
208         nibble/*word*/ id;      /* the Identification number of the page~ For layering~ */\r
209         byte far* data; /* the data for the page */\r
210         pagetileinfo_t ti;      // the tile information of the page\r
211         word dx;                /* col we are viewing on virtual screen (on page[0]) */ /* off screen buffer on the left size */\r
212         word dy;                /* row we are viewing on virtual screen (on page[0]) */ /* off screen buffer on the top size */\r
213         word sw;                /* screen width */      /* resolution */\r
214         word sh;                /* screen heigth */     /* resolution */\r
215         word width;             /* virtual width of the page */\r
216         word height;    /* virtual height of the page */\r
217         word stridew;   /* width/4 */   /* VGA */\r
218         word pagesize;  /* page size */\r
219         word pi;                /* increment page by this much to preserve location */\r
220         int tlx,tly;\r
221 //newer vars\r
222 //TODO: find where they are used\r
223         sword delta;                    // How much should we shift the page for smooth scrolling\r
224 } page_t;\r
225 \r
226 //from 16_in\r
227 //==========================================================================\r
228 #define KeyInt          9       // The keyboard ISR number\r
229 \r
230 //\r
231 // mouse constants\r
232 //\r
233 #define MReset          0\r
234 #define MButtons        3\r
235 #define MDelta          11\r
236 \r
237 #define MouseInt        0x33\r
238 //#define       Mouse(x)        _AX = x,geninterrupt(MouseInt)\r
239 \r
240 //\r
241 // joystick constants\r
242 //\r
243 #define JoyScaleMax             32768\r
244 #define JoyScaleShift   8\r
245 #define MaxJoyValue             5000\r
246 \r
247 #define MaxPlayers      4\r
248 #define MaxKbds         2\r
249 #define MaxJoys         2\r
250 #define NumCodes        128\r
251 \r
252 typedef byte            ScanCode;\r
253 \r
254 typedef enum            {\r
255                                                 //ctrl_None,                            // MDM (GAMERS EDGE) - added\r
256                                                 ctrl_Keyboard,\r
257                                                         ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2,\r
258                                                 ctrl_Joystick,\r
259                                                         ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2,\r
260                                                 ctrl_Mouse,\r
261                                         } ControlType;\r
262 typedef enum            {\r
263                                                 motion_Left = -1,motion_Up = -1,\r
264                                                 motion_None = 0,\r
265                                                 motion_Right = 1,motion_Down = 1\r
266                                         } Motion;\r
267 typedef enum            {               // Quick lookup for total direction\r
268                                                 /*dir_NorthWest,        */dir_North,/*  dir_NorthEast,*/\r
269                                                 dir_West,               dir_None,       dir_East,\r
270                                                 /*dir_SouthWest,        */dir_South/*,  dir_SouthEast*/\r
271                                         } Direction;\r
272 typedef struct          {\r
273                                                 boolean near    button0,button1,button2,button3;\r
274                                                 int     near            x,y;\r
275                                                 Motion  near    xaxis,yaxis;\r
276                                                 Direction near  dir;\r
277                                         } CursorInfo;\r
278 \r
279 typedef struct          {\r
280                                                 ScanCode near   button0,button1,\r
281                                                                         //upleft,\r
282                                                                         up,\r
283                                                                         down,\r
284                                                                         left,\r
285                                                                         right\r
286                                                                         //upright,\r
287                                                                         //downleft,\r
288                                                                         //,downright\r
289                                                                         ;\r
290                                         } KeyboardDef;\r
291 typedef struct          {\r
292                                                 word    near    joyMinX,joyMinY,\r
293                                                                         threshMinX,threshMinY,\r
294                                                                         threshMaxX,threshMaxY,\r
295                                                                         joyMaxX,joyMaxY,\r
296                                                                         joyMultXL,joyMultYL,\r
297                                                                         joyMultXH,joyMultYH;\r
298                                         } JoystickDef;\r
299 \r
300 typedef struct instat {\r
301         boolean         CapsLock;\r
302         ScanCode        CurCode,LastCode;\r
303 \r
304         boolean         Keyboard[NumCodes];\r
305         boolean         Paused;\r
306         char            LastASCII;\r
307         ScanCode        LastScan;\r
308 } inst_t;\r
309 \r
310 typedef struct// inconfig\r
311 {\r
312         boolean         IN_Started;\r
313 //\r
314 // configuration variables\r
315 //\r
316         boolean         JoysPresent[MaxJoys],\r
317                                         MousePresent,\r
318                                         JoyPadPresent;\r
319 \r
320 //      Global variables\r
321         KeyboardDef     KbdDefs[MaxKbds];\r
322         JoystickDef     JoyDefs[MaxJoys];\r
323         inst_t  *inst;\r
324 } in_info_t;\r
325 \r
326 //==========================================================================\r
327 \r
328 typedef struct\r
329 {\r
330         entity_t near   enti;\r
331 #ifdef  __WATCOMC__\r
332         //struct sprite *spri;  //supposively the sprite sheet data\r
333         //memptr                gr;\r
334 #endif\r
335 //      bitmap_t        *data;          //supposively the sprite sheet data//old format\r
336 //      bitmap_t        bmp;\r
337 \r
338         //input\r
339         byte near               pdir;   //previous direction~ used in IN_16 in IN_ReadControl()\r
340         CursorInfo              info;\r
341         ControlType     Controls;\r
342         word walktype;\r
343 //newer vars\r
344         int dx, dy, delta;      //TODO: what is this? ^^\r
345 } player_t;\r
346 \r
347 //===========================================//\r
348 \r
349 typedef struct\r
350 {\r
351         int profilehandle,debughandle,showmemhandle;\r
352         int heaphandle;\r
353 } loghandle_t;\r
354 \r
355 typedef struct\r
356 {\r
357         word frames_per_second;\r
358         clock_t t;\r
359         dword tiku;             //frames passed\r
360         word clock_start;       //timer start\r
361         word *clock;    //current time on clock\r
362         boolean fpscap; //cap the fps var\r
363         nibble wcpu;    //stored value of cpu type\r
364 } kurokku_t;\r
365 \r
366 //===================================//\r
367 #define PALSIZE                 768     //vga\r
368 #define NUMCHUNKS               416     //keen\r
369 //#define MAXSCANLINES  240     // size of ylookup table\r
370 \r
371 #define MAXSHIFTS               4\r
372 #define STARTSPRITES    0       //temp\r
373 \r
374 typedef struct\r
375 {\r
376         int     width,\r
377                 height,\r
378                 orgx,orgy,\r
379                 xl,yl,xh,yh,\r
380                 shifts;\r
381 } spritetabletype;\r
382 \r
383 typedef struct\r
384 {\r
385         unsigned        sourceoffset[MAXSHIFTS];\r
386         unsigned        planesize[MAXSHIFTS];\r
387         unsigned        width[MAXSHIFTS];\r
388         byte            data[];\r
389 } spritetype;           // the memptr for each sprite points to this\r
390 \r
391 typedef struct\r
392 {\r
393         int width,height;\r
394 } pictabletype;\r
395 \r
396 //video\r
397 typedef struct\r
398 {\r
399         word    tileHeight, tileWidth;  //defined by mapfile\r
400         word    quadwh;                 //preproccessed quad size of tilewidth and tileheight\r
401 } tile_dimention_t;\r
402 \r
403 #define MAXSCROLLEDGES 2\r
404 typedef struct\r
405 {\r
406         unsigned        panx,pany;              // panning adjustments inside port in pixels\r
407         unsigned        pansx,pansy;\r
408         unsigned        panadjust;              // panx/pany adjusted by screen resolution\r
409         int             hscrollblocks,vscrollblocks;\r
410         int             hscrolledge[MAXSCROLLEDGES],vscrolledge[MAXSCROLLEDGES];\r
411 } pan_t;\r
412 \r
413 typedef struct\r
414 {\r
415 //----  ylookup[MAXSCANLINES],\r
416         unsigned int offscreen_ofs;\r
417         unsigned int pattern_ofs;\r
418 //+-+-  unsigned        bufferofs,linewidth,displayofs;\r
419         pan_t           pan;\r
420 \r
421 } ofs_t;        //unfinished\r
422 \r
423 typedef struct\r
424 {\r
425 //doslib origi vars\r
426         byte far * omemptr;\r
427         byte vga_draw_stride;\r
428         byte vga_draw_stride_limit;             // further X clipping\r
429 //end of doslib origi vars\r
430         boolean __near rss;             //render sprite switch\r
431         boolean __near bgps;            //bg preservation render switch between old and new\r
432 } vga_state_t;\r
433 \r
434 typedef struct\r
435 {\r
436         boolean VL_Started,VL_Initiated;\r
437         char old_mode;          //old video mode before game!\r
438         sword curr_mode;                //modex curent mode\r
439         byte palette[PALSIZE], dpal[PALSIZE];   //palette array\r
440         page_t page[MAXPAGE];   //can be used as a pointer to root page[0]\r
441         word vmem_remain;       //remaining video memory\r
442         byte num_of_pages;      //number of actual pages\r
443         vga_state_t     vga_state;\r
444         sword __near sprifilei;         //player file's i\r
445         nibble __near p;                        //render page number\r
446         nibble __near sp;                       //show page number(for showpage)\r
447         boolean __near dorender;        //page flip, showpage, or render        if true\r
448         word pr[MAXPAGE][4];    //render sections of pages (this is supposed to be set up to draw sections of the screen if updated)\r
449 \r
450         nibble sfip;            //shinku_fps_indicator_page; // we're on page 1 now, shinku(). follow along please or it will not be visible.\r
451         ofs_t   ofs;            //offset vars used for doslib\r
452         word    vh;             //video combined height\r
453         tile_dimention_t        td;\r
454         //0000word startclk; float clk, tickclk;        //timer\r
455         //wolf3d vars\r
456         boolean screenfaded;\r
457         word            bordercolor;\r
458         boolean fastpalette;\r
459         byte            far     palette1[256][3],far palette2[256][3];\r
460 //????  pictabletype    _seg *pictable;\r
461         //keen/cata vars\r
462 //      spritetabletype _seg *spritetable;\r
463 //      unsigned        *shifttabletable[8];\r
464 } video_t;\r
465 \r
466 //from scroll16\r
467 //==========================================================================\r
468 typedef struct\r
469 {\r
470         map_t *map;\r
471         page_t *page;\r
472         int tx,ty; //appears to be the top left tile position on the viewable screen map\r
473         word dxThresh,dyThresh; //Threshold for physical tile switch\r
474         video_t *video; //pointer to game variables of the video\r
475         kurokku_t *kurokku;     //pointer to game variables of the kurokku\r
476         nibble __near *p;       // pointer to video's render page num\r
477         nibble __near *sp;      // pointer to video's show page num\r
478         int dx, dy;     // draw row and col var\r
479 //newer vars!\r
480         int delta, d;\r
481 } map_view_t;\r
482 /* Map is presumed to:\r
483  * 1. Have all the required layers and tilesets within itself\r
484  * 2. Have a 'fence' around accessible blocks to simplify boundary logic\r
485  * 3. Have a persistent map and tile size among the layers\r
486  * Map view is presumed to:\r
487  * 1. Calculate, store and update a panning info, which includes, but not limited to:\r
488  *      combined layer information, actual map representation (reflecting real state of the game),\r
489  *      pixel shift for smooth tile scrolling.\r
490  * 2. Provide ways to draw a visible part of map. For simplicity with smooth scrolling,\r
491  *      additional row/column is always drawn at the each side of the map. This implies that 'fence'\r
492  *      should have a sprite too. Map is drawn left-to-right, top-to-bottom.\r
493  */\r
494 \r
495 //==========================================================================\r
496 \r
497 //from 16_mm\r
498 //==========================================================================\r
499 \r
500 #define MAXBLOCKS               1024            //kd=1300 wolf3d=700 cata=600\r
501 \r
502 typedef struct mmblockstruct\r
503 {\r
504         //word  start,length,           word    blob;   //for data larger than 64k\r
505         word    start;  dword length;\r
506         unsigned        attributes;\r
507         memptr          *useptr;        // pointer to the segment start\r
508         struct mmblockstruct far *next;\r
509 } mmblocktype;\r
510 \r
511 typedef struct mmshowmemoryinfo\r
512 {\r
513         word x,y;\r
514         mmblocktype far *scan;\r
515 } mmshowmemoryinfo_t;\r
516 \r
517 typedef struct\r
518 {\r
519         dword   nearheap,farheap,EMSmem,XMSmem,mainmem;\r
520 //      boolean         PMStarted, MainPresent, EMSPresent, XMSPresent;\r
521 } mminfotype;\r
522 \r
523 typedef struct\r
524 {\r
525         boolean         mmstarted, bombonerror, mmerror;\r
526         void far        *farheap;\r
527 #ifdef __BORLANDC__\r
528         void            *nearheap;\r
529 #endif\r
530 #ifdef __WATCOMC__\r
531         void __near     *nearheap;\r
532 #endif\r
533 //----  unsigned int            EMSVer;\r
534 //----  word numUMBs,UMBbase[MAXUMBS];\r
535 //----  word                    totalEMSpages, freeEMSpages, EMSpagesmapped, EMSHandle, EMSPageFrame;\r
536 //----  dword   numUMBs,UMBbase[MAXUMBS];\r
537         mmblocktype     far mmblocks[MAXBLOCKS],far *mmhead,far *mmfree,far *mmrover,far *mmnew;\r
538         memptr  bufferseg;      //Allocates bufferseg misc buffer\r
539 } mminfo_t;\r
540 \r
541 //==========================================================================\r
542 \r
543 \r
544 //from 16_pm\r
545 //==========================================================================\r
546 \r
547 //      NOTE! PMPageSize must be an even divisor of EMSPageSize, and >= 1024\r
548 #define EMSPageSize             16384\r
549 #define EMSPageSizeSeg  (EMSPageSize >> 4)\r
550 #define EMSPageSizeKB   (EMSPageSize >> 10)\r
551 #define EMSFrameCount   4\r
552 #define PMPageSize              4096\r
553 #define PMPageSizeSeg   (PMPageSize >> 4)\r
554 #define PMPageSizeKB    (PMPageSize >> 10)\r
555 #define PMEMSSubPage    (EMSPageSize / PMPageSize)\r
556 \r
557 #define PMMinMainMem    10                      // Min acceptable # of pages from main\r
558 #define PMMaxMainMem    100                     // Max number of pages in main memory\r
559 \r
560 #define PMThrashThreshold       1       // Number of page thrashes before panic mode\r
561 #define PMUnThrashThreshold     5       // Number of non-thrashing frames before leaving panic mode\r
562 \r
563 typedef enum\r
564                 {\r
565                         pml_Unlocked,\r
566                         pml_Locked\r
567                 } PMLockType;\r
568 \r
569 typedef enum\r
570                 {\r
571                         pmba_Unused = 0,\r
572                         pmba_Used = 1,\r
573                         pmba_Allocated = 2\r
574                 } PMBlockAttr;\r
575 \r
576 typedef struct\r
577                 {\r
578                         dword   offset;         // Offset of chunk into file\r
579                         word            length;         // Length of the chunk\r
580 \r
581                         int                     xmsPage;        // If in XMS, (xmsPage * PMPageSize) gives offset into XMS handle\r
582 \r
583                         PMLockType      locked;         // If set, this page can't be purged\r
584                         int                     emsPage;        // If in EMS, logical page/offset into page\r
585                         int                     mainPage;       // If in Main, index into handle array\r
586 \r
587                         dword   lastHit;        // Last frame number of hit\r
588                 } PageListStruct;\r
589 \r
590 typedef struct\r
591                 {\r
592                         int                     baseEMSPage;    // Base EMS page for this phys frame\r
593                         dword   lastHit;                // Last frame number of hit\r
594                 } EMSListStruct;\r
595 \r
596 //      Main Mem specific variables\r
597 typedef struct\r
598 {\r
599         boolean                 MainPresent;\r
600         memptr                  MainMemPages[PMMaxMainMem];\r
601         PMBlockAttr             MainMemUsed[PMMaxMainMem];\r
602         int                             MainPagesAvail;\r
603 } pm_mmi_t;\r
604 \r
605 //      EMS specific variables\r
606 typedef struct\r
607 {\r
608         boolean                 EMSPresent;\r
609         unsigned int                    EMSVer;\r
610         word                    EMSAvail,EMSPagesAvail,EMSHandle,\r
611                                         EMSPageFrame,EMSPhysicalPage;\r
612         word                    totalEMSpages, freeEMSpages, EMSpagesmapped;\r
613         EMSListStruct   EMSList[EMSFrameCount];\r
614 } pm_emmi_t;\r
615 \r
616 //      XMS specific variables\r
617 typedef struct\r
618 {\r
619         boolean                 XMSPresent;\r
620         word                    XMSAvail,XMSPagesAvail,XMSHandle;//,XMSVer;\r
621         dword                   XMSDriver;\r
622         int                             XMSProtectPage;// = -1;\r
623 } pm_xmmi_t;\r
624 \r
625 //      File specific variables\r
626 typedef struct\r
627 {\r
628         char                    PageFileName[13];// = {"VSWAP."};\r
629         int                             PageFile;// = -1;\r
630         word                    ChunksInFile;\r
631         word                    PMSpriteStart,PMSoundStart;\r
632 } pm_fi_t;\r
633 \r
634 //      General usage variables\r
635 typedef struct\r
636 {\r
637         boolean                 PMStarted,\r
638                                         PMPanicMode,\r
639                                         PMThrashing;\r
640         word                    XMSPagesUsed,\r
641                                         EMSPagesUsed,\r
642                                         MainPagesUsed,\r
643                                         PMNumBlocks;\r
644         long                    PMFrameCount;\r
645         PageListStruct  far *PMPages,\r
646                                         _seg *PMSegPages;\r
647         pm_mmi_t        mm;\r
648         pm_emmi_t       emm;\r
649         pm_xmmi_t       xmm;\r
650         pm_fi_t fi;\r
651 } pm_t;\r
652 \r
653 //==========================================================================\r
654 \r
655 //for 16_sd\r
656 //==========================================================================\r
657 #pragma pack(push,1)\r
658 typedef struct imf_entry\r
659 {\r
660         byte            reg,data;\r
661         word            delay;\r
662 } imf_entry_t;\r
663 #pragma pack(pop)\r
664 \r
665 typedef struct\r
666 {\r
667         volatile unsigned long irq0_ticks;//=0;\r
668         volatile unsigned int irq0_cnt,irq0_add,irq0_max;//=0;\r
669         imf_entry_t*    imf_music;//=NULL;\r
670         imf_entry_t*    imf_play_ptr;//=NULL;\r
671         imf_entry_t*    imf_music_end;//=NULL;\r
672         word            imf_delay_countdown;//=0;\r
673 } sd_t;\r
674 \r
675 //==========================================================================\r
676 \r
677 //from 16_ca\r
678 //==========================================================================\r
679 \r
680 #define NOMAPS\r
681 #define NOGRAPHICS\r
682 #define NOAUDIO\r
683 \r
684 //#define MAPHEADERLINKED\r
685 //#define GRHEADERLINKED\r
686 //#define AUDIOHEADERLINKED\r
687 \r
688 #define NUMMAPS         4//39\r
689 #define NUMSNDCHUNKS            4//3\r
690 //#define NUMPICS               4//132//wolf3d wl6\r
691 \r
692 #define STRUCTPIC       0\r
693 #define CASVT           dword   //*start var type\r
694 \r
695 \r
696 #define DATADIR         "data/"\r
697 #define GDICTNAME       DATADIR"vgadict."\r
698 #define GHEADNAME       DATADIR"vgahead."\r
699 #define GFILENAME       DATADIR"vgagraph."\r
700 \r
701 \r
702 #define MAPSEGBUF       mapsegs\r
703 #define MAPSEGPTR       MAPSEGBUF[0]\r
704 #define MAPSEGINLM      (gvar->ca.MAPSEGPTR)\r
705 \r
706 typedef struct\r
707 {\r
708   word bit0,bit1;       // 0-255 is a character, > is a pointer to a node\r
709 } huffnode;\r
710 \r
711 typedef struct\r
712 {\r
713         long            planestart[3];\r
714         unsigned        planelength[3];\r
715         unsigned        width,height;\r
716         char            name[16];\r
717 } maptype;\r
718 \r
719 typedef struct\r
720 {\r
721         unsigned        RLEWtag;\r
722         long            headeroffsets[100];\r
723         byte            tileinfo[];\r
724 } mapfiletype;\r
725 \r
726 typedef struct\r
727 {\r
728         int                     maphandle;              // handle to MAPTEMP / GAMEMAPS\r
729         int                     grhandle;               // handle to EGAGRAPH\r
730         int                     audiohandle;    // handle to AUDIOT / AUDIO\r
731 } ca_handle_t;\r
732 /*\r
733 16/wf3d8086/id_ca.c:    grstarts = (long _seg *)FP_SEG(&EGAhead);\r
734 16/wf3d8086/id_ca.c:    tinf = (byte _seg *)FP_SEG(&maphead);\r
735 16/wf3d8086/id_ca.c:            pos = ((mapfiletype     _seg *)tinf)->headeroffsets[i];\r
736 16/wf3d8086/id_ca.c:    audiostarts = (long _seg *)FP_SEG(&audiohead);\r
737 16/wf3d8086/id_ca.c:            ((mapfiletype _seg *)tinf)->RLEWtag);\r
738 16/wf3d8086/id_ca.c:            ((mapfiletype _seg *)tinf)->RLEWtag);\r
739 16/wf3d8086/id_ca.c:                                    source = (byte _seg *)bufferseg+(pos-bufferstart);\r
740 */\r
741 typedef struct  //TODO: USE THIS!!!!\r
742 {\r
743         byte    ca_levelbit,ca_levelnum;\r
744         ca_handle_t             file;           //files to open\r
745 \r
746         byte            _seg    *tinf;//?? where in the id engine is this used and what is it? --sparky4\r
747         int             mapon, mapnum;\r
748         maptype         _seg    *mapheaderseg[NUMMAPS];\r
749         unsigned        _seg    *mapsegs[MAPPLANES];\r
750         void            _seg    *grsegs[NUMCHUNKS];\r
751         byte            far             grneeded[NUMCHUNKS];\r
752         word            _seg *audiosegs[NUMSNDCHUNKS];//long\r
753 \r
754         CASVT           _seg    *grstarts;      // array of offsets in egagraph, -1 for sparse//long\r
755         CASVT           _seg    *audiostarts;   // array of offsets in audio / audiot//long\r
756 \r
757 #ifdef GRHEADERLINKED\r
758         huffnode        *grhuffman;\r
759 #else\r
760         huffnode        grhuffman[63];\r
761 #endif\r
762 \r
763 #ifdef AUDIOHEADERLINKED\r
764         huffnode        *audiohuffman;\r
765 #else\r
766         huffnode        audiohuffman[63];\r
767 #endif\r
768 \r
769         CASVT           chunkcomplen,chunkexplen;//long\r
770 \r
771         sd_t            sd;\r
772         //TODO: extend! and learn from keen/wolf/catacomb's code wwww\r
773         memptr  spribuff;       //temp\r
774 } ca_t;\r
775 \r
776 //==========================================================================\r
777 \r
778 //actual global game varables!\r
779 /*typedef struct {\r
780         boolean clearmem;\r
781 } vidsw_t;\r
782 \r
783 typedef struct {\r
784         vidsw_t vsw;\r
785 } sw_t;*/\r
786 \r
787 #ifdef __WATCOMC__\r
788 extern char global_temp_status_text[512];\r
789 extern char global_temp_status_text2[512];\r
790 #endif\r
791 \r
792 typedef struct glob_game_vars\r
793 {\r
794         video_t video;  // video settings variable\r
795         ca_t            ca;     // ca stuff\r
796         pm_t            pm;     // pm stuff\r
797         loghandle_t     handle; //handles for file logging\r
798         kurokku_t       kurokku;        //clock struct\r
799         mminfo_t        mm; mminfotype  mmi;    // mm stuff\r
800         in_info_t       in;             // 16_in info\r
801         player_t        player[MaxPlayers];     // player vars\r
802         map_view_t      mv[4];\r
803 //      sw_t            sw;\r
804         boolean DLStarted;\r
805 } global_game_variables_t;\r
806 \r
807 #endif /* _TYPEDEFSTRUCT_H_ */\r