Might & Magic Compatibility Layer (Tool)

The role-playing games (I-X) that started it all and the various spin-offs (including Dark Messiah).

Moderator: Moderators

Emjayen
Leprechaun
Leprechaun
Posts: 31
Joined: 01 Aug 2013

Might & Magic Compatibility Layer (Tool)

Postby Emjayen » May 19 2017, 15:52

I've written this tool [MMCL] to provide better compatibility for Might & Magic 6, 7 and 8 with modern kernels by emulating the old DirectX APIs the game uses, solving a few common issues (e.g, "flickering", performance, ect) and better compatibility with tools such as screen-capture software and video card vendor (e.g, Nvidia) tools.

Additionally,included is preliminary support for enabling arbitrary display resolutions (screenshot: http://i.imgur.com/ikK8BTg.png -- 1680x1050, note that the UI overlay is simply scaled)

Be aware that that is an alpha release and so there are still quite a few bugs (particularly with non-native game resolutions). That being said, I'd appreciate it if you report any bugs/issues you discover, including the following information in your post:

  • Your OS version (e.g, "Windows 8")
  • Your log file ("mmcl.log")
  • Your crash-dump (if the game crashed)
  • A screen-shot (if relevant)
  • Any other relevant information.

Download

http://laserblue.org/mmcl.zip (0.0.0.3/Alpha)

To install:

  • Extract/copy ddraw.dll and mmcl.ini to your installation folder (it should be alongside mm7.exe and the like)

There's a few settings you can configure via mmcl.ini

Notes
  • Requires Windows Vista or later
  • MMCL does not work with the game's "windowed" mode, however you can achieve the same effect by enabling "Windowed" in mmcl.ini
  • Tested against 1.1 (filever: 1.0.0.1) and GrayFace (filever: 1.2.1.0) binaries.
  • A small bug in the engine's UI rendering at larger resolutions has unfortunately required patching the game itself (this is done only at runtime, thus not persistent)
  • Disable any compatibility-mode settings
  • No custom resolution support for MM8 or MM6 (latter will be supported in release)

Known Issues
  • [MM7/8] Game mouse-input does not work at all when using non-game-native (ie., not 640x480) resolutions -- UI input not affected.
  • [MM7/8] Cursor behaviour/performance issues.
  • [MM7/8] Incorrect rendering of monsters info. display when right-clicking
  • [MM7/8] Rendering issues with software 3D mode ("Software" in the setup utility)
  • [MM7] Breaks GrayFace patch's "MouseLook" feature.
  • [MM7] Breaks GrayFace's "MMExtension"
Last edited by Emjayen on May 25 2017, 3:21, edited 34 times in total.

Emjayen
Leprechaun
Leprechaun
Posts: 31
Joined: 01 Aug 2013

Re: Might & Magic Compatibility Layer (Tool)

Postby Emjayen » May 21 2017, 6:39

0.0.0.2/Alpha (21-5-2017)
=========================
- Added support for Might & Magic VI
- Added support for Might & Magic VIII

tomchen1989
Leprechaun
Leprechaun
Posts: 28
Joined: 21 Jun 2008
Location: Shanghai

Re: Might & Magic Compatibility Layer (Tool)

Postby tomchen1989 » May 21 2017, 12:07

Sounds really great. Unfortunately it doesn't work for me.

Windows 10. Crash dump and other files are here:
https://www.dropbox.com/s/y6nfgu4gh65j6 ... s.zip?dl=0

Emjayen
Leprechaun
Leprechaun
Posts: 31
Joined: 01 Aug 2013

Re: Might & Magic Compatibility Layer (Tool)

Postby Emjayen » May 21 2017, 13:18

tomchen1989 wrote:Sounds really great. Unfortunately it doesn't work for me.

Windows 10. Crash dump and other files are here:
https://www.dropbox.com/s/y6nfgu4gh65j6 ... s.zip?dl=0


Thanks for the detailed report.

It appears you have a compatibility-mode enabled; try disabling it.

User avatar
GrayFace
Archlich
Archlich
Posts: 1102
Joined: 29 Nov 2005

Re: Might & Magic Compatibility Layer (Tool)

Postby GrayFace » May 21 2017, 17:02

Cool! I'm surprised how much better everything actually looks in good resolution. I didn't notice problems with filtering. It's going to be great when it's done.
In any resolution it's incompatible with mouse look in my patch, also mouse moves like it's on drugs - I do a move and then the cursor catches up in a very short, but noticeable time. Why do you have to change how mouse works at all? Because of DirectInput? If yes, then a version that only does graphics would be handy.
Also incompatible with MMExtension, I can look into that.
Last edited by GrayFace on May 21 2017, 17:04, edited 3 times in total.
My patches: MM6 MM7 MM8. MMExtension. Tools. Also, I love Knytt Stories and Knytt Underground. I'm also known as sergroj.

Emjayen
Leprechaun
Leprechaun
Posts: 31
Joined: 01 Aug 2013

Re: Might & Magic Compatibility Layer (Tool)

Postby Emjayen » May 22 2017, 1:05

Cool! I'm surprised how much better everything actually looks in good resolution. I didn't notice problems with filtering. It's going to be great when it's done.

Yeah, I, too was surprised. Particularly at how well the UI turned out given it's simply bilinearly scaled -- point filtering may even give a decent result and intend to enable this to be configurable for users.

In any resolution it's incompatible with mouse look in my patch, also mouse moves like it's on drugs - I do a move and then the cursor catches up in a very short, but noticeable time. Why do you have to change how mouse works at all? Because of DirectInput? If yes, then a version that only does graphics would be handy.

I was able to reproduce that behaviour with Win95 compatibility mode enabled. I haven't looked into which actual associated aclayer fix causes it, but it results in the DInput thread only sampling at roughly 1Hz which in turn means the cursor is only updated at the same rate and sounds like what you're describing. That being said; try disabling any compatibility mode, if it still persists I'll have to look into it more.

The issues with mouse-look is another story -- although I do intend to [optionally] provide DInput emulation due to it being all but deprecated, at the moment MMCL does not interfere directly with the mouse at all and so I suspect the problem is related to the differing window/cursor handling behaviours of DirectDraw vs Direct3D9 (the game's window handle gets passed directly to D3D9, of which also hooks the window to handle a few things) and am currently investigating what may be causing it.
Last edited by Emjayen on May 22 2017, 1:06, edited 1 time in total.

User avatar
GrayFace
Archlich
Archlich
Posts: 1102
Joined: 29 Nov 2005

Re: Might & Magic Compatibility Layer (Tool)

Postby GrayFace » May 22 2017, 2:50

No, compatibility is off.
The problem with mouse look is that game window is at -32000x-32000 coordinates with 160x29 size: https://www.dropbox.com/s/uqvlf8790dif4 ... 0.png?dl=0
This must also be the reason why when you start the game mouse starts at top-left corner rather than center of the screen. With mouse look it also looks up and rotates, I suspect it rotates left.
My patches: MM6 MM7 MM8. MMExtension. Tools. Also, I love Knytt Stories and Knytt Underground. I'm also known as sergroj.

Emjayen
Leprechaun
Leprechaun
Posts: 31
Joined: 01 Aug 2013

Re: Might & Magic Compatibility Layer (Tool)

Postby Emjayen » May 23 2017, 9:51

0.0.0.3/Alpha (23-5-2017)
=========================
- Added some in-game performance counters. Use the F7 key to toggle on/off
- You can now cycle the texture filtering mode in-game using the F8 key
- Implemented emulation support for MM7/8's software 2D rendering (see: "Software2D" in mmcl.ini)
- Fixed issue where cinematics would not be rendered
- Fixed bug in cursor bitmap updating (e.g, during casting)
- Fixed video memory leak
- Fixed a few issues with windowed mode.
- Optimization that will slightly reduce level load-time


No, compatibility is off.
The problem with mouse look is that game window is at -32000x-32000 coordinates with 160x29 size: https://www.dropbox.com/s/uqvlf8790dif4 ... 0.png?dl=0
This must also be the reason why when you start the game mouse starts at top-left corner rather than center of the screen. With mouse look it also looks up and rotates, I suspect it rotates left.

I noticed that too, and although strange, they're the same metrics irrespective of MMCL being used -- actual tracing of MM7Patch's shows all calls to relevant functions (e.g, GetClientRect) return sane values (http://i.imgur.com/Vs4XMzw.png)

It appears what's actually causing it is the game clips the cursor (ClipCursor) to a 1x1 rect, essentially disabling the system cursor. However, removing clipping it reveals a new issue: it seems your mouse-look is implemented based upon the system cursor (using GetCursorPos and such), but the game's cursor position is based upon [axial-relative] data via DirectInput, thus the game's cursor and system cursor are not synchronized (atleast, that's my theory -- I'm not entirely sure on how you've implemented it as I'm not that familiar with pascal)

The root cause may be that the game appears to have two separate implementations for the cursor itself even; notice that with MMCL there's a seperate thread that's handling DirectInput/the cursor, yet without MMCL, this path is not used and is likely what you've designed MouseLook against. Similarly, with MMCL the game uses a different path for 2D rendering due to the different device caps.

I'll have to look into this some more.

EDIT: OK, the problem is that the game has two implementations for handling mouse-input (and keyboard, apparently) and MMCL is somehow causing it to use the path that uses DInput in a seperate thread (referred to as "asynchronous mouse" in the game binary). Interestingly, In software 3D the game never uses this method (even with MMCL), and mouse-look works fine.
Last edited by Emjayen on May 24 2017, 23:38, edited 10 times in total.

rnicknich
Leprechaun
Leprechaun
Posts: 1
Joined: 24 May 2017

Re: Might & Magic Compatibility Layer (Tool)

Postby rnicknich » May 24 2017, 16:18

Hey, created an account just to thank you for this amazing tool.

I noticed that mouse issue too, where it always goes to the top left corner of the screen. I hope there's a fix for that. But it's good enough to be able to play it on windowed mode already.

Thank you very much Emjayen. Also, a huge thanks to Grayface for the amazing patches. You guys are the best!

Emjayen
Leprechaun
Leprechaun
Posts: 31
Joined: 01 Aug 2013

Re: Might & Magic Compatibility Layer (Tool)

Postby Emjayen » May 25 2017, 1:33

The mouse problem is a known issue and is the current priority to be fixed.

Glad to hear it's helped otherwise :)

User avatar
GrayFace
Archlich
Archlich
Posts: 1102
Joined: 29 Nov 2005

Re: Might & Magic Compatibility Layer (Tool)

Postby GrayFace » May 26 2017, 17:19

Yes, I'm using GetCursorPos/SetCursorPos, I've no knowledge of DirectX. I can look into asyncronous mouse stuff.
[edit] So far I see that dword_DF1A74 is responsible for its activation, but I don't see what could set it to 1, I'll check in debugger.
[edit] It's "D3D Device" setting in the registry. If it's 1, async mouse is used. I'll fix it in my patch. I wonder what they did it for.
[edit] I removed checks for it: https://www.dropbox.com/s/y4oakom2hkttr ... 2.rar?dl=0
Now the cursor isn't drawn, but other problems (mouse look, crash with MMExtension) disappeared.

The old behavior with async mouse can be returned by adding this line to mm7.ini:
DisableAsyncMouse=0
Last edited by GrayFace on May 26 2017, 21:19, edited 11 times in total.
My patches: MM6 MM7 MM8. MMExtension. Tools. Also, I love Knytt Stories and Knytt Underground. I'm also known as sergroj.

Emjayen
Leprechaun
Leprechaun
Posts: 31
Joined: 01 Aug 2013

Re: Might & Magic Compatibility Layer (Tool)

Postby Emjayen » May 26 2017, 22:25

Ah, nice find.

The reason it's crashing with greater resolutions is because the game is also being switched to software-2D mode with your fix, and support for greater resolutions requires the game to use its hardware-2D path.

While trying to fix this myself I managed to produce the exact same behaviour (software2D+system cursor) by exposing MMCL as the default device rather than a separate one -- it makes no sense, and I suspect it's a bug in the game since what controls the game using hardware-2D is the device capabilities reported by DDraw (which makes sense, the game uses hardware if possible, elsewise falls back to software) and I'm still reporting the same capabilities.

Unfortunately supporting software-2D with greater resolutions isn't really practical because it would mean reversing the game's entire 2D software path and patching it so for now I'm still continuing to look for a way to coerce the game into using hardware-2D, but with the system cursor (ie., not async mouse)

EDIT: Note that *2dacceloff*, although probably does refer to this feature, doesn't appear to have any effect whatsoever

EDIT2: You can switch to software-2D via MMCL's Software2D setting; this results in the game using software 2D with async. mouse, so presumably the inverse (hardware-2D, system mouse) is also possible.

Also here's a few relevant addresses (of your mm7.exe version):

0x0049E714 -- game calls IDirectDraw4::GetCaps. The game uses the returned caps to decide on which path to use (software or hardware -2D). I haven't checked which one it uses exactly, but I'm guessing it's hardware color-key support.

0x0043BBCF -- game calls IDirectInput::GetDeviceState. This is the async. mouse path.

Code: Select all


// seperate thread
for(;;)
{
      Sleep(18);
      EnterCriticalSection(..);
      IDirectInput::GetDeviceState(&rel_x, &rel_y); // for brevity; real structure is a bit more complicated
     
      // compute screen coordinates; DInput gives us relative mouse-movement data, not absolute.
      this->cursor_x += rel_x;
      this->cursor_y += rel_y;
     
      LeaveCriticalSection(..);
     
      DrawMouseCursorOnFrameBuffer(this->x, this->y);
     
      // I'm guessing the main game thread just looks at this->x/y for its purposes.
 }
Last edited by Emjayen on May 27 2017, 0:29, edited 5 times in total.

User avatar
GrayFace
Archlich
Archlich
Posts: 1102
Joined: 29 Nov 2005

Re: Might & Magic Compatibility Layer (Tool)

Postby GrayFace » May 27 2017, 2:55

You've probably responded to my previous version of the message. With my last version the game should act as always, just without the async mouse stuff.
Here are 2 instructions that you would need NOP'ed: 4A03F8, 4A09EB. They erase data returned by GetCaps if the async mouse switch is off. Then, I suspect you should be able to use native windowed mode of the game and set the tool as any device.
My patches: MM6 MM7 MM8. MMExtension. Tools. Also, I love Knytt Stories and Knytt Underground. I'm also known as sergroj.


Return to “Might and Magic”

Who is online

Users browsing this forum: Bing [Bot] and 18 guests