diff --git a/src/core/libraries/font/font.cpp b/src/core/libraries/font/font.cpp index bbc2366e3..ef4ea7a12 100644 --- a/src/core/libraries/font/font.cpp +++ b/src/core/libraries/font/font.cpp @@ -75,14 +75,36 @@ u32 PS4_SYSV_ABI sceFontCharacterLooksWhiteSpace(OrbisFontTextCharacter* textCha return (textCharacter->charType == 0x0E) ? textCharacter->characterCode : 0; } -s32 PS4_SYSV_ABI sceFontCharacterRefersTextBack() { - LOG_ERROR(Lib_Font, "(STUBBED) called"); - return ORBIS_OK; +OrbisFontTextCharacter* PS4_SYSV_ABI +sceFontCharacterRefersTextBack(OrbisFontTextCharacter* textCharacter) { + if (!textCharacter) + return NULL; // Check if input is NULL + + OrbisFontTextCharacter* current = textCharacter->prev; // Move backward instead of forward + while (current) { + if (current->unkn_0x31 == 0 && current->unkn_0x33 == 0) { + return current; // Return the first matching node + } + current = current->prev; // Move to the previous node + } + + return NULL; // No valid node found } -s32 PS4_SYSV_ABI sceFontCharacterRefersTextNext() { - LOG_ERROR(Lib_Font, "(STUBBED) called"); - return ORBIS_OK; +OrbisFontTextCharacter* PS4_SYSV_ABI +sceFontCharacterRefersTextNext(OrbisFontTextCharacter* textCharacter) { + if (!textCharacter) + return NULL; // Null check + + OrbisFontTextCharacter* current = textCharacter->next; + while (current) { + if (current->unkn_0x31 == 0 && current->unkn_0x33 == 0) { + return current; // Found a match + } + current = current->next; // Move to the next node + } + + return NULL; // No matching node found } s32 PS4_SYSV_ABI sceFontCharactersRefersTextCodes() { @@ -725,14 +747,71 @@ s32 PS4_SYSV_ABI sceFontRendererSetOutlineBufferPolicy() { return ORBIS_OK; } -s32 PS4_SYSV_ABI sceFontRenderSurfaceInit() { - LOG_ERROR(Lib_Font, "(STUBBED) called"); - return ORBIS_OK; +void PS4_SYSV_ABI sceFontRenderSurfaceInit(OrbisFontRenderSurface* renderSurface, void* buffer, + int bufWidthByte, int pixelSizeByte, int widthPixel, + int heightPixel) { + if (renderSurface) { // Ensure surface is not NULL before modifying it + renderSurface->buffer = buffer; + renderSurface->widthByte = bufWidthByte; + renderSurface->pixelSizeByte = pixelSizeByte; + + // Initialize unknown fields (likely reserved or flags) + renderSurface->unkn_0xd = 0; + renderSurface->unkn_0xe = 0; + renderSurface->unkn_0xf = 0; + + // Ensure width and height are non-negative + renderSurface->width = (widthPixel < 0) ? 0 : widthPixel; + renderSurface->height = (heightPixel < 0) ? 0 : heightPixel; + + // Set the clipping/scaling rectangle + renderSurface->sc_x0 = 0; + renderSurface->sc_y0 = 0; + renderSurface->sc_x1 = renderSurface->width; + renderSurface->sc_y1 = renderSurface->height; + } } -s32 PS4_SYSV_ABI sceFontRenderSurfaceSetScissor() { - LOG_ERROR(Lib_Font, "(STUBBED) called"); - return ORBIS_OK; +void PS4_SYSV_ABI sceFontRenderSurfaceSetScissor(OrbisFontRenderSurface* renderSurface, int x0, + int y0, int w, int h) { + if (!renderSurface) + return; // Null check + + // Handle horizontal clipping + int surfaceWidth = renderSurface->width; + int clip_x0, clip_x1; + + if (surfaceWidth != 0) { + if (x0 < 0) { // Adjust for negative x0 + clip_x0 = 0; + clip_x1 = (w + x0 > surfaceWidth) ? surfaceWidth : w + x0; + if (w <= -x0) + clip_x1 = 0; // Entire width is clipped + } else { + clip_x0 = (x0 > surfaceWidth) ? surfaceWidth : x0; + clip_x1 = (w + x0 > surfaceWidth) ? surfaceWidth : w + x0; + } + renderSurface->sc_x0 = clip_x0; + renderSurface->sc_x1 = clip_x1; + } + + // Handle vertical clipping + int surfaceHeight = renderSurface->height; + int clip_y0, clip_y1; + + if (surfaceHeight != 0) { + if (y0 < 0) { // Adjust for negative y0 + clip_y0 = 0; + clip_y1 = (h + y0 > surfaceHeight) ? surfaceHeight : h + y0; + if (h <= -y0) + clip_y1 = 0; // Entire height is clipped + } else { + clip_y0 = (y0 > surfaceHeight) ? surfaceHeight : y0; + clip_y1 = (h + y0 > surfaceHeight) ? surfaceHeight : h + y0; + } + renderSurface->sc_y0 = clip_y0; + renderSurface->sc_y1 = clip_y1; + } } s32 PS4_SYSV_ABI sceFontRenderSurfaceSetStyleFrame() { @@ -1501,8 +1580,6 @@ void RegisterlibSceFont(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("6slrIYa3HhQ", "libSceFont", 1, "libSceFont", 1, 1, Func_EAC96B2186B71E14); LIB_FUNCTION("-keIqW70YlY", "libSceFont", 1, "libSceFont", 1, 1, Func_FE4788A96EF46256); LIB_FUNCTION("-n5a6V0wWPU", "libSceFont", 1, "libSceFont", 1, 1, Func_FE7E5AE95D3058F5); - LIB_FUNCTION("BaOKcng8g88", "libkernel", 1, "libSceFont", 1, 1, module_start); - LIB_FUNCTION("KpDMrPHvt3Q", "libkernel", 1, "libSceFont", 1, 1, module_stop); }; } // namespace Libraries::Font \ No newline at end of file diff --git a/src/core/libraries/font/font.h b/src/core/libraries/font/font.h index d770251e4..c3bae6c51 100644 --- a/src/core/libraries/font/font.h +++ b/src/core/libraries/font/font.h @@ -13,11 +13,30 @@ namespace Libraries::Font { struct OrbisFontTextCharacter { // Other fields... - void* textOrder; // Field at offset 0x10 (pointer to text order info) - u32 characterCode; // Field assumed at offset 0x28 - u8 charType; // Field assumed at offset 0x39 - u8 bidiLevel; // Field assumed at offset 0x3B stores the Bidi level - u8 formatFlags; // Field at offset 0x3D (stores format-related flags) + struct OrbisFontTextCharacter* next; // Pointer to the next node 0x00 + struct OrbisFontTextCharacter* prev; // Pointer to the next node 0x08 + void* textOrder; // Field at offset 0x10 (pointer to text order info) + u32 characterCode; // Field assumed at offset 0x28 + u8 unkn_0x31; // Offset 0x31 + u8 unkn_0x33; // Offset 0x33 + u8 charType; // Field assumed at offset 0x39 + u8 bidiLevel; // Field assumed at offset 0x3B stores the Bidi level + u8 formatFlags; // Field at offset 0x3D (stores format-related flags) +}; + +struct OrbisFontRenderSurface { + void* buffer; + s32 widthByte; + s8 pixelSizeByte; + u8 unkn_0xd; + u8 unkn_0xe; + u8 unkn_0xf; + s32 width, height; + u32 sc_x0; + u32 sc_y0; + u32 sc_x1; + u32 sc_y1; + u32 unkn_28[22]; }; s32 PS4_SYSV_ABI sceFontAttachDeviceCacheBuffer(); @@ -30,8 +49,10 @@ s32 PS4_SYSV_ABI sceFontCharacterGetTextOrder(OrbisFontTextCharacter* textCharac void** pTextOrder); u32 PS4_SYSV_ABI sceFontCharacterLooksFormatCharacters(OrbisFontTextCharacter* textCharacter); u32 PS4_SYSV_ABI sceFontCharacterLooksWhiteSpace(OrbisFontTextCharacter* textCharacter); -s32 PS4_SYSV_ABI sceFontCharacterRefersTextBack(); -s32 PS4_SYSV_ABI sceFontCharacterRefersTextNext(); +OrbisFontTextCharacter* PS4_SYSV_ABI +sceFontCharacterRefersTextBack(OrbisFontTextCharacter* textCharacter); +OrbisFontTextCharacter* PS4_SYSV_ABI +sceFontCharacterRefersTextNext(OrbisFontTextCharacter* textCharacter); s32 PS4_SYSV_ABI sceFontCharactersRefersTextCodes(); s32 PS4_SYSV_ABI sceFontClearDeviceCache(); s32 PS4_SYSV_ABI sceFontCloseFont(); @@ -160,8 +181,11 @@ s32 PS4_SYSV_ABI sceFontRenderCharGlyphImageVertical(); s32 PS4_SYSV_ABI sceFontRendererGetOutlineBufferSize(); s32 PS4_SYSV_ABI sceFontRendererResetOutlineBuffer(); s32 PS4_SYSV_ABI sceFontRendererSetOutlineBufferPolicy(); -s32 PS4_SYSV_ABI sceFontRenderSurfaceInit(); -s32 PS4_SYSV_ABI sceFontRenderSurfaceSetScissor(); +void PS4_SYSV_ABI sceFontRenderSurfaceInit(OrbisFontRenderSurface* renderSurface, void* buffer, + int bufWidthByte, int pixelSizeByte, int widthPixel, + int heightPixel); +void PS4_SYSV_ABI sceFontRenderSurfaceSetScissor(OrbisFontRenderSurface* renderSurface, int x0, + int y0, int w, int h); s32 PS4_SYSV_ABI sceFontRenderSurfaceSetStyleFrame(); s32 PS4_SYSV_ABI sceFontSetEffectSlant(); s32 PS4_SYSV_ABI sceFontSetEffectWeight(); @@ -251,8 +275,6 @@ s32 PS4_SYSV_ABI Func_E48D3CD01C342A33(); s32 PS4_SYSV_ABI Func_EAC96B2186B71E14(); s32 PS4_SYSV_ABI Func_FE4788A96EF46256(); s32 PS4_SYSV_ABI Func_FE7E5AE95D3058F5(); -s32 PS4_SYSV_ABI module_start(); -s32 PS4_SYSV_ABI module_stop(); void RegisterlibSceFont(Core::Loader::SymbolsResolver* sym); } // namespace Libraries::Font \ No newline at end of file diff --git a/src/core/libraries/font/fontft.cpp b/src/core/libraries/font/fontft.cpp index 0b67907de..4a7a13318 100644 --- a/src/core/libraries/font/fontft.cpp +++ b/src/core/libraries/font/fontft.cpp @@ -150,8 +150,6 @@ void RegisterlibSceFontFt(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("ojW+VKl4Ehs", "libSceFontFt", 1, "libSceFontFt", 1, 1, sceFontSelectGlyphsFt); LIB_FUNCTION("oM+XCzVG3oM", "libSceFontFt", 1, "libSceFontFt", 1, 1, sceFontSelectLibraryFt); LIB_FUNCTION("Xx974EW-QFY", "libSceFontFt", 1, "libSceFontFt", 1, 1, sceFontSelectRendererFt); - LIB_FUNCTION("BaOKcng8g88", "libkernel", 1, "libSceFontFt", 1, 1, module_start); - LIB_FUNCTION("KpDMrPHvt3Q", "libkernel", 1, "libSceFontFt", 1, 1, module_stop); }; } // namespace Libraries::FontFt \ No newline at end of file diff --git a/src/core/libraries/font/fontft.h b/src/core/libraries/font/fontft.h index 1e7842e35..cec6d7872 100644 --- a/src/core/libraries/font/fontft.h +++ b/src/core/libraries/font/fontft.h @@ -32,8 +32,6 @@ s32 PS4_SYSV_ABI sceFontFtTermAliases(); s32 PS4_SYSV_ABI sceFontSelectGlyphsFt(); s32 PS4_SYSV_ABI sceFontSelectLibraryFt(); s32 PS4_SYSV_ABI sceFontSelectRendererFt(); -s32 PS4_SYSV_ABI module_start(); -s32 PS4_SYSV_ABI module_stop(); void RegisterlibSceFontFt(Core::Loader::SymbolsResolver* sym); } // namespace Libraries::FontFt \ No newline at end of file