1 include "src\lib\scroll.h"
3 bitmap_t ptmp; // player sprite
6 static int persist_aniframe = 0; /* gonna be increased to 1 before being used, so 0 is ok for default */
7 page_t screen, screen2, screen3;
9 map_view_t mv, mv2, mv3;
10 map_view_t *bg, *spri, *mask;//, *tmp;
14 map = allocMap(MAPX,MAPY); //20x15 is the resolution of the screen you can make maps smaller than 20x15 but the null space needs to be drawn properly
23 ptmp = bitmapLoadPcx("ptmp.pcx"); // load sprite
26 modexPalUpdate(ptmp.palette);
27 screen = modexDefaultPage();
28 screen.width += (TILEWH*2);
29 screen.height += (TILEWH*2)+QUADWH;
31 screen2 = modexNextPage(mv.page);
41 //TODO: LOAD map data and position the map in the middle of the screen if smaller then screen
44 //mapGoTo(mask, 0, 0);
46 //TODO: put player in starting position of spot
47 //default player position on the viewable map
48 player.tx = bg->tx + 10;
49 player.ty = bg->ty + 8;
50 player.x = player.tx*TILEWH;
51 player.y = player.ty*TILEWH;
52 player.triggerx = player.tx;
53 player.triggery = player.ty+1;
54 //TODO: erase player initial draw
55 modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 64, 24, 32, &ptmp);
56 //temp draw trigger box
57 modexClearRegion(spri->page, player.triggerx*16, player.triggery*16, 16, 16, 1);
58 modexClearRegion(bg->page, player.triggerx*16, player.triggery*16, 16, 16, 1);
59 modexShowPage(spri->page);
60 while(!keyp(1))//!keyp(1))
62 //top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square
63 //to stop scrolling and have the player position data move to the edge of the screen with respect to the direction
64 //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
66 #define INC_PER_FRAME if(q&1) persist_aniframe++; if(persist_aniframe>4) persist_aniframe = 1;
68 if(keyp(77) && !keyp(75))
70 if(bg->tx >= 0 && bg->tx+20 < MAPX && player.tx == bg->tx + 10 && !(player.tx+1 == TRIGGX && player.ty == TRIGGY))
72 for(q=1; q<=(TILEWH/SPEED); q++)
75 //animatePlayer(bg, spri, mask, 1, 1, player.x, player.y, persist_aniframe, q, &ptmp);
76 animatePlayer(bg, spri, 1, 1, player.x, player.y, persist_aniframe, q, &ptmp);
77 mapScrollRight(bg, SPEED, q);
78 mapScrollRight(spri, SPEED, q);
79 //mapScrollRight(mask, SPEED);
80 modexShowPage(spri->page);
84 else if(player.tx < MAPX && !(player.tx+1 == TRIGGX && player.ty == TRIGGY))
86 for(q=1; q<=(TILEWH/SPEED); q++)
90 //animatePlayer(bg, spri, mask, 1, 0, player.x, player.y, persist_aniframe, q, &ptmp);
91 animatePlayer(bg, spri, 1, 0, player.x, player.y, persist_aniframe, q, &ptmp);
92 modexShowPage(spri->page);
98 modexCopyPageRegion(spri->page, bg->page, player.x-4, player.y-TILEWH, player.x-4, player.y-TILEWH, 24, 32);
99 modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 32, 24, 32, &ptmp);
100 modexShowPage(spri->page);
102 player.triggerx = player.tx+1;
103 player.triggery = player.ty;
106 if(keyp(75) && !keyp(77))
108 if(bg->tx > 0 && bg->tx+20 <= MAPX && player.tx == bg->tx + 10 && !(player.tx-1 == TRIGGX && player.ty == TRIGGY))
110 for(q=1; q<=(TILEWH/SPEED); q++)
113 //animatePlayer(bg, spri, mask, 3, 1, player.x, player.y, persist_aniframe, q, &ptmp);
114 animatePlayer(bg, spri, 3, 1, player.x, player.y, persist_aniframe, q, &ptmp);
115 mapScrollLeft(bg, SPEED, q);
116 mapScrollLeft(spri, SPEED, q);
117 //mapScrollLeft(mask, SPEED);
118 modexShowPage(spri->page);
122 else if(player.tx > 1 && !(player.tx-1 == TRIGGX && player.ty == TRIGGY))
124 for(q=1; q<=(TILEWH/SPEED); q++)
128 //animatePlayer(bg, spri, mask, 3, 0, player.x, player.y, persist_aniframe, q, &ptmp);
129 animatePlayer(bg, spri, 3, 0, player.x, player.y, persist_aniframe, q, &ptmp);
130 modexShowPage(spri->page);
136 modexCopyPageRegion(spri->page, bg->page, player.x-4, player.y-TILEWH, player.x-4, player.y-TILEWH, 24, 32);
137 modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 96, 24, 32, &ptmp);
138 modexShowPage(spri->page);
140 player.triggerx = player.tx-1;
141 player.triggery = player.ty;
144 if(keyp(80) && !keyp(72))
146 if(bg->ty >= 0 && bg->ty+15 < MAPY && player.ty == bg->ty + 8 && !(player.tx == TRIGGX && player.ty+1 == TRIGGY))
148 for(q=1; q<=(TILEWH/SPEED); q++)
151 //animatePlayer(bg, spri, mask, 2, 1, player.x, player.y, persist_aniframe, q, &ptmp);
152 animatePlayer(bg, spri, 2, 1, player.x, player.y, persist_aniframe, q, &ptmp);
153 mapScrollDown(bg, SPEED, q);
154 mapScrollDown(spri, SPEED, q);
155 //mapScrollDown(mask, SPEED);
156 modexShowPage(spri->page);
160 else if(player.ty < MAPY && !(player.tx == TRIGGX && player.ty+1 == TRIGGY))
162 for(q=1; q<=(TILEWH/SPEED); q++)
166 //animatePlayer(bg, spri, mask, 2, 0, player.x, player.y, persist_aniframe, q, &ptmp);
167 animatePlayer(bg, spri, 2, 0, player.x, player.y, persist_aniframe, q, &ptmp);
168 modexShowPage(spri->page);
174 modexCopyPageRegion(spri->page, bg->page, player.x-4, player.y-TILEWH, player.x-4, player.y-TILEWH, 24, 32);
175 modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 64, 24, 32, &ptmp);
176 modexShowPage(spri->page);
178 player.triggerx = player.tx;
179 player.triggery = player.ty+1;
182 if(keyp(72) && !keyp(80))
184 if(bg->ty > 0 && bg->ty+15 <= MAPY && player.ty == bg->ty + 8 && !(player.tx == TRIGGX && player.ty-1 == TRIGGY))
186 for(q=1; q<=(TILEWH/SPEED); q++)
189 //animatePlayer(bg, spri, mask, 0, 1, player.x, player.y, persist_aniframe, q, &ptmp);
190 animatePlayer(bg, spri, 0, 1, player.x, player.y, persist_aniframe, q, &ptmp);
191 mapScrollUp(bg, SPEED, q);
192 mapScrollUp(spri, SPEED, q);
193 //mapScrollUp(mask, SPEED);
194 modexShowPage(spri->page);
198 else if(player.ty > 1 && !(player.tx == TRIGGX && player.ty-1 == TRIGGY))
200 for(q=1; q<=(TILEWH/SPEED); q++)
204 //animatePlayer(bg, spri, mask, 0, 0, player.x, player.y, persist_aniframe, q, &ptmp);
205 modexShowPage(spri->page);
206 animatePlayer(bg, spri, 0, 0, player.x, player.y, persist_aniframe, q, &ptmp);
212 modexCopyPageRegion(spri->page, bg->page, player.x-4, player.y-TILEWH, player.x-4, player.y-TILEWH, 24, 32);
213 modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 0, 24, 32, &ptmp);
214 modexShowPage(spri->page);
216 player.triggerx = player.tx;
217 player.triggery = player.ty-1;
219 //modexClearRegion(mask->page, 66, 66, 2, 40, 0);
221 if((player.triggerx == TRIGGX && player.triggery == TRIGGY) && keyp(KEY_ENTER))
224 for(i=600; i>=400; i--)
234 printf("Project 16 scroll.exe\n");
235 printf("tx: %d\n", bg->tx);
236 printf("ty: %d\n", bg->ty);
237 printf("player.x: %d\n", player.x);
238 printf("player.y: %d\n", player.y);
239 printf("player.tx: %d\n", player.tx);
240 printf("player.ty: %d\n", player.ty);
241 printf("player.triggx: %d\n", player.triggerx);
242 printf("player.triggy: %d\n", player.triggery);
243 printf("temporary player sprite 0: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=45556867\n");
244 printf("temporary player sprite 1: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=44606385\n");
248 case 0: cpus = "8086/8088 or 186/88"; break;
249 case 1: cpus = "286"; break;
250 case 2: cpus = "386 or newer"; break;
251 default: cpus = "internal error"; break;
253 printf("detected CPU type: %s\n", cpus);