It sounds like you're pretty new to C#. I'm not sure whether you're getting stuck on the C# side of things or the underlying concepts. I don't mind in the least trying to help, but right now I'm just basically guessing which blanks need to be filled in.
I know you probably already understand this, but just to walk through the logic... A complete CHR table contains 256 tiles. Each tile is identified by its index. So if you load your tiles into a vertical strip, the top tile would be tile 0, the next one down would be 1, and so on.
The metatile structure simply stores the four tile numbers that make up a metatile. So to store all your actual metatile data you could declare an array of MetaTile or a List<MetaTile>, depending on which one suits your needs better. An array might be simpler if you want a fixed number of metatiles. A List<MetaTile> would be easier if you want to be able to add/remove/insert MetaTile entries.
Code:
List<MetaTile> metatiles = new List<MetaTile> ()
void Example() {
// Create and initialize a metatile and add it to the list
MetaTile mt = new MetaTile();
mt.topLeft = 0x40;
mt.topRight = 0x41;
mt.bottomLeft = 0x50;
mt.bottomRight = 0x51;
metatiles.Add(mt);
}
The trickier part is presenting the data in the UI and letting the user manipulate it. If you want to draw a metatile, you'll probably want to start with a function that draws an individual tile by index.
Code:
void DrawTile(Graphics target, byte tileIndex, int x, int y) {
// Determine where we will grab the tile from, assuming tiles are stored in a vertical strip
var sourceRect = new Rectangle(0, tileIndex * 8, 8, 8);
// Determine where it will be drawn
var destRect = new Rectangle(x, y, 8, 8);
// Draw it
target.DrawImage(tileSourceImage, destRect, sourceRect);
}
Then you can simply call this function four times to draw a metatile.
Code:
void DrawMetatile(MetaTile mt, int x, int y) {
DrawTile(mt.TopLeft, x, y);
DrawTile(mt.TopRight, someX, someY);
// ... and two more times for the bottom tiles
}
void Usage() {
// Draw the first metatile (number 0) at the location 0,0
DrawMetatile(metatiles[0], 0, 0);
}
Hopefully that clears things up a bit.