CD_OUT_SRC/CD_PCX.CPP
2021-09-03 17:50:32 +02:00

152 lines
3.4 KiB
C++

///////////////////////////// FICHEROS A INCLUIR /////////////////////////////
//#include <time.h>
//#include <dos.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <conio.h> // Para getch();
#include <graphics.h> // Para outtextxy(...); y cleardevice(...);
#include "cd_error.h"
// #include "..\..\jd_lib\f_lib\make_bot.h" // Fuciones de MAKE_BOTON
////////////////////////////////// VARIABLES /////////////////////////////////
char far *dir_vga;
int ancho;
int alto;
char bits_pixel;
char dac[256*3];
extern char newdac[256*3];
//////////////////////// DECLARACIONES DE FUNCIONES //////////////////////////
void dibujo_640_x_480_256_c(FILE *handle);
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(int L_Imagen, char *N_Imagen2)
{
FILE *handle;
int esq_x1, esq_y1, esq_x2, esq_y2;
char string[80] = "cd_out0";
randomize();
if(L_Imagen==-1){
string[7] = (unsigned char)(random(9)+ '0');
string[8] = '.';
string[9] = 'P';
string[10] = 'C';
string[11] = 'X';
string[12] = '\0';
}
else if(L_Imagen==-2) strcpy( string, N_Imagen2 );
else
{
string[7] = (unsigned char)(L_Imagen + '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: Imagen Background");
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(handle);
// ENCIENDE_PANTALLA(dac);
}
void dibujo_640_x_480_256_c(FILE *handle)
{
unsigned char byte, contador;
int bank, n;
fseek(handle, 128, 0);
bank=0; (long)dir_vga=0xA0000000L;
CHANGE_BANK(bank);
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;
for(n=(256-16)*3; n<(256*3); n++) newdac[n]=getc(handle) >> 2;
fclose(handle);
}