Sprite routines in MODE 13 - how did YOU do it?
Posted: Wed Feb 24, 2016 1:48 pm
Hey,
Just reminiscing on my foray into Archimedes programming back in the day, and how I was never able to get the performance I needed in MODE 13. I thought I'd re-explore some techniques for getting sprites on the screen and see how they could be improved.
I was always targetting lowest common denominator specs (i.e. 8MHz ARM2) so this pretty much meant unrolling loops as much as possible and writing multiple different routines.
I started work at one point on a game similar in style to Tom Cooper's Hamsters, but I wanted lots of parallax layers and 50fps update. Wasn't ever going to happen! But I wonder if it were possible and whether I was doing it wrong.
Here is a spreadsheet containing three different sprite routines for comparison, with some rough timings. Each of them aims to plot a 32 pixel wide sprite row in MODE 13, unclipped, and offset one pixel to the right of a word boundary.
The first tries to do multiple loads/stores, and builds a sprite mask from the data (using colour 0 as the transparent colour), thus halving the amount of sprite data required.
The second is the method used by Tom Cooper's games (from what I remember), multiple loading but then conditionally STRBing pixels if they are non-transparent. I remembered this being quite good, but looking at the timings, it doesn't really perform as well as the other two, unless the sprites are mostly transparent (this routine performs better the more transparent the sprite - you can change the percentage of transparent pixels in the spreadsheet).
The third relies on a sprite mask being interleaved with the data, every 16 pixels. This performs the best, at the expense of doubling the sprite size. Maybe in MODE 13 with its bigger memory requirements, this couldn't have been an option.
But what other methods are there to improve on this? As ever, it's the memory vs speed trade-off.
Interested to know how other people constructed sprite routines on the Arc!
Just reminiscing on my foray into Archimedes programming back in the day, and how I was never able to get the performance I needed in MODE 13. I thought I'd re-explore some techniques for getting sprites on the screen and see how they could be improved.
I was always targetting lowest common denominator specs (i.e. 8MHz ARM2) so this pretty much meant unrolling loops as much as possible and writing multiple different routines.
I started work at one point on a game similar in style to Tom Cooper's Hamsters, but I wanted lots of parallax layers and 50fps update. Wasn't ever going to happen! But I wonder if it were possible and whether I was doing it wrong.
Here is a spreadsheet containing three different sprite routines for comparison, with some rough timings. Each of them aims to plot a 32 pixel wide sprite row in MODE 13, unclipped, and offset one pixel to the right of a word boundary.
The first tries to do multiple loads/stores, and builds a sprite mask from the data (using colour 0 as the transparent colour), thus halving the amount of sprite data required.
The second is the method used by Tom Cooper's games (from what I remember), multiple loading but then conditionally STRBing pixels if they are non-transparent. I remembered this being quite good, but looking at the timings, it doesn't really perform as well as the other two, unless the sprites are mostly transparent (this routine performs better the more transparent the sprite - you can change the percentage of transparent pixels in the spreadsheet).
The third relies on a sprite mask being interleaved with the data, every 16 pixels. This performs the best, at the expense of doubling the sprite size. Maybe in MODE 13 with its bigger memory requirements, this couldn't have been an option.
But what other methods are there to improve on this? As ever, it's the memory vs speed trade-off.
Interested to know how other people constructed sprite routines on the Arc!