]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_tdef.h
Revert "too tired to continue"
[16.git] / src / lib / 16_tdef.h
index 152f509dd0315cd8705203a575bb4e3b3c35c7f9..38fd2260f04af464ee6acd7144bbd04eb3c6954b 100755 (executable)
@@ -1,5 +1,5 @@
 /* Project 16 Source Code~\r
- * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
+ * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
  *\r
  * This file is part of Project 16.\r
  *\r
@@ -57,51 +57,209 @@ typedef struct {
 } tileset_t;\r
 \r
 typedef struct {\r
-       byte far *plane[4];     /* 4 planes of image data */\r
-       word width;         /* width of the image (spread across 4 planes) */\r
-       word height;        /* height of the image (spread across 4 planes) */\r
-       word pwidth;        /* the number of bytes in each plane */\r
+       byte far *plane[4];     // 4 planes of image data\r
+       word width;                     // width of the image (spread across 4 planes)\r
+       word height;            // height of the image (spread across 4 planes)\r
+       word pwidth;            // the number of bytes in each plane\r
        byte *palette;\r
 } planar_buf_t;\r
 \r
+//TODO: 16_mm and 16_ca must handle this\r
 typedef struct {\r
-       /*nibble*/word id;      /* the Identification number of the page~ For layering~ */\r
-       byte far* data; /* the data for the page */\r
-       word dx;                /* col we are viewing on the virtual screen */  /* off screen buffer on the left size */\r
-       word dy;                /* row we are viewing on the virtual screen */  /* off screen buffer on the top size */\r
-       word sw;                /* screen width */      /* resolution */\r
-       word sh;                /* screen heigth */     /* resolution */\r
+       bitmap_t far *data;             //old\r
+       //planar_buf_t far *data;       //old\r
+       word tileHeight, tileWidth;\r
+       unsigned int rows, cols;\r
+//     #ifdef __DEBUG__\r
+//     boolean debug_text;     //show the value of the tile! wwww\r
+//     byte *debug_data;\r
+//     #endif\r
+       byte    imgname[8];             //image file of tileset\r
+} tiles_t;\r
+\r
+//TODO: 16_mm and 16_ca must handle this\r
+//TODO: add variables from 16_ca\r
+//#define __NEWMAPTILEDATAVARS__\r
+\r
+#ifdef __NEWMAPTILEDATAVARS__\r
+#define MAPLAYERS 4\r
+#define MAPTILESPTR            layertile[0]\r
+#define MAPTILESPTK            layertile[k]\r
+#define MAPDATAPTR             layerdata[0]\r
+#define MAPDATAPTK             layerdata[k]\r
+#else\r
+#define MAPTILESPTR            tiles//layertile[0]\r
+#define MAPTILESPTK            tiles//layertile[k]\r
+#define MAPDATAPTR             data//layerdata[0]\r
+#define MAPDATAPTK             data//layerdata[k]\r
+#endif\r
+typedef struct {\r
+       //long          planestart[3];\r
+       //unsigned      planelength[3];\r
+#ifndef __NEWMAPTILEDATAVARS__\r
+       byte *data;                     //TODO: 16_mm and 16_ca must handle this\r
+       tiles_t *tiles;         //TODO: 16_mm and 16_ca must handle this\r
+#else\r
+       byte * far *layerdata;  //TODO: 16_mm and 16_ca must handle this\r
+       tiles_t far *layertile[MAPLAYERS];      //TODO: 16_mm and 16_ca must handle this\r
+#endif\r
+       int width, height;              //this has to be signed!\r
+       byte name[16];\r
+} map_t;\r
+\r
+typedef struct{\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 tilesw;            /* virtual screen width in tiles */\r
        word tilesh;            /* virtual screen height in tiles */\r
        sword tilemidposscreenx;        /* middle tile x position */    /* needed for scroll system to work accordingly */\r
        sword tilemidposscreeny;        /* middle tile y position */    /* needed for scroll system to work accordingly */\r
        sword tileplayerposscreenx;     /* player position on screen */ /* needed for scroll and map system to work accordingly */\r
        sword tileplayerposscreeny;     /* player position on screen */ /* needed for scroll and map system to work accordingly */\r
+} tileinfo_t;\r
+\r
+typedef struct {\r
+       nibble/*word*/ id;      /* the Identification number of the page~ For layering~ */\r
+       byte far* data; /* the data for the page */\r
+       tileinfo_t      ti;\r
+       word dx;                /* col we are viewing on virtual screen (on page[0]) */ /* off screen buffer on the left size */\r
+       word dy;                /* row we are viewing on virtual screen (on page[0]) */ /* off screen buffer on the top size */\r
+       word sw;                /* screen width */      /* resolution */\r
+       word sh;                /* screen heigth */     /* resolution */\r
+       word width;             /* virtual width of the page */\r
+       word height;    /* virtual height of the page */\r
        word stridew;                   /* width/4 */   /* VGA */\r
        word pagesize;                  /* page size */\r
        word pi;                                /* increment page by this much to preserve location */\r
+       int tlx,tly;\r
 //newer vars\r
 //TODO: find where they are used\r
        sword delta;                    // How much should we shift the page for smooth scrolling\r
 } page_t;\r
 \r
