From: ANTHONY APPLEYARD To: DJGPP AT SUN DOT SOE DOT CLARKSON DOT EDU Date: Wed, 14 Dec 1994 11:59:12 GMT Subject: New PC: driver or screen funny when in Gnu C On my PC, mode 0x64 is 480*640 pixels, 64K colours. I wrote the following test program to practise using this mode. It makes 64 squares, each 32*32 pixels. In each square, redness increases downwards and blueness increases to the right. Greenness increases as you go from each square to the next. There is one pixel with each of the possible 32*64*32 colour combinations. It works fine except for one important fault: any pixel that should be plotted at (screen start address + n) (reckoning in byte addresses) is actually plotted at (screen start address + (n % 0x10000))! But a test program that I have that I got as an .EXE and presumably was not compiled with Gnu C, writes to all the screen in this mode (and all modes) correctly. Please what's wrong???? My C:\AUTOEXEC.BAT's `SET GO32' line is:- set GO32=ansi driver c:/djgpp/contrib/libgrx/drivers/cl5426.grn gw 1024 gh 768 2r1 noglob core t$gccdbg nc 65536 Running C:\DJGPP\CONTRIB\LIBGRX\NDRIVERS\VESAINFO.COM causes a long output which starts thus:- VESASignature: "VESA" VESAVersion: 1.2 OEMStringPtr: "Cirrus Logic GD-54xx VGA" Capabilities: 0 VideoModePtr: 3734:2844 Video Modes: 0x14 0x10a 0x109 0x102 0x103 0x104 0x101 0x105 0x111 0x114 0x110 0x113 0x102 0x106 0x10f 0x112 Memory Size: 16*64KBytes ============================================ #include #include #include #include #include #include /*-----*/ long _ax,_bx,_cx,_dx; long _si,_di,_bp,_es; long GP_4; short GP_2; char GP_1; #define _SWOPR() /* swop registers with saved registers */ ({ \ asm("xorl %eax,__ax"); asm("xorl __ax,%eax"); asm("xorl %eax,__ax"); \ asm("xorl %ebx,__bx"); asm("xorl __bx,%ebx"); asm("xorl %ebx,__bx"); \ asm("xorl %ecx,__cx"); asm("xorl __cx,%ecx"); asm("xorl %ecx,__cx"); \ asm("xorl %edx,__dx"); asm("xorl __dx,%edx"); asm("xorl %edx,__dx"); \ asm("xorl %esi,__si"); asm("xorl __si,%esi"); asm("xorl %esi,__si"); \ asm("xorl %edi,__di"); asm("xorl __di,%edi"); asm("xorl %edi,__di"); \ asm("xorl %ebp,__bp"); asm("xorl __bp,%ebp"); asm("xorl %ebp,__bp"); }) /*-----*/ void int10() {_SWOPR(); asm("int $0x10"); _SWOPR();} void int21() {_SWOPR(); asm("int $0x21"); _SWOPR();} /*-----*/ unsigned char get_key(){_ax=0x0700; int21(); return _ax&255;} /*-----*/ unsigned char gp_mode(void) {_ax=0x0f00; int10(); return _ax&255;} /*-----*/ void gp_mode(char m) {_ax=m; int10(); if(m!=gp_mode()) printf("\007error: this computer has no mode 0x%1x\n",m);} /*-----*/ class Screen{public: short int wide,high; char mode,type; unsigned short*screen; Screen(int Wide,int High,int Mode,unsigned short*scr=0);}; /*-----*/ Screen::Screen(int Wide,int High,int Mode,unsigned short*scr){ wide=Wide; high=High; mode=Mode; screen=scr?(unsigned short*)scr:(unsigned short*)0xd0000000;} /*-----*/ unsigned short color(int r,int g,int b) {r>>=3; g>>=2; b>>=3; unsigned short i=(r<<11)|(g<<5)|b; return i;} /*-----*/ void Graphmode(Screen&scr){gp_mode(scr.mode);} void Textmode(){gp_mode(3);} /*----------*/ main(){long int r,g,b,i,j,k; unsigned short*screen=0; FILE*debug=fopen("t$debug","w"); unsigned short S[640*480]; Screen scr(640,480,0x64,screen); /* this on my PC is a 64K-color mode */ Graphmode(scr); k=0; for(r=0;r<256;r+=8) for(g=0;g<256;g+=4) for(b=0;b<256;b+=8) { i=(b>>3)+((g>>2)&15)*32; j=(r>>3)+(g>>6)*32; S[i+j*640]=color(r,g,b);} for(i=0;i<480;i++) S[i*641]=0; for(j=i=0;i<640*128;i++,j++) { if(!(i&0xfff)) { k=get_key(); if(!k) k=get_key(); if(k=='b') j=0; if(k=='s') goto Z;} scr.screen[j]=S[i];} if(!get_key()) get_key(); Z: Textmode(); printf("%08x\n",i);}