Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script/Text Pointer Macros for Map Scripts #367

Merged
merged 16 commits into from
Jul 14, 2023

Conversation

vulcandth
Copy link
Contributor

@vulcandth vulcandth commented Jun 24, 2022

Fixes #376

Was looking through through some of the comments for #270 and noticed that there was a lack of constants for script/text pointers. So I came up with some macros to define a constant and pointer at the same time. This would also allow giving more appropriate names to the text labels.

Todos at the end:

Consider changes SilphCoWorker text to something like: SilphCo7FWorkerM1BeforeText and SilphCo7FWorkerM1AfterText

@dannye
Copy link
Member

dannye commented Jun 24, 2022

I like the look of this.

@vulcandth

This comment was marked as resolved.

@Rangi42
Copy link
Member

Rangi42 commented Jun 27, 2022

Assuming we come up with meaningful constant names, this looks good.

I'm not sure if the constant should be first or the pointer label. It's an issue that was also brought up in pret/pokecrystal#748 and pret/pokecrystal#755.

@vulcandth

This comment was marked as resolved.

@dannye
Copy link
Member

dannye commented Jun 30, 2022

So I've been slowly working through this PR in my spare time... and I'm starting to worry that it could become rather difficult to review in a single PR.

We're used to reading large diffs when it's worth it :p

Here are the main changes I have planned:

  1. Rename map _ScriptPointers => _SceneScriptPointers (These scripts functions as scenes)

  2. Rename map _TextPointers => _TextScriptPointers (These aren't always just text, and sometimes contain their own scripts.)

I don't think this is a good idea.
Scripts can execute code and/or print text.
Texts can print text and/or execute code.
The important difference between them is their default mode; code or text processing.
Putting "Script" in each name makes it harder to distinguish while reading.
"Scene" also doesn't seem like an appropriate descriptor for all script routines.

Your 3) and 4) sound good to me, aside from simplifying proposed macro names (ie, def_scene_script_pointers -> def_script_pointers).

Would you find it easier to review if this was broken up into several PRs?

Just one PR is good 👍

scripts/AgathasRoom.asm Outdated Show resolved Hide resolved
scripts/ChampionsRoom.asm Outdated Show resolved Hide resolved
scripts/ChampionsRoom.asm Outdated Show resolved Hide resolved
@vulcandth vulcandth force-pushed the map-script-macros branch 2 times, most recently from bc21eea to 3f0da33 Compare July 4, 2022 01:39
scripts/AgathasRoom.asm Outdated Show resolved Hide resolved
scripts/AgathasRoom.asm Outdated Show resolved Hide resolved
scripts/BillsHouse.asm Outdated Show resolved Hide resolved
scripts/BillsHouse.asm Outdated Show resolved Hide resolved
scripts/BillsHouse.asm Outdated Show resolved Hide resolved
scripts/BillsHouse.asm Outdated Show resolved Hide resolved
text/BillsHouse.asm Outdated Show resolved Hide resolved
scripts/BluesHouse.asm Outdated Show resolved Hide resolved
scripts/CeladonCity.asm Outdated Show resolved Hide resolved
scripts/CeladonDiner.asm Outdated Show resolved Hide resolved
@vulcandth vulcandth force-pushed the map-script-macros branch 2 times, most recently from 9a22a70 to 55c6221 Compare July 7, 2022 02:08
Copy link
Member

@dannye dannye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome progress!

data/maps/objects/CeladonMart2F.asm Outdated Show resolved Hide resolved
scripts/BillsHouse.asm Show resolved Hide resolved
scripts/CeladonMart3F.asm Show resolved Hide resolved
scripts/CeruleanBadgeHouse.asm Outdated Show resolved Hide resolved
@kqesar
Copy link
Contributor

kqesar commented Jun 12, 2023

Hello,

I don't know if it's the right place to ask this but could we merge this PR ?

Merge this PR give the possibility to update our forks and continue to contribute to de-obsucate the code with the new macro of @vulcandth

Actually with the big update of this PR, contribute to help to de-obscucate it is not a good idea :/

Thank you in advance

PS: If my request is not in the right place i will remove my comment

Regards

@vulcandth
Copy link
Contributor Author

For all the Silph workers whose text just varies depending on whether you saved Silph, I don't think they need dialog-specific labels; just things like SilphCo7FWorkerM1BeforeText and SilphCo7FWorkerM1AfterText would do. Likewise for other NPCs who just switch between two texts based on an event.

I don't have a strong argument against this other than... I don't think it really matters all that much.. and i've already done the work by giving them dialog-specific labels and it be a minor pain to go back and fix them. If you think its best I will of course go back and fix it lol... but I can't say i'm not slightly reluctant lol.

scripts/SafariZoneGate.asm Outdated Show resolved Hide resolved
text/SafariZoneWest.asm Outdated Show resolved Hide resolved
text/SafariZoneEastRestHouse.asm Outdated Show resolved Hide resolved
data/maps/objects/SafariZoneEastRestHouse.asm Outdated Show resolved Hide resolved
data/maps/objects/SafariZoneEastRestHouse.asm Outdated Show resolved Hide resolved
scripts/SafariZoneEastRestHouse.asm Outdated Show resolved Hide resolved
scripts/SafariZoneEastRestHouse.asm Outdated Show resolved Hide resolved
scripts/Route23.asm Outdated Show resolved Hide resolved
Copy link
Member

@dannye dannye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, that's all I can spot. I'll do another pass checking for hSpriteIndex/hSpriteIndexOrTextID and w*CurScript to see if there are any more spots we should be using the new constants.

scripts/ChampionsRoom.asm Outdated Show resolved Hide resolved
scripts/GameCorner.asm Outdated Show resolved Hide resolved
scripts/GameCorner.asm Outdated Show resolved Hide resolved
scripts/HallOfFame.asm Outdated Show resolved Hide resolved
scripts/HallOfFame.asm Outdated Show resolved Hide resolved
scripts/Route5Gate.asm Outdated Show resolved Hide resolved
scripts/Route7Gate.asm Outdated Show resolved Hide resolved
scripts/SilphCo11F.asm Outdated Show resolved Hide resolved
scripts/SilphCo7F.asm Outdated Show resolved Hide resolved
scripts/SilphCo7F.asm Outdated Show resolved Hide resolved
@vulcandth
Copy link
Contributor Author

Alright, that's all I can spot. I'll do another pass checking for hSpriteIndex/hSpriteIndexOrTextID and w*CurScript to see if there are any more spots we should be using the new constants.

I did a pretty thorough review for this after I finished using several regex's to help identify potential ones I might have missed; but feel free!

Copy link
Member

@dannye dannye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final round from me :)

scripts/IndigoPlateau.asm Show resolved Hide resolved
scripts/SafariZoneCenter.asm Outdated Show resolved Hide resolved
scripts/SeafoamIslandsB3F.asm Show resolved Hide resolved
scripts/SeafoamIslandsB4F.asm Outdated Show resolved Hide resolved
scripts/WardensHouse.asm Outdated Show resolved Hide resolved
@vulcandth vulcandth requested a review from dannye June 24, 2023 00:35
Copy link
Member

@dannye dannye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ready to merge to me! @Rangi42 anything else you want to check for?

@Rangi42
Copy link
Member

Rangi42 commented Jun 29, 2023

I mainly want to review the Seafoam Islands and Silph Co names. (At least some are still unidentified, e.g. SeafoamIslands5Script_467a5.)

@Rangi42
Copy link
Member

Rangi42 commented Jul 14, 2023

Amazing work, @vulcandth ! 🥳

@Rangi42 Rangi42 merged commit d001ced into pret:master Jul 14, 2023
1 check passed
github-actions bot pushed a commit that referenced this pull request Jul 14, 2023
This introduces `def_script_pointers`, `def_text_pointers`, and `object_const_def` macros, and applies them to all maps. Most other map labels have also been identified.
@vulcandth vulcandth deleted the map-script-macros branch July 14, 2023 01:34

PewterGymTrainerHeaders:
def_trainers 2
PewterGymTrainerHeader0:
trainer EVENT_BEAT_PEWTER_GYM_TRAINER_0, 5, PewterGymBattleText1, PewterGymEndBattleText1, PewterGymAfterBattleText1
trainer EVENT_BEAT_PEWTER_GYM_TRAINER_0, 5, PewterGymCooltrainerMBattleText, PewterGymCooltrainerMEndBattleText, PewterGymCooltrainerMAfterBattleText
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this guy a Jr Trainer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this guy a Jr Trainer?

It's based on the sprite. He uses the CooltrainerM sprite.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Given that we have things like FIGHTINGDOJO_HITMONLEE_POKE_BALL, I'd expect trainers' labels and constants to match their real class. That's already the case for specific characters, e.g. OPP_ERIKA has TEXT_CELADONGYM_ERIKA, despite using SPRITE_SILPH_WORKER_F.

Copy link
Member

@Rangi42 Rangi42 Jul 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All such cases: https://pastebin.com/vb93gijw (There's just one case not in there which already goes this way: in PokemonMansionB1F.asm, an OPP_BURGLAR has TEXT_POKEMONMANSIONB1F_BURGLAR, despite using SPRITE_SUPER_NERD. All the rest are like TEXT_POKEMONMANSION2F_SUPER_NERD, TEXT_CINNABARGYM_SUPER_NERD2, etc.) I've updated #420 with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically detect invalid object_event or bg_event text IDs
5 participants