예제 #1
0
void main( void ) {

    int i, j, n;
    unsigned char v;
    
    // fixed 8.8:
    int x, y;
    
    int tecla;
    long pausa = 100;

    static unsigned char paleta [] = {
        
        // gggrrrbb
        
        0x04,
        0x08,
        0x0C,
        0x10,
        0x14,
        0x18,
        0x1C,
        0xBC,
        0xFC,
        0xF0,
        0xE0,
        0xE3,
        0xA3,
        0x23,
        0x0F,
        0x92,
    };
    
    unsigned char flagCambiarPantalla = 1;

    radasCls( 0 );

    radasPonerModoRadastan();

    radasPonerPaleta( paleta );




    sprites[ 0 ].x = 45;
    sprites[ 0 ].y = 3;
    sprites[ 0 ].tamx = 5;
    sprites[ 0 ].tamy = 5;
    sprites[ 0 ].velx = 1;
    sprites[ 0 ].vely = 0;
    sprites[ 0 ].color = 0x88;

    sprites[ 1 ].x = 35;
    sprites[ 1 ].y = 10;
    sprites[ 1 ].tamx = 10;
    sprites[ 1 ].tamy = 10;
    sprites[ 1 ].velx = 1;
    sprites[ 1 ].vely = 0;
    sprites[ 1 ].color = 0x44;

    sprites[ 2 ].x = 20;
    sprites[ 2 ].y = 20;
    sprites[ 2 ].tamx = 6;
    sprites[ 2 ].tamy = 6;
    sprites[ 2 ].velx = -1;
    sprites[ 2 ].vely = 0;
    sprites[ 2 ].color = 0x66;
    
    sprites[ 3 ].x = 16;
    sprites[ 3 ].y = 30;
    sprites[ 3 ].tamx = 8;
    sprites[ 3 ].tamy = 4;
    sprites[ 3 ].velx = 1;
    sprites[ 3 ].vely = 0;
    sprites[ 3 ].color = 0x99;
    
    sprites[ 4 ].x = 26;
    sprites[ 4 ].y = 40;
    sprites[ 4 ].tamx = 4;
    sprites[ 4 ].tamy = 5;
    sprites[ 4 ].velx = -1;
    sprites[ 4 ].vely = 0;
    sprites[ 4 ].color = 0xBB;

    
    for ( i = 0; i < NUM_SPRITES; i++ ) {
        Sprite *s = &sprites[ i ];
        s->xant = s->x;
        s->yant = s->y;
        s->xant2 = s->x;
        s->yant2 = s->y;
    }
    
    
    
    
    //pintarDegradado();

    srand( 1234 );
    n = 0;
/*
    for ( n = 0; n < 16; n++ ) {

        x = rand() & 0x7FFF;
        y = rand() & 0x3FFF;
        
        
        pintarPixel( x >> 8, y >> 8, n );
        
    }    
*/

    //    radasRectangulo( 3, 7, 10, 20, 0x48 );


    // Bucle principal
    
    x = 4;
//    y = 12;
    v = 0xFE;
    tecla = getk();
    tecla = 0;
    while ( tecla != ' ' ) {

        ula_sync();
        

        for ( i = 0; i < NUM_SPRITES; i++ ) {
            Sprite *s = &sprites[ i ];
            radasRectangulo( s->xant2, s->yant2, s->tamx, s->tamy, 0 );
        }

        for ( i = 0; i < NUM_SPRITES; i++ ) {
            Sprite *s = &sprites[ i ];

            int nx = s->x + s->velx;
            if ( ( nx + s->tamx >= PANTALLA_X2 ) || ( nx < 0 ) ) {
                s->velx = - s->velx;
            }
            else {
                s->x = nx;
            }
            
            s->xant2 = s->xant;
            s->yant2 = s->yant;
            s->xant = s->x;
            s->yant = s->y;

            radasRectangulo( s->x, s->y, s->tamx, s->tamy, s->color );
            
        }
        
        if ( flagCambiarPantalla ) {
            radasCambiarPantalla();
        }


/*
        x = rand() & 0x003B;
        y = rand() & 0x003B;
        v = rand() & 0x00FF;
//        v = v | ( v << 4 );
        radasRectangulo( x, y, 3, 4, v );
*/
/*        
        x = rand() & 0x007F;
        y = rand() & 0x003F;
        pintarPixel( x, y, n++ );

        rotarPaletaAdelante( paleta );
        radasPonerPaleta( paleta );
*/

        tecla = getk();
        
        if ( tecla ) {
            switch ( tecla ) {
                case 'x':
                    flagCambiarPantalla = 0;
                    break;
                case 'c':
                    flagCambiarPantalla = 1;
                    break;
                default:
                    break;
            }
        }
    }

    // Fin del programa
    radasCls( 0 );
    radasPonerModoNormal();
    radasCls( 0 );

}
예제 #2
0
파일: cmandel.c 프로젝트: z88dk/z88dk
void main()
{
    float a, b, c, d, e, g, h, i, j;
    int x, y;
    int xmax, ymax;
    int k;
    float l, m, n, o, p;

    cclg(1); // Blue background

#ifdef ALTLOWGFX
    xmax = 64;
    ymax = 24;
#else
    xmax = 32;
    ymax = 48;
#endif
    a = -2.0;
    b = 2.0;
    c = a;
    d = b;

    //a=-0.765; b=-0.7651;
    //c=-0.095; d=-0.0951;

    e = 4.0;

    g = (b - a) / (float)xmax;
    h = (d - c) / (float)ymax;

    for (y = ymax / 2; y >= 0; y--) {
        j = (float)y * h + c;
        for (x = xmax; x >= 0; x--) {
            i = (float)x * g + a;
            k = 0;
            l = 0.0;
            m = 0.0;
            n = 0.0;
            o = 0.0;
        l110:
            k++;
            if (k < 50) //Iterates
            {
                p = n - o + i;
                m = 2.0 * l * m + j;
                l = p;
                n = l * l;
                o = m * m;

                if ((n + o) < e)
                    goto l110;

                cplot(x, y, k & 7);
                cplot(x, ymax - y, k & 7);
            }
            ccopybuffer();
        }
        ccopybuffer();
    }

    if (ula_plus_mode()) {
        // color cycling - ulaplus mode
        for (k = 0; k < 240; k++) {
            ula_sync();
            for (x = 0; x < 8; x++) {
                ulaplus_set(x, x + k);
                ulaplus_set(x + 8, x + k);
            }
            for (y = 0; y < 1600; y++) {
            }
        }
    } else {
        // color cycling - standard mode
        for (k = 100; k >= 0; k--) {
            for (y = ymax; y >= 0; y--) {
                for (x = xmax; x >= 0; x--)
                    cplot(x, y, cpoint(x, y) + 1);
            }
            ccopybuffer();
        }
    }

    ccopybuffer();
}