├── .editorconfig ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md └── workflows │ └── build_artifacts.yml ├── .gitignore ├── OpenLRR-d.exe ├── OpenLRR.exe ├── README.md ├── data ├── Data │ └── OpenLRR │ │ └── EmptyAudio.avi └── Settings │ └── Shortcuts.cfg ├── lib └── d3drm │ ├── README.md │ ├── d3drm.def │ ├── d3drm.lib │ ├── inc │ ├── d3drm.h │ ├── d3drmdef.h │ ├── d3drmobj.h │ └── d3drmwin.h │ └── undecorate.py ├── openlrr-vscode.code-workspace ├── openlrr.sln ├── resources ├── OpenLRR-Injector.rc ├── OpenLRR.rc ├── logo │ ├── icon-gold.ico │ ├── icon-gold.png │ ├── icon-old.ico │ ├── icon-old.png │ ├── icon-teal-rr.ico │ ├── icon-teal-rr.png │ ├── icon-teal.ico │ ├── icon-teal.png │ ├── icon.ico │ └── icon.png ├── manifest-visualstyles.xml ├── resource-injector.h └── resource.h ├── scripts └── reset_fth.bat └── src ├── openlrr-injector ├── openlrr-injector.cpp └── openlrr-injector.vcxproj ├── openlrr-makeexe ├── README.md ├── common.h ├── openlrr-makeexe.cpp ├── openlrr-makeexe.vcxproj └── pe │ ├── PECommon.h │ ├── PEFile.cpp │ ├── PEFile.h │ ├── PEResources.h │ ├── PESectionStream.cpp │ └── PESectionStream.h └── openlrr ├── OpenLRR.cpp ├── OpenLRR.h ├── cmdline ├── CLGen.cpp ├── CLGen.h ├── CommandLine.cpp └── CommandLine.hpp ├── common.h ├── cpp.hint ├── dllmain.cpp ├── dllmain.h ├── engine ├── Graphics.cpp ├── Graphics.h ├── Init.cpp ├── Init.h ├── Main.cpp ├── Main.h ├── README.md ├── audio │ ├── 3DSound.cpp │ ├── 3DSound.h │ ├── Sound.cpp │ └── Sound.h ├── colour.h ├── core │ ├── Config.cpp │ ├── Config.h │ ├── Errors.cpp │ ├── Errors.h │ ├── Files.cpp │ ├── Files.h │ ├── ListSet.hpp │ ├── Maths.cpp │ ├── Maths.h │ ├── Memory.cpp │ ├── Memory.h │ ├── Random.cpp │ ├── Random.hpp │ ├── Utils.cpp │ ├── Utils.h │ ├── Wad.cpp │ └── Wad.h ├── drawing │ ├── Bmp.cpp │ ├── Bmp.h │ ├── DirectDraw.cpp │ ├── DirectDraw.h │ ├── Draw.cpp │ ├── Draw.h │ ├── Flic.cpp │ ├── Flic.h │ ├── Fonts.cpp │ ├── Fonts.h │ ├── Images.cpp │ ├── Images.h │ ├── TextWindow.cpp │ └── TextWindow.h ├── geometry.h ├── gfx │ ├── Activities.cpp │ ├── Activities.h │ ├── AnimClone.cpp │ ├── AnimClone.h │ ├── Containers.cpp │ ├── Containers.h │ ├── Lws.cpp │ ├── Lws.h │ ├── Lwt.cpp │ ├── Lwt.h │ ├── Materials.cpp │ ├── Materials.h │ ├── Mesh.cpp │ ├── Mesh.h │ ├── Viewports.cpp │ └── Viewports.h ├── input │ ├── Input.cpp │ ├── Input.h │ ├── InputButton.cpp │ ├── InputButton.hpp │ ├── Keys.cpp │ ├── Keys.h │ ├── MouseButtons.cpp │ └── MouseButtons.h ├── undefined.h ├── util │ ├── Compress.cpp │ ├── Compress.h │ ├── Dxbug.cpp │ ├── Dxbug.h │ ├── Registry.cpp │ └── Registry.h └── video │ ├── Animation.cpp │ ├── Animation.h │ ├── Animation.hpp │ ├── Movie.cpp │ ├── Movie.h │ └── Movie.hpp ├── game ├── Debug.cpp ├── Debug.h ├── Game.cpp ├── Game.h ├── GameCommon.h ├── GameState.cpp ├── README.md ├── Shortcuts.cpp ├── Shortcuts.hpp ├── audio │ ├── SFX.cpp │ └── SFX.h ├── effects │ ├── DamageText.cpp │ ├── DamageText.h │ ├── Effects.cpp │ ├── Effects.h │ ├── LightEffects.cpp │ ├── LightEffects.h │ ├── Smoke.cpp │ └── Smoke.h ├── front │ ├── Credits.cpp │ ├── Credits.h │ ├── FrontEnd.cpp │ ├── FrontEnd.h │ ├── Loader.cpp │ ├── Loader.h │ ├── Reward.cpp │ ├── Reward.h │ └── RewardScroll.h ├── interface │ ├── Advisor.cpp │ ├── Advisor.h │ ├── Encyclopedia.cpp │ ├── Encyclopedia.h │ ├── HelpWindow.cpp │ ├── HelpWindow.h │ ├── InfoMessages.cpp │ ├── InfoMessages.h │ ├── Interface.cpp │ ├── Interface.h │ ├── Panels.cpp │ ├── Panels.h │ ├── Pointers.cpp │ ├── Pointers.h │ ├── Priorities.cpp │ ├── Priorities.h │ ├── RadarMap.cpp │ ├── RadarMap.h │ ├── ScrollInfo.cpp │ ├── ScrollInfo.h │ ├── TextMessages.cpp │ ├── TextMessages.h │ ├── ToolTip.cpp │ ├── ToolTip.h │ └── hud │ │ ├── Bubbles.cpp │ │ ├── Bubbles.h │ │ ├── ObjInfo.cpp │ │ └── ObjInfo.h ├── mission │ ├── Messages.cpp │ ├── Messages.h │ ├── NERPsFile.cpp │ ├── NERPsFile.h │ ├── NERPsFunctions.cpp │ ├── NERPsFunctions.h │ ├── NERPsRuntime.cpp │ ├── NERPsRuntime.h │ ├── Objective.cpp │ ├── Objective.h │ ├── PTL.cpp │ ├── PTL.h │ └── Quota.h ├── object │ ├── AITask.cpp │ ├── AITask.h │ ├── BezierCurve.cpp │ ├── BezierCurve.h │ ├── Building.cpp │ ├── Building.h │ ├── Collision.cpp │ ├── Collision.h │ ├── Creature.cpp │ ├── Creature.h │ ├── Dependencies.cpp │ ├── Dependencies.h │ ├── Flocks.cpp │ ├── Flocks.h │ ├── MeshLOD.cpp │ ├── MeshLOD.h │ ├── Object.cpp │ ├── Object.h │ ├── ObjectRecall.cpp │ ├── ObjectRecall.h │ ├── Stats.cpp │ ├── Stats.h │ ├── Upgrade.cpp │ ├── Upgrade.h │ ├── Vehicle.cpp │ ├── Vehicle.h │ ├── Weapons.cpp │ └── Weapons.h └── world │ ├── Camera.cpp │ ├── Camera.h │ ├── Construction.cpp │ ├── Construction.h │ ├── Detail.cpp │ ├── Detail.h │ ├── ElectricFence.cpp │ ├── ElectricFence.h │ ├── Erosion.cpp │ ├── Erosion.h │ ├── Fallin.cpp │ ├── Fallin.h │ ├── Map3D.cpp │ ├── Map3D.h │ ├── Roof.cpp │ ├── Roof.h │ ├── SelectPlace.cpp │ ├── SelectPlace.h │ ├── SpiderWeb.cpp │ ├── SpiderWeb.h │ ├── Teleporter.cpp │ ├── Teleporter.h │ ├── Water.cpp │ └── Water.h ├── hook.cpp ├── hook.h ├── interop.cpp ├── interop.h ├── legacy.cpp ├── legacy.h ├── openlrr.vcxproj └── platform ├── d3drm.cpp ├── d3drm.h ├── ddraw.h ├── dinput.h ├── dsound.h ├── targetver.h ├── timeapi.h ├── vfw.h ├── windows.cpp └── windows.h /.gitattributes: -------------------------------------------------------------------------------- 1 | *.rc text working-tree-encoding=UTF-16LE-BOM eol=CRLF 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the issue** 11 | A clear and concise description of what the bug is. 12 | 13 | **Expected behaviour** 14 | A clear and concise description of what you expected to happen (if it's not an error message, crash or freeze). 15 | 16 | **Steps to reproduce** 17 | If it's possible to trigger this bug in some semi-reliable manner, then list the steps or conditions here. 18 | 19 | Not all bugs are easily reproducible, so describing the state of the game before/when the bug occurred is also helpful. 20 | 21 | **Additional information** 22 | * **Time played this session:** (rough estimate is fine. Time for the level -and- overall if played other levels before this) 23 | * **Level:** (current level being played) 24 | * **Game speed:** (speed when the bug occurred. Vanilla max: 200%, debug max: 300%) 25 | * **Graphics fix:** (dgVoodoo+version -or- DDrawCompat) 26 | * **Using mods:** (names of mods, or rough list of handmade modifications to asset/config files) 27 | 28 | 29 | *** 30 | 31 | **Additional context (optional)** 32 | Add any other context about the problem here. 33 | 34 | **Screenshots (optional)** 35 | If applicable, add screenshots to help explain your problem. 36 | -------------------------------------------------------------------------------- /.github/workflows/build_artifacts.yml: -------------------------------------------------------------------------------- 1 | name: Compile Debug and Release OpenLRR 2 | 3 | on: 4 | push: 5 | paths: 6 | - src/openlrr/** 7 | - resources/** 8 | tags: 'v*' 9 | branches: '**' 10 | 11 | jobs: 12 | Nightly_release_build: 13 | runs-on: windows-latest 14 | steps: 15 | - name: Clone repo 16 | uses: actions/checkout@v3 17 | - name: Add msbuild to PATH 18 | uses: microsoft/setup-msbuild@v1 19 | - name: Build OpenLRR for x86 Release 20 | run: msbuild openlrr.sln /t:openlrr /p:Configuration=Release /p:Platform=x86 21 | - name: Rerrange files to easily use OpenLRR 22 | run: | 23 | mkdir OpenLRR/OpenLRR/ 24 | Move-Item bin/openlrr.dll OpenLRR/OpenLRR/ 25 | Move-Item OpenLRR.exe OpenLRR/OpenLRR/ 26 | Move-Item data/* OpenLRR/OpenLRR/ 27 | - name: Upload OpenLRR Release build 28 | uses: actions/upload-artifact@v3 29 | with: 30 | name: OpenLRR-Release 31 | path: | 32 | OpenLRR/ 33 | 34 | Nightly_debug_build: 35 | runs-on: windows-latest 36 | steps: 37 | - name: Clone repo 38 | uses: actions/checkout@v3 39 | - name: Add msbuild to PATH 40 | uses: microsoft/setup-msbuild@v1 41 | - name: Build OpenLRR for x86 Debug 42 | run: msbuild openlrr.sln /t:openlrr /p:Configuration=Debug /p:Platform=x86 43 | - name: Rerrange files to easily use OpenLRR 44 | run: | 45 | mkdir OpenLRR/OpenLRR/ 46 | Move-Item bin/openlrr-d.dll OpenLRR/OpenLRR/ 47 | Move-Item OpenLRR.exe OpenLRR/OpenLRR/ 48 | Move-Item data/* OpenLRR/OpenLRR/ 49 | - name: Upload OpenLRR Debug build 50 | uses: actions/upload-artifact@v3 51 | with: 52 | name: OpenLRR-Debug 53 | path: | 54 | OpenLRR/ 55 | 56 | Prepare_release: 57 | runs-on: "ubuntu-latest" # Zip action only works on Ubuntu 58 | needs: Nightly_release_build 59 | # Trigger when a new tag is pusht 60 | if: startsWith(github.ref, 'refs/tags/') 61 | steps: 62 | - name: Set tag in env # Extract the pusht tag into a variable for later use 63 | run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV 64 | - name: Get artifact # Faster to download instead of recompile 65 | uses: actions/download-artifact@v2 66 | with: 67 | name: OpenLRR-Release 68 | - name: Zip artifact 69 | uses: montudor/action-zip@v1 70 | with: 71 | args: zip -qq -r OpenLRR-${{ env.RELEASE_VERSION }}.zip OpenLRR/ 72 | - name: Draft Public Release 73 | uses: "softprops/action-gh-release@v1" 74 | with: 75 | name: "Draft Release ${{ env.RELEASE_VERSION }}" 76 | draft: true 77 | files: OpenLRR-${{ env.RELEASE_VERSION }}.zip 78 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ########################################### 2 | ## Added to .gitignore 3 | 4 | # Solution build directory and language-specific build directories 5 | /bin 6 | /bin-* 7 | 8 | 9 | # Lazy method of hiding work-in-progress or local-only files with common extensions 10 | _wip/ 11 | _unused/ 12 | 13 | 14 | ########################################### 15 | ## Visual Studio IDE 16 | 17 | /.vs 18 | *.vcxproj.filters 19 | *.vcxproj.user 20 | *.aps 21 | *.pdb 22 | 23 | 24 | ########################################### 25 | ## Original .gitignore 26 | 27 | # Prerequisites 28 | *.d 29 | 30 | # Compiled Object files 31 | *.slo 32 | *.lo 33 | *.o 34 | *.obj 35 | 36 | # Precompiled Headers 37 | *.gch 38 | *.pch 39 | 40 | # Compiled Dynamic libraries 41 | *.so 42 | *.dylib 43 | *.dll 44 | 45 | # Fortran module files 46 | *.mod 47 | *.smod 48 | 49 | # Compiled Static libraries 50 | *.lai 51 | *.la 52 | *.a 53 | *.lib 54 | 55 | # Executables 56 | #*.exe 57 | *.out 58 | *.app 59 | 60 | 61 | ########################################### 62 | ## Explicit includes 63 | 64 | # Nothing in here 65 | /lib/unused/** 66 | 67 | # Everything in here (d3drm.lib, d3drm.def, inc/*) 68 | !/lib/d3drm/*.def 69 | !/lib/d3drm/*.lib 70 | -------------------------------------------------------------------------------- /OpenLRR-d.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trigger-segfault/OpenLRR/2f6743cfabd40d43024e5d32737c9ff55a05030f/OpenLRR-d.exe -------------------------------------------------------------------------------- /OpenLRR.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trigger-segfault/OpenLRR/2f6743cfabd40d43024e5d32737c9ff55a05030f/OpenLRR.exe -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenLRR ![app icon](resources/logo/icon.png) 2 | 3 | An open source re-implementation of [LEGO Rock Raiders (PC)][Wikipedia_LRR]. This is created by slowly implementing and replacing game functionality, while relying on the original executable and game assets for everything else. 4 | 5 | OpenLRR is not associated with The LEGO Group or Data Design Interactive. When using the name "OpenLRR" within this project, the **L** must never be expanded (i.e. do not write "Open _LEGO_ Rock Raiders"). 6 | 7 | 8 | ## Instructions 9 | 10 | Running OpenLRR requires a working installation of LEGO Rock Raiders, and building in Visual Studio 2019. 11 | 12 | * [Installing LEGO Rock Raiders][Wiki_RunningLRR] 13 | * [Your Master Guide to get LRR to run][Guide_Master] 14 | * [Building and running OpenLRR][Wiki_RunningOpenLRR] 15 | 16 | 17 | ## Contributing 18 | 19 | OpenLRR is still missing documentation to aid in contribution, but submittions and/or help is still encouraged. 20 | 21 | * [Decompilation and research][Wiki_Decompiling] 22 | * Implementing functions and modules in the **game/** folder. 23 | * Improving and refactoring **engine/** code. 24 | * Fixing bugs or implementing new features (please create an Issue if one doesn't exist). 25 | 26 | Submitting decompiled functions for game code is a very involved process. Most game module functions, structures, and enums are still going through heavy refactoring and renaming, with most names not accurately describing their purpose. However, assigning more-accurate names is **not required**. 27 | 28 | 29 | 30 | *** 31 | 32 | ## See also 33 | 34 | * [Rock Raiders United][Page_RRU] 35 | * [RRU: Knowledge Base][Page_RRUKB] 36 | 37 | ### Other LRR projects 38 | 39 | * [Manic Miners][Project_ManicMiners] 40 | * [ProjectReversio/LegoRockRaiders][Project_ProjectReversio] 41 | 42 | ### Similar open source projects 43 | 44 | * [OpenRCT2][Project_OpenRCT2] 45 | * [OpenTTD][Project_OpenTTD] 46 | 47 | 48 | 49 | 50 | 51 | [Page_RRU]: "Rock Raiders United" 52 | [Page_RRUKB]: "Rock Raiders United: Knowledge Base" 53 | 54 | [Project_ManicMiners]: "Manic Miners: The Rock Raiders remake" 55 | [Project_RRX]: "Rock Raiders X - Rock Raiders recreated - This site is gone!" 56 | [Project_ProjectReversio]: "ProjectReversio/LegoRockRaiders: Decompiling and implementing LRR from the top down" 57 | 58 | [Project_OpenRCT2]: "An open source re-implementation of RollerCoaster Tycoon 2" 59 | [Project_OpenTTD]: "An open source simulation game based upon Transport Tycoon Deluxe" 60 | 61 | [Wikipedia_LRR]: "Wikipedia: LEGO Rock Raiders (PC)" 62 | [Guide_Master]: "Your Master Guide to get LRR to run" 63 | [Guide_MusicFix]: "Rock Raiders Music without CD Fix" 64 | 65 | [Wiki_RunningLRR]: "OpenLRR Wiki: Running LEGO Rock Raiders" 66 | [Wiki_RunningOpenLRR]: "OpenLRR Wiki: Running OpenLRR" 67 | [Wiki_Decompiling]: "OpenLRR Wiki: Decompiling LEGO Rock Raiders" 68 | -------------------------------------------------------------------------------- /data/Data/OpenLRR/EmptyAudio.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trigger-segfault/OpenLRR/2f6743cfabd40d43024e5d32737c9ff55a05030f/data/Data/OpenLRR/EmptyAudio.avi -------------------------------------------------------------------------------- /lib/d3drm/README.md: -------------------------------------------------------------------------------- 1 | # Generating D3DRM.lib 2 | 3 | Although the `D3DRM.lib` file is already provided, instructions for how to re-generate it are included below. 4 | 5 | In order to generate a usable `.lib` file for `D3DRM.dll`, you'll need the following: 6 | 7 | * `D3DRM.dll` *(provided in `../bin/`)* 8 | * Visual Studio Developer command prompt 9 | * Hex editor 10 | 11 | The primary issue is the common `undecorated` name type that you need to work with Microsoft DLLs. The `lib.exe` utility is not able to generate this name type. However, this can actually be solved by a quick hex edit for the flags byte that determines this name type (and other fields). 12 | 13 | ## Steps 14 | 15 | 1. The `.def` file was initially created using [this StackOverflow answer](https://stackoverflow.com/questions/9360280/how-to-make-a-lib-file-when-have-a-dll-file-and-a-header-file/16127548#16127548). 16 | 2. The `@#` postfixes for each method were copy-pasted off of another existing `d3drm.lib` file found on GitHub, however they can be determined by hand, based on the amount of bytes passed as arguments onto the stack. `Direct3DRMCreate` is currently the only function we need access to, and is such the only function we need to worry about getting right. 17 | 3. Use the command `lib /def:d3drm.def /machine:x86 /out:d3drm.lib` in the VS Dev Command Prompt to generate the initial `.lib` file. 18 | 4. Once generated, open up the file in a hex editor and navigate down to the final usage of the required function names: `_Direct3DRMCreate@4`. 19 | 5. Two bytes before the underscore `_` will be the byte `08`, which determines the name type and other flags. Change this value to `0C` to get an `undecorated` function name type. This has to be done for all functions you plan on using in the DLL. 20 | 6. That's all, no extra Visual C DLL project required! :D 21 | -------------------------------------------------------------------------------- /lib/d3drm/d3drm.def: -------------------------------------------------------------------------------- 1 | LIBRARY d3drm.dll 2 | EXPORTS 3 | D3DRMColorGetAlpha@4 4 | D3DRMColorGetBlue@4 5 | D3DRMColorGetGreen@4 6 | D3DRMColorGetRed@4 7 | D3DRMCreateColorRGB@12 8 | D3DRMCreateColorRGBA@16 9 | D3DRMMatrixFromQuaternion@8 10 | D3DRMQuaternionFromRotation@12 11 | D3DRMQuaternionMultiply@12 12 | D3DRMQuaternionSlerp@16 13 | D3DRMVectorAdd@12 14 | D3DRMVectorCrossProduct@12 15 | D3DRMVectorDotProduct@8 16 | D3DRMVectorModulus@4 17 | D3DRMVectorNormalize@4 18 | D3DRMVectorRandom@4 19 | D3DRMVectorReflect@12 20 | D3DRMVectorRotate@16 21 | D3DRMVectorScale@12 22 | D3DRMVectorSubtract@12 23 | Direct3DRMCreate@4 -------------------------------------------------------------------------------- /lib/d3drm/d3drm.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trigger-segfault/OpenLRR/2f6743cfabd40d43024e5d32737c9ff55a05030f/lib/d3drm/d3drm.lib -------------------------------------------------------------------------------- /lib/d3drm/inc/d3drmwin.h: -------------------------------------------------------------------------------- 1 | /*==========================================================================; 2 | * 3 | * Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved. 4 | * 5 | * File: d3drm.h 6 | * Content: Direct3DRM include file 7 | * 8 | ***************************************************************************/ 9 | 10 | #ifndef __D3DRMWIN_H__ 11 | #define __D3DRMWIN_H__ 12 | 13 | #ifndef WIN32 14 | #define WIN32 15 | #endif 16 | 17 | #include "d3drm.h" 18 | 19 | #include 20 | #include 21 | 22 | /* 23 | * GUIDS used by Direct3DRM Windows interface 24 | */ 25 | DEFINE_GUID(IID_IDirect3DRMWinDevice, 0xc5016cc0, 0xd273, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1); 26 | 27 | WIN_TYPES(IDirect3DRMWinDevice, DIRECT3DRMWINDEVICE); 28 | 29 | #undef INTERFACE 30 | #define INTERFACE IDirect3DRMWinDevice 31 | 32 | DECLARE_INTERFACE_(IDirect3DRMWinDevice, IDirect3DRMObject) 33 | { 34 | IUNKNOWN_METHODS(PURE); 35 | IDIRECT3DRMOBJECT_METHODS(PURE); 36 | 37 | /* 38 | * IDirect3DRMWinDevice methods 39 | */ 40 | 41 | /* Repaint the window with the last frame which was rendered. */ 42 | STDMETHOD(HandlePaint)(THIS_ HDC hdc) PURE; 43 | 44 | /* Respond to a WM_ACTIVATE message. */ 45 | STDMETHOD(HandleActivate)(THIS_ WORD wparam) PURE; 46 | }; 47 | 48 | 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /openlrr-vscode.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | 8 | "settings": { 9 | // It's best to enforce tabs when browsing full decompiled Ghidra program exports (?) 10 | "[c|cpp]": { 11 | "editor.useTabStops": true, 12 | "editor.tabSize": 4, 13 | "files.eol": "\n" 14 | }, 15 | 16 | // Visual Studio project files (stay consistent with existing standards) 17 | "[xml]": { 18 | "editor.useTabStops": false, 19 | "editor.tabSize": 2, 20 | "files.eol": "\r\n" 21 | }, 22 | 23 | // Visual Studio Code workspace file 24 | "[json|jsonc]": { 25 | "editor.useTabStops": false, 26 | "editor.tabSize": 2, 27 | "files.eol": "\n" 28 | }, 29 | 30 | 31 | // NOTE: Cafeteria expects CRLF line endings for mod-script and cfg-like files 32 | "[plaintext]": { 33 | "files.eol": "\r\n" 34 | }, 35 | 36 | // Custom VSCode syntax highlighting for Lego.cfg 37 | // 38 | "[lrr-lego-cfg]": { 39 | "editor.useTabStops": true, 40 | "editor.tabSize": 4, 41 | "files.eol": "\r\n" 42 | }, 43 | // Custom VSCode syntax highlighting for CLGen.dat (purely fluff, and not required) 44 | "[lrr-clgen]": { 45 | // NOTE: CLGen.dat shouldn't have any indentation... at all. 46 | // This setting is a lazy way of forcing the user to notice. 47 | "editor.useTabStops": false, 48 | "editor.tabSize": 1, 49 | "files.eol": "\r\n" 50 | }, 51 | 52 | // For those realllly long lines 53 | "editor.wordWrap": "on", 54 | 55 | //////////////////////////////////////////////////// 56 | // Extra file associations 57 | 58 | "files.associations": { 59 | // Visual studio other project xml files (automatically handled) 60 | //"*.vcxproj.filters": "xml", 61 | //"*.vcxproj.user": "xml", 62 | 63 | // Visual Studio resource file 64 | "*.rc": "c", 65 | // Visual Studio C++ macros hint file 66 | "cpp.hint": "cpp", 67 | // Executable manifest file (or use .xml extension) 68 | "*.manifest": "xml", 69 | 70 | //////////////////////////////////////////////////// 71 | // Cafeteria mod script file (for reference only) 72 | //"script.txt": "plaintext", 73 | 74 | //////////////////////////////////////////////////// 75 | // LEGORR: All file format extensions (for reference only) 76 | // TEXT FORMATS // 77 | //"*.cfg": "lrr-lego-cfg", // Main game configuration file 78 | //"*.ae": "lrr-lego-cfg", // Main game configuration file 79 | //"*.ol": "lrr-lego-cfg", // Main game configuration file 80 | //"*.ptl": "lrr-lego-cfg", // Main game configuration file 81 | //"CLGen.dat": "lrr-clgen", // "Command-line Generator config file (purely fluff, and not required) 82 | //"*.nrm": "plaintext", // NERPs processed source file 83 | //"*.nrn": "c", // NERPs C original source file 84 | //"nerpnrn.h": "c", // NERPs standard header include file 85 | //"*.LEV": "plaintext", // (old) level map file list 86 | //"*.lws": "plaintext", // LightWave scene file 87 | //"*.uv": "plaintext", // Texture UV file(?) 88 | //"*.x": "plaintext", // Mesh file 89 | //"*.epb": "plaintext", // Encyclopedia text information 90 | //"LoaderProfile.txt": "plaintext", // List the number of bytes loaded per section (for loading bar) 91 | //"LoaderProfileNoSound.txt": "plaintext", // LoaderProfile when -nosound option is used 92 | 93 | // BINARY FORMATS // 94 | //"*.blk": "raw", // DDI's map editor: (old) 16-bit icons for specified map type 95 | //"*.blx": "raw", // DDI's map editor: (new) 16-bit icons for specified map type 96 | //"*.map": "raw", // Map data of a specified type 97 | //"*.npl": "raw", // NERPs compiled bytecode 98 | //"*.osf": "raw", // Object Recall save data 99 | //"[0-5].dat": "raw", // Save data thumbnail (BMP with a different extension) 100 | //"[0-5].sav": "raw", // Save data game information 101 | //"*.flh": "raw", // AutoDesk Flic animation file 102 | //"*.lwo": "raw", // LightWave object file 103 | //"*.wad": "raw", // WAD file archive 104 | //"*.wadp": "raw", // WAD patch file archive (for Cafeteria, same format as .wad) 105 | //"cd.key": "raw", // File that just needs to exist for CD detection. Contents: `DE AD` 106 | //"LegoRR.icd": "raw", // SafeDisc DRM executable binary 107 | }, 108 | 109 | //////////////////////////////////////////////////// 110 | // VSCode Extensions Configuration 111 | 112 | // [vscode-ext-color-highlight] 113 | "color-highlight.enable": true, 114 | 115 | } 116 | } -------------------------------------------------------------------------------- /openlrr.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31205.134 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openlrr", "src\openlrr\openlrr.vcxproj", "{9F8362B3-B3FF-4FC3-B98E-8AB77FA17583}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openlrr-injector", "src\openlrr-injector\openlrr-injector.vcxproj", "{1BE20375-38A4-401C-BA11-56E896EDD3BE}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tool", "tool", "{3AF1EC63-71C6-43A8-AD2E-6D26241389BC}" 11 | EndProject 12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E0240447-9D12-43B1-9CAF-9C18B2B2CBAC}" 13 | ProjectSection(SolutionItems) = preProject 14 | .editorconfig = .editorconfig 15 | EndProjectSection 16 | EndProject 17 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openlrr-makeexe", "src\openlrr-makeexe\openlrr-makeexe.vcxproj", "{BD87B4F1-E346-4CFF-891D-D1C0A0DF0B72}" 18 | EndProject 19 | Global 20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 21 | Debug|x64 = Debug|x64 22 | Debug|x86 = Debug|x86 23 | Release|x64 = Release|x64 24 | Release|x86 = Release|x86 25 | EndGlobalSection 26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 27 | {9F8362B3-B3FF-4FC3-B98E-8AB77FA17583}.Debug|x64.ActiveCfg = Debug|x64 28 | {9F8362B3-B3FF-4FC3-B98E-8AB77FA17583}.Debug|x64.Build.0 = Debug|x64 29 | {9F8362B3-B3FF-4FC3-B98E-8AB77FA17583}.Debug|x86.ActiveCfg = Debug|Win32 30 | {9F8362B3-B3FF-4FC3-B98E-8AB77FA17583}.Debug|x86.Build.0 = Debug|Win32 31 | {9F8362B3-B3FF-4FC3-B98E-8AB77FA17583}.Release|x64.ActiveCfg = Release|x64 32 | {9F8362B3-B3FF-4FC3-B98E-8AB77FA17583}.Release|x64.Build.0 = Release|x64 33 | {9F8362B3-B3FF-4FC3-B98E-8AB77FA17583}.Release|x86.ActiveCfg = Release|Win32 34 | {9F8362B3-B3FF-4FC3-B98E-8AB77FA17583}.Release|x86.Build.0 = Release|Win32 35 | {1BE20375-38A4-401C-BA11-56E896EDD3BE}.Debug|x64.ActiveCfg = Debug|x64 36 | {1BE20375-38A4-401C-BA11-56E896EDD3BE}.Debug|x64.Build.0 = Debug|x64 37 | {1BE20375-38A4-401C-BA11-56E896EDD3BE}.Debug|x86.ActiveCfg = Debug|Win32 38 | {1BE20375-38A4-401C-BA11-56E896EDD3BE}.Debug|x86.Build.0 = Debug|Win32 39 | {1BE20375-38A4-401C-BA11-56E896EDD3BE}.Release|x64.ActiveCfg = Release|x64 40 | {1BE20375-38A4-401C-BA11-56E896EDD3BE}.Release|x64.Build.0 = Release|x64 41 | {1BE20375-38A4-401C-BA11-56E896EDD3BE}.Release|x86.ActiveCfg = Release|Win32 42 | {1BE20375-38A4-401C-BA11-56E896EDD3BE}.Release|x86.Build.0 = Release|Win32 43 | {BD87B4F1-E346-4CFF-891D-D1C0A0DF0B72}.Debug|x64.ActiveCfg = Debug|x64 44 | {BD87B4F1-E346-4CFF-891D-D1C0A0DF0B72}.Debug|x64.Build.0 = Debug|x64 45 | {BD87B4F1-E346-4CFF-891D-D1C0A0DF0B72}.Debug|x86.ActiveCfg = Debug|Win32 46 | {BD87B4F1-E346-4CFF-891D-D1C0A0DF0B72}.Debug|x86.Build.0 = Debug|Win32 47 | {BD87B4F1-E346-4CFF-891D-D1C0A0DF0B72}.Release|x64.ActiveCfg = Release|x64 48 | {BD87B4F1-E346-4CFF-891D-D1C0A0DF0B72}.Release|x64.Build.0 = Release|x64 49 | {BD87B4F1-E346-4CFF-891D-D1C0A0DF0B72}.Release|x86.ActiveCfg = Release|Win32 50 | {BD87B4F1-E346-4CFF-891D-D1C0A0DF0B72}.Release|x86.Build.0 = Release|Win32 51 | EndGlobalSection 52 | GlobalSection(SolutionProperties) = preSolution 53 | HideSolutionNode = FALSE 54 | EndGlobalSection 55 | GlobalSection(NestedProjects) = preSolution 56 | {1BE20375-38A4-401C-BA11-56E896EDD3BE} = {3AF1EC63-71C6-43A8-AD2E-6D26241389BC} 57 | {BD87B4F1-E346-4CFF-891D-D1C0A0DF0B72} = {3AF1EC63-71C6-43A8-AD2E-6D26241389BC} 58 | EndGlobalSection 59 | GlobalSection(ExtensibilityGlobals) = postSolution 60 | SolutionGuid = {35E953ED-7822-427B-973C-4510249856B3} 61 | EndGlobalSection 62 | EndGlobal 63 | -------------------------------------------------------------------------------- /resources/OpenLRR-Injector.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trigger-segfault/OpenLRR/2f6743cfabd40d43024e5d32737c9ff55a05030f/resources/OpenLRR-Injector.rc -------------------------------------------------------------------------------- /resources/OpenLRR.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trigger-segfault/OpenLRR/2f6743cfabd40d43024e5d32737c9ff55a05030f/resources/OpenLRR.rc -------------------------------------------------------------------------------- /resources/logo/icon-gold.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trigger-segfault/OpenLRR/2f6743cfabd40d43024e5d32737c9ff55a05030f/resources/logo/icon-gold.ico -------------------------------------------------------------------------------- /resources/logo/icon-gold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trigger-segfault/OpenLRR/2f6743cfabd40d43024e5d32737c9ff55a05030f/resources/logo/icon-gold.png -------------------------------------------------------------------------------- /resources/logo/icon-old.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trigger-segfault/OpenLRR/2f6743cfabd40d43024e5d32737c9ff55a05030f/resources/logo/icon-old.ico -------------------------------------------------------------------------------- /resources/logo/icon-old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trigger-segfault/OpenLRR/2f6743cfabd40d43024e5d32737c9ff55a05030f/resources/logo/icon-old.png -------------------------------------------------------------------------------- /resources/logo/icon-teal-rr.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trigger-segfault/OpenLRR/2f6743cfabd40d43024e5d32737c9ff55a05030f/resources/logo/icon-teal-rr.ico -------------------------------------------------------------------------------- /resources/logo/icon-teal-rr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trigger-segfault/OpenLRR/2f6743cfabd40d43024e5d32737c9ff55a05030f/resources/logo/icon-teal-rr.png -------------------------------------------------------------------------------- /resources/logo/icon-teal.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trigger-segfault/OpenLRR/2f6743cfabd40d43024e5d32737c9ff55a05030f/resources/logo/icon-teal.ico -------------------------------------------------------------------------------- /resources/logo/icon-teal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trigger-segfault/OpenLRR/2f6743cfabd40d43024e5d32737c9ff55a05030f/resources/logo/icon-teal.png -------------------------------------------------------------------------------- /resources/logo/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trigger-segfault/OpenLRR/2f6743cfabd40d43024e5d32737c9ff55a05030f/resources/logo/icon.ico -------------------------------------------------------------------------------- /resources/logo/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trigger-segfault/OpenLRR/2f6743cfabd40d43024e5d32737c9ff55a05030f/resources/logo/icon.png -------------------------------------------------------------------------------- /resources/manifest-visualstyles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /resources/resource-injector.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | 4 | 5 | ///////////////////////////////////////////////////////////////////// 6 | // Used by openlrr-injector.rc 7 | // 8 | #define IDI_OPENLRR 105 9 | 10 | 11 | ///////////////////////////////////////////////////////////////////// 12 | // Next default values for new objects 13 | // 14 | #ifdef APSTUDIO_INVOKED 15 | #ifndef APSTUDIO_READONLY_SYMBOLS 16 | #define _APS_NEXT_RESOURCE_VALUE 101 17 | #define _APS_NEXT_COMMAND_VALUE 40001 18 | #define _APS_NEXT_CONTROL_VALUE 1001 19 | #define _APS_NEXT_SYMED_VALUE 101 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /scripts/reset_fth.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | :: Reset Windows FTH (Fault Tolerant Heap) to disable crash prevention when testing OpenLRR. 3 | :: This must be run as an administrator. 4 | :: 5 | 6 | :: If you see the following message while debugging in Visual Studio, 7 | :: then FTH has been activated and must be disabled again: 8 | :: "Fault tolerant heap shim applied to current process. This is usually due to previous crashes" 9 | 10 | Rundll32.exe fthsvc.dll,FthSysprepSpecialize 11 | -------------------------------------------------------------------------------- /src/openlrr-makeexe/README.md: -------------------------------------------------------------------------------- 1 | # OpenLRR-MakeExe 2 | 3 | Tool to generate `OpenLRR.exe` for distribution and attaching to the VS Debugger. 4 | 5 | 6 | ### Usage 7 | 8 | ```cmd 9 | Create an OpenLRR executable from a LegoRR masterpiece executable. 10 | usage: OpenLRR-MakeExe [-h] [-d] [ICOFILE] 11 | 12 | arguments: 13 | -h,--help Show this help message 14 | -d,--debug Output a debug executable that imports a debug build of OpenLRR 15 | "OpenLRR-d.exe" and "openlrr-d.dll" 16 | LEGORREXE Filepath to LegoRR masterpiece executable 17 | ICOFILE Optional filepath to replacement icon 18 | Currently only supports same dimensions/bit-depth 19 | 20 | 21 | Output file is written to working directory as "OpenLRR.exe" or "OpenLRR-d.exe". 22 | ``` 23 | 24 | 25 | *** 26 | 27 | ## Steps 28 | 29 | The goal is to import the OpenLRR codebase contained in `openlrr.dll`, and replace the original `LegoRR.exe!WinMain` entrypoint with a call to `openlrr.dll!StartOpenLRR`. 30 | 31 | 1. Insert a new Import Directory PE section (`.idata2`) after `.idata` and before the final section `.rsrc`. 32 | 2. Append a new import for `openlrr.dll` and include the function `StartOpenLRR`. 33 | 3. Overwrite `LegoRR.exe!WinMain` with a call to `int __cdecl openlrr.dll!StartOpenLRR` that pushes the same 4 parameters, then cleans up the stack and returns (register `EBP` must be preserved). 34 | 4. Update the Import and Resource directory RVAs to point to their new location. 35 | 5. Update the address offsets within `.rsrc` to match their new location. 36 | 6. Replace the main icon resource with *"teal-OR"* and include any other desired resources. 37 | 38 | **Note:** The reason `.idata2` isn't being appended after `.rsrc` is so that anyone can freely modify executable resources without potentially breaking our hook into `openlrr.dll!StartOpenLRR`. This ensures our import will be placed in a fixed position that won't unexpectedly change. 39 | 40 | 41 | *** 42 | 43 | ### PE fields of importance 44 | 45 | #### Fields to read 46 | 47 | * OPTIONAL HEADER: FileAlignment 48 | * OPTIONAL HEADER: VirtualAlignment 49 | 50 | 51 | #### Fields to modify 52 | 53 | * FILE HEADER: NumberOfSections (+1 for `.idata2`) 54 | * OPTIONAL HEADER: SizeOfInitializedData (+file size diff of `.rsrc`, round up to file alignment) 55 | * OPTIONAL HEADER: SizeOfImage (+virtual size diff of `.rsrc`, and +virtual size of `.idata2`, round up to virtual alignment) 56 | * DATA DIRECTORY\[1\] Import directory 57 | * VirtualAddress (change to address of `.idata2`) 58 | * Size (+0x14 for added dll import `openlrr.dll`) 59 | * DATA DIRECTORY\[2\] Resource directory 60 | * VirtualAddress (+offset in address caused by `.idata2`) 61 | * Size (+file size diff of `.rscr`) 62 | 63 | -------------------------------------------------------------------------------- /src/openlrr-makeexe/common.h: -------------------------------------------------------------------------------- 1 | // common.h : Include file for standard C runtime include files, 2 | // or project specific include files. 3 | // 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | 20 | ///////////////////////////////////////////////////////////////////// 21 | // Undefines 22 | 23 | // Undefined windows.h macros that would replace std:: functions. 24 | #ifdef min 25 | #undef min 26 | #endif 27 | #ifdef max 28 | #undef max 29 | #endif 30 | 31 | 32 | ///////////////////////////////////////////////////////////////////// 33 | // Missing defines 34 | 35 | // Define if window.h is not included. 36 | #ifndef OUT 37 | #define OUT 38 | #endif 39 | 40 | #ifndef IN 41 | #define IN 42 | #endif 43 | 44 | #ifndef OPTIONAL 45 | #define OPTIONAL 46 | #endif 47 | 48 | 49 | ///////////////////////////////////////////////////////////////////// 50 | // Macro functions 51 | 52 | // (secondary macro needed for macro expansion) 53 | #define nameof_(symbol) #symbol 54 | #define nameof(symbol) nameof_(symbol) 55 | 56 | #define tstrsizeof(s) ((_tcslen((s)) + 1) * sizeof(TCHAR)) 57 | 58 | 59 | ///////////////////////////////////////////////////////////////////// 60 | // Typedefs 61 | 62 | using tstring = std::basic_string; 63 | 64 | typedef char ascii; 65 | 66 | -------------------------------------------------------------------------------- /src/openlrr-makeexe/pe/PEResources.h: -------------------------------------------------------------------------------- 1 | // PEResources.h : (unused) 2 | // 3 | 4 | #pragma once 5 | 6 | #include "PECommon.h" 7 | 8 | 9 | namespace PE 10 | {; // !<--- 11 | 12 | ///////////////////////////////////////////////////////////////////// 13 | // Forward declarations 14 | 15 | struct ResourceDirectory; 16 | struct ResourceEntry; 17 | 18 | 19 | ///////////////////////////////////////////////////////////////////// 20 | // Structures 21 | 22 | struct ResourceEntry 23 | { 24 | IMAGE_RESOURCE_DIRECTORY_ENTRY entry; 25 | std::shared_ptr subDirectory; 26 | IMAGE_RESOURCE_DATA_ENTRY data; 27 | }; 28 | 29 | struct ResourceDirectory 30 | { 31 | IMAGE_RESOURCE_DIRECTORY directory; 32 | std::vector entries; 33 | }; 34 | 35 | struct ResourceId 36 | { 37 | uint16_t Id; 38 | std::string Name; 39 | bool NameIsString; 40 | 41 | ResourceId() : Id(0), Name(), NameIsString(false) 42 | { 43 | } 44 | ResourceId(const ResourceEntry& entry) : Id(0), Name(), NameIsString(entry.entry.NameIsString) 45 | { 46 | assert(entry.entry.NameIsString == 0); // Names not supported 47 | this->Id = entry.entry.Id; 48 | this->Name = ""; 49 | this->NameIsString = (entry.entry.NameIsString != 0); 50 | } 51 | }; 52 | 53 | struct Resource 54 | { 55 | ResourceId Type; 56 | ResourceId Name; 57 | ResourceId Lang; 58 | uint32_t OffsetToData; 59 | uint32_t Size; 60 | uint32_t CodePage; 61 | }; 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/openlrr-makeexe/pe/PESectionStream.cpp: -------------------------------------------------------------------------------- 1 | // PESectionStream.cpp : PE class definition for reading and writing section buffers. 2 | // 3 | 4 | #include "PEFile.h" 5 | 6 | #include "PESectionStream.h" 7 | 8 | 9 | ///////////////////////////////////////////////////////////////////// 10 | // Classes 11 | 12 | PE::PESectionStream::PESectionStream(PESectionSPtr section, bool expandable) 13 | : m_section(section), m_position(0), m_expandable(expandable) 14 | { 15 | if (m_section == nullptr) 16 | throw std::exception("section cannot be null"); 17 | } 18 | PE::PESectionStream::PESectionStream(PEFile& pefile, const std::string& name, bool expandable) 19 | : m_section(nullptr), m_position(0), m_expandable(expandable) 20 | { 21 | m_section = pefile.GetSection(name); 22 | if (m_section == nullptr) 23 | throw std::exception("section with name not found"); 24 | } 25 | 26 | 27 | #pragma region Stream I/O 28 | 29 | sectionoff32_t PE::PESectionStream::Tell() const 30 | { 31 | return m_position; 32 | } 33 | 34 | void PE::PESectionStream::Seek(sectionoff_t offset, int32_t origin) 35 | { 36 | sectionoff_t length = this->Length(); 37 | switch (origin) { 38 | case SEEK_SET: break; // do nothing 39 | case SEEK_CUR: offset += m_position; break; 40 | case SEEK_END: offset += length; break; 41 | } 42 | 43 | if (offset < 0) 44 | offset = 0; 45 | else if (offset > length) { 46 | if (!m_expandable) { 47 | // Only cap offset when not expandable. 48 | offset = length; 49 | } 50 | else { 51 | // Otherwise support resizing buffer to fit offset. 52 | this->SetLength(offset); 53 | } 54 | } 55 | 56 | m_position = offset; 57 | } 58 | 59 | bool PE::PESectionStream::IsEOF() const 60 | { 61 | return m_position >= this->Length(); 62 | } 63 | 64 | int32_t PE::PESectionStream::GetC() 65 | { 66 | if (m_position >= this->Length()) 67 | return EOF; 68 | 69 | uint8_t cByte; 70 | this->Read(&cByte, sizeof(cByte)); 71 | return cByte; 72 | } 73 | 74 | int32_t PE::PESectionStream::PutC(int32_t c) 75 | { 76 | uint8_t cByte = (uint8_t)c; 77 | this->Write(&cByte, sizeof(cByte)); 78 | return cByte; 79 | } 80 | 81 | size32_t PE::PESectionStream::Read(OUT void* buffer, size32_t size) 82 | { 83 | if (m_position < 0 || m_position + size > this->Length()) 84 | throw std::exception("section read failed"); 85 | 86 | std::memcpy(buffer, m_section->Data.data() + m_position, size); 87 | m_position += size; 88 | return size; 89 | } 90 | 91 | size32_t PE::PESectionStream::Write(const void* buffer, size32_t size) 92 | { 93 | if (m_position < 0) 94 | throw std::exception("section write failed"); 95 | if (m_position + size > this->Length()) { 96 | if (!m_expandable) 97 | throw std::exception("section write failed"); 98 | 99 | // Otherwise resize our buffer. 100 | this->SetLength(m_position + size); 101 | } 102 | 103 | std::memcpy(m_section->Data.data() + m_position, buffer, size); 104 | m_position += size; 105 | return size; 106 | } 107 | 108 | #pragma endregion 109 | 110 | #pragma region Extended stream I/O 111 | 112 | std::string PE::PESectionStream::ReadCString() 113 | { 114 | std::string str = ""; 115 | int32_t c; 116 | while ((c = this->GetC()) != EOF && c != '\0') 117 | str.append(1, (char)c); 118 | return str.c_str(); 119 | } 120 | 121 | size32_t PE::PESectionStream::WriteCString(const std::string& str) 122 | { 123 | return Write(str.c_str(), str.length() + 1); 124 | } 125 | 126 | size32_t PE::PESectionStream::Length() const 127 | { 128 | return (size32_t)m_section->Data.size(); 129 | } 130 | 131 | void PE::PESectionStream::SetLength(size32_t newLength) 132 | { 133 | int32_t diff = (int32_t)(newLength - this->Length()); 134 | m_section->Data.resize(newLength); 135 | m_section->Header.SizeOfRawData += diff; 136 | m_section->Header.VirtualSize += diff; 137 | } 138 | 139 | #pragma endregion 140 | -------------------------------------------------------------------------------- /src/openlrr-makeexe/pe/PESectionStream.h: -------------------------------------------------------------------------------- 1 | // PESectionStream.h : PE class declaration for reading and writing section buffers. 2 | // 3 | 4 | #pragma once 5 | 6 | #include "PECommon.h" 7 | #include "PEFile.h" 8 | 9 | 10 | namespace PE 11 | {; // !<--- 12 | 13 | ///////////////////////////////////////////////////////////////////// 14 | // Classes 15 | 16 | class PESectionStream 17 | { 18 | private: 19 | PESectionSPtr m_section; 20 | sectionoff32_t m_position; 21 | bool m_expandable; 22 | 23 | 24 | public: 25 | PESectionStream(PESectionSPtr section, bool expandable = false); 26 | PESectionStream(PEFile& pefile, const std::string& name, bool expandable = false); 27 | 28 | 29 | #pragma region Accessors/Mutators 30 | 31 | inline PE::PESectionSPtr Section() noexcept { return m_section; } 32 | 33 | // Shorthand for Section()->Name() 34 | inline std::string Name() const { m_section->Name(); } 35 | 36 | // True if writing past the section size will increase the buffer size to make room. 37 | constexpr bool IsExpandable() const noexcept { return m_expandable; } 38 | constexpr void SetExpandable(bool expandable) noexcept { m_expandable = expandable; } 39 | 40 | #pragma endregion 41 | 42 | #pragma region Address I/O conversion 43 | 44 | inline address32_t TellAddress(const PEFile& pefile) const 45 | { 46 | return pefile.RVA2Address(this->TellRVA()); 47 | } 48 | 49 | inline rva32_t TellRVA() const 50 | { 51 | return m_section->Section2RVA(this->Tell()); 52 | } 53 | 54 | inline fileoff32_t TellFile() const 55 | { 56 | return m_section->Section2File(this->Tell()); 57 | } 58 | 59 | inline sectionoff32_t TellSection() const 60 | { 61 | return this->Tell(); 62 | } 63 | 64 | inline void SeekAddress(const PEFile& pefile, address_t address) 65 | { 66 | this->SeekRVA(pefile.Address2RVA(address)); 67 | } 68 | 69 | inline void SeekRVA(rva_t rva) 70 | { 71 | this->Seek(m_section->RVA2Section(rva), SEEK_SET); 72 | } 73 | 74 | inline void SeekFile(fileoff_t fileOffset) 75 | { 76 | this->Seek(m_section->File2Section(fileOffset), SEEK_SET); 77 | } 78 | 79 | inline void SeekSection(sectionoff_t sectionOffset) 80 | { 81 | this->Seek(sectionOffset, SEEK_SET); 82 | } 83 | 84 | #pragma endregion 85 | 86 | #pragma region Stream I/O 87 | 88 | sectionoff32_t Tell() const; 89 | 90 | void Seek(sectionoff_t offset, int32_t origin); 91 | 92 | bool IsEOF() const; 93 | 94 | int32_t GetC(); 95 | 96 | int32_t PutC(int32_t c); 97 | 98 | size32_t Read(OUT void* buffer, size32_t size); 99 | 100 | size32_t Write(const void* buffer, size32_t size); 101 | 102 | //void Flush(); 103 | 104 | #pragma endregion 105 | 106 | #pragma region Extended stream I/O 107 | 108 | std::string ReadCString(); 109 | 110 | size32_t WriteCString(const std::string& str); 111 | 112 | size32_t Length() const; 113 | 114 | void SetLength(size32_t newLength); 115 | 116 | #pragma endregion 117 | }; 118 | 119 | } 120 | -------------------------------------------------------------------------------- /src/openlrr/OpenLRR.h: -------------------------------------------------------------------------------- 1 | // OpenLRR.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "platform/windows.h" 7 | 8 | #include "engine/Main.h" 9 | 10 | #include "common.h" 11 | 12 | 13 | /********************************************************************************** 14 | ******** Enumerations 15 | **********************************************************************************/ 16 | 17 | #pragma region Enums 18 | 19 | // Method used to run OpenLRR 20 | enum class InjectMethod 21 | { 22 | Unknown, 23 | NotAttached, // There is no `LegoRR.exe`. OpenLRR is running on its own 24 | Injector, // OpenLRR-Injector method. Launcher program that safely injects `openlrr.dll` before `LegoRR.exe` can run 25 | DllImport, // Community Edition method. An existing executable that imports `openlrr.dll` 26 | DllStart, // OpenRCT2 method. An existing executable that imports `openlrr.dll` and calls `StartOpenLRR` 27 | }; 28 | 29 | // User-selectable icon to display with the window. 30 | enum class OpenLRRIcon 31 | { 32 | None, 33 | Native, // Whatever is present at resource 113 in the native-loaded executable. 34 | OpenLRR, // Teal rim with "OR" letters 35 | Gold, // Gold rim (from LegoRR.exe) 36 | Teal, // Teal rim (from CLGen.exe) 37 | TealRR, // Teal rim with "RR" letters (from CDROM) 38 | 39 | Count, 40 | }; 41 | 42 | #pragma endregion 43 | 44 | /********************************************************************************** 45 | ******** Structures 46 | **********************************************************************************/ 47 | 48 | #pragma region Structs 49 | 50 | // Global state variables for OpenLRR 51 | struct OpenLRR_Globs 52 | { 53 | HINSTANCE hInstDll; // DLL instance handle passed by `DllMain` 54 | HINSTANCE hInstMain; // EXE instance handle passed by `WinMain` 55 | FILE* conout; // CONOUT$ file opened by `MakeConsole` 56 | InjectMethod method; // How OpenLRR has been injected and attached to `LegoRR.exe` 57 | 58 | std::array(OpenLRRIcon::Count)> iconList; 59 | HMENU menu; 60 | HACCEL accels; 61 | 62 | Gods98::Main_State legoState; // Main_State assigned by Lego_Gods_Go 63 | char legoProgramName[256]; // Copied program name that is ensured to start with Lego* 64 | 65 | // Game variables backup: 66 | uint32 orig_programmerLevel; 67 | 68 | bool wobblyWorld; // Fun mode where ALL blocks use the same texture "UV Wobbles" effect as lava and water. 69 | }; 70 | 71 | #pragma endregion 72 | 73 | /********************************************************************************** 74 | ******** Globals 75 | **********************************************************************************/ 76 | 77 | #pragma region Globals 78 | 79 | extern OpenLRR_Globs openlrrGlobs; 80 | 81 | #pragma endregion 82 | 83 | /********************************************************************************** 84 | ******** Functions 85 | **********************************************************************************/ 86 | 87 | #pragma region I/O Functions 88 | 89 | // DLL instance handle passed by `DllMain`. 90 | inline HINSTANCE OpenLRR_hInstDll(void) { return openlrrGlobs.hInstDll; } 91 | // EXE instance handle passed by `WinMain`. 92 | inline HINSTANCE OpenLRR_hInstMain(void) { return openlrrGlobs.hInstMain; } 93 | 94 | // How OpenLRR has been injected and attached to `LegoRR.exe`. 95 | inline InjectMethod OpenLRR_GetMethod(void) { return openlrrGlobs.method; } 96 | // State how OpenLRR has been injected and attached to `LegoRR.exe`. 97 | inline InjectMethod OpenLRR_SetMethod(InjectMethod newMethod) { return openlrrGlobs.method = newMethod; } 98 | 99 | 100 | // Gets if the wobbly world fun effects are enabled. 101 | inline bool OpenLRR_IsWobblyWorld(void) { return openlrrGlobs.wobblyWorld; } 102 | // Sets if the wobbly world, fun effects are enabled. This needs some hardcoded handling to turn off mid-game. 103 | void OpenLRR_SetWobblyWorld(bool on); 104 | // Called during `OpenLRR_MainLoop_Wrapper` to forcefully make all block textures wobble. 105 | void OpenLRR_UpdateWobblyWorld(void); 106 | 107 | 108 | bool32 __cdecl OpenLRR_Initialise_Wrapper(void); 109 | bool32 __cdecl OpenLRR_MainLoop_Wrapper(real32 elapsed); 110 | void __cdecl OpenLRR_Shutdown_Wrapper(void); 111 | 112 | 113 | // Open a console window for easy logging with `printf`. 114 | FILE* MakeConsole(void); 115 | 116 | // Inject openlrr.dll into LegoRR.exe by hooking `WinMain` with `RunOpenLRR`. 117 | bool InjectOpenLRR(HINSTANCE hInstanceDll); 118 | 119 | // Perform OpenLRR initialisation then call `Gods98::Main_WinMain`. 120 | sint32 __stdcall StartOpenLRRInjected(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, sint32 cmdShow); 121 | extern "C" __declspec(dllexport) sint32 __cdecl StartOpenLRR(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, sint32 cmdShow); 122 | 123 | // Community Edition requires that this function be exported by lrrce.dll. 124 | // This requires `extern "C"` and `__cdecl` to avoid function name mangling. 125 | // Do not remove this, as launching via the Community Edition method is still supported! 126 | //extern "C" __declspec(dllexport) void __cdecl Dummy(void); 127 | 128 | #pragma endregion 129 | -------------------------------------------------------------------------------- /src/openlrr/cmdline/CLGen.h: -------------------------------------------------------------------------------- 1 | // CLGen.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "../platform/windows.h" 7 | 8 | #include "../common.h" 9 | 10 | 11 | namespace CLGen 12 | {; // !<--- 13 | 14 | /********************************************************************************** 15 | ******** Forward Declarations 16 | **********************************************************************************/ 17 | 18 | #pragma region Forward Declarations 19 | 20 | #pragma endregion 21 | 22 | /********************************************************************************** 23 | ******** Function Typedefs 24 | **********************************************************************************/ 25 | 26 | #pragma region Function Typedefs 27 | 28 | #pragma endregion 29 | 30 | /********************************************************************************** 31 | ******** Constants 32 | **********************************************************************************/ 33 | 34 | #pragma region Constants 35 | 36 | #define CLGEN_FILENAME "CLGen.dat" 37 | 38 | 39 | #define CLGEN_CMD_TITLE "TITLE" 40 | #define CLGEN_USAGE_TITLE "Usage " CLGEN_CMD_TITLE "|" 41 | 42 | #define CLGEN_CMD_INSTRUCTION "INSTRUCTION" 43 | #define CLGEN_USAGE_INSTRUCTION "Usage " CLGEN_CMD_INSTRUCTION "|" 44 | #define CLGEN_CMD_ADDITEM "ADDITEM" 45 | #define CLGEN_USAGE_ADDITEM "Usage " CLGEN_CMD_ADDITEM "||" 46 | #define CLGEN_CMD_ACTION "ACTION" 47 | #define CLGEN_ACTION_WRITEKEY "WRITEKEY" 48 | #define CLGEN_USAGE_ACTION_WRITEKEY "Usage " CLGEN_CMD_ACTION "|" CLGEN_ACTION_WRITEKEY "|" 49 | #define CLGEN_MSG_UNKNOWN_ACTION "Unknown action" 50 | 51 | #pragma endregion 52 | 53 | /********************************************************************************** 54 | ******** Enumerations 55 | **********************************************************************************/ 56 | 57 | #pragma region Enums 58 | 59 | #pragma endregion 60 | 61 | /********************************************************************************** 62 | ******** Structures 63 | **********************************************************************************/ 64 | 65 | #pragma region Structs 66 | 67 | struct CLGen_Preset 68 | { 69 | const char* displayName; 70 | const char* options; 71 | }; 72 | assert_sizeof(CLGen_Preset, 0x8); 73 | 74 | 75 | struct CLGen_Globs 76 | { 77 | /*0,4*/ char* buffer; 78 | /*4,4*/ uint32 fileSize; 79 | /*8,4*/ const char* title; 80 | /*c,4*/ const char* instruction; 81 | /*10,4*/ const char* writeKey; 82 | /*14,4*/ CLGen_Preset* presetList; 83 | /*18,4*/ uint32 count; 84 | /*1c,4*/ uint32 capacity; 85 | /*20,4*/ sint32 selIndex; 86 | }; 87 | assert_sizeof(CLGen_Globs, 0x24); 88 | 89 | #pragma endregion 90 | 91 | /********************************************************************************** 92 | ******** Globals 93 | **********************************************************************************/ 94 | 95 | #pragma region Globals 96 | 97 | // 98 | extern CLGen_Globs clgenGlobs; 99 | 100 | #pragma endregion 101 | 102 | /********************************************************************************** 103 | ******** Functions 104 | **********************************************************************************/ 105 | 106 | #pragma region Functions 107 | 108 | uint32 CLGen_GetPresetCount(); 109 | 110 | const CLGen_Preset* CLGen_GetPreset(uint32 index); 111 | 112 | 113 | 114 | // 115 | sint32 __stdcall CLGen_WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, 116 | _In_ LPSTR lpCmdLine, _In_ sint32 nCmdShow); 117 | 118 | // Open "CLGen.dat" file and parse commands 119 | // 120 | bool32 __cdecl CLGen_Open(const char* filename); 121 | 122 | void CLGen_Close(); 123 | 124 | // Parse a single "CLGen.dat" line command 125 | // 126 | const char* __cdecl CLGen_ParseCommand(sint32 argc, char** argv); 127 | 128 | // Apply changes to Registry key using the passed mode's options 129 | // 130 | void __cdecl CLGen_ApplyRegistryChanges(const CLGen_Preset* preset); 131 | 132 | // Add a CLGen mode name and associated options to table 133 | // 134 | CLGen_Preset* __cdecl CLGen_AddPresetItem(const char* presetName, const char* options); 135 | 136 | // 137 | BOOL __stdcall CLGen_DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); 138 | 139 | // 140 | bool32 __cdecl CLGen_Dialog_HandleInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam); 141 | 142 | // 143 | bool32 __cdecl CLGen_Dialog_HandleCommand(HWND hDlg, WPARAM wParam, LPARAM lParam); 144 | 145 | // 146 | bool32 __cdecl CLGen_Dialog_HandleMenuCommand(HWND hDlg, WPARAM wParam); 147 | 148 | // 149 | bool32 __cdecl CLGen_Dialog_HandleAcceleratorCommand(HWND hDlg, WORD sourceId, HWND hCtrl); 150 | 151 | #pragma endregion 152 | 153 | } 154 | -------------------------------------------------------------------------------- /src/openlrr/cpp.hint: -------------------------------------------------------------------------------- 1 | // cpp.hint : This file exists to stop Visual Studio from complaining about #define macros 2 | // 3 | // Put commonly-used macros in here 4 | 5 | #define _ENUM_FLAG_CONSTEXPR constexpr 6 | 7 | #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \ 8 | extern "C++" { \ 9 | inline constexpr ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) throw() { return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER::type)a) | ((_ENUM_FLAG_SIZED_INTEGER::type)b)); } \ 10 | inline ENUMTYPE &operator |= (ENUMTYPE &a, ENUMTYPE b) throw() { return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER::type &)a) |= ((_ENUM_FLAG_SIZED_INTEGER::type)b)); } \ 11 | inline constexpr ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) throw() { return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER::type)a) & ((_ENUM_FLAG_SIZED_INTEGER::type)b)); } \ 12 | inline ENUMTYPE &operator &= (ENUMTYPE &a, ENUMTYPE b) throw() { return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER::type &)a) &= ((_ENUM_FLAG_SIZED_INTEGER::type)b)); } \ 13 | inline constexpr ENUMTYPE operator ~ (ENUMTYPE a) throw() { return ENUMTYPE(~((_ENUM_FLAG_SIZED_INTEGER::type)a)); } \ 14 | inline constexpr ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) throw() { return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER::type)a) ^ ((_ENUM_FLAG_SIZED_INTEGER::type)b)); } \ 15 | inline ENUMTYPE &operator ^= (ENUMTYPE &a, ENUMTYPE b) throw() { return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER::type &)a) ^= ((_ENUM_FLAG_SIZED_INTEGER::type)b)); } \ 16 | } 17 | 18 | // Gets the name of a symbol as a C string 19 | #define nameof_(symbol) #symbol 20 | #define nameof(symbol) nameof_(symbol) 21 | 22 | #define assert_sizeof(type, size) static_assert(sizeof(type) == (size), "Improper type size for " nameof(type)) 23 | 24 | // Shorthand cast to unsigned character for GODS string comparisons 25 | #define uchr(c) ((uansi)(c)) 26 | #define ustr(c) ((uansi_str)(c)) 27 | #define ucstr(c) ((const_uansi_str)(c)) 28 | 29 | 30 | #define noinline(funcname) _noinline_ ##funcname 31 | 32 | 33 | #define flags_enum(name) \ 34 | DEFINE_ENUM_FLAG_OPERATORS(name) 35 | 36 | 37 | #define enum_scoped(name) \ 38 | namespace _ns_ ##name { \ 39 | enum name 40 | 41 | #define enum_scoped_forward(name) \ 42 | enum_scoped(name) 43 | 44 | #define enum_scoped_forward_end(name) \ 45 | } using name = _ns_ ##name## :: ##name 46 | 47 | #define flags_scoped(name) enum_scoped(name) 48 | 49 | 50 | #define enum_scoped_end(name, size) \ 51 | assert_sizeof(name, size); \ 52 | } using name = _ns_ ##name## :: ##name 53 | 54 | #define flags_scoped_end(name, size) \ 55 | flags_enum(name); \ 56 | enum_scoped_end(name, size) 57 | 58 | 59 | #define enum_end(name, size) \ 60 | assert_sizeof(name, size) 61 | 62 | #define flags_end(name, size) \ 63 | flags_enum(name); \ 64 | assert_sizeof(name, size) 65 | 66 | 67 | #define log_firstcall() { static bool _log_firstcallbool = false; \ 68 | if (!_log_firstcallbool) {_log_firstcallbool = true; \ 69 | if (Gods98::Error_IsTraceVisible()) { \ 70 | std::printf("%s called\n", __FUNCTION__); } } } 71 | -------------------------------------------------------------------------------- /src/openlrr/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : 2 | // 3 | 4 | #include "platform/windows.h" 5 | 6 | #include "dllmain.h" 7 | #include "OpenLRR.h" 8 | 9 | 10 | // At the moment this is disabled because it worsens the race condition 11 | // when launching OpenLRR though the Community Edition method. 12 | //#define USE_CREATETHREAD 13 | 14 | 15 | static bool isAttached = false; 16 | 17 | 18 | // Used with `USE_CREATETHREAD` define. 19 | DWORD WINAPI DllMainThread(LPVOID hModule) 20 | { 21 | InjectOpenLRR((HMODULE)hModule); 22 | 23 | return 0; 24 | } 25 | 26 | BOOL APIENTRY DllMain(HMODULE hModule, 27 | DWORD fdwReason, 28 | LPVOID lpReserved) 29 | { 30 | switch (fdwReason) 31 | { 32 | case DLL_PROCESS_ATTACH: 33 | if (!isAttached) { 34 | isAttached = true; 35 | 36 | #ifdef USE_CREATETHREAD 37 | 38 | ::DisableThreadLibraryCalls(hModule); 39 | ::CreateThread(0, 0, DllMainThread, hModule, 0, 0); 40 | 41 | #else 42 | 43 | InjectOpenLRR(hModule); 44 | 45 | #endif 46 | } 47 | break; 48 | //case DLL_THREAD_ATTACH: 49 | //std::printf("[0x%08x] DLL_THREAD_ATTACH\n", ::timeGetTime()); 50 | //break; 51 | //case DLL_THREAD_DETACH: 52 | //std::printf("[0x%08x] DLL_THREAD_DETACH\n", ::timeGetTime()); 53 | //break; 54 | case DLL_PROCESS_DETACH: 55 | //std::printf("[0x%08x] DLL_PROCESS_DETACH\n", ::timeGetTime()); 56 | break; 57 | } 58 | return TRUE; 59 | } 60 | -------------------------------------------------------------------------------- /src/openlrr/dllmain.h: -------------------------------------------------------------------------------- 1 | // dllmain.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "platform/windows.h" 7 | 8 | #include "common.h" 9 | 10 | // Entry point where we inject our OpenLRR hook. 11 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved); 12 | 13 | -------------------------------------------------------------------------------- /src/openlrr/engine/Init.h: -------------------------------------------------------------------------------- 1 | // Init.h : 2 | // 3 | /// APIS: - 4 | /// DEPENDENCIES: Main, DirectDraw, (Errors) 5 | /// DEPENDENTS: Main 6 | 7 | #pragma once 8 | 9 | #include "../platform/windows.h" 10 | 11 | #include "../common.h" 12 | 13 | #include "drawing/DirectDraw.h" 14 | 15 | 16 | namespace Gods98 17 | {; // !<--- 18 | 19 | /********************************************************************************** 20 | ******** Structures 21 | **********************************************************************************/ 22 | 23 | #pragma region Structs 24 | 25 | struct Init_Globs 26 | { 27 | /*00000,4*/ uint32 driverCount; 28 | /*00004,4*/ uint32 deviceCount; 29 | /*00008,4*/ uint32 modeCount; 30 | /*0000c,1590*/ Graphics_Driver drivers[GRAPHICS_MAXDRIVERS]; 31 | /*0159c,1590*/ Graphics_Device devices[GRAPHICS_MAXDEVICES]; 32 | /*02b2c,d480*/ Graphics_Mode modes[GRAPHICS_MAXMODES]; 33 | /*0ffac,4*/ const Graphics_Driver* selDriver; 34 | /*0ffb0,4*/ const Graphics_Device* selDevice; 35 | /*0ffb4,4*/ const Graphics_Mode* selMode; 36 | /*0ffb8,4*/ bool32 selFullScreen; 37 | /*0ffbc,4*/ bool32 wasFullScreen; 38 | /*0ffc0,d480*/ Graphics_Mode validModes[GRAPHICS_MAXMODES]; 39 | /*1d440,4*/ uint32 validModeCount; 40 | /*1d444*/ 41 | }; 42 | assert_sizeof(Init_Globs, 0x1d444); 43 | 44 | #pragma endregion 45 | 46 | /********************************************************************************** 47 | ******** Globals 48 | **********************************************************************************/ 49 | 50 | #pragma region Globals 51 | 52 | // 53 | extern Init_Globs & initGlobs; 54 | 55 | #pragma endregion 56 | 57 | /********************************************************************************** 58 | ******** Functions 59 | **********************************************************************************/ 60 | 61 | #pragma region Functions 62 | 63 | // Entry point for Init "Mode Selection" dialog. 64 | // Calls the appropriate DirectDraw_Setup function after a mode has been selected. 65 | // 66 | bool32 __cdecl Init_Initialise(bool32 setup, bool32 debug, bool32 best, bool32 window, const char* noHALMsg); 67 | 68 | // 69 | BOOL __stdcall Init_DialogProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); 70 | 71 | // Change the FullScreen mode setting, and update the "Screen Mode" / "Window Size" label text. 72 | // 73 | void __cdecl Init_SetFullScreen(HWND hWndDlg, bool32 on); 74 | 75 | // Rebuild (enumerate through) and repopulate the listbox of modes. 76 | // Only modes registered as supported by the game will appear in the listbox. 77 | // 78 | void __cdecl Init_SetModeList(HWND hWndDlg); 79 | 80 | // Rebuild (enumerate through) and repopulate the listbox of devices. 81 | // 82 | void __cdecl Init_SetDeviceList(HWND hWndDlg); 83 | 84 | // Register a mode that the game supports. 85 | // Although this assigns to a table using the same ScreenMode structure, 86 | // only the width, height, and depth fields are assigned. 87 | // 88 | void __cdecl Init_AddValidMode(uint32 width, uint32 height, uint32 depth); 89 | 90 | // Check if the selected system-available screen mode is supported by the game. 91 | // 92 | bool32 __cdecl Init_IsValidMode(uint32 mode); 93 | 94 | // Get the index of a system-available mode from the display name used in the listbox. 95 | // 96 | bool32 __cdecl Init_GetMode(const char* name, OUT uint32* mode); 97 | 98 | // Update FullScreen/Window radio buttons depending on whether 99 | // the currently selected driver allows windowed mode. 100 | // 101 | void __cdecl Init_HandleWindowButton(HWND hWndDlg); 102 | 103 | #pragma endregion 104 | 105 | } 106 | -------------------------------------------------------------------------------- /src/openlrr/engine/README.md: -------------------------------------------------------------------------------- 1 | # OpenLRR engine code 2 | 3 | The engine for OpenLRR is implemented based on the abandonware Gods98 source code. For that reason, this probably can't be placed under the same project-wide license that would be applicable to the game code. 4 | 5 | 6 | ### Contents 7 | 8 | * `audio/` 9 | 10 | Music, 3D sound effects playback, and wave file loading. 11 | 12 | * `core/` 13 | 14 | Core functionality depended on by the rest of the engine, and the game as whole. 15 | 16 | * `drawing/` 17 | 18 | 2D drawing, images, fonts, etc. 19 | 20 | * `gfx/` 21 | 22 | 3D rendering, models, scenes, etc. 23 | 24 | * `input/` 25 | 26 | Keyboard and mouse input, and key name lookup. 27 | 28 | * `util/` 29 | 30 | Engine-specific utilities not needed by game code. 31 | 32 | * `video/` 33 | 34 | AVI animations, and movie playback. 35 | 36 | * `colour.h` 37 | 38 | Colour-based types and structures. 39 | 40 | * `geometry.h` 41 | 42 | Math-based types, structures, and enums. 43 | 44 | * `Graphics` 45 | 46 | Main engine rendering functionality (split off from the `Main` module). 47 | 48 | * `Init` 49 | 50 | Mode Selection dialog, and graphics display settings selection. 51 | 52 | * `Main` 53 | 54 | Main engine functionality and main loop. 55 | 56 | * `undefined.h` 57 | 58 | Common typedefs used for unknown fields in Ghidra. 59 | -------------------------------------------------------------------------------- /src/openlrr/engine/colour.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../common.h" 4 | 5 | #include "geometry.h" 6 | 7 | 8 | #pragma region Colour Structs 9 | 10 | /// TODO: Add `r`, `g`, `b`, `a` field aliases to all colours. They're much cleaner. 11 | 12 | struct ColourRGBI { 13 | union { 14 | struct { 15 | /*0,4*/ uint32 r; 16 | /*4,4*/ uint32 g; 17 | /*8,4*/ uint32 b; 18 | /*c*/ 19 | }; 20 | /*0,c*/ std::array channels; 21 | /*c*/ 22 | }; 23 | }; assert_sizeof(ColourRGBI, 0xc); 24 | 25 | 26 | struct ColourRGBF { 27 | union { 28 | struct { 29 | /*0,4*/ real32 r; 30 | /*4,4*/ real32 g; 31 | /*8,4*/ real32 b; 32 | /*c*/ 33 | }; 34 | /*0,c*/ Vector3F xyz; 35 | /*0,c*/ std::array channels; 36 | /*c*/ 37 | }; 38 | }; assert_sizeof(ColourRGBF, 0xc); 39 | 40 | 41 | struct ColourRGBAI { 42 | union { 43 | struct { 44 | /*00,4*/ uint32 r; 45 | /*04,4*/ uint32 g; 46 | /*08,4*/ uint32 b; 47 | /*0c,4*/ uint32 a; 48 | /*10*/ 49 | }; 50 | /*00,c*/ ColourRGBI rgb; 51 | /*00,10*/ std::array channels; 52 | /*10*/ 53 | }; 54 | }; assert_sizeof(ColourRGBAI, 0x10); 55 | 56 | 57 | struct ColourRGBAF { 58 | union { 59 | struct { 60 | /*00,4*/ real32 r; 61 | /*04,4*/ real32 g; 62 | /*08,4*/ real32 b; 63 | /*0c,4*/ real32 a; 64 | /*10*/ 65 | }; 66 | /*00,c*/ ColourRGBF rgb; 67 | /*00,c*/ Vector3F xyz; 68 | /*00,10*/ Vector4F xyzw; 69 | /*00,10*/ std::array channels; 70 | /*10*/ 71 | }; 72 | }; assert_sizeof(ColourRGBAF, 0x10); 73 | 74 | 75 | #pragma pack(push, 1) 76 | 77 | // 24-bit packed RGB-ordered colour channels 78 | struct ColourRGBPacked { 79 | union { 80 | struct { 81 | /*0,1*/ uint8 r; 82 | /*1,1*/ uint8 g; 83 | /*2,1*/ uint8 b; 84 | /*3*/ 85 | }; 86 | /*0,3*/ std::array channels; 87 | /*3*/ 88 | }; 89 | }; assert_sizeof(ColourRGBPacked, 0x3); 90 | 91 | // 32-bit packed RGBA-ordered colour channels 92 | struct ColourRGBAPacked { 93 | union { 94 | struct { 95 | /*0,1*/ uint8 r; 96 | /*1,1*/ uint8 g; 97 | /*2,1*/ uint8 b; 98 | /*3,1*/ uint8 a; 99 | /*4*/ 100 | }; 101 | /*0,4*/ std::array channels; 102 | /*0,4*/ uint32 rgbaColour; 103 | /*4*/ 104 | }; 105 | 106 | }; assert_sizeof(ColourRGBAPacked, 0x4); 107 | 108 | 109 | // 24-bit packed BGR-ordered colour channels 110 | struct ColourBGRPacked { 111 | union { 112 | struct { 113 | /*0,1*/ uint8 b; 114 | /*1,1*/ uint8 g; 115 | /*2,1*/ uint8 r; 116 | /*3*/ 117 | }; 118 | /*0,3*/ std::array channels; 119 | /*3*/ 120 | }; 121 | }; assert_sizeof(ColourBGRPacked, 0x3); 122 | 123 | // 32-bit packed BGRA-ordered colour channels 124 | struct ColourBGRAPacked { 125 | union { 126 | struct { 127 | /*0,1*/ uint8 b; 128 | /*1,1*/ uint8 g; 129 | /*2,1*/ uint8 r; 130 | /*3,1*/ uint8 a; 131 | /*4*/ 132 | }; 133 | /*0,4*/ std::array channels; 134 | /*0,4*/ uint32 bgraColour; 135 | /*4*/ 136 | }; 137 | }; assert_sizeof(ColourRGBAPacked, 0x4); 138 | 139 | #pragma pack(pop) 140 | 141 | #pragma endregion 142 | -------------------------------------------------------------------------------- /src/openlrr/engine/core/Memory.cpp: -------------------------------------------------------------------------------- 1 | // Memory.cpp : 2 | // 3 | 4 | #include "Errors.h" 5 | 6 | #include "Memory.h" 7 | 8 | 9 | /********************************************************************************** 10 | ******** Globals 11 | **********************************************************************************/ 12 | 13 | #pragma region Globals 14 | 15 | // 16 | Gods98::Mem_Globs & Gods98::memGlobs = *(Gods98::Mem_Globs*)0x00545a20; // (no init) 17 | 18 | #pragma endregion 19 | 20 | /********************************************************************************** 21 | ******** Functions 22 | **********************************************************************************/ 23 | 24 | #pragma region Functions 25 | 26 | /*__inline void* __cdecl Mem_Alloc(unsigned long size) { return std::malloc(size); } 27 | __inline void* __cdecl Mem_ReAlloc(void* addr, unsigned long size) { return std::realloc(addr, size); } 28 | __inline void __cdecl Mem_Free(void* addr) { std::free(addr); }*/ 29 | 30 | 31 | // 32 | void __cdecl Gods98::Mem_Initialise(void) 33 | { 34 | log_firstcall(); 35 | 36 | for (Mem_HandleValue loop = 0; loop < MEMORY_MAXHANDLES; loop++) { 37 | memGlobs.handleList[loop].addr = nullptr; 38 | memGlobs.handleList[loop].flags = Mem_HandleFlags::MEMORY_HANDLE_FLAG_NONE; 39 | } 40 | } 41 | 42 | // 43 | void __cdecl Gods98::Mem_Shutdown(bool32 freeAll) 44 | { 45 | // debug-only functions 46 | } 47 | 48 | // 49 | Gods98::Mem_HandleValue __cdecl Gods98::Mem_AllocHandle(uint32 size) 50 | { 51 | log_firstcall(); 52 | 53 | for (Mem_HandleValue loop = 0; loop < MEMORY_MAXHANDLES; loop++){ 54 | if (!(memGlobs.handleList[loop].flags & Mem_HandleFlags::MEMORY_HANDLE_FLAG_USED)){ 55 | 56 | memGlobs.handleList[loop].addr = Mem_Alloc(size); 57 | 58 | memGlobs.handleList[loop].flags |= Mem_HandleFlags::MEMORY_HANDLE_FLAG_USED; 59 | return (Mem_HandleValue)loop; 60 | } 61 | } 62 | 63 | Error_Fatal(true, "Run out of memory handles"); 64 | return MEMORY_HANDLE_INVALID /*-1*/; 65 | } 66 | 67 | // 68 | void __cdecl Gods98::Mem_FreeHandle(Mem_HandleValue handle) 69 | { 70 | log_firstcall(); 71 | 72 | if (handle >= 0 && handle < MEMORY_MAXHANDLES) { 73 | if (memGlobs.handleList[handle].flags & Mem_HandleFlags::MEMORY_HANDLE_FLAG_USED) { 74 | Mem_Free(memGlobs.handleList[handle].addr); 75 | memGlobs.handleList[handle].addr = nullptr; 76 | memGlobs.handleList[handle].flags = Mem_HandleFlags::MEMORY_HANDLE_FLAG_NONE; 77 | } 78 | else Error_Warn(true, "Handle has already been freed"); 79 | } 80 | else Error_Warn(true, "Handle is out of range"); 81 | } 82 | 83 | // 84 | void * __cdecl Gods98::Mem_AddressHandle(Mem_HandleValue handle) 85 | { 86 | log_firstcall(); 87 | 88 | if (handle >= 0 && handle < MEMORY_MAXHANDLES) { 89 | if (memGlobs.handleList[handle].flags & Mem_HandleFlags::MEMORY_HANDLE_FLAG_USED) { 90 | 91 | return memGlobs.handleList[handle].addr; 92 | 93 | } 94 | else Error_Warn(true, "Handle has already been freed"); 95 | } 96 | else Error_Warn(true, "Handle is out of range"); 97 | 98 | return nullptr; 99 | } 100 | 101 | #pragma endregion 102 | 103 | -------------------------------------------------------------------------------- /src/openlrr/engine/core/Memory.h: -------------------------------------------------------------------------------- 1 | // Memory.h : 2 | // 3 | /// APIS: - 4 | /// DEPENDENCIES: -, (Errors) 5 | /// DEPENDENTS: Files 6 | 7 | #pragma once 8 | 9 | #include "../../common.h" 10 | #include "../../legacy.h" 11 | 12 | 13 | namespace Gods98 14 | {; // !<--- 15 | 16 | /********************************************************************************** 17 | ******** Constants 18 | **********************************************************************************/ 19 | 20 | #pragma region Constants 21 | 22 | #define MEMORY_MAXHANDLES 2000 23 | 24 | #define MEMORY_HANDLE_INVALID (static_cast(-1)) 25 | 26 | #pragma endregion 27 | 28 | /********************************************************************************** 29 | ******** Enumerations 30 | **********************************************************************************/ 31 | 32 | #pragma region Enums 33 | 34 | flags_scoped(Mem_GlobFlags) : uint32 35 | { 36 | MEMORY_GLOB_FLAG_NONE = 0, 37 | }; 38 | flags_scoped_end(Mem_GlobFlags, 0x4); 39 | 40 | 41 | flags_scoped(Mem_HandleFlags) : uint32 42 | { 43 | MEMORY_HANDLE_FLAG_NONE = 0, 44 | 45 | MEMORY_HANDLE_FLAG_USED = 0x1, 46 | }; 47 | flags_scoped_end(Mem_HandleFlags, 0x4); 48 | 49 | #pragma endregion 50 | 51 | /********************************************************************************** 52 | ******** Typedefs 53 | **********************************************************************************/ 54 | 55 | #pragma region Typedefs 56 | 57 | typedef uint32 Mem_HandleValue; 58 | 59 | #pragma endregion 60 | 61 | /********************************************************************************** 62 | ******** Structures 63 | **********************************************************************************/ 64 | 65 | #pragma region Structs 66 | 67 | struct Mem_Handle 68 | { 69 | /// FIX: stored as LPVOID*, rather than LPVOID 70 | /*0,4*/ void* addr; 71 | /*4,4*/ Mem_HandleFlags flags; 72 | /*8*/ 73 | }; 74 | assert_sizeof(Mem_Handle, 0x8); 75 | 76 | 77 | struct Mem_Globs 78 | { 79 | /*0000,3e80*/ Mem_Handle handleList[MEMORY_MAXHANDLES]; 80 | /*3e80,4*/ Mem_GlobFlags flags; // (unused) 81 | /*3e84*/ 82 | }; 83 | assert_sizeof(Mem_Globs, 0x3e84); 84 | 85 | #pragma endregion 86 | 87 | /********************************************************************************** 88 | ******** Globals 89 | **********************************************************************************/ 90 | 91 | #pragma region Globals 92 | 93 | // 94 | extern Mem_Globs & memGlobs; 95 | 96 | #pragma endregion 97 | 98 | /********************************************************************************** 99 | ******** Functions 100 | **********************************************************************************/ 101 | 102 | #pragma region Functions 103 | 104 | #define Mem_StopAtID(i) (i) 105 | #define Mem_StopAtAddress(i) (i) 106 | #define Mem_DebugTrash(a,v,s) 107 | 108 | 109 | // void* std::malloc(size_t); 110 | // 111 | __inline void * Mem_Alloc(uint32 size) 112 | { 113 | return legacy::malloc(size); 114 | //return ((void* (__cdecl*)(uint32))0x0048de90)(size); 115 | } 116 | 117 | // void std::free(void*); 118 | // 119 | __inline void Mem_Free(void * addr) 120 | { 121 | return legacy::free(addr); 122 | //((void(__cdecl*)(void*))0x0048de40)(addr); 123 | } 124 | 125 | // void* std::realloc(void*, size_t); 126 | // 127 | __inline void * Mem_ReAlloc(void * addr, uint32 size) 128 | { 129 | return legacy::realloc(addr, size); 130 | //return ((void*(__cdecl*)(void*, uint32))0x0048df40)(addr, size); 131 | } 132 | 133 | 134 | // 135 | void __cdecl Mem_Initialise(void); 136 | 137 | // 138 | void __cdecl Mem_Shutdown(bool32 freeAll); 139 | 140 | // 141 | Mem_HandleValue __cdecl Mem_AllocHandle(uint32 size); 142 | 143 | // 144 | void __cdecl Mem_FreeHandle(Mem_HandleValue handle); 145 | 146 | // 147 | void * __cdecl Mem_AddressHandle(Mem_HandleValue handle); 148 | 149 | #pragma endregion 150 | 151 | } 152 | -------------------------------------------------------------------------------- /src/openlrr/engine/core/Random.cpp: -------------------------------------------------------------------------------- 1 | // Random.cpp : C++ classes for the random number generator used by LRR's C runtime library. 2 | // 3 | 4 | #include "Random.hpp" 5 | 6 | 7 | #pragma region LCG number generation 8 | 9 | // Plain view of number generation: 10 | //state = (state * 214013) + 2531011; 11 | //return ((sint32)state >> 16) & 0x7fff; 12 | 13 | // Step 1: Modifies and returns the next LCG state. Which can then be used with 14 | // `uint32 lcgRandFromState(uint32)` to generate the next random number. 15 | static constexpr uint32 lcgNextState(uint32 state) 16 | { 17 | return (state * Random::LCGEngine::multiplier) + Random::LCGEngine::increment; 18 | //return (state * 214013) + 2531011; 19 | } 20 | // Step 2: Generates a random number from the modified LCG state returned by 21 | // `uint32 lcgNextState(uint32)`. 22 | static constexpr sint32 lcgRandFromState(uint32 state) 23 | { 24 | // Using & here, because its cheaper for our modulus term of `0x7fff`. 25 | return ((sint32)state >> Random::LCGEngine::shift) & Random::LCGEngine::modulus; 26 | //return ((sint32)state >> 16) & 0x7fff; 27 | } 28 | 29 | #pragma endregion 30 | 31 | 32 | 33 | #pragma region LCG engine classes 34 | 35 | Random::LCGEngine::LCGEngine(uint32 initialSeed) 36 | : m_state(initialSeed) 37 | { 38 | } 39 | 40 | sint32 Random::LCGEngine::Next() 41 | { 42 | this->m_state = lcgNextState(this->m_state); 43 | return lcgRandFromState(this->m_state); 44 | } 45 | 46 | 47 | 48 | Random::WrapperLCGEngine::WrapperLCGEngine(uint32& stateInMemory) 49 | : m_stateInMemory(stateInMemory) 50 | { 51 | this->m_state = this->m_stateInMemory; 52 | } 53 | 54 | sint32 Random::WrapperLCGEngine::Next() 55 | { 56 | this->m_stateInMemory = this->m_state = lcgNextState(this->m_stateInMemory); 57 | return lcgRandFromState(this->m_stateInMemory); 58 | } 59 | 60 | #pragma endregion 61 | -------------------------------------------------------------------------------- /src/openlrr/engine/core/Random.hpp: -------------------------------------------------------------------------------- 1 | // Random.hpp : C++ classes for the random number generator used by LRR's C runtime library. 2 | // 3 | 4 | #pragma once 5 | 6 | #include "../../common.h" 7 | 8 | 9 | namespace Random 10 | {; // !<--- 11 | 12 | #pragma region LCG Engine 13 | 14 | /** 15 | * @brief Random number generator engine: MS Quick C - Linear Congruential Generator (LCG). 16 | * Standalone version that uses its own state field. 17 | */ 18 | class LCGEngine 19 | { 20 | // 21 | // 22 | 23 | // Linear Congruential Generator (LCG) Parameters 24 | // 25 | // | impl | n | a | c | 26 | // |:----------:|:----:|:------:|:-------:| 27 | // | MS Quick C | 2^32 | 214013 | 2531011 | 28 | 29 | public: 30 | static constexpr const sint32 multiplier = 214013; /** @brief The multiplier term (a). */ 31 | static constexpr const sint32 increment = 2531011; /** @brief The increment term (c). */ 32 | static constexpr const sint32 shift = 16; /** @brief The shift right term before applying the modulus. */ 33 | static constexpr const sint32 modulus = 0x7fff; /** @brief The modulus term (m). */ 34 | static constexpr const uint32 default_seed = 1; /** @brief The default seed (1). */ 35 | 36 | static constexpr const sint32 rand_max = modulus; /** @brief The maximum value producible by the engine. */ 37 | 38 | /** 39 | * @brief Constructs a standalone LCG engine. 40 | * @param initialSeed Optional seeded state to start with. 41 | */ 42 | LCGEngine(uint32 initialSeed = default_seed); 43 | 44 | /** 45 | * @brief Gets the current value for the engine's state. Can be used in combination 46 | * with `void Seed(uint32)` to backup and restore the state of the PRNG. 47 | */ 48 | inline uint32 State() const { return this->m_state; } 49 | 50 | /** 51 | * @brief Seeds the engine's state. Can be used in combination with 52 | * `uint32 State()` to backup and restore the state of the PRNG. 53 | * @param seed The new seed. 54 | */ 55 | inline void Seed(uint32 seed) { this->m_state = seed; } 56 | 57 | /** 58 | * @brief Generates the next random number in the engine's state. 59 | */ 60 | sint32 Next(); 61 | 62 | protected: 63 | uint32 m_state; 64 | }; 65 | 66 | 67 | /** 68 | * @brief Random number generator engine: MS Quick C - Linear Congruential Generator (LCG). 69 | * Reference version that manipulates existing memory. 70 | */ 71 | class WrapperLCGEngine : public LCGEngine // Inherit from `LCGEngine` just for the constants. 72 | { 73 | public: 74 | /** 75 | * @brief Constructs an LCG engine wrapped around an existing state field. 76 | * @param stateInMemory The reference to memory holding the engine state. 77 | */ 78 | WrapperLCGEngine(uint32& stateInMemory); 79 | 80 | /** 81 | * @brief Gets the current value for the engine's state. Can be used in combination 82 | * with `void Seed(uint32)` to backup and restore the state of the PRNG. 83 | */ 84 | inline uint32 State() const { return this->m_stateInMemory; } 85 | /** 86 | * @brief Seeds the engine's state. Can be used in combination with 87 | * `uint32 State()` to backup and restore the state of the PRNG. 88 | * @param seed The new seed. 89 | */ 90 | inline void Seed(uint32 seed) { this->m_stateInMemory = this->m_state = seed; } 91 | 92 | /** 93 | * @brief Generates the next random number in the engine's state. 94 | */ 95 | sint32 Next(); 96 | 97 | private: 98 | uint32& m_stateInMemory; 99 | }; 100 | 101 | #pragma endregion 102 | 103 | } 104 | -------------------------------------------------------------------------------- /src/openlrr/engine/core/Utils.h: -------------------------------------------------------------------------------- 1 | // Utils.h : 2 | // 3 | /// APIS: - 4 | /// DEPENDENCIES: -, (Memory) 5 | /// DEPENDENTS: ... 6 | 7 | #pragma once 8 | 9 | #include "../../common.h" 10 | 11 | 12 | namespace Gods98 13 | {; // !<--- 14 | 15 | /********************************************************************************** 16 | ******** Constants 17 | **********************************************************************************/ 18 | 19 | #pragma region Constants 20 | 21 | #define UTIL_DEFSTRINGLEN 512 22 | #define UTIL_LARGENUMBER 6293815 // For Util_HashString() 23 | #define UTIL_MAXSTRINGLENGTH 256 24 | 25 | #pragma endregion 26 | 27 | /********************************************************************************** 28 | ******** Functions 29 | **********************************************************************************/ 30 | 31 | #pragma region Functions 32 | 33 | //typedef char* Util_StringMatrix[4][4]; 34 | 35 | // 36 | char* __cdecl Util_GetLine(IN OUT char** buffer, const char* bufferEnd); 37 | 38 | // 39 | // 40 | uint32 __cdecl Util_Tokenise(IN OUT char* str, OUT char** argv, const char* sep); 41 | 42 | /// CUSTOM: Util_Tokenise with an upper limit on the number of arguments. 43 | /// Return the total number of arguments found regardless of count (for error detection). 44 | uint32 Util_TokeniseSafe(IN OUT char* str, OUT char** argv, const char* sep, uint32 count); 45 | 46 | // 47 | uint32 __cdecl Util_WSTokenise(IN OUT char* str, OUT char** argv); 48 | 49 | /// CUSTOM: Util_WSTokenise with an upper limit on the number of arguments. 50 | /// Return the total number of arguments found regardless of count (for error detection). 51 | uint32 Util_WSTokeniseSafe(IN OUT char* str, OUT char** argv, uint32 count); 52 | 53 | // (char* ::_strdup(const char*)) 54 | // 55 | char* __cdecl Util_StrCpy(const char* str); 56 | 57 | // 58 | char* __cdecl Util_RemoveUnderscores(const char* str, ...); 59 | 60 | // 61 | char* __cdecl Util_StrIStr(char* str1, const char* str2); 62 | // const implementation 63 | // 64 | inline const char* __cdecl Util_StrIStr(const char* str1, const char* str2) 65 | { 66 | return Util_StrIStr(const_cast(str1), str2); 67 | } 68 | 69 | // 70 | uint32 __cdecl Util_HashString(const char* str, bool32 bIgnoreBlanks, bool32 upperCase); 71 | 72 | // 73 | bool32 __cdecl Util_IsNumber(const char* str); 74 | 75 | // 76 | BoolTri __cdecl Util_GetBoolFromString(const char* str); 77 | 78 | /*VOID __cdecl Util_MultiplyStringMatrix(Util_StringMatrix r, Util_StringMatrix a, Util_StringMatrix b); 79 | VOID __cdecl Util_PrintStringMatrix(Util_StringMatrix r); 80 | VOID __cdecl Util_TransposeStringMatrix(Util_StringMatrix m); 81 | VOID __cdecl Util_FreeStringMatrix(Util_StringMatrix m);*/ 82 | 83 | #pragma endregion 84 | 85 | } 86 | 87 | -------------------------------------------------------------------------------- /src/openlrr/engine/drawing/TextWindow.h: -------------------------------------------------------------------------------- 1 | // TextWindow.h : 2 | // 3 | /// APIS: - 4 | /// DEPENDENCIES: Fonts, (Memory) 5 | /// DEPENDENTS: 6 | 7 | #pragma once 8 | 9 | #include "../../common.h" 10 | #include "../geometry.h" 11 | 12 | 13 | namespace Gods98 14 | {; // !<--- 15 | 16 | /********************************************************************************** 17 | ******** Forward Declarations 18 | **********************************************************************************/ 19 | 20 | #pragma region Forward Declarations 21 | 22 | struct Font; // from `engine/drawing/Fonts.h` 23 | 24 | #pragma endregion 25 | 26 | /********************************************************************************** 27 | ******** Constants 28 | **********************************************************************************/ 29 | 30 | #pragma region Constants 31 | 32 | #define TEXTWINDOW_MAXSTRINGLEN 1024 33 | #define TEXTWINDOW_MAXLINES 256 34 | 35 | #define TEXTWINDOW_DISPLAYDELAY 25 36 | 37 | #pragma endregion 38 | 39 | /********************************************************************************** 40 | ******** Enumerations 41 | **********************************************************************************/ 42 | 43 | #pragma region Enums 44 | 45 | flags_scoped(TextWindowFlags) : uint32 46 | { 47 | TEXTWINDOW_FLAG_NONE = 0, // (unused) 48 | 49 | TEXTWINDOW_FLAG_WINDOWWRAPPED = 0x1, 50 | TEXTWINDOW_FLAG_OVERLAY = 0x2, 51 | TEXTWINDOW_FLAG_CENTERED = 0x4, 52 | }; 53 | flags_scoped_end(TextWindowFlags, 0x4); 54 | 55 | #pragma endregion 56 | 57 | /********************************************************************************** 58 | ******** Structures 59 | **********************************************************************************/ 60 | 61 | #pragma region Structs 62 | 63 | struct TextWindow 64 | { 65 | /*000,4*/ Font* font; 66 | /*004,10*/ Area2F windowSize; 67 | /*014,4*/ char* windowBuffer; 68 | /*018,400*/ char secondaryBuffer[TEXTWINDOW_MAXSTRINGLEN]; 69 | /*418,4*/ uint32 windowBufferSize; 70 | /*41c,4*/ uint32 windowBufferEnd; 71 | /*420,400*/ uint32 lineList[TEXTWINDOW_MAXLINES]; 72 | /*820,4*/ uint32 usedLines; // (count) 73 | /*824,4*/ uint32 maxLines; // (capacity) 74 | /*828,4*/ real32 displayDelay; 75 | /*82c,4*/ TextWindowFlags flags; 76 | /*830*/ 77 | }; 78 | assert_sizeof(TextWindow, 0x830); 79 | 80 | #pragma endregion 81 | 82 | /********************************************************************************** 83 | ******** Functions 84 | **********************************************************************************/ 85 | 86 | #pragma region Functions 87 | 88 | // 89 | TextWindow* __cdecl TextWindow_Create(Font* font, const Area2F* size, uint32 bufferSize); 90 | 91 | // 92 | void __cdecl TextWindow_EnableCentering(TextWindow* window, bool32 enable); 93 | 94 | // 95 | void __cdecl TextWindow_Remove(TextWindow* window); 96 | 97 | // 98 | void __cdecl TextWindow_ChangePosition(TextWindow* window, sint32 xPos, sint32 yPos); 99 | 100 | // 101 | void __cdecl TextWindow_ChangeSize(TextWindow* window, uint32 width, uint32 height); 102 | 103 | // 104 | void __cdecl TextWindow_PagePrintF(TextWindow* window, uint32 page, const char* msg, ...); 105 | 106 | // 107 | void __cdecl TextWindow_PrintF(TextWindow* window, const char* msg, ...); 108 | 109 | // 110 | void __cdecl TextWindow_VPrintF(TextWindow* window, uint32 page, const char* msg, std::va_list args); 111 | 112 | // 113 | void __cdecl TextWindow_PrintFOverlay(TextWindow* window, bool32 oneFrame, const char* msg, ...); 114 | 115 | // 116 | bool32 __cdecl TextWindow_Update(TextWindow* window, uint32 posFromEnd, real32 time, OUT sint32* lpLowestPoint); 117 | 118 | // 119 | bool32 __cdecl TextWindow_UpdateOverlay(TextWindow* window, real32 time, OUT sint32* lpLowestPoint); 120 | 121 | // 122 | void __cdecl TextWindow_Clear(TextWindow* window); 123 | 124 | // 125 | void __cdecl TextWindow_GetInfo(TextWindow* window, OUT uint32* linesUsed, OUT uint32* linesInWindow); 126 | 127 | 128 | // 129 | sint32 __cdecl TextWindow_GetDrawPos(TextWindow* window, uint32 chrPos, uint32 line, uint32 xpos, bool32 check); 130 | 131 | // 132 | sint32 __cdecl TextWindow_GetRow(TextWindow* window, sint32 chrPos, sint32 dir); 133 | 134 | // 135 | void __cdecl TextWindow_SetFont(TextWindow* window, Font* font); 136 | 137 | #pragma endregion 138 | 139 | } 140 | -------------------------------------------------------------------------------- /src/openlrr/engine/gfx/Activities.cpp: -------------------------------------------------------------------------------- 1 | // Activities.cpp : 2 | // 3 | 4 | #include "../core/Config.h" 5 | #include "../core/Errors.h" 6 | #include "../core/Utils.h" 7 | 8 | #include "Activities.h" 9 | 10 | 11 | /********************************************************************************** 12 | ******** Functions 13 | **********************************************************************************/ 14 | 15 | #pragma region Functions 16 | 17 | // Possibly inlined inside Container_Load 18 | // 19 | uint32 __cdecl Gods98::Activity_Load(const char* filename, const char* gameID, IN char* arglist, ActivityReadCallback ReadCallBack, void* data) 20 | { 21 | char* argv[ACTIVITY_MAXARGS]; 22 | char* result; 23 | char searchString[UTIL_DEFSTRINGLEN]; 24 | uint32 calls=0; 25 | Config* conf; 26 | 27 | std::sprintf(searchString, "%s\\%s.ae", filename, filename); 28 | if (conf = Config_Load(searchString)){ 29 | 30 | uint32 count; 31 | if (count = Util_Tokenise(arglist, argv, ACTIVITY_SEPARATOR)){ 32 | for (uint32 loop=0 ; loop 52 | uint32 __cdecl Activity_Load(const char* filename, const char* gameID, IN char* arglist, ActivityReadCallback ReadCallBack, void* data); 53 | 54 | #pragma endregion 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/openlrr/engine/gfx/AnimClone.h: -------------------------------------------------------------------------------- 1 | // AnimClone.h : 2 | // 3 | /// APIS: IDirect3DRM3, IDirect3DRMAnimationSet2, IDirect3DRMFrame[13|Array], 4 | /// IDirect3DRMUserVisual, IDirect3DRMVisual 5 | /// DEPENDENCIES: Lws, Main, Mesh, (Containers, Errors, Memory) 6 | /// DEPENDENTS: Containers 7 | 8 | #pragma once 9 | 10 | #include "../../common.h" 11 | 12 | 13 | /********************************************************************************** 14 | ******** Forward Global Namespace Declarations 15 | **********************************************************************************/ 16 | 17 | #pragma region Forward Declarations 18 | 19 | struct IDirect3DRMAnimationSet2; 20 | struct IDirect3DRMFrame3; 21 | 22 | #pragma endregion 23 | 24 | 25 | namespace Gods98 26 | {; // !<--- 27 | 28 | /********************************************************************************** 29 | ******** Forward Declarations 30 | **********************************************************************************/ 31 | 32 | #pragma region Forward Declarations 33 | 34 | struct Lws_Info; // from `engine/gfx/Lws.h` 35 | 36 | #pragma endregion 37 | 38 | /********************************************************************************** 39 | ******** Function Typedefs 40 | **********************************************************************************/ 41 | 42 | #pragma region Function Typedefs 43 | 44 | typedef bool32 (__cdecl* AnimClone_WalkTreeCallback)(IDirect3DRMFrame3* frame, void* data); 45 | 46 | #pragma endregion 47 | 48 | /********************************************************************************** 49 | ******** Constants 50 | **********************************************************************************/ 51 | 52 | #pragma region Constants 53 | 54 | #define ANIMCLONE_MAXVISUALS 4 55 | 56 | #pragma endregion 57 | 58 | /********************************************************************************** 59 | ******** Structures 60 | **********************************************************************************/ 61 | 62 | #pragma region Structs 63 | 64 | struct AnimClone 65 | { 66 | /*00,4*/ AnimClone* clonedFrom; 67 | /*04,4*/ Lws_Info* scene; 68 | /*08,4*/ IDirect3DRMAnimationSet2* animSet; 69 | /*0c,4*/ bool32 lws; 70 | /*10,4*/ IDirect3DRMFrame3* root; 71 | /*14,4*/ IDirect3DRMFrame3** partArray; 72 | /*18,4*/ uint32 partCount; 73 | /*1c,4*/ uint32 frameCount; 74 | /*20*/ 75 | }; 76 | assert_sizeof(AnimClone, 0x20); 77 | 78 | #pragma endregion 79 | 80 | /********************************************************************************** 81 | ******** Functions 82 | **********************************************************************************/ 83 | 84 | #pragma region Functions 85 | 86 | // 87 | AnimClone* __cdecl AnimClone_Register(IDirect3DRMAnimationSet2* animSet, IDirect3DRMFrame3* root, uint32 frameCount); 88 | 89 | // 90 | AnimClone* __cdecl AnimClone_RegisterLws(Lws_Info* scene, IDirect3DRMFrame3* root, uint32 frameCount); 91 | 92 | // 93 | AnimClone* __cdecl AnimClone_Make(AnimClone* orig, IDirect3DRMFrame3* parent, OPTIONAL OUT uint32* frameCount); 94 | 95 | // 96 | void __cdecl AnimClone_Remove(AnimClone* dead); 97 | 98 | 99 | // This function performs the same accessor, 100 | // shared between 3 different structure types. 101 | // uint32 __cdecl Flic_GetWidth(Flic* fsp); 102 | // bool32 __cdecl AnimClone_IsLws(AnimClone* clone); 103 | // uint32 __cdecl Flocks_GetNumSubdata(Flocks* flocksData); 104 | // (shared) "AnimClone_IsLws__Flic_GetWidth" 105 | // THIS FUNCTION MUST BE HOOKED ON AN INDIVIDUAL BASIS 106 | // There are 5 calls made to this: 107 | // type:Flic (Flic_GetWidth) -> FUN_004120e0 <@004120f7> 108 | // Panel_Draw <@0045ab17> 109 | // Pointer_DrawPointer <@0045cfc8> 110 | // type:FlocksData (Flocks_GetNumSubdata) -> LegoObject_Flocks_FUN_0044bef0 <@0044bfc3> 111 | // type:AnimClone (AnimClone_IsLws) -> Container_FormatPartName <@00473f60> 112 | // 113 | // Only called by Container_FormatPartName 114 | // 115 | // 116 | bool32 __cdecl AnimClone_IsLws(const AnimClone* clone); 117 | 118 | 119 | // 120 | void __cdecl AnimClone_SetTime(AnimClone* clone, real32 time, OPTIONAL const real32* oldTime); 121 | 122 | // 123 | bool32 __cdecl AnimClone_FrameCountCallback(IDirect3DRMFrame3* frame, void* data); 124 | 125 | // 126 | bool32 __cdecl AnimClone_SetupFrameArrayCallback(IDirect3DRMFrame3* frame, void* p); 127 | 128 | // 129 | bool32 __cdecl AnimClone_WalkTree(IDirect3DRMFrame3* frame, uint32 level, 130 | AnimClone_WalkTreeCallback callback, void* data); 131 | 132 | // 133 | void __cdecl AnimClone_CreateCopy(IDirect3DRMFrame3* orig, IDirect3DRMFrame3* clone, bool32 lws); 134 | 135 | // 136 | void __cdecl AnimClone_CloneLwsMesh(IDirect3DRMFrame3* orig, IDirect3DRMFrame3* clone); 137 | 138 | // 139 | void __cdecl AnimClone_ReferenceVisuals(IDirect3DRMFrame3* orig, IDirect3DRMFrame3* clone); 140 | 141 | #pragma endregion 142 | 143 | } 144 | 145 | -------------------------------------------------------------------------------- /src/openlrr/engine/gfx/Materials.cpp: -------------------------------------------------------------------------------- 1 | // Materials.cpp : 2 | // 3 | 4 | #include "../../platform/d3drm.h" 5 | 6 | #include "../core/Errors.h" 7 | #include "../Graphics.h" 8 | 9 | #include "Materials.h" 10 | 11 | 12 | /********************************************************************************** 13 | ******** Functions 14 | **********************************************************************************/ 15 | 16 | #pragma region Functions 17 | 18 | // 19 | Gods98::Material* __cdecl Gods98::Material_Create(real32 emissiveRed, real32 emissiveGreen, real32 emissiveBlue, 20 | real32 specularRed, real32 specularGreen, real32 specularBlue, real32 power) 21 | { 22 | log_firstcall(); 23 | 24 | IDirect3DRMMaterial2* mat; 25 | 26 | if (lpD3DRM()->CreateMaterial(power, &mat) == D3DRM_OK) { 27 | mat->SetEmissive(emissiveRed, emissiveGreen, emissiveBlue); 28 | mat->SetSpecular(specularRed, specularGreen, specularBlue); 29 | return (Material*) mat; 30 | } 31 | 32 | return nullptr; 33 | } 34 | 35 | 36 | // 37 | void __cdecl Gods98::Material_Remove(Material* material) 38 | { 39 | 40 | /// FIXME GODS98: using IDirect3DRMMaterial* instead of IDirect3DRMMaterial2* 41 | IDirect3DRMMaterial* mat = (IDirect3DRMMaterial*) material; 42 | 43 | Error_Fatal(!mat, "Null passed as material to Material_Remove()"); 44 | 45 | mat->Release(); 46 | } 47 | 48 | // 49 | void __cdecl Gods98::Material_SetEmissive(Material* material, real32 emissiveRed, real32 emissiveGreen, real32 emissiveBlue) 50 | { 51 | /// FIXME GODS98: using IDirect3DRMMaterial* instead of IDirect3DRMMaterial2* 52 | IDirect3DRMMaterial* mat = (IDirect3DRMMaterial*) material; 53 | 54 | Error_Fatal(!mat, "Null passed as material to Material_SetEmissive()"); 55 | 56 | mat->SetEmissive(emissiveRed, emissiveGreen, emissiveBlue); 57 | } 58 | 59 | // 60 | void __cdecl Gods98::Material_SetSpecular(Material* material, real32 specularRed, real32 specularGreen, real32 specularBlue, real32 power) 61 | { 62 | /// FIXME GODS98: using IDirect3DRMMaterial* instead of IDirect3DRMMaterial2* 63 | IDirect3DRMMaterial* mat = (IDirect3DRMMaterial*) material; 64 | 65 | Error_Fatal(!mat, "Null passed as material to Material_SetSpecular()"); 66 | 67 | mat->SetPower(power); 68 | mat->SetSpecular(specularRed, specularGreen, specularBlue); 69 | } 70 | 71 | #pragma endregion 72 | -------------------------------------------------------------------------------- /src/openlrr/engine/gfx/Materials.h: -------------------------------------------------------------------------------- 1 | // Materials.h : 2 | // 3 | /// APIS: IDirect3DRM3, IDirect3DRMMaterial[12] 4 | /// DEPENDENCIES: Main, (Errors) 5 | /// DEPENDENTS: Map3D 6 | 7 | #pragma once 8 | 9 | #include "../../common.h" 10 | 11 | 12 | namespace Gods98 13 | {; // !<--- 14 | 15 | /********************************************************************************** 16 | ******** Structures 17 | **********************************************************************************/ 18 | 19 | #pragma region Structs 20 | 21 | // Essentially a typedef pointer to IDirect3DRMMaterial2 (when treated as Material*) 22 | struct Material 23 | { 24 | uint32 dummy; 25 | }; 26 | assert_sizeof(Material, 0x4); 27 | 28 | /// ALT: Similar to the Movie/Animation C wrapper typedefs 29 | //typedef void Material; 30 | 31 | #pragma endregion 32 | 33 | /********************************************************************************** 34 | ******** Functions 35 | **********************************************************************************/ 36 | 37 | #pragma region Functions 38 | 39 | // 40 | Material* __cdecl Material_Create(real32 emissiveRed, real32 emissiveGreen, real32 emissiveBlue, 41 | real32 specularRed, real32 specularGreen, real32 specularBlue, real32 power); 42 | 43 | 44 | // 45 | void __cdecl Material_Remove(Material* material); 46 | 47 | // 48 | void __cdecl Material_SetEmissive(Material* material, real32 emissiveRed, real32 emissiveGreen, real32 emissiveBlue); 49 | 50 | // 51 | void __cdecl Material_SetSpecular(Material* material, real32 specularRed, real32 specularGreen, real32 specularBlue, real32 power); 52 | 53 | #pragma endregion 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/openlrr/engine/input/Keys.cpp: -------------------------------------------------------------------------------- 1 | // Keys.cpp : 2 | // 3 | 4 | #include "../core/Errors.h" 5 | 6 | #include "Keys.h" 7 | 8 | 9 | /********************************************************************************** 10 | ******** Globals 11 | **********************************************************************************/ 12 | 13 | #pragma region Globals 14 | 15 | // 16 | Gods98::Key_Globs & Gods98::keyGlobs = *(Gods98::Key_Globs*)0x005775e0; 17 | 18 | #pragma endregion 19 | 20 | /********************************************************************************** 21 | ******** Functions 22 | **********************************************************************************/ 23 | 24 | #pragma region Functions 25 | 26 | // 27 | void __cdecl Gods98::Keys_Initialise(void) 28 | { 29 | log_firstcall(); 30 | 31 | for (uint32 loop = 0; loop < _countof(keyGlobs.keyName); loop++) { 32 | keyGlobs.keyName[loop] = nullptr; 33 | } 34 | 35 | //Key_RegisterName(KEY_NONE); 36 | Key_RegisterName(KEY_ESCAPE); 37 | Key_RegisterName(KEY_ONE); 38 | Key_RegisterName(KEY_TWO); 39 | Key_RegisterName(KEY_THREE); 40 | Key_RegisterName(KEY_FOUR); 41 | Key_RegisterName(KEY_FIVE); 42 | Key_RegisterName(KEY_SIX); 43 | Key_RegisterName(KEY_SEVEN); 44 | Key_RegisterName(KEY_EIGHT); 45 | Key_RegisterName(KEY_NINE); 46 | Key_RegisterName(KEY_ZERO); 47 | Key_RegisterName(KEY_MINUS); 48 | Key_RegisterName(KEY_EQUALS); 49 | Key_RegisterName(KEY_BACKSPACE); 50 | Key_RegisterName(KEY_TAB); 51 | Key_RegisterName(KEY_Q); 52 | Key_RegisterName(KEY_W); 53 | Key_RegisterName(KEY_E); 54 | Key_RegisterName(KEY_R); 55 | Key_RegisterName(KEY_T); 56 | Key_RegisterName(KEY_Y); 57 | Key_RegisterName(KEY_U); 58 | Key_RegisterName(KEY_I); 59 | Key_RegisterName(KEY_O); 60 | Key_RegisterName(KEY_P); 61 | Key_RegisterName(KEY_LEFTBRACE); 62 | Key_RegisterName(KEY_RIGHTBRACE); 63 | Key_RegisterName(KEY_RETURN); 64 | Key_RegisterName(KEY_LEFTCTRL); 65 | Key_RegisterName(KEY_A); 66 | Key_RegisterName(KEY_S); 67 | Key_RegisterName(KEY_D); 68 | Key_RegisterName(KEY_F); 69 | Key_RegisterName(KEY_G); 70 | Key_RegisterName(KEY_H); 71 | Key_RegisterName(KEY_J); 72 | Key_RegisterName(KEY_K); 73 | Key_RegisterName(KEY_L); 74 | Key_RegisterName(KEY_SEMICOLON); 75 | Key_RegisterName(KEY_AT); 76 | Key_RegisterName(KEY_RSINGLEQUOTE); 77 | Key_RegisterName(KEY_LEFTSHIFT); 78 | Key_RegisterName(KEY_HASH); 79 | Key_RegisterName(KEY_Z); 80 | Key_RegisterName(KEY_X); 81 | Key_RegisterName(KEY_C); 82 | Key_RegisterName(KEY_V); 83 | Key_RegisterName(KEY_B); 84 | Key_RegisterName(KEY_N); 85 | Key_RegisterName(KEY_M); 86 | Key_RegisterName(KEY_LEFTARROW); 87 | Key_RegisterName(KEY_RIGHTARROW); 88 | Key_RegisterName(KEY_QUESTIONMARK); 89 | Key_RegisterName(KEY_RIGHTSHIFT); 90 | Key_RegisterName(KEYPAD_ASTERISK); 91 | Key_RegisterName(KEY_ALT); 92 | Key_RegisterName(KEY_SPACE); 93 | Key_RegisterName(KEY_CAPLOCK); 94 | Key_RegisterName(KEY_F1); 95 | Key_RegisterName(KEY_F2); 96 | Key_RegisterName(KEY_F3); 97 | Key_RegisterName(KEY_F4); 98 | Key_RegisterName(KEY_F5); 99 | Key_RegisterName(KEY_F6); 100 | Key_RegisterName(KEY_F7); 101 | Key_RegisterName(KEY_F8); 102 | Key_RegisterName(KEY_F9); 103 | Key_RegisterName(KEY_F10); 104 | Key_RegisterName(KEYPAD_NUMLOCK); 105 | Key_RegisterName(KEY_SCROLLLOCK); 106 | Key_RegisterName(KEYPAD_7); 107 | Key_RegisterName(KEYPAD_8); 108 | Key_RegisterName(KEYPAD_9); 109 | Key_RegisterName(KEYPAD_MINUS); 110 | Key_RegisterName(KEYPAD_4); 111 | Key_RegisterName(KEYPAD_5); 112 | Key_RegisterName(KEYPAD_6); 113 | Key_RegisterName(KEYPAD_PLUS); 114 | Key_RegisterName(KEYPAD_1); 115 | Key_RegisterName(KEYPAD_2); 116 | Key_RegisterName(KEYPAD_3); 117 | Key_RegisterName(KEYPAD_0); 118 | Key_RegisterName(KEYPAD_DELETE); 119 | Key_RegisterName(KEY_BACKSLASH); 120 | Key_RegisterName(KEY_F11); 121 | Key_RegisterName(KEY_F12); 122 | Key_RegisterName(KEYPAD_ENTER); 123 | Key_RegisterName(KEY_RIGHTCTRL); 124 | Key_RegisterName(KEYPAD_FORWARDSLASH); 125 | Key_RegisterName(KEY_PRINTSCREEN); 126 | Key_RegisterName(KEY_ALTGR); 127 | Key_RegisterName(KEY_HOME); 128 | Key_RegisterName(KEY_CURSORUP); 129 | Key_RegisterName(KEY_PGUP); 130 | Key_RegisterName(KEY_CURSORLEFT); 131 | Key_RegisterName(KEY_CURSORRIGHT); 132 | Key_RegisterName(KEY_END); 133 | Key_RegisterName(KEY_CURSORDOWN); 134 | Key_RegisterName(KEY_PGDN); 135 | Key_RegisterName(KEY_INSERT); 136 | Key_RegisterName(KEY_DELETE); 137 | } 138 | 139 | // 140 | bool32 __cdecl Gods98::Key_Find(const char* name, OUT Keys* keyID) 141 | { 142 | log_firstcall(); 143 | 144 | for (uint32 loop = 0; loop < _countof(keyGlobs.keyName); loop++) { 145 | if (keyGlobs.keyName[loop] && ::_stricmp(keyGlobs.keyName[loop], name) == 0) { 146 | *keyID = (Keys)loop; 147 | return true; 148 | } 149 | } 150 | 151 | return false; 152 | } 153 | 154 | // 155 | const char* __cdecl Gods98::Key_GetName(Keys key) 156 | { 157 | return keyGlobs.keyName[key]; 158 | } 159 | 160 | #pragma endregion 161 | -------------------------------------------------------------------------------- /src/openlrr/engine/input/MouseButtons.cpp: -------------------------------------------------------------------------------- 1 | // MouseButtons.cpp : 2 | // 3 | 4 | #include "../core/Errors.h" 5 | 6 | #include "MouseButtons.h" 7 | 8 | 9 | /********************************************************************************** 10 | ******** Globals 11 | **********************************************************************************/ 12 | 13 | #pragma region Globals 14 | 15 | Gods98::MouseButton_Globs Gods98::mouseButtonGlobs = { 0 }; 16 | 17 | #pragma endregion 18 | 19 | /********************************************************************************** 20 | ******** Functions 21 | **********************************************************************************/ 22 | 23 | #pragma region Functions 24 | 25 | void __cdecl Gods98::MouseButtons_Initialise(void) 26 | { 27 | log_firstcall(); 28 | 29 | for (uint32 loop = 0; loop < _countof(mouseButtonGlobs.buttonName); loop++) { 30 | mouseButtonGlobs.buttonName[loop] = nullptr; 31 | } 32 | 33 | //MouseButton_RegisterName(MOUSE_NONE); 34 | MouseButton_RegisterName(MOUSE_LEFT); 35 | MouseButton_RegisterName(MOUSE_MIDDLE); 36 | MouseButton_RegisterName(MOUSE_RIGHT); 37 | MouseButton_RegisterName(MOUSE_XBUTTON1); 38 | MouseButton_RegisterName(MOUSE_XBUTTON2); 39 | } 40 | 41 | bool32 __cdecl Gods98::MouseButton_Find(const char* name, OUT MouseButtons* mouseButtonID) 42 | { 43 | log_firstcall(); 44 | 45 | for (uint32 loop = 0; loop < _countof(mouseButtonGlobs.buttonName); loop++) { 46 | if (mouseButtonGlobs.buttonName[loop] && ::_stricmp(mouseButtonGlobs.buttonName[loop], name) == 0) { 47 | *mouseButtonID = (MouseButtons)loop; 48 | return true; 49 | } 50 | } 51 | 52 | return false; 53 | } 54 | 55 | const char* __cdecl Gods98::MouseButton_GetName(MouseButtons mouseButton) 56 | { 57 | return mouseButtonGlobs.buttonName[mouseButton]; 58 | } 59 | 60 | #pragma endregion 61 | -------------------------------------------------------------------------------- /src/openlrr/engine/input/MouseButtons.h: -------------------------------------------------------------------------------- 1 | // MouseButtons.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "../../common.h" 7 | 8 | 9 | namespace Gods98 10 | {; // !<--- 11 | 12 | /********************************************************************************** 13 | ******** Constants 14 | **********************************************************************************/ 15 | 16 | #pragma region Constants 17 | 18 | #pragma endregion 19 | 20 | /********************************************************************************** 21 | ******** Enumerations 22 | **********************************************************************************/ 23 | 24 | #pragma region Enums 25 | 26 | enum MouseButtons : uint8 27 | { 28 | MOUSE_NONE = 0, // Not a real MOUSE BUTTON enum name 29 | MOUSE_LEFT = 1, 30 | MOUSE_MIDDLE = 2, 31 | MOUSE_RIGHT = 3, 32 | MOUSE_XBUTTON1 = 4, 33 | MOUSE_XBUTTON2 = 5, 34 | }; 35 | 36 | #pragma endregion 37 | 38 | /********************************************************************************** 39 | ******** Structures 40 | **********************************************************************************/ 41 | 42 | #pragma region Structs 43 | 44 | struct MouseButton_Globs 45 | { 46 | const char* buttonName[6]; 47 | }; 48 | 49 | #pragma endregion 50 | 51 | /********************************************************************************** 52 | ******** Globals 53 | **********************************************************************************/ 54 | 55 | #pragma region Globals 56 | 57 | extern MouseButton_Globs mouseButtonGlobs; 58 | 59 | #pragma endregion 60 | 61 | /********************************************************************************** 62 | ******** Macros 63 | **********************************************************************************/ 64 | 65 | #pragma region Macros 66 | 67 | #define MouseButton_RegisterName(k) (mouseButtonGlobs.buttonName[k]=#k) 68 | 69 | #pragma endregion 70 | 71 | /********************************************************************************** 72 | ******** Functions 73 | **********************************************************************************/ 74 | 75 | #pragma region Functions 76 | 77 | void __cdecl MouseButtons_Initialise(void); 78 | 79 | bool32 __cdecl MouseButton_Find(const char* name, OUT MouseButtons* mouseButtonID); 80 | 81 | const char* __cdecl MouseButton_GetName(MouseButtons mouseButton); 82 | 83 | #pragma endregion 84 | 85 | } 86 | 87 | -------------------------------------------------------------------------------- /src/openlrr/engine/undefined.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../common.h" 4 | 5 | 6 | #pragma region Undefined typedefs 7 | 8 | typedef uint8 undefined; 9 | typedef uint8 undefined1; 10 | typedef uint16 undefined2; 11 | typedef uint32 undefined4; 12 | typedef uint64 undefined8; 13 | 14 | typedef uint8 flags8; 15 | typedef uint16 flags16; 16 | typedef uint32 flags32; 17 | 18 | #pragma endregion 19 | -------------------------------------------------------------------------------- /src/openlrr/engine/util/Registry.cpp: -------------------------------------------------------------------------------- 1 | // Registry.cpp : 2 | // 3 | 4 | #include "../../platform/windows.h" 5 | #include "../core/Errors.h" 6 | 7 | #include "Registry.h" 8 | 9 | 10 | /********************************************************************************** 11 | ******** Functions 12 | **********************************************************************************/ 13 | 14 | #pragma region Functions 15 | 16 | // 17 | // 18 | const char* __cdecl Gods98::Registry_GetKeyFromPath(const char* path, OUT char* str) 19 | { 20 | log_firstcall(); 21 | 22 | *str = '\0'; 23 | while (*path && *path != '\\') { 24 | *str = *path; 25 | path++; 26 | str++; 27 | } 28 | 29 | if (*path == '\\') path++; 30 | *str = '\0'; 31 | 32 | return path; 33 | } 34 | 35 | 36 | // 37 | bool32 __cdecl Gods98::Registry_SetValue(const char* path, 38 | const char* key, 39 | RegistryValue dataType, 40 | const void* data, 41 | uint32 dataSize) 42 | { 43 | return Registry_SetValue_Recursive(HKEY_LOCAL_MACHINE, path, key, dataType, data, dataSize); 44 | } 45 | 46 | 47 | // 48 | bool32 __cdecl Gods98::Registry_GetValue(const char* path, 49 | const char* key, 50 | RegistryValue dataType, 51 | OUT void* data, 52 | uint32 dataSize) 53 | { 54 | log_firstcall(); 55 | 56 | return Registry_GetValue_Recursive(HKEY_LOCAL_MACHINE, path, key, dataType, data, dataSize); 57 | } 58 | 59 | // 60 | bool32 __cdecl Gods98::Registry_SetValue_Recursive(HKEY parent, 61 | const char* path, 62 | const char* key, 63 | RegistryValue dataType, 64 | const void* data, 65 | uint32 dataSize) 66 | { 67 | HKEY localKey; 68 | char str[100]; 69 | 70 | const char* newPath = Registry_GetKeyFromPath(path, str); 71 | 72 | if (!str[0]) { 73 | // Set the value 74 | switch (dataType) { 75 | case RegistryValue::String: 76 | ::RegSetValueExA(parent, key, 0, REG_SZ, (const BYTE*)data, dataSize); 77 | return true; 78 | 79 | case RegistryValue::Dword: 80 | ::RegSetValueExA(parent, key, 0, REG_DWORD, (const BYTE*)data, dataSize); 81 | return true; 82 | 83 | default: 84 | return false; 85 | } 86 | } 87 | else { 88 | // Open the key and recurse 89 | ::RegCreateKeyA(parent, str, &localKey); 90 | 91 | if (!localKey) return false; 92 | 93 | bool32 retVal = (bool32)Registry_SetValue_Recursive(localKey, newPath, key, dataType, data, dataSize); 94 | 95 | ::RegCloseKey(localKey); 96 | 97 | return retVal; 98 | } 99 | } 100 | 101 | // 102 | bool32 __cdecl Gods98::Registry_GetValue_Recursive(HKEY parent, 103 | const char* path, 104 | const char* key, 105 | RegistryValue dataType, 106 | OUT void* data, 107 | uint32 dataSize) 108 | { 109 | log_firstcall(); 110 | 111 | HKEY localKey; 112 | char str[100]; 113 | 114 | const char* newPath = Registry_GetKeyFromPath(path, str); 115 | 116 | if (!str[0]) { 117 | DWORD _dataSize = dataSize; 118 | DWORD _dataType = 0; 119 | 120 | // Set the value 121 | switch (dataType) { 122 | case RegistryValue::String: 123 | return (::RegQueryValueExA(parent, key, 0, &_dataType, (BYTE*)data, &_dataSize) == ERROR_SUCCESS); 124 | 125 | case RegistryValue::Dword: 126 | return (::RegQueryValueExA(parent, key, 0, &_dataType, (BYTE*)data, &_dataSize) == ERROR_SUCCESS); 127 | 128 | default: 129 | return false; 130 | } 131 | } 132 | else { 133 | // Open the key and recurse 134 | ::RegCreateKeyA(parent, str, &localKey); 135 | 136 | if (!localKey) return false; 137 | 138 | bool32 retVal = (bool32)Registry_GetValue_Recursive(localKey, newPath, key, dataType, data, dataSize); 139 | 140 | ::RegCloseKey(localKey); 141 | 142 | return retVal; 143 | } 144 | } 145 | 146 | #pragma endregion 147 | -------------------------------------------------------------------------------- /src/openlrr/engine/util/Registry.h: -------------------------------------------------------------------------------- 1 | // Registry.h : 2 | // 3 | /// APIS: win32 4 | /// DEPENDENCIES: - 5 | /// DEPENDENTS: Files, Main 6 | 7 | #pragma once 8 | 9 | #include "../../common.h" 10 | 11 | 12 | namespace Gods98 13 | {; // !<--- 14 | 15 | /********************************************************************************** 16 | ******** Enumerations 17 | **********************************************************************************/ 18 | 19 | #pragma region Enums 20 | 21 | // Supported registry value kinds 22 | enum class RegistryValue : uint32 23 | { 24 | String = 0, 25 | Dword = 1, 26 | }; 27 | assert_sizeof(RegistryValue, 0x4); 28 | 29 | #pragma endregion 30 | 31 | /********************************************************************************** 32 | ******** Functions 33 | **********************************************************************************/ 34 | 35 | #pragma region Functions 36 | 37 | // 38 | // 39 | const char* __cdecl Registry_GetKeyFromPath(const char* path, OUT char* str); 40 | 41 | 42 | // 43 | bool32 __cdecl Registry_SetValue(const char* path, 44 | const char* key, 45 | RegistryValue dataType, 46 | const void* data, 47 | uint32 dataSize); 48 | 49 | 50 | // 51 | bool32 __cdecl Registry_GetValue(const char* path, 52 | const char* key, 53 | RegistryValue dataType, 54 | OUT void* data, 55 | uint32 dataSize); 56 | 57 | // 58 | bool32 __cdecl Registry_SetValue_Recursive(HKEY parent, 59 | const char* path, 60 | const char* key, 61 | RegistryValue dataType, 62 | const void* data, 63 | uint32 dataSize); 64 | 65 | // 66 | bool32 __cdecl Registry_GetValue_Recursive(HKEY parent, 67 | const char* path, 68 | const char* key, 69 | RegistryValue dataType, 70 | OUT void* data, 71 | uint32 dataSize); 72 | 73 | #pragma endregion 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/openlrr/engine/video/Animation.h: -------------------------------------------------------------------------------- 1 | // Animation.h : Header file for the C G98CAnimation wrapper around the C++ implementation. 2 | // 3 | /// PURPOSE: Animation is only by the Credits looping starfield background AVI. 4 | /// This uses the AVIFile API, and thus is likely restricted to this file format. 5 | /// This is likely used over the VideoPlayer class, since it offers more flexibility 6 | /// with rendering, which allows drawing the credits text over-top and manually handling 7 | /// video looping. 8 | /// 9 | /// INITIALISE: Call `Animation_Initialise(IDirectDraw4*)` once on startup. `IDirectDraw4*` is not owned by this module. 10 | /// (no cleanup) 11 | /// GLOBALS: private 12 | /// FILEIO: Data[std] 13 | /// APIS: IDirectDraw4, IDirectDrawClipper(unused), IDirectDrawPalette, IDirectDrawSurface[14] 14 | /// IAVIStream, IGetFrame 15 | /// DEPENDENCIES: DirectDraw, Files 16 | /// DEPENDENTS: Credits 17 | 18 | #pragma once 19 | 20 | #include "../../common.h" 21 | #include "../geometry.h" 22 | 23 | 24 | /********************************************************************************** 25 | ******** Forward Global Namespace Declarations 26 | **********************************************************************************/ 27 | 28 | #pragma region Forward Declarations 29 | 30 | struct IDirectDraw4; 31 | 32 | #pragma endregion 33 | 34 | 35 | namespace Gods98 36 | {; // !<--- 37 | 38 | /********************************************************************************** 39 | ******** Typedefs 40 | **********************************************************************************/ 41 | 42 | #pragma region Typedefs 43 | 44 | // C wrapper typedef around G98CAnimation class. 45 | typedef void Animation_t; 46 | 47 | #pragma endregion 48 | 49 | /********************************************************************************** 50 | ******** Structures 51 | **********************************************************************************/ 52 | 53 | #pragma region Structs 54 | 55 | struct Animation_Globs 56 | { 57 | /*0,1*/ bool g98NoAvis; 58 | ///*1,3*/ uint8 padding1[3]; 59 | /*4,4*/ IDirectDraw4* ddraw; 60 | /*8*/ 61 | }; 62 | assert_sizeof(Animation_Globs, 0x8); 63 | 64 | #pragma endregion 65 | 66 | /********************************************************************************** 67 | ******** Globals 68 | **********************************************************************************/ 69 | 70 | #pragma region Globals 71 | 72 | // 73 | extern Animation_Globs & animationGlobs; 74 | 75 | #pragma endregion 76 | 77 | /********************************************************************************** 78 | ******** Functions 79 | **********************************************************************************/ 80 | 81 | #pragma region Functions 82 | 83 | // 84 | void __cdecl Animation_Initialise(IDirectDraw4* directDraw); 85 | 86 | 87 | // 88 | void __cdecl Animation_ShutDown(void); 89 | 90 | 91 | // 92 | Animation_t* __cdecl Animation_Load(const char* fName); 93 | 94 | // 95 | bool32 __cdecl Animation_Update(Animation_t* anim); 96 | 97 | // 98 | void __cdecl Animation_BlitToBackBuffer(Animation_t* anim, const Rect2I* destRect); 99 | 100 | // Sets the animation time in frame units. 101 | // 102 | void __cdecl Animation_SetTime(Animation_t* anim, uint32 time); 103 | 104 | // Gets the animation time in frame units. 105 | // 106 | uint32 __cdecl Animation_GetTime(const Animation_t* anim); 107 | 108 | // Gets the animation length in frame units. 109 | // 110 | uint32 __cdecl Animation_GetLength(const Animation_t* anim); 111 | 112 | // 113 | void __cdecl Animation_Free(Animation_t* anim); 114 | 115 | // 116 | bool32 __cdecl Animation_IsOk(const Animation_t* anim); 117 | 118 | #pragma endregion 119 | 120 | } 121 | -------------------------------------------------------------------------------- /src/openlrr/engine/video/Movie.h: -------------------------------------------------------------------------------- 1 | // Movie.h : Header file for the C G98CMovie wrapper around the C++ implementation. 2 | // 3 | /// PURPOSE: Movie is used by all types of AVI video playback EXCEPT the credits starfield loop 4 | /// This uses the IAMMultiMediaStream system, so this is why other video types are supported. 5 | /// 6 | /// FILEIO: Data[std,cd] 7 | /// APIS: IDirectDraw[24], IDirectDrawSurface[134], IDirectDrawStreamSample, 8 | /// IDirectDrawMediaStream, IMediaStream, IAMMultiMediaStream 9 | /// DEPENDENCIES: DirectDraw, Files 10 | /// DEPENDENTS: FrontEnd, Lego, Rewards 11 | 12 | #pragma once 13 | 14 | #include "../../common.h" 15 | #include "../geometry.h" 16 | 17 | 18 | namespace Gods98 19 | {; // !<--- 20 | 21 | /********************************************************************************** 22 | ******** Typedefs 23 | **********************************************************************************/ 24 | 25 | #pragma region Typedefs 26 | 27 | // C wrapper typedef around G98CMovie class. 28 | typedef void Movie_t; 29 | 30 | #pragma endregion 31 | 32 | /********************************************************************************** 33 | ******** Functions 34 | **********************************************************************************/ 35 | 36 | #pragma region Functions 37 | 38 | /// CUSTOM: Temporarily sets up a media stream to speed up audio load times. 39 | /// This does not need to be called if Movie_Load is called successfully. 40 | /// This function is placed here, because it uses the same API as Movie, and 41 | /// only needs to be called when not calling Movie_Load. 42 | bool Movie_ImproveAudioLoadSpeed(); 43 | 44 | // 45 | Movie_t* __cdecl Movie_Load(const char* fName); 46 | 47 | // cannot be const, due to using IDirectDraw-type interface 48 | // 49 | void __cdecl Movie_GetSize(Movie_t* mov, OUT uint32* width, OUT uint32* height); 50 | 51 | // Gets the movie duration in milliseconds. 52 | // cannot be const, due to using IMultiMedia-type interface 53 | // 54 | sint64 __cdecl Movie_GetDuration(Movie_t* mov); 55 | 56 | // also performs BlitToBackBuffer 57 | // float speed parameter is unused (name is assumed as 1.0f is always passed) 58 | // 59 | bool32 __cdecl Movie_Update(Movie_t* mov, real32 speed, const Rect2I* destRect); 60 | 61 | // 62 | void __cdecl Movie_Free(Movie_t* mov); 63 | 64 | #pragma endregion 65 | 66 | } /* namespace Gods98 */ 67 | -------------------------------------------------------------------------------- /src/openlrr/engine/video/Movie.hpp: -------------------------------------------------------------------------------- 1 | // Movie.hpp : Header file for the C++ G98CMovie implementation. 2 | // 3 | 4 | #pragma once 5 | 6 | #include "../../platform/windows.h" 7 | #include "../../platform/ddraw.h" 8 | #include 9 | 10 | #include "../../common.h" 11 | #include "../geometry.h" 12 | 13 | 14 | namespace Gods98 15 | {; // !<--- 16 | 17 | /********************************************************************************** 18 | ******** Classes 19 | **********************************************************************************/ 20 | 21 | #pragma region Classes 22 | 23 | /// PRIVATE: 24 | class G98CMovie 25 | { 26 | public: 27 | // (no vftable) 28 | /*00,4*/ IAMMultiMediaStream* m_amStream; 29 | /*04,4*/ HRESULT m_err; 30 | /*08,4*/ IMediaStream* m_sampleBaseStream; 31 | /*0c,4*/ IDirectDrawMediaStream* m_sampleStream; 32 | /*10,4*/ IDirectDrawSurface* m_baseSurf; // base surface for IDirectDrawStreamSample* m_sample 33 | /*14,4*/ IDirectDrawSurface3* m_surf; // DDS3 surface for IDirectDrawStreamSample* m_sample 34 | /*18,4*/ IDirectDrawStreamSample* m_sample; 35 | /*1c,4*/ IDirectDrawSurface3* m_bSurf; // render target passed in by constructor 36 | /*2c,10*/ Rect2I m_movieRect; // rect for IDirectDrawStreamSample* m_sample 37 | /*30,4*/ char* m_filename; 38 | /*34,4*/ IDirectDraw2* m_ddraw2; 39 | /*38*/ 40 | 41 | private: 42 | // 43 | bool InitSample(IAMMultiMediaStream* lpAMMMStream); 44 | // 45 | bool OpenAMStream(const char* fName, IAMMultiMediaStream** lplpAMMMStream, IDirectDraw2* ddraw2); 46 | 47 | public: 48 | // 49 | G98CMovie(OPTIONAL const char* fName, IDirectDrawSurface3* bSurf3, IDirectDraw2* ddraw2); 50 | // 51 | ~G98CMovie(); 52 | 53 | // float speed parameter is unused (name is assumed as 1.0f is always passed) 54 | // 55 | bool Update(real32 speed, const Rect2I* destRect); 56 | // cannot be const, due to using IMultiMedia-type interface 57 | // 58 | sint64 GetDuration(); 59 | 60 | 61 | // 62 | inline IDirectDrawSurface3* GetSurface() { return this->m_surf; } 63 | }; 64 | assert_sizeof(G98CMovie, 0x38); 65 | 66 | #pragma endregion 67 | 68 | } /* namespace Gods98 */ 69 | -------------------------------------------------------------------------------- /src/openlrr/game/Debug.h: -------------------------------------------------------------------------------- 1 | // Debug.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "GameCommon.h" 7 | #include "Game.h" 8 | 9 | 10 | namespace LegoRR 11 | {; // !<--- 12 | 13 | /********************************************************************************** 14 | ******** Forward Declarations 15 | **********************************************************************************/ 16 | 17 | #pragma region Forward Declarations 18 | 19 | #pragma endregion 20 | 21 | /********************************************************************************** 22 | ******** Constants 23 | **********************************************************************************/ 24 | 25 | #pragma region Constants 26 | 27 | #pragma endregion 28 | 29 | /********************************************************************************** 30 | ******** Enumerations 31 | **********************************************************************************/ 32 | 33 | #pragma region Enums 34 | 35 | enum class Debug_RouteVisualAuto 36 | { 37 | None, 38 | TrackedOnRadar, 39 | AllFriendly, 40 | All, 41 | }; 42 | 43 | #pragma endregion 44 | 45 | /********************************************************************************** 46 | ******** Structures 47 | **********************************************************************************/ 48 | 49 | #pragma region Structs 50 | 51 | struct Debug_RouteVisual 52 | { 53 | LegoObject* object; 54 | Gods98::Container* contMeshLines; // Block-to-block lines for the full route. 55 | Gods98::Container* contMeshCurve; // Between-block curve lines for the current block section. 56 | bool autoAdded; // Auto-added units can be removed during UpdateAll (manually adding overwrites this). 57 | }; 58 | 59 | #pragma endregion 60 | 61 | /********************************************************************************** 62 | ******** Globals 63 | **********************************************************************************/ 64 | 65 | #pragma region Globals 66 | 67 | #pragma endregion 68 | 69 | /********************************************************************************** 70 | ******** Functions 71 | **********************************************************************************/ 72 | 73 | #pragma region Functions 74 | 75 | const char* Debug_GetObjectTypeName(LegoObject_Type objType); 76 | const char* Debug_GetObjectIDName(LegoObject_Type objType, LegoObject_ID objID); 77 | 78 | #pragma region RouteVisual 79 | 80 | bool Debug_RouteVisual_IsEnabled(); 81 | void Debug_RouteVisual_SetEnabled(bool enabled); 82 | bool Debug_RouteVisual_IsCompletedPathsEnabled(); 83 | void Debug_RouteVisual_SetCompletedPathsEnabled(bool enabled); 84 | bool Debug_RouteVisual_IsCurvePathsEnabled(); 85 | void Debug_RouteVisual_SetCurvePathsEnabled(bool enabled); 86 | Debug_RouteVisualAuto Debug_RouteVisual_GetAutoMode(); 87 | void Debug_RouteVisual_SetAutoMode(Debug_RouteVisualAuto autoMode); 88 | 89 | bool Debug_RouteVisual_CanAdd(LegoObject* liveObj, bool friendlyOnly); 90 | 91 | Debug_RouteVisual* Debug_RouteVisual_Get(LegoObject* liveObj); 92 | void _Debug_RouteVisual_Hide(Debug_RouteVisual* routeVisual, bool hide); 93 | bool _Debug_RouteVisual_IsHidden(Debug_RouteVisual* routeVisual); 94 | Debug_RouteVisual* Debug_RouteVisual_Add(LegoObject* liveObj, bool autoAdd = false); 95 | bool Debug_RouteVisual_Remove(LegoObject* liveObj); 96 | void _Debug_RouteVisual_Remove2(Debug_RouteVisual* routeVisual, bool erase); 97 | void _Debug_RouteVisual_Update(Debug_RouteVisual* routeVisual, real32 elapsedWorld, real32 elapsedInterface); 98 | 99 | void Debug_RouteVisual_UpdateAll(real32 elapsedWorld, real32 elapsedInterface); 100 | void Debug_RouteVisual_HideAll(bool hide); 101 | 102 | void Debug_RouteVisual_AddAll(bool friendlyOnly); 103 | void Debug_RouteVisual_AddSelected(); 104 | void Debug_RouteVisual_RemoveAll(); 105 | void Debug_RouteVisual_RemoveSelected(); 106 | 107 | void _Debug_RouteVisual_UpdateLine(Gods98::Container* contMesh, uint32 groupID, real32 thickness, const Vector3F* fromPos, const Vector3F* toPos, real32 red, real32 green, real32 blue, real32 alpha, bool visible); 108 | 109 | #pragma endregion 110 | 111 | #pragma endregion 112 | 113 | } 114 | -------------------------------------------------------------------------------- /src/openlrr/game/README.md: -------------------------------------------------------------------------------- 1 | # OpenLRR game code 2 | 3 | 4 | ### Contents 5 | 6 | * `audio/SFX` 7 | 8 | SFX name lookup, loading of `Samples` config block, random sample groups, and speech management. 9 | 10 | * `effects/` 11 | 12 | 3D world effects and particles. 13 | 14 | * `front/` 15 | 16 | Screens and menus not tied to gameplay. 17 | 18 | * `interface/` 19 | 20 | Game interaction, icon menus, panels, heads up displays, and some shared 2D drawing code. 21 | 22 | * `mission/` 23 | 24 | Level goals, reward quotas, scripting, and PTL files. 25 | 26 | * `object/` 27 | 28 | In-game entity AI, stats, logic, and object models. 29 | 30 | * `world/` 31 | 32 | World map, camera, objects tied to block grids, and 3D rendering. 33 | 34 | * `Game` 35 | 36 | Main game functionality (originally the `Lego` module in LRR). 37 | 38 | * `GameCommon.h` 39 | 40 | Common defines, structures, and enums that haven't been properly tied to a specific module yet. 41 | -------------------------------------------------------------------------------- /src/openlrr/game/front/Credits.h: -------------------------------------------------------------------------------- 1 | // Credits.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "../../common.h" 7 | 8 | #include "../../engine/drawing/Fonts.h" 9 | 10 | 11 | namespace LegoRR 12 | {; // !<--- 13 | 14 | /********************************************************************************** 15 | ******** Functions 16 | **********************************************************************************/ 17 | 18 | #pragma region Functions 19 | 20 | // 21 | void __cdecl Credits_Play(const char* textFile, Gods98::Font* font, const char* aviFile); 22 | 23 | #pragma endregion 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/openlrr/game/front/Loader.h: -------------------------------------------------------------------------------- 1 | // Loader.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "../GameCommon.h" 7 | 8 | 9 | namespace LegoRR 10 | {; // !<--- 11 | 12 | /********************************************************************************** 13 | ******** Forward Declarations 14 | **********************************************************************************/ 15 | 16 | #pragma region Forward Declarations 17 | 18 | #pragma endregion 19 | 20 | /********************************************************************************** 21 | ******** Constants 22 | **********************************************************************************/ 23 | 24 | #pragma region Constants 25 | 26 | // Default section name for all game data loaded on game boot. 27 | #define LOADER_SECTION_GAMEDATA "Game Data" 28 | 29 | // Loader profile filename (total file sizes of loaded data when sound is enabled). 30 | #define LOADER_PROFILE_NAME "LoaderProfile.txt" 31 | // Loader profile filename (total file sizes of loaded data when sound is disabled). 32 | #define LOADER_PROFILE_NOSOUND_NAME "LoaderProfileNoSound.txt" 33 | 34 | 35 | // LOW HARDCODED LIMIT!! 49 levels + 1 section for game data :( 36 | #define LOADER_MAXSECTIONS 50 37 | 38 | #pragma endregion 39 | 40 | /********************************************************************************** 41 | ******** Enumerations 42 | **********************************************************************************/ 43 | 44 | #pragma region Enums 45 | 46 | enum Loader_GlobFlags : uint32 // [LegoRR/Loader.c|flags:0x4|type:uint] 47 | { 48 | LOADER_GLOB_FLAG_NONE = 0, 49 | LOADER_GLOB_FLAG_ENABLED = 0x1, 50 | }; 51 | flags_end(Loader_GlobFlags, 0x4); 52 | 53 | #pragma endregion 54 | 55 | /********************************************************************************** 56 | ******** Structures 57 | **********************************************************************************/ 58 | 59 | #pragma region Structs 60 | 61 | struct LoaderSection // [LegoRR/Loader.c|struct:0xc] 62 | { 63 | /*0,4*/ char* name; // Name of the section files are being loaded from 64 | /*4,4*/ uint32 currentSize; // Current total size of files loaded for this section 65 | /*8,4*/ uint32 totalSize; // Predefined total "expected" size for files to load from this section 66 | /*c*/ 67 | }; 68 | assert_sizeof(LoaderSection, 0xc); 69 | 70 | 71 | struct Loader_Globs // [LegoRR/Loader.c|struct:0x290|tags:GLOBS] 72 | { 73 | /*000,4*/ Gods98::Image* LoadScreen; 74 | /*004,4*/ Gods98::Font* font; 75 | /*008,258*/ LoaderSection sectionList[LOADER_MAXSECTIONS]; // Very bad hardcoded list size. No more than 49 levels and 1 for Game Data. 76 | /*260,4*/ LoaderSection* current; // current section being loaded 77 | /*264,4*/ Gods98::Image* ShutdownScreen; 78 | /*268,4*/ Gods98::Image* ProgressBar; 79 | /*26c,10*/ Area2F ProgressWindow; 80 | /*27c,4*/ Direction ProgressDirection; // expand direction of progress bar: U, R, D, L 81 | /*280,4*/ char* LoadingText; 82 | /*284,4*/ uint32 LoadingWidth; // measured width of font with LoadingText 83 | /*288,4*/ real32 progressLast; // percentage of filesize for section (stores percent of last render) 84 | /*28c,4*/ Loader_GlobFlags flags; // (1 = show loading bar) 85 | /*290*/ 86 | }; 87 | assert_sizeof(Loader_Globs, 0x290); 88 | 89 | #pragma endregion 90 | 91 | /********************************************************************************** 92 | ******** Globals 93 | **********************************************************************************/ 94 | 95 | #pragma region Globals 96 | 97 | // 98 | extern Loader_Globs & loaderGlobs; 99 | 100 | #pragma endregion 101 | 102 | /********************************************************************************** 103 | ******** Macros 104 | **********************************************************************************/ 105 | 106 | #pragma region Macros 107 | 108 | #pragma endregion 109 | 110 | /********************************************************************************** 111 | ******** Functions 112 | **********************************************************************************/ 113 | 114 | #pragma region Functions 115 | 116 | // 117 | void __cdecl Loader_Initialise(const char* loadScreenName, const char* shutdownScreenName, Gods98::Font* font5HI, const char* profileName, Direction progressDirection, const char* progressBarName, const Area2F* progressWindow, const char* loadingText); 118 | 119 | // 120 | void __cdecl Loader_Shutdown(const char* filename); 121 | 122 | // Sets the current section being loaded. Set to nullptr to disable loader screen. 123 | // 124 | void __cdecl Loader_display_loading_bar(const char* section); 125 | 126 | // Callback when a data file is loaded, which is used to add to the load size/progress of the currently active section. 127 | // 128 | void __cdecl Loader_FileLoadCallback(const char* filename, uint32 fileSize, void* data); 129 | 130 | // Displays the "Shutdown" screen image (only seen during a full shutdown with -programmer 10). 131 | // 132 | void __cdecl Loader_display_shutdown(void); 133 | 134 | #pragma endregion 135 | 136 | } 137 | -------------------------------------------------------------------------------- /src/openlrr/game/front/RewardScroll.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /src/openlrr/game/interface/Encyclopedia.h: -------------------------------------------------------------------------------- 1 | // Encyclopedia.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "../GameCommon.h" 7 | 8 | 9 | namespace LegoRR 10 | {; // !<--- 11 | 12 | /********************************************************************************** 13 | ******** Forward Declarations 14 | **********************************************************************************/ 15 | 16 | #pragma region Forward Declarations 17 | 18 | #pragma endregion 19 | 20 | /********************************************************************************** 21 | ******** Constants 22 | **********************************************************************************/ 23 | 24 | #pragma region Constants 25 | 26 | #pragma endregion 27 | 28 | /********************************************************************************** 29 | ******** Enumerations 30 | **********************************************************************************/ 31 | 32 | #pragma region Enums 33 | 34 | enum Encyclopedia_GlobFlags : uint32 35 | { 36 | ENCYCLOPEDIA_GLOB_FLAG_NONE = 0, 37 | 38 | ENCYCLOPEDIA_GLOB_FLAG_ACTIVE = 0x1, 39 | ENCYCLOPEDIA_GLOB_FLAG_NEEDSTEXT = 0x2, 40 | }; 41 | flags_end(Encyclopedia_GlobFlags, 0x4); 42 | 43 | #pragma endregion 44 | 45 | /********************************************************************************** 46 | ******** Structures 47 | **********************************************************************************/ 48 | 49 | #pragma region Structs 50 | 51 | /// TODO: Instead of opening a file, just read all the text. This is wasting open wad file entry slots. 52 | struct Encyclopedia_Globs // [LegoRR/Encyclopedia.c|struct:0x24|tags:GLOBS] 53 | { 54 | /*00,4*/ Gods98::File** vehicleFiles; 55 | /*04,4*/ Gods98::File** minifigureFiles; 56 | /*08,4*/ Gods98::File** rockmonsterFiles; 57 | /*0c,4*/ Gods98::File** buildingFiles; 58 | /*10,4*/ Gods98::File* powercrystalFile; 59 | /*14,4*/ Gods98::File* oreFile; 60 | /*18,4*/ Gods98::File* currentObjFile; 61 | /*1c,4*/ LegoObject* currentObj; 62 | /*20,4*/ Encyclopedia_GlobFlags flags; 63 | /*24*/ 64 | }; 65 | assert_sizeof(Encyclopedia_Globs, 0x24); 66 | 67 | #pragma endregion 68 | 69 | /********************************************************************************** 70 | ******** Globals 71 | **********************************************************************************/ 72 | 73 | #pragma region Globals 74 | 75 | // 76 | extern Encyclopedia_Globs & encyclopediaGlobs; 77 | 78 | #pragma endregion 79 | 80 | /********************************************************************************** 81 | ******** Functions 82 | **********************************************************************************/ 83 | 84 | #pragma region Functions 85 | 86 | // 87 | //#define Encyclopedia_Initialise ((void (__cdecl* )(const Gods98::Config* config, const char* gameName))0x0040e3c0) 88 | void __cdecl Encyclopedia_Initialise(const Gods98::Config* config, const char* gameName); 89 | 90 | // 91 | //#define Encyclopedia_SelectObject ((void (__cdecl* )(LegoObject* liveObj))0x0040e630) 92 | void __cdecl Encyclopedia_SelectObject(LegoObject* liveObj); 93 | 94 | // 95 | //#define Encyclopedia_ClearSelection ((void (__cdecl* )(void))0x0040e710) 96 | void __cdecl Encyclopedia_ClearSelection(void); 97 | 98 | // 99 | //#define Encyclopedia_Update ((void (__cdecl* )(real32 elapsedAbs))0x0040e720) 100 | void __cdecl Encyclopedia_Update(real32 elapsedAbs); 101 | 102 | // DRAW MODE: Only Draw API drawing calls can be used within this function. 103 | // 104 | //#define Encyclopedia_DrawSelectBox ((void (__cdecl* )(Gods98::Viewport* viewMain))0x0040e800) 105 | void __cdecl Encyclopedia_DrawSelectBox(Gods98::Viewport* viewMain); 106 | 107 | /// CUSTOM: Isolate Draw API calls from Encyclopedia_DrawSelectBox. 108 | void __cdecl Encyclopedia_DrawSelectName(Gods98::Viewport* viewMain); 109 | 110 | 111 | // Removes the current encyclopedia object if it matches the specified object. 112 | // 113 | //#define Encyclopedia_RemoveCurrentReference ((void (__cdecl* )(LegoObject* liveObj))0x0040e840) 114 | void __cdecl Encyclopedia_RemoveCurrentReference(LegoObject* liveObj); 115 | 116 | #pragma endregion 117 | 118 | } 119 | -------------------------------------------------------------------------------- /src/openlrr/game/interface/HelpWindow.cpp: -------------------------------------------------------------------------------- 1 | // HelpWindow.cpp : 2 | // 3 | 4 | #include "HelpWindow.h" 5 | 6 | 7 | /********************************************************************************** 8 | ******** Globals 9 | **********************************************************************************/ 10 | 11 | #pragma region Globals 12 | 13 | // 14 | LegoRR::HelpWindow_Globs & LegoRR::helpwindowGlobs = *(LegoRR::HelpWindow_Globs*)0x004dc8e8; 15 | 16 | #pragma endregion 17 | 18 | /********************************************************************************** 19 | ******** Functions 20 | **********************************************************************************/ 21 | 22 | #pragma region Functions 23 | 24 | // 25 | //void __cdecl LegoRR::HelpWindow_SetFont(Gods98::Font* font); 26 | 27 | // 28 | //void __cdecl LegoRR::HelpWindow_ClearFlag1(void); 29 | 30 | // 31 | //void __cdecl LegoRR::HelpWindow_Initialise(const Gods98::Config* config, const char* gameName); 32 | 33 | // 34 | //void __cdecl LegoRR::HelpWindow_LoadLevelsInfo(const Gods98::Config* config, const char* gameName); 35 | 36 | // 37 | //void __cdecl LegoRR::HelpWindow_LoadButtons(const Gods98::Config* config, const char* gameName); 38 | 39 | // 40 | //void __cdecl LegoRR::HelpWindow_IfFlag4_AndParam_Clear1_Set2_Else_Clear3(bool32 state); 41 | 42 | // 43 | //void __cdecl LegoRR::HelpWindow_RecallDependencies(LegoObject_Type objType, LegoObject_ID objID, uint32 objLevel, bool32 noHelpWindow); 44 | 45 | // 46 | //void __cdecl LegoRR::HelpWindow_Object_Unlock(LegoObject_Type objType, LegoObject_ID objID, uint32 objLevel); 47 | 48 | // 49 | //void __cdecl LegoRR::HelpWindow_Close_FUN_00418900(void); 50 | 51 | // 52 | //void __cdecl LegoRR::HelpWindow_FUN_00418930(void); 53 | 54 | // 55 | //bool32 __cdecl LegoRR::HelpWindow_FUN_00418cd0(uint32 mouseX, uint32 mouseY, bool32 leftButton, bool32 leftLast, bool32 leftReleased, real32 elapsed); 56 | 57 | // 58 | //void __cdecl LegoRR::HelpWindow_ToolTip_FUN_00418eb0(sint32 param_1); 59 | 60 | // 61 | //bool32 __cdecl LegoRR::HelpWindow_FUN_00418ef0(sint32 param_1, sint32 param_2, sint32 param_3); 62 | 63 | // 64 | //void __cdecl LegoRR::HelpWindow_FUN_00418f60(undefined4 param_1, real32 elapsed); 65 | 66 | // 67 | //void __cdecl LegoRR::HelpWindow_DrawButtons(void); 68 | 69 | // 70 | //Gods98::Image* __cdecl LegoRR::HelpWindow_GetButtonImage(sint32 buttonIndex); 71 | 72 | // 73 | //bool32 __cdecl LegoRR::HelpWindow_IsEnabled_AndFlags_3_AndNoTutorialFlags(void); 74 | 75 | // 76 | //bool32 __cdecl LegoRR::HelpWindow_IsEnabled(void); 77 | 78 | // 79 | //void __cdecl LegoRR::HelpWindow_SetEnabled(bool32 toggle, bool32 enable); 80 | 81 | #pragma endregion 82 | -------------------------------------------------------------------------------- /src/openlrr/game/interface/Pointers.h: -------------------------------------------------------------------------------- 1 | // Pointers.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "../../engine/drawing/Flic.h" 7 | #include "../../engine/drawing/Images.h" 8 | 9 | #include "../GameCommon.h" 10 | 11 | 12 | namespace LegoRR 13 | {; // !<--- 14 | 15 | /********************************************************************************** 16 | ******** Forward Declarations 17 | **********************************************************************************/ 18 | 19 | #pragma region Forward Declarations 20 | 21 | #pragma endregion 22 | 23 | /********************************************************************************** 24 | ******** Constants 25 | **********************************************************************************/ 26 | 27 | #pragma region Constants 28 | 29 | #pragma endregion 30 | 31 | /********************************************************************************** 32 | ******** Enumerations 33 | **********************************************************************************/ 34 | 35 | #pragma region Enums 36 | 37 | #pragma endregion 38 | 39 | /********************************************************************************** 40 | ******** Structures 41 | **********************************************************************************/ 42 | 43 | #pragma region Structs 44 | 45 | struct Pointer_Globs // [LegoRR/Pointer.c|struct:0x468|tags:GLOBS] 46 | { 47 | /*000,4*/ Pointer_Type currType; 48 | /*004,e0*/ Gods98::Image_Flic images[Pointer_Type_Count]; // (each item is either an Image or Flic) 49 | /*0e4,e0*/ bool32 imageIsFlic[Pointer_Type_Count]; 50 | /*1c4,1c0*/ Point2I flicOffsets[Pointer_Type_Count]; 51 | /*384,e0*/ const char* pointerName[Pointer_Type_Count]; 52 | /*464,4*/ real32 timer; // Countdown timer to change pointer(?) 53 | /*468*/ 54 | }; 55 | assert_sizeof(Pointer_Globs, 0x468); 56 | 57 | #pragma endregion 58 | 59 | /********************************************************************************** 60 | ******** Globals 61 | **********************************************************************************/ 62 | 63 | #pragma region Globals 64 | 65 | // 66 | extern Pointer_Globs & pointerGlobs; 67 | 68 | #pragma endregion 69 | 70 | /********************************************************************************** 71 | ******** Macros 72 | **********************************************************************************/ 73 | 74 | #pragma region Macros 75 | 76 | #define Pointer_RegisterName(n) (pointerGlobs.pointerName[n]=#n) 77 | 78 | #pragma endregion 79 | 80 | /********************************************************************************** 81 | ******** Functions 82 | **********************************************************************************/ 83 | 84 | #pragma region Functions 85 | 86 | // 87 | //#define Pointer_Initialise ((void (__cdecl* )(void))0x0045caf0) 88 | void __cdecl Pointer_Initialise(void); 89 | 90 | // Load all Pointers in the CFG block (prop is the first child in the block) 91 | // USAGE: 92 | // USAGE: ,, 93 | // 94 | // NOTE: config is the first item in the array of pointers!! 95 | // 96 | //#define Pointer_Load ((void (__cdecl* )(const Gods98::Config* config))0x0045cd30) 97 | void __cdecl Pointer_Load(const Gods98::Config* config); 98 | 99 | // 100 | //#define Pointer_GetType ((bool32 (__cdecl* )(const char* name, OUT Pointer_Type* pointerType))0x0045ce90) 101 | bool32 __cdecl Pointer_GetType(const char* name, OUT Pointer_Type* pointerType); 102 | 103 | // 104 | //#define Pointer_GetImage ((Gods98::Image* (__cdecl* )(Pointer_Type pointerType))0x0045ced0) 105 | Gods98::Image_Flic __cdecl Pointer_GetImage(Pointer_Type pointerType); 106 | 107 | // 108 | //#define Pointer_SetCurrent_IfTimerFinished ((void (__cdecl* )(Pointer_Type pointerType))0x0045cee0) 109 | void __cdecl Pointer_SetCurrent_IfTimerFinished(Pointer_Type pointerType); 110 | 111 | // 112 | //#define Pointer_SetCurrent ((void (__cdecl* )(Pointer_Type pointerType, real32 timer))0x0045cf00) 113 | void __cdecl Pointer_SetCurrent(Pointer_Type pointerType, real32 timer); 114 | 115 | // 116 | //#define Pointer_GetCurrentType ((Pointer_Type (__cdecl* )(void))0x0045cf20) 117 | Pointer_Type __cdecl Pointer_GetCurrentType(void); 118 | 119 | // 120 | //#define Pointer_DrawPointer ((void (__cdecl* )(uint32 mouseX, uint32 mouseY))0x0045cf30) 121 | void __cdecl Pointer_DrawPointer(uint32 mouseX, uint32 mouseY); 122 | 123 | // 124 | //#define Pointer_Update ((void (__cdecl* )(real32 elapsedReal))0x0045d050) 125 | void __cdecl Pointer_Update(real32 elapsedReal); 126 | 127 | #pragma endregion 128 | 129 | } 130 | -------------------------------------------------------------------------------- /src/openlrr/game/interface/ScrollInfo.cpp: -------------------------------------------------------------------------------- 1 | // ScrollInfo.cpp : 2 | // 3 | 4 | #include "ScrollInfo.h" 5 | 6 | 7 | /********************************************************************************** 8 | ******** Globals 9 | **********************************************************************************/ 10 | 11 | #pragma region Globals 12 | 13 | // 14 | bool32 & LegoRR::s_ScrollInfo_BOOL_005023c0 = *(bool32*)0x005023c0; 15 | 16 | // 17 | LegoRR::ScrollInfoStruct_20 (& LegoRR::g_ScrollInfos)[2] = *(LegoRR::ScrollInfoStruct_20(*)[2])0x00553140; 18 | 19 | #pragma endregion 20 | 21 | /********************************************************************************** 22 | ******** Functions 23 | **********************************************************************************/ 24 | 25 | #pragma region Functions 26 | 27 | // 28 | //void __cdecl LegoRR::ScrollInfo_Initialise(const char* filename, bool32 index, uint32 unkFlags, sint32 param_4, sint32 param_5); 29 | 30 | // 31 | //void __cdecl LegoRR::ScrollInfo_SetXYOrSize_Unk(bool32 index, uint32 x_or_width, uint32 y_or_height); 32 | 33 | // 34 | //void __cdecl LegoRR::ScrollInfo_AddStruct1C(bool32 index, bool32 use50InsteadOf4c, const Area2F* rect, OPTIONAL const char* filename1, OPTIONAL const char* filename2); 35 | 36 | // 37 | //void __cdecl LegoRR::ScrollInfo_AddCreateStruct28(bool32 index, Area2F* area, sint32 number, sint32 param_4, const char* filename); 38 | 39 | // 40 | //bool32 __cdecl LegoRR::ScrollInfo_Mouse_FUN_00463b60(OUT sint32* out_param_1, uint32 mouseX, uint32 mouseY, bool32 param_4, bool32 param_5); 41 | 42 | // 43 | //bool32 __cdecl LegoRR::ScrollInfo_FUN_00463ec0(ScrollInfoStruct_20* param_1, ScrollInfoSubStruct_1c* param_2, sint32 mouseX, sint32 mouseY); 44 | 45 | // 46 | //bool32 __cdecl LegoRR::ScrollInfo_FUN_00463f50(ScrollInfoStruct_20* param_1, sint32 mouseX, sint32 mouseY); 47 | 48 | // 49 | //void __cdecl LegoRR::ScrollInfo_Update(bool32 index); 50 | 51 | // 52 | //sint64 __cdecl LegoRR::ScrollInfo_MathX_RoundToLL(real32 x); 53 | 54 | // 55 | //void __cdecl LegoRR::ScrollInfo_GetSubStruct28_Fields1C_20(bool32 index, OUT sint32* field1c, OUT sint32* field20); 56 | 57 | // 58 | //void __cdecl LegoRR::ScrollInfo_SetSubStruct28_Fields1C_20(bool32 index, sint32 field1c, sint32 field20); 59 | 60 | #pragma endregion 61 | -------------------------------------------------------------------------------- /src/openlrr/game/mission/NERPsRuntime.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trigger-segfault/OpenLRR/2f6743cfabd40d43024e5d32737c9ff55a05030f/src/openlrr/game/mission/NERPsRuntime.cpp -------------------------------------------------------------------------------- /src/openlrr/game/mission/NERPsRuntime.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /src/openlrr/game/mission/PTL.cpp: -------------------------------------------------------------------------------- 1 | // PTL.cpp : 2 | // 3 | 4 | #include "../../engine/core/Config.h" 5 | #include "../../engine/core/Errors.h" 6 | #include "../../engine/core/Memory.h" 7 | #include "../../engine/core/Utils.h" 8 | 9 | #include "../object/Object.h" 10 | #include "../Game.h" 11 | 12 | #include "Messages.h" 13 | #include "PTL.h" 14 | 15 | 16 | /********************************************************************************** 17 | ******** Globals 18 | **********************************************************************************/ 19 | 20 | #pragma region Globals 21 | 22 | // 23 | LegoRR::PTL_Globs & LegoRR::ptlGlobs = *(LegoRR::PTL_Globs*)0x00556be0; 24 | 25 | #pragma endregion 26 | 27 | /********************************************************************************** 28 | ******** Functions 29 | **********************************************************************************/ 30 | 31 | #pragma region Functions 32 | 33 | // 34 | bool32 __cdecl LegoRR::PTL_Initialise(const char* fname, const char* gameName) 35 | { 36 | ptlGlobs.count = 0; 37 | 38 | Gods98::Config* ptl = Gods98::Config_Load(fname); 39 | if (ptl != nullptr) { 40 | 41 | const Gods98::Config* arrayFirst = Gods98::Config_FindArray(ptl, gameName); 42 | for (const Gods98::Config* prop = arrayFirst; prop != nullptr; prop = Gods98::Config_GetNextItem(prop)) { 43 | Error_Fatal(ptlGlobs.count >= PTL_MAXPROPERTIES, "Too many PTL properties"); 44 | 45 | ptlGlobs.table[ptlGlobs.count].fromType = Message_ParsePTLName(Gods98::Config_GetItemName(prop)); 46 | ptlGlobs.table[ptlGlobs.count].toType = Message_ParsePTLName(Gods98::Config_GetDataString(prop)); 47 | ptlGlobs.count++; 48 | } 49 | 50 | Gods98::Config_Free(ptl); 51 | return true; 52 | } 53 | return false; 54 | } 55 | 56 | // 57 | void __cdecl LegoRR::PTL_TranslateEvent(IN OUT Message_Event* message) 58 | { 59 | for (uint32 i = 0; i < ptlGlobs.count; i++) { 60 | if (message->type == ptlGlobs.table[i].fromType) { 61 | message->type = ptlGlobs.table[i].toType; 62 | return; 63 | } 64 | } 65 | // No translation, use the original event message type. 66 | } 67 | 68 | 69 | #pragma endregion 70 | -------------------------------------------------------------------------------- /src/openlrr/game/mission/PTL.h: -------------------------------------------------------------------------------- 1 | // PTL.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "../GameCommon.h" 7 | 8 | 9 | namespace LegoRR 10 | {; // !<--- 11 | 12 | /********************************************************************************** 13 | ******** Forward Declarations 14 | **********************************************************************************/ 15 | 16 | #pragma region Forward Declarations 17 | 18 | struct Message_Event; 19 | 20 | #pragma endregion 21 | 22 | /********************************************************************************** 23 | ******** Constants 24 | **********************************************************************************/ 25 | 26 | #pragma region Constants 27 | 28 | #define PTL_MAXPROPERTIES 40 29 | 30 | #pragma endregion 31 | 32 | /********************************************************************************** 33 | ******** Enumerations 34 | **********************************************************************************/ 35 | 36 | #pragma region Enums 37 | 38 | #pragma endregion 39 | 40 | /********************************************************************************** 41 | ******** Structures 42 | **********************************************************************************/ 43 | 44 | #pragma region Structs 45 | 46 | struct PTL_Property // [LegoRR/PTL.c|struct:0x8] Property loaded from a level's PTL config file (contains lookup index for actions) 47 | { 48 | /*0,4*/ Message_Type fromType; // The original "posted" event message type. 49 | /*4,4*/ Message_Type toType; // The output "translated" event message type. 50 | /*8*/ 51 | }; 52 | assert_sizeof(PTL_Property, 0x8); 53 | 54 | 55 | struct PTL_Globs // [LegoRR/PTL.c|struct:0x144|tags:GLOBS] 56 | { 57 | /*000,140*/ PTL_Property table[PTL_MAXPROPERTIES]; 58 | /*140,4*/ uint32 count; 59 | /*144*/ 60 | }; 61 | assert_sizeof(PTL_Globs, 0x144); 62 | 63 | #pragma endregion 64 | 65 | /********************************************************************************** 66 | ******** Globals 67 | **********************************************************************************/ 68 | 69 | #pragma region Globals 70 | 71 | // 72 | extern PTL_Globs & ptlGlobs; 73 | 74 | #pragma endregion 75 | 76 | /********************************************************************************** 77 | ******** Functions 78 | **********************************************************************************/ 79 | 80 | #pragma region Functions 81 | 82 | // 83 | bool32 __cdecl PTL_Initialise(const char* fname, const char* gameName); 84 | 85 | // 86 | void __cdecl PTL_TranslateEvent(IN OUT Message_Event* message); 87 | 88 | #pragma endregion 89 | 90 | } 91 | -------------------------------------------------------------------------------- /src/openlrr/game/mission/Quota.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /src/openlrr/game/object/BezierCurve.h: -------------------------------------------------------------------------------- 1 | // BezierCurve.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "../../common.h" 7 | #include "../../engine/geometry.h" 8 | #include "../../engine/undefined.h" 9 | 10 | 11 | namespace LegoRR 12 | {; // !<--- 13 | 14 | /********************************************************************************** 15 | ******** Constants 16 | **********************************************************************************/ 17 | 18 | #pragma region Constants 19 | 20 | #define BEZIERCURVE_MAXPOINTS 50 21 | 22 | #pragma endregion 23 | 24 | /********************************************************************************** 25 | ******** Structures 26 | **********************************************************************************/ 27 | 28 | #pragma region Structs 29 | 30 | struct BezierCurve // [LegoRR/Routing.c|struct:0x25c] 31 | { 32 | /*000,4*/ uint32 count; 33 | /*004,190*/ Point2F points[BEZIERCURVE_MAXPOINTS]; 34 | /*194,c8*/ real32 distances[BEZIERCURVE_MAXPOINTS]; 35 | /*25c*/ 36 | }; 37 | assert_sizeof(BezierCurve, 0x25c); 38 | 39 | #pragma endregion 40 | 41 | /********************************************************************************** 42 | ******** Functions 43 | **********************************************************************************/ 44 | 45 | #pragma region Functions 46 | 47 | // 48 | void __cdecl BezierCurve_Curve(OUT Point2F* r, const Point2F* p0, const Point2F* p1, const Point2F* p2, const Point2F* p3, real32 t); 49 | 50 | // sqrt(((a.x-b.x)*(a.x-b.x)) + ((a.y-b.y)*(a.y-b.y))) 51 | // 52 | real32 __cdecl BezierCurve_Vector2DDistance(const Point2F* a, const Point2F* b); 53 | 54 | // r = norm(r) * newLength 55 | // NOTE: Unlike `Maths_Vector2DSetLength`, this function modifies the input point. 56 | // 57 | Point2F* __cdecl BezierCurve_Vector2DChangeLength(IN OUT Point2F* r, real32 newLength); 58 | 59 | // 60 | real32 __cdecl BezierCurve_UpdateDistances(BezierCurve* curve); 61 | 62 | // 63 | void __cdecl BezierCurve_BuildPoints(BezierCurve* curve, const Point2F* p0, const Point2F* p1, const Point2F* p2, const Point2F* p3, uint32 count); 64 | 65 | // 66 | uint32 __cdecl BezierCurve_Interpolate(const BezierCurve* curve, real32 currentDist, OUT Point2F* r); 67 | 68 | #pragma endregion 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/openlrr/game/object/Collision.cpp: -------------------------------------------------------------------------------- 1 | // Collision.cpp : 2 | // 3 | 4 | #include "../../engine/core/Errors.h" 5 | #include "../../engine/core/Maths.h" 6 | 7 | #include "Collision.h" 8 | 9 | 10 | /********************************************************************************** 11 | ******** Functions 12 | **********************************************************************************/ 13 | 14 | #pragma region Functions 15 | 16 | // 17 | real32 __cdecl LegoRR::Collision_DistanceToLine(const Point2F* point, const Point2F* start, const Point2F* end) 18 | { 19 | // Vector between two endpoints(?) 20 | Point2F ray; 21 | Gods98::Maths_Vector2DSubtract(&ray, end, start); 22 | Gods98::Maths_Vector2DNormalize(&ray); 23 | 24 | Point2F vector1; 25 | Gods98::Maths_Vector2DSubtract(&vector1, point, end); 26 | real32 length = Gods98::Maths_Vector2DModulus(&vector1); 27 | Gods98::Maths_Vector2DScale(&vector1, &vector1, 1.0f / length); // Normalize without recalculating the length. 28 | 29 | real32 dot = Gods98::Maths_Vector2DDotProduct(&vector1, &ray); 30 | if (dot < 0.0f) { 31 | 32 | Point2F vector2; 33 | Gods98::Maths_Vector2DSubtract(&vector2, point, start); 34 | length = Gods98::Maths_Vector2DModulus(&vector2); 35 | Gods98::Maths_Vector2DScale(&vector2, &vector2, 1.0f / length); // Normalize without recalculating the length. 36 | 37 | dot = Gods98::Maths_Vector2DDotProduct(&vector2, &ray); 38 | if (dot > 0.0f) { 39 | // The closest point on the line is an endpoint. 40 | length *= std::sin(std::acos(/*(long double)*/dot)); // Maybe keep long double cast for more-accurate calculations? 41 | } 42 | } 43 | return length; 44 | } 45 | 46 | // 47 | real32 __cdecl LegoRR::Collision_DistanceToPolyOutline(const Point2F* point, const Point2F* fromList, const Point2F* toList, uint32 count) 48 | { 49 | Error_Fatal((count == 0), "Collision_DistanceToPolyOutline: Point list is empty."); 50 | 51 | real32 minValue = Collision_DistanceToLine(point, &fromList[0], &toList[0]); 52 | 53 | for (uint32 i = 1; i < count; i++) { 54 | const real32 value = Collision_DistanceToLine(point, &fromList[i], &toList[i]); 55 | if (value < minValue) { 56 | minValue = value; 57 | } 58 | } 59 | return minValue; 60 | } 61 | 62 | // Returns result 63 | // 64 | Point2F* __cdecl LegoRR::Collision_PointOnLine(const Point2F* start, const Point2F* end, const Point2F* point, OUT Point2F* result) 65 | { 66 | /// REFACTOR: This function is identical to Collision_PointOnLineRay, with the exception of the new subtraction with param start. 67 | /// Just call the other function after subtracting. 68 | Point2F ray; 69 | Gods98::Maths_Vector2DSubtract(&ray, end, start); 70 | return Collision_PointOnLineRay(start, &ray, point, result); 71 | } 72 | 73 | // Returns result 74 | // 75 | Point2F* __cdecl LegoRR::Collision_PointOnLineRay(const Point2F* start, const Point2F* ray, const Point2F* point, OUT Point2F* result) 76 | { 77 | Point2F norm = *ray; 78 | Gods98::Maths_Vector2DNormalize(&norm); 79 | 80 | Point2F diff; 81 | Gods98::Maths_Vector2DSubtract(&diff, point, start); 82 | 83 | const real32 dot = Gods98::Maths_Vector2DDotProduct(&diff, &norm); 84 | 85 | // Don't use result in-place of temp in-case result is also param start. 86 | Point2F temp; 87 | Gods98::Maths_Vector2DScale(&temp, &norm, dot); 88 | Gods98::Maths_Vector2DAdd(result, start, &temp); 89 | return result; 90 | } 91 | 92 | #pragma endregion 93 | -------------------------------------------------------------------------------- /src/openlrr/game/object/Collision.h: -------------------------------------------------------------------------------- 1 | // Collision.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "../GameCommon.h" 7 | 8 | 9 | namespace LegoRR 10 | {; // !<--- 11 | 12 | /********************************************************************************** 13 | ******** Functions 14 | **********************************************************************************/ 15 | 16 | #pragma region Functions 17 | 18 | // 19 | //#define Collision_DistanceToLine ((real32 (__cdecl* )(const Point2F* point, const Point2F* start, const Point2F* end))0x00408900) 20 | real32 __cdecl Collision_DistanceToLine(const Point2F* point, const Point2F* start, const Point2F* end); 21 | 22 | // Does not return 0 when point is inside polygon, only the distance to the outline. 23 | // 24 | //#define Collision_DistanceToPolyOutline ((real32 (__cdecl* )(const Point2F* point, const Point2F* fromList, const Point2F* toList, uint32 count))0x00408a30) 25 | real32 __cdecl Collision_DistanceToPolyOutline(const Point2F* point, const Point2F* fromList, const Point2F* toList, uint32 count); 26 | 27 | // Returns result 28 | // 29 | //#define Collision_PointOnLine ((Point2F* (__cdecl* )(const Point2F* start, const Point2F* end, const Point2F* point, OUT Point2F* result))0x00408a90) 30 | Point2F* __cdecl Collision_PointOnLine(const Point2F* start, const Point2F* end, const Point2F* point, OUT Point2F* result); 31 | 32 | // Returns result 33 | // 34 | //#define Collision_PointOnLineRay ((Point2F* (__cdecl* )(const Point2F* start, const Point2F* ray, const Point2F* point, OUT Point2F* result))0x00408b20) 35 | Point2F* __cdecl Collision_PointOnLineRay(const Point2F* start, const Point2F* ray, const Point2F* point, OUT Point2F* result); 36 | 37 | #pragma endregion 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/openlrr/game/object/Dependencies.cpp: -------------------------------------------------------------------------------- 1 | // Dependencies.cpp : 2 | // 3 | 4 | #include "Dependencies.h" 5 | 6 | 7 | /********************************************************************************** 8 | ******** Globals 9 | **********************************************************************************/ 10 | 11 | #pragma region Globals 12 | 13 | // 14 | LegoRR::Dependencies_Globs & LegoRR::dependencyGlobs = *(LegoRR::Dependencies_Globs*)0x004b9bc8; 15 | 16 | #pragma endregion 17 | 18 | /********************************************************************************** 19 | ******** Functions 20 | **********************************************************************************/ 21 | 22 | #pragma region Functions 23 | 24 | // 25 | //void __cdecl LegoRR::Dependencies_SetEnabled(bool32 on); 26 | 27 | // 28 | //void __cdecl LegoRR::Dependencies_Reset_ClearAllLevelFlags_10c(void); 29 | 30 | // 31 | //void __cdecl LegoRR::Dependencies_Initialise(const Gods98::Config* config, const char* gameName); 32 | 33 | // 34 | //bool32 __cdecl LegoRR::Dependencies_Object_FUN_0040add0(LegoObject_Type objType, LegoObject_ID objID, uint32 objLevel); 35 | 36 | // 37 | //bool32 __cdecl LegoRR::Dependencies_LiveObject_CallbackCheck_FUN_0040ae70(LegoObject* liveObj, LegoObject* otherObj); 38 | 39 | // 40 | //void __cdecl LegoRR::Dependencies_Object_GetRequirements(LegoObject_Type objType, LegoObject_ID objID, uint32 objLevel, OUT DependencyRequirement** requirements, OUT uint32* count); 41 | 42 | // 43 | //void __cdecl LegoRR::Dependencies_Object_Unlock(LegoObject_Type objType, LegoObject_ID objID, uint32 objLevel, DependencyUnlocks* unlocks); 44 | 45 | // 46 | //void __cdecl LegoRR::Dependencies_Prepare_Unk(void); 47 | 48 | // 49 | //bool32 __cdecl LegoRR::Dependencies_Object_IsLevelFlag4(LegoObject_Type objType, LegoObject_ID objID, uint32 objLevel); 50 | 51 | // 52 | //void __cdecl LegoRR::Dependencies_Object_AddLevelFlag_100(LegoObject_Type objType, LegoObject_ID objID, uint32 objLevel); 53 | 54 | // 55 | //bool32 __cdecl LegoRR::Dependencies_Object_GetLevelFlag_100(LegoObject_Type objType, LegoObject_ID objID, uint32 objLevel); 56 | 57 | #pragma endregion 58 | -------------------------------------------------------------------------------- /src/openlrr/game/object/Flocks.cpp: -------------------------------------------------------------------------------- 1 | // Flocks.cpp : 2 | // 3 | 4 | #include "Flocks.h" 5 | 6 | 7 | /********************************************************************************** 8 | ******** Globals 9 | **********************************************************************************/ 10 | 11 | #pragma region Globals 12 | 13 | // 14 | LegoRR::Flocks_Globs & LegoRR::flocksGlobs = *(LegoRR::Flocks_Globs*)0x00558850; 15 | 16 | #pragma endregion 17 | 18 | /********************************************************************************** 19 | ******** Functions 20 | **********************************************************************************/ 21 | 22 | #pragma region Functions 23 | 24 | // 25 | //LegoRR::FlocksItem* __cdecl LegoRR::Flocks_LiveObject_Flocks_CreateSubdata(OPTIONAL const Vector3F* vector_1, OPTIONAL const Vector3F* vector_2, real32 turn, real32 speed, real32 tightness, real32 goalUpdate, Gods98::Container* cont); 26 | 27 | // 28 | //LegoRR::Flocks* __cdecl LegoRR::Flocks_LiveObject_Flocks_CreateData(OPTIONAL const Vector3F* vector_1, OPTIONAL const Vector3F* vector_2, real32 turn, real32 speed, real32 tightness, Gods98::Container* cont); 29 | 30 | // 31 | //void __cdecl LegoRR::Flocks_FreeData(Flocks* flocksData); 32 | 33 | // 34 | //void __cdecl LegoRR::Flocks_Subdata_MathChangeRotationX(FlocksItem* flockSubdata, const Vector3F* vector); 35 | 36 | // 37 | //void __cdecl LegoRR::Flocks_Subdata_MathChangeRotationsYZ(FlocksItem* subdata, IN OUT Vector3F* vector); 38 | 39 | // 40 | //void __cdecl LegoRR::Flocks_Subdata_Matrix_MultRotXYZ(FlocksItem* subdata); 41 | 42 | // 43 | //void __cdecl LegoRR::Flocks_Callback_SubdataMoveAndTurn(Flocks* unused_flocksData, FlocksItem* subdata, real32* pElapsed); 44 | 45 | // 46 | //void __cdecl LegoRR::Flocks_MathX_Vector3DRandomMultiply(OUT Vector3F* vector, real32 x, real32 y, real32 z); 47 | 48 | // 49 | //void __cdecl LegoRR::Flocks_Callback_SubdataMoveTightness(Flocks* flocksData, FlocksItem* subData, real32* pElapsed); 50 | 51 | // 52 | //void __cdecl LegoRR::Flocks_SetVector2(Flocks* flocksData, const Vector3F* vector2); 53 | 54 | // 55 | //void __cdecl LegoRR::Flocks_Subdata_MoveAndTurn(FlocksItem* subdata, real32 elapsed); 56 | 57 | // 58 | //void __cdecl LegoRR::Flocks_Subdata_UpdateMove(Flocks* flocksData, real32 elapsed); 59 | 60 | // 61 | //void __cdecl LegoRR::Flocks_LiveObject_Flocks_AddSubdata(Flocks* flockData, FlocksItem* subdata); 62 | 63 | // 64 | //LegoRR::FlocksItem* __cdecl LegoRR::Flocks_Free_SubdataRecurse(Flocks* flocksData); 65 | 66 | // 67 | //void __cdecl LegoRR::Flocks_CallbackForAllSubdata(Flocks* flockData, FlocksCallback callback, void* data); 68 | 69 | // 70 | //real32 __cdecl LegoRR::Flocks_MathX_RandRangeOne(void); 71 | 72 | // 73 | //void __cdecl LegoRR::Flocks_Callback_FUN_0040fe00(Flocks* flocksData, FlocksItem* subdata, real32* param_3); 74 | 75 | // 76 | //void __cdecl LegoRR::Flocks_FUN_0040fe80(Flocks* flocksData, real32 randomness); 77 | 78 | // 79 | //void __cdecl LegoRR::Flocks_SetParameters1(Flocks* flocksData, real32 turn, real32 speed, real32 tightness); 80 | 81 | // 82 | //void __cdecl LegoRR::Flocks_Callback_SetSubdataParametersFromGlobals(Flocks* flocksData, FlocksItem* subdata); 83 | 84 | // 85 | //void __cdecl LegoRR::Flocks_SetGlobal_AndAllSubdataParameters(Flocks* flockData, real32 turn, real32 speed, real32 tightness, real32 goalUpdate); 86 | 87 | // 88 | //void __cdecl LegoRR::Flocks_SetVector1(Flocks* flocksData, const Vector3F* vector1); 89 | 90 | // 91 | //void __cdecl LegoRR::Flocks_Callback_SetSubdataVectorC(Flocks* flocksData, FlocksItem* subdata, void* vector); 92 | 93 | // 94 | //void __cdecl LegoRR::Flocks_SetAllSubdataVectorC(Flocks* flocksData, const Vector3F* vector); 95 | 96 | // 97 | //void __cdecl LegoRR::Flocks_Callback_SetSubdataVector0(Flocks* flocksData, FlocksItem* subdata, void* vector); 98 | 99 | // 100 | //void __cdecl LegoRR::Flocks_SetAllSubdataVector0(Flocks* flocksData, const Vector3F* vector); 101 | 102 | // 103 | //void __cdecl LegoRR::Flocks_Callback_FUN_00410000(Flocks* flocksData, FlocksItem* subdata, real32* pElapsed); 104 | 105 | // 106 | //void __cdecl LegoRR::Flocks_Callback_CompareVecs_0_c(Flocks* flocksData, FlocksItem* subdata, bool32* pSuccess); 107 | 108 | // 109 | //bool32 __cdecl LegoRR::Flocks_CompareAllVecs_0_c(Flocks* flocksData); 110 | 111 | #pragma endregion 112 | -------------------------------------------------------------------------------- /src/openlrr/game/object/MeshLOD.h: -------------------------------------------------------------------------------- 1 | // MeshLOD.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "../GameCommon.h" 7 | 8 | 9 | namespace LegoRR 10 | {; // !<--- 11 | 12 | /********************************************************************************** 13 | ******** Forward Declarations 14 | **********************************************************************************/ 15 | 16 | #pragma region Forward Declarations 17 | 18 | #pragma endregion 19 | 20 | /********************************************************************************** 21 | ******** Constants 22 | **********************************************************************************/ 23 | 24 | #pragma region Constants 25 | 26 | #pragma endregion 27 | 28 | /********************************************************************************** 29 | ******** Enumerations 30 | **********************************************************************************/ 31 | 32 | #pragma region Enums 33 | 34 | enum MeshLODFlags : uint32 // [LegoRR/MeshLOD.c|flags:0x4|type:uint] 35 | { 36 | MESHLOD_FLAG_NONE = 0, 37 | MESHLOD_FLAG_CLONED = 0x1, 38 | MESHLOD_FLAG_MEMBLOCK = 0x2, // Start of linked list contiguous memory allocation. 39 | }; 40 | flags_end(MeshLODFlags, 0x4); 41 | 42 | #pragma endregion 43 | 44 | /********************************************************************************** 45 | ******** Structures 46 | **********************************************************************************/ 47 | 48 | #pragma region Structs 49 | 50 | struct MeshLOD // [LegoRR/MeshPoly.c|struct:0x18] 51 | { 52 | /*00,4*/ Gods98::Container* contMeshOrigin; // (LWO|MESH, true) 53 | /*04,4*/ Gods98::Container* contMeshTarget; 54 | /*08,4*/ char* partName; // name of LoadObject file.lwo 55 | /*0c,4*/ uint32 setID; // MeshLOD's may contain multiple sets of the same parts, this specifies which set its from. 56 | /*10,4*/ MeshLODFlags flags; // (1 = dont free partName/cont_0, 2 = unk dtor behavior) 57 | /*14,4*/ MeshLOD* next; 58 | /*18*/ 59 | }; 60 | assert_sizeof(MeshLOD, 0x18); 61 | 62 | #pragma endregion 63 | 64 | /********************************************************************************** 65 | ******** Functions 66 | **********************************************************************************/ 67 | 68 | #pragma region Functions 69 | 70 | // 71 | //#define MeshLOD_Create ((MeshLOD* (__cdecl* )(OPTIONAL MeshLOD* prevMeshLOD, const char* partName, const char* dirname, const char* meshName, uint32 setID))0x00451c70) 72 | MeshLOD* __cdecl MeshLOD_Create(OPTIONAL MeshLOD* prevMeshLOD, const char* partName, const char* dirname, const char* meshName, uint32 setID); 73 | 74 | // 75 | //#define MeshLOD_CreateEmpty ((MeshLOD* (__cdecl* )(OPTIONAL MeshLOD* prevMeshLOD, const char* partName, uint32 setID))0x00451d70) 76 | MeshLOD* __cdecl MeshLOD_CreateEmpty(OPTIONAL MeshLOD* prevMeshLOD, const char* partName, uint32 setID); 77 | 78 | // 79 | //#define MeshLOD_Clone ((MeshLOD* (__cdecl* )(IN MeshLOD* srcMeshLOD))0x00451df0) 80 | MeshLOD* __cdecl MeshLOD_Clone(IN MeshLOD* srcMeshLOD); 81 | 82 | // 83 | //#define MeshLOD_SwapTarget ((void (__cdecl* )(MeshLOD* meshLOD, Gods98::Container* contActTarget, bool32 restore, uint32 setID))0x00451e80) 84 | void __cdecl MeshLOD_SwapTarget(MeshLOD* meshLOD, Gods98::Container* contActTarget, bool32 restore, uint32 setID); 85 | 86 | // 87 | //#define MeshLOD_RemoveTargets ((void (__cdecl* )(MeshLOD* meshLOD))0x00451ef0) 88 | void __cdecl MeshLOD_RemoveTargets(MeshLOD* meshLOD); 89 | 90 | // 91 | //#define MeshLOD_Free ((void (__cdecl* )(MeshLOD* meshLOD))0x00451f10) 92 | void __cdecl MeshLOD_Free(MeshLOD* meshLOD); 93 | 94 | #pragma endregion 95 | 96 | } 97 | -------------------------------------------------------------------------------- /src/openlrr/game/object/ObjectRecall.h: -------------------------------------------------------------------------------- 1 | // ObjectRecall.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "../GameCommon.h" 7 | 8 | 9 | namespace LegoRR 10 | {; // !<--- 11 | 12 | /********************************************************************************** 13 | ******** Constants 14 | **********************************************************************************/ 15 | 16 | #pragma region Constants 17 | 18 | #define OBJECTRECALL_FILE_SIGNATURE "RROS" 19 | 20 | #pragma endregion 21 | 22 | /********************************************************************************** 23 | ******** Structures 24 | **********************************************************************************/ 25 | 26 | #pragma region Structs 27 | 28 | // Moved to ObjectRecall.h, as a temporary location that both FrontEnd.h and Object.h can rely on without needing to include these heavy modules. 29 | #if true 30 | struct SaveStruct_18 // [LegoRR/save.c|struct:0x18] 31 | { 32 | /*00,18*/ undefined field_0x0_0x17[24]; 33 | /*18*/ 34 | }; 35 | assert_sizeof(SaveStruct_18, 0x18); 36 | #endif 37 | 38 | 39 | struct RROSFileHeader // [LegoRR/ObjectRecall.c|struct:0x8] For .osf Object Recall save files 40 | { 41 | /*0,4*/ char signature[4]; // "RROS" 42 | /*4,4*/ uint32 count; 43 | ///*8,0*/ ObjectRecallEntry entries[]; 44 | /*8*/ 45 | }; 46 | assert_sizeof(RROSFileHeader, 0x8); 47 | 48 | 49 | struct ObjectRecallEntry // [LegoRR/ObjectRecall.c|struct:0x14] Object recall structure (for .osf file) 50 | { 51 | /*00,4*/ LegoObject_AbilityFlags abilityFlags; // LiveFlags5 52 | /*04,4*/ uint32 level; 53 | /*08,c*/ char customName[OBJECT_CUSTOMNAMELENGTH]; 54 | /*14*/ 55 | }; 56 | assert_sizeof(ObjectRecallEntry, 0x14); 57 | 58 | 59 | struct ObjectRecall_Globs // [LegoRR/ObjectRecall.c|struct:0x18|tags:GLOBS] 60 | { 61 | /*00,4*/ ObjectRecallEntry* recallList; 62 | /*04,4*/ uint32 recallUsed; 63 | /*08,4*/ uint32 recallCapacity; 64 | /*0c,4*/ ObjectRecallEntry* recallNewList; 65 | /*10,4*/ uint32 recallNewCount; 66 | /*14,4*/ bool32 loaded; 67 | /*18*/ 68 | }; 69 | assert_sizeof(ObjectRecall_Globs, 0x18); 70 | 71 | #pragma endregion 72 | 73 | /********************************************************************************** 74 | ******** Globals 75 | **********************************************************************************/ 76 | 77 | #pragma region Globals 78 | 79 | // 80 | extern ObjectRecall_Globs & objectRecallGlobs; 81 | 82 | #pragma endregion 83 | 84 | /********************************************************************************** 85 | ******** Functions 86 | **********************************************************************************/ 87 | 88 | #pragma region Functions 89 | 90 | // 91 | void __cdecl ObjectRecall_StoreMiniFigure(const LegoObject* liveObj); 92 | 93 | // 94 | bool32 __cdecl ObjectRecall_RecallMiniFigure(LegoObject* liveObj); 95 | 96 | // 97 | void __cdecl ObjectRecall_Save_FreeObjectRecall(void); 98 | 99 | // 100 | void __cdecl ObjectRecall_Save_CopyToNewObjectRecallData(void); 101 | 102 | // 103 | bool32 __cdecl ObjectRecall_Save_CreateNewObjectRecall(void); 104 | 105 | // 106 | bool32 __cdecl ObjectRecall_IsLoaded(void); 107 | 108 | // 109 | bool32 __cdecl ObjectRecall_SaveRROSFile(const char* filename); 110 | 111 | // 112 | bool32 __cdecl ObjectRecall_LoadRROSFile(const char* filename); 113 | 114 | #pragma endregion 115 | 116 | } 117 | -------------------------------------------------------------------------------- /src/openlrr/game/object/Upgrade.cpp: -------------------------------------------------------------------------------- 1 | // Upgrade.cpp : 2 | // 3 | 4 | #include "Upgrade.h" 5 | 6 | 7 | /********************************************************************************** 8 | ******** Functions 9 | **********************************************************************************/ 10 | 11 | #pragma region Functions 12 | 13 | // 14 | //void __cdecl LegoRR::Upgrade_Part_Hide(Upgrade_PartModel* upgradePart, bool32 hide); 15 | 16 | // 17 | //Gods98::Container* __cdecl LegoRR::Upgrade_Part_GetActivityContainer(Upgrade_PartModel* upgradePart); 18 | 19 | // 20 | //Gods98::Container* __cdecl LegoRR::Upgrade_Part_FindNull(Upgrade_PartModel* upgradePart, const char* name, uint32 frameNo); 21 | 22 | // 23 | //void __cdecl LegoRR::Upgrade_Part_SetOwnerObject(Upgrade_PartModel* upgradePart, LegoObject* liveObj); 24 | 25 | // 26 | //bool32 __cdecl LegoRR::Upgrade_Part_IsHidden(Upgrade_PartModel* upgradePart); 27 | 28 | // 29 | //void __cdecl LegoRR::Upgrade_Part_Load(OUT Upgrade_PartModel* upgradePart, LegoObject_ID objID, Gods98::Container* root, const char* filename); 30 | 31 | // 32 | //void __cdecl LegoRR::Upgrade_Part_Clone(IN Upgrade_PartModel* srcUpgradePart, OUT Upgrade_PartModel* destUpgradePart); 33 | 34 | // 35 | //void __cdecl LegoRR::Upgrade_Part_Remove(Upgrade_PartModel* upgradePart); 36 | 37 | // 38 | //real32 __cdecl LegoRR::Upgrade_Part_MoveAnimation(Upgrade_PartModel* upgradePart, real32 elapsed, uint32 unused_unkFrameNo); 39 | 40 | // 41 | //bool32 __cdecl LegoRR::Upgrade_Part_SetActivity(Upgrade_PartModel* upgradePart, const char* activityName); 42 | 43 | // 44 | //void __cdecl LegoRR::Upgrade_Load(OUT UpgradesModel* upgrades, const Gods98::Config* act, const char* gameName); 45 | 46 | // 47 | //void __cdecl LegoRR::Upgrade_SetUpgradeLevel(UpgradesModel* upgrades, uint32 objLevel); 48 | 49 | #pragma endregion 50 | -------------------------------------------------------------------------------- /src/openlrr/game/world/Detail.cpp: -------------------------------------------------------------------------------- 1 | // Detail.cpp : 2 | // 3 | 4 | #include "Detail.h" 5 | 6 | 7 | /********************************************************************************** 8 | ******** Functions 9 | **********************************************************************************/ 10 | 11 | #pragma region Functions 12 | 13 | // 14 | //LegoRR::Detail_TextureSet* __cdecl LegoRR::Detail_LoadTextureSet(const char* textureBaseName, uint32 width, uint32 height); 15 | 16 | // 17 | //void __cdecl LegoRR::Detail_FreeTextureSet(Detail_TextureSet* textureSet); 18 | 19 | // 20 | //real32 __cdecl LegoRR::Detail_FUN_0040b3a0(const Vector3F* vertPoses, Gods98::Viewport* view, const Point2F* viewportSize, bool32 param_4); 21 | 22 | // 23 | //LegoRR::Detail_Mesh* __cdecl LegoRR::Detail_LoadMeshes(Gods98::Container* cont, const char* meshName_a, const char* meshName_b, real32 blockSize, Detail_TextureSet* textureSet); 24 | 25 | // 26 | //void __cdecl LegoRR::Detail_FreeMesh(Detail_Mesh* detailMesh); 27 | 28 | // 29 | //void __cdecl LegoRR::Detail_RemoveMesh_FUN_0040b740(Detail_Mesh* detailMesh); 30 | 31 | // 32 | //Gods98::Container_Texture* __cdecl LegoRR::Detail_GetTexture(Detail_TextureSet* textureSet, SurfaceTexture texture); 33 | 34 | // 35 | //void __cdecl LegoRR::Detail_FUN_0040b7b0(LegoRR::Detail_Mesh* detailMesh, const Vector3F* vectPoses4, LegoRR::SurfaceTexture texture, uint8 direction, real32 scaleZ, real32 brightness); 36 | 37 | // 38 | //void __cdecl LegoRR::Detail_Sub1_Transform(Gods98::Container* cont, real32 blockSize, const Vector3F* p1, const Vector3F* p2, const Vector3F* p3, real32 scaleZ, real32 brightness, Gods98::Container_Texture* contTexture, Detail_TransformFlags transformFlags); 39 | 40 | // 41 | //void __cdecl LegoRR::Detail_Sub2_FUN_0040bac0(Gods98::Container* cont, real32 blockSize, const Vector3F* p1, const Vector3F* p2, const Vector3F* p3); 42 | 43 | // 44 | //void __cdecl LegoRR::Detail_Matrix_FUN_0040bc90(OUT Matrix4F* m, real32 blockWidth, real32 blockHeight, real32 invxP2_y, real32 invxP3_x, real32 invxP3_y); 45 | 46 | #pragma endregion 47 | -------------------------------------------------------------------------------- /src/openlrr/game/world/Fallin.h: -------------------------------------------------------------------------------- 1 | // Fallin.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "../GameCommon.h" 7 | 8 | 9 | namespace LegoRR 10 | {; // !<--- 11 | 12 | /********************************************************************************** 13 | ******** Forward Declarations 14 | **********************************************************************************/ 15 | 16 | #pragma region Forward Declarations 17 | 18 | #pragma endregion 19 | 20 | /********************************************************************************** 21 | ******** Constants 22 | **********************************************************************************/ 23 | 24 | #pragma region Constants 25 | 26 | #define FALLIN_MAXTRIES 100 // Number of attempts to generate fallin at random block 27 | 28 | #pragma endregion 29 | 30 | /********************************************************************************** 31 | ******** Enumerations 32 | **********************************************************************************/ 33 | 34 | #pragma region Enums 35 | 36 | #pragma endregion 37 | 38 | /********************************************************************************** 39 | ******** Structures 40 | **********************************************************************************/ 41 | 42 | #pragma region Structs 43 | 44 | struct Fallin_Globs // [LegoRR/Fallin.c|struct:0x4|tags:GLOBS] Just a single field for Fallins (most other settings are found in Lego_Globs) 45 | { 46 | /*0,4*/ uint32 numLandSlidesTillCaveIn; 47 | /*4*/ 48 | }; 49 | assert_sizeof(Fallin_Globs, 0x4); 50 | 51 | #pragma endregion 52 | 53 | /********************************************************************************** 54 | ******** Globals 55 | **********************************************************************************/ 56 | 57 | #pragma region Globals 58 | 59 | // 60 | extern Fallin_Globs & fallinGlobs; // fallinGlobs_NumberOfLandSlidesTillCaveIn; 61 | 62 | // 63 | extern real32 & s_fallinUpdateTimer; // Count-down timer until next fallin generation. 64 | 65 | #pragma endregion 66 | 67 | /********************************************************************************** 68 | ******** Macros 69 | **********************************************************************************/ 70 | 71 | #pragma region Macros 72 | 73 | #pragma endregion 74 | 75 | /********************************************************************************** 76 | ******** Functions 77 | **********************************************************************************/ 78 | 79 | #pragma region Functions 80 | 81 | // 82 | //#define Fallin_Update ((void (__cdecl* )(real32 elapsedWorld))0x0040f010) 83 | void __cdecl Fallin_Update(real32 elapsedWorld); 84 | 85 | // 86 | //#define Fallin_TryGenerateLandSlide ((bool32 (__cdecl* )(const Point2I* blockPos, bool32 allowCaveIn))0x0040f0c0) 87 | bool32 __cdecl Fallin_TryGenerateLandSlide(const Point2I* blockPos, bool32 allowCaveIn); 88 | 89 | // 90 | //#define Fallin_CanLandSlideAtBlock ((bool32 (__cdecl* )(const Point2I* blockPos))0x0040f1e0) 91 | bool32 __cdecl Fallin_CanLandSlideAtBlock(const Point2I* blockPos); 92 | 93 | // 94 | //#define Fallin_GenerateLandSlide ((void (__cdecl* )(const Point2I* blockPos, DirectionFlags fallinDirs, bool32 allowCaveIn))0x0040f260) 95 | void __cdecl Fallin_GenerateLandSlide(const Point2I* blockPos, DirectionFlags fallinDirs, bool32 allowCaveIn); 96 | 97 | // 98 | //#define Fallin_Initialise ((void (__cdecl* )(uint32 numLandSlidesTillCaveIn))0x0040f510) 99 | void __cdecl Fallin_Initialise(uint32 numLandSlidesTillCaveIn); 100 | 101 | // 102 | //#define Fallin_GenerateCaveIn ((void (__cdecl* )(const Point2I* blockPos, DirectionFlags fallinDirs))0x0040f520) 103 | void __cdecl Fallin_GenerateCaveIn(const Point2I* blockPos, DirectionFlags fallinDirs); 104 | 105 | #pragma endregion 106 | 107 | } 108 | -------------------------------------------------------------------------------- /src/openlrr/game/world/Roof.h: -------------------------------------------------------------------------------- 1 | // Roof.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "../GameCommon.h" 7 | 8 | 9 | namespace LegoRR 10 | {; // !<--- 11 | 12 | /********************************************************************************** 13 | ******** Forward Declarations 14 | **********************************************************************************/ 15 | 16 | #pragma region Forward Declarations 17 | 18 | #pragma endregion 19 | 20 | /********************************************************************************** 21 | ******** Constants 22 | **********************************************************************************/ 23 | 24 | #pragma region Constants 25 | 26 | #pragma endregion 27 | 28 | /********************************************************************************** 29 | ******** Enumerations 30 | **********************************************************************************/ 31 | 32 | #pragma region Enums 33 | 34 | enum RoofFlags : uint32 // [LegoRR/Roof.c|flags:0x4|type:uint] 35 | { 36 | ROOF_FLAG_NONE = 0, 37 | ROOF_FLAG_HIDDEN = 0x1, 38 | ROOF_FLAG_NEEDUPDATE = 0x2, 39 | ROOF_FLAG_SHIFTVERTICES = 0x4, 40 | }; 41 | flags_end(RoofFlags, 0x4); 42 | 43 | #pragma endregion 44 | 45 | /********************************************************************************** 46 | ******** Structures 47 | **********************************************************************************/ 48 | 49 | #pragma region Structs 50 | 51 | struct RoofBlock // [LegoRR/Roof.c|struct:0x8] Mesh group for a single block in the world's roof. (only used for FP) 52 | { 53 | /*0,4*/ uint32 groupID; 54 | /*4,4*/ RoofFlags flags; // (0x1 = hidde, 0x2 = needsUpdate, 0x4 = shiftVertices) 55 | /*8*/ 56 | }; 57 | assert_sizeof(RoofBlock, 0x8); 58 | 59 | struct Roof_Globs // [LegoRR/Roof.c|struct:0x7f0|tags:GLOBS] A level's roof mesh displayed in the world (only when in FP) 60 | { 61 | /*000,4*/ Gods98::Container* contMesh; // MakeMesh2:IMMEDIATE 62 | /*004,8*/ Size2I dimensions; 63 | /*00c,4*/ bool32 hidden; 64 | /*010,4*/ bool32 needsUpdate; // Similar to the ROOF_NEEDSUPDATE flag, but is true if any blocks have to be updated 65 | /*014,4*/ Gods98::Container_Texture* texture; 66 | /*018,4*/ RoofBlock* grid; // Allocation size of 8, may be same as struct type below 67 | /*01c,7d0*/ RoofBlock* visibleTable[500]; // items are either null, or point to a block in grid 68 | /*7ec,4*/ uint32 visibleCount; // (not sure if "visible" is correct) 69 | /*7f0*/ 70 | }; 71 | assert_sizeof(Roof_Globs, 0x7f0); 72 | 73 | #pragma endregion 74 | 75 | /********************************************************************************** 76 | ******** Globals 77 | **********************************************************************************/ 78 | 79 | #pragma region Globals 80 | 81 | // 82 | extern Roof_Globs& roofGlobs; 83 | 84 | #pragma endregion 85 | 86 | /********************************************************************************** 87 | ******** Macros 88 | **********************************************************************************/ 89 | 90 | #pragma region Macros 91 | 92 | #pragma endregion 93 | 94 | /********************************************************************************** 95 | ******** Functions 96 | **********************************************************************************/ 97 | 98 | #pragma region Functions 99 | 100 | // 101 | bool32 __cdecl Roof_Initialise(Gods98::Container* contRoot, sint32 width, sint32 height); 102 | 103 | // 104 | bool32 __cdecl Roof_SetTexture(const char* filename); 105 | 106 | // 107 | void __cdecl Roof_Shutdown(void); 108 | 109 | // 110 | void __cdecl Roof_SetBlockRoofVertices(uint32 bx, uint32 by, const Vector3F* vertPos0, const Vector3F* vertPos1, const Vector3F* vertPos2, const Vector3F* vertPos3); 111 | 112 | // 113 | void __cdecl Roof_Update(void); 114 | 115 | // 116 | void __cdecl Roof_Hide(bool32 hide); 117 | 118 | // I'm not actually sure if this is supposed to be "visible" blocks. But it's a 119 | // list of blocks that are assigned and cleared, all in a single FP update loop. 120 | // 121 | void __cdecl Roof_AddVisibleBlock(uint32 bx, uint32 by); 122 | 123 | // 124 | void __cdecl Roof_HideAllVisibleBlocks(void); 125 | 126 | // 127 | bool32 __cdecl Roof_GetBlockPlaneNormal(uint32 bx, uint32 by, OUT Vector3F* normal); 128 | 129 | #pragma endregion 130 | 131 | } 132 | -------------------------------------------------------------------------------- /src/openlrr/game/world/SpiderWeb.cpp: -------------------------------------------------------------------------------- 1 | // SpiderWeb.cpp : 2 | // 3 | 4 | #include "SpiderWeb.h" 5 | 6 | 7 | /********************************************************************************** 8 | ******** Globals 9 | **********************************************************************************/ 10 | 11 | #pragma region Globals 12 | 13 | // 14 | LegoRR::SpiderWeb_Globs & LegoRR::spiderwebGlobs = *(LegoRR::SpiderWeb_Globs*)0x005530e8; 15 | 16 | #pragma endregion 17 | 18 | /********************************************************************************** 19 | ******** Functions 20 | **********************************************************************************/ 21 | 22 | #pragma region Functions 23 | 24 | // 25 | //void __cdecl LegoRR::SpiderWeb_Initialise(Lego_Level* level); 26 | 27 | // 28 | //void __cdecl LegoRR::SpiderWeb_Shutdown(void); 29 | 30 | // 31 | //void __cdecl LegoRR::SpiderWeb_Restart(Lego_Level* level); 32 | 33 | // 34 | //bool32 __cdecl LegoRR::SpiderWeb_SpawnAt(uint32 bx, uint32 by); 35 | 36 | // 37 | //void __cdecl LegoRR::SpiderWeb_Add(sint32 bx, sint32 by, LegoObject* webObj); 38 | 39 | // 40 | //bool32 __cdecl LegoRR::SpiderWeb_GetAngle(sint32 bx, sint32 by, OUT real32* theta); 41 | 42 | // 43 | //bool32 __cdecl LegoRR::SpiderWeb_CheckCollision(LegoObject* liveObj); 44 | 45 | // 46 | //bool32 __cdecl LegoRR::SpiderWeb_Update(real32 elapsedGame); 47 | 48 | // 49 | //bool32 __cdecl LegoRR::SpiderWeb_LiveObjectCallback(LegoObject* liveObj, real32* pElapsedGame); 50 | 51 | // 52 | //void __cdecl LegoRR::SpiderWeb_Remove(sint32 bx, sint32 by); 53 | 54 | #pragma endregion 55 | -------------------------------------------------------------------------------- /src/openlrr/game/world/SpiderWeb.h: -------------------------------------------------------------------------------- 1 | // SpiderWeb.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "../GameCommon.h" 7 | 8 | 9 | namespace LegoRR 10 | {; // !<--- 11 | 12 | /********************************************************************************** 13 | ******** Forward Declarations 14 | **********************************************************************************/ 15 | 16 | #pragma region Forward Declarations 17 | 18 | #pragma endregion 19 | 20 | /********************************************************************************** 21 | ******** Constants 22 | **********************************************************************************/ 23 | 24 | #pragma region Constants 25 | 26 | #pragma endregion 27 | 28 | /********************************************************************************** 29 | ******** Enumerations 30 | **********************************************************************************/ 31 | 32 | #pragma region Enums 33 | 34 | enum SpiderWeb_BlockFlags : uint32 // [LegoRR/SpiderWeb.c|flags:0x4|type:uint] 35 | { 36 | BLOCKWEB_FLAG_NONE = 0, 37 | BLOCKWEB_FLAG_ACTIVE = 0x100, 38 | }; 39 | flags_end(SpiderWeb_BlockFlags, 0x4); 40 | 41 | #pragma endregion 42 | 43 | /********************************************************************************** 44 | ******** Structures 45 | **********************************************************************************/ 46 | 47 | #pragma region Structs 48 | 49 | struct SpiderWeb_Block // [LegoRR/SpiderWeb.c|struct:0xc] 50 | { 51 | /*0,4*/ LegoObject* object; // "SpiderWeb" LiveObject 52 | /*4,4*/ real32 health; // Assumed as health, init: 100.0f 53 | /*8,4*/ SpiderWeb_BlockFlags flags; 54 | /*c*/ 55 | }; 56 | assert_sizeof(SpiderWeb_Block, 0xc); 57 | 58 | 59 | struct SpiderWeb_Globs // [LegoRR/SpiderWeb.c|struct:0x8|tags:GLOBS] 60 | { 61 | /*0,4*/ SpiderWeb_Block* webBlocks; 62 | /*4,4*/ Lego_Level* level; 63 | /*8*/ 64 | }; 65 | assert_sizeof(SpiderWeb_Globs, 0x8); 66 | 67 | #pragma endregion 68 | 69 | /********************************************************************************** 70 | ******** Globals 71 | **********************************************************************************/ 72 | 73 | #pragma region Globals 74 | 75 | // 76 | extern SpiderWeb_Globs & spiderwebGlobs; 77 | 78 | #pragma endregion 79 | 80 | /********************************************************************************** 81 | ******** Macros 82 | **********************************************************************************/ 83 | 84 | #pragma region Macros 85 | 86 | #pragma endregion 87 | 88 | /********************************************************************************** 89 | ******** Functions 90 | **********************************************************************************/ 91 | 92 | #pragma region Functions 93 | 94 | // 95 | #define SpiderWeb_Initialise ((void (__cdecl* )(Lego_Level* level))0x00466480) 96 | //void __cdecl SpiderWeb_Initialise(Lego_Level* level); 97 | 98 | // 99 | #define SpiderWeb_Shutdown ((void (__cdecl* )(void))0x004664d0) 100 | //void __cdecl SpiderWeb_Shutdown(void); 101 | 102 | // 103 | #define SpiderWeb_Restart ((void (__cdecl* )(Lego_Level* level))0x004664f0) 104 | //void __cdecl SpiderWeb_Restart(Lego_Level* level); 105 | 106 | // 107 | #define SpiderWeb_SpawnAt ((bool32 (__cdecl* )(uint32 bx, uint32 by))0x00466510) 108 | //bool32 __cdecl SpiderWeb_SpawnAt(uint32 bx, uint32 by); 109 | 110 | // 111 | #define SpiderWeb_Add ((void (__cdecl* )(sint32 bx, sint32 by, LegoObject* webObj))0x00466640) 112 | //void __cdecl SpiderWeb_Add(sint32 bx, sint32 by, LegoObject* webObj); 113 | 114 | // 115 | #define SpiderWeb_GetAngle ((bool32 (__cdecl* )(sint32 bx, sint32 by, OUT real32* theta))0x004666b0) 116 | //bool32 __cdecl SpiderWeb_GetAngle(sint32 bx, sint32 by, OUT real32* theta); 117 | 118 | // 119 | #define SpiderWeb_CheckCollision ((bool32 (__cdecl* )(LegoObject* liveObj))0x00466750) 120 | //bool32 __cdecl SpiderWeb_CheckCollision(LegoObject* liveObj); 121 | 122 | // 123 | #define SpiderWeb_Update ((bool32 (__cdecl* )(real32 elapsedGame))0x00466880) 124 | //bool32 __cdecl SpiderWeb_Update(real32 elapsedGame); 125 | 126 | // 127 | #define SpiderWeb_LiveObjectCallback ((bool32 (__cdecl* )(LegoObject* liveObj, real32* pElapsedGame))0x004668a0) 128 | //bool32 __cdecl SpiderWeb_LiveObjectCallback(LegoObject* liveObj, real32* pElapsedGame); 129 | 130 | // 131 | #define SpiderWeb_Remove ((void (__cdecl* )(sint32 bx, sint32 by))0x00466a10) 132 | //void __cdecl SpiderWeb_Remove(sint32 bx, sint32 by); 133 | 134 | #pragma endregion 135 | 136 | } 137 | -------------------------------------------------------------------------------- /src/openlrr/game/world/Teleporter.cpp: -------------------------------------------------------------------------------- 1 | // Teleporter.cpp : 2 | // 3 | 4 | #include "Teleporter.h" 5 | 6 | 7 | /********************************************************************************** 8 | ******** Globals 9 | **********************************************************************************/ 10 | 11 | #pragma region Globals 12 | 13 | // 14 | LegoRR::Teleporter_Globs & LegoRR::teleporterGlobs = *(LegoRR::Teleporter_Globs*)0x004ab450; 15 | 16 | // 17 | bool32 & LegoRR::g_Teleporter_BOOL_00504188 = *(bool32*)0x00504188; 18 | 19 | #pragma endregion 20 | 21 | /********************************************************************************** 22 | ******** Functions 23 | **********************************************************************************/ 24 | 25 | #pragma region Functions 26 | 27 | // 28 | //void __cdecl LegoRR::Teleporter_RemoveAll(TeleporterService* teleporter); 29 | 30 | // 31 | //void __cdecl LegoRR::Teleporter_Restart(void); 32 | 33 | // 34 | //bool32 __cdecl LegoRR::Teleporter_LiveObjectCallback_Service(LegoObject* liveObj, void* search); 35 | 36 | // 37 | //Point2F __cdecl LegoRR::Teleporter_GetCameraPosition(void); 38 | 39 | // 40 | //void __cdecl LegoRR::Teleporter_Add(TeleporterService* teleporter); 41 | 42 | // 43 | //bool32 __cdecl LegoRR::Teleporter_LiveObjectCallback_Unk(LegoObject* liveObj, void* teleportObjType); 44 | 45 | // 46 | //bool32 __cdecl LegoRR::Teleporter_ServiceAll(LegoObject_TypeFlags teleportObjTypes); 47 | 48 | // 49 | //void __cdecl LegoRR::Teleporter_Start(LegoObject_TypeFlags teleportObjType, uint32 modeFlags, uint32 teleportFlags); 50 | 51 | // 52 | //bool32 __cdecl LegoRR::Teleporter_LiveObjectCallback_Update(LegoObject* liveObj, void* data_unused); 53 | 54 | // 55 | //bool32 __cdecl LegoRR::Teleporter_UpdateService(TeleporterService* teleporter, real32 elapsedGame); 56 | 57 | // 58 | //void __cdecl LegoRR::Teleporter_Update(real32 elapsedGame); 59 | 60 | // 61 | //LegoRR::LegoObject_Type __cdecl LegoRR::Teleporter_GetServiceObjectType(LegoObject_TypeFlags teleportObjType); 62 | 63 | #pragma endregion 64 | -------------------------------------------------------------------------------- /src/openlrr/hook.h: -------------------------------------------------------------------------------- 1 | // hook.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "common.h" 7 | 8 | 9 | uint32 hook_to_dist(void* src, void* dst, sint32 srcOffset, sint32 dstOffset); 10 | inline uint32 hook_to_dist(uint32 src, void* dst, sint32 srcOffset, sint32 dstOffset) 11 | { 12 | return hook_to_dist((void*)src, dst, srcOffset, dstOffset); 13 | } 14 | inline uint32 hook_to_dist(uint32 src, uint32 dst, sint32 srcOffset, sint32 dstOffset) 15 | { 16 | return hook_to_dist((void*)src, (void*)dst, srcOffset, dstOffset); 17 | } 18 | 19 | 20 | void* hook_from_dist(void* src, uint32 dist, sint32 srcOffset, sint32 distOffset); 21 | inline uint32 hook_from_dist(uint32 src, uint32 dist, sint32 srcOffset, sint32 distOffset) 22 | { 23 | return (uint32)hook_from_dist((void*)src, dist, srcOffset, distOffset); 24 | } 25 | 26 | 27 | bool hook_write_jmp(void* address, void* jmpAddress, OPTIONAL uint8* backup = nullptr); 28 | inline bool hook_write_jmp(uint32 address, void* jmpAddress, OPTIONAL uint8* backup = nullptr) 29 | { 30 | return hook_write_jmp((void*)address, jmpAddress, backup); 31 | } 32 | 33 | 34 | bool hook_write_jmpret(void* address, void* jmpAddress, OPTIONAL uint8* backup = nullptr); 35 | inline bool hook_write_jmpret(uint32 address, void* jmpAddress, OPTIONAL uint8* backup = nullptr) 36 | { 37 | return hook_write_jmpret((void*)address, jmpAddress, backup); 38 | } 39 | 40 | 41 | bool hook_write_call(void* address, void* callAddress, OPTIONAL uint8* backup = nullptr); 42 | inline bool hook_write_call(uint32 address, void* callAddress, OPTIONAL uint8* backup = nullptr) 43 | { 44 | return hook_write_call((void*)address, callAddress, backup); 45 | } 46 | 47 | 48 | bool hook_write_addr(void* address, const void* newAddress, OPTIONAL void** backup = nullptr); 49 | inline bool hook_write_addr(uint32 address, const void* newAddress, OPTIONAL void** backup = nullptr) 50 | { 51 | return hook_write_addr((void*)address, newAddress, backup); 52 | } 53 | 54 | 55 | bool hook_write(void* address, const uint8* newData, size_t size, OPTIONAL uint8* backup = nullptr); 56 | inline bool hook_write(uint32 address, const uint8* newData, size_t size, OPTIONAL uint8* backup = nullptr) 57 | { 58 | return hook_write((void*)address, newData, size, backup); 59 | } 60 | 61 | 62 | bool hook_read(void* address, uint8* data, size_t size); 63 | inline bool hook_read(uint32 address, uint8* data, size_t size) 64 | { 65 | return hook_read((void*)address, data, size); 66 | } 67 | 68 | 69 | sint32 hook_cmp(void* address, const uint8* data, size_t size); 70 | inline sint32 hook_cmp(uint32 address, const uint8* data, size_t size) 71 | { 72 | return hook_cmp((void*)address, data, size); 73 | } 74 | -------------------------------------------------------------------------------- /src/openlrr/interop.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | 5 | 6 | constexpr const uint32 PROCESS_EIP = 0x0048f2c0; // LegoRR.exe!entry 7 | constexpr const uint32 PROCESS_WINMAIN = 0x00477a60; // LegoRR.exe!WinMain 8 | 9 | 10 | #pragma region DLL Import Hooks 11 | bool interop_hook_calls_WINMM_timeGetTime(void); 12 | #pragma endregion 13 | 14 | #pragma region C Runtime Hooks 15 | bool interop_hook_CRT_rand(void); 16 | #pragma endregion 17 | 18 | #pragma region Gods98 Engine Hooks 19 | bool interop_hook_WinMain(void); 20 | bool interop_hook_Gods98_3DSound(void); 21 | bool interop_hook_Gods98_Animation(void); 22 | bool interop_hook_calls_Gods98_AnimClone(void); 23 | bool interop_hook_Gods98_AnimClone(void); 24 | bool interop_hook_Gods98_Bmp(void); 25 | bool interop_hook_Gods98_Compress(void); 26 | bool interop_hook_Gods98_Config(void); 27 | bool interop_hook_Gods98_Containers(void); 28 | bool interop_hook_Gods98_DirectDraw(void); 29 | bool interop_hook_Gods98_Draw(void); 30 | bool interop_hook_Gods98_Dxbug(void); 31 | bool interop_hook_Gods98_Errors(void); 32 | bool interop_hook_Gods98_Files(void); 33 | bool interop_hook_calls_Gods98_Flic(void); 34 | bool interop_hook_Gods98_Flic(void); 35 | bool interop_hook_Gods98_Fonts(void); 36 | bool interop_hook_Gods98_Images(void); 37 | bool interop_hook_Gods98_Input(void); 38 | bool interop_hook_Gods98_Keys(void); 39 | bool interop_hook_Gods98_Lws(void); 40 | bool interop_hook_Gods98_Lwt(void); 41 | bool interop_hook_Gods98_Main(void); 42 | bool interop_hook_Gods98_Materials(void); 43 | bool interop_hook_Gods98_Maths(void); 44 | bool interop_hook_Gods98_Memory(void); 45 | bool interop_hook_Gods98_Mesh(void); 46 | bool interop_hook_Gods98_Movie(void); 47 | bool interop_hook_Gods98_Registry(void); 48 | bool interop_hook_Gods98_Sound(void); 49 | bool interop_hook_Gods98_TextWindow(void); 50 | bool interop_hook_Gods98_Utils(void); 51 | bool interop_hook_Gods98_Viewports(void); 52 | bool interop_hook_Gods98_Wad(void); 53 | bool interop_hook_Gods98_Init(void); 54 | #pragma endregion 55 | 56 | #pragma region LegoRR Game Hooks 57 | bool interop_hook_LegoRR_Advisor(void); 58 | bool interop_hook_LegoRR_AITask(void); 59 | bool interop_hook_LegoRR_BezierCurve(void); 60 | bool interop_hook_LegoRR_Bubbles(void); 61 | bool interop_hook_LegoRR_Building(void); 62 | bool interop_hook_LegoRR_Collision(void); 63 | bool interop_hook_LegoRR_Construction(void); 64 | bool interop_hook_LegoRR_Creature(void); 65 | bool interop_hook_LegoRR_Credits(void); 66 | bool interop_hook_LegoRR_DamageText(void); 67 | bool interop_hook_LegoRR_Effect(void); 68 | bool interop_hook_LegoRR_ElectricFence(void); 69 | bool interop_hook_LegoRR_Encyclopedia(void); 70 | bool interop_hook_LegoRR_Erosion(void); 71 | bool interop_hook_LegoRR_Fallin(void); 72 | bool interop_hook_LegoRR_FrontEnd(void); 73 | bool interop_hook_LegoRR_Game(void); 74 | bool interop_hook_LegoRR_Interface(void); 75 | bool interop_hook_LegoRR_LegoCamera(void); 76 | bool interop_hook_LegoRR_LightEffects(void); 77 | bool interop_hook_LegoRR_Loader(void); 78 | bool interop_hook_LegoRR_MeshLOD(void); 79 | bool interop_hook_LegoRR_Messages(void); 80 | bool interop_hook_LegoRR_NERPsFile(void); 81 | bool interop_hook_LegoRR_NERPsFunctions(void); 82 | bool interop_hook_LegoRR_Object(void); 83 | bool interop_hook_LegoRR_ObjectRecall(void); 84 | bool interop_hook_LegoRR_Objective(void); 85 | bool interop_hook_LegoRR_ObjInfo(void); 86 | bool interop_hook_LegoRR_Pointers(void); 87 | bool interop_hook_LegoRR_Priorities(void); 88 | bool interop_hook_LegoRR_PTL(void); 89 | bool interop_hook_LegoRR_RadarMap(void); 90 | bool interop_hook_LegoRR_Reward(void); 91 | bool interop_hook_LegoRR_Roof(void); 92 | bool interop_hook_LegoRR_SelectPlace(void); 93 | bool interop_hook_LegoRR_SFX(void); 94 | bool interop_hook_LegoRR_Smoke(void); 95 | bool interop_hook_LegoRR_Stats(void); 96 | bool interop_hook_LegoRR_ToolTip(void); 97 | bool interop_hook_LegoRR_TextMessages(void); 98 | bool interop_hook_LegoRR_Vehicle(void); 99 | bool interop_hook_LegoRR_Water(void); 100 | bool interop_hook_LegoRR_Weapons(void); 101 | #pragma endregion 102 | 103 | #pragma region LegoRR Game Special Hooks 104 | bool interop_hook_replace_LegoRR_PanelRadarMapZoom(void); 105 | #pragma endregion 106 | 107 | #pragma region Hook All 108 | bool interop_hook_all(void); 109 | #pragma endregion 110 | 111 | -------------------------------------------------------------------------------- /src/openlrr/legacy.cpp: -------------------------------------------------------------------------------- 1 | // legacy.h : 2 | // 3 | 4 | #include "legacy.h" 5 | 6 | 7 | /********************************************************************************** 8 | ******** Globals 9 | **********************************************************************************/ 10 | 11 | #pragma region Globals 12 | 13 | // Global variable for random number generation. 14 | 15 | // moved to: `engine/core/Maths.cpp` 16 | // 17 | //uint32 & legacy::g_rand = *(uint32*)0x004b0cc8; // = 1U; 18 | 19 | // These globals are used with inlined isspace, isdigit, is*, _isctype functions 20 | 21 | // (unused) 22 | // 23 | uint16* (& legacy::g_pctype) = *(uint16**)0x004b0d68; // = legacy::g_wctype; 24 | 25 | // (unused) 26 | // 27 | uint16* (& legacy::g_pwctype) = *(uint16**)0x004b0d6c; // = legacy::g_wctype; 28 | 29 | // 30 | uint16 (& legacy::g_wctype)[256] = *(uint16 (*)[256])0x004b0f74; 31 | 32 | // 33 | sint32 & legacy::g_pcharwidth = *(sint32*)0x004b0f74; // = 1; 34 | 35 | #pragma endregion 36 | -------------------------------------------------------------------------------- /src/openlrr/platform/d3drm.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "d3drm.h" 3 | 4 | 5 | /********************************************************************************** 6 | ******** IIDs 7 | **********************************************************************************/ 8 | 9 | #pragma region IIDs 10 | 11 | /// TODO: We're currently just relying on the IID defined in LegoRR, 12 | /// since our `d3drm.lib` won't give it to us. Later on this should be manually defined. 13 | 14 | // {4a1b1be6-bfed-11d1-8ed8-00a0c967a482} 15 | // 16 | IID & Idl::IID_IDirect3DRMViewport2 = *(IID*)0x004a0958; 17 | // {eb16cb03-d271-11ce-ac48-0000c03825a1} 18 | // 19 | IID & Idl::IID_IDirect3DRMFrame = *(IID*)0x004a0968; 20 | // {ff6b7f70-a40e-11d1-91f9-0000f8758e66} 21 | // 22 | IID & Idl::IID_IDirect3DRMFrame3 = *(IID*)0x004a0988; 23 | // {a3a80d01-6e12-11cf-ac4a-0000c03825a1} 24 | // 25 | IID & Idl::IID_IDirect3DRMMesh = *(IID*)0x004a09a8; 26 | // {4516ec77-8f20-11d0-9b6d-0000c0781bc3} 27 | // 28 | IID & Idl::IID_IDirect3DRMMeshBuilder2 = *(IID*)0x004a09c8; 29 | // {eb16cb09-d271-11ce-ac48-0000c03825a1} 30 | // 31 | IID & Idl::IID_IDirect3DRMTexture = *(IID*)0x004a0a18; 32 | // {eb16cb0b-d271-11ce-ac48-0000c03825a1} 33 | // 34 | IID & Idl::IID_IDirect3DRMMaterial = *(IID*)0x004a0a58; 35 | // {59163de0-6d43-11cf-ac4a-0000c03825a1} 36 | // 37 | IID & Idl::IID_IDirect3DRMUserVisual = *(IID*)0x004a0b48; 38 | // {4516ec83-8f20-11d0-9b6d-0000c0781bc3} 39 | // 40 | IID & Idl::IID_IDirect3DRM3 = *(IID*)0x004a0bd8; 41 | 42 | #pragma endregion 43 | -------------------------------------------------------------------------------- /src/openlrr/platform/d3drm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "windows.h" 4 | #include 5 | 6 | 7 | /********************************************************************************** 8 | ******** IIDs 9 | **********************************************************************************/ 10 | 11 | #pragma region IIDs 12 | namespace Idl 13 | {; // !<--- 14 | 15 | /// TODO: We're currently just relying on the IID defined in LegoRR, 16 | /// since our `d3drm.lib` won't give it to us. Later on this should be manually defined. 17 | 18 | // {4a1b1be6-bfed-11d1-8ed8-00a0c967a482} 19 | // 20 | extern IID & IID_IDirect3DRMViewport2; 21 | // {eb16cb03-d271-11ce-ac48-0000c03825a1} 22 | // 23 | extern IID & IID_IDirect3DRMFrame; 24 | // {ff6b7f70-a40e-11d1-91f9-0000f8758e66} 25 | // 26 | extern IID & IID_IDirect3DRMFrame3; 27 | // {a3a80d01-6e12-11cf-ac4a-0000c03825a1} 28 | // 29 | extern IID & IID_IDirect3DRMMesh; 30 | // {4516ec77-8f20-11d0-9b6d-0000c0781bc3} 31 | // 32 | extern IID & IID_IDirect3DRMMeshBuilder2; 33 | // {eb16cb09-d271-11ce-ac48-0000c03825a1} 34 | // 35 | extern IID & IID_IDirect3DRMTexture; 36 | // {eb16cb0b-d271-11ce-ac48-0000c03825a1} 37 | // 38 | extern IID & IID_IDirect3DRMMaterial; 39 | // {59163de0-6d43-11cf-ac4a-0000c03825a1} 40 | // 41 | extern IID & IID_IDirect3DRMUserVisual; 42 | // {4516ec83-8f20-11d0-9b6d-0000c0781bc3} 43 | // 44 | extern IID & IID_IDirect3DRM3; 45 | 46 | } 47 | #pragma endregion 48 | 49 | 50 | namespace legacy 51 | {; // !<--- 52 | 53 | /********************************************************************************** 54 | ******** Functions 55 | **********************************************************************************/ 56 | 57 | #pragma region Functions 58 | 59 | // 60 | __inline HRESULT Direct3DRMCreate(LPDIRECT3DRM* lplpDirect3DRM) 61 | { 62 | return ((HRESULT(__stdcall*)(LPDIRECT3DRM*))0x0049b970)(lplpDirect3DRM); 63 | } 64 | 65 | // 66 | __inline LPD3DVECTOR D3DRMVectorRandom(LPD3DVECTOR d) 67 | { 68 | return ((LPD3DVECTOR(__stdcall*)(LPD3DVECTOR))0x0049b976)(d); 69 | } 70 | 71 | // 72 | __inline LPD3DVECTOR D3DRMVectorRotate(LPD3DVECTOR r, LPD3DVECTOR v, LPD3DVECTOR axis, D3DVALUE theta) 73 | { 74 | return ((LPD3DVECTOR(__stdcall*)(LPD3DVECTOR, LPD3DVECTOR, LPD3DVECTOR, D3DVALUE))0x0049b97c)(r, v, axis, theta); 75 | } 76 | 77 | #pragma endregion 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/openlrr/platform/ddraw.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "windows.h" 4 | #include 5 | 6 | 7 | namespace legacy 8 | {; // !<--- 9 | 10 | /********************************************************************************** 11 | ******** Functions 12 | **********************************************************************************/ 13 | 14 | #pragma region Functions 15 | 16 | // 17 | __inline HRESULT DirectDrawEnumerateA(LPDDENUMCALLBACKA lpCallback, LPVOID lpContext) 18 | { 19 | return ((HRESULT(__stdcall*)(LPDDENUMCALLBACKA, LPVOID))0x0049b982)(lpCallback, lpContext); 20 | } 21 | 22 | // 23 | __inline HRESULT DirectDrawCreate(LPGUID lpGUID, IDirectDraw** lplpIDirectDraw, LPUNKNOWN pUnkOuter) 24 | { 25 | return ((HRESULT(__stdcall*)(LPGUID, IDirectDraw**, LPUNKNOWN))0x0049b988)(lpGUID, lplpIDirectDraw, pUnkOuter); 26 | } 27 | 28 | #pragma endregion 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/openlrr/platform/dinput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "windows.h" 4 | 5 | #ifndef DIRECTINPUT_VERSION 6 | #define DIRECTINPUT_VERSION 0x0500 7 | #elif DIRECTINPUT_VERSION != 0x0500 8 | #undef DIRECTINPUT_VERSION 9 | #define DIRECTINPUT_VERSION 0x0500 10 | #endif 11 | 12 | #include 13 | 14 | 15 | namespace legacy 16 | {; // !<--- 17 | 18 | /********************************************************************************** 19 | ******** Constants 20 | **********************************************************************************/ 21 | 22 | #pragma region Constants 23 | 24 | #define LEGACY_DIRECTINPUT_VERSION 0x0500 25 | 26 | #pragma endregion 27 | 28 | /********************************************************************************** 29 | ******** Functions 30 | **********************************************************************************/ 31 | 32 | #pragma region Functions 33 | 34 | // 35 | __inline HRESULT DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA* ppDI, LPUNKNOWN punkOuter) 36 | { 37 | return ((HRESULT(__stdcall*)(HINSTANCE, DWORD, LPDIRECTINPUTA*, LPUNKNOWN))0x0049ca68)(hinst, dwVersion, ppDI, punkOuter); 38 | } 39 | 40 | #pragma endregion 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/openlrr/platform/dsound.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "windows.h" 4 | #include 5 | 6 | 7 | namespace legacy 8 | {; // !<--- 9 | 10 | /********************************************************************************** 11 | ******** Functions 12 | **********************************************************************************/ 13 | 14 | #pragma region Functions 15 | 16 | // 17 | __inline HRESULT DirectSoundCreate(_In_opt_ LPCGUID pcGuidDevice, _Outptr_ LPDIRECTSOUND* ppDS, _Pre_null_ LPUNKNOWN pUnkOuter) 18 | { 19 | return ((HRESULT(__stdcall*)(LPCGUID, LPDIRECTSOUND*,LPUNKNOWN))0x0049ca6e)(pcGuidDevice, ppDS, pUnkOuter); 20 | } 21 | 22 | #pragma endregion 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/openlrr/platform/targetver.h: -------------------------------------------------------------------------------- 1 | // platform/targetver.h : 2 | // 3 | 4 | #pragma once 5 | 6 | // Including SDKDDKVer.h defines the highest available Windows platform. 7 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 8 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 9 | // 10 | 11 | // Disabled for now. Causing trouble with dsound 12 | #if 0 13 | #pragma warning (push) 14 | #pragma warning (disable : 4005) 15 | 16 | #include 17 | 18 | // Windows NT 4.0 19 | //#define _WIN32_WINNT 0x0400 20 | //#define WINVER 0x0400 21 | //#define NTDDI_VERSION 0x04000000 22 | 23 | // Windows 2000 24 | #define _WIN32_WINNT 0x0500 25 | #define WINVER 0x0500 26 | #define NTDDI_VERSION 0x05000000 27 | 28 | // Windows XP 29 | //#define _WIN32_WINNT 0x0501 30 | //#define WINVER 0x0501 31 | //#define NTDDI_VERSION 0x05010000 32 | 33 | #include 34 | 35 | #pragma warning (pop) 36 | #endif 37 | -------------------------------------------------------------------------------- /src/openlrr/platform/timeapi.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "windows.h" 4 | #include // timeGetTime() 5 | 6 | 7 | namespace legacy 8 | {; // !<--- 9 | 10 | /********************************************************************************** 11 | ******** Functions 12 | **********************************************************************************/ 13 | 14 | #pragma region Functions 15 | 16 | // 17 | __inline DWORD timeGetTime(void) 18 | { 19 | // no thunk function, has to be called as a pointer pointer 20 | return (*((DWORD(__stdcall**)(void))0x0076f594))(); 21 | } 22 | 23 | #pragma endregion 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/openlrr/platform/vfw.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "windows.h" 4 | #include // AVIFile 5 | 6 | 7 | namespace legacy 8 | {; // !<--- 9 | 10 | /********************************************************************************** 11 | ******** Functions 12 | **********************************************************************************/ 13 | 14 | #pragma region Functions 15 | 16 | // 17 | __inline HRESULT AVIStreamInfoA(_In_ PAVISTREAM pavi, _Out_writes_bytes_(lSize) LPAVISTREAMINFOA psi, _In_ LONG lSize) 18 | { 19 | return ((HRESULT(__stdcall*)(PAVISTREAM, LPAVISTREAMINFOA, LONG))0x0049b98e)(pavi, psi, lSize); 20 | } 21 | 22 | // 23 | __inline PGETFRAME AVIStreamGetFrameOpen(_In_ PAVISTREAM pavi, _In_opt_ LPBITMAPINFOHEADER lpbiWanted) 24 | { 25 | return ((PGETFRAME(__stdcall*)(PAVISTREAM, LPBITMAPINFOHEADER))0x0049b994)(pavi, lpbiWanted); 26 | } 27 | 28 | // 29 | __inline HRESULT AVIStreamOpenFromFileA(_Outptr_ PAVISTREAM FAR* ppavi, _In_ LPCSTR szFile, _In_ DWORD fccType, _In_ LONG lParam, _In_ UINT mode, _In_opt_ CLSID FAR* pclsidHandler) 30 | { 31 | return ((HRESULT(__stdcall*)(PAVISTREAM*, LPCSTR, DWORD, LONG, UINT, CLSID*))0x0049b99a)(ppavi, szFile, fccType, lParam, mode, pclsidHandler); 32 | } 33 | 34 | // 35 | __inline ULONG AVIStreamRelease(PAVISTREAM pavi) 36 | { 37 | return ((ULONG(__stdcall*)(PAVISTREAM))0x0049b9a0)(pavi); 38 | } 39 | 40 | // 41 | __inline LPVOID AVIStreamGetFrame(_In_ PGETFRAME pg, _In_ LONG lPos) 42 | { 43 | return ((LPVOID(__stdcall*)(PGETFRAME, LONG))0x0049b9a6)(pg, lPos); 44 | } 45 | 46 | // 47 | __inline void AVIFileInit(void) 48 | { 49 | ((void(__stdcall*)(void))0x0049b9ac)(); 50 | } 51 | 52 | #pragma endregion 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/openlrr/platform/windows.cpp: -------------------------------------------------------------------------------- 1 | // platform/windows.cpp : 2 | // 3 | 4 | #include "windows.h" 5 | 6 | 7 | // Enable visual styles 8 | //#pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") 9 | 10 | 11 | #pragma region Library Comments 12 | 13 | // Direct X Header Files and Library 14 | #pragma comment(lib, "ddraw.lib") // DirectDraw 15 | #pragma comment(lib, "dsound.lib") // DirectSound 16 | #pragma comment(lib, "dinput8.lib") // DirectInput 8.0 17 | #pragma comment(lib, "winmm.lib") // Multimedia System and timeGetTime() 18 | #pragma comment(lib, "dxguid.lib") // GUID and IID constants 19 | 20 | // Reintroduced legacy support: 21 | //#pragma comment(lib, "d3drm.lib") // Direct3DRM (included in linker settings) 22 | //#pragma comment(lib, "d3d8.lib") // Direct3D 8.0 23 | 24 | #pragma comment(lib, "vfw32.lib") // AVIFile 25 | 26 | // Windows Process and memory management (for inspecting runnings instance of LegoRR.exe) 27 | //#pragma comment(lib, "psapi.lib") // EnumProcesses() + OpenProcess() 28 | // 29 | // Used by Movie.cpp 30 | // 31 | #pragma comment(lib, "Strmbase.lib") // IAMMultiMediaStream interfaces 32 | #pragma comment(lib, "Strmiids.lib") // IAMMultiMediaStream IID constants 33 | 34 | #pragma endregion 35 | -------------------------------------------------------------------------------- /src/openlrr/platform/windows.h: -------------------------------------------------------------------------------- 1 | // platform/windows.h : 2 | // 3 | 4 | #pragma once 5 | 6 | #include "targetver.h" 7 | 8 | // dinput.h version. NOTE: Normally this is 0x500 (v5) in LegoRR, 9 | // but we don't need to try to support that. 10 | //#define DIRECTINPUT_VERSION 0x0800 11 | //#define DIRECTINPUT_VERSION 0x0500 12 | 13 | 14 | #pragma warning (push) 15 | #pragma warning (disable : 4005) 16 | 17 | //#define _USE_MATH_DEFINES // Include constants such as M_PI 18 | 19 | //#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 20 | #include 21 | 22 | #pragma warning (pop) 23 | 24 | 25 | #pragma region API Includes 26 | 27 | // Direct X Header Files and Library 28 | //#include // Multimedia System 29 | //#include // Direct3D 30 | //#include // DirectDraw 31 | //#include // DirectSound 32 | //#include // DirectInput 8.0 33 | // Reintroduced legacy support: 34 | 35 | ////////////////////// 36 | // TODO: re-add me 37 | //#include // now available as additional include 38 | ////////////////////// 39 | 40 | //#include // AVIFile 41 | //#include // timeGetTime() 42 | 43 | // Windows Process and memory management (for inspecting runnings instance of LegoRR.exe) 44 | //#include // ReadProcessMemory() 45 | //#include // EnumProcesses() + OpenProcess() 46 | 47 | #pragma endregion 48 | --------------------------------------------------------------------------------