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:
		
							parent
							
								
									5b3c1d2b13
								
							
						
					
					
						commit
						a997bcd67f
					
				
					 9 changed files with 57 additions and 9 deletions
				
			
		| 
						 | 
					@ -49,6 +49,10 @@
 | 
				
			||||||
#include "binding-types.h"
 | 
					#include "binding-types.h"
 | 
				
			||||||
#include "mrb-ext/marshal.h"
 | 
					#include "mrb-ext/marshal.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __EMSCRIPTEN__
 | 
				
			||||||
 | 
					#include <emscripten.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void mrbBindingExecute();
 | 
					static void mrbBindingExecute();
 | 
				
			||||||
static void mrbBindingTerminate();
 | 
					static void mrbBindingTerminate();
 | 
				
			||||||
static void mrbBindingReset();
 | 
					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",
 | 
						snprintf(msgBoxText, sizeof(msgBoxText), "Script '%s' line %d: %s occured.\n\n%s",
 | 
				
			||||||
	         mrbValueString(file), mrb_fixnum(line), excClass, mrbValueString(mesg));
 | 
						         mrbValueString(file), mrb_fixnum(line), excClass, mrbValueString(mesg));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	shState->eThread().showMessageBox(msgBoxText, SDL_MESSAGEBOX_ERROR);
 | 
						printf("Alert -  %s\n", msgBoxText);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					@ -289,13 +293,16 @@ runRMXPScripts(mrb_state *mrb, mrbc_context *ctx)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int scriptCount = mrb_ary_len(scriptMrb, scriptArray);
 | 
						int scriptCount = mrb_arY_len(scriptMrb, scriptArray);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	std::string decodeBuffer;
 | 
						std::string decodeBuffer;
 | 
				
			||||||
	decodeBuffer.resize(0x1000);
 | 
						decodeBuffer.resize(0x1000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (int i = 0; i < scriptCount; ++i)
 | 
						for (int i = 0; i < scriptCount; ++i)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 | 
					#ifdef __EMSCRIPTEN
 | 
				
			||||||
 | 
							emscripten_sleep(10);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
		mrb_value script = mrb_ary_entry(scriptArray, i);
 | 
							mrb_value script = mrb_ary_entry(scriptArray, i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		mrb_value scriptChksum = mrb_ary_entry(script, 0);
 | 
							mrb_value scriptChksum = mrb_ary_entry(script, 0);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,6 +24,7 @@
 | 
				
			||||||
#include "exception.h"
 | 
					#include "exception.h"
 | 
				
			||||||
#include "binding-util.h"
 | 
					#include "binding-util.h"
 | 
				
			||||||
#include "util.h"
 | 
					#include "util.h"
 | 
				
			||||||
 | 
					#include "eventthread.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <mruby/hash.h>
 | 
					#include <mruby/hash.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
| 
						 | 
					@ -33,6 +34,7 @@ MRB_FUNCTION(inputUpdate)
 | 
				
			||||||
	MRB_FUN_UNUSED_PARAM;
 | 
						MRB_FUN_UNUSED_PARAM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	shState->input().update();
 | 
						shState->input().update();
 | 
				
			||||||
 | 
						shState->eThread().process(shState->rtData());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return mrb_nil_value();
 | 
						return mrb_nil_value();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,6 +35,10 @@
 | 
				
			||||||
#include <SDL_thread.h>
 | 
					#include <SDL_thread.h>
 | 
				
			||||||
#include <SDL_timer.h>
 | 
					#include <SDL_timer.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __EMSCRIPTEN__
 | 
				
			||||||
 | 
					#include <emscripten.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ALStream::ALStream(LoopMode loopMode,
 | 
					ALStream::ALStream(LoopMode loopMode,
 | 
				
			||||||
		           const std::string &threadId)
 | 
							           const std::string &threadId)
 | 
				
			||||||
	: looped(loopMode == Looped),
 | 
						: looped(loopMode == Looped),
 | 
				
			||||||
| 
						 | 
					@ -474,6 +478,11 @@ void ALStream::streamData()
 | 
				
			||||||
		if (threadTermReq)
 | 
							if (threadTermReq)
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __EMSCRIPTEN__
 | 
				
			||||||
 | 
							emscripten_sleep(AUDIO_SLEEP);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
		SDL_Delay(AUDIO_SLEEP);
 | 
							SDL_Delay(AUDIO_SLEEP);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,6 +33,10 @@
 | 
				
			||||||
#include <SDL_thread.h>
 | 
					#include <SDL_thread.h>
 | 
				
			||||||
#include <SDL_timer.h>
 | 
					#include <SDL_timer.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __EMSCRIPTEN__
 | 
				
			||||||
 | 
					#include <emscripten.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct AudioPrivate
 | 
					struct AudioPrivate
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	AudioStream bgm;
 | 
						AudioStream bgm;
 | 
				
			||||||
| 
						 | 
					@ -232,7 +236,11 @@ struct AudioPrivate
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __EMSCRIPTEN__
 | 
				
			||||||
 | 
								emscripten_sleep(AUDIO_SLEEP);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
			SDL_Delay(AUDIO_SLEEP);
 | 
								SDL_Delay(AUDIO_SLEEP);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,6 +28,10 @@
 | 
				
			||||||
#include <SDL_thread.h>
 | 
					#include <SDL_thread.h>
 | 
				
			||||||
#include <SDL_timer.h>
 | 
					#include <SDL_timer.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __EMSCRIPTEN__
 | 
				
			||||||
 | 
					#include <emscripten.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AudioStream::AudioStream(ALStream::LoopMode loopMode,
 | 
					AudioStream::AudioStream(ALStream::LoopMode loopMode,
 | 
				
			||||||
                         const std::string &threadId)
 | 
					                         const std::string &threadId)
 | 
				
			||||||
	: extPaused(false),
 | 
						: extPaused(false),
 | 
				
			||||||
