added sounds to cx16 tehtriz

This commit is contained in:
Irmen de Jong 2021-02-23 01:29:45 +01:00
parent e65c5402d7
commit 6e65cb2c0a
2 changed files with 47 additions and 46 deletions

View File

@ -2,9 +2,6 @@
TODO TODO
==== ====
- add sound to the cx16 tehtriz
- add const arrays and cost strings
- hoist all variable declarations up to the subroutine scope *before* even the constant folding takes place (to avoid undefined symbol errors when referring to a variable from another nested scope in the subroutine) - hoist all variable declarations up to the subroutine scope *before* even the constant folding takes place (to avoid undefined symbol errors when referring to a variable from another nested scope in the subroutine)
- optimize swap of two memread values with index, using the same pointer expression/variable, like swap(@(ptr+1), @(ptr+2)) - optimize swap of two memread values with index, using the same pointer expression/variable, like swap(@(ptr+1), @(ptr+2))
- optimize several inner loops in gfx2 (highres 4 color mode) - optimize several inner loops in gfx2 (highres 4 color mode)

View File

@ -5,8 +5,7 @@
; wall kick rotations ; wall kick rotations
; shows next piece ; shows next piece
; staged speed increase ; staged speed increase
; TODO: replicate the simple sound effects from the C64 version ; simplistic sound effects (Vera PSG)
; how to do this on the Vera PSG without a ADSR envelope...?
%target cx16 %target cx16
@ -215,7 +214,7 @@ waitkey:
sound.lineclear_big() sound.lineclear_big()
else else
sound.lineclear() sound.lineclear()
sys.wait(20) ; slight delay to flash the line sys.wait(10) ; 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)
@ -589,68 +588,73 @@ blocklogic {
sound { sound {
; TODO stubs for now
sub init() { sub init() {
; c64.MVOL = 15 cx16.vpoke(1, $f9c2, %00111111) ; volume max, no channels
} }
sub blockrotate() { sub blockrotate() {
; soft click ; soft click/"tschk" sound
; c64.MVOL = 5 uword freq = 15600
; c64.AD1 = %00100010 cx16.vpoke(1, $f9c0, lsb(freq))
; c64.SR1 = %00000000 cx16.vpoke(1, $f9c1, msb(freq))
; c64.FREQ1 = 15600 cx16.vpoke(1, $f9c2, %11110000) ; half volume
; c64.CR1 = %10000000 cx16.vpoke(1, $f9c3, %11000000) ; noise waveform
; c64.CR1 = %10000001 sys.wait(2)
cx16.vpoke(1, $f9c2, 0) ; shut off
} }
sub blockdrop() { sub blockdrop() {
; swish ; swish
; c64.MVOL = 5 uword freq = 4600
; c64.AD1 = %01010111 cx16.vpoke(1, $f9c0, lsb(freq))
; c64.SR1 = %00000000 cx16.vpoke(1, $f9c1, msb(freq))
; c64.FREQ1 = 4600 cx16.vpoke(1, $f9c2, %11110000) ; half volume
; c64.CR1 = %10000000 cx16.vpoke(1, $f9c3, %11000000) ; noise waveform
; c64.CR1 = %10000001 sys.wait(6)
cx16.vpoke(1, $f9c2, 0) ; shut off
} }
sub swapping() { sub swapping() {
; beep ; beep
; c64.MVOL = 8 uword freq = 1500
; c64.AD1 = %01010111 cx16.vpoke(1, $f9c0, lsb(freq))
; c64.SR1 = %00000000 cx16.vpoke(1, $f9c1, msb(freq))
; c64.FREQ1 = 5500 cx16.vpoke(1, $f9c2, %11110000) ; half volume
; c64.CR1 = %00010000 cx16.vpoke(1, $f9c3, %10000000) ; triangle waveform
; c64.CR1 = %00010001 sys.wait(6)
cx16.vpoke(1, $f9c2, 0) ; shut off
} }
sub lineclear() { sub lineclear() {
; explosion ; explosion
; c64.MVOL = 15 uword freq = 1400
; c64.AD1 = %01100110 cx16.vpoke(1, $f9c0, lsb(freq))
; c64.SR1 = %00000000 cx16.vpoke(1, $f9c1, msb(freq))
; c64.FREQ1 = 1600 cx16.vpoke(1, $f9c2, %11111111) ; max volume
; c64.CR1 = %10000000 cx16.vpoke(1, $f9c3, %11000000) ; noise waveform
; c64.CR1 = %10000001 sys.wait(8)
cx16.vpoke(1, $f9c2, 0) ; shut off
} }
sub lineclear_big() { sub lineclear_big() {
; big explosion ; big explosion
; c64.MVOL = 15 uword freq = 2500
; c64.AD1 = %01101010 cx16.vpoke(1, $f9c0, lsb(freq))
; c64.SR1 = %00000000 cx16.vpoke(1, $f9c1, msb(freq))
; c64.FREQ1 = 2600 cx16.vpoke(1, $f9c2, %11111111) ; max volume
; c64.CR1 = %10000000 cx16.vpoke(1, $f9c3, %11000000) ; noise waveform
; c64.CR1 = %10000001 sys.wait(30)
cx16.vpoke(1, $f9c2, 0) ; shut off
} }
sub gameover() { sub gameover() {
; buzz ; attempt at buzz/boing (but can't get the sawtooth/triangle combined waveform of the sid)
; c64.MVOL = 15 uword freq = 200
; c64.FREQ2 = 600 cx16.vpoke(1, $f9c0, lsb(freq))
; c64.AD2 = %00111010 cx16.vpoke(1, $f9c1, msb(freq))
; c64.SR2 = %00000000 cx16.vpoke(1, $f9c2, %11111111) ; max volume
; c64.CR2 = %00110000 cx16.vpoke(1, $f9c3, %01000000) ; sawtooth waveform
; c64.CR2 = %00110001 sys.wait(30)
cx16.vpoke(1, $f9c2, 0) ; shut off
} }
} }