Skip to content
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

Document Sprite Resource / Util (Cell Actor Part 3) #244

Merged
merged 17 commits into from
Jul 11, 2024

Conversation

Fexty12573
Copy link
Contributor

This is yet another resource "manager". This time specifically for sprite resources. A SpriteResource can hold any of

  • Character Data (NCGR) -> Tiles
  • Palette Data (NCLR) -> Palettes
  • Cell Data (NCER) -> Sprites
  • Cell Anim Data (NANR) -> Sprite Anims
  • Multi Cell Data (NMCR) -> Multi Sprites
  • Multi Cell Anim Data (NMAR) -> Multi Sprite Anims

It contains the raw file data and the unpacked data, obtained using the NNS_G2dGetUnpacked* functions, as well as some additional info in case of palettes and tiles.

Resources can (as usual...) be added to a collection: SpriteResourceCollection. A sprite resource collection can only hold resources of one type. I.e. only sprites or only palettes, etc. It provides methods for loading resources from NARCs

Another type in this is SpriteResourceTable, which is similar to a collection but it's a table deserialized directly from a file or a NARC. It, by itself, then contains further references to either other files or NARCs which contain the actual resources. All entries from such a table can be added directly to a sprite resource collection as well, via SpriteResourceCollection_AddTable[Ex].

I now realized that this is most likely gonna be a 6 part PR, instead of 4. This file is mostly utility functions used by a more abstract system. However, there are two more files with utility functions like that. One is for handling VRAM transfers and the other I'm not sure yet.

I am also now debating going back to the cell actor PR and adjusting the terminology there (cell -> sprite) but I first need to see if there is a more concrete "Sprite" type elsewhere.

@lhearachel
Copy link
Collaborator

Now that #176 has been merged, make sure to clean up your merge conflicts and run your code through the formatting utility.

Comment on lines +50 to +51
SpriteResourceTableEntryFile fileEntries[1];
SpriteResourceTableEntryNARC narcEntries[1];
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: Is the subscript necessary to match?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, but in my opinion it makes the code that actually uses these fields nicer. Could probably do [0] as well, provided mwcc supports that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
SpriteResourceTableEntryFile fileEntries[1];
SpriteResourceTableEntryNARC narcEntries[1];
SpriteResourceTableEntryFile *fileEntries;
SpriteResourceTableEntryNARC *narcEntries;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's not the same code tho. It's an inline array, not a pointer to an array.

src/sprite_resource.c Outdated Show resolved Hide resolved
src/sprite_resource.c Outdated Show resolved Hide resolved
src/sprite_resource.c Outdated Show resolved Hide resolved
src/sprite_resource.c Outdated Show resolved Hide resolved
@lhearachel lhearachel merged commit f13e75a into pret:main Jul 11, 2024
2 checks 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