Hi, it’s been another busy week and the finish line for the Supernova2 engine is pretty near. Last time I wrote a post I had 22 out of 71 rooms implemented. Now I have finished implementing all of the rooms and the only thing missing is the outro. The game is playable from start to end, so my work for the next week will at first be, implementing the outro, then a lot of bughunting and once I can’t find any more bugs, preparing to and eventually merge the supernova and supernova2 engines.
Implementing rooms is pretty boring and repetitive task, but still one interesting thing happened. There is a part of the game, where the player is supposed to steal a dinosaur skeleton from a museum. There are pressure sensors, cameras and a security guard wandering around the museum and player has to evade all of that in order to not get caught and not trigger the alarm. The implementation of the alarm sound in the original code is pretty simple, it’s a few rows of assembly using the OUT instruction to send frequencies between 1500 Hz and 1800 Hz and thus make a siren sound. So there isn’t any file containing the sound and because of that it has to be generated. So I tried using the PCSpeaker class which can play tones of given frequency. Using the class I managed to play the sound, but unfortunately between every tone, there was a slight “tick” sound. So the solution was to write my own code to generate a raw sound stream with the siren sound. Should be easy, right? Well, it is, but because I have no experience with sound it took me longer than it should. At first I was pretty surprised that generating a stream that has every byte of the same value produces no sound. Fortunately it was enough to google “raw sound” (which took me a few hours) and then I remembered I actually took course this winter semester which part was about this. So I wrote the code just to end up with the same problem I had when using the PSSpeaker class, a “tick” sound between every tone change. I had to higher the audio rate up to 80000 (a lot for just a siren sound) to get rid of it. But thanks to Criezy’s advice we managed to modify the code so it is able to generate a good enough siren sound even on 44000 audio rate.