Sprite with transparency

GFA BASIC-related articles in here please

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
hylst
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Wed Apr 27, 2011 6:22 pm
Location: France : Strasbourg
Contact:

Sprite with transparency

Postby hylst » Thu May 01, 2014 8:55 pm

Hi !

I'm using back gfa for sprite / block display with transparency on a given 4 planes background in ST LOW.
What i need do not require great speed so rc copy and get/put are enough.

However, when i use bit (graphmode) mode 1 (AND) to put mask of sprite on background, and then i put the sprite himself at the same place with mode 7 (OR).
It's dispayed with a kind of transparency, but... some colors are a little modified ...

Maybe my mask rout is wrong ?

kind of (not optimized here) :

Code: Select all

' sprite%=address of 4p bitmap data of the sprite
' mask%=address of free area to create mask of the sprite  (same length as sprite%)
For w&=0 to pred(width.byte.sprite&)
 For h&=0 to pred(heigth.sprite&)
  mask.p%=mask%+2*w&+160*h&
  sprite.p%=sprite%+2*w&+160*h&
  CARD{maskp%}=NOT(CARD{sprite.p%} OR CARD{sprite.p%+2} OR CARD{sprite.p%+4} OR CARD{sprite.p%+6})
  CARD{maskp%+2}=CARD{maskp%}
  CARD{maskp%+4}=CARD{maskp%}
  CARD{maskp%+6}=CARD{maskp%}
 Next h&
Next w&


Thanks for your help :)
Falcon CT60 +CENTRAM14 - 520 STE 4M - 1040 STf
Let's visit my Personal website http://hylst.t15.org !
The new website of my productions (French for the moment)

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4848
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Sprite with transparency

Postby simonsunnyboy » Fri May 02, 2014 10:33 am

You have to invert the mask, set all bits that have to preserved, clear all bits that should show the sprite data.
This mask can be applied with a normal bit AND operation (assembly coded sprite routines do that). Apply sprite data with normal bit OR.

Btw. you can calculate a simple sprite mask as follows:
OR all sprite data planes together and then invert the result:

Code: Select all

mask& = plane0& OR plane1& OR plane2& OR plane3&
mask&= mask& XOR &HFFFF


But this is siilar to what you do above...

If I have to generate masks by code in GFA, I most often loop over the data pixel by pixel, draw color 15 where transparency is to shown and draw color 0 where the sprite shall appear.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
hylst
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Wed Apr 27, 2011 6:22 pm
Location: France : Strasbourg
Contact:

Re: Sprite with transparency

Postby hylst » Sun May 04, 2014 9:52 pm

simonsunnyboy wrote:You have to invert the mask, set all bits that have to preserved, clear all bits that should show the sprite data.
This mask can be applied with a normal bit AND operation (assembly coded sprite routines do that). Apply sprite data with normal bit OR.

Btw. you can calculate a simple sprite mask as follows:
OR all sprite data planes together and then invert the result:

Code: Select all

mask& = plane0& OR plane1& OR plane2& OR plane3&
mask&= mask& XOR &HFFFF


But this is siilar to what you do above...

If I have to generate masks by code in GFA, I most often loop over the data pixel by pixel, draw color 15 where transparency is to shown and draw color 0 where the sprite shall appear.



Thanks for your help one more time Simon Sunny Boy :)
Falcon CT60 +CENTRAM14 - 520 STE 4M - 1040 STf
Let's visit my Personal website http://hylst.t15.org !
The new website of my productions (French for the moment)


Social Media

     

Return to “GFA BASIC”

Who is online

Users browsing this forum: No registered users and 1 guest