Commit Graph

65 Commits

Author SHA1 Message Date
Haven1433
ecfb990fb0 Verify that scripts can parse negative word values 2022-01-08 19:53:32 -06:00
Haven1433
c9aaa8b4ba Improve script decompile hex logic
* Allow a value to be shown in hex if it's an out-of-range enum value
* Have values default to hex if they're >= 0x4000
2021-12-14 07:40:42 -06:00
Benjamin Popp
cf8da71e5b Use base 10 for scripts
base-16 values can be entered by prefixing with 0x or $.
base-16 values will be output by the script parser if the argument is suffixed with |h
All other values will now naturally decompile to base-10.
2021-11-29 07:30:32 -06:00
Benjamin Popp
1972361c2b Notify OW width/height changing when changed from stream
Notification previously worked when changing via the main view or when changing via an element in the table tool. But notification didn't work right for stream deserialization, since the stream wasn't aware of what was changing.

Now, all write-data-to-model methods return a flag expressing whether or not they actually wrote any data. This makes it possible for streams to know which elements of the stream were changed, which means notification now works correctly.

Note that we are not notifying for compressed data changes or whenever a new stream is created from scratch.
2021-10-18 22:50:42 -05:00
Benjamin Popp
0bb9eaa224 when changing text causes it to repoint, update the script 2021-08-01 00:03:33 -05:00
Benjamin Popp
ade819e561 fix pokemart format element name 2021-07-31 23:28:33 -05:00
Benjamin Popp
6df5c90dcc fix data format consistency
Not only do we need to clear any excess after the new run is inserted (if the old run was longer), we also need to clear any conflict before the new run is inserted (if the new run is longer). This prevents format conflicts.
2021-07-30 08:20:37 -05:00
Benjamin Popp
ae80071ce5 fix scripting bugs
* script repointing should during ?????? pointer resolution: make sure that the pointer resolves to a different address than the script repoints to. This happened because we were looking for freespace for the new pointer and the moved script at the same time.
* when auto-repointing a script, clear the old pointer format and update their anchors with the new destination. This is not happening automatically because scripts don't hold all their length like other runs do, so repointing them left their pointers behind.
2021-07-29 23:35:13 -05:00
Benjamin Popp
0a9a61f2ef Keep anchors when editing script text 2021-07-29 16:12:22 -05:00
Benjamin Popp
e5a8cc39dc fix trainerbattle compile error 2021-07-29 09:44:37 -05:00
Benjamin Popp
066eb689bc allow label parsing in scripts when there are no <> 2021-07-29 07:56:08 -05:00
Benjamin Popp
89f733ecdc script ArrayArg -> handle 0 args correctly 2021-07-25 21:27:10 -05:00
Benjamin Popp
46af7d65de fix script-insertion anchor issue
when writing a new script run, don't pass in the pointer sources for the parent script
2021-07-23 23:23:29 -05:00
Benjamin Popp
ccc1d81a0e fix edge case bugs
* scirpt parser needs to clear format before inserting movement streams
* give a reasonable max limit for warp x/y position
2021-07-23 22:29:36 -05:00
Benjamin Popp
83cb7280a1 Fix script-text insertion bug
When inserting text from a script, clear the format first
2021-07-23 09:27:41 -05:00
Benjamin Popp
a3394df79d Don't make the script-parser read _really slow_ if it's reading a bunch of nops in a row 2021-06-18 23:53:31 -05:00
Benjamin Popp
0995bb9068 Fixing script parsing bugs
* Don't crash if a line contains nothing but whitespace
* Decode variable-arg commands correctly
* Decode animation scripts as animation scripts
2021-04-28 20:53:13 -05:00
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