WIP: Emscripten support
This commit is contained in:
parent
c65d9ad287
commit
11d3755116
|
@ -1,4 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 2.8.11)
|
cmake_minimum_required(VERSION 2.8.11)
|
||||||
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
Project(mkxp)
|
Project(mkxp)
|
||||||
|
|
||||||
## Setup options ##
|
## Setup options ##
|
||||||
|
@ -14,7 +15,7 @@ set(EXTERNAL_LIB_PATH "" CACHE PATH "External precompiled lib prefix")
|
||||||
include(cmake/PrepUtils.cmake)
|
include(cmake/PrepUtils.cmake)
|
||||||
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||||
IF("${CMAKE_SYSTEM}" MATCHES "Linux")
|
IF("${CMAKE_SYSTEM}" MATCHES "Linux")
|
||||||
SET(LINUX ON)
|
SET(LINUX ON)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
@ -53,6 +54,16 @@ elseif(APPLE)
|
||||||
set(LIB_PATH "lib")
|
set(LIB_PATH "lib")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(EMTERPRETER_OPT "-O0 -s ASSERTIONS=0 -s TOTAL_MEMORY=67108864 -s ABORTING_MALLOC=0 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 -s NO_EXIT_RUNTIME=1 --embed-file \"game\"")
|
||||||
|
set(EMTERPRETER_OPT "${EMTERPRETER_OPT} -s EMTERPRETIFY_WHITELIST=\"['__ZN8Graphics10transitionEiPKci','__ZL18graphicsTransitioniPmm','_call_cfunc','_rb_call0','_rb_call','_rb_eval','_rb_eval_string','_eval_node','_eval','_rb_f_eval','_rb_funcall2','_rb_protect','_rb_yield_0','_loop_i','_rb_rescue2','_rb_f_loop','__ZL10evalHelperP7evalArg','__ZL10evalStringmmPi','__ZL14runRMXPScriptsR13BacktraceData','__Z13rgssThreadFunPv','_main','__ZL11inputUpdateiPmm','__ZN11EventThread7processER14RGSSThreadData','__ZL17mriBindingExecutev','__ZL14mriBindingInitv','_module_setup']\"")
|
||||||
|
|
||||||
|
message(STATUS ${EMTERPRETER_OPT})
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EMTERPRETER_OPT}")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EMTERPRETER_OPT}")
|
||||||
|
|
||||||
|
message(STATUS ${CMAKE_C_FLAGS})
|
||||||
|
|
||||||
set(CMAKE_SKIP_BUILD_RPATH TRUE)
|
set(CMAKE_SKIP_BUILD_RPATH TRUE)
|
||||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||||
set(CMAKE_INSTALL_RPATH ${BIN_RPATH})
|
set(CMAKE_INSTALL_RPATH ${BIN_RPATH})
|
||||||
|
@ -64,12 +75,12 @@ find_package(PkgConfig REQUIRED)
|
||||||
|
|
||||||
if (EXTERNAL_LIB_PATH)
|
if (EXTERNAL_LIB_PATH)
|
||||||
set(CMAKE_PREFIX_PATH ${EXTERNAL_LIB_PATH})
|
set(CMAKE_PREFIX_PATH ${EXTERNAL_LIB_PATH})
|
||||||
|
|
||||||
if(EXISTS "${EXTERNAL_LIB_PATH}/${LIB_PATH}/pkgconfig/")
|
if(EXISTS "${EXTERNAL_LIB_PATH}/${LIB_PATH}/pkgconfig/")
|
||||||
SET(ENV{PKG_CONFIG_PATH} "${EXTERNAL_LIB_PATH}/${LIB_PATH}/pkgconfig/")
|
SET(ENV{PKG_CONFIG_PATH} "${EXTERNAL_LIB_PATH}/${LIB_PATH}/pkgconfig/")
|
||||||
endif()
|
endif()
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(PLATFORM_SHARED_LIBS
|
set(PLATFORM_SHARED_LIBS
|
||||||
libSDL2.dylib libSDL2_image-2.0.0.dylib libSDL2_ttf-2.0.0.dylib libSDL_sound-1.0.1.dylib
|
libSDL2.dylib libSDL2_image-2.0.0.dylib libSDL2_ttf-2.0.0.dylib libSDL_sound-1.0.1.dylib
|
||||||
libfreetype.6.dylib libsigc-2.0.0.dylib
|
libfreetype.6.dylib libsigc-2.0.0.dylib
|
||||||
CACHE STRING "List of shared libraries that need to be copied into the OS X bundle")
|
CACHE STRING "List of shared libraries that need to be copied into the OS X bundle")
|
||||||
|
@ -92,9 +103,10 @@ pkg_check_modules(SDL2_TTF REQUIRED SDL2_ttf)
|
||||||
pkg_check_modules(SDL2_IMAGE REQUIRED SDL2_image)
|
pkg_check_modules(SDL2_IMAGE REQUIRED SDL2_image)
|
||||||
pkg_check_modules(SDL_SOUND REQUIRED SDL_sound)
|
pkg_check_modules(SDL_SOUND REQUIRED SDL_sound)
|
||||||
|
|
||||||
find_package(Boost 1.49 COMPONENTS program_options REQUIRED)
|
#find_package(Boost 1.49 COMPONENTS program_options REQUIRED)
|
||||||
find_package(OpenAL REQUIRED)
|
find_package(OpenAL REQUIRED)
|
||||||
find_package(ZLIB REQUIRED)
|
pkg_check_modules(ZLIB REQUIRED zlib)
|
||||||
|
#find_package(ZLIB REQUIRED)
|
||||||
|
|
||||||
## Setup main source ##
|
## Setup main source ##
|
||||||
|
|
||||||
|
@ -395,7 +407,7 @@ link_directories(
|
||||||
${PIXMAN_LIBRARY_DIRS}
|
${PIXMAN_LIBRARY_DIRS}
|
||||||
${PHYSFS_LIBRARY_DIRS}
|
${PHYSFS_LIBRARY_DIRS}
|
||||||
${SDL2_LIBRARY_DIRS} # Blindly assume other SDL bits are in same directory
|
${SDL2_LIBRARY_DIRS} # Blindly assume other SDL bits are in same directory
|
||||||
${Boost_LIBRARY_DIR}
|
# ${Boost_LIBRARY_DIR}
|
||||||
${MRI_LIBDIR}
|
${MRI_LIBDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -417,11 +429,13 @@ target_include_directories(${PROJECT_NAME} PRIVATE
|
||||||
${PIXMAN_INCLUDE_DIRS}
|
${PIXMAN_INCLUDE_DIRS}
|
||||||
${PHYSFS_INCLUDE_DIRS}
|
${PHYSFS_INCLUDE_DIRS}
|
||||||
${SDL2_INCLUDE_DIRS} # Blindly assume other SDL bits are in same directory
|
${SDL2_INCLUDE_DIRS} # Blindly assume other SDL bits are in same directory
|
||||||
${Boost_INCLUDE_DIR}
|
# ${Boost_INCLUDE_DIR}
|
||||||
${MRI_INCLUDE_DIRS}
|
${MRI_INCLUDE_DIRS}
|
||||||
${VORBISFILE_INCLUDE_DIRS}
|
${VORBISFILE_INCLUDE_DIRS}
|
||||||
${FLUID_INCLUDE_DIRS}
|
${FLUID_INCLUDE_DIRS}
|
||||||
${OPENAL_INCLUDE_DIR}
|
${OPENAL_INCLUDE_DIR}
|
||||||
|
${SDL_SOUND_INCLUDE_DIRS}
|
||||||
|
${FREETYPE_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
@ -432,14 +446,21 @@ target_link_libraries(${PROJECT_NAME}
|
||||||
${SDL_SOUND_LIBRARIES}
|
${SDL_SOUND_LIBRARIES}
|
||||||
${PHYSFS_LIBRARIES}
|
${PHYSFS_LIBRARIES}
|
||||||
${PIXMAN_LIBRARIES}
|
${PIXMAN_LIBRARIES}
|
||||||
${Boost_LIBRARIES}
|
# ${Boost_LIBRARIES}
|
||||||
${MRI_LIBRARIES}
|
${MRI_LIBRARIES}
|
||||||
${VORBISFILE_LIBRARIES}
|
${VORBISFILE_LIBRARIES}
|
||||||
${FLUID_LIBRARIES}
|
${FLUID_LIBRARIES}
|
||||||
${OPENAL_LIBRARY}
|
${OPENAL_LIBRARY}
|
||||||
${ZLIB_LIBRARY}
|
${ZLIB_LIBRARY}
|
||||||
|
|
||||||
${PLATFORM_LIBRARIES}
|
${PLATFORM_LIBRARIES}
|
||||||
|
"libruby-static.a"
|
||||||
|
"libfreetype.a"
|
||||||
|
"libz.a"
|
||||||
|
"libpng.a"
|
||||||
|
"libogg.a"
|
||||||
|
"libvorbis.a"
|
||||||
|
"libvorbisfile.a"
|
||||||
|
"libjpeg.a"
|
||||||
)
|
)
|
||||||
|
|
||||||
PostBuildMacBundle(${PROJECT_NAME} "" "${PLATFORM_COPY_LIBS}")
|
PostBuildMacBundle(${PROJECT_NAME} "" "${PLATFORM_COPY_LIBS}")
|
||||||
|
|
|
@ -164,7 +164,9 @@ static void mriBindingInit()
|
||||||
static void
|
static void
|
||||||
showMsg(const std::string &msg)
|
showMsg(const std::string &msg)
|
||||||
{
|
{
|
||||||
shState->eThread().showMessageBox(msg.c_str());
|
printf("Show msg %s\n", msg.c_str());
|
||||||
|
return;
|
||||||
|
// shState->eThread().showMessageBox(msg.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printP(int argc, VALUE *argv,
|
static void printP(int argc, VALUE *argv,
|
||||||
|
@ -350,6 +352,9 @@ static VALUE evalHelper(evalArg *arg)
|
||||||
return rb_funcall2(Qnil, rb_intern("eval"), ARRAY_SIZE(argv), argv);
|
return rb_funcall2(Qnil, rb_intern("eval"), ARRAY_SIZE(argv), argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
#include <emscripten.h>
|
||||||
|
#endif
|
||||||
static VALUE evalString(VALUE string, VALUE filename, int *state)
|
static VALUE evalString(VALUE string, VALUE filename, int *state)
|
||||||
{
|
{
|
||||||
evalArg arg = { string, filename };
|
evalArg arg = { string, filename };
|
||||||
|
@ -482,6 +487,10 @@ static void runRMXPScripts(BacktraceData &btData)
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
#ifdef __EMSCRIPTEN
|
||||||
|
emscripten_sleep(10);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (long i = 0; i < scriptCount; ++i)
|
for (long i = 0; i < scriptCount; ++i)
|
||||||
{
|
{
|
||||||
VALUE script = rb_ary_entry(scriptArray, i);
|
VALUE script = rb_ary_entry(scriptArray, i);
|
||||||
|
@ -508,6 +517,9 @@ static void runRMXPScripts(BacktraceData &btData)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("tick\n");
|
||||||
|
shState->eThread().process(shState->rtData());
|
||||||
|
|
||||||
VALUE exc = rb_gv_get("$!");
|
VALUE exc = rb_gv_get("$!");
|
||||||
if (rb_obj_class(exc) != getRbData()->exc[Reset])
|
if (rb_obj_class(exc) != getRbData()->exc[Reset])
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -24,12 +24,14 @@
|
||||||
#include "exception.h"
|
#include "exception.h"
|
||||||
#include "binding-util.h"
|
#include "binding-util.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "eventthread.h"
|
||||||
|
|
||||||
RB_METHOD(inputUpdate)
|
RB_METHOD(inputUpdate)
|
||||||
{
|
{
|
||||||
RB_UNUSED_PARAM;
|
RB_UNUSED_PARAM;
|
||||||
|
|
||||||
shState->input().update();
|
shState->input().update();
|
||||||
|
shState->eThread().process(shState->rtData());
|
||||||
|
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,9 @@
|
||||||
|
|
||||||
#ifndef BOOSTHASH_H
|
#ifndef BOOSTHASH_H
|
||||||
#define BOOSTHASH_H
|
#define BOOSTHASH_H
|
||||||
|
#include <string>
|
||||||
#include <boost/unordered/unordered_map.hpp>
|
#include <map>
|
||||||
#include <boost/unordered/unordered_set.hpp>
|
#include <set>
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
/* Wrappers around the boost unordered template classes,
|
/* Wrappers around the boost unordered template classes,
|
||||||
|
@ -34,7 +33,7 @@ template<typename K, typename V>
|
||||||
class BoostHash
|
class BoostHash
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef boost::unordered_map<K, V> BoostType;
|
typedef std::map<K, V> BoostType;
|
||||||
typedef std::pair<K, V> PairType;
|
typedef std::pair<K, V> PairType;
|
||||||
BoostType p;
|
BoostType p;
|
||||||
|
|
||||||
|
@ -98,7 +97,7 @@ template<typename K>
|
||||||
class BoostSet
|
class BoostSet
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef boost::unordered_set<K> BoostType;
|
typedef std::set<K> BoostType;
|
||||||
BoostType p;
|
BoostType p;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -21,9 +21,9 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <boost/program_options/options_description.hpp>
|
//#include <boost/program_options/options_description.hpp>
|
||||||
#include <boost/program_options/parsers.hpp>
|
//#include <boost/program_options/parsers.hpp>
|
||||||
#include <boost/program_options/variables_map.hpp>
|
//#include <boost/program_options/variables_map.hpp>
|
||||||
|
|
||||||
#include <SDL_filesystem.h>
|
#include <SDL_filesystem.h>
|
||||||
|
|
||||||
|
@ -141,8 +141,8 @@ std::set<T> setFromVec(const std::vector<T> &vec)
|
||||||
return std::set<T>(vec.begin(), vec.end());
|
return std::set<T>(vec.begin(), vec.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef std::vector<std::string> StringVec;
|
//typedef std::vector<std::string> StringVec;
|
||||||
namespace po = boost::program_options;
|
//namespace po = boost::program_options;
|
||||||
|
|
||||||
#define CONF_FILE "mkxp.conf"
|
#define CONF_FILE "mkxp.conf"
|
||||||
|
|
||||||
|
@ -151,6 +151,8 @@ Config::Config()
|
||||||
|
|
||||||
void Config::read(int argc, char *argv[])
|
void Config::read(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
gameFolder = "game";
|
||||||
|
#if 0
|
||||||
#define PO_DESC_ALL \
|
#define PO_DESC_ALL \
|
||||||
PO_DESC(rgssVersion, int, 0) \
|
PO_DESC(rgssVersion, int, 0) \
|
||||||
PO_DESC(debugMode, bool, false) \
|
PO_DESC(debugMode, bool, false) \
|
||||||
|
@ -267,6 +269,8 @@ void Config::read(int argc, char *argv[])
|
||||||
|
|
||||||
#undef PO_DESC
|
#undef PO_DESC
|
||||||
#undef PO_DESC_ALL
|
#undef PO_DESC_ALL
|
||||||
|
#endif
|
||||||
|
preloadScripts.insert("win32_wrap.rb");
|
||||||
|
|
||||||
rgssVersion = clamp(rgssVersion, 0, 3);
|
rgssVersion = clamp(rgssVersion, 0, 3);
|
||||||
|
|
||||||
|
@ -299,6 +303,7 @@ static void setupScreenSize(Config &conf)
|
||||||
|
|
||||||
void Config::readGameINI()
|
void Config::readGameINI()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!customScript.empty())
|
if (!customScript.empty())
|
||||||
{
|
{
|
||||||
game.title = baseName(customScript);
|
game.title = baseName(customScript);
|
||||||
|
@ -310,10 +315,12 @@ void Config::readGameINI()
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string iniFilename = execName + ".ini";
|
std::string iniFilename = execName + ".ini";
|
||||||
SDLRWStream iniFile(iniFilename.c_str(), "r");
|
SDLRWStream iniFile(iniFilename.c_str(), "r");
|
||||||
|
#if 0
|
||||||
if (iniFile)
|
if (iniFile)
|
||||||
{
|
{
|
||||||
INIConfiguration ic;
|
INIConfiguration ic;
|
||||||
|
@ -344,6 +351,9 @@ void Config::readGameINI()
|
||||||
Debug() << "FAILED to open" << iniFilename;
|
Debug() << "FAILED to open" << iniFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
game.scripts = "Data/Scripts.rxdata";
|
||||||
|
strReplace(game.scripts, '\\', '/');
|
||||||
#ifdef INI_ENCODING
|
#ifdef INI_ENCODING
|
||||||
/* Can add more later */
|
/* Can add more later */
|
||||||
const char *languages[] =
|
const char *languages[] =
|
||||||
|
|
55
src/config.h
55
src/config.h
|
@ -28,57 +28,62 @@
|
||||||
|
|
||||||
struct Config
|
struct Config
|
||||||
{
|
{
|
||||||
int rgssVersion;
|
int rgssVersion = 0;
|
||||||
|
|
||||||
bool debugMode;
|
bool debugMode = false;
|
||||||
bool printFPS;
|
bool printFPS = false;
|
||||||
|
|
||||||
bool winResizable;
|
bool winResizable = false;
|
||||||
bool fullscreen;
|
bool fullscreen = false;
|
||||||
bool fixedAspectRatio;
|
bool fixedAspectRatio = true;
|
||||||
bool smoothScaling;
|
bool smoothScaling = true;
|
||||||
bool vsync;
|
bool vsync = false;
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
int defScreenW;
|
int defScreenW;
|
||||||
int defScreenH;
|
int defScreenH;
|
||||||
std::string windowTitle;
|
std::string windowTitle;
|
||||||
|
=======
|
||||||
|
int defScreenW = 0;
|
||||||
|
int defScreenH = 0;
|
||||||
|
>>>>>>> WIP: Emscripten support
|
||||||
|
|
||||||
int fixedFramerate;
|
int fixedFramerate = 0;
|
||||||
bool frameSkip;
|
bool frameSkip =true;
|
||||||
bool syncToRefreshrate;
|
bool syncToRefreshrate = false;
|
||||||
|
|
||||||
bool solidFonts;
|
bool solidFonts = false;
|
||||||
|
|
||||||
bool subImageFix;
|
bool subImageFix = false;
|
||||||
bool enableBlitting;
|
bool enableBlitting = true;
|
||||||
int maxTextureSize;
|
int maxTextureSize = 0;
|
||||||
|
|
||||||
std::string gameFolder;
|
std::string gameFolder = ".";
|
||||||
bool anyAltToggleFS;
|
bool anyAltToggleFS = false;
|
||||||
bool enableReset;
|
bool enableReset = true;
|
||||||
bool allowSymlinks;
|
bool allowSymlinks = false;
|
||||||
bool pathCache;
|
bool pathCache=true;
|
||||||
|
|
||||||
std::string dataPathOrg;
|
std::string dataPathOrg;
|
||||||
std::string dataPathApp;
|
std::string dataPathApp;
|
||||||
|
|
||||||
std::string iconPath;
|
std::string iconPath;
|
||||||
std::string execName;
|
std::string execName = "Game";
|
||||||
std::string titleLanguage;
|
std::string titleLanguage;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
std::string soundFont;
|
std::string soundFont;
|
||||||
bool chorus;
|
bool chorus = false;
|
||||||
bool reverb;
|
bool reverb = false;
|
||||||
} midi;
|
} midi;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
int sourceCount;
|
int sourceCount = 6;
|
||||||
} SE;
|
} SE;
|
||||||
|
|
||||||
bool useScriptNames;
|
bool useScriptNames = false;
|
||||||
|
|
||||||
std::string customScript;
|
std::string customScript;
|
||||||
std::set<std::string> preloadScripts;
|
std::set<std::string> preloadScripts;
|
||||||
|
|
|
@ -100,7 +100,9 @@ bool EventThread::allocUserEvents()
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
#include <emscripten.h>
|
||||||
|
#endif
|
||||||
EventThread::EventThread()
|
EventThread::EventThread()
|
||||||
: fullscreen(false),
|
: fullscreen(false),
|
||||||
showCursor(false)
|
showCursor(false)
|
||||||
|
@ -108,64 +110,43 @@ EventThread::EventThread()
|
||||||
|
|
||||||
void EventThread::process(RGSSThreadData &rtData)
|
void EventThread::process(RGSSThreadData &rtData)
|
||||||
{
|
{
|
||||||
|
SDL_Event event;
|
||||||
|
UnidirMessage<Vec2i> windowSizeMsg;
|
||||||
|
|
||||||
|
static bool once = true;
|
||||||
|
if (once) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
SDL_Window *win = rtData.window;
|
SDL_Window *win = rtData.window;
|
||||||
UnidirMessage<Vec2i> &windowSizeMsg = rtData.windowSizeMsg;
|
UnidirMessage<Vec2i> &windowSizeMsg = rtData.windowSizeMsg;
|
||||||
|
|
||||||
initALCFunctions(rtData.alcDev);
|
initALCFunctions(rtData.alcDev);
|
||||||
|
|
||||||
// XXX this function breaks input focus on OSX
|
|
||||||
#ifndef __MACOSX__
|
|
||||||
SDL_SetEventFilter(eventFilter, &rtData);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fullscreen = rtData.config.fullscreen;
|
fullscreen = rtData.config.fullscreen;
|
||||||
int toggleFSMod = rtData.config.anyAltToggleFS ? KMOD_ALT : KMOD_LALT;
|
toggleFSMod = rtData.config.anyAltToggleFS ? KMOD_ALT : KMOD_LALT;
|
||||||
|
|
||||||
fps.lastFrame = SDL_GetPerformanceCounter();
|
fps.lastFrame = SDL_GetPerformanceCounter();
|
||||||
fps.displayCounter = 0;
|
fps.displayCounter = 0;
|
||||||
fps.acc = 0;
|
fps.acc = 0;
|
||||||
fps.accDiv = 0;
|
fps.accDiv = 0;
|
||||||
|
|
||||||
if (rtData.config.printFPS)
|
|
||||||
fps.sendUpdates.set();
|
|
||||||
|
|
||||||
bool displayingFPS = false;
|
|
||||||
|
|
||||||
bool cursorInWindow = false;
|
|
||||||
/* Will be updated eventually */
|
|
||||||
SDL_Rect gameScreen = { 0, 0, 0, 0 };
|
|
||||||
|
|
||||||
/* SDL doesn't send an initial FOCUS_GAINED event */
|
|
||||||
bool windowFocused = true;
|
|
||||||
|
|
||||||
bool terminate = false;
|
|
||||||
|
|
||||||
SDL_Joystick *js = 0;
|
|
||||||
if (SDL_NumJoysticks() > 0)
|
if (SDL_NumJoysticks() > 0)
|
||||||
js = SDL_JoystickOpen(0);
|
js = SDL_JoystickOpen(0);
|
||||||
|
|
||||||
char buffer[128];
|
|
||||||
|
|
||||||
char pendingTitle[128];
|
|
||||||
bool havePendingTitle = false;
|
|
||||||
|
|
||||||
bool resetting = false;
|
|
||||||
|
|
||||||
int winW, winH;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
SDL_GetWindowSize(win, &winW, &winH);
|
SDL_GetWindowSize(win, &winW, &winH);
|
||||||
|
|
||||||
SettingsMenu *sMenu = 0;
|
once = false;
|
||||||
|
}
|
||||||
while (true)
|
while (SDL_PollEvent(&event))
|
||||||
{
|
{
|
||||||
if (!SDL_WaitEvent(&event))
|
#ifdef __EMSCRIPTEN__
|
||||||
{
|
emscripten_sleep(10);
|
||||||
Debug() << "EventThread: Event error";
|
#endif
|
||||||
break;
|
// if (!SDL_WaitEvent(&event))
|
||||||
}
|
// {
|
||||||
|
// Debug() << "EventThread: Event error";
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
|
||||||
if (sMenu && sMenu->onEvent(event))
|
if (sMenu && sMenu->onEvent(event))
|
||||||
{
|
{
|
||||||
|
@ -460,12 +441,12 @@ void EventThread::process(RGSSThreadData &rtData)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Just in case */
|
/* Just in case */
|
||||||
rtData.syncPoint.resumeThreads();
|
//rtData.syncPoint.resumeThreads();
|
||||||
|
|
||||||
if (SDL_JoystickGetAttached(js))
|
//if (SDL_JoystickGetAttached(js))
|
||||||
SDL_JoystickClose(js);
|
// SDL_JoystickClose(js);
|
||||||
|
|
||||||
delete sMenu;
|
//delete sMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EventThread::eventFilter(void *data, SDL_Event *event)
|
int EventThread::eventFilter(void *data, SDL_Event *event)
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
class SettingsMenu;
|
||||||
struct RGSSThreadData;
|
struct RGSSThreadData;
|
||||||
typedef struct ALCdevice_struct ALCdevice;
|
typedef struct ALCdevice_struct ALCdevice;
|
||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
|
@ -123,6 +123,35 @@ private:
|
||||||
double acc;
|
double acc;
|
||||||
uint32_t accDiv;
|
uint32_t accDiv;
|
||||||
} fps;
|
} fps;
|
||||||
|
|
||||||
|
SDL_Window *win;
|
||||||
|
int toggleFSMod;
|
||||||
|
|
||||||
|
bool displayingFPS = false;
|
||||||
|
|
||||||
|
bool cursorInWindow = false;
|
||||||
|
/* Will be updated eventually */
|
||||||
|
SDL_Rect gameScreen = { 0, 0, 0, 0 };
|
||||||
|
|
||||||
|
/* SDL doesn't send an initial FOCUS_GAINED event */
|
||||||
|
bool windowFocused = true;
|
||||||
|
|
||||||
|
bool terminate = false;
|
||||||
|
|
||||||
|
SDL_Joystick *js = 0;
|
||||||
|
|
||||||
|
char buffer[128];
|
||||||
|
|
||||||
|
char pendingTitle[128];
|
||||||
|
bool havePendingTitle = false;
|
||||||
|
|
||||||
|
bool resetting = false;
|
||||||
|
|
||||||
|
int winW, winH;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
SettingsMenu *sMenu = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Used to asynchronously inform the RGSS thread
|
/* Used to asynchronously inform the RGSS thread
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
** You should have received a copy of the GNU General Public License
|
** You should have received a copy of the GNU General Public License
|
||||||
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#include <cassert>
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
|
|
||||||
#include "rgssad.h"
|
#include "rgssad.h"
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#elif __WINDOWS__
|
#elif __WINDOWS__
|
||||||
#define FLUID_LIB "fluidsynth.dll"
|
#define FLUID_LIB "fluidsynth.dll"
|
||||||
#else
|
#else
|
||||||
#error "platform not recognized"
|
//#error "platform not recognized"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct FluidFunctions fluid;
|
struct FluidFunctions fluid;
|
||||||
|
@ -22,6 +22,7 @@ static void *so;
|
||||||
|
|
||||||
void initFluidFunctions()
|
void initFluidFunctions()
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
#ifdef SHARED_FLUID
|
#ifdef SHARED_FLUID
|
||||||
|
|
||||||
#define FLUID_FUN(name, type) \
|
#define FLUID_FUN(name, type) \
|
||||||
|
@ -60,4 +61,7 @@ fail:
|
||||||
SDL_UnloadObject(so);
|
SDL_UnloadObject(so);
|
||||||
so = 0;
|
so = 0;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
so = 0;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -316,7 +316,9 @@ private:
|
||||||
|
|
||||||
/* Nanoseconds per second */
|
/* Nanoseconds per second */
|
||||||
#define NS_PER_S 1000000000
|
#define NS_PER_S 1000000000
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
#include <emscripten.h>
|
||||||
|
#endif
|
||||||
struct FPSLimiter
|
struct FPSLimiter
|
||||||
{
|
{
|
||||||
uint64_t lastTickCount;
|
uint64_t lastTickCount;
|
||||||
|
@ -418,6 +420,7 @@ struct FPSLimiter
|
||||||
private:
|
private:
|
||||||
void delayTicks(uint64_t ticks)
|
void delayTicks(uint64_t ticks)
|
||||||
{
|
{
|
||||||
|
#ifndef __EMSCRIPTEN__
|
||||||
#if defined(HAVE_NANOSLEEP)
|
#if defined(HAVE_NANOSLEEP)
|
||||||
struct timespec req;
|
struct timespec req;
|
||||||
uint64_t nsec = ticks / tickFreqNS;
|
uint64_t nsec = ticks / tickFreqNS;
|
||||||
|
@ -439,6 +442,10 @@ private:
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
SDL_Delay(ticks / tickFreqMS);
|
SDL_Delay(ticks / tickFreqMS);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifdef __EMSCRIPTEN
|
||||||
|
emscripten_sleep(ticks /tickFreqMS);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
11
src/main.cpp
11
src/main.cpp
|
@ -232,7 +232,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.readGameINI();
|
conf.readGameINI();
|
||||||
|
printf("%s\n", conf.gameFolder.c_str());
|
||||||
if (conf.windowTitle.empty())
|
if (conf.windowTitle.empty())
|
||||||
conf.windowTitle = conf.game.title;
|
conf.windowTitle = conf.game.title;
|
||||||
|
|
||||||
|
@ -325,8 +325,9 @@ int main(int argc, char *argv[])
|
||||||
rtData.bindingUpdateMsg.post(loadBindings(conf));
|
rtData.bindingUpdateMsg.post(loadBindings(conf));
|
||||||
|
|
||||||
/* Start RGSS thread */
|
/* Start RGSS thread */
|
||||||
SDL_Thread *rgssThread =
|
//SDL_Thread *rgssThread =
|
||||||
SDL_CreateThread(rgssThreadFun, "rgss", &rtData);
|
// SDL_CreateThread(rgssThreadFun, "rgss", &rtData);
|
||||||
|
::rgssThreadFun(&rtData);
|
||||||
|
|
||||||
/* Start event processing */
|
/* Start event processing */
|
||||||
eventThread.process(rtData);
|
eventThread.process(rtData);
|
||||||
|
@ -350,8 +351,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
/* If RGSS thread ack'd request, wait for it to shutdown,
|
/* If RGSS thread ack'd request, wait for it to shutdown,
|
||||||
* otherwise abandon hope and just end the process as is. */
|
* otherwise abandon hope and just end the process as is. */
|
||||||
if (rtData.rqTermAck)
|
if (rtData.rqTermAck){}
|
||||||
SDL_WaitThread(rgssThread, 0);
|
//SDL_WaitThread(rgssThread, 0);
|
||||||
else
|
else
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, conf.windowTitle.c_str(),
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, conf.windowTitle.c_str(),
|
||||||
"The RGSS script seems to be stuck and mkxp will now force quit", win);
|
"The RGSS script seems to be stuck and mkxp will now force quit", win);
|
||||||
|
|
Loading…
Reference in New Issue