From dac9ccc57787125a75fa77db1cdf0a7d2bda79d3 Mon Sep 17 00:00:00 2001 From: RSDuck Date: Mon, 17 Jun 2019 13:14:52 +0200 Subject: fix OGL renderer not working at all on some GPUs --- src/GPU3D_OpenGL.cpp | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/GPU3D_OpenGL.cpp b/src/GPU3D_OpenGL.cpp index 0d86690..92fdfe8 100644 --- a/src/GPU3D_OpenGL.cpp +++ b/src/GPU3D_OpenGL.cpp @@ -342,36 +342,11 @@ bool Init() SetupDefaultTexParams(FramebufferTex[7]); // downscale framebuffer for antialiased mode - glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[2]); SetupDefaultTexParams(FramebufferTex[2]); // downscale framebuffer for display capture (always 256x192) - glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[3]); SetupDefaultTexParams(FramebufferTex[3]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 192, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, FramebufferTex[3], 0); - - GLenum fbassign[2] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1}; - - glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[0]); - glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, FramebufferTex[0], 0); - glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, FramebufferTex[4], 0); - glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, FramebufferTex[5], 0); - glDrawBuffers(2, fbassign); - - glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[1]); - glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, FramebufferTex[1], 0); - glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, FramebufferTex[4], 0); - glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, FramebufferTex[5], 0); - glDrawBuffers(2, fbassign); - - glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[2]); - glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, FramebufferTex[2], 0); - glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, FramebufferTex[6], 0); - glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, FramebufferTex[7], 0); - glDrawBuffers(2, fbassign); - - glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[0]); glEnable(GL_BLEND); glBlendEquationSeparate(GL_FUNC_ADD, GL_MAX); @@ -475,6 +450,31 @@ void UpdateDisplaySettings() glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8UI, ScreenW, ScreenH, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, NULL); } + glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[3]); + glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, FramebufferTex[3], 0); + + GLenum fbassign[2] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1}; + + glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[0]); + glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, FramebufferTex[0], 0); + glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, FramebufferTex[4], 0); + glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, FramebufferTex[5], 0); + glDrawBuffers(2, fbassign); + + glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[1]); + glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, FramebufferTex[1], 0); + glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, FramebufferTex[4], 0); + glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, FramebufferTex[5], 0); + glDrawBuffers(2, fbassign); + + glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[2]); + glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, FramebufferTex[2], 0); + glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, FramebufferTex[6], 0); + glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, FramebufferTex[7], 0); + glDrawBuffers(2, fbassign); + + glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[0]); + glBindBuffer(GL_PIXEL_PACK_BUFFER, PixelbufferID); glBufferData(GL_PIXEL_PACK_BUFFER, 256*192*4, NULL, GL_DYNAMIC_READ); -- cgit v1.2.3 From 6d01677a57616e06f8a56475c53fdc9487594e3c Mon Sep 17 00:00:00 2001 From: Arisotura Date: Thu, 20 Jun 2019 13:57:14 +0200 Subject: add 32bit writes to some IO ports. fixes #313 --- src/NDS.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/NDS.cpp b/src/NDS.cpp index ea34103..37053a4 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -1548,7 +1548,7 @@ void debug(u32 param) // printf("VRAM %c: %02X\n", 'A'+i, GPU::VRAMCNT[i]); FILE* - shit = fopen("debug/card.bin", "wb"); + shit = fopen("debug/manic.bin", "wb"); for (u32 i = 0x02000000; i < 0x02400000; i+=4) { u32 val = ARM7Read32(i); @@ -2819,6 +2819,11 @@ void ARM9IOWrite32(u32 addr, u32 val) { switch (addr) { + case 0x04000004: + GPU::SetDispStat(0, val & 0xFFFF); + GPU::SetVCount(val >> 16); + return; + case 0x04000060: GPU3D::Write32(addr, val); return; case 0x04000064: case 0x04000068: GPU::GPU2D_A->Write32(addr, val); return; @@ -3382,6 +3387,11 @@ void ARM7IOWrite32(u32 addr, u32 val) { switch (addr) { + case 0x04000004: + GPU::SetDispStat(1, val & 0xFFFF); + GPU::SetVCount(val >> 16); + return; + case 0x040000B0: DMAs[4]->SrcAddr = val; return; case 0x040000B4: DMAs[4]->DstAddr = val; return; case 0x040000B8: DMAs[4]->WriteCnt(val); return; @@ -3465,6 +3475,8 @@ void ARM7IOWrite32(u32 addr, u32 val) case 0x04000210: IE[1] = val; UpdateIRQ(1); return; case 0x04000214: IF[1] &= ~val; UpdateIRQ(1); return; + case 0x04000304: PowerControl7 = val & 0xFFFF; return; + case 0x04000308: if (ARM7BIOSProt == 0) ARM7BIOSProt = val & 0xFFFE; -- cgit v1.2.3 From f59094e033fafc28664700061e2726be70a1568c Mon Sep 17 00:00:00 2001 From: Arisotura Date: Thu, 20 Jun 2019 16:00:12 +0200 Subject: OpenGL: disable vsync, atleast under Windows --- src/libui_sdl/libui/ui.h | 1 + src/libui_sdl/libui/unix/gl.c | 5 +++++ src/libui_sdl/libui/windows/gl.cpp | 35 +++++++++++++++++++++++++++++++++++ src/libui_sdl/main.cpp | 1 + 4 files changed, 42 insertions(+) diff --git a/src/libui_sdl/libui/ui.h b/src/libui_sdl/libui/ui.h index e15c127..03aef5d 100644 --- a/src/libui_sdl/libui/ui.h +++ b/src/libui_sdl/libui/ui.h @@ -620,6 +620,7 @@ _UI_EXTERN void *uiGLGetProcAddress(const char* proc); _UI_EXTERN int uiGLGetFramebuffer(uiGLContext* ctx); _UI_EXTERN float uiGLGetFramebufferScale(uiGLContext* ctx); _UI_EXTERN void uiGLSwapBuffers(uiGLContext* ctx); +_UI_EXTERN void uiGLSetVSync(int sync); _UI_ENUM(uiModifiers) { diff --git a/src/libui_sdl/libui/unix/gl.c b/src/libui_sdl/libui/unix/gl.c index e1665ee..e15cf4f 100644 --- a/src/libui_sdl/libui/unix/gl.c +++ b/src/libui_sdl/libui/unix/gl.c @@ -193,6 +193,11 @@ void uiGLSwapBuffers(uiGLContext* ctx) ctx->backbuffer = ctx->backbuffer ? 0 : 1; } +void uiGLSetVSync(int sync) +{ + // TODO +} + void uiGLMakeContextCurrent(uiGLContext* ctx) { if (!ctx) diff --git a/src/libui_sdl/libui/windows/gl.cpp b/src/libui_sdl/libui/windows/gl.cpp index c621721..07ef19b 100644 --- a/src/libui_sdl/libui/windows/gl.cpp +++ b/src/libui_sdl/libui/windows/gl.cpp @@ -3,6 +3,7 @@ #include "area.hpp" #include +#include #include struct uiGLContext @@ -159,3 +160,37 @@ float uiGLGetFramebufferScale(uiGLContext* ctx) // TODO return 1; } + +void uiGLSetVSync(int sync) +{ + static PFNWGLSWAPINTERVALEXTPROC _wglSwapIntervalEXT = NULL; + static bool symloaded = false; + + if (!symloaded) + { + PFNGLGETSTRINGIPROC _glGetStringi = (PFNGLGETSTRINGIPROC)wglGetProcAddress("glGetStringi"); + if (_glGetStringi == NULL) return; + + GLint numext; + glGetIntegerv(GL_NUM_EXTENSIONS, &numext); + + bool hasswapctrl = false; + for (GLint i = 0; i < numext; i++) + { + const char* ext = (const char*)_glGetStringi(GL_EXTENSIONS, i); + if (!stricmp(ext, "WGL_EXT_swap_control")) + { + hasswapctrl = true; + break; + } + } + + if (hasswapctrl) + _wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); + + symloaded = true; + } + + if (_wglSwapIntervalEXT) + _wglSwapIntervalEXT(sync); +} diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 86949eb..693e9e3 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -2417,6 +2417,7 @@ void CreateMainWindow(bool opengl) if (opengl_good) { uiGLMakeContextCurrent(GLContext); + uiGLSetVSync(0); // TODO: make configurable? if (!GLScreen_Init()) opengl_good = false; if (opengl_good) { -- cgit v1.2.3 From e2dc98d1449c3e6682837f04eda60814f8d6a5fc Mon Sep 17 00:00:00 2001 From: Arisotura Date: Thu, 20 Jun 2019 16:31:28 +0200 Subject: fix bug when mapping a joystick axis control but no button --- src/libui_sdl/DlgInputConfig.cpp | 33 +++++++++++++++++++++------------ src/libui_sdl/main.cpp | 37 +++++++++++++++++++++---------------- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/src/libui_sdl/DlgInputConfig.cpp b/src/libui_sdl/DlgInputConfig.cpp index 8882275..3818c04 100644 --- a/src/libui_sdl/DlgInputConfig.cpp +++ b/src/libui_sdl/DlgInputConfig.cpp @@ -125,21 +125,30 @@ void JoyMappingName(int id, char* str) return; } - if (id & 0x100) + bool hasbtn = ((id & 0xFFFF) != 0xFFFF); + + if (hasbtn) { - int hatnum = ((id >> 4) & 0xF) + 1; + if (id & 0x100) + { + int hatnum = ((id >> 4) & 0xF) + 1; - switch (id & 0xF) + switch (id & 0xF) + { + case 0x1: sprintf(str, "Hat %d up", hatnum); break; + case 0x2: sprintf(str, "Hat %d right", hatnum); break; + case 0x4: sprintf(str, "Hat %d down", hatnum); break; + case 0x8: sprintf(str, "Hat %d left", hatnum); break; + } + } + else { - case 0x1: sprintf(str, "Hat %d up", hatnum); break; - case 0x2: sprintf(str, "Hat %d right", hatnum); break; - case 0x4: sprintf(str, "Hat %d down", hatnum); break; - case 0x8: sprintf(str, "Hat %d left", hatnum); break; + sprintf(str, "Button %d", (id & 0xFFFF) + 1); } } else { - sprintf(str, "Button %d", (id & 0xFFFF) + 1); + strcpy(str, ""); } if (id & 0x10000) @@ -151,9 +160,9 @@ void JoyMappingName(int id, char* str) switch ((id >> 20) & 0xF) { - case 0: sprintf(str, "%s / Axis %d +", tmp, axisnum); break; - case 1: sprintf(str, "%s / Axis %d -", tmp, axisnum); break; - case 2: sprintf(str, "%s / Trigger %d", tmp, axisnum); break; + case 0: sprintf(str, "%s%sAxis %d +", tmp, hasbtn?" / ":"", axisnum); break; + case 1: sprintf(str, "%s%sAxis %d -", tmp, hasbtn?" / ":"", axisnum); break; + case 2: sprintf(str, "%s%sTrigger %d", tmp, hasbtn?" / ":"", axisnum); break; } } } @@ -287,7 +296,7 @@ Uint32 JoyPoll(Uint32 interval, void* param) } int oldmap; - if (dlg->joymap[id] == -1) oldmap = 0; + if (dlg->joymap[id] == -1) oldmap = 0xFFFF; else oldmap = dlg->joymap[id]; int nbuttons = SDL_JoystickNumButtons(joy); diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 693e9e3..01f67d7 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -710,26 +710,31 @@ bool JoystickButtonDown(int val) { if (val == -1) return false; - if (val & 0x100) + bool hasbtn = ((val & 0xFFFF) != 0xFFFF); + + if (hasbtn) { - int hatnum = (val >> 4) & 0xF; - int hatdir = val & 0xF; - Uint8 hatval = SDL_JoystickGetHat(Joystick, hatnum); + if (val & 0x100) + { + int hatnum = (val >> 4) & 0xF; + int hatdir = val & 0xF; + Uint8 hatval = SDL_JoystickGetHat(Joystick, hatnum); - bool pressed = false; - if (hatdir == 0x1) pressed = (hatval & SDL_HAT_UP); - else if (hatdir == 0x4) pressed = (hatval & SDL_HAT_DOWN); - else if (hatdir == 0x2) pressed = (hatval & SDL_HAT_RIGHT); - else if (hatdir == 0x8) pressed = (hatval & SDL_HAT_LEFT); + bool pressed = false; + if (hatdir == 0x1) pressed = (hatval & SDL_HAT_UP); + else if (hatdir == 0x4) pressed = (hatval & SDL_HAT_DOWN); + else if (hatdir == 0x2) pressed = (hatval & SDL_HAT_RIGHT); + else if (hatdir == 0x8) pressed = (hatval & SDL_HAT_LEFT); - if (pressed) return true; - } - else - { - int btnnum = val & 0xFFFF; - Uint8 btnval = SDL_JoystickGetButton(Joystick, btnnum); + if (pressed) return true; + } + else + { + int btnnum = val & 0xFFFF; + Uint8 btnval = SDL_JoystickGetButton(Joystick, btnnum); - if (btnval) return true; + if (btnval) return true; + } } if (val & 0x10000) -- cgit v1.2.3 From 49b2f8d9694d7f91ad4d735a95044dee6828aec9 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Tue, 25 Jun 2019 02:05:48 +0200 Subject: raise kMaxIterationCycles to 64 --- src/GPU2D.cpp | 5 +++++ src/NDS.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/GPU2D.cpp b/src/GPU2D.cpp index e0da772..3375d45 100644 --- a/src/GPU2D.cpp +++ b/src/GPU2D.cpp @@ -246,6 +246,11 @@ u8 GPU2D::Read8(u32 addr) case 0x049: return WinCnt[1]; case 0x04A: return WinCnt[2]; case 0x04B: return WinCnt[3]; + + // there are games accidentally trying to read those + // those are write-only + case 0x04C: + case 0x04D: return 0; } printf("unknown GPU read8 %08X\n", addr); diff --git a/src/NDS.cpp b/src/NDS.cpp index 37053a4..6272f88 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -69,7 +69,7 @@ u64 FrameStartTimestamp; int CurCPU; -const s32 kMaxIterationCycles = 16; +const s32 kMaxIterationCycles = 64; u32 ARM9ClockShift; -- cgit v1.2.3 From 58575f82b7453c16616333e043651a57ea713eb6 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Tue, 25 Jun 2019 12:29:56 +0200 Subject: libui/windows: backport fix for #471 --- src/libui_sdl/libui/windows/window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libui_sdl/libui/windows/window.cpp b/src/libui_sdl/libui/windows/window.cpp index 18d1171..a8f7f23 100644 --- a/src/libui_sdl/libui/windows/window.cpp +++ b/src/libui_sdl/libui/windows/window.cpp @@ -95,7 +95,7 @@ static LRESULT CALLBACK windowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA // not a menu if (lParam != 0) break; - if (HIWORD(wParam) != 0) + if (HIWORD(wParam) != 0 || LOWORD(wParam) <= IDCANCEL) break; runMenuEvent(LOWORD(wParam), uiWindow(w)); return 0; -- cgit v1.2.3 From 1d8902c631da44756d80db1bb303dba3aab19dea Mon Sep 17 00:00:00 2001 From: Arisotura Date: Tue, 25 Jun 2019 13:09:06 +0200 Subject: remove stupid hack that caused more problems than it fixed --- src/GPU3D_OpenGL_shaders.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/GPU3D_OpenGL_shaders.h b/src/GPU3D_OpenGL_shaders.h index afe7518..2545ee0 100644 --- a/src/GPU3D_OpenGL_shaders.h +++ b/src/GPU3D_OpenGL_shaders.h @@ -656,7 +656,7 @@ void main() int zshift = (attr >> 16) & 0x1F; vec4 fpos; - fpos.xy = (((vec2(vPosition.xy) + 0.5) * 2.0) / uScreenSize) - 1.0; + fpos.xy = (((vec2(vPosition.xy) ) * 2.0) / uScreenSize) - 1.0; fpos.z = (float(vPosition.z << zshift) / 8388608.0) - 1.0; fpos.w = float(vPosition.w) / 65536.0f; fpos.xyz *= fpos.w; @@ -679,7 +679,7 @@ void main() int zshift = (attr >> 16) & 0x1F; vec4 fpos; - fpos.xy = (((vec2(vPosition.xy) + 0.5) * 2.0) / uScreenSize) - 1.0; + fpos.xy = (((vec2(vPosition.xy) ) * 2.0) / uScreenSize) - 1.0; fZ = float(vPosition.z << zshift) / 16777216.0; fpos.w = float(vPosition.w) / 65536.0f; fpos.xy *= fpos.w; -- cgit v1.2.3 From 4d775dcf8578c0ded92d39917a2a60c70e248e70 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Tue, 25 Jun 2019 17:37:32 +0200 Subject: fix OpenGL deinit when closing emu --- src/libui_sdl/main.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 01f67d7..1e91e15 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -1049,6 +1049,12 @@ int EmuThreadFunc(void* burp) return 44203; } +void StopEmuThread() +{ + EmuRunning = 0; + SDL_WaitThread(EmuThread, NULL); +} + void OnAreaDraw(uiAreaHandler* handler, uiArea* area, uiAreaDrawParams* params) { @@ -1856,6 +1862,7 @@ int OnCloseWindow(uiWindow* window, void* blarg) while (EmuStatus != 3); CloseAllDialogs(); + StopEmuThread(); uiQuit(); return 1; } @@ -1893,6 +1900,7 @@ void OnCloseByMenu(uiMenuItem* item, uiWindow* window, void* blarg) while (EmuStatus != 3); CloseAllDialogs(); + StopEmuThread(); DestroyMainWindow(); uiQuit(); } @@ -2691,9 +2699,6 @@ int main(int argc, char** argv) uiMain(); - EmuRunning = 0; - SDL_WaitThread(EmuThread, NULL); - if (Joystick) SDL_JoystickClose(Joystick); if (AudioDevice) SDL_CloseAudioDevice(AudioDevice); if (MicDevice) SDL_CloseAudioDevice(MicDevice); -- cgit v1.2.3 From 204b5d87006f05a2b27fa908201146ac98c1ac62 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Tue, 25 Jun 2019 19:29:21 +0200 Subject: HARK HARK HARK --- README.md | 2 +- melon.rc | 8 ++++---- src/GPU3D_OpenGL.cpp | 5 ++++- src/libui_sdl/main.cpp | 4 ++-- src/version.h | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 293af51..7fabcaf 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

