Tools: New Coding Tricks Used In The C64 Game Seawolves 2026

Tools: New Coding Tricks Used In The C64 Game Seawolves 2026

With the release of my first ever commercial game on the Commodore 64, Seawolves, I thought it might be of interest to the coders among you as to how the game was constructed. From the outset, brace yourself to read about some "code less travelled", as the game required several strange or quirky methods that are perhaps more associated with the madness that goes in the demo scene.

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:

If the foregoing sounds horrendous and esoteric, I can only apologise for making it thus through poor explanation skills, but really, it boils down to giving the developer a more coder-friendly way of slicing the screen up into horizontal layers that collectively form a useful game environment. NMIs are timer interrupts, meaning that unlike IRQs, they can't be triggered by $D012 on the VIC-II chip, but instead are controlled by either of the two timers on CIA chip #2 (likewise, timer IRQs can be set up using either of the 2 timers on CIA #1). The timers hold the number of cycles between each NMI instance in the form of a lo-byte, hi-byte 16-bit number stored in $DD04 + $DD05 (for timer A) or $DD06 + $DD07 (for timer B). Those cycle counts are referred to, unhelpfully, in the Commodore 64 Programmer's Reference Guide as "frequencies". Critical to setting up NMIs is a consistent start cycle on the same scanline each time the game is initiated. Like IRQs, NMIs can stall too, but the effect is different; whereas an IRST stall consists of a fleeting collapse in the IRQ schema, an NMI stall event looks more like a regrouping of all NMIs in the chain down-screen from their proper position and is caused either by (a) unanticipated cycle steal caused by the presence of sprites, which take priority over NMIs every bit as much as they do over IRQs, and (b) an NMI handler not completing its tasks before the next NMI is scheduled to fire. You really have to use a spreadsheet to calculate the timer 16-bit number for each NMI instance, which is the only very awkward aspect of using them. For more, see my in-depth guide to setting up NMIs.

The torpedoes are, fundamentally, sprites... but not in the usual sense.

Source: HackerNews