Example #1
0
        public static void TraverseChildren()
        {
            var(_, data) = TinyHiRomCreator.CreateSampleRomByteSourceElements();

            var snesAddress = data.ConvertPCtoSnes(0);

            var snesByte = data.SnesAddressSpace.Bytes[snesAddress];
            var romByte  = data.RomByteSource.Bytes[0];

            Assert.Null(snesByte);
            Assert.NotNull(romByte);

            Assert.NotNull(romByte.Annotations.Parent);
            Assert.Equal(3, romByte.Annotations.Count);
            var opcodeAnnotation = romByte.GetOneAnnotation <OpcodeAnnotation>();

            Assert.NotNull(opcodeAnnotation);
            Assert.NotNull(opcodeAnnotation.Parent);
            Assert.Equal(opcodeAnnotation.Parent, romByte);

            var graph = ByteGraphUtil.BuildFullGraph(data.SnesAddressSpace, snesAddress);

            var flattenedNode = ByteGraphUtil.BuildFlatDataFrom(graph);

            Assert.NotNull(flattenedNode);
            Assert.NotNull(flattenedNode.Byte);
            Assert.Equal(0x8D, flattenedNode.Byte.Value);
            Assert.Equal(3, flattenedNode.Annotations.Count);

            // make sure the parent hasn't changed after we built our flattened node
            Assert.Equal(opcodeAnnotation.Parent, romByte);
        }
Example #2
0
        public static void TestGetFlatByteNonPadded()
        {
            // Get a byte from the sample data that is a real (i.e. non-padded) byte

            var       sampleData  = SampleRomData.CreateSampleData();
            const int romOffset   = 0x0A;
            const int snesAddress = 0x808000 + romOffset;

            var flatByte = ByteGraphUtil.BuildFlatDataFrom(sampleData.Data.SnesAddressSpace, snesAddress);

            Assert.NotNull(flatByte);
            Assert.NotNull(flatByte.Byte);
            Assert.Equal(0xC2, flatByte.Byte.Value);
        }
Example #3
0
        public static void TestGetFlatByteInRange()
        {
            // Get a byte from the sample data that is a padded (i.e. for sample ROMs we can create them with a different
            // size than their source data. in this one, we pad the ROM from a few hundred bytes and add zero'd bytes
            // until we reach 32k bytes). This test is mostly testing that we built the sample data correctly, in real
            // world scenarios, this would never fail because we're not doing padding.

            var       sampleData  = SampleRomData.CreateSampleData();
            const int romOffset   = 0xEB;
            const int snesAddress = 0x808000 + romOffset;

            Assert.True(romOffset >= sampleData.OriginalRomSizeBeforePadding);

            var flatByte = ByteGraphUtil.BuildFlatDataFrom(sampleData.Data.SnesAddressSpace, snesAddress);

            Assert.NotNull(flatByte);
            Assert.NotNull(flatByte.Byte);
            Assert.Equal(0x00, flatByte.Byte.Value);
        }