From 85710b37e4082a5b8e6d35c16311cb024298e24f Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Thu, 8 Nov 2018 10:23:10 +0200 Subject: [PATCH] fixed build, untested --- Makefile | 1 + src/au_sb.c | 21 +++++++++++++-------- src/ausamples.s | 6 ++++++ src/dma.c | 1 + src/main.c | 2 +- 5 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 src/ausamples.s diff --git a/Makefile b/Makefile index cb6a3d6..1015733 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ opt = -O3 -ffast-math -fno-strict-aliasing dbg = -g warn = -pedantic -Wall -Wno-unused-function -Wno-unused-variable +AS = $(TOOLPREFIX)as CC = $(TOOLPREFIX)gcc AR = $(TOOLPREFIX)ar CFLAGS = $(warn) -march=pentium $(dbg) $(opt) $(inc) diff --git a/src/au_sb.c b/src/au_sb.c index ab12b9e..8ff4ea1 100644 --- a/src/au_sb.c +++ b/src/au_sb.c @@ -169,18 +169,23 @@ void *sb_buffer(int *size) void sb_start(int rate, int nchan) { + int seg, pmsel; uint32_t addr; int size; _go32_dpmi_seginfo intr; - /* for now just use the are after boot2. it's only used by the second stage - * loader and the VBE init code, none of which should overlap with audio playback. - * It's not necessary to use low memory. We can use up to the first 16mb for this, - * so if this becomes an issue, I'll make a DMA buffer allocator over 1mb. - * start the buffer from the next 64k boundary. - */ - addr = ((uint32_t)low_mem_buffer + 0xffff) & 0xffff0000; - buffer = (void*)addr; + if(!buffer) { + /* allocate a 64k-aligned 64k buffer in low memory */ + if((seg = __dpmi_allocate_dos_memory(65536 * 2 / 16, &pmsel)) <= 0) { + fprintf(stderr, "sb_start: failed to allocate DMA buffer\n"); + return; + } + + addr = ((uint32_t)(seg << 4) + 0xffff) & 0xffff0000; + buffer = (void*)addr; + } else { + addr = (uint32_t)buffer; + } xfer_mode = CMD_MODE_SIGNED; if(nchan > 1) { diff --git a/src/ausamples.s b/src/ausamples.s new file mode 100644 index 0000000..e74c9e7 --- /dev/null +++ b/src/ausamples.s @@ -0,0 +1,6 @@ + .data + .global _snd_click + .global _snd_click_size +_snd_click: + .incbin "click-s8_mono.pcm" +_snd_click_size: .long . - _snd_click diff --git a/src/dma.c b/src/dma.c index 9c6ad67..e483002 100644 --- a/src/dma.c +++ b/src/dma.c @@ -1,3 +1,4 @@ +#include #include "dma.h" /* 8bit DMA ports */ diff --git a/src/main.c b/src/main.c index 44f41b8..fd87b7a 100644 --- a/src/main.c +++ b/src/main.c @@ -4,7 +4,7 @@ static int au_callback(void *buffer, int size, void *cls); -/* defined in sndsamples.s */ +/* defined in ausamples.s */ extern signed char snd_click[]; extern int snd_click_size; -- 1.7.10.4