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(player[pn].enti.q&1) player[pn].enti.persist_aniframe++; if(player[pn].enti.persist_aniframe>4) player[pn].enti.persist_aniframe = 1;
\r
129 #ifdef OLDWALKSHOWPAGESTUFF
\r
130 #define SHOWMVFUN__ ZC_ShowMV(pip, 1, 0);
\r
133 void ZC_walk(map_view_t *pip, player_t *player, word pn)
\r
135 switch(player[pn].enti.d)
\r
139 //0000pip[0].video->startclk = (*clockw);
\r
143 if(ZCL_ScreenMidPosChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty) &&
\r
144 ZCL_CollCheck(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection!
\r
146 player[pn].walktype=2;
\r
147 if(player[pn].enti.q<=player[pn].enti.spt)
\r
149 ZC_animatePlayer(pip, player, pn);
\r
150 ZC_mapScroll(pip, player, pn);
\r
151 player[pn].enti.q++;
\r
152 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
153 #ifdef OLDWALKSHOWPAGESTUFF
\r
156 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
158 else if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 0, 1) &&
\r
159 ZCL_CollCheck(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY))
\r
161 player[pn].walktype=1;
\r
162 if(player[pn].enti.q<=player[pn].enti.spt)
\r
164 player[pn].enti.x+=(player[pn].enti.speed);
\r
165 ZC_animatePlayer(pip, player, pn);
\r
166 player[pn].enti.q++;
\r
167 #ifdef OLDWALKSHOWPAGESTUFF
\r
170 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
174 player[pn].walktype=0;
\r
175 ZC_animatePlayer(pip, player, pn);
\r
176 player[pn].enti.d = 2;
\r
177 #ifdef OLDWALKSHOWPAGESTUFF
\r
181 player[pn].enti.triggerx = player[pn].enti.tx+1;
\r
182 player[pn].enti.triggery = player[pn].enti.ty;
\r
186 if(ZCL_ScreenMidPosChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty) &&
\r
187 ZCL_CollCheck(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection!
\r
189 player[pn].walktype=2;
\r
190 if(player[pn].enti.q<=player[pn].enti.spt)
\r
192 ZC_animatePlayer(pip, player, pn);
\r
193 ZC_mapScroll(pip, player, pn);
\r
194 player[pn].enti.q++;
\r
195 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
196 #ifdef OLDWALKSHOWPAGESTUFF
\r
199 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
201 else if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 0, 1) &&
\r
202 ZCL_CollCheck(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY))
\r
204 player[pn].walktype=1;
\r
205 if(player[pn].enti.q<=player[pn].enti.spt)
\r
207 player[pn].enti.x-=(player[pn].enti.speed);
\r
208 ZC_animatePlayer(pip, player, pn);
\r
209 player[pn].enti.q++;
\r
210 #ifdef OLDWALKSHOWPAGESTUFF
\r
213 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
217 player[pn].walktype=0;
\r
218 ZC_animatePlayer(pip, player, pn);
\r
219 player[pn].enti.d = 2;
\r
220 #ifdef OLDWALKSHOWPAGESTUFF
\r
224 player[pn].enti.triggerx = player[pn].enti.tx-1;
\r
225 player[pn].enti.triggery = player[pn].enti.ty;
\r
229 if(ZCL_ScreenMidPosChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty) &&
\r
230 ZCL_CollCheck(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY)) //collision detection!
\r
232 player[pn].walktype=2;
\r
233 if(player[pn].enti.q<=player[pn].enti.spt)
\r
235 ZC_animatePlayer(pip, player, pn);
\r
236 ZC_mapScroll(pip, player, pn);
\r
237 player[pn].enti.q++;
\r
238 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
239 #ifdef OLDWALKSHOWPAGESTUFF
\r
242 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
244 else if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 0, 1) &&
\r
245 ZCL_CollCheck(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY))
\r
247 player[pn].walktype=1;
\r
248 if(player[pn].enti.q<=player[pn].enti.spt)
\r
250 player[pn].enti.y+=(player[pn].enti.speed);
\r
251 ZC_animatePlayer(pip, player, pn);
\r
252 player[pn].enti.q++;
\r
253 #ifdef OLDWALKSHOWPAGESTUFF
\r
256 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
260 player[pn].walktype=0;
\r
261 ZC_animatePlayer(pip, player, pn);
\r
262 player[pn].enti.d = 2;
\r
263 #ifdef OLDWALKSHOWPAGESTUFF
\r
267 player[pn].enti.triggerx = player[pn].enti.tx;
\r
268 player[pn].enti.triggery = player[pn].enti.ty+1;
\r
272 if(ZCL_ScreenMidPosChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty) &&
\r
273 ZCL_CollCheck(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY)) //collision detection!
\r
275 player[pn].walktype=2;
\r
276 if(player[pn].enti.q<=player[pn].enti.spt)
\r
278 ZC_animatePlayer(pip, player, pn);
\r
279 ZC_mapScroll(pip, player, pn);
\r
280 player[pn].enti.q++;
\r
281 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
282 #ifdef OLDWALKSHOWPAGESTUFF
\r
285 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
287 else if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 0, 1) &&
\r
288 ZCL_CollCheck(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY))
\r
290 player[pn].walktype=1;
\r
291 if(player[pn].enti.q<=player[pn].enti.spt)
\r
293 player[pn].enti.y-=(player[pn].enti.speed);
\r
294 ZC_animatePlayer(pip, player, pn);
\r
295 player[pn].enti.q++;
\r
296 #ifdef OLDWALKSHOWPAGESTUFF
\r
299 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
303 player[pn].walktype=0;
\r
304 ZC_animatePlayer(pip, player, pn);
\r
305 player[pn].enti.d = 2;
\r
306 #ifdef OLDWALKSHOWPAGESTUFF
\r
310 player[pn].enti.triggerx = player[pn].enti.tx;
\r
311 player[pn].enti.triggery = player[pn].enti.ty-1;
\r
318 void ZC_panPageManual(map_view_t *pip, player_t *player, word pn)
\r
320 #define SHOWMVFUN_ ZC_ShowMV(pip, 0, 0);
\r
321 switch(player[pn].enti.d)
\r
325 if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 1, 0))
\r
327 if(player[pn].enti.q<=player[pn].enti.spt)
\r
329 pip[0].page->dx+=4;
\r
331 player[pn].enti.q++;
\r
332 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].tx++; }
\r
338 if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 1, 0))
\r
340 if(player[pn].enti.q<=player[pn].enti.spt)
\r
342 pip[0].page->dx-=4;
\r
344 player[pn].enti.q++;
\r
345 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].tx--; }
\r
351 if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 1, 0))
\r
353 if(player[pn].enti.q<=player[pn].enti.spt)
\r
355 pip[0].page->dy+=4;
\r
357 player[pn].enti.q++;
\r
358 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].ty++; }
\r
364 if(ZCL_mapEdgeChk(pip, player[pn].enti.d, player[pn].enti.tx, player[pn].enti.ty, 1, 0))
\r
366 if(player[pn].enti.q<=player[pn].enti.spt)
\r
368 pip[0].page->dy-=4;
\r
370 player[pn].enti.q++;
\r
371 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].ty--; }
\r
380 void ZC_MVSetup(map_view_t *pip, map_t *map, global_game_variables_t *gv)
\r
385 pip[0].page = &gv->video.page[0];
\r
387 pip[0].video = &gv->video;
\r
388 pip[0].kurokku = &gv->kurokku;
\r
389 pip[0].p = &gv->video.p;
\r
390 pip[0].sp = &gv->video.sp;
\r
391 ZC_MVInit(pip, 1, 1);
\r
393 for(i=ZC_MVI;i<gv->video.num_of_pages;i++)
\r
395 pip[i].page = &gv->video.page[i];
\r
396 pip[i].map = pip[0].map;
\r
397 pip[i].video = pip[0].video;
\r
398 pip[i].p = pip[0].p;
\r
399 pip[i].sp = pip[0].sp;
\r
407 void ZC_MVInit(map_view_t *pip, int tx, int ty)
\r
411 //pip[0].tx = pip[1].tx = tx;
\r
412 //pip[0].ty = pip[1].ty = ty;
\r
415 void ZC_ShowMV(map_view_t *moo, boolean vsync, boolean sr)
\r
417 VL_ShowPage(moo[0].page, vsync, sr);
\r
422 initMap(map_t *map) {
\r
423 // just a place holder to fill out an alternating pattern
\r
429 for(y=0; y<map->height; y++) {
\r
430 for(x=0; x<map->width; x++) {
\r
431 map->layerdata[0].data[i]=255;
\r
432 // printf("[%d]", map->layerdata[0].data[i]);
\r
433 tile = tile ? 0 : 1;
\r
436 tile = tile ? 0 : 1;
\r
441 initMap(map_t *map) {
\r
442 /* just a place holder to fill out an alternating pattern */
\r
446 map->tiles = malloc(sizeof(tiles_t));
\r
450 /* create the tile set */
\r
451 map->tiles->spri = malloc(sizeof(sprite_t));
\r
452 map->tiles->spri->sprite_vrl_cont.vrl_header->width = (TILEWH*2);
\r
453 map->tiles->spri->sprite_vrl_cont.vrl_header->height= TILEWH;
\r
454 map->tiles->spri->sprite_vrl_cont.buffer = malloc((TILEWH*2)*TILEWH);
\r
455 map->tiles->tileHeight = TILEWH;
\r
456 map->tiles->tileWidth =TILEWH*2;
\r
457 map->tiles->rows = 1;
\r
458 map->tiles->cols = 2;
\r
461 for(y=0; y<TILEWH; y++) {
\r
462 for(x=0; x<(TILEWH*2); x++) {
\r
464 map->tiles->spri->sprite_vrl_cont.buffer[i] = 28;//0x24;
\r
466 map->tiles->spri->sprite_vrl_cont.buffer[i] = 0;//0x34;
\r
473 for(y=0; y<map->height; y++) {
\r
474 for(x=0; x<map->width; x++) {
\r
475 map->layerdata[0].data[i] = tile;
\r
476 // printf("%u ", map->layerdata[0].data[i]);
\r
477 tile = tile ? 0 : 1;
\r
481 tile = tile ? 0 : 1;
\r
485 //===========================================================================//
\r
488 void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
\r
490 word x;//, y; /* coordinate for drawing */
\r
492 ScrollRight(mv, player, id, plid);
\r
494 /* draw the next column */
\r
495 x= mv[0].page->sw + mv[0].map->tiles->tileWidth;
\r
496 if(ZCL_mapEdgeChk(mv, player[plid].enti.d, player[plid].enti.tx, player[plid].enti.ty, 0, 0))
\r
498 if(player[plid].enti.q%4)
\r
500 if(player[plid].enti.q==4)
\r
503 mapDrawCol(&mv[id], mv[0].tx + mv[0].page->ti.tw, mv[0].ty-1, x, player, DRAWCOLNUM);
\r
505 // if(mv[0].video->vga_state.bgps)
\r
506 // modexCopyPageRegion(mv->page, mv[0].page, x, 0, x, 0, mv[0].map->tiles->tileWidth, mv[0].page->height);
\r
507 //mv[0].video->dorender=1;//ScrollRight
\r
511 void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
\r
513 word x;//,y; /* coordinate for drawing */
\r
515 ScrollLeft(mv, player, id, plid);
\r
517 /* draw the next column */
\r
519 if(ZCL_mapEdgeChk(mv, player[plid].enti.d, player[plid].enti.tx, player[plid].enti.ty, 0, 0))
\r
521 if(player[plid].enti.q%4)
\r
523 if(player[plid].enti.q==4)
\r
526 mapDrawCol(&mv[id], mv[0].tx - 1, mv[0].ty-1, x, player, DRAWCOLNUM);
\r
528 // if(mv[0].video->vga_state.bgps)
\r
529 // modexCopyPageRegion(mv->page, mv[0].page, x, 0, x, 0, mv[0].map->tiles->tileWidth, mv[0].page->height);
\r
530 //mv[0].video->dorender=1;//ScrollLeft
\r
534 void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
\r
536 word y;//x, /* coordinate for drawing */
\r
538 ScrollUp(mv, player, id, plid);
\r
540 /* draw the next row */
\r
542 if(ZCL_mapEdgeChk(mv, player[plid].enti.d, player[plid].enti.tx, player[plid].enti.ty, 0, 0))
\r
544 if(player[plid].enti.q%3)
\r
546 if(player[plid].enti.q==4)
\r
549 mapDrawRow(&mv[id], mv[0].tx - 1, mv[0].ty-1, y, player, DRAWROWNUM);
\r
551 // if(mv[0].video->vga_state.bgps)
\r
552 // modexCopyPageRegion(mv->page, mv[0].page, 0, y, 0, y, mv[0].page->width, mv[0].map->tiles->tileHeight);
\r
553 //mv[0].video->dorender=1;//ScrollUp
\r
557 void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)
\r
559 word y;//x, /* coordinate for drawing */
\r
561 ScrollDown(mv, player, id, plid);
\r
563 /* draw the next row */
\r
564 y= mv[0].page->sh + mv[0].map->tiles->tileHeight;
\r
565 if(ZCL_mapEdgeChk(mv, player[plid].enti.d, player[plid].enti.tx, player[plid].enti.ty, 0, 0))
\r
567 if(player[plid].enti.q%3)
\r
569 if(player[plid].enti.q==4)
\r
572 mapDrawRow(&mv[id], mv[0].tx - 1, mv[0].ty+mv[0].page->ti.th, y, player, DRAWROWNUM);
\r
574 // if(mv[0].video->vga_state.bgps)
\r
575 // modexCopyPageRegion(mv->page, mv[0].page, 0, y, 0, y, mv[0].page->width, mv[0].map->tiles->tileHeight);
\r
576 //mv[0].video->dorender=1;//ScrollDown
\r
579 void ZC_mapScroll(map_view_t *mv, player_t *player, word pn)
\r
581 word b = mv[0].video->vga_state.bgps;
\r
582 switch(player[pn].enti.d)
\r
587 ScrollRight(mv, player, 3, pn);
\r
588 ScrollRight(mv, player, 2, pn);
\r
589 mapScrollRight(mv, player, (0), pn);
\r
590 if(b) mapScrollRight(mv, player, (1), pn);
\r
593 ScrollLeft(mv, player, 3, pn);
\r
594 ScrollLeft(mv, player, 2, pn);
\r
595 mapScrollLeft(mv, player, (0), pn);
\r
596 if(b) mapScrollLeft(mv, player, (1), pn);
\r
599 ScrollDown(mv, player, 3, pn);
\r
600 ScrollDown(mv, player, 2, pn);
\r
601 mapScrollDown(mv, player, (0), pn);
\r
602 if(b) mapScrollDown(mv, player, (1), pn);
\r
605 ScrollUp(mv, player, 3, pn);
\r
606 ScrollUp(mv, player, 2, pn);
\r
607 mapScrollUp(mv, player, (0), pn);
\r
608 if(b) mapScrollUp(mv, player, (1), pn);
\r
611 //mv[0].video->dorender=1;//ZC_mapScroll
\r
614 //===========================================================================
\r
615 //TODO: put player in starting position of assigned spot on map
\r
616 //default player position on the viewable map
\r
617 void ZC_PlayerXYpos(int x, int y, player_t *player, map_view_t *pip, nibble pn, boolean defaultsw)
\r
619 player[pn].enti.tx = x + pip[0].tx;
\r
620 player[pn].enti.ty = y + pip[0].ty;
\r
625 player[pn].enti.tx += pip[0].page->ti.tilemidposscreenx;
\r
626 player[pn].enti.ty += pip[0].page->ti.tilemidposscreeny;
\r
632 //===========================================================================
\r
634 void ZC_checkardmap(map_t *map)
\r
636 // just a place holder to fill out an alternating pattern
\r
639 static byte z[(MAPW*MAPH)];//map->width*map->height];
\r
643 for(y=0; y<map->height; y++) {
\r
644 for(x=0; x<map->width; x++) {
\r
646 tile = tile ? 0 : 1;
\r
649 tile = tile ? 0 : 1;
\r
651 map->layerdata[0].data = &z;
\r
654 sword chkmap(map_t *map, word q)
\r
657 // static byte x[(MAPW*MAPH)+1] =
\r
658 //{ 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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1, 1, 1, 1, 1, 1, 0, 0, 4, 0, 0, 0, 0, 0, 8, 8, 1, 11, 11, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 8, 8, 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, 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
661 //check for failed to load map
\r
662 if((map->width == map->height == 0) && (q>0))
\r
664 //initiate a null map!
\r
667 // map->layerdata[0].data = fmfaflflfofcf(((map->width*map->height)+1)*sizeof(byte));
\r
668 ZC_checkardmap(map);//map->layerdata[0].data = &x;
\r
669 //fix this to be far~
\r
670 // bp = bitmapLoadPcx("data/ed.pcx");
\r
671 // map->tiles->data = &bp;
\r
672 map->tiles->tileHeight = 16;
\r
673 map->tiles->tileWidth = 16;
\r
674 map->tiles->rows = 1;
\r
675 map->tiles->cols = 1;
\r
680 //TODO: player position here
\r
681 void mapGoTo(map_view_t *mv, int tx, int ty)
\r
683 ZC_mapinitMV(mv, tx, ty);
\r
685 /* draw the tiles */
\r
686 modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 0);
\r
687 ZC_mapredraw(mv, tx, ty);
\r
689 //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
692 void ZC_mapinitMV(map_view_t *mv, int tx, int ty)
\r
694 /* set up the coordinates */
\r
695 mv[0].tx = mv[1].tx = tx;
\r
696 mv[0].ty = mv[1].ty = ty;
\r
697 mv[0].page->dx = mv[1].page->dx = mv[2].page->dx = mv[3].page->dx = mv->map->tiles->tileWidth;
\r
698 mv[0].page->dy = mv[1].page->dy = mv[2].page->dy = mv[3].page->dy = mv->map->tiles->tileHeight;
\r
700 /* set up the thresholds */
\r
701 mv[0].dxThresh = mv[1].dxThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileWidth * 2;
\r
702 mv[0].dyThresh = mv[1].dyThresh = mv[2].dyThresh = mv[3].dyThresh = mv->map->tiles->tileHeight * 2;
\r
705 void ZC_mapredraw(map_view_t *mv, int tx, int ty)
\r
711 i=mv[0].ty * mv[0].map->width + mv[0].tx;
\r
712 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
713 mapDrawWRow(&mv[0], tx-1, ty, py);
\r
714 mapDrawWRow(&mv[1], tx-1, ty, py);
\r
715 i+=mv->map->width - tx;
\r
720 mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y)
\r
723 // printf("%02d ", i); if(x >= page->width - t->tileWidth) printf("\n");
\r
728 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 1); //currently the over scan color!
\r
731 rx = (((i-1) % ((t->spri->sprite_vrl_cont.vrl_header->width)/t->tileWidth)) * t->tileWidth);
\r
732 ry = (((i-1) / ((t->spri->sprite_vrl_cont.vrl_header->height)/t->tileHeight)) * t->tileHeight);
\r
734 #ifdef __DEBUG_RF__
\r
735 if(!dbg_pagenorendermap)
\r
737 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, i+1);
\r
739 modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, i);
\r
740 //draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));
\r
741 //modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
\r
743 #ifdef __DEBUG_MAP__
\r
744 if(dbg_maptext){ sprintf(global_temp_status_text2, "%u", i); modexprint(page, x, y, 1, 0, 1, 2, 1, global_temp_status_text2); }
\r
749 #define PALMAPDRAWW 13
\r
750 void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *player, word poopoffset)
\r
753 #ifdef __DEBUG_RF__
\r
754 if(dbg_pagedelayrendermap) if(!y) y+=TILEWH; else y-=TILEWH;
\r
756 poopoffset%=player[0].enti.speed;
\r
757 //printf("y: %d\n", poopoffset);
\r
758 #ifdef __DEBUG_RF__
\r
759 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
761 /* the position within the map array */
\r
762 i=ty * mv->map->width + tx;
\r
763 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
765 mapDrawTile(mv->map->tiles, mv->map->layerdata[0].data[i], mv->page, mv->dx, y);
\r
767 if(mv->map->layerdata[z].data[i]){
\r
768 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
769 //mapDrawTile(mv->map->tiles, mv->map->layerdata[z].data[i], mv->page, mv->dx, y);
\r
774 #ifdef __DEBUG_RF__
\r
775 if(dbg_pagedelayrendermap) delay(200);
\r
779 void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *player, word poopoffset)
\r
782 #ifdef __DEBUG_RF__
\r
783 if(dbg_pagedelayrendermap) if(!x) x+=TILEWH; else x-=TILEWH;
\r
785 poopoffset%=player[0].enti.speed;
\r
786 //printf("x: %d\n", poopoffset);
\r
787 #ifdef __DEBUG_RF__
\r
788 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
790 /* location in the map array */
\r
791 i=ty * mv->map->width + tx;
\r
792 /* We'll copy all of the columns in the screen,
\r
793 i + 1 row above and one below */
\r
794 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
796 mapDrawTile(mv->map->tiles, mv->map->layerdata[0].data[i], mv->page, x, mv->dy);
\r
798 if(mv->map->layerdata[z].data[i]){
\r
799 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
800 //mapDrawTile(mv->map->tiles, mv->map->layerdata[z].data[i], mv->page, x, mv->dy);
\r
803 i += mv->map->width;
\r
805 #ifdef __DEBUG_RF__
\r
806 if(dbg_pagedelayrendermap) delay(200);
\r
810 void mapDrawWRow(map_view_t *mv, int tx, int ty, word y)
\r
814 /* the position within the map array */
\r
815 i=ty * mv->map->width + tx;
\r
816 for(mv->dx=0; mv->dx<mv->page->sw+mv->dxThresh && tx < mv->map->width; mv->dx+=mv->map->tiles->tileWidth, tx++) {
\r
817 if(i>=0){ /* we are in the map, so copy! */
\r
818 mapDrawTile(mv->map->tiles, mv->map->layerdata[0].data[i], mv->page, mv->dx, y);
\r
820 if(mv->map->layerdata[z].data[i]){
\r
821 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
822 //mapDrawTile(mv->map->tiles, mv->map->layerdata[z].data[i], mv->page, mv->dx, y);
\r
829 void mapDrawWCol(map_view_t *mv, int tx, int ty, word x)
\r
833 /* location in the map array */
\r
834 i=ty * mv->map->width + tx;
\r
836 /* We'll copy all of the columns in the screen,
\r
837 i + 1 row above and one below */
\r
838 for(mv->dy=0; mv->dy<mv->page->sh+mv->dyThresh && ty < mv->map->height; mv->dy+=mv->map->tiles->tileHeight, ty++) {
\r
839 if(i>=0){ /* we are in the map, so copy away! */
\r
840 mapDrawTile(mv->map->tiles, mv->map->layerdata[0].data[i], mv->page, x, mv->dy);
\r
842 if(mv->map->layerdata[z].data[i]){
\r
843 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
844 //mapDrawTile(mv->map->tiles, mv->map->layerdata[z].data[i], mv->page, x, mv->dy);
\r
847 i += mv->map->width;
\r
853 void shinku(global_game_variables_t *gv)
\r
856 word x = gv->video.page[/*!*/(gv->video.p)].dx; //(gv->video.page[(gv->video.p)].tlx) - // follow the screen
\r
857 word y = gv->video.page[/*!*/(gv->video.p)].dy; //(gv->video.page[(gv->video.p)].tly) - // follow the screen
\r
858 word col = 2, bgcol = 1, type = 1;//w = 64, h = 8,
\r
860 if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second))
\r
863 // NTS: For some bizarre reason, gv->pee is not initialized, but the pointer is not NULL even
\r
864 // though it should be. Instead it's NULL as a neAr pointer but contains a non-null
\r
865 // segment value, so testing against NULL doesn't work. It is initialized properly if
\r
866 // you call start_timer() though which uses neAr mAlloc. Rather than fight with that,
\r
867 // I decided it would be better to declare a temp buffer statically and sprintf to that.
\r
869 // This fixes *** Null pointer assignment detected error message in ZCROLL.EXE on exit.
\r
870 sprintf(global_temp_status_text, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv));
\r
871 //modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, 1, col, bgcol, global_temp_status_text);
\r
872 if(gv->kurokku.wcpu)
\r
874 modexCopyPageRegion(&gv->video.page[0], &gv->video.page[1],
\r
875 gv->video.page[/*!*/(gv->video.p)].dx,
\r
876 gv->video.page[/*!*/(gv->video.p)].dy,
\r
877 gv->video.page[/*!*/(gv->video.p)].dx,
\r
878 gv->video.page[/*!*/(gv->video.p)].dy,
\r
880 modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, 1, col, bgcol, 1, global_temp_status_text);
\r
881 //0000printf("dx=%u dy=%u\n", gv->video.page[/*!*/(gv->video.p)].dx, gv->video.page[/*!*/(gv->video.p)].dy);
\r
884 gv->kurokku.tiku=0;
\r
885 }else //copy dat sheet
\r
886 gv->kurokku.tiku++;
\r
889 if(gv->video.dorender)
\r
893 modexCopyPageRegion(&(gv->video.page[ ]), &(gv->video.page[ ]), 0, 0, 0, 0, gv->video.page[ ].width, gv->video.page[ ].height);
\r
895 //modexCopyPageRegion(&video->page[0], &video->page[1], enti->x, enti->y, 0, 0, 24, 32);
\r
897 #ifndef OLDWALKSHOWPAGESTUFF
\r
898 VL_ShowPage(&(gv->video.page[gv->video.sp]), gv->kurokku.fpscap, 0);
\r
900 gv->video.dorender =!gv->video.dorender;
\r
901 //0000gv->video.tickclk = ((*clockw)-gv->video.startclk)/18.2;
\r
904 switch(gv->kurokku.fpscap)
\r
906 case 0: //turn this off if XT
\r
907 //modexprint(&(gv->video.page[0]), x, y+8, type, 1, col, bgcol, "sanic!");
\r
908 gv->kurokku.frames_per_second=1;
\r
911 #ifdef OLDWALKSHOWPAGESTUFF
\r
912 //modexWaitBorder();
\r
913 //modexWaitBorder_start();
\r
915 vga_wait_for_vsync();
\r
916 //vga_wait_for_vsync_end();
\r
918 gv->kurokku.frames_per_second=60;
\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
1004 boolean boundary_check(int x, int y, int dx, int dy, int h, int w)
\r
1006 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
1009 boolean coll_check(int x, int y, int dx, int dy, map_view_t *map_v)
\r
1011 // Assume everything crosses at most 1 tile at once
\r
1012 return dx && 1;//crossable_tile(x + dx, map_v) || dy && crossable_tile(y + dy, map_v);
\r
1015 boolean ZC_walk2(entity_t *enti, map_view_t *map_v)
\r
1035 if(coll_check(enti->x, enti->y, dx, dy, map_v))
\r
1039 // Start animation
\r
1040 // Mark next tile as occupied
\r
1041 // Mark this tile as vacant
\r
1047 void player_walk(player_t *player, map_view_t *map_v){
\r
1049 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
1051 mapScroll(map_v, player);
\r
1052 // (Un)load stuff?
\r
1062 void mapScroll(map_view_t *mv, player_t *player)
\r
1064 //word x, y; /* coordinate for drawing */
\r
1067 mv->delta += player->dx | player->dy;
\r
1068 delta = mv->delta;
\r
1069 mv->d = (player->dx) ? (player->dx > 0) ? 3 : 1 : (player->dy) ? (player->dy > 0) ? 4 : 0 : 2;
\r
1075 if(!(delta + mv->dxThresh))
\r
1085 if(!(delta + mv->dyThresh))
\r