diff options
author | StapleButter <thetotalworm@gmail.com> | 2017-04-06 19:44:34 +0200 |
---|---|---|
committer | StapleButter <thetotalworm@gmail.com> | 2017-04-06 19:44:34 +0200 |
commit | 8d66beba6bc49f8d1f6cb443745bfd1ffe4008a3 (patch) | |
tree | 3651180e7fef820c2fe841e6accc76a032155080 /src/wx | |
parent | 28cddadfbcc547b8a7b015e219219088bbb2387d (diff) |
start SPU work
Diffstat (limited to 'src/wx')
-rw-r--r-- | src/wx/main.cpp | 39 | ||||
-rw-r--r-- | src/wx/main.h | 6 |
2 files changed, 36 insertions, 9 deletions
diff --git a/src/wx/main.cpp b/src/wx/main.cpp index 85568a4..f3d8ef8 100644 --- a/src/wx/main.cpp +++ b/src/wx/main.cpp @@ -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; diff --git a/src/wx/main.h b/src/wx/main.h index 851a061..0219ff7 100644 --- a/src/wx/main.h +++ b/src/wx/main.h @@ -46,7 +46,7 @@ class wxApp_melonDS : public wxApp public: virtual bool OnInit(); virtual int OnExit(); - + EmuThread* emuthread; }; @@ -91,7 +91,7 @@ public: bool EmuIsRunning() { return (emustatus == 1) || (emustatus == 2); } bool EmuIsPaused() { return (emustatus == 2) && emupaused; } - + MainFrame* parent; protected: @@ -105,6 +105,8 @@ protected: SDL_Rect topsrc, topdst; SDL_Rect botsrc, botdst; + SDL_AudioDeviceID audio; + bool Touching; int txoffset, tyoffset; |