1 /* Project 16 Source Code~
\r
2 * Copyright (C) 2012-2018 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
28 boolean ZCL_mapEdgeChk(map_view_t *map_v, nibble dir, int tx, int ty, boolean pansw, boolean noscrollsw)
\r
35 w = map_v[0].map->width;
\r
36 h = map_v[0].map->height;
\r
39 w = map_v[0].page->ti.tilesw;
\r
40 h = map_v[0].page->ti.tilesh;
\r
46 default://no direction
\r
48 //0000pip[0].video->startclk = (*clockw);
\r
53 if(noscrollsw) return tx < map_v[0].map->width;
\r
54 else return (map_v[0].tx >= 0 && map_v[0].tx+map_v[0].page->ti.tw < w);
\r
58 if(noscrollsw) return tx > 1;
\r
59 else return (map_v[0].tx > 0 && map_v[0].tx+map_v[0].page->ti.tw <= w);
\r
63 if(noscrollsw) return ty < map_v[0].map->height;
\r
64 else return (map_v[0].ty >= 0 && map_v[0].ty+map_v[0].page->ti.th < h);
\r
68 if(noscrollsw) return ty > 1;
\r
69 else return (map_v[0].ty > 0 && map_v[0].ty+map_v[0].page->ti.th <= h);
\r
75 boolean ZCL_CollCheck(map_view_t *map_v, nibble dir, int tx, int ty)
\r
79 default://no direction
\r
83 return !(map_v[0].map->layerdata[0].data[(tx)+(map_v[0].map->width*(ty-1))] == 0);
\r
86 return !(map_v[0].map->layerdata[0].data[(tx-2)+(map_v[0].map->width*(ty-1))] == 0);
\r
89 return !(map_v[0].map->layerdata[0].data[(tx-1)+(map_v[0].map->width*(ty))] == 0);
\r
92 return !(map_v[0].map->layerdata[0].data[(tx-1)+(map_v[0].map->width*(ty-2))] == 0);
\r
98 boolean ZCL_ScreenMidPosChk(map_view_t *map_v, nibble dir, int tx, int ty)
\r
100 if(ZCL_mapEdgeChk(map_v, dir, 0, 0, 0, 0))
\r
103 default://no direction
\r
105 //0000map_v[0].video->startclk = (*clockw);
\r
110 return tx == map_v[0].tx+map_v[0].page->ti.tilemidposscreenx;
\r
114 return tx == map_v[0].tx+map_v[0].page->ti.tilemidposscreenx;
\r
118 return ty == map_v[0].ty+map_v[0].page->ti.tilemidposscreeny;
\r
122 return ty == map_v[0].ty+map_v[0].page->ti.tilemidposscreeny;
\r
128 //#define INC_PER_FRAME if(gvar->player[pn].enti.q&1) gvar->player[pn].enti.persist_aniframe++; if(gvar->player[pn].enti.persist_aniframe>4) gvar->player[pn].enti.persist_aniframe = 1;
\r
129 #ifdef OLDWALKSHOWPAGESTUFF
\r
130 #define SHOWMVFUN__ VL_ShowPage(&gvar->video.page[0], 1, 0);//modexShowPage(&gvar->video.page);
\r
131 //ZC_ShowMV(gvar->mv, 1, 0);
\r
134 void ZC_walk(global_game_variables_t *gvar, word pn)
\r
136 switch(gvar->player[pn].enti.d)
\r
140 //0000gvar->mv[0].video->startclk = (*clockw);
\r
144 if(ZCL_ScreenMidPosChk(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty) &&
\r
145 ZCL_CollCheck(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty))//!(gvar->player[pn].enti.tx+1 == TRIGGX && gvar->player[pn].enti.ty == TRIGGY)) //collision detection!
\r
147 gvar->player[pn].walktype=2;
\r
148 if(gvar->player[pn].enti.q<=gvar->player[pn].enti.spt)
\r
150 ZC_animatePlayer(gvar->mv, gvar->player, pn);
\r
151 ZC_mapScroll(gvar->mv, gvar->player, pn);
\r
152 gvar->player[pn].enti.q++;
\r
153 //0000gvar->mv[0].video->clk = ((*clockw)-gvar->mv[0].video->startclk)/18.2;
\r
154 #ifdef OLDWALKSHOWPAGESTUFF
\r
157 } else { gvar->player[pn].enti.q = 1; gvar->player[pn].enti.d = 2; gvar->player[pn].enti.tx++; }
\r
159 else if(ZCL_mapEdgeChk(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty, 0, 1) &&
\r
160 ZCL_CollCheck(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty))//!(gvar->player[pn].enti.tx+1 == TRIGGX && gvar->player[pn].enti.ty == TRIGGY))
\r
162 gvar->player[pn].walktype=1;
\r
163 if(gvar->player[pn].enti.q<=gvar->player[pn].enti.spt)
\r
165 gvar->player[pn].enti.x+=(gvar->player[pn].enti.spt);
\r
166 ZC_animatePlayer(gvar->mv, gvar->player, pn);
\r
167 gvar->player[pn].enti.q++;
\r
168 #ifdef OLDWALKSHOWPAGESTUFF
\r
171 } else { gvar->player[pn].enti.q = 1; gvar->player[pn].enti.d = 2; gvar->player[pn].enti.tx++; }
\r
175 gvar->player[pn].walktype=0;
\r
176 ZC_animatePlayer(gvar->mv, gvar->player, pn);
\r
177 gvar->player[pn].enti.d = 2;
\r
178 #ifdef OLDWALKSHOWPAGESTUFF
\r
182 gvar->player[pn].enti.triggerx = gvar->player[pn].enti.tx+1;
\r
183 gvar->player[pn].enti.triggery = gvar->player[pn].enti.ty;
\r
187 if(ZCL_ScreenMidPosChk(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty) &&
\r
188 ZCL_CollCheck(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty))//!(gvar->player[pn].enti.tx-1 == TRIGGX && gvar->player[pn].enti.ty == TRIGGY)) //collision detection!
\r
190 gvar->player[pn].walktype=2;
\r
191 if(gvar->player[pn].enti.q<=gvar->player[pn].enti.spt)
\r
193 ZC_animatePlayer(gvar->mv, gvar->player, pn);
\r
194 ZC_mapScroll(gvar->mv, gvar->player, pn);
\r
195 gvar->player[pn].enti.q++;
\r
196 //0000gvar->mv[0].video->clk = ((*clockw)-gvar->mv[0].video->startclk)/18.2;
\r
197 #ifdef OLDWALKSHOWPAGESTUFF
\r
200 } else { gvar->player[pn].enti.q = 1; gvar->player[pn].enti.d = 2; gvar->player[pn].enti.tx--; }
\r
202 else if(ZCL_mapEdgeChk(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty, 0, 1) &&
\r
203 ZCL_CollCheck(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty))//!(gvar->player[pn].enti.tx-1 == TRIGGX && gvar->player[pn].enti.ty == TRIGGY))
\r
205 gvar->player[pn].walktype=1;
\r
206 if(gvar->player[pn].enti.q<=gvar->player[pn].enti.spt)
\r
208 gvar->player[pn].enti.x-=(gvar->player[pn].enti.spt);
\r
209 ZC_animatePlayer(gvar->mv, gvar->player, pn);
\r
210 gvar->player[pn].enti.q++;
\r
211 #ifdef OLDWALKSHOWPAGESTUFF
\r
214 } else { gvar->player[pn].enti.q = 1; gvar->player[pn].enti.d = 2; gvar->player[pn].enti.tx--; }
\r
218 gvar->player[pn].walktype=0;
\r
219 ZC_animatePlayer(gvar->mv, gvar->player, pn);
\r
220 gvar->player[pn].enti.d = 2;
\r
221 #ifdef OLDWALKSHOWPAGESTUFF
\r
225 gvar->player[pn].enti.triggerx = gvar->player[pn].enti.tx-1;
\r
226 gvar->player[pn].enti.triggery = gvar->player[pn].enti.ty;
\r
230 if(ZCL_ScreenMidPosChk(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty) &&
\r
231 ZCL_CollCheck(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty))//!(gvar->player[pn].enti.tx == TRIGGX && gvar->player[pn].enti.ty+1 == TRIGGY)) //collision detection!
\r
233 gvar->player[pn].walktype=2;
\r
234 if(gvar->player[pn].enti.q<=gvar->player[pn].enti.spt)
\r
236 ZC_animatePlayer(gvar->mv, gvar->player, pn);
\r
237 ZC_mapScroll(gvar->mv, gvar->player, pn);
\r
238 gvar->player[pn].enti.q++;
\r
239 //0000gvar->mv[0].video->clk = ((*clockw)-gvar->mv[0].video->startclk)/18.2;
\r
240 #ifdef OLDWALKSHOWPAGESTUFF
\r
243 } else { gvar->player[pn].enti.q = 1; gvar->player[pn].enti.d = 2; gvar->player[pn].enti.ty++; }
\r
245 else if(ZCL_mapEdgeChk(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty, 0, 1) &&
\r
246 ZCL_CollCheck(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty))//!(gvar->player[pn].enti.tx == TRIGGX && gvar->player[pn].enti.ty+1 == TRIGGY))
\r
248 gvar->player[pn].walktype=1;
\r
249 if(gvar->player[pn].enti.q<=gvar->player[pn].enti.spt)
\r
251 gvar->player[pn].enti.y+=(gvar->player[pn].enti.spt);
\r
252 ZC_animatePlayer(gvar->mv, gvar->player, pn);
\r
253 gvar->player[pn].enti.q++;
\r
254 #ifdef OLDWALKSHOWPAGESTUFF
\r
257 } else { gvar->player[pn].enti.q = 1; gvar->player[pn].enti.d = 2; gvar->player[pn].enti.ty++; }
\r
261 gvar->player[pn].walktype=0;
\r
262 ZC_animatePlayer(gvar->mv, gvar->player, pn);
\r
263 gvar->player[pn].enti.d = 2;
\r
264 #ifdef OLDWALKSHOWPAGESTUFF
\r
268 gvar->player[pn].enti.triggerx = gvar->player[pn].enti.tx;
\r
269 gvar->player[pn].enti.triggery = gvar->player[pn].enti.ty+1;
\r
273 if(ZCL_ScreenMidPosChk(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty) &&
\r
274 ZCL_CollCheck(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty))//!(gvar->player[pn].enti.tx == TRIGGX && gvar->player[pn].enti.ty-1 == TRIGGY)) //collision detection!
\r
276 gvar->player[pn].walktype=2;
\r
277 if(gvar->player[pn].enti.q<=gvar->player[pn].enti.spt)
\r
279 ZC_animatePlayer(gvar->mv, gvar->player, pn);
\r
280 ZC_mapScroll(gvar->mv, gvar->player, pn);
\r
281 gvar->player[pn].enti.q++;
\r
282 //0000gvar->mv[0].video->clk = ((*clockw)-gvar->mv[0].video->startclk)/18.2;
\r
283 #ifdef OLDWALKSHOWPAGESTUFF
\r
286 } else { gvar->player[pn].enti.q = 1; gvar->player[pn].enti.d = 2; gvar->player[pn].enti.ty--; }
\r
288 else if(ZCL_mapEdgeChk(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty, 0, 1) &&
\r
289 ZCL_CollCheck(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty))//!(gvar->player[pn].enti.tx == TRIGGX && gvar->player[pn].enti.ty-1 == TRIGGY))
\r
291 gvar->player[pn].walktype=1;
\r
292 if(gvar->player[pn].enti.q<=gvar->player[pn].enti.spt)
\r
294 gvar->player[pn].enti.y-=(gvar->player[pn].enti.spt);
\r
295 ZC_animatePlayer(gvar->mv, gvar->player, pn);
\r
296 gvar->player[pn].enti.q++;
\r
297 #ifdef OLDWALKSHOWPAGESTUFF
\r
300 } else { gvar->player[pn].enti.q = 1; gvar->player[pn].enti.d = 2; gvar->player[pn].enti.ty--; }
\r
304 gvar->player[pn].walktype=0;
\r
305 ZC_animatePlayer(gvar->mv, gvar->player, pn);
\r
306 gvar->player[pn].enti.d = 2;
\r
307 #ifdef OLDWALKSHOWPAGESTUFF
\r
311 gvar->player[pn].enti.triggerx = gvar->player[pn].enti.tx;
\r
312 gvar->player[pn].enti.triggery = gvar->player[pn].enti.ty-1;
\r
319 void ZC_panPageManual(map_view_t *pip, player_t *player, word pn)
\r
321 #define SHOWMVFUN_ VL_ShowPage(pip[0].page, 0, 0);//ZC_ShowMV(pip, 0, 0);
\r
322 switch(player[pn].enti.d)
\r
326 if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 1, 0))
\r
328 if(player[pn].enti.q<=player[pn].enti.spt)
\r
330 pip[0].page->dx+=4;
\r
332 player[pn].enti.q++;
\r
333 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].tx++; }
\r
339 if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 1, 0))
\r
341 if(player[pn].enti.q<=player[pn].enti.spt)
\r
343 pip[0].page->dx-=4;
\r
345 player[pn].enti.q++;
\r
346 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].tx--; }
\r
352 if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 1, 0))
\r
354 if(player[pn].enti.q<=player[pn].enti.spt)
\r
356 pip[0].page->dy+=4;
\r
358 player[pn].enti.q++;
\r
359 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].ty++; }
\r
365 if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 1, 0))
\r
367 if(player[pn].enti.q<=player[pn].enti.spt)
\r
369 pip[0].page->dy-=4;
\r
371 player[pn].enti.q++;
\r
372 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].ty--; }
\r
381 void ZC_MVSetup(map_view_t *pip, map_t *map, global_game_variables_t *gv)
\r
386 pip[0].page = &gv->video.page[0];
\r
388 pip[0].video = &gv->video;
\r
389 pip[0].kurokku = &gv->kurokku;
\r
390 pip[0].p = &gv->video.p;
\r
391 pip[0].sp = &gv->video.sp;
\r
392 ZC_MVInit(pip, 1, 1);
\r
394 for(i=ZC_MVI;i<gv->video.num_of_pages;i++)
\r
396 pip[i].page = &gv->video.page[i];
\r
397 pip[i].map = pip[0].map;
\r
398 pip[i].video = pip[0].video;
\r
399 pip[i].p = pip[0].p;
\r
400 pip[i].sp = pip[0].sp;
\r
408 void ZC_MVInit(map_view_t *pip, int tx, int ty)
\r
412 //pip[0].tx = pip[1].tx = tx;
\r
413 //pip[0].ty = pip[1].ty = ty;
\r
417 //for backwards compatibility with code i am lazy ww
\r
418 void ZC_ShowMV(map_view_t *moo, boolean vsync, boolean sr)
\r
420 VL_ShowPage(moo[0].page, vsync, sr);
\r
425 initMap(map_t *map) {
\r
426 // just a place holder to fill out an alternating pattern
\r
432 for(y=0; y<map->height; y++) {
\r
433 for(x=0; x<map->width; x++) {
\r
434 map->layerdata[0].data[i]=255;
\r
435 // printf("[%d]", map->layerdata[0].data[i]);
\r
436 tile = tile ? 0 : 1;
\r
439 tile = tile ? 0 : 1;
\r
444 initMap(map_t *map) {
\r
445 /* just a place holder to fill out an alternating pattern */
\r
449 map->tiles = malloc(sizeof(tiles_t));
\r
453 /* create the tile set */
\r
454 map->tiles->spri = malloc(sizeof(sprite_t));
\r
455 map->tiles->spri->sprite_vrl_cont.vrl_header->width = (TILEWH*2);
\r
456 map->tiles->spri->sprite_vrl_cont.vrl_header->height= TILEWH;
\r
457 map->tiles->spri->sprite_vrl_cont.buffer = malloc((TILEWH*2)*TILEWH);
\r
458 map->tiles->tileHeight = TILEWH;
\r
459 map->tiles->tileWidth =TILEWH*2;
\r
460 map->tiles->rows = 1;
\r
461 map->tiles->cols = 2;
\r
464 for(y=0; y<TILEWH; y++) {
\r
465 for(x=0; x<(TILEWH*2); x++) {
\r
467 map->tiles->spri->sprite_vrl_cont.buffer[i] = 28;//0x24;
\r
469 map->tiles->spri->sprite_vrl_cont.buffer[i] = 0;//0x34;
\r
476 for(y=0; y<map->height; y++) {
\r
477 for(x=0; x<map->width; x++) {
\r
478 map->layerdata[0].data[i] = tile;
\r
479 // printf("%u ", map->layerdata[0].data[i]);
\r
480 tile = tile ? 0 : 1;
\r
484 tile = tile ? 0 : 1;
\r
488 //===========================================================================//
\r
491 void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
\r
493 word x;//, y; /* coordinate for drawing */
\r
495 ScrollRight(mv, player, id, plid);
\r
497 /* draw the next column */
\r
498 x= mv[0].page->sw + mv[0].map->tiles->tileWidth;
\r
499 if(ZCL_mapEdgeChk(mv, player[plid].enti.d, player[plid].enti.tx, player[plid].enti.ty, 0, 0))
\r
501 if(player[plid].enti.q%4)
\r
503 if(player[plid].enti.q==4)
\r
506 mapDrawCol(&mv[id], mv[0].tx + mv[0].page->ti.tw, mv[0].ty-1, x, player);
\r
508 // if(mv[0].video->vga_state.bgps)
\r
509 // modexCopyPageRegion(mv->page, mv[0].page, x, 0, x, 0, mv[0].map->tiles->tileWidth, mv[0].page->height);
\r
510 //mv[0].video->dorender=1;//ScrollRight
\r
514 void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
\r
516 word x;//,y; /* coordinate for drawing */
\r
518 ScrollLeft(mv, player, id, plid);
\r
520 /* draw the next column */
\r
522 if(ZCL_mapEdgeChk(mv, player[plid].enti.d, player[plid].enti.tx, player[plid].enti.ty, 0, 0))
\r
524 if(player[plid].enti.q%4)
\r
526 if(player[plid].enti.q==4)
\r
529 mapDrawCol(&mv[id], mv[0].tx - 1, mv[0].ty-1, x, player);
\r
531 // if(mv[0].video->vga_state.bgps)
\r
532 // modexCopyPageRegion(mv->page, mv[0].page, x, 0, x, 0, mv[0].map->tiles->tileWidth, mv[0].page->height);
\r
533 //mv[0].video->dorender=1;//ScrollLeft
\r
537 void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
\r
539 word y;//x, /* coordinate for drawing */
\r
541 ScrollUp(mv, player, id, plid);
\r
543 /* draw the next row */
\r
545 if(ZCL_mapEdgeChk(mv, player[plid].enti.d, player[plid].enti.tx, player[plid].enti.ty, 0, 0))
\r
547 if(player[plid].enti.q%3)
\r
549 if(player[plid].enti.q==4)
\r
552 mapDrawRow(&mv[id], mv[0].tx - 1, mv[0].ty-1, y, player);
\r
554 // if(mv[0].video->vga_state.bgps)
\r
555 // modexCopyPageRegion(mv->page, mv[0].page, 0, y, 0, y, mv[0].page->width, mv[0].map->tiles->tileHeight);
\r
556 //mv[0].video->dorender=1;//ScrollUp
\r
560 void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)
\r
562 word y;//x, /* coordinate for drawing */
\r
564 ScrollDown(mv, player, id, plid);
\r
566 /* draw the next row */
\r
567 y= mv[0].page->sh + mv[0].map->tiles->tileHeight;
\r
568 if(ZCL_mapEdgeChk(mv, player[plid].enti.d, player[plid].enti.tx, player[plid].enti.ty, 0, 0))
\r
570 if(player[plid].enti.q%3)
\r
572 if(player[plid].enti.q==4)
\r
575 mapDrawRow(&mv[id], mv[0].tx - 1, mv[0].ty+mv[0].page->ti.th, y, player);
\r
577 // if(mv[0].video->vga_state.bgps)
\r
578 // modexCopyPageRegion(mv->page, mv[0].page, 0, y, 0, y, mv[0].page->width, mv[0].map->tiles->tileHeight);
\r
579 //mv[0].video->dorender=1;//ScrollDown
\r
582 void ZC_mapScroll(map_view_t *mv, player_t *player, word pn)
\r
584 word b = mv[0].video->vga_state.bgps;
\r
585 switch(player[pn].enti.d)
\r
590 ScrollRight(mv, player, 3, pn);
\r
591 ScrollRight(mv, player, 2, pn);
\r
592 mapScrollRight(mv, player, (0), pn);
\r
593 if(b) mapScrollRight(mv, player, (1), pn);
\r
596 ScrollLeft(mv, player, 3, pn);
\r
597 ScrollLeft(mv, player, 2, pn);
\r
598 mapScrollLeft(mv, player, (0), pn);
\r
599 if(b) mapScrollLeft(mv, player, (1), pn);
\r
602 ScrollDown(mv, player, 3, pn);
\r
603 ScrollDown(mv, player, 2, pn);
\r
604 mapScrollDown(mv, player, (0), pn);
\r
605 if(b) mapScrollDown(mv, player, (1), pn);
\r
608 ScrollUp(mv, player, 3, pn);
\r
609 ScrollUp(mv, player, 2, pn);
\r
610 mapScrollUp(mv, player, (0), pn);
\r
611 if(b) mapScrollUp(mv, player, (1), pn);
\r
614 //mv[0].video->dorender=1;//ZC_mapScroll
\r
617 //===========================================================================
\r
618 //TODO: put player in starting position of assigned spot on map
\r
619 //default player position on the viewable map
\r
620 void ZC_PlayerXYpos(int x, int y, player_t *player, map_view_t *pip, boolean defaultsw)
\r
622 player->enti.tx = x + pip[0].tx;
\r
623 player->enti.ty = y + pip[0].ty;
\r
628 player->enti.tx += pip[0].page->ti.tilemidposscreenx;
\r
629 player->enti.ty += pip[0].page->ti.tilemidposscreeny;
\r
635 //===========================================================================
\r
637 void ZC_checkardmap(map_t *map)
\r
639 // just a place holder to fill out an alternating pattern
\r
642 static byte z[(MAPW*MAPH)];//map->width*map->height];
\r
646 for(y=0; y<map->height; y++) {
\r
647 for(x=0; x<map->width; x++) {
\r
649 tile = tile ? 0 : 1;
\r
652 tile = tile ? 0 : 1;
\r
654 map->layerdata[0].data = &z;
\r
657 sword chkmap(map_t *map, word q)
\r
660 // static byte x[(MAPW*MAPH)+1] =
\r
661 //{ 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 10, 11, 12, 4, 1, 0, 1, 0, 0, 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, 1, 1, 1, 1, 13, 14, 15, 16, 0, 1, 1, 1, 5, 8, 1, 11, 11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1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 3, 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, 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, 1, 1, 1, 1, 1, 1, 1, 3, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 1, 2, 3, 4 };
\r
664 //check for failed to load map
\r
665 if((!map->width || !map->height) && (q>0))
\r
667 //initiate a null map!
\r
670 // map->layerdata[0].data = fmfaflflfofcf(((map->width*map->height)+1)*sizeof(byte));
\r
671 ZC_checkardmap(map);//map->layerdata[0].data = &x;
\r
672 //fix this to be far~
\r
673 // bp = bitmapLoadPcx("data/ed.pcx");
\r
674 // map->tiles->data = &bp;
\r
675 map->tiles->tileHeight = 16;
\r
676 map->tiles->tileWidth = 16;
\r
677 map->tiles->rows = 1;
\r
678 map->tiles->cols = 1;
\r
683 //TODO: player position here
\r
684 void mapGoTo(map_view_t *mv, int tx, int ty)
\r
686 ZC_mapinitMV(mv, tx, ty);
\r
688 /* draw the tiles */
\r
689 modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 0);
\r
690 ZC_mapredraw(mv, tx, ty);
\r
692 //if(mv[0].video->vga_state.bgps) modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height);
\r
695 void ZC_mapinitMV(map_view_t *mv, int tx, int ty)
\r
697 /* set up the coordinates */
\r
698 mv[0].tx = mv[1].tx = tx;
\r
699 mv[0].ty = mv[1].ty = ty;
\r
700 mv[0].page->dx = mv[1].page->dx = mv[2].page->dx = mv[3].page->dx = mv->map->tiles->tileWidth;
\r
701 mv[0].page->dy = mv[1].page->dy = mv[2].page->dy = mv[3].page->dy = mv->map->tiles->tileHeight;
\r
703 /* set up the thresholds */
\r
704 mv[0].dxThresh = mv[1].dxThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileWidth * 2;
\r
705 mv[0].dyThresh = mv[1].dyThresh = mv[2].dyThresh = mv[3].dyThresh = mv->map->tiles->tileHeight * 2;
\r
708 void ZC_mapredraw(map_view_t *mv, int tx, int ty)
\r
714 i=mv[0].ty * mv[0].map->width + mv[0].tx;
\r
715 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
716 mapDrawWRow(&mv[0], tx-1, ty, py);
\r
717 mapDrawWRow(&mv[1], tx-1, ty, py);
\r
718 i+=mv->map->width - tx;
\r
723 mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y)
\r
726 // printf("%02d ", i); if(x >= page->width - t->tileWidth) printf("\n");
\r
731 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 1); //currently the over scan color!
\r
734 rx = (((i-1) % ((t->spri->sprite_vrl_cont.vrl_header->width)/t->tileWidth)) * t->tileWidth);
\r
735 ry = (((i-1) / ((t->spri->sprite_vrl_cont.vrl_header->height)/t->tileHeight)) * t->tileHeight);
\r
737 #ifdef __DEBUG_RF__
\r
738 if(!dbg_pagenorendermap)
\r
740 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, i+1);
\r
742 modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, i);
\r
743 //draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));
\r
744 //modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
\r
746 #ifdef __DEBUG_MAP__
\r
747 if(dbg_maptext){ sprintf(global_temp_status_text2, "%u", i); modexprint(page, x, y, 1, 0, 1, 2, 1, global_temp_status_text2); }
\r
752 #define PALMAPDRAWW 13
\r
753 void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *player)
\r
756 #if defined(FULLRCREND) || defined(__DEBUG_RF__)
\r
757 word drawtileoffset=0;
\r
758 //printf("y: %d ", drawtileoffset);
\r
759 drawtileoffset%=player[0].enti.spt;
\r
760 //printf("%d\n", drawtileoffset);
\r
762 #ifdef __DEBUG_RF__
\r
763 if(dbg_pagedelayrendermap){ if(!y) y+=TILEWH; else y-=TILEWH;
\r
764 sprintf(global_temp_status_text, "%-3u", drawtileoffset); modexprint(mv->page, player[0].enti.x, player[0].enti.y-28-(drawtileoffset*8) , 1, 0, PALMAPDRAWW, 1, 1, global_temp_status_text); }
\r
766 /* the position within the map array */
\r
767 i=ty * mv->map->width + tx;
\r
771 for( mv->dx=drawtileoffset; mv->dx<(mv->page->sw+mv->dxThresh)/(drawtileoffset+1) && tx < mv->map->width; mv->dx+=mv->map->tiles->tileWidth, tx++) {
\r
773 for(mv->dx=0; mv->dx<mv->page->sw+mv->dxThresh && tx < mv->map->width; mv->dx+=mv->map->tiles->tileWidth, tx++) {
\r
776 mapDrawTile(mv->map->tiles, mv->map->layerdata[0].data[i], mv->page, mv->dx, y);
\r
779 #ifdef __DEBUG_RF__
\r
780 if(dbg_pagedelayrendermap) DBG_RFDELAYMETHOD;
\r
791 void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *player)
\r
794 #if defined(FULLRCREND) || defined(__DEBUG_RF__)
\r
795 word drawtileoffset=0;
\r
796 //printf("x: %d ", drawtileoffset);
\r
797 drawtileoffset%=player[0].enti.spt;
\r
798 //printf("%d\n", drawtileoffset);
\r
800 #ifdef __DEBUG_RF__
\r
801 if(dbg_pagedelayrendermap){ if(!x) x+=TILEWH; else x-=TILEWH;
\r
802 sprintf(global_temp_status_text, "%-3u", drawtileoffset); modexprint(mv->page, player[0].enti.x, player[0].enti.y-28-(drawtileoffset*8) , 1, 0, PALMAPDRAWW, 1, 1, global_temp_status_text); }
\r
804 /* location in the map array */
\r
805 i=ty * mv->map->width + tx;
\r
806 /* We'll copy all of the columns in the screen,
\r
807 i + 1 row above and one below */
\r
809 for( mv->dy=drawtileoffset; mv->dy<(mv->page->sh+mv->dyThresh)/(drawtileoffset+1) && ty < mv->map->height; mv->dy+=mv->map->tiles->tileHeight, ty++) {
\r
811 for(mv->dy=0; mv->dy<mv->page->sh+mv->dyThresh && ty < mv->map->height; mv->dy+=mv->map->tiles->tileHeight, ty++) {
\r
814 mapDrawTile(mv->map->tiles, mv->map->layerdata[0].data[i], mv->page, x, mv->dy);
\r
815 i += mv->map->width;
\r
817 #ifdef __DEBUG_RF__
\r
818 if(dbg_pagedelayrendermap) DBG_RFDELAYMETHOD;
\r
822 void mapDrawWRow(map_view_t *mv, int tx, int ty, word y)
\r
826 /* the position within the map array */
\r
827 i=ty * mv->map->width + tx;
\r
828 for(mv->dx=0; mv->dx<mv->page->sw+mv->dxThresh && tx < mv->map->width; mv->dx+=mv->map->tiles->tileWidth, tx++) {
\r
829 if(i>=0){ /* we are in the map, so copy! */
\r
830 mapDrawTile(mv->map->tiles, mv->map->layerdata[0].data[i], mv->page, mv->dx, y);
\r
832 if(mv->map->layerdata[z].data[i]){
\r
833 sprintf(global_temp_status_text2, "%u", mv->map->layerdata[z].data[i]); modexprint(mv->page, mv->dx, y, 1, 0, PALMAPDRAWW, z+2, 1, global_temp_status_text2);
\r
834 //mapDrawTile(mv->map->tiles, mv->map->layerdata[z].data[i], mv->page, mv->dx, y);
\r
841 void mapDrawWCol(map_view_t *mv, int tx, int ty, word x)
\r
845 /* location in the map array */
\r
846 i=ty * mv->map->width + tx;
\r
848 /* We'll copy all of the columns in the screen,
\r
849 i + 1 row above and one below */
\r
850 for(mv->dy=0; mv->dy<mv->page->sh+mv->dyThresh && ty < mv->map->height; mv->dy+=mv->map->tiles->tileHeight, ty++) {
\r
851 if(i>=0){ /* we are in the map, so copy away! */
\r
852 mapDrawTile(mv->map->tiles, mv->map->layerdata[0].data[i], mv->page, x, mv->dy);
\r
854 if(mv->map->layerdata[z].data[i]){
\r
855 sprintf(global_temp_status_text2, "%u", mv->map->layerdata[z].data[i]); modexprint(mv->page, x, mv->dy, 1, 0, PALMAPDRAWW, z+2, 1, global_temp_status_text2);
\r
856 //mapDrawTile(mv->map->tiles, mv->map->layerdata[z].data[i], mv->page, x, mv->dy);
\r
859 i += mv->map->width;
\r
865 void shinku(global_game_variables_t *gv)
\r
868 word x = gv->video.page[/*!*/(gv->video.p)].dx; //(gv->video.page[(gv->video.p)].tlx) - // follow the screen
\r
869 word y = gv->video.page[/*!*/(gv->video.p)].dy; //(gv->video.page[(gv->video.p)].tly) - // follow the screen
\r
870 word col = 2, bgcol = 1, type = 1;//w = 64, h = 8,
\r
872 if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second))
\r
875 // NTS: For some bizarre reason, gv->pee is not initialized, but the pointer is not NULL even
\r
876 // though it should be. Instead it's NULL as a neAr pointer but contains a non-null
\r
877 // segment value, so testing against NULL doesn't work. It is initialized properly if
\r
878 // you call start_timer() though which uses neAr mAlloc. Rather than fight with that,
\r
879 // I decided it would be better to declare a temp buffer statically and sprintf to that.
\r
881 // This fixes *** Null pointer assignment detected error message in ZCROLL.EXE on exit.
\r
882 sprintf(global_temp_status_text, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv));
\r
883 //modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, 1, col, bgcol, global_temp_status_text);
\r
884 if(gv->kurokku.wcpu)
\r
886 modexCopyPageRegion(&gv->video.page[0], &gv->video.page[1],
\r
887 gv->video.page[/*!*/(gv->video.p)].dx,
\r
888 gv->video.page[/*!*/(gv->video.p)].dy,
\r
889 gv->video.page[/*!*/(gv->video.p)].dx,
\r
890 gv->video.page[/*!*/(gv->video.p)].dy,
\r
892 modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, 1, col, bgcol, 1, global_temp_status_text);
\r
893 //0000printf("dx=%u dy=%u\n", gv->video.page[/*!*/(gv->video.p)].dx, gv->video.page[/*!*/(gv->video.p)].dy);
\r
896 gv->kurokku.tiku=0;
\r
897 }else //copy dat sheet
\r
898 gv->kurokku.tiku++;
\r
901 if(gv->video.dorender)
\r
905 modexCopyPageRegion(&(gv->video.page[ ]), &(gv->video.page[ ]), 0, 0, 0, 0, gv->video.page[ ].width, gv->video.page[ ].height);
\r
907 //modexCopyPageRegion(&video->page[0], &video->page[1], enti->x, enti->y, 0, 0, 24, 32);
\r
909 #ifndef OLDWALKSHOWPAGESTUFF
\r
910 VL_ShowPage(&(gv->video.page[gv->video.sp]), gv->kurokku.fpscap, 0);
\r
912 gv->video.dorender =!gv->video.dorender;
\r
913 //0000gv->video.tickclk = ((*clockw)-gv->video.startclk)/18.2;
\r
916 switch(gv->kurokku.fpscap)
\r
918 case 0: //turn this off if XT
\r
919 //modexprint(&(gv->video.page[0]), x, y+8, type, 1, col, bgcol, "sanic!");
\r
920 gv->kurokku.frames_per_second=1;
\r
923 //#ifndef OLDWALKSHOWPAGESTUFF
\r
924 //vga_wait_for_vsync();
\r
925 vga_wait_for_vsync_end();
\r
927 //modexWaitBorder();
\r
929 gv->kurokku.frames_per_second=FPSVALUE;
\r
935 void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn)
\r
937 sword x = player[pn].enti.x;
\r
938 sword y = player[pn].enti.y;
\r
939 sword qq,dd; //scroll offset
\r
940 player[pn].enti.dire=10; //direction
\r
942 switch(player[pn].walktype)
\r
954 qq = player[pn].enti.q*player[pn].enti.spt;
\r
958 y-=pip[0].map->tiles->tileHeight;
\r
959 switch (player[pn].enti.d)
\r
963 player[pn].enti.dire*=player[pn].enti.d+1;
\r
968 player[pn].enti.dire*=(player[pn].enti.d-1);
\r
975 player[pn].enti.dire*=(player[pn].enti.d-1);
\r
980 player[pn].enti.dire*=(player[pn].enti.d+3);
\r
984 player[pn].enti.dire+=dd;
\r
985 //setting xy position
\r
986 player[pn].enti.spri.x = x;
\r
987 player[pn].enti.spri.y = y;
\r
989 if((player[pn].enti.q==1 && player[pn].enti.pred != player[pn].enti.d) || !dd)//when dir changed OR when player change face direction
\r
991 //0000printf(" q=%u pred=%u d=%u dd=%u\n", player[pn].enti.q, player[pn].enti.pred, player[pn].enti.d, dd);
\r
992 set_anim_by_id(&player[pn].enti.spri, player[pn].enti.dire); //pip->video->sprifilei = set_anim_by_id(player[pn].enti.spri, player[pn].enti.dire); if(pip->video->sprifilei == -1){ printf("ERROR! %u\n", player[pn].enti.dire); return; }
\r
993 player[pn].enti.pred = player[pn].enti.d;
\r
994 if(!dd)//changed direction while NOT moving!
\r
996 modexCopyPageRegion(pip[0].page, pip[1].page, x-4, y-4, x-4, y-4, 28, 40);
\r
997 animate_spri(&player[pn].enti, pip[0].video);
\r
1001 if(pip[0].video->vga_state.bgps && dd)//if moving wwww
\r
1003 modexCopyPageRegion(pip[0].page, pip[1].page, x-4, y-4, x-4, y-4, 28, 40);
\r
1006 animate_spri(&player[pn].enti, pip[0].video);
\r
1008 //0000if(player[pn].enti.q<4) delay(200);
\r
1009 #ifdef OLDWALKSHOWPAGESTUFF
\r
1010 modexWaitBorder();
\r
1018 boolean boundary_check(int x, int y, int dx, int dy, int h, int w)
\r
1020 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
1023 boolean coll_check(int x, int y, int dx, int dy, map_view_t *map_v)
\r
1025 // Assume everything crosses at most 1 tile at once
\r
1026 return dx && 1;//crossable_tile(x + dx, map_v) || dy && crossable_tile(y + dy, map_v);
\r
1029 boolean ZC_walk2(entity_t *enti, map_view_t *map_v)
\r
1049 if(coll_check(enti->x, enti->y, dx, dy, map_v))
\r
1053 // Start animation
\r
1054 // Mark next tile as occupied
\r
1055 // Mark this tile as vacant
\r
1061 void player_walk(player_t *player, map_view_t *map_v){
\r
1063 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->ti.tilesw, map_v->map->height - 2*map_v->page->ti.tilesh))
\r
1065 mapScroll(map_v, player);
\r
1066 // (Un)load stuff?
\r
1075 void mapScroll(map_view_t *mv, player_t *player)
\r
1077 //word x, y; /* coordinate for drawing */
\r
1080 mv->delta += player->dx | player->dy;
\r
1081 delta = mv->delta;
\r
1082 mv->d = (player->dx) ? (player->dx > 0) ? 3 : 1 : (player->dy) ? (player->dy > 0) ? 4 : 0 : 2;
\r
1088 if(!(delta + mv->dxThresh))
\r
1098 if(!(delta + mv->dyThresh))
\r
1109 void ZC_GirdChk (global_game_variables_t *gvar, player_t *player)
\r
1111 if((player->enti.q==1) &&
\r
1112 !(player->enti.x%gvar->mv[0].map->tiles->tileWidth==0 && player->enti.y%gvar->mv[0].map->tiles->tileHeight==0))
\r
1113 ZC_PlayerXYpos(0, 0, player, gvar->mv, 1);
\r
1114 //TODO: MAKE SURE TO RESYNC PLAYER IN WALKABLE SPOT
\r