Porting blitzplus programs to blitzmax: advice?

BlitzMax Forums/BlitzMax Programming/Porting blitzplus programs to blitzmax: advice?

salric(Posted 2006) [#1]
Hi All,

So I've got a 10,000+ line game I need to port from Blitzplus to BMax. While the beach-ball was spinning & the .bb source file was being imported into max I had dreams about clicking compile & experiencing instant gratification.

Needless to say it didn't work out that way.

Specifically, the following issues occurred:

- Lines that contained more than one statement had their colons replaced by a semi-colon. Is there some magic here or do I need to separate these into their own lines?
- Several errors occurred: Booleans can only be used on integers, putting a % following the variable does not solve this issue... what does this mean?
- Commands such as color etc., are not recognised, does this mean I need to either write functions for the majority of blitzplus graphics commands or search-replace them out?
- I've learned to hate search and replace as it searches and replaces within words, is there anyway to change this behaviour in the default ide (hope springs eternal) ?

In summary, has anyone had any practical experience in porting a blitzplus (or 2d blitz3d) program across to blitzmax that could give me some advice on shortcuts, best practices etc.?

In addition, I'm wondering if there is a smart way to replace the setbuffer commands (draw to a number of different buffers) with the pixmap equivalents (i.e. a neat little function that emulates setbuffer perhaps?)

Anyhow, I look forward to your responses; I figured that I'd check with the community before embarking on this task.

Cheers!


skidracer(Posted 2006) [#2]
Semi-colons are the new colons, I'm embarassed to say I can't actually see where this is documented in the BlitzMax help.

You now need to test objects against null as in if object then -> if object<>null then for boolean purposes.

Color should have been converted to SetColor by the converter... Also it's behavior has changed as it affects drawing of images.

I never got round to adding setbuffer style function helpers, this might be a good initial project to get your feet wet with BlitzMax rather than diving directly to 200 ft with out oxygen...

A second task may be to fix up the .bb code converter a little, BlitzMax has come a long way since it was written so it is in need of some attention, will post the source soon.


FlameDuck(Posted 2006) [#3]
So I've got a 10,000+ line game I need to port from Blitzplus to BMax.
Rewrite it properly in BlitzMAX. I know that's not the answer you where looking for, but it really is the best solution.

On the upside, you can probably dramatically reduce the ammount of lines and convoluted logic needed, by using a more object oriented approach.


Grisu(Posted 2006) [#4]
I have tried converting my cardwar game to bmx.
Around 15.000 lines of code and I failed.

Rewrite it from scratch is my advise as well.


Grey Alien(Posted 2006) [#5]
I also say rewrite. You can make it much better with objects.


Murilo(Posted 2006) [#6]
Same here. I've taken the porting route with my current game (Archon Evolution), and I wish I'd just rewritten it from scratch.

Rewrite and take full advantage of Max's lovliness...


Russell(Posted 2006) [#7]
I converted a 2000 line B3D program by hand and it took me over an hour (with only 2D commands used)...

Strangely, File/Import BB Project misses a couple of obvious things like converting Color to SetColor, Line to DrawLine, etc. I found that I was manually going in there and fixing things. Text -> DrawText (and the params are in a different order, and there's no 'Center X' or 'Center Y' flags) etc.

Speaking of Center X and Center Y: B3D's docs say
"center x = optional; true = center horizontally
center y = optional; true = center vertically"

This is kind of misleading. What it actually does is place the HANDLE of the text in the center horizontally or vertically, respectively, instead of in the upper left corner. Screen width and height are not taken into account as one might expect.

A little late to be posting this complaint, I know. ;)

Russell


Grisu(Posted 2006) [#8]
@Leigh:
Why are the Archon Forums down?


Dreamora(Posted 2006) [#9]
File Import is no solution at all. It will handle the data the B3D / BB+ way which means 10-40 times slower than if you wrote it in BM from scratch


Mark1nc(Posted 2006) [#10]
What I do is throw in some helper functions at first to get it to compile. Later you can go through and convert to the new/replacement function calls.

Function Rect(x:Int,y:Int,w:Int,h:Int,f:Int=0)
	If f
		'solid
		DrawRect x,y,w,h
	Else
		'outline
		Local x1:Int = x + w
		Local y1:Int = y + h
		DrawLine x,y,x,y1
		DrawLine x,y1,x1,y1
		DrawLine x1,y1,x1,y
		DrawLine x1,y,x,y
	EndIf
End Function


Function Color(r:Int,g:Int,b:Int)

	SetColor r,g,b

End Function

Function Text(x:Int,y:Int,tx:String)

	DrawText tx$,x,y

End Function





kfprimm(Posted 2006) [#11]
Function Text(x:Int,y:Int,tx:String,centerx:Int=False,centery:Int=False)
	DrawText tx$,x+((TextWidth(tx)/2)*-centerx),+((TextHeight(tx)/2)*-centery)
End Function

Here's a little addition to Mark1nc's helper functions


AlexO(Posted 2006) [#12]
I'ved attempted a straight port also and I soon realized it's not worth it and I can get a much better result by rewriting the whole thing with Bmax's new features in mind, especially the object-oriented aspect.