delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/09/07:31:40

From: marg AT okstate DOT edu (Carl Marg)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Help! VGA programming problem in DJGPP
Date: Fri, 09 Jan 1998 12:02:58 GMT
Organization: Oklahoma State University, Stillwater OK
Lines: 64
Message-ID: <34b61060.1258329@news.okstate.edu>
References: <34B46FF2 DOT 22E31F82 AT sunlink DOT net>
Reply-To: marg AT okstate DOT edu
NNTP-Posting-Host: dhstudent-res-life-302.dhcp.okstate.edu
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, &regs, &regs);
>}
>
>                // 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 -


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