Commit Graph

80 Commits

Author SHA1 Message Date
Haven1433
ee28bc8a02 initial ai script support 2022-09-12 20:23:40 -05:00
Haven1433
610171b59a fix broken behavior
New rule: when clearing format and the run starts _before_ what we're clearing, leave the pointers and a NoInfoRun. Before this rule, we would clear out the anchor as well, which could cause some confusion if that anchor/format was re-added later, since it wouldn't know about tables that point to it.

Fix bug in script parser: next text runs should know about pointers to them
2022-09-11 20:59:35 -05:00
Haven1433
52880278ea update battleScriptReference
thanks to AGSMG for helping to fill out some of these missing details
2022-09-01 12:45:33 -05:00
Haven1433
810f8c7a65 ScriptParser needs to know which game it is.
The 'showmoney' and 'updatemoney' commands are different from game to game. It has 2 parameters in R/S, but 3 parameters in FR/LG/E.

Update the scriptReference to specify that these commands have different versions for the different games.

Update ScriptParser to be able to read this new addition to the script reference format.

Add tests to show that the new commands are read correctly between games.
2022-08-25 06:51:51 -05:00
Haven1433
65765e695f Allow Text Macros
* Replace the static PCSString.Convert method with an instance method on a TextConverter that's owned by the Model. The TextConverter can know about different macros depending on which rom is being edited.
* Add macros to pcsReference.txt
2022-06-02 20:53:39 -05:00
Haven1433
01f0c3905e battle script update 2022-05-16 21:11:48 -05:00
Haven1433
485b307115 Don't require filler arguments to be explicit 2022-05-03 10:50:57 -05:00
Haven1433
5bccc8258f improve script parsing
allow enum tables to parse numeric values
2022-05-03 06:51:04 -05:00
Haven1433
87bd11fd7a Don't have scripts clear the pointer-to format if we don't need to 2022-04-17 22:11:11 -05:00
Haven1433
8c873c881d support multiple loadgfx commands in a row 2022-04-17 20:51:11 -05:00
Haven1433
13ca381bb5 Fix error message for trainerbattle script command 2022-04-13 21:16:12 -05:00
Haven1433
e251b08ac8 Improve battle script parsing 2022-03-19 22:56:31 -05:00
Haven1433
cc0406a06d Read 0x prefix as hex when compiling multi-args
Also read 0X and $ as hex.
2022-02-19 20:53:57 -06:00
Haven1433
b1d599098b call points to the next script 2022-02-18 21:51:18 -06:00
Haven1433
f5f16166bd Use 0x prefix for hex values in group arguments 2022-02-18 21:51:03 -06:00
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