| 
						 | 
					@ -323,7 +327,11 @@ void AudioStream::fadeOutThread()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		unlockStream();
 | 
							unlockStream();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __EMSCRIPTEN__
 | 
				
			||||||
 | 
							emscripten_sleep(AUDIO_SLEEP);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
		SDL_Delay(AUDIO_SLEEP);
 | 
							SDL_Delay(AUDIO_SLEEP);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fade.active.clear();
 | 
						fade.active.clear();
 | 
				
			||||||
| 
						 | 
					@ -360,6 +368,10 @@ void AudioStream::fadeInThread()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		unlockStream();
 | 
							unlockStream();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __EMSCRIPTEN__
 | 
				
			||||||
 | 
							emscripten_sleep(AUDIO_SLEEP);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
		SDL_Delay(AUDIO_SLEEP);
 | 
							SDL_Delay(AUDIO_SLEEP);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,9 +21,10 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef BOOSTHASH_H
 | 
					#ifndef BOOSTHASH_H
 | 
				
			||||||
#define BOOSTHASH_H
 | 
					#define BOOSTHASH_H
 | 
				
			||||||
#include <string>
 | 
					
 | 
				
			||||||
#include <map>
 | 
					#include <boost/unordered/unordered_map.hpp>
 | 
				
			||||||
#include <set>
 | 
					#include <boost/unordered/unordered_set.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <utility>
 | 
					#include <utility>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Wrappers around the boost unordered template classes,
 | 
					/* Wrappers around the boost unordered template classes,
 | 
				
			||||||
| 
						 | 
					@ -33,7 +34,7 @@ template<typename K, typename V>
 | 
				
			||||||
class BoostHash
 | 
					class BoostHash
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	typedef std::map<K, V> BoostType;
 | 
						typedef boost::unordered_map<K, V> BoostType;
 | 
				
			||||||
	typedef std::pair<K, V> PairType;
 | 
						typedef std::pair<K, V> PairType;
 | 
				
			||||||
	BoostType p;
 | 
						BoostType p;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -97,7 +98,7 @@ template<typename K>
 | 
				
			||||||
class BoostSet
 | 
					class BoostSet
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	typedef std::set<K> BoostType;
 | 
						typedef boost::unordered_set<K> BoostType;
 | 
				
			||||||
	BoostType p;
 | 
						BoostType p;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,7 +43,7 @@ struct Config
 | 
				
			||||||
	int defScreenH = 0;
 | 
						int defScreenH = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int fixedFramerate = 0;
 | 
						int fixedFramerate = 0;
 | 
				
			||||||
	bool frameSkip =true;
 | 
						bool frameSkip =false;
 | 
				
			||||||
	bool syncToRefreshrate = false;
 | 
						bool syncToRefreshrate = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool solidFonts = false;
 | 
						bool solidFonts = false;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -446,7 +446,7 @@ private:
 | 
				
			||||||
		SDL_Delay(ticks / tickFreqMS);
 | 
							SDL_Delay(ticks / tickFreqMS);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifdef __EMSCRIPTEN
 | 
					#ifdef __EMSCRIPTEN__
 | 
				
			||||||
		emscripten_sleep(ticks /tickFreqMS);
 | 
							emscripten_sleep(ticks /tickFreqMS);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -46,6 +46,11 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "icon.png.xxd"
 | 
					#include "icon.png.xxd"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __EMSCRIPTEN__
 | 
				
			||||||
 | 
					#include <emscripten.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
rgssThreadError(RGSSThreadData *rtData, const std::string &msg)
 | 
					rgssThreadError(RGSSThreadData *rtData, const std::string &msg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -335,6 +340,10 @@ int main(int argc, char *argv[])
 | 
				
			||||||
	/* Wait for RGSS thread response */
 | 
						/* Wait for RGSS thread response */
 | 
				
			||||||
	for (int i = 0; i < 1000; ++i)
 | 
						for (int i = 0; i < 1000; ++i)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 | 
					#ifdef __EMSCRIPTEN
 | 
				
			||||||
 | 
							emscripten_sleep(10);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* We can stop waiting when the request was ack'd */
 | 
							/* We can stop waiting when the request was ack'd */
 | 
				
			||||||
		if (rtData.rqTermAck)
 | 
							if (rtData.rqTermAck)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue