#include #include #include char *MPantalla; char Pantalla[320][200]; void DoPaleta(void); void CreaBase(void); void CalculaFuego(void); void main( void ) { int x, y; MPantalla = (char *)MK_FP(0xA000, 0); // create a pointer to video memory asm mov al, 0x13 asm mov ah, 0x00 asm int 0x10 // Hacer paleta DoPaleta(); randomize(); CreaBase(); /* for ( x = 30; x < 290; x++ ) for ( y = 190; y < 80; y++ ) MPantalla[320*y+x] = Pantalla[x][y]; */ do { CalculaFuego(); /* for ( x=30; x<290; x++) for ( y=190; y > 80; y -- ) MPantalla[320*y+x] = Pantalla[x][y]; */ } while ( !kbhit() ); textmode(LASTMODE); } void DoPaleta(void) { int i; for ( i=0; i<15; i++ ) { outport( 0x3c9, 0 ); outport( 0x3c9, 0 ); outport( 0x3c9, 0 ); } for ( i=0; i<7; i++ ) { outport( 0x3c9, i*4);//i*4 ); outport( 0x3c9, i*4);//i*4 ); outport( 0x3c9, 0 ); } for ( i=0; i<31; i++ ) { outport( 0x3c9, 63 ); outport( 0x3c9, 63-i*2 ); outport( 0x3c9, 0 ); } for ( i=0; i<63; i++ ) { outport( 0x3c9, 63 ); outport( 0x3c9, 0 ); outport( 0x3c9, 0 ); } outport( 0x3c8, 0 ); outport( 0x3c9, 0 ); outport( 0x3c9, 0 ); outport( 0x3c9, 0 ); } void CreaBase(void) { int i; for ( i=100; i < 220; i++ ) { if ( random(100) < 30 ) //Pantalla[i][190] = random(150); MPantalla[320*190 + i ] = random(150); } for ( i=100; i < 220; i++ ) { if ( random(100) < 30 ) //Pantalla[i][189] = random(150); MPantalla[320*189 + i ] = random(150); } } void CalculaFuego(void) { int Cur, x, y; for ( y = 120; y < 190; y++) for ( x = 75; x < 245; x++) { // Cur = (Pantalla[x][y+1] + Pantalla[x+1][y+1] + Pantalla[x-1][y+1] + Pantalla[x+1][y]) >>2 ; Cur = (MPantalla[x+320*(y+1)] + MPantalla[320*(y+1) + x+1] + MPantalla[320*(y+1)+x-1] + MPantalla[320*y +(x+1)]) >>2 ; if ( Cur > 1 ) Cur--; // Pantalla[x][y-1] = Cur; MPantalla[320*( y-1) + x] = Cur; } CreaBase(); }