port java game to dreamcast?

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
hansjak
DCEmu Newbie
DCEmu Newbie
Posts: 7
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Sat May 21, 2005 8:07 pm
Has thanked: 0
Been thanked: 0

port java game to dreamcast?

Post by hansjak »

me and some friends of mine developed a java game. we have to present our project in a month or so at our university...

now i tought it would be cool to present our game on my dreamcast too. that would rock for sure...



i started searching the internet for anything related to java and dreamcast... and the only thing i found, was that a company ported personalJava along with a web-browser... and i found out that it could be possible to use gcj (gnu java compiler), which uses the gcc backend which supports the sh-4.

i would be happy if i could port at least a limited version of the game (no network support, no sound, ...)

to make it short: should i even bother trying to port our game to the dreamcast? do i have a chance to complete this project in a month?


regards,
hansjak



things you might want to know about the game:
- it makes use of lwjgl (opengl, fmod)
- it's 2d only
- it's single-threaded
i'm more smarter than you are be
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Post by BlackAura »

You'd have to rewrite most of it from scratch, I'm afraid. There is no Java VM available on the Dreamcast (at least, none that aren't embedded in a web browser), and no OpenGL either (we have a work-alike called KGL, but it's not exactly compatible with OpenGL).
Ex-Cyber
DCEmu User with No Life
DCEmu User with No Life
Posts: 3641
Joined: Sat Feb 16, 2002 1:55 pm
Has thanked: 0
Been thanked: 0

Post by Ex-Cyber »

GCJ can compile to native code, so lack of a VM shouldn't be an issue, but I'd think you would essentially end up having to port Classpath as well, unless your code is highly self-contained.
"You know, I have a great, wonderful, really original method of teaching antitrust law, and it kept 80 percent of the students awake. They learned things. It was fabulous." -- Justice Stephen Breyer
hansjak
DCEmu Newbie
DCEmu Newbie
Posts: 7
Joined: Sat May 21, 2005 8:07 pm
Has thanked: 0
Been thanked: 0

Post by hansjak »

