[Reverse-engineering] [th05] Custom entity structure
On the surface, TH05 uses one single 26-byte structure for
• the Stage 2 starfield,
• Alice's puppets,
• curve bullet heads,
• Mai's snowballs and Yuki's fireballs,
• Yumeko's knives,
• and Shinki's 32×32 bullets.
But looking closer, it turns out that the fields of all these have very
different semantics, and in some cases, even different types. uth05win
treated all of those as distinct structures, and we're going to do the
same, merely overlaying the pointers onto the same generic array.
Part of P0078, funded by iruleatgames and -Tom-.
2020-02-25 21:02:44 +00:00
|
|
|
// Memory for up to 64 entities of a single extra custom type, specific to a
|
|
|
|
// stage or boss portion, with sizeof(custom_t) bytes per entity.
|
|
|
|
// To define such a custom type, declare your own structure, then
|
|
|
|
// reinterpret_cast [custom_entities] to that type.
|
|
|
|
|
|
|
|
#define CUSTOM_COUNT 64
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint8_t flag;
|
|
|
|
uint8_t angle;
|
2021-06-30 14:30:06 +00:00
|
|
|
PlayfieldMotion pos;
|
[Reverse-engineering] [th05] Custom entity structure
On the surface, TH05 uses one single 26-byte structure for
• the Stage 2 starfield,
• Alice's puppets,
• curve bullet heads,
• Mai's snowballs and Yuki's fireballs,
• Yumeko's knives,
• and Shinki's 32×32 bullets.
But looking closer, it turns out that the fields of all these have very
different semantics, and in some cases, even different types. uth05win
treated all of those as distinct structures, and we're going to do the
same, merely overlaying the pointers onto the same generic array.
Part of P0078, funded by iruleatgames and -Tom-.
2020-02-25 21:02:44 +00:00
|
|
|
uint16_t val1;
|
|
|
|
uint16_t val2;
|
|
|
|
int16_t sprite;
|
|
|
|
int16_t val3;
|
|
|
|
int16_t damage;
|
|
|
|
SubpixelLength8 speed;
|
|
|
|
int8_t padding; // Unused across all custom entities in ZUN's code
|
|
|
|
} custom_t;
|
|
|
|
|
2022-02-20 14:48:41 +00:00
|
|
|
extern custom_t custom_entities[CUSTOM_COUNT];
|
[Reverse-engineering] [th05] Custom entity structure
On the surface, TH05 uses one single 26-byte structure for
• the Stage 2 starfield,
• Alice's puppets,
• curve bullet heads,
• Mai's snowballs and Yuki's fireballs,
• Yumeko's knives,
• and Shinki's 32×32 bullets.
But looking closer, it turns out that the fields of all these have very
different semantics, and in some cases, even different types. uth05win
treated all of those as distinct structures, and we're going to do the
same, merely overlaying the pointers onto the same generic array.
Part of P0078, funded by iruleatgames and -Tom-.
2020-02-25 21:02:44 +00:00
|
|
|
|
|
|
|
#define CUSTOM_VERIFY(derived_type, derived_count) \
|
|
|
|
((void)sizeof(char[1 - 2*!!( \
|
|
|
|
(sizeof(derived_type) * derived_count) \
|
|
|
|
> (sizeof(custom_t) * CUSTOM_COUNT) \
|
|
|
|
)]))
|