aboutsummaryrefslogtreecommitdiff
path: root/sounds.c
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-01-07 07:21:35 -0500
committerB. Watson <yalhcru@gmail.com>2016-01-07 07:21:35 -0500
commitebbc4a225ba2ecf3b7d54510884976c4e7a961cc (patch)
tree0bf55b2c33a5204f2db5628db472e651799bc4a0 /sounds.c
parent2ae2b1397ec74e6535f5a5b5b0be8f0d0d4f4965 (diff)
downloadtaipan-ebbc4a225ba2ecf3b7d54510884976c4e7a961cc.tar.gz
silly explosion noises, enable/disable sound from title screen
Diffstat (limited to 'sounds.c')
-rw-r--r--sounds.c65
1 files changed, 57 insertions, 8 deletions
diff --git a/sounds.c b/sounds.c
index aee7319..de6ea83 100644
--- a/sounds.c
+++ b/sounds.c
@@ -11,6 +11,9 @@
#include <atari.h>
#include <peekpoke.h>
+#include "sounds.h"
+
+int sound_disabled = 0x06ff;
/* to build standalone xex that just plays the 3 sounds:
cl65 -DTESTXEX -t atari -o sounds.xex sounds.c
@@ -27,21 +30,23 @@ void jsleep(unsigned int j) {
extern void __fastcall__ jsleep(unsigned int j);
#endif
-void init_sound(void) {
+void init_sound(unsigned char audc1) {
+ if(PEEK(sound_disabled)) return;
+
/* init POKEY audio */
POKEY_WRITE.audctl = 0;
POKEY_WRITE.skctl = 3;
- POKEY_WRITE.audc1 = 0xaa; /* SOUND 0,x,10,10 */
+ POKEY_WRITE.audc1 = audc1; /* SOUND 0,x,audc1>>4,audc1&0x0f */
}
void stop_sound(void) {
POKEY_WRITE.audc1 = 0x00; /* SOUND 0,x,0,0 */
}
-void bad_joss_sound() {
+void bad_joss_sound(void) {
unsigned char i;
- init_sound();
+ init_sound(0xaa);
for(i=0; i<10; i++) {
POKEY_WRITE.audf1 = 80-i*8;
jsleep(1);
@@ -49,10 +54,10 @@ void bad_joss_sound() {
stop_sound();
}
-void good_joss_sound() {
+void good_joss_sound(void) {
unsigned char i, j;
- init_sound();
+ init_sound(0xaa);
for(j=0; j<3; j++) {
for(i=0; i<4; i++) {
POKEY_WRITE.audf1 = 20-i*5;
@@ -62,10 +67,10 @@ void good_joss_sound() {
stop_sound();
}
-void under_attack_sound() {
+void under_attack_sound(void) {
unsigned char i, j;
- init_sound();
+ init_sound(0xaa);
for(j=0; j<3; j++) {
for(i=0; i<3; i++) {
POKEY_WRITE.audf1 = 20-i*3;
@@ -75,9 +80,44 @@ void under_attack_sound() {
stop_sound();
}
+void cannon_sound(void) {
+ unsigned char i;
+
+ init_sound(0xaa);
+ for(i = 20; i < 40; i += 1) {
+ POKEY_WRITE.audf1 = i;
+ jsleep(1);
+ }
+
+ init_sound(0x8a);
+ POKEY_WRITE.audf1 = 120;
+ for(i = 15; i > 3; i--) {
+ POKEY_WRITE.audc1 = 0x80 | i;
+ jsleep(3);
+ }
+
+ stop_sound();
+}
+
+/* this isn't a very good explosion yet */
+void weve_been_hit_sound(void) {
+ unsigned char i;
+
+ init_sound(0x8a);
+ POKEY_WRITE.audf1 = 200;
+ for(i = 15; i > 3; i--) {
+ POKEY_WRITE.audc1 = 0x80 | i;
+ POKEY_WRITE.audf1 = 200-i*2;
+ jsleep(4);
+ }
+
+ stop_sound();
+}
+
#ifdef TESTXEX
int main(void) {
for(;;) {
+ /*
puts("Bad joss, Taipan!");
bad_joss_sound();
jsleep(30);
@@ -89,6 +129,15 @@ int main(void) {
puts("1.0E+97 hostile ships approaching, Taipan!");
under_attack_sound();
jsleep(30);
+ */
+
+ puts("We're firing on them!");
+ cannon_sound();
+ jsleep(30);
+
+ puts("We've been hit!");
+ weve_been_hit_sound();
+ jsleep(30);
}
hang: goto hang;