Add block shuffler detection and attempt to mimic vanilla behavior#252
Open
idlechild wants to merge 3 commits into
Open
Add block shuffler detection and attempt to mimic vanilla behavior#252idlechild wants to merge 3 commits into
idlechild wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If a certain PLM draw function is commanded to draw zero values, this is our clue that block shuffler is happening. I believe there are other, less powerful variants of block shuffler, but this one that clobbers the entire bank $7F (except the first two bytes) is the one we're interested in. When the draw function is told to copy zero values, it copies 65536 values (65536 words; it loops the whole 16-bit address space twice).
This creates a couple problems for the practice hack:
Now that we know where the block shuffler is happening, we can shield some of the practice hack stuff (similar to what we did for spacetime beam). If copying from $F000-$FFFD space, we know that should all be $FFFF, so we can write that value. With that area protected, we can move all of our Bank 84 freespace stuff in there (starting at $F002 just in case we try to copy a word from $EFFF; this is also why the space stops at $FFFE).
That still leaves us with some patches that we can't move, and also the WRAM that we can't un-repurpose. Thus after block shuffler runs, some cleanup occurs to write the vanilla values in where we may have copied non-vanilla values to bank $7F.