An alternative to composing music is to use algorithmically-generated music. I'm an electronic music composer, but I've found that unexpanded memory is insufficient to store "notes" in most cases. So I use various forms of generative music in my games. Each of my games does it a bit differently, for variety, but the skeleton is based on a decade-old hardware synthesizer module designed by Tom Whitwell* that does this:
Code: Select all
(1) Randomize two 8-bit registers
(2) On a trigger (usually, but not necessarily, controlled by a clock):
(a) Shift both registers left, and set bit 0 of each register to the carry bit of the other register
(b) Potentially reverse the value of bit 0 of the "low register" based on probability
(3) Continuously emit voltage (0-5V) scaled to the value of one of the 8-bit registers
Usually the voltage from (3) is sent to the volt-per-octave input of an oscillator, either directly or via a quantizer for using specific musical modes, and often through an attenuator to limit the notes' range. For the VIC-20, you can either directly set a sound register to the shift register value or (better yet) use the value as an index to a note in a specific game-appropriate musical mode.
The result is a sixteen-step pattern that repeats, but gradually changes based on probability. In game usage, it doesn't need to be probability. And the seed doesn't need to be random; I usually curate registers (after auditioning dozens of results for suitability), and I might flip bits according to specific game events or other rules.
Since arcade game music is typically simple, this type of music player provides a lot of bang for the byte, with my players typically costing 80 bytes or so. Examples of variations on this idea:
* In
TRBo: Turtle Rescue Bot, I used eight curated registers of two bytes each (for sixteen steps per theme). These simply repeat during the level, then the theme changes for the next level.
* In
Trolley Problem, the game starts off with a curated pattern, and then the low bit is flipped each time you pick up a rider. So as the game progresses, the music slowly evolves.
* In
ZEPTOPOLIS, a curated shift register is modified deterministically, to provide several minutes of different music before repetition.
* In
Dungeon of Dance, the register is randomized rather than curated, and is realized as a bass/snare/hi-hat drum beat rather than notes.
These are all games for unexpanded VIC-20. Being the simplest example, you can see the code for
TRBo here, from lines 1179-1234. The curated themes start at 1815. The ISR simply calls NXNOTE each interrupt:
https://github.com/Chysn/VIC20-TRBo/blo ... c/trbo.asm
__________________
*
https://www.musicthing.co.uk/Turing-Machine/