Posted October 12, 2020 by Bob's Stuff
This week has been all about sound. With my ZX81 games I don't need to worry about sound, but for the ZX Spectrum - and especially the 128K hardware with its AY chip - there's no escaping it, Luckily for me, the very nice chap whose been doing the tunes for the PC version of Melkhior's is also going to be doing the 128K AY music. Yay! (You really don't want to leave it to me!)
So at the beginning of the week I managed to get the AY playback engine working in-game using one of its demo tunes. The player we'll be using is the Arkos Tracker 2 (www.julien-nevo.com/arkostracker/) and it was relatively straightforward to implement. The major issue was with not knowing which registers it uses - and so I'm currently preserving all of them, main & alternative - and how much stack space it used. That, coupled with some 128K paging issues, meant that the first run of the game had very uneven music playback and quickly corrupted everything! With those issues fixed I've since had a near-final version of the main-menu tune working, and it sounds wonderful!
With the AY chip doing the tunes, it's down to the good-ole' hardware beeper to do all the SFX. With wanting to keep the 'feel' of Atic Atac as much as possible I've been scanning a disassembly of that game's source code in order to try and reproduce the original effects. The first effect I felt I had to get working was the footsteps - they're so iconic! So I found these in the original code, implemented them in mine, and... it was all wrong! It should be a two-tone effect, but I was getting various tones coming from each foot - and I was stumped for a while as to why this was happening. I isolated the code and ran it separately, and it sounded perfect, but in-game it was still wrong. Finally it dawned on me that an interrupt was often occurring at the exact point as the SFX was being played - and so was distorting the effect. With that in mind I moved the effect into the interrupt handler, and footsteps perfectly echoed around the halls!
Having got both the AY tune and the footstep playing, the game sounds strange - it's no longer quiet, but it's obviously missing a lot of the effects I'm suddenly expecting to hear as I think of playing Atic Atac. I've since added the sound of the doors opening and closing, and objects being picked-up and dropped, and will be moving onto the 'enter room' sound next, then the enemies, weapons etc. There's lots still to do!