From 3d7d8a9b549f1b6445858f78012b4c55609e1335 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Thu, 7 Jan 2016 04:55:59 -0500 Subject: first pass at sounds --- sounds.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 sounds.c (limited to 'sounds.c') 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 +#include + +/* to build standalone xex that just plays the 3 sounds: + cl65 -DTESTXEX -t atari -o sounds.xex sounds.c +*/ +#ifdef TESTXEX +#include + +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 -- cgit v1.2.3