Jump to content
sleirsgoevy

Cibyl -- compile C to Java

Recommended Posts

I've prepared a small project that demonstrates the use of the Cibyl MIPS-to-Java compiler to run C code in the BD-J environment. This compiler may be useful for porting existing C games into Java. However the transpiled code is a bit slower than native Java code, so this is more for porting existing software, which is going to be troublesome as BD-J has only several megabytes of RAM, and new games should (probably) be developed directly in Java.

Anyway, I've uploaded the example of using cibyl to GitHub.

  • Like 1
  • Upvote 1

Share this post


Link to post
Share on other sites

Interesting project. I will link to it on blu-play.com 🙂

Share this post


Link to post
Share on other sites

It's not mine of course, I just crafted a simple usage example that works, since some aspects are not trivial to figure out. Please note that on blu-play.com.

Also you've set an incorrect date on the news. It's year 2020 now.

Edited by sleirsgoevy
  • Upvote 1

Share this post


Link to post
Share on other sites

A few other things I noticed while making that demo:

  • Floating-point arithmetic in Cibyl is dog slow, as each operation involves 3 nested Java method calls. The same demo using doubles only gave 1-2 FPS. (Maybe it'll be a bit better if I use float instead of double).
  • The transpiler doesn't handle GCC optimization levels larger than -O1 correctly. It does compile and run without crashing, but results in a black screen.
  • Upvote 1

Share this post


Link to post
Share on other sites

It seems that I've found a bug in Cibyl (or in Cibyl's GCC, didn't check that yet) resulting in the code behaving incorrectly. The test case is as follows:
 

int main()
{
    volatile int a = 46;
    volatile int b = -2147483637;
    assert(!(a < b));
    return 0;

}

As the transpiler seems to be unmaintained, I will probably have dig into that myself.

EDIT: I figured out the cause of the problem. The transpiler effectively replaced a<b here with a-b<0, and that is true due to integer overflow.

EDIT 2: FIXED. Github fork with the fix is here, and the modified xcibyl-translator can be downloaded here.

Edited by sleirsgoevy
  • Upvote 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...