Before I given the
whole Rules of Engagement project, I was given a few code files at
first to gauge the feasibility of porting this old game to modern
architectures. This consisted of a section of the graphics library
and a bit of the tactical display code. The idea was that I needed to
gauge if the game was too tied to legacy libraries or some kind of
paradigm what would be simply unworkable in modern systems. I also
was keen to see if I could forge it into some kind of POSIX
compliance to make it a little more targetable to other platforms.
The idea is that I plan to use a C game library named “Allegro”
that I’ve been using on and off since the 90s for little game
projects of mine. It’s in it’s 5th iteration now and still
maintains much of it’s legacy DOS concepts but adapted to a little
more modern and platform neutral. Many of the old DOS/Real Mode
interrupt calls have been replaced with legitimate functions, but are
still single-fire methods with striking similarity. This makes sense
because when Allegro was young, it wrapped it’s library functions
around basic DOS calls such as INT 21h(filesystem), INT 33h(mouse),
and INT 10h(video).
Still seeing some of
the old library headers in the ROE was kind of a nostalgic walk down
memory lane. It was also quite pleasant to see that many of them can
be tossed as modern systems handle the more low-level stuff
automatically, or there is a simple POSIX equivalent. Here is a quick
copy/paste from the graphics lib.
#include
"stdio.h" <-- POSIX
#include
"stdlib.h" <-- POSIX
#include "dos.h" <--
Delays and sound are Allegro - Time Functions are POSIX
#include
"time.h" <-- POSIX
#include
"malloc.h" <-- Allegro has malloc wrappers so that it’s
platform independent
#include
"graph.h" <-- Allegro handles low-level graphics
#include
"string.h" <-- POSIX
#include
"conio.h" <-- Text I/O interrupt wrappers - Allegro
handles this now
#include
"bios.h" <-- No need to make BIOS calls anymore –
Allegro has equivalents
#include "xmm.h" <--
We use a Protected mode flat memory model now. No need for XMM
#include
"rules.h" <-- This in turn has direct.h, this can
be replaced with unistd.h (POSIX)
Real mode interrupt
calls do not function in protected mode, and is DOS legacy anyway.
The other thing that will make live much easier is that ROE can be a
monolithic executable. For space reasons, the game was broken up into
pieces called “overlays” would block swap parts of itself into
memory from disk while it was running. Nowadays we have virtual
memory and shared runtime libraries (.dll /.so files) that manged by
the OS.
This caught my eye
too…
#define DPI 6.283185308
This can now be defined as TAU and hopefully won’t break much :)
One final though as
that Allegro handles bitmaps in a device independent way so gone are
the legacy bitplanes of CGA/EGA/VGA of old. Also mp3s and GIF files
are out of patent.
No comments:
Post a Comment