English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 26 February 2015, 22:12   #21
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 473
Here is my base skeleton to get you started.
Please note the order of appearance of Functions/Statements. As i said before, you can only call those after they are defined (in source, not in real time appearance).

Code:
._about
.
.init

; no doublebuffer yet !
;
 #Width        =$80000023
 #Height       =$80000024
 #Dpth         =$80000025
 #Typ          =$8000002D
 #DisplayID    =$80000032
 #Overscan     =$80000034
 #AutoScroll   =$80000039
 #LikeWorkbench=$80000047

 ;NOTE:We use an AGA (classic chipset) screen mode Workbench!!!

 ScreenTags1,"tetris test",#LikeWorkbench,True,#Width,800,#Height,600,#Dpth,8,#AutoScroll,True,0,0
 Window 1,0,0,800,600,$1900,"",2,1  ;print to window with Text{}
 ScreensBitMap1,1 ;gfx output (chg to window later)
 BitMapOutput1      ;Print to bmap

._macros
Macro myshared
Macro Origin

.funcs
Statement Text {x,y,txt$,col}
Statement DrawBlk {col, x, y, fade}
Statement DrawBoardBlocks{}
Statement DrawBoard{}
Statement DrawGhostPiece{}
Statement DrawCurrentPiece{}
Statement DrawNextPiece{}
Statement DrawInfo{}
Statement CalcGhostPosition{}
Statement ResetPiece{}
Function  DropPiece{}
Statement CheckForLines{}
Function  PlacePiece{}
Statement LineClearer{}
Statement MoveLeft{}
Statement MoveRight{}
Statement RotatePiece{rotateLeft}
Statement DrawPauseMessage {}
Statement EndGame{}
Statement PrintGameOver{}
Statement StartNewGame{}
Statement ProcessInputs{}

.main
Repeat
;
Until exit;Esc key
.mloop
.
End
._colsdat

._piecedat

.eof
Note this is a quick sumup, so don't pinpoint me at something. I use an AGA screen, a Workbench clone, so all gfx coords are basically the same.

