18 February 2016, 17:43 | #1 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,356
|
Simple corkscrew scroller in Blitz2
There has been talk in several threads about scrolling techniques, and one which is very promising is the so-called corkscrew scroll. This has been described in depth in depth in http://aminet.net/package/dev/src/ScrollingTrick and some have already investigated its feasibility in Blitz Basic.
Here is a very basic implementation. It scrolls for ten screens using only a bitmap 352 pixels wide and 256+10 pixels high. This exploits the fact that soft scrolling on the Amiga only offsets a starting pointer into a bitplane. Since Blitz's DisplayBitmap command doesn't do any bounds checking (thankfully), it can be incremented beyond the width of the bitmap scrolled, upon which it "wraps around" to the starting position, but one pixel down. So if you allocate an extra pixel in height for your bitmap (for each screenwidth scrollable — in this case ten), the bitmap is offset down, and all you have to do is blit in new background blocks in the currently obscured part of the bitmap (it's two blocks wider than the visible screen), offset one pixel down for each screenwidth scrolled. Thanks to ReadOnlyCat, MrsBeanBag, Shatterhand, Luman and others for discussing this in depth in previous threads. Code:
#BORDER=1 .makron Macro Border CNIF #BORDER=1 MOVE.w #`1,$dff180 CEND End Macro .init DecodeShapes 0,?font ; Incbinned below #SCRWIDTH=320 #BLOCKWIDTH=16 #BMWIDTH=#SCRWIDTH+#BLOCKWIDTH+#BLOCKWIDTH #SCREENS=10 BitMap 0,#BMWIDTH,256+#SCREENS,4 BitMap 1,320,10,1 shapenr=1 Use BitMap 0 For y=0 To 256-16-1 Step 16 For x=0 To (320+16) Step 16 Block shapenr,x,y Next x shapenr+1 Next y BLITZ For i=0 To 15 : PalRGB 0,i,i,i,i : Next i PalRGB 0,1,15,15,15 InitCopList 0,44,240,$14,8,16,0 ; lores, 4 bpl, 8 spr, mjukscroll InitCopList 1,44+240+2,$10,$11,8,2,0 ; lores, 4 bpl, 8 spr, mjukscroll BLITZ ; Enter Blitz mode BitMapOutput 1 ; Write debug info on little screen CreateDisplay 0,1 ; A screen with coplist 0 och 1 DisplayPalette 0,0 ; Use palette for bitmap 0 DisplayPalette 1,0 ; Use palette for bitmap 1 DisplayBitMap 1,1 ; Make debug screen visible .finscroll #VBL=1 #SCROLLSPEED=1 xscroll=16 ; Scroll position, increments infinitely x=0 ; X position for blitting, reset upon each wraparound yoffset=1 ; Y offset for blitting, incremented for each wraparound Repeat VWait #VBL DisplayBitMap 0,0,xscroll,0 If xscroll MOD #BMWIDTH = 0 !Border{$ff0} ; MouseWait shapenr+1 EndIf If x=320+16+16 x=0 yoffset+1 EndIf Locate 0,0 : Print "Xscroll: ",xscroll," X: ",x," yoffset: ",yoffset If xscroll MOD #BLOCKWIDTH = 0 !Border{$f00} ; MouseWait For y=0 To 256-16 Step 16 Block shapenr,x,y+yoffset ;Line x,y+yoffset,x+15,y+yoffset,3 Next y EndIf xscroll+#SCROLLSPEED : x+#SCROLLSPEED Until JoyC(0)=2 End .font IncBin "Data:BB2/font.shapes" Last edited by idrougge; 28 February 2016 at 04:10. |
18 February 2016, 17:51 | #2 |
Phone Homer
Join Date: Jun 2006
Location: 5150
Posts: 5,812
|
Well done you could have commented it
Is it actully any faster than Amos? Why do most examples allways use screen copy when we know this is wrong? : Lot of Flicker on 68000 - id say not better than Amos and about the same on 68020 - but Bobs are better in Blitz 2 but if you animated your Tiles instead of Bobs in Amos you could probably reach the same. Maybe try FBlit with BlockScroll - ill have a look some time but the Blitz 2 Syntax is Yuk! ^ on faster processor - but no need this will work on faster processor Last edited by Retro1234; 18 February 2016 at 19:07. Reason: Back to Back |
18 February 2016, 19:12 | #3 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,356
|
I've only tried it briefly on my A4000 with an LCD screen. No discernible flicker there. But I know from before that AMOS can't really blit an entire row of tiles in one vbl while also printing on the screen.
|
18 February 2016, 19:25 | #4 |
Phone Homer
Join Date: Jun 2006
Location: 5150
Posts: 5,812
|
Flicker only on 68000 -Yeah a whole row is to much on 68000 even in ASM
maybe ask Graham how he did downfull this video is on 68030@40 I uploaded a video of 68000 but my Archos didnt do it justice in the top corner you can see 17 thats 17 Amos waits,Double Buffer Two Wait Vbl, 32 colour and still to fast. If you want ill get you a compiled version at some point [ Show youtube player ] Last edited by Retro1234; 19 February 2016 at 02:29. |
18 February 2016, 20:11 | #5 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 475
|
It is nicely running. but from around xs=8000 and up the bmap gets trashed from the top.
|
19 February 2016, 00:09 | #6 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,356
|
8000? Xscroll should never go that far with the debugger on, only around 3000.
|
19 February 2016, 01:51 | #7 |
Phone Homer
Join Date: Jun 2006
Location: 5150
Posts: 5,812
|
Im not having a go at you but thats a 16 colour screen, scrolling 1 pixel and a 1 colour tile not reading a map and it doesnt work on 68000 not very fast is it.
Last edited by Retro1234; 19 February 2016 at 02:23. |
19 February 2016, 12:58 | #8 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,356
|
Where did I say it was fast? It's a proof-of-concept, not an arcade game.
|
19 February 2016, 13:03 | #9 |
Phone Homer
Join Date: Jun 2006
Location: 5150
Posts: 5,812
|
I know and I wasnt questioning you but where is there an example that Blitz can handle a Map at a good speed?
|
19 February 2016, 13:17 | #10 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,356
|
Not here.
|
19 February 2016, 14:39 | #11 |
Phone Homer
Join Date: Jun 2006
Location: 5150
Posts: 5,812
|
Ok.
|
19 February 2016, 21:08 | #12 |
Amigan - an' lovin' it!!
Join Date: Nov 2010
Location: Nottingham, UK
Age: 55
Posts: 557
|
Good going, idrougge. There was a LOT of discussion about this topic - and other scroll methods too - so another example of a technique is a really interesting read.
@Boo Boo - check The Zone for a proof of concept game I threw together. It has a never-ending scroller that uses a bitmap that is only one block (16 pixels, I think) wider than the display. It also uses BlockScroll to copy a full game screen in one VWait. I'm currently re-writing my GogoPogo game to use the same approach. Blitz should be able to handle this on an A500 (although I've only tested it on an A600). |
19 February 2016, 21:37 | #13 |
Phone Homer
Join Date: Jun 2006
Location: 5150
Posts: 5,812
|
Now that is faster than Amos equivalent
But just use your tiles in his code and change untill it works that should be full hardware scrolling. |
20 February 2016, 10:04 | #14 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,200
|
The point of the corkscrew wrap around isn't speed so much as saving chip RAM.
|
20 February 2016, 10:24 | #15 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 475
|
Yes, the ChipRAM issue is the true problem. Scrollspeed is not an issue with BB2, as Blitz has Copper"scroll" support. I have a horizontal scroller as well, but it uses double width bmaps (16cols) plus a really wide second bmap as parallax background (aga dpf). I have to chg that someday to another 8way-engine, but who has the time...
Last edited by Cylon; 20 February 2016 at 18:31. |
20 February 2016, 10:43 | #16 |
Phone Homer
Join Date: Jun 2006
Location: 5150
Posts: 5,812
|
I think it will work if you build on itl.
|
20 February 2016, 14:37 | #17 | |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,356
|
Quote:
What makes corkscrew quite difficult is not the plain scrolling, but placing your bobs. Position X on the visible screen is not straight-forward to calculate, and once every wrap-around, it is at the end of the bitmap, which requires two partial blits to take the Y offset into account and must also be clipped so that the Blitz debugger doesn't halt because you're blitting outside the bitmap. Last edited by idrougge; 21 February 2016 at 15:47. |
|
20 February 2016, 15:49 | #18 |
Phone Homer
Join Date: Jun 2006
Location: 5150
Posts: 5,812
|
This will work and already works on 68020+
|
20 February 2016, 15:53 | #19 |
Code Kitten
Join Date: Aug 2015
Location: Montreal/Canadia
Age: 52
Posts: 1,178
|
The code looks really good with no extra fluff and is very readable.
I see no reason why Blitz could not handle drawing a full column of tiles every 16 pixels, maybe it is the Also, you should also credit CodeTapper, it was he who first mentioned this technique in the scrolling thread started by Akira. |
20 February 2016, 15:56 | #20 |
Phone Homer
Join Date: Jun 2006
Location: 5150
Posts: 5,812
|
It probably could if you double buffer but change it to one tile per pixel take out the print command and load in megaman x Tiles
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sine scroller | pmc | Coders. Tutorials | 95 | 02 July 2017 16:40 |
Sine scroller - dycp | blazeb | Coders. Asm / Hardware | 6 | 02 May 2012 10:08 |
2d side scroller/ platformer. | Conundrum | Looking for a game name ? | 3 | 27 December 2011 17:33 |
Corkscrew scroller | pmc | Coders. Tutorials | 33 | 01 September 2010 12:41 |
A space 2d multidirectional scroller | dabbler | Looking for a game name ? | 11 | 21 April 2010 06:48 |
|
|