English Amiga Board


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

 
 
Thread Tools
Old 12 April 2015, 01:23   #61
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 471
Be aware of the fact that you have to change the ProcessInputs{} func (and main) a little bit.
On Amiga, retrieving keyboard input is a different story once you try to do this by yourself, means hardware banging. Blitz (Amiga) offers this way as well, while Blitz (PC) seems to handle keyboards more abstract.
While this Tetris conversion is system friendly, we have to use the system way, which is widely supported by Blitz: Window Events (thats why i added a backdrop window in the first place).
Cylon is offline  
Old 16 April 2015, 00:25   #62
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,529
So to make sure i tested again yesterday:
run -> CTRL-ALT-C then press E ->guru
run -> CTRL-ALT-C then press EVAL on screen ->guru

tried to modify stuff on my own, changed forever in until GhostPieceY+yiter >22,
now pieces show on board only if blue and don't go down, it stays stuck on top;

i tihnk is depending from the update, based on millisecs on original, i changed to ticks
and also added some old goodie debug strings but it seems the cycle is not even reaching it.

Source attached here:
tetris_am297.bb2.txt

Last edited by saimon69; 16 April 2015 at 08:49.
saimon69 is offline  
Old 16 April 2015, 22:59   #63
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 471
Quote:
Originally Posted by saimon69 View Post
So to make sure i tested again yesterday:
run -> CTRL-ALT-C then press E ->guru
run -> CTRL-ALT-C then press EVAL on screen ->guru

tried to modify stuff on my own, changed forever in until GhostPieceY+yiter >22,
now pieces show on board only if blue and don't go down, it stays stuck on top;

i tihnk is depending from the update, based on millisecs on original, i changed to ticks
Hm, you did a lot of things in there that are not nice.
First of all: You are using RawStatus for reading keyboard inputs. This works, if it works at all, only in an emulator. Normally this is only allowed in Blitzmode (Blitzkeys On). In UAE i can read the key pressed except the N, sometimes. Blitzmode on the other hand requires a display, which we dont have as we have a system "display" in use: a Screen.

That is why i mentioned window events for reading the keyboard.
I can run your code without Guru or anything (in UAE), only the overflow occurs because you never use Resettimer to reset Ticks back to 0 (i put it for now in your src in the main loop, cant remember now for sure if this is the right spot). Also all timing values have to be much smaller, because we are counting ticks, which are not 1/1000 of a sec but only 1/50 of a sec.

I attached your src with some small changes and comments (search for Cylon).
It still doesn't run as needed, but you'll find some places to get your hands dirty
I will have to check my converted src again to give you some more clues at the upcoming weekend.
Attached Thumbnails
Click image for larger version

Name:	eab_tetris_sshot0.png
Views:	247
Size:	252.9 KB
ID:	43985   Click image for larger version

Name:	eab_tetris_sshot1.png
Views:	254
Size:	84.3 KB
ID:	43986  
Attached Files
File Type: txt tetris_eab_edit0.bb.txt (18.5 KB, 132 views)
Cylon is offline  
Old 17 April 2015, 07:42   #64
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,529
The RawStatus part i took it form LabRitcho tutorials when at first i started to port the game; i assumed were good to use even for normal mode.
saimon69 is offline  
Old 18 April 2015, 02:14   #65
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 471
Quote:
Originally Posted by Cylon View Post
"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{}

Updated this.

I will post main and processinputs{} tomorrow(tday?) to get you kickstarted. i did not plan to look at my src again until you get it running and we can start fixing and optimizing but who cares
Cylon is offline  
Old 19 April 2015, 21:01   #66
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 471
tetris main and processinputs + some framework

Here is the snipd src from my conversion (03-07-15) regarding keyb input and input handling.
Please note that there are still bugs, e.g. faded blocks and timing and so on.
I hope it helps, anyway.
Please keep me noticed if you encounter problems.

(Please note i have removed lines that are already known to make it easier to find what you are looking for).
First startup:
Code:
;tetris clone example code


;by WolRon

;converted for blitz2(the AMIGA) by Cylon(at)eab

WBStartup
;SetErr:End:End SetErr
.
.init

DEFTYPE.l        ;make sure all boolean vars are real fix (0/-1)!!


;set up graphics
;Graphics 800, 600
;SetBuffer BackBuffer()

; 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!!!
._Display
 ScreenTags1,"tetris test",#LikeWorkbench,True,#Width,800,#Height,600,#Dpth,5,#AutoScroll,True,0,0
 Window1,0,0,800,600,$1900,"",2,1
 ScreensBitMap1,1
 WindowOutput1      ;Print to window

._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)


._DataRead
;
._SetOrigins

EndOfGame = True

._DefKeys
;declare keys
;--------------------------------------------

;keyboard constants

#KEY_BSP=8   ;backspace
#KEY_RET=13  ;return

#KEY_ESC=27  ;escape

#KEY_CUP=28  ;cursor up
#KEY_CDN=29  ;cursor down
#KEY_CRT=30  ;cursor right
#KEY_CLT=31  ;cursor left

#KEY_DEL=127
#KEY_HLP=139

#KEY_F1 =129
#KEY_F2 =130
#KEY_F3 =131
#KEY_F4 =132
#KEY_F5 =133
#KEY_F6 =134
#KEY_F7 =135
#KEY_F8 =136
#KEY_F9 =137
#KEY_F10=138

;keyboard QUALIFIERs (extra keys)

#q_none    =$ 0
#q_caps    =$ 4
#q_control =$ 8

#q_shiftl  =$ 1
#q_shiftr  =$ 2

#q_altl    =$10
#q_altr    =$20

#q_amigal  =$40
#q_amigar  =$80
;--------------------------------------------
;adapt my constants to org src

KeyEsc         =#KEY_ESC  ;=27
KeyPause       =Asc("p")
KeyRotate      =Asc("x")
KeyRotateLeft  =Asc("c")
KeyLeft        =#KEY_CLT  ;=31
KeyRight       =#KEY_CRT  ;=30
KeyDwn         =#KEY_CDN  ;=29
KeyInstantDrop =32        ;" " ;space
KeyN           =Asc("n")
KeyQ           =Asc("q")

._Macros
...
Code:
.funcs
._EraseBoard
Statement EraseBoard{}
!myshared
  ;erase board

  !Origin {OrigBoardX, OrigBoardY + 75}

  ;Color 255, 0, 0                 ;red
  ;Rect -3, -3, 255, 505, 0
  Boxf xx-2,yy-2,xx+254,yy +504,#cblack
  Box xx-3,yy-3,xx+255,yy +505,#cred

End Statement
Note: EraseBoard{} was added to avoid entire clear and redraw of screen (see main).
Code:
._DropPiece
Function DropPiece{}
!myshared
  For yiter = 3 To 0 Step -1
    For xiter = 0 To 3
      If Piece(CurrentPiece + (CurPieceRot * 7), xiter, yiter) <> 0
        If CurPieceY+yiter+1 > 22 Then Function Return False
        If Board(CurPieceX+xiter, CurPieceY+yiter+1) <> 0 Then Function Return False
      EndIf
    Next
  Next
  CurPieceY = CurPieceY + 1
  CalcGhostPosition {}
  Function Return True
End Function

._PlacePiece
Function PlacePiece{}
!myshared
  ;Local outofbounds
  For yiter = 0 To 3
    For xiter = 0 To 3
      If Piece(CurrentPiece + (CurPieceRot * 7), xiter, yiter) <> 0
        Board(CurPieceX+xiter, CurPieceY+yiter) = CurrentPiece
        If CurPieceY+yiter < 3 Then outofbounds = True;above the 10x20 playing area
      EndIf
    Next
  Next
  If outofbounds Then Function Return False
  ;check if any lines were created
  CheckForLines {}
  If NOT ClearLines
    ResetPiece{}
  EndIf
  Function Return True
