English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. Blitz Basic (https://eab.abime.net/forumdisplay.php?f=126)
-   -   [blitz basic] How much amiga-blitz friendly is this? (https://eab.abime.net/showthread.php?t=76982)

saimon69 10 February 2015 20:46

[blitz basic] How much amiga-blitz friendly is this?
 
[note: i just got all pieces of amiblitz 2 and going to install it so am not ready yet]

found this tutorial for a Tetris clone on blitz basic PC: how much do i need to modify this to make it run on an amiga? (of course the 800x600 screen gotta go)

bare-bones tetris clone example code

Seems kinda straightforward but since is a long time i dont touch a basic and havent touched Blitz yet i want to make sure before to start work on it.

saimon69 11 February 2015 18:54

[update]
ok, actually what i found is Blitz Basic 2: is the one to use or what version do you advice me? i remember hearing about using Amiblitz 2 rather than 3...

idrougge 11 February 2015 22:04

By all means, go ahead and use BB2, just don't try to adapt PC source codes in it.

Coagulus 11 February 2015 23:38

Quote:

Originally Posted by idrougge (Post 1003282)
By all means, go ahead and use BB2, just don't try to adapt PC source codes in it.

It's possible (sort of) from PC Blitz to Amiga Blitz, I've done it with Timebomb and I'm doing it with JetHunt. :guru

But be prepared to do a fair bit of rewriting, especially where anything writes to the screen.

And I replaced many of the functions eg drawboard() with labels eg .drawboard and used Gosub to call them but you then have to rearrange the variables especially if functions are using local variables. Blitz amiga does have statements and functions though too.

saimon69 12 February 2015 03:05

Else, is there some tetris game written in BB2 amiga that i can take as reference to understand how to modify it to my needs?

Cylon 12 February 2015 23:25

I've written one couple of years ago, but the src is not public. What you need is: Look how tetris works and figure out how to do this by yourself. It is fairly simple. Why do you need the source "to modify it to [your] needs" instead of writing it all from scratch?

saimon69 13 February 2015 01:02

first because i dont know where to get my hands on to modify that source code: i guess the logic of handling arrays and collision is basically the same but display have no clue: i code in javascript actionscrtipt 1 and php and used zx basic but blitz is definitely different: did look for tutorials very base level but found little stuff so far :(

second, because my fnal purpose is to create a version of the old flashpoint arcade, that is based on tetris logic plus some little additions (now is more a beat the level game than a puzzle one) so having a working tetris base i could just add modifications - did it on a tetris flash so more or less i know what to add but lack basics to do it on blitz.

saimon69 17 February 2015 22:28

ok i got rid of a biltz2 copy and started to get grip of the usage. So far i changed the set screen and the key control but now have some doubts about some functions and instructions used on that port.

First of all: are the read-data instructions used in the same way?
second the instruction
Code:

SeedRnd MilliSecs()
is correct or have to use other stuff?

then for instructions like cls, setOrigin etc. are already on blitz 2 or need to use other ones?

saimon69 19 February 2015 10:35

Updates: i was able to make the BlitzOut AF tutorial run; had to write a separate program to generate the shapes though; this also made me understand that have a good deal of work to do in order to convert that tutorial in Amiblitz; will go on slowly and steadily..

saimon69 19 February 2015 21:34

ok so was pondering on what to do and i realized am using not the listing above but the more advanced one here:
tetris clone example code

now i started to convert some of those functions in statements however some of the functions actually have parameter, like RotatePiece; how transfer parameters on a statement?

Plus, am planning to use shapes and not drawn blocks: how much the logic might differ?

Cylon 19 February 2015 22:21

Quote:

Originally Posted by saimon69 (Post 1004560)
First of all: are the read-data instructions used in the same way?
second the instruction
Code:

SeedRnd MilliSecs()
is correct or have to use other stuff?

then for instructions like cls, setOrigin etc. are already on blitz 2 or need to use other ones?

Yes, the read-Data is basic BASIC. Please note: Blockcolor is in 24bits (255 values for red/green/blue). So you need AGA display or RTG.

Forget SeedRnd, you don't need it. This is for internal use of the random number generator. Just replace the
Code:

NextPiece = Rand(1, 7)
with
Code:

NextPiece = RND(6)+1
and you are good.;)

Quote:

Originally Posted by saimon69 (Post 1005052)
..now i started to convert some of those functions in statements however some of the functions actually have parameter, like RotatePiece; how transfer parameters on a statement?

Code:

Function RotatePiece(rotateLeft = False)
could be just
Code:

Statement RotatePiece{rotateLeft}
Note the brackets. You cannot declare anything of the arguments inside the function arguments. And: Any variable listed as GLOBAL variable on top of the source present in your Function or Statement must be declared inside the Function with SHARED before using it. Otherwise it is 0.
Note: there is a
Code:

  If .... Then Return
inside this Function.
You can (for now) just replace the Return with
Code:

Statement Return
(Normally, you have to "Pop" too. Doesn't matter now.
Quote:

Plus, am planning to use shapes and not drawn blocks: how much the logic might differ?
You can draw the blocks to create your own shapes once and save/load them later. Or you use a paint program. Or you start to use the block drawing and change that later.;) But this is headache, donot start with this. Try to make it run first, let it compile and see what happens.
Reason: You have to change the logic quite a bit. I would start to replace the little "DrawBlk" Function with a simple "Box", with adaptions for color, of course. this would speed up things a little bit if you after this.

saimon69 19 February 2015 22:59

@Cylon

sounds like homework ^^

Cylon 20 February 2015 23:27

No, not really. If you know Blitz a little bit then a little thinking gets you further.
* Don't use the RGB at all. Use Colors (one for each of the 7 tiles).
* Put all the Functions (or Statements after "conversion") on top, right after init and variable declaration. The main routine follows (because you can only call Functions after they have been created).
* If you don't want to screw up too much of the original src, you can go for a screen with the same dimensions, maybe with less colors (8 bit or less). Just make it autoscroll 800x600, the displays dimensions doesn't matter in that case.
* Replace all GLOBAL on top with SHARED (Find&Replace), then encapsulate the whole GLOBALSHARED block with
Code:

Macro myshared
SHARED Endofgame  ;example!
.
.
End Macro

Every declaration, e.g. Global CurPieceX = 3 must go:
Code:

Global CurPieceX = 3
becomes
SHARED CurPieceX

and later (or before, as we encapsulated the Globals into a macro)
CurPieceX = 3

Now, in every function Foo we write the macro call on top
Code:

Function Foo {}
!myshared
.
.
End Function

Which should work just fine.

*Edit:
Please note: You have DIMed some arrays, those Shares must be inside the myshared Macro too.

The provided source is actually quite easy to convert to Blitzbasic2....:)

saimon69 24 February 2015 01:40

did not had time to work on it this weekend, will keep you posted

saimon69 24 February 2015 08:08

ok continued to work on the adaptation, now have a "garbage at end of line" error when the code reach an Origin statement like:

Code:

Origin OrigBoardX, OrigBoardY

Cylon 25 February 2015 22:47

Ignore that ;-)
It means: "Origin" is not a known Command or whatever, if it is a label, then there is cr*p after it.

It sets the origin coordinates for the following text statements. Add a ; in front of this line. Proceed adding ; in front of every text .... you encounter on the way. Dito with color ...

As i said: Make it compile. Save all (big) steps into different file iterations.

I've got mine compiling, btw. (started today 1:30 hrs ago).

saimon69 26 February 2015 00:58

Well you got more experience, i feel like trying to make my horizons tape running on ZX spectrum for the first time (and it took a good while - talking on a week of attempts - due to volume and azimut settings)

saimon69 26 February 2015 10:48

so now here i am with a Illegal Procedure Call concerning DrawBlk:

following the above syntax i modified it as DrawBlk{params} because with round braces was having syntax error...

Cylon 26 February 2015 21:54

Quote:

Originally Posted by Cylon (Post 1006545)
Ignore that ;-)
It means: "Origin" is not a known Command or whatever, if it is a label, then there is cr*p after it.

It sets the origin coordinates for the following text statements. Add a ; in front of this line. Proceed adding ; in front of every text .... you encounter on the way. Dito with color ...
.

It is not like that after looking at it again today.
All the Origin.... variables setting different areas which act as an origin(!) to the following drawing commands.
I can surround this (as Blitz2 has no Origin cmd) by creating a Macro:
Code:

Macro Origin
  xx=`1
  yy=`2
End Macro

In the statements, we replace the
Code:

Origin OrigBoardX, OrigBoardY
with
Code:

!Origin {OrigBoardX, OrigBoardY}
and all calls to drawing operations, like LINE, are using the xx and yy we created using the Macro:
Code:

Line 0, 200, 400, 200, ...
Code:

Line xx+ 0,yy+  200,xx+ 400,yy+ 200, ...
And so on.
That way we get our Origin. It also only happens a few times, so it is not much work.

Cylon 26 February 2015 22:06

Quote:

Originally Posted by saimon69 (Post 1006608)
so now here i am with a Illegal Procedure Call concerning DrawBlk:

following the above syntax i modified it as DrawBlk{params} because with round braces was having syntax error...

"Illegal Procedure Call" happens, when you try to call a Function as a Statement or vice versa.

Example:
Code:

If NOT DropPiece{}
indicates it is a Function, because it returns a value, so we can check it with
If NOT (return from)DropPiece{}.

EDIT: (return from) indicates a spark in your mind, as a NOT expects an argument that is kindly delivered as a return value from a Function{}


All times are GMT +2. The time now is 09:42.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.12165 seconds with 11 queries