Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:52 14 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: New user - blit transparency question in 16-bit mode

Author Message
electrotrains
Newbie

Joined: 29/07/2020
Location: United Kingdom
Posts: 13
Posted: 12:07pm 29 Jul 2020
Copy link to clipboard 
Print this post

Hi all,

I'm attempting to make a game with my son on the CMM2 to have some fun and so he can learn some programming.

However, I'm not very clear on how transparency works with BLITs in 16-bit colour mode (MODE 3,16).

I've created a sprite sheet as a PNG and loaded it offscreen (PAGE WRITE 1). The PNG has transparent pixels where there is no sprite.

We then blit individual frames of animation onto the screen using PAGE WRITE 0, then BLIT from page 1. This is working fine so far.

What I'm not very clear about is how the transparent mode for BLIT will work in 16-bit colour mode - since presumably the tranparency information was lost when I loaded the PNG.

The graphics tutorial posted on this forum (here) has some code that says:

' move the text but only non-transparent (non-zero) pixels
blit 100,100,200,200,32,50,,4


which implies anything zero (i.e. black?) counts as transparent. Is this simply the case for BLITs in 16-bit mode? in which case my sprite sheets should really use black as the transparent colour, rather than the PNG alpha channel.

Any pointers appreciated!

Robin
https://github.com/robinhedwards
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10580
Posted: 12:19pm 29 Jul 2020
Copy link to clipboard 
Print this post

In 8 and 16 bit modes black is considered transparent
 
electrotrains
Newbie

Joined: 29/07/2020
Location: United Kingdom
Posts: 13
Posted: 12:27pm 29 Jul 2020
Copy link to clipboard 
Print this post

Thanks - good to have that confirmed.

It does means that my (blitted) sprites and tiles can't contain true black, though I suppose I can use the darkest grey instead if I needed to.

It would be good to have a command to set the colour to be treated as transparent.

Unless there's a better way to go about this? Maybe 12-bit mode helps here?
https://github.com/robinhedwards
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10580
Posted: 12:33pm 29 Jul 2020
Copy link to clipboard 
Print this post

12-bit mode is definitely the way to go if you want to really use transsparency. For other modes it is just a conditional copy pixel by pixel which is inherently inefficient. I did start with having the concept of a "selectable" transparent colour but that just added another layer of complexity so using a dark colour for black is the workround
 
electrotrains
Newbie

Joined: 29/07/2020
Location: United Kingdom
Posts: 13
Posted: 12:43pm 29 Jul 2020
Copy link to clipboard 
Print this post

Peter,

Great to get such prompt responses from you! Much appreciated.

I'm hoping this machine will be as much fun to make games with as STOS/AMOS on the Atari ST/Amiga were in my youth. So far its looking promising, so thanks for all you've done.

I'll persist with 16-bit mode for a bit at least, and try to get my head round 12-bit mode later.

Robin
https://github.com/robinhedwards
 
capsikin
Guru

Joined: 30/06/2020
Location: Australia
Posts: 342
Posted: 11:56pm 29 Jul 2020
Copy link to clipboard 
Print this post

  matherp said  In 8 and 16 bit modes black is considered transparent


For 8 bit mode can I check something?
Only colour 0 is considered transparent, even if you set colour 1 to also be black using MAP(1)=RGB(0,0,0), right?
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025