www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/24/22:01:02

From: walter DOT koebler AT franken2000 DOT de (Walter Köbler)
Newsgroups: comp.os.msdos.djgpp
Subject: Parameters of common graphic-cards?
Date: Wed, 22 Jul 1998 13:21:07 GMT
Organization: Nacamar Data Communications
Message-ID: <35b5e355.6207811@news.astat.de>
NNTP-Posting-Host: dialin-146.astat.de
Lines: 65
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi

Programming a trident SVGA-graphic-card is very simple.
Example-resolution: 1024 x 768, 256 palette-registers, each
contanining one of 63*63*63 possible colors. Operating system
MS-DOS (here for example GNU/DJGPP/C++):

#define COLUMNS 1024
#define ROWS    768
long VGA_START = 0xa0000;
typedef U_C unsigned char;
const U_C graphic_mode = 0x62, text_modus = 3;
int read_write_port = 0x3c5;//int: 4 bytes
int write_palette      = 0x3c8;
int read_palette       = 0x3c7;
int rgb_part              = 0x3c9;
U_C red,green,blue; 
U_C bank[] ={0x2,0x3,0x0,0x1,0x6,0x7,0x4,0x5,0xa,0xb,0x8,0x9};
//bank:  12*64 rows = 768 vertical monitor-lines(top->down)
U_C *svga_array = new (U_C) [COLUMNS*ROWS];//each Byte is
// the number 0...<=255 of a palette
void SetVideoMode(U_C video_mode)
{ union REGS regs;
  regs.h.ah = 0;
  regs.h.al =  video_mode;
  int86 (0x10, &regs, &regs);
}//get_plot as simplified special-case of a shadow-array(svga_array):
//y*1024 ==  y<<10;
U_C get_plot(int &x, int &y, COLORS color)
//upper-left:x=y=0, simple convertable to a bitmap-array
{ U_C C;
   outportb(read_write_port,bank[y>>6]);
   dosmemget(VGA_START + ((y%64)<<10)+x,1,&C);//get C-pixel
  dosmemput(&color,1,VGA_START + ((y%64)<<10)+x);//put color-pixel
  return C;
}
//256 paletten-register, each containing a red/green/blue-triple of
//3x6 - bit color-bytes. 0<=red,green,blue<=62 . Scheme:
  for(int palette=0;palette<=255;palette++)
//svga_array[y*COLUMNS+x] == palette, just for fun
//all 256 registers get the same color:
  { outportb(write_palette,palette);
    outportb(rgb_part,red);
    outportb(rgb_part,green); 
    outportb(rbg_part,blue);
  }//read paletten-register-rgb-contents:
  for(int palette=0;palette<=255;palette++)
  { outportb(read_palette,palette);
    red  =inportb(rgb_part);
    green=inportb(rgb_part);
    blue =inportb(rgb_part);
  }
This will be as simple with all graphic adapters from
1024 x 768 resolution upward - no book necessary.
I ask you for the measly few values respectively for their
equivalences:
read/write_port,read/write_palette,rgb_part,bank[],graphic_mode
for most common graphic adapters from 1024x768 to 1600x1200 pixel
and from 256 to 16.700.000 colors.

Many thanks 
greetings
W.K.

Also to my eMail:  walter DOT koebler AT franken2000 DOT de

- Raw text -


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