saturn: sound
This commit is contained in:
parent
368bc58d0a
commit
eae4c0ee81
|
@ -15,6 +15,13 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn
|
|||
[DllImport("libyabause.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void libyabause_setvidbuff(IntPtr buff);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="buff">persistent location of s16 interleaved</param>
|
||||
[DllImport("libyabause.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void libyabause_setsndbuff(IntPtr buff);
|
||||
|
||||
/// <summary>
|
||||
/// soft reset, or something like that
|
||||
/// </summary>
|
||||
|
@ -26,8 +33,9 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn
|
|||
/// </summary>
|
||||
/// <param name="w">width of framebuffer</param>
|
||||
/// <param name="h">height of framebuffer</param>
|
||||
/// <param name="nsamp">number of sample pairs produced</param>
|
||||
[DllImport("libyabause.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void libyabause_frameadvance(out int w, out int h);
|
||||
public static extern void libyabause_frameadvance(out int w, out int h, out int nsamp);
|
||||
|
||||
[DllImport("libyabause.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void libyabause_deinit();
|
||||
|
|
|
@ -20,6 +20,9 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn
|
|||
static Yabause AttachedCore = null;
|
||||
GCHandle VideoHandle;
|
||||
DiscSystem.Disc CD;
|
||||
GCHandle SoundHandle;
|
||||
|
||||
bool Disposed = false;
|
||||
|
||||
LibYabause.CDInterface.Init InitH;
|
||||
LibYabause.CDInterface.DeInit DeInitH;
|
||||
|
@ -44,6 +47,7 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn
|
|||
AttachedCore = null;
|
||||
}
|
||||
VideoHandle = GCHandle.Alloc(VideoBuffer, GCHandleType.Pinned);
|
||||
SoundHandle = GCHandle.Alloc(SoundBuffer, GCHandleType.Pinned);
|
||||
|
||||
LibYabause.CDInterface CDInt = new LibYabause.CDInterface();
|
||||
CDInt.InitFunc = InitH = new LibYabause.CDInterface.Init(CD_Init);
|
||||
|
@ -57,7 +61,11 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn
|
|||
throw new Exception("libyabause_init() failed!");
|
||||
|
||||
LibYabause.libyabause_setvidbuff(VideoHandle.AddrOfPinnedObject());
|
||||
LibYabause.libyabause_setsndbuff(SoundHandle.AddrOfPinnedObject());
|
||||
AttachedCore = this;
|
||||
|
||||
BufferWidth = 320;
|
||||
BufferHeight = 224;
|
||||
}
|
||||
|
||||
public ControllerDefinition ControllerDefinition
|
||||
|
@ -69,12 +77,14 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn
|
|||
|
||||
public void FrameAdvance(bool render, bool rendersound = true)
|
||||
{
|
||||
int w, h;
|
||||
LibYabause.libyabause_frameadvance(out w, out h);
|
||||
int w, h, nsamp;
|
||||
LibYabause.libyabause_frameadvance(out w, out h, out nsamp);
|
||||
BufferWidth = w;
|
||||
BufferHeight = h;
|
||||
SoundNSamp = nsamp;
|
||||
Frame++;
|
||||
LagCount++;
|
||||
//Console.WriteLine(nsamp);
|
||||
}
|
||||
|
||||
public int Frame
|
||||
|
@ -164,9 +174,15 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn
|
|||
|
||||
public void Dispose()
|
||||
{
|
||||
LibYabause.libyabause_setvidbuff(IntPtr.Zero);
|
||||
LibYabause.libyabause_deinit();
|
||||
VideoHandle.Free();
|
||||
if (!Disposed)
|
||||
{
|
||||
LibYabause.libyabause_setvidbuff(IntPtr.Zero);
|
||||
LibYabause.libyabause_setsndbuff(IntPtr.Zero);
|
||||
LibYabause.libyabause_deinit();
|
||||
VideoHandle.Free();
|
||||
SoundHandle.Free();
|
||||
Disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
#region IVideoProvider
|
||||
|
@ -183,11 +199,12 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn
|
|||
|
||||
#region ISyncSoundProvider
|
||||
|
||||
short[] SoundBuffer = new short[735 * 2];
|
||||
short[] SoundBuffer = new short[44100 * 2];
|
||||
int SoundNSamp = 0;
|
||||
|
||||
public void GetSamples(out short[] samples, out int nsamp)
|
||||
{
|
||||
nsamp = 735;
|
||||
nsamp = SoundNSamp;
|
||||
samples = SoundBuffer;
|
||||
}
|
||||
|
||||
|
@ -324,7 +341,6 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn
|
|||
// ignored for now
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -151,10 +151,6 @@
|
|||
<ClInclude Include="..\sh2int.h" />
|
||||
<ClInclude Include="..\sh2trace.h" />
|
||||
<ClInclude Include="..\smpc.h" />
|
||||
<ClInclude Include="..\sndal.h" />
|
||||
<ClInclude Include="..\snddx.h" />
|
||||
<ClInclude Include="..\sndmac.h" />
|
||||
<ClInclude Include="..\sndsdl.h" />
|
||||
<ClInclude Include="..\threads.h" />
|
||||
<ClInclude Include="..\titan\titan.h" />
|
||||
<ClInclude Include="..\vdp1.h" />
|
||||
|
|
|
@ -230,18 +230,6 @@
|
|||
<ClInclude Include="..\smpc.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\sndal.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\snddx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\sndmac.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\sndsdl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\threads.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -22,6 +22,8 @@ CDInterface FECD =
|
|||
NULL,
|
||||
};
|
||||
|
||||
SoundInterface_struct FESND;
|
||||
|
||||
|
||||
extern "C" SH2Interface_struct *SH2CoreList[] = {
|
||||
&SH2Interpreter,
|
||||
|
@ -43,6 +45,7 @@ NULL
|
|||
|
||||
extern "C" SoundInterface_struct *SNDCoreList[] = {
|
||||
&SNDDummy,
|
||||
&FESND,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -98,6 +101,9 @@ int YuiSetVideoMode(int width, int height, int bpp, int fullscreen)
|
|||
return 0; // success
|
||||
}
|
||||
|
||||
|
||||
s16 *sndbuff = NULL;
|
||||
int sndbuffpos = 0;
|
||||
u32 *vidbuff = NULL;
|
||||
|
||||
extern "C" int vdp2height;
|
||||
|
@ -125,9 +131,30 @@ void YuiSwapBuffers(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void FESNDUpdateAudio(UNUSED u32 *leftchanbuffer, UNUSED u32 *rightchanbuffer, UNUSED u32 num_samples)
|
||||
{
|
||||
/*
|
||||
static s16 stereodata16[44100 / 50];
|
||||
ScspConvert32uto16s((s32 *)leftchanbuffer, (s32 *)rightchanbuffer, (s16 *)stereodata16, num_samples);
|
||||
*/
|
||||
}
|
||||
|
||||
static u32 FESNDGetAudioSpace(void)
|
||||
{
|
||||
return 44100;
|
||||
}
|
||||
// some garbage from the sound system, we'll have to fix this all up
|
||||
extern "C" void DRV_AviSoundUpdate(void* soundData, int soundLen)
|
||||
{
|
||||
// soundLen should be number of sample pairs (4 byte units)
|
||||
if (sndbuff)
|
||||
{
|
||||
s16 *src = (s16*)soundData;
|
||||
s16 *dst = sndbuff;
|
||||
dst += sndbuffpos * 2;
|
||||
memcpy (dst, src, soundLen * 4);
|
||||
sndbuffpos += soundLen;
|
||||
}
|
||||
}
|
||||
|
||||
// must hold at least 704x512 pixels
|
||||
|
@ -136,16 +163,23 @@ extern "C" __declspec(dllexport) void libyabause_setvidbuff(u32 *buff)
|
|||
vidbuff = buff;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void libyabause_setsndbuff(s16 *buff)
|
||||
{
|
||||
sndbuff = buff;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void libyabause_softreset()
|
||||
{
|
||||
YabauseResetButton();
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void libyabause_frameadvance(int *w, int *h)
|
||||
extern "C" __declspec(dllexport) void libyabause_frameadvance(int *w, int *h, int *nsamp)
|
||||
{
|
||||
sndbuffpos = 0;
|
||||
YabauseEmulate();
|
||||
*w = vdp2width;
|
||||
*h = vdp2height;
|
||||
*nsamp = sndbuffpos;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void libyabause_deinit()
|
||||
|
@ -162,12 +196,19 @@ extern "C" __declspec(dllexport) int libyabause_init(CDInterface *_CD)
|
|||
FECD.ReadSectorFAD = _CD->ReadSectorFAD;
|
||||
FECD.ReadTOC = _CD->ReadTOC;
|
||||
|
||||
// only overwrite a few SNDDummy functions
|
||||
memcpy(&FESND, &SNDDummy, sizeof(FESND));
|
||||
FESND.id = 2;
|
||||
FESND.Name = "FESND";
|
||||
FESND.GetAudioSpace = FESNDGetAudioSpace;
|
||||
FESND.UpdateAudio = FESNDUpdateAudio;
|
||||
|
||||
yabauseinit_struct yinit;
|
||||
memset(&yinit, 0, sizeof(yabauseinit_struct));
|
||||
yinit.percoretype = PERCORE_DUMMY;
|
||||
yinit.sh2coretype = SH2CORE_INTERPRETER;
|
||||
yinit.vidcoretype = VIDCORE_SOFT;
|
||||
yinit.sndcoretype = SNDCORE_DUMMY;
|
||||
yinit.sndcoretype = 2; //SNDCORE_DUMMY;
|
||||
yinit.cdcoretype = 2; // CDCORE_ISO; //CDCORE_DUMMY;
|
||||
yinit.m68kcoretype = M68KCORE_C68K;
|
||||
yinit.cartpath = CART_NONE;
|
||||
|
@ -183,5 +224,9 @@ extern "C" __declspec(dllexport) int libyabause_init(CDInterface *_CD)
|
|||
if (YabauseInit(&yinit) != 0)
|
||||
return 0;
|
||||
|
||||
SpeedThrottleDisable();
|
||||
DisableAutoFrameSkip();
|
||||
ScspSetFrameAccurate(1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue