Cleanup sceRtc, move sceFont to its own file.

This commit is contained in:
Henrik Rydgard 2012-11-22 22:29:51 +01:00
parent 772b599041
commit 08f8f4b323
14 changed files with 206 additions and 139 deletions

View File

@ -586,6 +586,8 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/HLE/sceDmac.h
Core/HLE/sceGe.cpp
Core/HLE/sceGe.h
Core/HLE/sceFont.cpp
Core/HLE/sceFont.h
Core/HLE/sceHprm.cpp
Core/HLE/sceHprm.h
Core/HLE/sceHttp.cpp

View File

@ -23,6 +23,7 @@ set(SRCS
HLE/sceDisplay.cpp
HLE/sceDmac.cpp
HLE/sceGe.cpp
HLE/sceFont.cpp
HLE/sceHprm.cpp
HLE/sceHttp.cpp
HLE/sceImpose.cpp

View File

@ -132,6 +132,7 @@
<ClCompile Include="HLE\sceCtrl.cpp" />
<ClCompile Include="HLE\sceDisplay.cpp" />
<ClCompile Include="HLE\sceDmac.cpp" />
<ClCompile Include="HLE\sceFont.cpp" />
<ClCompile Include="HLE\sceGe.cpp" />
<ClCompile Include="HLE\sceHprm.cpp" />
<ClCompile Include="HLE\sceHttp.cpp" />
@ -264,6 +265,7 @@
<ClInclude Include="HLE\sceCtrl.h" />
<ClInclude Include="HLE\sceDisplay.h" />
<ClInclude Include="HLE\sceDmac.h" />
<ClInclude Include="HLE\sceFont.h" />
<ClInclude Include="HLE\sceGe.h" />
<ClInclude Include="HLE\sceHprm.h" />
<ClInclude Include="HLE\sceHttp.h" />

View File

@ -297,6 +297,9 @@
<ClCompile Include="Util\ppge_atlas.cpp">
<Filter>Util</Filter>
</ClCompile>
<ClCompile Include="HLE\sceFont.cpp">
<Filter>HLE\Libraries</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ELF\ElfReader.h">
@ -542,6 +545,9 @@
<ClInclude Include="Util\ppge_atlas.h">
<Filter>Util</Filter>
</ClInclude>
<ClInclude Include="HLE\sceFont.h">
<Filter>HLE\Libraries</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />

View File

@ -58,7 +58,7 @@ inline int usToCycles(int us) {
return (int)(CPU_HZ / 1000000 * us);
}
inline int cyclesToUs(int cycles) {
inline u64 cyclesToUs(u64 cycles) {
return cycles / (CPU_HZ / 1000000);
}

View File

@ -29,6 +29,12 @@ template<u32 func()> void WrapU_V() {
RETURN(func());
}
template<u64 func()> void WrapU64_V() {
u64 retval = func();
currentMIPS->r[2] = retval & 0xFFFFFFFF;
currentMIPS->r[3] = (retval >> 32) & 0xFFFFFFFF;
}
template<float func()> void WrapF_V() {
RETURNF(func());
}

View File

@ -26,6 +26,7 @@
#include "sceIo.h"
#include "sceHprm.h"
#include "scePower.h"
#include "sceFont.h"
#include "sceNet.h"
#include "sceMpeg.h"
#include "sceImpose.h"
@ -35,6 +36,7 @@
#include "sceSas.h"
#include "sceUmd.h"
#include "sceDmac.h"
#include "sceRtc.h"
#include "sceKernel.h"
#include "sceKernelEventFlag.h"
#include "sceKernelMemory.h"
@ -94,46 +96,6 @@ const HLEFunction UtilsForUser[] =
};
const HLEFunction sceRtc[] =
{
{0xC41C2853, sceRtcGetTickResolution, "sceRtcGetTickResolution"},
{0x3f7ad767, sceRtcGetCurrentTick, "sceRtcGetCurrentTick"},
{0x011F03C1, sceRtcGetCurrentTick, "sceRtcGetAccumulativeTime"},
{0x029CA3B3, sceRtcGetCurrentTick, "sceRtcGetAccumlativeTime"},
{0x4cfa57b0, 0, "sceRtcGetCurrentClock"},
{0xE7C27D1B, sceRtcGetCurrentClockLocalTime, "sceRtcGetCurrentClockLocalTime"},
{0x34885E0D, 0, "sceRtcConvertUtcToLocalTime"},
{0x779242A2, 0, "sceRtcConvertLocalTimeToUTC"},
{0x42307A17, 0, "sceRtcIsLeapYear"},
{0x05ef322c, &WrapU_UU<sceRtcGetDaysInMonth>, "sceRtcGetDaysInMonth"},
{0x57726bc1, &WrapU_UUU<sceRtcGetDayOfWeek>, "sceRtcGetDayOfWeek"},
{0x4B1B5E82, 0, "sceRtcCheckValid"},
{0x3a807cc8, 0, "sceRtcSetTime_t"},
{0x27c4594c, 0, "sceRtcGetTime_t"},
{0xF006F264, 0, "sceRtcSetDosTime"},
{0x36075567, 0, "sceRtcGetDosTime"},
{0x7ACE4C04, 0, "sceRtcSetWin32FileTime"},
{0xCF561893, 0, "sceRtcGetWin32FileTime"},
{0x7ED29E40, 0, "sceRtcSetTick"},
{0x6FF40ACC, sceRtcGetTick, "sceRtcGetTick"},
{0x9ED0AE87, 0, "sceRtcCompareTick"},
{0x44F45E05, 0, "sceRtcTickAddTicks"},
{0x26D25A5D, 0, "sceRtcTickAddMicroseconds"},
{0xF2A4AFE5, 0, "sceRtcTickAddSeconds"},
{0xE6605BCA, 0, "sceRtcTickAddMinutes"},
{0x26D7A24A, 0, "sceRtcTickAddHours"},
{0xE51B4B7A, 0, "sceRtcTickAddDays"},
{0xCF3A2CA8, 0, "sceRtcTickAddWeeks"},
{0xDBF74F1B, 0, "sceRtcTickAddMonths"},
{0x42842C77, 0, "sceRtcTickAddYears"},
{0xC663B3B9, 0, "sceRtcFormatRFC2822"},
{0x7DE6711B, 0, "sceRtcFormatRFC2822LocalTime"},
{0x0498FB3C, 0, "sceRtcFormatRFC3339"},
{0x27F98543, 0, "sceRtcFormatRFC3339LocalTime"},
{0xDFBC5F16, 0, "sceRtcParseDateTime"},
{0x28E1E988, 0, "sceRtcParseRFC3339"},
};
const HLEFunction IoFileMgrForKernel[] =
{
{0xa905b705, 0, "sceIoCloseAll"},
@ -231,39 +193,6 @@ const HLEFunction sceUsb[] =
};
const HLEFunction sceLibFont[] =
{
{0x67f17ed7, 0, "sceFontNewLib"},
{0x574b6fbc, 0, "sceFontDoneLib"},
{0x48293280, 0, "sceFontSetResolution"},
{0x27f6e642, 0, "sceFontGetNumFontList"},
{0xbc75d85b, 0, "sceFontGetFontList"},
{0x099ef33c, 0, "sceFontFindOptimumFont"},
{0x681e61a7, 0, "sceFontFindFont"},
{0x2f67356a, 0, "sceFontCalcMemorySize"},
{0x5333322d, 0, "sceFontGetFontInfoByIndexNumber"},
{0xa834319d, 0, "sceFontOpen"},
{0x57fcb733, 0, "sceFontOpenUserFile"},
{0xbb8e7fe6, 0, "sceFontOpenUserMemory"},
{0x3aea8cb6, 0, "sceFontClose"},
{0x0da7535e, 0, "sceFontGetFontInfo"},
{0xdcc80c2f, 0, "sceFontGetCharInfo"},
{0x5c3e4a9e, 0, "sceFontGetCharImageRect"},
{0x980f4895, 0, "sceFontGetCharGlyphImage"},
{0xca1e6945, 0, "sceFontGetCharGlyphImage_Clip"},
{0x74b21701, 0, "sceFontPixelToPointH"},
{0xf8f0752e, 0, "sceFontPixelToPointV"},
{0x472694cd, 0, "sceFontPointToPixelH"},
{0x3c4b7e82, 0, "sceFontPointToPixelV"},
{0xee232411, 0, "sceFontSetAltCharacterCode"},
{0xaa3de7b5, 0, "sceFontGetShadowInfo"},
{0x48b06520, 0, "sceFontGetShadowImageRect"},
{0x568be516, 0, "sceFontGetShadowGlyphImage"},
{0x5dcf6858, 0, "sceFontGetShadowGlyphImage_Clip"},
{0x02d7f94b, 0, "sceFontFlush"},
};
const HLEFunction sceUsbstor[] =
{
{0x60066CFE, 0, "sceUsbstorGetStatus"},
@ -293,7 +222,6 @@ const HLEModule moduleList[] =
{"UtilsForUser",SZ(UtilsForUser),UtilsForUser},
{"KDebugForKernel",SZ(KDebugForKernel),KDebugForKernel},
{"sceParseUri"},
{"sceRtc",SZ(sceRtc),sceRtc},
{"sceSAScore"},
{"sceUsbstor",SZ(sceUsbstor),sceUsbstor},
{"sceUsbstorBoot",SZ(sceUsbstorBoot),sceUsbstorBoot},
@ -301,13 +229,11 @@ const HLEModule moduleList[] =
{"SceBase64_Library"},
{"sceCert_Loader"},
{"SceFont_Library"},
{"sceLibFont",SZ(sceLibFont),sceLibFont},
{"sceNetApctl"},
{"sceOpenPSID"},
{"sceParseHttp"},
{"sceSsl"},
{"sceSIRCS_IrDA_Driver"},
{"sceRtc"},
{"Pspnet_Scan"},
{"Pspnet_Show_MacAddr"},
{"pspeDebug", SZ(pspeDebug), pspeDebug},
@ -333,7 +259,9 @@ void RegisterAllModules() {
Register_sceDisplay();
Register_sceAudio();
Register_sceSasCore();
Register_sceNet();
Register_sceFont();
Register_sceNet();
Register_sceRtc();
Register_sceWlanDrv();
Register_sceMpeg();
Register_sceMp3();

48
Core/HLE/sceFont.cpp Normal file
View File

@ -0,0 +1,48 @@
#include "sceFont.h"
#include "base/timeutil.h"
#include "HLE.h"
#include "../MIPS/MIPS.h"
#include "sceFont.h"
const HLEFunction sceLibFont[] =
{
{0x67f17ed7, 0, "sceFontNewLib"},
{0x574b6fbc, 0, "sceFontDoneLib"},
{0x48293280, 0, "sceFontSetResolution"},
{0x27f6e642, 0, "sceFontGetNumFontList"},
{0xbc75d85b, 0, "sceFontGetFontList"},
{0x099ef33c, 0, "sceFontFindOptimumFont"},
{0x681e61a7, 0, "sceFontFindFont"},
{0x2f67356a, 0, "sceFontCalcMemorySize"},
{0x5333322d, 0, "sceFontGetFontInfoByIndexNumber"},
{0xa834319d, 0, "sceFontOpen"},
{0x57fcb733, 0, "sceFontOpenUserFile"},
{0xbb8e7fe6, 0, "sceFontOpenUserMemory"},
{0x3aea8cb6, 0, "sceFontClose"},
{0x0da7535e, 0, "sceFontGetFontInfo"},
{0xdcc80c2f, 0, "sceFontGetCharInfo"},
{0x5c3e4a9e, 0, "sceFontGetCharImageRect"},
{0x980f4895, 0, "sceFontGetCharGlyphImage"},
{0xca1e6945, 0, "sceFontGetCharGlyphImage_Clip"},
{0x74b21701, 0, "sceFontPixelToPointH"},
{0xf8f0752e, 0, "sceFontPixelToPointV"},
{0x472694cd, 0, "sceFontPointToPixelH"},
{0x3c4b7e82, 0, "sceFontPointToPixelV"},
{0xee232411, 0, "sceFontSetAltCharacterCode"},
{0xaa3de7b5, 0, "sceFontGetShadowInfo"},
{0x48b06520, 0, "sceFontGetShadowImageRect"},
{0x568be516, 0, "sceFontGetShadowGlyphImage"},
{0x5dcf6858, 0, "sceFontGetShadowGlyphImage_Clip"},
{0x02d7f94b, 0, "sceFontFlush"},
};
void Register_sceFont()
{
RegisterModule("sceLibFont", ARRAY_SIZE(sceLibFont), sceLibFont);
}

3
Core/HLE/sceFont.h Normal file
View File

@ -0,0 +1,3 @@
#pragma once
void Register_sceFont();

View File

@ -145,55 +145,3 @@ void sceKernelLibcGettimeofday()
#endif
RETURN(0);
}
void sceRtcGetCurrentClockLocalTime()
{
DEBUG_LOG(HLE,"0=sceRtcGetCurrentClockLocalTime()");
RETURN(0);
}
void sceRtcGetTick()
{
DEBUG_LOG(HLE,"0=sceRtcGetTick()");
RETURN(0);
}
u32 sceRtcGetDayOfWeek(u32 year, u32 month, u32 day)
{
static u32 t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
year -= month < 3;
return ( year + year/4 - year/100 + year/400 + t[month-1] + day) % 7;
}
u32 sceRtcGetDaysInMonth(u32 year, u32 month)
{
DEBUG_LOG(HLE,"0=sceRtcGetDaysInMonth()");
u32 numberOfDays;
switch (month)
{
case 4:
case 6:
case 9:
case 11:
numberOfDays = 30;
break;
case 2:
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
numberOfDays = 29;
else
numberOfDays = 28;
break;
default:
numberOfDays = 31;
break;
}
return numberOfDays;
}
void sceRtcGetTickResolution()
{
DEBUG_LOG(HLE,"100=sceRtcGetTickResolution()");
RETURN(100);
}

View File

@ -27,8 +27,6 @@ void sceKernelSysClock2USec();
void sceKernelSysClock2USecWide();
u32 sceKernelUSec2SysClockWide(u32 usec);
u32 sceKernelLibcClock();
void sceRtcGetCurrentClockLocalTime();
void sceRtcGetTickResolution();
void sceRtcGetTick();
u32 sceRtcGetDaysInMonth(u32 year, u32 month);
u32 sceRtcGetDayOfWeek(u32 year, u32 month, u32 day);

View File

@ -25,13 +25,136 @@
#include "../MIPS/MIPS.h"
#include "sceRtc.h"
#include "../CoreTiming.h"
void sceRtcGetCurrentTick()
// Grabbed from JPSCP
const u64 rtcMagicOffset = 62135596800000000L;
u64 __RtcGetCurrentTick()
{
#ifdef _WIN32
RETURN(GetTickCount());
#else
time_update();
RETURN(time_now_d());
#endif
return cyclesToUs(CoreTiming::GetTicks()) + rtcMagicOffset;
}
u32 sceRtcGetTickResolution()
{
DEBUG_LOG(HLE, "sceRtcGetTickResolution()");
return 1000000;
}
u32 sceRtcGetCurrentTick(u32 tickPtr)
{
DEBUG_LOG(HLE, "sceRtcGetCurrentTick(%08x)", tickPtr);
u64 curTick = __RtcGetCurrentTick();
if (Memory::IsValidAddress(tickPtr))
{
Memory::Write_U32(tickPtr, curTick & 0xFFFFFFFF);
Memory::Write_U32(tickPtr + 4, (curTick >> 32) & 0xFFFFFFFF);
}
return 0;
}
u64 sceRtcGetAcculumativeTime()
{
DEBUG_LOG(HLE, "sceRtcGetAcculumativeTime()");
return __RtcGetCurrentTick();
}
u32 sceRtcGetCurrentClockLocalTime()
{
ERROR_LOG(HLE,"UNIMPL 0=sceRtcGetCurrentClockLocalTime()");
return 0;
}
u32 sceRtcGetTick()
{
ERROR_LOG(HLE,"UNIMPL 0=sceRtcGetTick(...)");
return 0;
}
u32 sceRtcGetDayOfWeek(u32 year, u32 month, u32 day)
{
DEBUG_LOG(HLE,"sceRtcGetDayOfWeek()");
static u32 t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
if (month > 12 || month < 1) {
// Preventive crashfix
ERROR_LOG(HLE,"Bad month");
return 0;
}
year -= month < 3;
return ( year + year/4 - year/100 + year/400 + t[month-1] + day) % 7;
}
u32 sceRtcGetDaysInMonth(u32 year, u32 month)
{
DEBUG_LOG(HLE,"sceRtcGetDaysInMonth()");
u32 numberOfDays;
switch (month)
{
case 4:
case 6:
case 9:
case 11:
numberOfDays = 30;
break;
case 2:
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
numberOfDays = 29;
else
numberOfDays = 28;
break;
default:
numberOfDays = 31;
break;
}
return numberOfDays;
}
const HLEFunction sceRtc[] =
{
{0xC41C2853, WrapU_V<sceRtcGetTickResolution>, "sceRtcGetTickResolution"},
{0x3f7ad767, WrapU_U<sceRtcGetCurrentTick>, "sceRtcGetCurrentTick"},
{0x011F03C1, WrapU64_V<sceRtcGetAcculumativeTime>, "sceRtcGetAccumulativeTime"},
{0x029CA3B3, WrapU64_V<sceRtcGetAcculumativeTime>, "sceRtcGetAccumlativeTime"},
{0x4cfa57b0, 0, "sceRtcGetCurrentClock"},
{0xE7C27D1B, WrapU_V<sceRtcGetCurrentClockLocalTime>, "sceRtcGetCurrentClockLocalTime"},
{0x34885E0D, 0, "sceRtcConvertUtcToLocalTime"},
{0x779242A2, 0, "sceRtcConvertLocalTimeToUTC"},
{0x42307A17, 0, "sceRtcIsLeapYear"},
{0x05ef322c, WrapU_UU<sceRtcGetDaysInMonth>, "sceRtcGetDaysInMonth"},
{0x57726bc1, WrapU_UUU<sceRtcGetDayOfWeek>, "sceRtcGetDayOfWeek"},
{0x4B1B5E82, 0, "sceRtcCheckValid"},
{0x3a807cc8, 0, "sceRtcSetTime_t"},
{0x27c4594c, 0, "sceRtcGetTime_t"},
{0xF006F264, 0, "sceRtcSetDosTime"},
{0x36075567, 0, "sceRtcGetDosTime"},
{0x7ACE4C04, 0, "sceRtcSetWin32FileTime"},
{0xCF561893, 0, "sceRtcGetWin32FileTime"},
{0x7ED29E40, 0, "sceRtcSetTick"},
{0x6FF40ACC, WrapU_V<sceRtcGetTick>, "sceRtcGetTick"},
{0x9ED0AE87, 0, "sceRtcCompareTick"},
{0x44F45E05, 0, "sceRtcTickAddTicks"},
{0x26D25A5D, 0, "sceRtcTickAddMicroseconds"},
{0xF2A4AFE5, 0, "sceRtcTickAddSeconds"},
{0xE6605BCA, 0, "sceRtcTickAddMinutes"},
{0x26D7A24A, 0, "sceRtcTickAddHours"},
{0xE51B4B7A, 0, "sceRtcTickAddDays"},
{0xCF3A2CA8, 0, "sceRtcTickAddWeeks"},
{0xDBF74F1B, 0, "sceRtcTickAddMonths"},
{0x42842C77, 0, "sceRtcTickAddYears"},
{0xC663B3B9, 0, "sceRtcFormatRFC2822"},
{0x7DE6711B, 0, "sceRtcFormatRFC2822LocalTime"},
{0x0498FB3C, 0, "sceRtcFormatRFC3339"},
{0x27F98543, 0, "sceRtcFormatRFC3339LocalTime"},
{0xDFBC5F16, 0, "sceRtcParseDateTime"},
{0x28E1E988, 0, "sceRtcParseRFC3339"},
};
void Register_sceRtc()
{
RegisterModule("sceSasCore", ARRAY_SIZE(sceRtc), sceRtc);
}

View File

@ -18,3 +18,4 @@
#pragma once
void sceRtcGetCurrentTick();
void Register_sceRtc();

View File

@ -102,6 +102,7 @@ LOCAL_SRC_FILES := \
$(SRC)/Core/HLE/sceDisplay.cpp \
$(SRC)/Core/HLE/sceDmac.cpp \
$(SRC)/Core/HLE/sceGe.cpp \
$(SRC)/Core/HLE/sceFont.cpp \
$(SRC)/Core/HLE/sceHprm.cpp \
$(SRC)/Core/HLE/sceHttp.cpp \
$(SRC)/Core/HLE/sceImpose.cpp \