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
23 #include "src/lib/scroll16.h"
\r
24 #include "src/lib/16_timer.h"
\r
25 #include "src/lib/16_dbg.h"
\r
30 //#define OLDPLAYERSPRITESTUFF
\r
31 #define XC_CTRLTYPE ctrl_Keyboard//ctrl_Joystick1//ctrl_Mouse
\r
33 #define SCROLLEXEDEBUG
\r
37 #ifdef OLDPLAYERSPRITESTUFF
\r
38 #include "src/lib/bitmapl.h"
\r
39 static int persist_aniframe = 0; /* gonna be increased to 1 before being used, so 0 is ok for default */
\r
40 #define INC_PER_FRAME if(gvar->player[pn].enti.q&1) persist_aniframe++; if(persist_aniframe>4) persist_aniframe = 1;
\r
42 void modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp);
\r
43 void modexDrawSpriteRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp);
\r
44 boolean ZCL_ScreenMidPosChk(map_view_t *map_v, nibble dir, int tx, int ty);
\r
45 boolean ZCL_CollCheck(map_view_t *map_v, nibble dir, int tx, int ty);
\r
46 boolean ZCL_mapEdgeChk(map_view_t *map_v, nibble dir, int tx, int ty, boolean pansw, boolean noscrollsw);
\r
47 void oldwalk(global_game_variables_t *gvar, word pn, bitmap_t *pbmp);
\r
48 void animatePlayer(global_game_variables_t *gvar, /*map_view_t *top, */short d1, short d2, int x, int y, int ls, int lp, bitmap_t *bmp);
\r
53 boolean panswitch=0,baka=0;
\r
54 //extern boolean pageflipflop=1;
\r
55 extern boolean pagenorendermap; //default: 0
\r
59 //static word paloffset=0;
\r
63 boolean spriteswitch=0;
\r
65 #define FILENAME_1 "data/spri/chikyuu.vrs"
\r
66 #define FILENAME_1P "data/spri/chikyuu.pal"
\r
67 #define FILENAME_2 "data/spri/me.vrs"
\r
68 #define FILENAME_2P "data/spri/me.pal"
\r
69 //#define FILENAME_3 "data/spri/chistnd.vrl"
\r
71 void main(int argc, char *argv[])
\r
73 #ifdef OLDPLAYERSPRITESTUFF
\r
74 bitmap_t ptmp; // player sprite
\r
76 static global_game_variables_t gvar;
\r
77 struct glob_game_vars *ggvv;
\r
79 char bakapee[64] = FILENAME_1;
\r
80 char bakapeep[64] = FILENAME_1P;
\r
81 // char bakapee3[64] = FILENAME_3;
\r
84 dbg_joymousedelta=0;
\r
92 if(argv[1]){ strcpy(bakapee, argv[1]);
\r
93 if(argv[2]) strcpy(bakapeep, argv[2]); }
\r
96 // OK, this one takes hellova time and needs to be done in farmalloc or MM_...
\r
97 //IN CA i think you use CAL_SetupGrFile but i do think we should work together on this part --sparky4
\r
98 //----gvar.player[0].enti.spri.spritesheet = malloc(sizeof(struct vrs_container));
\r
101 #ifdef SCROLLEXEDEBUG
\r
102 //strcpy(gvar.handle.datadumpfilename, "mmdump1.16w"); MM_DumpData (&gvar);
\r
103 //strcpy(gvar.handle.heapdumpfilename, "heap1.16w"); HC_heapdump(&gvar);
\r
104 //fprintf(stderr, "testing map load~ ");
\r
107 CA_loadmap("data/test.map", &gvar.map, &gvar);
\r
108 chkmap(&gvar.map, 0);
\r
110 chkmap(&gvar.map, 1);
\r
112 //initMap(&gvar.map);
\r
113 #ifdef SCROLLEXEDEBUG
\r
114 printf("chkmap ok\n");
\r
115 // fprintf(stderr, "yay map loaded~~\n");
\r
116 //strcpy(gvar.handle.datadumpfilename, "mmdump2.16w"); MM_DumpData (&gvar);
\r
117 //strcpy(gvar.handle.heapdumpfilename, "heap2.16w"); HC_heapdump(&gvar);
\r
121 #ifdef OLDPLAYERSPRITESTUFF
\r
122 ptmp = bitmapLoadPcx("data/chikyuu.pcx"); // load sprite
\r
123 modexPalUpdate(ptmp.palette);
\r
125 #ifdef SCROLLEXEDEBUG
\r
126 fprintf(stderr, "VRS_LoadVRS~ ");
\r
127 //strcpy(gvar.handle.datadumpfilename, "mmdump3.16w"); MM_DumpData (&gvar);
\r
128 //strcpy(gvar.handle.heapdumpfilename, "heap3.16w"); HC_heapdump(&gvar);
\r
130 VRS_LoadVRS(bakapee, &gvar.player[0].enti, &gvar);
\r
131 #ifdef SCROLLEXEDEBUG
\r
132 printf("VRS load OK~\n");
\r
133 //strcpy(gvar.handle.datadumpfilename, "mmdump4.16w"); MM_DumpData (&gvar);
\r
134 //strcpy(gvar.handle.heapdumpfilename, "heap4.16w"); HC_heapdump(&gvar);
\r
139 IN_Default(0, &gvar.player[0],XC_CTRLTYPE, &gvar);
\r
140 IN_SetControlType(&gvar.player[0],XC_CTRLTYPE);
\r
142 // save the palette
\r
144 modexPalSave(&gvar.video.dpal);
\r
145 modexFadeOff(4, &gvar.video.dpal);
\r
149 //--VGAmodeX(1/*bakapee*/, 1, &gvar);
\r
152 /* load color palette */
\r
153 /*ptmp.offset=(paloffset/3);
\r
154 modexPalUpdate(&ptmp, &paloffset, 0, 0);
\r
155 //modexClearRegion(bg->page, 0, 0, 320, 240, 255);
\r
156 //printf(" %d\n", sizeof(ptmp.data));
\r
157 //printf("1: %d\n", paloffset);
\r
158 map.tiles->data->offset=(paloffset/3);
\r
159 modexPalUpdate(map.tiles->data, &paloffset, 0, 0);*/
\r
160 VL_LoadPalFile(bakapeep, &gvar.video.palette, &gvar);
\r
161 //VL_LoadPalFile("data/default.pal", &gvar.video.palette);
\r
164 modexPalSave(&gvar.video.palette);
\r
165 modexSavePalFile("data/g.pal", &gvar.video.palette);
\r
166 modexPalBlack(); //so player will not see loadings~
\r
169 // setup camera and screen~
\r
170 modexHiganbanaPageSetup(&gvar);
\r
171 ZC_MVSetup(&gvar.mv, &gvar.map, &gvar);
\r
174 modexFadeOn(4, &gvar.video.palette);
\r
177 //0000 IN_StartAck (&gvar); MM_ShowMemory(&gvar); while (!IN_CheckAck (&gvar)){}
\r
179 modexPalBlack(); //so player will not see loadings~
\r
183 //TODO: LOAD map data and position the map in the middle of the screen if smaller then screen
\r
184 mapGoTo(&gvar.mv, 0, 0);
\r
186 ZC_PlayerXYpos(0, 0, &gvar.player[0], &gvar.mv, 1);
\r
187 EN_initPlayer(&gvar.player[0], &gvar.video);
\r
189 #ifndef OLDPLAYERSPRITESTUFF
\r
190 //print_anim_ids(gvar.player[0].enti.spri);
\r
191 if (gvar.video.sprifilei == -1)
\r
194 modexFadeOff(4, &gvar.video.palette);
\r
196 Quit (&gvar, "Wrong ID for sprite");
\r
198 modexFadeOn(4, &gvar.video.dpal);
\r
204 // while(!gvar.in.inst->Keyboard[sc_Escape) && !gvar.in.inst->Keyboard[sc_Space) && !gvar.in.inst->Keyboard[sc_Enter]){ FUNCTIONKEYSHOWMV }
\r
205 gvar.video.page[0].tlx=gvar.mv[0].tx*TILEWH;
\r
206 gvar.video.page[0].tly=gvar.mv[0].ty*TILEWH;
\r
208 #ifdef OLDWALKSHOWPAGESTUFF
\r
209 VL_ShowPage(&(gvar.video.page[gvar.video.sp]), gvar.kurokku.fpscap, 0);
\r
213 //modexpdump(gvar.mv[0].page);
\r
215 modexFadeOn(4, &gvar.video.palette);
\r
217 while(!gvar.in.inst->Keyboard[sc_Escape] && gvar.player[0].enti.hp>0)
\r
219 gvar.video.page[0].tlx=gvar.mv[0].tx*TILEWH;
\r
220 gvar.video.page[0].tly=gvar.mv[0].ty*TILEWH;
\r
222 //top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square
\r
223 //to stop scrolling and have the gvar.player position data move to the edge of the screen with respect to the direction
\r
224 //when gvar.player[0].tx or gvar.player[0].ty == 0 or gvar.player[0].tx == 20 or gvar.player[0].ty == 15 then stop because that is edge of map and you do not want to walk of the map
\r
226 //gvar.player movement
\r
227 IN_ReadControl(&gvar.player[0], &gvar);
\r
229 //ZC_walk2(gvar.player[0].ent, mv);
\r
230 //ZC_walk(&gvar.mv, &gvar.player, 0);
\r
231 #ifdef OLDPLAYERSPRITESTUFF
\r
232 oldwalk(&gvar, 0, &ptmp);
\r
238 //printf(" gvar.player[0].enti.q: %d", gvar.player[0].enti.q); printf(" gvar.player[0].d: %d\n", gvar.player[0].d);
\r
241 //the scripting stuff....
\r
242 //if(((gvar.player[0].enti.triggerx == TRIGGX && gvar.player[0].enti.triggery == TRIGGY) && gvar.in.inst->Keyboard[0x1C))||(gvar.player[0].enti.tx == 5 && gvar.player[0].enti.ty == 5))
\r
243 if(((gvar.mv[0].map->layerdata[0].data[(gvar.player[0].enti.triggerx-1)+(gvar.map.width*(gvar.player[0].enti.triggery-1))] == 0) && gvar.in.inst->Keyboard[0x1C])||(gvar.player[0].enti.tx == 5 && gvar.player[0].enti.ty == 5))
\r
246 for(i=800; i>=400; i--)
\r
252 if(gvar.player[0].enti.q == (TILEWH/(gvar.player[0].enti.spt))+1 && gvar.player[0].info.dir != 2 && (gvar.player[0].enti.triggerx == 5 && gvar.player[0].enti.triggery == 5)){ gvar.player[0].enti.hp--; }
\r
254 // if(gvar.in.inst->Keyboard[24]){ VL_modexPalScramble(&gvar.video.palette); /*paloffset=0;*/ VL_LoadPalFileCore(&gvar.video.palette, &gvar); modexpdump(gvar.mv[0].page); IN_UserInput(1, &gvar); } //o
\r
255 if(gvar.in.inst->Keyboard[sc_O]){ VL_LoadPalFileCore(&gvar.video.palette, &gvar); modexpdump(gvar.video.sp, &gvar); IN_UserInput(1, &gvar); } //o
\r
256 if(gvar.in.inst->Keyboard[22]){ VL_modexPalScramble(&gvar.video.palette); VL_LoadPalFileCore(&gvar.video.palette, &gvar); } //u
\r
258 TAIL_FUNCTIONKEYFUNCTIONS
\r
259 TAIL_FUNCTIONKEYDRAWJUNK
\r
260 if(gvar.in.inst->Keyboard[sc_L]){ modexClearRegion(&gvar.video.page[0], gvar.player[0].enti.x, gvar.player[0].enti.y, 16, 16, 1); }
\r
262 //===============================================================================
\r
264 if(gvar.in.inst->Keyboard[sc_BackSlash]){
\r
265 VRS_ReadVRL(bakapee3, &gvar.player[0].enti, &gvar);
\r
267 gvar.player[0].enti.x,
\r
268 gvar.player[0].enti.y,
\r
269 gvar.player[0].enti.spri.sprite_vrl_cont.vrl_header,
\r
270 gvar.player[0].enti.spri.sprite_vrl_cont.line_offsets,
\r
271 gvar.player[0].enti.spri.sprite_vrl_cont.buffer + sizeof(struct vrl1_vgax_header),
\r
272 gvar.player[0].enti.spri.sprite_vrl_cont.data_size
\r
273 ); while (!IN_CheckAck (&gvar)){}
\r
274 VRS_ReadVRS(bakapee, &gvar.player[0].enti, &gvar);
\r
275 IN_UserInput(1, &gvar); }
\r
277 //===============================================================================
\r
279 #ifdef OLDPLAYERSPRITESTUFF
\r
280 if(gvar.in.inst->Keyboard[sc_J])// || gvar.in.inst->Keyboard[sc_K])
\r
282 // sprintf(global_temp_status_text2, "%Fp", &ptmp.data);
\r
283 // modexprint(&(gvar.video.page[0]), gvar.video.page[0].sw/2, gvar.video.page[0].sh/2, 1, 1, 3/*ccolor*/, 8, gvar.video.VL_Started, global_temp_status_text2);
\r
284 modexDrawSprite(&gvar.video.page[0], 16, 16, &ptmp);
\r
286 if(gvar.in.inst->Keyboard[sc_K])
\r
288 _fmemset(ptmp.data, 4, (ptmp.width)*ptmp.height);
\r
291 if(gvar.in.inst->Keyboard[sc_J])// || gvar.in.inst->Keyboard[sc_K])
\r
293 if(spriteswitch)//gvar.in.inst->Keyboard[sc_J])
\r
295 strcpy(bakapee, FILENAME_1);
\r
296 strcpy(bakapeep, FILENAME_1P);
\r
297 gvar.player[0].enti.overdraww=0;
\r
299 else//if(gvar.in.inst->Keyboard[sc_K])
\r
301 strcpy(bakapee, FILENAME_2);
\r
302 strcpy(bakapeep, FILENAME_2P);
\r
303 gvar.player[0].enti.overdraww=2;
\r
305 spriteswitch=!spriteswitch;
\r
307 //read_vrs(&gvar, bakapee, gvar.player[0].enti.spri->spritesheet);
\r
308 VRS_ReadVRS(bakapee, &gvar.player[0].enti, &gvar);
\r
309 VL_LoadPalFile(bakapeep, &gvar.video.palette, &gvar);
\r
310 ZC_animatePlayer(&gvar.mv, &gvar.player, 0);
\r
311 IN_UserInput(1, &gvar);
\r
315 // if(gvar.in.inst->Keyboard[10]){ modexPalOverscan(rand()%56); modexPalUpdate(gvar.video.dpal); IN_UserInput(1, &gvar); }
\r
317 if(gvar.in.inst->Keyboard[sc_R]){ VL_modexPalOverscan(&gvar.video.palette, rand()%32); } //r
\r
318 if(gvar.in.inst->Keyboard[sc_F]){ VL_SetPalette(&gamepal, &gvar.video); } //f
\r
321 //if((gvar.player[0].enti.q==1) && !(gvar.player[0].enti.x%TILEWH==0 && gvar.player[0].enti.y%TILEWH==0)) Quit (&gvar, "PLAYER OFF THE RAILS!");//break; //incase things go out of sync!
\r
322 ZC_GirdChk(&gvar, &gvar.player[0]);
\r
325 /* fade back to text mode */
\r
326 /* but 1st lets save the game palette~ */
\r
328 modexPalSave(&gvar.video.palette);
\r
329 modexSavePalFile("data/g.pal", &gvar.video.palette);
\r
330 modexFadeOff(4, &gvar.video.palette);
\r
332 #ifdef SCROLLEXEDEBUG
\r
333 MM_DumpData (&gvar);
\r
334 HC_heapdump (&gvar);
\r
337 printf("\nProject 16 xcroll.exe. This is just a test file!\n");
\r
338 printf("version %s\n", VERSION);
\r
342 modexFadeOn(4, gvar.video.dpal);
\r
356 #ifdef OLDPLAYERSPRITESTUFF
\r
358 modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp) {
\r
359 /* draw the whole sprite */
\r
360 modexDrawSpriteRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);
\r
361 // sprintf(global_temp_status_text2, "%Fp", &bmp->data);
\r
362 // modexprint(page, page->sw/2, (page->sh/2)+8, 1, 1, 3/*ccolor*/, 8, gvar->video.VL_Started, global_temp_status_text2);
\r
366 modexDrawSpriteRegion(page_t *page, int x, int y,
\r
367 int rx, int ry, int rw, int rh, bitmap_t *bmp) {
\r
368 word poffset = (word)page->data + y*(page->width/4) + x/4;
\r
369 byte *data = bmp->data;
\r
370 word bmpOffset = (word) data + ry * bmp->width + rx;
\r
373 byte plane = 1 << ((byte) x & 0x03);
\r
374 word scanCount = width/4 + (width%4 ? 1 :0);
\r
375 word nextPageRow = page->width/4 - scanCount;
\r
376 word nextBmpRow = (word) bmp->width - width;
\r
378 byte planeCounter = 4;
\r
380 // sprintf(global_temp_status_text2, "%Fp", bmp->data);
\r
381 // modexprint(page, page->sw/2, (page->sh/2)+8, 1, 1, 3/*ccolor*/, 8, ggvv->video.VL_Started, global_temp_status_text2);
\r
382 // sprintf(global_temp_status_text2, "%Fp", data);
\r
383 // modexprint(page, page->sw/2, (page->sh/2)+16, 1, 1, 3/*ccolor*/, 8, ggvv->video.VL_Started, global_temp_status_text2);
\r
386 MOV AX, SCREEN_SEG ; go to the VGA memory
\r
389 MOV DX, SC_INDEX ; point at the map mask register
\r
390 MOV AL, SC_MAPMASK ;
\r
394 MOV DX, SC_DATA ; select the current plane
\r
398 ;-- begin plane painting
\r
399 MOV AX, height ; start the row counter
\r
400 MOV rowCounter, AX ;
\r
401 MOV DI, poffset ; go to the first pixel
\r
402 MOV SI, bmpOffset ; go to the bmp pixel
\r
404 MOV CX, width ; count the columns
\r
409 JNE DRAW_PIXEL ; draw non-zero pixels
\r
411 INC DI ; skip the transparent pixel
\r
415 MOVSB ; copy the pixel
\r
417 SUB CX, 3 ; we skip the next 3
\r
418 ADD SI, 3 ; skip the bmp pixels
\r
419 LOOP SCAN_LOOP ; finish the scan
\r
421 MOV AX, nextPageRow
\r
422 ADD DI, AX ; go to the next row on screen
\r
424 ADD SI, AX ; go to the next row on bmp
\r
427 JNZ ROW_LOOP ; do all the rows
\r
428 ;-- end plane painting
\r
430 MOV AL, plane ; advance to the next plane
\r
432 AND AL, 0x0f ; mask the plane properly
\r
433 MOV plane, AL ; store the plane
\r
435 INC bmpOffset ; start bmp at the right spot
\r
438 JNZ PLANE_LOOP ; do all 4 planes
\r
442 void oldwalk(global_game_variables_t *gvar, word pn, bitmap_t *pbmp)
\r
444 switch(gvar->player[pn].enti.d)
\r
448 //0000gvar->mv[0].video->startclk = (*clockw);
\r
452 if(ZCL_ScreenMidPosChk(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty) &&
\r
453 ZCL_CollCheck(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty))//!(gvar->player[pn].enti.tx+1 == TRIGGX && gvar->player[pn].enti.ty == TRIGGY)) //collision detection!
\r
455 gvar->player[pn].walktype=2;
\r
456 if(gvar->player[pn].enti.q<=gvar->player[pn].enti.spt)
\r
459 animatePlayer(gvar, 1, 1, gvar->player[pn].enti.x, gvar->player[pn].enti.y, persist_aniframe, gvar->player[pn].enti.q, pbmp);
\r
460 ZC_mapScroll(gvar->mv, gvar->player, pn);
\r
461 gvar->player[pn].enti.q++;
\r
462 //0000gvar->mv[0].video->clk = ((*clockw)-gvar->mv[0].video->startclk)/18.2;
\r
463 modexShowPage(&gvar->video.page[0]);
\r
464 } else { gvar->player[pn].enti.q = 1; gvar->player[pn].enti.d = 2; gvar->player[pn].enti.tx++; }
\r
466 else if(ZCL_mapEdgeChk(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty, 0, 1) &&
\r
467 ZCL_CollCheck(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty))//!(gvar->player[pn].enti.tx+1 == TRIGGX && gvar->player[pn].enti.ty == TRIGGY))
\r
469 gvar->player[pn].walktype=1;
\r
470 if(gvar->player[pn].enti.q<=gvar->player[pn].enti.spt)
\r
473 gvar->player[pn].enti.x+=(gvar->player[pn].enti.spt);
\r
474 animatePlayer(gvar, 1, 0, gvar->player[pn].enti.x, gvar->player[pn].enti.y, persist_aniframe, gvar->player[pn].enti.q, pbmp);
\r
475 gvar->player[pn].enti.q++;
\r
476 modexShowPage(&gvar->video.page[0]);
\r
477 } else { gvar->player[pn].enti.q = 1; gvar->player[pn].enti.d = 2; gvar->player[pn].enti.tx++; }
\r
481 gvar->player[pn].walktype=0;
\r
482 //ZC_animatePlayer(gvar->mv, gvar->player, pn);
\r
483 modexShowPage(&gvar->video.page[0]);
\r
484 gvar->player[pn].enti.d = 2;
\r
486 gvar->player[pn].enti.triggerx = gvar->player[pn].enti.tx+1;
\r
487 gvar->player[pn].enti.triggery = gvar->player[pn].enti.ty;
\r
491 if(ZCL_ScreenMidPosChk(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty) &&
\r
492 ZCL_CollCheck(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty))//!(gvar->player[pn].enti.tx-1 == TRIGGX && gvar->player[pn].enti.ty == TRIGGY)) //collision detection!
\r
494 gvar->player[pn].walktype=2;
\r
495 if(gvar->player[pn].enti.q<=gvar->player[pn].enti.spt)
\r
498 animatePlayer(gvar, 1, 1, gvar->player[pn].enti.x, gvar->player[pn].enti.y, persist_aniframe, gvar->player[pn].enti.q, pbmp);
\r
499 ZC_mapScroll(gvar->mv, gvar->player, pn);
\r
500 gvar->player[pn].enti.q++;
\r
501 //0000gvar->mv[0].video->clk = ((*clockw)-gvar->mv[0].video->startclk)/18.2;
\r
502 modexShowPage(&gvar->video.page[0]);
\r
503 } else { gvar->player[pn].enti.q = 1; gvar->player[pn].enti.d = 2; gvar->player[pn].enti.tx--; }
\r
505 else if(ZCL_mapEdgeChk(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty, 0, 1) &&
\r
506 ZCL_CollCheck(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty))//!(gvar->player[pn].enti.tx-1 == TRIGGX && gvar->player[pn].enti.ty == TRIGGY))
\r
508 gvar->player[pn].walktype=1;
\r
509 if(gvar->player[pn].enti.q<=gvar->player[pn].enti.spt)
\r
512 gvar->player[pn].enti.x-=(gvar->player[pn].enti.spt);
\r
513 animatePlayer(gvar, 1, 0, gvar->player[pn].enti.x, gvar->player[pn].enti.y, persist_aniframe, gvar->player[pn].enti.q, pbmp);
\r
514 gvar->player[pn].enti.q++;
\r
515 modexShowPage(&gvar->video.page[0]);
\r
516 } else { gvar->player[pn].enti.q = 1; gvar->player[pn].enti.d = 2; gvar->player[pn].enti.tx--; }
\r
520 gvar->player[pn].walktype=0;
\r
521 //ZC_animatePlayer(gvar->mv, gvar->player, pn);
\r
522 modexShowPage(&gvar->video.page[0]);
\r
523 gvar->player[pn].enti.d = 2;
\r
525 gvar->player[pn].enti.triggerx = gvar->player[pn].enti.tx-1;
\r
526 gvar->player[pn].enti.triggery = gvar->player[pn].enti.ty;
\r
530 if(ZCL_ScreenMidPosChk(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty) &&
\r
531 ZCL_CollCheck(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty))//!(gvar->player[pn].enti.tx == TRIGGX && gvar->player[pn].enti.ty+1 == TRIGGY)) //collision detection!
\r
533 gvar->player[pn].walktype=2;
\r
534 if(gvar->player[pn].enti.q<=gvar->player[pn].enti.spt)
\r
537 animatePlayer(gvar, 1, 1, gvar->player[pn].enti.x, gvar->player[pn].enti.y, persist_aniframe, gvar->player[pn].enti.q, pbmp);
\r
538 ZC_mapScroll(gvar->mv, gvar->player, pn);
\r
539 gvar->player[pn].enti.q++;
\r
540 //0000gvar->mv[0].video->clk = ((*clockw)-gvar->mv[0].video->startclk)/18.2;
\r
541 modexShowPage(&gvar->video.page[0]);
\r
542 } else { gvar->player[pn].enti.q = 1; gvar->player[pn].enti.d = 2; gvar->player[pn].enti.ty++; }
\r
544 else if(ZCL_mapEdgeChk(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty, 0, 1) &&
\r
545 ZCL_CollCheck(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty))//!(gvar->player[pn].enti.tx == TRIGGX && gvar->player[pn].enti.ty+1 == TRIGGY))
\r
547 gvar->player[pn].walktype=1;
\r
548 if(gvar->player[pn].enti.q<=gvar->player[pn].enti.spt)
\r
551 gvar->player[pn].enti.y+=(gvar->player[pn].enti.spt);
\r
552 animatePlayer(gvar, 1, 0, gvar->player[pn].enti.x, gvar->player[pn].enti.y, persist_aniframe, gvar->player[pn].enti.q, pbmp);
\r
553 gvar->player[pn].enti.q++;
\r
554 modexShowPage(&gvar->video.page[0]);
\r
555 } else { gvar->player[pn].enti.q = 1; gvar->player[pn].enti.d = 2; gvar->player[pn].enti.ty++; }
\r
559 gvar->player[pn].walktype=0;
\r
560 //ZC_animatePlayer(gvar->mv, gvar->player, pn);
\r
561 modexShowPage(&gvar->video.page[0]);
\r
562 gvar->player[pn].enti.d = 2;
\r
564 gvar->player[pn].enti.triggerx = gvar->player[pn].enti.tx;
\r
565 gvar->player[pn].enti.triggery = gvar->player[pn].enti.ty+1;
\r
569 if(ZCL_ScreenMidPosChk(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty) &&
\r
570 ZCL_CollCheck(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty))//!(gvar->player[pn].enti.tx == TRIGGX && gvar->player[pn].enti.ty-1 == TRIGGY)) //collision detection!
\r
572 gvar->player[pn].walktype=2;
\r
573 if(gvar->player[pn].enti.q<=gvar->player[pn].enti.spt)
\r
576 animatePlayer(gvar, 1, 1, gvar->player[pn].enti.x, gvar->player[pn].enti.y, persist_aniframe, gvar->player[pn].enti.q, pbmp);
\r
577 ZC_mapScroll(gvar->mv, gvar->player, pn);
\r
578 gvar->player[pn].enti.q++;
\r
579 //0000gvar->mv[0].video->clk = ((*clockw)-gvar->mv[0].video->startclk)/18.2;
\r
580 modexShowPage(&gvar->video.page[0]);
\r
581 } else { gvar->player[pn].enti.q = 1; gvar->player[pn].enti.d = 2; gvar->player[pn].enti.ty--; }
\r
583 else if(ZCL_mapEdgeChk(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty, 0, 1) &&
\r
584 ZCL_CollCheck(gvar->mv, gvar->player[pn].enti.d, gvar->player[pn].enti.tx, gvar->player[pn].enti.ty))//!(gvar->player[pn].enti.tx == TRIGGX && gvar->player[pn].enti.ty-1 == TRIGGY))
\r
586 gvar->player[pn].walktype=1;
\r
587 if(gvar->player[pn].enti.q<=gvar->player[pn].enti.spt)
\r
590 gvar->player[pn].enti.y-=(gvar->player[pn].enti.spt);
\r
591 animatePlayer(gvar, 1, 0, gvar->player[pn].enti.x, gvar->player[pn].enti.y, persist_aniframe, gvar->player[pn].enti.q, pbmp);
\r
592 gvar->player[pn].enti.q++;
\r
593 modexShowPage(&gvar->video.page[0]);
\r
594 } else { gvar->player[pn].enti.q = 1; gvar->player[pn].enti.d = 2; gvar->player[pn].enti.ty--; }
\r
598 gvar->player[pn].walktype=0;
\r
599 //ZC_animatePlayer(gvar->mv, gvar->player, pn);
\r
600 modexShowPage(&gvar->video.page[0]);
\r
601 gvar->player[pn].enti.d = 2;
\r
603 gvar->player[pn].enti.triggerx = gvar->player[pn].enti.tx;
\r
604 gvar->player[pn].enti.triggery = gvar->player[pn].enti.ty-1;
\r
609 void animatePlayer(global_game_variables_t *gvar, /*map_view_t *top, */short d1, short d2, int x, int y, int ls, int lp, bitmap_t *bmp)
\r
611 short dire=32*d1; //direction
\r
612 short qq; //scroll offset
\r
615 else qq = ((lp)*gvar->player[0].enti.spt);
\r
639 modexCopyPageRegion(gvar->mv[0].page, gvar->mv[1].page, x-4, y-4, x-4, y-4, 28, 40);
\r
640 if(2>ls && ls>=1) { modexDrawSpriteRegion(gvar->mv[0].page, x, y, 48, dire, 24, 32, bmp); }else
\r
641 if(3>ls && ls>=2) { modexDrawSpriteRegion(gvar->mv[0].page, x, y, 24, dire, 24, 32, bmp); }else
\r
642 if(4>ls && ls>=3) { modexDrawSpriteRegion(gvar->mv[0].page, x, y, 0, dire, 24, 32, bmp); }else
\r
643 if(5>ls && ls>=4) { modexDrawSpriteRegion(gvar->mv[0].page, x, y, 24, dire, 24, 32, bmp); }
\r
644 //TODO: mask copy //modexCopyPageRegion(gvar->mv[0].page, gvar->mv[0].page, x-4, y-4, x-4, y-4, 28, 40);
\r
645 //modexClearRegion(top->page, 66, 66, 2, 40, 0);
\r
646 //modexCopyPageRegion(gvar->mv[0].page, top->page, 66, 66, 66, 66, 2, 40);
\r
647 //turn this off if XT
\r
648 //if(detectcpu() > 0) modexWaitBorder();
\r
649 switch(gvar->kurokku.fpscap)
\r
651 case 0: //turn this off if XT
\r
652 //modexprint(&(gv->video.page[0]), x, y+8, type, 1, col, bgcol, "sanic!");
\r
653 gvar->kurokku.frames_per_second=1;
\r
657 gvar->kurokku.frames_per_second=FPSVALUE;
\r
660 PM_NextFrame(gvar);
\r