-//TODO: MAKE THIS WWWW\r
-typedef struct\r
+//from 16_sprit.h\r
+#ifdef __WATCOMC__\r
+typedef struct sprite\r
 {\r
-       //sprite ....\r
-       boolean wwww;\r
-} spri_t;\r
+       // VRS container from which we will extract animation and image data\r
+       struct vrs_container *spritesheet;\r
+       // Container for a vrl sprite\r
+       struct vrl_container *sprite_vrl_cont;\r
+       // Current sprite id\r
+       int curr_spri_id;\r
+       // Index of a current sprite in an animation sequence\r
+       int curr_anim_spri;\r
+       // Current animation sequence\r
+       struct vrs_animation_list_entry_t *curr_anim_list;\r
+       // Index of current animation in relevant VRS offsets table\r
+       int curr_anim;\r
+       // Delay in time units untill we should change sprite\r
+       int delay;\r
+       // Position of sprite on screen\r
+       int x, y;\r
+} sprite_t;\r
+#endif\r
 \r
-//TODO: MAKE THIS TO WWWW\r
-typedef struct\r
+//newer structs\r
+typedef        struct\r
 {\r
-       //vrs with sprite ....\r
-       spri_t *spri;\r
-} vrs_t;\r
+       int x; //entity exact position on the viewable map\r
+       int y; //entity exact position on the viewable map\r
+       int tx; //entity tile position on the viewable map\r
+       int ty; //entity tile position on the viewable map\r
+       int triggerx; //entity's trigger box tile position on the viewable map\r
+       int triggery; //entity's trigger box tile position on the viewable map\r
+//     int sheetsetx; //NOT USED YET! entity sprite sheet set on the image x\r
+//     int sheetsety; //NOT USED YET! entity sprite sheet set on the image y\r
+       nibble d;               //direction to render sprite!! wwww\r
+       nibble pred;    //prev. direction for animation changing\r
+       word dire;              //sprite in use\r
+       nibble q;               //loop variable for anumation and locking the playing to compleate the animation cycle to prevent issues with misalignment www\r
+       word speed;             //entity speed!\r
+       word spt;               //speed per tile\r
+#ifdef __WATCOMC__\r
+       sprite_t *spri; // sprite used by entity\r
+#endif\r
+       sword hp; //hitpoints of the entity\r
+       nibble overdraww, overdrawh;    // how many pixels to "overdraw" so that moving sprites with edge pixels don't leave streaks.\r
+                                               // if the sprite's edge pixels are clear anyway, you can set this to 0.\r
+       nibble /*int*/ persist_aniframe;    // gonna be increased to 1 before being used, so 0 is ok for default\r
+} entity_t;\r
+\r
+//from 16_in\r
+//==========================================================================\r
+typedef        byte            ScanCode;\r
+\r
+typedef        enum            {\r
+                                               //ctrl_None,                            // MDM (GAMERS EDGE) - added\r
+                                               ctrl_Keyboard,\r
+                                                       ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2,\r
+                                               ctrl_Joystick,\r
+                                                       ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2,\r
+                                               ctrl_Mouse,\r
+                                       } ControlType;\r
+typedef        enum            {\r
+                                               motion_Left = -1,motion_Up = -1,\r
+                                               motion_None = 0,\r
+                                               motion_Right = 1,motion_Down = 1\r
+                                       } Motion;\r
+typedef        enum            {\r
+                                               dir_North,//dir_NorthEast,\r
+                                               dir_West,//dir_Nortinest,\r
+                                               dir_None,\r
+                                               dir_East,//,dir_SouthEast,\r
+                                               dir_South,//dir_Soutinest,\r
+                                       } Direction;\r
+typedef        struct          {\r
+                                               boolean near    button0,button1,button2,button3;\r
+                                               int     near            x,y;\r
+                                               Motion  near    xaxis,yaxis;\r
+                                               Direction near  dir;\r
+                                       } CursorInfo;\r
+\r
+typedef        struct          {\r
+                                               ScanCode near   button0,button1,\r
+                                                                       //upleft,\r
+                                                                       up,\r
+                                                                       down,\r
+                                                                       left,\r
+                                                                       right\r
+                                                                       //upright,\r
+                                                                       //downleft,\r
+                                                                       //,downright\r
+                                                                       ;\r
+                                       } KeyboardDef;\r
+typedef        struct          {\r
+                                               word    near    joyMinX,joyMinY,\r
+                                                                       threshMinX,threshMinY,\r
+                                                                       threshMaxX,threshMaxY,\r
+                                                                       joyMaxX,joyMaxY,\r
+                                                                       joyMultXL,joyMultYL,\r
+                                                                       joyMultXH,joyMultYH;\r
+                                       } JoystickDef;\r
+\r
+//==========================================================================\r
+\r
+typedef        struct\r
+{\r
+       entity_t near   enti;\r
+#ifdef __WATCOMC__\r
+       //struct sprite *spri;  //supposively the sprite sheet data\r
+       memptr          gr;\r
+#endif\r
+       bitmap_t        *data;          //supposively the sprite sheet data//old format\r
+       bitmap_t        bmp;\r
+\r
+       //input\r
+       byte near               pdir;   //previous direction~ used in IN_16 in IN_ReadControl()\r
+       CursorInfo              info;\r
+       ControlType     Controls;\r
+       word walktype;\r
+//newer vars\r
+       int dx, dy, delta;      //TODO: what is this? ^^\r
+} player_t;\r
+\r
+//===========================================//\r
 \r
 typedef struct\r
 {\r
@@ -119,29 +277,73 @@ typedef struct
        boolean fpscap; //cap the fps var\r
 } kurokku_t;\r
 \r
