Adding Cocoa to Hiro

Archived bsnes development news, feature requests and bug reports. Forum is now located at http://board.byuu.org/
Locked
akihabara
New Member
Posts: 3
Joined: Sat Aug 16, 2008 2:11 am

Adding Cocoa to Hiro

Post by akihabara »

I just wanted to give byuu and others a heads up that I'm currently in the process of adding Cocoa to Hiro. I don't think anybody else is, wants to or even can from what I've read while lurking around here. However, it's totally possible with knowledge of Cocoa, which I'm working on obtaining regardless.

This will definitely take me a lot of time because:
I'm a lousy programmer.
I'm not yet proficient with Cocoa, but I plan to be.
I have a life, family, friends and even a chronic illness or two.

In other words, it will be done when it is done and I don't care if it's all done by me, only some of it is done by me or even if somebody else swoops in and does the whole thing while I'm still trying to get Cocoa to conform to Hiro's interface. This is for me to learn Cocoa and a way for me to help bring a project that I believe in to a slightly larger audience.

If byuu likes, this can be the official Hiro Cocoa Thread.

Anybody that doesn't like seeing Objective C mixed with C++ and Cocoa bastardized into a mess that slightly resembles the Windows API had better stay out. :twisted:

Seriously, that's basically what I'm going to have to do in order to get this to work. Luckily, I'm rather proficient with the Windows API and am using that implementation of Hiro as a template for the Cocoa implementation.
earbenT
New Member
Posts: 5
Joined: Thu Aug 14, 2008 3:34 am

Post by earbenT »

As a part-time OS X user, I very much appreciate the effort. I'd love to see a Cocoa version that stays current with the Windows and Linux releases.
byuu

Post by byuu »

I actually have OS X + Xcode, but have yet to even manage to create a single Cocoa app that doesn't rely on pre-generated partial binary files from the IDE.

So little info out there on it, and then they expect you to learn another programming language just to use it ... ugh.

Anyway, the main reason I haven't bothered is because bsnes is so far from Apple's HIG so as to not even be funny.

For instance, I presently allow all windows to have their own unique menubar. Is it possible to do something like that with Cocoa? Obviously the menubars would go to the top of the screen, but can you have one for each window inside a Cocoa app? Or is it one menu for the entire app? I also have no intentions of following their toolbar rules that most apps use. But, something is better than nothing, right?

And we'd hopefully still have Bannister's wonderful HIG-compliant port with EE, for those who really care about that.

Other than that, if you manage to port hiro to Cocoa, I'd be extremely grateful :D
With that, I could start working on things like a CoreAudio plugin, etc; and keep my releases synced on the Mac as well.
earbenT
New Member
Posts: 5
Joined: Thu Aug 14, 2008 3:34 am

Post by earbenT »

byuu wrote:So little info out there on it.
http://developer.apple.com/referencelibrary/
http://lists.apple.com/

