thpatch / thcrap-tsa

Basic thcrap patches maintained by the Touhou Patch Center developers
https://www.thpatch.net
23 stars 13 forks source link

base_tsa: Fix crash after Ctrl-Alt-Del in all games since th11 #1

Closed nmlgc closed 6 years ago

nmlgc commented 10 years ago

This seems to be a rather common issue among Windows applications in general, as I've also encountered it with DOSBox and Neko Project II. Maybe these are just GPU hardware or driver issues on my end?

DankRank commented 7 years ago

A while ago I've tried to fix this bug, but I didn't succeed. My guess was that the game doesn't handle lost devices the right way. It seems like the game indeed doesn't do it properly, but it isn't a problem most of the time, because modern versions of d3d9 don't lose device when you alt-tab or alt-enter, etc. It still happens, however, when you do win+L or ctrl+alt+del. That's not the actual reason though, after applying my fix, the game still crashes somewhere around texture (re)initialization.

One thing I haven't got around to test is wether or not the game will crash under XP (with original d3d9 installed) when alt-tabbing from full screen.

Here's the aforementioned fix: DankRank/thcrap@42e7b152 The BP_devicelost is supposed to replace a call to IDirect3DDevice9::Reset.

p.s. Everything I mention applies to LoLK, as I haven't looked at the other games (except DDC), but I'd assume that the problem is same. p.p.s. I will post relevant memory locations for LoLK (and maybe DDC, if I still have those saved) later.

DankRank commented 7 years ago

Found my old stuff for LoLK v1.00b

stack trace:

0044F349 - crash happens here (inside sub_44F300)
called at 00472981 (inside sub_472940)
called at 00472913 (inside sub_472790)
called at 00471AB7 (inside sub_471340, looks like WinMain)

Patch for the BP_devicelost, mentioned in previous post. th15.js

{
    "breakpoints": {
        "devicelost": {
            "cavesize": "5"
        }
    }
}

th15.v1.00b.js

{
    "breakpoints":{
        "devicelost":{
            "addr": "Rx72972"
        }
    }
}
DankRank commented 7 years ago

2edbcc1be066cc2259c928e3cbe5cee4fde6bff6 fixes this for all latest versions

DankRank commented 7 years ago

Reopening, since the fix doesn't work on all machines apparently.

DankRank commented 7 years ago

Should be fixed as of thpatch/thcrap@cb3404cdd

UPD: that fix breaks switching between fullscreen and windowed for some reason.

DankRank commented 6 years ago

Fixed the fullscreen switching in thpatch/thcrap@c807a61ba0

Works on my machine, stops working on @nmlgc 's machine after switching fullscreen to window. (UPD2: because his drivers are trash)

UPD: [11:13 PM] Nmlgc: Next problem: F10 to cycle between the modes doesn't work anymore in TH11-TH13. Simply continues rendering in 640×480 fullscreen on the first monitor and shows a black window in the active window on the second monitor.

UPD2: disregard that.

nmlgc commented 6 years ago

Turned out to be a graphics driver issue on my end, and no remaining bugs in here after all.

In case anyone else has a similar issue with a AMD Radeon GPU (R7 260X in my case): TH14 and later used to not be displayed correctly in fullscreen mode. On startup, the screen flashed for a few seconds as Direct3D tried to change the display mode and failed. After that, the game was rendered at its native resolution in the top-left corner of my first monitor, with the rest of the screen filled with black, like this:

th14_046

The fix: Catalyst Control Center → My Digital Flat-Planels → (the display Touhou appears on) → Image Scaling Prefences → Disable GPU up-scaling. th14 amd fullscreen bug culprit