Skip to content

Allow custom charmaps #34

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

Merged
merged 21 commits into from
Apr 18, 2025
Merged

Allow custom charmaps #34

merged 21 commits into from
Apr 18, 2025

Conversation

BlueAnthem37510
Copy link
Contributor

Allows user to set custom character map(s) using the RGBDS character mapping

Should hopefully satisfy issue #33 also? :)

To use this a path to the file containing the character map(s) is added to the command. This file will be copied to the disassembly and included in game.asm

To mark which text should use the custom character map ":cm" is added to the end of the text label otherwise it will use the default to handle text. Additionally ",[index]" may be used after this to specify which character map should be used if there are multiple.

Please see below for example using Dragon Warrior Monsters.

Command line
image

Symbols
image

Character map file
image

Disassembly
image

game.asm
image

Copy link
Collaborator

@ISSOtm ISSOtm left a comment

Choose a reason for hiding this comment

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

Hello! Thank you for the PR. I really like the idea!

However, before reviewing the code itself, I would like to iterate on the design (mostly the syntax) a little.

Noteworthy also is that RGBDS v0.9.0 has added multi-value charmaps (CHARMAP "<br>", 13, 10), which may be a little more complicated to handle, since you'd start needing leftmost-longest semantics. (As mentioned above, I haven't looked at the implementation, so I don't know if you have implemented such support.)

@BlueAnthem37510
Copy link
Contributor Author

Hi @ISSOtm thank you for checking my pr and the suggestions!

I had been waiting for multi character support to be added forever I can't believe I missed that! Makes the text look so much cleaner.
image
image

Regarding the syntax I've compromised a little (or perhaps overdoing it?) by allowing "cm" or "charmap" and indexing or the character map name
image

I added some warnings also if the user makes a typo or an out of range index, I'm happy for this to be handled a different way though.
image

Let me know what you think!

Copy link
Collaborator

@ISSOtm ISSOtm left a comment

Choose a reason for hiding this comment

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

Thank you for this patch, and my apologies for taking a while to respond.

It's a lot of code, so I've only reviewed a bit of it. Feel free to make more similar changes if you think they'll be appropriate, too!

@BlueAnthem37510
Copy link
Contributor Author

No worries! I've moved the getting "character map index" into a function and implemented your changes. Hopefully should be more readable now!

@BlueAnthem37510 BlueAnthem37510 requested a review from ISSOtm March 7, 2025 17:11
@mattcurrie
Copy link
Owner

@BlueAnthem37510, hey thanks for putting this PR together!

I've just added a test in the master branch which builds a test ROM and then disassembles it and checks the result against some expected disassembly and the original ROM.

The test tries a few different things using character maps, so if you could try merging master into your branch and then hopefully it should just be a case of running make in the /test directory and then updating the files in /test/expected from /test/disassembly to get the test to pass after your changes.

Copy link
Owner

@mattcurrie mattcurrie left a comment

Choose a reason for hiding this comment

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

Thanks for those changes! I just found a few minor things that could be tweaked when I tried with my test character map.

Copy link
Collaborator

@ISSOtm ISSOtm left a comment

Choose a reason for hiding this comment

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

Thank you for seeing this through!
I do have a couple of QA changes to request.

BlueAnthem37510 and others added 5 commits March 22, 2025 12:04
Co-authored-by: Eldred Habert <[email protected]>
Co-authored-by: Eldred Habert <[email protected]>
Co-authored-by: Eldred Habert <[email protected]>
Co-authored-by: Eldred Habert <[email protected]>
Copy link
Collaborator

@ISSOtm ISSOtm left a comment

Choose a reason for hiding this comment

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

Looks good to me!

I'll admit I skimmed the code that actually does the character (reverse) mapping, but I'll assume that you tested it.

Note that there can be issues with some charmaps, for example:

charmap "a", 0
charmap "b", 1
charmap "ab", 2

...and reversing the bytes 00 01 would produce db "ab", which would not-round-trip to 02.

The fix is to split the string (db "a","b"). I would totally understand if you choose not to handle this specific edge case, but I think it would be a good idea to mention it in the manual, so it wouldn't catch other people off-guard. (Possibly inside of a <details> element, to keep it skimmable?)

@mattcurrie
Copy link
Owner

@ISSOtm, I've just tried that edge case and it seems to be working. I'll merge and update the test to use the charmap.

@BlueAnthem37510 thanks again for your work on this. Great to have this functionality!

@mattcurrie mattcurrie merged commit a39aed7 into mattcurrie:master Apr 18, 2025
1 check passed
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.

3 participants