Note also (if you don't saw it before):
The original program is updating the screen all the time, you certainly don't want that, it is too slow anyway.

Last edited by Cylon; 26 February 2015 at 22:55. Reason: act. adds
Cylon is offline  
Old 26 February 2015, 22:47   #22
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 473
So far:
Attached Thumbnails
Click image for larger version

Name:	tetristest-00.png
Views:	306
Size:	4.7 KB
ID:	43389  
Cylon is offline  
Old 27 February 2015, 08:33   #23
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,568
feel like am plying chess with the devil; macros, labels, physical addresses, how a n00b know that, and where they explain it? The most understandable tutorial i found online is the one from labritcho, the AF and CU print stuff follow but not at the same level; however this feels years ahead...

so right now have TED getting stuck at this line with a syntax error:

Code:
DrawBlk{r, g, b, xx+CurPieceX*25 + xiter*25, yy+GhostPieceY*25 + yiter*25, 1}
the called DrawBlk function is actually in this state:
Code:
Function DrawBlk{r, g, b, x, y, faden}

!sharedstuff
 ; Color r, g, b
;  Rect x, y, 24, 24
 ; Color r * fade#, g * fade#, b * faden
;  Rect x + 2, y + 2, 20, 20, 0
;  Line x, y, x+2, y+2
;  Line x, y+23, x+23, y+23
;  Line x+1, y+22, x+22, y+22
;  Line x+22, y+1, x+22, y+22
;  Line x+23, y, x+23, y+23
End Function
[EDIT] ok i see your structure and how you handled DrawBlk trying to do the same now...

Last edited by saimon69; 27 February 2015 at 08:45.
saimon69 is online now  
Old 28 February 2015, 01:12   #24
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 473
i have done some changes:

ProcessInput{} seems to work,
Timing is odd, but works(??),
GhostPieces got an own color (we dont use fade and rgb drawing),
Esc & Quit works (some)times.
Removed CLS, added EraseBoard{} to replace it.
Flicker is present, as expected.

I will post parts of src (or all of it?) later, on request. Could be a tutorial or a guided first-steps-to-blitz.
Attached Thumbnails
Click image for larger version

Name:	tetristest-01.png
Views:	290
Size:	3.3 KB
ID:	43400  

Last edited by Cylon; 28 February 2015 at 02:41.
Cylon is offline  
Old 28 February 2015, 01:28   #25
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 473
Quote:
Originally Posted by saimon69 View Post
feel like am plying chess with the devil; macros, labels, physical addresses, how a n00b know that, and where they explain it? The most understandable tutorial i found online is the one from labritcho, the AF and CU print stuff follow but not at the same level; however this feels years ahead...

so right now have TED getting stuck at this line with a syntax error:

Code:
DrawBlk{r, g, b, xx+CurPieceX*25 + xiter*25, yy+GhostPieceY*25 + yiter*25, 1}
the called DrawBlk function is actually in this state:
Code:
Function DrawBlk{r, g, b, x, y, faden}

!sharedstuff
 ; Color r, g, b
;  Rect x, y, 24, 24
 ; Color r * fade#, g * fade#, b * faden
;  Rect x + 2, y + 2, 20, 20, 0
;  Line x, y, x+2, y+2
;  Line x, y+23, x+23, y+23
;  Line x+1, y+22, x+22, y+22
;  Line x+22, y+1, x+22, y+22
;  Line x+23, y, x+23, y+23
End Function
[EDIT] ok i see your structure and how you handled DrawBlk trying to do the same now...
The DrawBlk{} is a statement (=Command with no return value), not a function.
it should look (in my adaption) like this:
Code:
._DrawBlk    
Statement DrawBlk {col, x, y, fade}
!myshared

  ;Color r, g, b
  ;Rect x, y, 24, 24
  Boxf x,y,x+24,y+24,col

  ;Color r * fade, g * fade, b * fade
  ;Rect x + 2, y + 2, 20, 20, 0

  ;we donot support shaded faces yet
  ;Line x, y, x+2, y+2           ,col
  ;Line x, y+23, x+23, y+23      ,col
  ;Line x+1, y+22, x+22, y+22    ,col
  ;Line x+22, y+1, x+22, y+22    ,col
  ;Line x+23, y, x+23, y+23      ,col
End Statement
You have to understand the difference between a function and a statement:

A statement is a command:
Code:
PRINT A
.
A function is a request:
Code:
whatis = Len ("example")
.
Cylon is offline  
Old 28 February 2015, 01:59   #26
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 473
As i mentioned before, we cannot (easily) use 24 bit rgb gfx within Blitzbasic2 while keeping the look&feel of BASIC.
So thats the reason why i try to avoid to much specific code and keep the src understandable.

I suggested to chg the Piece/Color behavior to use indexed color entries, so we don't use calls like this

Code:
Statement DrawBoardBlocks{}
  ;draw blocks
  Origin OrigBoardX, OrigBoardY
  For yiter = 0 To 22
    For xiter = 0 To 9
      If Board(xiter, yiter) <> 0
        r = BlockColor(Board(xiter, yiter), 0)
        g = BlockColor(Board(xiter, yiter), 1)
        b = BlockColor(Board(xiter, yiter), 2)
        DrawBlk{r, g, b, xiter*25, yiter*25, .25}
      EndIf
    Next
  Next
End Statement
we use
Code:
Statement DrawBoardBlocks{}
!myshared
  ;draw blocks
  !Origin {OrigBoardX, OrigBoardY} ;xx,yy

  For yiter = 0 To 22
    For xiter = 0 To 9
      If Board(xiter, yiter) <> 0

        col=Board(xiter, yiter)

        DrawBlk{col,xx+ (xiter*25),yy+ (yiter*25), .25}
      EndIf
    Next
  Next
End Statement
We avoid double switch from Piece>ArrayOfColors>GetCols>DrawBoxes.
Instead we do a Piece>Col=Piece>DrawBoxes.
The colors are set in the Startup; we use a Screen with max 256 cols, but we don't need that much colors (yet ) , so 16 or 32 colors are enough for now.

Ok. so, when we want to use indexed colors (and not 24bit truecolor), we have to define those colors somehow. That's how we do it:

Code:
;now let`s reshape the color behaviour
;we are NOT using RGB values To draw, we don`t Use this 24bit system.
;instead, we draw with index colors.

;NOTE: the first 7 constants are the very first in the formerly known BlockColor() array. this is for easy nderstanding only.
#cyellow   =1    ; 255, 255, 0     ;yellow
#cturquoise=2    ;   0, 128, 255   ;turquoise
#cblue     =3    ;   0,   0, 255   ;blue
#corange   =4    ; 255, 128, 0     ;orange
#cred      =5    ; 255,   0, 0     ;red
#cgreen    =6    ;   0, 255, 0     ;green
#cpurple   =7    ; 128,   0, 255   ;purple
;more cols added
#cwhite    =8    ; 255, 255, 255   ;white
#cgrey50   =9    ; 128, 128, 128   ;grey 50%
#cblack    =10   ;   0,   0, 0     ;black
#cgrey25   =11   ;  64,  64, 64    ;grey 25% ghostpiece color

._DataRead
;read in block color data
;Please DIM the BlockColor() to maxcols!
Restore _colsdat
Read maxcols
For iter = 1 To maxcols
  Read BlockColor(iter, 0)
  Read BlockColor(iter, 1)
  Read BlockColor(iter, 2)

  AGAPalRGB 1,iter, BlockColor(iter, 0),BlockColor(iter, 1),BlockColor(iter, 2)
Next
Use Screen1
ShowPalette 1

._colsdat
Data 11         ;maxcols
Data 255, 255, 0;yellow
Data 0, 128, 255;turquoise
Data 0, 0, 255  ;blue
Data 255, 128, 0;orange
Data 255, 0, 0  ;red
Data 0, 255, 0  ;green
Data 128, 0, 255;purple
;more cols added
Data 255,255,255;white
Data 128,128,128;grey 50%
Data 0,0,0      ;black
Data 64,64,64   ;grey 25% for ghostpiece
Fine.
Now whenever we find a Color rr,gg,bb call in the original source, we try to replace it:
Code:
Statement PrintGameOver{}
!myshared
  !Origin {OrigMessAreaX, OrigMessAreaY} ;> xx, yy

  ;Color 255, 0, 0 ;this is blue (is it?)
  Text {xx+ 150,yy+ 50, "Game Over",#cred}; True, True

  ;Color 255, 255, 0 ;this is orange
  Text {xx+ 150,yy+ 100, "Press 'N' to",#corange}
  Text {xx+ 150,yy+ 120, "start a new game.",#corange}
  Text {xx+ 150,yy+ 230, "Press ESC to quit.",#corange}

End Statement
Note:
All #constants are available within the entire source without taking care of local/global/shared etc.; so if you want to use a colorpen try to use e.g. #cwhite for use with Boxf or whatever.

Last edited by Cylon; 28 February 2015 at 02:24.
Cylon is offline  
Old 28 February 2015, 02:11   #27
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 473
The (new) Text{} statement used to replaced the given Text .... is as follows:

Code:
Statement Text {x,y,txt$,col}
 If Len(txt$)>0
   WindowOutput1
   WLocate x,y
   WColour col,0
   Print txt$
 EndIf
End Statement
We donot care (yet) about the additional options, which might be inverse printing or whatever (i don't know).
Cylon is offline  
Old 28 February 2015, 03:08   #28
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 473
Quote:
Originally Posted by saimon69 View Post
feel like am plying chess with the devil; macros, labels, physical addresses, how a n00b know that, and where they explain it? The most understandable tutorial i found online is the one from labritcho, the AF and CU print stuff follow but not at the same level; however this feels years ahead...
Get a time machine, use it, buy the full package and read the manual. Or, download the manual from somewhere and read it. READ IT. Then start messing around with the examples on the disks. Use the debugger alot.
Those things.
Cylon is offline  
Old 03 March 2015, 01:39   #29
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,568
hope to find time tonight to work more
saimon69 is online now  
Old 05 March 2015, 20:29   #30
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 473
Quote:
Originally Posted by saimon69 View Post
hope to find time tonight to work more
Try to understand, what it does and why it fails. When the debugger stops (once you've got it running) then hit 'e' to enter a variable you need to know its value, hit 's' to step run forward. That way you can follow a variable change during program flow.
Cylon is offline  
Old 05 March 2015, 21:14   #31
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,568
Quote:
Originally Posted by Cylon View Post
Try to understand, what it does and why it fails. When the debugger stops (once you've got it running) then hit 'e' to enter a variable you need to know its value, hit 's' to step run forward. That way you can follow a variable change during program flow.
Well since still does not compile i see there is a good amount of stuff to do there...
saimon69 is online now  
Old 06 March 2015, 21:05   #32
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 473
Keep the pace up...

Here's my raw version, AA workbench screen (to clone) required. it is very hard to play, bcause of the timing and flickering, but it works.
start with "n",
cursor keys left right to move piece,
"x" + "c" to rotate,
ESC for end.
I hope it is encouraging for you.

p.s.:i've got fade/shade support for drawblk here; don't use it without surrounding framework!
Code:
._DrawBlk
Statement DrawBlk {col, x, y, fade}
  !myshared

  Boxf x,y,x+24,y+24,col

  If fade>0 AND col<8

    col+#cfadeofs

    Boxf x+2,y+2,x+22,y+22,col

    Line x, y, x+2, y+2           ,col
    Line x, y+23, x+23, y+23      ,col
    Line x+1, y+22, x+22, y+22    ,col
    Line x+22, y+1, x+22, y+22    ,col
    Line x+23, y, x+23, y+23      ,col

  EndIf
End Statement
Code:
._colsdat
Data 18         ;maxcols
Data 255, 255, 0;yellow
Data 0, 128, 255;turquoise
Data 0, 0, 255  ;blue
Data 255, 128, 0;orange
Data 255, 0, 0  ;red
Data 0, 255, 0  ;green
Data 128, 0, 255;purple
;more cols added
Data 255,255,255;white
Data 128,128,128;grey 50%
Data 0,0,0      ;black

Data 64,64,64   ;grey 25% for ghostpiece

;11+ fade colors
Data 64, 64, 0;yellow    25%
Data 0, 32, 64;turquoise 25%
Data 0, 0, 64  ;blue      25%
Data 64, 32, 0;orange    25%
Data 64, 0, 0  ;red       25%
Data 0, 64, 0  ;green     25%
Data  32, 0, 64;purple    25%
Code:
._Dims
;set up arrays
Dim Board (9, 22)
Dim BlockColor (99, 2) ;99 cols is enough?!? we use them as color index
Dim Piece (28, 3, 3)
Dim LineToErase (4)

;now let`s reshape the color behaviour
;we are NOT using RGB values To draw, we don`t Use this 24bit system.
;instead, we draw with index colors.

#cyellow   =1    ; 255, 255, 0     ;yellow
#cturquoise=2    ;   0, 128, 255   ;turquoise
#cblue     =3    ;   0,   0, 255   ;blue
#corange   =4    ; 255, 128, 0     ;orange
#cred      =5    ; 255,   0, 0     ;red
#cgreen    =6    ;   0, 255, 0     ;green
#cpurple   =7    ; 128,   0, 255   ;purple
;more cols added
#cwhite    =8    ; 255, 255, 255   ;white
#cgrey50   =9    ; 128, 128, 128   ;grey 50%
#cblack    =10   ;   0,   0, 0     ;black
#cgrey25   =11   ;  64,  64, 64    ;grey 25% ghostpiece color

#cfadeofs  =11   ;this is the offset for fade colors!

._DataRead
;read in block color data
Restore _colsdat
Read maxcols
For iter = 1 To maxcols
  Read BlockColor(iter, 0)
  Read BlockColor(iter, 1)
  Read BlockColor(iter, 2)

  AGAPalRGB 1,iter, BlockColor(iter, 0),BlockColor(iter, 1),BlockColor(iter, 2)
Next
Use Screen1
ShowPalette 1
Attached Thumbnails
Click image for larger version

Name:	tetristest-02.png
Views:	287
Size:	3.4 KB
ID:	43487   Click image for larger version

Name:	tetristest-03.png
Views:	258
Size:	5.2 KB
ID:	43497  
Attached Files
File Type: lha tetristest_eab.lha (22.7 KB, 155 views)

Last edited by Cylon; 07 March 2015 at 02:54. Reason: pic added
Cylon is offline  
Old 06 March 2015, 21:49   #33
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 473
Quote:
Originally Posted by saimon69 View Post
..
so right now have TED getting stuck at this line with a syntax error:

Code:
DrawBlk{r, g, b, xx+CurPieceX*25 + xiter*25, yy+GhostPieceY*25 + yiter*25, 1}
...
[EDIT] ok i see your structure and how you handled DrawBlk trying to do the same now...
If this is still one of the holdbacks please have a look at all the places you actually call DrawBlk{} (use the search menu):
When your Statement is of Statement {var1,var2,var3,var4} then you have to call it also with 4 values to work with.
Syntax errors are sometimes hard to find because it can be a very tiny simple thing, like using a ',' instead of a ':' .
Cylon is offline  
Old 13 March 2015, 07:54   #34
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,568
going further on writing: this line
Code:
ScreenTags1,"tetris test",#LikeWorkbench,True,#Width,800,#Height,600,#Dpth,8,#AutoScroll,True,0,0
is giving me a "constant not found" error on ScreenTags1.
Did i mention i am using blitz v2.10, if that is important?
saimon69 is online now  
Old 14 March 2015, 00:44   #35
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 473
Quote:
Originally Posted by saimon69 View Post
going further on writing: this line
Code:
ScreenTags1,"tetris test",#LikeWorkbench,True,#Width,800,#Height,600,#Dpth,8,#AutoScroll,True,0,0
is giving me a "constant not found" error on ScreenTags1.
Did i mention i am using blitz v2.10, if that is important?
No, it is not. Just make sure you avoid typos or other errors.
The Constants are case sensitive and should look like this:
Code:
 
  #Width        =$80000023
  #Height       =$80000024
  #Dpth         =$80000025
  #Typ          =$8000002D
  #DisplayID    =$80000032
  #Overscan     =$80000034
  #AutoScroll   =$80000039
  #LikeWorkbench=$80000047
Double check if needed.
Cylon is offline  
Old 16 March 2015, 18:17   #36
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,568
Is still early since this thing not even compile yet but would adapt it to ruin in a 320x256 window using graphic tiles. how complicated will be to adapt everything?
saimon69 is online now  
Old 17 March 2015, 21:56   #37
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 473
Quote:
Originally Posted by saimon69 View Post
Is still early since this thing not even compile yet but would adapt it to ruin in a 320x256 window using graphic tiles. how complicated will be to adapt everything?
It is not complicated, but if it doesn't run it makes no sense at all to try converting the src to a different environment.

If it does not compile, try to start over new only with the few lines to create the screen with a window and a MouseWait:end.

Don't do anything else until you have a screen you can rely on.
Cylon is offline  
Old 18 March 2015, 02:00   #38
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,568
have two IF NOT statementname{} THEN condition that the compiler don't like in the main loop [no, using If NOT (return from)stetementname{} seems not to work] and also a problem with the milliseconds() constant that is used for some calculations; i disabled it so far but wonder if that can give me problems.
saimon69 is online now  
Old 18 March 2015, 07:47   #39
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,568
update: i reach compilation! I commented the if not that was giving me trouble and now am in an empty screen.
Now am going to add the colors and other stuff that were not included first.
saimon69 is online now  
Old 18 March 2015, 23:08   #40
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,642
Moved this thread to the Coders.Languages forum. Please post in the designated forums in future. Carry on
Photon is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tutorials for Amiga Blitz Basic 2? Kenan support.Other 2 19 July 2013 23:27
amiga and old blitz basic prog - please help brian hills support.Other 7 05 October 2009 01:56
Wanting to learn Blitz Basic on real Amiga Adropac2 request.Other 20 20 August 2008 07:30
blitz basic petza request.Apps 11 08 April 2007 01:49
Blitz Basic 2 LaundroMat Retrogaming General Discussion 5 24 July 2001 08:10

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 21:48.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10035 seconds with 13 queries