Пример #1
0
        public void SearchFindsEggMoveData()
        {
            CreateSimpleRun();

            var pairs = viewPort.Find("wind");

            Assert.Contains((2, 3), pairs);

            pairs = viewPort.Find("carl");
            Assert.Contains((0, 1), pairs);
        }
Пример #2
0
        public void CanEndCommentWithPound()
        {
            ViewPort.Edit($"FF @00 ^text\"\" Some # Comment Here #Text");
            var matches = ViewPort.Find("Some Text");

            Assert.Single(matches);
        }
Пример #3
0
        public void CanIncludeCommentsInPasteScripts()
        {
            var nl = Environment.NewLine;

            ViewPort.Edit($"FF @00 ^text\"\" Some # Comment Here {nl}Text");
            var matches = ViewPort.Find("Some Text");

            Assert.Single(matches);
        }
Пример #4
0
        public void SearchForByteRunName_ReturnsByteRuns()
        {
            ViewPort.Edit(".some.counter @02 .some.counter @00 ");

            var results = ViewPort.Find("some.counter");

            Assert.Equal((0, 0), results[0]);
            Assert.Equal((2, 2), results[1]);
        }
Пример #5
0
        public void TextWithEscape_Search_Find()
        {
            var text = "Some\\nText";

            PCSString.Convert(text).WriteInto(Model.RawData, 0x20);

            var results = ViewPort.Find(text);

            Assert.Equal(0x20, results.Single().start);
        }
Пример #6
0
        public void SearchFor6BytesAlsoFindsPointers()
        {
            var data     = new byte[0x1200];
            var model    = new PokemonModel(data);
            var viewPort = new ViewPort("file.txt", model);

            viewPort.Edit("<001060>");
            var results = viewPort.Find("001060");

            Assert.Single(results);
        }
Пример #7
0
        public void FindCanFindSingle()
        {
            var array = new byte[0x1000];

            new byte[] { 0x84, 0x23, 0xBB, 0x21 }.CopyTo(array, 0x240);
            var port = new ViewPort(new LoadedFile("test", array));

            var results = port.Find("84 23 BB 21");

            Assert.Single(results);
            Assert.Equal(0x240, results[0].start);
        }
Пример #8
0
        public void CanFindPointer()
        {
            var buffer   = new byte[0x100];
            var model    = new PokemonModel(buffer);
            var viewPort = new ViewPort("file.txt", model)
            {
                Width = 0x10, Height = 0x10
            };

            viewPort.SelectionStart = new Point(4, 1);
            viewPort.Edit("<000058> 23 19");
            var results = viewPort.Find("<000058> 23 19");

            Assert.Single(results);
        }
Пример #9
0
        public void FindCanFindMultiple()
        {
            var array     = new byte[0x1000];
            var searchFor = new byte[] { 0x84, 0x23, 0xBB, 0x21 };

            searchFor.CopyTo(array, 0x240);
            searchFor.CopyTo(array, 0xA70);
            var port = new ViewPort(new LoadedFile("test", array));

            var results = port.Find("84 23 BB 21").Select(result => result.start).ToList();

            Assert.Equal(2, results.Count);
            Assert.Contains(0x240, results);
            Assert.Contains(0xA70, results);
        }
Пример #10
0
        public void StringSearchAutomaticallySearchesForPointersToResults()
        {
            var text   = "This is the song that never ends.";
            var bytes  = PCSString.Convert(text).ToArray();
            var buffer = new byte[0x200];

            Array.Copy(bytes, 0, buffer, 0x32, bytes.Length);                // the data itself, positioned at x32 (won't be automatically found on load)
            Array.Copy(new byte[] { 0x32, 0, 0, 0x08 }, 0, buffer, 0x10, 4); // the pointer to the data. Pointer is aligned, but data is not.
            var model    = new PokemonModel(buffer);
            var viewPort = new ViewPort("test.gba", model);

            // the act of searching should find the anchor
            var results = viewPort.Find("this is the song");

            Assert.Single(results);
            Assert.Single(model.GetNextRun(0x32).PointerSources);
        }
Пример #11
0
        public void FindForStringsWorksWithoutQuotes()
        {
            var buffer = Enumerable.Repeat((byte)0xFF, 0x200).ToArray();

            for (int i = 0; i < 0x10; i++)
            {
                buffer[i] = 0x00;
            }
            var model    = new PokemonModel(buffer);
            var viewPort = new ViewPort("test.txt", model)
            {
                Width = 0x10, Height = 0x10
            };

            viewPort.Edit("^bob\"\" \"Text and BULBASAUR!\"");

            var results = viewPort.Find("bulbasaur").Select(result => result.start).ToList();

            Assert.Single(results);
            Assert.Equal(9, results[0]);
        }
Пример #12
0
        public void CanSearchForTextWithinPlmStream()
        {
            // setup text tables
            SetupNameTable(0x40);
            SetupMoveTable(0x80);

            // setup pointers that will eventually be in the lvlmoves table
            viewPort.Goto.Execute("000000");
            viewPort.Edit("<000100><000110><000120><000130><000140><000150><000160><000170>");

            // setup data that lvlmoves pointers will point to
            for (int i = 0x100; i < 0x180; i += 0x10)
            {
                SetupPlmStream(i, 6, withName: false);
            }

            // add lvlmoves table
            viewPort.Goto.Execute("000000");
            viewPort.Edit($"^{HardcodeTablesModel.LevelMovesTableName}[data<`plm`>]{HardcodeTablesModel.PokemonNameTable} ");

            var results = viewPort.Find("Three");

            Assert.Equal(9, results.Count); // the actual text + entries for the 8 pokemon
        }