+//video\r
 typedef struct\r
 {\r
-       word    pn;\r
-} pan_t;\r
-\r
-//video\r
+       unsigned int offscreen_ofs;\r
+       unsigned int pattern_ofs;\r
+} ofs_t;\r
 #define NUMCHUNKS      416     //keen\r
 \r
 typedef struct\r
 {\r
        char old_mode;          //old video mode before game!\r
+       byte palette[768];              //palette array\r
        page_t page[MAXPAGE];   //can be used as a pointer to root page[0]\r
        word vmem_remain;       //remaining video memory\r
        byte num_of_pages;      //number of actual pages\r
-       boolean __near p;                       //render page number\r
-       boolean __near r;                       //page flip if true\r
+       //doslib origi vars\r
+       byte far * omemptr;\r
+       byte vga_draw_stride;\r
+       byte vga_draw_stride_limit;             // further X clipping\r
+       //end of doslib origi vars\r
+       boolean __near rss;             //render sprite switch\r
+       boolean __near bgps;            //bg preservation render switch between old and new\r
+       sword __near sprifilei;         //player file's i\r
+       nibble __near p;                        //render page number\r
+       nibble __near sp;                       //show page number(for showpage)\r
+       boolean __near dorender;        //page flip, showpage, or render        if true\r
        word pr[MAXPAGE][4];    //render sections of pages (this is supposed to be set up to draw sections of the screen if updated)\r
+\r
+       nibble sfip;            //shinku_fps_indicator_page; // we're on page 1 now, shinku(). follow along please or it will not be visible.\r
+       ofs_t   ofs;            //offset vars used for doslib\r
+       word    vh;             //video combined height\r
        //0000word startclk; float clk, tickclk;        //timer\r
 //newer vars\r
 //TODO: find out how they are used\r
        byte grneeded[NUMCHUNKS];\r
 } video_t;\r
 \r
