Real Color Image Display Technology in DOS True Color Mode (II)

Sixth, the demonstration program Above two kinds of programming realization sees the attachment routine, the procedure has in the ISA/VESA/PCI three bus slot OctekHippo12 mainboards, AMD DX4/100 CPU, 8M RAM, EMC1024×768, 28 interlaced scanning color The monitor, Cirrus GD5434 (2M VRAM) graphics card, and Borland C++ 3.1 Small mode compile. However, the execution program does not depend on the compiled hardware environment. It has been equipped with 1G VRAM TGE9440, TGUI9680, ARK2000PV, S3 86C868 VESA local bus, PCI local bus, even ISA bus TVGA8900D (also supports VESA 1.2 standard, 1M following The OEM model number is the same as TGUI9440). The 486 to 586 PCs of the graphics card are all passed under the DOS environment.
The sample program has generality for Super VGA card VESA BIOS high and true color extended mode programming. For other high and true color graphics cards not mentioned in this document, as long as they support the VESA standard (Version>1.1), they can be used without modification or slight modification; for higher resolution, only display the adapter card with 2M VRAM You can program 115H, 116H, and 117H modes. In the routine, you only need to modify the upper and lower bounds of n and m in the highcolor() and truecolor() functions and the upper bound of addr. But more importantly: Prior to running the program, a utility program that adjusts the DRAM pixel clock or adjusts the scanning frequency of the color display with a display adapter card adjusts the pixel clock and the scanning frequency to the values ​​required for the current resolution of the card, for example, , Cirrus GD5434 card (2M VRAM) in the 117H mode to successfully simulate 16.7M true color, must be performed under DOS CLMODE.EXE t640 = 60 t800 = 60t1024 = 60 t1280 = 0, the program will be able to successfully display high color images .
// 24-bit PCX high, true color image display routine
#include
#include
#include
#include
#include
#include
#include
#include
#include
Unsigned long dataoffset,Line-bytes;
Unsigned long addr;
Unsigned int Curpage,Wingran,Y-res,width,height;
FILE *fp;
Typedef struct { // PCX image file header format
Char manufacturer;
Char version;
Char encoding;
Char bits-perpixel;
Int xmin, ymin;
Int xmax, ymax;
Int hres;
Int vres;
Char palette;
Char reserved;
Char color-planes;
Int bytes-perline;
Int palettetype;
Char filler;
} PCXHEAD;
Struct mode infoblock {
Unsigned int modeattr;
Unsigned char winaattr;
Unsigned char winbattr;
Unsigned int wingran;
Unsigned int winsize;
Unsigned int winaseg;
Unsigned int winbseg;
Unsigned char *pagefunc;
Unsigned int bytesperscanline;
Unsigned int xres,yres;
Unsigned char charx,chary;
Unsigned char numberofplanes;
Unsigned char bitperpixel;
Unsigned char numberofbanks;
Unsigned char memorymodel;
Unsigned char banksize;
Unsigned char numberofimagepages;
Unsigned char Reserved;
Unsigned char x;
} modeinfo;
Void SetVesaMode(unsigned int mode);
Void VesaInfo(unsigned int mode);
Void map(void);
Void Selectpage(unsigned int page);
Void highcolor(void);
Void truecolor(void);
Main() // main function
{PCXHEAD header;
Char *filename,c;
Printf("Please enter the 640480 24bit RGB mode

PCX fil
Ename: ");
Gets(filename);
If((fp=fopen(filename, "rb"))==NULL)
{
SetVesaMode(003);
Puts("File reading error");
Exit(1);
}
Fread( (char *) &header, 1, sizeof(PCXHEAD), fp);
Width = header.bytes-perline;
Height = header.ymax - header.ymin + 1;
Printf("Image information: Width=%d, Height=%d", width,h
Eight);
If ((header.bits-perpixel==8)&&(header.color-planes==3)
) {
Printf("
Type : 24bits RGB true colors");
Printf("1...Emulating display 16M true color image with
64K high color");
Printf("2...Display of 16M true color image");
Printf("Press selec 1 or 2 : ");
If ((c=getch())==`1`) {
Highcolor();
SetVesaMode(003);
}
Else if (c==`2`) {
Truecolor();
SetVesaMode(003);
}
Else {
Printf("This is not high-color & true-color image !")
;
Exit(1);
}
}
Fclose(fp);
Return 0;
}
// Set VESA BIOS Extended Mode Functions
Void SetVesaMode(unsigned int mode)
{unio REGS r;
Unsigned int setmode=1;
Rxax=04f02;
Rxbx=mode;
Int86(010,&r,&r);
If (rxax!=04f)
Setmode=0;
Else VesaInfo(mode);
Curpage=0ffff;
Return(setmode);
}
// Return VESA programming information function
Void VesaInfo(unsigned int mode)
{unio REGS r;
Struct SREGS sr;
Rxcx=mode;
Rxax=04f01;
Sr.es =FP-SEG(&modeinfo);
Rxdi=FP-OFF(&modeinfo);
Int86x(010,&r,&r,&sr);
Wingran =modeinfo.wingran;
Line-bytes=modeinfo.bytesperscanline;
Y-res
=modeinfo.yres;
}
// Calculate scanline start address function
Void map(void)
{ register int i,j;
For(i=0; i Addr = (unsigned long) (i) * Line-bytes;
}
// Select video window alignment page function
Void Selectpage(unsigned int page)
{unio REGS r;
If (page!=Curpage) {
Rxbx=0;
Rxdx=page*64L/Wingran;
Rxax=04f05;
Int86(010,&r,&r);
Curpage=page;
}
}
// 16-bit high color emulation 24-bit PCX true color image display function
Void highcolor(void)
{ register int i, j;
Unsigned int red, green, blue;
Unsigned int *word, *wordptr;
Int n, m, k, cnt, total;
Unsigned long segmet;
Unsigned char *pic, *p0,*p1,*p2;
Unsigned char page, picdata;
SetVesaMode(0111);
Map();
Selectpage(0);
n=min(480,height);
m=min(640,width);
Word =(unsigned int *)malloc(2*m);
Wordptr=word;
For (k=0; k<3; k++)
Pic=(unsigned char *)malloc(m);
P0=pic; p1=pic; p2=pic;
Fseek(fp,080L,SEEK-SET);
For(i=0; i Pic=p0; pic=p1; pic=p2;
Word=wordptr;
For (j=0;j<3;j++) {
Total = 0;
While(total < m) {
Cnt = 1;
Picdata = fgetc(fp);
If(0c0==(0c0 & picdata)) {
Cnt = 03f & picdata;
Picdata = fgetc(fp);
For (k=0; k *pic++ =picdata;
}
Else
*pic++ =picdata;
Total+=cnt;
}
}
Pic=p0; pic=p1; pic=p2;
For (j=0; j Red = *pic++ >>3;
Green= *pic++ >>2;
Blue = *pic++ >>3;
Red=red<<11; green=green<<5;
*word++ =red|green|blue;
}
Word=word

Ptr;
For (j=0;j<2*(m-1);j+=2) {
Segmet=addr+j;
Page=segmet>>16;
If (segmet <= 65535L) {
Poke(0a000, addr+j, *word++ );
}
Else {
Selectpage(page);
Poke(0a000, addr+j, *word++ );
}
}
}
Getch();
Free(wordptr); free(pic);
Free(pic) ; free(pic);
}
// 24-bit PCX true color image holographic display function
Void truecolor(void)
{ register int i, j;
Unsigned char *pic, *p0,*p1,*p2;
Unsigned char page, picdata;
Int n,m,k,cnt,total;
Unsigned long segmet;
SetVesaMode(0112);
Map();
Selectpage(0);
n=min(480,height);
m=min(640,width);
For (k=0; k<3; k++)
Pic=(unsigned char *)malloc(m);
P0=pic; p1=pic; p2=pic;
Fseek(fp,080L,SEEK-SET);
For(i=0; i Pic=p0; pic=p1; pic=p2;
For (j=0;j<3;j++) {
Total = 0;
While(total < m) {
Cnt = 1;
Picdata = fgetc(fp);
If(0c0==(0c0 & picdata)) {
Cnt = 03f & picdata;
Picdata = fgetc(fp);
For (k=0; k *pic++ =picdata;
}
Else
*pic++ =picdata;
Total+=cnt;
}
}
Pic=p0; pic=p1; pic=p2;
For (j=0;j<3*(m-1);j+=3) {
Segmet=addr+j;
Page=segmet>>16;
If (segmet <= 65535L) {
For (k=0; k<3; k++)
Pokeb(0a000, addr+j+k, *pic++);
}
Else {
Selectpage(page);
For (k=0; k<3; k++)
Pokeb(0a000, addr+j+k, *pic++);
}
}
}
Getch();
For (k=0; k<3; k++) free(pic);
}


Source: Computer Papers

Cover With Lighter Gas Refill

Butane Refill,Cover For Gas Bottle,Yellow And Red Cover,Lid For Butane Gas Cartridge

Viva Lighter (Chenzhou) Co.,Ltd , http://www.vivalightercz.com

Posted on