From 42d2344557fe8aa7136ece7aa398e235cfcdfcb6 Mon Sep 17 00:00:00 2001 From: Ilya Shurumov Date: Mon, 21 Jun 2021 18:08:52 +0600 Subject: [PATCH] - fix emscripten build not compiling essential files - fix runtime errors - fix sound shutting down issue --- .emscripten/style.css | 1 - src_rebuild/Game/C/main.c | 4 +++ src_rebuild/PsyCross/src/psx/LIBSPU.C | 5 ++-- .../PsyCross/src/render/PsyX_render.cpp | 10 ++----- src_rebuild/premake5.lua | 28 ++++++++++++------- 5 files changed, 27 insertions(+), 21 deletions(-) diff --git a/.emscripten/style.css b/.emscripten/style.css index 2f3d88ff..50ab628f 100644 --- a/.emscripten/style.css +++ b/.emscripten/style.css @@ -5,7 +5,6 @@ html, body {overflow-x: hidden; padding: 0!important} html, section { background-color: #600000; color: white; - background-image: url(tanner.png); height: 100vh; width: 100vw; -webkit-background-size: auto 100%; diff --git a/src_rebuild/Game/C/main.c b/src_rebuild/Game/C/main.c index 28958ef4..206f085f 100644 --- a/src_rebuild/Game/C/main.c +++ b/src_rebuild/Game/C/main.c @@ -1911,6 +1911,10 @@ int redriver2_main(int argc, char** argv) // TODO: divide game by the states, place main loop here. if (argc <= 1) +#elif !defined(PSX) + + InitStringMng(); + #endif { //PlayFMV(99); // [A] don't show publisher logo diff --git a/src_rebuild/PsyCross/src/psx/LIBSPU.C b/src_rebuild/PsyCross/src/psx/LIBSPU.C index 3843ffd6..18dd4247 100644 --- a/src_rebuild/PsyCross/src/psx/LIBSPU.C +++ b/src_rebuild/PsyCross/src/psx/LIBSPU.C @@ -264,10 +264,9 @@ void PsyX_SPU_ShutdownSound() { alDeleteEffects(1, &g_nAlReverbEffect); g_ALEffectsSupported = AL_NONE; + alDeleteAuxiliaryEffectSlots(1, g_ALEffectSlots); } - alDeleteAuxiliaryEffectSlots(1, g_ALEffectSlots); - alcDestroyContext(g_ALCcontext); alcCloseDevice(g_ALCdevice); @@ -500,7 +499,9 @@ void SpuInit(void) void SpuQuit(void) { g_spuInit = 0; +#ifndef __EMSCRIPTEN__ PsyX_SPU_ShutdownSound(); +#endif // SpuQuit } void UpdateVoiceSample(SPUVoice* voice) diff --git a/src_rebuild/PsyCross/src/render/PsyX_render.cpp b/src_rebuild/PsyCross/src/render/PsyX_render.cpp index 70ae71fa..c68be9ad 100644 --- a/src_rebuild/PsyCross/src/render/PsyX_render.cpp +++ b/src_rebuild/PsyCross/src/render/PsyX_render.cpp @@ -1371,15 +1371,9 @@ void GR_Clear(int x, int y, int w, int h, unsigned char r, unsigned char g, unsi #endif } -#define NOFILE 0 - -#if !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) - void GR_SaveVRAM(const char* outputFileName, int x, int y, int width, int height, int bReadFromFrameBuffer) { -#if NOFILE - return; -#endif +#if !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) #if defined(USE_OPENGL) @@ -1411,8 +1405,8 @@ void GR_SaveVRAM(const char* outputFileName, int x, int y, int width, int height fclose(fp); #undef FLIP_Y -} #endif +} void GR_CopyRGBAFramebufferToVRAM(u_int* src, int x, int y, int w, int h, int update_vram, int flip_y) { diff --git a/src_rebuild/premake5.lua b/src_rebuild/premake5.lua index 74516cfd..e9ca1f70 100644 --- a/src_rebuild/premake5.lua +++ b/src_rebuild/premake5.lua @@ -41,11 +41,11 @@ workspace "REDRIVER2" buildoptions { --"-s USE_PTHREADS=1", - "-s PTHREAD_POOL_SIZE=8", - "-s ABORTING_MALLOC=0", - "-s FETCH=1", + --"-s PTHREAD_POOL_SIZE=8", + --"-s ABORTING_MALLOC=0", + --"-s FETCH=1", --"-s PROXY_TO_PTHREAD=1", - "-s WASM=1", + --"-s WASM=1", "-s TOTAL_MEMORY=1073741824", "-s USE_SDL=2", "-s FULL_ES2=1", @@ -64,11 +64,11 @@ workspace "REDRIVER2" } linkoptions { --"-s USE_PTHREADS=1", - "-s PTHREAD_POOL_SIZE=8", - "-s ABORTING_MALLOC=0", - "-s FETCH=1", + --"-s PTHREAD_POOL_SIZE=8", + --"-s ABORTING_MALLOC=0", + --"-s FETCH=1", --"-s PROXY_TO_PTHREAD=1", - "-s WASM=1", + --"-s WASM=1", "-s TOTAL_MEMORY=1073741824", "-s USE_SDL=2", "-s FULL_ES2=1", @@ -80,6 +80,8 @@ workspace "REDRIVER2" ("--preload-file " .. WEBDEMO_DIR) } + targetextension ".bc" + filter { "kind:*App" } targetextension ".html" @@ -137,7 +139,7 @@ workspace "REDRIVER2" "NDEBUG", } -if os.target() == "windows" then +if os.target() == "windows" or os.target() == "emscripten" then include "premake_libjpeg.lua" end @@ -170,7 +172,7 @@ project "REDRIVER2" "Game/**.c" } - filter "system:Windows or linux" + filter {"system:Windows or linux or platforms:emscripten"} --dependson { "PsyX" } links { "jpeg" } @@ -181,6 +183,12 @@ project "REDRIVER2" "redriver2_psxpc.cpp", "DebugOverlay.cpp", } + + filter "platforms:emscripten" + includedirs { + OPENAL_DIR.."/include", + JPEG_DIR.."/", + } filter "system:Windows" entrypoint "mainCRTStartup"