1 /* Project 16 Source Code~
2 * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
4 * This file is part of Project 16.
6 * Project 16 is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * Project 16 is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>, or
18 * write to the Free Software Foundation, Inc., 51 Franklin Street,
19 * Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "src/lib/scroll16.h"
27 void walk(map_view_t *pip, player_t *player, word pn)
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;
34 if(pip[0].tx >= 0 && pip[0].tx+20 < pip[0].map->width && player[pn].tx == pip[0].tx + 10 &&
35 !(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!
37 if(player[pn].q<=(TILEWH/(player[pn].speed)))
40 animatePlayer(pip, player, pn, 1);
41 mapScrollRight(pip, player, 0, pn);
42 mapScrollRight(pip, player, 1, pn);
43 modexShowPage(pip[1].page);
45 } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx++; }
47 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))
49 if(player[pn].q<=(TILEWH/(player[pn].speed)))
52 player[pn].x+=(player[pn].speed);
53 animatePlayer(pip, player, pn, 0);
54 modexShowPage(pip[1].page);
56 } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx++; }
60 modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x-4, player[pn].y-TILEWH, player[pn].x-4, player[pn].y-TILEWH, 24, 32);
62 modexDrawSpriteRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 24, 32, &player[pn].data);
64 modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 14);
66 modexShowPage(pip[1].page);
69 player[pn].triggerx = player[pn].tx+1;
70 player[pn].triggery = player[pn].ty;
75 if(pip[0].tx > 0 && pip[0].tx+20 <= pip[0].map->width && player[pn].tx == pip[0].tx + 10 &&
76 !(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!
78 if(player[pn].q<=(TILEWH/(player[pn].speed)))
81 animatePlayer(pip, player, pn, 1);
82 mapScrollLeft(pip, player, 0, pn);
83 mapScrollLeft(pip, player, 1, pn);
84 modexShowPage(pip[1].page);
86 } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx--; }
88 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))
90 if(player[pn].q<=(TILEWH/(player[pn].speed)))
93 player[pn].x-=(player[pn].speed);
94 animatePlayer(pip, player, pn, 0);
95 modexShowPage(pip[1].page);
97 } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx--; }
101 modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x-4, player[pn].y-TILEWH, player[pn].x-4, player[pn].y-TILEWH, 24, 32);
103 modexDrawSpriteRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 96, 24, 32, &player[pn].data);
105 modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 10);
107 modexShowPage(pip[1].page);
110 player[pn].triggerx = player[pn].tx-1;
111 player[pn].triggery = player[pn].ty;
116 if(pip[0].ty >= 0 && pip[0].ty+15 < pip[0].map->height && player[pn].ty == pip[0].ty + 8 &&
117 !(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!
119 if(player[pn].q<=(TILEWH/(player[pn].speed)))
122 animatePlayer(pip, player, pn, 1);
123 mapScrollDown(pip, player, 0, pn);
124 mapScrollDown(pip, player, 1, pn);
125 modexShowPage(pip[1].page);
127 } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty++; }
129 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))
131 if(player[pn].q<=(TILEWH/(player[pn].speed)))
134 player[pn].y+=(player[pn].speed);
135 animatePlayer(pip, player, pn, 0);
136 modexShowPage(pip[1].page);
138 } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty++; }
142 modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x-4, player[pn].y-TILEWH, player[pn].x-4, player[pn].y-TILEWH, 24, 32);
144 modexDrawSpriteRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 64, 24, 32, &player[pn].data);
146 modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 9);
148 modexShowPage(pip[1].page);
151 player[pn].triggerx = player[pn].tx;
152 player[pn].triggery = player[pn].ty+1;
157 if(pip[0].ty > 0 && pip[0].ty+15 <= pip[0].map->height && player[pn].ty == pip[0].ty + 8 &&
158 !(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!
160 if(player[pn].q<=(TILEWH/(player[pn].speed)))
163 animatePlayer(pip, player, pn, 1);
164 mapScrollUp(pip, player, 0, pn);
165 mapScrollUp(pip, player, 1, pn);
166 modexShowPage(pip[1].page);
168 } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty--; }
170 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))
172 if(player[pn].q<=(TILEWH/(player[pn].speed)))
175 player[pn].y-=(player[pn].speed);
176 animatePlayer(pip, player, 0, pn);
177 modexShowPage(pip[1].page);
179 } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty--; }
183 modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x-4, player[pn].y-TILEWH, player[pn].x-4, player[pn].y-TILEWH, 24, 32);
185 modexDrawSpriteRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 0, 24, 32, &player[pn].data);
187 modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 12);
189 modexShowPage(pip[1].page);
192 player[pn].triggerx = player[pn].tx;
193 player[pn].triggery = player[pn].ty-1;
199 allocMap(int w, int h) {
204 result.data = malloc(sizeof(byte) * w * h);
205 //result.data = (byte *)alloc_emem(((int)sizeof(byte) * w * h)/1024);
206 if(isEMS() || checkEMS())
209 //emmhandle = mallocEMS(coretotalEMS());//alloc_emem((int)sizeof(map))
210 mm.length=sizeof(result);
212 mm.sourceOff=ptr2long(&result);
215 ist = move_emem(&mm);
216 if(!ist){ dealloc_emem(emmhandle); exit(5); }
217 printf("%d\n", coretotalEMS());
224 initMap(map_t *map) {
225 // just a place holder to fill out an alternating pattern
229 //if(!isEMS() || !checkEMS())
230 // map->tiles = malloc(sizeof(tiles_t));
232 // map->tiles = (tiles_t *)alloc_emem(sizeof(tiles_t));
234 //create the tile set
235 //if(!isEMS() || !checkEMS())
236 // map->tiles->data = malloc(sizeof(bitmap_t));
238 // map->tiles->data = (bitmap_t *)alloc_emem(sizeof(bitmap_t));
239 // map->tiles->data->width = (TILEWH);
240 // map->tiles->data->height= TILEWH;
241 //if(!isEMS() || !checkEMS())
242 // map->tiles->data->data = malloc((TILEWH*2)*TILEWH);
244 // map->tiles->data->data = (byte *)alloc_emem((TILEWH*2)*TILEWH);
245 // map->tiles->tileHeight = TILEWH;
246 // map->tiles->tileWidth =TILEWH;
247 // map->tiles->rows = 1;
248 // map->tiles->cols = 1;//2;
251 //for(y=0; y<map->height; y++) {
252 //for(x=0; x<map->width; x++) {
254 for(yy=0; yy<TILEWH; yy++) {
255 for(xx=0; xx<(TILEWH); xx++) {
257 map->tiles->data->data[i+1] = map->data[q];//28;//0x24;
258 // printf("[%d]", map->tiles->data->data[i]);
260 //map->tiles->data->data[i] = map->data[q];//0;//0x34;
261 //printf("]%d[==[%d]", i, map->tiles->data->data[i]);
267 // printf("[%d]", map->data[q]);
274 for(y=0; y<map->height; y++) {
275 for(x=0; x<map->width; x++) {
277 printf("[%d]", map->data[i]);
278 //tile = tile ? 0 : 1;
281 //tile = tile ? 0 : 1;
285 void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
287 word x, y; /* coordinate for drawing */
289 /* increment the pixel position and update the page */
290 mv[id].page->dx += player[plid].speed;
292 /* check to see if this changes the tile */
293 if(mv[id].page->dx >= mv[id].dxThresh )
295 /* go forward one tile */
297 /* Snap the origin forward */
298 mv[id].page->data += 4;
299 mv[id].page->dx = mv[id].map->tiles->tileWidth;
302 /* draw the next column */
303 x= SCREEN_WIDTH + mv[id].map->tiles->tileWidth;
306 mapDrawCol(&mv[0], mv[0].tx + 20 , mv[0].ty-1, x, player, mv->page->dx);
308 modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*17);
313 void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
315 word x, y; /* coordinate for drawing */
317 /* increment the pixel position and update the page */
318 mv[id].page->dx -= player[plid].speed;
320 /* check to see if this changes the tile */
321 if(mv[id].page->dx == 0)
323 /* go backward one tile */
326 /* Snap the origin backward */
327 mv[id].page->data -= 4;
328 mv[id].page->dx = mv[id].map->tiles->tileWidth;
331 /* draw the next column */
335 mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, mv->page->dx);
337 modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*17);
342 void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
344 word x, y; /* coordinate for drawing */
346 /* increment the pixel position and update the page */
347 mv[id].page->dy -= player[plid].speed;
349 /* check to see if this changes the tile */
350 if(mv[id].page->dy == 0 )
352 /* go down one tile */
354 /* Snap the origin downward */
355 mv[id].page->data -= mv[id].page->width*4;
356 mv[id].page->dy = mv[id].map->tiles->tileHeight;
359 /* draw the next row */
363 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, mv->page->dy);
365 modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*22, mv[id].map->tiles->tileHeight);
369 void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)
371 word x, y; /* coordinate for drawing */
373 /* increment the pixel position and update the page */
374 mv[id].page->dy += player[plid].speed;
376 /* check to see if this changes the tile */
377 if(mv[id].page->dy >= mv[id].dyThresh )
379 /* go down one tile */
381 /* Snap the origin downward */
382 mv[id].page->data += mv[id].page->width*4;
383 mv[id].page->dy = mv[id].map->tiles->tileHeight;
386 /* draw the next row */
387 y= SCREEN_HEIGHT + mv[id].map->tiles->tileHeight;
390 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+15, y, player, mv->page->dy);
392 modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*22, mv[id].map->tiles->tileHeight);
396 sword chkmap(map_t *map, word q)
399 static byte x[(MAPW*MAPH)+1] =
400 { 1, 2, 3, 4, 0, 3, 3, 3, 3, 3, 3, 3, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, \
410 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
411 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
412 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
413 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
414 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
415 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 1, 2, 3, 4 };*/
416 //check for failed to load map
417 if((map->width == map->height == 0) && (q>0))
419 //initiate a null map!
420 map->width=MAPW;///2;
421 map->height=MAPH;///2;
422 // map->data = malloc(((map->width*map->height)+1)*sizeof(byte));
424 map->tiles = malloc(sizeof(tiles_t));
425 //fix this to be far~
426 // bp = bitmapLoadPcx("data/ed.pcx");
427 // map->tiles->data = &bp;
428 map->tiles->debug_data = map->data;
429 map->tiles->tileHeight = 16;
430 map->tiles->tileWidth = 16;
431 map->tiles->rows = 1;
432 map->tiles->cols = 1;
433 map->tiles->debug_text = true;
435 else map->tiles->debug_text = false;
439 void mapGoTo(map_view_t *mv, int tx, int ty)
444 /* set up the coordinates */
447 mv->page->dx = mv->map->tiles->tileWidth;
448 mv->page->dy = mv->map->tiles->tileHeight;
450 /* set up the thresholds */
451 mv->dxThresh = mv->map->tiles->tileWidth * 2;
452 mv->dyThresh = mv->map->tiles->tileHeight * 2;
455 modexClearRegion(mv->page, 0, 0, mv->page->width, mv->page->height, 0);
457 i=mv->ty * mv->map->width + mv->tx;
458 for(ty=mv->ty-1; py < SCREEN_HEIGHT+mv->dyThresh && ty < mv->map->height; ty++, py+=mv->map->tiles->tileHeight) {
459 mapDrawWRow(mv, tx-1, ty, py);
460 i+=mv->map->width - tx;
466 mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y)
476 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 0); //currently the over scan color!
480 rx = (((i-1) % ((t->data->width)/t->tileWidth)) * t->tileWidth);
481 ry = (((i-1) / ((t->data->height)/t->tileHeight)) * t->tileHeight);
482 ////0000printf("i=%d\n", i);
483 switch(t->debug_text)
487 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, ((t->debug_data[i])+1)*2);
488 //cannot print number value du to it being slow as bakapee
490 modexDrawBmpRegion(page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
494 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, (t->debug_data[i])+1);
495 //modexprintbig(page, x, y, 1, 15, 0, (t->debug_data));
496 /*for(texty=0; texty<2; texty++)
498 for(textx=0; textx<2; textx++)
500 // modexprint(page, x+(textx*8), y+(texty*8), 1, (word)(t->debug_data), 0, (t->debug_data));
508 void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *p, word poopoffset)
512 poopoffset%=p[0].speed;
513 //printf("y: %d\n", poopoffset);
514 /* the position within the map array */
515 i=ty * mv->map->width + tx;
516 for(x=poopoffset; x<(SCREEN_WIDTH+mv->dxThresh)/(poopoffset+1) && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
518 /* we are in the map, so copy! */
519 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
525 void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *p, word poopoffset)
529 poopoffset%=p[0].speed;
530 //printf("x: %d\n", poopoffset);
531 /* location in the map array */
532 i=ty * mv->map->width + tx;
534 /* We'll copy all of the columns in the screen,
535 i + 1 row above and one below */
536 for(y=poopoffset; y<(SCREEN_HEIGHT+mv->dyThresh)/(poopoffset+1) && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
538 /* we are in the map, so copy away! */
539 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
545 void mapDrawWRow(map_view_t *mv, int tx, int ty, word y)
550 /* the position within the map array */
551 i=ty * mv->map->width + tx;
552 for(x=0; x<SCREEN_WIDTH+mv->dxThresh && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
554 /* we are in the map, so copy! */
555 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
561 void mapDrawWCol(map_view_t *mv, int tx, int ty, word x)
566 /* location in the map array */
567 i=ty * mv->map->width + tx;
569 /* We'll copy all of the columns in the screen,
570 i + 1 row above and one below */
571 for(y=0; y<SCREEN_HEIGHT+mv->dyThresh && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
573 /* we are in the map, so copy away! */
574 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
587 void shinku(map_view_t *pip, global_game_variables_t *gv)
590 //modexCopyPageRegion(pip[1].page, pip[2].page, 16, 16, 16, 16, (14*8)+4, 8+4);
591 if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second))
598 //t=(((*(gv->clock))-gv->clock_start) /18.2);
599 sprintf(gv->pee, "%f fps", (double)gv->kurokku.tiku/ticktock(gv));
600 modexprint(pip[1].page, 16, 16, 1, 15, 0, gv->pee);
601 //(gv->clock_start)=*(gv->clock);
604 //modexprint(page, 16, 16, 1, 15, 0, pee);
606 switch(gv->kurokku.fpscap)
609 //modexprint(page, 16, 32, 1, 15, 0, "sanic!");
610 gv->kurokku.frames_per_second=1;
613 //turn this off if XT
615 gv->kurokku.frames_per_second=60;
620 void near animatePlayer(map_view_t *pip, player_t *player, word playnum, sword scrollswitch)
622 sword x = player[playnum].x;
623 sword y = player[playnum].y;
625 word dire=32; //direction
627 word dire=8; //direction
629 sword qq; //scroll offset
630 word ls = player[playnum].persist_aniframe;
632 if(scrollswitch==0) qq = 0;
633 else qq = ((player[playnum].q)*(player[playnum].speed));
636 switch (player[playnum].d)
640 dire*=player[playnum].d;
645 dire*=(player[playnum].d-2);
652 dire*=(player[playnum].d-2);
657 dire*=(player[playnum].d+2);
664 #define FRAME1 oldDrawBmp(VGA, x, y, &player[playnum].data, 1);
665 #define FRAME2 oldDrawBmp(VGA, x, y, &player[playnum].data, 1);
666 #define FRAME3 oldDrawBmp(VGA, x, y, &player[playnum].data, 1);
667 #define FRAME4 oldDrawBmp(VGA, x, y, &player[playnum].data, 1);
669 #define FRAME1 modexDrawSpriteRegion(pip[1].page, x, y, 48, dire, 24, 32, &player[playnum].data);
670 #define FRAME2 modexDrawSpriteRegion(pip[1].page, x, y, 24, dire, 24, 32, &player[playnum].data);
671 #define FRAME3 modexDrawSpriteRegion(pip[1].page, x, y, 0, dire, 24, 32, &player[playnum].data);
672 #define FRAME4 modexDrawSpriteRegion(pip[1].page, x, y, 24, dire, 24, 32, &player[playnum].data);
675 #define FRAME1 modexClearRegion(pip[1].page, x, y, 24, 32, 2+dire);
676 #define FRAME2 modexClearRegion(pip[1].page, x, y, 24, 32, 1+dire);
677 #define FRAME3 modexClearRegion(pip[1].page, x, y, 24, 32, dire);
678 #define FRAME4 modexClearRegion(pip[1].page, x, y, 24, 32, 1+dire);
680 modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 40);
681 //modexCopyPageRegion(pip[2].page, pip[1].page, 16, 16, 16, 16, (14*8)+4, 8+4);
682 if(2>ls && ls>=1) { FRAME1 }else
683 if(3>ls && ls>=2) { FRAME2 }else
684 if(4>ls && ls>=3) { FRAME3 }else
685 if(5>ls && ls>=4) { FRAME4 }
686 //TODO: mask copy //modexCopyPageRegion(dest->page, src->page, x-4, y-4, x-4, y-4, 28, 40);
687 //modexClearRegion(top->page, 66, 66, 2, 40, 0);
688 //modexCopyPageRegion(dest->page, top->page, 66, 66, 66, 66, 2, 40);