(I'm not being facetious btw)
For instance, I presently allow all windows to have their own unique menubar. Is it possible to do something like that with Cocoa? Obviously the menubars would go to the top of the screen, but can you have one for each window inside a Cocoa app? Or is it one menu for the entire app? I also have no intentions of following their toolbar rules that most apps use. But, something is better than nothing, right?
It is indeed one toolbar for the entire app. However, the toolbar contains all possible menus and subsequent menu items, with each item being either selectable or greyed-out depending on the window you're currently focused on.
And we'd hopefully still have Bannister's wonderful HIG-compliant port with EE, for those who really care about that.
Bannister seems largely disinterested in keeping up with new versions. What's EE?
I.S.T.
Zealot
Posts: 1325
Joined: Tue Nov 27, 2007 7:03 am

Post by I.S.T. »

dvdmth
New Member
Posts: 6
Joined: Thu Feb 14, 2008 9:12 pm

Post by dvdmth »

I would be using Bannister's port right now, except that it has a really annoying input lag problem. Too bad he's been tied up with other things and hasn't been able to update this emu (though strangely he was able to update Nestopia to 1.40 BEFORE the Windows version - I though the world would come to an end when that happened).

Any port of bsnes to OS X (Carbon/Cocoa) will have to have changes to the UI design, simply because the Mac interface is incompatible with Windows/Linux. You could work around the differences (I've seen ports of other programs that literally change the menu bar contents when the front window changed), but doing so will make the end result unpopular among Mac users.

If you want the same UI design, a much better approach would be to make an X11 build. Such a build *shouldn't* be too hard, though I wasn't able to succeed earlier this year when I tried. The source has changed since, so I may have another go at it if I have the time.

If anyone out there can get this emulator ported to OS X (be it Carbon, Cocoa, or X11) without that input lag problem, I'd very much appreciate it.
byuu

Post by byuu »

Bannister seems largely disinterested in keeping up with new versions.
I speak with him about most new versions. He's just quite busy and I release new versions (with lots of API changes) fairly quickly.
though strangely he was able to update Nestopia to 1.40 BEFORE the Windows version
Well, Nestopia is also ~10-20x more popular, at least. He's probably just focusing the time he does have in the most useful way.
Any port of bsnes to OS X (Carbon/Cocoa) will have to have changes to the UI design, simply because the Mac interface is incompatible with Windows/Linux. You could work around the differences (I've seen ports of other programs that literally change the menu bar contents when the front window changed), but doing so will make the end result unpopular among Mac users.
That's pretty much what I thought would be the case, sadly. I have no intentions of personally maintaining multiple ports of the UI. This is why I merged the Windows and Linux ones. It makes my life so much easier.
If you want the same UI design, a much better approach would be to make an X11 build. Such a build *shouldn't* be too hard, though I wasn't able to succeed earlier this year when I tried. The source has changed since, so I may have another go at it if I have the time.
I do like that as a compromise. If anyone does manage this, I'll be happy to add new compilation targets and such. Since the last time you worked with it, we've ported libco to gcc, and it builds and runs in OSX now. So no need for nasm / yasm, at least.

A pure SDL port could also be a possibility, but no user interface would kind of suck.
akihabara
New Member
Posts: 3
Joined: Sat Aug 16, 2008 2:11 am

Post by akihabara »

I actually have OS X + Xcode, but have yet to even manage to create a single Cocoa app that doesn't rely on pre-generated partial binary files from the IDE.
Just like Visual Studio, Apple's IDE is mainly for easing the creation of GUI programs and you don't have to use it.

The minimal Cocoa program is:

Code: Select all

#import <Cocoa/Cocoa.h>

int main(int argc, char *argv[])
{
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
	NSApp = [NSApplication sharedApplication];
	[NSApp run];
	[NSApp release];
	[pool release];
}
Save it as test.m

Code: Select all

mkdir -p Test.app/Contents/MacOS
gcc -o Test.app/Contents/MacOS/Test -framework Cocoa test.m
open Test.app
It doesn't do anything, but it has a dock icon, a dock menu and will properly close when you select Quit from the dock menu.
learn another programming language just to use it
Objective C is 100% compatible with C (take that C++ :P) and is easy to learn. It's just that the syntax turns people off right away before they give it a chance. I know because the same thing happened to me. Now that I've actually started to use it, it seems pretty straightforward.
bsnes is so far from Apple's HIG so as to not even be funny
Most emulators are. Anyway, I'm just going to see if I can get Hiro to even work on Mac OS X first. Then I can see about maybe getting it to look and act like a good Mac OS X citizen. There are cross platform C++ GUI toolkits that give a good experience on Mac OS X. I'd like to see if Hiro can be one of them.
Obviously the menubars would go to the top of the screen, but can you have one for each window inside a Cocoa app?
Of course you can. If I'm remembering correctly, AppleWorks completely changes the menubar depending on what document you are working on. It's actually rather trivial to do. [NSApp setMainMenu: anNSMenuObject]
keep my releases synced on the Mac as well.
That really is the main point of all this. I think there is real value in having BSnes simultaneously released on the three most important computing platforms.
Richard Bannister

Post by Richard Bannister »

earbenT wrote:Bannister seems largely disinterested in keeping up with new versions.
Bannister has spent the better part of a decade developing and maintaining the lions share of all emulators available for Mac OS X. Throughout his seven years as a third level student he had ample time available to keep all his ports in sync with the originals. These days, however, he works a full time job and takes consultancy contracts from time to time in order to pay the mortgage repayments on his apartment. He therefore has only very limited spare time available to keep his projects up-to-date, and consequentially he is forced to prioritize.

He generally takes the view that one major update to an emulator every couple of months is sufficient, especially when the changes, interesting though they may be, have very limited effect on end users. He makes an exception to this rule when the changes in a new release require no modifications to his Mac specific code (Nestopia).

He also has an unfortunate tendency to refer to himself in the third person.
Richard Bannister

Post by Richard Bannister »

dvdmth wrote:I would be using Bannister's port right now, except that it has a really annoying input lag problem. Too bad he's been tied up with other things and hasn't been able to update this emu (though strangely he was able to update Nestopia to 1.40 BEFORE the Windows version - I though the world would come to an end when that happened).
That was a drop-in recompile; I'd just released 1.39 when Martin Freij sent me the new code. It took me less than ten minutes to build 1.40, and most of that was spent doing a quick stress test.

If BSNES was the same I'd be fully in sync with each release.
byuu

Post by byuu »

Too late, Mr. Bannister. I've beaten you to the punch.

My version of bsnes, running on OS X:
http://byuu.cinnamonpirate.com/images/d ... 80820a.png

Richard's version on OS X:
http://byuu.cinnamonpirate.com/images/d ... 80820b.png

Screenshots are not faked in any way ;)
Dullaron
Lurker
Posts: 199
Joined: Mon Mar 10, 2008 11:36 pm

Post by Dullaron »

Nice. 8)
Window Vista Home Premium 32-bit / Intel Core 2 Quad Q6600 2.40Ghz / 3.00 GB RAM / Nvidia GeForce 8500 GT
akihabara
New Member
Posts: 3
Joined: Sat Aug 16, 2008 2:11 am

Post by akihabara »

Nice job, byuu. :o That's using GTK, isn't it?

I haven't made much progress adding Cocoa to Hiro yet. I've been sick with a cold and I'm now busy reprogramming an old Sharp Pocket Computer PC-1262. Don't ask. Crazy work stuff. :roll:
Locked