From: sparky4 Date: Wed, 18 Jan 2017 18:00:03 +0000 (-0600) Subject: fine tuning animation still X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=cdb255713796ffb83b3bc2676e079871c4b47731;p=16.git fine tuning animation still --- diff --git a/src/lib/16_sprit.c b/src/lib/16_sprit.c index 3895cc72..e32e9f96 100755 --- a/src/lib/16_sprit.c +++ b/src/lib/16_sprit.c @@ -97,26 +97,29 @@ void print_anim_ids(struct sprite *spri) } } -/* -void animate_spri(struct sprite *spri, global_game_variables_t *gv) +void oldanimate_spri(struct sprite *spri, video_t *video) { int i; // Events go here + vga_state.vga_graphics_ram = (VGA_RAM_PTR)video->page[0].data;//vga_state.vga_graphics_ram; // save original mem ptr + + // Draw sprite i = get_vrl_by_id(spri->spritesheet, spri->curr_spri_id, spri->sprite_vrl_cont); if(i < 0) { - Quit (gv, "Error retriving required sprite"); + //Quit (gv, "Error retriving required sprite"); + return; } // replace VGA stride with our own and mem ptr. then sprite rendering at this stage is just (0,0) - vga_state.vga_draw_stride_limit = (gv->video.page[0].width + 3 - spri->x) >> 2; + vga_state.vga_draw_stride_limit = (video->page[0].width + 3 - spri->x) >> 2; draw_vrl1_vgax_modex( - spri->x-gv->video.page[0].dx, - spri->y-gv->video.page[0].dy, + spri->x,//-video->page[0].dx, + spri->y,//-video->page[0].dy, spri->sprite_vrl_cont->vrl_header, spri->sprite_vrl_cont->line_offsets, spri->sprite_vrl_cont->buffer + sizeof(struct vrl1_vgax_header), @@ -124,7 +127,7 @@ void animate_spri(struct sprite *spri, global_game_variables_t *gv) ); // restore stride - vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = gv->video.page[0].stridew; + vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = video->page[0].stridew; // Depending on delay, update indices switch(spri->delay){ @@ -149,7 +152,8 @@ void animate_spri(struct sprite *spri, global_game_variables_t *gv) break; } } -*/ + + void animate_spri(struct sprite *spri, video_t *video) { #define GVARVIDEO video @@ -157,7 +161,7 @@ void animate_spri(struct sprite *spri, video_t *video) #define VMEMPAGEDATA2 GVARVIDEO->page[2].data unsigned int i,o,o2; int j; int x,y,rx,ry,w,h; - int overdraw = 1; // how many pixels to "overdraw" so that moving sprites with edge pixels don't leave streaks. + int overdraw = 0;//16; // how many pixels to "overdraw" so that moving sprites with edge pixels don't leave streaks. // if the sprite's edge pixels are clear anyway, you can set this to 0. VGA_RAM_PTR omemptr; @@ -165,7 +169,7 @@ void animate_spri(struct sprite *spri, video_t *video) omemptr = (VGA_RAM_PTR)video->page[0].data;//vga_state.vga_graphics_ram; // save original mem ptr - x=spri->x;//-4; + x=spri->x; y=spri->y; // Draw sprite @@ -201,6 +205,9 @@ void animate_spri(struct sprite *spri, video_t *video) vga_state.vga_graphics_ram = omemptr + VMEMPAGESIZE2; // then the sprite. note modding ram ptr means we just draw to (x&3,0) +#ifndef SPRITE + modexClearRegion(&GVARVIDEO->page[0], x, y, 16, 32, 1); +#else draw_vrl1_vgax_modex( x-rx, y-ry, @@ -209,7 +216,7 @@ void animate_spri(struct sprite *spri, video_t *video) spri->sprite_vrl_cont->buffer + sizeof(struct vrl1_vgax_header), spri->sprite_vrl_cont->data_size ); - +#endif // restore ptr vga_state.vga_graphics_ram = omemptr; diff --git a/src/lib/16_sprit.h b/src/lib/16_sprit.h index 386b42f1..a72e9671 100755 --- a/src/lib/16_sprit.h +++ b/src/lib/16_sprit.h @@ -23,6 +23,7 @@ #define __16_SPRI__ #include "src/lib/16_vrs.h" +#include "src/lib/scroll16.h" struct sprite { @@ -66,6 +67,7 @@ int set_anim_by_id(struct sprite *spri, int id); * In: * + struct sprite *spri - sprite to animate */ +void oldanimate_spri(struct sprite *spri, video_t *video); void animate_spri(struct sprite *spri, video_t *video); void print_anim_ids(struct sprite *spri); diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c index 4f758b05..07eb939f 100755 --- a/src/lib/16_vl.c +++ b/src/lib/16_vl.c @@ -374,6 +374,7 @@ VL_ShowPage(page_t *page, boolean vsync, boolean sr) { /* do PEL panning here */ outp(AC_INDEX, 0x33); outp(AC_INDEX, (page[0].dx & 0x03) << 1); + vga_state.vga_graphics_ram = (VGA_RAM_PTR)page[0].data; } //============================================================================= diff --git a/src/lib/scroll16.c b/src/lib/scroll16.c index d4a34e5c..d7b79bf5 100755 --- a/src/lib/scroll16.c +++ b/src/lib/scroll16.c @@ -26,10 +26,10 @@ #define ANIMATESPRIFUN ZC_animatePlayer -void oldwalk(map_view_t *pip, player_t *player, word pn) +#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; + +void ZC_walk(map_view_t *pip, player_t *player, word pn) { - #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; - //printf("player[%d].d=%d\n", pn, player[pn].enti.d); switch(player[pn].enti.d) { //no direction @@ -38,7 +38,6 @@ void oldwalk(map_view_t *pip, player_t *player, word pn) break; //right movement case 3: - //printf("pip[0].page->tilesw=%d ", pip[0].page->tilesw); printf("pip[0].page->tw=%d\n", pip[0].page->tw); 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 && !(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! { @@ -48,9 +47,7 @@ void oldwalk(map_view_t *pip, player_t *player, word pn) ANIMATESPRIFUN(pip, player, pn, 1); ScrollRight(pip, player, 3, pn); ScrollRight(pip, player, 2, pn); - //mapScrollRight(pip, player, !(pip[0].video->p), pn); mapScrollRight(pip, player, (pip[0].video->p), pn); - if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; } @@ -62,25 +59,22 @@ void oldwalk(map_view_t *pip, player_t *player, word pn) INC_PER_FRAME; player[pn].enti.x+=(player[pn].enti.speed); ANIMATESPRIFUN(pip, player, pn, 0); - if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; } } else { - 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); -#ifdef SPRITE - modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATAPTR); -#else - modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 14); -#endif - if(!pageflipflop) modexShowPage(pip[1].page); +//#ifdef SPRITE +//modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATAPTR); + ANIMATESPRIFUN(pip, player, pn, 0); +//#else +// modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 14); +//#endif player[pn].enti.d = 2; } player[pn].enti.triggerx = player[pn].enti.tx+1; player[pn].enti.triggery = player[pn].enti.ty; break; - //left movement case 1: 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 && @@ -92,9 +86,7 @@ void oldwalk(map_view_t *pip, player_t *player, word pn) ANIMATESPRIFUN(pip, player, pn, 1); ScrollLeft(pip, player, 3, pn); ScrollLeft(pip, player, 2, pn); - //mapScrollLeft(pip, player, !(pip[0].video->p), pn); mapScrollLeft(pip, player, (pip[0].video->p), pn); - if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; } @@ -106,25 +98,22 @@ void oldwalk(map_view_t *pip, player_t *player, word pn) INC_PER_FRAME; player[pn].enti.x-=(player[pn].enti.speed); ANIMATESPRIFUN(pip, player, pn, 0); - if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; } } else { - 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); -#ifdef SPRITE - modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATAPTR); -#else - modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 10); -#endif - if(!pageflipflop) modexShowPage(pip[1].page); +//#ifdef SPRITE +//modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATAPTR); + ANIMATESPRIFUN(pip, player, pn, 0); +//#else +// modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 10); +//#endif player[pn].enti.d = 2; } player[pn].enti.triggerx = player[pn].enti.tx-1; player[pn].enti.triggery = player[pn].enti.ty; break; - //down movement case 4: 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 && @@ -136,9 +125,7 @@ void oldwalk(map_view_t *pip, player_t *player, word pn) ANIMATESPRIFUN(pip, player, pn, 1); ScrollDown(pip, player, 3, pn); ScrollDown(pip, player, 2, pn); - //mapScrollDown(pip, player, !(pip[0].video->p), pn); mapScrollDown(pip, player, (pip[0].video->p), pn); - if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; } @@ -150,25 +137,22 @@ void oldwalk(map_view_t *pip, player_t *player, word pn) INC_PER_FRAME; player[pn].enti.y+=(player[pn].enti.speed); ANIMATESPRIFUN(pip, player, pn, 0); - if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; } } else { - 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); -#ifdef SPRITE - modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATAPTR); -#else - modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 9); -#endif - if(!pageflipflop) modexShowPage(pip[1].page); +//#ifdef SPRITE +//modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATAPTR); + ANIMATESPRIFUN(pip, player, pn, 0); +//#else +// modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 9); +//#endif player[pn].enti.d = 2; } player[pn].enti.triggerx = player[pn].enti.tx; player[pn].enti.triggery = player[pn].enti.ty+1; break; - //up movement case 0: 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 && @@ -180,9 +164,7 @@ void oldwalk(map_view_t *pip, player_t *player, word pn) ANIMATESPRIFUN(pip, player, pn, 1); ScrollUp(pip, player, 3, pn); ScrollUp(pip, player, 2, pn); - //mapScrollUp(pip, player, !(pip[0].video->p), pn); mapScrollUp(pip, player, (pip[0].video->p), pn); - if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; } @@ -194,19 +176,17 @@ void oldwalk(map_view_t *pip, player_t *player, word pn) INC_PER_FRAME; player[pn].enti.y-=(player[pn].enti.speed); ANIMATESPRIFUN(pip, player, 0, pn); - if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; } } else { - 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); -#ifdef SPRITE - modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATAPTR); -#else - modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 12); -#endif - if(!pageflipflop) modexShowPage(pip[1].page); +//#ifdef SPRITE +//modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATAPTR); + ANIMATESPRIFUN(pip, player, pn, 0); +//#else +// modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 12); +//#endif player[pn].enti.d = 2; } player[pn].enti.triggerx = player[pn].enti.tx; @@ -225,9 +205,9 @@ src/lib/scroll16.c: pip->video->r=1; src/lib/scroll16.c: mv->video->r=1; */ -void ZC_walk(map_view_t *pip, player_t *player, word pn) +void oldwalk(map_view_t *pip, player_t *player, word pn) { - #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; + //printf("player[%d].d=%d\n", pn, player[pn].enti.d); switch(player[pn].enti.d) { //no direction @@ -236,6 +216,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) break; //right movement case 3: + //printf("pip[0].page->tilesw=%d ", pip[0].page->tilesw); printf("pip[0].page->tw=%d\n", pip[0].page->tw); 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 && !(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! { @@ -245,7 +226,9 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) ANIMATESPRIFUN(pip, player, pn, 1); ScrollRight(pip, player, 3, pn); ScrollRight(pip, player, 2, pn); + //mapScrollRight(pip, player, !(pip[0].video->p), pn); mapScrollRight(pip, player, (pip[0].video->p), pn); + if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; } @@ -257,21 +240,25 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) INC_PER_FRAME; player[pn].enti.x+=(player[pn].enti.speed); ANIMATESPRIFUN(pip, player, pn, 0); + if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; } } else { + 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); #ifdef SPRITE modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATAPTR); #else modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 14); #endif + if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.d = 2; } player[pn].enti.triggerx = player[pn].enti.tx+1; player[pn].enti.triggery = player[pn].enti.ty; break; + //left movement case 1: 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 && @@ -283,7 +270,9 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) ANIMATESPRIFUN(pip, player, pn, 1); ScrollLeft(pip, player, 3, pn); ScrollLeft(pip, player, 2, pn); + //mapScrollLeft(pip, player, !(pip[0].video->p), pn); mapScrollLeft(pip, player, (pip[0].video->p), pn); + if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; } @@ -295,21 +284,25 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) INC_PER_FRAME; player[pn].enti.x-=(player[pn].enti.speed); ANIMATESPRIFUN(pip, player, pn, 0); + if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; } } else { + 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); #ifdef SPRITE modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATAPTR); #else modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 10); #endif + if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.d = 2; } player[pn].enti.triggerx = player[pn].enti.tx-1; player[pn].enti.triggery = player[pn].enti.ty; break; + //down movement case 4: 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 && @@ -321,7 +314,9 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) ANIMATESPRIFUN(pip, player, pn, 1); ScrollDown(pip, player, 3, pn); ScrollDown(pip, player, 2, pn); + //mapScrollDown(pip, player, !(pip[0].video->p), pn); mapScrollDown(pip, player, (pip[0].video->p), pn); + if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; } @@ -333,21 +328,25 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) INC_PER_FRAME; player[pn].enti.y+=(player[pn].enti.speed); ANIMATESPRIFUN(pip, player, pn, 0); + if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; } } else { + 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); #ifdef SPRITE modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATAPTR); #else modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 9); #endif + if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.d = 2; } player[pn].enti.triggerx = player[pn].enti.tx; player[pn].enti.triggery = player[pn].enti.ty+1; break; + //up movement case 0: 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 && @@ -359,7 +358,9 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) ANIMATESPRIFUN(pip, player, pn, 1); ScrollUp(pip, player, 3, pn); ScrollUp(pip, player, 2, pn); + //mapScrollUp(pip, player, !(pip[0].video->p), pn); mapScrollUp(pip, player, (pip[0].video->p), pn); + if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; } @@ -371,16 +372,19 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) INC_PER_FRAME; player[pn].enti.y-=(player[pn].enti.speed); ANIMATESPRIFUN(pip, player, 0, pn); + if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; } } else { + 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); #ifdef SPRITE modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATAPTR); #else modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 12); #endif + if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.d = 2; } player[pn].enti.triggerx = player[pn].enti.tx; @@ -1103,10 +1107,10 @@ void shinku(global_game_variables_t *gv) #define FRAME3 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 0, dire, 24, 32, PLAYERBMPDATAPTR); #define FRAME4 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, dire, 24, 32, PLAYERBMPDATAPTR); #else -#define FRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 2+dire); -#define FRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 1+dire); -#define FRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, dire); -#define FRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 1+dire); +#define FRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 2+dire); +#define FRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+dire); +#define FRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, dire); +#define FRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+dire); #endif void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch) @@ -1197,114 +1201,17 @@ void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scroll pip->video->r=1; } -/* -void animate_spri(struct sprite *spri, global_game_variables_t *gv) -{ -#define GVARVIDEO gv->video -#define VMEMPAGESIZE2 GVARVIDEO.page[0].pagesize+GVARVIDEO.page[1].pagesize -#define VMEMPAGEDATA2 GVARVIDEO.page[2].data - unsigned int i,o,o2; int j; - int x,y,rx,ry,w,h; - int overdraw = 1; // how many pixels to "overdraw" so that moving sprites with edge pixels don't leave streaks. - // if the sprite's edge pixels are clear anyway, you can set this to 0. - VGA_RAM_PTR omemptr; - - // Events go here - - omemptr = vga_state.vga_graphics_ram; // save original mem ptr - x=spri->x-4; - y=spri->y; - - // Draw sprite - j = get_vrl_by_id(spri->spritesheet, spri->curr_spri_id, spri->sprite_vrl_cont); - if(j < 0) - { - Quit (gv, "Error retriving required sprite"); - } - - // render box bounds. y does not need modification, but x and width must be multiple of 4 - if (x >= overdraw) rx = (x - overdraw) & (~3); - else rx = -(GVARVIDEO.page[0].dx); - if (y >= overdraw) ry = (y - overdraw); - else ry = -(GVARVIDEO.page[0].dy); - h = spri->sprite_vrl_cont->vrl_header->height + overdraw + y - ry; - w = (x + spri->sprite_vrl_cont->vrl_header->width + (overdraw*2) + 3 - rx) & (~3);//round up - if ((rx+w) > GVARVIDEO.page[0].width) w = GVARVIDEO.page[0].width-rx; - if ((ry+h) > GVARVIDEO.page[0].height) h = GVARVIDEO.page[0].height-ry; - - // block copy pattern to where we will draw the sprite - vga_setup_wm1_block_copy(); - o2 = VMEMPAGESIZE2; - o = (0x10000UL - (uint16_t)VMEMPAGEDATA2) + (ry * GVARVIDEO.page[0].stridew) + (rx >> 2); // source offscreen - for (i=0;i < h;i++,o += GVARVIDEO.page[0].stridew,o2 += (w >> 2)) vga_wm1_mem_block_copy(o2,o,w >> 2); - - // must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally - vga_restore_rm0wm0(); - - // replace VGA stride with our own and mem ptr. then sprite rendering at this stage is just (0,0) - vga_state.vga_draw_stride_limit = (GVARVIDEO.page[0].width + 3 - x) >> 2;//round up - vga_state.vga_draw_stride = w >> 2; - vga_state.vga_graphics_ram = omemptr + VMEMPAGESIZE2; - - // then the sprite. note modding ram ptr means we just draw to (x&3,0) - draw_vrl1_vgax_modex( - x-rx, - y-ry, - spri->sprite_vrl_cont->vrl_header, - spri->sprite_vrl_cont->line_offsets, - spri->sprite_vrl_cont->buffer + sizeof(struct vrl1_vgax_header), - spri->sprite_vrl_cont->data_size - ); - - // restore ptr - vga_state.vga_graphics_ram = omemptr; - - // block copy to visible RAM from offscreen - vga_setup_wm1_block_copy(); - o = VMEMPAGESIZE2; // source offscreen - o2 = (ry * GVARVIDEO.page[0].stridew) + (rx >> 2); // dest visible (original stride) - for (i=0;i < h;i++,o += vga_state.vga_draw_stride,o2 += GVARVIDEO.page[0].stridew) vga_wm1_mem_block_copy(o2,o,w >> 2); - // must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally - vga_restore_rm0wm0(); - - // restore stride - vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = GVARVIDEO.page[0].stridew; - - // Depending on delay, update indices - switch(spri->delay){ - // Delay = 0 means that sprite should loop. Nothing to change here - case 0: - break; - - // Delay = 1 means that on next time unit sprite should be changed - case 1: - spri->curr_anim_spri++; - - // If we hit the end of an animation sequence, restart it - if(!(spri->curr_spri_id = spri->curr_anim_list[spri->curr_anim_spri].sprite_id)){ - spri->curr_anim_spri = 0; - spri->curr_spri_id = spri->curr_anim_list[spri->curr_anim_spri].sprite_id; - } - spri->delay = spri->curr_anim_list[spri->curr_anim_spri].delay; - - // Delay > 1 means that we should not change sprite yet. Decrease delay - default: - spri->delay--; - break; - } -} -*/ -//void animate_spri(struct sprite *spri, global_game_variables_t *gv) void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch) { sword x = player[pn].enti.x; sword y = player[pn].enti.y; word dire=10; //direction - sword i; sword qq; //scroll offset word ls = player[pn].enti.persist_aniframe; - +#ifdef SPRITE + int i=0; +#endif switch(scrollswitch) { case 0: @@ -1314,30 +1221,32 @@ void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scr qq = ((player[pn].enti.q)*(player[pn].enti.speed)); break; } - //x-=4; +#ifdef SPRITE + x-=4; +#endif y-=pip[0].map->tiles->tileHeight; switch (player[pn].enti.d) { case 0: //up - dire*=(player[pn].enti.d+1);// dire++; + dire*=player[pn].enti.d+1; y-=qq; break; case 3: // right - dire*=(player[pn].enti.d-1);// dire++; + dire*=(player[pn].enti.d-1); x+=qq; break; case 2: break; case 4: //down - dire*=(player[pn].enti.d-1);// dire++; + dire*=(player[pn].enti.d-1); y+=qq; break; case 1: //left - dire*=(player[pn].enti.d+3);// dire++; + dire*=(player[pn].enti.d+3); x-=qq; break; } @@ -1350,11 +1259,19 @@ void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scr //#define FRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 1+dire); //#define FRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, dire); //#define FRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 1+dire); +#ifdef SPRITE +//#define DRAWFRAME if (i == -1) return; oldanimate_spri(player[pn].ent->spri, pip->video) #define DRAWFRAME if (i == -1) return; animate_spri(player[pn].ent->spri, pip->video) #define NFRAME1 i = set_anim_by_id(player[pn].ent->spri, 2+dire); DRAWFRAME; #define NFRAME2 i = set_anim_by_id(player[pn].ent->spri, 1+dire); DRAWFRAME; #define NFRAME3 i = set_anim_by_id(player[pn].ent->spri, dire); DRAWFRAME; #define NFRAME4 i = set_anim_by_id(player[pn].ent->spri, 2+dire); DRAWFRAME; +#else +#define NFRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 2+dire); +#define NFRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+dire); +#define NFRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, dire); +#define NFRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+dire); +#endif switch(ls) { @@ -1362,7 +1279,7 @@ void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scr NFRAME1 break; case 2: - NFRAME2; + NFRAME2 break; case 3: NFRAME3 diff --git a/src/lib/scroll16.h b/src/lib/scroll16.h index f514f416..b9bfed95 100755 --- a/src/lib/scroll16.h +++ b/src/lib/scroll16.h @@ -108,7 +108,7 @@ typedef struct { printf(" tx: %d", player[0].enti.tx); printf(" ty: %d\n", player[0].enti.ty);\ printf(" triggx: %d", player[0].enti.triggerx); printf(" triggy: %d\n", player[0].enti.triggery);\ printf(" hp: %d", (player[0].enti.hp)); printf(" q: %d", player[0].enti.q); printf(" player.info.dir: %d", player[0].info.dir); printf(" player.d: %d ", player[0].enti.d);\ - printf(" pdir=%d\n", player[0].pdir);\ + printf(" pdir=%d\n", player[0].pdir); printf(" aniframe=%u", player[0].enti.persist_aniframe);\ printf(" tile data value at player trigger position: %d\n\n", mv[0].map->data[(player[0].enti.triggerx-1)+(map.width*(player[0].enti.triggery-1))]);\ \ printf("Virtual Screen: %dx", gvar.video.page[0].width); printf("%d ", gvar.video.page[0].height);\ @@ -137,8 +137,8 @@ extern char global_temp_status_text[512]; //map_t allocMap(int w, int h); //void initMap(map_t *map); -void walk(map_view_t *pip, player_t *player, word pn); void ZC_walk(map_view_t *pip, player_t *player, word pn); +void oldwalk(map_view_t *pip, player_t *player, word pn); void ZC_panPageManual(map_view_t *pip, player_t *player, word pn); void ZC_MVSetup(map_view_t *pip, map_t *map, global_game_variables_t *gv); void ZC_MVInit(map_view_t *pip, int tx, int ty); diff --git a/src/zcroll.c b/src/zcroll.c index 4dd13598..99ded28a 100755 --- a/src/zcroll.c +++ b/src/zcroll.c @@ -108,11 +108,12 @@ void main(int argc, char *argv[]) playerXYpos(0, 0, &player, &mv, 0); IN_initplayer(&player, 0); - player[0].ent->spri->x = player[0].enti.x; - player[0].ent->spri->y = player[0].enti.y; + player[0].ent->spri->x = player[0].enti.x-4; + player[0].ent->spri->y = player[0].enti.y-16; + player[0].ent->spri->delay = 0; i = set_anim_by_id(player[0].ent->spri, 31); - print_anim_ids(player[0].ent->spri); + //print_anim_ids(player[0].ent->spri); if (i == -1) { #ifdef FADE @@ -193,7 +194,7 @@ void main(int argc, char *argv[]) player[0].ent->spri->x = TILEWH; default: i++; - player[0].ent->spri->delay = 1; animate_spri((player[0].ent->spri), &gvar.video);// player[0].ent->spri->x += 16; + player[0].ent->spri->delay = 0; animate_spri((player[0].ent->spri), &gvar.video);// player[0].ent->spri->x += 16; break; } }