Commit Graph

48 Commits

Author SHA1 Message Date
Benjamin Popp
8832b49cfd Fix crash bug in script help 2021-02-26 15:42:21 -06:00
Benjamin Popp
c2c5fc1fba fix script parser bugs
Make sure that the text reader handles empty string correctly.
Make sure that the help finder handles beginning whitespace correctly.
2021-02-24 21:51:46 -06:00
Benjamin Popp
68c1496101 Fix Loading Issues
* Don't assert on pointers that point _into_ elements in tables that accept pointers to elements. This is a data error, but the metadata is fine.
* Do clear anchors that would be in the middle of a new run
* Do clear anchors on pointers if that pointer has nothing pointing to it.
* Clear format when introducing a SpriteTemplateStream
2020-11-23 02:12:34 -06:00
Benjamin Popp
128c075676 trainerbattle 03 should have only 3 args after the 03 2020-09-26 22:53:16 -05:00
Benjamin Popp
acdff5146f Introduce new utility method: Range()
Does Enumerable.Range(0, n) in a more compact way.
It's a thing that we need to type a lot.
Also add a new test that captures a problem parsing Overworlds in FireRed
2020-09-16 09:54:04 -05:00
Benjamin Popp
ff76f1c756 Fix scripting bug
In which enums are parsed incorrectly
2020-09-04 21:49:14 -05:00
Benjamin Popp
3966d66181 Right-click -> add new XSE script 2020-08-18 21:33:53 -05:00
Benjamin Popp
b9763affbe Add support for extended display for single-item streams
Also add SpriteTemplate decoding in animation scripts
2020-08-16 20:36:15 -05:00
Benjamin Popp
9932ee3478 Add initial support for animation scripts
Animation scripts can use the same engine as map scripts and battle scripts... except that they include a new type of parameter.

With animation scripts, the last parameter of some lines is allowed to include arbitrarily many arguments. This is represented by putting the last argument in brackets `[]`.
2020-08-10 19:38:56 -05:00
Benjamin Popp
c7a2f546e0 Script improvements
* battle script jumpifstat commands now properly categorize their destination as a battle script
* pasting a battle script or XSE script that forces a repoint will now properly interpret inner-pointers at the newly repointed address. This removes the need to paste a second time to fix up addresses after a paste causes a repoint.
* the script decompilers now do a bit more validation before running, so that they don't try to decompile data that is clearly not a script.
2020-08-08 22:53:04 -05:00
Benjamin Popp
82c6c3c5dc Split compiled code on both types of newlines
When copying from some programs, newlines are just `\n`. So the compiler should split lines on both `\r\n` and `\n`.
2020-08-04 07:10:05 -05:00
Benjamin Popp
d150b68187 Don't show incorrect stream data when decompiling
If GetNextRun's stream run doesn't start at the expected address, then it's not the data we're looking for and we shouldn't add it to the view.
2020-07-04 23:09:55 -05:00
Benjamin Popp
02d6b76510 Fix assertion
Code was actualyl removing in the correct cases. But assert had a false-hit.
2020-07-04 23:04:15 -05:00
Benjamin Popp
2fbd320a06 Clear pointer formats where commands start
Be careful, though: *only* clear pointers. Don't accidentally clear any anchors, because we want to keep those.
2020-06-29 19:49:57 -05:00
Benjamin Popp
750861d16c Battle script pasting should use relative label offsets
When copying a battle script and pasting it elsewhere, if some of the pointers are back into later points in the same script, the new pointers should point into the new script. Do this by checking for relative labels before checking for absolute addresses.
2020-06-29 19:31:17 -05:00
Benjamin Popp
2ec471d0df Introduce SortedSpan
Merging lists takes a long time. Since we want the pointer sources to be sorted at all times, lets expose that detail and take advantage of it to allow us to merge-sort any time we combine tables together. This significantly increases list-merging speeds.
2020-06-25 23:52:37 -05:00
Benjamin Popp
c8ccab9710 Improving battle script support
* Allow battle scripts to _not_ add a new code body if the code body contains a subset of already found code.
* Allow battle scripts to include XXXXXX: labels for parts that have things pointing directly to them.
* Improve battle script parameter recognition.
2020-06-23 22:38:10 -05:00
Benjamin Popp
1c3b30f4ff Fix BSE Scripting issues
* remove undo within script editor textboxes
* properly clear formats when a script gets shorter
* properly clear formats of where pointers used to be when a script changes
* When checking for a need to repoint, use the proper script type
2020-06-04 10:19:33 -05:00
Benjamin Popp
ffe37fa9f4 Fix failing test
Also use automated code review
2020-05-27 23:28:39 -05:00
Benjamin Popp
0e7f5e9e24 Improve script editing 2020-05-22 21:45:32 -05:00
Benjamin Popp
9f14ed091f Don't show tooltip for completed lines 2020-05-18 11:34:12 -05:00
Benjamin Popp
c3b0156502 Improve script tokenizing 2020-05-15 11:12:31 -05:00
Benjamin Popp
1d0d030434 Improve BattleScript support 2020-05-03 22:12:45 -05:00
Benjamin Popp
0e963da3de Load battle-scripts for move effects 2020-05-01 16:52:50 -05:00
Benjamin Popp
93250ec061 Add backbone for battle-script support
battle scripts are almost identical to pokescripts in how they work. Each command has a single-byte code, followed by some number of arguments, each of which are 1 to 4 bytes.

Because of these similarities, we can reuse the same engine code and just load the engine from another file. So the code tool can have a 4th mode and basically just work for free. Runs for battle scripts can be as simple as XSE runs: just a single byte, don't bothe decoding, show decoding only in the tool.

Still to add: how to know which battle script commands are ending commands, or which ones point to other battle scripts, or which ones point to strings. How to view battle scripts in the editor? Etc.
2020-05-01 08:16:04 -05:00
Benjamin Popp
6ed54cd459 Bugfix: show more scripts in script tool 2020-04-28 08:19:45 -05:00
Benjamin Popp
0f73e7b3e4 Tooltip help during scripting 2020-04-27 22:57:18 -05:00
Benjamin Popp
bef73ad75f Support editing marts in scripts 2020-04-24 08:09:54 -05:00
Benjamin Popp
8ffe70dda4 Pointers update when scripts change/move 2020-04-22 22:53:04 -05:00
Benjamin Popp
eb69c8ec46 Update script with new movement/text 2020-04-22 22:07:27 -05:00
Benjamin Popp
38a7d99392 Scripting fixes
* Put the selection in the right place when moving a script
* Don't make an orphan run in the location we moved away from
2020-04-22 17:22:50 -05:00
Benjamin Popp
4f9dd0b3ca Allow <??????> to translate to a new pointer 2020-04-22 15:22:55 -05:00
Benjamin Popp
15d68115bb Show compile errors instead of crashing 2020-04-22 13:10:08 -05:00
Benjamin Popp
8b1320aeff UI for multi-contents
Don't swap out the UI element that's currently being updated.
2020-04-22 11:27:51 -05:00
Benjamin Popp
86b0f1e99b Initial ViewModel for a multi-script editor 2020-04-22 10:56:04 -05:00
Benjamin Popp
a63769e119 Cascade scripts on TOML load
If a toml file contains an XSE script, add the children when loading.
2020-04-21 22:45:48 -05:00
Benjamin Popp
16f34c6d9e Name orphan scripts 2020-04-21 22:16:49 -05:00
Benjamin Popp
053fc56a6b Include streams in scripts
Scripts that access text / movement data should include those inline.
2020-04-21 15:51:01 -05:00
Benjamin Popp
9c6212bcac Abbreviate underscore_values in enums 2020-04-21 11:07:26 -05:00
Benjamin Popp
1fb1460965 Add movement data from script 2020-04-21 08:16:10 -05:00
Benjamin Popp
3d441ce570 Add text decoding 2020-04-20 16:26:18 -05:00
Benjamin Popp
0e37719ca2 Use an anchor instead of a run for the initial XSE script add 2020-04-20 15:38:27 -05:00
Benjamin Popp
85422d06e1 Make it possible to edit scripts inline
Also add support for operator decoding for if statements
Inform users on repoint
2020-04-20 14:56:28 -05:00
Benjamin Popp
5b11e11c7a Parse argless commands correctly 2020-04-20 12:43:40 -05:00
Benjamin Popp
b79d7a6ea1 Allow inline script editing 2020-04-20 11:18:42 -05:00
Benjamin Popp
9c0732c2da Load useful scripting info when opening from AMap
* Add XSERun, which right now is just a 1-byte header that marks the start of a script segment.
* Add the ability to cascade down through script segments to find all endpoints, adding XSERuns and pointers as needed.
2020-04-18 16:08:04 -05:00
Benjamin Popp
3e8fd018a1 Refactor Singletons
Previously, the creating a new ViewPort loaded from 2 text files and creating a new HardcodeTablesMoel loaded from 1 text file. This is a lot of parsing!

Refactor to do the parsing once, in the EditorViewModel, using a Singleton class to hold the non-editable loaded data. Inject that data into the appropriate structers later on.

To prevent massive refactoring in the tests, not every ViewPort needs to be given a Singletons instance. Instead, allow a ViewPort to still do its own parsing. However, BaseViewModelTestClass has been updated to make this work for a majority of tests, along with changes to AutoSearchTests's fixture and several of the Setup methods that are used by multiple tests.
2020-02-08 21:25:48 -06:00
Benjamin Popp
7f2655655e Add Scripting to Code Tool
Being able to dissassemble ARM code is only half of the code that hackers want to see. They also need to be able to read/write pokescript, often done via tools like XSE. Eventually I can be more intelligent with scripts, but for now a simple decoder is plenty.
2019-07-17 22:02:15 -05:00