Mail Archives: djgpp/1998/01/08/22:46:44
From: | Brian Reich <breich AT sunlink DOT net>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Help! VGA programming problem in DJGPP
|
Date: | Wed, 07 Jan 1998 22:19:31 -0800
|
Organization: | B & D Website Production
|
Lines: | 48
|
Message-ID: | <34B46FF2.22E31F82@sunlink.net>
|
NNTP-Posting-Host: | m723.sunlink.net
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
I am wondering why this code will not work when I try to use the plot
function. it gives me all kinds of 'segment fault' errors... Any idea???
/* Mode 13h code lovingly copied from VGA Basics Tutorial,
http://silo.csci.unt.edu/home/brackeen/vga/basics.html
Rest of program written by Brian Reich */
//Required Libraries
#include <bios.h>
#include <iostream.h>
// Global Macros
#define VGAMode 0x13
#define TEXTMode 0x03
//Global Variables
typedef unsigned char byte;
byte *VideoBuffer = (byte *)0xA000000L;
// Function which changes to desired video mode
void setVideoMode(int mode) {
union REGS regs;
regs.h.ah = 0x00;
regs.h.al = mode;
int86(0x10, ®s, ®s);
}
// Function which draws Pixel directly to video buffer
(FAST!)
// Taken from Tricks of the Game Programming Gurus
void plot(int x, int y, unsigned int color)
{
int index = (y<<8) + (y<<6) + x;
VideoBuffer[index] = color;
}
void main(void) {
setVideoMode(VGAMode);
cout <<"Nifty";
plot(2,2,5);
// setVideoMode(TEXTMode);
}
When it gets to plot(2, 2, 5); the program crashes. All I want to do is
plot a damn pixel! If you can help PLEASE lemme know what I am doing
wrong.
breich AT sunlink DOT net
- Raw text -