From cb68cf1bf2b3d24562e63f78a33a6419bd0864e9 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Tue, 12 Aug 2025 01:14:33 -0600 Subject: Fixed torch to build on emscripten --- src/lib/web.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/lib/web.cpp (limited to 'src/lib/web.cpp') diff --git a/src/lib/web.cpp b/src/lib/web.cpp new file mode 100644 index 0000000..eed9c26 --- /dev/null +++ b/src/lib/web.cpp @@ -0,0 +1,53 @@ +#ifdef __EMSCRIPTEN__ +#include "Companion.h" + +#include +using namespace emscripten; + +Companion* Companion::Instance; + +void Bind(Companion* instance) { + Companion::Instance = instance; +} + +EMSCRIPTEN_BINDINGS(Torch) { + register_vector("VectorUInt8"); + + function("Bind", &Bind, allow_raw_pointers()); + + enum_("ExportType") + .value("Header", ExportType::Header) + .value("Code", ExportType::Code) + .value("Binary", ExportType::Binary) + .value("Modding", ExportType::Modding) + .value("XML", ExportType::XML); + + enum_("ArchiveType") + .value("None", ArchiveType::None) + .value("OTR", ArchiveType::OTR) + .value("O2R", ArchiveType::O2R); + + enum_("CountryCode") + .value("Japan", N64::CountryCode::Japan) + .value("NorthAmerica", N64::CountryCode::NorthAmerica) + .value("Europe", N64::CountryCode::Europe) + .value("Unknown", N64::CountryCode::Unknown); + + class_("Cartridge") + .function("GetGameTitle", &N64::Cartridge::GetGameTitle) + .function("GetCountryCode", &N64::Cartridge::GetCountryCode) + .function("GetCountry", &N64::Cartridge::GetCountry) + .function("GetVersion", &N64::Cartridge::GetVersion) + .function("GetHash", &N64::Cartridge::GetHash) + .function("GetCRC", &N64::Cartridge::GetCRC); + + class_("Companion") + .constructor, ArchiveType, bool, bool, std::string, std::string>() + .constructor, ArchiveType, bool, bool, std::string>() + .constructor, ArchiveType, bool, bool>() + .function("Init", &Companion::Init) + .function("GetCartridge", &Companion::GetCartridge, allow_raw_pointers()) + .function("Process", &Companion::Process) + .function("GetRomData", &Companion::GetRomData, allow_raw_pointers()); +} +#endif \ No newline at end of file -- cgit v1.2.3