Friday, June 20, 2008

iFrodo is dead, long live iC64

The Obituary

To whom it may concern:

After repeated gaming accidents, it is with sincere regret that iFrodo is no longer.  A team of 1 and countless hours spent operating in the debugger simply could not save it.

And for all that you, iFrodo have taught me about the iPhone SDK, I am forever in your debt.

The Diagnosis

During routine exercises (testing), iFrodo was consistently passing out.  The first occurrences were running Wizball and Fist II, which caused iFrodo to report an invalid opcode.  In an attempt to eliminate any genetic issues, I decided to check family history, which included WinFrodo and their .NET cousin, sharp-64; however, they showed almost identical symptoms.

Next, to eliminate the possibility the D64 images were corrupt, I tested the offending games using iFrodo's distant relatives, CCS64 (PC), WinVICE (PC), VICE (OSX) and Power64 (OSX) all of which had no issues.

I spent many hours and explored many avenues, but could not come up with the elusive fix.

The Future

I have completed a port of VICE to the iPhone, iC64.  Any suggestions for an alternative name for the 'product' are welcome.  More importantly, all functionality that was present in iFrodo is available in iC64, with the exception of the previously mentioned bugs.

A picture is worth a thousand words and a video is worth a lot more:

Update: Video now plays the emulator sound.  Forgive the voice-over, as it is a little quite when the sound is on.

27 comments:

Timothy Barrington-Smythe said...

Wow! You rock! I have just one question: How are you going to release this? Reason I ask is the fact that when I mentioned the emulator to a friend, they pointed out Apple's overly stringent policies would most likely prevent this from being on the app store.

The emulator I'm not that concerned about. It's the offshoot SID player that has me concerned. I'm considering going legit when 2.0 comes out (Jailbroken right now) but getting a SID player on my iPod is my top priority.

Keep up the epic work.

Timothy Barrington-Smythe said...

Me again.

Just watched the video. Great stuff. Might I suggest a keyboard shortcut for the loading stuff? Looked like quite a bit of hassle.

Really impressive stuff.

Stuart said...

@timothy,

I think the SID player is less of a concern, since it will only play music. I could argue that it is similar in functionality to MIDI.

I have reSID running as a side effect of porting VICE, so SIDPlay should be coming to and iPhone or iPod Touch near you!

Unfortunately, I have issues with my recording software and uploading to youtube, which dropped the emulator's audio track. Wizball sounds great ;-)

Timothy Barrington-Smythe said...

I did wonder when you were saying about the sound:)

I hope you're right and Apple can't say "no" to this. I want both, but the SID player will need files on the device to play. How would you get the entire HVSC on there? I mean right now with jailbroken device it's dead easy. Just wondering how you can do this.

Any idea when you may be releasing?

Can you tell I'm excited?:) Wish I could help you beta test.

Stuart said...

@Timothy,

There is nothing in the license agreement to suggest you can't download files. It is more specific in that you cannot download 'interpreted code'. We'll see if SID files are considered 'interpreted' ;-)

I hope to be able to beta-test it too, so we'll see how that works with the SDK. If it works out that I can, I'll post on my blog to see who is interested :)

Chris said...

Funnily enough Stu I remember Fist 2 crashing on the actual C64. I seem to remember you could work around it somehow though but it could actually be related possibly.

Stuart said...

@Chris,

I do remember that now, mate. it was pretty frustrating too, as if I recall correctly, it was a bit of a ways in to the game.

Timothy Barrington-Smythe said...

Well good luck to you. I shall be following along closely. Will get Appstore ready on 2.0 launch day and wait with baited breath;)

daniel said...

Can't tell you how happy I am that you're sticking with the C64 on iPhone despite the iFrodo issues.

Also nice to hear a familiar accent on the videos. :)

Really looking forward to seeing (and hearing) your solution for the game controls.

More power to you.

Stuart said...

@Daniel,

Thanks for the feedback, mate.

I haven't got a developer key from Apple yet, so I've only been able to try the game controls out conceptually on the emulator. It doesn't allow true multi-touch, so I look forward to running on the real device - with videos :)

I've got auto-launching working, but still needs a little work.

Cheers

Timothy Barrington-Smythe said...

So assuming Apple have no problem with the emulator bit, how are you going to get roms/SID files onto the iPhone out of interest? Since something I was reading was saying that Apple won't allow any way of uploading stuff to the device outside of iTunes.

Blogtester said...

