Switched to OPL emulation to DOSBox dbopl emulator.
Fixed SB Pro v2. Clarified GPL license in readme.txt.
This commit is contained in:
parent
31bc0ef789
commit
78f2d4a229
13 changed files with 1985 additions and 5609 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include "ibm.h"
|
||||
#include "io.h"
|
||||
#include "sound_opl.h"
|
||||
#include "sound_dbopl.h"
|
||||
|
||||
/*Interfaces between PCem and the actual OPL emulator*/
|
||||
|
||||
|
|
@ -12,14 +13,14 @@ uint8_t opl2_read(uint16_t a, void *priv)
|
|||
opl_t *opl = (opl_t *)priv;
|
||||
|
||||
cycles -= (int)(isa_timing * 8);
|
||||
return ym3812_read(opl->YM3812[0], a);
|
||||
return opl_read(0, a);
|
||||
}
|
||||
void opl2_write(uint16_t a, uint8_t v, void *priv)
|
||||
{
|
||||
opl_t *opl = (opl_t *)priv;
|
||||
|
||||
ym3812_write(opl->YM3812[0],a,v);
|
||||
ym3812_write(opl->YM3812[1],a,v);
|
||||
opl_write(0, a, v);
|
||||
opl_write(1, a, v);
|
||||
}
|
||||
|
||||
uint8_t opl2_l_read(uint16_t a, void *priv)
|
||||
|
|
@ -27,13 +28,13 @@ uint8_t opl2_l_read(uint16_t a, void *priv)
|
|||
opl_t *opl = (opl_t *)priv;
|
||||
|
||||
cycles -= (int)(isa_timing * 8);
|
||||
return ym3812_read(opl->YM3812[0], a);
|
||||
return opl_read(0, a);
|
||||
}
|
||||
void opl2_l_write(uint16_t a, uint8_t v, void *priv)
|
||||
{
|
||||
opl_t *opl = (opl_t *)priv;
|
||||
|
||||
ym3812_write(opl->YM3812[0],a,v);
|
||||
opl_write(0, a, v);
|
||||
}
|
||||
|
||||
uint8_t opl2_r_read(uint16_t a, void *priv)
|
||||
|
|
@ -41,13 +42,13 @@ uint8_t opl2_r_read(uint16_t a, void *priv)
|
|||
opl_t *opl = (opl_t *)priv;
|
||||
|
||||
cycles -= (int)(isa_timing * 8);
|
||||
return ym3812_read(opl->YM3812[1], a);
|
||||
return opl_read(1, a);
|
||||
}
|
||||
void opl2_r_write(uint16_t a, uint8_t v, void *priv)
|
||||
{
|
||||
opl_t *opl = (opl_t *)priv;
|
||||
|
||||
ym3812_write(opl->YM3812[1],a,v);
|
||||
opl_write(1, a, v);
|
||||
}
|
||||
|
||||
uint8_t opl3_read(uint16_t a, void *priv)
|
||||
|
|
@ -55,20 +56,20 @@ uint8_t opl3_read(uint16_t a, void *priv)
|
|||
opl_t *opl = (opl_t *)priv;
|
||||
|
||||
cycles -= (int)(isa_timing * 8);
|
||||
return ymf262_read(opl->YMF262, a);
|
||||
return opl_read(0, a);
|
||||
}
|
||||
void opl3_write(uint16_t a, uint8_t v, void *priv)
|
||||
{
|
||||
opl_t *opl = (opl_t *)priv;
|
||||
|
||||
ymf262_write(opl->YMF262, a, v);
|
||||
opl_write(0, a, v);
|
||||
}
|
||||
|
||||
|
||||
void opl2_poll(opl_t *opl, int16_t *bufl, int16_t *bufr)
|
||||
{
|
||||
ym3812_update_one(opl->YM3812[0], bufl, 1);
|
||||
ym3812_update_one(opl->YM3812[1], bufr, 1);
|
||||
opl2_update(0, bufl, 1);
|
||||
opl2_update(1, bufr, 1);
|
||||
|
||||
opl->filtbuf[0] = *bufl = ((*bufl) / 4) + ((opl->filtbuf[0] * 11) / 16);
|
||||
opl->filtbuf[1] = *bufr = ((*bufr) / 4) + ((opl->filtbuf[1] * 11) / 16);
|
||||
|
|
@ -76,31 +77,31 @@ void opl2_poll(opl_t *opl, int16_t *bufl, int16_t *bufr)
|
|||
if (opl->timers_enable[0][0])
|
||||
{
|
||||
opl->timers[0][0]--;
|
||||
if (opl->timers[0][0] < 0) ym3812_timer_over(opl->YM3812[0], 0);
|
||||
if (opl->timers[0][0] < 0) opl_timer_over(0, 0);
|
||||
}
|
||||
if (opl->timers_enable[0][1])
|
||||
{
|
||||
opl->timers[0][1]--;
|
||||
if (opl->timers[0][1] < 0) ym3812_timer_over(opl->YM3812[0], 1);
|
||||
if (opl->timers[0][1] < 0) opl_timer_over(0, 1);
|
||||
}
|
||||
if (opl->timers_enable[1][0])
|
||||
{
|
||||
opl->timers[1][0]--;
|
||||
if (opl->timers[1][0] < 0) ym3812_timer_over(opl->YM3812[1], 0);
|
||||
if (opl->timers[1][0] < 0) opl_timer_over(1, 0);
|
||||
}
|
||||
if (opl->timers_enable[1][1])
|
||||
{
|
||||
opl->timers[1][1]--;
|
||||
if (opl->timers[1][1] < 0) ym3812_timer_over(opl->YM3812[1], 1);
|
||||
if (opl->timers[1][1] < 0) opl_timer_over(1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void opl3_poll(opl_t *opl, int16_t *bufl, int16_t *bufr)
|
||||
{
|
||||
ymf262_update_one(opl->YMF262, opl->bufs, 1);
|
||||
opl3_update(0, bufl, bufr, 1);
|
||||
|
||||
opl->filtbuf[0] = *bufl = ((opl->bufs[0][0]) / 4) + ((opl->filtbuf[0] * 11) / 16);
|
||||
opl->filtbuf[1] = *bufr = ((opl->bufs[1][0]) / 4) + ((opl->filtbuf[1] * 11) / 16);
|
||||
opl->filtbuf[0] = *bufl = ((*bufl) / 4) + ((opl->filtbuf[0] * 11) / 16);
|
||||
opl->filtbuf[1] = *bufr = ((*bufr) / 4) + ((opl->filtbuf[1] * 11) / 16);
|
||||
|
||||
if (opl->timers_enable[0][0])
|
||||
{
|
||||
|
|
@ -108,7 +109,7 @@ void opl3_poll(opl_t *opl, int16_t *bufl, int16_t *bufr)
|
|||
if (opl->timers[0][0] < 0)
|
||||
{
|
||||
opl->timers_enable[0][0] = 0;
|
||||
ymf262_timer_over(opl->YMF262, 0);
|
||||
opl_timer_over(0, 0);
|
||||
}
|
||||
}
|
||||
if (opl->timers_enable[0][1])
|
||||
|
|
@ -117,12 +118,12 @@ void opl3_poll(opl_t *opl, int16_t *bufl, int16_t *bufr)
|
|||
if (opl->timers[0][1] < 0)
|
||||
{
|
||||
opl->timers_enable[0][1] = 0;
|
||||
ymf262_timer_over(opl->YMF262, 1);
|
||||
opl_timer_over(0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ym3812_timer_set_0(void *param, int timer, attotime period)
|
||||
void ym3812_timer_set_0(void *param, int timer, int64_t period)
|
||||
{
|
||||
opl_t *opl = (opl_t *)param;
|
||||
|
||||
|
|
@ -130,7 +131,7 @@ void ym3812_timer_set_0(void *param, int timer, attotime period)
|
|||
if (!opl->timers[0][timer]) opl->timers[0][timer] = 1;
|
||||
opl->timers_enable[0][timer] = period ? 1 : 0;
|
||||
}
|
||||
void ym3812_timer_set_1(void *param, int timer, attotime period)
|
||||
void ym3812_timer_set_1(void *param, int timer, int64_t period)
|
||||
{
|
||||
opl_t *opl = (opl_t *)param;
|
||||
|
||||
|
|
@ -139,7 +140,7 @@ void ym3812_timer_set_1(void *param, int timer, attotime period)
|
|||
opl->timers_enable[1][timer] = period ? 1 : 0;
|
||||
}
|
||||
|
||||
void ymf262_timer_set(void *param, int timer, attotime period)
|
||||
void ymf262_timer_set(void *param, int timer, int64_t period)
|
||||
{
|
||||
opl_t *opl = (opl_t *)param;
|
||||
|
||||
|
|
@ -150,46 +151,12 @@ void ymf262_timer_set(void *param, int timer, attotime period)
|
|||
|
||||
void opl2_init(opl_t *opl)
|
||||
{
|
||||
opl->bufs[0] = (int16_t *)malloc(4);
|
||||
opl->bufs[1] = (int16_t *)malloc(4);
|
||||
opl->bufs[2] = (int16_t *)malloc(4);
|
||||
opl->bufs[3] = (int16_t *)malloc(4);
|
||||
|
||||
opl->YM3812[0] = ym3812_init(NULL, 3579545, 48000);
|
||||
ym3812_reset_chip(opl->YM3812[0]);
|
||||
ym3812_set_timer_handler(opl->YM3812[0], ym3812_timer_set_0, opl);
|
||||
|
||||
opl->YM3812[1] = ym3812_init(NULL, 3579545, 48000);
|
||||
ym3812_reset_chip(opl->YM3812[1]);
|
||||
ym3812_set_timer_handler(opl->YM3812[1], ym3812_timer_set_1, opl);
|
||||
opl_init(ym3812_timer_set_0, opl, 0, 0);
|
||||
opl_init(ym3812_timer_set_1, opl, 1, 0);
|
||||
}
|
||||
|
||||
void opl3_init(opl_t *opl)
|
||||
{
|
||||
opl->bufs[0] = (int16_t *)malloc(4);
|
||||
opl->bufs[1] = (int16_t *)malloc(4);
|
||||
opl->bufs[2] = (int16_t *)malloc(4);
|
||||
opl->bufs[3] = (int16_t *)malloc(4);
|
||||
|
||||
opl->YMF262 = ymf262_init(NULL, 3579545 * 4, 48000);
|
||||
ymf262_reset_chip(opl->YMF262);
|
||||
ymf262_set_timer_handler(opl->YMF262, ymf262_timer_set, opl);
|
||||
opl_init(ymf262_timer_set, opl, 0, 1);
|
||||
}
|
||||
|
||||
void opl2_close(opl_t *opl)
|
||||
{
|
||||
free(opl->bufs[0]);
|
||||
free(opl->bufs[1]);
|
||||
|
||||
ym3812_shutdown(opl->YM3812[0]);
|
||||
ym3812_shutdown(opl->YM3812[1]);
|
||||
}
|
||||
|
||||
void opl3_close(opl_t *opl)
|
||||
{
|
||||
free(opl->bufs[0]);
|
||||
free(opl->bufs[1]);
|
||||
|
||||
ym3812_shutdown(opl->YM3812[0]);
|
||||
ymf262_shutdown(opl->YMF262);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue