Exemplo n.º 1
0
        protected static void Cmd17 <T>(ROM rom, T state)
        {
            int segment      = rom.Read8(3);
            int startAddress = rom.Read32(4);
            int endAddress   = rom.Read32(8);

            if ((uint)startAddress > 0x4000000)
            {
                return;
            }

            SegmentDescriptor descriptor = new SegmentDescriptor(startAddress, endAddress - startAddress);

            rom.SetSegment(segment, descriptor);
        }
Exemplo n.º 2
0
        protected static void Cmd00 <T>(ROM rom, T state)
        {
            int segment = rom.Read8(3);
            //if (segment != 0x19)
            //    throw new ArgumentException("ROM does not use bank 0x19. Did you import a level?");

            int startAddress             = rom.Read32(4);
            int endAddress               = rom.Read32(8);
            SegmentDescriptor descriptor = new SegmentDescriptor(startAddress, endAddress - startAddress);

            rom.SetSegment(segment, descriptor);

            int segmentedAddress   = rom.Read32(12);
            int levelscriptAddress = rom.GetROMAddress(segmentedAddress);

            rom.offset = levelscriptAddress - 0x10; // kostul for adding 0x10
        }
Exemplo n.º 3
0
        public void T000_BasicTests()
        {
            MergeCandidate mc;

            var mm = new MergeManager_Incremental(null);
            mm.MIN_MERGE_SIZE = 1; // force small merge sizes okay for ours tests
            mm.MAX_MERGE_SIZE = 1000; // force 'infinite' merge sizes for our tests
            var gen0seg = new SegmentDescriptor(0, new RecordKey().appendParsedKey("A"), new RecordKey().appendParsedKey("Z"));
            var gen1seg = new SegmentDescriptor(1, new RecordKey().appendParsedKey("A"), new RecordKey().appendParsedKey("Z"));
            var gen2seg = new SegmentDescriptor(2, new RecordKey().appendParsedKey("A"), new RecordKey().appendParsedKey("Z"));

            // add two segments on top of eachother
            mm.notify_addSegment(gen0seg);
            mm.notify_addSegment(gen1seg);

            Assert.AreEqual(1, mm.getNumberOfCandidates(), "candidate count 1");
            mc = mm.getBestCandidate();
            Assert.AreEqual(new SegmentDescriptor[1] { gen1seg }, mc.source_segs);
            Assert.AreEqual(new SegmentDescriptor[1] { gen0seg }, mc.target_segs);

            // add a third segment
            mm.notify_addSegment(gen2seg);

            mc = mm.getBestCandidate();
            System.Console.WriteLine(mc.ToString());
            Assert.AreEqual(3, mm.getNumberOfCandidates(), "candidate count 2");
            Assert.AreEqual(new SegmentDescriptor[2] { gen2seg, gen1seg }, mc.source_segs);
            Assert.AreEqual(new SegmentDescriptor[1] { gen0seg }, mc.target_segs);

            // test removal
            mm.notify_removeSegment(gen2seg);
            Assert.AreEqual(1, mm.getNumberOfCandidates(), "candidate count 3");
            mc = mm.getBestCandidate();
            Assert.AreEqual(new SegmentDescriptor[1] { gen1seg }, mc.source_segs);
            Assert.AreEqual(new SegmentDescriptor[1] { gen0seg }, mc.target_segs);

            mm.notify_removeSegment(gen1seg);
            Assert.AreEqual(0, mm.getNumberOfCandidates());

            mm.notify_addSegment(gen1seg);
            Assert.AreEqual(1, mm.getNumberOfCandidates());

            mm.notify_removeSegment(gen0seg);
            Assert.AreEqual(0, mm.getNumberOfCandidates());
        }
Exemplo n.º 4
0
        public void T000_TestRangeBoundaries()
        {
            MergeCandidate mc;

            var mm = new MergeManager_Incremental(null);
            mm.MIN_MERGE_SIZE = 1; // force small merge sizes okay for our tests
            mm.MAX_MERGE_SIZE = 1000; // force 'infinite' merge sizes for our tests
            mm.getMaxGeneration();

            var gen0abseg = new SegmentDescriptor(0, new RecordKey().appendParsedKey("A"), new RecordKey().appendParsedKey("B"));
            var gen0dfseg = new SegmentDescriptor(0, new RecordKey().appendParsedKey("D"), new RecordKey().appendParsedKey("F"));
            var gen1acseg = new SegmentDescriptor(1, new RecordKey().appendParsedKey("A"), new RecordKey().appendParsedKey("C"));
            var gen2azseg = new SegmentDescriptor(2, new RecordKey().appendParsedKey("A"), new RecordKey().appendParsedKey("Z"));

            // add two gen0 segs
            mm.notify_addSegment(gen0abseg);
            mm.notify_addSegment(gen0dfseg);

            Assert.AreEqual(0, mm.getNumberOfCandidates(), "candidate count 1");

            // add gen1 seg
            mm.notify_addSegment(gen1acseg);
            Assert.AreEqual(1, mm.getNumberOfCandidates());
            mc = mm.getBestCandidate();
            Assert.AreEqual(new SegmentDescriptor[1] { gen1acseg }, mc.source_segs);
            Assert.AreEqual(new SegmentDescriptor[1] { gen0abseg }, mc.target_segs);

            // add gen2 seg
            mm.notify_addSegment(gen2azseg);

            dumpPrioritizedMergeList(mm);
            Assert.AreEqual(3, mm.getNumberOfCandidates(), "candidate count 2");
            mc = mm.getBestCandidate();
            Assert.AreEqual(new SegmentDescriptor[2] { gen2azseg, gen1acseg }, mc.source_segs);
            Assert.AreEqual(new SegmentDescriptor[2] { gen0abseg, gen0dfseg }, mc.target_segs);

            // simulate "merge down" of gen1ac -> gen0abseg
            var gen0acseg = new SegmentDescriptor(0, new RecordKey().appendParsedKey("A"), new RecordKey().appendParsedKey("C"));
            mm.notify_removeSegment(gen1acseg);
            mm.notify_removeSegment(gen0abseg);
            Assert.AreEqual(0, mm.getNumberOfCandidates(), "candidate count 3");
            mm.notify_addSegment(gen0acseg);

            dumpPrioritizedMergeList(mm);
            Assert.AreEqual(1, mm.getNumberOfCandidates());
            mc = mm.getBestCandidate();
            Assert.AreEqual(new SegmentDescriptor[1] { gen2azseg}, mc.source_segs);
            Assert.AreEqual(new SegmentDescriptor[2] { gen0acseg, gen0dfseg }, mc.target_segs);
        }