MonkeyMax - BlitzMax Target

Monkey Archive Forums/Monkey Projects/MonkeyMax - BlitzMax Target

therevills(Posted 2011) [#1]
Continuing from this post:
http://www.monkeycoder.co.nz/Community/posts.php?topic=1573

But more an "offical" project now ;)

This is the first part of the BlitzMax Target - meaning it only currently translates Monkey code - NOT Mojo! So no graphics stuff yet!

Instructions:

1. Grab the zip file from here:
http://www.therevillsgames.com/monkey/MonkeyMax/MonkeyMax.zip

2. Back up your Monkey Folder!! The zip will replace several files, including Trans, config.winnt.txt etc!

3. Extract the zip file into your Monkey Folder

4. Alter the config.winnt.txt and set your BlitzMax path - This is my config.winnt.txt so it will have removed all your paths... Thats why I told you to back up your Monkey Folder in Step 2!

5. Run Monk.exe and open the bmaxTest.monkey file

6. Click Run and select BMAX

7. Hopefully it will now output a heap of stuff in the console - this is the BlitzMax program running!!

I've done a heap of testing and it seems okay... Arrays still need work, but meh!


Raz(Posted 2011) [#2]
Wahay :D Glad to see this is going well


MikeHart(Posted 2011) [#3]
???? Besides using DirectX on Widnows then, what would be the use for it?


Dabz(Posted 2011) [#4]
nice work Mr T!

Dabz


therevills(Posted 2011) [#5]
what would be the use for it


A lot of the current Monkey coders are from a Blitz background, having a BlitzMax target means that they should be able to debug the code themselves using BlitzMax tools.

Also since BlitzMax is very stable I feel it would be a better alternative than the current GLFW target.


DruggedBunny(Posted 2011) [#6]
... and you could do a more configurable/adaptable/desktop-friendly port with the same game converted to BlitzMax.


ErikT(Posted 2011) [#7]
Great stuff! Well done :)


Raz(Posted 2011) [#8]
???? Besides using DirectX on Widnows then, what would be the use for it?

I consider it a Windows / Mac / Linux friendly target that I know will work. I've had little to no luck with GLFW and XNA when releasing for windows.


Neuro(Posted 2011) [#9]
This is awesome :)!


therevills(Posted 2011) [#10]
MojoMax News:

Good News:
I've got a sprite displaying on the screen \o/

Bad News:
BlitzMax OO hurts!! BlitzMax's inheritance doesn't properly kick in until the constructor chain is complete... which means I have to change mojo's app.monkey, I did not want to do this!

This is the generated BlitzMax code using the standard app.monkey:
Type bb_MyGame Extends bb_App 
	Method  bb_MyGame_new:bb_MyGame()
		Super.bb_App_new();
		Return Self;
	EndMethod
Type bb_App 
	Method  bb_App_new:bb_App()
		bb_device=(New bb_AppDevice).bb_AppDevice_new(Self);
		Return Self;
	EndMethod
Type bb_AppDevice Extends gxtkApp
	Method  bb_AppDevice_new:bb_AppDevice(bbt_app:bb_App)
		Self.bb_app=bbt_app;
		bb_SetGraphicsContext((New bb_GraphicsContext).bb_GraphicsContext_new(Self.GraphicsDevice()));
		Return Self;
	EndMethod
Type gxtkApp
..
	Method New()
		app=Self;
		ggraphics=New gxtkGraphics;
		
		'input=new gxtkInput;
		'audio=new gxtkAudio;
		
		startMillis=BlitzMaxMillisecs()
		
		'game.stage.addEventListener( Event.ENTER_FRAME,OnEnterFrame );
		
		SetFrameRate( 0 );
		
		InvokeOnCreate();
		InvokeOnRender();
		Update()
	EndMethod

I had to add a Setup() Method to get around this:
Type bb_App 
	Method  bb_App_new:bb_App()
		bb_device=(New bb_AppDevice).bb_AppDevice_new(Self);
		bb_device.SetUp();
		Return Self;
	EndMethod
Type gxtkApp
..
	Method New()
		app=Self;
		ggraphics=New gxtkGraphics;
	EndMethod
	
	Method Setup()
		
		'input=new gxtkInput;
		'audio=new gxtkAudio;
		
		startMillis=BlitzMaxMillisecs()
		
		'game.stage.addEventListener( Event.ENTER_FRAME,OnEnterFrame );
		
		SetFrameRate( 0 );
		
		InvokeOnCreate();
		InvokeOnRender();
		Update()
	EndMethod



therevills(Posted 2011) [#11]
Just to show the above problem more:

Java Code


When you run the above Java code it will print out:
Start
AppDevice - Update


BlitzMax Code


This code outputs:
Start
GxtkApp - Update


You see it actually calls the incorrect Update method!! Is this a bug with BlitzMax!?


Skn3(Posted 2011) [#12]
You could potentially get around this by making your types a base Abstract type and then the real type (ie accessed from translated monkey code) is extended. EG

monkey
Class apple
	Method func()
	End
End
blitzmax
Type appleBase Abstract
	Method func() Abstract
End Type

Type apple Extends appleBase
	Method func()
	End Method
End Type
I dont even know if the targets translation code allows this, but it's what I usually have to do in max to get inherited methods to work "properly" in this scenario. I always wondered if it was a blitzmax bug or by design?


Samah(Posted 2011) [#13]
@Skn3: I always wondered if it was a blitzmax bug or by design?

Personally I think it's just poor OO design. See this post by FlameDuck as to why this kind of thing is dangerous: http://monkeycoder.co.nz/Community/post.php?topic=1534&post=14007


Skn3(Posted 2011) [#14]
So you reckon essentially it shouldn't be allowed ? Or did I misunderstand?


therevills(Posted 2011) [#15]
Sprites frames now work :)

And I've got DrawText to work... I had the translator wrong - opps!


therevills(Posted 2011) [#16]
I've checked in MonkeyMax and the start of MojoMax into the Diddy Repository.

To get MojoMax to work you need to do a few things:

Copy the mojo monkey files to the mojomax module folder and alter app.monkey:

Add "Method SetUp()" to Class gxtkApp="gxtkApp"

And change the App Class' New method:
Class App
  	Method New()
 		device=New AppDevice( Self )
 		device.SetUp()
 	End


And comment out the input and audio stuff...

http://code.google.com/p/diddy/source/browse/#svn%2Ftrunk%2Fmonkeymax


Skn3(Posted 2011) [#17]
Wow looking good, keep it up!


teremochek(Posted 2011) [#18]
"Compile error"
local bbt_l:String=((bbt_lhs) as bb_StringObject).bb_value;
I'm doing wrong?


TheRedFox(Posted 2011) [#19]
This is great! You efforts motivated me to have a look at all the trans module and dig in deeper :-)

Mark really did a great job... Wow.

From the tokenizer code and so on, it would be interesting to get a code beautifier. JungleIDE doesn't do it (yet) even if they parse everything.

Is there anybody out there who started one?