]> 4ch.mooo.com Git - 16.git/blob - src/lib/scroll16.c
====scroll.exe coverted and bakapi.exe converted!! this is a major commit!
[16.git] / src / lib / scroll16.c
1 /* Project 16 Source Code~
2  * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
3  *
4  * This file is part of Project 16.
5  *
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.
10  *
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.
15  *
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.
20  *
21  */
22 /*
23         scroll16 library~
24 */
25 #include "src/lib/scroll16.h"
26
27 void walk(map_view_t *pip, player_t *player, word pn)
28 {
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;
30         //right movement
31         switch(player[pn].info.dir)
32         {
33                 case 3:
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!
36                         {
37                                 if(player[pn].q<=(TILEWH/(player[pn].speed)))
38                                 {
39                                         INC_PER_FRAME;
40                                         animatePlayer(pip, player, pn, 1);
41                                         mapScrollRight(pip, player, 0, pn);
42                                         mapScrollRight(pip, player, 1, pn);
43                                         modexShowPage(pip[1].page);
44                                         player[pn].q++;
45                                 } else { player[pn].q = 1; player[pn].info.dir = 0; player[pn].tx++; }
46                         }
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))
48                         {
49                                 if(player[pn].q<=(TILEWH/(player[pn].speed)))
50                                 {
51                                         INC_PER_FRAME;
52                                         player[pn].x+=(player[pn].speed);
53                                         animatePlayer(pip, player, pn, 0);
54                                         modexShowPage(pip[1].page);
55                                         player[pn].q++;
56                                 } else { player[pn].q = 1; player[pn].info.dir = 0; player[pn].tx++; }
57                         }
58                         else
59                         {
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);
61                                 modexDrawSpriteRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 24, 32, &player[pn].data);
62                                 modexShowPage(pip[1].page);
63                                 player[pn].info.dir = 0;
64                         }
65                         player[pn].triggerx = player[pn].tx+1;
66                         player[pn].triggery = player[pn].ty;
67                 break;
68
69                 //left movement
70                 case 1:
71                         if(pip[0].tx > 0 && pip[0].tx+20 <= pip[0].map->width && player[pn].tx == pip[0].tx + 10 &&
72                         !(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!
73                         {
74                                 if(player[pn].q<=(TILEWH/(player[pn].speed)))
75                                 {
76                                         INC_PER_FRAME;
77                                         animatePlayer(pip, player, pn, 1);
78                                         mapScrollLeft(pip, player, 0, pn);
79                                         mapScrollLeft(pip, player, 1, pn);
80                                         modexShowPage(pip[1].page);
81                                         player[pn].q++;
82                                 } else { player[pn].q = 1; player[pn].info.dir = 0; player[pn].tx--; }
83                         }
84                         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))
85                         {
86                                 if(player[pn].q<=(TILEWH/(player[pn].speed)))
87                                 {
88                                         INC_PER_FRAME;
89                                         player[pn].x-=(player[pn].speed);
90                                         animatePlayer(pip, player, pn, 0);
91                                         modexShowPage(pip[1].page);
92                                         player[pn].q++;
93                                 } else { player[pn].q = 1; player[pn].info.dir = 0; player[pn].tx--; }
94                         }
95                         else
96                         {
97                                 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);
98                                 modexDrawSpriteRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 96, 24, 32, &player[pn].data);
99                                 modexShowPage(pip[1].page);
100                                 player[pn].info.dir = 0;
101                         }
102                         player[pn].triggerx = player[pn].tx-1;
103                         player[pn].triggery = player[pn].ty;
104                 break;
105
106                 //down movement
107                 case 4:
108                         if(pip[0].ty >= 0 && pip[0].ty+15 < pip[0].map->height && player[pn].ty == pip[0].ty + 8 &&
109                         !(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!
110                         {
111                                 if(player[pn].q<=(TILEWH/(player[pn].speed)))
112                                 {
113                                         INC_PER_FRAME;
114                                         animatePlayer(pip, player, pn, 1);
115                                         mapScrollDown(pip, player, 0, pn);
116                                         mapScrollDown(pip, player, 1, pn);
117                                         modexShowPage(pip[1].page);
118                                         player[pn].q++;
119                                 } else { player[pn].q = 1; player[pn].info.dir = 0; player[pn].ty++; }
120                         }
121                         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))
122                         {
123                                 if(player[pn].q<=(TILEWH/(player[pn].speed)))
124                                 {
125                                         INC_PER_FRAME;
126                                         player[pn].y+=(player[pn].speed);
127                                         animatePlayer(pip, player, pn, 0);
128                                         modexShowPage(pip[1].page);
129                                         player[pn].q++;
130                                 } else { player[pn].q = 1; player[pn].info.dir = 0; player[pn].ty++; }
131                         }
132                         else
133                         {
134                                 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);
135                                 modexDrawSpriteRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 64, 24, 32, &player[pn].data);
136                                 modexShowPage(pip[1].page);
137                                 player[pn].info.dir = 0;
138                         }
139                         player[pn].triggerx = player[pn].tx;
140                         player[pn].triggery = player[pn].ty+1;
141                 break;
142
143                 //up movement
144                 case 0:
145                         if(pip[0].ty > 0 && pip[0].ty+15 <= pip[0].map->height && player[pn].ty == pip[0].ty + 8 &&
146                         !(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!
147                         {
148                                 if(player[pn].q<=(TILEWH/(player[pn].speed)))
149                                 {
150                                         INC_PER_FRAME;
151                                         animatePlayer(pip, player, pn, 1);
152                                         mapScrollUp(pip, player, 0, pn);
153                                         mapScrollUp(pip, player, 1, pn);
154                                         modexShowPage(pip[1].page);
155                                         player[pn].q++;
156                                 } else { player[pn].q = 1; player[pn].info.dir = 0; player[pn].ty--; }
157                         }
158                         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))
159                         {
160                                 if(player[pn].q<=(TILEWH/(player[pn].speed)))
161                                 {
162                                         INC_PER_FRAME;
163                                         player[pn].y-=(player[pn].speed);
164                                         animatePlayer(pip, player, 0, pn);
165                                         modexShowPage(pip[1].page);
166                                         player[pn].q++;
167                                 } else { player[pn].q = 1; player[pn].info.dir = 0; player[pn].ty--; }
168                         }
169                         else
170                         {
171                                 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);
172                                 modexDrawSpriteRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 0, 24, 32, &player[pn].data);
173                                 modexShowPage(pip[1].page);
174                                 player[pn].info.dir = 0;
175                         }
176                         player[pn].triggerx = player[pn].tx;
177                         player[pn].triggery = player[pn].ty-1;
178                 break;
179         }
180 }
181
182 /*map_t
183 allocMap(int w, int h) {
184         map_t result;
185
186         result.width =w;
187         result.height=h;
188         result.data = malloc(sizeof(byte) * w * h);
189         //result.data = (byte *)alloc_emem(((int)sizeof(byte) * w * h)/1024);
190         if(isEMS() || checkEMS())
191         {
192                 XMOVE mm;
193                 //emmhandle = mallocEMS(coretotalEMS());//alloc_emem((int)sizeof(map))
194                 mm.length=sizeof(result);
195                 mm.sourceH=0;
196                 mm.sourceOff=ptr2long(&result);
197                 mm.destH=emmhandle;
198                 mm.destOff=0;
199                 ist = move_emem(&mm);
200                 if(!ist){ dealloc_emem(emmhandle); exit(5); }
201                 printf("%d\n", coretotalEMS());
202         }
203
204         return result;
205 }*/
206
207 /*void
208 initMap(map_t *map) {
209         // just a place holder to fill out an alternating pattern
210         int x, y, xx, yy;
211         int i, q;
212 //      int tile = 1;
213         //if(!isEMS() || !checkEMS())
214 //              map->tiles = malloc(sizeof(tiles_t));
215         //else
216         //      map->tiles = (tiles_t *)alloc_emem(sizeof(tiles_t));
217
218          //create the tile set
219         //if(!isEMS() || !checkEMS())
220 //              map->tiles->data = malloc(sizeof(bitmap_t));
221         //else
222         //      map->tiles->data = (bitmap_t *)alloc_emem(sizeof(bitmap_t));
223 //      map->tiles->data->width = (TILEWH);
224 //      map->tiles->data->height= TILEWH;
225         //if(!isEMS() || !checkEMS())
226 //              map->tiles->data->data = malloc((TILEWH*2)*TILEWH);
227         //else
228         //      map->tiles->data->data = (byte *)alloc_emem((TILEWH*2)*TILEWH);
229 //      map->tiles->tileHeight = TILEWH;
230 //      map->tiles->tileWidth =TILEWH;
231 //      map->tiles->rows = 1;
232 //      map->tiles->cols = 1;//2;
233
234         q=0;
235         //for(y=0; y<map->height; y++) {
236         //for(x=0; x<map->width; x++) {
237         i=0;
238         for(yy=0; yy<TILEWH; yy++) {
239         for(xx=0; xx<(TILEWH); xx++) {
240                 //if(x<TILEWH){
241                   map->tiles->data->data[i+1] = map->data[q];//28;//0x24;
242 //                printf("[%d]", map->tiles->data->data[i]);
243                 //}else{
244                   //map->tiles->data->data[i] = map->data[q];//0;//0x34;
245                   //printf("]%d[==[%d]", i, map->tiles->data->data[i]);
246                 //}
247                 i++;
248         }
249 //      printf("\n");
250         }
251 //      printf("[%d]", map->data[q]);
252         q++;
253 //      }
254         //printf("\n\n");
255 //      }
256
257         i=0;
258         for(y=0; y<map->height; y++) {
259                 for(x=0; x<map->width; x++) {
260 //                      map->data[i]=255;
261                         printf("[%d]", map->data[i]);
262                         //tile = tile ? 0 : 1;
263                         i++;
264                 }
265                 //tile = tile ? 0 : 1;
266         }
267 }*/
268
269 void mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
270 {
271         word x, y;  /* coordinate for drawing */
272
273         /* increment the pixel position and update the page */
274         mv[id].page->dx += player[plid].speed;
275
276         /* check to see if this changes the tile */
277         if(mv[id].page->dx >= mv[id].dxThresh )
278         {
279         /* go forward one tile */
280         mv[id].tx++;
281         /* Snap the origin forward */
282         mv[id].page->data += 4;
283         mv[id].page->dx = mv[id].map->tiles->tileWidth;
284         }
285
286         /* draw the next column */
287         x= SCREEN_WIDTH + mv[id].map->tiles->tileWidth;
288         if(player[plid].q%4)
289                 if(id==0)
290                         mapDrawCol(&mv[0], mv[0].tx + 20 , mv[0].ty-1, x, player, mv->page->dx);
291                 else
292                         modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*17);
293         //}
294 }
295
296
297 void mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
298 {
299         word x, y;  /* coordinate for drawing */
300
301         /* increment the pixel position and update the page */
302         mv[id].page->dx -= player[plid].speed;
303
304         /* check to see if this changes the tile */
305         if(mv[id].page->dx == 0)
306         {
307         /* go backward one tile */
308         mv[id].tx--;
309
310         /* Snap the origin backward */
311         mv[id].page->data -= 4;
312         mv[id].page->dx = mv[id].map->tiles->tileWidth;
313         }
314
315         /* draw the next column */
316         x= 0;
317         if(player[plid].q%4)
318                 if(id==0)
319                         mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, mv->page->dx);
320                 else
321                         modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*17);
322         //}
323 }
324
325
326 void mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
327 {
328         word x, y;  /* coordinate for drawing */
329
330         /* increment the pixel position and update the page */
331         mv[id].page->dy -= player[plid].speed;
332
333         /* check to see if this changes the tile */
334         if(mv[id].page->dy == 0 )
335         {
336         /* go down one tile */
337         mv[id].ty--;
338         /* Snap the origin downward */
339         mv[id].page->data -= mv[id].page->width*4;
340         mv[id].page->dy = mv[id].map->tiles->tileHeight;
341         }
342
343         /* draw the next row */
344         y= 0;
345         if(player[plid].q%3)
346                 if(id==0)
347                         mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, mv->page->dy);
348                 else
349                         modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*22, mv[id].map->tiles->tileHeight);
350         //}
351 }
352
353 void mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)
354 {
355         word x, y;  /* coordinate for drawing */
356
357         /* increment the pixel position and update the page */
358         mv[id].page->dy += player[plid].speed;
359
360         /* check to see if this changes the tile */
361         if(mv[id].page->dy >= mv[id].dyThresh )
362         {
363         /* go down one tile */
364         mv[id].ty++;
365         /* Snap the origin downward */
366         mv[id].page->data += mv[id].page->width*4;
367         mv[id].page->dy = mv[id].map->tiles->tileHeight;
368         }
369
370         /* draw the next row */
371         y= SCREEN_HEIGHT + mv[id].map->tiles->tileHeight;
372         if(player[plid].q%3)
373                 if(id==0)
374                         mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+15, y, player, mv->page->dy);
375                 else
376                         modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*22, mv[id].map->tiles->tileHeight);
377         //}
378 }
379
380
381 void mapGoTo(map_view_t *mv, int tx, int ty)
382 {
383         int px, py;
384         unsigned int i;
385
386         /* set up the coordinates */
387         mv->tx = tx;
388         mv->ty = ty;
389         mv->page->dx = mv->map->tiles->tileWidth;
390         mv->page->dy = mv->map->tiles->tileHeight;
391
392         /* set up the thresholds */
393         mv->dxThresh = mv->map->tiles->tileWidth * 2;
394         mv->dyThresh = mv->map->tiles->tileHeight * 2;
395
396         /* draw the tiles */
397         modexClearRegion(mv->page, 0, 0, mv->page->width, mv->page->height, 0);
398         py=0;
399         i=mv->ty * mv->map->width + mv->tx;
400         for(ty=mv->ty-1; py < SCREEN_HEIGHT+mv->dyThresh && ty < mv->map->height; ty++, py+=mv->map->tiles->tileHeight) {
401                 mapDrawWRow(mv, tx-1, ty, py);
402         i+=mv->map->width - tx;
403         }
404 }
405
406
407 void
408 mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y)
409 {
410         word rx;
411         word ry;
412         //if(i==0) i=2;
413         if(i==0)
414         {
415                 //wwww
416                 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 0); //currently the over scan color!
417         }
418         else
419         {
420         rx = (((i-1) % ((t->data->width)/t->tileWidth)) * t->tileWidth);
421         ry = (((i-1) / ((t->data->height)/t->tileHeight)) * t->tileHeight);
422 ////0000        printf("i=%d\n", i);
423         //mxPutTile(t->data, x, y, t->tileWidth, t->tileHeight);
424         modexDrawBmpRegion(page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
425         }
426 }
427
428 void mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *p, word poopoffset)
429 {
430         word x;
431         int i;
432         poopoffset%=p[0].speed;
433 //printf("y: %d\n", poopoffset);
434         /* the position within the map array */
435         i=ty * mv->map->width + tx;
436         for(x=poopoffset; x<(SCREEN_WIDTH+mv->dxThresh)/(poopoffset+1) && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
437         if(i>=0) {
438                 /* we are in the map, so copy! */
439                 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
440         }
441         i++; /* next! */
442         }
443 }
444
445 void mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *p, word poopoffset)
446 {
447         int y;
448         int i;
449         poopoffset%=p[0].speed;
450 //printf("x: %d\n", poopoffset);
451         /* location in the map array */
452         i=ty * mv->map->width + tx;
453
454         /* We'll copy all of the columns in the screen,
455            i + 1 row above and one below */
456         for(y=poopoffset; y<(SCREEN_HEIGHT+mv->dyThresh)/(poopoffset+1) && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
457         if(i>=0) {
458                 /* we are in the map, so copy away! */
459                 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
460         }
461         i += mv->map->width;
462         }
463 }
464
465 void mapDrawWRow(map_view_t *mv, int tx, int ty, word y)
466 {
467         word x;
468         int i;
469
470         /* the position within the map array */
471         i=ty * mv->map->width + tx;
472         for(x=0; x<SCREEN_WIDTH+mv->dxThresh && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
473         if(i>=0) {
474                 /* we are in the map, so copy! */
475                 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
476         }
477         i++; /* next! */
478         }
479 }
480
481 void mapDrawWCol(map_view_t *mv, int tx, int ty, word x)
482 {
483         int y;
484         int i;
485
486         /* location in the map array */
487         i=ty * mv->map->width + tx;
488
489         /* We'll copy all of the columns in the screen,
490            i + 1 row above and one below */
491         for(y=0; y<SCREEN_HEIGHT+mv->dyThresh && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
492         if(i>=0) {
493                 /* we are in the map, so copy away! */
494                 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
495         }
496         i += mv->map->width;
497         }
498 }
499
500 void qclean()
501 {
502         modexLeave();
503         //setkb(0);
504 }
505
506 void pdump(page_t *pee)
507 {
508         int mult=(QUADWH);
509         int palq=(mult)*TILEWH;
510         int palcol=0;
511         int palx, paly;
512         for(paly=0; paly<palq; paly+=mult){
513                 for(palx=0; palx<palq; palx+=mult){
514                                 modexClearRegion(pee, palx+TILEWH, paly+TILEWH, mult, mult, palcol);
515                         palcol++;
516                 }
517         }
518 }
519
520 void animatePlayer(map_view_t *pip, player_t *player, word playnum, sword scrollswitch)
521 {
522         sword dire=32; //direction
523         sword qq; //scroll offset
524         word ls = player[playnum].persist_aniframe;
525
526         if(scrollswitch==0) qq = 0;
527         else qq = ((player[playnum].persist_aniframe)*player[playnum].speed);
528         switch (player[playnum].info.dir)
529         {
530                 case 0:
531                         //up
532                         dire*=player[playnum].info.dir;
533                         player[playnum].x=player[playnum].x-4;
534                         player[playnum].y=player[playnum].y-qq-TILEWH;
535                 break;
536                 case 1:
537                         // right
538                         dire*=(player[playnum].info.dir-2);
539                         player[playnum].x=player[playnum].x+qq-4;
540                         player[playnum].y=player[playnum].y-TILEWH;
541                 break;
542                 case 2:
543                 break;
544                 case 3:
545                         //down
546                         dire*=(player[playnum].info.dir-2);
547                         player[playnum].x=player[playnum].x-4;
548                         player[playnum].y=player[playnum].y+qq-TILEWH;
549                 break;
550                 case 4:
551                         //left
552                         dire*=(player[playnum].info.dir+2);
553                         player[playnum].x=player[playnum].x-qq-4;
554                         player[playnum].y=player[playnum].y-TILEWH;
555                 break;
556         }
557         modexCopyPageRegion(pip[1].page, pip[0].page, player[playnum].x-4, player[playnum].y-4, player[playnum].x-4, player[playnum].y-4, 28, 40);
558         if(2>ls && ls>=1) { modexDrawSpriteRegion(pip[1].page, player[playnum].x, player[playnum].y, 48, dire, 24, 32, &player[playnum].data); }else
559         if(3>ls && ls>=2) { modexDrawSpriteRegion(pip[1].page, player[playnum].x, player[playnum].y, 24, dire, 24, 32, &player[playnum].data); }else
560         if(4>ls && ls>=3) { modexDrawSpriteRegion(pip[1].page, player[playnum].x, player[playnum].y, 0, dire, 24, 32, &player[playnum].data); }else
561         if(5>ls && ls>=4) { modexDrawSpriteRegion(pip[1].page, player[playnum].x, player[playnum].y, 24, dire, 24, 32, &player[playnum].data); }
562         //TODO: mask copy //modexCopyPageRegion(dest->page, src->page, x-4, y-4, x-4, y-4, 28, 40);
563         //modexClearRegion(top->page, 66, 66, 2, 40, 0);
564         //modexCopyPageRegion(dest->page, top->page, 66, 66, 66, 66, 2, 40);
565         //turn this off if XT
566         //XTif(detectcpu() > 0)
567         modexWaitBorder();
568 }