mirror of
https://github.com/irmen/prog8.git
synced 2025-08-07 21:25:18 +00:00
psg tweaks
This commit is contained in:
@@ -53,10 +53,10 @@ psg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub silent() {
|
sub silent() {
|
||||||
for cx16.r9L in 0 to 15 {
|
for cx16.r15L in 0 to 15 {
|
||||||
volume(cx16.r9L, 0)
|
volume(cx16.r15L, 0)
|
||||||
envelope_volumes[cx16.r9L] = 0
|
envelope_volumes[cx16.r15L] = 0
|
||||||
envelope_states[cx16.r9L] = 1
|
envelope_states[cx16.r15L] = 255
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,25 +71,28 @@ psg {
|
|||||||
cx16.r14H = cx16.VERA_ADDR_H
|
cx16.r14H = cx16.VERA_ADDR_H
|
||||||
|
|
||||||
for cx16.r15L in 0 to 15 {
|
for cx16.r15L in 0 to 15 {
|
||||||
if envelope_states[cx16.r15L] {
|
when envelope_states[cx16.r15L] {
|
||||||
; release
|
0 -> {
|
||||||
cx16.r0 = envelope_volumes[cx16.r15L] - envelope_releases[cx16.r15L]
|
; attack
|
||||||
if msb(cx16.r0) & %11000000 {
|
cx16.r0 = envelope_volumes[cx16.r15L] + envelope_attacks[cx16.r15L]
|
||||||
cx16.r0 = 0
|
if msb(cx16.r0) & %11000000 or envelope_attacks[cx16.r15L]==0 {
|
||||||
envelope_releases[cx16.r15L] = 0
|
cx16.r0 = mkword(63, 0)
|
||||||
|
envelope_attacks[cx16.r15L] = 0
|
||||||
|
envelope_states[cx16.r15L] = 1 ; start release
|
||||||
|
}
|
||||||
|
envelope_volumes[cx16.r15L] = cx16.r0
|
||||||
|
volume(cx16.r15L, msb(cx16.r0))
|
||||||
}
|
}
|
||||||
envelope_volumes[cx16.r15L] = cx16.r0
|
1 -> {
|
||||||
volume(cx16.r15L, msb(cx16.r0))
|
; release
|
||||||
} else {
|
cx16.r0 = envelope_volumes[cx16.r15L] - envelope_releases[cx16.r15L]
|
||||||
; attack
|
if msb(cx16.r0) & %11000000 {
|
||||||
cx16.r0 = envelope_volumes[cx16.r15L] + envelope_attacks[cx16.r15L]
|
cx16.r0 = 0
|
||||||
if msb(cx16.r0) & %11000000 or envelope_attacks[cx16.r15L]==0 {
|
envelope_releases[cx16.r15L] = 0
|
||||||
cx16.r0 = mkword(63, 0)
|
}
|
||||||
envelope_attacks[cx16.r15L] = 0
|
envelope_volumes[cx16.r15L] = cx16.r0
|
||||||
envelope_states[cx16.r15L] = 1 ; start release
|
volume(cx16.r15L, msb(cx16.r0))
|
||||||
}
|
}
|
||||||
envelope_volumes[cx16.r15L] = cx16.r0
|
|
||||||
volume(cx16.r15L, msb(cx16.r0))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cx16.VERA_CTRL = cx16.r13L
|
cx16.VERA_CTRL = cx16.r13L
|
||||||
|
@@ -4,6 +4,7 @@ TODO
|
|||||||
For next release
|
For next release
|
||||||
^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^
|
||||||
- optimize msb(cx16.r0) -> cx16.r0H, lsb(cx16.r0) -> cx16.r0L
|
- optimize msb(cx16.r0) -> cx16.r0H, lsb(cx16.r0) -> cx16.r0L
|
||||||
|
- if passing a subroutine or label name as an uword argument, without &, add the addressof automatically
|
||||||
- convert the sounds in cx16 tehtriz to use the psg module instead
|
- convert the sounds in cx16 tehtriz to use the psg module instead
|
||||||
- notify petaxian that it could use the psg module too?
|
- notify petaxian that it could use the psg module too?
|
||||||
|
|
||||||
|
@@ -4,12 +4,59 @@
|
|||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
sub start() {
|
sub explosion() {
|
||||||
|
; this subroutine is not used but it is an example of how to make a sound effect using the psg library!
|
||||||
|
psg.silent()
|
||||||
|
cx16.set_irq(&psg.envelopes_irq, true)
|
||||||
|
psg.voice(0, psg.LEFT, 0, psg.NOISE, 0)
|
||||||
|
psg.voice(1, psg.RIGHT, 0, psg.NOISE, 0)
|
||||||
|
psg.freq(0, 1000)
|
||||||
|
psg.freq(1, 2000)
|
||||||
|
psg.envelope(0, 50, 5)
|
||||||
|
psg.envelope(1, 80, 6)
|
||||||
|
sys.wait(100)
|
||||||
|
psg.silent()
|
||||||
|
cx16.restore_irq()
|
||||||
|
}
|
||||||
|
|
||||||
|
sub sweeping() {
|
||||||
|
; this subroutine is not used but it is an example of how to make a sound effect using the psg library!
|
||||||
|
psg.silent()
|
||||||
|
psg.voice(0, psg.LEFT, 63, psg.PULSE, 0)
|
||||||
|
psg.voice(1, psg.LEFT, 63, psg.PULSE, 1)
|
||||||
|
psg.voice(2, psg.RIGHT, 63, psg.PULSE, 2)
|
||||||
|
psg.voice(3, psg.RIGHT, 63, psg.PULSE, 3)
|
||||||
|
psg.freq(0, 160)
|
||||||
|
psg.freq(1, 161)
|
||||||
|
psg.freq(2, 162)
|
||||||
|
psg.freq(3, 163)
|
||||||
|
repeat {
|
||||||
|
ubyte pw
|
||||||
|
for pw in 0 to 63 {
|
||||||
|
psg.pulse_width(0, pw)
|
||||||
|
psg.pulse_width(1, pw)
|
||||||
|
psg.pulse_width(2, pw)
|
||||||
|
psg.pulse_width(3, pw)
|
||||||
|
sys.wait(2)
|
||||||
|
}
|
||||||
|
for pw in 62 downto 1 {
|
||||||
|
psg.pulse_width(0, pw)
|
||||||
|
psg.pulse_width(1, pw)
|
||||||
|
psg.pulse_width(2, pw)
|
||||||
|
psg.pulse_width(3, pw)
|
||||||
|
sys.wait(2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
psg.silent()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub start() {
|
||||||
txt.print("will play the music from boulderdash,\nmade in 1984 by peter liepa.\npress enter to start: ")
|
txt.print("will play the music from boulderdash,\nmade in 1984 by peter liepa.\npress enter to start: ")
|
||||||
void c64.CHRIN()
|
void c64.CHRIN()
|
||||||
txt.clear_screen()
|
txt.clear_screen()
|
||||||
|
|
||||||
|
psg.silent()
|
||||||
psg.voice(0, psg.LEFT, 63, psg.TRIANGLE, 0)
|
psg.voice(0, psg.LEFT, 63, psg.TRIANGLE, 0)
|
||||||
psg.voice(1, psg.RIGHT, 63, psg.TRIANGLE, 0)
|
psg.voice(1, psg.RIGHT, 63, psg.TRIANGLE, 0)
|
||||||
cx16.set_irq(&psg.envelopes_irq, false)
|
cx16.set_irq(&psg.envelopes_irq, false)
|
||||||
|
Reference in New Issue
Block a user