Fix emscripten support, for mruby

Gets to title screen, input works

Fix up repo, fix Graphics.cpp, add emscripten_sleep to audio files
This commit is contained in:
Varun Patil 2018-04-30 22:49:27 +05:30
parent 5b3c1d2b13
commit a997bcd67f
9 changed files with 57 additions and 9 deletions

View file

@ -49,6 +49,10 @@
#include "binding-types.h"
#include "mrb-ext/marshal.h"
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
static void mrbBindingExecute();
static void mrbBindingTerminate();
static void mrbBindingReset();
@ -164,7 +168,7 @@ showExcMessageBox(mrb_state *mrb, mrb_value exc)
snprintf(msgBoxText, sizeof(msgBoxText), "Script '%s' line %d: %s occured.\n\n%s",
mrbValueString(file), mrb_fixnum(line), excClass, mrbValueString(mesg));
shState->eThread().showMessageBox(msgBoxText, SDL_MESSAGEBOX_ERROR);
printf("Alert - %s\n", msgBoxText);
}
static void
@ -289,13 +293,16 @@ runRMXPScripts(mrb_state *mrb, mrbc_context *ctx)
return;
}
int scriptCount = mrb_ary_len(scriptMrb, scriptArray);
int scriptCount = mrb_arY_len(scriptMrb, scriptArray);
std::string decodeBuffer;
decodeBuffer.resize(0x1000);
for (int i = 0; i < scriptCount; ++i)
{
#ifdef __EMSCRIPTEN
emscripten_sleep(10);
#endif
mrb_value script = mrb_ary_entry(scriptArray, i);
mrb_value scriptChksum = mrb_ary_entry(script, 0);

View file

@ -24,6 +24,7 @@
#include "exception.h"
#include "binding-util.h"
#include "util.h"
#include "eventthread.h"
#include <mruby/hash.h>
#include <string.h>
@ -33,6 +34,7 @@ MRB_FUNCTION(inputUpdate)
MRB_FUN_UNUSED_PARAM;
shState->input().update();
shState->eThread().process(shState->rtData());
return mrb_nil_value();
}