diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c28ea84..1d3b5e5f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,7 @@ jobs: - { name: 'msys2 mingw32', os: 'windows-latest', generator: 'Ninja', dx5: false, config: false, mingw: true, werror: true, clang-tidy: true, msystem: 'mingw32', msys-env: 'mingw-w64-i686', shell: 'msys2 {0}' } - { name: 'msys2 mingw64', os: 'windows-latest', generator: 'Ninja', dx5: false, config: true, mingw: true, werror: true, clang-tidy: true, msystem: 'mingw64', msys-env: 'mingw-w64-x86_64', shell: 'msys2 {0}' } - { name: 'macOS', os: 'macos-latest', generator: 'Ninja', dx5: false, config: true, brew: true, werror: true, clang-tidy: false } + - { name: 'iOS', os: 'macos-15', generator: 'Xcode', dx5: false, config: false, brew: true, werror: true, clang-tidy: false, cmake-args: '-DCMAKE_SYSTEM_NAME=iOS' } - { name: 'Emscripten', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, emsdk: true, werror: true, clang-tidy: false, cmake-wrapper: 'emcmake' } - { name: 'Nintendo 3DS', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, n3ds: true, werror: true, clang-tidy: false, container: 'devkitpro/devkitarm:latest', cmake-args: '-DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/3DS.cmake' } - { name: 'Xbox One', os: 'windows-latest', generator: 'Visual Studio 17 2022', dx5: false, config: false, msvc: true, werror: false, clang-tidy: false, vc-arch: 'amd64', cmake-args: '-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0.26100.0', xbox-one: true} @@ -122,7 +123,20 @@ jobs: if: ${{ !matrix.n3ds }} run: | cd build - cpack . + success=0 + max_tries=10 + for i in $(seq $max_tries); do + cpack . && success=1 + if test $success = 1; then + break + fi + echo "Package creation failed. Sleep 1 second and try again." + sleep 1 + done + if test $success = 0; then + echo "Package creation failed after $max_tries attempts." + exit 1 + fi - name: Install linuxdeploy if: ${{ matrix.linux }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 33c77acb..e3dc60ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,12 @@ cmake_minimum_required(VERSION 3.25...4.0 FATAL_ERROR) project(isle LANGUAGES CXX C VERSION 0.1) +if (IOS) + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED NO) + set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0") + add_compile_definitions(IOS) +endif() + if (WINDOWS_STORE) add_compile_definitions(WINDOWS_STORE) endif() @@ -42,7 +48,8 @@ option(ISLE_WERROR "Treat warnings as errors" OFF) option(ISLE_DEBUG "Enable imgui debug" ON) cmake_dependent_option(ISLE_USE_DX5 "Build with internal DirectX 5 SDK" "${NOT_MINGW}" "WIN32;CMAKE_SIZEOF_VOID_P EQUAL 4" OFF) cmake_dependent_option(ISLE_MINIWIN "Use miniwin" ON "NOT ISLE_USE_DX5" OFF) -cmake_dependent_option(ISLE_BUILD_CONFIG "Build CONFIG.EXE application" ON "(MSVC OR ISLE_MINIWIN) AND (NOT PSP) AND (NOT NINTENDO_3DS) AND (NOT WINDOWS_STORE)" OFF) +cmake_dependent_option(ISLE_EXTENSIONS "Use extensions" ON "NOT ISLE_USE_DX5" OFF) +cmake_dependent_option(ISLE_BUILD_CONFIG "Build CONFIG.EXE application" ON "MSVC OR ISLE_MINIWIN;NOT NINTENDO_3DS;NOT WINDOWS_STORE;NOT PSP" OFF) cmake_dependent_option(ISLE_COMPILE_SHADERS "Compile shaders" ON "SDL_SHADERCROSS_BIN;TARGET Python3::Interpreter" OFF) cmake_dependent_option(CMAKE_POSITION_INDEPENDENT_CODE "Build with -fPIC" ON "NOT PSP" OFF) option(ENABLE_CLANG_TIDY "Enable clang-tidy") @@ -55,6 +62,7 @@ message(STATUS "Isle app: ${ISLE_BUILD_APP}") message(STATUS "Config app: ${ISLE_BUILD_CONFIG}") message(STATUS "Internal DirectX5 SDK: ${ISLE_USE_DX5}") message(STATUS "Internal miniwin: ${ISLE_MINIWIN}") +message(STATUS "Isle extensions: ${ISLE_EXTENSIONS}") message(STATUS "Isle debugging: ${ISLE_DEBUG}") message(STATUS "Compile shaders: ${ISLE_COMPILE_SHADERS}") @@ -167,6 +175,7 @@ add_library(lego1 target_precompile_headers(lego1 PRIVATE "LEGO1/lego1_pch.h") set_property(TARGET lego1 PROPERTY DEFINE_SYMBOL "LEGO1_DLL") target_include_directories(lego1 PUBLIC "$") +target_include_directories(lego1 PUBLIC "$") target_include_directories(lego1 PUBLIC "$") target_include_directories(lego1 PUBLIC "$") target_include_directories(lego1 PUBLIC "$") @@ -489,6 +498,14 @@ if (NOT ISLE_MINIWIN) target_compile_definitions(lego1 PRIVATE DIRECTINPUT_VERSION=0x0500) endif() +if (ISLE_EXTENSIONS) + target_compile_definitions(lego1 PUBLIC EXTENSIONS) + target_sources(lego1 PRIVATE + extensions/src/extensions.cpp + extensions/src/textureloader.cpp + ) +endif() + if (ISLE_BUILD_APP) add_executable(isle WIN32 ISLE/res/isle.rc @@ -544,9 +561,11 @@ if (ISLE_BUILD_APP) endif() if(EMSCRIPTEN) target_sources(isle PRIVATE + ISLE/emscripten/config.cpp ISLE/emscripten/events.cpp ISLE/emscripten/filesystem.cpp ISLE/emscripten/messagebox.cpp + ISLE/emscripten/window.cpp ) target_compile_definitions(isle PRIVATE "ISLE_EMSCRIPTEN_HOST=\"${ISLE_EMSCRIPTEN_HOST}\"") set_property(TARGET isle PROPERTY SUFFIX ".html") @@ -562,6 +581,11 @@ if (ISLE_BUILD_APP) ISLE/xbox_one_series/config.cpp ) endif() + if (IOS) + target_sources(isle PRIVATE + ISLE/ios/config.cpp + ) + endif() if(Python3_FOUND) if(NOT DEFINED PYTHON_PIL_AVAILABLE) execute_process( @@ -719,6 +743,7 @@ if (NOT (NINTENDO_3DS OR WINDOWS_STORE)) install(TARGETS isle ${install_extra_targets} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + BUNDLE DESTINATION "." ) endif() if (ISLE_BUILD_CONFIG) @@ -743,6 +768,7 @@ if (ISLE_BUILD_CONFIG) endif() install(TARGETS isle-config RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + BUNDLE DESTINATION "." ) endif() if(EMSCRIPTEN) @@ -812,8 +838,14 @@ if(WINDOWS_STORE) PATTERN "*/*.msix" PATTERN "*/*.msixbundle") endif() -if(MSVC) +if(MSVC OR IOS) set(CPACK_GENERATOR ZIP) + if(IOS) + set(CPACK_ARCHIVE_FILE_EXTENSION ".ipa") + set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF) + endif() +elseif(APPLE AND NOT IOS) + set(CPACK_GENERATOR DragNDrop) elseif(PSP) # Create an EBOOT.PBP file set(BUILD_PRX 1) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 61b8cf68..8be43bce 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,12 +6,7 @@ If you feel fit to contribute, feel free to create a pull request! Someone will Please keep your pull requests small and understandable; you may be able to shoot ahead and make a lot of progress in a short amount of time, but this is a collaborative project, so you must allow others to catch up and follow along. Large pull requests become significantly more unwieldy to review, and as such make it exponentially more likely for a mistake or error to go undetected. They also make it harder to merge other pull requests because the more files you modify, the more likely it is for a merge conflict to occur. A general guideline is to keep submissions limited to one class at a time. Sometimes two or more classes may be too interlinked for this to be feasible, so this is not a hard rule, however if your PR is starting to modify more than 10 or so files, it's probably getting too big. -This repository has a single goal: achieving platform independence. Consequently, contributions that do not support this goal cannot be accepted. Examples of out-of-scope contributions include: - -* Improving code efficiency or performance without addressing platform compatibility -* Replacing `MxString` with `std::string` -* Fixing gameplay bugs -* Enhancing audio or video quality +This repository has achieving platform independence as its primary goal, with limited support for light modding (using [`extensions`](/extensions)). Any changes that modify code in `LEGO1` are unlikely to be accepted, unless they directly serve to increase platform compatibility. If in doubt, please contact us in the [Matrix chatroom](https://matrix.to/#/#isledecomp:matrix.org). diff --git a/ISLE/emscripten/config.cpp b/ISLE/emscripten/config.cpp new file mode 100644 index 00000000..58a42704 --- /dev/null +++ b/ISLE/emscripten/config.cpp @@ -0,0 +1,27 @@ +#include "config.h" + +#include "filesystem.h" +#include "window.h" + +#include +#include +#include + +void Emscripten_SetupDefaultConfigOverrides(dictionary* p_dictionary) +{ + SDL_Log("Overriding default config for Emscripten"); + + iniparser_set(p_dictionary, "isle:diskpath", Emscripten_bundledPath); + iniparser_set(p_dictionary, "isle:cdpath", Emscripten_streamPath); + iniparser_set(p_dictionary, "isle:savepath", Emscripten_savePath); + iniparser_set(p_dictionary, "isle:Full Screen", "false"); + iniparser_set(p_dictionary, "isle:Flip Surfaces", "true"); + + // Emscripten-only for now + Emscripten_SetScaleAspect(iniparser_getboolean(p_dictionary, "isle:Original Aspect Ratio", true)); + Emscripten_SetOriginalResolution(iniparser_getboolean(p_dictionary, "isle:Original Resolution", true)); + + // clang-format off + MAIN_THREAD_EM_ASM({JSEvents.fullscreenEnabled = function() { return false; }}); +// clang-format on +} diff --git a/ISLE/emscripten/config.h b/ISLE/emscripten/config.h new file mode 100644 index 00000000..255888c0 --- /dev/null +++ b/ISLE/emscripten/config.h @@ -0,0 +1,8 @@ +#ifndef EMSCRIPTEN_CONFIG_H +#define EMSCRIPTEN_CONFIG_H + +#include "dictionary.h" + +void Emscripten_SetupDefaultConfigOverrides(dictionary* p_dictionary); + +#endif // EMSCRIPTEN_CONFIG_H diff --git a/ISLE/emscripten/emscripten.patch b/ISLE/emscripten/emscripten.patch index 0bc8222d..a24a67bd 100644 --- a/ISLE/emscripten/emscripten.patch +++ b/ISLE/emscripten/emscripten.patch @@ -1,3 +1,28 @@ +diff --git a/src/lib/libhtml5.js b/src/lib/libhtml5.js +index da08765e7..24e5da22e 100644 +--- a/src/lib/libhtml5.js ++++ b/src/lib/libhtml5.js +@@ -1182,6 +1182,7 @@ var LibraryHTML5 = { + + $registerRestoreOldStyle__deps: ['$getCanvasElementSize', '$setCanvasElementSize', '$currentFullscreenStrategy'], + $registerRestoreOldStyle: (canvas) => { ++ return; + var canvasSize = getCanvasElementSize(canvas); + var oldWidth = canvasSize[0]; + var oldHeight = canvasSize[1]; +@@ -1326,9 +1327,9 @@ var LibraryHTML5 = { + var topMargin; + + if (inAspectRatioFixedFullscreenMode) { +- if (w*y < x*h) h = (w * y / x) | 0; +- else if (w*y > x*h) w = (h * x / y) | 0; +- topMargin = ((screenHeight - h) / 2) | 0; ++ if (w*y < x*h) h = Math.round(w * y / x) | 0; ++ else if (w*y > x*h) w = Math.round(h * x / y) | 0; ++ topMargin = Math.round((screenHeight - h) / 2) | 0; + } + + if (inPixelPerfectFullscreenMode) { diff --git a/src/lib/libpthread.js b/src/lib/libpthread.js index 6d979627e..97e3f8684 100644 --- a/src/lib/libpthread.js @@ -140,20 +165,26 @@ index e8c9f7e21..caf1971d2 100644 - }); diff --git a/src/preamble.js b/src/preamble.js -index 572694517..0d2f4421b 100644 +index 572694517..44e65c823 100644 --- a/src/preamble.js +++ b/src/preamble.js -@@ -1062,3 +1062,13 @@ function getCompilerSetting(name) { +@@ -1062,3 +1062,19 @@ function getCompilerSetting(name) { // dynamic linker as symbols are loaded. var asyncifyStubs = {}; #endif + -+(async () => { -+ try { -+ await navigator.storage.getDirectory(); -+ Module["disableOpfs"] = false; -+ } catch (e) { -+ Module["disableOpfs"] = true; -+ } -+})(); ++if (typeof document !== "undefined") { ++ (async () => { ++ try { ++ await navigator.storage.getDirectory(); ++ Module["disableOpfs"] = false; ++ } catch (e) { ++ Module["disableOpfs"] = true; ++ } ++ console.log("disableOpfs: " + Module["disableOpfs"]); ++ })(); ++ ++ Module["disableOffscreenCanvases"] ||= !document.createElement('canvas').getContext('webgl'); ++ console.log("disableOffscreenCanvases: " + Module["disableOffscreenCanvases"]); ++} + diff --git a/ISLE/emscripten/window.cpp b/ISLE/emscripten/window.cpp new file mode 100644 index 00000000..6766490f --- /dev/null +++ b/ISLE/emscripten/window.cpp @@ -0,0 +1,98 @@ +#include "window.h" + +#include "mxtypes.h" + +#include +#include +#include + +double g_fullWidth; +double g_fullHeight; +bool g_scaleAspect = true; +bool g_originalResolution = true; + +extern MxS32 g_targetWidth; +extern MxS32 g_targetHeight; + +void Emscripten_SetupWindow(SDL_Window* p_window) +{ + EmscriptenFullscreenStrategy strategy; + strategy.scaleMode = g_scaleAspect ? EMSCRIPTEN_FULLSCREEN_SCALE_ASPECT : EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH; + strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_HIDEF; + strategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT; + strategy.canvasResizedCallbackUserData = p_window; + strategy.canvasResizedCallback = [](int eventType, const void* reserved, void* userData) -> bool { + int width, height; + emscripten_get_canvas_element_size("canvas", &width, &height); + emscripten_get_element_css_size("#canvas", &g_fullWidth, &g_fullHeight); + + if (g_originalResolution) { + SDL_SetWindowSize((SDL_Window*) userData, g_targetWidth, g_targetHeight); + } + else { + SDL_SetWindowSize((SDL_Window*) userData, width, height); + } + + SDL_Log( + "Emscripten: window size %dx%d, canvas size %dx%d, scale aspect %s, original resolution %s", + width, + height, + (int) g_fullWidth, + (int) g_fullHeight, + g_scaleAspect ? "TRUE" : "FALSE", + g_originalResolution ? "TRUE" : "FALSE" + ); + return true; + }; + + emscripten_enter_soft_fullscreen("canvas", &strategy); +} + +void Emscripten_SetScaleAspect(bool p_scaleAspect) +{ + g_scaleAspect = p_scaleAspect; +} + +void Emscripten_SetOriginalResolution(bool p_originalResolution) +{ + g_originalResolution = p_originalResolution; +} + +void Emscripten_ConvertEventToRenderCoordinates(SDL_Event* event) +{ + if (!g_scaleAspect) { + return; + } + + switch (event->type) { + case SDL_EVENT_MOUSE_MOTION: { + const float scale = std::min(g_fullWidth / g_targetWidth, g_fullHeight / g_targetHeight); + const float widthRatio = (g_targetWidth * scale) / g_fullWidth; + const float heightRatio = (g_targetHeight * scale) / g_fullHeight; + event->motion.x = (event->motion.x - (g_targetWidth * (1.0f - widthRatio) / 2.0f)) / widthRatio; + event->motion.y = (event->motion.y - (g_targetHeight * (1.0f - heightRatio) / 2.0f)) / heightRatio; + break; + } + case SDL_EVENT_MOUSE_BUTTON_DOWN: + case SDL_EVENT_MOUSE_BUTTON_UP: { + const float scale = std::min(g_fullWidth / g_targetWidth, g_fullHeight / g_targetHeight); + const float widthRatio = (g_targetWidth * scale) / g_fullWidth; + const float heightRatio = (g_targetHeight * scale) / g_fullHeight; + event->button.x = (event->button.x - (g_targetWidth * (1.0f - widthRatio) / 2.0f)) / widthRatio; + event->button.y = (event->button.y - (g_targetHeight * (1.0f - heightRatio) / 2.0f)) / heightRatio; + break; + } + case SDL_EVENT_FINGER_MOTION: + case SDL_EVENT_FINGER_DOWN: + case SDL_EVENT_FINGER_UP: { + const float scale = std::min(g_fullWidth / g_targetWidth, g_fullHeight / g_targetHeight); + const float widthRatio = (g_targetWidth * scale) / g_fullWidth; + const float heightRatio = (g_targetHeight * scale) / g_fullHeight; + event->tfinger.x = (event->tfinger.x * g_targetWidth - (g_targetWidth * (1.0f - widthRatio) / 2.0f)) / + widthRatio / g_targetWidth; + event->tfinger.y = (event->tfinger.y * g_targetHeight - (g_targetHeight * (1.0f - heightRatio) / 2.0f)) / + heightRatio / g_targetHeight; + break; + } + } +} diff --git a/ISLE/emscripten/window.h b/ISLE/emscripten/window.h new file mode 100644 index 00000000..01b13ae4 --- /dev/null +++ b/ISLE/emscripten/window.h @@ -0,0 +1,11 @@ +#ifndef EMSCRIPTEN_WINDOW_H +#define EMSCRIPTEN_WINDOW_H + +#include + +void Emscripten_SetupWindow(SDL_Window* p_window); +void Emscripten_SetScaleAspect(bool p_scaleAspect); +void Emscripten_SetOriginalResolution(bool p_originalResolution); +void Emscripten_ConvertEventToRenderCoordinates(SDL_Event* event); + +#endif // EMSCRIPTEN_WINDOW_H diff --git a/ISLE/ios/config.cpp b/ISLE/ios/config.cpp new file mode 100644 index 00000000..ee9349fa --- /dev/null +++ b/ISLE/ios/config.cpp @@ -0,0 +1,25 @@ +#include "config.h" + +#include +#include +#include + +void IOS_SetupDefaultConfigOverrides(dictionary* p_dictionary) +{ + SDL_Log("Overriding default config for iOS"); + + // Use DevelopmentFiles path for disk and cd paths + // It's good to use that path since user can easily + // connect through SMB and copy the files + const char* documentFolder = SDL_GetUserFolder(SDL_FOLDER_DOCUMENTS); + char* diskPath = new char[strlen(documentFolder) + strlen("isle") + 1](); + strcpy(diskPath, documentFolder); + strcat(diskPath, "isle"); + + if (!SDL_GetPathInfo(diskPath, NULL)) { + SDL_CreateDirectory(diskPath); + } + + iniparser_set(p_dictionary, "isle:diskpath", diskPath); + iniparser_set(p_dictionary, "isle:cdpath", diskPath); +} diff --git a/ISLE/ios/config.h b/ISLE/ios/config.h new file mode 100644 index 00000000..53caf824 --- /dev/null +++ b/ISLE/ios/config.h @@ -0,0 +1,8 @@ +#ifndef IOS_CONFIG_H +#define IOS_CONFIG_H + +#include "dictionary.h" + +void IOS_SetupDefaultConfigOverrides(dictionary* p_dictionary); + +#endif // IOS_CONFIG_H diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 7ba7bf3e..d67f3b5d 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -37,6 +37,7 @@ #include "tgl/d3drm/impl.h" #include "viewmanager/viewmanager.h" +#include #include #define SDL_MAIN_USE_CALLBACKS @@ -48,9 +49,11 @@ #include #ifdef __EMSCRIPTEN__ +#include "emscripten/config.h" #include "emscripten/events.h" #include "emscripten/filesystem.h" #include "emscripten/messagebox.h" +#include "emscripten/window.h" #endif #ifdef __3DS__ @@ -66,6 +69,10 @@ #include #endif +#ifdef IOS +#include "ios/config.h" +#endif + DECOMP_SIZE_ASSERT(IsleApp, 0x8c) // GLOBAL: ISLE 0x410030 @@ -102,6 +109,7 @@ MxFloat g_lastJoystickMouseX = 0; MxFloat g_lastJoystickMouseY = 0; MxFloat g_lastMouseX = 320; MxFloat g_lastMouseY = 240; +MxBool g_mouseWarped = FALSE; bool g_dpadUp = false; bool g_dpadDown = false; @@ -435,10 +443,17 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) case SDL_EVENT_MOUSE_MOTION: case SDL_EVENT_MOUSE_BUTTON_DOWN: case SDL_EVENT_MOUSE_BUTTON_UP: + case SDL_EVENT_FINGER_MOTION: + case SDL_EVENT_FINGER_DOWN: + case SDL_EVENT_FINGER_UP: IDirect3DRMMiniwinDevice* device = GetD3DRMMiniwinDevice(); if (device && !device->ConvertEventToRenderCoordinates(event)) { SDL_Log("Failed to convert event coordinates: %s", SDL_GetError()); } + +#ifdef __EMSCRIPTEN__ + Emscripten_ConvertEventToRenderCoordinates(event); +#endif break; } @@ -603,6 +618,10 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) break; } case SDL_EVENT_MOUSE_MOTION: + if (g_mouseWarped) { + g_mouseWarped = FALSE; + break; + } #ifdef __EMSCRIPTEN__ if (detectedTouchEvents) { break; @@ -620,8 +639,13 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) ); } - if (g_isle->GetDrawCursor()) { - VideoManager()->MoveCursor(Min((MxS32) event->motion.x, 639), Min((MxS32) event->motion.y, 479)); + g_lastMouseX = event->motion.x; + g_lastMouseY = event->motion.y; + + SDL_ShowCursor(); + g_isle->SetDrawCursor(FALSE); + if (VideoManager()) { + VideoManager()->SetCursorBitmap(NULL); } break; case SDL_EVENT_FINGER_MOTION: { @@ -630,15 +654,20 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) #endif g_mousemoved = TRUE; - float x = SDL_clamp(event->tfinger.x, 0, 1) * 640; - float y = SDL_clamp(event->tfinger.y, 0, 1) * 480; + float x = SDL_clamp(event->tfinger.x, 0, 1) * g_targetWidth; + float y = SDL_clamp(event->tfinger.y, 0, 1) * g_targetHeight; if (InputManager()) { InputManager()->QueueEvent(c_notificationMouseMove, LegoEventNotificationParam::c_lButtonState, x, y, 0); } - if (g_isle->GetDrawCursor()) { - VideoManager()->MoveCursor(Min((MxS32) x, 639), Min((MxS32) y, 479)); + g_lastMouseX = x; + g_lastMouseY = y; + + SDL_HideCursor(); + g_isle->SetDrawCursor(FALSE); + if (VideoManager()) { + VideoManager()->SetCursorBitmap(NULL); } break; } @@ -666,12 +695,21 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) #endif g_mousedown = TRUE; - float x = SDL_clamp(event->tfinger.x, 0, 1) * 640; - float y = SDL_clamp(event->tfinger.y, 0, 1) * 480; + float x = SDL_clamp(event->tfinger.x, 0, 1) * g_targetWidth; + float y = SDL_clamp(event->tfinger.y, 0, 1) * g_targetHeight; if (InputManager()) { InputManager()->QueueEvent(c_notificationButtonDown, LegoEventNotificationParam::c_lButtonState, x, y, 0); } + + g_lastMouseX = x; + g_lastMouseY = y; + + SDL_HideCursor(); + g_isle->SetDrawCursor(FALSE); + if (VideoManager()) { + VideoManager()->SetCursorBitmap(NULL); + } break; } case SDL_EVENT_MOUSE_BUTTON_UP: @@ -704,8 +742,8 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) #endif g_mousedown = FALSE; - float x = SDL_clamp(event->tfinger.x, 0, 1) * 640; - float y = SDL_clamp(event->tfinger.y, 0, 1) * 480; + float x = SDL_clamp(event->tfinger.x, 0, 1) * g_targetWidth; + float y = SDL_clamp(event->tfinger.y, 0, 1) * g_targetHeight; if (InputManager()) { InputManager()->QueueEvent(c_notificationButtonUp, 0, x, y, 0); @@ -745,6 +783,11 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) if (!g_isle->GetGameStarted() && action && state == MxPresenter::e_ready && !SDL_strncmp(action->GetObjectName(), "Lego_Smk", 8)) { g_isle->SetGameStarted(TRUE); + +#ifdef __EMSCRIPTEN__ + Emscripten_SetupWindow((SDL_Window*) g_isle->GetWindowHandle()); +#endif + SDL_Log("Game started"); } } @@ -808,12 +851,9 @@ MxResult IsleApp::SetupWindow() m_cursorBusy = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT); m_cursorNo = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NOT_ALLOWED); SDL_SetCursor(m_cursorCurrent); - if (g_isle->GetDrawCursor()) { - SDL_HideCursor(); - m_cursorCurrentBitmap = m_cursorArrowBitmap = &arrow_cursor; - m_cursorBusyBitmap = &busy_cursor; - m_cursorNoBitmap = &no_cursor; - } + m_cursorCurrentBitmap = m_cursorArrowBitmap = &arrow_cursor; + m_cursorBusyBitmap = &busy_cursor; + m_cursorNoBitmap = &no_cursor; SDL_PropertiesID props = SDL_CreateProperties(); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, g_targetWidth); @@ -899,7 +939,7 @@ MxResult IsleApp::SetupWindow() LegoOmni::GetInstance()->GetInputManager()->SetUseJoystick(m_useJoystick); LegoOmni::GetInstance()->GetInputManager()->SetJoystickIndex(m_joystickIndex); } - if (LegoOmni::GetInstance()->GetVideoManager() && g_isle->GetDrawCursor()) { + if (LegoOmni::GetInstance()->GetVideoManager()) { LegoOmni::GetInstance()->GetVideoManager()->SetCursorBitmap(m_cursorCurrentBitmap); } MxDirect3D* d3d = LegoOmni::GetInstance()->GetVideoManager()->GetDirect3D(); @@ -923,7 +963,11 @@ MxResult IsleApp::SetupWindow() // FUNCTION: ISLE 0x4028d0 bool IsleApp::LoadConfig() { +#ifdef IOS + const char* prefPath = SDL_GetUserFolder(SDL_FOLDER_DOCUMENTS); +#else char* prefPath = SDL_GetPrefPath("isledecomp", "isle"); +#endif char* iniConfig; #ifdef __EMSCRIPTEN__ @@ -988,7 +1032,6 @@ bool IsleApp::LoadConfig() iniparser_set(dict, "isle:UseJoystick", m_useJoystick ? "true" : "false"); iniparser_set(dict, "isle:JoystickIndex", SDL_itoa(m_joystickIndex, buf, 10)); - iniparser_set(dict, "isle:Draw Cursor", m_drawCursor ? "true" : "false"); SDL_snprintf(buf, sizeof(buf), "%f", m_cursorSensitivity); iniparser_set(dict, "isle:Cursor Sensitivity", buf); @@ -1001,11 +1044,21 @@ bool IsleApp::LoadConfig() iniparser_set(dict, "isle:Max Allowed Extras", SDL_itoa(m_maxAllowedExtras, buf, 10)); iniparser_set(dict, "isle:Transition Type", SDL_itoa(m_transitionType, buf, 10)); +#ifdef EXTENSIONS + iniparser_set(dict, "extensions", NULL); + for (const char* key : Extensions::availableExtensions) { + iniparser_set(dict, key, "false"); + } +#endif + #ifdef __3DS__ N3DS_SetupDefaultConfigOverrides(dict); #endif #ifdef WINDOWS_STORE XBONE_SetupDefaultConfigOverrides(dict); +#endif +#ifdef IOS + IOS_SetupDefaultConfigOverrides(dict); #endif iniparser_dump_ini(dict, iniFP); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "New config written at '%s'", iniConfig); @@ -1013,19 +1066,15 @@ bool IsleApp::LoadConfig() } #ifdef __EMSCRIPTEN__ - const char* hdPath = Emscripten_bundledPath; -#else - const char* hdPath = iniparser_getstring(dict, "isle:diskpath", SDL_GetBasePath()); + Emscripten_SetupDefaultConfigOverrides(dict); #endif + + const char* hdPath = iniparser_getstring(dict, "isle:diskpath", SDL_GetBasePath()); m_hdPath = new char[strlen(hdPath) + 1]; strcpy(m_hdPath, hdPath); MxOmni::SetHD(m_hdPath); -#ifdef __EMSCRIPTEN__ - const char* cdPath = Emscripten_streamPath; -#else const char* cdPath = iniparser_getstring(dict, "isle:cdpath", MxOmni::GetCD()); -#endif m_cdPath = new char[strlen(cdPath) + 1]; strcpy(m_cdPath, cdPath); MxOmni::SetCD(m_cdPath); @@ -1035,19 +1084,12 @@ bool IsleApp::LoadConfig() strcpy(m_mediaPath, mediaPath); m_flipSurfaces = iniparser_getboolean(dict, "isle:Flip Surfaces", m_flipSurfaces); - -#ifdef __EMSCRIPTEN__ - m_fullScreen = FALSE; -#else m_fullScreen = iniparser_getboolean(dict, "isle:Full Screen", m_fullScreen); -#endif - m_wideViewAngle = iniparser_getboolean(dict, "isle:Wide View Angle", m_wideViewAngle); m_use3dSound = iniparser_getboolean(dict, "isle:3DSound", m_use3dSound); m_useMusic = iniparser_getboolean(dict, "isle:Music", m_useMusic); m_useJoystick = iniparser_getboolean(dict, "isle:UseJoystick", m_useJoystick); m_joystickIndex = iniparser_getint(dict, "isle:JoystickIndex", m_joystickIndex); - m_drawCursor = iniparser_getboolean(dict, "isle:Draw Cursor", m_drawCursor); m_cursorSensitivity = iniparser_getdouble(dict, "isle:Cursor Sensitivity", m_cursorSensitivity); MxS32 backBuffersInVRAM = iniparser_getboolean(dict, "isle:Back Buffers in Video RAM", -1); @@ -1081,17 +1123,27 @@ bool IsleApp::LoadConfig() // [library:config] // The original game does not save any data if no savepath is given. // Instead, we use SDLs prefPath as a default fallback and always save data. -#ifdef __EMSCRIPTEN__ - const char* savePath = Emscripten_savePath; -#else const char* savePath = iniparser_getstring(dict, "isle:savepath", prefPath); -#endif m_savePath = new char[strlen(savePath) + 1]; strcpy(m_savePath, savePath); +#ifdef EXTENSIONS + std::vector keys; + keys.resize(iniparser_getsecnkeys(dict, "extensions")); + iniparser_getseckeys(dict, "extensions", keys.data()); + + for (const char* key : keys) { + if (iniparser_getboolean(dict, key, 0)) { + Extensions::Enable(key); + } + } +#endif + iniparser_freedict(dict); delete[] iniConfig; +#ifndef IOS SDL_free(prefPath); +#endif return true; } @@ -1220,12 +1272,7 @@ void IsleApp::SetupCursor(Cursor p_cursor) } if (g_isle->GetDrawCursor()) { - if (m_cursorCurrentBitmap == NULL) { - VideoManager()->SetCursorBitmap(NULL); - } - else { - VideoManager()->SetCursorBitmap(m_cursorCurrentBitmap); - } + VideoManager()->SetCursorBitmap(m_cursorCurrentBitmap); } else { if (m_cursorCurrent != NULL) { @@ -1386,8 +1433,8 @@ void IsleApp::MoveVirtualMouseViaJoystick() if (moveX != 0 || moveY != 0) { g_mousemoved = TRUE; - g_lastMouseX = SDL_clamp(g_lastMouseX + moveX, 0, 640); - g_lastMouseY = SDL_clamp(g_lastMouseY + moveY, 0, 480); + g_lastMouseX = SDL_clamp(g_lastMouseX + moveX, 0, g_targetWidth); + g_lastMouseY = SDL_clamp(g_lastMouseY + moveY, 0, g_targetHeight); if (InputManager()) { InputManager()->QueueEvent( @@ -1399,8 +1446,18 @@ void IsleApp::MoveVirtualMouseViaJoystick() ); } - if (g_isle->GetDrawCursor()) { + SDL_HideCursor(); + g_isle->SetDrawCursor(TRUE); + if (VideoManager()) { + VideoManager()->SetCursorBitmap(m_cursorCurrentBitmap); VideoManager()->MoveCursor(Min((MxS32) g_lastMouseX, 639), Min((MxS32) g_lastMouseY, 479)); } + IDirect3DRMMiniwinDevice* device = GetD3DRMMiniwinDevice(); + if (device) { + Sint32 x, y; + device->ConvertRenderToWindowCoordinates(g_lastMouseX, g_lastMouseY, x, y); + g_mouseWarped = TRUE; + SDL_WarpMouseInWindow(window, x, y); + } } } diff --git a/ISLE/isleapp.h b/ISLE/isleapp.h index 70445d05..7054f6d1 100644 --- a/ISLE/isleapp.h +++ b/ISLE/isleapp.h @@ -56,6 +56,7 @@ class IsleApp { void SetWindowActive(MxS32 p_windowActive) { m_windowActive = p_windowActive; } void SetGameStarted(MxS32 p_gameStarted) { m_gameStarted = p_gameStarted; } + void SetDrawCursor(MxS32 p_drawCursor) { m_drawCursor = p_drawCursor; } MxResult ParseArguments(int argc, char** argv); MxResult VerifyFilesystem(); diff --git a/LEGO1/lego/legoomni/include/act3ammo.h b/LEGO1/lego/legoomni/include/act3ammo.h index ee4e3dc1..e80aa6b0 100644 --- a/LEGO1/lego/legoomni/include/act3ammo.h +++ b/LEGO1/lego/legoomni/include/act3ammo.h @@ -90,7 +90,7 @@ class Act3Ammo : public LegoPathActor { // Act3Ammo::`scalar deleting destructor' private: - MxResult FUN_10053db0(float p_param1, const Matrix4& p_param2); + MxResult FUN_10053db0(float p_param1, Matrix4& p_param2); static Mx3DPointFloat g_unk0x10104f08; diff --git a/LEGO1/lego/legoomni/include/infocenter.h b/LEGO1/lego/legoomni/include/infocenter.h index 470bdc31..aa0befd1 100644 --- a/LEGO1/lego/legoomni/include/infocenter.h +++ b/LEGO1/lego/legoomni/include/infocenter.h @@ -78,10 +78,20 @@ class InfocenterState : public LegoState { // SIZE 0x18 struct InfocenterMapEntry { + enum { + e_infocenter = 3, + e_jetrace = 10, + e_carrace = 11, + e_pizzeria = 12, + e_garage = 13, + e_hospital = 14, + e_police = 15, + }; + InfocenterMapEntry(); MxStillPresenter* m_destCtl; // 0x00 - undefined4 m_unk0x04; // 0x04 + MxU32 m_target; // 0x04 MxRect m_area; // 0x08 }; @@ -154,7 +164,7 @@ class Infocenter : public LegoWorld { void PlayCutscene(Cutscene p_entityId, MxBool p_scale); void StopCutscene(); - void FUN_10070d10(MxS32 p_x, MxS32 p_y); + void UpdateEnabledGlowControl(MxS32 p_x, MxS32 p_y); void StartCredits(); void StopCredits(); @@ -173,12 +183,12 @@ class Infocenter : public LegoWorld { Radio m_radio; // 0x10c MxStillPresenter* m_dragPresenter; // 0x11c InfocenterMapEntry m_glowInfo[7]; // 0x120 - MxS16 m_unk0x1c8; // 0x1c8 + MxS16 m_enabledGlowControl; // 0x1c8 MxStillPresenter* m_frame; // 0x1cc MxS16 m_infoManDialogueTimer; // 0x1d0 MxS16 m_bookAnimationTimer; // 0x1d2 - MxU16 m_unk0x1d4; // 0x1d4 - MxS16 m_unk0x1d6; // 0x1d6 + MxU16 m_playingMovieCounter; // 0x1d4 + MxS16 m_bigInfoBlinkTimer; // 0x1d6 }; #endif // INFOCENTER_H diff --git a/LEGO1/lego/legoomni/include/legopathboundary.h b/LEGO1/lego/legoomni/include/legopathboundary.h index 05d0487c..2bc304f0 100644 --- a/LEGO1/lego/legoomni/include/legopathboundary.h +++ b/LEGO1/lego/legoomni/include/legopathboundary.h @@ -75,7 +75,7 @@ class LegoPathBoundary : public LegoWEGEdge { // _Tree >::_Kfn,LegoPathActorSetCompare,allocator >::erase // TEMPLATE: LEGO1 0x1002c440 -// TEMPLATE: BETA10 0x100b6480 +// TEMPLATE: BETA10 0x10020480 // _Tree >::_Kfn,LegoPathActorSetCompare,allocator >::find // TEMPLATE: LEGO1 0x1002c4c0 @@ -190,6 +190,12 @@ class LegoPathBoundary : public LegoWEGEdge { // TEMPLATE: BETA10 0x10082b40 // _Tree >::_Kfn,LegoAnimPresenterSetCompare,allocator >::const_iterator::operator* +// TEMPLATE: BETA10 0x100b6440 +// set >::find + +// TEMPLATE: BETA10 0x100b6480 +// _Tree >::_Kfn,LegoAnimPresenterSetCompare,allocator >::find + // TEMPLATE: BETA10 0x10021dc0 // ??0?$Set@PAVLegoPathActor@@ULegoPathActorSetCompare@@@@QAE@ABV0@@Z diff --git a/LEGO1/lego/legoomni/include/legoutils.h b/LEGO1/lego/legoomni/include/legoutils.h index 3862465f..2df6ad4a 100644 --- a/LEGO1/lego/legoomni/include/legoutils.h +++ b/LEGO1/lego/legoomni/include/legoutils.h @@ -49,28 +49,28 @@ LegoROI* PickROI(MxLong p_x, MxLong p_y); LegoROI* PickRootROI(MxLong p_x, MxLong p_y); void RotateY(LegoROI* p_roi, MxFloat p_angle); MxBool SpheresIntersect(const BoundingSphere& p_sphere1, const BoundingSphere& p_sphere2); -MxBool FUN_1003ded0(MxFloat p_param1[2], MxFloat p_param2[3], MxFloat p_param3[3]); +MxBool CalculateRayOriginDirection(MxFloat p_coordinates[2], MxFloat p_direction[3], MxFloat p_origin[3]); MxBool TransformWorldToScreen(const MxFloat p_world[3], MxFloat p_screen[4]); MxS16 CountTotalTreeNodes(LegoTreeNode* p_node); LegoTreeNode* GetTreeNode(LegoTreeNode* p_node, MxU32 p_index); -void FUN_1003e050(LegoAnimPresenter* p_presenter); +void CalculateViewFromAnimation(LegoAnimPresenter* p_presenter); Extra::ActionType MatchActionString(const char*); void InvokeAction(Extra::ActionType p_actionId, const MxAtomId& p_pAtom, MxS32 p_streamId, LegoEntity* p_sender); void SetCameraControllerFromIsle(); void ConvertHSVToRGB(float p_h, float p_s, float p_v, float* p_rOut, float* p_bOut, float* p_gOut); void PlayCamAnim(LegoPathActor* p_actor, MxBool p_unused, MxU32 p_location, MxBool p_bool); -void FUN_1003eda0(); +void ResetViewVelocity(); MxBool RemoveFromCurrentWorld(const MxAtomId& p_atomId, MxS32 p_id); void EnableAnimations(MxBool p_enable); void SetAppCursor(Cursor p_cursor); -MxBool FUN_1003ef60(); +MxBool CanExit(); MxBool RemoveFromWorld(MxAtomId& p_entityAtom, MxS32 p_entityId, MxAtomId& p_worldAtom, MxS32 p_worldEntityId); MxS32 UpdateLightPosition(MxS32 p_increase); void SetLightPosition(MxS32 p_index); LegoNamedTexture* ReadNamedTexture(LegoStorage* p_storage); void WriteDefaultTexture(LegoStorage* p_storage, const char* p_name); void WriteNamedTexture(LegoStorage* p_storage, LegoNamedTexture* p_namedTexture); -void FUN_1003f930(LegoNamedTexture* p_namedTexture); +void LoadFromNamedTexture(LegoNamedTexture* p_namedTexture); // FUNCTION: BETA10 0x100260a0 inline void StartIsleAction(IsleScript::Script p_objectId) diff --git a/LEGO1/lego/legoomni/src/actors/act3ammo.cpp b/LEGO1/lego/legoomni/src/actors/act3ammo.cpp index d88a7bee..4ab1a27b 100644 --- a/LEGO1/lego/legoomni/src/actors/act3ammo.cpp +++ b/LEGO1/lego/legoomni/src/actors/act3ammo.cpp @@ -200,7 +200,7 @@ MxResult Act3Ammo::FUN_10053d30(LegoPathController* p_p, MxFloat p_unk0x19c) // FUNCTION: LEGO1 0x10053db0 // FUNCTION: BETA10 0x1001e0f0 -MxResult Act3Ammo::FUN_10053db0(float p_param1, const Matrix4& p_param2) +MxResult Act3Ammo::FUN_10053db0(float p_param1, Matrix4& p_param2) { float local34 = p_param1 * p_param1; @@ -384,6 +384,8 @@ void Act3Ammo::Animate(float p_time) m_world->RemoveDonut(*this); m_world->TriggerHitSound(4); } + + return; } else { if (IsPizza()) { @@ -394,89 +396,99 @@ void Act3Ammo::Animate(float p_time) assert(SoundManager()->GetCacheSoundManager()); SoundManager()->GetCacheSoundManager()->Play("stickdn", NULL, FALSE); } + } - LegoPathActorSet& plpas = m_boundary->GetActors(); - LegoPathActorSet lpas(plpas); + LegoPathActorSet& plpas = m_boundary->GetActors(); + LegoPathActorSet lpas(plpas); - for (LegoPathActorSet::iterator itpa = lpas.begin(); itpa != lpas.end(); itpa++) { - if (plpas.find(*itpa) != plpas.end() && this != *itpa) { - LegoROI* r = (*itpa)->GetROI(); - assert(r); + for (LegoPathActorSet::iterator itpa = lpas.begin(); itpa != lpas.end(); itpa++) { + if (plpas.find(*itpa) == plpas.end()) { + continue; + } - if (!strncmp(r->GetName(), "pammo", 5)) { - Mx3DPointFloat local1c8; - Mx3DPointFloat local1b4; + if (this == *itpa) { + continue; + } - local1c8 = r->GetLocal2World()[3]; - local1b4 = m_roi->GetLocal2World()[3]; + LegoROI* r = (*itpa)->GetROI(); + assert(r); - local1b4 -= local1c8; + if (!strncmp(r->GetName(), "pammo", 5)) { + Mx3DPointFloat local1c8; + Mx3DPointFloat local1b4; - float radius = r->GetWorldBoundingSphere().Radius(); - if (local1b4.LenSquared() <= radius * radius) { - MxS32 index = -1; - if (sscanf(r->GetName(), "pammo%d", &index) != 1) { - assert(0); - } + local1c8 = r->GetLocal2World()[3]; + local1b4 = m_roi->GetLocal2World()[3]; - assert(m_world); + local1b4 -= local1c8; - if (m_world->m_pizzas[index].IsValid() && !m_world->m_pizzas[index].IsSharkFood()) { - m_world->EatPizza(index); - m_world->m_brickster->FUN_100417c0(); - } - - if (IsDonut()) { - assert(SoundManager()->GetCacheSoundManager()); - SoundManager()->GetCacheSoundManager()->Play("dnhitpz", NULL, FALSE); - m_world->RemoveDonut(*this); - local14 = TRUE; - break; - } - } + float radius = r->GetWorldBoundingSphere().Radius(); + if (local1b4.LenSquared() <= radius * radius) { + MxS32 index = -1; + if (sscanf(r->GetName(), "pammo%d", &index) != 1) { + assert(0); } - else if (!strncmp(r->GetName(), "dammo", 5)) { - Mx3DPointFloat local1f8; - Mx3DPointFloat local1e4; - local1f8 = r->GetLocal2World()[3]; - local1e4 = m_roi->GetLocal2World()[3]; + assert(m_world); - local1e4 -= local1f8; +#ifdef BETA10 + m_world->EatPizza(index); +#else + if (m_world->m_pizzas[index].IsValid() && !m_world->m_pizzas[index].IsSharkFood()) { + m_world->EatPizza(index); + m_world->m_brickster->FUN_100417c0(); + } +#endif - float radius = r->GetWorldBoundingSphere().Radius(); - if (local1e4.LenSquared() <= radius * radius) { - MxS32 index = -1; - if (sscanf(r->GetName(), "dammo%d", &index) != 1) { - assert(0); - } - - assert(m_world); - - m_world->EatDonut(index); - - if (IsPizza()) { - assert(SoundManager()->GetCacheSoundManager()); - SoundManager()->GetCacheSoundManager()->Play("pzhitdn", NULL, FALSE); - m_world->RemovePizza(*this); - local14 = TRUE; - break; - } - } + if (IsDonut()) { + assert(SoundManager()->GetCacheSoundManager()); + SoundManager()->GetCacheSoundManager()->Play("dnhitpz", NULL, FALSE); + m_world->RemoveDonut(*this); + local14 = TRUE; + break; } } } + else if (!strncmp(r->GetName(), "dammo", 5)) { + Mx3DPointFloat local1f8; + Mx3DPointFloat local1e4; - if (!local14) { - if (IsPizza()) { - m_world->FUN_10073360(*this, local68); - } - else { - m_world->FUN_10073390(*this, local68); - } + local1f8 = r->GetLocal2World()[3]; + local1e4 = m_roi->GetLocal2World()[3]; - m_worldSpeed = -1.0f; + local1e4 -= local1f8; + + float radius = r->GetWorldBoundingSphere().Radius(); + if (local1e4.LenSquared() <= radius * radius) { + MxS32 index = -1; + if (sscanf(r->GetName(), "dammo%d", &index) != 1) { + assert(0); + } + + assert(m_world); + + m_world->EatDonut(index); + + if (IsPizza()) { + assert(SoundManager()->GetCacheSoundManager()); + SoundManager()->GetCacheSoundManager()->Play("pzhitdn", NULL, FALSE); + m_world->RemovePizza(*this); + local14 = TRUE; + break; + } + } } } + + if (!local14) { + if (IsPizza()) { + m_world->FUN_10073360(*this, local68); + } + else { + m_world->FUN_10073390(*this, local68); + } + + m_worldSpeed = -1.0f; + } } } diff --git a/LEGO1/lego/legoomni/src/actors/bike.cpp b/LEGO1/lego/legoomni/src/actors/bike.cpp index 0d480ad0..6c82cb0d 100644 --- a/LEGO1/lego/legoomni/src/actors/bike.cpp +++ b/LEGO1/lego/legoomni/src/actors/bike.cpp @@ -52,7 +52,7 @@ void Bike::Exit() // FUNCTION: LEGO1 0x100769a0 MxLong Bike::HandleClick() { - if (FUN_1003ef60()) { + if (CanExit()) { Act1State* state = (Act1State*) GameState()->GetState("Act1State"); FUN_10015820(TRUE, 0); diff --git a/LEGO1/lego/legoomni/src/actors/buildings.cpp b/LEGO1/lego/legoomni/src/actors/buildings.cpp index ea7069cc..833287bc 100644 --- a/LEGO1/lego/legoomni/src/actors/buildings.cpp +++ b/LEGO1/lego/legoomni/src/actors/buildings.cpp @@ -80,7 +80,7 @@ MxLong InfoCenterEntity::HandleClick(LegoEventNotificationParam& p_param) // FUNCTION: LEGO1 0x100151d0 MxLong GasStationEntity::HandleClick(LegoEventNotificationParam& p_param) { - if (FUN_1003ef60()) { + if (CanExit()) { Act1State* state = (Act1State*) GameState()->GetState("Act1State"); if (state->GetUnknown18() != 8) { @@ -104,7 +104,7 @@ MxLong GasStationEntity::HandleClick(LegoEventNotificationParam& p_param) // FUNCTION: LEGO1 0x10015270 MxLong HospitalEntity::HandleClick(LegoEventNotificationParam& p_param) { - if (FUN_1003ef60()) { + if (CanExit()) { Act1State* act1State = (Act1State*) GameState()->GetState("Act1State"); if (act1State->GetUnknown18() != 10) { @@ -128,7 +128,7 @@ MxLong HospitalEntity::HandleClick(LegoEventNotificationParam& p_param) // FUNCTION: LEGO1 0x10015310 MxLong PoliceEntity::HandleClick(LegoEventNotificationParam& p_param) { - if (FUN_1003ef60()) { + if (CanExit()) { Act1State* state = (Act1State*) GameState()->GetState("Act1State"); if (state->GetUnknown18() != 10) { @@ -152,7 +152,7 @@ MxLong PoliceEntity::HandleClick(LegoEventNotificationParam& p_param) // FUNCTION: LEGO1 0x100153b0 MxLong BeachHouseEntity::HandleClick(LegoEventNotificationParam& p_param) { - if (FUN_1003ef60()) { + if (CanExit()) { Act1State* state = (Act1State*) GameState()->GetState("Act1State"); state->SetUnknown18(0); @@ -173,7 +173,7 @@ MxLong BeachHouseEntity::HandleClick(LegoEventNotificationParam& p_param) // FUNCTION: LEGO1 0x10015450 MxLong RaceStandsEntity::HandleClick(LegoEventNotificationParam& p_param) { - if (FUN_1003ef60()) { + if (CanExit()) { Act1State* state = (Act1State*) GameState()->GetState("Act1State"); state->SetUnknown18(0); @@ -195,7 +195,7 @@ MxLong RaceStandsEntity::HandleClick(LegoEventNotificationParam& p_param) // FUNCTION: BETA10 0x100256e8 MxLong JailEntity::HandleClick(LegoEventNotificationParam& p_param) { - if (FUN_1003ef60()) { + if (CanExit()) { PlayCamAnim(UserActor(), FALSE, 18, TRUE); } diff --git a/LEGO1/lego/legoomni/src/actors/dunebuggy.cpp b/LEGO1/lego/legoomni/src/actors/dunebuggy.cpp index 049c7f86..59bac080 100644 --- a/LEGO1/lego/legoomni/src/actors/dunebuggy.cpp +++ b/LEGO1/lego/legoomni/src/actors/dunebuggy.cpp @@ -91,7 +91,7 @@ void DuneBuggy::Exit() // FUNCTION: LEGO1 0x10068060 MxLong DuneBuggy::HandleClick() { - if (!FUN_1003ef60()) { + if (!CanExit()) { return 1; } diff --git a/LEGO1/lego/legoomni/src/actors/helicopter.cpp b/LEGO1/lego/legoomni/src/actors/helicopter.cpp index bf9eb9d0..c8c465f7 100644 --- a/LEGO1/lego/legoomni/src/actors/helicopter.cpp +++ b/LEGO1/lego/legoomni/src/actors/helicopter.cpp @@ -121,7 +121,7 @@ void Helicopter::Exit() // FUNCTION: BETA10 0x1002a3db MxLong Helicopter::HandleClick() { - if (!FUN_1003ef60()) { + if (!CanExit()) { return 1; } diff --git a/LEGO1/lego/legoomni/src/actors/islepathactor.cpp b/LEGO1/lego/legoomni/src/actors/islepathactor.cpp index fbd57206..9d5a3a22 100644 --- a/LEGO1/lego/legoomni/src/actors/islepathactor.cpp +++ b/LEGO1/lego/legoomni/src/actors/islepathactor.cpp @@ -153,7 +153,7 @@ void IslePathActor::Exit() FUN_1001b660(); FUN_10010c30(); - FUN_1003eda0(); + ResetViewVelocity(); } // GLOBAL: LEGO1 0x10102b28 @@ -598,7 +598,7 @@ void IslePathActor::SpawnPlayer(LegoGameState::Area p_area, MxBool p_enter, MxU8 } if (m_cameraFlag) { - FUN_1003eda0(); + ResetViewVelocity(); } if (p_flags & c_playMusic && g_spawnLocations[i].m_music != JukeboxScript::c_noneJukebox) { @@ -632,7 +632,7 @@ void IslePathActor::VTable0xec(MxMatrix p_transform, LegoPathBoundary* p_boundar m_roi->SetLocal2World(p_transform); if (m_cameraFlag) { - FUN_1003eda0(); + ResetViewVelocity(); FUN_10010c30(); } } diff --git a/LEGO1/lego/legoomni/src/actors/jetski.cpp b/LEGO1/lego/legoomni/src/actors/jetski.cpp index 2c57c76e..2ef3a547 100644 --- a/LEGO1/lego/legoomni/src/actors/jetski.cpp +++ b/LEGO1/lego/legoomni/src/actors/jetski.cpp @@ -83,7 +83,7 @@ void Jetski::Exit() MxLong Jetski::HandleClick() { #ifndef BETA10 - if (!FUN_1003ef60()) { + if (!CanExit()) { return 1; } diff --git a/LEGO1/lego/legoomni/src/actors/jukeboxentity.cpp b/LEGO1/lego/legoomni/src/actors/jukeboxentity.cpp index ecf0bec8..c92aec79 100644 --- a/LEGO1/lego/legoomni/src/actors/jukeboxentity.cpp +++ b/LEGO1/lego/legoomni/src/actors/jukeboxentity.cpp @@ -36,7 +36,7 @@ MxLong JukeBoxEntity::Notify(MxParam& p_param) MxNotificationParam& param = (MxNotificationParam&) p_param; if (param.GetNotification() == c_notificationClick) { - if (!FUN_1003ef60()) { + if (!CanExit()) { return 1; } diff --git a/LEGO1/lego/legoomni/src/actors/motorcycle.cpp b/LEGO1/lego/legoomni/src/actors/motorcycle.cpp index 6a20d6f3..eaaa90be 100644 --- a/LEGO1/lego/legoomni/src/actors/motorcycle.cpp +++ b/LEGO1/lego/legoomni/src/actors/motorcycle.cpp @@ -86,7 +86,7 @@ void Motocycle::Exit() // FUNCTION: LEGO1 0x10035c50 MxLong Motocycle::HandleClick() { - if (!FUN_1003ef60()) { + if (!CanExit()) { return 1; } diff --git a/LEGO1/lego/legoomni/src/actors/pizzeria.cpp b/LEGO1/lego/legoomni/src/actors/pizzeria.cpp index a040f337..3b5f8923 100644 --- a/LEGO1/lego/legoomni/src/actors/pizzeria.cpp +++ b/LEGO1/lego/legoomni/src/actors/pizzeria.cpp @@ -69,7 +69,7 @@ void Pizzeria::CreateState() // FUNCTION: BETA10 0x100efc91 MxLong Pizzeria::HandleClick() { - if (FUN_1003ef60() && m_pizzaMissionState->m_unk0x0c == 0) { + if (CanExit() && m_pizzaMissionState->m_unk0x0c == 0) { if (UserActor()->GetActorId() != GameState()->GetActorId()) { if (!UserActor()->IsA("SkateBoard")) { ((IslePathActor*) UserActor())->Exit(); diff --git a/LEGO1/lego/legoomni/src/actors/racecar.cpp b/LEGO1/lego/legoomni/src/actors/racecar.cpp index f511f524..ff9eb293 100644 --- a/LEGO1/lego/legoomni/src/actors/racecar.cpp +++ b/LEGO1/lego/legoomni/src/actors/racecar.cpp @@ -40,7 +40,7 @@ MxResult RaceCar::Create(MxDSAction& p_dsAction) // FUNCTION: LEGO1 0x100284d0 MxLong RaceCar::HandleClick() { - if (!FUN_1003ef60()) { + if (!CanExit()) { return 1; } diff --git a/LEGO1/lego/legoomni/src/actors/skateboard.cpp b/LEGO1/lego/legoomni/src/actors/skateboard.cpp index 18d2810d..0998ba58 100644 --- a/LEGO1/lego/legoomni/src/actors/skateboard.cpp +++ b/LEGO1/lego/legoomni/src/actors/skateboard.cpp @@ -75,7 +75,7 @@ MxLong SkateBoard::HandleClick() { Act1State* state = (Act1State*) GameState()->GetState("Act1State"); - if (!FUN_1003ef60() && state->m_unk0x018 != 3) { + if (!CanExit() && state->m_unk0x018 != 3) { return 1; } diff --git a/LEGO1/lego/legoomni/src/build/legocarbuild.cpp b/LEGO1/lego/legoomni/src/build/legocarbuild.cpp index 9b983b82..124442e0 100644 --- a/LEGO1/lego/legoomni/src/build/legocarbuild.cpp +++ b/LEGO1/lego/legoomni/src/build/legocarbuild.cpp @@ -374,7 +374,7 @@ void LegoCarBuild::FUN_10023130(MxLong p_x, MxLong p_y) pfVar3[0] = p_x; pfVar3[1] = p_y; - if (FUN_1003ded0(pfVar3, local30, local84)) { + if (CalculateRayOriginDirection(pfVar3, local30, local84)) { MxFloat local18[3]; MxFloat local8c[2]; @@ -424,7 +424,7 @@ void LegoCarBuild::VTable0x74(MxFloat p_param1[2], MxFloat p_param2[3]) MxFloat local20[3]; MxFloat local14[3]; - FUN_1003ded0(p_param1, local14, local20); + CalculateRayOriginDirection(p_param1, local14, local20); fVar1 = (m_unk0x2a4[2] - local20[2]) / local14[2]; p_param2[0] = (fVar1 * local14[0] + local20[0]) - m_unk0x2a4[0]; @@ -440,7 +440,7 @@ void LegoCarBuild::VTable0x78(MxFloat p_param1[2], MxFloat p_param2[3]) MxFloat local18[3]; MxFloat localc[3]; - FUN_1003ded0(p_param1, local18, localc); + CalculateRayOriginDirection(p_param1, local18, localc); p_param2[2] = m_unk0x2a4[2] + (m_unk0x2bc[2] - m_unk0x2a4[2]) * ((p_param1[1] - m_unk0x290[1]) / (m_unk0x298[1] - m_unk0x290[1])); @@ -456,7 +456,7 @@ void LegoCarBuild::VTable0x7c(MxFloat p_param1[2], MxFloat p_param2[3]) { MxFloat local18[3]; MxFloat localc[3]; - FUN_1003ded0(p_param1, local18, localc); + CalculateRayOriginDirection(p_param1, local18, localc); MxFloat fVar1 = (m_unk0x2bc[1] - localc[1]) / local18[1]; p_param2[0] = fVar1 * local18[0] - m_unk0x2a4[0] + localc[0]; @@ -1252,7 +1252,7 @@ undefined4 LegoCarBuild::FUN_10024c20(MxNotificationParam* p_param) // FUNCTION: LEGO1 0x10024ef0 void LegoCarBuild::FUN_10024ef0() { - FUN_1003eda0(); + ResetViewVelocity(); m_buildState->m_animationState = LegoVehicleBuildState::e_cutscene; FUN_10025720(FUN_10025d70()); m_buildState->m_unk0x4c += 1; diff --git a/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp b/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp index eb639d84..a0be25b7 100644 --- a/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp +++ b/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp @@ -1,5 +1,6 @@ #include "legotextureinfo.h" +#include "extensions/textureloader.h" #include "legovideomanager.h" #include "misc.h" #include "misc/legoimage.h" @@ -9,6 +10,8 @@ DECOMP_SIZE_ASSERT(LegoTextureInfo, 0x10) +using namespace Extensions; + // FUNCTION: LEGO1 0x10065bf0 LegoTextureInfo::LegoTextureInfo() { @@ -56,6 +59,10 @@ LegoTextureInfo* LegoTextureInfo::Create(const char* p_name, LegoTexture* p_text strcpy(textureInfo->m_name, p_name); } + if (Extension::Call(PatchTexture, textureInfo).value_or(false)) { + return textureInfo; + } + LPDIRECTDRAW pDirectDraw = VideoManager()->GetDirect3D()->DirectDraw(); LegoImage* image = p_texture->GetImage(); diff --git a/LEGO1/lego/legoomni/src/common/legoutils.cpp b/LEGO1/lego/legoomni/src/common/legoutils.cpp index a2ffbe5e..ff45676b 100644 --- a/LEGO1/lego/legoomni/src/common/legoutils.cpp +++ b/LEGO1/lego/legoomni/src/common/legoutils.cpp @@ -102,29 +102,29 @@ MxBool SpheresIntersect(const BoundingSphere& p_sphere1, const BoundingSphere& p // FUNCTION: LEGO1 0x1003ded0 // FUNCTION: BETA10 0x100d3802 -MxBool FUN_1003ded0(MxFloat p_param1[2], MxFloat p_param2[3], MxFloat p_param3[3]) +MxBool CalculateRayOriginDirection(MxFloat p_coordinates[2], MxFloat p_direction[3], MxFloat p_origin[3]) { - MxFloat local1c[4]; - MxFloat local10[3]; + MxFloat screenPoint[4]; + MxFloat farPoint[3]; Tgl::View* view = VideoManager()->Get3DManager()->GetLego3DView()->GetView(); - local1c[0] = p_param1[0]; - local1c[1] = p_param1[1]; - local1c[2] = 1.0f; - local1c[3] = 1.0f; + screenPoint[0] = p_coordinates[0]; + screenPoint[1] = p_coordinates[1]; + screenPoint[2] = 1.0f; + screenPoint[3] = 1.0f; - view->TransformScreenToWorld(local1c, p_param3); + view->TransformScreenToWorld(screenPoint, p_origin); - local1c[0] *= 2.0; - local1c[1] *= 2.0; - local1c[3] = 2.0; + screenPoint[0] *= 2.0; + screenPoint[1] *= 2.0; + screenPoint[3] = 2.0; - view->TransformScreenToWorld(local1c, local10); + view->TransformScreenToWorld(screenPoint, farPoint); - p_param2[0] = local10[0] - p_param3[0]; - p_param2[1] = local10[1] - p_param3[1]; - p_param2[2] = local10[2] - p_param3[2]; + p_direction[0] = farPoint[0] - p_origin[0]; + p_direction[1] = farPoint[1] - p_origin[1]; + p_direction[2] = farPoint[2] - p_origin[2]; return TRUE; } @@ -176,7 +176,7 @@ LegoTreeNode* GetTreeNode(LegoTreeNode* p_node, MxU32 p_index) // FUNCTION: LEGO1 0x1003e050 // FUNCTION: BETA10 0x100d3abc -void FUN_1003e050(LegoAnimPresenter* p_presenter) +void CalculateViewFromAnimation(LegoAnimPresenter* p_presenter) { MxMatrix viewMatrix; LegoTreeNode* rootNode = p_presenter->GetAnimation()->GetRoot(); @@ -184,7 +184,7 @@ void FUN_1003e050(LegoAnimPresenter* p_presenter) LegoAnimNodeData* targetData = NULL; MxS16 nodesCount = CountTotalTreeNodes(rootNode); - MxFloat cam; + MxFloat fov; for (MxS16 i = 0; i < nodesCount; i++) { if (camData && targetData) { break; @@ -194,7 +194,7 @@ void FUN_1003e050(LegoAnimPresenter* p_presenter) if (!SDL_strncasecmp(data->GetName(), "CAM", strlen("CAM"))) { camData = data; - cam = atof(&data->GetName()[strlen(data->GetName()) - 2]); + fov = atof(&data->GetName()[strlen(data->GetName()) - 2]); } else if (!SDL_strcasecmp(data->GetName(), "TARGET")) { targetData = data; @@ -223,8 +223,8 @@ void FUN_1003e050(LegoAnimPresenter* p_presenter) roi->WrappedSetLocal2WorldWithWorldDataUpdate(viewMatrix); view->Moved(*roi); - FUN_1003eda0(); - video->Get3DManager()->SetFrustrum(cam, 0.1, 250.0); + ResetViewVelocity(); + video->Get3DManager()->SetFrustrum(fov, 0.1, 250.0); } // FUNCTION: LEGO1 0x1003e300 @@ -477,7 +477,7 @@ void PlayCamAnim(LegoPathActor* p_actor, MxBool p_unused, MxU32 p_location, MxBo // FUNCTION: LEGO1 0x1003eda0 // FUNCTION: BETA10 0x100d4bf4 -void FUN_1003eda0() +void ResetViewVelocity() { Mx3DPointFloat vec; vec.Clear(); @@ -577,7 +577,7 @@ void SetAppCursor(Cursor p_cursor) } // FUNCTION: LEGO1 0x1003ef60 -MxBool FUN_1003ef60() +MxBool CanExit() { Act1State* act1State = (Act1State*) GameState()->GetState("Act1State"); @@ -774,7 +774,7 @@ void WriteNamedTexture(LegoStorage* p_storage, LegoNamedTexture* p_namedTexture) } // FUNCTION: LEGO1 0x1003f930 -void FUN_1003f930(LegoNamedTexture* p_namedTexture) +void LoadFromNamedTexture(LegoNamedTexture* p_namedTexture) { LegoTextureInfo* textureInfo = TextureContainer()->Get(p_namedTexture->GetName()->GetData()); diff --git a/LEGO1/lego/legoomni/src/entity/legoworld.cpp b/LEGO1/lego/legoomni/src/entity/legoworld.cpp index 37fce2bd..b638f1e3 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworld.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworld.cpp @@ -426,7 +426,7 @@ void LegoWorld::Add(MxCore* p_object) #ifndef BETA10 if (p_object->IsA("LegoAnimPresenter")) { if (!SDL_strcasecmp(((LegoAnimPresenter*) p_object)->GetAction()->GetObjectName(), "ConfigAnimation")) { - FUN_1003e050((LegoAnimPresenter*) p_object); + CalculateViewFromAnimation((LegoAnimPresenter*) p_object); ((LegoAnimPresenter*) p_object) ->GetAction() ->SetDuration(((LegoAnimPresenter*) p_object)->GetAnimation()->GetDuration()); diff --git a/LEGO1/lego/legoomni/src/race/legoracers.cpp b/LEGO1/lego/legoomni/src/race/legoracers.cpp index 4aeaced0..74fd9f9a 100644 --- a/LEGO1/lego/legoomni/src/race/legoracers.cpp +++ b/LEGO1/lego/legoomni/src/race/legoracers.cpp @@ -59,7 +59,7 @@ EdgeReference g_skBMap[] = { // GLOBAL: LEGO1 0x100f0a50 // GLOBAL: BETA10 0x101f5e60 -const SkeletonKickPhase g_skeletonKickPhases[] = { +SkeletonKickPhase g_skeletonKickPhases[] = { {&g_skBMap[0], 0.1, 0.2, LEGORACECAR_KICK2}, {&g_skBMap[1], 0.2, 0.3, LEGORACECAR_KICK2}, {&g_skBMap[2], 0.3, 0.4, LEGORACECAR_KICK2}, diff --git a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp index aa13fb33..a350199b 100644 --- a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp @@ -138,14 +138,14 @@ Infocenter::Infocenter() memset(&m_glowInfo, 0, sizeof(m_glowInfo)); - m_unk0x1c8 = -1; + m_enabledGlowControl = -1; SetAppCursor(e_cursorBusy); NotificationManager()->Register(this); m_infoManDialogueTimer = 0; m_bookAnimationTimer = 0; - m_unk0x1d4 = 0; - m_unk0x1d6 = 0; + m_playingMovieCounter = 0; + m_bigInfoBlinkTimer = 0; } // FUNCTION: LEGO1 0x1006ec80 @@ -300,11 +300,11 @@ MxLong Infocenter::HandleEndAction(MxEndActionNotificationParam& p_param) action->GetObjectId() == InfomainScript::c_Pepper_All_Movie || action->GetObjectId() == InfomainScript::c_Nick_All_Movie || action->GetObjectId() == InfomainScript::c_Laura_All_Movie)) { - if (m_unk0x1d4) { - m_unk0x1d4--; + if (m_playingMovieCounter) { + m_playingMovieCounter--; } - if (!m_unk0x1d4) { + if (!m_playingMovieCounter) { PlayMusic(JukeboxScript::c_InformationCenter_Music); if (!Lego()->IsVersion10()) { @@ -343,7 +343,7 @@ MxLong Infocenter::HandleEndAction(MxEndActionNotificationParam& p_param) if (action->GetObjectId() == InfomainScript::c_iicx26in_RunAnim - Lego()->IsVersion10()) { ControlManager()->UpdateEnabledChild(InfomainScript::c_BigInfo_Ctl, action->GetAtomId().GetInternal(), 0); - m_unk0x1d6 = 0; + m_bigInfoBlinkTimer = 0; } switch (m_infocenterState->m_unk0x74) { @@ -448,8 +448,8 @@ void Infocenter::ReadyWorld() { m_infoManDialogueTimer = 0; m_bookAnimationTimer = 0; - m_unk0x1d4 = 0; - m_unk0x1d6 = 0; + m_playingMovieCounter = 0; + m_bigInfoBlinkTimer = 0; MxStillPresenter* bg = (MxStillPresenter*) Find("MxStillPresenter", "Background_Bitmap"); MxStillPresenter* bgRed = (MxStillPresenter*) Find("MxStillPresenter", "BackgroundRed_Bitmap"); @@ -481,8 +481,8 @@ void Infocenter::ReadyWorld() InfomainScript::Script script = m_infocenterState->GetNextReturnDialogue(); PlayAction(script); - if (script == InfomainScript::c_iicx26in_RunAnim - Lego()->IsVersion10()) { - m_unk0x1d6 = 1; + if (script == InfomainScript::c_iicx26in_RunAnim - Lego()->IsVersion10()) { // want to get back? Click on I! + m_bigInfoBlinkTimer = 1; } FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen); @@ -638,37 +638,37 @@ void Infocenter::InitializeBitmaps() m_glowInfo[0].m_destCtl = (MxStillPresenter*) Find("MxStillPresenter", "Info_A_Bitmap"); assert(m_glowInfo[0].m_destCtl); m_glowInfo[0].m_area = MxRect(391, 182, 427, 230); - m_glowInfo[0].m_unk0x04 = 3; + m_glowInfo[0].m_target = InfocenterMapEntry::e_infocenter; m_glowInfo[1].m_destCtl = (MxStillPresenter*) Find("MxStillPresenter", "Boat_A_Bitmap"); assert(m_glowInfo[1].m_destCtl); m_glowInfo[1].m_area = MxRect(304, 225, 350, 268); - m_glowInfo[1].m_unk0x04 = 10; + m_glowInfo[1].m_target = InfocenterMapEntry::e_jetrace; m_glowInfo[2].m_destCtl = (MxStillPresenter*) Find("MxStillPresenter", "Race_A_Bitmap"); assert(m_glowInfo[1].m_destCtl); // DECOMP: intentional typo m_glowInfo[2].m_area = MxRect(301, 133, 347, 181); - m_glowInfo[2].m_unk0x04 = 11; + m_glowInfo[2].m_target = InfocenterMapEntry::e_carrace; m_glowInfo[3].m_destCtl = (MxStillPresenter*) Find("MxStillPresenter", "Pizza_A_Bitmap"); assert(m_glowInfo[3].m_destCtl); m_glowInfo[3].m_area = MxRect(289, 182, 335, 225); - m_glowInfo[3].m_unk0x04 = 12; + m_glowInfo[3].m_target = InfocenterMapEntry::e_pizzeria; m_glowInfo[4].m_destCtl = (MxStillPresenter*) Find("MxStillPresenter", "Gas_A_Bitmap"); assert(m_glowInfo[4].m_destCtl); m_glowInfo[4].m_area = MxRect(350, 161, 391, 209); - m_glowInfo[4].m_unk0x04 = 13; + m_glowInfo[4].m_target = InfocenterMapEntry::e_garage; m_glowInfo[5].m_destCtl = (MxStillPresenter*) Find("MxStillPresenter", "Med_A_Bitmap"); assert(m_glowInfo[5].m_destCtl); m_glowInfo[5].m_area = MxRect(392, 130, 438, 176); - m_glowInfo[5].m_unk0x04 = 14; + m_glowInfo[5].m_target = InfocenterMapEntry::e_hospital; m_glowInfo[6].m_destCtl = (MxStillPresenter*) Find("MxStillPresenter", "Cop_A_Bitmap"); assert(m_glowInfo[6].m_destCtl); m_glowInfo[6].m_area = MxRect(396, 229, 442, 272); - m_glowInfo[6].m_unk0x04 = 15; + m_glowInfo[6].m_target = InfocenterMapEntry::e_police; m_frame = (MxStillPresenter*) Find("MxStillPresenter", "FrameHot_Bitmap"); assert(m_frame); @@ -694,7 +694,7 @@ MxU8 Infocenter::HandleMouseMove(MxS32 p_x, MxS32 p_y) m_dragPresenter->SetPosition(p_x, p_y); } - FUN_10070d10(p_x, p_y); + UpdateEnabledGlowControl(p_x, p_y); return 1; } @@ -783,7 +783,7 @@ MxU8 Infocenter::HandleButtonUp(MxS32 p_x, MxS32 p_y) m_radio.Stop(); BackgroundAudioManager()->Stop(); PlayAction(InfomainScript::c_Pepper_All_Movie); - m_unk0x1d4++; + m_playingMovieCounter++; } break; case InfomainScript::c_Mama_Ctl: @@ -791,7 +791,7 @@ MxU8 Infocenter::HandleButtonUp(MxS32 p_x, MxS32 p_y) m_radio.Stop(); BackgroundAudioManager()->Stop(); PlayAction(InfomainScript::c_Mama_All_Movie); - m_unk0x1d4++; + m_playingMovieCounter++; } break; case InfomainScript::c_Papa_Ctl: @@ -799,7 +799,7 @@ MxU8 Infocenter::HandleButtonUp(MxS32 p_x, MxS32 p_y) m_radio.Stop(); BackgroundAudioManager()->Stop(); PlayAction(InfomainScript::c_Papa_All_Movie); - m_unk0x1d4++; + m_playingMovieCounter++; } break; case InfomainScript::c_Nick_Ctl: @@ -807,7 +807,7 @@ MxU8 Infocenter::HandleButtonUp(MxS32 p_x, MxS32 p_y) m_radio.Stop(); BackgroundAudioManager()->Stop(); PlayAction(InfomainScript::c_Nick_All_Movie); - m_unk0x1d4++; + m_playingMovieCounter++; } break; case InfomainScript::c_Laura_Ctl: @@ -815,17 +815,17 @@ MxU8 Infocenter::HandleButtonUp(MxS32 p_x, MxS32 p_y) m_radio.Stop(); BackgroundAudioManager()->Stop(); PlayAction(InfomainScript::c_Laura_All_Movie); - m_unk0x1d4++; + m_playingMovieCounter++; } break; } } else { - if (m_unk0x1c8 != -1) { + if (m_enabledGlowControl != -1) { m_infoManDialogueTimer = 0; - switch (m_glowInfo[m_unk0x1c8].m_unk0x04) { - case 3: + switch (m_glowInfo[m_enabledGlowControl].m_target) { + case InfocenterMapEntry::e_infocenter: GameState()->SetActor(m_selectedCharacter); switch (m_selectedCharacter) { @@ -846,37 +846,37 @@ MxU8 Infocenter::HandleButtonUp(MxS32 p_x, MxS32 p_y) break; } break; - case 10: + case InfocenterMapEntry::e_jetrace: if (m_selectedCharacter) { m_destLocation = LegoGameState::e_jetraceExterior; m_infocenterState->m_unk0x74 = 5; } break; - case 11: + case InfocenterMapEntry::e_carrace: if (m_selectedCharacter) { m_destLocation = LegoGameState::e_carraceExterior; m_infocenterState->m_unk0x74 = 5; } break; - case 12: + case InfocenterMapEntry::e_pizzeria: if (m_selectedCharacter) { m_destLocation = LegoGameState::e_pizzeriaExterior; m_infocenterState->m_unk0x74 = 5; } break; - case 13: + case InfocenterMapEntry::e_garage: if (m_selectedCharacter) { m_destLocation = LegoGameState::e_garageExterior; m_infocenterState->m_unk0x74 = 5; } break; - case 14: + case InfocenterMapEntry::e_hospital: if (m_selectedCharacter) { m_destLocation = LegoGameState::e_hospitalExterior; m_infocenterState->m_unk0x74 = 5; } break; - case 15: + case InfocenterMapEntry::e_police: if (m_selectedCharacter) { m_destLocation = LegoGameState::e_policeExterior; m_infocenterState->m_unk0x74 = 5; @@ -938,7 +938,7 @@ MxU8 Infocenter::HandleButtonUp(MxS32 p_x, MxS32 p_y) } UpdateFrameHot(TRUE); - FUN_10070d10(0, 0); + UpdateEnabledGlowControl(0, 0); } return FALSE; @@ -1239,21 +1239,21 @@ MxResult Infocenter::Tickle() m_bookAnimationTimer = 1; } - if (m_unk0x1d6 != 0) { - m_unk0x1d6 += 100; + if (m_bigInfoBlinkTimer != 0) { + m_bigInfoBlinkTimer += 100; - if (m_unk0x1d6 > 3400 && m_unk0x1d6 < 3650) { + if (m_bigInfoBlinkTimer > 3400 && m_bigInfoBlinkTimer < 3650) { ControlManager()->UpdateEnabledChild(InfomainScript::c_BigInfo_Ctl, m_atomId.GetInternal(), 1); } - else if (m_unk0x1d6 > 3650 && m_unk0x1d6 < 3900) { + else if (m_bigInfoBlinkTimer > 3650 && m_bigInfoBlinkTimer < 3900) { ControlManager()->UpdateEnabledChild(InfomainScript::c_BigInfo_Ctl, m_atomId.GetInternal(), 0); } - else if (m_unk0x1d6 > 3900 && m_unk0x1d6 < 4150) { + else if (m_bigInfoBlinkTimer > 3900 && m_bigInfoBlinkTimer < 4150) { ControlManager()->UpdateEnabledChild(InfomainScript::c_BigInfo_Ctl, m_atomId.GetInternal(), 1); } - else if (m_unk0x1d6 > 4400) { + else if (m_bigInfoBlinkTimer > 4400) { ControlManager()->UpdateEnabledChild(InfomainScript::c_BigInfo_Ctl, m_atomId.GetInternal(), 0); - m_unk0x1d6 = 0; + m_bigInfoBlinkTimer = 0; } } @@ -1302,7 +1302,7 @@ MxBool Infocenter::VTable0x5c() // FUNCTION: LEGO1 0x10070d10 // FUNCTION: BETA10 0x100307d4 -void Infocenter::FUN_10070d10(MxS32 p_x, MxS32 p_y) +void Infocenter::UpdateEnabledGlowControl(MxS32 p_x, MxS32 p_y) { MxS16 i; for (i = 0; i < (MxS32) (sizeof(m_glowInfo) / sizeof(m_glowInfo[0])); i++) { @@ -1320,12 +1320,12 @@ void Infocenter::FUN_10070d10(MxS32 p_x, MxS32 p_y) i = -1; } - if (i != m_unk0x1c8) { - if (m_unk0x1c8 != -1) { - m_glowInfo[m_unk0x1c8].m_destCtl->Enable(FALSE); + if (i != m_enabledGlowControl) { + if (m_enabledGlowControl != -1) { + m_glowInfo[m_enabledGlowControl].m_destCtl->Enable(FALSE); } - m_unk0x1c8 = i; + m_enabledGlowControl = i; if (i != -1) { m_glowInfo[i].m_destCtl->Enable(TRUE); } diff --git a/LEGO1/lego/legoomni/src/worlds/isle.cpp b/LEGO1/lego/legoomni/src/worlds/isle.cpp index 8c35e1f1..f275430c 100644 --- a/LEGO1/lego/legoomni/src/worlds/isle.cpp +++ b/LEGO1/lego/legoomni/src/worlds/isle.cpp @@ -1653,19 +1653,19 @@ void Act1State::PlaceActors() m_helicopter = NULL; if (m_helicopterWindshield != NULL) { - FUN_1003f930(m_helicopterWindshield); + LoadFromNamedTexture(m_helicopterWindshield); delete m_helicopterWindshield; m_helicopterWindshield = NULL; } if (m_helicopterJetLeft != NULL) { - FUN_1003f930(m_helicopterJetLeft); + LoadFromNamedTexture(m_helicopterJetLeft); delete m_helicopterJetLeft; m_helicopterJetLeft = NULL; } if (m_helicopterJetRight != NULL) { - FUN_1003f930(m_helicopterJetRight); + LoadFromNamedTexture(m_helicopterJetRight); delete m_helicopterJetRight; m_helicopterJetRight = NULL; } @@ -1689,13 +1689,13 @@ void Act1State::PlaceActors() m_jetski = NULL; if (m_jetskiFront != NULL) { - FUN_1003f930(m_jetskiFront); + LoadFromNamedTexture(m_jetskiFront); delete m_jetskiFront; m_jetskiFront = NULL; } if (m_jetskiWindshield != NULL) { - FUN_1003f930(m_jetskiWindshield); + LoadFromNamedTexture(m_jetskiWindshield); delete m_jetskiWindshield; m_jetskiWindshield = NULL; } @@ -1723,7 +1723,7 @@ void Act1State::PlaceActors() m_dunebuggy = NULL; if (m_dunebuggyFront != NULL) { - FUN_1003f930(m_dunebuggyFront); + LoadFromNamedTexture(m_dunebuggyFront); delete m_dunebuggyFront; m_dunebuggyFront = NULL; } @@ -1751,19 +1751,19 @@ void Act1State::PlaceActors() m_racecar = NULL; if (m_racecarFront != NULL) { - FUN_1003f930(m_racecarFront); + LoadFromNamedTexture(m_racecarFront); delete m_racecarFront; m_racecarFront = NULL; } if (m_racecarBack != NULL) { - FUN_1003f930(m_racecarBack); + LoadFromNamedTexture(m_racecarBack); delete m_racecarBack; m_racecarBack = NULL; } if (m_racecarTail != NULL) { - FUN_1003f930(m_racecarTail); + LoadFromNamedTexture(m_racecarTail); delete m_racecarTail; m_racecarTail = NULL; } diff --git a/LEGO1/lego/sources/roi/legoroi.cpp b/LEGO1/lego/sources/roi/legoroi.cpp index aeda3659..7b02dd01 100644 --- a/LEGO1/lego/sources/roi/legoroi.cpp +++ b/LEGO1/lego/sources/roi/legoroi.cpp @@ -44,13 +44,13 @@ ROIColorAlias g_roiColorAliases[22] = { int g_roiConfig = 100; // GLOBAL: LEGO1 0x10101370 -const char* g_unk0x10101370[] = {"bike", "moto", NULL}; +const char* g_sharedModelsHigh[] = {"bike", "moto", NULL}; // GLOBAL: LEGO1 0x10101380 -const char* g_unk0x10101380[] = {"bike", "moto", "haus", NULL}; +const char* g_sharedModelsLow[] = {"bike", "moto", "haus", NULL}; // GLOBAL: LEGO1 0x10101390 -const char* g_unk0x10101390[] = {"rcuser", "jsuser", "dunebugy", "chtrblad", "chtrbody", "chtrshld", NULL}; +const char* g_alwaysLoadNames[] = {"rcuser", "jsuser", "dunebugy", "chtrblad", "chtrbody", "chtrshld", NULL}; // GLOBAL: LEGO1 0x101013ac ColorOverride g_colorOverride = NULL; @@ -225,30 +225,30 @@ LegoResult LegoROI::Read( } if (g_roiConfig <= 2) { - for (i = 0; g_unk0x10101380[i] != NULL; i++) { - if (!SDL_strncasecmp(m_name, g_unk0x10101380[i], 4)) { - roiName = g_unk0x10101380[i]; + for (i = 0; g_sharedModelsLow[i] != NULL; i++) { + if (!SDL_strncasecmp(m_name, g_sharedModelsLow[i], 4)) { + roiName = g_sharedModelsLow[i]; break; } } } else { - for (i = 0; g_unk0x10101370[i] != NULL; i++) { - if (!SDL_strncasecmp(m_name, g_unk0x10101370[i], 4)) { - roiName = g_unk0x10101370[i]; + for (i = 0; g_sharedModelsHigh[i] != NULL; i++) { + if (!SDL_strncasecmp(m_name, g_sharedModelsHigh[i], 4)) { + roiName = g_sharedModelsHigh[i]; break; } } } if ((lodList = p_viewLODListManager->Lookup(roiName))) { - for (j = 0; g_unk0x10101390[j] != NULL; j++) { - if (!SDL_strcasecmp(g_unk0x10101390[j], roiName)) { + for (j = 0; g_alwaysLoadNames[j] != NULL; j++) { + if (!SDL_strcasecmp(g_alwaysLoadNames[j], roiName)) { break; } } - if (g_unk0x10101390[j] != NULL) { + if (g_alwaysLoadNames[j] != NULL) { while (lodList->Size()) { delete const_cast(lodList->PopBack()); } diff --git a/LEGO1/omni/src/video/mxdisplaysurface.cpp b/LEGO1/omni/src/video/mxdisplaysurface.cpp index b36cbd2a..2902c4fe 100644 --- a/LEGO1/omni/src/video/mxdisplaysurface.cpp +++ b/LEGO1/omni/src/video/mxdisplaysurface.cpp @@ -827,6 +827,7 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::VTable0x44( ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT; ddsd.dwWidth = p_bitmap->GetBmiWidth(); ddsd.dwHeight = p_bitmap->GetBmiHeightAbs(); + ddsd.ddpfPixelFormat = m_surfaceDesc.ddpfPixelFormat; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; *p_ret = 0; ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; diff --git a/README.md b/README.md index 765c74d2..95237c85 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This initiative is a portable version of LEGO Island (Version 1.1, English) based on the [decompilation project](https://github.com/isledecomp/isle). Our primary goal is to transform the codebase to achieve platform independence, thereby enhancing compatibility across various systems while preserving the original game's experience as faithfully as possible. -Please note: this project is dedicated to achieving platform independence without altering the core gameplay, adding new features, enhancing visual quality, or rewriting code for improvement's sake. While those are worthwhile objectives, they are not within the scope of this project. +Please note: this project is primarily dedicated to achieving platform independence without altering the core gameplay or rewriting code for improvement's sake. While those are worthwhile objectives, they are not within the scope of this project. `isle-portable` offers support for light modding using [`extensions`](/extensions). ## Status @@ -16,10 +16,10 @@ Please note: this project is dedicated to achieving platform independence withou | [Web](https://isle.pizza) | [![CI](https://github.com/isledecomp/isle-portable/actions/workflows/ci.yml/badge.svg)](https://github.com/isledecomp/isle-portable/actions/workflows/ci.yml) | | Nintendo 3DS | [![CI](https://github.com/isledecomp/isle-portable/actions/workflows/ci.yml/badge.svg)](https://github.com/isledecomp/isle-portable/actions/workflows/ci.yml) | | Xbox One | [![CI](https://github.com/isledecomp/isle-portable/actions/workflows/ci.yml/badge.svg)](https://github.com/isledecomp/isle-portable/actions/workflows/ci.yml) | +| iOS | [![CI](https://github.com/isledecomp/isle-portable/actions/workflows/ci.yml/badge.svg)](https://github.com/isledecomp/isle-portable/actions/workflows/ci.yml) | We are actively working to support more platforms. If you have experience with a particular platform, we encourage you to contribute to `isle-portable`. You can find a [list of ongoing efforts](https://github.com/isledecomp/isle-portable/wiki/Work%E2%80%90in%E2%80%90progress-ports) in our Wiki. - ## Usage **An existing copy of LEGO Island is required to use this project.** diff --git a/docker/emscripten/Dockerfile b/docker/emscripten/Dockerfile index a213093c..707b3c7a 100644 --- a/docker/emscripten/Dockerfile +++ b/docker/emscripten/Dockerfile @@ -28,6 +28,7 @@ COPY --chown=emscripten:emscripten miniwin/ ./miniwin/ COPY --chown=emscripten:emscripten util/ ./util/ COPY --chown=emscripten:emscripten CMake/ ./CMake/ COPY --chown=emscripten:emscripten packaging/ ./packaging/ +COPY --chown=emscripten:emscripten extensions/ ./extensions/ COPY --chown=emscripten:emscripten CMakeLists.txt . RUN emcmake cmake -S . -B build -DISLE_BUILD_CONFIG=OFF -DISLE_DEBUG=OFF -DCMAKE_BUILD_TYPE=Release -DISLE_EMSCRIPTEN_HOST=/assets && \ diff --git a/extensions/include/extensions/extensions.h b/extensions/include/extensions/extensions.h new file mode 100644 index 00000000..215bf80a --- /dev/null +++ b/extensions/include/extensions/extensions.h @@ -0,0 +1,28 @@ +#pragma once + +#include "lego1_export.h" + +#include +#include +#include + +namespace Extensions +{ +constexpr const char* availableExtensions[] = {"extensions:texture loader"}; + +LEGO1_EXPORT void Enable(const char* p_key); + +template +struct Extension { + template + static auto Call(Function&& function, Args&&... args) -> std::optional> + { +#ifdef EXTENSIONS + if (T::enabled) { + return std::invoke(std::forward(function), std::forward(args)...); + } +#endif + return std::nullopt; + } +}; +}; // namespace Extensions diff --git a/extensions/include/extensions/textureloader.h b/extensions/include/extensions/textureloader.h new file mode 100644 index 00000000..649c6112 --- /dev/null +++ b/extensions/include/extensions/textureloader.h @@ -0,0 +1,24 @@ +#pragma once + +#include "extensions/extensions.h" +#include "legotextureinfo.h" + +namespace Extensions +{ +class TextureLoader { +public: + static bool PatchTexture(LegoTextureInfo* p_textureInfo); + static bool enabled; + +private: + static constexpr const char* texturePath = "/textures/"; + + static SDL_Surface* FindTexture(const char* p_name); +}; + +#ifdef EXTENSIONS +constexpr auto PatchTexture = &TextureLoader::PatchTexture; +#else +constexpr decltype(&TextureLoader::PatchTexture) PatchTexture = nullptr; +#endif +}; // namespace Extensions diff --git a/extensions/src/extensions.cpp b/extensions/src/extensions.cpp new file mode 100644 index 00000000..e1d0c389 --- /dev/null +++ b/extensions/src/extensions.cpp @@ -0,0 +1,19 @@ +#include "extensions/extensions.h" + +#include "extensions/textureloader.h" + +#include + +void Extensions::Enable(const char* p_key) +{ + for (const char* key : availableExtensions) { + if (!SDL_strcasecmp(p_key, key)) { + if (!SDL_strcasecmp(p_key, "extensions:texture loader")) { + TextureLoader::enabled = true; + } + + SDL_Log("Enabled extension: %s", p_key); + break; + } + } +} diff --git a/extensions/src/textureloader.cpp b/extensions/src/textureloader.cpp new file mode 100644 index 00000000..dd96105e --- /dev/null +++ b/extensions/src/textureloader.cpp @@ -0,0 +1,101 @@ +#include "extensions/textureloader.h" + +using namespace Extensions; + +bool TextureLoader::enabled = false; + +bool TextureLoader::PatchTexture(LegoTextureInfo* p_textureInfo) +{ + SDL_Surface* surface = FindTexture(p_textureInfo->m_name); + if (!surface) { + return false; + } + + const SDL_PixelFormatDetails* details = SDL_GetPixelFormatDetails(surface->format); + + DDSURFACEDESC desc; + memset(&desc, 0, sizeof(desc)); + desc.dwSize = sizeof(desc); + desc.dwFlags = DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS; + desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY; + desc.ddpfPixelFormat.dwSize = sizeof(desc.ddpfPixelFormat); + desc.dwWidth = surface->w; + desc.dwHeight = surface->h; + desc.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; + desc.ddpfPixelFormat.dwRGBBitCount = details->bits_per_pixel; + desc.ddpfPixelFormat.dwRBitMask = details->Rmask; + desc.ddpfPixelFormat.dwGBitMask = details->Gmask; + desc.ddpfPixelFormat.dwBBitMask = details->Bmask; + desc.ddpfPixelFormat.dwRGBAlphaBitMask = details->Amask; + + LPDIRECTDRAW pDirectDraw = VideoManager()->GetDirect3D()->DirectDraw(); + if (pDirectDraw->CreateSurface(&desc, &p_textureInfo->m_surface, NULL) != DD_OK) { + SDL_DestroySurface(surface); + return false; + } + + memset(&desc, 0, sizeof(desc)); + desc.dwSize = sizeof(desc); + + if (p_textureInfo->m_surface->Lock(NULL, &desc, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY, NULL) != DD_OK) { + SDL_DestroySurface(surface); + return false; + } + + MxU8* dst = (MxU8*) desc.lpSurface; + Uint8* srcPixels = (Uint8*) surface->pixels; + + if (details->bits_per_pixel == 8) { + SDL_Palette* sdlPalette = SDL_GetSurfacePalette(surface); + if (!sdlPalette) { + SDL_DestroySurface(surface); + return false; + } + + PALETTEENTRY entries[256]; + for (int i = 0; i < sdlPalette->ncolors; ++i) { + entries[i].peRed = sdlPalette->colors[i].r; + entries[i].peGreen = sdlPalette->colors[i].g; + entries[i].peBlue = sdlPalette->colors[i].b; + entries[i].peFlags = PC_NONE; + } + + LPDIRECTDRAWPALETTE ddPalette = nullptr; + if (pDirectDraw->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256, entries, &ddPalette, NULL) != DD_OK) { + SDL_DestroySurface(surface); + return false; + } + + p_textureInfo->m_surface->SetPalette(ddPalette); + ddPalette->Release(); + } + + memcpy(dst, srcPixels, surface->pitch * surface->h); + p_textureInfo->m_surface->Unlock(desc.lpSurface); + p_textureInfo->m_palette = NULL; + + if (((TglImpl::RendererImpl*) VideoManager()->GetRenderer()) + ->CreateTextureFromSurface(p_textureInfo->m_surface, &p_textureInfo->m_texture) != D3DRM_OK) { + SDL_DestroySurface(surface); + return false; + } + + p_textureInfo->m_texture->SetAppData((LPD3DRM_APPDATA) p_textureInfo); + SDL_DestroySurface(surface); + return true; +} + +SDL_Surface* TextureLoader::FindTexture(const char* p_name) +{ + SDL_Surface* surface; + MxString path = MxString(MxOmni::GetHD()) + texturePath + p_name + ".bmp"; + + path.MapPathToFilesystem(); + if (!(surface = SDL_LoadBMP(path.GetData()))) { + path = MxString(MxOmni::GetCD()) + texturePath + p_name + ".bmp"; + path.MapPathToFilesystem(); + surface = SDL_LoadBMP(path.GetData()); + } + + return surface; +} diff --git a/miniwin/CMakeLists.txt b/miniwin/CMakeLists.txt index 1ed5e909..3fe96ea3 100644 --- a/miniwin/CMakeLists.txt +++ b/miniwin/CMakeLists.txt @@ -19,42 +19,44 @@ add_library(miniwin STATIC EXCLUDE_FROM_ALL src/d3drm/d3drmmesh.cpp src/d3drm/d3drmtexture.cpp src/d3drm/d3drmviewport.cpp + src/d3drm/d3drmrenderer.cpp src/internal/meshutils.cpp - - # D3DRM backends - src/d3drm/backends/sdl3gpu/renderer.cpp - src/d3drm/backends/sdl3gpu/shaders/generated/ShaderIndex.cpp - src/d3drm/backends/software/renderer.cpp ) target_compile_definitions(miniwin PRIVATE $<$:DEBUG> ) -find_package(OpenGL) -if(OpenGL_FOUND AND NOT WINDOWS_STORE) - message(STATUS "Found OpenGL: enabling OpenGL 1.x renderer") - target_sources(miniwin PRIVATE - src/d3drm/backends/opengl1/actual.cpp - src/d3drm/backends/opengl1/renderer.cpp - ) - target_compile_definitions(miniwin PRIVATE USE_OPENGL1) - target_link_libraries(miniwin PRIVATE OpenGL::GL) -else() - message(STATUS "🧩 OpenGL 1.x support not enabled — needs OpenGL") +list(APPEND GRAPHICS_BACKENDS USE_SOFTWARE_RENDER) +list(APPEND GRAPHICS_BACKENDS USE_SDL_GPU) + +if(NOT WINDOWS_STORE) + find_package(OpenGL) + if(OpenGL_FOUND) + message(STATUS "Found OpenGL: enabling OpenGL 1.x renderer") + target_sources(miniwin PRIVATE + src/d3drm/backends/opengl1/actual.cpp + src/d3drm/backends/opengl1/renderer.cpp + ) + list(APPEND GRAPHICS_BACKENDS USE_OPENGL1) + target_link_libraries(miniwin PRIVATE OpenGL::GL) + else() + message(STATUS "🧩 OpenGL 1.x support not enabled — needs OpenGL") + endif() + + find_library(OPENGL_ES2_LIBRARY NAMES GLESv2) + if(EMSCRIPTEN OR OPENGL_ES2_LIBRARY) + message(STATUS "Found OpenGL: enabling OpenGL ES 2.x renderer") + target_sources(miniwin PRIVATE src/d3drm/backends/opengles2/renderer.cpp) + list(APPEND GRAPHICS_BACKENDS USE_OPENGLES2) + if(OPENGL_ES2_LIBRARY) + target_link_libraries(miniwin PRIVATE ${OPENGL_ES2_LIBRARY}) + endif() + else() + message(STATUS "🧩 OpenGL ES 2.x support not enabled") + endif() endif() -find_library(OPENGL_ES2_LIBRARY NAMES GLESv2) -if(EMSCRIPTEN OR OPENGL_ES2_LIBRARY AND NOT WINDOWS_STORE) - message(STATUS "Found OpenGL: enabling OpenGL ES 2.x renderer") - target_sources(miniwin PRIVATE src/d3drm/backends/opengles2/renderer.cpp) - target_compile_definitions(miniwin PRIVATE USE_OPENGLES2) - if(OPENGL_ES2_LIBRARY) - target_link_libraries(miniwin PRIVATE OpenGL::GL) - endif() -else() - message(STATUS "🧩 OpenGL ES 2.x support not enabled") -endif() if(NINTENDO_3DS) if(ISLE_DEBUG) @@ -68,6 +70,7 @@ if(NINTENDO_3DS) ctr_add_shader_library(vshader src/d3drm/backends/citro3d/vshader.v.pica) dkp_add_embedded_binary_library(3ds_shaders vshader) target_link_libraries(miniwin PRIVATE ${CITRO3D_LIBRARY} 3ds_shaders) + list(APPEND GRAPHICS_BACKENDS USE_CITRO3D) else() message(STATUS "🧩 Citro3D support not enabled") endif() @@ -79,12 +82,26 @@ if(WIN32 AND NOT WINDOWS_STORE) src/d3drm/backends/directx9/renderer.cpp ) target_link_libraries(miniwin PRIVATE d3d9) + list(APPEND GRAPHICS_BACKENDS USE_DIRECTX9) endif() if(WINDOWS_STORE) add_compile_definitions(WINDOWS_STORE) endif() +if(USE_SDL_GPU IN_LIST GRAPHICS_BACKENDS) + target_sources(miniwin PRIVATE + src/d3drm/backends/sdl3gpu/renderer.cpp + src/d3drm/backends/sdl3gpu/shaders/generated/ShaderIndex.cpp + ) +endif() + +if(USE_SOFTWARE_RENDER IN_LIST GRAPHICS_BACKENDS) + target_sources(miniwin PRIVATE + src/d3drm/backends/software/renderer.cpp + ) +endif() + target_compile_definitions(miniwin PUBLIC MINIWIN) target_include_directories(miniwin @@ -96,6 +113,9 @@ target_link_libraries(miniwin PUBLIC miniwin-headers) target_link_libraries(miniwin PRIVATE SDL3::SDL3) +target_compile_definitions(miniwin PUBLIC ${GRAPHICS_BACKENDS}) + + # Shader stuff set(shader_src_dir "${CMAKE_CURRENT_SOURCE_DIR}/src/d3drm/backends/sdl3gpu/shaders/src") diff --git a/miniwin/include/miniwin/ddraw.h b/miniwin/include/miniwin/ddraw.h index 0250c099..912a1b9f 100644 --- a/miniwin/include/miniwin/ddraw.h +++ b/miniwin/include/miniwin/ddraw.h @@ -143,9 +143,12 @@ enum class DDBltFlags : uint32_t { }; ENABLE_BITMASK_OPERATORS(DDBltFlags) +#define DDPF_ALPHAPIXELS DDPixelFormatFlags::ALPHAPIXELS #define DDPF_PALETTEINDEXED8 DDPixelFormatFlags::PALETTEINDEXED8 #define DDPF_RGB DDPixelFormatFlags::RGB +#define DDPF_ALPHAPIXELS DDPixelFormatFlags::ALPHAPIXELS enum class DDPixelFormatFlags : uint32_t { + ALPHAPIXELS = 1 << 0, // dwRGBAlphaBitMask is valid PALETTEINDEXED8 = 1 << 5, // The texture uses an 8 bit palette RGB = 1 << 6, // dwRGBBitCount, dwRBitMask, dwGBitMask, and dwBBitMask is valid }; diff --git a/miniwin/include/miniwin/miniwindevice.h b/miniwin/include/miniwin/miniwindevice.h index 00329393..de28e76a 100644 --- a/miniwin/include/miniwin/miniwindevice.h +++ b/miniwin/include/miniwin/miniwindevice.h @@ -6,4 +6,5 @@ DEFINE_GUID(IID_IDirect3DRMMiniwinDevice, 0x6eb09673, 0x8d30, 0x4d8a, 0x8d, 0x81 struct IDirect3DRMMiniwinDevice : virtual public IUnknown { virtual bool ConvertEventToRenderCoordinates(SDL_Event* event) = 0; + virtual bool ConvertRenderToWindowCoordinates(Sint32 inX, Sint32 inY, Sint32& outX, Sint32& outY) = 0; }; diff --git a/miniwin/src/d3drm/d3drm.cpp b/miniwin/src/d3drm/d3drm.cpp index 1088a943..7328d21c 100644 --- a/miniwin/src/d3drm/d3drm.cpp +++ b/miniwin/src/d3drm/d3drm.cpp @@ -7,20 +7,6 @@ #include "d3drmmesh_impl.h" #include "d3drmobject_impl.h" #include "d3drmrenderer.h" -#ifdef USE_OPENGL1 -#include "d3drmrenderer_opengl1.h" -#endif -#ifdef USE_OPENGLES2 -#include "d3drmrenderer_opengles2.h" -#endif -#ifdef __3DS__ -#include "d3drmrenderer_citro3d.h" -#endif -#ifdef _WIN32 -#include "d3drmrenderer_directx9.h" -#endif -#include "d3drmrenderer_sdl3gpu.h" -#include "d3drmrenderer_software.h" #include "d3drmtexture_impl.h" #include "d3drmviewport_impl.h" #include "ddraw_impl.h" @@ -146,33 +132,8 @@ HRESULT Direct3DRMImpl::CreateDeviceFromSurface( DDSDesc.dwSize = sizeof(DDSURFACEDESC); surface->GetSurfaceDesc(&DDSDesc); - if (SDL_memcmp(&guid, &SDL3_GPU_GUID, sizeof(GUID)) == 0) { - DDRenderer = Direct3DRMSDL3GPURenderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight); - } - else if (SDL_memcmp(&guid, &SOFTWARE_GUID, sizeof(GUID)) == 0) { - DDRenderer = new Direct3DRMSoftwareRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight); - } -#ifdef USE_OPENGLES2 - else if (SDL_memcmp(&guid, &OpenGLES2_GUID, sizeof(GUID)) == 0) { - DDRenderer = OpenGLES2Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight); - } -#endif -#ifdef USE_OPENGL1 - else if (SDL_memcmp(&guid, &OpenGL1_GUID, sizeof(GUID)) == 0) { - DDRenderer = OpenGL1Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight); - } -#endif -#ifdef __3DS__ - else if (SDL_memcmp(&guid, &Citro3D_GUID, sizeof(GUID)) == 0) { - DDRenderer = new Citro3DRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight); - } -#endif -#if defined(_WIN32) && !defined(WINDOWS_STORE) - else if (SDL_memcmp(&guid, &DirectX9_GUID, sizeof(GUID)) == 0) { - DDRenderer = DirectX9Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight); - } -#endif - else { + DDRenderer = CreateDirect3DRMRenderer(DDSDesc, guid); + if (!DDRenderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Device GUID not recognized"); return E_NOINTERFACE; } diff --git a/miniwin/src/d3drm/d3drmdevice.cpp b/miniwin/src/d3drm/d3drmdevice.cpp index bae67e94..e3190692 100644 --- a/miniwin/src/d3drm/d3drmdevice.cpp +++ b/miniwin/src/d3drm/d3drmdevice.cpp @@ -150,14 +150,13 @@ ViewportTransform CalculateViewportTransform(int virtualW, int virtualH, int win void Direct3DRMDevice2Impl::Resize() { - int width, height; - SDL_GetWindowSizeInPixels(DDWindow, &width, &height); + SDL_GetWindowSizeInPixels(DDWindow, &m_windowWidth, &m_windowHeight); #ifdef __3DS__ - width = 320; // We are on the lower screen - height = 240; + m_windowWidth = 320; // We are on the lower screen + m_windowHeight = 240; #endif - m_viewportTransform = CalculateViewportTransform(m_virtualWidth, m_virtualHeight, width, height); - m_renderer->Resize(width, height, m_viewportTransform); + m_viewportTransform = CalculateViewportTransform(m_virtualWidth, m_virtualHeight, m_windowWidth, m_windowHeight); + m_renderer->Resize(m_windowWidth, m_windowHeight, m_viewportTransform); m_renderer->Clear(0, 0, 0); for (int i = 0; i < m_viewports->GetSize(); i++) { IDirect3DRMViewport* viewport; @@ -173,18 +172,35 @@ bool Direct3DRMDevice2Impl::ConvertEventToRenderCoordinates(SDL_Event* event) Resize(); break; } - case SDL_EVENT_MOUSE_MOTION: + case SDL_EVENT_MOUSE_MOTION: { + event->motion.x = (event->motion.x - m_viewportTransform.offsetX) / m_viewportTransform.scale; + event->motion.y = (event->motion.y - m_viewportTransform.offsetY) / m_viewportTransform.scale; + break; + } case SDL_EVENT_MOUSE_BUTTON_DOWN: case SDL_EVENT_MOUSE_BUTTON_UP: { - int rawX = event->motion.x; - int rawY = event->motion.y; - float x = (rawX - m_viewportTransform.offsetX) / m_viewportTransform.scale; - float y = (rawY - m_viewportTransform.offsetY) / m_viewportTransform.scale; - event->motion.x = static_cast(x); - event->motion.y = static_cast(y); + event->button.x = (event->button.x - m_viewportTransform.offsetX) / m_viewportTransform.scale; + event->button.y = (event->button.y - m_viewportTransform.offsetY) / m_viewportTransform.scale; break; - } break; + } + case SDL_EVENT_FINGER_MOTION: + case SDL_EVENT_FINGER_DOWN: + case SDL_EVENT_FINGER_UP: { + float x = (event->tfinger.x * m_windowWidth - m_viewportTransform.offsetX) / m_viewportTransform.scale; + float y = (event->tfinger.y * m_windowHeight - m_viewportTransform.offsetY) / m_viewportTransform.scale; + event->tfinger.x = x / m_virtualWidth; + event->tfinger.y = y / m_virtualHeight; + break; + } } return true; } + +bool Direct3DRMDevice2Impl::ConvertRenderToWindowCoordinates(Sint32 inX, Sint32 inY, Sint32& outX, Sint32& outY) +{ + outX = static_cast(inX * m_viewportTransform.scale + m_viewportTransform.offsetX); + outY = static_cast(inY * m_viewportTransform.scale + m_viewportTransform.offsetY); + + return true; +} diff --git a/miniwin/src/d3drm/d3drmrenderer.cpp b/miniwin/src/d3drm/d3drmrenderer.cpp new file mode 100644 index 00000000..ca9b5541 --- /dev/null +++ b/miniwin/src/d3drm/d3drmrenderer.cpp @@ -0,0 +1,76 @@ +#include "d3drmrenderer.h" +#ifdef USE_OPENGL1 +#include "d3drmrenderer_opengl1.h" +#endif +#ifdef USE_OPENGLES2 +#include "d3drmrenderer_opengles2.h" +#endif +#ifdef USE_CITRO3D +#include "d3drmrenderer_citro3d.h" +#endif +#ifdef USE_DIRECTX9 +#include "d3drmrenderer_directx9.h" +#endif +#ifdef USE_SDL_GPU +#include "d3drmrenderer_sdl3gpu.h" +#endif +#ifdef USE_SOFTWARE_RENDER +#include "d3drmrenderer_software.h" +#endif + +Direct3DRMRenderer* CreateDirect3DRMRenderer(const DDSURFACEDESC& DDSDesc, const GUID* guid) +{ +#ifdef USE_SDL_GPU + if (SDL_memcmp(guid, &SDL3_GPU_GUID, sizeof(GUID)) == 0) { + return Direct3DRMSDL3GPURenderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight); + } +#endif +#ifdef USE_SOFTWARE_RENDER + if (SDL_memcmp(guid, &SOFTWARE_GUID, sizeof(GUID)) == 0) { + return new Direct3DRMSoftwareRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight); + } +#endif +#ifdef USE_OPENGLES2 + if (SDL_memcmp(guid, &OpenGLES2_GUID, sizeof(GUID)) == 0) { + return OpenGLES2Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight); + } +#endif +#ifdef USE_OPENGL1 + if (SDL_memcmp(guid, &OpenGL1_GUID, sizeof(GUID)) == 0) { + return OpenGL1Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight); + } +#endif +#ifdef USE_CITRO3D + if (SDL_memcmp(guid, &Citro3D_GUID, sizeof(GUID)) == 0) { + return new Citro3DRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight); + } +#endif +#ifdef USE_DIRECTX9 + if (SDL_memcmp(guid, &DirectX9_GUID, sizeof(GUID)) == 0) { + return DirectX9Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight); + } +#endif + return nullptr; +} + +void Direct3DRMRenderer_EnumDevices(LPD3DENUMDEVICESCALLBACK cb, void* ctx) +{ +#ifdef USE_SDL_GPU + Direct3DRMSDL3GPU_EnumDevice(cb, ctx); +#endif +#ifdef USE_OPENGLES2 + OpenGLES2Renderer_EnumDevice(cb, ctx); +#endif +#ifdef USE_OPENGL1 + OpenGL1Renderer_EnumDevice(cb, ctx); +#endif +#ifdef USE_CITRO3D + Citro3DRenderer_EnumDevice(cb, ctx); +#endif +#ifdef USE_DIRECTX9 + DirectX9Renderer_EnumDevice(cb, ctx); +#endif +#ifdef USE_SOFTWARE_RENDER + Direct3DRMSoftware_EnumDevice(cb, ctx); +#endif +} diff --git a/miniwin/src/ddraw/ddraw.cpp b/miniwin/src/ddraw/ddraw.cpp index f9dabada..264ceeb1 100644 --- a/miniwin/src/ddraw/ddraw.cpp +++ b/miniwin/src/ddraw/ddraw.cpp @@ -1,17 +1,5 @@ -#ifdef USE_OPENGL1 -#include "d3drmrenderer_opengl1.h" -#endif -#ifdef USE_OPENGLES2 -#include "d3drmrenderer_opengles2.h" -#endif -#ifdef __3DS__ -#include "d3drmrenderer_citro3d.h" -#endif -#if defined(_WIN32) && !defined(WINDOWS_STORE) -#include "d3drmrenderer_directx9.h" -#endif -#include "d3drmrenderer_sdl3gpu.h" -#include "d3drmrenderer_software.h" + +#include "d3drmrenderer.h" #include "ddpalette_impl.h" #include "ddraw_impl.h" #include "ddsurface_impl.h" @@ -106,13 +94,17 @@ HRESULT DirectDrawImpl::CreateSurface( #endif if ((lpDDSurfaceDesc->dwFlags & DDSD_PIXELFORMAT) == DDSD_PIXELFORMAT) { if ((lpDDSurfaceDesc->ddpfPixelFormat.dwFlags & DDPF_RGB) == DDPF_RGB) { - switch (lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount) { - case 8: - format = SDL_PIXELFORMAT_INDEX8; - break; - case 16: - format = SDL_PIXELFORMAT_RGB565; - break; + int bpp = lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount; + Uint32 rMask = lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask; + Uint32 gMask = lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask; + Uint32 bMask = lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask; + Uint32 aMask = (lpDDSurfaceDesc->ddpfPixelFormat.dwFlags & DDPF_ALPHAPIXELS) == DDPF_ALPHAPIXELS + ? lpDDSurfaceDesc->ddpfPixelFormat.dwRGBAlphaBitMask + : 0; + + format = SDL_GetPixelFormatForMasks(bpp, rMask, gMask, bMask, aMask); + if (format == SDL_PIXELFORMAT_UNKNOWN) { + return DDERR_INVALIDPIXELFORMAT; } } } @@ -168,7 +160,7 @@ HRESULT DirectDrawImpl::EnumDisplayModes( ddsd.dwWidth = modes[i]->w; ddsd.dwHeight = modes[i]->h; ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); - ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB; + ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; ddsd.ddpfPixelFormat.dwRGBBitCount = details->bits_per_pixel; if (details->bits_per_pixel == 8) { ddsd.ddpfPixelFormat.dwFlags |= DDPF_PALETTEINDEXED8; @@ -228,21 +220,7 @@ void EnumDevice( HRESULT DirectDrawImpl::EnumDevices(LPD3DENUMDEVICESCALLBACK cb, void* ctx) { - Direct3DRMSDL3GPU_EnumDevice(cb, ctx); -#ifdef USE_OPENGLES2 - OpenGLES2Renderer_EnumDevice(cb, ctx); -#endif -#ifdef USE_OPENGL1 - OpenGL1Renderer_EnumDevice(cb, ctx); -#endif -#ifdef __3DS__ - Citro3DRenderer_EnumDevice(cb, ctx); -#endif -#if defined(_WIN32) && !defined(WINDOWS_STORE) - DirectX9Renderer_EnumDevice(cb, ctx); -#endif - Direct3DRMSoftware_EnumDevice(cb, ctx); - + Direct3DRMRenderer_EnumDevices(cb, ctx); return S_OK; } @@ -271,7 +249,7 @@ HRESULT DirectDrawImpl::GetDisplayMode(LPDDSURFACEDESC lpDDSurfaceDesc) lpDDSurfaceDesc->dwWidth = mode->w; lpDDSurfaceDesc->dwHeight = mode->h; lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount = details->bits_per_pixel; - lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_RGB; + lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; if (details->bits_per_pixel == 8) { lpDDSurfaceDesc->ddpfPixelFormat.dwFlags |= DDPF_PALETTEINDEXED8; } @@ -311,11 +289,11 @@ HRESULT DirectDrawImpl::SetCooperativeLevel(HWND hWnd, DDSCLFlags dwFlags) return DDERR_INVALIDPARAMS; } - if (!SDL_SetWindowFullscreen(sdlWindow, fullscreen)) { #ifndef __EMSCRIPTEN__ + if (!SDL_SetWindowFullscreen(sdlWindow, fullscreen)) { return DDERR_GENERIC; -#endif } +#endif DDWindow = sdlWindow; } return DD_OK; @@ -339,33 +317,8 @@ HRESULT DirectDrawImpl::CreateDevice( DDSDesc.dwSize = sizeof(DDSURFACEDESC); pBackBuffer->GetSurfaceDesc(&DDSDesc); - if (SDL_memcmp(&guid, &SDL3_GPU_GUID, sizeof(GUID)) == 0) { - DDRenderer = Direct3DRMSDL3GPURenderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight); - } -#ifdef USE_OPENGLES2 - else if (SDL_memcmp(&guid, &OpenGLES2_GUID, sizeof(GUID)) == 0) { - DDRenderer = OpenGLES2Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight); - } -#endif -#ifdef USE_OPENGL1 - else if (SDL_memcmp(&guid, &OpenGL1_GUID, sizeof(GUID)) == 0) { - DDRenderer = OpenGL1Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight); - } -#endif -#ifdef __3DS__ - else if (SDL_memcmp(&guid, &Citro3D_GUID, sizeof(GUID)) == 0) { - DDRenderer = new Citro3DRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight); - } -#endif -#if defined(_WIN32) && !defined(WINDOWS_STORE) - else if (SDL_memcmp(&guid, &DirectX9_GUID, sizeof(GUID)) == 0) { - DDRenderer = DirectX9Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight); - } -#endif - else if (SDL_memcmp(&guid, &SOFTWARE_GUID, sizeof(GUID)) == 0) { - DDRenderer = new Direct3DRMSoftwareRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight); - } - else { + DDRenderer = CreateDirect3DRMRenderer(DDSDesc, &guid); + if (!DDRenderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Device GUID not recognized"); return E_NOINTERFACE; } diff --git a/miniwin/src/ddraw/ddsurface.cpp b/miniwin/src/ddraw/ddsurface.cpp index 056912fd..9e710596 100644 --- a/miniwin/src/ddraw/ddsurface.cpp +++ b/miniwin/src/ddraw/ddsurface.cpp @@ -145,7 +145,7 @@ HRESULT DirectDrawSurfaceImpl::GetPalette(LPDIRECTDRAWPALETTE* lplpDDPalette) HRESULT DirectDrawSurfaceImpl::GetPixelFormat(LPDDPIXELFORMAT lpDDPixelFormat) { memset(lpDDPixelFormat, 0, sizeof(*lpDDPixelFormat)); - lpDDPixelFormat->dwFlags = DDPF_RGB; + lpDDPixelFormat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; const SDL_PixelFormatDetails* details = SDL_GetPixelFormatDetails(m_surface->format); if (details->bits_per_pixel == 8) { lpDDPixelFormat->dwFlags |= DDPF_PALETTEINDEXED8; diff --git a/miniwin/src/ddraw/framebuffer.cpp b/miniwin/src/ddraw/framebuffer.cpp index 13caa434..d3d8a3b8 100644 --- a/miniwin/src/ddraw/framebuffer.cpp +++ b/miniwin/src/ddraw/framebuffer.cpp @@ -143,7 +143,7 @@ HRESULT FrameBufferImpl::GetPalette(LPDIRECTDRAWPALETTE* lplpDDPalette) HRESULT FrameBufferImpl::GetPixelFormat(LPDDPIXELFORMAT lpDDPixelFormat) { memset(lpDDPixelFormat, 0, sizeof(*lpDDPixelFormat)); - lpDDPixelFormat->dwFlags = DDPF_RGB; + lpDDPixelFormat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; const SDL_PixelFormatDetails* details = SDL_GetPixelFormatDetails(m_transferBuffer->m_surface->format); if (details->bits_per_pixel == 8) { lpDDPixelFormat->dwFlags |= DDPF_PALETTEINDEXED8; diff --git a/miniwin/src/internal/d3drmdevice_impl.h b/miniwin/src/internal/d3drmdevice_impl.h index daab564a..46dc5ed2 100644 --- a/miniwin/src/internal/d3drmdevice_impl.h +++ b/miniwin/src/internal/d3drmdevice_impl.h @@ -34,12 +34,15 @@ struct Direct3DRMDevice2Impl : public Direct3DRMObjectBaseImpl\" + \"\$\" + DESTINATION \"\$\{CMAKE_INSTALL_PREFIX\}/${ISLE_TARGET_NAME}.app/Frameworks\") + execute_process(COMMAND /usr/bin/install_name_tool + -add_rpath @executable_path/Frameworks + \"\$\{CMAKE_INSTALL_PREFIX\}/${ISLE_TARGET_NAME}.app/${ISLE_TARGET_NAME}\" + ) + file(MAKE_DIRECTORY + \"\$\{CMAKE_INSTALL_PREFIX\}/Payload\") + file(RENAME + \"\$\{CMAKE_INSTALL_PREFIX\}/${ISLE_TARGET_NAME}.app\" + \"\$\{CMAKE_INSTALL_PREFIX\}/Payload/${ISLE_TARGET_NAME}.app\") + ") +endif() + +install(CODE " + if(IS_DIRECTORY \"\$\{CMAKE_INSTALL_PREFIX\}/bin\" OR IS_DIRECTORY \"\$\{CMAKE_INSTALL_PREFIX\}/lib\" OR EXISTS \"\$\{CMAKE_INSTALL_PREFIX\}/AppIcon.icns\") + execute_process(COMMAND /bin/rm + -rf \"\$\{CMAKE_INSTALL_PREFIX\}/bin\" \"\$\{CMAKE_INSTALL_PREFIX\}/lib\" \"\$\{CMAKE_INSTALL_PREFIX\}/AppIcon.icns\" + ) + endif() +") diff --git a/packaging/ios/isle/Assets.xcassets/AppIcon.appiconset/AppIcon.png b/packaging/ios/isle/Assets.xcassets/AppIcon.appiconset/AppIcon.png new file mode 100644 index 00000000..f51e7069 Binary files /dev/null and b/packaging/ios/isle/Assets.xcassets/AppIcon.appiconset/AppIcon.png differ diff --git a/packaging/ios/isle/Assets.xcassets/AppIcon.appiconset/Contents.json b/packaging/ios/isle/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..ce8e776e --- /dev/null +++ b/packaging/ios/isle/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,36 @@ +{ + "images" : [ + { + "filename" : "AppIcon.png", + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "tinted" + } + ], + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/packaging/ios/isle/Assets.xcassets/Contents.json b/packaging/ios/isle/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/packaging/ios/isle/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/packaging/ios/isle/Info.plist.in b/packaging/ios/isle/Info.plist.in new file mode 100644 index 00000000..714324a3 --- /dev/null +++ b/packaging/ios/isle/Info.plist.in @@ -0,0 +1,86 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${MACOSX_BUNDLE_EXECUTABLE_NAME} + CFBundleGetInfoString + @MACOSX_BUNDLE_INFO_STRING@ + CFBundleIdentifier + @MACOSX_BUNDLE_GUI_IDENTIFIER@ + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + @MACOSX_BUNDLE_LONG_VERSION_STRING@ + CFBundleName + @MACOSX_ISLE_BUNDLE_NAME@ + CFBundleDisplayName + @MACOSX_ISLE_BUNDLE_DISPLAY_NAME@ + CFBundlePackageType + APPL + CFBundleShortVersionString + @MACOSX_BUNDLE_SHORT_VERSION_STRING@ + CFBundleSignature + ???? + CFBundleVersion + @MACOSX_BUNDLE_BUNDLE_VERSION@ + UILaunchStoryboardName + LaunchScreen + NSHighResolutionCapable + + CSResourcesFileMapped + + LSRequires@MACOSX_BUNDLE_REQUIRED_PLATFORM@ + + NSHumanReadableCopyright + @MACOSX_BUNDLE_COPYRIGHT@ + SDL_FILESYSTEM_BASE_DIR_TYPE + resource + NSSupportsAutomaticGraphicsSwitching + + UIApplicationSupportsIndirectInputEvents + + LSSupportsOpeningDocumentsInPlace + + UIFileSharingEnabled + + CADisableMinimumFrameDurationOnPhone + + UIDeviceFamily + + 1 + 2 + + UIRequiresFullScreen + + UIStatusBarHidden + + UISupportedInterfaceOrientations + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + + CFBundleAllowMixedLocalizations + + LSApplicationCategoryType + public.app-category.games + DTPlatformName + iphoneos + UIFileSharingEnabled + + LSSupportsOpeningDocumentsInPlace + + + \ No newline at end of file diff --git a/packaging/ios/isle/LaunchScreen.storyboard b/packaging/ios/isle/LaunchScreen.storyboard new file mode 100644 index 00000000..ad167a8a --- /dev/null +++ b/packaging/ios/isle/LaunchScreen.storyboard @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packaging/linux/flatpak/org.legoisland.Isle.json b/packaging/linux/flatpak/org.legoisland.Isle.json index 178434fa..229ba424 100644 --- a/packaging/linux/flatpak/org.legoisland.Isle.json +++ b/packaging/linux/flatpak/org.legoisland.Isle.json @@ -55,6 +55,11 @@ "path": "../../../miniwin", "dest": "miniwin/" }, + { + "type": "dir", + "path": "../../../extensions", + "dest": "extensions/" + }, { "type": "dir", "path": "../../../packaging", diff --git a/packaging/macos/CMakeLists.txt b/packaging/macos/CMakeLists.txt new file mode 100644 index 00000000..d6e93db8 --- /dev/null +++ b/packaging/macos/CMakeLists.txt @@ -0,0 +1,99 @@ +set(_icon_file AppIcon) +set(MACOSX_BUNDLE_GUI_IDENTIFIER ${APP_ID}) +set(MACOSX_BUNDLE_COPYRIGHT ${APP_SPDX}) +set(ISLE_TARGET_NAME isle) +set(MACOSX_ISLE_BUNDLE_NAME ${APP_NAME}) # Do note that it can be up to 15 characters long +set(MACOSX_ISLE_BUNDLE_DISPLAY_NAME ${APP_NAME}) +set(CONFIG_TARGET_NAME isle-config) +set(MACOSX_CONFIG_BUNDLE_NAME "Config Isle") # Do note that it can be up to 15 characters long +set(MACOSX_CONFIG_BUNDLE_DISPLAY_NAME "Configure ${APP_NAME}") +set(MACOSX_BUNDLE_INFO_STRING ${PROJECT_VERSION}) +set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}) +set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION}) +set(MACOSX_BUNDLE_LONG_VERSION_STRING "Version ${PROJECT_VERSION}") + +# TODO: darwin < 9 +set(MACOSX_BUNDLE_REQUIRED_PLATFORM Carbon) + +set(CPACK_DMG_VOLUME_NAME "Isle Portable") + +if(ISLE_BUILD_APP) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/isle/Info.plist.in" + "${CMAKE_CURRENT_BINARY_DIR}/isle/Info.plist" + @ONLY + ) + set(RESOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/isle/${_icon_file}.icns") + target_sources(${ISLE_TARGET_NAME} PRIVATE ${RESOURCE_FILES}) + set_target_properties(${ISLE_TARGET_NAME} PROPERTIES + MACOSX_BUNDLE TRUE + MACOSX_BUNDLE_ICON_FILE "${_icon_file}.icns" + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_BINARY_DIR}/isle/Info.plist" + RESOURCE ${RESOURCE_FILES}) + install(TARGETS ${ISLE_TARGET_NAME} DESTINATION ./) + install(CODE " + include(BundleUtilities) + fixup_bundle(${CMAKE_BINARY_DIR}/${ISLE_TARGET_NAME}.app \"\" \"\") + " + COMPONENT Runtime) + install(CODE " + execute_process(COMMAND /usr/bin/codesign + --force --deep --sign - --timestamp + \"\$\{CMAKE_INSTALL_PREFIX\}/${ISLE_TARGET_NAME}.app/Contents/MacOS/${ISLE_TARGET_NAME}\") + ") + install(CODE " + file(RENAME + \"\$\{CMAKE_INSTALL_PREFIX\}/${ISLE_TARGET_NAME}.app\" + \"\$\{CMAKE_INSTALL_PREFIX\}/${MACOSX_ISLE_BUNDLE_DISPLAY_NAME}.app\") + ") +endif() +if(ISLE_BUILD_CONFIG) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/config/Info.plist.in" + "${CMAKE_CURRENT_BINARY_DIR}/config/Info.plist" + @ONLY + ) + set(RESOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/config/${_icon_file}.icns") + target_sources(${CONFIG_TARGET_NAME} PRIVATE ${RESOURCE_FILES}) + set_target_properties(${CONFIG_TARGET_NAME} PROPERTIES + MACOSX_BUNDLE TRUE + MACOSX_BUNDLE_ICON_FILE "${_icon_file}.icns" + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_BINARY_DIR}/config/Info.plist" + RESOURCE ${RESOURCE_FILES}) + install(TARGETS ${CONFIG_TARGET_NAME} DESTINATION ./) + install(CODE " + include(BundleUtilities) + fixup_bundle(${CMAKE_BINARY_DIR}/${CONFIG_TARGET_NAME}.app \"\" \"\") + " + COMPONENT Runtime) + qt_generate_deploy_app_script( + TARGET ${CONFIG_TARGET_NAME} + OUTPUT_SCRIPT deploy_script + NO_COMPILER_RUNTIME + NO_TRANSLATIONS + ) + install(SCRIPT "${deploy_script}") + install(CODE " + execute_process(COMMAND /usr/bin/install_name_tool + -add_rpath \"@executable_path/../Frameworks\" + \"\$\{CMAKE_INSTALL_PREFIX\}/${CONFIG_TARGET_NAME}.app/Contents/MacOS/${CONFIG_TARGET_NAME}\") + ") + install(CODE " + execute_process(COMMAND /usr/bin/codesign + --force --deep --sign - --timestamp + \"\$\{CMAKE_INSTALL_PREFIX\}/${CONFIG_TARGET_NAME}.app/Contents/MacOS/${CONFIG_TARGET_NAME}\") + ") + install(CODE " + file(RENAME + \"\$\{CMAKE_INSTALL_PREFIX\}/${CONFIG_TARGET_NAME}.app\" + \"\$\{CMAKE_INSTALL_PREFIX\}/${MACOSX_CONFIG_BUNDLE_DISPLAY_NAME}.app\") + ") +endif() + +install(CODE " + if(IS_DIRECTORY \"\$\{CMAKE_INSTALL_PREFIX\}/bin\" OR IS_DIRECTORY \"\$\{CMAKE_INSTALL_PREFIX\}/lib\" OR EXISTS \"\$\{CMAKE_INSTALL_PREFIX\}/AppIcon.icns\") + execute_process(COMMAND /bin/rm + -rf \"\$\{CMAKE_INSTALL_PREFIX\}/bin\" \"\$\{CMAKE_INSTALL_PREFIX\}/lib\" \"\$\{CMAKE_INSTALL_PREFIX\}/AppIcon.icns\" + ) + endif() +") diff --git a/packaging/macos/config/AppIcon.icns b/packaging/macos/config/AppIcon.icns new file mode 100644 index 00000000..5b67c48a Binary files /dev/null and b/packaging/macos/config/AppIcon.icns differ diff --git a/packaging/macos/config/Info.plist.in b/packaging/macos/config/Info.plist.in new file mode 100644 index 00000000..d128adc0 --- /dev/null +++ b/packaging/macos/config/Info.plist.in @@ -0,0 +1,80 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${MACOSX_BUNDLE_EXECUTABLE_NAME} + CFBundleGetInfoString + @MACOSX_BUNDLE_INFO_STRING@ + CFBundleIconFile + @MACOSX_BUNDLE_ICON_FILE@ + CFBundleIdentifier + @MACOSX_BUNDLE_GUI_IDENTIFIER@ + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + @MACOSX_BUNDLE_LONG_VERSION_STRING@ + CFBundleName + @MACOSX_CONFIG_BUNDLE_NAME@ + CFBundleDisplayName + @MACOSX_CONFIG_BUNDLE_DISPLAY_NAME@ + CFBundlePackageType + APPL + CFBundleShortVersionString + @MACOSX_BUNDLE_SHORT_VERSION_STRING@ + CFBundleSignature + ???? + CFBundleVersion + @MACOSX_BUNDLE_BUNDLE_VERSION@ + UILaunchStoryboardName + LaunchScreen + NSHighResolutionCapable + + CSResourcesFileMapped + + LSRequires@MACOSX_BUNDLE_REQUIRED_PLATFORM@ + + NSHumanReadableCopyright + @MACOSX_BUNDLE_COPYRIGHT@ + SDL_FILESYSTEM_BASE_DIR_TYPE + resource + NSSupportsAutomaticGraphicsSwitching + + UIApplicationSupportsIndirectInputEvents + + LSSupportsOpeningDocumentsInPlace + + UIFileSharingEnabled + + CADisableMinimumFrameDurationOnPhone + + UIDeviceFamily + + 1 + 2 + + UIRequiresFullScreen + + UIStatusBarHidden + + UISupportedInterfaceOrientations + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + + CFBundleAllowMixedLocalizations + + + \ No newline at end of file diff --git a/packaging/macos/isle/AppIcon.icns b/packaging/macos/isle/AppIcon.icns new file mode 100644 index 00000000..61aa735e Binary files /dev/null and b/packaging/macos/isle/AppIcon.icns differ diff --git a/packaging/macos/isle/Info.plist.in b/packaging/macos/isle/Info.plist.in new file mode 100644 index 00000000..2ca3d26e --- /dev/null +++ b/packaging/macos/isle/Info.plist.in @@ -0,0 +1,82 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${MACOSX_BUNDLE_EXECUTABLE_NAME} + CFBundleGetInfoString + @MACOSX_BUNDLE_INFO_STRING@ + CFBundleIconFile + @MACOSX_BUNDLE_ICON_FILE@ + CFBundleIdentifier + @MACOSX_BUNDLE_GUI_IDENTIFIER@ + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + @MACOSX_BUNDLE_LONG_VERSION_STRING@ + CFBundleName + @MACOSX_ISLE_BUNDLE_NAME@ + CFBundleDisplayName + @MACOSX_ISLE_BUNDLE_DISPLAY_NAME@ + CFBundlePackageType + APPL + CFBundleShortVersionString + @MACOSX_BUNDLE_SHORT_VERSION_STRING@ + CFBundleSignature + ???? + CFBundleVersion + @MACOSX_BUNDLE_BUNDLE_VERSION@ + UILaunchStoryboardName + LaunchScreen + NSHighResolutionCapable + + CSResourcesFileMapped + + LSRequires@MACOSX_BUNDLE_REQUIRED_PLATFORM@ + + NSHumanReadableCopyright + @MACOSX_BUNDLE_COPYRIGHT@ + SDL_FILESYSTEM_BASE_DIR_TYPE + resource + NSSupportsAutomaticGraphicsSwitching + + UIApplicationSupportsIndirectInputEvents + + LSSupportsOpeningDocumentsInPlace + + UIFileSharingEnabled + + CADisableMinimumFrameDurationOnPhone + + UIDeviceFamily + + 1 + 2 + + UIRequiresFullScreen + + UIStatusBarHidden + + UISupportedInterfaceOrientations + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + + CFBundleAllowMixedLocalizations + + LSApplicationCategoryType + public.app-category.games + + \ No newline at end of file