mirror of
https://github.com/irmen/prog8.git
synced 2025-01-12 04:30:03 +00:00
convert the sounds in cx16 tehtriz to use the psg module instead
This commit is contained in:
parent
4bdac7404a
commit
3ec05709d5
@ -15,8 +15,10 @@ psg {
|
|||||||
const ubyte RIGHT = %10000000
|
const ubyte RIGHT = %10000000
|
||||||
|
|
||||||
sub voice(ubyte voice_num, ubyte channel, ubyte volume, ubyte waveform, ubyte pulsewidth) {
|
sub voice(ubyte voice_num, ubyte channel, ubyte volume, ubyte waveform, ubyte pulsewidth) {
|
||||||
|
envelope_states[voice_num] = 255
|
||||||
cx16.vpoke(1, $f9c2 + voice_num * 4, channel | volume)
|
cx16.vpoke(1, $f9c2 + voice_num * 4, channel | volume)
|
||||||
cx16.vpoke(1, $f9c3 + voice_num * 4, waveform | pulsewidth)
|
cx16.vpoke(1, $f9c3 + voice_num * 4, waveform | pulsewidth)
|
||||||
|
envelope_volumes[voice_num] = mkword(volume, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
; sub freq_hz(ubyte voice_num, float hertz) {
|
; sub freq_hz(ubyte voice_num, float hertz) {
|
||||||
@ -34,6 +36,7 @@ psg {
|
|||||||
sub volume(ubyte voice_num, ubyte vol) {
|
sub volume(ubyte voice_num, ubyte vol) {
|
||||||
uword reg = $f9c2 + voice_num * 4
|
uword reg = $f9c2 + voice_num * 4
|
||||||
cx16.vpoke(1, reg, cx16.vpeek(1, reg) & %11000000 | vol)
|
cx16.vpoke(1, reg, cx16.vpeek(1, reg) & %11000000 | vol)
|
||||||
|
envelope_volumes[voice_num] = mkword(vol, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
sub pulse_width(ubyte voice_num, ubyte pw) {
|
sub pulse_width(ubyte voice_num, ubyte pw) {
|
||||||
@ -100,7 +103,7 @@ psg {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
; set new volumes using vera stride of 4
|
; set new volumes of all 16 voices, using vera stride of 4
|
||||||
cx16.push_vera_context()
|
cx16.push_vera_context()
|
||||||
cx16.VERA_CTRL = 0
|
cx16.VERA_CTRL = 0
|
||||||
cx16.VERA_ADDR_L = $c2
|
cx16.VERA_ADDR_L = $c2
|
||||||
|
@ -3,8 +3,7 @@ TODO
|
|||||||
|
|
||||||
For next release
|
For next release
|
||||||
^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^
|
||||||
- convert the sounds in cx16 tehtriz to use the psg module instead
|
...
|
||||||
- notify petaxian that it could use the psg module too?
|
|
||||||
|
|
||||||
Need help with
|
Need help with
|
||||||
^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^
|
||||||
|
@ -5,13 +5,12 @@
|
|||||||
; wall kick rotations
|
; wall kick rotations
|
||||||
; shows next piece
|
; shows next piece
|
||||||
; staged speed increase
|
; staged speed increase
|
||||||
; simplistic sound effects (Vera PSG)
|
; simple sound effects (Vera PSG)
|
||||||
|
|
||||||
|
|
||||||
%import syslib
|
%import syslib
|
||||||
%import textio
|
%import textio
|
||||||
%import test_stack
|
%import test_stack
|
||||||
|
%import psg
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
@ -212,11 +211,14 @@ waitkey:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if num_lines {
|
if num_lines {
|
||||||
if num_lines>3
|
if num_lines>3 {
|
||||||
sound.lineclear_big()
|
sound.lineclear_big()
|
||||||
else
|
sys.wait(25) ; slight delay to flash the line
|
||||||
|
}
|
||||||
|
else {
|
||||||
sound.lineclear()
|
sound.lineclear()
|
||||||
sys.wait(10) ; slight delay to flash the line
|
sys.wait(15) ; slight delay to flash the line
|
||||||
|
}
|
||||||
for linepos in complete_lines
|
for linepos in complete_lines
|
||||||
if linepos and blocklogic.isLineFull(linepos)
|
if linepos and blocklogic.isLineFull(linepos)
|
||||||
blocklogic.collapse(linepos)
|
blocklogic.collapse(linepos)
|
||||||
@ -592,71 +594,52 @@ blocklogic {
|
|||||||
sound {
|
sound {
|
||||||
sub init() {
|
sub init() {
|
||||||
cx16.vpoke(1, $f9c2, %00111111) ; volume max, no channels
|
cx16.vpoke(1, $f9c2, %00111111) ; volume max, no channels
|
||||||
|
psg.silent()
|
||||||
|
cx16.set_irq(&psg.envelopes_irq, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
sub blockrotate() {
|
sub blockrotate() {
|
||||||
; soft click/"tschk" sound
|
; soft click/"tschk" sound
|
||||||
uword freq = 15600
|
psg.freq(0, 15600)
|
||||||
cx16.vpoke(1, $f9c0, lsb(freq))
|
psg.voice(0, psg.LEFT | psg.RIGHT, 32, psg.NOISE, 0)
|
||||||
cx16.vpoke(1, $f9c1, msb(freq))
|
psg.envelope(0, 200, 1, 100)
|
||||||
cx16.vpoke(1, $f9c2, %11110000) ; half volume
|
|
||||||
cx16.vpoke(1, $f9c3, %11000000) ; noise waveform
|
|
||||||
sys.wait(2)
|
|
||||||
cx16.vpoke(1, $f9c2, 0) ; shut off
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub blockdrop() {
|
sub blockdrop() {
|
||||||
; swish
|
; swish
|
||||||
uword freq = 4600
|
psg.freq(1, 4600)
|
||||||
cx16.vpoke(1, $f9c0, lsb(freq))
|
psg.voice(1, psg.LEFT | psg.RIGHT, 32, psg.NOISE, 0)
|
||||||
cx16.vpoke(1, $f9c1, msb(freq))
|
psg.envelope(1, 200, 5, 20)
|
||||||
cx16.vpoke(1, $f9c2, %11110000) ; half volume
|
|
||||||
cx16.vpoke(1, $f9c3, %11000000) ; noise waveform
|
|
||||||
sys.wait(6)
|
|
||||||
cx16.vpoke(1, $f9c2, 0) ; shut off
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub swapping() {
|
sub swapping() {
|
||||||
; beep
|
; beep
|
||||||
uword freq = 1500
|
psg.freq(2, 1500)
|
||||||
cx16.vpoke(1, $f9c0, lsb(freq))
|
psg.voice(2, psg.LEFT | psg.RIGHT, 32, psg.TRIANGLE, 0)
|
||||||
cx16.vpoke(1, $f9c1, msb(freq))
|
psg.envelope(2, 100, 6, 10)
|
||||||
cx16.vpoke(1, $f9c2, %11110000) ; half volume
|
|
||||||
cx16.vpoke(1, $f9c3, %10000000) ; triangle waveform
|
|
||||||
sys.wait(6)
|
|
||||||
cx16.vpoke(1, $f9c2, 0) ; shut off
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub lineclear() {
|
sub lineclear() {
|
||||||
; explosion
|
; explosion
|
||||||
uword freq = 1400
|
psg.freq(3, 1400)
|
||||||
cx16.vpoke(1, $f9c0, lsb(freq))
|
psg.voice(3, psg.LEFT | psg.RIGHT, 63, psg.NOISE, 0)
|
||||||
cx16.vpoke(1, $f9c1, msb(freq))
|
psg.envelope(3, 100, 8, 10)
|
||||||
cx16.vpoke(1, $f9c2, %11111111) ; max volume
|
|
||||||
cx16.vpoke(1, $f9c3, %11000000) ; noise waveform
|
|
||||||
sys.wait(8)
|
|
||||||
cx16.vpoke(1, $f9c2, 0) ; shut off
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub lineclear_big() {
|
sub lineclear_big() {
|
||||||
; big explosion
|
; big explosion
|
||||||
uword freq = 2500
|
psg.freq(4, 2500)
|
||||||
cx16.vpoke(1, $f9c0, lsb(freq))
|
psg.voice(4, psg.LEFT | psg.RIGHT, 63, psg.NOISE, 0)
|
||||||
cx16.vpoke(1, $f9c1, msb(freq))
|
psg.envelope(4, 100, 20, 10)
|
||||||
cx16.vpoke(1, $f9c2, %11111111) ; max volume
|
|
||||||
cx16.vpoke(1, $f9c3, %11000000) ; noise waveform
|
|
||||||
sys.wait(30)
|
|
||||||
cx16.vpoke(1, $f9c2, 0) ; shut off
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub gameover() {
|
sub gameover() {
|
||||||
; attempt at buzz/boing (but can't get the sawtooth/triangle combined waveform of the sid)
|
; attempt at buzz/boing
|
||||||
uword freq = 200
|
psg.freq(5, 300)
|
||||||
cx16.vpoke(1, $f9c0, lsb(freq))
|
psg.freq(6, 600)
|
||||||
cx16.vpoke(1, $f9c1, msb(freq))
|
psg.voice(5, psg.LEFT | psg.RIGHT, 0, psg.SAWTOOTH, 0)
|
||||||
cx16.vpoke(1, $f9c2, %11111111) ; max volume
|
psg.voice(6, psg.LEFT | psg.RIGHT, 0, psg.TRIANGLE, 0)
|
||||||
cx16.vpoke(1, $f9c3, %01000000) ; sawtooth waveform
|
psg.envelope(5, 100, 30, 10)
|
||||||
sys.wait(30)
|
psg.envelope(6, 100, 30, 10)
|
||||||
cx16.vpoke(1, $f9c2, 0) ; shut off
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user