First commit 09/04/1995
This commit is contained in:
147
SUPERVGA.CPP
Normal file
147
SUPERVGA.CPP
Normal file
@ -0,0 +1,147 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// MODO SVGA VESA DE 640 X 480 EN 256 COLORES //
|
||||
// //
|
||||
// Jos<6F> Antonio Acedo Mart<72>n-Grande (91)611 72 71 (Madrid) //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////// FICHEROS A INCLUIR /////////////////////////////
|
||||
|
||||
#include <dos.h>
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
//////////////////////////////// DEFINICIONES ////////////////////////////////
|
||||
|
||||
#define MODO_80x25_16c 0x003
|
||||
#define MODO_640x480_256c 0x101
|
||||
|
||||
////////////////////////////////// VARIABLES /////////////////////////////////
|
||||
|
||||
char *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 ///////////////////////////////////
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int esq_x1, esq_y1, esq_x2, esq_y2;
|
||||
|
||||
if(argc!=2) exit(1);
|
||||
|
||||
if(NULL==SET_VESA(MODO_640x480_256c))
|
||||
{
|
||||
asigna_modo_video(MODO_80x25_16c);
|
||||
printf("No se encontr<74> el driver VESA");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if((handle=fopen(argv[1], "rb"))==NULL)
|
||||
{
|
||||
asigna_modo_video(MODO_80x25_16c);
|
||||
printf("No se encontr<74> el archivo especificado");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(10!=getc(handle))
|
||||
{
|
||||
asigna_modo_video(MODO_80x25_16c);
|
||||
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)
|
||||
{
|
||||
asigna_modo_video(MODO_80x25_16c);
|
||||
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);
|
||||
|
||||
getch();
|
||||
|
||||
APAGA_PANTALLA(dac);
|
||||
|
||||
asigna_modo_video(MODO_80x25_16c);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
fclose(handle);
|
||||
}
|
||||
|
||||
void asigna_modo_video(char modo) // asigna el modo de v<>deo indicado
|
||||
{ // en la variable "modo"
|
||||
union REGS ent, sal;
|
||||
|
||||
ent.h.al = modo;
|
||||
ent.h.ah = 0;
|
||||
int86(16, &ent, &sal); // funci<63>n para asignar el modo de video
|
||||
}
|
Reference in New Issue
Block a user