mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-15 02:29:51 +01:00
Merge branch 'master' into TemporaryHackishBranch
# Conflicts: # UI/DevScreens.cpp # UI/GameSettingsScreen.cpp
This commit is contained in:
commit
1f961b6c82
36 files changed
+996
-754
No files matched your search
+2
-6
@@ -42,18 +42,14 @@ double time_now_d() {
|
||||
|
||||
#else
|
||||
|
||||
static uint64_t _frequency = 0;
|
||||
static uint64_t _starttime = 0;
|
||||
|
||||
double time_now_d() {
|
||||
static time_t start;
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
gettimeofday(&tv, nullptr);
|
||||
if (start == 0) {
|
||||
start = tv.tv_sec;
|
||||
}
|
||||
tv.tv_sec -= start;
|
||||
return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0;
|
||||
return (double)(tv.tv_sec - start) + (double)tv.tv_usec * (1.0 / 1000000.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+3
-1
@@ -988,8 +988,9 @@ static ConfigSetting networkSettings[] = {
|
||||
ConfigSetting("PortOffset", &g_Config.iPortOffset, 0, true, true),
|
||||
ConfigSetting("MinTimeout", &g_Config.iMinTimeout, 1, true, true),
|
||||
ConfigSetting("TCPNoDelay", &g_Config.bTCPNoDelay, false, true, true),
|
||||
ConfigSetting("ForcedFirstConnect", &g_Config.bForcedFirstConnect, false, true, true),
|
||||
ConfigSetting("EnableUPnP", &g_Config.bEnableUPnP, false, true, true),
|
||||
ConfigSetting("UPnPUseOriginalPort", &g_Config.bUPnPUseOriginalPort, true, true, true),
|
||||
ConfigSetting("UPnPUseOriginalPort", &g_Config.bUPnPUseOriginalPort, false, true, true),
|
||||
|
||||
ConfigSetting("EnableNetworkChat", &g_Config.bEnableNetworkChat, false, true, true),
|
||||
ConfigSetting("ChatButtonPosition",&g_Config.iChatButtonPosition,BOTTOM_LEFT,true,true),
|
||||
@@ -1048,6 +1049,7 @@ static ConfigSetting systemParamSettings[] = {
|
||||
ConfigSetting("WlanPowerSave", &g_Config.bWlanPowerSave, (bool) PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF, true, true),
|
||||
ReportedConfigSetting("EncryptSave", &g_Config.bEncryptSave, true, true, true),
|
||||
ConfigSetting("SavedataUpgradeVersion", &g_Config.bSavedataUpgrade, true, true, false),
|
||||
ConfigSetting("MemStickSize", &g_Config.iMemStickSizeGB, 16, true, false),
|
||||
|
||||
ConfigSetting(false),
|
||||
};
|
||||
|
||||
@@ -130,6 +130,7 @@ public:
|
||||
std::string sRemoteISOSubdir;
|
||||
bool bRemoteDebuggerOnStartup;
|
||||
bool bMemStickInserted;
|
||||
int iMemStickSizeGB;
|
||||
bool bLoadPlugins;
|
||||
|
||||
int iScreenRotation; // The rotation angle of the PPSSPP UI. Only supported on Android and possibly other mobile platforms.
|
||||
@@ -433,6 +434,7 @@ public:
|
||||
bool bTCPNoDelay;
|
||||
bool bEnableUPnP;
|
||||
bool bUPnPUseOriginalPort;
|
||||
bool bForcedFirstConnect;
|
||||
int iPortOffset;
|
||||
int iMinTimeout;
|
||||
int iWlanAdhocChannel;
|
||||
|
||||
@@ -44,9 +44,8 @@
|
||||
static const float FONT_SCALE = 0.65f;
|
||||
|
||||
// Needs testing.
|
||||
const static int NET_INIT_DELAY_US = 300000;
|
||||
const static int NET_SHUTDOWN_DELAY_US = 260000;
|
||||
const static int NET_RUNNING_DELAY_US = 1000000; // KHBBS is showing adhoc dialog for about 3-4 seconds, but feels too long, so we're faking it to 1 sec instead to let players read the text
|
||||
const static int NET_INIT_DELAY_US = 200000;
|
||||
const static int NET_SHUTDOWN_DELAY_US = 200000;
|
||||
const static int NET_CONNECT_TIMEOUT = 15000000; // Using 15 secs to match the timeout on Adhoc Server side (SERVER_USER_TIMEOUT)
|
||||
|
||||
struct ScanInfos {
|
||||
@@ -306,27 +305,24 @@ int PSPNetconfDialog::Update(int animSpeed) {
|
||||
}
|
||||
DisplayButtons(DS_BUTTON_CANCEL, di->T("Cancel"));
|
||||
|
||||
// The Netconf dialog stays visible until the network reaches
|
||||
// the state PSP_NET_APCTL_STATE_GOT_IP.
|
||||
// The Netconf dialog stays visible until the network reaches the state PSP_NET_APCTL_STATE_GOT_IP.
|
||||
if (state == PSP_NET_APCTL_STATE_GOT_IP) {
|
||||
if (pendingStatus != SCE_UTILITY_STATUS_FINISHED) {
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, NET_RUNNING_DELAY_US);
|
||||
}
|
||||
else if (GetStatus() == SCE_UTILITY_STATUS_FINISHED) {
|
||||
// We are done!
|
||||
StartFade(false);
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, NET_SHUTDOWN_DELAY_US);
|
||||
}
|
||||
}
|
||||
|
||||
else if (state == PSP_NET_APCTL_STATE_GETTING_IP) {
|
||||
else if (state == PSP_NET_APCTL_STATE_JOINING) {
|
||||
// Switch to the next message
|
||||
StartFade(true);
|
||||
}
|
||||
|
||||
else if (state == PSP_NET_APCTL_STATE_DISCONNECTED) {
|
||||
// When connecting with infrastructure, simulate a connection
|
||||
// using the first network configuration entry.
|
||||
connResult = sceNetApctlConnect(1);
|
||||
// When connecting with infrastructure, simulate a connection using the first network configuration entry.
|
||||
if (connResult < 0) {
|
||||
connResult = sceNetApctlConnect(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,17 +438,14 @@ int PSPNetconfDialog::Update(int animSpeed) {
|
||||
}
|
||||
}
|
||||
|
||||
// The Netconf dialog stays visible until the network reaches
|
||||
// the state ADHOCCTL_STATE_CONNECTED.
|
||||
// The Netconf dialog stays visible until the network reaches the state ADHOCCTL_STATE_CONNECTED.
|
||||
if (state == ADHOCCTL_STATE_CONNECTED) {
|
||||
// Checking pendingStatus to make sure ChangeStatus not to continously extending the delay ticks on every call for eternity
|
||||
if (pendingStatus != SCE_UTILITY_STATUS_FINISHED) {
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, NET_RUNNING_DELAY_US);
|
||||
}
|
||||
// Start fading only when the actual status has changed
|
||||
else if (GetStatus() == SCE_UTILITY_STATUS_FINISHED) {
|
||||
StartFade(false);
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, NET_SHUTDOWN_DELAY_US);
|
||||
}
|
||||
|
||||
// Let's not leaks any memory
|
||||
if (Memory::IsValidAddress(scanInfosAddr))
|
||||
userMemory.Free(scanInfosAddr);
|
||||
|
||||
@@ -1417,7 +1417,7 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param)
|
||||
saveDataListCount = (int)allSaves.size();
|
||||
saveDataList = new SaveFileInfo[saveDataListCount];
|
||||
for (auto save : allSaves) {
|
||||
if (save.name == "." || save.name == "..")
|
||||
if (save.type != FILETYPE_DIRECTORY || save.name == "." || save.name == "..")
|
||||
continue;
|
||||
std::string fileDataDir = savePath + save.name;
|
||||
PSPFileInfo info = pspFileSystem.GetFileInfo(fileDataDir);
|
||||
|
||||
@@ -669,3 +669,17 @@ void MetaFileSystem::DoState(PointerWrap &p)
|
||||
}
|
||||
}
|
||||
|
||||
u64 MetaFileSystem::getDirSize(const std::string &dirPath) {
|
||||
u64 result = 0;
|
||||
auto allFiles = GetDirListing(dirPath);
|
||||
for (auto file : allFiles) {
|
||||
if (file.name == "." || file.name == "..")
|
||||
continue;
|
||||
if (file.type == FILETYPE_DIRECTORY) {
|
||||
result += getDirSize(dirPath + file.name + "/");
|
||||
} else {
|
||||
result += file.size;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -129,4 +129,6 @@ public:
|
||||
std::lock_guard<std::recursive_mutex> guard(lock);
|
||||
startingDirectory = dir;
|
||||
}
|
||||
|
||||
u64 getDirSize(const std::string &dirPath);
|
||||
};
|
||||
+14
-11
@@ -123,12 +123,15 @@ bool isPDPPortInUse(uint16_t port) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isPTPPortInUse(uint16_t port) {
|
||||
bool isPTPPortInUse(uint16_t port, bool forListen) {
|
||||
// Iterate Sockets
|
||||
for (int i = 0; i < MAX_SOCKET; i++) {
|
||||
auto sock = adhocSockets[i];
|
||||
if (sock != NULL && sock->type == SOCK_PTP)
|
||||
if (sock->data.ptp.lport == port)
|
||||
// It's allowed to Listen and Open the same PTP port, But it's not allowed to Listen or Open the same PTP port twice.
|
||||
if (sock->data.ptp.lport == port &&
|
||||
((forListen && sock->data.ptp.state == ADHOC_PTP_STATE_LISTEN) ||
|
||||
(!forListen && sock->data.ptp.state != ADHOC_PTP_STATE_LISTEN)))
|
||||
return true;
|
||||
}
|
||||
// Unused Port
|
||||
@@ -1412,7 +1415,7 @@ int friendFinder(){
|
||||
getLocalMac(&localMac);
|
||||
if (std::find_if(gameModeMacs.begin(), gameModeMacs.end(),
|
||||
[localMac](SceNetEtherAddr const& e) {
|
||||
return IsMatch(e, localMac);
|
||||
return isMacMatch(&e, &localMac);
|
||||
}) == gameModeMacs.end()) {
|
||||
// Arrange the order to be consistent on all players (Host on top), Starting from our self the rest of new players will be added to the back
|
||||
gameModeMacs.push_back(localMac);
|
||||
@@ -1501,14 +1504,14 @@ int friendFinder(){
|
||||
if (adhocctlCurrentMode == ADHOCCTL_MODE_GAMEMODE) {
|
||||
if (std::find_if(gameModeMacs.begin(), gameModeMacs.end(),
|
||||
[packet](SceNetEtherAddr const& e) {
|
||||
return IsMatch(e, packet->mac);
|
||||
return isMacMatch(&e, &packet->mac);
|
||||
}) == gameModeMacs.end()) {
|
||||
// Arrange the order to be consistent on all players (Host on top), Existing players are sent in reverse by AdhocServer
|
||||
SceNetEtherAddr localMac;
|
||||
getLocalMac(&localMac);
|
||||
auto it = std::find_if(gameModeMacs.begin(), gameModeMacs.end(),
|
||||
[localMac](SceNetEtherAddr const& e) {
|
||||
return IsMatch(e, localMac);
|
||||
return isMacMatch(&e, &localMac);
|
||||
});
|
||||
// Starting from our self the rest of new players will be added to the back
|
||||
if (it != gameModeMacs.end()) {
|
||||
@@ -1572,8 +1575,8 @@ int friendFinder(){
|
||||
/*if (adhocctlCurrentMode == ADHOCCTL_MODE_GAMEMODE) {
|
||||
auto peer = findFriendByIP(packet->ip);
|
||||
gameModeMacs.erase(std::remove_if(gameModeMacs.begin(), gameModeMacs.end(),
|
||||
[peer](auto const& e) {
|
||||
return IsMatch(e, peer->mac_addr);
|
||||
[peer](SceNetEtherAddr const& e) {
|
||||
return isMacMatch(&e, &peer->mac_addr);
|
||||
}), gameModeMacs.end());
|
||||
}*/
|
||||
|
||||
@@ -1985,7 +1988,7 @@ int getNicknameCount(const char * nickname)
|
||||
for (; peer != NULL; peer = peer->next)
|
||||
{
|
||||
// Match found
|
||||
if (strncmp((char *)&peer->nickname.data, nickname, ADHOCCTL_NICKNAME_LEN) == 0) count++;
|
||||
if (peer->last_recv != 0 && strncmp((char *)&peer->nickname.data, nickname, ADHOCCTL_NICKNAME_LEN) == 0) count++;
|
||||
}
|
||||
|
||||
// Return Result
|
||||
@@ -2078,9 +2081,9 @@ int initNetwork(SceNetAdhocctlAdhocId *adhoc_id){
|
||||
errorcode = errno;
|
||||
|
||||
if (iResult == SOCKET_ERROR && errorcode != EISCONN) {
|
||||
u64 startTime = (u64)(time_now_d() * 1000.0);
|
||||
u64 startTime = (u64)(time_now_d() * 1000000.0);
|
||||
while (IsSocketReady(metasocket, false, true) <= 0) {
|
||||
u64 now = (u64)(time_now_d() * 1000.0);
|
||||
u64 now = (u64)(time_now_d() * 1000000.0);
|
||||
if (coreState == CORE_POWERDOWN) return iResult;
|
||||
if (now - startTime > adhocDefaultTimeout) break;
|
||||
sleep_ms(10);
|
||||
@@ -2102,7 +2105,7 @@ int initNetwork(SceNetAdhocctlAdhocId *adhoc_id){
|
||||
packet.name.data[ADHOCCTL_NICKNAME_LEN - 1] = 0;
|
||||
memcpy(packet.game.data, adhoc_id->data, ADHOCCTL_ADHOCID_LEN);
|
||||
|
||||
IsSocketReady(metasocket, false, true, nullptr, adhocDefaultTimeout * 1000);
|
||||
IsSocketReady(metasocket, false, true, nullptr, adhocDefaultTimeout);
|
||||
int sent = send(metasocket, (char*)&packet, sizeof(packet), MSG_NOSIGNAL);
|
||||
if (sent > 0) {
|
||||
socklen_t addrLen = sizeof(LocalIP);
|
||||
|
||||
+23
-14
@@ -56,6 +56,7 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
#undef errno
|
||||
#undef ESHUTDOWN
|
||||
#undef ECONNABORTED
|
||||
#undef ECONNRESET
|
||||
#undef ENOTCONN
|
||||
@@ -65,6 +66,7 @@
|
||||
#undef EALREADY
|
||||
#undef ETIMEDOUT
|
||||
#define errno WSAGetLastError()
|
||||
#define ESHUTDOWN WSAESHUTDOWN
|
||||
#define ECONNABORTED WSAECONNABORTED
|
||||
#define ECONNRESET WSAECONNRESET
|
||||
#define ENOTCONN WSAENOTCONN
|
||||
@@ -74,11 +76,13 @@
|
||||
#define EALREADY WSAEALREADY
|
||||
#define ETIMEDOUT WSAETIMEDOUT
|
||||
inline bool connectInProgress(int errcode){ return (errcode == WSAEWOULDBLOCK || errcode == WSAEINPROGRESS || errcode == WSAEALREADY); }
|
||||
inline bool isDisconnected(int errcode) { return (errcode == WSAECONNRESET || errcode == WSAECONNABORTED || errcode == WSAESHUTDOWN); }
|
||||
#else
|
||||
#define INVALID_SOCKET -1
|
||||
#define SOCKET_ERROR -1
|
||||
#define closesocket close
|
||||
inline bool connectInProgress(int errcode){ return (errcode == EAGAIN || errcode == EWOULDBLOCK || errcode == EINPROGRESS || errcode == EALREADY); }
|
||||
inline bool isDisconnected(int errcode) { return (errcode == EPIPE || errcode == ECONNRESET || errcode == ECONNABORTED || errcode == ESHUTDOWN); }
|
||||
#endif
|
||||
|
||||
#ifndef POLL_ERR
|
||||
@@ -104,11 +108,9 @@ inline bool connectInProgress(int errcode){ return (errcode == EAGAIN || errcode
|
||||
// Server Listening Port
|
||||
#define SERVER_PORT 27312
|
||||
|
||||
// Default GameMode Port
|
||||
// Default GameMode definitions
|
||||
#define ADHOC_GAMEMODE_PORT 31000
|
||||
|
||||
#define GAMEMODE_UPDATE_INTERVAL 12000 // usec, based on JPCSP
|
||||
#define GAMEMODE_BUFFER_SIZE 0x8000
|
||||
#define GAMEMODE_UPDATE_INTERVAL 10000 // 12000 usec on JPCSP, but 10000 works better on BattleZone (in order to get full speed 60 FPS)
|
||||
|
||||
// psp strutcs and definitions
|
||||
#define ADHOCCTL_MODE_NONE -1
|
||||
@@ -156,15 +158,15 @@ inline bool connectInProgress(int errcode){ return (errcode == EAGAIN || errcode
|
||||
#define ADHOC_EV_CONNECT 0x0004
|
||||
#define ADHOC_EV_ACCEPT 0x0008
|
||||
#define ADHOC_EV_FLUSH 0x0010
|
||||
#define ADHOC_EV_INVALID 0x0100
|
||||
#define ADHOC_EV_DELETE 0x0200
|
||||
#define ADHOC_EV_INVALID 0x0100 // ignored on events but can be raised on revents? similar to POLLNVAL on posix poll?
|
||||
#define ADHOC_EV_DELETE 0x0200 // ignored on events but can be raised on revents? similar to POLLERR on posix poll?
|
||||
#define ADHOC_EV_ALERT 0x0400
|
||||
#define ADHOC_EV_DISCONNECT 0x0800
|
||||
#define ADHOC_EV_DISCONNECT 0x0800 // ignored on events but can be raised on revents? similar to POLLHUP on posix poll?
|
||||
|
||||
// PTP Connection States
|
||||
#define ADHOC_PTP_STATE_CLOSED 0
|
||||
#define ADHOC_PTP_STATE_LISTEN 1
|
||||
#define ADHOC_PTP_STATE_SYN_SENT 2
|
||||
#define ADHOC_PTP_STATE_SYN_SENT 2 // 3-way handshake normally: [client]send SYN -> [server]recv SYN and reply with ACK+SYN -> [client]recv SYN and reply with ACK -> Established
|
||||
#define ADHOC_PTP_STATE_SYN_RCVD 3
|
||||
#define ADHOC_PTP_STATE_ESTABLISHED 4
|
||||
|
||||
@@ -209,9 +211,9 @@ extern uint8_t broadcastMAC[ETHER_ADDR_LEN];
|
||||
|
||||
// Malloc Pool Information
|
||||
typedef struct SceNetMallocStat {
|
||||
s32_le pool; // Pointer to the pool? // This should be the poolSize isn't?
|
||||
s32_le maximum; // Maximum size of the pool? Maximum usage (ie. pool- free) ?
|
||||
s32_le free; // How much memory is free
|
||||
s32_le pool; // On Vantage Master Portable this is 0x1ffe0 on sceNetGetMallocStat, while the poolSize arg on sceNetInit was 0x20000
|
||||
s32_le maximum; // On Vantage Master Portable this is 0x4050, Footprint of Highest amount allocated so far?
|
||||
s32_le free; // On Vantage Master Portable this is 0x1f300, VMP compares this value with required size before sending data
|
||||
} PACK SceNetMallocStat;
|
||||
|
||||
// Adhoc Virtual Network Name
|
||||
@@ -303,6 +305,7 @@ typedef struct SceNetAdhocctlGameModeInfo {
|
||||
|
||||
// GameModeUpdateInfo
|
||||
typedef struct GameModeUpdateInfo {
|
||||
u32_le length; //size of GameModeUpdateInfo (16 bytes)
|
||||
s32_le updated;
|
||||
u64_le timeStamp;
|
||||
} PACK GameModeUpdateInfo;
|
||||
@@ -353,10 +356,14 @@ typedef struct AdhocSocket {
|
||||
s32_le type; // SOCK_PDP/SOCK_PTP
|
||||
s32_le flags; // Socket Alert Flags
|
||||
s32_le alerted_flags; // Socket Alerted Flags
|
||||
s32_le nonblocking; // last non-blocking flag
|
||||
u32 buffer_size;
|
||||
u32 send_timeout; // default connect timeout
|
||||
u32 recv_timeout; // default accept timeout
|
||||
s32 retry_count; // combined with timeout to be used on keepalive
|
||||
s32 retry_interval; // related to keepalive
|
||||
s32 retry_count; // multiply with retry interval to be used as keepalive timeout
|
||||
s32 attemptCount; // connect/accept attempts
|
||||
u64 lastAttempt; // timestamp to retry again
|
||||
union {
|
||||
SceNetAdhocPdpStat pdp;
|
||||
SceNetAdhocPtpStat ptp;
|
||||
@@ -943,12 +950,14 @@ bool isLocalMAC(const SceNetEtherAddr * addr);
|
||||
bool isPDPPortInUse(uint16_t port);
|
||||
|
||||
/**
|
||||
* Check whether PTP Port is in use or not
|
||||
* Check whether PTP Port is in use or not (only sockets with non-Listening state will be considered as in use)
|
||||
* @param port To-be-checked Port Number
|
||||
* @param forListen to check for listening or non-listening port
|
||||
* @return 1 if in use or... 0
|
||||
*/
|
||||
bool isPTPPortInUse(uint16_t port);
|
||||
bool isPTPPortInUse(uint16_t port, bool forListen);
|
||||
|
||||
// Convert MAC address to string
|
||||
std::string mac2str(SceNetEtherAddr* mac);
|
||||
|
||||
/*
|
||||
|
||||
@@ -619,6 +619,9 @@ static void DoFrameTiming(bool &throttle, bool &skipFrame, float timestep) {
|
||||
skipFrame = true;
|
||||
}
|
||||
|
||||
// TODO: This is NOT where we should wait, really! We should mark each outgoing frame with the desired
|
||||
// timestamp to push it to display, and sleep in the render thread to achieve that.
|
||||
|
||||
if (curFrameTime < nextFrameTime && throttle) {
|
||||
// If time gap is huge just jump (somebody unthrottled)
|
||||
if (nextFrameTime - curFrameTime > 2*scaledTimestep) {
|
||||
|
||||
+122
-63
@@ -68,6 +68,7 @@ u32 netApctlState;
|
||||
u32 apctlThreadHackAddr = 0;
|
||||
u32_le apctlThreadCode[3];
|
||||
SceUID apctlThreadID = 0;
|
||||
int apctlStateEvent = -1;
|
||||
int actionAfterApctlMipsCall;
|
||||
std::recursive_mutex apctlEvtMtx;
|
||||
std::deque<ApctlArgs> apctlEvents;
|
||||
@@ -125,10 +126,47 @@ void InitLocalhostIP() {
|
||||
isLocalServer = (!strcasecmp(serverStr.c_str(), "localhost") || serverStr.find("127.") == 0);
|
||||
}
|
||||
|
||||
static void __ApctlState(u64 userdata, int cyclesLate) {
|
||||
SceUID threadID = userdata >> 32;
|
||||
int uid = (int)(userdata & 0xFFFFFFFF);
|
||||
int event = uid - 1;
|
||||
|
||||
s64 result = 0;
|
||||
u32 error = 0;
|
||||
|
||||
SceUID waitID = __KernelGetWaitID(threadID, WAITTYPE_NET, error);
|
||||
if (waitID == 0 || error != 0)
|
||||
return;
|
||||
|
||||
u32 waitVal = __KernelGetWaitValue(threadID, error);
|
||||
if (error == 0) {
|
||||
netApctlState = waitVal;
|
||||
}
|
||||
|
||||
__KernelResumeThreadFromWait(threadID, result);
|
||||
DEBUG_LOG(SCENET, "Returning (WaitID: %d, error: %d) Result (%08x) of sceNetApctl - Event: %d, State: %d", waitID, error, (int)result, event, netApctlState);
|
||||
}
|
||||
|
||||
// Used to change Apctl State after a delay and before executing callback mipscall (since we don't have beforeAction)
|
||||
int ScheduleApctlState(int event, int newState, int usec, const char* reason) {
|
||||
int uid = event + 1;
|
||||
|
||||
if (apctlStateEvent < 0)
|
||||
apctlStateEvent = CoreTiming::RegisterEvent("__ApctlState", __ApctlState);
|
||||
|
||||
u64 param = ((u64)__KernelGetCurThread()) << 32 | uid;
|
||||
CoreTiming::ScheduleEvent(usToCycles(usec), apctlStateEvent, param);
|
||||
__KernelWaitCurThread(WAITTYPE_NET, uid, newState, 0, false, reason);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __NetApctlInit() {
|
||||
netApctlInited = false;
|
||||
netApctlState = PSP_NET_APCTL_STATE_DISCONNECTED;
|
||||
apctlStateEvent = CoreTiming::RegisterEvent("__ApctlState", __ApctlState);
|
||||
apctlHandlers.clear();
|
||||
apctlEvents.clear();
|
||||
memset(&netApctlInfo, 0, sizeof(netApctlInfo));
|
||||
}
|
||||
|
||||
@@ -182,6 +220,8 @@ void __NetApctlShutdown() {
|
||||
kernelMemory.Free(apctlThreadHackAddr);
|
||||
apctlThreadHackAddr = 0;
|
||||
}
|
||||
apctlHandlers.clear();
|
||||
apctlEvents.clear();
|
||||
}
|
||||
|
||||
void __NetShutdown() {
|
||||
@@ -216,7 +256,7 @@ void netValidateLoopMemory() {
|
||||
|
||||
// This feels like a dubious proposition, mostly...
|
||||
void __NetDoState(PointerWrap &p) {
|
||||
auto s = p.Section("sceNet", 1, 4);
|
||||
auto s = p.Section("sceNet", 1, 5);
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
@@ -260,6 +300,15 @@ void __NetDoState(PointerWrap &p) {
|
||||
apctlThreadHackAddr = 0;
|
||||
apctlThreadID = 0;
|
||||
}
|
||||
if (s >= 5) {
|
||||
Do(p, apctlStateEvent);
|
||||
if (apctlStateEvent != -1) {
|
||||
CoreTiming::RestoreRegisterEvent(apctlStateEvent, "__ApctlState", __ApctlState);
|
||||
}
|
||||
}
|
||||
else {
|
||||
apctlStateEvent = -1;
|
||||
}
|
||||
|
||||
if (p.mode == p.MODE_READ) {
|
||||
// Let's not change "Inited" value when Loading SaveState in the middle of multiplayer to prevent memory & port leaks
|
||||
@@ -370,78 +419,106 @@ std::string error2str(u32 errorCode) {
|
||||
void __NetApctlCallbacks()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> apctlGuard(apctlEvtMtx);
|
||||
hleSkipDeadbeef();
|
||||
int delayus = 10000;
|
||||
|
||||
// We are temporarily borrowing APctl thread for NpAuth callbacks for testing to simulate authentication
|
||||
if (!npAuthEvents.empty())
|
||||
{
|
||||
auto args = npAuthEvents.front();
|
||||
auto& id = args.data[0];
|
||||
auto& result = args.data[1];
|
||||
auto& argAddr = args.data[2];
|
||||
npAuthEvents.pop_front();
|
||||
|
||||
delayus = (adhocEventDelay + adhocExtraDelay);
|
||||
|
||||
int handlerID = id - 1;
|
||||
for (std::map<int, NpAuthHandler>::iterator it = npAuthHandlers.begin(); it != npAuthHandlers.end(); ++it) {
|
||||
if (it->first == handlerID) {
|
||||
DEBUG_LOG(SCENET, "NpAuthCallback [HandlerID=%i][RequestID=%d][Result=%d][ArgsPtr=%08x]", it->first, id, result, it->second.argument);
|
||||
// TODO: Update result / args.data[1] with the actual ticket length (or error code?)
|
||||
hleEnqueueCall(it->second.entryPoint, 3, args.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// How AP works probably like this: Game use sceNetApctl function -> sceNetApctl let the hardware know and do their's thing and have a new State -> Let the game know the resulting State through Event on their handler
|
||||
if (!apctlEvents.empty())
|
||||
{
|
||||
auto args = apctlEvents.front();
|
||||
auto oldState = &args.data[0];
|
||||
auto newState = &args.data[1];
|
||||
auto event = &args.data[2];
|
||||
auto error = &args.data[3];
|
||||
auto& oldState = args.data[0];
|
||||
auto& newState = args.data[1];
|
||||
auto& event = args.data[2];
|
||||
auto& error = args.data[3];
|
||||
apctlEvents.pop_front();
|
||||
|
||||
// Adjust delay according to current event. Added an extra delay to prevent I/O Timing method from causing disconnection
|
||||
if (*event == PSP_NET_APCTL_EVENT_CONNECT_REQUEST || *event == PSP_NET_APCTL_EVENT_GET_IP || *event == PSP_NET_APCTL_EVENT_SCAN_REQUEST)
|
||||
delayus = (adhocEventDelayMS + 2 * adhocExtraPollDelayMS) * 1000;
|
||||
// Adjust delay according to current event.
|
||||
if (event == PSP_NET_APCTL_EVENT_CONNECT_REQUEST || event == PSP_NET_APCTL_EVENT_GET_IP || event == PSP_NET_APCTL_EVENT_SCAN_REQUEST)
|
||||
delayus = adhocEventDelay;
|
||||
else
|
||||
delayus = (adhocEventPollDelayMS + 2 * adhocExtraPollDelayMS) * 1000;
|
||||
delayus = adhocEventPollDelay;
|
||||
|
||||
// Do we need to change the oldState? even if there was error?
|
||||
//if (*error == 0)
|
||||
*oldState = netApctlState;
|
||||
//if (error == 0)
|
||||
// oldState = netApctlState;
|
||||
|
||||
// Need to make sure netApctlState is updated before calling the callback's mipscall so the game can GetState()/GetInfo() within their handler's subroutine and make use the new State/Info
|
||||
// Should we update NewState & Error accordingly to Event before executing the mipscall ? sceNetApctl* functions might want to set the error value tho, so we probably should leave it untouched
|
||||
//*error = 0;
|
||||
switch (*event) {
|
||||
// Should we update NewState & Error accordingly to Event before executing the mipscall ? sceNetApctl* functions might want to set the error value tho, so we probably should leave it untouched, right?
|
||||
//error = 0;
|
||||
switch (event) {
|
||||
case PSP_NET_APCTL_EVENT_CONNECT_REQUEST:
|
||||
netApctlState = PSP_NET_APCTL_STATE_JOINING; // Should we set the State to PSP_NET_APCTL_STATE_DISCONNECTED if there was error?
|
||||
if (*error == 0) apctlEvents.push_front({ netApctlState, netApctlState, PSP_NET_APCTL_EVENT_ESTABLISHED, 0 }); // Should we use PSP_NET_APCTL_EVENT_EAP_AUTH if securityType is not NONE?
|
||||
newState = PSP_NET_APCTL_STATE_JOINING; // Should we set the State to PSP_NET_APCTL_STATE_DISCONNECTED if there was error?
|
||||
if (error == 0)
|
||||
apctlEvents.push_front({ newState, newState, PSP_NET_APCTL_EVENT_ESTABLISHED, 0 }); // Should we use PSP_NET_APCTL_EVENT_EAP_AUTH if securityType is not NONE?
|
||||
break;
|
||||
|
||||
case PSP_NET_APCTL_EVENT_ESTABLISHED:
|
||||
netApctlState = PSP_NET_APCTL_STATE_GETTING_IP;
|
||||
if (*error == 0) apctlEvents.push_front({ netApctlState, netApctlState, PSP_NET_APCTL_EVENT_GET_IP, 0 });
|
||||
newState = PSP_NET_APCTL_STATE_GETTING_IP;
|
||||
if (error == 0)
|
||||
apctlEvents.push_front({ newState, newState, PSP_NET_APCTL_EVENT_GET_IP, 0 });
|
||||
break;
|
||||
|
||||
case PSP_NET_APCTL_EVENT_GET_IP:
|
||||
netApctlState = PSP_NET_APCTL_STATE_GOT_IP;
|
||||
newState = PSP_NET_APCTL_STATE_GOT_IP;
|
||||
NetApctl_InitInfo();
|
||||
break;
|
||||
|
||||
case PSP_NET_APCTL_EVENT_DISCONNECT_REQUEST:
|
||||
netApctlState = PSP_NET_APCTL_STATE_DISCONNECTED;
|
||||
newState = PSP_NET_APCTL_STATE_DISCONNECTED;
|
||||
break;
|
||||
|
||||
case PSP_NET_APCTL_EVENT_SCAN_REQUEST:
|
||||
netApctlState = PSP_NET_APCTL_STATE_SCANNING;
|
||||
if (*error == 0) apctlEvents.push_front({ netApctlState, netApctlState, PSP_NET_APCTL_EVENT_SCAN_COMPLETE, 0 });
|
||||
newState = PSP_NET_APCTL_STATE_SCANNING;
|
||||
if (error == 0)
|
||||
apctlEvents.push_front({ newState, newState, PSP_NET_APCTL_EVENT_SCAN_COMPLETE, 0 });
|
||||
break;
|
||||
|
||||
case PSP_NET_APCTL_EVENT_SCAN_COMPLETE:
|
||||
netApctlState = PSP_NET_APCTL_STATE_DISCONNECTED;
|
||||
newState = PSP_NET_APCTL_STATE_DISCONNECTED;
|
||||
break;
|
||||
|
||||
case PSP_NET_APCTL_EVENT_EAP_AUTH: // Is this suppose to happen between JOINING and ESTABLISHED ?
|
||||
netApctlState = PSP_NET_APCTL_STATE_EAP_AUTH;
|
||||
if (*error == 0) apctlEvents.push_front({ netApctlState, netApctlState, PSP_NET_APCTL_EVENT_KEY_EXCHANGE, 0 }); // not sure if KEY_EXCHANGE is the next step after AUTH or not tho
|
||||
newState = PSP_NET_APCTL_STATE_EAP_AUTH;
|
||||
if (error == 0)
|
||||
apctlEvents.push_front({ newState, newState, PSP_NET_APCTL_EVENT_KEY_EXCHANGE, 0 }); // not sure if KEY_EXCHANGE is the next step after AUTH or not tho
|
||||
break;
|
||||
|
||||
case PSP_NET_APCTL_EVENT_KEY_EXCHANGE: // Is this suppose to happen between JOINING and ESTABLISHED ?
|
||||
netApctlState = PSP_NET_APCTL_STATE_KEY_EXCHANGE;
|
||||
if (*error == 0) apctlEvents.push_front({ netApctlState, netApctlState, PSP_NET_APCTL_EVENT_ESTABLISHED, 0 });
|
||||
newState = PSP_NET_APCTL_STATE_KEY_EXCHANGE;
|
||||
if (error == 0)
|
||||
apctlEvents.push_front({ newState, newState, PSP_NET_APCTL_EVENT_ESTABLISHED, 0 });
|
||||
break;
|
||||
|
||||
case PSP_NET_APCTL_EVENT_RECONNECT:
|
||||
netApctlState = PSP_NET_APCTL_STATE_DISCONNECTED;
|
||||
if (*error == 0) apctlEvents.push_front({ netApctlState, netApctlState, PSP_NET_APCTL_EVENT_CONNECT_REQUEST, 0 });
|
||||
newState = PSP_NET_APCTL_STATE_DISCONNECTED;
|
||||
if (error == 0)
|
||||
apctlEvents.push_front({ newState, newState, PSP_NET_APCTL_EVENT_CONNECT_REQUEST, 0 });
|
||||
break;
|
||||
}
|
||||
// Do we need to change the newState? even if there were error?
|
||||
//if (*error == 0)
|
||||
*newState = netApctlState;
|
||||
//if (error != 0)
|
||||
// newState = netApctlState;
|
||||
|
||||
// Since 0 is a valid index to types_ we use -1 to detects if it was loaded from an old save state
|
||||
if (actionAfterApctlMipsCall < 0) {
|
||||
@@ -450,38 +527,19 @@ void __NetApctlCallbacks()
|
||||
|
||||
// Run mipscall. Should we skipped executing the mipscall if oldState == newState?
|
||||
for (std::map<int, ApctlHandler>::iterator it = apctlHandlers.begin(); it != apctlHandlers.end(); ++it) {
|
||||
DEBUG_LOG(SCENET, "ApctlCallback [ID=%i][OldState=%d][NewState=%d][Event=%d][Error=%d][ArgsPtr=%08x]", it->first, *oldState, *newState, *event, *error, it->second.argument);
|
||||
DEBUG_LOG(SCENET, "ApctlCallback [ID=%i][OldState=%d][NewState=%d][Event=%d][Error=%08x][ArgsPtr=%08x]", it->first, oldState, newState, event, error, it->second.argument);
|
||||
args.data[4] = it->second.argument;
|
||||
AfterApctlMipsCall* after = (AfterApctlMipsCall*)__KernelCreateAction(actionAfterApctlMipsCall);
|
||||
after->SetData(it->first, *oldState, *newState, *event, *error, it->second.argument);
|
||||
after->SetData(it->first, oldState, newState, event, error, it->second.argument);
|
||||
hleEnqueueCall(it->second.entryPoint, 5, args.data, after);
|
||||
}
|
||||
// Similar to Adhocctl, new State might need to be set after delayed, right before executing the mipscall (ie. simulated beforeAction)
|
||||
ScheduleApctlState(event, newState, delayus, "apctl callback state");
|
||||
return;
|
||||
}
|
||||
|
||||
// We are temporarily borrowing APctl thread for NpAuth callbacks for testing to simulate authentication
|
||||
if (!npAuthEvents.empty())
|
||||
{
|
||||
auto args = npAuthEvents.front();
|
||||
auto id = &args.data[0];
|
||||
auto result = &args.data[1];
|
||||
auto argAddr = &args.data[2];
|
||||
npAuthEvents.pop_front();
|
||||
|
||||
delayus = (adhocEventDelayMS + 2 * adhocExtraPollDelayMS) * 1000;
|
||||
|
||||
int handlerID = *id - 1;
|
||||
for (std::map<int, NpAuthHandler>::iterator it = npAuthHandlers.begin(); it != npAuthHandlers.end(); ++it) {
|
||||
if (it->first == handlerID) {
|
||||
DEBUG_LOG(SCENET, "NpAuthCallback [HandlerID=%i][RequestID=%d][Result=%d][ArgsPtr=%08x]", it->first, *id, *result, it->second.argument);
|
||||
// TODO: Update result / args.data[1] with the actual ticket length (or error code?)
|
||||
hleEnqueueCall(it->second.entryPoint, 3, args.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Must be delayed long enough whenever there is a pending callback.
|
||||
// Must be delayed long enough whenever there is a pending callback to make sure previous callback & it's afterAction are fully executed
|
||||
sceKernelDelayThread(delayus);
|
||||
hleSkipDeadbeef();
|
||||
}
|
||||
|
||||
static inline u32 AllocUser(u32 size, bool fromTop, const char *name) {
|
||||
@@ -535,7 +593,7 @@ static u32 sceNetTerm() {
|
||||
int retval = Net_Term();
|
||||
|
||||
// Give time to make sure everything are cleaned up
|
||||
hleDelayResult(retval, "give time to init/cleanup", adhocEventDelayMS * 1000);
|
||||
hleEatMicro(adhocDefaultDelay);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -583,14 +641,15 @@ static int sceNetInit(u32 poolSize, u32 calloutPri, u32 calloutStack, u32 netini
|
||||
}
|
||||
|
||||
WARN_LOG(SCENET, "sceNetInit(poolsize=%d, calloutpri=%i, calloutstack=%d, netintrpri=%i, netintrstack=%d) at %08x", poolSize, calloutPri, calloutStack, netinitPri, netinitStack, currentMIPS->pc);
|
||||
netInited = true;
|
||||
netMallocStat.pool = poolSize; // This should be the poolSize isn't?
|
||||
netMallocStat.maximum = poolSize/2; // According to JPCSP's sceNetGetMallocStat this is Currently Used size = (poolSize - free), faked to half the pool
|
||||
netMallocStat.free = poolSize - netMallocStat.maximum;
|
||||
|
||||
netMallocStat.pool = poolSize - 0x20; // On Vantage Master Portable this is slightly (32 bytes) smaller than the poolSize arg when tested with JPCSP + prx files
|
||||
netMallocStat.maximum = 0x4050; // Dummy maximum foot print
|
||||
netMallocStat.free = netMallocStat.pool; // Dummy free size, we should set this high enough to prevent any issue (ie. Vantage Master Portable), this is probably the only field being checked by games?
|
||||
|
||||
// Clear Socket Translator Memory
|
||||
memset(&adhocSockets, 0, sizeof(adhocSockets));
|
||||
|
||||
|
||||
netInited = true;
|
||||
return hleLogSuccessI(SCENET, 0);
|
||||
}
|
||||
|
||||
@@ -712,7 +771,7 @@ static void sceNetEtherStrton(u32 bufferPtr, u32 macPtr) {
|
||||
|
||||
// Write static data since we don't actually manage any memory for sceNet* yet.
|
||||
static int sceNetGetMallocStat(u32 statPtr) {
|
||||
VERBOSE_LOG(SCENET, "UNTESTED sceNetGetMallocStat(%x)", statPtr);
|
||||
VERBOSE_LOG(SCENET, "UNTESTED sceNetGetMallocStat(%x) at %08x", statPtr, currentMIPS->pc);
|
||||
if(Memory::IsValidAddress(statPtr))
|
||||
Memory::WriteStruct(statPtr, &netMallocStat);
|
||||
else
|
||||
|
||||
@@ -219,6 +219,7 @@ private:
|
||||
|
||||
extern bool netInetInited;
|
||||
extern bool netApctlInited;
|
||||
extern u32 netApctlState;
|
||||
extern SceNetApctlInfoInternal netApctlInfo;
|
||||
|
||||
template <typename I> std::string num2hex(I w, size_t hex_len = sizeof(I) << 1);
|
||||
|
||||
+667
-533
File diff suppressed because it is too large.
Load diff
@@ -98,11 +98,12 @@ int NetAdhoc_Term();
|
||||
extern bool netAdhocInited;
|
||||
extern bool netAdhocctlInited;
|
||||
extern bool networkInited;
|
||||
extern int adhocDefaultTimeout;
|
||||
extern int adhocExtraPollDelayMS;
|
||||
extern int adhocEventPollDelayMS;
|
||||
extern int adhocMatchingEventDelayMS;
|
||||
extern int adhocEventDelayMS; // This will affect the duration of "Connecting..." dialog/message box in .Hack//Link and Naruto Ultimate Ninja Heroes 3
|
||||
extern int adhocDefaultTimeout; //3000000 usec
|
||||
extern int adhocDefaultDelay; //10000
|
||||
extern int adhocExtraDelay; //20000
|
||||
extern int adhocEventPollDelay; //100000; // Seems to be the same with PSP_ADHOCCTL_RECV_TIMEOUT
|
||||
extern int adhocMatchingEventDelay; //30000
|
||||
extern int adhocEventDelay; //1000000
|
||||
extern std::recursive_mutex adhocEvtMtx;
|
||||
extern int IsAdhocctlInCB;
|
||||
|
||||
|
||||
@@ -71,15 +71,18 @@ u64 MemoryStick_SectorSize() {
|
||||
}
|
||||
|
||||
u64 MemoryStick_FreeSpace() {
|
||||
u64 freeSpace = pspFileSystem.FreeSpace("ms0:/");
|
||||
|
||||
// Cap the memory stick size to avoid math errors when old games get sizes that were
|
||||
// hard to imagine back then.
|
||||
// We have a compat setting to make it even smaller for Harry Potter : Goblet of Fire, see #13266.
|
||||
const u64 memStickSize = PSP_CoreParameter().compat.flags().ReportSmallMemstick ? smallMemstickSize : normalMemstickSize;
|
||||
if (freeSpace < memStickSize)
|
||||
return freeSpace;
|
||||
return memStickSize;
|
||||
const u64 memStickSize = PSP_CoreParameter().compat.flags().ReportSmallMemstick ? smallMemstickSize : (u64)g_Config.iMemStickSizeGB * 1024 * 1024 * 1024;
|
||||
u64 usedSpace = pspFileSystem.getDirSize("ms0:/PSP/SAVEDATA/");// Assume the memory stick is only used to store savedata.
|
||||
u64 freeSpace;
|
||||
if (usedSpace >= memStickSize)
|
||||
freeSpace = 0;
|
||||
else
|
||||
freeSpace = memStickSize - usedSpace;
|
||||
|
||||
return freeSpace;
|
||||
}
|
||||
|
||||
void MemoryStick_SetFatState(MemStickFatState state) {
|
||||
|
||||
+22
-41
@@ -29,67 +29,48 @@ inline int Xpose(int v) {
|
||||
return v^0x20;
|
||||
}
|
||||
|
||||
// Half of PI, or 90 degrees.
|
||||
#ifndef M_PI_2
|
||||
#define M_PI_2 1.57079632679489661923
|
||||
#endif
|
||||
|
||||
// Some games depend on exact values, but sinf() and cosf() aren't always precise.
|
||||
// The VFPU uses weird angles where 4.0 represents a full circle. This makes it possible to return
|
||||
// exact 1.0/-1.0 values at certain angles. We get close enough for #2921 and #12900 by computing
|
||||
// things in double precision, multiplying the input by pi/2.
|
||||
//
|
||||
// A better solution would be to tailor some sine approximation for the 0..90 degrees range, compute
|
||||
// modulo manually and mirror that around the circle. Also correctly special casing for inf/nan inputs
|
||||
// and just trying to match it as closely as possible to the real PSP.
|
||||
//
|
||||
// Stepping down to [0, 2pi) helps, but we also check common exact-result values.
|
||||
// TODO: cos(1) and sin(2) should be -0.0, but doing that gives wrong results (possibly from floorf.)
|
||||
|
||||
// Messing around with the modulo functions? try https://www.desmos.com/calculator.
|
||||
|
||||
inline float vfpu_sin(float angle) {
|
||||
angle -= floorf(angle * 0.25f) * 4.f;
|
||||
if (angle == 0.0f || angle == 2.0f) {
|
||||
return 0.0f;
|
||||
} else if (angle == 1.0f) {
|
||||
return 1.0f;
|
||||
} else if (angle == 3.0f) {
|
||||
return -1.0f;
|
||||
}
|
||||
angle *= (float)M_PI_2;
|
||||
return sinf(angle);
|
||||
return (float)sin((double)angle * M_PI_2);
|
||||
}
|
||||
|
||||
inline float vfpu_cos(float angle) {
|
||||
angle -= floorf(angle * 0.25f) * 4.f;
|
||||
if (angle == 1.0f || angle == 3.0f) {
|
||||
return 0.0f;
|
||||
} else if (angle == 0.0f) {
|
||||
return 1.0f;
|
||||
} else if (angle == 2.0f) {
|
||||
return -1.0f;
|
||||
}
|
||||
angle *= (float)M_PI_2;
|
||||
return cosf(angle);
|
||||
return (float)cos((double)angle * M_PI_2);
|
||||
}
|
||||
|
||||
inline float vfpu_asin(float angle) {
|
||||
return asinf(angle) / M_PI_2;
|
||||
}
|
||||
|
||||
inline void vfpu_sincos(float angle, float &sine, float &cosine) {
|
||||
angle -= floorf(angle * 0.25f) * 4.f;
|
||||
if (angle == 0.0f) {
|
||||
sine = 0.0f;
|
||||
cosine = 1.0f;
|
||||
} else if (angle == 1.0f) {
|
||||
sine = 1.0f;
|
||||
cosine = 0.0f;
|
||||
} else if (angle == 2.0f) {
|
||||
sine = 0.0f;
|
||||
cosine = -1.0f;
|
||||
} else if (angle == 3.0f) {
|
||||
sine = -1.0f;
|
||||
cosine = 0.0f;
|
||||
} else {
|
||||
angle *= (float)M_PI_2;
|
||||
inline void vfpu_sincos(float angle_f, float &sine, float &cosine) {
|
||||
double angle = (double)angle_f * M_PI_2;
|
||||
#if defined(__linux__)
|
||||
sincosf(angle, &sine, &cosine);
|
||||
double d_sine;
|
||||
double d_cosine;
|
||||
sincos(angle, &d_sine, &d_cosine);
|
||||
sine = (float)d_sine;
|
||||
cosine = (float)d_cosine;
|
||||
#else
|
||||
sine = sinf(angle);
|
||||
cosine = cosf(angle);
|
||||
sine = (float)sin(angle);
|
||||
cosine = (float)cos(angle);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
inline float vfpu_clamp(float v, float min, float max) {
|
||||
|
||||
+13
-5
@@ -60,7 +60,9 @@ namespace Reporting
|
||||
// Temporarily stores a reference to the hostname.
|
||||
static std::string lastHostname;
|
||||
// Keeps track of report-only-once identifiers. Since they're always constants, a pointer is okay.
|
||||
static std::map<const char *, int> logOnceUsed;
|
||||
static std::map<const char *, int> logNTimes;
|
||||
static std::mutex logNTimesLock;
|
||||
|
||||
// Keeps track of whether a harmful setting was ever used.
|
||||
static bool everUnsupported = false;
|
||||
// Support is cached here to avoid checking it on every single request.
|
||||
@@ -303,7 +305,7 @@ namespace Reporting
|
||||
{
|
||||
// New game, clean slate.
|
||||
spamProtectionCount = 0;
|
||||
logOnceUsed.clear();
|
||||
logNTimes.clear();
|
||||
everUnsupported = false;
|
||||
currentSupported = IsSupported();
|
||||
pendingMessagesDone = false;
|
||||
@@ -347,9 +349,10 @@ namespace Reporting
|
||||
bool ShouldLogNTimes(const char *identifier, int count)
|
||||
{
|
||||
// True if it wasn't there already -> so yes, log.
|
||||
auto iter = logOnceUsed.find(identifier);
|
||||
if (iter == logOnceUsed.end()) {
|
||||
logOnceUsed.insert(std::pair<const char*, int>(identifier, 1));
|
||||
std::lock_guard<std::mutex> lock(logNTimesLock);
|
||||
auto iter = logNTimes.find(identifier);
|
||||
if (iter == logNTimes.end()) {
|
||||
logNTimes.insert(std::pair<const char*, int>(identifier, 1));
|
||||
return true;
|
||||
} else {
|
||||
if (iter->second >= count) {
|
||||
@@ -361,6 +364,11 @@ namespace Reporting
|
||||
}
|
||||
}
|
||||
|
||||
void ResetCounts() {
|
||||
std::lock_guard<std::mutex> lock(logNTimesLock);
|
||||
logNTimes.clear();
|
||||
}
|
||||
|
||||
std::string CurrentGameID()
|
||||
{
|
||||
// TODO: Maybe ParamSFOData shouldn't include nulls in std::strings? Don't work to break savedata, though...
|
||||
|
||||
@@ -53,6 +53,9 @@ namespace Reporting
|
||||
void Init();
|
||||
void Shutdown();
|
||||
|
||||
// Resets counts on any count-limited logs (see ShouldLogNTimes).
|
||||
void ResetCounts();
|
||||
|
||||
// Check savestate compatibility, mostly needed on load.
|
||||
void DoState(PointerWrap &p);
|
||||
|
||||
|
||||
@@ -1717,7 +1717,7 @@ void FramebufferManagerCommon::SetRenderSize(VirtualFramebuffer *vfb) {
|
||||
force1x = vfb->bufferWidth <= 256 || vfb->bufferHeight <= 128;
|
||||
break;
|
||||
case 3:
|
||||
force1x = vfb->bufferWidth < 480 || vfb->bufferWidth > 800 || vfb->bufferHeight < 272; // GOW uses 864x272
|
||||
force1x = vfb->bufferWidth < 480 || vfb->bufferWidth > 800 || vfb->bufferHeight < 272; // GOW uses 864x272
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -24,13 +24,6 @@ MainWindow::MainWindow(QWidget *parent, bool fullscreen) :
|
||||
nextState(CORE_POWERDOWN),
|
||||
lastUIState(UISTATE_MENU)
|
||||
{
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
int screenNum = QProcessEnvironment::systemEnvironment().value("SDL_VIDEO_FULLSCREEN_HEAD", "0").toInt();
|
||||
|
||||
// Move window to the center of selected screen
|
||||
QRect rect = desktop->screenGeometry(screenNum);
|
||||
move((rect.width() - frameGeometry().width()) / 4, (rect.height() - frameGeometry().height()) / 4);
|
||||
|
||||
setWindowIcon(QIcon(qApp->applicationDirPath() + "/assets/icon_regular_72.png"));
|
||||
|
||||
SetGameTitle("");
|
||||
@@ -64,6 +57,9 @@ void MainWindow::newFrame()
|
||||
updateMenus();
|
||||
}
|
||||
|
||||
if (g_Config.bFullScreen != isFullScreen())
|
||||
SetFullScreen(g_Config.bFullScreen);
|
||||
|
||||
std::unique_lock<std::mutex> lock(msgMutex_);
|
||||
while (!msgQueue_.empty()) {
|
||||
MainWindowMsg msg = msgQueue_.front();
|
||||
@@ -112,9 +108,6 @@ void MainWindow::updateMenus()
|
||||
|
||||
void MainWindow::bootDone()
|
||||
{
|
||||
if (g_Config.bFullScreen != isFullScreen())
|
||||
SetFullScreen(g_Config.bFullScreen);
|
||||
|
||||
if (nextState == CORE_RUNNING)
|
||||
runAct();
|
||||
updateMenus();
|
||||
@@ -389,6 +382,13 @@ void MainWindow::SetFullScreen(bool fullscreen) {
|
||||
|
||||
if (GetUIState() == UISTATE_INGAME && QApplication::overrideCursor())
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
int screenNum = QProcessEnvironment::systemEnvironment().value("SDL_VIDEO_FULLSCREEN_HEAD", "0").toInt();
|
||||
|
||||
// Move window to the center of selected screen
|
||||
QRect rect = desktop->screenGeometry(screenNum);
|
||||
move((rect.width() - frameGeometry().width()) / 4, (rect.height() - frameGeometry().height()) / 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
|
||||
#include "Common/System/Display.h"
|
||||
#include "Common/System/NativeApp.h"
|
||||
#include "Common/System/System.h"
|
||||
@@ -37,6 +38,7 @@
|
||||
#include "Core/Config.h"
|
||||
#include "Core/ConfigValues.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/Reporting.h"
|
||||
#include "Core/CoreParameter.h"
|
||||
#include "Core/MIPS/MIPSTables.h"
|
||||
#include "Core/MIPS/JitCommon/JitBlockCache.h"
|
||||
@@ -89,6 +91,7 @@ void DevMenu::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
items->Add(new Choice(dev->T("Toggle Freeze")))->OnClick.Handle(this, &DevMenu::OnFreezeFrame);
|
||||
items->Add(new Choice(dev->T("Dump Frame GPU Commands")))->OnClick.Handle(this, &DevMenu::OnDumpFrame);
|
||||
items->Add(new Choice(dev->T("Toggle Audio Debug")))->OnClick.Handle(this, &DevMenu::OnToggleAudioDebug);
|
||||
items->Add(new Choice(dev->T("Reset limited logging")))->OnClick.Handle(this, &DevMenu::OnResetLimitedLogging);
|
||||
|
||||
|
||||
scroll->Add(items);
|
||||
@@ -105,6 +108,10 @@ UI::EventReturn DevMenu::OnToggleAudioDebug(UI::EventParams &e) {
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn DevMenu::OnResetLimitedLogging(UI::EventParams &e) {
|
||||
Reporting::ResetCounts();
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn DevMenu::OnLogView(UI::EventParams &e) {
|
||||
UpdateUIState(UISTATE_PAUSEMENU);
|
||||
|
||||
@@ -45,6 +45,7 @@ protected:
|
||||
UI::EventReturn OnDumpFrame(UI::EventParams &e);
|
||||
UI::EventReturn OnDeveloperTools(UI::EventParams &e);
|
||||
UI::EventReturn OnToggleAudioDebug(UI::EventParams &e);
|
||||
UI::EventReturn OnResetLimitedLogging(UI::EventParams &e);
|
||||
};
|
||||
|
||||
class JitDebugScreen : public UIDialogScreenWithBackground {
|
||||
|
||||
@@ -873,6 +873,7 @@ void GameSettingsScreen::CreateViews() {
|
||||
networkingSettings->Add(new PopupSliderChoice(&g_Config.iPortOffset, 0, 60000, n->T("Port offset", "Port offset (0 = PSP compatibility)"), 100, screenManager()));
|
||||
networkingSettings->Add(new PopupSliderChoice(&g_Config.iMinTimeout, 1, 15000, n->T("Minimum Timeout", "Minimum Timeout (override low latency in ms)"), 100, screenManager()));
|
||||
networkingSettings->Add(new CheckBox(&g_Config.bTCPNoDelay, n->T("TCP No Delay", "TCP No Delay (faster TCP)")));
|
||||
networkingSettings->Add(new CheckBox(&g_Config.bForcedFirstConnect, n->T("Forced First Connect", "Forced First Connect (faster Connect)")));
|
||||
|
||||
ViewGroup *toolsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
|
||||
toolsScroll->SetTag("GameSettingsTools");
|
||||
@@ -930,7 +931,10 @@ void GameSettingsScreen::CreateViews() {
|
||||
rewindFreq->SetZeroLabel(sy->T("Off"));
|
||||
|
||||
systemSettings->Add(new CheckBox(&g_Config.bMemStickInserted, sy->T("Memory Stick inserted")));
|
||||
PopupSliderChoice *memStickSize = systemSettings->Add(new PopupSliderChoice(&g_Config.iMemStickSizeGB, 1, 32, sy->T("Change Memory Stick Size", "Change Memory Stick Size(GB)"), screenManager(), "GB"));
|
||||
|
||||
}
|
||||
|
||||
systemSettings->Add(new ItemHeader(sy->T("General")));
|
||||
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
@@ -1924,7 +1928,7 @@ void HostnameSelectScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
buttonsRow2->Add(new Button(di->T("Toggle List")))->OnClick.Handle(this, &HostnameSelectScreen::OnShowIPListClick);
|
||||
buttonsRow2->Add(new Spacer(new LinearLayoutParams(1.0, G_RIGHT)));
|
||||
|
||||
std::vector<std::string> listIP = {"myneighborsushicat.com", "localhost"};
|
||||
std::vector<std::string> listIP = {"myneighborsushicat.com", "socom.cc", "localhost"}; // TODO: Add some saved recent history too?
|
||||
net::GetIPList(listIP);
|
||||
ipRows_ = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0));
|
||||
ScrollView* scrollView = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
|
||||
|
||||
+7
-1
@@ -595,8 +595,14 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
|
||||
#endif
|
||||
if (!strncmp(argv[i], "--pause-menu-exit", strlen("--pause-menu-exit")))
|
||||
g_Config.bPauseMenuExitsEmulator = true;
|
||||
if (!strcmp(argv[i], "--fullscreen"))
|
||||
if (!strcmp(argv[i], "--fullscreen")) {
|
||||
g_Config.bFullScreen = true;
|
||||
System_SendMessage("toggle_fullscreen", "1");
|
||||
}
|
||||
if (!strcmp(argv[i], "--windowed")) {
|
||||
g_Config.bFullScreen = false;
|
||||
System_SendMessage("toggle_fullscreen", "0");
|
||||
}
|
||||
if (!strcmp(argv[i], "--touchscreentest"))
|
||||
gotoTouchScreenTest = true;
|
||||
if (!strcmp(argv[i], "--gamesettings"))
|
||||
|
||||
@@ -22,8 +22,9 @@ void OnScreenMessagesView::Draw(UIContext &dc) {
|
||||
float y = 10.0f;
|
||||
// Then draw them all.
|
||||
const std::list<OnScreenMessages::Message> &messages = osm.Messages();
|
||||
double now = time_now_d();
|
||||
for (auto iter = messages.begin(); iter != messages.end(); ++iter) {
|
||||
float alpha = (iter->endTime - time_now_d()) * 4.0f;
|
||||
float alpha = (iter->endTime - now) * 4.0f;
|
||||
if (alpha > 1.0) alpha = 1.0f;
|
||||
if (alpha < 0.0) alpha = 0.0f;
|
||||
// Messages that are wider than the screen are left-aligned instead of centered.
|
||||
|
||||
@@ -658,7 +658,7 @@ namespace MainWindow
|
||||
}
|
||||
lastMouseDown = 0.0;
|
||||
} else {
|
||||
lastMouseDown = time_now_d();
|
||||
lastMouseDown = now;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -17,6 +17,6 @@ private:
|
||||
int check_delay[4]{};
|
||||
XINPUT_STATE prevState[4]{};
|
||||
XINPUT_VIBRATION prevVibration[4]{};
|
||||
int prevVibrationTime = 0;
|
||||
double prevVibrationTime = 0.0;
|
||||
u32 prevButtons[4]{};
|
||||
};
|
||||
@@ -564,9 +564,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
|
||||
break;
|
||||
}
|
||||
|
||||
if (wideArgs[i] == L"--windowed")
|
||||
g_Config.bFullScreen = false;
|
||||
|
||||
if (wideArgs[i].find(gpuBackend) != std::wstring::npos && wideArgs[i].size() > gpuBackend.size()) {
|
||||
const std::wstring restOfOption = wideArgs[i].substr(gpuBackend.size());
|
||||
|
||||
|
||||
Binary file not shown.
+1
-1
Submodule assets/lang updated: d5a2a51942...fd6f5bc01a.
+1
-1
@@ -5,7 +5,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.0.1'
|
||||
classpath 'com.android.tools.build:gradle:4.0.2'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ static const int64 kint64max = static_cast<int64>(0x7FFFFFFFFFFFFFFFLL);
|
||||
// and 32-bit values (not 64-bit); older versions either raise a fatal signal,
|
||||
// do an unaligned read and rotate the words around a bit, or do the reads very
|
||||
// slowly (trip through kernel mode). There's no simple #define that says just
|
||||
// “ARMv7 or higher”, so we have to filter away all ARMv5 and ARMv6
|
||||
// "ARMv7 or higher", so we have to filter away all ARMv5 and ARMv6
|
||||
// sub-architectures.
|
||||
//
|
||||
// This is a mess, but there's not much we can do about it.
|
||||
|
||||
+24
-24
@@ -384,12 +384,12 @@ static inline char* EmitCopyAtMost64(char* op, size_t offset, size_t len) {
|
||||
if (len_less_than_12 && SNAPPY_PREDICT_TRUE(offset < 2048)) {
|
||||
// offset fits in 11 bits. The 3 highest go in the top of the first byte,
|
||||
// and the rest go in the second byte.
|
||||
*op++ = COPY_1_BYTE_OFFSET + ((len - 4) << 2) + ((offset >> 3) & 0xe0);
|
||||
*op++ = (char)(COPY_1_BYTE_OFFSET + ((len - 4) << 2) + ((offset >> 3) & 0xe0));
|
||||
*op++ = offset & 0xff;
|
||||
} else {
|
||||
// Write 4 bytes, though we only care about 3 of them. The output buffer
|
||||
// is required to have some slack, so the extra byte won't overrun it.
|
||||
uint32 u = COPY_2_BYTE_OFFSET + ((len - 1) << 2) + (offset << 8);
|
||||
uint32 u = (uint32)(COPY_2_BYTE_OFFSET + ((len - 1) << 2) + (offset << 8));
|
||||
LittleEndian::Store32(op, u);
|
||||
op += 3;
|
||||
}
|
||||
@@ -458,7 +458,7 @@ uint32 CalculateTableSize(uint32 input_size) {
|
||||
namespace internal {
|
||||
WorkingMemory::WorkingMemory(size_t input_size) {
|
||||
const size_t max_fragment_size = std::min(input_size, kBlockSize);
|
||||
const size_t table_size = CalculateTableSize(max_fragment_size);
|
||||
const size_t table_size = CalculateTableSize((uint32)max_fragment_size);
|
||||
size_ = table_size * sizeof(*table_) + max_fragment_size +
|
||||
MaxCompressedLength(max_fragment_size);
|
||||
mem_ = std::allocator<char>().allocate(size_);
|
||||
@@ -473,9 +473,9 @@ WorkingMemory::~WorkingMemory() {
|
||||
|
||||
uint16* WorkingMemory::GetHashTable(size_t fragment_size,
|
||||
int* table_size) const {
|
||||
const size_t htsize = CalculateTableSize(fragment_size);
|
||||
const size_t htsize = CalculateTableSize((uint32)fragment_size);
|
||||
memset(table_, 0, htsize * sizeof(*table_));
|
||||
*table_size = htsize;
|
||||
*table_size = (int)htsize;
|
||||
return table_;
|
||||
}
|
||||
} // end namespace internal
|
||||
@@ -602,7 +602,7 @@ char* CompressFragment(const char* input,
|
||||
assert(candidate >= base_ip);
|
||||
assert(candidate < ip);
|
||||
|
||||
table[hash] = ip - base_ip;
|
||||
table[hash] = (uint16)(ip - base_ip);
|
||||
} while (SNAPPY_PREDICT_TRUE(UNALIGNED_LOAD32(ip) !=
|
||||
UNALIGNED_LOAD32(candidate)));
|
||||
|
||||
@@ -610,7 +610,7 @@ char* CompressFragment(const char* input,
|
||||
// than 4 bytes match. But, prior to the match, input
|
||||
// bytes [next_emit, ip) are unmatched. Emit them as "literal bytes."
|
||||
assert(next_emit + 16 <= ip_end);
|
||||
op = EmitLiteral</*allow_fast_path=*/true>(op, next_emit, ip - next_emit);
|
||||
op = EmitLiteral</*allow_fast_path=*/true>(op, next_emit, (int)(ip - next_emit));
|
||||
|
||||
// Step 3: Call EmitCopy, and then see if another EmitCopy could
|
||||
// be our next move. Repeat until we find no match for the
|
||||
@@ -647,11 +647,11 @@ char* CompressFragment(const char* input,
|
||||
// we also update table[Hash(ip - 1, shift)] and table[Hash(ip, shift)].
|
||||
input_bytes = GetEightBytesAt(ip - 1);
|
||||
uint32 prev_hash = HashBytes(GetUint32AtOffset(input_bytes, 0), shift);
|
||||
table[prev_hash] = ip - base_ip - 1;
|
||||
table[prev_hash] = (uint16)(ip - base_ip - 1);
|
||||
uint32 cur_hash = HashBytes(GetUint32AtOffset(input_bytes, 1), shift);
|
||||
candidate = base_ip + table[cur_hash];
|
||||
candidate_bytes = UNALIGNED_LOAD32(candidate);
|
||||
table[cur_hash] = ip - base_ip;
|
||||
table[cur_hash] = (uint16)(ip - base_ip);
|
||||
} while (GetUint32AtOffset(input_bytes, 1) == candidate_bytes);
|
||||
|
||||
next_hash = HashBytes(GetUint32AtOffset(input_bytes, 2), shift);
|
||||
@@ -663,7 +663,7 @@ char* CompressFragment(const char* input,
|
||||
// Emit the remaining bytes as a literal
|
||||
if (next_emit < ip_end) {
|
||||
op = EmitLiteral</*allow_fast_path=*/false>(op, next_emit,
|
||||
ip_end - next_emit);
|
||||
(int)(ip_end - next_emit));
|
||||
}
|
||||
|
||||
return op;
|
||||
@@ -864,7 +864,7 @@ class SnappyDecompressor {
|
||||
// Long literal.
|
||||
const size_t literal_length_length = literal_length - 60;
|
||||
literal_length =
|
||||
ExtractLowBytes(LittleEndian::Load32(ip), literal_length_length) +
|
||||
ExtractLowBytes(LittleEndian::Load32(ip), (int)literal_length_length) +
|
||||
1;
|
||||
ip += literal_length_length;
|
||||
}
|
||||
@@ -877,7 +877,7 @@ class SnappyDecompressor {
|
||||
size_t n;
|
||||
ip = reader_->Peek(&n);
|
||||
avail = n;
|
||||
peeked_ = avail;
|
||||
peeked_ = (uint32)avail;
|
||||
if (avail == 0) return; // Premature end of input
|
||||
ip_limit_ = ip + avail;
|
||||
}
|
||||
@@ -889,7 +889,7 @@ class SnappyDecompressor {
|
||||
} else {
|
||||
const size_t entry = char_table[c];
|
||||
const size_t trailer =
|
||||
ExtractLowBytes(LittleEndian::Load32(ip), entry >> 11);
|
||||
ExtractLowBytes(LittleEndian::Load32(ip), (int)entry >> 11);
|
||||
const size_t length = entry & 0xff;
|
||||
ip += entry >> 11;
|
||||
|
||||
@@ -915,7 +915,7 @@ bool SnappyDecompressor::RefillTag() {
|
||||
reader_->Skip(peeked_); // All peeked bytes are used up
|
||||
size_t n;
|
||||
ip = reader_->Peek(&n);
|
||||
peeked_ = n;
|
||||
peeked_ = (uint32)n;
|
||||
eof_ = (n == 0);
|
||||
if (eof_) return false;
|
||||
ip_limit_ = ip + n;
|
||||
@@ -929,7 +929,7 @@ bool SnappyDecompressor::RefillTag() {
|
||||
assert(needed <= sizeof(scratch_));
|
||||
|
||||
// Read more bytes from reader if needed
|
||||
uint32 nbuf = ip_limit_ - ip;
|
||||
uint32 nbuf = (uint32)(ip_limit_ - ip);
|
||||
if (nbuf < needed) {
|
||||
// Stitch together bytes from ip and reader to form the word
|
||||
// contents. We store the needed bytes in "scratch_". They
|
||||
@@ -942,7 +942,7 @@ bool SnappyDecompressor::RefillTag() {
|
||||
size_t length;
|
||||
const char* src = reader_->Peek(&length);
|
||||
if (length == 0) return false;
|
||||
uint32 to_add = std::min<uint32>(needed - nbuf, length);
|
||||
uint32 to_add = std::min<uint32>(needed - nbuf, (uint32)length);
|
||||
memcpy(scratch_ + nbuf, src, to_add);
|
||||
nbuf += to_add;
|
||||
reader_->Skip(to_add);
|
||||
@@ -972,7 +972,7 @@ static bool InternalUncompress(Source* r, Writer* writer) {
|
||||
uint32 uncompressed_len = 0;
|
||||
if (!decompressor.ReadUncompressedLength(&uncompressed_len)) return false;
|
||||
|
||||
return InternalUncompressAllTags(&decompressor, writer, r->Available(),
|
||||
return InternalUncompressAllTags(&decompressor, writer, (uint32)r->Available(),
|
||||
uncompressed_len);
|
||||
}
|
||||
|
||||
@@ -1001,7 +1001,7 @@ size_t Compress(Source* reader, Sink* writer) {
|
||||
size_t N = reader->Available();
|
||||
const size_t uncompressed_size = N;
|
||||
char ulength[Varint::kMax32];
|
||||
char* p = Varint::Encode32(ulength, N);
|
||||
char* p = Varint::Encode32(ulength, (uint32)N);
|
||||
writer->Append(ulength, p-ulength);
|
||||
written += (p - ulength);
|
||||
|
||||
@@ -1043,7 +1043,7 @@ size_t Compress(Source* reader, Sink* writer) {
|
||||
uint16* table = wmem.GetHashTable(num_to_read, &table_size);
|
||||
|
||||
// Compress input_fragment and append to dest
|
||||
const int max_output = MaxCompressedLength(num_to_read);
|
||||
const int max_output = (int)MaxCompressedLength(num_to_read);
|
||||
|
||||
// Need a scratch buffer for the output, in case the byte sink doesn't
|
||||
// have room for us directly.
|
||||
@@ -1491,7 +1491,7 @@ class SnappyScatteredWriter {
|
||||
|
||||
inline bool TryFastAppend(const char* ip, size_t available, size_t length) {
|
||||
char* op = op_ptr_;
|
||||
const int space_left = op_limit_ - op;
|
||||
const int space_left = (int)(op_limit_ - op);
|
||||
if (length <= 16 && available >= 16 + kMaximumTagLength &&
|
||||
space_left >= 16) {
|
||||
// Fast path, used for the majority (about 95%) of invocations.
|
||||
@@ -1507,7 +1507,7 @@ class SnappyScatteredWriter {
|
||||
char* const op_end = op_ptr_ + len;
|
||||
// See SnappyArrayWriter::AppendFromSelf for an explanation of
|
||||
// the "offset - 1u" trick.
|
||||
if (SNAPPY_PREDICT_TRUE(offset - 1u < op_ptr_ - op_base_ &&
|
||||
if (SNAPPY_PREDICT_TRUE(offset - 1u < (size_t)(op_ptr_ - op_base_) &&
|
||||
op_end <= op_limit_)) {
|
||||
// Fast path: src and dst in current block.
|
||||
op_ptr_ = IncrementalCopy(op_ptr_ - offset, op_ptr_, op_end, op_limit_);
|
||||
@@ -1540,7 +1540,7 @@ bool SnappyScatteredWriter<Allocator>::SlowAppend(const char* ip, size_t len) {
|
||||
|
||||
// Make new block
|
||||
size_t bsize = std::min<size_t>(kBlockSize, expected_ - full_size_);
|
||||
op_base_ = allocator_.Allocate(bsize);
|
||||
op_base_ = allocator_.Allocate((int)bsize);
|
||||
op_ptr_ = op_base_;
|
||||
op_limit_ = op_base_ + bsize;
|
||||
blocks_.push_back(op_base_);
|
||||
@@ -1647,13 +1647,13 @@ bool Uncompress(Source* compressed, Sink* uncompressed) {
|
||||
if (allocated_size >= uncompressed_len) {
|
||||
SnappyArrayWriter writer(buf);
|
||||
bool result = InternalUncompressAllTags(&decompressor, &writer,
|
||||
compressed_len, uncompressed_len);
|
||||
(uint32)compressed_len, uncompressed_len);
|
||||
uncompressed->Append(buf, writer.Produced());
|
||||
return result;
|
||||
} else {
|
||||
SnappySinkAllocator allocator(uncompressed);
|
||||
SnappyScatteredWriter<SnappySinkAllocator> writer(allocator);
|
||||
return InternalUncompressAllTags(&decompressor, &writer, compressed_len,
|
||||
return InternalUncompressAllTags(&decompressor, &writer, (uint32)compressed_len,
|
||||
uncompressed_len);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -444,7 +444,7 @@ void blendPixel(const Kernel_3x3& ker,
|
||||
return true;
|
||||
|
||||
//make sure there is no second blending in an adjacent rotation for this pixel: handles insular pixels, mario eyes
|
||||
if (getTopR(blend) != BLEND_NONE && !eq(e, g)) //but support double-blending for 90° corners
|
||||
if (getTopR(blend) != BLEND_NONE && !eq(e, g)) //but support double-blending for 90?corners
|
||||
return false;
|
||||
if (getBottomL(blend) != BLEND_NONE && !eq(e, c))
|
||||
return false;
|
||||
|
||||
+1
-1
@@ -3115,7 +3115,7 @@ XXH3_initCustomSecret_avx512(void* XXH_RESTRICT customSecret, xxh_u64 seed64)
|
||||
int i;
|
||||
for (i=0; i < nbRounds; ++i) {
|
||||
/* GCC has a bug, _mm512_stream_load_si512 accepts 'void*', not 'void const*',
|
||||
* this will warn "discards ‘const’ qualifier". */
|
||||
* this will warn "discards 'const' qualifier". */
|
||||
union {
|
||||
XXH_ALIGN(64) const __m512i* cp;
|
||||
XXH_ALIGN(64) void* p;
|
||||
|
||||
+13
-1
@@ -23,6 +23,9 @@
|
||||
//
|
||||
// TODO: Make a test of nice unittest asserts and count successes etc.
|
||||
// Or just integrate with an existing testing framework.
|
||||
//
|
||||
// To use, set command line parameter to one or more of the tests below, or "all".
|
||||
// Search for "availableTests".
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -308,10 +311,19 @@ bool TestVFPUSinCos() {
|
||||
EXPECT_APPROX_EQ_FLOAT(sine, 1.0f);
|
||||
EXPECT_APPROX_EQ_FLOAT(cosine, 0.0f);
|
||||
|
||||
for (float angle = -10.0f; angle < 10.0f; angle++) {
|
||||
vfpu_sincos(-1.0f, sine, cosine);
|
||||
EXPECT_EQ_FLOAT(sine, -1.0f);
|
||||
EXPECT_EQ_FLOAT(cosine, 0.0f);
|
||||
vfpu_sincos(-2.0f, sine, cosine);
|
||||
EXPECT_EQ_FLOAT(sine, 0.0f);
|
||||
EXPECT_EQ_FLOAT(cosine, -1.0f);
|
||||
|
||||
for (float angle = -10.0f; angle < 10.0f; angle += 0.1f) {
|
||||
vfpu_sincos(angle, sine, cosine);
|
||||
EXPECT_APPROX_EQ_FLOAT(sine, sinf(angle * M_PI_2));
|
||||
EXPECT_APPROX_EQ_FLOAT(cosine, cosf(angle * M_PI_2));
|
||||
|
||||
printf("sine: %f==%f cosine: %f==%f\n", sine, sinf(angle * M_PI_2), cosine, cosf(angle * M_PI_2));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user