English Amiga Board


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

 
 
Thread Tools
Old 04 September 2019, 18:08   #1
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 36
Posts: 3,342
Vertical Scrolling by blitting outside the bitmap

I've been doing some test with scrolling routines on blitz... I just figured out if you use BLOCK outside the bitmap to blit new tiles to background and keep scrolling outside its boundaries, it just works. The new blocks will show up correctly when the bitmap wraps around, you just have to keep scrolling beyond the boundaries of the bitmap and blitting the blocks outside the bitmap.

Of course you also have to turn off the debugger which won't allow you to do that.

Now I'd guess it won't let you do that for a reason. Blitting outside the bitmap is probably messing with memory addresses that aren't reserved for the Bitmap, so stuff could be overwritten, and this routine would have problems in the long run.

Or am I wrong? Can I just blit "Outside" the bitmap as much as I want, as long as I keep the debugger off?
Shatterhand is offline  
Old 04 September 2019, 18:36   #2
Retro1234
Boo

Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 4,351
I never thought you could Vertically scroll like this, this is basically how you horizontally scroll - It doesnt work in Amos.

I would guess its not a problem and if it works I guess your need to place BOBs right on the crease but that will also cause the Debbuger to halt.

But if the screen just Wraps round you can change your X position to minus e.g 256

When reach End >
Display BLOCK 16,Y,No instead of Bob 272,Y,No

Last edited by Retro1234; 04 September 2019 at 19:02.
Retro1234 is online now  
Old 04 September 2019, 18:42   #3
tolkien
AmigaMan

tolkien's Avatar
 
Join Date: Oct 2012
Location: Castro Urdiales/Spain
Posts: 535
you need to allocate a large bitmap. The way you do it is dangerous cos can overwrite data when blit a block outside the allocate bitmap.
tolkien is online now  
Old 04 September 2019, 18:56   #4
Retro1234
Boo

Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 4,351
Sorry are you saying it works the same as Horizontal scrolling and when you scroll past the Top end of the Bitmap you can see the beginning again?

I never even thought to try this as it doesnt work in Amos and I never heard anyone mention it.

Creating a large Bitmap defeats the purpose of of infant scrolling but some games use it, also of course requires more memory.

Edit; Looking at this http://eab.abime.net/showthread.php?t=96410 its not that easy?

but that might help you.

Last edited by Retro1234; 04 September 2019 at 19:10.
Retro1234 is online now  
Old 04 September 2019, 20:13   #5
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 36
Posts: 3,342
There's a clear difference between doing horizontally and vertically.

Please keep in mind that I barely understand what's the hardware is doing, so forgive me if I say something that sound stupid (The problems of only coding on high-level languages, hehe).

When you do it horizontally, you shoud keep blitting ON the bitmap. When the scrolling reach the end of the bitmap, it "wraps" around but with a vertical 1 pixel offset. You should now block your tiles on position 0 again, but minding the 1 pixel offset. If your bitmap is 320 pixels wide, bliting on pixel 0 or pixel 321 will give the same result except by that 1 pixel offset. So you should just blit on pixel 0 to keep in the boundaries of the bitmap, though I believe you'll still be writing data off the bitmap "reserved memory" because of the vertical offset (You'll need at some point to blit outside the bitmap vertically).

Keep in mind this *does* crash the display at some point if you scroll the bitmap long enough horizontally. I've tested it and I always got the display being trashed at the same point. But if you plan ahead properly, it works.

But you can blit on the "outside" of the bitmap horizontally too and it will work.

Vertically you have no pixel offset when the bitmap wraps, but what you'll see is the bitmap with wrong colors. If you keep scrolling and wraping the bitmap several times you'll get just a lot of garbage on screen. BUT if you blit the new tile on the new position of the bitmap, it works. Say, the bitmap is 240 pixels tall... when it completely wraps, the next tile should be at position Y 241... blit your tile there, and IT WILL SHOW PROPERLY instead of showing garbage if you just let the bitmap wrap around. If you blit "inside" the bitmap (say, on position 0 again), it won't show properly on the bitmap after it has wraped, you'll see just garbled colors with something that resembles the bitmap.

I don't know WHY this works, and I don't know if it *should* be done like this at all. I believe it will also crash the display at some point, and maybe even do worse stuff like maybe overwrite data on memory that's not related to the bitmap/display at all.

That said, I still don't know what's the best way to scroll vertically on Blitz. If this is safe to do (and I really doubt it is), it's certainly a great way.

EDIT: Retro 1234, that thread does have the proper way to do it, doing the copper splits which I read about it. That's probably the right way.

But writing outside the bitmap is SO MUCH EASIER AND FASTER to write

Last edited by Shatterhand; 04 September 2019 at 20:23.
Shatterhand is offline  
Old 04 September 2019, 20:29   #6
Retro1234
Boo

Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 4,351
Interesting.......

Hopefully someone for knowlagable will answer, but if you can, can you try scolling at least twenty screens like this and see what happens.

