2020-12-05 12:45:18 +01:00
|
|
|
; TI SN76489 sound chip display driver
|
|
|
|
; @author Daniele Verducci
|
|
|
|
;
|
|
|
|
; USAGE:
|
|
|
|
; call Snd_init <-- inits sound (and silences default tone)
|
|
|
|
; call Snd_beep <-- system beep
|
|
|
|
|
2020-12-06 15:51:26 +01:00
|
|
|
; Sound card is on port 1
|
|
|
|
SND_DATA_REG: EQU IO_1
|
2020-12-06 14:09:48 +01:00
|
|
|
|
2020-12-05 12:45:18 +01:00
|
|
|
; Init device (silence all channels)
|
|
|
|
; Bits meaning:
|
|
|
|
; 1 R0 R1 R2 A0 A1 A2 A3
|
|
|
|
; Bit0 is 1
|
|
|
|
; Bit1,2,3 select the channel: 001, 011, 101, 111(noise)
|
|
|
|
; Bit4,5,6,7 selecy the attenuation (0000=full volume, 1111=silent)
|
|
|
|
Snd_init:
|
|
|
|
; silence ch1
|
2020-12-06 14:09:48 +01:00
|
|
|
ld a,%10011111
|
2020-12-05 12:45:18 +01:00
|
|
|
out (SND_DATA_REG),a
|
|
|
|
; silence ch2
|
2020-12-06 14:09:48 +01:00
|
|
|
ld a,%10111111
|
2020-12-05 12:45:18 +01:00
|
|
|
out (SND_DATA_REG),a
|
|
|
|
; silence ch3
|
2020-12-06 14:09:48 +01:00
|
|
|
ld a,%11011111
|
2020-12-05 12:45:18 +01:00
|
|
|
out (SND_DATA_REG),a
|
|
|
|
; silence noise ch
|
|
|
|
ld a,%11111111
|
|
|
|
out (SND_DATA_REG),a
|
|
|
|
ret
|
|
|
|
|
2020-12-06 14:09:48 +01:00
|
|
|
; Plays the system beep.
|
2020-12-05 12:45:18 +01:00
|
|
|
Snd_beep:
|
|
|
|
; ch1 max volume
|
|
|
|
ld a,%10010000
|
|
|
|
out (SND_DATA_REG),a
|
|
|
|
; play beep freq
|
|
|
|
ld a,%10000000
|
|
|
|
out (SND_DATA_REG),a
|
|
|
|
ld a,%00001000
|
|
|
|
out (SND_DATA_REG),a
|
2020-12-06 15:51:26 +01:00
|
|
|
; wait
|
2020-12-16 23:39:24 +01:00
|
|
|
ld bc, (TIME_DUR_MILLIS * 100)
|
2020-12-05 12:45:18 +01:00
|
|
|
call Time_delay55
|
|
|
|
; silence ch1
|
|
|
|
ld a,%10011111
|
|
|
|
out (SND_DATA_REG),a
|
|
|
|
ret
|
2020-12-06 14:09:48 +01:00
|
|
|
|
|
|
|
; Sets the attenuation value for a channel
|
|
|
|
; @param a Channel (0, 1, 2, 3(Noise))
|
|
|
|
; @param c Attenuation (0 to 16)
|
|
|
|
; Snd_setAtt:
|
|
|
|
; cp a, 0
|
|
|
|
|