Don't pass quite so many args to DrawCharacter().

This commit is contained in:
Unknown W. Brackets 2013-05-05 21:13:50 -07:00
parent 4ab165ebd7
commit 95823a776b
3 changed files with 22 additions and 31 deletions

View File

@ -409,7 +409,7 @@ bool PGF::GetCharGlyph(int charCode, int glyphType, Glyph &glyph) {
return true;
}
void PGF::DrawCharacter(u32 base, int bpl, int bufWidth, int bufHeight, int x, int y, int clipX, int clipY, int clipWidth, int clipHeight, int pixelformat, int charCode, int altCharCode, int glyphType) {
void PGF::DrawCharacter(const GlyphImage *image, int clipX, int clipY, int clipWidth, int clipHeight, int charCode, int altCharCode, int glyphType) {
Glyph glyph;
if (!GetCharGlyph(charCode, glyphType, glyph)) {
// No Glyph available for this charCode, try to use the alternate char.
@ -432,6 +432,9 @@ void PGF::DrawCharacter(u32 base, int bpl, int bufWidth, int bufHeight, int x, i
int numberPixels = glyph.w * glyph.h;
int pixelIndex = 0;
int x = image->xPos64 >> 6;
int y = image->yPos64 >> 6;
while (pixelIndex < numberPixels && bitPtr + 8 < fontDataSize * 8) {
// This is some kind of nibble based RLE compression.
int nibble = getBits(4, fontData, bitPtr);
@ -467,7 +470,7 @@ void PGF::DrawCharacter(u32 base, int bpl, int bufWidth, int bufHeight, int x, i
if (pixelX >= clipX && pixelX < clipX + clipWidth && pixelY >= clipY && pixelY < clipY + clipHeight) {
// 4-bit color value
int pixelColor = value;
switch (pixelformat) {
switch (image->pixelFormat) {
case PSP_FONT_PIXELFORMAT_8:
// 8-bit color value
pixelColor |= pixelColor << 4;
@ -486,7 +489,7 @@ void PGF::DrawCharacter(u32 base, int bpl, int bufWidth, int bufHeight, int x, i
break;
}
SetFontPixel(base, bpl, bufWidth, bufHeight, pixelX, pixelY, pixelColor, pixelformat);
SetFontPixel(image->bufferPtr, image->bytesPerLine, image->bufWidth, image->bufHeight, pixelX, pixelY, pixelColor, image->pixelFormat);
}
pixelIndex++;

View File

@ -108,6 +108,17 @@ struct Glyph {
u32 ptr;
};
struct GlyphImage {
FontPixelFormat pixelFormat;
s32 xPos64;
s32 yPos64;
u16 bufWidth;
u16 bufHeight;
u16 bytesPerLine;
u16 pad;
u32 bufferPtr;
};
#pragma pack(push,1)
struct PGFHeader
{
@ -243,7 +254,7 @@ public:
bool GetCharInfo(int charCode, PGFCharInfo *ci);
void GetFontInfo(PGFFontInfo *fi);
void DrawCharacter(u32 base, int bpl, int bufWidth, int bufHeight, int x, int y, int clipX, int clipY, int clipWidth, int clipHeight, int pixelformat, int charCode, int altCharCode, int glyphType);
void DrawCharacter(const GlyphImage *image, int clipX, int clipY, int clipWidth, int clipHeight, int charCode, int altCharCode, int glyphType);
void DoState(PointerWrap &p);

View File

@ -57,17 +57,6 @@ struct FontNewLibParams {
u32 ioFinishFuncAddr;
};
struct GlyphImage {
FontPixelFormat pixelFormat;
s32 xPos64;
s32 yPos64;
u16 bufWidth;
u16 bufHeight;
u16 bytesPerLine;
u16 pad;
u32 bufferPtr;
};
struct FontRegistryEntry {
int hSize;
int vSize;
@ -840,13 +829,7 @@ int sceFontGetShadowImageRect(u32 fontHandle, u32 charCode, u32 charRectPtr) {
int sceFontGetCharGlyphImage(u32 fontHandle, u32 charCode, u32 glyphImagePtr) {
INFO_LOG(HLE, "sceFontGetCharGlyphImage(%x, %x, %x)", fontHandle, charCode, glyphImagePtr);
int pixelFormat = Memory::Read_U32(glyphImagePtr);
int xPos64 = Memory::Read_U32(glyphImagePtr+4);
int yPos64 = Memory::Read_U32(glyphImagePtr+8);
int bufWidth = Memory::Read_U16(glyphImagePtr+12);
int bufHeight = Memory::Read_U16(glyphImagePtr+14);
int bytesPerLine = Memory::Read_U16(glyphImagePtr+16);
int buffer = Memory::Read_U32(glyphImagePtr+20);
auto glyph = Memory::GetStruct<const GlyphImage>(glyphImagePtr);
LoadedFont *font = GetLoadedFont(fontHandle, false);
if (!font) {
@ -854,20 +837,14 @@ int sceFontGetCharGlyphImage(u32 fontHandle, u32 charCode, u32 glyphImagePtr) {
return 0;
}
int altCharCode = font->GetFontLib()->GetAltCharCode();
font->GetPGF()->DrawCharacter(buffer, bytesPerLine, bufWidth, bufHeight, xPos64 >> 6, yPos64 >> 6, 0, 0, 8192, 8192, pixelFormat, charCode, altCharCode, FONT_PGF_CHARGLYPH);
font->GetPGF()->DrawCharacter(glyph, 0, 0, 8192, 8192, charCode, altCharCode, FONT_PGF_CHARGLYPH);
return 0;
}
int sceFontGetCharGlyphImage_Clip(u32 fontHandle, u32 charCode, u32 glyphImagePtr, int clipXPos, int clipYPos, int clipWidth, int clipHeight) {
INFO_LOG(HLE, "sceFontGetCharGlyphImage_Clip(%08x, %i, %08x, %i, %i, %i, %i)", fontHandle, charCode, glyphImagePtr, clipXPos, clipYPos, clipWidth, clipHeight);
int pixelFormat = Memory::Read_U32(glyphImagePtr);
int xPos64 = Memory::Read_U32(glyphImagePtr+4);
int yPos64 = Memory::Read_U32(glyphImagePtr+8);
int bufWidth = Memory::Read_U16(glyphImagePtr+12);
int bufHeight = Memory::Read_U16(glyphImagePtr+14);
int bytesPerLine = Memory::Read_U16(glyphImagePtr+16);
int buffer = Memory::Read_U32(glyphImagePtr+20);
auto glyph = Memory::GetStruct<const GlyphImage>(glyphImagePtr);
LoadedFont *font = GetLoadedFont(fontHandle, false);
if (!font) {
@ -875,7 +852,7 @@ int sceFontGetCharGlyphImage_Clip(u32 fontHandle, u32 charCode, u32 glyphImagePt
return 0;
}
int altCharCode = font->GetFontLib()->GetAltCharCode();
font->GetPGF()->DrawCharacter(buffer, bytesPerLine, bufWidth, bufHeight, xPos64 >> 6, yPos64 >> 6, clipXPos, clipYPos, clipXPos + clipWidth, clipYPos + clipHeight, pixelFormat, charCode, altCharCode, FONT_PGF_CHARGLYPH);
font->GetPGF()->DrawCharacter(glyph, clipXPos, clipYPos, clipXPos + clipWidth, clipYPos + clipHeight, charCode, altCharCode, FONT_PGF_CHARGLYPH);
return 0;
}