* Avoid using foreach/enumorables in `MacroScriptLine.Matches` since it's called so often.
* Use Span<char> to reduce string allocations in `ArrayRun.ctor` and `ArrayRunEnumSegment.GetOptions`
* don't store the delta object used for initial setup
* avoid making lambdas in `ScriptLine.Matches`, which is called very often.
* use use List<int> instead of SortedSpan<int> for building the initial DestinationToSource cache, since we're already guaranteed that they'll be added in order and without duplicates. This greatly reduces the number of int[] arrays created during startup.
* allow `ArrayRunPointerSegment` to cache the table content results from parsing its InnerFormat, so it doesn't have to re-parse each time. This greatly reduces the number of string allocations.
* Use `ThreadSafeDictionary` for `TryGetValueCaseInsensitive` so we don't need to create a new collection of keys each time we call the method. Also add key caching to `ThreadSafeDictionary` so we don't need to make a new collection each time it's requested.
* Make `GetOptions` return a readonly list. We already know it's unique, this means we don't have to make a new collection every time we parse segments.
* limit the number of undo tokens we store (default 100) to save memory
* Use `byte[]` and `Array.Copy` instead of `List<byte>` and `AddRange` to reduce byte array allocations when loading a file.
* Freeze geometries in the `Icons` collection.
* add option for running garbage collection from the developer menu
* use a custom `AutomationPeer` to prevent WPF from holding memory after controls have been closed.
* Remove the `compact` macro, since it's just a combination of 3 macros that each make sense by themselves. The goal for macros is to put them in situations where you wouldn't ever want the command by itself.
* Move the `if` macros down to live with the other `if` macros.
* The `(` symbol has been moved.
This was supposed to go in the previous pull request, but I was too late...
* Added another `msgbox.yesno` macro.
No testing has been done yet.
* Added if.yes & if.no macroes.
Caution: These macroes will show up unintentionally if you're using commands other than msgbox.yesno that involve comparing the last result variable (800D) with the literal number 1.
* Fixed the `ptr` pointer format.
my bad
* Configured the macroes.
* Added comments to the macros.
They seem all jumbled up.
* Added corresponding cmds. for trainerbattle 0−8.
Testing needs to be done to make sure they work atm.
* Updated trainerbattle 09 & 0C.
though trainerbattle 09 will need another change.
* Added trainerbattle 09 types based on a bit field.
Right-most bit: Whether or not the player can lose
Second-right-most bit: Tutorial battle w/ Professor Oak
Based on the combinations of bits, I added more variants to FRLG's `trainerbattle 09` command.
* LocalIDs are correctly filled in as 1/2-words now.
My bad
---------
Co-authored-by: haven1433 <haven1433@gmail.com>
I thought the Berry Master & his wife would pull items from this table to give to the player if the player inputted the correct phrases; however, this specific table is only referenced in the `SetOpponentsBerryData` function in Pokémon Emerald.
* Added a macro for multichoice's allowCancel field.
0 = the game does not ignore B presses (OK to cancel out)
1 = the game ignores B presses (forbid canceling out)
* Clarified by adding "Cancel" to each option.
* Added "movenpc" command.
The exact things will be subj to change.
* Fixed "move.npc" and added "move.player."
I'll need to test these soon.
* Switched the order of 2 command macroes.
Switched the order of move.player and move.npc.
* Fixed the move.player command macro.
I can't specify base-10 numbers to hard code, apparently.
* Added the "move.camera" macro.
* Each new movement macro has 2 lines of flavor text
* Removed the constant references for the XY coords.
We may need to do the same for the default BPEF and BPEI `.toml` files.
These addresses are actually part of thumb instructions and don't have anything to do with the spawn coordinates.
Actually, Emerald's code makes the player spawn at (−1, −1), which is a pair of invalid coordinates; therefore, the player actually spawns in the centre of the map. Another tricky thing is that there's no indication in the thumb code about those −1 coordinates — at least one we haven't found yet..
* Removed XY starting constants for Ruby & Sapphire.
(same reason as Emerald's case from a while ago)
when generating data for a new stream and the pointer is to freespace, be aware that we're creating a stream starting from length zero, rather than whatever the model data parses as the length. The parsed length doesn't matter, because we're pointing at freespace.
* In sky attack, after the two-turn-animation command, the `end` command is pointed to by other pieces of script. Since its address actually matters, don't combine things together into a single script.
* Both CollectScripts and FindLength have script aggregation logic that needs to be limited.
For script performance:
* call data.GetGameCode() less often, using a cached value for the ScriptParser
* use a 4-byte game code instead of string parsing for the game code
For map previews in the table tool performance
* Don't use dispatcher foreground/background thread swapping, it's safe to add the previews to the collection from the background thread.
* Check the exit condition more often
For drawing performance:
* Use Array.Copy when we don't need to worry about Transparency, since it's much faster.
* Make `Darken` faster, we call it a lot
* Reuse DarkenRect utility in HighlightCollision
Other performance changes
* Protototype for ObserableList<T> for a more configurable version of ObservableCollection
Situation:
* Script A refers to B and C. B and C occur right after eachother.
* Scirpt B does not refer to script C, so C doesn't get included in the same body.
-> when editing B, B needs to know that its length does not include C. So the script-length-cache that B uses shouldn't know about C, since B doesn't refer to C.
-> Therefore, B can't use the same cache as A.
* track length caches based on the code body start, not based on the entire model. This lets each code body have its own cache.
* fadescreen should use screenfades list
* map object graphics should use overworld sprites enum (allows finding events from the overworld sprites table)
* change field name from 'unused' to 'padding' for final part of object event data
* Updated the "jumpiftype" commands' type field.
* Added the other keypadIcons anchor.
The name was very similar in the decomps, but this anchor refers to a table instead of a sprite sheet.
* Added the HM logo image in tableReference.txt.
Thank you VersekrDarkYT for notifying us about this image in #feature-requests!
* Added Emerald's message box graphics anchor refs.
Thank you Lunos for the feature request! The word "noframe" for Emerald's message box identifies the message box graphics used for stuff like the "Would you like to save the game?" prompt. These type of message boxes are independent of the text frame configured by the player.
* Miscellaneous typo fixed.
We previously had code that tried to find lengths of sub-scripts from scripts, but only followed pointers forward, not backward, to prevent infinite loops. But it didn't properly handle scripts that _do_ have backwards pointers: it was returning a length of 1 for those, which is wrong.
* Updated the "graphics.text.importer" formatting.
The "a" field was actually supposed to be 4 one-byte fields.
* Added the table for Japanese bold glyphs in EM.
* Added support for the keypad characters image.
I don't know what palette is associated with this image, though.
* Moved new table to a more appropriate location.
* Added "data.fonts" support for Emerald.
The table in EM is formatted differently than in RS. I'm going to make an "allFonts" [[List]] soon for Ruby, Sapphire, and Emerald.
There is 1 tab character before the first offset in some of the rows of tableReference.txt (like on lines 784 to 788), which may require revamping the file altogether.
* Started the [[List]] of all fonts for Emerald.
A few notes:
− "short2" comes before "short" because of the naming conventions HMA already has in place for the two short fonts that are similar but have different lower-case Ls. (short2 has the lower-case L that's used in battles, etc.). The regular "short" is "short_narrow" in the decomps.
− I suspect that the "?" entries are Japanese fonts, but I'm not sure about which ones.
I still need to make Ruby's list and do some testing.
* Added a table for the multipliers on stats.
These are the values that are multiplied (then divided) when your Pokémon's at −6, −5, ..., +5, or +6 in battle.
* Filled in the rest of the allFonts List for EM.
07 = japan2
08 = japan1
02-05 = japan3
The game uses some font slots for multiple fonts. If you used \CC0608 before text, you would get glyphs from "graphics.text.font.short.characters" OR "graphics.text.font.japan1.characters", depending on what language you specified in your text string.
* Added the allFonts [[List]] for Ruby & Sapphire.
Many of the fonts in "data.fonts" are duplicates, albeit with minor numerical changes here and there.
I'd be fine with removing the '-01,' '-02,' etc. and just leaving duplicates of font names ('japan1,' 'japan1∼2,' etc.) if that's less confusing.
* Moved and standardized the stat changes table.
Changed the name and location, as well as adding another field to the table formatting.
* don't allow streams to have <section> labels
* update the <auto> algorithm to allow stream pointers to be picked up in the middle of a script. This will get changed if the script is recompiled to put the streams at the end, but it allows longer scripts to be read no matter where the streams were placed.
* Implemented Skyzio's BPEF .toml into the defaults.
I think we still have to whitelist BPEF so that more bytes get formatted instead of just the header, game code, etc.
* Updated the default.bpef.toml file.
* Updated .csproj file to incorporate the BPEF .toml
* Move particle names start at index 0 now.
Having them start at 10k didn't work the way I wanted them to work.
Also, I removed the low lines from each item in the list because it unintentionally triggered the letter abbreviations when shown in the hex content viewer.
* Implemented the move_particle list.
I will need to test these changes very soon.
The animation script commands would show the names of the move particles instead of numerals, and the move particles tables' length would be controlled by the newly-added list.
* Undid the animationScript change.
This change caused crashes, though I think those crashes could be resolved.
* Broke apart the "japan2" font.
In Emerald, HMA renders its "japan2" font incorrectly. It's only supposed to contain 16,384 bytes worth of characters while the preceding bytes are actually unused font sheets and widths. Those are now formatted as separate runs. The issue is that I can't put any of these changes in "tableReference.txt" because none of those tables/images have anchors to reference since they're unused.
* Fixed the japan2 characters format.
* Filled in missing font addresses.
Two fonts in Japanese that are rendered backwards in HMA (and possibly unused) and the short font used when showing Pokémon nicknames in battle.
* Removed an overlooked comment.
also fix possible race condition when refreshing border render while drawing the map
also fix condition where writing script data content formats shouldn't write empty runs if the token doesn't allow changes.
* better for experts because they can more easily parse a handful of section headers compared to random hex addresses
* Better for new users because it helps them learn that they can use whatever names they want for the headers of scripts and for pointers.
doing <??????> auto-included a new {} block, which is cool. But that block needs to not be included when calculating the new cursor position, because the cursor position should remain _before_ the new {}, so it's still on the same line in case you're writing `trainerbattle` or something with multiple pointers in the line.
* Changed which NPC facing option we shouldn't use.
The movement behavior right below "FaceRight" is actually the one that confuses people as it used to be called "Look Down" in AdvanceMap. That one causes weird stuff to happen after a battle while the first movement option is now correctly labeled "No Movement."
* Reverted the CausesGlitches change.
note that this could be dangerous, since we're writing an end token to an arbitrary address that is still being decided on. A couple things mitigate this problem:
* the user can use <auto> pointers in scripts
* addresses won't be checked/used unless the user has both an open < and a close >.
* Correctly fixed the domains of script commands.
According to the 3 decomps' "script_cmd_table.inc" file, Ruby/Sapphire's last command is at index C5 while FireRed/LeafGreen's last command is at index D4. Thus, I updated the file so that valid commands would only show up if you're editing a game with which said commands would be valid.
ex. preparemsg3 no longer shows up as a valid command in FR/LG.
* Found out the parameter for fadescreen3.
Thank you decomps!
I'm not sure if the "mode.screenfades" parameter is the same for the "fadescreen" command.
* Updated "trainerbattle" & other scripts' comments.
Added some comments to clarify some unknowns in commands 5E, 5F, and 65.
I also fixed some comments and unknown pointers in the trainer battle commands.
* More minor comment fixes.
I mean the word "not" in the comments for commands 4D & 4E. The commands are technically not "nop"s in the code, but the edit to 0x800D is commented out.
* Clarified warp descriptions & other commands.
- Warp commands have more descriptive comments.
- Changed FRLG's description for "nop2C."
- Added another way to fill in the "condition" parameter for "gotostdif" and "callstdif" to make it more in line with "if1" and "if2."
* Adjusted Pokémon animation options.
- Renamed "...animations.options" to "...animations.options.front" (even though those animation codes are not exclusive to front sprite animations)
- Added "...animations.options.back" since there's a smaller table for Pokémon's back sprite animations.
The words "extreme," "medium," and "mild" are used (in this context) to describe the differences in animations used for each back animation sprite slot. The Pokémon's nature determines which of the three to use.
* Added the nature mod table for Pokémon back anims.
I also updated the formatting for "graphics.pokemon.animations.back."
* Added buffer macros
These can be used instead of \\02, \\03, and \\04 in the Text tool.
* Buffers now don't have spaces in them.
* Fixed an alignment error.
* submit failing tests
* Grab failing trainer test from remote branch (#121)
* Updated flash constants
* Fixed flash constant locations
I originally supplied anchor references, not locations of the constants themselves. That's been fixed. Also, I changed the field name for flash.radius, so it's hopefully clearer.
* Fixed some other pointer issues with RAM addresses in script commands
RAM addresses can't be encased in <> nicely. Some commands still needed their RAM-address pointers to have the ::|h formatting instead.
* Fixing some parameter formats in the script reference file.
There were a few other commands that needed RAM-address parameters set to their correct format so that typing "2024284" doesn't auto format to 0xA024284, etc.
* update script reference (again)
* Added a failing test for duplicating trainer data
Bug report in query: https://discord.com/channels/538022037718040588/538022038376415234/1083215729177931877
---------
Co-authored-by: ShinyTillDawn <80070404+ShinyTillDawn@users.noreply.github.com>
* Fix test
ExportTilesetWithPalette2_EditTileset_ImportTilesetWithPalette2_DataMatches
-> fix formatting in LzSpriteRun
-> fix overflow error in SpriteRun
-> fix default palette detection in SpriteTool
-> improve test so it gives better failure info
* fix trainer duplication assert
fix test name / remove unneeded comments
handle Trainer team runs specially
update assertion error message
* Improve pointer error logic
Pointers are allowed to point into the middle of an existing run. Such a pointer is an error, but is not a metadata inconsistency. Update metadata checking for new logic. Update pointer logic to display pointer as an error.
* improve handling of `auto`
allow <auto> to be used if there's a one-byte gap
* improve interruptingSourceRun logic
an interrupting table is not always valid.
It's only valid if the source is at an index that would make it a pointer.
* don't clear bytes, clear anchors
If you have a custom anchor name in the middle of a script and then edit the script, that custom anchor name will be lost. But anything pointing to it will still point to it.
---------
Co-authored-by: ShinyTillDawn <80070404+ShinyTillDawn@users.noreply.github.com>
* Added the constant related to OW table limiters.
By default, it's 151 (0x97) in the Kanto games.
* Updated the OW table for FRLG.
The length is now controlled by a newly added constant.
I primarily focused on D2 setcatchlocation so that its location parameter allowed the user to type in map names. I found more commands that needed similar treatments.
* Another scriptReference edit
Updated some incorrect/missing commands in script reference, adjusted the Address width, and implemented the directions macro for the spriteface command.
* Marked lines 270 and 273 as [BPEE].
Similar to the prize money field in the trainer table, I added a field to the Pokémon stats table for a Pokémon's base stat total.
(Requested by Dweebio The Rom Hacker)
* Implemented 8 feature requests or so
- fixing money cap description
- updating trainer AI script command parameters so names of types/moves can be used
- updated various font anchors
- made lists for trainer AI scripts
- added floor names for FRLG
* Fixed ability field oversight
IDK how I had the ability field use the type field.
When scripts get merged together, some inner-scripts no longer appear to be real scripts. These were showing up as orphans when the scripts get formatted, since that causes scripts to get merged. But the pointers are still there, so they're not actually orphans.
Fix the orphan-naming logic so that it won't name things as orphans if they're inner scripts that still have pointers
ai script children should appear as ai scripts
editing an AI script shouldn't make a bunch of orphans
introduce a light caching system for noticing when scripts don't need to be loaded again.
script edits that don't change any compiled bytes should be capable of skipping the metadata update in situations where the metadata is already correct
* replace cleartrainerflag/settrainerflag with defeatedtrainer/readytrainer
* update `if` macros to include both goto and call forms, and both positive checks and negative checks for trainers/flags
* Updated flash constants
* Fixed flash constant locations
I originally supplied anchor references, not locations of the constants themselves. That's been fixed. Also, I changed the field name for flash.radius, so it's hopefully clearer.
* Selecting brock's script should select the _whole_ script
* Get correct number of code sections when scripts point to freespace
* Make sure script concatenation works correctly for `goto` followed by `end` (vanilla games do this a lot)
* multiple if statements / gotos all get compiled into one script, so long as it's all contiginous script data
* make sure `trainerbattle 01` works correctly with labels
* include blank line separators between labels when decompiling scripts
if the last thing is a label, make sure to include an end command for it
if the last thing isn't an end command (or goto, etc) make sure to include an end command for it
* add a basic limiter so that parsing scripts will 'give up' if they get the same 0-arg command 20 times
* fix crash that could happen sometimes when trying to check a pointer for sources during script decoding
* don't try to decode streams as scripts (misuse of the destinations collection)
Since scripts don't always end at an `end` or `goto` anymore (if there's a label from within the script to directly after the script), we need to make sure that these appended scripts still get a chance to add more scripts into the UI.
* add anchor for misc animations
* flags should be seen as hex in the script editor
* various table updates
* update text in empty block selection case
* creating a new map should be considered an autonomous operation for undo purposes
* support connection-objects for FireRed
* crash less when reading invalid map / layout data
* show correct hover square when hovering over neighbor maps with borders
* fix elevation names / map permissions
* don't update tile render info for the block editor if the x/y change is a no-op
*
* say width/height correctly in the tooltips of the map size handles
* less flickering during undo
* include default OW sprite instead of blank (for example, tutorial catch man in viridian city)
* speed up the initial script-check process that looks for default trainer sprites for each OW by not caring about the length of child scripts
* use proper thread locking during block cache invalidation and renewal so that undo doesn't mess up the number of blocks shown in the block panel
* when docompiling, don't include a box that contains a partial script that's already in the main box
* when compiling, require arg counting for getting macro length
add enum types for fanfare / bufferitem
allow script constants to contain underscores
allow autocomplete for constants that are the last argument
allow 'find usages -> scripts' to find usages from macros (and fix crash)
instead of the script line itself knowing that it points to something,
pull it down to the argument level, so that each argument knows
if it points to something.
This will allow a single script line to point to multiple things (like trainers pointing to multiple text or scripts)