1 /* Project 16 Source Code~
\r
2 * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
\r
4 * This file is part of Project 16.
\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
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
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
25 #include "src/lib/scroll16.h"
\r
27 #define INC_PER_FRAME_PRINT sprintf(global_temp_status_text, "%u", player[pn].enti.persist_aniframe);\
\r
28 modexprint(&(pip->video->page[0]), player[pn].enti.x-(8*player[pn].enti.persist_aniframe), player[pn].enti.y-TILEWH-(8*player[pn].enti.persist_aniframe), 1, 20, 1, global_temp_status_text);
\r
30 #define WALKTYPE_FRAM_PRINT walktypeinfo(player, pn);\
\r
31 modexprint(&(pip->video->page[0]), player[pn].enti.x-(8*player[pn].enti.persist_aniframe)+8, player[pn].enti.y-TILEWH-(8*player[pn].enti.persist_aniframe), 1, 20, 1, global_temp_status_text);\
\r
34 #define INC_PER_FRAME if(player[pn].enti.q&1) player[pn].enti.persist_aniframe++; if(player[pn].enti.persist_aniframe>4) player[pn].enti.persist_aniframe = 1;
\r
36 void ZC_walk(map_view_t *pip, player_t *player, word pn)
\r
38 switch(player[pn].enti.d)
\r
42 //0000pip[0].video->startclk = (*clockw);
\r
46 if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->tw < pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->tilemidposscreenx &&
\r
47 !(pip[0].map->data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection!
\r
49 player[pn].walktype=2;
\r
50 if(player[pn].enti.q<=player[pn].enti.spt)
\r
53 ANIMATESPRIFUN(pip, player, pn, 1);
\r
54 ScrollRight(pip, player, 3, pn);
\r
55 ScrollRight(pip, player, 2, pn);
\r
56 mapScrollRight(pip, player, (pip[0].video->p), pn);
\r
57 player[pn].enti.q++;
\r
58 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
59 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
61 else if(player[pn].enti.tx < pip[0].map->width && !(pip[0].map->data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY))
\r
63 player[pn].walktype=1;
\r
64 if(player[pn].enti.q<=player[pn].enti.spt)
\r
67 player[pn].enti.x+=(player[pn].enti.speed);
\r
68 ANIMATESPRIFUN(pip, player, pn, 0);
\r
69 player[pn].enti.q++;
\r
70 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
74 player[pn].walktype=0;
\r
76 //modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATAPTR);
\r
77 ANIMATESPRIFUN(pip, player, pn, 0);
\r
79 // modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 14);
\r
81 player[pn].enti.d = 2;
\r
83 player[pn].enti.triggerx = player[pn].enti.tx+1;
\r
84 player[pn].enti.triggery = player[pn].enti.ty;
\r
89 if(pip[0].tx > 0 && pip[0].tx+pip[0].page->tw <= pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->tilemidposscreenx &&
\r
90 !(pip[0].map->data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection!
\r
92 player[pn].walktype=2;
\r
93 if(player[pn].enti.q<=player[pn].enti.spt)
\r
96 ANIMATESPRIFUN(pip, player, pn, 1);
\r
97 ScrollLeft(pip, player, 3, pn);
\r
98 ScrollLeft(pip, player, 2, pn);
\r
99 mapScrollLeft(pip, player, (pip[0].video->p), pn);
\r
100 player[pn].enti.q++;
\r
101 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
102 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
104 else if(player[pn].enti.tx > 1 && !(pip[0].map->data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY))
\r
106 player[pn].walktype=1;
\r
107 if(player[pn].enti.q<=player[pn].enti.spt)
\r
110 player[pn].enti.x-=(player[pn].enti.speed);
\r
111 ANIMATESPRIFUN(pip, player, pn, 0);
\r
112 player[pn].enti.q++;
\r
113 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
117 player[pn].walktype=0;
\r
119 //modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATAPTR);
\r
120 ANIMATESPRIFUN(pip, player, pn, 0);
\r
122 // modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 10);
\r
124 player[pn].enti.d = 2;
\r
126 player[pn].enti.triggerx = player[pn].enti.tx-1;
\r
127 player[pn].enti.triggery = player[pn].enti.ty;
\r
128 WALKTYPE_FRAM_PRINT
\r
132 if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->th < pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->tilemidposscreeny &&
\r
133 !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY)) //collision detection!
\r
135 player[pn].walktype=2;
\r
136 if(player[pn].enti.q<=player[pn].enti.spt)
\r
139 ANIMATESPRIFUN(pip, player, pn, 1);
\r
140 ScrollDown(pip, player, 3, pn);
\r
141 ScrollDown(pip, player, 2, pn);
\r
142 mapScrollDown(pip, player, (pip[0].video->p), pn);
\r
143 player[pn].enti.q++;
\r
144 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
145 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
147 else if(player[pn].enti.ty < pip[0].map->height && !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY))
\r
149 player[pn].walktype=1;
\r
150 if(player[pn].enti.q<=player[pn].enti.spt)
\r
153 player[pn].enti.y+=(player[pn].enti.speed);
\r
154 ANIMATESPRIFUN(pip, player, pn, 0);
\r
155 player[pn].enti.q++;
\r
156 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
160 player[pn].walktype=0;
\r
162 //modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATAPTR);
\r
163 ANIMATESPRIFUN(pip, player, pn, 0);
\r
165 // modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 9);
\r
167 player[pn].enti.d = 2;
\r
169 player[pn].enti.triggerx = player[pn].enti.tx;
\r
170 player[pn].enti.triggery = player[pn].enti.ty+1;
\r
171 WALKTYPE_FRAM_PRINT
\r
175 if(pip[0].ty > 0 && pip[0].ty+pip[0].page->th <= pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->tilemidposscreeny &&
\r
176 !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY)) //collision detection!
\r
178 player[pn].walktype=2;
\r
179 if(player[pn].enti.q<=player[pn].enti.spt)
\r
182 ANIMATESPRIFUN(pip, player, pn, 1);
\r
183 ScrollUp(pip, player, 3, pn);
\r
184 ScrollUp(pip, player, 2, pn);
\r
185 mapScrollUp(pip, player, (pip[0].video->p), pn);
\r
186 player[pn].enti.q++;
\r
187 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
188 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
190 else if(player[pn].enti.ty > 1 && !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY))
\r
192 player[pn].walktype=1;
\r
193 if(player[pn].enti.q<=player[pn].enti.spt)
\r
196 player[pn].enti.y-=(player[pn].enti.speed);
\r
197 ANIMATESPRIFUN(pip, player, 0, pn);
\r
198 player[pn].enti.q++;
\r
199 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
203 player[pn].walktype=0;
\r
205 //modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATAPTR);
\r
206 ANIMATESPRIFUN(pip, player, pn, 0);
\r
208 // modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 12);
\r
210 player[pn].enti.d = 2;
\r
212 player[pn].enti.triggerx = player[pn].enti.tx;
\r
213 player[pn].enti.triggery = player[pn].enti.ty-1;
\r
214 WALKTYPE_FRAM_PRINT
\r
217 if(player[pn].enti.d!=2 && pip[0].video->rs)
\r
226 src/lib/scroll16.c: mv[0].video->r=1;
\r
227 src/lib/scroll16.c: mv[0].video->r=1;
\r
228 src/lib/scroll16.c: mv[0].video->r=1;
\r
229 src/lib/scroll16.c: mv[0].video->r=1;
\r
230 src/lib/scroll16.c: pip->video->r=1;
\r
231 src/lib/scroll16.c: mv->video->r=1;
\r
234 void oldwalk(map_view_t *pip, player_t *player, word pn)
\r
236 //printf("player[%d].d=%d\n", pn, player[pn].enti.d);
\r
237 switch(player[pn].enti.d)
\r
241 //0000pip[0].video->startclk = (*clockw);
\r
245 //printf("pip[0].page->tilesw=%d ", pip[0].page->tilesw); printf("pip[0].page->tw=%d\n", pip[0].page->tw);
\r
246 if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->tw < pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->tilemidposscreenx &&
\r
247 !(pip[0].map->data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection!
\r
249 if(player[pn].enti.q<=player[pn].enti.spt)
\r
252 ANIMATESPRIFUN(pip, player, pn, 1);
\r
253 ScrollRight(pip, player, 3, pn);
\r
254 ScrollRight(pip, player, 2, pn);
\r
255 //mapScrollRight(pip, player, !(pip[0].video->p), pn);
\r
256 mapScrollRight(pip, player, (pip[0].video->p), pn);
\r
257 if(!pageflipflop) modexShowPage(pip[1].page);
\r
258 player[pn].enti.q++;
\r
259 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
260 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
262 else if(player[pn].enti.tx < pip[0].map->width && !(pip[0].map->data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY))
\r
264 if(player[pn].enti.q<=player[pn].enti.spt)
\r
267 player[pn].enti.x+=(player[pn].enti.speed);
\r
268 ANIMATESPRIFUN(pip, player, pn, 0);
\r
269 if(!pageflipflop) modexShowPage(pip[1].page);
\r
270 player[pn].enti.q++;
\r
271 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
275 if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32);
\r
277 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATAPTR);
\r
279 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 14);
\r
281 if(!pageflipflop) modexShowPage(pip[1].page);
\r
282 player[pn].enti.d = 2;
\r
284 player[pn].enti.triggerx = player[pn].enti.tx+1;
\r
285 player[pn].enti.triggery = player[pn].enti.ty;
\r
290 if(pip[0].tx > 0 && pip[0].tx+pip[0].page->tw <= pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->tilemidposscreenx &&
\r
291 !(pip[0].map->data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection!
\r
293 if(player[pn].enti.q<=player[pn].enti.spt)
\r
296 ANIMATESPRIFUN(pip, player, pn, 1);
\r
297 ScrollLeft(pip, player, 3, pn);
\r
298 ScrollLeft(pip, player, 2, pn);
\r
299 //mapScrollLeft(pip, player, !(pip[0].video->p), pn);
\r
300 mapScrollLeft(pip, player, (pip[0].video->p), pn);
\r
301 if(!pageflipflop) modexShowPage(pip[1].page);
\r
302 player[pn].enti.q++;
\r
303 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
304 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
306 else if(player[pn].enti.tx > 1 && !(pip[0].map->data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY))
\r
308 if(player[pn].enti.q<=player[pn].enti.spt)
\r
311 player[pn].enti.x-=(player[pn].enti.speed);
\r
312 ANIMATESPRIFUN(pip, player, pn, 0);
\r
313 if(!pageflipflop) modexShowPage(pip[1].page);
\r
314 player[pn].enti.q++;
\r
315 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
319 if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32);
\r
321 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATAPTR);
\r
323 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 10);
\r
325 if(!pageflipflop) modexShowPage(pip[1].page);
\r
326 player[pn].enti.d = 2;
\r
328 player[pn].enti.triggerx = player[pn].enti.tx-1;
\r
329 player[pn].enti.triggery = player[pn].enti.ty;
\r
334 if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->th < pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->tilemidposscreeny &&
\r
335 !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY)) //collision detection!
\r
337 if(player[pn].enti.q<=player[pn].enti.spt)
\r
340 ANIMATESPRIFUN(pip, player, pn, 1);
\r
341 ScrollDown(pip, player, 3, pn);
\r
342 ScrollDown(pip, player, 2, pn);
\r
343 //mapScrollDown(pip, player, !(pip[0].video->p), pn);
\r
344 mapScrollDown(pip, player, (pip[0].video->p), pn);
\r
345 if(!pageflipflop) modexShowPage(pip[1].page);
\r
346 player[pn].enti.q++;
\r
347 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
348 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
350 else if(player[pn].enti.ty < pip[0].map->height && !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY))
\r
352 if(player[pn].enti.q<=player[pn].enti.spt)
\r
355 player[pn].enti.y+=(player[pn].enti.speed);
\r
356 ANIMATESPRIFUN(pip, player, pn, 0);
\r
357 if(!pageflipflop) modexShowPage(pip[1].page);
\r
358 player[pn].enti.q++;
\r
359 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
363 if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32);
\r
365 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATAPTR);
\r
367 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 9);
\r
369 if(!pageflipflop) modexShowPage(pip[1].page);
\r
370 player[pn].enti.d = 2;
\r
372 player[pn].enti.triggerx = player[pn].enti.tx;
\r
373 player[pn].enti.triggery = player[pn].enti.ty+1;
\r
378 if(pip[0].ty > 0 && pip[0].ty+pip[0].page->th <= pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->tilemidposscreeny &&
\r
379 !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY)) //collision detection!
\r
381 if(player[pn].enti.q<=player[pn].enti.spt)
\r
384 ANIMATESPRIFUN(pip, player, pn, 1);
\r
385 ScrollUp(pip, player, 3, pn);
\r
386 ScrollUp(pip, player, 2, pn);
\r
387 //mapScrollUp(pip, player, !(pip[0].video->p), pn);
\r
388 mapScrollUp(pip, player, (pip[0].video->p), pn);
\r
389 if(!pageflipflop) modexShowPage(pip[1].page);
\r
390 player[pn].enti.q++;
\r
391 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
392 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
394 else if(player[pn].enti.ty > 1 && !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY))
\r
396 if(player[pn].enti.q<=player[pn].enti.spt)
\r
399 player[pn].enti.y-=(player[pn].enti.speed);
\r
400 ANIMATESPRIFUN(pip, player, 0, pn);
\r
401 if(!pageflipflop) modexShowPage(pip[1].page);
\r
402 player[pn].enti.q++;
\r
403 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
407 if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32);
\r
409 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATAPTR);
\r
411 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 12);
\r
413 if(!pageflipflop) modexShowPage(pip[1].page);
\r
414 player[pn].enti.d = 2;
\r
416 player[pn].enti.triggerx = player[pn].enti.tx;
\r
417 player[pn].enti.triggery = player[pn].enti.ty-1;
\r
423 void ZC_panPageManual(map_view_t *pip, player_t *player, word pn)
\r
425 #define SHOWMVFUN_ ZC_ShowMV(pip, 0, 0);
\r
426 switch(player[pn].enti.d)
\r
430 if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->tw < pip[0].page->tilesw)
\r
432 if(player[pn].enti.q<=player[pn].enti.spt)
\r
434 pip[0].page->dx+=4;
\r
436 player[pn].enti.q++;
\r
437 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].tx++; }
\r
443 if(pip[0].tx > 0 && pip[0].tx+pip[0].page->tw <= pip[0].page->tilesw)
\r
445 if(player[pn].enti.q<=player[pn].enti.spt)
\r
447 pip[0].page->dx-=4;
\r
449 player[pn].enti.q++;
\r
450 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].tx--; }
\r
456 if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->th < pip[0].page->tilesh)
\r
458 if(player[pn].enti.q<=player[pn].enti.spt)
\r
460 pip[0].page->dy+=4;
\r
462 player[pn].enti.q++;
\r
463 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].ty++; }
\r
469 if(pip[0].ty > 0 && pip[0].ty+pip[0].page->th <= pip[0].page->tilesh)
\r
471 if(player[pn].enti.q<=player[pn].enti.spt)
\r
473 pip[0].page->dy-=4;
\r
475 player[pn].enti.q++;
\r
476 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].ty--; }
\r
485 void ZC_MVSetup(map_view_t *pip, map_t *map, global_game_variables_t *gv)
\r
490 pip[0].page = &gv->video.page[0];
\r
492 pip[0].video = &gv->video;
\r
493 pip[0].panp = &gv->video.panp;
\r
494 ZC_MVInit(pip, 1, 1);
\r
496 for(i=ZC_MVI;i<gv->video.num_of_pages;i++)
\r
498 pip[i].page = &gv->video.page[i];
\r
499 pip[i].map = pip[0].map;
\r
500 pip[i].video = pip[0].video;
\r
501 pip[i].panp = pip[0].panp;
\r
509 void ZC_MVInit(map_view_t *pip, int tx, int ty)
\r
513 //pip[0].tx = pip[1].tx = tx;
\r
514 //pip[0].ty = pip[1].ty = ty;
\r
517 void ZC_ShowMV(map_view_t *moo, boolean vsync, boolean sr)
\r
519 word high_address, low_address, offset;
\r
522 /* calculate offset */
\r
523 offset = (word) moo[moo[0].video->panp].page->data;
\r
524 offset += moo[0].page->dy * (moo[0].page->width >> 2 );
\r
525 offset += moo[0].page->dx >> 2;
\r
527 /* calculate crtcOffset according to virtual width */
\r
531 crtcOffset = moo[0].page->sw >> 3;
\r
535 crtcOffset = moo[0].page->width >> 3;
\r
539 high_address = HIGH_ADDRESS | (offset & 0xff00);
\r
540 low_address = LOW_ADDRESS | (offset << 8);
\r
542 /* wait for appropriate timing and then program CRTC */
\r
543 if(vsync) while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE));
\r
544 outpw(CRTC_INDEX, high_address);
\r
545 outpw(CRTC_INDEX, low_address);
\r
546 outp(CRTC_INDEX, 0x13);
\r
547 outp(CRTC_DATA, crtcOffset);
\r
549 /* wait for one retrace */
\r
550 if(vsync) while (!(inp(INPUT_STATUS_1) & VRETRACE));
\r
552 /* do PEL panning here */
\r
553 outp(AC_INDEX, 0x33);
\r
554 outp(AC_INDEX, (moo[0].page->dx & 0x03) << 1);
\r
558 allocMap(int w, int h) {
\r
563 result.data = malloc(sizeof(byte) * w * h);
\r
564 //result.data = (byte *)alloc_emem(((int)sizeof(byte) * w * h)/1024);
\r
565 if(isEMS() || checkEMS())
\r
568 //emmhandle = mallocEMS(coretotalEMS());//alloc_emem((int)sizeof(map))
\r
569 mm.length=sizeof(result);
\r
571 mm.sourceOff=ptr2long(&result);
\r
572 mm.destH=emmhandle;
\r
574 ist = move_emem(&mm);
\r
575 if(!ist){ dealloc_emem(emmhandle); exit(5); }
\r
576 printf("%d\n", coretotalEMS());
\r
583 initMap(map_t *map) {
\r
584 // just a place holder to fill out an alternating pattern
\r
588 //if(!isEMS() || !checkEMS())
\r
589 // map->tiles = malloc(sizeof(tiles_t));
\r
591 // map->tiles = (tiles_t *)alloc_emem(sizeof(tiles_t));
\r
593 //create the tile set
\r
594 //if(!isEMS() || !checkEMS())
\r
595 // map->tiles->data = malloc(sizeof(bitmap_t));
\r
597 // map->tiles->data = (bitmap_t *)alloc_emem(sizeof(bitmap_t));
\r
598 // map->tiles->data->width = (TILEWH);
\r
599 // map->tiles->data->height= TILEWH;
\r
600 //if(!isEMS() || !checkEMS())
\r
601 // map->tiles->data->data = malloc((TILEWH*2)*TILEWH);
\r
603 // map->tiles->data->data = (byte *)alloc_emem((TILEWH*2)*TILEWH);
\r
604 // map->tiles->tileHeight = TILEWH;
\r
605 // map->tiles->tileWidth =TILEWH;
\r
606 // map->tiles->rows = 1;
\r
607 // map->tiles->cols = 1;//2;
\r
610 //for(y=0; y<map->height; y++) {
\r
611 //for(x=0; x<map->width; x++) {
\r
613 for(yy=0; yy<TILEWH; yy++) {
\r
614 for(xx=0; xx<(TILEWH); xx++) {
\r
616 map->tiles->data->data[i+1] = map->data[q];//28;//0x24;
\r
617 // printf("[%d]", map->tiles->data->data[i]);
\r
619 //map->tiles->data->data[i] = map->data[q];//0;//0x34;
\r
620 //printf("]%d[==[%d]", i, map->tiles->data->data[i]);
\r
626 // printf("[%d]", map->data[q]);
\r
633 for(y=0; y<map->height; y++) {
\r
634 for(x=0; x<map->width; x++) {
\r
635 // map->data[i]=255;
\r
636 printf("[%d]", map->data[i]);
\r
637 //tile = tile ? 0 : 1;
\r
640 //tile = tile ? 0 : 1;
\r
644 void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
\r
646 word x;//, y; /* coordinate for drawing */
\r
648 /* increment the pixel position and update the page */
\r
649 mv[id].page[0].dx += player[plid].enti.speed;
\r
651 /* check to see if this changes the tile */
\r
652 if(mv[id].page[0].dx >= mv[id].dxThresh )
\r
654 /* go forward one tile */
\r
656 /* Snap the origin forward */
\r
657 mv[id].page->data += 4;
\r
659 mv[id].page[0].dx = mv[id].map->tiles->tileWidth;
\r
662 /* draw the next column */
\r
663 x= mv[0].page->sw + mv[id].map->tiles->tileWidth;
\r
664 if(player[plid].enti.q%4)
\r
666 mapDrawCol(&mv[0], mv[0].tx + mv[0].page->tw, mv[0].ty-1, x, player, mv->page[0].dx);
\r
668 if(!pageflipflop && !pageploop)
\r
669 modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->th+2));
\r
674 void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
\r
676 word x;//,y; /* coordinate for drawing */
\r
678 /* decrement the pixel position and update the page */
\r
679 mv[id].page[0].dx -= player[plid].enti.speed;
\r
681 /* check to see if this changes the tile */
\r
682 if(mv[id].page[0].dx == 0)
\r
684 /* go backward one tile */
\r
686 /* Snap the origin backward */
\r
687 mv[id].page->data -= 4;
\r
689 mv[id].page[0].dx = mv[id].map->tiles->tileWidth;
\r
692 /* draw the next column */
\r
694 if(player[plid].enti.q%4)
\r
696 mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, mv->page[0].dx);
\r
698 if(!pageflipflop && !pageploop)
\r
699 modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->th+2));
\r
704 void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
\r
706 word y;//x, /* coordinate for drawing */
\r
708 /* decrement the pixel position and update the page */
\r
709 mv[id].page[0].dy -= player[plid].enti.speed;
\r
711 /* check to see if this changes the tile */
\r
712 if(mv[id].page[0].dy == 0 )
\r
714 /* go down one tile */
\r
716 /* Snap the origin downward */
\r
717 mv[id].page->data -= mv[id].page->pi;
\r
719 mv[id].page[0].dy = mv[id].map->tiles->tileHeight;
\r
722 /* draw the next row */
\r
724 if(player[plid].enti.q%3)
\r
726 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, mv->page[0].dy);
\r
728 if(!pageflipflop && !pageploop)
\r
729 modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->tw+2), mv[id].map->tiles->tileHeight);
\r
733 void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)
\r
735 word y;//x, /* coordinate for drawing */
\r
737 /* increment the pixel position and update the page */
\r
738 mv[id].page[0].dy += player[plid].enti.speed;
\r
740 /* check to see if this changes the tile */
\r
741 if(mv[id].page[0].dy >= mv[id].dyThresh )
\r
743 /* go down one tile */
\r
745 /* Snap the origin downward */
\r
746 mv[id].page->data += mv[id].page->pi;
\r
748 mv[id].page[0].dy = mv[id].map->tiles->tileHeight;
\r
751 /* draw the next row */
\r
752 y= mv[0].page->sh + mv[id].map->tiles->tileHeight;
\r
753 if(player[plid].enti.q%3)
\r
755 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+mv[0].page->th, y, player, mv->page[0].dy);
\r
757 if(!pageflipflop && !pageploop)
\r
758 modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->tw+2), mv[id].map->tiles->tileHeight);
\r
763 //TODO finish this wwww
\r
764 void near ScrollRight(map_view_t *mv, player_t *player, word id, word plid)
\r
766 /* increment the pixel position and update the page */
\r
767 mv[id].page->dx += player[plid].enti.speed;
\r
769 /* check to see if this changes the tile */
\r
770 if(mv[id].page->dx >= mv[0].dxThresh )
\r
772 // vga_setup_wm1_block_copy();
\r
773 // _fmemmove(mv[id].page->data+4, mv[id].page->data, mv[id].page->pagesize);
\r
774 // vga_restore_rm0wm0();
\r
775 /* Snap the origin forward */
\r
776 mv[id].page->data += 4;
\r
777 mv[id].page->dx = mv[0].map->tiles->tileWidth;
\r
781 void near ScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
\r
783 /* decrement the pixel position and update the page */
\r
784 mv[id].page->dx -= player[plid].enti.speed;
\r
786 /* check to see if this changes the tile */
\r
787 if(mv[id].page->dx == 0)
\r
789 // vga_setup_wm1_block_copy();
\r
790 // _fmemmove(mv[id].page->data-4, mv[id].page->data, mv[id].page->pagesize);
\r
791 // vga_restore_rm0wm0();
\r
792 /* Snap the origin backward */
\r
793 mv[id].page->data -= 4;
\r
794 mv[id].page->dx = mv[0].map->tiles->tileWidth;
\r
798 void near ScrollUp(map_view_t *mv, player_t *player, word id, word plid)
\r
800 /* decrement the pixel position and update the page */
\r
801 mv[id].page->dy -= player[plid].enti.speed;
\r
803 /* check to see if this changes the tile */
\r
804 if(mv[id].page->dy == 0)
\r
806 // vga_setup_wm1_block_copy();
\r
807 // _fmemmove(mv[id].page->data-mv[id].page->pi, mv[id].page->data, mv[id].page->pagesize);
\r
808 // vga_restore_rm0wm0();
\r
809 /* Snap the origin backward */
\r
810 mv[id].page->data -= mv[id].page->pi;
\r
811 mv[id].page->dy = mv[0].map->tiles->tileWidth;
\r
815 void near ScrollDown(map_view_t *mv, player_t *player, word id, word plid)
\r
817 /* increment the pixel position and update the page */
\r
818 mv[id].page->dy += player[plid].enti.speed;
\r
820 /* check to see if this changes the tile */
\r
821 if(mv[id].page->dy >= mv[0].dxThresh )
\r
823 // vga_setup_wm1_block_copy();
\r
824 // _fmemmove(mv[id].page->data+mv[id].page->pi, mv[id].page->data, mv[id].page->pagesize);
\r
825 // vga_restore_rm0wm0();
\r
826 /* Snap the origin forward */
\r
827 mv[id].page->data += mv[id].page->pi;
\r
828 mv[id].page->dy = mv[0].map->tiles->tileWidth;
\r
832 //===========================================================================
\r
833 //TODO: put player in starting position of assigned spot on map
\r
834 //default player position on the viewable map
\r
835 void playerXYpos(int x, int y, player_t *player, map_view_t *pip, nibble pn)
\r
837 player[pn].enti.tx = x + pip[0].tx + pip[0].page->tilemidposscreenx;
\r
838 player[pn].enti.ty = y + pip[0].ty + pip[0].page->tilemidposscreeny;
\r
840 //===========================================================================
\r
842 sword chkmap(map_t *map, word q)
\r
845 static byte x[(MAPW*MAPH)+1] =
\r
846 { 1, 2, 3, 4, 0, 3, 3, 3, 3, 3, 3, 3, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 6, 7, 8, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
\r
858 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
859 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
\r
860 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
861 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 1, 2, 3, 4 };*/
\r
862 //check for failed to load map
\r
863 if((map->width == map->height == 0) && (q>0))
\r
865 //initiate a null map!
\r
866 map->width=MAPW;///2;
\r
867 map->height=MAPH;///2;
\r
868 // map->data = malloc(((map->width*map->height)+1)*sizeof(byte));
\r
870 map->tiles = malloc(sizeof(tiles_t));
\r
871 //fix this to be far~
\r
872 // bp = bitmapLoadPcx("data/ed.pcx");
\r
873 // map->tiles->data = &bp;
\r
874 #ifdef __DEBUG_MAP__
\r
875 dbg_mapdata = map->data;
\r
877 map->tiles->tileHeight = 16;
\r
878 map->tiles->tileWidth = 16;
\r
879 map->tiles->rows = 1;
\r
880 map->tiles->cols = 1;
\r
881 #ifdef __DEBUG_MAP__
\r
882 dbg_maptext = true;
\r
885 #ifdef __DEBUG_MAP__
\r
886 else dbg_maptext = false;
\r
891 //TODO: player position here
\r
892 void mapGoTo(map_view_t *mv, int tx, int ty)
\r
897 mapinitmapview(mv, tx, ty);
\r
899 /* draw the tiles */
\r
900 modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 0);
\r
902 i=mv[0].ty * mv[0].map->width + mv[0].tx;
\r
903 for(ty=mv[0].ty-1; py < mv[0].page->sh+mv->dyThresh && ty < mv[0].map->height; ty++, py+=mv[0].map->tiles->tileHeight) {
\r
904 mapDrawWRow(&mv[0], tx-1, ty, py);
\r
905 i+=mv->map->width - tx;
\r
907 if(!pageploop) modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height);
\r
909 // unsigned int k,j,o;
\r
910 // /* fill screen with a distinctive pattern */
\r
911 // for (k=0;k < vga_state.vga_width;k++) {
\r
913 // vga_write_sequencer(0x02/*map mask*/,1 << (k&3));
\r
914 // for (j=0;j < (mv[0].page->height)+(mv[1].page->height)+(mv[2].page->height)+(mv[3].page->height);j++,o += vga_state.vga_stride)
\r
915 // vga_state.vga_graphics_ram[o] = (k^j)&15; // VRL samples put all colors in first 15!
\r
918 modexCopyPageRegion(mv[3].page, mv[0].page, 0/**/, 0/**/, 0, 0, 24, 32);
\r
921 void mapinitmapview(map_view_t *mv, int tx, int ty)
\r
923 /* set up the coordinates */
\r
924 mv[0].tx = mv[1].tx = tx;
\r
925 mv[0].ty = mv[1].ty = ty;
\r
926 mv[0].page->dx = mv[1].page->dx = mv[2].page->dx = mv[3].page->dx = mv->map->tiles->tileWidth;
\r
927 mv[0].page->dy = mv[1].page->dy = mv[2].page->dy = mv[3].page->dy = mv->map->tiles->tileHeight;
\r
929 /* set up the thresholds */
\r
930 mv[0].dxThresh = mv[1].dxThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileWidth * 2;
\r
931 mv[0].dyThresh = mv[1].dyThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileHeight * 2;
\r
935 mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y)
\r
939 //word textx=0, texty=0;
\r
944 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 0); //currently the over scan color!
\r
948 rx = (((i-1) % ((t->data->width)/t->tileWidth)) * t->tileWidth);
\r
949 ry = (((i-1) / ((t->data->height)/t->tileHeight)) * t->tileHeight);
\r
950 ////0000printf("i=%d\n", i);
\r
951 #ifdef __DEBUG_MAP__
\r
952 switch(dbg_maptext)
\r
957 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, ((dbg_mapdata[i])+1));
\r
958 //modexprint(page, x, y, 1, 15, 0, (char const *)(t->debug_data[i]));
\r
960 modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
\r
961 /* then the sprite. note modding ram ptr means we just draw to (x&3,0) */
\r
962 //draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));
\r
963 //modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
\r
965 #ifdef __DEBUG_MAP__
\r
968 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, (dbg_mapdata[i])+1);
\r
969 //modexprintbig(page, x, y, 1, 15, 0, (t->debug_data));
\r
970 /*for(texty=0; texty<2; texty++)
\r
972 for(textx=0; textx<2; textx++)
\r
974 // modexprint(page, x+(textx*8), y+(texty*8), 1, (word)(t->debug_data), 0, (t->debug_data));
\r
983 void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *player, word poopoffset)
\r
987 poopoffset%=player[0].enti.speed;
\r
988 //printf("y: %d\n", poopoffset);
\r
989 /* the position within the map array */
\r
990 i=ty * mv->map->width + tx;
\r
991 for(x=poopoffset; x<(mv->page->sw+mv->dxThresh)/(poopoffset+1) && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
\r
993 /* we are in the map, so copy! */
\r
994 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
1000 void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *player, word poopoffset)
\r
1004 poopoffset%=player[0].enti.speed;
\r
1005 //printf("x: %d\n", poopoffset);
\r
1006 /* location in the map array */
\r
1007 i=ty * mv->map->width + tx;
\r
1009 /* We'll copy all of the columns in the screen,
\r
1010 i + 1 row above and one below */
\r
1011 for(y=poopoffset; y<(mv->page->sh+mv->dyThresh)/(poopoffset+1) && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
\r
1013 /* we are in the map, so copy away! */
\r
1014 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
1016 i += mv->map->width;
\r
1020 void mapDrawWRow(map_view_t *mv, int tx, int ty, word y)
\r
1025 /* the position within the map array */
\r
1026 i=ty * mv->map->width + tx;
\r
1027 for(x=0; x<mv->page->sw+mv->dxThresh && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
\r
1029 /* we are in the map, so copy! */
\r
1030 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
1036 void mapDrawWCol(map_view_t *mv, int tx, int ty, word x)
\r
1041 /* location in the map array */
\r
1042 i=ty * mv->map->width + tx;
\r
1044 /* We'll copy all of the columns in the screen,
\r
1045 i + 1 row above and one below */
\r
1046 for(y=0; y<mv->page->sh+mv->dyThresh && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
\r
1048 /* we are in the map, so copy away! */
\r
1049 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
1051 i += mv->map->width;
\r
1060 boolean pageflipflop = 1;
\r
1061 boolean pageploop = 1;
\r
1064 void shinku(global_game_variables_t *gv)
\r
1066 word x = (0) + gv->video.page[/*!*/(gv->video.p)].dx; // follow the screen
\r
1067 word y = (0) + gv->video.page[/*!*/(gv->video.p)].dy; // follow the screen
\r
1068 word col = 7, bgcol = 0, type = 1;//w = 64, h = 8,
\r
1070 //modexCopyPageRegion(pip[1].page, pip[2].page, 16, 16, 16, 16, (14*8)+4, 8+4);
\r
1071 /* block copy to visible RAM from offscreen */
\r
1072 // vga_setup_wm1_block_copy();
\r
1073 // modexCopyPageRegion(&(gv->video.page[gv->video->sfip]), &(gv->video.page[!gv->video->sfip]), x, y, x+w, 0, w, h);
\r
1074 // o = *(gv->video.page[2].data); // source offscreen
\r
1075 // o2 = *(gv->video.page[gv->video->sfip].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride)
\r
1076 // for (i=0;i < h;i++,o += vga_state.vga_draw_stride,o2 += vga_state.vga_stride) vga_wm1_mem_block_copy(o2,o,w >> 2);
\r
1077 /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */
\r
1078 // vga_restore_rm0wm0();
\r
1079 if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second))
\r
1081 // NTS: For some bizarre reason, gv->pee is not initialized, but the pointer is not NULL even
\r
1082 // though it should be. Instead it's NULL as a near pointer but contains a non-null
\r
1083 // segment value, so testing against NULL doesn't work. It is initialized properly if
\r
1084 // you call start_timer() though which uses near malloc. Rather than fight with that,
\r
1085 // I decided it would be better to declare a temp buffer statically and sprintf to that.
\r
1087 // This fixes *** Null pointer assignment detected error message in ZCROLL.EXE on exit.
\r
1088 sprintf(global_temp_status_text, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv));
\r
1089 //modexClearRegion(&(gv->video.page[gv->video->sfip]), x, y, w, h, 45);
\r
1090 modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, col, bgcol, global_temp_status_text);
\r
1091 gv->kurokku.tiku=0;
\r
1092 /* block copy to visible RAM from offscreen */
\r
1093 // vga_setup_wm1_block_copy();
\r
1094 // o = *(gv->video.page[gv->video->sfip].data); // source offscreen
\r
1095 // o2 = *(gv->video.page[2].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride)
\r
1096 // for (i=0;i < h;i++,o += vga_state.vga_draw_stride,o2 += vga_state.vga_stride) vga_wm1_mem_block_copy(o2,o,w >> 2);
\r
1097 // modexCopyPageRegion(&(gv->video.page[gv->video->sfip]), &(gv->video.page[!gv->video->sfip]), x, y, x, 0, w, h);
\r
1098 /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */
\r
1099 // vga_restore_rm0wm0();
\r
1100 }else //copy dat sheet
\r
1101 gv->kurokku.tiku++;
\r
1103 switch(gv->kurokku.fpscap)
\r
1106 //modexprint(&(gv->video.page[gv->video->sfip]), x, y+8, type, col, bgcol, "sanic!");
\r
1107 gv->kurokku.frames_per_second=1;
\r
1110 //turn this off if XT
\r
1111 //modexWaitBorder();
\r
1112 vga_wait_for_vsync();
\r
1113 gv->kurokku.frames_per_second=60;
\r
1118 //vga_setup_wm1_block_copy();
\r
1119 //_fmemcpy((gv->video.page[(gv->video.p)]).data, (gv->video.page[(!gv->video.p)]).data, gv->video.page[(!gv->video.p)].pagesize);
\r
1120 //vga_restore_rm0wm0();
\r
1121 if(!pageploop) modexCopyPageRegion(&(gv->video.page[(gv->video.p)]), &(gv->video.page[(!gv->video.p)]), 0, 0, 0, 0, gv->video.page[gv->video.p].width, gv->video.page[!gv->video.p].height);
\r
1122 modexShowPage(&(gv->video.page[gv->video.p]));
\r
1123 if(!pageploop) gv->video.p=!gv->video.p;
\r
1124 gv->video.r=!gv->video.r;
\r
1125 //0000gv->video.tickclk = ((*clockw)-gv->video.startclk)/18.2;
\r
1130 void near ZC_drawframe(map_view_t *pip, player_t *player, word pn, sword x, sword y, word dire, word sw)
\r
1132 pip->video->sprifilei=0;
\r
1150 switch(pip[0].video->rs)
\r
1153 pip->video->sprifilei = set_anim_by_id(player[pn].ent->spri, dire); if(pip->video->sprifilei == -1) return;
\r
1154 animate_spri(player[pn].ent->spri, pip->video);
\r
1157 pip->video->sprifilei = set_anim_by_id(player[pn].ent->spri, dire); if(pip->video->sprifilei == -1) return;
\r
1158 oldanimate_spri(player[pn].ent->spri, pip->video);
\r
1161 modexClearRegion(&(pip[0].page[0]), x, y, 16, 32, dire);
\r
1166 /*void ZC_odrawframe()
\r
1172 #define FRAME1 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 48, dire, 24, 32, PLAYERBMPDATAPTR);
\r
1173 #define FRAME2 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, dire, 24, 32, PLAYERBMPDATAPTR);
\r
1174 #define FRAME3 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 0, dire, 24, 32, PLAYERBMPDATAPTR);
\r
1175 #define FRAME4 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, dire, 24, 32, PLAYERBMPDATAPTR);
\r
1177 #define FRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 2+dire);
\r
1178 #define FRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+dire);
\r
1179 #define FRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, dire);
\r
1180 #define FRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+dire);
\r
1183 void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch)
\r
1185 sword x = player[pn].enti.x;
\r
1186 sword y = player[pn].enti.y;
\r
1187 sword bx = x+16; //buffer's x
\r
1188 sword by = y+16; //buffer's y
\r
1189 word dire=32; //direction
\r
1190 sword qq; //scroll offset
\r
1191 word ls = player[pn].enti.persist_aniframe;
\r
1193 switch(scrollswitch)
\r
1199 qq = ((player[pn].enti.q)*(player[pn].enti.speed));
\r
1203 y-=pip[0].map->tiles->tileHeight;
\r
1204 switch (player[pn].enti.d)
\r
1208 dire*=player[pn].enti.d;
\r
1214 dire*=(player[pn].enti.d-2);
\r
1222 dire*=(player[pn].enti.d-2);
\r
1228 dire*=(player[pn].enti.d+2);
\r
1235 modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 36);
\r
1237 //copy old bg to page0
\r
1238 //modexCopyPageRegion(pip[3].page, pip[0].page, bx, by, 0, 0, 20, 36);
\r
1240 //modexCopyPageRegion(pip[0].page, pip[3].page, 0, 0, x, y, 20, 36);
\r
1242 //modexCopyPageRegion(page_t *dest, page_t *src, word sx, word sy, word dx, word dy, word width, word height);
\r
1243 //modexCopyPageRegion(pip[3].page, pip[!(pip->video->p)].page, x-4, y-4, 0, 128, 28, 36);
\r
1244 /*modexCopyPageRegion(pip[pip->video->p].page,
\r
1245 pip[!(pip->video->p)].page, x-4, y-4, x-4, y-4, 28, 36);*/
\r
1246 // else modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 40);
\r
1262 // if(2>ls && ls>=1) { FRAME1 }else
\r
1263 // if(3>ls && ls>=2) { FRAME2 }else
\r
1264 // if(4>ls && ls>=3) { FRAME3 }else
\r
1265 // if(5>ls && ls>=4) { FRAME4 }
\r
1266 //modexCopyPageRegion(pip[0].page, pip[3].page, 0, 0, x, y, 24, 32);
\r
1267 //printf("x=%d y=%d bx=%d by=%d\n", x, y, bx, by);
\r
1271 void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch)
\r
1273 sword x = player[pn].enti.x;
\r
1274 sword y = player[pn].enti.y;
\r
1275 word dire=10; //direction
\r
1276 sword qq; //scroll offset
\r
1277 word ls = player[pn].enti.persist_aniframe;
\r
1279 switch(scrollswitch)
\r
1285 qq = ((player[pn].enti.q)*(player[pn].enti.speed));
\r
1288 if(pip[0].video->rs<2)
\r
1290 y-=pip[0].map->tiles->tileHeight;
\r
1291 switch (player[pn].enti.d)
\r
1295 dire*=player[pn].enti.d+1;
\r
1300 dire*=(player[pn].enti.d-1);
\r
1307 dire*=(player[pn].enti.d-1);
\r
1312 dire*=(player[pn].enti.d+3);
\r
1317 //setting xy position
\r
1318 player[pn].ent->spri->x = x;
\r
1319 player[pn].ent->spri->y = y;
\r
1324 ZC_drawframe(pip, player, pn, x, y, dire, ls);
\r
1327 ZC_drawframe(pip, player, pn, x, y, dire, ls);
\r
1330 ZC_drawframe(pip, player, pn, x, y, dire, ls);
\r
1333 ZC_drawframe(pip, player, pn, x, y, dire, ls);
\r
1343 boolean boundary_check(int x, int y, int dx, int dy, int h, int w)
\r
1345 return (dx > 0 && (x + dx) < w) || (dx < 0 && (x + dx) >= 0) || (dy > 0 && (y + dy) < h) || (dy < 0 && (y + dy) >= 0) || (dx == dy && dx == 0);
\r
1348 boolean coll_check(int x, int y, int dx, int dy, map_view_t *map_v)
\r
1350 // Assume everything crosses at most 1 tile at once
\r
1351 return dx && 1;//crossable_tile(x + dx, map_v) || dy && crossable_tile(y + dy, map_v);
\r
1354 boolean ZC_walk2(entity_t *ent, map_view_t *map_v)
\r
1374 if(coll_check(ent->x, ent->y, dx, dy, map_v))
\r
1378 // Start animation
\r
1379 // Mark next tile as occupied
\r
1380 // Mark this tile as vacant
\r
1386 void player_walk(player_t *player, map_view_t *map_v){
\r
1388 if(ZC_walk2(&(player->enti), map_v) && boundary_check(map_v->tx, map_v->ty, dx, dy, map_v->map->width - 2*map_v->page->tilesw, map_v->map->height - 2*map_v->page->tilesh))
\r
1390 mapScroll(map_v, player);
\r
1391 // (Un)load stuff?
\r
1395 void near mapScroll(map_view_t *mv, player_t *player)
\r
1397 //word x, y; /* coordinate for drawing */
\r
1400 mv->delta += player->dx | player->dy;
\r
1401 delta = mv->delta;
\r
1402 mv->d = (player->dx) ? (player->dx > 0) ? 3 : 1 : (player->dy) ? (player->dy > 0) ? 4 : 0 : 2;
\r
1408 if(!(delta + mv->dxThresh))
\r
1418 if(!(delta + mv->dyThresh))
\r