End Function
...
Now, the ProcessInputs{}:
Code:
._ProcessInputs
Statement ProcessInputs{ev.l}
!myshared

  If ev = $400  ;keyboard event
  ;Stop      ;or BeepScreen!
  ;BeepScreen1

  inp.w=Asc(Inkey$)   ;get input from window (!)

  If NOT EndOfGame

    Select inp          ;switch keys

      Case KeyRotate     :RotatePiece{False} ;space key or X key
      Case KeyRotateLeft :RotatePiece{True}; C key (Z key)

      Case KeyInstantDrop:CurPieceY = GhostPieceY
      Case KeyEsc        :End

      Default

        ;If (NOT KeyLeft) AND (NOT KeyRight)
        If inp = NOT (KeyLeft OR KeyRight)

          RepeatDelay = True
        Else
          If RepeatSpeed < NowTime
            If RepeatDelay
              RepeatSpeed = NowTime + 50 ;150
              RepeatDelay = False
            Else
              RepeatSpeed = NowTime + 10 ;30
            EndIf

            If inp = KeyLeft  Then MoveLeft{}
            If inp = KeyRight Then MoveRight{}

          EndIf
        EndIf

        If (inp = KeyEsc) OR (inp = KeyPause)

          If GamePaused
            ;Stop
            GamePaused = 0
            LastDropTime = LastDropTime + Ticks - PauseTime ; MilliSecs() - PauseTime
          Else
            GamePaused = True
            PauseTime = Ticks ;MilliSecs()
          EndIf
        EndIf

    End Select
  Else  ;EndOfGame
    Select inp
      Case KeyQ          :EndGame{}  ;quit game
      Case KeyN          :StartNewGame{}  ;new game
      Case KeyEsc        :End
    End Select
  EndIf
  EndIf ;ev
End Statement
As you can see i've added an argument to the statement call! This argument is provided from within the main routine:
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   Main Game loop   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.main
DrawInfo{}
ResetTimer
Repeat
  Delay_5;make it a levelspeed-loop!
;:Cls
  EraseBoard{}
  DrawBoard{}

  If GamePaused
    DrawPauseMessage{}
  Else
    DrawBoardBlocks{}
    DrawNextPiece{}
    If NOT ClearLines
      If NOT EndOfGame Then DrawGhostPiece{}
      DrawCurrentPiece{}
    EndIf
  EndIf

  ProcessInputs{Event}

  If EndOfGame=0
    If ClearLines=0
      If GamePaused=0
        If Inkey$=Chr$(KeyDwn)  ;****
          DropDelay = 35
        Else
          DropDelay = DropSpeed
        EndIf

        NowTime = Ticks; MilliSecs()

        If (NowTime > LastDropTime + DropDelay) OR KeyInstantDrop
          LastDropTime = NowTime
          If NOT DropPiece{}
            If NOT PlacePiece{}
              EndGame{}
            EndIf
          EndIf
        EndIf

      EndIf
    Else
      LineClearer{}
    EndIf
  Else
    PrintGameOver{}
  EndIf

  ;Flip no dbuffer
Until exit;Esc key
.mloop
.
End
;;;;;;;;;;;;;;;;;;;;;;;;;;;;   End of main loop   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
._colsdat

._piecedat
;piece descriptions

.eof
The Event in main is the key part. It provides any input coming from mouse, keyboard, windowhandling and so on. You just have to filter what is coming in. We do this in processinputs{} by looking only for $400 type events, which are keyboard inputs.
Please also note the reduced timing values in main and processinputs{}!

(w.i.p.)

Last edited by Cylon; 25 April 2015 at 04:24.
Cylon is offline  
Old 21 April 2015, 10:56   #67
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,529
After i managed this code the program reached a playable state, finally: will post pics when possible
saimon69 is offline  
Old 25 April 2015, 03:23   #68
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,529
now i an starting to think to phase 2:
-change playfield size to 20x10
-insert a level counter
-remove the showghost
-create variables to handle tiles size
-change graphic to use graphic pieces rather than draw objects
and bring it to lores
-find a way to feed a map, check on the number of a certain type of block and then switch level when reached
saimon69 is offline  
Old 25 April 2015, 03:48   #69
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 471
Quote:
Originally Posted by saimon69 View Post
now i an starting to think to phase 2:
-change playfield size to 20x10
-insert a level counter
-remove the showghost
-create variables to handle tiles size
-change graphic to use graphic pieces rather than draw objects
and bring it to lores
-find a way to feed a map, check on the number of a certain type of block and then switch level when reached
Hm, gettin' cocky?
Level counter is present, you want to chg it?
Showghost is a hint to the player, you might remove it but it will make the game more original. My blesses for this.
LowRes for the game requires to understand how things are done the way they are.
The rest is blurry.

