Page 1 of 1

Alpha in the same background??

Posted: Sat Nov 21, 2009 2:15 am
by elnanni
Hi, it's me again :S. It's coding weekend so I hope to find some of the Gurus :D.

I was able to draw my isometric tiles in background 1, but now I have another problem, if I set a transparent color, in this case #00FFFF - RGB15(0, 31, 31) - this transaprency shows background 0, but what I want is to show the tile behind, here's te code:

Code: Select all

void drawBg32x32Iso(int *tilePos, int tile, int offSet){

  if(*tilePos % 32 == 0 && *tilePos != 0) *tilePos += 96;
  *(BG_MAP_RAM(0) + *tilePos + 32 * offSet) = tile;
  *(BG_MAP_RAM(0) + *tilePos + 1 + 32 * offSet) = tile + 1;
  *(BG_MAP_RAM(0) + *tilePos + 2 + 32 * offSet) = tile + 2;
  *(BG_MAP_RAM(0) + *tilePos + 3 + 32 * offSet) = tile + 3;
  *(BG_MAP_RAM(0) + *tilePos + 32 + 32 * offSet) = tile + 4;
  *(BG_MAP_RAM(0) + *tilePos + 33 + 32 * offSet) = tile + 5;
  *(BG_MAP_RAM(0) + *tilePos + 34 + 32 * offSet) = tile + 6;
  *(BG_MAP_RAM(0) + *tilePos + 35 + 32 * offSet) = tile + 7;
  *(BG_MAP_RAM(0) + *tilePos + 64 + 32 * offSet) = tile + 8;
  *(BG_MAP_RAM(0) + *tilePos + 65 + 32 * offSet) = tile + 9;
  *(BG_MAP_RAM(0) + *tilePos + 66 + 32 * offSet) = tile + 10;
  *(BG_MAP_RAM(0) + *tilePos + 67 + 32 * offSet) = tile + 11;
  *(BG_MAP_RAM(0) + *tilePos + 96 + 32 * offSet) = tile + 12;
  *(BG_MAP_RAM(0) + *tilePos + 97 + 32 * offSet) = tile + 13;
  *(BG_MAP_RAM(0) + *tilePos + 98 + 32 * offSet) = tile + 14;
  *(BG_MAP_RAM(0) + *tilePos + 99 + 32 * offSet) = tile + 15;
  *tilePos += 2;

}

...

  dmaCopy(tilesPal, BG_PALETTE, tilesPalLen);
  dmaCopy(tilesTiles, bgGetGfxPtr(bgTiles16x12), tilesTilesLen);

  int tilePos;
  int tile;
  tilePos = 0;

  drawBg32x32Iso(&tilePos, 0, 0);
  drawBg32x32Iso(&tilePos, 16, 1);
  drawBg32x32Iso(&tilePos, 0, 2);
  drawBg32x32Iso(&tilePos, 16, 3);
  drawBg32x32Iso(&tilePos, 0, 4);
  drawBg32x32Iso(&tilePos, 16, 5);

  int row;
  int col;
  for(row = 0; row < SCREEN_HEIGHT; row++)
    for(col = 0; col < SCREEN_WIDTH; col++)
      *(bgGetGfxPtr(bgMain256x256) + col + (row * SCREEN_WIDTH)) = RGB15(0, 0, 31) | BIT(15);
Is there a way to achieve this or will I have to use PaLib :S?? Hehe, just kiding, is there a way, or will I have to do it pixel by pixel :S???

This is the image:

Image
http://mmabj.blogsome.com/images/bug3.jpg

Re: Alpha in the same background??

Posted: Mon Nov 30, 2009 7:23 pm
by elnanni
No answer yet :(?

Re: Alpha in the same background??

Posted: Mon Nov 30, 2009 7:46 pm
by elhobbs
example images are even better when you can see them...

Re: Alpha in the same background??

Posted: Mon Nov 30, 2009 9:07 pm
by elnanni
Hehe, never thought that could be a problem, he.

Any way, just refresh the forbiden page and the image should be shown.

So, looks like I was not able to explain myself, ok.

I have this tiles

TTBBBBBBBBBBB
BBBBBBBBBBBTT

and

TTGGGGGGGGG
GGGGGGGGGTT

T = Transparent
B = Blue
G = Green

For example, and as this is an Isometric tile, so I need an offset in order to make it look like an isometric map, so I want to do this:

TTGGGGGGGGGBBBBBBBBB
GGGGGGGGGBBBBBBBBBTT

So, as you can see, what I want is that my transparent color show the tile behind it, and not the background behind my tiles background.

Hope this explanation helps to explain my problem. If not, just refresh the URL of the image I provided before.

Re: Alpha in the same background??

Posted: Mon Nov 30, 2009 10:29 pm
by StevenH
Short answer: No.

Long answer: No, but if you work on your tiles carefully you can achieve what you want, but it means that the number of tiles you are going to use will increase by a fair bit.

For example, where you have the following tiles:

Code: Select all

TTGGGGTT  TTBBBBTT
GGGGGGGG  BBBBBBBB
TTGGGGTT  TTBBBBTT
TTTTTTTT  TTTTTTTT
Split this into 4 tiles (4x2) for each iso tile, and then look at all the possible tile combo's you may have and create these tiles as well:

Code: Select all

BBGG  GGBB  BBBB  BBBB  GGGG  GGGG
GGGG  GGGG  BBBB  BBBB  GGGG  GGGG

BBGG  GGBB  BBBB  BBBB  GGGG  GGGG
BBBB  BBBB  BBBB  BBBB  GGGG  GGGG
You then use these tiles in the places where you need to have the alpha blending.

If you use more than 2 tiles then you will need to add those splits in as well, so the number of translation tiles slowy get worse

----

The way to do isometric on the GBA/DS according to Square Enix (more specifically FFTA) is to use 1 background layer for a pre-rendered iso image with a second layer used for any area's of the map that you can walk behind.

Another way that's been shown to me is to use 2 background layers for the background tiles, another for the foreground items, leaving one for any text or any other information you want to display.

Re: Alpha in the same background??

Posted: Sat Dec 12, 2009 5:04 am
by elnanni
Ok, so I was able to do it, I used two text backgrounds to achieve this, but I really did not like the way I did it.

In the less priority bg I draw this tiles:
Image

Then the bg with more priority has this:
Image

And combined looks like this:
Image

But I didn't like the way it's done :S, now I'll try to draw pixel by pixel :(, I tried to get each pixel from the tiles bgGetGfxPtr pointer but did not work :(...

I'm starting to get mad :S, any kind of advice will be nice :S...

Re: Alpha in the same background??

Posted: Thu Dec 31, 2009 4:00 am
by WinterMute

Re: Alpha in the same background??

Posted: Fri Jan 01, 2010 5:43 am
by elnanni
It's an interesting project :D. I like people sharing knowledge :D. It's not what I'm loking to achieve but it's good :D.