Skip to content

Unpack item_icon.narc and refactor pl_item_data #508

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

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

memory5ty7
Copy link

New Enum to document the items icons and palettes from item_icon.narc.
This will be useful later for file naming conventions of PNG and PAL files.

How I envision the new structure:
-An icons/palette order file that specifies the order of the files in the final NARC
-This enum generated automatically from the icons/palettes order file
-Every palette or icon named according to the enum eg. "plate.png" or "flame_plate.pal"
-Every item has its own json file (properties from pl_item_data.csv AND content of sItemArchiveIDs in item.c)

Every NCGR / NCLR is then built in the correct order according to the icons/palettes order file and the item data array is built using the items.txt order (There are some unused items that appear in only one of the two arrays)

Copy link
Collaborator

@lhearachel lhearachel left a comment

Choose a reason for hiding this comment

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

How I envision the new structure:

  • An icons/palette order file that specifies the order of the files in the final NARC
  • This enum generated automatically from the icons/palettes order file
  • Every palette or icon named according to the enum eg. "plate.png" or "flame_plate.pal"
  • Every item has its own json file (properties from pl_item_data.csv AND content of sItemArchiveIDs in item.c)

Is there any reason not to go ahead and implement this structure along with decompiling the graphics files themselves? The enum is a bit superfluous, in that regard, as we will just replace it with the generated constants built when packing the NARC.

There is a good bit of implicit feedback here in that these generated constants are currently bound to the names of the output files emitted by nitrogfx. Ideally, those would be decoupled... or we could at least output an arbitrary filename and tell nitrogfx what conversion routine to use as an override.

@memory5ty7
Copy link
Author

Alright, I've updated the structure. We now have two json files (one for the cell, one for the anim), png files and pal files.
This generates a naix header which is used in item.c.
I read on the guidelines that enum values should be uppercased, however I couldn't find a way to make it work and I find it impractical to have filenames in lowercase and then the enum in uppercase

@memory5ty7 memory5ty7 changed the title Items Icons and Palettes Enum Unpack item_icon.narc Jun 16, 2025
Copy link
Collaborator

@lhearachel lhearachel 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 unpacking this, this is a huge bounty! ❤️

I read on the guidelines that enum values should be uppercased, however I couldn't find a way to make it work and I find it impractical to have filenames in lowercase and then the enum in uppercase

Yes, unfortunately, this is the case; the generated naix bases the names for packed member-files from the source file's name. Some file systems are case-sensitive, while some are not, so we cannot 100% ensure that two indices would not collide in all cases.

I may revisit that assumption, though, if we can make the semantics of the error clearer than a compilation error about a re-defined preprocessor symbol. 😅

Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion:

  1. Can we apply palettes to these icons so that they are easily moddable in a graphics editor that supports indexed PNGs? You can apply the palette using the -palette option when converting NCGR to png and providing a NCLR file as an argument for the option. This will probably require a custom packing-script, but that's okay with me, if the scope of work doesn't feel too bad.
  2. I think it would be valuable to reorganize the folders a bit... I had started working on this in the past, and my aim was to structure items similarly to pokemon, where a unique folder exists for each item and contains a (potentially empty) data file and its icon.

Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: icon_bag_cancel.png (or whatever the menu option is called in vanilla)

@memory5ty7 memory5ty7 changed the title Unpack item_icon.narc Unpack item_icon.narc and refactor pl_item_data Jun 18, 2025
@memory5ty7
Copy link
Author

I've restructured the icons to be similar to pokemon : there is now a folder for every item with a data.json file obtained from pl_item_data.csv (this file is not used for the moment), and an icon.png for items that use their respective palette and icon. For the other icons, their icons and palettes stay in the root folder

@memory5ty7
Copy link
Author

Things left to do are :
-actually using every item's data.json to build the narc
-potentially adding nuts_data.csv's informations to the berries' data.json

@lhearachel lhearachel self-assigned this Jun 19, 2025
@memory5ty7 memory5ty7 marked this pull request as draft June 29, 2025 16:43
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.

2 participants