Rabbit Holes
During my studies on the EGA, it occurred to me that a good way to learn some of its inner workings is to code an emulator. The more I think about it, the more I dread all the rabbit holes I’ll be going down. That’s the fun of it, though… right?
I reckon.
I suppose I could create a structure for each group: Graphics Controller, Attribute Controller, Sequencer. (Not sure if the CRT Controller should be included here, since I plan to have this plug into Allegro 5. Maybe for the sake of completeness.) There should be bytes allocated for the fake video memory. A simple 2D array. Yes, that would do nicely.
But, of course, it’ll be a bit more complicated than that. (We’re peeking into the rabbit hole now. It’s looking dark down there.)
The EGA could have up to 256k of video RAM. In mode 0Dh, that’s 8 pages at a resolution of 320x200. There’s more!
This memory was arranged in planes—four of them, to be exact. Each 64k. These planes are essentially stacked on top of each other.
A simple 2D array could handle this…
#define PLANE_SIZE 64000
#define NUM_PLANES 4
uint8_t ega_mem[NUM_PLANES][PLANE_SIZE];
So there you have it—256k of video RAM, arranged sequentially. It’s a start.
But there’s more! (We’re sticking our head through the rabbit hole now. There’s a slight sucking sensation.)
Now, we’ve gotta figure out how to convert this memory over to an ALLEGRO_BITMAP. There’s the palette to consider too.
Ahh! So many things to consider!
That’s how you “git gud,” though, right? These rabbit holes send you all over the place. It’s good practice.
My goal here?
I want a way to compile a Windows version and a DOS version of this game that I’ve been obsessed with making for most of my life. I don’t want to use DOSBox because debugging is way easier with modern tools. I can debug in my comfy modern setup and compile for both platforms and compare.
I’m sure there are tools out there already. But I’m a selfish bastard, narcissistic, maybe, and I hoard my code like a rat hoards insulation. (I’m only joking. I merely like to create my own stuff for the fun of it.) I guess that’s the plan, man.
I guess I’m building my own stripped-down and specific setup version of DOSBox (but without ever looking at that codebase, and never will).
It’s the concept. Small and compact. I love things that are small and stripped down to necessity. There’s so much bloat out there today, it makes me sad.
Allegro 5 could be considered bloaty. But you can compile it down to just the essentials—just enough to handle bitmaps, controls, and sound.
Another rabbit hole? Build your own Allegro library! Or use SDL!
Now that’s too far off track. A project for another time.
Must keep focus.
It’s hard.