Пример #1
0
void TerosCam::drawobjects ()
{
	clearview ();
    
	for (int i = 0; i < objects.size (); i++)
	{
		drawobject (*objects [i]);
	}
}
Пример #2
0
static void drawview(int nexts, int nextc) {
    clearview();
    if (nexts == 21 || nexts == 23)
        drawshape(nexts, nextc, VIEWX-1, VIEWY);
    else if (nexts >=24)
        drawshape(nexts, nextc, VIEWX+1, VIEWY);
    else
        drawshape(nexts, nextc, VIEWX, VIEWY);
    flush();
}
Пример #3
0
void TerosCam::setviewsize (int rows, int column)
{
    
	if (column > 0 && rows > 0)
	{
		m_viewcolumns = column;
		view.resize ((unsigned long) (column*rows));
		viewdepth.resize (view.size ());
	}
    clearview();
}
Пример #4
0
static void
initpage(void)
{
	int i;

	view_setup(nview);
	for (i = 0; i < nview-1; i++)
		draw(screen, view[i], screen, nil, view[i+1].min);
	clearview(view[nview-1]);
	offset = view[nview-1].min;
	vpos = 0;
}
Пример #5
0
TerosCam::TerosCam ()
{
	//setviewsize (SCRWIDTH, SCRHEIGHT);
    
	clearview ();
    
	m_camx = 0;
	m_camy = 0;
	m_camz = 0;
    m_zoomfactor = 10;
    m_position.set(m_camx, m_camy, m_camz, 1.0f);

	basisreset ();

}
Пример #6
0
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;
    }
Пример #7
0
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;
}
Пример #8
0
static void game(void) {
    char c;
    int counter = sspeed, rs, a, blocks = 0, paused = 0;

    gamescreen();
    clearboard();

    nexts = rnd()%28;
    nextc = rnd()%7 + 1;
    newshape();
    score = view = 0;
    if (view) drawview(nexts, nextc);
    level = 1;
    speed = sspeed;
    printscore();
    printlevel();

    for(;;) {
        if (paused) {
            gametick();
            c = tgetchar();
            switch(c) {
            case 'q':
                goto stopgame;
            case 'p':
                paused = 0;
                moveto(68,5); setbg(black);
                printf("           ");
                normal();
                flush();
            default:
                break;
            }
            continue;
        }

        if (counter <= 0) {
            counter = 14 - speed;
            if (shapefits(current.s, current.x, current.y+1)) {
                drawshape(current.s, 0, 40-WIDTH-8+current.x*2, current.y-3);
                current.y++;
                drawshape(current.s, current.color, 40-WIDTH-8+current.x*2,
                                                                current.y-3);
            } else {
                markboard(current.s, current.color, current.x, current.y);
                checkboard(current.y);
                incrscore(1);
                newshape();
                if (!shapefits(current.s, current.x, current.y)) goto stopgame;
                blocks++;
                if (blocks == blocksperlevel) {
                    blocks = 0;
                    incrlevel(1);
                }
                if (view) drawview(nexts, nextc);
            }
        }
        counter--;

        moveto(1,24);
        flush();
        gametick();
        c = tgetchar();
        switch(c) {
        case 'q':
            goto stopgame;
        case 'j':
            if (shapefits(current.s, current.x-1, current.y)) {
                drawshape(current.s, 0, 40-WIDTH-8+current.x*2, current.y-3);
                current.x--;
                drawshape(current.s, current.color, 40-WIDTH-8+current.x*2,
                                                              current.y-3);
            }
            break;
        case 'l':
            if (shapefits(current.s, current.x+1, current.y)) {
                drawshape(current.s, 0, 40-WIDTH-8+current.x*2, current.y-3);
                current.x++;
                drawshape(current.s, current.color, 40-WIDTH-8+current.x*2,
                                                              current.y-3);
            }
            break;
        case 'k':
            rs = (current.s & ~0x03) | ((current.s + 1) & 0x03);
            if (shapefits(rs, current.x, current.y)) {
                drawshape(current.s, 0, 40-WIDTH-8+current.x*2, current.y-3);
                current.s = rs;
                drawshape(current.s, current.color, 40-WIDTH-8+current.x*2,
                                                              current.y-3);
            }
            break;
        case ' ':
            for (a=1; ; a++) {
                if (!shapefits(current.s, current.x, current.y+a))
                    break;
            }
            if (shapefits(current.s, current.x, current.y+a-1)) {
                drawshape(current.s, 0, 40-WIDTH-8+current.x*2, current.y-3);
                current.y += a-1;
                drawshape(current.s, current.color, 40-WIDTH-8+current.x*2,
                                                              current.y-3);
            }
            incrscore(view ? (a-1) * 3 / 4 : a-1);
            break;
        case 'n':
            view ^= 1;
            if (view) drawview(nexts, nextc);
            else clearview();
            break;
        case 'p':
            paused = 1;
            moveto(68,5); setfg(white); setbg(blue);
            printf(" PAUSED!!! ");
            moveto(1,24);
            flush();
        default:
            break;
        }
    }

stopgame:
    setbg(white);
    rect(20,8,60,12);
    setbg(red);
    frect(21,9,59,11);
    setfg(white);
    bold();
    moveto(30,10);
    printf(" G A M E    O V E R ");
    moveto(1,24);
    flush();

    for(;;) {
        c = tgetchar();
        if (c > 0) return;
    }
}