Allegro.cc - Online Community

Allegro.cc Forums » The Depot » Porting game from Allegro 4 to Allegro 5

This thread is locked; no one can reply to it. rss feed Print
Porting game from Allegro 4 to Allegro 5
Frank Drebin
Member #2,987
December 2002
avatar

I just finished porting my game from Allegro 4 to Allegro 5 (the windows version for now) and here are a few thoughts:

First I have to say that the transition went quite smooth because every convenient function found in Allegro 4 is included in Allegro 5 as well. Even though I was used to Allegro 4 a lot, I prefer the naming convention of the al_... functions which improves readability and the event-driven system is just great! Also, I like the idea that Allegro 5 support modern hardware and hardware acceleration. I was a bit surprised that the Allegro 5 dll is much bigger in size but I assume this is for a good reason...

So in the end I just want to tell the developpers that they did a great job :-*

Chris Katko
Member #1,881
January 2002
avatar

Yep. And basically, anyone who complains, is just lazy. ::) You can almost port the entire thing over with a series of Find/Replace / regex's.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

It's really not that simple. :/

Palette routines are not supported in Allegro 5. Neither is MIDI. If you want to port the first, you need a shader. If you want to port the second, you need an audio library like FMOD.

There's more to it than CTRL-R. :/

Chris Katko
Member #1,881
January 2002
avatar

Of course I exaggerated a bit.

MIDI? Shim it off to null functions. Then replace with a small cross-platform library (I think even fmod supports midi).

8-bit palette? First, just draw everything and let it look like butt until you get everything working. The shader is actually super simple and many tutorials/articles/googles exist. Keep everything in 8-bit bitmaps, load the palette into a 32-bit bitmap, and have the shader translate.

ONE shader. And a shader is just a modular program. We're all used to programming, shaders aren't a big deal if you sit down for a day or two and read about them.

Event Queues could be an issue if they have their logic strewn across random places of the codebase. But you can, IIRC, run Allegro 5 without them properly and just save their events into a structure and react to them like you used to.

-> The key is, get SOMETHING up and running and shim off anything that doesn't let you do it. Then deal with each problem individually. Even a black screen without crashing that loads all your assets, is a start.

I might go and port that Zelda classic repo just for the hell of it...

[edit] Oh my god. Their codebase. It was written in 1999, and it's full of so many hard coded values (not constant variables, just literals)... "My God, It's full of stars"

{"name":"xl1XYq8.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/3\/731bf4aaf9622eb24ca79dc12ad2ab1c.jpg","w":1620,"h":1079,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/3\/731bf4aaf9622eb24ca79dc12ad2ab1c"}xl1XYq8.jpg

Anywhere they randomly change the palette, I'd have to shim that off to a "change my palette bitmap" function. And they do some/lots of per-pixel effects like assembly code flame generation. That's no-bueno. Not sure the best way to resolve that except chop it out temporarily.

[edit] Huge amounts of, what I'd consider anti-patterns, mixing of graphics and logic code in the same lines. And zero encapsulation (even though it's C++). The "run the ending" code accesses save games, quests, graphics, probably even file access, all around the same lines of code, loops, and if statements. It's not like, some horrific codebase, but code like that is certainly more brittle to changes because you don't know if it'll affect something greater. That is, say, you change a animation handler, and it affects your mouse because deep in the code the mouse was actually dependent on the animation timer.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Go to: