This commit is contained in:
Ghabry 2019-09-26 21:32:29 +02:00
parent 11d3755116
commit 01d8eb582d
8 changed files with 35 additions and 29 deletions

View File

@ -54,8 +54,12 @@ elseif(APPLE)
set(LIB_PATH "lib")
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']\"")
#set(EMTERPRETER_OPT "-s ASSERTIONS=0 -s TOTAL_MEMORY=67108864 -s ABORTING_MALLOC=0 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 -s NO_EXIT_RUNTIME=1 --preload-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', '_main']\"")
#set(EMTERPRETER_OPT "${EMTERPRETER_OPT} -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['Pointer_stringify']\" -s DISABLE_EXCEPTION_CATCHING=2")
#set(EMTERPRETER_OPT "${EMTERPRETER_OPT} -s ALIASING_FUNCTION_POINTERS=0")
set(EMTERPRETER_OPT "-s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 -s ABORTING_MALLOC=0 -s NO_EXIT_RUNTIME=1 -s ASYNCIFY -s ERROR_ON_UNDEFINED_SYMBOLS=0 --embed-file \"game\"")
message(STATUS ${EMTERPRETER_OPT})
@ -104,7 +108,8 @@ pkg_check_modules(SDL2_IMAGE REQUIRED SDL2_image)
pkg_check_modules(SDL_SOUND REQUIRED SDL_sound)
#find_package(Boost 1.49 COMPONENTS program_options REQUIRED)
find_package(OpenAL REQUIRED)
#find_package(OpenAL REQUIRED)
pkg_check_modules(OpenAL REQUIRED openal)
pkg_check_modules(ZLIB REQUIRED zlib)
#find_package(ZLIB REQUIRED)
@ -307,7 +312,7 @@ source_group("Embedded Source" FILES ${EMBEDDED_INPUT} ${EMBEDDED_SOURCE})
if (BINDING STREQUAL "MRI")
set(MRIVERSION "2.1" CACHE STRING "Version of MRI to link with")
pkg_check_modules(MRI REQUIRED ruby-${MRIVERSION})
#pkg_check_modules(MRI REQUIRED ruby-${MRIVERSION})
list(APPEND DEFINES
BINDING_MRI
)
@ -433,9 +438,11 @@ target_include_directories(${PROJECT_NAME} PRIVATE
${MRI_INCLUDE_DIRS}
${VORBISFILE_INCLUDE_DIRS}
${FLUID_INCLUDE_DIRS}
${OPENAL_INCLUDE_DIR}
${OpenAL_INCLUDE_DIRS}
${SDL_SOUND_INCLUDE_DIRS}
${FREETYPE_INCLUDE_DIRS}
"/home/gabriel/Programmierung/mkxp_js/deps_js/install/lib/ruby/1.8/x86_64-linux"
"/home/gabriel/Programmierung/mkxp_js/deps_js/install/lib/ruby/1.8"
)
target_link_libraries(${PROJECT_NAME}
@ -450,7 +457,7 @@ target_link_libraries(${PROJECT_NAME}
${MRI_LIBRARIES}
${VORBISFILE_LIBRARIES}
${FLUID_LIBRARIES}
${OPENAL_LIBRARY}
${OpenAL_LIBRARY}
${ZLIB_LIBRARY}
${PLATFORM_LIBRARIES}
"libruby-static.a"

View File

@ -42,6 +42,10 @@
#include <SDL_filesystem.h>
extern "C" {
extern char** environ;
};
extern const char module_rpg1[];
extern const char module_rpg2[];
extern const char module_rpg3[];
@ -156,7 +160,7 @@ static void mriBindingInit()
if (rgssVer == 1)
rb_gv_set("DEBUG", debug);
else if (rgssVer >= 2)
rb_gv_set("TEST", debug);
rb_gv_set("TEST", (VALUE)environ);
rb_gv_set("BTEST", rb_bool_new(shState->config().editor.battleTest));
}
@ -164,7 +168,7 @@ static void mriBindingInit()
static void
showMsg(const std::string &msg)
{
printf("Show msg %s\n", msg.c_str());
printf("Show msg %s\n", msg.c_str());
return;
// shState->eThread().showMessageBox(msg.c_str());
}
@ -277,9 +281,9 @@ RB_METHOD(mriRgssMain)
{
VALUE exc = Qnil;
rb_rescue2((VALUE(*)(ANYARGS)) rgssMainCb, rb_block_proc(),
/*rb_rescue2((VALUE(*)(ANYARGS)) rgssMainCb, rb_block_proc(),
(VALUE(*)(ANYARGS)) rgssMainRescue, (VALUE) &exc,
rb_eException, (VALUE) 0);
rb_eException, (VALUE) 0);*/
if (NIL_P(exc))
break;
@ -426,7 +430,7 @@ static void runRMXPScripts(BacktraceData &btData)
long scriptCount = RARRAY_LEN(scriptArray);
std::string decodeBuffer;
std::vector<unsigned char> decodeBuffer;
decodeBuffer.resize(0x1000);
for (long i = 0; i < scriptCount; ++i)
@ -445,11 +449,11 @@ static void runRMXPScripts(BacktraceData &btData)
while (true)
{
unsigned char *bufferPtr =
reinterpret_cast<unsigned char*>(const_cast<char*>(decodeBuffer.c_str()));
reinterpret_cast<unsigned char*>(decodeBuffer.data());
const unsigned char *sourcePtr =
reinterpret_cast<const unsigned char*>(RSTRING_PTR(scriptString));
bufferLen = decodeBuffer.length();
bufferLen = decodeBuffer.size();
result = uncompress(bufferPtr, &bufferLen,
sourcePtr, RSTRING_LEN(scriptString));
@ -473,7 +477,7 @@ static void runRMXPScripts(BacktraceData &btData)
break;
}
rb_ary_store(script, 3, rb_str_new_cstr(decodeBuffer.c_str()));
rb_ary_store(script, 3, rb_str_new_cstr(reinterpret_cast<const char*>(decodeBuffer.data())));
}
/* Execute preloaded scripts */
@ -488,8 +492,8 @@ static void runRMXPScripts(BacktraceData &btData)
while (true)
{
#ifdef __EMSCRIPTEN
emscripten_sleep(10);
#endif
emscripten_sleep(1);
#endif
for (long i = 0; i < scriptCount; ++i)
{

View File

@ -212,7 +212,7 @@ RB_METHOD(_marshalLoad)
#else
VALUE v[] = { port, proc };
#endif
return rb_funcall2(marsh, rb_intern("_mkxp_load_alias"), ARRAY_SIZE(v), v);
return rb_funcall2(marsh, rb_intern("load"), ARRAY_SIZE(v), v);
}
void
@ -234,7 +234,7 @@ fileIntBindingInit()
/* We overload the built-in 'Marshal::load()' function to silently
* insert our utf8proc that ensures all read strings will be
* UTF-8 encoded */
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
rb_define_alias(rb_singleton_class(marsh), "_mkxp_load_alias", "load");
_rb_define_module_function(marsh, "load", _marshalLoad);
//VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
//rb_define_alias(rb_singleton_class(marsh), "_mkxp_load_alias", "load");
//_rb_define_module_function(marsh, "load", _marshalLoad);
}

View File

@ -270,7 +270,7 @@ void Config::read(int argc, char *argv[])
#undef PO_DESC
#undef PO_DESC_ALL
#endif
preloadScripts.insert("win32_wrap.rb");
//preloadScripts.insert("win32_wrap.rb");
rgssVersion = clamp(rgssVersion, 0, 3);

View File

@ -39,14 +39,9 @@ struct Config
bool smoothScaling = true;
bool vsync = false;
<<<<<<< HEAD
int defScreenW;
int defScreenH;
std::string windowTitle;
=======
int defScreenW = 0;
int defScreenH = 0;
>>>>>>> WIP: Emscripten support
int fixedFramerate = 0;
bool frameSkip =true;

View File

@ -140,7 +140,7 @@ void EventThread::process(RGSSThreadData &rtData)
while (SDL_PollEvent(&event))
{
#ifdef __EMSCRIPTEN__
emscripten_sleep(10);
emscripten_sleep(1);
#endif
// if (!SDL_WaitEvent(&event))
// {

View File

@ -444,7 +444,7 @@ private:
SDL_Delay(ticks / tickFreqMS);
#endif
#endif
#ifdef __EMSCRIPTEN
#ifdef __EMSCRIPTEN__
emscripten_sleep(ticks /tickFreqMS);
#endif
}

View File

@ -232,7 +232,7 @@ int main(int argc, char *argv[])
}
conf.readGameINI();
printf("%s\n", conf.gameFolder.c_str());
printf("GAME: %s\n", conf.gameFolder.c_str());
if (conf.windowTitle.empty())
conf.windowTitle = conf.game.title;