Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Super Robot Taisen Gaiden - Masou Kishin - The Lord of Elemental crashes Snes9x #316

Closed
ImSpecial opened this issue May 30, 2018 · 27 comments

Comments

@ImSpecial
Copy link

Super Robot Taisen Gaiden - Masou Kishin - The Lord of Elemental (Japan)
Snes9x 1.55 (OV's test build 05-24-2018)
Windows 10 64-bit

During the intro sequence before the first mission the emulator just locks up.

Not sure what else to add. :/

@OV2
Copy link
Collaborator

OV2 commented May 30, 2018

Seems to no longer be an issue in the latest git.

@OV2 OV2 closed this as completed May 30, 2018
@ImSpecial
Copy link
Author

Just grabbed the latest off of EmuCR and it still happens.

https://i.imgur.com/VBqj6j8.png

And with a clean Snes9x.ini

https://i.imgur.com/pTGGYtI.png

@OV2
Copy link
Collaborator

OV2 commented May 30, 2018

You can try the most recent automatic appveyor build: https://ci.appveyor.com/project/snes9x/snes9x

I'll make a new testbuild soon.

@ImSpecial
Copy link
Author

ImSpecial commented May 30, 2018

Yeah same thing unfortunately.

https://i.imgur.com/2PbaEAx.png

EDIT: Also verified the rom, it seems good.

Super Robot Taisen Gaiden - Masou Kishin - The Lord of Elemental (J).smc
EBADC924
680EE04AF6792C3891947B43B98EED46
3FA8B1EDEB9A42916A1B59634D7EEAC0A5B26966

@bearoso
Copy link
Collaborator

bearoso commented May 30, 2018

I'm using the same rom image and it works. On GTK+ port, at least.

@ImSpecial
Copy link
Author

ImSpecial commented May 30, 2018

For what its worth, I wasn't able to get it to crash with higan_v106-windows
EDIT: and seems to works fine with v1.55, so a regression somewhere, sometime happened...

@OV2
Copy link
Collaborator

OV2 commented May 30, 2018

I can't even get it to crash with the emucr build. How are you triggering it? Are you just pressing A until you get there? Do you let it idle somewhere?

@bearoso
Copy link
Collaborator

bearoso commented May 30, 2018

I'm not even getting a crash with the new translation patch.

@bearoso
Copy link
Collaborator

bearoso commented May 30, 2018

I notice in his screenshots that the whole program is unresponsive. Maybe something to do with syncing spinlocking again?

@ImSpecial: Try turning off sound syncing and/or the automatic input rate box and see if it still locks up.

@ImSpecial
Copy link
Author

I should say that it happens "sometimes". I have gotten past this part before, but the crash seems to happen very regularly, it might be turbo related? Like, as I'm testing and reproducing this over and over again, I just hold down the turbo key to get to this part. I can make a Save state right before, and sometimes get past it, sometimes it locks, it's like a 50/50.

All I can say is maybe try several times.

@ImSpecial
Copy link
Author

ImSpecial commented May 30, 2018

I've tried with both sound syncing on/off and made no difference, not sure what " automatic input rate " is...

@bearoso
Copy link
Collaborator

bearoso commented May 30, 2018

No cheats enabled, either?

@ImSpecial
Copy link
Author

Nope, happens with a clean snes.conf file too, also I'm not alone so it's nice knowing I'm not crazy here.

@bearoso
Copy link
Collaborator

bearoso commented May 30, 2018

Ok, I reproduced it on windows using a release build, but couldn't on a debug build. That's not good, because it might be the optimizer screwing with things.

@bearoso bearoso reopened this May 30, 2018
@ghost
Copy link

ghost commented May 30, 2018

Just tried it on Snes9x 1.55-171 Dev Build May 30 2018 appveyor no crash

Hmm no crash on release 1.55 either.

Using WIndows in OPEN GL and D3D

@bearoso
Copy link
Collaborator

bearoso commented May 30, 2018

I've already reproduced the crash numerous times. It's temperamental and dependent on compiler. I'm trying to track it down.

@ghost
Copy link

ghost commented May 30, 2018

i see that you have im saying these two builds dont so maybe that helps i dunno :)

@bearoso
Copy link
Collaborator

bearoso commented May 30, 2018

