Posted by
GuShH on September 5, 2009
This is a tool that I’ve been using for quite a long while, just recently I fixed a small bug in the regexp and I thought it was time to share it.
For those of you using the official IDE, there’s no real solution to this “problem”. When you’re working on something small, it’s not a big deal to define a couple of declares here and there… However, on bigger code this becomes a real issue!. So why waste the time switching between IDEs or doing it by hand?…
Grab it and let me know how it runs! (nasty ugly source included).
The tool is very simple to install, I recommend you unzip directly into your PB directory and configure it as follows:

That’s it. You’re ready to declar’em!.
Cheers.
Posted by
GuShH on August 28, 2009
One of the most important things a programmer has to know and learn is proper code design, structuring of the code, etc. This may not be imperative for you if you’re just starting out, but sooner or later you’ll be able to spot the patterns and realize that your current way of doing things is not optimal but rather cumbersome. This is when you start to separate things into modules and you begin to design your code with more meaning and purpose.
By breaking your code into modules or “classes” you can have a finer granularity of the code itself, you can encapsulate the base code and work on top of it, you can also reuse the code in other projects if you have a good design. An example would be a log library (for logging useful debugging information onto text files) with proper design and care you’ll be able to use the same library in almost all of your projects with little to no modification at all.
More…
Posted by
GuShH on August 27, 2009
I keep forgetting the fact that PB is retarded when it comes to the modulo operator and floating point values!.
It’s time to write our own fmod() equivalent; lucky for us the Intel guys were kind enough as to implement quite a useful instruction called FPREM a few eons ago, which pretty much means “Partial REMinder” and what it does is rather simple: it computes the partial remainder of st(0)/st(1).
Procedure.f fmod( x.f, y.f )
EnableASM
FLD DWORD[p.v_y]
FLD DWORD[p.v_x]
!NOT_READY:
FPREM
FSTSW AX
TEST AH, 100b
!JNZ NOT_READY
FSTP ST1
DisableASM
ProcedureReturn
EndProcedure
Of course with great instructions comes great limitations: in this case we cannot produce the final reminder if the difference between X and Y is bigger than 63. We can solve this by implementing a loop and checking for the C2 bit of the status word to be cleared. This is all explained in the IA32 manuals.
It’s not pretty but until fpu modulo operations are officially supported in the language, this might well be your only sane choice.
Posted by
GuShH on August 6, 2009
Dependent on the time-lapse lib, the animation code provides you with several count methods to manipulate your animations in an easy and comprehensible way.
If you add a sprite atlas library (I’ll share later) you’ll be able to manipulate sprites with animation in quite a flexible way without too much hassle.
The idea is to encapsulate the animation functionality in such a way that it makes it easy to work with. You have the ability to start, stop, pause, change speed, etc. You can create animations that range from any frame to any frame and that can animate in many ways such as sequential (loop), play-once and ping-pong (back and forth, or rather the inverse). By making use of the time-lapse library we can easily create time-based animation.
More…
Posted by
GuShH on August 5, 2009
This little lib is used to keep track of time using the low resolution timer provided by the OS (in Windows “GetTickCount”). The goal of this type of library is to encapsulate timing actions. It was originally designed for game development in mind but needless to say you can use it and adapt it to your own needs.
Basically you define a time interval as you create the “timelapse” instance. Every time you call the update function a simple check determines whether the time was reached or not. This is trivial, but encapsulating it makes sense. Specially if you plan to create an animation system in the future!
More…