meta tiles?

Post Reply
Tomdev
Posts: 82
Joined: Thu Jan 08, 2009 9:15 pm

meta tiles?

Post by Tomdev » Wed Apr 22, 2009 8:28 pm

ok so i heard something about meta tiles but it's not completely clear to me: are meta tiles groups of 8x8 tiles. i want to use 16x16 tiles , are meta tiles the solution then? and if so, how do they work on the ds? because the ds expects 8x8 tiles if i'm right?

User avatar
vuurrobin
Posts: 222
Joined: Fri Jul 11, 2008 8:49 pm
Location: The Netherlands
Contact:

Re: meta tiles?

Post by vuurrobin » Thu Apr 23, 2009 10:57 am

well, you pretty much said the awnser yourself.

the ds hardware needs the tiles to be 8*8 pixels, so if you want tiles of 16*16 pixels, you would create a 16*16 metatile that is made up from 4 8*8 'normal' tiles.

as for using them, I'm pretty sure that programs like grit has options for converting metatiles.

Tomdev
Posts: 82
Joined: Thu Jan 08, 2009 9:15 pm

Re: meta tiles?

Post by Tomdev » Thu Apr 23, 2009 11:59 am

ok i will test that option and look into the files that i will get. :P

edit: ok so i tested the functions and looked into the .c file of the output this is what i get:
"normal 8x8 tiles"
meta tiles
meta map
and a palette,

but now if i want to load this background how should i do that? because the ds expect 8x8 tiles and no 16x16 so i load the 8x8 tiles into memory and then?
Last edited by Tomdev on Tue Jun 01, 2010 4:58 pm, edited 1 time in total.

elnanni
Posts: 23
Joined: Sat Nov 14, 2009 1:41 am

Re: meta tiles?

Post by elnanni » Thu Nov 19, 2009 4:47 am

I'm having the same problem, my tiles are 16x16 - I'll change the size, but I'm trying to do it with this dimensions first -, so in grit I left this options:

# Tile format
-gt
# Set the bit depth to 16
-gB8
# Set the transparent color to 00FFFF (rrggbb hex)
-gT 00FFFF
# Add Map
-m
-Mh4
-Mw4

and in the code I'm doing this:

Code: Select all

  bgTiles32x32 = initBg(true, 0, BgType_Text8bpp, BgSize_T_256x256, 0, 1);

  dmaCopy(tilesPal, BG_PALETTE, tilesPalLen);
  dmaCopy(tilesMetaTiles, bgGetGfxPtr(bgTiles32x32), tilesMetaTilesLen);

  *(bgGetMapPtr(bgTiles32x32) + 0) = 0;
  *(bgGetMapPtr(bgTiles32x32) + 1) = 1;
  *(bgGetMapPtr(bgTiles32x32) + 2) = 2;
  *(bgGetMapPtr(bgTiles32x32) + 3) = 3;
  *(bgGetMapPtr(bgTiles32x32) + 4) = 4;
  *(bgGetMapPtr(bgTiles32x32) + 5) = 5;
  *(bgGetMapPtr(bgTiles32x32) + 6) = 6;
  *(bgGetMapPtr(bgTiles32x32) + 7) = 7;
  *(bgGetMapPtr(bgTiles32x32) + 8) = 8;
  *(bgGetMapPtr(bgTiles32x32) + 9) = 9;
  *(bgGetMapPtr(bgTiles32x32) + 10) = 10;
  *(bgGetMapPtr(bgTiles32x32) + 11) = 11;
  *(bgGetMapPtr(bgTiles32x32) + 12) = 12;
  *(bgGetMapPtr(bgTiles32x32) + 13) = 13;
  *(bgGetMapPtr(bgTiles32x32) + 14) = 14;
  *(bgGetMapPtr(bgTiles32x32) + 15) = 15;
But I'm getting some really extrange results, first of all, the 00FFFF color is not transparent, and the images are wrong :(. If you fond the answer, please let me know :(... Not even google was able to help me :S

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

Tomdev
Posts: 82
Joined: Thu Jan 08, 2009 9:15 pm

Re: meta tiles?

Post by Tomdev » Thu Nov 19, 2009 3:45 pm

you're converting to 32x32 metatiles with grit:

Code: Select all

-Mh4 // 4*8=32
-Mw4 // the same
change that to, this should work:

Code: Select all

