/// <summary> /// Gets the offset of the pointer referenced by the specified pointer. /// </summary> /// <param name="p">The address of the pointer to resolve.</param> /// <returns></returns> public pRom DerefHandle(pCpu p) { int pointerOffset = ToPRom(p); pCpu referencedPointer = new pCpu(data, pointerOffset); return(ToPRom(referencedPointer)); }
public static int GetAltBackgroundPaletteOffset(Level level) { pCpu macroPointer = level.PalettePointers[5]; int macroOffset = level.ToPRom(macroPointer); macroOffset += macroHeaderSize; return(macroOffset); }
public LevelDataStore GetContainingStore(pCpu offset) { if ((int)offset < 0x9560) { return(LevelDataStore.ExpandoStore); } return(LevelDataStore.StandardStore); }
/// <summary> /// Takes a pointer and resolves it to the actual RomOffset the pointer references. /// Workes for both level-data banks and fixed-PRG banks, with both normal and expando roms. /// </summary> public pRom ToPRom(pCpu p) { if (p.Value < 0xC000 & p.Value >= 0x8000) { return((pRom)(p.BankedOffset + Bank.Offset)); } else if (p.Value >= 0x8000) { return((pRom)(p.BankedOffset + rom.FixedBank.Offset)); } else { System.Diagnostics.Debug.Fail("Level.ResolvePointer: attempted to dereference a pointer that referenced RAM or another address that does not map to a ROM location"); return((pRom)(p.BankedOffset + MetroidRom.HeaderSize)); // Silent failure == success? } }
/// <summary> /// Modifies the underlying pointer, allowing pointer arithmetic to be performed. /// </summary> /// <param name="amount">The amount to offset the pointer.</param> public void OffsetPointer_DEPRECATED(int amount) { ////////////////////////// Get pointer data ////////////////////////Union_16 pointerValue = Union_16.Create(); ////////////////////////pointerValue.Byte2 = data[offset + 1]; ////////////////////////pointerValue.Byte1 = data[offset]; ////////////////////////// Offset pointer data ////////////////////////pointerValue.UShort = (ushort)(pointerValue.UShort + amount); ////////////////////////// Store modified pointer data ////////////////////////data[offset + 1] = pointerValue.Byte2; ////////////////////////data[offset] = pointerValue.Byte1; pCpu ptr = new pCpu(data, offset); ptr += amount; ptr.Write(data, offset); }
public override IList <LineDisplayItem> GetListItems() { List <LineDisplayItem> items = new List <LineDisplayItem>(pointerCount); for (int i = 0; i < pointerCount; i++) { int offset = this.offset + i * 2; pCpu p = new pCpu(romData, offset); items.Add(new LineDisplayItem( i.ToString("x") + ":" + p.ToString(), offset, 2, romData )); } return(items); }
private int CalculateStructCount() { int StructCount; switch (Level.Index) { case LevelIndex.Brinstar: StructCount = StandardRomCounts.brinstarStructCount; break; case LevelIndex.Norfair: StructCount = StandardRomCounts.norfairStructCount; break; case LevelIndex.Tourian: StructCount = StandardRomCounts.tourianStructCount; break; case LevelIndex.Kraid: StructCount = StandardRomCounts.kraidStructCount; break; case LevelIndex.Ridley: StructCount = StandardRomCounts.ridleyStructCount; break; case LevelIndex.None: default: throw new ArgumentException("Invalid level index."); } bool structDataRelocated = Level.PRom[Level.Format.pPointerToStructPTable] < Level.PRom[Level.Format.pPointerToRoomPTable]; if (structDataRelocated) // relocated expando { pCpu firstStructOffset = new pCpu(Level.Rom.data, StructTableOffset); int firstStructRomOffset = firstStructOffset.BankedOffset + Level.BankOffset; StructCount = (firstStructRomOffset - StructTableOffset) / 2; } return(StructCount); }
private void PopulateListView() { PaletteList.BeginUpdate(); for (int i = 0; i < Level.PaletteCount; i++) { pCpu PpuMacroPointer = GetPpuMacroPointer(i); if (PpuMacroPointer.IsLevelBank) { //var macro = GetPpuMacro(i); //if (macro.IsPaletteMacro) AddEntry(i); //else // AddInvalidEntry_BadPpuTarget(i); } else { AddInvalidEntry_BadPointer(i); } } PaletteList.EndUpdate(); }
public AdvancedPaletteEdit SetPalMacroDest(Level level, int palIndex, pCpu newDest) { return(new AdvancedPaletteEdit(queue, level, AdvancedPaletteEditType.DataDest, palIndex, newDest.Value)); }
/// <summary> /// Gets the offset of the pointer referenced by the specified pointer. /// </summary> /// <param name="p">The address of the pointer to resolve.</param> /// <returns></returns> public pCpu DerefHandleCpu(pCpu p) { int pointerOffset = ToPRom(p); return(new pCpu(data, pointerOffset)); }
/// <summary> /// Returns the offset of data that is identified by the pointer that is found at /// the offset 'pOffset' specifies. /// </summary> /// <param name="pOffset">The address of the pointer to resolve.</param> /// <returns></returns> public pRom DerefHandle(pRom pOffset) { pCpu referencedPointer = new pCpu(data, (int)pOffset); return(ToPRom(referencedPointer)); }
internal void WritePointer(pRom offset, pCpu pointer) { data[(int)offset] = pointer.Byte1; data[(int)offset + 1] = pointer.Byte2; }
public static void WriteTwoBytePointer(byte[] data, int tableOffset, int index, pCpu pointer) { data[tableOffset + index * 2] = pointer.Byte1; data[tableOffset + index * 2 + 1] = pointer.Byte2; }