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

@ -35,6 +35,10 @@
#include <SDL_thread.h>
#include <SDL_timer.h>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
ALStream::ALStream(LoopMode loopMode,
const std::string &threadId)
: looped(loopMode == Looped),
@ -474,6 +478,11 @@ void ALStream::streamData()
if (threadTermReq)
break;
#ifdef __EMSCRIPTEN__
emscripten_sleep(AUDIO_SLEEP);
#else
SDL_Delay(AUDIO_SLEEP);
#endif
}
}

View file

@ -33,6 +33,10 @@
#include <SDL_thread.h>
#include <SDL_timer.h>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
struct AudioPrivate
{
AudioStream bgm;
@ -232,7 +236,11 @@ struct AudioPrivate
}
}
#ifdef __EMSCRIPTEN__
emscripten_sleep(AUDIO_SLEEP);
#else
SDL_Delay(AUDIO_SLEEP);
#endif
}
}
};

View file

@ -28,6 +28,10 @@
#include <SDL_thread.h>
#include <SDL_timer.h>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
AudioStream::AudioStream(ALStream::LoopMode loopMode,
const std::string &threadId)
: extPaused(false),
@ -323,7 +327,11 @@ void AudioStream::fadeOutThread()
unlockStream();
#ifdef __EMSCRIPTEN__
emscripten_sleep(AUDIO_SLEEP);
#else
SDL_Delay(AUDIO_SLEEP);
#endif
}
fade.active.clear();
@ -360,6 +368,10 @@ void AudioStream::fadeInThread()
unlockStream();
#ifdef __EMSCRIPTEN__
emscripten_sleep(AUDIO_SLEEP);
#else
SDL_Delay(AUDIO_SLEEP);
#endif
}
}

View file

@ -21,9 +21,10 @@
#ifndef BOOSTHASH_H
#define BOOSTHASH_H
#include <string>
#include <map>
#include <set>
#include <boost/unordered/unordered_map.hpp>
#include <boost/unordered/unordered_set.hpp>
#include <utility>
/* Wrappers around the boost unordered template classes,
@ -33,7 +34,7 @@ template<typename K, typename V>
class BoostHash
{
private:
typedef std::map<K, V> BoostType;
typedef boost::unordered_map<K, V> BoostType;
typedef std::pair<K, V> PairType;
BoostType p;
@ -97,7 +98,7 @@ template<typename K>
class BoostSet
{
private:
typedef std::set<K> BoostType;
typedef boost::unordered_set<K> BoostType;
BoostType p;
public:

View file

@ -43,7 +43,7 @@ struct Config
int defScreenH = 0;
int fixedFramerate = 0;
bool frameSkip =true;
bool frameSkip =false;
bool syncToRefreshrate = false;
bool solidFonts = false;

View file

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

View file

@ -46,6 +46,11 @@
#include "icon.png.xxd"
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
static void
rgssThreadError(RGSSThreadData *rtData, const std::string &msg)
{
@ -335,6 +340,10 @@ int main(int argc, char *argv[])
/* Wait for RGSS thread response */
for (int i = 0; i < 1000; ++i)
{
#ifdef __EMSCRIPTEN
emscripten_sleep(10);
#endif
/* We can stop waiting when the request was ack'd */
if (rtData.rqTermAck)
{