I've tried that build, too. It still crashes. It's random: if you can run through it 5 times or more with no crashes, then it's probably ok.

@bearoso
Copy link
Collaborator

bearoso commented May 30, 2018

Tracked it down to 3553650, the Speedy Gonzales commit. For some bizarre reason, this coupled with enabling optimization causes the crash. Only on Visual Studio. With gcc and clang on Linux it's fine.

@OV2
Copy link
Collaborator

OV2 commented May 30, 2018

I've tried the latest git about 20 times and only got the crash once, so I guess it's somehow timing related?

@bearoso
Copy link
Collaborator

bearoso commented May 30, 2018

I was guessing more like uninitialized memory being used. But I don't know why that commit would cause it.

@bearoso
Copy link
Collaborator

bearoso commented May 30, 2018

But the uninitialized memory thing does fit with the debug/release discrepancy.

@bearoso
Copy link
Collaborator

bearoso commented May 30, 2018

Should be fixed now. No idea why the VS optimization broke it. I moved the openbus set to the last register Speedy writes during HDMA, 212D, since we know that because Speedy does it that the hardware does it, too. It's very likely that having all PPU writes go through OpenBus was wrong, so this is a better fix.

@bearoso bearoso closed this as completed May 30, 2018
@ImSpecial
Copy link
Author

Using the latest appveyor build, I gave the intro probably a good 10 run-throughs and was not able to get it to lockup once, so I'm thinking you got this bug fixed.

@bearoso
Copy link
Collaborator

bearoso commented May 30, 2018

One can only hope so. :-)

@OV2
Copy link
Collaborator

OV2 commented May 31, 2018

I think I've found the root issue in S9xGetWord:
return (OpenBus | (S9xGetByte(a.xPBPC) << 8));

Bitwise or does not specify an evaluation order, and MSVC will reorder it to this:

00000001400612CE  mov         ecx,dword ptr [a]  
00000001400612D2  call        S9xGetByte (0140060BE0h)  
00000001400612D7  movzx       ecx,al  
00000001400612DA  movzx       eax,byte ptr [OpenBus (01405AEED3h)]  
00000001400612E1  shl         ecx,8  
00000001400612E4  or          ax,cx  

This causes problems when OpenBus changes during S9xGetByte, in this instance when HDMA triggers and S9xSetPPU runs. Looks like this:

$00:91C3 7C E1 9F    JMP ($9FE1,x)[$00:9FB0] A:001E X:001E Y:0000 D:0000 DB:01 S:0374 P:envmxdizc HC:1068 VC:163 FC:56   V .    HT:10 VT:223 C:81850
*** HDMA Transfer HC:1108, Channel:60
--- HDMA PPU 2132 -> 80
--- HDMA PPU 2132 -> 40
--- HDMA PPU 2132 -> 20
$00:9F20 1F 00 49 1F ORA $1F4900,x[$1F:491E] A:001E X:001E Y:0000 D:0000 DB:01 S:0374 P:envmxdizc HC:1166 VC:163 FC:56   V .    HT:10 VT:223 C:81850
$00:9F24 00 1A       BRK #$1A                A:1F1F X:001E Y:0000 D:0000 DB:01 S:0374 P:envmxdizc HC:1210 VC:163 FC:56   V .    HT:10 VT:223 C:81850
*** BRK
$00:E875 78          SEI                     A:1F1F X:001E Y:0000 D:0000 DB:01 S:0370 P:envmxdIzc HC:1274 VC:163 FC:56   V .    HT:10 VT:223 C:81850
$00:E876 DB          STP                     A:1F1F X:001E Y:0000 D:0000 DB:01 S:0370 P:envmxdIzc HC:1288 VC:163 FC:56   V .    HT:10 VT:223 C:81850

(address discrepancy between the disassembly of JMP and the next command)

The lockup is then because it runs into an STP command, in which case we no longer leave the main loop unless we're in DEBUGGER mode. Should we maybe add DEBUG_MODE_FLAG as a break condition even in regular mode?

@bearoso
Copy link
Collaborator

bearoso commented May 31, 2018

Should we maybe add DEBUG_MODE_FLAG as a break condition even in regular mode?

Probably. I don't imagine a state where we never return from S9xMainLoop is ever a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants