Saturday, November 25, 2017

Breaking Down and Building Up.

This is me
You know that scene in Iron Man when Tony Stark starts to make the Mark II suit by virtually taking the Mark I  apart and tossing what he didn't need into a trashcan? Yea, that's how I feel. ROE has a thing going for it where it interfaced into a graphics library called "Nermal 2". (I'm assuming named after Jon's second cat in the "Garfield" comic.)

I'm basically writing a Nermal wrapper around Allegro, but there is so much legacy stuff that needs to be rifled though. Many variables are no longer needed and much of the internal Nermal API can be replaced with a one or two line Allegro equivalent. As Allegro uses 32 bit graphics (24 bit + 8 alpha), I still have to work out the color mapping. Amusingly enough, I find myself cribbing from the 4-color CGA code because of it's straightforward video memory mapping. I may also steal the CGA "color" code as EGA and VGA rely on palette cycles that I won't be using in 24 bit mode.

Also, Allegro does not have a GIF loader like what ROE used to load it's graphics Allegro's GIF loader was most likely not implemented due to patents, and when they expired Allegro became TrueColor anyway. I'll be converting the graphics to 32 bit PNG files. That said, my goal for this first pass is to get everything running as close as stock as possible. After that, then I hone the presentation a smidgen.

One of the more amusing things I ran across is what I've had to do to the prepossessor so that it can compile. In the years since 1991, C compilers go nuts if you try and use string commands that are prone to buffer overruns. For example scanf() as opposed  to sscanf(). I had to put a prepossessor directive in MSVC to allow me to use them anyway. (Which I will remove when I do my second pass). Also there are #ifdefs for three architectures in there, IBM, Amiga, and Atari. Visual Studio does not recognize "IBM" as a predefined macro, as that would mean something profoundly different nowadays, so I had to put it in  there so I have at least one valid codepath.

It loads data though, so that's cool.

No comments:

Post a Comment