1 /* Project 16 Source Code~
\r
2 * Copyright (C) 2012-2017 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.speed);
\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.speed);
\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.speed);
\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.speed);
\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_ 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
416 void ZC_ShowMV(map_view_t *moo, boolean vsync, boolean sr)
\r
418 VL_ShowPage(moo[0].page, vsync, sr);
\r
423 initMap(map_t *map) {
\r
424 // just a place holder to fill out an alternating pattern
\r
430 for(y=0; y<map->height; y++) {
\r
431 for(x=0; x<map->width; x++) {
\r
432 map->layerdata[0].data[i]=255;
\r
433 // printf("[%d]", map->layerdata[0].data[i]);
\r
434 tile = tile ? 0 : 1;
\r
437 tile = tile ? 0 : 1;
\r
442 initMap(map_t *map) {
\r
443 /* just a place holder to fill out an alternating pattern */
\r
447 map->tiles = malloc(sizeof(tiles_t));
\r
451 /* create the tile set */
\r
452 map->tiles->spri = malloc(sizeof(sprite_t));
\r
453 map->tiles->spri->sprite_vrl_cont.vrl_header->width = (TILEWH*2);
\r
454 map->tiles->spri->sprite_vrl_cont.vrl_header->height= TILEWH;
\r
455 map->tiles->spri->sprite_vrl_cont.buffer = malloc((TILEWH*2)*TILEWH);
\r
456 map->tiles->tileHeight = TILEWH;
\r
457 map->tiles->tileWidth =TILEWH*2;
\r
458 map->tiles->rows = 1;
\r
459 map->tiles->cols = 2;
\r
462 for(y=0; y<TILEWH; y++) {
\r
463 for(x=0; x<(TILEWH*2); x++) {
\r
465 map->tiles->spri->sprite_vrl_cont.buffer[i] = 28;//0x24;
\r
467 map->tiles->spri->sprite_vrl_cont.buffer[i] = 0;//0x34;
\r
474 for(y=0; y<map->height; y++) {
\r
475 for(x=0; x<map->width; x++) {
\r
476 map->layerdata[0].data[i] = tile;
\r
477 // printf("%u ", map->layerdata[0].data[i]);
\r
478 tile = tile ? 0 : 1;
\r
482 tile = tile ? 0 : 1;
\r
486 //===========================================================================//
\r
489 void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
\r
491 word x;//, y; /* coordinate for drawing */
\r
493 ScrollRight(mv, player, id, plid);
\r
495 /* draw the next column */
\r
496 x= mv[0].page->sw + mv[0].map->tiles->tileWidth;
\r
497 if(ZCL_mapEdgeChk(mv, player[plid].enti.d, player[plid].enti.tx, player[plid].enti.ty, 0, 0))
\r
499 if(player[plid].enti.q%4)
\r
501 if(player[plid].enti.q==4)
\r
504 mapDrawCol(&mv[id], mv[0].tx + mv[0].page->ti.tw, mv[0].ty-1, x, player, DRAWCOLNUM);
\r
506 // if(mv[0].video->vga_state.bgps)
\r
507 // modexCopyPageRegion(mv->page, mv[0].page, x, 0, x, 0, mv[0].map->tiles->tileWidth, mv[0].page->height);
\r
508 //mv[0].video->dorender=1;//ScrollRight
\r
512 void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
\r
514 word x;//,y; /* coordinate for drawing */
\r
516 ScrollLeft(mv, player, id, plid);
\r
518 /* draw the next column */
\r
520 if(ZCL_mapEdgeChk(mv, player[plid].enti.d, player[plid].enti.tx, player[plid].enti.ty, 0, 0))
\r
522 if(player[plid].enti.q%4)
\r
524 if(player[plid].enti.q==4)
\r
527 mapDrawCol(&mv[id], mv[0].tx - 1, mv[0].ty-1, x, player, DRAWCOLNUM);
\r
529 // if(mv[0].video->vga_state.bgps)
\r
530 // modexCopyPageRegion(mv->page, mv[0].page, x, 0, x, 0, mv[0].map->tiles->tileWidth, mv[0].page->height);
\r
531 //mv[0].video->dorender=1;//ScrollLeft
\r
535 void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
\r
537 word y;//x, /* coordinate for drawing */
\r
539 ScrollUp(mv, player, id, plid);
\r
541 /* draw the next row */
\r
543 if(ZCL_mapEdgeChk(mv, player[plid].enti.d, player[plid].enti.tx, player[plid].enti.ty, 0, 0))
\r
545 if(player[plid].enti.q%3)
\r
547 if(player[plid].enti.q==4)
\r
550 mapDrawRow(&mv[id], mv[0].tx - 1, mv[0].ty-1, y, player, DRAWROWNUM);
\r
552 // if(mv[0].video->vga_state.bgps)
\r
553 // modexCopyPageRegion(mv->page, mv[0].page, 0, y, 0, y, mv[0].page->width, mv[0].map->tiles->tileHeight);
\r
554 //mv[0].video->dorender=1;//ScrollUp
\r
558 void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)
\r
560 word y;//x, /* coordinate for drawing */
\r
562 ScrollDown(mv, player, id, plid);
\r
564 /* draw the next row */
\r
565 y= mv[0].page->sh + mv[0].map->tiles->tileHeight;
\r
566 if(ZCL_mapEdgeChk(mv, player[plid].enti.d, player[plid].enti.tx, player[plid].enti.ty, 0, 0))
\r
568 if(player[plid].enti.q%3)
\r
570 if(player[plid].enti.q==4)
\r
573 mapDrawRow(&mv[id], mv[0].tx - 1, mv[0].ty+mv[0].page->ti.th, y, player, DRAWROWNUM);
\r
575 // if(mv[0].video->vga_state.bgps)
\r
576 // modexCopyPageRegion(mv->page, mv[0].page, 0, y, 0, y, mv[0].page->width, mv[0].map->tiles->tileHeight);
\r
577 //mv[0].video->dorender=1;//ScrollDown
\r
580 void ZC_mapScroll(map_view_t *mv, player_t *player, word pn)
\r
582 word b = mv[0].video->vga_state.bgps;
\r
583 switch(player[pn].enti.d)
\r
588 ScrollRight(mv, player, 3, pn);
\r
589 ScrollRight(mv, player, 2, pn);
\r
590 mapScrollRight(mv, player, (0), pn);
\r
591 if(b) mapScrollRight(mv, player, (1), pn);
\r
594 ScrollLeft(mv, player, 3, pn);
\r
595 ScrollLeft(mv, player, 2, pn);
\r
596 mapScrollLeft(mv, player, (0), pn);
\r
597 if(b) mapScrollLeft(mv, player, (1), pn);
\r
600 ScrollDown(mv, player, 3, pn);
\r
601 ScrollDown(mv, player, 2, pn);
\r
602 mapScrollDown(mv, player, (0), pn);
\r
603 if(b) mapScrollDown(mv, player, (1), pn);
\r
606 ScrollUp(mv, player, 3, pn);
\r
607 ScrollUp(mv, player, 2, pn);
\r
608 mapScrollUp(mv, player, (0), pn);
\r
609 if(b) mapScrollUp(mv, player, (1), pn);
\r
612 //mv[0].video->dorender=1;//ZC_mapScroll
\r
615 //===========================================================================
\r
616 //TODO: put player in starting position of assigned spot on map
\r
617 //default player position on the viewable map
\r
618 void ZC_PlayerXYpos(int x, int y, player_t *player, map_view_t *pip, boolean defaultsw)
\r
620 player->enti.tx = x + pip[0].tx;
\r
621 player->enti.ty = y + pip[0].ty;
\r
626 player->enti.tx += pip[0].page->ti.tilemidposscreenx;
\r
627 player->enti.ty += pip[0].page->ti.tilemidposscreeny;
\r
633 //===========================================================================
\r
635 void ZC_checkardmap(map_t *map)
\r
637 // just a place holder to fill out an alternating pattern
\r
640 static byte z[(MAPW*MAPH)];//map->width*map->height];
\r
644 for(y=0; y<map->height; y++) {
\r
645 for(x=0; x<map->width; x++) {
\r
647 tile = tile ? 0 : 1;
\r
650 tile = tile ? 0 : 1;
\r
652 map->layerdata[0].data = &z;
\r
655 sword chkmap(map_t *map, word q)
\r
658 // static byte x[(MAPW*MAPH)+1] =
\r
659 //{ 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, 1, 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 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
662 //check for failed to load map
\r
663 if((map->width == map->height == 0) && (q>0))
\r
665 //initiate a null map!
\r
668 // map->layerdata[0].data = fmfaflflfofcf(((map->width*map->height)+1)*sizeof(byte));
\r
669 ZC_checkardmap(map);//map->layerdata[0].data = &x;
\r
670 //fix this to be far~
\r
671 // bp = bitmapLoadPcx("data/ed.pcx");
\r
672 // map->tiles->data = &bp;
\r
673 map->tiles->tileHeight = 16;
\r
674 map->tiles->tileWidth = 16;
\r
675 map->tiles->rows = 1;
\r
676 map->tiles->cols = 1;
\r
681 //TODO: player position here
\r
682 void mapGoTo(map_view_t *mv, int tx, int ty)
\r
684 ZC_mapinitMV(mv, tx, ty);
\r
686 /* draw the tiles */
\r
687 modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 0);
\r
688 ZC_mapredraw(mv, tx, ty);
\r
690 //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
693 void ZC_mapinitMV(map_view_t *mv, int tx, int ty)
\r
695 /* set up the coordinates */
\r
696 mv[0].tx = mv[1].tx = tx;
\r
697 mv[0].ty = mv[1].ty = ty;
\r
698 mv[0].page->dx = mv[1].page->dx = mv[2].page->dx = mv[3].page->dx = mv->map->tiles->tileWidth;
\r
699 mv[0].page->dy = mv[1].page->dy = mv[2].page->dy = mv[3].page->dy = mv->map->tiles->tileHeight;
\r
701 /* set up the thresholds */
\r
702 mv[0].dxThresh = mv[1].dxThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileWidth * 2;
\r
703 mv[0].dyThresh = mv[1].dyThresh = mv[2].dyThresh = mv[3].dyThresh = mv->map->tiles->tileHeight * 2;
\r
706 void ZC_mapredraw(map_view_t *mv, int tx, int ty)
\r
712 i=mv[0].ty * mv[0].map->width + mv[0].tx;
\r
713 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
714 mapDrawWRow(&mv[0], tx-1, ty, py);
\r
715 mapDrawWRow(&mv[1], tx-1, ty, py);
\r
716 i+=mv->map->width - tx;
\r
721 mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y)
\r
724 // printf("%02d ", i); if(x >= page->width - t->tileWidth) printf("\n");
\r
729 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 1); //currently the over scan color!
\r
732 rx = (((i-1) % ((t->spri->sprite_vrl_cont.vrl_header->width)/t->tileWidth)) * t->tileWidth);
\r
733 ry = (((i-1) / ((t->spri->sprite_vrl_cont.vrl_header->height)/t->tileHeight)) * t->tileHeight);
\r
735 #ifdef __DEBUG_RF__
\r
736 if(!dbg_pagenorendermap)
\r
738 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, i+1);
\r
740 modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, i);
\r
741 //draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));
\r
742 //modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
\r
744 #ifdef __DEBUG_MAP__
\r
745 if(dbg_maptext){ sprintf(global_temp_status_text2, "%u", i); modexprint(page, x, y, 1, 0, 1, 2, 1, global_temp_status_text2); }
\r
750 #define PALMAPDRAWW 13
\r
751 void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *player, word poopoffset)
\r
754 #ifdef __DEBUG_RF__
\r
755 if(dbg_pagedelayrendermap) if(!y) y+=TILEWH; else y-=TILEWH;
\r
757 poopoffset%=player[0].enti.speed;
\r
758 //printf("y: %d\n", poopoffset);
\r
759 #ifdef __DEBUG_RF__
\r
760 if(dbg_pagedelayrendermap){ sprintf(global_temp_status_text, "%-3u", mv->dx); modexprint(mv[0].page, player[0].enti.x, player[0].enti.y-28-(poopoffset*8) , 1, 0, PALMAPDRAWW, 1, 1, global_temp_status_text); }
\r
762 /* the position within the map array */
\r
763 i=ty * mv->map->width + tx;
\r
764 for( mv->dx=poopoffset; mv->dx<(mv->page->sw+mv->dxThresh)/(poopoffset+1) && tx < mv->map->width; mv->dx+=mv->map->tiles->tileWidth, tx++) {
\r
766 mapDrawTile(mv->map->tiles, mv->map->layerdata[0].data[i], mv->page, mv->dx, y);
\r
768 if(mv->map->layerdata[z].data[i]){
\r
769 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
770 //mapDrawTile(mv->map->tiles, mv->map->layerdata[z].data[i], mv->page, mv->dx, y);
\r
775 #ifdef __DEBUG_RF__
\r
776 if(dbg_pagedelayrendermap) delay(200);
\r
780 void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *player, word poopoffset)
\r
783 #ifdef __DEBUG_RF__
\r
784 if(dbg_pagedelayrendermap) if(!x) x+=TILEWH; else x-=TILEWH;
\r
786 poopoffset%=player[0].enti.speed;
\r
787 //printf("x: %d\n", poopoffset);
\r
788 #ifdef __DEBUG_RF__
\r
789 if(dbg_pagedelayrendermap){ sprintf(global_temp_status_text, "%-3u", mv->dy); modexprint(mv[0].page, player[0].enti.x, player[0].enti.y-28-(poopoffset*8) , 1, 0, PALMAPDRAWW, 1, global_temp_status_text); }
\r
791 /* location in the map array */
\r
792 i=ty * mv->map->width + tx;
\r
793 /* We'll copy all of the columns in the screen,
\r
794 i + 1 row above and one below */
\r
795 for( mv->dy=poopoffset; mv->dy<(mv->page->sh+mv->dyThresh)/(poopoffset+1) && ty < mv->map->height; mv->dy+=mv->map->tiles->tileHeight, ty++) {
\r
797 mapDrawTile(mv->map->tiles, mv->map->layerdata[0].data[i], mv->page, x, mv->dy);
\r
799 if(mv->map->layerdata[z].data[i]){
\r
800 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
801 //mapDrawTile(mv->map->tiles, mv->map->layerdata[z].data[i], mv->page, x, mv->dy);
\r
804 i += mv->map->width;
\r
806 #ifdef __DEBUG_RF__
\r
807 if(dbg_pagedelayrendermap) delay(200);
\r
811 void mapDrawWRow(map_view_t *mv, int tx, int ty, word y)
\r
815 /* the position within the map array */
\r
816 i=ty * mv->map->width + tx;
\r
817 for(mv->dx=0; mv->dx<mv->page->sw+mv->dxThresh && tx < mv->map->width; mv->dx+=mv->map->tiles->tileWidth, tx++) {
\r
818 if(i>=0){ /* we are in the map, so copy! */
\r
819 mapDrawTile(mv->map->tiles, mv->map->layerdata[0].data[i], mv->page, mv->dx, y);
\r
821 if(mv->map->layerdata[z].data[i]){
\r
822 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
823 //mapDrawTile(mv->map->tiles, mv->map->layerdata[z].data[i], mv->page, mv->dx, y);
\r
830 void mapDrawWCol(map_view_t *mv, int tx, int ty, word x)
\r
834 /* location in the map array */
\r
835 i=ty * mv->map->width + tx;
\r
837 /* We'll copy all of the columns in the screen,
\r
838 i + 1 row above and one below */
\r
839 for(mv->dy=0; mv->dy<mv->page->sh+mv->dyThresh && ty < mv->map->height; mv->dy+=mv->map->tiles->tileHeight, ty++) {
\r
840 if(i>=0){ /* we are in the map, so copy away! */
\r
841 mapDrawTile(mv->map->tiles, mv->map->layerdata[0].data[i], mv->page, x, mv->dy);
\r
843 if(mv->map->layerdata[z].data[i]){
\r
844 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
845 //mapDrawTile(mv->map->tiles, mv->map->layerdata[z].data[i], mv->page, x, mv->dy);
\r
848 i += mv->map->width;
\r
854 void shinku(global_game_variables_t *gv)
\r
857 word x = gv->video.page[/*!*/(gv->video.p)].dx; //(gv->video.page[(gv->video.p)].tlx) - // follow the screen
\r
858 word y = gv->video.page[/*!*/(gv->video.p)].dy; //(gv->video.page[(gv->video.p)].tly) - // follow the screen
\r
859 word col = 2, bgcol = 1, type = 1;//w = 64, h = 8,
\r
861 if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second))
\r
864 // NTS: For some bizarre reason, gv->pee is not initialized, but the pointer is not NULL even
\r
865 // though it should be. Instead it's NULL as a neAr pointer but contains a non-null
\r
866 // segment value, so testing against NULL doesn't work. It is initialized properly if
\r
867 // you call start_timer() though which uses neAr mAlloc. Rather than fight with that,
\r
868 // I decided it would be better to declare a temp buffer statically and sprintf to that.
\r
870 // This fixes *** Null pointer assignment detected error message in ZCROLL.EXE on exit.
\r
871 sprintf(global_temp_status_text, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv));
\r
872 //modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, 1, col, bgcol, global_temp_status_text);
\r
873 if(gv->kurokku.wcpu)
\r
875 modexCopyPageRegion(&gv->video.page[0], &gv->video.page[1],
\r
876 gv->video.page[/*!*/(gv->video.p)].dx,
\r
877 gv->video.page[/*!*/(gv->video.p)].dy,
\r
878 gv->video.page[/*!*/(gv->video.p)].dx,
\r
879 gv->video.page[/*!*/(gv->video.p)].dy,
\r
881 modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, 1, col, bgcol, 1, global_temp_status_text);
\r
882 //0000printf("dx=%u dy=%u\n", gv->video.page[/*!*/(gv->video.p)].dx, gv->video.page[/*!*/(gv->video.p)].dy);
\r
885 gv->kurokku.tiku=0;
\r
886 }else //copy dat sheet
\r
887 gv->kurokku.tiku++;
\r
890 if(gv->video.dorender)
\r
894 modexCopyPageRegion(&(gv->video.page[ ]), &(gv->video.page[ ]), 0, 0, 0, 0, gv->video.page[ ].width, gv->video.page[ ].height);
\r
896 //modexCopyPageRegion(&video->page[0], &video->page[1], enti->x, enti->y, 0, 0, 24, 32);
\r
898 #ifndef OLDWALKSHOWPAGESTUFF
\r
899 VL_ShowPage(&(gv->video.page[gv->video.sp]), gv->kurokku.fpscap, 0);
\r
901 gv->video.dorender =!gv->video.dorender;
\r
902 //0000gv->video.tickclk = ((*clockw)-gv->video.startclk)/18.2;
\r
905 switch(gv->kurokku.fpscap)
\r
907 case 0: //turn this off if XT
\r
908 //modexprint(&(gv->video.page[0]), x, y+8, type, 1, col, bgcol, "sanic!");
\r
909 gv->kurokku.frames_per_second=1;
\r
912 //#ifndef OLDWALKSHOWPAGESTUFF
\r
913 //vga_wait_for_vsync();
\r
914 vga_wait_for_vsync_end();
\r
916 //modexWaitBorder();
\r
918 gv->kurokku.frames_per_second=FPSVALUE;
\r
924 void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn)
\r
926 sword x = player[pn].enti.x;
\r
927 sword y = player[pn].enti.y;
\r
928 sword qq,dd; //scroll offset
\r
929 player[pn].enti.dire=10; //direction
\r
931 switch(player[pn].walktype)
\r
943 qq = player[pn].enti.q*player[pn].enti.speed;
\r
947 y-=pip[0].map->tiles->tileHeight;
\r
948 switch (player[pn].enti.d)
\r
952 player[pn].enti.dire*=player[pn].enti.d+1;
\r
957 player[pn].enti.dire*=(player[pn].enti.d-1);
\r
964 player[pn].enti.dire*=(player[pn].enti.d-1);
\r
969 player[pn].enti.dire*=(player[pn].enti.d+3);
\r
973 player[pn].enti.dire+=dd;
\r
974 //setting xy position
\r
975 player[pn].enti.spri.x = x;
\r
976 player[pn].enti.spri.y = y;
\r
978 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
980 //0000printf(" q=%u pred=%u d=%u dd=%u\n", player[pn].enti.q, player[pn].enti.pred, player[pn].enti.d, dd);
\r
981 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
982 player[pn].enti.pred = player[pn].enti.d;
\r
983 if(!dd)//changed direction while NOT moving!
\r
985 modexCopyPageRegion(pip[0].page, pip[1].page, x-4, y-4, x-4, y-4, 28, 40);
\r
986 animate_spri(&player[pn].enti, pip[0].video);
\r
990 if(pip[0].video->vga_state.bgps && dd)//if moving wwww
\r
992 modexCopyPageRegion(pip[0].page, pip[1].page, x-4, y-4, x-4, y-4, 28, 40);
\r
995 animate_spri(&player[pn].enti, pip[0].video);
\r
997 //0000if(player[pn].enti.q<4) delay(200);
\r
998 #ifdef OLDWALKSHOWPAGESTUFF
\r
1007 boolean boundary_check(int x, int y, int dx, int dy, int h, int w)
\r
1009 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
1012 boolean coll_check(int x, int y, int dx, int dy, map_view_t *map_v)
\r
1014 // Assume everything crosses at most 1 tile at once
\r
1015 return dx && 1;//crossable_tile(x + dx, map_v) || dy && crossable_tile(y + dy, map_v);
\r
1018 boolean ZC_walk2(entity_t *enti, map_view_t *map_v)
\r
1038 if(coll_check(enti->x, enti->y, dx, dy, map_v))
\r
1042 // Start animation
\r
1043 // Mark next tile as occupied
\r
1044 // Mark this tile as vacant
\r
1050 void player_walk(player_t *player, map_view_t *map_v){
\r
1052 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
1054 mapScroll(map_v, player);
\r
1055 // (Un)load stuff?
\r
1064 void mapScroll(map_view_t *mv, player_t *player)
\r
1066 //word x, y; /* coordinate for drawing */
\r
1069 mv->delta += player->dx | player->dy;
\r
1070 delta = mv->delta;
\r
1071 mv->d = (player->dx) ? (player->dx > 0) ? 3 : 1 : (player->dy) ? (player->dy > 0) ? 4 : 0 : 2;
\r
1077 if(!(delta + mv->dxThresh))
\r
1087 if(!(delta + mv->dyThresh))
\r
1098 void ZC_GirdChk (global_game_variables_t *gvar, player_t *player)
\r
1100 if((player->enti.q==1) &&
\r
1101 !(player->enti.x%gvar->mv[0].map->tiles->tileWidth==0 && player->enti.y%gvar->mv[0].map->tiles->tileHeight==0))
\r
1102 ZC_PlayerXYpos(0, 0, player, gvar->mv, 1);
\r
1103 //TODO: MAKE SURE TO RESYNC PLAYER IN WALKABLE SPOT
\r