From 8aad15d18bb9421d70114872403d9a58626e3030 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sun, 2 Jul 2023 06:49:42 +0200 Subject: [PATCH 1/4] lego1: match MxBitmap::Read and vtable (#67) * lego1: match MxBitmap::Read and vtable * fix param name --- LEGO1/mxbitmap.cpp | 103 ++++++++++++++++++++++++++++++++++----------- LEGO1/mxbitmap.h | 18 ++++++-- 2 files changed, 94 insertions(+), 27 deletions(-) diff --git a/LEGO1/mxbitmap.cpp b/LEGO1/mxbitmap.cpp index a7425dd8..2ccdd80b 100644 --- a/LEGO1/mxbitmap.cpp +++ b/LEGO1/mxbitmap.cpp @@ -14,15 +14,75 @@ MxBitmap::MxBitmap() // OFFSET: LEGO1 0x100bca10 MxBitmap::~MxBitmap() { - if (this->m_info != NULL) { + if (this->m_info != NULL) delete m_info; - } - if (this->m_data != NULL) { + if (this->m_data != NULL) delete m_data; - } - if (this->m_palette != NULL) { + if (this->m_palette != NULL) delete m_palette; - } +} + +// OFFSET: LEGO1 0x100bcc40 STUB +int MxBitmap::vtable14(int) +{ + return 0; +} + +// OFFSET: LEGO1 0x100bcba0 STUB +int MxBitmap::vtable18(BITMAPINFOHEADER *p_bmiHeader) +{ + return 0; +} + +// OFFSET: LEGO1 0x100bcaa0 STUB +int MxBitmap::vtable1c(int p_width, int p_height, MxPalette *p_palette, int) +{ + return 0; +} + +// OFFSET: LEGO1 0x100bcd60 STUB +MxResult MxBitmap::LoadFile(HANDLE p_handle) +{ + return SUCCESS; +} + +// OFFSET: LEGO1 0x100bcd10 +long MxBitmap::Read(const char *p_filename) +{ + MxResult result = FAILURE; + HANDLE handle = CreateFileA( + p_filename, + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL + ); + + if (handle != INVALID_HANDLE_VALUE && !LoadFile(handle)) + result = SUCCESS; + + if (handle) + CloseHandle(handle); + + return result; +} + +// OFFSET: LEGO1 0x1004e0d0 +int MxBitmap::vtable28(int) +{ + return -1; +} + +// OFFSET: LEGO1 0x100ce70 STUB +void MxBitmap::vtable2c(int, int, int, int, int, int, int) +{ +} + +// OFFSET: LEGO1 0x100d020 STUB +void MxBitmap::vtable30(int, int, int, int, int, int, int) +{ } // OFFSET: LEGO1 0x100bd1c0 @@ -51,24 +111,19 @@ MxPalette *MxBitmap::CreatePalette() return pal; } -// OFFSET: LEGO1 0x100bcd10 -long MxBitmap::Read(const char *filename) +// OFFSET: LEGO1 0x100bd280 STUB +void MxBitmap::vtable38(void*) { - HANDLE handle; - int unk1; - MxResult ret = FAILURE; - - handle = CreateFileA(filename,GENERIC_READ,FILE_SHARE_READ,(LPSECURITY_ATTRIBUTES)NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,(HANDLE)NULL); - if(handle != (HANDLE)INVALID_HANDLE_VALUE) { // INVALID_HANDLE_VALUE = -1, or 0xffffffff - // FIXME: line 16. iVar gets changed in this line - if(unk1 == 0) { - ret = SUCCESS; - } - } - if(handle != (HANDLE)NULL) { - CloseHandle(handle); - } - - return ret; } +// OFFSET: LEGO1 0x100bd2d0 STUB +int MxBitmap::vtable3c(MxBool) +{ + return 0; +} + +// OFFSET: LEGO1 0x100bd3e0 STUB +int MxBitmap::vtable40(HDC p_hdc, int p_xSrc, int p_ySrc, int p_xDest, int p_yDest, int p_destWidth, int p_destHeight) +{ + return 0; +} \ No newline at end of file diff --git a/LEGO1/mxbitmap.h b/LEGO1/mxbitmap.h index 24d9e166..e16fcb0e 100644 --- a/LEGO1/mxbitmap.h +++ b/LEGO1/mxbitmap.h @@ -11,9 +11,21 @@ class MxBitmap : public MxCore { public: __declspec(dllexport) MxBitmap(); - __declspec(dllexport) virtual ~MxBitmap(); - __declspec(dllexport) virtual MxPalette *CreatePalette(); - __declspec(dllexport) virtual long Read(const char *); + __declspec(dllexport) virtual ~MxBitmap(); // vtable+00 + + virtual int vtable14(int); + virtual int vtable18(BITMAPINFOHEADER *p_bmiHeader); + virtual int vtable1c(int p_width, int p_height, MxPalette *p_palette, int); + virtual MxResult LoadFile(HANDLE p_handle); + __declspec(dllexport) virtual long Read(const char *p_filename); // vtable+24 + virtual int vtable28(int); + virtual void vtable2c(int, int, int, int, int, int, int); + virtual void vtable30(int, int, int, int, int, int, int); + __declspec(dllexport) virtual MxPalette *CreatePalette(); // vtable+34 + virtual void vtable38(void*); + virtual int vtable3c(MxBool); + virtual int vtable40(HDC p_hdc, int p_xSrc, int p_ySrc, int p_xDest, int p_yDest, int p_destWidth, int p_destHeight); + private: BITMAPINFO *m_info; BITMAPINFOHEADER *m_bmiHeader; From 904640e028e7aa00b17c730887cfce070801cc66 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Sun, 2 Jul 2023 06:51:26 +0200 Subject: [PATCH 2/4] CI steps (#65) * break build up into steps * download artifacts * clone uploadtool * need env on windows * just use ubuntu for inkscape * report went missing * add inkscape to path * use ubuntu for compare * Revert "use ubuntu for compare" This reverts commit a4ce103d091185471bcd629f6dfa6d1ab97829eb. * reinstall after cache * try different apt cache * use im * use rsvg * change size to avoid downscaling * remove png * do not install librsvg anymore --- .github/workflows/build.yml | 58 ++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 09bf06a2..3bbc6d50 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,10 +1,6 @@ name: Build -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] +on: [push, pull_request] jobs: build: @@ -61,6 +57,27 @@ jobs: cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -G "NMake Makefiles" cmake --build . + - name: Upload Artifact + uses: actions/upload-artifact@master + with: + name: Win32 + path: | + build/ISLE.EXE + build/ISLE.PDB + build/LEGO1.DLL + build/LEGO1.PDB + + compare: + needs: build + runs-on: windows-latest + steps: + - uses: actions/checkout@master + + - uses: actions/download-artifact@master + with: + name: Win32 + path: build + - name: Restore cached original binaries id: cache-original-binaries uses: actions/cache/restore@v3 @@ -103,14 +120,6 @@ jobs: run: | python3 tools/verexp/verexp.py legobin/LEGO1.DLL build/LEGO1.DLL - - name: Upload Artifact - uses: actions/upload-artifact@master - with: - name: Win32 - path: | - build/ISLE.EXE - build/LEGO1.DLL - - name: Upload Artifact uses: actions/upload-artifact@master with: @@ -118,15 +127,30 @@ jobs: path: | ISLEPROGRESS.* LEGO1PROGRESS.* - + + upload: + needs: [build, compare] + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + steps: + - uses: actions/checkout@v3 + with: + repository: 'probonopd/uploadtool' + + - uses: actions/download-artifact@master + with: + name: Win32 + path: build + + - uses: actions/download-artifact@master + with: + name: Accuracy Report + - name: Upload Continuous Release - shell: bash - if: github.event_name == 'push' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} UPLOAD_KEY: ${{ secrets.UPLOAD_KEY }} run: | - curl -fLOSs https://raw.githubusercontent.com/probonopd/uploadtool/master/upload.sh ./upload.sh \ build/ISLE.EXE \ build/LEGO1.DLL \ From 40dd0a93d473400f55cc2377c613eb469a0944ba Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sun, 2 Jul 2023 08:52:47 +0200 Subject: [PATCH 3/4] Faster reccmp.py on linux (#62) * reccmp: avoid repeated execution of winepath Executing winepath many times is slow, so try we like to avoid it as much as possible. When the path start with a known prefix, replace it with a cached prefix and do some string manipulation. This change reduces execution time of reccmp.py from 90s to 2s. Which is nice. m * reccmp: continue looking when source cannot be found Most often, the reasons is mismatched sources. * reccmp: add basic logging + optional debug * Read the addresses in the exe headers as little endian --- tools/reccmp/reccmp.py | 93 ++++++++++++++++++++++++++++++------------ 1 file changed, 66 insertions(+), 27 deletions(-) diff --git a/tools/reccmp/reccmp.py b/tools/reccmp/reccmp.py index abfe71a7..226be15d 100755 --- a/tools/reccmp/reccmp.py +++ b/tools/reccmp/reccmp.py @@ -6,6 +6,7 @@ import difflib import struct import subprocess +import logging import os import sys import colorama @@ -24,8 +25,14 @@ parser.add_argument('--svg-icon', metavar='icon', help='Icon to use in SVG (PNG)') parser.add_argument('--print-rec-addr', action='store_true', help='Print addresses of recompiled functions too') +parser.set_defaults(loglevel=logging.INFO) +parser.add_argument('--debug', action='store_const', const=logging.DEBUG, dest='loglevel', help='Print script debug information') + args = parser.parse_args() +logging.basicConfig(level=args.loglevel, format='[%(levelname)s] %(message)s') +logger = logging.getLogger(__name__) + colorama.init() verbose = None @@ -61,6 +68,7 @@ # to file addresses class Bin: def __init__(self, filename): + logger.debug('Parsing headers of "%s"... ', filename) self.file = open(filename, 'rb') #HACK: Strictly, we should be parsing the header, but we know where @@ -68,15 +76,16 @@ def __init__(self, filename): # Read ImageBase self.file.seek(0xB4) - self.imagebase = struct.unpack('i', self.file.read(4))[0] + self.imagebase, = struct.unpack(' str: + if unix_fn.startswith('./'): + return self.win_cmd + '\\' + unix_fn[2:].replace('/', '\\') + if unix_fn.startswith(self.unix_cwd): + return self.win_cwd + '\\' + unix_fn.removeprefix(self.unix_cwd).replace('/', '\\').lstrip('\\') + return self._call_winepath_unix2win(unix_fn) + + def get_unix_path(self, win_fn: str) -> str: + if win_fn.startswith('.\\') or win_fn.startswith('./'): + return self.unix_cwd + '/' + win_fn[2:].replace('\\', '/') + if win_fn.startswith(self.win_cwd): + return self.unix_cwd + '/' + win_fn.removeprefix(self.win_cwd).replace('\\', '/') + return self._call_winepath_win2unix(win_fn) + + @staticmethod + def _call_winepath_unix2win(fn: str) -> str: + return subprocess.check_output(['winepath', '-w', fn], text=True).strip() + + @staticmethod + def _call_winepath_win2unix(fn: str) -> str: + return subprocess.check_output(['winepath', fn], text=True).strip() def get_file_in_script_dir(fn): return os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), fn) @@ -109,22 +140,24 @@ class SymInfo: funcs = {} lines = {} - def __init__(self, pdb, file): + def __init__(self, pdb, file, wine_path_converter): call = [get_file_in_script_dir('cvdump.exe'), '-l', '-s'] - if os.name != 'nt': + if wine_path_converter: # Run cvdump through wine and convert path to Windows-friendly wine path call.insert(0, 'wine') - call.append(get_wine_path(pdb)) + call.append(wine_path_converter.get_wine_path(pdb)) else: call.append(pdb) - print('Parsing %s...' % pdb) - + logger.info('Parsing %s ...', pdb) + logger.debug('Command = %r', call) line_dump = subprocess.check_output(call).decode('utf-8').split('\r\n') current_section = None + logger.debug('Parsing output of cvdump.exe ...') + for i, line in enumerate(line_dump): if line.startswith('***'): current_section = line[4:] @@ -132,8 +165,6 @@ def __init__(self, pdb, file): if current_section == 'SYMBOLS' and 'S_GPROC32' in line: addr = int(line[26:34], 16) - - info = RecompiledInfo() info.addr = addr + recompfile.imagebase + recompfile.textvirt @@ -155,9 +186,9 @@ def __init__(self, pdb, file): elif current_section == 'LINES' and line.startswith(' ') and not line.startswith(' '): sourcepath = line.split()[0] - if os.name != 'nt': + if wine_path_converter: # Convert filename to Unix path for file compare - sourcepath = get_unix_path(sourcepath) + sourcepath = wine_path_converter.get_unix_path(sourcepath) if sourcepath not in self.lines: self.lines[sourcepath] = {} @@ -178,18 +209,23 @@ def __init__(self, pdb, file): j += 1 + logger.debug('... Parsing output of cvdump.exe finished') + def get_recompiled_address(self, filename, line): addr = None found = False - #print('Looking for ' + filename + ' line ' + str(line)) + logger.debug('Looking for %s:%d', filename, line) for fn in self.lines: # Sometimes a PDB is compiled with a relative path while we always have # an absolute path. Therefore we must - if os.path.samefile(fn, filename): - filename = fn - break + try: + if os.path.samefile(fn, filename): + filename = fn + break + except FileNotFoundError as e: + continue if filename in self.lines and line in self.lines[fn]: addr = self.lines[fn][line] @@ -197,13 +233,16 @@ def get_recompiled_address(self, filename, line): if addr in self.funcs: return self.funcs[addr] else: - print('Failed to find function symbol with address: %s' % hex(addr)) + logger.error('Failed to find function symbol with address: 0x%x', addr) else: - print('Failed to find function symbol with filename and line: %s:%s' % (filename, str(line))) + logger.error('Failed to find function symbol with filename and line: %s:%d', filename, line) +wine_path_converter = None +if os.name != 'nt': + wine_path_converter = WinePathConverter(source) origfile = Bin(original) recompfile = Bin(recomp) -syminfo = SymInfo(syms, recompfile) +syminfo = SymInfo(syms, recompfile, wine_path_converter) print() From 302b3f66f09133bd8feaff24992ffbd4e986211b Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sun, 2 Jul 2023 08:53:54 +0200 Subject: [PATCH 4/4] Get Isle building on MinGW32 (#63) * Add MxUnknown100dc6b0::~MxUnknown100dc6b0 stub * Declare destructor of MxOmni and MxTransitionManager in class * inline attribute must go first * Stub LegoState::Vtable0x14 for Act3State * MxStreamer::VTable0x14 is not an override * Stub MxEntity::Destroy for LegoState::Destroy * Stub MxUnknown100dc6e0 for MxSoundManager * ::ClassName and ::IsA are const methods * methods in the class body don't need a namespace * MxSoundManager subclasses MxUnknown100dc6e0 * LegoInputManager subclasses MxPresenter * NotificationId is an enum, and does not need __declspec(dllexport) * Fix final #endif of legoomni.h and mxobjectfactory.h * Add const alternative for LegoOmni::Create and MxVideoParam, only available for MinGW * Alternative approach to MinGW compatibility * MinGW on Linux is case sensitve * Don't delete a member variable. C++ automatically destructs member variables --------- Co-authored-by: MattKC <34096995+itsmattkc@users.noreply.github.com> --- CMakeLists.txt | 1 + LEGO1/act2brick.h | 6 +++--- LEGO1/compat.h | 14 ++++++++++++++ LEGO1/legobackgroundcolor.h | 3 ++- LEGO1/legoinputmanager.h | 8 ++++---- LEGO1/legoomni.cpp | 2 +- LEGO1/legoomni.h | 3 ++- LEGO1/legostate.cpp | 5 +++++ LEGO1/legostate.h | 4 +++- LEGO1/mxentity.cpp | 6 ++++++ LEGO1/mxentity.h | 2 ++ LEGO1/mxmediapresenter.h | 4 ++-- LEGO1/mxobjectfactory.h | 2 +- LEGO1/mxomni.h | 5 +++-- LEGO1/mxsoundmanager.cpp | 12 ++++++++++-- LEGO1/mxsoundmanager.h | 8 ++++++-- LEGO1/mxstreamer.h | 2 +- LEGO1/mxstringvariable.cpp | 17 ++++++++--------- LEGO1/mxstringvariable.h | 2 +- LEGO1/mxtimer.h | 2 +- LEGO1/mxtransitionmanager.h | 3 ++- LEGO1/mxunknown100dc6b0.cpp | 6 ++++++ LEGO1/mxunknown100dc6b0.h | 1 + LEGO1/mxunknown100dc6e0.cpp | 19 +++++++++++++++++++ LEGO1/mxunknown100dc6e0.h | 19 +++++++++++++++++++ LEGO1/mxvideoparam.cpp | 2 +- LEGO1/mxvideoparam.h | 3 ++- 27 files changed, 126 insertions(+), 35 deletions(-) create mode 100644 LEGO1/compat.h create mode 100644 LEGO1/mxunknown100dc6e0.cpp create mode 100644 LEGO1/mxunknown100dc6e0.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e7b584d9..4d4976fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,6 +142,7 @@ add_library(lego1 SHARED LEGO1/mxtimer.cpp LEGO1/mxtransitionmanager.cpp LEGO1/mxunknown100dc6b0.cpp + LEGO1/mxunknown100dc6e0.cpp LEGO1/mxvariabletable.cpp LEGO1/mxvideomanager.cpp LEGO1/mxvideoparam.cpp diff --git a/LEGO1/act2brick.h b/LEGO1/act2brick.h index d5703081..fd10a997 100644 --- a/LEGO1/act2brick.h +++ b/LEGO1/act2brick.h @@ -8,21 +8,21 @@ class Act2Brick : public LegoPathActor { public: - Act2Brick(); + Act2Brick(); virtual ~Act2Brick() override; // vtable+0x0 virtual long Notify(MxParam &p) override; // vtable+0x4 virtual long Tickle() override; // vtable+0x08 // OFFSET: LEGO1 0x1007a360 - inline virtual const char *ClassName() override // vtable+0x0c + inline virtual const char *ClassName() const override // vtable+0x0c { // 0x100f0438 return "Act2Brick"; } // OFFSET: LEGO1 0x1007a370 - inline virtual MxBool IsA(const char *name) override // vtable+0x10 + inline virtual MxBool IsA(const char *name) const override // vtable+0x10 { return !strcmp(Act2Brick::ClassName(), name) || LegoEntity::IsA(name); } diff --git a/LEGO1/compat.h b/LEGO1/compat.h new file mode 100644 index 00000000..496fa4db --- /dev/null +++ b/LEGO1/compat.h @@ -0,0 +1,14 @@ +#ifndef ISLECOMPAT_H +#define ISLECOMPAT_H + +// Various macros to enable compiling with other/newer compilers. + +// Use `COMPAT_CONST` where something ought to be 'const', and a newer compiler would complain if it +// wasn't, but we know it isn't 'const' in the original code. +#ifdef __MINGW32__ +#define COMPAT_CONST const +#else +#define COMPAT_CONST +#endif + +#endif // ISLECOMPAT_H \ No newline at end of file diff --git a/LEGO1/legobackgroundcolor.h b/LEGO1/legobackgroundcolor.h index 812e8882..1daa6311 100644 --- a/LEGO1/legobackgroundcolor.h +++ b/LEGO1/legobackgroundcolor.h @@ -2,7 +2,8 @@ #define LEGOBACKGROUNDCOLOR_H #include "mxstring.h" #include "mxcore.h" -#include "MxStringVariable.h" +#include "mxstringvariable.h" + class LegoBackgroundColor : public MxStringVariable { public: diff --git a/LEGO1/legoinputmanager.h b/LEGO1/legoinputmanager.h index caafed52..c629134e 100644 --- a/LEGO1/legoinputmanager.h +++ b/LEGO1/legoinputmanager.h @@ -1,9 +1,9 @@ #ifndef LEGOINPUTMANAGER_H #define LEGOINPUTMANAGER_H -#include "mxcore.h" +#include "mxpresenter.h" -__declspec(dllexport) enum NotificationId +enum NotificationId { NONE = 0, KEYDOWN = 7, @@ -15,7 +15,7 @@ __declspec(dllexport) enum NotificationId // VTABLE 0x100d8760 // SIZE 0x338 -class LegoInputManager +class LegoInputManager : public MxPresenter { public: LegoInputManager(); @@ -27,7 +27,7 @@ class LegoInputManager virtual long Tickle() override; // vtable+0x8 - char m_pad00[0x19C]; + char m_pad00[0x15c]; int m_joystickIndex; char m_pad200[0x194]; MxBool m_useJoystick; diff --git a/LEGO1/legoomni.cpp b/LEGO1/legoomni.cpp index 365748e7..45f7a9f7 100644 --- a/LEGO1/legoomni.cpp +++ b/LEGO1/legoomni.cpp @@ -176,7 +176,7 @@ void LegoOmni::Init() } // OFFSET: LEGO1 0x10058e70 -MxResult LegoOmni::Create(MxOmniCreateParam &p) +MxResult LegoOmni::Create(COMPAT_CONST MxOmniCreateParam &p) { // FIXME: Stub return SUCCESS; diff --git a/LEGO1/legoomni.h b/LEGO1/legoomni.h index 9d825ebc..512fba41 100644 --- a/LEGO1/legoomni.h +++ b/LEGO1/legoomni.h @@ -1,6 +1,7 @@ #ifndef LEGOOMNI_H #define LEGOOMNI_H +#include "compat.h" #include "legoentity.h" #include "legoinputmanager.h" #include "legogamestate.h" @@ -51,7 +52,7 @@ class LegoOmni : public MxOmni } virtual void Init(); // vtable+14 - virtual MxResult Create(MxOmniCreateParam &p); // vtable+18 + virtual MxResult Create(COMPAT_CONST MxOmniCreateParam &p); // vtable+18 virtual void Destroy(); // vtable+1c virtual void vtable20(); virtual void vtable24(MxDSAction &ds); diff --git a/LEGO1/legostate.cpp b/LEGO1/legostate.cpp index 2b49fcd7..55637dc4 100644 --- a/LEGO1/legostate.cpp +++ b/LEGO1/legostate.cpp @@ -4,3 +4,8 @@ LegoState::~LegoState() { } + +// OFFSET: LEGO1 0x10005f90 +MxBool LegoState::VTable0x14() { + return TRUE; +} diff --git a/LEGO1/legostate.h b/LEGO1/legostate.h index be7289bc..904ad323 100644 --- a/LEGO1/legostate.h +++ b/LEGO1/legostate.h @@ -11,7 +11,7 @@ class LegoState : public MxCore // OFFSET: LEGO1 0x100060d0 inline virtual const char *ClassName() const override // vtable+0x0c - { + { // 0x100f01b8 return "LegoState"; } @@ -22,6 +22,8 @@ class LegoState : public MxCore return !strcmp(name, LegoState::ClassName()) || MxCore::IsA(name); } + virtual MxBool VTable0x14(); + }; #endif // LEGOSTATE_H diff --git a/LEGO1/mxentity.cpp b/LEGO1/mxentity.cpp index 526a03e2..7459dd24 100644 --- a/LEGO1/mxentity.cpp +++ b/LEGO1/mxentity.cpp @@ -11,3 +11,9 @@ MxEntity::~MxEntity() { // TODO } + +// OFFSET: LEGO1 0x10001070 STUB +void MxEntity::Destroy() +{ + // TODO +} diff --git a/LEGO1/mxentity.h b/LEGO1/mxentity.h index dda04646..7123abbf 100644 --- a/LEGO1/mxentity.h +++ b/LEGO1/mxentity.h @@ -23,6 +23,8 @@ class MxEntity : public MxCore return !strcmp(name, MxEntity::ClassName()) || MxCore::IsA(name); } + virtual void Destroy(); // vtable+0x1c + // 0x8: MxResult // 0xc MxAtomId }; diff --git a/LEGO1/mxmediapresenter.h b/LEGO1/mxmediapresenter.h index 3fb70d31..647150c4 100644 --- a/LEGO1/mxmediapresenter.h +++ b/LEGO1/mxmediapresenter.h @@ -15,14 +15,14 @@ class MxMediaPresenter : public MxPresenter virtual long Tickle() override; // vtable+0x8, override MxCore // OFFSET: LEGO1 0x1000c5c0 - inline virtual const char *MxMediaPresenter::ClassName() const override // vtable+0xc + inline virtual const char *ClassName() const override // vtable+0xc { // 0x100f074c return "MxMediaPresenter"; } // OFFSET: LEGO1 0x1000c5d0 - inline virtual MxBool MxMediaPresenter::IsA(const char *name) const override // vtable+0x10 + inline virtual MxBool IsA(const char *name) const override // vtable+0x10 { return !strcmp(name, MxMediaPresenter::ClassName()) || MxPresenter::IsA(name); } diff --git a/LEGO1/mxobjectfactory.h b/LEGO1/mxobjectfactory.h index 57809be9..bdd172a8 100644 --- a/LEGO1/mxobjectfactory.h +++ b/LEGO1/mxobjectfactory.h @@ -9,4 +9,4 @@ class MxObjectFactory : public MxCore }; -#endif MXOBJECTFACTORY_H +#endif // MXOBJECTFACTORY_H diff --git a/LEGO1/mxomni.h b/LEGO1/mxomni.h index 0e837ad1..dee03229 100644 --- a/LEGO1/mxomni.h +++ b/LEGO1/mxomni.h @@ -28,8 +28,9 @@ class MxOmni : public MxCore __declspec(dllexport) static void SetCD(const char *p_cd); __declspec(dllexport) static void SetHD(const char *p_hd); __declspec(dllexport) static void SetSound3D(MxBool p_3dsound); - - virtual ~MxOmni(); + + MxOmni(); + virtual ~MxOmni() override; virtual long Notify(MxParam &p); // vtable+04 virtual void Init(); // vtable+14 diff --git a/LEGO1/mxsoundmanager.cpp b/LEGO1/mxsoundmanager.cpp index d12ecee1..275d0514 100644 --- a/LEGO1/mxsoundmanager.cpp +++ b/LEGO1/mxsoundmanager.cpp @@ -1,9 +1,9 @@ #include "mxsoundmanager.h" -// OFFSET: LEGO1 0x100ae740 STUB +// OFFSET: LEGO1 0x100ae740 MxSoundManager::MxSoundManager() { - // TODO + Init(); } // OFFSET: LEGO1 0x100ae7d0 STUB @@ -11,3 +11,11 @@ MxSoundManager::~MxSoundManager() { // TODO } + +// OFFSET: LEGO1 0x100ae830 +void MxSoundManager::Init() +{ + m_unk30 = 0; + m_unk34 = 0; +} + diff --git a/LEGO1/mxsoundmanager.h b/LEGO1/mxsoundmanager.h index 3421a5d6..4d74fa95 100644 --- a/LEGO1/mxsoundmanager.h +++ b/LEGO1/mxsoundmanager.h @@ -1,17 +1,21 @@ #ifndef MXSOUNDMANAGER_H #define MXSOUNDMANAGER_H -#include "mxcore.h" +#include "mxunknown100dc6e0.h" // VTABLE 0x100dc128 // SIZE 0x3c // Base vtables are: MxCore -> 0x100dc6b0 -> 0x100dc6e0 -> MxSoundManager -class MxSoundManager +class MxSoundManager : public MxUnknown100dc6e0 { public: MxSoundManager(); virtual ~MxSoundManager() override; // vtable+0x0 +private: + void Init(); + int m_unk30; + int m_unk34; }; #endif // MXSOUNDMANAGER_H diff --git a/LEGO1/mxstreamer.h b/LEGO1/mxstreamer.h index f8eeb43b..de84ed01 100644 --- a/LEGO1/mxstreamer.h +++ b/LEGO1/mxstreamer.h @@ -15,7 +15,7 @@ class MxStreamer : public MxCore __declspec(dllexport) long Close(const char *p); virtual long Notify(MxParam &p) override; // vtable+0x4 - virtual MxResult VTable0x14() override; // vtable+0x14 + virtual MxResult VTable0x14(); // vtable+0x14 }; #endif // MXSTREAMER_H diff --git a/LEGO1/mxstringvariable.cpp b/LEGO1/mxstringvariable.cpp index a9432679..e63329c1 100644 --- a/LEGO1/mxstringvariable.cpp +++ b/LEGO1/mxstringvariable.cpp @@ -1,14 +1,6 @@ -#include "MxStringVariable.h" +#include "mxstringvariable.h" #include "mxstring.h" -//FIXME: Figure out what exactly this class is used for. It is used in LegoGameState::LegoGameState when loading the background color, and for loading the "fsmovie" variable -// OFFSET: LEGO1 0x1003bec0 -MxStringVariable::~MxStringVariable() -{ - - delete &m_string; - delete &m_name; -} // OFFSET: LEGO1 0x1003bea0 MxString *MxStringVariable::GetString() @@ -21,3 +13,10 @@ void MxStringVariable::SetString(const char *colorString) { m_string = colorString; } + +//FIXME: Figure out what exactly this class is used for. It is used in LegoGameState::LegoGameState when loading the background color, and for loading the "fsmovie" variable +// OFFSET: LEGO1 0x1003bec0 +void MxStringVariable::Destroy() +{ + delete this; +} diff --git a/LEGO1/mxstringvariable.h b/LEGO1/mxstringvariable.h index 5284fc5d..dd623dfb 100644 --- a/LEGO1/mxstringvariable.h +++ b/LEGO1/mxstringvariable.h @@ -10,7 +10,7 @@ class MxStringVariable MxStringVariable() {} virtual MxString *GetString(); virtual void SetString(const char *colorString); - virtual ~MxStringVariable(); + virtual void Destroy(); protected: MxString m_name; diff --git a/LEGO1/mxtimer.h b/LEGO1/mxtimer.h index d79023d8..564eedfa 100644 --- a/LEGO1/mxtimer.h +++ b/LEGO1/mxtimer.h @@ -15,7 +15,7 @@ class MxTimer : public MxCore __declspec(dllexport) long GetRealTime(); - long GetTime() inline + inline long GetTime() { if (this->m_isRunning) return s_LastTimeCalculated; diff --git a/LEGO1/mxtransitionmanager.h b/LEGO1/mxtransitionmanager.h index 3fdb1ebf..9dcb7f7c 100644 --- a/LEGO1/mxtransitionmanager.h +++ b/LEGO1/mxtransitionmanager.h @@ -9,7 +9,8 @@ class MxVideoPresenter; class MxTransitionManager : public MxCore { public: - virtual ~MxTransitionManager(); // vtable+0x0 + MxTransitionManager(); + virtual ~MxTransitionManager() override; // vtable+0x0 __declspec(dllexport) void SetWaitIndicator(MxVideoPresenter *videoPresenter); diff --git a/LEGO1/mxunknown100dc6b0.cpp b/LEGO1/mxunknown100dc6b0.cpp index 029be1f7..b896fa10 100644 --- a/LEGO1/mxunknown100dc6b0.cpp +++ b/LEGO1/mxunknown100dc6b0.cpp @@ -6,6 +6,12 @@ MxUnknown100dc6b0::MxUnknown100dc6b0() Init(); } +// OFFSET: LEGO1 0x100b8560 STUB +MxUnknown100dc6b0::~MxUnknown100dc6b0() +{ + // TODO +} + // OFFSET: LEGO1 0x100b85d0 MxResult MxUnknown100dc6b0::Init() { diff --git a/LEGO1/mxunknown100dc6b0.h b/LEGO1/mxunknown100dc6b0.h index ca2ee600..29d42209 100644 --- a/LEGO1/mxunknown100dc6b0.h +++ b/LEGO1/mxunknown100dc6b0.h @@ -10,6 +10,7 @@ class MxUnknown100dc6b0 : public MxCore { public: MxUnknown100dc6b0(); + virtual ~MxUnknown100dc6b0() override; MxResult Init(); diff --git a/LEGO1/mxunknown100dc6e0.cpp b/LEGO1/mxunknown100dc6e0.cpp new file mode 100644 index 00000000..b896e89b --- /dev/null +++ b/LEGO1/mxunknown100dc6e0.cpp @@ -0,0 +1,19 @@ +#include "mxunknown100dc6e0.h" + +// OFFSET: LEGO1 0x100b8d00 +MxUnknown100dc6e0::MxUnknown100dc6e0() +{ + Init(); +} + +// OFFSET: LEGO1 0x100b8d90 STUB +MxUnknown100dc6e0::~MxUnknown100dc6e0() +{ + // TODO +} + +// OFFSET: LEGO1 0x100b8df0 +void MxUnknown100dc6e0::Init() +{ + this->m_unk2c = 100; +} diff --git a/LEGO1/mxunknown100dc6e0.h b/LEGO1/mxunknown100dc6e0.h new file mode 100644 index 00000000..79c63bab --- /dev/null +++ b/LEGO1/mxunknown100dc6e0.h @@ -0,0 +1,19 @@ +#ifndef MXUNKNOWN100DC6E0_H +#define MXUNKNOWN100DC6E0_H + +#include "mxunknown100dc6b0.h" + +// VTABLE 0x100dc6e0 +class MxUnknown100dc6e0 : public MxUnknown100dc6b0 +{ +public: + MxUnknown100dc6e0(); + virtual ~MxUnknown100dc6e0() override; + +protected: + void Init(); + + int m_unk2c; +}; + +#endif // MXUNKNOWN100DC6E0_H diff --git a/LEGO1/mxvideoparam.cpp b/LEGO1/mxvideoparam.cpp index b72107c7..81f5d2d7 100644 --- a/LEGO1/mxvideoparam.cpp +++ b/LEGO1/mxvideoparam.cpp @@ -17,7 +17,7 @@ MxVideoParam::MxVideoParam() } // OFFSET: LEGO1 0x100beca0 -MxVideoParam::MxVideoParam(MxRect32 &p_rect, MxPalette *p_pal, unsigned long p_backBuffers, MxVideoParamFlags &p_flags) +MxVideoParam::MxVideoParam(COMPAT_CONST MxRect32 &p_rect, MxPalette *p_pal, unsigned long p_backBuffers, COMPAT_CONST MxVideoParamFlags &p_flags) { this->m_rect.m_left = p_rect.m_left; this->m_rect.m_top = p_rect.m_top; diff --git a/LEGO1/mxvideoparam.h b/LEGO1/mxvideoparam.h index 3e00a920..0b6b2a38 100644 --- a/LEGO1/mxvideoparam.h +++ b/LEGO1/mxvideoparam.h @@ -3,6 +3,7 @@ #include +#include "compat.h" #include "mxpalette.h" #include "mxrect32.h" #include "mxtypes.h" @@ -14,7 +15,7 @@ class MxVideoParam public: __declspec(dllexport) MxVideoParam(); __declspec(dllexport) MxVideoParam(MxVideoParam &); - __declspec(dllexport) MxVideoParam(MxRect32 &rect, MxPalette *pal, unsigned long p3, MxVideoParamFlags &flags); + __declspec(dllexport) MxVideoParam(COMPAT_CONST MxRect32 &rect, MxPalette *pal, unsigned long p3, COMPAT_CONST MxVideoParamFlags &flags); __declspec(dllexport) MxVideoParam &operator=(const MxVideoParam &); __declspec(dllexport) ~MxVideoParam();