anim.cgxjanim.c"NHhdB@LLLPTEXTCWIEgxj#include #include #include #include #include "anim.h" #include "sprite.h" #include "global.h" #include "addrs.h" #include "assert.h" typedef struct animentry { u_char x,y; // Position of animation u_char type; // 0 - TV, 1 - Wave // 2 - Eyes, 3 - 2nd TV // 4 - Reeds, 5 - Gunk // 6 - Light u_char frame; // Current frame of animation struct animentry *next; } anim; static anim *anims = NULL; // Pointer to head of animation list. extern u_char screen; void FindAnims(void) { u_char x,y,tile; u_char *mapptr = (u_char*)mapaddr+(screen*20*15); anim *temp; // Wipe any existing animations while (anims!=NULL) { temp = anims; anims = anims->next; free(temp); } for (y=0;y<15;y++) { for (x=0;x<20;x++) { tile = *(mapptr++); switch (tile) { case 113: case 114: case 116: case 120: case 122: case 143: case 146: // Add new animation to list temp = (anim*)malloc(sizeof(anim)); temp->x = x; temp->y = y; // Find start frame number do { temp->frame = rand() & 127; } while (temp->frame>=96); temp->next = anims; anims = temp; // Set type of animation if (tile==113) anims->type = 0; if (tile==114) anims->type = 3; if (tile==116) anims->type = 1; if (tile==120) anims->type = 2; if (tile==122) anims->type = 6; if (tile==143) anims->type = 4; if (tile==146) anims->type = 5; break; } } } } void Animate(GsOT* OT) { anim *animptr = anims; GsSPRITE animspr; u_char tile; u_short u,v; InitSpr(&animspr); animspr.w = animspr.h = 16; while (animptr!=NULL) { // Cycle animation frame round. if (++animptr->frame == 96) animptr->frame = 0; // Get tile corresponding to animation frame. tile = *((u_char*)animsaddr + 96*animptr->type + animptr->frame); // Find u & v values in VRAM for tile. v = 0; while (tile>=48) { tile-=48; v+=16; } u = 320*2 + tile*16; animspr.x = animptr->x*16; animspr.y = animptr->y*16; CalcSprPos(animspr, u, v); GsSortFastSprite(&animspr, OT, 14); animptr = animptr->next; } }ZZRNavigator 3.01 %anim.c.c.humentsx.harozentallerETEXTCWIEgcache27443.gifNetscape Navigator 3.01 %ˋϳC>H Monaco0%0%ZZRz<4&RMPSRMWBB*LR