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 //printf("pip[0].page->tilesw=%d\n", pip[0].page->tilesw);
35 if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->tilesw < pip[0].map->width && player[pn].tx == pip[0].tx+pip[0].page->tilemidposscreenx &&
36 !(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!
38 if(player[pn].q<=(TILEWH/(player[pn].speed)))
41 animatePlayer(pip, player, pn, 1);
42 mapScrollRight(pip, player, 0, pn);
43 mapScrollRight(pip, player, 1, pn);
44 modexShowPage(pip[1].page);
46 } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx++; }
48 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))
50 if(player[pn].q<=(TILEWH/(player[pn].speed)))
53 player[pn].x+=(player[pn].speed);
54 animatePlayer(pip, player, pn, 0);
55 modexShowPage(pip[1].page);
57 } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx++; }
61 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);
64 modexDrawPBufRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 24, 32, &player[pn].data, 1);
66 modexDrawSpriteRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 24, 32, &player[pn].data);
69 modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 14);
71 modexShowPage(pip[1].page);
74 player[pn].triggerx = player[pn].tx+1;
75 player[pn].triggery = player[pn].ty;
80 if(pip[0].tx > 0 && pip[0].tx+pip[0].page->tilesw <= pip[0].map->width && player[pn].tx == pip[0].tx+pip[0].page->tilemidposscreenx &&
81 !(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!
83 if(player[pn].q<=(TILEWH/(player[pn].speed)))
86 animatePlayer(pip, player, pn, 1);
87 mapScrollLeft(pip, player, 0, pn);
88 mapScrollLeft(pip, player, 1, pn);
89 modexShowPage(pip[1].page);
91 } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx--; }
93 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))
95 if(player[pn].q<=(TILEWH/(player[pn].speed)))
98 player[pn].x-=(player[pn].speed);
99 animatePlayer(pip, player, pn, 0);
100 modexShowPage(pip[1].page);
102 } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx--; }
106 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);
109 modexDrawPBufRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 96, 24, 32, &player[pn].data, 1);
111 modexDrawSpriteRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 96, 24, 32, &player[pn].data);
114 modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 10);
116 modexShowPage(pip[1].page);
119 player[pn].triggerx = player[pn].tx-1;
120 player[pn].triggery = player[pn].ty;
125 if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->tilesh < pip[0].map->height && player[pn].ty == pip[0].ty+pip[0].page->tilemidposscreeny &&
126 !(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!
128 if(player[pn].q<=(TILEWH/(player[pn].speed)))
131 animatePlayer(pip, player, pn, 1);
132 mapScrollDown(pip, player, 0, pn);
133 mapScrollDown(pip, player, 1, pn);
134 modexShowPage(pip[1].page);
136 } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty++; }
138 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))
140 if(player[pn].q<=(TILEWH/(player[pn].speed)))
143 player[pn].y+=(player[pn].speed);
144 animatePlayer(pip, player, pn, 0);
145 modexShowPage(pip[1].page);
147 } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty++; }
151 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);
154 modexDrawPBufRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 64, 24, 32, &player[pn].data, 1);
156 modexDrawSpriteRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 64, 24, 32, &player[pn].data);
159 modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 9);
161 modexShowPage(pip[1].page);
164 player[pn].triggerx = player[pn].tx;
165 player[pn].triggery = player[pn].ty+1;
170 if(pip[0].ty > 0 && pip[0].ty+pip[0].page->tilesh <= pip[0].map->height && player[pn].ty == pip[0].ty+pip[0].page->tilemidposscreeny &&
171 !(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!
173 if(player[pn].q<=(TILEWH/(player[pn].speed)))
176 animatePlayer(pip, player, pn, 1);
177 mapScrollUp(pip, player, 0, pn);
178 mapScrollUp(pip, player, 1, pn);
179 modexShowPage(pip[1].page);
181 } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty--; }
183 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))
185 if(player[pn].q<=(TILEWH/(player[pn].speed)))
188 player[pn].y-=(player[pn].speed);
189 animatePlayer(pip, player, 0, pn);
190 modexShowPage(pip[1].page);
192 } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty--; }
196 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);
199 modexDrawPBufRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 0, 24, 32, &player[pn].data, 1);
201 modexDrawSpriteRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 0, 24, 32, &player[pn].data);
204 modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 12);
206 modexShowPage(pip[1].page);
209 player[pn].triggerx = player[pn].tx;
210 player[pn].triggery = player[pn].ty-1;
216 allocMap(int w, int h) {
221 result.data = malloc(sizeof(byte) * w * h);
222 //result.data = (byte *)alloc_emem(((int)sizeof(byte) * w * h)/1024);
223 if(isEMS() || checkEMS())
226 //emmhandle = mallocEMS(coretotalEMS());//alloc_emem((int)sizeof(map))
227 mm.length=sizeof(result);
229 mm.sourceOff=ptr2long(&result);
232 ist = move_emem(&mm);
233 if(!ist){ dealloc_emem(emmhandle); exit(5); }
234 printf("%d\n", coretotalEMS());
241 initMap(map_t *map) {
242 // just a place holder to fill out an alternating pattern
246 //if(!isEMS() || !checkEMS())
247 // map->tiles = malloc(sizeof(tiles_t));
249 // map->tiles = (tiles_t *)alloc_emem(sizeof(tiles_t));
251 //create the tile set
252 //if(!isEMS() || !checkEMS())
253 // map->tiles->data = malloc(sizeof(bitmap_t));
255 // map->tiles->data = (bitmap_t *)alloc_emem(sizeof(bitmap_t));
256 // map->tiles->data->width = (TILEWH);
257 // map->tiles->data->height= TILEWH;
258 //if(!isEMS() || !checkEMS())
259 // map->tiles->data->data = malloc((TILEWH*2)*TILEWH);
261 // map->tiles->data->data = (byte *)alloc_emem((TILEWH*2)*TILEWH);
262 // map->tiles->tileHeight = TILEWH;
263 // map->tiles->tileWidth =TILEWH;
264 // map->tiles->rows = 1;
265 // map->tiles->cols = 1;//2;
268 //for(y=0; y<map->height; y++) {
269 //for(x=0; x<map->width; x++) {
271 for(yy=0; yy<TILEWH; yy++) {
272 for(xx=0; xx<(TILEWH); xx++) {
274 map->tiles->data->data[i+1] = map->data[q];//28;//0x24;
275 // printf("[%d]", map->tiles->data->data[i]);
277 //map->tiles->data->data[i] = map->data[q];//0;//0x34;
278 //printf("]%d[==[%d]", i, map->tiles->data->data[i]);
284 // printf("[%d]", map->data[q]);
291 for(y=0; y<map->height; y++) {
292 for(x=0; x<map->width; x++) {
294 printf("[%d]", map->data[i]);
295 //tile = tile ? 0 : 1;
298 //tile = tile ? 0 : 1;
302 void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
304 word x, y; /* coordinate for drawing */
306 /* increment the pixel position and update the page */
307 mv[id].page->dx += player[plid].speed;
309 /* check to see if this changes the tile */
310 if(mv[id].page->dx >= mv[id].dxThresh )
312 /* go forward one tile */
314 /* Snap the origin forward */
315 mv[id].page->data += 4;
316 mv[id].page->dx = mv[id].map->tiles->tileWidth;
319 /* draw the next column */
320 x= mv[0].page->sw + mv[id].map->tiles->tileWidth;
323 mapDrawCol(&mv[0], mv[0].tx + mv[0].page->tilesw, mv[0].ty-1, x, player, mv->page->dx);
325 modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->tilesh+2));
330 void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
332 word x, y; /* coordinate for drawing */
334 /* increment the pixel position and update the page */
335 mv[id].page->dx -= player[plid].speed;
337 /* check to see if this changes the tile */
338 if(mv[id].page->dx == 0)
340 /* go backward one tile */
343 /* Snap the origin backward */
344 mv[id].page->data -= 4;
345 mv[id].page->dx = mv[id].map->tiles->tileWidth;
348 /* draw the next column */
352 mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, mv->page->dx);
354 modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->tilesh+2));
359 void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
361 word x, y; /* coordinate for drawing */
363 /* increment the pixel position and update the page */
364 mv[id].page->dy -= player[plid].speed;
366 /* check to see if this changes the tile */
367 if(mv[id].page->dy == 0 )
369 /* go down one tile */
371 /* Snap the origin downward */
372 mv[id].page->data -= mv[id].page->width*4;
373 mv[id].page->dy = mv[id].map->tiles->tileHeight;
376 /* draw the next row */
380 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, mv->page->dy);
382 modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->tilesw+2), mv[id].map->tiles->tileHeight);
386 void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)
388 word x, y; /* coordinate for drawing */
390 /* increment the pixel position and update the page */
391 mv[id].page->dy += player[plid].speed;
393 /* check to see if this changes the tile */
394 if(mv[id].page->dy >= mv[id].dyThresh )
396 /* go down one tile */
398 /* Snap the origin downward */
399 mv[id].page->data += mv[id].page->width*4;
400 mv[id].page->dy = mv[id].map->tiles->tileHeight;
403 /* draw the next row */
404 y= mv[0].page->sh + mv[id].map->tiles->tileHeight;
407 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+mv[0].page->tilesh, y, player, mv->page->dy);
409 modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->tilesw+2), mv[id].map->tiles->tileHeight);
413 sword chkmap(map_t *map, word q)
416 static byte x[(MAPW*MAPH)+1] =
417 { 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 8, 8, 1, 1, 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, 1, 1, 1, 1, 1, 1, \
420 9, 10, 11, 12, 4, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
421 13, 14, 15, 16, 0, 1, 1, 1, 5, 8, 1, 11, 11, 1, 1, 1, 1, 1, 1, 1, \
422 0, 0, 4, 0, 0, 0, 0, 0, 8, 8, 1, 11, 11, 3, 1, 1, 1, 1, 1, 1, \
423 1, 1, 1, 1, 0, 0, 0, 0, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
424 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
425 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
426 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
427 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
428 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
429 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
430 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
431 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
432 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 1, 2, 3, 4 };*/
433 //check for failed to load map
434 if((map->width == map->height == 0) && (q>0))
436 //initiate a null map!
437 map->width=MAPW;///2;
438 map->height=MAPH;///2;
439 // map->data = malloc(((map->width*map->height)+1)*sizeof(byte));
441 map->tiles = malloc(sizeof(tiles_t));
442 //fix this to be far~
443 // bp = bitmapLoadPcx("data/ed.pcx");
444 // map->tiles->data = &bp;
445 map->tiles->debug_data = map->data;
446 map->tiles->tileHeight = 16;
447 map->tiles->tileWidth = 16;
448 map->tiles->rows = 1;
449 map->tiles->cols = 1;
450 map->tiles->debug_text = true;
452 else map->tiles->debug_text = false;
456 void mapGoTo(map_view_t *mv, int tx, int ty)
461 /* set up the coordinates */
464 mv->page->dx = mv->map->tiles->tileWidth;
465 mv->page->dy = mv->map->tiles->tileHeight;
467 /* set up the thresholds */
468 mv->dxThresh = mv->map->tiles->tileWidth * 2;
469 mv->dyThresh = mv->map->tiles->tileHeight * 2;
472 modexClearRegion(mv->page, 0, 0, mv->page->width, mv->page->height, 0);
474 i=mv->ty * mv->map->width + mv->tx;
475 for(ty=mv->ty-1; py < mv->page->sh+mv->dyThresh && ty < mv->map->height; ty++, py+=mv->map->tiles->tileHeight) {
476 mapDrawWRow(mv, tx-1, ty, py);
477 i+=mv->map->width - tx;
483 mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y)
493 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 0); //currently the over scan color!
497 rx = (((i-1) % ((t->data->width)/t->tileWidth)) * t->tileWidth);
498 ry = (((i-1) / ((t->data->height)/t->tileHeight)) * t->tileHeight);
499 ////0000printf("i=%d\n", i);
500 switch(t->debug_text)
504 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, ((t->debug_data[i])+1)*2);
505 //cannot print number value du to it being slow as bakapee
508 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, ((t->debug_data[i])+1)*2);
509 //modexDrawPBufRegion(page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data), 0);
511 modexDrawBmpRegion(page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
516 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, (t->debug_data[i])+1);
517 //modexprintbig(page, x, y, 1, 15, 0, (t->debug_data));
518 /*for(texty=0; texty<2; texty++)
520 for(textx=0; textx<2; textx++)
522 // modexprint(page, x+(textx*8), y+(texty*8), 1, (word)(t->debug_data), 0, (t->debug_data));
530 void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *p, word poopoffset)
534 poopoffset%=p[0].speed;
535 //printf("y: %d\n", poopoffset);
536 /* the position within the map array */
537 i=ty * mv->map->width + tx;
538 for(x=poopoffset; x<(mv->page->sw+mv->dxThresh)/(poopoffset+1) && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
540 /* we are in the map, so copy! */
541 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
547 void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *p, word poopoffset)
551 poopoffset%=p[0].speed;
552 //printf("x: %d\n", poopoffset);
553 /* location in the map array */
554 i=ty * mv->map->width + tx;
556 /* We'll copy all of the columns in the screen,
557 i + 1 row above and one below */
558 for(y=poopoffset; y<(mv->page->sh+mv->dyThresh)/(poopoffset+1) && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
560 /* we are in the map, so copy away! */
561 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
567 void mapDrawWRow(map_view_t *mv, int tx, int ty, word y)
572 /* the position within the map array */
573 i=ty * mv->map->width + tx;
574 for(x=0; x<mv->page->sw+mv->dxThresh && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
576 /* we are in the map, so copy! */
577 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
583 void mapDrawWCol(map_view_t *mv, int tx, int ty, word x)
588 /* location in the map array */
589 i=ty * mv->map->width + tx;
591 /* We'll copy all of the columns in the screen,
592 i + 1 row above and one below */
593 for(y=0; y<mv->page->sh+mv->dyThresh && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
595 /* we are in the map, so copy away! */
596 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
608 void shinku(map_view_t *pip, global_game_variables_t *gv)
611 //modexCopyPageRegion(pip[1].page, pip[2].page, 16, 16, 16, 16, (14*8)+4, 8+4);
612 if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second))
619 //t=(((*(gv->clock))-gv->clock_start) /18.2);
620 sprintf(gv->pee, "%f fps", (double)gv->kurokku.tiku/ticktock(gv));
621 modexprint(pip[1].page, 16, 16, 1, 15, 0, gv->pee);
622 //(gv->clock_start)=*(gv->clock);
625 //modexprint(page, 16, 16, 1, 15, 0, pee);
627 switch(gv->kurokku.fpscap)
630 //modexprint(page, 16, 32, 1, 15, 0, "sanic!");
631 gv->kurokku.frames_per_second=1;
634 //turn this off if XT
636 gv->kurokku.frames_per_second=60;
641 void near animatePlayer(map_view_t *pip, player_t *player, word playnum, sword scrollswitch)
643 sword x = player[playnum].x;
644 sword y = player[playnum].y;
646 word dire=32; //direction
648 word dire=8; //direction
650 sword qq; //scroll offset
651 word ls = player[playnum].persist_aniframe;
653 if(scrollswitch==0) qq = 0;
654 else qq = ((player[playnum].q)*(player[playnum].speed));
657 switch (player[playnum].d)
661 dire*=player[playnum].d;
666 dire*=(player[playnum].d-2);
673 dire*=(player[playnum].d-2);
678 dire*=(player[playnum].d+2);
685 #define FRAME1 modexDrawPBufRegion(pip[1].page, x, y, 48, dire, 24, 32, &player[playnum].data, 1);
686 #define FRAME2 modexDrawPBufRegion(pip[1].page, x, y, 24, dire, 24, 32, &player[playnum].data, 1);
687 #define FRAME3 modexDrawPBufRegion(pip[1].page, x, y, 0, dire, 24, 32, &player[playnum].data, 1);
688 #define FRAME4 modexDrawPBufRegion(pip[1].page, x, y, 24, dire, 24, 32, &player[playnum].data, 1);
690 #define FRAME1 modexDrawSpriteRegion(pip[1].page, x, y, 48, dire, 24, 32, &player[playnum].data);
691 #define FRAME2 modexDrawSpriteRegion(pip[1].page, x, y, 24, dire, 24, 32, &player[playnum].data);
692 #define FRAME3 modexDrawSpriteRegion(pip[1].page, x, y, 0, dire, 24, 32, &player[playnum].data);
693 #define FRAME4 modexDrawSpriteRegion(pip[1].page, x, y, 24, dire, 24, 32, &player[playnum].data);
696 #define FRAME1 modexClearRegion(pip[1].page, x, y, 24, 32, 2+dire);
697 #define FRAME2 modexClearRegion(pip[1].page, x, y, 24, 32, 1+dire);
698 #define FRAME3 modexClearRegion(pip[1].page, x, y, 24, 32, dire);
699 #define FRAME4 modexClearRegion(pip[1].page, x, y, 24, 32, 1+dire);
701 modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 40);
702 //modexCopyPageRegion(pip[2].page, pip[1].page, 16, 16, 16, 16, (14*8)+4, 8+4);
703 if(2>ls && ls>=1) { FRAME1 }else
704 if(3>ls && ls>=2) { FRAME2 }else
705 if(4>ls && ls>=3) { FRAME3 }else
706 if(5>ls && ls>=4) { FRAME4 }
707 //TODO: mask copy //modexCopyPageRegion(dest->page, src->page, x-4, y-4, x-4, y-4, 28, 40);
708 //modexClearRegion(top->page, 66, 66, 2, 40, 0);
709 //modexCopyPageRegion(dest->page, top->page, 66, 66, 66, 66, 2, 40);