Why not try to chg the game as it now appears to be more like the original one?
ToDo:
- text font is different,
- text display is not using all opts,
- glitches in display,
- no dbl buffer,
- drwblocks are not like the original (fade etc.),
- esc/quit handling doesn't work properly,
- gamespeed needs adaption to ticks(/per level...)
- ....

- what about game controllers?
Cylon is offline  
Old 27 April 2015, 02:53   #70
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,529
@cylon2
My final purpose is to arrive to have something like [ Show youtube player ] but yeah i need to put more my hands on the original source and i still dont know enough

so i said levels but i would have meant stages

I however can start to work to abstract and use lowres and shapes, that i have already some artwork

Last edited by saimon69; 27 April 2015 at 03:01.
saimon69 is offline  
Old 27 April 2015, 03:12   #71
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 471
Quote:
Originally Posted by saimon69 View Post
@cylon2
My final purpose is to arrive to have something like [ Show youtube player ] but yeah i need to put more my hands on the original source and i still dont know enough

so i said levels but i would have meant stages

I however can start to work to abstract and use lowres and shapes, that i have already some artwork
Oh, i see. Nice idea and not hard to do btw...
But as you said you have to know the src you are working on. Otherwise you'll never find bugs or adapt it perfectly to your needs.
Cylon is offline  
Old 05 May 2015, 00:12   #72
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,529
So i started to change a bit stuff around; i added some constants for area width and height , block width and height (needed if i want to make this thing run in low-res) and started to implement it; i also changed keys a bit so that now rotate happens also with cursor up; next am gong to clear the "next piece" area just before a new piece is shown...
saimon69 is offline  
Old 09 May 2015, 09:52   #73
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,529
Added a new statement to clean up the next piece since was leaving trails of the old ones, as above.

Now am thinking how could i clean up the top area, probably with an if vertical position < startareaY or similar
(the next piece part has already been cleaned up)

Click image for larger version

Name:	blitztetris34.jpg
Views:	221
Size:	62.0 KB
ID:	44150
saimon69 is offline  
Old 10 May 2015, 01:19   #74
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 471
Your text areas are messed up. I advice to clean up all mess and bugs before adding new features. ;-)
Cylon is offline  
Old 13 May 2015, 07:15   #75
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,529
I moved the texts around, now the white block on pause seems not align properly to the text:
Code:
Boxf 80+xx,70+yy,140+xx,60+yy,#cwhite
text{150+xx,100+yy,"Paused",#cyellow}
i found also a bug in ResetPiece where the random seed was 6 and not 7 so T piece never appeared

Last edited by saimon69; 13 May 2015 at 07:21.
saimon69 is offline  
Old 15 May 2015, 21:14   #76
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 471

Keep going...
Cylon is offline  
Old 16 May 2015, 01:40   #77
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,529
Yuo were telling me about double budffering; i did gave a fast look in the manual but is not that clear; do i really need to write alternatively on two screns and swap the data or there is some automatism that will help me on that?

(thinking further i could just write in the hidden screen and then show its content in the main one, but still is not clear the how to me, yet)
saimon69 is offline  
Old 16 May 2015, 02:13   #78
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 471
If you are still going with the system display the dbl buffer display can be done by:

a: make the game's screen (and window) double in height and swap ypos of that screen;
b: open another screen (and windows) and swap those as needed;
c: draw everything into memory and draw that memory block to screen.
d: ...
e: ...

...Well, 50 times a second, if possible.
Cylon is offline  
Old 16 May 2015, 02:23   #79
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,529
honestly, considered the time to redraw, even 12 times/second at that resolution should be decent, for lo-res at least 25
saimon69 is offline  
Old 16 May 2015, 02:58   #80
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 471
Quote:
Originally Posted by saimon69 View Post
honestly, considered the time to redraw, even 12 times/second at that resolution should be decent, for lo-res at least 25
Please go on with this goal.
Cylon 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 20:55.

Top

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