///////////////////////////// FICHEROS A INCLUIR ///////////////////////////// #include #include #include #include #include // Para getch(); #include // Para outtextxy(...); y cleardevice(...); #include "cd_error.h" #include "..\..\jd_lib\make_bot.h" // Fuciones de MAKE_BOTON ////////////////////////////////// VARIABLES ///////////////////////////////// char far *dir_vga; int ancho; int alto; char bits_pixel; FILE *handle; char dibujo[15]; char dac[256*3]; //////////////////////// DECLARACIONES DE FUNCIONES ////////////////////////// void dibujo_640_x_480_256_c(void); void asigna_modo_video(char); extern "C" { int SET_VESA(int); void CHANGE_BANK(int); void ENCIENDE_PANTALLA(char *); void APAGA_PANTALLA(char *); } ///////////////////////////////// PROGRAMA /////////////////////////////////// void Inicializa_Dibujo(void) { int esq_x1, esq_y1, esq_x2, esq_y2; char string[80] = "cd_out0"; randomize(); string[7] = (unsigned char)(random(7)+ '0'); string[8] = '.'; string[9] = 'P'; string[10] = 'C'; string[11] = 'X'; string[12] = '\0'; if((handle=fopen(/*"CD_OUT1.IMG"*/string, "rb"))==NULL) { Imprime_Estaticos( E_O, "cd_out.img"); // Imprime botones estaticos 'Seccion 2' Espera_Tecla_o_Raton(); restorecrtmode(); printf("No se encontr¢ el archivo especificado"); exit(1); } if(10!=getc(handle)) { Imprime_Estaticos( E_PCX, "cd_out.img"); // Imprime botones estaticos 'Seccion 2' Espera_Tecla_o_Raton(); restorecrtmode(); printf("El archivo especificado no es un fichero PCX"); exit(1); } getw(handle); bits_pixel=getc(handle); esq_x1=getw(handle); esq_y1=getw(handle); esq_x2=getw(handle); esq_y2=getw(handle); ancho=esq_x2-esq_x1+1; alto =esq_y2-esq_y1+1; if(ancho!=640 || alto!=480 || bits_pixel!=8) { Imprime_Estaticos( E_PCX, "cd_out.img"); // Imprime botones estaticos 'Seccion 2' Espera_Tecla_o_Raton(); restorecrtmode(); printf("El fichero especificado no es un dibujo de 640 x 480 en 256 colores"); exit(1); } // APAGA_PANTALLA(dac); dibujo_640_x_480_256_c(); // ENCIENDE_PANTALLA(dac); } void dibujo_640_x_480_256_c(void) { unsigned char byte, contador; int bank, n; fseek(handle, 128, 0); bank=0; (long)dir_vga=0xA0000000L; for(alto=480; alto>0; alto--) { for(ancho=640; ancho>0; ) { byte=getc(handle); if(byte<=0xC0) { *dir_vga++=byte; ancho--; if((long)dir_vga==0xA0000000L) { bank++; CHANGE_BANK(bank); } } else { contador=byte&0x3F; byte=getc(handle); for(; contador>0; contador--) { *dir_vga++=byte; ancho--; if((long)dir_vga==0xA0000000L) { bank++; CHANGE_BANK(bank); } } } } } getc(handle); // for(n=0; n<256*3; n++) dac[n]=getc(handle) >> 2; for(n=0; n<(256-16)*3; n++) dac[n]=getc(handle) >> 2; fclose(handle); }