Blitzmax to Monkey

Monkey Forums/Monkey Programming/Blitzmax to Monkey

GfK(Posted 2011) [#1]
Hello.

Just a hyper... hypo... hippo... theoretical question really. Suppose I have a heap of code written in BlitzMax, and I want that same code to run on an Android, Flash, HTML5 etc target - graphic/resolution issues aside, is it realistic to stuff all that code into Monk/Jungle, and work through it until it actually runs? Or is it better just to rewrite it all from the ground up?

(I'm talking about whole games with a couple hundred KB of source, not poopy little bits of test code).


JIM(Posted 2011) [#2]
The syntax is similar enough, however the design is probably very different.

You can get away with pasting lots of "utils" code I guess (math stuff, etc.) and use Replace all on a few things.

Core application design might need to be rewritten (OnUpdate, OnRender, ...). There's also lots of stuff still missing from monkey so you'll have to fill the gaps or work around those areas.

I would start with copy-pasting the stuff that has little chance of being completely broken (math, util functions, high-level classes), and rewrite where necessary the fiddly stuff (opengl stuff, event-based code, window customization - icon, title, buttons, etc.).


wiebow(Posted 2011) [#3]
I guess it depends on which features of Blitzmax you are using in your original program and whether they are already implemented in Monkey or not. There is now basic file I/O, but who knows what other stuff you are using that is not yet in.

I for one really miss reflection, asserts and try/catch.


therevills(Posted 2011) [#4]
@Gfk - Most of the code I wrote for Pirate Solitare Monkey Edition was copied from the BlitzMax version with small changes.

@Wiebo - There is an Asserts module in Diddy ;)


anawiki(Posted 2011) [#5]
We started by trying to translate all BMX code to Monkey, but ended up writing from scratch using parts of the BMX code. A lot of code was reused this way, but you had clear progress, while trying to translate all code at once made it very very very complex.


ziggy(Posted 2011) [#6]
anawiki+=1
My experience rewriting the FontMachine module for Monkey/Mojo have been:

Phase 1: I'm going to translate this

Phase 2: I'll look for a workaraound for this, and that...

Phase 3: Ok, let's face it, this needs a rewrite. I'm going to start all over without translating

Phase 4: I've got a different approach for the FontMachine module for Monkey that is much more devices oriented for several reasons, and much better that a translation would ever be.

So, all in all, I would considere a rewrite from scratch. It'll be a lot faster as you'll be reusing code when you really need it.


Wiering(Posted 2011) [#7]
If you do decide to translate it, you could start by changing your BlitzMax version so that it works like Monkey (with OnRender/OnUpdate) with a Main function like: Repeat; OnUpdate(); OnRender(); Flip(); Forever; and make sure everything works properly in BlitzMax before you start translating.


GfK(Posted 2011) [#8]
There is now basic file I/O
Where/what is this?


dopeyrulz(Posted 2011) [#9]
Dave,

In GLFW, there are some file access commands. See the IO module for details.


GfK(Posted 2011) [#10]
Ah.... not for iOS and Android then. :/