Coding Tricks Used in the C64 Game Seawolves

9 Exotic Coding Tricks used in the C64 Game, Seawolves 9 Exotic Coding Tricks used in the C64 Game, Seawolves Updated on: 15th July 2025 Introduction 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. 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. Let’s check them out in turn. #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. 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

Source: Hacker News | Original Link