2023-01-06 05:12:58 +00:00
|
|
|
;
|
|
|
|
; Mariano Domínguez
|
|
|
|
; 2022-12-4
|
|
|
|
;
|
2023-01-18 10:55:52 +00:00
|
|
|
; this file provides an equivalent to the BASIC SOUND function
|
|
|
|
;
|
|
|
|
; void __fastcall__ _sound (unsigned char voice, unsigned char frequency, unsigned char distortion, unsigned char volume);
|
2023-01-06 05:12:58 +00:00
|
|
|
;
|
|
|
|
.include "atari.inc"
|
2023-01-10 19:16:36 +00:00
|
|
|
.export __sound
|
2023-01-06 05:12:58 +00:00
|
|
|
.import popa
|
2023-01-16 01:05:24 +00:00
|
|
|
.importzp tmp1,tmp2
|
2023-01-16 01:00:05 +00:00
|
|
|
|
2023-01-18 10:55:52 +00:00
|
|
|
; play sound, arguments: voice, pitch, distortion, volume
|
2023-01-10 19:16:36 +00:00
|
|
|
.proc __sound
|
2023-01-16 01:00:05 +00:00
|
|
|
sta tmp2 ;save volume
|
2023-01-06 05:27:54 +00:00
|
|
|
jsr popa ;get distortion
|
2023-01-16 01:00:05 +00:00
|
|
|
sta tmp1 ;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
|
2023-01-16 01:00:05 +00:00
|
|
|
sta SKCTL ;init sound
|
|
|
|
lda tmp1 ;get distortion
|
2023-01-06 05:27:54 +00:00
|
|
|
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-16 17:01:11 +00:00
|
|
|
adc tmp2 ;add volume
|
2023-01-06 05:27:54 +00:00
|
|
|
sta AUDC1,x ;volume + distortion in control channel
|
|
|
|
rts
|
2023-01-06 05:12:58 +00:00
|
|
|
.endproc
|