diff options
author | B. Watson <yalhcru@gmail.com> | 2016-01-07 04:55:59 -0500 |
---|---|---|
committer | B. Watson <yalhcru@gmail.com> | 2016-01-07 04:55:59 -0500 |
commit | 3d7d8a9b549f1b6445858f78012b4c55609e1335 (patch) | |
tree | 11406bc12cae0ee6169754fd442eb28e6acff663 /sounds.c | |
parent | 23fd09c5c464505c7c9ceb801fceb907446cd1ab (diff) | |
download | taipan-3d7d8a9b549f1b6445858f78012b4c55609e1335.tar.gz |
first pass at sounds
Diffstat (limited to 'sounds.c')
-rw-r--r-- | sounds.c | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/sounds.c b/sounds.c new file mode 100644 index 0000000..aee7319 --- /dev/null +++ b/sounds.c @@ -0,0 +1,97 @@ +/* Sounds for Taipan! Atari 800 port. + + Made by capturing the Apple II audio and taking wild guesses, + then refining them. + + I'm not shooting for Atari sounds that are identical to the + Apple ones: (a) it's impossible anyway, and (b) the Apple + sounds are a bit harsh to the ear. Hopefully these sound + a little smoother while still being pretty close. +*/ + +#include <atari.h> +#include <peekpoke.h> + +/* to build standalone xex that just plays the 3 sounds: + cl65 -DTESTXEX -t atari -o sounds.xex sounds.c +*/ +#ifdef TESTXEX +#include <stdio.h> + +void jsleep(unsigned int j) { + POKE(20,0); + while(PEEK(20) < j) + ; +} +#else +extern void __fastcall__ jsleep(unsigned int j); +#endif + +void init_sound(void) { + /* init POKEY audio */ + POKEY_WRITE.audctl = 0; + POKEY_WRITE.skctl = 3; + POKEY_WRITE.audc1 = 0xaa; /* SOUND 0,x,10,10 */ +} + +void stop_sound(void) { + POKEY_WRITE.audc1 = 0x00; /* SOUND 0,x,0,0 */ +} + +void bad_joss_sound() { + unsigned char i; + + init_sound(); + for(i=0; i<10; i++) { + POKEY_WRITE.audf1 = 80-i*8; + jsleep(1); + } + stop_sound(); +} + +void good_joss_sound() { + unsigned char i, j; + + init_sound(); + for(j=0; j<3; j++) { + for(i=0; i<4; i++) { + POKEY_WRITE.audf1 = 20-i*5; + jsleep(2); + } + } + stop_sound(); +} + +void under_attack_sound() { + unsigned char i, j; + + init_sound(); + for(j=0; j<3; j++) { + for(i=0; i<3; i++) { + POKEY_WRITE.audf1 = 20-i*3; + jsleep(3); + } + } + stop_sound(); +} + +#ifdef TESTXEX +int main(void) { + for(;;) { + puts("Bad joss, Taipan!"); + bad_joss_sound(); + jsleep(30); + + puts("Good joss, Taipan!"); + good_joss_sound(); + jsleep(30); + + puts("1.0E+97 hostile ships approaching, Taipan!"); + under_attack_sound(); + jsleep(30); + } + +hang: goto hang; + return 0; +} +#endif |