Commit graph

1143 commits

Author SHA1 Message Date
Joshua Peisach
5617e0e044
MxAudioManager: Destructor, LockedReinitialize, Reinitialize (#125)
* MxAudioManager: Destructor, LockedReinitialize

* MxAudioManager::Reinitialize, fix LockedReinitialize logic

* MxAudioManager cleanup

- fix param in LockedReinitialize, mark that function as private/give it a better param name

* Match LockedReinitialize, fix function declarations, add/match InitPresenters

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
2023-09-19 16:42:39 +02:00
Christian Semmler
c67e537508
Implement/match MxMediaManager::Tickle (#127)
* Implement/match MxMediaManager::Tickle

* Remove space
2023-09-17 14:10:38 -07:00
Christian Semmler
b819657bd8
Implement AddPresenter, RemovePresenter, StopPresenters (#124)
* Add MxList, MxPresenterList, add to MxMediaManager

* Match ~MxList<T>

* Implement AddPresenter, RemovePresenter, StopPresenters

* Initial implementation of RemovePresenter/Find/Detach

* Implement/match MxMediaManager::StopPresenters

* Move definitions out of class body

* Match RemovePresenter/Detach

* Fix style

* Fix merge error

* Fix merge error

* Fix merge error

* Remove space
2023-09-17 12:38:50 +02:00
Christian Semmler
253538feed
Add MxList, MxPresenterList, add to MxMediaManager (#122)
* Add MxList, MxPresenterList, add to MxMediaManager

* Match ~MxList<T>
2023-09-16 21:18:56 -07:00
Christian Semmler
b1a2aeaed6
Print recompiled address when using --verbose 2023-09-13 10:39:35 -04:00
MS
89f66e4e0e
MxPresenter::ParseExtra (#123)
* MxPresenter::ParseExtra and surrounding functions

* Named extra data is MxDSAction, added Parsed flag to enum
2023-09-13 09:44:03 +02:00
Joshua Peisach
3e7cb6a7a8
Init functions in MxMediaPresenter and LegoPalettePresenter (#121)
* Match MxMediaPresenter::Init

* LegoPalettePresenter::Init()

* LegoPalettePresenter: for now, use undefined4 type
2023-09-11 13:43:55 -04:00
Joshua Peisach
dc18b5d9c1
MxDirect3D (#114)
* MxDirect3D Constructor

* Implement MxDirect3D::Clear (not yet matching)

* Match MxDirect3D::Clear

* Building out MxDirect3D, link dxguid, add size asserts

* Move a few things around on the Enumerate context obj

* remove dupe mxdirect3d

* Match BuildErrorString and _DoEnumerate

* Fix style

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
Co-authored-by: disinvite <disinvite@users.noreply.github.com>
2023-09-10 14:56:16 +02:00
Joshua Peisach
1fa2fd9737
The IslePathActor's (#113)
* pizza: fix type m_unk90

* Initial implementation of a lot of IslePathActor's

All IslePathActor's seem to have (for the most part), the same few variables in common,
probably some ID. SkateBoard, Pizza and TowTrack seem to be a bit more complicated with additional
fields surrounding it.

* Add missing ClassName(s) and IsA(s)

* Add decomp size asserts

* Fix size assertions

* Make legopathactor fields protected for now, fix a type in Pizza

* Fix TowTrack structure

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
2023-09-10 14:01:39 +02:00
MishaProductions
c4453fe49f
Match SetUserMaxLOD (#118)
* Match SetUserMaxLOD and implement UpdateMaxLOD

* Update realtimeview.cpp
2023-09-04 16:34:27 -07:00
Christian Semmler
2b3f7cbfc1
Add tickle states and implement/match MxPresenter::Tickle (#119)
* Implement/match MxPresenter::Tickle

* Remove space

* Explicit inline for aesthetics
2023-09-04 15:33:38 -07:00
Joshua Peisach
c7458211f3
Some MxBitmap vtable functions (#89)
* Match MxBitmap::vtable+40 (CopyColorData)

It's basically a call to StretchDIBits, which copies color data for a rectangle

* Name a ternary raster op

* Name variable m_unk18 (m_bmiColorsProvided)

Since this variable is passed to StretchDIBits, we can see what its supposed to mean.

We dont have DX5 docs, but we have docs of the current day, and this as its 'iUsage':
"Specifies whether the bmiColors member of the BITMAPINFO structure was provided and, if so, whether bmiColors contains explicit red, green, blue (RGB) values or indexes."
The second part (about what the bmiColors contains) seems redundant, since we know this is a boolean.

Source: https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-stretchdibits

* MxBitmap::CreatePalette is now up to 60%

* Add progress on MxBitmap::LoadFile, add the global bitmap signature, add Clone call in CreatePalette

* getting closer

* Implement MxBitmap::vtable18

* Got vtable18 into a better state

It's progress doesn't affect the status of CopyColorData, which is
back at 100%, as it makes sense the loop is a memcpy

* if you want to do more of vtable18 have fun

* Cleanup MxBitmap::LoadFile

* Begin work on FUN_100bd450 (ImportColorsToPalette)

This took a lot of time, finally I got a good understanding of it.

Primarily what's left now is the loop
https://hackmd.io/@KsNMFSBHTO2gxDyRIPRQ1g/H1LCVQXon

* Don’t include class name in method declaration

* yolo vtable38 (I can't test the build atm)

I moved up ImportColorsToPalette so other functions, including this one can use it

* Cleanup while i keep getting bored of matching these functions that wont match

* likely malloc is an operator new

* A few things for MxBitmap
* new struct MxBITMAPINFO
* vtable18 and ImportPalette 100%
* ImportColorsToPalette improvement

* Match vtable1c and vtable3c

* use MxResult return types

* CreatePalette - Use MxResult to track success

* Define types for the bit depth

That boolean is not really a boolean, its just a variable to store
the bit depth as some DWORD. 0 = 256 color, 1 = High Color (16-bit).

* Match MxBitmap::CreatePalette

* Match LoadFile

YEGYEEHEEHEHEHEHEHE3 YES THIS IS FINALLY DONE OMFG

* Reorder variable placement in CreatePalette

* Start vtable14

* Match MxBitmap vtable14, down to reg swap.

Maybe some import function?

* Name MxBitmap vtable functions

---------

Co-authored-by: disinvite <disinvite@users.noreply.github.com>
Co-authored-by: Christian Semmler <mail@csemmler.com>
2023-08-28 03:04:39 -07:00
Joshua Peisach
5a2cc72dbb
MxMediaManager (#116) 2023-08-28 03:01:45 -07:00
Christian Semmler
2233da39d8
Implement/match MxDisplaySurface::Create (#115) 2023-08-28 02:49:15 -07:00
Joshua Peisach
23457da730
Matching spree (#98)
* LegoNavController: Match CalculateNewTargetSpeed

Ghidra showed this correctly too, but the asm showed the problem simply, an incorrect comparison

* Match a MxPresenter vtable function

* Match known functions in LegoPhonemePresenter

* Revert "LegoNavController: Match CalculateNewTargetSpeed"

This reverts commit 718489923b.

* MxPresenter: rename tickle flag fields

* LegoPhonemePresenter: add size assert

---------

Co-authored-by: MattKC <34096995+itsmattkc@users.noreply.github.com>
2023-08-28 02:38:46 -07:00
MattKC
1d104141b5
Update README.md [skip ci]
Remove no longer relevant SmartHeap section
2023-08-18 16:24:13 -07:00
Christian Semmler
28f961b86d
Add MxDSAnim, MxDSEvent, MxDSObjectAction, MxDSStill (#112)
* Add MxDSAnim

* Add MxDSEvent, MxDSObjectAction, MxDSStill
2023-08-16 16:38:26 -07:00
Christian Semmler
4a2226181c
Implement MxDSStreamingAction (#108)
* Implement MxDSStreamingAction

* Add remaining functions

* Use inline assignment operators
2023-08-16 15:02:26 -07:00
Christian Semmler
51ac526f8a
Add MxDSSound (#111) 2023-08-16 10:15:59 -07:00
MS
bb0d5be921
Implement MxAtomId and reference counter (stl set) (#109)
* Implement MxAtomId and reference counter (stl set)
* Partial success in hiding 4786 warning spam.
* Build out most of MxOmni::Destroy since it also touches the set

* Add some size asserts
2023-08-16 10:09:44 -07:00
MS
75c1276292
Skip upload step for forks (#110) 2023-08-14 16:03:30 -07:00
pewpew
87938e9b0e
Add modified mxstl.h (#107) 2023-08-12 10:32:43 -07:00
Christian Semmler
4e0149361e
Implement MxDSAction (#106) 2023-08-10 10:57:53 -07:00
Christian Semmler
a02e07c4d7
Implement MxDSAction::AppendData (#105)
* Implement MxDSAction::ConcatData

* use GLOBAL

* Update mxdsaction.cpp

* Update mxdsaction.h

* Move TWOCC/FOURCC to common header file

* Fix

* Fix deletes
2023-08-10 10:57:19 -07:00
Christian Semmler
88bfb3c419
Match MxDSAction::CopyFrom (#104)
* Match MxDSAction::CopyFrom

* Fix src/dest

* Update mxvector.h

* Update mxvector.h

* Update mxvector.h

* Update mxdsaction.cpp
2023-08-09 16:48:49 -07:00
Christian Semmler
bd9dca0d3f
Implement most of MxDSAction (#103)
* Implement most of MxDSAction

* Update mxdsaction.h

* Update mxdsobject.cpp
2023-08-08 19:38:07 -07:00
Christian Semmler
d41b7f2ca4
Add GetDeviceModeFinder to WndProc (#102) 2023-08-06 13:26:14 -07:00
itsmattkc
b59d8ef5cf include directx 5 sdk
This is almost certainly abandonware, fairly small (<1MB), and is going to save us a lot of dev environment headaches
2023-08-06 12:47:16 -07:00
itsmattkc
67816d5213 disable "nonstandard extension used 'bool'" warning spam
In newer versions of MSVC, this could have been achieved with /wd4237, however 4.2 doesn't have this option, it only seems to have the pragma. Ah well.
2023-08-06 10:52:37 -07:00
Christian Semmler
c48fc69cf3
Implement/match MxDSAction constructor (#101)
* Implement MxDSAction constructor

* Update mxdsaction.cpp
2023-08-06 10:39:22 -07:00
MS
71950cd40a
lego1: MxVariableTable (#87)
* MxStringVariable -> MxVariable

* cursor test

* GetVariable to 100

* meh

* node insert inline

* move to header file

* use reference to match available code

* variable table init in mxomni, some reshuffling
2023-08-03 17:13:41 -07:00
Joshua Peisach
b6ada8f46c
Small implementations in MxEntity/MxEventManager (#96)
* Small implementations in MxEntity/MxEventManager

* Cleanup

* Update LEGO1/mxentity.cpp

---------

Co-authored-by: MattKC <34096995+itsmattkc@users.noreply.github.com>
2023-08-03 16:43:36 -07:00
Joshua Peisach
dc585c7f61
MxBackgroundAudioManager (#97)
* Start MxBackgroundAudioManager

* Match MxBackgroundAudioManager constructor. This took WAY too much time.

* add size assert

* improve readability of MxBackgroundAudioManager::Enable

While the previous iteration wasn't incorrect, it definitely reads like pseudocode (i.e. it's very unlikely any actual developers would have written that). This is much more readable/likely to have been written and still results in the same asm.

---------

Co-authored-by: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
2023-08-03 11:42:12 -07:00
Mark Langen
694045abd8
Implement MxVector2/3/4 and MxMatrix (#100)
* All of the MxVectors share an inheritance chain. MxVector4 inherits
  from MxVector3 which inherits from MxVector2.

* They all operate on a shared `float*` data member which points to the
  underlying storage.

* There are also MxVector3/4Data classes, which inherit from Vector3/4,
  but add concrete storage for the Vector data rather than just an
  abstract data pointer.

* The same is true for MxMatrix, with there being an abstract and a
  concrete variant of it.

* Also improve reccmp.py register matching algorithm. It previously
  could not recognize an effective match when a swap had to take place
  between two registers used on the same line. It turns out this happens
  a lot in floating point math code so I adjusted the implementation to
  break the disassembly lines on spaces rather than just linebreaks
  allowing the existing effective match code to handle that case too.
2023-08-03 11:25:29 -07:00
itsmattkc
ee7c419be8 fix the pizza conflict
Sounds like an episode of a neo-noir TV show
2023-08-03 11:21:05 -07:00
pewpew
0f92e345b3
MxTickleManager mostly done (#94)
* Checkpoint to show MxTickleManager::SetClientTickleInterval match.

* Match MxTickleManager::~MxTickleManager, obliterate MxTickleManager::SetClientTickleInterval.

* Make conditional more realistic, move MxTime to mxtypes.h, add TODO for MxTickleManager::Tickle.
2023-08-03 11:19:05 -07:00
Christian Semmler
932baa2a87
lego1: Add MxDisplaySurface class members and some functions (#95)
* Add MxDisplaySurface class members and some functions

* Add size assert

* style
2023-08-03 11:13:27 -07:00
Joshua Peisach
ff13dc691c
Start IslePathActor (#93)
* Start IslePathActor

* Update types/add needed type in LegoPathActor for Pizza

Yes, this is a recommit because last time I pushed my cmake dir

* Fix types in  islepathactor

* Adjust variables

* add size asserts

---------

Co-authored-by: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
2023-08-03 11:10:54 -07:00
Roman Masanin
db2b98c248
MxDirectDraw functions and structures (#33)
* MxDirectDraw functions and structures

* fix indents, and globals

* fix build, add mxdirectdraw build configuration

* add new files to cmake

* MxDirectDraw: Add code from my PR #19 on main repo

Merging in the missing functions from my pull request for MxDirectDraw on the main repo. Credit to @foxtacles for the GetPrimaryBitDepth function. All match 100% on reccmp except ErrorToString, but the problem there is with the jump table at the end.

Co-authored-by: Christian Semmler <mail@csemmler.com>

* improve match

* improve accuracy

* improve accuracy

* move _countof, impove up to 96.90%

* Update LEGO1/mxdirectdraw.h

Co-authored-by: MattKC <34096995+itsmattkc@users.noreply.github.com>

* Update LEGO1/mxdirectdraw.cpp

Co-authored-by: MattKC <34096995+itsmattkc@users.noreply.github.com>

* Update LEGO1/mxdirectdraw.cpp

Co-authored-by: MattKC <34096995+itsmattkc@users.noreply.github.com>

* Update LEGO1/mxdirectdraw.cpp

Co-authored-by: MattKC <34096995+itsmattkc@users.noreply.github.com>

* Update LEGO1/mxdirectdraw.cpp

* Update LEGO1/mxdirectdraw.cpp

---------

Co-authored-by: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Co-authored-by: disinvite <disinvite@users.noreply.github.com>
Co-authored-by: Christian Semmler <mail@csemmler.com>
2023-08-03 10:09:22 -07:00
Joshua Peisach
ac89815663
🍕 (#79)
* start pizza

* Add some pizza vtable functions (they are stubs at the moment)

Unknown parameter types, likely either Pizzeria or PizzaMissionState.

* Pizza: Add/update functions as according to MxCore inheritance

IsleActor::Notify needs to be stubbed
---------

Co-authored-by: Kai Kaufman <ktkaufman@wpi.edu>

* match pizza destructor

* Update pizza members

* add size asserts

---------

Co-authored-by: Kai Kaufman <ktkaufman@wpi.edu>
Co-authored-by: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
2023-08-03 09:54:08 -07:00
Christian Semmler
fa5417f58a
lego1: match MxVideoManager::RealizePalette (#92)
* Match MxVideoManager::RealizePalette

* Rename class

* Name some functions
2023-07-21 18:28:13 -07:00
pewpew
9fa08b1017
Pretty much match MxNotificationManager::FlushPending. (#91) 2023-07-16 18:38:37 -07:00
MS
c7acbf559f
lego1: implement MXIOINFO (#54)
* 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
2023-07-16 18:37:21 -07:00
Mark Langen
19dcfe1164
Fix SmartHeap files (#90) 2023-07-16 09:27:30 -07:00
Joshua Peisach
a31626cffb
MxDSAction/Chunk/MediaAction/Sound (#85)
* 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'
2023-07-15 23:51:11 -07:00
Joshua Peisach
e3bf7b53b5
MxEntity (#84)
* Start MxEntity

* MxEntity: make MxAtomId a member
2023-07-15 23:49:47 -07:00
pewpew
4a50a9ff56
MxNotificationManager and MxParam initial work. (#78)
* 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.
2023-07-15 23:43:08 -07:00
MattKC
2ffe227d82
Add SmartHeap (#83)
* 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>
2023-07-15 23:18:21 -07:00
Mark Langen
f247e10b7e
reccmp.py improvements (#82)
* 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%".
2023-07-15 23:13:34 -07:00
Joshua Peisach
f8b1995a83
LEGO1: MxPalette (#56)
* 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 63f2215737.

* 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>
2023-07-15 22:51:24 -07:00