2020-09-05 14:09:18 +00:00
|
|
|
|
/// Uncompressed, monochrome / 16-color / 16-color + alpha, 32w×h sprite format
|
|
|
|
|
/// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// Number of planes per image.
|
|
|
|
|
typedef enum {
|
|
|
|
|
#if (GAME >= 4)
|
|
|
|
|
CDG_COLORS = 0, // 4 planes per image
|
|
|
|
|
CDG_COLORS_AND_ALPHA = 1, // 5 planes per image
|
|
|
|
|
CDG_ALPHA = 2, // 1 plane per image
|
|
|
|
|
#else
|
|
|
|
|
CDG_COLORS_AND_ALPHA = 0, // 5 planes per image
|
|
|
|
|
#endif
|
|
|
|
|
} cdg_plane_layout_t;
|
|
|
|
|
|
|
|
|
|
// Doubles as both the file format header (describing all images in a file)
|
|
|
|
|
// and the internal slot structure (describing a single image).
|
|
|
|
|
typedef struct {
|
|
|
|
|
// Size of a single bitplane.
|
|
|
|
|
uint16_t bitplane_size;
|
|
|
|
|
|
|
|
|
|
// Only used by custom functions that apply effects on the image. The core
|
|
|
|
|
// CDG functions mainly use the two pre-calculated values
|
|
|
|
|
// [offset_at_bottom_left] and [vram_dword_w] instead.
|
|
|
|
|
int16_t pixel_w;
|
|
|
|
|
int16_t pixel_h;
|
|
|
|
|
|
|
|
|
|
// vram_byte_amount_t, equal to (ROW_SIZE * ([pixel_h - 1])).
|
|
|
|
|
int16_t offset_at_bottom_left;
|
|
|
|
|
|
|
|
|
|
// vram_dword_amount_t, equal to [pixel_w / 32].
|
|
|
|
|
uint16_t vram_dword_w;
|
|
|
|
|
|
|
|
|
|
// In TH03, this can also be 0 for single-image files.
|
|
|
|
|
uint8_t image_count;
|
|
|
|
|
|
|
|
|
|
// See cdg_plane_layout_t.
|
|
|
|
|
int8_t plane_layout;
|
|
|
|
|
|
|
|
|
|
// Memory segments of the loaded data. Must be 0 in the file header!
|
|
|
|
|
uint16_t seg_alpha;
|
|
|
|
|
uint16_t seg_colors;
|
|
|
|
|
} cdg_t;
|
|
|
|
|
|
|
|
|
|
#if (GAME >= 4)
|
|
|
|
|
static const int CDG_SLOT_COUNT = 64;
|
|
|
|
|
#else
|
|
|
|
|
static const int CDG_SLOT_COUNT = 32;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
extern cdg_t cdg_slots[CDG_SLOT_COUNT];
|
|
|
|
|
|
2020-09-05 15:52:09 +00:00
|
|
|
|
// Loading and freeing
|
|
|
|
|
// -------------------
|
|
|
|
|
// Loads all images of the CDG file [fn], starting at [slot_first] and
|
|
|
|
|
// incrementing the slot number for every further image.
|
|
|
|
|
void pascal cdg_load_all(int slot_first, const char *fn);
|
|
|
|
|
|
|
|
|
|
// Like cdg_load_all(), but not loading any alpha planes.
|
[Decompilation] [th05] Stage setup
"Yeah, let's do this real quick, how can this possibly be hard, it's
just MOVs and a few function calls"…
…except that these MOVs access quite a lot of data, which we now all
have to declare in the C world, hooray.
Once it came to midbosses and bosses, I just turned them into C structs
after all. Despite what I said in 260edd8… after all, the ASM world
doesn't care about the representation in the C world, so they don't
necessarily have to be the same.
Since these structs can't contain everything related to midbosses and
bosses (really, why did all those variables have to be spread out like
this, ZUN?), it also made for a nice occasion to continue the "stuff"
naming scheme, describing "an obviously incomplete collection of
variables related to a thing", first seen in 160d4eb.
Also, PROCDESC apparently is the only syntactically correct option to
declare an extern near proc?
Also, that `boss_phase_timed_out` variable only needs to be here
already because TCC enforces word alignment for the .data segment…
yeah, it's technically not related to this commit, but why waste time
working around it if we can just include that one variable.
Completes P0030, funded by zorg.
2019-09-15 18:14:00 +00:00
|
|
|
|
void pascal cdg_load_all_noalpha(int slot_first, const char *fn);
|
2020-09-05 15:52:09 +00:00
|
|
|
|
|
|
|
|
|
// Loads the [n]th image of the CDG file [fn] into [slot].
|
|
|
|
|
void pascal cdg_load_single(int slot, const char *fn, int n);
|
|
|
|
|
|
|
|
|
|
// Like cdg_load_single(), but not loading any alpha planes.
|
|
|
|
|
void pascal cdg_load_single_noalpha(int slot, const char *fn, int n);
|
|
|
|
|
|
|
|
|
|
// Frees the CDG image in the given [slot].
|
|
|
|
|
void pascal cdg_free(int slot);
|
|
|
|
|
|
|
|
|
|
// Frees the CDG images in all slots.
|
|
|
|
|
void pascal cdg_free_all(void);
|
|
|
|
|
// -------------------
|
2020-09-05 23:40:03 +00:00
|
|
|
|
|
|
|
|
|
// Blitting
|
|
|
|
|
// --------
|
2020-09-19 16:41:48 +00:00
|
|
|
|
// Displays the CDG image in the given [slot] at (⌊left/8⌋*8, top).
|
|
|
|
|
void pascal cdg_put_8(screen_x_t left, vram_y_t top, int slot);
|
|
|
|
|
|
2020-09-05 23:40:03 +00:00
|
|
|
|
// Displays the CDG image in the given [slot] at (⌊left/8⌋*8, top),
|
|
|
|
|
// disregarding its alpha plane.
|
2020-09-19 16:41:48 +00:00
|
|
|
|
void pascal cdg_put_noalpha_8(screen_x_t left, vram_y_t top, int slot);
|
|
|
|
|
|
|
|
|
|
#if (GAME == 3)
|
|
|
|
|
// Displays the CDG image in the given [slot] at (⌊left/8⌋*8, top),
|
|
|
|
|
// flipped horizontally using the [hflip_lut].
|
|
|
|
|
void pascal cdg_put_hflip_8(screen_x_t left, vram_y_t top, int slot);
|
|
|
|
|
|
|
|
|
|
// Displays the CDG image in the given [slot] centered at
|
|
|
|
|
// (⌊center_x/8⌋*8, center_y), then applies a dissolve effect with the
|
|
|
|
|
// given [strength] (mod 8, 0 = none, 7 = full) on the E bitplane.
|
|
|
|
|
void pascal cdg_put_dissolve_e_8(
|
|
|
|
|
screen_x_t center_x, vram_y_t center_y, int slot, int strength
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Assuming that the CDG image in the given [slot] was previously
|
|
|
|
|
// displayed centered at (⌊center_x/8⌋*8, center_y), this function clears
|
|
|
|
|
// the two lines at the bottom of that image, as well as the one line
|
|
|
|
|
// immediately below, from the VRAM's E plane.
|
|
|
|
|
void cdg_unput_for_upwards_motion_e_8(
|
|
|
|
|
screen_x_t center_x, vram_y_t center_y, int slot
|
|
|
|
|
);
|
|
|
|
|
#endif
|
2020-09-05 23:40:03 +00:00
|
|
|
|
// --------
|
2020-09-05 14:09:18 +00:00
|
|
|
|
/// ---------------------------------------------------------------------------
|