+//from scroll16\r
+//==========================================================================\r
+typedef struct\r
+{\r
+       map_t *map;\r
+       page_t *page;\r
+       int tx,ty; //appears to be the top left tile position on the viewable screen map\r
+       word dxThresh,dyThresh; //Threshold for physical tile switch\r
+       video_t *video; //pointer to game variables of the video\r
+       nibble __near *p;       // pointer to video's render page num\r
+       nibble __near *sp;      // pointer to video's show page num\r
+       int dx, dy;     // draw row and col var\r
+//newer vars!\r
+       int delta, d;\r
+} map_view_t;\r
+/* Map is presumed to:\r
+ * 1. Have all the required layers and tilesets within itself\r
+ * 2. Have a 'fence' around accessible blocks to simplify boundary logic\r
+ * 3. Have a persistent map and tile size among the layers\r
+ * Map view is presumed to:\r
+ * 1. Calculate, store and update a panning info, which includes, but not limited to:\r
+ *     combined layer information, actual map representation (reflecting real state of the game),\r
+ *     pixel shift for smooth tile scrolling.\r
+ * 2. Provide ways to draw a visible part of map. For simplicity with smooth scrolling,\r
+ *     additional row/column is always drawn at the each side of the map. This implies that 'fence'\r
+ *     should have a sprite too. Map is drawn left-to-right, top-to-bottom.\r
+ */\r
+\r
+//==========================================================================\r
+\r
 //from 16_mm\r
 //==========================================================================\r
 \r
@@ -310,9 +512,10 @@ typedef struct
 typedef struct\r
 {\r
        int             mapon, mapnum;\r
-       __SEGA  *mapsegs[4];\r
-       __SEGA  *mapheaderseg[NUMMAPS];\r
-       __SEGA  *tinf;\r
+       //__SEGA        *mapsegs[4];\r
+       //__SEGA        *mapheaderseg[NUMMAPS];\r
+       //__SEGA        *tinf;\r
+       memptr  mapsegs;\r
 } ca_mapinfo_t;\r
 \r
 typedef struct\r
@@ -328,6 +531,9 @@ typedef struct
        __SEGA  *grsegs[NUMCHUNKS];\r
        byte            far     grneeded[NUMCHUNKS];\r
        huffnode huffnode;\r
+\r
+       //TODO: extend! and learn from keen/wolf/catacomb's code wwww\r
+       memptr  spribuff;\r
 } ca_t;\r
 \r
 //==========================================================================\r
@@ -351,8 +557,9 @@ typedef struct
        mminfo_t mm; mminfotype mmi;\r
 } global_game_variables_t;\r
 \r
-extern char global_temp_status_text[512];\r
 #ifdef __WATCOMC__\r
+extern char global_temp_status_text[512];\r
+extern char global_temp_status_text2[512];\r
 #define EINVFMT EMFILE\r
 #endif\r
 #endif /* _TYPEDEFSTRUCT_H_ */\r