www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/28/08:33:29

From: Stephen Liu <stephen_liu AT bigfoot DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Writing directly to vga memory in DJGPP
Date: Thu, 27 Feb 1997 21:59:28 -0500
Organization: Kadoorie Corp.
Lines: 39
Message-ID: <33164A10.1D88@bigfoot.com>
NNTP-Posting-Host: 128.226.101.87
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

The following program clears the screen in VGA mode (13h) in each 
of the 255 colors.  My buffer is declared as:

unsigned char *vidbuffer=(unsigned char *)0xA0000;

Is this correct? When I run it under Win95, it creates
a memory exception and quits the program.


//*******************************************************************

#include <stdio.h>
#include <dos.h>

unsigned char *vidbuffer=(unsigned char *)0xA0000;

void setmode(int mode)
{ union REGS regs;
  regs.h.al = mode;
  regs.h.ah = 0;
  int86(0x10, &regs, &regs);
}

void clrvidbuffer(unsigned char color)
{ int i;
  for (i=0; i<32000; i++)
  { vidbuffer[i]=color;     // Write pixel to buffer
  }
}

void main()
{ int i;
  setmode(0x13);        // Set VGA mode

  for (i=0; i<256; i++) 
   clrvidbuffer(i);     // Clear the screen in each color
}

//*******************************************************************

- Raw text -


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