hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
11.07k stars 2.16k forks source link

Danganronpa bug #1686

Closed CPkmn closed 11 years ago

CPkmn commented 11 years ago

I tried a search in the issues here to see if anyone reported this yet, but it seems no one did.

While playing Danganronpa (both the demo and the full release) in PPSSPP I noticed objects are not interactable. This basically makes the game unplayable since the requires object interaction on many occasions. I notice the same issue on JPCSP, however the software rendering mode in JPCSP works with the objects (and has since at least revision 2450, the first software rendering public release; https://code.google.com/p/jpcsp/source/detail?r=2450). Unfortunately I can't check earlier releases' software rendering modes since I don't know how to compile JPCSP.

I'll attach a picture of what PPSSPP and JPCSP (in software rendering mode) get when hovering over a should-be-interactable object.

(JPCSP in software rendering mode) danganronpa_correct

(PPSSPP) danganronpa_wrong

hrydgard commented 11 years ago

I bet it reads pixels using the CPU to figure out what's under the cursor, or something like that. Hard to emulate without readbacks at just the right moment or software rendering.

CPkmn commented 11 years ago

I noticed something else interesting :

When you use software rendering in JPCSP, then switch out of software rendering, the objects are detectable.

danganronpa_correct_nonsw

This makes the graphics nicer, however every time a scene comes up this would need to be done (which would be annoying)

sum2012 commented 11 years ago

@CPkmn I have a post of this game https://github.com/hrydgard/ppsspp/issues/844 edit:I don't need to enable software rendering.Leave all setting blank.I am using Nvidia card

CPkmn commented 11 years ago

@sum2012 thanks. I did some testing after hearing that.

I noticed when changing some options, more specifically the "Save GE screen to Textures instead of Memory" needed to be turned off in order to emulate the cursor correctly (other options didn't affect the cursor issue). Would it be possible to save the GE screen to Memory in PPSSPP? Just curious.

unknownbrackets commented 11 years ago

It may be possible using e.g. glReadPixels. That's #618. Doing it too often could cripple performance.

-[Unknown]

HermitCrap commented 11 years ago

Is there a way to fix this? Or is it possible to make a beta version with the glReadPixels and test it out since the newer versions of PPSSPP is now pretty stable? The performance is also pretty good, maxed out settings getting 60VPS thought I disable them all as there are graphical glitches in some other games except for V-Sync to prevent tearing. I referring to turning off the "Save GE screen to Textures instead of Memory" for the beta inclusion of course.

CPkmn commented 11 years ago

Actually there is something interesting about this case.

PPSSPP works for Danganronpa's Nonstop Debates (demo and full version), but not when investigating/exploring.

Yes, the GE screen->Memory (disabling save GE screen to Textures) seems to be the solution. I would work on implementing that, but I'm not exactly sure where it would go in PPSSPP's coding. I know where to find it in JPCSP's coding though.

Just started a nonstop debate in PPSSPP on the full version ~

danganronpa_debate_begin

(Don't mind the red square; I don't want to spoil who died since there will probably be many new players because the translation was very recently released)

HermitCrap commented 11 years ago

LOL, I accidentally spoil myself with who the mastermind is even before I played the game when I was reading the player profiles on the wikia -_- Will take a look at the source and continue the talk in thread #618.

ghost commented 11 years ago

For the Nonstop Debates, I think the game uses its own rectangular hitboxes. After all, it's possible for the user to fire the bullet at a small crevice in the middle of the text glyphs, and I believe that that counts as a hit.

HermitCrap commented 11 years ago

I believe it's more like an entity. Like an enemy in a game that will interact with you unlike the investigation which uses "pixel detection" since it's part of the background. Since the words will move around in the debate unlike the items which stay in place like the background or doors etc thus being unable to interact as well. The only way to fix it is to implement #618.

arnastia commented 11 years ago

I took a stab at this and I seemingly managed to fix the problem basically by calling glReadPixels whenever a framebuffer object was either displayed (in FramebufferManager::CopyDisplayToOutput()) or switched for a new one for rendering (in FramebufferManager::SetRenderFrameBuffer(); Danganronpa draws a certain FBO every frame but never actually displays it) and Memcpy'ing the results to the address the game expects them to be in. Since just calling glReadPixels won't yield the correct results when the user's playing in a larger render resolution, whenever needed I use a separate, native resolution FBO blit'd with glBlitFramebuffer to resize the render and get glReadPixels to return the correct data (well, likely not as correct as if it were originally rendered 1x, but at least for 2x linear filtering seems close enough).

While I didn't really try to measure it, I have a feeling this did have a slightly noticeable negative impact on performance (just doesn't seem to flow as nicely?). Framerate-wise the game seems completely playable, though I only tried it on a fairly decent desktop PC. Eitherway, this is a hackish fix, but should keep folks wanting to play the translation happy.

I didn't post this in #618 for now since though the end problem is the same, the approach I took is slightly different because Danganronpa doesn't call sceDmacMemcpy.

I'll get around to pushing the branch online tomorrow, since it's fairly late here right now.

Other than this, the game seems to have two other problems, that would probably be better off on different issues, but I'll just list them briefly here:

HermitCrap commented 11 years ago

I believe the voice problem is an issue with the atrac3+ plugin as the sound in other games that require it sounds horrendous. This problem can be ignored for now until someone comes up with a better atrac3+ option since the Devs do not want to use the current plugin. The displayed message is fixed for me when I enable buffered rendering for some reason. I only get them when I fast forward it to unlimited, I would then have to rest the game for it to work. Looking forward to your build, I shall test them for you as well. Cheers! :)

