Archived

This topic is now archived and is closed to further replies.

tHiSiSbOb

Too Slow?!?!?!

Recommended Posts

I am making a Tile-based rpg and I am having some problems with the pixel * pixel scrolling engine. It works just fine but in my opnion it should be going alot faster. Here is the code i am using. void MAP::DrawMap() { RECT rct; int x,y; int xcount,ycount; for (y=ScrollYValuemin;yBltFast(0,y*16,Map_Surface,&rct,DDBLTFAST_WAIT); xcount=0; for (x=(ScrollXValuemin);xBltFast(xcount-(PixelScrollValueX),y*16,Map_Surface,&rct,DDBLTFAST_WAIT); } xcount+=16; } } Is there any major way this code can be optimized. I tested it on another (slower) computer and it seemed to run faster. Here are the specs for the two comps i tested on. mine: Intel PIII @ 1.1 ghz GeForce 4 mx 420 w/63mb 256 mb pc133 ram WinXP Home The other comp: AMD Duron @700 mhz vanta w/8mb of ram 256 mb pc133 ram WinME. Any Help will be apprectiated. "Computers are only as smart as their programers" My Site-> Still working on it.

Share this post


Link to post
Share on other sites
Possibly the OS difference. WinMe gives you closer access to the hardware (as opposed to the NT HAL present in WinXP). Since the difference is solely system-based, it''s also possibly driver-related.

As for optimization in the code, I would change y*16 to (y << 4), which equates to the same but is slightly faster on the processor-side. (Theoretically, a good compiler will do this for you.)

Also, what method are you using to update the screen? If you re-render the entire screen per-frame, it''s not necessary to clear the backbuffer before filling it with map-pixel data. Are you blitting back -> front, or performing page flipping? And are there any other parts of the code that could be slowing the program down (input, sound, network)?




MatrixCubed
http://MatrixCubed.cjb.net

Share this post


Link to post
Share on other sites
I am re-rendering the screen. Also I am blitting to the Back then page flipping to the primary. As for n e thing else that could be slowing it down....i am not sure why but i think it might be something in my main loop....No network,input,sound;

"Computers are only as smart as their programers"
My Site-> Still working on it.

[edited by - tHiSiSbOb on July 30, 2002 1:25:17 PM]

[edited by - tHiSiSbOb on July 30, 2002 1:27:39 PM]

Share this post


Link to post
Share on other sites
Try getting rid of DDBLTFAST_WAIT in your blitting lines, I think that might help. Also, instead of doing the multiplies so often to find out which tile you''re drawing (ie. [ScrollXValuemin][y] and [x][y]) which is a multiply and an addition every time you do it, try finding the address of the first tile, and then just incrementing it as you move across. Then when you reach the end, you increment it by (Width-(LastTileInRow-FirstTileInRow)). Although on those machines, the first idea will probably make more difference.

tj963

Share this post


Link to post
Share on other sites
When using DirectX, the only time you should use anything that ends with _WAIT is when you flip the backbuffer, and then only when using VSYNC (that is, in fact, how you do it).

When doing anything else, the _WAIT flags are intended for debugging purposes only...

Just a tip...

Share this post


Link to post
Share on other sites