Original Post

OK, here’s the problem: I’d like to use some sprites that have black in them. Only problem is, the background isn’t black. I was just wondering if there was a way to turn off some of the pixels in the background to make the sprite look like it has black in it.

25 Replies

Here’s a screenshot to illustrate what I’m trying to do, so I know it’s possible. How did they make Wario’s pants black against a red background?

Attachments:

If you look carefully, Wario consists of only two red shades and black.

Any pixel with a value of zero is transparent, while values 1, 2, and 3 are opaque. You can use the palettes to change “colors” 1, 2, and 3 to any one of the three red shades—BRTA, BRTB or BRTC—or black. If you set the palette so that one of the non-zero pixel values is black, you can have opaque black. You could even give up some chars/bgmap space to put the third red shade back, but this is kind of wasteful…

OK, the next question is: how do I set the palette?

VirtualChris wrote:
OK, the next question is: how do I set the palette?

The answer to this, and every VB programming question is…

[size=xx-large]READ THE WIKI!!!!!1111one

😛

I don’t understand the Wiki!
So what would I type in to make this change?
I suppose

“0x0005_F824=00b”
would be too easy
???

VirtualChris wrote:
I don’t understand the Wiki!
So what would I type in to make this change?
I suppose

“0x0005_F824=00b”
would be too easy
???

You’re not far off. Look in your libgccvb.h for “VIP_REGS” (no quotes) and then look for “GPLT0” (again, no quotes). Not just where they’re defined, but how they’re used. Then, re-read the wiki article and see if it makes more sense.

OK, so in order to make low black, I would type in:
VIP_REGS[BRTA]=00;

VirtualChris wrote:
OK, so in order to make low black, I would type in:
VIP_REGS[BRTA]=00;

No, the brightness registers globally control the brightness of the three red shades on the whole screen. GPLT0-GPLT3 are the palettes (which map pixel values to brightness values) assigned to bgmaps. Read the wiki article again, grasshopper (including the links therein).

Well, that’s odd because it is doing what I want it to do (i.e. low = black).

So once you assign the color pallete can you change it per sprite, or is it only for the whole image. For example can you have a sprite with 2 shades of red and black and a scrolling background with one shade of black and 3 shades of red?

morintari wrote:
So once you assign the color pallete can you change it per sprite, or is it only for the whole image. For example can you have a sprite with 2 shades of red and black and a scrolling background with one shade of black and 3 shades of red?

Again, it’s all in the wiki, but here goes…

There are four palettes for bgmaps and four for objects (either one can be used for sprites). Any BGMap cell (consisting of one character) can use any one of the four bgmap palettes. Likewise, any Object can use one of the four object palettes.

As for the background, you can only use all three shades of red and black if it’s the furthest “layer” on the screen. This allows the background color (which can be black or any of the red shades) to show through the transparent pixels (i.e. the pixels with a value of zero). On any other layer, the transparent pixels will allow other layers to show through, obviously.

VirtualChris: you have gotten rid of the darkest red shade for every pixel on the entire screen (as well as darkening the brightest red by a bit). If you just change the palette, it will only affect chars to which that palette is assigned.

Oh! I get it now! So, to make the lowest red black for just the sprite in BGMap1, I should use:

VIP_REGS[GPLT1]=0x4B;

0x4B being 01001011 in binary.

Re wiki:

A VB palette is a single byte (8-bit number) containing three (3) 2-bit colors, in bits 2 through 7, and two padding bits which are ignored. Each 2-bit entry points either to black or to one of the BRTx registers. Black is zero (00b), BRTA is 1 (01b), BRTB is 2 (10b), and 3 (11b) refers to the sum of BRTA, BRTB, and BRTC (See: Brightness).

So, we only get three colors for each character. So why is it when I put in VIP_REGS[GPLT1]= 0x2C (00101100 in binary), it still shows the darkest red as the darkest red and not black like it is supposed to be?

For a lark, I tried reversing the order of the colors, and it worked. That should be clarified in the Wiki that the order of the colors is backwards. Anyway, I noticed all the BGMaps use the same palette. I looked through the wiki and couldn’t find a way to type in code so that only certain BGMaps should use certain palettes. Is there a way to do this?

VirtualChris wrote:
For a lark, I tried reversing the order of the colors, and it worked. That should be clarified in the Wiki that the order of the colors is backwards. Anyway, I noticed all the BGMaps use the same palette. I looked through the wiki and couldn’t find a way to type in code so that only certain BGMaps should use certain palettes. Is there a way to do this?

I think the wiki was perfectly clear, even giving an example of a palette in both binary and hex, but I rewrote it a bit. Does it make more sense, now?

Also, BGMaps don’t use palettes at all. Each individual cell designates the palette used to render it. If you’re using VIDE to make your maps, DanB’s map editor plugin has easy controls for changing the palette used by a given cell. It can also be done programmatically, if you understand the format of a BGMap cell (wiki) and basic bitwise manipulation in C (“google” it).

Here’s a new question same topic. I looked in the Wiki (of course a non programmer looking in the Wiki lol (a bit like Mickey looking in the book of incantations in Sorcerer’s Apprentice). And couldn’t find anything on this so here it goes. You know how Wario’s arms are on one level of 3d space and his body on another level. Is it possible to use 3 colors on his body and a different 3 colors on his arm?

morintari wrote:
You know how Wario’s arms are on one level of 3d space and his body on another level. Is it possible to use 3 colors on his body and a different 3 colors on his arm?

Sure! his arms are stored in a different part of the background map than the body. All you need to do is to make that part of the map use a different palette.

Thank you for that clarification. That was the answer I had hoped to get.

I’ve read the Wiki parts about colors and stuff and nowhere does it say that you can make a certain part of a background map use a certain palette and other parts use other palettes. How do I do this?

VirtualChris wrote:
I’ve read the Wiki parts about colors and stuff and nowhere does it say that you can make a certain part of a background map use a certain palette and other parts use other palettes. How do I do this?

Hmm… did you try looking in the background map section?

Attachments:

 

Write a reply

You must be logged in to reply to this topic.