Make changes for Emscripten
This commit is contained in:
		
							parent
							
								
									776564d583
								
							
						
					
					
						commit
						8c5db3a401
					
				
					 33 changed files with 5082 additions and 3720 deletions
				
			
		| 
						 | 
				
			
			@ -22,7 +22,7 @@
 | 
			
		|||
#ifndef ALUTIL_H
 | 
			
		||||
#define ALUTIL_H
 | 
			
		||||
 | 
			
		||||
#include <al.h>
 | 
			
		||||
#include <AL/al.h>
 | 
			
		||||
#include <SDL_audio.h>
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -210,7 +210,7 @@ struct ALStreamOpenHandler : FileSystem::OpenHandler
 | 
			
		|||
	    : srcOps(&srcOps), looped(looped), source(0)
 | 
			
		||||
	{}
 | 
			
		||||
 | 
			
		||||
	bool tryRead(SDL_RWops &ops, const char *ext)
 | 
			
		||||
	bool tryRead(SDL_RWops &ops, const char *ext, const char *fullPath)
 | 
			
		||||
	{
 | 
			
		||||
		/* Copy this because we need to keep it around,
 | 
			
		||||
		 * as we will continue reading data from it later */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -241,9 +241,13 @@ struct BitmapOpenHandler : FileSystem::OpenHandler
 | 
			
		|||
	    : surf(0)
 | 
			
		||||
	{}
 | 
			
		||||
 | 
			
		||||
	bool tryRead(SDL_RWops &ops, const char *ext)
 | 
			
		||||
	bool tryRead(SDL_RWops &ops, const char *ext, const char * fullPath)
 | 
			
		||||
	{
 | 
			
		||||
#ifdef __EMSCRIPTEN__
 | 
			
		||||
		surf = IMG_Load(fullPath);
 | 
			
		||||
#else
 | 
			
		||||
		surf = IMG_LoadTyped_RW(&ops, 1, ext);
 | 
			
		||||
#endif
 | 
			
		||||
		return surf != 0;
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -254,9 +258,11 @@ Bitmap::Bitmap(const char *filename)
 | 
			
		|||
	shState->fileSystem().openRead(handler, filename);
 | 
			
		||||
	SDL_Surface *imgSurf = handler.surf;
 | 
			
		||||
 | 
			
		||||
	if (!imgSurf)
 | 
			
		||||
	if (!imgSurf) {
 | 
			
		||||
		printf("ERROR OCCURED LOADING IMAGE %s : %s\n", filename, SDL_GetError());
 | 
			
		||||
		throw Exception(Exception::SDLError, "Error loading image '%s': %s",
 | 
			
		||||
		                filename, SDL_GetError());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	p->ensureFormat(imgSurf, SDL_PIXELFORMAT_ABGR8888);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -150,14 +150,9 @@ Config::Config()
 | 
			
		|||
 | 
			
		||||
void Config::read(int argc, char *argv[])
 | 
			
		||||
{
 | 
			
		||||
	gameFolder = "game";
 | 
			
		||||
	defScreenW = 640;
 | 
			
		||||
	defScreenH = 480;
 | 
			
		||||
	enableBlitting = true;
 | 
			
		||||
	smoothScaling = true;
 | 
			
		||||
	subImageFix = false;
 | 
			
		||||
	
 | 
			
		||||
#if 0
 | 
			
		||||
#undef PO_DESC
 | 
			
		||||
#define PO_DESC(a, b, c) a = c;
 | 
			
		||||
 | 
			
		||||
#define PO_DESC_ALL \
 | 
			
		||||
	PO_DESC(rgssVersion, int, 0) \
 | 
			
		||||
	PO_DESC(debugMode, bool, false) \
 | 
			
		||||
| 
						 | 
				
			
			@ -194,6 +189,19 @@ void Config::read(int argc, char *argv[])
 | 
			
		|||
	PO_DESC(pathCache, bool, true) \
 | 
			
		||||
	PO_DESC(useScriptNames, bool, false)
 | 
			
		||||
 | 
			
		||||
	PO_DESC_ALL;
 | 
			
		||||
	gameFolder = "game";
 | 
			
		||||
	fixedFramerate = -1;
 | 
			
		||||
	syncToRefreshrate = false;
 | 
			
		||||
	rgssVersion = 1;
 | 
			
		||||
	defScreenW = 640;
 | 
			
		||||
	defScreenH = 480;
 | 
			
		||||
	enableBlitting = false;
 | 
			
		||||
 | 
			
		||||
#undef PO_DESC
 | 
			
		||||
#undef PO_DESC_ALL
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
// Not gonna take your shit boost
 | 
			
		||||
#define GUARD_ALL( exp ) try { exp } catch(...) {}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,9 +29,8 @@
 | 
			
		|||
#include <SDL_touch.h>
 | 
			
		||||
#include <SDL_rect.h>
 | 
			
		||||
 | 
			
		||||
#include <al.h>
 | 
			
		||||
#include <alc.h>
 | 
			
		||||
#include <alext.h>
 | 
			
		||||
#include <AL/al.h>
 | 
			
		||||
#include <AL/alc.h>
 | 
			
		||||
 | 
			
		||||
#include "sharedstate.h"
 | 
			
		||||
#include "graphics.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -41,18 +40,10 @@
 | 
			
		|||
 | 
			
		||||
#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
 | 
			
		||||
{
 | 
			
		||||
#define AL_FUN(name, type) type name;
 | 
			
		||||
	AL_DEVICE_PAUSE_FUN
 | 
			
		||||
#undef AL_FUN
 | 
			
		||||
 | 
			
		||||
} static alc;
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
| 
						 | 
				
			
			@ -62,13 +53,9 @@ initALCFunctions(ALCdevice *alcDev)
 | 
			
		|||
		return;
 | 
			
		||||
 | 
			
		||||
	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[];
 | 
			
		||||
EventThread::JoyState EventThread::joyState;
 | 
			
		||||
| 
						 | 
				
			
			@ -112,13 +99,18 @@ void EventThread::process(RGSSThreadData &rtData)
 | 
			
		|||
	SDL_Window *win = rtData.window;
 | 
			
		||||
	UnidirMessage<Vec2i> &windowSizeMsg = rtData.windowSizeMsg;
 | 
			
		||||
 | 
			
		||||
	initALCFunctions(rtData.alcDev);
 | 
			
		||||
	static bool once = true;
 | 
			
		||||
	if (once) {
 | 
			
		||||
		initALCFunctions(rtData.alcDev);
 | 
			
		||||
 | 
			
		||||
	// XXX this function breaks input focus on OSX
 | 
			
		||||
		// XXX this function breaks input focus on OSX
 | 
			
		||||
#ifndef __MACOSX__
 | 
			
		||||
	SDL_SetEventFilter(eventFilter, &rtData);
 | 
			
		||||
		SDL_SetEventFilter(eventFilter, &rtData);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
		once = false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fullscreen = rtData.config.fullscreen;
 | 
			
		||||
	int toggleFSMod = rtData.config.anyAltToggleFS ? KMOD_ALT : KMOD_LALT;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -159,13 +151,8 @@ void EventThread::process(RGSSThreadData &rtData)
 | 
			
		|||
 | 
			
		||||
	SettingsMenu *sMenu = 0;
 | 
			
		||||
 | 
			
		||||
	while (true)
 | 
			
		||||
	while (SDL_PollEvent(&event))
 | 
			
		||||
	{
 | 
			
		||||
		if (!SDL_WaitEvent(&event))
 | 
			
		||||
		{
 | 
			
		||||
			Debug() << "EventThread: Event error";
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (sMenu && sMenu->onEvent(event))
 | 
			
		||||
		{
 | 
			
		||||
| 
						 | 
				
			
			@ -459,11 +446,13 @@ void EventThread::process(RGSSThreadData &rtData)
 | 
			
		|||
			break;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
#ifndef __EMSCRIPTEN__
 | 
			
		||||
	/* Just in case */
 | 
			
		||||
	rtData.syncPoint.resumeThreads();
 | 
			
		||||
 | 
			
		||||
	if (SDL_JoystickGetAttached(js))
 | 
			
		||||
		SDL_JoystickClose(js);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	delete sMenu;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -477,8 +466,10 @@ int EventThread::eventFilter(void *data, SDL_Event *event)
 | 
			
		|||
	case SDL_APP_WILLENTERBACKGROUND :
 | 
			
		||||
		Debug() << "SDL_APP_WILLENTERBACKGROUND";
 | 
			
		||||
 | 
			
		||||
#if HAVE_ALC_DEVICE_PAUSE
 | 
			
		||||
		if (HAVE_ALC_DEVICE_PAUSE)
 | 
			
		||||
			alc.DevicePause(rtData.alcDev);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
		rtData.syncPoint.haltThreads();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -495,8 +486,10 @@ int EventThread::eventFilter(void *data, SDL_Event *event)
 | 
			
		|||
	case SDL_APP_DIDENTERFOREGROUND :
 | 
			
		||||
		Debug() << "SDL_APP_DIDENTERFOREGROUND";
 | 
			
		||||
 | 
			
		||||
#if HAVE_ALC_DEVICE_PAUSE
 | 
			
		||||
		if (HAVE_ALC_DEVICE_PAUSE)
 | 
			
		||||
			alc.DeviceResume(rtData.alcDev);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
		rtData.syncPoint.resumeThreads();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -593,18 +586,11 @@ void EventThread::requestShowCursor(bool mode)
 | 
			
		|||
	SDL_PushEvent(&event);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
void EventThread::showMessageBox(const char *body, int flags)
 | 
			
		||||
{
 | 
			
		||||
	msgBoxDone.clear();
 | 
			
		||||
 | 
			
		||||
	SDL_Event event;
 | 
			
		||||
	event.user.code = flags;
 | 
			
		||||
	event.user.data1 = strdup(body);
 | 
			
		||||
	event.type = usrIdStart + REQUEST_MESSAGEBOX;
 | 
			
		||||
	SDL_PushEvent(&event);
 | 
			
		||||
 | 
			
		||||
	/* Keep repainting screen while box is open */
 | 
			
		||||
	shState->graphics().repaintWait(msgBoxDone);
 | 
			
		||||
	printf(body);
 | 
			
		||||
	/* Prevent endless loops */
 | 
			
		||||
	resetInputStates();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -625,7 +625,7 @@ openReadEnumCB(void *d, const char *dirpath, const char *filename)
 | 
			
		|||
 | 
			
		||||
	const char *ext = findExt(filename);
 | 
			
		||||
 | 
			
		||||
	if (data.handler.tryRead(data.ops, ext))
 | 
			
		||||
	if (data.handler.tryRead(data.ops, ext, fullPath))
 | 
			
		||||
		data.stopSearching = true;
 | 
			
		||||
 | 
			
		||||
	++data.matchCount;
 | 
			
		||||
| 
						 | 
				
			
			@ -678,11 +678,15 @@ void FileSystem::openRead(OpenHandler &handler, const char *filename)
 | 
			
		|||
		PHYSFS_enumerate(dir, openReadEnumCB, &data);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (data.physfsError)
 | 
			
		||||
	if (data.physfsError) {
 | 
			
		||||
		printf("PHYSFS ERROR %s\n", filename);
 | 
			
		||||
		throw Exception(Exception::PHYSFSError, "PhysFS: %s", data.physfsError);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (data.matchCount == 0)
 | 
			
		||||
	if (data.matchCount == 0) {
 | 
			
		||||
		printf("NO SUCH FILE %s\n", filename);
 | 
			
		||||
		throw Exception(Exception::NoFileError, "%s", filename);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FileSystem::openReadRaw(SDL_RWops &ops,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,7 +53,7 @@ public:
 | 
			
		|||
		 * After this function returns, ops becomes invalid, so don't take
 | 
			
		||||
		 * references to it. Instead, copy the structure without closing
 | 
			
		||||
		 * if you need to further read from it later. */
 | 
			
		||||
		virtual bool tryRead(SDL_RWops &ops, const char *ext) = 0;
 | 
			
		||||
		virtual bool tryRead(SDL_RWops &ops, const char *ext, const char *fullPath) = 0;
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	void openRead(OpenHandler &handler,
 | 
			
		||||
| 
						 | 
				
			
			@ -66,7 +66,6 @@ public:
 | 
			
		|||
 | 
			
		||||
	/* Does not perform extension supplementing */
 | 
			
		||||
	bool exists(const char *filename);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	FileSystemPrivate *p;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,8 +13,12 @@
 | 
			
		|||
#elif __WINDOWS__
 | 
			
		||||
#define FLUID_LIB "fluidsynth.dll"
 | 
			
		||||
#else
 | 
			
		||||
#ifdef __EMSCRIPTEN__
 | 
			
		||||
#define FLUID_LIB "fluidsynth.bc"
 | 
			
		||||
#else
 | 
			
		||||
#error "platform not recognized"
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
struct FluidFunctions fluid;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -22,6 +26,10 @@ static void *so;
 | 
			
		|||
 | 
			
		||||
void initFluidFunctions()
 | 
			
		||||
{
 | 
			
		||||
#ifdef __EMSCRIPTEN__
 | 
			
		||||
	goto fail;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef SHARED_FLUID
 | 
			
		||||
 | 
			
		||||
#define FLUID_FUN(name, type) \
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -418,6 +418,10 @@ struct FPSLimiter
 | 
			
		|||
private:
 | 
			
		||||
	void delayTicks(uint64_t ticks)
 | 
			
		||||
	{
 | 
			
		||||
#ifdef __EMSCRIPTEN__
 | 
			
		||||
	return;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined(HAVE_NANOSLEEP)
 | 
			
		||||
		struct timespec req;
 | 
			
		||||
		uint64_t nsec = ticks / tickFreqNS;
 | 
			
		||||
| 
						 | 
				
			
			@ -751,6 +755,7 @@ void Graphics::transition(int duration,
 | 
			
		|||
		/* We need to clean up transMap properly before
 | 
			
		||||
		 * a possible longjmp, so we manually test for
 | 
			
		||||
		 * shutdown/reset here */
 | 
			
		||||
 | 
			
		||||
		if (p->threadData->rqTerm)
 | 
			
		||||
		{
 | 
			
		||||
			glState.blend.pop();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										34
									
								
								src/main.cpp
									
										
									
									
									
								
							
							
						
						
									
										34
									
								
								src/main.cpp
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -19,7 +19,7 @@
 | 
			
		|||
** along with mkxp.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include <alc.h>
 | 
			
		||||
#include <AL/alc.h>
 | 
			
		||||
 | 
			
		||||
#include <SDL.h>
 | 
			
		||||
#include <SDL_image.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -111,11 +111,6 @@ int rgssThreadFun(void *userdata)
 | 
			
		|||
 | 
			
		||||
	printGLInfo();
 | 
			
		||||
 | 
			
		||||
	bool vsync = conf.vsync || conf.syncToRefreshrate;
 | 
			
		||||
	SDL_GL_SetSwapInterval(vsync ? 1 : 0);
 | 
			
		||||
 | 
			
		||||
	GLDebugLogger dLogger;
 | 
			
		||||
 | 
			
		||||
	/* Setup AL context */
 | 
			
		||||
	ALCcontext *alcCtx = alcCreateContext(threadData->alcDev, 0);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -145,6 +140,7 @@ int rgssThreadFun(void *userdata)
 | 
			
		|||
	/* Start script execution */
 | 
			
		||||
	scriptBinding->execute();
 | 
			
		||||
 | 
			
		||||
#ifndef __EMSCRIPTEN__
 | 
			
		||||
	threadData->rqTermAck.set();
 | 
			
		||||
	threadData->ethread->requestTerminate();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -152,6 +148,10 @@ int rgssThreadFun(void *userdata)
 | 
			
		|||
 | 
			
		||||
	alcDestroyContext(alcCtx);
 | 
			
		||||
	SDL_GL_DeleteContext(glCtx);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	bool vsync = conf.vsync || conf.syncToRefreshrate;
 | 
			
		||||
	SDL_GL_SetSwapInterval(vsync ? 1 : 0);
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -239,7 +239,11 @@ int main(int argc, char *argv[])
 | 
			
		|||
	assert(conf.rgssVersion >= 1 && conf.rgssVersion <= 3);
 | 
			
		||||
	printRgssVersion(conf.rgssVersion);
 | 
			
		||||
 | 
			
		||||
#ifdef __EMSCRIPTEN__
 | 
			
		||||
	int imgFlags = 0;
 | 
			
		||||
#else
 | 
			
		||||
	int imgFlags = IMG_INIT_PNG | IMG_INIT_JPG;
 | 
			
		||||
#endif
 | 
			
		||||
	if (IMG_Init(imgFlags) != imgFlags)
 | 
			
		||||
	{
 | 
			
		||||
		showInitError(std::string("Error initializing SDL_image: ") + SDL_GetError());
 | 
			
		||||
| 
						 | 
				
			
			@ -324,13 +328,19 @@ int main(int argc, char *argv[])
 | 
			
		|||
	/* Load and post key bindings */
 | 
			
		||||
	rtData.bindingUpdateMsg.post(loadBindings(conf));
 | 
			
		||||
 | 
			
		||||
	/* Start RGSS thread */
 | 
			
		||||
	SDL_Thread *rgssThread =
 | 
			
		||||
	        SDL_CreateThread(rgssThreadFun, "rgss", &rtData);
 | 
			
		||||
 | 
			
		||||
	/* Start event processing */
 | 
			
		||||
	eventThread.process(rtData);
 | 
			
		||||
 | 
			
		||||
#ifdef __EMSCRIPTEN__
 | 
			
		||||
	::rgssThreadFun(&rtData);
 | 
			
		||||
	printf("Exiting main function\n");
 | 
			
		||||
	return 0;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	/* Start RGSS thread */
 | 
			
		||||
        rgssThreadFun(&rtData);
 | 
			
		||||
	return 0;
 | 
			
		||||
 | 
			
		||||
	/* Request RGSS thread to stop */
 | 
			
		||||
	rtData.rqTerm.set();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -350,8 +360,8 @@ int main(int argc, char *argv[])
 | 
			
		|||
 | 
			
		||||
	/* If RGSS thread ack'd request, wait for it to shutdown,
 | 
			
		||||
	 * otherwise abandon hope and just end the process as is. */
 | 
			
		||||
	if (rtData.rqTermAck)
 | 
			
		||||
		SDL_WaitThread(rgssThread, 0);
 | 
			
		||||
	if (rtData.rqTermAck);
 | 
			
		||||
//		SDL_WaitThread(rgssThread, 0);
 | 
			
		||||
	else
 | 
			
		||||
		SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, conf.windowTitle.c_str(),
 | 
			
		||||
		                         "The RGSS script seems to be stuck and mkxp will now force quit", win);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,7 +23,8 @@
 | 
			
		|||
#include "boost-hash.h"
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <cstring>
 | 
			
		||||
 | 
			
		||||
struct RGSS_entryData
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -293,7 +294,8 @@ processDirectories(RGSS_archiveData *data, BoostSet<std::string> &topLevel,
 | 
			
		|||
		if (slash)
 | 
			
		||||
			nameBuf[i] = '\0';
 | 
			
		||||
 | 
			
		||||
		topLevel.insert(nameBuf);
 | 
			
		||||
		std::string nameBufStr(nameBuf);
 | 
			
		||||
		topLevel.insert(nameBufStr);
 | 
			
		||||
 | 
			
		||||
		if (slash)
 | 
			
		||||
			nameBuf[i] = '/';
 | 
			
		||||
| 
						 | 
				
			
			@ -639,3 +641,4 @@ const PHYSFS_Archiver RGSS3_Archiver =
 | 
			
		|||
	RGSS_stat,
 | 
			
		||||
	RGSS_closeArchive
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,10 @@
 | 
			
		|||
#ifndef SDLUTIL_H
 | 
			
		||||
#define SDLUTIL_H
 | 
			
		||||
 | 
			
		||||
#ifndef __EMSCRIPTEN__
 | 
			
		||||
#include <SDL_atomic.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <SDL_thread.h>
 | 
			
		||||
#include <SDL_rwops.h>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -17,21 +20,37 @@ struct AtomicFlag
 | 
			
		|||
 | 
			
		||||
	void set()
 | 
			
		||||
	{
 | 
			
		||||
#ifdef __EMSCRIPTEN__
 | 
			
		||||
		atom = true;
 | 
			
		||||
#else
 | 
			
		||||
		SDL_AtomicSet(&atom, 1);
 | 
			
		||||
#endif
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void clear()
 | 
			
		||||
	{
 | 
			
		||||
#ifdef __EMSCRIPTEN__
 | 
			
		||||
		atom = false;
 | 
			
		||||
#else
 | 
			
		||||
		SDL_AtomicSet(&atom, 0);
 | 
			
		||||
#endif
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	operator bool() const
 | 
			
		||||
	{
 | 
			
		||||
#ifdef __EMSCRIPTEN__
 | 
			
		||||
		return atom;
 | 
			
		||||
#else
 | 
			
		||||
		return SDL_AtomicGet(&atom);
 | 
			
		||||
#endif
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
#ifdef __EMSCRIPTEN__
 | 
			
		||||
	bool atom = false;
 | 
			
		||||
#else
 | 
			
		||||
	mutable SDL_atomic_t atom;
 | 
			
		||||
#endif
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template<class C, void (C::*func)()>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -263,16 +263,13 @@ void SharedState::bindTex()
 | 
			
		|||
 | 
			
		||||
void SharedState::ensureTexSize(int minW, int minH, Vec2i ¤tSizeOut)
 | 
			
		||||
{
 | 
			
		||||
	if (minW > p->globalTexW)
 | 
			
		||||
	{
 | 
			
		||||
		p->globalTexDirty = true;
 | 
			
		||||
		p->globalTexW = findNextPow2(minW);
 | 
			
		||||
	}
 | 
			
		||||
	minW = findNextPow2(minW); minH = findNextPow2(minH);
 | 
			
		||||
 | 
			
		||||
	if (minH > p->globalTexH)
 | 
			
		||||
	if (minW != p->globalTexW || minH != p->globalTexH)
 | 
			
		||||
	{
 | 
			
		||||
		p->globalTexW = minW;
 | 
			
		||||
		p->globalTexH = minH;
 | 
			
		||||
		p->globalTexDirty = true;
 | 
			
		||||
		p->globalTexH = findNextPow2(minH);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	currentSizeOut = Vec2i(p->globalTexW, p->globalTexH);
 | 
			
		||||
| 
						 | 
				
			
			@ -280,22 +277,12 @@ void SharedState::ensureTexSize(int minW, int minH, Vec2i ¤tSizeOut)
 | 
			
		|||
 | 
			
		||||
TEXFBO &SharedState::gpTexFBO(int minW, int minH)
 | 
			
		||||
{
 | 
			
		||||
	bool needResize = false;
 | 
			
		||||
	minW = findNextPow2(minW); minH = findNextPow2(minH);
 | 
			
		||||
 | 
			
		||||
	if (minW > p->gpTexFBO.width)
 | 
			
		||||
	{
 | 
			
		||||
		p->gpTexFBO.width = findNextPow2(minW);
 | 
			
		||||
		needResize = true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (minH > p->gpTexFBO.height)
 | 
			
		||||
	{
 | 
			
		||||
		p->gpTexFBO.height = findNextPow2(minH);
 | 
			
		||||
		needResize = true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (needResize)
 | 
			
		||||
	if (minW != p->gpTexFBO.width || minH != p->gpTexFBO.height)
 | 
			
		||||
	{
 | 
			
		||||
		p->gpTexFBO.width = minW;
 | 
			
		||||
		p->gpTexFBO.height = minH;
 | 
			
		||||
		TEX::bind(p->gpTexFBO.tex);
 | 
			
		||||
		TEX::allocEmpty(p->gpTexFBO.width, p->gpTexFBO.height);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -192,7 +192,7 @@ struct SoundOpenHandler : FileSystem::OpenHandler
 | 
			
		|||
	    : buffer(0)
 | 
			
		||||
	{}
 | 
			
		||||
 | 
			
		||||
	bool tryRead(SDL_RWops &ops, const char *ext)
 | 
			
		||||
	bool tryRead(SDL_RWops &ops, const char *ext, const char *fullPath)
 | 
			
		||||
	{
 | 
			
		||||
		Sound_Sample *sample = Sound_NewSample(&ops, ext, 0, STREAM_BUF_SIZE);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -388,29 +388,16 @@ struct WindowPrivate
 | 
			
		|||
 | 
			
		||||
	void ensureBaseTexReady()
 | 
			
		||||
	{
 | 
			
		||||
		/* Make sure texture is big enough */
 | 
			
		||||
		int newW = baseTex.width;
 | 
			
		||||
		int newH = baseTex.height;
 | 
			
		||||
		bool resizeNeeded = false;
 | 
			
		||||
		/* Make sure texture is properly sized */
 | 
			
		||||
		int newW = findNextPow2(size.x);
 | 
			
		||||
		int newH = findNextPow2(size.y);
 | 
			
		||||
 | 
			
		||||
		if (size.x > baseTex.width)
 | 
			
		||||
		if (newW != baseTex.width || newH != baseTex.height)
 | 
			
		||||
		{
 | 
			
		||||
			newW = findNextPow2(size.x);
 | 
			
		||||
			resizeNeeded = true;
 | 
			
		||||
			shState->texPool().release(baseTex);
 | 
			
		||||
			baseTex = shState->texPool().request(newW, newH);
 | 
			
		||||
			baseTexDirty = true;
 | 
			
		||||
		}
 | 
			
		||||
		if (size.y > baseTex.height)
 | 
			
		||||
		{
 | 
			
		||||
			newH = findNextPow2(size.y);
 | 
			
		||||
			resizeNeeded = true;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (!resizeNeeded)
 | 
			
		||||
			return;
 | 
			
		||||
 | 
			
		||||
		shState->texPool().release(baseTex);
 | 
			
		||||
		baseTex = shState->texPool().request(newW, newH);
 | 
			
		||||
 | 
			
		||||
		baseTexDirty = true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void redrawBaseTex()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue