Category : C Source Code
Archive   : CBIBLE.ZIP
Filename : OUTPORT.C
#include
#include
#define EGA_RAM ((unsigned char far *)0xA0000000)
#define MAX_GR_COLS 640
#define MAX_GR_ROWS 350
#define MAX_COL_BYTES (MAX_GR_COLS/8)
#define BIOS_VIDEO 0x10
#define SETMODE 0 /* BIOS service: set video mode*/
#define EGAMODE 16 /* EGA mode for high resolution*/
#define EGA_GR12 0x3ce /* Port to select register */
#define EGA_GR_MODE 0x5 /* Register no. for write mode*/
/* The box size and the color */
#define XSTART 120
#define YSTART 120
#define XSIZE 280
#define YSIZE 200
#define COLOR 2
static union REGS xr, yr;
static char far *videoram;
main()
{
int ynum, bytecount, startadrs, startbyte, stopbyte,
horbytes, skipbytes;
unsigned temp, egacommand;
/* Use BIOS to put EGA in high_res graphics mode */
xr.h.ah = SETMODE;
xr.h.al = EGAMODE;
int86 (BIOS_VIDEO, &xr, &yr);
/* compute starting address */
startbyte = XSTART/8;
startadrs = 80*YSTART + startbyte;
videoram = EGA_RAM + startadrs;
skipbytes = MAX_COL_BYTES;
/* Put EGA in write mode 2. Use outpw. The following
* code is equivalent to 2 lines:
* outportb (EGA_GR12, EGA_GR_MODE);
* outportb (EGA_GR_PORT, 2); */
egacommand = (2<<8) : EGA_GR_MODE;
outport(EGA_GR12, egacommand);
stopbyte = (XSTART + XSIZE - 1)/8;
horbytes = stopbyte - startbyte;
skipbytes = MAX_COL_BYTES - horbytes;
/* We already have the proper graphics mode settings */
for (ynum = 0; ynum < YSIZE; ynum++)
{
for (bytecount = 0; bytecount < horbytes; bytecount++)
{
/* Fill in 8 bits at a time.
* First read to latch in bytes. */
temp = *videoram;
/* Now write out pixel value to all 8 bits at once */
*videoarm = COLOR;
videoram++;
}
/* Skip to next row */
videoram += skipbytes;
}
/* Reset graphics environment back to BIOS standard */
egacommand = EGA_GR_MODE;
outport(EGA_GR12, egacommand);
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
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/