2023-05-04 20:44:11 +00:00
|
|
|
// Fixed-size memory block for entities of a custom type, specific to a stage
|
|
|
|
// or boss portion. To define such a custom type, declare your own structure,
|
|
|
|
// then reinterpret_cast [custom_entities] to that type.
|
[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
|
|
|
|
2024-05-25 18:31:09 +00:00
|
|
|
#include "th04/main/playfld.hpp"
|
|
|
|
|
2023-05-03 17:38:15 +00:00
|
|
|
#if (GAME == 5)
|
|
|
|
#define CUSTOM_COUNT 64
|
[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
|
|
|
|
2023-05-03 17:38:15 +00:00
|
|
|
struct custom_t {
|
|
|
|
uint8_t flag;
|
|
|
|
uint8_t angle;
|
|
|
|
PlayfieldMotion pos;
|
|
|
|
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
|
|
|
|
};
|
2023-05-04 20:44:11 +00:00
|
|
|
#else
|
|
|
|
#define CUSTOM_COUNT 32
|
|
|
|
|
|
|
|
struct custom_t {
|
|
|
|
uint8_t flag;
|
|
|
|
uint8_t angle;
|
|
|
|
point_t center;
|
|
|
|
int16_t val1;
|
|
|
|
Subpixel origin_y;
|
|
|
|
PlayfieldPoint velocity;
|
|
|
|
uint16_t val2;
|
|
|
|
int16_t distance;
|
|
|
|
int16_t val3;
|
|
|
|
int16_t hp;
|
|
|
|
int16_t damage_this_frame;
|
|
|
|
uint8_t val4;
|
|
|
|
uint8_t angle_speed;
|
|
|
|
};
|
2023-05-03 17:38:15 +00:00
|
|
|
#endif
|
[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
|
|
|
|
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
|
|
|
|
2022-06-09 15:03:49 +00:00
|
|
|
#define custom_assert_count(derived_type, derived_count) \
|
|
|
|
static_assert( \
|
|
|
|
(sizeof(derived_type) * derived_count) <= \
|
|
|
|
(sizeof(custom_t) * CUSTOM_COUNT) \
|
|
|
|
)
|