19 August 2016, 10:51 | #1 |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,547
|
Questions re: Efficient blitting
A little bit of background on my work in progress game
[ Show youtube player ] It's AGA, dual playfield with 4 bitplanes on each playfield. The background layer contains the trees, grass etc, and essentially is never drawn to (except for permanent damage to the background, such as the bodies of the enemies). The foreground layer is where the BOBs (in this case, the purple enemies - the player and his projectiles are sprites) are drawn to. The current configuration is this - every frame, the BOB is wiped out with an erase blit (to prevent it leaving trails), and redrawn, simple as that. I don't use BBlit because I don't need to keep what was there previously, there's nothing on the foreground playfield except for the BOBs themselves. So my questions are these: - I don't really need a "cookie" mask shape, as the BOBs are essentially square and shouldn't overlap with each other - in other words, I don't mind at all if a previously opaque pixel is wiped out by a transparent pixel on the BOB. Is there a way of blitting without "cookie" masks in Blitz, and do you get a performance gain from this? - In addition to the above, if say I had a 1 pixel transparent border around my BOB, and only moved it by no more than 1 pixel per frame - would this negate the need for having an erase blit at all if it was being blitted without a mask? - Is there anything else that I can do that might boost blitter performance? For reference, the minimum target of the game will be a stock AGA machine (2mb, 68020) Thanks in advance |
23 August 2016, 21:23 | #2 |
Registered User
Join Date: Mar 2012
Location: UK
Posts: 1,895
|
Looking good!
In answer to your question, looking through my Blitz manual you should use Blit Shape#.X.Y and as you say cookie mode is on. The other modes can be selected by using BlitMode but I don't think any of them will be or use as they are either erasemode, invmode and solidmode. Block shape#,X,Y is faster but restricts you to shapes that are multiples of 16 and position at mulitples of 16 (x position only so block could be useful for objects that move up and down the screen). Like the old ZX Speccy you could have preshifted bobs but this would mean that you would need 16 versions of each image and might be a memory problem (although if you have 16 frames of animation...) I would have thought that just bliting using Blit and having a 1 pixel border would work fine - remember that in Blitz colour 0 is transparent. |
25 August 2016, 18:38 | #3 | |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 475
|
Quote:
If you create your shapes with shapesmaker, there is an option in the menu for "make cookie" - uncheck it. You can blit in any fancy way you like - use the cmd 'blitmode ' to set the required minterms. Useful values are already known as constants (well, not really) SolidMode, CookieMode and EraseMode. To speed up things: If you're sure, the bobs will not interfere you can blit them all every frame without eraseblit and then use simple CLS to erase the whole bmap. I guess you use dblbuffer? |
|
05 September 2016, 05:42 | #4 |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,547
|
Thanks guys, I did a few experiments and such.
It appears that I can do a straight blitter copy (without mask) by using a custom blitter mode, eg #CopyMode=$DC0 BlitMode #CopyMode (Though I'm not sure that's the optimal way to do it) I've experiment with a bunch of different ways to wipe the enemies from the backbuffer and redraw them, the QBlit method appears to be the most efficient. I tried CLS but it's painfully slow (I guess because my backbuffer is 4 fullscreen bitplanes) |
05 September 2016, 14:43 | #5 | |
Registered User
Join Date: Nov 2015
Location: Vaasa, Finland
Posts: 525
|
Quote:
I too have experimented with all sorts methods to make the unbuffering faster, but there aren't that many ways...CLS is slow, and so is full screen "filled Box" drawing. But I also tried this method: I drew everything with "Blit", and as usual had two Bitmaps for Buffering, but also made a third empty Bitmap, as large as the screen, filled with background color. And at the start of every frame I would "BlockScroll" the contents of this third Bitmap to my current Backbuffer, which achieved a "CLS" effect. And I think this was a faster way of emptying the screen than doing a real CLS, but still way slower than a series of QBlit-Unqueues. Although in those cases when the screen was totally filled with BOBS, like about 50 large characters, it was faster to empty the backbuffer with the "BlockScroll-CLS", than doing "Unqueues" for 50 large BOBs. So in some cases this method might be useful, but only in games that would constantly draw extremely lot of stuff, and which would run around 20fps, such as BOB based 1st person shooters maybe? And also it was interesting that when I tried the Blockscroll trick from a 1 bitplane Bitmap to a 3 bitplane Bitmap, it was a lot faster, but it only erased some colors of the BOBs, leaving other 2 bitplanes intact. This phenomenon could also be useful in some cases, but it could be hard to use in normal games. |
|
05 September 2016, 14:59 | #6 |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,547
|
Thanks for that! I assumed all drawing commands were CPU based whereas BlockScroll etc is Blitter based, so that could be why..
I'm thinking of attempting a super simple Mario Kart engine, with just one bitplane for the track to keep 3D overhead to a bare minimum (UI and Karts would be rendered with sprites and a second playfield) that BlockScroll trick would probably be useful here. |
05 September 2016, 15:06 | #7 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,348
|
If you have a "clean" background buffer, you can use that as a source for restoration with Unqueue. Add the clean bitmap as a second parameter to Unqueue, such as:
Code:
Unqueue 1,3 |
05 September 2016, 15:16 | #8 | ||
Registered User
Join Date: Nov 2015
Location: Vaasa, Finland
Posts: 525
|
Quote:
Quote:
One game idea that I've been thinking about is basically Doom, but made like Backlash: http://hol.abime.net/12 So there would be no walls or real levels, just lots of enemies and action. I think that even A500 could run it at 50fps, with occasional slowdowns. A dual playfield setup would be used for speed, and when the action gets too hot, then maybe the Blockscroll trick + Frameskip could save the day. |
||
05 September 2016, 15:30 | #9 | |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,547
|
Quote:
If it's not 50FPS on A500 then I suppose I could make the project AGA only. Though it'd be nice if it was OCS, so far as I know there's no OCS Mario Kart clone (I don't count games like Bump N Burn that have Outrun style turning, and of course Xtreme Racing was AGA only). |
|
31 December 2016, 06:47 | #10 |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,547
|
Digging this up again because I had a further question -
Is it possible (or even a good idea to?) easily disable blitter waits? I was thinking of using the blitter interrupt to let the game know when it's safe to draw again, and while it's still waiting to be able to draw it'd instead do game logic things etc (so program flow would only halt if it attempted to draw another Bob, but there was already a Bob render outstanding) |
31 December 2016, 20:41 | #11 | |
Warhasneverbeensomuchfun
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 41
Posts: 3,450
|
Sorry Earok, I can't answer your question, though I am curious if someone can answer it too.
Quote:
Clearing the whole screen is a good idea if it's actually faster than erasing just the necessary shapes. I tried it before, but without using a Double Buffer, so the bitmap became basically garbage. Though that's something really easy to check out. |
|
01 January 2017, 06:41 | #12 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,348
|
CLS doesn't seem to be the optimal way of clearing the screen. There is a vector graphics example in the Examples directory which uses a piece of inline assembly to clear the screen instead.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Most efficient way to cool a MC 68060 CPU? | eXeler0 | Retrogaming General Discussion | 12 | 01 May 2015 17:44 |
Amiga's most efficient and cleanest coders. | lordofchaos | Retrogaming General Discussion | 47 | 10 February 2013 16:33 |
Blitting question | sandruzzo | Coders. General | 30 | 06 April 2011 11:29 |
Some questions about blitting and ordering of drawing | neoman | Coders. General | 23 | 29 October 2010 18:03 |
Most memory efficient way to run WHDLoad on a 2MB A600? | e5frog | project.WHDLoad | 2 | 25 July 2010 19:41 |
|
|