Also is there not a 1 pixel gap between the wrapping around.

Thanks.

My understanding with the Corkscrew in Blitz is Apparently with initCopList after scrolling 8192 the tiles become out of sync but with Slice it's ok?
Retro1234 is online now  
Old 04 September 2019, 20:56   #7
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 36
Posts: 3,342
Quote:
Originally Posted by Retro1234 View Post
Interesting.......

Hopefully someone for knowlagable will answer, but if you can, can you try scolling at least twenty screens like this and see what happens.

Also is there not a 1 pixel gap between the wrapping around.

Thanks.

My understanding with the Corkscrew in Blitz is Apparently with initCopList after scrolling 8192 the tiles become out of sync but with Slice it's ok?
Oh yeah, I remember someone said it works eternally with slices (Maybe it was even you), but I never tested it.

I believe I actually tested it with more than 20 screens and still worked, but I can't be sure it will keep working when I throw more stuff at the code.
Shatterhand is offline  
Old 04 September 2019, 21:37   #8
Retro1234
Boo

Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 4,351
I think its very Interesting if it works

Yeah I want to try it in Blitz also want to just check if it works in Amos.

I think MickGyver found that Slice works.

I presume earok found a way around the 8192 with initCopList.
Retro1234 is online now  
Old 04 September 2019, 21:59   #9
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 36
Posts: 3,342
Quote:
Originally Posted by Retro1234 View Post
I think its very Interesting if it works

Yeah I want to try it in Blitz also want to just check if it works in Amos.

I think MickGyver found that Slice works.

I presume earok found a way around the 8192 with initCopList.
I was reading Andrew Braybrook's blog, and the way he describes how to do Vertical Scrolling on Amiga is exactly the way your link does it, but in Blitz.

I'd be really surprised if this ghetto "Blit outside bitmap" method is safe and works but no one used it/figured it out back at the time. Unless Blitz Basic does something different that allows this to work.
Shatterhand is offline  
Old 04 September 2019, 22:18   #10
Retro1234
Boo

Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 4,351
Can you link me to Andrew Braybrook's blog.
Retro1234 is online now  
Old 04 September 2019, 22:44   #11
tolkien
AmigaMan

tolkien's Avatar
 
Join Date: Oct 2012
Location: Castro Urdiales/Spain
Posts: 535
You can have a good reading about scroll methods here:
https://aminet.net/package/dev/src/ScrollingTrick

Its C but is well explained.
tolkien is online now  
Old 04 September 2019, 23:46   #12
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 36
Posts: 3,342
Quote:
Originally Posted by Retro1234 View Post
Can you link me to Andrew Braybrook's blog.
http://uridiumauthor.blogspot.com/
Shatterhand is offline  
Old 05 September 2019, 00:20   #13
roondar
Registered User

 
Join Date: Jul 2015
Location: The Netherlands
Posts: 1,294
Just a small, friendly warning: what you're doing will eventually likely crash the Amiga as scrolling the display always also means you're moving through memory*. Once you start seeing 'garbage' on screen (that you overwrite), you're highly likely to be overwriting your own or someone else's program and/or data.

*) That is if you scroll vertically for any distance or horizontally for more than 16 pixels.

The easiest way to scroll vertically in Blitz is probably setting up a screen twice as high as you need it to be and drawing the new tiles you want to uncover on both sides of the visible part of the bitmap as you scroll it. Then, when you reach the 'top' or 'bottom' of the display, you manually wrap it around by resetting the scroll value back to the beginning.

Note this does double the memory cost compared to a non-scrolling screen
Then again, you probably already know this given you're making a screen that scrolls

Vertical scrolling can be done without using all that extra memory by making a copper list that resets the display pointers somewhere down the screen to create a wrapping display (and splitting your bobs as you blit them), but I'm not so sure Blitz supports that in any easy to use way.
roondar is offline  
Old 05 September 2019, 00:28   #14
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 36
Posts: 3,342
Quote:
Note this does double the memory cost compared to a non-scrolling screen
Then again, you probably already know this given you're making a screen that scrolls
Yes Also doubles the amount of blocks you have to blit on screen.

Quote:
Vertical scrolling can be done without using all that extra memory by making a copper list that resets the display pointers somewhere down the screen to create a wrapping display (and splitting your bobs as you blit them), but I'm not so sure Blitz supports that in any easy to use way.
The link Retro1234 shared has an example that shows exactly how to do that. I took a quickly glance at it and I was only able to understand it because of the post you made earlier about how the Copper works



Quote:
Once you start seeing 'garbage' on screen (that you overwrite), you're highly likely to be overwriting your own or someone else's program and/or data.
What's really funny is that's not exactly "garbage", it looks like it's just the bitmap but with its colors garbled. I really don't think this is a safe thing to do, but I would like some confirmation (And of course, understanding what the hell is happening is always interesting too)
Shatterhand is offline  
Old 05 September 2019, 00:36   #15
Retro1234
Boo

Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 4,351
Yeah I would say its not that dangerous as doing very similar horizontally I.e the corkscrew is considered good practice.

