md2612: fix bugs barry and combone reported

This commit is contained in:
dinkc64 2017-07-21 03:14:43 +00:00
parent 03bb224c35
commit d3069a0902
2 changed files with 12 additions and 28 deletions

View File

@ -3,8 +3,6 @@
#include "burn_sound.h"
#include "burn_md2612.h"
#define MAX_MD2612 1
void (*BurnMD2612Update)(INT16* pSoundBuf, INT32 nSegmentEnd);
static INT32 (*BurnMD2612StreamCallback)(INT32 nSoundRate);
@ -12,7 +10,7 @@ static INT32 (*BurnMD2612StreamCallback)(INT32 nSoundRate);
static INT32 nBurnMD2612SoundRate;
static INT16* pBuffer;
static INT16* pMD2612Buffer[2 * MAX_MD2612];
static INT16* pMD2612Buffer[2];
static INT32 nMD2612Position;
@ -22,8 +20,8 @@ static INT32 nFractionalPosition;
static INT32 nNumChips = 0;
static INT32 bMD2612AddSignal;
static double MD2612Volumes[2 * MAX_MD2612];
static INT32 MD2612RouteDirs[2 * MAX_MD2612];
static double MD2612Volumes[2];
static INT32 MD2612RouteDirs[2];
// ----------------------------------------------------------------------------
// Dummy functions
@ -156,7 +154,6 @@ void BurnMD2612UpdateRequest()
MD2612Render(BurnMD2612StreamCallback(nBurnMD2612SoundRate));
}
// ----------------------------------------------------------------------------
// Initialisation, etc.
@ -194,7 +191,7 @@ void BurnMD2612Exit()
INT32 BurnMD2612Init(INT32 num, INT32 bIsPal, INT32 (*StreamCallback)(INT32), double (*GetTimeCallback)(), INT32 bAddSignal)
{
if (num > 1) {
bprintf(0, _T("MD2612 only supports 1 chip!\n"));
bprintf(0, _T("BurnMD2612Init(): MD2612 only supports 1 chip!\n"));
return 0;
}
@ -254,11 +251,6 @@ void BurnMD2612SetRoute(INT32 nChip, INT32 nIndex, double nVolume, INT32 nRouteD
MD2612Volumes[nIndex] = nVolume;
MD2612RouteDirs[nIndex] = nRouteDir;
}
if (nChip == 1) {
MD2612Volumes[2 + nIndex] = nVolume;
MD2612RouteDirs[2 + nIndex] = nRouteDir;
}
}
void BurnMD2612Scan(INT32 nAction, INT32* pnMin)
@ -278,5 +270,3 @@ void BurnMD2612Scan(INT32 nAction, INT32* pnMin)
}
}
}
#undef MAX_MD2612

View File

@ -779,8 +779,6 @@ INLINE void INTERNAL_TIMER_A()
ym2612.OPN.ST.TAC--;
if (ym2612.OPN.ST.TAC <= 0)
{
//if (!in_reset)
//BurnMD2612UpdateRequest();
/* set status (if enabled) */
if (ym2612.OPN.ST.mode & 0x04)
ym2612.OPN.ST.status |= 0x01;
@ -1974,14 +1972,16 @@ void MDYM2612Write(unsigned int a, unsigned int v)
default: /* data port */
{
int addr = ym2612.OPN.ST.address; /* verified by Nemesis on real YM2612 */
if (!in_reset)
BurnMD2612UpdateRequest();
switch( addr & 0x1f0 )
{
case 0x20: /* 0x20-0x2f Mode */
switch( addr )
{
case 0x2a: /* DAC data (ym2612) */
if (!in_reset)
BurnMD2612UpdateRequest();
ym2612.dacout = ((int)v - 0x80) << 6; /* convert to 14-bit output */
break;
case 0x2b: /* DAC Sel (ym2612) */
@ -1989,15 +1989,11 @@ void MDYM2612Write(unsigned int a, unsigned int v)
ym2612.dacen = v & 0x80;
break;
default: /* OPN section */
if (!in_reset)
BurnMD2612UpdateRequest();
/* write register */
OPNWriteMode(addr,v);
}
break;
default: /* 0x30-0xff OPN section */
if (!in_reset)
BurnMD2612UpdateRequest();
/* write register */
OPNWriteReg(addr,v);
}
@ -2008,6 +2004,8 @@ void MDYM2612Write(unsigned int a, unsigned int v)
unsigned int MDYM2612Read(void)
{
if (!in_reset)
BurnMD2612UpdateRequest();
return ym2612.OPN.ST.status & 0xff;
}
@ -2162,7 +2160,6 @@ int MDYM2612LoadContext()
{
int c,s;
UINT8 index;
int bufferptr = 0;
/* restore YM2612 context */
SCAN_VAR(ym2612);
@ -2173,7 +2170,6 @@ int MDYM2612LoadContext()
for (s=0; s<4; s++)
{
SCAN_VAR(index);
bufferptr += sizeof(index);
ym2612.CH[c].SLOT[s].DT = ym2612.OPN.ST.dt_tab[index&7];
}
}
@ -2186,14 +2182,13 @@ int MDYM2612LoadContext()
setup_connection(&ym2612.CH[4],4);
setup_connection(&ym2612.CH[5],5);
return bufferptr;
return 0;
}
int MDYM2612SaveContext()
{
int c,s;
UINT8 index;
int bufferptr = 0;
/* save YM2612 context */
SCAN_VAR(ym2612);
@ -2205,9 +2200,8 @@ int MDYM2612SaveContext()
{
index = (ym2612.CH[c].SLOT[s].DT - ym2612.OPN.ST.dt_tab[0]) >> 5;
SCAN_VAR(index);
bufferptr += sizeof(index);
}
}
return bufferptr;
return 0;
}