Hey Stuart,
I'm an interaction designer with a keen interest in both emulation and the 64. I have been a Power64 for years.

Is there anything I can lend a hand with?

I'm based in Brisbane (so same time zone).

Matt.

Stuart said...

@Timothy,

Apple has stated that you cannot download 'executable' code via the internet. If they don't consider the C64 emulator and it's D64 images 'executable' code, then it shouldn't matter. If they do, then the point is moot anyway.

I'm banking on the fact that this clause is for Flash, Mono, Java and other enterprise frameworks, totally negating the need for the App Store.
Hopefully emulators are just a hobbyist market that Apple will not care about.

If they allow the 'emulator' but want to restrict how D64 images get to the device, I had considered providing a client running on your machine, which you could connect via your phone and 'copy' your games from your desktop / laptop.

I don't think the SID player is going to be an issue, since it's just a music player.

Stuart said...

@blogtester (Matt),

Do you have an iPhone, mate? I'd be very happy to get feedback.

Unfortunately, I wasn't one of the 4,000 who received device keys, so until Apple grants me a developer license, I'm working in my own sandbox, with the simulator (no app store for me, yet).

Still, we're days away from the 2.0 release, so things might start moving.

Cheers,

Stu

Matt Morphett said...

Hey Stuart,

Matt (blogtester) here.

I don't have an iPhone yet. I hope to have one within two weeks.

I do have some suggestions about the UI - would you rather I PM you. Not even sure how to do that here.
Here are a couple of thoughts. Excuse me if any of these are already obvious.

Let's face it 95% of your users will be nostalgists who want to play games or load demos - so I suggest optimising the experience for them. Here's how...
1. I think the main click in your browser list should also execute a load "*" ,0,1 etc. and then a run after the load (Power64 does this pretty well after selecting an entry in the c64 disk directory). At the very least, I suggest an autoload key and a run key on the keyboard.
2. You could place a button to the right of each list entry which would provide access to the directory on that disk or tape (a la Power 64s list). Clicking on one of these loads and runs that entry. This provides access to items on the disk other than the first one in the list.
3. You would then have a second button to the right of each item in the browser list (which possibly looks like a blue on blue ready prompt) which mounts the disk and returns the (power) user to the ready prompt so that they can do their power-stuff.
Suggestions 2 and possibly 3 could be left off in the first release as they really cater for more advanced users.
4. (This is obvious but) I suggest you place the joystick at the bottom of the keyboard rather than on top of it. Simply for access / ergonomic reasons. It might also be worth providing facility to collapse the keyboard and expand the joystick at any time (in one move). Then again some games require the use of the space bar which could become painful. Yet, thinking out loud, the space bar could remain exposed even though the rest of the KBD is collapsed.
5. I would think you could hold off designing the special characters for the keypad when pressing the modifier keys as they aren't really essential - although this all depends on where you think the i64 sits on the cool memories <----> authentic emulation continuum. On the other hand, I have come across a c64 font which seems to have all of the PETSCII (as they were known) characters in it. I'd be happy to do some of the grunt work if you need a hand.
6. I have seem some MAME front ends which automatically execute a similar warp mode for about 5-10 secs after load. I suggest you try this by default.
Those are a couple of thoughts. I don't have an SDK (or whatever it is you are using in your sandbox) but I'm happy to mock-up some of these ideas if it would help.
Matt.

Jeffrey Caban said...

How is the program going?

Stuart said...

@Jeffrey Caban,

It is very functional today, and games are completely playable.

I do have additional features to report in an upcoming video. Examples include auto-launch feature, and I'm in the midst of implementing auto-rotate.

Unfortunately, I don't have a developer key, so I'm not able to run it on even my own device (yet!).

There is still a little bit of work left to tidy up the UI and then it'll be ready as v1.0.

Stuart said...

@matt,

Email me at stuart.carnie@gm--l.c-m.removeme

Timothy Barrington-Smythe said...

I like the idea of a seperate client program. That makes all kinds of sense:)

As I've said before, I'm mainly interested in the SID player bit. Really looking forward to trying it!

Anonymous said...

Hello,
what about a joystick? I suggest to add an extra key to the keyboard which ,switches' it to a tuchable joystick (like widgets in the dashboard swing around to reveal the options panel) -- that may be much more comfortable than having to place your fingers inside the game screen.

Greetings, flitzefisch

Mikko Hämäläinen said...

