From 6fb45f480bb7e76f7712b332b30a7d86ffcffc02 Mon Sep 17 00:00:00 2001 From: elasota Date: Mon, 29 Mar 2021 21:41:11 -0400 Subject: [PATCH] Emscripten port --- Aerofoil.sln | 6 + AerofoilSDL/AerofoilSDL_Combined.cpp | 8 + AerofoilSDL/GpDisplayDriver_SDL_GL2.cpp | 50 +- AerofoilSDL/GpInputDriver_SDL_Gamepad.cpp | 1 - AerofoilWeb/.gitignore | 3 + AerofoilWeb/AerofoilWeb_Combined.cpp | 4 + AerofoilWeb/AerofoilWeb_Resources.cpp | 15 + AerofoilWeb/BuildAerofoilSDL.bat | 7 + AerofoilWeb/BuildAerofoilWeb.bat | 7 + AerofoilWeb/BuildGpApp.bat | 7 + AerofoilWeb/BuildGpShell.bat | 7 + AerofoilWeb/BuildMacRomanConversion.bat | 7 + AerofoilWeb/BuildPortabilityLayer.bat | 7 + AerofoilWeb/BuildResources.bat | 10 + AerofoilWeb/GpFileSystem_Web.cpp | 651 + AerofoilWeb/GpFileSystem_Web.h | 62 + AerofoilWeb/GpFileSystem_Web_Resources.h | 28 + AerofoilWeb/GpLogDriver_Web.cpp | 89 + AerofoilWeb/GpLogDriver_Web.h | 25 + AerofoilWeb/GpMain_SDL_Web.cpp | 91 + AerofoilWeb/GpSystemServices_Web.cpp | 206 + AerofoilWeb/GpSystemServices_Web.h | 41 + AerofoilWeb/Link.bat | 5 + AerofoilWeb/LinkLog.txt | 18 + AerofoilWeb/MakeBuildDirs.bat | 3 + AerofoilWeb/Rebuild.bat | 9 + AerofoilWeb/Run.bat | 1 + AerofoilWeb/aerofoil.wat | 13128 ++++++++++++++++ Common/CoreDefs.h | 16 + GpApp/About.cpp | 11 +- GpApp/AnimCursor.cpp | 5 +- GpApp/Banner.cpp | 20 +- GpApp/DialogUtils.cpp | 3 + GpApp/Environ.h | 2 +- GpApp/Events.cpp | 6 +- GpApp/GameOver.cpp | 2 + GpApp/GpAppInterface.cpp | 20 +- GpApp/GpApp_Combined.cpp | 69 + GpApp/HighScores.cpp | 14 +- GpApp/House.cpp | 23 +- GpApp/HouseInfo.cpp | 3 +- GpApp/Main.cpp | 73 +- GpApp/MainWindow.cpp | 3 + GpApp/ObjectInfo.cpp | 40 +- GpApp/Render.cpp | 3 +- GpApp/RoomInfo.cpp | 6 +- GpApp/SavedGames.cpp | 20 +- GpApp/SelectHouse.cpp | 3 +- GpApp/Settings.cpp | 17 +- GpApp/Transitions.cpp | 7 +- GpApp/Utilities.cpp | 9 + GpCommon/IGpClipboardContents.h | 2 + GpCommon/IGpDisplayDriver.h | 11 +- GpShell/GpShell_Combined.cpp | 8 + PortabilityLayer/DialogManager.cpp | 105 +- PortabilityLayer/DialogManager.h | 3 +- PortabilityLayer/FileBrowserUI.cpp | 40 +- PortabilityLayer/FileManager.cpp | 10 + PortabilityLayer/GpAppInterface.h | 4 +- PortabilityLayer/HostSuspendHook.cpp | 20 +- PortabilityLayer/MenuManager.cpp | 18 +- PortabilityLayer/MenuManager.h | 3 +- PortabilityLayer/PLButtonWidget.cpp | 201 +- PortabilityLayer/PLButtonWidget.h | 6 +- PortabilityLayer/PLDialogs.cpp | 20 - PortabilityLayer/PLDialogs.h | 79 +- PortabilityLayer/PLEditboxWidget.cpp | 10 +- PortabilityLayer/PLEditboxWidget.h | 5 +- PortabilityLayer/PLIconWidget.cpp | 9 +- PortabilityLayer/PLIconWidget.h | 5 +- PortabilityLayer/PLImageWidget.cpp | 14 +- PortabilityLayer/PLImageWidget.h | 5 +- PortabilityLayer/PLInvisibleWidget.cpp | 9 +- PortabilityLayer/PLInvisibleWidget.h | 5 +- PortabilityLayer/PLLabelWidget.cpp | 14 +- PortabilityLayer/PLLabelWidget.h | 5 +- PortabilityLayer/PLPopupMenuWidget.cpp | 16 +- PortabilityLayer/PLPopupMenuWidget.h | 6 +- PortabilityLayer/PLResourceManager.cpp | 3 + PortabilityLayer/PLScrollBarWidget.cpp | 10 +- PortabilityLayer/PLScrollBarWidget.h | 6 +- PortabilityLayer/PLSysCalls.cpp | 32 +- PortabilityLayer/PLSysCalls.h | 14 + PortabilityLayer/PLWidgets.cpp | 66 +- PortabilityLayer/PLWidgets.h | 61 +- .../PortabilityLayer_Combined.cpp | 86 + PortabilityLayer/WindowManager.cpp | 18 +- PortabilityLayer/WindowManager.h | 5 +- PortabilityLayer/ZipFileProxy.cpp | 28 + bin2h/bin2h.cpp | 92 + bin2h/bin2h.vcxproj | 84 + bin2h/bin2h.vcxproj.filters | 22 + 92 files changed, 15731 insertions(+), 300 deletions(-) create mode 100644 AerofoilSDL/AerofoilSDL_Combined.cpp create mode 100644 AerofoilWeb/.gitignore create mode 100644 AerofoilWeb/AerofoilWeb_Combined.cpp create mode 100644 AerofoilWeb/AerofoilWeb_Resources.cpp create mode 100644 AerofoilWeb/BuildAerofoilSDL.bat create mode 100644 AerofoilWeb/BuildAerofoilWeb.bat create mode 100644 AerofoilWeb/BuildGpApp.bat create mode 100644 AerofoilWeb/BuildGpShell.bat create mode 100644 AerofoilWeb/BuildMacRomanConversion.bat create mode 100644 AerofoilWeb/BuildPortabilityLayer.bat create mode 100644 AerofoilWeb/BuildResources.bat create mode 100644 AerofoilWeb/GpFileSystem_Web.cpp create mode 100644 AerofoilWeb/GpFileSystem_Web.h create mode 100644 AerofoilWeb/GpFileSystem_Web_Resources.h create mode 100644 AerofoilWeb/GpLogDriver_Web.cpp create mode 100644 AerofoilWeb/GpLogDriver_Web.h create mode 100644 AerofoilWeb/GpMain_SDL_Web.cpp create mode 100644 AerofoilWeb/GpSystemServices_Web.cpp create mode 100644 AerofoilWeb/GpSystemServices_Web.h create mode 100644 AerofoilWeb/Link.bat create mode 100644 AerofoilWeb/LinkLog.txt create mode 100644 AerofoilWeb/MakeBuildDirs.bat create mode 100644 AerofoilWeb/Rebuild.bat create mode 100644 AerofoilWeb/Run.bat create mode 100644 AerofoilWeb/aerofoil.wat create mode 100644 GpApp/GpApp_Combined.cpp create mode 100644 GpShell/GpShell_Combined.cpp create mode 100644 PortabilityLayer/PortabilityLayer_Combined.cpp create mode 100644 bin2h/bin2h.cpp create mode 100644 bin2h/bin2h.vcxproj create mode 100644 bin2h/bin2h.vcxproj.filters diff --git a/Aerofoil.sln b/Aerofoil.sln index 705163b..a0e9f4e 100644 --- a/Aerofoil.sln +++ b/Aerofoil.sln @@ -65,6 +65,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MergeGPF", "MergeGPF\MergeG EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GenerateFonts", "GenerateFonts\GenerateFonts.vcxproj", "{3B7FD18D-7A50-4DF5-AC25-543E539BFACE}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bin2h", "bin2h\bin2h.vcxproj", "{D045F28D-F245-44DD-B576-CC91BF3BE6E9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -181,6 +183,10 @@ Global {3B7FD18D-7A50-4DF5-AC25-543E539BFACE}.Debug|x64.Build.0 = Debug|x64 {3B7FD18D-7A50-4DF5-AC25-543E539BFACE}.Release|x64.ActiveCfg = Release|x64 {3B7FD18D-7A50-4DF5-AC25-543E539BFACE}.Release|x64.Build.0 = Release|x64 + {D045F28D-F245-44DD-B576-CC91BF3BE6E9}.Debug|x64.ActiveCfg = Debug|x64 + {D045F28D-F245-44DD-B576-CC91BF3BE6E9}.Debug|x64.Build.0 = Debug|x64 + {D045F28D-F245-44DD-B576-CC91BF3BE6E9}.Release|x64.ActiveCfg = Release|x64 + {D045F28D-F245-44DD-B576-CC91BF3BE6E9}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/AerofoilSDL/AerofoilSDL_Combined.cpp b/AerofoilSDL/AerofoilSDL_Combined.cpp new file mode 100644 index 0000000..9cc267d --- /dev/null +++ b/AerofoilSDL/AerofoilSDL_Combined.cpp @@ -0,0 +1,8 @@ +#include "GpAudioDriver_SDL2.cpp" +#include "GpDisplayDriver_SDL_GL2.cpp" +#include "GpInputDriver_SDL_Gamepad.cpp" +#include "ShaderCode/CopyQuadP.cpp" +#include "ShaderCode/DrawQuadPaletteP.cpp" +#include "ShaderCode/DrawQuad32P.cpp" +#include "ShaderCode/DrawQuadV.cpp" +#include "ShaderCode/ScaleQuadP.cpp" diff --git a/AerofoilSDL/GpDisplayDriver_SDL_GL2.cpp b/AerofoilSDL/GpDisplayDriver_SDL_GL2.cpp index 821eb94..525d0eb 100644 --- a/AerofoilSDL/GpDisplayDriver_SDL_GL2.cpp +++ b/AerofoilSDL/GpDisplayDriver_SDL_GL2.cpp @@ -29,6 +29,9 @@ #include #include +#ifdef __EMSCRIPTEN__ +#include +#endif #pragma push_macro("LoadCursor") #ifdef LoadCursor @@ -730,18 +733,18 @@ public: explicit GpDisplayDriver_SDL_GL2(const GpDisplayDriverProperties &properties); ~GpDisplayDriver_SDL_GL2(); - bool Init() override; - void ServeTicks(int tickCount) override; + bool Init() GP_ASYNCIFY_PARANOID_OVERRIDE; + void ServeTicks(int tickCount) GP_ASYNCIFY_PARANOID_OVERRIDE; void ForceSync() override; - void Shutdown() override; + void Shutdown() GP_ASYNCIFY_PARANOID_OVERRIDE; void TranslateSDLMessage(const SDL_Event *msg, IGpVOSEventQueue *eventQueue, float pixelScaleX, float pixelScaleY, bool obstructiveTextInput); void GetInitialDisplayResolution(unsigned int *width, unsigned int *height) override; IGpDisplayDriverSurface *CreateSurface(size_t width, size_t height, size_t pitch, GpPixelFormat_t pixelFormat, SurfaceInvalidateCallback_t invalidateCallback, void *invalidateContext) override; void DrawSurface(IGpDisplayDriverSurface *surface, int32_t x, int32_t y, size_t width, size_t height, const GpDisplayDriverSurfaceEffects *effects) override; - IGpCursor *CreateBWCursor(size_t width, size_t height, const void *pixelData, const void *maskData, size_t hotSpotX, size_t hotSpotY) override; - IGpCursor *CreateColorCursor(size_t width, size_t height, const void *pixelDataRGBA, size_t hotSpotX, size_t hotSpotY) override; + IGpCursor *CreateBWCursor(size_t width, size_t height, const void *pixelData, const void *maskData, size_t hotSpotX, size_t hotSpotY) GP_ASYNCIFY_PARANOID_OVERRIDE; + IGpCursor *CreateColorCursor(size_t width, size_t height, const void *pixelDataRGBA, size_t hotSpotX, size_t hotSpotY) GP_ASYNCIFY_PARANOID_OVERRIDE; void SetCursor(IGpCursor *cursor) override; void SetStandardCursor(EGpStandardCursor_t standardCursor) override; void UpdatePalette(const void *paletteData) override; @@ -1416,6 +1419,8 @@ void GpDisplayDriver_SDL_GL2::ServeTicks(int ticks) IGpLogDriver *logger = m_properties.m_logger; const bool obstructiveTextInput = m_properties.m_systemServices->IsTextInputObstructive(); + logger->Printf(IGpLogDriver::Category_Information, "ServeTicks %i", ticks); + for (;;) { SDL_Event msg; @@ -1614,7 +1619,7 @@ static void PostTouchEvent(IGpVOSEventQueue *eventQueue, GpTouchEventType_t even static bool IdentifyVKey(const SDL_KeyboardEvent *keyEvt, GpKeyIDSubset_t &outSubset, GpKeyboardInputEvent::KeyUnion &outKey) { - SDL_KeyCode keyCode = static_cast(keyEvt->keysym.sym); + SDL_Keycode keyCode = static_cast(keyEvt->keysym.sym); switch (keyCode) { @@ -3091,6 +3096,10 @@ bool GpDisplayDriver_SDL_GL2::SyncRender() SDL_GL_SwapWindow(m_window); +#ifdef __EMSCRIPTEN__ + emscripten_sleep(16); +#endif + std::chrono::time_point::duration syncTime = std::chrono::high_resolution_clock::now().time_since_epoch(); const intmax_t periodNum = std::chrono::high_resolution_clock::period::num; const intmax_t periodDen = std::chrono::high_resolution_clock::period::den; @@ -3215,4 +3224,33 @@ T *GpGLObjectImpl::Create(GpDisplayDriver_SDL_GL2 *driver) return obj; } +#if GP_ASYNCIFY_PARANOID +bool IGpDisplayDriver::Init() +{ + return static_cast(this)->Init(); +} + +void IGpDisplayDriver::ServeTicks(int tickCount) +{ + static_cast(this)->ServeTicks(tickCount); +} + +void IGpDisplayDriver::Shutdown() +{ + static_cast(this)->Shutdown(); +} + +IGpCursor *IGpDisplayDriver::CreateBWCursor(size_t width, size_t height, const void *pixelData, const void *maskData, size_t hotSpotX, size_t hotSpotY) +{ + return static_cast(this)->CreateBWCursor(width, height, pixelData, maskData, hotSpotX, hotSpotY); +} + +IGpCursor *IGpDisplayDriver::CreateColorCursor(size_t width, size_t height, const void *pixelDataRGBA, size_t hotSpotX, size_t hotSpotY) +{ + return static_cast(this)->CreateColorCursor(width, height, pixelDataRGBA, hotSpotX, hotSpotY); +} + +#endif + + #pragma pop_macro("LoadCursor") diff --git a/AerofoilSDL/GpInputDriver_SDL_Gamepad.cpp b/AerofoilSDL/GpInputDriver_SDL_Gamepad.cpp index 8c275e6..7c5119c 100644 --- a/AerofoilSDL/GpInputDriver_SDL_Gamepad.cpp +++ b/AerofoilSDL/GpInputDriver_SDL_Gamepad.cpp @@ -1,6 +1,5 @@ #include "GpInputDriver_SDL_Gamepad.h" #include "GpVOSEvent.h" -#include "GpWindows.h" #include "IGpVOSEventQueue.h" #include "SDL_events.h" diff --git a/AerofoilWeb/.gitignore b/AerofoilWeb/.gitignore new file mode 100644 index 0000000..94ac521 --- /dev/null +++ b/AerofoilWeb/.gitignore @@ -0,0 +1,3 @@ +obj +res +bin diff --git a/AerofoilWeb/AerofoilWeb_Combined.cpp b/AerofoilWeb/AerofoilWeb_Combined.cpp new file mode 100644 index 0000000..bfdc449 --- /dev/null +++ b/AerofoilWeb/AerofoilWeb_Combined.cpp @@ -0,0 +1,4 @@ +#include "GpFileSystem_Web.cpp" +#include "GpLogDriver_Web.cpp" +#include "GpMain_SDL_Web.cpp" +#include "GpSystemServices_Web.cpp" diff --git a/AerofoilWeb/AerofoilWeb_Resources.cpp b/AerofoilWeb/AerofoilWeb_Resources.cpp new file mode 100644 index 0000000..738d026 --- /dev/null +++ b/AerofoilWeb/AerofoilWeb_Resources.cpp @@ -0,0 +1,15 @@ +#include + +#include "GpFileSystem_Web_Resources.h" + +namespace GpFileSystem_Web_Resources +{ + namespace ApplicationData + { + #include "res/ApplicationData.h" + } + namespace GameData + { + #include "res/GameData.h" + } +} diff --git a/AerofoilWeb/BuildAerofoilSDL.bat b/AerofoilWeb/BuildAerofoilSDL.bat new file mode 100644 index 0000000..3f64240 --- /dev/null +++ b/AerofoilWeb/BuildAerofoilSDL.bat @@ -0,0 +1,7 @@ +set INPUT_DIR=../AerofoilSDL +set OUTPUT_DIR=obj +set FLAGS=-s USE_SDL=2 -flto -I../GpCommon/ -I../PortabilityLayer/ -I../Common/ -s ASYNCIFY -O0 -DGP_DEBUG_CONFIG=0 + +emcc -c %INPUT_DIR%/AerofoilSDL_Combined.cpp -o %OUTPUT_DIR%/AerofoilSDL_Combined.o %FLAGS% + +pause diff --git a/AerofoilWeb/BuildAerofoilWeb.bat b/AerofoilWeb/BuildAerofoilWeb.bat new file mode 100644 index 0000000..56e6b65 --- /dev/null +++ b/AerofoilWeb/BuildAerofoilWeb.bat @@ -0,0 +1,7 @@ +set INPUT_DIR=. +set OUTPUT_DIR=obj +set FLAGS=-s USE_SDL=2 -flto -I../GpCommon/ -I../PortabilityLayer/ -I../Common/ -I../GpShell/ -s ASYNCIFY -O3 -DGP_DEBUG_CONFIG=0 + +emcc -c %INPUT_DIR%/AerofoilWeb_Combined.cpp -o %OUTPUT_DIR%/AerofoilWeb_Combined.o %FLAGS% + +pause diff --git a/AerofoilWeb/BuildGpApp.bat b/AerofoilWeb/BuildGpApp.bat new file mode 100644 index 0000000..f18b9eb --- /dev/null +++ b/AerofoilWeb/BuildGpApp.bat @@ -0,0 +1,7 @@ +set INPUT_DIR=../GpApp +set OUTPUT_DIR=obj +set FLAGS=-s USE_SDL=2 -flto -I../GpCommon/ -I../PortabilityLayer/ -I../Common/ -s ASYNCIFY -O0 -DGP_DEBUG_CONFIG=0 + +emcc -c %INPUT_DIR%/GpApp_Combined.cpp -o %OUTPUT_DIR%/GpApp_Combined.o %FLAGS% + +pause diff --git a/AerofoilWeb/BuildGpShell.bat b/AerofoilWeb/BuildGpShell.bat new file mode 100644 index 0000000..5c06b0d --- /dev/null +++ b/AerofoilWeb/BuildGpShell.bat @@ -0,0 +1,7 @@ +set INPUT_DIR=../GpShell +set OUTPUT_DIR=obj +set FLAGS=-s USE_SDL=2 -flto -I../GpCommon/ -I../PortabilityLayer/ -I../Common/ -s ASYNCIFY -O0 -DGP_DEBUG_CONFIG=0 + +emcc -c %INPUT_DIR%/GpShell_Combined.cpp -o %OUTPUT_DIR%/GpShell_Combined.o %FLAGS% + +pause diff --git a/AerofoilWeb/BuildMacRomanConversion.bat b/AerofoilWeb/BuildMacRomanConversion.bat new file mode 100644 index 0000000..3755fdf --- /dev/null +++ b/AerofoilWeb/BuildMacRomanConversion.bat @@ -0,0 +1,7 @@ +set INPUT_DIR=../MacRomanConversion +set OUTPUT_DIR=obj +set FLAGS=-flto -I../MacRomanConversion/ -s ASYNCIFY -O3 + +emcc -c %INPUT_DIR%/MacRomanConversion.cpp -o %OUTPUT_DIR%/MacRomanConversion.o %FLAGS% + +pause diff --git a/AerofoilWeb/BuildPortabilityLayer.bat b/AerofoilWeb/BuildPortabilityLayer.bat new file mode 100644 index 0000000..11e26b9 --- /dev/null +++ b/AerofoilWeb/BuildPortabilityLayer.bat @@ -0,0 +1,7 @@ +set INPUT_DIR=../PortabilityLayer +set OUTPUT_DIR=obj +set FLAGS=-s USE_ZLIB=1 -flto -I../GpCommon/ -I../Common/ -I../PortabilityLayer/ -I../rapidjson/include/ -I../MacRomanConversion/ -I../stb/ -s ASYNCIFY -O3 -DGP_DEBUG_CONFIG=0 -Wno-tautological-constant-out-of-range-compare + +emcc -c %INPUT_DIR%/PortabilityLayer_Combined.cpp -o %OUTPUT_DIR%/PortabilityLayer_Combined.o %FLAGS% + +pause diff --git a/AerofoilWeb/BuildResources.bat b/AerofoilWeb/BuildResources.bat new file mode 100644 index 0000000..42178e5 --- /dev/null +++ b/AerofoilWeb/BuildResources.bat @@ -0,0 +1,10 @@ +..\x64\Release\bin2h.exe ..\Packaged res\ApplicationData.h +..\x64\Release\bin2h.exe ..\Packaged\Houses res\GameData.h + +set INPUT_DIR=. +set OUTPUT_DIR=obj +set FLAGS=-flto -O3 -DGP_DEBUG_CONFIG=0 + +emcc -c %INPUT_DIR%/AerofoilWeb_Resources.cpp -o %OUTPUT_DIR%/AerofoilWeb_Resources.o %FLAGS% + +pause diff --git a/AerofoilWeb/GpFileSystem_Web.cpp b/AerofoilWeb/GpFileSystem_Web.cpp new file mode 100644 index 0000000..8578b5a --- /dev/null +++ b/AerofoilWeb/GpFileSystem_Web.cpp @@ -0,0 +1,651 @@ +#define _LARGEFILE64_SOURCE +#include "GpFileSystem_Web.h" +#include "GpIOStream.h" +#include "IGpDirectoryCursor.h" +#include "IGpSystemServices.h" +#include "IGpMutex.h" +#include "VirtualDirectory.h" + +#include "PLDrivers.h" + +#include "SDL2/SDL.h" +#include "SDL2/SDL_rwops.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "UTF8.h" + +#if defined(__CYGWIN__) || defined(__EMSCRIPTEN__) +typedef off_t off64_t; +#define fstat64 fstat +#define fseek64 fseek +#define ftruncate64 ftruncate +#define stat64 stat +#endif + + +class GpFileStream_Web_StaticMemFile final : public GpIOStream +{ +public: + GpFileStream_Web_StaticMemFile(const unsigned char *bytes, size_t size); + ~GpFileStream_Web_StaticMemFile(); + + size_t Read(void *bytesOut, size_t size) override; + size_t Write(const void *bytes, size_t size) override; + bool IsSeekable() const override; + bool IsReadOnly() const override; + bool IsWriteOnly() const override; + bool SeekStart(GpUFilePos_t loc) override; + bool SeekCurrent(GpFilePos_t loc) override; + bool SeekEnd(GpUFilePos_t loc) override; + GpUFilePos_t Size() const override; + GpUFilePos_t Tell() const override; + void Close() override; + void Flush() override; + +private: + const unsigned char *m_bytes; + size_t m_offset; + size_t m_size; +}; + +GpFileStream_Web_StaticMemFile::GpFileStream_Web_StaticMemFile(const unsigned char *bytes, size_t size) + : m_bytes(bytes) + , m_size(size) + , m_offset(0) +{ +} + +GpFileStream_Web_StaticMemFile::~GpFileStream_Web_StaticMemFile() +{ +} + +size_t GpFileStream_Web_StaticMemFile::Read(void *bytesOut, size_t size) +{ + size_t available = m_size - m_offset; + size = std::min(size, available); + + memcpy(bytesOut, m_bytes + m_offset, size); + m_offset += size; + return size; +} + +size_t GpFileStream_Web_StaticMemFile::Write(const void *bytes, size_t size) +{ + return 0; +} + +bool GpFileStream_Web_StaticMemFile::IsSeekable() const +{ + return true; +} + +bool GpFileStream_Web_StaticMemFile::IsReadOnly() const +{ + return true; +} + +bool GpFileStream_Web_StaticMemFile::IsWriteOnly() const +{ + return false; +} + +bool GpFileStream_Web_StaticMemFile::SeekStart(GpUFilePos_t loc) +{ + if (loc > m_size) + return false; + + m_offset = static_cast(loc); + return true; +} + +bool GpFileStream_Web_StaticMemFile::SeekCurrent(GpFilePos_t loc) +{ + GpFilePos_t minOffset = -static_cast(m_offset); + GpFilePos_t maxOffset = static_cast(m_size - m_offset); + + if (loc < minOffset || loc > maxOffset) + return false; + + m_offset = static_cast(static_cast(m_offset) + loc); + return true; +} + +bool GpFileStream_Web_StaticMemFile::SeekEnd(GpUFilePos_t loc) +{ + if (loc > m_size) + { + fprintf(stderr, "SeekEnd failed: Loc %i size %i\n", static_cast(loc), static_cast(m_size)); + return false; + } + + m_offset = m_size - loc; + return true; +} + +GpUFilePos_t GpFileStream_Web_StaticMemFile::Size() const +{ + return m_size; +} + +GpUFilePos_t GpFileStream_Web_StaticMemFile::Tell() const +{ + return m_offset; +} + +void GpFileStream_Web_StaticMemFile::Close() +{ + delete this; +} + +void GpFileStream_Web_StaticMemFile::Flush() +{ +} + + +class GpFileStream_Web_File final : public GpIOStream +{ +public: + GpFileStream_Web_File(FILE *f, bool readOnly, bool writeOnly); + ~GpFileStream_Web_File(); + + size_t Read(void *bytesOut, size_t size) override; + size_t Write(const void *bytes, size_t size) override; + bool IsSeekable() const override; + bool IsReadOnly() const override; + bool IsWriteOnly() const override; + bool SeekStart(GpUFilePos_t loc) override; + bool SeekCurrent(GpFilePos_t loc) override; + bool SeekEnd(GpUFilePos_t loc) override; + GpUFilePos_t Size() const override; + GpUFilePos_t Tell() const override; + void Close() override; + void Flush() override; + +private: + FILE *m_f; + bool m_seekable; + bool m_isReadOnly; + bool m_isWriteOnly; +}; + + +GpFileStream_Web_File::GpFileStream_Web_File(FILE *f, bool readOnly, bool writeOnly) + : m_f(f) + , m_isReadOnly(readOnly) + , m_isWriteOnly(writeOnly) +{ + m_seekable = (fseek(m_f, 0, SEEK_CUR) == 0); +} + +GpFileStream_Web_File::~GpFileStream_Web_File() +{ + fclose(m_f); +} + +size_t GpFileStream_Web_File::Read(void *bytesOut, size_t size) +{ + if (m_isWriteOnly) + return 0; + return fread(bytesOut, 1, size, m_f); +} + +size_t GpFileStream_Web_File::Write(const void *bytes, size_t size) +{ + if (m_isReadOnly) + return 0; + return fwrite(bytes, 1, size, m_f); +} + +bool GpFileStream_Web_File::IsSeekable() const +{ + return m_seekable; +} + +bool GpFileStream_Web_File::IsReadOnly() const +{ + return m_isReadOnly; +} + +bool GpFileStream_Web_File::IsWriteOnly() const +{ + return m_isWriteOnly; +} + +bool GpFileStream_Web_File::SeekStart(GpUFilePos_t loc) +{ + if (!m_seekable) + return false; + + fflush(m_f); + return fseek64(m_f, static_cast(loc), SEEK_SET) >= 0; +} + +bool GpFileStream_Web_File::SeekCurrent(GpFilePos_t loc) +{ + if (!m_seekable) + return false; + + fflush(m_f); + return fseek64(m_f, static_cast(loc), SEEK_CUR) >= 0; +} + +bool GpFileStream_Web_File::SeekEnd(GpUFilePos_t loc) +{ + if (!m_seekable) + return false; + + fflush(m_f); + return fseek64(m_f, -static_cast(loc), SEEK_END) >= 0; +} + +GpUFilePos_t GpFileStream_Web_File::Size() const +{ + fflush(m_f); + + struct stat64 s; + if (fstat64(fileno(m_f), &s) < 0) + return 0; + + return static_cast(s.st_size); +} + +GpUFilePos_t GpFileStream_Web_File::Tell() const +{ + return static_cast(ftell(m_f)); +} + +void GpFileStream_Web_File::Close() +{ + this->~GpFileStream_Web_File(); + free(this); +} + +void GpFileStream_Web_File::Flush() +{ + fflush(m_f); +} + +bool GpFileSystem_Web::ResolvePath(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths, std::string &resolution) +{ + const char *prefsAppend = nullptr; + + switch (virtualDirectory) + { + case PortabilityLayer::VirtualDirectories::kApplicationData: + resolution = std::string("Packaged"); + break; + case PortabilityLayer::VirtualDirectories::kGameData: + resolution = std::string("Packaged/Houses"); + break; + case PortabilityLayer::VirtualDirectories::kFonts: + resolution = std::string("Resources"); + break; + case PortabilityLayer::VirtualDirectories::kHighScores: + prefsAppend = "HighScores"; + break; + case PortabilityLayer::VirtualDirectories::kUserData: + prefsAppend = "Houses"; + break; + case PortabilityLayer::VirtualDirectories::kUserSaves: + prefsAppend = "SavedGames"; + break; + case PortabilityLayer::VirtualDirectories::kPrefs: + prefsAppend = "Prefs"; + break; + case PortabilityLayer::VirtualDirectories::kFontCache: + prefsAppend = "FontCache"; + break; + default: + return false; + }; + + if (prefsAppend) + resolution = m_prefsPath + prefsAppend; + else + resolution = m_basePath + resolution; + + for (size_t i = 0; i < numPaths; i++) + { + resolution += "/"; + resolution += paths[i]; + } + + return true; +} + +GpFileSystem_Web::GpFileSystem_Web() + : m_delayCallback(nullptr) +{ +} + +GpFileSystem_Web::~GpFileSystem_Web() +{ +} + +void GpFileSystem_Web::Init() +{ + char *prefsDir = SDL_GetPrefPath("aerofoil", "aerofoil"); + m_prefsPath = prefsDir; + + char *baseDir = SDL_GetBasePath(); + m_basePath = baseDir; + SDL_free(baseDir); + + char baseDirSeparator = m_basePath[m_basePath.size() - 1]; + if (m_basePath.size() >= 4 && m_basePath.substr(m_basePath.size() - 4, 3) == "bin") + m_basePath = m_basePath.substr(0, m_basePath.size() - 4) + "lib" + baseDirSeparator + "aerofoil" + baseDirSeparator; + + const char *extensions[] = { "HighScores", "Houses", "SavedGames", "Prefs", "FontCache" }; + for (size_t i = 0; i < sizeof(extensions) / sizeof(extensions[0]); i++) + { + std::string prefsPath = std::string(prefsDir) + extensions[i]; + int created = mkdir(prefsPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + } + SDL_free(prefsDir); +} + +bool GpFileSystem_Web::FileExists(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path) +{ + if (const GpFileSystem_Web_Resources::FileCatalog *catalog = GetCatalogForVirtualDirectory(virtualDirectory)) + { + for (size_t i = 0; i < catalog->m_numEntries; i++) + { + const GpFileSystem_Web_Resources::FileCatalogEntry &entry = catalog->m_entries[i]; + if (!strcmp(path, entry.m_fileName)) + return true; + } + + return false; + } + + std::string resolvedPath; + if (!ResolvePath(virtualDirectory, &path, 1, resolvedPath)) + return false; + + struct stat s; + return stat(resolvedPath.c_str(), &s) == 0; +} + +bool GpFileSystem_Web::FileLocked(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool &exists) +{ + fprintf(stderr, "FileLocked %s\n", path); + if (const GpFileSystem_Web_Resources::FileCatalog *catalog = GetCatalogForVirtualDirectory(virtualDirectory)) + { + for (size_t i = 0; i < catalog->m_numEntries; i++) + { + const GpFileSystem_Web_Resources::FileCatalogEntry &entry = catalog->m_entries[i]; + if (!strcmp(path, entry.m_fileName)) + { + exists = true; + return true; + } + } + + exists = false; + return false; + } + + std::string resolvedPath; + if (!ResolvePath(virtualDirectory, &path, 1, resolvedPath)) + { + if (exists) + exists = false; + return false; + } + + int permissions = access(resolvedPath.c_str(), W_OK | F_OK); + exists = ((permissions & F_OK) != 0); + return ((permissions & W_OK) != 0); +} + +GpIOStream *GpFileSystem_Web::OpenFileNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* subPaths, size_t numSubPaths, bool writeAccess, GpFileCreationDisposition_t createDisposition) +{ + fprintf(stderr, "OpenFileNested %i %s subPaths %i\n", static_cast(virtualDirectory), subPaths[0], static_cast(numSubPaths)); + if (numSubPaths == 1) + { + fprintf(stderr, "Only one subpath\n"); + if (const GpFileSystem_Web_Resources::FileCatalog *catalog = GetCatalogForVirtualDirectory(virtualDirectory)) + { + fprintf(stderr, "Catalog matched. %i entries. %i size %i size0\n", static_cast(catalog->m_numEntries), static_cast(catalog->m_size), static_cast(catalog->m_size0)); + for (size_t i = 0; i < catalog->m_numEntries; i++) + { + const GpFileSystem_Web_Resources::FileCatalogEntry &entry = catalog->m_entries[i]; + fprintf(stderr, "Comparing '%s' to '%s'\n", subPaths[0], entry.m_fileName); + if (!strcmp(subPaths[0], entry.m_fileName)) + { + fprintf(stderr, "File name matched\n"); + return new GpFileStream_Web_StaticMemFile(entry.m_data, entry.m_size); + } + } + + fprintf(stderr, "Catalog had no match\n"); + return nullptr; + } + } + + fprintf(stderr, "More paths, falling through...\n"); + + const char *mode = nullptr; + bool canWrite = false; + bool needResetPosition = false; + + switch (createDisposition) + { + case GpFileCreationDispositions::kCreateOrOverwrite: + mode = "wb"; + break; + case GpFileCreationDispositions::kCreateNew: + mode = "x+b"; + break; + case GpFileCreationDispositions::kCreateOrOpen: + mode = "a+b"; + needResetPosition = true; + break; + case GpFileCreationDispositions::kOpenExisting: + mode = writeAccess ? "r+b" : "rb"; + break; + case GpFileCreationDispositions::kOverwriteExisting: + mode = "r+b"; + break; + default: + return nullptr; + }; + + if (virtualDirectory == PortabilityLayer::VirtualDirectories::kSourceExport) + return nullptr; + + std::string resolvedPath; + if (!ResolvePath(virtualDirectory, subPaths, numSubPaths, resolvedPath)) + return nullptr; + + void *objStorage = malloc(sizeof(GpFileStream_Web_File)); + if (!objStorage) + return nullptr; + + FILE *f = fopen(resolvedPath.c_str(), mode); + if (!f) + { + free(objStorage); + return nullptr; + } + + if (needResetPosition) + fseek(f, 0, SEEK_SET); + + if (createDisposition == GpFileCreationDispositions::kOverwriteExisting) + { + if (ftruncate64(fileno(f), 0) < 0) + { + free(objStorage); + fclose(f); + return nullptr; + } + } + + return new (objStorage) GpFileStream_Web_File(f, !writeAccess, false); +} + +bool GpFileSystem_Web::DeleteFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool &existed) +{ + fprintf(stderr, "Delete file %s\n", path); + if (const GpFileSystem_Web_Resources::FileCatalog *catalog = GetCatalogForVirtualDirectory(virtualDirectory)) + return false; + + std::string resolvedPath; + if (!ResolvePath(virtualDirectory, &path, 1, resolvedPath)) + { + existed = false; + return false; + } + + if (unlink(resolvedPath.c_str()) < 0) + { + existed = (errno != ENOENT); + return false; + } + existed = true; + return true; +} + +bool GpFileSystem_Web::ValidateFilePath(const char *path, size_t length) const +{ + for (size_t i = 0; i < length; i++) + { + const char c = path[i]; + if (c >= '0' && c <= '9') + continue; + + if (c == '_' || c == '.' || c == '\'' || c == '!') + continue; + + if (c == ' ' && i != 0 && i != length - 1) + continue; + + if (c >= 'a' && c <= 'z') + continue; + + if (c >= 'A' && c <= 'Z') + continue; + + return false; + } + + return true; +} + +bool GpFileSystem_Web::ValidateFilePathUnicodeChar(uint32_t c) const +{ + if (c >= '0' && c <= '9') + return true; + + if (c == '_' || c == '\'') + return true; + + if (c == ' ') + return true; + + if (c >= 'a' && c <= 'z') + return true; + + if (c >= 'A' && c <= 'Z') + return true; + + return false; +} + +void GpFileSystem_Web::SetDelayCallback(DelayCallback_t delayCallback) +{ + m_delayCallback = delayCallback; +} + +GpFileSystem_Web *GpFileSystem_Web::GetInstance() +{ + return &ms_instance; +} + +class GpDirectoryCursor_StringList final : public IGpDirectoryCursor +{ +public: + explicit GpDirectoryCursor_StringList(std::vector &paths); + ~GpDirectoryCursor_StringList(); + + bool GetNext(const char *&outFileName) override; + void Destroy() override; + +private: + std::vector m_paths; + size_t m_index; +}; + +GpDirectoryCursor_StringList::GpDirectoryCursor_StringList(std::vector &paths) + : m_index(0) +{ + std::swap(paths, m_paths); +} + +GpDirectoryCursor_StringList::~GpDirectoryCursor_StringList() +{ +} + +bool GpDirectoryCursor_StringList::GetNext(const char *&outFileName) +{ + if (m_index == m_paths.size()) + return false; + outFileName = m_paths[m_index].c_str(); + m_index++; + return true; +} + +void GpDirectoryCursor_StringList::Destroy() +{ + delete this; +} + + +IGpDirectoryCursor *GpFileSystem_Web::ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths) +{ + if (const GpFileSystem_Web_Resources::FileCatalog *catalog = GetCatalogForVirtualDirectory(virtualDirectory)) + return ScanCatalog(*catalog); + + return nullptr; +} + +const GpFileSystem_Web_Resources::FileCatalog *GpFileSystem_Web::GetCatalogForVirtualDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory) +{ + if (virtualDirectory == PortabilityLayer::VirtualDirectories::kApplicationData) + { + fprintf(stderr, "%i == %i\n", static_cast(virtualDirectory), static_cast(PortabilityLayer::VirtualDirectories::kApplicationData)); + fprintf(stderr, "%i size\n", GpFileSystem_Web_Resources::ApplicationData::GetCatalog().m_size); + fprintf(stderr, "First name: %s\n", GpFileSystem_Web_Resources::ApplicationData::GetCatalog().m_entries[0].m_fileName); + return &GpFileSystem_Web_Resources::ApplicationData::GetCatalog(); + } + fprintf(stderr, "%i != %i\n", static_cast(virtualDirectory), static_cast(PortabilityLayer::VirtualDirectories::kApplicationData)); + + if (virtualDirectory == PortabilityLayer::VirtualDirectories::kGameData) + { + fprintf(stderr, "%i == %i\n", static_cast(virtualDirectory), static_cast(PortabilityLayer::VirtualDirectories::kGameData)); + return &GpFileSystem_Web_Resources::GameData::GetCatalog(); + } + fprintf(stderr, "%i != %i\n", static_cast(virtualDirectory), static_cast(PortabilityLayer::VirtualDirectories::kGameData)); + + return nullptr; +} + +IGpDirectoryCursor *GpFileSystem_Web::ScanCatalog(const GpFileSystem_Web_Resources::FileCatalog &catalog) +{ + std::vector paths; + for (size_t i = 0; i < catalog.m_numEntries; i++) + paths.push_back(std::string(catalog.m_entries[i].m_fileName)); + + return new GpDirectoryCursor_StringList(paths); +} + + +GpFileSystem_Web GpFileSystem_Web::ms_instance; diff --git a/AerofoilWeb/GpFileSystem_Web.h b/AerofoilWeb/GpFileSystem_Web.h new file mode 100644 index 0000000..236a10a --- /dev/null +++ b/AerofoilWeb/GpFileSystem_Web.h @@ -0,0 +1,62 @@ +#pragma once + +#include "IGpFileSystem.h" +#include "GpFileSystem_Web_Resources.h" + +#include "GpCoreDefs.h" + +#include +#include + +struct IGpMutex; + +class GpFileSystem_Web final : public IGpFileSystem +{ +public: + GpFileSystem_Web(); + ~GpFileSystem_Web(); + + void Init(); + + bool FileExists(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path) override; + bool FileLocked(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool &exists) override; + GpIOStream *OpenFileNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* subPaths, size_t numSubPaths, bool writeAccess, GpFileCreationDisposition_t createDisposition) override; + bool DeleteFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool &existed) override; + IGpDirectoryCursor *ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths) override; + + bool ValidateFilePath(const char *path, size_t pathLen) const override; + bool ValidateFilePathUnicodeChar(uint32_t ch) const override; + + void SetDelayCallback(DelayCallback_t delayCallback) override; + + static GpFileSystem_Web *GetInstance(); + +private: + struct ScanDirectoryNestedContext + { + GpFileSystem_Web *m_this; + + IGpDirectoryCursor *m_returnValue; + PortabilityLayer::VirtualDirectory_t m_virtualDirectory; + char const *const *m_paths; + size_t m_numPaths; + }; + + static void ScanDirectoryNestedThunk(void *context); + IGpDirectoryCursor *ScanDirectoryNestedInternal(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths); + + IGpDirectoryCursor *ScanDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths); + + static const GpFileSystem_Web_Resources::FileCatalog *GetCatalogForVirtualDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory); + + static IGpDirectoryCursor *ScanCatalog(const GpFileSystem_Web_Resources::FileCatalog &catalog); + + bool ResolvePath(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths, std::string &resolution); + + DelayCallback_t m_delayCallback; + + std::string m_prefsPath; + std::string m_basePath; + + static GpFileSystem_Web ms_instance; +}; diff --git a/AerofoilWeb/GpFileSystem_Web_Resources.h b/AerofoilWeb/GpFileSystem_Web_Resources.h new file mode 100644 index 0000000..fb7a60e --- /dev/null +++ b/AerofoilWeb/GpFileSystem_Web_Resources.h @@ -0,0 +1,28 @@ +#pragma once + +namespace GpFileSystem_Web_Resources +{ + struct FileCatalogEntry + { + const char *m_fileName; + const unsigned char *m_data; + const unsigned int m_size; + }; + + struct FileCatalog + { + const FileCatalogEntry *m_entries; + const unsigned int m_numEntries; + const unsigned int m_size; + const unsigned int m_size0; + }; + + namespace ApplicationData + { + const FileCatalog &GetCatalog(); + } + namespace GameData + { + const FileCatalog &GetCatalog(); + } +} diff --git a/AerofoilWeb/GpLogDriver_Web.cpp b/AerofoilWeb/GpLogDriver_Web.cpp new file mode 100644 index 0000000..973174e --- /dev/null +++ b/AerofoilWeb/GpLogDriver_Web.cpp @@ -0,0 +1,89 @@ +#include "GpLogDriver_Web.h" +#include "GpFileSystem_Web.h" + +#include "GpApplicationName.h" +#include "GpIOStream.h" + +#include +#include + +GpLogDriver_Web::GpLogDriver_Web() +{ +} + +void GpLogDriver_Web::Init() +{ + ms_instance.InitInternal(); +} + +void GpLogDriver_Web::VPrintf(Category category, const char *fmt, va_list args) +{ + size_t fmtSize = 0; + bool hasFormatting = false; + for (const char *fmtCheck = fmt; *fmtCheck; fmtCheck++) + { + if (*fmtCheck == '%') + hasFormatting = true; + + fmtSize++; + } + + time_t t = time(nullptr); + struct tm sysTime = *localtime(&t); + + char timestampBuffer[64]; + sprintf(timestampBuffer, "[%02d:%02d:%02d] ", sysTime.tm_hour, sysTime.tm_min, sysTime.tm_sec); + + const char *debugTag = ""; + + switch (category) + { + case Category_Warning: + debugTag = "[WARNING] "; + break; + case Category_Error: + debugTag = "[ERROR] "; + break; + default: + break; + }; + + int formattedSize = vsnprintf(nullptr, 0, fmt, args); + if (formattedSize <= 0) + return; + + char *charBuff = static_cast(malloc(formattedSize + 1)); + if (!charBuff) + return; + + vsnprintf(charBuff, formattedSize + 1, fmt, args); + + fprintf(stderr, "%s%s%s\n", timestampBuffer, debugTag, charBuff); + fflush(stderr); + + free(charBuff); +} + +void GpLogDriver_Web::Shutdown() +{ +} + +GpLogDriver_Web *GpLogDriver_Web::GetInstance() +{ + return &ms_instance; +} + +void GpLogDriver_Web::InitInternal() +{ + time_t t = time(nullptr); + struct tm utcTime = *gmtime(&t); + + this->Printf(IGpLogDriver::Category_Information, GP_APPLICATION_NAME " build " __TIMESTAMP__); +#if !GP_DEBUG_CONFIG + this->Printf(IGpLogDriver::Category_Information, "Configuration: Release"); +#else + this->Printf(IGpLogDriver::Category_Information, "Configuration: Debug"); +#endif +} + +GpLogDriver_Web GpLogDriver_Web::ms_instance; diff --git a/AerofoilWeb/GpLogDriver_Web.h b/AerofoilWeb/GpLogDriver_Web.h new file mode 100644 index 0000000..07a10d8 --- /dev/null +++ b/AerofoilWeb/GpLogDriver_Web.h @@ -0,0 +1,25 @@ +#pragma once + +#include "IGpLogDriver.h" + +#include + +class GpIOStream; + +class GpLogDriver_Web : public IGpLogDriver +{ +public: + GpLogDriver_Web(); + + static void Init(); + + void VPrintf(Category category, const char *fmt, va_list args) override; + void Shutdown() override; + + static GpLogDriver_Web *GetInstance(); + +private: + void InitInternal(); + + static GpLogDriver_Web ms_instance; +}; diff --git a/AerofoilWeb/GpMain_SDL_Web.cpp b/AerofoilWeb/GpMain_SDL_Web.cpp new file mode 100644 index 0000000..a424a87 --- /dev/null +++ b/AerofoilWeb/GpMain_SDL_Web.cpp @@ -0,0 +1,91 @@ +#include +#include "SDL_main.h" + +#include "GpMain.h" +#include "GpAudioDriverFactory.h" +#include "GpDisplayDriverFactory.h" +#include "GpGlobalConfig.h" +#include "GpFileSystem_Web.h" +#include "GpLogDriver_Web.h" +#include "GpFontHandlerFactory.h" +#include "GpInputDriverFactory.h" +#include "GpAppInterface.h" +#include "GpSystemServices_Web.h" +#include "GpVOSEvent.h" +#include "GpX.h" + +#include "IGpFileSystem.h" +#include "IGpThreadEvent.h" +#include "IGpVOSEventQueue.h" + +#include + +GpXGlobals g_gpXGlobals; + +extern "C" IGpFontHandler *GpDriver_CreateFontHandler_FreeType2(const GpFontHandlerProperties &properties); + +IGpDisplayDriver *GpDriver_CreateDisplayDriver_SDL_GL2(const GpDisplayDriverProperties &properties); +IGpAudioDriver *GpDriver_CreateAudioDriver_SDL(const GpAudioDriverProperties &properties); +IGpInputDriver *GpDriver_CreateInputDriver_SDL2_Gamepad(const GpInputDriverProperties &properties); + + +int main(int argc, char* argv[]) +{ + GpLogDriver_Web::Init(); + IGpLogDriver *logger = GpLogDriver_Web::GetInstance(); + +#if GP_ASYNCIFY_PARANOID + SDL_SetHint(SDL_HINT_EMSCRIPTEN_ASYNCIFY, "0"); +#endif + + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER) < 0) + return -1; + + if (logger) + logger->Printf(IGpLogDriver::Category_Information, "Starting filesystem..."); + + GpFileSystem_Web::GetInstance()->Init(); + + GpDriverCollection *drivers = GpAppInterface_Get()->PL_GetDriverCollection(); + + if (logger) + logger->Printf(IGpLogDriver::Category_Information, "Setting up drivers..."); + + drivers->SetDriver(GpFileSystem_Web::GetInstance()); + drivers->SetDriver(GpSystemServices_Web::GetInstance()); + drivers->SetDriver(GpLogDriver_Web::GetInstance()); + + g_gpGlobalConfig.m_displayDriverType = EGpDisplayDriverType_SDL_GL2; + + g_gpGlobalConfig.m_audioDriverType = EGpAudioDriverType_SDL2; + + g_gpGlobalConfig.m_fontHandlerType = EGpFontHandlerType_None; + + EGpInputDriverType inputDrivers[] = + { + EGpInputDriverType_SDL2_Gamepad + }; + + g_gpGlobalConfig.m_inputDriverTypes = inputDrivers; + g_gpGlobalConfig.m_numInputDrivers = sizeof(inputDrivers) / sizeof(inputDrivers[0]); + + g_gpGlobalConfig.m_osGlobals = &g_gpXGlobals; + g_gpGlobalConfig.m_logger = logger; + g_gpGlobalConfig.m_systemServices = GpSystemServices_Web::GetInstance(); + + GpDisplayDriverFactory::RegisterDisplayDriverFactory(EGpDisplayDriverType_SDL_GL2, GpDriver_CreateDisplayDriver_SDL_GL2); + GpAudioDriverFactory::RegisterAudioDriverFactory(EGpAudioDriverType_SDL2, GpDriver_CreateAudioDriver_SDL); + GpInputDriverFactory::RegisterInputDriverFactory(EGpInputDriverType_SDL2_Gamepad, GpDriver_CreateInputDriver_SDL2_Gamepad); + + if (logger) + logger->Printf(IGpLogDriver::Category_Information, "SDL environment configured, starting up"); + + int returnCode = GpMain::Run(); + + if (logger) + logger->Printf(IGpLogDriver::Category_Information, "SDL environment exited with code %i, cleaning up", returnCode); + + SDL_Quit(); + + return returnCode; +} diff --git a/AerofoilWeb/GpSystemServices_Web.cpp b/AerofoilWeb/GpSystemServices_Web.cpp new file mode 100644 index 0000000..48e874b --- /dev/null +++ b/AerofoilWeb/GpSystemServices_Web.cpp @@ -0,0 +1,206 @@ +#include "GpSystemServices_Web.h" + +#include "IGpClipboardContents.h" +#include "IGpThreadEvent.h" +#include "SDL2/SDL.h" + +#include +#include +#include + +class GpMutex_Web_Null final : public IGpMutex +{ +public: + void Destroy() override; + + void Lock() override; + void Unlock() override; + + static IGpMutex *GetInstance(); + +private: + static GpMutex_Web_Null ms_instance; +}; + +void GpMutex_Web_Null::Destroy() +{ +} + +void GpMutex_Web_Null::Lock() +{ +} + +void GpMutex_Web_Null::Unlock() +{ +} + +IGpMutex *GpMutex_Web_Null::GetInstance() +{ + return &ms_instance; +} + +GpMutex_Web_Null GpMutex_Web_Null::ms_instance; + + +class GpThreadEvent_Web_Null final : public IGpThreadEvent +{ +public: + void Wait() override; + bool WaitTimed(uint32_t msec) override; + void Signal() override; + void Destroy() override; + + static IGpThreadEvent *GetInstance(); + +private: + static GpThreadEvent_Web_Null ms_instance; +}; + +void GpThreadEvent_Web_Null::Wait() +{ +} + +bool GpThreadEvent_Web_Null::WaitTimed(uint32_t msec) +{ + return true; +} + +void GpThreadEvent_Web_Null::Signal() +{ +} + +void GpThreadEvent_Web_Null::Destroy() +{ +} + +IGpThreadEvent *GpThreadEvent_Web_Null::GetInstance() +{ + return &ms_instance; +} + + +GpSystemServices_Web::GpSystemServices_Web() + : m_textInputEnabled(false) + , m_clipboardContents(nullptr) +{ +} + +int64_t GpSystemServices_Web::GetTime() const +{ + time_t t = time(nullptr); + return static_cast(t) - 2082844800; +} + +void GpSystemServices_Web::GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const +{ + time_t t = time(nullptr); + tm *tmObject = localtime(&t); + year = static_cast(tmObject->tm_year); + month = static_cast(tmObject->tm_mon + 1); + hour = static_cast(tmObject->tm_hour); + minute = static_cast(tmObject->tm_min); + second = static_cast(tmObject->tm_sec); +} + +IGpMutex *GpSystemServices_Web::CreateMutex() +{ + return GpMutex_Web_Null::GetInstance(); +} + +IGpMutex *GpSystemServices_Web::CreateRecursiveMutex() +{ + return GpMutex_Web_Null::GetInstance(); +} + +IGpThreadEvent *GpSystemServices_Web::CreateThreadEvent(bool autoReset, bool startSignaled) +{ + return GpThreadEvent_Web_Null::GetInstance(); +} + +uint64_t GpSystemServices_Web::GetFreeMemoryCosmetic() const +{ + return 0; +} + +GpSystemServices_Web::~GpSystemServices_Web() +{ + if (m_clipboardContents) + m_clipboardContents->Destroy(); +} + +void *GpSystemServices_Web::CreateThread(ThreadFunc_t threadFunc, void *context) +{ + return nullptr; +} + +void GpSystemServices_Web::Beep() const +{ +} + +bool GpSystemServices_Web::IsTouchscreen() const +{ + return false; +} + +bool GpSystemServices_Web::IsUsingMouseAsTouch() const +{ + return false; +} + +bool GpSystemServices_Web::IsTextInputObstructive() const +{ + return false; +} + +bool GpSystemServices_Web::IsFullscreenPreferred() const +{ + return false; +} + +bool GpSystemServices_Web::IsFullscreenOnStartup() const +{ + return false; +} + +unsigned int GpSystemServices_Web::GetCPUCount() const +{ + return SDL_GetCPUCount(); +} + +void GpSystemServices_Web::SetTextInputEnabled(bool isEnabled) +{ + m_textInputEnabled = isEnabled; +} + +bool GpSystemServices_Web::IsTextInputEnabled() const +{ + return m_textInputEnabled; +} + +bool GpSystemServices_Web::AreFontResourcesSeekable() const +{ + return true; +} + +IGpClipboardContents *GpSystemServices_Web::GetClipboardContents() const +{ + return m_clipboardContents; +} + +void GpSystemServices_Web::SetClipboardContents(IGpClipboardContents *contents) +{ + if (contents != m_clipboardContents) + { + if (m_clipboardContents) + m_clipboardContents->Destroy(); + + m_clipboardContents = contents; + } +} + +GpSystemServices_Web *GpSystemServices_Web::GetInstance() +{ + return &ms_instance; +} + +GpSystemServices_Web GpSystemServices_Web::ms_instance; diff --git a/AerofoilWeb/GpSystemServices_Web.h b/AerofoilWeb/GpSystemServices_Web.h new file mode 100644 index 0000000..ebc7e5d --- /dev/null +++ b/AerofoilWeb/GpSystemServices_Web.h @@ -0,0 +1,41 @@ +#pragma once + +#include "IGpSystemServices.h" +#include "GpCoreDefs.h" + +struct IGpClipboardContents; + +class GpSystemServices_Web final : public IGpSystemServices +{ +public: + GpSystemServices_Web(); + ~GpSystemServices_Web(); + + void *CreateThread(ThreadFunc_t threadFunc, void *context) override; + void Beep() const override; + bool IsTouchscreen() const override; + bool IsUsingMouseAsTouch() const override; + bool IsTextInputObstructive() const override; + bool IsFullscreenPreferred() const override; + bool IsFullscreenOnStartup() const override; + unsigned int GetCPUCount() const override; + void SetTextInputEnabled(bool isEnabled) override; + bool IsTextInputEnabled() const override; + bool AreFontResourcesSeekable() const override; + IGpClipboardContents *GetClipboardContents() const override; + void SetClipboardContents(IGpClipboardContents *contents) override; + int64_t GetTime() const override; + void GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const override; + IGpMutex *CreateMutex() override; + IGpMutex *CreateRecursiveMutex() override; + IGpThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override; + uint64_t GetFreeMemoryCosmetic() const override; + + static GpSystemServices_Web *GetInstance(); + +private: + static GpSystemServices_Web ms_instance; + + IGpClipboardContents *m_clipboardContents; + bool m_textInputEnabled; +}; diff --git a/AerofoilWeb/Link.bat b/AerofoilWeb/Link.bat new file mode 100644 index 0000000..f1ff6c4 --- /dev/null +++ b/AerofoilWeb/Link.bat @@ -0,0 +1,5 @@ +set INPUT_DIR=. +set OUTPUT_DIR=bin +set FLAGS=-flto -O0 -g -s USE_SDL=2 -s USE_ZLIB=1 -s ASYNCIFY -s ASYNCIFY_IGNORE_INDIRECT -s INITIAL_MEMORY=33554432 -s ASYNCIFY_ADVISE + +emcc obj/AerofoilWeb_Combined.o obj/AerofoilWeb_Resources.o obj/GpShell_Combined.o obj/AerofoilSDL_Combined.o obj/GpApp_Combined.o obj/PortabilityLayer_Combined.o obj/MacRomanConversion.o -o %OUTPUT_DIR%/aerofoil.html %FLAGS% diff --git a/AerofoilWeb/LinkLog.txt b/AerofoilWeb/LinkLog.txt new file mode 100644 index 0000000..953aa4b --- /dev/null +++ b/AerofoilWeb/LinkLog.txt @@ -0,0 +1,18 @@ + +d:\src\GlidePort\AerofoilWeb> + +d:\src\GlidePort\AerofoilWeb> + +d:\src\GlidePort\AerofoilWeb> + +d:\src\GlidePort\AerofoilWeb> + +d:\src\GlidePort\AerofoilWeb> + +d:\src\GlidePort\AerofoilWeb> + +d:\src\GlidePort\AerofoilWeb> + +d:\src\GlidePort\AerofoilWeb> + +d:\src\GlidePort\AerofoilWeb> \ No newline at end of file diff --git a/AerofoilWeb/MakeBuildDirs.bat b/AerofoilWeb/MakeBuildDirs.bat new file mode 100644 index 0000000..67bfe7d --- /dev/null +++ b/AerofoilWeb/MakeBuildDirs.bat @@ -0,0 +1,3 @@ +mkdir obj +mkdir bin +mkdir res diff --git a/AerofoilWeb/Rebuild.bat b/AerofoilWeb/Rebuild.bat new file mode 100644 index 0000000..1fe3a49 --- /dev/null +++ b/AerofoilWeb/Rebuild.bat @@ -0,0 +1,9 @@ +call MakeBuildDirs.bat +call BuildAerofoilSDL.bat +call BuildAerofoilWeb.bat +call BuildGpApp.bat +call BuildGpShell.bat +call BuildMacRomanConversion.bat +call BuildPortabilityLayer.bat +call BuildResources.bat +call Link.bat diff --git a/AerofoilWeb/Run.bat b/AerofoilWeb/Run.bat new file mode 100644 index 0000000..3fc3522 --- /dev/null +++ b/AerofoilWeb/Run.bat @@ -0,0 +1 @@ +emrun bin/aerofoil.html diff --git a/AerofoilWeb/aerofoil.wat b/AerofoilWeb/aerofoil.wat new file mode 100644 index 0000000..72781b4 --- /dev/null +++ b/AerofoilWeb/aerofoil.wat @@ -0,0 +1,13128 @@ +(module + (type (;0;) (func (param i32 i32 i32) (result i32))) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (param i32 i32) (result i32))) + (type (;3;) (func (param i32))) + (type (;4;) (func (param i32 i32))) + (type (;5;) (func)) + (type (;6;) (func (param i32 i32 i32 i32))) + (type (;7;) (func (param i32 i32 i32 i32) (result i32))) + (type (;8;) (func (param i32 i32 i32 i32 i32))) + (type (;9;) (func (param i32 i32 i32 i32 i32 i32))) + (type (;10;) (func (param i32) (result i64))) + (type (;11;) (func (result i32))) + (type (;12;) (func (param i32 i64 i32) (result i64))) + (type (;13;) (func (param i32 i32 i32))) + (type (;14;) (func (param i32 i32 i32 i32 i32) (result i32))) + (type (;15;) (func (param i32 i64) (result i32))) + (type (;16;) (func (param i32 i32 i32 i32 i32 i32 i32))) + (type (;17;) (func (param i32 i64 i64 i32))) + (type (;18;) (func (param i32 f64 i32 i32 i32 i32) (result i32))) + (type (;19;) (func (param i64 i32) (result i32))) + (type (;20;) (func (param i32 i32 i32 i32 i32 i32) (result i32))) + (type (;21;) (func (param i32 i32 i32 i32 i32 i32 i32) (result i32))) + (type (;22;) (func (param i32 i64 i32) (result i32))) + (type (;23;) (func (param i64 i32 i32) (result i32))) + (type (;24;) (func (param i64 i64) (result f64))) + (type (;25;) (func (param f64 i32) (result f64))) + (import "a" "a" (func (;0;) (type 1))) + (import "a" "b" (func (;1;) (type 1))) + (import "a" "c" (func (;2;) (type 1))) + (import "a" "d" (func (;3;) (type 0))) + (import "a" "e" (func (;4;) (type 2))) + (import "a" "f" (func (;5;) (type 0))) + (import "a" "g" (func (;6;) (type 5))) + (import "a" "h" (func (;7;) (type 7))) + (import "a" "i" (func (;8;) (type 7))) + (import "a" "j" (func (;9;) (type 0))) + (import "a" "k" (func (;10;) (type 2))) + (import "a" "l" (func (;11;) (type 14))) + (import "a" "m" (func (;12;) (type 0))) + (import "a" "n" (func (;13;) (type 0))) + (import "a" "o" (func (;14;) (type 2))) + (import "a" "p" (func (;15;) (type 2))) + (import "a" "q" (func (;16;) (type 2))) + (import "a" "r" (func (;17;) (type 2))) + (import "a" "s" (func (;18;) (type 1))) + (import "a" "t" (func (;19;) (type 7))) + (import "a" "u" (func (;20;) (type 2))) + (func (;21;) (type 3) (param i32) + (local i32 i32 i32 i32 i32 i32 i32) + block ;; label = @1 + local.get 0 + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.const 8 + i32.sub + local.set 3 + local.get 3 + local.get 0 + i32.const 4 + i32.sub + i32.load + local.tee 1 + i32.const -8 + i32.and + local.tee 0 + i32.add + local.set 5 + block ;; label = @2 + local.get 1 + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 1 + i32.const 3 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 3 + local.get 3 + i32.load + local.tee 1 + i32.sub + local.tee 3 + i32.const 3148 + i32.load + i32.lt_u + br_if 1 (;@1;) + local.get 0 + local.get 1 + i32.add + local.set 0 + local.get 3 + i32.const 3152 + i32.load + i32.ne + if ;; label = @3 + local.get 1 + i32.const 255 + i32.le_u + if ;; label = @4 + local.get 3 + i32.load offset=8 + local.tee 2 + local.get 1 + i32.const 3 + i32.shr_u + local.tee 4 + i32.const 3 + i32.shl + i32.const 3172 + i32.add + i32.eq + drop + local.get 2 + local.get 3 + i32.load offset=12 + local.tee 1 + i32.eq + if ;; label = @5 + i32.const 3132 + i32.const 3132 + i32.load + i32.const -2 + local.get 4 + i32.rotl + i32.and + i32.store + br 3 (;@2;) + end + local.get 2 + local.get 1 + i32.store offset=12 + local.get 1 + local.get 2 + i32.store offset=8 + br 2 (;@2;) + end + local.get 3 + i32.load offset=24 + local.set 6 + block ;; label = @4 + local.get 3 + local.get 3 + i32.load offset=12 + local.tee 1 + i32.ne + if ;; label = @5 + local.get 3 + i32.load offset=8 + local.tee 2 + local.get 1 + i32.store offset=12 + local.get 1 + local.get 2 + i32.store offset=8 + br 1 (;@4;) + end + block ;; label = @5 + local.get 3 + i32.const 20 + i32.add + local.tee 2 + i32.load + local.tee 4 + br_if 0 (;@5;) + local.get 3 + i32.const 16 + i32.add + local.tee 2 + i32.load + local.tee 4 + br_if 0 (;@5;) + i32.const 0 + local.set 1 + br 1 (;@4;) + end + loop ;; label = @5 + local.get 2 + local.set 7 + local.get 4 + local.tee 1 + i32.const 20 + i32.add + local.tee 2 + i32.load + local.tee 4 + br_if 0 (;@5;) + local.get 1 + i32.const 16 + i32.add + local.set 2 + local.get 1 + i32.load offset=16 + local.tee 4 + br_if 0 (;@5;) + end + local.get 7 + i32.const 0 + i32.store + end + local.get 6 + i32.eqz + br_if 1 (;@2;) + block ;; label = @4 + local.get 3 + i32.load offset=28 + local.tee 2 + i32.const 2 + i32.shl + i32.const 3436 + i32.add + local.tee 4 + i32.load + local.get 3 + i32.eq + if ;; label = @5 + local.get 4 + local.get 1 + i32.store + local.get 1 + br_if 1 (;@4;) + i32.const 3136 + i32.const 3136 + i32.load + i32.const -2 + local.get 2 + i32.rotl + i32.and + i32.store + br 3 (;@2;) + end + local.get 6 + i32.const 16 + i32.const 20 + local.get 3 + local.get 6 + i32.load offset=16 + i32.eq + select + i32.add + local.get 1 + i32.store + local.get 1 + i32.eqz + br_if 2 (;@2;) + end + local.get 1 + local.get 6 + i32.store offset=24 + local.get 3 + i32.load offset=16 + local.tee 2 + if ;; label = @4 + local.get 1 + local.get 2 + i32.store offset=16 + local.get 2 + local.get 1 + i32.store offset=24 + end + local.get 3 + i32.load offset=20 + local.tee 2 + i32.eqz + br_if 1 (;@2;) + local.get 1 + local.get 2 + i32.store offset=20 + local.get 2 + local.get 1 + i32.store offset=24 + br 1 (;@2;) + end + local.get 5 + i32.load offset=4 + local.tee 1 + i32.const 3 + i32.and + i32.const 3 + i32.ne + br_if 0 (;@2;) + i32.const 3140 + local.get 0 + i32.store + local.get 5 + local.get 1 + i32.const -2 + i32.and + i32.store offset=4 + local.get 3 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 0 + local.get 3 + i32.add + local.get 0 + i32.store + return + end + local.get 3 + local.get 5 + i32.ge_u + br_if 0 (;@1;) + local.get 5 + i32.load offset=4 + local.tee 1 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + block ;; label = @2 + local.get 1 + i32.const 2 + i32.and + i32.eqz + if ;; label = @3 + local.get 5 + i32.const 3156 + i32.load + i32.eq + if ;; label = @4 + i32.const 3156 + local.get 3 + i32.store + i32.const 3144 + i32.const 3144 + i32.load + local.get 0 + i32.add + local.tee 0 + i32.store + local.get 3 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 3 + i32.const 3152 + i32.load + i32.ne + br_if 3 (;@1;) + i32.const 3140 + i32.const 0 + i32.store + i32.const 3152 + i32.const 0 + i32.store + return + end + local.get 5 + i32.const 3152 + i32.load + i32.eq + if ;; label = @4 + i32.const 3152 + local.get 3 + i32.store + i32.const 3140 + i32.const 3140 + i32.load + local.get 0 + i32.add + local.tee 0 + i32.store + local.get 3 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 0 + local.get 3 + i32.add + local.get 0 + i32.store + return + end + local.get 1 + i32.const -8 + i32.and + local.get 0 + i32.add + local.set 0 + block ;; label = @4 + local.get 1 + i32.const 255 + i32.le_u + if ;; label = @5 + local.get 5 + i32.load offset=8 + local.tee 2 + local.get 1 + i32.const 3 + i32.shr_u + local.tee 4 + i32.const 3 + i32.shl + i32.const 3172 + i32.add + i32.eq + drop + local.get 2 + local.get 5 + i32.load offset=12 + local.tee 1 + i32.eq + if ;; label = @6 + i32.const 3132 + i32.const 3132 + i32.load + i32.const -2 + local.get 4 + i32.rotl + i32.and + i32.store + br 2 (;@4;) + end + local.get 2 + local.get 1 + i32.store offset=12 + local.get 1 + local.get 2 + i32.store offset=8 + br 1 (;@4;) + end + local.get 5 + i32.load offset=24 + local.set 6 + block ;; label = @5 + local.get 5 + local.get 5 + i32.load offset=12 + local.tee 1 + i32.ne + if ;; label = @6 + local.get 5 + i32.load offset=8 + local.tee 2 + i32.const 3148 + i32.load + i32.lt_u + drop + local.get 2 + local.get 1 + i32.store offset=12 + local.get 1 + local.get 2 + i32.store offset=8 + br 1 (;@5;) + end + block ;; label = @6 + local.get 5 + i32.const 20 + i32.add + local.tee 2 + i32.load + local.tee 4 + br_if 0 (;@6;) + local.get 5 + i32.const 16 + i32.add + local.tee 2 + i32.load + local.tee 4 + br_if 0 (;@6;) + i32.const 0 + local.set 1 + br 1 (;@5;) + end + loop ;; label = @6 + local.get 2 + local.set 7 + local.get 4 + local.tee 1 + i32.const 20 + i32.add + local.tee 2 + i32.load + local.tee 4 + br_if 0 (;@6;) + local.get 1 + i32.const 16 + i32.add + local.set 2 + local.get 1 + i32.load offset=16 + local.tee 4 + br_if 0 (;@6;) + end + local.get 7 + i32.const 0 + i32.store + end + local.get 6 + i32.eqz + br_if 0 (;@4;) + block ;; label = @5 + local.get 5 + local.get 5 + i32.load offset=28 + local.tee 2 + i32.const 2 + i32.shl + i32.const 3436 + i32.add + local.tee 4 + i32.load + i32.eq + if ;; label = @6 + local.get 4 + local.get 1 + i32.store + local.get 1 + br_if 1 (;@5;) + i32.const 3136 + i32.const 3136 + i32.load + i32.const -2 + local.get 2 + i32.rotl + i32.and + i32.store + br 2 (;@4;) + end + local.get 6 + i32.const 16 + i32.const 20 + local.get 5 + local.get 6 + i32.load offset=16 + i32.eq + select + i32.add + local.get 1 + i32.store + local.get 1 + i32.eqz + br_if 1 (;@4;) + end + local.get 1 + local.get 6 + i32.store offset=24 + local.get 5 + i32.load offset=16 + local.tee 2 + if ;; label = @5 + local.get 1 + local.get 2 + i32.store offset=16 + local.get 2 + local.get 1 + i32.store offset=24 + end + local.get 5 + i32.load offset=20 + local.tee 2 + i32.eqz + br_if 0 (;@4;) + local.get 1 + local.get 2 + i32.store offset=20 + local.get 2 + local.get 1 + i32.store offset=24 + end + local.get 3 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 0 + local.get 3 + i32.add + local.get 0 + i32.store + local.get 3 + i32.const 3152 + i32.load + i32.ne + br_if 1 (;@2;) + i32.const 3140 + local.get 0 + i32.store + return + end + local.get 5 + local.get 1 + i32.const -2 + i32.and + i32.store offset=4 + local.get 3 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 0 + local.get 3 + i32.add + local.get 0 + i32.store + end + local.get 0 + i32.const 255 + i32.le_u + if ;; label = @2 + local.get 0 + i32.const 3 + i32.shr_u + local.tee 1 + i32.const 3 + i32.shl + i32.const 3172 + i32.add + local.set 0 + block (result i32) ;; label = @3 + i32.const 1 + local.get 1 + i32.shl + local.tee 1 + i32.const 3132 + i32.load + local.tee 2 + i32.and + i32.eqz + if ;; label = @4 + i32.const 3132 + local.get 1 + local.get 2 + i32.or + i32.store + local.get 0 + br 1 (;@3;) + end + local.get 0 + i32.load offset=8 + end + local.set 2 + local.get 0 + local.get 3 + i32.store offset=8 + local.get 2 + local.get 3 + i32.store offset=12 + local.get 3 + local.get 0 + i32.store offset=12 + local.get 3 + local.get 2 + i32.store offset=8 + return + end + i32.const 31 + local.set 2 + local.get 3 + i64.const 0 + i64.store offset=16 align=4 + local.get 0 + i32.const 16777215 + i32.le_u + if ;; label = @2 + local.get 0 + i32.const 8 + i32.shr_u + local.tee 4 + i32.const 1048320 + i32.add + i32.const 16 + i32.shr_u + i32.const 8 + i32.and + local.set 1 + local.get 4 + local.get 1 + i32.shl + local.tee 4 + i32.const 520192 + i32.add + i32.const 16 + i32.shr_u + i32.const 4 + i32.and + local.set 2 + local.get 4 + local.get 2 + i32.shl + local.tee 4 + local.get 4 + i32.const 245760 + i32.add + i32.const 16 + i32.shr_u + i32.const 2 + i32.and + local.tee 4 + i32.shl + i32.const 15 + i32.shr_u + local.get 1 + local.get 2 + i32.or + local.get 4 + i32.or + i32.sub + local.tee 1 + i32.const 1 + i32.shl + local.set 2 + local.get 2 + local.get 0 + local.get 1 + i32.const 21 + i32.add + i32.shr_u + i32.const 1 + i32.and + i32.or + i32.const 28 + i32.add + local.set 2 + end + local.get 3 + local.get 2 + i32.store offset=28 + local.get 2 + i32.const 2 + i32.shl + i32.const 3436 + i32.add + local.set 1 + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + i32.const 3136 + i32.load + local.tee 4 + i32.const 1 + local.get 2 + i32.shl + local.tee 7 + i32.and + i32.eqz + if ;; label = @5 + i32.const 3136 + local.get 4 + local.get 7 + i32.or + i32.store + local.get 1 + local.get 3 + i32.store + local.get 3 + local.get 1 + i32.store offset=24 + br 1 (;@4;) + end + local.get 0 + i32.const 0 + i32.const 25 + local.get 2 + i32.const 1 + i32.shr_u + i32.sub + local.get 2 + i32.const 31 + i32.eq + select + i32.shl + local.set 2 + local.get 1 + i32.load + local.set 1 + loop ;; label = @5 + local.get 1 + local.tee 4 + i32.load offset=4 + i32.const -8 + i32.and + local.get 0 + i32.eq + br_if 2 (;@3;) + local.get 2 + i32.const 29 + i32.shr_u + local.set 1 + local.get 2 + i32.const 1 + i32.shl + local.set 2 + local.get 1 + i32.const 4 + i32.and + local.get 4 + i32.add + local.tee 7 + i32.const 16 + i32.add + i32.load + local.tee 1 + br_if 0 (;@5;) + end + local.get 7 + local.get 3 + i32.store offset=16 + local.get 3 + local.get 4 + i32.store offset=24 + end + local.get 3 + local.get 3 + i32.store offset=12 + local.get 3 + local.get 3 + i32.store offset=8 + br 1 (;@2;) + end + local.get 4 + i32.load offset=8 + local.tee 0 + local.get 3 + i32.store offset=12 + local.get 4 + local.get 3 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=24 + local.get 3 + local.get 4 + i32.store offset=12 + local.get 3 + local.get 0 + i32.store offset=8 + end + i32.const 3164 + i32.const 3164 + i32.load + i32.const 1 + i32.sub + local.tee 0 + i32.const -1 + local.get 0 + select + i32.store + end) + (func (;22;) (type 13) (param i32 i32 i32) + local.get 0 + i32.load8_u + i32.const 32 + i32.and + i32.eqz + if ;; label = @1 + local.get 1 + local.get 2 + local.get 0 + call 40 + drop + end) + (func (;23;) (type 8) (param i32 i32 i32 i32 i32) + (local i32) + global.get 0 + i32.const 256 + i32.sub + local.tee 5 + global.set 0 + block ;; label = @1 + local.get 2 + local.get 3 + i32.le_s + br_if 0 (;@1;) + local.get 4 + i32.const 73728 + i32.and + br_if 0 (;@1;) + local.get 1 + i32.const 255 + i32.and + local.set 4 + local.get 2 + local.get 3 + i32.sub + local.tee 2 + i32.const 256 + i32.lt_u + local.set 1 + local.get 5 + local.get 4 + local.get 2 + i32.const 256 + local.get 1 + select + call 31 + drop + local.get 1 + i32.eqz + if ;; label = @2 + loop ;; label = @3 + local.get 0 + local.get 5 + i32.const 256 + call 22 + local.get 2 + i32.const 256 + i32.sub + local.tee 2 + i32.const 255 + i32.gt_u + br_if 0 (;@3;) + end + end + local.get 0 + local.get 5 + local.get 2 + call 22 + end + local.get 5 + i32.const 256 + i32.add + global.set 0) + (func (;24;) (type 0) (param i32 i32 i32) (result i32) + local.get 2 + i32.eqz + if ;; label = @1 + local.get 0 + i32.load offset=4 + local.get 1 + i32.load offset=4 + i32.eq + return + end + local.get 0 + local.get 1 + i32.eq + if ;; label = @1 + i32.const 1 + return + end + local.get 0 + i32.load offset=4 + local.get 1 + i32.load offset=4 + call 139 + i32.eqz) + (func (;25;) (type 1) (param i32) (result i32) + (local i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 12 + global.set 0 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + block ;; label = @6 + block ;; label = @7 + block ;; label = @8 + block ;; label = @9 + block ;; label = @10 + block ;; label = @11 + block ;; label = @12 + block ;; label = @13 + local.get 0 + i32.const 244 + i32.le_u + if ;; label = @14 + i32.const 3132 + i32.load + local.tee 6 + i32.const 16 + local.get 0 + i32.const 11 + i32.add + i32.const -8 + i32.and + local.get 0 + i32.const 11 + i32.lt_u + select + local.tee 5 + i32.const 3 + i32.shr_u + local.tee 0 + i32.shr_u + local.tee 1 + i32.const 3 + i32.and + if ;; label = @15 + local.get 1 + i32.const -1 + i32.xor + i32.const 1 + i32.and + local.get 0 + i32.add + local.tee 2 + i32.const 3 + i32.shl + local.tee 3 + i32.const 3180 + i32.add + i32.load + local.tee 1 + i32.const 8 + i32.add + local.set 0 + block ;; label = @16 + local.get 3 + i32.const 3172 + i32.add + local.tee 3 + local.get 1 + i32.load offset=8 + local.tee 4 + i32.eq + if ;; label = @17 + i32.const 3132 + local.get 6 + i32.const -2 + local.get 2 + i32.rotl + i32.and + i32.store + br 1 (;@16;) + end + local.get 4 + local.get 3 + i32.store offset=12 + local.get 3 + local.get 4 + i32.store offset=8 + end + local.get 1 + local.get 2 + i32.const 3 + i32.shl + local.tee 2 + i32.const 3 + i32.or + i32.store offset=4 + local.get 1 + local.get 2 + i32.add + local.tee 1 + i32.load offset=4 + i32.const 1 + i32.or + local.set 2 + local.get 1 + local.get 2 + i32.store offset=4 + br 14 (;@1;) + end + i32.const 3140 + i32.load + local.tee 8 + local.get 5 + i32.ge_u + br_if 1 (;@13;) + local.get 1 + if ;; label = @15 + i32.const 0 + i32.const 2 + local.get 0 + i32.shl + local.tee 2 + i32.sub + local.set 3 + i32.const 0 + local.get 2 + local.get 3 + i32.or + local.get 1 + local.get 0 + i32.shl + i32.and + local.tee 0 + i32.sub + local.set 1 + local.get 0 + local.get 1 + i32.and + i32.const 1 + i32.sub + local.tee 0 + local.get 0 + i32.const 12 + i32.shr_u + i32.const 16 + i32.and + local.tee 0 + i32.shr_u + local.tee 1 + i32.const 5 + i32.shr_u + i32.const 8 + i32.and + local.set 2 + local.get 0 + local.get 2 + i32.or + local.set 3 + local.get 3 + local.get 1 + local.get 2 + i32.shr_u + local.tee 0 + i32.const 2 + i32.shr_u + i32.const 4 + i32.and + local.tee 1 + i32.or + local.set 2 + local.get 2 + local.get 0 + local.get 1 + i32.shr_u + local.tee 0 + i32.const 1 + i32.shr_u + i32.const 2 + i32.and + local.tee 1 + i32.or + local.set 2 + local.get 2 + local.get 0 + local.get 1 + i32.shr_u + local.tee 0 + i32.const 1 + i32.shr_u + i32.const 1 + i32.and + local.tee 1 + i32.or + local.set 2 + block ;; label = @16 + local.get 2 + local.get 0 + local.get 1 + i32.shr_u + i32.add + local.tee 2 + i32.const 3 + i32.shl + local.tee 4 + i32.const 3180 + i32.add + i32.load + local.tee 1 + i32.load offset=8 + local.tee 0 + local.get 4 + i32.const 3172 + i32.add + local.tee 4 + i32.eq + if ;; label = @17 + i32.const 3132 + local.get 6 + i32.const -2 + local.get 2 + i32.rotl + i32.and + local.tee 6 + i32.store + br 1 (;@16;) + end + local.get 0 + local.get 4 + i32.store offset=12 + local.get 4 + local.get 0 + i32.store offset=8 + end + local.get 1 + i32.const 8 + i32.add + local.set 0 + local.get 1 + local.get 5 + i32.const 3 + i32.or + i32.store offset=4 + local.get 1 + local.get 5 + i32.add + local.tee 7 + local.get 2 + i32.const 3 + i32.shl + local.tee 2 + local.get 5 + i32.sub + local.tee 3 + i32.const 1 + i32.or + i32.store offset=4 + local.get 1 + local.get 2 + i32.add + local.get 3 + i32.store + local.get 8 + if ;; label = @16 + local.get 8 + i32.const 3 + i32.shr_u + local.tee 4 + i32.const 3 + i32.shl + i32.const 3172 + i32.add + local.set 1 + i32.const 3152 + i32.load + local.set 2 + block (result i32) ;; label = @17 + local.get 6 + i32.const 1 + local.get 4 + i32.shl + local.tee 4 + i32.and + i32.eqz + if ;; label = @18 + i32.const 3132 + local.get 4 + local.get 6 + i32.or + i32.store + local.get 1 + br 1 (;@17;) + end + local.get 1 + i32.load offset=8 + end + local.set 4 + local.get 1 + local.get 2 + i32.store offset=8 + local.get 4 + local.get 2 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=12 + local.get 2 + local.get 4 + i32.store offset=8 + end + i32.const 3152 + local.get 7 + i32.store + i32.const 3140 + local.get 3 + i32.store + br 14 (;@1;) + end + i32.const 3136 + i32.load + local.tee 10 + i32.eqz + br_if 1 (;@13;) + local.get 10 + i32.const 0 + local.get 10 + i32.sub + i32.and + i32.const 1 + i32.sub + local.tee 0 + local.get 0 + i32.const 12 + i32.shr_u + i32.const 16 + i32.and + local.tee 0 + i32.shr_u + local.tee 1 + i32.const 5 + i32.shr_u + i32.const 8 + i32.and + local.set 2 + local.get 0 + local.get 2 + i32.or + local.set 3 + local.get 3 + local.get 1 + local.get 2 + i32.shr_u + local.tee 0 + i32.const 2 + i32.shr_u + i32.const 4 + i32.and + local.tee 1 + i32.or + local.set 2 + local.get 2 + local.get 0 + local.get 1 + i32.shr_u + local.tee 0 + i32.const 1 + i32.shr_u + i32.const 2 + i32.and + local.tee 1 + i32.or + local.set 2 + local.get 2 + local.get 0 + local.get 1 + i32.shr_u + local.tee 0 + i32.const 1 + i32.shr_u + i32.const 1 + i32.and + local.tee 1 + i32.or + local.set 2 + local.get 2 + local.get 0 + local.get 1 + i32.shr_u + i32.add + i32.const 2 + i32.shl + i32.const 3436 + i32.add + i32.load + local.tee 3 + i32.load offset=4 + i32.const -8 + i32.and + local.get 5 + i32.sub + local.set 2 + local.get 3 + local.set 1 + loop ;; label = @15 + block ;; label = @16 + local.get 1 + i32.load offset=16 + local.tee 0 + i32.eqz + if ;; label = @17 + local.get 1 + i32.load offset=20 + local.tee 0 + i32.eqz + br_if 1 (;@16;) + end + local.get 0 + i32.load offset=4 + i32.const -8 + i32.and + local.get 5 + i32.sub + local.tee 1 + local.get 2 + local.get 1 + local.get 2 + i32.lt_u + local.tee 1 + select + local.set 2 + local.get 0 + local.get 3 + local.get 1 + select + local.set 3 + local.get 0 + local.set 1 + br 1 (;@15;) + end + end + local.get 3 + local.get 5 + i32.add + local.tee 11 + local.get 3 + i32.le_u + br_if 2 (;@12;) + local.get 3 + i32.load offset=24 + local.set 9 + local.get 3 + i32.load offset=12 + local.tee 4 + local.get 3 + i32.ne + if ;; label = @15 + local.get 3 + i32.load offset=8 + local.tee 0 + i32.const 3148 + i32.load + i32.lt_u + drop + local.get 0 + local.get 4 + i32.store offset=12 + local.get 4 + local.get 0 + i32.store offset=8 + br 13 (;@2;) + end + local.get 3 + i32.const 20 + i32.add + local.tee 1 + i32.load + local.tee 0 + i32.eqz + if ;; label = @15 + local.get 3 + i32.load offset=16 + local.tee 0 + i32.eqz + br_if 4 (;@11;) + local.get 3 + i32.const 16 + i32.add + local.set 1 + end + loop ;; label = @15 + local.get 1 + local.set 7 + local.get 0 + local.set 4 + local.get 0 + i32.const 20 + i32.add + local.tee 1 + i32.load + local.tee 0 + br_if 0 (;@15;) + local.get 4 + i32.const 16 + i32.add + local.set 1 + local.get 4 + i32.load offset=16 + local.tee 0 + br_if 0 (;@15;) + end + local.get 7 + i32.const 0 + i32.store + br 12 (;@2;) + end + i32.const -1 + local.set 5 + local.get 0 + i32.const -65 + i32.gt_u + br_if 0 (;@13;) + local.get 0 + i32.const 11 + i32.add + local.tee 0 + i32.const -8 + i32.and + local.set 5 + i32.const 3136 + i32.load + local.tee 8 + i32.eqz + br_if 0 (;@13;) + i32.const 31 + local.set 7 + local.get 5 + i32.const 16777215 + i32.le_u + if ;; label = @14 + local.get 0 + i32.const 8 + i32.shr_u + local.tee 0 + local.get 0 + i32.const 1048320 + i32.add + i32.const 16 + i32.shr_u + i32.const 8 + i32.and + local.tee 0 + i32.shl + local.tee 1 + local.get 1 + i32.const 520192 + i32.add + i32.const 16 + i32.shr_u + i32.const 4 + i32.and + local.tee 1 + i32.shl + local.tee 2 + local.get 2 + i32.const 245760 + i32.add + i32.const 16 + i32.shr_u + i32.const 2 + i32.and + local.tee 2 + i32.shl + i32.const 15 + i32.shr_u + local.get 2 + local.get 0 + local.get 1 + i32.or + i32.or + i32.sub + local.tee 0 + i32.const 1 + i32.shl + local.set 1 + local.get 1 + local.get 5 + local.get 0 + i32.const 21 + i32.add + i32.shr_u + i32.const 1 + i32.and + i32.or + i32.const 28 + i32.add + local.set 7 + end + i32.const 0 + local.get 5 + i32.sub + local.set 2 + block ;; label = @14 + block ;; label = @15 + block ;; label = @16 + local.get 7 + i32.const 2 + i32.shl + i32.const 3436 + i32.add + i32.load + local.tee 1 + i32.eqz + if ;; label = @17 + i32.const 0 + local.set 0 + br 1 (;@16;) + end + i32.const 0 + local.set 0 + local.get 5 + i32.const 0 + i32.const 25 + local.get 7 + i32.const 1 + i32.shr_u + i32.sub + local.get 7 + i32.const 31 + i32.eq + select + i32.shl + local.set 3 + loop ;; label = @17 + block ;; label = @18 + local.get 1 + i32.load offset=4 + i32.const -8 + i32.and + local.get 5 + i32.sub + local.tee 6 + local.get 2 + i32.ge_u + br_if 0 (;@18;) + local.get 1 + local.set 4 + local.get 6 + local.tee 2 + br_if 0 (;@18;) + i32.const 0 + local.set 2 + local.get 1 + local.set 0 + br 3 (;@15;) + end + local.get 0 + local.get 1 + i32.load offset=20 + local.tee 6 + local.get 6 + local.get 3 + i32.const 29 + i32.shr_u + i32.const 4 + i32.and + local.get 1 + i32.add + i32.load offset=16 + local.tee 1 + i32.eq + select + local.get 0 + local.get 6 + select + local.set 0 + local.get 3 + i32.const 1 + i32.shl + local.set 3 + local.get 1 + br_if 0 (;@17;) + end + end + local.get 0 + local.get 4 + i32.or + i32.eqz + if ;; label = @16 + i32.const 0 + i32.const 2 + local.get 7 + i32.shl + local.tee 0 + i32.sub + local.set 1 + local.get 8 + local.get 0 + local.get 1 + i32.or + i32.and + local.tee 0 + i32.eqz + br_if 3 (;@13;) + i32.const 0 + local.get 0 + i32.sub + local.get 0 + i32.and + i32.const 1 + i32.sub + local.tee 0 + local.get 0 + i32.const 12 + i32.shr_u + i32.const 16 + i32.and + local.tee 0 + i32.shr_u + local.tee 1 + i32.const 5 + i32.shr_u + i32.const 8 + i32.and + local.set 3 + local.get 0 + local.get 3 + i32.or + local.set 7 + local.get 7 + local.get 1 + local.get 3 + i32.shr_u + local.tee 0 + i32.const 2 + i32.shr_u + i32.const 4 + i32.and + local.tee 1 + i32.or + local.set 3 + local.get 3 + local.get 0 + local.get 1 + i32.shr_u + local.tee 0 + i32.const 1 + i32.shr_u + i32.const 2 + i32.and + local.tee 1 + i32.or + local.set 3 + local.get 3 + local.get 0 + local.get 1 + i32.shr_u + local.tee 0 + i32.const 1 + i32.shr_u + i32.const 1 + i32.and + local.tee 1 + i32.or + local.set 3 + local.get 3 + local.get 0 + local.get 1 + i32.shr_u + i32.add + i32.const 2 + i32.shl + i32.const 3436 + i32.add + i32.load + local.set 0 + end + local.get 0 + i32.eqz + br_if 1 (;@14;) + end + loop ;; label = @15 + local.get 0 + i32.load offset=4 + i32.const -8 + i32.and + local.get 5 + i32.sub + local.tee 7 + local.get 2 + i32.lt_u + local.set 3 + local.get 7 + local.get 2 + local.get 3 + select + local.set 2 + local.get 0 + local.get 4 + local.get 3 + select + local.set 4 + local.get 0 + i32.load offset=16 + local.tee 1 + if (result i32) ;; label = @16 + local.get 1 + else + local.get 0 + i32.load offset=20 + end + local.tee 0 + br_if 0 (;@15;) + end + end + local.get 4 + i32.eqz + br_if 0 (;@13;) + local.get 2 + i32.const 3140 + i32.load + local.get 5 + i32.sub + i32.ge_u + br_if 0 (;@13;) + local.get 4 + local.get 5 + i32.add + local.tee 6 + local.get 4 + i32.le_u + br_if 1 (;@12;) + local.get 4 + i32.load offset=24 + local.set 9 + local.get 4 + local.get 4 + i32.load offset=12 + local.tee 3 + i32.ne + if ;; label = @14 + local.get 4 + i32.load offset=8 + local.tee 0 + i32.const 3148 + i32.load + i32.lt_u + drop + local.get 0 + local.get 3 + i32.store offset=12 + local.get 3 + local.get 0 + i32.store offset=8 + br 11 (;@3;) + end + local.get 4 + i32.const 20 + i32.add + local.tee 1 + i32.load + local.tee 0 + i32.eqz + if ;; label = @14 + local.get 4 + i32.load offset=16 + local.tee 0 + i32.eqz + br_if 4 (;@10;) + local.get 4 + i32.const 16 + i32.add + local.set 1 + end + loop ;; label = @14 + local.get 1 + local.set 7 + local.get 0 + local.set 3 + local.get 0 + i32.const 20 + i32.add + local.tee 1 + i32.load + local.tee 0 + br_if 0 (;@14;) + local.get 3 + i32.const 16 + i32.add + local.set 1 + local.get 3 + i32.load offset=16 + local.tee 0 + br_if 0 (;@14;) + end + local.get 7 + i32.const 0 + i32.store + br 10 (;@3;) + end + local.get 5 + i32.const 3140 + i32.load + local.tee 1 + i32.le_u + if ;; label = @13 + i32.const 3152 + i32.load + local.set 0 + block ;; label = @14 + local.get 1 + local.get 5 + i32.sub + local.tee 2 + i32.const 16 + i32.ge_u + if ;; label = @15 + i32.const 3140 + local.get 2 + i32.store + i32.const 3152 + local.get 0 + local.get 5 + i32.add + local.tee 4 + i32.store + local.get 4 + local.get 2 + i32.const 1 + i32.or + i32.store offset=4 + local.get 0 + local.get 1 + i32.add + local.get 2 + i32.store + local.get 0 + local.get 5 + i32.const 3 + i32.or + i32.store offset=4 + br 1 (;@14;) + end + i32.const 3152 + i32.const 0 + i32.store + i32.const 3140 + i32.const 0 + i32.store + local.get 0 + local.get 1 + i32.const 3 + i32.or + i32.store offset=4 + local.get 0 + local.get 1 + i32.add + local.tee 1 + i32.load offset=4 + i32.const 1 + i32.or + local.set 2 + local.get 1 + local.get 2 + i32.store offset=4 + end + local.get 0 + i32.const 8 + i32.add + local.set 0 + br 12 (;@1;) + end + local.get 5 + i32.const 3144 + i32.load + local.tee 3 + i32.lt_u + if ;; label = @13 + i32.const 3144 + local.get 3 + local.get 5 + i32.sub + local.tee 1 + i32.store + i32.const 3156 + local.get 5 + i32.const 3156 + i32.load + local.tee 0 + i32.add + local.tee 2 + i32.store + local.get 2 + local.get 1 + i32.const 1 + i32.or + i32.store offset=4 + local.get 0 + local.get 5 + i32.const 3 + i32.or + i32.store offset=4 + local.get 0 + i32.const 8 + i32.add + local.set 0 + br 12 (;@1;) + end + i32.const 0 + local.set 0 + local.get 5 + local.get 5 + i32.const 47 + i32.add + local.tee 8 + block (result i32) ;; label = @13 + i32.const 3604 + i32.load + if ;; label = @14 + i32.const 3612 + i32.load + br 1 (;@13;) + end + i32.const 3616 + i64.const -1 + i64.store align=4 + i32.const 3608 + i64.const 17592186048512 + i64.store align=4 + i32.const 3604 + local.get 12 + i32.const 12 + i32.add + i32.const -16 + i32.and + i32.const 1431655768 + i32.xor + i32.store + i32.const 3624 + i32.const 0 + i32.store + i32.const 3576 + i32.const 0 + i32.store + i32.const 4096 + end + local.tee 2 + i32.add + local.tee 7 + i32.const 0 + local.get 2 + i32.sub + local.tee 9 + i32.and + local.tee 4 + i32.ge_u + br_if 11 (;@1;) + i32.const 3572 + i32.load + local.tee 1 + if ;; label = @13 + local.get 4 + i32.const 3564 + i32.load + local.tee 2 + i32.add + local.set 6 + local.get 2 + local.get 6 + i32.ge_u + br_if 12 (;@1;) + local.get 1 + local.get 6 + i32.lt_u + br_if 12 (;@1;) + end + i32.const 3576 + i32.load8_u + i32.const 4 + i32.and + br_if 6 (;@6;) + block ;; label = @13 + i32.const 3156 + i32.load + local.tee 2 + if ;; label = @14 + local.get 5 + i32.const 48 + i32.add + local.set 10 + i32.const 3580 + local.set 0 + loop ;; label = @15 + local.get 2 + local.get 0 + i32.load + local.tee 1 + i32.ge_u + if ;; label = @16 + local.get 0 + i32.load offset=4 + local.tee 6 + local.get 1 + i32.add + local.get 2 + i32.gt_u + br_if 3 (;@13;) + end + local.get 0 + i32.load offset=8 + local.tee 0 + br_if 0 (;@15;) + end + end + block ;; label = @14 + memory.size + i32.const 16 + i32.shl + i32.const 2940 + i32.load + local.tee 2 + i32.ge_u + br_if 0 (;@14;) + local.get 2 + call 0 + br_if 0 (;@14;) + i32.const 2992 + i32.const 48 + i32.store + br 7 (;@7;) + end + i32.const 2940 + local.get 2 + i32.store + local.get 2 + i32.const -1 + i32.eq + br_if 6 (;@7;) + local.get 4 + local.set 7 + local.get 2 + i32.const 3608 + i32.load + local.tee 0 + i32.const 1 + i32.sub + local.tee 1 + i32.and + if ;; label = @14 + local.get 4 + local.get 2 + i32.sub + local.get 1 + local.get 2 + i32.add + i32.const 0 + local.get 0 + i32.sub + i32.and + i32.add + local.set 7 + end + local.get 5 + local.get 7 + i32.ge_u + br_if 6 (;@7;) + local.get 7 + i32.const 2147483646 + i32.gt_u + br_if 6 (;@7;) + i32.const 3572 + i32.load + local.tee 0 + if ;; label = @14 + local.get 7 + i32.const 3564 + i32.load + local.tee 1 + i32.add + local.set 3 + local.get 1 + local.get 3 + i32.ge_u + br_if 7 (;@7;) + local.get 0 + local.get 3 + i32.lt_u + br_if 7 (;@7;) + end + local.get 2 + local.get 7 + i32.const 3 + i32.add + i32.const -4 + i32.and + local.tee 1 + i32.add + local.set 0 + block ;; label = @14 + local.get 1 + i32.const 1 + i32.ge_s + i32.const 0 + local.get 0 + local.get 2 + i32.le_u + select + br_if 0 (;@14;) + memory.size + i32.const 16 + i32.shl + local.get 0 + i32.lt_u + if ;; label = @15 + local.get 0 + call 0 + i32.eqz + br_if 1 (;@14;) + end + i32.const 2940 + local.get 0 + i32.store + br 9 (;@5;) + end + i32.const 2992 + i32.const 48 + i32.store + local.get 2 + i32.const -1 + i32.ne + br_if 6 (;@7;) + br 8 (;@5;) + end + local.get 9 + local.get 7 + local.get 3 + i32.sub + i32.and + local.tee 7 + i32.const 2147483646 + i32.gt_u + br_if 5 (;@7;) + i32.const 2940 + i32.load + local.tee 2 + local.get 7 + i32.const 3 + i32.add + i32.const -4 + i32.and + local.tee 9 + i32.add + local.set 3 + local.get 9 + i32.const 1 + i32.ge_s + i32.const 0 + local.get 2 + local.get 3 + i32.ge_u + select + br_if 3 (;@9;) + memory.size + i32.const 16 + i32.shl + local.get 3 + i32.lt_u + if ;; label = @13 + local.get 3 + call 0 + i32.eqz + br_if 4 (;@9;) + local.get 0 + i32.load offset=4 + local.set 6 + local.get 0 + i32.load + local.set 1 + end + i32.const 2940 + local.get 3 + i32.store + local.get 2 + local.get 1 + local.get 6 + i32.add + i32.eq + if ;; label = @13 + local.get 2 + i32.const -1 + i32.eq + br_if 6 (;@7;) + br 8 (;@5;) + end + block ;; label = @13 + local.get 7 + local.get 10 + i32.ge_u + br_if 0 (;@13;) + local.get 2 + i32.const -1 + i32.eq + br_if 0 (;@13;) + i32.const 3612 + i32.load + local.tee 0 + local.get 8 + local.get 7 + i32.sub + i32.add + local.set 1 + local.get 1 + i32.const 0 + local.get 0 + i32.sub + i32.and + local.tee 3 + i32.const 2147483646 + i32.gt_u + br_if 8 (;@5;) + i32.const 2940 + i32.load + local.tee 1 + local.get 3 + i32.const 3 + i32.add + i32.const -4 + i32.and + local.tee 6 + i32.add + local.set 0 + block ;; label = @14 + block (result i32) ;; label = @15 + block ;; label = @16 + local.get 6 + i32.const 1 + i32.lt_s + br_if 0 (;@16;) + local.get 0 + local.get 1 + i32.gt_u + br_if 0 (;@16;) + local.get 1 + br 1 (;@15;) + end + memory.size + i32.const 16 + i32.shl + local.get 0 + i32.ge_u + br_if 1 (;@14;) + local.get 0 + call 0 + br_if 1 (;@14;) + i32.const 2940 + i32.load + end + local.set 0 + i32.const 2992 + i32.const 48 + i32.store + br 6 (;@8;) + end + i32.const 2940 + local.get 0 + i32.store + local.get 1 + i32.const -1 + i32.eq + br_if 5 (;@8;) + local.get 3 + local.get 7 + i32.add + local.set 7 + br 8 (;@5;) + end + local.get 2 + i32.const -1 + i32.ne + br_if 7 (;@5;) + br 5 (;@7;) + end + unreachable + end + i32.const 0 + local.set 4 + br 8 (;@2;) + end + i32.const 0 + local.set 3 + br 6 (;@3;) + end + i32.const 2992 + i32.const 48 + i32.store + br 1 (;@7;) + end + i32.const 3 + local.get 7 + i32.sub + i32.const -4 + i32.and + local.tee 2 + local.get 0 + i32.add + local.set 1 + block ;; label = @8 + local.get 2 + i32.const 1 + i32.ge_s + i32.const 0 + local.get 0 + local.get 1 + i32.ge_u + select + br_if 0 (;@8;) + local.get 1 + memory.size + i32.const 16 + i32.shl + i32.gt_u + if ;; label = @9 + local.get 1 + call 0 + i32.eqz + br_if 1 (;@8;) + end + i32.const 2940 + local.get 1 + i32.store + br 1 (;@7;) + end + i32.const 2992 + i32.const 48 + i32.store + end + i32.const 3576 + i32.const 3576 + i32.load + i32.const 4 + i32.or + i32.store + end + local.get 4 + i32.const 2147483646 + i32.gt_u + br_if 1 (;@4;) + local.get 4 + i32.const 3 + i32.add + i32.const -4 + i32.and + local.tee 1 + i32.const 2940 + i32.load + local.tee 2 + i32.add + local.set 0 + block ;; label = @6 + block ;; label = @7 + block (result i32) ;; label = @8 + block ;; label = @9 + local.get 1 + i32.const 1 + i32.lt_s + br_if 0 (;@9;) + local.get 0 + local.get 2 + i32.gt_u + br_if 0 (;@9;) + local.get 2 + br 1 (;@8;) + end + memory.size + i32.const 16 + i32.shl + local.get 0 + i32.ge_u + br_if 1 (;@7;) + local.get 0 + call 0 + br_if 1 (;@7;) + i32.const 2940 + i32.load + end + local.set 0 + i32.const 2992 + i32.const 48 + i32.store + i32.const -1 + local.set 2 + br 1 (;@6;) + end + i32.const 2940 + local.get 0 + i32.store + end + memory.size + i32.const 16 + i32.shl + local.get 0 + i32.lt_u + if ;; label = @6 + local.get 0 + call 0 + i32.eqz + br_if 2 (;@4;) + end + i32.const 2940 + local.get 0 + i32.store + local.get 0 + local.get 2 + i32.le_u + br_if 1 (;@4;) + local.get 2 + i32.const -1 + i32.eq + br_if 1 (;@4;) + local.get 0 + i32.const -1 + i32.eq + br_if 1 (;@4;) + local.get 0 + local.get 2 + i32.sub + local.tee 7 + local.get 5 + i32.const 40 + i32.add + i32.le_u + br_if 1 (;@4;) + end + i32.const 3564 + local.get 7 + i32.const 3564 + i32.load + i32.add + local.tee 0 + i32.store + i32.const 3568 + i32.load + local.get 0 + i32.lt_u + if ;; label = @5 + i32.const 3568 + local.get 0 + i32.store + end + block ;; label = @5 + block ;; label = @6 + block ;; label = @7 + i32.const 3156 + i32.load + local.tee 4 + if ;; label = @8 + i32.const 3580 + local.set 0 + loop ;; label = @9 + local.get 0 + i32.load + local.tee 1 + local.get 0 + i32.load offset=4 + local.tee 3 + i32.add + local.get 2 + i32.eq + br_if 2 (;@7;) + local.get 0 + i32.load offset=8 + local.tee 0 + br_if 0 (;@9;) + end + br 2 (;@6;) + end + local.get 2 + i32.const 3148 + i32.load + local.tee 0 + i32.ge_u + local.set 1 + local.get 0 + i32.const 0 + local.get 1 + select + i32.eqz + if ;; label = @8 + i32.const 3148 + local.get 2 + i32.store + end + i32.const 0 + local.set 0 + i32.const 3584 + local.get 7 + i32.store + i32.const 3580 + local.get 2 + i32.store + i32.const 3164 + i32.const -1 + i32.store + i32.const 3168 + i32.const 3604 + i32.load + i32.store + i32.const 3592 + i32.const 0 + i32.store + loop ;; label = @8 + local.get 0 + i32.const 3 + i32.shl + local.tee 1 + i32.const 3180 + i32.add + local.get 1 + i32.const 3172 + i32.add + local.tee 4 + i32.store + local.get 1 + i32.const 3184 + i32.add + local.get 4 + i32.store + local.get 0 + i32.const 1 + i32.add + local.tee 0 + i32.const 32 + i32.ne + br_if 0 (;@8;) + end + i32.const 3144 + local.get 7 + i32.const 40 + i32.sub + local.tee 0 + i32.const -8 + local.get 2 + i32.sub + i32.const 7 + i32.and + i32.const 0 + local.get 2 + i32.const 8 + i32.add + i32.const 7 + i32.and + select + local.tee 1 + i32.sub + local.tee 4 + i32.store + i32.const 3156 + local.get 1 + local.get 2 + i32.add + local.tee 1 + i32.store + local.get 1 + local.get 4 + i32.const 1 + i32.or + i32.store offset=4 + local.get 0 + local.get 2 + i32.add + i32.const 40 + i32.store offset=4 + i32.const 3160 + i32.const 3620 + i32.load + i32.store + br 2 (;@5;) + end + local.get 2 + local.get 4 + i32.le_u + br_if 0 (;@6;) + local.get 1 + local.get 4 + i32.gt_u + br_if 0 (;@6;) + local.get 0 + i32.load offset=12 + i32.const 8 + i32.and + br_if 0 (;@6;) + local.get 0 + local.get 3 + local.get 7 + i32.add + i32.store offset=4 + i32.const 3156 + local.get 4 + i32.const -8 + local.get 4 + i32.sub + i32.const 7 + i32.and + i32.const 0 + local.get 4 + i32.const 8 + i32.add + i32.const 7 + i32.and + select + local.tee 0 + i32.add + local.tee 1 + i32.store + i32.const 3144 + local.get 7 + i32.const 3144 + i32.load + i32.add + local.tee 2 + local.get 0 + i32.sub + local.tee 0 + i32.store + local.get 1 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 2 + local.get 4 + i32.add + i32.const 40 + i32.store offset=4 + i32.const 3160 + i32.const 3620 + i32.load + i32.store + br 1 (;@5;) + end + local.get 2 + i32.const 3148 + i32.load + i32.lt_u + if ;; label = @6 + i32.const 3148 + local.get 2 + i32.store + end + local.get 2 + local.get 7 + i32.add + local.set 1 + i32.const 3580 + local.set 0 + block ;; label = @6 + block ;; label = @7 + block ;; label = @8 + block ;; label = @9 + block ;; label = @10 + block ;; label = @11 + loop ;; label = @12 + local.get 0 + i32.load + local.get 1 + i32.ne + if ;; label = @13 + local.get 0 + i32.load offset=8 + local.tee 0 + br_if 1 (;@12;) + br 2 (;@11;) + end + end + local.get 0 + i32.load8_u offset=12 + i32.const 8 + i32.and + i32.eqz + br_if 1 (;@10;) + end + i32.const 3580 + local.set 0 + loop ;; label = @11 + local.get 4 + local.get 0 + i32.load + local.tee 1 + i32.ge_u + if ;; label = @12 + local.get 4 + local.get 0 + i32.load offset=4 + local.get 1 + i32.add + local.tee 3 + i32.lt_u + br_if 3 (;@9;) + end + local.get 0 + i32.load offset=8 + local.set 0 + br 0 (;@11;) + end + unreachable + end + local.get 0 + local.get 2 + i32.store + local.get 0 + local.get 7 + local.get 0 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 2 + i32.const -8 + local.get 2 + i32.sub + i32.const 7 + i32.and + i32.const 0 + local.get 2 + i32.const 8 + i32.add + i32.const 7 + i32.and + select + i32.add + local.tee 8 + local.get 5 + i32.const 3 + i32.or + i32.store offset=4 + local.get 1 + i32.const -8 + local.get 1 + i32.sub + i32.const 7 + i32.and + i32.const 0 + local.get 1 + i32.const 8 + i32.add + i32.const 7 + i32.and + select + i32.add + local.tee 6 + local.get 8 + i32.sub + local.get 5 + i32.sub + local.set 3 + local.get 5 + local.get 8 + i32.add + local.set 5 + local.get 4 + local.get 6 + i32.eq + if ;; label = @10 + i32.const 3156 + local.get 5 + i32.store + i32.const 3144 + local.get 3 + i32.const 3144 + i32.load + i32.add + local.tee 0 + i32.store + local.get 5 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + br 3 (;@7;) + end + local.get 6 + i32.const 3152 + i32.load + i32.eq + if ;; label = @10 + i32.const 3152 + local.get 5 + i32.store + i32.const 3140 + local.get 3 + i32.const 3140 + i32.load + i32.add + local.tee 0 + i32.store + local.get 5 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 0 + local.get 5 + i32.add + local.get 0 + i32.store + br 3 (;@7;) + end + local.get 6 + i32.load offset=4 + local.tee 0 + i32.const 3 + i32.and + i32.const 1 + i32.eq + if ;; label = @10 + local.get 0 + i32.const -8 + i32.and + local.set 9 + block ;; label = @11 + local.get 0 + i32.const 255 + i32.le_u + if ;; label = @12 + local.get 6 + i32.load offset=8 + local.tee 1 + local.get 0 + i32.const 3 + i32.shr_u + local.tee 2 + i32.const 3 + i32.shl + i32.const 3172 + i32.add + i32.eq + drop + local.get 1 + local.get 6 + i32.load offset=12 + local.tee 0 + i32.eq + if ;; label = @13 + i32.const 3132 + i32.const 3132 + i32.load + i32.const -2 + local.get 2 + i32.rotl + i32.and + i32.store + br 2 (;@11;) + end + local.get 1 + local.get 0 + i32.store offset=12 + local.get 0 + local.get 1 + i32.store offset=8 + br 1 (;@11;) + end + local.get 6 + i32.load offset=24 + local.set 7 + block ;; label = @12 + local.get 6 + local.get 6 + i32.load offset=12 + local.tee 1 + i32.ne + if ;; label = @13 + local.get 6 + i32.load offset=8 + local.tee 0 + local.get 1 + i32.store offset=12 + local.get 1 + local.get 0 + i32.store offset=8 + br 1 (;@12;) + end + block ;; label = @13 + local.get 6 + i32.const 20 + i32.add + local.tee 0 + i32.load + local.tee 2 + br_if 0 (;@13;) + local.get 6 + i32.const 16 + i32.add + local.tee 0 + i32.load + local.tee 2 + br_if 0 (;@13;) + i32.const 0 + local.set 1 + br 1 (;@12;) + end + loop ;; label = @13 + local.get 0 + local.set 4 + local.get 2 + local.tee 1 + i32.const 20 + i32.add + local.tee 0 + i32.load + local.tee 2 + br_if 0 (;@13;) + local.get 1 + i32.const 16 + i32.add + local.set 0 + local.get 1 + i32.load offset=16 + local.tee 2 + br_if 0 (;@13;) + end + local.get 4 + i32.const 0 + i32.store + end + local.get 7 + i32.eqz + br_if 0 (;@11;) + block ;; label = @12 + local.get 6 + local.get 6 + i32.load offset=28 + local.tee 0 + i32.const 2 + i32.shl + i32.const 3436 + i32.add + local.tee 2 + i32.load + i32.eq + if ;; label = @13 + local.get 2 + local.get 1 + i32.store + local.get 1 + br_if 1 (;@12;) + i32.const 3136 + i32.const 3136 + i32.load + i32.const -2 + local.get 0 + i32.rotl + i32.and + i32.store + br 2 (;@11;) + end + local.get 7 + i32.const 16 + i32.const 20 + local.get 6 + local.get 7 + i32.load offset=16 + i32.eq + select + i32.add + local.get 1 + i32.store + local.get 1 + i32.eqz + br_if 1 (;@11;) + end + local.get 1 + local.get 7 + i32.store offset=24 + local.get 6 + i32.load offset=16 + local.tee 0 + if ;; label = @12 + local.get 1 + local.get 0 + i32.store offset=16 + local.get 0 + local.get 1 + i32.store offset=24 + end + local.get 6 + i32.load offset=20 + local.tee 0 + i32.eqz + br_if 0 (;@11;) + local.get 1 + local.get 0 + i32.store offset=20 + local.get 0 + local.get 1 + i32.store offset=24 + end + local.get 6 + local.get 9 + i32.add + local.set 6 + local.get 3 + local.get 9 + i32.add + local.set 3 + end + local.get 6 + local.get 6 + i32.load offset=4 + i32.const -2 + i32.and + i32.store offset=4 + local.get 5 + local.get 3 + i32.const 1 + i32.or + i32.store offset=4 + local.get 3 + local.get 5 + i32.add + local.get 3 + i32.store + local.get 3 + i32.const 255 + i32.le_u + if ;; label = @10 + local.get 3 + i32.const 3 + i32.shr_u + local.tee 1 + i32.const 3 + i32.shl + i32.const 3172 + i32.add + local.set 0 + block (result i32) ;; label = @11 + i32.const 1 + local.get 1 + i32.shl + local.tee 1 + i32.const 3132 + i32.load + local.tee 2 + i32.and + i32.eqz + if ;; label = @12 + i32.const 3132 + local.get 1 + local.get 2 + i32.or + i32.store + local.get 0 + br 1 (;@11;) + end + local.get 0 + i32.load offset=8 + end + local.set 2 + local.get 0 + local.get 5 + i32.store offset=8 + local.get 2 + local.get 5 + i32.store offset=12 + local.get 5 + local.get 0 + i32.store offset=12 + local.get 5 + local.get 2 + i32.store offset=8 + br 3 (;@7;) + end + i32.const 31 + local.set 0 + local.get 3 + i32.const 16777215 + i32.le_u + if ;; label = @10 + local.get 3 + i32.const 8 + i32.shr_u + local.tee 0 + local.get 0 + i32.const 1048320 + i32.add + i32.const 16 + i32.shr_u + i32.const 8 + i32.and + local.tee 0 + i32.shl + local.tee 1 + local.get 1 + i32.const 520192 + i32.add + i32.const 16 + i32.shr_u + i32.const 4 + i32.and + local.tee 1 + i32.shl + local.tee 2 + local.get 2 + i32.const 245760 + i32.add + i32.const 16 + i32.shr_u + i32.const 2 + i32.and + local.tee 2 + i32.shl + i32.const 15 + i32.shr_u + local.get 2 + local.get 0 + local.get 1 + i32.or + i32.or + i32.sub + local.tee 0 + i32.const 1 + i32.shl + local.set 1 + local.get 1 + local.get 3 + local.get 0 + i32.const 21 + i32.add + i32.shr_u + i32.const 1 + i32.and + i32.or + i32.const 28 + i32.add + local.set 0 + end + local.get 5 + local.get 0 + i32.store offset=28 + local.get 5 + i64.const 0 + i64.store offset=16 align=4 + local.get 0 + i32.const 2 + i32.shl + i32.const 3436 + i32.add + local.set 1 + block ;; label = @10 + i32.const 3136 + i32.load + local.tee 2 + i32.const 1 + local.get 0 + i32.shl + local.tee 4 + i32.and + i32.eqz + if ;; label = @11 + i32.const 3136 + local.get 2 + local.get 4 + i32.or + i32.store + local.get 1 + local.get 5 + i32.store + local.get 5 + local.get 1 + i32.store offset=24 + br 1 (;@10;) + end + local.get 3 + i32.const 0 + i32.const 25 + local.get 0 + i32.const 1 + i32.shr_u + i32.sub + local.get 0 + i32.const 31 + i32.eq + select + i32.shl + local.set 0 + local.get 1 + i32.load + local.set 1 + loop ;; label = @11 + local.get 1 + local.set 2 + local.get 3 + local.get 1 + i32.load offset=4 + i32.const -8 + i32.and + i32.eq + br_if 3 (;@8;) + local.get 0 + i32.const 29 + i32.shr_u + local.set 1 + local.get 0 + i32.const 1 + i32.shl + local.set 0 + local.get 2 + local.get 1 + i32.const 4 + i32.and + i32.add + local.tee 4 + i32.const 16 + i32.add + i32.load + local.tee 1 + br_if 0 (;@11;) + end + local.get 4 + local.get 5 + i32.store offset=16 + local.get 5 + local.get 2 + i32.store offset=24 + end + local.get 5 + local.get 5 + i32.store offset=12 + local.get 5 + local.get 5 + i32.store offset=8 + br 2 (;@7;) + end + i32.const 3144 + local.get 7 + i32.const 40 + i32.sub + local.tee 0 + i32.const -8 + local.get 2 + i32.sub + i32.const 7 + i32.and + i32.const 0 + local.get 2 + i32.const 8 + i32.add + i32.const 7 + i32.and + select + local.tee 1 + i32.sub + local.tee 6 + i32.store + i32.const 3156 + local.get 1 + local.get 2 + i32.add + local.tee 1 + i32.store + local.get 1 + local.get 6 + i32.const 1 + i32.or + i32.store offset=4 + local.get 0 + local.get 2 + i32.add + i32.const 40 + i32.store offset=4 + i32.const 3160 + i32.const 3620 + i32.load + i32.store + local.get 4 + local.get 3 + i32.const 39 + local.get 3 + i32.sub + i32.const 7 + i32.and + i32.const 0 + local.get 3 + i32.const 39 + i32.sub + i32.const 7 + i32.and + select + i32.add + i32.const 47 + i32.sub + local.tee 0 + local.get 4 + i32.const 16 + i32.add + local.get 0 + i32.gt_u + select + local.tee 1 + i32.const 27 + i32.store offset=4 + local.get 1 + i32.const 3588 + i64.load align=4 + i64.store offset=16 align=4 + local.get 1 + i32.const 3580 + i64.load align=4 + i64.store offset=8 align=4 + i32.const 3588 + local.get 1 + i32.const 8 + i32.add + i32.store + i32.const 3584 + local.get 7 + i32.store + i32.const 3580 + local.get 2 + i32.store + i32.const 3592 + i32.const 0 + i32.store + local.get 1 + i32.const 24 + i32.add + local.set 0 + loop ;; label = @9 + local.get 0 + i32.const 7 + i32.store offset=4 + local.get 0 + i32.const 8 + i32.add + local.set 2 + local.get 0 + i32.const 4 + i32.add + local.set 0 + local.get 2 + local.get 3 + i32.lt_u + br_if 0 (;@9;) + end + local.get 1 + local.get 4 + i32.eq + br_if 3 (;@5;) + local.get 1 + local.get 1 + i32.load offset=4 + i32.const -2 + i32.and + i32.store offset=4 + local.get 4 + local.get 1 + local.get 4 + i32.sub + local.tee 2 + i32.const 1 + i32.or + i32.store offset=4 + local.get 1 + local.get 2 + i32.store + local.get 2 + i32.const 255 + i32.le_u + if ;; label = @9 + local.get 2 + i32.const 3 + i32.shr_u + local.tee 1 + i32.const 3 + i32.shl + i32.const 3172 + i32.add + local.set 0 + block (result i32) ;; label = @10 + i32.const 1 + local.get 1 + i32.shl + local.tee 1 + i32.const 3132 + i32.load + local.tee 2 + i32.and + i32.eqz + if ;; label = @11 + i32.const 3132 + local.get 1 + local.get 2 + i32.or + i32.store + local.get 0 + br 1 (;@10;) + end + local.get 0 + i32.load offset=8 + end + local.set 2 + local.get 0 + local.get 4 + i32.store offset=8 + local.get 2 + local.get 4 + i32.store offset=12 + local.get 4 + local.get 0 + i32.store offset=12 + local.get 4 + local.get 2 + i32.store offset=8 + br 4 (;@5;) + end + i32.const 31 + local.set 0 + local.get 4 + i64.const 0 + i64.store offset=16 align=4 + local.get 2 + i32.const 16777215 + i32.le_u + if ;; label = @9 + local.get 2 + i32.const 8 + i32.shr_u + local.tee 0 + local.get 0 + i32.const 1048320 + i32.add + i32.const 16 + i32.shr_u + i32.const 8 + i32.and + local.tee 0 + i32.shl + local.tee 1 + local.get 1 + i32.const 520192 + i32.add + i32.const 16 + i32.shr_u + i32.const 4 + i32.and + local.tee 1 + i32.shl + local.tee 3 + local.get 3 + i32.const 245760 + i32.add + i32.const 16 + i32.shr_u + i32.const 2 + i32.and + local.tee 3 + i32.shl + i32.const 15 + i32.shr_u + local.get 3 + local.get 0 + local.get 1 + i32.or + i32.or + i32.sub + local.tee 0 + i32.const 1 + i32.shl + local.set 1 + local.get 1 + local.get 2 + local.get 0 + i32.const 21 + i32.add + i32.shr_u + i32.const 1 + i32.and + i32.or + i32.const 28 + i32.add + local.set 0 + end + local.get 4 + local.get 0 + i32.store offset=28 + local.get 0 + i32.const 2 + i32.shl + i32.const 3436 + i32.add + local.set 1 + block ;; label = @9 + i32.const 3136 + i32.load + local.tee 3 + i32.const 1 + local.get 0 + i32.shl + local.tee 7 + i32.and + i32.eqz + if ;; label = @10 + i32.const 3136 + local.get 3 + local.get 7 + i32.or + i32.store + local.get 1 + local.get 4 + i32.store + br 1 (;@9;) + end + local.get 2 + i32.const 0 + i32.const 25 + local.get 0 + i32.const 1 + i32.shr_u + i32.sub + local.get 0 + i32.const 31 + i32.eq + select + i32.shl + local.set 0 + local.get 1 + i32.load + local.set 3 + loop ;; label = @10 + local.get 3 + local.tee 1 + i32.load offset=4 + i32.const -8 + i32.and + local.get 2 + i32.eq + br_if 4 (;@6;) + local.get 0 + i32.const 29 + i32.shr_u + local.set 3 + local.get 0 + i32.const 1 + i32.shl + local.set 0 + local.get 3 + i32.const 4 + i32.and + local.get 1 + i32.add + local.tee 7 + i32.const 16 + i32.add + i32.load + local.tee 3 + br_if 0 (;@10;) + end + local.get 7 + local.get 4 + i32.store offset=16 + end + local.get 4 + local.get 1 + i32.store offset=24 + local.get 4 + local.get 4 + i32.store offset=12 + local.get 4 + local.get 4 + i32.store offset=8 + br 3 (;@5;) + end + local.get 2 + i32.load offset=8 + local.tee 0 + local.get 5 + i32.store offset=12 + local.get 2 + local.get 5 + i32.store offset=8 + local.get 5 + i32.const 0 + i32.store offset=24 + local.get 5 + local.get 2 + i32.store offset=12 + local.get 5 + local.get 0 + i32.store offset=8 + end + local.get 8 + i32.const 8 + i32.add + local.set 0 + br 5 (;@1;) + end + local.get 1 + i32.load offset=8 + local.tee 0 + local.get 4 + i32.store offset=12 + local.get 1 + local.get 4 + i32.store offset=8 + local.get 4 + i32.const 0 + i32.store offset=24 + local.get 4 + local.get 1 + i32.store offset=12 + local.get 4 + local.get 0 + i32.store offset=8 + end + local.get 5 + i32.const 3144 + i32.load + local.tee 0 + i32.ge_u + br_if 0 (;@4;) + i32.const 3144 + local.get 0 + local.get 5 + i32.sub + local.tee 1 + i32.store + i32.const 3156 + local.get 5 + i32.const 3156 + i32.load + local.tee 0 + i32.add + local.tee 2 + i32.store + local.get 2 + local.get 1 + i32.const 1 + i32.or + i32.store offset=4 + local.get 0 + local.get 5 + i32.const 3 + i32.or + i32.store offset=4 + local.get 0 + i32.const 8 + i32.add + local.set 0 + br 3 (;@1;) + end + i32.const 0 + local.set 0 + i32.const 2992 + i32.const 48 + i32.store + br 2 (;@1;) + end + block ;; label = @3 + local.get 9 + i32.eqz + br_if 0 (;@3;) + block ;; label = @4 + local.get 4 + i32.load offset=28 + local.tee 0 + i32.const 2 + i32.shl + i32.const 3436 + i32.add + local.tee 1 + i32.load + local.get 4 + i32.eq + if ;; label = @5 + local.get 1 + local.get 3 + i32.store + local.get 3 + br_if 1 (;@4;) + i32.const 3136 + local.get 8 + i32.const -2 + local.get 0 + i32.rotl + i32.and + local.tee 8 + i32.store + br 2 (;@3;) + end + local.get 9 + i32.const 16 + i32.const 20 + local.get 4 + local.get 9 + i32.load offset=16 + i32.eq + select + i32.add + local.get 3 + i32.store + local.get 3 + i32.eqz + br_if 1 (;@3;) + end + local.get 3 + local.get 9 + i32.store offset=24 + local.get 4 + i32.load offset=16 + local.tee 0 + if ;; label = @4 + local.get 3 + local.get 0 + i32.store offset=16 + local.get 0 + local.get 3 + i32.store offset=24 + end + local.get 4 + i32.load offset=20 + local.tee 0 + i32.eqz + br_if 0 (;@3;) + local.get 3 + local.get 0 + i32.store offset=20 + local.get 0 + local.get 3 + i32.store offset=24 + end + block ;; label = @3 + local.get 2 + i32.const 15 + i32.le_u + if ;; label = @4 + local.get 4 + local.get 2 + local.get 5 + i32.add + local.tee 0 + i32.const 3 + i32.or + i32.store offset=4 + local.get 0 + local.get 4 + i32.add + local.tee 0 + i32.load offset=4 + i32.const 1 + i32.or + local.set 1 + local.get 0 + local.get 1 + i32.store offset=4 + br 1 (;@3;) + end + local.get 4 + local.get 5 + i32.const 3 + i32.or + i32.store offset=4 + local.get 6 + local.get 2 + i32.const 1 + i32.or + i32.store offset=4 + local.get 2 + local.get 6 + i32.add + local.get 2 + i32.store + local.get 2 + i32.const 255 + i32.le_u + if ;; label = @4 + local.get 2 + i32.const 3 + i32.shr_u + local.tee 1 + i32.const 3 + i32.shl + i32.const 3172 + i32.add + local.set 0 + block (result i32) ;; label = @5 + i32.const 1 + local.get 1 + i32.shl + local.tee 1 + i32.const 3132 + i32.load + local.tee 2 + i32.and + i32.eqz + if ;; label = @6 + i32.const 3132 + local.get 1 + local.get 2 + i32.or + i32.store + local.get 0 + br 1 (;@5;) + end + local.get 0 + i32.load offset=8 + end + local.set 2 + local.get 0 + local.get 6 + i32.store offset=8 + local.get 2 + local.get 6 + i32.store offset=12 + local.get 6 + local.get 0 + i32.store offset=12 + local.get 6 + local.get 2 + i32.store offset=8 + br 1 (;@3;) + end + i32.const 31 + local.set 0 + local.get 2 + i32.const 16777215 + i32.le_u + if ;; label = @4 + local.get 2 + i32.const 8 + i32.shr_u + local.tee 0 + local.get 0 + i32.const 1048320 + i32.add + i32.const 16 + i32.shr_u + i32.const 8 + i32.and + local.tee 0 + i32.shl + local.tee 1 + local.get 1 + i32.const 520192 + i32.add + i32.const 16 + i32.shr_u + i32.const 4 + i32.and + local.tee 1 + i32.shl + local.tee 3 + local.get 3 + i32.const 245760 + i32.add + i32.const 16 + i32.shr_u + i32.const 2 + i32.and + local.tee 3 + i32.shl + i32.const 15 + i32.shr_u + local.get 3 + local.get 0 + local.get 1 + i32.or + i32.or + i32.sub + local.tee 0 + i32.const 1 + i32.shl + local.set 1 + local.get 1 + local.get 2 + local.get 0 + i32.const 21 + i32.add + i32.shr_u + i32.const 1 + i32.and + i32.or + i32.const 28 + i32.add + local.set 0 + end + local.get 6 + local.get 0 + i32.store offset=28 + local.get 6 + i64.const 0 + i64.store offset=16 align=4 + local.get 0 + i32.const 2 + i32.shl + i32.const 3436 + i32.add + local.set 1 + block ;; label = @4 + block ;; label = @5 + local.get 8 + i32.const 1 + local.get 0 + i32.shl + local.tee 3 + i32.and + i32.eqz + if ;; label = @6 + i32.const 3136 + local.get 3 + local.get 8 + i32.or + i32.store + local.get 1 + local.get 6 + i32.store + br 1 (;@5;) + end + local.get 2 + i32.const 0 + i32.const 25 + local.get 0 + i32.const 1 + i32.shr_u + i32.sub + local.get 0 + i32.const 31 + i32.eq + select + i32.shl + local.set 0 + local.get 1 + i32.load + local.set 5 + loop ;; label = @6 + local.get 5 + local.tee 1 + i32.load offset=4 + i32.const -8 + i32.and + local.get 2 + i32.eq + br_if 2 (;@4;) + local.get 0 + i32.const 29 + i32.shr_u + local.set 3 + local.get 0 + i32.const 1 + i32.shl + local.set 0 + local.get 3 + i32.const 4 + i32.and + local.get 1 + i32.add + local.tee 3 + i32.const 16 + i32.add + i32.load + local.tee 5 + br_if 0 (;@6;) + end + local.get 3 + local.get 6 + i32.store offset=16 + end + local.get 6 + local.get 1 + i32.store offset=24 + local.get 6 + local.get 6 + i32.store offset=12 + local.get 6 + local.get 6 + i32.store offset=8 + br 1 (;@3;) + end + local.get 1 + i32.load offset=8 + local.tee 0 + local.get 6 + i32.store offset=12 + local.get 1 + local.get 6 + i32.store offset=8 + local.get 6 + i32.const 0 + i32.store offset=24 + local.get 6 + local.get 1 + i32.store offset=12 + local.get 6 + local.get 0 + i32.store offset=8 + end + local.get 4 + i32.const 8 + i32.add + local.set 0 + br 1 (;@1;) + end + block ;; label = @2 + local.get 9 + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + local.get 3 + i32.load offset=28 + local.tee 0 + i32.const 2 + i32.shl + i32.const 3436 + i32.add + local.tee 1 + i32.load + local.get 3 + i32.eq + if ;; label = @4 + local.get 1 + local.get 4 + i32.store + local.get 4 + br_if 1 (;@3;) + i32.const 3136 + local.get 10 + i32.const -2 + local.get 0 + i32.rotl + i32.and + i32.store + br 2 (;@2;) + end + local.get 9 + i32.const 16 + i32.const 20 + local.get 3 + local.get 9 + i32.load offset=16 + i32.eq + select + i32.add + local.get 4 + i32.store + local.get 4 + i32.eqz + br_if 1 (;@2;) + end + local.get 4 + local.get 9 + i32.store offset=24 + local.get 3 + i32.load offset=16 + local.tee 0 + if ;; label = @3 + local.get 4 + local.get 0 + i32.store offset=16 + local.get 0 + local.get 4 + i32.store offset=24 + end + local.get 3 + i32.load offset=20 + local.tee 0 + i32.eqz + br_if 0 (;@2;) + local.get 4 + local.get 0 + i32.store offset=20 + local.get 0 + local.get 4 + i32.store offset=24 + end + block ;; label = @2 + local.get 2 + i32.const 15 + i32.le_u + if ;; label = @3 + local.get 3 + local.get 2 + local.get 5 + i32.add + local.tee 0 + i32.const 3 + i32.or + i32.store offset=4 + local.get 0 + local.get 3 + i32.add + local.tee 0 + i32.load offset=4 + i32.const 1 + i32.or + local.set 1 + local.get 0 + local.get 1 + i32.store offset=4 + br 1 (;@2;) + end + local.get 3 + local.get 5 + i32.const 3 + i32.or + i32.store offset=4 + local.get 11 + local.get 2 + i32.const 1 + i32.or + i32.store offset=4 + local.get 2 + local.get 11 + i32.add + local.get 2 + i32.store + local.get 8 + if ;; label = @3 + local.get 8 + i32.const 3 + i32.shr_u + local.tee 4 + i32.const 3 + i32.shl + i32.const 3172 + i32.add + local.set 0 + i32.const 3152 + i32.load + local.set 1 + block (result i32) ;; label = @4 + local.get 6 + i32.const 1 + local.get 4 + i32.shl + local.tee 4 + i32.and + i32.eqz + if ;; label = @5 + i32.const 3132 + local.get 4 + local.get 6 + i32.or + i32.store + local.get 0 + br 1 (;@4;) + end + local.get 0 + i32.load offset=8 + end + local.set 5 + local.get 0 + local.get 1 + i32.store offset=8 + local.get 5 + local.get 1 + i32.store offset=12 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + local.get 5 + i32.store offset=8 + end + i32.const 3152 + local.get 11 + i32.store + i32.const 3140 + local.get 2 + i32.store + end + local.get 3 + i32.const 8 + i32.add + local.set 0 + end + local.get 12 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func (;26;) (type 0) (param i32 i32 i32) (result i32) + (local i32 i32 i32) + local.get 2 + i32.const 512 + i32.ge_u + if ;; label = @1 + local.get 0 + local.get 1 + local.get 2 + call 13 + drop + local.get 0 + return + end + local.get 0 + local.get 2 + i32.add + local.set 3 + block ;; label = @1 + local.get 0 + local.get 1 + i32.xor + i32.const 3 + i32.and + i32.eqz + if ;; label = @2 + block ;; label = @3 + local.get 2 + i32.const 1 + i32.lt_s + if ;; label = @4 + local.get 0 + local.set 2 + br 1 (;@3;) + end + local.get 0 + i32.const 3 + i32.and + i32.eqz + if ;; label = @4 + local.get 0 + local.set 2 + br 1 (;@3;) + end + local.get 0 + local.set 2 + loop ;; label = @4 + local.get 2 + local.get 1 + i32.load8_u + i32.store8 + local.get 1 + i32.const 1 + i32.add + local.set 1 + local.get 3 + local.get 2 + i32.const 1 + i32.add + local.tee 2 + i32.le_u + br_if 1 (;@3;) + local.get 2 + i32.const 3 + i32.and + br_if 0 (;@4;) + end + end + block ;; label = @3 + local.get 3 + i32.const -4 + i32.and + local.tee 4 + i32.const 64 + i32.lt_u + br_if 0 (;@3;) + local.get 4 + i32.const -64 + i32.add + local.tee 5 + local.get 2 + i32.lt_u + br_if 0 (;@3;) + loop ;; label = @4 + local.get 2 + local.get 1 + i32.load + i32.store + local.get 2 + local.get 1 + i32.load offset=4 + i32.store offset=4 + local.get 2 + local.get 1 + i32.load offset=8 + i32.store offset=8 + local.get 2 + local.get 1 + i32.load offset=12 + i32.store offset=12 + local.get 2 + local.get 1 + i32.load offset=16 + i32.store offset=16 + local.get 2 + local.get 1 + i32.load offset=20 + i32.store offset=20 + local.get 2 + local.get 1 + i32.load offset=24 + i32.store offset=24 + local.get 2 + local.get 1 + i32.load offset=28 + i32.store offset=28 + local.get 2 + local.get 1 + i32.load offset=32 + i32.store offset=32 + local.get 2 + local.get 1 + i32.load offset=36 + i32.store offset=36 + local.get 2 + local.get 1 + i32.load offset=40 + i32.store offset=40 + local.get 2 + local.get 1 + i32.load offset=44 + i32.store offset=44 + local.get 2 + local.get 1 + i32.load offset=48 + i32.store offset=48 + local.get 2 + local.get 1 + i32.load offset=52 + i32.store offset=52 + local.get 2 + local.get 1 + i32.load offset=56 + i32.store offset=56 + local.get 2 + local.get 1 + i32.load offset=60 + i32.store offset=60 + local.get 1 + i32.const -64 + i32.sub + local.set 1 + local.get 5 + local.get 2 + i32.const -64 + i32.sub + local.tee 2 + i32.ge_u + br_if 0 (;@4;) + end + end + local.get 2 + local.get 4 + i32.ge_u + br_if 1 (;@1;) + loop ;; label = @3 + local.get 2 + local.get 1 + i32.load + i32.store + local.get 1 + i32.const 4 + i32.add + local.set 1 + local.get 4 + local.get 2 + i32.const 4 + i32.add + local.tee 2 + i32.gt_u + br_if 0 (;@3;) + end + br 1 (;@1;) + end + local.get 3 + i32.const 4 + i32.lt_u + if ;; label = @2 + local.get 0 + local.set 2 + br 1 (;@1;) + end + local.get 3 + i32.const 4 + i32.sub + local.tee 4 + local.get 0 + i32.lt_u + if ;; label = @2 + local.get 0 + local.set 2 + br 1 (;@1;) + end + local.get 0 + local.set 2 + loop ;; label = @2 + local.get 2 + local.get 1 + i32.load8_u + i32.store8 + local.get 2 + local.get 1 + i32.load8_u offset=1 + i32.store8 offset=1 + local.get 2 + local.get 1 + i32.load8_u offset=2 + i32.store8 offset=2 + local.get 2 + local.get 1 + i32.load8_u offset=3 + i32.store8 offset=3 + local.get 1 + i32.const 4 + i32.add + local.set 1 + local.get 4 + local.get 2 + i32.const 4 + i32.add + local.tee 2 + i32.ge_u + br_if 0 (;@2;) + end + end + local.get 2 + local.get 3 + i32.lt_u + if ;; label = @1 + loop ;; label = @2 + local.get 2 + local.get 1 + i32.load8_u + i32.store8 + local.get 1 + i32.const 1 + i32.add + local.set 1 + local.get 3 + local.get 2 + i32.const 1 + i32.add + local.tee 2 + i32.ne + br_if 0 (;@2;) + end + end + local.get 0) + (func (;27;) (type 1) (param i32) (result i32) + (local i32) + local.get 0 + if ;; label = @1 + local.get 0 + i32.load offset=76 + i32.const -1 + i32.le_s + if ;; label = @2 + local.get 0 + call 39 + return + end + local.get 0 + call 39 + return + end + i32.const 2996 + i32.load + if ;; label = @1 + i32.const 2996 + i32.load + call 27 + local.set 1 + end + i32.const 3000 + i32.load + local.tee 0 + if ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.load offset=76 + drop + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=28 + i32.gt_u + if ;; label = @3 + local.get 0 + call 39 + local.get 1 + i32.or + local.set 1 + end + local.get 0 + i32.load offset=56 + local.tee 0 + br_if 0 (;@2;) + end + end + local.get 1) + (func (;28;) (type 19) (param i64 i32) (result i32) + (local i32 i32 i32 i64) + block ;; label = @1 + local.get 0 + i64.const 4294967296 + i64.lt_u + if ;; label = @2 + local.get 0 + local.set 5 + br 1 (;@1;) + end + loop ;; label = @2 + local.get 1 + i32.const 1 + i32.sub + local.tee 1 + local.get 0 + i64.const 10 + i64.div_u + local.tee 5 + i64.const -10 + i64.mul + local.get 0 + i64.add + i32.wrap_i64 + i32.const 48 + i32.or + i32.store8 + local.get 0 + i64.const 42949672959 + i64.gt_u + local.set 2 + local.get 5 + local.set 0 + local.get 2 + br_if 0 (;@2;) + end + end + local.get 5 + i32.wrap_i64 + local.tee 2 + if ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.const 1 + i32.sub + local.tee 1 + local.get 2 + i32.const 10 + i32.div_u + local.tee 3 + i32.const -10 + i32.mul + local.get 2 + i32.add + i32.const 48 + i32.or + i32.store8 + local.get 2 + i32.const 9 + i32.gt_u + local.set 4 + local.get 3 + local.set 2 + local.get 4 + br_if 0 (;@2;) + end + end + local.get 1) + (func (;29;) (type 3) (param i32) + nop) + (func (;30;) (type 2) (param i32 i32) (result i32) + local.get 0 + local.get 1 + call 140 + local.tee 0 + i32.const 0 + local.get 0 + i32.load8_u + local.get 1 + i32.const 255 + i32.and + i32.eq + select) + (func (;31;) (type 0) (param i32 i32 i32) (result i32) + (local i32 i32 i64) + block ;; label = @1 + local.get 2 + i32.eqz + br_if 0 (;@1;) + local.get 0 + local.get 2 + i32.add + local.tee 3 + i32.const 1 + i32.sub + local.get 1 + i32.store8 + local.get 0 + local.get 1 + i32.store8 + local.get 2 + i32.const 3 + i32.lt_u + br_if 0 (;@1;) + local.get 3 + i32.const 2 + i32.sub + local.get 1 + i32.store8 + local.get 0 + local.get 1 + i32.store8 offset=1 + local.get 3 + i32.const 3 + i32.sub + local.get 1 + i32.store8 + local.get 0 + local.get 1 + i32.store8 offset=2 + local.get 2 + i32.const 7 + i32.lt_u + br_if 0 (;@1;) + local.get 3 + i32.const 4 + i32.sub + local.get 1 + i32.store8 + local.get 0 + local.get 1 + i32.store8 offset=3 + local.get 2 + i32.const 9 + i32.lt_u + br_if 0 (;@1;) + i32.const 0 + local.get 0 + i32.sub + i32.const 3 + i32.and + local.tee 4 + local.get 0 + i32.add + local.tee 3 + local.get 1 + i32.const 255 + i32.and + i32.const 16843009 + i32.mul + local.tee 1 + i32.store + local.get 3 + local.get 2 + local.get 4 + i32.sub + i32.const -4 + i32.and + local.tee 4 + i32.add + local.tee 2 + i32.const 4 + i32.sub + local.get 1 + i32.store + local.get 4 + i32.const 9 + i32.lt_u + br_if 0 (;@1;) + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 1 + i32.store offset=4 + local.get 2 + i32.const 8 + i32.sub + local.get 1 + i32.store + local.get 2 + i32.const 12 + i32.sub + local.get 1 + i32.store + local.get 4 + i32.const 25 + i32.lt_u + br_if 0 (;@1;) + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 1 + i32.store offset=20 + local.get 3 + local.get 1 + i32.store offset=16 + local.get 3 + local.get 1 + i32.store offset=12 + local.get 2 + i32.const 16 + i32.sub + local.get 1 + i32.store + local.get 2 + i32.const 20 + i32.sub + local.get 1 + i32.store + local.get 2 + i32.const 24 + i32.sub + local.get 1 + i32.store + local.get 2 + i32.const 28 + i32.sub + local.get 1 + i32.store + local.get 4 + local.get 3 + i32.const 4 + i32.and + i32.const 24 + i32.or + local.tee 4 + i32.sub + local.tee 2 + i32.const 32 + i32.lt_u + br_if 0 (;@1;) + local.get 1 + i64.extend_i32_u + i64.const 4294967297 + i64.mul + local.set 5 + local.get 3 + local.get 4 + i32.add + local.set 1 + loop ;; label = @2 + local.get 1 + local.get 5 + i64.store offset=24 + local.get 1 + local.get 5 + i64.store offset=16 + local.get 1 + local.get 5 + i64.store offset=8 + local.get 1 + local.get 5 + i64.store + local.get 1 + i32.const 32 + i32.add + local.set 1 + local.get 2 + i32.const 32 + i32.sub + local.tee 2 + i32.const 31 + i32.gt_u + br_if 0 (;@2;) + end + end + local.get 0) + (func (;32;) (type 1) (param i32) (result i32) + (local i32 i32 i32) + block ;; label = @1 + block ;; label = @2 + local.get 0 + local.tee 1 + i32.const 3 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 0 + i32.load8_u + i32.eqz + if ;; label = @3 + i32.const 0 + return + end + loop ;; label = @3 + local.get 1 + i32.const 1 + i32.add + local.tee 1 + i32.const 3 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 1 + i32.load8_u + br_if 0 (;@3;) + end + br 1 (;@1;) + end + loop ;; label = @2 + local.get 1 + local.tee 2 + i32.const 4 + i32.add + local.set 1 + local.get 2 + i32.load + local.tee 3 + i32.const -1 + i32.xor + local.get 3 + i32.const 16843009 + i32.sub + i32.and + i32.const -2139062144 + i32.and + i32.eqz + br_if 0 (;@2;) + end + local.get 3 + i32.const 255 + i32.and + i32.eqz + if ;; label = @2 + local.get 2 + local.get 0 + i32.sub + return + end + loop ;; label = @2 + local.get 2 + i32.load8_u offset=1 + local.set 3 + local.get 2 + i32.const 1 + i32.add + local.tee 1 + local.set 2 + local.get 3 + br_if 0 (;@2;) + end + end + local.get 1 + local.get 0 + i32.sub) + (func (;33;) (type 1) (param i32) (result i32) + local.get 0 + i32.const 1 + local.get 0 + select + call 25 + local.tee 0 + i32.eqz + if ;; label = @1 + call 6 + unreachable + end + local.get 0) + (func (;34;) (type 0) (param i32 i32 i32) (result i32) + (local i64) + local.get 1 + i64.extend_i32_s + local.set 3 + block (result i32) ;; label = @1 + local.get 0 + i32.load offset=76 + i32.const -1 + i32.le_s + if ;; label = @2 + local.get 0 + local.get 3 + local.get 2 + call 49 + br 1 (;@1;) + end + local.get 0 + local.get 3 + local.get 2 + call 49 + end) + (func (;35;) (type 14) (param i32 i32 i32 i32 i32) (result i32) + (local i32 i32 i32 i32 i32 i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 5 + global.set 0 + i32.const 1509 + local.set 6 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + block ;; label = @6 + block ;; label = @7 + block ;; label = @8 + block ;; label = @9 + block ;; label = @10 + block (result i32) ;; label = @11 + block ;; label = @12 + block ;; label = @13 + block ;; label = @14 + local.get 1 + i32.const 1 + i32.sub + br_table 0 (;@14;) 1 (;@13;) 4 (;@10;) 5 (;@9;) 6 (;@8;) 2 (;@12;) 12 (;@2;) 8 (;@6;) 12 (;@2;) 7 (;@7;) 12 (;@2;) + end + local.get 4 + i32.load8_s offset=11 + i32.const -1 + i32.le_s + if ;; label = @14 + local.get 4 + i32.load + call 21 + end + i32.const 8 + local.set 7 + local.get 4 + i32.const 8 + i32.store8 offset=11 + local.get 4 + i32.const 0 + i32.store8 offset=8 + local.get 4 + i64.const 7234302044551733584 + i64.store align=4 + i32.const 0 + local.set 8 + i32.const 1684367201 + br 2 (;@11;) + end + i32.const 16 + call 33 + local.tee 1 + i32.const 1500 + i64.load align=1 + i64.store offset=7 align=1 + local.get 1 + i32.const 1493 + i64.load align=1 + i64.store align=1 + local.get 1 + i32.const 0 + i32.store8 offset=15 + local.get 4 + i32.load8_s offset=11 + i32.const -1 + i32.le_s + if ;; label = @13 + local.get 4 + i32.load + call 21 + end + local.get 4 + i64.const -9223371968135299057 + i64.store offset=4 align=4 + local.get 4 + local.get 1 + i32.store + i32.const 128 + local.set 7 + i32.const 1 + local.set 8 + i32.const 15 + br 1 (;@11;) + end + local.get 4 + i32.load8_s offset=11 + i32.const -1 + i32.le_s + if ;; label = @12 + local.get 4 + i32.load + call 21 + end + i32.const 9 + local.set 7 + local.get 4 + i32.const 9 + i32.store8 offset=11 + local.get 4 + i32.const 0 + i32.store8 offset=9 + local.get 4 + i64.const 8315161630257148773 + i64.store offset=1 align=1 + local.get 4 + i32.const 82 + i32.store8 + i32.const 0 + local.set 8 + i32.const 1701016181 + end + local.set 6 + local.get 5 + i32.const 0 + i32.store offset=8 + local.get 5 + i64.const 0 + i64.store + local.get 0 + i32.load8_u offset=31 + local.tee 1 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + i32.const 0 + i32.lt_s + local.set 9 + local.get 0 + i32.load offset=24 + local.get 1 + local.get 9 + select + local.tee 1 + local.get 6 + local.get 7 + local.get 8 + select + local.tee 7 + i32.add + local.tee 6 + i32.const -16 + i32.ge_u + br_if 9 (;@1;) + local.get 0 + i32.load offset=20 + local.set 10 + local.get 6 + i32.const 10 + i32.gt_u + br_if 5 (;@5;) + local.get 5 + local.get 1 + i32.store8 offset=11 + local.get 5 + local.set 6 + br 6 (;@4;) + end + i32.const 1520 + local.set 6 + br 3 (;@6;) + end + i32.const 1527 + local.set 6 + br 2 (;@6;) + end + i32.const 1538 + local.set 6 + br 1 (;@6;) + end + i32.const 1544 + local.set 6 + end + local.get 5 + i32.const 0 + i32.store offset=8 + local.get 5 + i64.const 0 + i64.store + block (result i32) ;; label = @6 + local.get 0 + i32.load8_s offset=19 + local.tee 1 + i32.const -1 + i32.le_s + if ;; label = @7 + local.get 0 + i32.load offset=12 + local.set 7 + local.get 6 + call 32 + local.set 1 + local.get 0 + i32.load offset=8 + br 1 (;@6;) + end + local.get 1 + i32.const 255 + i32.and + local.set 7 + local.get 6 + call 32 + local.set 1 + local.get 0 + i32.const 8 + i32.add + end + local.set 8 + local.get 1 + local.get 7 + i32.add + local.tee 0 + i32.const -16 + i32.ge_u + br_if 4 (;@1;) + block ;; label = @6 + local.get 0 + i32.const 10 + i32.le_u + if ;; label = @7 + local.get 5 + local.get 7 + i32.store8 offset=11 + local.get 5 + local.set 0 + br 1 (;@6;) + end + local.get 0 + i32.const 16 + i32.add + i32.const -16 + i32.and + local.tee 9 + call 33 + local.set 0 + local.get 5 + local.get 9 + i32.const -2147483648 + i32.or + i32.store offset=8 + local.get 5 + local.get 0 + i32.store + local.get 5 + local.get 7 + i32.store offset=4 + end + local.get 7 + if ;; label = @6 + local.get 0 + local.get 8 + local.get 7 + call 26 + drop + end + local.get 0 + local.get 7 + i32.add + i32.const 0 + i32.store8 + local.get 5 + local.get 6 + local.get 1 + call 41 + drop + br 2 (;@3;) + end + local.get 6 + i32.const 16 + i32.add + i32.const -16 + i32.and + local.tee 11 + call 33 + local.set 6 + local.get 5 + local.get 11 + i32.const -2147483648 + i32.or + i32.store offset=8 + local.get 5 + local.get 6 + i32.store + local.get 5 + local.get 1 + i32.store offset=4 + end + local.get 1 + if ;; label = @4 + local.get 6 + local.get 10 + local.get 0 + i32.const 20 + i32.add + local.get 9 + select + local.get 1 + call 26 + drop + end + local.get 1 + local.get 6 + i32.add + i32.const 0 + i32.store8 + local.get 5 + local.get 4 + i32.load + local.get 4 + local.get 8 + select + local.get 7 + call 41 + drop + end + local.get 4 + i32.load8_s offset=11 + i32.const -1 + i32.le_s + if ;; label = @3 + local.get 4 + i32.load + call 21 + end + local.get 4 + local.get 5 + i64.load + i64.store align=4 + local.get 4 + local.get 5 + i32.load offset=8 + i32.store offset=8 + local.get 3 + i32.eqz + if ;; label = @3 + i32.const 1 + local.set 7 + br 1 (;@2;) + end + i32.const 0 + local.set 0 + loop ;; label = @3 + local.get 4 + i32.const 1554 + call 52 + local.get 2 + local.get 0 + i32.const 2 + i32.shl + i32.add + i32.load + call 52 + drop + i32.const 1 + local.set 7 + local.get 3 + local.get 0 + i32.const 1 + i32.add + local.tee 0 + i32.ne + br_if 0 (;@3;) + end + end + local.get 5 + i32.const 16 + i32.add + global.set 0 + local.get 7 + return + end + call 51 + unreachable) + (func (;36;) (type 1) (param i32) (result i32) + i32.const 0) + (func (;37;) (type 13) (param i32 i32 i32) + local.get 0 + local.get 1 + local.get 2 + call 26 + drop) + (func (;38;) (type 21) (param i32 i32 i32 i32 i32 i32 i32) (result i32) + (local i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i64) + global.get 0 + i32.const 80 + i32.sub + local.tee 7 + global.set 0 + local.get 7 + local.get 1 + i32.store offset=76 + local.get 7 + i32.const 55 + i32.add + local.set 21 + local.get 7 + i32.const 56 + i32.add + local.set 19 + i32.const 0 + local.set 1 + block ;; label = @1 + loop ;; label = @2 + block ;; label = @3 + local.get 15 + i32.const 0 + i32.lt_s + br_if 0 (;@3;) + i32.const 2147483647 + local.get 15 + i32.sub + local.get 1 + i32.lt_s + if ;; label = @4 + i32.const 2992 + i32.const 61 + i32.store + i32.const -1 + local.set 15 + br 1 (;@3;) + end + local.get 1 + local.get 15 + i32.add + local.set 15 + end + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + local.get 7 + i32.load offset=76 + local.tee 11 + local.tee 1 + i32.load8_u + local.tee 8 + if ;; label = @6 + loop ;; label = @7 + block ;; label = @8 + block ;; label = @9 + local.get 8 + i32.const 255 + i32.and + local.tee 8 + i32.eqz + if ;; label = @10 + local.get 1 + local.set 8 + br 1 (;@9;) + end + local.get 8 + i32.const 37 + i32.ne + br_if 1 (;@8;) + local.get 1 + local.set 8 + loop ;; label = @10 + local.get 1 + i32.load8_u offset=1 + i32.const 37 + i32.ne + br_if 1 (;@9;) + local.get 7 + local.get 1 + i32.const 2 + i32.add + local.tee 9 + i32.store offset=76 + local.get 8 + i32.const 1 + i32.add + local.set 8 + local.get 1 + i32.load8_u offset=2 + local.set 12 + local.get 9 + local.set 1 + local.get 12 + i32.const 37 + i32.eq + br_if 0 (;@10;) + end + end + local.get 8 + local.get 11 + i32.sub + local.set 1 + local.get 0 + if ;; label = @9 + local.get 0 + local.get 11 + local.get 1 + call 22 + end + local.get 1 + br_if 6 (;@2;) + local.get 7 + i32.load offset=76 + local.tee 9 + i32.const 1 + i32.add + local.set 1 + i32.const -1 + local.set 17 + block ;; label = @9 + local.get 9 + i32.load8_s offset=1 + local.tee 8 + i32.const 48 + i32.sub + i32.const 10 + i32.ge_u + br_if 0 (;@9;) + local.get 9 + i32.load8_u offset=2 + i32.const 36 + i32.ne + br_if 0 (;@9;) + local.get 9 + i32.const 3 + i32.add + local.set 1 + local.get 8 + i32.const 48 + i32.sub + local.set 17 + i32.const 1 + local.set 20 + end + local.get 7 + local.get 1 + i32.store offset=76 + i32.const 0 + local.set 16 + block ;; label = @9 + local.get 1 + i32.load8_s + local.tee 12 + i32.const 32 + i32.sub + local.tee 9 + i32.const 31 + i32.gt_u + if ;; label = @10 + local.get 1 + local.set 8 + br 1 (;@9;) + end + local.get 1 + local.set 8 + i32.const 1 + local.get 9 + i32.shl + local.tee 9 + i32.const 75913 + i32.and + i32.eqz + br_if 0 (;@9;) + loop ;; label = @10 + local.get 7 + local.get 1 + i32.const 1 + i32.add + local.tee 8 + i32.store offset=76 + local.get 9 + local.get 16 + i32.or + local.set 16 + local.get 1 + i32.load8_s offset=1 + local.tee 12 + i32.const 32 + i32.sub + local.tee 9 + i32.const 32 + i32.ge_u + br_if 1 (;@9;) + local.get 8 + local.set 1 + i32.const 1 + local.get 9 + i32.shl + local.tee 9 + i32.const 75913 + i32.and + br_if 0 (;@10;) + end + end + block ;; label = @9 + local.get 12 + i32.const 42 + i32.eq + if ;; label = @10 + block (result i32) ;; label = @11 + block ;; label = @12 + local.get 8 + i32.load8_s offset=1 + local.tee 1 + i32.const 48 + i32.sub + i32.const 10 + i32.ge_u + br_if 0 (;@12;) + local.get 8 + i32.load8_u offset=2 + i32.const 36 + i32.ne + br_if 0 (;@12;) + local.get 4 + local.get 1 + i32.const 2 + i32.shl + i32.add + i32.const 192 + i32.sub + i32.const 10 + i32.store + local.get 8 + i32.const 3 + i32.add + local.set 1 + i32.const 1 + local.set 20 + local.get 8 + i32.load8_s offset=1 + i32.const 3 + i32.shl + local.get 3 + i32.add + i32.const 384 + i32.sub + i32.load + br 1 (;@11;) + end + local.get 20 + br_if 6 (;@5;) + local.get 8 + i32.const 1 + i32.add + local.set 1 + local.get 0 + i32.eqz + if ;; label = @12 + local.get 7 + local.get 1 + i32.store offset=76 + i32.const 0 + local.set 20 + i32.const 0 + local.set 14 + br 3 (;@9;) + end + local.get 2 + local.get 2 + i32.load + local.tee 8 + i32.const 4 + i32.add + i32.store + i32.const 0 + local.set 20 + local.get 8 + i32.load + end + local.set 14 + local.get 7 + local.get 1 + i32.store offset=76 + local.get 14 + i32.const -1 + i32.gt_s + br_if 1 (;@9;) + i32.const 0 + local.get 14 + i32.sub + local.set 14 + local.get 16 + i32.const 8192 + i32.or + local.set 16 + br 1 (;@9;) + end + local.get 7 + i32.const 76 + i32.add + call 44 + local.tee 14 + i32.const 0 + i32.lt_s + br_if 4 (;@5;) + local.get 7 + i32.load offset=76 + local.set 1 + end + i32.const -1 + local.set 10 + block ;; label = @9 + local.get 1 + i32.load8_u + i32.const 46 + i32.ne + br_if 0 (;@9;) + local.get 1 + i32.load8_u offset=1 + i32.const 42 + i32.eq + if ;; label = @10 + block ;; label = @11 + block ;; label = @12 + local.get 1 + i32.load8_s offset=2 + local.tee 8 + i32.const 48 + i32.sub + i32.const 10 + i32.ge_u + br_if 0 (;@12;) + local.get 1 + i32.load8_u offset=3 + i32.const 36 + i32.ne + br_if 0 (;@12;) + local.get 8 + i32.const 2 + i32.shl + local.get 4 + i32.add + i32.const 192 + i32.sub + i32.const 10 + i32.store + local.get 1 + i32.load8_s offset=2 + i32.const 3 + i32.shl + local.get 3 + i32.add + i32.const 384 + i32.sub + i32.load + local.set 10 + local.get 1 + i32.const 4 + i32.add + local.set 1 + br 1 (;@11;) + end + local.get 20 + br_if 6 (;@5;) + local.get 1 + i32.const 2 + i32.add + local.set 1 + local.get 0 + i32.eqz + if ;; label = @12 + i32.const 0 + local.set 10 + br 1 (;@11;) + end + local.get 2 + local.get 2 + i32.load + local.tee 8 + i32.const 4 + i32.add + i32.store + local.get 8 + i32.load + local.set 10 + end + local.get 7 + local.get 1 + i32.store offset=76 + br 1 (;@9;) + end + local.get 7 + local.get 1 + i32.const 1 + i32.add + i32.store offset=76 + local.get 7 + i32.const 76 + i32.add + call 44 + local.set 10 + local.get 7 + i32.load offset=76 + local.set 1 + end + i32.const 0 + local.set 9 + loop ;; label = @9 + local.get 9 + local.set 18 + i32.const -1 + local.set 13 + local.get 1 + local.set 12 + local.get 1 + i32.load8_s + i32.const 65 + i32.sub + i32.const 57 + i32.gt_u + br_if 8 (;@1;) + local.get 7 + local.get 12 + i32.const 1 + i32.add + local.tee 1 + i32.store offset=76 + local.get 12 + i32.load8_s + local.get 18 + i32.const 58 + i32.mul + i32.add + i32.const 1695 + i32.add + i32.load8_u + local.tee 9 + i32.const 1 + i32.sub + i32.const 8 + i32.lt_u + br_if 0 (;@9;) + end + block ;; label = @9 + block ;; label = @10 + local.get 9 + i32.const 19 + i32.ne + if ;; label = @11 + local.get 9 + i32.eqz + br_if 10 (;@1;) + local.get 17 + i32.const 0 + i32.ge_s + if ;; label = @12 + local.get 4 + local.get 17 + i32.const 2 + i32.shl + i32.add + local.get 9 + i32.store + local.get 7 + local.get 3 + local.get 17 + i32.const 3 + i32.shl + i32.add + i64.load + i64.store offset=64 + br 2 (;@10;) + end + local.get 0 + i32.eqz + br_if 8 (;@3;) + local.get 7 + i32.const -64 + i32.sub + local.get 9 + local.get 2 + local.get 6 + call 43 + br 2 (;@9;) + end + local.get 17 + i32.const -1 + i32.gt_s + br_if 9 (;@1;) + end + i32.const 0 + local.set 1 + local.get 0 + i32.eqz + br_if 7 (;@2;) + end + local.get 16 + i32.const -65537 + i32.and + local.tee 8 + local.get 16 + local.get 16 + i32.const 8192 + i32.and + select + local.set 9 + i32.const 0 + local.set 13 + i32.const 2224 + local.set 17 + local.get 19 + local.set 16 + block ;; label = @9 + block ;; label = @10 + block ;; label = @11 + block (result i32) ;; label = @12 + block ;; label = @13 + block ;; label = @14 + block ;; label = @15 + block ;; label = @16 + block (result i32) ;; label = @17 + block ;; label = @18 + block ;; label = @19 + block ;; label = @20 + block ;; label = @21 + block ;; label = @22 + block ;; label = @23 + block ;; label = @24 + local.get 12 + i32.load8_s + local.tee 1 + i32.const -33 + i32.and + local.get 1 + local.get 1 + i32.const 15 + i32.and + i32.const 3 + i32.eq + select + local.get 1 + local.get 18 + select + local.tee 1 + i32.const 88 + i32.sub + br_table 4 (;@20;) 20 (;@4;) 20 (;@4;) 20 (;@4;) 20 (;@4;) 20 (;@4;) 20 (;@4;) 20 (;@4;) 20 (;@4;) 14 (;@10;) 20 (;@4;) 15 (;@9;) 6 (;@18;) 14 (;@10;) 14 (;@10;) 14 (;@10;) 20 (;@4;) 6 (;@18;) 20 (;@4;) 20 (;@4;) 20 (;@4;) 20 (;@4;) 2 (;@22;) 5 (;@19;) 3 (;@21;) 20 (;@4;) 20 (;@4;) 9 (;@15;) 20 (;@4;) 1 (;@23;) 20 (;@4;) 20 (;@4;) 4 (;@20;) 0 (;@24;) + end + block ;; label = @24 + local.get 1 + i32.const 65 + i32.sub + br_table 14 (;@10;) 20 (;@4;) 11 (;@13;) 20 (;@4;) 14 (;@10;) 14 (;@10;) 14 (;@10;) 0 (;@24;) + end + local.get 1 + i32.const 83 + i32.eq + br_if 9 (;@14;) + br 19 (;@4;) + end + local.get 7 + i64.load offset=64 + local.set 22 + i32.const 2224 + br 5 (;@17;) + end + i32.const 0 + local.set 1 + block ;; label = @22 + block ;; label = @23 + block ;; label = @24 + block ;; label = @25 + block ;; label = @26 + block ;; label = @27 + block ;; label = @28 + local.get 18 + i32.const 255 + i32.and + br_table 0 (;@28;) 1 (;@27;) 2 (;@26;) 3 (;@25;) 4 (;@24;) 26 (;@2;) 5 (;@23;) 6 (;@22;) 26 (;@2;) + end + local.get 7 + i32.load offset=64 + local.get 15 + i32.store + br 25 (;@2;) + end + local.get 7 + i32.load offset=64 + local.get 15 + i32.store + br 24 (;@2;) + end + local.get 7 + i32.load offset=64 + local.get 15 + i64.extend_i32_s + i64.store + br 23 (;@2;) + end + local.get 7 + i32.load offset=64 + local.get 15 + i32.store16 + br 22 (;@2;) + end + local.get 7 + i32.load offset=64 + local.get 15 + i32.store8 + br 21 (;@2;) + end + local.get 7 + i32.load offset=64 + local.get 15 + i32.store + br 20 (;@2;) + end + local.get 7 + i32.load offset=64 + local.get 15 + i64.extend_i32_s + i64.store + br 19 (;@2;) + end + local.get 10 + i32.const 8 + local.get 10 + i32.const 8 + i32.gt_u + select + local.set 10 + local.get 9 + i32.const 8 + i32.or + local.set 9 + i32.const 120 + local.set 1 + end + local.get 7 + i64.load offset=64 + local.get 19 + local.get 1 + i32.const 32 + i32.and + call 67 + local.set 11 + local.get 9 + i32.const 8 + i32.and + i32.eqz + br_if 3 (;@16;) + local.get 7 + i64.load offset=64 + i64.eqz + br_if 3 (;@16;) + local.get 1 + i32.const 4 + i32.shr_u + i32.const 2224 + i32.add + local.set 17 + i32.const 2 + local.set 13 + br 3 (;@16;) + end + local.get 7 + i64.load offset=64 + local.get 19 + call 66 + local.set 11 + local.get 9 + i32.const 8 + i32.and + i32.eqz + br_if 2 (;@16;) + local.get 10 + local.get 19 + local.get 11 + i32.sub + local.tee 1 + i32.const 1 + i32.add + local.get 1 + local.get 10 + i32.lt_s + select + local.set 10 + br 2 (;@16;) + end + local.get 7 + i64.load offset=64 + local.tee 22 + i64.const -1 + i64.le_s + if ;; label = @18 + local.get 7 + i64.const 0 + local.get 22 + i64.sub + local.tee 22 + i64.store offset=64 + i32.const 1 + local.set 13 + i32.const 2224 + br 1 (;@17;) + end + local.get 9 + i32.const 2048 + i32.and + if ;; label = @18 + i32.const 1 + local.set 13 + i32.const 2225 + br 1 (;@17;) + end + i32.const 2226 + i32.const 2224 + local.get 9 + i32.const 1 + i32.and + local.tee 13 + select + end + local.set 17 + local.get 22 + local.get 19 + call 28 + local.set 11 + end + local.get 9 + i32.const -65537 + i32.and + local.get 9 + local.get 10 + i32.const -1 + i32.gt_s + select + local.set 9 + local.get 7 + i64.load offset=64 + local.set 22 + block ;; label = @16 + local.get 10 + br_if 0 (;@16;) + local.get 22 + i64.eqz + i32.eqz + br_if 0 (;@16;) + i32.const 0 + local.set 10 + local.get 19 + local.set 11 + br 12 (;@4;) + end + local.get 10 + local.get 22 + i64.eqz + local.get 19 + local.get 11 + i32.sub + i32.add + local.tee 1 + i32.gt_s + local.set 8 + local.get 10 + local.get 1 + local.get 8 + select + local.set 10 + br 11 (;@4;) + end + local.get 7 + i32.load offset=64 + local.tee 1 + i32.const 2234 + local.get 1 + select + local.tee 11 + local.get 10 + call 65 + local.tee 1 + local.get 10 + local.get 11 + i32.add + local.get 1 + select + local.set 16 + local.get 8 + local.set 9 + local.get 1 + local.get 11 + i32.sub + local.get 10 + local.get 1 + select + local.set 10 + br 10 (;@4;) + end + local.get 10 + if ;; label = @14 + local.get 7 + i32.load offset=64 + br 2 (;@12;) + end + i32.const 0 + local.set 1 + local.get 0 + i32.const 32 + local.get 14 + i32.const 0 + local.get 9 + call 23 + br 2 (;@11;) + end + local.get 7 + i32.const 0 + i32.store offset=12 + local.get 7 + local.get 7 + i64.load offset=64 + i64.store32 offset=8 + local.get 7 + local.get 7 + i32.const 8 + i32.add + i32.store offset=64 + i32.const -1 + local.set 10 + local.get 7 + i32.const 8 + i32.add + end + local.set 8 + i32.const 0 + local.set 1 + block ;; label = @12 + loop ;; label = @13 + local.get 8 + i32.load + local.tee 11 + i32.eqz + br_if 1 (;@12;) + block ;; label = @14 + local.get 7 + i32.const 4 + i32.add + local.get 11 + call 47 + local.tee 12 + i32.const 0 + i32.lt_s + local.tee 11 + br_if 0 (;@14;) + local.get 10 + local.get 1 + i32.sub + local.get 12 + i32.lt_u + br_if 0 (;@14;) + local.get 8 + i32.const 4 + i32.add + local.set 8 + local.get 10 + local.get 1 + local.get 12 + i32.add + local.tee 1 + i32.gt_u + br_if 1 (;@13;) + br 2 (;@12;) + end + end + i32.const -1 + local.set 13 + local.get 11 + br_if 11 (;@1;) + end + local.get 0 + i32.const 32 + local.get 14 + local.get 1 + local.get 9 + call 23 + local.get 1 + i32.eqz + if ;; label = @12 + i32.const 0 + local.set 1 + br 1 (;@11;) + end + i32.const 0 + local.set 8 + local.get 7 + i32.load offset=64 + local.set 12 + loop ;; label = @12 + local.get 12 + i32.load + local.tee 11 + i32.eqz + br_if 1 (;@11;) + local.get 7 + i32.const 4 + i32.add + local.get 11 + call 47 + local.tee 11 + local.get 8 + i32.add + local.tee 8 + local.get 1 + i32.gt_s + br_if 1 (;@11;) + local.get 0 + local.get 7 + i32.const 4 + i32.add + local.get 11 + call 22 + local.get 12 + i32.const 4 + i32.add + local.set 12 + local.get 1 + local.get 8 + i32.gt_u + br_if 0 (;@12;) + end + end + local.get 0 + i32.const 32 + local.get 14 + local.get 1 + local.get 9 + i32.const 8192 + i32.xor + call 23 + local.get 14 + local.get 1 + local.get 1 + local.get 14 + i32.lt_s + select + local.set 1 + br 8 (;@2;) + end + local.get 0 + local.get 7 + f64.load offset=64 + local.get 14 + local.get 10 + local.get 9 + local.get 1 + local.get 5 + call_indirect (type 18) + local.set 1 + br 7 (;@2;) + end + local.get 7 + local.get 7 + i64.load offset=64 + i64.store8 offset=55 + i32.const 1 + local.set 10 + local.get 21 + local.set 11 + local.get 8 + local.set 9 + br 4 (;@4;) + end + local.get 7 + local.get 1 + i32.const 1 + i32.add + local.tee 9 + i32.store offset=76 + local.get 1 + i32.load8_u offset=1 + local.set 8 + local.get 9 + local.set 1 + br 0 (;@7;) + end + unreachable + end + local.get 15 + local.set 13 + local.get 0 + br_if 4 (;@1;) + local.get 20 + i32.eqz + br_if 2 (;@3;) + i32.const 1 + local.set 1 + loop ;; label = @6 + local.get 4 + local.get 1 + i32.const 2 + i32.shl + i32.add + i32.load + local.tee 0 + if ;; label = @7 + local.get 1 + i32.const 3 + i32.shl + local.get 3 + i32.add + local.get 0 + local.get 2 + local.get 6 + call 43 + i32.const 1 + local.set 13 + local.get 1 + i32.const 1 + i32.add + local.tee 1 + i32.const 10 + i32.ne + br_if 1 (;@6;) + br 6 (;@1;) + end + end + i32.const 1 + local.set 13 + local.get 1 + i32.const 10 + i32.ge_u + br_if 4 (;@1;) + i32.const 0 + local.set 8 + loop ;; label = @6 + local.get 8 + br_if 1 (;@5;) + local.get 1 + i32.const 1 + i32.add + local.tee 1 + i32.const 10 + i32.eq + br_if 5 (;@1;) + local.get 4 + local.get 1 + i32.const 2 + i32.shl + i32.add + i32.load + local.set 8 + br 0 (;@6;) + end + unreachable + end + i32.const -1 + local.set 13 + br 3 (;@1;) + end + local.get 10 + local.get 16 + local.get 11 + i32.sub + local.tee 12 + i32.lt_s + local.set 1 + local.get 13 + local.get 12 + local.get 10 + local.get 1 + select + local.tee 8 + i32.add + local.tee 18 + local.get 14 + i32.gt_s + local.set 1 + local.get 0 + i32.const 32 + local.get 18 + local.get 14 + local.get 1 + select + local.tee 1 + local.get 18 + local.get 9 + call 23 + local.get 0 + local.get 17 + local.get 13 + call 22 + local.get 0 + i32.const 48 + local.get 1 + local.get 18 + local.get 9 + i32.const 65536 + i32.xor + call 23 + local.get 0 + i32.const 48 + local.get 8 + local.get 12 + i32.const 0 + call 23 + local.get 0 + local.get 11 + local.get 12 + call 22 + local.get 0 + i32.const 32 + local.get 1 + local.get 18 + local.get 9 + i32.const 8192 + i32.xor + call 23 + br 1 (;@2;) + end + end + i32.const 0 + local.set 13 + end + local.get 7 + i32.const 80 + i32.add + global.set 0 + local.get 13) + (func (;39;) (type 1) (param i32) (result i32) + (local i32 i32) + block ;; label = @1 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=28 + i32.le_u + br_if 0 (;@1;) + local.get 0 + i32.const 0 + i32.const 0 + local.get 0 + i32.load offset=36 + call_indirect (type 0) + drop + local.get 0 + i32.load offset=20 + br_if 0 (;@1;) + i32.const -1 + return + end + local.get 0 + i32.load offset=4 + local.tee 1 + local.get 0 + i32.load offset=8 + local.tee 2 + i32.lt_u + if ;; label = @1 + local.get 0 + local.get 1 + local.get 2 + i32.sub + i64.extend_i32_s + i32.const 1 + local.get 0 + i32.load offset=40 + call_indirect (type 12) + drop + end + local.get 0 + i32.const 0 + i32.store offset=28 + local.get 0 + i64.const 0 + i64.store offset=16 + local.get 0 + i64.const 0 + i64.store offset=4 align=4 + i32.const 0) + (func (;40;) (type 0) (param i32 i32 i32) (result i32) + (local i32 i32 i32 i32) + local.get 1 + local.set 6 + block ;; label = @1 + local.get 6 + local.get 2 + i32.load offset=16 + local.tee 3 + if (result i32) ;; label = @2 + local.get 3 + else + local.get 2 + call 95 + br_if 1 (;@1;) + local.get 2 + i32.load offset=16 + end + local.get 2 + i32.load offset=20 + local.tee 5 + i32.sub + i32.gt_u + if ;; label = @2 + local.get 2 + local.get 0 + local.get 1 + local.get 2 + i32.load offset=36 + call_indirect (type 0) + return + end + block ;; label = @2 + local.get 2 + i32.load8_s offset=75 + i32.const 0 + i32.lt_s + if ;; label = @3 + i32.const 0 + local.set 3 + br 1 (;@2;) + end + local.get 1 + local.set 4 + loop ;; label = @3 + local.get 4 + local.tee 3 + i32.eqz + if ;; label = @4 + i32.const 0 + local.set 3 + br 2 (;@2;) + end + local.get 3 + i32.const 1 + i32.sub + local.tee 4 + local.get 0 + i32.add + i32.load8_u + i32.const 10 + i32.ne + br_if 0 (;@3;) + end + local.get 3 + local.get 2 + local.get 0 + local.get 3 + local.get 2 + i32.load offset=36 + call_indirect (type 0) + local.tee 4 + i32.gt_u + br_if 1 (;@1;) + local.get 0 + local.get 3 + i32.add + local.set 0 + local.get 1 + local.get 3 + i32.sub + local.set 1 + local.get 2 + i32.load offset=20 + local.set 5 + end + local.get 5 + local.get 0 + local.get 1 + call 26 + drop + local.get 2 + local.get 1 + local.get 2 + i32.load offset=20 + i32.add + i32.store offset=20 + local.get 1 + local.get 3 + i32.add + local.set 4 + end + local.get 4) + (func (;41;) (type 0) (param i32 i32 i32) (result i32) + (local i32 i32) + block ;; label = @1 + local.get 0 + i32.load8_u offset=11 + i32.const 7 + i32.shr_u + if (result i32) ;; label = @2 + local.get 0 + i32.load offset=8 + i32.const 2147483647 + i32.and + i32.const 1 + i32.sub + else + i32.const 10 + end + local.tee 4 + block (result i32) ;; label = @2 + local.get 0 + i32.load8_u offset=11 + i32.const 7 + i32.shr_u + if ;; label = @3 + local.get 0 + i32.load offset=4 + br 1 (;@2;) + end + local.get 0 + i32.load8_u offset=11 + end + local.tee 3 + i32.sub + local.get 2 + i32.ge_u + if ;; label = @2 + local.get 2 + i32.eqz + br_if 1 (;@1;) + local.get 3 + block (result i32) ;; label = @3 + local.get 0 + i32.load8_u offset=11 + i32.const 7 + i32.shr_u + if ;; label = @4 + local.get 0 + i32.load + br 1 (;@3;) + end + local.get 0 + end + local.tee 4 + i32.add + local.get 1 + local.get 2 + call 37 + local.get 2 + local.get 3 + i32.add + local.tee 2 + local.set 1 + block ;; label = @3 + local.get 0 + i32.load8_u offset=11 + i32.const 7 + i32.shr_u + if ;; label = @4 + local.get 0 + local.get 1 + i32.store offset=4 + br 1 (;@3;) + end + local.get 0 + local.get 1 + i32.store8 offset=11 + end + local.get 2 + local.get 4 + i32.add + i32.const 0 + i32.store8 + local.get 0 + return + end + local.get 0 + local.get 4 + local.get 2 + local.get 3 + i32.add + local.get 4 + i32.sub + local.get 3 + local.get 3 + local.get 2 + local.get 1 + call 133 + end + local.get 0) + (func (;42;) (type 5) + i32.const 5246512 + global.set 2 + i32.const 3632 + global.set 1 + call 138 + call 118) + (func (;43;) (type 6) (param i32 i32 i32 i32) + block ;; label = @1 + local.get 1 + i32.const 20 + i32.gt_u + br_if 0 (;@1;) + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + block ;; label = @6 + block ;; label = @7 + block ;; label = @8 + block ;; label = @9 + block ;; label = @10 + block ;; label = @11 + local.get 1 + i32.const 9 + i32.sub + br_table 0 (;@11;) 1 (;@10;) 2 (;@9;) 3 (;@8;) 4 (;@7;) 5 (;@6;) 6 (;@5;) 7 (;@4;) 8 (;@3;) 9 (;@2;) 10 (;@1;) + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i32.load + i32.store + return + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load32_s + i64.store + return + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load32_u + i64.store + return + end + local.get 2 + local.get 2 + i32.load + i32.const 7 + i32.add + i32.const -8 + i32.and + local.tee 1 + i32.const 8 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load + i64.store + return + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load16_s + i64.store + return + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load16_u + i64.store + return + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load8_s + i64.store + return + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load8_u + i64.store + return + end + local.get 2 + local.get 2 + i32.load + i32.const 7 + i32.add + i32.const -8 + i32.and + local.tee 1 + i32.const 8 + i32.add + i32.store + local.get 0 + local.get 1 + f64.load + f64.store + return + end + local.get 0 + local.get 2 + local.get 3 + call_indirect (type 4) + end) + (func (;44;) (type 1) (param i32) (result i32) + (local i32 i32 i32) + local.get 0 + i32.load + local.set 1 + loop ;; label = @1 + local.get 1 + i32.load8_s + local.tee 3 + i32.const 48 + i32.sub + i32.const 10 + i32.lt_u + if ;; label = @2 + local.get 0 + local.get 1 + i32.const 1 + i32.add + local.tee 1 + i32.store + local.get 2 + i32.const 10 + i32.mul + local.get 3 + i32.add + i32.const 48 + i32.sub + local.set 2 + br 1 (;@1;) + end + end + local.get 2) + (func (;45;) (type 14) (param i32 i32 i32 i32 i32) (result i32) + (local i32 i32 i32) + global.get 0 + i32.const 208 + i32.sub + local.tee 5 + global.set 0 + local.get 5 + local.get 2 + i32.store offset=204 + local.get 5 + i32.const 160 + i32.add + i32.const 0 + i32.const 40 + call 31 + drop + local.get 5 + local.get 5 + i32.load offset=204 + i32.store offset=200 + block ;; label = @1 + i32.const 0 + local.get 1 + local.get 5 + i32.const 200 + i32.add + local.get 5 + i32.const 80 + i32.add + local.get 5 + i32.const 160 + i32.add + local.get 3 + local.get 4 + call 38 + i32.const 0 + i32.lt_s + if ;; label = @2 + i32.const -1 + local.set 1 + br 1 (;@1;) + end + local.get 0 + i32.load offset=76 + i32.const 0 + i32.ge_s + local.set 2 + local.get 0 + i32.load + local.set 6 + local.get 0 + i32.load8_s offset=74 + i32.const 0 + i32.le_s + if ;; label = @2 + local.get 0 + local.get 6 + i32.const -33 + i32.and + i32.store + end + local.get 6 + i32.const 32 + i32.and + local.set 7 + block (result i32) ;; label = @2 + local.get 0 + i32.load offset=48 + if ;; label = @3 + local.get 0 + local.get 1 + local.get 5 + i32.const 200 + i32.add + local.get 5 + i32.const 80 + i32.add + local.get 5 + i32.const 160 + i32.add + local.get 3 + local.get 4 + call 38 + br 1 (;@2;) + end + local.get 0 + i32.const 80 + i32.store offset=48 + local.get 0 + local.get 5 + i32.const 80 + i32.add + i32.store offset=16 + local.get 0 + local.get 5 + i32.store offset=28 + local.get 0 + local.get 5 + i32.store offset=20 + local.get 0 + i32.load offset=44 + local.set 6 + local.get 0 + local.get 5 + i32.store offset=44 + local.get 0 + local.get 1 + local.get 5 + i32.const 200 + i32.add + local.get 5 + i32.const 80 + i32.add + local.get 5 + i32.const 160 + i32.add + local.get 3 + local.get 4 + call 38 + local.tee 1 + local.get 6 + i32.eqz + br_if 0 (;@2;) + drop + local.get 0 + i32.const 0 + i32.const 0 + local.get 0 + i32.load offset=36 + call_indirect (type 0) + drop + local.get 0 + i32.const 0 + i32.store offset=48 + local.get 0 + local.get 6 + i32.store offset=44 + local.get 0 + i32.const 0 + i32.store offset=28 + local.get 0 + i32.const 0 + i32.store offset=16 + local.get 0 + i32.load offset=20 + local.set 3 + local.get 0 + i32.const 0 + i32.store offset=20 + local.get 1 + i32.const -1 + local.get 3 + select + end + local.set 3 + local.get 0 + local.get 7 + local.get 0 + i32.load + local.tee 0 + i32.or + i32.store + i32.const -1 + local.get 3 + local.get 0 + i32.const 32 + i32.and + select + local.set 1 + local.get 2 + i32.eqz + br_if 0 (;@1;) + end + local.get 5 + i32.const 208 + i32.add + global.set 0 + local.get 1) + (func (;46;) (type 25) (param f64 i32) (result f64) + (local i32 i64) + local.get 0 + i64.reinterpret_f64 + local.tee 3 + i64.const 52 + i64.shr_u + i32.wrap_i64 + i32.const 2047 + i32.and + local.tee 2 + i32.const 2047 + i32.ne + if (result f64) ;; label = @1 + local.get 2 + i32.eqz + if ;; label = @2 + local.get 1 + local.get 0 + f64.const 0x0p+0 (;=0;) + f64.eq + if (result i32) ;; label = @3 + i32.const 0 + else + local.get 0 + f64.const 0x1p+64 (;=1.84467e+19;) + f64.mul + local.get 1 + call 46 + local.set 0 + local.get 1 + i32.load + i32.const -64 + i32.add + end + i32.store + local.get 0 + return + end + local.get 1 + local.get 2 + i32.const 1022 + i32.sub + i32.store + local.get 3 + i64.const -9218868437227405313 + i64.and + i64.const 4602678819172646912 + i64.or + f64.reinterpret_i64 + else + local.get 0 + end) + (func (;47;) (type 2) (param i32 i32) (result i32) + local.get 0 + i32.eqz + if ;; label = @1 + i32.const 0 + return + end + local.get 0 + local.get 1 + call 68) + (func (;48;) (type 10) (param i32) (result i64) + (local i64 i32) + local.get 0 + i32.load offset=40 + local.set 2 + local.get 0 + i64.const 0 + local.get 0 + i32.load8_u + i32.const 128 + i32.and + if (result i32) ;; label = @1 + i32.const 2 + i32.const 1 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=28 + i32.gt_u + select + else + i32.const 1 + end + local.get 2 + call_indirect (type 12) + local.tee 1 + i64.const 0 + i64.ge_s + if (result i64) ;; label = @1 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=28 + i32.sub + i64.extend_i32_s + local.get 1 + local.get 0 + i32.load offset=8 + local.get 0 + i32.load offset=4 + i32.sub + i64.extend_i32_s + i64.sub + i64.add + else + local.get 1 + end) + (func (;49;) (type 22) (param i32 i64 i32) (result i32) + local.get 2 + i32.const 1 + i32.eq + if ;; label = @1 + local.get 1 + local.get 0 + i32.load offset=8 + local.get 0 + i32.load offset=4 + i32.sub + i64.extend_i32_s + i64.sub + local.set 1 + end + block ;; label = @1 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=28 + i32.gt_u + if ;; label = @2 + local.get 0 + i32.const 0 + i32.const 0 + local.get 0 + i32.load offset=36 + call_indirect (type 0) + drop + local.get 0 + i32.load offset=20 + i32.eqz + br_if 1 (;@1;) + end + local.get 0 + i32.const 0 + i32.store offset=28 + local.get 0 + i64.const 0 + i64.store offset=16 + local.get 0 + local.get 1 + local.get 2 + local.get 0 + i32.load offset=40 + call_indirect (type 12) + i64.const 0 + i64.lt_s + br_if 0 (;@1;) + local.get 0 + i64.const 0 + i64.store offset=4 align=4 + local.get 0 + local.get 0 + i32.load + i32.const -17 + i32.and + i32.store + i32.const 0 + return + end + i32.const -1) + (func (;50;) (type 1) (param i32) (result i32) + i32.const 1) + (func (;51;) (type 5) + call 6 + unreachable) + (func (;52;) (type 2) (param i32 i32) (result i32) + local.get 0 + local.get 1 + local.get 1 + call 32 + call 41) + (func (;53;) (type 3) (param i32) + (local i32 i32 i32) + local.get 0 + i32.load offset=76 + drop + block ;; label = @1 + local.get 0 + i32.load + i32.const 1 + i32.and + local.tee 3 + br_if 0 (;@1;) + local.get 0 + i32.load offset=52 + local.tee 1 + if ;; label = @2 + local.get 1 + local.get 0 + i32.load offset=56 + i32.store offset=56 + end + local.get 0 + i32.load offset=56 + local.tee 2 + if ;; label = @2 + local.get 2 + local.get 1 + i32.store offset=52 + end + i32.const 3000 + i32.load + local.get 0 + i32.ne + br_if 0 (;@1;) + i32.const 3000 + local.get 2 + i32.store + end + local.get 0 + call 27 + drop + local.get 0 + local.get 0 + i32.load offset=12 + call_indirect (type 1) + drop + local.get 0 + i32.load offset=96 + local.tee 1 + if ;; label = @1 + local.get 1 + call 21 + end + local.get 3 + i32.eqz + if ;; label = @1 + local.get 0 + call 21 + end) + (func (;54;) (type 7) (param i32 i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 160 + i32.sub + local.tee 4 + global.set 0 + local.get 4 + i32.const 8 + i32.add + i32.const 2312 + i32.const 144 + call 26 + drop + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.const 1 + i32.sub + i32.const 2147483647 + i32.ge_u + if ;; label = @3 + local.get 1 + br_if 1 (;@2;) + i32.const 1 + local.set 1 + local.get 4 + i32.const 159 + i32.add + local.set 0 + end + local.get 4 + local.get 0 + i32.store offset=52 + local.get 4 + local.get 0 + i32.store offset=28 + local.get 4 + i32.const -2 + local.get 0 + i32.sub + local.tee 5 + local.get 1 + local.get 1 + local.get 5 + i32.gt_u + select + local.tee 1 + i32.store offset=56 + local.get 4 + local.get 0 + local.get 1 + i32.add + local.tee 0 + i32.store offset=36 + local.get 4 + local.get 0 + i32.store offset=24 + local.get 4 + i32.const 8 + i32.add + local.get 2 + local.get 3 + i32.const 7 + i32.const 8 + call 45 + local.set 0 + local.get 1 + i32.eqz + br_if 1 (;@1;) + local.get 4 + i32.load offset=28 + local.tee 1 + local.get 4 + i32.load offset=24 + i32.eq + local.set 2 + local.get 1 + local.get 2 + i32.sub + i32.const 0 + i32.store8 + br 1 (;@1;) + end + i32.const 2992 + i32.const 61 + i32.store + i32.const -1 + local.set 0 + end + local.get 4 + i32.const 160 + i32.add + global.set 0 + local.get 0) + (func (;55;) (type 1) (param i32) (result i32) + local.get 0 + i32.load8_u offset=8) + (func (;56;) (type 0) (param i32 i32 i32) (result i32) + i32.const 0) + (func (;57;) (type 1) (param i32) (result i32) + i32.const 2708) + (func (;58;) (type 1) (param i32) (result i32) + local.get 0 + i32.const 3068 + call 17) + (func (;59;) (type 13) (param i32 i32 i32) + (local i32) + local.get 0 + i32.load offset=16 + local.tee 3 + i32.eqz + if ;; label = @1 + local.get 0 + i32.const 1 + i32.store offset=36 + local.get 0 + local.get 2 + i32.store offset=24 + local.get 0 + local.get 1 + i32.store offset=16 + return + end + block ;; label = @1 + local.get 1 + local.get 3 + i32.eq + if ;; label = @2 + local.get 0 + i32.load offset=24 + i32.const 2 + i32.ne + br_if 1 (;@1;) + local.get 0 + local.get 2 + i32.store offset=24 + return + end + local.get 0 + i32.const 1 + i32.store8 offset=54 + local.get 0 + i32.const 2 + i32.store offset=24 + local.get 0 + local.get 0 + i32.load offset=36 + i32.const 1 + i32.add + i32.store offset=36 + end) + (func (;60;) (type 6) (param i32 i32 i32 i32) + local.get 0 + i32.const 1 + i32.store8 offset=53 + block ;; label = @1 + local.get 0 + i32.load offset=4 + local.get 2 + i32.ne + br_if 0 (;@1;) + local.get 0 + i32.const 1 + i32.store8 offset=52 + local.get 0 + i32.load offset=16 + local.tee 2 + i32.eqz + if ;; label = @2 + local.get 0 + i32.const 1 + i32.store offset=36 + local.get 0 + local.get 3 + i32.store offset=24 + local.get 0 + local.get 1 + i32.store offset=16 + local.get 3 + i32.const 1 + i32.ne + br_if 1 (;@1;) + local.get 0 + i32.load offset=48 + i32.const 1 + i32.ne + br_if 1 (;@1;) + local.get 0 + i32.const 1 + i32.store8 offset=54 + return + end + local.get 1 + local.get 2 + i32.eq + if ;; label = @2 + local.get 0 + i32.load offset=24 + local.tee 2 + i32.const 2 + i32.eq + if ;; label = @3 + local.get 0 + local.get 3 + i32.store offset=24 + local.get 3 + local.set 2 + end + local.get 0 + i32.load offset=48 + i32.const 1 + i32.ne + br_if 1 (;@1;) + local.get 2 + i32.const 1 + i32.ne + br_if 1 (;@1;) + local.get 0 + i32.const 1 + i32.store8 offset=54 + return + end + local.get 0 + i32.const 1 + i32.store8 offset=54 + local.get 0 + local.get 0 + i32.load offset=36 + i32.const 1 + i32.add + i32.store offset=36 + end) + (func (;61;) (type 3) (param i32) + local.get 0 + call 21) + (func (;62;) (type 0) (param i32 i32 i32) (result i32) + (local i32 i32) + local.get 1 + local.set 3 + local.get 2 + local.get 0 + i32.load offset=16 + local.get 0 + i32.load offset=20 + local.tee 4 + i32.sub + local.tee 1 + local.get 1 + local.get 2 + i32.gt_u + select + local.set 1 + local.get 4 + local.get 3 + local.get 1 + call 26 + drop + local.get 0 + local.get 0 + i32.load offset=20 + local.get 1 + i32.add + i32.store offset=20 + local.get 2) + (func (;63;) (type 4) (param i32 i32) + local.get 1 + local.get 1 + i32.load + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee 1 + i32.const 16 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load + local.get 1 + i64.load offset=8 + call 119 + f64.store) + (func (;64;) (type 18) (param i32 f64 i32 i32 i32 i32) (result i32) + (local i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 f64 i64 i64 i64) + global.get 0 + i32.const 560 + i32.sub + local.tee 9 + global.set 0 + local.get 9 + i32.const 0 + i32.store offset=44 + block (result i32) ;; label = @1 + local.get 1 + i64.reinterpret_f64 + local.tee 25 + i64.const -1 + i64.le_s + if ;; label = @2 + i32.const 1 + local.set 18 + local.get 1 + f64.neg + local.tee 1 + i64.reinterpret_f64 + local.set 25 + i32.const 2272 + br 1 (;@1;) + end + i32.const 1 + local.set 18 + i32.const 2275 + local.get 4 + i32.const 2048 + i32.and + br_if 0 (;@1;) + drop + i32.const 2278 + local.get 4 + i32.const 1 + i32.and + br_if 0 (;@1;) + drop + i32.const 0 + local.set 18 + i32.const 1 + local.set 19 + i32.const 2273 + end + local.set 22 + block ;; label = @1 + local.get 25 + i64.const 9218868437227405312 + i64.and + i64.const 9218868437227405312 + i64.eq + if ;; label = @2 + local.get 0 + i32.const 32 + local.get 2 + local.get 18 + i32.const 3 + i32.add + local.tee 13 + local.get 4 + i32.const -65537 + i32.and + call 23 + local.get 0 + local.get 22 + local.get 18 + call 22 + local.get 0 + i32.const 2303 + i32.const 2299 + local.get 5 + i32.const 32 + i32.and + local.tee 3 + select + i32.const 2295 + i32.const 2291 + local.get 3 + select + local.get 1 + local.get 1 + f64.ne + select + i32.const 3 + call 22 + br 1 (;@1;) + end + local.get 9 + i32.const 16 + i32.add + local.set 16 + block ;; label = @2 + block (result i32) ;; label = @3 + block ;; label = @4 + local.get 1 + local.get 9 + i32.const 44 + i32.add + call 46 + local.tee 1 + local.get 1 + f64.add + local.tee 1 + f64.const 0x0p+0 (;=0;) + f64.ne + if ;; label = @5 + local.get 9 + local.get 9 + i32.load offset=44 + local.tee 6 + i32.const 1 + i32.sub + i32.store offset=44 + local.get 5 + i32.const 32 + i32.or + local.tee 20 + i32.const 97 + i32.ne + br_if 1 (;@4;) + br 3 (;@2;) + end + local.get 5 + i32.const 32 + i32.or + local.tee 20 + i32.const 97 + i32.eq + br_if 2 (;@2;) + local.get 9 + i32.load offset=44 + local.set 11 + i32.const 6 + local.get 3 + local.get 3 + i32.const 0 + i32.lt_s + select + br 1 (;@3;) + end + local.get 9 + local.get 6 + i32.const 29 + i32.sub + local.tee 11 + i32.store offset=44 + local.get 1 + f64.const 0x1p+28 (;=2.68435e+08;) + f64.mul + local.set 1 + i32.const 6 + local.get 3 + local.get 3 + i32.const 0 + i32.lt_s + select + end + local.set 10 + local.get 9 + i32.const 48 + i32.add + local.get 9 + i32.const 336 + i32.add + local.get 11 + i32.const 0 + i32.lt_s + select + local.tee 14 + local.set 8 + loop ;; label = @3 + local.get 8 + block (result i32) ;; label = @4 + local.get 1 + f64.const 0x1p+32 (;=4.29497e+09;) + f64.lt + local.get 1 + f64.const 0x0p+0 (;=0;) + f64.ge + i32.and + if ;; label = @5 + local.get 1 + i32.trunc_f64_u + br 1 (;@4;) + end + i32.const 0 + end + local.tee 3 + i32.store + local.get 8 + i32.const 4 + i32.add + local.set 8 + local.get 1 + local.get 3 + f64.convert_i32_u + f64.sub + f64.const 0x1.dcd65p+29 (;=1e+09;) + f64.mul + local.tee 1 + f64.const 0x0p+0 (;=0;) + f64.ne + br_if 0 (;@3;) + end + block ;; label = @3 + local.get 11 + i32.const 1 + i32.lt_s + if ;; label = @4 + local.get 11 + local.set 3 + local.get 8 + local.set 6 + local.get 14 + local.set 7 + br 1 (;@3;) + end + local.get 14 + local.set 7 + local.get 11 + local.set 3 + loop ;; label = @4 + local.get 3 + i32.const 29 + local.get 3 + i32.const 29 + i32.lt_s + select + local.set 12 + block ;; label = @5 + local.get 7 + local.get 8 + i32.const 4 + i32.sub + local.tee 6 + i32.gt_u + br_if 0 (;@5;) + local.get 12 + i64.extend_i32_u + local.set 26 + i64.const 0 + local.set 25 + loop ;; label = @6 + local.get 6 + local.get 25 + i64.const 4294967295 + i64.and + local.get 6 + i64.load32_u + local.get 26 + i64.shl + i64.add + local.tee 27 + i64.const 1000000000 + i64.div_u + local.tee 25 + i64.const -1000000000 + i64.mul + local.get 27 + i64.add + i64.store32 + local.get 7 + local.get 6 + i32.const 4 + i32.sub + local.tee 6 + i32.le_u + br_if 0 (;@6;) + end + local.get 25 + i32.wrap_i64 + local.tee 3 + i32.eqz + br_if 0 (;@5;) + local.get 7 + i32.const 4 + i32.sub + local.tee 7 + local.get 3 + i32.store + end + loop ;; label = @5 + local.get 7 + local.get 8 + local.tee 6 + i32.lt_u + if ;; label = @6 + local.get 6 + i32.const 4 + i32.sub + local.tee 8 + i32.load + i32.eqz + br_if 1 (;@5;) + end + end + local.get 9 + local.get 9 + i32.load offset=44 + local.get 12 + i32.sub + local.tee 3 + i32.store offset=44 + local.get 6 + local.set 8 + local.get 3 + i32.const 0 + i32.gt_s + br_if 0 (;@4;) + end + end + local.get 3 + i32.const -1 + i32.le_s + if ;; label = @3 + local.get 10 + i32.const 25 + i32.add + i32.const 9 + i32.div_s + i32.const 1 + i32.add + local.set 17 + local.get 20 + i32.const 102 + i32.eq + local.set 13 + loop ;; label = @4 + i32.const 9 + i32.const 0 + local.get 3 + i32.sub + local.get 3 + i32.const -9 + i32.lt_s + select + local.set 23 + block ;; label = @5 + local.get 6 + local.get 7 + i32.le_u + if ;; label = @6 + local.get 7 + local.get 7 + i32.const 4 + i32.add + local.get 7 + i32.load + select + local.set 7 + br 1 (;@5;) + end + i32.const 1000000000 + local.get 23 + i32.shr_u + local.set 21 + i32.const -1 + local.get 23 + i32.shl + i32.const -1 + i32.xor + local.set 15 + i32.const 0 + local.set 3 + local.get 7 + local.set 8 + loop ;; label = @6 + local.get 8 + local.get 8 + i32.load + local.tee 12 + local.get 23 + i32.shr_u + local.get 3 + i32.add + i32.store + local.get 21 + local.get 12 + local.get 15 + i32.and + i32.mul + local.set 3 + local.get 8 + i32.const 4 + i32.add + local.tee 8 + local.get 6 + i32.lt_u + br_if 0 (;@6;) + end + local.get 7 + local.get 7 + i32.const 4 + i32.add + local.get 7 + i32.load + select + local.set 7 + local.get 3 + i32.eqz + br_if 0 (;@5;) + local.get 6 + local.get 3 + i32.store + local.get 6 + i32.const 4 + i32.add + local.set 6 + end + local.get 9 + local.get 23 + local.get 9 + i32.load offset=44 + i32.add + local.tee 3 + i32.store offset=44 + local.get 14 + local.get 7 + local.get 13 + select + local.tee 8 + local.get 17 + i32.const 2 + i32.shl + i32.add + local.get 6 + local.get 17 + local.get 6 + local.get 8 + i32.sub + i32.const 2 + i32.shr_s + i32.lt_s + select + local.set 6 + local.get 3 + i32.const 0 + i32.lt_s + br_if 0 (;@4;) + end + end + i32.const 0 + local.set 8 + block ;; label = @3 + local.get 6 + local.get 7 + i32.le_u + br_if 0 (;@3;) + local.get 14 + local.get 7 + i32.sub + i32.const 2 + i32.shr_s + i32.const 9 + i32.mul + local.set 8 + i32.const 10 + local.set 3 + local.get 7 + i32.load + local.tee 12 + i32.const 10 + i32.lt_u + br_if 0 (;@3;) + loop ;; label = @4 + local.get 8 + i32.const 1 + i32.add + local.set 8 + local.get 12 + local.get 3 + i32.const 10 + i32.mul + local.tee 3 + i32.ge_u + br_if 0 (;@4;) + end + end + local.get 10 + i32.const 0 + local.get 8 + local.get 20 + i32.const 102 + i32.eq + select + i32.sub + local.get 20 + i32.const 103 + i32.eq + local.get 10 + i32.const 0 + i32.ne + i32.and + i32.sub + local.tee 3 + local.get 6 + local.get 14 + i32.sub + i32.const 2 + i32.shr_s + i32.const 9 + i32.mul + i32.const 9 + i32.sub + i32.lt_s + if ;; label = @3 + local.get 3 + i32.const 9216 + i32.add + local.tee 15 + i32.const 9 + i32.div_s + local.tee 12 + i32.const 2 + i32.shl + local.get 9 + i32.const 48 + i32.add + i32.const 4 + i32.or + local.get 9 + i32.const 340 + i32.add + local.get 11 + i32.const 0 + i32.lt_s + select + i32.add + i32.const 4096 + i32.sub + local.set 13 + i32.const 10 + local.set 3 + local.get 15 + local.get 12 + i32.const -9 + i32.mul + i32.add + local.tee 15 + i32.const 7 + i32.le_s + if ;; label = @4 + loop ;; label = @5 + local.get 3 + i32.const 10 + i32.mul + local.set 3 + local.get 15 + i32.const 1 + i32.add + local.tee 15 + i32.const 8 + i32.ne + br_if 0 (;@5;) + end + end + local.get 13 + i32.load + local.tee 15 + local.get 3 + i32.div_u + local.tee 12 + local.get 3 + i32.mul + local.set 11 + block ;; label = @4 + i32.const 0 + local.get 13 + i32.const 4 + i32.add + local.tee 17 + local.get 6 + i32.eq + local.get 15 + local.get 11 + i32.sub + local.tee 21 + select + br_if 0 (;@4;) + f64.const 0x1p-1 (;=0.5;) + f64.const 0x1p+0 (;=1;) + f64.const 0x1.8p+0 (;=1.5;) + local.get 21 + local.get 3 + i32.const 1 + i32.shr_u + local.tee 11 + i32.eq + select + f64.const 0x1.8p+0 (;=1.5;) + local.get 6 + local.get 17 + i32.eq + select + local.get 11 + local.get 21 + i32.gt_u + select + local.set 24 + f64.const 0x1.0000000000001p+53 (;=9.0072e+15;) + f64.const 0x1p+53 (;=9.0072e+15;) + local.get 12 + i32.const 1 + i32.and + select + local.set 1 + block ;; label = @5 + local.get 19 + br_if 0 (;@5;) + local.get 22 + i32.load8_u + i32.const 45 + i32.ne + br_if 0 (;@5;) + local.get 24 + f64.neg + local.set 24 + local.get 1 + f64.neg + local.set 1 + end + local.get 13 + local.get 15 + local.get 21 + i32.sub + local.tee 11 + i32.store + local.get 1 + local.get 24 + f64.add + local.get 1 + f64.eq + br_if 0 (;@4;) + local.get 13 + local.get 3 + local.get 11 + i32.add + local.tee 3 + i32.store + local.get 3 + i32.const 1000000000 + i32.ge_u + if ;; label = @5 + loop ;; label = @6 + local.get 13 + i32.const 0 + i32.store + local.get 13 + i32.const 4 + i32.sub + local.tee 13 + local.get 7 + i32.lt_u + if ;; label = @7 + local.get 7 + i32.const 4 + i32.sub + local.tee 7 + i32.const 0 + i32.store + end + local.get 13 + local.get 13 + i32.load + i32.const 1 + i32.add + local.tee 3 + i32.store + local.get 3 + i32.const 999999999 + i32.gt_u + br_if 0 (;@6;) + end + end + local.get 14 + local.get 7 + i32.sub + i32.const 2 + i32.shr_s + i32.const 9 + i32.mul + local.set 8 + i32.const 10 + local.set 3 + local.get 7 + i32.load + local.tee 11 + i32.const 10 + i32.lt_u + br_if 0 (;@4;) + loop ;; label = @5 + local.get 8 + i32.const 1 + i32.add + local.set 8 + local.get 11 + local.get 3 + i32.const 10 + i32.mul + local.tee 3 + i32.ge_u + br_if 0 (;@5;) + end + end + local.get 6 + local.get 13 + i32.const 4 + i32.add + local.tee 3 + i32.gt_u + local.set 11 + local.get 3 + local.get 6 + local.get 11 + select + local.set 6 + end + loop ;; label = @3 + local.get 6 + local.set 11 + local.get 6 + local.get 7 + i32.le_u + local.tee 12 + i32.eqz + if ;; label = @4 + local.get 11 + i32.const 4 + i32.sub + local.tee 6 + i32.load + i32.eqz + br_if 1 (;@3;) + end + end + block ;; label = @3 + local.get 20 + i32.const 103 + i32.ne + if ;; label = @4 + local.get 4 + i32.const 8 + i32.and + local.set 19 + br 1 (;@3;) + end + local.get 8 + i32.const -1 + i32.xor + i32.const -1 + local.get 8 + local.get 10 + i32.const 1 + local.get 10 + select + local.tee 6 + i32.lt_s + local.get 8 + i32.const -5 + i32.gt_s + i32.and + local.tee 3 + select + local.set 10 + local.get 6 + local.get 10 + i32.add + local.set 10 + local.get 5 + i32.const -1 + i32.const -2 + local.get 3 + select + i32.add + local.set 5 + local.get 4 + i32.const 8 + i32.and + local.tee 19 + br_if 0 (;@3;) + i32.const -9 + local.set 6 + block ;; label = @4 + local.get 12 + br_if 0 (;@4;) + local.get 11 + i32.const 4 + i32.sub + i32.load + local.tee 12 + i32.eqz + br_if 0 (;@4;) + i32.const 10 + local.set 15 + i32.const 0 + local.set 6 + local.get 12 + i32.const 10 + i32.rem_u + br_if 0 (;@4;) + loop ;; label = @5 + local.get 6 + local.tee 3 + i32.const 1 + i32.add + local.set 6 + local.get 12 + local.get 15 + i32.const 10 + i32.mul + local.tee 15 + i32.rem_u + i32.eqz + br_if 0 (;@5;) + end + local.get 3 + i32.const -1 + i32.xor + local.set 6 + end + local.get 11 + local.get 14 + i32.sub + i32.const 2 + i32.shr_s + i32.const 9 + i32.mul + local.set 3 + local.get 5 + i32.const -33 + i32.and + i32.const 70 + i32.eq + if ;; label = @4 + i32.const 0 + local.set 19 + local.get 3 + local.get 6 + i32.add + i32.const 9 + i32.sub + local.tee 3 + i32.const 0 + i32.gt_s + local.set 6 + local.get 10 + local.get 3 + i32.const 0 + local.get 6 + select + local.tee 3 + i32.lt_s + local.set 6 + local.get 10 + local.get 3 + local.get 6 + select + local.set 10 + br 1 (;@3;) + end + i32.const 0 + local.set 19 + local.get 6 + local.get 3 + local.get 8 + i32.add + i32.add + i32.const 9 + i32.sub + local.tee 3 + i32.const 0 + i32.gt_s + local.set 6 + local.get 10 + local.get 3 + i32.const 0 + local.get 6 + select + local.tee 3 + i32.lt_s + local.set 6 + local.get 10 + local.get 3 + local.get 6 + select + local.set 10 + end + local.get 8 + i32.const 0 + local.get 8 + i32.const 0 + i32.gt_s + select + local.set 6 + local.get 0 + i32.const 32 + local.get 2 + local.get 5 + i32.const -33 + i32.and + local.tee 12 + i32.const 70 + i32.ne + if (result i32) ;; label = @3 + local.get 8 + local.get 8 + i32.const 31 + i32.shr_s + local.tee 3 + i32.add + local.set 6 + local.get 16 + local.get 3 + local.get 6 + i32.xor + i64.extend_i32_u + local.get 16 + call 28 + local.tee 6 + i32.sub + i32.const 1 + i32.le_s + if ;; label = @4 + loop ;; label = @5 + local.get 6 + i32.const 1 + i32.sub + local.tee 6 + i32.const 48 + i32.store8 + local.get 16 + local.get 6 + i32.sub + i32.const 2 + i32.lt_s + br_if 0 (;@5;) + end + end + local.get 6 + i32.const 2 + i32.sub + local.tee 17 + local.get 5 + i32.store8 + local.get 6 + i32.const 1 + i32.sub + i32.const 45 + i32.const 43 + local.get 8 + i32.const 0 + i32.lt_s + select + i32.store8 + local.get 16 + local.get 17 + i32.sub + else + local.get 6 + end + local.get 10 + local.get 18 + i32.add + local.get 10 + local.get 19 + i32.or + local.tee 21 + i32.const 0 + i32.ne + i32.add + i32.add + i32.const 1 + i32.add + local.tee 13 + local.get 4 + call 23 + local.get 0 + local.get 22 + local.get 18 + call 22 + local.get 0 + i32.const 48 + local.get 2 + local.get 13 + local.get 4 + i32.const 65536 + i32.xor + call 23 + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + local.get 12 + i32.const 70 + i32.eq + if ;; label = @6 + local.get 9 + i32.const 16 + i32.add + i32.const 8 + i32.or + local.set 3 + local.get 9 + i32.const 16 + i32.add + i32.const 9 + i32.or + local.set 8 + local.get 14 + local.get 7 + local.get 7 + local.get 14 + i32.gt_u + select + local.tee 5 + local.set 7 + loop ;; label = @7 + local.get 7 + i64.load32_u + local.get 8 + call 28 + local.set 6 + block ;; label = @8 + local.get 5 + local.get 7 + i32.ne + if ;; label = @9 + local.get 9 + i32.const 16 + i32.add + local.get 6 + i32.ge_u + br_if 1 (;@8;) + loop ;; label = @10 + local.get 6 + i32.const 1 + i32.sub + local.tee 6 + i32.const 48 + i32.store8 + local.get 9 + i32.const 16 + i32.add + local.get 6 + i32.lt_u + br_if 0 (;@10;) + end + br 1 (;@8;) + end + local.get 6 + local.get 8 + i32.ne + br_if 0 (;@8;) + local.get 9 + i32.const 48 + i32.store8 offset=24 + local.get 3 + local.set 6 + end + local.get 0 + local.get 6 + local.get 8 + local.get 6 + i32.sub + call 22 + local.get 14 + local.get 7 + i32.const 4 + i32.add + local.tee 7 + i32.ge_u + br_if 0 (;@7;) + end + local.get 21 + if ;; label = @7 + local.get 0 + i32.const 2307 + i32.const 1 + call 22 + end + local.get 7 + local.get 11 + i32.ge_u + br_if 1 (;@5;) + local.get 10 + i32.const 1 + i32.lt_s + br_if 1 (;@5;) + loop ;; label = @7 + local.get 7 + i64.load32_u + local.get 8 + call 28 + local.tee 6 + local.get 9 + i32.const 16 + i32.add + i32.gt_u + if ;; label = @8 + loop ;; label = @9 + local.get 6 + i32.const 1 + i32.sub + local.tee 6 + i32.const 48 + i32.store8 + local.get 6 + local.get 9 + i32.const 16 + i32.add + i32.gt_u + br_if 0 (;@9;) + end + end + local.get 0 + local.get 6 + local.get 10 + i32.const 9 + local.get 10 + i32.const 9 + i32.lt_s + select + call 22 + local.get 10 + i32.const 9 + i32.sub + local.set 6 + local.get 7 + i32.const 4 + i32.add + local.tee 7 + local.get 11 + i32.ge_u + br_if 3 (;@4;) + local.get 10 + i32.const 9 + i32.gt_s + local.set 3 + local.get 6 + local.set 10 + local.get 3 + br_if 0 (;@7;) + end + br 2 (;@4;) + end + block ;; label = @6 + local.get 10 + i32.const 0 + i32.lt_s + br_if 0 (;@6;) + local.get 11 + local.get 7 + i32.const 4 + i32.add + local.get 7 + local.get 11 + i32.lt_u + select + local.set 5 + local.get 9 + i32.const 16 + i32.add + i32.const 8 + i32.or + local.set 3 + local.get 9 + i32.const 16 + i32.add + i32.const 9 + i32.or + local.set 11 + local.get 7 + local.set 8 + loop ;; label = @7 + local.get 11 + local.get 8 + i64.load32_u + local.get 11 + call 28 + local.tee 6 + i32.eq + if ;; label = @8 + local.get 9 + i32.const 48 + i32.store8 offset=24 + local.get 3 + local.set 6 + end + block ;; label = @8 + local.get 7 + local.get 8 + i32.ne + if ;; label = @9 + local.get 9 + i32.const 16 + i32.add + local.get 6 + i32.ge_u + br_if 1 (;@8;) + loop ;; label = @10 + local.get 6 + i32.const 1 + i32.sub + local.tee 6 + i32.const 48 + i32.store8 + local.get 9 + i32.const 16 + i32.add + local.get 6 + i32.lt_u + br_if 0 (;@10;) + end + br 1 (;@8;) + end + local.get 0 + local.get 6 + i32.const 1 + call 22 + local.get 6 + i32.const 1 + i32.add + local.set 6 + local.get 19 + i32.eqz + i32.const 0 + local.get 10 + i32.const 1 + i32.lt_s + select + br_if 0 (;@8;) + local.get 0 + i32.const 2307 + i32.const 1 + call 22 + end + local.get 6 + local.set 14 + local.get 10 + local.get 11 + local.get 6 + i32.sub + local.tee 6 + i32.gt_s + local.set 20 + local.get 0 + local.get 14 + local.get 6 + local.get 10 + local.get 20 + select + call 22 + local.get 10 + local.get 6 + i32.sub + local.set 10 + local.get 8 + i32.const 4 + i32.add + local.tee 8 + local.get 5 + i32.ge_u + br_if 1 (;@6;) + local.get 10 + i32.const -1 + i32.gt_s + br_if 0 (;@7;) + end + end + local.get 0 + i32.const 48 + local.get 10 + i32.const 18 + i32.add + i32.const 18 + i32.const 0 + call 23 + local.get 0 + local.get 17 + local.get 16 + local.get 17 + i32.sub + call 22 + br 2 (;@3;) + end + local.get 10 + local.set 6 + end + local.get 0 + i32.const 48 + local.get 6 + i32.const 9 + i32.add + i32.const 9 + i32.const 0 + call 23 + end + br 1 (;@1;) + end + local.get 22 + i32.const 9 + i32.add + local.get 22 + local.get 5 + i32.const 32 + i32.and + local.tee 11 + select + local.set 10 + block ;; label = @2 + local.get 3 + i32.const 11 + i32.gt_u + br_if 0 (;@2;) + i32.const 12 + local.get 3 + i32.sub + local.tee 6 + i32.eqz + br_if 0 (;@2;) + f64.const 0x1p+3 (;=8;) + local.set 24 + loop ;; label = @3 + local.get 24 + f64.const 0x1p+4 (;=16;) + f64.mul + local.set 24 + local.get 6 + i32.const 1 + i32.sub + local.tee 6 + br_if 0 (;@3;) + end + local.get 10 + i32.load8_u + i32.const 45 + i32.eq + if ;; label = @3 + local.get 24 + local.get 1 + f64.neg + local.get 24 + f64.sub + f64.add + f64.neg + local.set 1 + br 1 (;@2;) + end + local.get 1 + local.get 24 + f64.add + local.get 24 + f64.sub + local.set 1 + end + local.get 18 + i32.const 2 + i32.or + local.set 14 + local.get 9 + i32.load offset=44 + local.tee 8 + i32.const 31 + i32.shr_s + local.tee 6 + local.get 8 + i32.add + local.set 7 + local.get 16 + local.get 6 + local.get 7 + i32.xor + i64.extend_i32_u + local.get 16 + call 28 + local.tee 6 + i32.eq + if ;; label = @2 + local.get 9 + i32.const 48 + i32.store8 offset=15 + local.get 9 + i32.const 15 + i32.add + local.set 6 + end + local.get 6 + i32.const 2 + i32.sub + local.tee 12 + local.get 5 + i32.const 15 + i32.add + i32.store8 + local.get 6 + i32.const 1 + i32.sub + i32.const 45 + i32.const 43 + local.get 8 + i32.const 0 + i32.lt_s + select + i32.store8 + local.get 4 + i32.const 8 + i32.and + local.set 8 + local.get 9 + i32.const 16 + i32.add + local.set 7 + loop ;; label = @2 + local.get 7 + local.set 5 + local.get 7 + local.get 11 + block (result i32) ;; label = @3 + local.get 1 + f64.abs + f64.const 0x1p+31 (;=2.14748e+09;) + f64.lt + if ;; label = @4 + local.get 1 + i32.trunc_f64_s + br 1 (;@3;) + end + i32.const -2147483648 + end + local.tee 6 + i32.const 2256 + i32.add + i32.load8_u + i32.or + i32.store8 + local.get 1 + local.get 6 + f64.convert_i32_s + f64.sub + f64.const 0x1p+4 (;=16;) + f64.mul + local.set 1 + block ;; label = @3 + local.get 5 + i32.const 1 + i32.add + local.tee 7 + local.get 9 + i32.const 16 + i32.add + i32.sub + i32.const 1 + i32.ne + br_if 0 (;@3;) + block ;; label = @4 + local.get 8 + br_if 0 (;@4;) + local.get 3 + i32.const 0 + i32.gt_s + br_if 0 (;@4;) + local.get 1 + f64.const 0x0p+0 (;=0;) + f64.eq + br_if 1 (;@3;) + end + local.get 5 + i32.const 46 + i32.store8 offset=1 + local.get 5 + i32.const 2 + i32.add + local.set 7 + end + local.get 1 + f64.const 0x0p+0 (;=0;) + f64.ne + br_if 0 (;@2;) + end + local.get 14 + local.set 5 + local.get 0 + i32.const 32 + local.get 2 + local.get 5 + block (result i32) ;; label = @2 + block ;; label = @3 + local.get 3 + i32.eqz + br_if 0 (;@3;) + local.get 7 + local.get 9 + i32.sub + i32.const 18 + i32.sub + local.get 3 + i32.ge_s + br_if 0 (;@3;) + local.get 3 + local.get 16 + i32.add + local.get 12 + i32.sub + i32.const 2 + i32.add + br 1 (;@2;) + end + local.get 7 + local.get 16 + local.get 9 + i32.const 16 + i32.add + i32.sub + local.get 12 + i32.sub + i32.add + end + local.tee 11 + i32.add + local.tee 13 + local.get 4 + call 23 + local.get 0 + local.get 10 + local.get 14 + call 22 + local.get 0 + i32.const 48 + local.get 2 + local.get 13 + local.get 4 + i32.const 65536 + i32.xor + call 23 + local.get 0 + local.get 9 + i32.const 16 + i32.add + local.get 7 + local.get 9 + i32.const 16 + i32.add + i32.sub + local.tee 5 + call 22 + local.get 0 + i32.const 48 + local.get 11 + local.get 5 + local.get 16 + local.get 12 + i32.sub + local.tee 3 + i32.add + i32.sub + i32.const 0 + i32.const 0 + call 23 + local.get 0 + local.get 12 + local.get 3 + call 22 + end + local.get 0 + i32.const 32 + local.get 2 + local.get 13 + local.get 4 + i32.const 8192 + i32.xor + call 23 + local.get 9 + i32.const 560 + i32.add + global.set 0 + local.get 2 + local.get 13 + local.get 2 + local.get 13 + i32.gt_s + select) + (func (;65;) (type 2) (param i32 i32) (result i32) + (local i32 i32) + local.get 1 + i32.const 0 + i32.ne + local.set 2 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 3 + i32.and + i32.eqz + br_if 0 (;@3;) + loop ;; label = @4 + local.get 0 + i32.load8_u + i32.eqz + br_if 2 (;@2;) + local.get 0 + i32.const 1 + i32.add + local.set 0 + local.get 1 + i32.const 1 + i32.sub + local.tee 1 + i32.const 0 + i32.ne + local.set 2 + local.get 1 + i32.eqz + br_if 1 (;@3;) + local.get 0 + i32.const 3 + i32.and + br_if 0 (;@4;) + end + end + local.get 2 + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.load8_u + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.const 4 + i32.lt_u + br_if 0 (;@3;) + loop ;; label = @4 + local.get 0 + i32.load + local.tee 2 + i32.const -1 + i32.xor + local.set 3 + local.get 3 + local.get 2 + i32.const 16843009 + i32.sub + i32.and + i32.const -2139062144 + i32.and + br_if 1 (;@3;) + local.get 0 + i32.const 4 + i32.add + local.set 0 + local.get 1 + i32.const 4 + i32.sub + local.tee 1 + i32.const 3 + i32.gt_u + br_if 0 (;@4;) + end + end + local.get 1 + i32.eqz + br_if 1 (;@1;) + end + loop ;; label = @2 + local.get 0 + i32.load8_u + i32.eqz + if ;; label = @3 + local.get 0 + return + end + local.get 0 + i32.const 1 + i32.add + local.set 0 + local.get 1 + i32.const 1 + i32.sub + local.tee 1 + br_if 0 (;@2;) + end + end + i32.const 0) + (func (;66;) (type 19) (param i64 i32) (result i32) + local.get 0 + i64.eqz + i32.eqz + if ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.const 1 + i32.sub + local.tee 1 + local.get 0 + i32.wrap_i64 + i32.const 7 + i32.and + i32.const 48 + i32.or + i32.store8 + local.get 0 + i64.const 3 + i64.shr_u + local.tee 0 + i64.const 0 + i64.ne + br_if 0 (;@2;) + end + end + local.get 1) + (func (;67;) (type 23) (param i64 i32 i32) (result i32) + local.get 0 + i64.eqz + i32.eqz + if ;; label = @1 + loop ;; label = @2 + local.get 1 + i32.const 1 + i32.sub + local.tee 1 + local.get 0 + i32.wrap_i64 + i32.const 15 + i32.and + i32.const 2256 + i32.add + i32.load8_u + local.get 2 + i32.or + i32.store8 + local.get 0 + i64.const 4 + i64.shr_u + local.tee 0 + i64.const 0 + i64.ne + br_if 0 (;@2;) + end + end + local.get 1) + (func (;68;) (type 2) (param i32 i32) (result i32) + block ;; label = @1 + local.get 0 + if (result i32) ;; label = @2 + local.get 1 + i32.const 127 + i32.le_u + br_if 1 (;@1;) + block ;; label = @3 + i32.const 2884 + i32.load + i32.load + i32.eqz + if ;; label = @4 + local.get 1 + i32.const -128 + i32.and + i32.const 57216 + i32.eq + br_if 3 (;@1;) + br 1 (;@3;) + end + local.get 1 + i32.const 2047 + i32.le_u + if ;; label = @4 + local.get 0 + local.get 1 + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=1 + local.get 0 + local.get 1 + i32.const 6 + i32.shr_u + i32.const 192 + i32.or + i32.store8 + i32.const 2 + return + end + local.get 1 + i32.const 55296 + i32.ge_u + i32.const 0 + local.get 1 + i32.const -8192 + i32.and + i32.const 57344 + i32.ne + select + i32.eqz + if ;; label = @4 + local.get 0 + local.get 1 + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=2 + local.get 0 + local.get 1 + i32.const 12 + i32.shr_u + i32.const 224 + i32.or + i32.store8 + local.get 0 + local.get 1 + i32.const 6 + i32.shr_u + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=1 + i32.const 3 + return + end + local.get 1 + i32.const 65536 + i32.sub + i32.const 1048575 + i32.le_u + if ;; label = @4 + local.get 0 + local.get 1 + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=3 + local.get 0 + local.get 1 + i32.const 18 + i32.shr_u + i32.const 240 + i32.or + i32.store8 + local.get 0 + local.get 1 + i32.const 6 + i32.shr_u + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=2 + local.get 0 + local.get 1 + i32.const 12 + i32.shr_u + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=1 + i32.const 4 + return + end + end + i32.const 2992 + i32.const 25 + i32.store + i32.const -1 + else + i32.const 1 + end + return + end + local.get 0 + local.get 1 + i32.store8 + i32.const 1) + (func (;69;) (type 1) (param i32) (result i32) + (local i32 i32) + local.get 0 + i32.load8_u offset=74 + local.tee 1 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + local.get 1 + local.get 2 + i32.or + i32.store8 offset=74 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=28 + i32.gt_u + if ;; label = @1 + local.get 0 + i32.const 0 + i32.const 0 + local.get 0 + i32.load offset=36 + call_indirect (type 0) + drop + end + local.get 0 + i32.const 0 + i32.store offset=28 + local.get 0 + i64.const 0 + i64.store offset=16 + local.get 0 + i32.load + local.tee 1 + i32.const 4 + i32.and + if ;; label = @1 + local.get 0 + local.get 1 + i32.const 32 + i32.or + i32.store + i32.const -1 + return + end + local.get 0 + local.get 0 + i32.load offset=44 + local.get 0 + i32.load offset=48 + i32.add + local.tee 2 + i32.store offset=8 + local.get 0 + local.get 2 + i32.store offset=4 + local.get 1 + i32.const 27 + i32.shl + i32.const 31 + i32.shr_s) + (func (;70;) (type 2) (param i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + block ;; label = @1 + i32.const 2456 + local.get 1 + i32.load8_s + call 30 + i32.eqz + if ;; label = @2 + i32.const 2992 + i32.const 28 + i32.store + br 1 (;@1;) + end + i32.const 1176 + call 25 + local.tee 2 + i32.eqz + if ;; label = @2 + i32.const 0 + local.set 2 + br 1 (;@1;) + end + local.get 2 + i32.const 0 + i32.const 144 + call 31 + drop + local.get 1 + i32.const 43 + call 30 + i32.eqz + if ;; label = @2 + local.get 2 + i32.const 8 + i32.const 4 + local.get 1 + i32.load8_u + i32.const 114 + i32.eq + select + i32.store + end + block ;; label = @2 + local.get 1 + i32.load8_u + i32.const 97 + i32.ne + if ;; label = @3 + local.get 2 + i32.load + local.set 1 + br 1 (;@2;) + end + local.get 0 + i32.const 3 + i32.const 0 + call 3 + local.tee 1 + i32.const 1024 + i32.and + i32.eqz + if ;; label = @3 + local.get 3 + local.get 1 + i32.const 1024 + i32.or + i32.store offset=16 + local.get 0 + i32.const 4 + local.get 3 + i32.const 16 + i32.add + call 3 + drop + end + local.get 2 + local.get 2 + i32.load + i32.const 128 + i32.or + local.tee 1 + i32.store + end + local.get 2 + i32.const 255 + i32.store8 offset=75 + local.get 2 + i32.const 1024 + i32.store offset=48 + local.get 2 + local.get 0 + i32.store offset=60 + local.get 2 + local.get 2 + i32.const 152 + i32.add + i32.store offset=44 + block ;; label = @2 + local.get 1 + i32.const 8 + i32.and + br_if 0 (;@2;) + local.get 3 + local.get 3 + i32.const 24 + i32.add + i32.store + local.get 0 + i32.const 21523 + local.get 3 + call 9 + br_if 0 (;@2;) + local.get 2 + i32.const 10 + i32.store8 offset=75 + end + local.get 2 + i32.const 3 + i32.store offset=40 + local.get 2 + i32.const 4 + i32.store offset=36 + local.get 2 + i32.const 5 + i32.store offset=32 + local.get 2 + i32.const 6 + i32.store offset=12 + i32.const 3008 + i32.load + i32.eqz + if ;; label = @2 + local.get 2 + i32.const -1 + i32.store offset=76 + end + local.get 2 + i32.const 3000 + i32.load + local.tee 0 + i32.store offset=56 + local.get 0 + if ;; label = @2 + local.get 0 + local.get 2 + i32.store offset=52 + end + i32.const 3000 + local.get 2 + i32.store + end + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 2) + (func (;71;) (type 1) (param i32) (result i32) + (local i32 i32) + i32.const 2 + local.set 1 + block (result i32) ;; label = @1 + local.get 0 + i32.const 43 + call 30 + i32.eqz + if ;; label = @2 + local.get 0 + i32.load8_u + i32.const 114 + i32.ne + local.set 1 + end + local.get 1 + i32.const 128 + i32.or + end + local.get 1 + local.get 0 + i32.const 120 + call 30 + select + local.tee 1 + i32.const 524288 + i32.or + local.get 1 + local.get 0 + i32.const 101 + call 30 + select + local.tee 1 + i32.const 64 + i32.or + local.set 2 + local.get 1 + local.get 2 + local.get 0 + i32.load8_u + local.tee 0 + i32.const 114 + i32.eq + select + local.tee 1 + i32.const 512 + i32.or + local.get 1 + local.get 0 + i32.const 119 + i32.eq + select + local.tee 1 + i32.const 1024 + i32.or + local.get 1 + local.get 0 + i32.const 97 + i32.eq + select) + (func (;72;) (type 1) (param i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 1 + global.set 0 + i32.const 1 + local.set 2 + local.get 0 + local.get 1 + i32.const 8 + i32.add + call 14 + local.tee 0 + if (result i32) ;; label = @1 + i32.const 2992 + local.get 0 + i32.store + i32.const 0 + else + local.get 2 + end + local.set 0 + local.get 1 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func (;73;) (type 4) (param i32 i32) + (local i32 i32 i32) + loop ;; label = @1 + local.get 0 + local.get 2 + i32.add + local.tee 3 + local.get 2 + i32.const 1732 + i32.add + i32.load8_u + i32.store8 + local.get 2 + i32.const 14 + i32.ne + local.set 4 + local.get 2 + i32.const 1 + i32.add + local.set 2 + local.get 4 + br_if 0 (;@1;) + end + local.get 1 + if ;; label = @1 + i32.const 14 + local.set 2 + local.get 1 + local.set 3 + loop ;; label = @2 + local.get 2 + i32.const 1 + i32.add + local.set 2 + local.get 3 + i32.const 9 + i32.gt_u + local.set 4 + local.get 3 + i32.const 10 + i32.div_u + local.set 3 + local.get 4 + br_if 0 (;@2;) + end + local.get 0 + local.get 2 + i32.add + i32.const 0 + i32.store8 + loop ;; label = @2 + local.get 2 + i32.const 1 + i32.sub + local.tee 2 + local.get 0 + i32.add + local.get 1 + i32.const 10 + i32.div_u + local.tee 3 + i32.const -10 + i32.mul + local.get 1 + i32.add + i32.const 48 + i32.or + i32.store8 + local.get 1 + i32.const 9 + i32.gt_u + local.set 4 + local.get 3 + local.set 1 + local.get 4 + br_if 0 (;@2;) + end + return + end + local.get 3 + i32.const 48 + i32.store8 + local.get 0 + i32.const 0 + i32.store8 offset=15) + (func (;74;) (type 11) (result i32) + i32.const 2992) + (func (;75;) (type 1) (param i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 1 + global.set 0 + local.get 1 + i32.const 0 + i32.store + local.get 0 + i32.const 622592 + local.get 1 + call 5 + local.tee 0 + i32.const -4095 + i32.ge_u + if ;; label = @1 + i32.const 2992 + i32.const 0 + local.get 0 + i32.sub + i32.store + i32.const -1 + local.set 0 + end + local.get 1 + i32.const 16 + i32.add + global.set 0 + local.get 0) + (func (;76;) (type 3) (param i32) + (local i32) + local.get 0 + call 1 + local.tee 0 + i32.const 27 + i32.eq + local.set 1 + i32.const 0 + local.get 0 + local.get 1 + select + local.tee 0 + if ;; label = @1 + i32.const 2992 + local.get 0 + i32.store + end) + (func (;77;) (type 3) (param i32) + local.get 0 + i32.load offset=4 + call 27 + drop) + (func (;78;) (type 0) (param i32 i32 i32) (result i32) + (local i32) + local.get 1 + local.set 3 + local.get 3 + block (result i32) ;; label = @1 + local.get 2 + i32.load offset=76 + i32.const -1 + i32.le_s + if ;; label = @2 + local.get 0 + local.get 1 + local.get 2 + call 40 + br 1 (;@1;) + end + local.get 0 + local.get 1 + local.get 2 + call 40 + end + local.tee 0 + i32.eq + if ;; label = @1 + local.get 1 + return + end + local.get 0) + (func (;79;) (type 3) (param i32) + local.get 0 + i32.const 1584 + i32.store + local.get 0 + i32.load offset=4 + call 53 + local.get 0 + call 21) + (func (;80;) (type 10) (param i32) (result i64) + (local i64) + block (result i32) ;; label = @1 + block (result i64) ;; label = @2 + local.get 0 + i32.load offset=4 + local.tee 0 + i32.load offset=76 + i32.const -1 + i32.le_s + if ;; label = @3 + local.get 0 + call 48 + br 1 (;@2;) + end + local.get 0 + call 48 + end + local.tee 1 + i64.const 2147483648 + i64.ge_s + if ;; label = @2 + i32.const 2992 + i32.const 61 + i32.store + i32.const -1 + br 1 (;@1;) + end + local.get 1 + i32.wrap_i64 + end + i64.extend_i32_s) + (func (;81;) (type 2) (param i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 2 + global.set 0 + block (result i32) ;; label = @1 + local.get 0 + local.get 1 + call 10 + local.tee 3 + i32.const -8 + i32.ne + if ;; label = @2 + local.get 3 + i32.const -4095 + i32.ge_u + if (result i32) ;; label = @3 + i32.const 2992 + i32.const 0 + local.get 3 + i32.sub + i32.store + i32.const -1 + else + local.get 3 + end + br 1 (;@1;) + end + local.get 0 + call 72 + i32.eqz + if ;; label = @2 + i32.const 2992 + i32.const 8 + i32.store + i32.const -1 + br 1 (;@1;) + end + local.get 2 + local.get 0 + call 73 + local.get 2 + local.get 1 + call 4 + local.tee 0 + i32.const -4095 + i32.ge_u + if (result i32) ;; label = @2 + i32.const 2992 + i32.const 0 + local.get 0 + i32.sub + i32.store + i32.const -1 + else + local.get 0 + end + end + local.set 0 + local.get 2 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func (;82;) (type 10) (param i32) (result i64) + (local i32 i64) + global.get 0 + i32.const 96 + i32.sub + local.tee 1 + global.set 0 + local.get 0 + i32.load offset=4 + call 27 + drop + block ;; label = @1 + local.get 0 + i32.load offset=4 + local.tee 0 + i32.load offset=76 + i32.const 0 + i32.lt_s + br_if 0 (;@1;) + end + local.get 0 + i32.load offset=60 + local.get 1 + i32.const 8 + i32.add + call 81 + local.set 0 + local.get 1 + i64.load offset=48 + local.set 2 + local.get 1 + i32.const 96 + i32.add + global.set 0 + i64.const 0 + local.get 2 + local.get 0 + i32.const 0 + i32.lt_s + select) + (func (;83;) (type 15) (param i32 i64) (result i32) + local.get 0 + i32.load8_u offset=8 + i32.eqz + if ;; label = @1 + i32.const 0 + return + end + local.get 0 + i32.load offset=4 + call 27 + drop + local.get 0 + i32.load offset=4 + i32.const 0 + local.get 1 + i32.wrap_i64 + i32.sub + i32.const 2 + call 34 + i32.const -1 + i32.gt_s) + (func (;84;) (type 15) (param i32 i64) (result i32) + local.get 0 + i32.load8_u offset=8 + i32.eqz + if ;; label = @1 + i32.const 0 + return + end + local.get 0 + i32.load offset=4 + call 27 + drop + local.get 0 + i32.load offset=4 + local.get 1 + i32.wrap_i64 + i32.const 1 + call 34 + i32.const -1 + i32.gt_s) + (func (;85;) (type 15) (param i32 i64) (result i32) + local.get 0 + i32.load8_u offset=8 + i32.eqz + if ;; label = @1 + i32.const 0 + return + end + local.get 0 + i32.load offset=4 + call 27 + drop + local.get 0 + i32.load offset=4 + local.get 1 + i32.wrap_i64 + i32.const 0 + call 34 + i32.const -1 + i32.gt_s) + (func (;86;) (type 1) (param i32) (result i32) + local.get 0 + i32.load8_u offset=10) + (func (;87;) (type 1) (param i32) (result i32) + local.get 0 + i32.load8_u offset=9) + (func (;88;) (type 0) (param i32 i32 i32) (result i32) + local.get 0 + i32.load8_u offset=9 + if (result i32) ;; label = @1 + i32.const 0 + else + local.get 1 + local.get 2 + local.get 0 + i32.load offset=4 + call 78 + end) + (func (;89;) (type 0) (param i32 i32 i32) (result i32) + (local i32 i32 i32) + local.get 2 + i32.load offset=76 + drop + local.get 2 + local.get 2 + i32.load8_u offset=74 + local.tee 3 + i32.const 1 + i32.sub + local.get 3 + i32.or + i32.store8 offset=74 + local.get 1 + local.set 5 + local.get 2 + i32.load offset=8 + local.get 2 + i32.load offset=4 + local.tee 4 + i32.sub + local.tee 3 + i32.const 1 + i32.ge_s + if ;; label = @1 + local.get 0 + local.get 4 + local.get 3 + local.get 1 + local.get 1 + local.get 3 + i32.gt_u + select + local.tee 3 + call 26 + drop + local.get 2 + local.get 3 + local.get 2 + i32.load offset=4 + i32.add + i32.store offset=4 + local.get 1 + local.get 3 + i32.sub + local.set 5 + local.get 0 + local.get 3 + i32.add + local.set 0 + end + local.get 5 + local.tee 3 + if ;; label = @1 + loop ;; label = @2 + block ;; label = @3 + local.get 2 + call 69 + i32.eqz + if ;; label = @4 + local.get 2 + local.get 0 + local.get 3 + local.get 2 + i32.load offset=32 + call_indirect (type 0) + local.tee 4 + i32.const 1 + i32.add + i32.const 1 + i32.gt_u + br_if 1 (;@3;) + end + local.get 1 + local.get 3 + i32.sub + return + end + local.get 0 + local.get 4 + i32.add + local.set 0 + local.get 3 + local.get 4 + i32.sub + local.tee 3 + br_if 0 (;@2;) + end + end + local.get 1) + (func (;90;) (type 0) (param i32 i32 i32) (result i32) + local.get 0 + i32.load8_u offset=10 + if (result i32) ;; label = @1 + i32.const 0 + else + local.get 1 + local.get 2 + local.get 0 + i32.load offset=4 + call 89 + end) + (func (;91;) (type 3) (param i32) + (local i32) + local.get 0 + i32.const 1416 + i32.store + local.get 0 + i32.load offset=4 + local.tee 1 + i32.load + call 76 + local.get 1 + call 21 + local.get 0 + call 21) + (func (;92;) (type 1) (param i32) (result i32) + (local i32 i32) + block ;; label = @1 + local.get 0 + i32.load offset=16 + local.tee 2 + local.get 0 + i32.load offset=20 + i32.ge_s + if ;; label = @2 + i32.const 0 + local.set 2 + local.get 0 + i32.load + local.get 0 + i32.const 32 + i32.add + i32.const 2048 + call 12 + local.tee 1 + i32.const 0 + i32.le_s + if ;; label = @3 + i32.const 0 + local.set 0 + local.get 1 + i32.const -44 + i32.eq + br_if 2 (;@1;) + local.get 1 + i32.eqz + br_if 2 (;@1;) + i32.const 2992 + i32.const 0 + local.get 1 + i32.sub + i32.store + i32.const 0 + return + end + local.get 0 + local.get 1 + i32.store offset=20 + end + local.get 0 + local.get 0 + local.get 2 + i32.add + local.tee 1 + i32.load16_u offset=48 + local.get 2 + i32.add + i32.store offset=16 + local.get 0 + local.get 1 + i64.load offset=40 + i64.store offset=8 + local.get 1 + i32.const 32 + i32.add + local.set 0 + end + local.get 0) + (func (;93;) (type 2) (param i32 i32) (result i32) + local.get 0 + i32.load offset=4 + call 92 + local.tee 0 + if ;; label = @1 + local.get 1 + local.get 0 + i32.const 19 + i32.add + i32.store + end + local.get 0 + i32.const 0 + i32.ne) + (func (;94;) (type 4) (param i32 i32) + local.get 0 + local.get 1 + i32.store offset=4) + (func (;95;) (type 1) (param i32) (result i32) + (local i32 i32) + local.get 0 + i32.load8_u offset=74 + local.tee 1 + i32.const 1 + i32.sub + local.set 2 + local.get 0 + local.get 1 + local.get 2 + i32.or + i32.store8 offset=74 + local.get 0 + i32.load + local.tee 1 + i32.const 8 + i32.and + if ;; label = @1 + local.get 0 + local.get 1 + i32.const 32 + i32.or + i32.store + i32.const -1 + return + end + local.get 0 + i64.const 0 + i64.store offset=4 align=4 + local.get 0 + local.get 0 + i32.load offset=44 + local.tee 1 + i32.store offset=28 + local.get 0 + local.get 1 + i32.store offset=20 + local.get 0 + local.get 0 + i32.load offset=48 + local.get 1 + i32.add + i32.store offset=16 + i32.const 0) + (func (;96;) (type 2) (param i32 i32) (result i32) + block ;; label = @1 + local.get 1 + i32.const 48 + i32.sub + i32.const 10 + i32.lt_u + br_if 0 (;@1;) + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.const 32 + i32.sub + br_table 2 (;@1;) 1 (;@2;) 1 (;@2;) 1 (;@2;) 1 (;@2;) 1 (;@2;) 1 (;@2;) 2 (;@1;) 0 (;@3;) + end + local.get 1 + i32.const 95 + i32.eq + br_if 1 (;@1;) + end + local.get 1 + i32.const -33 + i32.and + i32.const 65 + i32.sub + i32.const 26 + i32.lt_u + return + end + i32.const 1) + (func (;97;) (type 0) (param i32 i32 i32) (result i32) + (local i32 i32 i32 i32) + block ;; label = @1 + local.get 2 + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 1 + i32.sub + local.set 5 + i32.const 1 + local.set 4 + i32.const 0 + local.set 0 + loop ;; label = @2 + block ;; label = @3 + local.get 0 + local.get 1 + i32.add + i32.load8_u + local.tee 3 + i32.const 48 + i32.sub + i32.const 255 + i32.and + i32.const 10 + i32.lt_u + br_if 0 (;@3;) + local.get 3 + i32.const 33 + i32.sub + local.tee 6 + i32.const 13 + i32.le_u + i32.const 0 + i32.const 1 + local.get 6 + i32.shl + i32.const 8257 + i32.and + select + br_if 0 (;@3;) + local.get 3 + i32.const 95 + i32.eq + br_if 0 (;@3;) + local.get 3 + i32.const 32 + i32.eq + local.get 0 + i32.const 0 + i32.ne + i32.and + local.get 0 + local.get 5 + i32.ne + i32.and + br_if 0 (;@3;) + local.get 3 + i32.const 223 + i32.and + i32.const 65 + i32.sub + i32.const 255 + i32.and + i32.const 25 + i32.gt_u + br_if 2 (;@1;) + end + local.get 2 + local.get 0 + i32.const 1 + i32.add + local.tee 0 + i32.gt_u + local.set 4 + local.get 0 + local.get 2 + i32.ne + br_if 0 (;@2;) + end + end + local.get 4 + i32.const -1 + i32.xor + i32.const 1 + i32.and) + (func (;98;) (type 1) (param i32) (result i32) + (local i32) + block ;; label = @1 + local.get 0 + call 75 + local.tee 0 + i32.const 0 + i32.ge_s + if ;; label = @2 + i32.const 2080 + call 25 + local.tee 1 + i32.eqz + br_if 1 (;@1;) + local.get 1 + i32.const 4 + i32.sub + i32.load8_u + i32.const 3 + i32.and + if ;; label = @3 + local.get 1 + i32.const 0 + i32.const 2080 + call 31 + drop + end + local.get 1 + local.get 0 + i32.store + end + local.get 1 + return + end + local.get 0 + call 1 + drop + i32.const 0) + (func (;99;) (type 7) (param i32 i32 i32 i32) (result i32) + (local i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 4 + global.set 0 + local.get 4 + i32.const 0 + i32.store offset=8 + local.get 4 + i64.const 0 + i64.store + block ;; label = @1 + local.get 0 + local.get 1 + local.get 2 + local.get 3 + local.get 4 + call 35 + i32.eqz + br_if 0 (;@1;) + local.get 4 + i32.load + local.get 4 + local.get 4 + i32.load8_s offset=11 + i32.const 0 + i32.lt_s + select + call 98 + local.tee 0 + i32.eqz + br_if 0 (;@1;) + i32.const 8 + call 33 + local.tee 5 + local.get 0 + i32.store offset=4 + local.get 5 + i32.const 1416 + i32.store + end + local.get 4 + i32.load8_s offset=11 + i32.const -1 + i32.le_s + if ;; label = @1 + local.get 4 + i32.load + call 21 + end + local.get 4 + i32.const 16 + i32.add + global.set 0 + local.get 5) + (func (;100;) (type 7) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 4 + global.set 0 + local.get 4 + local.get 2 + i32.store offset=12 + local.get 4 + i32.const 0 + i32.store offset=8 + local.get 4 + i64.const 0 + i64.store + i32.const 0 + local.set 2 + local.get 3 + block (result i32) ;; label = @1 + i32.const 0 + local.get 0 + local.get 1 + local.get 4 + i32.const 12 + i32.add + i32.const 1 + local.get 4 + call 35 + i32.eqz + br_if 0 (;@1;) + drop + i32.const 1 + local.set 2 + i32.const 1 + local.get 4 + i32.load + local.get 4 + local.get 4 + i32.load8_s offset=11 + i32.const 0 + i32.lt_s + select + call 18 + local.tee 0 + i32.const -4095 + i32.ge_u + if (result i32) ;; label = @2 + i32.const 2992 + i32.const 0 + local.get 0 + i32.sub + i32.store + i32.const -1 + else + local.get 0 + end + i32.const -1 + i32.gt_s + br_if 0 (;@1;) + drop + i32.const 0 + local.set 2 + i32.const 2992 + i32.load + i32.const 44 + i32.ne + end + i32.store8 + local.get 4 + i32.load8_s offset=11 + i32.const -1 + i32.le_s + if ;; label = @1 + local.get 4 + i32.load + call 21 + end + local.get 4 + i32.const 16 + i32.add + global.set 0 + local.get 2) + (func (;101;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + block ;; label = @1 + i32.const 2456 + local.get 1 + i32.load8_s + call 30 + i32.eqz + if ;; label = @2 + i32.const 2992 + i32.const 28 + i32.store + br 1 (;@1;) + end + local.get 1 + call 71 + local.set 4 + local.get 2 + i32.const 438 + i32.store + local.get 0 + local.get 4 + i32.const 32768 + i32.or + local.get 2 + call 5 + local.tee 0 + i32.const -4095 + i32.ge_u + if ;; label = @2 + i32.const 2992 + i32.const 0 + local.get 0 + i32.sub + i32.store + i32.const -1 + local.set 0 + end + local.get 0 + i32.const 0 + i32.lt_s + br_if 0 (;@1;) + local.get 0 + local.get 1 + call 70 + local.tee 3 + br_if 0 (;@1;) + local.get 0 + call 1 + drop + i32.const 0 + local.set 3 + end + local.get 2 + i32.const 16 + i32.add + global.set 0 + local.get 3) + (func (;102;) (type 20) (param i32 i32 i32 i32 i32 i32) (result i32) + (local i32 i32 i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 6 + global.set 0 + i32.const 1571 + local.set 7 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + block ;; label = @6 + local.get 5 + br_table 4 (;@2;) 0 (;@6;) 1 (;@5;) 2 (;@4;) 3 (;@3;) 5 (;@1;) + end + i32.const 1567 + local.set 7 + br 3 (;@2;) + end + i32.const 1563 + local.set 7 + i32.const 1 + local.set 8 + br 2 (;@2;) + end + i32.const 1556 + i32.const 1560 + local.get 4 + select + local.set 7 + br 1 (;@2;) + end + i32.const 1556 + local.set 7 + end + local.get 1 + i32.const 11 + i32.eq + br_if 0 (;@1;) + local.get 6 + i32.const 0 + i32.store offset=8 + local.get 6 + i64.const 0 + i64.store + block ;; label = @2 + local.get 0 + local.get 1 + local.get 2 + local.get 3 + local.get 6 + call 35 + i32.eqz + br_if 0 (;@2;) + i32.const 12 + call 25 + local.tee 0 + i32.eqz + br_if 0 (;@2;) + local.get 6 + i32.load + local.get 6 + local.get 6 + i32.load8_s offset=11 + i32.const 0 + i32.lt_s + select + local.get 7 + call 101 + local.tee 1 + i32.eqz + if ;; label = @3 + local.get 0 + call 21 + br 1 (;@2;) + end + local.get 8 + if ;; label = @3 + local.get 1 + i32.const 0 + i32.const 0 + call 34 + drop + end + block ;; label = @3 + local.get 5 + i32.const 4 + i32.ne + br_if 0 (;@3;) + block ;; label = @4 + local.get 1 + i32.load offset=76 + i32.const 0 + i32.lt_s + br_if 0 (;@4;) + end + local.get 1 + i32.load offset=60 + i32.const 0 + i32.const 0 + i32.const 0 + call 19 + local.tee 2 + i32.const -4095 + i32.ge_u + if (result i32) ;; label = @4 + i32.const 2992 + i32.const 0 + local.get 2 + i32.sub + i32.store + i32.const -1 + else + local.get 2 + end + i32.const -1 + i32.gt_s + br_if 0 (;@3;) + local.get 0 + call 21 + local.get 1 + call 53 + br 1 (;@2;) + end + local.get 0 + i32.const 0 + i32.store8 offset=10 + local.get 0 + local.get 1 + i32.store offset=4 + local.get 0 + i32.const 1584 + i32.store + local.get 0 + local.get 4 + i32.const 1 + i32.xor + i32.store8 offset=9 + local.get 0 + local.get 1 + i32.const 0 + i32.const 1 + call 34 + i32.eqz + i32.store8 offset=8 + local.get 0 + local.set 9 + end + local.get 6 + i32.load8_s offset=11 + i32.const -1 + i32.gt_s + br_if 0 (;@1;) + local.get 6 + i32.load + call 21 + end + local.get 6 + i32.const 16 + i32.add + global.set 0 + local.get 9) + (func (;103;) (type 7) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 4 + global.set 0 + local.get 4 + local.get 2 + i32.store offset=12 + i32.const 0 + local.set 2 + local.get 4 + i32.const 0 + i32.store offset=8 + local.get 4 + i64.const 0 + i64.store + block ;; label = @1 + local.get 0 + local.get 1 + local.get 4 + i32.const 12 + i32.add + i32.const 1 + local.get 4 + call 35 + i32.eqz + if ;; label = @2 + local.get 3 + i32.load8_u + i32.eqz + br_if 1 (;@1;) + local.get 3 + i32.const 0 + i32.store8 + br 1 (;@1;) + end + local.get 4 + i32.load + local.get 4 + local.get 4 + i32.load8_s offset=11 + i32.const 0 + i32.lt_s + select + i32.const 2 + call 20 + local.tee 0 + i32.const -4095 + i32.ge_u + if ;; label = @2 + i32.const 2992 + i32.const 0 + local.get 0 + i32.sub + i32.store + i32.const -1 + local.set 0 + end + local.get 3 + i32.const 0 + i32.store8 + local.get 0 + i32.const 2 + i32.and + i32.const 1 + i32.shr_u + local.set 2 + end + local.get 4 + i32.load8_s offset=11 + i32.const -1 + i32.le_s + if ;; label = @1 + local.get 4 + i32.load + call 21 + end + local.get 4 + i32.const 16 + i32.add + global.set 0 + local.get 2) + (func (;104;) (type 0) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const 112 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 2 + i32.store offset=108 + i32.const 0 + local.set 2 + local.get 3 + i32.const 0 + i32.store offset=104 + local.get 3 + i64.const 0 + i64.store offset=96 + local.get 0 + local.get 1 + local.get 3 + i32.const 108 + i32.add + i32.const 1 + local.get 3 + i32.const 96 + i32.add + call 35 + if ;; label = @1 + local.get 3 + i32.load offset=96 + local.get 3 + i32.const 96 + i32.add + local.get 3 + i32.load8_s offset=107 + i32.const 0 + i32.lt_s + select + local.get 3 + i32.const 8 + i32.add + call 4 + local.tee 0 + i32.const -4095 + i32.ge_u + if (result i32) ;; label = @2 + i32.const 2992 + i32.const 0 + local.get 0 + i32.sub + i32.store + i32.const -1 + else + local.get 0 + end + i32.eqz + local.set 2 + end + local.get 3 + i32.load8_s offset=107 + i32.const -1 + i32.le_s + if ;; label = @1 + local.get 3 + i32.load offset=96 + call 21 + end + local.get 3 + i32.const 112 + i32.add + global.set 0 + local.get 2) + (func (;105;) (type 3) (param i32) + local.get 0 + i32.load offset=4 + local.tee 0 + if ;; label = @1 + local.get 0 + local.get 0 + i32.load + i32.load offset=40 + call_indirect (type 3) + end) + (func (;106;) (type 4) (param i32 i32) + (local i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + local.get 1 + i32.store offset=12 + local.get 0 + local.get 1 + call 145 + local.get 2 + i32.const 16 + i32.add + global.set 0) + (func (;107;) (type 6) (param i32 i32 i32 i32) + (local i32 i32 i32 i32 i32 i64) + global.get 0 + i32.const 96 + i32.sub + local.tee 5 + global.set 0 + local.get 2 + local.set 4 + block ;; label = @1 + block ;; label = @2 + loop ;; label = @3 + block ;; label = @4 + block ;; label = @5 + local.get 4 + i32.load8_u + local.tee 7 + i32.const 37 + i32.ne + if ;; label = @6 + local.get 7 + br_if 1 (;@5;) + local.get 5 + i32.const 0 + call 2 + i32.store offset=92 + local.get 5 + i32.const 92 + i32.add + call 58 + local.tee 4 + i64.load align=4 + local.set 9 + local.get 5 + local.get 4 + i32.load offset=8 + i32.store + local.get 5 + local.get 9 + i64.const 32 + i64.rotl + i64.store offset=4 align=4 + local.get 5 + i32.const 16 + i32.add + local.get 5 + call 106 + local.get 0 + i32.load offset=4 + local.tee 4 + if ;; label = @7 + local.get 4 + local.get 5 + i32.const 16 + i32.add + local.get 5 + i32.const 16 + i32.add + call 32 + local.get 4 + i32.load + i32.load offset=4 + call_indirect (type 0) + drop + end + block ;; label = @7 + i32.const 1340 + i32.const 1330 + i32.const 1339 + local.get 1 + i32.const 2 + i32.eq + select + local.get 1 + i32.const 1 + i32.eq + select + local.tee 1 + i32.load8_u + i32.eqz + br_if 0 (;@7;) + local.get 0 + i32.load offset=4 + local.tee 4 + i32.eqz + br_if 0 (;@7;) + local.get 4 + local.get 1 + local.get 1 + call 32 + local.get 4 + i32.load + i32.load offset=4 + call_indirect (type 0) + drop + end + local.get 8 + br_if 2 (;@4;) + local.get 0 + i32.load offset=4 + local.tee 1 + i32.eqz + br_if 5 (;@1;) + local.get 1 + local.get 2 + local.get 6 + local.get 1 + i32.load + i32.load offset=4 + call_indirect (type 0) + drop + br 4 (;@2;) + end + i32.const 1 + local.set 8 + end + local.get 4 + i32.const 1 + i32.add + local.set 4 + local.get 6 + i32.const 1 + i32.add + local.set 6 + br 1 (;@3;) + end + end + i32.const 0 + i32.const 0 + local.get 2 + local.get 3 + call 54 + local.tee 4 + i32.const 1 + i32.lt_s + br_if 1 (;@1;) + local.get 4 + i32.const 1 + i32.add + local.tee 6 + call 25 + local.tee 1 + i32.eqz + br_if 1 (;@1;) + local.get 1 + local.get 6 + local.get 2 + local.get 3 + call 54 + drop + local.get 0 + i32.load offset=4 + local.tee 2 + if ;; label = @3 + local.get 2 + local.get 1 + local.get 4 + local.get 2 + i32.load + i32.load offset=4 + call_indirect (type 0) + drop + end + local.get 1 + call 21 + end + local.get 0 + i32.load offset=4 + local.tee 1 + i32.eqz + br_if 0 (;@1;) + local.get 1 + i32.const 1351 + i32.const 1 + local.get 1 + i32.load + i32.load offset=4 + call_indirect (type 0) + drop + local.get 0 + i32.load offset=4 + local.tee 0 + i32.load + i32.load offset=44 + local.set 1 + local.get 0 + local.get 1 + call_indirect (type 3) + end + local.get 5 + i32.const 96 + i32.add + global.set 0) + (func (;108;) (type 4) (param i32 i32) + (local i32) + local.get 0 + i32.load offset=4 + local.tee 2 + local.get 1 + i32.ne + if ;; label = @1 + local.get 2 + if ;; label = @2 + local.get 2 + local.get 2 + i32.load + i32.load offset=4 + call_indirect (type 3) + end + local.get 0 + local.get 1 + i32.store offset=4 + end) + (func (;109;) (type 1) (param i32) (result i32) + local.get 0 + i32.load offset=4) + (func (;110;) (type 4) (param i32 i32) + local.get 0 + local.get 1 + i32.store8 offset=8) + (func (;111;) (type 1) (param i32) (result i32) + i32.const 2988 + i32.load8_u + i32.eqz + if ;; label = @1 + i32.const 2988 + i32.const 1 + i32.store8 + end + i32.const 1) + (func (;112;) (type 10) (param i32) (result i64) + i64.const 0) + (func (;113;) (type 16) (param i32 i32 i32 i32 i32 i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + i32.const 0 + call 2 + i32.store offset=12 + local.get 1 + local.get 3 + i32.const 12 + i32.add + call 58 + local.tee 0 + i32.load offset=20 + i32.store + local.get 2 + local.get 0 + i32.load offset=16 + i32.const 1 + i32.add + i32.store + local.get 4 + local.get 0 + i32.load offset=8 + i32.store + local.get 5 + local.get 0 + i32.load offset=4 + i32.store + local.get 6 + local.get 0 + i32.load + i32.store + local.get 3 + i32.const 16 + i32.add + global.set 0) + (func (;114;) (type 10) (param i32) (result i64) + i32.const 0 + call 2 + i64.extend_i32_s + i64.const 2082844800 + i64.sub) + (func (;115;) (type 3) (param i32) + i32.const 3628 + i32.const 1088 + i32.store) + (func (;116;) (type 17) (param i32 i64 i64 i32) + (local i64) + block ;; label = @1 + local.get 3 + i32.const 64 + i32.and + if ;; label = @2 + local.get 2 + local.get 3 + i32.const -64 + i32.add + i64.extend_i32_u + i64.shr_u + local.set 1 + i64.const 0 + local.set 2 + br 1 (;@1;) + end + local.get 3 + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.const 64 + local.get 3 + i32.sub + i64.extend_i32_u + i64.shl + local.get 1 + local.get 3 + i64.extend_i32_u + local.tee 4 + i64.shr_u + i64.or + local.set 1 + local.get 2 + local.get 4 + i64.shr_u + local.set 2 + end + local.get 0 + local.get 1 + i64.store + local.get 0 + local.get 2 + i64.store offset=8) + (func (;117;) (type 3) (param i32) + i32.const 2944 + i32.const 1032 + i32.store + i32.const 2975 + i32.load8_s + i32.const -1 + i32.le_s + if ;; label = @1 + i32.const 2964 + i32.load + call 21 + end + i32.const 2963 + i32.load8_s + i32.const -1 + i32.le_s + if ;; label = @1 + i32.const 2952 + i32.load + call 21 + end) + (func (;118;) (type 5) + i32.const 2948 + i64.const 0 + i64.store align=4 + i32.const 2944 + i32.const 1032 + i32.store + i32.const 2956 + i64.const 0 + i64.store align=4 + i32.const 2964 + i64.const 0 + i64.store align=4 + i32.const 2972 + i32.const 0 + i32.store + i32.const 2976 + i32.const 1072 + i32.store + i32.const 3628 + i32.const 1088 + i32.store + i32.const 2984 + i32.const 0 + i32.store8 + i32.const 2980 + i32.const 0 + i32.store) + (func (;119;) (type 24) (param i64 i64) (result f64) + (local i64 i64 i32 i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 4 + global.set 0 + block ;; label = @1 + local.get 1 + i64.const 9223372036854775807 + i64.and + local.tee 3 + i64.const 4323737117252386816 + i64.sub + local.get 3 + i64.const 4899634919602388992 + i64.sub + i64.lt_u + if ;; label = @2 + local.get 1 + i64.const 4 + i64.shl + local.get 0 + i64.const 60 + i64.shr_u + i64.or + local.set 3 + local.get 0 + i64.const 1152921504606846975 + i64.and + local.tee 0 + i64.const 576460752303423489 + i64.ge_u + if ;; label = @3 + local.get 3 + i64.const 4611686018427387905 + i64.add + local.set 2 + br 2 (;@1;) + end + local.get 3 + i64.const -4611686018427387904 + i64.sub + local.set 2 + local.get 0 + i64.const 576460752303423488 + i64.xor + i64.const 0 + i64.ne + br_if 1 (;@1;) + local.get 2 + local.get 3 + i64.const 1 + i64.and + i64.add + local.set 2 + br 1 (;@1;) + end + local.get 0 + i64.eqz + local.get 3 + i64.const 9223090561878065152 + i64.lt_u + local.get 3 + i64.const 9223090561878065152 + i64.eq + select + i32.eqz + if ;; label = @2 + local.get 1 + i64.const 4 + i64.shl + local.get 0 + i64.const 60 + i64.shr_u + i64.or + i64.const 2251799813685247 + i64.and + i64.const 9221120237041090560 + i64.or + local.set 2 + br 1 (;@1;) + end + i64.const 9218868437227405312 + local.set 2 + local.get 3 + i64.const 4899634919602388991 + i64.gt_u + br_if 0 (;@1;) + i64.const 0 + local.set 2 + local.get 3 + i64.const 48 + i64.shr_u + i32.wrap_i64 + local.tee 5 + i32.const 15249 + i32.lt_u + br_if 0 (;@1;) + local.get 4 + i32.const 16 + i32.add + local.get 0 + local.get 1 + i64.const 281474976710655 + i64.and + i64.const 281474976710656 + i64.or + local.tee 2 + local.get 5 + i32.const 15233 + i32.sub + call 146 + local.get 4 + local.get 0 + local.get 2 + i32.const 15361 + local.get 5 + i32.sub + call 116 + local.get 4 + i64.load offset=8 + i64.const 4 + i64.shl + local.get 4 + i64.load + local.tee 0 + i64.const 60 + i64.shr_u + i64.or + local.set 2 + local.get 4 + i64.load offset=16 + local.get 4 + i64.load offset=24 + i64.or + i64.const 0 + i64.ne + i64.extend_i32_u + local.get 0 + i64.const 1152921504606846975 + i64.and + i64.or + local.tee 0 + i64.const 576460752303423489 + i64.ge_u + if ;; label = @2 + local.get 2 + i64.const 1 + i64.add + local.set 2 + br 1 (;@1;) + end + local.get 0 + i64.const 576460752303423488 + i64.xor + i64.const 0 + i64.ne + br_if 0 (;@1;) + local.get 2 + local.get 2 + i64.const 1 + i64.and + i64.add + local.set 2 + end + local.get 4 + i32.const 32 + i32.add + global.set 0 + local.get 2 + local.get 1 + i64.const -9223372036854775808 + i64.and + i64.or + f64.reinterpret_i64) + (func (;120;) (type 5) + i32.const 0 + global.set 3 + global.get 4 + i32.load + global.get 4 + i32.load offset=4 + i32.gt_u + if ;; label = @1 + unreachable + end) + (func (;121;) (type 3) (param i32) + i32.const 2 + global.set 3 + local.get 0 + global.set 4 + global.get 4 + i32.load + global.get 4 + i32.load offset=4 + i32.gt_u + if ;; label = @1 + unreachable + end) + (func (;122;) (type 5) + i32.const 0 + global.set 3 + global.get 4 + i32.load + global.get 4 + i32.load offset=4 + i32.gt_u + if ;; label = @1 + unreachable + end) + (func (;123;) (type 3) (param i32) + i32.const 1 + global.set 3 + local.get 0 + global.set 4 + global.get 4 + i32.load + global.get 4 + i32.load offset=4 + i32.gt_u + if ;; label = @1 + unreachable + end) + (func (;124;) (type 4) (param i32 i32) + local.get 1 + local.get 0 + call_indirect (type 3)) + (func (;125;) (type 9) (param i32 i32 i32 i32 i32 i32) + local.get 0 + local.get 1 + i32.load offset=8 + local.get 5 + call 24 + if ;; label = @1 + local.get 1 + local.get 2 + local.get 3 + local.get 4 + call 60 + end) + (func (;126;) (type 8) (param i32 i32 i32 i32 i32) + local.get 0 + local.get 1 + i32.load offset=8 + local.get 4 + call 24 + if ;; label = @1 + block ;; label = @2 + local.get 2 + local.get 1 + i32.load offset=4 + i32.ne + br_if 0 (;@2;) + local.get 1 + i32.load offset=28 + i32.const 1 + i32.eq + br_if 0 (;@2;) + local.get 1 + local.get 3 + i32.store offset=28 + end + return + end + block ;; label = @1 + local.get 0 + local.get 1 + i32.load + local.get 4 + call 24 + i32.eqz + br_if 0 (;@1;) + block ;; label = @2 + local.get 2 + local.get 1 + i32.load offset=16 + i32.ne + if ;; label = @3 + local.get 2 + local.get 1 + i32.load offset=20 + i32.ne + br_if 1 (;@2;) + end + local.get 3 + i32.const 1 + i32.ne + br_if 1 (;@1;) + local.get 1 + i32.const 1 + i32.store offset=32 + return + end + local.get 1 + local.get 2 + i32.store offset=20 + local.get 1 + local.get 3 + i32.store offset=32 + local.get 1 + local.get 1 + i32.load offset=40 + i32.const 1 + i32.add + i32.store offset=40 + block ;; label = @2 + local.get 1 + i32.load offset=36 + i32.const 1 + i32.ne + br_if 0 (;@2;) + local.get 1 + i32.load offset=24 + i32.const 2 + i32.ne + br_if 0 (;@2;) + local.get 1 + i32.const 1 + i32.store8 offset=54 + end + local.get 1 + i32.const 4 + i32.store offset=44 + end) + (func (;127;) (type 6) (param i32 i32 i32 i32) + local.get 0 + local.get 1 + i32.load offset=8 + i32.const 0 + call 24 + if ;; label = @1 + local.get 1 + local.get 2 + local.get 3 + call 59 + end) + (func (;128;) (type 6) (param i32 i32 i32 i32) + (local i32) + local.get 0 + local.get 1 + i32.load offset=8 + i32.const 0 + call 24 + if ;; label = @1 + local.get 1 + local.get 2 + local.get 3 + call 59 + return + end + local.get 0 + i32.load offset=8 + local.tee 0 + i32.load + i32.load offset=28 + local.set 4 + local.get 0 + local.get 1 + local.get 2 + local.get 3 + local.get 4 + call_indirect (type 6)) + (func (;129;) (type 8) (param i32 i32 i32 i32 i32) + (local i32) + local.get 0 + local.get 1 + i32.load offset=8 + local.get 4 + call 24 + if ;; label = @1 + block ;; label = @2 + local.get 2 + local.get 1 + i32.load offset=4 + i32.ne + br_if 0 (;@2;) + local.get 1 + i32.load offset=28 + i32.const 1 + i32.eq + br_if 0 (;@2;) + local.get 1 + local.get 3 + i32.store offset=28 + end + return + end + block ;; label = @1 + local.get 0 + local.get 1 + i32.load + local.get 4 + call 24 + if ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=16 + local.get 2 + i32.ne + if ;; label = @4 + local.get 1 + i32.load offset=20 + local.get 2 + i32.ne + br_if 1 (;@3;) + end + local.get 3 + i32.const 1 + i32.ne + br_if 2 (;@1;) + local.get 1 + i32.const 1 + i32.store offset=32 + return + end + local.get 1 + local.get 3 + i32.store offset=32 + block ;; label = @3 + local.get 1 + i32.load offset=44 + i32.const 4 + i32.eq + br_if 0 (;@3;) + local.get 1 + i32.const 0 + i32.store16 offset=52 + local.get 0 + i32.load offset=8 + local.tee 0 + i32.load + i32.load offset=20 + local.set 3 + local.get 0 + local.get 1 + local.get 2 + local.get 2 + i32.const 1 + local.get 4 + local.get 3 + call_indirect (type 9) + local.get 1 + i32.load8_u offset=53 + if ;; label = @4 + local.get 1 + i32.const 3 + i32.store offset=44 + local.get 1 + i32.load8_u offset=52 + i32.eqz + br_if 1 (;@3;) + br 3 (;@1;) + end + local.get 1 + i32.const 4 + i32.store offset=44 + end + local.get 1 + local.get 2 + i32.store offset=20 + local.get 1 + local.get 1 + i32.load offset=40 + i32.const 1 + i32.add + i32.store offset=40 + local.get 1 + i32.load offset=36 + i32.const 1 + i32.ne + br_if 1 (;@1;) + local.get 1 + i32.load offset=24 + i32.const 2 + i32.ne + br_if 1 (;@1;) + local.get 1 + i32.const 1 + i32.store8 offset=54 + return + end + local.get 0 + i32.load offset=8 + local.tee 0 + i32.load + i32.load offset=24 + local.set 5 + local.get 0 + local.get 1 + local.get 2 + local.get 3 + local.get 4 + local.get 5 + call_indirect (type 8) + end) + (func (;130;) (type 9) (param i32 i32 i32 i32 i32 i32) + (local i32) + local.get 0 + local.get 1 + i32.load offset=8 + local.get 5 + call 24 + if ;; label = @1 + local.get 1 + local.get 2 + local.get 3 + local.get 4 + call 60 + return + end + local.get 0 + i32.load offset=8 + local.tee 0 + i32.load + i32.load offset=20 + local.set 6 + local.get 0 + local.get 1 + local.get 2 + local.get 3 + local.get 4 + local.get 5 + local.get 6 + call_indirect (type 9)) + (func (;131;) (type 1) (param i32) (result i32) + (local i32 i32 i32 i32) + global.get 0 + i32.const -64 + i32.add + local.tee 1 + global.set 0 + local.get 0 + i32.load + local.tee 2 + i32.const 4 + i32.sub + i32.load + local.set 3 + local.get 2 + i32.const 8 + i32.sub + i32.load + local.set 4 + local.get 1 + i32.const 2484 + i32.store offset=16 + local.get 1 + local.get 0 + i32.store offset=12 + local.get 1 + i32.const 2496 + i32.store offset=8 + i32.const 0 + local.set 2 + local.get 1 + i32.const 20 + i32.add + i32.const 0 + i32.const 43 + call 31 + drop + local.get 0 + local.get 4 + i32.add + local.set 0 + block ;; label = @1 + local.get 3 + i32.const 2496 + i32.const 0 + call 24 + if ;; label = @2 + local.get 1 + i32.const 1 + i32.store offset=56 + local.get 3 + local.get 1 + i32.const 8 + i32.add + local.get 0 + local.get 0 + i32.const 1 + i32.const 0 + local.get 3 + i32.load + i32.load offset=20 + call_indirect (type 9) + local.get 0 + i32.const 0 + local.get 1 + i32.load offset=32 + i32.const 1 + i32.eq + select + local.set 2 + br 1 (;@1;) + end + local.get 3 + local.get 1 + i32.const 8 + i32.add + local.get 0 + i32.const 1 + i32.const 0 + local.get 3 + i32.load + i32.load offset=24 + call_indirect (type 8) + block ;; label = @2 + block ;; label = @3 + local.get 1 + i32.load offset=44 + br_table 0 (;@3;) 1 (;@2;) 2 (;@1;) + end + local.get 1 + i32.load offset=28 + i32.const 0 + local.get 1 + i32.load offset=40 + i32.const 1 + i32.eq + select + i32.const 0 + local.get 1 + i32.load offset=36 + i32.const 1 + i32.eq + select + i32.const 0 + local.get 1 + i32.load offset=48 + i32.const 1 + i32.eq + select + local.set 2 + br 1 (;@1;) + end + local.get 1 + i32.load offset=32 + i32.const 1 + i32.ne + if ;; label = @2 + local.get 1 + i32.load offset=48 + br_if 1 (;@1;) + local.get 1 + i32.load offset=36 + i32.const 1 + i32.ne + br_if 1 (;@1;) + local.get 1 + i32.load offset=40 + i32.const 1 + i32.ne + br_if 1 (;@1;) + end + local.get 1 + i32.load offset=24 + local.set 2 + end + local.get 1 + i32.const -64 + i32.sub + global.set 0 + local.get 2) + (func (;132;) (type 0) (param i32 i32 i32) (result i32) + (local i32) + global.get 0 + i32.const -64 + i32.add + local.tee 3 + global.set 0 + block (result i32) ;; label = @1 + i32.const 1 + local.get 0 + local.get 1 + i32.const 0 + call 24 + br_if 0 (;@1;) + drop + i32.const 0 + local.get 1 + i32.eqz + br_if 0 (;@1;) + drop + i32.const 0 + local.get 1 + call 131 + local.tee 1 + i32.eqz + br_if 0 (;@1;) + drop + local.get 3 + i32.const 8 + i32.add + i32.const 4 + i32.or + i32.const 0 + i32.const 52 + call 31 + drop + local.get 3 + i32.const 1 + i32.store offset=56 + local.get 3 + i32.const -1 + i32.store offset=20 + local.get 3 + local.get 0 + i32.store offset=16 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 1 + local.get 3 + i32.const 8 + i32.add + local.get 2 + i32.load + i32.const 1 + local.get 1 + i32.load + i32.load offset=28 + call_indirect (type 6) + local.get 3 + i32.load offset=32 + local.tee 0 + i32.const 1 + i32.eq + if ;; label = @2 + local.get 2 + local.get 3 + i32.load offset=24 + i32.store + end + local.get 0 + i32.const 1 + i32.eq + end + local.set 0 + local.get 3 + i32.const -64 + i32.sub + global.set 0 + local.get 0) + (func (;133;) (type 16) (param i32 i32 i32 i32 i32 i32 i32) + (local i32 i32 i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 7 + global.set 0 + i32.const -18 + local.get 1 + i32.sub + local.get 2 + i32.ge_u + if ;; label = @1 + block (result i32) ;; label = @2 + local.get 0 + i32.load8_u offset=11 + i32.const 7 + i32.shr_u + if ;; label = @3 + local.get 0 + i32.load + br 1 (;@2;) + end + local.get 0 + end + local.set 9 + i32.const -17 + local.set 8 + block (result i32) ;; label = @2 + local.get 1 + i32.const 2147483622 + i32.le_u + if ;; label = @3 + local.get 7 + local.get 1 + i32.const 1 + i32.shl + i32.store offset=8 + local.get 7 + local.get 1 + local.get 2 + i32.add + i32.store offset=12 + local.get 7 + i32.const 8 + i32.add + local.get 7 + i32.const 12 + i32.add + local.get 7 + i32.load offset=12 + local.get 7 + i32.load offset=8 + i32.lt_u + select + i32.load + local.tee 2 + i32.const 11 + i32.ge_u + if (result i32) ;; label = @4 + local.get 2 + i32.const 16 + i32.add + i32.const -16 + i32.and + local.tee 2 + local.set 8 + local.get 2 + i32.const 1 + i32.sub + local.tee 2 + i32.const 11 + i32.eq + local.set 10 + local.get 8 + local.get 2 + local.get 10 + select + else + i32.const 10 + end + i32.const 1 + i32.add + local.set 8 + end + local.get 8 + end + call 33 + local.set 2 + local.get 4 + if ;; label = @2 + local.get 2 + local.get 9 + local.get 4 + call 37 + end + local.get 5 + if ;; label = @2 + local.get 2 + local.get 4 + i32.add + local.get 6 + local.get 5 + call 37 + end + local.get 3 + local.get 4 + i32.sub + local.tee 6 + if ;; label = @2 + local.get 2 + local.get 4 + i32.add + local.get 5 + i32.add + local.get 4 + local.get 9 + i32.add + local.get 6 + call 37 + end + local.get 1 + i32.const 10 + i32.ne + if ;; label = @2 + local.get 9 + call 21 + end + local.get 0 + local.get 2 + i32.store + local.get 0 + local.get 8 + i32.const -2147483648 + i32.or + i32.store offset=8 + local.get 0 + local.get 3 + local.get 5 + i32.add + local.tee 0 + i32.store offset=4 + local.get 0 + local.get 2 + i32.add + i32.const 0 + i32.store8 + local.get 7 + i32.const 16 + i32.add + global.set 0 + return + end + call 51 + unreachable) + (func (;134;) (type 1) (param i32) (result i32) + local.get 0) + (func (;135;) (type 11) (result i32) + i32.const 3128) + (func (;136;) (type 11) (result i32) + i32.const 3124) + (func (;137;) (type 11) (result i32) + i32.const 3116) + (func (;138;) (type 5) + (local i32 i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 0 + global.set 0 + block ;; label = @1 + local.get 0 + i32.const 12 + i32.add + local.get 0 + i32.const 8 + i32.add + call 16 + br_if 0 (;@1;) + i32.const 3112 + local.get 0 + i32.load offset=12 + i32.const 2 + i32.shl + i32.const 4 + i32.add + call 25 + local.tee 1 + i32.store + local.get 1 + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load offset=8 + call 25 + local.tee 1 + i32.eqz + if ;; label = @2 + i32.const 3112 + i32.const 0 + i32.store + br 1 (;@1;) + end + i32.const 3112 + i32.load + local.tee 2 + local.get 0 + i32.load offset=12 + i32.const 2 + i32.shl + i32.add + i32.const 0 + i32.store + local.get 2 + local.get 1 + call 15 + i32.eqz + br_if 0 (;@1;) + i32.const 3112 + i32.const 0 + i32.store + end + local.get 0 + i32.const 16 + i32.add + global.set 0) + (func (;139;) (type 2) (param i32 i32) (result i32) + (local i32 i32) + local.get 1 + i32.load8_u + local.set 2 + block ;; label = @1 + local.get 0 + i32.load8_u + local.tee 3 + i32.eqz + br_if 0 (;@1;) + local.get 2 + local.get 3 + i32.ne + br_if 0 (;@1;) + loop ;; label = @2 + local.get 1 + i32.load8_u offset=1 + local.set 2 + local.get 0 + i32.load8_u offset=1 + local.tee 3 + i32.eqz + br_if 1 (;@1;) + local.get 1 + i32.const 1 + i32.add + local.set 1 + local.get 0 + i32.const 1 + i32.add + local.set 0 + local.get 2 + local.get 3 + i32.eq + br_if 0 (;@2;) + end + end + local.get 3 + local.get 2 + i32.sub) + (func (;140;) (type 2) (param i32 i32) (result i32) + (local i32 i32 i32) + block ;; label = @1 + local.get 1 + i32.const 255 + i32.and + local.tee 3 + if ;; label = @2 + local.get 0 + i32.const 3 + i32.and + if ;; label = @3 + loop ;; label = @4 + local.get 0 + i32.load8_u + local.tee 2 + i32.eqz + br_if 3 (;@1;) + local.get 1 + i32.const 255 + i32.and + local.get 2 + i32.eq + br_if 3 (;@1;) + local.get 0 + i32.const 1 + i32.add + local.tee 0 + i32.const 3 + i32.and + br_if 0 (;@4;) + end + end + block ;; label = @3 + local.get 0 + i32.load + local.tee 2 + i32.const -1 + i32.xor + local.get 2 + i32.const 16843009 + i32.sub + i32.and + i32.const -2139062144 + i32.and + br_if 0 (;@3;) + local.get 3 + i32.const 16843009 + i32.mul + local.set 3 + loop ;; label = @4 + local.get 2 + local.get 3 + i32.xor + local.tee 2 + i32.const -1 + i32.xor + local.set 4 + local.get 4 + local.get 2 + i32.const 16843009 + i32.sub + i32.and + i32.const -2139062144 + i32.and + br_if 1 (;@3;) + local.get 0 + i32.load offset=4 + local.set 2 + local.get 0 + i32.const 4 + i32.add + local.set 0 + local.get 2 + i32.const 16843009 + i32.sub + local.get 2 + i32.const -1 + i32.xor + i32.and + i32.const -2139062144 + i32.and + i32.eqz + br_if 0 (;@4;) + end + end + loop ;; label = @3 + local.get 0 + local.tee 2 + i32.load8_u + local.tee 3 + if ;; label = @4 + local.get 2 + i32.const 1 + i32.add + local.set 0 + local.get 3 + local.get 1 + i32.const 255 + i32.and + i32.ne + br_if 1 (;@3;) + end + end + local.get 2 + return + end + local.get 0 + call 32 + local.get 0 + i32.add + return + end + local.get 0) + (func (;141;) (type 1) (param i32) (result i32) + local.get 0 + i32.load offset=60 + call 1) + (func (;142;) (type 0) (param i32 i32 i32) (result i32) + (local i32 i32 i32 i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 1 + i32.store offset=16 + local.get 3 + local.get 2 + local.get 0 + i32.load offset=48 + local.tee 4 + i32.const 0 + i32.ne + i32.sub + i32.store offset=20 + local.get 0 + i32.load offset=44 + local.set 5 + local.get 3 + local.get 4 + i32.store offset=28 + local.get 3 + local.get 5 + i32.store offset=24 + i32.const -1 + local.set 4 + i32.const 0 + local.set 6 + block ;; label = @1 + block ;; label = @2 + local.get 0 + i32.load offset=60 + local.get 3 + i32.const 16 + i32.add + i32.const 2 + local.get 3 + i32.const 12 + i32.add + call 8 + local.tee 5 + if (result i32) ;; label = @3 + i32.const 2992 + local.get 5 + i32.store + i32.const -1 + else + local.get 6 + end + i32.eqz + if ;; label = @3 + local.get 3 + i32.load offset=12 + local.tee 4 + i32.const 0 + i32.gt_s + br_if 1 (;@2;) + end + local.get 0 + local.get 0 + i32.load + local.get 4 + i32.const 48 + i32.and + i32.const 16 + i32.xor + i32.or + i32.store + br 1 (;@1;) + end + local.get 3 + i32.load offset=20 + local.tee 6 + local.get 4 + i32.ge_u + br_if 0 (;@1;) + local.get 0 + local.get 0 + i32.load offset=44 + local.tee 5 + i32.store offset=4 + local.get 0 + local.get 4 + local.get 6 + i32.sub + local.get 5 + i32.add + i32.store offset=8 + local.get 0 + i32.load offset=48 + if ;; label = @2 + local.get 0 + local.get 5 + i32.const 1 + i32.add + i32.store offset=4 + local.get 1 + local.get 2 + i32.add + i32.const 1 + i32.sub + local.get 5 + i32.load8_u + i32.store8 + end + local.get 2 + local.set 4 + end + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 4) + (func (;143;) (type 0) (param i32 i32 i32) (result i32) + (local i32 i32 i32 i32 i32 i32 i32) + global.get 0 + i32.const 32 + i32.sub + local.tee 3 + global.set 0 + local.get 3 + local.get 0 + i32.load offset=28 + local.tee 5 + i32.store offset=16 + local.get 0 + i32.load offset=20 + local.set 6 + local.get 3 + local.get 2 + i32.store offset=28 + local.get 3 + local.get 1 + i32.store offset=24 + local.get 3 + local.get 6 + local.get 5 + i32.sub + local.tee 1 + i32.store offset=20 + local.get 1 + local.get 2 + i32.add + local.set 5 + i32.const 2 + local.set 6 + local.get 3 + i32.const 16 + i32.add + local.set 1 + block (result i32) ;; label = @1 + loop ;; label = @2 + block ;; label = @3 + i32.const 0 + local.set 4 + block ;; label = @4 + block ;; label = @5 + local.get 0 + i32.load offset=60 + local.get 1 + local.get 6 + local.get 3 + i32.const 12 + i32.add + call 7 + local.tee 7 + if (result i32) ;; label = @6 + i32.const 2992 + local.get 7 + i32.store + i32.const -1 + else + local.get 4 + end + i32.eqz + if ;; label = @6 + local.get 5 + local.get 3 + i32.load offset=12 + local.tee 7 + i32.eq + br_if 1 (;@5;) + local.get 7 + i32.const -1 + i32.gt_s + br_if 2 (;@4;) + br 3 (;@3;) + end + local.get 5 + i32.const -1 + i32.ne + br_if 2 (;@3;) + end + local.get 0 + local.get 0 + i32.load offset=44 + local.tee 1 + i32.store offset=28 + local.get 0 + local.get 1 + i32.store offset=20 + local.get 0 + local.get 0 + i32.load offset=48 + local.get 1 + i32.add + i32.store offset=16 + local.get 2 + br 3 (;@1;) + end + local.get 1 + i32.load offset=4 + local.tee 4 + local.get 7 + i32.lt_u + local.tee 8 + i32.const 3 + i32.shl + local.get 1 + i32.add + local.tee 9 + local.get 7 + local.get 4 + i32.const 0 + local.get 8 + select + i32.sub + local.tee 4 + local.get 9 + i32.load + i32.add + i32.store + i32.const 12 + i32.const 4 + local.get 8 + select + local.get 1 + i32.add + local.tee 9 + i32.load + local.get 4 + i32.sub + local.set 4 + local.get 9 + local.get 4 + i32.store + local.get 1 + i32.const 8 + i32.add + local.get 1 + local.get 8 + select + local.set 1 + local.get 5 + local.get 7 + i32.sub + local.set 5 + local.get 6 + local.get 8 + i32.sub + local.set 6 + br 1 (;@2;) + end + end + local.get 0 + i32.const 0 + i32.store offset=28 + local.get 0 + i64.const 0 + i64.store offset=16 + local.get 0 + local.get 0 + i32.load + i32.const 32 + i32.or + i32.store + i32.const 0 + local.get 6 + i32.const 2 + i32.eq + br_if 0 (;@1;) + drop + local.get 2 + local.get 1 + i32.load offset=4 + i32.sub + end + local.set 0 + local.get 3 + i32.const 32 + i32.add + global.set 0 + local.get 0) + (func (;144;) (type 12) (param i32 i64 i32) (result i64) + (local i32 i32) + global.get 0 + i32.const 16 + i32.sub + local.tee 3 + global.set 0 + local.get 0 + i32.load offset=60 + local.get 1 + i32.wrap_i64 + local.get 1 + i64.const 32 + i64.shr_u + i32.wrap_i64 + local.get 2 + i32.const 255 + i32.and + local.get 3 + i32.const 8 + i32.add + call 11 + local.tee 0 + i32.eqz + local.set 4 + i32.const 0 + local.set 2 + local.get 4 + i32.eqz + if ;; label = @1 + i32.const 2992 + local.get 0 + i32.store + i32.const -1 + local.set 2 + end + local.get 3 + i64.load offset=8 + local.set 1 + local.get 3 + i32.const 16 + i32.add + global.set 0 + i64.const -1 + local.get 1 + local.get 2 + select) + (func (;145;) (type 4) (param i32 i32) + (local i32 i32) + global.get 0 + i32.const 144 + i32.sub + local.tee 2 + global.set 0 + local.get 2 + i32.const 2312 + i32.const 144 + call 26 + local.tee 2 + local.get 0 + i32.store offset=44 + local.get 2 + local.get 0 + i32.store offset=20 + local.get 2 + i32.const -2 + local.get 0 + i32.sub + local.tee 3 + i32.const 2147483647 + local.get 3 + i32.const 2147483647 + i32.lt_u + select + local.tee 3 + i32.store offset=48 + local.get 2 + local.get 0 + local.get 3 + i32.add + local.tee 0 + i32.store offset=28 + local.get 2 + local.get 0 + i32.store offset=16 + local.get 2 + i32.const 1312 + local.get 1 + i32.const 0 + i32.const 0 + call 45 + drop + local.get 3 + if ;; label = @1 + local.get 2 + i32.load offset=20 + local.tee 0 + local.get 2 + i32.load offset=16 + i32.eq + local.set 1 + local.get 0 + local.get 1 + i32.sub + i32.const 0 + i32.store8 + end + local.get 2 + i32.const 144 + i32.add + global.set 0) + (func (;146;) (type 17) (param i32 i64 i64 i32) + (local i64) + block ;; label = @1 + local.get 3 + i32.const 64 + i32.and + if ;; label = @2 + local.get 1 + local.get 3 + i32.const -64 + i32.add + i64.extend_i32_u + i64.shl + local.set 2 + i64.const 0 + local.set 1 + br 1 (;@1;) + end + local.get 3 + i32.eqz + br_if 0 (;@1;) + local.get 2 + local.get 3 + i64.extend_i32_u + local.tee 4 + i64.shl + local.get 1 + i32.const 64 + local.get 3 + i32.sub + i64.extend_i32_u + i64.shr_u + i64.or + local.set 2 + local.get 1 + local.get 4 + i64.shl + local.set 1 + end + local.get 0 + local.get 1 + i64.store + local.get 0 + local.get 2 + i64.store offset=8) + (table (;0;) 68 68 funcref) + (memory (;0;) 256 256) + (global (;0;) (mut i32) (i32.const 5246512)) + (global (;1;) (mut i32) (i32.const 0)) + (global (;2;) (mut i32) (i32.const 0)) + (global (;3;) (mut i32) (i32.const 0)) + (global (;4;) (mut i32) (i32.const 0)) + (export "v" (memory 0)) + (export "w" (func 42)) + (export "x" (func 21)) + (export "y" (func 25)) + (export "z" (func 74)) + (export "A" (func 137)) + (export "B" (func 136)) + (export "C" (func 135)) + (export "D" (table 0)) + (export "E" (func 124)) + (export "F" (func 123)) + (export "G" (func 122)) + (export "H" (func 121)) + (export "I" (func 120)) + (elem (;0;) (i32.const 1) func 117 115 144 143 142 141 64 63 104 103 102 100 99 97 96 94 107 105 114 113 57 57 56 56 112 29 36 36 50 36 36 111 110 55 50 109 108 29 29 29 93 91 90 88 55 87 86 85 84 83 82 80 79 77 62 134 61 29 29 132 130 129 128 61 125 126 127) + (data (;0;) (i32.const 1028) "t\05\00\00\09\00\00\00\0a\00\00\00\0b\00\00\00\0c\00\00\00\0d\00\00\00\0e\00\00\00\0f\00\00\00\10\00\00\00\00\00\00\00\14\05\00\00\11\00\00\00\12\00\00\00\00\00\00\00\8c\04\00\00\13\00\00\00\14\00\00\00\15\00\00\00\16\00\00\00\17\00\00\00\18\00\00\00\19\00\00\00\1a\00\00\00\1b\00\00\00\1c\00\00\00\1d\00\00\00\1e\00\00\00\1f\00\00\00 \00\00\00!\00\00\00\22\00\00\00#\00\00\00$\00\00\00%\00\00\00\d4\09\00\00\de\04\00\00\f8\04\00\00\00\00\00\00\ac\04\00\00&\00\00\00'\00\00\00(\00\00\00\d4\09\00\00\b8\04\00\00\cc\04\00\0016GpMutex_Web_Null\00\00t\0a\00\00\d4\04\00\008IGpMutex\0020GpSystemServices_Web\00\00\00\00t\0a\00\00\00\05\00\0017IGpSystemServices\00\d4\09\00\00I\05\00\00\5c\05\00\00[%02d:%02d:%02d] \00[ERROR] \00\00[WARNING] \00\0a\0015GpLogDriver_Web\00\00t\0a\00\00d\05\00\0012IGpLogDriver\00\00\d4\09\00\00\99\06\00\00\ac\06\00\00\00\00\00\00\90\05\00\00)\00\00\00*\00\00\00\d4\09\00\00\9c\05\00\00\b8\05\00\0023GpDirectoryCursor_POSIX\00\00\00t\0a\00\00\c0\05\00\0018IGpDirectoryCursor\00Packaged/Houses\00HighScores\00Houses\00SavedGames\00Prefs\00FontCache\00/\00r+b\00rb\00a+b\00x+b\00wb\00\00\00\00\00\00\00`\06\00\00+\00\00\00,\00\00\00-\00\00\00.\00\00\00/\00\00\000\00\00\001\00\00\002\00\00\003\00\00\004\00\00\005\00\00\006\00\00\00\d4\09\00\00l\06\00\00\84\06\00\0021GpFileStream_Web_File\00t\0a\00\00\8c\06\00\0010GpIOStream\0016GpFileSystem_Web\00t\0a\00\00\b4\06\00\0013IGpFileSystem\00/proc/self/fd/") + (data (;1;) (i32.const 1760) "\11\00\0a\00\11\11\11\00\00\00\00\05\00\00\00\00\00\00\09\00\00\00\00\0b\00\00\00\00\00\00\00\00\11\00\0f\0a\11\11\11\03\0a\07\00\01\00\09\0b\0b\00\00\09\06\0b\00\00\0b\00\06\11\00\00\00\11\11\11") + (data (;2;) (i32.const 1841) "\0b\00\00\00\00\00\00\00\00\11\00\0a\0a\11\11\11\00\0a\00\00\02\00\09\0b\00\00\00\09\00\0b\00\00\0b") + (data (;3;) (i32.const 1899) "\0c") + (data (;4;) (i32.const 1911) "\0c\00\00\00\00\0c\00\00\00\00\09\0c\00\00\00\00\00\0c\00\00\0c") + (data (;5;) (i32.const 1957) "\0e") + (data (;6;) (i32.const 1969) "\0d\00\00\00\04\0d\00\00\00\00\09\0e\00\00\00\00\00\0e\00\00\0e") + (data (;7;) (i32.const 2015) "\10") + (data (;8;) (i32.const 2027) "\0f\00\00\00\00\0f\00\00\00\00\09\10\00\00\00\00\00\10\00\00\10\00\00\12\00\00\00\12\12\12") + (data (;9;) (i32.const 2082) "\12\00\00\00\12\12\12\00\00\00\00\00\00\09") + (data (;10;) (i32.const 2131) "\0b") + (data (;11;) (i32.const 2143) "\0a\00\00\00\00\0a\00\00\00\00\09\0b\00\00\00\00\00\0b\00\00\0b") + (data (;12;) (i32.const 2189) "\0c") + (data (;13;) (i32.const 2201) "\0c\00\00\00\00\0c\00\00\00\00\09\0c\00\00\00\00\00\0c\00\00\0c\00\00-+ 0X0x\00(null)") + (data (;14;) (i32.const 2256) "0123456789ABCDEF-0X+0X 0X-0x+0x 0x\00INF\00inf\00NAN\00nan\00.") + (data (;15;) (i32.const 2348) "7") + (data (;16;) (i32.const 2387) "\ff\ff\ff\ff\ff") + (data (;17;) (i32.const 2456) "rwa\00St9type_info\00\00\00\00t\0a\00\00\9c\09\00\00\d4\09\00\00I\0a\00\00\ac\09\00\00\d4\09\00\00\f4\09\00\00\b4\09\00\00\00\00\00\00\18\0a\00\008\00\00\009\00\00\00:\00\00\00;\00\00\00<\00\00\00=\00\00\00>\00\00\00?\00\00\00N10__cxxabiv117__class_type_infoE\00\00\00\d4\09\00\00$\0a\00\00\c0\09\00\00N10__cxxabiv120__si_class_type_infoE\00N10__cxxabiv116__shim_type_infoE\00\00\00\00\00\00\00\c0\09\00\008\00\00\00@\00\00\00:\00\00\00;\00\00\00<\00\00\00A\00\00\00B\00\00\00C") + (data (;18;) (i32.const 2708) "\a0\04") + (data (;19;) (i32.const 2884) "\e4\0b") + (data (;20;) (i32.const 2940) "0\0eP")) diff --git a/Common/CoreDefs.h b/Common/CoreDefs.h index e22753c..55fa0c4 100644 --- a/Common/CoreDefs.h +++ b/Common/CoreDefs.h @@ -53,3 +53,19 @@ static const size_t GP_SYSTEM_MEMORY_ALIGNMENT = 16; #if !defined(GP_DEBUG_CONFIG) #error "GP_DEBUG_CONFIG was not set" #endif + +#ifdef __EMSCRIPTEN__ +#define GP_ASYNCIFY_PARANOID 1 +#else +#define GP_ASYNCIFY_PARANOID 0 +#endif + +#if GP_ASYNCIFY_PARANOID +#define GP_ASYNCIFY_PARANOID_VIRTUAL +#define GP_ASYNCIFY_PARANOID_PURE +#define GP_ASYNCIFY_PARANOID_OVERRIDE +#else +#define GP_ASYNCIFY_PARANOID_VIRTUAL virtual +#define GP_ASYNCIFY_PARANOID_PURE = 0 +#define GP_ASYNCIFY_PARANOID_OVERRIDE override +#endif diff --git a/GpApp/About.cpp b/GpApp/About.cpp index 41083e6..eaa2c9d 100644 --- a/GpApp/About.cpp +++ b/GpApp/About.cpp @@ -136,7 +136,7 @@ void DoAbout (void) do // Loop until user wants to exit { - hit = aboutDialog->ExecuteModal(nullptr, AboutFilter); + hit = aboutDialog->ExecuteModal(nullptr, PL_FILTER_FUNC(AboutFilter)); } while (hit != kOkayButton); @@ -218,7 +218,7 @@ void DoLicenseReader(int resID) do { - hit = dialog->ExecuteModal(nullptr, LicenseReaderFilter); + hit = dialog->ExecuteModal(nullptr, PL_FILTER_FUNC(LicenseReaderFilter)); } while (hit != kOkayButton); dialog->Destroy(); @@ -265,7 +265,7 @@ void DoAboutOpenSource(void) do { - hit = dialog->ExecuteModal(nullptr, AboutFrameworkFilter); + hit = dialog->ExecuteModal(nullptr, PL_FILTER_FUNC(AboutFrameworkFilter)); switch (hit) { @@ -359,7 +359,7 @@ void DoAboutFramework (void) do { - hit = dialog->ExecuteModal(nullptr, AboutFrameworkFilter); + hit = dialog->ExecuteModal(nullptr, PL_FILTER_FUNC(AboutFrameworkFilter)); if (hit == kAboutOpenSourceButton) DoAboutOpenSource(); @@ -766,3 +766,6 @@ static int16_t LicenseReaderFilter(void *context, Dialog *dialog, const TimeTagg return hit; } +PL_IMPLEMENT_FILTER_FUNCTION(AboutFilter) +PL_IMPLEMENT_FILTER_FUNCTION(LicenseReaderFilter) +PL_IMPLEMENT_FILTER_FUNCTION(AboutFrameworkFilter) diff --git a/GpApp/AnimCursor.cpp b/GpApp/AnimCursor.cpp index 19144bb..830203f 100644 --- a/GpApp/AnimCursor.cpp +++ b/GpApp/AnimCursor.cpp @@ -12,9 +12,10 @@ #include "MemoryManager.h" #include "ResourceManager.h" +#include "PLBigEndian.h" #include "PLDrivers.h" #include "PLResources.h" -#include "PLBigEndian.h" +#include "PLSysCalls.h" #include @@ -375,6 +376,8 @@ void DecrementCursor (void) void SpinCursor (short incrementIndex) { + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); + UInt32 dummyLong; short i; diff --git a/GpApp/Banner.cpp b/GpApp/Banner.cpp index 70e2f7a..2c224b5 100644 --- a/GpApp/Banner.cpp +++ b/GpApp/Banner.cpp @@ -21,6 +21,7 @@ #include "Utilities.h" #include "WindowDef.h" #include "WindowManager.h" +#include "PLSysCalls.h" #define kBannerPageTopPICT 1993 @@ -179,11 +180,13 @@ void BringUpBanner (void) (BitMap *)*GetGWorldPixMap(workSrcMap), &wholePage, &wholePage, srcCopy); - - if (demoGoing) - WaitForInputEvent(4); - else - WaitForInputEvent(15); + { + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); + if (demoGoing) + WaitForInputEvent(4); + else + WaitForInputEvent(15); + } // if (quickerTransitions) // DissBitsChunky(&justRoomsRect); @@ -237,8 +240,11 @@ void DisplayStarsRemaining(void) if (doZooms) wm->FlickerWindowIn(starsWindow, 32); - DelayTicks(60); - WaitForInputEvent(30); + { + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); + DelayTicks(60); + WaitForInputEvent(30); + } if (doZooms) wm->FlickerWindowOut(starsWindow, 32); diff --git a/GpApp/DialogUtils.cpp b/GpApp/DialogUtils.cpp index fcd7af3..0abaaa7 100644 --- a/GpApp/DialogUtils.cpp +++ b/GpApp/DialogUtils.cpp @@ -11,6 +11,7 @@ #include "PLNumberFormatting.h" #include "PLPasStr.h" #include "PLStandardColors.h" +#include "PLSysCalls.h" #include "PLWidgets.h" #include "QDStandardPalette.h" #include "DialogUtils.h" @@ -341,6 +342,8 @@ void ZoomOutAlertRect (short alertID) void FlashDialogButton (Dialog *theDialog, short itemNumber) { + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); + ControlHandle itemHandle; UInt32 dummyLong; diff --git a/GpApp/Environ.h b/GpApp/Environ.h index ccaf2c3..33fec7f 100644 --- a/GpApp/Environ.h +++ b/GpApp/Environ.h @@ -3,7 +3,7 @@ // Environ.h //---------------------------------------------------------------------------- //============================================================================ - +#pragma once #include "PLQDraw.h" diff --git a/GpApp/Events.cpp b/GpApp/Events.cpp index 6314b86..8e94c1e 100644 --- a/GpApp/Events.cpp +++ b/GpApp/Events.cpp @@ -19,6 +19,7 @@ #include "Rect2i.h" #include "WindowManager.h" +#include "PLSysCalls.h" void HandleMouseEvent (const GpMouseInputEvent &, uint32_t); void HandleKeyEvent (const KeyDownStates &keyStates, const GpKeyboardInputEvent &); @@ -419,7 +420,10 @@ void HandleEvent (void) SelectTool(kSelectTool); } - itHappened = WaitForEvent(&theEvent, sleep); + { + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); + itHappened = WaitForEvent(&theEvent, sleep); + } if (itHappened) { diff --git a/GpApp/GameOver.cpp b/GpApp/GameOver.cpp index 4d8c2b0..b5beec7 100644 --- a/GpApp/GameOver.cpp +++ b/GpApp/GameOver.cpp @@ -21,6 +21,7 @@ #include "RenderedFont.h" #include "ResolveCachingColor.h" #include "Utilities.h" +#include "PLSysCalls.h" #define kNumCountDownFrames 16 @@ -489,6 +490,7 @@ void DoDiedGameOver (void) } } + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); Delay(1, nullptr); } while (TickCount() < nextLoop); diff --git a/GpApp/GpAppInterface.cpp b/GpApp/GpAppInterface.cpp index 7224786..fc62ec3 100644 --- a/GpApp/GpAppInterface.cpp +++ b/GpApp/GpAppInterface.cpp @@ -14,8 +14,8 @@ void gpAppInit(); class GpAppInterfaceImpl final : public GpAppInterface { public: - void ApplicationInit() override; - int ApplicationMain() override; + void ApplicationInit() GP_ASYNCIFY_PARANOID_OVERRIDE; + int ApplicationMain() GP_ASYNCIFY_PARANOID_OVERRIDE; void PL_IncrementTickCounter(uint32_t count) override; void PL_Render(IGpDisplayDriver *displayDriver) override; @@ -30,7 +30,11 @@ void GpAppInterfaceImpl::ApplicationInit() int GpAppInterfaceImpl::ApplicationMain() { +#if GP_ASYNCIFY_PARANOID + return gpAppMain(); +#else return PLSysCalls::MainExitWrapper(gpAppMain); +#endif } void GpAppInterfaceImpl::PL_IncrementTickCounter(uint32_t count) @@ -69,3 +73,15 @@ GP_APP_DLL_EXPORT_API GpAppInterface *GpAppInterface_Get() { return &gs_application; } + +#if GP_ASYNCIFY_PARANOID +void GpAppInterface::ApplicationInit() +{ + static_cast(this)->ApplicationInit(); +} + +int GpAppInterface::ApplicationMain() +{ + return static_cast(this)->ApplicationMain(); +} +#endif diff --git a/GpApp/GpApp_Combined.cpp b/GpApp/GpApp_Combined.cpp new file mode 100644 index 0000000..a0b34db --- /dev/null +++ b/GpApp/GpApp_Combined.cpp @@ -0,0 +1,69 @@ +#include "About.cpp" +#include "AnimCursor.cpp" +#include "AppleEvents.cpp" +#include "Banner.cpp" +#include "ColorUtils.cpp" +#include "Coordinates.cpp" +#include "DialogUtils.cpp" +#include "DynamicMaps.cpp" +#include "Dynamics.cpp" +#include "Dynamics2.cpp" +#include "Dynamics3.cpp" +#include "Environ.cpp" +#include "Events.cpp" +#include "FileError.cpp" +#include "GameOver.cpp" +#include "GpAppInterface.cpp" +#include "Grease.cpp" +#include "HighScores.cpp" +#include "House.cpp" +#include "HouseInfo.cpp" +#include "HouseIO.cpp" +#include "HouseLegal.cpp" +#include "Input.cpp" +#include "Interactions.cpp" +#include "InterfaceInit.cpp" +#include "Link.cpp" +#include "Main.cpp" +#include "MainMenuUI.cpp" +#include "MainWindow.cpp" +#include "Map.cpp" +#include "Marquee.cpp" +#include "Menu.cpp" +#include "Modes.cpp" +#include "Music.cpp" +#include "ObjectAdd.cpp" +#include "ObjectDraw.cpp" +#include "ObjectDraw2.cpp" +#include "ObjectDrawAll.cpp" +#include "ObjectEdit.cpp" +#include "ObjectInfo.cpp" +#include "ObjectRects.cpp" +#include "Objects.cpp" +#include "Play.cpp" +#include "Player.cpp" +#include "Prefs.cpp" +#include "RectUtils.cpp" +#include "Render.cpp" +#include "Room.cpp" +#include "RoomGraphics.cpp" +#include "RoomInfo.cpp" +#include "RubberBands.cpp" +#include "SavedGames.cpp" +#include "Scoreboard.cpp" +#include "Scrap.cpp" +#include "SelectHouse.cpp" +#include "Settings.cpp" +#include "Sound.cpp" +#include "SoundSync_Cpp11.cpp" +#include "SourceExport.cpp" +#include "StringUtils.cpp" +#include "StructuresInit.cpp" +#include "StructuresInit2.cpp" +#include "Tools.cpp" +#include "Transit.cpp" +#include "Transitions.cpp" +#include "Triggers.cpp" +#include "Trip.cpp" +#include "Utilities.cpp" +#include "WindowUtils.cpp" diff --git a/GpApp/HighScores.cpp b/GpApp/HighScores.cpp index 4b9eb74..c033ad9 100644 --- a/GpApp/HighScores.cpp +++ b/GpApp/HighScores.cpp @@ -96,8 +96,12 @@ void DoHighScores (void) // DissBits(&workSrcRect); InitCursor(); - DelayTicks(60); - WaitForInputEvent(30); + + { + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); + DelayTicks(60); + WaitForInputEvent(30); + } RedrawSplashScreen(); } @@ -553,7 +557,7 @@ void GetHighScoreName (short place) while (!leaving) { - item = theDial->ExecuteModal(nullptr, NameFilter); + item = theDial->ExecuteModal(nullptr, PL_FILTER_FUNC(NameFilter)); if (item == kOkayButton) { @@ -666,7 +670,7 @@ void GetHighScoreBanner (void) while (!leaving) { - item = theDial->ExecuteModal(nullptr, BannerFilter); + item = theDial->ExecuteModal(nullptr, PL_FILTER_FUNC(BannerFilter)); if (item == kOkayButton) { @@ -789,3 +793,5 @@ Boolean ReadScoresFromDisk (void) return (true); } +PL_IMPLEMENT_FILTER_FUNCTION(NameFilter) +PL_IMPLEMENT_FILTER_FUNCTION(BannerFilter) diff --git a/GpApp/House.cpp b/GpApp/House.cpp index 41ee32b..78042ed 100644 --- a/GpApp/House.cpp +++ b/GpApp/House.cpp @@ -52,24 +52,24 @@ extern Boolean houseOpen, noRoomAtAll; extern Boolean twoPlayerGame, wardBitSet, phoneBitSet; -static void FBUI_DrawLabels(DrawSurface *surface, const Point &basePoint) +static void FBUI_House_DrawLabels(DrawSurface *surface, const Point &basePoint) { } -static void FBUI_DrawFileDetails(DrawSurface *surface, const Point &basePoint, const Rect &constraintRect, void *fileDetails) +static void FBUI_House_DrawFileDetails(DrawSurface *surface, const Point &basePoint, const Rect &constraintRect, void *fileDetails) { } -static void *FBUI_LoadFileDetails(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename) +static void *FBUI_House_LoadFileDetails(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename) { return nullptr; } -static void FBUI_FreeFileDetails(void *fileDetails) +static void FBUI_House_FreeFileDetails(void *fileDetails) { } -static bool FBUI_FilterFile(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename) +static bool FBUI_House_FilterFile(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename) { PortabilityLayer::CompositeFile *cfile = PortabilityLayer::FileManager::GetInstance()->OpenCompositeFile(dirID, filename); @@ -80,11 +80,11 @@ static PortabilityLayer::FileBrowserUI_DetailsCallbackAPI GetHouseDetailsAPI() { PortabilityLayer::FileBrowserUI_DetailsCallbackAPI api; - api.m_drawLabelsCallback = FBUI_DrawLabels; - api.m_drawFileDetailsCallback = FBUI_DrawFileDetails; - api.m_loadFileDetailsCallback = FBUI_LoadFileDetails; - api.m_freeFileDetailsCallback = FBUI_FreeFileDetails; - api.m_filterFileCallback = FBUI_FilterFile; + api.m_drawLabelsCallback = FBUI_House_DrawLabels; + api.m_drawFileDetailsCallback = FBUI_House_DrawFileDetails; + api.m_loadFileDetailsCallback = FBUI_House_LoadFileDetails; + api.m_freeFileDetailsCallback = FBUI_House_FreeFileDetails; + api.m_filterFileCallback = FBUI_House_FilterFile; return api; } @@ -707,7 +707,7 @@ int16_t GoToFilter(void *context, Dialog *dial, const TimeTaggedVOSEvent *evt) while (!leaving) { - item = theDialog->ExecuteModal(nullptr, GoToFilter); + item = theDialog->ExecuteModal(nullptr, PL_FILTER_FUNC(GoToFilter)); if (item == kOkayButton) { @@ -863,3 +863,4 @@ void ShiftWholeHouse (short howFar) CloseMessageWindow(); } +PL_IMPLEMENT_FILTER_FUNCTION(GoToFilter) diff --git a/GpApp/HouseInfo.cpp b/GpApp/HouseInfo.cpp index 244852c..14b8d06 100644 --- a/GpApp/HouseInfo.cpp +++ b/GpApp/HouseInfo.cpp @@ -249,7 +249,7 @@ void DoHouseInfo (void) while (!leaving) { - item = houseInfoDialog->ExecuteModal(nullptr, HouseFilter); + item = houseInfoDialog->ExecuteModal(nullptr, PL_FILTER_FUNC(HouseFilter)); if (item == kOkayButton) { @@ -334,3 +334,4 @@ void HowToZeroScores (void) #endif +PL_IMPLEMENT_FILTER_FUNCTION(HouseFilter) diff --git a/GpApp/Main.cpp b/GpApp/Main.cpp index c30ee87..f731985 100644 --- a/GpApp/Main.cpp +++ b/GpApp/Main.cpp @@ -15,6 +15,7 @@ #include "FontManager.h" #include "GpApplicationName.h" #include "GpRenderedFontMetrics.h" +#include "IGpLogDriver.h" #include "IGpMutex.h" #include "IGpThreadEvent.h" #include "IGpDisplayDriver.h" @@ -519,15 +520,20 @@ void gpAppInit() //-------------------------------------------------------------- main // Here is main(). The first function called when Glider PRO comes up. -int gpAppMain() +int AppStartup() { -// long wasSeed; + // long wasSeed; long theErr; PLError_t fileErr; Boolean whoCares, copyGood; PL_Init(); + IGpLogDriver *logger = PLDrivers::GetLogDriver(); + + if (logger) + logger->Printf(IGpLogDriver::Category_Information, "Init phase 1..."); + ToolBoxInit(); CheckOurEnvirons(); @@ -540,18 +546,24 @@ int gpAppMain() RedAlert(kErrNeedSystem7); if (thisMac.numScreens == 0) RedAlert(kErrNeed16Or256Colors); -// dataResFile = OpenResFile("\pMermaid"); + // dataResFile = OpenResFile("\pMermaid"); SetUpAppleEvents(); LoadCursors(); ReadInPrefs(); + if (logger) + logger->Printf(IGpLogDriver::Category_Information, "Init phase 2..."); + SpinCursor(2); // Tick once to let the display driver flush any resolution changes from prefs FlushResolutionChange(); + if (logger) + logger->Printf(IGpLogDriver::Category_Information, "Init phase 3..."); + #if defined COMPILEDEMO copyGood = true; #elif defined COMPILENOCP -// didValidation = false; + // didValidation = false; copyGood = true; #else didValidation = false; @@ -562,8 +574,8 @@ int gpAppMain() WriteOutPrefs(); SpinCursor(3); #endif -// if ((thisMac.numScreens > 1) && (isUseSecondScreen)) -// ReflectSecondMonitorEnvirons(false, true, true); + // if ((thisMac.numScreens > 1) && (isUseSecondScreen)) + // ReflectSecondMonitorEnvirons(false, true, true); HandleDepthSwitching(); VariableInit(); GetExtraCursors(); @@ -572,6 +584,9 @@ int gpAppMain() InitSrcRects(); CreateOffscreens(); + if (logger) + logger->Printf(IGpLogDriver::Category_Information, "Init phase 3..."); + bool resolutionChanged = false; if (!isPrefsLoaded) @@ -598,19 +613,32 @@ int gpAppMain() if (isDoColorFade) PortabilityLayer::WindowManager::GetInstance()->SetWindowDesaturation(mainWindow, 1.0); + if (logger) + logger->Printf(IGpLogDriver::Category_Information, "Init phase 4..."); + InitSound(); SpinCursor(2); InitMusic(); SpinCursor(2); + + if (logger) + logger->Printf(IGpLogDriver::Category_Information, "Init phase 5..."); + BuildHouseList(); OpenHouse(true); PlayPrioritySound(kBirdSound, kBirdPriority); - DelayTicks(6); + { + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); + DelayTicks(6); + } InitializeMenus(); InitCursor(); #if BUILD_ARCADE_VERSION -// HideMenuBarOld(); + // HideMenuBarOld(); #endif + if (logger) + logger->Printf(IGpLogDriver::Category_Information, "Initialization completed"); + if (isDoColorFade) WashColorIn(); @@ -619,14 +647,16 @@ int gpAppMain() if (thisMac.isTouchscreen) StartMainMenuUI(); - while (!quitting) // this is the main loop - HandleEvent(); + return 0; +} -/* -#if BUILD_ARCADE_VERSION - ShowMenuBarOld(); -#endif -*/ +int AppShutdown() +{ + /* + #if BUILD_ARCADE_VERSION + ShowMenuBarOld(); + #endif + */ KillMusic(); KillSound(); if (houseOpen) @@ -641,8 +671,19 @@ int gpAppMain() } WriteOutPrefs(); PL_DEAD(FlushEvents()); -// theErr = LoadScrap(); + // theErr = LoadScrap(); return 0; } +int gpAppMain() +{ + int returnCode = AppStartup(); + if (returnCode != 0) + return returnCode; + + while (!quitting) // this is the main loop + HandleEvent(); + + return AppShutdown(); +} diff --git a/GpApp/MainWindow.cpp b/GpApp/MainWindow.cpp index effe354..bd274de 100644 --- a/GpApp/MainWindow.cpp +++ b/GpApp/MainWindow.cpp @@ -23,6 +23,7 @@ #include "PLDrivers.h" #include "PLNumberFormatting.h" #include "PLPasStr.h" +#include "PLSysCalls.h" #define kMainWindowID 128 #define kEditWindowID 129 @@ -571,6 +572,8 @@ void HardDrawMainWindow (void) // palette. In this way, color appears to slowly wash in. void WashColorIn (void) { + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); + #define kGray2ColorSteps 180 long longDelta; short i, c; diff --git a/GpApp/ObjectInfo.cpp b/GpApp/ObjectInfo.cpp index 7c4281c..bedff3c 100644 --- a/GpApp/ObjectInfo.cpp +++ b/GpApp/ObjectInfo.cpp @@ -785,7 +785,7 @@ void DoBlowerObjectInfo (short what) { bool redrawMain = false; - item = infoDial->ExecuteModal(nullptr, BlowerFilter); + item = infoDial->ExecuteModal(nullptr, PL_FILTER_FUNC(BlowerFilter)); if (item == kOkayButton) { @@ -937,7 +937,7 @@ void DoFurnitureObjectInfo (void) while (!leaving) { - item = infoDial->ExecuteModal(nullptr, FurnitureFilter); + item = infoDial->ExecuteModal(nullptr, PL_FILTER_FUNC(FurnitureFilter)); if (item == kOkayButton) leaving = true; @@ -997,7 +997,7 @@ void DoCustPictObjectInfo (void) { bool redrawMain = false; - item = infoDial->ExecuteModal(nullptr, CustPictFilter); + item = infoDial->ExecuteModal(nullptr, PL_FILTER_FUNC(CustPictFilter)); if (item == kOkayButton) { @@ -1106,7 +1106,7 @@ void DoSwitchObjectInfo (void) while (!leaving) { - item = infoDial->ExecuteModal(nullptr, SwitchFilter); + item = infoDial->ExecuteModal(nullptr, PL_FILTER_FUNC(SwitchFilter)); if (item == kOkayButton) { @@ -1231,7 +1231,7 @@ void DoTriggerObjectInfo (void) while (!leaving) { - item = infoDial->ExecuteModal(nullptr, TriggerFilter); + item = infoDial->ExecuteModal(nullptr, PL_FILTER_FUNC(TriggerFilter)); if (item == kOkayButton) { @@ -1371,7 +1371,7 @@ void DoLightObjectInfo (void) while (!leaving) { bool redrawMain = false; - item = infoDial->ExecuteModal(nullptr, LightFilter); + item = infoDial->ExecuteModal(nullptr, PL_FILTER_FUNC(LightFilter)); if (item == kOkayButton) { @@ -1465,7 +1465,7 @@ void DoApplianceObjectInfo (short what) while (!leaving) { bool redrawMain = false; - item = infoDial->ExecuteModal(nullptr, ApplianceFilter); + item = infoDial->ExecuteModal(nullptr, PL_FILTER_FUNC(ApplianceFilter)); if (item == kOkayButton) { @@ -1585,7 +1585,7 @@ void DoMicrowaveObjectInfo (void) while (!leaving) { bool redrawMain = false; - item = infoDial->ExecuteModal(nullptr, MicrowaveFilter); + item = infoDial->ExecuteModal(nullptr, PL_FILTER_FUNC(MicrowaveFilter)); if (item == kOkayButton) { @@ -1695,7 +1695,7 @@ void DoGreaseObjectInfo (void) { bool redrawMain = false; - item = infoDial->ExecuteModal(nullptr, GreaseFilter); + item = infoDial->ExecuteModal(nullptr, PL_FILTER_FUNC(GreaseFilter)); if (item == kOkayButton) { @@ -1783,7 +1783,7 @@ void DoInvisBonusObjectInfo (void) while (!leaving) { - item = infoDial->ExecuteModal(nullptr, InvisBonusFilter); + item = infoDial->ExecuteModal(nullptr, PL_FILTER_FUNC(InvisBonusFilter)); if (item == kOkayButton) { @@ -1907,7 +1907,7 @@ void DoTransObjectInfo (short what) while (!leaving) { - item = infoDial->ExecuteModal(nullptr, TransFilter); + item = infoDial->ExecuteModal(nullptr, PL_FILTER_FUNC(TransFilter)); if (item == kOkayButton) { @@ -2017,7 +2017,7 @@ void DoEnemyObjectInfo (short what) while (!leaving) { - item = infoDial->ExecuteModal(nullptr, EnemyFilter); + item = infoDial->ExecuteModal(nullptr, PL_FILTER_FUNC(EnemyFilter)); if (item == kOkayButton) { @@ -2113,7 +2113,7 @@ void DoFlowerObjectInfo (void) { bool redrawMain = false; - item = infoDial->ExecuteModal(nullptr, FlowerFilter); + item = infoDial->ExecuteModal(nullptr, PL_FILTER_FUNC(FlowerFilter)); if (item == kOkayButton) { @@ -2361,3 +2361,17 @@ void DoObjectInfo (void) #endif +PL_IMPLEMENT_FILTER_FUNCTION(BlowerFilter) +PL_IMPLEMENT_FILTER_FUNCTION(FurnitureFilter) +PL_IMPLEMENT_FILTER_FUNCTION(CustPictFilter) +PL_IMPLEMENT_FILTER_FUNCTION(SwitchFilter) +PL_IMPLEMENT_FILTER_FUNCTION(TriggerFilter) +PL_IMPLEMENT_FILTER_FUNCTION(LightFilter) +PL_IMPLEMENT_FILTER_FUNCTION(ApplianceFilter) +PL_IMPLEMENT_FILTER_FUNCTION(MicrowaveFilter) +PL_IMPLEMENT_FILTER_FUNCTION(GreaseFilter) +PL_IMPLEMENT_FILTER_FUNCTION(InvisBonusFilter) +PL_IMPLEMENT_FILTER_FUNCTION(TransFilter) +PL_IMPLEMENT_FILTER_FUNCTION(EnemyFilter) +PL_IMPLEMENT_FILTER_FUNCTION(FlowerFilter) + diff --git a/GpApp/Render.cpp b/GpApp/Render.cpp index 3ce5c7c..efdc646 100644 --- a/GpApp/Render.cpp +++ b/GpApp/Render.cpp @@ -16,7 +16,7 @@ #include "RectUtils.h" #include "Room.h" #include "RubberBands.h" - +#include "PLSysCalls.h" #define kMaxGarbageRects 48 @@ -739,6 +739,7 @@ void RenderFrame (void) while (TickCount() < nextFrame) { + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); Delay(1, nullptr); } nextFrame = TickCount() + kTicksPerFrame; diff --git a/GpApp/RoomInfo.cpp b/GpApp/RoomInfo.cpp index 607f832..122ecec 100644 --- a/GpApp/RoomInfo.cpp +++ b/GpApp/RoomInfo.cpp @@ -502,7 +502,7 @@ void DoRoomInfo(void) { bool needRedraw = false; - item = roomInfoDialog->ExecuteModal(nullptr, RoomFilter); + item = roomInfoDialog->ExecuteModal(nullptr, PL_FILTER_FUNC(RoomFilter)); if (item == kOkayButton) { @@ -737,7 +737,7 @@ short ChooseOriginalArt (short was) while (!leaving) { - item = theDialog->ExecuteModal(nullptr, OriginalArtFilter); + item = theDialog->ExecuteModal(nullptr, PL_FILTER_FUNC(OriginalArtFilter)); if (item == kOkayButton) { @@ -881,3 +881,5 @@ void ComplainAboutPICTNotFound (void) } #endif +PL_IMPLEMENT_FILTER_FUNCTION(RoomFilter) +PL_IMPLEMENT_FILTER_FUNCTION(OriginalArtFilter) diff --git a/GpApp/SavedGames.cpp b/GpApp/SavedGames.cpp index a955d74..10aa2c7 100644 --- a/GpApp/SavedGames.cpp +++ b/GpApp/SavedGames.cpp @@ -41,7 +41,7 @@ static const int kStarsOffset = 180; static const int kGlidersOffset = 260; static const int kScoreOffset = 320; -static void FBUI_DrawLabels(DrawSurface *surface, const Point &basePoint) +static void FBUI_Save_DrawLabels(DrawSurface *surface, const Point &basePoint) { PortabilityLayer::ResolveCachingColor blackColor(StdColors::Black()); PortabilityLayer::RenderedFont *rfont = GetFont(PortabilityLayer::FontPresets::kSystem12Bold); @@ -51,7 +51,7 @@ static void FBUI_DrawLabels(DrawSurface *surface, const Point &basePoint) surface->DrawString(basePoint + Point::Create(kScoreOffset, 0), PSTR("Score"), blackColor, rfont); } -static void FBUI_DrawFileDetails(DrawSurface *surface, const Point &basePoint, const Rect &constraintRect, void *fileDetails) +static void FBUI_Save_DrawFileDetails(DrawSurface *surface, const Point &basePoint, const Rect &constraintRect, void *fileDetails) { PortabilityLayer::ResolveCachingColor blackColor(StdColors::Black()); PortabilityLayer::RenderedFont *rfont = GetFont(PortabilityLayer::FontPresets::kSystem12Bold); @@ -70,7 +70,7 @@ static void FBUI_DrawFileDetails(DrawSurface *surface, const Point &basePoint, c surface->DrawString(basePoint + Point::Create(kScoreOffset, 0), numStr, blackColor, rfont); } -static void *FBUI_LoadFileDetails(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename) +static void *FBUI_Save_LoadFileDetails(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename) { GpIOStream *stream = nullptr; if (PortabilityLayer::FileManager::GetInstance()->OpenNonCompositeFile(dirID, filename, ".sav", PortabilityLayer::EFilePermission_Read, GpFileCreationDispositions::kOpenExisting, stream) != PLErrors::kNone) @@ -97,12 +97,12 @@ static void *FBUI_LoadFileDetails(PortabilityLayer::VirtualDirectory_t dirID, co return gameData; } -static void FBUI_FreeFileDetails(void *fileDetails) +static void FBUI_Save_FreeFileDetails(void *fileDetails) { PortabilityLayer::MemoryManager::GetInstance()->Release(fileDetails); } -static bool FBUI_FilterFile(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename) +static bool FBUI_Save_FilterFile(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &filename) { return true; } @@ -111,11 +111,11 @@ static PortabilityLayer::FileBrowserUI_DetailsCallbackAPI GetSavedGameDetailsAPI { PortabilityLayer::FileBrowserUI_DetailsCallbackAPI api; - api.m_drawLabelsCallback = FBUI_DrawLabels; - api.m_drawFileDetailsCallback = FBUI_DrawFileDetails; - api.m_loadFileDetailsCallback = FBUI_LoadFileDetails; - api.m_freeFileDetailsCallback = FBUI_FreeFileDetails; - api.m_filterFileCallback = FBUI_FilterFile; + api.m_drawLabelsCallback = FBUI_Save_DrawLabels; + api.m_drawFileDetailsCallback = FBUI_Save_DrawFileDetails; + api.m_loadFileDetailsCallback = FBUI_Save_LoadFileDetails; + api.m_freeFileDetailsCallback = FBUI_Save_FreeFileDetails; + api.m_filterFileCallback = FBUI_Save_FilterFile; return api; } diff --git a/GpApp/SelectHouse.cpp b/GpApp/SelectHouse.cpp index 54fe0c8..cc47439 100644 --- a/GpApp/SelectHouse.cpp +++ b/GpApp/SelectHouse.cpp @@ -407,7 +407,7 @@ void DoLoadHouse (void) while (!leaving) { - int16_t item = theDial->ExecuteModal(nullptr, LoadFilter); + int16_t item = theDial->ExecuteModal(nullptr, PL_FILTER_FUNC(LoadFilter)); bool requiresRedraw = false; @@ -665,3 +665,4 @@ void AddExtraHouse (const VFileSpec &newHouse) numExtraHouses++; } +PL_IMPLEMENT_FILTER_FUNCTION(LoadFilter) diff --git a/GpApp/Settings.cpp b/GpApp/Settings.cpp index 6e666b6..83ab590 100644 --- a/GpApp/Settings.cpp +++ b/GpApp/Settings.cpp @@ -254,7 +254,7 @@ void DoBrainsPrefs (void) while (!leaving) { - itemHit = prefDlg->ExecuteModal(nullptr, BrainsFilter); + itemHit = prefDlg->ExecuteModal(nullptr, PL_FILTER_FUNC(BrainsFilter)); switch (itemHit) { case kOkayButton: @@ -536,7 +536,7 @@ void DoControlPrefs (void) while (!leaving) { - itemHit = prefDlg->ExecuteModal(nullptr, ControlFilter); + itemHit = prefDlg->ExecuteModal(nullptr, PL_FILTER_FUNC(ControlFilter)); switch (itemHit) { case kOkayButton: @@ -758,7 +758,7 @@ void DoSoundPrefs (void) while (!leaving) { - itemHit = prefDlg->ExecuteModal(nullptr, SoundFilter); + itemHit = prefDlg->ExecuteModal(nullptr, PL_FILTER_FUNC(SoundFilter)); switch (itemHit) { @@ -1026,7 +1026,7 @@ void DoDisplayPrefs (void) while (!leaving) { - int16_t itemHit = prefDlg->ExecuteModal(nullptr, DisplayFilter); + int16_t itemHit = prefDlg->ExecuteModal(nullptr, PL_FILTER_FUNC(DisplayFilter)); switch (itemHit) { case kOkayButton: @@ -1166,6 +1166,8 @@ void SetAllDefaults (void) void FlashSettingsButton (DrawSurface *surface, short who) { + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); + #define kNormalSettingsIcon 1010 #define kInvertedSettingsIcon 1014 short theID; @@ -1293,7 +1295,7 @@ void DoSettingsMain (void) while (!leaving) { - int16_t selectedItem = prefDlg->ExecuteModal(nullptr, PrefsFilter); + int16_t selectedItem = prefDlg->ExecuteModal(nullptr, PL_FILTER_FUNC(PrefsFilter)); switch (selectedItem) { @@ -1374,3 +1376,8 @@ void ComplainAboutChanges (void) hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kChangesEffectAlert, nullptr); } +PL_IMPLEMENT_FILTER_FUNCTION(BrainsFilter) +PL_IMPLEMENT_FILTER_FUNCTION(ControlFilter) +PL_IMPLEMENT_FILTER_FUNCTION(SoundFilter) +PL_IMPLEMENT_FILTER_FUNCTION(DisplayFilter) +PL_IMPLEMENT_FILTER_FUNCTION(PrefsFilter) diff --git a/GpApp/Transitions.cpp b/GpApp/Transitions.cpp index 4e10ed6..ca026b8 100644 --- a/GpApp/Transitions.cpp +++ b/GpApp/Transitions.cpp @@ -14,6 +14,7 @@ #include "PLQDraw.h" #include "RectUtils.h" #include "RandomNumberGenerator.h" +#include "PLSysCalls.h" #include @@ -166,6 +167,7 @@ void WipeScreenOn (short direction, Rect *theRect) mainWindow->GetDrawSurface()->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents); + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); Delay(1, nullptr); } } @@ -229,7 +231,10 @@ void DissolveScreenOn(Rect *theRect) graf->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents); - Delay(1, nullptr); + { + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); + Delay(1, nullptr); + } } graf->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents); diff --git a/GpApp/Utilities.cpp b/GpApp/Utilities.cpp index 9eb191c..d648936 100644 --- a/GpApp/Utilities.cpp +++ b/GpApp/Utilities.cpp @@ -18,11 +18,14 @@ #include "DialogManager.h" #include "DisplayDeviceManager.h" #include "Externs.h" +#include "IGpLogDriver.h" #include "IconLoader.h" #include "InputManager.h" #include "ResourceManager.h" #include "Utilities.h" +#include "PLDrivers.h" + #include @@ -92,6 +95,11 @@ long RandomLong (long range) void RedAlert (short errorNumber) { + IGpLogDriver *logger = PLDrivers::GetLogDriver(); + + if (logger) + logger->Printf(IGpLogDriver::Category_Error, "Red alert error %i", static_cast(errorNumber)); + #define rDeathAlertID 170 // alert res. ID for death error #define rErrTitleID 170 // string ID for death error title #define rErrMssgID 171 // string ID for death error message @@ -486,6 +494,7 @@ void WaitCommandQReleased (void) if (!theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kControl)) || !theKeys->IsSet(PL_KEY_ASCII('Q'))) waiting = false; + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); Delay(1, nullptr); } FlushEvents(); diff --git a/GpCommon/IGpClipboardContents.h b/GpCommon/IGpClipboardContents.h index 6291c44..9682bb3 100644 --- a/GpCommon/IGpClipboardContents.h +++ b/GpCommon/IGpClipboardContents.h @@ -1,3 +1,5 @@ +#pragma once + #include "GpClipboardContentsType.h" #include diff --git a/GpCommon/IGpDisplayDriver.h b/GpCommon/IGpDisplayDriver.h index bda8036..32f957a 100644 --- a/GpCommon/IGpDisplayDriver.h +++ b/GpCommon/IGpDisplayDriver.h @@ -1,5 +1,6 @@ #pragma once +#include "CoreDefs.h" #include "GpPixelFormat.h" #include "EGpStandardCursor.h" @@ -29,10 +30,10 @@ struct IGpDisplayDriver { typedef void (*SurfaceInvalidateCallback_t) (void *context); - virtual bool Init() = 0; - virtual void ServeTicks(int tickCount) = 0; + GP_ASYNCIFY_PARANOID_VIRTUAL bool Init() GP_ASYNCIFY_PARANOID_PURE; + GP_ASYNCIFY_PARANOID_VIRTUAL void ServeTicks(int tickCount) GP_ASYNCIFY_PARANOID_PURE; virtual void ForceSync() = 0; - virtual void Shutdown() = 0; + GP_ASYNCIFY_PARANOID_VIRTUAL void Shutdown() GP_ASYNCIFY_PARANOID_PURE; // Returns the initial resolution before any display resolution events are posted virtual void GetInitialDisplayResolution(unsigned int *width, unsigned int *height) = 0; @@ -40,8 +41,8 @@ struct IGpDisplayDriver virtual IGpDisplayDriverSurface *CreateSurface(size_t width, size_t height, size_t pitch, GpPixelFormat_t pixelFormat, SurfaceInvalidateCallback_t invalidateCallback, void *invalidateContext) = 0; virtual void DrawSurface(IGpDisplayDriverSurface *surface, int32_t x, int32_t y, size_t width, size_t height, const GpDisplayDriverSurfaceEffects *effects) = 0; - virtual IGpCursor *CreateBWCursor(size_t width, size_t height, const void *pixelData, const void *maskData, size_t hotSpotX, size_t hotSpotY) = 0; - virtual IGpCursor *CreateColorCursor(size_t width, size_t height, const void *pixelDataRGBA, size_t hotSpotX, size_t hotSpotY) = 0; + GP_ASYNCIFY_PARANOID_VIRTUAL IGpCursor *CreateBWCursor(size_t width, size_t height, const void *pixelData, const void *maskData, size_t hotSpotX, size_t hotSpotY) GP_ASYNCIFY_PARANOID_PURE; + GP_ASYNCIFY_PARANOID_VIRTUAL IGpCursor *CreateColorCursor(size_t width, size_t height, const void *pixelDataRGBA, size_t hotSpotX, size_t hotSpotY) GP_ASYNCIFY_PARANOID_PURE; virtual void SetCursor(IGpCursor *cursor) = 0; virtual void SetStandardCursor(EGpStandardCursor_t standardCursor) = 0; diff --git a/GpShell/GpShell_Combined.cpp b/GpShell/GpShell_Combined.cpp new file mode 100644 index 0000000..f6c96fc --- /dev/null +++ b/GpShell/GpShell_Combined.cpp @@ -0,0 +1,8 @@ +#include "GpAppEnvironment.cpp" +#include "GpAudioDriverFactory.cpp" +#include "GpDisplayDriverFactory.cpp" +#include "GpFontHandlerFactory.cpp" +#include "GpGlobalConfig.cpp" +#include "GpInputDriverFactory.cpp" +#include "GpMain.cpp" +#include "GpVOSEventQueue.cpp" diff --git a/PortabilityLayer/DialogManager.cpp b/PortabilityLayer/DialogManager.cpp index 701ae96..2a01013 100644 --- a/PortabilityLayer/DialogManager.cpp +++ b/PortabilityLayer/DialogManager.cpp @@ -34,6 +34,11 @@ #include #include +int16_t DialogManagerImpl_AlertFilter(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt) +{ + return -1; +} + namespace PortabilityLayer { class DialogImpl; @@ -90,7 +95,12 @@ namespace PortabilityLayer ArrayView GetItems() const override; void SetItemVisibility(unsigned int itemIndex, bool isVisible) override; +#if GP_ASYNCIFY_PARANOID + template + int16_t ExecuteModal(void *captureContext, const TFilterFunc &filterFunc); +#else int16_t ExecuteModal(void *captureContext, DialogFilterFunc_t filterFunc) override; +#endif bool ReplaceWidget(unsigned int itemIndex, Widget *widget) override; @@ -108,15 +118,71 @@ namespace PortabilityLayer static void MakeStringSubstitutions(uint8_t *outStr, const uint8_t *inStr, const DialogTextSubstitutions *substitutions); +#if GP_ASYNCIFY_PARANOID + template + int16_t ExecuteModalInDarkenStack(void *captureContext, const TFilterFunc &filterFunc); +#else int16_t ExecuteModalInDarkenStack(void *captureContext, DialogFilterFunc_t filterFunc); +#endif Window *m_window; DialogItem *m_items; size_t m_numItems; size_t m_maxItems; }; +} +#if GP_ASYNCIFY_PARANOID + +#define PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(f) \ +template<> \ +int16_t Dialog::ExecuteModal(void *captureContext, DialogFilterFunc_t filterFuncID, const DialogFilterFuncs::InvokeWrapper &filterFunc) \ +{ \ + (void)filterFuncID; \ + return static_cast(this)->ExecuteModal(captureContext, filterFunc); \ +} + +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(BlowerFilter) + +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(FurnitureFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(CustPictFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(SwitchFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(TriggerFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(ApplianceFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(MicrowaveFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(GreaseFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(InvisBonusFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(TransFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(EnemyFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(FlowerFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(LightFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(GoToFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(RoomFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(OriginalArtFilter) + +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(AboutFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(LicenseReaderFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(LoadFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(AboutFrameworkFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(BrainsFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(NameFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(BannerFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(ControlFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(SoundFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(HouseFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(DisplayFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(PrefsFilter) + +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(FileBrowserUIImpl_PopUpAlertUIFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(FileBrowserUIImpl_FileBrowserUIFilter) +PL_DIALOG_IMPLEMENT_EXECUTE_MODAL(DialogManagerImpl_AlertFilter) + +#endif + + +namespace PortabilityLayer +{ DialogItem::DialogItem(Widget *widget) : m_widget(widget) { @@ -336,7 +402,12 @@ namespace PortabilityLayer } } +#if GP_ASYNCIFY_PARANOID + template + int16_t DialogImpl::ExecuteModal(void *captureContext, const TFilterFunc &filterFunc) +#else int16_t DialogImpl::ExecuteModal(void *captureContext, DialogFilterFunc_t filterFunc) +#endif { Window *exclWindow = this->GetWindow(); @@ -349,7 +420,12 @@ namespace PortabilityLayer return result; } +#if GP_ASYNCIFY_PARANOID + template + int16_t DialogImpl::ExecuteModalInDarkenStack(void *captureContext, const TFilterFunc &filterFunc) +#else int16_t DialogImpl::ExecuteModalInDarkenStack(void *captureContext, DialogFilterFunc_t filterFunc) +#endif { Window *window = this->GetWindow(); Widget *capturingWidget = nullptr; @@ -359,12 +435,16 @@ namespace PortabilityLayer { TimeTaggedVOSEvent evt; - const bool haveEvent = WaitForEvent(&evt, 1); + bool haveEvent = false; + { + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); + haveEvent = WaitForEvent(&evt, 1); + } if (!haveEvent && window->IsHandlingTickEvents()) window->OnTick(); - const int16_t selection = (filterFunc != nullptr) ? filterFunc(captureContext, this, haveEvent ? &evt : nullptr) : -1; + const int16_t selection = filterFunc(captureContext, this, haveEvent ? &evt : nullptr); if (selection >= 0) return selection; @@ -614,7 +694,7 @@ namespace PortabilityLayer public: Dialog *LoadDialog(int16_t resID, Window *behindWindow, const DialogTextSubstitutions *substitutions) override; Dialog *LoadDialogFromTemplate(int16_t templateResID, const Rect &rect, bool visible, bool hasCloseBox, uint32_t referenceConstant, uint16_t positionSpec, Window *behindWindow, const PLPasStr &title, const DialogTextSubstitutions *substitutions) override; - int16_t DisplayAlert(int16_t alertResID, const DialogTextSubstitutions *substitutions) override; + int16_t DisplayAlert(int16_t alertResID, const DialogTextSubstitutions *substitutions) GP_ASYNCIFY_PARANOID_OVERRIDE; void PositionWindow(Window *window, const Rect &rect) const override; DialogTemplate *LoadDialogTemplate(int16_t resID); @@ -622,9 +702,6 @@ namespace PortabilityLayer static DialogManagerImpl *GetInstance(); private: - - static int16_t AlertFilter(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt); - static DialogManagerImpl ms_instance; }; @@ -708,11 +785,6 @@ namespace PortabilityLayer return dialog; } - int16_t DialogManagerImpl::AlertFilter(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt) - { - return -1; - } - int16_t DialogManagerImpl::DisplayAlert(int16_t alertResID, const DialogTextSubstitutions *substitutions) { struct AlertResourceData @@ -769,7 +841,7 @@ namespace PortabilityLayer if (!dialog) return 0; - int16_t hit = dialog->ExecuteModal(nullptr, DialogManagerImpl::AlertFilter); + int16_t hit = dialog->ExecuteModal(nullptr, PL_FILTER_FUNC(DialogManagerImpl_AlertFilter)); dialog->Destroy(); return hit; @@ -885,3 +957,12 @@ namespace PortabilityLayer return DialogManagerImpl::GetInstance(); } } + +PL_IMPLEMENT_FILTER_FUNCTION(DialogManagerImpl_AlertFilter) + +#if GP_ASYNCIFY_PARANOID +int16_t PortabilityLayer::DialogManager::DisplayAlert(int16_t alertResID, const DialogTextSubstitutions *substitutions) +{ + return static_cast(this)->DisplayAlert(alertResID, substitutions); +} +#endif diff --git a/PortabilityLayer/DialogManager.h b/PortabilityLayer/DialogManager.h index 347305b..2ab5df8 100644 --- a/PortabilityLayer/DialogManager.h +++ b/PortabilityLayer/DialogManager.h @@ -1,5 +1,6 @@ #pragma once +#include "CoreDefs.h" #include struct Dialog; @@ -19,7 +20,7 @@ namespace PortabilityLayer public: virtual Dialog *LoadDialog(int16_t resID, Window *behindWindow, const DialogTextSubstitutions *substitutions) = 0; virtual Dialog *LoadDialogFromTemplate(int16_t templateResID, const Rect &rect, bool visible, bool hasCloseBox, uint32_t referenceConstant, uint16_t positionSpec, Window *behindWindow, const PLPasStr &title, const DialogTextSubstitutions *substitutions) = 0; - virtual int16_t DisplayAlert(int16_t alertResID, const DialogTextSubstitutions *substitutions) = 0; + GP_ASYNCIFY_PARANOID_VIRTUAL int16_t DisplayAlert(int16_t alertResID, const DialogTextSubstitutions *substitutions) GP_ASYNCIFY_PARANOID_PURE; virtual void PositionWindow(Window *window, const Rect &rect) const = 0; static DialogManager *GetInstance(); diff --git a/PortabilityLayer/FileBrowserUI.cpp b/PortabilityLayer/FileBrowserUI.cpp index 8149b7d..24d9531 100644 --- a/PortabilityLayer/FileBrowserUI.cpp +++ b/PortabilityLayer/FileBrowserUI.cpp @@ -62,8 +62,6 @@ namespace PortabilityLayer static void PubScrollBarCallback(void *captureContext, Widget *control, int part); static bool PubEditBoxCharFilter(void *context, uint8_t ch); - static int16_t PubFileBrowserUIFilter(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt); - static int16_t PubPopUpAlertUIFilter(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt); bool AppendName(const char *name, size_t nameLength, void *details); void SortNames(); @@ -82,6 +80,9 @@ namespace PortabilityLayer static int16_t PopUpAlert(const Rect &rect, int dialogResID, const DialogTextSubstitutions *substitutions); + int16_t FileBrowserUIFilter(Dialog *dialog, const TimeTaggedVOSEvent *evt); + int16_t PopUpAlertUIFilter(Dialog *dialog, const TimeTaggedVOSEvent *evt); + private: typedef PascalStr<255> NameStr_t; @@ -92,8 +93,6 @@ namespace PortabilityLayer }; void ScrollBarCallback(Widget *control, int part); - int16_t FileBrowserUIFilter(Dialog *dialog, const TimeTaggedVOSEvent *evt); - int16_t PopUpAlertUIFilter(Dialog *dialog, const TimeTaggedVOSEvent *evt); static bool FileEntrySortPred(const FileEntry &a, const FileEntry &b); @@ -114,7 +113,21 @@ namespace PortabilityLayer const FileBrowserUI_DetailsCallbackAPI m_api; }; +} + +static int16_t FileBrowserUIImpl_FileBrowserUIFilter(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt) +{ + return static_cast(context)->FileBrowserUIFilter(dialog, evt); +} + +static int16_t FileBrowserUIImpl_PopUpAlertUIFilter(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt) +{ + return static_cast(context)->PopUpAlertUIFilter(dialog, evt); +} + +namespace PortabilityLayer +{ FileBrowserUIImpl::FileBrowserUIImpl(const FileBrowserUI_DetailsCallbackAPI &callbackAPI) : m_offset(0) , m_surface(nullptr) @@ -148,16 +161,6 @@ namespace PortabilityLayer static_cast(captureContext)->ScrollBarCallback(control, part); } - int16_t FileBrowserUIImpl::PubFileBrowserUIFilter(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt) - { - return static_cast(context)->FileBrowserUIFilter(dialog, evt); - } - - int16_t FileBrowserUIImpl::PubPopUpAlertUIFilter(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt) - { - return static_cast(context)->PopUpAlertUIFilter(dialog, evt); - } - bool FileBrowserUIImpl::PubEditBoxCharFilter(void *context, uint8_t ch) { uint16_t unicodeChar = MacRoman::ToUnicode(ch); @@ -356,6 +359,7 @@ namespace PortabilityLayer if (okayButton->IsEnabled()) { + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); okayButton->SetHighlightStyle(kControlButtonPart, true); PLSysCalls::Sleep(8); okayButton->SetHighlightStyle(kControlButtonPart, false); @@ -368,6 +372,7 @@ namespace PortabilityLayer case PL_KEY_SPECIAL(kEscape): { + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); Widget *cancelButton = dialog->GetItems()[kCancelButton - 1].GetWidget(); cancelButton->SetHighlightStyle(kControlButtonPart, true); @@ -555,7 +560,7 @@ namespace PortabilityLayer int16_t hit = 0; do { - hit = dialog->ExecuteModal(nullptr, PubPopUpAlertUIFilter); + hit = dialog->ExecuteModal(nullptr, PL_FILTER_FUNC(FileBrowserUIImpl_PopUpAlertUIFilter)); } while (hit != kOkayButton && hit != kCancelButton); dialog->Destroy(); @@ -709,7 +714,7 @@ namespace PortabilityLayer do { - hit = dialog->ExecuteModal(&uiImpl, FileBrowserUIImpl::PubFileBrowserUIFilter); + hit = dialog->ExecuteModal(&uiImpl, PL_FILTER_FUNC(FileBrowserUIImpl_FileBrowserUIFilter)); if (hit == kFileListScrollBar) uiImpl.SetScrollOffset(scrollBar->GetState()); @@ -806,3 +811,6 @@ namespace PortabilityLayer return confirmed; } } + +PL_IMPLEMENT_FILTER_FUNCTION(FileBrowserUIImpl_FileBrowserUIFilter) +PL_IMPLEMENT_FILTER_FUNCTION(FileBrowserUIImpl_PopUpAlertUIFilter) diff --git a/PortabilityLayer/FileManager.cpp b/PortabilityLayer/FileManager.cpp index e1ccccd..f96926c 100644 --- a/PortabilityLayer/FileManager.cpp +++ b/PortabilityLayer/FileManager.cpp @@ -100,6 +100,8 @@ namespace PortabilityLayer if (!stream) return nullptr; + fprintf(stderr, "Composite file opened\n"); + ZipFileProxy *zipFile = ZipFileProxy::Create(stream); if (!zipFile) { @@ -107,6 +109,8 @@ namespace PortabilityLayer return nullptr; } + fprintf(stderr, "Zip proxy created\n"); + size_t metaIndex = 0; if (!zipFile->IndexFile("!!meta", metaIndex)) { @@ -114,6 +118,8 @@ namespace PortabilityLayer return nullptr; } + fprintf(stderr, "Meta file indexed\n"); + MacFilePropertiesSerialized mfps; GpIOStream *metaStream = zipFile->OpenFile(metaIndex); @@ -124,6 +130,8 @@ namespace PortabilityLayer return nullptr; } + fprintf(stderr, "Meta data deserialized\n"); + if (!metaStream->ReadExact(mfps.m_data, sizeof(mfps.m_data))) { metaStream->Close(); @@ -152,6 +160,8 @@ namespace PortabilityLayer stream = nullptr; } + fprintf(stderr, "Composite constructed\n"); + CompositeFile *compositeFile = CompositeFileImpl::Create(dirID, filename, stream, zipFile, mfp, hasResources, hasData, hasData ? dataIndex : 0); if (!compositeFile) { diff --git a/PortabilityLayer/GpAppInterface.h b/PortabilityLayer/GpAppInterface.h index 9a9a900..344fe1d 100644 --- a/PortabilityLayer/GpAppInterface.h +++ b/PortabilityLayer/GpAppInterface.h @@ -32,8 +32,8 @@ struct IGpDisplayDriver; class GpAppInterface { public: - virtual void ApplicationInit() = 0; - virtual int ApplicationMain() = 0; + GP_ASYNCIFY_PARANOID_VIRTUAL void ApplicationInit() GP_ASYNCIFY_PARANOID_PURE; + GP_ASYNCIFY_PARANOID_VIRTUAL int ApplicationMain() GP_ASYNCIFY_PARANOID_PURE; virtual void PL_IncrementTickCounter(uint32_t count) = 0; virtual void PL_Render(IGpDisplayDriver *displayDriver) = 0; virtual GpDriverCollection *PL_GetDriverCollection() = 0; diff --git a/PortabilityLayer/HostSuspendHook.cpp b/PortabilityLayer/HostSuspendHook.cpp index e58b834..39af223 100644 --- a/PortabilityLayer/HostSuspendHook.cpp +++ b/PortabilityLayer/HostSuspendHook.cpp @@ -1,17 +1,17 @@ -#include "HostSuspendHook.h" +#include "HostSuspendHook.h" #include "HostSuspendCallArgument.h" #include "DisplayDeviceManager.h" #include "PLDrivers.h" -#include "IGpDisplayDriver.h" - - -namespace PortabilityLayer -{ +#include "IGpDisplayDriver.h" + + +namespace PortabilityLayer +{ void RenderFrames(unsigned int ticks) - { + { PLDrivers::GetDisplayDriver()->ServeTicks(ticks); - DisplayDeviceManager::GetInstance()->IncrementTickCount(ticks); - } -} + DisplayDeviceManager::GetInstance()->IncrementTickCount(ticks); + } +} diff --git a/PortabilityLayer/MenuManager.cpp b/PortabilityLayer/MenuManager.cpp index 4782f2c..a2b565e 100644 --- a/PortabilityLayer/MenuManager.cpp +++ b/PortabilityLayer/MenuManager.cpp @@ -22,6 +22,7 @@ #include "PLPasStr.h" #include "PLResources.h" #include "PLStandardColors.h" +#include "PLSysCalls.h" #include "PLTimeTaggedVOSEvent.h" #include "PLQDOffscreen.h" @@ -153,7 +154,7 @@ namespace PortabilityLayer uint16_t GetMenuBarHeight() const override; bool FindMenuShortcut(uint16_t &menuID, uint16_t &itemID, uint8_t shortcutChar) override; - void MenuSelect(const Vec2i &initialPoint, int16_t *outMenu, uint16_t *outItem) override; + void MenuSelect(const Vec2i &initialPoint, int16_t *outMenu, uint16_t *outItem) GP_ASYNCIFY_PARANOID_OVERRIDE; void PopupMenuSelect(const THandle &menu, const Vec2i &popupMenuPos, const Vec2i &initialPoint, size_t initialItem, uint16_t *outItem) override; void DrawMenuBar() override; @@ -709,7 +710,13 @@ namespace PortabilityLayer bool canDismiss = false; while (!canDismiss) { - if (WaitForEvent(&evt, 1)) + bool haveEvent = false; + { + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); + haveEvent = WaitForEvent(&evt, 1); + } + + if (haveEvent) { if (evt.m_vosEvent.m_eventType == GpVOSEventTypes::kMouseInput) { @@ -1576,4 +1583,11 @@ namespace PortabilityLayer { return MenuManagerImpl::GetInstance(); } + +#ifdef GP_ASYNCIFY_PARANOID + void MenuManager::MenuSelect(const Vec2i &initialPoint, int16_t *outMenu, uint16_t *outItem) + { + static_cast(this)->MenuSelect(initialPoint, outMenu, outItem); + } +#endif } diff --git a/PortabilityLayer/MenuManager.h b/PortabilityLayer/MenuManager.h index e373b8a..cf66c6d 100644 --- a/PortabilityLayer/MenuManager.h +++ b/PortabilityLayer/MenuManager.h @@ -4,6 +4,7 @@ #include #include "PLErrorCodes.h" +#include "CoreDefs.h" template class THandle; @@ -48,7 +49,7 @@ namespace PortabilityLayer virtual uint16_t GetMenuBarHeight() const = 0; virtual bool FindMenuShortcut(uint16_t &menuID, uint16_t &itemID, uint8_t shortcutChar) = 0; - virtual void MenuSelect(const Vec2i &initialPoint, int16_t *outMenu, uint16_t *outItem) = 0; + GP_ASYNCIFY_PARANOID_VIRTUAL void MenuSelect(const Vec2i &initialPoint, int16_t *outMenu, uint16_t *outItem) GP_ASYNCIFY_PARANOID_PURE; virtual void PopupMenuSelect(const THandle &menu, const Vec2i &popupMenuPos, const Vec2i &initialPoint, size_t initialItem, uint16_t *outItem) = 0; virtual void DrawMenuBar() = 0; diff --git a/PortabilityLayer/PLButtonWidget.cpp b/PortabilityLayer/PLButtonWidget.cpp index fe27ec6..f5a69e8 100644 --- a/PortabilityLayer/PLButtonWidget.cpp +++ b/PortabilityLayer/PLButtonWidget.cpp @@ -1,10 +1,11 @@ #include "PLButtonWidget.h" #include "PLCore.h" #include "PLControlDefinitions.h" -#include "PLRegions.h" -#include "PLTimeTaggedVOSEvent.h" -#include "PLStandardColors.h" #include "PLQDraw.h" +#include "PLRegions.h" +#include "PLStandardColors.h" +#include "PLSysCalls.h" +#include "PLTimeTaggedVOSEvent.h" #include "FontFamily.h" #include "RenderedFont.h" #include "GpRenderedFontMetrics.h" @@ -13,10 +14,10 @@ #include -static const int kLightGray = 238; -static const int kMidGray = 221; -static const int kMidDarkGray = 170; -static const int kDarkGray = 102; +static const int kButtonLightGray = 238; +static const int kButtonMidGray = 221; +static const int kButtonMidDarkGray = 170; +static const int kButtonDarkGray = 102; #ifdef CLR #undef CLR @@ -27,28 +28,28 @@ static const int kDarkGray = 102; static const PortabilityLayer::RGBAColor gs_buttonTopLeftCornerGraphicPixels[] = { CLR(0), CLR(0), CLR(0), - CLR(0), CLR(0), CLR(kMidGray), - CLR(0), CLR(kMidGray), CLR(255) + CLR(0), CLR(0), CLR(kButtonMidGray), + CLR(0), CLR(kButtonMidGray), CLR(255) }; static const PortabilityLayer::RGBAColor gs_buttonTopRightCornerGraphicPixels[] = { CLR(0), CLR(0), CLR(0), - CLR(kMidGray), CLR(0), CLR(0), - CLR(255), CLR(kMidGray), CLR(0) + CLR(kButtonMidGray), CLR(0), CLR(0), + CLR(255), CLR(kButtonMidGray), CLR(0) }; static const PortabilityLayer::RGBAColor gs_buttonBottomLeftCornerGraphicPixels[] = { - CLR(0), CLR(kMidGray), CLR(255), - CLR(0), CLR(0), CLR(kMidGray), + CLR(0), CLR(kButtonMidGray), CLR(255), + CLR(0), CLR(0), CLR(kButtonMidGray), CLR(0), CLR(0), CLR(0) }; static const PortabilityLayer::RGBAColor gs_buttonBottomRightCornerGraphicPixels[] = { - CLR(kMidGray), CLR(kDarkGray), CLR(0), - CLR(kDarkGray), CLR(0), CLR(0), + CLR(kButtonMidGray), CLR(kButtonDarkGray), CLR(0), + CLR(kButtonDarkGray), CLR(0), CLR(0), CLR(0), CLR(0), CLR(0) }; @@ -57,28 +58,28 @@ static const PortabilityLayer::RGBAColor gs_buttonBottomRightCornerGraphicPixels static const PortabilityLayer::RGBAColor gs_buttonPressedTopLeftCornerGraphicPixels[] = { CLR(0), CLR(0), CLR(0), - CLR(0), CLR(0), CLR(kDarkGray), - CLR(0), CLR(kDarkGray), CLR(kDarkGray) + CLR(0), CLR(0), CLR(kButtonDarkGray), + CLR(0), CLR(kButtonDarkGray), CLR(kButtonDarkGray) }; static const PortabilityLayer::RGBAColor gs_buttonPressedTopRightCornerGraphicPixels[] = { CLR(0), CLR(0), CLR(0), - CLR(kDarkGray), CLR(0), CLR(0), - CLR(kDarkGray), CLR(kDarkGray), CLR(0) + CLR(kButtonDarkGray), CLR(0), CLR(0), + CLR(kButtonDarkGray), CLR(kButtonDarkGray), CLR(0) }; static const PortabilityLayer::RGBAColor gs_buttonPressedBottomLeftCornerGraphicPixels[] = { - CLR(0), CLR(kDarkGray), CLR(kDarkGray), - CLR(0), CLR(0), CLR(kDarkGray), + CLR(0), CLR(kButtonDarkGray), CLR(kButtonDarkGray), + CLR(0), CLR(0), CLR(kButtonDarkGray), CLR(0), CLR(0), CLR(0) }; static const PortabilityLayer::RGBAColor gs_buttonPressedBottomRightCornerGraphicPixels[] = { - CLR(kDarkGray), CLR(kDarkGray), CLR(0), - CLR(kDarkGray), CLR(0), CLR(0), + CLR(kButtonDarkGray), CLR(kButtonDarkGray), CLR(0), + CLR(kButtonDarkGray), CLR(0), CLR(0), CLR(0), CLR(0), CLR(0) }; @@ -86,30 +87,30 @@ static const PortabilityLayer::RGBAColor gs_buttonPressedBottomRightCornerGraphi static const PortabilityLayer::RGBAColor gs_buttonDisabledTopLeftCornerGraphicPixels[] = { - CLR(kDarkGray), CLR(kDarkGray), CLR(kDarkGray), - CLR(kDarkGray), CLR(kDarkGray), CLR(kLightGray), - CLR(kDarkGray), CLR(kLightGray), CLR(kLightGray) + CLR(kButtonDarkGray), CLR(kButtonDarkGray), CLR(kButtonDarkGray), + CLR(kButtonDarkGray), CLR(kButtonDarkGray), CLR(kButtonLightGray), + CLR(kButtonDarkGray), CLR(kButtonLightGray), CLR(kButtonLightGray) }; static const PortabilityLayer::RGBAColor gs_buttonDisabledTopRightCornerGraphicPixels[] = { - CLR(kDarkGray), CLR(kDarkGray), CLR(kDarkGray), - CLR(kLightGray), CLR(kDarkGray), CLR(kDarkGray), - CLR(kLightGray), CLR(kLightGray), CLR(kDarkGray) + CLR(kButtonDarkGray), CLR(kButtonDarkGray), CLR(kButtonDarkGray), + CLR(kButtonLightGray), CLR(kButtonDarkGray), CLR(kButtonDarkGray), + CLR(kButtonLightGray), CLR(kButtonLightGray), CLR(kButtonDarkGray) }; static const PortabilityLayer::RGBAColor gs_buttonDisabledBottomLeftCornerGraphicPixels[] = { - CLR(kDarkGray), CLR(kLightGray), CLR(kLightGray), - CLR(kDarkGray), CLR(kDarkGray), CLR(kLightGray), - CLR(kDarkGray), CLR(kDarkGray), CLR(kDarkGray) + CLR(kButtonDarkGray), CLR(kButtonLightGray), CLR(kButtonLightGray), + CLR(kButtonDarkGray), CLR(kButtonDarkGray), CLR(kButtonLightGray), + CLR(kButtonDarkGray), CLR(kButtonDarkGray), CLR(kButtonDarkGray) }; static const PortabilityLayer::RGBAColor gs_buttonDisabledBottomRightCornerGraphicPixels[] = { - CLR(kLightGray), CLR(kLightGray), CLR(kDarkGray), - CLR(kLightGray), CLR(kDarkGray), CLR(kDarkGray), - CLR(kDarkGray), CLR(kDarkGray), CLR(kDarkGray) + CLR(kButtonLightGray), CLR(kButtonLightGray), CLR(kButtonDarkGray), + CLR(kButtonLightGray), CLR(kButtonDarkGray), CLR(kButtonDarkGray), + CLR(kButtonDarkGray), CLR(kButtonDarkGray), CLR(kButtonDarkGray) }; // Default boundary @@ -118,35 +119,35 @@ static const PortabilityLayer::RGBAColor gs_buttonDefaultTopLeftCornerGraphicPix { CLR(0), CLR(0), CLR(0), CLR(0), CLR(0), CLR(0), CLR(0), CLR(0), CLR(0), CLR(255), - CLR(0), CLR(0), CLR(0), CLR(255), CLR(kMidGray), - CLR(0), CLR(0), CLR(255), CLR(kMidGray), CLR(kMidGray), - CLR(0), CLR(255), CLR(kMidGray), CLR(kMidGray), CLR(0), + CLR(0), CLR(0), CLR(0), CLR(255), CLR(kButtonMidGray), + CLR(0), CLR(0), CLR(255), CLR(kButtonMidGray), CLR(kButtonMidGray), + CLR(0), CLR(255), CLR(kButtonMidGray), CLR(kButtonMidGray), CLR(0), }; static const PortabilityLayer::RGBAColor gs_buttonDefaultTopRightCornerGraphicPixels[] = { CLR(0), CLR(0), CLR(0), CLR(0), CLR(0), CLR(255), CLR(0), CLR(0), CLR(0), CLR(0), - CLR(kMidGray), CLR(kMidGray), CLR(0), CLR(0), CLR(0), - CLR(kMidGray), CLR(kMidGray), CLR(kMidGray), CLR(0), CLR(0), - CLR(0), CLR(kMidGray), CLR(kMidGray), CLR(kDarkGray), CLR(0), + CLR(kButtonMidGray), CLR(kButtonMidGray), CLR(0), CLR(0), CLR(0), + CLR(kButtonMidGray), CLR(kButtonMidGray), CLR(kButtonMidGray), CLR(0), CLR(0), + CLR(0), CLR(kButtonMidGray), CLR(kButtonMidGray), CLR(kButtonDarkGray), CLR(0), }; static const PortabilityLayer::RGBAColor gs_buttonDefaultBottomLeftCornerGraphicPixels[] = { - CLR(0), CLR(255), CLR(kMidGray), CLR(kMidGray), CLR(0), - CLR(0), CLR(0), CLR(kMidGray), CLR(kMidGray), CLR(kMidGray), - CLR(0), CLR(0), CLR(0), CLR(kMidGray), CLR(kMidGray), - CLR(0), CLR(0), CLR(0), CLR(0), CLR(kDarkGray), + CLR(0), CLR(255), CLR(kButtonMidGray), CLR(kButtonMidGray), CLR(0), + CLR(0), CLR(0), CLR(kButtonMidGray), CLR(kButtonMidGray), CLR(kButtonMidGray), + CLR(0), CLR(0), CLR(0), CLR(kButtonMidGray), CLR(kButtonMidGray), + CLR(0), CLR(0), CLR(0), CLR(0), CLR(kButtonDarkGray), CLR(0), CLR(0), CLR(0), CLR(0), CLR(0), }; static const PortabilityLayer::RGBAColor gs_buttonDefaultBottomRightCornerGraphicPixels[] = { - CLR(0), CLR(kMidGray), CLR(kMidGray), CLR(kDarkGray), CLR(0), - CLR(kMidGray), CLR(kMidGray), CLR(kDarkGray), CLR(0), CLR(0), - CLR(kMidGray), CLR(kDarkGray), CLR(0), CLR(0), CLR(0), - CLR(kDarkGray), CLR(0), CLR(0), CLR(0), CLR(0), + CLR(0), CLR(kButtonMidGray), CLR(kButtonMidGray), CLR(kButtonDarkGray), CLR(0), + CLR(kButtonMidGray), CLR(kButtonMidGray), CLR(kButtonDarkGray), CLR(0), CLR(0), + CLR(kButtonMidGray), CLR(kButtonDarkGray), CLR(0), CLR(0), CLR(0), + CLR(kButtonDarkGray), CLR(0), CLR(0), CLR(0), CLR(0), CLR(0), CLR(0), CLR(0), CLR(0), CLR(0), }; @@ -154,15 +155,15 @@ static const PortabilityLayer::RGBAColor gs_buttonRadioGraphicPixels[] = { CLR(0),CLR(0),CLR(0),CLR(0),CLR(0),CLR(0),CLR(0),CLR(0),CLR(0),CLR(0),CLR(0),CLR(0), CLR(0),CLR(0),CLR(0),CLR(255),CLR(255),CLR(255),CLR(255),CLR(255),CLR(255),CLR(0),CLR(0),CLR(0), - CLR(0),CLR(0),CLR(255),CLR(255),CLR(kLightGray),CLR(kLightGray),CLR(kLightGray),CLR(kLightGray),CLR(kMidGray),CLR(kMidGray),CLR(0),CLR(0), - CLR(0),CLR(255),CLR(255),CLR(kLightGray),CLR(kLightGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kDarkGray),CLR(0), - CLR(0),CLR(255),CLR(kLightGray),CLR(kLightGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidDarkGray),CLR(kDarkGray),CLR(0), - CLR(0),CLR(255),CLR(kLightGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidDarkGray),CLR(kDarkGray),CLR(0), - CLR(0),CLR(255),CLR(kLightGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidDarkGray),CLR(kDarkGray),CLR(0), - CLR(0),CLR(255),CLR(kLightGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidDarkGray),CLR(kMidDarkGray),CLR(kDarkGray),CLR(0), - CLR(0),CLR(255),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidGray),CLR(kMidDarkGray),CLR(kMidDarkGray),CLR(kDarkGray),CLR(kDarkGray),CLR(0), - CLR(0),CLR(0),CLR(kMidGray),CLR(kMidGray),CLR(kMidDarkGray),CLR(kMidDarkGray),CLR(kMidDarkGray),CLR(kMidDarkGray),CLR(kDarkGray),CLR(kDarkGray),CLR(0),CLR(0), - CLR(0),CLR(0),CLR(0),CLR(kDarkGray),CLR(kDarkGray),CLR(kDarkGray),CLR(kDarkGray),CLR(kDarkGray),CLR(kDarkGray),CLR(0),CLR(0),CLR(0), + CLR(0),CLR(0),CLR(255),CLR(255),CLR(kButtonLightGray),CLR(kButtonLightGray),CLR(kButtonLightGray),CLR(kButtonLightGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(0),CLR(0), + CLR(0),CLR(255),CLR(255),CLR(kButtonLightGray),CLR(kButtonLightGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonDarkGray),CLR(0), + CLR(0),CLR(255),CLR(kButtonLightGray),CLR(kButtonLightGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidDarkGray),CLR(kButtonDarkGray),CLR(0), + CLR(0),CLR(255),CLR(kButtonLightGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidDarkGray),CLR(kButtonDarkGray),CLR(0), + CLR(0),CLR(255),CLR(kButtonLightGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidDarkGray),CLR(kButtonDarkGray),CLR(0), + CLR(0),CLR(255),CLR(kButtonLightGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidDarkGray),CLR(kButtonMidDarkGray),CLR(kButtonDarkGray),CLR(0), + CLR(0),CLR(255),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidDarkGray),CLR(kButtonMidDarkGray),CLR(kButtonDarkGray),CLR(kButtonDarkGray),CLR(0), + CLR(0),CLR(0),CLR(kButtonMidGray),CLR(kButtonMidGray),CLR(kButtonMidDarkGray),CLR(kButtonMidDarkGray),CLR(kButtonMidDarkGray),CLR(kButtonMidDarkGray),CLR(kButtonDarkGray),CLR(kButtonDarkGray),CLR(0),CLR(0), + CLR(0),CLR(0),CLR(0),CLR(kButtonDarkGray),CLR(kButtonDarkGray),CLR(kButtonDarkGray),CLR(kButtonDarkGray),CLR(kButtonDarkGray),CLR(kButtonDarkGray),CLR(0),CLR(0),CLR(0), CLR(0),CLR(0),CLR(0),CLR(0),CLR(0),CLR(0),CLR(0),CLR(0),CLR(0),CLR(0),CLR(0),CLR(0), }; @@ -222,7 +223,7 @@ namespace PortabilityLayer } ButtonWidget::ButtonWidget(const WidgetBasicState &state) - : WidgetSpec(state) + : WidgetSpec(state) , m_text(state.m_text) , m_haveHighlightOverride(false) , m_buttonStyle(kButtonStyle_Button) @@ -280,7 +281,13 @@ namespace PortabilityLayer } TimeTaggedVOSEvent evt; - if (WaitForEvent(&evt, 1)) + bool haveEvent = false; + { + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); + haveEvent = WaitForEvent(&evt, 1); + } + + if (haveEvent) { if (evt.m_vosEvent.m_eventType == GpVOSEventTypes::kMouseInput) { @@ -363,45 +370,45 @@ namespace PortabilityLayer if (!m_enabled) { cornerGraphics = gs_buttonDisabledCornerGraphics; - topStripeColors[0] = PortabilityLayer::RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255); - topStripeColors[1] = PortabilityLayer::RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255); - leftStripeColors[0] = PortabilityLayer::RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255); - leftStripeColors[1] = PortabilityLayer::RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255); - bottomStripeColors[0] = PortabilityLayer::RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255); - bottomStripeColors[1] = PortabilityLayer::RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255); - rightStripeColors[0] = PortabilityLayer::RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255); - rightStripeColors[1] = PortabilityLayer::RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255); - centerColor = PortabilityLayer::RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255); - textColor = PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255); - borderColor = PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255); + topStripeColors[0] = PortabilityLayer::RGBAColor::Create(kButtonLightGray, kButtonLightGray, kButtonLightGray, 255); + topStripeColors[1] = PortabilityLayer::RGBAColor::Create(kButtonLightGray, kButtonLightGray, kButtonLightGray, 255); + leftStripeColors[0] = PortabilityLayer::RGBAColor::Create(kButtonLightGray, kButtonLightGray, kButtonLightGray, 255); + leftStripeColors[1] = PortabilityLayer::RGBAColor::Create(kButtonLightGray, kButtonLightGray, kButtonLightGray, 255); + bottomStripeColors[0] = PortabilityLayer::RGBAColor::Create(kButtonLightGray, kButtonLightGray, kButtonLightGray, 255); + bottomStripeColors[1] = PortabilityLayer::RGBAColor::Create(kButtonLightGray, kButtonLightGray, kButtonLightGray, 255); + rightStripeColors[0] = PortabilityLayer::RGBAColor::Create(kButtonLightGray, kButtonLightGray, kButtonLightGray, 255); + rightStripeColors[1] = PortabilityLayer::RGBAColor::Create(kButtonLightGray, kButtonLightGray, kButtonLightGray, 255); + centerColor = PortabilityLayer::RGBAColor::Create(kButtonLightGray, kButtonLightGray, kButtonLightGray, 255); + textColor = PortabilityLayer::RGBAColor::Create(kButtonDarkGray, kButtonDarkGray, kButtonDarkGray, 255); + borderColor = PortabilityLayer::RGBAColor::Create(kButtonDarkGray, kButtonDarkGray, kButtonDarkGray, 255); } else if (inverted || m_haveHighlightOverride) { cornerGraphics = gs_buttonPressedCornerGraphics; - topStripeColors[0] = PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255); - topStripeColors[1] = PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255); - leftStripeColors[0] = PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255); - leftStripeColors[1] = PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255); - bottomStripeColors[0] = PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255); - bottomStripeColors[1] = PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255); - rightStripeColors[0] = PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255); - rightStripeColors[1] = PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255); - centerColor = PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255); + topStripeColors[0] = PortabilityLayer::RGBAColor::Create(kButtonDarkGray, kButtonDarkGray, kButtonDarkGray, 255); + topStripeColors[1] = PortabilityLayer::RGBAColor::Create(kButtonDarkGray, kButtonDarkGray, kButtonDarkGray, 255); + leftStripeColors[0] = PortabilityLayer::RGBAColor::Create(kButtonDarkGray, kButtonDarkGray, kButtonDarkGray, 255); + leftStripeColors[1] = PortabilityLayer::RGBAColor::Create(kButtonDarkGray, kButtonDarkGray, kButtonDarkGray, 255); + bottomStripeColors[0] = PortabilityLayer::RGBAColor::Create(kButtonDarkGray, kButtonDarkGray, kButtonDarkGray, 255); + bottomStripeColors[1] = PortabilityLayer::RGBAColor::Create(kButtonDarkGray, kButtonDarkGray, kButtonDarkGray, 255); + rightStripeColors[0] = PortabilityLayer::RGBAColor::Create(kButtonDarkGray, kButtonDarkGray, kButtonDarkGray, 255); + rightStripeColors[1] = PortabilityLayer::RGBAColor::Create(kButtonDarkGray, kButtonDarkGray, kButtonDarkGray, 255); + centerColor = PortabilityLayer::RGBAColor::Create(kButtonDarkGray, kButtonDarkGray, kButtonDarkGray, 255); textColor = StdColors::White(); borderColor = StdColors::Black(); } else { cornerGraphics = gs_buttonCornerGraphics; - topStripeColors[0] = PortabilityLayer::RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255); + topStripeColors[0] = PortabilityLayer::RGBAColor::Create(kButtonMidGray, kButtonMidGray, kButtonMidGray, 255); topStripeColors[1] = StdColors::White(); - leftStripeColors[0] = PortabilityLayer::RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255); + leftStripeColors[0] = PortabilityLayer::RGBAColor::Create(kButtonMidGray, kButtonMidGray, kButtonMidGray, 255); leftStripeColors[1] = StdColors::White(); - bottomStripeColors[0] = PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255); - bottomStripeColors[1] = PortabilityLayer::RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255); - rightStripeColors[0] = PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255); - rightStripeColors[1] = PortabilityLayer::RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255); - centerColor = PortabilityLayer::RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255); + bottomStripeColors[0] = PortabilityLayer::RGBAColor::Create(kButtonDarkGray, kButtonDarkGray, kButtonDarkGray, 255); + bottomStripeColors[1] = PortabilityLayer::RGBAColor::Create(kButtonMidGray, kButtonMidGray, kButtonMidGray, 255); + rightStripeColors[0] = PortabilityLayer::RGBAColor::Create(kButtonDarkGray, kButtonDarkGray, kButtonDarkGray, 255); + rightStripeColors[1] = PortabilityLayer::RGBAColor::Create(kButtonMidGray, kButtonMidGray, kButtonMidGray, 255); + centerColor = PortabilityLayer::RGBAColor::Create(kButtonMidGray, kButtonMidGray, kButtonMidGray, 255); textColor = StdColors::Black(); borderColor = StdColors::Black(); } @@ -469,9 +476,9 @@ namespace PortabilityLayer ResolveCachingColor *checkEraseColor = nullptr; ResolveCachingColor *textColor = nullptr; - ResolveCachingColor midGrayColor = RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255); - ResolveCachingColor lightGrayColor = RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255); - ResolveCachingColor darkGrayColor = RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255); + ResolveCachingColor midGrayColor = RGBAColor::Create(kButtonMidGray, kButtonMidGray, kButtonMidGray, 255); + ResolveCachingColor lightGrayColor = RGBAColor::Create(kButtonLightGray, kButtonLightGray, kButtonLightGray, 255); + ResolveCachingColor darkGrayColor = RGBAColor::Create(kButtonDarkGray, kButtonDarkGray, kButtonDarkGray, 255); ResolveCachingColor blackColor = StdColors::Black(); if (!m_enabled) @@ -558,9 +565,9 @@ namespace PortabilityLayer ResolveCachingColor *radioColor = nullptr; ResolveCachingColor *textColor = nullptr; - ResolveCachingColor midGrayColor = RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255); - ResolveCachingColor lightGrayColor = RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255); - ResolveCachingColor darkGrayColor = RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255); + ResolveCachingColor midGrayColor = RGBAColor::Create(kButtonMidGray, kButtonMidGray, kButtonMidGray, 255); + ResolveCachingColor lightGrayColor = RGBAColor::Create(kButtonLightGray, kButtonLightGray, kButtonLightGray, 255); + ResolveCachingColor darkGrayColor = RGBAColor::Create(kButtonDarkGray, kButtonDarkGray, kButtonDarkGray, 255); if (!m_enabled) { @@ -613,15 +620,15 @@ namespace PortabilityLayer RGBAColor upperLeftStripeColors[3] = { - RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255), + RGBAColor::Create(kButtonMidGray, kButtonMidGray, kButtonMidGray, 255), StdColors::White(), StdColors::Black(), }; RGBAColor bottomRightStripeColors[3] = { - RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255), - RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255), + RGBAColor::Create(kButtonMidGray, kButtonMidGray, kButtonMidGray, 255), + RGBAColor::Create(kButtonDarkGray, kButtonDarkGray, kButtonDarkGray, 255), StdColors::Black(), }; @@ -653,3 +660,5 @@ namespace PortabilityLayer } } } + +PL_IMPLEMENT_WIDGET_TYPE(PortabilityLayer::WidgetTypes::kButton, PortabilityLayer::ButtonWidget) diff --git a/PortabilityLayer/PLButtonWidget.h b/PortabilityLayer/PLButtonWidget.h index ea1f9a9..f71422b 100644 --- a/PortabilityLayer/PLButtonWidget.h +++ b/PortabilityLayer/PLButtonWidget.h @@ -5,7 +5,7 @@ namespace PortabilityLayer { - class ButtonWidget final : public WidgetSpec + class ButtonWidget final : public WidgetSpec { public: enum ButtonStyle @@ -30,10 +30,10 @@ namespace PortabilityLayer void SetString(const PLPasStr &str) override; PLPasStr GetString() const override; - WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) override; + WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) GP_ASYNCIFY_PARANOID_OVERRIDE; void OnEnabledChanged() override; void OnStateChanged() override; - int16_t Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) override; + int16_t Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) GP_ASYNCIFY_PARANOID_OVERRIDE; void SetHighlightStyle(int16_t style, bool enabled) override; static void DrawDefaultButtonChrome(const Rect &rect, DrawSurface *surface); diff --git a/PortabilityLayer/PLDialogs.cpp b/PortabilityLayer/PLDialogs.cpp index e5dcaad..71f0f76 100644 --- a/PortabilityLayer/PLDialogs.cpp +++ b/PortabilityLayer/PLDialogs.cpp @@ -89,26 +89,6 @@ void SelectDialogItemText(Dialog *dialog, int item, int firstSelChar, int lastSe widget->SetSelection(firstSelChar, lastSelCharExclusive); } -ModalFilterUPP NewModalFilterUPP(ModalFilterUPP func) -{ - return func; -} - -void ModalDialog(ModalFilterUPP filter, short *item) -{ - PL_NotYetImplemented(); -} - -void DisposeModalFilterUPP(ModalFilterUPP upp) -{ - PL_NotYetImplemented(); -} - -void ShowDialogItem(Dialog *dialog, int item) -{ - PL_NotYetImplemented(); -} - void HideDialogItem(Dialog *dialog, int item) { PortabilityLayer::Widget *widget = dialog->GetItems()[item - 1].GetWidget(); diff --git a/PortabilityLayer/PLDialogs.h b/PortabilityLayer/PLDialogs.h index 8377370..9a2207c 100644 --- a/PortabilityLayer/PLDialogs.h +++ b/PortabilityLayer/PLDialogs.h @@ -14,7 +14,79 @@ class PLPasStr; struct Control; struct Dialog; +#if GP_ASYNCIFY_PARANOID +namespace DialogFilterFuncs +{ + enum DialogFilterFunc + { + kBlowerFilter, + kFurnitureFilter, + kCustPictFilter, + kSwitchFilter, + kTriggerFilter, + kApplianceFilter, + kMicrowaveFilter, + kGreaseFilter, + kInvisBonusFilter, + kTransFilter, + kEnemyFilter, + kFlowerFilter, + kLightFilter, + kGoToFilter, + kRoomFilter, + kOriginalArtFilter, + + kAboutFilter, + kLicenseReaderFilter, + kLoadFilter, + kAboutFrameworkFilter, + kBrainsFilter, + kNameFilter, + kBannerFilter, + kControlFilter, + kSoundFilter, + kHouseFilter, + kDisplayFilter, + kPrefsFilter, + + kFileBrowserUIImpl_PopUpAlertUIFilter, + kFileBrowserUIImpl_FileBrowserUIFilter, + kDialogManagerImpl_AlertFilter, + }; + + template + int16_t InvokeWrapperThunk(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt); + + template + class InvokeWrapper + { + public: + inline int16_t operator()(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt) const + { + return InvokeWrapperThunk(context, dialog, evt); + } + }; +} + +typedef DialogFilterFuncs::DialogFilterFunc DialogFilterFunc_t; + +#define PL_FILTER_FUNC(f) DialogFilterFuncs::k##f, DialogFilterFuncs::InvokeWrapper() +#define PL_IMPLEMENT_FILTER_FUNCTION_THUNK(f, impl) \ + template<> \ + int16_t DialogFilterFuncs::InvokeWrapperThunk(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt) \ + { \ + return impl(context, dialog, evt); \ + } + +#define PL_IMPLEMENT_FILTER_FUNCTION(f) PL_IMPLEMENT_FILTER_FUNCTION_THUNK(f, f) + +#else typedef int16_t(*DialogFilterFunc_t)(void *context, Dialog *dialog, const TimeTaggedVOSEvent *evt); +#define PL_FILTER_FUNC(f) f +#define PL_IMPLEMENT_FILTER_FUNCTION_THUNK(f, impl) +#define PL_IMPLEMENT_FILTER_FUNCTION(f) + +#endif struct DialogTextSubstitutions { @@ -39,7 +111,12 @@ struct Dialog virtual void SetItemVisibility(unsigned int itemIndex, bool isVisible) = 0; +#if GP_ASYNCIFY_PARANOID + template + int16_t ExecuteModal(void *captureContext, DialogFilterFunc_t filterFuncID, const TFilterFunc &filterFunc); +#else virtual int16_t ExecuteModal(void *captureContext, DialogFilterFunc_t filterFunc) = 0; +#endif virtual bool ReplaceWidget(unsigned int itemIndex, PortabilityLayer::Widget *widget) = 0; }; @@ -56,7 +133,5 @@ void SetDialogItemText(THandle handle, const PLPasStr &str); void SelectDialogItemText(Dialog *dialog, int item, int firstSelChar, int lastSelCharExclusive); -void ModalDialog(ModalFilterUPP filter, short *item); - void ShowDialogItem(Dialog *dialog, int item); void HideDialogItem(Dialog *dialog, int item); diff --git a/PortabilityLayer/PLEditboxWidget.cpp b/PortabilityLayer/PLEditboxWidget.cpp index aa5ea0c..59fc22f 100644 --- a/PortabilityLayer/PLEditboxWidget.cpp +++ b/PortabilityLayer/PLEditboxWidget.cpp @@ -26,7 +26,7 @@ namespace PortabilityLayer { EditboxWidget::EditboxWidget(const WidgetBasicState &state) - : WidgetSpec(state) + : WidgetSpec(state) , m_capacity(255) , m_length(0) , m_chars(nullptr) @@ -351,6 +351,11 @@ namespace PortabilityLayer return WidgetHandleStates::kIgnored; } + int16_t EditboxWidget::Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) + { + return DefaultCapture(captureContext, pos, callback); + } + Rect EditboxWidget::GetExpandedRect() const { return GetRect().Inset(-3, -3); @@ -1394,4 +1399,7 @@ namespace PortabilityLayer { 0xf5, EditboxWidget::CharacterCategory_AlphaNumeric }, { 0xff, EditboxWidget::CharacterCategory_Punctuation }, }; + } + +PL_IMPLEMENT_WIDGET_TYPE(PortabilityLayer::WidgetTypes::kEditbox, PortabilityLayer::EditboxWidget) diff --git a/PortabilityLayer/PLEditboxWidget.h b/PortabilityLayer/PLEditboxWidget.h index 9da7192..b45ad8f 100644 --- a/PortabilityLayer/PLEditboxWidget.h +++ b/PortabilityLayer/PLEditboxWidget.h @@ -8,7 +8,7 @@ struct DrawSurface; namespace PortabilityLayer { - class EditboxWidget final : public WidgetSpec + class EditboxWidget final : public WidgetSpec { public: typedef bool (*CharacterFilterCallback_t)(void *context, uint8_t character); @@ -25,7 +25,8 @@ namespace PortabilityLayer void GainFocus() override; void LoseFocus() override; - WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) override; + WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) GP_ASYNCIFY_PARANOID_OVERRIDE; + int16_t Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) GP_ASYNCIFY_PARANOID_OVERRIDE; Rect GetExpandedRect() const override; diff --git a/PortabilityLayer/PLIconWidget.cpp b/PortabilityLayer/PLIconWidget.cpp index 90a5c6b..bfa28d1 100644 --- a/PortabilityLayer/PLIconWidget.cpp +++ b/PortabilityLayer/PLIconWidget.cpp @@ -9,7 +9,7 @@ namespace PortabilityLayer { IconWidget::IconWidget(const WidgetBasicState &state) - : WidgetSpec(state) + : WidgetSpec(state) { } @@ -58,4 +58,11 @@ namespace PortabilityLayer else return WidgetHandleStates::kIgnored; } + + int16_t IconWidget::Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) + { + return DefaultCapture(captureContext, pos, callback); + } } + +PL_IMPLEMENT_WIDGET_TYPE(PortabilityLayer::WidgetTypes::kIcon, PortabilityLayer::IconWidget) diff --git a/PortabilityLayer/PLIconWidget.h b/PortabilityLayer/PLIconWidget.h index bdea5f8..6e8f3a9 100644 --- a/PortabilityLayer/PLIconWidget.h +++ b/PortabilityLayer/PLIconWidget.h @@ -7,7 +7,7 @@ namespace PortabilityLayer { class PixMapImpl; - class IconWidget final : public WidgetSpec + class IconWidget final : public WidgetSpec { public: IconWidget(const WidgetBasicState &state); @@ -17,7 +17,8 @@ namespace PortabilityLayer void DrawControl(DrawSurface *surface) override; - WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) override; + WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) GP_ASYNCIFY_PARANOID_OVERRIDE; + int16_t Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) GP_ASYNCIFY_PARANOID_OVERRIDE; private: THandle m_iconImage; diff --git a/PortabilityLayer/PLImageWidget.cpp b/PortabilityLayer/PLImageWidget.cpp index 4d4b779..b0b0400 100644 --- a/PortabilityLayer/PLImageWidget.cpp +++ b/PortabilityLayer/PLImageWidget.cpp @@ -5,7 +5,7 @@ namespace PortabilityLayer { ImageWidget::ImageWidget(const WidgetBasicState &state) - : WidgetSpec(state) + : WidgetSpec(state) { } @@ -28,4 +28,16 @@ namespace PortabilityLayer if (m_pict && m_rect.IsValid()) surface->DrawPicture(m_pict, m_rect); } + + WidgetHandleState_t ImageWidget::ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) + { + return DefaultProcessEvent(captureContext, evt); + } + + int16_t ImageWidget::Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) + { + return DefaultCapture(captureContext, pos, callback); + } } + +PL_IMPLEMENT_WIDGET_TYPE(PortabilityLayer::WidgetTypes::kImage, PortabilityLayer::ImageWidget) diff --git a/PortabilityLayer/PLImageWidget.h b/PortabilityLayer/PLImageWidget.h index 5c9cd37..17200a9 100644 --- a/PortabilityLayer/PLImageWidget.h +++ b/PortabilityLayer/PLImageWidget.h @@ -7,7 +7,7 @@ struct BitmapImage; namespace PortabilityLayer { - class ImageWidget final : public WidgetSpec + class ImageWidget final : public WidgetSpec { public: ImageWidget(const WidgetBasicState &state); @@ -16,6 +16,9 @@ namespace PortabilityLayer bool Init(const WidgetBasicState &state, const void *additionalData) override; void DrawControl(DrawSurface *surface) override; + WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) GP_ASYNCIFY_PARANOID_OVERRIDE; + int16_t Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) GP_ASYNCIFY_PARANOID_OVERRIDE; + private: THandle m_pict; }; diff --git a/PortabilityLayer/PLInvisibleWidget.cpp b/PortabilityLayer/PLInvisibleWidget.cpp index 0c4e9e7..13fa563 100644 --- a/PortabilityLayer/PLInvisibleWidget.cpp +++ b/PortabilityLayer/PLInvisibleWidget.cpp @@ -5,7 +5,7 @@ namespace PortabilityLayer { InvisibleWidget::InvisibleWidget(const WidgetBasicState &state) - : WidgetSpec(state) + : WidgetSpec(state) , m_clickable(state.m_enabled) { } @@ -31,4 +31,11 @@ namespace PortabilityLayer else return WidgetHandleStates::kIgnored; } + + int16_t InvisibleWidget::Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) + { + return DefaultCapture(captureContext, pos, callback); + } } + +PL_IMPLEMENT_WIDGET_TYPE(PortabilityLayer::WidgetTypes::kInvisible, PortabilityLayer::InvisibleWidget) diff --git a/PortabilityLayer/PLInvisibleWidget.h b/PortabilityLayer/PLInvisibleWidget.h index f23770e..c66aaf3 100644 --- a/PortabilityLayer/PLInvisibleWidget.h +++ b/PortabilityLayer/PLInvisibleWidget.h @@ -4,7 +4,7 @@ namespace PortabilityLayer { - class InvisibleWidget final : public WidgetSpec + class InvisibleWidget final : public WidgetSpec { public: explicit InvisibleWidget(const WidgetBasicState &state); @@ -12,7 +12,8 @@ namespace PortabilityLayer bool Init(const WidgetBasicState &state, const void *additionalData) override; - WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) override; + WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) GP_ASYNCIFY_PARANOID_OVERRIDE; + int16_t Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) GP_ASYNCIFY_PARANOID_OVERRIDE; private: bool m_clickable; diff --git a/PortabilityLayer/PLLabelWidget.cpp b/PortabilityLayer/PLLabelWidget.cpp index 543fb1b..17817fc 100644 --- a/PortabilityLayer/PLLabelWidget.cpp +++ b/PortabilityLayer/PLLabelWidget.cpp @@ -11,7 +11,7 @@ namespace PortabilityLayer { LabelWidget::LabelWidget(const WidgetBasicState &state) - : WidgetSpec(state) + : WidgetSpec(state) , m_text(state.m_text) { } @@ -46,4 +46,16 @@ namespace PortabilityLayer surface->DrawStringWrap(textStartPoint, m_rect, m_text.ToShortStr(), blackColor, sysFont); } + + WidgetHandleState_t LabelWidget::ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) + { + return DefaultProcessEvent(captureContext, evt); + } + + int16_t LabelWidget::Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) + { + return DefaultCapture(captureContext, pos, callback); + } } + +PL_IMPLEMENT_WIDGET_TYPE(PortabilityLayer::WidgetTypes::kLabel, PortabilityLayer::LabelWidget) diff --git a/PortabilityLayer/PLLabelWidget.h b/PortabilityLayer/PLLabelWidget.h index cfcce13..5e66202 100644 --- a/PortabilityLayer/PLLabelWidget.h +++ b/PortabilityLayer/PLLabelWidget.h @@ -5,7 +5,7 @@ namespace PortabilityLayer { - class LabelWidget final : public WidgetSpec + class LabelWidget final : public WidgetSpec { public: LabelWidget(const WidgetBasicState &state); @@ -17,6 +17,9 @@ namespace PortabilityLayer void DrawControl(DrawSurface *surface) override; + WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) GP_ASYNCIFY_PARANOID_OVERRIDE; + int16_t Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) GP_ASYNCIFY_PARANOID_OVERRIDE; + private: PascalStr<255> m_text; }; diff --git a/PortabilityLayer/PLPopupMenuWidget.cpp b/PortabilityLayer/PLPopupMenuWidget.cpp index 2c06264..702baab 100644 --- a/PortabilityLayer/PLPopupMenuWidget.cpp +++ b/PortabilityLayer/PLPopupMenuWidget.cpp @@ -12,15 +12,15 @@ #include "FontFamily.h" #include "Vec2i.h" -static const int kLightGray = 238; -static const int kMidGray = 221; -static const int kMidDarkGray = 170; -static const int kDarkGray = 102; +static const int kPopupMenuLightGray = 238; +static const int kPopupMenuMidGray = 221; +static const int kPopupMenuMidDarkGray = 170; +static const int kPopupMenuDarkGray = 102; namespace PortabilityLayer { PopupMenuWidget::PopupMenuWidget(const WidgetBasicState &state) - : WidgetSpec(state) + : WidgetSpec(state) { } @@ -82,8 +82,8 @@ namespace PortabilityLayer PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White(); PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black(); - PortabilityLayer::ResolveCachingColor midGrayColor = RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255); - PortabilityLayer::ResolveCachingColor darkGrayColor = RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255); + PortabilityLayer::ResolveCachingColor midGrayColor = RGBAColor::Create(kPopupMenuMidGray, kPopupMenuMidGray, kPopupMenuMidGray, 255); + PortabilityLayer::ResolveCachingColor darkGrayColor = RGBAColor::Create(kPopupMenuDarkGray, kPopupMenuDarkGray, kPopupMenuDarkGray, 255); const Rect rect = m_rect; const Rect innerRect = rect.Inset(2, 2); @@ -144,3 +144,5 @@ namespace PortabilityLayer return m_menu; } } + +PL_IMPLEMENT_WIDGET_TYPE(PortabilityLayer::WidgetTypes::kPopupMenu, PortabilityLayer::PopupMenuWidget) diff --git a/PortabilityLayer/PLPopupMenuWidget.h b/PortabilityLayer/PLPopupMenuWidget.h index 7c9e7d3..fe440ec 100644 --- a/PortabilityLayer/PLPopupMenuWidget.h +++ b/PortabilityLayer/PLPopupMenuWidget.h @@ -7,15 +7,15 @@ struct Menu; namespace PortabilityLayer { - class PopupMenuWidget final : public WidgetSpec + class PopupMenuWidget final : public WidgetSpec { public: explicit PopupMenuWidget(const WidgetBasicState &state); bool Init(const WidgetBasicState &state, const void *additionalData) override; - WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) override; - int16_t Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) override; + WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) GP_ASYNCIFY_PARANOID_OVERRIDE; + int16_t Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) GP_ASYNCIFY_PARANOID_OVERRIDE; void DrawControl(DrawSurface *surface) override; void OnStateChanged() override; diff --git a/PortabilityLayer/PLResourceManager.cpp b/PortabilityLayer/PLResourceManager.cpp index e05435b..2dafc65 100644 --- a/PortabilityLayer/PLResourceManager.cpp +++ b/PortabilityLayer/PLResourceManager.cpp @@ -184,9 +184,12 @@ namespace PortabilityLayer GpIOStream *fStream = nullptr; ZipFileProxy *proxy = nullptr; bool proxyIsShared = false; + + fprintf(stderr, "Trying to open resource file\n"); if (file->OpenResources(fStream, proxy, proxyIsShared) != PLErrors::kNone) return nullptr; + fprintf(stderr, "Creating resource archive\n"); IResourceArchive *archive = ResourceArchiveZipFile::Create(proxy, proxyIsShared, fStream); if (!archive) { diff --git a/PortabilityLayer/PLScrollBarWidget.cpp b/PortabilityLayer/PLScrollBarWidget.cpp index b84c485..d438223 100644 --- a/PortabilityLayer/PLScrollBarWidget.cpp +++ b/PortabilityLayer/PLScrollBarWidget.cpp @@ -9,7 +9,7 @@ namespace PortabilityLayer { ScrollBarWidget::ScrollBarWidget(const WidgetBasicState &state) - : WidgetSpec(state) + : WidgetSpec(state) , m_min(0) , m_max(0) , m_gripSize(0) @@ -260,11 +260,11 @@ namespace PortabilityLayer void ScrollBarWidget::SetState(int16_t state) { if (state < m_min) - WidgetSpec::SetState(m_min); + WidgetSpec::SetState(m_min); else if (state > m_max) - WidgetSpec::SetState(m_max); + WidgetSpec::SetState(m_max); else - WidgetSpec::SetState(state); + WidgetSpec::SetState(state); } void ScrollBarWidget::OnStateChanged() @@ -486,3 +486,5 @@ namespace PortabilityLayer return kControlDownButtonPart; } } + +PL_IMPLEMENT_WIDGET_TYPE(PortabilityLayer::WidgetTypes::kScrollBar, PortabilityLayer::ScrollBarWidget) diff --git a/PortabilityLayer/PLScrollBarWidget.h b/PortabilityLayer/PLScrollBarWidget.h index 9166ed6..7ae3501 100644 --- a/PortabilityLayer/PLScrollBarWidget.h +++ b/PortabilityLayer/PLScrollBarWidget.h @@ -7,7 +7,7 @@ struct Rect; namespace PortabilityLayer { - class ScrollBarWidget final : public WidgetSpec + class ScrollBarWidget final : public WidgetSpec { public: explicit ScrollBarWidget(const WidgetBasicState &state); @@ -15,7 +15,7 @@ namespace PortabilityLayer bool Init(const WidgetBasicState &state, const void *additionalData) override; void OnEnabledChanged() override; - WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) override; + WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) GP_ASYNCIFY_PARANOID_OVERRIDE; void DrawControl(DrawSurface *surface) override; void SetState(int16_t state) override; @@ -24,7 +24,7 @@ namespace PortabilityLayer void SetMin(int32_t v) override; void SetMax(int32_t v) override; - int16_t Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) override; + int16_t Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) GP_ASYNCIFY_PARANOID_OVERRIDE; int ResolvePart(const Point &point) const override; diff --git a/PortabilityLayer/PLSysCalls.cpp b/PortabilityLayer/PLSysCalls.cpp index b797919..b59a10d 100644 --- a/PortabilityLayer/PLSysCalls.cpp +++ b/PortabilityLayer/PLSysCalls.cpp @@ -15,6 +15,7 @@ #include "MacRomanConversion.h" #include "PLDrivers.h" +#include "CoreDefs.h" #include #include @@ -173,10 +174,35 @@ static void ImportVOSEvents(uint32_t timestamp) namespace PLSysCalls { + // Asyncify disarm checks are for manually checking that a stack has no indirect calls. + // They should not be nested! +#if GP_DEBUG_CONFIG && GP_ASYNCIFY_PARANOID + static bool g_asyncifyParanoidDisarmed = false; + + void AsyncifyParanoidSetDisarmed(bool state) + { + assert(g_asyncifyParanoidDisarmed != state); + g_asyncifyParanoidDisarmed = state; + } + + AsyncifyDisarmScope::AsyncifyDisarmScope() + { + AsyncifyParanoidSetDisarmed(true); + } + + AsyncifyDisarmScope::~AsyncifyDisarmScope() + { + AsyncifyParanoidSetDisarmed(false); + } +#endif + void Sleep(uint32_t ticks) { +#if GP_DEBUG_CONFIG && GP_ASYNCIFY_PARANOID + assert(g_asyncifyParanoidDisarmed); +#endif if (ticks > 0) - { + { PortabilityLayer::RenderFrames(ticks); ImportVOSEvents(PortabilityLayer::DisplayDeviceManager::GetInstance()->GetTickCount()); @@ -190,8 +216,12 @@ namespace PLSysCalls void Exit(int exitCode) { +#if GP_ASYNCIFY_PARANOID + exit(exitCode); +#else gs_exitCode = exitCode; longjmp(gs_mainExitWrapper, 1); +#endif } int MainExitWrapper(int (*mainFunc)()) diff --git a/PortabilityLayer/PLSysCalls.h b/PortabilityLayer/PLSysCalls.h index 962aad2..0bd77a8 100644 --- a/PortabilityLayer/PLSysCalls.h +++ b/PortabilityLayer/PLSysCalls.h @@ -1,5 +1,6 @@ #pragma once +#include "CoreDefs.h" #include "VirtualDirectory.h" #include @@ -9,5 +10,18 @@ namespace PLSysCalls void Sleep(uint32_t ticks); void Exit(int exitCode); +#if GP_DEBUG_CONFIG && GP_ASYNCIFY_PARANOID + class AsyncifyDisarmScope + { + public: + AsyncifyDisarmScope(); + ~AsyncifyDisarmScope(); + }; + +#define PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE() PLSysCalls::AsyncifyDisarmScope disarmScope +#else +#define PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE() +#endif + int MainExitWrapper(int (*mainFunc)()); } diff --git a/PortabilityLayer/PLWidgets.cpp b/PortabilityLayer/PLWidgets.cpp index 507a286..442d68d 100644 --- a/PortabilityLayer/PLWidgets.cpp +++ b/PortabilityLayer/PLWidgets.cpp @@ -17,14 +17,14 @@ namespace PortabilityLayer { } - WidgetHandleState_t Widget::ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) + WidgetHandleState_t Widget::DefaultProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) { (void)evt; return WidgetHandleStates::kIgnored; } - int16_t Widget::Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) + int16_t Widget::DefaultCapture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) { return 0; } @@ -34,6 +34,68 @@ namespace PortabilityLayer (void)surface; } +#if GP_ASYNCIFY_PARANOID + WidgetHandleState_t Widget::ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) + { + switch (this->GetWidgetType()) + { + case WidgetTypes::kButton: + return DispatchDynProcessEvent(this, captureContext, evt); + case WidgetTypes::kPopupMenu: + return DispatchDynProcessEvent(this, captureContext, evt); + case WidgetTypes::kEditbox: + return DispatchDynProcessEvent(this, captureContext, evt); + case WidgetTypes::kIcon: + return DispatchDynProcessEvent(this, captureContext, evt); + case WidgetTypes::kImage: + return DispatchDynProcessEvent(this, captureContext, evt); + case WidgetTypes::kInvisible: + return DispatchDynProcessEvent(this, captureContext, evt); + case WidgetTypes::kLabel: + return DispatchDynProcessEvent(this, captureContext, evt); + case WidgetTypes::kScrollBar: + return DispatchDynProcessEvent(this, captureContext, evt); + default: + return WidgetHandleStates::kIgnored; + } + } + + int16_t Widget::Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) + { + switch (this->GetWidgetType()) + { + case WidgetTypes::kButton: + return DispatchDynCapture(this, captureContext, pos, callback); + case WidgetTypes::kPopupMenu: + return DispatchDynCapture(this, captureContext, pos, callback); + case WidgetTypes::kEditbox: + return DispatchDynCapture(this, captureContext, pos, callback); + case WidgetTypes::kIcon: + return DispatchDynCapture(this, captureContext, pos, callback); + case WidgetTypes::kImage: + return DispatchDynCapture(this, captureContext, pos, callback); + case WidgetTypes::kInvisible: + return DispatchDynCapture(this, captureContext, pos, callback); + case WidgetTypes::kLabel: + return DispatchDynCapture(this, captureContext, pos, callback); + case WidgetTypes::kScrollBar: + return DispatchDynCapture(this, captureContext, pos, callback); + default: + return -1; + } + } +#else + WidgetHandleState_t Widget::ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) + { + return this->DefaultProcessEvent(captureContext, evt); + } + + int16_t Widget::Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) + { + return this->DefaultCapture(captureContext, pos, callback); + } +#endif + void Widget::SetMin(int32_t v) { } diff --git a/PortabilityLayer/PLWidgets.h b/PortabilityLayer/PLWidgets.h index b28f9fc..d241c96 100644 --- a/PortabilityLayer/PLWidgets.h +++ b/PortabilityLayer/PLWidgets.h @@ -25,7 +25,47 @@ namespace PortabilityLayer typedef WidgetHandleStates::WidgetHandleState WidgetHandleState_t; - typedef void (*WidgetUpdateCallback_t)(void *captureContext, Widget *control, int part); + namespace WidgetTypes + { + enum WidgetType + { + kButton, + kPopupMenu, + kEditbox, + kIcon, + kImage, + kInvisible, + kLabel, + kScrollBar, + }; + } + + typedef WidgetTypes::WidgetType WidgetType_t; + + typedef void(*WidgetUpdateCallback_t)(void *captureContext, Widget *control, int part); + +#if GP_ASYNCIFY_PARANOID + template + WidgetHandleState_t DispatchDynProcessEvent(Widget *widget, void *captureContext, const TimeTaggedVOSEvent &evt); + + template + int16_t DispatchDynCapture(Widget *widget, void *captureContext, const Point &pos, WidgetUpdateCallback_t callback); + +#define PL_IMPLEMENT_WIDGET_TYPE(typeID, type) \ + template<> \ + PortabilityLayer::WidgetHandleState_t PortabilityLayer::DispatchDynProcessEvent(Widget *widget, void *captureContext, const TimeTaggedVOSEvent &evt) \ + { \ + return static_cast(widget)->ProcessEvent(captureContext, evt); \ + } \ + template<> \ + int16_t PortabilityLayer::DispatchDynCapture(Widget *widget, void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) \ + { \ + return static_cast(widget)->Capture(captureContext, pos, callback); \ + } + +#else +#define PL_IMPLEMENT_WIDGET_TYPE(typeID, type) +#endif struct WidgetBasicState { @@ -48,9 +88,12 @@ namespace PortabilityLayer { public: virtual bool Init(const WidgetBasicState &state, const void *additionalData) = 0; + virtual WidgetType_t GetWidgetType() const = 0; + + GP_ASYNCIFY_PARANOID_VIRTUAL WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) GP_ASYNCIFY_PARANOID_PURE; + GP_ASYNCIFY_PARANOID_VIRTUAL int16_t Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) GP_ASYNCIFY_PARANOID_PURE; + virtual void Destroy() = 0; - virtual WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt); - virtual int16_t Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback); virtual void DrawControl(DrawSurface *surface); virtual void SetMin(int32_t v); @@ -100,6 +143,9 @@ namespace PortabilityLayer static void BaseRelease(void *storage); static void *BaseAlloc(size_t sz); + WidgetHandleState_t DefaultProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt); + int16_t DefaultCapture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback); + Window *m_window; Rect m_rect; uint32_t m_referenceConstant; @@ -115,7 +161,7 @@ namespace PortabilityLayer namespace PortabilityLayer { - template + template class WidgetSpec : public Widget { public: @@ -130,6 +176,11 @@ namespace PortabilityLayer Widget::BaseRelease(static_cast(this)); } + WidgetType_t GetWidgetType() const override + { + return TWidgetType; + } + static T *Create(const WidgetBasicState &state, const void *additionalData) { void *storage = Widget::BaseAlloc(sizeof(T)); @@ -139,7 +190,7 @@ namespace PortabilityLayer T *widgetT = new (storage) T(state); // Conversion check - WidgetSpec *downcastWidget = widgetT; + WidgetSpec *downcastWidget = widgetT; (void)downcastWidget; Widget *widget = widgetT; diff --git a/PortabilityLayer/PortabilityLayer_Combined.cpp b/PortabilityLayer/PortabilityLayer_Combined.cpp new file mode 100644 index 0000000..8f68695 --- /dev/null +++ b/PortabilityLayer/PortabilityLayer_Combined.cpp @@ -0,0 +1,86 @@ +#include "AntiAliasTable.cpp" +#include "AppEventHandler.cpp" +#include "BinHex4.cpp" +#include "BitmapImage.cpp" +#include "ByteSwap.cpp" +#include "CFileStream.cpp" +#include "DeflateCodec.cpp" +#include "DialogManager.cpp" +#include "DisplayDeviceManager.cpp" +#include "EllipsePlotter.cpp" +#include "FileBrowserUI.cpp" +#include "FileManager.cpp" +#include "FileSectionStream.cpp" +#include "FontFamily.cpp" +#include "FontManager.cpp" +#include "FontRenderer.cpp" +#include "GPArchive.cpp" +#include "HostSuspendHook.cpp" +#include "IconLoader.cpp" +#include "InflateStream.cpp" +#include "InputManager.cpp" +#include "LinePlotter.cpp" +#include "MacBinary2.cpp" +#include "MacFileInfo.cpp" +#include "MacFileMem.cpp" +#include "MemoryManager.cpp" +#include "MemReaderStream.cpp" +#include "MenuManager.cpp" +#include "MMBlock.cpp" +#include "MMHandleBlock.cpp" +#include "PLApplication.cpp" +#include "PLButtonWidget.cpp" +#include "PLControlDefinitions.cpp" +#include "PLCore.cpp" +#include "PLCTabReducer.cpp" +#include "PLDialogs.cpp" +#include "PLDrivers.cpp" +#include "PLEditboxWidget.cpp" +#include "PLEventQueue.cpp" +#include "PLHacks.cpp" +#include "PLHandle.cpp" +#include "PLIconWidget.cpp" +#include "PLImageWidget.cpp" +#include "PLInvisibleWidget.cpp" +#include "PLKeyEncoding.cpp" +#include "PLLabelWidget.cpp" +#include "PLMenus.cpp" +#include "PLMovies.cpp" +#include "PLNumberFormatting.cpp" +#include "PLPopupMenuWidget.cpp" +#include "PLQDOffscreen.cpp" +#include "PLQDraw.cpp" +#include "PLResourceManager.cpp" +#include "PLResources.cpp" +#include "PLScrollBarWidget.cpp" +#include "PLSound.cpp" +#include "PLStandardColors.cpp" +#include "PLStringCompare.cpp" +#include "PLSysCalls.cpp" +#include "PLTimeTaggedVOSEvent.cpp" +#include "PLWidgets.cpp" +#include "QDGraf.cpp" +#include "QDManager.cpp" +#include "QDPictDecoder.cpp" +#include "QDPictEmitContext.cpp" +#include "QDPictHeader.cpp" +#include "QDPixMap.cpp" +#include "QDPort.cpp" +#include "QDStandardPalette.cpp" +#include "RandomNumberGenerator.cpp" +#include "ResolveCachingColor.cpp" +#include "ResourceCompiledRef.cpp" +#include "ResourceFile.cpp" +#include "ScanlineMask.cpp" +#include "ScanlineMaskBuilder.cpp" +#include "ScanlineMaskConverter.cpp" +#include "ScanlineMaskIterator.cpp" +#include "SimpleGraphic.cpp" +#include "TextPlacer.cpp" +#include "UTF8.cpp" +#include "UTF16.cpp" +#include "WindowDef.cpp" +#include "WindowManager.cpp" +#include "WorkerThread.cpp" +#include "XModemCRC.cpp" +#include "ZipFileProxy.cpp" diff --git a/PortabilityLayer/WindowManager.cpp b/PortabilityLayer/WindowManager.cpp index 582e78a..9521c38 100644 --- a/PortabilityLayer/WindowManager.cpp +++ b/PortabilityLayer/WindowManager.cpp @@ -188,8 +188,8 @@ namespace PortabilityLayer bool GetWindowChromeInteractionZone(Window *window, const Vec2i &point, RegionID_t &outRegion) const override; void SwapExclusiveWindow(Window *& windowRef) override; - void FlickerWindowIn(Window *window, int32_t velocity) override; - void FlickerWindowOut(Window *window, int32_t velocity) override; + void FlickerWindowIn(Window *window, int32_t velocity) GP_ASYNCIFY_PARANOID_OVERRIDE; + void FlickerWindowOut(Window *window, int32_t velocity) GP_ASYNCIFY_PARANOID_OVERRIDE; void SetWindowDesaturation(Window *window, float desaturationLevel) override; @@ -1324,6 +1324,7 @@ namespace PortabilityLayer void WindowManagerImpl::FlickerWindowIn(Window *window, int32_t velocity) { + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); m_flickerWindow = static_cast(window); int32_t chromeLead = 64; @@ -1353,6 +1354,7 @@ namespace PortabilityLayer void WindowManagerImpl::FlickerWindowOut(Window *window, int32_t velocity) { + PL_ASYNCIFY_PARANOID_DISARM_FOR_SCOPE(); m_flickerWindow = static_cast(window); int32_t chromeLead = 64; @@ -1689,4 +1691,16 @@ namespace PortabilityLayer { return WindowManagerImpl::GetInstance(); } + +#if GP_ASYNCIFY_PARANOID + void WindowManager::FlickerWindowIn(Window *window, int32_t velocity) + { + static_cast(this)->FlickerWindowIn(window, velocity); + } + + void WindowManager::FlickerWindowOut(Window *window, int32_t velocity) + { + static_cast(this)->FlickerWindowOut(window, velocity); + } +#endif } diff --git a/PortabilityLayer/WindowManager.h b/PortabilityLayer/WindowManager.h index 28606c4..abfdfce 100644 --- a/PortabilityLayer/WindowManager.h +++ b/PortabilityLayer/WindowManager.h @@ -3,6 +3,7 @@ #include #include "PLRegions.h" +#include "PLSysCalls.h" struct Window; struct DrawSurface; @@ -39,8 +40,8 @@ namespace PortabilityLayer virtual bool GetWindowChromeInteractionZone(Window *window, const Vec2i &point, RegionID_t &outRegion) const = 0; virtual void SwapExclusiveWindow(Window *& windowRef) = 0; - virtual void FlickerWindowIn(Window *window, int32_t velocity) = 0; - virtual void FlickerWindowOut(Window *window, int32_t velocity) = 0; + GP_ASYNCIFY_PARANOID_VIRTUAL void FlickerWindowIn(Window *window, int32_t velocity) GP_ASYNCIFY_PARANOID_PURE; + GP_ASYNCIFY_PARANOID_VIRTUAL void FlickerWindowOut(Window *window, int32_t velocity) GP_ASYNCIFY_PARANOID_PURE; virtual void SetWindowDesaturation(Window *window, float desaturationLevel) = 0; diff --git a/PortabilityLayer/ZipFileProxy.cpp b/PortabilityLayer/ZipFileProxy.cpp index a4d9f44..1f17fa0 100644 --- a/PortabilityLayer/ZipFileProxy.cpp +++ b/PortabilityLayer/ZipFileProxy.cpp @@ -285,17 +285,29 @@ namespace PortabilityLayer MemoryManager *mm = MemoryManager::GetInstance(); if (!stream->SeekEnd(sizeof(ZipEndOfCentralDirectoryRecord))) + { + fprintf(stderr, "Seek end failed\n"); return nullptr; + } ZipEndOfCentralDirectoryRecord eocd; if (stream->Read(&eocd, sizeof(eocd)) != sizeof(eocd)) + { + fprintf(stderr, "EOCD read failed\n"); return nullptr; + } if (eocd.m_signature != ZipEndOfCentralDirectoryRecord::kSignature) + { + fprintf(stderr, "EOCD sig check failed\n"); return nullptr; + } if (!stream->SeekStart(eocd.m_centralDirStartOffset)) + { + fprintf(stderr, "CDir seek failed\n"); return nullptr; + } const size_t centralDirSize = eocd.m_centralDirectorySizeBytes; void *centralDirImage = nullptr; @@ -318,6 +330,8 @@ namespace PortabilityLayer if (stream->Read(centralDirImage, centralDirSize) != centralDirSize) { + fprintf(stderr, "CDir image read failed\n"); + mm->Release(centralDirFiles); mm->Release(centralDirImage); return nullptr; @@ -334,6 +348,8 @@ namespace PortabilityLayer { if (centralDirEnd - centralDirCursor < sizeof(ZipCentralDirectoryFileHeader)) { + fprintf(stderr, "CDir read failed point 1\n"); + failed = true; break; } @@ -345,18 +361,24 @@ namespace PortabilityLayer if (centralDirHeader.m_signature != ZipCentralDirectoryFileHeader::kSignature) { + fprintf(stderr, "CDir read failed point 2\n"); + failed = true; break; } if (centralDirEnd - centralDirCursor < centralDirHeader.m_fileNameLength) { + fprintf(stderr, "CDir read failed point 3\n"); + failed = true; break; } if (!CheckAndFixFileName(centralDirCursor, centralDirHeader.m_fileNameLength)) { + fprintf(stderr, "CDir read failed point 4\n"); + failed = true; break; } @@ -365,6 +387,8 @@ namespace PortabilityLayer if (centralDirEnd - centralDirCursor < centralDirHeader.m_extraFieldLength) { + fprintf(stderr, "CDir read failed point 5\n"); + failed = true; break; } @@ -373,6 +397,8 @@ namespace PortabilityLayer if (centralDirEnd - centralDirCursor < centralDirHeader.m_commentLength) { + fprintf(stderr, "CDir read failed point 6\n"); + failed = true; break; } @@ -396,6 +422,8 @@ namespace PortabilityLayer { if (ZipDirectorySortPredicate(centralDirFiles + (i - 1), centralDirFiles + i) == 0) { + fprintf(stderr, "File names were duplicated\n"); + // Duplicate file names mm->Release(centralDirFiles); mm->Release(centralDirImage); diff --git a/bin2h/bin2h.cpp b/bin2h/bin2h.cpp new file mode 100644 index 0000000..319a6c4 --- /dev/null +++ b/bin2h/bin2h.cpp @@ -0,0 +1,92 @@ +#include +#include + +#include "WindowsUnicodeToolShim.h" + +#include +#include + +int toolMain(int argc, const char **argv) +{ + if (argc != 3) + { + fprintf(stderr, "Usage: bin2h "); + return -1; + } + + std::string dir = argv[1]; + std::string filter = dir + "\\*"; + + WIN32_FIND_DATAA findData; + HANDLE findDataH = FindFirstFileA(filter.c_str(), &findData); + + if (findDataH == INVALID_HANDLE_VALUE) + { + fprintf(stderr, "Failed to open directory scan"); + return -1; + } + + + FILE *outF = fopen_utf8(argv[2], "wb"); + if (!outF) + { + fprintf(stderr, "Failed to open output file"); + return -1; + } + + std::vector fileNames; + int numFiles = 0; + + for (;;) + { + if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + fileNames.push_back(std::string(findData.cFileName)); + + std::string filePath = dir + "\\" + findData.cFileName; + + FILE *inF = fopen_utf8(filePath.c_str(), "rb"); + if (!inF) + { + fprintf(stderr, "Failed to open input file"); + return -1; + } + + fprintf(outF, "const unsigned char g_fileContents%i[] = {\n", numFiles); + + fseek(inF, 0, SEEK_END); + long fileSize = ftell(inF); + fseek(inF, 0, SEEK_SET); + + for (long i = 0; i < fileSize; i++) + { + if (i % 20 == 0) + fputs("\n\t\t", outF); + + int c = fgetc(inF); + fprintf(outF, "% 4i,", (c & 0xff)); + } + fprintf(outF, "\n};\n\n", numFiles); + + numFiles++; + + fclose(inF); + } + + if (!FindNextFileA(findDataH, &findData)) + break; + } + + FindClose(findDataH); + + fprintf(outF, "FileCatalogEntry g_catalogEntries[] = {\n"); + for (int i = 0; i < numFiles; i++) + fprintf(outF, "\t{ \"%s\", g_fileContents%i, sizeof(g_fileContents%i) },\n", fileNames[i].c_str(), i, i); + fprintf(outF, "};\n"); + fprintf(outF, "FileCatalog g_catalog = { g_catalogEntries, sizeof(g_catalogEntries) / sizeof(g_catalogEntries[0]), sizeof(g_catalogEntries), sizeof(g_catalogEntries[0]) };\n"); + fprintf(outF, "const FileCatalog &GetCatalog() { return g_catalog; }\n"); + + fclose(outF); + + return 0; +} diff --git a/bin2h/bin2h.vcxproj b/bin2h/bin2h.vcxproj new file mode 100644 index 0000000..3667f61 --- /dev/null +++ b/bin2h/bin2h.vcxproj @@ -0,0 +1,84 @@ + + + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {D045F28D-F245-44DD-B576-CC91BF3BE6E9} + bin2h + 10.0.17763.0 + + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + true + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + + + + + + + + {6ec62b0f-9353-40a4-a510-3788f1368b33} + + + {15009625-1120-405e-8bba-69a16cd6713d} + + + + + + \ No newline at end of file diff --git a/bin2h/bin2h.vcxproj.filters b/bin2h/bin2h.vcxproj.filters new file mode 100644 index 0000000..db7292a --- /dev/null +++ b/bin2h/bin2h.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file