1 #include "src\lib\dos_kb.h"
2 #include "src\lib\mapread.c"
\r
3 //#include "16\lib\x\modex.h"
\r
4 #include "src\lib\wtest\wtest.c"
\r
5 #include "src\lib\planar.c"
6 //====#include "src\lib\ems.c"
\r
8 //word far *clock= (word far*) 0x046C; /* 18.2hz clock */
\r
30 int tx; //appears to be the top left tile position on the viewable screen map
\r
31 int ty; //appears to be the top left tile position on the viewable screen map
\r
32 word dxThresh; //????
\r
33 word dyThresh; //????
\r
37 int x; //player exact position on the viewable map
\r
38 int y; //player exact position on the viewable map
\r
39 int tx; //player tile position on the viewable map
\r
40 int ty; //player tile position on the viewable map
\r
41 int triggerx; //player's trigger box tile position on the viewable map
\r
42 int triggery; //player's trigger box tile position on the viewable map
\r
43 int setx; //NOT USED YET! player sprite sheet set on the image x
\r
44 int sety; //NOT USED YET! player sprite sheet set on the image y
\r
45 word q; //loop variable
\r
47 bitmap_t data; //supposively the sprite sheet data
\r
48 int hp; //hitpoints of the player
\r
51 map_t allocMap(int w, int h);
\r
52 void initMap(map_t *map);
\r
53 void mapScrollRight(map_view_t *mv, byte offset);
\r
54 void mapScrollLeft(map_view_t *mv, byte offest);
\r
55 void mapScrollUp(map_view_t *mv, byte offset);
\r
56 void mapScrollDown(map_view_t *mv, byte offset);
\r
57 void mapGoTo(map_view_t *mv, int tx, int ty);
\r
58 void mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y);
\r
59 void mapDrawRow(map_view_t *mv, int tx, int ty, word y);
\r
60 void mapDrawCol(map_view_t *mv, int tx, int ty, word x);
\r
62 void animatePlayer(map_view_t *src, map_view_t *dest, /*map_view_t *top, */sword d, short scrolloffsetswitch, int x, int y, int ls, int lp, bitmap_t *bmp);
\r
65 #define QUADWH (TILEWH/4)
\r
67 //#define LOOPMAX (TILEWH/SPEED)
\r
69 //place holder definitions
\r
80 bitmap_t ptmp;//, npctmp; // player sprite
\r
83 static int persist_aniframe = 0; /* gonna be increased to 1 before being used, so 0 is ok for default */
\r
84 page_t screen, screen2, screen3;
\r
86 map_view_t mv, mv2, mv3;
\r
87 map_view_t *bg, *spri, *mask;//, *tmp;
\r
93 // atexit(qclean());
\r
96 printf("Expanded memory is not present\n");
\r
102 printf("Expanded memory manager is not present\n");
\r
106 emsavail = emmavail();
\r
109 printf("Expanded memory manager error\n");
\r
112 printf("There are %ld pages available\n",emsavail);
\r
114 if((emmhandle = emmalloc(emsavail)) < 0)
\r
116 printf("Insufficient pages available\n");
\r
121 loadmap("data/test.map", &map/*, 0*/);
122 // map = allocMap(map.width,map.height); //20x15 is the resolution of the screen you can make maps smaller than 20x15 but the null space needs to be drawn properly
123 //if(isEMS()) printf("%d tesuto\n", coretotalEMS());
\r
129 /* draw the tiles */
\r
132 ptmp = bitmapLoadPcx("data/ptmp.pcx"); // load sprite
\r
133 //npctmp = bitmapLoadPcx("ptmp1.pcx"); // load sprite
\r
134 /* create the planar buffer */
\r
135 p = planar_buf_from_bitmap(&ptmp);
\r
140 mm.length=sizeof(map);
\r
142 mm.sourceOff=(long)↦
\r
143 mm.destH=emmhandle;
\r
146 ist = move_emem(&mm);
\r
147 printf("%d\n", coretotalEMS());
\r
148 if(!ist){ dealloc_emem(emmhandle); exit(5); }
\r
149 //printf("%d\n", emmhandle);
\r
155 mm.length=emmhandle;
\r
157 mm.sourceOff=(long)&ptmp;
\r
158 mm.destH=emmhandle;
\r
161 ist = move_emem(&mm);
\r
162 printf("%d\n", coretotalEMS());
\r
163 if(!ist){ dealloc_emem(emmhandle); exit(5); }
\r
164 //printf("%d\n", emmhandle);
\r
167 /* save the palette */
\r
168 pal = modexNewPal();
\r
170 modexFadeOff(4, pal);
\r
176 modexPalUpdate(ptmp.palette);
\r
177 modexFadeOn(4, ptmp.palette);
\r
178 screen = modexDefaultPage();
\r
179 screen.width += (TILEWH*2);
\r
180 screen.height += (TILEWH*2)+QUADWH;
\r
182 screen2 = modexNextPage(mv.page);
\r
183 mv2.page = &screen2;
\r
185 mv3.page = &screen3;
\r
187 /* set up paging */
\r
192 //TODO: LOAD map data and position the map in the middle of the screen if smaller then screen
\r
194 mapGoTo(spri, 0, 0);
\r
195 //mapGoTo(mask, 0, 0);
\r
197 //TODO: put player in starting position of spot
\r
198 //default player position on the viewable map
\r
199 player.tx = bg->tx + 10;
\r
200 player.ty = bg->ty + 8;
\r
201 player.x = player.tx*TILEWH;
\r
202 player.y = player.ty*TILEWH;
\r
203 player.triggerx = player.tx;
\r
204 player.triggery = player.ty+1;
\r
209 /*npc0.tx = bg->tx + 1;
\r
210 npc0.ty = bg->ty + 1;
\r
211 npc0.x = npc0.tx*TILEWH;
\r
212 npc0.y = npc0.ty*TILEWH;
\r
213 npc0.triggerx = npc0.tx;
\r
214 npc0.triggery = npc0.ty+1;
\r
217 modexDrawSpriteRegion(spri->page, npc0.x-4, npc0.y-TILEWH, 24, 64, 24, 32, &npctmp);*/
\r
218 modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 64, 24, 32, &ptmp);
\r
220 modexClearRegion(spri->page, player.triggerx*16, player.triggery*16, 16, 16, 1);
\r
221 modexClearRegion(bg->page, player.triggerx*16, player.triggery*16, 16, 16, 1);
\r
223 modexClearRegion(spri->page, 5*16, 5*16, 16, 16, 255);
\r
224 modexClearRegion(bg->page, 5*16, 5*16, 16, 16, 255);
\r
226 modexShowPage(spri->page);
\r
227 while(!keyp(1) && player.hp>0)
\r
229 //top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square
\r
230 //to stop scrolling and have the player position data move to the edge of the screen with respect to the direction
\r
231 //when player.tx or player.ty == 0 or player.tx == 20 or player.ty == 15 then stop because that is edge of map and you do not want to walk of the map
\r
232 #define INC_PER_FRAME if(player.q&1) persist_aniframe++; if(persist_aniframe>4) persist_aniframe = 1;
\r
233 /*#define INC_PER_FRAME_NPC if(npc0.q&1) persist_aniframe++; if(persist_aniframe>4) persist_aniframe = 1;
\r
235 if(npc0.d == 0 && npc0.q == 1) npc0.d =rand()%8;
\r
242 if(npc0.tx < map.width && !(npc0.tx+1 == TRIGGX && npc0.ty == TRIGGY) && !(npc0.tx+1 == player.tx && npc0.ty == player.ty))
\r
244 if(npc0.q<=(TILEWH/SPEED))
\r
248 //animatePlayer(bg, spri, mask, 1, 0, npc0.x, npc0.y, persist_aniframe, q, &npctmp);
\r
249 animatePlayer(bg, spri, npc0.d-1, 0, npc0.x, npc0.y, persist_aniframe, npc0.q, &npctmp);
\r
250 modexShowPage(spri->page);
\r
252 } else { npc0.q = 1; npc0.d = 0; npc0.tx++; }
\r
256 modexCopyPageRegion(spri->page, bg->page, npc0.x-4, npc0.y-TILEWH, npc0.x-4, npc0.y-TILEWH, 24, 32);
\r
257 modexDrawSpriteRegion(spri->page, npc0.x-4, npc0.y-TILEWH, 24, 32, 24, 32, &npctmp);
\r
258 modexShowPage(spri->page);
\r
261 npc0.triggerx = npc0.tx+1;
\r
262 npc0.triggery = npc0.ty;
\r
268 if(npc0.tx > 1 && !(npc0.tx-1 == TRIGGX && npc0.ty == TRIGGY) && !(npc0.tx-1 == player.tx && npc0.ty == player.ty))
\r
270 if(npc0.q<=(TILEWH/SPEED))
\r
274 //animatePlayer(bg, spri, mask, 3, 0, npc0.x, npc0.y, persist_aniframe, q, &npctmp);
\r
275 animatePlayer(bg, spri, npc0.d-1, 0, npc0.x, npc0.y, persist_aniframe, npc0.q, &npctmp);
\r
276 modexShowPage(spri->page);
\r
278 } else { npc0.q = 1; npc0.d = 0; npc0.tx--; }
\r
282 modexCopyPageRegion(spri->page, bg->page, npc0.x-4, npc0.y-TILEWH, npc0.x-4, npc0.y-TILEWH, 24, 32);
\r
283 modexDrawSpriteRegion(spri->page, npc0.x-4, npc0.y-TILEWH, 24, 96, 24, 32, &npctmp);
\r
284 modexShowPage(spri->page);
\r
287 npc0.triggerx = npc0.tx-1;
\r
288 npc0.triggery = npc0.ty;
\r
294 if(npc0.ty < map.height && !(npc0.tx == TRIGGX && npc0.ty+1 == TRIGGY) && !(npc0.tx == player.tx && npc0.ty == player.ty+1))
\r
296 if(npc0.q<=(TILEWH/SPEED))
\r
300 //animatePlayer(bg, spri, mask, 2, 0, npc0.x, npc0.y, persist_aniframe, q, &npctmp);
\r
301 animatePlayer(bg, spri, npc0.d-1, 0, npc0.x, npc0.y, persist_aniframe, npc0.q, &npctmp);
\r
302 modexShowPage(spri->page);
\r
304 } else { npc0.q = 1; npc0.d = 0; npc0.ty++; }
\r
308 modexCopyPageRegion(spri->page, bg->page, npc0.x-4, npc0.y-TILEWH, npc0.x-4, npc0.y-TILEWH, 24, 32);
\r
309 modexDrawSpriteRegion(spri->page, npc0.x-4, npc0.y-TILEWH, 24, 64, 24, 32, &npctmp);
\r
310 modexShowPage(spri->page);
\r
313 npc0.triggerx = npc0.tx;
\r
314 npc0.triggery = npc0.ty+1;
\r
320 if(npc0.ty > 1 && !(npc0.tx == TRIGGX && npc0.ty-1 == TRIGGY) && !(npc0.tx+1 == player.tx && npc0.ty == player.ty-1))
\r
322 if(npc0.q<=(TILEWH/SPEED))
\r
326 //animatePlayer(bg, spri, mask, 0, 0, npc0.x, npc0.y, persist_aniframe, q, &npctmp);
\r
327 modexShowPage(spri->page);
\r
328 animatePlayer(bg, spri, npc0.d-1, 0, npc0.x, npc0.y, persist_aniframe, npc0.q, &npctmp);
\r
330 } else { npc0.q = 1; npc0.d = 0; npc0.ty--; }
\r
334 modexCopyPageRegion(spri->page, bg->page, npc0.x-4, npc0.y-TILEWH, npc0.x-4, npc0.y-TILEWH, 24, 32);
\r
335 modexDrawSpriteRegion(spri->page, npc0.x-4, npc0.y-TILEWH, 24, 0, 24, 32, &npctmp);
\r
336 modexShowPage(spri->page);
\r
339 npc0.triggerx = npc0.tx;
\r
340 npc0.triggery = npc0.ty-1;
\r
343 if((npc0.triggery == player.ty && npc0.triggerx == player.tx) || (npc0.ty == player.ty && npc0.tx == player.tx)){ player.hp--; }
\r
347 //TODO: make movement into a function!
\r
349 if((keyp(77) && !keyp(75) && player.d == 0) || player.d == 2)
\r
351 if(player.d == 0){ player.d = 2; }
\r
352 if(bg->tx >= 0 && bg->tx+20 < map.width && player.tx == bg->tx + 10 && !(player.tx+1 == TRIGGX && player.ty == TRIGGY))
\r
354 if(player.q<=(TILEWH/SPEED))
\r
357 //animatePlayer(bg, spri, mask, 1, 1, player.x, player.y, persist_aniframe, q, &ptmp);
\r
358 animatePlayer(bg, spri, player.d-1, 1, player.x, player.y, persist_aniframe, player.q, &ptmp);
\r
359 mapScrollRight(bg, SPEED);
\r
360 mapScrollRight(spri, SPEED);
\r
361 //mapScrollRight(mask, SPEED);
\r
362 modexShowPage(spri->page);
\r
364 } else { player.q = 1; player.d = 0; player.tx++; }
\r
366 else if(player.tx < map.width && !(player.tx+1 == TRIGGX && player.ty == TRIGGY))
\r
368 if(player.q<=(TILEWH/SPEED))
\r
372 //animatePlayer(bg, spri, mask, 1, 0, player.x, player.y, persist_aniframe, q, &ptmp);
\r
373 animatePlayer(bg, spri, player.d-1, 0, player.x, player.y, persist_aniframe, player.q, &ptmp);
\r
374 modexShowPage(spri->page);
\r
376 } else { player.q = 1; player.d = 0; player.tx++; }
\r
380 modexCopyPageRegion(spri->page, bg->page, player.x-4, player.y-TILEWH, player.x-4, player.y-TILEWH, 24, 32);
\r
381 modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 32, 24, 32, &ptmp);
\r
382 modexShowPage(spri->page);
\r
385 player.triggerx = player.tx+1;
\r
386 player.triggery = player.ty;
\r
390 if((keyp(75) && !keyp(77) && player.d == 0) || player.d == 4)
\r
392 if(player.d == 0){ player.d = 4; }
\r
393 if(bg->tx > 0 && bg->tx+20 <= map.width && player.tx == bg->tx + 10 && !(player.tx-1 == TRIGGX && player.ty == TRIGGY))
\r
395 if(player.q<=(TILEWH/SPEED))
\r
398 //animatePlayer(bg, spri, mask, 3, 1, player.x, player.y, persist_aniframe, q, &ptmp);
\r
399 animatePlayer(bg, spri, player.d-1, 1, player.x, player.y, persist_aniframe, player.q, &ptmp);
\r
400 mapScrollLeft(bg, SPEED);
\r
401 mapScrollLeft(spri, SPEED);
\r
402 //mapScrollLeft(mask, SPEED);
\r
403 modexShowPage(spri->page);
\r
405 } else { player.q = 1; player.d = 0; player.tx--; }
\r
407 else if(player.tx > 1 && !(player.tx-1 == TRIGGX && player.ty == TRIGGY))
\r
409 if(player.q<=(TILEWH/SPEED))
\r
413 //animatePlayer(bg, spri, mask, 3, 0, player.x, player.y, persist_aniframe, q, &ptmp);
\r
414 animatePlayer(bg, spri, player.d-1, 0, player.x, player.y, persist_aniframe, player.q, &ptmp);
\r
415 modexShowPage(spri->page);
\r
417 } else { player.q = 1; player.d = 0; player.tx--; }
\r
421 modexCopyPageRegion(spri->page, bg->page, player.x-4, player.y-TILEWH, player.x-4, player.y-TILEWH, 24, 32);
\r
422 modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 96, 24, 32, &ptmp);
\r
423 modexShowPage(spri->page);
\r
426 player.triggerx = player.tx-1;
\r
427 player.triggery = player.ty;
\r
431 if((keyp(80) && !keyp(72) && player.d == 0) || player.d == 3)
\r
433 if(player.d == 0){ player.d = 3; }
\r
434 if(bg->ty >= 0 && bg->ty+15 < map.height && player.ty == bg->ty + 8 && !(player.tx == TRIGGX && player.ty+1 == TRIGGY))
\r
436 if(player.q<=(TILEWH/SPEED))
\r
439 //animatePlayer(bg, spri, mask, 2, 1, player.x, player.y, persist_aniframe, q, &ptmp);
\r
440 animatePlayer(bg, spri, player.d-1, 1, player.x, player.y, persist_aniframe, player.q, &ptmp);
\r
441 mapScrollDown(bg, SPEED);
\r
442 mapScrollDown(spri, SPEED);
\r
443 //mapScrollDown(mask, SPEED);
\r
444 modexShowPage(spri->page);
\r
446 } else { player.q = 1; player.d = 0; player.ty++; }
\r
448 else if(player.ty < map.height && !(player.tx == TRIGGX && player.ty+1 == TRIGGY))
\r
450 if(player.q<=(TILEWH/SPEED))
\r
454 //animatePlayer(bg, spri, mask, 2, 0, player.x, player.y, persist_aniframe, q, &ptmp);
\r
455 animatePlayer(bg, spri, player.d-1, 0, player.x, player.y, persist_aniframe, player.q, &ptmp);
\r
456 modexShowPage(spri->page);
\r
458 } else { player.q = 1; player.d = 0; player.ty++; }
\r
462 modexCopyPageRegion(spri->page, bg->page, player.x-4, player.y-TILEWH, player.x-4, player.y-TILEWH, 24, 32);
\r
463 modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 64, 24, 32, &ptmp);
\r
464 modexShowPage(spri->page);
\r
467 player.triggerx = player.tx;
\r
468 player.triggery = player.ty+1;
\r
472 if((keyp(72) && !keyp(80) && player.d == 0) || player.d == 1)
\r
474 if(player.d == 0){ player.d = 1; }
\r
475 if(bg->ty > 0 && bg->ty+15 <= map.height && player.ty == bg->ty + 8 && !(player.tx == TRIGGX && player.ty-1 == TRIGGY))
\r
477 if(player.q<=(TILEWH/SPEED))
\r
480 //animatePlayer(bg, spri, mask, 0, 1, player.x, player.y, persist_aniframe, q, &ptmp);
\r
481 animatePlayer(bg, spri, player.d-1, 1, player.x, player.y, persist_aniframe, player.q, &ptmp);
\r
482 mapScrollUp(bg, SPEED);
\r
483 mapScrollUp(spri, SPEED);
\r
484 //mapScrollUp(mask, SPEED);
\r
485 modexShowPage(spri->page);
\r
487 } else { player.q = 1; player.d = 0; player.ty--; }
\r
489 else if(player.ty > 1 && !(player.tx == TRIGGX && player.ty-1 == TRIGGY))
\r
491 if(player.q<=(TILEWH/SPEED))
\r
495 //animatePlayer(bg, spri, mask, 0, 0, player.x, player.y, persist_aniframe, q, &ptmp);
\r
496 modexShowPage(spri->page);
\r
497 animatePlayer(bg, spri, player.d-1, 0, player.x, player.y, persist_aniframe, player.q, &ptmp);
\r
499 } else { player.q = 1; player.d = 0; player.ty--; }
\r
503 modexCopyPageRegion(spri->page, bg->page, player.x-4, player.y-TILEWH, player.x-4, player.y-TILEWH, 24, 32);
\r
504 modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 0, 24, 32, &ptmp);
\r
505 modexShowPage(spri->page);
\r
508 player.triggerx = player.tx;
\r
509 player.triggery = player.ty-1;
\r
511 //modexClearRegion(mask->page, 66, 66, 2, 40, 0);
\r
513 if(((player.triggerx == TRIGGX && player.triggery == TRIGGY) && keyp(0x1C))||(player.tx == 5 && player.ty == 5))
\r
516 for(i=800; i>=400; i--)
\r
522 if(player.q == (TILEWH/SPEED)+1 && player.d > 0 && (player.triggerx == 5 && player.triggery == 5)){ player.hp--; }
\r
523 //if(keyp(0x0E)) while(1){ if(xmsmalloc(24)) break; }
536 /* fade back to text mode */
\r
537 modexFadeOff(4, ptmp.palette);
\r
541 //system("mem /E /P");
\r
542 printf("Project 16 scroll.exe\n");
\r
543 printf("tx: %d\n", bg->tx);
\r
544 printf("ty: %d\n", bg->ty);
\r
545 printf("player.x: %d", player.x);
\r
546 if(player.hp==0) printf("%d wwww\n", player.y+8);
\r
547 else printf("\nplayer.y: %d\n", player.y);
\r
548 printf("player.tx: %d\n", player.tx);
\r
549 printf("player.ty: %d\n", player.ty);
\r
550 printf("player.triggx: %d\n", player.triggerx);
\r
551 printf("player.triggy: %d\n", player.triggery);
\r
552 printf("player.hp: %d\n", player.hp);
\r
553 printf("player.q: %d\n", player.q);
\r
554 printf("player.d: %d\n", player.d);
555 printf("%d\n", map.data[0]);
\r
556 printf("temporary player sprite 0: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=45556867\n");
\r
557 printf("temporary player sprite 1: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=44606385\n");
\r
564 //emmclose(emmhandle);
\r
565 switch(detectcpu())
\r
567 case 0: cpus = "8086/8088 or 186/88"; break;
\r
568 case 1: cpus = "286"; break;
\r
569 case 2: cpus = "386 or newer"; break;
\r
570 default: cpus = "internal error"; break;
\r
572 printf("detected CPU type: %s\n", cpus);
\r
574 modexFadeOn(4, pal);
\r
579 allocMap(int w, int h) {
\r
584 result.data = malloc(sizeof(byte) * w * h);
\r
585 //result.data = (byte *)alloc_emem(((int)sizeof(byte) * w * h)/1024);
\r
586 /*if(isEMS() || checkEMS())
\r
589 //emmhandle = mallocEMS(coretotalEMS());//alloc_emem((int)sizeof(map))
\r
590 mm.length=sizeof(result);
\r
592 mm.sourceOff=ptr2long(&result);
\r
593 mm.destH=emmhandle;
\r
595 ist = move_emem(&mm);
\r
596 if(!ist){ dealloc_emem(emmhandle); exit(5); }
\r
597 printf("%d\n", coretotalEMS());
\r
604 initMap(map_t *map) {
\r
605 /* just a place holder to fill out an alternating pattern */
\r
609 //if(!isEMS() || !checkEMS())
\r
610 // map->tiles = malloc(sizeof(tiles_t));
\r
612 // map->tiles = (tiles_t *)alloc_emem(sizeof(tiles_t));
\r
614 /* create the tile set */
\r
615 //if(!isEMS() || !checkEMS())
\r
616 // map->tiles->data = malloc(sizeof(bitmap_t));
\r
618 // map->tiles->data = (bitmap_t *)alloc_emem(sizeof(bitmap_t));
\r
619 // map->tiles->data->width = (TILEWH/**2*/);
\r
620 // map->tiles->data->height= TILEWH;
\r
621 //if(!isEMS() || !checkEMS())
\r
622 // map->tiles->data->data = malloc((TILEWH*2)*TILEWH);
\r
624 // map->tiles->data->data = (byte *)alloc_emem((TILEWH*2)*TILEWH);
\r
625 // map->tiles->tileHeight = TILEWH;
\r
626 // map->tiles->tileWidth =TILEWH;
\r
627 // map->tiles->rows = 1;
\r
628 // map->tiles->cols = 1;//2;
\r
631 //for(y=0; y<map->height; y++) {
\r
632 //for(x=0; x<map->width; x++) {
634 for(yy=0; yy<TILEWH; yy++) {
\r
635 for(xx=0; xx<(TILEWH); xx++) {
\r
637 map->tiles->data->data[i+1] = map->data[q];//28;//0x24;
638 // printf("[%d]", map->tiles->data->data[i]);
\r
640 //map->tiles->data->data[i] = map->data[q];//0;//0x34;
641 //printf("]%d[==[%d]", i, map->tiles->data->data[i]);
647 // printf("[%d]", map->data[q]);
654 for(y=0; y<map->height; y++) {
\r
655 for(x=0; x<map->width; x++) {
656 // map->data[i]=255;
\r
657 printf("[%d]", map->data[i]);
\r
658 //tile = tile ? 0 : 1;
\r
661 //tile = tile ? 0 : 1;
\r
667 mapScrollRight(map_view_t *mv, byte offset) {
\r
668 word x, y; /* coordinate for drawing */
\r
670 /* increment the pixel position and update the page */
\r
671 mv->page->dx += offset;
\r
673 /* check to see if this changes the tile */
\r
674 if(mv->page->dx >= mv->dxThresh ) {
\r
675 /* go forward one tile */
\r
677 /* Snap the origin forward */
\r
678 mv->page->data += 4;
\r
679 mv->page->dx = mv->map->tiles->tileWidth;
\r
682 /* draw the next column */
\r
683 x= SCREEN_WIDTH + mv->map->tiles->tileWidth;
\r
684 mapDrawCol(mv, mv->tx + 20 , mv->ty-1, x);
\r
690 mapScrollLeft(map_view_t *mv, byte offset) {
\r
691 word x, y; /* coordinate for drawing */
\r
693 /* increment the pixel position and update the page */
\r
694 mv->page->dx -= offset;
\r
696 /* check to see if this changes the tile */
\r
697 if(mv->page->dx == 0) {
\r
698 /* go backward one tile */
\r
701 /* Snap the origin backward */
\r
702 mv->page->data -= 4;
\r
703 mv->page->dx = mv->map->tiles->tileWidth;
\r
705 /* draw the next column */
\r
706 mapDrawCol(mv, mv->tx-1, mv->ty-1, 0);
\r
712 mapScrollUp(map_view_t *mv, byte offset) {
\r
713 word x, y; /* coordinate for drawing */
\r
715 /* increment the pixel position and update the page */
\r
716 mv->page->dy -= offset;
\r
718 /* check to see if this changes the tile */
\r
719 if(mv->page->dy == 0 ) {
\r
720 /* go down one tile */
\r
722 /* Snap the origin downward */
\r
723 mv->page->data -= mv->page->width*4;
\r
724 mv->page->dy = mv->map->tiles->tileHeight;
\r
727 /* draw the next row */
\r
729 mapDrawRow(mv, mv->tx-1 , mv->ty-1, y);
\r
735 mapScrollDown(map_view_t *mv, byte offset) {
\r
736 word x, y; /* coordinate for drawing */
\r
738 /* increment the pixel position and update the page */
\r
739 mv->page->dy += offset;
\r
741 /* check to see if this changes the tile */
\r
742 if(mv->page->dy >= mv->dyThresh ) {
\r
743 /* go down one tile */
\r
745 /* Snap the origin downward */
\r
746 mv->page->data += mv->page->width*4;
\r
747 mv->page->dy = mv->map->tiles->tileHeight;
\r
750 /* draw the next row */
\r
751 y= SCREEN_HEIGHT + mv->map->tiles->tileHeight;
\r
752 mapDrawRow(mv, mv->tx-1 , mv->ty+15, y);
\r
759 mapGoTo(map_view_t *mv, int tx, int ty) {
\r
763 /* set up the coordinates */
\r
766 mv->page->dx = mv->map->tiles->tileWidth;
\r
767 mv->page->dy = mv->map->tiles->tileHeight;
\r
769 /* set up the thresholds */
\r
770 mv->dxThresh = mv->map->tiles->tileWidth * 2;
\r
771 mv->dyThresh = mv->map->tiles->tileHeight * 2;
\r
773 /* draw the tiles */
\r
774 modexClearRegion(mv->page, 0, 0, mv->page->width, mv->page->height, 0);
\r
776 i=mv->ty * mv->map->width + mv->tx;
\r
777 for(ty=mv->ty-1; py < SCREEN_HEIGHT+mv->dyThresh && ty < mv->map->height; ty++, py+=mv->map->tiles->tileHeight) {
\r
778 mapDrawRow(mv, tx-1, ty, py);
\r
779 i+=mv->map->width - tx;
\r
785 mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y) {
\r
788 rx = (i % t->cols) * t->tileWidth;
\r
789 ry = (i / t->cols) * t->tileHeight;
\r
790 //mxPutTile(t->data, x, y, t->tileWidth, t->tileHeight);
\r
791 modexDrawBmpRegion(page, x, y, rx, ry, t->tileWidth, t->tileHeight, t->data);
\r
796 mapDrawRow(map_view_t *mv, int tx, int ty, word y) {
\r
800 /* the position within the map array */
\r
801 i=ty * mv->map->width + tx;
\r
802 for(x=0; x<SCREEN_WIDTH+mv->dxThresh && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
\r
804 /* we are in the map, so copy! */
\r
805 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
812 mapDrawCol(map_view_t *mv, int tx, int ty, word x) {
\r
816 /* location in the map array */
\r
817 i=ty * mv->map->width + tx;
\r
819 /* We'll copy all of the columns in the screen,
\r
820 i + 1 row above and one below */
\r
821 for(y=0; y<SCREEN_HEIGHT+mv->dyThresh && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
\r
823 /* we are in the map, so copy away! */
\r
824 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
826 i += mv->map->width;
\r
837 animatePlayer(map_view_t *src, map_view_t *dest, /*map_view_t *top, */sword d, short scrolloffsetswitch, int x, int y, int ls, int lp, bitmap_t *bmp)
\r
839 sword dire=32*d; //direction
\r
840 sword qq; //scroll offset
\r
842 if(scrolloffsetswitch==0) qq = 0;
\r
843 else qq = ((lp)*SPEED);
\r
867 modexCopyPageRegion(dest->page, src->page, x-4, y-4, x-4, y-4, 28, 40);
\r
868 if(2>ls && ls>=1) { modexDrawSpriteRegion(dest->page, x, y, 48, dire, 24, 32, bmp); }else
\r
869 if(3>ls && ls>=2) { modexDrawSpriteRegion(dest->page, x, y, 24, dire, 24, 32, bmp); }else
\r
870 if(4>ls && ls>=3) { modexDrawSpriteRegion(dest->page, x, y, 0, dire, 24, 32, bmp); }else
\r
871 if(5>ls && ls>=4) { modexDrawSpriteRegion(dest->page, x, y, 24, dire, 24, 32, bmp); }
\r
872 //TODO: mask copy //modexCopyPageRegion(dest->page, src->page, x-4, y-4, x-4, y-4, 28, 40);
\r
873 //modexClearRegion(top->page, 66, 66, 2, 40, 0);
\r
874 //modexCopyPageRegion(dest->page, top->page, 66, 66, 66, 66, 2, 40);
\r
875 //turn this off if XT
\r
876 if(detectcpu() > 0) modexWaitBorder();
\r