mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-03-01 10:35:54 +00:00
PGF font works!
Please put font file from flash0:/font/ to Flash/font/
This commit is contained in:
parent
ffd3e76878
commit
11dd7c57ac
@ -1,11 +1,20 @@
|
||||
#include "sceFont.h"
|
||||
|
||||
|
||||
#include "base/timeutil.h"
|
||||
|
||||
#include "../Config.h"
|
||||
#include "../Host.h"
|
||||
#include "../SaveState.h"
|
||||
#include "HLE.h"
|
||||
#include "../MIPS/MIPS.h"
|
||||
#include "ChunkFile.h"
|
||||
|
||||
#include "../FileSystems/FileSystem.h"
|
||||
#include "../FileSystems/MetaFileSystem.h"
|
||||
#include "../System.h"
|
||||
|
||||
|
||||
|
||||
#include "sceFont.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@ -249,7 +258,7 @@ PGF_FONT *load_pgf_from_buf(u8 *buf, int length)
|
||||
buf += (ph->dimension_len*8);
|
||||
|
||||
/* left bearing table */
|
||||
pgft->bearingX = (F26_PAIRS*)buf;
|
||||
pgft->bearingX = (F26_PAIRS*)buf;
|
||||
buf += (ph->bearingX_len*8);
|
||||
|
||||
/* top bearing table */
|
||||
@ -306,142 +315,55 @@ void free_pgf_font(PGF_FONT *pgft)
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
static const char *font_list[16] = {
|
||||
"flash0:/font/jpn0.pgf",
|
||||
"flash0:/font/ltn0.pgf",
|
||||
"flash0:/font/ltn2.pgf",
|
||||
"flash0:/font/ltn3.pgf",
|
||||
"flash0:/font/ltn4.pgf",
|
||||
"flash0:/font/ltn5.pgf",
|
||||
"flash0:/font/ltn6.pgf",
|
||||
"flash0:/font/ltn7.pgf",
|
||||
"flash0:/font/ltn8.pgf",
|
||||
"flash0:/font/ltn9.pgf",
|
||||
"flash0:/font/ltn10.pgf",
|
||||
"flash0:/font/ltn11.pgf",
|
||||
"flash0:/font/ltn12.pgf",
|
||||
"flash0:/font/ltn13.pgf",
|
||||
"flash0:/font/ltn14.pgf",
|
||||
"flash0:/font/ltn15.pgf",
|
||||
};
|
||||
static int font_num = 16;
|
||||
|
||||
static PGF_FONT *font_slot[8] = {NULL, };
|
||||
|
||||
static int get_font_slot(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<8; i++){
|
||||
if(font_slot[i]==NULL)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static float f26_float(int value)
|
||||
{
|
||||
float f, t;
|
||||
|
||||
f = (float)(value>>6);
|
||||
t = (float)(value&0x3f);
|
||||
f += t/64;
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
typedef u32 FontLibraryHandle;
|
||||
typedef u32 FontHandle;
|
||||
|
||||
struct FontNewLibParams {
|
||||
u32 userDataAddr;
|
||||
u32 numFonts;
|
||||
u32 cacheDataAddr;
|
||||
|
||||
// Driver callbacks.
|
||||
u32 allocFuncAddr;
|
||||
u32 freeFuncAddr;
|
||||
u32 openFuncAddr;
|
||||
u32 closeFuncAddr;
|
||||
u32 readFuncAddr;
|
||||
u32 seekFuncAddr;
|
||||
u32 errorFuncAddr;
|
||||
u32 ioFinishFuncAddr;
|
||||
};
|
||||
|
||||
typedef enum Family {
|
||||
FONT_FAMILY_SANS_SERIF = 1,
|
||||
FONT_FAMILY_SERIF = 2,
|
||||
};
|
||||
|
||||
typedef enum Style {
|
||||
FONT_STYLE_REGULAR = 1,
|
||||
FONT_STYLE_ITALIC = 2,
|
||||
FONT_STYLE_BOLD = 5,
|
||||
FONT_STYLE_BOLD_ITALIC = 6,
|
||||
FONT_STYLE_DB = 103, // Demi-Bold / semi-bold
|
||||
};
|
||||
|
||||
typedef enum Language {
|
||||
FONT_LANGUAGE_JAPANESE = 1,
|
||||
FONT_LANGUAGE_LATIN = 2,
|
||||
FONT_LANGUAGE_KOREAN = 3,
|
||||
};
|
||||
|
||||
struct FontStyle {
|
||||
float fontH;
|
||||
float fontV;
|
||||
float fontHRes;
|
||||
float fontVRes;
|
||||
float fontWeight;
|
||||
u16 fontFamily;
|
||||
u16 fontStyle;
|
||||
// Check.
|
||||
u16 fontStyleSub;
|
||||
u16 fontLanguage;
|
||||
u16 fontRegion;
|
||||
u16 fontCountry;
|
||||
char fontName[64];
|
||||
char fontFileName[64];
|
||||
u32 fontAttributes;
|
||||
u32 fontExpire;
|
||||
};
|
||||
|
||||
struct FontInfo {
|
||||
// Glyph metrics (in 26.6 signed fixed-point).
|
||||
u32 maxGlyphWidthI;
|
||||
u32 maxGlyphHeightI;
|
||||
u32 maxGlyphAscenderI;
|
||||
u32 maxGlyphDescenderI;
|
||||
u32 maxGlyphLeftXI;
|
||||
u32 maxGlyphBaseYI;
|
||||
u32 minGlyphCenterXI;
|
||||
u32 maxGlyphTopYI;
|
||||
u32 maxGlyphAdvanceXI;
|
||||
u32 maxGlyphAdvanceYI;
|
||||
|
||||
// Glyph metrics (replicated as float).
|
||||
float maxGlyphWidthF;
|
||||
float maxGlyphHeightF;
|
||||
float maxGlyphAscenderF;
|
||||
float maxGlyphDescenderF;
|
||||
float maxGlyphLeftXF;
|
||||
float maxGlyphBaseYF;
|
||||
float minGlyphCenterXF;
|
||||
float maxGlyphTopYF;
|
||||
float maxGlyphAdvanceXF;
|
||||
float maxGlyphAdvanceYF;
|
||||
|
||||
// Bitmap dimensions.
|
||||
short maxGlyphWidth;
|
||||
short maxGlyphHeight;
|
||||
u32 charMapLength; // Number of elements in the font's charmap.
|
||||
u32 shadowMapLength; // Number of elements in the font's shadow charmap.
|
||||
|
||||
// Font style (used by font comparison functions).
|
||||
FontStyle fontStyle;
|
||||
|
||||
u8 BPP; // Font's BPP.
|
||||
u8 pad[3];
|
||||
};
|
||||
|
||||
struct CharInfo {
|
||||
u32 bitmapWidth;
|
||||
u32 bitmapHeight;
|
||||
u32 bitmapLeft;
|
||||
u32 bitmapTop;
|
||||
// Glyph metrics (in 26.6 signed fixed-point).
|
||||
u32 spf26Width;
|
||||
u32 spf26Height;
|
||||
s32 spf26Ascender;
|
||||
s32 spf26Descender;
|
||||
s32 spf26BearingHX;
|
||||
s32 spf26BearingHY;
|
||||
s32 spf26BearingVX;
|
||||
s32 spf26BearingVY;
|
||||
s32 spf26AdvanceH;
|
||||
s32 spf26AdvanceV;
|
||||
u8 pad[4];
|
||||
};
|
||||
|
||||
enum FontPixelFormat {
|
||||
PSP_FONT_PIXELFORMAT_4 = 0,
|
||||
PSP_FONT_PIXELFORMAT_4_REV = 1,
|
||||
PSP_FONT_PIXELFORMAT_8 = 2,
|
||||
PSP_FONT_PIXELFORMAT_24 = 3,
|
||||
PSP_FONT_PIXELFORMAT_32 = 4
|
||||
};
|
||||
|
||||
struct GlyphImage {
|
||||
FontPixelFormat pixelFormat;
|
||||
s32 xPos64;
|
||||
s32 yPos64;
|
||||
u16 bufWidth;
|
||||
u16 bufHeight;
|
||||
u16 bytesPerLine;
|
||||
u16 pad;
|
||||
u32 bufferPtr;
|
||||
};
|
||||
|
||||
FontNewLibParams fontLib;
|
||||
|
||||
@ -458,7 +380,7 @@ void __FontDoState(PointerWrap &p)
|
||||
|
||||
u32 sceFontNewLib(u32 FontNewLibParamsPtr, u32 errorCodePtr)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceFontNewLib %x, %x", FontNewLibParamsPtr, errorCodePtr);
|
||||
DEBUG_LOG(HLE, "sceFontNewLib %x, %x", FontNewLibParamsPtr, errorCodePtr);
|
||||
|
||||
if (Memory::IsValidAddress(FontNewLibParamsPtr)&&Memory::IsValidAddress(errorCodePtr))
|
||||
{
|
||||
@ -469,55 +391,142 @@ u32 sceFontNewLib(u32 FontNewLibParamsPtr, u32 errorCodePtr)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int sceFontDoneLib(u32 FontLibraryHandlePtr)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceFontDoneLib %x", FontLibraryHandlePtr);
|
||||
DEBUG_LOG(HLE, "sceFontDoneLib %x", FontLibraryHandlePtr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
u32 sceFontOpen(u32 libHandle, u32 index, u32 mode, u32 errorCodePtr)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceFontDoneLib %x, %x, %x, %x", libHandle, index, mode, errorCodePtr);
|
||||
if (Memory::IsValidAddress(errorCodePtr))
|
||||
{
|
||||
Memory::Write_U32(0, errorCodePtr);
|
||||
int retv, slot;
|
||||
u8 *buf;
|
||||
|
||||
DEBUG_LOG(HLE, "sceFontDoneLib %x, %x, %x, %x", libHandle, index, mode, errorCodePtr);
|
||||
|
||||
retv = 0;
|
||||
slot = get_font_slot();
|
||||
if(slot==-1){
|
||||
retv = -1;
|
||||
if (Memory::IsValidAddress(errorCodePtr))
|
||||
Memory::Write_U32(-1, errorCodePtr);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
||||
index -= 1;
|
||||
u32 h = pspFileSystem.OpenFile(font_list[index], FILEACCESS_READ);
|
||||
if (h == 0){
|
||||
ERROR_LOG(HLE, "sceFontOpen: %s not found", font_list[index]);
|
||||
if (Memory::IsValidAddress(errorCodePtr))
|
||||
Memory::Write_U32(-1, errorCodePtr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
PSPFileInfo info = pspFileSystem.GetFileInfo(font_list[index]);
|
||||
buf = (u8*)malloc((size_t)info.size);
|
||||
pspFileSystem.ReadFile(h, buf, info.size);
|
||||
pspFileSystem.CloseFile(h);
|
||||
|
||||
font_slot[slot] = load_pgf_from_buf(buf, (int)info.size);
|
||||
|
||||
if (Memory::IsValidAddress(errorCodePtr))
|
||||
Memory::Write_U32(0, errorCodePtr);
|
||||
|
||||
return slot+1;
|
||||
}
|
||||
|
||||
u32 sceFontOpenUserMemory(u32 libHandle, u32 memoryFontAddrPtr, u32 memoryFontLength, u32 errorCodePtr)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceFontOpenUserMemory %x, %x, %x, %x", libHandle, memoryFontAddrPtr, memoryFontLength, errorCodePtr);
|
||||
if (Memory::IsValidAddress(errorCodePtr))
|
||||
{
|
||||
Memory::Write_U32(0, errorCodePtr);
|
||||
int retv, slot;
|
||||
u8 *buf;
|
||||
|
||||
DEBUG_LOG(HLE, "sceFontOpenUserMemory %x, %x, %x, %x", libHandle, memoryFontAddrPtr, memoryFontLength, errorCodePtr);
|
||||
|
||||
retv = 0;
|
||||
slot = get_font_slot();
|
||||
if(slot==-1){
|
||||
if (Memory::IsValidAddress(errorCodePtr))
|
||||
Memory::Write_U32(-1, errorCodePtr);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
||||
if (!Memory::IsValidAddress(memoryFontAddrPtr)){
|
||||
if (Memory::IsValidAddress(errorCodePtr))
|
||||
Memory::Write_U32(-1, errorCodePtr);
|
||||
return 0;
|
||||
}
|
||||
buf = (u8*) Memory::GetPointer(memoryFontAddrPtr);
|
||||
|
||||
font_slot[slot] = load_pgf_from_buf(buf, memoryFontLength);
|
||||
|
||||
if (Memory::IsValidAddress(errorCodePtr))
|
||||
Memory::Write_U32(0, errorCodePtr);
|
||||
|
||||
return slot+1;
|
||||
}
|
||||
|
||||
u32 sceFontOpenUserFile(u32 libHandle, u32 fileNamePtr, u32 mode, u32 errorCodePtr)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceFontOpenUserFile %x, %x, %x, %x", libHandle, fileNamePtr, mode, errorCodePtr);
|
||||
if (Memory::IsValidAddress(errorCodePtr))
|
||||
{
|
||||
Memory::Write_U32(0, errorCodePtr);
|
||||
int retv, slot;
|
||||
u8 *buf;
|
||||
char *filename;
|
||||
|
||||
DEBUG_LOG(HLE, "sceFontOpenUserFile %x, %x, %x, %x", libHandle, fileNamePtr, mode, errorCodePtr);
|
||||
|
||||
retv = 0;
|
||||
slot = get_font_slot();
|
||||
if(slot==-1){
|
||||
if (Memory::IsValidAddress(errorCodePtr))
|
||||
Memory::Write_U32(-1, errorCodePtr);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
||||
if (!Memory::IsValidAddress(fileNamePtr)){
|
||||
if (Memory::IsValidAddress(errorCodePtr))
|
||||
Memory::Write_U32(-1, errorCodePtr);
|
||||
return 0;
|
||||
}
|
||||
filename = (char*) Memory::GetPointer(fileNamePtr);
|
||||
|
||||
u32 h = pspFileSystem.OpenFile(filename, FILEACCESS_READ);
|
||||
if (h == 0){
|
||||
ERROR_LOG(HLE, "sceFontOpenUserFIle: %s not found", filename);
|
||||
if (Memory::IsValidAddress(errorCodePtr))
|
||||
Memory::Write_U32(-1, errorCodePtr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
PSPFileInfo info = pspFileSystem.GetFileInfo(filename);
|
||||
buf = (u8*)malloc((size_t)info.size);
|
||||
pspFileSystem.ReadFile(h, buf, info.size);
|
||||
pspFileSystem.CloseFile(h);
|
||||
|
||||
font_slot[slot] = load_pgf_from_buf(buf, (int)info.size);
|
||||
|
||||
if (Memory::IsValidAddress(errorCodePtr))
|
||||
Memory::Write_U32(0, errorCodePtr);
|
||||
|
||||
return slot+1;
|
||||
}
|
||||
|
||||
int sceFontClose(u32 fontHandle)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceFontClose %x", fontHandle);
|
||||
int slot;
|
||||
|
||||
DEBUG_LOG(HLE, "sceFontClose %x", fontHandle);
|
||||
|
||||
slot = fontHandle-1;
|
||||
free_pgf_font(font_slot[slot]);
|
||||
font_slot[slot] = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceFontFindOptimumFont(u32 libHandlePtr, u32 fontStylePtr, u32 errorCodePtr)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceFontFindOptimumFont %x, %x, %x", libHandlePtr, fontStylePtr, errorCodePtr);
|
||||
if (Memory::IsValidAddress(errorCodePtr))
|
||||
{
|
||||
DEBUG_LOG(HLE, "sceFontFindOptimumFont %x, %x, %x", libHandlePtr, fontStylePtr, errorCodePtr);
|
||||
if (Memory::IsValidAddress(errorCodePtr)){
|
||||
Memory::Write_U32(0, errorCodePtr);
|
||||
}
|
||||
return 1;
|
||||
@ -525,84 +534,125 @@ int sceFontFindOptimumFont(u32 libHandlePtr, u32 fontStylePtr, u32 errorCodePtr)
|
||||
|
||||
int sceFontFindFont(u32 libHandlePtr, u32 fontStylePtr, u32 errorCodePtr)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceFontFindFont %x, %x, %x", libHandlePtr, fontStylePtr, errorCodePtr);
|
||||
DEBUG_LOG(HLE, "sceFontFindFont %x, %x, %x", libHandlePtr, fontStylePtr, errorCodePtr);
|
||||
if (Memory::IsValidAddress(errorCodePtr)){
|
||||
Memory::Write_U32(0, errorCodePtr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sceFontGetFontInfo(u32 fontHandle, u32 fontInfoPtr)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceFontGetFontInfo %x, %x", fontHandle, fontInfoPtr);
|
||||
PGF_FONT *pgft;
|
||||
PGF_HEADER *ph;
|
||||
int slot;
|
||||
|
||||
DEBUG_LOG(HLE, "sceFontGetFontInfo %x, %x", fontHandle, fontInfoPtr);
|
||||
|
||||
slot = fontHandle-1;
|
||||
pgft = font_slot[slot];
|
||||
ph = (PGF_HEADER*)pgft->buf;
|
||||
|
||||
FontInfo fi;
|
||||
memset (&fi, 0, sizeof(fi));
|
||||
if (Memory::IsValidAddress(fontInfoPtr))
|
||||
{
|
||||
fi.BPP = 4;
|
||||
fi.charMapLength = 255;
|
||||
fi.maxGlyphAdvanceXF = 2.0;
|
||||
fi.maxGlyphAdvanceXI = 2;
|
||||
fi.maxGlyphAdvanceYF = 2.0;
|
||||
fi.maxGlyphAdvanceYI = 32 << 6;
|
||||
fi.maxGlyphAscenderF = 32 << 6;
|
||||
fi.maxGlyphAscenderI = 32 << 6;
|
||||
fi.maxGlyphBaseYF = 0.0;
|
||||
fi.maxGlyphBaseYI = 0;
|
||||
fi.maxGlyphDescenderF = 0;
|
||||
fi.maxGlyphDescenderI = 0;
|
||||
fi.maxGlyphHeight = 32;
|
||||
fi.maxGlyphHeightF = 32;
|
||||
fi.maxGlyphHeightI = 32;
|
||||
fi.maxGlyphLeftXF = 0;
|
||||
fi.maxGlyphLeftXI = 0;
|
||||
fi.maxGlyphTopYF = 0;
|
||||
fi.maxGlyphTopYI = 0;
|
||||
fi.maxGlyphWidth = 32;
|
||||
fi.maxGlyphWidthF = 32;
|
||||
fi.maxGlyphWidthI = 32;
|
||||
fi.minGlyphCenterXF = 16;
|
||||
fi.minGlyphCenterXI = 16;
|
||||
fi.shadowMapLength = 0;
|
||||
fi.fontStyle.fontAttributes=1;
|
||||
fi.fontStyle.fontCountry= 1;
|
||||
fi.fontStyle.fontExpire= 1;
|
||||
fi.fontStyle.fontFamily= 1;
|
||||
strcpy(fi.fontStyle.fontFileName, "asd");
|
||||
fi.fontStyle.fontH=32;
|
||||
fi.fontStyle.fontHRes=32;
|
||||
fi.fontStyle.fontLanguage=1;
|
||||
strcpy(fi.fontStyle.fontName, "ppsspp");
|
||||
fi.fontStyle.fontRegion=9;
|
||||
fi.fontStyle.fontV=32;
|
||||
fi.fontStyle.fontVRes=32;
|
||||
fi.fontStyle.fontWeight= 32;
|
||||
fi.charMapLength = ph->charmap_len;
|
||||
fi.shadowMapLength = ph->shadowmap_len;
|
||||
|
||||
fi.maxInfoI.width = ph->max_glyph_w<<6;
|
||||
fi.maxInfoI.height = ph->max_glyph_h<<6;
|
||||
fi.maxInfoI.ascender = ph->ascender;
|
||||
fi.maxInfoI.descender = ph->descender;
|
||||
fi.maxInfoI.h_bearingX = ph->max_h_bearingX;
|
||||
fi.maxInfoI.h_bearingY = ph->max_h_bearingY;
|
||||
fi.maxInfoI.v_bearingX = ph->min_v_bearingX;
|
||||
fi.maxInfoI.v_bearingY = ph->max_v_bearingY;
|
||||
fi.maxInfoI.h_advance = ph->max_h_advance;
|
||||
fi.maxInfoI.v_advance = ph->max_v_advance;
|
||||
|
||||
fi.maxInfoF.width = (float)(ph->max_glyph_w);
|
||||
fi.maxInfoF.height = (float)(ph->max_glyph_h);
|
||||
fi.maxInfoF.ascender = f26_float(ph->ascender);
|
||||
fi.maxInfoF.descender = f26_float(ph->descender);
|
||||
fi.maxInfoF.h_bearingX = f26_float(ph->max_h_bearingX);
|
||||
fi.maxInfoF.h_bearingY = f26_float(ph->max_h_bearingY);
|
||||
fi.maxInfoF.v_bearingX = f26_float(ph->min_v_bearingX);
|
||||
fi.maxInfoF.v_bearingY = f26_float(ph->max_v_bearingY);
|
||||
fi.maxInfoF.h_advance = f26_float(ph->max_h_advance);
|
||||
fi.maxInfoF.v_advance = f26_float(ph->max_v_advance);
|
||||
|
||||
fi.maxGlyphHeight = ph->max_glyph_h;
|
||||
fi.maxGlyphWidth = ph->max_glyph_w;
|
||||
|
||||
fi.fontStyle.fontAttributes = 1;
|
||||
fi.fontStyle.fontCountry = 1;
|
||||
fi.fontStyle.fontExpire = 1;
|
||||
fi.fontStyle.fontFamily = 1;
|
||||
fi.fontStyle.fontH = f26_float(ph->h_size);
|
||||
fi.fontStyle.fontHRes = f26_float(ph->h_res);
|
||||
fi.fontStyle.fontLanguage = 1;
|
||||
fi.fontStyle.fontRegion = 9;
|
||||
fi.fontStyle.fontV = f26_float(ph->v_size);
|
||||
fi.fontStyle.fontVRes = f26_float(ph->v_res);
|
||||
fi.fontStyle.fontWeight = 32;
|
||||
strcpy(fi.fontStyle.fontFileName, font_list[slot]);
|
||||
strcpy(fi.fontStyle.fontName, (const char*)ph->font_name);
|
||||
|
||||
Memory::WriteStruct(fontInfoPtr, &fi);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceFontGetFontInfoByIndexNumber(u32 libHandle, u32 fontInfoPtr, u32 unknown, u32 fontIndex)
|
||||
int sceFontGetFontInfoByIndexNumber(u32 libHandle, u32 fontInfoPtr, u32 fontIndex)
|
||||
{
|
||||
ERROR_LOG(HLE, "HACK sceFontGetFontInfoByIndexNumber %x, %x, %x, %x", libHandle, fontInfoPtr, unknown, fontIndex);
|
||||
ERROR_LOG(HLE, "HACK sceFontGetFontInfoByIndexNumber %x, %x, %x", libHandle, fontInfoPtr, fontIndex);
|
||||
// clearly wrong..
|
||||
return sceFontGetFontInfo(libHandle, fontInfoPtr);
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
int sceFontGetCharInfo(u32 fontHandle, u32 charCode, u32 charInfoPtr)
|
||||
{
|
||||
ERROR_LOG(HLE, "HACK sceFontGetCharInfo %x, %x, %x", fontHandle, charCode, charInfoPtr);
|
||||
if (Memory::IsValidAddress(charInfoPtr))
|
||||
{
|
||||
CharInfo pspCharInfo;
|
||||
memset(&pspCharInfo, 0, sizeof(pspCharInfo));
|
||||
pspCharInfo.bitmapWidth = 16;
|
||||
pspCharInfo.bitmapHeight = 16;
|
||||
PGF_FONT *pgft;
|
||||
PGF_HEADER *ph;
|
||||
PGF_GLYPH *gh;
|
||||
int slot;
|
||||
|
||||
DEBUG_LOG(HLE, "HACK sceFontGetCharInfo %x, %x, %x", fontHandle, charCode, charInfoPtr);
|
||||
|
||||
slot = fontHandle-1;
|
||||
pgft = font_slot[slot];
|
||||
if(pgft==NULL)
|
||||
return -1;
|
||||
|
||||
ph = (PGF_HEADER*)pgft->buf;
|
||||
gh = pgft->char_glyph[charCode];
|
||||
if(gh==NULL)
|
||||
return -2;
|
||||
|
||||
if (Memory::IsValidAddress(charInfoPtr)) {
|
||||
CharInfo pspCharInfo;
|
||||
memset(&pspCharInfo, 0, sizeof(pspCharInfo));
|
||||
|
||||
pspCharInfo.bitmapWidth = gh->width;
|
||||
pspCharInfo.bitmapHeight = gh->height;
|
||||
pspCharInfo.bitmapLeft = gh->left;
|
||||
pspCharInfo.bitmapTop = gh->top;
|
||||
|
||||
pspCharInfo.info.width = gh->dimension.h;
|
||||
pspCharInfo.info.height = gh->dimension.v;
|
||||
pspCharInfo.info.ascender = ph->ascender;
|
||||
pspCharInfo.info.descender = ph->descender;
|
||||
pspCharInfo.info.h_bearingX = gh->bearingX.h;
|
||||
pspCharInfo.info.h_bearingY = gh->bearingY.h;
|
||||
pspCharInfo.info.v_bearingX = gh->bearingX.v;
|
||||
pspCharInfo.info.v_bearingY = gh->bearingY.v;
|
||||
pspCharInfo.info.h_advance = gh->advance.h;
|
||||
pspCharInfo.info.v_advance = gh->advance.v;
|
||||
|
||||
pspCharInfo.spf26Width = pspCharInfo.bitmapWidth << 6;
|
||||
pspCharInfo.spf26Height = pspCharInfo.bitmapHeight << 6;
|
||||
pspCharInfo.spf26AdvanceH = pspCharInfo.bitmapWidth << 6;
|
||||
pspCharInfo.spf26AdvanceV = pspCharInfo.bitmapHeight << 6;
|
||||
Memory::WriteStruct(charInfoPtr, &pspCharInfo);
|
||||
}
|
||||
return 0;
|
||||
@ -610,36 +660,77 @@ int sceFontGetCharInfo(u32 fontHandle, u32 charCode, u32 charInfoPtr)
|
||||
|
||||
int sceFontGetCharImageRect(u32 fontHandle, u32 charCode, u32 charRectPtr)
|
||||
{
|
||||
ERROR_LOG(HLE, "HACK sceFontGetCharImageRect %x, %x (%c)", fontHandle, charRectPtr, charCode);
|
||||
PGF_FONT *pgft;
|
||||
PGF_GLYPH *gh;
|
||||
int slot;
|
||||
|
||||
DEBUG_LOG(HLE, "HACK sceFontGetCharImageRect %x, %x (%c)", fontHandle, charRectPtr, charCode);
|
||||
|
||||
slot = fontHandle-1;
|
||||
pgft = font_slot[slot];
|
||||
if(pgft==NULL)
|
||||
return -1;
|
||||
|
||||
gh = pgft->char_glyph[charCode];
|
||||
if(gh==NULL)
|
||||
return -2;
|
||||
|
||||
if (Memory::IsValidAddress(charRectPtr)) {
|
||||
Memory::Write_U16(16, charRectPtr); // character bitmap width in pixels
|
||||
Memory::Write_U16(16, charRectPtr + 2); // character bitmap height in pixels
|
||||
Memory::Write_U16(gh->width, charRectPtr); // character bitmap width in pixels
|
||||
Memory::Write_U16(gh->width, charRectPtr+2); // character bitmap height in pixels
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceFontGetCharGlyphImage(u32 fontHandle, u32 charCode, u32 glyphImagePtr)
|
||||
{
|
||||
ERROR_LOG(HLE, "HACK sceFontGetCharGlyphImage %x, %x, %x (%c)", fontHandle, charCode, glyphImagePtr, charCode);
|
||||
PGF_FONT *pgft;
|
||||
PGF_GLYPH *gh;
|
||||
int slot;
|
||||
u8 line_buf[512];
|
||||
|
||||
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);
|
||||
DEBUG_LOG(HLE, "HACK sceFontGetCharGlyphImage %x, %x, %x (%c)", fontHandle, charCode, glyphImagePtr, charCode);
|
||||
|
||||
slot = fontHandle-1;
|
||||
pgft = font_slot[slot];
|
||||
if(pgft==NULL)
|
||||
return -1;
|
||||
|
||||
gh = pgft->char_glyph[charCode];
|
||||
if(gh==NULL)
|
||||
return -2;
|
||||
|
||||
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);
|
||||
int buffer = Memory::Read_U32(glyphImagePtr+20);
|
||||
|
||||
// Small chessboard. Does not respect pixelformat currently...
|
||||
xPos64 = (xPos64+32)>>6;
|
||||
yPos64 = (yPos64+32)>>6;
|
||||
|
||||
// Actually should be really easy to substitute in a proper font here...
|
||||
// could even grab pixel data from the PPGe one.
|
||||
for (int y = 0; y < bufHeight; y++)
|
||||
{
|
||||
for (int x = 0; x < bytesPerLine; x++)
|
||||
{
|
||||
Memory::Write_U8((((x >> 1) ^ (y >> 1)) & 1) ? 0xff : 0x00, buffer + (y * bytesPerLine + x));
|
||||
int line = buffer + yPos64*bytesPerLine;
|
||||
u8 *src = gh->bmp;
|
||||
|
||||
for (int y=0; y<gh->height; y++) {
|
||||
Memory::Memcpy(line_buf, line, bytesPerLine);
|
||||
int xp = xPos64;
|
||||
for (int x=0; x<gh->width; x++) {
|
||||
if(xp&1){
|
||||
line_buf[xp/2] &= 0x0f;
|
||||
line_buf[xp/2] |= (*src)<<4;
|
||||
}else{
|
||||
line_buf[xp/2] &= 0xf0;
|
||||
line_buf[xp/2] |= (*src);
|
||||
}
|
||||
xp += 1;
|
||||
src += 1;
|
||||
}
|
||||
Memory::Memcpy(line, line_buf, bytesPerLine);
|
||||
line += bytesPerLine;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -647,14 +738,13 @@ int sceFontGetCharGlyphImage(u32 fontHandle, u32 charCode, u32 glyphImagePtr)
|
||||
|
||||
int sceFontGetCharGlyphImage_Clip(u32 libHandler, u32 charCode, u32 glyphImagePtr, int clipXPos, int clipYPos, int clipWidth, int clipHeight)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceFontGetCharGlyphImage_Clip %x, %x, %x (%c)", libHandler, charCode, glyphImagePtr, charCode);
|
||||
//sceFontGetCharGlyphImage(libHandler, charCode, glyphImagePtr);
|
||||
return 0;
|
||||
DEBUG_LOG(HLE, "sceFontGetCharGlyphImage_Clip %x, %x, %x (%c)", libHandler, charCode, glyphImagePtr, charCode);
|
||||
return sceFontGetCharGlyphImage(libHandler, charCode, glyphImagePtr);
|
||||
}
|
||||
|
||||
int sceFontSetAltCharacterCode(u32 libHandle, u32 charCode)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceFontSetAltCharacterCode %x (%c)", libHandle, charCode);
|
||||
DEBUG_LOG(HLE, "sceFontSetAltCharacterCode %x (%c)", libHandle, charCode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -666,7 +756,7 @@ int sceFontFlush(u32 fontHandle)
|
||||
|
||||
int sceFontGetFontList(u32 fontLibHandle, u32 fontStylePtr, u32 numFonts)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceFontGetFontList %x, %x, %x", fontLibHandle, fontStylePtr, numFonts);
|
||||
DEBUG_LOG(HLE, "sceFontGetFontList %x, %x, %x", fontLibHandle, fontStylePtr, numFonts);
|
||||
|
||||
FontStyle style;
|
||||
memset(&style, 0, sizeof (style));
|
||||
@ -687,12 +777,12 @@ int sceFontGetFontList(u32 fontLibHandle, u32 fontStylePtr, u32 numFonts)
|
||||
|
||||
int sceFontGetNumFontList(u32 libHandle, u32 errorCodePtr)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceFontGetNumFontList %x, %x", libHandle, errorCodePtr);
|
||||
DEBUG_LOG(HLE, "UNIMPL sceFontGetNumFontList %x, %x", libHandle, errorCodePtr);
|
||||
if (Memory::IsValidAddress(errorCodePtr))
|
||||
{
|
||||
Memory::Write_U32(0, errorCodePtr);
|
||||
}
|
||||
return 1;
|
||||
return font_num;
|
||||
}
|
||||
|
||||
int sceFontSetResolution(u32 fontLibHandle, float hRes, float vRes)
|
||||
@ -718,7 +808,7 @@ const HLEFunction sceLibFont[] =
|
||||
{0x099ef33c, WrapI_UUU<sceFontFindOptimumFont>, "sceFontFindOptimumFont"},
|
||||
{0x681e61a7, WrapI_UUU<sceFontFindFont>, "sceFontFindFont"},
|
||||
{0x2f67356a, WrapI_V<sceFontCalcMemorySize>, "sceFontCalcMemorySize"},
|
||||
{0x5333322d, WrapI_UUUU<sceFontGetFontInfoByIndexNumber>, "sceFontGetFontInfoByIndexNumber"},
|
||||
{0x5333322d, WrapI_UUU<sceFontGetFontInfoByIndexNumber>, "sceFontGetFontInfoByIndexNumber"},
|
||||
{0xa834319d, WrapU_UUUU<sceFontOpen>, "sceFontOpen"},
|
||||
{0x57fcb733, WrapU_UUUU<sceFontOpenUserFile>, "sceFontOpenUserFile"},
|
||||
{0xbb8e7fe6, WrapU_UUUU<sceFontOpenUserMemory>, "sceFontOpenUserMemory"},
|
||||
|
@ -7,10 +7,137 @@ void Register_sceFont();
|
||||
void __FontInit();
|
||||
void __FontDoState(PointerWrap &p);
|
||||
|
||||
typedef u32 FontLibraryHandle;
|
||||
typedef u32 FontHandle;
|
||||
|
||||
struct FontNewLibParams {
|
||||
u32 userDataAddr;
|
||||
u32 numFonts;
|
||||
u32 cacheDataAddr;
|
||||
|
||||
// Driver callbacks.
|
||||
u32 allocFuncAddr;
|
||||
u32 freeFuncAddr;
|
||||
u32 openFuncAddr;
|
||||
u32 closeFuncAddr;
|
||||
u32 readFuncAddr;
|
||||
u32 seekFuncAddr;
|
||||
u32 errorFuncAddr;
|
||||
u32 ioFinishFuncAddr;
|
||||
};
|
||||
|
||||
typedef enum Family {
|
||||
FONT_FAMILY_SANS_SERIF = 1,
|
||||
FONT_FAMILY_SERIF = 2,
|
||||
};
|
||||
|
||||
typedef enum Style {
|
||||
FONT_STYLE_REGULAR = 1,
|
||||
FONT_STYLE_ITALIC = 2,
|
||||
FONT_STYLE_BOLD = 5,
|
||||
FONT_STYLE_BOLD_ITALIC = 6,
|
||||
FONT_STYLE_DB = 103, // Demi-Bold / semi-bold
|
||||
};
|
||||
|
||||
typedef enum Language {
|
||||
FONT_LANGUAGE_JAPANESE = 1,
|
||||
FONT_LANGUAGE_LATIN = 2,
|
||||
FONT_LANGUAGE_KOREAN = 3,
|
||||
};
|
||||
|
||||
struct FontStyle {
|
||||
float fontH;
|
||||
float fontV;
|
||||
float fontHRes;
|
||||
float fontVRes;
|
||||
float fontWeight;
|
||||
u16 fontFamily;
|
||||
u16 fontStyle;
|
||||
// Check.
|
||||
u16 fontStyleSub;
|
||||
u16 fontLanguage;
|
||||
u16 fontRegion;
|
||||
u16 fontCountry;
|
||||
char fontName[64];
|
||||
char fontFileName[64];
|
||||
u32 fontAttributes;
|
||||
u32 fontExpire;
|
||||
};
|
||||
|
||||
struct iMerticsInfo{
|
||||
// Glyph metrics (in 26.6 signed fixed-point).
|
||||
u32 width;
|
||||
u32 height;
|
||||
u32 ascender;
|
||||
u32 descender;
|
||||
u32 h_bearingX;
|
||||
u32 h_bearingY;
|
||||
u32 v_bearingX;
|
||||
u32 v_bearingY;
|
||||
u32 h_advance;
|
||||
u32 v_advance;
|
||||
};
|
||||
|
||||
struct fMerticsInfo{
|
||||
// Glyph metrics (in 26.6 signed fixed-point).
|
||||
float width;
|
||||
float height;
|
||||
float ascender;
|
||||
float descender;
|
||||
float h_bearingX;
|
||||
float h_bearingY;
|
||||
float v_bearingX;
|
||||
float v_bearingY;
|
||||
float h_advance;
|
||||
float v_advance;
|
||||
};
|
||||
|
||||
struct FontInfo {
|
||||
struct iMerticsInfo maxInfoI;
|
||||
struct fMerticsInfo maxInfoF;
|
||||
|
||||
// Bitmap dimensions.
|
||||
short maxGlyphWidth;
|
||||
short maxGlyphHeight;
|
||||
u32 charMapLength; // Number of elements in the font's charmap.
|
||||
u32 shadowMapLength; // Number of elements in the font's shadow charmap.
|
||||
|
||||
// Font style (used by font comparison functions).
|
||||
FontStyle fontStyle;
|
||||
|
||||
u8 BPP; // Font's BPP.
|
||||
u8 pad[3];
|
||||
};
|
||||
|
||||
struct CharInfo {
|
||||
u32 bitmapWidth;
|
||||
u32 bitmapHeight;
|
||||
u32 bitmapLeft;
|
||||
u32 bitmapTop;
|
||||
// Glyph metrics (in 26.6 signed fixed-point).
|
||||
struct iMerticsInfo info;
|
||||
u8 pad[4];
|
||||
};
|
||||
|
||||
enum FontPixelFormat {
|
||||
PSP_FONT_PIXELFORMAT_4 = 0,
|
||||
PSP_FONT_PIXELFORMAT_4_REV = 1,
|
||||
PSP_FONT_PIXELFORMAT_8 = 2,
|
||||
PSP_FONT_PIXELFORMAT_24 = 3,
|
||||
PSP_FONT_PIXELFORMAT_32 = 4
|
||||
};
|
||||
|
||||
struct GlyphImage {
|
||||
FontPixelFormat pixelFormat;
|
||||
s32 xPos64;
|
||||
s32 yPos64;
|
||||
u16 bufWidth;
|
||||
u16 bufHeight;
|
||||
u16 bytesPerLine;
|
||||
u16 pad;
|
||||
u32 bufferPtr;
|
||||
};
|
||||
|
||||
typedef unsigned int u32;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned char u8;
|
||||
|
||||
typedef struct f26_pairs {
|
||||
int h;
|
||||
|
Loading…
x
Reference in New Issue
Block a user