sms fm wip

This commit is contained in:
dinkc64 2015-03-12 14:46:00 +00:00
parent bb7981dd95
commit 7ce977fc6f
6 changed files with 31 additions and 153 deletions

View File

@ -3,6 +3,7 @@
#include "smsshared.h"
#include "z80_intf.h"
#include "sn76496.h"
#include "burn_ym2413.h"
static UINT8 *AllMem;
static UINT8 *MemEnd;
@ -19,6 +20,10 @@ UINT8 SMSDips[3];
static struct BurnDIPInfo SMSDIPList[] = {
{0x11, 0xff, 0xff, 0x00, NULL },
{0 , 0xfe, 0 , 2, "FM Unit Emulation"},
{0x11, 0x01, 0x04, 0x04, "On" },
{0x11, 0x01, 0x04, 0x00, "Off" },
};
STDDIPINFO(SMS)
@ -150,7 +155,7 @@ INT32 SMSFrame()
if(SMSJoy2[8]) input.pad[1] |= INPUT_BUTTON1;
if(SMSJoy1[1]) input.system |= (IS_GG) ? INPUT_START : INPUT_PAUSE;
gg_overscanmode = (SMSDips[0] == 8);
gg_overscanmode = (SMSDips[0] & 0x08);
}
@ -308,7 +313,12 @@ INT32 SMSInit()
snd.sample_rate = 44100;
snd.mixer_callback = NULL;
sms.use_fm = 0;
sms.use_fm = (SMSDips[0] & 0x04);
if (sms.use_fm) {
bprintf(0, _T("Emulating FM\n"));
sms.territory = TERRITORY_DOMESTIC;
sms.console = CONSOLE_SMSJ;
}
system_init();
@ -344,9 +354,12 @@ INT32 SMSScan(INT32 nAction, INT32 *pnMin)
if (nAction & ACB_VOLATILE) {
ZetScan(nAction);
SN76496Scan(nAction, pnMin);
SCAN_VAR(vdp);
SCAN_VAR(sms);
SCAN_VAR(cart.fcr);
if (sms.use_fm) // put it down here so we keep compatibility with non-fm states.
BurnYM2413Scan(nAction);
if (nAction & ACB_WRITE) {
ZetOpen(0);

View File

@ -79,7 +79,7 @@ void sms_init(void)
{
sms.console = CONSOLE_SMSJ;
sms.territory = TERRITORY_DOMESTIC;
sms.display = DISPLAY_NTSC;
sms.display = DISPLAY_NTSC;
}
/* Initialize selected console emulation */

View File

@ -1,165 +1,32 @@
/*
fmintf.c --
Interface to EMU2413 and YM2413 emulators.
Disabled Feb. 24, 2015, saving for possible future use
*/
#include "smsshared.h"
#include "burn_ym2413.h"
//static OPLL *opll;
//FM_Context fm_context;
void FM_Init(void)
{
/* switch(snd.fm_which)
{
case SND_EMU2413:
OPLL_init(snd.fm_clock, snd.sample_rate);
opll = OPLL_new();
OPLL_reset(opll);
OPLL_reset_patch(opll, 0);
break;
case SND_YM2413:
SMSYM2413Init(1, snd.fm_clock, snd.sample_rate);
SMSYM2413ResetChip(0);
break;
}*/
BurnYM2413Init(snd.fm_clock);
BurnYM2413SetAllRoutes(1.00, BURN_SND_ROUTE_BOTH);
}
void FM_Shutdown(void)
{
/* switch(snd.fm_which)
{
case SND_EMU2413:
if(opll)
{
OPLL_delete(opll);
opll = NULL;
}
OPLL_close();
break;
case SND_YM2413:
SMSYM2413Shutdown();
break;
}*/
BurnYM2413Exit();
}
void FM_Reset(void)
{
/* switch(snd.fm_which)
{
case SND_EMU2413:
OPLL_reset(opll);
OPLL_reset_patch(opll, 0);
break;
case SND_YM2413:
SMSYM2413ResetChip(0);
break;
}*/
BurnYM2413Reset();
}
void FM_Update(INT16 **/*buffer*/, INT32 /*length*/)
{
/* switch(snd.fm_which)
{
case SND_EMU2413:
OPLL_update(opll, buffer, length);
break;
case SND_YM2413:
SMSYM2413UpdateOne(0, buffer, length);
break;
}*/
void FM_Write(INT32 offset, INT32 data)
{ bprintf(0, _T("%X[%X],"), offset, data);
BurnYM2413Write(offset, data);
}
void FM_WriteReg(INT32 /*reg*/, INT32 /*data*/)
{
/* FM_Write(0, reg);
FM_Write(1, data);*/
}
void FM_Write(INT32 /*offset*/, INT32 /*data*/)
{
/* if(offset & 1)
fm_context.reg[ fm_context.latch ] = data;
else
fm_context.latch = data;
switch(snd.fm_which)
{
case SND_EMU2413:
OPLL_write(opll, offset & 1, data);
break;
case SND_YM2413:
SMSYM2413Write(0, offset & 1, data);
break;
}*/
}
void FM_GetContext(UINT8 */*data*/)
{
// memcpy(data, &fm_context, sizeof(FM_Context));
}
void FM_SetContext(UINT8 */*data*/)
{
/*
INT32 i;
UINT8 *reg = fm_context.reg;
memcpy(&fm_context, data, sizeof(FM_Context));
// If we are loading a save state, we want to update the YM2413 context
// but not actually write to the current YM2413 emulator.
if(!snd.enabled || !sms.use_fm)
return;
FM_Write(0, 0x0E);
FM_Write(1, reg[0x0E]);
for(i = 0x00; i <= 0x07; i++)
{
FM_Write(0, i);
FM_Write(1, reg[i]);
}
for(i = 0x10; i <= 0x18; i++)
{
FM_Write(0, i);
FM_Write(1, reg[i]);
}
for(i = 0x20; i <= 0x28; i++)
{
FM_Write(0, i);
FM_Write(1, reg[i]);
}
for(i = 0x30; i <= 0x38; i++)
{
FM_Write(0, i);
FM_Write(1, reg[i]);
}
FM_Write(0, fm_context.latch);
*/
}
INT32 FM_GetContextSize(void)
{
return 0; //sizeof(FM_Context);
}
UINT8 *FM_GetContextPtr(void)
{
//return (UINT8 *)&fm_context;
return (UINT8 *)NULL;
}

View File

@ -18,10 +18,4 @@ void FM_Shutdown(void);
void FM_Reset(void);
void FM_Update(INT16 **buffer, INT32 length);
void FM_Write(INT32 offset, INT32 data);
void FM_GetContext(UINT8 *data);
void FM_SetContext(UINT8 *data);
INT32 FM_GetContextSize(void);
UINT8 *FM_GetContextPtr(void);
void FM_WriteReg(INT32 reg, INT32 data);
#endif /* _FMINTF_H_ */

View File

@ -89,12 +89,12 @@ void psg_write(INT32 data)
/*--------------------------------------------------------------------------*/
INT32 fmunit_detect_r(void)
{
{ bprintf(0, _T("fm detect READ [%X]\n"), sms.fm_detect);
return sms.fm_detect;
}
void fmunit_detect_w(INT32 data)
{
{ bprintf(0, _T("fm detect [%X]\n"), data);
sms.fm_detect = data;
}

View File

@ -19,7 +19,7 @@
#include "smsshared.h"
#include "z80_intf.h"
#include "sn76496.h"
#include "burn_ym2413.h"
bitmap_t bitmap;
cart_t cart;
@ -107,6 +107,8 @@ void system_frame(INT32 skip_render)
INT32 nSegmentLength = nBurnSoundLen / lpf;
INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
SN76496Update(0, pSoundBuf, nSegmentLength);
if (sms.use_fm)
BurnYM2413Render(pSoundBuf, nSegmentLength);
nSoundBufferPos += nSegmentLength;
}
@ -122,6 +124,8 @@ void system_frame(INT32 skip_render)
INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
if (nSegmentLength) {
SN76496Update(0, pSoundBuf, nSegmentLength);
if (sms.use_fm)
BurnYM2413Render(pSoundBuf, nSegmentLength);
}
}
}