/// <summary>
        /// Stores a section in this collection
        /// </summary>
        /// <param name="startAddress">Start address</param>
        /// <param name="endAddress">End address</param>
        /// <param name="type">Memory section type</param>
        public void AddSection(ushort startAddress, ushort endAddress, MemorySectionType type)
        {
            var startAnn = Parent.GetAnnotationFor(startAddress, out var start);
            var endAnn   = Parent.GetAnnotationFor((ushort)(endAddress - 1), out var end);

            if (startAnn == endAnn)
            {
                // --- The section is within one bank
                var tempSection = new MemorySection(start, end, type);
                startAnn.MemoryMap.Add(tempSection);
                startAnn.MemoryMap.Normalize();
                SaveAnnotations(startAnn, startAddress);
            }
            else
            {
                // --- The section overlaps multiple banks
                // --- We must be in FullViewMode to get here
                var origSection = new MemorySection(startAddress, endAddress, type);
                for (var bank = 0; bank <= 3; bank++)
                {
                    var bankSection = new MemorySection((ushort)(bank * 0x4000), (ushort)(bank * 0x4000 + 0x3FFF));
                    if (origSection.Overlaps(bankSection))
                    {
                        // --- There is a memory section for this bank
                        var cutSection = origSection.Intersect(bankSection);
                        var bankAnn    = Parent.GetAnnotationFor(cutSection.StartAddress, out var cutStart);
                        Parent.GetAnnotationFor(cutSection.EndAddress, out var cutEnd);
                        bankAnn.MemoryMap.Add(new MemorySection(cutStart, cutEnd, type));
                        bankAnn.MemoryMap.Normalize();
                        SaveAnnotations(bankAnn, startAddress);
                    }
                }
            }
        }
Exemple #2
0
        public void IntersectionWorksAsExpected2()
        {
            // --- Arrange
            var ms1 = new MemorySection(0x1000, 0x1FFF);
            var ms2 = new MemorySection(0x0000, 0x0FFF);

            // --- Assert
            ms1.Intersect(ms2).ShouldBeNull();
            ms2.Intersect(ms1).ShouldBeNull();
        }
Exemple #3
0
        public void IntersectionWorksAsExpected5()
        {
            // --- Arrange
            var ms1 = new MemorySection(0x1000, 0x1FFF);
            var ms2 = new MemorySection(0x1100, 0x11FF);

            // --- Act
            var intersection1 = ms1.Intersect(ms2);
            var intersection2 = ms2.Intersect(ms1);

            // --- Assert
            intersection1.ShouldNotBeNull();
            intersection1.StartAddress.ShouldBe((ushort)0x1100);
            intersection1.EndAddress.ShouldBe((ushort)0x11FF);
            intersection2.ShouldNotBeNull();
            intersection2.StartAddress.ShouldBe((ushort)0x1100);
            intersection2.EndAddress.ShouldBe((ushort)0x11FF);
        }