1 /* Project 16 Source Code~
2 * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123
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);
63 PBUFSFUN(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATA);
65 modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 14);
67 modexShowPage(pip[1].page);
70 player[pn].triggerx = player[pn].tx+1;
71 player[pn].triggery = player[pn].ty;
76 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 &&
77 !(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!
79 if(player[pn].q<=(TILEWH/(player[pn].speed)))
82 animatePlayer(pip, player, pn, 1);
83 mapScrollLeft(pip, player, 0, pn);
84 mapScrollLeft(pip, player, 1, pn);
85 modexShowPage(pip[1].page);
87 } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx--; }
89 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))
91 if(player[pn].q<=(TILEWH/(player[pn].speed)))
94 player[pn].x-=(player[pn].speed);
95 animatePlayer(pip, player, pn, 0);
96 modexShowPage(pip[1].page);
98 } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx--; }
102 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);
104 PBUFSFUN(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATA);
106 modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 10);
108 modexShowPage(pip[1].page);
111 player[pn].triggerx = player[pn].tx-1;
112 player[pn].triggery = player[pn].ty;
117 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 &&
118 !(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!
120 if(player[pn].q<=(TILEWH/(player[pn].speed)))
123 animatePlayer(pip, player, pn, 1);
124 mapScrollDown(pip, player, 0, pn);
125 mapScrollDown(pip, player, 1, pn);
126 modexShowPage(pip[1].page);
128 } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty++; }
130 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))
132 if(player[pn].q<=(TILEWH/(player[pn].speed)))
135 player[pn].y+=(player[pn].speed);
136 animatePlayer(pip, player, pn, 0);
137 modexShowPage(pip[1].page);
139 } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty++; }
143 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);
145 PBUFSFUN(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATA);
147 modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 9);
149 modexShowPage(pip[1].page);
152 player[pn].triggerx = player[pn].tx;
153 player[pn].triggery = player[pn].ty+1;
158 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 &&
159 !(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!
161 if(player[pn].q<=(TILEWH/(player[pn].speed)))
164 animatePlayer(pip, player, pn, 1);
165 mapScrollUp(pip, player, 0, pn);
166 mapScrollUp(pip, player, 1, pn);
167 modexShowPage(pip[1].page);
169 } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty--; }
171 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))
173 if(player[pn].q<=(TILEWH/(player[pn].speed)))
176 player[pn].y-=(player[pn].speed);
177 animatePlayer(pip, player, 0, pn);
178 modexShowPage(pip[1].page);
180 } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty--; }
184 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);
186 PBUFSFUN(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATA);
188 modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 12);
190 modexShowPage(pip[1].page);
193 player[pn].triggerx = player[pn].tx;
194 player[pn].triggery = player[pn].ty-1;
200 allocMap(int w, int h) {
205 result.data = malloc(sizeof(byte) * w * h);
206 //result.data = (byte *)alloc_emem(((int)sizeof(byte) * w * h)/1024);
207 if(isEMS() || checkEMS())
210 //emmhandle = mallocEMS(coretotalEMS());//alloc_emem((int)sizeof(map))
211 mm.length=sizeof(result);
213 mm.sourceOff=ptr2long(&result);
216 ist = move_emem(&mm);
217 if(!ist){ dealloc_emem(emmhandle); exit(5); }
218 printf("%d\n", coretotalEMS());
225 initMap(map_t *map) {
226 // just a place holder to fill out an alternating pattern
230 //if(!isEMS() || !checkEMS())
231 // map->tiles = malloc(sizeof(tiles_t));
233 // map->tiles = (tiles_t *)alloc_emem(sizeof(tiles_t));
235 //create the tile set
236 //if(!isEMS() || !checkEMS())
237 // map->tiles->data = malloc(sizeof(bitmap_t));
239 // map->tiles->data = (bitmap_t *)alloc_emem(sizeof(bitmap_t));
240 // map->tiles->data->width = (TILEWH);
241 // map->tiles->data->height= TILEWH;
242 //if(!isEMS() || !checkEMS())
243 // map->tiles->data->data = malloc((TILEWH*2)*TILEWH);
245 // map->tiles->data->data = (byte *)alloc_emem((TILEWH*2)*TILEWH);
246 // map->tiles->tileHeight = TILEWH;
247 // map->tiles->tileWidth =TILEWH;
248 // map->tiles->rows = 1;
249 // map->tiles->cols = 1;//2;
252 //for(y=0; y<map->height; y++) {
253 //for(x=0; x<map->width; x++) {
255 for(yy=0; yy<TILEWH; yy++) {
256 for(xx=0; xx<(TILEWH); xx++) {
258 map->tiles->data->data[i+1] = map->data[q];//28;//0x24;
259 // printf("[%d]", map->tiles->data->data[i]);
261 //map->tiles->data->data[i] = map->data[q];//0;//0x34;
262 //printf("]%d[==[%d]", i, map->tiles->data->data[i]);
268 // printf("[%d]", map->data[q]);
275 for(y=0; y<map->height; y++) {
276 for(x=0; x<map->width; x++) {
278 printf("[%d]", map->data[i]);
279 //tile = tile ? 0 : 1;
282 //tile = tile ? 0 : 1;
286 void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
288 word x, y; /* coordinate for drawing */
290 /* increment the pixel position and update the page */
291 mv[id].page->dx += player[plid].speed;
293 /* check to see if this changes the tile */
294 if(mv[id].page->dx >= mv[id].dxThresh )
296 /* go forward one tile */
298 /* Snap the origin forward */
299 mv[id].page->data += 4;
300 mv[id].page->dx = mv[id].map->tiles->tileWidth;
303 /* draw the next column */
304 x= mv[0].page->sw + mv[id].map->tiles->tileWidth;
307 mapDrawCol(&mv[0], mv[0].tx + mv[0].page->tilesw, mv[0].ty-1, x, player, mv->page->dx);
309 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));
314 void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
316 word x, y; /* coordinate for drawing */
318 /* increment the pixel position and update the page */
319 mv[id].page->dx -= player[plid].speed;
321 /* check to see if this changes the tile */
322 if(mv[id].page->dx == 0)
324 /* go backward one tile */
327 /* Snap the origin backward */
328 mv[id].page->data -= 4;
329 mv[id].page->dx = mv[id].map->tiles->tileWidth;
332 /* draw the next column */
336 mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, mv->page->dx);
338 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));
343 void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
345 word x, y; /* coordinate for drawing */
347 /* increment the pixel position and update the page */
348 mv[id].page->dy -= player[plid].speed;
350 /* check to see if this changes the tile */
351 if(mv[id].page->dy == 0 )
353 /* go down one tile */
355 /* Snap the origin downward */
356 mv[id].page->data -= mv[id].page->width*4;
357 mv[id].page->dy = mv[id].map->tiles->tileHeight;
360 /* draw the next row */
364 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, mv->page->dy);
366 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);
370 void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)
372 word x, y; /* coordinate for drawing */
374 /* increment the pixel position and update the page */
375 mv[id].page->dy += player[plid].speed;
377 /* check to see if this changes the tile */
378 if(mv[id].page->dy >= mv[id].dyThresh )
380 /* go down one tile */
382 /* Snap the origin downward */
383 mv[id].page->data += mv[id].page->width*4;
384 mv[id].page->dy = mv[id].map->tiles->tileHeight;
387 /* draw the next row */
388 y= mv[0].page->sh + mv[id].map->tiles->tileHeight;
391 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+mv[0].page->tilesh, y, player, mv->page->dy);
393 modexC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1, 1, 1, 1, \
408 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
409 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 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, 1, 1, 1, 1, \
412 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
413 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
414 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
415 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
416 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 1, 2, 3, 4 };*/
417 //check for failed to load map
418 if((map->width == map->height == 0) && (q>0))
420 //initiate a null map!
421 map->width=MAPW;///2;
422 map->height=MAPH;///2;
423 // map->data = malloc(((map->width*map->height)+1)*sizeof(byte));
425 map->tiles = malloc(sizeof(tiles_t));
426 //fix this to be far~
427 // bp = bitmapLoadPcx("data/ed.pcx");
428 // map->tiles->data = &bp;
429 map->tiles->debug_data = map->data;
430 map->tiles->tileHeight = 16;
431 map->tiles->tileWidth = 16;
432 map->tiles->rows = 1;
433 map->tiles->cols = 1;
434 map->tiles->debug_text = true;
436 else map->tiles->debug_text = false;
440 void mapGoTo(map_view_t *mv, int tx, int ty)
445 /* set up the coordinates */
448 mv->page->dx = mv->map->tiles->tileWidth;
449 mv->page->dy = mv->map->tiles->tileHeight;
451 /* set up the thresholds */
452 mv->dxThresh = mv->map->tiles->tileWidth * 2;
453 mv->dyThresh = mv->map->tiles->tileHeight * 2;
456 modexClearRegion(mv->page, 0, 0, mv->page->width, mv->page->height, 0);
458 i=mv->ty * mv->map->width + mv->tx;
459 for(ty=mv->ty-1; py < mv->page->sh+mv->dyThresh && ty < mv->map->height; ty++, py+=mv->map->tiles->tileHeight) {
460 mapDrawWRow(mv, tx-1, ty, py);
461 i+=mv->map->width - tx;
467 mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y)
477 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 0); //currently the over scan color!
481 rx = (((i-1) % ((t->data->width)/t->tileWidth)) * t->tileWidth);
482 ry = (((i-1) / ((t->data->height)/t->tileHeight)) * t->tileHeight);
483 ////0000printf("i=%d\n", i);
484 switch(t->debug_text)
488 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, ((t->debug_data[i])+1));
489 //cannot print number value du to it being slow as bakapee
491 PBUFBFUN (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
492 /* then the sprite. note modding ram ptr means we just draw to (x&3,0) */
493 //draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));
494 //modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
498 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, (t->debug_data[i]+1));
499 //modexprintbig(page, x, y, 1, 15, 0, (t->debug_data));
500 /*for(texty=0; texty<2; texty++)
502 for(textx=0; textx<2; textx++)
504 // modexprint(page, x+(textx*8), y+(texty*8), 1, (word)(t->debug_data), 0, (t->debug_data));
512 void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *p, word poopoffset)
516 poopoffset%=p[0].speed;
517 //printf("y: %d\n", poopoffset);
518 /* the position within the map array */
519 i=ty * mv->map->width + tx;
520 for(x=poopoffset; x<(mv->page->sw+mv->dxThresh)/(poopoffset+1) && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
522 /* we are in the map, so copy! */
523 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
529 void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *p, word poopoffset)
533 poopoffset%=p[0].speed;
534 //printf("x: %d\n", poopoffset);
535 /* location in the map array */
536 i=ty * mv->map->width + tx;
538 /* We'll copy all of the columns in the screen,
539 i + 1 row above and one below */
540 for(y=poopoffset; y<(mv->page->sh+mv->dyThresh)/(poopoffset+1) && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
542 /* we are in the map, so copy away! */
543 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
549 void mapDrawWRow(map_view_t *mv, int tx, int ty, word y)
554 /* the position within the map array */
555 i=ty * mv->map->width + tx;
556 for(x=0; x<mv->page->sw+mv->dxThresh && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
558 /* we are in the map, so copy! */
559 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
565 void mapDrawWCol(map_view_t *mv, int tx, int ty, word x)
570 /* location in the map array */
571 i=ty * mv->map->width + tx;
573 /* We'll copy all of the columns in the screen,
574 i + 1 row above and one below */
575 for(y=0; y<mv->page->sh+mv->dyThresh && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
577 /* we are in the map, so copy away! */
578 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
590 void shinku(map_view_t *pip, global_game_variables_t *gv)
593 //modexCopyPageRegion(pip[1].page, pip[2].page, 16, 16, 16, 16, (14*8)+4, 8+4);
594 if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second))
601 //t=(((*(gv->clock))-gv->clock_start) /18.2);
602 sprintf(gv->pee, "%f fps", (double)gv->kurokku.tiku/ticktock(gv));
603 modexprint(pip[1].page, 16, 16, 1, 15, 0, gv->pee);
604 //(gv->clock_start)=*(gv->clock);
607 //modexprint(page, 16, 16, 1, 15, 0, pee);
609 switch(gv->kurokku.fpscap)
612 //modexprint(page, 16, 32, 1, 15, 0, "sanic!");
613 gv->kurokku.frames_per_second=1;
616 //turn this off if XT
618 vga_wait_for_vsync();
619 gv->kurokku.frames_per_second=60;
624 void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch)
626 sword x = player[pn].x;
627 sword y = player[pn].y;
629 word dire=32; //direction
631 word dire=8; //direction
633 sword qq; //scroll offset
634 word ls = player[pn].persist_aniframe;
636 if(scrollswitch==0) qq = 0;
637 else qq = ((player[pn].q)*(player[pn].speed));
640 switch (player[pn].d)
649 dire*=(player[pn].d-2);
656 dire*=(player[pn].d-2);
661 dire*=(player[pn].d+2);
667 // #define FRAME1 PBUFSFUN(pip[1].page, x, y, 48, dire, 24, 32, PLAYERBMPDATA);
668 // #define FRAME2 PBUFSFUN(pip[1].page, x, y, 24, dire, 24, 32, PLAYERBMPDATA);
669 // #define FRAME3 PBUFSFUN(pip[1].page, x, y, 0, dire, 24, 32, PLAYERBMPDATA);
670 // #define FRAME4 PBUFSFUN(pip[1].page, x, y, 24, dire, 24, 32, PLAYERBMPDATA);
671 #define FRAME1 PBUFSFUN(pip[1].page, x, y, 48, dire, 24, 32, PLAYERBMPDATA);
672 #define FRAME2 PBUFSFUN(pip[1].page, x, y, 24, dire, 24, 32, PLAYERBMPDATA);
673 #define FRAME3 PBUFSFUN(pip[1].page, x, y, 0, dire, 24, 32, PLAYERBMPDATA);
674 #define FRAME4 PBUFSFUN(pip[1].page, x, y, 24, dire, 24, 32, PLAYERBMPDATA);
676 #define FRAME1 modexClearRegion(pip[1].page, x, y, 24, 32, 2+dire);
677 #define FRAME2 modexClearRegion(pip[1].page, x, y, 24, 32, 1+dire);
678 #define FRAME3 modexClearRegion(pip[1].page, x, y, 24, 32, dire);
679 #define FRAME4 modexClearRegion(pip[1].page, x, y, 24, 32, 1+dire);
681 modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 40);
682 //modexCopyPageRegion(pip[2].page, pip[1].page, 16, 16, 16, 16, (14*8)+4, 8+4);
683 if(2>ls && ls>=1) { FRAME1 }else
684 if(3>ls && ls>=2) { FRAME2 }else
685 if(4>ls && ls>=3) { FRAME3 }else
686 if(5>ls && ls>=4) { FRAME4 }
687 //TODO: mask copy //modexCopyPageRegion(dest->page, src->page, x-4, y-4, x-4, y-4, 28, 40);
688 //modexClearRegion(top->page, 66, 66, 2, 40, 0);
689 //modexCopyPageRegion(dest->page, top->page, 66, 66, 66, 66, 2, 40);