www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/29/14:40:22

From: Paul Shirley <Paul AT foobar DOT co DOT uk DOT chocolat>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: graphics
Date: Sun, 29 Dec 1996 18:31:20 +0000
Organization: wot? me?
Lines: 27
Distribution: world
Message-ID: <kd3CcCA4jrxyEwsO@foobar.co.uk>
References: <1 DOT 5 DOT 4 DOT 16 DOT 19961218230509 DOT 19f7ab66 AT mail DOT algonet DOT se>
<32c3e184 DOT 1226804 AT news DOT eunet DOT fi> <01bbf50f$5ce75680$d42649c2 AT default>
Reply-To: Paul Shirley <junk AT defeating DOT email DOT address>
NNTP-Posting-Host: chocolat.foobar.co.uk
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <01bbf50f$5ce75680$d42649c2 AT default>, Thomas Harte
<T DOT Harte AT btinternet DOT com> writes
>> Then draw pixels in this way:
>> #include<go32.h>
>> #include<sys/farptr.h>
>> _farpokeb(_dos_ds, 0xA0000+y*320+x, color);
>
>       Instead of multiplying by 320, I suggest you use two bit-shifts, 
>therefore
>changing the line to :-
>
>       _farpokeb(_dos_ds, 0xA0000 + (y << 8) + (y << 6) + x, colour);
>
>       . . . .as this is faster.
>
>               -Thomas

I suggest you leave it as *320, gcc will generate optimal code itself.
You will also be better able to read the source ;)

(It probably compiles faster as well... last time I looked the explicit
shift version got converted to the same code as a plain multiply. Its
probably a lot easier to detect a explicit multiply than the implied
one.)

---
Paul Shirley: shuffle chocolat before foobar for my real email address

- Raw text -


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