12 April 2015, 01:23 | #61 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 481
|
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). |
16 April 2015, 00:25 | #62 |
J.M.D - Bedroom Musician
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,663
|
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. |
16 April 2015, 22:59 | #63 | |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 481
|
Quote:
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. |
|
17 April 2015, 07:42 | #64 |
J.M.D - Bedroom Musician
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,663
|
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.
|
18 April 2015, 02:14 | #65 | |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 481
|
Quote:
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 |
|
19 April 2015, 21:01 | #66 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 481
|
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 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 ... 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 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 Please also note the reduced timing values in main and processinputs{}! (w.i.p.) Last edited by Cylon; 25 April 2015 at 04:24. |
21 April 2015, 10:56 | #67 |
J.M.D - Bedroom Musician
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,663
|
After i managed this code the program reached a playable state, finally: will post pics when possible
|
25 April 2015, 03:23 | #68 |
J.M.D - Bedroom Musician
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,663
|
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 |
25 April 2015, 03:48 | #69 | |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 481
|
Quote:
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? |
|
27 April 2015, 02:53 | #70 |
J.M.D - Bedroom Musician
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,663
|
@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. |
27 April 2015, 03:12 | #71 | |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 481
|
Quote:
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. |
|
05 May 2015, 00:12 | #72 |
J.M.D - Bedroom Musician
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,663
|
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...
|
09 May 2015, 09:52 | #73 |
J.M.D - Bedroom Musician
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,663
|
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) |
10 May 2015, 01:19 | #74 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 481
|
Your text areas are messed up. I advice to clean up all mess and bugs before adding new features. ;-)
|
13 May 2015, 07:15 | #75 |
J.M.D - Bedroom Musician
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,663
|
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} Last edited by saimon69; 13 May 2015 at 07:21. |
15 May 2015, 21:14 | #76 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 481
|
Keep going... |
16 May 2015, 01:40 | #77 |
J.M.D - Bedroom Musician
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,663
|
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) |
16 May 2015, 02:13 | #78 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 481
|
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. |
16 May 2015, 02:23 | #79 |
J.M.D - Bedroom Musician
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,663
|
honestly, considered the time to redraw, even 12 times/second at that resolution should be decent, for lo-res at least 25
|
16 May 2015, 02:58 | #80 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 481
|
|
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 |
|
|