Provenance-Emu / Provenance

iOS & tvOS multi-emulator frontend, supporting various Atari, Bandai, NEC, Nintendo, Sega, SNK and Sony console systems… Get Started: https://wiki.provenance-emu.com |
https://provenance-emu.com
Other
5.97k stars 689 forks source link

Add support for Playstation 1 games #58

Closed XeresRazor closed 6 years ago

XeresRazor commented 9 years ago

Add support for Playstation 1 titles to Provenance.

mathewrennie commented 7 years ago

@JoeMatt The speed values are being messed up by the Master Clock references within OpenEmu coding. Using the branch from @msikma I removed the Master Clock coding and the PSX games ran at full speed on load. Your coding is a bit more complicated to go through as you've added further support in the MednafenGameCore.mm file for other emulators.

Hopefully though it will help you to go over your code and resolve the issue.

mathewrennie commented 7 years ago

@JoeMatt It does seem to be the Master Clock is the issue, I've went through your coding and removed references and PSX games load at normal speed. I'm now working on tidying up some loose coding for aspect ratio. Once completed I will upload code to GitHub for others to mess around with. Regards.

mathewrennie commented 7 years ago

Ok, so I've uploaded my version to GitHub for those to mess around with, I've modified the upload server to help newbies understand the way's to upload PSX roms.

https://github.com/mathewrennie/Provenance-galnet-mednafen

Fixes I've Made Include:

  1. Crash when opening up another PSX game after closing another one down.
  2. Speed Load, Games now load in at normal speed.
  3. Fixed issue with aspect ratio.

I've not tested any of the other emulators which @JoeMatt had added to his repo, so please don't shout at me if these aren't running correctly.

Let me know if you have any issues, and would be happy to help others in coding should they have issues. Let's make Provenance one of the best emulators around from the Apple TV 4.

MonkeyInitiatives commented 7 years ago

@mathewrennie Hi there. I tried your version but I'm running into strange issues. I'll note that I'm not using it on an Apple TV 4, but a 9.7 iPad Pro.

  1. I haven't had any crashes when switching between PSX games, so that seems to be working for me.
  2. Game speed still doesn't work correctly for me. In JoeMatt's version, once I switched to normal after loading a PSX game, it would run fine. Your version doesn't run smooth, and I get a lot of stuttering in video and sound effects; everything progressively gets slower as time goes on and the sound stuttering does not improve even when switching between game speeds. "Normal" never runs at normal speed, always slow and stuttering.
  3. The aspect ratio has been fixed for all non-PSX games now, but PSX games are shifted to the right and not centered. I wonder if this is because the iPad's screen is 4:3 while the TV is 16:9? Basically, it's the inverse of the problem I mentioned earlier in JoeMatt's version. His shifted every thing to the left except PSX games which were centered while yours shifts everything to the right, making every thing centered except PSX games which are now cut off on the right.

Are the other emulators, like NES/SNES/SegaCD, all assuming a 4:3 display and that's why they display correctly while Madnafen assumes a 16:9 and so it works correctly for Apple TV but not iPads?

Hope all of that makes sense. I can post screenshots of the resolution issues on an iPad if it would help. The bizarre thing is the game speed is worse now for me, as changing the speed doesn't get a normal speed and it is now stuttering on every PSX game I've tried.

Oh, and one last thing that applies to both yours and JoeMatt's version: my MFI controller always switches to player 2 after starting a PSX game. It doesn't cause any problems, but I've noticed this is a consistent thing and don't know how it would affect 2 player games or something like Metal Gear Solid.

Edit: To anyone, how do you determine which core or emulator is running? Looking at the code, I assume I could just add an if statement in the PVGLViewController.m that is basically:

if running mednafen use @JoeMatt's vertices/coordinates/code in - (void)glkView:(GLKView )view drawInRect:(CGRect)rect else use @mathewrennie's code in - (void)glkView:(GLKView )view drawInRect:(CGRect)rect

JoeMatt commented 7 years ago

@mathewrennie If you did a GitHub fork instead of an upload as a new project, I could actully see your diffs. As of right now I don't know what the changes are. If you tell me what the changes are to prevent crash on reload, I'll add them into my branch.

I have a fix for the runspeed and it's nothing that's mentioned here. I has to due with mednafenCoreTiming variable changing on each frame around 60 frames, but sometimes more, sometimes less. That variable is used to set the framerate, which is used to calculate gameInterval, which is used to determine if the game loop thread should sleep. Either it's a race condition on startup when the value is read, or it's something else related. The simple fix seems to be to just hardcode the frame frame to 60. I'm testing if that effects the other systems in Mednafen and then push that change.

