Update for latest mruby, emscripten

This commit is contained in:
Varun Patil 2019-05-07 22:35:40 +05:30
parent bd75100d24
commit 0dbe2008af
9 changed files with 2728 additions and 3153 deletions

View File

@ -265,6 +265,11 @@ void __attribute__ ((optnone)) main_update_loop() {
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
if (static_mrb->exc) { if (static_mrb->exc) {
printf("Execution Errored\n"); printf("Execution Errored\n");
mrb_value s = mrb_funcall(static_mrb, mrb_obj_value(static_mrb->exc), "inspect", 0);
if (mrb_string_p(s)) {
printf("%s", mrb_str_to_cstr(static_mrb, s));
printf("\n");
}
mrb_close(static_scriptmrb); mrb_close(static_scriptmrb);
shState->texPool().disable(); shState->texPool().disable();
mrb_close(static_mrb); mrb_close(static_mrb);

View File

@ -23,6 +23,7 @@
#include "binding-util.h" #include "binding-util.h"
#include "binding-types.h" #include "binding-types.h"
#include "serializable-binding.h" #include "serializable-binding.h"
#include <iostream>
#define ATTR_RW(Type, Attr, arg_type, mrb_val, arg_t_s) \ #define ATTR_RW(Type, Attr, arg_type, mrb_val, arg_t_s) \
MRB_METHOD(Type##Get##Attr) \ MRB_METHOD(Type##Get##Attr) \

File diff suppressed because it is too large Load Diff

View File

@ -38,4 +38,5 @@ bool SDL_rw_file_helper::write(char * data) {
} }
SDL_RWclose(rw); SDL_RWclose(rw);
} }
return false;
} }

BIN
binding-mruby/rpg.mrb Normal file

Binary file not shown.

View File

@ -22,8 +22,8 @@
#ifndef BOOSTHASH_H #ifndef BOOSTHASH_H
#define BOOSTHASH_H #define BOOSTHASH_H
#include <boost/unordered/unordered_map.hpp> #include <map>
#include <boost/unordered/unordered_set.hpp> #include <set>
#include <utility> #include <utility>
@ -34,7 +34,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 +98,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:

View File

@ -31,7 +31,7 @@
#include <al.h> #include <al.h>
#include <alc.h> #include <alc.h>
#include <alext.h> //#include <alext.h>
#include "sharedstate.h" #include "sharedstate.h"
#include "graphics.h" #include "graphics.h"
@ -41,18 +41,9 @@
#include <string.h> #include <string.h>
typedef void (ALC_APIENTRY *LPALCDEVICEPAUSESOFT) (ALCdevice *device);
typedef void (ALC_APIENTRY *LPALCDEVICERESUMESOFT) (ALCdevice *device);
#define AL_DEVICE_PAUSE_FUN \
AL_FUN(DevicePause, LPALCDEVICEPAUSESOFT) \
AL_FUN(DeviceResume, LPALCDEVICERESUMESOFT)
struct ALCFunctions struct ALCFunctions
{ {
#define AL_FUN(name, type) type name;
AL_DEVICE_PAUSE_FUN
#undef AL_FUN
} static alc; } static alc;
static void static void
@ -62,13 +53,9 @@ initALCFunctions(ALCdevice *alcDev)
return; return;
Debug() << "ALC_SOFT_pause_device present"; Debug() << "ALC_SOFT_pause_device present";
#define AL_FUN(name, type) alc. name = (type) alcGetProcAddress(alcDev, "alc" #name "SOFT");
AL_DEVICE_PAUSE_FUN;
#undef AL_FUN
} }
#define HAVE_ALC_DEVICE_PAUSE alc.DevicePause #define HAVE_ALC_DEVICE_PAUSE false
uint8_t EventThread::keyStates[]; uint8_t EventThread::keyStates[];
EventThread::JoyState EventThread::joyState; EventThread::JoyState EventThread::joyState;
@ -448,9 +435,6 @@ int EventThread::eventFilter(void *data, SDL_Event *event)
case SDL_APP_WILLENTERBACKGROUND : case SDL_APP_WILLENTERBACKGROUND :
Debug() << "SDL_APP_WILLENTERBACKGROUND"; Debug() << "SDL_APP_WILLENTERBACKGROUND";
if (HAVE_ALC_DEVICE_PAUSE)
alc.DevicePause(rtData.alcDev);
rtData.syncPoint.haltThreads(); rtData.syncPoint.haltThreads();
return 0; return 0;
@ -466,9 +450,6 @@ int EventThread::eventFilter(void *data, SDL_Event *event)
case SDL_APP_DIDENTERFOREGROUND : case SDL_APP_DIDENTERFOREGROUND :
Debug() << "SDL_APP_DIDENTERFOREGROUND"; Debug() << "SDL_APP_DIDENTERFOREGROUND";
if (HAVE_ALC_DEVICE_PAUSE)
alc.DeviceResume(rtData.alcDev);
rtData.syncPoint.resumeThreads(); rtData.syncPoint.resumeThreads();
return 0; return 0;

View File

@ -25,6 +25,8 @@
#include "exception.h" #include "exception.h"
#include <SDL_video.h> #include <SDL_video.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <string> #include <string>
GLFunctions gl; GLFunctions gl;
@ -69,7 +71,7 @@ static void parseExtensionsCompat(_PFNGLGETSTRINGPROC GetString, BoostSet<std::s
} }
#define GL_FUN(name, type) \ #define GL_FUN(name, type) \
gl.name = (type) SDL_GL_GetProcAddress("gl" #name EXT_SUFFIX); gl.name = (type) gl##name;
#define EXC(msg) \ #define EXC(msg) \
Exception(Exception::MKXPError, "%s", msg) Exception(Exception::MKXPError, "%s", msg)
@ -108,15 +110,15 @@ void initGLFunctions()
BoostSet<std::string> ext; BoostSet<std::string> ext;
if (glMajor >= 3) // if (glMajor >= 3)
parseExtensionsCore(gl.GetIntegerv, ext); // parseExtensionsCore(gl.GetIntegerv, ext);
else //else
parseExtensionsCompat(gl.GetString, ext); parseExtensionsCompat(gl.GetString, ext);
#define HAVE_EXT(_ext) ext.contains("GL_" #_ext) #define HAVE_EXT(_ext) ext.contains("GL_" #_ext)
/* FBO entrypoints */ /* FBO entrypoints */
if (glMajor >= 3 || HAVE_EXT(ARB_framebuffer_object)) /*if (glMajor >= 3 || HAVE_EXT(ARB_framebuffer_object))
{ {
#undef EXT_SUFFIX #undef EXT_SUFFIX
#define EXT_SUFFIX "" #define EXT_SUFFIX ""
@ -124,9 +126,9 @@ void initGLFunctions()
GL_FBO_BLIT_FUN; GL_FBO_BLIT_FUN;
} }
else if (gles && glMajor == 2) else if (gles && glMajor == 2)
{ {*/
GL_FBO_FUN; GL_FBO_FUN;
} /*}
else if (HAVE_EXT(EXT_framebuffer_object)) else if (HAVE_EXT(EXT_framebuffer_object))
{ {
#undef EXT_SUFFIX #undef EXT_SUFFIX
@ -141,10 +143,10 @@ void initGLFunctions()
else else
{ {
throw EXC("No FBO support available"); throw EXC("No FBO support available");
} }*/
/* VAO entrypoints */ /* VAO entrypoints */
if (HAVE_EXT(ARB_vertex_array_object) || glMajor >= 3) /*if (HAVE_EXT(ARB_vertex_array_object) || glMajor >= 3)
{ {
#undef EXT_SUFFIX #undef EXT_SUFFIX
#define EXT_SUFFIX "" #define EXT_SUFFIX ""
@ -161,10 +163,10 @@ void initGLFunctions()
#undef EXT_SUFFIX #undef EXT_SUFFIX
#define EXT_SUFFIX "OES" #define EXT_SUFFIX "OES"
GL_VAO_FUN; GL_VAO_FUN;
} }*/
/* Debug callback entrypoints */ /* Debug callback entrypoints */
if (HAVE_EXT(KHR_debug)) /*if (HAVE_EXT(KHR_debug))
{ {
#undef EXT_SUFFIX #undef EXT_SUFFIX
#define EXT_SUFFIX "" #define EXT_SUFFIX ""
@ -182,7 +184,7 @@ void initGLFunctions()
#undef EXT_SUFFIX #undef EXT_SUFFIX
#define EXT_SUFFIX "GREMEDY" #define EXT_SUFFIX "GREMEDY"
GL_GREMEMDY_FUN; GL_GREMEMDY_FUN;
} }*/
/* Misc caps */ /* Misc caps */
if (!gles || glMajor >= 3 || HAVE_EXT(EXT_unpack_subimage)) if (!gles || glMajor >= 3 || HAVE_EXT(EXT_unpack_subimage))

View File

@ -23,7 +23,7 @@
#include "boost-hash.h" #include "boost-hash.h"
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string>
struct RGSS_entryData struct RGSS_entryData
{ {
@ -281,8 +281,9 @@ static const PHYSFS_Io RGSS_IoTemplate =
static void static void
processDirectories(RGSS_archiveData *data, BoostSet<std::string> &topLevel, processDirectories(RGSS_archiveData *data, BoostSet<std::string> &topLevel,
char *nameBuf, uint32_t nameLen) char *nameBufc, uint32_t nameLen)
{ {
std::string nameBuf(nameBufc);
/* Check for top level entries */ /* Check for top level entries */
for (uint32_t i = 0; i < nameLen; ++i) for (uint32_t i = 0; i < nameLen; ++i)
{ {
@ -307,7 +308,7 @@ processDirectories(RGSS_archiveData *data, BoostSet<std::string> &topLevel,
{ {
nameBuf[i] = '\0'; nameBuf[i] = '\0';
const char *dir = nameBuf; const char *dir = nameBuf.c_str();
const char *entry = &nameBuf[i+1]; const char *entry = &nameBuf[i+1];
BoostSet<std::string> &entryList = data->dirHash[dir]; BoostSet<std::string> &entryList = data->dirHash[dir];