diff --git a/Core/Config.h b/Core/Config.h index bf8d5f12ab..d873fcb725 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -54,6 +54,7 @@ public: std::string currentDirectory; std::string memCardDirectory; + std::string flashDirectory; void Load(const char *iniFileName = "ppsspp.ini"); void Save(); diff --git a/Core/HLE/FunctionWrappers.h b/Core/HLE/FunctionWrappers.h index bc7f1ed1b2..6bd5ce3373 100644 --- a/Core/HLE/FunctionWrappers.h +++ b/Core/HLE/FunctionWrappers.h @@ -98,6 +98,22 @@ template void WrapI_UU() { RETURN(retval); } +template void WrapI_UUU() { + int retval = func(PARAM(0), PARAM(1), PARAM(2)); + RETURN(retval); +} + +template void WrapI_UUUIIII() { + int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6)); + RETURN(retval); +} + +template void WrapI_UUUU() { + int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); + RETURN(retval); +} + + template void WrapI_V() { int retval = func(); RETURN(retval); diff --git a/Core/HLE/sceFont.cpp b/Core/HLE/sceFont.cpp index 389acf877c..ed1a05d5f4 100644 --- a/Core/HLE/sceFont.cpp +++ b/Core/HLE/sceFont.cpp @@ -8,27 +8,329 @@ #include "sceFont.h" +typedef u32 FontLibraryHandle; +typedef u32 FontHandle; + +typedef struct { + u32* userDataAddr; + u32 numFonts; + u32* cacheDataAddr; + + // Driver callbacks. + void *(*allocFuncAddr)(void *, u32); + void (*freeFuncAddr )(void *, void *); + u32* openFuncAddr; + u32* closeFuncAddr; + u32* readFuncAddr; + u32* seekFuncAddr; + u32* errorFuncAddr; + u32* ioFinishFuncAddr; +} FontNewLibParams; + +typedef enum { + FONT_FAMILY_SANS_SERIF = 1, + FONT_FAMILY_SERIF = 2, +} Family; + +typedef enum { + 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 +} Style; + +typedef enum { + FONT_LANGUAGE_JAPANESE = 1, + FONT_LANGUAGE_LATIN = 2, + FONT_LANGUAGE_KOREAN = 3, +} Language; + +typedef struct { + 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; +} FontStyle; + +typedef struct { + // 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]; +} FontInfo; + +typedef struct { + 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]; +} CharInfo; + +typedef enum { + 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 +} FontPixelFormat; + +typedef struct { + FontPixelFormat pixelFormat; + s32 xPos64; + s32 yPos64; + u16 bufWidth; + u16 bufHeight; + u16 bytesPerLine; + u16 pad; + void *buffer; +} GlyphImage; + +FontNewLibParams fontLib; + +u32 sceFontNewLib(u32 FontNewLibParamsPtr, u32 errorCodePtr) +{ + ERROR_LOG(HLE, "sceFontNewLib %x, %x", FontNewLibParamsPtr, errorCodePtr); + + if (Memory::IsValidAddress(FontNewLibParamsPtr)&&Memory::IsValidAddress(errorCodePtr)) + { + Memory::Write_U32(0, errorCodePtr); + Memory::ReadStruct(FontNewLibParamsPtr, &fontLib); + } + + return 1; +} + + +int sceFontDoneLib(u32 FontLibraryHandlePtr) +{ + ERROR_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); + } + return 1; +} + +u32 sceFontOpenUserMemory(u32 libHandle, u32 memoryFontAddrPtr, u32 memoryFontLength, u32 errorCodePtr) +{ + ERROR_LOG(HLE, "sceFontOpenUserMemory %x, %x, %x, %x", libHandle, memoryFontAddrPtr, memoryFontLength, errorCodePtr); + return 1; +} + +u32 sceFontOpenUserFile(u32 libHandle, u32 fileNamePtr, u32 mode, u32 errorCodePtr) +{ + ERROR_LOG(HLE, "sceFontOpenUserFile %x, %x, %x, %x", libHandle, fileNamePtr, mode, errorCodePtr); + return 1; +} + +int sceFontClose(u32 fontHandle) +{ + ERROR_LOG(HLE, "sceFontClose %x", fontHandle); + return 0; +} + + +int sceFontGetNumFontList(u32 libHandle, u32 errorCodePtr) +{ + ERROR_LOG(HLE, "sceFontGetNumFontList %x, %x", libHandle, errorCodePtr); + if (Memory::IsValidAddress(errorCodePtr)) + { + Memory::Write_U32(0, errorCodePtr); + } + return 1; +} + +int sceFontFindOptimumFont(u32 libHandlePtr, u32 fontStylePtr, u32 errorCodePtr) +{ + ERROR_LOG(HLE, "sceFontFindOptimumFont %x, %x, %x", libHandlePtr, fontStylePtr, errorCodePtr); + if (Memory::IsValidAddress(errorCodePtr)) + { + Memory::Write_U32(0, errorCodePtr); + } + return 1; +} + +int sceFontFindFont(u32 libHandlePtr, u32 fontStylePtr, u32 errorCodePtr) +{ + ERROR_LOG(HLE, "sceFontFindFont %x, %x, %x", libHandlePtr, fontStylePtr, errorCodePtr); + return 1; +} + +int sceFontGetFontInfo(u32 fontHandle, u32 fontInfoPtr) +{ + ERROR_LOG(HLE, "sceFontGetFontInfo %x, %x", fontHandle, fontInfoPtr); + + FontInfo fi; + memset (&fi, 0, sizeof(fi)); + if (Memory::IsValidAddress(fontInfoPtr)) + { + fi.BPP =4; + fi.charMapLength = 255; + // fi.fontStyle =1; + 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.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; + Memory::WriteStruct(fontInfoPtr, &fi); + } + + return 0; +} + +int sceFontGetFontInfoByIndexNumber(u32 libHandle, u32 fontInfoPtr, u32 unknown, u32 fontIndex) +{ + ERROR_LOG(HLE, "sceFontGetFontInfoByIndexNumber %x, %x, %x, %x", libHandle, fontInfoPtr, unknown, fontIndex); + // clearly wrong.. + return sceFontGetFontInfo(libHandle, fontInfoPtr); + +} + +int sceFontGetCharInfo(u32 libHandler, u32 charCode, u32 charInfoPtr) +{ + ERROR_LOG(HLE, "sceFontGetCharInfo %x, %x, %x", libHandler, charCode, charInfoPtr); + if (Memory::IsValidAddress(charInfoPtr)) + { + CharInfo pspCharInfo; + memset(&pspCharInfo, 0, sizeof(pspCharInfo)); + pspCharInfo.bitmapWidth = 32; + pspCharInfo.bitmapHeight = 32; + + 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; +} + +int sceFontGetCharGlyphImage(u32 libHandler, u32 charCode, u32 glyphImagePtr) +{ + ERROR_LOG(HLE, "sceFontGetCharGlyphImage %x, %x, %x (%c)", libHandler, charCode, glyphImagePtr, charCode); + + 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); + + Memory::Memset(buffer, 0x7F, bytesPerLine*bufHeight*pixelFormat); + + return 0; +} + +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; +} + const HLEFunction sceLibFont[] = { - {0x67f17ed7, 0, "sceFontNewLib"}, - {0x574b6fbc, 0, "sceFontDoneLib"}, + {0x67f17ed7, WrapU_UU, "sceFontNewLib"}, + {0x574b6fbc, WrapI_U, "sceFontDoneLib"}, {0x48293280, 0, "sceFontSetResolution"}, - {0x27f6e642, 0, "sceFontGetNumFontList"}, + {0x27f6e642, WrapI_UU, "sceFontGetNumFontList"}, {0xbc75d85b, 0, "sceFontGetFontList"}, - {0x099ef33c, 0, "sceFontFindOptimumFont"}, - {0x681e61a7, 0, "sceFontFindFont"}, + {0x099ef33c, WrapI_UUU, "sceFontFindOptimumFont"}, + {0x681e61a7, WrapI_UUU, "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"}, + {0x5333322d, WrapI_UUUU, "sceFontGetFontInfoByIndexNumber"}, + {0xa834319d, WrapU_UUUU, "sceFontOpen"}, + {0x57fcb733, WrapU_UUUU, "sceFontOpenUserFile"}, + {0xbb8e7fe6, WrapU_UUUU, "sceFontOpenUserMemory"}, + {0x3aea8cb6, WrapI_U, "sceFontClose"}, + {0x0da7535e, WrapI_UU, "sceFontGetFontInfo"}, + {0xdcc80c2f, WrapI_UUU, "sceFontGetCharInfo"}, {0x5c3e4a9e, 0, "sceFontGetCharImageRect"}, - {0x980f4895, 0, "sceFontGetCharGlyphImage"}, - {0xca1e6945, 0, "sceFontGetCharGlyphImage_Clip"}, + {0x980f4895, WrapI_UUU, "sceFontGetCharGlyphImage"}, + {0xca1e6945, WrapI_UUUIIII, "sceFontGetCharGlyphImage_Clip"}, {0x74b21701, 0, "sceFontPixelToPointH"}, {0xf8f0752e, 0, "sceFontPixelToPointV"}, {0x472694cd, 0, "sceFontPointToPixelH"}, diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 6e6bd73905..f613fbe5ad 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -151,7 +151,8 @@ void __IoInit() { #ifdef _WIN32 char path_buffer[_MAX_PATH], drive[_MAX_DRIVE] ,dir[_MAX_DIR], file[_MAX_FNAME], ext[_MAX_EXT]; - char mypath[_MAX_PATH]; + char memstickpath[_MAX_PATH]; + char flashpath[_MAX_PATH]; GetModuleFileName(NULL,path_buffer,sizeof(path_buffer)); @@ -163,20 +164,25 @@ void __IoInit() { _splitpath_s(path_buffer, drive, dir, file, ext ); // Mount a couple of filesystems - sprintf(mypath, "%s%sMemStick\\", drive, dir); + sprintf(memstickpath, "%s%sMemStick\\", drive, dir); + sprintf(flashpath, "%s%sFlash\\", drive, dir); + #else // TODO - std::string mypath = g_Config.memCardDirectory; + std::string memstickpath = g_Config.memCardDirectory; + std::string flashpath = g_Config.flashDirectory; #endif DirectoryFileSystem *memstick; - memstick = new DirectoryFileSystem(&pspFileSystem, mypath); + DirectoryFileSystem *flash; + memstick = new DirectoryFileSystem(&pspFileSystem, memstickpath); + flash = new DirectoryFileSystem(&pspFileSystem, flashpath); pspFileSystem.Mount("ms0:", memstick); pspFileSystem.Mount("fatms0:", memstick); pspFileSystem.Mount("fatms:", memstick); - pspFileSystem.Mount("flash0:", new EmptyFileSystem()); - pspFileSystem.Mount("flash1:", new EmptyFileSystem()); + pspFileSystem.Mount("flash0:", flash); + pspFileSystem.Mount("flash1:", flash); } void __IoShutdown() { @@ -856,12 +862,18 @@ u32 sceIoDclose(int id) { return kernelObjects.Destroy(id); } +u32 sceIoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen) +{ + ERROR_LOG(HLE, "UNIMPL 0=sceIoIoctrl id: %08x, cmd %08x, indataPtr %08x, inlen %08x, outdataPtr %08x, outLen %08x", id,cmd,indataPtr,inlen,outdataPtr,outlen); + return 0; +} + const HLEFunction IoFileMgrForUser[] = { { 0xb29ddf9c, &WrapU_C, "sceIoDopen" }, { 0xe3eb004c, &WrapU_IU, "sceIoDread" }, { 0xeb092469, &WrapU_I, "sceIoDclose" }, { 0xe95a012b, 0, "sceIoIoctlAsync" }, - { 0x63632449, 0, "sceIoIoctl" }, + { 0x63632449, &WrapU_UUUUUU, "sceIoIoctl" }, { 0xace946e8, &WrapU_CU, "sceIoGetstat" }, { 0xb8a740f4, 0, "sceIoChstat" }, { 0x55f4717d, &WrapU_C, "sceIoChdir" }, diff --git a/Core/HLE/sceKernel.cpp b/Core/HLE/sceKernel.cpp index c86a6d6d70..5633579f46 100644 --- a/Core/HLE/sceKernel.cpp +++ b/Core/HLE/sceKernel.cpp @@ -84,7 +84,7 @@ void __KernelInit() __UmdInit(); __CtrlInit(); __SslInit(); - + // "Internal" PSP libraries __PPGeInit(); @@ -104,7 +104,7 @@ void __KernelShutdown() kernelObjects.Clear(); __PPGeShutdown(); - + __GeShutdown(); __AudioShutdown(); __IoShutdown(); diff --git a/Core/HLE/sceKernel.h b/Core/HLE/sceKernel.h index 51b3eb151c..2876906894 100644 --- a/Core/HLE/sceKernel.h +++ b/Core/HLE/sceKernel.h @@ -362,6 +362,24 @@ public: return t; } } + template + T* GetByModuleByEntryAddr(u32 entryAddr) + { + for (int i=0; i <4096; i++) + { + T* t = dynamic_cast(pool[i]); + + if (t) + { + if (t->nm.entry_addr == entryAddr) + { + return t; + } + } + } + return 0; + } + static u32 GetMissingErrorCode() { return -1; } // TODO bool GetIDType(SceUID handle, int *type) const diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index bc5baa2e1d..3b1e710241 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -723,13 +723,24 @@ void sceKernelUnloadModule() RETURN(0); } -void sceKernelGetModuleIdByAddress() +u32 sceKernelGetModuleIdByAddress(u32 moduleAddr) { ERROR_LOG(HLE,"HACKIMPL sceKernelGetModuleIdByAddress(%08x)", PARAM(0)); - if ((PARAM(0) & 0xFFFF0000) == 0x08800000) - RETURN(mainModuleID); + + if ((moduleAddr & 0xFFFF0000) == 0x08800000) + { + return mainModuleID; + } else - RETURN(0); + { + Module* foundMod= kernelObjects.GetByModuleByEntryAddr(moduleAddr); + + if(foundMod) + { + return foundMod->GetUID(); + } + } + return 0; } void sceKernelGetModuleId() @@ -744,16 +755,16 @@ void sceKernelFindModuleByName() RETURN(1); } -u32 sceKernelLoadModuleByID(u32 id) { - ERROR_LOG(HLE,"UNIMPL sceKernelLoadModuleById(%08x)", id); +u32 sceKernelLoadModuleByID(u32 id, u32 flags, u32 lmoptionPtr) { + ERROR_LOG(HLE,"UNIMPL sceKernelLoadModuleById(%08x, %08x)", id, lmoptionPtr); // Apparenty, ID is a sceIo File UID. So this shouldn't be too hard when needed. - return 0; + return id; } const HLEFunction ModuleMgrForUser[] = { {0x977DE386,&WrapU_CU,"sceKernelLoadModule"}, - {0xb7f46618,&WrapU_U,"sceKernelLoadModuleByID"}, + {0xb7f46618,&WrapU_UUU,"sceKernelLoadModuleByID"}, {0x50F0C1EC,&WrapV_UUUUU,"sceKernelStartModule"}, {0xD675EBB8,&sceKernelExitGame,"sceKernelSelfStopUnloadModule"}, //HACK {0xd1ff982a,&WrapV_UUUUU,"sceKernelStopModule"}, @@ -762,7 +773,7 @@ const HLEFunction ModuleMgrForUser[] = {0xF9275D98,0,"sceKernelLoadModuleBufferUsbWlan"}, ///??? {0xCC1D3699,0,"sceKernelStopUnloadSelfModule"}, {0x748CBED9,0,"sceKernelQueryModuleInfo"}, - {0xd8b73127,&sceKernelGetModuleIdByAddress, "sceKernelGetModuleIdByAddress"}, + {0xd8b73127,&WrapU_U, "sceKernelGetModuleIdByAddress"}, {0xf0a26395,&sceKernelGetModuleId, "sceKernelGetModuleId"}, {0x8f2df740,0,"sceKernelStopUnloadSelfModuleWithStatus"}, }; diff --git a/Core/HLE/sceRtc.cpp b/Core/HLE/sceRtc.cpp index e032db3d63..5e19e89750 100644 --- a/Core/HLE/sceRtc.cpp +++ b/Core/HLE/sceRtc.cpp @@ -443,8 +443,9 @@ int sceRtcGetTime_t(u32 datePtr, u32 timePtr) { ScePspDateTime pt; Memory::ReadStruct(datePtr, &pt); - u64 result = __RtcPspTimeToTicks(pt); - Memory::Write_U64(result, timePtr); + pt.year-=1969; + u64 result = __RtcPspTimeToTicks(pt)/1000000ULL; + Memory::Write_U32(result, timePtr); } else { diff --git a/Windows/Potemkin.txt b/Windows/Potemkin.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/android/jni/NativeApp.cpp b/android/jni/NativeApp.cpp index 4f35ed9d8e..14daeeecf6 100644 --- a/android/jni/NativeApp.cpp +++ b/android/jni/NativeApp.cpp @@ -218,8 +218,10 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co #if defined(ANDROID) || defined(BLACKBERRY) g_Config.memCardDirectory = user_data_path; + g_Config.flashDirectory = user_data_path+"/flash/"; #else g_Config.memCardDirectory = std::string(getenv("HOME"))+"/.ppsspp/"; + g_Config.flashDirectory = g_Config.memCardDirectory+"/flash/"; #endif for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)