diff --git a/fpPS4.lpr b/fpPS4.lpr index dade3e25..dc774f93 100644 --- a/fpPS4.lpr +++ b/fpPS4.lpr @@ -286,8 +286,8 @@ begin // 'sceKernelClockGettime':; // 'pthread_mutex_lock':; // 'pthread_mutex_unlock':; - // 'sceKernelPread':; - // 'sceKernelClose':; + // //'sceKernelPread':; + // //'sceKernelClose':; // 'sceDiscMapIsRequestOnHDD':; // 'Unknow':; // 'sceFiosIOFilterPsarcDearchiver':; @@ -301,10 +301,11 @@ begin // 'scePthreadRwlockUnlock':; // 'scePthreadCondBroadcast':; // 'sceFiosFHCloseSync':; - // 'sceKernelStat':; + // //'sceKernelStat':; // 'sceFiosFHOpenSync':; // 'sceFiosFHGetSize':; - // 'sceKernelOpen':; + // //'sceKernelOpen':; + // '_write':; // else // begin // Result:=TStubMemoryTrace(Stub).NewTraceStub(Info^.Nid,Info^.lib,Result,@_trace_enter,@_trace_exit); @@ -408,6 +409,12 @@ begin //ps4_app.app_path:='..\samples\api_gnm\'; //ps4_app.app_file:='..\samples\api_gnm\anisotropy-sample\anisotropy-sample_debug.elf'; + //ps4_app.app_path:='..\samples\api_gnm\'; + //ps4_app.app_file:='..\samples\api_gnm\depth-mode-sample\depth-mode-sample_debug.elf'; + + //ps4_app.app_path:='..\samples\api_gnm\'; + //ps4_app.app_file:='..\samples\api_gnm\eqaa-sample\eqaa-sample_debug.elf'; + //ps4_app.app_path:='..\samples\tutorial_graphics_programming\basic_quad\'; //ps4_app.app_file:='..\samples\tutorial_graphics_programming\basic_quad\basic_quad_debug.elf'; @@ -515,6 +522,15 @@ begin //ps4_app.app_path:='C:\Users\User\Desktop\Games\Stardew_Valley\CUSA06829\'; //ps4_app.app_file:='C:\Users\User\Desktop\Games\Stardew_Valley\CUSA06829\eboot.bin'; + //ps4_app.app_path:='G:\Games\Stardew_Valley\CUSA06829\'; + //ps4_app.app_file:='G:\Games\Stardew_Valley\CUSA06829\eboot.bin'; + + //ps4_app.app_path:='G:\Games\Super Exploding Zoo\CUSA00446\'; + //ps4_app.app_file:='G:\Games\Super Exploding Zoo\CUSA00446\eboot.bin'; + + //ps4_app.app_path:='G:\Games\Untitled Goose Game\CUSA23079\'; + //ps4_app.app_file:='G:\Games\Untitled Goose Game\CUSA23079\eboot.bin'; + //elf:=Telf_file(LoadPs4ElfFromFile('libSceLibcInternal.sprx')); //elf.Prepare; //elf.SavePs4ElfToFile('libSceLibcInternal.prx'); diff --git a/ps4_libkernel/ps4_kernel_file.pas b/ps4_libkernel/ps4_kernel_file.pas index 7509e45a..78217bce 100644 --- a/ps4_libkernel/ps4_kernel_file.pas +++ b/ps4_libkernel/ps4_kernel_file.pas @@ -262,7 +262,11 @@ end; function ps4_open(path:PChar;flags,mode:Integer):Integer; SysV_ABI_CDecl; begin - Result:=_set_errno(sce2px(ps4_sceKernelOpen(path,flags,mode))); + Result:=ps4_sceKernelOpen(path,flags,mode); + if (Result<0) then + begin + Result:=_set_errno(sce2px(Result)); + end; end; function ps4_sceKernelOpen(path:PChar;flags,mode:Integer):Integer; SysV_ABI_CDecl; diff --git a/ps4_libkernel/ps4_libkernel.pas b/ps4_libkernel/ps4_libkernel.pas index 8ce63963..4da0746c 100644 --- a/ps4_libkernel/ps4_libkernel.pas +++ b/ps4_libkernel/ps4_libkernel.pas @@ -1029,7 +1029,9 @@ begin lib^.set_proc($21620105D4C78ADE,@ps4_sceKernelMapFlexibleMemory); lib^.set_proc($71091EF54B8140E9,@ps4_sceKernelMunmap); lib^.set_proc($58571F2F697389DA,@ps4_sceKernelQueryMemoryProtection); + lib^.set_proc($AD58D1BC72745FA7,@ps4_sceKernelVirtualQuery); lib^.set_proc($BD23009B77316136,@ps4_sceKernelMprotect); + lib^.set_proc($0C6306DC9B21AD95,@ps4_sceKernelSetVirtualRangeName); //mmap @@ -1061,6 +1063,9 @@ begin lib^.set_proc($FF62115023BFFCF3,@ps4_sceKernelReadTsc); lib^.set_proc($4018BB1C22B4DE1C,@ps4_sceKernelClockGettime); lib^.set_proc($E09DAC5099AE1D94,@ps4_sceKernelGetProcessTime); + lib^.set_proc($04DA30C76979F3C1,@ps4_sceKernelGetProcessTimeCounterFrequency); + lib^.set_proc($7E0C6731E4CD52D6,@ps4_sceKernelGetProcessTimeCounter); + lib^.set_proc($C92F14D931827B50,@ps4_nanosleep); lib^.set_proc($41CB5E4706EC9D5D,@ps4_usleep); lib^.set_proc($D637D72D15738AC7,@ps4_sceKernelUsleep); diff --git a/ps4_libkernel/ps4_map_mm.pas b/ps4_libkernel/ps4_map_mm.pas index fc940ba6..09f986d1 100644 --- a/ps4_libkernel/ps4_map_mm.pas +++ b/ps4_libkernel/ps4_map_mm.pas @@ -61,6 +61,28 @@ type __align:Integer; end; +const + SCE_KERNEL_VIRTUAL_RANGE_NAME_SIZE=32; + SCE_KERNEL_VQ_FIND_NEXT=1; + +type + pSceKernelVirtualQueryInfo=^SceKernelVirtualQueryInfo; + SceKernelVirtualQueryInfo=packed record + pstart:Pointer; + pend :Pointer; + offset:QWORD; + protection:Integer; + memoryType:Integer; + bits:bitpacked record + isFlexibleMemory:0..1; + isDirectMemory :0..1; + isStack :0..1; + isPooledMemory :0..1; + isCommitted :0..1; + end; + name:array[0..SCE_KERNEL_VIRTUAL_RANGE_NAME_SIZE-1] of AnsiChar; + end; + function ps4_sceKernelGetDirectMemorySize:Int64; SysV_ABI_CDecl; function ps4_getpagesize:Integer; SysV_ABI_CDecl; @@ -108,7 +130,14 @@ function ps4_sceKernelMapFlexibleMemory( function ps4_sceKernelMunmap(addr:Pointer;len:size_t):Integer; SysV_ABI_CDecl; function ps4_sceKernelQueryMemoryProtection(addr:Pointer;pStart,pEnd:PPointer;pProt:PInteger):Integer; SysV_ABI_CDecl; + +function ps4_sceKernelVirtualQuery(addr:Pointer; + flags:Integer; + info:pSceKernelVirtualQueryInfo; + infoSize:QWORD):Integer; SysV_ABI_CDecl; + function ps4_sceKernelMprotect(addr:Pointer;len:QWORD;prot:Integer):Integer; SysV_ABI_CDecl; +function ps4_sceKernelSetVirtualRangeName(addr:Pointer;len:QWORD;name:Pchar):Integer; SysV_ABI_CDecl; function ps4_mmap(addr:Pointer;len:size_t;prot,flags:Integer;fd:Integer;offset:size_t):Pointer; SysV_ABI_CDecl; function ps4_munmap(addr:Pointer;len:size_t):Integer; SysV_ABI_CDecl; function ps4_msync(addr:Pointer;len:size_t;flags:Integer):Integer; SysV_ABI_CDecl; @@ -1700,6 +1729,15 @@ begin _sig_unlock; end; +function ps4_sceKernelVirtualQuery(addr:Pointer; + flags:Integer; + info:pSceKernelVirtualQueryInfo; + infoSize:QWORD):Integer; SysV_ABI_CDecl; +begin + Result:=0; + Assert(false,'TODO'); +end; + function ps4_sceKernelMprotect(addr:Pointer;len:QWORD;prot:Integer):Integer; SysV_ABI_CDecl; begin Result:=SCE_KERNEL_ERROR_EINVAL; @@ -1710,6 +1748,12 @@ begin end; +function ps4_sceKernelSetVirtualRangeName(addr:Pointer;len:QWORD;name:Pchar):Integer; SysV_ABI_CDecl; +begin + Writeln('sceKernelSetVirtualRangeName:',HexStr(addr),':',len,':',name); + Result:=0; +end; + function ps4_mmap(addr:Pointer;len:size_t;prot,flags:Integer;fd:Integer;offset:size_t):Pointer; SysV_ABI_CDecl; Var map:Pointer; diff --git a/ps4_libkernel/ps4_time.pas b/ps4_libkernel/ps4_time.pas index 28634b63..ecf8955f 100644 --- a/ps4_libkernel/ps4_time.pas +++ b/ps4_libkernel/ps4_time.pas @@ -41,6 +41,8 @@ function ps4_sceKernelGetTscFrequency():QWORD; SysV_ABI_CDecl; function ps4_sceKernelReadTsc():QWORD; SysV_ABI_CDecl; function ps4_sceKernelClockGettime(clockId:Integer;tp:Ptimespec):Integer; SysV_ABI_CDecl; function ps4_sceKernelGetProcessTime:QWORD; SysV_ABI_CDecl; //microseconds +function ps4_sceKernelGetProcessTimeCounterFrequency:QWORD; SysV_ABI_CDecl; //microseconds*10 +function ps4_sceKernelGetProcessTimeCounter:QWORD; SysV_ABI_CDecl; //microseconds*10 function ps4_nanosleep(req,rem:Ptimespec):Integer; SysV_ABI_CDecl; function ps4_usleep(usec:DWORD):Integer; SysV_ABI_CDecl; //microseconds @@ -329,6 +331,26 @@ begin _sig_unlock; end; +function ps4_sceKernelGetProcessTimeCounterFrequency:QWORD; SysV_ABI_CDecl; //microseconds*10 +begin + Result:=HECTONANOSEC_PER_SEC; +end; + +function ps4_sceKernelGetProcessTimeCounter:QWORD; SysV_ABI_CDecl; //microseconds*10 +var + ct,et,kt,ut:TFileTime; +begin + _sig_lock; + if GetProcessTimes(GetCurrentProcess,ct,et,kt,ut) then + begin + Result:=({QWORD(kt)+}QWORD(ut)); + end else + begin + Result:=0; + end; + _sig_unlock; +end; + //1sec=10 000 000 //lpUserTime/ 10 000 000 *1 000 000 diff --git a/ps4_libsceaudioout.pas b/ps4_libsceaudioout.pas index 2f6e7ada..a7423a07 100644 --- a/ps4_libsceaudioout.pas +++ b/ps4_libsceaudioout.pas @@ -287,18 +287,10 @@ begin Exit(SCE_AUDIO_OUT_ERROR_INVALID_FORMAT); end; - _sig_lock; - err:=Pa_OpenDefaultStream(@pstream, - 0, - pnumOutputChannels, - psampleFormat, - freq, - paFramesPerBufferUnspecified,nil,nil); - _sig_unlock; - - if (err<>0) and (pnumOutputChannels>2) then + pstream:=nil; + err:=0; + if (_type=SCE_AUDIO_OUT_PORT_TYPE_MAIN) then //so far only main begin - pnumOutputChannels:=2; _sig_lock; err:=Pa_OpenDefaultStream(@pstream, 0, @@ -307,13 +299,25 @@ begin freq, paFramesPerBufferUnspecified,nil,nil); _sig_unlock; - end; - if (err<>0) then - begin - Writeln(StdErr,'Pa_GetErrorText:',PaErrorCode(err),':',Pa_GetErrorText(err)); - //Exit(SCE_AUDIO_OUT_ERROR_NOT_INIT); - pstream:=nil; + if (err<>0) and (pnumOutputChannels>2) then + begin + pnumOutputChannels:=2; + _sig_lock; + err:=Pa_OpenDefaultStream(@pstream, + 0, + pnumOutputChannels, + psampleFormat, + freq, + paFramesPerBufferUnspecified,nil,nil); + _sig_unlock; + end; + + if (err<>0) then + begin + Writeln(StdErr,'Pa_GetErrorText:',PaErrorCode(err),':',Pa_GetErrorText(err)); + //Exit(SCE_AUDIO_OUT_ERROR_NOT_INIT); + end; end; err:=0; @@ -447,6 +451,23 @@ begin Result:=0; end; +function ps4_sceAudioOutSetMixLevelPadSpk(handle,mixLevel:Integer):Integer; SysV_ABI_CDecl; +Var + H:TAudioOutHandle; + i:Integer; +begin + if (HAudioOuts=nil) then Exit(SCE_AUDIO_OUT_ERROR_NOT_INIT); + + _sig_lock; + H:=TAudioOutHandle(HAudioOuts.Acqure(handle)); + _sig_unlock; + + //ignore + + H.Release; + Result:=0; +end; + procedure _VecMulI16M(Src,Dst:Pointer;count:Integer;volume:Integer);// inline; begin if volume=SCE_AUDIO_VOLUME_0DB then @@ -702,6 +723,7 @@ begin lib^.set_proc($B35FFFB84F66045C,@ps4_sceAudioOutClose); lib^.set_proc($1AB43DB3822B35A4,@ps4_sceAudioOutGetPortState); lib^.set_proc($6FEB8057CF489711,@ps4_sceAudioOutSetVolume); + lib^.set_proc($C15C0F539D294B57,@ps4_sceAudioOutSetMixLevelPadSpk); lib^.set_proc($40E42D6DE0EAB13E,@ps4_sceAudioOutOutput); lib^.set_proc($C373DD6924D2C061,@ps4_sceAudioOutOutputs); end; diff --git a/ps4_libscedialogs.pas b/ps4_libscedialogs.pas index 3bda1dcf..52348845 100644 --- a/ps4_libscedialogs.pas +++ b/ps4_libscedialogs.pas @@ -67,6 +67,11 @@ begin Result:=0; end; +function ps4_sceErrorDialogUpdateStatus():Integer; SysV_ABI_CDecl; +begin + Result:=0; //SCE_ERROR_DIALOG_STATUS_NONE +end; + function ps4_sceNpProfileDialogInitialize():Integer; SysV_ABI_CDecl; begin Writeln('sceNpProfileDialogInitialize'); @@ -237,6 +242,11 @@ begin Result:=0; end; +function ps4_sceNpCommerceDialogUpdateStatus():Integer; SysV_ABI_CDecl; +begin + Result:=0; //SCE_COMMON_DIALOG_STATUS_NONE +end; + // function Load_libSceCommonDialog(Const name:RawByteString):TElf_node; @@ -259,6 +269,7 @@ begin Result.pFileName:=name; lib:=Result._add_lib('libSceErrorDialog'); lib^.set_proc($23CF0A0A19729D2B,@ps4_sceErrorDialogInitialize); + lib^.set_proc($596886BA1F577E04,@ps4_sceErrorDialogUpdateStatus); end; // @@ -312,6 +323,7 @@ begin Result.pFileName:=name; lib:=Result._add_lib('libSceNpCommerce'); lib^.set_proc($D1A4766969906A5E,@ps4_sceNpCommerceDialogInitialize); + lib^.set_proc($2D1E5CC0530C0951,@ps4_sceNpCommerceDialogUpdateStatus); end; initialization diff --git a/ps4_libscenpscore.pas b/ps4_libscenpscore.pas index c72f0fa5..98b7c617 100644 --- a/ps4_libscenpscore.pas +++ b/ps4_libscenpscore.pas @@ -184,6 +184,8 @@ begin Result:=0; end; +//nop nid:libSceNpScore:00D26CB0FCF7998D:sceNpScoreRecordScoreAsync + function Load_libSceNpScoreRanking(Const name:RawByteString):TElf_node; var lib:PLIBRARY; diff --git a/ps4_program.pas b/ps4_program.pas index a2a520e9..0e693d7c 100644 --- a/ps4_program.pas +++ b/ps4_program.pas @@ -425,74 +425,74 @@ begin Result:=PathConcat(s,filename); end; +function _parse_cast(var pp,fp:PChar;var Path:RawByteString):Byte; +begin + Result:=0; + Case (fp-pp) of + 0:pp:=fp+1; //next + 4:Case PDWORD(pp)^ of + $30707061: //app0 + begin + if (fp^<>#0) then Inc(fp); + Path:=PathConcat(ps4_app.app_path,fp); + Result:=1; + end; + else + Result:=2; + end; + 9:Case PQWORD(pp)^ of + $6174616465766173: //savedata + begin + Case (pp+8)^ of + '0'..'9': + begin + if (fp^<>#0) then Inc(fp); + Path:=MountConcat(ord((pp+8)^)-ord('0'),fp);; + Result:=1; + end; + else + Result:=2; + end; + end; + else + Result:=2; + end; + 10:Case PQWORD(pp)^ of + $6174616465766173: //savedata + begin + Case PWORD(pp+8)^ of + $3031, //10 + $3131, //11 + $3231, //12 + $3331, //13 + $3431, //14 + $3531: //15 + begin + if (fp^<>#0) then Inc(fp); + Path:=MountConcat(ord((pp+9)^)-ord('0')+10,fp); + //Result:=PathConcat(GetCurrentDir,fp); + Result:=1; + end; + else + Result:=2; + end; + end; + else + Result:=2; + end; + else + begin + //Writeln((fp-pp),'*',fp,'*',pp); + Result:=2; + end; + end; +end; + function _parse_filename(filename:PChar):RawByteString; var Path:RawByteString; pp,fp:PChar; - function _cast(var str:RawByteString):Byte; - begin - Result:=0; - Case (fp-pp) of - 0:pp:=fp+1; //next - 4:Case PDWORD(pp)^ of - $30707061: //app0 - begin - if (fp^<>#0) then Inc(fp); - str:=PathConcat(ps4_app.app_path,fp); - Result:=1; - end; - else - Result:=2; - end; - 9:Case PQWORD(pp)^ of - $6174616465766173: //savedata - begin - Case (pp+8)^ of - '0'..'9': - begin - if (fp^<>#0) then Inc(fp); - str:=MountConcat(ord((pp+8)^)-ord('0'),fp);; - Result:=1; - end; - else - Result:=2; - end; - end; - else - Result:=2; - end; - 10:Case PQWORD(pp)^ of - $6174616465766173: //savedata - begin - Case PWORD(pp+8)^ of - $3031, //10 - $3131, //11 - $3231, //12 - $3331, //13 - $3431, //14 - $3531: //15 - begin - if (fp^<>#0) then Inc(fp); - str:=MountConcat(ord((pp+9)^)-ord('0')+10,fp); - //Result:=PathConcat(GetCurrentDir,fp); - Result:=1; - end; - else - Result:=2; - end; - end; - else - Result:=2; - end; - else - begin - //Writeln((fp-pp),'*',fp,'*',pp); - Result:=2; - end; - end; - end; - begin Result:=''; //Writeln(filename); @@ -506,9 +506,9 @@ begin Case fp^ of '/': begin - Case _cast(Result) of + Case _parse_cast(pp,fp,Result) of 1:Exit; //mapped - 2:Exit(''); //not mapped + 2:Exit; //not mapped else; //next char end; @@ -517,10 +517,10 @@ begin Inc(fp); end; - Case _cast(Result) of + Case _parse_cast(pp,fp,Result) of 1:Exit; //mapped else; - Exit(''); //not mapped + Exit; //not mapped end; end; diff --git a/sys/sys_crt.pas b/sys/sys_crt.pas index c10a4df7..48cfb569 100644 --- a/sys/sys_crt.pas +++ b/sys/sys_crt.pas @@ -12,6 +12,9 @@ Procedure sys_crt_init; implementation +uses + sys_signal; + var StdOutLock:Pointer=nil; @@ -33,6 +36,7 @@ Begin if (t.BufPos=0) then exit; n:=0; + _sig_lock; spin_lock(StdOutLock); WriteConsole(t.Handle,t.Bufptr,t.BufPos,@n,nil); @@ -41,6 +45,7 @@ Begin t.BufPos:=0; spin_unlock(StdOutLock); + _sig_unlock; end; Procedure CrtErrWrite(var t:TextRec); @@ -53,6 +58,7 @@ Begin if (t.BufPos=0) then exit; n:=0; + _sig_lock; spin_lock(StdOutLock); old:=7; @@ -67,6 +73,7 @@ Begin t.BufPos:=0; spin_unlock(StdOutLock); + _sig_unlock; end; Procedure CrtClose(Var F:TextRec); diff --git a/vulkan/vBuffer.pas b/vulkan/vBuffer.pas index e2f10078..72454fc9 100644 --- a/vulkan/vBuffer.pas +++ b/vulkan/vBuffer.pas @@ -28,6 +28,7 @@ var cinfo:TVkBufferCreateInfo; r:TVkResult; begin + Assert(size<>0); FSize:=size; FUsage:=usage; cinfo:=Default(TVkBufferCreateInfo); diff --git a/vulkan/vShaderExt.pas b/vulkan/vShaderExt.pas index 45e01c6c..91dffa35 100644 --- a/vulkan/vShaderExt.pas +++ b/vulkan/vShaderExt.pas @@ -610,7 +610,7 @@ end; Procedure TvUniformBuilder.AddVSharp(PV:PVSharpResource4;fset,bind,offset:DWord); var b:TBufBindExt; - i,stride:Integer; + i,stride,num_records:Integer; begin Assert(PV<>nil); if (PV=nil) then Exit; @@ -625,8 +625,10 @@ begin b.addr:=Pointer(PV^.base); stride:=PV^.stride; + num_records:=PV^.num_records; if (stride=0) then stride:=1; - b.size:=stride*PV^.num_records; + if (num_records=0) then num_records:=1; + b.size:=stride*num_records; i:=Length(FBuffers); SetLength(FBuffers,i+1);