]> 4ch.mooo.com Git - 16.git/blob - src/lib/16_tdef.h
pcxtest.exe and pcxtest2.exe compiles but we are unable to test because of compiling...
[16.git] / src / lib / 16_tdef.h
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2022 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 far *plane[4];     // 4 planes of image data\r
51         word width;                     // width of the image (spread across 4 planes)\r
52         word height;            // height of the image (spread across 4 planes)\r
53         word pwidth;            // the number of bytes in each plane\r
54         byte *palette;\r
55 } planar_buf_t;\r
56 \r
57 typedef struct {\r
58         byte *data;\r
59         word width;\r
60         word height;\r
61         byte *palette;\r
62         word offset;\r
63 } bitmap_t;\r
64 \r
65 typedef struct {\r
66         byte far **data;\r
67         word ntiles;            // the number of tiles\r
68         word twidth;    // width of the tiles\r
69         word theight;   // height of the tiles\r
70         byte *palette;  // palette for the tile set\r
71 } tileset_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         byte datadumpfilename[12];\r
354         byte heapdumpfilename[12];\r
355 } loghandle_t;\r
356 \r
357 typedef struct\r
358 {\r
359         word frames_per_second;\r
360         clock_t t;\r
361         dword tiku;             //frames passed\r
362         word clock_start;       //timer start\r
363         word *clock;    //current time on clock\r
364         boolean fpscap; //cap the fps var\r
365         nibble wcpu;    //stored value of cpu type\r
366 } kurokku_t;\r
367 \r
368 //===================================//\r
369 #define PALSIZE                 768     //vga\r
370 #define NUMCHUNKS               416     //keen\r
371 //#define MAXSCANLINES  240     // size of ylookup table\r
372 \r
373 #define MAXSHIFTS               4\r
374 #define STARTSPRITES    0       //temp\r
375 \r
376 typedef struct\r
377 {\r
378         int     width,\r
379                 height,\r
380                 orgx,orgy,\r
381                 xl,yl,xh,yh,\r
382                 shifts;\r
383 } spritetabletype;\r
384 \r
385 typedef struct\r
386 {\r
387         unsigned        sourceoffset[MAXSHIFTS];\r
388         unsigned        planesize[MAXSHIFTS];\r
389         unsigned        width[MAXSHIFTS];\r
390         byte            data[];\r
391 } spritetype;           // the memptr for each sprite points to this\r
392 \r
393 typedef struct\r
394 {\r
395         int width,height;\r
396 } pictabletype;\r
397 \r
398 //video\r
399 typedef struct\r
400 {\r
401         word    tileHeight, tileWidth;  //defined by mapfile\r
402         word    quadwh;                 //preproccessed quad size of tilewidth and tileheight\r
403 } tile_dimention_t;\r
404 \r
405 #define MAXSCROLLEDGES 2\r
406 typedef struct\r
407 {\r
408         unsigned        panx,pany;              // panning adjustments inside port in pixels\r
409         unsigned        pansx,pansy;\r
410         unsigned        panadjust;              // panx/pany adjusted by screen resolution\r
411         int             hscrollblocks,vscrollblocks;\r
412         int             hscrolledge[MAXSCROLLEDGES],vscrolledge[MAXSCROLLEDGES];\r
413 } pan_t;\r
414 \r
415 typedef struct\r
416 {\r
417         sword x;\r
418         sword y;\r
419         word t;\r
420         boolean tlsw;\r
421         word color;\r
422         word bgcolor;\r
423 } modexprint_t;\r
424 \r
425 typedef struct\r
426 {\r
427 //----  ylookup[MAXSCANLINES],\r
428         unsigned int offscreen_ofs;\r
429         unsigned int pattern_ofs;\r
430 //+-+-  unsigned        bufferofs,linewidth,displayofs;\r
431         pan_t           pan;\r
432 \r
433 } ofs_t;        //unfinished\r
434 \r
435 typedef struct\r
436 {\r
437 //doslib origi vars\r
438         byte far * omemptr;\r
439         byte vga_draw_stride;\r
440         byte vga_draw_stride_limit;             // further X clipping\r
441 //end of doslib origi vars\r
442         boolean __near rss;             //render sprite switch\r
443         boolean __near bgps;            //bg preservation render switch between old and new\r
444 } vga_state_t;\r
445 \r
446 typedef struct\r
447 {\r
448         boolean VL_Started,VL_Initiated;\r
449         char old_mode;          //old video mode before game!\r
450         sword curr_mode;                //modex curent mode\r
451         byte palette[PALSIZE], dpal[PALSIZE];   //palette array\r
452         page_t page[MAXPAGE];   //can be used as a pointer to root page[0]\r
453         word vmem_remain;       //remaining video memory\r
454         byte num_of_pages;      //number of actual pages\r
455         vga_state_t     vga_state;\r
456         sword __near sprifilei;         //player file's i\r
457         nibble __near p;                        //render page number\r
458         nibble __near sp;                       //show page number(for showpage)\r
459         boolean __near dorender;        //page flip, showpage, or render        if true\r
460         word pr[MAXPAGE][4];    //render sections of pages (this is supposed to be set up to draw sections of the screen if updated)\r
461 \r
462         nibble sfip;            //shinku_fps_indicator_page; // we're on page 1 now, shinku(). follow along please or it will not be visible.\r
463         ofs_t   ofs;            //offset vars used for doslib\r
464         word    vh;             //video combined height\r
465         modexprint_t    print;  //modexprint variables\r
466         tile_dimention_t        td;\r
467         //0000word startclk; float clk, tickclk;        //timer\r
468         //wolf3d vars\r
469         boolean screenfaded;\r
470         word            bordercolor;\r
471         boolean fastpalette;\r
472         byte            far     palette1[256][3],far palette2[256][3];\r
473 //????  pictabletype    _seg *pictable;\r
474         //keen/cata vars\r
475 //      spritetabletype _seg *spritetable;\r
476 //      unsigned        *shifttabletable[8];\r
477 } video_t;\r
478 \r
479 //from scroll16\r
480 //==========================================================================\r
481 typedef struct\r
482 {\r
483         map_t *map;\r
484         page_t *page;\r
485         int tx,ty; //appears to be the top left tile position on the viewable screen map\r
486         word dxThresh,dyThresh; //Threshold for physical tile switch\r
487         video_t *video; //pointer to game variables of the video\r
488         kurokku_t *kurokku;     //pointer to game variables of the kurokku\r
489         nibble __near *p;       // pointer to video's render page num\r
490         nibble __near *sp;      // pointer to video's show page num\r
491         int dx, dy;     // draw row and col var\r
492 //newer vars!\r
493         int delta, d;\r
494 } map_view_t;\r
495 /* Map is presumed to:\r
496  * 1. Have all the required layers and tilesets within itself\r
497  * 2. Have a 'fence' around accessible blocks to simplify boundary logic\r
498  * 3. Have a persistent map and tile size among the layers\r
499  * Map view is presumed to:\r
500  * 1. Calculate, store and update a panning info, which includes, but not limited to:\r
501  *      combined layer information, actual map representation (reflecting real state of the game),\r
502  *      pixel shift for smooth tile scrolling.\r
503  * 2. Provide ways to draw a visible part of map. For simplicity with smooth scrolling,\r
504  *      additional row/column is always drawn at the each side of the map. This implies that 'fence'\r
505  *      should have a sprite too. Map is drawn left-to-right, top-to-bottom.\r
506  */\r
507 \r
508 //==========================================================================\r
509 \r
510 //from 16_mm\r
511 //==========================================================================\r
512 \r
513 #define MAXBLOCKS               1024            //kd=1300 wolf3d=700 cata=600\r
514 \r
515 typedef struct mmblockstruct\r
516 {\r
517         //word  start,length,           blob;   //for data larger than 64k\r
518         word    start;  dword length;\r
519         unsigned        attributes;\r
520         memptr          *useptr;        // pointer to the segment start\r
521         struct mmblockstruct far *next;\r
522 } mmblocktype;\r
523 \r
524 typedef struct mmshowmemoryinfo\r
525 {\r
526 //      unsigned x,y;\r
527         mmblocktype far *scan;\r
528 } mmshowmemoryinfo_t;\r
529 \r
530 typedef struct\r
531 {\r
532         dword   nearheap,farheap,EMSmem,XMSmem,mainmem;\r
533 //      boolean         PMStarted, MainPresent, EMSPresent, XMSPresent;\r
534 } mminfotype;\r
535 \r
536 typedef struct\r
537 {\r
538         boolean         mmstarted, bombonerror, mmerror;\r
539         void far        *farheap;\r
540 #ifdef __BORLANDC__\r
541         void            *nearheap;\r
542 #endif\r
543 #ifdef __WATCOMC__\r
544         void __near     *nearheap;\r
545 #endif\r
546 //----  unsigned int            EMSVer;\r
547 //----  word numUMBs,UMBbase[MAXUMBS];\r
548 //----  word                    totalEMSpages, freeEMSpages, EMSpagesmapped, EMSHandle, EMSPageFrame;\r
549 //----  dword   numUMBs,UMBbase[MAXUMBS];\r
550         mmblocktype     far mmblocks[MAXBLOCKS],far *mmhead,far *mmfree,far *mmrover,far *mmnew;\r
551         memptr  bufferseg;      //Allocates bufferseg misc buffer\r
552 } mminfo_t;\r
553 \r
554 //==========================================================================\r
555 \r
556 \r
557 //from 16_pm\r
558 //==========================================================================\r
559 \r
560 //      NOTE! PMPageSize must be an even divisor of EMSPageSize, and >= 1024\r
561 #define EMSPageSize             16384\r
562 #define EMSPageSizeSeg  (EMSPageSize >> 4)\r
563 #define EMSPageSizeKB   (EMSPageSize >> 10)\r
564 #define EMSFrameCount   4\r
565 #define PMPageSize              4096\r
566 #define PMPageSizeSeg   (PMPageSize >> 4)\r
567 #define PMPageSizeKB    (PMPageSize >> 10)\r
568 #define PMEMSSubPage    (EMSPageSize / PMPageSize)\r
569 \r
570 #define PMMinMainMem    10                      // Min acceptable # of pages from main\r
571 #define PMMaxMainMem    100                     // Max number of pages in main memory\r
572 \r
573 #define PMThrashThreshold       1       // Number of page thrashes before panic mode\r
574 #define PMUnThrashThreshold     5       // Number of non-thrashing frames before leaving panic mode\r
575 \r
576 typedef enum\r
577                 {\r
578                         pml_Unlocked,\r
579                         pml_Locked\r
580                 } PMLockType;\r
581 \r
582 typedef enum\r
583                 {\r
584                         pmba_Unused = 0,\r
585                         pmba_Used = 1,\r
586                         pmba_Allocated = 2\r
587                 } PMBlockAttr;\r
588 \r
589 typedef struct\r
590                 {\r
591                         dword   offset;         // Offset of chunk into file\r
592                         word            length;         // Length of the chunk\r
593 \r
594                         int                     xmsPage;        // If in XMS, (xmsPage * PMPageSize) gives offset into XMS handle\r
595 \r
596                         PMLockType      locked;         // If set, this page can't be purged\r
597                         int                     emsPage;        // If in EMS, logical page/offset into page\r
598                         int                     mainPage;       // If in Main, index into handle array\r
599 \r
600                         dword   lastHit;        // Last frame number of hit\r
601                 } PageListStruct;\r
602 \r
603 typedef struct\r
604                 {\r
605                         int                     baseEMSPage;    // Base EMS page for this phys frame\r
606                         dword   lastHit;                // Last frame number of hit\r
607                 } EMSListStruct;\r
608 \r
609 //      Main Mem specific variables\r
610 typedef struct\r
611 {\r
612         boolean                 MainPresent;\r
613         memptr                  MainMemPages[PMMaxMainMem];\r
614         PMBlockAttr             MainMemUsed[PMMaxMainMem];\r
615         int                             MainPagesAvail;\r
616 } pm_mmi_t;\r
617 \r
618 //      EMS specific variables\r
619 typedef struct\r
620 {\r
621         boolean                 EMSPresent;\r
622         unsigned int                    EMSVer;\r
623         word                    EMSAvail,EMSPagesAvail,EMSHandle,\r
624                                         EMSPageFrame,EMSPhysicalPage;\r
625         word                    totalEMSpages, freeEMSpages, EMSpagesmapped;\r
626         EMSListStruct   EMSList[EMSFrameCount];\r
627 } pm_emmi_t;\r
628 \r
629 //      XMS specific variables\r
630 typedef struct\r
631 {\r
632         boolean                 XMSPresent;\r
633         word                    XMSAvail,XMSPagesAvail,XMSHandle;//,XMSVer;\r
634         dword                   XMSDriver;\r
635         int                             XMSProtectPage;// = -1;\r
636 } pm_xmmi_t;\r
637 \r
638 //      File specific variables\r
639 typedef struct\r
640 {\r
641         char                    PageFileName[13];// = {"VSWAP."};\r
642         int                             PageFile;// = -1;\r
643         word                    ChunksInFile;\r
644         word                    PMSpriteStart,PMSoundStart;\r
645 } pm_fi_t;\r
646 \r
647 //      General usage variables\r
648 typedef struct\r
649 {\r
650         boolean                 PMStarted,\r
651                                         PMPanicMode,\r
652                                         PMThrashing;\r
653         word                    XMSPagesUsed,\r
654                                         EMSPagesUsed,\r
655                                         MainPagesUsed,\r
656                                         PMNumBlocks;\r
657         long                    PMFrameCount;\r
658         PageListStruct  far *PMPages,\r
659                                         _seg *PMSegPages;\r
660         pm_mmi_t        mm;\r
661         pm_emmi_t       emm;\r
662         pm_xmmi_t       xmm;\r
663         pm_fi_t fi;\r
664 } pm_t;\r
665 \r
666 //==========================================================================\r
667 \r
668 //for 16_sd\r
669 //==========================================================================\r
670 \r
671 /////////////////////////////////////////////////\r
672 //\r
673 // MUSE Header for .WL6\r
674 // Created Tue Jul 14 15:04:53 1992\r
675 //\r
676 /////////////////////////////////////////////////\r
677 \r
678 #define NUMSOUNDS               87\r
679 //--#define NUMSNDCHUNKS                288\r
680 \r
681 //\r
682 // Sound names & indexes\r
683 //\r
684 typedef enum {\r
685                 HITWALLSND,              // 0\r
686                 SELECTWPNSND,            // 1\r
687                 SELECTITEMSND,           // 2\r
688                 LASTSOUND\r
689              } soundnames;\r
690 \r
691 //\r
692 // Base offsets\r
693 //\r
694 #define STARTPCSOUNDS           0\r
695 #define STARTADLIBSOUNDS        87\r
696 #define STARTDIGISOUNDS         174\r
697 #define STARTMUSIC              0//++++261\r
698 \r
699 //\r
700 // Music names & indexes\r
701 //\r
702 typedef enum {\r
703                 CORNER_MUS,              // 0\r
704                 LASTMUSIC\r
705              } musicnames;\r
706 \r
707 /////////////////////////////////////////////////\r
708 //\r
709 // Thanks for playing with MUSE!\r
710 //\r
711 /////////////////////////////////////////////////\r
712 \r
713 #pragma pack(push,1)\r
714 typedef struct imf_entry\r
715 {\r
716         byte            reg,data;\r
717         word            delay;\r
718 } imf_entry_t;\r
719 #pragma pack(pop)\r
720 \r
721 typedef struct\r
722 {\r
723         volatile unsigned long irq0_ticks;//=0;\r
724         volatile unsigned int irq0_cnt,irq0_add,irq0_max;//=0;\r
725         imf_entry_t*    imf_music;//=NULL;\r
726         imf_entry_t*    imf_play_ptr;//=NULL;\r
727         imf_entry_t*    imf_music_end;//=NULL;\r
728         word            imf_delay_countdown;//=0;\r
729         dword           ptick,tickrate;\r
730 } sd_t;\r
731 \r
732 //==========================================================================\r
733 \r
734 //from 16_ca\r
735 //==========================================================================\r
736 \r
737 #define NOMAPS\r
738 #define NOGRAPHICS\r
739 #define NOAUDIO\r
740 \r
741 //#define MAPHEADERLINKED\r
742 //#define GRHEADERLINKED\r
743 //#define AUDIOHEADERLINKED\r
744 \r
745 #define NUMMAPS         4//39\r
746 #define NUMSNDCHUNKS            4//3\r
747 //#define NUMPICS               4//132//wolf3d wl6\r
748 \r
749 #define STRUCTPIC       0\r
750 #define CASVT           dword   //*start var type\r
751 \r
752 \r
753 #define DATADIR         "data/"\r
754 #define GDICTNAME       DATADIR"vgadict."\r
755 #define GHEADNAME       DATADIR"vgahead."\r
756 #define GFILENAME       DATADIR"vgagraph."\r
757 \r
758 \r
759 #define MAPSEGBUF       mapsegs\r
760 #define MAPSEGPTR       MAPSEGBUF[0]\r
761 #define MAPSEGINLM      (gvar->ca.MAPSEGPTR)\r
762 \r
763 typedef struct\r
764 {\r
765   word bit0,bit1;       // 0-255 is a character, > is a pointer to a node\r
766 } huffnode;\r
767 \r
768 typedef struct\r
769 {\r
770         long            planestart[3];\r
771         unsigned        planelength[3];\r
772         unsigned        width,height;\r
773         char            name[16];\r
774 } maptype;\r
775 \r
776 typedef struct\r
777 {\r
778         unsigned        RLEWtag;\r
779         long            headeroffsets[100];\r
780         byte            tileinfo[];\r
781 } mapfiletype;\r
782 \r
783 typedef struct\r
784 {\r
785         int                     maphandle;              // handle to MAPTEMP / GAMEMAPS\r
786         int                     grhandle;               // handle to EGAGRAPH\r
787         int                     audiohandle;    // handle to AUDIOT / AUDIO\r
788 } ca_handle_t;\r
789 /*\r
790 16/wf3d8086/id_ca.c:    grstarts = (long _seg *)FP_SEG(&EGAhead);\r
791 16/wf3d8086/id_ca.c:    tinf = (byte _seg *)FP_SEG(&maphead);\r
792 16/wf3d8086/id_ca.c:            pos = ((mapfiletype     _seg *)tinf)->headeroffsets[i];\r
793 16/wf3d8086/id_ca.c:    audiostarts = (long _seg *)FP_SEG(&audiohead);\r
794 16/wf3d8086/id_ca.c:            ((mapfiletype _seg *)tinf)->RLEWtag);\r
795 16/wf3d8086/id_ca.c:            ((mapfiletype _seg *)tinf)->RLEWtag);\r
796 16/wf3d8086/id_ca.c:                                    source = (byte _seg *)bufferseg+(pos-bufferstart);\r
797 */\r
798 typedef struct  //TODO: USE THIS!!!!\r
799 {\r
800         byte    ca_levelbit,ca_levelnum;\r
801         ca_handle_t             file;           //files to open\r
802 \r
803         byte            _seg    *tinf;//?? where in the id engine is this used and what is it? --sparky4\r
804         int             mapon, mapnum;\r
805         maptype         _seg    *mapheaderseg[NUMMAPS];\r
806         unsigned        _seg    *mapsegs[MAPPLANES];\r
807         void            _seg    *grsegs[NUMCHUNKS];\r
808         byte            far             grneeded[NUMCHUNKS];\r
809         word            _seg *audiosegs[NUMSNDCHUNKS];//long\r
810 \r
811         CASVT           _seg    *grstarts;      // array of offsets in egagraph, -1 for sparse//long\r
812         CASVT           _seg    *audiostarts;   // array of offsets in audio / audiot//long\r
813 \r
814 #ifdef GRHEADERLINKED\r
815         huffnode        *grhuffman;\r
816 #else\r
817         huffnode        grhuffman[63];\r
818 #endif\r
819 \r
820 #ifdef AUDIOHEADERLINKED\r
821         huffnode        *audiohuffman;\r
822 #else\r
823         huffnode        audiohuffman[63];\r
824 #endif\r
825 \r
826         CASVT           chunkcomplen,chunkexplen;//long\r
827 \r
828         sd_t            sd;\r
829         //TODO: extend! and learn from keen/wolf/catacomb's code wwww\r
830         memptr  spribuff[64];   //temp\r
831 } ca_t;\r
832 \r
833 //==========================================================================\r
834 \r
835 //actual global game varables!\r
836 /*typedef struct {\r
837         boolean clearmem;\r
838 } vidsw_t;\r
839 \r
840 typedef struct {\r
841         vidsw_t vsw;\r
842 } sw_t;*/\r
843 \r
844 #ifdef __WATCOMC__\r
845 extern char global_temp_status_text[512];\r
846 extern char global_temp_status_text2[512];\r
847 #endif\r
848 \r
849 typedef struct glob_game_vars\r
850 {\r
851         video_t video;  // video settings variable\r
852         ca_t            ca;     // ca stuff\r
853         pm_t            pm;     // pm stuff\r
854         loghandle_t     handle; //handles for file logging\r
855         kurokku_t       kurokku;        //clock struct\r
856         mminfo_t        mm; mminfotype  mmi;    // mm stuff\r
857         in_info_t       in;             // 16_in info\r
858         player_t        player[MaxPlayers];     // player vars\r
859         map_view_t      mv[4];\r
860         map_t           map;\r
861 //      sw_t            sw;\r
862         boolean DLStarted;\r
863 } global_game_variables_t;\r
864 \r
865 #endif /* _TYPEDEFSTRUCT_H_ */\r