pret / pokeplatinum

Decompilation of Pokémon Platinum
164 stars 56 forks source link

Document Cell Actor (Collection) API (Cell Actor Part 2) #241

Closed Fexty12573 closed 1 month ago

Fexty12573 commented 1 month ago

Documents the low level CellActor API (cell_actor.h). I am unfortunately not able to give a super detailed breakdown of how to use it yet because this system is basically never used directly. It is wrapped by a more abstract sprite API. Once I document that I will provide documentation.

Also apologies for the size of this PR but a lot of the types/functions in this PR are used in a ton of files. The actual changes are basically exclusively in cell_actor.h/.c)

There's 2 core types in this:

CellActor

This is a pretty thin wrapper around the G2D API which supports

Both drawing and animation can be toggled on or off using the CellActor_Set*Flag functions. It provides functionality for overwriting data provided by the OAM using CellActor_SetExplicit* functions. There are also functions for performing affine transforms (translation, Z rotation, scale, See CellActor_SetAffine* functions). Scale is limited to x2 by the hardware.

It is important to note that these cell actors are hardware sprites. This is a relevant distinction because there is a concept of software sprites on the DS. Software sprites are basically just textures rendered onto quads using the 3D engine.

This API does not handle file loading/management. Cell Actors need to be initialized from already loaded cell banks and cell animation banks (See CellActorInitParams[Ex])

CellActorCollection

CellActors are essentially always part of a collection. You will most likely not see individual CellActors being used. This is also the reason why there is a CellActor_Delete function, but no CellActor_New. You use CellActorCollection_Add[Ex] instead. CellActorCollection has space for a fixed number of cell actors, dictated by its initialization parameters (CellActorCollectionParams). Internally it keeps track of the active actors using a doubly linked list (similar to SysTaskManager).

A cell actor collection can:

To remove an actor from a collection you use CellActor_Delete.

This is part 2 of a 4 part PR to document the sprite API. Full documentation on the system will be in part 4.

lhearachel commented 1 month ago

As a general pre-comment, try to avoid commit descriptions like "Label some stuff"; the goal of each commit should be self-contained and buildable code. If necessary, do some rebasing before filing a PR.