Keeping it real for Outline 2018

It’s been a while, but I’m back. Or at least, I hope to have some more time to blog again from now on. And not just to blog, because many of my blogs are the result of experimentations with software and hardware. So I hope to have time to experiment, write new demos, and generally play around with stuff.

First things first though… A backlog of items has accumulated in the past silent months. And it occured to me that I never even wrote a blog about my last demoscene production, which was the invitation for Outline 2018, released at Revision 2018:

Granted, it is not too spectacular… Some graphics, a nice animation, and just a simple text writer with vertical scrolling, accompanied by some OPL3 music. But still, I’d like to describe some of the development behind it.

Music

The music was done by Diode Milliampere in Adlib Tracker II, making fine use of the OPL3 functionality. Getting the music to play was a technical challenge. Adlib Tracker II may be open source, but it is written in Free Pascal. This makes it difficult to interface with other languages such as C and ASM, which I prefer. The code also requires 32-bit DOS or Windows.

Initially I went looking for an alternative player, and I found a routine in C. There were some problems with it though. The code was rather outdated, which meant it was not compatible with the later versions of AT2. One problem was that AT2 switched to a different compression algorithm. I tried porting the Pascal code for the decompressor myself, and eventually got it working.

However, because of the way the format is designed, you need huge buffers to decompress the pattern data, and the format is also extremely wasteful. Storing entire patterns in memory works fine when you use 4-channel mods, with 64 rows per pattern. However, OPL2 is 18 channels, and AT2 supports higher resolution patterns, up to 256 rows each. This means every single pattern takes up about 130k in memory, so things get very memory-hungry fast.

The same goes for the macro feature that the format supports. This has similar memory-hungry buffers. In short, just to decompress an AT2 file, you already needed about 5 MB of memory. So 16-bit was never going to be an option. I tried skipping the macro feature, and using some simple compression scheme for the pattern data (a lot of values tend to be 0 in every row, so you can store it efficiently by just making a linked list of the used data, and skipping the unused rows). It did eventually play some simple files in 16-bit mode, but you quickly ran out of memory still when there was more pattern data.

Another problem is that the replayer logic is also rather time-consuming with all the instrument and effect parameters running over 18 channels. The lower bound for playing AT2 files is more or less a 486SX-25.

So, I figured that it might be better to just go with my own preprocessing VGM player, which is at the other end of the spectrum in terms of CPU and memory usage. I just captured the music with DOSBox, and used the preprocessed capture data in the demo.

Graphics

The graphics effects are rather simple. The main text is just a Mode X screen, where I scroll vertically by just updating the screen offset. I simply draw the next screen of text to the page that is currently invisible.

The other ‘effect’ is the animation at the start. This animation was drawn by visionvortex. He supplied it as a set of PNG files. I simply include all raw pixeldata in the EXE file, and copy the frames to the screen one by one, with the appropriate delay. Nothing fancy.

Final version

The party version was rather quick and dirty, but we wanted to release it at Revision anyway, because its goal was to invite people to the Outline party. It worked, but there was a small bug in the initialization routine for the OPL3 chip, which messed up the music.

Another problem was that the animation had quite a few frames, so it took up a lot of memory. This led to an EXE file of 1.7 mb. It also meant that I had to make it a 32-bit DOS release.

In the final version, both things are fixed. The music now sounds the way Diode Milliampere intended it. And I implemented my own simple Mode X RLE compressor and decompressor for the animation frames. The compression worked incredibly well on this animation, so the resulting EXE is only 87 kb. This meant that I could also make the code 16-bit, and fully 8088-compatible.

Advertisements
This entry was posted in Oldskool/retro programming, Software development and tagged , , , , , , , , , . Bookmark the permalink.

5 Responses to Keeping it real for Outline 2018

  1. nickysn says:

    “Adlib Tracker II may be open source, but it is written in Free Pascal. This means that only 32-bit DOS code is supported.”

    Just for the record, Free Pascal supports 16-bit real mode DOS as well. I know that, because I did the port myself. Here’s the download page on Free Pascal’s official site:

    https://www.freepascal.org/down/i8086/msdos.html

    There are even more improvements for the i8086 code generator in SVN trunk, including an extra memory model (the huge memory model), improvements to the inline asm reader (full support for 32-bit instructions and registers, and lots of segment-related bug fixes and compatibility improvements with TASM and Turbo Pascal 7’s inline asm).

    • Scali says:

      Ah right. Well, in this case it wouldn’t have made a difference, because the memory requirements of the code would never make it work in 16-bit mode anyway.

      • nickysn says:

        That is true – code that was originally written for 32-bit flat model may be hard or impossible to adapt to fit inside a 16-bit segmented memory model and/or within the 640kb conventional memory limit.

        I just wanted to clarify that Free Pascal now supports 16-bit real mode DOS, as it might prove to be useful in a different situation (there’s no other 16-bit real mode compiler for Pascal that I know of that is also open source and actively developed).

      • Scali says:

        Yea, I wasn’t aware of that at the time. The 16-bit support hasn’t been around that long, has it? Anyway, I’ve changed the text a bit to reflect that.

  2. nickysn says:

    It’s relatively new. The i8086 branch was merged into trunk in April 2013, but it took some more time before an official stable release was available. The first stable version that supports i8086-msdos (crosscompiled from Windows or Linux) was FPC 3.0.0, which was released in November 2015. For comparison, 32-bit DOS extender support has been available since the project’s beginning (first release was from 1997, according to Wikipedia, but work on the compiler has been started much earlier, 1993 I think). In fact, the reason Free Pascal was started was because Borland had announced they’re not going to make a 32-bit version of Turbo Pascal for DOS. Since the compiler itself is written in Pascal, the first versions were compiled with Turbo Pascal, so the compiler was a 16-bit .exe, that produced 32-bit code. That was until it reached the point where it could compile itself and became self hosting and support for compilation with Turbo Pascal was dropped.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s