works in dosbox
authorJohn Tsiombikas <nuclear@member.fsf.org>
Sat, 10 Nov 2018 14:38:50 +0000 (16:38 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Sat, 10 Nov 2018 14:38:50 +0000 (16:38 +0200)
src/au_sb.c
src/audio.c
src/main.c

index 8ff4ea1..2046f91 100644 (file)
@@ -3,6 +3,7 @@
 #include <pc.h>
 #include <go32.h>
 #include <dpmi.h>
 #include <pc.h>
 #include <go32.h>
 #include <dpmi.h>
+#include <sys/nearptr.h>
 #include "audio.h"
 #include "au_sb.h"
 #include "dma.h"
 #include "audio.h"
 #include "au_sb.h"
 #include "dma.h"
@@ -175,14 +176,19 @@ void sb_start(int rate, int nchan)
        _go32_dpmi_seginfo intr;
 
        if(!buffer) {
        _go32_dpmi_seginfo intr;
 
        if(!buffer) {
+               __djgpp_nearptr_enable();
+
                /* 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;
                }
 
                /* 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;
                }
 
+               printf("allocated seg: %d, addr: %lx\n", seg, (unsigned long)seg << 4);
+
                addr = ((uint32_t)(seg << 4) + 0xffff) & 0xffff0000;
                addr = ((uint32_t)(seg << 4) + 0xffff) & 0xffff0000;
-               buffer = (void*)addr;
+               printf("aligned: %lx\n", (unsigned long)addr);
+               buffer = (void*)(addr - __djgpp_base_address);
        } else {
                addr = (uint32_t)buffer;
        }
        } else {
                addr = (uint32_t)buffer;
        }
index 49b8a8d..d783559 100644 (file)
@@ -1,20 +1,3 @@
-/*
-pcboot - bootable PC demo/game kernel
-Copyright (C) 2018  John Tsiombikas <nuclear@member.fsf.org>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY, without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <https://www.gnu.org/licenses/>.
-*/
 #include <stdio.h>
 #include "audio.h"
 #include "au_sb.h"
 #include <stdio.h>
 #include "audio.h"
 #include "au_sb.h"
index fd87b7a..1e32b61 100644 (file)
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include "audio.h"
 
 static int au_callback(void *buffer, int size, void *cls);
 #include "audio.h"
 
 static int au_callback(void *buffer, int size, void *cls);
@@ -21,23 +22,6 @@ int main(int argc, char **argv)
 /* snd_click_size is < 65536 so we can just throw it all at once in there */
 static int au_callback(void *buffer, int size, void *cls)
 {
 /* snd_click_size is < 65536 so we can just throw it all at once in there */
 static int au_callback(void *buffer, int size, void *cls)
 {
-       int i;
-       signed char *ptr = buffer;
-       signed char *src = snd_click;
-       /*
-          for(i=0; i<size; i++) {
-          if((i / 32) & 1) {
-        *ptr++ = -64;
-        } else {
-        *ptr++ = 64;
-        }
-        }
-        */
-       /*memcpy(buffer, snd_click, snd_click_size);*/
-
-       for(i=0; i<snd_click_size; i++) {
-               *ptr++ = *src++;
-       }
-
+       memcpy(buffer, snd_click, snd_click_size);
        return snd_click_size;
 }
        return snd_click_size;
 }