-
Notifications
You must be signed in to change notification settings - Fork 818
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
Sectionful refactor #631
Sectionful refactor #631
Conversation
How the section splitting was doneFirst of all, I'm establishing a definition for what a "section" is: A section is a self-contained blob of code or data that can move around the ROM banks without anything breaking. Given the current state of the disassembly, I believed this problem could be solved in a semi-objective manner by writing some tools to analyze the code. So, I wrote a couple of tools to do the following:
Doing this gave me actually surprisingly decent results, but it requires working out of false-positives and other quirks. As such, every single one of these steps has an additional step to fix them. I won't go too much into detail about this here but you can read my The biggest flaw of this system is its inability to identify unrelated sections that are right between two other sections in the same ROM bank that relate to eachother. This caused some rather huge chunks of several banks to be a single section in the initial pass I did of this. I've done my best to manually work away the biggest examples of this, but it's by no means perfect, and as such, some currently unidentified areas of the code might need to be split further, later down the line. |
Current assembler-related quirksTo make sure some sections are in the same bank as others (due to non-BANK()ed references), I use the BANK[] attribute with a static bank. This could be done better if |
UncertainitiesTo be able to get out more sections, I've split Some files contain a bunch of tangentially related functions, these include most prominently I've tried splitting map scripts and songs on a per-unit basis, since each map and song has a separate file, anyway. However, there's a small problem with maps and songs referencing eachother. This happens in for example the rival theme, or the different ruins of alph chambers. Thankfully, all of the instances where this happens are right after eachother in the ROM, so there's no need to deal with splitting into separate sections. Now, there's multiple ways to deal with this:
I'm leaning towards the second option but this might mess with map editors that rely on everything being |
For maps or songs that reference each other, I'd recommend option 3, "Keep both as separate .asm files and sections but make sure both sections are in the same bank." Since making sure that multiple sections share a bank is something that needs doing elsewhere anyway (currently with |
While I agree this is the case with maps, it's actually rather obvious which one is the "parent" track with music. But I like consistency, so doing the same for maps as for audio tracks is probably the best idea. |
The case for select_menu.asm
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mon_menu.asm wasn't originally in data/pokemon/ because everything in data/pokemon/ is related to the individual Pokémon indexes. Otherwise party_menu_qualities.asm and growth_rates.asm would also be there.
Reverted. |
Alright, so for the section names, I'm currently doing the following:
Big exception: anything in |
This splits all of the sections into completely self-contained parts.
This section was bound together by a single reference from TiffanyFamilyMembers to the end of the bank. Probably caused by the translators.
It isn't related to the player object at all.
Want to ask people what the best course of action for these would be.
This will make the `.o` file splitting easier later down the line. Some more splitting is required to finish making main.asm INCLUDE-only, however.
Moved the core part of anim_commands out to core, and included the entire battle anim engine there.
Add documentation for the usage of the new makefile, as I'm sure it'll confuse some people.
- Copy the files when running `make` without arguments - Clean topdir files when running `make tidy` - Remove `-march=native` as this doesn't work with `clang`
They're arbitrary names, and the .asm part is redundant
BANK_CRYSTALBank $12 is a bit entangled, having been used mostly for crystal-related things. There's 5 files with a bunch of references across eachother:
I've merged the first two, and the last two, and made 3 separate sections of these, to "liberate" the couple of files in-between. These files should be looked at in the future, especially |
Apparently there's a very sneaky non-banked reference between these, that will cause the game to crash if these are not in the same bank.
Unneccessarily "generic" file, also didn't make sense now pokedex_2 is gone.
These strings are right at the end of generic_callee, but for convenience I'll move them out to a separate file, for now at least.
Issue: a depfile won't be updated if an included file updates. So if an .asm file |
Is this PR still active? |
Yes, I intend on merging parts of this PR upstream first, however, since that'll allow separate review of those changes. |
Closing for the time being, as mentioned in a previous comment, this should be split up. |
Right now, the current disassembly splits sections arbitrarily. This means that
we have an odd combination of a linker script and
INCLUDE
s in several filesto sort everything in the ROM. Some sections even cause the game to break when
they're moved around to different banks, such as
bank10
(which containsengine/pokemon/evolve.asm
) andEvolutions and Attacks
.To make it easier for a regular user to move things around to different banks
without headaches, I decided this should be fixed.
To achieve this, I plan to do the following:
.inc
and have the Makefile scan for.asm
files.This Pull Request is mostly to show progress, explain what I'm doing, and
discuss several decisions relating to this endeavour.
Current state
Everything I wanted to do has been done. I'll be reviewing some of the changes made, and so should you.