Category : C Source Code
Archive   : RXGRAPH.ZIP
Filename : DOT320.C

 
Output of file : DOT320.C contained in archive : RXGRAPH.ZIP
#if 0
DOT320.C

Procedures contained:

void put_dot_320 (row, col, color) int row, col; unsigned char color;
int get_dot_320 (row, col) int row, col;

Procedures called: None
Include files: None

These functions read and write the color values for individual pixels in
320 by 200 (medium resolution) graphics mode on a CGA, using memory
mapped routines rather than DOS calls. Writes are done without waiting
for retrace, and in testing this did not appear to cause "snow".

Source code includes two versions. The default uses shifting and
masking to get at the bits for the specified pixel. An alternative
would be to use C bit fields. Compile with the option "/DBITFIELDS" to
use the bit field version.

#endif

static char far *CGA_RAM=(char far *)(((long)0xb800)<<16);
#define SET_CELL cell=CGA_RAM+(row>>1)*80 + col/4 + 0x2000*(row%2)

put_dot_320(row, col, color) int row, col; unsigned char color;

#ifdef BITFIELDS
{
struct pixels /* Note bit fields are assigned right to left */
{
unsigned pixel_3:2;
unsigned pixel_2:2;
unsigned pixel_1:2;
unsigned pixel_0:2;
} far *cell;
SET_CELL;
switch (col%4)
{
case 0: cell->pixel_0=color; break;
case 1: cell->pixel_1=color; break;
case 2: cell->pixel_2=color; break;
case 3: cell->pixel_3=color; break;
}
}
#else
{
unsigned char far *cell;
unsigned int two_bits;
SET_CELL;
col%=4;
two_bits=(0xff3f >> (col<<1));
color<<=((3-col)<<1);
*cell &= two_bits;
*cell |= color;
}
#endif

int get_dot_320(row, col) int row, col;

#ifdef BITFIELDS
{
struct pixels /* Note bit fields are assigned right to left */
{
unsigned pixel_3:2;
unsigned pixel_2:2;
unsigned pixel_1:2;
unsigned pixel_0:2;
} far *cell;
SET_CELL;
switch (col%4)
{
case 0: return cell->pixel_0;
case 1: return cell->pixel_1;
case 2: return cell->pixel_2;
case 3: return cell->pixel_3;
}
}
#else
{
char far *cell;
SET_CELL;
col%=4;
return 3 & ((*cell) >> ((3-col)*2));
}
#endif


  3 Responses to “Category : C Source Code
Archive   : RXGRAPH.ZIP
Filename : DOT320.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/