diff --git a/Core/HLE/FunctionWrappers.h b/Core/HLE/FunctionWrappers.h index 26e1e13ce6..b212f6c9d9 100644 --- a/Core/HLE/FunctionWrappers.h +++ b/Core/HLE/FunctionWrappers.h @@ -115,6 +115,20 @@ template void WrapI_ RETURN(retval); } +// Hm, do so many params get passed in registers? +template void WrapI_CICIIIII() { + u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), Memory::GetCharPointer(PARAM(2)), + PARAM(3), PARAM(4), PARAM(5), PARAM(6), PARAM(7)); + RETURN(retval); +} + +// Hm, do so many params get passed in registers? +template void WrapI_CIIIIII() { + u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), + PARAM(3), PARAM(4), PARAM(5), PARAM(6)); + RETURN(retval); +} + template void WrapU_IV() { u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1))); RETURN(retval); @@ -391,11 +405,21 @@ template void WrapI_IIII() { RETURN(retval); } +template void WrapI_UIII() { + int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); + RETURN(retval); +} + template void WrapI_IIIUI() { int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); RETURN(retval); } +template void WrapI_IUUII() { + int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); + RETURN(retval); +} + template void WrapI_ICIUU() { int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3), PARAM(4)); RETURN(retval); @@ -436,6 +460,11 @@ template void WrapI_CU() { RETURN(retval); } +template void WrapI_CUI() { + int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); + RETURN(retval); +} + template void WrapI_CUU() { int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); RETURN(retval); diff --git a/Core/HLE/HLETables.cpp b/Core/HLE/HLETables.cpp index 8a8c6b229f..8f85242670 100644 --- a/Core/HLE/HLETables.cpp +++ b/Core/HLE/HLETables.cpp @@ -19,26 +19,24 @@ #include "HLETables.h" -#include "sceCcc.h" -#include "sceCtrl.h" -#include "sceDisplay.h" -#include "sceHttp.h" #include "sceAtrac.h" -#include "sceIo.h" -#include "sceHprm.h" -#include "scePower.h" -#include "sceFont.h" -#include "sceNet.h" -#include "sceMpeg.h" -#include "sceImpose.h" -#include "sceGe.h" -#include "scePsmf.h" -#include "sceRtc.h" -#include "sceSas.h" -#include "sceUmd.h" +#include "sceAudio.h" +#include "sceAudiocodec.h" +#include "sceCcc.h" +#include "sceChnnlsv.h" +#include "sceCtrl.h" +#include "sceDeflt.h" +#include "sceDisplay.h" #include "sceDmac.h" -#include "sceRtc.h" -#include "sceOpenPSID.h" +#include "sceFont.h" +#include "sceGameUpdate.h" +#include "sceGe.h" +#include "sceHeap.h" +#include "sceHprm.h" +#include "sceHttp.h" +#include "sceImpose.h" +#include "sceIo.h" +#include "sceJpeg.h" #include "sceKernel.h" #include "sceKernelEventFlag.h" #include "sceKernelMemory.h" @@ -47,26 +45,28 @@ #include "sceKernelSemaphore.h" #include "sceKernelThread.h" #include "sceKernelTime.h" -#include "sceAudio.h" -#include "sceUtility.h" -#include "sceParseUri.h" -#include "sceSsl.h" -#include "sceParseHttp.h" -#include "sceVaudio.h" -#include "sceUsb.h" -#include "sceChnnlsv.h" -#include "scePspNpDrm_user.h" -#include "sceP3da.h" -#include "sceGameUpdate.h" -#include "sceDeflt.h" +#include "sceMd5.h" #include "sceMp4.h" #include "sceMp3.h" -#include "scePauth.h" +#include "sceNet.h" +#include "sceNetAdhoc.h" #include "sceNp.h" -#include "sceMd5.h" -#include "sceJpeg.h" -#include "sceAudiocodec.h" -#include "sceHeap.h" +#include "sceMpeg.h" +#include "sceOpenPSID.h" +#include "sceP3da.h" +#include "sceParseHttp.h" +#include "sceParseUri.h" +#include "scePauth.h" +#include "scePower.h" +#include "scePspNpDrm_user.h" +#include "scePsmf.h" +#include "sceRtc.h" +#include "sceSas.h" +#include "sceSsl.h" +#include "sceUmd.h" +#include "sceUsb.h" +#include "sceUtility.h" +#include "sceVaudio.h" #define N(s) s @@ -275,6 +275,7 @@ void RegisterAllModules() { Register_sceSasCore(); Register_sceFont(); Register_sceNet(); + Register_sceNetAdhoc(); Register_sceRtc(); Register_sceWlanDrv(); Register_sceMpeg(); diff --git a/Core/HLE/sceNetAdhoc.cpp b/Core/HLE/sceNetAdhoc.cpp index 32105c3538..41d03b7e6b 100644 --- a/Core/HLE/sceNetAdhoc.cpp +++ b/Core/HLE/sceNetAdhoc.cpp @@ -15,6 +15,21 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + +// sceNetAdhoc + +// These acronyms are seen in function names: +// * PDP: a proprietary Sony protocol similar to UDP. +// * PTP: a proprietary Sony protocol similar to TCP. + +// We will need to wrap them into the similar UDP and TCP messages. If we want to +// play adhoc remotely online, I guess we'll need to wrap both into TCP/IP. + +// We will need some server infrastructure to provide match making. We'll +// group players per game. Maybe allow players to join rooms and then start the game, +// instead of the other way around? + + #include "Core/HLE/HLE.h" #include "Core/HLE/sceNetAdhoc.h" @@ -48,6 +63,13 @@ enum { ERROR_NET_ADHOCCTL_TOO_MANY_HANDLERS = 0x80410b12, }; +enum { + PSP_ADHOC_POLL_READY_TO_SEND = 1, + PSP_ADHOC_POLL_DATA_AVAILABLE = 2, + PSP_ADHOC_POLL_CAN_CONNECT = 4, + PSP_ADHOC_POLL_CAN_ACCEPT = 8, +}; + const size_t MAX_ADHOCCTL_HANDLERS = 32; static bool netAdhocInited; @@ -93,7 +115,7 @@ void __UpdateAdhocctlHandlers(int flag, int error) { args[0] = flag; args[1] = error; - for(std::map::iterator it = adhocctlHandlers.begin(); it != adhocctlHandlers.end(); ++it) { + for (std::map::iterator it = adhocctlHandlers.begin(); it != adhocctlHandlers.end(); ++it) { args[2] = it->second.argument; __KernelDirectMipsCall(it->second.entryPoint, NULL, args, 3, true); @@ -101,7 +123,7 @@ void __UpdateAdhocctlHandlers(int flag, int error) { } u32 sceNetAdhocInit() { - ERROR_LOG(HLE,"UNIMPL sceNetAdhocInit()"); + ERROR_LOG(HLE, "UNIMPL sceNetAdhocInit()"); if (netAdhocInited) return ERROR_NET_ADHOC_ALREADY_INITIALIZED; netAdhocInited = true; @@ -110,19 +132,21 @@ u32 sceNetAdhocInit() { } u32 sceNetAdhocctlInit(int stackSize, int prio, u32 productAddr) { - ERROR_LOG(HLE,"UNIMPL sceNetAdhocctlInit(%i, %i, %08x)", stackSize, prio, productAddr); - if(netAdhocctlInited) + ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlInit(%i, %i, %08x)", stackSize, prio, productAddr); + if (netAdhocctlInited) return ERROR_NET_ADHOCCTL_ALREADY_INITIALIZED; netAdhocctlInited = true; return 0; } + + // Seems to always return 0, and write 0 to the pointer.. // TODO: Eventually research what possible states there are int sceNetAdhocctlGetState(u32 ptrToStatus) { WARN_LOG(HLE, "UNTESTED sceNetAdhocctlGetState(%x)", ptrToStatus); - if(Memory::IsValidAddress(ptrToStatus)) + if (Memory::IsValidAddress(ptrToStatus)) Memory::Write_U32(0, ptrToStatus); else ERROR_LOG(HLE, "UNTESTED sceNetAdhocctlGetState(%x): Tried to write invalid location", ptrToStatus); @@ -141,17 +165,22 @@ int sceNetAdhocctlGetParameter(u32 paramAddr) { WARN_LOG(HLE, "UNTESTED sceNetAdhocctlGetParameter(%x)", paramAddr); struct SceNetAdhocctlParams params; params.channel = 0; - for(int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) params.bssid[i] = i + 1; strcpy(params.name, ""); strcpy(params.nickname, ""); - if(Memory::IsValidAddress(paramAddr)) + if (Memory::IsValidAddress(paramAddr)) Memory::WriteStruct(paramAddr, ¶ms); return ERROR_NET_ADHOCCTL_DISCONNECTED; } +int sceNetAdhocPdpSend(int id, const char *mac, u32 port, void *data, void *dataLength, u32 timeout, int nonBlock) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocPdpSend(%d, %s, %d, %p, %p, %d, %d)", id, mac, port, data, dataLength, timeout, nonBlock); + return -1; +} + // Return -1 packets since we don't have networking yet.. int sceNetAdhocPdpRecv(int id, const char *mac, u32 port, void *data, void *dataLength, u32 timeout, int nonBlock) { ERROR_LOG(HLE, "UNIMPL sceNetAdhocPdpRecv(%d, %s, %d, %p, %p, %d, %d)", id, mac, port, data, dataLength, timeout, nonBlock); @@ -164,6 +193,12 @@ int sceNetAdhocSetSocketAlert(int id, int flag) { return -1; } +int sceNetAdhocPollSocket(u32 socketStructAddr, int count, int timeout, int nonblock) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocPollSocket(%08x, %i, %i, %i)", count, timeout, nonblock); + return -1; +} + + int sceNetAdhocPdpDelete(int id, int unknown) { ERROR_LOG(HLE, "UNIMPL sceNetAdhocPdpDelete(%d, %d)", id, unknown); return 0; @@ -186,18 +221,6 @@ int sceNetAdhocctlGetScanInfo() { return 0; } -int sceNetAdhocctlConnect(u32 ptrToGroupName) { - if (Memory::IsValidAddress(ptrToGroupName)) - { - ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlConnect(groupName=%s)", Memory::GetCharPointer(ptrToGroupName)); - } - else - ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlConnect(%x)", ptrToGroupName); - __UpdateAdhocctlHandlers(0, ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF); - - return 0; -} - // TODO: How many handlers can the PSP actually have for Adhocctl? // TODO: Should we allow the same handler to be added more than once? u32 sceNetAdhocctlAddHandler(u32 handlerPtr, u32 handlerArg) { @@ -212,30 +235,40 @@ u32 sceNetAdhocctlAddHandler(u32 handlerPtr, u32 handlerArg) { handler.entryPoint = handlerPtr; handler.argument = handlerArg; - for(std::map::iterator it = adhocctlHandlers.begin(); it != adhocctlHandlers.end(); it++) { - if(it->second.entryPoint == handlerPtr) { + for (std::map::iterator it = adhocctlHandlers.begin(); it != adhocctlHandlers.end(); it++) { + if (it->second.entryPoint == handlerPtr) { foundHandler = true; break; } } - if(!foundHandler && Memory::IsValidAddress(handlerPtr)) { - if(adhocctlHandlers.size() >= MAX_ADHOCCTL_HANDLERS) { + if (!foundHandler && Memory::IsValidAddress(handlerPtr)) { + if (adhocctlHandlers.size() >= MAX_ADHOCCTL_HANDLERS) { ERROR_LOG(HLE, "UNTESTED UNTESTED sceNetAdhocctlAddHandler(%x, %x): Too many handlers", handlerPtr, handlerArg); retval = ERROR_NET_ADHOCCTL_TOO_MANY_HANDLERS; return retval; } adhocctlHandlers[retval] = handler; WARN_LOG(HLE, "UNTESTED sceNetAdhocctlAddHandler(%x, %x): added handler %d", handlerPtr, handlerArg, retval); - } - else + } else { ERROR_LOG(HLE, "UNTESTED sceNetAdhocctlAddHandler(%x, %x): Same handler already exists", handlerPtr, handlerArg); - + } // The id to return is the number of handlers currently registered return retval; } +int sceNetAdhocctlConnect(u32 ptrToGroupName) { + if (Memory::IsValidAddress(ptrToGroupName)) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlConnect(groupName=%s)", Memory::GetCharPointer(ptrToGroupName)); + } else { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlConnect(%x)", ptrToGroupName); + } + __UpdateAdhocctlHandlers(0, ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF); + + return 0; +} + u32 sceNetAdhocctlDisconnect() { ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlDisconnect()"); __UpdateAdhocctlHandlers(0, ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF); @@ -244,13 +277,12 @@ u32 sceNetAdhocctlDisconnect() { } u32 sceNetAdhocctlDelHandler(u32 handlerID) { - - if(adhocctlHandlers.find(handlerID) != adhocctlHandlers.end()) { + if (adhocctlHandlers.find(handlerID) != adhocctlHandlers.end()) { adhocctlHandlers.erase(handlerID); WARN_LOG(HLE, "UNTESTED sceNetAdhocctlDelHandler(%d): deleted handler %d", handlerID, handlerID); - } - else + } else { ERROR_LOG(HLE, "UNTESTED sceNetAdhocctlDelHandler(%d): asked to delete invalid handler %d", handlerID, handlerID); + } return 0; } @@ -289,33 +321,118 @@ int sceNetAdhocMatchingTerm() { return 0; } +int sceNetAdhocGetPdpStat(int structSize, u32 structAddr) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocGetPdpStat(%i, %08x)", structSize, structAddr); + return 0; +} + +int sceNetAdhocGetPtpStat(int structSize, u32 structAddr) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocGetPtpStat(%i, %08x)", structSize, structAddr); + return 0; +} + +int sceNetAdhocPtpOpen(const char *srcmac, int srcport, const char *dstmac, int dstport, int bufsize, int retryDelay, int retryCount, int unknown) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocPtpOpen(%s : %i, %s : %i, %i, %i, %i)", srcmac, srcport, dstmac, dstport, bufsize, retryDelay, retryCount, unknown); + return 0; +} + +int sceNetAdhocPtpAccept(int id, u32 peerMacAddrPtr, u32 peerPortPtr, int timeout, int nonblock) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocPtpAccept(%i, %08x, %08x, %i, %i)", id, peerMacAddrPtr, peerPortPtr, timeout, nonblock); + return 0; +} + +int sceNetAdhocPtpConnect(int id, int timeout, int nonblock) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocPtpConnect(%i, %i, %i)", id, timeout, nonblock); + return -1; +} + +int sceNetAdhocPtpClose(int id, int unknown) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocPtpClose(%i, %i)", id, unknown); + return 0; +} + +int sceNetAdhocPtpListen(const char *srcmac, int srcport, int bufsize, int retryDelay, int retryCount, int queue, int unk) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocPtpListen(%s : %i, %i, %i, %i, %i, %i)", srcmac, srcport, bufsize, retryDelay, retryCount, queue, unk); + return 0; +} + +int sceNetAdhocPtpSend(int id, u32 data, u32 dataSizeAddr, int timeout, int nonblock) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocPtpSend(%i, %08x, %08x, %i, %i)", id, data, dataSizeAddr, timeout, nonblock); + return 0; +} + +int sceNetAdhocPtpRecv(int id, u32 data, u32 dataSizeAddr, int timeout, int nonblock) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocPtpRecv(%i, %08x, %08x, %i, %i)", id, data, dataSizeAddr, timeout, nonblock); + return 0; +} + +int sceNetAdhocPtpFlush(int id, int timeout, int nonblock) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocPtpFlush(%i, %i, %i)", id, timeout, nonblock); + return 0; +} + +int sceNetAdhocGameModeCreateMaster(u32 data, int size) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocGameModeCreateMaster(%08x, %i)", data, size); + return -1; +} + +int sceNetAdhocGameModeCreateReplica(const char *mac, u32 data, int size) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocGameModeCreateReplica(%s, %08x, %i)", mac, data, size); + return -1; +} + +int sceNetAdhocGameModeUpdateMaster() { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocGameModeUpdateMaster()"); + return -1; +} + +int sceNetAdhocGameModeDeleteMaster() { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocGameModeDeleteMaster()"); + return -1; +} + +int sceNetAdhocGameModeUpdateReplica(int id, u32 infoAddr) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocGameModeUpdateReplica(%i, %08x)", id, infoAddr); + return -1; +} + +int sceNetAdhocGameModeDeleteReplica(int id) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocGameModeDeleteReplica(%i)", id); + return -1; +} + +int sceNetAdhocGetSocketAlert() { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocGetSocketAlert()"); + return 0; +} + const HLEFunction sceNetAdhoc[] = { {0xE1D621D7, WrapU_V, "sceNetAdhocInit"}, {0xA62C6F57, WrapI_V, "sceNetAdhocTerm"}, - {0x0AD043ED, 0, "sceNetAdhocctlConnect"}, + {0x0AD043ED, WrapI_U, "sceNetAdhocctlConnect"}, {0x6f92741b, WrapI_CUIU, "sceNetAdhocPdpCreate"}, - {0xabed3790, 0, "sceNetAdhocPdpSend"}, + {0xabed3790, WrapI_ICUVVUI, "sceNetAdhocPdpSend"}, {0xdfe53e03, WrapI_ICUVVUI, "sceNetAdhocPdpRecv"}, {0x7f27bb5e, WrapI_II, "sceNetAdhocPdpDelete"}, - {0xc7c1fc57, 0, "sceNetAdhocGetPdpStat"}, - {0x157e6225, 0, "sceNetAdhocPtpClose"}, - {0x4da4c788, 0, "sceNetAdhocPtpSend"}, - {0x877f6d66, 0, "sceNetAdhocPtpOpen"}, - {0x8bea2b3e, 0, "sceNetAdhocPtpRecv"}, - {0x9df81198, 0, "sceNetAdhocPtpAccept"}, - {0xe08bdac1, 0, "sceNetAdhocPtpListen"}, - {0xfc6fc07b, 0, "sceNetAdhocPtpConnect"}, - {0x9ac2eeac, 0, "sceNetAdhocPtpFlush"}, - {0xb9685118, 0, "sceNetAdhocGetPtpStat"}, - {0x3278ab0c, 0, "sceNetAdhocGameModeCreateReplica"}, - {0x98c204c8, 0, "sceNetAdhocGameModeUpdateMaster"}, - {0xfa324b4e, 0, "sceNetAdhocGameModeUpdateReplica"}, - {0xa0229362, 0, "sceNetAdhocGameModeDeleteMaster"}, - {0x0b2228e9, 0, "sceNetAdhocGameModeDeleteReplica"}, - {0x7F75C338, 0, "sceNetAdhocGameModeCreateMaster"}, + {0xc7c1fc57, WrapI_IU, "sceNetAdhocGetPdpStat"}, + {0x157e6225, WrapI_II, "sceNetAdhocPtpClose"}, + {0x4da4c788, WrapI_IUUII, "sceNetAdhocPtpSend"}, + {0x877f6d66, WrapI_CICIIIII, "sceNetAdhocPtpOpen"}, + {0x8bea2b3e, WrapI_IUUII, "sceNetAdhocPtpRecv"}, + {0x9df81198, WrapI_IUUII, "sceNetAdhocPtpAccept"}, + {0xe08bdac1, WrapI_CIIIIII, "sceNetAdhocPtpListen"}, + {0xfc6fc07b, WrapI_III, "sceNetAdhocPtpConnect"}, + {0x9ac2eeac, WrapI_III, "sceNetAdhocPtpFlush"}, + {0xb9685118, WrapI_IU, "sceNetAdhocGetPtpStat"}, + {0x3278ab0c, WrapI_CUI, "sceNetAdhocGameModeCreateReplica"}, + {0x98c204c8, WrapI_V, "sceNetAdhocGameModeUpdateMaster"}, + {0xfa324b4e, WrapI_IU, "sceNetAdhocGameModeUpdateReplica"}, + {0xa0229362, WrapI_V, "sceNetAdhocGameModeDeleteMaster"}, + {0x0b2228e9, WrapI_I, "sceNetAdhocGameModeDeleteReplica"}, + {0x7F75C338, WrapI_UI, "sceNetAdhocGameModeCreateMaster"}, {0x73bfd52d, WrapI_II, "sceNetAdhocSetSocketAlert"}, - {0x7a662d6b, 0, "sceNetAdhocPollSocket"}, - {0x4d2ce199, 0, "sceNetAdhocGetSocketAlert"}, + {0x4d2ce199, WrapI_V, "sceNetAdhocGetSocketAlert"}, + {0x7a662d6b, WrapI_UIII, "sceNetAdhocPollSocket"}, }; const HLEFunction sceNetAdhocMatching[] = {