How to create a target...?

Monkey Targets Forums/User Targets/How to create a target...?

SLotman(Posted 2013) [#1]
Is there a guide somewhere on how to create a target for monkey?

I know its probably very complicated, and probably out of my reach, but I was looking at the Nokia S40 SDK... it's Java - MIDP basically - so probably a lot could be taken from the Android Target, just changing drawing/playing audio stuff, I guess.

..and to top it all, Nokia is charging "1 euro" to be able to publish on their store.

(And since I'm seeing a lot of those "Asha" devices, could be worth a shot porting games to S40)


frank(Posted 2013) [#2]
It's not that hard to make a target (I started on an SDL one because it is much easier to port to older/embedded devices that GLFW); I would copy all target files for Android and change them; with a hello world MIDP project as basic framework for the app it should be pretty straightforward. I would guess implementing Mojo for it is more work than getting the target up.


therevills(Posted 2013) [#3]
It's not that hard to make a target

As long as Monkey currently supports the language you are aiming at... if it doesnt its quite a pain to do...


frank(Posted 2013) [#4]
@therevills: yes, should've said that, agree.


SLotman(Posted 2013) [#5]
(Resurrecting this topic, writing this for my own reference)
So, this is what I could gather so far...

To create a new Monkey target one have to (I'm using j2me as a sample):
- Alter trans, to have a new "TARGET" (is this still necessary with latest Monkey?)
- Alter trans, to call the J2ME compiler/build sequence?
- Create a new folder in the "targets" folder, with this structure:
TARGETS
->J2ME
  .TARGET.MONKEY
  ->modules
    .monkeytarget.monkey
    ->native
      .j2megame.java
      .monkeytarget.java
  ->template
    .MonkeyGame.java (???)


Then you would have to implement mojo.j2me.java (?) with the following commands:


I still don't know exactly how to integrate this mojo thing with the target, and I didn't find where to actually write code to handle input...

Now this is a very basic J2ME/MIDP code -- I wonder how can I implement it (writing it on template->MonkeyGame.java?) so Monkey would actually generate the correct code.




Ferdi(Posted 2013) [#6]
- Alter trans, to have a new "TARGET" (is this still necessary with latest Monkey?)
- Alter trans, to call the J2ME compiler/build sequence?


AFAIK, in V71C you still need to update trans. You need to add or modify these files:

src
->transcc
  ->builders
    .builders.monkey <-- you will need to add j2me.monkey into this file.
    .j2me.monkey <-- you need to add this file.


In builders.monkey you will need to add the following line:

builders.Set "j2me", New J2meBuilder( tcc )


j2me.monkey is the file that tells monkey how you are going to compile this target. I copy mine from glfw.monkey, since I needed to use Visual C++. I am not sure how you will be compiling J2ME code, may be copy the android.monkey?

NOTE] Make sure you have MinGW working as that is the tool that is used to compile C++ Tool target.

Here is the line that compile a new transcc:

..\..\bin\transcc_winnt.exe -target=C++_Tool -config=release transcc.monkey


This is kinda related, may be worth pointing out. When you run transcc_winnt.exe, you will see the following:

C:\Users\Ferdi\Desktop\MonkeyPro70g\bin>transcc_winnt
TRANS monkey compiler V1.48
TRANS Usage: transcc [-update] [-build] [-run] [-clean] [-config=...] [-target=...] [-cfgfile=...] [-modpath=...] <main_monkey_source_file>
Valid targets: Android_Game C++_Tool Flash_Game Glfw_Game Html5_Game PS_Mobile_Game Popcap_Sexy_Framework Windows_8_Game Windows_Phone_8_Game Xna_Game
Valid configs: debug release


Notice the "Valid targets". J2me_Game needs to appear here for it to appear in Ted.

I still don't know exactly how to integrate this mojo thing with the target


When the target compile, it will create one huge file, in my case it is main.cpp, I am guessing in you case it will be main.java. Mojo will be in there. It knows to put the correct mojo in main.java by looking at target name specified in the file targets/j2me/target.monkey

I am assuming your mojo file will be mojo.j2me.monkey. So your target.monkey should be as follows:

#TARGET_NAME="J2me Game"
#TARGET_SYSTEM="j2me"
#TARGET_BUILDER="j2me"


I am not sure whether it uses TARGET_SYSTEM or TARGET_BUILDER.

and I didn't find where to actually write code to handle input...


Input code should be in the file targets/j2me/modules/native/j2megame.java

Check out: https://github.com/blitz-research/monkey/blob/master/targets/android/modules/native/androidgame.java

Then look for OnKeyDown, and OnTouchEvent.

Now this is a very basic J2ME/MIDP code -- I wonder how can


I am not sure if this is what you are looking for, but check out: https://github.com/blitz-research/monkey/blob/master/targets/android/modules/native/monkeytarget.java

Anyway, good luck!


SLotman(Posted 2013) [#7]
@Ferdi,

Thanks! I can see this is very complicated and waaay over my head... but I'll still try it, little by little :)

I was almost giving this up since I dug out some old J2ME games I made, and looked in horror on the capabilities (no alpha, no rotation, no dynamic loading images...)

But I just found some OpenGL ES reference for J2ME, which may help things a little bit:
http://www.j2megame.org/j2meapi/JSR_184_Mobile_3D_Graphics_API_1_1/


Ferdi(Posted 2013) [#8]
np, SLotman.

I never made J2ME games, but I remember looking at them. And if I am not wrong they were running on low cpu-powered mobile. So I am kinda surprise it even have Open GL on it!

Forgot to mention, the hardest part is the debugging. Because you have to debug in the *.build folder, and then make your changes in mojo / target folders.

If you run into trouble or have anymore questions just dump it in this thread, then I can try to answer it as best as I can. This way it is documented somewhere. I have subscribe to this thread, so I will get an email.