1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-01 13:41:34 +00:00
cc65/libsrc/atari/sound.s

40 lines
1.1 KiB
ArmAsm
Raw Normal View History

;
; 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
2023-01-06 05:27:54 +00:00
sta STORE2 ;save volume
jsr popa ;get distortion
2023-01-06 18:54:16 +00:00
sta STORE1 ;save distortion
2023-01-06 05:27:54 +00:00
jsr popa ;get pitch
pha ;save in stack
jsr popa ;get voice
asl a ;adjust voice *2 for offset in x
2023-01-06 05:30:31 +00:00
tax
2023-01-06 05:27:54 +00:00
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
2023-01-06 05:34:43 +00:00
asl a
asl a
2023-01-06 05:27:54 +00:00
asl a
2023-01-06 05:36:44 +00:00
clc ;setup for adding volume
2023-01-06 05:27:54 +00:00
adc STORE2 ;add volume
sta AUDC1,x ;volume + distortion in control channel
rts
.endproc
2023-01-06 05:27:54 +00:00
;reserve 2 bytes for temp storage
2023-01-06 05:29:33 +00:00
.bss
2023-01-06 05:27:54 +00:00
STORE1: .res 1
STORE2: .res 1