speed,speed

Started by
14 comments, last by holy 23 years, 7 months ago
hi,

my stupid code is below;

for y:=-240 to 240 do
begin
for aci:=1 to 689 do
begin
if (-points_fast[aci,y].y+240>=80) and (-points_fast[aci,y].y+240<=400) then
pword(integer(surfacedesc.lpsurface)+(points_fast[aci,y].x+320)*2+(-points_fast[aci,y].y+240)*surfacedesc.lpitch)^:=imagetable[639-enginetable[round(aci*0.92)],-y+240];
end;
end;

i am working on adventure game engine which has a property of
cylindirical environment.So i calculate all of points ,then
assign them to directx surface pixels...so on,so on....




Advertisement
You should use Trunc instead of Round , is alot faster.
Has anybody done any research into x++ vs. ++x in situations such as these? I know that conceptualy ++x should be faster, since it doesn''t have to store the value before it increments it. I wonder if the code generated by the following would be any leaner or if today''s compilers are smart enough to optimize it out (please forgive the logic/syntax errors, i haven''t looked at it that carefully):

for (y = 0; y < 7; ++y){  (buf)* = (chardata)*;  (++buf)* = (++chardata)*;  (++buf)* = (++chardata)*;  (++buf)* = (++chardata)*;  (++buf)* = (++chardata)*;  (++buf)* = (++chardata)*;  (++buf)* = (++chardata)*;  (++buf)* = (++chardata)*;  ++buf; ++chardata;  buf += screenWidth - 8;} 


quote:Original post by Sly

...

for (y = 0; y < 7; y++){  (buf++)* = (chardata++)*;  (buf++)* = (chardata++)*;  (buf++)* = (chardata++)*;  (buf++)* = (chardata++)*;  (buf++)* = (chardata++)*;  (buf++)* = (chardata++)*;  (buf++)* = (chardata++)*;  (buf++)* = (chardata++)*;  buf += screenWidth - 8;}  

I did a "Panorama" viewer for DelphiX where I used VRAM (systemmemory=false) and StrechBLT to wrap a panoramic cylinder around the viewer. On a P2-450 with a Voodoo Banshee it would clock in around 50FPS. The technique should work fine on most hardware...

I also used integer math (when possible) and SIN256 and COS256 for warping calculations. Maybe I should post the source....?

[ side note: Another way to do it for Sphereical "image bubbles" is to use 3D hardware to texturemap the inside of a sphere. Easy enough to do in retained mode... ]





[ turbo | turbo.gamedev.net ]
[ Michael Wilson | turbo sys-op | turbo.gamedev.net ]
hi turbo,

how can you use strechblt function ?,First i define a cylinder in space coordinates,then calculate all of points that deformated to my camera and then i assign it to an array.But this way is not fast for my Celeron 366.Because the framerate is about 20 and in P166 ,it is 5-6 frame....

if you post the code,i am so happy for.......

and also using retained mode,if you want to make a realistic world visulation,you have define too big sphere and this way is not fast for,creating spherical panorama. Can you know that how Cryo made Atlantis,may be like a same way? but i think ,not.
Okay Holy

the For-Loop itself is still optimizable (refering to a prior reply by me (that entire unrolling, precalcing, etc.)

To get the maximum benefit though (without assembler) you should in my opinion try the following.

-Use a Pixel(offset,col) type routine

-enginetable[round(aci*0.92)]
should become:
enginetable[aci]
infact... the entire imagetable thing should also be done in a single precalc.

simply pre-do the forloops once with the original
engine[round..]
and only use engine[aci] (or something) inside the rendering loop

effectively it could look like:
for y:=0 to 100 do begin
lineY:=y*pitch;
for x:=0 to 200 do begin
PutPixel(lineY+x+20, engine[x]);
end;
end;

something like that... as far as I understood your code, you are trying to attempt a screen-transform, which makes the data look like it would, if you''d look at it through a glass cylinder...?

Well... have fun.

This topic is closed to new replies.

Advertisement