mirror of https://github.com/n64decomp/mk64.git
Migrate debug font asset to new extract utility (#325)
Required fixing a restriction some old n64graphics chagnes had. We can now use the `-Z` option with both ci8 and ci4 images. Signed-off-by: Taggerung <tyler.taggerung@email.com>
This commit is contained in:
parent
74d3ffec0d
commit
c9ad612442
|
@ -306,7 +306,6 @@
|
|||
"textures/common/132B50_03B48.rgba16.png": {"meta":{"dims":[64,32]}, "offsets": {"us":["0x132B50", "0x03B48"]}},
|
||||
"textures/common/132B50_06A58.i4.png": {"meta":{"dims":[16,16]}, "offsets": {"us":["0x132B50", "0x06A58"]}},
|
||||
"textures/common/132B50_06AD8.ia8.png": {"meta":{"dims":[32,32]}, "offsets": {"us":["0x132B50", "0x06AD8"]}},
|
||||
"textures/common/tlut/132B50_06EF8.rgba16.ci4.png": {"meta":{"dims":[128,32], "pal":"0x06ED8"}, "offsets": {"us":["0x132B50", "0x06EF8"]}},
|
||||
"textures/common/132B50_09958.i4.png": {"meta":{"dims":[64,96]}, "offsets": {"us":["0x132B50", "0x09958"]}},
|
||||
"textures/common/132B50_0A558.i4.png": {"meta":{"dims":[64,32]}, "offsets": {"us":["0x132B50", "0x0A558"]}},
|
||||
"textures/common/132B50_0A958.rgba16.png": {"meta":{"dims":[32,8]}, "offsets": {"us":["0x132B50", "0x0A958"]}},
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"gTLUTDebugFont": {"output_dir": "debug_font", "rom_offset": "0x132B50", "block_offset": "0x6ED8", "width": 4, "height": 4, "type": "rgba16"},
|
||||
"gTextureDebugFont": {"output_dir": "debug_font", "rom_offset": "0x132B50", "block_offset": "0x6EF8", "width": 128, "height": 32, "type": "ci4", "tlut": "gTLUTDebugFont"}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
DEBUG_FONT_DIR := assets/debug_font
|
||||
|
||||
DEBUG_FONT_PALETTE := $(DEBUG_FONT_DIR)/gTLUTDebugFont.png
|
||||
|
||||
DEBUG_FONT_PNG := $(DEBUG_FONT_DIR)/gTextureDebugFont.png
|
||||
|
||||
DEBUG_FONT_EXPORT_SENTINEL := $(DEBUG_FONT_DIR)/.export
|
||||
|
||||
$(BUILD_DIR)/src/common_textures.inc.o: $(DEBUG_FONT_PNG:%.png=%.inc.c) $(DEBUG_FONT_PALETTE:%.png=%.inc.c)
|
||||
|
||||
$(DEBUG_FONT_PNG:%.png=%.inc.c): %.inc.c : %.png
|
||||
$(N64GRAPHICS) -Z $@ -g $< -s u8 -f ci4 -c rgba16 -p $(DEBUG_FONT_PALETTE)
|
||||
|
||||
$(DEBUG_FONT_PALETTE:%.png=%.inc.c): %.inc.c : %.png
|
||||
$(N64GRAPHICS) -i $@ -g $< -s u8 -f rgba16
|
||||
|
||||
$(DEBUG_FONT_PNG) $(DEBUG_FONT_PALETTE): $(DEBUG_FONT_EXPORT_SENTINEL) ;
|
||||
|
||||
$(DEBUG_FONT_EXPORT_SENTINEL): $(ASSET_DIR)/debug_font.json
|
||||
$(ASSET_EXTRACT) $(BASEROM) $<
|
||||
touch $@
|
||||
|
||||
.PHONY: distclean_debug_font
|
||||
distclean_debug_font:
|
||||
rm -rf $(DEBUG_FONT_DIR)
|
||||
|
||||
distclean_assets: distclean_debug_font
|
|
@ -122,8 +122,8 @@ extern Gfx D_0D006A28[];
|
|||
extern Gfx D_0D006A40[];
|
||||
extern s8 D_0D006A58[];
|
||||
extern s8 D_0D006AD8[];
|
||||
extern s8 D_0D006ED8[];
|
||||
extern s8 D_0D006EF8[];
|
||||
extern s8 gTLUTDebugFont[];
|
||||
extern s8 gTextureDebugFont[];
|
||||
extern Gfx D_0D0076F8[];
|
||||
extern Gfx D_0D007780[];
|
||||
extern Gfx D_0D0077A0[];
|
||||
|
|
|
@ -1243,12 +1243,12 @@ s8 D_0D006AD8[] = {
|
|||
};
|
||||
|
||||
// tlut
|
||||
s8 D_0D006ED8[] = {
|
||||
#include "textures/common/tlut/132B50_06EF8.rgba16.ci4.tlut.inc.c"
|
||||
s8 gTLUTDebugFont[] = {
|
||||
#include "assets/debug_font/gTLUTDebugFont.inc.c"
|
||||
};
|
||||
|
||||
s8 D_0D006EF8[] = {
|
||||
#include "textures/common/tlut/132B50_06EF8.rgba16.ci4.inc.c"
|
||||
s8 gTextureDebugFont[] = {
|
||||
#include "assets/debug_font/gTextureDebugFont.inc.c"
|
||||
};
|
||||
|
||||
// 0x76F8
|
||||
|
@ -1722,9 +1722,9 @@ Gfx D_0D008060[] = {
|
|||
Gfx D_0D008080[] = {
|
||||
gsSPDisplayList(D_0D007EF8),
|
||||
gsDPSetTextureLUT(G_TT_RGBA16),
|
||||
gsDPLoadTLUT_pal16(0, D_0D006ED8),
|
||||
gsDPLoadTLUT_pal16(0, gTLUTDebugFont),
|
||||
gsDPLoadSync(),
|
||||
gsDPLoadTextureBlock_4b(D_0D006EF8, G_IM_FMT_CI, 128, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD),
|
||||
gsDPLoadTextureBlock_4b(gTextureDebugFont, G_IM_FMT_CI, 128, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD),
|
||||
gsSPEndDisplayList(),
|
||||
};
|
||||
|
||||
|
|
|
@ -326,7 +326,7 @@ int get_color_index(const rgba comp, const rgba *pal, int mask_value, int pal_si
|
|||
* If a value in img is not found in pal, return 0, indicating an error
|
||||
* Returns 1 if all values in img are found somewhere in pal
|
||||
**/
|
||||
int imgpal2rawci(uint8_t *rawci, const rgba *img, const rgba *pal, const uint8_t *wheel_mask, int raw_size, int img_size, int pal_size) {
|
||||
int imgpal2rawci(uint8_t *rawci, const rgba *img, const rgba *pal, const uint8_t *wheel_mask, int raw_size, int ci_depth, int img_size, int pal_size) {
|
||||
int img_idx;
|
||||
int pal_idx;
|
||||
int mask_value;
|
||||
|
@ -340,7 +340,19 @@ int imgpal2rawci(uint8_t *rawci, const rgba *img, const rgba *pal, const uint8_t
|
|||
}
|
||||
pal_idx = get_color_index(img[img_idx], pal, mask_value, pal_size);
|
||||
if (pal_idx != -1) {
|
||||
rawci[img_idx] = pal_idx;
|
||||
switch (ci_depth) {
|
||||
case 8:
|
||||
rawci[img_idx] = pal_idx;
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
int byte_idx = img_idx / 2;
|
||||
int nibble = 1 - (img_idx % 2);
|
||||
uint8_t mask = 0xF << (4 * (1 - nibble));
|
||||
rawci[byte_idx] = (rawci[byte_idx] & mask) | (pal_idx << (4 * nibble));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -1207,8 +1219,6 @@ int main(int argc, char *argv[])
|
|||
* The proper thing to do here would be to:
|
||||
* Expand the config to have separate image and bin file parameters
|
||||
* Add optional argument(s) to specify the new parameters
|
||||
* In practice what this means is that, as written, when using the -Z mode you MUST set the -f
|
||||
* argument to `ci8`. Anything else is erroneous
|
||||
**/
|
||||
switch (config.format.format) {
|
||||
case IMG_FORMAT_CI:
|
||||
|
@ -1238,7 +1248,7 @@ int main(int argc, char *argv[])
|
|||
wheel_mask = NULL;
|
||||
}
|
||||
|
||||
conversion_success = imgpal2rawci(rawci, imgr, palr, wheel_mask, ci_length, img_length, pal_length);
|
||||
conversion_success = imgpal2rawci(rawci, imgr, palr, wheel_mask, ci_length, config.format.depth, img_length, pal_length);
|
||||
if (!conversion_success) {
|
||||
ERROR("Error converting PNG and TLUT to CI\n");
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
Loading…
Reference in New Issue