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
27 //#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
29 void ZC_walk(map_view_t *pip, player_t *player, word pn)
\r
31 switch(player[pn].enti.d)
\r
35 //0000pip[0].video->startclk = (*clockw);
\r
39 if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->ti.tw < pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->ti.tilemidposscreenx &&
\r
40 !(pip[0].map->data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection!
\r
42 player[pn].walktype=2;
\r
43 if(player[pn].enti.q<=player[pn].enti.spt)
\r
46 ANIMATESPRIFUN(pip, player, pn, 2);
\r
47 ScrollRight(pip, player, 3, pn);
\r
48 ScrollRight(pip, player, 2, pn);
\r
49 mapScrollRight(pip, player, (pip[0].video->p), pn);
\r
50 player[pn].enti.q++;
\r
51 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
52 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
54 else if(player[pn].enti.tx < pip[0].map->width && !(pip[0].map->data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY))
\r
56 player[pn].walktype=1;
\r
57 if(player[pn].enti.q<=player[pn].enti.spt)
\r
60 player[pn].enti.x+=(player[pn].enti.speed);
\r
61 ANIMATESPRIFUN(pip, player, pn, 1);
\r
62 player[pn].enti.q++;
\r
63 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
67 player[pn].walktype=0;
\r
68 ANIMATESPRIFUN(pip, player, pn, 0);
\r
69 player[pn].enti.d = 2;
\r
71 player[pn].enti.triggerx = player[pn].enti.tx+1;
\r
72 player[pn].enti.triggery = player[pn].enti.ty;
\r
76 if(pip[0].tx > 0 && pip[0].tx+pip[0].page->ti.tw <= pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->ti.tilemidposscreenx &&
\r
77 !(pip[0].map->data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection!
\r
79 player[pn].walktype=2;
\r
80 if(player[pn].enti.q<=player[pn].enti.spt)
\r
83 ANIMATESPRIFUN(pip, player, pn, 2);
\r
84 ScrollLeft(pip, player, 3, pn);
\r
85 ScrollLeft(pip, player, 2, pn);
\r
86 mapScrollLeft(pip, player, (pip[0].video->p), pn);
\r
87 player[pn].enti.q++;
\r
88 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
89 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
91 else if(player[pn].enti.tx > 1 && !(pip[0].map->data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY))
\r
93 player[pn].walktype=1;
\r
94 if(player[pn].enti.q<=player[pn].enti.spt)
\r
97 player[pn].enti.x-=(player[pn].enti.speed);
\r
98 ANIMATESPRIFUN(pip, player, pn, 1);
\r
99 player[pn].enti.q++;
\r
100 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
104 player[pn].walktype=0;
\r
105 ANIMATESPRIFUN(pip, player, pn, 0);
\r
106 player[pn].enti.d = 2;
\r
108 player[pn].enti.triggerx = player[pn].enti.tx-1;
\r
109 player[pn].enti.triggery = player[pn].enti.ty;
\r
113 if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->ti.th < pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->ti.tilemidposscreeny &&
\r
114 !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY)) //collision detection!
\r
116 player[pn].walktype=2;
\r
117 if(player[pn].enti.q<=player[pn].enti.spt)
\r
120 ANIMATESPRIFUN(pip, player, pn, 2);
\r
121 ScrollDown(pip, player, 3, pn);
\r
122 ScrollDown(pip, player, 2, pn);
\r
123 mapScrollDown(pip, player, (pip[0].video->p), pn);
\r
124 player[pn].enti.q++;
\r
125 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
126 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
128 else if(player[pn].enti.ty < pip[0].map->height && !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY))
\r
130 player[pn].walktype=1;
\r
131 if(player[pn].enti.q<=player[pn].enti.spt)
\r
134 player[pn].enti.y+=(player[pn].enti.speed);
\r
135 ANIMATESPRIFUN(pip, player, pn, 1);
\r
136 player[pn].enti.q++;
\r
137 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
141 player[pn].walktype=0;
\r
142 ANIMATESPRIFUN(pip, player, pn, 0);
\r
143 player[pn].enti.d = 2;
\r
145 player[pn].enti.triggerx = player[pn].enti.tx;
\r
146 player[pn].enti.triggery = player[pn].enti.ty+1;
\r
150 if(pip[0].ty > 0 && pip[0].ty+pip[0].page->ti.th <= pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->ti.tilemidposscreeny &&
\r
151 !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY)) //collision detection!
\r
153 player[pn].walktype=2;
\r
154 if(player[pn].enti.q<=player[pn].enti.spt)
\r
157 ANIMATESPRIFUN(pip, player, pn, 2);
\r
158 ScrollUp(pip, player, 3, pn);
\r
159 ScrollUp(pip, player, 2, pn);
\r
160 mapScrollUp(pip, player, (pip[0].video->p), pn);
\r
161 player[pn].enti.q++;
\r
162 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
163 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
165 else if(player[pn].enti.ty > 1 && !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY))
\r
167 player[pn].walktype=1;
\r
168 if(player[pn].enti.q<=player[pn].enti.spt)
\r
171 player[pn].enti.y-=(player[pn].enti.speed);
\r
172 ANIMATESPRIFUN(pip, player, pn, 1);
\r
173 player[pn].enti.q++;
\r
174 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
178 player[pn].walktype=0;
\r
179 ANIMATESPRIFUN(pip, player, pn, 0);
\r
180 player[pn].enti.d = 2;
\r
182 player[pn].enti.triggerx = player[pn].enti.tx;
\r
183 player[pn].enti.triggery = player[pn].enti.ty-1;
\r
190 void ZC_panPageManual(map_view_t *pip, player_t *player, word pn)
\r
192 #define SHOWMVFUN_ ZC_ShowMV(pip, 0, 0);
\r
193 switch(player[pn].enti.d)
\r
197 if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->ti.tw < pip[0].page->ti.tilesw)
\r
199 if(player[pn].enti.q<=player[pn].enti.spt)
\r
201 pip[0].page->dx+=4;
\r
203 player[pn].enti.q++;
\r
204 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].tx++; }
\r
210 if(pip[0].tx > 0 && pip[0].tx+pip[0].page->ti.tw <= pip[0].page->ti.tilesw)
\r
212 if(player[pn].enti.q<=player[pn].enti.spt)
\r
214 pip[0].page->dx-=4;
\r
216 player[pn].enti.q++;
\r
217 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].tx--; }
\r
223 if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->ti.th < pip[0].page->ti.tilesh)
\r
225 if(player[pn].enti.q<=player[pn].enti.spt)
\r
227 pip[0].page->dy+=4;
\r
229 player[pn].enti.q++;
\r
230 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].ty++; }
\r
236 if(pip[0].ty > 0 && pip[0].ty+pip[0].page->ti.th <= pip[0].page->ti.tilesh)
\r
238 if(player[pn].enti.q<=player[pn].enti.spt)
\r
240 pip[0].page->dy-=4;
\r
242 player[pn].enti.q++;
\r
243 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].ty--; }
\r
252 void ZC_MVSetup(map_view_t *pip, map_t *map, global_game_variables_t *gv)
\r
257 pip[0].page = &gv->video.page[0];
\r
259 pip[0].video = &gv->video;
\r
260 pip[0].p = &gv->video.p;
\r
261 pip[0].sp = &gv->video.sp;
\r
262 ZC_MVInit(pip, 1, 1);
\r
264 for(i=ZC_MVI;i<gv->video.num_of_pages;i++)
\r
266 pip[i].page = &gv->video.page[i];
\r
267 pip[i].map = pip[0].map;
\r
268 pip[i].video = pip[0].video;
\r
269 pip[i].p = pip[0].p;
\r
270 pip[i].sp = pip[0].sp;
\r
278 void ZC_MVInit(map_view_t *pip, int tx, int ty)
\r
282 //pip[0].tx = pip[1].tx = tx;
\r
283 //pip[0].ty = pip[1].ty = ty;
\r
286 void ZC_ShowMV(map_view_t *moo, boolean vsync, boolean sr)
\r
288 VL_ShowPage(moo[moo[0].video->sp].page, vsync, sr);
\r
289 /*word high_address, low_address, offset;
\r
292 // calculate offset
\r
293 offset = (word) moo[moo[0].video->sp].page->data;
\r
294 offset += moo[0].page->dy * (moo[0].page->width >> 2 );
\r
295 offset += moo[0].page->dx >> 2;
\r
297 // calculate crtcOffset according to virtual width
\r
301 crtcOffset = moo[moo[0].video->sp].page->sw >> 3;
\r
305 crtcOffset = moo[0].page->width >> 3;
\r
309 high_address = HIGH_ADDRESS | (offset & 0xff00);
\r
310 low_address = LOW_ADDRESS | (offset << 8);
\r
312 // wait for appropriate timing and then program CRTC
\r
313 if(vsync) while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE));
\r
314 outpw(CRTC_INDEX, high_address);
\r
315 outpw(CRTC_INDEX, low_address);
\r
316 outp(CRTC_INDEX, 0x13);
\r
317 outp(CRTC_DATA, crtcOffset);
\r
319 // wait for one retrace
\r
320 if(vsync) while (!(inp(INPUT_STATUS_1) & VRETRACE));
\r
322 // do PEL panning here
\r
323 outp(AC_INDEX, 0x33);
\r
324 outp(AC_INDEX, (moo[0].page->dx & 0x03) << 1);*/
\r
328 allocMap(int w, int h) {
\r
333 result.data = malloc(sizeof(byte) * w * h);
\r
334 //result.data = (byte *)alloc_emem(((int)sizeof(byte) * w * h)/1024);
\r
335 if(isEMS() || checkEMS())
\r
338 //emmhandle = mallocEMS(coretotalEMS());//alloc_emem((int)sizeof(map))
\r
339 mm.length=sizeof(result);
\r
341 mm.sourceOff=ptr2long(&result);
\r
342 mm.destH=emmhandle;
\r
344 ist = move_emem(&mm);
\r
345 if(!ist){ dealloc_emem(emmhandle); exit(5); }
\r
346 printf("%d\n", coretotalEMS());
\r
353 initMap(map_t *map) {
\r
354 // just a place holder to fill out an alternating pattern
\r
355 int x, y;//, xx, yy;
\r
358 //if(!isEMS() || !checkEMS())
\r
359 // map->tiles = malloc(sizeof(tiles_t));
\r
361 // map->tiles = (tiles_t *)alloc_emem(sizeof(tiles_t));
\r
363 //create the tile set
\r
364 //if(!isEMS() || !checkEMS())
\r
365 // map->tiles->data = malloc(sizeof(bitmap_t));
\r
367 // map->tiles->data = (bitmap_t *)alloc_emem(sizeof(bitmap_t));
\r
368 // map->tiles->data->width = (TILEWH);
\r
369 // map->tiles->data->height= TILEWH;
\r
370 //if(!isEMS() || !checkEMS())
\r
371 // map->tiles->data->data = malloc((TILEWH*2)*TILEWH);
\r
373 // map->tiles->data->data = (byte *)alloc_emem((TILEWH*2)*TILEWH);
\r
374 // map->tiles->tileHeight = TILEWH;
\r
375 // map->tiles->tileWidth =TILEWH;
\r
376 // map->tiles->rows = 1;
\r
377 // map->tiles->cols = 1;//2;
\r
380 //for(y=0; y<map->height; y++) {
\r
381 //for(x=0; x<map->width; x++) {
\r
383 for(yy=0; yy<TILEWH; yy++) {
\r
384 for(xx=0; xx<(TILEWH); xx++) {
\r
386 map->tiles->data->data[i+1] = map->data[q];//28;//0x24;
\r
387 // printf("[%d]", map->tiles->data->data[i]);
\r
389 //map->tiles->data->data[i] = map->data[q];//0;//0x34;
\r
390 //printf("]%d[==[%d]", i, map->tiles->data->data[i]);
\r
396 // printf("[%d]", map->data[q]);
\r
403 for(y=0; y<map->height; y++) {
\r
404 for(x=0; x<map->width; x++) {
\r
406 // printf("[%d]", map->data[i]);
\r
407 tile = tile ? 0 : 1;
\r
410 tile = tile ? 0 : 1;
\r
415 void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
\r
417 word x;//, y; /* coordinate for drawing */
\r
419 ScrollRight(mv, player, id, plid);
\r
421 /* draw the next column */
\r
422 x= mv[0].page->sw + mv[id].map->tiles->tileWidth;
\r
424 if(player[plid].enti.q%4)
\r
426 if(player[plid].enti.q==4)
\r
429 mapDrawCol(&mv[0], mv[0].tx + mv[0].page->ti.tw, mv[0].ty-1, x, player, DRAWCOLNUM);
\r
431 // if(!pageflipflop && !pageploop)
\r
432 // modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->ti.th+2));
\r
437 void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
\r
439 word x;//,y; /* coordinate for drawing */
\r
441 ScrollLeft(mv, player, id, plid);
\r
443 /* draw the next column */
\r
446 if(player[plid].enti.q%4)
\r
448 if(player[plid].enti.q==4)
\r
451 mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, DRAWCOLNUM);
\r
453 // if(!pageflipflop && !pageploop)
\r
454 // modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->ti.th+2));
\r
459 void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
\r
461 word y;//x, /* coordinate for drawing */
\r
463 ScrollUp(mv, player, id, plid);
\r
465 /* draw the next row */
\r
468 if(player[plid].enti.q%3)
\r
470 if(player[plid].enti.q==4)
\r
473 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, DRAWCOLNUM);
\r
475 // if(!pageflipflop && !pageploop)
\r
476 // modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->ti.tw+2), mv[id].map->tiles->tileHeight);
\r
481 void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)
\r
483 word y;//x, /* coordinate for drawing */
\r
485 ScrollDown(mv, player, id, plid);
\r
487 /* draw the next row */
\r
488 y= mv[0].page->sh + mv[id].map->tiles->tileHeight;
\r
490 if(player[plid].enti.q%3)
\r
492 if(player[plid].enti.q==4)
\r
495 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+mv[0].page->ti.th, y, player, DRAWCOLNUM);
\r
497 // if(!pageflipflop && !pageploop)
\r
498 // modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->ti.tw+2), mv[id].map->tiles->tileHeight);
\r
504 //===========================================================================
\r
505 //TODO: put player in starting position of assigned spot on map
\r
506 //default player position on the viewable map
\r
507 void ZC_playerXYpos(int x, int y, player_t *player, map_view_t *pip, nibble pn)
\r
509 player[pn].enti.tx = x + pip[0].tx + pip[0].page->ti.tilemidposscreenx;
\r
510 player[pn].enti.ty = y + pip[0].ty + pip[0].page->ti.tilemidposscreeny;
\r
512 //===========================================================================
\r
514 sword chkmap(map_t *map, word q)
\r
517 static byte x[(MAPW*MAPH)+1] =
\r
518 { 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, 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, 0, 0, 4, 0, 0, 0, 0, 0, 8, 8, 1, 11, 11, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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3, 3, 3, 3, 3, 3, 4, 1, 1, 1, 1, 1, 1, \
\r
520 5, 6, 7, 8, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
521 9, 10, 11, 12, 4, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
522 13, 14, 15, 16, 0, 1, 1, 1, 5, 8, 1, 11, 11, 1, 1, 1, 1, 1, 1, 1, \
\r
523 0, 0, 4, 0, 0, 0, 0, 0, 8, 8, 1, 11, 11, 3, 1, 1, 1, 1, 1, 1, \
\r
524 1, 1, 1, 1, 0, 0, 0, 0, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
525 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
526 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
\r
527 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
528 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
529 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
\r
530 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
531 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
\r
532 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
533 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 1, 2, 3, 4 };*/
\r
534 //check for failed to load map
\r
535 if((map->width == map->height == 0) && (q>0))
\r
537 //initiate a null map!
\r
538 map->width=MAPW;///2;
\r
539 map->height=MAPH;///2;
\r
540 // map->data = malloc(((map->width*map->height)+1)*sizeof(byte));
\r
542 map->tiles = malloc(sizeof(tiles_t));
\r
543 //fix this to be far~
\r
544 // bp = bitmapLoadPcx("data/ed.pcx");
\r
545 // map->tiles->data = &bp;
\r
546 #ifdef __DEBUG_MAP__
\r
547 dbg_mapdata = map->data;
\r
549 map->tiles->tileHeight = 16;
\r
550 map->tiles->tileWidth = 16;
\r
551 map->tiles->rows = 1;
\r
552 map->tiles->cols = 1;
\r
553 #ifdef __DEBUG_MAP__
\r
554 dbg_maptext = true;
\r
557 #ifdef __DEBUG_MAP__
\r
558 else dbg_maptext = false;
\r
563 //TODO: player position here
\r
564 void mapGoTo(map_view_t *mv, int tx, int ty)
\r
569 mapinitmapview(mv, tx, ty);
\r
571 /* draw the tiles */
\r
572 modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 0);
\r
574 i=mv[0].ty * mv[0].map->width + mv[0].tx;
\r
575 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
576 mapDrawWRow(&mv[0], tx-1, ty, py);
\r
577 i+=mv->map->width - tx;
\r
579 // if(!pageploop) modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height);
\r
580 modexCopyPageRegion(mv[3].page, mv[0].page, 0/**/, 0/**/, 0, 0, 24, 32);
\r
583 void mapinitmapview(map_view_t *mv, int tx, int ty)
\r
585 /* set up the coordinates */
\r
586 mv[0].tx = mv[1].tx = tx;
\r
587 mv[0].ty = mv[1].ty = ty;
\r
588 mv[0].page->dx = mv[1].page->dx = mv[2].page->dx = mv[3].page->dx = mv->map->tiles->tileWidth;
\r
589 mv[0].page->dy = mv[1].page->dy = mv[2].page->dy = mv[3].page->dy = mv->map->tiles->tileHeight;
\r
591 /* set up the thresholds */
\r
592 mv[0].dxThresh = mv[1].dxThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileWidth * 2;
\r
593 mv[0].dyThresh = mv[1].dyThresh = mv[2].dyThresh = mv[3].dyThresh = mv->map->tiles->tileHeight * 2;
\r
597 mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y)
\r
601 //word textx=0, texty=0;
\r
606 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 1); //currently the over scan color!
\r
610 rx = (((i-1) % ((t->data->width)/t->tileWidth)) * t->tileWidth);
\r
611 ry = (((i-1) / ((t->data->height)/t->tileHeight)) * t->tileHeight);
\r
612 ////0000printf("i=%d\n", i);
\r
613 #ifdef __DEBUG_MAP__
\r
614 switch(dbg_maptext)
\r
619 if(!pagenorendermap) modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, ((dbg_mapdata[i])+1));
\r
620 //modexprint(page, x, y, 1, 15, 0, (char const *)(t->debug_data[i]));
\r
622 modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
\r
623 /* then the sprite. note modding ram ptr means we just draw to (x&3,0) */
\r
624 //draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));
\r
625 //modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
\r
627 #ifdef __DEBUG_MAP__
\r
630 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, (dbg_mapdata[i])+1);
\r
631 //modexprintbig(page, x, y, 1, 15, 0, (t->debug_data));
\r
632 /*for(texty=0; texty<2; texty++)
\r
634 for(textx=0; textx<2; textx++)
\r
636 // modexprint(page, x+(textx*8), y+(texty*8), 1, (word)(t->debug_data), 0, (t->debug_data));
\r
645 void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *player, word poopoffset)
\r
648 if(pagedelayrendermap) if(!y) y+=TILEWH; else y-=TILEWH;
\r
649 poopoffset%=player[0].enti.speed;
\r
650 //printf("y: %d\n", poopoffset);
\r
651 if(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, 2, 1, global_temp_status_text); }
\r
652 /* the position within the map array */
\r
653 i=ty * mv->map->width + tx;
\r
654 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
655 if(i>=0) /* we are in the map, so copy away! */
\r
656 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, mv->dx, y);
\r
659 //if(pagedelayrendermap) delay(200);
\r
662 void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *player, word poopoffset)
\r
665 if(pagedelayrendermap) if(!x) x+=TILEWH; else x-=TILEWH;
\r
666 poopoffset%=player[0].enti.speed;
\r
667 //printf("x: %d\n", poopoffset);
\r
668 if(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, 2, 1, global_temp_status_text); }
\r
669 /* location in the map array */
\r
670 i=ty * mv->map->width + tx;
\r
671 /* We'll copy all of the columns in the screen,
\r
672 i + 1 row above and one below */
\r
673 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
674 if(i>=0) /* we are in the map, so copy away! */
\r
675 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, mv->dy);
\r
676 i += mv->map->width;
\r
678 //if(pagedelayrendermap) delay(200);
\r
681 void mapDrawWRow(map_view_t *mv, int tx, int ty, word y)
\r
685 /* the position within the map array */
\r
686 i=ty * mv->map->width + tx;
\r
687 for(mv->dx=0; mv->dx<mv->page->sw+mv->dxThresh && tx < mv->map->width; mv->dx+=mv->map->tiles->tileWidth, tx++) {
\r
688 if(i>=0) /* we are in the map, so copy! */
\r
689 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, mv->dx, y);
\r
694 void mapDrawWCol(map_view_t *mv, int tx, int ty, word x)
\r
698 /* location in the map array */
\r
699 i=ty * mv->map->width + tx;
\r
701 /* We'll copy all of the columns in the screen,
\r
702 i + 1 row above and one below */
\r
703 for(mv->dy=0; mv->dy<mv->page->sh+mv->dyThresh && ty < mv->map->height; mv->dy+=mv->map->tiles->tileHeight, ty++) {
\r
704 if(i>=0) /* we are in the map, so copy away! */
\r
705 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, mv->dy);
\r
706 i += mv->map->width;
\r
715 //boolean pageflipflop = 1;
\r
716 //boolean pageploop = 1;
\r
717 boolean pagenorendermap = 0;
\r
718 boolean pagedelayrendermap = 0;
\r
721 void shinku(global_game_variables_t *gv)
\r
723 word x = (0) + gv->video.page[/*!*/(gv->video.p)].dx; // follow the screen
\r
724 word y = (0) + gv->video.page[/*!*/(gv->video.p)].dy; // follow the screen
\r
725 word col = 2, bgcol = 1, type = 1;//w = 64, h = 8, //col7bgcol0
\r
727 //modexCopyPageRegion(pip[1].page, pip[2].page, 16, 16, 16, 16, (14*8)+4, 8+4);
\r
728 /* block copy to visible RAM from offscreen */
\r
729 // vga_setup_wm1_block_copy();
\r
730 // modexCopyPageRegion(&(gv->video.page[gv->video->sfip]), &(gv->video.page[!gv->video->sfip]), x, y, x+w, 0, w, h);
\r
731 // o = *(gv->video.page[2].data); // source offscreen
\r
732 // o2 = *(gv->video.page[gv->video->sfip].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride)
\r
733 // for (i=0;i < h;i++,o += vga_state.vga_draw_stride,o2 += vga_state.vga_stride) vga_wm1_mem_block_copy(o2,o,w >> 2);
\r
734 /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */
\r
735 // vga_restore_rm0wm0();
\r
736 if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second))
\r
738 // NTS: For some bizarre reason, gv->pee is not initialized, but the pointer is not NULL even
\r
739 // though it should be. Instead it's NULL as a neAr pointer but contains a non-null
\r
740 // segment value, so testing against NULL doesn't work. It is initialized properly if
\r
741 // you call start_timer() though which uses neAr malloc. Rather than fight with that,
\r
742 // I decided it would be better to declare a temp buffer statically and sprintf to that.
\r
744 // This fixes *** Null pointer assignment detected error message in ZCROLL.EXE on exit.
\r
745 sprintf(global_temp_status_text, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv));
\r
746 //modexClearRegion(&(gv->video.page[gv->video->sfip]), x, y, w, h, 45);
\r
747 modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, col, bgcol, global_temp_status_text);
\r
748 gv->kurokku.tiku=0;
\r
749 /* block copy to visible RAM from offscreen */
\r
750 // vga_setup_wm1_block_copy();
\r
751 // o = *(gv->video.page[gv->video->sfip].data); // source offscreen
\r
752 // o2 = *(gv->video.page[2].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride)
\r
753 // for (i=0;i < h;i++,o += vga_state.vga_draw_stride,o2 += vga_state.vga_stride) vga_wm1_mem_block_copy(o2,o,w >> 2);
\r
754 // modexCopyPageRegion(&(gv->video.page[gv->video->sfip]), &(gv->video.page[!gv->video->sfip]), x, y, x, 0, w, h);
\r
755 /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */
\r
756 // vga_restore_rm0wm0();
\r
757 }else //copy dat sheet
\r
758 gv->kurokku.tiku++;
\r
760 switch(gv->kurokku.fpscap)
\r
763 //modexprint(&(gv->video.page[gv->video->sfip]), x, y+8, type, col, bgcol, "sanic!");
\r
764 gv->kurokku.frames_per_second=1;
\r
767 //turn this off if XT
\r
768 //modexWaitBorder();
\r
769 //vga_wait_for_vsync();
\r
770 gv->kurokku.frames_per_second=60;
\r
774 // if(pageflipflop){
\r
775 if(gv->video.r ){//r=1
\r
776 //vga_setup_wm1_block_copy();
\r
777 //_fmemcpy((gv->video.page[(gv->video.p)]).data, (gv->video.page[(!gv->video.p)]).data, gv->video.page[(!gv->video.p)].pagesize);
\r
778 //vga_restore_rm0wm0();
\r
779 // if(!pageploop) modexCopyPageRegion(&(gv->video.page[(gv->video.p)]), &(gv->video.page[(!gv->video.p)]), 0, 0, 0, 0, gv->video.page[gv->video.p].width, gv->video.page[!gv->video.p].height);
\r
780 VL_ShowPage(&(gv->video.page[gv->video.sp]), gv->kurokku.fpscap, 0);
\r
781 // if(!pageploop) gv->video.p=!gv->video.p;
\r
782 gv->video.r =!gv->video.r ;
\r
783 //0000gv->video.tickclk = ((*clockw)-gv->video.startclk)/18.2;
\r
788 void near ZC_drawframe(map_view_t *pip, entity_t *enti, sword x, sword y)
\r
790 switch(pip[0].video->rss)
\r
793 animate_spri(enti, pip->video);
\r
796 animate_spri(enti, pip->video);
\r
799 // modexClearRegion(&(pip[0].page[0]), x, y, 16, 32, player[pn].enti.dire);
\r
805 #define FRAME1 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 48, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR);
\r
806 #define FRAME2 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR);
\r
807 #define FRAME3 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 0, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR);
\r
808 #define FRAME4 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR);
\r
810 #define FRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 2+player[pn].enti.dire);
\r
811 #define FRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+player[pn].enti.dire);
\r
812 #define FRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, player[pn].enti.dire);
\r
813 #define FRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+player[pn].enti.dire);
\r
816 void animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch)
\r
818 sword x = player[pn].enti.x;
\r
819 sword y = player[pn].enti.y;
\r
820 sword bx = x+16; //buffer's x
\r
821 sword by = y+16; //buffer's y
\r
822 sword qq; //scroll offset
\r
823 word ls = 0;//player[pn].enti.persist_aniframe;
\r
824 player[pn].enti.dire=32; //direction
\r
826 switch(scrollswitch)
\r
832 qq = ((player[pn].enti.q)*(player[pn].enti.speed));
\r
836 y-=pip[0].map->tiles->tileHeight;
\r
837 switch (player[pn].enti.d)
\r
841 player[pn].enti.dire*=player[pn].enti.d;
\r
847 player[pn].enti.dire*=(player[pn].enti.d-2);
\r
855 player[pn].enti.dire*=(player[pn].enti.d-2);
\r
861 player[pn].enti.dire*=(player[pn].enti.d+2);
\r
867 // if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 36);
\r
869 // //copy old bg to page0
\r
870 // //modexCopyPageRegion(pip[3].page, pip[0].page, bx, by, 0, 0, 20, 36);
\r
872 // //modexCopyPageRegion(pip[0].page, pip[3].page, 0, 0, x, y, 20, 36);
\r
874 //modexCopyPageRegion(page_t *dest, page_t *src, word sx, word sy, word dx, word dy, word width, word height);
\r
875 //modexCopyPageRegion(pip[3].page, pip[!(pip->video->p)].page, x-4, y-4, 0, 128, 28, 36);
\r
876 /*modexCopyPageRegion(pip[pip->video->p].page,
\r
877 pip[!(pip->video->p)].page, x-4, y-4, x-4, y-4, 28, 36);*/
\r
878 // else modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 40);
\r
894 // if(2>ls && ls>=1) { FRAME1 }else
\r
895 // if(3>ls && ls>=2) { FRAME2 }else
\r
896 // if(4>ls && ls>=3) { FRAME3 }else
\r
897 // if(5>ls && ls>=4) { FRAME4 }
\r
898 //modexCopyPageRegion(pip[0].page, pip[3].page, 0, 0, x, y, 24, 32);
\r
899 //printf("x=%d y=%d bx=%d by=%d\n", x, y, bx, by);
\r
903 void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch)
\r
905 sword x = player[pn].enti.x;
\r
906 sword y = player[pn].enti.y;
\r
907 sword qq,dd; //scroll offset
\r
908 player[pn].enti.dire=10; //direction
\r
910 switch(scrollswitch)
\r
922 qq = ((player[pn].enti.q)*(player[pn].enti.speed));
\r
926 y-=pip[0].map->tiles->tileHeight;
\r
927 switch (player[pn].enti.d)
\r
931 player[pn].enti.dire*=player[pn].enti.d+1;
\r
936 player[pn].enti.dire*=(player[pn].enti.d-1);
\r
943 player[pn].enti.dire*=(player[pn].enti.d-1);
\r
948 player[pn].enti.dire*=(player[pn].enti.d+3);
\r
952 player[pn].enti.dire+=dd;
\r
953 if((player[pn].enti.q==1 && player[pn].enti.pred != player[pn].enti.d) || !dd)
\r
955 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
956 player[pn].enti.pred = player[pn].enti.d;
\r
959 //setting xy position
\r
960 player[pn].enti.spri->x = x;
\r
961 player[pn].enti.spri->y = y;
\r
964 ZC_drawframe(pip, &player[pn].enti, x, y);
\r
965 //0000if(player[pn].enti.q<2) delay(200);
\r
973 boolean boundary_check(int x, int y, int dx, int dy, int h, int w)
\r
975 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
978 boolean coll_check(int x, int y, int dx, int dy, map_view_t *map_v)
\r
980 // Assume everything crosses at most 1 tile at once
\r
981 return dx && 1;//crossable_tile(x + dx, map_v) || dy && crossable_tile(y + dy, map_v);
\r
984 boolean ZC_walk2(entity_t *enti, map_view_t *map_v)
\r
1004 if(coll_check(enti->x, enti->y, dx, dy, map_v))
\r
1008 // Start animation
\r
1009 // Mark next tile as occupied
\r
1010 // Mark this tile as vacant
\r
1016 void player_walk(player_t *player, map_view_t *map_v){
\r
1018 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
1020 mapScroll(map_v, player);
\r
1021 // (Un)load stuff?
\r
1025 void mapScroll(map_view_t *mv, player_t *player)
\r
1027 //word x, y; /* coordinate for drawing */
\r
1030 mv->delta += player->dx | player->dy;
\r
1031 delta = mv->delta;
\r
1032 mv->d = (player->dx) ? (player->dx > 0) ? 3 : 1 : (player->dy) ? (player->dy > 0) ? 4 : 0 : 2;
\r
1038 if(!(delta + mv->dxThresh))
\r
1048 if(!(delta + mv->dyThresh))
\r