melonDS

- +

diff --git a/melon.rc b/melon.rc index c1d773d..15535c3 100644 --- a/melon.rc +++ b/melon.rc @@ -6,8 +6,8 @@ //include version information in .exe, modify these values to match your needs 1 VERSIONINFO -FILEVERSION 0,8,1,0 -PRODUCTVERSION 0,8,1,0 +FILEVERSION 0,8,2,0 +PRODUCTVERSION 0,8,2,0 FILETYPE VFT_APP { BLOCK "StringFileInfo" @@ -15,14 +15,14 @@ FILETYPE VFT_APP BLOCK "040904E4" { VALUE "CompanyName", "Melon Factory of Kuribo64" - VALUE "FileVersion", "0.8.1" + VALUE "FileVersion", "0.8.2" VALUE "FileDescription", "DS emulator, sorta. also 1st quality melon." VALUE "InternalName", "SDnolem" VALUE "LegalCopyright", "2016-2019 Arisotura & co." VALUE "LegalTrademarks", "" VALUE "OriginalFilename", "zafkflzdasd.exe" VALUE "ProductName", "melonDS" - VALUE "ProductVersion", "0.8.1" + VALUE "ProductVersion", "0.8.2" } } BLOCK "VarFileInfo" diff --git a/src/GPU3D_OpenGL.cpp b/src/GPU3D_OpenGL.cpp index 92fdfe8..d616e1c 100644 --- a/src/GPU3D_OpenGL.cpp +++ b/src/GPU3D_OpenGL.cpp @@ -479,7 +479,7 @@ void UpdateDisplaySettings() glBufferData(GL_PIXEL_PACK_BUFFER, 256*192*4, NULL, GL_DYNAMIC_READ); //glLineWidth(scale); - glLineWidth(1.5); + //glLineWidth(1.5); } @@ -743,6 +743,7 @@ void RenderSceneChunk(int y, int h) // pass 1: opaque pixels UseRenderShader(flags); + glLineWidth(1.0); glColorMaski(1, GL_TRUE, GL_TRUE, fogenable, GL_FALSE); @@ -774,6 +775,7 @@ void RenderSceneChunk(int y, int h) if (RenderDispCnt & (1<<5)) { UseRenderShader(flags | RenderFlag_Edge); + glLineWidth(1.5); glColorMaski(0, GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glColorMaski(1, GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE); @@ -806,6 +808,7 @@ void RenderSceneChunk(int y, int h) glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ONE); UseRenderShader(flags | RenderFlag_Trans); + glLineWidth(1.0); if (NumOpaqueFinalPolys > -1) { diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 1e91e15..99d4e3f 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -1223,8 +1223,8 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt) KeyHotkeyMask |= (1<Scancode == 0x57) // F11 - NDS::debug(0); + //if (evt->Scancode == 0x57) // F11 + // NDS::debug(0); } return 1; diff --git a/src/version.h b/src/version.h index cc15c89..0d71ed8 100644 --- a/src/version.h +++ b/src/version.h @@ -19,7 +19,7 @@ #ifndef VERSION_H #define VERSION_H -#define MELONDS_VERSION "0.8.1" +#define MELONDS_VERSION "0.8.2" #define MELONDS_URL "http://melonds.kuribo64.net/" -- cgit v1.2.3 From 1b98a3e3a0aabb32fd233832d143968cc1509a57 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Thu, 27 Jun 2019 14:05:51 +0200 Subject: fix 'shift by register' operands: always only take the lower 8 bits of the register, fix handling for LSL/LSR >32 fixes #479 --- src/ARMInterpreter_ALU.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ARMInterpreter_ALU.cpp b/src/ARMInterpreter_ALU.cpp index f23d6b2..d60d8f8 100644 --- a/src/ARMInterpreter_ALU.cpp +++ b/src/ARMInterpreter_ALU.cpp @@ -106,12 +106,12 @@ namespace ARMInterpreter x = ROR(x, (s&0x1F)); #define LSL_REG_S(x, s) \ - if (s > 31) { cpu->SetC(x & (1<<0)); x = 0; } \ - else if (s > 0) { cpu->SetC(x & (1<<(32-s))); x <<= s; } + if (s > 31) { cpu->SetC((s>32) ? 0 : (x & (1<<0))); x = 0; } \ + else if (s > 0) { cpu->SetC(x & (1<<(32-s))); x <<= s; } #define LSR_REG_S(x, s) \ - if (s > 31) { cpu->SetC(x & (1<<31)); x = 0; } \ - else if (s > 0) { cpu->SetC(x & (1<<(s-1))); x >>= s; } + if (s > 31) { cpu->SetC((s>32) ? 0 : (x & (1<<31))); x = 0; } \ + else if (s > 0) { cpu->SetC(x & (1<<(s-1))); x >>= s; } #define ASR_REG_S(x, s) \ if (s > 31) { cpu->SetC(x & (1<<31)); x = ((s32)x) >> 31; } \ @@ -134,7 +134,7 @@ namespace ARMInterpreter #define A_CALC_OP2_REG_SHIFT_REG(shiftop) \ u32 b = cpu->R[cpu->CurInstr&0xF]; \ if ((cpu->CurInstr&0xF)==15) b += 4; \ - shiftop(b, cpu->R[(cpu->CurInstr>>8)&0xF]); + shiftop(b, (cpu->R[(cpu->CurInstr>>8)&0xF] & 0xFF)); #define A_IMPLEMENT_ALU_OP(x,s) \ -- cgit v1.2.3 From 36f1e6f475a2102d1f931423903dc327bf076e9d Mon Sep 17 00:00:00 2001 From: Arisotura Date: Sun, 30 Jun 2019 16:57:30 +0200 Subject: remove glBindImageTexture (4.2) --- src/OpenGLSupport.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/OpenGLSupport.h b/src/OpenGLSupport.h index fbc100c..a08bcdf 100644 --- a/src/OpenGLSupport.h +++ b/src/OpenGLSupport.h @@ -112,8 +112,6 @@ func(GLGETUNIFORMLOCATION, glGetUniformLocation); \ func(GLGETUNIFORMBLOCKINDEX, glGetUniformBlockIndex); \ \ - func(GLBINDIMAGETEXTURE, glBindImageTexture); \ - \ func(GLDRAWBUFFERS, glDrawBuffers); \ \ func(GLBLENDFUNCSEPARATE, glBlendFuncSeparate); \ -- cgit v1.2.3 From 592e493a7aae701957d1a5c05ef8d31c5187ed8c Mon Sep 17 00:00:00 2001 From: Arisotura Date: Tue, 9 Jul 2019 18:39:50 +0200 Subject: input: don't check modifiers for regular input --- src/NDS.cpp | 3 ++- src/libui_sdl/main.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/NDS.cpp b/src/NDS.cpp index 6272f88..991995d 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -1548,7 +1548,8 @@ void debug(u32 param) // printf("VRAM %c: %02X\n", 'A'+i, GPU::VRAMCNT[i]); FILE* - shit = fopen("debug/manic.bin", "wb"); + shit = fopen("debug/party.bin", "wb"); + fwrite(ARM9->ITCM, 0x8000, 1, shit); for (u32 i = 0x02000000; i < 0x02400000; i+=4) { u32 val = ARM7Read32(i); diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 99d4e3f..e2d50ff 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -1168,13 +1168,13 @@ void OnAreaDragBroken(uiAreaHandler* handler, uiArea* area) { } -bool EventMatchesKey(uiAreaKeyEvent* evt, int val) +bool EventMatchesKey(uiAreaKeyEvent* evt, int val, bool checkmod) { if (val == -1) return false; int key = val & 0xFFFF; int mod = val >> 16; - return evt->Scancode == key && evt->Modifiers == mod; + return evt->Scancode == key && (!checkmod || evt->Modifiers == mod); } int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt) @@ -1188,11 +1188,11 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt) if (evt->Up) { for (int i = 0; i < 12; i++) - if (EventMatchesKey(evt, Config::KeyMapping[i])) + if (EventMatchesKey(evt, Config::KeyMapping[i], false)) KeyInputMask |= (1<Repeat) @@ -1215,11 +1215,11 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt) } for (int i = 0; i < 12; i++) - if (EventMatchesKey(evt, Config::KeyMapping[i])) + if (EventMatchesKey(evt, Config::KeyMapping[i], false)) KeyInputMask &= ~(1< Date: Tue, 9 Jul 2019 18:41:44 +0200 Subject: don't allow modifier mappings in input config dialog, either --- src/libui_sdl/DlgInputConfig.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libui_sdl/DlgInputConfig.cpp b/src/libui_sdl/DlgInputConfig.cpp index 3818c04..a80e2ec 100644 --- a/src/libui_sdl/DlgInputConfig.cpp +++ b/src/libui_sdl/DlgInputConfig.cpp @@ -232,10 +232,12 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt) // set key. if (evt->Scancode != 0x1 || evt->Modifiers != 0) // ESC { + int mod = (dlg->type == 0) ? 0 : evt->Modifiers; + if (evt->Scancode == 0xE && evt->Modifiers == 0) // backspace dlg->keymap[dlg->pollid] = -1; else - dlg->keymap[dlg->pollid] = evt->Scancode | (evt->Modifiers << 16); + dlg->keymap[dlg->pollid] = evt->Scancode | (mod << 16); } char keyname[64]; -- cgit v1.2.3 From ff27036b3566d0c4215cacf09d44486d46cfc049 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Fri, 12 Jul 2019 22:04:55 +0200 Subject: start botching the FPS limiter results in shitty audio because it's overflowing the buffer --- src/SPU.cpp | 1 + src/libui_sdl/main.cpp | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/SPU.cpp b/src/SPU.cpp index ee9237f..2dfdf44 100644 --- a/src/SPU.cpp +++ b/src/SPU.cpp @@ -734,6 +734,7 @@ void Mix(u32 samples) OutputBuffer[OutputWriteOffset + 1] = r >> 1; OutputWriteOffset += 2; OutputWriteOffset &= ((2*OutputBufferSize)-1); + if (OutputWriteOffset == OutputReadOffset) printf("!! SOUND FIFO OVERFLOW\n"); } NDS::ScheduleEvent(NDS::Event_SPU, true, 1024*kSamplesPerRun, Mix, kSamplesPerRun); diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index e2d50ff..a19495b 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -569,7 +569,7 @@ void AudioCallback(void* data, Uint8* stream, int len) int num_in = SPU::ReadOutput(buf_in, 710); int num_out = 1024; - +printf("took %d/%d samples\n", num_in, 710); int margin = 6; if (num_in < 710-margin) { @@ -962,7 +962,7 @@ int EmuThreadFunc(void* burp) // framerate limiter based off SDL2_gfx float framerate = (1000.0f * nlines) / (60.0f * 263.0f); - fpslimitcount++; + /*fpslimitcount++; u32 curtick = SDL_GetTicks(); u32 delay = curtick - lasttick; lasttick = curtick; @@ -978,6 +978,24 @@ int EmuThreadFunc(void* burp) { fpslimitcount = 0; starttick = curtick; + }*/ + + fpslimitcount++; + if (fpslimitcount >= 3) + { + u32 curtick = SDL_GetTicks(); + u32 delay = curtick - lasttick; + + bool limitfps = Config::LimitFPS && !HotkeyDown(HK_FastForward); + + u32 wantedtick = lasttick + (u32)((float)fpslimitcount * framerate); + if (curtick < wantedtick && limitfps) + { + SDL_Delay(wantedtick - curtick); + } + + lasttick = SDL_GetTicks(); + fpslimitcount = 0; } nframes++; -- cgit v1.2.3 From 22f3cae0677d07033289689d536f4f515ea3274d Mon Sep 17 00:00:00 2001 From: Arisotura Date: Sat, 13 Jul 2019 02:54:14 +0200 Subject: fix potential out-of-bounds write --- src/GPU.cpp | 1 + src/GPU2D.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/GPU.cpp b/src/GPU.cpp index dcd79b4..071d5f6 100644 --- a/src/GPU.cpp +++ b/src/GPU.cpp @@ -284,6 +284,7 @@ void SetDisplaySettings(bool accel) if (Framebuffer[1][0]) delete[] Framebuffer[1][0]; if (Framebuffer[0][1]) delete[] Framebuffer[0][1]; if (Framebuffer[1][1]) delete[] Framebuffer[1][1]; + Framebuffer[0][0] = new u32[fbsize]; Framebuffer[1][0] = new u32[fbsize]; Framebuffer[0][1] = new u32[fbsize]; diff --git a/src/GPU2D.cpp b/src/GPU2D.cpp index 3375d45..8998453 100644 --- a/src/GPU2D.cpp +++ b/src/GPU2D.cpp @@ -753,8 +753,10 @@ void GPU2D::DrawScanline(u32 line) case 1: // regular display { - for (int i = 0; i < stride; i+=2) + int i = 0; + for (; i < (stride & ~1); i+=2) *(u64*)&dst[i] = *(u64*)&BGOBJLine[i]; + if (stride & 1) dst[i] = BGOBJLine[i]; } break; -- cgit v1.2.3 From c1fa5d8283cde76110690d15b2d127ead65d2265 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Wed, 24 Jul 2019 00:27:08 +0200 Subject: GPU2D: forced-blank only disables BG/OBJ compositing (VRAM/FIFO display, capture, master brightness still run) fixes #491 --- src/GPU2D.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/GPU2D.cpp b/src/GPU2D.cpp index 8998453..9d7ab8f 100644 --- a/src/GPU2D.cpp +++ b/src/GPU2D.cpp @@ -709,10 +709,6 @@ void GPU2D::DrawScanline(u32 line) // oddly that's not the case for GPU A if (Num && !Enabled) forceblank = true; - // forced blank - // (checkme: are there still things that can run under this mode? likely not) - if (DispCnt & (1<<7)) forceblank = true; - if (forceblank) { for (int i = 0; i < 256; i++) @@ -1350,6 +1346,15 @@ void GPU2D::DrawScanlineBGMode6(u32 line) void GPU2D::DrawScanline_BGOBJ(u32 line) { + // forced blank disables BG/OBJ compositing + if (DispCnt & (1<<7)) + { + for (int i = 0; i < 256; i++) + BGOBJLine[i] = 0xFF3F3F3F; + + return; + } + u64 backdrop; if (Num) backdrop = *(u16*)&GPU::Palette[0x400]; else backdrop = *(u16*)&GPU::Palette[0]; -- cgit v1.2.3 From 3c006fd36154e48325c3cf862ed3287b265924c1 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Wed, 24 Jul 2019 02:46:30 +0200 Subject: GPU2D: fill gaps in BG modes * mode6 actually works on the sub GPU, albeit limited to 1/4 the full bitmap size due to having only 128K of VRAM * mode7 draws BG0, BG1 and sprites. no BG2/BG3. --- src/GPU2D.cpp | 38 ++++++++++++++++++++++++++++++-------- src/GPU2D.h | 1 + 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/GPU2D.cpp b/src/GPU2D.cpp index 9d7ab8f..4bba235 100644 --- a/src/GPU2D.cpp +++ b/src/GPU2D.cpp @@ -1316,12 +1316,6 @@ void GPU2D::DrawScanlineBGMode(u32 line) void GPU2D::DrawScanlineBGMode6(u32 line) { - if (Num) - { - printf("GPU2D: MODE6 ON SUB GPU???\n"); - return; - } - for (int i = 3; i >= 0; i--) { if ((BGCnt[2] & 0x3) == i) @@ -1335,8 +1329,36 @@ void GPU2D::DrawScanlineBGMode6(u32 line) { if (DispCnt & 0x0100) { - if (DispCnt & 0x8) + if ((!Num) && (DispCnt & 0x8)) + DrawBG_3D(); + } + } + if ((DispCnt & 0x1000) && NumSprites) + InterleaveSprites(0x8000 | (i<<16)); + } +} + +void GPU2D::DrawScanlineBGMode7(u32 line) +{ + // mode 7 only has text-mode BG0 and BG1 + + for (int i = 3; i >= 0; i--) + { + if ((BGCnt[1] & 0x3) == i) + { + if (DispCnt & 0x0200) + { + DrawBG_Text(line, 1); + } + } + if ((BGCnt[0] & 0x3) == i) + { + if (DispCnt & 0x0100) + { + if ((!Num) && (DispCnt & 0x8)) DrawBG_3D(); + else + DrawBG_Text(line, 0); } } if ((DispCnt & 0x1000) && NumSprites) @@ -1376,7 +1398,6 @@ void GPU2D::DrawScanline_BGOBJ(u32 line) else memset(WindowMask, 0xFF, 256); - // TODO: what happens in mode 7? mode 6 on the sub engine? switch (DispCnt & 0x7) { case 0: DrawScanlineBGMode<0>(line); break; @@ -1386,6 +1407,7 @@ void GPU2D::DrawScanline_BGOBJ(u32 line) case 4: DrawScanlineBGMode<4>(line); break; case 5: DrawScanlineBGMode<5>(line); break; case 6: DrawScanlineBGMode6(line); break; + case 7: DrawScanlineBGMode7(line); break; } // color special effects diff --git a/src/GPU2D.h b/src/GPU2D.h index b9a2422..6ad9783 100644 --- a/src/GPU2D.h +++ b/src/GPU2D.h @@ -135,6 +135,7 @@ private: template void DrawScanlineBGMode(u32 line); void DrawScanlineBGMode6(u32 line); + void DrawScanlineBGMode7(u32 line); void DrawScanline_BGOBJ(u32 line); static void DrawPixel_Normal(u32* dst, u16 color, u32 flag); -- cgit v1.2.3 From a8886d5949780221386ed623d12039bdc8e78e36 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Wed, 24 Jul 2019 03:30:09 +0200 Subject: GPU2D: add 'prohibited' large BG sizes --- src/GPU2D.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/GPU2D.cpp b/src/GPU2D.cpp index 4bba235..fbb7fea 100644 --- a/src/GPU2D.cpp +++ b/src/GPU2D.cpp @@ -2069,14 +2069,19 @@ void GPU2D::DrawBG_Large(u32 line) // BG is always BG2 u32 tilesetaddr, tilemapaddr; u16* pal; + // large BG sizes: + // 0: 512x1024 + // 1: 1024x512 + // 2: 512x256 + // 3: 512x512 u32 xmask, ymask; u32 yshift; switch (bgcnt & 0xC000) { case 0x0000: xmask = 0x1FFFF; ymask = 0x3FFFF; yshift = 9; break; case 0x4000: xmask = 0x3FFFF; ymask = 0x1FFFF; yshift = 10; break; - case 0x8000: // TODO (most likely the second size bit is just ignored) - case 0xC000: printf("bad BG size for large BG: %04X\n", bgcnt); return; + case 0x8000: xmask = 0x1FFFF; ymask = 0x0FFFF; yshift = 9; break; + case 0xC000: xmask = 0x1FFFF; ymask = 0x1FFFF; yshift = 9; break; } u32 ofxmask, ofymask; -- cgit v1.2.3 From 78ff4165edaccf995b646b095abbc63b441b7d23 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Wed, 24 Jul 2019 04:29:19 +0200 Subject: GPU2D: * implement reserved mode for bitmap sprites (not too interesting) * mask out DISPCNT bits that don't apply to the sub GPU --- src/GPU2D.cpp | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/GPU2D.cpp b/src/GPU2D.cpp index fbb7fea..1ce62c6 100644 --- a/src/GPU2D.cpp +++ b/src/GPU2D.cpp @@ -304,10 +304,22 @@ void GPU2D::Write8(u32 addr, u8 val) switch (addr & 0x00000FFF) { - case 0x000: DispCnt = (DispCnt & 0xFFFFFF00) | val; return; - case 0x001: DispCnt = (DispCnt & 0xFFFF00FF) | (val << 8); return; - case 0x002: DispCnt = (DispCnt & 0xFF00FFFF) | (val << 16); return; - case 0x003: DispCnt = (DispCnt & 0x00FFFFFF) | (val << 24); return; + case 0x000: + DispCnt = (DispCnt & 0xFFFFFF00) | val; + if (Num) DispCnt &= 0xC0B1FFF7; + return; + case 0x001: + DispCnt = (DispCnt & 0xFFFF00FF) | (val << 8); + if (Num) DispCnt &= 0xC0B1FFF7; + return; + case 0x002: + DispCnt = (DispCnt & 0xFF00FFFF) | (val << 16); + if (Num) DispCnt &= 0xC0B1FFF7; + return; + case 0x003: + DispCnt = (DispCnt & 0x00FFFFFF) | (val << 24); + if (Num) DispCnt &= 0xC0B1FFF7; + return; case 0x008: BGCnt[0] = (BGCnt[0] & 0xFF00) | val; return; case 0x009: BGCnt[0] = (BGCnt[0] & 0x00FF) | (val << 8); return; @@ -386,8 +398,14 @@ void GPU2D::Write16(u32 addr, u16 val) switch (addr & 0x00000FFF) { - case 0x000: DispCnt = (DispCnt & 0xFFFF0000) | val; return; - case 0x002: DispCnt = (DispCnt & 0x0000FFFF) | (val << 16); return; + case 0x000: + DispCnt = (DispCnt & 0xFFFF0000) | val; + if (Num) DispCnt &= 0xC0B1FFF7; + return; + case 0x002: + DispCnt = (DispCnt & 0x0000FFFF) | (val << 16); + if (Num) DispCnt &= 0xC0B1FFF7; + return; case 0x008: BGCnt[0] = val; return; case 0x00A: BGCnt[1] = val; return; @@ -519,6 +537,7 @@ void GPU2D::Write32(u32 addr, u32 val) { case 0x000: DispCnt = val; + if (Num) DispCnt &= 0xC0B1FFF7; return; case 0x028: @@ -2326,8 +2345,10 @@ void GPU2D::DrawSprite_Rotscale(u16* attrib, u16* rotparams, u32 boundwidth, u32 { if (DispCnt & 0x20) { - // TODO ("reserved") - printf("bad reserved mode\n"); + // 'reserved' + // draws nothing + + return; } else { @@ -2559,8 +2580,10 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, s32 ypos) { if (DispCnt & 0x20) { - // TODO ("reserved") - printf("bad reserved mode\n"); + // 'reserved' + // draws nothing + + return; } else { -- cgit v1.2.3 From d838c6ab4ea8a38477b50b7a5018aba5d3f927fc Mon Sep 17 00:00:00 2001 From: Roger Date: Tue, 13 Aug 2019 12:41:16 -0400 Subject: Use the new GitHub sponsors feature to a link to the patreon --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..bb83359 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +patreon: staplebutter -- cgit v1.2.3 From 5998f7be5f65c259c590bc34b708eac0ea1f8b78 Mon Sep 17 00:00:00 2001 From: Lukas Wienke Date: Thu, 15 Aug 2019 23:54:20 +0200 Subject: add clion standatd dirs to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f63e239..bd1d485 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ obj melon_grc.c melon_grc.h cmake-build +cmake-build-debug +.idea -- cgit v1.2.3 From 6a50bcfaf70a08295db62d2a706db158853f179b Mon Sep 17 00:00:00 2001 From: Lukas Wienke Date: Thu, 15 Aug 2019 23:55:00 +0200 Subject: add warning message if romlist.bin is not found --- src/libui_sdl/main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index a19495b..38b734b 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -2573,7 +2573,6 @@ int main(int argc, char** argv) SDL_Quit(); return 0; } - { FILE* f = Platform::OpenLocalFile("romlist.bin", "rb"); if (f) @@ -2590,6 +2589,13 @@ int main(int argc, char** argv) "You should use the latest version of romlist.bin (provided in melonDS release packages)."); } } + else + { + uiMsgBoxError(NULL, + "romlist.bin not found.", + "Save memory type detection will not work correctly.\n\n" + "You should use the latest version of romlist.bin (provided in melonDS release packages)."); + } } CreateMainWindowMenu(); -- cgit v1.2.3 From 626a9c13859b556a19abbf2212233a834e11f022 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Sun, 18 Aug 2019 11:31:03 +0200 Subject: my bad. --- src/SPU.cpp | 22 +++++++++++++++------- src/SPU.h | 1 + 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/SPU.cpp b/src/SPU.cpp index 2dfdf44..b25b8d0 100644 --- a/src/SPU.cpp +++ b/src/SPU.cpp @@ -26,7 +26,7 @@ // * capture addition modes, overflow bugs // * channel hold // * 'length less than 4' glitch - +int brap = 0; namespace SPU { @@ -63,7 +63,7 @@ const s16 PSGTable[8][8] = const u32 kSamplesPerRun = 1; -const u32 OutputBufferSize = 2*1024; +const u32 OutputBufferSize = 2*2*1024; s16 OutputBuffer[2 * OutputBufferSize]; u32 OutputReadOffset; u32 OutputWriteOffset; @@ -101,7 +101,7 @@ void Reset() { memset(OutputBuffer, 0, 2*OutputBufferSize*2); OutputReadOffset = 0; - OutputWriteOffset = OutputBufferSize; + OutputWriteOffset = 0;//OutputBufferSize; Cnt = 0; MasterVolume = 0; @@ -579,7 +579,7 @@ void CaptureUnit::Run(s32 sample) } } - +int zog = 0, zig = 0; void Mix(u32 samples) { s32 channelbuf[32]; @@ -734,15 +734,23 @@ void Mix(u32 samples) OutputBuffer[OutputWriteOffset + 1] = r >> 1; OutputWriteOffset += 2; OutputWriteOffset &= ((2*OutputBufferSize)-1); - if (OutputWriteOffset == OutputReadOffset) printf("!! SOUND FIFO OVERFLOW\n"); + if (OutputWriteOffset == OutputReadOffset) printf("!! SOUND FIFO OVERFLOW %d\n", OutputWriteOffset>>1); + zog++; zig++; brap++; } NDS::ScheduleEvent(NDS::Event_SPU, true, 1024*kSamplesPerRun, Mix, kSamplesPerRun); } +int GetOutputSize() +{ + return zog; // derp +} + int ReadOutput(s16* data, int samples) { + printf("ReadOutput(%d): wrote=%d level=%d ReadOffset=%d WriteOffset=%d\n", samples, zog, zig, OutputReadOffset>>1, OutputWriteOffset>>1); + zog = 0; zig -= (zigSetLoopPos(val); return; - case 0xC: chan->SetLength((chan->Length & 0xFFFF0000) | val); return; - case 0xE: chan->SetLength((chan->Length & 0x0000FFFF) | (val << 16)); return; + case 0xC: chan->SetLength(((chan->Length >> 2) & 0xFFFF0000) | val); return; + case 0xE: chan->SetLength(((chan->Length >> 2) & 0x0000FFFF) | (val << 16)); return; } } else diff --git a/src/SPU.h b/src/SPU.h index 3cd5df3..ddd235a 100644 --- a/src/SPU.h +++ b/src/SPU.h @@ -35,6 +35,7 @@ void SetBias(u16 bias); void Mix(u32 samples); +int GetOutputSize(); int ReadOutput(s16* data, int samples); u8 Read8(u32 addr); -- cgit v1.2.3 From 6c7c037b202ca0e145a47a9d8dfbf34bc8cdda7d Mon Sep 17 00:00:00 2001 From: xperia64 Date: Sat, 24 Aug 2019 11:52:24 -0400 Subject: Fix division edge case --- src/NDS.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NDS.cpp b/src/NDS.cpp index 991995d..ceeeb79 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -1416,7 +1416,7 @@ void DivDone(u32 param) if (den == 0) { DivQuotient[0] = (num<0) ? 1:-1; - DivQuotient[1] = (num<0) ? -1:1; + DivQuotient[1] = (num<0) ? -1:0; *(s64*)&DivRemainder[0] = num; } else if (num == -0x80000000 && den == -1) -- cgit v1.2.3 From 7cb8112984172d1886d6bd7b12f0afffd1fa7229 Mon Sep 17 00:00:00 2001 From: Zapeth Date: Sun, 25 Aug 2019 18:28:54 +0200 Subject: Fix MinGW resource file compilation issues --- src/libui_sdl/CMakeLists.txt | 4 ++++ src/libui_sdl/libui/windows/CMakeLists.txt | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libui_sdl/CMakeLists.txt b/src/libui_sdl/CMakeLists.txt index 63e9f48..b5d29d8 100644 --- a/src/libui_sdl/CMakeLists.txt +++ b/src/libui_sdl/CMakeLists.txt @@ -14,6 +14,10 @@ SET(SOURCES_LIBUI OSD.cpp ) +if (WIN32) + set(CMAKE_RC_COMPILE_OBJECT " -i -o ") +endif() + option(BUILD_SHARED_LIBS "Whether to build libui as a shared library or a static library" ON) set(BUILD_SHARED_LIBS OFF) add_subdirectory(libui) diff --git a/src/libui_sdl/libui/windows/CMakeLists.txt b/src/libui_sdl/libui/windows/CMakeLists.txt index 9d5313a..24d4ad9 100644 --- a/src/libui_sdl/libui/windows/CMakeLists.txt +++ b/src/libui_sdl/libui/windows/CMakeLists.txt @@ -73,7 +73,7 @@ macro(_handle_static) add_custom_command( TARGET libui POST_BUILD COMMAND - ${CMAKE_COMMAND} -E copy $/CMakeFiles/libui.dir/windows/resources.rc.* ${_LIBUI_STATIC_RES} + ${CMAKE_COMMAND} -E copy $/CMakeFiles/libui.dir/windows/resources.rc.obj ${_LIBUI_STATIC_RES} COMMENT "Copying libui.res") endmacro() -- cgit v1.2.3 From 6635ded6ec16873e7bc8f4bd7c68d97ce91fd6f2 Mon Sep 17 00:00:00 2001 From: tokumeiwokiboushimasu Date: Wed, 28 Aug 2019 22:23:26 +0900 Subject: Fix build error on Fedora --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ebb69f..048dd44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,11 @@ endif() if(ENABLE_LTO) add_compile_options(-O3 -flto) + set(CMAKE_AR "gcc-ar") + set(CMAKE_C_ARCHIVE_CREATE " qcs ") + set(CMAKE_C_ARCHIVE_FINISH true) + set(CMAKE_CXX_ARCHIVE_CREATE " qcs ") + set(CMAKE_CXX_ARCHIVE_FINISH true) endif() add_compile_options(-fno-pic) -- cgit v1.2.3 From 96d5d3f4c8ebdb887da49998522e37c329f1115f Mon Sep 17 00:00:00 2001 From: Zapeth Date: Wed, 28 Aug 2019 22:24:54 +0200 Subject: Fix glib-compile-resources path issues Apparently double quotes are not stripped away for assigned arguments when parsing, which causes isses for paths that include spaces. --- src/libui_sdl/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libui_sdl/CMakeLists.txt b/src/libui_sdl/CMakeLists.txt index b5d29d8..64206bf 100644 --- a/src/libui_sdl/CMakeLists.txt +++ b/src/libui_sdl/CMakeLists.txt @@ -43,11 +43,11 @@ if (UNIX) ADD_DEFINITIONS(${GTK3_CFLAGS_OTHER}) add_custom_command(OUTPUT melon_grc.c - COMMAND glib-compile-resources --sourcedir="${CMAKE_SOURCE_DIR}" - --target="${CMAKE_CURRENT_BINARY_DIR}/melon_grc.c" + COMMAND glib-compile-resources --sourcedir=${CMAKE_SOURCE_DIR} + --target=${CMAKE_CURRENT_BINARY_DIR}/melon_grc.c --generate-source "${CMAKE_SOURCE_DIR}/melon_grc.xml" - COMMAND glib-compile-resources --sourcedir="${CMAKE_SOURCE_DIR}" - --target="${CMAKE_CURRENT_BINARY_DIR}/melon_grc.h" + COMMAND glib-compile-resources --sourcedir=${CMAKE_SOURCE_DIR} + --target=${CMAKE_CURRENT_BINARY_DIR}/melon_grc.h --generate-header "${CMAKE_SOURCE_DIR}/melon_grc.xml") if (CMAKE_SYSTEM_NAME STREQUAL "Linux") -- cgit v1.2.3 From fbad8b0f4393a41892c5da59d1ef62d0314a029b Mon Sep 17 00:00:00 2001 From: Arisotura Date: Thu, 29 Aug 2019 15:55:18 +0200 Subject: * new FPS limiter * new audio output/sync method about fucking time --- src/SPU.cpp | 47 ++++++++++++++++++++------ src/SPU.h | 1 + src/libui_sdl/main.cpp | 90 +++++++++++++++++++++++++++----------------------- 3 files changed, 86 insertions(+), 52 deletions(-) diff --git a/src/SPU.cpp b/src/SPU.cpp index b25b8d0..6b594b0 100644 --- a/src/SPU.cpp +++ b/src/SPU.cpp @@ -26,7 +26,6 @@ // * capture addition modes, overflow bugs // * channel hold // * 'length less than 4' glitch -int brap = 0; namespace SPU { @@ -63,10 +62,10 @@ const s16 PSGTable[8][8] = const u32 kSamplesPerRun = 1; -const u32 OutputBufferSize = 2*2*1024; +const u32 OutputBufferSize = 2*1024; s16 OutputBuffer[2 * OutputBufferSize]; -u32 OutputReadOffset; -u32 OutputWriteOffset; +volatile u32 OutputReadOffset; +volatile u32 OutputWriteOffset; u16 Cnt; @@ -579,7 +578,7 @@ void CaptureUnit::Run(s32 sample) } } -int zog = 0, zig = 0; + void Mix(u32 samples) { s32 channelbuf[32]; @@ -629,7 +628,7 @@ void Mix(u32 samples) else if (val > 0x7FFF) val = 0x7FFF; Capture[0]->Run(val); - if (!((Capture[0]->Cnt & (1<<7)))) break; + if (!(Capture[0]->Cnt & (1<<7))) break; } } @@ -644,7 +643,7 @@ void Mix(u32 samples) else if (val > 0x7FFF) val = 0x7FFF; Capture[1]->Run(val); - if (!((Capture[1]->Cnt & (1<<7)))) break; + if (!(Capture[1]->Cnt & (1<<7))) break; } } @@ -735,7 +734,6 @@ void Mix(u32 samples) OutputWriteOffset += 2; OutputWriteOffset &= ((2*OutputBufferSize)-1); if (OutputWriteOffset == OutputReadOffset) printf("!! SOUND FIFO OVERFLOW %d\n", OutputWriteOffset>>1); - zog++; zig++; brap++; } NDS::ScheduleEvent(NDS::Event_SPU, true, 1024*kSamplesPerRun, Mix, kSamplesPerRun); @@ -744,13 +742,40 @@ void Mix(u32 samples) int GetOutputSize() { - return zog; // derp + int ret; + if (OutputWriteOffset >= OutputReadOffset) + ret = OutputWriteOffset - OutputReadOffset; + else + ret = (OutputBufferSize*2) - OutputReadOffset + OutputWriteOffset; + + ret >>= 1; + return ret; +} + +void Sync(bool wait) +{ + // sync to audio output in case the core is running too fast + // * wait=true: wait until enough audio data has been played + // * wait=false: merely skip some audio data to avoid a FIFO overflow + + const int halflimit = (OutputBufferSize / 2); + + if (wait) + { + // TODO: less CPU-intensive wait? + while (GetOutputSize() > halflimit); + } + else if (GetOutputSize() > halflimit) + { + int readpos = OutputWriteOffset - (halflimit*2); + if (readpos < 0) readpos += (OutputBufferSize*2); + + OutputReadOffset = readpos; + } } int ReadOutput(s16* data, int samples) { - printf("ReadOutput(%d): wrote=%d level=%d ReadOffset=%d WriteOffset=%d\n", samples, zog, zig, OutputReadOffset>>1, OutputWriteOffset>>1); - zog = 0; zig -= (zig> 8; buf_out[i*2+1] = (buf_in[res_pos*2+1] * volume) >> 8; + /*s16 s_l = buf_in[res_pos*2 ]; + s16 s_r = buf_in[res_pos*2+1]; + + float a = res_timer; + float b = 1.0 - a; + s_l = (s_l * a) + (buf_in[(res_pos-1)*2 ] * b); + s_r = (s_r * a) + (buf_in[(res_pos-1)*2+1] * b); + + buf_out[i*2 ] = (s_l * volume) >> 8; + buf_out[i*2+1] = (s_r * volume) >> 8;*/ + res_timer += res_incr; while (res_timer >= 1.0) { @@ -838,6 +851,7 @@ bool JoyButtonHeld(int btnid, int njoybuttons, Uint8* joybuttons, Uint32 hat) void UpdateWindowTitle(void* data) { + if (EmuStatus == 0) return; uiWindowSetTitle(MainWindow, (const char*)data); } @@ -880,6 +894,10 @@ int EmuThreadFunc(void* burp) u32 lasttick = starttick; u32 lastmeasuretick = lasttick; u32 fpslimitcount = 0; + u64 perfcount = SDL_GetPerformanceCounter(); + u64 perffreq = SDL_GetPerformanceFrequency(); + float samplesleft = 0; + u32 nsamples = 0; char melontitle[100]; while (EmuRunning != 0) @@ -959,43 +977,30 @@ int EmuThreadFunc(void* burp) } uiAreaQueueRedrawAll(MainDrawArea); - // framerate limiter based off SDL2_gfx - float framerate = (1000.0f * nlines) / (60.0f * 263.0f); - - /*fpslimitcount++; - u32 curtick = SDL_GetTicks(); - u32 delay = curtick - lasttick; - lasttick = curtick; - bool limitfps = Config::LimitFPS && !HotkeyDown(HK_FastForward); + SPU::Sync(limitfps); - u32 wantedtick = starttick + (u32)((float)fpslimitcount * framerate); - if (curtick < wantedtick && limitfps) - { - SDL_Delay(wantedtick - curtick); - } - else - { - fpslimitcount = 0; - starttick = curtick; - }*/ + float framerate = (1000.0f * nlines) / (60.0f * 263.0f); - fpslimitcount++; - if (fpslimitcount >= 3) { u32 curtick = SDL_GetTicks(); u32 delay = curtick - lasttick; - bool limitfps = Config::LimitFPS && !HotkeyDown(HK_FastForward); - - u32 wantedtick = lasttick + (u32)((float)fpslimitcount * framerate); - if (curtick < wantedtick && limitfps) + if (limitfps) { - SDL_Delay(wantedtick - curtick); + float wantedtickF = starttick + (framerate * (fpslimitcount+1)); + u32 wantedtick = (u32)ceil(wantedtickF); + if (curtick < wantedtick) SDL_Delay(wantedtick - curtick); + + lasttick = SDL_GetTicks(); + fpslimitcount++; + if ((abs(wantedtickF - (float)wantedtick) < 0.001312) || (fpslimitcount > 60)) + { + fpslimitcount = 0; + nsamples = 0; + starttick = lasttick; + } } - - lasttick = SDL_GetTicks(); - fpslimitcount = 0; } nframes++; @@ -2649,20 +2654,23 @@ int main(int argc, char** argv) uiMenuItemSetChecked(MenuItem_LimitFPS, Config::LimitFPS==1); uiMenuItemSetChecked(MenuItem_ShowOSD, Config::ShowOSD==1); + AudioFreq = 48000; // TODO: make configurable? SDL_AudioSpec whatIwant, whatIget; memset(&whatIwant, 0, sizeof(SDL_AudioSpec)); - whatIwant.freq = 47340; + whatIwant.freq = AudioFreq; whatIwant.format = AUDIO_S16LSB; whatIwant.channels = 2; whatIwant.samples = 1024; whatIwant.callback = AudioCallback; - AudioDevice = SDL_OpenAudioDevice(NULL, 0, &whatIwant, &whatIget, 0); + AudioDevice = SDL_OpenAudioDevice(NULL, 0, &whatIwant, &whatIget, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE); if (!AudioDevice) { printf("Audio init failed: %s\n", SDL_GetError()); } else { + AudioFreq = whatIget.freq; + printf("Audio output frequency: %d Hz\n", AudioFreq); SDL_PauseAudioDevice(AudioDevice, 1); } -- cgit v1.2.3 From 455b0e568987b66e757f98869450decb94e02d28 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Sun, 1 Sep 2019 15:41:46 +0200 Subject: more fixes to audio output maybe by 2034 we'll finally get that shit going --- src/SPU.cpp | 17 ++++++++++++++--- src/SPU.h | 2 ++ src/libui_sdl/main.cpp | 20 ++++++++++++++++++-- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/SPU.cpp b/src/SPU.cpp index 6b594b0..b36becf 100644 --- a/src/SPU.cpp +++ b/src/SPU.cpp @@ -98,9 +98,7 @@ void DeInit() void Reset() { - memset(OutputBuffer, 0, 2*OutputBufferSize*2); - OutputReadOffset = 0; - OutputWriteOffset = 0;//OutputBufferSize; + InitOutput(); Cnt = 0; MasterVolume = 0; @@ -740,6 +738,19 @@ void Mix(u32 samples) } +void DrainOutput() +{ + OutputReadOffset = 0; + OutputWriteOffset = 0; +} + +void InitOutput() +{ + memset(OutputBuffer, 0, 2*OutputBufferSize*2); + OutputReadOffset = 0; + OutputWriteOffset = OutputBufferSize; +} + int GetOutputSize() { int ret; diff --git a/src/SPU.h b/src/SPU.h index 839b1b0..7c99887 100644 --- a/src/SPU.h +++ b/src/SPU.h @@ -35,6 +35,8 @@ void SetBias(u16 bias); void Mix(u32 samples); +void DrainOutput(); +void InitOutput(); int GetOutputSize(); void Sync(bool wait); int ReadOutput(s16* data, int samples); diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 7d7bce0..1b4a9c6 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -159,6 +159,7 @@ int JoystickID; SDL_Joystick* Joystick; int AudioFreq; +float AudioSampleFrac; SDL_AudioDeviceID AudioDevice, MicDevice; u32 MicBufferLength = 2048; @@ -565,7 +566,10 @@ void AudioCallback(void* data, Uint8* stream, int len) // resample incoming audio to match the output sample rate - int len_in = (int)ceil((len * 32823.6328125) / (float)AudioFreq); + float f_len_in = (len * 32823.6328125) / (float)AudioFreq; + f_len_in += AudioSampleFrac; + int len_in = (int)floor(f_len_in); + AudioSampleFrac = f_len_in - len_in; s16 buf_in[1024*2]; s16* buf_out = (s16*)stream; @@ -573,6 +577,12 @@ void AudioCallback(void* data, Uint8* stream, int len) int num_in = SPU::ReadOutput(buf_in, len_in); int num_out = len; + if (num_in < 1) + { + memset(stream, 0, len*sizeof(s16)*2); + return; + } + int margin = 6; if (num_in < len_in-margin) { @@ -591,7 +601,7 @@ void AudioCallback(void* data, Uint8* stream, int len) int volume = Config::AudioVolume; - for (int i = 0; i < 1024; i++) + for (int i = 0; i < len; i++) { buf_out[i*2 ] = (buf_in[res_pos*2 ] * volume) >> 8; buf_out[i*2+1] = (buf_in[res_pos*2+1] * volume) >> 8; @@ -1522,6 +1532,8 @@ void Run() EmuRunning = 1; RunningSomething = true; + SPU::InitOutput(); + AudioSampleFrac = 0; SDL_PauseAudioDevice(AudioDevice, 0); SDL_PauseAudioDevice(MicDevice, 0); @@ -1560,6 +1572,7 @@ void TogglePause(void* blarg) EmuRunning = 2; uiMenuItemSetChecked(MenuItem_Pause, 1); + SPU::DrainOutput(); SDL_PauseAudioDevice(AudioDevice, 1); SDL_PauseAudioDevice(MicDevice, 1); @@ -1571,6 +1584,8 @@ void TogglePause(void* blarg) EmuRunning = 1; uiMenuItemSetChecked(MenuItem_Pause, 0); + SPU::InitOutput(); + AudioSampleFrac = 0; SDL_PauseAudioDevice(AudioDevice, 0); SDL_PauseAudioDevice(MicDevice, 0); @@ -1621,6 +1636,7 @@ void Stop(bool internal) uiAreaQueueRedrawAll(MainDrawArea); + SPU::DrainOutput(); SDL_PauseAudioDevice(AudioDevice, 1); SDL_PauseAudioDevice(MicDevice, 1); -- cgit v1.2.3 From f01016a30b2e8482d06798895ebc674370e81816 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Sun, 1 Sep 2019 18:35:33 +0200 Subject: GPU2D: shape3 sprites are always 8x8 --- src/GPU2D.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/GPU2D.cpp b/src/GPU2D.cpp index 1ce62c6..432eaaf 100644 --- a/src/GPU2D.cpp +++ b/src/GPU2D.cpp @@ -2192,17 +2192,17 @@ void GPU2D::DrawSprites(u32 line) const s32 spritewidth[16] = { - 8, 16, 8, 0, - 16, 32, 8, 0, - 32, 32, 16, 0, - 64, 64, 32, 0 + 8, 16, 8, 8, + 16, 32, 8, 8, + 32, 32, 16, 8, + 64, 64, 32, 8 }; const s32 spriteheight[16] = { - 8, 8, 16, 0, - 16, 8, 32, 0, - 32, 16, 32, 0, - 64, 32, 64, 0 + 8, 8, 16, 8, + 16, 8, 32, 8, + 32, 16, 32, 8, + 64, 32, 64, 8 }; u32 nsprites = 0; -- cgit v1.2.3 From 5b5103443608d6f7e88229b1fbf8fb276b4f5f27 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Sun, 1 Sep 2019 18:38:01 +0200 Subject: zerp --- src/GPU2D.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/GPU2D.cpp b/src/GPU2D.cpp index 432eaaf..288ee58 100644 --- a/src/GPU2D.cpp +++ b/src/GPU2D.cpp @@ -2205,8 +2205,6 @@ void GPU2D::DrawSprites(u32 line) 64, 32, 64, 8 }; - u32 nsprites = 0; - for (int bgnum = 0x0C00; bgnum >= 0x0000; bgnum -= 0x0400) { for (int sprnum = 127; sprnum >= 0; sprnum--) -- cgit v1.2.3 From abb06269a1ade49f71c02d1fc2b63128f872d294 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Sun, 1 Sep 2019 20:20:22 +0200 Subject: add VSync toggle --- src/libui_sdl/DlgVideoSettings.cpp | 26 +++++++++++++++++++++++++- src/libui_sdl/PlatformConfig.cpp | 2 ++ src/libui_sdl/PlatformConfig.h | 1 + src/libui_sdl/main.cpp | 18 ++++++++++++++++-- 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/libui_sdl/DlgVideoSettings.cpp b/src/libui_sdl/DlgVideoSettings.cpp index 7d876e2..155fe8b 100644 --- a/src/libui_sdl/DlgVideoSettings.cpp +++ b/src/libui_sdl/DlgVideoSettings.cpp @@ -39,12 +39,14 @@ uiWindow* win; uiRadioButtons* rbRenderer; uiCheckbox* cbGLDisplay; +uiCheckbox* cbVSync; uiCheckbox* cbThreaded3D; uiCombobox* cbResolution; uiCheckbox* cbAntialias; int old_renderer; int old_gldisplay; +int old_vsync; int old_threaded3D; int old_resolution; int old_antialias; @@ -89,6 +91,11 @@ void RevertSettings() { Config::ScreenUseGL = old_gldisplay; } + if (old_vsync != Config::ScreenVSync) + { + Config::ScreenVSync = old_vsync; + ApplyNewSettings(4); + } if (old_usegl != new_usegl) { apply2 = true; @@ -134,17 +141,25 @@ void OnRendererChanged(uiRadioButtons* rb, void* blarg) ApplyNewSettings(2); else ApplyNewSettings(3); - + uiControlSetFocus(uiControl(win)); } void OnGLDisplayChanged(uiCheckbox* cb, void* blarg) { Config::ScreenUseGL = uiCheckboxChecked(cb); + if (Config::ScreenUseGL) uiControlEnable(uiControl(cbVSync)); + else uiControlDisable(uiControl(cbVSync)); ApplyNewSettings(2); uiControlSetFocus(uiControl(win)); } +void OnVSyncChanged(uiCheckbox* cb, void* blarg) +{ + Config::ScreenVSync = uiCheckboxChecked(cb); + ApplyNewSettings(4); +} + void OnThreaded3DChanged(uiCheckbox* cb, void* blarg) { Config::Threaded3D = uiCheckboxChecked(cb); @@ -232,6 +247,10 @@ void Open() cbGLDisplay = uiNewCheckbox("OpenGL display"); uiCheckboxOnToggled(cbGLDisplay, OnGLDisplayChanged, NULL); uiBoxAppend(in_ctrl, uiControl(cbGLDisplay), 0); + + cbVSync = uiNewCheckbox("VSync"); + uiCheckboxOnToggled(cbVSync, OnVSyncChanged, NULL); + uiBoxAppend(in_ctrl, uiControl(cbVSync), 0); } { @@ -300,17 +319,22 @@ void Open() old_renderer = Config::_3DRenderer; old_gldisplay = Config::ScreenUseGL; + old_vsync = Config::ScreenVSync; old_threaded3D = Config::Threaded3D; old_resolution = Config::GL_ScaleFactor; old_antialias = Config::GL_Antialias; uiCheckboxSetChecked(cbGLDisplay, Config::ScreenUseGL); + uiCheckboxSetChecked(cbVSync, Config::ScreenVSync); uiCheckboxSetChecked(cbThreaded3D, Config::Threaded3D); uiComboboxSetSelected(cbResolution, Config::GL_ScaleFactor-1); //uiCheckboxSetChecked(cbAntialias, Config::GL_Antialias); uiRadioButtonsSetSelected(rbRenderer, Config::_3DRenderer); UpdateControls(); + if (Config::ScreenUseGL) uiControlEnable(uiControl(cbVSync)); + else uiControlDisable(uiControl(cbVSync)); + uiControlShow(uiControl(win)); } diff --git a/src/libui_sdl/PlatformConfig.cpp b/src/libui_sdl/PlatformConfig.cpp index 7f45b59..fb31ccd 100644 --- a/src/libui_sdl/PlatformConfig.cpp +++ b/src/libui_sdl/PlatformConfig.cpp @@ -43,6 +43,7 @@ int ScreenSizing; int ScreenFilter; int ScreenUseGL; +int ScreenVSync; int ScreenRatio; int LimitFPS; @@ -118,6 +119,7 @@ ConfigEntry PlatformConfigFile[] = {"ScreenFilter", 0, &ScreenFilter, 1, NULL, 0}, {"ScreenUseGL", 0, &ScreenUseGL, 1, NULL, 0}, + {"ScreenVSync", 0, &ScreenVSync, 0, NULL, 0}, {"ScreenRatio", 0, &ScreenRatio, 0, NULL, 0}, {"LimitFPS", 0, &LimitFPS, 1, NULL, 0}, diff --git a/src/libui_sdl/PlatformConfig.h b/src/libui_sdl/PlatformConfig.h index 2c59e5d..2aede24 100644 --- a/src/libui_sdl/PlatformConfig.h +++ b/src/libui_sdl/PlatformConfig.h @@ -54,6 +54,7 @@ extern int ScreenSizing; extern int ScreenFilter; extern int ScreenUseGL; +extern int ScreenVSync; extern int ScreenRatio; extern int LimitFPS; diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 1b4a9c6..24febf6 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -988,7 +988,8 @@ int EmuThreadFunc(void* burp) uiAreaQueueRedrawAll(MainDrawArea); bool limitfps = Config::LimitFPS && !HotkeyDown(HK_FastForward); - SPU::Sync(limitfps); + bool vsync = Config::ScreenVSync && Screen_UseGL; + SPU::Sync(limitfps || vsync); float framerate = (1000.0f * nlines) / (60.0f * 263.0f); @@ -2260,6 +2261,19 @@ void ApplyNewSettings(int type) GPU3D::InitRenderer(Screen_UseGL); if (Screen_UseGL) uiGLMakeContextCurrent(NULL); } + else if (type == 4) // vsync + { + if (Screen_UseGL) + { + uiGLMakeContextCurrent(GLContext); + uiGLSetVSync(Config::ScreenVSync); + uiGLMakeContextCurrent(NULL); + } + else + { + // TODO eventually: VSync for non-GL screen? + } + } EmuRunning = prevstatus; } @@ -2469,7 +2483,7 @@ void CreateMainWindow(bool opengl) if (opengl_good) { uiGLMakeContextCurrent(GLContext); - uiGLSetVSync(0); // TODO: make configurable? + uiGLSetVSync(Config::ScreenVSync); if (!GLScreen_Init()) opengl_good = false; if (opengl_good) { -- cgit v1.2.3 From f70ee39543e7c57ebca8c02f025798d347e3aef2 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Sun, 1 Sep 2019 20:40:55 +0200 Subject: BAHAHAHAHHHAHARKKZKFKKSLFS-*~+ยค MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- melon.rc | 8 ++++---- src/version.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/melon.rc b/melon.rc index 15535c3..e2d8dc2 100644 --- a/melon.rc +++ b/melon.rc @@ -6,8 +6,8 @@ //include version information in .exe, modify these values to match your needs 1 VERSIONINFO -FILEVERSION 0,8,2,0 -PRODUCTVERSION 0,8,2,0 +FILEVERSION 0,8,3,0 +PRODUCTVERSION 0,8,3,0 FILETYPE VFT_APP { BLOCK "StringFileInfo" @@ -15,14 +15,14 @@ FILETYPE VFT_APP BLOCK "040904E4" { VALUE "CompanyName", "Melon Factory of Kuribo64" - VALUE "FileVersion", "0.8.2" + VALUE "FileVersion", "0.8.3" VALUE "FileDescription", "DS emulator, sorta. also 1st quality melon." VALUE "InternalName", "SDnolem" VALUE "LegalCopyright", "2016-2019 Arisotura & co." VALUE "LegalTrademarks", "" VALUE "OriginalFilename", "zafkflzdasd.exe" VALUE "ProductName", "melonDS" - VALUE "ProductVersion", "0.8.2" + VALUE "ProductVersion", "0.8.3" } } BLOCK "VarFileInfo" diff --git a/src/version.h b/src/version.h index 0d71ed8..2e18ba9 100644 --- a/src/version.h +++ b/src/version.h @@ -19,7 +19,7 @@ #ifndef VERSION_H #define VERSION_H -#define MELONDS_VERSION "0.8.2" +#define MELONDS_VERSION "0.8.3" #define MELONDS_URL "http://melonds.kuribo64.net/" -- cgit v1.2.3 From a4f9187b9b06ef3babb7659bf563b809a328e6e5 Mon Sep 17 00:00:00 2001 From: StapleButter Date: Sun, 1 Sep 2019 23:04:06 +0200 Subject: fix bug with vsync checkbox --- src/libui_sdl/DlgVideoSettings.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libui_sdl/DlgVideoSettings.cpp b/src/libui_sdl/DlgVideoSettings.cpp index 155fe8b..afa7357 100644 --- a/src/libui_sdl/DlgVideoSettings.cpp +++ b/src/libui_sdl/DlgVideoSettings.cpp @@ -137,6 +137,10 @@ void OnRendererChanged(uiRadioButtons* rb, void* blarg) UpdateControls(); bool new_usegl = (Config::ScreenUseGL != 0) || (Config::_3DRenderer != 0); + + if (new_usegl) uiControlEnable(uiControl(cbVSync)); + else uiControlDisable(uiControl(cbVSync)); + if (new_usegl != old_usegl) ApplyNewSettings(2); else @@ -332,8 +336,10 @@ void Open() uiRadioButtonsSetSelected(rbRenderer, Config::_3DRenderer); UpdateControls(); - if (Config::ScreenUseGL) uiControlEnable(uiControl(cbVSync)); - else uiControlDisable(uiControl(cbVSync)); + if (Config::ScreenUseGL || Config::_3DRenderer != 0) + uiControlEnable(uiControl(cbVSync)); + else + uiControlDisable(uiControl(cbVSync)); uiControlShow(uiControl(win)); } -- cgit v1.2.3 From 1b40149b0a39d55ed64831050766f0b35a6f2e24 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Wed, 4 Sep 2019 15:41:42 +0200 Subject: blarg here, have code --- src/libui_sdl/PlatformConfig.cpp | 4 +++- src/libui_sdl/PlatformConfig.h | 1 + src/libui_sdl/main.cpp | 18 ++++++++++++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/libui_sdl/PlatformConfig.cpp b/src/libui_sdl/PlatformConfig.cpp index fb31ccd..c8ec19f 100644 --- a/src/libui_sdl/PlatformConfig.cpp +++ b/src/libui_sdl/PlatformConfig.cpp @@ -47,6 +47,7 @@ int ScreenVSync; int ScreenRatio; int LimitFPS; +int AudioSync; int ShowOSD; int DirectBoot; @@ -122,7 +123,8 @@ ConfigEntry PlatformConfigFile[] = {"ScreenVSync", 0, &ScreenVSync, 0, NULL, 0}, {"ScreenRatio", 0, &ScreenRatio, 0, NULL, 0}, - {"LimitFPS", 0, &LimitFPS, 1, NULL, 0}, + {"LimitFPS", 0, &LimitFPS, 0, NULL, 0}, + {"AudioSync", 0, &AudioSync, 1, NULL, 0}, {"ShowOSD", 0, &ShowOSD, 1, NULL, 0}, {"DirectBoot", 0, &DirectBoot, 1, NULL, 0}, diff --git a/src/libui_sdl/PlatformConfig.h b/src/libui_sdl/PlatformConfig.h index 2aede24..842e72a 100644 --- a/src/libui_sdl/PlatformConfig.h +++ b/src/libui_sdl/PlatformConfig.h @@ -58,6 +58,7 @@ extern int ScreenVSync; extern int ScreenRatio; extern int LimitFPS; +extern int AudioSync; extern int ShowOSD; extern int DirectBoot; diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 7fd02bb..c4cc542 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -93,6 +93,7 @@ uiMenuItem* MenuItem_ScreenSizing[4]; uiMenuItem* MenuItem_ScreenFilter; uiMenuItem* MenuItem_LimitFPS; +uiMenuItem* MenuItem_AudioSync; uiMenuItem* MenuItem_ShowOSD; SDL_Thread* EmuThread; @@ -2198,6 +2199,13 @@ void OnSetLimitFPS(uiMenuItem* item, uiWindow* window, void* blarg) else Config::LimitFPS = false; } +void OnSetAudioSync(uiMenuItem* item, uiWindow* window, void* blarg) +{ + int chk = uiMenuItemChecked(item); + if (chk != 0) Config::AudioSync = true; + else Config::AudioSync = false; +} + void OnSetShowOSD(uiMenuItem* item, uiWindow* window, void* blarg) { int chk = uiMenuItemChecked(item); @@ -2442,11 +2450,16 @@ void CreateMainWindowMenu() MenuItem_ScreenFilter = uiMenuAppendCheckItem(menu, "Screen filtering"); uiMenuItemOnClicked(MenuItem_ScreenFilter, OnSetScreenFiltering, NULL); + MenuItem_ShowOSD = uiMenuAppendCheckItem(menu, "Show OSD"); + uiMenuItemOnClicked(MenuItem_ShowOSD, OnSetShowOSD, NULL); + + uiMenuAppendSeparator(menu); + MenuItem_LimitFPS = uiMenuAppendCheckItem(menu, "Limit framerate"); uiMenuItemOnClicked(MenuItem_LimitFPS, OnSetLimitFPS, NULL); - MenuItem_ShowOSD = uiMenuAppendCheckItem(menu, "Show OSD"); - uiMenuItemOnClicked(MenuItem_ShowOSD, OnSetShowOSD, NULL); + MenuItem_AudioSync = uiMenuAppendCheckItem(menu, "Audio sync"); + uiMenuItemOnClicked(MenuItem_AudioSync, OnSetAudioSync, NULL); } void CreateMainWindow(bool opengl) @@ -2688,6 +2701,7 @@ int main(int argc, char** argv) uiMenuItemSetChecked(MenuItem_ScreenFilter, Config::ScreenFilter==1); uiMenuItemSetChecked(MenuItem_LimitFPS, Config::LimitFPS==1); + uiMenuItemSetChecked(MenuItem_AudioSync, Config::AudioSync==1); uiMenuItemSetChecked(MenuItem_ShowOSD, Config::ShowOSD==1); AudioFreq = 48000; // TODO: make configurable? -- cgit v1.2.3 From 02a6fe182c21afe68f39067318f95eacaa051484 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Wed, 4 Sep 2019 16:29:40 +0200 Subject: see, Arisotura, was it that hard? --- src/SPU.cpp | 10 +++++++ src/SPU.h | 1 + src/libui_sdl/DlgVideoSettings.cpp | 10 +++---- src/libui_sdl/main.cpp | 53 +++++++++++++++++++++++++++++++++----- 4 files changed, 63 insertions(+), 11 deletions(-) diff --git a/src/SPU.cpp b/src/SPU.cpp index b36becf..9249416 100644 --- a/src/SPU.cpp +++ b/src/SPU.cpp @@ -738,6 +738,16 @@ void Mix(u32 samples) } +void TrimOutput() +{ + const int halflimit = (OutputBufferSize / 2); + + int readpos = OutputWriteOffset - (halflimit*2); + if (readpos < 0) readpos += (OutputBufferSize*2); + + OutputReadOffset = readpos; +} + void DrainOutput() { OutputReadOffset = 0; diff --git a/src/SPU.h b/src/SPU.h index 7c99887..53a8e0a 100644 --- a/src/SPU.h +++ b/src/SPU.h @@ -35,6 +35,7 @@ void SetBias(u16 bias); void Mix(u32 samples); +void TrimOutput(); void DrainOutput(); void InitOutput(); int GetOutputSize(); diff --git a/src/libui_sdl/DlgVideoSettings.cpp b/src/libui_sdl/DlgVideoSettings.cpp index afa7357..ff88ba8 100644 --- a/src/libui_sdl/DlgVideoSettings.cpp +++ b/src/libui_sdl/DlgVideoSettings.cpp @@ -94,7 +94,7 @@ void RevertSettings() if (old_vsync != Config::ScreenVSync) { Config::ScreenVSync = old_vsync; - ApplyNewSettings(4); + //ApplyNewSettings(4); } if (old_usegl != new_usegl) { @@ -137,10 +137,10 @@ void OnRendererChanged(uiRadioButtons* rb, void* blarg) UpdateControls(); bool new_usegl = (Config::ScreenUseGL != 0) || (Config::_3DRenderer != 0); - + if (new_usegl) uiControlEnable(uiControl(cbVSync)); else uiControlDisable(uiControl(cbVSync)); - + if (new_usegl != old_usegl) ApplyNewSettings(2); else @@ -161,7 +161,7 @@ void OnGLDisplayChanged(uiCheckbox* cb, void* blarg) void OnVSyncChanged(uiCheckbox* cb, void* blarg) { Config::ScreenVSync = uiCheckboxChecked(cb); - ApplyNewSettings(4); + //ApplyNewSettings(4); } void OnThreaded3DChanged(uiCheckbox* cb, void* blarg) @@ -336,7 +336,7 @@ void Open() uiRadioButtonsSetSelected(rbRenderer, Config::_3DRenderer); UpdateControls(); - if (Config::ScreenUseGL || Config::_3DRenderer != 0) + if (Config::ScreenUseGL || Config::_3DRenderer != 0) uiControlEnable(uiControl(cbVSync)); else uiControlDisable(uiControl(cbVSync)); diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index c4cc542..d4afa22 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -130,6 +130,8 @@ bool GL_ScreenSizeDirty; int GL_3DScale; +bool GL_VSyncStatus; + int ScreenGap = 0; int ScreenLayout = 0; int ScreenSizing = 0; @@ -163,6 +165,9 @@ int AudioFreq; float AudioSampleFrac; SDL_AudioDeviceID AudioDevice, MicDevice; +SDL_cond* AudioSync; +SDL_mutex* AudioSyncLock; + u32 MicBufferLength = 2048; s16 MicBuffer[2048]; u32 MicBufferReadPos, MicBufferWritePos; @@ -239,6 +244,8 @@ bool GLScreen_InitOSDShader(GLuint* shader) bool GLScreen_Init() { + GL_VSyncStatus = Config::ScreenVSync; + // TODO: consider using epoxy? if (!OpenGL_Init()) return false; @@ -301,6 +308,13 @@ void GLScreen_DeInit() void GLScreen_DrawScreen() { + bool vsync = Config::ScreenVSync && !HotkeyDown(HK_FastForward); + if (vsync != GL_VSyncStatus) + { + GL_VSyncStatus = vsync; + uiGLSetVSync(vsync); + } + float scale = uiGLGetFramebufferScale(GLContext); glBindFramebuffer(GL_FRAMEBUFFER, uiGLGetFramebuffer(GLContext)); @@ -575,9 +589,14 @@ void AudioCallback(void* data, Uint8* stream, int len) s16 buf_in[1024*2]; s16* buf_out = (s16*)stream; - int num_in = SPU::ReadOutput(buf_in, len_in); + int num_in; int num_out = len; + SDL_LockMutex(AudioSyncLock); + num_in = SPU::ReadOutput(buf_in, len_in); + SDL_CondSignal(AudioSync); + SDL_UnlockMutex(AudioSyncLock); + if (num_in < 1) { memset(stream, 0, len*sizeof(s16)*2); @@ -920,6 +939,7 @@ int EmuThreadFunc(void* burp) Config::LimitFPS = !Config::LimitFPS; uiQueueMain(UpdateFPSLimit, NULL); } + // TODO: similar hotkeys for video/audio sync? if (HotkeyPressed(HK_Pause)) uiQueueMain(TogglePause, NULL); if (HotkeyPressed(HK_Reset)) uiQueueMain(Reset, NULL); @@ -988,9 +1008,23 @@ int EmuThreadFunc(void* burp) } uiAreaQueueRedrawAll(MainDrawArea); - bool limitfps = Config::LimitFPS && !HotkeyDown(HK_FastForward); - bool vsync = Config::ScreenVSync && Screen_UseGL; - SPU::Sync(limitfps || vsync); + bool fastforward = HotkeyDown(HK_FastForward); + + if (Config::AudioSync && !fastforward) + { + SDL_LockMutex(AudioSyncLock); + while (SPU::GetOutputSize() > 1024) + { + int ret = SDL_CondWaitTimeout(AudioSync, AudioSyncLock, 500); + if (ret == SDL_MUTEX_TIMEDOUT) break; + } + SDL_UnlockMutex(AudioSyncLock); + } + else + { + // ensure the audio FIFO doesn't overflow + //SPU::TrimOutput(); + } float framerate = (1000.0f * nlines) / (60.0f * 263.0f); @@ -998,6 +1032,7 @@ int EmuThreadFunc(void* burp) u32 curtick = SDL_GetTicks(); u32 delay = curtick - lasttick; + bool limitfps = Config::LimitFPS && !fastforward; if (limitfps) { float wantedtickF = starttick + (framerate * (fpslimitcount+1)); @@ -2269,7 +2304,7 @@ void ApplyNewSettings(int type) GPU3D::InitRenderer(Screen_UseGL); if (Screen_UseGL) uiGLMakeContextCurrent(NULL); } - else if (type == 4) // vsync + /*else if (type == 4) // vsync { if (Screen_UseGL) { @@ -2281,7 +2316,7 @@ void ApplyNewSettings(int type) { // TODO eventually: VSync for non-GL screen? } - } + }*/ EmuRunning = prevstatus; } @@ -2704,6 +2739,9 @@ int main(int argc, char** argv) uiMenuItemSetChecked(MenuItem_AudioSync, Config::AudioSync==1); uiMenuItemSetChecked(MenuItem_ShowOSD, Config::ShowOSD==1); + AudioSync = SDL_CreateCond(); + AudioSyncLock = SDL_CreateMutex(); + AudioFreq = 48000; // TODO: make configurable? SDL_AudioSpec whatIwant, whatIget; memset(&whatIwant, 0, sizeof(SDL_AudioSpec)); @@ -2779,6 +2817,9 @@ int main(int argc, char** argv) if (AudioDevice) SDL_CloseAudioDevice(AudioDevice); if (MicDevice) SDL_CloseAudioDevice(MicDevice); + SDL_DestroyCond(AudioSync); + SDL_DestroyMutex(AudioSyncLock); + if (MicWavBuffer) delete[] MicWavBuffer; if (ScreenBitmap[0]) uiDrawFreeBitmap(ScreenBitmap[0]); -- cgit v1.2.3 From 3efe90f78a3536bfe86931cbcf24cb88545ccc17 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Wed, 4 Sep 2019 16:40:29 +0200 Subject: deal with SPU FIFO overflow in a more pleasant manner --- src/SPU.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/SPU.cpp b/src/SPU.cpp index 9249416..9d5f04f 100644 --- a/src/SPU.cpp +++ b/src/SPU.cpp @@ -731,7 +731,13 @@ void Mix(u32 samples) OutputBuffer[OutputWriteOffset + 1] = r >> 1; OutputWriteOffset += 2; OutputWriteOffset &= ((2*OutputBufferSize)-1); - if (OutputWriteOffset == OutputReadOffset) printf("!! SOUND FIFO OVERFLOW %d\n", OutputWriteOffset>>1); + if (OutputWriteOffset == OutputReadOffset) + { + //printf("!! SOUND FIFO OVERFLOW %d\n", OutputWriteOffset>>1); + // advance the read position too, to avoid losing the entire FIFO + OutputReadOffset += 2; + OutputReadOffset &= ((2*OutputBufferSize)-1); + } } NDS::ScheduleEvent(NDS::Event_SPU, true, 1024*kSamplesPerRun, Mix, kSamplesPerRun); -- cgit v1.2.3 From e8f4735c7fb4d9fc142a4571e99672ca750be66b Mon Sep 17 00:00:00 2001 From: Arisotura Date: Wed, 4 Sep 2019 17:03:51 +0200 Subject: update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7fabcaf..cf0afed 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

melonDS

- +

-- cgit v1.2.3