1 /* Project 16 Source Code~
\r
2 * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
\r
4 * This file is part of Project 16.
\r
6 * Project 16 is free software; you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation; either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * Project 16 is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with this program. If not, see <http://www.gnu.org/licenses/>, or
\r
18 * write to the Free Software Foundation, Inc., 51 Franklin Street,
\r
19 * Fifth Floor, Boston, MA 02110-1301 USA.
\r
25 #include "src/lib/scroll16.h"
\r
27 #define ANIMATESPRIFUN ZC_animatePlayer
\r
29 #define INC_PER_FRAME if(player[pn].enti.q&1) player[pn].enti.persist_aniframe++; if(player[pn].enti.persist_aniframe>4) player[pn].enti.persist_aniframe = 1;
\r
31 void ZC_walk(map_view_t *pip, player_t *player, word pn)
\r
33 switch(player[pn].enti.d)
\r
37 //0000pip[0].video->startclk = (*clockw);
\r
41 if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->tw < pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->tilemidposscreenx &&
\r
42 !(pip[0].map->data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection!
\r
44 if(player[pn].enti.q<=player[pn].enti.spt)
\r
47 ANIMATESPRIFUN(pip, player, pn, 1);
\r
48 ScrollRight(pip, player, 3, pn);
\r
49 ScrollRight(pip, player, 2, pn);
\r
50 mapScrollRight(pip, player, (pip[0].video->p), pn);
\r
51 player[pn].enti.q++;
\r
52 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
53 sprintf(global_temp_status_text, "%u", player[pn].enti.persist_aniframe);
\r
54 modexprint(&(pip[0].video->page[0]), player[pn].enti.x+(8*player[pn].enti.persist_aniframe), player[pn].enti.y-TILEWH-8, 1, 8, 1, global_temp_status_text);
\r
56 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
58 else if(player[pn].enti.tx < pip[0].map->width && !(pip[0].map->data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY))
\r
60 if(player[pn].enti.q<=player[pn].enti.spt)
\r
63 player[pn].enti.x+=(player[pn].enti.speed);
\r
64 ANIMATESPRIFUN(pip, player, pn, 0);
\r
65 player[pn].enti.q++;
\r
67 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
72 //modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATAPTR);
\r
73 ANIMATESPRIFUN(pip, player, pn, 0);
\r
75 // modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 14);
\r
77 player[pn].enti.d = 2;
\r
79 player[pn].enti.triggerx = player[pn].enti.tx+1;
\r
80 player[pn].enti.triggery = player[pn].enti.ty;
\r
84 if(pip[0].tx > 0 && pip[0].tx+pip[0].page->tw <= pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->tilemidposscreenx &&
\r
85 !(pip[0].map->data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection!
\r
87 if(player[pn].enti.q<=player[pn].enti.spt)
\r
90 ANIMATESPRIFUN(pip, player, pn, 1);
\r
91 ScrollLeft(pip, player, 3, pn);
\r
92 ScrollLeft(pip, player, 2, pn);
\r
93 mapScrollLeft(pip, player, (pip[0].video->p), pn);
\r
94 player[pn].enti.q++;
\r
95 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
96 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
98 else if(player[pn].enti.tx > 1 && !(pip[0].map->data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY))
\r
100 if(player[pn].enti.q<=player[pn].enti.spt)
\r
103 player[pn].enti.x-=(player[pn].enti.speed);
\r
104 ANIMATESPRIFUN(pip, player, pn, 0);
\r
105 player[pn].enti.q++;
\r
106 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
111 //modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATAPTR);
\r
112 ANIMATESPRIFUN(pip, player, pn, 0);
\r
114 // modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 10);
\r
116 player[pn].enti.d = 2;
\r
118 player[pn].enti.triggerx = player[pn].enti.tx-1;
\r
119 player[pn].enti.triggery = player[pn].enti.ty;
\r
123 if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->th < pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->tilemidposscreeny &&
\r
124 !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY)) //collision detection!
\r
126 if(player[pn].enti.q<=player[pn].enti.spt)
\r
129 ANIMATESPRIFUN(pip, player, pn, 1);
\r
130 ScrollDown(pip, player, 3, pn);
\r
131 ScrollDown(pip, player, 2, pn);
\r
132 mapScrollDown(pip, player, (pip[0].video->p), pn);
\r
133 player[pn].enti.q++;
\r
134 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
135 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
137 else if(player[pn].enti.ty < pip[0].map->height && !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY))
\r
139 if(player[pn].enti.q<=player[pn].enti.spt)
\r
142 player[pn].enti.y+=(player[pn].enti.speed);
\r
143 ANIMATESPRIFUN(pip, player, pn, 0);
\r
144 player[pn].enti.q++;
\r
145 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
150 //modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATAPTR);
\r
151 ANIMATESPRIFUN(pip, player, pn, 0);
\r
153 // modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 9);
\r
155 player[pn].enti.d = 2;
\r
157 player[pn].enti.triggerx = player[pn].enti.tx;
\r
158 player[pn].enti.triggery = player[pn].enti.ty+1;
\r
162 if(pip[0].ty > 0 && pip[0].ty+pip[0].page->th <= pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->tilemidposscreeny &&
\r
163 !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY)) //collision detection!
\r
165 if(player[pn].enti.q<=player[pn].enti.spt)
\r
168 ANIMATESPRIFUN(pip, player, pn, 1);
\r
169 ScrollUp(pip, player, 3, pn);
\r
170 ScrollUp(pip, player, 2, pn);
\r
171 mapScrollUp(pip, player, (pip[0].video->p), pn);
\r
172 player[pn].enti.q++;
\r
173 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
174 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
176 else if(player[pn].enti.ty > 1 && !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY))
\r
178 if(player[pn].enti.q<=player[pn].enti.spt)
\r
181 player[pn].enti.y-=(player[pn].enti.speed);
\r
182 ANIMATESPRIFUN(pip, player, 0, pn);
\r
183 player[pn].enti.q++;
\r
184 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
189 //modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATAPTR);
\r
190 ANIMATESPRIFUN(pip, player, pn, 0);
\r
192 // modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 12);
\r
194 player[pn].enti.d = 2;
\r
196 player[pn].enti.triggerx = player[pn].enti.tx;
\r
197 player[pn].enti.triggery = player[pn].enti.ty-1;
\r
204 src/lib/scroll16.c: mv[0].video->r=1;
\r
205 src/lib/scroll16.c: mv[0].video->r=1;
\r
206 src/lib/scroll16.c: mv[0].video->r=1;
\r
207 src/lib/scroll16.c: mv[0].video->r=1;
\r
208 src/lib/scroll16.c: pip->video->r=1;
\r
209 src/lib/scroll16.c: mv->video->r=1;
\r
212 void oldwalk(map_view_t *pip, player_t *player, word pn)
\r
214 //printf("player[%d].d=%d\n", pn, player[pn].enti.d);
\r
215 switch(player[pn].enti.d)
\r
219 //0000pip[0].video->startclk = (*clockw);
\r
223 //printf("pip[0].page->tilesw=%d ", pip[0].page->tilesw); printf("pip[0].page->tw=%d\n", pip[0].page->tw);
\r
224 if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->tw < pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->tilemidposscreenx &&
\r
225 !(pip[0].map->data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection!
\r
227 if(player[pn].enti.q<=player[pn].enti.spt)
\r
230 ANIMATESPRIFUN(pip, player, pn, 1);
\r
231 ScrollRight(pip, player, 3, pn);
\r
232 ScrollRight(pip, player, 2, pn);
\r
233 //mapScrollRight(pip, player, !(pip[0].video->p), pn);
\r
234 mapScrollRight(pip, player, (pip[0].video->p), pn);
\r
235 if(!pageflipflop) modexShowPage(pip[1].page);
\r
236 player[pn].enti.q++;
\r
237 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
238 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
240 else if(player[pn].enti.tx < pip[0].map->width && !(pip[0].map->data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY))
\r
242 if(player[pn].enti.q<=player[pn].enti.spt)
\r
245 player[pn].enti.x+=(player[pn].enti.speed);
\r
246 ANIMATESPRIFUN(pip, player, pn, 0);
\r
247 if(!pageflipflop) modexShowPage(pip[1].page);
\r
248 player[pn].enti.q++;
\r
249 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
253 if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32);
\r
255 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATAPTR);
\r
257 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 14);
\r
259 if(!pageflipflop) modexShowPage(pip[1].page);
\r
260 player[pn].enti.d = 2;
\r
262 player[pn].enti.triggerx = player[pn].enti.tx+1;
\r
263 player[pn].enti.triggery = player[pn].enti.ty;
\r
268 if(pip[0].tx > 0 && pip[0].tx+pip[0].page->tw <= pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->tilemidposscreenx &&
\r
269 !(pip[0].map->data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection!
\r
271 if(player[pn].enti.q<=player[pn].enti.spt)
\r
274 ANIMATESPRIFUN(pip, player, pn, 1);
\r
275 ScrollLeft(pip, player, 3, pn);
\r
276 ScrollLeft(pip, player, 2, pn);
\r
277 //mapScrollLeft(pip, player, !(pip[0].video->p), pn);
\r
278 mapScrollLeft(pip, player, (pip[0].video->p), pn);
\r
279 if(!pageflipflop) modexShowPage(pip[1].page);
\r
280 player[pn].enti.q++;
\r
281 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
282 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
284 else if(player[pn].enti.tx > 1 && !(pip[0].map->data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY))
\r
286 if(player[pn].enti.q<=player[pn].enti.spt)
\r
289 player[pn].enti.x-=(player[pn].enti.speed);
\r
290 ANIMATESPRIFUN(pip, player, pn, 0);
\r
291 if(!pageflipflop) modexShowPage(pip[1].page);
\r
292 player[pn].enti.q++;
\r
293 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
297 if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32);
\r
299 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATAPTR);
\r
301 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 10);
\r
303 if(!pageflipflop) modexShowPage(pip[1].page);
\r
304 player[pn].enti.d = 2;
\r
306 player[pn].enti.triggerx = player[pn].enti.tx-1;
\r
307 player[pn].enti.triggery = player[pn].enti.ty;
\r
312 if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->th < pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->tilemidposscreeny &&
\r
313 !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY)) //collision detection!
\r
315 if(player[pn].enti.q<=player[pn].enti.spt)
\r
318 ANIMATESPRIFUN(pip, player, pn, 1);
\r
319 ScrollDown(pip, player, 3, pn);
\r
320 ScrollDown(pip, player, 2, pn);
\r
321 //mapScrollDown(pip, player, !(pip[0].video->p), pn);
\r
322 mapScrollDown(pip, player, (pip[0].video->p), pn);
\r
323 if(!pageflipflop) modexShowPage(pip[1].page);
\r
324 player[pn].enti.q++;
\r
325 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
326 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
328 else if(player[pn].enti.ty < pip[0].map->height && !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY))
\r
330 if(player[pn].enti.q<=player[pn].enti.spt)
\r
333 player[pn].enti.y+=(player[pn].enti.speed);
\r
334 ANIMATESPRIFUN(pip, player, pn, 0);
\r
335 if(!pageflipflop) modexShowPage(pip[1].page);
\r
336 player[pn].enti.q++;
\r
337 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
341 if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32);
\r
343 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATAPTR);
\r
345 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 9);
\r
347 if(!pageflipflop) modexShowPage(pip[1].page);
\r
348 player[pn].enti.d = 2;
\r
350 player[pn].enti.triggerx = player[pn].enti.tx;
\r
351 player[pn].enti.triggery = player[pn].enti.ty+1;
\r
356 if(pip[0].ty > 0 && pip[0].ty+pip[0].page->th <= pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->tilemidposscreeny &&
\r
357 !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY)) //collision detection!
\r
359 if(player[pn].enti.q<=player[pn].enti.spt)
\r
362 ANIMATESPRIFUN(pip, player, pn, 1);
\r
363 ScrollUp(pip, player, 3, pn);
\r
364 ScrollUp(pip, player, 2, pn);
\r
365 //mapScrollUp(pip, player, !(pip[0].video->p), pn);
\r
366 mapScrollUp(pip, player, (pip[0].video->p), pn);
\r
367 if(!pageflipflop) modexShowPage(pip[1].page);
\r
368 player[pn].enti.q++;
\r
369 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
370 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
372 else if(player[pn].enti.ty > 1 && !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY))
\r
374 if(player[pn].enti.q<=player[pn].enti.spt)
\r
377 player[pn].enti.y-=(player[pn].enti.speed);
\r
378 ANIMATESPRIFUN(pip, player, 0, pn);
\r
379 if(!pageflipflop) modexShowPage(pip[1].page);
\r
380 player[pn].enti.q++;
\r
381 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
385 if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32);
\r
387 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATAPTR);
\r
389 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 12);
\r
391 if(!pageflipflop) modexShowPage(pip[1].page);
\r
392 player[pn].enti.d = 2;
\r
394 player[pn].enti.triggerx = player[pn].enti.tx;
\r
395 player[pn].enti.triggery = player[pn].enti.ty-1;
\r
401 void ZC_panPageManual(map_view_t *pip, player_t *player, word pn)
\r
403 #define SHOWMVFUN_ ZC_ShowMV(pip, 0, 0);
\r
404 switch(player[pn].enti.d)
\r
408 if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->tw < pip[0].page->tilesw)
\r
410 if(player[pn].enti.q<=player[pn].enti.spt)
\r
412 pip[0].page->dx+=4;
\r
414 player[pn].enti.q++;
\r
415 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].tx++; }
\r
421 if(pip[0].tx > 0 && pip[0].tx+pip[0].page->tw <= pip[0].page->tilesw)
\r
423 if(player[pn].enti.q<=player[pn].enti.spt)
\r
425 pip[0].page->dx-=4;
\r
427 player[pn].enti.q++;
\r
428 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].tx--; }
\r
434 if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->th < pip[0].page->tilesh)
\r
436 if(player[pn].enti.q<=player[pn].enti.spt)
\r
438 pip[0].page->dy+=4;
\r
440 player[pn].enti.q++;
\r
441 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].ty++; }
\r
447 if(pip[0].ty > 0 && pip[0].ty+pip[0].page->th <= pip[0].page->tilesh)
\r
449 if(player[pn].enti.q<=player[pn].enti.spt)
\r
451 pip[0].page->dy-=4;
\r
453 player[pn].enti.q++;
\r
454 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].ty--; }
\r
463 void ZC_MVSetup(map_view_t *pip, map_t *map, global_game_variables_t *gv)
\r
468 pip[0].page = &gv->video.page[0];
\r
470 pip[0].video = &gv->video;
\r
471 pip[0].panp = &gv->video.panp;
\r
472 ZC_MVInit(pip, 1, 1);
\r
474 for(i=ZC_MVI;i<gv->video.num_of_pages;i++)
\r
476 pip[i].page = &gv->video.page[i];
\r
477 pip[i].map = pip[0].map;
\r
478 pip[i].video = pip[0].video;
\r
479 pip[i].panp = pip[0].panp;
\r
487 void ZC_MVInit(map_view_t *pip, int tx, int ty)
\r
491 //pip[0].tx = pip[1].tx = tx;
\r
492 //pip[0].ty = pip[1].ty = ty;
\r
495 void ZC_ShowMV(map_view_t *moo, boolean vsync, boolean sr)
\r
497 word high_address, low_address, offset;
\r
500 /* calculate offset */
\r
501 offset = (word) moo[moo[0].video->panp].page->data;
\r
502 offset += moo[0].page->dy * (moo[0].page->width >> 2 );
\r
503 offset += moo[0].page->dx >> 2;
\r
505 /* calculate crtcOffset according to virtual width */
\r
509 crtcOffset = moo[0].page->sw >> 3;
\r
513 crtcOffset = moo[0].page->width >> 3;
\r
517 high_address = HIGH_ADDRESS | (offset & 0xff00);
\r
518 low_address = LOW_ADDRESS | (offset << 8);
\r
520 /* wait for appropriate timing and then program CRTC */
\r
521 if(vsync) while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE));
\r
522 outpw(CRTC_INDEX, high_address);
\r
523 outpw(CRTC_INDEX, low_address);
\r
524 outp(CRTC_INDEX, 0x13);
\r
525 outp(CRTC_DATA, crtcOffset);
\r
527 /* wait for one retrace */
\r
528 if(vsync) while (!(inp(INPUT_STATUS_1) & VRETRACE));
\r
530 /* do PEL panning here */
\r
531 outp(AC_INDEX, 0x33);
\r
532 outp(AC_INDEX, (moo[0].page->dx & 0x03) << 1);
\r
536 allocMap(int w, int h) {
\r
541 result.data = malloc(sizeof(byte) * w * h);
\r
542 //result.data = (byte *)alloc_emem(((int)sizeof(byte) * w * h)/1024);
\r
543 if(isEMS() || checkEMS())
\r
546 //emmhandle = mallocEMS(coretotalEMS());//alloc_emem((int)sizeof(map))
\r
547 mm.length=sizeof(result);
\r
549 mm.sourceOff=ptr2long(&result);
\r
550 mm.destH=emmhandle;
\r
552 ist = move_emem(&mm);
\r
553 if(!ist){ dealloc_emem(emmhandle); exit(5); }
\r
554 printf("%d\n", coretotalEMS());
\r
561 initMap(map_t *map) {
\r
562 // just a place holder to fill out an alternating pattern
\r
566 //if(!isEMS() || !checkEMS())
\r
567 // map->tiles = malloc(sizeof(tiles_t));
\r
569 // map->tiles = (tiles_t *)alloc_emem(sizeof(tiles_t));
\r
571 //create the tile set
\r
572 //if(!isEMS() || !checkEMS())
\r
573 // map->tiles->data = malloc(sizeof(bitmap_t));
\r
575 // map->tiles->data = (bitmap_t *)alloc_emem(sizeof(bitmap_t));
\r
576 // map->tiles->data->width = (TILEWH);
\r
577 // map->tiles->data->height= TILEWH;
\r
578 //if(!isEMS() || !checkEMS())
\r
579 // map->tiles->data->data = malloc((TILEWH*2)*TILEWH);
\r
581 // map->tiles->data->data = (byte *)alloc_emem((TILEWH*2)*TILEWH);
\r
582 // map->tiles->tileHeight = TILEWH;
\r
583 // map->tiles->tileWidth =TILEWH;
\r
584 // map->tiles->rows = 1;
\r
585 // map->tiles->cols = 1;//2;
\r
588 //for(y=0; y<map->height; y++) {
\r
589 //for(x=0; x<map->width; x++) {
\r
591 for(yy=0; yy<TILEWH; yy++) {
\r
592 for(xx=0; xx<(TILEWH); xx++) {
\r
594 map->tiles->data->data[i+1] = map->data[q];//28;//0x24;
\r
595 // printf("[%d]", map->tiles->data->data[i]);
\r
597 //map->tiles->data->data[i] = map->data[q];//0;//0x34;
\r
598 //printf("]%d[==[%d]", i, map->tiles->data->data[i]);
\r
604 // printf("[%d]", map->data[q]);
\r
611 for(y=0; y<map->height; y++) {
\r
612 for(x=0; x<map->width; x++) {
\r
613 // map->data[i]=255;
\r
614 printf("[%d]", map->data[i]);
\r
615 //tile = tile ? 0 : 1;
\r
618 //tile = tile ? 0 : 1;
\r
622 void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
\r
624 word x;//, y; /* coordinate for drawing */
\r
626 /* increment the pixel position and update the page */
\r
627 mv[id].page[0].dx += player[plid].enti.speed;
\r
629 /* check to see if this changes the tile */
\r
630 if(mv[id].page[0].dx >= mv[id].dxThresh )
\r
632 /* go forward one tile */
\r
634 /* Snap the origin forward */
\r
635 mv[id].page->data += 4;
\r
637 mv[id].page[0].dx = mv[id].map->tiles->tileWidth;
\r
640 /* draw the next column */
\r
641 x= mv[0].page->sw + mv[id].map->tiles->tileWidth;
\r
642 if(player[plid].enti.q%4)
\r
644 mapDrawCol(&mv[0], mv[0].tx + mv[0].page->tw, mv[0].ty-1, x, player, mv->page[0].dx);
\r
646 if(!pageflipflop && !pageploop)
\r
647 modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->th+2));
\r
652 void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
\r
654 word x;//,y; /* coordinate for drawing */
\r
656 /* decrement the pixel position and update the page */
\r
657 mv[id].page[0].dx -= player[plid].enti.speed;
\r
659 /* check to see if this changes the tile */
\r
660 if(mv[id].page[0].dx == 0)
\r
662 /* go backward one tile */
\r
664 /* Snap the origin backward */
\r
665 mv[id].page->data -= 4;
\r
667 mv[id].page[0].dx = mv[id].map->tiles->tileWidth;
\r
670 /* draw the next column */
\r
672 if(player[plid].enti.q%4)
\r
674 mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, mv->page[0].dx);
\r
676 if(!pageflipflop && !pageploop)
\r
677 modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->th+2));
\r
682 void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
\r
684 word y;//x, /* coordinate for drawing */
\r
686 /* decrement the pixel position and update the page */
\r
687 mv[id].page[0].dy -= player[plid].enti.speed;
\r
689 /* check to see if this changes the tile */
\r
690 if(mv[id].page[0].dy == 0 )
\r
692 /* go down one tile */
\r
694 /* Snap the origin downward */
\r
695 mv[id].page->data -= mv[id].page->pi;
\r
697 mv[id].page[0].dy = mv[id].map->tiles->tileHeight;
\r
700 /* draw the next row */
\r
702 if(player[plid].enti.q%3)
\r
704 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, mv->page[0].dy);
\r
706 if(!pageflipflop && !pageploop)
\r
707 modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->tw+2), mv[id].map->tiles->tileHeight);
\r
711 void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)
\r
713 word y;//x, /* coordinate for drawing */
\r
715 /* increment the pixel position and update the page */
\r
716 mv[id].page[0].dy += player[plid].enti.speed;
\r
718 /* check to see if this changes the tile */
\r
719 if(mv[id].page[0].dy >= mv[id].dyThresh )
\r
721 /* go down one tile */
\r
723 /* Snap the origin downward */
\r
724 mv[id].page->data += mv[id].page->pi;
\r
726 mv[id].page[0].dy = mv[id].map->tiles->tileHeight;
\r
729 /* draw the next row */
\r
730 y= mv[0].page->sh + mv[id].map->tiles->tileHeight;
\r
731 if(player[plid].enti.q%3)
\r
733 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+mv[0].page->th, y, player, mv->page[0].dy);
\r
735 if(!pageflipflop && !pageploop)
\r
736 modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->tw+2), mv[id].map->tiles->tileHeight);
\r
741 //TODO finish this wwww
\r
742 void near ScrollRight(map_view_t *mv, player_t *player, word id, word plid)
\r
744 /* increment the pixel position and update the page */
\r
745 mv[id].page->dx += player[plid].enti.speed;
\r
747 /* check to see if this changes the tile */
\r
748 if(mv[id].page->dx >= mv[0].dxThresh )
\r
750 // vga_setup_wm1_block_copy();
\r
751 // _fmemmove(mv[id].page->data+4, mv[id].page->data, mv[id].page->pagesize);
\r
752 // vga_restore_rm0wm0();
\r
753 /* Snap the origin forward */
\r
754 mv[id].page->data += 4;
\r
755 mv[id].page->dx = mv[0].map->tiles->tileWidth;
\r
759 void near ScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
\r
761 /* decrement the pixel position and update the page */
\r
762 mv[id].page->dx -= player[plid].enti.speed;
\r
764 /* check to see if this changes the tile */
\r
765 if(mv[id].page->dx == 0)
\r
767 // vga_setup_wm1_block_copy();
\r
768 // _fmemmove(mv[id].page->data-4, mv[id].page->data, mv[id].page->pagesize);
\r
769 // vga_restore_rm0wm0();
\r
770 /* Snap the origin backward */
\r
771 mv[id].page->data -= 4;
\r
772 mv[id].page->dx = mv[0].map->tiles->tileWidth;
\r
776 void near ScrollUp(map_view_t *mv, player_t *player, word id, word plid)
\r
778 /* decrement the pixel position and update the page */
\r
779 mv[id].page->dy -= player[plid].enti.speed;
\r
781 /* check to see if this changes the tile */
\r
782 if(mv[id].page->dy == 0)
\r
784 // vga_setup_wm1_block_copy();
\r
785 // _fmemmove(mv[id].page->data-mv[id].page->pi, mv[id].page->data, mv[id].page->pagesize);
\r
786 // vga_restore_rm0wm0();
\r
787 /* Snap the origin backward */
\r
788 mv[id].page->data -= mv[id].page->pi;
\r
789 mv[id].page->dy = mv[0].map->tiles->tileWidth;
\r
793 void near ScrollDown(map_view_t *mv, player_t *player, word id, word plid)
\r
795 /* increment the pixel position and update the page */
\r
796 mv[id].page->dy += player[plid].enti.speed;
\r
798 /* check to see if this changes the tile */
\r
799 if(mv[id].page->dy >= mv[0].dxThresh )
\r
801 // vga_setup_wm1_block_copy();
\r
802 // _fmemmove(mv[id].page->data+mv[id].page->pi, mv[id].page->data, mv[id].page->pagesize);
\r
803 // vga_restore_rm0wm0();
\r
804 /* Snap the origin forward */
\r
805 mv[id].page->data += mv[id].page->pi;
\r
806 mv[id].page->dy = mv[0].map->tiles->tileWidth;
\r
810 //===========================================================================
\r
811 //TODO: put player in starting position of assigned spot on map
\r
812 //default player position on the viewable map
\r
813 void playerXYpos(int x, int y, player_t *player, map_view_t *pip, nibble pn)
\r
815 player[pn].enti.tx = x + pip[0].tx + pip[0].page->tilemidposscreenx;
\r
816 player[pn].enti.ty = y + pip[0].ty + pip[0].page->tilemidposscreeny;
\r
818 //===========================================================================
\r
820 sword chkmap(map_t *map, word q)
\r
823 static byte x[(MAPW*MAPH)+1] =
\r
824 { 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, 1, 1, 1, 1, 1, 1, 1, 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, 1, \
\r
827 9, 10, 11, 12, 4, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
828 13, 14, 15, 16, 0, 1, 1, 1, 5, 8, 1, 11, 11, 1, 1, 1, 1, 1, 1, 1, \
\r
829 0, 0, 4, 0, 0, 0, 0, 0, 8, 8, 1, 11, 11, 3, 1, 1, 1, 1, 1, 1, \
\r
830 1, 1, 1, 1, 0, 0, 0, 0, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
831 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
832 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
\r
833 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
834 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
835 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
\r
836 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
837 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
\r
838 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
839 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 1, 2, 3, 4 };*/
\r
840 //check for failed to load map
\r
841 if((map->width == map->height == 0) && (q>0))
\r
843 //initiate a null map!
\r
844 map->width=MAPW;///2;
\r
845 map->height=MAPH;///2;
\r
846 // map->data = malloc(((map->width*map->height)+1)*sizeof(byte));
\r
848 map->tiles = malloc(sizeof(tiles_t));
\r
849 //fix this to be far~
\r
850 // bp = bitmapLoadPcx("data/ed.pcx");
\r
851 // map->tiles->data = &bp;
\r
852 #ifdef __DEBUG_MAP__
\r
853 dbg_mapdata = map->data;
\r
855 map->tiles->tileHeight = 16;
\r
856 map->tiles->tileWidth = 16;
\r
857 map->tiles->rows = 1;
\r
858 map->tiles->cols = 1;
\r
859 #ifdef __DEBUG_MAP__
\r
860 dbg_maptext = true;
\r
863 #ifdef __DEBUG_MAP__
\r
864 else dbg_maptext = false;
\r
869 //TODO: player position here
\r
870 void mapGoTo(map_view_t *mv, int tx, int ty)
\r
875 mapinitmapview(mv, tx, ty);
\r
877 /* draw the tiles */
\r
878 modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 0);
\r
880 i=mv[0].ty * mv[0].map->width + mv[0].tx;
\r
881 for(ty=mv[0].ty-1; py < mv[0].page->sh+mv->dyThresh && ty < mv[0].map->height; ty++, py+=mv[0].map->tiles->tileHeight) {
\r
882 mapDrawWRow(&mv[0], tx-1, ty, py);
\r
883 i+=mv->map->width - tx;
\r
885 if(!pageploop) modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height);
\r
887 // unsigned int k,j,o;
\r
888 // /* fill screen with a distinctive pattern */
\r
889 // for (k=0;k < vga_state.vga_width;k++) {
\r
891 // vga_write_sequencer(0x02/*map mask*/,1 << (k&3));
\r
892 // for (j=0;j < (mv[0].page->height)+(mv[1].page->height)+(mv[2].page->height)+(mv[3].page->height);j++,o += vga_state.vga_stride)
\r
893 // vga_state.vga_graphics_ram[o] = (k^j)&15; // VRL samples put all colors in first 15!
\r
896 modexCopyPageRegion(mv[3].page, mv[0].page, 0/**/, 0/**/, 0, 0, 24, 32);
\r
899 void mapinitmapview(map_view_t *mv, int tx, int ty)
\r
901 /* set up the coordinates */
\r
902 mv[0].tx = mv[1].tx = tx;
\r
903 mv[0].ty = mv[1].ty = ty;
\r
904 mv[0].page->dx = mv[1].page->dx = mv[2].page->dx = mv[3].page->dx = mv->map->tiles->tileWidth;
\r
905 mv[0].page->dy = mv[1].page->dy = mv[2].page->dy = mv[3].page->dy = mv->map->tiles->tileHeight;
\r
907 /* set up the thresholds */
\r
908 mv[0].dxThresh = mv[1].dxThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileWidth * 2;
\r
909 mv[0].dyThresh = mv[1].dyThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileHeight * 2;
\r
913 mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y)
\r
917 //word textx=0, texty=0;
\r
922 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 0); //currently the over scan color!
\r
926 rx = (((i-1) % ((t->data->width)/t->tileWidth)) * t->tileWidth);
\r
927 ry = (((i-1) / ((t->data->height)/t->tileHeight)) * t->tileHeight);
\r
928 ////0000printf("i=%d\n", i);
\r
929 #ifdef __DEBUG_MAP__
\r
930 switch(dbg_maptext)
\r
935 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, ((dbg_mapdata[i])+1));
\r
936 //modexprint(page, x, y, 1, 15, 0, (char const *)(t->debug_data[i]));
\r
938 modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
\r
939 /* then the sprite. note modding ram ptr means we just draw to (x&3,0) */
\r
940 //draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));
\r
941 //modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
\r
943 #ifdef __DEBUG_MAP__
\r
946 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, (dbg_mapdata[i])+1);
\r
947 //modexprintbig(page, x, y, 1, 15, 0, (t->debug_data));
\r
948 /*for(texty=0; texty<2; texty++)
\r
950 for(textx=0; textx<2; textx++)
\r
952 // modexprint(page, x+(textx*8), y+(texty*8), 1, (word)(t->debug_data), 0, (t->debug_data));
\r
961 void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *player, word poopoffset)
\r
965 poopoffset%=player[0].enti.speed;
\r
966 //printf("y: %d\n", poopoffset);
\r
967 /* the position within the map array */
\r
968 i=ty * mv->map->width + tx;
\r
969 for(x=poopoffset; x<(mv->page->sw+mv->dxThresh)/(poopoffset+1) && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
\r
971 /* we are in the map, so copy! */
\r
972 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
978 void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *player, word poopoffset)
\r
982 poopoffset%=player[0].enti.speed;
\r
983 //printf("x: %d\n", poopoffset);
\r
984 /* location in the map array */
\r
985 i=ty * mv->map->width + tx;
\r
987 /* We'll copy all of the columns in the screen,
\r
988 i + 1 row above and one below */
\r
989 for(y=poopoffset; y<(mv->page->sh+mv->dyThresh)/(poopoffset+1) && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
\r
991 /* we are in the map, so copy away! */
\r
992 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
994 i += mv->map->width;
\r
998 void mapDrawWRow(map_view_t *mv, int tx, int ty, word y)
\r
1003 /* the position within the map array */
\r
1004 i=ty * mv->map->width + tx;
\r
1005 for(x=0; x<mv->page->sw+mv->dxThresh && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
\r
1007 /* we are in the map, so copy! */
\r
1008 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
1014 void mapDrawWCol(map_view_t *mv, int tx, int ty, word x)
\r
1019 /* location in the map array */
\r
1020 i=ty * mv->map->width + tx;
\r
1022 /* We'll copy all of the columns in the screen,
\r
1023 i + 1 row above and one below */
\r
1024 for(y=0; y<mv->page->sh+mv->dyThresh && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
\r
1026 /* we are in the map, so copy away! */
\r
1027 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
1029 i += mv->map->width;
\r
1038 boolean pageflipflop = 1;
\r
1039 boolean pageploop = 1;
\r
1042 void shinku(global_game_variables_t *gv)
\r
1044 word x = (0) + gv->video.page[/*!*/(gv->video.p)].dx; // follow the screen
\r
1045 word y = (0) + gv->video.page[/*!*/(gv->video.p)].dy; // follow the screen
\r
1046 word col = 7, bgcol = 0, type = 1;//w = 64, h = 8,
\r
1048 //modexCopyPageRegion(pip[1].page, pip[2].page, 16, 16, 16, 16, (14*8)+4, 8+4);
\r
1049 /* block copy to visible RAM from offscreen */
\r
1050 // vga_setup_wm1_block_copy();
\r
1051 // modexCopyPageRegion(&(gv->video.page[gv->video->sfip]), &(gv->video.page[!gv->video->sfip]), x, y, x+w, 0, w, h);
\r
1052 // o = *(gv->video.page[2].data); // source offscreen
\r
1053 // o2 = *(gv->video.page[gv->video->sfip].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride)
\r
1054 // for (i=0;i < h;i++,o += vga_state.vga_draw_stride,o2 += vga_state.vga_stride) vga_wm1_mem_block_copy(o2,o,w >> 2);
\r
1055 /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */
\r
1056 // vga_restore_rm0wm0();
\r
1057 if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second))
\r
1059 // NTS: For some bizarre reason, gv->pee is not initialized, but the pointer is not NULL even
\r
1060 // though it should be. Instead it's NULL as a near pointer but contains a non-null
\r
1061 // segment value, so testing against NULL doesn't work. It is initialized properly if
\r
1062 // you call start_timer() though which uses near malloc. Rather than fight with that,
\r
1063 // I decided it would be better to declare a temp buffer statically and sprintf to that.
\r
1065 // This fixes *** Null pointer assignment detected error message in ZCROLL.EXE on exit.
\r
1066 sprintf(global_temp_status_text, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv));
\r
1067 //modexClearRegion(&(gv->video.page[gv->video->sfip]), x, y, w, h, 45);
\r
1068 modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, col, bgcol, global_temp_status_text);
\r
1069 gv->kurokku.tiku=0;
\r
1070 /* block copy to visible RAM from offscreen */
\r
1071 // vga_setup_wm1_block_copy();
\r
1072 // o = *(gv->video.page[gv->video->sfip].data); // source offscreen
\r
1073 // o2 = *(gv->video.page[2].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride)
\r
1074 // for (i=0;i < h;i++,o += vga_state.vga_draw_stride,o2 += vga_state.vga_stride) vga_wm1_mem_block_copy(o2,o,w >> 2);
\r
1075 // modexCopyPageRegion(&(gv->video.page[gv->video->sfip]), &(gv->video.page[!gv->video->sfip]), x, y, x, 0, w, h);
\r
1076 /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */
\r
1077 // vga_restore_rm0wm0();
\r
1078 }else //copy dat sheet
\r
1079 gv->kurokku.tiku++;
\r
1081 switch(gv->kurokku.fpscap)
\r
1084 //modexprint(&(gv->video.page[gv->video->sfip]), x, y+8, type, col, bgcol, "sanic!");
\r
1085 gv->kurokku.frames_per_second=1;
\r
1088 //turn this off if XT
\r
1089 //modexWaitBorder();
\r
1090 vga_wait_for_vsync();
\r
1091 gv->kurokku.frames_per_second=60;
\r
1096 //vga_setup_wm1_block_copy();
\r
1097 //_fmemcpy((gv->video.page[(gv->video.p)]).data, (gv->video.page[(!gv->video.p)]).data, gv->video.page[(!gv->video.p)].pagesize);
\r
1098 //vga_restore_rm0wm0();
\r
1099 if(!pageploop) modexCopyPageRegion(&(gv->video.page[(gv->video.p)]), &(gv->video.page[(!gv->video.p)]), 0, 0, 0, 0, gv->video.page[gv->video.p].width, gv->video.page[!gv->video.p].height);
\r
1100 modexShowPage(&(gv->video.page[gv->video.p]));
\r
1101 if(!pageploop) gv->video.p=!gv->video.p;
\r
1102 gv->video.r=!gv->video.r;
\r
1103 //0000gv->video.tickclk = ((*clockw)-gv->video.startclk)/18.2;
\r
1109 #define FRAME1 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 48, dire, 24, 32, PLAYERBMPDATAPTR);
\r
1110 #define FRAME2 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, dire, 24, 32, PLAYERBMPDATAPTR);
\r
1111 #define FRAME3 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 0, dire, 24, 32, PLAYERBMPDATAPTR);
\r
1112 #define FRAME4 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, dire, 24, 32, PLAYERBMPDATAPTR);
\r
1114 #define FRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 2+dire);
\r
1115 #define FRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+dire);
\r
1116 #define FRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, dire);
\r
1117 #define FRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+dire);
\r
1120 void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch)
\r
1122 sword x = player[pn].enti.x;
\r
1123 sword y = player[pn].enti.y;
\r
1124 sword bx = x+16; //buffer's x
\r
1125 sword by = y+16; //buffer's y
\r
1126 word dire=32; //direction
\r
1127 sword qq; //scroll offset
\r
1128 word ls = player[pn].enti.persist_aniframe;
\r
1130 switch(scrollswitch)
\r
1136 qq = ((player[pn].enti.q)*(player[pn].enti.speed));
\r
1140 y-=pip[0].map->tiles->tileHeight;
\r
1141 switch (player[pn].enti.d)
\r
1145 dire*=player[pn].enti.d;
\r
1151 dire*=(player[pn].enti.d-2);
\r
1159 dire*=(player[pn].enti.d-2);
\r
1165 dire*=(player[pn].enti.d+2);
\r
1172 modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 36);
\r
1174 //copy old bg to page0
\r
1175 //modexCopyPageRegion(pip[3].page, pip[0].page, bx, by, 0, 0, 20, 36);
\r
1177 //modexCopyPageRegion(pip[0].page, pip[3].page, 0, 0, x, y, 20, 36);
\r
1179 //modexCopyPageRegion(page_t *dest, page_t *src, word sx, word sy, word dx, word dy, word width, word height);
\r
1180 //modexCopyPageRegion(pip[3].page, pip[!(pip->video->p)].page, x-4, y-4, 0, 128, 28, 36);
\r
1181 /*modexCopyPageRegion(pip[pip->video->p].page,
\r
1182 pip[!(pip->video->p)].page, x-4, y-4, x-4, y-4, 28, 36);*/
\r
1183 // else modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 40);
\r
1199 // if(2>ls && ls>=1) { FRAME1 }else
\r
1200 // if(3>ls && ls>=2) { FRAME2 }else
\r
1201 // if(4>ls && ls>=3) { FRAME3 }else
\r
1202 // if(5>ls && ls>=4) { FRAME4 }
\r
1203 //modexCopyPageRegion(pip[0].page, pip[3].page, 0, 0, x, y, 24, 32);
\r
1204 //printf("x=%d y=%d bx=%d by=%d\n", x, y, bx, by);
\r
1209 void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch)
\r
1211 sword x = player[pn].enti.x;
\r
1212 sword y = player[pn].enti.y;
\r
1213 word dire=10; //direction
\r
1214 sword qq; //scroll offset
\r
1215 word ls = player[pn].enti.persist_aniframe;
\r
1219 switch(scrollswitch)
\r
1225 qq = ((player[pn].enti.q)*(player[pn].enti.speed));
\r
1231 y-=pip[0].map->tiles->tileHeight;
\r
1232 switch (player[pn].enti.d)
\r
1236 dire*=player[pn].enti.d+1;
\r
1241 dire*=(player[pn].enti.d-1);
\r
1248 dire*=(player[pn].enti.d-1);
\r
1253 dire*=(player[pn].enti.d+3);
\r
1258 //setting xy position
\r
1259 player[pn].ent->spri->x = x;
\r
1260 player[pn].ent->spri->y = y;
\r
1262 //#define FRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 2+dire);
\r
1263 //#define FRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 1+dire);
\r
1264 //#define FRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, dire);
\r
1265 //#define FRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 1+dire);
\r
1267 //#define DRAWFRAME if (i == -1) return; oldanimate_spri(player[pn].ent->spri, pip->video)
\r
1268 #define DRAWFRAME if (i == -1) return; animate_spri(player[pn].ent->spri, pip->video)
\r
1269 #define NFRAME1 i = set_anim_by_id(player[pn].ent->spri, 2+dire); DRAWFRAME;
\r
1270 #define NFRAME2 i = set_anim_by_id(player[pn].ent->spri, 1+dire); DRAWFRAME;
\r
1271 #define NFRAME3 i = set_anim_by_id(player[pn].ent->spri, dire); DRAWFRAME;
\r
1272 #define NFRAME4 i = set_anim_by_id(player[pn].ent->spri, 2+dire); DRAWFRAME;
\r
1274 #define NFRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 2+dire);
\r
1275 #define NFRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+dire);
\r
1276 #define NFRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, dire);
\r
1277 #define NFRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+dire);
\r
1302 boolean boundary_check(int x, int y, int dx, int dy, int h, int w)
\r
1304 return (dx > 0 && (x + dx) < w) || (dx < 0 && (x + dx) >= 0) || (dy > 0 && (y + dy) < h) || (dy < 0 && (y + dy) >= 0) || (dx == dy && dx == 0);
\r
1307 boolean coll_check(int x, int y, int dx, int dy, map_view_t *map_v)
\r
1309 // Assume everything crosses at most 1 tile at once
\r
1310 return dx && 1;//crossable_tile(x + dx, map_v) || dy && crossable_tile(y + dy, map_v);
\r
1313 boolean ZC_walk2(entity_t *ent, map_view_t *map_v)
\r
1333 if(coll_check(ent->x, ent->y, dx, dy, map_v))
\r
1337 // Start animation
\r
1338 // Mark next tile as occupied
\r
1339 // Mark this tile as vacant
\r
1345 void player_walk(player_t *player, map_view_t *map_v){
\r
1347 if(ZC_walk2(&(player->enti), map_v) && boundary_check(map_v->tx, map_v->ty, dx, dy, map_v->map->width - 2*map_v->page->tilesw, map_v->map->height - 2*map_v->page->tilesh))
\r
1349 mapScroll(map_v, player);
\r
1350 // (Un)load stuff?
\r
1354 void near mapScroll(map_view_t *mv, player_t *player)
\r
1356 //word x, y; /* coordinate for drawing */
\r
1359 mv->delta += player->dx | player->dy;
\r
1360 delta = mv->delta;
\r
1361 mv->d = (player->dx) ? (player->dx > 0) ? 3 : 1 : (player->dy) ? (player->dy > 0) ? 4 : 0 : 2;
\r
1367 if(!(delta + mv->dxThresh))
\r
1377 if(!(delta + mv->dyThresh))
\r