#include <pc.h>
#include <go32.h>
#include <dpmi.h>
+#include <sys/nearptr.h>
#include "audio.h"
#include "au_sb.h"
#include "dma.h"
_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;
}
+ printf("allocated seg: %d, addr: %lx\n", seg, (unsigned long)seg << 4);
+
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;
}
-/*
-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 <stdlib.h>
+#include <string.h>
#include "audio.h"
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;
}