char * LoadAnm ( short anim_num ) { long handle; char *animbuf, *palptr; long i, j, k; DSPRINTF ( ds, "LoadAnm" ); MONO_PRINT ( ds ); // this seperate allows the anim to be precached easily ANIMnum = anim_num; // lock it walock[ANIM_TILE ( ANIMnum )] = 219; if ( anm_ptr[anim_num] == 0 ) { handle = kopen4load ( ANIMname[ANIMnum], 0 ); if ( handle == -1 ) { return ( NULL ); } length = kfilelength ( handle ); allocache ( ( intptr_t * ) &anm_ptr[anim_num], length + sizeof ( anim_t ), &walock[ANIM_TILE ( ANIMnum )] ); animbuf = ( char * ) ( FP_OFF ( anm_ptr[anim_num] ) + sizeof ( anim_t ) ); kread ( handle, animbuf, length ); kclose ( handle ); } else { animbuf = ( char * ) ( FP_OFF ( anm_ptr[anim_num] ) + sizeof ( anim_t ) ); } return ( animbuf ); }
void playanm(short anim_num) { unsigned char *animbuf, *palptr; int i, j, k, length = 0, numframes = 0; int32 handle = -1; unsigned char ANIMvesapal[4*256]; unsigned char tempbuf[256]; unsigned char *palook_bak = palookup[0]; UserInput uinfo = { FALSE, FALSE, dir_None }; ANIMnum = anim_num; KB_FlushKeyboardQueue(); KB_ClearKeysDown(); DSPRINTF(ds,"PlayAnm"); MONO_PRINT(ds); DSPRINTF(ds,"PlayAnm"); MONO_PRINT(ds); animbuf = LoadAnm(anim_num); if (!animbuf) return; DSPRINTF(ds,"PlayAnm - Palette Stuff"); MONO_PRINT(ds); for (i = 0; i < 256; i++) tempbuf[i] = i; palookup[0] = tempbuf; ANIM_LoadAnim(animbuf); ANIMnumframes = ANIM_NumFrames(); numframes = ANIMnumframes; palptr = ANIM_GetPalette(); for (i = 0; i < 768; i++) ANIMvesapal[i] = palptr[i]>>2; tilesizx[ANIM_TILE(ANIMnum)] = 200; tilesizy[ANIM_TILE(ANIMnum)] = 320; clearview(0); setbrightness(gs.Brightness,ANIMvesapal,2); if (ANIMnum == 1) { // draw the first frame waloff[ANIM_TILE(ANIMnum)] = (intptr_t)ANIM_DrawFrame(1); invalidatetile(ANIM_TILE(ANIMnum), 0, 1<<4); rotatesprite(0 << 16, 0 << 16, 65536L, 512, ANIM_TILE(ANIMnum), 0, 0, 2 + 4 + 8 + 16 + 64, 0, 0, xdim - 1, ydim - 1); } SoundState = 0; //ototalclock = totalclock + 120*2; ototalclock = totalclock; for (i = 1; i < numframes; i++) { while (totalclock < ototalclock) { handleevents(); CONTROL_GetUserInput(&uinfo); CONTROL_ClearUserInput(&uinfo); switch (ANIMnum) { case ANIM_INTRO: if (KB_KeyWaiting() || uinfo.button0 || uinfo.button1 || quitevent) goto ENDOFANIMLOOP; break; case ANIM_SERP: if (KEY_PRESSED(KEYSC_ESC) || uinfo.button1 || quitevent) goto ENDOFANIMLOOP; break; } getpackets(); } switch (ANIMnum) { case ANIM_INTRO: AnimShareIntro(i,numframes); break; case ANIM_SERP: AnimSerp(i,numframes); break; case ANIM_SUMO: AnimSumo(i,numframes); break; case ANIM_ZILLA: AnimZilla(i,numframes); break; } waloff[ANIM_TILE(ANIMnum)] = (intptr_t)ANIM_DrawFrame(i); invalidatetile(ANIM_TILE(ANIMnum), 0, 1<<4); rotatesprite(0 << 16, 0 << 16, 65536L, 512, ANIM_TILE(ANIMnum), 0, 0, 2 + 4 + 8 + 16 + 64, 0, 0, xdim - 1, ydim - 1); nextpage(); } // pause on final frame while (totalclock < ototalclock) { handleevents(); getpackets(); } ENDOFANIMLOOP: clearview(0); nextpage(); palookup[0] = palook_bak; setbrightness(gs.Brightness, (unsigned char*)palette_data, 2); KB_FlushKeyboardQueue(); KB_ClearKeysDown(); ANIM_FreeAnim(); walock[ANIM_TILE(ANIMnum)] = 1; }
void playanm ( short anim_num ) { char *animbuf, *palptr; long i, j, k, numframes = 0; int32 handle = -1; char ANIMvesapal[4 * 256]; char tempbuf[256]; char *palook_bak = palookup[0]; ANIMnum = anim_num; KB_FlushKeyboardQueue(); KB_ClearKeysDown(); DSPRINTF ( ds, "PlayAnm" ); MONO_PRINT ( ds ); DSPRINTF ( ds, "PlayAnm" ); MONO_PRINT ( ds ); animbuf = LoadAnm ( anim_num ); if ( !animbuf ) { return; } DSPRINTF ( ds, "PlayAnm - Palette Stuff" ); MONO_PRINT ( ds ); for ( i = 0; i < 256; i++ ) { tempbuf[i] = i; } palookup[0] = tempbuf; ANIM_LoadAnim ( ( uint8_t * ) animbuf, length ); ANIMnumframes = ANIM_NumFrames(); numframes = ANIMnumframes; palptr = ( char * ) ANIM_GetPalette(); for ( i = 0; i < 768; i++ ) { ANIMvesapal[i] = palptr[i] >> 2; } tilesiz[TILE_ANIM].x = 200; tilesiz[TILE_ANIM].y = 320; setbasepal ( 0, ( const uint8_t * ) ANIMvesapal ); setbrightness ( gs.Brightness, 0, 2 ); if ( ANIMnum == 1 ) { // draw the first frame waloff[TILE_ANIM] = FP_OFF ( ANIM_DrawFrame ( 1 ) ); invalidatetile ( TILE_ANIM, 0, 1 << 4 ); rotatesprite ( 0 << 16, 0 << 16, 65536L, 512, TILE_ANIM, 0, 0, 2 + 4 + 8 + 16 + 64, 0, 0, xdim - 1, ydim - 1 ); } SoundState = 0; //ototalclock = totalclock + 120*2; ototalclock = totalclock; for ( i = 1; i < numframes; i++ ) { while ( totalclock < ototalclock ) { switch ( ANIMnum ) { case 0: if ( KB_KeyWaiting() ) { goto ENDOFANIMLOOP; } break; case 1: if ( KEY_PRESSED ( KEYSC_ESC ) ) { goto ENDOFANIMLOOP; } break; } getpackets(); } switch ( ANIMnum ) { case ANIM_INTRO: AnimShareIntro ( i, numframes ); break; case ANIM_SERP: AnimSerp ( i, numframes ); break; case ANIM_SUMO: AnimSumo ( i, numframes ); break; case ANIM_ZILLA: AnimZilla ( i, numframes ); break; } waloff[TILE_ANIM] = FP_OFF ( ANIM_DrawFrame ( i ) ); invalidatetile ( TILE_ANIM, 0, 1 << 4 ); rotatesprite ( 0 << 16, 0 << 16, 65536L, 512, TILE_ANIM, 0, 0, 2 + 4 + 8 + 16 + 64, 0, 0, xdim - 1, ydim - 1 ); nextpage(); } // pause on final frame while ( totalclock < ototalclock ) { getpackets(); } ENDOFANIMLOOP: clearview ( 0 ); nextpage(); palookup[0] = palook_bak; // setbrightness(gs.Brightness, (char*)palette_data, 2); setbasepal ( 0, ( const uint8_t * ) palette_data ); setbrightness ( gs.Brightness, 0, 2 ); KB_FlushKeyboardQueue(); KB_ClearKeysDown(); ANIM_FreeAnim(); walock[ANIM_TILE ( ANIMnum )] = 1; }
int AutoBreakSprite(short BreakSprite, short type) { SPRITEp bp = &sprite[BreakSprite]; BREAK_INFOp break_info; extern void DoWallBreakMatch( short match ); int SpawnBreakFlames(SHORT SpriteNum); break_info = FindSpriteBreakInfo(bp->picnum); if(bp->hitag < 0) DoWallBreakMatch(bp->hitag); if (!break_info) { //DSPRINTF(ds,"Break Info not found - sprite %d", bp - sprite); MONO_PRINT(ds); return(FALSE); } // Check to see if it should break with current weapon type if(!CheckBreakToughness(break_info, type)) { if (break_info->breaknum != -1) { if (!TEST(break_info->flags, BF_LEAVE_BREAK)) { RESET(bp->extra, SPRX_BREAKABLE); RESET(bp->cstat, CSTAT_SPRITE_BREAKABLE); } bp->picnum = break_info->breaknum; // pass Break Info Globally GlobBreakInfo = break_info; SpawnShrap(BreakSprite, -1); GlobBreakInfo = NULL; if(bp->picnum == 3683) RESET(bp->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN); } return(FALSE); } RESET(bp->extra, SPRX_BREAKABLE); RESET(bp->cstat, CSTAT_SPRITE_BREAKABLE); // pass Break Info Globally GlobBreakInfo = break_info; SpawnShrap(BreakSprite, -1); GlobBreakInfo = NULL; // kill it or change the pic if (TEST(break_info->flags, BF_KILL) || break_info->breaknum == -1) { if (TEST(break_info->flags, BF_FIRE_FALL)) SpawnBreakFlames(BreakSprite); RESET(bp->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN); SET(bp->cstat, CSTAT_SPRITE_INVISIBLE); // Kill sound if one is attached DeleteNoSoundOwner(BreakSprite); KillBreakSprite(BreakSprite); //change_sprite_stat(BreakSprite, STAT_SUICIDE); //KillSprite(BreakSprite); return(TRUE); } else { bp->picnum = break_info->breaknum; if(bp->picnum == 3683) RESET(bp->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN); } return(FALSE); }
int AutoBreakWall(WALLp wallp, long hitx, long hity, long hitz, short ang, short type) { BREAK_INFOp break_info; short BreakSprite; WALLp nwp; SPRITEp bsp; //DSPRINTF(ds,"wallnum %d, pic %d, lo %d, hi %d",wallp-wall, wallp->picnum, wallp->lotag, wallp->hitag); MONO_PRINT(ds); wallp->lotag = 0; if (wallp->nextwall >= 0) { nwp = &wall[wallp->nextwall]; // get rid of both sides // only break ONE of the walls if (nwp->lotag == TAG_WALL_BREAK && nwp->overpicnum > 0 && TEST(nwp->cstat, CSTAT_WALL_MASKED)) { nwp->lotag = 0; } } if (wallp->overpicnum > 0 && TEST(wallp->cstat, CSTAT_WALL_MASKED)) break_info = FindWallBreakInfo(wallp->overpicnum); else break_info = FindWallBreakInfo(wallp->picnum); if (!break_info) { //DSPRINTF(ds,"Break Info not found - wall %d", wallp - wall); MONO_PRINT(ds); return(FALSE); } // Check to see if it should break with current weapon type if(!CheckBreakToughness(break_info, type)) return(FALSE); if (hitx != MAXLONG) { // need correct location for spawning shrap BreakSprite = COVERinsertsprite(0, STAT_DEFAULT); ASSERT(BreakSprite >= 0); bsp = &sprite[BreakSprite]; bsp->cstat = 0; bsp->extra = 0; bsp->ang = ang; bsp->picnum = ST1; bsp->xrepeat = bsp->yrepeat = 64; setsprite(BreakSprite, hitx, hity, hitz); // pass Break Info Globally GlobBreakInfo = break_info; SpawnShrap(BreakSprite, -1); GlobBreakInfo = NULL; KillSprite(BreakSprite); } // change the wall if (wallp->overpicnum > 0 && TEST(wallp->cstat, CSTAT_WALL_MASKED)) { if (break_info->breaknum == -1) { RESET(wallp->cstat, CSTAT_WALL_MASKED|CSTAT_WALL_1WAY|CSTAT_WALL_BLOCK_HITSCAN|CSTAT_WALL_BLOCK); wallp->overpicnum = 0; if (wallp->nextwall >= 0) { nwp = &wall[wallp->nextwall]; RESET(nwp->cstat, CSTAT_WALL_MASKED|CSTAT_WALL_1WAY|CSTAT_WALL_BLOCK_HITSCAN|CSTAT_WALL_BLOCK); nwp->overpicnum = 0; } } else { RESET(wallp->cstat, CSTAT_WALL_BLOCK_HITSCAN|CSTAT_WALL_BLOCK); wallp->overpicnum = break_info->breaknum; if (wallp->nextwall >= 0) { nwp = &wall[wallp->nextwall]; RESET(nwp->cstat, CSTAT_WALL_BLOCK_HITSCAN|CSTAT_WALL_BLOCK); nwp->overpicnum = break_info->breaknum; } } } else { if (break_info->breaknum == -1) wallp->picnum = 594; // temporary break pic else { wallp->picnum = break_info->breaknum; if( wallp->hitag < 0) DoWallBreakSpriteMatch( wallp->hitag ); } } return(TRUE); }