Use fmt::to_string for texture format overlay

This required adding parentheses to the font used by that.
This commit is contained in:
Pokechu22 2022-02-22 18:22:47 -08:00
parent 290e62f179
commit 850e524514
2 changed files with 27 additions and 77 deletions

View File

@ -242,7 +242,7 @@ TextureFormat TexDecoder_GetEFBCopyBaseFormat(EFBCopyFormat format)
case EFBCopyFormat::XFB:
return TextureFormat::XFB;
default:
PanicAlertFmt("Invalid EFB Copy Format ()! (GetEFBCopyBaseFormat)", format);
PanicAlertFmt("Invalid EFB Copy Format {}! (GetEFBCopyBaseFormat)", format);
return static_cast<TextureFormat>(format);
}
}
@ -253,77 +253,6 @@ void TexDecoder_SetTexFmtOverlayOptions(bool enable, bool center)
TexFmt_Overlay_Center = center;
}
static const char* texfmt[] = {
// pixel
"I4",
"I8",
"IA4",
"IA8",
"RGB565",
"RGB5A3",
"RGBA8",
"0x07",
"C4",
"C8",
"C14X2",
"0x0B",
"0x0C",
"0x0D",
"CMPR",
"0x0F",
// Z-buffer
"0x10",
"Z8",
"0x12",
"Z16",
"0x14",
"0x15",
"Z24X8",
"0x17",
"0x18",
"0x19",
"0x1A",
"0x1B",
"0x1C",
"0x1D",
"0x1E",
"0x1F",
// pixel + copy
"CR4",
"0x21",
"CRA4",
"CRA8",
"0x24",
"0x25",
"CYUVA8",
"CA8",
"CR8",
"CG8",
"CB8",
"CRG8",
"CGB8",
"0x2D",
"0x2E",
"XFB",
// Z + copy
"CZ4",
"0x31",
"0x32",
"0x33",
"0x34",
"0x35",
"0x36",
"0x37",
"0x38",
"CZ8M",
"CZ8L",
"0x3B",
"CZ16L",
"0x3D",
"0x3E",
"0x3F",
};
static void TexDecoder_DrawOverlay(u8* dst, int width, int height, TextureFormat texformat)
{
int w = std::min(width, 40);
@ -338,11 +267,11 @@ static void TexDecoder_DrawOverlay(u8* dst, int width, int height, TextureFormat
yoff = 0;
}
const char* fmt = texfmt[static_cast<int>(texformat) & 15];
while (*fmt)
const auto fmt_str = fmt::to_string(texformat);
for (char ch : fmt_str)
{
int xcnt = 0;
int nchar = sfont_map[(int)*fmt];
int nchar = sfont_map[ch];
const unsigned char* ptr = sfont_raw[nchar]; // each char is up to 9x10
@ -363,7 +292,6 @@ static void TexDecoder_DrawOverlay(u8* dst, int width, int height, TextureFormat
ptr += 9;
}
xoff += xcnt;
fmt++;
}
}

View File

@ -4,7 +4,7 @@
static const unsigned char sfont_map[] = {
10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
10,10,10,10,10,10,10,10,63,64,10,10,10,10,10,10,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,10,10,10,10,10,
10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,
26,27,28,29,30,31,32,33,34,35,36,10,10,10,10,10,
@ -713,5 +713,27 @@ static const unsigned char sfont_raw[][9*10] = {
0xff, 0x00, 0x00, 0x00, 0xff, 0x78, 0x78, 0x78, 0x78,
0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78,
0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78,
},{
0xff, 0xff, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
0xff, 0xff, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
0xff, 0xff, 0x00, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
0xff, 0x00, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
0xff, 0x00, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
0xff, 0x00, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
0xff, 0x00, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
0xff, 0xff, 0x00, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
0xff, 0xff, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
0xff, 0xff, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
},{
0xff, 0xff, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
0xff, 0xff, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
0xff, 0x00, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
0xff, 0xff, 0x00, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
0xff, 0xff, 0x00, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
0xff, 0xff, 0x00, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
0xff, 0xff, 0x00, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
0xff, 0x00, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
0xff, 0xff, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
0xff, 0xff, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78, 0x78,
},
};