]> 4ch.mooo.com Git - 16.git/blob - src/lib/scroll16.h
just pushing before i use ZC_mapscroll
[16.git] / src / lib / scroll16.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 __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 #define PLAYERBMPDATAVAR        player[pn].data\r
48 #define PLAYERBMPDATA           *PLAYERBMPDATAVAR\r
49 #define PLAYERBMPDATAPTR        PLAYERBMPDATAVAR\r
50 \r
51 #define PCXBMPVAR       player[0].data\r
52 #define PCXBMP          *PCXBMPVAR\r
53 #define PCXBMPPTR       PCXBMPVAR\r
54 \r
55 //row and colum drawing routines\r
56 #define FULLRCREND\r
57 #define DRAWCOLNUM mv->page[id].dx\r
58 #define DRAWROWNUM mv->page[id].dy\r
59 //#define DRAWCOLNUM player[plid].enti.q\r
60 //#define DRAWROLNUM player[plid].enti.q\r
61 \r
62 //for null map!\r
63 #define MAPW    40\r
64 #define MAPH    30\r
65 \r
66         //if(player[0].enti.hp==0) printf("%d wwww\n", player[0].enti.y+8);\r
67         //else printf("\nplayer[0].enti.y: %d\n", player[0].enti.y);\r
68 //printf("gvar.video.p=%u ", gvar.video.p);\r
69 //not used now  printf("temporary player sprite 0: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=45556867\n");\r
70 //not used now  printf("temporary player sprite 1: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=44606385\n");\r
71 //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
72 //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
73 //printf("map.width=%d  map.height=%d   map.data[0]=%d\n", mv[1].map->width, mv[1].map->height, mv[1].map->data[0]);\r
74 //printf("pageflipflop=%u", pageflipflop);\r
75 //printf("&global_temp_status_text = %Fp\n", &global_temp_status_text);\r
76 //printf("middle tile position: %dx", gvar.video.page[0].tilemidposscreenx);    printf("%d\n", gvar.video.page[0].tilemidposscreeny);\r
77 //printf("      aniframe=%u", player[0].enti.persist_aniframe);\r
78 #define SCROLLEXITMESG  printf("[0]txy: %dx%d   ", mv[1].tx, mv[1].ty); printf("[1]txy: %dx%d", mv[1].tx, mv[1].ty);\\r
79         printf("\n\n");\\r
80         printf("player vars:\n");\\r
81         printf("        xy: %dx%d", player[0].enti.x, player[0].enti.y); printf("       txy: %dx%d", player[0].enti.tx, player[0].enti.ty); printf("    triggxy: %dx%d", player[0].enti.triggerx, player[0].enti.triggery); printf("    value: %d\n", mv[1].map->data[(player[0].enti.triggerx-1)+(map.width*(player[0].enti.triggery-1))]);\\r
82         printf("        hp: %d", (player[0].enti.hp));  printf("        q: %d", player[0].enti.q);      printf("        info.dir: %d", player[0].info.dir);     printf("        d: %d ", player[0].enti.d);\\r
83                 printf("        pdir: %d\n", player[0].pdir); printf("  delay=%u", player[0].enti.spri->delay);\\r
84 printf("\n\n");\\r
85         VL_PrintmodexmemInfo(&gvar.video);\\r
86 \\r
87         printf("gvar.video.r=%u ", gvar.video.r);\\r
88         printf("gvar.video.bgps=%u ", gvar.video.bgps);\\r
89 printf("\n\n");\r
90 \r
91 extern boolean pagenorendermap, pagedelayrendermap;\r
92 \r
93 extern char global_temp_status_text[512];\r
94 \r
95 //map_t allocMap(int w, int h);\r
96 void initMap(map_t *map);\r
97 void ZC_walk(map_view_t *pip, player_t *player, word pn);\r
98 void ZC_panPageManual(map_view_t *pip, player_t *player, word pn);\r
99 void ZC_MVSetup(map_view_t *pip, map_t *map, global_game_variables_t *gv);\r
100 void ZC_MVInit(map_view_t *pip, int tx, int ty);\r
101 void ZC_ShowMV(map_view_t *moo, boolean vsync, boolean sr);\r
102 void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid);\r
103 void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid);\r
104 void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid);\r
105 void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid);\r
106 void ZC_mapScroll(map_view_t *mv, player_t *player, word pn);\r
107 void ZC_playerXYpos(int x, int y, player_t *player, map_view_t *pip, nibble pn);\r
108 sword chkmap(map_t *map, word q);\r
109 void mapGoTo(map_view_t *mv, int tx, int ty);\r
110 void ZC_mapinitMV(map_view_t *mv, int tx, int ty);\r
111 void near mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y);\r
112 void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *player, word poopoffset);\r
113 void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *player, word poopoffset);\r
114 void mapDrawWRow(map_view_t *mv, int tx, int ty, word y);\r
115 void mapDrawWCol(map_view_t *mv, int tx, int ty, word x);\r
116 inline void near ScrollRight(map_view_t *mv, player_t *player, word id, word plid)\r
117 {\r
118         /* increment the pixel position and update the page */\r
119         mv[id].page->dx += player[plid].enti.speed;\r
120 \r
121         /* check to see if this changes the tile */\r
122         if(mv[id].page->dx >= mv[id].dxThresh )\r
123         {\r
124                 /* go forward one tile */\r
125                 if(id==0) mv[id].tx++;\r
126                 /* Snap the origin forward */\r
127                 mv[id].page->data += 4;\r
128 \r
129                 mv[id].page->dx = mv[id].map->tiles->tileWidth;\r
130         }\r
131 }\r
132 \r
133 inline void near ScrollLeft(map_view_t *mv, player_t *player, word id, word plid)\r
134 {\r
135         /* decrement the pixel position and update the page */\r
136         mv[id].page->dx -= player[plid].enti.speed;\r
137 \r
138         /* check to see if this changes the tile */\r
139         if(mv[id].page->dx == 0)\r
140         {\r
141                 /* go backward one tile */\r
142                 if(id==0) mv[id].tx--;\r
143                 /* Snap the origin backward */\r
144                 mv[id].page->data -= 4;\r
145 \r
146                 mv[id].page->dx = mv[id].map->tiles->tileWidth;\r
147         }\r
148 }\r
149 \r
150 inline void near ScrollUp(map_view_t *mv, player_t *player, word id, word plid)\r
151 {\r
152         /* decrement the pixel position and update the page */\r
153         mv[id].page->dy -= player[plid].enti.speed;\r
154 \r
155         /* check to see if this changes the tile */\r
156         if(mv[id].page->dy == 0 )\r
157         {\r
158                 /* go up one tile */\r
159                 if(id==0) mv[id].ty--;\r
160                 /* Snap the origin upward */\r
161                 mv[id].page->data -= mv[id].page->pi;\r
162 \r
163                 mv[id].page->dy = mv[id].map->tiles->tileHeight;\r
164         }\r
165 }\r
166 \r
167 inline void near ScrollDown(map_view_t *mv, player_t *player, word id, word plid)\r
168 {\r
169         /* increment the pixel position and update the page */\r
170         mv[id].page->dy += player[plid].enti.speed;\r
171 \r
172         /* check to see if this changes the tile */\r
173         if(mv[id].page->dy >= mv[id].dyThresh )\r
174         {\r
175                 /* go down one tile */\r
176                 if(id==0) mv[id].ty++;\r
177                 /* Snap the origin downward */\r
178                 mv[id].page->data += mv[id].page->pi;\r
179 \r
180                 mv[id].page->dy = mv[id].map->tiles->tileHeight;\r
181         }\r
182 }\r
183 \r
184 //void qclean();\r
185 //sync\r
186 void shinku(global_game_variables_t *gv);\r
187 //animate the sprite\r
188 void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch);\r
189 \r
190 // Move an entity around. Should actually be in 16_entity\r
191 boolean ZC_walk2(entity_t *ent, map_view_t *map_v);\r
192 \r
193 // Move player around and call map scrolling if required/possible\r
194 void walk_player(player_t *player, map_view_t *map_v);\r
195 \r
196 // Scroll map in one direction (assumed from player's movement)\r
197 void mapScroll(map_view_t *mv, player_t *player);\r
198 \r
199 #endif /*__SCROLL16_H_*/\r