delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/01/31/12:37:25

From: "A.Appleyard" <A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk>
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Date: Tue, 31 Jan 1995 11:11:29 GMT
Subject: Re: True Color Graphics Possible?

havemann AT uran DOT informatik DOT uni-bonn DOT de wrote:-

> I have a Miro Crystal 8S VESA-S3 card capable of showing 640x480x24bit true
> color ... I didn't manage to display them from gcc/djgpp even when using djgpp
> 2.6.0m1, with set GO32=driver d:/.../vesadrv.vdr::pf gw 640 gh 480 nc 16777216

I successfully wrote to my PC's screen in its 0x64 (graphics) mode (640*480
pixels, 64K colours) with this program. It is Gnu C++. It must be compiled
with -lgrx . In it, G (granularity) and W (window size) may vary between PC's.
The interrupt `AX=0xf401, CX=n, int0x10' writes to [ES:DI] etseq 256 bytes of
information about mode n including: bytes 4,5 = window granularity in Kbytes,
bytes 6,7 = window size in Kbytes.

#include <stdio.h>
#include <math.h>
#include <builtin.h>
#include <stdio.h>
#include <std.h>
#include <pc.h>
/*-----*/
double ask(char*s) {double x; static char buf[512]; X: printf(s); gets(buf);
if(sscanf(buf,"%lf",&x)<1) goto X; return x;}
/*-----*/
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("xchgl %eax,__ax"); asm("xchgl %ebx,__bx"); asm("xchgl %ecx,__cx"); \
asm("xchgl %edx,__dx"); asm("xchgl %esi,__si"); asm("xchgl %edi,__di"); \
asm("xchgl %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 /* ((i&0xff00)>>8)|((i&0x00ff)<<8) */ ;}
/*-----*/
void Graphmode(Screen&scr){gp_mode(scr.mode);}
void Textmode(){gp_mode(3);}
/*----------*/
main(){
long int r,g,b,i,j,k,G,W; unsigned short*screen=0; unsigned char Z[1024];
FILE*debug=fopen("t$debug","w"); unsigned short S[640*480];
/*_ax=0x4f01; _cx=0x64; _di=(int)Z; int10();
for(i=0;i<512;i++) printf("%02x",Z[i]); printf("\n"); get_key(); */
GrSetBIOSMode(0x12,640,480,16);
Screen scr(640,480,0x64,screen);
LOOP: G= 1<<11; /* (int)ask("log2 granularity?"); if(G<0) goto OUT; G=1<<G; */
W=15 /* (int)ask("log2 window size?") */;
/* this on my PC is a 64K-color mode 640*480 pixels */
Graphmode(scr); k=0; /* one pixel of each possible color combination */
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=512;i<640;i++) for(j=0;j<128;j++) S[i+j*640]=S[i-512+j*640];
/* for(i=0;i<480;i++) S[i*641]=0; */
/* copy array S to screen, halt every 32 lines of pixels */
for(i=0;i<640*480;i++) {j=i&(0xffffffff<<W);
    if(i==j) {_ax=0x4f05; _bx=0; _dx=j/G; int10();}
    scr.screen[i]=S[i%(640*128)];}
if(!get_key()) get_key(); Textmode(); /* goto LOOP; */
OUT:;}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019