1 /* Project 16 Source Code~
\r
2 * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
\r
4 * This file is part of Project 16.
\r
6 * Project 16 is free software; you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation; either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * Project 16 is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with this program. If not, see <http://www.gnu.org/licenses/>, or
\r
18 * write to the Free Software Foundation, Inc., 51 Franklin Street,
\r
19 * Fifth Floor, Boston, MA 02110-1301 USA.
\r
25 #include "src/lib/scroll16.h"
\r
27 void walk(map_view_t *pip, player_t *player, word pn)
\r
29 #define INC_PER_FRAME if(player[pn].q&1) player[pn].persist_aniframe++; if(player[pn].persist_aniframe>4) player[pn].persist_aniframe = 1;
\r
30 //printf("player[%d].d=%d\n", pn, player[pn].d);
\r
31 switch(player[pn].d)
\r
35 //0000pip[0].video->startclk = (*clockw);
\r
39 //printf("pip[0].page->tilesw=%d ", pip[0].page->tilesw); printf("pip[0].page->tw=%d\n", pip[0].page->tw);
\r
40 if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->tw < pip[0].map->width && player[pn].tx == pip[0].tx+pip[0].page->tilemidposscreenx &&
\r
41 !(pip[0].map->data[(player[pn].tx)+(pip[0].map->width*(player[pn].ty-1))] == 0))//!(player[pn].tx+1 == TRIGGX && player[pn].ty == TRIGGY)) //collision detection!
\r
43 if(player[pn].q<=player[pn].spt)
\r
46 animatePlayer(pip, player, pn, 1);
\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 mapScrollRight(pip, player, (pip[0].video->p), pn);
\r
51 if(!pageflipflop) modexShowPage(pip[1].page);
\r
53 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
54 } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx++; }
\r
56 else if(player[pn].tx < pip[0].map->width && !(pip[0].map->data[(player[pn].tx)+(pip[0].map->width*(player[pn].ty-1))] == 0))//!(player[pn].tx+1 == TRIGGX && player[pn].ty == TRIGGY))
\r
58 if(player[pn].q<=player[pn].spt)
\r
61 player[pn].x+=(player[pn].speed);
\r
62 animatePlayer(pip, player, pn, 0);
\r
63 if(!pageflipflop) modexShowPage(pip[1].page);
\r
65 } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx++; }
\r
69 if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x, player[pn].y-TILEWH, player[pn].x, player[pn].y-TILEWH, 24, 32);
\r
71 PBUFSFUN(pip[0].page, player[pn].x, player[pn].y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATA);
\r
73 modexClearRegion(pip[1].page, player[pn].x, player[pn].y-TILEWH, 24, 32, 14);
\r
75 if(!pageflipflop) modexShowPage(pip[1].page);
\r
78 player[pn].triggerx = player[pn].tx+1;
\r
79 player[pn].triggery = player[pn].ty;
\r
84 if(pip[0].tx > 0 && pip[0].tx+pip[0].page->tw <= pip[0].map->width && player[pn].tx == pip[0].tx+pip[0].page->tilemidposscreenx &&
\r
85 !(pip[0].map->data[(player[pn].tx-2)+(pip[0].map->width*(player[pn].ty-1))] == 0))//!(player[pn].tx-1 == TRIGGX && player[pn].ty == TRIGGY)) //collision detection!
\r
87 if(player[pn].q<=player[pn].spt)
\r
90 animatePlayer(pip, player, pn, 1);
\r
91 ScrollLeft(pip, player, 3, pn);
\r
92 ScrollLeft(pip, player, 2, pn);
\r
93 mapScrollLeft(pip, player, !(pip[0].video->p), pn);
\r
94 mapScrollLeft(pip, player, (pip[0].video->p), pn);
\r
95 if(!pageflipflop) modexShowPage(pip[1].page);
\r
97 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
98 } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx--; }
\r
100 else if(player[pn].tx > 1 && !(pip[0].map->data[(player[pn].tx-2)+(pip[0].map->width*(player[pn].ty-1))] == 0))//!(player[pn].tx-1 == TRIGGX && player[pn].ty == TRIGGY))
\r
102 if(player[pn].q<=player[pn].spt)
\r
105 player[pn].x-=(player[pn].speed);
\r
106 animatePlayer(pip, player, pn, 0);
\r
107 if(!pageflipflop) modexShowPage(pip[1].page);
\r
109 } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx--; }
\r
113 if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x, player[pn].y-TILEWH, player[pn].x, player[pn].y-TILEWH, 24, 32);
\r
115 PBUFSFUN(pip[0].page, player[pn].x, player[pn].y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATA);
\r
117 modexClearRegion(pip[1].page, player[pn].x, player[pn].y-TILEWH, 24, 32, 10);
\r
119 if(!pageflipflop) modexShowPage(pip[1].page);
\r
122 player[pn].triggerx = player[pn].tx-1;
\r
123 player[pn].triggery = player[pn].ty;
\r
128 if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->th < pip[0].map->height && player[pn].ty == pip[0].ty+pip[0].page->tilemidposscreeny &&
\r
129 !(pip[0].map->data[(player[pn].tx-1)+(pip[0].map->width*(player[pn].ty))] == 0))//!(player[pn].tx == TRIGGX && player[pn].ty+1 == TRIGGY)) //collision detection!
\r
131 if(player[pn].q<=player[pn].spt)
\r
134 animatePlayer(pip, player, pn, 1);
\r
135 ScrollDown(pip, player, 3, pn);
\r
136 ScrollDown(pip, player, 2, pn);
\r
137 mapScrollDown(pip, player, !(pip[0].video->p), pn);
\r
138 mapScrollDown(pip, player, (pip[0].video->p), pn);
\r
139 if(!pageflipflop) modexShowPage(pip[1].page);
\r
141 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
142 } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty++; }
\r
144 else if(player[pn].ty < pip[0].map->height && !(pip[0].map->data[(player[pn].tx-1)+(pip[0].map->width*(player[pn].ty))] == 0))//!(player[pn].tx == TRIGGX && player[pn].ty+1 == TRIGGY))
\r
146 if(player[pn].q<=player[pn].spt)
\r
149 player[pn].y+=(player[pn].speed);
\r
150 animatePlayer(pip, player, pn, 0);
\r
151 if(!pageflipflop) modexShowPage(pip[1].page);
\r
153 } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty++; }
\r
157 if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x, player[pn].y-TILEWH, player[pn].x, player[pn].y-TILEWH, 24, 32);
\r
159 PBUFSFUN(pip[0].page, player[pn].x, player[pn].y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATA);
\r
161 modexClearRegion(pip[1].page, player[pn].x, player[pn].y-TILEWH, 24, 32, 9);
\r
163 if(!pageflipflop) modexShowPage(pip[1].page);
\r
166 player[pn].triggerx = player[pn].tx;
\r
167 player[pn].triggery = player[pn].ty+1;
\r
172 if(pip[0].ty > 0 && pip[0].ty+pip[0].page->th <= pip[0].map->height && player[pn].ty == pip[0].ty+pip[0].page->tilemidposscreeny &&
\r
173 !(pip[0].map->data[(player[pn].tx-1)+(pip[0].map->width*(player[pn].ty-2))] == 0))//!(player[pn].tx == TRIGGX && player[pn].ty-1 == TRIGGY)) //collision detection!
\r
175 if(player[pn].q<=player[pn].spt)
\r
178 animatePlayer(pip, player, pn, 1);
\r
179 ScrollUp(pip, player, 3, pn);
\r
180 ScrollUp(pip, player, 2, pn);
\r
181 mapScrollUp(pip, player, !(pip[0].video->p), pn);
\r
182 mapScrollUp(pip, player, (pip[0].video->p), pn);
\r
183 if(!pageflipflop) modexShowPage(pip[1].page);
\r
185 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
186 } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty--; }
\r
188 else if(player[pn].ty > 1 && !(pip[0].map->data[(player[pn].tx-1)+(pip[0].map->width*(player[pn].ty-2))] == 0))//!(player[pn].tx == TRIGGX && player[pn].ty-1 == TRIGGY))
\r
190 if(player[pn].q<=player[pn].spt)
\r
193 player[pn].y-=(player[pn].speed);
\r
194 animatePlayer(pip, player, 0, pn);
\r
195 if(!pageflipflop) modexShowPage(pip[1].page);
\r
197 } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty--; }
\r
201 if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x, player[pn].y-TILEWH, player[pn].x, player[pn].y-TILEWH, 24, 32);
\r
203 PBUFSFUN(pip[0].page, player[pn].x, player[pn].y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATA);
\r
205 modexClearRegion(pip[1].page, player[pn].x, player[pn].y-TILEWH, 24, 32, 12);
\r
207 if(!pageflipflop) modexShowPage(pip[1].page);
\r
210 player[pn].triggerx = player[pn].tx;
\r
211 player[pn].triggery = player[pn].ty-1;
\r
217 void panPageManual(map_view_t *pip, player_t *player, word pn)
\r
219 switch(player[pn].d)
\r
223 if(pip[pip[0].pan->pn].tx >= 0 && pip[pip[0].pan->pn].tx+pip[pip[0].pan->pn].page->tw < pip[pip[0].pan->pn].page->tilesw)
\r
225 if(player[pn].q<=player[pn].spt)
\r
227 pip[pip[0].pan->pn].page->dx+=4;
\r
228 modexShowPage(pip[pip[0].pan->pn].page);
\r
230 } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].tx++; }
\r
236 if(pip[pip[0].pan->pn].tx > 0 && pip[pip[0].pan->pn].tx+pip[pip[0].pan->pn].page->tw <= pip[pip[0].pan->pn].page->tilesw)
\r
238 if(player[pn].q<=player[pn].spt)
\r
240 pip[pip[0].pan->pn].page->dx-=4;
\r
241 modexShowPage(pip[pip[0].pan->pn].page);
\r
243 } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].tx--; }
\r
249 if(pip[pip[0].pan->pn].ty >= 0 && pip[pip[0].pan->pn].ty+pip[pip[0].pan->pn].page->th < pip[pip[0].pan->pn].page->tilesh)
\r
251 if(player[pn].q<=player[pn].spt)
\r
253 pip[pip[0].pan->pn].page->dy+=4;
\r
254 modexShowPage(pip[pip[0].pan->pn].page);
\r
256 } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].ty++; }
\r
262 if(pip[pip[0].pan->pn].ty > 0 && pip[pip[0].pan->pn].ty+pip[pip[0].pan->pn].page->th <= pip[pip[0].pan->pn].page->tilesh)
\r
264 if(player[pn].q<=player[pn].spt)
\r
266 pip[pip[0].pan->pn].page->dy-=4;
\r
267 modexShowPage(pip[pip[0].pan->pn].page);
\r
269 } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].ty--; }
\r
273 //if (player[pn].d!=2) printf("player[%u].d=%u player[%u].q=%u\n", pn, player[pn].d, pn, player[pn].q);
\r
277 void panVmemManual(map_view_t *pip, player_t *player, word pn)
\r
279 switch(player[pn].d)
\r
283 if(pip[pip[0].pan->pn].tx >= 0 && pip[pip[0].pan->pn].tx+pip[pip[0].pan->pn].page->tw < pip[pip[0].pan->pn].page->tilesw)
\r
285 if(player[pn].q<=player[pn].spt)
\r
287 pip[pip[0].pan->pn].page->dx+=4;
\r
288 modexShowPageVsync(pip[pip[0].pan->pn].page);
\r
290 } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].tx++; }
\r
296 if(pip[pip[0].pan->pn].tx > 0 && pip[pip[0].pan->pn].tx+pip[pip[0].pan->pn].page->tw <= pip[pip[0].pan->pn].page->tilesw)
\r
298 if(player[pn].q<=player[pn].spt)
\r
300 pip[pip[0].pan->pn].page->dx-=4;
\r
301 modexShowPageVsync(pip[pip[0].pan->pn].page);
\r
303 } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].tx--; }
\r
309 if(pip[pip[0].pan->pn].ty >= 0 && pip[pip[0].pan->pn].ty+pip[pip[0].pan->pn].page->th < pip[pip[0].pan->pn].page->tilesh)
\r
311 if(player[pn].q<=player[pn].spt)
\r
313 pip[pip[0].pan->pn].page->dy+=4;
\r
314 modexShowPageVsync(pip[pip[0].pan->pn].page);
\r
316 } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].ty++; }
\r
322 if(pip[pip[0].pan->pn].ty > 0 && pip[pip[0].pan->pn].ty+pip[pip[0].pan->pn].page->th <= pip[pip[0].pan->pn].page->tilesh)
\r
324 if(player[pn].q<=player[pn].spt)
\r
326 pip[pip[0].pan->pn].page->dy-=4;
\r
327 modexShowPageVsync(pip[pip[0].pan->pn].page);
\r
329 } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].ty--; }
\r
333 //if (player[pn].d!=2) printf("player[%u].d=%u player[%u].q=%u\n", pn, player[pn].d, pn, player[pn].q);
\r
339 void modexMVSetup(map_view_t *mv, map_t *map, pan_t *pan, global_game_variables_t *gv)
\r
343 mv[0].page = &gv->video.page[0];
\r
345 mv[0].video = &gv->video;
\r
348 for(i=1;i<gv->video.num_of_pages;i++)
\r
350 mv[i].page = &gv->video.page[i];
\r
351 mv[i].map = mv[0].map;
\r
352 mv[i].video = mv[0].video;
\r
353 mv[i].pan = mv[0].pan;
\r
358 allocMap(int w, int h) {
\r
363 result.data = malloc(sizeof(byte) * w * h);
\r
364 //result.data = (byte *)alloc_emem(((int)sizeof(byte) * w * h)/1024);
\r
365 if(isEMS() || checkEMS())
\r
368 //emmhandle = mallocEMS(coretotalEMS());//alloc_emem((int)sizeof(map))
\r
369 mm.length=sizeof(result);
\r
371 mm.sourceOff=ptr2long(&result);
\r
372 mm.destH=emmhandle;
\r
374 ist = move_emem(&mm);
\r
375 if(!ist){ dealloc_emem(emmhandle); exit(5); }
\r
376 printf("%d\n", coretotalEMS());
\r
383 initMap(map_t *map) {
\r
384 // just a place holder to fill out an alternating pattern
\r
388 //if(!isEMS() || !checkEMS())
\r
389 // map->tiles = malloc(sizeof(tiles_t));
\r
391 // map->tiles = (tiles_t *)alloc_emem(sizeof(tiles_t));
\r
393 //create the tile set
\r
394 //if(!isEMS() || !checkEMS())
\r
395 // map->tiles->data = malloc(sizeof(bitmap_t));
\r
397 // map->tiles->data = (bitmap_t *)alloc_emem(sizeof(bitmap_t));
\r
398 // map->tiles->data->width = (TILEWH);
\r
399 // map->tiles->data->height= TILEWH;
\r
400 //if(!isEMS() || !checkEMS())
\r
401 // map->tiles->data->data = malloc((TILEWH*2)*TILEWH);
\r
403 // map->tiles->data->data = (byte *)alloc_emem((TILEWH*2)*TILEWH);
\r
404 // map->tiles->tileHeight = TILEWH;
\r
405 // map->tiles->tileWidth =TILEWH;
\r
406 // map->tiles->rows = 1;
\r
407 // map->tiles->cols = 1;//2;
\r
410 //for(y=0; y<map->height; y++) {
\r
411 //for(x=0; x<map->width; x++) {
\r
413 for(yy=0; yy<TILEWH; yy++) {
\r
414 for(xx=0; xx<(TILEWH); xx++) {
\r
416 map->tiles->data->data[i+1] = map->data[q];//28;//0x24;
\r
417 // printf("[%d]", map->tiles->data->data[i]);
\r
419 //map->tiles->data->data[i] = map->data[q];//0;//0x34;
\r
420 //printf("]%d[==[%d]", i, map->tiles->data->data[i]);
\r
426 // printf("[%d]", map->data[q]);
\r
433 for(y=0; y<map->height; y++) {
\r
434 for(x=0; x<map->width; x++) {
\r
435 // map->data[i]=255;
\r
436 printf("[%d]", map->data[i]);
\r
437 //tile = tile ? 0 : 1;
\r
440 //tile = tile ? 0 : 1;
\r
444 void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
\r
446 word x;//, y; /* coordinate for drawing */
\r
448 /* increment the pixel position and update the page */
\r
449 mv[id].page->dx += player[plid].speed;
\r
451 /* check to see if this changes the tile */
\r
452 if(mv[id].page->dx >= mv[id].dxThresh )
\r
454 /* go forward one tile */
\r
456 /* Snap the origin forward */
\r
457 mv[id].page->data += 4;
\r
459 mv[id].page->dx = mv[id].map->tiles->tileWidth;
\r
462 /* draw the next column */
\r
463 x= mv[0].page->sw + mv[id].map->tiles->tileWidth;
\r
464 if(player[plid].q%4)
\r
466 mapDrawCol(&mv[0], mv[0].tx + mv[0].page->tw, mv[0].ty-1, x, player, mv->page->dx);
\r
468 if(!pageflipflop && !pageploop)
\r
469 modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->th+2));
\r
474 void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
\r
476 word x;//,y; /* coordinate for drawing */
\r
478 /* decrement the pixel position and update the page */
\r
479 mv[id].page->dx -= player[plid].speed;
\r
481 /* check to see if this changes the tile */
\r
482 if(mv[id].page->dx == 0)
\r
484 /* go backward one tile */
\r
486 /* Snap the origin backward */
\r
487 mv[id].page->data -= 4;
\r
489 mv[id].page->dx = mv[id].map->tiles->tileWidth;
\r
492 /* draw the next column */
\r
494 if(player[plid].q%4)
\r
496 mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, mv->page->dx);
\r
498 if(!pageflipflop && !pageploop)
\r
499 modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->th+2));
\r
504 void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
\r
506 word y;//x, /* coordinate for drawing */
\r
508 /* decrement the pixel position and update the page */
\r
509 mv[id].page->dy -= player[plid].speed;
\r
511 /* check to see if this changes the tile */
\r
512 if(mv[id].page->dy == 0 )
\r
514 /* go down one tile */
\r
516 /* Snap the origin downward */
\r
517 mv[id].page->data -= mv[id].page->pi;
\r
519 mv[id].page->dy = mv[id].map->tiles->tileHeight;
\r
522 /* draw the next row */
\r
524 if(player[plid].q%3)
\r
526 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, mv->page->dy);
\r
528 if(!pageflipflop && !pageploop)
\r
529 modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->tw+2), mv[id].map->tiles->tileHeight);
\r
533 void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)
\r
535 word y;//x, /* coordinate for drawing */
\r
537 /* increment the pixel position and update the page */
\r
538 mv[id].page->dy += player[plid].speed;
\r
540 /* check to see if this changes the tile */
\r
541 if(mv[id].page->dy >= mv[id].dyThresh )
\r
543 /* go down one tile */
\r
545 /* Snap the origin downward */
\r
546 mv[id].page->data += mv[id].page->pi;
\r
548 mv[id].page->dy = mv[id].map->tiles->tileHeight;
\r
551 /* draw the next row */
\r
552 y= mv[0].page->sh + mv[id].map->tiles->tileHeight;
\r
553 if(player[plid].q%3)
\r
555 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+mv[0].page->th, y, player, mv->page->dy);
\r
557 if(!pageflipflop && !pageploop)
\r
558 modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->tw+2), mv[id].map->tiles->tileHeight);
\r
563 //TODO finish this wwww
\r
564 void near ScrollRight(map_view_t *mv, player_t *player, word id, word plid)
\r
566 /* increment the pixel position and update the page */
\r
567 mv[id].page->dx += player[plid].speed;
\r
569 /* check to see if this changes the tile */
\r
570 if(mv[id].page->dx >= mv[0].dxThresh )
\r
572 // vga_setup_wm1_block_copy();
\r
573 // _fmemmove(mv[id].page->data+4, mv[id].page->data, mv[id].page->pagesize);
\r
574 // vga_restore_rm0wm0();
\r
575 /* Snap the origin forward */
\r
576 mv[id].page->data += 4;
\r
577 mv[id].page->dx = mv[0].map->tiles->tileWidth;
\r
581 void near ScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
\r
583 /* decrement the pixel position and update the page */
\r
584 mv[id].page->dx -= player[plid].speed;
\r
586 /* check to see if this changes the tile */
\r
587 if(mv[id].page->dx == 0)
\r
589 // vga_setup_wm1_block_copy();
\r
590 // _fmemmove(mv[id].page->data-4, mv[id].page->data, mv[id].page->pagesize);
\r
591 // vga_restore_rm0wm0();
\r
592 /* Snap the origin backward */
\r
593 mv[id].page->data -= 4;
\r
594 mv[id].page->dx = mv[0].map->tiles->tileWidth;
\r
598 void near ScrollUp(map_view_t *mv, player_t *player, word id, word plid)
\r
600 /* decrement the pixel position and update the page */
\r
601 mv[id].page->dy -= player[plid].speed;
\r
603 /* check to see if this changes the tile */
\r
604 if(mv[id].page->dy == 0)
\r
606 // vga_setup_wm1_block_copy();
\r
607 // _fmemmove(mv[id].page->data-mv[id].page->pi, mv[id].page->data, mv[id].page->pagesize);
\r
608 // vga_restore_rm0wm0();
\r
609 /* Snap the origin backward */
\r
610 mv[id].page->data -= mv[id].page->pi;
\r
611 mv[id].page->dy = mv[0].map->tiles->tileWidth;
\r
615 void near ScrollDown(map_view_t *mv, player_t *player, word id, word plid)
\r
617 /* increment the pixel position and update the page */
\r
618 mv[id].page->dy += player[plid].speed;
\r
620 /* check to see if this changes the tile */
\r
621 if(mv[id].page->dy >= mv[0].dxThresh )
\r
623 // vga_setup_wm1_block_copy();
\r
624 // _fmemmove(mv[id].page->data+mv[id].page->pi, mv[id].page->data, mv[id].page->pagesize);
\r
625 // vga_restore_rm0wm0();
\r
626 /* Snap the origin forward */
\r
627 mv[id].page->data += mv[id].page->pi;
\r
628 mv[id].page->dy = mv[0].map->tiles->tileWidth;
\r
632 sword chkmap(map_t *map, word q)
\r
635 static byte x[(MAPW*MAPH)+1] =
\r
636 { 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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1, \
\r
649 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
\r
650 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
651 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 1, 2, 3, 4 };*/
\r
652 //check for failed to load map
\r
653 if((map->width == map->height == 0) && (q>0))
\r
655 //initiate a null map!
\r
656 map->width=MAPW;///2;
\r
657 map->height=MAPH;///2;
\r
658 // map->data = malloc(((map->width*map->height)+1)*sizeof(byte));
\r
660 map->tiles = malloc(sizeof(tiles_t));
\r
661 //fix this to be far~
\r
662 // bp = bitmapLoadPcx("data/ed.pcx");
\r
663 // map->tiles->data = &bp;
\r
664 #ifdef __DEBUG_MAP__
\r
665 dbg_mapdata = map->data;
\r
667 map->tiles->tileHeight = 16;
\r
668 map->tiles->tileWidth = 16;
\r
669 map->tiles->rows = 1;
\r
670 map->tiles->cols = 1;
\r
671 #ifdef __DEBUG_MAP__
\r
672 dbg_maptext = true;
\r
675 #ifdef __DEBUG_MAP__
\r
676 else dbg_maptext = false;
\r
681 //TODO: player position here
\r
682 void mapGoTo(map_view_t *mv, int tx, int ty)
\r
687 mapinitmapview(mv, tx, ty);
\r
689 /* draw the tiles */
\r
690 modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 0);
\r
692 i=mv[0].ty * mv[0].map->width + mv[0].tx;
\r
693 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
694 mapDrawWRow(&mv[0], tx-1, ty, py);
\r
695 i+=mv->map->width - tx;
\r
697 if(!pageploop) modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height);
\r
699 // unsigned int k,j,o;
\r
700 // /* fill screen with a distinctive pattern */
\r
701 // for (k=0;k < vga_state.vga_width;k++) {
\r
703 // vga_write_sequencer(0x02/*map mask*/,1 << (k&3));
\r
704 // for (j=0;j < (mv[0].page->height)+(mv[1].page->height)+(mv[2].page->height)+(mv[3].page->height);j++,o += vga_state.vga_stride)
\r
705 // vga_state.vga_graphics_ram[o] = (k^j)&15; // VRL samples put all colors in first 15!
\r
708 modexCopyPageRegion(mv[3].page, mv[0].page, 0/**/, 0/**/, 0, 0, 24, 32);
\r
711 void mapinitmapview(map_view_t *mv, int tx, int ty)
\r
713 /* set up the coordinates */
\r
714 mv[0].tx = mv[1].tx = tx;
\r
715 mv[0].ty = mv[1].ty = ty;
\r
716 mv[0].page->dx = mv[1].page->dx = mv[2].page->dx = mv[3].page->dx = mv->map->tiles->tileWidth;
\r
717 mv[0].page->dy = mv[1].page->dy = mv[2].page->dy = mv[3].page->dy = mv->map->tiles->tileHeight;
\r
719 /* set up the thresholds */
\r
720 mv[0].dxThresh = mv[1].dxThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileWidth * 2;
\r
721 mv[0].dyThresh = mv[1].dyThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileHeight * 2;
\r
725 mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y)
\r
729 //word textx=0, texty=0;
\r
734 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 0); //currently the over scan color!
\r
738 rx = (((i-1) % ((t->data->width)/t->tileWidth)) * t->tileWidth);
\r
739 ry = (((i-1) / ((t->data->height)/t->tileHeight)) * t->tileHeight);
\r
740 ////0000printf("i=%d\n", i);
\r
741 #ifdef __DEBUG_MAP__
\r
742 switch(dbg_maptext)
\r
747 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, ((dbg_mapdata[i])+1));
\r
748 //modexprint(page, x, y, 1, 15, 0, (char const *)(t->debug_data[i]));
\r
750 PBUFBFUN (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
\r
751 /* then the sprite. note modding ram ptr means we just draw to (x&3,0) */
\r
752 //draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));
\r
753 //modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
\r
755 #ifdef __DEBUG_MAP__
\r
758 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, (dbg_mapdata[i])+1);
\r
759 //modexprintbig(page, x, y, 1, 15, 0, (t->debug_data));
\r
760 /*for(texty=0; texty<2; texty++)
\r
762 for(textx=0; textx<2; textx++)
\r
764 // modexprint(page, x+(textx*8), y+(texty*8), 1, (word)(t->debug_data), 0, (t->debug_data));
\r
773 void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *p, word poopoffset)
\r
777 poopoffset%=p[0].speed;
\r
778 //printf("y: %d\n", poopoffset);
\r
779 /* the position within the map array */
\r
780 i=ty * mv->map->width + tx;
\r
781 for(x=poopoffset; x<(mv->page->sw+mv->dxThresh)/(poopoffset+1) && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
\r
783 /* we are in the map, so copy! */
\r
784 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
790 void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *p, word poopoffset)
\r
794 poopoffset%=p[0].speed;
\r
795 //printf("x: %d\n", poopoffset);
\r
796 /* location in the map array */
\r
797 i=ty * mv->map->width + tx;
\r
799 /* We'll copy all of the columns in the screen,
\r
800 i + 1 row above and one below */
\r
801 for(y=poopoffset; y<(mv->page->sh+mv->dyThresh)/(poopoffset+1) && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
\r
803 /* we are in the map, so copy away! */
\r
804 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
806 i += mv->map->width;
\r
810 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(x=0; x<mv->page->sw+mv->dxThresh && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
\r
819 /* we are in the map, so copy! */
\r
820 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
826 void mapDrawWCol(map_view_t *mv, int tx, int ty, word x)
\r
831 /* location in the map array */
\r
832 i=ty * mv->map->width + tx;
\r
834 /* We'll copy all of the columns in the screen,
\r
835 i + 1 row above and one below */
\r
836 for(y=0; y<mv->page->sh+mv->dyThresh && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
\r
838 /* we are in the map, so copy away! */
\r
839 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
841 i += mv->map->width;
\r
850 unsigned char shinku_fps_indicator_page = 2;
\r
851 boolean pageflipflop = 1;
\r
852 boolean pageploop = 1;
\r
855 void shinku(global_game_variables_t *gv)
\r
857 word x = (0) + gv->video.page[/*!*/(gv->video.p)].dx; // follow the screen
\r
858 word y = (0) + gv->video.page[/*!*/(gv->video.p)].dy; // follow the screen
\r
859 word col = 7, bgcol = 0, type = 1;//w = 64, h = 8,
\r
861 //modexCopyPageRegion(pip[1].page, pip[2].page, 16, 16, 16, 16, (14*8)+4, 8+4);
\r
862 /* block copy to visible RAM from offscreen */
\r
863 // vga_setup_wm1_block_copy();
\r
864 // modexCopyPageRegion(&(gv->video.page[shinku_fps_indicator_page]), &(gv->video.page[!shinku_fps_indicator_page]), x, y, x+w, 0, w, h);
\r
865 // o = *(gv->video.page[2].data); // source offscreen
\r
866 // o2 = *(gv->video.page[shinku_fps_indicator_page].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride)
\r
867 // 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
868 /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */
\r
869 // vga_restore_rm0wm0();
\r
870 if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second))
\r
872 // NTS: For some bizarre reason, gv->pee is not initialized, but the pointer is not NULL even
\r
873 // though it should be. Instead it's NULL as a near pointer but contains a non-null
\r
874 // segment value, so testing against NULL doesn't work. It is initialized properly if
\r
875 // you call start_timer() though which uses near malloc. Rather than fight with that,
\r
876 // I decided it would be better to declare a temp buffer statically and sprintf to that.
\r
878 // This fixes *** Null pointer assignment detected error message in ZCROLL.EXE on exit.
\r
879 sprintf(global_temp_status_text, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv));
\r
880 //modexClearRegion(&(gv->video.page[shinku_fps_indicator_page]), x, y, w, h, 45);
\r
881 modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, col, bgcol, global_temp_status_text);
\r
882 gv->kurokku.tiku=0;
\r
883 /* block copy to visible RAM from offscreen */
\r
884 // vga_setup_wm1_block_copy();
\r
885 // o = *(gv->video.page[shinku_fps_indicator_page].data); // source offscreen
\r
886 // o2 = *(gv->video.page[2].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride)
\r
887 // 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
888 // modexCopyPageRegion(&(gv->video.page[shinku_fps_indicator_page]), &(gv->video.page[!shinku_fps_indicator_page]), x, y, x, 0, w, h);
\r
889 /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */
\r
890 // vga_restore_rm0wm0();
\r
891 }else //copy dat sheet
\r
892 gv->kurokku.tiku++;
\r
894 switch(gv->kurokku.fpscap)
\r
897 //modexprint(&(gv->video.page[shinku_fps_indicator_page]), x, y+8, type, col, bgcol, "sanic!");
\r
898 gv->kurokku.frames_per_second=1;
\r
901 //turn this off if XT
\r
902 //modexWaitBorder();
\r
903 vga_wait_for_vsync();
\r
904 gv->kurokku.frames_per_second=60;
\r
909 //vga_setup_wm1_block_copy();
\r
910 //_fmemcpy((gv->video.page[(gv->video.p)]).data, (gv->video.page[(!gv->video.p)]).data, gv->video.page[(!gv->video.p)].pagesize);
\r
911 //vga_restore_rm0wm0();
\r
912 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
913 modexShowPage(&(gv->video.page[gv->video.p]));
\r
914 if(!pageploop) gv->video.p=!gv->video.p;
\r
915 gv->video.r=!gv->video.r;
\r
916 //0000gv->video.tickclk = ((*clockw)-gv->video.startclk)/18.2;
\r
921 void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch)
\r
923 sword x = player[pn].x;
\r
924 sword y = player[pn].y;
\r
925 sword bx = x+16; //buffer's x
\r
926 sword by = y+16; //buffer's y
\r
927 word dire=32; //direction
\r
928 sword qq; //scroll offset
\r
929 word ls = player[pn].persist_aniframe;
\r
931 switch(scrollswitch)
\r
937 qq = ((player[pn].q)*(player[pn].speed));
\r
941 y-=pip[0].map->tiles->tileHeight;
\r
942 switch (player[pn].d)
\r
946 dire*=player[pn].d;
\r
952 dire*=(player[pn].d-2);
\r
960 dire*=(player[pn].d-2);
\r
966 dire*=(player[pn].d+2);
\r
973 #define FRAME1 PBUFSFUN(pip[/*!*/(pip->video->p)].page, x, y, 48, dire, 24, 32, PLAYERBMPDATA);
\r
974 #define FRAME2 PBUFSFUN(pip[/*!*/(pip->video->p)].page, x, y, 24, dire, 24, 32, PLAYERBMPDATA);
\r
975 #define FRAME3 PBUFSFUN(pip[/*!*/(pip->video->p)].page, x, y, 0, dire, 24, 32, PLAYERBMPDATA);
\r
976 #define FRAME4 PBUFSFUN(pip[/*!*/(pip->video->p)].page, x, y, 24, dire, 24, 32, PLAYERBMPDATA);
\r
978 #define FRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 2+dire);
\r
979 #define FRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 1+dire);
\r
980 #define FRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, dire);
\r
981 #define FRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 1+dire);
\r
984 modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 36);
\r
986 //copy old bg to page0
\r
987 //modexCopyPageRegion(pip[3].page, pip[0].page, bx, by, 0, 0, 20, 36);
\r
989 //modexCopyPageRegion(pip[0].page, pip[3].page, 0, 0, x, y, 20, 36);
\r
991 //modexCopyPageRegion(page_t *dest, page_t *src, word sx, word sy, word dx, word dy, word width, word height);
\r
992 //modexCopyPageRegion(pip[3].page, pip[!(pip->video->p)].page, x-4, y-4, 0, 128, 28, 36);
\r
993 /*modexCopyPageRegion(pip[pip->video->p].page,
\r
994 pip[!(pip->video->p)].page, x-4, y-4, x-4, y-4, 28, 36);*/
\r
995 // else modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 40);
\r
1011 // if(2>ls && ls>=1) { FRAME1 }else
\r
1012 // if(3>ls && ls>=2) { FRAME2 }else
\r
1013 // if(4>ls && ls>=3) { FRAME3 }else
\r
1014 // if(5>ls && ls>=4) { FRAME4 }
\r
1015 //modexCopyPageRegion(pip[0].page, pip[3].page, 0, 0, x, y, 24, 32);
\r
1016 //printf("x=%d y=%d bx=%d by=%d\n", x, y, bx, by);
\r
1024 boolean boundary_check(int x, int y, int dx, int dy, int h, int w)
\r
1026 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
1029 boolean coll_check(int x, int y, int dx, int dy, map_view_t *map_v)
\r
1031 // Assume everything crosses at most 1 tile at once
\r
1032 return dx && 1;//crossable_tile(x + dx, map_v) || dy && crossable_tile(y + dy, map_v);
\r
1035 boolean ZC_walk(entity_t *ent, map_view_t *map_v)
\r
1055 if(coll_check(ent->x, ent->y, dx, dy, map_v))
\r
1059 // Start animation
\r
1060 // Mark next tile as occupied
\r
1061 // Mark this tile as vacant
\r
1067 void player_walk(player_t *player, map_view_t *map_v){
\r
1069 if(ZC_walk(player->ent, map_v) && boundary_check(map_v->tx, map_v->ty, dx, dy, map_v->map->width - 2*map_v->page->tilesw, map_v->map->height - 2*map_v->page->tilesh))
\r
1071 mapScroll(map_v, player);
\r
1072 // (Un)load stuff?
\r
1076 void near mapScroll(map_view_t *mv, player_t *player)
\r
1078 //word x, y; /* coordinate for drawing */
\r
1081 mv->delta += player->dx | player->dy;
\r
1082 delta = mv->delta;
\r
1083 mv->d = (player->dx) ? (player->dx > 0) ? 3 : 1 : (player->dy) ? (player->dy > 0) ? 4 : 0 : 2;
\r
1089 if(!(delta + mv->dxThresh))
\r
1099 if(!(delta + mv->dyThresh))
\r