FunkyFr3sh / cnc-ddraw

GDI, OpenGL and Direct3D 9 re-implementation of the DirectDraw API for classic 2D games for better compatibility with Windows 2000, XP, Vista, 7, 8, 10, 11, Wine (Linux/macOS/Android) and Virtual Machines
https://discord.gg/afWXJNDDF5
MIT License
2.12k stars 143 forks source link

Maze Controls Not Responding in Nancy Drew: Message in a Haunted Mansion #311

Closed indianajson closed 1 month ago

indianajson commented 1 month ago

Hi again @FunkyFr3sh, you helped me with the #309 (Last Train to Blue Moon Canyon) last week, and I found one more bug in another game in the series, Message in a Haunted Mansion.

At one point in the game the player activates a 3D-esque maze, where movement is controlled by arrow keys (for left right and forward) or left mouse click (for forward). Video for reference: https://www.youtube.com/watch?v=MHIqSdiYxC8.

Without cnc-ddraw: the maze is playable (but the rest of the game is really bad).

With cnc-ddraw: the game plays well but the maze does not respond to forward (up arrow or left mouse), turning right is super slow (right arrow), but turning left is fine (left arrow).

Below is the log file (40mb uncompressed) using the latest debug version from issue #309. For reference, I began logging then: opened the game, loaded the save, clicked to start the maze, pressed up arrow, then left arrow, then right arrow, then left mouse, then right mouse, then exited the game (if that's helpful in reading the log).

cnc-ddraw-1.log.zip

FunkyFr3sh commented 1 month ago

I probably won't be able to fix this one with just debug logs. Could you share your save maybe? I'll try to get the game then

indianajson commented 1 month ago

Here you go. Just paste it in the main game folder, (replacing the one that exists). If it doesn't already exist you may need to boot the game once to generate them.

Once it is in the folder, start the game and it should be in the first save slot under "Load & Save" in the main menu titled "Maze Puzzle Test".

NANSTD0.SAV.zip

indianajson commented 1 month ago

If you need a copy for debugging purposes I can lend you a copy. Just let me know.

FunkyFr3sh commented 1 month ago

I got the game now (download took ages), thanks though

I can reproduce the issue on windows as well. I also seem to have the issue with the cursor being stuck on opengl on normal fullscreen like you had in the other nancy drew game, but it does work with direct3d and/or borderless/windowed. Unfortunately I cannot run the game without cnc-ddraw to see how it would behave there, the cursor is stuck no matter what I do. I'll probably have to try it on a windows XP or linux VM. IT will take some time to get it all set up, so maybe not going to happen today

indianajson commented 1 month ago

Glad you were able to reproduce. And no rush.

Just the fact that you've already taken the time to reproduce it (less than 12 hours since I mentioned the issue) speaks volumes to your passion for maintaining your project. I really appreciate it.

FunkyFr3sh commented 1 month ago

I may have the bug with the maze workarounded (still need to think about a good solution...), but i'm not 100% sure it will work on macOS (AKA Wine). Here's what I have currently:

ddraw.zip

indianajson commented 1 month ago

No success on my end I'm afraid. I have to imagine this is a more complex problem given it's dealing with psuedo-3D.

indianajson commented 1 month ago

