reicast-emulator icon indicating copy to clipboard operation
reicast-emulator copied to clipboard

iOS Version of Reicast #768 (continued)

Open AbandonedCart opened this issue 6 years ago • 55 comments

Continuation of https://github.com/reicast/reicast-emulator/issues/768

(Summary of most recent comments) @JoeMatt

I'm a little confused, is the disussion on posting a build from my fork? Was any of that merged into main? My fork is a nice thing to look at but I wouldn't consider it playable until I work out the audio timing issues. It's on my radar, but I have a lot of projects right now I'm working on.

I've actually been doing the next stage of work on a branch of Provenance, since I'm more familiar with my own code base and have a lot of assistance classes for audio / video timing etc,

https://github.com/Provenance-Emu/Provenance/tree/feature/Core-Reicast

I have another commit with the time stamped CARingBuffer, which might be the final solution, but I haven't pushed it yet since the input buffer's CATimeStamp is not yet synced to anything meaningful but the system clock, so it drifts in and out of the output buffer range. It's a nice test but you'll get audio for a few seconds, then none, then audio again, then none. The speed is more stable though and CPU isn't being stalled on each frame causing the massive overhead as it rushes to render the next frame after the audio buffer is drained like the original code on the non-dynarec pipeline.

@brand175

Instead of using google drive or dropbox. I zipped the file and dragged it onto github. I'll also put it on the reicast forum.

reicast-ios.zip


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

AbandonedCart avatar May 05 '18 11:05 AbandonedCart

I was looking at the speed syncing issues a while back too, maybe one of the Reicast devs more familiar with the inner workings can help me out here...

From what I recall, the interpreter has CPU_RATIO defined as 8 which affects how often interrupts get fired off into the other systems and how often various systems that are scheduled based on clock cycles get triggered. It seemed to me that it would be difficult or impossible to get games' audio and video to run at the correct speed without a CPU_RATIO of 1. Is that accurate or am I misunderstanding?

I also saw that there's the rec-cpp stuff which seems to me to be more like a threaded interpreter that caches traces so it wouldn't require executable code pages and would therefore work on non-jailbroken iOS devices. Am I understanding that right? I'm wondering if that would be the better path to pursue.

braindx avatar May 05 '18 13:05 braindx

I was able to start Reicast for the first time on my iPhone 6s with the ipa of @brand175, thanks a lot ! If I can be helpful in testing some games or functionnalities in return, it will be with pleasure. Thanks to the dev team of Reicast by the way, I will never say it strongly enough.

I've first tested Sonic Adventure 2, and in contrary of @brand175 I was able to bypass the start menu normaly and reach the in-game section:

img_8467

It might depends of the device or bios since I use the same .ipa

I've also tested Marvel vs Capcom 2 but here I can't pass this screen:

img_8468

Maybe because the virtual memory is full or not recognized.

Here are some other issues I found: (it may be helpful)

  • Sound & music & animation speed are some times too fast. Nevertheless it's mostly stable at approximatively 120fps for me, it's very hopeful for the future of the app !
  • When lauching the game vertically the controls doesn't match correctly the screen when it return in the horizontal way.
  • The play button on the bios doesn't play the game but crash or reach again the bios screen.
  • As said before, Joystick doesn't work on touch screen but may work with a MFI controller after @brand175.
  • Random D-pad directions are sometimes pressed automaticaly by the emulator.
  • I didn't found any important graphic glitch
  • There are two virtually memories card recognized by Sonic Adventure 2

NOTE: The .gdi and .cdi games files work both on the emulator.

Hope it will help you, and good luck for the next !

DecMaster avatar May 05 '18 16:05 DecMaster

The music player in the bios works. Also @DecMaster don’t forget about the LT button being slightly lower than the RT button which would cause people with OCD to go crazy (not me 😊). Also did you first try the Sonic adventure 2 menu thing. This happens in most games I tried. If you keep retrying it works but unfortunately for me sonic adventure 2 still kicks me out even on my iPad Pro. Most of the times clicking the abxy buttons help before clicking the start button. I noticed that Soldier of Fortune on the iPhone 6 has about 35% less graphical glitches in the first cutscene than the iPad Pro. I’ve seen this kind of stuff on the Dolphin emulator on ios. It’s most likely an OpenGL problem than the emulator it self.

brand175 avatar May 05 '18 17:05 brand175

I managed to fix the Lt and Rt triggers for the MFi controller. They are currently bound to the right stick. Up and Down is Rt, Left and Right is Lt. I don't have enough experience in coding to bind the Rt and Lt on the controller itself. I'll see what I can do to fix it anyways. Also I can't compile the provenance version probably because of the older Xcode version that I have installed.

Reicast Rt Lt Experimental Fix.zip

trigger fix gif

brand175 avatar May 07 '18 22:05 brand175

https://github.com/AbandonedCart/reicast-emulator-lk/commit/1bcf1a062251f916266ea715b129cfbf7422a1d9

AbandonedCart avatar May 07 '18 23:05 AbandonedCart

That would of taken me 3 weeks just to figure that out. I'm pretty sure that change was only for the touchscreen. I'll add that change to the MFi Controls section and update the ipa tomorrow.

brand175 avatar May 08 '18 00:05 brand175

It should be the same thing, but a different "trigger" (not the physical trigger)

AbandonedCart avatar May 08 '18 01:05 AbandonedCart

@brand175 @mk8itra1n The old thread was 263 comments, so this thread was added to cut the excessive load time. A reference was left at the end of that thread, so everyone can find this one.

I renamed this thread, so there should be no confusion about the conversation being moved here.

AbandonedCart avatar May 08 '18 05:05 AbandonedCart

@mk8itra1n Anything new about the iPhone X test yet. Would it be possible to make a short video since ios 11 has in built screen recording. I also tried to install the reicast on my iphone 4 but it said that the ios version is too low. I wonder if it would work on a iphone 5.

brand175 avatar May 08 '18 15:05 brand175

@brand175 I tested the build out on my X. It works on a game by game basis for me. Some games the Lt and Rt work and others like Sonic Adventure there is no response when i touch those controls or any controls for that matter. It may be just how the emulator renders certain games that is causing the control issues or timing issues with the CPU. I am jailbroken on iOS 11.1.2. I should be able to get a built in screen recording onto this thread. I believe this emulator should work on a iPhone 5 at the lowest since if memory serves me correctly it is able to run iOS 10.

mk8itra1n avatar May 08 '18 20:05 mk8itra1n

Doubt it would run on an iPhone 5 since it doesn't have GLES 3, weaker GPU generation in general even if GLES 2 is the target (it's not right now but could be).

But we know it runs, there's not much point in reporting anything and cluttering up this ticket until the clocking issues are resolved.

On that note, I pushed my WIP code for Provenance-Reicast with timestamped ring buffer.

https://github.com/Provenance-Emu/Provenance/tree/feature/Core-Reicast

The code that's in progress is this mess of method here, https://github.com/Provenance-Emu/Provenance/blob/b636f50a4d9e9225e2a23ef5fbee0a7d9d964738/PVReicast/PVReicastCore/PVReicastCore.mm#L821

That's where the callback is entered, which used to stall until the system drained the audio buffer, which would defacto sync the audio processor (and others?) to the system, but also caused the massive CPU overhead just spinning waiting for the buffers to be drained.

I experimented with read ahead, and threaded deadlocks, with limited success.

I have some things I need to know / learn,

  1. If the audio CB doesn't wait when it's ahead in time, does it continue to repush PCM samples from the audio processor state?
  2. If 1 is the case, is there a clock to sync the current time of the sample buffer start.

