コード例 #1
0
ファイル: Expander.cs プロジェクト: snarfblam/editroid
        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);
            }
        }
コード例 #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;
     }
 }
コード例 #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);
 }
コード例 #4
0
ファイル: PatternTable.cs プロジェクト: snarfblam/editroid
        }         // 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);
        }
コード例 #5
0
ファイル: Level.cs プロジェクト: snarfblam/editroid
        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)));
            }
        }
コード例 #6
0
ファイル: Expander.cs プロジェクト: snarfblam/editroid
 public void SetPointers(Level level, pCpu ppPTable, int pointerCount)
 {
     this.pPTable     = ppPTable.AsPRom(level);
     this.ptableCount = pointerCount;
     this.pSource     = level.DerefHandle(ppPTable);
 }
コード例 #7
0
 public pCpu(pRom romOffset, Level level)
     : this(level.CreatePointer(romOffset).Value)
 {
 }
コード例 #8
0
ファイル: Level.cs プロジェクト: snarfblam/editroid
 /// <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));
 }
コード例 #9
0
ファイル: Level.cs プロジェクト: snarfblam/editroid
        /// <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));
        }
コード例 #10
0
ファイル: MetroidRom.cs プロジェクト: snarfblam/editroid
 internal void WritePointer(pRom offset, pCpu pointer)
 {
     data[(int)offset]     = pointer.Byte1;
     data[(int)offset + 1] = pointer.Byte2;
 }
コード例 #11
0
ファイル: MetroidRom.cs プロジェクト: snarfblam/editroid
 /// <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));
 }
コード例 #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));
 }
コード例 #13
0
 public PatchSegment(pRom offset, byte[] data)
 {
     this.TargetOffset = offset;
     this.data         = data;
 }
コード例 #14
0
 public void LoadPattern(pRom offset)
 {
     patternOffset = offset;
 }
コード例 #15
0
 public PointerTable(MetroidRom rom, pRom tableLocation, int tableSize)
 {
     this.Offset = tableLocation;
     this.Rom    = rom;
     this.Count  = tableSize;
 }