Esempio n. 1
0
        private void QueueDataSegment(IList <levelDataTypes> moveList, pRom dest)
        {
            int bytesUsed = 0;

            for (int i = 0; i < moveList.Count; i++)
            {
                var move        = moveList[i];
                var datasegment = dataSegments[(int)move];

                QueueMove(datasegment, ref dest, ref bytesUsed);
            }
        }
Esempio n. 2
0
 public PointerTable(MetroidRom rom, pRom tableLocation, int tableSize, bool use24BitPointers)
 {
     this.Offset             = tableLocation;
     this.Rom                = rom;
     this.Count              = tableSize;
     this.using24BitPointers = use24BitPointers;
     if (use24BitPointers)
     {
         EntrySize     = 3;
         pointerOffset = 1;
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Automatically adjusts ROM offsets that refer to the main PRG bank if
 /// the Expando property returns true.
 /// </summary>
 /// <param name="offset"></param>
 /// <returns></returns>
 protected pRom FormatAdjust(pRom offset)
 {
     if (offset > 0x1C010)
     {
         if (RomFormat == RomFormats.Expando)
         {
             offset += expandoPrgOffset;
         }
         else
         {
             offset += mmc3PrgOffset;
         }
     }
     return(offset);
 }
Esempio n. 4
0
        }         // function

        public static void ExtractSingleTile(Bitmap b, Point tileLocation, byte[] data, pRom offset)
        {
            BitmapData lockData     = b.LockBits(new Rectangle(tileLocation.X, tileLocation.Y, 8, 8), ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
            pRom       outputOffset = pRom.Null;

            byte[] output = new byte[lockData.Stride * 8];

            // Image data in NES rom has 2 planes. This is the first
            for (int PixelY = 0; PixelY < 8; PixelY += 1)
            {
                output[outputOffset + 7] = (byte)(data[offset] & 0x01);
                output[outputOffset + 6] = (byte)((data[offset] & 0x02) >> 1);
                output[outputOffset + 5] = (byte)((data[offset] & 0x04) >> 2);
                output[outputOffset + 4] = (byte)((data[offset] & 0x08) >> 3);
                output[outputOffset + 3] = (byte)((data[offset] & 0x10) >> 4);
                output[outputOffset + 2] = (byte)((data[offset] & 0x20) >> 5);
                output[outputOffset + 1] = (byte)((data[offset] & 0x40) >> 6);
                output[outputOffset + 0] = (byte)((data[offset] & 0x80) >> 7);
                offset++;
                outputOffset += lockData.Stride;
            }

            // Second plane.
            outputOffset = pRom.Null;
            for (int PixelY = 0; PixelY < 8; PixelY += 1)
            {
                output[outputOffset + 7] |= (byte)((data[offset] & 0x01) << 1);
                output[outputOffset + 6] |= (byte)((data[offset] & 0x02));
                output[outputOffset + 5] |= (byte)((data[offset] & 0x04) >> 1);
                output[outputOffset + 4] |= (byte)((data[offset] & 0x08) >> 2);
                output[outputOffset + 3] |= (byte)((data[offset] & 0x10) >> 3);
                output[outputOffset + 2] |= (byte)((data[offset] & 0x20) >> 4);
                output[outputOffset + 1] |= (byte)((data[offset] & 0x40) >> 5);
                output[outputOffset + 0] |= (byte)((data[offset] & 0x80) >> 6);

                offset++;
                outputOffset += lockData.Stride;
            }

            Marshal.Copy(output, 0, lockData.Scan0, output.Length);
            b.UnlockBits(lockData);
        }
Esempio n. 5
0
        public pCpu CreatePointer(pRom offset)
        {
            if (offset >= rom.FixedBank.Offset)   // PRG ROM (mapped to 0xC000-0xFFFF)
            {
                int relativeOffset = offset - rom.FixedBank.Offset;
                if (offset > 0x3FFF)
                {
                    throw new ArgumentException("Offset was beyond end of last PRG bank.");
                }
                return(new pCpu((ushort)(0xC000 + offset)));
            }
            else     // Level data ROM (mapped to 0x8000-0xBFFF)
            {
                int relativeOffset = offset - Bank.Offset;

                if (relativeOffset < 0 || relativeOffset >= 0x4000)
                {
                    throw new ArgumentException("Offset does not refer to fixed PRG bank or this level's data bank.");
                }

                return(new pCpu((ushort)(relativeOffset | 0x8000)));
            }
        }
Esempio n. 6
0
 public void SetPointers(Level level, pCpu ppPTable, int pointerCount)
 {
     this.pPTable     = ppPTable.AsPRom(level);
     this.ptableCount = pointerCount;
     this.pSource     = level.DerefHandle(ppPTable);
 }
Esempio n. 7
0
 public pCpu(pRom romOffset, Level level)
     : this(level.CreatePointer(romOffset).Value)
 {
 }
Esempio n. 8
0
 /// <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 pCpu DerefHandleCpu(pRom pOffset)
 {
     return(new pCpu(data, (int)pOffset));
 }
Esempio n. 9
0
        /// <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));
        }
Esempio n. 10
0
 internal void WritePointer(pRom offset, pCpu pointer)
 {
     data[(int)offset]     = pointer.Byte1;
     data[(int)offset + 1] = pointer.Byte2;
 }
Esempio n. 11
0
 /// <summary>
 /// Gets a pointer from ROM data at the specified ROM offset.
 /// </summary>
 /// <param name="entryOffset"></param>
 /// <returns></returns>
 internal pCpu GetPointer(pRom offset)
 {
     return(new pCpu(data, (int)offset));
 }
Esempio n. 12
0
 /// <summary>
 /// Creates a patch segment with the same data at a different offset.
 /// </summary>
 public PatchSegment Duplicate(pRom offset)
 {
     return(new PatchSegment(offset, this.data));
 }
Esempio n. 13
0
 public PatchSegment(pRom offset, byte[] data)
 {
     this.TargetOffset = offset;
     this.data         = data;
 }
Esempio n. 14
0
 public void LoadPattern(pRom offset)
 {
     patternOffset = offset;
 }
Esempio n. 15
0
 public PointerTable(MetroidRom rom, pRom tableLocation, int tableSize)
 {
     this.Offset = tableLocation;
     this.Rom    = rom;
     this.Count  = tableSize;
 }