www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/07/19/15:38:12

Date: Thu, 19 Jul 2001 15:36:27 -0400
Message-Id: <200107191936.PAA22352@envy.delorie.com>
X-Authentication-Warning: envy.delorie.com: dj set sender to dj AT envy DOT delorie DOT com using -f
From: DJ Delorie <dj AT delorie DOT com>
To: Sterten AT aol DOT com
CC: eliz AT is DOT elta DOT co DOT il, djgpp AT delorie DOT com
In-reply-to: <bc.17884332.28888d5d@aol.com> (Sterten@aol.com)
Subject: Re: pokeb peekb
References: <bc DOT 17884332 DOT 28888d5d AT aol DOT com>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> #include<go32.h> 
> int main() { // gcc video3.c -o video3.exe 
> _farpokeb(_dos_ds,0xb8000+12*160+40*2,1);}
> 
> compiles and runs fine. (gcc2.03)

If you run it on my old laptop it will fail, because my laptop has a
monochrome screen (0xb0000).  It will fail on my newer laptop because
the screen is not 80x25 cells.  It will fail if the center cell has a
black-on-black attribute already (or any other same-on-same
attribute).  Just because it happens to run on your machine does not
mean you have learned a proper and useful technique.

If your purpose is to do graphics programming, then you are learning
the wrong techniques anyway.  You want to learn about the _farns*
functions and nearptrs, or use Allegro (which hides the hardware
layer, allowing you more than 640x480 without having to know what kind
of card you're using) or GRX.  *Especially* if you're teaching people
how to program!  Give them a high-level library like Allegro and
they'll see better results faster, which will encourage them to
continue.

See also http://www.delorie.com/djgpp/doc/ug/ which has a chapter on
graphics programming for DJGPP.

As for general C, you should get in the habit of adding spaces and
sparsely populated lines (appropriately, of course) to make your
program more readable (DJGPP's indent tool can do this for you).  This
is especially important if you want someone else to read your code to
help you solve a problem.

Before:

int main() { // gcc video3.c -o video3.exe 
_farpokeb(_dos_ds,0xb8000+12*160+40*2,1);}

After:

int
main ()
{
  // gcc video3.c -o video3.exe 
  _farpokeb (_dos_ds, 0xb8000 + 12 * 160 + 40 * 2, 1);
}

You should get in the habit of returning a valid exit code, either by
calling exit() with a suitable value (zero for success, nonzero for
failure) or returning a suitable value from main (rather than just
falling off the end as you do).

- Raw text -


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