it would be interesting to hear from someone experienced in such things, cough cough earok.
Retro1234 is online now  
Old 05 September 2019, 00:37   #16
roondar
Registered User

 
Join Date: Jul 2015
Location: The Netherlands
Posts: 1,294
Quote:
Originally Posted by Shatterhand View Post
Yes Also doubles the amount of blocks you have to blit on screen.
Well, a smart person only blits about a block per frame for the optimal scroller. So that would make it two per frame. Not a big deal really

Quote:
The link Retro1234 shared has an example that shows exactly how to do that. I took a quickly glance at it and I was only able to understand it because of the post you made earlier about how the Copper works
Yup, it did. And happy to be of service.

Quote:
What's really funny is that's not exactly "garbage", it looks like it's just the bitmap but with its colors garbled. I really don't think this is a safe thing to do, but I would like some confirmation (And of course, understanding what the hell is happening is always interesting too)
I just gave you confirmation it's not safe. Would you like me to do so again?

What is happening is that you're moving the bitplane pointers up or down through memory. This has two consequences. The first is that (part of) the display shows up distorted. The second is that part of the display now shows data from outside of the display boundaries as you allocated them.

If you write in those regions by say, using the Block command, then you're writing in unallocated memory. Anything can be there, including code & data belonging to your program or any other program that is running.
Quote:
Originally Posted by Retro1234 View Post
Yeah I would say its not that dangerous as doing very similar horizontally I.e the corkscrew is considered good practice.
Only if you have allocated the required extra space for it, otherwise it actually is dangerous.

For reference, horizontal corkscrew scrolling requires you to allocate one extra line for the display for each screen you scroll horizontally. Vertical scrolling requires you to allocate one extra line for the display for each line you scroll (unless you wrap the display with the Copper, in which case you don't need to allocate extra for vertical scrolling).

Last edited by roondar; 05 September 2019 at 00:43.
roondar is offline  
Old 05 September 2019, 01:25   #17
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 36
Posts: 3,342
Quote:
I just gave you confirmation it's not safe. Would you like me to do so again?
YOLO I LIKE TO LIVE DANGEROUSLY.

Quote:
What is happening is that you're moving the bitplane pointers up or down through memory. This has two consequences. The first is that (part of) the display shows up distorted. The second is that part of the display now shows data from outside of the display boundaries as you allocated them.

If you write in those regions by say, using the Block command, then you're writing in unallocated memory. Anything can be there, including code & data belonging to your program or any other program that is running.
This means I had a lot of free memory still when I did the test

It's true, now that you said it, I remember first time I read about the corkscrew scrolling is that you *should* make the bitamp 1 pixel higher for each screen you would like to scroll.

I actually did this with the corckscrew method:
[ Show youtube player ]


Quote:
Well, a smart person only blits about a block per frame for the optimal scroller. So that would make it two per frame. Not a big deal really
It depends on what you're scrolling and how fast its moving, I guess

Funny side-story to that: I currently work at the same place with my wife (We actually are the owners here), after I saw your post on this thread we went out to grab a snack, as we were walking she saw me doing some funny face or something while I was thinking how I could optimize my current scrolling routine (without overwriting data, mind you ), and she was like "What you're thinking?" and I joking said "I am writing codes on my head", to what she obviously replied "Weirdo". But then she said "Why don't you bring your laptop to work, so on those moments you're just waiting you can write your game for real, instead of in your head?"

Shatterhand is offline  
Old 05 September 2019, 02:00   #18
Retro1234
Boo

Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 4,351
Just a thought can you display a Bob on the crease in the correct colours etc?
Retro1234 is online now  
Old 05 September 2019, 02:08   #19
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 36
Posts: 3,342
Hmm.. I only tried doing blocks and they would fit perfectly either completely inside the bitmap or outside it.

But i believe colours would be correct if I scrolled the crease into screen.
Shatterhand is offline  
Old 05 September 2019, 02:17   #20
Retro1234
Boo

Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 4,351
Sorry if im being a bit of a pest

because there would be a point for example the crease would be in the middle of the screen and a ship or bullet might be flying over it so it would be in both sections.
Retro1234 is online now  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Infinite vertical scrolling LuigiThirty Coders. Asm / Hardware 38 04 January 2017 23:25
Smooth vertical scrolling in AMOS idrougge Coders. AMOS 42 24 January 2016 14:37
Horizontal vs vertical scrolling Akira Coders. General 20 26 October 2015 11:15
[Found: Insanity Fight] Vertical Scrolling Shootemup capehorn Looking for a game name ? 5 13 March 2009 08:18
Vertical scrolling motorcycle game.. Anyone? Thrash75 Looking for a game name ? 11 18 May 2005 19:44

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 22:32.


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