コード例 #1
0
ファイル: anim.c プロジェクト: JohnnyonFlame/gcw0-jfsw
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;
    }
コード例 #2
0
ファイル: anim.cpp プロジェクト: jmarshall23/PolymerNGPublic
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;
}