The point of the time stamped ring buffer is that if a buffer comes in that overlaps with existing audio waiting for the OS to pull it (audio buffers are a pull for those that don't know. The sound card requests the audio for a time, not the other way around of the system 'pushing' samples to the sound card as they come, that allows pre-preocessing audio in chunks ahead of time) , the ring buffer with time stamps should resolve, i think, overlapping input buffers if the audio coprocessor callback is repeating sections as it's ahead of the other processors and we're not stalling like the original way mentioned above.

  • The other issue is coming up with a time stamp value that can be within a range for the output clock of the audio system (measered in samples acquired since 0) and the 'clock' state of the audio processor.

  • Also need to check that the interlacing and bit depth/sample rate are correct, might explain the fast audio but normal video in some games

  • Alternatively, if my assumptions are correct about repeated sample windows, maybe there's a way to jus not do that, like keep a window range and if the current state is still in the range of samples already sent, don't call the callback, (like how the callback isn't called if it's way ahead by that 1.2 value that I don't quite understand)

In the comments of that function i documented some things Im' going to play with, and also noted an interesting kind of hack that DirectSound does on Windows, which seems like was the original audio subsystem since the requriments on the design seem to parallel that way DirectSound works.

JoeMatt avatar May 08 '18 21:05 JoeMatt

@mk8itra1n The Rt and Lt button only works on the MFi controller. I only set the Rt and Lt for the extended gamepad profile. Which has more buttons than the other MFi controllers. Also @LoungeKatt I couldn’t get the trigger fix to work. I’ve tried your way and then adding it to the mfi extended gamepad. Do I have to change the *button to a *axis along with the GCcontrollerAxisInput.

brand175 avatar May 08 '18 22:05 brand175

I believe you do. I'm still a little rusty with iOS. It's been a few months of strict Android lol.

AbandonedCart avatar May 09 '18 03:05 AbandonedCart

Is Shenmue 2 working yet with descent sound and speed using touch screen controls? Iphone 6 would do It?

yurimerath avatar May 09 '18 07:05 yurimerath

Let’s move general discussions and speculation to the forum to avoid overloading the tracker. http://dcemulation.org/phpBB/viewforum.php?f=86 please :)

On Wed, 9 May 2018 at 10:06, yurimerath [email protected] wrote:

Is Shenmue 2 working yet with descent sound and speed using touch screen controls? Iphone 6 would do It?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/reicast/reicast-emulator/issues/1145#issuecomment-387641732, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYAMp9-3JYcgB9gq0Y8_BB2oMH6fVF5ks5twpV_gaJpZM4TzmO- .

-- ~skmp

skmp avatar May 09 '18 07:05 skmp

@yurimerath I haven’t tested it yet. Touchscreen controls are not fully implemented yet and would probably take some time. I think the Provenance version of reicast may have fully working controls but I can’t compile it due to the Xcode version I have plus other errors. I’m pretty sure that version also has better framerates than the other one. Also I know where to store the code for the touchscreen joystick. I just need to learn how to implement the code into reicast and bind it to the touchscreen. Just thinking about how to implement it is giving me a headache 🤕

brand175 avatar May 09 '18 07:05 brand175

@skmp I’ll just post the link to the forum that I created a few days ago on Reicast for iOS. Hopefully this comes to good use.

http://dcemulation.org/phpBB/viewtopic.php?f=86&t=104564&sid=35c81a33078e63a6f7f195708f50f7a0

brand175 avatar May 09 '18 08:05 brand175

Ahh there’s even already a thread. Nice!

On Wed, 9 May 2018 at 11:02, brand175 [email protected] wrote:

@skmp https://github.com/skmp I’ll just post the link to the forum that I created a few days ago on Reicast for iOS. Hopefully this comes to good use.

http://dcemulation.org/phpBB/viewtopic.php?f=86&t=104564&sid=35c81a33078e63a6f7f195708f50f7a0

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/reicast/reicast-emulator/issues/1145#issuecomment-387656067, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYAMmC36RPZUU4RLLiF42fmlA4bP_QDks5twqJ9gaJpZM4TzmO- .

-- ~skmp

skmp avatar May 09 '18 08:05 skmp

I fixed the triggers for the MFi controller. I made a bunch of changes and I don't exactly know what I did. But what I do know is the GCcontrollerButtonInput stays the same as well as *button. I'll update the github code once I figure what I did to make it work. I didn't change much.

Reicast MFi Trigger fix.zip

brand175 avatar May 09 '18 22:05 brand175

@skmp From the GitHub history it seems like you wrote most if not all of the rec-cpp system. Would be able to weigh in on its current state and whether my understanding of it as stated above is correct? Additionally, if you have any insight as to the CPU_RATIO define and how that affects the synchronization/timing of various other subsystems it would be greatly appreciated. If you prefer to discuss this via forum or in another medium, just let me know. I'm happy to spin something up!

braindx avatar May 09 '18 23:05 braindx

brand175 thanks and keep up the good work! Where can I get this provenance version with the recaist core and how do I configure It? (Where to put the bios files etc) I’m gonna test shenmue 2!

yurimerath avatar May 10 '18 00:05 yurimerath

@yurimerath https://github.com/reicast/reicast-emulator/issues/1145#issuecomment-387542021

AbandonedCart avatar May 10 '18 01:05 AbandonedCart

I want the IPA

yurimerath avatar May 10 '18 08:05 yurimerath

@yurimerath The point was that there currently is no IPA, but you can build one yourself. If you would like help building it, then I recommend asking on the reicast forum. This thread is for trying to debug and improve the source.

AbandonedCart avatar May 10 '18 11:05 AbandonedCart

Hey guys, okay so i managed to build @JoeMatt ´s Provenance branch through XCode and send it to my iDevices. Those are iPad mini4 (10.2 Jailbroken), mini4 (11.2.1 non-Jailbroken) and iPhoneX (11.3 non-Jailbroken) Bios files are in the right place and 3 roms to test (SonicAdventure 2, SonicShuffle and VirtuaTennis2). On all 3 devices both Sonic games show black, then crash the app, Tennis gets stuck on a grey screen. Am wondering if my build is somewhat faulty... They all run more or less glitchy on @brand175 ´s standalone build. Am happy to test stuff out if you like me to

Lemmy8 avatar May 10 '18 15:05 Lemmy8

@Lemmy8 @JoeMatt did warn of that version being heavily under construction at the moment and will likely have resources set up to help debug it when it is ready. For now, we should probably try to focus on just the build that would be a likely candidate here to prevent confusion and give him some time to prepare for user feedback.

AbandonedCart avatar May 10 '18 16:05 AbandonedCart

@brand175

/**
 Shoulder buttons are required to be analog inputs.
 */
@property (nonatomic, readonly) GCControllerButtonInput *leftShoulder;
/**
 Shoulder buttons are required to be analog inputs.
 */
@property (nonatomic, readonly) GCControllerButtonInput *rightShoulder;

/**
 Triggers are required to be analog inputs. Common uses would be acceleration and decelleration in a driving game for example.
 */
@property (nonatomic, readonly) GCControllerButtonInput *leftTrigger;
@property (nonatomic, readonly) GCControllerButtonInput *rightTrigger;

@end

I don't have a device to test it, but the code should be something like: https://github.com/reicast/reicast-emulator/commit/23d9bf61ac5a49180a40e86e4e0608e555123018

AbandonedCart avatar May 10 '18 17:05 AbandonedCart

@LoungeKatt sure, i had hopes that the Provenance implementation runs comparable to the standalone but fixes input issues. But yes, it's too early for testing. Please keep up the great work, this is coming along soo promising after all those silent months 😀

Lemmy8 avatar May 10 '18 20:05 Lemmy8

@LoungeKatt I just discovered that the Trigger fix that I did for the MFi controller from a few days ago isn't fully analog. And the very first one I did was (I think it may not be 100% analog. I tested a different game to test the triggers and I noticed that the newer one didn't work for that game but it did on the other). I'll test your code tomorrow and see if anything works. I'm hoping that I can contribute to reicast on ios even though my skill level is very low. I'm learning by modifying given code and creating new lines of code based on what code is available. I know some basic C++ stuff and that's about it.

brand175 avatar May 11 '18 04:05 brand175

It seems there's a lot of community interest now but everyone is working on their own bug fixes. I have a busy schedule at the moment but I promise I'll fix my fork and make a proper pull request as soon as possible, hopefully this week, and incorporate some of the changes posted here. Then hopefully everyone can work together on a coherent branch.

Maybe the admins want to make a specific feature branch on GitHub too to work against since the PR wouldn't be ready for prime time on the main branches but I'll leave that up to them.

JoeMatt avatar May 11 '18 22:05 JoeMatt