CMM2 graphics examples and explanation
| Author | Message | ||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 11176 |
12-bit Modes The 12-bit graphics modes are one of the most powerful capabilities of the Colour Maximite 2. They enable us to create semi-transparent objects floating over a background like the ghost demo or the effect of parallax like the stars demo. Note in the latter how the nearer stars are moving faster relative to the spaceship than those further away. The way that it works is using layers. The concept will be very familiar to those of you doing manipulations of images with any of the more capable graphics packages. In 12-bit colour mode the CMM2 supports three layers. This is a property of the processor chip itself. The bottom layer is just a single colour background and to set the colour we specify it in the MODE command. MODE 3,12,RGB(blue) Will put a blue over the screen. Note how, as we are at the command prompt, the status line and command prompt overwrite the background, but it shows through the unset pixels in each character. To change the background colour you can just use the mode command again with the new colour. Other information on the screen won't be affected (NB: V5.05.02RC26 or greater) ![]() The status line and command prompt are writing to the second layer of the three layers and the data for this layer is stored in page 0 The data for the third and top layer is stored in page 1. Unless pixels are set to have some transparency (more on this later) any information written to layer 3 (page 1) will block out layers 1 and 2. We can prove this. Type: PAGE WRITE 1: TEXT 247,190,"X":page write 0 We have to do the command as a single line to avoid the status updating while we are writing to page 1 ![]() Note how the "X" appears to have overwritten the brown seconds units but the seconds are still incrementing underneath and pixels that are not covered by the "X" show normally Now type: PAGE WRITE 1: TEXT 247,190," ":page write 0 The "X" disappears and the seconds continue incrementing normally. Black, i.e. the pixels in text that aren't set, defaults to being a completely transparent colour. Now type CLS RGB(black,15) ![]() Check out the RGB function in the user manual. We have asked the system to clear the screen but to use a non-transparent black. Valid transparency values are from 0 to 15 where 15 is a solid colour. However, the default background colour is fully transparent black so the characters associated with the command prompt and the status line still show the blue colour. Now try: COLOUR RGB(WHITE), RGB(BLACK,15) We have set the background colour to solid black rather than transparent black and now the blue colour on layer 1 has gone completely (NB: V5.05.02RC26 or greater). Lets play a bit more with transparency ![]() The blue square on layer 2 (PAGE 0) is partially overwritten by the green square on layer 3 (PAGE 1) which is set to 50% transparency. Where the squares overlap we get CYAN We could do the same thing with layer 2 and the background layer 1 ![]() That should give you a good understanding of 12-bit mode (ARGB4444) and how the "A" transparency can be used to create interesting effects. The most important thing to note is that in 12-bit mode the CMM2 is displaying information from two pages at the same time (PAGE 0 and PAGE 1) plus a fixed background colour. Information on PAGE 0 will overwrite the background depending on the transparency of each individual pixel on PAGE 0. A transparency of 0 will have no effect. A transparency of 15 is a solid colour and will overwrite completely. Information on PAGE 1 will overwrite both the background and PAGE 0 depending on the transparency of each individual pixel. We will revisit this with a more interesting example when we look at sprites. However, the next post will look in more detail at loading and manipulating pictures Edited 2020-05-14 04:57 by matherp |
||||