After reading my digital copy of Compute's 'Mapping the 64 and 64C', specifically the sections relating to the SID registers, I thought it might be easy to shove some data into said registers and see what happens!
After a bit of fiddling, low and behold, I made noise! It really was as simple as writing a short routine that inserted some previously created values for the waveform type, pitch (note), attack/decay and so forth into their associated registers and then changing those values over a short period of time using another small routine. It did sound a little like Paradroid to start with though!
Next, I inserted these little routines into my Chiller 2 code and called them when certain actions were performed, in this case when the player jumps or when crosses are collected.
It worked!
But... problem...
It seems that, even though I had kept a voice free on SID (in this case voice 3) for the effects, the GoatTracker music driver still writes values to the voice 3 registers, effectively neutering my sound effects. Damn...
After a bit more reading around, it turns out that GoatTracker has a sound effects routine built in. I've read the GoatTracker help file a few times over the years, so how the hell have I ever missed this information about sound effects!?!? So I investigated this and within about 20 minutes, had sound effects playing using this GoatTracker routine!
The process goes a little like this:
When exporting your music file from GoatTracker as a .prg to include in your code (press F9), there is an option to enable the SFX player. Do this and once saved the SFX module is now part of the overall music file. This does add about 150 bytes to the overall file size.
You then create your SFX exactly the same way as creating instruments in GoatTracker. These instruments are then saved from within GoatTracker. The instrument file is then converted to a sound effect using a tool bundled with GoatTracker called 'ins2snd2.exe', which gives you a text file with the associated hex data for the sound. There are a couple of rules to follow for the tool to be able to convert the instruments to effects, but you'll have to read the GoatTracker help file yourself for those!
Currently, the data for my jump and collect SFX look a little like this...
; sfx data (lower the sfx data, the higher play priority it has)
sfx_jump
!byte $38,$F6,$04,$A0,$21,$A0,$A0,$A6,$A6,$A6,$20,$A9,$A9,$A9,$A2,$A2
!byte $A2,$A6,$A6,$A6,$A9,$A9,$A9,$A2,$A2,$A2,$A6,$A6,$A6,$A9,$A9,$A9
!byte $A2,$A2,$A2,$A6,$A6,$A6,$A9,$A9,$A9,$00
sfx_collect
!byte $00,$89,$04,$A2,$41,$A2,$A2,$A6,$A6,$A6,$40,$A9,$A9,$A9,$A2,$A2
!byte $A2,$A6,$A6,$A6,$A9,$A9,$A9,$A2,$A2,$A2,$A6,$A6,$A6,$A9,$A9,$A9
!byte $A2,$A2,$A2,$A6,$A6,$A6,$A9,$A9,$A9,$00
To play the effect, you then insert a small simple piece of code that is triggered when, for example, the player jumps or collects a cross. Something like this...
lda #<sfx_jump ; start address of the effect
ldy #>sfx_jump
ldx #$0e ; 0, 7 or 14 for channels 1-3 (channel 3 use here, or $0e)
jsr music+$06 ; music = memory location where music is stored in memory
; sfx player is at +$06!
So Chiller 2 finally has some sound effects! I've purposefully kept the sounds quite low in the 'mix' (quiet) currently, since both the jump and collect will be played quite frequently and I don't want to annoy the game player!
Sound effects... TICK!
Next diary entry...
