private void DrawLevelPatterns(LevelIndex level) { spritePatterns.Clear(); bgPatterns.Clear(); PatternGroupIndexTable groups = GetLevelPatterns(level); spritePatterns.BeginWrite(); bgPatterns.BeginWrite(); for (int i = 0; i < groups.Count; i++) { PatternGroupOffsets offsets = rom.PatternGroupOffsets[groups[i]]; if (offsets.IsPage0) { spritePatterns.LoadTiles(offsets); } else { bgPatterns.LoadTiles(offsets); } } spritePatterns.EndWrite(); bgPatterns.EndWrite(); ApplyPalette(level); SpritePatternBox.Image = spritePatterns.PatternImage; BackgroundPatternBox.Image = bgPatterns.PatternImage; }
private void CopyPatternGroup(PatternGroupOffsets groupData, int dest) { // Calculate location (source & dest) of data and size int sourceOffset = groupData.SourceRomOffset; int dataSize = groupData.ByteCount; Array.Copy(rom.data, sourceOffset, newRomData, dest, dataSize); }
/// <summary>Loads a referenced CHR group into the CHR data buffer</summary> private void LoadChrGroup(PatternGroupOffsets group) { int start = group.DestPpuOffset; int length = group.TileCount * 0x10; var clipped = CopyChr(group.SourceRomOffset, start, length); //Array.Copy(rom.data, group.SourceRomOffset, rawChrBuffer, start, length); System.Diagnostics.Debug.Print("Clipping occurred."); }
public void LoadPatternGroups(PatternGroupIndexTable table) { foreach (byte groupIndex in table) { PatternGroupOffsets offsets = rom.PatternGroupOffsets[groupIndex]; // Page 0 = sprite pattern mem, 1 = bg. if ( (offsets.IsPage0 && type == PatternTableType.sprite) || (offsets.IsPage1 && type == PatternTableType.background)) { LoadTiles(rom.data, offsets.SourceRomOffset, offsets.DestTileIndex, offsets.TileCount); } } }
/// <summary> /// Copies pattern groups for pseudo-ppu-dumps (used to generate a compiled set of bg patterns for each level) /// </summary> /// <param name="groupData">Information about the pattern group</param> /// <param name="baseOffset">The base offset of the 1 kb block of pattern data.</param> private void CopyBgPatternGroup(PatternGroupOffsets groupData, int baseOffset) { if (!groupData.IsBackground) { throw new ArgumentException("Attempted to use sprite patterns to create a compiled bg pattern set.", "groupData"); } // Calculate location (source & dest) of data and size int sourceOffset = groupData.SourceRomOffset; int ppuDest = groupData.DestPpuOffset; int relativeOffset = ppuDest - 0x1000; // Bg patterns start at 0x1000 in PPU mem int offset = baseOffset + relativeOffset; int dataSize = groupData.ByteCount; Array.Copy(rom.data, sourceOffset, newRomData, offset, dataSize); }
IList <LineDisplayItem> IRomDataParentObject.GetListItems() { LineDisplayItem[] items = new LineDisplayItem[groups.Count]; for (int i = 0; i < groups.Count; i++) { PatternGroupOffsets offsets = rom.PatternGroupOffsets[groups[i]]; items[i] = new LineDisplayItem( "Pattern Group " + i.ToString("X"), offsets.SourceRomOffset, offsets.TileCount * 16, rom.data); } return(items); }
/// <summary>Loads pattern groups from the rom.</summary> private void LoadPatternGroups() { PatternGroupsList.Items.Clear(); PatternGroupsList.BeginUpdate(); for (int i = 0; i < rom.PatternGroupOffsets.Count; i++) { PatternGroupOffsets o = rom.PatternGroupOffsets[i]; ListViewItem item = new ListViewItem(new string[] { i.ToString("X"), o.SourceRomOffset.ToString("X"), o.DestTileIndex.ToString("X"), o.TileCount.ToString("X"), o.IsPage0 ? SpriteString : BgString }); PatternGroupsList.Items.Add(item); } PatternGroupsList.EndUpdate(); }
public void LoadTiles(PatternGroupOffsets tiles) { LoadTiles(tiles.Rom.data, tiles.SourceRomOffset, tiles.DestTileIndex, tiles.TileCount); }