Beispiel #1
0
        public bool Connect(List <Data> TileTables, List <Data> TileSheets,
                            List <Data> Palettes)
        {
            bool success = true;

            if (TileTables.Count == 0 || TileSheets.Count == 0)
            {
                return(false);
            }
            MyCreTable = (TileTable)TileTables [0];
            MyCreSheet = (TileSheet)TileSheets [0];
            MySceTable = (TileTable)TileTables.Find(x => x.StartAddressLR == SceTablePtr);
            if (MySceTable == null)
            {
                success = false;
            }
            MySceSheet = (TileSheet)TileSheets.Find(x => x.StartAddressLR == SceSheetPtr);
            if (MySceSheet == null)
            {
                success = false;
            }
            MyPalette = (CompressedPalette)Palettes.Find(x => x.StartAddressLR == PalettePtr);
            if (MyPalette == null)
            {
                success = false;
            }
            return(success);
        }
Beispiel #2
0
        public TileSet() : base()
        {
            SceTablePtr = 0;
            SceSheetPtr = 0;
            PalettePtr  = 0;

            MyCreTable = null;
            MyCreSheet = null;
            MySceTable = null;
            MySceSheet = null;
            MyPalette  = null;
        }
Beispiel #3
0
//----------------------------------------------------------------------------------------

        // Render a 16x16 tile from the tile map to a byte array (BGRA).
        public byte [] RenderTile(int index)
        {
            if (index < 0 || index > RowCount * ColCount)
            {
                return(null);
            }
            int row               = index / ColCount;
            int col               = index % ColCount;
            int FirstSceTileRow   = 8;  // [wip] make static field?
            int firstCreTileIndex = 0x280;
            int width             = 16; // Tile is 16 pixels wide
            int height            = 16; // and 16 pixels high.

            TileTable table = MyCreTable;

            if (row >= FirstSceTileRow)
            {
                table = MySceTable;
                row  -= FirstSceTileRow;
            }

            byte [] image = new byte [width * height * 4];
            for (int q1 = 0; q1 < 2; q1++)
            {
                for (int q0 = 0; q0 < 2; q0++)
                {
                    int  quadrant   = 2 * q1 + q0;
                    int  tile8Index = table.GetTile8Index(ColCount * row + col, quadrant);
                    int  paletteRow = table.GetPaletteRow(ColCount * row + col, quadrant);
                    bool hFlip      = table.GetHFlip(ColCount * row + col, quadrant);
                    bool vFlip      = table.GetVFlip(ColCount * row + col, quadrant);
                    if (tile8Index < firstCreTileIndex)
                    {
                        MySceSheet.DrawTile(image, width, height, MyPalette, paletteRow,
                                            8 * q0, 8 * q1,
                                            tile8Index, hFlip, vFlip);
                    }
                    else
                    {
                        MyCreSheet.DrawTile(image, width, height, MyPalette, paletteRow,
                                            8 * q0, 8 * q1,
                                            tile8Index - firstCreTileIndex, hFlip, vFlip);
                    }
                }
            }
            return(image);
        }