[Reverse-engineering] [th01] Items: Structure

Storing bomb and point items not just in separate arrays, but also
using separate *functions* for both?! At least it's only a single
structure for both.

Part of P0158, funded by Yanga.
This commit is contained in:
nmlgc 2021-09-14 17:00:22 +02:00
parent fc40bdaa09
commit b75ee8c208
2 changed files with 368 additions and 300 deletions

50
th01/main/stage/item.cpp Normal file
View File

@ -0,0 +1,50 @@
extern "C" {
#include "platform.h"
#include "pc98.h"
#include "planar.h"
#include "th01/formats/ptn.hpp"
}
/// Constants
/// ---------
static const pixel_t ITEM_W = PTN_W;
static const pixel_t ITEM_H = PTN_H;
/// ---------
/// Structures
/// ----------
enum item_flag_t {
IF_FREE = 0,
IF_SPLASH = 1,
IF_FALL = 2,
IF_BOUNCE = 3,
IF_COLLECTED = 99,
IF_COLLECTED_OVER_CAP = 100,
_item_flag_t_FORCE_INT16 = 0x7FFF
};
union item_flag_state_t {
unsigned char splash_radius; // During IF_SPLASH. In pixels.
unsigned char collect_time; // During ≥IF_COLLECTED.
};
struct item_t {
// Also overloaded for the text popup shown when the item is collected.
screen_x_t left;
screen_y_t top;
int16_t unknown_zero;
pixel_t velocity_y;
char flag; // item_flag_t
item_flag_state_t flag_state;
};
static const int ITEM_BOMB_COUNT = 4;
static const int ITEM_POINT_COUNT = 10;
extern item_t items_bomb[ITEM_BOMB_COUNT];
extern item_t items_point[ITEM_POINT_COUNT];
/// ----------

File diff suppressed because it is too large Load Diff