English Amiga Board


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

 
 
Thread Tools
Old 22 December 2016, 20:21   #1
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 37
Posts: 3,437
Blitting one bitplane

If I use a bitmap with just 1 or 2 bitplanes, I can blit things faster than if using 3 bitplanes, right?

What I would like to know: If I have a bitmap with 3 bitplanes, but I want to blit something on it that only uses 2 colors, is there a way I can blit it as a 1 bitplane and save blitter time?
Shatterhand is offline  
Old 22 December 2016, 21:02   #2
Coagulus
Gets there in the end...

Coagulus's Avatar
 
Join Date: Sep 2005
Location: Wales
Posts: 680
Quote:
Originally Posted by Shatterhand View Post
If I use a bitmap with just 1 or 2 bitplanes, I can blit things faster than if using 3 bitplanes, right?

What I would like to know: If I have a bitmap with 3 bitplanes, but I want to blit something on it that only uses 2 colors, is there a way I can blit it as a 1 bitplane and save blitter time?
I think bitplanesbitmap is a command that could help here.
Coagulus is offline  
Old 23 December 2016, 23:19   #3
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 37
Posts: 3,437
Read about bitplanesbitmap on the manual, didn't understand anything
Shatterhand is offline  
Old 23 December 2016, 23:25   #4
Cylon
Registered User

 
Join Date: Oct 2014
Location: Europe
Posts: 466
Quote:
Originally Posted by Shatterhand View Post
Read about bitplanesbitmap on the manual, didn't understand anything
http://www.amiblitz.de/community/vie...php?f=11&t=157

Easy as pie.

Just remember setting the values for your fake bmaps in binary format: that way you'll understand the logic behind it.
Code:
BitPlanesBitMap0,re0,%001   ;binary for better understanding
BitPlanesBitMap0,gn0,%010   ; bitplane masking!!
BitPlanesBitMap0,bl0,%100   ; :-)

BitPlanesBitMap1,re1,%001   ;same for dbl bmap…
BitPlanesBitMap1,gn1,%010
BitPlanesBitMap1,bl1,%100
Cylon is offline  
Old 25 December 2016, 20:50   #5
hooverphonique
ex. demoscener "Bigmama"

 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,096
I am not sure if it is your source or target bitmap that has 3 bpls, but to set an arbitrary color in your target, you need to blit as many bitplanes as your target depth, regardless of if you're using interleaved bitplanes or not, and there really is no way around this.
hooverphonique is offline  
Old 27 December 2016, 11:43   #6
Anakirob
Unregistered User
Anakirob's Avatar
 
Join Date: Nov 2005
Location: Tasmania
Age: 38
Posts: 858
But if you use the BitPlanesBitmap function, and you are blitting to one of those Bitmap objects assigned with the afore mentioned function, then your target is only one bitplane.
Anakirob is offline  
Old 27 December 2016, 17:08   #7
Cylon
Registered User

 
Join Date: Oct 2014
Location: Europe
Posts: 466
One possible use is a shadow or a lighting effect. Or transparent texts. You only have to setup your palette entries to your needs.
Cylon is offline  
Old 28 December 2016, 02:05   #8
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 37
Posts: 3,437
Quote:
Originally Posted by hooverphonique View Post
I am not sure if it is your source or target bitmap that has 3 bpls, but to set an arbitrary color in your target, you need to blit as many bitplanes as your target depth, regardless of if you're using interleaved bitplanes or not, and there really is no way around this.
This answers my question. Thank you
Shatterhand is offline  
Old 28 December 2016, 03:19   #9
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 37
Posts: 3,437
Quote:
Blit Shape#,X, Y[,Excessonoff]
Blit is the simplest of all the blitting commands. Blit will simply draw a shape object onto the currently used bitmap at the pixel position specified by X,Y. The shape's handle, if any, will be taken into account when positioning the blit. The optional Excessonoff parameter only comes into use if you are blitting a shape which has less bitplanes (colours) than the bitmap to which it is being blitted. In this case, Excessonoff allows you to specify an on/off value for the excess bitplanes - ie, the bitplanes beyond those altered by the shape. Bit zero of Excessonoff will specify an on/off value for the first excess bitplane, bit one an on/off value for the second excess bitplane and so on.
This is taken from Blitz manual. I think the Excessonoff argument may help with what I was asking. Has anyone used this ?
Shatterhand is offline  
Old 31 December 2016, 06:44   #10
earok
Registered User

 
Join Date: Dec 2013
Location: Auckland
Posts: 2,325
Quote:
Originally Posted by Shatterhand View Post
This is taken from Blitz manual. I think the Excessonoff argument may help with what I was asking. Has anyone used this ?
I'm not sure it'd help performance overall as you'd still be blitting to all of the bitplanes, it just saves you from needing to make graphics that use all bitplanes.

I did use it for an experimental type thingy where I was able to use the same source graphics for Sprites and BOBs, eg it worked along these lines:

- Game was 32 colours, the first 16 was used exclusively for background elements, the second 16 was used for sprites and BOBs. So the game bitmap used 5 bitplanes.
- My sprite sheet was 16 colours / 4 bitplanes, so..
- If I ran out of sprite channels, I could instead draw the foreground graphics with the blitter using excesschannel of 1.
earok is offline  
Old 03 January 2017, 10:31   #11
earok
Registered User

 
Join Date: Dec 2013
Location: Auckland
Posts: 2,325
I found this when looking through the BUMs. I hope it's of some value.

Quote:
GamesTips 'n' Trix
==================

One of the major factors affecting a games speed
is the amount of bitplanes that are Used. With the A1200 AND A4000
came the AGA chip set which allows up To 8 bitplanes To be Used in
a single playfield display. So with up To 256 colours On Screen
you can imagine some pretty mean, Console bashing games.
Unfortunately, the more colours you Use, the more bitplanes you
Use, the more bitplanes you Use the slower it takes To draw each
Shape (a BLITZ blitter object). Fortunately there are a few tricks
up the BLITZ programmers sleeve To speed things up.


Use of colours
==============
Although a game may Use 32 colours (5 bitplanes) it is
pretty rare For all the graphics in the game To have all 32
colours in them. This is were clever Palette control comes in.

Try AND place the most frequently Used colours in the lower half of
the Palette. While it may be nice To have all the greys together,
all the reds together etc. it may NOT be very practical. If
jumbling your Palette up means that some of the graphics now only
Use the lower 4, 8 OR 16 colours Then do it !

Once you have done
this it is also important how you cut the shapes out of the
BitMap. If your BitMap has 5 bitplanes any Shape that you cut out
of it using the GetaShape command will have 5 bitplanes too,
regardless of the amount of colours that are actually in the
Shape. The easiest way To Get around this is when you are actually
drawing the graphics (e.g. in a paint package such as Brilliance
OR DPaint) To keep all graphics with 3 bitplanes in one IFF File,
all graphics with 4 bitplanes in another IFF File etc. so that you
can create a BitMap with the correct amount of bitplanes To cut
them from.

So now that some of your shapes Use less bitplanes your
shapes will take less time draw when using the blitter commands
(such as Blit, QBlit, Block etc.).


Bitplane magic
==============
With BUM 4 there
came a very trendy command in BLITZ called BitPlanesBitMap the
syntax of which is shown below:

BitPlanesBitMap SrcBitMap,

DestBitMap,PlanePickThis allows you To create a new BitMap using
some of the bitplanes from a BitMap that you have already created.
As this command uses bitplanes that have already been created very
little memory is taken up by the new BitMap. The planes are
selected using the PlanePick parameter, the following values can
be ORed together:

Bitplane 1 = $01 Bitplane 2 = $02
Bitplane 3 = $04 Bitplane 4 = $08
Bitplane 5 = $10 Bitplane 6 = $20
Bitplane 7 = $40 Bitplane 8 = $80


Blitter collision
-----------------
Probably
one of the most Used collision commands is the BlitColl command
which allows you To 'test Blit' a Shape To a BitMap without the
Shape actually being written, To see If the Shape would collide
with something already drawn On the BitMap. As the command does
NOT actually draw the Shape it is pretty fast. The syntax of this
command is shown below:

BlitColl (Shape#,X,Y)

Sometimes, as with
sprites, it is only necessary To check For the presence of odd
colours when doing collision checking (again, it depends On how
you have set up your Palette). So If you are only going To check
For odd colours you only need To check the first bitplane (all odd
colours Use the first bitplane).

Normally the BlitColl command
would check the same amount of bitplanes as the Shape you are
using. So If you are using BlitColl with a Shape that has 3
bitplanes, the command will check the first three bitplanes of the
current BitMap. However, If you only want To do collision checking
For odd colours this is wasting precious processing time. The
following fragment of code shows you how To Use only the first
bitplane of BitMap 0 For collision checking.

#SHP_Man = 10 ; The number of our shape
#BMP_Main = 0 ; The number of the main bitmap
#BMP_Coll = 1 ; The number of the dummy collision
... ; bitmap
BitMap #BMP_Main,320,256,3 ; The main bitmap (bitmap 0)
BitPlanesBitMap #BMP_Main,#BMP_Coll,1 ; Dummy bitmap (bitmap 1) created
... ; using bitplane 1 of bitmap 0
Use BitMap 1 ; Use collision bitmap
If BlitColl(#SHP_Man,1) ; Check for collision with odd colours
... collision code goes here
Else
Use BitMap 0 ; Use the main bitmap
Blit #SHP_Man,X,Y ; and blit the shape
EndIf


Palettes revisited
------------------
If you are only doing collision
checking For odd colours AND the area in the BitMap you are
checking consists of only Even colours, a collision will NOT be
registered. You can Use this To your advantage.

If you are writing
a game that uses explosions, For example a shoot-em-up, when the
player fires a missile it would NOT be desirable For it To
register a collision when blitted over an explosion. This would
waste valuable processing time While you are trying To find out
what it was that the missile hit. If the explosion was made up of
only Even colours Then no collision would be registered when using
the BlitColl command.


Shadows AND other special effects
---------------------------------
The BitPlanesBitMap command can also be Used To create some nice
effects such as shadows. Try running the following
code:


BLITZBitMap 0,320,256,5
BitPlanesBitMap 0,1,16Slice 0,44,320,256,$FFF8,5,8,32,320,320
Show 0

X=80:Y=48:Width=160:Height=160
Use BitMap 0
For ColourNo = 0 To 15
DarkRed=QLimit(Red(ColourNo)-5,0,15)
DarkGreen=QLimit(Green(ColourNo)-5,0,15)
DarkBlue=QLimit(Blue(ColourNo)-5,0,15)
RGB ColourNo+16,DarkRed,DarkGreen,DarkBlue
Boxf X,Y,X+Width,Y+Height,ColourNo
X+4:Y+4:Width-8:Height-8
Next ColourNo

X=120:Y=88:Width=80:Height=80
Use BitMap 1
While Joyb(1) = 0
Jx=Joyx(1):Jy=Joyy(1)
If Jx OR Jy
Cls
X=QLimit(X+Jx,0,320-Width)
Y=QLimit(Y+Jy,0,256-Height)
EndIf
Boxf X,Y,X+Width,Y+Height,1
VWait
Wend
End


The above example creates
a darker version of the first 16 colours in the second half of the
Palette. The Boxf command is Then Used To draw a Box into bitplane
5, using the dummy BitMap created with the BitPlanesBitMap
command, To give a shadow Type effect.


Last but NOT least
==================
When using shapes containing different amounts of bitplanes, ensure that
shapes with the least amount of bitplanes are drawn first. Drawing
a 3 bitplane Shape On top of a graphic with more than 3 bitplanes
will more than likely produce an undesirable effect. If you do
have To do this, Use the Excessonoff parameter of the relevant
Blit command so that the remaining (OR excess) bitplanes are
cleared.


Careful planning
----------------
As with all things careful planning
initially may take more time but will save you time in the long
run. The key points are:

* Choose your Palette well,
carefully placed colours can help you increase your games speed.
* Cut down the amount of bitplanes needed wherever possible. The
least amount of bitplanes you Use, the faster you can draw
your objects.
* When using BlitColl, clever Use of the
BitPlanesBitMap command can save a lot of time (especially with
big shapes).
* When drawing shapes, draw shapes with the least
amount of bitplanes first.
* Most importantly of all, Use your
imagination AND experiment. The best way To learn is through
trial AND error.

Tim Caldwell
Tues. 26th April 1994
earok is offline  
Old 03 January 2017, 16:53   #12
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 4,686
Some good tips there... Loving the random capitalisation of things that comes from editing the document in Blitz's editor
Daedalus is offline  
Old 03 January 2017, 18:26   #13
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 37
Posts: 3,437
So this means if my shape has just 4 colors on the palette, it will be blitted using just 2 bitplanes automatically. I am using independent files for my graphics, so I can easily reduce colors of each file.

That's what I wanted to do. I already had done the bullets on my game using just the first 2 colors from the palette predicting this somehow was possible, and then some of the enemies using just 4 of the first colors.

I also did it in a way that I only need to test collisions with the first color of the palette, which I guess it's faster than testing with all odd colors (and Blitz allows this).
Shatterhand is offline  
Old 01 February 2017, 16:13   #14
carrion
Registered User

carrion's Avatar
 
Join Date: Dec 2016
Location: Warsaw area
Posts: 99
question I have doesn't really to problem in this thread directly but it's pretty close so i decided to post here and not open a new one

I want all 3 bitplanes of my bitmap show the same biplane (the same address pointer)?
in asm/copperlist I'd pass the same pointer to biplane ($0e0, $0e2 etc,) but how to do it in blitz?
TIA
carrion is offline  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bitplane removal on the fly gifgit request.UAE Wishlist 6 11 October 2015 20:31
Problem with blitting.... xboxown Coders. Language 0 09 March 2014 21:51
Blitting question sandruzzo Coders. General 30 06 April 2011 11:29
Questions about bitplane DMA Leffmann Coders. General 11 15 July 2008 15:08
bitplane modulos bluea Coders. General 0 09 July 2006 01:58

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 14:31.


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