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 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
55 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
57 if(player[pn].enti.q<=player[pn].enti.spt)
\r
60 player[pn].enti.x+=(player[pn].enti.speed);
\r
61 ANIMATESPRIFUN(pip, player, pn, 0);
\r
62 player[pn].enti.q++;
\r
63 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
68 //modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATAPTR);
\r
69 ANIMATESPRIFUN(pip, player, pn, 0);
\r
71 // modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 14);
\r
73 player[pn].enti.d = 2;
\r
75 player[pn].enti.triggerx = player[pn].enti.tx+1;
\r
76 player[pn].enti.triggery = player[pn].enti.ty;
\r
80 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
81 !(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
83 if(player[pn].enti.q<=player[pn].enti.spt)
\r
86 ANIMATESPRIFUN(pip, player, pn, 1);
\r
87 ScrollLeft(pip, player, 3, pn);
\r
88 ScrollLeft(pip, player, 2, pn);
\r
89 mapScrollLeft(pip, player, (pip[0].video->p), pn);
\r
90 player[pn].enti.q++;
\r
91 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
92 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
94 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
96 if(player[pn].enti.q<=player[pn].enti.spt)
\r
99 player[pn].enti.x-=(player[pn].enti.speed);
\r
100 ANIMATESPRIFUN(pip, player, pn, 0);
\r
101 player[pn].enti.q++;
\r
102 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
107 //modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATAPTR);
\r
108 ANIMATESPRIFUN(pip, player, pn, 0);
\r
110 // modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 10);
\r
112 player[pn].enti.d = 2;
\r
114 player[pn].enti.triggerx = player[pn].enti.tx-1;
\r
115 player[pn].enti.triggery = player[pn].enti.ty;
\r
119 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
120 !(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
122 if(player[pn].enti.q<=player[pn].enti.spt)
\r
125 ANIMATESPRIFUN(pip, player, pn, 1);
\r
126 ScrollDown(pip, player, 3, pn);
\r
127 ScrollDown(pip, player, 2, pn);
\r
128 mapScrollDown(pip, player, (pip[0].video->p), pn);
\r
129 player[pn].enti.q++;
\r
130 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
131 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
133 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
135 if(player[pn].enti.q<=player[pn].enti.spt)
\r
138 player[pn].enti.y+=(player[pn].enti.speed);
\r
139 ANIMATESPRIFUN(pip, player, pn, 0);
\r
140 player[pn].enti.q++;
\r
141 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
146 //modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATAPTR);
\r
147 ANIMATESPRIFUN(pip, player, pn, 0);
\r
149 // modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 9);
\r
151 player[pn].enti.d = 2;
\r
153 player[pn].enti.triggerx = player[pn].enti.tx;
\r
154 player[pn].enti.triggery = player[pn].enti.ty+1;
\r
158 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
159 !(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
161 if(player[pn].enti.q<=player[pn].enti.spt)
\r
164 ANIMATESPRIFUN(pip, player, pn, 1);
\r
165 ScrollUp(pip, player, 3, pn);
\r
166 ScrollUp(pip, player, 2, pn);
\r
167 mapScrollUp(pip, player, (pip[0].video->p), pn);
\r
168 player[pn].enti.q++;
\r
169 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
170 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
172 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
174 if(player[pn].enti.q<=player[pn].enti.spt)
\r
177 player[pn].enti.y-=(player[pn].enti.speed);
\r
178 ANIMATESPRIFUN(pip, player, 0, pn);
\r
179 player[pn].enti.q++;
\r
180 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
185 //modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATAPTR);
\r
186 ANIMATESPRIFUN(pip, player, pn, 0);
\r
188 // modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 12);
\r
190 player[pn].enti.d = 2;
\r
192 player[pn].enti.triggerx = player[pn].enti.tx;
\r
193 player[pn].enti.triggery = player[pn].enti.ty-1;
\r
200 src/lib/scroll16.c: mv[0].video->r=1;
\r
201 src/lib/scroll16.c: mv[0].video->r=1;
\r
202 src/lib/scroll16.c: mv[0].video->r=1;
\r
203 src/lib/scroll16.c: mv[0].video->r=1;
\r
204 src/lib/scroll16.c: pip->video->r=1;
\r
205 src/lib/scroll16.c: mv->video->r=1;
\r
208 void oldwalk(map_view_t *pip, player_t *player, word pn)
\r
210 //printf("player[%d].d=%d\n", pn, player[pn].enti.d);
\r
211 switch(player[pn].enti.d)
\r
215 //0000pip[0].video->startclk = (*clockw);
\r
219 //printf("pip[0].page->tilesw=%d ", pip[0].page->tilesw); printf("pip[0].page->tw=%d\n", pip[0].page->tw);
\r
220 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
221 !(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
223 if(player[pn].enti.q<=player[pn].enti.spt)
\r
226 ANIMATESPRIFUN(pip, player, pn, 1);
\r
227 ScrollRight(pip, player, 3, pn);
\r
228 ScrollRight(pip, player, 2, pn);
\r
229 //mapScrollRight(pip, player, !(pip[0].video->p), pn);
\r
230 mapScrollRight(pip, player, (pip[0].video->p), pn);
\r
231 if(!pageflipflop) modexShowPage(pip[1].page);
\r
232 player[pn].enti.q++;
\r
233 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
234 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
236 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
238 if(player[pn].enti.q<=player[pn].enti.spt)
\r
241 player[pn].enti.x+=(player[pn].enti.speed);
\r
242 ANIMATESPRIFUN(pip, player, pn, 0);
\r
243 if(!pageflipflop) modexShowPage(pip[1].page);
\r
244 player[pn].enti.q++;
\r
245 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
249 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
251 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATAPTR);
\r
253 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 14);
\r
255 if(!pageflipflop) modexShowPage(pip[1].page);
\r
256 player[pn].enti.d = 2;
\r
258 player[pn].enti.triggerx = player[pn].enti.tx+1;
\r
259 player[pn].enti.triggery = player[pn].enti.ty;
\r
264 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
265 !(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
267 if(player[pn].enti.q<=player[pn].enti.spt)
\r
270 ANIMATESPRIFUN(pip, player, pn, 1);
\r
271 ScrollLeft(pip, player, 3, pn);
\r
272 ScrollLeft(pip, player, 2, pn);
\r
273 //mapScrollLeft(pip, player, !(pip[0].video->p), pn);
\r
274 mapScrollLeft(pip, player, (pip[0].video->p), pn);
\r
275 if(!pageflipflop) modexShowPage(pip[1].page);
\r
276 player[pn].enti.q++;
\r
277 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
278 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
280 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
282 if(player[pn].enti.q<=player[pn].enti.spt)
\r
285 player[pn].enti.x-=(player[pn].enti.speed);
\r
286 ANIMATESPRIFUN(pip, player, pn, 0);
\r
287 if(!pageflipflop) modexShowPage(pip[1].page);
\r
288 player[pn].enti.q++;
\r
289 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
293 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
295 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATAPTR);
\r
297 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 10);
\r
299 if(!pageflipflop) modexShowPage(pip[1].page);
\r
300 player[pn].enti.d = 2;
\r
302 player[pn].enti.triggerx = player[pn].enti.tx-1;
\r
303 player[pn].enti.triggery = player[pn].enti.ty;
\r
308 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
309 !(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
311 if(player[pn].enti.q<=player[pn].enti.spt)
\r
314 ANIMATESPRIFUN(pip, player, pn, 1);
\r
315 ScrollDown(pip, player, 3, pn);
\r
316 ScrollDown(pip, player, 2, pn);
\r
317 //mapScrollDown(pip, player, !(pip[0].video->p), pn);
\r
318 mapScrollDown(pip, player, (pip[0].video->p), pn);
\r
319 if(!pageflipflop) modexShowPage(pip[1].page);
\r
320 player[pn].enti.q++;
\r
321 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
322 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
324 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
326 if(player[pn].enti.q<=player[pn].enti.spt)
\r
329 player[pn].enti.y+=(player[pn].enti.speed);
\r
330 ANIMATESPRIFUN(pip, player, pn, 0);
\r
331 if(!pageflipflop) modexShowPage(pip[1].page);
\r
332 player[pn].enti.q++;
\r
333 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
337 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
339 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATAPTR);
\r
341 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 9);
\r
343 if(!pageflipflop) modexShowPage(pip[1].page);
\r
344 player[pn].enti.d = 2;
\r
346 player[pn].enti.triggerx = player[pn].enti.tx;
\r
347 player[pn].enti.triggery = player[pn].enti.ty+1;
\r
352 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
353 !(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
355 if(player[pn].enti.q<=player[pn].enti.spt)
\r
358 ANIMATESPRIFUN(pip, player, pn, 1);
\r
359 ScrollUp(pip, player, 3, pn);
\r
360 ScrollUp(pip, player, 2, pn);
\r
361 //mapScrollUp(pip, player, !(pip[0].video->p), pn);
\r
362 mapScrollUp(pip, player, (pip[0].video->p), pn);
\r
363 if(!pageflipflop) modexShowPage(pip[1].page);
\r
364 player[pn].enti.q++;
\r
365 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
366 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
368 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
370 if(player[pn].enti.q<=player[pn].enti.spt)
\r
373 player[pn].enti.y-=(player[pn].enti.speed);
\r
374 ANIMATESPRIFUN(pip, player, 0, pn);
\r
375 if(!pageflipflop) modexShowPage(pip[1].page);
\r
376 player[pn].enti.q++;
\r
377 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
381 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
383 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATAPTR);
\r
385 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 12);
\r
387 if(!pageflipflop) modexShowPage(pip[1].page);
\r
388 player[pn].enti.d = 2;
\r
390 player[pn].enti.triggerx = player[pn].enti.tx;
\r
391 player[pn].enti.triggery = player[pn].enti.ty-1;
\r
397 void ZC_panPageManual(map_view_t *pip, player_t *player, word pn)
\r
399 #define SHOWMVFUN_ ZC_ShowMV(pip, 0, 0);
\r
400 switch(player[pn].enti.d)
\r
404 if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->tw < pip[0].page->tilesw)
\r
406 if(player[pn].enti.q<=player[pn].enti.spt)
\r
408 pip[0].page->dx+=4;
\r
410 player[pn].enti.q++;
\r
411 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].tx++; }
\r
417 if(pip[0].tx > 0 && pip[0].tx+pip[0].page->tw <= pip[0].page->tilesw)
\r
419 if(player[pn].enti.q<=player[pn].enti.spt)
\r
421 pip[0].page->dx-=4;
\r
423 player[pn].enti.q++;
\r
424 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].tx--; }
\r
430 if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->th < pip[0].page->tilesh)
\r
432 if(player[pn].enti.q<=player[pn].enti.spt)
\r
434 pip[0].page->dy+=4;
\r
436 player[pn].enti.q++;
\r
437 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].ty++; }
\r
443 if(pip[0].ty > 0 && pip[0].ty+pip[0].page->th <= pip[0].page->tilesh)
\r
445 if(player[pn].enti.q<=player[pn].enti.spt)
\r
447 pip[0].page->dy-=4;
\r
449 player[pn].enti.q++;
\r
450 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].ty--; }
\r
459 void ZC_MVSetup(map_view_t *pip, map_t *map, global_game_variables_t *gv)
\r
464 pip[0].page = &gv->video.page[0];
\r
466 pip[0].video = &gv->video;
\r
467 pip[0].panp = &gv->video.panp;
\r
468 ZC_MVInit(pip, 1, 1);
\r
470 for(i=ZC_MVI;i<gv->video.num_of_pages;i++)
\r
472 pip[i].page = &gv->video.page[i];
\r
473 pip[i].map = pip[0].map;
\r
474 pip[i].video = pip[0].video;
\r
475 pip[i].panp = pip[0].panp;
\r
483 void ZC_MVInit(map_view_t *pip, int tx, int ty)
\r
487 //pip[0].tx = pip[1].tx = tx;
\r
488 //pip[0].ty = pip[1].ty = ty;
\r
491 void ZC_ShowMV(map_view_t *moo, boolean vsync, boolean sr)
\r
493 word high_address, low_address, offset;
\r
496 /* calculate offset */
\r
497 offset = (word) moo[moo[0].video->panp].page->data;
\r
498 offset += moo[0].page->dy * (moo[0].page->width >> 2 );
\r
499 offset += moo[0].page->dx >> 2;
\r
501 /* calculate crtcOffset according to virtual width */
\r
505 crtcOffset = moo[0].page->sw >> 3;
\r
509 crtcOffset = moo[0].page->width >> 3;
\r
513 high_address = HIGH_ADDRESS | (offset & 0xff00);
\r
514 low_address = LOW_ADDRESS | (offset << 8);
\r
516 /* wait for appropriate timing and then program CRTC */
\r
517 if(vsync) while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE));
\r
518 outpw(CRTC_INDEX, high_address);
\r
519 outpw(CRTC_INDEX, low_address);
\r
520 outp(CRTC_INDEX, 0x13);
\r
521 outp(CRTC_DATA, crtcOffset);
\r
523 /* wait for one retrace */
\r
524 if(vsync) while (!(inp(INPUT_STATUS_1) & VRETRACE));
\r
526 /* do PEL panning here */
\r
527 outp(AC_INDEX, 0x33);
\r
528 outp(AC_INDEX, (moo[0].page->dx & 0x03) << 1);
\r
532 allocMap(int w, int h) {
\r
537 result.data = malloc(sizeof(byte) * w * h);
\r
538 //result.data = (byte *)alloc_emem(((int)sizeof(byte) * w * h)/1024);
\r
539 if(isEMS() || checkEMS())
\r
542 //emmhandle = mallocEMS(coretotalEMS());//alloc_emem((int)sizeof(map))
\r
543 mm.length=sizeof(result);
\r
545 mm.sourceOff=ptr2long(&result);
\r
546 mm.destH=emmhandle;
\r
548 ist = move_emem(&mm);
\r
549 if(!ist){ dealloc_emem(emmhandle); exit(5); }
\r
550 printf("%d\n", coretotalEMS());
\r
557 initMap(map_t *map) {
\r
558 // just a place holder to fill out an alternating pattern
\r
562 //if(!isEMS() || !checkEMS())
\r
563 // map->tiles = malloc(sizeof(tiles_t));
\r
565 // map->tiles = (tiles_t *)alloc_emem(sizeof(tiles_t));
\r
567 //create the tile set
\r
568 //if(!isEMS() || !checkEMS())
\r
569 // map->tiles->data = malloc(sizeof(bitmap_t));
\r
571 // map->tiles->data = (bitmap_t *)alloc_emem(sizeof(bitmap_t));
\r
572 // map->tiles->data->width = (TILEWH);
\r
573 // map->tiles->data->height= TILEWH;
\r
574 //if(!isEMS() || !checkEMS())
\r
575 // map->tiles->data->data = malloc((TILEWH*2)*TILEWH);
\r
577 // map->tiles->data->data = (byte *)alloc_emem((TILEWH*2)*TILEWH);
\r
578 // map->tiles->tileHeight = TILEWH;
\r
579 // map->tiles->tileWidth =TILEWH;
\r
580 // map->tiles->rows = 1;
\r
581 // map->tiles->cols = 1;//2;
\r
584 //for(y=0; y<map->height; y++) {
\r
585 //for(x=0; x<map->width; x++) {
\r
587 for(yy=0; yy<TILEWH; yy++) {
\r
588 for(xx=0; xx<(TILEWH); xx++) {
\r
590 map->tiles->data->data[i+1] = map->data[q];//28;//0x24;
\r
591 // printf("[%d]", map->tiles->data->data[i]);
\r
593 //map->tiles->data->data[i] = map->data[q];//0;//0x34;
\r
594 //printf("]%d[==[%d]", i, map->tiles->data->data[i]);
\r
600 // printf("[%d]", map->data[q]);
\r
607 for(y=0; y<map->height; y++) {
\r
608 for(x=0; x<map->width; x++) {
\r
609 // map->data[i]=255;
\r
610 printf("[%d]", map->data[i]);
\r
611 //tile = tile ? 0 : 1;
\r
614 //tile = tile ? 0 : 1;
\r
618 void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
\r
620 word x;//, y; /* coordinate for drawing */
\r
622 /* increment the pixel position and update the page */
\r
623 mv[id].page[0].dx += player[plid].enti.speed;
\r
625 /* check to see if this changes the tile */
\r
626 if(mv[id].page[0].dx >= mv[id].dxThresh )
\r
628 /* go forward one tile */
\r
630 /* Snap the origin forward */
\r
631 mv[id].page->data += 4;
\r
633 mv[id].page[0].dx = mv[id].map->tiles->tileWidth;
\r
636 /* draw the next column */
\r
637 x= mv[0].page->sw + mv[id].map->tiles->tileWidth;
\r
638 if(player[plid].enti.q%4)
\r
640 mapDrawCol(&mv[0], mv[0].tx + mv[0].page->tw, mv[0].ty-1, x, player, mv->page[0].dx);
\r
642 if(!pageflipflop && !pageploop)
\r
643 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
648 void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
\r
650 word x;//,y; /* coordinate for drawing */
\r
652 /* decrement the pixel position and update the page */
\r
653 mv[id].page[0].dx -= player[plid].enti.speed;
\r
655 /* check to see if this changes the tile */
\r
656 if(mv[id].page[0].dx == 0)
\r
658 /* go backward one tile */
\r
660 /* Snap the origin backward */
\r
661 mv[id].page->data -= 4;
\r
663 mv[id].page[0].dx = mv[id].map->tiles->tileWidth;
\r
666 /* draw the next column */
\r
668 if(player[plid].enti.q%4)
\r
670 mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, mv->page[0].dx);
\r
672 if(!pageflipflop && !pageploop)
\r
673 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
678 void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
\r
680 word y;//x, /* coordinate for drawing */
\r
682 /* decrement the pixel position and update the page */
\r
683 mv[id].page[0].dy -= player[plid].enti.speed;
\r
685 /* check to see if this changes the tile */
\r
686 if(mv[id].page[0].dy == 0 )
\r
688 /* go down one tile */
\r
690 /* Snap the origin downward */
\r
691 mv[id].page->data -= mv[id].page->pi;
\r
693 mv[id].page[0].dy = mv[id].map->tiles->tileHeight;
\r
696 /* draw the next row */
\r
698 if(player[plid].enti.q%3)
\r
700 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, mv->page[0].dy);
\r
702 if(!pageflipflop && !pageploop)
\r
703 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
707 void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)
\r
709 word y;//x, /* coordinate for drawing */
\r
711 /* increment the pixel position and update the page */
\r
712 mv[id].page[0].dy += player[plid].enti.speed;
\r
714 /* check to see if this changes the tile */
\r
715 if(mv[id].page[0].dy >= mv[id].dyThresh )
\r
717 /* go down one tile */
\r
719 /* Snap the origin downward */
\r
720 mv[id].page->data += mv[id].page->pi;
\r
722 mv[id].page[0].dy = mv[id].map->tiles->tileHeight;
\r
725 /* draw the next row */
\r
726 y= mv[0].page->sh + mv[id].map->tiles->tileHeight;
\r
727 if(player[plid].enti.q%3)
\r
729 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+mv[0].page->th, y, player, mv->page[0].dy);
\r
731 if(!pageflipflop && !pageploop)
\r
732 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
737 //TODO finish this wwww
\r
738 void near ScrollRight(map_view_t *mv, player_t *player, word id, word plid)
\r
740 /* increment the pixel position and update the page */
\r
741 mv[id].page->dx += player[plid].enti.speed;
\r
743 /* check to see if this changes the tile */
\r
744 if(mv[id].page->dx >= mv[0].dxThresh )
\r
746 // vga_setup_wm1_block_copy();
\r
747 // _fmemmove(mv[id].page->data+4, mv[id].page->data, mv[id].page->pagesize);
\r
748 // vga_restore_rm0wm0();
\r
749 /* Snap the origin forward */
\r
750 mv[id].page->data += 4;
\r
751 mv[id].page->dx = mv[0].map->tiles->tileWidth;
\r
755 void near ScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
\r
757 /* decrement the pixel position and update the page */
\r
758 mv[id].page->dx -= player[plid].enti.speed;
\r
760 /* check to see if this changes the tile */
\r
761 if(mv[id].page->dx == 0)
\r
763 // vga_setup_wm1_block_copy();
\r
764 // _fmemmove(mv[id].page->data-4, mv[id].page->data, mv[id].page->pagesize);
\r
765 // vga_restore_rm0wm0();
\r
766 /* Snap the origin backward */
\r
767 mv[id].page->data -= 4;
\r
768 mv[id].page->dx = mv[0].map->tiles->tileWidth;
\r
772 void near ScrollUp(map_view_t *mv, player_t *player, word id, word plid)
\r
774 /* decrement the pixel position and update the page */
\r
775 mv[id].page->dy -= player[plid].enti.speed;
\r
777 /* check to see if this changes the tile */
\r
778 if(mv[id].page->dy == 0)
\r
780 // vga_setup_wm1_block_copy();
\r
781 // _fmemmove(mv[id].page->data-mv[id].page->pi, mv[id].page->data, mv[id].page->pagesize);
\r
782 // vga_restore_rm0wm0();
\r
783 /* Snap the origin backward */
\r
784 mv[id].page->data -= mv[id].page->pi;
\r
785 mv[id].page->dy = mv[0].map->tiles->tileWidth;
\r
789 void near ScrollDown(map_view_t *mv, player_t *player, word id, word plid)
\r
791 /* increment the pixel position and update the page */
\r
792 mv[id].page->dy += player[plid].enti.speed;
\r
794 /* check to see if this changes the tile */
\r
795 if(mv[id].page->dy >= mv[0].dxThresh )
\r
797 // vga_setup_wm1_block_copy();
\r
798 // _fmemmove(mv[id].page->data+mv[id].page->pi, mv[id].page->data, mv[id].page->pagesize);
\r
799 // vga_restore_rm0wm0();
\r
800 /* Snap the origin forward */
\r
801 mv[id].page->data += mv[id].page->pi;
\r
802 mv[id].page->dy = mv[0].map->tiles->tileWidth;
\r
806 //===========================================================================
\r
807 //TODO: put player in starting position of assigned spot on map
\r
808 //default player position on the viewable map
\r
809 void playerXYpos(int x, int y, player_t *player, map_view_t *pip, nibble pn)
\r
811 player[pn].enti.tx = x + pip[0].tx + pip[0].page->tilemidposscreenx;
\r
812 player[pn].enti.ty = y + pip[0].ty + pip[0].page->tilemidposscreeny;
\r
814 //===========================================================================
\r
816 sword chkmap(map_t *map, word q)
\r
819 static byte x[(MAPW*MAPH)+1] =
\r
820 { 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 1, 1, \
\r
825 0, 0, 4, 0, 0, 0, 0, 0, 8, 8, 1, 11, 11, 3, 1, 1, 1, 1, 1, 1, \
\r
826 1, 1, 1, 1, 0, 0, 0, 0, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
827 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
828 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
\r
829 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
830 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
831 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
\r
832 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
833 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 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, 3, 3, 3, 3, 1, 2, 3, 4 };*/
\r
836 //check for failed to load map
\r
837 if((map->width == map->height == 0) && (q>0))
\r
839 //initiate a null map!
\r
840 map->width=MAPW;///2;
\r
841 map->height=MAPH;///2;
\r
842 // map->data = malloc(((map->width*map->height)+1)*sizeof(byte));
\r
844 map->tiles = malloc(sizeof(tiles_t));
\r
845 //fix this to be far~
\r
846 // bp = bitmapLoadPcx("data/ed.pcx");
\r
847 // map->tiles->data = &bp;
\r
848 #ifdef __DEBUG_MAP__
\r
849 dbg_mapdata = map->data;
\r
851 map->tiles->tileHeight = 16;
\r
852 map->tiles->tileWidth = 16;
\r
853 map->tiles->rows = 1;
\r
854 map->tiles->cols = 1;
\r
855 #ifdef __DEBUG_MAP__
\r
856 dbg_maptext = true;
\r
859 #ifdef __DEBUG_MAP__
\r
860 else dbg_maptext = false;
\r
865 //TODO: player position here
\r
866 void mapGoTo(map_view_t *mv, int tx, int ty)
\r
871 mapinitmapview(mv, tx, ty);
\r
873 /* draw the tiles */
\r
874 modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 0);
\r
876 i=mv[0].ty * mv[0].map->width + mv[0].tx;
\r
877 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
878 mapDrawWRow(&mv[0], tx-1, ty, py);
\r
879 i+=mv->map->width - tx;
\r
881 if(!pageploop) modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height);
\r
883 // unsigned int k,j,o;
\r
884 // /* fill screen with a distinctive pattern */
\r
885 // for (k=0;k < vga_state.vga_width;k++) {
\r
887 // vga_write_sequencer(0x02/*map mask*/,1 << (k&3));
\r
888 // 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
889 // vga_state.vga_graphics_ram[o] = (k^j)&15; // VRL samples put all colors in first 15!
\r
892 modexCopyPageRegion(mv[3].page, mv[0].page, 0/**/, 0/**/, 0, 0, 24, 32);
\r
895 void mapinitmapview(map_view_t *mv, int tx, int ty)
\r
897 /* set up the coordinates */
\r
898 mv[0].tx = mv[1].tx = tx;
\r
899 mv[0].ty = mv[1].ty = ty;
\r
900 mv[0].page->dx = mv[1].page->dx = mv[2].page->dx = mv[3].page->dx = mv->map->tiles->tileWidth;
\r
901 mv[0].page->dy = mv[1].page->dy = mv[2].page->dy = mv[3].page->dy = mv->map->tiles->tileHeight;
\r
903 /* set up the thresholds */
\r
904 mv[0].dxThresh = mv[1].dxThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileWidth * 2;
\r
905 mv[0].dyThresh = mv[1].dyThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileHeight * 2;
\r
909 mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y)
\r
913 //word textx=0, texty=0;
\r
918 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 0); //currently the over scan color!
\r
922 rx = (((i-1) % ((t->data->width)/t->tileWidth)) * t->tileWidth);
\r
923 ry = (((i-1) / ((t->data->height)/t->tileHeight)) * t->tileHeight);
\r
924 ////0000printf("i=%d\n", i);
\r
925 #ifdef __DEBUG_MAP__
\r
926 switch(dbg_maptext)
\r
931 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, ((dbg_mapdata[i])+1));
\r
932 //modexprint(page, x, y, 1, 15, 0, (char const *)(t->debug_data[i]));
\r
934 modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
\r
935 /* then the sprite. note modding ram ptr means we just draw to (x&3,0) */
\r
936 //draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));
\r
937 //modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
\r
939 #ifdef __DEBUG_MAP__
\r
942 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, (dbg_mapdata[i])+1);
\r
943 //modexprintbig(page, x, y, 1, 15, 0, (t->debug_data));
\r
944 /*for(texty=0; texty<2; texty++)
\r
946 for(textx=0; textx<2; textx++)
\r
948 // modexprint(page, x+(textx*8), y+(texty*8), 1, (word)(t->debug_data), 0, (t->debug_data));
\r
957 void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *player, word poopoffset)
\r
961 poopoffset%=player[0].enti.speed;
\r
962 //printf("y: %d\n", poopoffset);
\r
963 /* the position within the map array */
\r
964 i=ty * mv->map->width + tx;
\r
965 for(x=poopoffset; x<(mv->page->sw+mv->dxThresh)/(poopoffset+1) && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
\r
967 /* we are in the map, so copy! */
\r
968 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
974 void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *player, word poopoffset)
\r
978 poopoffset%=player[0].enti.speed;
\r
979 //printf("x: %d\n", poopoffset);
\r
980 /* location in the map array */
\r
981 i=ty * mv->map->width + tx;
\r
983 /* We'll copy all of the columns in the screen,
\r
984 i + 1 row above and one below */
\r
985 for(y=poopoffset; y<(mv->page->sh+mv->dyThresh)/(poopoffset+1) && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
\r
987 /* we are in the map, so copy away! */
\r
988 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
990 i += mv->map->width;
\r
994 void mapDrawWRow(map_view_t *mv, int tx, int ty, word y)
\r
999 /* the position within the map array */
\r
1000 i=ty * mv->map->width + tx;
\r
1001 for(x=0; x<mv->page->sw+mv->dxThresh && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
\r
1003 /* we are in the map, so copy! */
\r
1004 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
1010 void mapDrawWCol(map_view_t *mv, int tx, int ty, word x)
\r
1015 /* location in the map array */
\r
1016 i=ty * mv->map->width + tx;
\r
1018 /* We'll copy all of the columns in the screen,
\r
1019 i + 1 row above and one below */
\r
1020 for(y=0; y<mv->page->sh+mv->dyThresh && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
\r
1022 /* we are in the map, so copy away! */
\r
1023 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
1025 i += mv->map->width;
\r
1034 boolean pageflipflop = 1;
\r
1035 boolean pageploop = 1;
\r
1038 void shinku(global_game_variables_t *gv)
\r
1040 word x = (0) + gv->video.page[/*!*/(gv->video.p)].dx; // follow the screen
\r
1041 word y = (0) + gv->video.page[/*!*/(gv->video.p)].dy; // follow the screen
\r
1042 word col = 7, bgcol = 0, type = 1;//w = 64, h = 8,
\r
1044 //modexCopyPageRegion(pip[1].page, pip[2].page, 16, 16, 16, 16, (14*8)+4, 8+4);
\r
1045 /* block copy to visible RAM from offscreen */
\r
1046 // vga_setup_wm1_block_copy();
\r
1047 // modexCopyPageRegion(&(gv->video.page[gv->video->sfip]), &(gv->video.page[!gv->video->sfip]), x, y, x+w, 0, w, h);
\r
1048 // o = *(gv->video.page[2].data); // source offscreen
\r
1049 // o2 = *(gv->video.page[gv->video->sfip].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride)
\r
1050 // 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
1051 /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */
\r
1052 // vga_restore_rm0wm0();
\r
1053 if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second))
\r
1055 // NTS: For some bizarre reason, gv->pee is not initialized, but the pointer is not NULL even
\r
1056 // though it should be. Instead it's NULL as a near pointer but contains a non-null
\r
1057 // segment value, so testing against NULL doesn't work. It is initialized properly if
\r
1058 // you call start_timer() though which uses near malloc. Rather than fight with that,
\r
1059 // I decided it would be better to declare a temp buffer statically and sprintf to that.
\r
1061 // This fixes *** Null pointer assignment detected error message in ZCROLL.EXE on exit.
\r
1062 sprintf(global_temp_status_text, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv));
\r
1063 //modexClearRegion(&(gv->video.page[gv->video->sfip]), x, y, w, h, 45);
\r
1064 modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, col, bgcol, global_temp_status_text);
\r
1065 gv->kurokku.tiku=0;
\r
1066 /* block copy to visible RAM from offscreen */
\r
1067 // vga_setup_wm1_block_copy();
\r
1068 // o = *(gv->video.page[gv->video->sfip].data); // source offscreen
\r
1069 // o2 = *(gv->video.page[2].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride)
\r
1070 // 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
1071 // modexCopyPageRegion(&(gv->video.page[gv->video->sfip]), &(gv->video.page[!gv->video->sfip]), x, y, x, 0, w, h);
\r
1072 /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */
\r
1073 // vga_restore_rm0wm0();
\r
1074 }else //copy dat sheet
\r
1075 gv->kurokku.tiku++;
\r
1077 switch(gv->kurokku.fpscap)
\r
1080 //modexprint(&(gv->video.page[gv->video->sfip]), x, y+8, type, col, bgcol, "sanic!");
\r
1081 gv->kurokku.frames_per_second=1;
\r
1084 //turn this off if XT
\r
1085 //modexWaitBorder();
\r
1086 vga_wait_for_vsync();
\r
1087 gv->kurokku.frames_per_second=60;
\r
1092 //vga_setup_wm1_block_copy();
\r
1093 //_fmemcpy((gv->video.page[(gv->video.p)]).data, (gv->video.page[(!gv->video.p)]).data, gv->video.page[(!gv->video.p)].pagesize);
\r
1094 //vga_restore_rm0wm0();
\r
1095 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
1096 modexShowPage(&(gv->video.page[gv->video.p]));
\r
1097 if(!pageploop) gv->video.p=!gv->video.p;
\r
1098 gv->video.r=!gv->video.r;
\r
1099 //0000gv->video.tickclk = ((*clockw)-gv->video.startclk)/18.2;
\r
1105 #define FRAME1 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 48, dire, 24, 32, PLAYERBMPDATAPTR);
\r
1106 #define FRAME2 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, dire, 24, 32, PLAYERBMPDATAPTR);
\r
1107 #define FRAME3 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 0, dire, 24, 32, PLAYERBMPDATAPTR);
\r
1108 #define FRAME4 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, dire, 24, 32, PLAYERBMPDATAPTR);
\r
1110 #define FRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 2+dire);
\r
1111 #define FRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+dire);
\r
1112 #define FRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, dire);
\r
1113 #define FRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+dire);
\r
1116 void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch)
\r
1118 sword x = player[pn].enti.x;
\r
1119 sword y = player[pn].enti.y;
\r
1120 sword bx = x+16; //buffer's x
\r
1121 sword by = y+16; //buffer's y
\r
1122 word dire=32; //direction
\r
1123 sword qq; //scroll offset
\r
1124 word ls = player[pn].enti.persist_aniframe;
\r
1126 switch(scrollswitch)
\r
1132 qq = ((player[pn].enti.q)*(player[pn].enti.speed));
\r
1136 y-=pip[0].map->tiles->tileHeight;
\r
1137 switch (player[pn].enti.d)
\r
1141 dire*=player[pn].enti.d;
\r
1147 dire*=(player[pn].enti.d-2);
\r
1155 dire*=(player[pn].enti.d-2);
\r
1161 dire*=(player[pn].enti.d+2);
\r
1168 modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 36);
\r
1170 //copy old bg to page0
\r
1171 //modexCopyPageRegion(pip[3].page, pip[0].page, bx, by, 0, 0, 20, 36);
\r
1173 //modexCopyPageRegion(pip[0].page, pip[3].page, 0, 0, x, y, 20, 36);
\r
1175 //modexCopyPageRegion(page_t *dest, page_t *src, word sx, word sy, word dx, word dy, word width, word height);
\r
1176 //modexCopyPageRegion(pip[3].page, pip[!(pip->video->p)].page, x-4, y-4, 0, 128, 28, 36);
\r
1177 /*modexCopyPageRegion(pip[pip->video->p].page,
\r
1178 pip[!(pip->video->p)].page, x-4, y-4, x-4, y-4, 28, 36);*/
\r
1179 // else modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 40);
\r
1195 // if(2>ls && ls>=1) { FRAME1 }else
\r
1196 // if(3>ls && ls>=2) { FRAME2 }else
\r
1197 // if(4>ls && ls>=3) { FRAME3 }else
\r
1198 // if(5>ls && ls>=4) { FRAME4 }
\r
1199 //modexCopyPageRegion(pip[0].page, pip[3].page, 0, 0, x, y, 24, 32);
\r
1200 //printf("x=%d y=%d bx=%d by=%d\n", x, y, bx, by);
\r
1205 void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch)
\r
1207 sword x = player[pn].enti.x;
\r
1208 sword y = player[pn].enti.y;
\r
1209 word dire=10; //direction
\r
1210 sword qq; //scroll offset
\r
1211 word ls = player[pn].enti.persist_aniframe;
\r
1215 switch(scrollswitch)
\r
1221 qq = ((player[pn].enti.q)*(player[pn].enti.speed));
\r
1227 y-=pip[0].map->tiles->tileHeight;
\r
1228 switch (player[pn].enti.d)
\r
1232 dire*=player[pn].enti.d+1;
\r
1237 dire*=(player[pn].enti.d-1);
\r
1244 dire*=(player[pn].enti.d-1);
\r
1249 dire*=(player[pn].enti.d+3);
\r
1254 //setting xy position
\r
1255 player[pn].ent->spri->x = x;
\r
1256 player[pn].ent->spri->y = y;
\r
1258 //#define FRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 2+dire);
\r
1259 //#define FRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 1+dire);
\r
1260 //#define FRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, dire);
\r
1261 //#define FRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 1+dire);
\r
1263 //#define DRAWFRAME if (i == -1) return; oldanimate_spri(player[pn].ent->spri, pip->video)
\r
1264 #define DRAWFRAME if (i == -1) return; animate_spri(player[pn].ent->spri, pip->video)
\r
1265 #define NFRAME1 i = set_anim_by_id(player[pn].ent->spri, 2+dire); DRAWFRAME;
\r
1266 #define NFRAME2 i = set_anim_by_id(player[pn].ent->spri, 1+dire); DRAWFRAME;
\r
1267 #define NFRAME3 i = set_anim_by_id(player[pn].ent->spri, dire); DRAWFRAME;
\r
1268 #define NFRAME4 i = set_anim_by_id(player[pn].ent->spri, 2+dire); DRAWFRAME;
\r
1270 #define NFRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 2+dire);
\r
1271 #define NFRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+dire);
\r
1272 #define NFRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, dire);
\r
1273 #define NFRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+dire);
\r
1298 boolean boundary_check(int x, int y, int dx, int dy, int h, int w)
\r
1300 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
1303 boolean coll_check(int x, int y, int dx, int dy, map_view_t *map_v)
\r
1305 // Assume everything crosses at most 1 tile at once
\r
1306 return dx && 1;//crossable_tile(x + dx, map_v) || dy && crossable_tile(y + dy, map_v);
\r
1309 boolean ZC_walk2(entity_t *ent, map_view_t *map_v)
\r
1329 if(coll_check(ent->x, ent->y, dx, dy, map_v))
\r
1333 // Start animation
\r
1334 // Mark next tile as occupied
\r
1335 // Mark this tile as vacant
\r
1341 void player_walk(player_t *player, map_view_t *map_v){
\r
1343 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
1345 mapScroll(map_v, player);
\r
1346 // (Un)load stuff?
\r
1350 void near mapScroll(map_view_t *mv, player_t *player)
\r
1352 //word x, y; /* coordinate for drawing */
\r
1355 mv->delta += player->dx | player->dy;
\r
1356 delta = mv->delta;
\r
1357 mv->d = (player->dx) ? (player->dx > 0) ? 3 : 1 : (player->dy) ? (player->dy > 0) ? 4 : 0 : 2;
\r
1363 if(!(delta + mv->dxThresh))
\r
1373 if(!(delta + mv->dyThresh))
\r