@stuart: unless your implementation is 100% clean room for all the parts of emulation, you can not publish your software via AppStore without violating GPL license. As I recall, Frodo, libsidplay, reSID, libsidplay, TinySID and basically every C64/SID emulator are under GPL license.

This is not to disregard your great work, but the licensing issue should be considered or you will personally be liable for license violation. It is a lose-lose situation since you cannot publish the source under the terms of GPL without violating Apple's NDA and you cannot publish the binary without violating GPL.

Stuart said...

@mikko,

Thanks for the info; however, I do understand the requirements of the GPL and plan to adhere to the requirements, making all my source available to the public.

Apple is expected to lift the NDA, at which point I will be able to publish all my source, likely on Google Code, and therefore not violating Apple's NDA, the GPL or any FSF licenses.

Obviously until Apple lifts the NDA, I must wait. Still, I'm a ways off completing my projects, so I expect the NDA will be long gone by this time.

Mikko Hämäläinen said...

@stuart: the problem is not the source, but your provisioning certificates that should be published with the source. As GPLv2 states you must include all the necessary scripts to compile and install the binary, you need to include your personal provisioning certificates - something that Apple's license agreement forbids. This might be strict interpretation of the license, but I really think this is the case since Apple does not provide certificates without restrictions.

The reason I'm pointing this out is that I've already done the porting for iPhone, but pulled back the release due to licensing issues that I only found about later and I'm now making my own clean room implementation for 6510, 6562 and 6581 emulation. These will be either closed source or under BSD license. I think BSD would be beneficial for larger audience as GPL is often too restrictive compared to BSD or Apache license.

If you go on with the AppStore distribution, it will be interesting to see how this goes. So far there has not been any GPL'd software published (using GPL code published prior AppStore), or the GPL code has been used in secret :-)

In any case, keep up the great work! There are always ways to distribute if AppStore option is out of the question :-)

Stuart said...

@mikko,

Disclaimer: I'm no lawyer; however, I would like to address your concerns based on my understanding.

My specific provisioning certificates do not need to be published, as they have nothing to do with the GPL'd software and the software is not dependent on my specific certificates. This is a very important distinction. Certainly, if my GPL'd version required my specific certificates, then I would be bound by the GPL to include them.

The provisioning certificates are a requirement of Apple's iPhone development SDK, in order to deploy to a physical device. As long as an individual has the necessary environment set up, with their own provisioning certificates, they will be able to make changes to my app and reinstall - and that is what is important with GPL.

I think you might be confusing the fact that the provisioning certificates are in 'soft' form, and so you assume they need to be included.

Perhaps a quick analogy. Imagine the provisioning certificate was actually a USB dongle, that a developer had to purchase? Each developer can have their own key and still install my GPL'd software. Owning this key (or in real-world case a provisioning certificate) is no different to requiring a physical iPhone, a Mac computer, a cable (to transfer from computer to device), XCode, provisioning certificate, etc...

Hope this helps.

BTW, if you read through the iPhone 'Legal' section on the device, it does run GPL'd software. I don't see any indication on how to obtain this software, modify it and install it on the device, which would imply I'd be able to generate my own 'firmware'. :)

dandee said...

Man, that's awesome. Now I really need to get an Iphone soon. ;). I noticed, that you still have some space for additional keys left on the second screen of the keyboard. Why not put in som buttons for loading "0:*",8,1 or something, that you don't have to write it all over again - something like a launch first games on disk or similar. Keep it up!!! I want to see this thing released any time soon ... Apple? Do you read me?

cheers!

P.S.:Funny that you use our released (REM) to test you emus.

dandee said...

I couldn't resist and doodled around with the keyboard optics. As I couldn't find any email adress on the blog, I just will give you the link to the file. I don't know, if this works or if the look fits to the clean look of an Iphone... (don't have one myself). Some keys have been shifted and most are bigger than the original... you are the coder. ;)

http://www.computer-classics.de/i64/i64_keyb1.jpg

best.

Stuart said...

@dandee,

Thanks mate - that keyboard is awesome! I'd like to play around with that once I get some of the other issues sorted!

I've actually been back and forth between VICE and Frodo, and as of today, I have managed to get Frodo to significantly outperform VICE on the iPhone playing games. I will be able to get a playable emulator running on the iPhone.

My biggest issue with Frodo is that it crashes on some games. This behaviour is the same running on Windows, my .NET port and others - so it has nothing to do with the iPhone. I'm just going to have to bite the bullet and try to track down the problem.

Cheers