2020-07-29 18:09:12 +00:00
|
|
|
|
/// Uncompressed monochrome 8w×h sprite format
|
|
|
|
|
/// ------------------------------------------
|
2024-05-16 17:34:26 +00:00
|
|
|
|
|
2020-07-30 18:46:00 +00:00
|
|
|
|
#include "th01/formats/sprfmt_h.hpp"
|
2021-11-01 15:44:11 +00:00
|
|
|
|
#include "th01/sprites/main_grc.h"
|
2024-05-16 17:34:26 +00:00
|
|
|
|
#include "game/pf.h"
|
2024-05-25 18:31:09 +00:00
|
|
|
|
#include "planar.h"
|
2020-07-30 18:46:00 +00:00
|
|
|
|
|
|
|
|
|
#define GRC_MAGIC "GRCG"
|
|
|
|
|
|
|
|
|
|
// On-disk per-file header. Not the same as for .BOS!
|
|
|
|
|
struct grc_header_t {
|
|
|
|
|
char magic[sizeof(GRC_MAGIC) - 1];
|
|
|
|
|
int16_t vram_w;
|
|
|
|
|
int16_t h;
|
|
|
|
|
spriteformat_header_inner_t inner;
|
|
|
|
|
};
|
|
|
|
|
|
2020-07-29 18:09:12 +00:00
|
|
|
|
static const int GRC_IMAGES_PER_SLOT = 8;
|
|
|
|
|
|
|
|
|
|
// In-memory slot structure
|
|
|
|
|
struct grc_t {
|
2020-08-21 18:13:08 +00:00
|
|
|
|
vram_byte_amount_t vram_w;
|
|
|
|
|
pixel_t h;
|
2020-07-29 18:09:12 +00:00
|
|
|
|
int image_count;
|
|
|
|
|
dots8_t* dots[GRC_IMAGES_PER_SLOT];
|
|
|
|
|
};
|
|
|
|
|
|
2020-07-30 18:46:00 +00:00
|
|
|
|
// Loads all images from the .GRC file with the given [fn] inside the
|
|
|
|
|
// currently active packfile into the given .GRC [slot]. Always returns 0.
|
2021-11-01 15:44:11 +00:00
|
|
|
|
int grc_load(main_grc_slot_t slot, const char fn[PF_FN_LEN]);
|
2020-07-31 19:09:50 +00:00
|
|
|
|
|
2020-08-01 09:58:16 +00:00
|
|
|
|
// Frees all images in the given [slot].
|
2021-11-01 15:44:11 +00:00
|
|
|
|
void grc_free(main_grc_slot_t slot);
|
2020-08-01 09:58:16 +00:00
|
|
|
|
|
2020-07-31 19:09:50 +00:00
|
|
|
|
// Blits the sub[image] from the given [slot] to (⌊left/8⌋*8, top) with the
|
|
|
|
|
// given [col]. Correctly clips the sprite at all 4 edges of VRAM.
|
2021-11-01 15:44:11 +00:00
|
|
|
|
void grc_put_8(
|
2023-06-25 18:41:05 +00:00
|
|
|
|
screen_x_t left, vram_y_t top, main_grc_slot_t slot, int image, vc2 col
|
2021-11-01 15:44:11 +00:00
|
|
|
|
);
|
2022-05-08 18:03:18 +00:00
|
|
|
|
|
|
|
|
|
// For some reason, all code assumes .GRC entities to be 48×32, rather than
|
|
|
|
|
// 32×32. Why?!
|
|
|
|
|
#define grc_sloppy_unput(left, top) \
|
|
|
|
|
egc_copy_rect_1_to_0_16(left, top, 48, 32);
|
2020-07-29 18:09:12 +00:00
|
|
|
|
/// ------------------------------------------
|