Read Part One if you haven’t. So with a little SDL graphics knowledge under my belt, I decided that I would set out to actually implement the old BGI library using SDL. That is, I wanted to use the same game code for Ten Nights but instead of linking to obsolete Borland libraries that would no longer work in Windows-based system, I wanted to link to my own library that would look the same (from the game’s perspective), yet work in Windows via SDL.

I decided to start by porting another simpler game written by Sinasac (“Caverns of Xaskazien”). The original codebase of “Caverns” was C and clocked in under 5000 lines. Once I set up a C++ project, linked in a stub of the BOSS library, corrected various compiler errors and warnings that were no longer “correct” (the Borland compiler strictness of the early nineties were pretty lax compared to today), the game actually compiled and ran. Then I started filling in the BGI functions that I needed by writing them using C++ and SDL. You can see the early development timeline of BOSS here. I wrote the basic workable BOSS library and ported the “Caverns” code in 5 days and handed the “Caverns” code back to Sinasac two days before my wife gave birth to our two wonderful baby boys. Yes, I know I should have been rubbing her feet that whole time…

Note that I only wrote the BOSS functions that the game needed, no more. My goal in the BOSS library was only for porting the existing games, not for being “feature complete”. I think this was really the start of my newer philosophy on development: Set smaller goals and march towards them, don’t get distracted and don’t try to engineer the ultimate generic solution. This eventually morphed into: Do incremental steps to achieve what you want, while always providing a fully functional app (something akin to the “Small Releases” goal in eXtreme Programming methodology). The focus on delivering builds that are always fully functional keeps my goals smaller and more incremental, but gives me a better chance of actually achieving them, given my limited free time to work on this stuff.

Anyway, the success of the initial stages of BOSS got me working on expanding it to include old-school keyboard handling like getch(), bioskey(), kbhit() and to implement a sound subsystem that originally came out of “The Black Art of Game Programming” (Andre Lemothe). All of it done in SDL with little problems (implementing bioskey() and getch() proved to be the most challenging). With all these things packed into BOSS, it was fairly usable as a “guts replacement” for the old-school C libraries that the games used and it was fairly straightforward to set up “Ten Nights” to use BOSS.

I’m done with Boss now. If someone wants to finish BOSS up, I would open source the project, but I can’t imagine the call for such a thing would be very strong. Borland’s BGI libraries are already more than a decade obsolete.

You see, the usefulness of BOSS is only for porting old applications that relied on these ancient libraries, it is hardly useful for more modern game programming. For that, it makes sense to use SDL directly for both maximum flexibility and speed.

With that in mind, I started out restructuring “Ten Nights” to use SDL directly, moving functionality piece-by-piece to use SDL directly (instead of the BOSS wraparound).

Then…. well, my kids were born… so the pace slowed down quite a bit… (hear the crickets chirping?)

More on SDL development for games in Part Three.

§141 · August 24, 2005 · C++, Games, SDL, Software, Technology · · [Print]

2 Comments to “SDL in Games: Old School”

  1. JLK says:

    Hi Jeff,

    BGI is obsolete (for games anyway), but it is a very easy to use (not event-driven) graphics package that is great for teachers and learners of programming. Examples and lab exercises using simple graphics are much more motivating. Nothing beats BGI for this.

    I am such a teacher, and I use the excellent WinBGIm Windows 32 BGI emulation from the university of Colorado, in my teaching (not portable, but they have published their source).

    Now that I have to move my teaching to Linux, I wish I could use your SDL-based library, but I am very reluctant to commit to a library that is not open source or public domain. I probably would not complete the library, but I want to be able to fix any bug I come across. Access to source saved my skin a few times with WinBGIm.

    Will you consider making boss open source?

  2. JLK,

    Actually I have planned on doing this for a year or more, just never found the time. You have spurred me to action.

    I have just now released the BOSS Library as open source under the GNU General Public License (earlier versions were only under the LGPL). I have put the information here. If you can help in any way, that would be fantastic.