Coding Tricks Used in the C64 Game Seawolves (2025)
Updated on:
Introduction
NMIs + IRQs running in sync.
Real-time torpedoes thanks to "splites".
Real-time implosion animations.
Real-time ocean waves.
Real-time water distortion effects.
FLD shift + upward correction.
GFX stream-ins.
Quick logic.
Branch-jumping.
#1: NMIs + IRQs Running in Synchronisation
I first combined NMIs and IRQs inside a game environment in
Parallaxian and again in
The Wild Wood, to great effect, because it offers the following benefits:
You can easily interrupt long tasks in a raster IRQ (IRST) with the NMI to perform short scanline-exact tasks without the need for nesting IRQs;
it's simpler and more elegant.
It can be used as a safety net to minimise the effects of raster stall events, in which freak load conditions on an IRQ (say a 1 in 1000 alignment of circumstances)
would cause the IRQ schema to stall / collapse for a screen refresh frame before recovering. In this case, the final NMI handler, rather than the last IRQ handler,
sets the IRQ pointers / vectors for the top-of-the-screen IRQ. This way, if (for example), IRQ handler #3 out of 7 IRQ handlers stalls, the contagion only spread to
the bottom of the screen before normal service is resumed at the top during the next frame. Otherwise, the stall effects would not recover until the next time IRQ
handler #3 fires.
NMIs, being timer interrupts, can be set up to trigger at pretty much any cycle along a scanline, making them more efficient in terms of managing raster time than
IRSTs are; typically with a raster IRQ, you will have to carefully place NOPs or otherwise juggle code before changing a register (e.g. changing background colour)
and that's after you have lost time In stabilising the IRST, whereas with NMIs, you have better control over where on the desired scanline they fire.
#2: Real-Time Torpedoes thanks to "Splites"
The torpedoes are, fundamentally, sprites... but not in the usual sense.
#3: Real-Time Implosion Animations
When a player submarine dies, instead of a clichéd explosion I thought it might be interesting to have it disintegrate under pressure.