DarkOnes Wolf3D source tutorial 1.

Need for Speed


The purpose of this tutorial is to setup compiler to use some optimizations and make an fps counter in Wolf3D.



Lets start! I assume you have set up a compiler and can build a working engine. Lets set-up some compiler optimization parameters, all my future tutorials would assume you did it.


Make settings are the same as on the following screenshots:


Options->Compiler->Advanced Code Generation:


Options->Compiler->Code Generation: (note Floating Point option here, it uses hardware x87 co-processor which makes if faster so you can use some floating point math in your code, youll need hardware which support it though, but all modern hardware, beginning with 486 have it, and the majority of old also)


Options->Debugger: (disabling source debugging makes executable smaller and little bit faster)


Additionally remove wolfhack.c and whack_a.asm files from the project. To do this go Window->Project select file and do Project->Delete Item.



So, enough messing with compiler, lets do some real things! We are going to add fps counter today. In case you dont know it counts how fast engine renders frames (how many of them are drawn in one second).


First well add some global variables:


WL_DRAW.C (beginning)

long lasttimecount;

long frameon;

int fps_frames=0, fps_time=0, fps=0;


And then well write actual code:


WL_DRAW.C (ThreeDRefresh function)













PrintX=8; PrintY=190;



US_Print(" fps");





Voila! It would give you a nice fps counter in the lower left corner of the screen!



Note: max fps value is 70 (by wolf engine design)


How to understand and use fps counter:

If fps is 65..70 all is OK!

If fps is 55..65 if you have fast machine optimize your code, a less powerful machine will have problems with it

If fps is 25..55 on lesser machines it wouldnt be playable

If fps is 00..25 (off the lights.., unless you have a 286)



I hope this thing helped you on your way to create the best Wolf3D conversion ever made. If so, just drop me a line on DarkOne@navigators.lv. I wish to see your work!



2002 DarkOne; part of NewWolf project



Hosted by uCoz