Skip to content

Commit

Permalink
libSceNpWebApi2 functions + getsockname + SceVoiceSetMuteFlag + SceAu…
Browse files Browse the repository at this point in the history
…dio3dBedWrite (#189)

* libSceNpWebApi2 functions

* getsockname

* sceVoiceSetMuteFlag

* sceAudio3dBedWrite

* +

---------

Co-authored-by: red-prig <vdpasha@mail.ru>
  • Loading branch information
Ordinary205 and red-prig authored Feb 7, 2024
1 parent 7c7c04a commit 16778c4
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 39 deletions.
1 change: 1 addition & 0 deletions kernel/ps4_libkernel.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1985,6 +1985,7 @@ function Load_libkernel(Const name:RawByteString):TElf_node;
lib^.set_proc($4D4BA2612DA413CB,@ps4_shutdown);
lib^.set_proc($DDEFB822FEC827C5,@ps4_accept);
lib^.set_proc($A01AF7D773E9A4D1,@ps4_sendto);
lib^.set_proc($45E9C8D652F55859,@ps4_getsockname);

//socket

Expand Down
41 changes: 34 additions & 7 deletions kernel/ps4_scesocket.pas
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ interface
pSceNetId=^SceNetId;
SceNetId=Integer;

function ps4_socket(const name:PChar;
family,_type,protocol:Integer):Integer; SysV_ABI_CDecl;
function ps4_socket(family,_type,protocol:Integer):Integer; SysV_ABI_CDecl;

function ps4_bind(s:SceNetId;
const addr:pSceNetSockaddr;
Expand All @@ -26,7 +25,12 @@ function ps4_setsockopt(s:SceNetId;
const optval:Pointer;
optlen:SceNetSocklen_t):Integer; SysV_ABI_CDecl;

function ps4_select():Integer; SysV_ABI_CDecl;
function ps4_select(s:SceNetId;
readfds :Pointer;
writefds :Pointer;
exceptfds:Pointer;
timeout :Pointer
):Integer; SysV_ABI_CDecl;

function ps4_recvfrom(s:SceNetId;
buf:Pointer;
Expand All @@ -48,12 +52,15 @@ function ps4_sendto(s:SceNetId;
len:QWORD;
flags:Integer;
const addr:pSceNetSockaddr;
paddrlen:pSceNetSocklen_t):Integer; SysV_ABI_CDecl;
paddrlen:pSceNetSocklen_t):Integer; SysV_ABI_CDecl;

function ps4_getsockname(s:SceNetId;
addr:pSceNetSockaddr;
paddrlen:pSceNetSocklen_t):Integer; SysV_ABI_CDecl;

implementation

function ps4_socket(const name:PChar;
family,_type,protocol:Integer):Integer; SysV_ABI_CDecl;
function ps4_socket(family,_type,protocol:Integer):Integer; SysV_ABI_CDecl;
begin
Result:=0;
end;
Expand All @@ -73,7 +80,12 @@ function ps4_setsockopt(s:SceNetId;
Result:=0;
end;

function ps4_select():Integer; SysV_ABI_CDecl;
function ps4_select(s:SceNetId;
readfds :Pointer;
writefds :Pointer;
exceptfds:Pointer;
timeout :Pointer
):Integer; SysV_ABI_CDecl;
begin
Result:=0;
end;
Expand Down Expand Up @@ -115,5 +127,20 @@ function ps4_sendto(s:SceNetId;
Result:=0;
end;

function ps4_getsockname(s:SceNetId;
addr:pSceNetSockaddr;
paddrlen:pSceNetSocklen_t):Integer; SysV_ABI_CDecl;
begin
Result:=0;
if (addr<>nil) then
begin
addr^:=default_addr;
end;
if (paddrlen<>nil) then
begin
paddrlen^:=SizeOf(SceNetSockaddr);
end;
end;

end.

17 changes: 17 additions & 0 deletions src/audio/ps4_libsceaudio3d.pas
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ interface
ps4_program;

const
//SceAudio3dFormat
SCE_AUDIO3D_FORMAT_S16 =0;
SCE_AUDIO3D_FORMAT_FLOAT=1;

//SceAudio3dRate
SCE_AUDIO3D_RATE_48000=0;

Expand All @@ -21,6 +25,9 @@ interface
SCE_AUDIO3D_BLOCKING_SYNC =1;

type
pSceAudio3dFormat=^SceAudio3dFormat;
SceAudio3dFormat=Integer;

pSceAudio3dAttributeId=^SceAudio3dAttributeId;
SceAudio3dAttributeId=DWORD;

Expand Down Expand Up @@ -137,6 +144,15 @@ function ps4_sceAudio3dPortGetQueueLevel(uiPortId:SceAudio3dPortId;
Result:=0;
end;

function ps4_sceAudio3dBedWrite(uiPortId:SceAudio3dPortId;
uiNumChannels:Integer;
eFormat:SceAudio3dFormat;
const pBuffer:Pointer;
_uiNumChannels:Integer):Integer; SysV_ABI_CDecl;
begin
Result:=0;
end;

function Load_libSceAudio3d(Const name:RawByteString):TElf_node;
var
lib:PLIBRARY;
Expand All @@ -155,6 +171,7 @@ function Load_libSceAudio3d(Const name:RawByteString):TElf_node;
lib^.set_proc($54456167DA9DE196,@ps4_sceAudio3dPortPush);
lib^.set_proc($B9C12C8BADACA13A,@ps4_sceAudio3dAudioOutOpen);
lib^.set_proc($61A6836C3C0AA453,@ps4_sceAudio3dPortGetQueueLevel);
lib^.set_proc($F6D130134195D2AA,@ps4_sceAudio3dBedWrite);
end;

initialization
Expand Down
99 changes: 78 additions & 21 deletions src/np/ps4_libscenpwebapi.pas
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,6 @@ function ps4_sceNpWebApiDeleteRequest(requestId:Int64):Integer; SysV_ABI_CDecl;
Result:=0;
end;

//

function ps4_sceNpWebApi2Initialize(libHttp2CtxId:Integer;
poolSize:size_t):Integer; SysV_ABI_CDecl;
begin
Writeln('sceNpWebApi2Initialize:',libHttp2CtxId,':',poolSize);
Result:=4;
end;

function ps4_sceNpWebApi2CreateUserContext(libCtxId,m_userId:Integer):Integer; SysV_ABI_CDecl;
begin
Writeln('sceNpWebApi2CreateUserContext:',libCtxId,':',m_userId);
Result:=5;
end;

function ps4_sceNpWebApi2PushEventDeletePushContext(param_1:Integer;param_2:Pointer):Integer; SysV_ABI_CDecl;
begin
Result:=0;
end;

function ps4_sceNpWebApiSendRequest(requestId:Int64;
pData:Pointer;
dataSize:size_t):Integer; SysV_ABI_CDecl;
Expand Down Expand Up @@ -273,6 +253,80 @@ function ps4_sceNpWebApiDeleteContext(userCtxId:Integer):Integer; SysV_ABI_CDecl
Result:=0;
end;

//NpWebApi2

type
pSceNpWebApi2ContentParameter=^SceNpWebApi2ContentParameter;
SceNpWebApi2ContentParameter=packed record
contentLength:QWORD;
pContentType :Pchar;
reserved :array[0..15] of Byte;
end;

pSceNpWebApi2ResponseInformationOption=^SceNpWebApi2ResponseInformationOption;
SceNpWebApi2ResponseInformationOption=packed record
httpStatus :Integer;
_align :Integer;
pErrorObject :Pchar;
errorObjectSize :QWORD;
responseDataSize:QWORD;
end;

const
SCE_NP_WEBAPI2_PUSH_EVENT_UUID_LENGTH=36;

type
pSceNpWebApi2PushEventPushContextId=^SceNpWebApi2PushEventPushContextId;
SceNpWebApi2PushEventPushContextId=packed record
uuid:array[0..SCE_NP_WEBAPI2_PUSH_EVENT_UUID_LENGTH] of Char;
end;

function ps4_sceNpWebApi2Initialize(libHttp2CtxId:Integer;
poolSize:size_t):Integer; SysV_ABI_CDecl;
begin
Writeln('sceNpWebApi2Initialize:',libHttp2CtxId,':',poolSize);
Result:=4;
end;

function ps4_sceNpWebApi2CreateRequest(titleUserCtxId:Integer;
pApiGroup:Pchar;
pPath:Pchar;
method:PChar; //SceNpWebApi2HttpMethod
pContentParameter:pSceNpWebApi2ContentParameter;
pRequestId:pInt64):Integer; SysV_ABI_CDecl;
begin
Result:=0;
end;

function ps4_sceNpWebApi2SendRequest(requestId:Int64;
pData:Pointer;
dataSize:QWORD;
pRespInfoOption:pSceNpWebApi2ResponseInformationOption):Integer; SysV_ABI_CDecl;
begin
Result:=0;
end;

function ps4_sceNpWebApi2CreateUserContext(libCtxId,m_userId:Integer):Integer; SysV_ABI_CDecl;
begin
Writeln('sceNpWebApi2CreateUserContext:',libCtxId,':',m_userId);
Result:=5;
end;

function ps4_sceNpWebApi2PushEventDeletePushContext(userCtxId:Integer;
pPushCtxId:pSceNpWebApi2PushEventPushContextId):Integer; SysV_ABI_CDecl;
begin
Result:=0;
end;

function ps4_sceNpWebApi2AddHttpRequestHeader(requestId:Integer;
const pFieldName:PChar;
const pValue:PChar):Integer; SysV_ABI_CDecl;
begin
Result:=0;
end;

//NpWebApi2

function Load_libSceNpWebApi(Const name:RawByteString):TElf_node;
var
lib:PLIBRARY;
Expand Down Expand Up @@ -315,9 +369,12 @@ function Load_libSceNpWebApi2(Const name:RawByteString):TElf_node;

lib:=Result._add_lib('libSceNpWebApi2');

lib^.set_proc($FA8F7CD7A61086A4,@ps4_sceNpWebApi2Initialize );
lib^.set_proc($FA8F7CD7A61086A4,@ps4_sceNpWebApi2Initialize);
lib^.set_proc($DC423F39227AE577,@ps4_sceNpWebApi2CreateRequest);
lib^.set_proc($95038217CE25BF3C,@ps4_sceNpWebApi2SendRequest);
lib^.set_proc($B24E786E2E85B583,@ps4_sceNpWebApi2CreateUserContext);
lib^.set_proc($41A7F179933758AE,@ps4_sceNpWebApi2PushEventDeletePushContext);
lib^.set_proc($7A038EBEB9C5EA62,@ps4_sceNpWebApi2AddHttpRequestHeader);
end;

initialization
Expand Down
21 changes: 10 additions & 11 deletions src/ps4_libscenet.pas
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ interface
SysUtils;

const
AF_INET = 2;
AF_INET6=28;

SCE_NET_EINVAL =22;
SCE_NET_ENOSPC =28;
SCE_NET_EAFNOSUPPORT=47;
Expand Down Expand Up @@ -65,6 +68,13 @@ interface
data:SceNetEpollData;
end;

const
default_addr:SceNetSockaddr=(
sa_len :SizeOf(SceNetSockaddr);
sa_family:AF_INET;
sa_data :(80,0,1,1,1,1,0,0,0,0,0,0,0,0);
);

implementation

uses
Expand Down Expand Up @@ -130,10 +140,6 @@ function ps4_sceNetEpollCreate(name:PChar;flags:Integer):Integer; SysV_ABI_CDecl
Result:=3;
end;

const
AF_INET = 2;
AF_INET6=28;

function ps4_sceNetInetPton(af:Integer;
src:Pchar;
dst:Pointer):Integer; SysV_ABI_CDecl;
Expand Down Expand Up @@ -281,13 +287,6 @@ function ps4_sceNetListen(s:Integer;backlog:Integer):Integer; SysV_ABI_CDecl;
Result:=0;
end;

const
default_addr:SceNetSockaddr=(
sa_len :SizeOf(SceNetSockaddr);
sa_family:AF_INET;
sa_data :(80,0,1,1,1,1,0,0,0,0,0,0,0,0);
);

function ps4_sceNetAccept(s:Integer;
addr:pSceNetSockaddr;
paddrlen:pSceNetSocklen_t):Integer; SysV_ABI_CDecl;
Expand Down
6 changes: 6 additions & 0 deletions src/ps4_libscevoice.pas
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ function ps4_sceVoiceSetVolume(portId:DWORD;volume:Single):Integer; SysV_ABI_CDe
Result:=0;
end;

function ps4_sceVoiceSetMuteFlag(portId:DWORD;bMuted:Boolean):Integer; SysV_ABI_CDecl;
begin
Result:=0;
end;

function Load_libSceVoice(Const name:RawByteString):TElf_node;
var
lib:PLIBRARY;
Expand All @@ -125,6 +130,7 @@ function Load_libSceVoice(Const name:RawByteString):TElf_node;
lib^.set_proc($0AB2EA0F058BA173,@ps4_sceVoiceGetPortInfo);
lib^.set_proc($710E831AC4048D5E,@ps4_sceVoiceReadFromOPort);
lib^.set_proc($4011680088C9A174,@ps4_sceVoiceSetVolume);
lib^.set_proc($8305329E41203456,@ps4_sceVoiceSetMuteFlag);
end;

function Load_libSceVoiceQoS(Const name:RawByteString):TElf_node;
Expand Down

0 comments on commit 16778c4

Please sign in to comment.