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 INC_PER_FRAME_PRINT sprintf(global_temp_status_text, "%u", player[pn].enti.persist_aniframe);\
\r
28 modexprint(&(pip->video->page[0]), player[pn].enti.x-(8*player[pn].enti.persist_aniframe), player[pn].enti.y-TILEWH-(8*player[pn].enti.persist_aniframe), 1, 20, 1, global_temp_status_text);
\r
30 #define WALKTYPE_FRAM_PRINT INC_PER_FRAME_PRINT
\r
31 //walktypeinfo(player, pn);
\r
32 //modexprint(&(pip->video->page[0]), player[pn].enti.x-(8*player[pn].enti.persist_aniframe)+8, player[pn].enti.y-TILEWH-(8*player[pn].enti.persist_aniframe), 1, 20, 1, global_temp_status_text);
\r
34 #define PERSIST_ANIFRAME_INIT 1
\r
35 #define Q_INIT PERSIST_ANIFRAME_INIT
\r
36 #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 = PERSIST_ANIFRAME_INIT;
\r
38 void ZC_walk(map_view_t *pip, player_t *player, word pn)
\r
40 switch(player[pn].enti.d)
\r
44 //0000pip[0].video->startclk = (*clockw);
\r
48 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
49 !(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
51 player[pn].walktype=2;
\r
52 if(player[pn].enti.q<=player[pn].enti.spt)
\r
55 ANIMATESPRIFUN(pip, player, pn, 1);
\r
56 ScrollRight(pip, player, 3, pn);
\r
57 ScrollRight(pip, player, 2, pn);
\r
58 mapScrollRight(pip, player, (pip[0].video->p), pn);
\r
59 player[pn].enti.q++;
\r
60 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
61 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
63 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
65 player[pn].walktype=1;
\r
66 if(player[pn].enti.q<=player[pn].enti.spt)
\r
69 player[pn].enti.x+=(player[pn].enti.speed);
\r
70 ANIMATESPRIFUN(pip, player, pn, 0);
\r
71 player[pn].enti.q++;
\r
72 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
76 player[pn].walktype=0;
\r
78 //modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATAPTR);
\r
79 ANIMATESPRIFUN(pip, player, pn, 0);
\r
81 // modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 14);
\r
83 player[pn].enti.d = 2;
\r
85 player[pn].enti.triggerx = player[pn].enti.tx+1;
\r
86 player[pn].enti.triggery = player[pn].enti.ty;
\r
87 //WALKTYPE_FRAM_PRINT
\r
91 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
92 !(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
94 player[pn].walktype=2;
\r
95 if(player[pn].enti.q<=player[pn].enti.spt)
\r
98 ANIMATESPRIFUN(pip, player, pn, 1);
\r
99 ScrollLeft(pip, player, 3, pn);
\r
100 ScrollLeft(pip, player, 2, pn);
\r
101 mapScrollLeft(pip, player, (pip[0].video->p), pn);
\r
102 player[pn].enti.q++;
\r
103 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
104 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
106 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
108 player[pn].walktype=1;
\r
109 if(player[pn].enti.q<=player[pn].enti.spt)
\r
112 player[pn].enti.x-=(player[pn].enti.speed);
\r
113 ANIMATESPRIFUN(pip, player, pn, 0);
\r
114 player[pn].enti.q++;
\r
115 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
119 player[pn].walktype=0;
\r
121 //modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATAPTR);
\r
122 ANIMATESPRIFUN(pip, player, pn, 0);
\r
124 // modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 10);
\r
126 player[pn].enti.d = 2;
\r
128 player[pn].enti.triggerx = player[pn].enti.tx-1;
\r
129 player[pn].enti.triggery = player[pn].enti.ty;
\r
130 //WALKTYPE_FRAM_PRINT
\r
134 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
135 !(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
137 player[pn].walktype=2;
\r
138 if(player[pn].enti.q<=player[pn].enti.spt)
\r
141 ANIMATESPRIFUN(pip, player, pn, 1);
\r
142 ScrollDown(pip, player, 3, pn);
\r
143 ScrollDown(pip, player, 2, pn);
\r
144 mapScrollDown(pip, player, (pip[0].video->p), pn);
\r
145 player[pn].enti.q++;
\r
146 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
147 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
149 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
151 player[pn].walktype=1;
\r
152 if(player[pn].enti.q<=player[pn].enti.spt)
\r
155 player[pn].enti.y+=(player[pn].enti.speed);
\r
156 ANIMATESPRIFUN(pip, player, pn, 0);
\r
157 player[pn].enti.q++;
\r
158 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
162 player[pn].walktype=0;
\r
164 //modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATAPTR);
\r
165 ANIMATESPRIFUN(pip, player, pn, 0);
\r
167 // modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 9);
\r
169 player[pn].enti.d = 2;
\r
171 player[pn].enti.triggerx = player[pn].enti.tx;
\r
172 player[pn].enti.triggery = player[pn].enti.ty+1;
\r
173 //WALKTYPE_FRAM_PRINT
\r
177 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
178 !(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
180 player[pn].walktype=2;
\r
181 if(player[pn].enti.q<=player[pn].enti.spt)
\r
184 ANIMATESPRIFUN(pip, player, pn, 1);
\r
185 ScrollUp(pip, player, 3, pn);
\r
186 ScrollUp(pip, player, 2, pn);
\r
187 mapScrollUp(pip, player, (pip[0].video->p), pn);
\r
188 player[pn].enti.q++;
\r
189 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
190 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
192 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
194 player[pn].walktype=1;
\r
195 if(player[pn].enti.q<=player[pn].enti.spt)
\r
198 player[pn].enti.y-=(player[pn].enti.speed);
\r
199 ANIMATESPRIFUN(pip, player, 0, pn);
\r
200 player[pn].enti.q++;
\r
201 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
205 player[pn].walktype=0;
\r
207 //modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATAPTR);
\r
208 ANIMATESPRIFUN(pip, player, pn, 0);
\r
210 // modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 12);
\r
212 player[pn].enti.d = 2;
\r
214 player[pn].enti.triggerx = player[pn].enti.tx;
\r
215 player[pn].enti.triggery = player[pn].enti.ty-1;
\r
216 //WALKTYPE_FRAM_PRINT
\r
219 //if(player[pn].enti.d!=2 && pip[0].video->rs) IN_UserInput(1,1);
\r
220 //else if(!pip[0].video->rs) delay(500);
\r
225 src/lib/scroll16.c: mv[0].video->r=1;
\r
226 src/lib/scroll16.c: mv[0].video->r=1;
\r
227 src/lib/scroll16.c: mv[0].video->r=1;
\r
228 src/lib/scroll16.c: mv[0].video->r=1;
\r
229 src/lib/scroll16.c: pip->video->r=1;
\r
230 src/lib/scroll16.c: mv->video->r=1;
\r
233 void oldwalk(map_view_t *pip, player_t *player, word pn)
\r
235 //printf("player[%d].d=%d\n", pn, player[pn].enti.d);
\r
236 switch(player[pn].enti.d)
\r
240 //0000pip[0].video->startclk = (*clockw);
\r
244 //printf("pip[0].page->tilesw=%d ", pip[0].page->tilesw); printf("pip[0].page->tw=%d\n", pip[0].page->tw);
\r
245 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
246 !(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
248 if(player[pn].enti.q<=player[pn].enti.spt)
\r
251 ANIMATESPRIFUN(pip, player, pn, 1);
\r
252 ScrollRight(pip, player, 3, pn);
\r
253 ScrollRight(pip, player, 2, pn);
\r
254 //mapScrollRight(pip, player, !(pip[0].video->p), pn);
\r
255 mapScrollRight(pip, player, (pip[0].video->p), pn);
\r
256 if(!pageflipflop) modexShowPage(pip[1].page);
\r
257 player[pn].enti.q++;
\r
258 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
259 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
261 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
263 if(player[pn].enti.q<=player[pn].enti.spt)
\r
266 player[pn].enti.x+=(player[pn].enti.speed);
\r
267 ANIMATESPRIFUN(pip, player, pn, 0);
\r
268 if(!pageflipflop) modexShowPage(pip[1].page);
\r
269 player[pn].enti.q++;
\r
270 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
274 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
276 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATAPTR);
\r
278 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 14);
\r
280 if(!pageflipflop) modexShowPage(pip[1].page);
\r
281 player[pn].enti.d = 2;
\r
283 player[pn].enti.triggerx = player[pn].enti.tx+1;
\r
284 player[pn].enti.triggery = player[pn].enti.ty;
\r
289 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
290 !(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
292 if(player[pn].enti.q<=player[pn].enti.spt)
\r
295 ANIMATESPRIFUN(pip, player, pn, 1);
\r
296 ScrollLeft(pip, player, 3, pn);
\r
297 ScrollLeft(pip, player, 2, pn);
\r
298 //mapScrollLeft(pip, player, !(pip[0].video->p), pn);
\r
299 mapScrollLeft(pip, player, (pip[0].video->p), pn);
\r
300 if(!pageflipflop) modexShowPage(pip[1].page);
\r
301 player[pn].enti.q++;
\r
302 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
303 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
305 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
307 if(player[pn].enti.q<=player[pn].enti.spt)
\r
310 player[pn].enti.x-=(player[pn].enti.speed);
\r
311 ANIMATESPRIFUN(pip, player, pn, 0);
\r
312 if(!pageflipflop) modexShowPage(pip[1].page);
\r
313 player[pn].enti.q++;
\r
314 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
318 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
320 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATAPTR);
\r
322 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 10);
\r
324 if(!pageflipflop) modexShowPage(pip[1].page);
\r
325 player[pn].enti.d = 2;
\r
327 player[pn].enti.triggerx = player[pn].enti.tx-1;
\r
328 player[pn].enti.triggery = player[pn].enti.ty;
\r
333 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
334 !(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
336 if(player[pn].enti.q<=player[pn].enti.spt)
\r
339 ANIMATESPRIFUN(pip, player, pn, 1);
\r
340 ScrollDown(pip, player, 3, pn);
\r
341 ScrollDown(pip, player, 2, pn);
\r
342 //mapScrollDown(pip, player, !(pip[0].video->p), pn);
\r
343 mapScrollDown(pip, player, (pip[0].video->p), pn);
\r
344 if(!pageflipflop) modexShowPage(pip[1].page);
\r
345 player[pn].enti.q++;
\r
346 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
347 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
349 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
351 if(player[pn].enti.q<=player[pn].enti.spt)
\r
354 player[pn].enti.y+=(player[pn].enti.speed);
\r
355 ANIMATESPRIFUN(pip, player, pn, 0);
\r
356 if(!pageflipflop) modexShowPage(pip[1].page);
\r
357 player[pn].enti.q++;
\r
358 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
362 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
364 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATAPTR);
\r
366 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 9);
\r
368 if(!pageflipflop) modexShowPage(pip[1].page);
\r
369 player[pn].enti.d = 2;
\r
371 player[pn].enti.triggerx = player[pn].enti.tx;
\r
372 player[pn].enti.triggery = player[pn].enti.ty+1;
\r
377 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
378 !(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
380 if(player[pn].enti.q<=player[pn].enti.spt)
\r
383 ANIMATESPRIFUN(pip, player, pn, 1);
\r
384 ScrollUp(pip, player, 3, pn);
\r
385 ScrollUp(pip, player, 2, pn);
\r
386 //mapScrollUp(pip, player, !(pip[0].video->p), pn);
\r
387 mapScrollUp(pip, player, (pip[0].video->p), pn);
\r
388 if(!pageflipflop) modexShowPage(pip[1].page);
\r
389 player[pn].enti.q++;
\r
390 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
391 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
393 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
395 if(player[pn].enti.q<=player[pn].enti.spt)
\r
398 player[pn].enti.y-=(player[pn].enti.speed);
\r
399 ANIMATESPRIFUN(pip, player, 0, pn);
\r
400 if(!pageflipflop) modexShowPage(pip[1].page);
\r
401 player[pn].enti.q++;
\r
402 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
406 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
408 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATAPTR);
\r
410 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 12);
\r
412 if(!pageflipflop) modexShowPage(pip[1].page);
\r
413 player[pn].enti.d = 2;
\r
415 player[pn].enti.triggerx = player[pn].enti.tx;
\r
416 player[pn].enti.triggery = player[pn].enti.ty-1;
\r
422 void ZC_panPageManual(map_view_t *pip, player_t *player, word pn)
\r
424 #define SHOWMVFUN_ ZC_ShowMV(pip, 0, 0);
\r
425 switch(player[pn].enti.d)
\r
429 if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->tw < pip[0].page->tilesw)
\r
431 if(player[pn].enti.q<=player[pn].enti.spt)
\r
433 pip[0].page->dx+=4;
\r
435 player[pn].enti.q++;
\r
436 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; pip[0].tx++; }
\r
442 if(pip[0].tx > 0 && pip[0].tx+pip[0].page->tw <= pip[0].page->tilesw)
\r
444 if(player[pn].enti.q<=player[pn].enti.spt)
\r
446 pip[0].page->dx-=4;
\r
448 player[pn].enti.q++;
\r
449 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; pip[0].tx--; }
\r
455 if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->th < pip[0].page->tilesh)
\r
457 if(player[pn].enti.q<=player[pn].enti.spt)
\r
459 pip[0].page->dy+=4;
\r
461 player[pn].enti.q++;
\r
462 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; pip[0].ty++; }
\r
468 if(pip[0].ty > 0 && pip[0].ty+pip[0].page->th <= pip[0].page->tilesh)
\r
470 if(player[pn].enti.q<=player[pn].enti.spt)
\r
472 pip[0].page->dy-=4;
\r
474 player[pn].enti.q++;
\r
475 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; pip[0].ty--; }
\r
484 void ZC_MVSetup(map_view_t *pip, map_t *map, global_game_variables_t *gv)
\r
489 pip[0].page = &gv->video.page[0];
\r
491 pip[0].video = &gv->video;
\r
492 pip[0].panp = &gv->video.panp;
\r
493 ZC_MVInit(pip, 1, 1);
\r
495 for(i=ZC_MVI;i<gv->video.num_of_pages;i++)
\r
497 pip[i].page = &gv->video.page[i];
\r
498 pip[i].map = pip[0].map;
\r
499 pip[i].video = pip[0].video;
\r
500 pip[i].panp = pip[0].panp;
\r
508 void ZC_MVInit(map_view_t *pip, int tx, int ty)
\r
512 //pip[0].tx = pip[1].tx = tx;
\r
513 //pip[0].ty = pip[1].ty = ty;
\r
516 void ZC_ShowMV(map_view_t *moo, boolean vsync, boolean sr)
\r
518 word high_address, low_address, offset;
\r
521 /* calculate offset */
\r
522 offset = (word) moo[moo[0].video->panp].page->data;
\r
523 offset += moo[0].page->dy * (moo[0].page->width >> 2 );
\r
524 offset += moo[0].page->dx >> 2;
\r
526 /* calculate crtcOffset according to virtual width */
\r
530 crtcOffset = moo[0].page->sw >> 3;
\r
534 crtcOffset = moo[0].page->width >> 3;
\r
538 high_address = HIGH_ADDRESS | (offset & 0xff00);
\r
539 low_address = LOW_ADDRESS | (offset << 8);
\r
541 /* wait for appropriate timing and then program CRTC */
\r
542 if(vsync) while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE));
\r
543 outpw(CRTC_INDEX, high_address);
\r
544 outpw(CRTC_INDEX, low_address);
\r
545 outp(CRTC_INDEX, 0x13);
\r
546 outp(CRTC_DATA, crtcOffset);
\r
548 /* wait for one retrace */
\r
549 if(vsync) while (!(inp(INPUT_STATUS_1) & VRETRACE));
\r
551 /* do PEL panning here */
\r
552 outp(AC_INDEX, 0x33);
\r
553 outp(AC_INDEX, (moo[0].page->dx & 0x03) << 1);
\r
557 allocMap(int w, int h) {
\r
562 result.data = malloc(sizeof(byte) * w * h);
\r
563 //result.data = (byte *)alloc_emem(((int)sizeof(byte) * w * h)/1024);
\r
564 if(isEMS() || checkEMS())
\r
567 //emmhandle = mallocEMS(coretotalEMS());//alloc_emem((int)sizeof(map))
\r
568 mm.length=sizeof(result);
\r
570 mm.sourceOff=ptr2long(&result);
\r
571 mm.destH=emmhandle;
\r
573 ist = move_emem(&mm);
\r
574 if(!ist){ dealloc_emem(emmhandle); exit(5); }
\r
575 printf("%d\n", coretotalEMS());
\r
582 initMap(map_t *map) {
\r
583 // just a place holder to fill out an alternating pattern
\r
587 //if(!isEMS() || !checkEMS())
\r
588 // map->tiles = malloc(sizeof(tiles_t));
\r
590 // map->tiles = (tiles_t *)alloc_emem(sizeof(tiles_t));
\r
592 //create the tile set
\r
593 //if(!isEMS() || !checkEMS())
\r
594 // map->tiles->data = malloc(sizeof(bitmap_t));
\r
596 // map->tiles->data = (bitmap_t *)alloc_emem(sizeof(bitmap_t));
\r
597 // map->tiles->data->width = (TILEWH);
\r
598 // map->tiles->data->height= TILEWH;
\r
599 //if(!isEMS() || !checkEMS())
\r
600 // map->tiles->data->data = malloc((TILEWH*2)*TILEWH);
\r
602 // map->tiles->data->data = (byte *)alloc_emem((TILEWH*2)*TILEWH);
\r
603 // map->tiles->tileHeight = TILEWH;
\r
604 // map->tiles->tileWidth =TILEWH;
\r
605 // map->tiles->rows = 1;
\r
606 // map->tiles->cols = 1;//2;
\r
609 //for(y=0; y<map->height; y++) {
\r
610 //for(x=0; x<map->width; x++) {
\r
612 for(yy=0; yy<TILEWH; yy++) {
\r
613 for(xx=0; xx<(TILEWH); xx++) {
\r
615 map->tiles->data->data[i+1] = map->data[q];//28;//0x24;
\r
616 // printf("[%d]", map->tiles->data->data[i]);
\r
618 //map->tiles->data->data[i] = map->data[q];//0;//0x34;
\r
619 //printf("]%d[==[%d]", i, map->tiles->data->data[i]);
\r
625 // printf("[%d]", map->data[q]);
\r
632 for(y=0; y<map->height; y++) {
\r
633 for(x=0; x<map->width; x++) {
\r
634 // map->data[i]=255;
\r
635 printf("[%d]", map->data[i]);
\r
636 //tile = tile ? 0 : 1;
\r
639 //tile = tile ? 0 : 1;
\r
643 void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
\r
645 word x;//, y; /* coordinate for drawing */
\r
647 /* increment the pixel position and update the page */
\r
648 mv[id].page[0].dx += player[plid].enti.speed;
\r
650 /* check to see if this changes the tile */
\r
651 if(mv[id].page[0].dx >= mv[id].dxThresh )
\r
653 /* go forward one tile */
\r
655 /* Snap the origin forward */
\r
656 mv[id].page->data += 4;
\r
658 mv[id].page[0].dx = mv[id].map->tiles->tileWidth;
\r
661 /* draw the next column */
\r
662 x= mv[0].page->sw + mv[id].map->tiles->tileWidth;
\r
663 if(player[plid].enti.q%4)
\r
665 mapDrawCol(&mv[0], mv[0].tx + mv[0].page->tw, mv[0].ty-1, x, player, mv->page[0].dx);
\r
667 if(!pageflipflop && !pageploop)
\r
668 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
673 void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
\r
675 word x;//,y; /* coordinate for drawing */
\r
677 /* decrement the pixel position and update the page */
\r
678 mv[id].page[0].dx -= player[plid].enti.speed;
\r
680 /* check to see if this changes the tile */
\r
681 if(mv[id].page[0].dx == 0)
\r
683 /* go backward one tile */
\r
685 /* Snap the origin backward */
\r
686 mv[id].page->data -= 4;
\r
688 mv[id].page[0].dx = mv[id].map->tiles->tileWidth;
\r
691 /* draw the next column */
\r
693 if(player[plid].enti.q%4)
\r
695 mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, mv->page[0].dx);
\r
697 if(!pageflipflop && !pageploop)
\r
698 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
703 void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
\r
705 word y;//x, /* coordinate for drawing */
\r
707 /* decrement the pixel position and update the page */
\r
708 mv[id].page[0].dy -= player[plid].enti.speed;
\r
710 /* check to see if this changes the tile */
\r
711 if(mv[id].page[0].dy == 0 )
\r
713 /* go down one tile */
\r
715 /* Snap the origin downward */
\r
716 mv[id].page->data -= mv[id].page->pi;
\r
718 mv[id].page[0].dy = mv[id].map->tiles->tileHeight;
\r
721 /* draw the next row */
\r
723 if(player[plid].enti.q%3)
\r
725 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, mv->page[0].dy);
\r
727 if(!pageflipflop && !pageploop)
\r
728 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
732 void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)
\r
734 word y;//x, /* coordinate for drawing */
\r
736 /* increment the pixel position and update the page */
\r
737 mv[id].page[0].dy += player[plid].enti.speed;
\r
739 /* check to see if this changes the tile */
\r
740 if(mv[id].page[0].dy >= mv[id].dyThresh )
\r
742 /* go down one tile */
\r
744 /* Snap the origin downward */
\r
745 mv[id].page->data += mv[id].page->pi;
\r
747 mv[id].page[0].dy = mv[id].map->tiles->tileHeight;
\r
750 /* draw the next row */
\r
751 y= mv[0].page->sh + mv[id].map->tiles->tileHeight;
\r
752 if(player[plid].enti.q%3)
\r
754 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+mv[0].page->th, y, player, mv->page[0].dy);
\r
756 if(!pageflipflop && !pageploop)
\r
757 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
762 //TODO finish this wwww
\r
763 void near ScrollRight(map_view_t *mv, player_t *player, word id, word plid)
\r
765 /* increment the pixel position and update the page */
\r
766 mv[id].page->dx += player[plid].enti.speed;
\r
768 /* check to see if this changes the tile */
\r
769 if(mv[id].page->dx >= mv[0].dxThresh )
\r
771 // vga_setup_wm1_block_copy();
\r
772 // _fmemmove(mv[id].page->data+4, mv[id].page->data, mv[id].page->pagesize);
\r
773 // vga_restore_rm0wm0();
\r
774 /* Snap the origin forward */
\r
775 mv[id].page->data += 4;
\r
776 mv[id].page->dx = mv[0].map->tiles->tileWidth;
\r
780 void near ScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
\r
782 /* decrement the pixel position and update the page */
\r
783 mv[id].page->dx -= player[plid].enti.speed;
\r
785 /* check to see if this changes the tile */
\r
786 if(mv[id].page->dx == 0)
\r
788 // vga_setup_wm1_block_copy();
\r
789 // _fmemmove(mv[id].page->data-4, mv[id].page->data, mv[id].page->pagesize);
\r
790 // vga_restore_rm0wm0();
\r
791 /* Snap the origin backward */
\r
792 mv[id].page->data -= 4;
\r
793 mv[id].page->dx = mv[0].map->tiles->tileWidth;
\r
797 void near ScrollUp(map_view_t *mv, player_t *player, word id, word plid)
\r
799 /* decrement the pixel position and update the page */
\r
800 mv[id].page->dy -= player[plid].enti.speed;
\r
802 /* check to see if this changes the tile */
\r
803 if(mv[id].page->dy == 0)
\r
805 // vga_setup_wm1_block_copy();
\r
806 // _fmemmove(mv[id].page->data-mv[id].page->pi, mv[id].page->data, mv[id].page->pagesize);
\r
807 // vga_restore_rm0wm0();
\r
808 /* Snap the origin backward */
\r
809 mv[id].page->data -= mv[id].page->pi;
\r
810 mv[id].page->dy = mv[0].map->tiles->tileWidth;
\r
814 void near ScrollDown(map_view_t *mv, player_t *player, word id, word plid)
\r
816 /* increment the pixel position and update the page */
\r
817 mv[id].page->dy += player[plid].enti.speed;
\r
819 /* check to see if this changes the tile */
\r
820 if(mv[id].page->dy >= mv[0].dxThresh )
\r
822 // vga_setup_wm1_block_copy();
\r
823 // _fmemmove(mv[id].page->data+mv[id].page->pi, mv[id].page->data, mv[id].page->pagesize);
\r
824 // vga_restore_rm0wm0();
\r
825 /* Snap the origin forward */
\r
826 mv[id].page->data += mv[id].page->pi;
\r
827 mv[id].page->dy = mv[0].map->tiles->tileWidth;
\r
831 //===========================================================================
\r
832 //TODO: put player in starting position of assigned spot on map
\r
833 //default player position on the viewable map
\r
834 void playerXYpos(int x, int y, player_t *player, map_view_t *pip, nibble pn)
\r
836 player[pn].enti.tx = x + pip[0].tx + pip[0].page->tilemidposscreenx;
\r
837 player[pn].enti.ty = y + pip[0].ty + pip[0].page->tilemidposscreeny;
\r
839 //===========================================================================
\r
841 sword chkmap(map_t *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 1, 1, \
\r
853 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
\r
854 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
855 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
856 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
\r
857 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
858 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, \
\r
859 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
860 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 1, 2, 3, 4 };*/
\r
861 //check for failed to load map
\r
862 if((map->width == map->height == 0) && (q>0))
\r
864 //initiate a null map!
\r
865 map->width=MAPW;///2;
\r
866 map->height=MAPH;///2;
\r
867 // map->data = malloc(((map->width*map->height)+1)*sizeof(byte));
\r
869 map->tiles = malloc(sizeof(tiles_t));
\r
870 //fix this to be far~
\r
871 // bp = bitmapLoadPcx("data/ed.pcx");
\r
872 // map->tiles->data = &bp;
\r
873 #ifdef __DEBUG_MAP__
\r
874 dbg_mapdata = map->data;
\r
876 map->tiles->tileHeight = 16;
\r
877 map->tiles->tileWidth = 16;
\r
878 map->tiles->rows = 1;
\r
879 map->tiles->cols = 1;
\r
880 #ifdef __DEBUG_MAP__
\r
881 dbg_maptext = true;
\r
884 #ifdef __DEBUG_MAP__
\r
885 else dbg_maptext = false;
\r
890 //TODO: player position here
\r
891 void mapGoTo(map_view_t *mv, int tx, int ty)
\r
896 mapinitmapview(mv, tx, ty);
\r
898 /* draw the tiles */
\r
899 modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 0);
\r
901 i=mv[0].ty * mv[0].map->width + mv[0].tx;
\r
902 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
903 mapDrawWRow(&mv[0], tx-1, ty, py);
\r
904 i+=mv->map->width - tx;
\r
906 if(!pageploop) modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height);
\r
908 // unsigned int k,j,o;
\r
909 // /* fill screen with a distinctive pattern */
\r
910 // for (k=0;k < vga_state.vga_width;k++) {
\r
912 // vga_write_sequencer(0x02/*map mask*/,1 << (k&3));
\r
913 // 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
914 // vga_state.vga_graphics_ram[o] = (k^j)&15; // VRL samples put all colors in first 15!
\r
917 modexCopyPageRegion(mv[3].page, mv[0].page, 0/**/, 0/**/, 0, 0, 24, 32);
\r
920 void mapinitmapview(map_view_t *mv, int tx, int ty)
\r
922 /* set up the coordinates */
\r
923 mv[0].tx = mv[1].tx = tx;
\r
924 mv[0].ty = mv[1].ty = ty;
\r
925 mv[0].page->dx = mv[1].page->dx = mv[2].page->dx = mv[3].page->dx = mv->map->tiles->tileWidth;
\r
926 mv[0].page->dy = mv[1].page->dy = mv[2].page->dy = mv[3].page->dy = mv->map->tiles->tileHeight;
\r
928 /* set up the thresholds */
\r
929 mv[0].dxThresh = mv[1].dxThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileWidth * 2;
\r
930 mv[0].dyThresh = mv[1].dyThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileHeight * 2;
\r
934 mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y)
\r
938 //word textx=0, texty=0;
\r
943 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 0); //currently the over scan color!
\r
947 rx = (((i-1) % ((t->data->width)/t->tileWidth)) * t->tileWidth);
\r
948 ry = (((i-1) / ((t->data->height)/t->tileHeight)) * t->tileHeight);
\r
949 ////0000printf("i=%d\n", i);
\r
950 #ifdef __DEBUG_MAP__
\r
951 switch(dbg_maptext)
\r
956 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, ((dbg_mapdata[i])+1));
\r
957 //modexprint(page, x, y, 1, 15, 0, (char const *)(t->debug_data[i]));
\r
959 modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
\r
960 /* then the sprite. note modding ram ptr means we just draw to (x&3,0) */
\r
961 //draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));
\r
962 //modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
\r
964 #ifdef __DEBUG_MAP__
\r
967 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, (dbg_mapdata[i])+1);
\r
968 //modexprintbig(page, x, y, 1, 15, 0, (t->debug_data));
\r
969 /*for(texty=0; texty<2; texty++)
\r
971 for(textx=0; textx<2; textx++)
\r
973 // modexprint(page, x+(textx*8), y+(texty*8), 1, (word)(t->debug_data), 0, (t->debug_data));
\r
982 void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *player, word poopoffset)
\r
986 poopoffset%=player[0].enti.speed;
\r
987 //printf("y: %d\n", poopoffset);
\r
988 /* the position within the map array */
\r
989 i=ty * mv->map->width + tx;
\r
990 for(x=poopoffset; x<(mv->page->sw+mv->dxThresh)/(poopoffset+1) && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
\r
992 /* we are in the map, so copy! */
\r
993 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
999 void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *player, word poopoffset)
\r
1003 poopoffset%=player[0].enti.speed;
\r
1004 //printf("x: %d\n", poopoffset);
\r
1005 /* location in the map array */
\r
1006 i=ty * mv->map->width + tx;
\r
1008 /* We'll copy all of the columns in the screen,
\r
1009 i + 1 row above and one below */
\r
1010 for(y=poopoffset; y<(mv->page->sh+mv->dyThresh)/(poopoffset+1) && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
\r
1012 /* we are in the map, so copy away! */
\r
1013 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
1015 i += mv->map->width;
\r
1019 void mapDrawWRow(map_view_t *mv, int tx, int ty, word y)
\r
1024 /* the position within the map array */
\r
1025 i=ty * mv->map->width + tx;
\r
1026 for(x=0; x<mv->page->sw+mv->dxThresh && tx < mv->map->width; x+=mv->map->tiles->tileWidth, tx++) {
\r
1028 /* we are in the map, so copy! */
\r
1029 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
1035 void mapDrawWCol(map_view_t *mv, int tx, int ty, word x)
\r
1040 /* location in the map array */
\r
1041 i=ty * mv->map->width + tx;
\r
1043 /* We'll copy all of the columns in the screen,
\r
1044 i + 1 row above and one below */
\r
1045 for(y=0; y<mv->page->sh+mv->dyThresh && ty < mv->map->height; y+=mv->map->tiles->tileHeight, ty++) {
\r
1047 /* we are in the map, so copy away! */
\r
1048 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y);
\r
1050 i += mv->map->width;
\r
1059 boolean pageflipflop = 1;
\r
1060 boolean pageploop = 1;
\r
1063 void shinku(global_game_variables_t *gv)
\r
1065 word x = (0) + gv->video.page[/*!*/(gv->video.p)].dx; // follow the screen
\r
1066 word y = (0) + gv->video.page[/*!*/(gv->video.p)].dy; // follow the screen
\r
1067 word col = 7, bgcol = 0, type = 1;//w = 64, h = 8,
\r
1069 //modexCopyPageRegion(pip[1].page, pip[2].page, 16, 16, 16, 16, (14*8)+4, 8+4);
\r
1070 /* block copy to visible RAM from offscreen */
\r
1071 // vga_setup_wm1_block_copy();
\r
1072 // modexCopyPageRegion(&(gv->video.page[gv->video->sfip]), &(gv->video.page[!gv->video->sfip]), x, y, x+w, 0, w, h);
\r
1073 // o = *(gv->video.page[2].data); // source offscreen
\r
1074 // o2 = *(gv->video.page[gv->video->sfip].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride)
\r
1075 // 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
1076 /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */
\r
1077 // vga_restore_rm0wm0();
\r
1078 if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second))
\r
1080 // NTS: For some bizarre reason, gv->pee is not initialized, but the pointer is not NULL even
\r
1081 // though it should be. Instead it's NULL as a near pointer but contains a non-null
\r
1082 // segment value, so testing against NULL doesn't work. It is initialized properly if
\r
1083 // you call start_timer() though which uses near malloc. Rather than fight with that,
\r
1084 // I decided it would be better to declare a temp buffer statically and sprintf to that.
\r
1086 // This fixes *** Null pointer assignment detected error message in ZCROLL.EXE on exit.
\r
1087 sprintf(global_temp_status_text, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv));
\r
1088 //modexClearRegion(&(gv->video.page[gv->video->sfip]), x, y, w, h, 45);
\r
1089 modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, col, bgcol, global_temp_status_text);
\r
1090 gv->kurokku.tiku=0;
\r
1091 /* block copy to visible RAM from offscreen */
\r
1092 // vga_setup_wm1_block_copy();
\r
1093 // o = *(gv->video.page[gv->video->sfip].data); // source offscreen
\r
1094 // o2 = *(gv->video.page[2].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride)
\r
1095 // 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
1096 // modexCopyPageRegion(&(gv->video.page[gv->video->sfip]), &(gv->video.page[!gv->video->sfip]), x, y, x, 0, w, h);
\r
1097 /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */
\r
1098 // vga_restore_rm0wm0();
\r
1099 }else //copy dat sheet
\r
1100 gv->kurokku.tiku++;
\r
1102 switch(gv->kurokku.fpscap)
\r
1105 //modexprint(&(gv->video.page[gv->video->sfip]), x, y+8, type, col, bgcol, "sanic!");
\r
1106 gv->kurokku.frames_per_second=1;
\r
1109 //turn this off if XT
\r
1110 //modexWaitBorder();
\r
1111 vga_wait_for_vsync();
\r
1112 gv->kurokku.frames_per_second=60;
\r
1117 //vga_setup_wm1_block_copy();
\r
1118 //_fmemcpy((gv->video.page[(gv->video.p)]).data, (gv->video.page[(!gv->video.p)]).data, gv->video.page[(!gv->video.p)].pagesize);
\r
1119 //vga_restore_rm0wm0();
\r
1120 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
1121 modexShowPage(&(gv->video.page[gv->video.p]));
\r
1122 if(!pageploop) gv->video.p=!gv->video.p;
\r
1123 gv->video.r=!gv->video.r;
\r
1124 //0000gv->video.tickclk = ((*clockw)-gv->video.startclk)/18.2;
\r
1129 void near ZC_drawframe(map_view_t *pip, player_t *player, word pn, sword x, sword y, word sw)
\r
1131 switch(pip[0].video->rs)
\r
1134 animate_spri(player[pn].ent->spri, pip->video);
\r
1137 oldanimate_spri(player[pn].ent->spri, pip->video);
\r
1140 modexClearRegion(&(pip[0].page[0]), x, y, 16, 32, player[pn].enti.dire);
\r
1146 #define FRAME1 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 48, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR);
\r
1147 #define FRAME2 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR);
\r
1148 #define FRAME3 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 0, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR);
\r
1149 #define FRAME4 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR);
\r
1151 #define FRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 2+player[pn].enti.dire);
\r
1152 #define FRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+player[pn].enti.dire);
\r
1153 #define FRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, player[pn].enti.dire);
\r
1154 #define FRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+player[pn].enti.dire);
\r
1157 void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch)
\r
1159 sword x = player[pn].enti.x;
\r
1160 sword y = player[pn].enti.y;
\r
1161 sword bx = x+16; //buffer's x
\r
1162 sword by = y+16; //buffer's y
\r
1163 sword qq; //scroll offset
\r
1164 word ls = player[pn].enti.persist_aniframe;
\r
1165 player[pn].enti.dire=32; //direction
\r
1167 switch(scrollswitch)
\r
1173 qq = ((player[pn].enti.q)*(player[pn].enti.speed));
\r
1177 y-=pip[0].map->tiles->tileHeight;
\r
1178 switch (player[pn].enti.d)
\r
1182 player[pn].enti.dire*=player[pn].enti.d;
\r
1188 player[pn].enti.dire*=(player[pn].enti.d-2);
\r
1196 player[pn].enti.dire*=(player[pn].enti.d-2);
\r
1202 player[pn].enti.dire*=(player[pn].enti.d+2);
\r
1209 modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 36);
\r
1211 //copy old bg to page0
\r
1212 //modexCopyPageRegion(pip[3].page, pip[0].page, bx, by, 0, 0, 20, 36);
\r
1214 //modexCopyPageRegion(pip[0].page, pip[3].page, 0, 0, x, y, 20, 36);
\r
1216 //modexCopyPageRegion(page_t *dest, page_t *src, word sx, word sy, word dx, word dy, word width, word height);
\r
1217 //modexCopyPageRegion(pip[3].page, pip[!(pip->video->p)].page, x-4, y-4, 0, 128, 28, 36);
\r
1218 /*modexCopyPageRegion(pip[pip->video->p].page,
\r
1219 pip[!(pip->video->p)].page, x-4, y-4, x-4, y-4, 28, 36);*/
\r
1220 // else modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 40);
\r
1236 // if(2>ls && ls>=1) { FRAME1 }else
\r
1237 // if(3>ls && ls>=2) { FRAME2 }else
\r
1238 // if(4>ls && ls>=3) { FRAME3 }else
\r
1239 // if(5>ls && ls>=4) { FRAME4 }
\r
1240 //modexCopyPageRegion(pip[0].page, pip[3].page, 0, 0, x, y, 24, 32);
\r
1241 //printf("x=%d y=%d bx=%d by=%d\n", x, y, bx, by);
\r
1245 void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch)
\r
1247 sword x = player[pn].enti.x;
\r
1248 sword y = player[pn].enti.y;
\r
1249 sword qq; //scroll offset
\r
1250 word ls = player[pn].enti.persist_aniframe;
\r
1251 player[pn].enti.dire=10; //direction
\r
1253 switch(scrollswitch)
\r
1259 qq = ((player[pn].enti.q)*(player[pn].enti.speed));
\r
1262 if(pip[0].video->rs<2)
\r
1264 y-=pip[0].map->tiles->tileHeight;
\r
1265 switch (player[pn].enti.d)
\r
1269 player[pn].enti.dire*=player[pn].enti.d+1;
\r
1274 player[pn].enti.dire*=(player[pn].enti.d-1);
\r
1281 player[pn].enti.dire*=(player[pn].enti.d-1);
\r
1286 player[pn].enti.dire*=(player[pn].enti.d+3);
\r
1290 player[pn].enti.dire++;
\r
1292 player[pn].ent->spri->delay=1;
\r
1293 //pip->video->sprifilei = set_anim_by_id(player[pn].ent->spri, player[pn].enti.dire); if(pip->video->sprifilei == -1){ printf("ERROR! %u\n", player[pn].enti.dire); return; }
\r
1295 //setting xy position
\r
1296 player[pn].ent->spri->x = x;
\r
1297 player[pn].ent->spri->y = y;
\r
1302 ZC_drawframe(pip, player, pn, x, y, ls);
\r
1305 ZC_drawframe(pip, player, pn, x, y, ls);
\r
1308 ZC_drawframe(pip, player, pn, x, y, ls);
\r
1311 ZC_drawframe(pip, player, pn, x, y, ls);
\r
1315 WALKTYPE_FRAM_PRINT;
\r
1316 //sprintf(global_temp_status_text, " %u", player[pn].enti.dire);
\r
1317 //modexprint(&(pip->video->page[0]), player[pn].enti.x-(8*player[pn].enti.persist_aniframe)+8, player[pn].enti.y-TILEWH-(8*player[pn].enti.persist_aniframe), 1, 20, 1, global_temp_status_text);
\r
1324 boolean boundary_check(int x, int y, int dx, int dy, int h, int w)
\r
1326 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
1329 boolean coll_check(int x, int y, int dx, int dy, map_view_t *map_v)
\r
1331 // Assume everything crosses at most 1 tile at once
\r
1332 return dx && 1;//crossable_tile(x + dx, map_v) || dy && crossable_tile(y + dy, map_v);
\r
1335 boolean ZC_walk2(entity_t *ent, map_view_t *map_v)
\r
1355 if(coll_check(ent->x, ent->y, dx, dy, map_v))
\r
1359 // Start animation
\r
1360 // Mark next tile as occupied
\r
1361 // Mark this tile as vacant
\r
1367 void player_walk(player_t *player, map_view_t *map_v){
\r
1369 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
1371 mapScroll(map_v, player);
\r
1372 // (Un)load stuff?
\r
1376 void near mapScroll(map_view_t *mv, player_t *player)
\r
1378 //word x, y; /* coordinate for drawing */
\r
1381 mv->delta += player->dx | player->dy;
\r
1382 delta = mv->delta;
\r
1383 mv->d = (player->dx) ? (player->dx > 0) ? 3 : 1 : (player->dy) ? (player->dy > 0) ? 4 : 0 : 2;
\r
1389 if(!(delta + mv->dxThresh))
\r
1399 if(!(delta + mv->dyThresh))
\r