JoeMatt commented 7 years ago

Branch is updated. I fixed both the stutter issue and the crash on reload.

That just leaves the aspect ratio stuff. This has to be changed system by system in the core so it's not as easy as an if/mednafen fix. I'll try to take a look sooner than later. It's not difficult, it just takes time to implement it right.

edit: Crash on reload is still there, just in a different spot it's crashing now. I dunno, I'll look at it some other time. Too much work to do right now.

MonkeyInitiatives commented 7 years ago

I did a restore and was able to get things working properly again. Don't know why I was having so many issues this time, but the restore from backup after deleting the app worked.

Speed does work fine now at start. Yeah, the crash on reload is still there but that's minor. Things are looking pretty good.

It makes sense that a if/mednafen fix would probably not be the greatest, but I figured I would give it a shot until someone else did a proper fix; this now works fine for me (except the boot of PSX is still offset, but once you get in the game it looks fine). I changed things in (void)glkView:(GLKView *)view drawInRect:(CGRect)rect PVGLViewController.m

NSString* checkCore = self.emulatorCore.systemIdentifier;
if ([checkCore isEqualToString:@"com.provenance.psx"]) {
    vertices[0] = GLKVector3Make(-1.2, -1.0,  1.0); // Left  bottom
    vertices[1] = GLKVector3Make( 1.0, -1.0,  1.0); // Right bottom
    vertices[2] = GLKVector3Make( 1.0,  1.0,  1.0); // Right top
    vertices[3] = GLKVector3Make(-1.2,  1.0,  1.0); // Left  top

    textureCoordinates[0] = GLKVector2Make(0.0f, texHeight); // Left bottom
    textureCoordinates[1] = GLKVector2Make(texWidth*1.1f, texHeight); // Right bottom
    textureCoordinates[2] = GLKVector2Make(texWidth*1.1f, 0.0f); // Right top
    textureCoordinates[3] = GLKVector2Make(0.0f, 0.0f); // Left top

}
else {
    vertices[0] = GLKVector3Make(-1.0, -1.0,  1.0); // Left  bottom front
    vertices[1] = GLKVector3Make( 1.0, -1.0,  1.0); // Right bottom front
    vertices[2] = GLKVector3Make( 1.0,  1.0,  1.0); // Right top    front
    vertices[3] = GLKVector3Make(-1.0,  1.0,  1.0); // Left  top    front
    vertices[4] = GLKVector3Make(-1.0, -1.0, -1.0); // Left  bottom back
    vertices[5] = GLKVector3Make( 1.0, -1.0, -1.0); // Right bottom back
    vertices[6] = GLKVector3Make( 1.0,  1.0, -1.0); // Right top    back
    vertices[7] = GLKVector3Make(-1.0,  1.0, -1.0); // Left  top    back

    //GALNET GRAPHICS FIX END

    textureCoordinates[0] = GLKVector2Make(0.0f, texHeight); // Left bottom
    textureCoordinates[1] = GLKVector2Make(texWidth, texHeight); // Right bottom
    textureCoordinates[2] = GLKVector2Make(texWidth, 0.0f); // Right top
    textureCoordinates[3] = GLKVector2Make(0.0f, 0.0f); // Left top 
}
mathewrennie commented 7 years ago

@JoeMatt Sorry that's my bad. I'm busy today so can't really do much, but I will delete the Repo and from now on make sure I'm working on your fork to help things along. I uploaded directly from my Mac without thinking. Cheers, Mat.

mathewrennie commented 7 years ago

@brianmcdoogle you are right about the differences on iPad and Apple TV.. I created that code based only on what I was seeing via the AppleTV. I do have an iPad Pro so will use this to cross examine things. @JoeMatt for reference are your testing your coding on an iPad or AppleTV as it could be both systems are conflicting.

mathewrennie commented 7 years ago

@JoeMatt just quickly to stop the crashing on reload here is the patch:

To stop crashing when reloading PSX Game:

In settings.cpp change:

if(FindSetting(setting->name, false, true) != NULL) { printf("Duplicate setting name %s\n", setting->name); abort(); }

To:

if(FindSetting(setting->name, false, true) != NULL) { printf("Duplicate setting name %s\n", setting->name); }

