From f9024d132a33ffb62257fbb2bb84b63436eb8996 Mon Sep 17 00:00:00 2001 From: Mariano Dominguez Date: Thu, 5 Jan 2023 21:12:58 -0800 Subject: [PATCH 01/16] add sound command this behives the same as BASIC sound(voice, pitch, distortion, volume) --- include/atari.h | 6 ++++++ libsrc/atari/sound.s | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 libsrc/atari/sound.s diff --git a/include/atari.h b/include/atari.h index deae8fdf5..e31463991 100644 --- a/include/atari.h +++ b/include/atari.h @@ -235,6 +235,12 @@ extern void __fastcall__ _scroll (signed char numlines); /* numlines < 0 scrolls down */ +/*****************************************************************************/ +/* Sound function */ +/*****************************************************************************/ + +extern void __fastcall__ sound (unsigned char voice, unsigned char frequency, unsigned char distortion, unsigned char volume); /* plays a sound in the specidied voice, to silence call with in other params*/ + /*****************************************************************************/ /* Misc. functions */ /*****************************************************************************/ diff --git a/libsrc/atari/sound.s b/libsrc/atari/sound.s new file mode 100644 index 000000000..53cb717ff --- /dev/null +++ b/libsrc/atari/sound.s @@ -0,0 +1,43 @@ +; +; Mariano Domínguez +; 2022-12-4 +; +; atari lib +; + .include "atari.inc" + + .export _sound + .import popa +; play sound, arguments: voice, pitch, distortion, volume. same as BASIC +.proc _sound + sta STORE2 ;save volume + jsr popa ;get distortion + sta STORE1 ;save distortion + jsr popa ;get pitch + pha ;save in stack + jsr popa ;get voice + + asl a ;adjust voice *2 for offset in x + tax + pla ;get pitch from stack + sta AUDF1,x ; store pitch + + lda #0 + sta AUDCTL + lda #3 + stx SKCTL ; init sound + + lda STORE1 ;get distortion + asl a ;ignore the high nibble + asl a + asl a + asl a + clc ; setup for adding volume + adc STORE2 ; add volume + sta AUDC1,x ; volume + distortion in control channel + rts +.endproc +; reserve 2 bytes for temp storage + .bss +STORE1: .res 1 +STORE2: .res 1 \ No newline at end of file From fa05294054a441be49d247d1a72a9cf53d2de9d6 Mon Sep 17 00:00:00 2001 From: Mariano Dominguez Date: Thu, 5 Jan 2023 21:16:58 -0800 Subject: [PATCH 02/16] add newline for style --- libsrc/atari/sound.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/atari/sound.s b/libsrc/atari/sound.s index 53cb717ff..94b7a2d8a 100644 --- a/libsrc/atari/sound.s +++ b/libsrc/atari/sound.s @@ -40,4 +40,4 @@ ; reserve 2 bytes for temp storage .bss STORE1: .res 1 -STORE2: .res 1 \ No newline at end of file +STORE2: .res 1 From 30df733c3156893e8f3b113718ed393750cb8daa Mon Sep 17 00:00:00 2001 From: Mariano Dominguez Date: Thu, 5 Jan 2023 21:20:16 -0800 Subject: [PATCH 03/16] remove dangling spaces --- libsrc/atari/sound.s | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/libsrc/atari/sound.s b/libsrc/atari/sound.s index 94b7a2d8a..eb90662ad 100644 --- a/libsrc/atari/sound.s +++ b/libsrc/atari/sound.s @@ -5,7 +5,6 @@ ; atari lib ; .include "atari.inc" - .export _sound .import popa ; play sound, arguments: voice, pitch, distortion, volume. same as BASIC @@ -15,18 +14,15 @@ sta STORE1 ;save distortion jsr popa ;get pitch pha ;save in stack - jsr popa ;get voice - - asl a ;adjust voice *2 for offset in x + jsr popa ;get voice + asl a ;adjust voice *2 for offset in x tax - pla ;get pitch from stack - sta AUDF1,x ; store pitch - + pla ;get pitch from stack + sta AUDF1,x ; store pitch lda #0 sta AUDCTL lda #3 - stx SKCTL ; init sound - + stx SKCTL ;init sound lda STORE1 ;get distortion asl a ;ignore the high nibble asl a From 29a80065cca2e36639d773f773ddf799f5808969 Mon Sep 17 00:00:00 2001 From: Mariano Dominguez Date: Thu, 5 Jan 2023 21:27:54 -0800 Subject: [PATCH 04/16] fix tab indentation --- libsrc/atari/sound.s | 52 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/libsrc/atari/sound.s b/libsrc/atari/sound.s index eb90662ad..756d0e02d 100644 --- a/libsrc/atari/sound.s +++ b/libsrc/atari/sound.s @@ -9,31 +9,31 @@ .import popa ; play sound, arguments: voice, pitch, distortion, volume. same as BASIC .proc _sound - sta STORE2 ;save volume - jsr popa ;get distortion - sta STORE1 ;save distortion - jsr popa ;get pitch - pha ;save in stack - jsr popa ;get voice - asl a ;adjust voice *2 for offset in x - tax - pla ;get pitch from stack - sta AUDF1,x ; store pitch - lda #0 - sta AUDCTL - lda #3 - stx SKCTL ;init sound - lda STORE1 ;get distortion - asl a ;ignore the high nibble - asl a - asl a - asl a - clc ; setup for adding volume - adc STORE2 ; add volume - sta AUDC1,x ; volume + distortion in control channel - rts + sta STORE2 ;save volume + jsr popa ;get distortion + sta STORE1 ;save distortion + jsr popa ;get pitch + pha ;save in stack + jsr popa ;get voice + asl a ;adjust voice *2 for offset in x + tax + pla ;get pitch from stack + sta AUDF1,x ;store pitch + lda #0 + sta AUDCTL + lda #3 + stx SKCTL ;init sound + lda STORE1 ;get distortion + asl a ;ignore the high nibble + asl a + asl a + asl a + clc ;setup for adding volume + adc STORE2 ;add volume + sta AUDC1,x ;volume + distortion in control channel + rts .endproc -; reserve 2 bytes for temp storage + ;reserve 2 bytes for temp storage .bss -STORE1: .res 1 -STORE2: .res 1 +STORE1: .res 1 +STORE2: .res 1 From 4e8b18c035775344519fde47b2571027abe2944c Mon Sep 17 00:00:00 2001 From: Mariano Dominguez Date: Thu, 5 Jan 2023 21:29:33 -0800 Subject: [PATCH 05/16] missing tab --- libsrc/atari/sound.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/atari/sound.s b/libsrc/atari/sound.s index 756d0e02d..880af3ee7 100644 --- a/libsrc/atari/sound.s +++ b/libsrc/atari/sound.s @@ -34,6 +34,6 @@ rts .endproc ;reserve 2 bytes for temp storage - .bss + .bss STORE1: .res 1 STORE2: .res 1 From 85f657b35e2c141ebccc1d99445c4f2ca4a50e56 Mon Sep 17 00:00:00 2001 From: Mariano Dominguez Date: Thu, 5 Jan 2023 21:30:31 -0800 Subject: [PATCH 06/16] missing space --- libsrc/atari/sound.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/atari/sound.s b/libsrc/atari/sound.s index 880af3ee7..0fc1dad07 100644 --- a/libsrc/atari/sound.s +++ b/libsrc/atari/sound.s @@ -16,7 +16,7 @@ pha ;save in stack jsr popa ;get voice asl a ;adjust voice *2 for offset in x - tax + tax pla ;get pitch from stack sta AUDF1,x ;store pitch lda #0 From 658c1ad71195e7cfd5544dabfa2dc7408454f30b Mon Sep 17 00:00:00 2001 From: Mariano Dominguez Date: Thu, 5 Jan 2023 21:33:40 -0800 Subject: [PATCH 07/16] only missing space --- libsrc/atari/sound.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/atari/sound.s b/libsrc/atari/sound.s index 0fc1dad07..90fed6f70 100644 --- a/libsrc/atari/sound.s +++ b/libsrc/atari/sound.s @@ -8,7 +8,7 @@ .export _sound .import popa ; play sound, arguments: voice, pitch, distortion, volume. same as BASIC -.proc _sound +.proc _sound sta STORE2 ;save volume jsr popa ;get distortion sta STORE1 ;save distortion From 8c97b54f5d5391322692436bb854913bbf02c957 Mon Sep 17 00:00:00 2001 From: Mariano Dominguez Date: Thu, 5 Jan 2023 21:34:43 -0800 Subject: [PATCH 08/16] more trailing spaces :( --- libsrc/atari/sound.s | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libsrc/atari/sound.s b/libsrc/atari/sound.s index 90fed6f70..80f89a0c4 100644 --- a/libsrc/atari/sound.s +++ b/libsrc/atari/sound.s @@ -25,8 +25,8 @@ stx SKCTL ;init sound lda STORE1 ;get distortion asl a ;ignore the high nibble - asl a - asl a + asl a + asl a asl a clc ;setup for adding volume adc STORE2 ;add volume From c3e1ae3478bc848a9ab16219aee4e8fd1c9d3424 Mon Sep 17 00:00:00 2001 From: Mariano Dominguez Date: Thu, 5 Jan 2023 21:36:44 -0800 Subject: [PATCH 09/16] last trailing space --- libsrc/atari/sound.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/atari/sound.s b/libsrc/atari/sound.s index 80f89a0c4..9b0984ad7 100644 --- a/libsrc/atari/sound.s +++ b/libsrc/atari/sound.s @@ -28,7 +28,7 @@ asl a asl a asl a - clc ;setup for adding volume + clc ;setup for adding volume adc STORE2 ;add volume sta AUDC1,x ;volume + distortion in control channel rts From 2a961a870b2486bf1a4edd2eb4e00faf57fe1064 Mon Sep 17 00:00:00 2001 From: Mariano Dominguez Date: Fri, 6 Jan 2023 09:56:15 -0800 Subject: [PATCH 10/16] add target test --- targettest/atari/Makefile | 5 ++++- targettest/atari/sound.c | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 targettest/atari/sound.c diff --git a/targettest/atari/Makefile b/targettest/atari/Makefile index dd4f6078f..d5b4d9593 100644 --- a/targettest/atari/Makefile +++ b/targettest/atari/Makefile @@ -39,6 +39,7 @@ EXELIST_atari = \ multi.xex \ ostype.xex \ scrcode.com \ + sound.xex \ sys.xex ifneq ($(EXELIST_$(SYS)),) @@ -74,7 +75,8 @@ scrcode.com: scrcode.s $(CL) -t atari -C atari-asm.cfg -o scrcode.com scrcode.s sys.xex: sys.c $(CL) -t atari -o sys.xex sys.c - +sound.xex: sound.c + $(CL) -t atari -o sound.xex sound.c clean: @$(DEL) charmapping.xex 2>$(NULLDEV) @$(DEL) defdev.xex 2>$(NULLDEV) @@ -85,3 +87,4 @@ clean: @$(DEL) scrcode.o 2>$(NULLDEV) @$(DEL) scrcode.com 2>$(NULLDEV) @$(DEL) sys.xex 2>$(NULLDEV) + @$(DEL) sound.xex 2>$(NULLDEV) diff --git a/targettest/atari/sound.c b/targettest/atari/sound.c new file mode 100644 index 000000000..e0cec7f3b --- /dev/null +++ b/targettest/atari/sound.c @@ -0,0 +1,20 @@ +/* +** testprogram printing the default device +** +** January 6 2023 Mariano Domínguez +*/ + +#include +#include +#include +#include + +int main(void) +{ + int i=0; + printf("playing sound \n"); + sound(1,121,10,15); + for(i=0;i<90;i++); + sound(1,0,0,0); + return 0; +} From 196962adac43b17a4df99da6f27bc801ae0e2fa7 Mon Sep 17 00:00:00 2001 From: Mariano Dominguez Date: Fri, 6 Jan 2023 10:54:16 -0800 Subject: [PATCH 11/16] remove lasy pesky space --- libsrc/atari/sound.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/atari/sound.s b/libsrc/atari/sound.s index 9b0984ad7..95431bbb4 100644 --- a/libsrc/atari/sound.s +++ b/libsrc/atari/sound.s @@ -11,7 +11,7 @@ .proc _sound sta STORE2 ;save volume jsr popa ;get distortion - sta STORE1 ;save distortion + sta STORE1 ;save distortion jsr popa ;get pitch pha ;save in stack jsr popa ;get voice From bf9fb6dcdb3717abb25dbd0dad6935f5a6d0e30d Mon Sep 17 00:00:00 2001 From: Mariano Dominguez Date: Fri, 6 Jan 2023 11:23:33 -0800 Subject: [PATCH 12/16] increase delay in sound test --- targettest/atari/sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targettest/atari/sound.c b/targettest/atari/sound.c index e0cec7f3b..66d0ee3e3 100644 --- a/targettest/atari/sound.c +++ b/targettest/atari/sound.c @@ -14,7 +14,7 @@ int main(void) int i=0; printf("playing sound \n"); sound(1,121,10,15); - for(i=0;i<90;i++); + for(i=0;i<9000;i++); sound(1,0,0,0); return 0; } From 27ecb555eab378f9c7aacabd5d1a302a042becca Mon Sep 17 00:00:00 2001 From: Mariano Dominguez Date: Tue, 10 Jan 2023 11:16:36 -0800 Subject: [PATCH 13/16] Rename sound to _sound. remove extra comments. --- include/atari.h | 2 +- libsrc/atari/sound.s | 4 ++-- targettest/atari/sound.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/atari.h b/include/atari.h index e31463991..08b671ff4 100644 --- a/include/atari.h +++ b/include/atari.h @@ -239,7 +239,7 @@ extern void __fastcall__ _scroll (signed char numlines); /* Sound function */ /*****************************************************************************/ -extern void __fastcall__ sound (unsigned char voice, unsigned char frequency, unsigned char distortion, unsigned char volume); /* plays a sound in the specidied voice, to silence call with in other params*/ +extern void __fastcall__ _sound (unsigned char voice, unsigned char frequency, unsigned char distortion, unsigned char volume); /*****************************************************************************/ /* Misc. functions */ diff --git a/libsrc/atari/sound.s b/libsrc/atari/sound.s index 95431bbb4..a8b712770 100644 --- a/libsrc/atari/sound.s +++ b/libsrc/atari/sound.s @@ -5,10 +5,10 @@ ; atari lib ; .include "atari.inc" - .export _sound + .export __sound .import popa ; play sound, arguments: voice, pitch, distortion, volume. same as BASIC -.proc _sound +.proc __sound sta STORE2 ;save volume jsr popa ;get distortion sta STORE1 ;save distortion diff --git a/targettest/atari/sound.c b/targettest/atari/sound.c index 66d0ee3e3..d1c50e1b4 100644 --- a/targettest/atari/sound.c +++ b/targettest/atari/sound.c @@ -1,5 +1,5 @@ /* -** testprogram printing the default device +** Test program for _sound for atari ** ** January 6 2023 Mariano Domínguez */ @@ -13,8 +13,8 @@ int main(void) { int i=0; printf("playing sound \n"); - sound(1,121,10,15); + _sound(1,121,10,15); //voice, pitch, distortion, volume for(i=0;i<9000;i++); - sound(1,0,0,0); + _sound(1,0,0,0); //silencing, same as Atari Basic return 0; } From 42c39c6bfcdc111b927c0f82895f11071e0ed6d0 Mon Sep 17 00:00:00 2001 From: Mariano Dominguez Date: Tue, 10 Jan 2023 11:26:12 -0800 Subject: [PATCH 14/16] remove trailing spacew, use correct user --- include/atari.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/atari.h b/include/atari.h index 08b671ff4..04cacab33 100644 --- a/include/atari.h +++ b/include/atari.h @@ -239,7 +239,7 @@ extern void __fastcall__ _scroll (signed char numlines); /* Sound function */ /*****************************************************************************/ -extern void __fastcall__ _sound (unsigned char voice, unsigned char frequency, unsigned char distortion, unsigned char volume); +extern void __fastcall__ _sound (unsigned char voice, unsigned char frequency, unsigned char distortion, unsigned char volume); /*****************************************************************************/ /* Misc. functions */ From 6236e828504bde60b0206fe6e710dfa34bcd7feb Mon Sep 17 00:00:00 2001 From: Mariano Dominguez Date: Sun, 15 Jan 2023 17:00:05 -0800 Subject: [PATCH 15/16] change storage to pager zero fix bug that kills keyboard. --- libsrc/atari/sound.s | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/libsrc/atari/sound.s b/libsrc/atari/sound.s index a8b712770..746ebc2bb 100644 --- a/libsrc/atari/sound.s +++ b/libsrc/atari/sound.s @@ -7,11 +7,13 @@ .include "atari.inc" .export __sound .import popa + .importzp tmp1,tmp2 + ; play sound, arguments: voice, pitch, distortion, volume. same as BASIC .proc __sound - sta STORE2 ;save volume + sta tmp2 ;save volume jsr popa ;get distortion - sta STORE1 ;save distortion + sta tmp1 ;save distortion jsr popa ;get pitch pha ;save in stack jsr popa ;get voice @@ -22,18 +24,14 @@ lda #0 sta AUDCTL lda #3 - stx SKCTL ;init sound - lda STORE1 ;get distortion + sta SKCTL ;init sound + lda tmp1 ;get distortion asl a ;ignore the high nibble asl a asl a asl a clc ;setup for adding volume - adc STORE2 ;add volume + adc tmp2 ;add volume sta AUDC1,x ;volume + distortion in control channel rts .endproc - ;reserve 2 bytes for temp storage - .bss -STORE1: .res 1 -STORE2: .res 1 From 40656ffb6e829da3abace9503020de5e8754a6d3 Mon Sep 17 00:00:00 2001 From: Mariano Dominguez Date: Sun, 15 Jan 2023 17:05:24 -0800 Subject: [PATCH 16/16] more style --- libsrc/atari/sound.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/atari/sound.s b/libsrc/atari/sound.s index 746ebc2bb..0c1e80db5 100644 --- a/libsrc/atari/sound.s +++ b/libsrc/atari/sound.s @@ -7,7 +7,7 @@ .include "atari.inc" .export __sound .import popa - .importzp tmp1,tmp2 + .importzp tmp1,tmp2 ; play sound, arguments: voice, pitch, distortion, volume. same as BASIC .proc __sound