From: sparky4 Date: Tue, 24 Jan 2017 20:56:33 +0000 (-0600) Subject: animation fixed and sprite rendering is more flexible with overdraww and overdrawh X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=faab239b16b39312b26f6c4c1af85f1258aa4445;p=16.git animation fixed and sprite rendering is more flexible with overdraww and overdrawh --- diff --git a/src/inputest.c b/src/inputest.c index 07b39306..30cb8598 100755 --- a/src/inputest.c +++ b/src/inputest.c @@ -43,7 +43,6 @@ main(int argc, char *argv[]) player[0].enti.q=1; player[0].enti.d=2; - player[0].enti.persist_aniframe=0; player[0].enti.speed=4; //0000 nibbletest(); @@ -53,14 +52,12 @@ main(int argc, char *argv[]) { //0000 shinkutxt(&gvar); IN_ReadControl(0, &player); - #define INC_PER_FRAME if(player[0].enti.q&1) player[0].enti.persist_aniframe++; if(player[0].enti.persist_aniframe>4) player[0].enti.persist_aniframe = 1; switch(player[0].enti.d) { //right movement case 3: if(player[0].enti.q<=(TILEWH/(player[0].enti.speed))) { - INC_PER_FRAME; player[0].enti.q++; } else { player[0].enti.q = 1; player[0].enti.d = 2; } break; @@ -69,7 +66,6 @@ main(int argc, char *argv[]) case 1: if(player[0].enti.q<=(TILEWH/(player[0].enti.speed))) { - INC_PER_FRAME; player[0].enti.q++; } else { player[0].enti.q = 1; player[0].enti.d = 2; } break; @@ -78,7 +74,6 @@ main(int argc, char *argv[]) case 4: if(player[0].enti.q<=(TILEWH/(player[0].enti.speed))) { - INC_PER_FRAME; player[0].enti.q++; } else { player[0].enti.q = 1; player[0].enti.d = 2; } break; @@ -87,7 +82,6 @@ main(int argc, char *argv[]) case 0: if(player[0].enti.q<=(TILEWH/(player[0].enti.speed))) { - INC_PER_FRAME; player[0].enti.q++; } else { player[0].enti.q = 1; player[0].enti.d = 2; } break; diff --git a/src/lib/16_enti.c b/src/lib/16_enti.c index 96be5fde..a6b42b67 100755 --- a/src/lib/16_enti.c +++ b/src/lib/16_enti.c @@ -33,9 +33,8 @@ void EN_initentity(entity_t *enti) enti->d =2; enti->hp=4; enti->speed=4; - enti->persist_aniframe= enti->q; + enti->persist_aniframe = enti->q; enti->spt=(TILEWH/(enti->speed)); //speed per tile wwww - //enti->spri->delay=1; enti->invq=1; enti->pred = enti->d; } diff --git a/src/lib/16_sprit.c b/src/lib/16_sprit.c index 0be43073..f797f23b 100755 --- a/src/lib/16_sprit.c +++ b/src/lib/16_sprit.c @@ -103,7 +103,7 @@ void animate_spri(entity_t *enti, 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 = 0;//16; // how many pixels to "overdraw" so that moving sprites with edge pixels don't leave streaks. + int overdraww = 0, overdrawh = 4; // 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; @@ -159,12 +159,12 @@ void animate_spri(entity_t *enti, video_t *video) // render box bounds. y does not need modification, but x and width must be multiple of 4 if(!GVARVIDEO->rss){ - if (x >= overdraw) rx = (x - overdraw) & (~3); + if (x >= overdraww) rx = (x - overdraww) & (~3); else rx = -(GVARVIDEO->page[0].dx); - if (y >= overdraw) ry = (y - overdraw); + if (y >= overdrawh) ry = (y - overdrawh); else ry = -(GVARVIDEO->page[0].dy); - h = enti->spri->sprite_vrl_cont->vrl_header->height + overdraw + y - ry; - w = (x + enti->spri->sprite_vrl_cont->vrl_header->width + (overdraw*2) + 3 - rx) & (~3);//round up + h = enti->spri->sprite_vrl_cont->vrl_header->height + overdrawh + y - ry; + w = (x + enti->spri->sprite_vrl_cont->vrl_header->width + (overdraww*2) + 3 - rx) & (~3) - overdraww;//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; diff --git a/src/lib/16_tdef.h b/src/lib/16_tdef.h index 77ef4549..d45433ac 100755 --- a/src/lib/16_tdef.h +++ b/src/lib/16_tdef.h @@ -146,7 +146,7 @@ typedef struct word spt; //speed per tile struct sprite *spri; // sprite used by entity sword hp; //hitpoints of the entity - int persist_aniframe; /* gonna be increased to 1 before being used, so 0 is ok for default */ + int persist_aniframe; // gonna be increased to 1 before being used, so 0 is ok for default } entity_t; //TODO: MAKE THIS WWWW diff --git a/src/lib/scroll16.c b/src/lib/scroll16.c index 2d9de4f9..8d02cacd 100755 --- a/src/lib/scroll16.c +++ b/src/lib/scroll16.c @@ -24,16 +24,7 @@ */ #include "src/lib/scroll16.h" -#define INC_PER_FRAME_PRINT sprintf(global_temp_status_text, "%u", player[pn].enti.persist_aniframe);\ -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); - -//#define WALKTYPE_FRAM_PRINT INC_PER_FRAME_PRINT -//walktypeinfo(player, pn); -//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); - -#define PERSIST_ANIFRAME_INIT 1 -#define Q_INIT PERSIST_ANIFRAME_INIT -#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; +#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) { @@ -58,7 +49,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) mapScrollRight(pip, player, (pip[0].video->p), pn); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; - } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx++; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; } } 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)) { @@ -69,7 +60,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) player[pn].enti.x+=(player[pn].enti.speed); ANIMATESPRIFUN(pip, player, pn, 1); player[pn].enti.q++; - } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx++; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; } } else { @@ -95,7 +86,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) mapScrollLeft(pip, player, (pip[0].video->p), pn); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; - } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx--; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; } } 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)) { @@ -106,7 +97,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) player[pn].enti.x-=(player[pn].enti.speed); ANIMATESPRIFUN(pip, player, pn, 1); player[pn].enti.q++; - } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx--; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; } } else { @@ -132,7 +123,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) mapScrollDown(pip, player, (pip[0].video->p), pn); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; - } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty++; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; } } 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)) { @@ -143,7 +134,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) player[pn].enti.y+=(player[pn].enti.speed); ANIMATESPRIFUN(pip, player, pn, 1); player[pn].enti.q++; - } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty++; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; } } else { @@ -169,7 +160,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) mapScrollUp(pip, player, (pip[0].video->p), pn); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; - } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty--; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; } } 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)) { @@ -180,7 +171,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) player[pn].enti.y-=(player[pn].enti.speed); ANIMATESPRIFUN(pip, player, pn, 1); player[pn].enti.q++; - } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty--; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; } } else { @@ -230,7 +221,7 @@ void oldwalk(map_view_t *pip, player_t *player, word 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 = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx++; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; } } 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)) { @@ -241,7 +232,7 @@ void oldwalk(map_view_t *pip, player_t *player, word pn) ANIMATESPRIFUN(pip, player, pn, 0); if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; - } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx++; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; } } else { @@ -274,7 +265,7 @@ void oldwalk(map_view_t *pip, player_t *player, word 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 = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx--; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; } } 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)) { @@ -285,7 +276,7 @@ void oldwalk(map_view_t *pip, player_t *player, word pn) ANIMATESPRIFUN(pip, player, pn, 0); if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; - } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.tx--; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; } } else { @@ -318,7 +309,7 @@ void oldwalk(map_view_t *pip, player_t *player, word 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 = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty++; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; } } 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)) { @@ -329,7 +320,7 @@ void oldwalk(map_view_t *pip, player_t *player, word pn) ANIMATESPRIFUN(pip, player, pn, 0); if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; - } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty++; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; } } else { @@ -362,7 +353,7 @@ void oldwalk(map_view_t *pip, player_t *player, word 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 = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty--; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; } } 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)) { @@ -373,7 +364,7 @@ void oldwalk(map_view_t *pip, player_t *player, word pn) ANIMATESPRIFUN(pip, player, pn, 0); if(!pageflipflop) modexShowPage(pip[1].page); player[pn].enti.q++; - } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; player[pn].enti.ty--; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; } } else { @@ -407,7 +398,7 @@ void ZC_panPageManual(map_view_t *pip, player_t *player, word pn) pip[0].page->dx+=4; SHOWMVFUN_; player[pn].enti.q++; - } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; pip[0].tx++; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].tx++; } } break; @@ -420,7 +411,7 @@ void ZC_panPageManual(map_view_t *pip, player_t *player, word pn) pip[0].page->dx-=4; SHOWMVFUN_; player[pn].enti.q++; - } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; pip[0].tx--; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].tx--; } } break; @@ -433,7 +424,7 @@ void ZC_panPageManual(map_view_t *pip, player_t *player, word pn) pip[0].page->dy+=4; SHOWMVFUN_; player[pn].enti.q++; - } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; pip[0].ty++; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].ty++; } } break; @@ -446,7 +437,7 @@ void ZC_panPageManual(map_view_t *pip, player_t *player, word pn) pip[0].page->dy-=4; SHOWMVFUN_; player[pn].enti.q++; - } else { player[pn].enti.q = Q_INIT; player[pn].enti.d = 2; pip[0].ty--; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].ty--; } } break; } @@ -1129,14 +1120,14 @@ void near ZC_drawframe(map_view_t *pip, entity_t *enti, sword x, sword y) #define FRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 16, 32, 1+player[pn].enti.dire); #endif -void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch) +void /*near*/ animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch) { sword x = player[pn].enti.x; sword y = player[pn].enti.y; sword bx = x+16; //buffer's x sword by = y+16; //buffer's y sword qq; //scroll offset - word ls = player[pn].enti.persist_aniframe; + word ls = 0;//player[pn].enti.persist_aniframe; player[pn].enti.dire=32; //direction switch(scrollswitch) @@ -1281,7 +1272,6 @@ void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scr ZC_drawframe(pip, &player[pn].enti, x, y); //if(player[pn].enti.q<4) delay(500); pip->video->r=1; - //WALKTYPE_FRAM_PRINT; } /* @@ -1340,7 +1330,7 @@ void player_walk(player_t *player, map_view_t *map_v){ } } -void near mapScroll(map_view_t *mv, player_t *player) +void /*near*/ mapScroll(map_view_t *mv, player_t *player) { //word x, y; /* coordinate for drawing */ int c = 1; diff --git a/src/lib/scroll16.h b/src/lib/scroll16.h index a66cb897..75f8eda3 100755 --- a/src/lib/scroll16.h +++ b/src/lib/scroll16.h @@ -95,6 +95,7 @@ typedef struct { //printf("map.width=%d map.height=%d map.data[0]=%d\n", mv[0].map->width, mv[0].map->height, mv[0].map->data[0]); //printf("&global_temp_status_text = %Fp\n", &global_temp_status_text); //print_anim_ids(player[0].ent->spri); +//printf(" aniframe=%u", player[0].enti.persist_aniframe); #define SCROLLEXITMESG printf("tx: %d ", mv[0].tx);\ printf("ty: %d\n", mv[0].ty);\ printf("\n");\ @@ -104,7 +105,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", player[0].enti.triggery); printf(" value: %d\n", mv[0].map->data[(player[0].enti.triggerx-1)+(map.width*(player[0].enti.triggery-1))]);\ 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(" aniframe=%u", player[0].enti.persist_aniframe); printf(" delay=%u", player[0].enti.spri->delay);\ + printf(" pdir=%d\n", player[0].pdir); printf(" delay=%u", player[0].enti.spri->delay);\ printf("\n\n");\ printf("Virtual Screen: %dx", gvar.video.page[0].width); printf("%d ", gvar.video.page[0].height);\ printf("Screen: %dx", gvar.video.page[0].sw); printf("%d\n", gvar.video.page[0].sh);\ @@ -158,7 +159,7 @@ void mapDrawWCol(map_view_t *mv, int tx, int ty, word x); //void qclean(); void shinku(global_game_variables_t *gv); void near ZC_drawframe(map_view_t *pip, entity_t *enti, sword x, sword y); -void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch); +void /*near*/ animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch); void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch); // Move an entity around. Should actually be in 16_entity @@ -168,7 +169,7 @@ boolean ZC_walk2(entity_t *ent, map_view_t *map_v); void walk_player(player_t *player, map_view_t *map_v); // Scroll map in one direction (assumed from player's movement) -void near mapScroll(map_view_t *mv, player_t *player); +void /*near*/ mapScroll(map_view_t *mv, player_t *player); #endif /*__SCROLL16_H_*/ //older zc_animate diff --git a/src/zcroll.c b/src/zcroll.c index a02ae0da..1f5200da 100755 --- a/src/zcroll.c +++ b/src/zcroll.c @@ -135,7 +135,7 @@ void main(int argc, char *argv[]) /*strcpy(global_temp_status_text, "press enter for the loop of zcroll\nescape to quit"); modexprint(&gvar.video.page[0], 144, 72, 1, 7, 0, global_temp_status_text); while(!IN_KeyDown(sc_Enter)){ if(IN_KeyDown(sc_Escape)) goto quit; } IN_UserInput(1,1);*///wwww - while(!IN_KeyDown(sc_Escape))// && player[0].enti.hp>0) + while(!IN_KeyDown(sc_Escape) && player[0].enti.hp>0) { shinku(&gvar); //top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square @@ -210,7 +210,6 @@ void main(int argc, char *argv[]) if(IN_KeyDown(sc_R)){ modexPalOverscan(rand()%56); } //r if((player[0].enti.q==1) && !(player[0].enti.x%TILEWH==0 && player[0].enti.y%TILEWH==0)) break; //incase things go out of sync! - player[0].enti.hp = 0; } /* fade back to text mode */