26 June 2021, 10:33 | #1 |
Prototron
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
|
Background store/restore question
Hi folks,
I've been tinkering away at a little game demo and it's going well, but I've hit a problem which seems to get getting bigger, so just want some advice before I commit to a technique. I'm using the Blitter to draw the game's moving objects, but I'm doing it using modular type slices to construct an animation frame - the offsets of which are read off of a table and added to the main X/Y position. It works really well and I have stuff animating, but since I'm using the blitter on a single playfield, the background store & restore is getting very tricky to do with all these little pieces, and my drawing routine is just ballooning due to it (plus I'm still an assembly noob, so there's that as well). I was previously copying and restoring a big rectangle from the background for each object, but that wasn't very flexible. I'm wondering if it might just be easier to copy and restore the whole (visible) 320x208 screen each frame, and that would restore the background for every screen object in one go without having to tediously do it piece by piece for every moving object? The problem with that is that it's a scrolling screen (twice the size of the visible screen, using a column blit on both sides for tiles, and then a pointer reset when the end is reached). It would certainly save a LOT of hassle just refreshing the whole screen's background instead of saving/restoring a whole load of little bits, and I know the blitter is capable of copying very large rectangles, but if there's going to be a massive performance hit (I'm doing it on ECS A600) then I'll need to think of something else (I thought about using duel playfield mode to simulate a Megadrive style sprite layer, but I forgot that splits the bitplanes between each playfield). Is this screen copy method maybe something worth pursuing? Thanks! |
26 June 2021, 11:09 | #2 |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
Solving that hassle will result in much better performance of your game, restoring the entire screen will pretty much take up the entire video frame.
You can restore faster using a few methods. 1) have a pristine copy of the background at all times and restore using a combination of the saved blit offset, modulo and blit size. (This is the method i normally use) 2) use tile based restores, mark which tiles are dirty and simply restore them. This saves you chip ram over option 1 3) use the method you mentioned and save/blit/restore ... the problem is its slow and uses memory 4) redraw the entire screen which is very slow, but depends how your game is made up action wise. Geezer |
26 June 2021, 11:24 | #3 | |
Prototron
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
|
Quote:
The tile restore from Option 2 seems interesting, as I'm holding a tile sheet in memory anyway for the backgrounds. Option 1 seems like the way to go though, but wouldn't that require saving whatever the screen is displaying at that moment ? (I'm using a HW scroll, so the background would change with the visible screen). Thanks again! |
|
26 June 2021, 11:42 | #4 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Do you have moving objects everywhere on the screen ?
If you have large areas that don't change often, you could restore only the part that encompasses all moving objects (finding this out is just coordinate comparisons to get min/max). It would already be faster than restoring the whole screen. |
26 June 2021, 12:11 | #5 | |
Prototron
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
|
Quote:
I think I may need to work out how to have a buffer(s) which can change size on the fly, but I don't know how to do that yet. I think McGeezer's tile-restore method sound like it would work. I saw something similar on the Amstrad a few years ago, but that was just for static screen, so I may need to think about this. I wish the Amiga (or at least the ECS) had a separate objects layer to blit to, but I guess this is all part of the challenge. |
|
26 June 2021, 12:38 | #6 | |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,211
|
Quote:
The ideal situation for you though, would probably be either:
|
|
26 June 2021, 13:11 | #7 | |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
Quote:
I think you mentioned above as well that you blit a whole wall of tiles... in scrolling games and depending on your speed you only need to blit a small number of tiles. So for example, if your screen height was 256 and your scroll speed of bplcon1 was 1 then you only need to blit 1 16x16 tile for each position updated in bplcon1. If you give more info on what you are doing we can probably give more clearer answers to best solve the problem. |
|
26 June 2021, 13:49 | #8 | ||
Prototron
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
|
Quote:
Quote:
For the backgrounds, I'm just moving through a map, and blitting one column of 16x16 tiles (same column) at either side of the visible screen in hidden areas. That way I can reset the pointers and still continue to seamlessly scroll through the map. It's scrolling 2 pixels at a time (Poking increments or decrements of $22 to BPLCON1's scroll value until a pointer reset) and this is based on whether the X-pos of the player is past a certain point of the screen (push scroll). I'm really interested in the tile replacer as I that seems to be the most effective, so I think I'll go with that. |
||
26 June 2021, 15:05 | #9 | |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
Quote:
You'll get a big performance boost by only blitting 2 tiles per frame instead of an entire column. It is very simple to do. Make your screen 1 word wider, and for testing open up diwstrt/diwstop so you can see the tiles being copied in per frame as bplcon1 updates the two tiles.... entirely up to you though. |
|
26 June 2021, 15:40 | #10 | |
Prototron
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
|
Quote:
I guess that would be easy enough to change, and if there's a performance boost then that would be great. |
|
26 June 2021, 16:01 | #11 | |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
Quote:
Yep - big performance boost because you are doing much less blits. |
|
26 June 2021, 16:44 | #12 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
If your map is not endless you can just add mapwidth - displaywidth words to the size of your bitmap. So you can continue scrolling without having to blit a second column or reset the pointers. Halves your total number of blits again.
|
26 June 2021, 17:19 | #13 | ||
Prototron
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
|
Quote:
Quote:
At the moment, my total screen width is 704 and the visible part is 320. As I say, I'm just resetting to the starting point when I hit the right edge of the total area (but staying within the map position). My map's width is 1280 (80 words), so it's exactly 4 times the size of the visible screen, although I may want to vary the size later on (but none would be endless). |
||
26 June 2021, 17:38 | #14 | ||||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Quote:
Quote:
Quote:
The 60 additional words allow you to continue scrolling to the right border. |
||||
26 June 2021, 19:03 | #15 | |
Prototron
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
|
Quote:
Are there any examples anywhere I could maybe have a look at for a reference? |
|
26 June 2021, 19:18 | #16 |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
Boot up Apidya with winuae with the action replay cart and have a look how the screen scrolls to the right... exactly the same technique.
|
26 June 2021, 20:05 | #17 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Quote:
Don't remember the exact path, as Aminet is down again, but it is definitely ScrollingTrick.lha. |
||
26 June 2021, 20:33 | #18 |
Registered User
Join Date: Nov 2020
Location: Fareham, UK
Posts: 2
|
In case it's not available at the moment, ScrollingTrick.lha is in the zone for you...
|
26 June 2021, 20:50 | #19 |
Prototron
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
|
Excellent!
Thanks for the help chaps. |
27 June 2021, 11:40 | #20 | |
Prototron
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 411
|
Quote:
I gave the 1 screen technique that phx suggested a try though, and it seemed to work straight off the bat. No resetting bitplane pointers and it scrolls nicely to the end of the map. I didn't add any extra words though, I just changed the BM width to 368 and it was fine. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Trying restore old HDD | JackTheKnife | support.Hardware | 12 | 03 March 2021 04:17 |
[Restore]Amiga 1200 Kwizoke restore (if possible) blog... | Mr. Trog | support.Hardware | 9 | 02 September 2020 21:44 |
Trying to dust off and restore my old Amigas | Alent | New to Emulation or Amiga scene | 6 | 09 March 2018 21:33 |
Restore system sprite | Lazycow | Coders. Asm / Hardware | 27 | 01 November 2017 23:06 |
Double question about saving background | nandius_c | Coders. Asm / Hardware | 5 | 15 January 2014 10:34 |
|
|