MOD files as a sound library with channels in MMBasic

Music and effects running side by side without cutting each other off. The path I took uses PLAY MODSAMPLE and a small set of fixed channels.

Caching array lookups inside hot loops

When the same array index shows up five times per iteration, hoist it into a variable. Small change, real effect for me.

LOCAL costs more than you'd think in MMBasic

Reaching for LOCAL feels like clean programming. Inside hot loops it turned out to be the wrong reflex for me.

CIRCLE per frame costs more than you'd think

Tiny dots, tiny cost, right? Once I profiled it, CIRCLE was one of the most expensive calls per frame. Here's what I did about it.

Rolling your own vector font in MMBasic from DATA

Pixel fonts don't scale cleanly, and they don't fit a vector game visually either. How I built a scalable typeface out of DATA statements.

Rotating vectors in MMBasic without a FOR loop

Rotating each vertex by hand with COS and SIN is the obvious move. MATH V_ROTATE does the same job faster, with no per-point loop.

Initialising arrays in MMBasic without a FOR loop

Setting an entire array to a single value, no loop. MATH SET is the quiet little command I now reach for more often than anything else in the MATH family.

Loading files that are allowed to be missing

On first launch a file may not exist yet, and the program shouldn't crash because of that. ON ERROR SKIP plus MM.ERRNO is the clean way.

STATIC for cooldowns, debouncing, and rate limits in MMBasic

A variable that keeps its value between calls without polluting global state. That's exactly what STATIC inside a sub gives you.

Object pool instead of dynamic allocation in MMBasic

Spawning and freeing shots, particles, and asteroids on demand isn't really a thing in MMBasic. A fixed pool with active flags gets you the same flexibility.