Okay, scratch that... I changed the renderer to GDI and the maze works now. It looks.... awful (maybe that's the shader)... but it does work. Is that helpful? (I'm not sure whether to call this fixed since it's failing on OpenGL).

FunkyFr3sh commented 1 month ago

The game sets the priority for the main thread to THREAD_PRIORITY_HIGHEST, this will choke the render and sound threads and it starts to lag hard (skipping frames / sounds). The problem here might be that wine/macOS will handle the threads completely differently and I'll probably have to test this on macOS to fix it

Not sure why it would behave differently on GDI/OpenGL, will have to investigae

FunkyFr3sh commented 1 month ago

Here one with slightly different settings:

ddraw.zip

That one works on windows as well, maybe there's a difference now on macOS with opengl?

indianajson commented 1 month ago

Same issue, works in GDI, but not OpenGL.

There is one other odd symptom in OpenGL. Normally, the game lets you use the cursor to move forward + left and right (if you click and drag you move in that direction. When running OpenGL the click and drag works to turn you left and right, but you don't move forward (the original issue), but it also inverts the rotation (dragging right turns the viewport left and vice versa). I have no idea if that's helpful (or even makes sense now that I read it back) but there it is.

FunkyFr3sh commented 1 month ago

Ah right... I don't have such issues, i can move with up arrow and left mouse just fine on any renderer. Turning left/right is also working correctly. I only had the issue with the slow turning, it was quite laggy (which is fixed now).

I guess this may be a Wine only bug then

indianajson commented 1 month ago

Oh, ugh. Are you thinking this is a cnc-ddraw bug in Wine only or an issue with Wine itself?

FunkyFr3sh commented 1 month ago

I would have guessed that the problem is somehow related to the upscaling (aka borderless mode) and maybe also windowed mode of cnc-ddraw combined with wine. Both have the same issue, right? Does regualr fullscreen work in this game or do you have the same issue as you had in the other nancy drew game where the cursor got stuck?

Only thing that's confusing me now is the fact that GDI seems to work, not sure how that's supposed to be possible. Maybe It's not the upscaling that triggers the bugs

indianajson commented 1 month ago

The cursor still runs to the bottom right corner in fullscreen.

The issue persists in windowed (with original game size), and borderless. I can't test full screen (per above).

indianajson commented 1 month ago

Okay, so here's something (may be totally unrelated), but I'll mention it. All these games have a built in windowed mode, which never seems to work. In this game, if I try to run it I get a similar error to the one we got with the other Nancy Drew game:

InitDirectDraw() - ERROR - GetSurfaceDescr() on pSPrimary: 
dwHeight=0, dwWidth=0, dwBackBufferCount=0,iPitch=0

This happens in all screen modes (fullscreen, windowed, borderless).

I may be grasping at straws here...

FunkyFr3sh commented 1 month ago

Yeah, that will not work, cnc-ddraw doesn't support that (games must be set to fullscreen). But it's a cool idea, I can try to make that somewhat working for testing just to see if it makes any difference

ddraw.zip

indianajson commented 1 month ago

I kind of remember reading that users weren't supposed to use the built-in windowed modes when I first started using cnc-ddraw. I just forgot.

Admittedly, you did make the built-in windowed mode work, but the maze issue still persists.

I keep fooling around with settings in the config, just to see if it's something dumb but to no avail.

indianajson commented 1 month ago

Okay, please hold, I just changed about a dozen settings in the config and it WORKS (admittedly I have rgb555 on so things are freaky).

indianajson commented 1 month ago

So that took forever (changing each setting one by one multiple times), but I figured it out.

If I set my config with limit_bltfast=true and maxgameticks=600 then the maze WORKS and the game seems to be functioning fine outside the maze.

If the maxgameticks is above 900 the maze forward controls will work for a moment then the maze forward controls will stop after a few seconds.

At this point, I don't see any degradation from using these settings, so theoretically this is "fixed", but you may know something about those settings that I don't.

Thoughts?

FunkyFr3sh commented 1 month ago

Nice 👍 That would make sense, the game is running too fast with the opengl renderer and the main loop repeats too often which somehow broke some logic (we will probably never found out what exactly went wrong and where!).

It did not happen with the GDI renderer because it's a lot slower than opengl and it managed to slow down the game without maxgameticks= set

However, for me there is a little side-effect, the cursor isn't that smooth anymore on the Load/Save menu

indianajson commented 1 month ago

Oh weird, you are right. I doesn't do it in the main menu for me, just the Load/Save menu.

Admittedly, this issue is a lot more livable than a game breaking puzzle issue (why would a game designer make a maze puzzle the alternative to a password on a laptop), but the cursor issue is odd.

FunkyFr3sh commented 1 month ago

Yeah, this is better than nothing for now. I can do some more research later. But I fear, there wont be a good solution.

BTW, are you sure 900 is the max value? 1000 would be ideal, it got the least impact on the cursor for me. Note: any value above 1000 does nothing, it would equal to 0 (AKA disabled)

indianajson commented 1 month ago

There might be something between 900 and 925, but anything above 925 causes a freeze in forward movement after a bit. At 1000 the forward controls don't work at all.

FunkyFr3sh commented 1 month ago

Alright, np. I'll just add a preset with 600 for now

FunkyFr3sh commented 1 month ago

Fullscreen is working now as well:

cnc-ddraw.zip

indianajson commented 1 month ago

Hmm, still runs the cursor to the corner for me, but slower, probably because of the max ticks behind lowered? Must be another wine specific issue.

FunkyFr3sh commented 1 month ago

Odd, could you upload me a new debug log? ddraw.zip

indianajson commented 1 month ago

cnc-ddraw-1.log

FunkyFr3sh commented 1 month ago

thanks! it's looking good now, not sure why it would still happen

And yes, I also had the cursor moving towards the bottom right slowly now with the new maxgameticks setting.

I'll have to try it on linux or macOS I guess

indianajson commented 1 month ago

Once again I appreciate your speed, responsiveness, and coming up with a workable solution. It's deeply appreciated. I imagine it was all the fixes you made that allowed the config to become the final step in the solution.

I know you're going to do a bit more investigating, but feel free to close this issue, if you want, since the original problem is "fixed".

FunkyFr3sh commented 1 month ago

Yeah, I'll close it. Confirmed it's working on linux/Windows as well.

The cursor moving part is now also fixed for me on both Windows and Linux (Tried old version, could reproduce the bug) - Not sure what's up with macOS but I may try that later as well