-Mh2 
-Mw2
Didn't look too well at your code, so maybe you're using code for 32x32 tiles? if your interested, I have an old lib, with metatiled functions(only 16x16) which can load tiles dynamically(for scrolling) and animate meta tiled bg's. just say if you want it, but be warned, it's not well coded

Tomdev

elnanni
Posts: 23
Joined: Sat Nov 14, 2009 1:41 am

Re: meta tiles?

Post by elnanni » Thu Nov 19, 2009 3:58 pm

Ok, maybe I did not explained the problem clear :S.

Let's take a look at a handmade example, I have this tiles:

Code: Select all

u8 tiles16x16[] = {
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
};

u8 tiles8x8[] = {
  1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1,
  2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2,
  3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3
};
If I use this code with the tiles8x8 it works as I want :D:

Code: Select all

  bgTiles32x32 = initBg(true, 0, BgType_Text8bpp, BgSize_T_256x256, 0, 1);

  u16* mapMemory = (u16*)BG_MAP_RAM(0);

  dmaCopy(palette, BG_PALETTE, sizeof(palette));
  dmaCopy(tiles8x8, bgGetGfxPtr(bgTiles32x32), sizeof(tiles8x8));

  for(tile = 0; tile < 32 * 32; tile += 1)
    mapMemory[tile] = BG_PALETTE[0];

  *(BG_MAP_RAM(0) + 0) = 0;
  *(BG_MAP_RAM(0) + 1) = 1;
  *(BG_MAP_RAM(0) + 2) = 2;

  //0 is red, 1 is green and 2 is blue
Output:
|RED |GREEN|BLUE|CIAN|CIAN|CIAN|....|CIAN
|CIAN|CIAN |CIAN |...........................|CIAN
..................
|CIAN|CIAN |CIAN |...........................|CIAN


