From 5e8f4d4f125267183f28381dd2e6636dd1d3f2d9 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Fri, 2 Feb 2018 17:08:10 -1000 Subject: [PATCH] Windows fixes --- NESEmulator/CNESEmulator.cpp | 22 +++++++++------------- NESEmulator/CNESShader.cpp | 21 ++++++++++----------- NESEmulator/malloc.h | 4 +++- hecl | 2 +- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/NESEmulator/CNESEmulator.cpp b/NESEmulator/CNESEmulator.cpp index 061e349f6..7b4856f5c 100644 --- a/NESEmulator/CNESEmulator.cpp +++ b/NESEmulator/CNESEmulator.cpp @@ -37,17 +37,18 @@ extern "C" * of the MIT license. See the LICENSE file for details. */ -#define WINDOWS_BUILD 1 #define DEBUG_HZ 0 #define DEBUG_MAIN_CALLS 0 #define DEBUG_KEY 0 #define DEBUG_LOAD_INFO 1 +#ifndef _WIN32 std::chrono::steady_clock::time_point s_tp = std::chrono::steady_clock::now(); static std::chrono::milliseconds::rep GetTickCount() { return std::chrono::duration_cast(std::chrono::steady_clock::now() - s_tp).count(); } +#endif static const char *VERSION_STRING = "fixNES Alpha v1.0.5"; static char window_title[256]; @@ -87,10 +88,6 @@ static bool inResize = false; static bool inDiskSwitch = false; static bool inReset = false; -#if WINDOWS_BUILD -//#include -//typedef bool (APIENTRY *PFNWGLSWAPINTERVALEXTPROC) (int interval); -//PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = NULL; #if DEBUG_HZ static int emuFrameStart = 0; static int emuTimesCalled = 0; @@ -102,7 +99,6 @@ static int emuMainTimesCalled = 0; static int emuMainTimesSkipped = 0; static int emuMainTotalElapsed = 0; #endif -#endif #define DOTS 341 @@ -239,14 +235,12 @@ void CNESEmulator::InitializeEmulator() sprintf(window_title, "%s NES - %s\n", nesPAL ? "PAL" : "NTSC", VERSION_STRING); sprintf(window_title_pause, "%s (Pause)", window_title); -#if WINDOWS_BUILD #if DEBUG_HZ emuFrameStart = GetTickCount(); #endif #if DEBUG_MAIN_CALLS emuMainFrameStart = GetTickCount(); #endif -#endif cpuCycleTimer = nesPAL ? 16 : 12; //do full frame per update loop ppuCycleTimer = nesPAL ? 5 : 4; @@ -386,7 +380,7 @@ size_t CNESEmulator::supplyAudio(boo::IAudioVoice& voice, size_t frames, int16_t return frames; } -#define CATCHUP_SKIP 1 +#define CATCHUP_SKIP 0 #if CATCHUP_SKIP static int catchupFrames = 0; #endif @@ -399,7 +393,7 @@ void CNESEmulator::NesEmuMainLoop() { if((!emuSkipVsync && emuRenderFrame) || nesPause) { -#if (WINDOWS_BUILD && DEBUG_MAIN_CALLS) +#if DEBUG_MAIN_CALLS emuMainTimesSkipped++; #endif //printf("LC RENDER: %d\n", loopCount); @@ -420,7 +414,7 @@ void CNESEmulator::NesEmuMainLoop() { if(!apuCycle()) { -#if (WINDOWS_BUILD && DEBUG_MAIN_CALLS) +#if DEBUG_MAIN_CALLS emuMainTimesSkipped++; #endif #if CATCHUP_SKIP @@ -459,7 +453,7 @@ void CNESEmulator::NesEmuMainLoop() emuRenderFrame = true; if(fm2playRunning()) fm2playUpdate(); -#if (WINDOWS_BUILD && DEBUG_HZ) +#if DEBUG_HZ emuTimesCalled++; int end = GetTickCount(); emuTotalElapsed += end - emuFrameStart; @@ -507,10 +501,12 @@ void CNESEmulator::NesEmuMainLoop() } while(true); +#if 0 int end = GetTickCount(); printf("%dms\n", end - start); +#endif -#if (WINDOWS_BUILD && DEBUG_MAIN_CALLS) +#if DEBUG_MAIN_CALLS emuMainTimesCalled++; int end = GetTickCount(); //printf("%dms\n", end - start); diff --git a/NESEmulator/CNESShader.cpp b/NESEmulator/CNESShader.cpp index 03b0d1df6..70e6c0dd8 100644 --- a/NESEmulator/CNESShader.cpp +++ b/NESEmulator/CNESShader.cpp @@ -198,11 +198,11 @@ boo::ObjToken CNESShader::BuildShaderDataBinding(boo::I boo::ObjToken uniBuf, boo::ObjToken tex) { - boo::ObjToken bufs[] = {filter.m_uniBuf.get()}; - boo::ObjToken texs[] = {filter.m_booTex.get()}; - return cctx.newShaderDataBinding(SelectPipeline(type, filter.m_gequal), s_VtxFmt, - filter.m_vbo.get(), nullptr, nullptr, 1, bufs, - nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr); + boo::ObjToken bufs[] = {uniBuf.get()}; + boo::ObjToken texs[] = {tex.get()}; + return ctx.newShaderDataBinding(g_Pipeline, g_VtxFmt, + vbo.get(), nullptr, nullptr, 1, bufs, + nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr); } #endif @@ -253,12 +253,11 @@ boo::ObjToken CNESShader::BuildShaderDataBinding(boo::V boo::ObjToken uniBuf, boo::ObjToken tex) { - boo::ObjToken bufs[] = {filter.m_uniBuf.get()}; - boo::ObjToken texs[] = {filter.m_booTex.get()}; - return cctx.newShaderDataBinding(SelectPipeline(type, filter.m_gequal, - filter.m_booTex->type() == boo::TextureType::Render), s_VtxFmt, - filter.m_vbo.get(), nullptr, nullptr, 1, bufs, - nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr); + boo::ObjToken bufs[] = {uniBuf.get()}; + boo::ObjToken texs[] = {tex.get()}; + return ctx.newShaderDataBinding(g_Pipeline, g_VtxFmt, + vbo.get(), nullptr, nullptr, 1, bufs, + nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr); } #endif diff --git a/NESEmulator/malloc.h b/NESEmulator/malloc.h index ebd554502..7f11d0973 100644 --- a/NESEmulator/malloc.h +++ b/NESEmulator/malloc.h @@ -3,8 +3,10 @@ #ifdef __APPLE__ #include +#elif _WIN32 +#include <../ucrt/malloc.h> #else -#include <../include/malloc.h> +#include_next #endif #endif // URDE_NESEMULATOR_MALLOC_H diff --git a/hecl b/hecl index 3454e81f9..e45ccd7b5 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 3454e81f97ae951b85cd4a9e18bb800f6123163e +Subproject commit e45ccd7b55d525080fdc1b87e5e055bd9b9e9fba