Mail Archives: djgpp/1998/01/09/07:31:40
>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
>
Well, some of the functions you use may be compiler specific to
another compiler, but I'm not sure, but that's not your real problem.
Your problem is that you are using real mode code on a
protected mode compiler/linker. I can't help you too much,
except to tell you to do some reading up on the use of DJGPP.
You might take a look at: http://www.rt66.com/~brennan/djgpp/
There is some useful information there.
Your tutorials and books probably contain a fair bit of low-level
real mode code, which is probably useless in protected mode,
I'm not sure how convertable it is.
Carl Marg
I might be right, but the odds are against it.
- Raw text -