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)
|