unknownbrackets commented 11 years ago

Copying to memory all the time is definitely gonna have a performance impact. I think we need to find a smarter method.

The gibberish is the texture cache. It corrects itself, and notes that those textures are "annoying." There might be options to improve its detection.

I think this game also uses that atrac context thing, so it will probably be helped when Sol Trigger et al are.

-[Unknown]

CPkmn commented 11 years ago

@unknownbrackets The game does use _sceAtracGetContextAddress for its voices. Interestingly, I notice some values JPCSP sets in memory during _sceAtracGetContextAddress that PPSSPP doesn't yet. I was thinking of getting around to checking them out soon, but I haven't missed any voices while playing the debates in the demo and full version so far (although the voice volume is a little lower than it should be - that might just be my problem though since I don't use the same sceAtrac as you guys anymore).

HermitCrap commented 11 years ago

@CPkmn, Can you tell me how to get the custom sceAtrac you got? I think it's alright if it is soft as most Android device can't handle the extreme loudness of most game, Oreimo give my speaker tearing to the point I stop playing it. Playing it on the PC on the other hand is alright. Still, I rather have working sound than loud sound.

@unknownbrackets, I think it's alright to retain this idea for now right? At least for experimental PC builds since most texture in 3D games also save their Graphics to VRAM. I think it will only affect the performance on Android device. Since the above method only works ideally when on 1x Rendering Size, I believe the performance won't be too big. Maybe you could try implementing it and experiment with it? Since this can fix some games at the moment.

hrydgard commented 11 years ago

If copying to memory every frame is what it takes, then we might just have to do it. It will probably make things unplayable on many mobile devices so we might have to do it as a per-game option, when I add support for that...

fagoatse commented 11 years ago

It could be implemeneted as a hack. However, if this function is used extensively in many games, a multithreaded software renderer like in pcsx2 would solve majorty of gfx issues and would be fast enough on modern x86 cpus. Displaying at the native resolution only isnt much of drawback either as there are many 2D games or games that scale poorly(3D on 2D background etc).

CPkmn commented 11 years ago

@HermitCrap I've been working on modifying things in my local copy for about a month now; you can't find it anywhere since I haven't released it, nor should you guys need my local copy since there is already a working version in the master. I just prefer mine is all.

Anyways, what I mean by "I don't miss any voices" is all voices have played for me so far, and just about all of them play fully, but a select few cut off a few words early (but they do play).

Also, I tried implementing memory writes in _sceAtracGetContextAddress according to JPCSP but I didn't notice anything different.

hrydgard commented 11 years ago

@fagoatse yes, adding a software renderer is also solution that will work, although that's a lot more work than glreadpixels and an extra fbo.

HermitCrap commented 11 years ago

@CPkmn, For me, It's when I skip a dialogue, the voice just stop playing for the whole game until I reset even for the master version. I think you should consider implementing your copy as the main for the coming release :P Software rendering will make games like Dangan Ronpa work and not suffer so much for Android device. But I still think that implementing this for experimenting should be a good idea just for the PC and Super Duper High Sch... End Device! The best way to do this now is to either make a per-game option or a GE Profiler now.

CPkmn commented 11 years ago

@HermitCrap you mean like if you press X in the middle of the sentence, no more voices will play? Anyways, I have no intention of committing my modifications of sceAtrac (at least, not the majority of them). Most of what I've done no longer applies to the master since I don't use Mai's AT3+ decoder.

HermitCrap commented 11 years ago

@CPkmn, Yeah, that's what I meant. How did you get the sounds to work without the decoder? SoundSonic? Mai's AT3+ Decoder is pretty buggy. Seems like I just gotta wait for someone to make another from the source and not Whitebox Reverse Engineer it.

CPkmn commented 11 years ago

@HermitCrap Mine works perfectly when I do that. I have a special trick for decoding my atrac3(+) sounds, but like I said, mine isn't the same as the master. Some of the methods I use have either been removed or have changed in the master while I was working on mine.

HermitCrap commented 11 years ago

@CPkmn, can you upload your copy of the source to your PPSSPP Repository/fork or make a pull request to Hrydgard's repo? I your coding for the sound will be beneficial to the devs and users since Mai's decoder is rather unreliable.

CPkmn commented 11 years ago

@HermitCrap You mean my version of sceAtrac, right? I can't pull request my copy of the game (and, well, it would be illegal if I did). The version I've been working on may be better for some things, but I only intended it to be personal - that is, the code doesn't contain comments (or, nothing besides the ones left originally) and is sorta messy. I'm not interested in having a lot of questions to answer if I was to send a pull request with it (and I'm sure there would be questions upon being reviewed). I don't see it as a priority since you guys already have a way to listen to sceAtrac music. :p

Also, I just added arnastia's fix to my local copy and I can confirm it works.

fbo_fix I don't notice any lag either.

lKomus commented 11 years ago

Using PPSSPP 0.8.1-37 with framebuffer with memory on, I can examine items in Investigation Mode, but not all the items you examine are the right ones, like you want to examine the drawer but you end examining a lint roller. This prevents progression very early in the game in chapter 1 where you must examine everything in your room, but no matter what you do, you can't examine your drawer.

Link for the save : http://www.mediafire.com/?mjzbhfdvrecycu2

arnastia commented 11 years ago

Well, I know you can get past that because some people I compiled the code for before I even pushed it here had already got out of the room. I'm writing some changes to the code, but I tried your save right now and on my version I can examine the drawer.

What I'm guessing can happen is the blitting of the framebuffer to a smaller resolution giving edges weird values because of the filtering, which should only happen if you were playing at 2x or above render resolution. Try to either play at 1x render resolution when that happens or maybe just change the viewing angle or position of the cursor a little.

Zindolence commented 11 years ago

I'm encountering the same problem as lKomus (as well as several other people from various forums). I tried to play at 1x render resolution, then disabled every option in graphics save for buffered rendering (since it's required for your fix), and finally tried V-sync on. None of those worked, and I reloaded my save before each try. I deactivated anti-aliasing/anisotropic filtering/texture scaling as well.

On top of the room IKomus mentioned, I met another instance where the locations of items were wrongly swapped. In the prologue, after the first classroom, when you're in the hallway trying to enter the toilet doors will point to wrong locations. About the investigation part with the drawer sending you to the lint roller : changing the camera angle unfortunately doesn't help. I even tried to point the cursor everywhere on the screen, including blank spaces, but the game never seems to find the drawer. I haven't gone further than chapter 1 but there might probably be other similar instances. The same bug happened on JPCSP as well, and temporarily switching to software rendering was the only solution.

If that is of any indication, I am using rev v0.8.1-41-ge440fa6 on Win8 64Bit, with an AMD HD7850 video card and an i3 3220 processor. I'm suspecting this bug might have to do with hardware since some people are unaffected.

HermitCrap commented 11 years ago

@Zindolence, this problem seems to be with AMD cards though I'm not really sure. The only workaround is like what arnastia said, play the game in 1x resolution.

Zindolence commented 11 years ago

As I mentioned, I tried that and it doesn't fix the problem. I even started a new game (with 1x render res without texture scaling) and skipped everything until the bugged parts to be absolutely sure.

HermitCrap commented 11 years ago

I will try it on both AMD and Nvidia and confirm whether it's just a problem with AMD Cards.

lKomus commented 11 years ago

I do have an AMD card, an ATI Mobility HD Radeon 5850M. Still not working at 1x render resolution even by mixing some graphical options. It's a shame if it's related to the AMD Drivers.

HermitCrap commented 11 years ago

I don't know how you guys can even get to interact with the options but the newest few dev builds doesn't work for. Interaction doesn't work, have to rely on a build uploaded on the translation site in the comments. That worked for me, the translators think that it is related to AMD Cards.

lKomus commented 11 years ago

You must set "FramebuffersToMem = True" in ppsspp.ini.

solarmystic commented 11 years ago

@HermitCrap

Also. use your machine equipped with a NVIDIA card to try it out. AMD cards apparently have issues even with this fix. Crappy AMD OGL drivers are to blame.

HermitCrap commented 11 years ago

@lKomus, so Hrydgard really add the option to turn it on like I requested. Was wondering why I can't find it :P @solarmystic, am gonna try it now.

HermitCrap commented 11 years ago

The game worked flawlessly on my Nvidia Machine, the doors are mapped correctly, lint roller to lint roller. Shall try it with my AMD Build later since my brother is using it now.

HermitCrap commented 11 years ago

AMD Card have that issue. It appears that the bug where the items are switched all over the place only happens on an AMD Computer. There is no way to check if Android will work since you can't turn on buffering to memory.

lKomus commented 11 years ago

I wonder if something like this can even be fixed for AMD cards, it's not the emulator's fault.

HermitCrap commented 11 years ago

Then I guess people should get up and just get a PSP to play this game :P

solarmystic commented 11 years ago

Add this game to a list of games unplayable on AMD's cards thanks to the their crappy OpenGL driver support.

That makes it 2 games now, this game and Final Fantasy IV The Complete Collection (BR OFF and still no text displayed, while NVIDIA cards get text displayed when BR is OFF https://github.com/hrydgard/ppsspp/issues/2018)

Perhaps I should make a new topic in the forums for this.

EDIT:- Tekken 6 is another one. Really horrible performance on AMD/ATI cards plus constant freezes when punches and kicks are connected with the opponent, unless you disable Hardware Transform.

That's right, turning Hardware Transform OFF in Tekken 6 actually improves performance(!) for AMD cards.

NVIDIA cards fly in that game, even with HT on.

HermitCrap commented 11 years ago

It's not exactly unplayable, please do mention only AMD cards can't play it. I believe there is a way to fix it, and it is to edit the OpenGL itself or look for better driver support.

HermitCrap commented 11 years ago

I believe the only way to fix this for now is to include DirectX support as an alternate renderer. Anyone think it's possible?

solarmystic commented 11 years ago

@HermitCrap

There was a suggestion in the builds section of the forum to incorporate a DX Renderer.

http://forums.ppsspp.org/showthread.php?tid=2399

No one's stepped up to the plate as of yet. It seems to be on the lowest of priorities now, since it's only really useful on Windows, and this is pretty much a crossplatform emulator which is why OGL was used in the first place. (Since mobiles can only really use OGL ES at the moment.)

HermitCrap commented 11 years ago

Yeah, but since OpenGL will give problems for AMD users which is also a significant amount of users and that frame buffering to memory doesn't work for Android. I think incorporating a DX Renderer as an alternative for PC will be a good move for PPSSPP Devs as it means it will eliminate some problems.

One question, if DirectX is not included. Why do we need DXSDK to compile the source? O.o

solarmystic commented 11 years ago

@HermitCrap

Native 360 controller (Xinput) and Dinput support. Amongst other things, I think.

A DirectX redist and VC++ redist installation is pretty much mandatory to run the emulator in the first place for the end user..

HermitCrap commented 11 years ago

@solarmystic, I saw this post in the forum "http://forums.ppsspp.org/showthread.php?tid=3289". Do you know how to install this "QindieGL"? I would like to try this and see if it works for me.

Ohhh... That explains it.

lKomus commented 11 years ago

From the qIndieGL site it seems not all functions of OpenGL are supported including glReadPixels that is partially supported.

fagoatse commented 11 years ago

I dont think any wrapper will work correctly. Has anybody tested intel's iGPUs such as hd 2000 and onwards? They are probably broken as well(unless intel got their shit together). There's a universal solution in the works right now btw - https://github.com/neobrain/ppsspp/commits/softgpu

HermitCrap commented 11 years ago

I believe what it does is that it "emulates" a GPU, I'm not really sure. But if it's really an universal solution, then we can consider it as a "software renderer" or he needs to support it for all GPU.