MiSTer-devel / PSX_MiSTer

PSX for MiSTer
GNU General Public License v2.0
207 stars 50 forks source link

Thrasher Presents Skate and Destroy & Dave Mirra Freestyle BMX (NTSC-U) #169

Open mailcty opened 2 years ago

mailcty commented 2 years ago

Issue: Random hangs potentially from music streaming/some form of HPS stressing

Reproduce: Thrasher savestate - Skate inside the ramp over time Dave Mirra Freestyle BMX: Maximum Remix savestate - Apparently harder to reproduce quickly, but traverse around the level over time

Workaround: Set music volume to 0 in main menu or in-game to reduce hangs, or change music in-game to "no track" to eliminate hangs

BIOS: SCPH-101

CD Images: Redump CHDs

Core Version: PSX_unstable_20220719

Video of Thrasher during a casual session Video of Thrasher while loading a savestate with CD Lid Closed & Open Video of Dave Mirra: Maximum Remix during a casual session

mailcty commented 1 year ago

Workaround is much simpler than I initially thought, simply disable the music in either game to reduce random hangs, or at least the hang time.

Either set the music volume to 0 in the main menu audio options: 7-27-22_ThrasherOpts

Or in-game where you should also have the option to play no track: 7-27-22_DMIG

Dave Mirra still manages to hang on me once despite having set the volume prior to loading the level. Though the hang time was at least reduced.

davedoc1984 commented 1 year ago

It freezes for some seconds, then unfreezes for a short time. Then may freeze again but what I noticed was the 3rd time it unfroze it then worked solidly for several minutes so not sure what is happening (Dave Mirra Maximum Remix).

ramapcsx2 commented 1 year ago

I've ran the Mechacon bus sniffer on this game. These "MotorOn" commands are probably meant to be a pause, but hardware just fires an INT5 and moves on. The emulation should do nothing to the drive state in these cases, except return an INT5. The previous ReadN should continue normally. Edit: Oh, and I just spotted that Stat should set bit 0, for the error condition ;)

C:Setloc 02 01 07 <3> 22 C:ReadS <3> 22 hdr :0E 02:01:07:02

<1> 22 hdr :0E 02:01:08:02 <1> 22 hdr :0E 02:01:09:02 <1> 22 hdr :0E 02:01:10:02 <1> 22 hdr :0E 02:01:11:02 <1> 22 hdr :0E 02:01:12:02 <1> 22 hdr :0E 02:01:13:02 <1> 22 hdr :0E 02:01:14:02 <1> 22 C:MotorOn<5> 23 20 hdr :0E 02:01:15:02 <1> 23 hdr :0E 02:01:16:02 <1> 23 hdr :0E 02:01:17:02 <1> 23 hdr :0E 02:01:18:02 <1> 23 hdr :0E 02:01:19:02 <1> 23 hdr :0E 02:01:20:02 <1> 23 hdr :0E 02:01:21:02 <1> 23 hdr :0E 02:01:22:02 <1> 23 C:GetStat<3> 22 hdr :0E 02:01:23:02 C:Setloc 02 01 15 <3> 22 <1> 22 C:ReadN <3> 22 hdr :0E 02:01:24:02 C:Setloc 02 01 15 <3> 42 C:ReadN <3> 42 hdr :0E 02:01:24:02 hdr :2E 02:01:24:02
RobertPeip commented 1 year ago

Are we looking at the same situation? I think the problem on XStation was not happening random ingame?

ramapcsx2 commented 1 year ago

Oh, it's not about xStation. These are just logs that may help troubleshooting the FPGA core. These are the responses the real decoder / mechacons produce for this game. Maybe there are differences to the FPGA :)

RobertPeip commented 1 year ago

I see. Just tested: the core delivers Int5 with response 0x23 0x20 when the motor was already on, so it seems to be correct.

My current assumption is that from all the READN commands, one of them is ignoring the seek due to a race condition in the core and it continues to read data rom the old position instead. This would explain why it happens totally random and is independent of seek or read speed.

ramapcsx2 commented 1 year ago

I fear something similar can happen on xStation, in case when the Mechacon misses the intended set location somehow. I've had a report of this game freezing when loading a level, on the current xStation firmware, and this generally bad CD code might somehow trigger it.

For the FPGA higher level emulation, maybe try tracking what you send before and after receiving a new SetLoc+ReadN. If the new location is 0 to maybe 4 LBA ahead of the current location, there will be no seek event. The Mechacon waits until the sector arrives. If the new location is behind the current location, there must be a seek to reach it. In this case, the seek setup takes some time, while still new sectors arrive (and the current location still increases). Eventually it'll do the seek, the data in the buffer goes bad, and sometime later, the new location data arrives. Whenever this backward seeking is in progress, it seems that this game's code is silly, and issues repeated SetLoc+ReadN to the wanted location. The extra requests should be mostly ignored, except for some minor side effects (such as taking Mechacon CPU time to process, and the reply flags). Good luck! :)

mailcty commented 1 year ago

Haven't been getting any random hangs with music enabled in-game on both Thrasher and Dave Mirra: Maximum Remix as of the latest stable build (20221023), seems this has been resolved

RobertPeip commented 1 year ago

Seems to happen randomly (again?) in Dave mirra

edit: retestet by PompPenguin on discord to be fine in 20221023. Need to find out which change broke it....

Kuba-J commented 1 year ago

for information only, no change in core 20230120