Files
86Box/src/sound_adlib.c
OBattler 6e2b91c3d1 Pretty much all timer counters are now 32-bit again;
Fixed FDI stream parameters passed to the 86F handler, FDI stream images now read correctly again;
The National Semiconductors PC87306 SuperI/O chip now supports enhanced FDC mode.
2016-11-07 06:39:20 +01:00

57 lines
1.1 KiB
C

#include <stdlib.h>
#include "ibm.h"
#include "device.h"
#include "sound.h"
#include "sound_adlib.h"
#include "sound_opl.h"
typedef struct adlib_t
{
opl_t opl;
} adlib_t;
static void adlib_get_buffer(int32_t *buffer, int len, void *p)
{
adlib_t *adlib = (adlib_t *)p;
int c;
opl2_update2(&adlib->opl);
for (c = 0; c < len * 2; c++)
buffer[c] += (int32_t)adlib->opl.buffer[c];
adlib->opl.pos = 0;
}
void *adlib_init()
{
adlib_t *adlib = malloc(sizeof(adlib_t));
memset(adlib, 0, sizeof(adlib_t));
pclog("adlib_init\n");
opl2_init(&adlib->opl);
io_sethandler(0x0388, 0x0002, opl2_read, NULL, NULL, opl2_write, NULL, NULL, &adlib->opl);
sound_add_handler(adlib_get_buffer, adlib);
return adlib;
}
void adlib_close(void *p)
{
adlib_t *adlib = (adlib_t *)p;
free(adlib);
}
device_t adlib_device =
{
"AdLib",
0,
adlib_init,
adlib_close,
NULL,
NULL,
NULL,
NULL
};