but when I use this code for the tiles16x16, it does not work as I want :(:

Code: Select all

  bgTiles32x32 = initBg(true, 0, BgType_Text8bpp, BgSize_T_256x256, 0, 1);

  u16* mapMemory = (u16*)BG_MAP_RAM(0);

  dmaCopy(palette, BG_PALETTE, sizeof(palette));
  dmaCopy(tiles16x16, bgGetGfxPtr(bgTiles32x32), sizeof(tiles16x16));
  //BG_PALETTE[n] = RGB15(R, G, B);

  for(tile = 0; tile < 32 * 32; tile += 1)
    mapMemory[tile] = BG_PALETTE[0];

  *(BG_MAP_RAM(0) + 0) = 0;
  *(BG_MAP_RAM(0) + 1) = 1;
  *(BG_MAP_RAM(0) + 2) = 2;
  *(BG_MAP_RAM(0) + 3) = 3;
  *(BG_MAP_RAM(0) + 4) = 4;
  *(BG_MAP_RAM(0) + 5) = 5;
  *(BG_MAP_RAM(0) + 6) = 6;
  *(BG_MAP_RAM(0) + 7) = 7;
  *(BG_MAP_RAM(0) + 8) = 8;
  *(BG_MAP_RAM(0) + 9) = 9;
  *(BG_MAP_RAM(0) + 10) = 10;
  *(BG_MAP_RAM(0) + 11) = 11;

  //Tiles 0 - 3 are red, 4 - 7 are green and 9 - 11 are blue
Output:
|RED |RED |RED |RED |GREEN|GREN|GREN|GREN|BLUE|BLUE|BLUE|BLUE|CIAN|CIAN|CIAN|....|CIAN
|CIAN|CIAN |CIAN |.....................................................................................................|CIAN
..................
|CIAN|CIAN |CIAN |.....................................................................................................|CIAN

As you can see, instead of a 2x2 8*8 (16*16) tile, they're normal 8*8 tiles.

Please help, I hope that by understanding this I'll be able to do the same with my png tiles.

UPDATE:

Hi Tomdev, I would really appreciate the code :D

elnanni
Posts: 23
Joined: Sat Nov 14, 2009 1:41 am

Re: meta tiles?

Post by elnanni » Thu Nov 19, 2009 4:40 pm

Ok, so, if in the 16x16 I do this:

Code: Select all

  *(BG_MAP_RAM(0) + 0) = 0;
  *(BG_MAP_RAM(0) + 1) = 1;
  *(BG_MAP_RAM(0) + 1 * 32) = 2;
  *(BG_MAP_RAM(0) + 1 * 32 + 1) = 3;
  *(BG_MAP_RAM(0) + 2) = 4;
  *(BG_MAP_RAM(0) + 3) = 5;
  *(BG_MAP_RAM(0) + 32 + 2) = 6;
  *(BG_MAP_RAM(0) + 32 + 3) = 7;
  *(BG_MAP_RAM(0) + 4) = 8;
  *(BG_MAP_RAM(0) + 5) = 9;
  *(BG_MAP_RAM(0) + 32 + 4) = 10;
  *(BG_MAP_RAM(0) + 32 + 5) = 11;
Output:
|RED |RED |GREEN|GREN|BLUE|BLUE|CIAN|CIAN|CIAN|....|CIAN
|RED |RED |GREEN|GREN|BLUE|BLUE|CIAN|CIAN|CIAN|....|CIAN
|CIAN|CIAN |CIAN |..................................................|CIAN
..................
|CIAN|CIAN |CIAN |..................................................|CIAN

it works as I want, is that the only way to do it??

it's like this now:

|8*8|8*8|8*8|8*8|8*8|8*8|....|8*8| -> 32 tiles in X
|8*8|8*8|8*8|8*8|8*8|8*8|....|8*8| -> 32 tiles in X
|8*8|8*8|8*8|8*8|8*8|8*8|....|8*8| -> 32 tiles in X
..................
|8*8|8*8|8*8|8*8|8*8|8*8|....|8*8| -> 32 tiles in X
|
v
24 tiles in Y

but it shouldn't it be something like this?:

|16*16|16*16|16*16|16*16|16*16|16*16|....|16*16| -> 16 tiles in X
|16*16|16*16|16*16|16*16|16*16|16*16|....|16*16| -> 16 tiles in X
|16*16|16*16|16*16|16*16|16*16|16*16|....|16*16| -> 16 tiles in X
...............
|16*16|16*16|16*16|16*16|16*16|16*16|....|16*16| -> 16 tiles in X
|
v
12 tiles in Y

UPDATE:

:S, so, now I made a map :S

Code: Select all

u16 map64x64[] = {
  0, 1, 4, 5, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  2, 3, 6, 7, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};

u16 palette[] = {
    RGB15(0, 31, 31),
    RGB15(31, 0, 0),
    RGB15(0, 31, 0),
    RGB15(0, 0, 31)
};
and copy the map:

Code: Select all

  bgTiles32x32 = initBg(true, 0, BgType_Text8bpp, BgSize_T_256x256, 0, 1);

  dmaCopy(palette, BG_PALETTE, sizeof(palette));
  dmaCopy(map64x64, (u16*)BG_BMP_RAM(0), sizeof(map64x64));
  dmaCopy(tiles16x16, bgGetGfxPtr(bgTiles32x32), sizeof(tiles16x16));
But it's drawing the same as before

Output:
|RED |RED |GREEN|GREN|BLUE|BLUE|CIAN|CIAN|CIAN|....|CIAN ->32XTiles
|RED |RED |GREEN|GREN|BLUE|BLUE|CIAN|CIAN|CIAN|....|CIAN->32XTiles
|CIAN|CIAN |CIAN |..................................................|CIAN->32XTiles
..................->32XTiles
|CIAN|CIAN |CIAN |..................................................|CIAN->32XTiles
|
v
24Ytiles

So, I'm starting to think it's the only way to do it :(, this is the result I want :(

Output:
|RED |GREEN|BLUE|CIAN|CIAN|CIAN|....|CIAN->16XTiles
|CIAN|CIAN |CIAN |...........................|CIAN->16XTiles
|CIAN|CIAN |CIAN |...........................|CIAN->16XTiles
..................->16XTiles
|CIAN|CIAN |CIAN |...........................|CIAN->16XTiles
|
v
12Ytiles

So the map should be something like:

Code: Select all

u16 map64x64[] = {
  0, 1, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
};

Tomdev
Posts: 82
Joined: Thu Jan 08, 2009 9:15 pm

Re: meta tiles?

Post by Tomdev » Thu Nov 19, 2009 7:09 pm

i think your code is a bit weird for me(but then only for me, you can see me as a silly person :lol: ) but okay it's not so fair, I got help from cearn(really smart person) :P so here's the link to my lib(contains some sprite functions, but where you're looking for is the metabg.c and .h file):
http://sites.google.com/site/tomdevsndshomebrew/
these functions work correctly, can dynamically load meta tiles(only 16x16 easy to modify) in vram when needed). as for the animating functions, they work but there was something wrong IIRC(but you won't need that if i'm right)

if you don't get something from the code ask me, and if you don't know how to use the functions, there are examples too

Tomdev

ps: handwriting tilesets and maps cost much time, I just use mappy, export the maps to text files and made an easy program which converted the text files to binary and compressed them for me:)->the lazy way 8)

elnanni
Posts: 23
Joined: Sat Nov 14, 2009 1:41 am

Re: meta tiles?

Post by elnanni » Thu Nov 19, 2009 8:58 pm

Ok, so, I need to do the math in order to make it work, so I'm going to take a look at the functions, thanks a lot, anyway, I was able to do it myself, but did not like it :S.

Code: Select all

u8 tiles16x16[] = {
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};

u16 map16x12[] = {
  0, 1, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
};

u16 palette[] = {
    RGB15(0, 31, 31),
    RGB15(31, 0, 0),
    RGB15(0, 31, 0),
    RGB15(0, 0, 31)
};

u8 tileContainer[] = {
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
....
  bgTiles32x32 = initBg(true, 0, BgType_Text8bpp, BgSize_T_256x256, 0, 1);

  u8* tileMemory = (u8*)BG_TILE_RAM(1);
  u16* mapMemory = (u16*)BG_MAP_RAM(0);
  int tile;
  int i;

  dmaCopy(palette, BG_PALETTE, sizeof(palette));

  for(i = 0; i <= 255; i++) tileContainer[i] = tiles16x16[i];
  swiCopy(tileContainer, tileMemory, 128);
  for(i = 0; i <= 255; i++) tileContainer[i] = tiles16x16[i + 256];
  swiCopy(tileContainer, tileMemory + 256, 128);
  for(i = 0; i <= 255; i++) tileContainer[i] = tiles16x16[i + 512];
  swiCopy(tileContainer, tileMemory + 512, 128);

  for(tile = 0; tile < 32 * 24; tile += 2){
    if(tile % 32 == 0 && tile != 0) tile += 32;
    int tmp = rand() % 11;
    mapMemory[tile] = tmp;
    mapMemory[tile + 1] = tmp;
    mapMemory[tile + 32] = tmp;
    mapMemory[tile + 32 + 1] = tmp;
  }
I'm going to see if there's a better way, but the thread can be closed now :D.

elnanni
Posts: 23
Joined: Sat Nov 14, 2009 1:41 am

Re: meta tiles? [closed]

Post by elnanni » Fri Nov 20, 2009 6:22 am

And this works for 64x64 tiles

Code: Select all

  int tile;
  int tmp;
  for(tile = 0; tile < 32 * 24; tile += 4){
    tmp = 1;
    if(tile % 32 == 0 && tile != 0) tile += 96;
    while(tmp != 0 && tmp != 16) tmp = rand() % 17;
    *(BG_MAP_RAM(0) + tile) = tmp;
    *(BG_MAP_RAM(0) + tile + 1) = tmp + 1;
    *(BG_MAP_RAM(0) + tile + 2) = tmp + 2;
    *(BG_MAP_RAM(0) + tile + 3) = tmp + 3;
    *(BG_MAP_RAM(0) + tile + 32) = tmp + 4;
    *(BG_MAP_RAM(0) + tile + 33) = tmp + 5;
    *(BG_MAP_RAM(0) + tile + 34) = tmp + 6;
    *(BG_MAP_RAM(0) + tile + 35) = tmp + 7;
    *(BG_MAP_RAM(0) + tile + 64) = tmp + 8;
    *(BG_MAP_RAM(0) + tile + 65) = tmp + 9;
    *(BG_MAP_RAM(0) + tile + 66) = tmp + 10;
    *(BG_MAP_RAM(0) + tile + 67) = tmp + 11;
    *(BG_MAP_RAM(0) + tile + 96) = tmp + 12;
    *(BG_MAP_RAM(0) + tile + 97) = tmp + 13;
    *(BG_MAP_RAM(0) + tile + 98) = tmp + 14;
    *(BG_MAP_RAM(0) + tile + 99) = tmp + 15;
  }

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot] and 4 guests