TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: KURT KUZBA
from: MATHIEU BOUCHARD
date: 1998-04-16 02:54:00
subject: VESATEST.CPP 2/3

 KK> void GraphicsScreen::PutPixel(int x, int y, int c)
 KK> {
   if(x  319 || y  199)   return;
 KK>    *((char*)0xA0000000L + x + (y << 8) + (y << 6)) = (char)c;
 KK> }
try this:
void GraphicsScreen::PutPixel(int x, int y, int c)
{
  if((unsigned)x >= 320 || (unsigned)y > 199) return;
  *((char*)0xA0000000L + x + (((y << 2) + y) << 6) = (char)c;
}
The major improvement is the first one. The 2nd normally should only
benefit on marginally old computers, but that is more probable when
using TC++. GCC automatically converts y*320 to either your code or
mine, or even better, i think it uses the LEA asm trick. GCC might also
find the 1st optimization itself as well, i'm not too sure.
matju
--- Terminate 4.00/Pro
---------------
* Origin: The Lost Remains Of SatelliteSoft BBS (1:163/215.42)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.