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, 2);
\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, 1);
\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
77 ANIMATESPRIFUN(pip, player, pn, 0);
\r
78 player[pn].enti.d = 2;
\r
80 player[pn].enti.triggerx = player[pn].enti.tx+1;
\r
81 player[pn].enti.triggery = player[pn].enti.ty;
\r
85 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
86 !(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
88 player[pn].walktype=2;
\r
89 if(player[pn].enti.q<=player[pn].enti.spt)
\r
92 ANIMATESPRIFUN(pip, player, pn, 2);
\r
93 ScrollLeft(pip, player, 3, pn);
\r
94 ScrollLeft(pip, player, 2, pn);
\r
95 mapScrollLeft(pip, player, (pip[0].video->p), pn);
\r
96 player[pn].enti.q++;
\r
97 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
98 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
100 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
102 player[pn].walktype=1;
\r
103 if(player[pn].enti.q<=player[pn].enti.spt)
\r
106 player[pn].enti.x-=(player[pn].enti.speed);
\r
107 ANIMATESPRIFUN(pip, player, pn, 1);
\r
108 player[pn].enti.q++;
\r
109 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
113 player[pn].walktype=0;
\r
114 ANIMATESPRIFUN(pip, player, pn, 0);
\r
115 player[pn].enti.d = 2;
\r
117 player[pn].enti.triggerx = player[pn].enti.tx-1;
\r
118 player[pn].enti.triggery = player[pn].enti.ty;
\r
122 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
123 !(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
125 player[pn].walktype=2;
\r
126 if(player[pn].enti.q<=player[pn].enti.spt)
\r
129 ANIMATESPRIFUN(pip, player, pn, 2);
\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 = Q_INIT; 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 player[pn].walktype=1;
\r
140 if(player[pn].enti.q<=player[pn].enti.spt)
\r
143 player[pn].enti.y+=(player[pn].enti.speed);
\r
144 ANIMATESPRIFUN(pip, player, pn, 1);
\r
145 player[pn].enti.q++;
\r
146 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
150 player[pn].walktype=0;
\r
151 ANIMATESPRIFUN(pip, player, pn, 0);
\r
152 player[pn].enti.d = 2;
\r
154 player[pn].enti.triggerx = player[pn].enti.tx;
\r
155 player[pn].enti.triggery = player[pn].enti.ty+1;
\r
159 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
160 !(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
162 player[pn].walktype=2;
\r
163 if(player[pn].enti.q<=player[pn].enti.spt)
\r
166 ANIMATESPRIFUN(pip, player, pn, 2);
\r
167 ScrollUp(pip, player, 3, pn);
\r
168 ScrollUp(pip, player, 2, pn);
\r
169 mapScrollUp(pip, player, (pip[0].video->p), pn);
\r
170 player[pn].enti.q++;
\r
171 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
172 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
174 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
176 player[pn].walktype=1;
\r
177 if(player[pn].enti.q<=player[pn].enti.spt)
\r
180 player[pn].enti.y-=(player[pn].enti.speed);
\r
181 ANIMATESPRIFUN(pip, player, pn, 1);
\r
182 player[pn].enti.q++;
\r
183 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
187 player[pn].walktype=0;
\r
188 ANIMATESPRIFUN(pip, player, pn, 0);
\r
189 player[pn].enti.d = 2;
\r
191 player[pn].enti.triggerx = player[pn].enti.tx;
\r
192 player[pn].enti.triggery = player[pn].enti.ty-1;
\r
199 src/lib/scroll16.c: mv[0].video->r=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: pip->video->r=1;
\r
204 src/lib/scroll16.c: mv->video->r=1;
\r
207 void oldwalk(map_view_t *pip, player_t *player, word pn)
\r
209 //printf("player[%d].d=%d\n", pn, player[pn].enti.d);
\r
210 switch(player[pn].enti.d)
\r
214 //0000pip[0].video->startclk = (*clockw);
\r
218 //printf("pip[0].page->tilesw=%d ", pip[0].page->tilesw); printf("pip[0].page->tw=%d\n", pip[0].page->tw);
\r
219 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
220 !(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
222 if(player[pn].enti.q<=player[pn].enti.spt)
\r
225 ANIMATESPRIFUN(pip, player, pn, 1);
\r
226 ScrollRight(pip, player, 3, pn);
\r
227 ScrollRight(pip, player, 2, pn);
\r
228 //mapScrollRight(pip, player, !(pip[0].video->p), pn);
\r
229 mapScrollRight(pip, player, (pip[0].video->p), pn);
\r
230 if(!pageflipflop) modexShowPage(pip[1].page);
\r
231 player[pn].enti.q++;
\r
232 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
233 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
235 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
237 if(player[pn].enti.q<=player[pn].enti.spt)
\r
240 player[pn].enti.x+=(player[pn].enti.speed);
\r
241 ANIMATESPRIFUN(pip, player, pn, 0);
\r
242 if(!pageflipflop) modexShowPage(pip[1].page);
\r
243 player[pn].enti.q++;
\r
244 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
248 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
250 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATAPTR);
\r
252 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 14);
\r
254 if(!pageflipflop) modexShowPage(pip[1].page);
\r
255 player[pn].enti.d = 2;
\r
257 player[pn].enti.triggerx = player[pn].enti.tx+1;
\r
258 player[pn].enti.triggery = player[pn].enti.ty;
\r
263 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
264 !(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
266 if(player[pn].enti.q<=player[pn].enti.spt)
\r
269 ANIMATESPRIFUN(pip, player, pn, 1);
\r
270 ScrollLeft(pip, player, 3, pn);
\r
271 ScrollLeft(pip, player, 2, pn);
\r
272 //mapScrollLeft(pip, player, !(pip[0].video->p), pn);
\r
273 mapScrollLeft(pip, player, (pip[0].video->p), pn);
\r
274 if(!pageflipflop) modexShowPage(pip[1].page);
\r
275 player[pn].enti.q++;
\r
276 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
277 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
279 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
281 if(player[pn].enti.q<=player[pn].enti.spt)
\r
284 player[pn].enti.x-=(player[pn].enti.speed);
\r
285 ANIMATESPRIFUN(pip, player, pn, 0);
\r
286 if(!pageflipflop) modexShowPage(pip[1].page);
\r
287 player[pn].enti.q++;
\r
288 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
292 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
294 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATAPTR);
\r
296 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 10);
\r
298 if(!pageflipflop) modexShowPage(pip[1].page);
\r
299 player[pn].enti.d = 2;
\r
301 player[pn].enti.triggerx = player[pn].enti.tx-1;
\r
302 player[pn].enti.triggery = player[pn].enti.ty;
\r
307 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
308 !(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
310 if(player[pn].enti.q<=player[pn].enti.spt)
\r
313 ANIMATESPRIFUN(pip, player, pn, 1);
\r
314 ScrollDown(pip, player, 3, pn);
\r
315 ScrollDown(pip, player, 2, pn);
\r
316 //mapScrollDown(pip, player, !(pip[0].video->p), pn);
\r
317 mapScrollDown(pip, player, (pip[0].video->p), pn);
\r
318 if(!pageflipflop) modexShowPage(pip[1].page);
\r
319 player[pn].enti.q++;
\r
320 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
321 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
323 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
325 if(player[pn].enti.q<=player[pn].enti.spt)
\r
328 player[pn].enti.y+=(player[pn].enti.speed);
\r
329 ANIMATESPRIFUN(pip, player, pn, 0);
\r
330 if(!pageflipflop) modexShowPage(pip[1].page);
\r
331 player[pn].enti.q++;
\r
332 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
336 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
338 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATAPTR);
\r
340 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 9);
\r
342 if(!pageflipflop) modexShowPage(pip[1].page);
\r
343 player[pn].enti.d = 2;
\r
345 player[pn].enti.triggerx = player[pn].enti.tx;
\r
346 player[pn].enti.triggery = player[pn].enti.ty+1;
\r
351 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
352 !(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
354 if(player[pn].enti.q<=player[pn].enti.spt)
\r
357 ANIMATESPRIFUN(pip, player, pn, 1);
\r
358 ScrollUp(pip, player, 3, pn);
\r
359 ScrollUp(pip, player, 2, pn);
\r
360 //mapScrollUp(pip, player, !(pip[0].video->p), pn);
\r
361 mapScrollUp(pip, player, (pip[0].video->p), pn);
\r
362 if(!pageflipflop) modexShowPage(pip[1].page);
\r
363 player[pn].enti.q++;
\r
364 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
365 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
367 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
369 if(player[pn].enti.q<=player[pn].enti.spt)
\r
372 player[pn].enti.y-=(player[pn].enti.speed);
\r
373 ANIMATESPRIFUN(pip, player, pn, 0);
\r
374 if(!pageflipflop) modexShowPage(pip[1].page);
\r
375 player[pn].enti.q++;
\r
376 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
380 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
382 modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATAPTR);
\r
384 modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 12);
\r
386 if(!pageflipflop) modexShowPage(pip[1].page);
\r
387 player[pn].enti.d = 2;
\r
389 player[pn].enti.triggerx = player[pn].enti.tx;
\r
390 player[pn].enti.triggery = player[pn].enti.ty-1;
\r
396 void ZC_panPageManual(map_view_t *pip, player_t *player, word pn)
\r
398 #define SHOWMVFUN_ ZC_ShowMV(pip, 0, 0);
\r
399 switch(player[pn].enti.d)
\r
403 if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->tw < pip[0].page->tilesw)
\r
405 if(player[pn].enti.q<=player[pn].enti.spt)
\r
407 pip[0].page->dx+=4;
\r
409 player[pn].enti.q++;
\r
410 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; pip[0].tx++; }
\r
416 if(pip[0].tx > 0 && pip[0].tx+pip[0].page->tw <= pip[0].page->tilesw)
\r
418 if(player[pn].enti.q<=player[pn].enti.spt)
\r
420 pip[0].page->dx-=4;
\r
422 player[pn].enti.q++;
\r
423 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; pip[0].tx--; }
\r
429 if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->th < pip[0].page->tilesh)
\r
431 if(player[pn].enti.q<=player[pn].enti.spt)
\r
433 pip[0].page->dy+=4;
\r
435 player[pn].enti.q++;
\r
436 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; pip[0].ty++; }
\r
442 if(pip[0].ty > 0 && pip[0].ty+pip[0].page->th <= pip[0].page->tilesh)
\r
444 if(player[pn].enti.q<=player[pn].enti.spt)
\r
446 pip[0].page->dy-=4;
\r
448 player[pn].enti.q++;
\r
449 } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; pip[0].ty--; }
\r
458 void ZC_MVSetup(map_view_t *pip, map_t *map, global_game_variables_t *gv)
\r
463 pip[0].page = &gv->video.page[0];
\r
465 pip[0].video = &gv->video;
\r
466 pip[0].panp = &gv->video.panp;
\r
467 ZC_MVInit(pip, 1, 1);
\r
469 for(i=ZC_MVI;i<gv->video.num_of_pages;i++)
\r
471 pip[i].page = &gv->video.page[i];
\r
472 pip[i].map = pip[0].map;
\r
473 pip[i].video = pip[0].video;
\r
474 pip[i].panp = pip[0].panp;
\r
482 void ZC_MVInit(map_view_t *pip, int tx, int ty)
\r
486 //pip[0].tx = pip[1].tx = tx;
\r
487 //pip[0].ty = pip[1].ty = ty;
\r
490 void ZC_ShowMV(map_view_t *moo, boolean vsync, boolean sr)
\r
492 word high_address, low_address, offset;
\r
495 /* calculate offset */
\r
496 offset = (word) moo[moo[0].video->panp].page->data;
\r
497 offset += moo[0].page->dy * (moo[0].page->width >> 2 );
\r
498 offset += moo[0].page->dx >> 2;
\r
500 /* calculate crtcOffset according to virtual width */
\r
504 crtcOffset = moo[0].page->sw >> 3;
\r
508 crtcOffset = moo[0].page->width >> 3;
\r
512 high_address = HIGH_ADDRESS | (offset & 0xff00);
\r
513 low_address = LOW_ADDRESS | (offset << 8);
\r
515 /* wait for appropriate timing and then program CRTC */
\r
516 if(vsync) while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE));
\r
517 outpw(CRTC_INDEX, high_address);
\r
518 outpw(CRTC_INDEX, low_address);
\r
519 outp(CRTC_INDEX, 0x13);
\r
520 outp(CRTC_DATA, crtcOffset);
\r
522 /* wait for one retrace */
\r
523 if(vsync) while (!(inp(INPUT_STATUS_1) & VRETRACE));
\r
525 /* do PEL panning here */
\r
526 outp(AC_INDEX, 0x33);
\r
527 outp(AC_INDEX, (moo[0].page->dx & 0x03) << 1);
\r
531 allocMap(int w, int h) {
\r
536 result.data = malloc(sizeof(byte) * w * h);
\r
537 //result.data = (byte *)alloc_emem(((int)sizeof(byte) * w * h)/1024);
\r
538 if(isEMS() || checkEMS())
\r
541 //emmhandle = mallocEMS(coretotalEMS());//alloc_emem((int)sizeof(map))
\r
542 mm.length=sizeof(result);
\r
544 mm.sourceOff=ptr2long(&result);
\r
545 mm.destH=emmhandle;
\r
547 ist = move_emem(&mm);
\r
548 if(!ist){ dealloc_emem(emmhandle); exit(5); }
\r
549 printf("%d\n", coretotalEMS());
\r
556 initMap(map_t *map) {
\r
557 // just a place holder to fill out an alternating pattern
\r
561 //if(!isEMS() || !checkEMS())
\r
562 // map->tiles = malloc(sizeof(tiles_t));
\r
564 // map->tiles = (tiles_t *)alloc_emem(sizeof(tiles_t));
\r
566 //create the tile set
\r
567 //if(!isEMS() || !checkEMS())
\r
568 // map->tiles->data = malloc(sizeof(bitmap_t));
\r
570 // map->tiles->data = (bitmap_t *)alloc_emem(sizeof(bitmap_t));
\r
571 // map->tiles->data->width = (TILEWH);
\r
572 // map->tiles->data->height= TILEWH;
\r
573 //if(!isEMS() || !checkEMS())
\r
574 // map->tiles->data->data = malloc((TILEWH*2)*TILEWH);
\r
576 // map->tiles->data->data = (byte *)alloc_emem((TILEWH*2)*TILEWH);
\r
577 // map->tiles->tileHeight = TILEWH;
\r
578 // map->tiles->tileWidth =TILEWH;
\r
579 // map->tiles->rows = 1;
\r
580 // map->tiles->cols = 1;//2;
\r
583 //for(y=0; y<map->height; y++) {
\r
584 //for(x=0; x<map->width; x++) {
\r
586 for(yy=0; yy<TILEWH; yy++) {
\r
587 for(xx=0; xx<(TILEWH); xx++) {
\r
589 map->tiles->data->data[i+1] = map->data[q];//28;//0x24;
\r
590 // printf("[%d]", map->tiles->data->data[i]);
\r
592 //map->tiles->data->data[i] = map->data[q];//0;//0x34;
\r
593 //printf("]%d[==[%d]", i, map->tiles->data->data[i]);
\r
599 // printf("[%d]", map->data[q]);
\r
606 for(y=0; y<map->height; y++) {
\r
607 for(x=0; x<map->width; x++) {
\r
608 // map->data[i]=255;
\r
609 printf("[%d]", map->data[i]);
\r
610 //tile = tile ? 0 : 1;
\r
613 //tile = tile ? 0 : 1;
\r
617 void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
\r
619 word x;//, y; /* coordinate for drawing */
\r
621 /* increment the pixel position and update the page */
\r
622 mv[id].page[0].dx += player[plid].enti.speed;
\r
624 /* check to see if this changes the tile */
\r
625 if(mv[id].page[0].dx >= mv[id].dxThresh )
\r
627 /* go forward one tile */
\r
629 /* Snap the origin forward */
\r
630 mv[id].page->data += 4;
\r
632 mv[id].page[0].dx = mv[id].map->tiles->tileWidth;
\r
635 /* draw the next column */
\r
636 x= mv[0].page->sw + mv[id].map->tiles->tileWidth;
\r
637 if(player[plid].enti.q%4)
\r
639 mapDrawCol(&mv[0], mv[0].tx + mv[0].page->tw, mv[0].ty-1, x, player, mv->page[0].dx);
\r
641 if(!pageflipflop && !pageploop)
\r
642 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
647 void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
\r
649 word x;//,y; /* coordinate for drawing */
\r
651 /* decrement the pixel position and update the page */
\r
652 mv[id].page[0].dx -= player[plid].enti.speed;
\r
654 /* check to see if this changes the tile */
\r
655 if(mv[id].page[0].dx == 0)
\r
657 /* go backward one tile */
\r
659 /* Snap the origin backward */
\r
660 mv[id].page->data -= 4;
\r
662 mv[id].page[0].dx = mv[id].map->tiles->tileWidth;
\r
665 /* draw the next column */
\r
667 if(player[plid].enti.q%4)
\r
669 mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, mv->page[0].dx);
\r
671 if(!pageflipflop && !pageploop)
\r
672 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
677 void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
\r
679 word y;//x, /* coordinate for drawing */
\r
681 /* decrement the pixel position and update the page */
\r
682 mv[id].page[0].dy -= player[plid].enti.speed;
\r
684 /* check to see if this changes the tile */
\r
685 if(mv[id].page[0].dy == 0 )
\r
687 /* go down one tile */
\r
689 /* Snap the origin downward */
\r
690 mv[id].page->data -= mv[id].page->pi;
\r
692 mv[id].page[0].dy = mv[id].map->tiles->tileHeight;
\r
695 /* draw the next row */
\r
697 if(player[plid].enti.q%3)
\r
699 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, mv->page[0].dy);
\r
701 if(!pageflipflop && !pageploop)
\r
702 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
706 void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)
\r
708 word y;//x, /* coordinate for drawing */
\r
710 /* increment the pixel position and update the page */
\r
711 mv[id].page[0].dy += player[plid].enti.speed;
\r
713 /* check to see if this changes the tile */
\r
714 if(mv[id].page[0].dy >= mv[id].dyThresh )
\r
716 /* go down one tile */
\r
718 /* Snap the origin downward */
\r
719 mv[id].page->data += mv[id].page->pi;
\r
721 mv[id].page[0].dy = mv[id].map->tiles->tileHeight;
\r
724 /* draw the next row */
\r
725 y= mv[0].page->sh + mv[id].map->tiles->tileHeight;
\r
726 if(player[plid].enti.q%3)
\r
728 mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+mv[0].page->th, y, player, mv->page[0].dy);
\r
730 if(!pageflipflop && !pageploop)
\r
731 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
736 //TODO finish this wwww
\r
737 void near ScrollRight(map_view_t *mv, player_t *player, word id, word plid)
\r
739 /* increment the pixel position and update the page */
\r
740 mv[id].page->dx += player[plid].enti.speed;
\r
742 /* check to see if this changes the tile */
\r
743 if(mv[id].page->dx >= mv[0].dxThresh )
\r
745 // vga_setup_wm1_block_copy();
\r
746 // _fmemmove(mv[id].page->data+4, mv[id].page->data, mv[id].page->pagesize);
\r
747 // vga_restore_rm0wm0();
\r
748 /* Snap the origin forward */
\r
749 mv[id].page->data += 4;
\r
750 mv[id].page->dx = mv[0].map->tiles->tileWidth;
\r
754 void near ScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
\r
756 /* decrement the pixel position and update the page */
\r
757 mv[id].page->dx -= player[plid].enti.speed;
\r
759 /* check to see if this changes the tile */
\r
760 if(mv[id].page->dx == 0)
\r
762 // vga_setup_wm1_block_copy();
\r
763 // _fmemmove(mv[id].page->data-4, mv[id].page->data, mv[id].page->pagesize);
\r
764 // vga_restore_rm0wm0();
\r
765 /* Snap the origin backward */
\r
766 mv[id].page->data -= 4;
\r
767 mv[id].page->dx = mv[0].map->tiles->tileWidth;
\r
771 void near ScrollUp(map_view_t *mv, player_t *player, word id, word plid)
\r
773 /* decrement the pixel position and update the page */
\r
774 mv[id].page->dy -= player[plid].enti.speed;
\r
776 /* check to see if this changes the tile */
\r
777 if(mv[id].page->dy == 0)
\r
779 // vga_setup_wm1_block_copy();
\r
780 // _fmemmove(mv[id].page->data-mv[id].page->pi, mv[id].page->data, mv[id].page->pagesize);
\r
781 // vga_restore_rm0wm0();
\r
782 /* Snap the origin backward */
\r
783 mv[id].page->data -= mv[id].page->pi;
\r
784 mv[id].page->dy = mv[0].map->tiles->tileWidth;
\r
788 void near ScrollDown(map_view_t *mv, player_t *player, word id, word plid)
\r
790 /* increment the pixel position and update the page */
\r
791 mv[id].page->dy += player[plid].enti.speed;
\r
793 /* check to see if this changes the tile */
\r
794 if(mv[id].page->dy >= mv[0].dxThresh )
\r
796 // vga_setup_wm1_block_copy();
\r
797 // _fmemmove(mv[id].page->data+mv[id].page->pi, mv[id].page->data, mv[id].page->pagesize);
\r
798 // vga_restore_rm0wm0();
\r
799 /* Snap the origin forward */
\r
800 mv[id].page->data += mv[id].page->pi;
\r
801 mv[id].page->dy = mv[0].map->tiles->tileWidth;
\r
805 //===========================================================================
\r
806 //TODO: put player in starting position of assigned spot on map
\r
807 //default player position on the viewable map
\r
808 void playerXYpos(int x, int y, player_t *player, map_view_t *pip, nibble pn)
\r
810 player[pn].enti.tx = x + pip[0].tx + pip[0].page->tilemidposscreenx;
\r
811 player[pn].enti.ty = y + pip[0].ty + pip[0].page->tilemidposscreeny;
\r
813 //===========================================================================
\r
815 sword chkmap(map_t *map, word q)
\r
818 static byte x[(MAPW*MAPH)+1] =
\r
819 { 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, 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, 12, 4, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
823 13, 14, 15, 16, 0, 1, 1, 1, 5, 8, 1, 11, 11, 1, 1, 1, 1, 1, 1, 1, \
\r
824 0, 0, 4, 0, 0, 0, 0, 0, 8, 8, 1, 11, 11, 3, 1, 1, 1, 1, 1, 1, \
\r
825 1, 1, 1, 1, 0, 0, 0, 0, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
826 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 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, 3, 1, 1, 1, \
\r
828 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 3, 1, 1, 1, \
\r
831 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
\r
832 1, 1, 1, 1, 1, 1, 1, 1, 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, 3, 3, 3, 3, 1, 2, 3, 4 };*/
\r
835 //check for failed to load map
\r
836 if((map->width == map->height == 0) && (q>0))
\r
838 //initiate a null map!
\r
839 map->width=MAPW;///2;
\r
840 map->height=MAPH;///2;
\r
841 // map->data = malloc(((map->width*map->height)+1)*sizeof(byte));
\r
843 map->tiles = malloc(sizeof(tiles_t));
\r
844 //fix this to be far~
\r
845 // bp = bitmapLoadPcx("data/ed.pcx");
\r
846 // map->tiles->data = &bp;
\r
847 #ifdef __DEBUG_MAP__
\r
848 dbg_mapdata = map->data;
\r
850 map->tiles->tileHeight = 16;
\r
851 map->tiles->tileWidth = 16;
\r
852 map->tiles->rows = 1;
\r
853 map->tiles->cols = 1;
\r
854 #ifdef __DEBUG_MAP__
\r
855 dbg_maptext = true;
\r
858 #ifdef __DEBUG_MAP__
\r
859 else dbg_maptext = false;
\r
864 //TODO: player position here
\r
865 void mapGoTo(map_view_t *mv, int tx, int ty)
\r
870 mapinitmapview(mv, tx, ty);
\r
872 /* draw the tiles */
\r
873 modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 0);
\r
875 i=mv[0].ty * mv[0].map->width + mv[0].tx;
\r
876 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
877 mapDrawWRow(&mv[0], tx-1, ty, py);
\r
878 i+=mv->map->width - tx;
\r
881 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
1104 void near ZC_drawframe(map_view_t *pip, player_t *player, word pn, sword x, sword y, word sw)
\r
1106 switch(pip[0].video->rs)
\r
1109 animate_spri(player[pn].ent->spri, pip->video);
\r
1112 oldanimate_spri(player[pn].ent->spri, pip->video);
\r
1115 modexClearRegion(&(pip[0].page[0]), x, y, 16, 32, player[pn].enti.dire);
\r
1121 #define FRAME1 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 48, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR);
\r
1122 #define FRAME2 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR);
\r
1123 #define FRAME3 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 0, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR);
\r
1124 #define FRAME4 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR);
\r
1126 #define FRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 2+player[pn].enti.dire);
\r
1127 #define FRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+player[pn].enti.dire);
\r
1128 #define FRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, player[pn].enti.dire);
\r
1129 #define FRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+player[pn].enti.dire);
\r
1132 void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch)
\r
1134 sword x = player[pn].enti.x;
\r
1135 sword y = player[pn].enti.y;
\r
1136 sword bx = x+16; //buffer's x
\r
1137 sword by = y+16; //buffer's y
\r
1138 sword qq; //scroll offset
\r
1139 word ls = player[pn].enti.persist_aniframe;
\r
1140 player[pn].enti.dire=32; //direction
\r
1142 switch(scrollswitch)
\r
1148 qq = ((player[pn].enti.q)*(player[pn].enti.speed));
\r
1152 y-=pip[0].map->tiles->tileHeight;
\r
1153 switch (player[pn].enti.d)
\r
1157 player[pn].enti.dire*=player[pn].enti.d;
\r
1163 player[pn].enti.dire*=(player[pn].enti.d-2);
\r
1171 player[pn].enti.dire*=(player[pn].enti.d-2);
\r
1177 player[pn].enti.dire*=(player[pn].enti.d+2);
\r
1184 modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 36);
\r
1186 //copy old bg to page0
\r
1187 //modexCopyPageRegion(pip[3].page, pip[0].page, bx, by, 0, 0, 20, 36);
\r
1189 //modexCopyPageRegion(pip[0].page, pip[3].page, 0, 0, x, y, 20, 36);
\r
1191 //modexCopyPageRegion(page_t *dest, page_t *src, word sx, word sy, word dx, word dy, word width, word height);
\r
1192 //modexCopyPageRegion(pip[3].page, pip[!(pip->video->p)].page, x-4, y-4, 0, 128, 28, 36);
\r
1193 /*modexCopyPageRegion(pip[pip->video->p].page,
\r
1194 pip[!(pip->video->p)].page, x-4, y-4, x-4, y-4, 28, 36);*/
\r
1195 // else modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 40);
\r
1211 // if(2>ls && ls>=1) { FRAME1 }else
\r
1212 // if(3>ls && ls>=2) { FRAME2 }else
\r
1213 // if(4>ls && ls>=3) { FRAME3 }else
\r
1214 // if(5>ls && ls>=4) { FRAME4 }
\r
1215 //modexCopyPageRegion(pip[0].page, pip[3].page, 0, 0, x, y, 24, 32);
\r
1216 //printf("x=%d y=%d bx=%d by=%d\n", x, y, bx, by);
\r
1220 void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch)
\r
1222 sword x = player[pn].enti.x;
\r
1223 sword y = player[pn].enti.y;
\r
1224 sword qq,dd; //scroll offset
\r
1225 word ls = player[pn].enti.persist_aniframe;
\r
1226 player[pn].enti.dire=10; //direction
\r
1228 switch(scrollswitch)
\r
1240 qq = ((player[pn].enti.q)*(player[pn].enti.speed));
\r
1243 if(pip[0].video->rs<2)
\r
1245 y-=pip[0].map->tiles->tileHeight;
\r
1246 switch (player[pn].enti.d)
\r
1250 player[pn].enti.dire*=player[pn].enti.d+1;
\r
1255 player[pn].enti.dire*=(player[pn].enti.d-1);
\r
1262 player[pn].enti.dire*=(player[pn].enti.d-1);
\r
1267 player[pn].enti.dire*=(player[pn].enti.d+3);
\r
1271 player[pn].enti.dire+=dd;
\r
1272 player[pn].ent->spri->delay=1;
\r
1273 if(player[pn].enti.q==1)
\r
1274 set_anim_by_id(player[pn].ent->spri, player[pn].enti.dire);
\r
1275 //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
1277 //setting xy position
\r
1278 player[pn].ent->spri->x = x;
\r
1279 player[pn].ent->spri->y = y;
\r
1284 ZC_drawframe(pip, player, pn, x, y, ls);
\r
1287 ZC_drawframe(pip, player, pn, x, y, ls);
\r
1290 ZC_drawframe(pip, player, pn, x, y, ls);
\r
1293 ZC_drawframe(pip, player, pn, x, y, ls);
\r
1297 if(player[pn].enti.persist_aniframe!=player[pn].enti.q)
\r
1299 sprintf(global_temp_status_text, "[%u]%u", player[pn].enti.persist_aniframe, player[pn].enti.q);
\r
1300 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
1303 //WALKTYPE_FRAM_PRINT;
\r
1304 //sprintf(global_temp_status_text, " %u", player[pn].enti.dire);
\r
1305 //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
1312 boolean boundary_check(int x, int y, int dx, int dy, int h, int w)
\r
1314 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
1317 boolean coll_check(int x, int y, int dx, int dy, map_view_t *map_v)
\r
1319 // Assume everything crosses at most 1 tile at once
\r
1320 return dx && 1;//crossable_tile(x + dx, map_v) || dy && crossable_tile(y + dy, map_v);
\r
1323 boolean ZC_walk2(entity_t *ent, map_view_t *map_v)
\r
1343 if(coll_check(ent->x, ent->y, dx, dy, map_v))
\r
1347 // Start animation
\r
1348 // Mark next tile as occupied
\r
1349 // Mark this tile as vacant
\r
1355 void player_walk(player_t *player, map_view_t *map_v){
\r
1357 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
1359 mapScroll(map_v, player);
\r
1360 // (Un)load stuff?
\r
1364 void near mapScroll(map_view_t *mv, player_t *player)
\r
1366 //word x, y; /* coordinate for drawing */
\r
1369 mv->delta += player->dx | player->dy;
\r
1370 delta = mv->delta;
\r
1371 mv->d = (player->dx) ? (player->dx > 0) ? 3 : 1 : (player->dy) ? (player->dy > 0) ? 4 : 0 : 2;
\r
1377 if(!(delta + mv->dxThresh))
\r
1387 if(!(delta + mv->dyThresh))
\r