delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/11/29/00:06:36

From: "Damian Yerrick" <NOSP AT Musenet@pineight.8m.com>
Newsgroups: comp.os.msdos.djgpp
References: <abi04.2131$t12 DOT 95240 AT newscontent-01 DOT sprint DOT ca>
Subject: Re: Newbie tries to plot a pixel and fails :)
Lines: 72
Organization: Pin Eight Software <http://pineight.8m.com/>
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
Message-ID: <CJm04.4240$at4.81509@dfiatx1-snr1.gtei.net>
X-Trace: +Sdx8YvGmOcw+MRF7m/eyPPJTCvwTR69gHbF1XTHwmBTICoe0t+iRhu25bVJT/BDGzTu10NLu3oC!sDLe0dzJDKLqc37Wf8Ae6xQ+NGjiNMKXJgDdVn7+aYVjEzGn6okRtMP2HmHgC6YFhCRME5hLiA==
X-Complaints-To: abuse AT gte DOT net
X-Abuse-Info: Please be sure to forward a copy of ALL headers
X-Abuse-Info: Otherwise we will be unable to process your complaint properly
NNTP-Posting-Date: Mon, 29 Nov 1999 03:49:54 GMT
Distribution: world
Date: Mon, 29 Nov 1999 03:49:54 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"James Migel" <jmigel AT sprint DOT ca> wrote:
> Hi all, I'm trying to work my way through the DJGPP tutorial on the game
> programming megasite http://perplexed.com/GPMega/ and am having trouble
> plotting a pixel. I have my code right I think... mode 13 starts and then
it
> is supposed to plot at x=25 y=25 color=25 but I see nothing... I thought
> that maybe my color (25) was black but it doesn't matter what I use I
still
> get a blank screen. Is it possible that I have to load a color palette
> before it knows any colors? code as follows:
>
> #include<stdio.h>
> #include<dos.h>
> #define GRAPHICS 0x013
> #define TEXT 0x03
> /*prototypes*/
> void SetGraphicsMode(int iMode);
> void PlotPixel(int ix,int iy,char cColor);
> /*global pointer to video buffer*/
> char *pcVideoBuffer=(char *)0xa0000;
>
> int main(void)
> {
>  SetGraphicsMode(GRAPHICS);
>  fflush(stdin);
>  getchar();
>  PlotPixel(25,25,25);
>  fflush(stdin);
>  getchar();
>  SetGraphicsMode(TEXT);
>  return 0;
> }
>
> void SetGraphicsMode(int iMode)
> {
>  union REGS regs;
>  regs.x.ax=iMode;
>  int86(0x10,&regs,&regs);
> }
>
> void PlotPixel(int ix,int iy,char cColor)
> {
>  pcVideoBuffer[(iy<<8)+(iy<<6)+ix]=cColor;

Can't do that. Video buffer is not in the program's data segment.
pcVideoBuffer? What else is there? macVideoBuffer?

> }
>
> Any help would be greatly appreciated...

You need to use either nearptr or farptr with protected mode.
I see neither in your code. DJGPP provides a linear address
space, but it doesn't start at the interrupt table like real mode's.
I suggest learning about far memory addressing, opening a
segment with DPMI to gain access to the VGA framebuffer,
and using farpokeb() (or whatever it's called) to plot pixels.

But if you want to get on the fast track to actually *doing*
graphics, you might want to try Allegro and study its source code.
http://www.talula.demon.co.uk/allegro/

Also, I see you're using Hungarian notation. IMHO, it's ugly.
If you're using an integer called mac (memory access counter)
e.g. in a malloc debugger, it would become iMac in Hungarian.
http://www.apple.com/
But we're getting way off topic...


Damian Yerrick


- Raw text -


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