]> 4ch.mooo.com Git - 16.git/blob - src/lib/scroll16.h
palllist not being worked on right now... i will work on sprite animation VERY soon
[16.git] / src / lib / scroll16.h
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2016 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 __SCROLL16_H_\r
24 #define __SCROLL16_H_\r
25 \r
26 #include "src/lib/16_head.h"\r
27 #include "src/lib/16_tail.h"\r
28 #include "src/lib/bakapee.h"\r
29 #include "src/lib/16_vl.h"\r
30 #include "src/lib/16_in.h"\r
31 #include "src/lib/bitmap.h"\r
32 #include "src/lib/16_map.h" //map is loaded here www\r
33 #include "src/lib/16render.h"\r
34 //#include "src/lib/16_map.h"   //new map stuff\r
35 #include "src/lib/16_timer.h"\r
36 #include "src/lib/wcpu/16_wcpu.h"\r
37 #include "src/lib/16_sprit.h"\r
38 \r
39 #include <hw/cpu/cpu.h>\r
40 #include <hw/dos/dos.h>\r
41 #include <hw/vga/vga.h>\r
42 #include <hw/vga/vrl.h>\r
43 \r
44 //#define SPRITE\r
45 //#define TILERENDER\r
46 \r
47 //extern void modexDrawSpriteRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp);\r
48 \r
49 //modexDrawSpritePBufRegion\r
50 //modexDrawBmpPBufRegion\r
51 //#define PBUFSFUN              modexDrawSpriteRegion\r
52 //#define PBUFBFUN              modexDrawBmpRegion\r
53 \r
54 #define PLAYERBMPDATAVAR        player[pn].data\r
55 #define PLAYERBMPDATA           *PLAYERBMPDATAVAR\r
56 #define PLAYERBMPDATAPTR        PLAYERBMPDATAVAR\r
57 \r
58 #define PCXBMPVAR       player[0].data\r
59 #define PCXBMP          *PCXBMPVAR\r
60 #define PCXBMPPTR       PCXBMPVAR\r
61 \r
62 typedef struct {\r
63         map_t *map;\r
64         page_t *page;\r
65         int tx; //appears to be the top left tile position on the viewable screen map\r
66         int ty; //appears to be the top left tile position on the viewable screen map\r
67         word dxThresh; //Threshold for physical tile switch\r
68         word dyThresh; //Threshold for physical tile switch\r
69         video_t *video; //pointer to game variables of the video\r
70         nibble *panp;   // pointer to video's pan page num\r
71 //newer vars!\r
72         int dx, dy, delta, d;\r
73 } map_view_t;\r
74 /* Map is presumed to:\r
75  * 1. Have all the required layers and tilesets within itself\r
76  * 2. Have a 'fence' around accessible blocks to simplify boundary logic\r
77  * 3. Have a persistent map and tile size among the layers\r
78  * Map view is presumed to:\r
79  * 1. Calculate, store and update a panning info, which includes, but not limited to:\r
80  *      combined layer information, actual map representation (reflecting real state of the game),\r
81  *      pixel shift for smooth tile scrolling.\r
82  * 2. Provide ways to draw a visible part of map. For simplicity with smooth scrolling,\r
83  *      additional row/column is always drawn at the each side of the map. This implies that 'fence'\r
84  *      should have a sprite too. Map is drawn left-to-right, top-to-bottom.\r
85  */\r
86 \r
87 //for null map!\r
88 #define MAPW    40\r
89 #define MAPH    30\r
90 \r
91         //if(player[0].enti.hp==0) printf("%d wwww\n", player[0].enti.y+8);\r
92         //else printf("\nplayer[0].enti.y: %d\n", player[0].enti.y);\r
93 //      printf("palette offset: %d\n", paloffset/3);\r
94 //++++  printf("Total used: %zu\n", oldfreemem-GetFreeSize());\r
95 //++++  printf("Total free: %zu\n", GetFreeSize());\r
96 //not used now  printf("temporary player sprite 0: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=45556867\n");\r
97 //not used now  printf("temporary player sprite 1: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=44606385\n");\r
98 //printf("mv[%u].tx: %d", gvar.video.panp, mv[gvar.video.panp].tx); printf("    mv[%u].ty: %d   ", gvar.video.panp, mv[gvar.video.panp].ty);\r
99 //printf("gvar.kurokku: "); printf("%.0f ", clock());   printf("tiku=%lu ", gvar.kurokku.tiku); printf("t=%.0f ", gvar.kurokku.t);      printf("ticktock()=%f ", ticktock(&gvar));      printf("%.0f fps", (double)gvar.kurokku.tiku/ticktock(&gvar));\r
100 //printf("map.width=%d  map.height=%d   map.data[0]=%d\n", mv[0].map->width, mv[0].map->height, mv[0].map->data[0]);\r
101 //printf("&global_temp_status_text = %Fp\n", &global_temp_status_text);\r
102 #define SCROLLEXITMESG  printf("tx: %d  ", mv[0].tx);\\r
103         printf("ty: %d\n", mv[0].ty);\\r
104         printf("\n");\\r
105         printf("player vars:\n");\\r
106         printf("        x: %d", player[0].enti.x); printf("     y: %d\n", player[0].enti.y);\\r
107         \\r
108         printf("        tx: %d", player[0].enti.tx); printf("   ty: %d\n", player[0].enti.ty);\\r
109         printf("        triggx: %d", player[0].enti.triggerx); printf(" triggy: %d\n", player[0].enti.triggery);\\r
110         printf("        hp: %d", (player[0].enti.hp));  printf("        q: %d", player[0].enti.q);      printf("        player.info.dir: %d", player[0].info.dir);      printf("        player.d: %d ", player[0].enti.d);\\r
111                 printf("        pdir=%d\n", player[0].pdir);\\r
112         printf("        tile data value at player trigger position: %d\n\n", mv[0].map->data[(player[0].enti.triggerx-1)+(map.width*(player[0].enti.triggery-1))]);\\r
113 \\r
114         printf("Virtual Screen: %dx", gvar.video.page[0].width);        printf("%d      ", gvar.video.page[0].height);\\r
115         printf("Screen: %dx", gvar.video.page[0].sw);   printf("%d\n", gvar.video.page[0].sh);\\r
116         printf("virtual tile resolution: %dx", gvar.video.page[0].tilesw);      printf("%d      ", gvar.video.page[0].tilesh);\\r
117         printf("tile resolution: %dx", gvar.video.page[0].tw);  printf("%d\n", gvar.video.page[0].th);\\r
118         printf("middle tile position: %dx", gvar.video.page[0].tilemidposscreenx);      printf("%d\n", gvar.video.page[0].tilemidposscreeny);\\r
119         modexprintmeminfo(&gvar.video);\\r
120 \\r
121         printf("gvar.video.p=%u ", gvar.video.p); printf("gvar.video.r=%u ", gvar.video.r);\\r
122         printf("pageflipflop=%u\n", pageflipflop);\\r
123         printf("\n");\r
124 \r
125 #define SHOWMVFUN ZC_ShowMV(&mv, 0, 0);\r
126 #define PANKEYFUN \\r
127                         ZC_panPageManual(&mv, &player, 0); \\r
128                         if(IN_KeyDown(1+1) || IN_KeyDown(sc_Z)){ gvar.video.panp=0; SHOWMVFUN; } \\r
129                         if(IN_KeyDown(2+1) || IN_KeyDown(sc_X)){ gvar.video.panp=1; SHOWMVFUN; } \\r
130                         if(IN_KeyDown(3+1) || IN_KeyDown(sc_C)){ gvar.video.panp=2; SHOWMVFUN; if(IN_KeyDown(sc_C)) modexClearRegion(&gvar.video.page[2], 0, 0, gvar.video.page[2].sw, gvar.video.page[2].sh, 47); } \\r
131                         if(IN_KeyDown(4+1) || IN_KeyDown(sc_V)){ gvar.video.panp=3; SHOWMVFUN; if(IN_KeyDown(sc_V)) modexClearRegion(&gvar.video.page[3], 0, 0, gvar.video.page[3].sw, gvar.video.page[3].sh, 45); } \\r
132                         if(IN_KeyDown(25)){ modexpdump(mv[1].page); modexShowPage(&(gvar.video.page[1])); IN_UserInput(1,1); }\r
133 \r
134 extern boolean pageflipflop, pageploop;\r
135 \r
136 extern char global_temp_status_text[512];\r
137 \r
138 //map_t allocMap(int w, int h);\r
139 //void initMap(map_t *map);\r
140 void walk(map_view_t *pip, player_t *player, word pn);\r
141 void ZC_walk(map_view_t *pip, player_t *player, word pn);\r
142 void ZC_panPageManual(map_view_t *pip, player_t *player, word pn);\r
143 void ZC_MVSetup(map_view_t *pip, map_t *map, global_game_variables_t *gv);\r
144 void ZC_MVInit(map_view_t *pip, int tx, int ty);\r
145 void ZC_ShowMV(map_view_t *moo, boolean vsync, boolean sr);\r
146 void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid);\r
147 void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid);\r
148 void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid);\r
149 void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid);\r
150 void near ScrollRight(map_view_t *mv, player_t *player, word id, word plid);\r
151 void near ScrollLeft(map_view_t *mv, player_t *player, word id, word plid);\r
152 void near ScrollUp(map_view_t *mv, player_t *player, word id, word plid);\r
153 void near ScrollDown(map_view_t *mv, player_t *player, word id, word plid);\r
154 void playerXYpos(int x, int y, player_t *player, map_view_t *pip, nibble pn);\r
155 sword chkmap(map_t *map, word q);\r
156 void mapGoTo(map_view_t *mv, int tx, int ty);\r
157 void mapinitmapview(map_view_t *mv, int tx, int ty);\r
158 void near mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y);\r
159 void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *player, word poopoffset);\r
160 void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *player, word poopoffset);\r
161 void mapDrawWRow(map_view_t *mv, int tx, int ty, word y);\r
162 void mapDrawWCol(map_view_t *mv, int tx, int ty, word x);\r
163 //void qclean();\r
164 void shinku(global_game_variables_t *gv);\r
165 void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch);\r
166 void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch, global_game_variables_t *gv);\r
167 \r
168 // Move an entity around. Should actually be in 16_entity\r
169 boolean ZC_walk2(entity_t *ent, map_view_t *map_v);\r
170 \r
171 // Move player around and call map scrolling if required/possible\r
172 void walk_player(player_t *player, map_view_t *map_v);\r
173 \r
174 // Scroll map in one direction (assumed from player's movement)\r
175 void near mapScroll(map_view_t *mv, player_t *player);\r
176 \r
177 #endif /*__SCROLL16_H_*/\r