so, that means "no"... :-(


can you imagine other consoles i could port our game more easily to?
i'm more smarter than you are be
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7499
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has thanked: 4 times
Been thanked: 10 times
Contact:

Post by Quzar »

java enabled web phones probably. you'd just have to compile/interpret it using j2me instead (and maybe rewrite some things that may not be compliant).
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
hansjak
DCEmu Newbie
DCEmu Newbie
Posts: 7
Joined: Sat May 21, 2005 8:07 pm
Has thanked: 0
Been thanked: 0

Post by hansjak »

rewrite some things? honestly... i don't think cell phones have enough power to run our game... but thanks for the suggestion.
i'm more smarter than you are be
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Post by BlackAura »

I've been doing some work on J2ME over the past couple of days. Apps written for J2SE generally won't work. The packages available in both J2ME and J2SE are java.lang, java.io and java.util. Even those packages are stripped down somewhat for J2ME.

Other than that... I can't think of anything. Java generally isn't used for games at all, except for mobile phones, and that's only because native code games will only work on a single type of phone, while Java MIDlets tend to work more-or-less the same on anything that has an appropriate Java / J2ME implementation.

Depending on how it's written, it might be possible to get it running, but you'd either have to port a JVM (like Kaffe) to the Dreamcast, or somehow make GCJ work (I couldn't get it working last time I tried, although that was years ago). Either way, you'd need to port the base classes over, you'd have to write a load of JNI-style bindings to KallistiOS system calls, and you'd have to write a back-end for your game that uses those instead of lwjgl. Not fun. Possible, but not fun.

I'll have to have another look at getting a JVM running on the Dreamcast. Last time I looked, KOS's support for the C standard library and C++ wasn't good enough. It might be now though.
User avatar
Ender
DCEmu Super Poster
DCEmu Super Poster
Posts: 1314
Joined: Mon Dec 10, 2001 4:01 pm
Location: Canada, first igloo on your left.
Has thanked: 0
Been thanked: 0
Contact:

Post by Ender »

I seem to remember BlueCrab telling me something one day about Java dev for DC. He had a whole dev environ up at one point apparently. You may want to ask him.
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Post by BlueCrab »

I did have enough of gcj working to get it to compile binaries for the dreamcast, however nothing ever really worked. (At least, not that I can remember)

I think that if I can get a chance to try to work on that again, I might try it. Exceptions would be a problem though, because I can't seem to get C++ exceptions to work at all on the dc.
hansjak
DCEmu Newbie
DCEmu Newbie
Posts: 7
Joined: Sat May 21, 2005 8:07 pm
Has thanked: 0
Been thanked: 0

Post by hansjak »

wow, thats soo cool... i didn't expect that much interest and support... if gcj really works, i'll try to port it. i couldn't get our game working with gcj 3.4.1. maybe gcc 4 works better...

thank you very much for your support!
i'm more smarter than you are be
User avatar
Pale Rider
DCEmu Freak
DCEmu Freak
Posts: 56
Joined: Sat Apr 23, 2005 3:17 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by Pale Rider »

java's tuff on the dc,even in planetweb with suns pjava support,somethings,even supported apps dont run...or they run extremely sluggish.but i would imagine that is due to the overhead in memory being used by the browser while trying to run an applet.
hansjak
DCEmu Newbie
DCEmu Newbie
Posts: 7
Joined: Sat May 21, 2005 8:07 pm
Has thanked: 0
Been thanked: 0

Post by hansjak »

gcj isn't as polished as i tought. i can't even use it (cygwin-version crashes, mingw-version sometimes locks) for my project, because of command-path-limitations, gcj limitations (1.4 not very well supported), ... i can't even compile our project for x86.

i guess we're out of luck.



but thanks for looking into the issue.
i'm more smarter than you are be
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Post by BlackAura »

Looking around, I basically see three possible ways to do Java stuff on the Dreamcast.

1 - GCJ, compiling to native SH-4 binaries. Assuming we can get GCC 4.0 working on the Dreamcast (GCJ 4 is much better than GCJ 3.x), that basically means we'd need to port libgcj (the GCJ runtime) over to KOS, and get the compiler itself building and generating working code. The runtime consists of a threading part (should be easy now we have pthreads support in KOS), a file handling part (should be easy now we have a POSIX-style libc), and a signal handling part to handle signals sent by the operating system and convert them into Java exceptions. That could be tough - not only does KOS not have anything like signals, it doesn't even use the SH-4's MMU so we will be completely unable to catch null pointer exceptions. That just leaves things like arithmetic exceptions (like divide by zero), but I don't think we can catch those either. So some modification of KOS itself might be in order, or we could just ignore it...

2 - Kaffe, or another JIT. Kaffe shouldn't be that much more difficult to port than GCJ. Might even be easier - the core library only has threading and file stuff, no signal handling to worry about. It already has an SH JIT backend, and has been ported to a number of embedded operating systems. Would require more memory than GCJ for the code cache, but it does also have an interpreter version, and the (now disappeared) DOS port ran on machines with 8MB of RAM. Doesn't leave that much room elsewhere, but you're not going to be doing 3D games with this thing anyway. Of course, if we have to write an SH-4 JIT, it's going to be bloody difficult.

3 - SableVM, or another interpreter. Slow, but probably a little easier than a JIT.

Once you have the interpreter up and running, that leaves you trying to do something useful with it. That would probably get you the core Java libraries - java.lang, java.io, java.util, and anything else that's part of the interpreter itself or implemented in pure Java. That's probably not all that hard, actually, but it would be a fair bit of work.

Might be interesting to try though.

Oh, one other possibility... Port Mono or Portable.Net over, and run Java code using IKVM. That's even more insane than porting a Java runtime (which, at least, we know is possible), but it'd also buy C# and Vb.Net (if you're using Microsoft's VB.Net compiler).
hansjak
DCEmu Newbie
DCEmu Newbie
Posts: 7
Joined: Sat May 21, 2005 8:07 pm
Has thanked: 0
Been thanked: 0

Post by hansjak »

phew... so many options... and everything sounds so easy :-)

ok, BlackAura, you still got ~25 days to do all this stuff. i'm waiting...
:D



well... i abandon the project. i think it would be easier to port everything to c++. but just to show off that's still too much effort.



i'll post a link where you can download the game when it's done.



so long...
i'm more smarter than you are be
hansjak
DCEmu Newbie
DCEmu Newbie
Posts: 7
Joined: Sat May 21, 2005 8:07 pm
Has thanked: 0
Been thanked: 0

Post by hansjak »

i'm more smarter than you are be
Post Reply