start SPU work

This commit is contained in:
StapleButter
2017-04-06 19:44:34 +02:00
parent 28cddadfbc
commit 8d66beba6b
6 changed files with 335 additions and 85 deletions

View File

@ -22,6 +22,7 @@
#include "../Config.h"
#include "../NDS.h"
#include "../GPU.h"
#include "../SPU.h"
#include "InputConfig.h"
#include "EmuConfig.h"
@ -86,7 +87,7 @@ bool wxApp_melonDS::OnInit()
printf("melonDS " MELONDS_VERSION "\n" MELONDS_URL "\n");
Config::Load();
emuthread = new EmuThread();
if (emuthread->Run() != wxTHREAD_NO_ERROR)
{
@ -97,7 +98,7 @@ bool wxApp_melonDS::OnInit()
MainFrame* melon = new MainFrame();
melon->Show(true);
melon->emuthread = emuthread;
emuthread->parent = melon;
@ -108,7 +109,7 @@ int wxApp_melonDS::OnExit()
{
emuthread->Wait();
delete emuthread;
return wxApp::OnExit();
}
@ -169,7 +170,7 @@ void MainFrame::OnClose(wxCloseEvent& event)
{
emuthread->EmuPause();
emuthread->EmuExit();
NDS::DeInit();
if (joy)
@ -313,6 +314,11 @@ EmuThread::~EmuThread()
{
}
static void AudioCallback(void* data, Uint8* stream, int len)
{
SPU::ReadOutput((s16*)stream, len>>2);
}
wxThread::ExitCode EmuThread::Entry()
{
emustatus = 3;
@ -344,6 +350,23 @@ wxThread::ExitCode EmuThread::Entry()
botdst.x = 0; botdst.y = 192;
botdst.w = 256; botdst.h = 192;
SDL_AudioSpec whatIwant, whatIget;
memset(&whatIwant, 0, sizeof(SDL_AudioSpec));
whatIwant.freq = 32824; // 32823.6328125
whatIwant.format = AUDIO_S16LSB;
whatIwant.channels = 2;
whatIwant.samples = 1024;
whatIwant.callback = AudioCallback;
audio = SDL_OpenAudioDevice(NULL, 0, &whatIwant, &whatIget, 0);
if (!audio)
{
printf("Audio init failed: %s\n", SDL_GetError());
}
else
{
SDL_PauseAudioDevice(audio, 0);
}
Touching = false;
axismask = 0;
@ -430,9 +453,11 @@ wxThread::ExitCode EmuThread::Entry()
emupaused = true;
}
}
emupaused = true;
if (audio) SDL_CloseAudioDevice(audio);
SDL_DestroyTexture(sdltex);
SDL_DestroyRenderer(sdlrend);
SDL_DestroyWindow(sdlwin);
@ -462,7 +487,7 @@ void EmuThread::ProcessEvents()
{
int w = evt.window.data1;
int h = evt.window.data2;
// SDL_SetWindowMinimumSize() doesn't seem to work on Linux. oh well
if ((w < 256) || (h < 384))
{
@ -514,7 +539,7 @@ void EmuThread::ProcessEvents()
{
Touching = true;
NDS::PressKey(16+6);
int mx, my;
SDL_GetGlobalMouseState(&mx, &my);
txoffset = mx - evt.button.x;