Skip to content
Thomas Thurman edited this page May 29, 2013 · 3 revisions

AVX is a DOS-specific memory-saving hack which should not be replicated when Avalot is ported. It is described here for interest and to help you understand existing code.

Avalot was allowed to use only 640K of RAM, as was standard with DOS, so memory was tight. We also needed to:

  • allow the user to "shell out", i.e. to invoke a new instance of COMMAND.COM while keeping Avalot in memory. The trouble was that even if a new COMMAND.COM would fit over the top of Avalot, there wouldn't be much memory left to do anything useful with it.
  • run various cut scenes.

The solution was AVX. All the cut scenes, and the main game itself, were compiled to EXE files and then renamed to have an .avx extension. The main game itself is AVALOT9.AVX, not AVALOT.EXE. The "AVALOT.EXE" which is first invoked when you play the game is in fact compiled from bootstrp.pas.

When it's run, this compiled version of Bootstrp does the following:

  • It allocates a block of memory (which is sometimes known as Sundry). DOS user interrupt 0x1C is then hooked and pointed at Sundry. (Sundry is also used for B Flight, but Bootstrp is only used for this in production.) Now that the interrupt is pointed at Sundry, it can also be read and written by the programs Bootstrp invokes.
  • Bootstrp then invokes AVALOT9.AVX to play the main game.
  • When AVALOT9.AVX exits, it checks the errorlevel (the exit code). If this is not 77, we assume it exited due to an error, so we also exit. If it is 77, we carry on.
  • We check the operation byte inside Sundry, which was set by the program we just invoked. This tells us what to invoke next: a cut scene, AVALOT9.AVX again, or COMMAND.COM. It can also tell us that we ourselves should exit. If not, we check the operation byte again, and so on. (After we run COMMAND.COM, though, we assume we're going back to AVALOT9.AVX, since COMMAND.COM doesn't know how to set the operation byte.)

While any program other than AVALOT9.AVX is executing, AVALOT9.AVX will have stored the state of the game in the block reserved for this at the end of Sundry, so that it can reload it seamlessly when the other program exits.

All AVXs, and the compiled version of Bootstrp itself, were compressed with Fabrice Bellard's LZEXE before shipping.

Clone this wiki locally