19 August 2018, 22:24 | #1 |
Registered User
Join Date: Aug 2018
Location: england
Posts: 24
|
How to scroll horizontally?
I did a search on the forum but found nothing definite.
I'm just wondering how it is done, just scrolling a single tile map..no parallax, also with sprites on top. I dont want the details in assembly but just an overview of what has to be done. |
19 August 2018, 22:34 | #2 |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,014
|
Basically use the hardware scroll register to scroll 1 pixel at a time. When the hardware scroll register has scrolled 16 pixels, reset the scroll register back to zero and at the same time add 2 to the bitplane pointers, then repeat.
|
19 August 2018, 22:41 | #3 |
Registered User
Join Date: Aug 2018
Location: england
Posts: 24
|
Thanks,
when drawing bobs over the background does the background under the bob have to be saved to memory and then re-drawn each time the bob is drawn? |
19 August 2018, 22:53 | #4 |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,014
|
In most cases yes, unless you use dual playfield mode and then you don't need to, but that comes with some limitations.
|
20 August 2018, 09:12 | #5 |
Registered User
Join Date: Aug 2018
Location: england
Posts: 24
|
oh, so using one playfield for the background basically gives you 'free' (as in almost zero cpu usage) scrolling
then you can draw the bobs on another playfield, wait for the raster to be in the right position, then erase and redraw bobs in their new positions? |
20 August 2018, 10:09 | #6 | |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
Quote:
|
|
20 August 2018, 10:20 | #7 | |
Registered User
Join Date: Aug 2018
Location: england
Posts: 24
|
Quote:
you then draw sprites onto the screen, then copy just areas of the buffer back to the screen which erases the sprites then draw sprites again I guess that would be faster, as you dont have to work out how many bits a background graphic has been shifted by scrolling? But then, wouldnt you have to copy the whole screen to a buffer each frame? |
|
20 August 2018, 10:34 | #8 | |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
Quote:
You dont have to copy thr whole screen, you just blit in the tiles in the pristine buffer exactly as you do for the onscreen buffers. |
|
20 August 2018, 10:52 | #9 |
Registered User
Join Date: Aug 2018
Location: england
Posts: 24
|
ok so lets say you:
copy tiles onto the screen copy same tiles to the buffer draw bobs then the scroll register is incremented by one so now on the screen the display has been shifted by one bit so now copying the buffer to the screen has to be shifted by one bit Alternatively: copy tiles to screen draw bobs scroll by one pixel draw tiles to screen shifted by one pixel (only where bobs are) for both methods you would have to calculate the parts of the screen that have to be redrawn, so im not sure why the buffer method is faster? |
20 August 2018, 11:02 | #10 | |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
Quote:
|
|
20 August 2018, 12:35 | #11 | |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,430
|
Quote:
It's faster because you only need to blit once (and thus only have to calculate the blitter register values once). Blitting from the tile map would mean fetching each of the tile addresses from the map and then blitting once for every tile the bob overlaps. This is a more complicated algorithm, which potentially restarts the blitter multiple times. So, while the blitter itself will spend the same time for both copies, the CPU will be spending quite a bit more time. |
|
20 August 2018, 12:38 | #12 |
Registered User
Join Date: Aug 2018
Location: england
Posts: 24
|
yes, so the second method would be
storing each tile position so lets say a tile is 16x16 then storing the offset 0 to 15 then just drawing tiles onto the screen at the correct offset, where the bobs were. Just wondering why this would be slower than copying the buffer. It could be because the area might cover 5 tiles and then you would have to: start and stop 5 times, fetch different tiles, and other calculations. I could imagine that being slower than just doing one copy. |
20 August 2018, 13:52 | #13 | ||
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,430
|
Quote:
Since the blitter always updates 16 bits/pixels at a time, this means that restoring bobs never needs to include any pixel offsets. It is enough to know which words the bob that needs be be restored covered in the bitmap. Quote:
A small bit of psuedocode might help here to show why it's always slower. First up, using a pristine restore buffer: Blit: Code:
bitmap = get_destination_bitmap_address(); // Destination bitmap for drawing bobs For each bob do { calculate_destination_byte_offset(); restore_offset[bob]=destination_byte_offset; destination_address=bitmap+destination_byte_offset; calculate_rest_of_blitter_values(mode_cookiecut); blit_bob(); } Code:
bitmap = get_destination_bitmap_address(); // Destination bitmap for restoring bobs For each bob do { destination_address=bitmap+restore_offset[bob]; calculate_rest_of_blitter_values(mode_copy); blit_copy(); } Blit: Code:
bitmap = get_destination_bitmap_address(); // Destination bitmap for drawing bobs For each bob do { calculate_destination_byte_offset(); restore_offset[bob]=destination_byte_offset; destination_address=bitmap+destination_byte_offset; calculate_rest_of_blitter_values(mode_cookiecut); blit_bob(); } Code:
bitmap = get_destination_bitmap_address(); // Destination bitmap for restoring bobs For each bob do { destination_address=bitmap+restore_offset[bob]; determine_tiles_covered(bobx,boby,bobsize); For each tile covered do { calculate_tile_address(tilex,tiley); calculate_rest_of_blitter_values(mode_copy); blit_copy(); } } |
||
20 August 2018, 17:14 | #14 |
Registered User
Join Date: Aug 2018
Location: england
Posts: 24
|
yes there do seem to be a fair amount of extra steps thanks
and thanks mcgeezer |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
WinUAE Display Problem - Gloom Pushed Horizontally To Left | CodyJarrett | support.WinUAE | 1 | 23 December 2014 10:29 |
Using SSCAN2 & SH10 register to repeat sprites horizontally in Blitz2 | leathered | Coders. Blitz Basic | 1 | 03 June 2014 19:29 |
Demos which scroll a large part of the screen horizontally | mark_k | request.Demos | 7 | 22 December 2012 15:21 |
Scroll with the mouse? | BarrySWE | support.Apps | 14 | 29 May 2012 22:16 |
help me smooth scroll | rusty71 | support.WinUAE | 7 | 21 November 2011 15:36 |
|
|