v0.4.0 - it has sound
It has sound now.
Sound effects play through Paula directly. There is no software mixer: each
effect is handed to one of the four hardware audio channels and DMA plays it, so
once a sound has started the CPU does nothing more for it. Volume and panning
are the hardware's own registers rather than arithmetic over samples.
The conversion turns out to be nearly free, which is what makes this worth doing
on a 68030 at all. OpenSFX ships at 44.1 kHz 16-bit; Paula wants 8-bit and tops
out around 28.6 kHz on PAL, so the target rate is 22.05 kHz — exactly half.
Resampling is therefore "take every other sample", the depth change is a shift,
and both happen once per effect before it is cached in Chip RAM. Nothing is
computed per sample at playback time.
The price of that approach is four channels: a fifth simultaneous sound is
dropped rather than mixed. In practice it is rarely noticeable, and it buys a
sound system that costs essentially nothing while playing.
Enable with -s amiga (the default), or -s null for silence. Music is not
implemented yet.
Two things worth knowing if you write Amiga audio code
audio.device is one of the devices where you must use BeginIO() rather than
SendIO() or DoIO() — those clear ADIOF_PERVOL, the flag that says "use the
volume and period I just gave you". Without it every write inherits the
channel's previous volume, which after allocation is zero. The device accepts
everything, reports no error, and plays silence. That one cost a full debugging
round.
And Delay(1) does not block for one tick. Measured against the E-clock it
takes 40.98 ms, not the nominal 20. Durations that looked twice too fast
were a measurement artefact; playback had been correct the whole time. Timed
properly, playback matches the computed values within 5%, and the DMA floor is
real — below period ~124 the hardware clamps rather than going faster.
Requirements
Unchanged: 68030 with an FPU minimum, 68040/40 recommended, 68060/50 for full
speed. AGA, 16 MB Fast RAM, AmigaOS 3.0/3.1. An FPU is genuinely required
despite the -msoft-float build — the double-precision routines are stubs into
mathieeedoubbas.library and the stubs themselves execute FPU instructions.
If it runs too slowly, switch to a lores mode in Game Options: a quarter of the
pixels to convert and no interlace.
Still missing: music, networking, and any RTG path.
Installing
Unpack anywhere and run openttd from a Shell, keeping splash.dat beside it.
Nothing from the original Transport Tycoon Deluxe is needed or included —
OpenGFX and OpenSFX are bundled, so it runs as unpacked. See LICENCES.txt for
what is in the archive and under what terms.