1 /* Project 16 Source Code~
\r
2 * Copyright (C) 2012-2017 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 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
29 void ZC_walk(map_view_t *pip, player_t *player, word pn)
\r
31 switch(player[pn].enti.d)
\r
35 //0000pip[0].video->startclk = (*clockw);
\r
39 if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->ti.tw < pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->ti.tilemidposscreenx &&
\r
40 !(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
42 player[pn].walktype=2;
\r
43 if(player[pn].enti.q<=player[pn].enti.spt)
\r
46 ANIMATESPRIFUN(pip, player, pn, 2);
\r
47 ScrollRight(pip, player, 3, pn);
\r
48 ScrollRight(pip, player, 2, pn);
\r
49 mapScrollRight(pip, player, (0), pn);
\r
50 if(pip[0].video->bgps) mapScrollRight(pip, player, (1), 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 player[pn].walktype=1;
\r
58 if(player[pn].enti.q<=player[pn].enti.spt)
\r
61 player[pn].enti.x+=(player[pn].enti.speed);
\r
62 ANIMATESPRIFUN(pip, player, pn, 1);
\r
63 player[pn].enti.q++;
\r
64 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }
\r
68 player[pn].walktype=0;
\r
69 ANIMATESPRIFUN(pip, player, pn, 0);
\r
70 player[pn].enti.d = 2;
\r
72 player[pn].enti.triggerx = player[pn].enti.tx+1;
\r
73 player[pn].enti.triggery = player[pn].enti.ty;
\r
77 if(pip[0].tx > 0 && pip[0].tx+pip[0].page->ti.tw <= pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->ti.tilemidposscreenx &&
\r
78 !(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
80 player[pn].walktype=2;
\r
81 if(player[pn].enti.q<=player[pn].enti.spt)
\r
84 ANIMATESPRIFUN(pip, player, pn, 2);
\r
85 ScrollLeft(pip, player, 3, pn);
\r
86 ScrollLeft(pip, player, 2, pn);
\r
87 mapScrollLeft(pip, player, (0), pn);
\r
88 if(pip[0].video->bgps) mapScrollLeft(pip, player, (1), pn);
\r
89 player[pn].enti.q++;
\r
90 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
91 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
93 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
95 player[pn].walktype=1;
\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, 1);
\r
101 player[pn].enti.q++;
\r
102 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }
\r
106 player[pn].walktype=0;
\r
107 ANIMATESPRIFUN(pip, player, pn, 0);
\r
108 player[pn].enti.d = 2;
\r
110 player[pn].enti.triggerx = player[pn].enti.tx-1;
\r
111 player[pn].enti.triggery = player[pn].enti.ty;
\r
115 if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->ti.th < pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->ti.tilemidposscreeny &&
\r
116 !(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
118 player[pn].walktype=2;
\r
119 if(player[pn].enti.q<=player[pn].enti.spt)
\r
122 ANIMATESPRIFUN(pip, player, pn, 2);
\r
123 ScrollDown(pip, player, 3, pn);
\r
124 ScrollDown(pip, player, 2, pn);
\r
125 mapScrollDown(pip, player, (0), pn);
\r
126 if(pip[0].video->bgps) mapScrollDown(pip, player, (1), pn);
\r
127 player[pn].enti.q++;
\r
128 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
129 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
131 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
133 player[pn].walktype=1;
\r
134 if(player[pn].enti.q<=player[pn].enti.spt)
\r
137 player[pn].enti.y+=(player[pn].enti.speed);
\r
138 ANIMATESPRIFUN(pip, player, pn, 1);
\r
139 player[pn].enti.q++;
\r
140 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }
\r
144 player[pn].walktype=0;
\r
145 ANIMATESPRIFUN(pip, player, pn, 0);
\r
146 player[pn].enti.d = 2;
\r
148 player[pn].enti.triggerx = player[pn].enti.tx;
\r
149 player[pn].enti.triggery = player[pn].enti.ty+1;
\r
153 if(pip[0].ty > 0 && pip[0].ty+pip[0].page->ti.th <= pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->ti.tilemidposscreeny &&
\r
154 !(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
156 player[pn].walktype=2;
\r
157 if(player[pn].enti.q<=player[pn].enti.spt)
\r
160 ANIMATESPRIFUN(pip, player, pn, 2);
\r
161 ScrollUp(pip, player, 3, pn);
\r
162 ScrollUp(pip, player, 2, pn);
\r
163 mapScrollUp(pip, player, (0), pn);
\r
164 if(pip[0].video->bgps) mapScrollUp(pip, player, (1), pn);
\r
165 player[pn].enti.q++;
\r
166 //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;
\r
167 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
169 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
171 player[pn].walktype=1;
\r
172 if(player[pn].enti.q<=player[pn].enti.spt)
\r
175 player[pn].enti.y-=(player[pn].enti.speed);
\r
176 ANIMATESPRIFUN(pip, player, pn, 1);
\r
177 player[pn].enti.q++;
\r
178 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }
\r
182 player[pn].walktype=0;
\r
183 ANIMATESPRIFUN(pip, player, pn, 0);
\r
184 player[pn].enti.d = 2;
\r
186 player[pn].enti.triggerx = player[pn].enti.tx;
\r
187 player[pn].enti.triggery = player[pn].enti.ty-1;
\r
194 void ZC_panPageManual(map_view_t *pip, player_t *player, word pn)
\r
196 #define SHOWMVFUN_ ZC_ShowMV(pip, 0, 0);
\r
197 switch(player[pn].enti.d)
\r
201 if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->ti.tw < pip[0].page->ti.tilesw)
\r
203 if(player[pn].enti.q<=player[pn].enti.spt)
\r
205 pip[0].page->dx+=4;
\r
207 player[pn].enti.q++;
\r
208 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].tx++; }
\r
214 if(pip[0].tx > 0 && pip[0].tx+pip[0].page->ti.tw <= pip[0].page->ti.tilesw)
\r
216 if(player[pn].enti.q<=player[pn].enti.spt)
\r
218 pip[0].page->dx-=4;
\r
220 player[pn].enti.q++;
\r
221 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].tx--; }
\r
227 if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->ti.th < pip[0].page->ti.tilesh)
\r
229 if(player[pn].enti.q<=player[pn].enti.spt)
\r
231 pip[0].page->dy+=4;
\r
233 player[pn].enti.q++;
\r
234 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].ty++; }
\r
240 if(pip[0].ty > 0 && pip[0].ty+pip[0].page->ti.th <= pip[0].page->ti.tilesh)
\r
242 if(player[pn].enti.q<=player[pn].enti.spt)
\r
244 pip[0].page->dy-=4;
\r
246 player[pn].enti.q++;
\r
247 } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].ty--; }
\r
256 void ZC_MVSetup(map_view_t *pip, map_t *map, global_game_variables_t *gv)
\r
261 pip[0].page = &gv->video.page[0];
\r
263 pip[0].video = &gv->video;
\r
264 pip[0].p = &gv->video.p;
\r
265 pip[0].sp = &gv->video.sp;
\r
266 ZC_MVInit(pip, 1, 1);
\r
268 for(i=ZC_MVI;i<gv->video.num_of_pages;i++)
\r
270 pip[i].page = &gv->video.page[i];
\r
271 pip[i].map = pip[0].map;
\r
272 pip[i].video = pip[0].video;
\r
273 pip[i].p = pip[0].p;
\r
274 pip[i].sp = pip[0].sp;
\r
282 void ZC_MVInit(map_view_t *pip, int tx, int ty)
\r
286 //pip[0].tx = pip[1].tx = tx;
\r
287 //pip[0].ty = pip[1].ty = ty;
\r
290 void ZC_ShowMV(map_view_t *moo, boolean vsync, boolean sr)
\r
292 //VL_ShowPage(moo[moo[0].video->sp].page, vsync, sr);
\r
293 word high_address, low_address, offset;
\r
296 // calculate offset
\r
297 offset = (word) moo[moo[0].video->sp].page->data;
\r
298 offset += moo[0].page->dy * (moo[0].page->width >> 2 );
\r
299 offset += moo[0].page->dx >> 2;
\r
301 // calculate crtcOffset according to virtual width
\r
305 crtcOffset = moo[moo[0].video->sp].page->sw >> 3;
\r
309 crtcOffset = moo[0].page->width >> 3;
\r
313 high_address = HIGH_ADDRESS | (offset & 0xff00);
\r
314 low_address = LOW_ADDRESS | (offset << 8);
\r
316 // wait for appropriate timing and then program CRTC
\r
317 if(vsync) while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE));
\r
318 outpw(CRTC_INDEX, high_address);
\r
319 outpw(CRTC_INDEX, low_address);
\r
320 outp(CRTC_INDEX, 0x13);
\r
321 outp(CRTC_DATA, crtcOffset);
\r
323 // wait for one retrace
\r
324 if(vsync) while (!(inp(INPUT_STATUS_1) & VRETRACE));
\r
326 // do PEL panning here
\r
327 outp(AC_INDEX, 0x33);
\r
328 outp(AC_INDEX, (moo[0].page->dx & 0x03) << 1);
\r
332 initMap(map_t *map) {
\r
333 // just a place holder to fill out an alternating pattern
\r
339 for(y=0; y<map->height; y++) {
\r
340 for(x=0; x<map->width; x++) {
\r
342 // printf("[%d]", map->data[i]);
\r
343 tile = tile ? 0 : 1;
\r
346 tile = tile ? 0 : 1;
\r
351 void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
\r
353 word x;//, y; /* coordinate for drawing */
\r
355 ScrollRight(mv, player, id, plid);
\r
357 /* draw the next column */
\r
358 x= mv[0].page->sw + mv[0].map->tiles->tileWidth;
\r
360 if(player[plid].enti.q%4)
\r
362 if(player[plid].enti.q==4)
\r
365 mapDrawCol(&mv[id], mv[0].tx + mv[0].page->ti.tw, mv[0].ty-1, x, player, DRAWCOLNUM);
\r
367 // if(mv[0].video->bgps)
\r
368 // modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[0].map->tiles->tileWidth, mv[0].page->height);
\r
373 void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
\r
375 word x;//,y; /* coordinate for drawing */
\r
377 ScrollLeft(mv, player, id, plid);
\r
379 /* draw the next column */
\r
382 if(player[plid].enti.q%4)
\r
384 if(player[plid].enti.q==4)
\r
387 mapDrawCol(&mv[id], mv[0].tx - 1, mv[0].ty-1, x, player, DRAWCOLNUM);
\r
389 // if(mv[0].video->bgps)
\r
390 // modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[0].map->tiles->tileWidth, mv[0].page->height);
\r
395 void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
\r
397 word y;//x, /* coordinate for drawing */
\r
399 ScrollUp(mv, player, id, plid);
\r
401 /* draw the next row */
\r
404 if(player[plid].enti.q%3)
\r
406 if(player[plid].enti.q==4)
\r
409 mapDrawRow(&mv[id], mv[0].tx - 1, mv[0].ty-1, y, player, DRAWCOLNUM);
\r
411 // if(mv[0].video->bgps)
\r
412 // modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[0].page->width, mv[0].map->tiles->tileHeight);
\r
417 void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)
\r
419 word y;//x, /* coordinate for drawing */
\r
421 ScrollDown(mv, player, id, plid);
\r
423 /* draw the next row */
\r
424 y= mv[0].page->sh + mv[0].map->tiles->tileHeight;
\r
426 if(player[plid].enti.q%3)
\r
428 if(player[plid].enti.q==4)
\r
431 mapDrawRow(&mv[id], mv[0].tx - 1, mv[0].ty+mv[0].page->ti.th, y, player, DRAWCOLNUM);
\r
433 // if(mv[0].video->bgps)
\r
434 // modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[0].page->width, mv[0].map->tiles->tileHeight);
\r
440 //===========================================================================
\r
441 //TODO: put player in starting position of assigned spot on map
\r
442 //default player position on the viewable map
\r
443 void ZC_playerXYpos(int x, int y, player_t *player, map_view_t *pip, nibble pn)
\r
445 player[pn].enti.tx = x + pip[0].tx + pip[0].page->ti.tilemidposscreenx;
\r
446 player[pn].enti.ty = y + pip[0].ty + pip[0].page->ti.tilemidposscreeny;
\r
448 //===========================================================================
\r
450 sword chkmap(map_t *map, word q)
\r
453 static byte x[(MAPW*MAPH)+1] =
\r
454 { 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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 if((map->width == map->height == 0) && (q>0))
\r
473 //initiate a null map!
\r
474 map->width=MAPW;///2;
\r
475 map->height=MAPH;///2;
\r
476 // map->data = malloc(((map->width*map->height)+1)*sizeof(byte));
\r
478 map->tiles = malloc(sizeof(tiles_t));
\r
479 //fix this to be far~
\r
480 // bp = bitmapLoadPcx("data/ed.pcx");
\r
481 // map->tiles->data = &bp;
\r
482 #ifdef __DEBUG_MAP__
\r
483 dbg_mapdata = map->data;
\r
485 map->tiles->tileHeight = 16;
\r
486 map->tiles->tileWidth = 16;
\r
487 map->tiles->rows = 1;
\r
488 map->tiles->cols = 1;
\r
489 #ifdef __DEBUG_MAP__
\r
490 dbg_maptext = true;
\r
493 #ifdef __DEBUG_MAP__
\r
494 else dbg_maptext = false;
\r
499 //TODO: player position here
\r
500 void mapGoTo(map_view_t *mv, int tx, int ty)
\r
505 ZC_mapinitMV(mv, tx, ty);
\r
507 /* draw the tiles */
\r
508 modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 0);
\r
510 i=mv[0].ty * mv[0].map->width + mv[0].tx;
\r
511 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
512 mapDrawWRow(&mv[0], tx-1, ty, py);
\r
513 i+=mv->map->width - tx;
\r
516 i=mv[1].ty * mv[1].map->width + mv[1].tx;
\r
517 for(ty=mv[1].ty-1; py < mv[1].page->sh+mv->dyThresh && ty < mv[1].map->height; ty++, py+=mv[1].map->tiles->tileHeight) {
\r
518 mapDrawWRow(&mv[1], tx-1, ty, py);
\r
519 i+=mv->map->width - tx;
\r
521 //if(mv[0].video->bgps) modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height);
\r
524 void ZC_mapinitMV(map_view_t *mv, int tx, int ty)
\r
526 /* set up the coordinates */
\r
527 mv[0].tx = mv[1].tx = tx;
\r
528 mv[0].ty = mv[1].ty = ty;
\r
529 mv[0].page->dx = mv[1].page->dx = mv[2].page->dx = mv[3].page->dx = mv->map->tiles->tileWidth;
\r
530 mv[0].page->dy = mv[1].page->dy = mv[2].page->dy = mv[3].page->dy = mv->map->tiles->tileHeight;
\r
532 /* set up the thresholds */
\r
533 mv[0].dxThresh = mv[1].dxThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileWidth * 2;
\r
534 mv[0].dyThresh = mv[1].dyThresh = mv[2].dyThresh = mv[3].dyThresh = mv->map->tiles->tileHeight * 2;
\r
538 mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y)
\r
542 //word textx=0, texty=0;
\r
547 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, 1); //currently the over scan color!
\r
551 rx = (((i-1) % ((t->data->width)/t->tileWidth)) * t->tileWidth);
\r
552 ry = (((i-1) / ((t->data->height)/t->tileHeight)) * t->tileHeight);
\r
553 ////0000printf("i=%d\n", i);
\r
554 #ifdef __DEBUG_MAP__
\r
555 switch(dbg_maptext)
\r
560 if(!pagenorendermap) modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, ((dbg_mapdata[i])+1));
\r
561 //modexprint(page, x, y, 1, 15, 0, (char const *)(t->debug_data[i]));
\r
563 modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
\r
564 /* then the sprite. note modding ram ptr means we just draw to (x&3,0) */
\r
565 //draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));
\r
566 //modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data));
\r
568 #ifdef __DEBUG_MAP__
\r
571 modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, (dbg_mapdata[i])+1);
\r
572 //modexprintbig(page, x, y, 1, 15, 0, (t->debug_data));
\r
573 /*for(texty=0; texty<2; texty++)
\r
575 for(textx=0; textx<2; textx++)
\r
577 // modexprint(page, x+(textx*8), y+(texty*8), 1, (word)(t->debug_data), 0, (t->debug_data));
\r
586 void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *player, word poopoffset)
\r
589 if(pagedelayrendermap) if(!y) y+=TILEWH; else y-=TILEWH;
\r
590 poopoffset%=player[0].enti.speed;
\r
591 //printf("y: %d\n", poopoffset);
\r
592 if(pagedelayrendermap){ sprintf(global_temp_status_text, "%-3u", mv->dx); modexprint(mv[0].page, player[0].enti.x, player[0].enti.y-28-(poopoffset*8) , 1, 2, 1, global_temp_status_text); }
\r
593 /* the position within the map array */
\r
594 i=ty * mv->map->width + tx;
\r
595 for( mv->dx=poopoffset; mv->dx<(mv->page->sw+mv->dxThresh)/(poopoffset+1) && tx < mv->map->width; mv->dx+=mv->map->tiles->tileWidth, tx++) {
\r
596 if(i>=0) /* we are in the map, so copy away! */
\r
597 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, mv->dx, y);
\r
600 //if(pagedelayrendermap) delay(200);
\r
603 void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *player, word poopoffset)
\r
606 if(pagedelayrendermap) if(!x) x+=TILEWH; else x-=TILEWH;
\r
607 poopoffset%=player[0].enti.speed;
\r
608 //printf("x: %d\n", poopoffset);
\r
609 if(pagedelayrendermap){ sprintf(global_temp_status_text, "%-3u", mv->dy); modexprint(mv[0].page, player[0].enti.x, player[0].enti.y-28-(poopoffset*8) , 1, 2, 1, global_temp_status_text); }
\r
610 /* location in the map array */
\r
611 i=ty * mv->map->width + tx;
\r
612 /* We'll copy all of the columns in the screen,
\r
613 i + 1 row above and one below */
\r
614 for( mv->dy=poopoffset; mv->dy<(mv->page->sh+mv->dyThresh)/(poopoffset+1) && ty < mv->map->height; mv->dy+=mv->map->tiles->tileHeight, ty++) {
\r
615 if(i>=0) /* we are in the map, so copy away! */
\r
616 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, mv->dy);
\r
617 i += mv->map->width;
\r
619 //if(pagedelayrendermap) delay(200);
\r
622 void mapDrawWRow(map_view_t *mv, int tx, int ty, word y)
\r
626 /* the position within the map array */
\r
627 i=ty * mv->map->width + tx;
\r
628 for(mv->dx=0; mv->dx<mv->page->sw+mv->dxThresh && tx < mv->map->width; mv->dx+=mv->map->tiles->tileWidth, tx++) {
\r
629 if(i>=0) /* we are in the map, so copy! */
\r
630 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, mv->dx, y);
\r
635 void mapDrawWCol(map_view_t *mv, int tx, int ty, word x)
\r
639 /* location in the map array */
\r
640 i=ty * mv->map->width + tx;
\r
642 /* We'll copy all of the columns in the screen,
\r
643 i + 1 row above and one below */
\r
644 for(mv->dy=0; mv->dy<mv->page->sh+mv->dyThresh && ty < mv->map->height; mv->dy+=mv->map->tiles->tileHeight, ty++) {
\r
645 if(i>=0) /* we are in the map, so copy away! */
\r
646 mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, mv->dy);
\r
647 i += mv->map->width;
\r
656 boolean pagenorendermap = 0;
\r
657 boolean pagedelayrendermap = 0;
\r
660 void shinku(global_game_variables_t *gv)
\r
662 word x = (0) + gv->video.page[/*!*/(gv->video.p)].dx; // follow the screen
\r
663 word y = (0) + gv->video.page[/*!*/(gv->video.p)].dy; // follow the screen
\r
664 word col = 2, bgcol = 1, type = 1;//w = 64, h = 8, //col7bgcol0
\r
666 //modexCopyPageRegion(pip[1].page, pip[2].page, 16, 16, 16, 16, (14*8)+4, 8+4);
\r
667 /* block copy to visible RAM from offscreen */
\r
668 // vga_setup_wm1_block_copy();
\r
669 // modexCopyPageRegion(&(gv->video.page[gv->video->sfip]), &(gv->video.page[!gv->video->sfip]), x, y, x+w, 0, w, h);
\r
670 // o = *(gv->video.page[2].data); // source offscreen
\r
671 // o2 = *(gv->video.page[gv->video->sfip].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride)
\r
672 // 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
673 /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */
\r
674 // vga_restore_rm0wm0();
\r
675 if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second))
\r
677 // NTS: For some bizarre reason, gv->pee is not initialized, but the pointer is not NULL even
\r
678 // though it should be. Instead it's NULL as a neAr pointer but contains a non-null
\r
679 // segment value, so testing against NULL doesn't work. It is initialized properly if
\r
680 // you call start_timer() though which uses neAr malloc. Rather than fight with that,
\r
681 // I decided it would be better to declare a temp buffer statically and sprintf to that.
\r
683 // This fixes *** Null pointer assignment detected error message in ZCROLL.EXE on exit.
\r
684 sprintf(global_temp_status_text, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv));
\r
685 //modexClearRegion(&(gv->video.page[gv->video->sfip]), x, y, w, h, 45);
\r
686 modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, col, bgcol, global_temp_status_text);
\r
687 gv->kurokku.tiku=0;
\r
688 /* block copy to visible RAM from offscreen */
\r
689 // vga_setup_wm1_block_copy();
\r
690 // o = *(gv->video.page[gv->video->sfip].data); // source offscreen
\r
691 // o2 = *(gv->video.page[2].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride)
\r
692 // 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
693 // modexCopyPageRegion(&(gv->video.page[gv->video->sfip]), &(gv->video.page[!gv->video->sfip]), x, y, x, 0, w, h);
\r
694 /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */
\r
695 // vga_restore_rm0wm0();
\r
696 }else //copy dat sheet
\r
697 gv->kurokku.tiku++;
\r
699 switch(gv->kurokku.fpscap)
\r
702 //modexprint(&(gv->video.page[gv->video->sfip]), x, y+8, type, col, bgcol, "sanic!");
\r
703 gv->kurokku.frames_per_second=1;
\r
706 //turn this off if XT
\r
707 //modexWaitBorder();
\r
708 //vga_wait_for_vsync();
\r
709 gv->kurokku.frames_per_second=60;
\r
717 modexCopyPageRegion(&(gv->video.page[ ]), &(gv->video.page[ ]), 0, 0, 0, 0, gv->video.page[ ].width, gv->video.page[ ].height);
\r
719 //modexCopyPageRegion(&video->page[0], &video->page[1], enti->x, enti->y, 0, 0, 24, 32);
\r
721 VL_ShowPage(&(gv->video.page[gv->video.sp]), gv->kurokku.fpscap, 0);
\r
722 gv->video.r =!gv->video.r ;
\r
723 //0000gv->video.tickclk = ((*clockw)-gv->video.startclk)/18.2;
\r
728 void near ZC_drawframe(map_view_t *pip, entity_t *enti, sword x, sword y)
\r
730 switch(pip[0].video->rss)
\r
733 animate_spri(enti, pip->video);
\r
736 animate_spri(enti, pip->video);
\r
739 // modexClearRegion(&(pip[0].page[0]), x, y, 16, 32, player[pn].enti.dire);
\r
745 #define FRAME1 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 48, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR);
\r
746 #define FRAME2 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR);
\r
747 #define FRAME3 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 0, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR);
\r
748 #define FRAME4 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR);
\r
750 #define FRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 2+player[pn].enti.dire);
\r
751 #define FRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+player[pn].enti.dire);
\r
752 #define FRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, player[pn].enti.dire);
\r
753 #define FRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+player[pn].enti.dire);
\r
756 void animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch)
\r
758 sword x = player[pn].enti.x;
\r
759 sword y = player[pn].enti.y;
\r
760 sword bx = x+16; //buffer's x
\r
761 sword by = y+16; //buffer's y
\r
762 sword qq; //scroll offset
\r
763 word ls = 0;//player[pn].enti.persist_aniframe;
\r
764 player[pn].enti.dire=32; //direction
\r
766 switch(scrollswitch)
\r
772 qq = ((player[pn].enti.q)*(player[pn].enti.speed));
\r
776 y-=pip[0].map->tiles->tileHeight;
\r
777 switch (player[pn].enti.d)
\r
781 player[pn].enti.dire*=player[pn].enti.d;
\r
787 player[pn].enti.dire*=(player[pn].enti.d-2);
\r
795 player[pn].enti.dire*=(player[pn].enti.d-2);
\r
801 player[pn].enti.dire*=(player[pn].enti.d+2);
\r
807 // if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 36);
\r
809 // //copy old bg to page0
\r
810 // //modexCopyPageRegion(pip[3].page, pip[0].page, bx, by, 0, 0, 20, 36);
\r
812 // //modexCopyPageRegion(pip[0].page, pip[3].page, 0, 0, x, y, 20, 36);
\r
814 //modexCopyPageRegion(page_t *dest, page_t *src, word sx, word sy, word dx, word dy, word width, word height);
\r
815 //modexCopyPageRegion(pip[3].page, pip[!(pip->video->p)].page, x-4, y-4, 0, 128, 28, 36);
\r
816 /*modexCopyPageRegion(pip[pip->video->p].page,
\r
817 pip[!(pip->video->p)].page, x-4, y-4, x-4, y-4, 28, 36);*/
\r
818 // else modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 40);
\r
834 // if(2>ls && ls>=1) { FRAME1 }else
\r
835 // if(3>ls && ls>=2) { FRAME2 }else
\r
836 // if(4>ls && ls>=3) { FRAME3 }else
\r
837 // if(5>ls && ls>=4) { FRAME4 }
\r
838 //modexCopyPageRegion(pip[0].page, pip[3].page, 0, 0, x, y, 24, 32);
\r
839 //printf("x=%d y=%d bx=%d by=%d\n", x, y, bx, by);
\r
843 void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch)
\r
845 sword x = player[pn].enti.x;
\r
846 sword y = player[pn].enti.y;
\r
847 sword qq,dd; //scroll offset
\r
848 player[pn].enti.dire=10; //direction
\r
850 switch(scrollswitch)
\r
862 qq = ((player[pn].enti.q)*(player[pn].enti.speed));
\r
866 y-=pip[0].map->tiles->tileHeight;
\r
867 switch (player[pn].enti.d)
\r
871 player[pn].enti.dire*=player[pn].enti.d+1;
\r
876 player[pn].enti.dire*=(player[pn].enti.d-1);
\r
883 player[pn].enti.dire*=(player[pn].enti.d-1);
\r
888 player[pn].enti.dire*=(player[pn].enti.d+3);
\r
892 player[pn].enti.dire+=dd;
\r
893 if((player[pn].enti.q==1 && player[pn].enti.pred != player[pn].enti.d) || !dd)
\r
895 set_anim_by_id(player[pn].enti.spri, player[pn].enti.dire); //pip->video->sprifilei = set_anim_by_id(player[pn].enti.spri, player[pn].enti.dire); if(pip->video->sprifilei == -1){ printf("ERROR! %u\n", player[pn].enti.dire); return; }
\r
896 player[pn].enti.pred = player[pn].enti.d;
\r
899 //setting xy position
\r
900 player[pn].enti.spri->x = x;
\r
901 player[pn].enti.spri->y = y;
\r
903 if(pip[0].video->bgps)
\r
904 modexCopyPageRegion(pip[0].page, pip[1].page, x-4, y-4, x-4, y-4, 28, 40);
\r
906 ZC_drawframe(pip, &player[pn].enti, x, y);
\r
907 //0000if(player[pn].enti.q<2) delay(200);
\r
915 boolean boundary_check(int x, int y, int dx, int dy, int h, int w)
\r
917 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
920 boolean coll_check(int x, int y, int dx, int dy, map_view_t *map_v)
\r
922 // Assume everything crosses at most 1 tile at once
\r
923 return dx && 1;//crossable_tile(x + dx, map_v) || dy && crossable_tile(y + dy, map_v);
\r
926 boolean ZC_walk2(entity_t *enti, map_view_t *map_v)
\r
946 if(coll_check(enti->x, enti->y, dx, dy, map_v))
\r
951 // Mark next tile as occupied
\r
952 // Mark this tile as vacant
\r
958 void player_walk(player_t *player, map_view_t *map_v){
\r
960 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->ti.tilesw, map_v->map->height - 2*map_v->page->ti.tilesh))
\r
962 mapScroll(map_v, player);
\r
967 void mapScroll(map_view_t *mv, player_t *player)
\r
969 //word x, y; /* coordinate for drawing */
\r
972 mv->delta += player->dx | player->dy;
\r
974 mv->d = (player->dx) ? (player->dx > 0) ? 3 : 1 : (player->dy) ? (player->dy > 0) ? 4 : 0 : 2;
\r
980 if(!(delta + mv->dxThresh))
\r
990 if(!(delta + mv->dyThresh))
\r