The duplication doesn't seem to effect things.

mathewrennie commented 7 years ago

@brianmcdoogle I've uploaded a new build to GitHub, it includes your If Else statement for the time being. I've also sorted game speed issues for both iPad and Apple TV. Not had any issues so far when running. Also in relation to 2 player and controller this isn't an issue as it's simply fixing a controller type to both player 1 and 2. As such player 2 can use another controller within settings.

@JoeMatt I've not forked this build yet as am still not sure if your testing just on iPad/iPhone or indeed both iPad/iPhone and Apple TV?

rbissoli commented 7 years ago

Hi guys! You all have done an incredible work porting madnafen psx to provenance.

I've compiled using xcode 8.2 for iOS 10.2.1 and it actually works fine. I have a logitech mfi controller and it also works properly. There is a problem when not using a mfi controller. Everytime I touch some button on the screen the emulator crashes and I have to restart everything again. I noticed that GBA/Genesis/SNES emulation the touch buttons work properly and I can play without any issues. Is that a button mapping problem ?

Thank you again :D

JoeMatt commented 7 years ago

@mathewrennie it actually crashes on the math test and the settings test. What's happening is that these static variables aren't going away or being reset when the core is killed. So, it might be possible to just ignore them for now by over-stepping those calls, but it's probably a really bad idea to leave junk laying around between runs. Also this would probably effect running games from different systems back to back because of the duplicated settings.

I'm testing mostly on apple TV, though I once in a while do a build for iOS.

A better test than looking for the core "com.provenance.psx" would for the core itself to return a Bool value that is defaulted in the super class as NO. And then MednafenCore could overload it to return YES depending on the system. The GL view having to have working knowledge of the cores and doing the switching itself is a poor separation of duties.

I haven't tested the on screen buttons, so they might crash. Should be easy to fix though.

JoeMatt commented 7 years ago

I have free time this weekend, I'll try to bang this out.

rbissoli commented 7 years ago

I would be great Joe. My mfi controller is pretty basic, It is similar to a SNES controller and doesn't have analogic sticks or L2, R2 buttons. I was wondering if would be possible to have a option to leave the buttons on screen even if the mfi controller is connected or if I could customize which buttons I would like to leave on screen when using the mfi controller. It would be really awesome and break some controllers limitations ! Thanks again guys!

JoeMatt commented 7 years ago

@rbissoli Customizing controls and/or leaving them on screen would need to be a Provenance feature and wouldn't pertain to this ticket. I think there's already a ticket for customizing controls #306 #38 #37 #25

rbissoli commented 7 years ago

thanks @JoeMatt , I've posted in the referenced ticket.

BobLoblaw74 commented 7 years ago

Great work @JoeMatt on this, I was able to import 2 PSX games and run them on my Apple TV 4 and they seem to be working fine! The only issue is... I am using a SteelSeries Nimbus controller, and for some reason none of the button works, which is surprising since the same controller works for all the other consoles in Provenance. Does anybody have any idea how to fix this issue? Thanks!

JoeMatt commented 7 years ago

@BobLoblaw74 Make sure you have the latest version of my branch. I updated it ~2 ago or so. I'm still working on controllers though my memory says PSX was mapped. Make sure the Nimbus is set to controller 1 and working on other systems. Often for me my controller jumps to Player 2 if it goes to sleep for instance. I'm close to making an official pull request for this branch. Some things to touch up and test MFi controllers on all the cores thoroughly.

BobLoblaw74 commented 7 years ago

@JoeMatt I am on commit e0cd4d1 on the mednafen branch.(I cloned it last Saturday). Is there a newer version? I did make sure that Nimbus was on Controller 1, and I could not get it to work on PSX, but was able to use it on Genesis or SNES immediately after. Thanks for your help!

JoeMatt commented 7 years ago

I just updated my branch with full MFi controller support. I tested every core and they seem to have logical button mappings. I used right paddle select, left start for console with those buttons. PSX has dual analog stick support as well.

Still have a bug where sometimes the system will start slow, change game speed to normal resolves this. I have a hack that fixes this most of the time but it's a hack and not perfect. Have to figure out the root cause still.

For some reason bin/cue conflicts show up for me on iOS, but not on tvOS. For tvOS when importing PSX or PCFX-CD games, manually move them to the proper system folders and rescan the library for now. Should make a separate bug ticket for the conflict UI on tvOS.

