Example #1
0
 public OverlayTiles(byte[] data, OverlayTileSizes sizes, OverlayTilePatterns patterns)
 {
     this.sizes        = sizes;
     this.patterns     = patterns;
     this.overlayTiles = new List <OverlayTile>();
     this.SetBytes(data);
 }
 private OverlayTileSize[] LoadPatternSizes(OverlayTileSizes sizes)
 {
     // TODO: Get this from the ROM, if even possible.
     // It is unlikely that this information is available anywhere in the ROM since
     // each overlay tile indicates which size to use when displayed at runtime.
     // Maybe the size of each pattern should be saved in the epic zone when we start supporting updating the patterns.
     byte[]            sizeIndexes = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 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, 1, 1, 1, 1 };
     OverlayTileSize[] sizeArray   = new OverlayTileSize[this.Count];
     for (int i = 0; i < this.Count; i++)
     {
         sizeArray[i] = sizes[sizeIndexes[i]];
     }
     return(sizeArray);
 }
        private void LoadPatterns(byte[] romBuffer, Offsets offsets, OverlayTileSizes sizes)
        {
            // Get the addresses where the individual pattern data is
            int addressOffset = offsets[Offset.TrackOverlayPatterns];

            int[] dataAddresses = this.LoadPatternDataAddresses(romBuffer, addressOffset);

            // Get the data lengths of all the patterns
            int sizeOffset = offsets[Offset.TrackOverlaySizes];

            int[] dataLengths = this.LoadPatternDataLengths(dataAddresses, sizeOffset);

            // Get the widths and heights of all the patterns
            OverlayTileSize[] overlayTilesizes = this.LoadPatternSizes(sizes);

            for (int i = 0; i < PatternCount; i++)
            {
                byte[] data = Utilities.ReadBlock(romBuffer, dataAddresses[i], dataLengths[i]);
                this.patterns[i] = new OverlayTilePattern(data, overlayTilesizes[i]);
            }
        }
 public OverlayTilePatterns(byte[] romBuffer, Offsets offsets, OverlayTileSizes sizes)
 {
     this.patterns = new OverlayTilePattern[PatternCount];
     this.LoadPatterns(romBuffer, offsets, sizes);
 }