* Implementation of MXIOINFO. Not a 100% match, but we are very close. I don't wanna wrangle with this one any more, so I figured I would open it up for review in case anyone else has ideas.
**Known problems:**
- The Open function uses a `movzx` instruction on the value of parameter `fdwOpen` before pushing to OpenFile from the kernel. You can force this to appear by casting to `unsigned short`, but this disturbs the instructions for the rest of the file. To get the "best" overall match I decided to leave this out.
- Flush, Advance, and Descend differ only in the order of operands on a `cmp` instruction.
- This entire file is honestly pretty ugly. The main reason is all the nested ifs; we are constrained by returning a result value from each function, but only at the very end instead of bailing out with a `return`. By far the worst offender is the do/while loop in the Descend function.
**Design considerations:**
- We are casting the file handle from MMIOINFO to `HFILE` everywhere it is used, so I decided to just change the type. While doing that, I figured I might as well just pull out the members from the struct so we don't have `m_info` all over the place.
- Without using a struct member, we have the issue of the obvious `memset` used to zero out the values in the constructor. I changed this to work on the object itself, which would not be valid in most cases, but seems fine here since we have no virtual methods.
There is a lot of repeated code here, namely the call to `_llseek` to reset `m_lDiskOffset` based on the current file position. You could move this to an inline function, but maybe that's not appropriate.
There are probably strides to be made on code clarity and comments (if needed or wanted) here. I'm open to any suggestions.
* remove casts on read, add size assert
* Use more Mx* types and param style convention
* Fixing up MXIOINFO to prepare for merge.
* Following feedback from @stravant and @itsmattkc, reverted back to using `MMIOINFO` struct as the class member instead of adding its values directly. (We actually gained a little on accuracy with this change.)
* The memset to zero out the values in the constructor now acts on `m_info` instead of `this`. Strictly speaking we don't need the size assert any more but I decided to keep it in case we change the members later for some reason.
* Casting the `hmmio` member to `HFILE` (int) or `HMMIO` (WORD) typedefs where needed.
* Squelch a signed/unsigned type comparison warning
* Match MxDSChunk ctor/dtor
* Push work on MxDSAction/MediaAction/Sound
* MxDSMediaAction constructor is matching up to a mov location
* Match MxDSSound constructor by adding the missing member
just four bytes in between them in ghidra.. isn't that enough for ghidra to justify a member variable?
* Match MxDSMediaAction constructor
Today's lesson: ecx suggests '1'
* MxNotificationManager initial work.
* Add .swp files to .gitignore.
* Checkpoint before anything too crazy with param
* Cleanup and add MxParam.
* Checkpoint for everything except MxNotificationManager::Register.
* Add int return type to MxCore::GetId instead of relying on implicit function nonsense.
* Add stlcompat.h so this can still be built on modern compilers, fix affected type size asserts.
* Switch to Mx types
* Add BUILD_COMPAT option to CMake so the project can still be built with modern compilers.
* Change vtable14 and vtable18 to Register and Unregister in MxTickleManager.
* Remove last unsigned int reference to id type.
* Remove MxList, use one inherited class per type. Improves accuracy again.
* Address compiler compatibility code review.
* Match MxNotificationManager::Register.
* Re-enable MxNotificationManager DECOMP_SIZE_ASSERT.
* add smartheap
* cmake: bump even further
* this seemed to be necessary but now it isn't? ok
* cmake: force include smrtheap.hpp
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
* cmake: force include smrtheap.hpp 2
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
* remove compiler defs - unnecessary if force-including anyway
* cmake: use interface for cleaner code
---------
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
* Rather than using <OFFSET> as a replacement for all offsets in a
function, label the offsets as <OFFSET1>, <OFFSET2>, etc. Doing this
will avoid false-positive 100% matches resulting from the same
function being called in two times where a different on should have
been called or vice versa. And the same for globals. I already
encountered one case of this in the wild.
* When a 100% match initially fails, try to make the functions match by
swapping register allocations. This makes it possible to get a 100%
match where the generated machine code differs only in register
allocation.
* Only apply the above when it is possible to reach a 100% match in that
way. Otherwise show the developer the unadultrated diff to avoid
complicating decompilation.
* In the result listing, show the functions which are "effective
matches" in this way as "100%*" instead of "100%".
* MxPalette - add missing member variables, Detach function
* mb
* MxPalette: give bob the builder his constructor
* push progress, gn
* avoid hexadecimal
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
* fix MxPalette::GetDefaultPalette
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
* aaaaaaaaaaaaaa
* Revert "fix MxPalette::GetDefaultPalette"
This reverts commit 63f2215737d3bcd286f67dcf1a04fdf8a234d41b.
* Implement MxPalette::Clone (doesn't match)
* fix MxPalette structure and match ctor/dtor
* Matching progress for MxPalette::GetDefaultPalette
* Implement ApplySystemEntriesToPalette except the memcpy calls
* implement SetSkyColor (doesn't match)
* Use MxTypes instead of generics
* prefer decimal values than hex for m_entries
* Update mxpalette.cpp
* Push MxPalette progress - read comments in code.
* improved MxPalette::operator==, will be 100% when MSVC feels like making it so
* improved MxPalette::SetSkyColor, will be 100% when MSVC feels like making it so
* improved MxPalette::Clone, will be 100% when MSVC feels like making it so
* Fixes
- reordered the functions in order of where they are in the hex because recmp.py sometimes kept saying it couldn't find the symbol (??)
- clone returns a pointer, not a ref
- worked a bit on setpalette/applysysentriestopalette
* Match GetDefaultPalette a bit more
* fix: MxPalette::GetDefaultPalette is now 100% matching
* fix: MxPalette::ApplySystemEntriesToPalette is now 100% matching
* tidy: rename `DC` var in GetDefaultPalette to `hdc`
* fix: MxPalette::SetPalette is now functionally matching
Not assembly matching yet because of MSVC weirdness.
At some point it will probably start matching, because
the structure seems to be accurate.
* fix: MxPalette rgbquad ctor functionally matches
Not quite ASM matching yet because of weird
register allocation mismatches.
* fix: I forgot to commit mxpalette.h...
* tidy: use Mx* primitives instead of builtins
* refactor: remove MxPalette::FromBitmapPalette
* fix: call ApplySystemEntriesToPalette from MxPalette(const RGBQUAD *)
* rename MxPalette::SetPalette to MxPalette::SetEntries
* fix: I once again forgot to commit mxpalette.h...
* feat: add/match MxPalette::Reset [0x100BF490]
* fix: add MVideoManager() to mxomni header
* refactor: change unk50 in MxVideoManager to LPDIRECTDRAW
* feat: add/match MxPalette::CreateNativePalette [0x100BF000]
* fix: MxPalette::SetSkyColor is 100% matching
* Annotate MxPalette members' offsets
* Annotate the global default aplette
* use hex size
* remove unnecessary variable offset listing
* Update LEGO1/mxpalette.cpp
---------
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
Co-authored-by: Christian Semmler <mail@csemmler.com>
Co-authored-by: ktkaufman03 <ktkaufman@wpi.edu>
Co-authored-by: MattKC <34096995+itsmattkc@users.noreply.github.com>
* Add MxSemphore + MxThread and the two implementations I could find
of MxThread (consumers extend it and override the Run method).
* Implement a function in MxDiskStreamProvider which uses thread and
semaphore to confirm correct layout / size of those classes.
* All 100% match except two functions with a pair of registers swapped.
* MxFile and implementations 100% match
* Add MxFile and it's implementations, MxSystemFile and MxMemoryFile.
The names are chosen by me, we don't know their original naming.
* These expose a Read/Write/Seek/Tell interface for reading and writing
data, either from a file on disk or memory buffer.
* 100% match all functions.
* Change name to LegoStream
* Use p_ convention
* Assert size
* define MxLong/MxULong
The "long" type has different sizes on different platforms, and this may cause issues.
* use DWORD to match RegQueryValueExA arg
* 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>
* MxatomId: implement inline operator==
* Add decomp.h header, containing macro's only used when matching the original binaries
* Add in-line constructor of MxPresenter
* MxMediaPresenter: add members to match size
* MxVideoPresenter: add members to match size
* MxCompositePresenter: add members to match size
* MxFlcPresenter: add members to match size
* MxSmkPresenter: add members to match size
* MxStillPresenter: add members to match size
* MxAudioPresenter: add members to match size
* MxWavePresenter: add members to match size
* MxMIDIPresenter: add members to match size
* MxEventPresenter: add members to match size
* MxLoopingFlcPresenter: add members to match size
* MxLoopingSmkPresenter: add members to match size
* MxLoopingMIDIPresenter: add check for size
* Implement MxObjectFactory::{MxObjectFactory,Create}
Matching of MxObjectFactory::Create is not good, because none of the other objects have been implemented.
* Implement a few MxPresenter methods
* Fix size of LegoInputManager
* Fix name of first padding member of legoinputmanager.h
* add DECOMP_SIZE_ASSERT macro
* Use DECOMP_SIZE_ASSERT macro + convert to hexadecimal
* fixed minor typos
---------
Co-authored-by: MattKC <34096995+itsmattkc@users.noreply.github.com>
Co-authored-by: itsmattkc <itsmattkc@gmail.com>
* 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>
* 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
* 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
Now we can use our own compiled LEGO1.LIB rather than one generated from the original. Also implements a script that tests them to help ensure future commits don't break them.
* initial cmake implementation
* ci: i guess older cmake doesn't support this
* cmake: add max version to suppress warning
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
---------
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
* Stubbed a bunch of classes and annotated them for later use. Heavily wip and more of pseudocode right now.
* Converted pseudocode into real code!
* Created a bunch more classes and added more information to exisiting ones
Did not error check, this was pushed just for reference
* More classes and implementation details. Still not checked for any errors
* Fixed code and decided on a way to handle virtual table stubs
* Some additional fixes
* More smaller fixes
* Added classes to project and made it compile
* Fixed function adresses that caused the python script to fail
* More classes and virtual function resolves. Builds and compares fine.
* Again more classes and virtual function resolves. Builds and compares fine.
* No clue, I guess forced update for line endings
* Finished up some work, compiles fine. All functions are STUB annotated to not pollute reccmp.py output.
* line ending change
* rename GetClassName/IsClass
Mirroring recent changes from master
* further conform to current master
* update project
* cleanup
* project only updates when you close msdev
---------
Co-authored-by: Cydra <cydra95@gmail.com>
Co-authored-by: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Followed the hint from @madebr in #31 that the next function in MxString was operator+. The one after that is operator+= and both are at 100%.
Squashed commits:
* Removed unnecessary consts
* Replaced malloc/free with new/delete, which solved swapped regs in operator=
* Use delete[] when freeing char* m_data