Not sure if this is a good point to make a pull request and live with the speed workaround or wait until I have that fixed. I might not have that much time coming up though. I have a huge backlog of other projects that are becoming more time sensitive.

t4t5 commented 7 years ago

@JoeMatt Thank you so much for your work on this!

lolkthxbai commented 7 years ago

@JoeMatt truly fantastic work!

BobLoblaw74 commented 7 years ago

@JoeMatt thanks a lot, I am now able to use the D-pad and the main buttons on my Nimbus! Great job!

fabd commented 7 years ago

This would be freaking amazing if possible. Although the titles I am eying on could be difficult to emulate, in particular the Wipeout series. Wip3out (3rd) has some kind of high resolution (double vertical lines) (or was it alternating lines mode). If those games don't run at full speed they're not really playable. Rapid Racer also uses the high res mode.

JoeMatt commented 7 years ago

@fabd See #566

appletv4 commented 7 years ago

People looking for a second controller , amazon has the steelseries nimbus controller for $26 with code ON96RMRZ As of 4pm 5/17 Amazon USA

JoeMatt commented 7 years ago

Code seems to only work on the refurb version, https://smile.amazon.com/gp/product/B07119SH6G/

jgstroud commented 7 years ago

I was having trouble getting my analog sticks to work. The emulator seemed to be stuck in "gamepad" mode. I ended up modifying the DualShock::Power function to force analog=true at init. This fixes my problem with the analog sticks, but I'm sure there is a better way to fix this.

jgstroud commented 7 years ago

I'm not sure why others don't seem to be reporting the same problem I am having, but I linked up the code that allows you to toggle between analog and digital modes (most games seem to work well with analog, but Crash required digital mode). See commit: b480915345ae112b58ab2784982e3046f31c0987

Merging some of the upstream commits make this more configurable: https://github.com/jgstroud/Provenance/commits/analog

Edit: I guess I should mention I have been testing on an ATV4 mainly with Crash and Croc. Crash seems to require a digital gamepad, and Croc has a nice controller menu that shows what type of controller is connected. This is a nice way to test the mode switch.

JoeMatt commented 7 years ago

I believe others have reported similar problems. The PSX emulator we use (mednafen) has support for analog and non analog versions of the original PSX controllers (even non released versions). The issue as i understand it is how to appropriately present the correct controller type based on rom because some complain about the old or the new depending on their heritage. There's a rom SKU mapping to multitap in MednafeGameCore.mm for controller functionality. Perhaps that's an insight to resolve this type of issue. I ripped it out of OpenEMU,so if it works in OpenEMU but not Prov then it's something we can maybe fix. If not...

jgstroud commented 7 years ago

Yeah, I was hoping to set it based on the ROM, and this would ultimately be the best way to do it. For now, I am using this AMCT button combination to switch the controller type and it works quite well. My biggest gripe was that it default starts in gamepad mode, and probably 90% of the time you'll want analog mode. So I changed the default. My first attempt at patching, I also had to change the button combination from the default because it wanted Select, Start, and all 4 shoulder buttons to switch modes. I changed it to just all 4 shoulder buttons. Then I saw that the upstream mednafen code makes this button combination user selectable, so I merged that change and added the combination to the init code in MednafeGameCore.mm, which seemed like the cleanest way since it basically leaves the upstream code untouched.

barlarb commented 6 years ago

Can somebody please upload a working .ipa? I would be so grateful! I can't for the life of me get this to work, despite following the instructions to the letter multiple times. I'm running Mac OS X 10.13 High Sierra, Xcode 9.1, iOS 10.3.3 Thank you in advance.

barlarb commented 6 years ago

@JoeMatt Would this be possible?

JoeMatt commented 6 years ago

Unfortunately uploading an IPA would be futile since it would only be an ad-hoc build for my registered devices. It would have to be resigned using tools or Xcode which one could argue would be non less difficult than just building ones self from source.

Most of this has been answered in #566, continue any PSX discussion there.

JoeMatt commented 6 years ago

This is in main after Mednafen merge.

XxXStefannXxX commented 6 years ago

I know I am not in the right discussion room but i have a request to make, to all programmers working on Provenance. Would it be possible to make r2 and l2 buttons in the app? Some update or smth? I’m not an expert or anything, and don’t know how its made but it would be great to have all buttons that were on Ps1 controller. Thanks guys

JoeMatt commented 6 years ago

@XxXStefannXxX Already an issue being tracked #644