Merge pull request #1962 from marianodominguez/feature_add_sound_command
add sound command
This commit is contained in:
@@ -235,6 +235,12 @@ extern void __fastcall__ _scroll (signed char numlines);
|
|||||||
/* numlines < 0 scrolls down */
|
/* numlines < 0 scrolls down */
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Sound function */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
extern void __fastcall__ _sound (unsigned char voice, unsigned char frequency, unsigned char distortion, unsigned char volume);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Misc. functions */
|
/* Misc. functions */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|||||||
37
libsrc/atari/sound.s
Normal file
37
libsrc/atari/sound.s
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
;
|
||||||
|
; Mariano Domínguez
|
||||||
|
; 2022-12-4
|
||||||
|
;
|
||||||
|
; atari lib
|
||||||
|
;
|
||||||
|
.include "atari.inc"
|
||||||
|
.export __sound
|
||||||
|
.import popa
|
||||||
|
.importzp tmp1,tmp2
|
||||||
|
|
||||||
|
; play sound, arguments: voice, pitch, distortion, volume. same as BASIC
|
||||||
|
.proc __sound
|
||||||
|
sta tmp2 ;save volume
|
||||||
|
jsr popa ;get distortion
|
||||||
|
sta tmp1 ;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
|
||||||
|
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 tmp2 ;add volume
|
||||||
|
sta AUDC1,x ;volume + distortion in control channel
|
||||||
|
rts
|
||||||
|
.endproc
|
||||||
@@ -39,6 +39,7 @@ EXELIST_atari = \
|
|||||||
multi.xex \
|
multi.xex \
|
||||||
ostype.xex \
|
ostype.xex \
|
||||||
scrcode.com \
|
scrcode.com \
|
||||||
|
sound.xex \
|
||||||
sys.xex
|
sys.xex
|
||||||
|
|
||||||
ifneq ($(EXELIST_$(SYS)),)
|
ifneq ($(EXELIST_$(SYS)),)
|
||||||
@@ -74,7 +75,8 @@ scrcode.com: scrcode.s
|
|||||||
$(CL) -t atari -C atari-asm.cfg -o scrcode.com scrcode.s
|
$(CL) -t atari -C atari-asm.cfg -o scrcode.com scrcode.s
|
||||||
sys.xex: sys.c
|
sys.xex: sys.c
|
||||||
$(CL) -t atari -o 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:
|
clean:
|
||||||
@$(DEL) charmapping.xex 2>$(NULLDEV)
|
@$(DEL) charmapping.xex 2>$(NULLDEV)
|
||||||
@$(DEL) defdev.xex 2>$(NULLDEV)
|
@$(DEL) defdev.xex 2>$(NULLDEV)
|
||||||
@@ -85,3 +87,4 @@ clean:
|
|||||||
@$(DEL) scrcode.o 2>$(NULLDEV)
|
@$(DEL) scrcode.o 2>$(NULLDEV)
|
||||||
@$(DEL) scrcode.com 2>$(NULLDEV)
|
@$(DEL) scrcode.com 2>$(NULLDEV)
|
||||||
@$(DEL) sys.xex 2>$(NULLDEV)
|
@$(DEL) sys.xex 2>$(NULLDEV)
|
||||||
|
@$(DEL) sound.xex 2>$(NULLDEV)
|
||||||
|
|||||||
20
targettest/atari/sound.c
Normal file
20
targettest/atari/sound.c
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
** Test program for _sound for atari
|
||||||
|
**
|
||||||
|
** January 6 2023 Mariano Domínguez
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <conio.h>
|
||||||
|
#include <atari.h>
|
||||||
|
#include <cc65.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int i=0;
|
||||||
|
printf("playing sound \n");
|
||||||
|
_sound(1,121,10,15); //voice, pitch, distortion, volume
|
||||||
|
for(i=0;i<9000;i++);
|
||||||
|
_sound(1,0,0,0); //silencing, same as Atari Basic
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user