Blade Edge

Computer software | Video production | My life in general

Blade Edge main header

Codin’ Frenzy!

October 20th, 2004 · No Comments · Software

Transposed from Gaiiden’s Scroll

Well I managed to accomplish quite a lot in just four hours of coding tonight. I’m still working on Tanto, the log reporter for my Katana engine. I started posting about it back on the 1st of this month. Tonight my goal was to code the log data loading system, which I did – yey. I only coded in loading for text output messages, but that’s a good start. Some highlights:

I was stymied for a bit trying to decide how to define what output type got assigned what color. At first I thought of just randomly choosing RGB values, but that could produce colors that wouldn’t read well on the screen. Finally I came up with using an image as a palette. I simply create a bitmap with each pixel a different color, aligned in a row. I then load in the bitmap, lock the surface, and use a GetPixel() function to get and store the color of each pixel. Ta da! Now I have colors to assign to text output types, and I can change those colors without having to recode anything.

Another problem I had was a result of a new feature I wanted to implement in my logging system. Currently the logger dumps everything to a file in real time. This can drag performance, having to keep a file open and writing to it possibly dozens of times per frame. Instead I want to implement a memory buffer and a dump limit. So when something’s sent to the log system to be outputted to a file, instead it’s stashed in memory. If the used memory exceeds a set limit, it dumps its contents to a file and clears the buffer for new data. So if you have a small buffer and play long enough, you could end up with more than one log file. The multiple log files will have numbered extensions, like RAR files: debug.log1, debug.log2, debug.log3, etc. When the app shuts down, it will dump the remains of the buffer into debug.log, along with the log header. Now, how do I open and input data from multiple files? I don’t use recursive functions much, but this was a situation too good to pass up. The user opens the main log file (with the .log extension) and at the top there’s a batch number. The function then appends that batch number onto the log file path and calls itself. So say we have 3 batch files:

Code listing.

Suhweeeeeet. Thanks to the wonderfulness that is recursion, I can now dump log data into multiple log files, and then load that data in proper order. Take notes kids.

So that’s really all the cool stuff I did tonight. Now that I’ve figured out the new format for my log text, I can change the way I log stuff in the engine. I’ve got this warm happy fuzzy feeling you get when know you’ve coded something proper. I’m going to wait until tomorrow to test it, because my fuzzy feeling’ll prob go away quick when the damn logistical errors crop up, like they always do.

So… off for some cherry pie, cookies and brownies – celebration time for a job well done!

Tags: ·

No Comments so far ↓

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment