Virtual Console for Modern Pokecrystal#882
Virtual Console for Modern Pokecrystal#882Rangi42 merged 186 commits intopret:masterfrom vulcandth:Vulcan-Virtual-Console
Conversation
Changes from mid-kid's original Pull Request: Ported code to modern pokecrystal Converted to MACRO vc_hooks throughout code Created macros/vc.asm for storing VC macros Added some useful troubleshooting output to make_patch.c verify_completeness function Configured make_patch.c verify_completeness to ignore stadium checksums Updated .gitattributes to ensure pokecrystalvc.patch.template is CRLF [Virtual Console will ignore patch file if it is not CRLF] Added vc/ directory to .gitignore as this is currently used to clone mid-kid's build cia repo into. Added BiographySave_ret assert to notify user of address change. [This hook is hardcoded in the virtual console] Added hJoyPressed MACRO assert in macros/vc.asm and hram.asm to notify user if hJoyPressed address has changed. [It shouldn't...]
|
Quite a bit to untangle here, from a quick look:
There's more, but this is just the few things I can think of so quickly. I'll look more in depth tonight. |
|
I appreciate the feedback a lot; I figured this still had a lot of work.. and you made a lot of good points to make me stop being lazy. I'll get to working on fixing the issues you addressed. As far as your first two bullets; I don't know why I didn't differentiate between the hooks and patches in the macros... Easy enough. As far as I'll admit my programming skills are still somewhat beginner; and I only started learning Assembly, RGBASM, and pokemon rom hacking like two-ish weeks ago lol. However, I like projects like this as it forces me to learn. I'll have some fixed commits soonish for further review. |
mid-kid
left a comment
There was a problem hiding this comment.
Don't sweat it, I'm happy someone's already gone through making sure it's compatible with modern pokecrystal and has already done part of the work necessary to get it upstream!
Unfortunately, it takes a bit more than you'd initially expect to get a feature like this merged, in a way that's ready for others to use and improve, without hitting stone walls/annoyances when editing the ROM like normal. This can take a bit of back and forth until we can settle on something agreeable at times, though I don't think this feature will need a lot of that.
That said, at any point you're free to just leave the PR as is, and leave it to someone else to finish. We'll keep it open as long as the issue with the feature request exists, so don't see it as an obligation.
|
Is this an actual console? Can I see some screenshots? |
* Readded Newlines that were inadvertently removed. * Fixed alignment removing <tab>s and adding <space> as appropriate. * Fixed the Dependencies for shared objects section to add pokecrystalvc on its own lline.
* Mention MOBILE_EVENT_OBJECT_GS_BALL instead of $b. * Moved a comment to its original location in modern pokecrystal * Re-added a missing spacing.
This is to enable support for building a patch file to be used when importing roms into Nintendo's Virtual Console to be used on Nintendo 3DS/2DS' systems. The Nintendo Virtual Console uses these patch files to know when to initiate functions for Link Trade/Battle by watching for code execution in the rom; as well as what locations it should patch. (There is a lot more to it.. and poorly explained... but should give you an idea.) |
* Removed hJoyPressed assert * Added vc_assert Macro * Corrected Bibliography assert to reference sMobileEventIndex and sMobileEventIndexBackup instead.
*Readded farcall PlaceWaitingText *Moved vc_hook send_byt2 above farcall * Adjusted patch.template to offset address by 5.
|
I'd say this suffers from the same problem as a few years ago. Namely, we don't really understand the format. The repo builds a fully-modifiable ROM; we understand everything* in it and we can successfully build modified versions at our leisure. This means that changes are not restricted at all by the existing codebase; it's entirely possible to replace complete subsystems, as many of us have done, and there are no constraints on what the replacements can do. On the other hand, the VC patch isn't fully understood. There are some good guesses at what some declarations do, but the format hasn't been fully reversed; it is not currently in a state where we can write our own patch files from scratch. Therefore, the presence of a patch file at all constrains the capabilities of the codebase, since complete subsystem replacements that require writing a new patch file become impossible as long as that kind of compatibility is desired. Therefore, a patch file effectively holds back (in part) the ability to modify the codebase while keeping existing components functional: a modified project that intends to replace a component that interacts with the patch file will have to keep parts of said component intact (or at least similar) for the patch file to work, without being fully aware of how this interaction works. Due to this difference in quality, and until the patch file format is fully reversed to the point where it is fully understood and it can be rewritten from scratch, I'd recommend keeping the VC components in a separate repository, perhaps linked from the README here, so that a partially-reversed component doesn't hold back modifications of a fully-reversed and almost-fully-documented codebase. |
|
I'd also point out that adding about a thousand lines of code to the main codebase (i.e., not patch-specific code, but the main code of the game) just for VC compatibility isn't a great idea, and I'd much rather avoid it. |
|
@mid-kid I Implemented a vc_patch macro in 89b82f0 and 612858d however I don't believe it is possible to split a conditional IF statement between multiple macros.. So I don't believe the vc_patch_else and vc_path_end will work. @aaaaaa123456789 I appreciate your input (No sarcasm), i'm only responding to an issue that has been open #813. In order not to clutter up the Pull Request with a discussion, may I suggest that it might be better to have this discussion there.. and in the meantime i'll continue working on the PR here. |
Or something to this effect. I forget how string interpolation works in recent versions of rgbds. Though I'd like to ask @Rangi42 for input before doing this. I'm a bit iffy on expressing normal conditionals with macros as well, though we do need start and end markers for a patch. |
|
Those I'm fine with patches being surrounded by standard |
|
How about this: Then |
|
@Rangi42 what about my idea to use the value passed to vc_patch within vc_patch_end? That would reduce repetition and potential problems with mismatched names. |
Yeah, that sounds good: |
Co-authored-by: Rangi <35663410+Rangi42@users.noreply.github.com>
This comment incorrectly references the old .loop2. It should now reference the unpatched .restart Co-authored-by: Rangi <35663410+Rangi42@users.noreply.github.com>
|
Give it another two weeks and @Rangi42 will have it down under 250 lines of code. |
Not quite, but @mid-kid I did take your suggestion to remove the single-line braces, bringing it to 399 lines. (Without any comments or blank lines it would still be 330.) |
|
To do:
|
|
I don't believe that the remaining ConditionValueC's should be a blocker from merge. I will continue to research better ways to abstract the remaining items; Fortunately the ONLY thing these Print Forbids actually do is block the player from pressing any button other than D_DOWN, D_UP, B_BUTTON, or simply providing NO_INPUT when the player is attempting to do a print function. They did a really lazy implementation at this, and its easy to circumvent. If these sections are removed it doesn't cause the game to crash.. the game just tells the user that the GameBoy Printer is unavailable. They are rather pointless. However, for the sake of perfectly replicating the original patch files, they are here. The Wiki should recommend that homebrew users should REMOVE these sections and perhaps provide manual in-game code changes if they want to. I fully support continuing to find ways to better abstract the values, and making them more dynamic... but this will take some time. What I know of the remaining values:
|
|
wMenuMetadata is the name of a structure (running from wMenuMetadata to wMenuMetadataEnd) of which wWindowStackPointer is the first element. This stack pointer points to a location between wWindowStack and wWindowStackBottom where the tiles that are obscured by the currently open menu are saved (because menus can stack on top of eachother, this is implemented as a stack). Of course this means it depends on how big the menus are that are loaded before this menu, the hard part about this is that it's in no way an identification of the menu, the developers just chose to rely on this. wMenuSelection stands separate from wMenuCursorY in the sense that it's not an Y coordinate relative to the top left corner of the menu box. wMenuSelection will usually be equal to Ideally all of this would somehow be programatically calculated, by for example having constants for the menu entries in the menus that need them (maybe even a constant to determine the NPC's position), but I agree doing so is a pain, would involve a bunch of hacks, and I'd rather push the PR through asap, so I'm fine with just documenting this, too. Maybe with @Rangi42 Thoughts on where to put these comments? |
I think constants for the NPC position would be overkill; it's obvious from the If constants are needed specifically for the VC, we might be able to put them in custom If I didn't know why my VC menu was failing, the menu code is the first place I'd look, so IMO that's where a comment should be. |
Even if you know that it works on a regular emulator? |
|
IMO; we should just packaged this information into the Wiki. Perhaps have make_patch print out a message after successful execution to refer to the Wiki page for troubleshooting or use in romhacks. Or you could have MakeFile run a SHA check on the original rom to check for modifications.. If modified. If the user is building a patch using I'm just trying to think outside the box. Should you decide to just go with the comment method; i'd be fine with that too. |
|
You might be right - documenting this in the "hard-coded logic" page might make more sense. This can be fixed over time so I'm fine with just not doing anything right now, I guess. |
|
This PR has gotten rather... LONG.... my recommendation. Lets finish the doc modfications @mid-kid wanted and merge this PR... and the create new github issues for the rest of the tasks (ex: Identify remaining CondValueC, Customizable labels, ect.). I can then open up new PR's in regards to those issues when we have enough info on how we want to address them. |
|
Sounds good. |
This pull request is in response to issue #813. It is based off of mid-kids' virtual-console branch https://github.com/mid-kid/pokecrystal/tree/virtual-console and has been updated to modern pokecrystal with a few changes as noted below.
Changes from mid-kid's original Pull Request #484:
I'm looking for feedback on what needs to still be worked on, in order to merge this. Again, as mid-kid originally stated when he attempted to merge this in 2018... It is far from perfect; but I believe it is pretty close to mergeable. If any issues arise, it will be on the virtual-console build; and users attempting to build normal pokecrystal should be unaffected. If we can get merged, then it will provide a base to continue improving.