diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 033009d5..d0f50ae4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,17 +11,16 @@ set(CMAKE_AUTOUIC ON) endif() if(WIN32) - set(SOURCES ${SRC_CORE} ${SRC_DRIVERS_COMMON} ${SRC_DRIVERS_WIN}) - include_directories( ${CMAKE_SOURCE_DIR}/src/drivers/win/directx ${CMAKE_SOURCE_DIR}/src/drivers/win/zlib ) - add_definitions( - -DWIN32 - -DFCEUDEF_DEBUGGER - -D_USE_SHARED_MEMORY_ - -DPSS_STYLE=2 - -DNOMINMAX - -D_S9XLUA_H - ) - link_directories( ${CMAKE_SOURCE_DIR}/src/drivers/win/directx ) + find_package(OpenGL REQUIRED) + find_package(Qt5 COMPONENTS Widgets OpenGL REQUIRED) + add_definitions( ${Qt5Widgets_DEFINITIONS} ) + include_directories( ${Qt5Widgets_INCLUDE_DIRS} ) + add_definitions( -DMSVC ) + add_definitions( -D__QT_DRIVER__ -DQT_DEPRECATED_WARNINGS ) + add_definitions( -DFCEUDEF_DEBUGGER ) + include_directories( C:/SDL2/include ) + include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/drivers/win/zlib ) + set( SDL2_LDFLAGS C:/SDL2/lib/x64/SDL2.lib ) else(WIN32) # Non Windows System # UNIX (Linux or Mac OSX) @@ -149,6 +148,24 @@ else(WIN32) endif(WIN32) +set( ZLIB_SOURCE + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/win/zlib/adler32.c + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/win/zlib/compress.c + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/win/zlib/crc32.c + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/win/zlib/deflate.c + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/win/zlib/gzio.c + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/win/zlib/infblock.c + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/win/zlib/infcodes.c + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/win/zlib/inffast.c + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/win/zlib/inflate.c + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/win/zlib/inftrees.c + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/win/zlib/infutil.c + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/win/zlib/trees.c + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/win/zlib/uncompr.c + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/win/zlib/unzip.c + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/win/zlib/zutil.c + ) + include_directories( ${CMAKE_SOURCE_DIR}/src ) include_directories( ${CMAKE_SOURCE_DIR}/src/drivers ) @@ -189,6 +206,7 @@ set(SRC_CORE ${CMAKE_CURRENT_SOURCE_DIR}/wave.cpp ${CMAKE_CURRENT_SOURCE_DIR}/x6502.cpp ${LUA_ENGINE_SOURCE} + ${ZLIB_SOURCE} ${CMAKE_CURRENT_SOURCE_DIR}/boards/01-222.cpp ${CMAKE_CURRENT_SOURCE_DIR}/boards/09-034a.cpp ${CMAKE_CURRENT_SOURCE_DIR}/boards/103.cpp @@ -403,8 +421,8 @@ set(SRC_DRIVERS_COMMON ${CMAKE_CURRENT_SOURCE_DIR}/drivers/common/vidblit.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drivers/common/os_utils.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drivers/common/nes_ntsc.c - ${CMAKE_CURRENT_SOURCE_DIR}/drivers/videolog/nesvideos-piece.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/drivers/videolog/rgbtorgb.cpp + #${CMAKE_CURRENT_SOURCE_DIR}/drivers/videolog/nesvideos-piece.cpp + #${CMAKE_CURRENT_SOURCE_DIR}/drivers/videolog/rgbtorgb.cpp ) if ( ${GTK} ) @@ -514,7 +532,7 @@ else() target_link_libraries( ${APP_NAME} ${Qt5Widgets_LIBRARIES} ${Qt5OpenGL_LIBRARIES} - ${OPENGL_LDFLAGS} + ${OPENGL_LDFLAGS} OpenGL::GL ${SDL2_LDFLAGS} ${MINIZIP_LDFLAGS} ${ZLIB_LIBRARIES} ${LUA_LDFLAGS} @@ -522,6 +540,10 @@ target_link_libraries( ${APP_NAME} ) endif() +target_link_libraries( ${APP_NAME} wsock32 ws2_32 ) + +set_target_properties(${APP_NAME} PROPERTIES WIN32_EXECUTABLE TRUE) + if (APPLE) install( TARGETS ${APP_NAME} diff --git a/src/drivers/Qt/ConsoleDebugger.cpp b/src/drivers/Qt/ConsoleDebugger.cpp index aafb0dda..ead2c06d 100644 --- a/src/drivers/Qt/ConsoleDebugger.cpp +++ b/src/drivers/Qt/ConsoleDebugger.cpp @@ -54,6 +54,7 @@ #include "../../asm.h" #include "../../ppu.h" #include "../../x6502.h" +#include "../../common/os_utils.h" #include "common/configSys.h" #include "Qt/main.h" @@ -2592,7 +2593,7 @@ void FCEUD_DebugBreakpoint( int bpNum ) frameAdvance_Delay_count++; } } - usleep(16667); + msleep(16); } // since we unfreezed emulation, reset delta_cycles counter ResetDebugStatisticsDeltaCounters(); diff --git a/src/drivers/Qt/ConsoleViewerGL.cpp b/src/drivers/Qt/ConsoleViewerGL.cpp index 335772da..df909ec9 100644 --- a/src/drivers/Qt/ConsoleViewerGL.cpp +++ b/src/drivers/Qt/ConsoleViewerGL.cpp @@ -24,6 +24,10 @@ #include #include +#ifdef WIN32 +#include +#endif + #include #include #include diff --git a/src/drivers/Qt/ConsoleViewerSDL.cpp b/src/drivers/Qt/ConsoleViewerSDL.cpp index db831053..34bfd822 100644 --- a/src/drivers/Qt/ConsoleViewerSDL.cpp +++ b/src/drivers/Qt/ConsoleViewerSDL.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +//#include #include "Qt/nes_shm.h" #include "Qt/fceuWrapper.h" diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index 44a19a90..d5e42f88 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -145,6 +145,7 @@ consoleWin_t::consoleWin_t(QWidget *parent) if ( opt ) { + #ifndef WIN32 int policy, prio, nice; g_config->getOption( "SDL.GuiSchedPolicy", &policy ); @@ -154,6 +155,7 @@ consoleWin_t::consoleWin_t(QWidget *parent) setNicePriority( nice ); setSchedParam( policy, prio ); + #endif } } @@ -1983,6 +1985,7 @@ void consoleWin_t::openMsgLogWin(void) return; } +#if defined(__linux__) || defined(__APPLE__) || defined(__unix__) int consoleWin_t::setNicePriority( int value ) { int ret = 0; @@ -2135,6 +2138,7 @@ int consoleWin_t::setSchedParam( int policy, int priority ) #endif return ret; } +#endif void consoleWin_t::syncActionConfig( QAction *act, const char *property ) { @@ -2232,6 +2236,7 @@ void emulatorThread_t::init(void) if ( opt ) { + #ifndef WIN32 int policy, prio, nice; g_config->getOption( "SDL.EmuSchedPolicy", &policy ); @@ -2241,6 +2246,7 @@ void emulatorThread_t::init(void) setNicePriority( nice ); setSchedParam( policy, prio ); + #endif } } @@ -2254,6 +2260,7 @@ void emulatorThread_t::setPriority( QThread::Priority priority_req ) //printf("Set Priority: %i \n", priority() ); } +#if defined(__linux__) || defined(__unix__) || defined(__APPLE__) int emulatorThread_t::setNicePriority( int value ) { int ret = 0; @@ -2384,6 +2391,7 @@ int emulatorThread_t::setSchedParam( int policy, int priority ) #endif return ret; } +#endif void emulatorThread_t::run(void) { diff --git a/src/drivers/Qt/LuaControl.cpp b/src/drivers/Qt/LuaControl.cpp index 3d63504b..3314f623 100644 --- a/src/drivers/Qt/LuaControl.cpp +++ b/src/drivers/Qt/LuaControl.cpp @@ -23,11 +23,16 @@ #include #include +#ifdef WIN32 +#include +#endif + #include #include #include #include "../../fceu.h" +#include "../../common/os_utils.h" #ifdef _S9XLUA_H #include "../../fceulua.h" @@ -429,7 +434,7 @@ int LuaKillMessageBox(void) while ( openLuaKillMsgBox ) { - usleep(100000); + msleep(100); } return luaKillMsgBoxRetVal; diff --git a/src/drivers/Qt/TimingConf.cpp b/src/drivers/Qt/TimingConf.cpp index ead6dcdc..9c702ace 100644 --- a/src/drivers/Qt/TimingConf.cpp +++ b/src/drivers/Qt/TimingConf.cpp @@ -25,10 +25,12 @@ #include #include +#ifndef WIN32 #include #include #include #include +#endif #include #include @@ -47,6 +49,7 @@ //---------------------------------------------------------------------------- static bool hasNicePermissions( int val ) { +#ifndef WIN32 int usrID; bool usrRoot; @@ -74,6 +77,7 @@ static bool hasNicePermissions( int val ) } #endif +#endif return false; } //---------------------------------------------------------------------------- @@ -103,9 +107,13 @@ TimingConfDialog_t::TimingConfDialog_t(QWidget *parent) emuSchedPrioLabel = new QLabel( tr("Priority (RT)") ); emuSchedNiceLabel = new QLabel( tr("Priority (Nice)") ); +#ifndef WIN32 emuSchedPolicyBox->addItem( tr("SCHED_OTHER") , SCHED_OTHER ); emuSchedPolicyBox->addItem( tr("SCHED_FIFO") , SCHED_FIFO ); emuSchedPolicyBox->addItem( tr("SCHED_RR") , SCHED_RR ); +#else + emuSchedPolicyBox->addItem( tr("TODO") , 0 ); +#endif grid->addWidget( new QLabel( tr("Policy") ), 0, 0 ); grid->addWidget( emuSchedPolicyBox, 0, 1 ); @@ -126,9 +134,13 @@ TimingConfDialog_t::TimingConfDialog_t(QWidget *parent) guiSchedPrioLabel = new QLabel( tr("Priority (RT)") ); guiSchedNiceLabel = new QLabel( tr("Priority (Nice)") ); +#ifndef WIN32 guiSchedPolicyBox->addItem( tr("SCHED_OTHER") , SCHED_OTHER ); guiSchedPolicyBox->addItem( tr("SCHED_FIFO") , SCHED_FIFO ); guiSchedPolicyBox->addItem( tr("SCHED_RR") , SCHED_RR ); +#else + guiSchedPolicyBox->addItem( tr("TODO") , 0 ); +#endif grid->addWidget( new QLabel( tr("Policy") ), 0, 0 ); grid->addWidget( guiSchedPolicyBox, 0, 1 ); @@ -199,6 +211,7 @@ void TimingConfDialog_t::emuSchedCtlChange( int state ) //---------------------------------------------------------------------------- void TimingConfDialog_t::saveValues(void) { +#ifndef WIN32 int policy, prio, nice; if ( consoleWindow == NULL ) @@ -226,10 +239,12 @@ void TimingConfDialog_t::saveValues(void) //printf("GUI Sched: %i %i %i\n", policy, prio, nice ); g_config->save(); +#endif } //---------------------------------------------------------------------------- void TimingConfDialog_t::emuSchedNiceChange(int val) { +#ifndef WIN32 if ( consoleWindow == NULL ) { return; @@ -253,10 +268,12 @@ void TimingConfDialog_t::emuSchedNiceChange(int val) updateSliderValues(); } fceuWrapperUnLock(); +#endif } //---------------------------------------------------------------------------- void TimingConfDialog_t::emuSchedPrioChange(int val) { +#ifndef WIN32 int policy, prio; if ( consoleWindow == NULL ) @@ -284,10 +301,12 @@ void TimingConfDialog_t::emuSchedPrioChange(int val) updateSliderValues(); } fceuWrapperUnLock(); +#endif } //---------------------------------------------------------------------------- void TimingConfDialog_t::emuSchedPolicyChange( int index ) { +#ifndef WIN32 int policy, prio; if ( consoleWindow == NULL ) @@ -320,10 +339,12 @@ void TimingConfDialog_t::emuSchedPolicyChange( int index ) updateSliderLimits(); updateSliderValues(); fceuWrapperUnLock(); +#endif } //---------------------------------------------------------------------------- void TimingConfDialog_t::guiSchedNiceChange(int val) { +#ifndef WIN32 if ( consoleWindow == NULL ) { return; @@ -347,10 +368,12 @@ void TimingConfDialog_t::guiSchedNiceChange(int val) updateSliderValues(); } fceuWrapperUnLock(); +#endif } //---------------------------------------------------------------------------- void TimingConfDialog_t::guiSchedPrioChange(int val) { +#ifndef WIN32 int policy, prio; if ( consoleWindow == NULL ) @@ -378,10 +401,12 @@ void TimingConfDialog_t::guiSchedPrioChange(int val) updateSliderValues(); } fceuWrapperUnLock(); +#endif } //---------------------------------------------------------------------------- void TimingConfDialog_t::guiSchedPolicyChange( int index ) { +#ifndef WIN32 int policy, prio; if ( consoleWindow == NULL ) @@ -414,10 +439,12 @@ void TimingConfDialog_t::guiSchedPolicyChange( int index ) updateSliderLimits(); updateSliderValues(); fceuWrapperUnLock(); +#endif } //---------------------------------------------------------------------------- void TimingConfDialog_t::updatePolicyBox(void) { +#ifndef WIN32 int policy, prio; if ( consoleWindow == NULL ) @@ -445,11 +472,12 @@ void TimingConfDialog_t::updatePolicyBox(void) guiSchedPolicyBox->setCurrentIndex( j ); } } - +#endif } //---------------------------------------------------------------------------- void TimingConfDialog_t::updateSliderValues(void) { +#ifndef WIN32 int policy, prio; bool hasNicePerms; @@ -496,7 +524,7 @@ void TimingConfDialog_t::updateSliderValues(void) guiSchedNiceLabel->setEnabled( hasNicePerms ); guiSchedNiceSlider->setEnabled( hasNicePerms ); - +#endif } //---------------------------------------------------------------------------- void TimingConfDialog_t::updateSliderLimits(void) @@ -506,6 +534,7 @@ void TimingConfDialog_t::updateSliderLimits(void) return; } +#ifndef WIN32 emuSchedNiceSlider->setMinimum( -20 ); emuSchedNiceSlider->setMaximum( 20 ); emuSchedPrioSlider->setMinimum( consoleWindow->emulatorThread->getMinSchedPriority() ); @@ -515,6 +544,7 @@ void TimingConfDialog_t::updateSliderLimits(void) guiSchedNiceSlider->setMaximum( 20 ); guiSchedPrioSlider->setMinimum( consoleWindow->getMinSchedPriority() ); guiSchedPrioSlider->setMaximum( consoleWindow->getMaxSchedPriority() ); +#endif } //---------------------------------------------------------------------------- diff --git a/src/drivers/Qt/TraceLogger.cpp b/src/drivers/Qt/TraceLogger.cpp index 5f75cf41..e0b48edf 100644 --- a/src/drivers/Qt/TraceLogger.cpp +++ b/src/drivers/Qt/TraceLogger.cpp @@ -41,6 +41,7 @@ #include "../../ines.h" #include "../../nsf.h" #include "../../movie.h" +#include "../../common/os_utils.h" #include "Qt/ConsoleUtilities.h" #include "Qt/TraceLogger.h" @@ -367,7 +368,7 @@ void TraceLoggerDialog_t::logMaxLinesChanged(int index) logPrev = logging; logging = 0; - usleep(1000); + msleep(1); initTraceLogBuffer( maxLines ); @@ -382,7 +383,7 @@ void TraceLoggerDialog_t::toggleLoggingOnOff(void) if ( logging ) { logging = 0; - usleep( 1000 ); + msleep( 1 ); pushMsgToLogBuffer("Logging Finished"); startStopButton->setText( tr("Start Logging") ); diff --git a/src/drivers/Qt/config.cpp b/src/drivers/Qt/config.cpp index 71d1783e..bd179a0c 100644 --- a/src/drivers/Qt/config.cpp +++ b/src/drivers/Qt/config.cpp @@ -34,16 +34,17 @@ #include #endif -#include +//#include #include #include #include #include #include -#include -#include -#include +//#include +//#include +//#include +#include static const char* HotkeyStrings[HK_MAX] = { "CheatMenu", @@ -321,6 +322,10 @@ InitConfig() config->addOption("periodicsaves", "SDL.PeriodicSaves", 0); char* home_dir = getenv("HOME"); + if ( home_dir == NULL ) + { + home_dir = ""; + } // prefixed with _ because they are internal (not cli options) config->addOption("_lastopenfile", "SDL.LastOpenFile", home_dir); config->addOption("_laststatefrom", "SDL.LastLoadStateFrom", home_dir); diff --git a/src/drivers/Qt/fceuWrapper.cpp b/src/drivers/Qt/fceuWrapper.cpp index 047d8f6f..9a6188a3 100644 --- a/src/drivers/Qt/fceuWrapper.cpp +++ b/src/drivers/Qt/fceuWrapper.cpp @@ -48,6 +48,7 @@ #include "../../fceu.h" #include "../../movie.h" #include "../../version.h" +#include "../../common/os_utils.h" #ifdef _S9XLUA_H #include "../../fceulua.h" @@ -61,6 +62,11 @@ #include "../videolog/nesvideos-piece.h" #endif +#ifdef _MSC_VER +//not #if defined(_WIN32) || defined(_WIN64) because we have strncasecmp in mingw +#define strncasecmp _strnicmp +#define strcasecmp _stricmp +#endif //***************************************************************** // Define Global Variables to be shared with FCEU Core //***************************************************************** @@ -136,13 +142,17 @@ EMUFILE_FILE* FCEUD_UTF8_fstream(const char *fn, const char *m) //return new std::fstream(fn,mode); } -static const char *s_linuxCompilerString = "g++ " __VERSION__; +#ifdef _MSC_VER +static const char *s_CompilerString = "MSVC"; +#else +static const char *s_CompilerString = "g++ " __VERSION__; +#endif /** * Returns the compiler string. */ const char *FCEUD_GetCompilerString(void) { - return s_linuxCompilerString; + return s_CompilerString; } /** @@ -314,7 +324,7 @@ int LoadGame(const char *path, bool silent) } isloaded = 1; - FCEUD_NetworkConnect(); + //FCEUD_NetworkConnect(); return 1; } @@ -861,7 +871,7 @@ FCEUD_Update(uint8 *XBuf, int Count) { int blitDone = 0; - extern int FCEUDnetplay; + //extern int FCEUDnetplay; #ifdef CREATE_AVI if (LoggingEnabled == 2 || (eoptions&EO_NOTHROTTLE)) @@ -955,19 +965,19 @@ FCEUD_Update(uint8 *XBuf, } } } //else puts("Skipped"); - else if (!NoWaiting && FCEUDnetplay && (uflow || tmpcan >= (Count * 1.8))) - { - if (Count > tmpcan) Count=tmpcan; - while(tmpcan > 0) - { - // printf("Overwrite: %d\n", (Count <= tmpcan)?Count : tmpcan); - #ifdef CREATE_AVI - if (!mutecapture) - #endif - WriteSound(Buffer, (Count <= tmpcan)?Count : tmpcan); - tmpcan -= Count; - } - } + //else if (!NoWaiting && FCEUDnetplay && (uflow || tmpcan >= (Count * 1.8))) + //{ + // if (Count > tmpcan) Count=tmpcan; + // while(tmpcan > 0) + // { + // // printf("Overwrite: %d\n", (Count <= tmpcan)?Count : tmpcan); + // #ifdef CREATE_AVI + // if (!mutecapture) + // #endif + // WriteSound(Buffer, (Count <= tmpcan)?Count : tmpcan); + // tmpcan -= Count; + // } + //} } else { @@ -1076,7 +1086,7 @@ int fceuWrapperUpdate( void ) // sleep to allow request to be serviced. if ( mutexPending > 0 ) { - usleep( 100000 ); + msleep( 100 ); } lock_acq = fceuWrapperTryLock(); @@ -1087,7 +1097,7 @@ int fceuWrapperUpdate( void ) { printf("Error: Emulator Failed to Acquire Mutex\n"); } - usleep( 100000 ); + msleep( 100 ); return -1; } @@ -1116,7 +1126,7 @@ int fceuWrapperUpdate( void ) emulatorHasMutux = 0; - usleep( 100000 ); + msleep( 100 ); } return 0; } diff --git a/src/drivers/Qt/input.cpp b/src/drivers/Qt/input.cpp index cd29ffc8..77b0dde4 100644 --- a/src/drivers/Qt/input.cpp +++ b/src/drivers/Qt/input.cpp @@ -1540,9 +1540,9 @@ static ButtConfig fkbmap[0x48] = { MK (LEFTSHIFT), MK (Z), MK (X), MK (C), MK (V), MK (B), MK (N), MK (M), MK (COMMA), MK (PERIOD), MK (SLASH), MK (RIGHTALT), MK (RIGHTSHIFT), MK (LEFTALT), - MK (SPACE), - MK (DELETE), MK (END), MK (PAGEDOWN), - MK (CURSORUP), MK (CURSORLEFT), MK (CURSORRIGHT), MK (CURSORDOWN) + MK (SPACE) + //MK (DELETE), MK (END), MK (PAGEDOWN), + //MK (CURSORUP), MK (CURSORLEFT), MK (CURSORRIGHT), MK (CURSORDOWN) }; /** @@ -1788,7 +1788,7 @@ int DWaitButton (const uint8_t * text, ButtConfig * bc, int *buttonConfigStatus { int done = 0; - usleep(10000); + SDL_Delay(10); timeout_ms -= 10; if ( timeout_ms <= 0 ) diff --git a/src/drivers/Qt/main.cpp b/src/drivers/Qt/main.cpp index a7c98626..6b84ba56 100644 --- a/src/drivers/Qt/main.cpp +++ b/src/drivers/Qt/main.cpp @@ -51,6 +51,7 @@ static void MessageOutput(QtMsgType type, const QMessageLogContext &context, con } } +#undef main // undef main in case SDL_Main int main( int argc, char *argv[] ) { @@ -59,6 +60,8 @@ int main( int argc, char *argv[] ) QApplication app(argc, argv); const char *styleSheetEnv = NULL; + printf("test\n"); + styleSheetEnv = ::getenv("FCEUX_QT_STYLESHEET"); if ( styleSheetEnv != NULL ) diff --git a/src/drivers/Qt/nes_shm.cpp b/src/drivers/Qt/nes_shm.cpp index 575b743c..83d23f10 100644 --- a/src/drivers/Qt/nes_shm.cpp +++ b/src/drivers/Qt/nes_shm.cpp @@ -20,13 +20,13 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include #include "Qt/nes_shm.h" diff --git a/src/drivers/Qt/sdl-joystick.cpp b/src/drivers/Qt/sdl-joystick.cpp index 31f02316..daf41963 100644 --- a/src/drivers/Qt/sdl-joystick.cpp +++ b/src/drivers/Qt/sdl-joystick.cpp @@ -27,8 +27,8 @@ #include "Qt/sdl-joystick.h" #include -#include -#include +//#include +//#include #include //#define MAX_JOYSTICKS 32 diff --git a/src/drivers/Qt/sdl-throttle.cpp b/src/drivers/Qt/sdl-throttle.cpp index 427ef89d..37121ac6 100644 --- a/src/drivers/Qt/sdl-throttle.cpp +++ b/src/drivers/Qt/sdl-throttle.cpp @@ -239,7 +239,7 @@ int highPrecSleep( double timeSeconds ) ret = nanosleep( &req, &rem ); #else - SDL_Delay( (long)(time_left * 1e3) ); + SDL_Delay( (long)(timeSeconds * 1e3) ); #endif return ret; } diff --git a/src/drivers/Qt/unix-netplay.cpp b/src/drivers/Qt/unix-netplay.cpp index 9c538d71..f9d07dd0 100644 --- a/src/drivers/Qt/unix-netplay.cpp +++ b/src/drivers/Qt/unix-netplay.cpp @@ -34,18 +34,18 @@ #include #include "common/configSys.h" -#include -#include -#include -#include -#include #include +#include +#include #include -#include #ifdef WIN32 #include #else +#include +#include +#include +#include #include #include #include diff --git a/src/drivers/common/configSys.cpp b/src/drivers/common/configSys.cpp index 02d7dfdd..29fa9386 100644 --- a/src/drivers/common/configSys.cpp +++ b/src/drivers/common/configSys.cpp @@ -3,7 +3,8 @@ #include #include #include -#include + +//#include #include "../../types.h" #include "configSys.h" @@ -559,6 +560,7 @@ Config::parse(int argc, return error; } +#ifndef WIN32 // try to read cfg.d/* std::string cfgd_dir_name = _dir + "/" + "cfg.d/"; DIR *d; @@ -585,7 +587,9 @@ Config::parse(int argc, closedir(d); } - +#else +// FIXME TODO WIN32 +#endif // parse the arguments return _parseArgs(argc, argv); } diff --git a/src/drivers/common/os_utils.cpp b/src/drivers/common/os_utils.cpp index 90460584..02de2d29 100644 --- a/src/drivers/common/os_utils.cpp +++ b/src/drivers/common/os_utils.cpp @@ -4,6 +4,8 @@ #if defined(WIN32) #include +#include +#include #else #include #include @@ -15,8 +17,8 @@ int fceu_mkdir( const char *path ) { int retval; #if defined(WIN32) - retval = mkdir(path); - chmod(path, 755); + retval = _mkdir(path); + _chmod(path, 755); #else retval = mkdir(path, S_IRWXU); @@ -67,7 +69,7 @@ bool fceu_file_exists( const char *filepath ) { #ifdef WIN32 FILE *fp; - fp = ::fopen( filename, "r" ); + fp = ::fopen( filepath, "r" ); if ( fp != NULL ) { @@ -85,3 +87,14 @@ bool fceu_file_exists( const char *filepath ) return false; } //************************************************************ +int msleep( int ms ) +{ + int ret = 0; + #ifdef WIN32 + Sleep(ms); + #else + ret = usleep(ms*1000); + #endif + return ret; +} +//************************************************************ diff --git a/src/drivers/common/os_utils.h b/src/drivers/common/os_utils.h index 4ebd7e06..dc8a2ed4 100644 --- a/src/drivers/common/os_utils.h +++ b/src/drivers/common/os_utils.h @@ -7,3 +7,4 @@ int fceu_mkpath( const char *path ); bool fceu_file_exists( const char *filepath ); +int msleep( int ms ); diff --git a/src/emufile.h b/src/emufile.h index 3f186725..78e4d6ee 100644 --- a/src/emufile.h +++ b/src/emufile.h @@ -219,7 +219,7 @@ public: reserve(pos+(s32)bytes); memcpy(buf()+pos,ptr,bytes); pos += (s32)bytes; - len = std::max(pos,len); + len = std::max(pos,len); } virtual int fseek(int offset, int origin){ diff --git a/src/fceu.cpp b/src/fceu.cpp index a9c629a5..ec825762 100644 --- a/src/fceu.cpp +++ b/src/fceu.cpp @@ -43,7 +43,7 @@ #include "file.h" #include "vsuni.h" #include "ines.h" -#ifdef WIN32 +#ifdef __WIN_DRIVER__ #include "drivers/win/pref.h" #include "utils/xstring.h" @@ -65,7 +65,7 @@ extern void RefreshThrottleFPS(); #endif //TODO - we really need some kind of global platform-specific options api -#ifdef WIN32 +#ifdef __WIN_DRIVER__ #include "drivers/win/main.h" #include "drivers/win/memview.h" #include "drivers/win/cheat.h" @@ -161,7 +161,7 @@ void FCEU_TogglePPU(void) { FCEUI_printf("Old PPU loaded"); } normalscanlines = (dendy ? 290 : 240)+newppu; // use flag as number! -#ifdef WIN32 +#ifdef __WIN_DRIVER__ SetMainWindowText(); #endif } @@ -176,7 +176,7 @@ static void FCEU_CloseGame(void) FCEUSS_Save(FCEU_MakeFName(FCEUMKF_RESUMESTATE, 0, 0).c_str(), false); } -#ifdef WIN32 +#ifdef __WIN_DRIVER__ extern char LoadedRomFName[2048]; if (storePreferences(mass_replace(LoadedRomFName, "|", ".").c_str())) FCEUD_PrintError("Couldn't store debugging data"); @@ -193,7 +193,7 @@ static void FCEU_CloseGame(void) } if (GameInfo->type != GIT_NSF) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ if (disableAutoLSCheats == 2) FCEU_FlushGameCheats(0, 1); else if (disableAutoLSCheats == 1) @@ -496,7 +496,7 @@ FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode, bool silen if (load_result == LOADER_OK) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ // ################################## Start of SP CODE ########################### extern char LoadedRomFName[2048]; extern int loadDebugDataFailed; @@ -516,7 +516,7 @@ FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode, bool silen FCEU_OpenGenie()) { FCEUI_SetGameGenie(false); -#ifdef WIN32 +#ifdef __WIN_DRIVER__ genie = 0; #endif } @@ -555,7 +555,7 @@ FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode, bool silen ResetScreenshotsCounter(); -#if defined (WIN32) || defined (WIN64) +#ifdef __WIN_DRIVER__ DoDebuggerDataReload(); // Reloads data without reopening window CDLoggerROMChanged(); if (hMemView) UpdateColorTable(); @@ -703,7 +703,7 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski // the user is holding Frame Advance key // clear paused flag temporarily EmulationPaused &= ~EMULATIONPAUSED_PAUSED; -#ifdef WIN32 +#ifdef __WIN_DRIVER__ // different emulation speed when holding Frame Advance if (fps_scale_frameadvance > 0) { @@ -713,7 +713,7 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski #endif } else { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ if (fps_scale_frameadvance > 0) { // restore emulation speed when Frame Advance is not held @@ -758,7 +758,7 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski FCEU_PutImage(); -#ifdef WIN32 +#ifdef __WIN_DRIVER__ //These Windows only dialogs need to be updated only once per frame so they are included here // CaH4e3: can't see why, this is only cause problems with selection // adelikat: selection is only a problem when not paused, it should be paused to select, we want to see the values update @@ -797,7 +797,7 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski { EmulationPaused = EMULATIONPAUSED_PAUSED; // restore EMULATIONPAUSED_PAUSED flag and clear EMULATIONPAUSED_FA flag JustFrameAdvanced = true; - #ifdef WIN32 + #ifdef __WIN_DRIVER__ if (soundoptions & SO_MUTEFA) //mute the frame advance if the user requested it *SoundBufSize = 0; //keep sound muted #endif @@ -962,7 +962,7 @@ void PowerNES(void) { timestampbase = 0; X6502_Power(); -#ifdef WIN32 +#ifdef __WIN_DRIVER__ ResetDebugStatisticsCounters(); #endif FCEU_PowerCheats(); @@ -971,7 +971,7 @@ void PowerNES(void) { extern uint8 *XBackBuf; memset(XBackBuf, 0, 256 * 256); -#ifdef WIN32 +#ifdef __WIN_DRIVER__ Update_RAM_Search(); // Update_RAM_Watch() is also called. #endif @@ -1109,7 +1109,7 @@ void FCEUI_SetRegion(int region, int notify) { totalscanlines = normalscanlines + (overclock_enabled ? postrenderscanlines : 0); FCEUI_SetVidSystem(pal_emulation); RefreshThrottleFPS(); -#ifdef WIN32 +#ifdef __WIN_DRIVER__ UpdateCheckedMenuItems(); PushCurrentVideoSettings(); #endif @@ -1260,7 +1260,7 @@ bool FCEU_IsValidUI(EFCEUI ui) { case FCEUI_INSERT_COIN: if (!GameInfo) return false; if (FCEUMOV_Mode(MOVIEMODE_RECORD)) return true; -#ifdef WIN32 +#ifdef __WIN_DRIVER__ if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR) && isTaseditorRecording()) return true; #endif if (!FCEUMOV_Mode(MOVIEMODE_INACTIVE)) return false; @@ -1401,7 +1401,7 @@ uint8 FCEU_ReadRomByte(uint32 i) { void FCEU_WriteRomByte(uint32 i, uint8 value) { if (i < 16) -#ifdef WIN32 +#ifdef __WIN_DRIVER__ MessageBox(hMemView, "Sorry", "You can't edit the ROM header.", MB_OK | MB_ICONERROR); #else printf("Sorry, you can't edit the ROM header.\n"); diff --git a/src/fceu.h b/src/fceu.h index 64ce2e56..eca3d6c3 100644 --- a/src/fceu.h +++ b/src/fceu.h @@ -98,7 +98,7 @@ extern bool movieSubtitles; //#include "driver.h" -typedef struct { +typedef struct fceu_settings_struct { int PAL; int NetworkPlay; int SoundVolume; //Master volume diff --git a/src/input.cpp b/src/input.cpp index 6a6e78dc..8b519ac1 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1008,7 +1008,7 @@ static void CommandSelectSaveSlot(void) { if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ handleEmuCmdByTaseditor(execcmd); #endif } else @@ -1026,7 +1026,7 @@ static void CommandStateSave(void) { if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ handleEmuCmdByTaseditor(execcmd); #endif } else @@ -1047,7 +1047,7 @@ static void CommandStateLoad(void) { if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ handleEmuCmdByTaseditor(execcmd); #endif } else @@ -1110,7 +1110,7 @@ void LagCounterToggle(void) static void LaunchTasEditor(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ extern bool enterTASEditor(); enterTASEditor(); #endif @@ -1118,56 +1118,56 @@ static void LaunchTasEditor(void) static void LaunchMemoryWatch(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ CreateMemWatch(); #endif } static void LaunchDebugger(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ DoDebug(0); #endif } static void LaunchNTView(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ DoNTView(); #endif } static void LaunchPPU(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ DoPPUView(); #endif } static void LaunchHex(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ DoMemView(); #endif } static void LaunchTraceLogger(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ DoTracer(); #endif } static void LaunchCodeDataLogger(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ DoCDLogger(); #endif } static void LaunchCheats(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ extern HWND hCheat; ConfigCheats(hCheat); #endif @@ -1175,7 +1175,7 @@ static void LaunchCheats(void) static void LaunchRamWatch(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ extern void OpenRamWatch(); //adelikat: Blah blah hacky, I know OpenRamWatch(); #endif @@ -1183,14 +1183,14 @@ static void LaunchRamWatch(void) static void LaunchRamSearch(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ extern void OpenRamSearch(); OpenRamSearch(); #endif } static void RamSearchOpLT(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ if (GameInfo) { extern void SetSearchType(int SearchType); @@ -1202,7 +1202,7 @@ static void RamSearchOpLT(void) { } static void RamSearchOpGT(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ if (GameInfo) { extern void SetSearchType(int SearchType); @@ -1214,7 +1214,7 @@ static void RamSearchOpGT(void) { } static void RamSearchOpLTE(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ if (GameInfo) { extern void SetSearchType(int SearchType); @@ -1226,7 +1226,7 @@ static void RamSearchOpLTE(void) { } static void RamSearchOpGTE(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ if (GameInfo) { extern void SetSearchType(int SearchType); @@ -1238,7 +1238,7 @@ static void RamSearchOpGTE(void) { } static void RamSearchOpEQ(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ if (GameInfo) { extern void SetSearchType(int SearchType); @@ -1250,7 +1250,7 @@ static void RamSearchOpEQ(void) { } static void RamSearchOpNE(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ if (GameInfo) { extern void SetSearchType(int SearchType); @@ -1263,7 +1263,7 @@ static void RamSearchOpNE(void) { static void DebuggerStepInto() { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ if (GameInfo) { extern void DoDebuggerStepInto(); @@ -1279,7 +1279,7 @@ static void FA_SkipLag(void) static void OpenRom(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ extern HWND hAppWnd; LoadNewGamey(hAppWnd, 0); #endif @@ -1287,14 +1287,14 @@ static void OpenRom(void) static void CloseRom(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ CloseGame(); #endif } void ReloadRom(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) { // load most recent project @@ -1326,14 +1326,14 @@ static void UndoRedoSavestate(void) static void FCEUI_DoExit(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ DoFCEUExit(); #endif } void ToggleFullscreen() { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ extern int SetVideoMode(int fs); //adelikat: Yeah, I know, hacky extern void UpdateCheckedMenuItems(); @@ -1349,20 +1349,20 @@ void ToggleFullscreen() static void TaseditorRewindOn(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ mustRewindNow = true; #endif } static void TaseditorRewindOff(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ mustRewindNow = false; #endif } static void TaseditorCommand(void) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) handleEmuCmdByTaseditor(execcmd); #endif diff --git a/src/movie.cpp b/src/movie.cpp index 0a33f5f0..a908bbff 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -21,6 +21,7 @@ #include "utils/memory.h" #include "utils/xstring.h" #include +#include #ifdef CREATE_AVI #include "drivers/videolog/nesvideos-piece.h" @@ -28,6 +29,8 @@ #ifdef WIN32 #include + +#ifdef __WIN_DRIVER__ #include "./drivers/win/common.h" #include "./drivers/win/window.h" extern void AddRecentMovieFile(const char *filename); @@ -35,6 +38,8 @@ extern void AddRecentMovieFile(const char *filename); extern bool mustEngageTaseditor; #endif +#endif + extern int RAMInitOption; extern int RAMInitSeed; @@ -619,7 +624,7 @@ static void LoadFM2_binarychunk(MovieData& movieData, EMUFILE* fp, int size) fp->fseek(curr,SEEK_SET); //the amount todo is the min of the limiting size we received and the remaining contents of the file - int todo = std::min(size, flen); + int todo = std::min(size, flen); int numRecords = todo/recordsize; if (movieData.loadFrameCount!=-1 && movieData.loadFrameCount= 0) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ int result = MessageBox(hAppWnd, "This movie is a TAS Editor project file.\nIt can be modified in TAS Editor only.\n\nOpen it in TAS Editor now?", "Movie Replay", MB_YESNO); if (result == IDYES) mustEngageTaseditor = true; @@ -1498,7 +1503,7 @@ bool FCEUMOV_ReadState(EMUFILE* is, uint32 size) if(tempMovieData.guid != currMovieData.guid) { //mbg 8/18/08 - this code can be used to turn the error message into an OK/CANCEL - #ifdef WIN32 + #ifdef __WIN_DRIVER__ std::string msg = "There is a mismatch between savestate's movie and current movie.\ncurrent: " + currMovieData.guid.toString() + "\nsavestate: " + tempMovieData.guid.toString() + "\n\nThis means that you have loaded a savestate belonging to a different movie than the one you are playing now.\n\nContinue loading this savestate anyway?"; int result = MessageBox(hAppWnd, msg.c_str(), "Error loading savestate", MB_OKCANCEL); if(result == IDCANCEL) @@ -1892,7 +1897,7 @@ void FCEUI_MoviePlayFromBeginning(void) { if (movieMode == MOVIEMODE_TASEDITOR) { -#ifdef WIN32 +#ifdef __WIN_DRIVER__ handleEmuCmdByTaseditor(EMUCMD_MOVIE_PLAY_FROM_BEGINNING); #endif } else if (movieMode != MOVIEMODE_INACTIVE) @@ -1925,7 +1930,7 @@ void FCEUI_MoviePlayFromBeginning(void) //currMovieData.loadSavestateFrom(&currMovieData.savestate); //TODO: make something like this work instead so it doesn't have to reload } } -#ifdef WIN32 +#ifdef __WIN_DRIVER__ SetMainWindowText(); #endif } diff --git a/src/state.cpp b/src/state.cpp index 91f1f92e..fe98c3b8 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -43,7 +43,7 @@ #endif //TODO - we really need some kind of global platform-specific options api -#ifdef WIN32 +#ifdef __WIN_DRIVER__ #include "drivers/win/main.h" #include "drivers/win/cheat.h" #include "drivers/win/ram_search.h" @@ -312,7 +312,7 @@ static bool ReadStateChunks(EMUFILE* is, int32 totalsize) //MBG TODO - can this be moved to a better place? //does it even make sense, displaying XBuf when its XBackBuf we just loaded? -#ifdef WIN32 +#ifdef __WIN_DRIVER__ else { FCEUD_BlitScreen(XBuf); @@ -795,7 +795,7 @@ bool FCEUSS_Load(const char *fname, bool display_message) } #endif -#ifdef WIN32 +#ifdef __WIN_DRIVER__ Update_RAM_Search(); // Update_RAM_Watch() is also called. #endif @@ -874,7 +874,7 @@ void AddExState(void *v, uint32 s, int type, const char *desc) std::string desc = tmp; if(names.find(desc) != names.end()) { -#ifdef _MSC_VER +#ifdef __WIN_DRIVER__ MessageBox(NULL,"OH NO!!! YOU HAVE AN INVALID SFORMAT! POST A BUG TICKET ALONG WITH INFO ON THE ROM YOURE USING\n","OOPS",MB_OK); #else printf("OH NO!!! YOU HAVE AN INVALID SFORMAT! POST A BUG TICKET ALONG WITH INFO ON THE ROM YOURE USING\n"); diff --git a/src/types.h b/src/types.h index b7764196..492a21ff 100644 --- a/src/types.h +++ b/src/types.h @@ -131,6 +131,10 @@ typedef uint32_t uint32; #endif +#if defined(WIN32) && !defined(__QT_DRIVER__) +#define __WIN_DRIVER__ +#endif + typedef void (*writefunc)(uint32 A, uint8 V); typedef uint8 (*readfunc)(uint32 A); diff --git a/src/version.h b/src/version.h index 3d65c382..0e331c6d 100644 --- a/src/version.h +++ b/src/version.h @@ -25,7 +25,7 @@ #define __FCEU_VERSION //todo - everyone will want to support this eventually, i suppose -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__QT_DRIVER__) #include "scmrev.h" #else #ifdef SVN_REV diff --git a/src/video.cpp b/src/video.cpp index 3c43d7bd..8a3e747d 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -37,7 +37,7 @@ #include "fceulua.h" #endif -#ifdef WIN32 +#ifdef __WIN_DRIVER__ #include "drivers/win/common.h" //For DirectX constants #include "drivers/win/input.h" #endif @@ -289,7 +289,7 @@ void FCEU_PutImage(void) uint32 ci = 0; uint32 color; -#ifdef WIN32 +#ifdef __WIN_DRIVER__ // This doesn't work in anything except windows for now. // It doesn't get set anywhere in other ports. if (!oldInputDisplay) diff --git a/src/wave.cpp b/src/wave.cpp index de6f1dc6..2925983a 100644 --- a/src/wave.cpp +++ b/src/wave.cpp @@ -24,7 +24,7 @@ void FCEU_WriteWaveData(int32 *Buffer, int Count) int16 *dest; int x; -#ifndef WIN32 +#ifndef __WIN_DRIVER__ if(!soundlog) return; #else if(!soundlog && !FCEUI_AviIsRecording()) return; @@ -46,7 +46,7 @@ void FCEU_WriteWaveData(int32 *Buffer, int Count) if(soundlog) wsize+=fwrite(temp,1,Count*sizeof(int16),soundlog); - #ifdef WIN32 + #ifdef __WIN_DRIVER__ if(FCEUI_AviIsRecording()) { FCEUI_AviSoundUpdate((void*)temp, Count);