Looks like code was started around 1987-88ish. Yes, every "screen" in the game has it's own program loop. I have a development blog, though I'm a weary of posting it here. Not because it's secret or anything, but because I don't want to lead on how awful a programmer I actually am
The game has mechanisms in place to keep race conditions to a minimum. It's pretty good about keeping variables read and write only, and can pause the interrupt when it's not needed. Right now the thread is working as intended. However, I'm using a very sub optimal loop.
void *newtimer(ALLEGRO_THREAD *thread, void *dummyarg)
inint = TRUE;
if (killthread == TRUE)
printf("1Ch Thread killed\n");
/* Do all the things! */
I know... I know... I know.
This is NOT how I should be doing it. It eats up CPU time needlessly and I have no control structures short if a variable that is checked. The killthread bool comes from input routine. There are several debug routines in there from the previous devs. I added my own escape hatch... (You press the "escape" key).
I'm going to be making three passes in my quest to rebuild this game..
Pass 1: Bring back the dead - Get the game running using chicken-wire and good expectations. This puts the code into a functional state and allows me to go though the source, document, and learn.
Pass 2: Refactor - When I build the solution now, the compiler generates so many warnings I literally have them turned off. Between unused variables, unresolved externs, incorrect return types, and DOS functions that operate wildly from the POSIX / Win32 counterparts, it's a wonder that I even have a display. But I know it's broken and my second pass with be with /WX enabled and poisoned #pragmas (Or whatever MSVC uses) to squash all those things that make the compiler sad.
Pass 3: Update - Once the engine is in a good state, I will be giving a much-needed resolution boost and graphical face lift.
I'll be fixing all the hacks and broken bits armed with my better knowledge of the code. Maybe there is a control scheme that can be rewritten.. I don't know yet as my main priority is to just get it running first. It will be changed to a proper event queue when I unify mouse, keyboard, and display queues. I know it's hacky, and trust me, I know when I do something yucky. It's going to cause me grief when I refactor on pass 2. However, I'll be going to that phase with better knowledge of the system as a whole and armed with a bunch of TODO: triggers all over my code.
I am, by all means, not done
That said, hopefully you won't give my dev blog too much of the evil-eye.