Particle file

From Boktai Hacking Wiki
Revision as of 19:03, 17 October 2024 by Raphi (talk | contribs) (Created page with "Particles are similar to sprite sets, but they are much simpler. They are used for Klorofolun, enemy sleeping indicators, etc. = Differences compared to sprite sets = * Sprites can be made up of multiple objects, particles always consist of one single object * Sprites reference the palette they require, particles do not * Sprites use [https://problemkaputt.de/gbatek-lcd-obj-vram-character-tile-mapping.htm 2D character mapping], particles use 1D char...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Particles are similar to sprite sets, but they are much simpler. They are used for Klorofolun, enemy sleeping indicators, etc.

Differences compared to sprite sets

  • Sprites can be made up of multiple objects, particles always consist of one single object
  • Sprites reference the palette they require, particles do not
  • Sprites use 2D character mapping, particles use 1D character mapping (for sprite objects, consecutive rows of tiles are always stored 16 tiles apart, whereas for particles consecutive rows follow immediately after the preceding row).

File format

A particles file contains multiple "groups". Particles with a similar "purpose" will be in the same group (for example, all Klorofolun particles are in the group 0xd28e in Boktai 1). However, the mapping is very loose and some groups contain wildly different types of particles. Every particle in the group has the same size, given by the shape field.

struct ParticleFile {
  /* offset 0x00 */ u32 unknown_0x00;
  /* offset 0x04 */ u16 tileCount;  // Number of elements in the tiles array
  /* offset 0x06 */ u16 groupCount; // Number of elements in the groups array

  // Byte offset from start of the file to the tiles array
  /* offset 0x08 */ u32 offsetToTiles;

  /* offset 0x0c */ ParticleGroup groups[groupCount];

  GBA_Tile tiles[];
};

struct ParticleGroup {
  /* offset 0x00 */ u16 id;
  /* offset 0x02 */ u8 unknown_0x02;

  // Same as the shape field in the [[Sprite set file]]
  /* offset 0x03 */ u8 shape;

  // Start index of this particle group in the tiles array,
  // number of tiles per particle is implied by the shape field.
  /* offset 0x04 */ u16 tile;

  /* offset 0x06 */ u16 unknown_0x06;
};