From e6cf770d2e8b3a9a723cb45af81197d4ca81dd21 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Tue, 17 Oct 2023 17:12:31 +0200 Subject: [PATCH] Fix memory bug and restore previous looping behaviour --- projects/examples/devices/audio-tests.tal | 4 ++-- src/devices/audio.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/examples/devices/audio-tests.tal b/projects/examples/devices/audio-tests.tal index 84c9dc2..caac352 100644 --- a/projects/examples/devices/audio-tests.tal +++ b/projects/examples/devices/audio-tests.tal @@ -1,6 +1,6 @@ ( dev/audio-tests ) -%GET-NOTE { #00 SWP ;melody ADD2 LDA #80 ORA } +%GET-NOTE { #00 SWP ;melody ADD2 LDA } ( devices ) @@ -68,7 +68,7 @@ BRK BRK @play-kick ( -> ) - #3c .Audio0/pitch DEO + #3c #80 ORA .Audio0/pitch DEO BRK @on-audio1 ( -> ) diff --git a/src/devices/audio.c b/src/devices/audio.c index a2d4428..ea14ee0 100644 --- a/src/devices/audio.c +++ b/src/devices/audio.c @@ -276,7 +276,7 @@ audio_handler(void *ctx, Uint8 *out_stream, int len) { } } int i; - for (i = 0; i < len; i++) { + for (i = 0; i < len / 2; i++) { stream[i] <<= 4; } } @@ -292,7 +292,7 @@ audio_start(int idx, Uint8 *d, Uxn *u) Uint8 *data = &u->ram[addr]; Uint16 len = PEEK2(d + 0xa); Uint8 volume = d[0xe]; - bool loop = !!(d[0xf] & 0x80); + bool loop = !(d[0xf] & 0x80); Uint8 pitch = d[0xf] & 0x7f; Uint16 adsr = PEEK2(d + 0x8); Uint8 attack = (adsr >> 12) & 0xF;