mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-17 19:34:39 +01:00
Merge branch 'master' into mediaengine.
Note: doesn't compile, just fixes conflicts. Conflicts: Core/HLE/sceKernel.cpp Core/HLE/sceKernelThread.cpp Core/HLE/sceKernelThread.h
This commit is contained in:
commit
6f9f9e1c98
212 files changed
+11915
-5209
No files matched your search
+21
-12
@@ -1,37 +1,46 @@
|
||||
# For MSVC
|
||||
*.lastcodeanalysissucceeded
|
||||
*.pdb
|
||||
*.ilk
|
||||
*.obj
|
||||
*.pch
|
||||
Logs
|
||||
*.log
|
||||
*.dll
|
||||
*.rar
|
||||
*.exe
|
||||
*.ini
|
||||
*.map
|
||||
*.lib
|
||||
*.user
|
||||
*.sdf
|
||||
*.ncb
|
||||
Debug
|
||||
DebugFast
|
||||
Release
|
||||
*.opensdf
|
||||
*.suo
|
||||
*.aps
|
||||
*.exp
|
||||
Debug
|
||||
DebugFast
|
||||
Release
|
||||
Windows/x64
|
||||
Windows/ipch
|
||||
|
||||
# For ppsspp.ini, etc.
|
||||
*.ini
|
||||
|
||||
Logs
|
||||
Memstick
|
||||
|
||||
bin
|
||||
gen
|
||||
libs
|
||||
obj
|
||||
*.exp
|
||||
build*/
|
||||
|
||||
.pspsh.hist
|
||||
GameLogNotes.txt
|
||||
Windows/x64
|
||||
Windows/ipch
|
||||
Memstick
|
||||
android/ui_atlas.zim
|
||||
__testoutput.txt
|
||||
__testerror.txt
|
||||
__testfinish.txt
|
||||
GameLogNotes.txt
|
||||
|
||||
android/ui_atlas.zim
|
||||
ppge_atlas.zim.png
|
||||
local.properties
|
||||
build*/
|
||||
+7
-2
@@ -109,6 +109,7 @@ endif()
|
||||
|
||||
if(NOT MSVC)
|
||||
# Disable some warnings
|
||||
add_definitions(-O2)
|
||||
add_definitions(-Wno-multichar)
|
||||
add_definitions(-fno-strict-aliasing)
|
||||
if(NOT APPLE)
|
||||
@@ -764,6 +765,8 @@ add_library(${CoreLibName} ${CoreLinkType}
|
||||
Core/PSPLoaders.h
|
||||
Core/PSPMixer.cpp
|
||||
Core/PSPMixer.h
|
||||
Core/SaveState.cpp
|
||||
Core/SaveState.h
|
||||
Core/System.cpp
|
||||
Core/System.h
|
||||
Core/Util/BlockAllocator.cpp
|
||||
@@ -786,6 +789,8 @@ add_library(GPU OBJECT
|
||||
GPU/GLES/FragmentShaderGenerator.h
|
||||
GPU/GLES/Framebuffer.cpp
|
||||
GPU/GLES/Framebuffer.h
|
||||
GPU/GLES/IndexGenerator.cpp
|
||||
GPU/GLES/IndexGenerator.h
|
||||
GPU/GLES/ShaderManager.cpp
|
||||
GPU/GLES/ShaderManager.h
|
||||
GPU/GLES/StateMapping.cpp
|
||||
@@ -799,12 +804,12 @@ add_library(GPU OBJECT
|
||||
GPU/GLES/VertexShaderGenerator.cpp
|
||||
GPU/GLES/VertexShaderGenerator.h
|
||||
GPU/GPUInterface.h
|
||||
GPU/GeDisasm.cpp
|
||||
GPU/GeDisasm.h
|
||||
GPU/GPUState.cpp
|
||||
GPU/GPUState.h
|
||||
GPU/Math3D.cpp
|
||||
GPU/Math3D.h
|
||||
# GPU/Null/NullDisplayListInterpreter.cpp
|
||||
# GPU/Null/NullDisplayListInterpreter.h
|
||||
GPU/Null/NullGpu.cpp
|
||||
GPU/Null/NullGpu.h
|
||||
GPU/ge_constants.h)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "ChunkFile.h"
|
||||
|
||||
// Sometimes you want to set something to happen later, without that later place really needing
|
||||
// to know about all the things that might happen. That's when you use an Action, and add it
|
||||
@@ -17,4 +18,6 @@ class Action
|
||||
public:
|
||||
virtual ~Action() {}
|
||||
virtual void run() = 0;
|
||||
virtual void DoState(PointerWrap &p) = 0;
|
||||
int actionTypeID;
|
||||
};
|
||||
+129
-3
@@ -31,6 +31,8 @@
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <set>
|
||||
|
||||
#include "Common.h"
|
||||
#include "FileUtil.h"
|
||||
@@ -112,14 +114,59 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template<class K, class T>
|
||||
void Do(std::multimap<K, T> &x)
|
||||
{
|
||||
unsigned int number = (unsigned int)x.size();
|
||||
Do(number);
|
||||
switch (mode) {
|
||||
case MODE_READ:
|
||||
{
|
||||
x.clear();
|
||||
while (number > 0)
|
||||
{
|
||||
K first;
|
||||
Do(first);
|
||||
T second;
|
||||
Do(second);
|
||||
x.insert(std::make_pair(first, second));
|
||||
--number;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MODE_WRITE:
|
||||
case MODE_MEASURE:
|
||||
case MODE_VERIFY:
|
||||
{
|
||||
typename std::multimap<K, T>::iterator itr = x.begin();
|
||||
while (number > 0)
|
||||
{
|
||||
Do(itr->first);
|
||||
Do(itr->second);
|
||||
--number;
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Store vectors.
|
||||
template<class T>
|
||||
void Do(std::vector<T> &x)
|
||||
{
|
||||
T dv;
|
||||
Do(x, dv);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void Do(std::vector<T> &x, T &default_val)
|
||||
{
|
||||
u32 vec_size = (u32)x.size();
|
||||
Do(vec_size);
|
||||
x.resize(vec_size);
|
||||
DoArray(&x[0], vec_size);
|
||||
x.resize(vec_size, default_val);
|
||||
if (vec_size > 0)
|
||||
DoArray(&x[0], vec_size);
|
||||
}
|
||||
|
||||
// Store deques.
|
||||
@@ -133,7 +180,62 @@ public:
|
||||
for(i = 0; i < deq_size; i++)
|
||||
DoVoid(&x[i],sizeof(T));
|
||||
}
|
||||
|
||||
|
||||
// Store STL lists.
|
||||
template<class T>
|
||||
void Do(std::list<T> &x)
|
||||
{
|
||||
T dv;
|
||||
Do(x, dv);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void Do(std::list<T> &x, T &default_val)
|
||||
{
|
||||
u32 list_size = (u32)x.size();
|
||||
Do(list_size);
|
||||
x.resize(list_size, default_val);
|
||||
|
||||
typename std::list<T>::iterator itr, end;
|
||||
for (itr = x.begin(), end = x.end(); itr != end; ++itr)
|
||||
Do(*itr);
|
||||
}
|
||||
|
||||
// Store STL sets.
|
||||
template <class T>
|
||||
void Do(std::set<T> &x)
|
||||
{
|
||||
unsigned int number = (unsigned int)x.size();
|
||||
Do(number);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case MODE_READ:
|
||||
{
|
||||
x.clear();
|
||||
while (number-- > 0)
|
||||
{
|
||||
T it;
|
||||
Do(it);
|
||||
x.insert(it);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MODE_WRITE:
|
||||
case MODE_MEASURE:
|
||||
case MODE_VERIFY:
|
||||
{
|
||||
typename std::set<T>::iterator itr = x.begin();
|
||||
while (number-- > 0)
|
||||
Do(*itr++);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG(COMMON, "Savestate error: invalid mode %d.", mode);
|
||||
}
|
||||
}
|
||||
|
||||
// Store strings.
|
||||
void Do(std::string &x)
|
||||
{
|
||||
@@ -371,6 +473,30 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static bool Verify(T& _class)
|
||||
{
|
||||
u8 *ptr = 0;
|
||||
|
||||
// Step 1: Measure the space required.
|
||||
PointerWrap p(&ptr, PointerWrap::MODE_MEASURE);
|
||||
_class.DoState(p);
|
||||
size_t const sz = (size_t)ptr;
|
||||
std::vector<u8> buffer(sz);
|
||||
|
||||
// Step 2: Dump the state.
|
||||
ptr = &buffer[0];
|
||||
p.SetMode(PointerWrap::MODE_WRITE);
|
||||
_class.DoState(p);
|
||||
|
||||
// Step 3: Verify the state.
|
||||
ptr = &buffer[0];
|
||||
p.SetMode(PointerWrap::MODE_VERIFY);
|
||||
_class.DoState(p);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
struct SChunkHeader
|
||||
{
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
#define LOGGER_CONFIG "Logger.ini"
|
||||
|
||||
// Files in the directory returned by GetUserPath(D_LOGS_IDX)
|
||||
#define MAIN_LOG "dolphin.log"
|
||||
#define MAIN_LOG "ppsspp.log"
|
||||
|
||||
// Sys files
|
||||
#define TOTALDB "totaldb.dsy"
|
||||
|
||||
@@ -318,9 +318,7 @@ void ConsoleListener::Log(LogTypes::LOG_LEVELS Level, const char *Text)
|
||||
Text += 10;
|
||||
}
|
||||
SetConsoleTextAttribute(hConsole, Color);
|
||||
size_t len = strlen(Text);
|
||||
if (Text[len-1] == '\n' && Text[len-1] == '\r')
|
||||
len--;
|
||||
size_t len = strlen(Text);
|
||||
WriteConsole(hConsole, Text, (DWORD)len, &cCharsWritten, NULL);
|
||||
#else
|
||||
char ColorAttr[16] = "";
|
||||
|
||||
@@ -335,6 +335,8 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
|
||||
ERROR_LOG(COMMON,
|
||||
"Copy: failed reading from source, %s --> %s: %s",
|
||||
srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
|
||||
fclose(input);
|
||||
fclose(output);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -346,6 +348,8 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
|
||||
ERROR_LOG(COMMON,
|
||||
"Copy: failed writing to output, %s --> %s: %s",
|
||||
srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
|
||||
fclose(input);
|
||||
fclose(output);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -713,6 +717,8 @@ std::string &GetUserPath(const unsigned int DirIDX, const std::string &newPath)
|
||||
#ifdef _WIN32
|
||||
// TODO: use GetExeDirectory() here instead of ROOT_DIR so that if the cwd is changed we still have the correct paths?
|
||||
paths[D_USER_IDX] = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP;
|
||||
#elif defined(__SYMBIAN32__)
|
||||
paths[D_USER_IDX] = "E:" DIR_SEP "PPSSPP" DIR_SEP;
|
||||
#else
|
||||
if (File::Exists(ROOT_DIR DIR_SEP USERDATA_DIR))
|
||||
paths[D_USER_IDX] = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP;
|
||||
|
||||
+22
-3
@@ -87,13 +87,32 @@ public:
|
||||
return count_;
|
||||
}
|
||||
|
||||
size_t capacity() const {
|
||||
return N;
|
||||
}
|
||||
|
||||
int room() const {
|
||||
return N - count_;
|
||||
}
|
||||
|
||||
bool empty() {
|
||||
return count_;
|
||||
}
|
||||
bool empty() {
|
||||
return count_ == 0;
|
||||
}
|
||||
|
||||
void DoState(PointerWrap &p) {
|
||||
int size = N;
|
||||
p.Do(size);
|
||||
if (size != N)
|
||||
{
|
||||
ERROR_LOG(HLE, "Savestate failure: Incompatible queue size.");
|
||||
return;
|
||||
}
|
||||
p.DoArray<T>(storage_, N);
|
||||
p.Do(head_);
|
||||
p.Do(tail_);
|
||||
p.Do(count_);
|
||||
p.DoMarker("FixedSizeQueue");
|
||||
}
|
||||
|
||||
private:
|
||||
T *storage_;
|
||||
|
||||
+24
-3
@@ -69,6 +69,8 @@ LogManager::LogManager()
|
||||
m_fileLog = new FileLogListener(File::GetUserPath(F_MAINLOG_IDX).c_str());
|
||||
m_consoleLog = new ConsoleListener();
|
||||
m_debuggerLog = new DebuggerLogListener();
|
||||
#else
|
||||
m_fileLog = NULL;
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||
@@ -89,8 +91,9 @@ LogManager::~LogManager()
|
||||
{
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||
{
|
||||
if (m_fileLog != NULL)
|
||||
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_fileLog);
|
||||
#if !defined(ANDROID) && !defined(IOS) && !defined(BLACKBERRY)
|
||||
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_fileLog);
|
||||
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_consoleLog);
|
||||
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_debuggerLog);
|
||||
#endif
|
||||
@@ -98,12 +101,30 @@ LogManager::~LogManager()
|
||||
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||
delete m_Log[i];
|
||||
if (m_fileLog != NULL)
|
||||
delete m_fileLog;
|
||||
#if !defined(ANDROID) && !defined(IOS) && !defined(BLACKBERRY)
|
||||
delete m_fileLog;
|
||||
delete m_consoleLog;
|
||||
#endif
|
||||
}
|
||||
|
||||
void LogManager::ChangeFileLog(const char *filename)
|
||||
{
|
||||
if (m_fileLog != NULL)
|
||||
{
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_fileLog);
|
||||
delete m_fileLog;
|
||||
}
|
||||
|
||||
if (filename != NULL)
|
||||
{
|
||||
m_fileLog = new FileLogListener(filename);
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||
m_Log[i]->AddListener(m_fileLog);
|
||||
}
|
||||
}
|
||||
|
||||
void LogManager::SaveConfig(IniFile::Section *section)
|
||||
{
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
|
||||
@@ -139,7 +160,7 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const
|
||||
static const char level_to_char[7] = "-NEWID";
|
||||
char formattedTime[13];
|
||||
Common::Timer::GetTimeFormatted(formattedTime);
|
||||
sprintf(msg, "%s %s:%u %c[%s]: %s\n",
|
||||
sprintf(msg, "%s %s:%d %c[%s]: %s\n",
|
||||
formattedTime,
|
||||
file, line, level_to_char[(int)level],
|
||||
log->GetShortName(), temp);
|
||||
|
||||
@@ -179,6 +179,8 @@ public:
|
||||
static void Init();
|
||||
static void Shutdown();
|
||||
|
||||
void ChangeFileLog(const char *filename);
|
||||
|
||||
void SaveConfig(IniFile::Section *section);
|
||||
void LoadConfig(IniFile::Section *section);
|
||||
};
|
||||
|
||||
+1
-1
@@ -283,7 +283,7 @@ static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32
|
||||
int i;
|
||||
for (i = 0; i < num_views; i++)
|
||||
{
|
||||
const MemoryView &view = views[i];
|
||||
const MemoryView &view = views[i];
|
||||
SKIP(flags, view.flags);
|
||||
if (view.flags & MV_MIRROR_PREVIOUS) {
|
||||
position = last_position;
|
||||
|
||||
@@ -55,6 +55,7 @@ void* AllocateExecutableMemory(size_t size, bool low)
|
||||
void* ptr = VirtualAlloc(0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||
#elif defined(__SYMBIAN32__)
|
||||
// On Symbian, we will need to create an RChunk and allocate with ->CreateLocalCode(size, size);
|
||||
static char *map_hint = 0;
|
||||
void* ptr = mmap(map_hint, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, -1, 0);
|
||||
#else
|
||||
static char *map_hint = 0;
|
||||
|
||||
@@ -49,14 +49,18 @@ void CConfig::Load(const char *iniFileName)
|
||||
general->Get("IgnoreBadMemAccess", &bIgnoreBadMemAccess, true);
|
||||
general->Get("CurrentDirectory", ¤tDirectory, "");
|
||||
general->Get("ShowDebuggerOnLoad", &bShowDebuggerOnLoad, false);
|
||||
|
||||
IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU");
|
||||
cpu->Get("Core", &iCpuCore, 0);
|
||||
cpu->Get("FastMemory", &bFastMemory, false);
|
||||
|
||||
IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
|
||||
graphics->Get("ShowFPSCounter", &bShowFPSCounter, false);
|
||||
graphics->Get("DisplayFramebuffer", &bDisplayFramebuffer, false);
|
||||
graphics->Get("WindowZoom", &iWindowZoom, 1);
|
||||
graphics->Get("BufferedRendering", &bBufferedRendering, true);
|
||||
graphics->Get("HardwareTransform", &bHardwareTransform, false);
|
||||
graphics->Get("LinearFiltering", &bLinearFiltering, false);
|
||||
|
||||
IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
|
||||
sound->Get("Enable", &bEnableSound, true);
|
||||
@@ -64,6 +68,10 @@ void CConfig::Load(const char *iniFileName)
|
||||
IniFile::Section *control = iniFile.GetOrCreateSection("Control");
|
||||
control->Get("ShowStick", &bShowAnalogStick, false);
|
||||
control->Get("ShowTouchControls", &bShowTouchControls, true);
|
||||
|
||||
|
||||
// Ephemeral settings
|
||||
bDrawWireframe = false;
|
||||
}
|
||||
|
||||
void CConfig::Save()
|
||||
@@ -83,12 +91,15 @@ void CConfig::Save()
|
||||
general->Set("ShowDebuggerOnLoad", bShowDebuggerOnLoad);
|
||||
IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU");
|
||||
cpu->Set("Core", iCpuCore);
|
||||
cpu->Set("FastMemory", bFastMemory);
|
||||
|
||||
IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
|
||||
graphics->Set("ShowFPSCounter", bShowFPSCounter);
|
||||
graphics->Set("DisplayFramebuffer", bDisplayFramebuffer);
|
||||
graphics->Set("WindowZoom", iWindowZoom);
|
||||
graphics->Set("BufferedRendering", bBufferedRendering);
|
||||
graphics->Set("HardwareTransform", bHardwareTransform);
|
||||
graphics->Set("LinearFiltering", bLinearFiltering);
|
||||
|
||||
IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
|
||||
sound->Set("Enable", bEnableSound);
|
||||
|
||||
+21
-8
@@ -32,25 +32,38 @@ public:
|
||||
CConfig();
|
||||
~CConfig();
|
||||
|
||||
// Many of these are currently broken.
|
||||
bool bEnableSound;
|
||||
bool bAutoLoadLast;
|
||||
// Whether to save the config on close.
|
||||
bool bSaveSettings;
|
||||
|
||||
// These are broken
|
||||
bool bAutoLoadLast;
|
||||
bool bFirstRun;
|
||||
bool bAutoRun;
|
||||
bool bSpeedLimit;
|
||||
bool bConfirmOnQuit;
|
||||
bool bIgnoreBadMemAccess;
|
||||
bool bDisplayFramebuffer;
|
||||
bool bBufferedRendering;
|
||||
|
||||
// Core
|
||||
bool bIgnoreBadMemAccess;
|
||||
bool bFastMemory;
|
||||
int iCpuCore;
|
||||
|
||||
// GFX
|
||||
bool bDisplayFramebuffer;
|
||||
bool bHardwareTransform;
|
||||
bool bBufferedRendering;
|
||||
bool bDrawWireframe;
|
||||
bool bLinearFiltering;
|
||||
int iWindowZoom; // for Windows
|
||||
|
||||
// Sound
|
||||
bool bEnableSound;
|
||||
|
||||
// UI
|
||||
bool bShowTouchControls;
|
||||
bool bShowDebuggerOnLoad;
|
||||
bool bShowAnalogStick;
|
||||
bool bShowFPSCounter;
|
||||
bool bShowDebugStats;
|
||||
int iWindowZoom; // for Windows
|
||||
int iCpuCore;
|
||||
|
||||
std::string currentDirectory;
|
||||
std::string memCardDirectory;
|
||||
|
||||
+3
-3
@@ -81,7 +81,7 @@ void Core_SingleStep()
|
||||
// Some platforms, like Android, do not call this function but handle things on their own.
|
||||
void Core_Run()
|
||||
{
|
||||
#if _DEBUG
|
||||
#if defined(_DEBUG)
|
||||
host->UpdateDisassembly();
|
||||
#endif
|
||||
|
||||
@@ -129,14 +129,14 @@ void Core_EnableStepping(bool step)
|
||||
//PowerPC::Pause();
|
||||
// Sleep(1);
|
||||
sleep_ms(1);
|
||||
#if _DEBUG
|
||||
#if defined(_DEBUG)
|
||||
host->SetDebugMode(true);
|
||||
#endif
|
||||
coreState=CORE_STEPPING;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if _DEBUG
|
||||
#if defined(_DEBUG)
|
||||
host->SetDebugMode(false);
|
||||
#endif
|
||||
coreState = CORE_RUNNING;
|
||||
|
||||
+2
-1
@@ -33,9 +33,10 @@ void Core_Halt(const char *msg);
|
||||
|
||||
bool Core_IsStepping();
|
||||
|
||||
// RUNNING must be at 0.
|
||||
enum CoreState
|
||||
{
|
||||
CORE_RUNNING,
|
||||
CORE_RUNNING = 0,
|
||||
CORE_STEPPING,
|
||||
CORE_POWERDOWN,
|
||||
CORE_ERROR,
|
||||
|
||||
@@ -91,6 +91,9 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>../common;..;../native;../native/ext/glew;../ext/zlib</AdditionalIncludeDirectories>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@@ -251,6 +254,7 @@
|
||||
<ClCompile Include="MIPS\x86\RegCache.cpp" />
|
||||
<ClCompile Include="PSPLoaders.cpp" />
|
||||
<ClCompile Include="PSPMixer.cpp" />
|
||||
<ClCompile Include="SaveState.cpp" />
|
||||
<ClCompile Include="System.cpp" />
|
||||
<ClCompile Include="Util\BlockAllocator.cpp" />
|
||||
<ClCompile Include="Util\PPGeDraw.cpp" />
|
||||
@@ -370,6 +374,7 @@
|
||||
<ClInclude Include="MIPS\x86\RegCache.h" />
|
||||
<ClInclude Include="PSPLoaders.h" />
|
||||
<ClInclude Include="PSPMixer.h" />
|
||||
<ClInclude Include="SaveState.h" />
|
||||
<ClInclude Include="System.h" />
|
||||
<ClInclude Include="Util\BlockAllocator.h" />
|
||||
<ClInclude Include="Util\Pool.h" />
|
||||
|
||||
@@ -351,6 +351,9 @@
|
||||
<ClCompile Include="HLE\sceUsb.cpp">
|
||||
<Filter>HLE\Libraries</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SaveState.cpp">
|
||||
<Filter>Core</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ELF\ElfReader.h">
|
||||
@@ -647,6 +650,9 @@
|
||||
<ClInclude Include="HLE\sceUsb.h">
|
||||
<Filter>HLE\Libraries</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SaveState.h">
|
||||
<Filter>Core</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="CMakeLists.txt" />
|
||||
|
||||
+53
-14
@@ -24,6 +24,7 @@
|
||||
#include "CoreTiming.h"
|
||||
#include "Core.h"
|
||||
#include "HLE/sceKernelThread.h"
|
||||
#include "../Common/ChunkFile.h"
|
||||
|
||||
int CPU_HZ = 222000000;
|
||||
|
||||
@@ -36,6 +37,11 @@ namespace CoreTiming
|
||||
|
||||
struct EventType
|
||||
{
|
||||
EventType() {}
|
||||
|
||||
EventType(TimedCallback cb, const char *n)
|
||||
: callback(cb), name(n) {}
|
||||
|
||||
TimedCallback callback;
|
||||
const char *name;
|
||||
};
|
||||
@@ -50,12 +56,6 @@ struct BaseEvent
|
||||
// Event *next;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct LinkedListItem : public T
|
||||
{
|
||||
LinkedListItem<T> *next;
|
||||
};
|
||||
|
||||
typedef LinkedListItem<BaseEvent> Event;
|
||||
|
||||
Event *first;
|
||||
@@ -74,11 +74,13 @@ s64 idledCycles;
|
||||
|
||||
static std::recursive_mutex externalEventSection;
|
||||
|
||||
// Warning: not included in save state.
|
||||
void (*advanceCallback)(int cyclesExecuted) = NULL;
|
||||
|
||||
void SetClockFrequencyMHz(int cpuMhz)
|
||||
{
|
||||
CPU_HZ = cpuMhz * 1000000;
|
||||
// TODO: Rescale times of scheduled events?
|
||||
}
|
||||
|
||||
int GetClockFrequencyMHz()
|
||||
@@ -124,13 +126,24 @@ void FreeTsEvent(Event* ev)
|
||||
|
||||
int RegisterEvent(const char *name, TimedCallback callback)
|
||||
{
|
||||
EventType type;
|
||||
type.name = name;
|
||||
type.callback = callback;
|
||||
event_types.push_back(type);
|
||||
event_types.push_back(EventType(callback, name));
|
||||
return (int)event_types.size() - 1;
|
||||
}
|
||||
|
||||
void AntiCrashCallback(u64 userdata, int cyclesLate)
|
||||
{
|
||||
ERROR_LOG(CPU, "Savestate broken: an unregistered event was called.");
|
||||
Core_Halt("invalid timing events");
|
||||
}
|
||||
|
||||
void RestoreRegisterEvent(int event_type, const char *name, TimedCallback callback)
|
||||
{
|
||||
if (event_type >= (int) event_types.size())
|
||||
event_types.resize(event_type + 1, EventType(AntiCrashCallback, "INVALID EVENT"));
|
||||
|
||||
event_types[event_type] = EventType(callback, name);
|
||||
}
|
||||
|
||||
void UnregisterAllEvents()
|
||||
{
|
||||
if (first)
|
||||
@@ -245,7 +258,7 @@ void ScheduleEvent(int cyclesIntoFuture, int event_type, u64 userdata)
|
||||
Event *ne = GetNewEvent();
|
||||
ne->userdata = userdata;
|
||||
ne->type = event_type;
|
||||
ne->time = globalTimer + cyclesIntoFuture;
|
||||
ne->time = GetTicks() + cyclesIntoFuture;
|
||||
AddEventToQueue(ne);
|
||||
}
|
||||
|
||||
@@ -294,6 +307,7 @@ u64 UnscheduleEvent(int event_type, u64 userdata)
|
||||
return result;
|
||||
}
|
||||
|
||||
// Warning: not included in save state.
|
||||
void RegisterAdvanceCallback(void (*callback)(int cyclesExecuted))
|
||||
{
|
||||
advanceCallback = callback;
|
||||
@@ -420,7 +434,7 @@ void ProcessFifoWaitEvents()
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MoveEvents()
|
||||
@@ -437,7 +451,7 @@ void MoveEvents()
|
||||
|
||||
// Move free events to threadsafe pool
|
||||
while(allocatedTsEvents > 0 && eventPool)
|
||||
{
|
||||
{
|
||||
Event *ev = eventPool;
|
||||
eventPool = ev->next;
|
||||
ev->next = eventTsPool;
|
||||
@@ -454,7 +468,7 @@ void Advance()
|
||||
|
||||
ProcessFifoWaitEvents();
|
||||
|
||||
if (!first)
|
||||
if (!first)
|
||||
{
|
||||
// WARN_LOG(CPU, "WARNING - no events in queue. Setting downcount to 10000");
|
||||
downcount += 10000;
|
||||
@@ -529,4 +543,29 @@ std::string GetScheduledEventsSummary()
|
||||
return text;
|
||||
}
|
||||
|
||||
void Event_DoState(PointerWrap &p, BaseEvent *ev)
|
||||
{
|
||||
p.Do(*ev);
|
||||
}
|
||||
|
||||
void DoState(PointerWrap &p)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lk(externalEventSection);
|
||||
|
||||
int n = (int) event_types.size();
|
||||
p.Do(n);
|
||||
// These (should) be filled in later by the modules.
|
||||
event_types.resize(n, EventType(AntiCrashCallback, "INVALID EVENT"));
|
||||
|
||||
p.DoLinkedList<BaseEvent, GetNewEvent, FreeEvent, Event_DoState>(first, (Event **) NULL);
|
||||
p.DoLinkedList<BaseEvent, GetNewTsEvent, FreeTsEvent, Event_DoState>(tsFirst, &tsLast);
|
||||
|
||||
p.Do(CPU_HZ);
|
||||
p.Do(downcount);
|
||||
p.Do(slicelength);
|
||||
p.Do(globalTimer);
|
||||
p.Do(idledCycles);
|
||||
p.DoMarker("CoreTiming");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -32,6 +32,7 @@
|
||||
// ScheduleEvent(periodInCycles - cyclesLate, callback, "whatever")
|
||||
|
||||
#include "../Globals.h"
|
||||
#include "../Common/ChunkFile.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -58,6 +59,10 @@ inline int usToCycles(int us) {
|
||||
return (int)(CPU_HZ / 1000000 * us);
|
||||
}
|
||||
|
||||
inline u64 usToCycles(u64 us) {
|
||||
return (u64)(CPU_HZ / 1000000ULL * us);
|
||||
}
|
||||
|
||||
inline u64 cyclesToUs(u64 cycles) {
|
||||
return cycles / (CPU_HZ / 1000000);
|
||||
}
|
||||
@@ -74,6 +79,8 @@ namespace CoreTiming
|
||||
|
||||
// Returns the event_type identifier.
|
||||
int RegisterEvent(const char *name, TimedCallback callback);
|
||||
// For save states.
|
||||
void RestoreRegisterEvent(int event_type, const char *name, TimedCallback callback);
|
||||
void UnregisterAllEvents();
|
||||
|
||||
// userdata MAY NOT CONTAIN POINTERS. userdata might get written and reloaded from disk,
|
||||
@@ -99,10 +106,13 @@ namespace CoreTiming
|
||||
|
||||
void LogPendingEvents();
|
||||
|
||||
// Warning: not included in save states.
|
||||
void RegisterAdvanceCallback(void (*callback)(int cyclesExecuted));
|
||||
|
||||
std::string GetScheduledEventsSummary();
|
||||
|
||||
void DoState(PointerWrap &p);
|
||||
|
||||
void SetClockFrequencyMHz(int cpuMhz);
|
||||
int GetClockFrequencyMHz();
|
||||
extern int downcount;
|
||||
|
||||
@@ -40,7 +40,7 @@ void MemCheck::Action(u32 iValue, u32 addr, bool write, int size, u32 pc)
|
||||
if (bLog)
|
||||
{
|
||||
char temp[256];
|
||||
printf(temp,"CHK %08x %s%i at %08x (%s), PC=%08x (%s)",iValue,write?"Write":"Read",size*8,addr,symbolMap.GetDescription(addr),pc,symbolMap.GetDescription(pc));
|
||||
sprintf(temp,"CHK %08x %s%i at %08x (%s), PC=%08x (%s)",iValue,write?"Write":"Read",size*8,addr,symbolMap.GetDescription(addr),pc,symbolMap.GetDescription(pc));
|
||||
ERROR_LOG(MEMMAP,"%s",temp);
|
||||
}
|
||||
if (bBreak)
|
||||
|
||||
@@ -144,10 +144,9 @@ bool SymbolMap::LoadSymbolMap(const char *filename)
|
||||
{
|
||||
char line[512],temp[256];
|
||||
fgets(line,511,f);
|
||||
if (strlen(line)<4)
|
||||
if (strlen(line) < 4 || sscanf(line, "%s", temp) != 1)
|
||||
continue;
|
||||
|
||||
sscanf(line,"%s",temp);
|
||||
if (strcmp(temp,"UNUSED")==0) continue;
|
||||
if (strcmp(temp,".text")==0) {started=true;continue;};
|
||||
if (strcmp(temp,".init")==0) {started=true;continue;};
|
||||
@@ -233,7 +232,7 @@ int SymbolMap::GetSymbolNum(unsigned int address, SymbolType symmask)
|
||||
}
|
||||
|
||||
|
||||
char temp[256];
|
||||
char descriptionTemp[256];
|
||||
|
||||
char *SymbolMap::GetDescription(unsigned int address)
|
||||
{
|
||||
@@ -244,8 +243,8 @@ char *SymbolMap::GetDescription(unsigned int address)
|
||||
return entries[fun].name;
|
||||
else
|
||||
{
|
||||
sprintf(temp, "(%08x)", address);
|
||||
return temp;
|
||||
sprintf(descriptionTemp, "(%08x)", address);
|
||||
return descriptionTemp;
|
||||
}
|
||||
//}
|
||||
//else
|
||||
@@ -438,11 +437,12 @@ void SymbolMap::UseFuncSignaturesFile(const char *filename, u32 maxAddress)
|
||||
//#1: Read the signature file and put them in a fast data structure
|
||||
FILE *f = fopen(filename, "r");
|
||||
int count;
|
||||
fscanf(f,"%08x\n",&count);
|
||||
u32 inst,size,hash;
|
||||
if (fscanf(f, "%08x\n", &count) != 1)
|
||||
count = 0;
|
||||
char name[256];
|
||||
for (int a=0; a<count; a++)
|
||||
{
|
||||
u32 inst, size, hash;
|
||||
if (fscanf(f,"%08x\t%08x\t%08x\t%s\n",&inst,&size,&hash,name)!=EOF)
|
||||
sigs[numSigs++]=Sig(inst,size,hash,name);
|
||||
else
|
||||
|
||||
@@ -53,14 +53,23 @@ void PSPDialog::DisplayMessage(std::string text)
|
||||
PPGeDrawText(text.c_str(), 480/2, 100, PPGE_ALIGN_CENTER, 0.5f, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
void PSPDialog::Shutdown()
|
||||
int PSPDialog::Shutdown()
|
||||
{
|
||||
status = SCE_UTILITY_STATUS_SHUTDOWN;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PSPDialog::Update()
|
||||
int PSPDialog::Update()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PSPDialog::DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(status);
|
||||
p.Do(lastButtons);
|
||||
p.Do(buttons);
|
||||
p.DoMarker("PSPDialog");
|
||||
}
|
||||
|
||||
bool PSPDialog::IsButtonPressed(int checkButton)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
#include "../Config.h"
|
||||
#include "../../Common/ChunkFile.h"
|
||||
|
||||
#define SCE_UTILITY_DIALOG_RESULT_SUCCESS 0
|
||||
#define SCE_UTILITY_DIALOG_RESULT_CANCEL 1
|
||||
@@ -45,8 +46,9 @@ public:
|
||||
PSPDialog();
|
||||
virtual ~PSPDialog();
|
||||
|
||||
virtual void Update();
|
||||
virtual void Shutdown();
|
||||
virtual int Update();
|
||||
virtual int Shutdown();
|
||||
virtual void DoState(PointerWrap &p);
|
||||
|
||||
enum DialogStatus
|
||||
{
|
||||
|
||||
@@ -29,12 +29,18 @@ PSPMsgDialog::PSPMsgDialog()
|
||||
PSPMsgDialog::~PSPMsgDialog() {
|
||||
}
|
||||
|
||||
void PSPMsgDialog::Init(unsigned int paramAddr)
|
||||
int PSPMsgDialog::Init(unsigned int paramAddr)
|
||||
{
|
||||
// Ignore if already running
|
||||
if (status != SCE_UTILITY_STATUS_NONE && status != SCE_UTILITY_STATUS_SHUTDOWN)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
messageDialogAddr = paramAddr;
|
||||
if (!Memory::IsValidAddress(messageDialogAddr))
|
||||
{
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
Memory::ReadStruct(messageDialogAddr, &messageDialog);
|
||||
|
||||
@@ -57,7 +63,7 @@ void PSPMsgDialog::Init(unsigned int paramAddr)
|
||||
status = SCE_UTILITY_STATUS_INITIALIZE;
|
||||
|
||||
lastButtons = __CtrlPeekButtons();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PSPMsgDialog::DisplayBack()
|
||||
@@ -89,7 +95,7 @@ void PSPMsgDialog::DisplayEnterBack()
|
||||
PPGeDrawText("Back", 320, 220, PPGE_ALIGN_LEFT, 0.5f, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
void PSPMsgDialog::Update()
|
||||
int PSPMsgDialog::Update()
|
||||
{
|
||||
switch (status) {
|
||||
case SCE_UTILITY_STATUS_FINISHED:
|
||||
@@ -99,7 +105,7 @@ void PSPMsgDialog::Update()
|
||||
|
||||
if (status != SCE_UTILITY_STATUS_RUNNING)
|
||||
{
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *text;
|
||||
@@ -185,17 +191,30 @@ void PSPMsgDialog::Update()
|
||||
break;
|
||||
default:
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
return;
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
lastButtons = buttons;
|
||||
|
||||
Memory::WriteStruct(messageDialogAddr, &messageDialog);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PSPMsgDialog::Shutdown()
|
||||
int PSPMsgDialog::Shutdown()
|
||||
{
|
||||
PSPDialog::Shutdown();
|
||||
return PSPDialog::Shutdown();
|
||||
}
|
||||
|
||||
void PSPMsgDialog::DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(display);
|
||||
p.Do(messageDialog);
|
||||
p.Do(messageDialogAddr);
|
||||
p.Do(yesnoChoice);
|
||||
p.Do(okButtonImg);
|
||||
p.Do(cancelButtonImg);
|
||||
p.Do(okButtonFlag);
|
||||
p.Do(cancelButtonFlag);
|
||||
p.DoMarker("PSPMsgDialog");
|
||||
}
|
||||
@@ -41,9 +41,10 @@ public:
|
||||
PSPMsgDialog();
|
||||
virtual ~PSPMsgDialog();
|
||||
|
||||
virtual void Init(unsigned int paramAddr);
|
||||
virtual void Update();
|
||||
void Shutdown();
|
||||
virtual int Init(unsigned int paramAddr);
|
||||
virtual int Update();
|
||||
virtual int Shutdown();
|
||||
virtual void DoState(PointerWrap &p);
|
||||
|
||||
private :
|
||||
void DisplayBack();
|
||||
|
||||
+149
-139
@@ -19,131 +19,17 @@
|
||||
#include "../Util/PPGeDraw.h"
|
||||
#include "../HLE/sceCtrl.h"
|
||||
|
||||
|
||||
/**
|
||||
* Enumeration for input language
|
||||
*/
|
||||
enum SceUtilityOskInputLanguage
|
||||
#define NUMKEYROWS 4
|
||||
#define KEYSPERROW 12
|
||||
#define NUMBEROFVALIDCHARS (KEYSPERROW * NUMKEYROWS)
|
||||
const char oskKeys[NUMKEYROWS][KEYSPERROW + 1] =
|
||||
{
|
||||
PSP_UTILITY_OSK_LANGUAGE_DEFAULT = 0x00,
|
||||
PSP_UTILITY_OSK_LANGUAGE_JAPANESE = 0x01,
|
||||
PSP_UTILITY_OSK_LANGUAGE_ENGLISH = 0x02,
|
||||
PSP_UTILITY_OSK_LANGUAGE_FRENCH = 0x03,
|
||||
PSP_UTILITY_OSK_LANGUAGE_SPANISH = 0x04,
|
||||
PSP_UTILITY_OSK_LANGUAGE_GERMAN = 0x05,
|
||||
PSP_UTILITY_OSK_LANGUAGE_ITALIAN = 0x06,
|
||||
PSP_UTILITY_OSK_LANGUAGE_DUTCH = 0x07,
|
||||
PSP_UTILITY_OSK_LANGUAGE_PORTUGESE = 0x08,
|
||||
PSP_UTILITY_OSK_LANGUAGE_RUSSIAN = 0x09,
|
||||
PSP_UTILITY_OSK_LANGUAGE_KOREAN = 0x0a
|
||||
{'1','2','3','4','5','6','7','8','9','0','-','+','\0'},
|
||||
{'Q','W','E','R','T','Y','U','I','O','P','[',']','\0'},
|
||||
{'A','S','D','F','G','H','J','K','L',';','@','~','\0'},
|
||||
{'Z','X','C','V','B','N','M',',','.','/','?','\\','\0'},
|
||||
};
|
||||
|
||||
/**
|
||||
* Enumeration for OSK internal state
|
||||
*/
|
||||
enum SceUtilityOskState
|
||||
{
|
||||
PSP_UTILITY_OSK_DIALOG_NONE = 0, /**< No OSK is currently active */
|
||||
PSP_UTILITY_OSK_DIALOG_INITING, /**< The OSK is currently being initialized */
|
||||
PSP_UTILITY_OSK_DIALOG_INITED, /**< The OSK is initialised */
|
||||
PSP_UTILITY_OSK_DIALOG_VISIBLE, /**< The OSK is visible and ready for use */
|
||||
PSP_UTILITY_OSK_DIALOG_QUIT, /**< The OSK has been cancelled and should be shut down */
|
||||
PSP_UTILITY_OSK_DIALOG_FINISHED /**< The OSK has successfully shut down */
|
||||
};
|
||||
|
||||
/**
|
||||
* Enumeration for OSK field results
|
||||
*/
|
||||
enum SceUtilityOskResult
|
||||
{
|
||||
PSP_UTILITY_OSK_RESULT_UNCHANGED = 0,
|
||||
PSP_UTILITY_OSK_RESULT_CANCELLED,
|
||||
PSP_UTILITY_OSK_RESULT_CHANGED
|
||||
};
|
||||
|
||||
/**
|
||||
* Enumeration for input types (these are limited by initial choice of language)
|
||||
*/
|
||||
enum SceUtilityOskInputType
|
||||
{
|
||||
PSP_UTILITY_OSK_INPUTTYPE_ALL = 0x00000000,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_LATIN_DIGIT = 0x00000001,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_LATIN_SYMBOL = 0x00000002,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_LATIN_LOWERCASE = 0x00000004,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_LATIN_UPPERCASE = 0x00000008,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_DIGIT = 0x00000100,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_SYMBOL = 0x00000200,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_LOWERCASE = 0x00000400,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_UPPERCASE = 0x00000800,
|
||||
// http://en.wikipedia.org/wiki/Hiragana
|
||||
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_HIRAGANA = 0x00001000,
|
||||
// http://en.wikipedia.org/wiki/Katakana
|
||||
// Half-width Katakana
|
||||
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_HALF_KATAKANA = 0x00002000,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_KATAKANA = 0x00004000,
|
||||
// http://en.wikipedia.org/wiki/Kanji
|
||||
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_KANJI = 0x00008000,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_RUSSIAN_LOWERCASE = 0x00010000,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_RUSSIAN_UPPERCASE = 0x00020000,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_KOREAN = 0x00040000,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_URL = 0x00080000
|
||||
};
|
||||
|
||||
/**
|
||||
* OSK Field data
|
||||
*/
|
||||
typedef struct _SceUtilityOskData
|
||||
{
|
||||
/** Unknown. Pass 0. */
|
||||
int unk_00;
|
||||
/** Unknown. Pass 0. */
|
||||
int unk_04;
|
||||
/** One of ::SceUtilityOskInputLanguage */
|
||||
int language;
|
||||
/** Unknown. Pass 0. */
|
||||
int unk_12;
|
||||
/** One or more of ::SceUtilityOskInputType (types that are selectable by pressing SELECT) */
|
||||
int inputtype;
|
||||
/** Number of lines */
|
||||
int lines;
|
||||
/** Unknown. Pass 0. */
|
||||
int unk_24;
|
||||
/** Description text */
|
||||
u32 descPtr;
|
||||
/** Initial text */
|
||||
u32 intextPtr;
|
||||
/** Length of output text */
|
||||
int outtextlength;
|
||||
/** Pointer to the output text */
|
||||
u32 outtextPtr;
|
||||
/** Result. One of ::SceUtilityOskResult */
|
||||
int result;
|
||||
/** The max text that can be input */
|
||||
int outtextlimit;
|
||||
|
||||
} SceUtilityOskData;
|
||||
|
||||
/**
|
||||
* OSK parameters
|
||||
*/
|
||||
typedef struct _SceUtilityOskParams
|
||||
{
|
||||
pspUtilityDialogCommon base;
|
||||
int datacount; /** Number of input fields */
|
||||
u32 SceUtilityOskDataPtr; /** Pointer to the start of the data for the input fields */
|
||||
int state; /** The local OSK state, one of ::SceUtilityOskState */
|
||||
int unk_60;/** Unknown. Pass 0 */
|
||||
|
||||
} SceUtilityOskParams;
|
||||
|
||||
SceUtilityOskParams oskParams;
|
||||
SceUtilityOskData oskData;
|
||||
std::string oskDesc;
|
||||
std::string oskIntext;
|
||||
std::string oskOuttext;
|
||||
|
||||
int oskParamsAddr;
|
||||
|
||||
|
||||
PSPOskDialog::PSPOskDialog() : PSPDialog() {
|
||||
|
||||
@@ -152,7 +38,6 @@ PSPOskDialog::PSPOskDialog() : PSPDialog() {
|
||||
PSPOskDialog::~PSPOskDialog() {
|
||||
}
|
||||
|
||||
|
||||
// Same as get string but read out 16bit
|
||||
void PSPOskDialog::HackyGetStringWide(std::string& _string, const u32 em_address)
|
||||
{
|
||||
@@ -160,7 +45,7 @@ void PSPOskDialog::HackyGetStringWide(std::string& _string, const u32 em_address
|
||||
char *string = stringBuffer;
|
||||
char c;
|
||||
u32 addr = em_address;
|
||||
while ((c = (Memory::Read_U16(addr))))
|
||||
while ((c = (char)(Memory::Read_U16(addr))))
|
||||
{
|
||||
*string++ = c;
|
||||
addr+=2;
|
||||
@@ -172,11 +57,20 @@ void PSPOskDialog::HackyGetStringWide(std::string& _string, const u32 em_address
|
||||
|
||||
int PSPOskDialog::Init(u32 oskPtr)
|
||||
{
|
||||
// Ignore if already running
|
||||
if (status != SCE_UTILITY_STATUS_NONE && status != SCE_UTILITY_STATUS_SHUTDOWN)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
status = SCE_UTILITY_STATUS_INITIALIZE;
|
||||
|
||||
memset(&oskParams, 0, sizeof(oskParams));
|
||||
memset(&oskData, 0, sizeof(oskData));
|
||||
// TODO: should this be init'd to oskIntext?
|
||||
inputChars.clear();
|
||||
oskParamsAddr = oskPtr;
|
||||
selectedChar = 0;
|
||||
|
||||
if (Memory::IsValidAddress(oskPtr))
|
||||
{
|
||||
Memory::ReadStruct(oskPtr, &oskParams);
|
||||
@@ -192,14 +86,74 @@ int PSPOskDialog::Init(u32 oskPtr)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Eat any keys pressed before the dialog inited.
|
||||
__CtrlReadLatch();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PSPOskDialog::Update()
|
||||
|
||||
void PSPOskDialog::RenderKeyboard()
|
||||
{
|
||||
buttons = __CtrlPeekButtons();
|
||||
//__UtilityUpdate();
|
||||
int selectedRow = selectedChar / KEYSPERROW;
|
||||
int selectedExtra = selectedChar % KEYSPERROW;
|
||||
|
||||
char temp[2];
|
||||
temp[1] = '\0';
|
||||
|
||||
int limit = oskData.outtextlimit;
|
||||
// TODO: Test more thoroughly. Encountered a game where this was 0.
|
||||
if (limit <= 0)
|
||||
limit = 16;
|
||||
|
||||
const float keyboardLeftSide = (480.0f - (23.0f * KEYSPERROW)) / 2.0f;
|
||||
float previewLeftSide = (480.0f - (15.0f * limit)) / 2.0f;
|
||||
|
||||
PPGeDrawText(oskDesc.c_str(), 480/2, 20, PPGE_ALIGN_CENTER, 0.5f, 0xFFFFFFFF);
|
||||
for (int i = 0; i < limit; ++i)
|
||||
{
|
||||
u32 color = 0xFFFFFFFF;
|
||||
if (i < (int) inputChars.size())
|
||||
temp[0] = inputChars[i];
|
||||
else if (i == inputChars.size())
|
||||
{
|
||||
temp[0] = oskKeys[selectedRow][selectedExtra];
|
||||
color = 0xFF3060FF;
|
||||
}
|
||||
else
|
||||
temp[0] = '_';
|
||||
|
||||
PPGeDrawText(temp, previewLeftSide + (i * 16.0f), 40.0f, NULL, 0.5f, color);
|
||||
}
|
||||
for (int row = 0; row < NUMKEYROWS; ++row)
|
||||
{
|
||||
for (int col = 0; col < KEYSPERROW; ++col)
|
||||
{
|
||||
u32 color = 0xFFFFFFFF;
|
||||
if (selectedRow == row && col == selectedExtra)
|
||||
color = 0xFF7f7f7f;
|
||||
|
||||
temp[0] = oskKeys[row][col];
|
||||
PPGeDrawText(temp, keyboardLeftSide + (25.0f * col), 70.0f + (25.0f * row), NULL, 0.6f, color);
|
||||
|
||||
if (selectedRow == row && col == selectedExtra)
|
||||
PPGeDrawText("_", keyboardLeftSide + (25.0f * col), 70.0f + (25.0f * row), NULL, 0.6f, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int PSPOskDialog::Update()
|
||||
{
|
||||
buttons = __CtrlReadLatch();
|
||||
int selectedRow = selectedChar / KEYSPERROW;
|
||||
int selectedExtra = selectedChar % KEYSPERROW;
|
||||
|
||||
int limit = oskData.outtextlimit;
|
||||
// TODO: Test more thoroughly. Encountered a game where this was 0.
|
||||
if (limit <= 0)
|
||||
limit = 16;
|
||||
|
||||
if (status == SCE_UTILITY_STATUS_INITIALIZE)
|
||||
{
|
||||
status = SCE_UTILITY_STATUS_RUNNING;
|
||||
@@ -207,12 +161,52 @@ void PSPOskDialog::Update()
|
||||
else if (status == SCE_UTILITY_STATUS_RUNNING)
|
||||
{
|
||||
StartDraw();
|
||||
RenderKeyboard();
|
||||
PPGeDrawImage(I_CROSS, 100, 220, 20, 20, 0, 0xFFFFFFFF);
|
||||
PPGeDrawText("Select", 130, 220, PPGE_ALIGN_LEFT, 0.5f, 0xFFFFFFFF);
|
||||
|
||||
PPGeDrawImage(I_CIRCLE, 200, 220, 20, 20, 0, 0xFFFFFFFF);
|
||||
PPGeDrawText("Delete", 230, 220, PPGE_ALIGN_LEFT, 0.5f, 0xFFFFFFFF);
|
||||
|
||||
PPGeDrawImage(I_BUTTON, 290, 220, 50, 20, 0, 0xFFFFFFFF);
|
||||
PPGeDrawText("Start", 305, 220, PPGE_ALIGN_LEFT, 0.5f, 0xFFFFFFFF);
|
||||
PPGeDrawText("Finish", 350, 220, PPGE_ALIGN_LEFT, 0.5f, 0xFFFFFFFF);
|
||||
|
||||
if (IsButtonPressed(CTRL_UP))
|
||||
{
|
||||
selectedChar -= KEYSPERROW;
|
||||
}
|
||||
else if (IsButtonPressed(CTRL_DOWN))
|
||||
{
|
||||
selectedChar += KEYSPERROW;
|
||||
}
|
||||
else if (IsButtonPressed(CTRL_LEFT))
|
||||
{
|
||||
selectedChar--;
|
||||
if (((selectedChar + KEYSPERROW) % KEYSPERROW) == KEYSPERROW - 1)
|
||||
selectedChar += KEYSPERROW;
|
||||
}
|
||||
else if (IsButtonPressed(CTRL_RIGHT))
|
||||
{
|
||||
selectedChar++;
|
||||
if ((selectedChar % KEYSPERROW) == 0)
|
||||
selectedChar -= KEYSPERROW;
|
||||
}
|
||||
|
||||
selectedChar = (selectedChar + NUMBEROFVALIDCHARS) % NUMBEROFVALIDCHARS;
|
||||
|
||||
DisplayMessage(oskDesc);
|
||||
PPGeDrawImage(I_CROSS, 200, 220, 20, 20, 0, 0xFFFFFFFF);
|
||||
PPGeDrawText("Ignore", 230, 220, PPGE_ALIGN_LEFT, 0.5f, 0xFFFFFFFF);
|
||||
// TODO : Dialogs should take control over input and not send them to the game while displaying
|
||||
if (IsButtonPressed(CTRL_CROSS))
|
||||
{
|
||||
if ((int) inputChars.size() < limit)
|
||||
inputChars += oskKeys[selectedRow][selectedExtra];
|
||||
}
|
||||
else if (IsButtonPressed(CTRL_CIRCLE))
|
||||
{
|
||||
if (inputChars.size() > 0)
|
||||
inputChars.resize(inputChars.size() - 1);
|
||||
}
|
||||
else if (IsButtonPressed(CTRL_START))
|
||||
{
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
}
|
||||
@@ -222,17 +216,33 @@ void PSPOskDialog::Update()
|
||||
{
|
||||
status = SCE_UTILITY_STATUS_SHUTDOWN;
|
||||
}
|
||||
// just fake the return values to be "000000" as this will work for most cases e.g. when restricted to entering just numbers
|
||||
Memory::Write_U16(0x0030,oskData.outtextPtr);
|
||||
Memory::Write_U16(0x0030,oskData.outtextPtr+2);
|
||||
Memory::Write_U16(0x0030,oskData.outtextPtr+4);
|
||||
Memory::Write_U16(0x0030,oskData.outtextPtr+6);
|
||||
Memory::Write_U16(0x0030,oskData.outtextPtr+8);
|
||||
Memory::Write_U16(0x0030,oskData.outtextPtr+10);
|
||||
Memory::Write_U16(0x0030,oskData.outtextPtr+12);
|
||||
oskData.outtextlength = 6;
|
||||
|
||||
for (int i = 0; i < limit; ++i)
|
||||
{
|
||||
u16 value = 0;
|
||||
if (i < (int) inputChars.size())
|
||||
value = 0x0000 ^ inputChars[i];
|
||||
Memory::Write_U16(value, oskData.outtextPtr + (2 * i));
|
||||
}
|
||||
|
||||
oskData.outtextlength = inputChars.size();
|
||||
oskParams.base.result= 0;
|
||||
oskData.result = PSP_UTILITY_OSK_RESULT_CHANGED;
|
||||
Memory::WriteStruct(oskParams.SceUtilityOskDataPtr, &oskData);
|
||||
Memory::WriteStruct(oskParamsAddr, &oskParams);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PSPOskDialog::DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(oskParams);
|
||||
p.Do(oskData);
|
||||
p.Do(oskDesc);
|
||||
p.Do(oskIntext);
|
||||
p.Do(oskOuttext);
|
||||
p.Do(oskParamsAddr);
|
||||
p.Do(selectedChar);
|
||||
p.Do(inputChars);
|
||||
p.DoMarker("PSPOskDialog");
|
||||
}
|
||||
+133
-1
@@ -19,14 +19,146 @@
|
||||
|
||||
#include "PSPDialog.h"
|
||||
#include "../Core/MemMap.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Enumeration for input language
|
||||
*/
|
||||
enum SceUtilityOskInputLanguage
|
||||
{
|
||||
PSP_UTILITY_OSK_LANGUAGE_DEFAULT = 0x00,
|
||||
PSP_UTILITY_OSK_LANGUAGE_JAPANESE = 0x01,
|
||||
PSP_UTILITY_OSK_LANGUAGE_ENGLISH = 0x02,
|
||||
PSP_UTILITY_OSK_LANGUAGE_FRENCH = 0x03,
|
||||
PSP_UTILITY_OSK_LANGUAGE_SPANISH = 0x04,
|
||||
PSP_UTILITY_OSK_LANGUAGE_GERMAN = 0x05,
|
||||
PSP_UTILITY_OSK_LANGUAGE_ITALIAN = 0x06,
|
||||
PSP_UTILITY_OSK_LANGUAGE_DUTCH = 0x07,
|
||||
PSP_UTILITY_OSK_LANGUAGE_PORTUGESE = 0x08,
|
||||
PSP_UTILITY_OSK_LANGUAGE_RUSSIAN = 0x09,
|
||||
PSP_UTILITY_OSK_LANGUAGE_KOREAN = 0x0a
|
||||
};
|
||||
|
||||
/**
|
||||
* Enumeration for OSK internal state
|
||||
*/
|
||||
enum SceUtilityOskState
|
||||
{
|
||||
PSP_UTILITY_OSK_DIALOG_NONE = 0, /**< No OSK is currently active */
|
||||
PSP_UTILITY_OSK_DIALOG_INITING, /**< The OSK is currently being initialized */
|
||||
PSP_UTILITY_OSK_DIALOG_INITED, /**< The OSK is initialised */
|
||||
PSP_UTILITY_OSK_DIALOG_VISIBLE, /**< The OSK is visible and ready for use */
|
||||
PSP_UTILITY_OSK_DIALOG_QUIT, /**< The OSK has been cancelled and should be shut down */
|
||||
PSP_UTILITY_OSK_DIALOG_FINISHED /**< The OSK has successfully shut down */
|
||||
};
|
||||
|
||||
/**
|
||||
* Enumeration for OSK field results
|
||||
*/
|
||||
enum SceUtilityOskResult
|
||||
{
|
||||
PSP_UTILITY_OSK_RESULT_UNCHANGED = 0,
|
||||
PSP_UTILITY_OSK_RESULT_CANCELLED,
|
||||
PSP_UTILITY_OSK_RESULT_CHANGED
|
||||
};
|
||||
|
||||
/**
|
||||
* Enumeration for input types (these are limited by initial choice of language)
|
||||
*/
|
||||
enum SceUtilityOskInputType
|
||||
{
|
||||
PSP_UTILITY_OSK_INPUTTYPE_ALL = 0x00000000,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_LATIN_DIGIT = 0x00000001,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_LATIN_SYMBOL = 0x00000002,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_LATIN_LOWERCASE = 0x00000004,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_LATIN_UPPERCASE = 0x00000008,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_DIGIT = 0x00000100,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_SYMBOL = 0x00000200,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_LOWERCASE = 0x00000400,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_UPPERCASE = 0x00000800,
|
||||
// http://en.wikipedia.org/wiki/Hiragana
|
||||
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_HIRAGANA = 0x00001000,
|
||||
// http://en.wikipedia.org/wiki/Katakana
|
||||
// Half-width Katakana
|
||||
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_HALF_KATAKANA = 0x00002000,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_KATAKANA = 0x00004000,
|
||||
// http://en.wikipedia.org/wiki/Kanji
|
||||
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_KANJI = 0x00008000,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_RUSSIAN_LOWERCASE = 0x00010000,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_RUSSIAN_UPPERCASE = 0x00020000,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_KOREAN = 0x00040000,
|
||||
PSP_UTILITY_OSK_INPUTTYPE_URL = 0x00080000
|
||||
};
|
||||
|
||||
/**
|
||||
* OSK Field data
|
||||
*/
|
||||
typedef struct _SceUtilityOskData
|
||||
{
|
||||
/** Unknown. Pass 0. */
|
||||
int unk_00;
|
||||
/** Unknown. Pass 0. */
|
||||
int unk_04;
|
||||
/** One of ::SceUtilityOskInputLanguage */
|
||||
int language;
|
||||
/** Unknown. Pass 0. */
|
||||
int unk_12;
|
||||
/** One or more of ::SceUtilityOskInputType (types that are selectable by pressing SELECT) */
|
||||
int inputtype;
|
||||
/** Number of lines */
|
||||
int lines;
|
||||
/** Unknown. Pass 0. */
|
||||
int unk_24;
|
||||
/** Description text */
|
||||
u32 descPtr;
|
||||
/** Initial text */
|
||||
u32 intextPtr;
|
||||
/** Length of output text */
|
||||
int outtextlength;
|
||||
/** Pointer to the output text */
|
||||
u32 outtextPtr;
|
||||
/** Result. One of ::SceUtilityOskResult */
|
||||
int result;
|
||||
/** The max text that can be input */
|
||||
int outtextlimit;
|
||||
|
||||
} SceUtilityOskData;
|
||||
|
||||
/**
|
||||
* OSK parameters
|
||||
*/
|
||||
typedef struct _SceUtilityOskParams
|
||||
{
|
||||
pspUtilityDialogCommon base;
|
||||
int datacount; /** Number of input fields */
|
||||
u32 SceUtilityOskDataPtr; /** Pointer to the start of the data for the input fields */
|
||||
int state; /** The local OSK state, one of ::SceUtilityOskState */
|
||||
int unk_60;/** Unknown. Pass 0 */
|
||||
|
||||
} SceUtilityOskParams;
|
||||
|
||||
|
||||
class PSPOskDialog: public PSPDialog {
|
||||
public:
|
||||
PSPOskDialog();
|
||||
virtual ~PSPOskDialog();
|
||||
|
||||
virtual int Init(u32 oskPtr);
|
||||
virtual void Update();
|
||||
virtual int Update();
|
||||
virtual void DoState(PointerWrap &p);
|
||||
private:
|
||||
void HackyGetStringWide(std::string& _string, const u32 em_address);
|
||||
void RenderKeyboard();
|
||||
|
||||
SceUtilityOskParams oskParams;
|
||||
SceUtilityOskData oskData;
|
||||
std::string oskDesc;
|
||||
std::string oskIntext;
|
||||
std::string oskOuttext;
|
||||
int oskParamsAddr;
|
||||
|
||||
int selectedChar;
|
||||
std::string inputChars;
|
||||
};
|
||||
|
||||
@@ -25,12 +25,13 @@ PSPPlaceholderDialog::~PSPPlaceholderDialog() {
|
||||
}
|
||||
|
||||
|
||||
void PSPPlaceholderDialog::Init()
|
||||
int PSPPlaceholderDialog::Init()
|
||||
{
|
||||
status = SCE_UTILITY_STATUS_INITIALIZE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PSPPlaceholderDialog::Update()
|
||||
int PSPPlaceholderDialog::Update()
|
||||
{
|
||||
//__UtilityUpdate();
|
||||
if (status == SCE_UTILITY_STATUS_INITIALIZE)
|
||||
@@ -45,4 +46,5 @@ void PSPPlaceholderDialog::Update()
|
||||
{
|
||||
status = SCE_UTILITY_STATUS_SHUTDOWN;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
PSPPlaceholderDialog();
|
||||
virtual ~PSPPlaceholderDialog();
|
||||
|
||||
virtual void Init();
|
||||
virtual void Update();
|
||||
virtual int Init();
|
||||
virtual int Update();
|
||||
};
|
||||
|
||||
@@ -31,12 +31,24 @@ PSPSaveDialog::PSPSaveDialog()
|
||||
PSPSaveDialog::~PSPSaveDialog() {
|
||||
}
|
||||
|
||||
void PSPSaveDialog::Init(int paramAddr)
|
||||
int PSPSaveDialog::Init(int paramAddr)
|
||||
{
|
||||
param.SetPspParam((SceUtilitySavedataParam*)Memory::GetPointer(paramAddr));
|
||||
// Ignore if already running
|
||||
if (status != SCE_UTILITY_STATUS_NONE && status != SCE_UTILITY_STATUS_SHUTDOWN)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEBUG_LOG(HLE,"sceUtilitySavedataInitStart(%08x)", paramAddr);
|
||||
DEBUG_LOG(HLE,"Mode: %i", param.GetPspParam()->mode);
|
||||
int size = Memory::Read_U32(paramAddr);
|
||||
memset(&request,0,sizeof(request));
|
||||
// Only copy the right size to support different save request format
|
||||
Memory::Memcpy(&request,paramAddr,size);
|
||||
requestAddr = paramAddr;
|
||||
|
||||
u32 retval = param.SetPspParam(&request);
|
||||
|
||||
INFO_LOG(HLE,"sceUtilitySavedataInitStart(%08x)", paramAddr);
|
||||
INFO_LOG(HLE,"Mode: %i", param.GetPspParam()->mode);
|
||||
|
||||
switch(param.GetPspParam()->mode)
|
||||
{
|
||||
@@ -79,13 +91,14 @@ void PSPSaveDialog::Init(int paramAddr)
|
||||
{
|
||||
ERROR_LOG(HLE, "Load/Save function %d not coded. Title: %s Save: %s File: %s", param.GetPspParam()->mode, param.GetGameName(param.GetPspParam()).c_str(), param.GetGameName(param.GetPspParam()).c_str(), param.GetFileName(param.GetPspParam()).c_str());
|
||||
param.GetPspParam()->result = 0;
|
||||
status = SCE_UTILITY_STATUS_INITIALIZE;
|
||||
display = DS_NONE;
|
||||
return; // Return 0 should allow the game to continue, but missing function must be implemented and returning the right value or the game can block.
|
||||
return 0; // Return 0 should allow the game to continue, but missing function must be implemented and returning the right value or the game can block.
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
status = SCE_UTILITY_STATUS_INITIALIZE;
|
||||
status = (int)retval < 0 ? SCE_UTILITY_STATUS_SHUTDOWN : SCE_UTILITY_STATUS_INITIALIZE;
|
||||
|
||||
currentSelectedSave = 0;
|
||||
lastButtons = __CtrlPeekButtons();
|
||||
@@ -121,7 +134,7 @@ void PSPSaveDialog::Init(int paramAddr)
|
||||
|
||||
INFO_LOG(HLE,"snd0 data : %08x",*((unsigned int*)¶m.GetPspParam()->snd0FileData.buf));
|
||||
INFO_LOG(HLE,"snd0 size : %u",param.GetPspParam()->snd0FileData.bufSize);*/
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void PSPSaveDialog::DisplaySaveList(bool canMove)
|
||||
@@ -137,16 +150,16 @@ void PSPSaveDialog::DisplaySaveList(bool canMove)
|
||||
}
|
||||
|
||||
// Calc save image position on screen
|
||||
int w = 150;
|
||||
int h = 80;
|
||||
int x = 20;
|
||||
float w = 150;
|
||||
float h = 80;
|
||||
float x = 20;
|
||||
if(displayCount != currentSelectedSave)
|
||||
{
|
||||
w = 80;
|
||||
h = 40;
|
||||
x = 50;
|
||||
}
|
||||
int y = 80;
|
||||
float y = 80;
|
||||
if(displayCount < currentSelectedSave)
|
||||
y -= 50 * (currentSelectedSave - displayCount);
|
||||
else if(displayCount > currentSelectedSave)
|
||||
@@ -194,10 +207,10 @@ void PSPSaveDialog::DisplaySaveIcon()
|
||||
}
|
||||
|
||||
// Calc save image position on screen
|
||||
int w = 150;
|
||||
int h = 80;
|
||||
int x = 20;
|
||||
int y = 80;
|
||||
float w = 150;
|
||||
float h = 80;
|
||||
float x = 20;
|
||||
float y = 80;
|
||||
|
||||
int tw = 256;
|
||||
int th = 256;
|
||||
@@ -226,8 +239,10 @@ void PSPSaveDialog::DisplaySaveDataInfo1()
|
||||
}
|
||||
else
|
||||
{
|
||||
char txt[1024];
|
||||
sprintf(txt,"%s\n%02d/%02d/%d %02d:%02d %d KB\n%s\n%s"
|
||||
char txt[2048];
|
||||
_dbg_assert_msg_(HLE, sizeof(txt) > sizeof(SaveFileInfo), "Local buffer is too small.");
|
||||
|
||||
sprintf(txt,"%s\n%02d/%02d/%d %02d:%02d %lld KB\n%s\n%s"
|
||||
, param.GetFileInfo(currentSelectedSave).title
|
||||
, param.GetFileInfo(currentSelectedSave).modif_time.tm_mday
|
||||
, param.GetFileInfo(currentSelectedSave).modif_time.tm_mon + 1
|
||||
@@ -251,7 +266,7 @@ void PSPSaveDialog::DisplaySaveDataInfo2()
|
||||
else
|
||||
{
|
||||
char txt[1024];
|
||||
sprintf(txt,"%s\n%02d/%02d/%d %02d:%02d\n%d KB"
|
||||
sprintf(txt,"%s\n%02d/%02d/%d %02d:%02d\n%lld KB"
|
||||
, param.GetFileInfo(currentSelectedSave).saveTitle
|
||||
, param.GetFileInfo(currentSelectedSave).modif_time.tm_mday
|
||||
, param.GetFileInfo(currentSelectedSave).modif_time.tm_mon + 1
|
||||
@@ -303,22 +318,24 @@ void PSPSaveDialog::DisplayBack()
|
||||
PPGeDrawText("Back", 270, 220, PPGE_ALIGN_LEFT, 0.5f, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
void PSPSaveDialog::Update()
|
||||
int PSPSaveDialog::Update()
|
||||
{
|
||||
switch (status) {
|
||||
case SCE_UTILITY_STATUS_FINISHED:
|
||||
status = SCE_UTILITY_STATUS_SHUTDOWN;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (status != SCE_UTILITY_STATUS_RUNNING)
|
||||
{
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!param.GetPspParam()) {
|
||||
status = SCE_UTILITY_STATUS_SHUTDOWN;
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
buttons = __CtrlPeekButtons();
|
||||
@@ -629,7 +646,6 @@ void PSPSaveDialog::Update()
|
||||
else
|
||||
param.GetPspParam()->result = SCE_UTILITY_SAVEDATA_ERROR_LOAD_NO_DATA;
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
return;
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_SAVE: // Only save and exit
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_AUTOSAVE:
|
||||
@@ -638,39 +654,71 @@ void PSPSaveDialog::Update()
|
||||
else
|
||||
param.GetPspParam()->result = SCE_UTILITY_SAVEDATA_ERROR_SAVE_MS_NOSPACE;
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
return;
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_SIZES:
|
||||
param.GetSizes(param.GetPspParam());
|
||||
param.GetPspParam()->result = SCE_UTILITY_SAVEDATA_ERROR_SIZES_NO_DATA;
|
||||
if(param.GetSizes(param.GetPspParam()))
|
||||
{
|
||||
param.GetPspParam()->result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
param.GetPspParam()->result = SCE_UTILITY_SAVEDATA_ERROR_SIZES_NO_DATA;
|
||||
}
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
return;
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_LIST:
|
||||
param.GetList(param.GetPspParam());
|
||||
param.GetPspParam()->result = 0;
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
return;
|
||||
break;
|
||||
// TODO: Don't know the name?
|
||||
case 12:
|
||||
// Pretend we have nothing, always.
|
||||
param.GetPspParam()->result = SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA;
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
break;
|
||||
default:
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
lastButtons = buttons;
|
||||
|
||||
|
||||
if(status == SCE_UTILITY_STATUS_FINISHED)
|
||||
{
|
||||
Memory::Memcpy(requestAddr,&request,request.size);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PSPSaveDialog::Shutdown()
|
||||
int PSPSaveDialog::Shutdown()
|
||||
{
|
||||
PSPDialog::Shutdown();
|
||||
param.SetPspParam(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PSPSaveDialog::DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(display);
|
||||
param.DoState(p);
|
||||
p.Do(request);
|
||||
// Just reset it.
|
||||
param.SetPspParam(&request);
|
||||
p.Do(requestAddr);
|
||||
p.Do(currentSelectedSave);
|
||||
p.Do(yesnoChoice);
|
||||
p.Do(okButtonImg);
|
||||
p.Do(cancelButtonImg);
|
||||
p.Do(okButtonFlag);
|
||||
p.Do(cancelButtonFlag);
|
||||
p.DoMarker("PSPSaveDialog");
|
||||
}
|
||||
@@ -30,6 +30,8 @@
|
||||
#define SCE_UTILITY_SAVEDATA_ERROR_LOAD_PARAM (0x80110308)
|
||||
#define SCE_UTILITY_SAVEDATA_ERROR_LOAD_INTERNAL (0x8011030b)
|
||||
|
||||
#define SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA (0x80110327)
|
||||
|
||||
#define SCE_UTILITY_SAVEDATA_ERROR_SAVE_NO_MS (0x80110381)
|
||||
#define SCE_UTILITY_SAVEDATA_ERROR_SAVE_EJECT_MS (0x80110382)
|
||||
#define SCE_UTILITY_SAVEDATA_ERROR_SAVE_MS_NOSPACE (0x80110383)
|
||||
@@ -62,9 +64,10 @@ public:
|
||||
PSPSaveDialog();
|
||||
virtual ~PSPSaveDialog();
|
||||
|
||||
virtual void Init(int paramAddr);
|
||||
virtual void Update();
|
||||
void Shutdown();
|
||||
virtual int Init(int paramAddr);
|
||||
virtual int Update();
|
||||
virtual int Shutdown();
|
||||
virtual void DoState(PointerWrap &p);
|
||||
|
||||
private :
|
||||
|
||||
@@ -102,6 +105,8 @@ private :
|
||||
DisplayState display;
|
||||
|
||||
SavedataParam param;
|
||||
SceUtilitySavedataParam request;
|
||||
int requestAddr;
|
||||
int currentSelectedSave;
|
||||
|
||||
int yesnoChoice;
|
||||
|
||||
+282
-223
@@ -16,10 +16,11 @@
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "SavedataParam.h"
|
||||
#include "../System.h"
|
||||
#include "image/png_load.h"
|
||||
#include "../HLE/sceKernelMemory.h"
|
||||
#include "../ELF/ParamSFO.h"
|
||||
#include "Core/HW/MemoryStick.h"
|
||||
#include "PSPSaveDialog.h"
|
||||
|
||||
std::string icon0Name = "ICON0.PNG";
|
||||
std::string icon1Name = "ICON1.PMF";
|
||||
@@ -29,19 +30,66 @@ std::string sfoName = "PARAM.SFO";
|
||||
|
||||
std::string savePath = "ms0:/PSP/SAVEDATA/";
|
||||
|
||||
namespace
|
||||
{
|
||||
int getSizeNormalized(int size)
|
||||
{
|
||||
int sizeCluster = (int)MemoryStick_SectorSize();
|
||||
return ((int)((size + sizeCluster - 1) / sizeCluster)) * sizeCluster;
|
||||
}
|
||||
|
||||
void SetStringFromSFO(ParamSFOData &sfoFile, const char *name, char *str, int strLength)
|
||||
{
|
||||
std::string value = sfoFile.GetValueString(name);
|
||||
strncpy(str, value.c_str(), strLength - 1);
|
||||
str[strLength - 1] = 0;
|
||||
}
|
||||
|
||||
bool ReadPSPFile(std::string filename, u8 *data, s64 dataSize)
|
||||
{
|
||||
u32 handle = pspFileSystem.OpenFile(filename, FILEACCESS_READ);
|
||||
if (handle == 0)
|
||||
return false;
|
||||
|
||||
int result = pspFileSystem.ReadFile(handle, data, dataSize);
|
||||
pspFileSystem.CloseFile(handle);
|
||||
|
||||
return result != 0;
|
||||
}
|
||||
|
||||
bool WritePSPFile(std::string filename, u8 *data, int dataSize)
|
||||
{
|
||||
u32 handle = pspFileSystem.OpenFile(filename, (FileAccess)(FILEACCESS_WRITE | FILEACCESS_CREATE));
|
||||
if (handle == 0)
|
||||
return false;
|
||||
|
||||
int result = pspFileSystem.WriteFile(handle, data, dataSize);
|
||||
pspFileSystem.CloseFile(handle);
|
||||
|
||||
return result != 0;
|
||||
}
|
||||
|
||||
struct EncryptFileInfo
|
||||
{
|
||||
int fileVersion;
|
||||
u8 key[16];
|
||||
int sdkVersion;
|
||||
};
|
||||
}
|
||||
|
||||
SavedataParam::SavedataParam()
|
||||
: pspParam(0)
|
||||
, selectedSave(0)
|
||||
, saveNameListData(0)
|
||||
, saveDataList(0)
|
||||
, saveNameListDataCount(0)
|
||||
, saveDataListCount(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SavedataParam::Init()
|
||||
{
|
||||
if(!pspFileSystem.GetFileInfo(savePath).exists)
|
||||
if (!pspFileSystem.GetFileInfo(savePath).exists)
|
||||
{
|
||||
pspFileSystem.MkDir(savePath);
|
||||
}
|
||||
@@ -54,7 +102,7 @@ std::string SavedataParam::GetSaveDir(SceUtilitySavedataParam* param, int saveId
|
||||
}
|
||||
|
||||
std::string dirPath = GetGameName(param)+GetSaveName(param);
|
||||
if(saveId >= 0 && saveNameListDataCount > 0) // if user selection, use it
|
||||
if (saveId >= 0 && saveNameListDataCount > 0) // if user selection, use it
|
||||
dirPath = std::string(GetGameName(param))+GetFilename(saveId);
|
||||
|
||||
return dirPath;
|
||||
@@ -101,9 +149,9 @@ bool SavedataParam::Delete(SceUtilitySavedataParam* param, int saveId)
|
||||
}
|
||||
|
||||
std::string dirPath = GetSaveFilePath(param,saveId);
|
||||
if(saveId >= 0 && saveNameListDataCount > 0) // if user selection, use it
|
||||
if (saveId >= 0 && saveNameListDataCount > 0) // if user selection, use it
|
||||
{
|
||||
if(saveDataList[saveId].size == 0) // don't delete no existing file
|
||||
if (saveDataList[saveId].size == 0) // don't delete no existing file
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -119,31 +167,22 @@ bool SavedataParam::Save(SceUtilitySavedataParam* param, int saveId)
|
||||
return false;
|
||||
}
|
||||
|
||||
u8* data_ = (u8*)Memory::GetPointer(*((unsigned int*)¶m->dataBuf));
|
||||
u8 *data_ = (u8*)Memory::GetPointer(*((unsigned int*)¶m->dataBuf));
|
||||
|
||||
std::string dirPath = GetSaveFilePath(param, saveId);
|
||||
|
||||
if(!pspFileSystem.GetFileInfo(dirPath).exists)
|
||||
if (!pspFileSystem.GetFileInfo(dirPath).exists)
|
||||
pspFileSystem.MkDir(dirPath);
|
||||
|
||||
std::string filePath = dirPath+"/"+GetFileName(param);
|
||||
INFO_LOG(HLE,"Saving file with size %u in %s",param->dataBufSize,filePath.c_str());
|
||||
unsigned int handle = pspFileSystem.OpenFile(filePath,(FileAccess)(FILEACCESS_WRITE | FILEACCESS_CREATE));
|
||||
if(handle == 0)
|
||||
if (!WritePSPFile(filePath, data_, param->dataBufSize))
|
||||
{
|
||||
ERROR_LOG(HLE,"Error opening file %s",filePath.c_str());
|
||||
return false;
|
||||
}
|
||||
if(!pspFileSystem.WriteFile(handle, data_, param->dataBufSize))
|
||||
{
|
||||
pspFileSystem.CloseFile(handle);
|
||||
ERROR_LOG(HLE,"Error writing file %s",filePath.c_str());
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
pspFileSystem.CloseFile(handle);
|
||||
|
||||
// SAVE PARAM.SFO
|
||||
ParamSFOData sfoFile;
|
||||
sfoFile.SetValue("TITLE",param->sfoParam.title,128);
|
||||
@@ -152,85 +191,87 @@ bool SavedataParam::Save(SceUtilitySavedataParam* param, int saveId)
|
||||
sfoFile.SetValue("PARENTAL_LEVEL",param->sfoParam.parentalLevel,4);
|
||||
sfoFile.SetValue("CATEGORY","MS",4);
|
||||
sfoFile.SetValue("SAVEDATA_DIRECTORY",GetSaveDir(param,saveId),64);
|
||||
sfoFile.SetValue("SAVEDATA_FILE_LIST","",3168); // This need to be filed with the save filename and a hash
|
||||
sfoFile.SetValue("SAVEDATA_PARAMS","",128); // This need to be filled with a hash of the save file encrypted.
|
||||
u8* sfoData;
|
||||
|
||||
// For each file, 32 bytes for filename, 32 bytes for file hash (0 in PPSSPP)
|
||||
u8* tmpData = new u8[3168];
|
||||
memset(tmpData, 0, 3168);
|
||||
sprintf((char*)tmpData,"%s",GetFileName(param).c_str());
|
||||
sfoFile.SetValue("SAVEDATA_FILE_LIST", tmpData, 3168, 3168);
|
||||
delete[] tmpData;
|
||||
|
||||
// No crypted save, so fill with 0
|
||||
tmpData = new u8[128];
|
||||
memset(tmpData, 0, 128);
|
||||
sfoFile.SetValue("SAVEDATA_PARAMS", tmpData, 128, 128);
|
||||
delete[] tmpData;
|
||||
|
||||
u8 *sfoData;
|
||||
size_t sfoSize;
|
||||
sfoFile.WriteSFO(&sfoData,&sfoSize);
|
||||
std::string sfopath = dirPath+"/"+sfoName;
|
||||
handle = pspFileSystem.OpenFile(sfopath,(FileAccess)(FILEACCESS_WRITE | FILEACCESS_CREATE));
|
||||
if(handle)
|
||||
{
|
||||
pspFileSystem.WriteFile(handle, sfoData, sfoSize);
|
||||
pspFileSystem.CloseFile(handle);
|
||||
}
|
||||
WritePSPFile(sfopath, sfoData, sfoSize);
|
||||
delete[] sfoData;
|
||||
|
||||
// SAVE ICON0
|
||||
if(param->icon0FileData.buf)
|
||||
if (param->icon0FileData.buf)
|
||||
{
|
||||
data_ = (u8*)Memory::GetPointer(*((unsigned int*)¶m->icon0FileData.buf));
|
||||
std::string icon0path = dirPath+"/"+icon0Name;
|
||||
handle = pspFileSystem.OpenFile(icon0path,(FileAccess)(FILEACCESS_WRITE | FILEACCESS_CREATE));
|
||||
if(handle)
|
||||
{
|
||||
pspFileSystem.WriteFile(handle, data_, param->icon0FileData.bufSize);
|
||||
pspFileSystem.CloseFile(handle);
|
||||
}
|
||||
WritePSPFile(icon0path, data_, param->icon0FileData.bufSize);
|
||||
}
|
||||
// SAVE ICON1
|
||||
if(param->icon1FileData.buf)
|
||||
if (param->icon1FileData.buf)
|
||||
{
|
||||
data_ = (u8*)Memory::GetPointer(*((unsigned int*)¶m->icon1FileData.buf));
|
||||
std::string icon1path = dirPath+"/"+icon1Name;
|
||||
handle = pspFileSystem.OpenFile(icon1path,(FileAccess)(FILEACCESS_WRITE | FILEACCESS_CREATE));
|
||||
if(handle)
|
||||
{
|
||||
pspFileSystem.WriteFile(handle, data_, param->icon1FileData.bufSize);
|
||||
pspFileSystem.CloseFile(handle);
|
||||
}
|
||||
WritePSPFile(icon1path, data_, param->icon1FileData.bufSize);
|
||||
}
|
||||
// SAVE PIC1
|
||||
if(param->pic1FileData.buf)
|
||||
if (param->pic1FileData.buf)
|
||||
{
|
||||
data_ = (u8*)Memory::GetPointer(*((unsigned int*)¶m->pic1FileData.buf));
|
||||
std::string pic1path = dirPath+"/"+pic1Name;
|
||||
handle = pspFileSystem.OpenFile(pic1path,(FileAccess)(FILEACCESS_WRITE | FILEACCESS_CREATE));
|
||||
if(handle)
|
||||
{
|
||||
pspFileSystem.WriteFile(handle, data_, param->pic1FileData.bufSize);
|
||||
pspFileSystem.CloseFile(handle);
|
||||
}
|
||||
WritePSPFile(pic1path, data_, param->pic1FileData.bufSize);
|
||||
}
|
||||
|
||||
// Save SND
|
||||
if(param->snd0FileData.buf)
|
||||
if (param->snd0FileData.buf)
|
||||
{
|
||||
data_ = (u8*)Memory::GetPointer(*((unsigned int*)¶m->snd0FileData.buf));
|
||||
std::string snd0path = dirPath+"/"+snd0Name;
|
||||
handle = pspFileSystem.OpenFile(snd0path,(FileAccess)(FILEACCESS_WRITE | FILEACCESS_CREATE));
|
||||
if(handle)
|
||||
{
|
||||
pspFileSystem.WriteFile(handle, data_, param->snd0FileData.bufSize);
|
||||
pspFileSystem.CloseFile(handle);
|
||||
}
|
||||
WritePSPFile(snd0path, data_, param->snd0FileData.bufSize);
|
||||
}
|
||||
|
||||
// Save Encryption Data
|
||||
{
|
||||
EncryptFileInfo encryptInfo;
|
||||
int dataSize = sizeof(encryptInfo); // version + key + sdkVersion
|
||||
memset(&encryptInfo,0,dataSize);
|
||||
|
||||
encryptInfo.fileVersion = 1;
|
||||
encryptInfo.sdkVersion = sceKernelGetCompiledSdkVersion();
|
||||
if(param->size > 1500)
|
||||
memcpy(encryptInfo.key,param->key,16);
|
||||
|
||||
std::string encryptInfoPath = dirPath+"/"+"ENCRYPT_INFO.BIN";
|
||||
WritePSPFile(encryptInfoPath, (u8*)&encryptInfo, dataSize);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SavedataParam::Load(SceUtilitySavedataParam* param, int saveId)
|
||||
bool SavedataParam::Load(SceUtilitySavedataParam *param, int saveId)
|
||||
{
|
||||
if (!param) {
|
||||
return false;
|
||||
}
|
||||
|
||||
u8* data_ = (u8*)Memory::GetPointer(*((unsigned int*)¶m->dataBuf));
|
||||
u8 *data_ = (u8*)Memory::GetPointer(*((unsigned int*)¶m->dataBuf));
|
||||
|
||||
std::string dirPath = GetSaveFilePath(param, saveId);
|
||||
if(saveId >= 0 && saveNameListDataCount > 0) // if user selection, use it
|
||||
if (saveId >= 0 && saveNameListDataCount > 0) // if user selection, use it
|
||||
{
|
||||
if(saveDataList[saveId].size == 0) // don't read no existing file
|
||||
if (saveDataList[saveId].size == 0) // don't read no existing file
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -238,62 +279,120 @@ bool SavedataParam::Load(SceUtilitySavedataParam* param, int saveId)
|
||||
|
||||
std::string filePath = dirPath+"/"+GetFileName(param);
|
||||
INFO_LOG(HLE,"Loading file with size %u in %s",param->dataBufSize,filePath.c_str());
|
||||
u32 handle = pspFileSystem.OpenFile(filePath,FILEACCESS_READ);
|
||||
if(!handle)
|
||||
if (!ReadPSPFile(filePath, data_, param->dataBufSize))
|
||||
{
|
||||
ERROR_LOG(HLE,"Error opening file %s",filePath.c_str());
|
||||
return false;
|
||||
}
|
||||
if(!pspFileSystem.ReadFile(handle, data_, param->dataBufSize))
|
||||
{
|
||||
pspFileSystem.CloseFile(handle);
|
||||
ERROR_LOG(HLE,"Error reading file %s",filePath.c_str());
|
||||
return false;
|
||||
}
|
||||
pspFileSystem.CloseFile(handle);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SavedataParam::GetSizes(SceUtilitySavedataParam* param)
|
||||
std::string SavedataParam::GetSpaceText(int size)
|
||||
{
|
||||
char text[50];
|
||||
|
||||
if(size < 1024)
|
||||
{
|
||||
sprintf(text,"%d B",size);
|
||||
return std::string(text);
|
||||
}
|
||||
|
||||
size /= 1024;
|
||||
|
||||
if(size < 1024)
|
||||
{
|
||||
sprintf(text,"%d KB",size);
|
||||
return std::string(text);
|
||||
}
|
||||
|
||||
size /= 1024;
|
||||
|
||||
if(size < 1024)
|
||||
{
|
||||
sprintf(text,"%d MB",size);
|
||||
return std::string(text);
|
||||
}
|
||||
|
||||
size /= 1024;
|
||||
sprintf(text,"%d GB",size);
|
||||
return std::string(text);
|
||||
}
|
||||
|
||||
// From my test, PSP only answer with data for save of size 1500 (sdk < 2)
|
||||
// Perhaps changed to use mode 22 id SDK >= 2
|
||||
// For now we always return results
|
||||
bool SavedataParam::GetSizes(SceUtilitySavedataParam *param)
|
||||
{
|
||||
if (!param) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(Memory::IsValidAddress(param->msFree))
|
||||
bool ret = true;
|
||||
|
||||
if (Memory::IsValidAddress(param->msFree))
|
||||
{
|
||||
Memory::Write_U32(32768,param->msFree);
|
||||
Memory::Write_U32(32768,param->msFree+4);
|
||||
Memory::Write_U32(1048576,param->msFree+8);
|
||||
Memory::Write_U8(0,param->msFree+12);
|
||||
Memory::Write_U32((u32)MemoryStick_SectorSize(),param->msFree); // cluster Size
|
||||
Memory::Write_U32((u32)(MemoryStick_FreeSpace() / MemoryStick_SectorSize()),param->msFree+4); // Free cluster
|
||||
Memory::Write_U32((u32)(MemoryStick_FreeSpace() / 0x400),param->msFree+8); // Free space (in KB)
|
||||
std::string spaceTxt = SavedataParam::GetSpaceText((int)MemoryStick_FreeSpace());
|
||||
Memory::Memset(param->msFree+12,0,spaceTxt.size()+1);
|
||||
Memory::Memcpy(param->msFree+12,spaceTxt.c_str(),spaceTxt.size()); // Text representing free space
|
||||
}
|
||||
if(Memory::IsValidAddress(param->msData))
|
||||
if (Memory::IsValidAddress(param->msData))
|
||||
{
|
||||
Memory::Write_U32(0,param->msData+36);
|
||||
Memory::Write_U32(0,param->msData+40);
|
||||
Memory::Write_U8(0,param->msData+44);
|
||||
Memory::Write_U32(0,param->msData+52);
|
||||
Memory::Write_U8(0,param->msData+56);
|
||||
std::string path = GetSaveFilePath(param,0);
|
||||
PSPFileInfo finfo = pspFileSystem.GetFileInfo(path);
|
||||
if(finfo.exists)
|
||||
{
|
||||
// TODO : fill correctly with the total save size
|
||||
Memory::Write_U32(1,param->msData+36); //1
|
||||
Memory::Write_U32(0x20,param->msData+40); // 0x20
|
||||
Memory::Write_U8(0,param->msData+44); // "32 KB" // 8 u8
|
||||
Memory::Write_U32(0x20,param->msData+52); // 0x20
|
||||
Memory::Write_U8(0,param->msData+56); // "32 KB" // 8 u8
|
||||
}
|
||||
else
|
||||
{
|
||||
Memory::Write_U32(0,param->msData+36);
|
||||
Memory::Write_U32(0,param->msData+40);
|
||||
Memory::Write_U8(0,param->msData+44);
|
||||
Memory::Write_U32(0,param->msData+52);
|
||||
Memory::Write_U8(0,param->msData+56);
|
||||
ret = false;
|
||||
// this should return SCE_UTILITY_SAVEDATA_ERROR_SIZES_NO_DATA
|
||||
}
|
||||
}
|
||||
if(Memory::IsValidAddress(param->utilityData))
|
||||
if (Memory::IsValidAddress(param->utilityData))
|
||||
{
|
||||
Memory::Write_U32(13,param->utilityData);
|
||||
Memory::Write_U32(416,param->utilityData+4);
|
||||
Memory::Write_U8(0,param->utilityData+8);
|
||||
Memory::Write_U32(416,param->utilityData+16);
|
||||
Memory::Write_U8(0,param->utilityData+20);
|
||||
int total_size = 0;
|
||||
total_size += getSizeNormalized(1); // SFO;
|
||||
total_size += getSizeNormalized(param->dataSize); // Save Data
|
||||
total_size += getSizeNormalized(param->icon0FileData.size);
|
||||
total_size += getSizeNormalized(param->icon1FileData.size);
|
||||
total_size += getSizeNormalized(param->pic1FileData.size);
|
||||
total_size += getSizeNormalized(param->snd0FileData.size);
|
||||
|
||||
Memory::Write_U32(total_size / (u32)MemoryStick_SectorSize(),param->utilityData); // num cluster
|
||||
Memory::Write_U32(total_size / 0x400,param->utilityData+4); // save size in KB
|
||||
std::string spaceTxt = SavedataParam::GetSpaceText(total_size);
|
||||
Memory::Memset(param->utilityData+8,0,spaceTxt.size()+1);
|
||||
Memory::Memcpy(param->utilityData+8,spaceTxt.c_str(),spaceTxt.size()); // save size in text
|
||||
Memory::Write_U32(total_size / 0x400,param->utilityData+16); // save size in KB
|
||||
spaceTxt = SavedataParam::GetSpaceText(total_size);
|
||||
Memory::Memset(param->utilityData+20,0,spaceTxt.size()+1);
|
||||
Memory::Memcpy(param->utilityData+20,spaceTxt.c_str(),spaceTxt.size()); // save size in text
|
||||
}
|
||||
return true;
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
bool SavedataParam::GetList(SceUtilitySavedataParam* param)
|
||||
bool SavedataParam::GetList(SceUtilitySavedataParam *param)
|
||||
{
|
||||
if (!param) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(Memory::IsValidAddress(param->idListAddr))
|
||||
if (Memory::IsValidAddress(param->idListAddr))
|
||||
{
|
||||
Memory::Write_U32(0,param->idListAddr+4);
|
||||
}
|
||||
@@ -302,11 +401,11 @@ bool SavedataParam::GetList(SceUtilitySavedataParam* param)
|
||||
|
||||
void SavedataParam::Clear()
|
||||
{
|
||||
if(saveDataList)
|
||||
if (saveDataList)
|
||||
{
|
||||
for(int i = 0; i < saveNameListDataCount; i++)
|
||||
for (int i = 0; i < saveNameListDataCount; i++)
|
||||
{
|
||||
if(saveDataList[i].textureData != 0)
|
||||
if (saveDataList[i].textureData != 0)
|
||||
kernelMemory.Free(saveDataList[i].textureData);
|
||||
saveDataList[i].textureData = 0;
|
||||
}
|
||||
@@ -316,111 +415,55 @@ void SavedataParam::Clear()
|
||||
}
|
||||
}
|
||||
|
||||
void SavedataParam::SetPspParam(SceUtilitySavedataParam* param)
|
||||
int SavedataParam::SetPspParam(SceUtilitySavedataParam *param)
|
||||
{
|
||||
pspParam = param;
|
||||
if(!pspParam)
|
||||
if (!pspParam)
|
||||
{
|
||||
Clear();
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool listEmptyFile = true;
|
||||
if(param->mode == SCE_UTILITY_SAVEDATA_TYPE_LISTLOAD ||
|
||||
if (param->mode == SCE_UTILITY_SAVEDATA_TYPE_LISTLOAD ||
|
||||
param->mode == SCE_UTILITY_SAVEDATA_TYPE_LISTDELETE)
|
||||
{
|
||||
listEmptyFile = false;
|
||||
}
|
||||
|
||||
if(param->saveNameList != 0)
|
||||
char (*saveNameListData)[20];
|
||||
if (param->saveNameList != 0)
|
||||
{
|
||||
saveNameListData = (char(*)[20])Memory::GetPointer(param->saveNameList);
|
||||
|
||||
// Get number of fileName in array
|
||||
int count = 0;
|
||||
saveDataListCount = 0;
|
||||
do
|
||||
{
|
||||
count++;
|
||||
} while(saveNameListData[count][0] != 0);
|
||||
saveDataListCount++;
|
||||
} while(saveNameListData[saveDataListCount][0] != 0);
|
||||
|
||||
Clear();
|
||||
saveDataList = new SaveFileInfo[count];
|
||||
saveDataList = new SaveFileInfo[saveDataListCount];
|
||||
|
||||
// get and stock file info for each file
|
||||
int realCount = 0;
|
||||
for(int i = 0; i <count; i++)
|
||||
for (int i = 0; i < saveDataListCount; i++)
|
||||
{
|
||||
DEBUG_LOG(HLE,"Name : %s",saveNameListData[i]);
|
||||
|
||||
std::string fileDataPath = savePath+GetGameName(param)+saveNameListData[i]+"/"+param->fileName;
|
||||
PSPFileInfo info = pspFileSystem.GetFileInfo(fileDataPath);
|
||||
if(info.exists)
|
||||
if (info.exists)
|
||||
{
|
||||
saveDataList[realCount].size = info.size;
|
||||
saveDataList[realCount].saveName = saveNameListData[i];
|
||||
saveDataList[realCount].idx = i;
|
||||
saveDataList[realCount].modif_time = info.mtime;
|
||||
|
||||
// Search save image icon0
|
||||
// TODO : If icon0 don't exist, need to use icon1 which is a moving icon. Also play sound
|
||||
std::string fileDataPath2 = savePath+GetGameName(param)+saveNameListData[i]+"/"+icon0Name;
|
||||
PSPFileInfo info2 = pspFileSystem.GetFileInfo(fileDataPath2);
|
||||
if(info2.exists)
|
||||
{
|
||||
u8* textureDataPNG = new u8[info2.size];
|
||||
int handle = pspFileSystem.OpenFile(fileDataPath2,FILEACCESS_READ);
|
||||
pspFileSystem.ReadFile(handle,textureDataPNG,info2.size);
|
||||
pspFileSystem.CloseFile(handle);
|
||||
unsigned char* textureData;
|
||||
int w,h;
|
||||
pngLoadPtr(textureDataPNG, info2.size, &w, &h, &textureData, false);
|
||||
delete[] textureDataPNG;
|
||||
u32 texSize = w*h*4;
|
||||
u32 atlasPtr = kernelMemory.Alloc(texSize, true, "SaveData Icon");
|
||||
saveDataList[realCount].textureData = atlasPtr;
|
||||
Memory::Memcpy(atlasPtr, textureData, texSize);
|
||||
free(textureData);
|
||||
saveDataList[realCount].textureWidth = w;
|
||||
saveDataList[realCount].textureHeight = h;
|
||||
}
|
||||
else
|
||||
{
|
||||
saveDataList[realCount].textureData = 0;
|
||||
}
|
||||
|
||||
// Load info in PARAM.SFO
|
||||
fileDataPath2 = savePath+GetGameName(param)+saveNameListData[i]+"/"+sfoName;
|
||||
info2 = pspFileSystem.GetFileInfo(fileDataPath2);
|
||||
if(info2.exists)
|
||||
{
|
||||
u8* sfoParam = new u8[info2.size];
|
||||
int handle = pspFileSystem.OpenFile(fileDataPath2,FILEACCESS_READ);
|
||||
pspFileSystem.ReadFile(handle,sfoParam,info2.size);
|
||||
pspFileSystem.CloseFile(handle);
|
||||
ParamSFOData sfoFile;
|
||||
if(sfoFile.ReadSFO(sfoParam,info2.size))
|
||||
{
|
||||
std::string title = sfoFile.GetValueString("TITLE");
|
||||
memcpy(saveDataList[realCount].title,title.c_str(),title.size());
|
||||
saveDataList[realCount].title[title.size()] = 0;
|
||||
|
||||
std::string savetitle = sfoFile.GetValueString("SAVEDATA_TITLE");
|
||||
memcpy(saveDataList[realCount].saveTitle,savetitle.c_str(),savetitle.size());
|
||||
saveDataList[realCount].saveTitle[savetitle.size()] = 0;
|
||||
|
||||
std::string savedetail = sfoFile.GetValueString("SAVEDATA_DETAIL");
|
||||
memcpy(saveDataList[realCount].saveDetail,savedetail.c_str(),savedetail.size());
|
||||
saveDataList[realCount].saveDetail[savedetail.size()] = 0;
|
||||
}
|
||||
delete sfoParam;
|
||||
}
|
||||
SetFileInfo(realCount, info, saveNameListData[i]);
|
||||
|
||||
DEBUG_LOG(HLE,"%s Exist",fileDataPath.c_str());
|
||||
realCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(listEmptyFile)
|
||||
if (listEmptyFile)
|
||||
{
|
||||
saveDataList[realCount].size = 0;
|
||||
saveDataList[realCount].saveName = saveNameListData[i];
|
||||
@@ -435,7 +478,7 @@ void SavedataParam::SetPspParam(SceUtilitySavedataParam* param)
|
||||
}
|
||||
else // Load info on only save
|
||||
{
|
||||
saveNameListData == 0;
|
||||
saveNameListData = 0;
|
||||
|
||||
Clear();
|
||||
saveDataList = new SaveFileInfo[1];
|
||||
@@ -445,73 +488,16 @@ void SavedataParam::SetPspParam(SceUtilitySavedataParam* param)
|
||||
|
||||
std::string fileDataPath = savePath+GetGameName(param)+GetSaveName(param)+"/"+param->fileName;
|
||||
PSPFileInfo info = pspFileSystem.GetFileInfo(fileDataPath);
|
||||
if(info.exists)
|
||||
if (info.exists)
|
||||
{
|
||||
saveDataList[0].size = info.size;
|
||||
saveDataList[0].saveName = GetSaveName(param);
|
||||
saveDataList[0].idx = 0;
|
||||
saveDataList[0].modif_time = info.mtime;
|
||||
|
||||
// Search save image icon0
|
||||
// TODO : If icon0 don't exist, need to use icon1 which is a moving icon. Also play sound
|
||||
std::string fileDataPath2 = savePath+GetGameName(param)+GetSaveName(param)+"/"+icon0Name;
|
||||
PSPFileInfo info2 = pspFileSystem.GetFileInfo(fileDataPath2);
|
||||
if(info2.exists)
|
||||
{
|
||||
u8* textureDataPNG = new u8[info2.size];
|
||||
int handle = pspFileSystem.OpenFile(fileDataPath2,FILEACCESS_READ);
|
||||
pspFileSystem.ReadFile(handle,textureDataPNG,info2.size);
|
||||
pspFileSystem.CloseFile(handle);
|
||||
unsigned char* textureData;
|
||||
int w,h;
|
||||
pngLoadPtr(textureDataPNG, info2.size, &w, &h, &textureData, false);
|
||||
delete[] textureDataPNG;
|
||||
u32 texSize = w*h*4;
|
||||
u32 atlasPtr = kernelMemory.Alloc(texSize, true, "SaveData Icon");
|
||||
saveDataList[0].textureData = atlasPtr;
|
||||
Memory::Memcpy(atlasPtr, textureData, texSize);
|
||||
free(textureData);
|
||||
saveDataList[0].textureWidth = w;
|
||||
saveDataList[0].textureHeight = h;
|
||||
}
|
||||
else
|
||||
{
|
||||
saveDataList[0].textureData = 0;
|
||||
}
|
||||
|
||||
// Load info in PARAM.SFO
|
||||
fileDataPath2 = savePath+GetGameName(param)+GetSaveName(param)+"/"+sfoName;
|
||||
info2 = pspFileSystem.GetFileInfo(fileDataPath2);
|
||||
if(info2.exists)
|
||||
{
|
||||
u8* sfoParam = new u8[info2.size];
|
||||
int handle = pspFileSystem.OpenFile(fileDataPath2,FILEACCESS_READ);
|
||||
pspFileSystem.ReadFile(handle,sfoParam,info2.size);
|
||||
pspFileSystem.CloseFile(handle);
|
||||
ParamSFOData sfoFile;
|
||||
if(sfoFile.ReadSFO(sfoParam,info2.size))
|
||||
{
|
||||
std::string title = sfoFile.GetValueString("TITLE");
|
||||
memcpy(saveDataList[0].title,title.c_str(),title.size());
|
||||
saveDataList[0].title[title.size()] = 0;
|
||||
|
||||
std::string savetitle = sfoFile.GetValueString("SAVEDATA_TITLE");
|
||||
memcpy(saveDataList[0].saveTitle,savetitle.c_str(),savetitle.size());
|
||||
saveDataList[0].saveTitle[savetitle.size()] = 0;
|
||||
|
||||
std::string savedetail = sfoFile.GetValueString("SAVEDATA_DETAIL");
|
||||
memcpy(saveDataList[0].saveDetail,savedetail.c_str(),savedetail.size());
|
||||
saveDataList[0].saveDetail[savedetail.size()] = 0;
|
||||
}
|
||||
delete sfoParam;
|
||||
}
|
||||
SetFileInfo(0, info, GetSaveName(pspParam));
|
||||
|
||||
DEBUG_LOG(HLE,"%s Exist",fileDataPath.c_str());
|
||||
saveNameListDataCount = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(listEmptyFile)
|
||||
if (listEmptyFile)
|
||||
{
|
||||
saveDataList[0].size = 0;
|
||||
saveDataList[0].saveName = GetSaveName(param);
|
||||
@@ -520,8 +506,71 @@ void SavedataParam::SetPspParam(SceUtilitySavedataParam* param)
|
||||
DEBUG_LOG(HLE,"Don't Exist");
|
||||
}
|
||||
saveNameListDataCount = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SavedataParam::SetFileInfo(int idx, PSPFileInfo &info, std::string saveName)
|
||||
{
|
||||
saveDataList[idx].size = info.size;
|
||||
saveDataList[idx].saveName = saveName;
|
||||
saveDataList[idx].idx = 0;
|
||||
saveDataList[idx].modif_time = info.mtime;
|
||||
|
||||
// Start with a blank slate.
|
||||
saveDataList[idx].textureData = 0;
|
||||
saveDataList[idx].title[0] = 0;
|
||||
saveDataList[idx].saveTitle[0] = 0;
|
||||
saveDataList[idx].saveDetail[0] = 0;
|
||||
|
||||
// Search save image icon0
|
||||
// TODO : If icon0 don't exist, need to use icon1 which is a moving icon. Also play sound
|
||||
std::string fileDataPath2 = savePath + GetGameName(pspParam) + saveName + "/" + icon0Name;
|
||||
PSPFileInfo info2 = pspFileSystem.GetFileInfo(fileDataPath2);
|
||||
if (info2.exists)
|
||||
{
|
||||
u8 *textureDataPNG = new u8[(size_t)info2.size];
|
||||
ReadPSPFile(fileDataPath2, textureDataPNG, info2.size);
|
||||
unsigned char *textureData;
|
||||
int w,h;
|
||||
|
||||
int success = pngLoadPtr(textureDataPNG, (int)info2.size, &w, &h, &textureData, false);
|
||||
delete[] textureDataPNG;
|
||||
|
||||
u32 texSize = w*h*4;
|
||||
u32 atlasPtr;
|
||||
if (success)
|
||||
atlasPtr = kernelMemory.Alloc(texSize, true, "SaveData Icon");
|
||||
if (success && atlasPtr > 0)
|
||||
{
|
||||
saveDataList[idx].textureData = atlasPtr;
|
||||
Memory::Memcpy(atlasPtr, textureData, texSize);
|
||||
free(textureData);
|
||||
saveDataList[idx].textureWidth = w;
|
||||
saveDataList[idx].textureHeight = h;
|
||||
}
|
||||
else
|
||||
WARN_LOG(HLE, "Unable to load PNG data for savedata.");
|
||||
}
|
||||
|
||||
// Load info in PARAM.SFO
|
||||
fileDataPath2 = savePath + GetGameName(pspParam) + saveName + "/" + sfoName;
|
||||
info2 = pspFileSystem.GetFileInfo(fileDataPath2);
|
||||
if (info2.exists)
|
||||
{
|
||||
u8 *sfoParam = new u8[(size_t)info2.size];
|
||||
ReadPSPFile(fileDataPath2, sfoParam, info2.size);
|
||||
ParamSFOData sfoFile;
|
||||
if (sfoFile.ReadSFO(sfoParam,(size_t)info2.size))
|
||||
{
|
||||
SetStringFromSFO(sfoFile, "TITLE", saveDataList[idx].title, sizeof(saveDataList[idx].title));
|
||||
SetStringFromSFO(sfoFile, "SAVEDATA_TITLE", saveDataList[idx].saveTitle, sizeof(saveDataList[idx].saveTitle));
|
||||
SetStringFromSFO(sfoFile, "SAVEDATA_DETAIL", saveDataList[idx].saveDetail, sizeof(saveDataList[idx].saveDetail));
|
||||
}
|
||||
delete [] sfoParam;
|
||||
}
|
||||
}
|
||||
|
||||
SceUtilitySavedataParam* SavedataParam::GetPspParam()
|
||||
@@ -547,8 +596,18 @@ int SavedataParam::GetSelectedSave()
|
||||
{
|
||||
return selectedSave;
|
||||
}
|
||||
|
||||
void SavedataParam::SetSelectedSave(int idx)
|
||||
{
|
||||
selectedSave = idx;
|
||||
}
|
||||
|
||||
void SavedataParam::DoState(PointerWrap &p)
|
||||
{
|
||||
// pspParam is handled in PSPSaveDialog.
|
||||
p.Do(selectedSave);
|
||||
p.Do(saveDataListCount);
|
||||
p.Do(saveNameListDataCount);
|
||||
p.DoArray(saveDataList, saveDataListCount);
|
||||
p.DoMarker("SavedataParam");
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../HLE/sceKernel.h"
|
||||
|
||||
#include "../System.h"
|
||||
|
||||
enum SceUtilitySavedataType
|
||||
{
|
||||
@@ -118,9 +118,10 @@ struct SceUtilitySavedataParam
|
||||
|
||||
};
|
||||
|
||||
// Non native, this one we can reorganize as we like
|
||||
struct SaveFileInfo
|
||||
{
|
||||
int size;
|
||||
s64 size;
|
||||
std::string saveName;
|
||||
int idx;
|
||||
|
||||
@@ -151,9 +152,11 @@ public:
|
||||
std::string GetSaveName(SceUtilitySavedataParam* param);
|
||||
std::string GetFileName(SceUtilitySavedataParam* param);
|
||||
|
||||
static std::string GetSpaceText(int size);
|
||||
|
||||
SavedataParam();
|
||||
|
||||
void SetPspParam(SceUtilitySavedataParam* param);
|
||||
int SetPspParam(SceUtilitySavedataParam* param);
|
||||
SceUtilitySavedataParam* GetPspParam();
|
||||
|
||||
int GetFilenameCount();
|
||||
@@ -163,13 +166,16 @@ public:
|
||||
int GetSelectedSave();
|
||||
void SetSelectedSave(int idx);
|
||||
|
||||
void DoState(PointerWrap &p);
|
||||
|
||||
private:
|
||||
void Clear();
|
||||
void SetFileInfo(int idx, PSPFileInfo &info, std::string saveName);
|
||||
|
||||
SceUtilitySavedataParam* pspParam;
|
||||
int selectedSave;
|
||||
char (*saveNameListData)[20];
|
||||
SaveFileInfo* saveDataList;
|
||||
int saveDataListCount;
|
||||
int saveNameListDataCount;
|
||||
|
||||
};
|
||||
+132
-114
@@ -50,6 +50,118 @@ void addrToHiLo(u32 addr, u16 &hi, s16 &lo)
|
||||
}
|
||||
}
|
||||
|
||||
void ElfReader::LoadRelocations(Elf32_Rel *rels, int numRelocs)
|
||||
{
|
||||
for (int r = 0; r < numRelocs; r++)
|
||||
{
|
||||
u32 info = rels[r].r_info;
|
||||
u32 addr = rels[r].r_offset;
|
||||
|
||||
int type = info & 0xf;
|
||||
|
||||
int readwrite = (info>>8) & 0xff;
|
||||
int relative = (info>>16) & 0xff;
|
||||
|
||||
//0 = code
|
||||
//1 = data
|
||||
|
||||
addr += segmentVAddr[readwrite];
|
||||
|
||||
u32 op = Memory::ReadUnchecked_U32(addr);
|
||||
|
||||
const bool log = false;
|
||||
//log=true;
|
||||
if (log)
|
||||
{
|
||||
DEBUG_LOG(LOADER,"rel at: %08x type: %08x",addr,info);
|
||||
}
|
||||
u32 relocateTo = segmentVAddr[relative];
|
||||
|
||||
#define R_MIPS32 2
|
||||
#define R_MIPS26 4
|
||||
#define R_MIPS16_HI 5
|
||||
#define R_MIPS16_LO 6
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case R_MIPS32:
|
||||
if (log)
|
||||
DEBUG_LOG(LOADER,"Full address reloc %08x", addr);
|
||||
//full address, no problemo
|
||||
op += relocateTo;
|
||||
break;
|
||||
|
||||
case R_MIPS26: //j, jal
|
||||
//add on to put in correct address space
|
||||
if (log)
|
||||
DEBUG_LOG(LOADER,"j/jal reloc %08x", addr);
|
||||
op = (op & 0xFC000000) | (((op&0x03FFFFFF)+(relocateTo>>2))&0x03FFFFFFF);
|
||||
break;
|
||||
|
||||
case R_MIPS16_HI: //lui part of lui-addiu pairs
|
||||
{
|
||||
if (log)
|
||||
DEBUG_LOG(LOADER,"HI reloc %08x", addr);
|
||||
|
||||
u32 cur = (op & 0xFFFF) << 16;
|
||||
u16 hi = 0;
|
||||
bool found = false;
|
||||
for (int t = r + 1; t<numRelocs; t++)
|
||||
{
|
||||
if ((rels[t].r_info & 0xF) == R_MIPS16_LO)
|
||||
{
|
||||
u32 corrLoAddr = rels[t].r_offset + segmentVAddr[readwrite];
|
||||
if (log)
|
||||
{
|
||||
DEBUG_LOG(LOADER,"Corresponding lo found at %08x", corrLoAddr);
|
||||
}
|
||||
|
||||
s16 lo = (s32)(s16)(u16)(Memory::ReadUnchecked_U32(corrLoAddr) & 0xFFFF); //signed??
|
||||
cur += lo;
|
||||
cur += relocateTo;
|
||||
addrToHiLo(cur, hi, lo);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
ERROR_LOG(LOADER, "R_MIPS16: not found");
|
||||
|
||||
op = (op & 0xFFFF0000) | (hi);
|
||||
}
|
||||
break;
|
||||
|
||||
case R_MIPS16_LO: //addiu part of lui-addiu pairs
|
||||
{
|
||||
if (log)
|
||||
DEBUG_LOG(LOADER,"LO reloc %08x", addr);
|
||||
u32 cur = op & 0xFFFF;
|
||||
cur += relocateTo;
|
||||
cur &= 0xFFFF;
|
||||
op = (op & 0xFFFF0000) | cur;
|
||||
}
|
||||
break;
|
||||
|
||||
case 7: //gp
|
||||
if (log)
|
||||
ERROR_LOG(LOADER,"ARGH IT'S A GP!!!!!!!! %08x", addr);
|
||||
break;
|
||||
|
||||
case 0: // another GP reloc!
|
||||
{
|
||||
char temp[256];
|
||||
MIPSDisAsm(op, 0, temp);
|
||||
ERROR_LOG(LOADER,"WARNING: GP reloc? @ %08x : 0 : %s", addr, temp );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG(LOADER,"ARGH IT'S A UNKNOWN RELOCATION!!!!!!!! %08x", addr);
|
||||
break;
|
||||
}
|
||||
Memory::Write_U32(op, addr);
|
||||
}
|
||||
}
|
||||
|
||||
bool ElfReader::LoadInto(u32 loadAddress)
|
||||
{
|
||||
@@ -109,9 +221,8 @@ bool ElfReader::LoadInto(u32 loadAddress)
|
||||
DEBUG_LOG(LOADER,"%i segments:", header->e_phnum);
|
||||
|
||||
// First pass : Get the damn bits into RAM
|
||||
u32 segmentVAddr[32];
|
||||
|
||||
u32 baseAddress = bRelocate?vaddr:0;
|
||||
|
||||
for (int i=0; i<header->e_phnum; i++)
|
||||
{
|
||||
Elf32_Phdr *p = segments + i;
|
||||
@@ -170,7 +281,6 @@ bool ElfReader::LoadInto(u32 loadAddress)
|
||||
if (s->sh_type == SHT_PSPREL)
|
||||
{
|
||||
//We have a relocation table!
|
||||
int symbolSection = s->sh_link;
|
||||
int sectionToModify = s->sh_info;
|
||||
|
||||
if (!(sections[sectionToModify].sh_flags & SHF_ALLOC))
|
||||
@@ -184,116 +294,7 @@ bool ElfReader::LoadInto(u32 loadAddress)
|
||||
Elf32_Rel *rels = (Elf32_Rel *)GetSectionDataPtr(i);
|
||||
|
||||
DEBUG_LOG(LOADER,"%s: Performing %i relocations on %s",name,numRelocs,GetSectionName(sectionToModify));
|
||||
|
||||
for (int r = 0; r < numRelocs; r++)
|
||||
{
|
||||
u32 info = rels[r].r_info;
|
||||
u32 addr = rels[r].r_offset;
|
||||
|
||||
int type = info & 0xf;
|
||||
|
||||
int readwrite = (info>>8) & 0xff;
|
||||
int relative = (info>>16) & 0xff;
|
||||
|
||||
//0 = code
|
||||
//1 = data
|
||||
|
||||
addr += segmentVAddr[readwrite];
|
||||
|
||||
u32 op = Memory::ReadUnchecked_U32(addr);
|
||||
|
||||
const bool log = false;
|
||||
//log=true;
|
||||
if (log)
|
||||
{
|
||||
DEBUG_LOG(LOADER,"rel at: %08x type: %08x",addr,info);
|
||||
}
|
||||
u32 relocateTo = segmentVAddr[relative];
|
||||
|
||||
#define R_MIPS32 2
|
||||
#define R_MIPS26 4
|
||||
#define R_MIPS16_HI 5
|
||||
#define R_MIPS16_LO 6
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case R_MIPS32:
|
||||
if (log)
|
||||
DEBUG_LOG(LOADER,"Full address reloc %08x", addr);
|
||||
//full address, no problemo
|
||||
op += relocateTo;
|
||||
break;
|
||||
|
||||
case R_MIPS26: //j, jal
|
||||
//add on to put in correct address space
|
||||
if (log)
|
||||
DEBUG_LOG(LOADER,"j/jal reloc %08x", addr);
|
||||
op = (op & 0xFC000000) | (((op&0x03FFFFFF)+(relocateTo>>2))&0x03FFFFFFF);
|
||||
break;
|
||||
|
||||
case R_MIPS16_HI: //lui part of lui-addiu pairs
|
||||
{
|
||||
if (log)
|
||||
DEBUG_LOG(LOADER,"HI reloc %08x", addr);
|
||||
|
||||
u32 cur = (op & 0xFFFF) << 16;
|
||||
u16 hi = 0;
|
||||
bool found = false;
|
||||
for (int t = r + 1; t<numRelocs; t++)
|
||||
{
|
||||
if ((rels[t].r_info & 0xF) == R_MIPS16_LO)
|
||||
{
|
||||
u32 corrLoAddr = rels[t].r_offset + segmentVAddr[readwrite];
|
||||
if (log)
|
||||
{
|
||||
DEBUG_LOG(LOADER,"Corresponding lo found at %08x", corrLoAddr);
|
||||
}
|
||||
|
||||
s16 lo = (s32)(s16)(u16)(Memory::ReadUnchecked_U32(corrLoAddr) & 0xFFFF); //signed??
|
||||
cur += lo;
|
||||
cur += relocateTo;
|
||||
addrToHiLo(cur, hi, lo);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
ERROR_LOG(LOADER, "R_MIPS16: not found");
|
||||
|
||||
op = (op & 0xFFFF0000) | (hi);
|
||||
}
|
||||
break;
|
||||
|
||||
case R_MIPS16_LO: //addiu part of lui-addiu pairs
|
||||
{
|
||||
if (log)
|
||||
DEBUG_LOG(LOADER,"LO reloc %08x", addr);
|
||||
u32 cur = op & 0xFFFF;
|
||||
cur += relocateTo;
|
||||
cur &= 0xFFFF;
|
||||
op = (op & 0xFFFF0000) | cur;
|
||||
}
|
||||
break;
|
||||
|
||||
case 7: //gp
|
||||
if (log)
|
||||
ERROR_LOG(LOADER,"ARGH IT'S A GP!!!!!!!! %08x", addr);
|
||||
break;
|
||||
|
||||
case 0: // another GP reloc!
|
||||
{
|
||||
char temp[256];
|
||||
MIPSDisAsm(op, 0, temp);
|
||||
ERROR_LOG(LOADER,"WARNING: GP reloc? @ %08x : 0 : %s", addr, temp );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG(LOADER,"ARGH IT'S A UNKNOWN RELOCATION!!!!!!!! %08x", addr);
|
||||
break;
|
||||
}
|
||||
Memory::Write_U32(op, addr);
|
||||
}
|
||||
LoadRelocations(rels, numRelocs);
|
||||
}
|
||||
else if (s->sh_type == SHT_REL)
|
||||
{
|
||||
@@ -305,7 +306,6 @@ bool ElfReader::LoadInto(u32 loadAddress)
|
||||
else
|
||||
{
|
||||
//We have a relocation table!
|
||||
int symbolSection = s->sh_link;
|
||||
int sectionToModify = s->sh_info;
|
||||
if (!(sections[sectionToModify].sh_flags & SHF_ALLOC))
|
||||
{
|
||||
@@ -317,6 +317,24 @@ bool ElfReader::LoadInto(u32 loadAddress)
|
||||
}
|
||||
}
|
||||
|
||||
// Segment relocations (a few games use them)
|
||||
if (GetNumSections() == 0)
|
||||
{
|
||||
for (int i=0; i<header->e_phnum; i++)
|
||||
{
|
||||
Elf32_Phdr *p = &segments[i];
|
||||
if (p->p_type == 0x700000A0)
|
||||
{
|
||||
INFO_LOG(LOADER,"Loading segment relocations");
|
||||
|
||||
int numRelocs = p->p_filesz / sizeof(Elf32_Rel);
|
||||
|
||||
Elf32_Rel *rels = (Elf32_Rel *)GetSegmentPtr(i);
|
||||
LoadRelocations(rels, numRelocs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NOTICE_LOG(LOADER,"ELF loading completed successfully.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ class ElfReader
|
||||
bool bRelocate;
|
||||
u32 entryPoint;
|
||||
u32 vaddr;
|
||||
u32 segmentVAddr[32];
|
||||
public:
|
||||
ElfReader(void *ptr)
|
||||
{
|
||||
@@ -104,6 +105,10 @@ public:
|
||||
{
|
||||
return segments[segment].p_offset;
|
||||
}
|
||||
u32 GetSegmentVaddr(int segment)
|
||||
{
|
||||
return segmentVAddr[segment];
|
||||
}
|
||||
|
||||
bool DidRelocate() {
|
||||
return bRelocate;
|
||||
@@ -117,4 +122,5 @@ public:
|
||||
// More indepth stuff:)
|
||||
bool LoadInto(u32 vaddr);
|
||||
bool LoadSymbols();
|
||||
void LoadRelocations(Elf32_Rel *rels, int numRelocs);
|
||||
};
|
||||
+25
-19
@@ -46,23 +46,18 @@ void ParamSFOData::SetValue(std::string key, unsigned int value, int max_size)
|
||||
}
|
||||
void ParamSFOData::SetValue(std::string key, std::string value, int max_size)
|
||||
{
|
||||
if(key == "ACCOUNT_ID" ||
|
||||
key == "PADDING" ||
|
||||
key == "PARAMS" ||
|
||||
key == "PARAMS2" ||
|
||||
key == "SAVEDATA_FILE_LIST" ||
|
||||
key == "SAVEDATA_PARAMS")
|
||||
{
|
||||
values[key].type = VT_UTF8_SPE;
|
||||
}
|
||||
else
|
||||
{
|
||||
values[key].type = VT_UTF8;
|
||||
}
|
||||
values[key].type = VT_UTF8;
|
||||
values[key].s_value = value;
|
||||
values[key].max_size = max_size;
|
||||
}
|
||||
|
||||
void ParamSFOData::SetValue(std::string key, const u8* value, unsigned int size, int max_size)
|
||||
{
|
||||
values[key].type = VT_UTF8_SPE;
|
||||
values[key].SetData(value,size);
|
||||
values[key].max_size = max_size;
|
||||
}
|
||||
|
||||
int ParamSFOData::GetValueInt(std::string key)
|
||||
{
|
||||
std::map<std::string,ValueData>::iterator it = values.find(key);
|
||||
@@ -73,10 +68,21 @@ int ParamSFOData::GetValueInt(std::string key)
|
||||
std::string ParamSFOData::GetValueString(std::string key)
|
||||
{
|
||||
std::map<std::string,ValueData>::iterator it = values.find(key);
|
||||
if(it == values.end() || (it->second.type != VT_UTF8 && it->second.type != VT_UTF8_SPE))
|
||||
if(it == values.end() || (it->second.type != VT_UTF8))
|
||||
return "";
|
||||
return it->second.s_value;
|
||||
}
|
||||
u8* ParamSFOData::GetValueData(std::string key, unsigned int *size)
|
||||
{
|
||||
std::map<std::string,ValueData>::iterator it = values.find(key);
|
||||
if(it == values.end() || (it->second.type != VT_UTF8_SPE))
|
||||
return 0;
|
||||
if(size)
|
||||
{
|
||||
*size = it->second.u_size;
|
||||
}
|
||||
return it->second.u_value;
|
||||
}
|
||||
|
||||
// I'm so sorry Ced but this is highly endian unsafe :(
|
||||
bool ParamSFOData::ReadSFO(const u8 *paramsfo, size_t size)
|
||||
@@ -108,9 +114,9 @@ bool ParamSFOData::ReadSFO(const u8 *paramsfo, size_t size)
|
||||
case 0x0004:
|
||||
// Special format UTF-8
|
||||
{
|
||||
const char *utfdata = (const char *)(data_start + indexTables[i].data_table_offset);
|
||||
const u8 *utfdata = (const u8 *)(data_start + indexTables[i].data_table_offset);
|
||||
DEBUG_LOG(LOADER, "%s %s", key, utfdata);
|
||||
SetValue(key,std::string(utfdata,indexTables[i].param_len),indexTables[i].param_max_len);
|
||||
SetValue(key, utfdata, indexTables[i].param_len, indexTables[i].param_max_len);
|
||||
}
|
||||
break;
|
||||
case 0x0204:
|
||||
@@ -187,10 +193,10 @@ bool ParamSFOData::WriteSFO(u8 **paramsfo, size_t *size)
|
||||
else if(it->second.type == VT_UTF8_SPE)
|
||||
{
|
||||
index_ptr->param_fmt = 0x0004;
|
||||
index_ptr->param_len = it->second.s_value.size()+1;
|
||||
index_ptr->param_len = it->second.u_size;
|
||||
|
||||
memcpy(data_ptr,it->second.s_value.c_str(),index_ptr->param_len);
|
||||
data_ptr[index_ptr->param_len] = 0;
|
||||
memset(data_ptr,0,index_ptr->param_max_len);
|
||||
memcpy(data_ptr,it->second.u_value,index_ptr->param_len);
|
||||
}
|
||||
else if(it->second.type == VT_UTF8)
|
||||
{
|
||||
|
||||
+38
-2
@@ -25,9 +25,11 @@ class ParamSFOData
|
||||
public:
|
||||
void SetValue(std::string key, unsigned int value, int max_size);
|
||||
void SetValue(std::string key, std::string value, int max_size);
|
||||
void SetValue(std::string key, const u8* value, unsigned int size, int max_size);
|
||||
|
||||
int GetValueInt(std::string key);
|
||||
std::string GetValueString(std::string key);
|
||||
u8* GetValueData(std::string key, unsigned int *size);
|
||||
|
||||
bool ReadSFO(const u8 *paramsfo, size_t size);
|
||||
bool WriteSFO(u8 **paramsfo, size_t *size);
|
||||
@@ -37,14 +39,48 @@ private:
|
||||
{
|
||||
VT_INT,
|
||||
VT_UTF8,
|
||||
VT_UTF8_SPE
|
||||
VT_UTF8_SPE // raw data in u8
|
||||
};
|
||||
struct ValueData
|
||||
class ValueData
|
||||
{
|
||||
public:
|
||||
ValueType type;
|
||||
int max_size;
|
||||
std::string s_value;
|
||||
int i_value;
|
||||
|
||||
u8* u_value;
|
||||
unsigned int u_size;
|
||||
|
||||
void SetData(const u8* data, int size)
|
||||
{
|
||||
if(u_value)
|
||||
{
|
||||
delete[] u_value;
|
||||
u_value = 0;
|
||||
}
|
||||
if(size > 0)
|
||||
{
|
||||
u_value = new u8[size];
|
||||
memcpy(u_value,data,size);
|
||||
}
|
||||
u_size = size;
|
||||
}
|
||||
|
||||
ValueData()
|
||||
{
|
||||
u_value = 0;
|
||||
u_size = 0;
|
||||
type = VT_INT;
|
||||
max_size = 0;
|
||||
i_value = 0;
|
||||
}
|
||||
|
||||
~ValueData()
|
||||
{
|
||||
if(u_value)
|
||||
delete[] u_value;
|
||||
}
|
||||
};
|
||||
|
||||
std::map<std::string,ValueData> values;
|
||||
|
||||
+173
-175
@@ -10,248 +10,248 @@ extern "C"
|
||||
// Thank you PSARDUMPER & JPCSP keys
|
||||
|
||||
// PRXDecrypter 16-byte tag keys.
|
||||
u8 keys260_0[] = {0xC3, 0x24, 0x89, 0xD3, 0x80, 0x87, 0xB2, 0x4E, 0x4C, 0xD7, 0x49, 0xE4, 0x9D, 0x1D, 0x34, 0xD1};
|
||||
u8 keys260_1[] = {0xF3, 0xAC, 0x6E, 0x7C, 0x04, 0x0A, 0x23, 0xE7, 0x0D, 0x33, 0xD8, 0x24, 0x73, 0x39, 0x2B, 0x4A};
|
||||
u8 keys260_2[] = {0x72, 0xB4, 0x39, 0xFF, 0x34, 0x9B, 0xAE, 0x82, 0x30, 0x34, 0x4A, 0x1D, 0xA2, 0xD8, 0xB4, 0x3C};
|
||||
u8 keys280_0[] = {0xCA, 0xFB, 0xBF, 0xC7, 0x50, 0xEA, 0xB4, 0x40, 0x8E, 0x44, 0x5C, 0x63, 0x53, 0xCE, 0x80, 0xB1};
|
||||
u8 keys280_1[] = {0x40, 0x9B, 0xC6, 0x9B, 0xA9, 0xFB, 0x84, 0x7F, 0x72, 0x21, 0xD2, 0x36, 0x96, 0x55, 0x09, 0x74};
|
||||
u8 keys280_2[] = {0x03, 0xA7, 0xCC, 0x4A, 0x5B, 0x91, 0xC2, 0x07, 0xFF, 0xFC, 0x26, 0x25, 0x1E, 0x42, 0x4B, 0xB5};
|
||||
u8 keys300_0[] = {0x9F, 0x67, 0x1A, 0x7A, 0x22, 0xF3, 0x59, 0x0B, 0xAA, 0x6D, 0xA4, 0xC6, 0x8B, 0xD0, 0x03, 0x77};
|
||||
u8 keys300_1[] = {0x15, 0x07, 0x63, 0x26, 0xDB, 0xE2, 0x69, 0x34, 0x56, 0x08, 0x2A, 0x93, 0x4E, 0x4B, 0x8A, 0xB2};
|
||||
u8 keys300_2[] = {0x56, 0x3B, 0x69, 0xF7, 0x29, 0x88, 0x2F, 0x4C, 0xDB, 0xD5, 0xDE, 0x80, 0xC6, 0x5C, 0xC8, 0x73};
|
||||
u8 keys303_0[] = {0x7b, 0xa1, 0xe2, 0x5a, 0x91, 0xb9, 0xd3, 0x13, 0x77, 0x65, 0x4a, 0xb7, 0xc2, 0x8a, 0x10, 0xaf};
|
||||
u8 keys310_0[] = {0xa2, 0x41, 0xe8, 0x39, 0x66, 0x5b, 0xfa, 0xbb, 0x1b, 0x2d, 0x6e, 0x0e, 0x33, 0xe5, 0xd7, 0x3f};
|
||||
u8 keys310_1[] = {0xA4, 0x60, 0x8F, 0xAB, 0xAB, 0xDE, 0xA5, 0x65, 0x5D, 0x43, 0x3A, 0xD1, 0x5E, 0xC3, 0xFF, 0xEA};
|
||||
u8 keys310_2[] = {0xE7, 0x5C, 0x85, 0x7A, 0x59, 0xB4, 0xE3, 0x1D, 0xD0, 0x9E, 0xCE, 0xC2, 0xD6, 0xD4, 0xBD, 0x2B};
|
||||
u8 keys310_3[] = {0x2E, 0x00, 0xF6, 0xF7, 0x52, 0xCF, 0x95, 0x5A, 0xA1, 0x26, 0xB4, 0x84, 0x9B, 0x58, 0x76, 0x2F};
|
||||
u8 keys330_0[] = {0x3B, 0x9B, 0x1A, 0x56, 0x21, 0x80, 0x14, 0xED, 0x8E, 0x8B, 0x08, 0x42, 0xFA, 0x2C, 0xDC, 0x3A};
|
||||
u8 keys330_1[] = {0xE8, 0xBE, 0x2F, 0x06, 0xB1, 0x05, 0x2A, 0xB9, 0x18, 0x18, 0x03, 0xE3, 0xEB, 0x64, 0x7D, 0x26};
|
||||
u8 keys330_2[] = {0xAB, 0x82, 0x25, 0xD7, 0x43, 0x6F, 0x6C, 0xC1, 0x95, 0xC5, 0xF7, 0xF0, 0x63, 0x73, 0x3F, 0xE7};
|
||||
u8 keys330_3[] = {0xA8, 0xB1, 0x47, 0x77, 0xDC, 0x49, 0x6A, 0x6F, 0x38, 0x4C, 0x4D, 0x96, 0xBD, 0x49, 0xEC, 0x9B};
|
||||
u8 keys330_4[] = {0xEC, 0x3B, 0xD2, 0xC0, 0xFA, 0xC1, 0xEE, 0xB9, 0x9A, 0xBC, 0xFF, 0xA3, 0x89, 0xF2, 0x60, 0x1F};
|
||||
u8 keys360_0[] = {0x3C, 0x2B, 0x51, 0xD4, 0x2D, 0x85, 0x47, 0xDA, 0x2D, 0xCA, 0x18, 0xDF, 0xFE, 0x54, 0x09, 0xED};
|
||||
u8 keys360_1[] = {0x31, 0x1F, 0x98, 0xD5, 0x7B, 0x58, 0x95, 0x45, 0x32, 0xAB, 0x3A, 0xE3, 0x89, 0x32, 0x4B, 0x34};
|
||||
u8 keys370_0[] = {0x26, 0x38, 0x0A, 0xAC, 0xA5, 0xD8, 0x74, 0xD1, 0x32, 0xB7, 0x2A, 0xBF, 0x79, 0x9E, 0x6D, 0xDB};
|
||||
u8 keys370_1[] = {0x53, 0xE7, 0xAB, 0xB9, 0xC6, 0x4A, 0x4B, 0x77, 0x92, 0x17, 0xB5, 0x74, 0x0A, 0xDA, 0xA9, 0xEA};
|
||||
u8 keys370_2[] = {0x71, 0x10, 0xF0, 0xA4, 0x16, 0x14, 0xD5, 0x93, 0x12, 0xFF, 0x74, 0x96, 0xDF, 0x1F, 0xDA, 0x89};
|
||||
u8 keys390_0[] = {0x45, 0xEF, 0x5C, 0x5D, 0xED, 0x81, 0x99, 0x84, 0x12, 0x94, 0x8F, 0xAB, 0xE8, 0x05, 0x6D, 0x7D};
|
||||
u8 keys390_1[] = {0x70, 0x1B, 0x08, 0x25, 0x22, 0xA1, 0x4D, 0x3B, 0x69, 0x21, 0xF9, 0x71, 0x0A, 0xA8, 0x41, 0xA9};
|
||||
u8 keys500_0[] = {0xEB, 0x1B, 0x53, 0x0B, 0x62, 0x49, 0x32, 0x58, 0x1F, 0x83, 0x0A, 0xF4, 0x99, 0x3D, 0x75, 0xD0};
|
||||
u8 keys500_1[] = {0xBA, 0xE2, 0xA3, 0x12, 0x07, 0xFF, 0x04, 0x1B, 0x64, 0xA5, 0x11, 0x85, 0xF7, 0x2F, 0x99, 0x5B};
|
||||
u8 keys500_2[] = {0x2C, 0x8E, 0xAF, 0x1D, 0xFF, 0x79, 0x73, 0x1A, 0xAD, 0x96, 0xAB, 0x09, 0xEA, 0x35, 0x59, 0x8B};
|
||||
u8 keys500_c[] = {0xA3, 0x5D, 0x51, 0xE6, 0x56, 0xC8, 0x01, 0xCA, 0xE3, 0x77, 0xBF, 0xCD, 0xFF, 0x24, 0xDA, 0x4D};
|
||||
u8 keys505_a[] = {0x7B, 0x94, 0x72, 0x27, 0x4C, 0xCC, 0x54, 0x3B, 0xAE, 0xDF, 0x46, 0x37, 0xAC, 0x01, 0x4D, 0x87};
|
||||
u8 keys505_0[] = {0x2E, 0x8E, 0x97, 0xA2, 0x85, 0x42, 0x70, 0x73, 0x18, 0xDA, 0xA0, 0x8A, 0xF8, 0x62, 0xA2, 0xB0};
|
||||
u8 keys505_1[] = {0x58, 0x2A, 0x4C, 0x69, 0x19, 0x7B, 0x83, 0x3D, 0xD2, 0x61, 0x61, 0xFE, 0x14, 0xEE, 0xAA, 0x11};
|
||||
u8 keys570_5k[] = {0x6D, 0x72, 0xA4, 0xBA, 0x7F, 0xBF, 0xD1, 0xF1, 0xA9, 0xF3, 0xBB, 0x07, 0x1B, 0xC0, 0xB3, 0x66};
|
||||
u8 keys600_1[] = {0xE3, 0x52, 0x39, 0x97, 0x3B, 0x84, 0x41, 0x1C, 0xC3, 0x23, 0xF1, 0xB8, 0xA9, 0x09, 0x4B, 0xF0};
|
||||
u8 keys600_2[] = {0xE1, 0x45, 0x93, 0x2C, 0x53, 0xE2, 0xAB, 0x06, 0x6F, 0xB6, 0x8F, 0x0B, 0x66, 0x91, 0xE7, 0x1E};
|
||||
u8 keys620_0[] = {0xD6, 0xBD, 0xCE, 0x1E, 0x12, 0xAF, 0x9A, 0xE6, 0x69, 0x30, 0xDE, 0xDA, 0x88, 0xB8, 0xFF, 0xFB};
|
||||
u8 keys620_1[] = {0x1D, 0x13, 0xE9, 0x50, 0x04, 0x73, 0x3D, 0xD2, 0xE1, 0xDA, 0xB9, 0xC1, 0xE6, 0x7B, 0x25, 0xA7};
|
||||
u8 keys620_a[] = {0xAC, 0x34, 0xBA, 0xB1, 0x97, 0x8D, 0xAE, 0x6F, 0xBA, 0xE8, 0xB1, 0xD6, 0xDF, 0xDF, 0xF1, 0xA2};
|
||||
u8 keys620_e[] = {0xB1, 0xB3, 0x7F, 0x76, 0xC3, 0xFB, 0x88, 0xE6, 0xF8, 0x60, 0xD3, 0x35, 0x3C, 0xA3, 0x4E, 0xF3};
|
||||
u8 keys620_5[] = {0xF1, 0xBC, 0x17, 0x07, 0xAE, 0xB7, 0xC8, 0x30, 0xD8, 0x34, 0x9D, 0x40, 0x6A, 0x8E, 0xDF, 0x4E};
|
||||
u8 keys620_5k[] = {0x41, 0x8A, 0x35, 0x4F, 0x69, 0x3A, 0xDF, 0x04, 0xFD, 0x39, 0x46, 0xA2, 0x5C, 0x2D, 0xF2, 0x21};
|
||||
u8 keys620_5v[] = {0xF2, 0x8F, 0x75, 0xA7, 0x31, 0x91, 0xCE, 0x9E, 0x75, 0xBD, 0x27, 0x26, 0xB4, 0xB4, 0x0C, 0x32};
|
||||
u8 keys630_k1[] = {0x36, 0xB0, 0xDC, 0xFC, 0x59, 0x2A, 0x95, 0x1D, 0x80, 0x2D, 0x80, 0x3F, 0xCD, 0x30, 0xA0, 0x1B};
|
||||
u8 keys630_k2[] = {0xd4, 0x35, 0x18, 0x02, 0x29, 0x68, 0xfb, 0xa0, 0x6a, 0xa9, 0xa5, 0xed, 0x78, 0xfd, 0x2e, 0x9d};
|
||||
u8 keys630_k3[] = {0x23, 0x8D, 0x3D, 0xAE, 0x41, 0x50, 0xA0, 0xFA, 0xF3, 0x2F, 0x32, 0xCE, 0xC7, 0x27, 0xCD, 0x50};
|
||||
u8 keys630_k4[] = {0xAA, 0xA1, 0xB5, 0x7C, 0x93, 0x5A, 0x95, 0xBD, 0xEF, 0x69, 0x16, 0xFC, 0x2B, 0x92, 0x31, 0xDD};
|
||||
u8 keys630_k5[] = {0x87, 0x37, 0x21, 0xCC, 0x65, 0xAE, 0xAA, 0x5F, 0x40, 0xF6, 0x6F, 0x2A, 0x86, 0xC7, 0xA1, 0xC8};
|
||||
u8 keys630_k6[] = {0x8D, 0xDB, 0xDC, 0x5C, 0xF2, 0x70, 0x2B, 0x40, 0xB2, 0x3D, 0x00, 0x09, 0x61, 0x7C, 0x10, 0x60};
|
||||
u8 keys630_k7[] = {0x77, 0x1C, 0x06, 0x5F, 0x53, 0xEC, 0x3F, 0xFC, 0x22, 0xCE, 0x5A, 0x27, 0xFF, 0x78, 0xA8, 0x48};
|
||||
u8 keys630_k8[] = {0x81, 0xD1, 0x12, 0x89, 0x35, 0xC8, 0xEA, 0x8B, 0xE0, 0x02, 0x2D, 0x2D, 0x6A, 0x18, 0x67, 0xB8};
|
||||
u8 keys636_k1[] = {0x07, 0xE3, 0x08, 0x64, 0x7F, 0x60, 0xA3, 0x36, 0x6A, 0x76, 0x21, 0x44, 0xC9, 0xD7, 0x06, 0x83};
|
||||
u8 keys636_k2[] = {0x91, 0xF2, 0x02, 0x9E, 0x63, 0x32, 0x30, 0xA9, 0x1D, 0xDA, 0x0B, 0xA8, 0xB7, 0x41, 0xA3, 0xCC};
|
||||
u8 keys638_k4[] = {0x98, 0x43, 0xFF, 0x85, 0x68, 0xB2, 0xDB, 0x3B, 0xD4, 0x22, 0xD0, 0x4F, 0xAB, 0x5F, 0x0A, 0x31};
|
||||
u8 keys639_k3[] = {0x01, 0x7B, 0xF0, 0xE9, 0xBE, 0x9A, 0xDD, 0x54, 0x37, 0xEA, 0x0E, 0xC4, 0xD6, 0x4D, 0x8E, 0x9E};
|
||||
u8 keys660_k1[] = {0x76, 0xF2, 0x6C, 0x0A, 0xCA, 0x3A, 0xBA, 0x4E, 0xAC, 0x76, 0xD2, 0x40, 0xF5, 0xC3, 0xBF, 0xF9};
|
||||
u8 keys660_k2[] = {0x7A, 0x3E, 0x55, 0x75, 0xB9, 0x6A, 0xFC, 0x4F, 0x3E, 0xE3, 0xDF, 0xB3, 0x6C, 0xE8, 0x2A, 0x82};
|
||||
u8 keys660_k3[] = {0xFA, 0x79, 0x09, 0x36, 0xE6, 0x19, 0xE8, 0xA4, 0xA9, 0x41, 0x37, 0x18, 0x81, 0x02, 0xE9, 0xB3};
|
||||
u8 keys660_v1[] = {0xBA, 0x76, 0x61, 0x47, 0x8B, 0x55, 0xA8, 0x72, 0x89, 0x15, 0x79, 0x6D, 0xD7, 0x2F, 0x78, 0x0E};
|
||||
u8 keys660_v2[] = {0xF9, 0x4A, 0x6B, 0x96, 0x79, 0x3F, 0xEE, 0x0A, 0x04, 0xC8, 0x8D, 0x7E, 0x5F, 0x38, 0x3A, 0xCF};
|
||||
u8 keys660_v3[] = {0x88, 0xAF, 0x18, 0xE9, 0xC3, 0xAA, 0x6B, 0x56, 0xF7, 0xC5, 0xA8, 0xBF, 0x1A, 0x84, 0xE9, 0xF3};
|
||||
u8 keys660_v4[] = {0xD1, 0xB0, 0xAE, 0xC3, 0x24, 0x36, 0x13, 0x49, 0xD6, 0x49, 0xD7, 0x88, 0xEA, 0xA4, 0x99, 0x86};
|
||||
u8 keys660_v5[] = {0xCB, 0x93, 0x12, 0x38, 0x31, 0xC0, 0x2D, 0x2E, 0x7A, 0x18, 0x5C, 0xAC, 0x92, 0x93, 0xAB, 0x32};
|
||||
u8 keys660_v6[] = {0x92, 0x8C, 0xA4, 0x12, 0xD6, 0x5C, 0x55, 0x31, 0x5B, 0x94, 0x23, 0x9B, 0x62, 0xB3, 0xDB, 0x47};
|
||||
u8 keys660_k4[] = {0xC8, 0xA0, 0x70, 0x98, 0xAE, 0xE6, 0x2B, 0x80, 0xD7, 0x91, 0xE6, 0xCA, 0x4C, 0xA9, 0x78, 0x4E};
|
||||
u8 keys660_k5[] = {0xBF, 0xF8, 0x34, 0x02, 0x84, 0x47, 0xBD, 0x87, 0x1C, 0x52, 0x03, 0x23, 0x79, 0xBB, 0x59, 0x81};
|
||||
u8 keys660_k6[] = {0xD2, 0x83, 0xCC, 0x63, 0xBB, 0x10, 0x15, 0xE7, 0x7B, 0xC0, 0x6D, 0xEE, 0x34, 0x9E, 0x4A, 0xFA};
|
||||
u8 keys660_k7[] = {0xEB, 0xD9, 0x1E, 0x05, 0x3C, 0xAE, 0xAB, 0x62, 0xE3, 0xB7, 0x1F, 0x37, 0xE5, 0xCD, 0x68, 0xC3};
|
||||
u8 keys660_v7[] = {0xC5, 0x9C, 0x77, 0x9C, 0x41, 0x01, 0xE4, 0x85, 0x79, 0xC8, 0x71, 0x63, 0xA5, 0x7D, 0x4F, 0xFB};
|
||||
u8 keys660_v8[] = {0x86, 0xA0, 0x7D, 0x4D, 0xB3, 0x6B, 0xA2, 0xFD, 0xF4, 0x15, 0x85, 0x70, 0x2D, 0x6A, 0x0D, 0x3A};
|
||||
u8 keys660_k8[] = {0x85, 0x93, 0x1F, 0xED, 0x2C, 0x4D, 0xA4, 0x53, 0x59, 0x9C, 0x3F, 0x16, 0xF3, 0x50, 0xDE, 0x46};
|
||||
u8 key_21C0[] = {0x6A, 0x19, 0x71, 0xF3, 0x18, 0xDE, 0xD3, 0xA2, 0x6D, 0x3B, 0xDE, 0xC7, 0xBE, 0x98, 0xE2, 0x4C};
|
||||
u8 key_2250[] = {0x50, 0xCC, 0x03, 0xAC, 0x3F, 0x53, 0x1A, 0xFA, 0x0A, 0xA4, 0x34, 0x23, 0x86, 0x61, 0x7F, 0x97};
|
||||
u8 key_22E0[] = {0x66, 0x0F, 0xCB, 0x3B, 0x30, 0x75, 0xE3, 0x10, 0x0A, 0x95, 0x65, 0xC7, 0x3C, 0x93, 0x87, 0x22};
|
||||
u8 key_2D80[] = {0x40, 0x02, 0xC0, 0xBF, 0x20, 0x02, 0xC0, 0xBF, 0x5C, 0x68, 0x2B, 0x95, 0x5F, 0x40, 0x7B, 0xB8};
|
||||
u8 key_2D90[] = {0x55, 0x19, 0x35, 0x10, 0x48, 0xD8, 0x2E, 0x46, 0xA8, 0xB1, 0x47, 0x77, 0xDC, 0x49, 0x6A, 0x6F};
|
||||
u8 key_2DA8[] = {0x80, 0x02, 0xC0, 0xBF, 0x00, 0x0A, 0xC0, 0xBF, 0x40, 0x03, 0xC0, 0xBF, 0x40, 0x00, 0x00, 0x00};
|
||||
u8 key_2DB8[] = {0x4C, 0x2D, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xB8, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
u8 key_D91605F0[] = {0xB8, 0x8C, 0x45, 0x8B, 0xB6, 0xE7, 0x6E, 0xB8, 0x51, 0x59, 0xA6, 0x53, 0x7C, 0x5E, 0x86, 0x31};
|
||||
u8 key_D91606F0[] = {0xED, 0x10, 0xE0, 0x36, 0xC4, 0xFE, 0x83, 0xF3, 0x75, 0x70, 0x5E, 0xF6, 0xA4, 0x40, 0x05, 0xF7};
|
||||
u8 key_D91608F0[] = {0x5C, 0x77, 0x0C, 0xBB, 0xB4, 0xC2, 0x4F, 0xA2, 0x7E, 0x3B, 0x4E, 0xB4, 0xB4, 0xC8, 0x70, 0xAF};
|
||||
u8 key_D91609F0[] = {0xD0, 0x36, 0x12, 0x75, 0x80, 0x56, 0x20, 0x43, 0xC4, 0x30, 0x94, 0x3E, 0x1C, 0x75, 0xD1, 0xBF};
|
||||
u8 key_D9160AF0[] = {0x10, 0xA9, 0xAC, 0x16, 0xAE, 0x19, 0xC0, 0x7E, 0x3B, 0x60, 0x77, 0x86, 0x01, 0x6F, 0xF2, 0x63};
|
||||
u8 key_D9160BF0[] = {0x83, 0x83, 0xF1, 0x37, 0x53, 0xD0, 0xBE, 0xFC, 0x8D, 0xA7, 0x32, 0x52, 0x46, 0x0A, 0xC2, 0xC2};
|
||||
u8 key_D91611F0[] = {0x61, 0xB0, 0xC0, 0x58, 0x71, 0x57, 0xD9, 0xFA, 0x74, 0x67, 0x0E, 0x5C, 0x7E, 0x6E, 0x95, 0xB9};
|
||||
u8 key_D91612F0[] = {0x9E, 0x20, 0xE1, 0xCD, 0xD7, 0x88, 0xDE, 0xC0, 0x31, 0x9B, 0x10, 0xAF, 0xC5, 0xB8, 0x73, 0x23};
|
||||
u8 key_D91613F0[] = {0xEB, 0xFF, 0x40, 0xD8, 0xB4, 0x1A, 0xE1, 0x66, 0x91, 0x3B, 0x8F, 0x64, 0xB6, 0xFC, 0xB7, 0x12};
|
||||
u8 key_D91614F0[] = {0xFD, 0xF7, 0xB7, 0x3C, 0x9F, 0xD1, 0x33, 0x95, 0x11, 0xB8, 0xB5, 0xBB, 0x54, 0x23, 0x73, 0x85};
|
||||
u8 key_D91615F0[] = {0xC8, 0x03, 0xE3, 0x44, 0x50, 0xF1, 0xE7, 0x2A, 0x6A, 0x0D, 0xC3, 0x61, 0xB6, 0x8E, 0x5F, 0x51};
|
||||
u8 key_D91616F0[] = {0x53, 0x03, 0xB8, 0x6A, 0x10, 0x19, 0x98, 0x49, 0x1C, 0xAF, 0x30, 0xE4, 0x25, 0x1B, 0x6B, 0x28};
|
||||
u8 key_D91617F0[] = {0x02, 0xFA, 0x48, 0x73, 0x75, 0xAF, 0xAE, 0x0A, 0x67, 0x89, 0x2B, 0x95, 0x4B, 0x09, 0x87, 0xA3};
|
||||
u8 key_D91618F0[] = {0x96, 0x96, 0x7C, 0xC3, 0xF7, 0x12, 0xDA, 0x62, 0x1B, 0xF6, 0x9A, 0x9A, 0x44, 0x44, 0xBC, 0x48};
|
||||
u8 key_D91619F0[] = {0xE0, 0x32, 0xA7, 0x08, 0x6B, 0x2B, 0x29, 0x2C, 0xD1, 0x4D, 0x5B, 0xEE, 0xA8, 0xC8, 0xB4, 0xE9};
|
||||
u8 key_D9161AF0[] = {0x27, 0xE5, 0xA7, 0x49, 0x52, 0xE1, 0x94, 0x67, 0x35, 0x66, 0x91, 0x0C, 0xE8, 0x9A, 0x25, 0x24};
|
||||
u8 key_D91620F0[] = {0x52, 0x1C, 0xB4, 0x5F, 0x40, 0x3B, 0x9A, 0xDD, 0xAC, 0xFC, 0xEA, 0x92, 0xFD, 0xDD, 0xF5, 0x90};
|
||||
u8 key_D91621F0[] = {0xD1, 0x91, 0x2E, 0xA6, 0x21, 0x14, 0x29, 0x62, 0xF6, 0xED, 0xAE, 0xCB, 0xDD, 0xA3, 0xBA, 0xFE};
|
||||
u8 key_D91622F0[] = {0x59, 0x5D, 0x78, 0x4D, 0x21, 0xB2, 0x01, 0x17, 0x6C, 0x9A, 0xB5, 0x1B, 0xDA, 0xB7, 0xF9, 0xE6};
|
||||
u8 key_D91623F0[] = {0xAA, 0x45, 0xEB, 0x4F, 0x62, 0xFB, 0xD1, 0x0D, 0x71, 0xD5, 0x62, 0xD2, 0xF5, 0xBF, 0xA5, 0x2F};
|
||||
u8 key_D91624F0[] = {0x61, 0xB7, 0x26, 0xAF, 0x8B, 0xF1, 0x41, 0x58, 0x83, 0x6A, 0xC4, 0x92, 0x12, 0xCB, 0xB1, 0xE9};
|
||||
u8 key_D91628F0[] = {0x49, 0xA4, 0xFC, 0x66, 0xDC, 0xE7, 0x62, 0x21, 0xDB, 0x18, 0xA7, 0x50, 0xD6, 0xA8, 0xC1, 0xB6};
|
||||
u8 key_D91680F0[] = {0x2C, 0x22, 0x9B, 0x12, 0x36, 0x74, 0x11, 0x67, 0x49, 0xD1, 0xD1, 0x88, 0x92, 0xF6, 0xA1, 0xD8};
|
||||
u8 key_D91681F0[] = {0x52, 0xB6, 0x36, 0x6C, 0x8C, 0x46, 0x7F, 0x7A, 0xCC, 0x11, 0x62, 0x99, 0xC1, 0x99, 0xBE, 0x98};
|
||||
u8 key_2E5E10F0[] = {0x9D, 0x5C, 0x5B, 0xAF, 0x8C, 0xD8, 0x69, 0x7E, 0x51, 0x9F, 0x70, 0x96, 0xE6, 0xD5, 0xC4, 0xE8};
|
||||
u8 key_2E5E12F0[] = {0x8A, 0x7B, 0xC9, 0xD6, 0x52, 0x58, 0x88, 0xEA, 0x51, 0x83, 0x60, 0xCA, 0x16, 0x79, 0xE2, 0x07};
|
||||
u8 key_2E5E13F0[] = {0xFF, 0xA4, 0x68, 0xC3, 0x31, 0xCA, 0xB7, 0x4C, 0xF1, 0x23, 0xFF, 0x01, 0x65, 0x3D, 0x26, 0x36};
|
||||
u8 key_2FD30BF0[] = {0xD8, 0x58, 0x79, 0xF9, 0xA4, 0x22, 0xAF, 0x86, 0x90, 0xAC, 0xDA, 0x45, 0xCE, 0x60, 0x40, 0x3F};
|
||||
u8 key_2FD311F0[] = {0x3A, 0x6B, 0x48, 0x96, 0x86, 0xA5, 0xC8, 0x80, 0x69, 0x6C, 0xE6, 0x4B, 0xF6, 0x04, 0x17, 0x44};
|
||||
u8 key_2FD312F0[] = {0xC5, 0xFB, 0x69, 0x03, 0x20, 0x7A, 0xCF, 0xBA, 0x2C, 0x90, 0xF8, 0xB8, 0x4D, 0xD2, 0xF1, 0xDE};
|
||||
u8 keys02G_E[] = {0x9D, 0x09, 0xFD, 0x20, 0xF3, 0x8F, 0x10, 0x69, 0x0D, 0xB2, 0x6F, 0x00, 0xCC, 0xC5, 0x51, 0x2E};
|
||||
u8 keys03G_E[] = {0x4F, 0x44, 0x5C, 0x62, 0xB3, 0x53, 0xC4, 0x30, 0xFC, 0x3A, 0xA4, 0x5B, 0xEC, 0xFE, 0x51, 0xEA};
|
||||
u8 keys05G_E[] = {0x5D, 0xAA, 0x72, 0xF2, 0x26, 0x60, 0x4D, 0x1C, 0xE7, 0x2D, 0xC8, 0xA3, 0x2F, 0x79, 0xC5, 0x54};
|
||||
u8 oneseg_310[] = {0xC7, 0x27, 0x72, 0x85, 0xAB, 0xA7, 0xF7, 0xF0, 0x4C, 0xC1, 0x86, 0xCC, 0xE3, 0x7F, 0x17, 0xCA};
|
||||
u8 oneseg_300[] = {0x76, 0x40, 0x9E, 0x08, 0xDB, 0x9B, 0x3B, 0xA1, 0x47, 0x8A, 0x96, 0x8E, 0xF3, 0xF7, 0x62, 0x92};
|
||||
u8 oneseg_280[] = {0x23, 0xDC, 0x3B, 0xB5, 0xA9, 0x82, 0xD6, 0xEA, 0x63, 0xA3, 0x6E, 0x2B, 0x2B, 0xE9, 0xE1, 0x54};
|
||||
u8 oneseg_260_271[] = {0x22, 0x43, 0x57, 0x68, 0x2F, 0x41, 0xCE, 0x65, 0x4C, 0xA3, 0x7C, 0xC6, 0xC4, 0xAC, 0xF3, 0x60};
|
||||
u8 oneseg_slim[] = {0x12, 0x57, 0x0D, 0x8A, 0x16, 0x6D, 0x87, 0x06, 0x03, 0x7D, 0xC8, 0x8B, 0x62, 0xA3, 0x32, 0xA9};
|
||||
u8 ms_app_main[] = {0x1E, 0x2E, 0x38, 0x49, 0xDA, 0xD4, 0x16, 0x08, 0x27, 0x2E, 0xF3, 0xBC, 0x37, 0x75, 0x80, 0x93};
|
||||
u8 demokeys_280[] = {0x12, 0x99, 0x70, 0x5E, 0x24, 0x07, 0x6C, 0xD0, 0x2D, 0x06, 0xFE, 0x7E, 0xB3, 0x0C, 0x11, 0x26};
|
||||
u8 demokeys_3XX_1[] = {0x47, 0x05, 0xD5, 0xE3, 0x56, 0x1E, 0x81, 0x9B, 0x09, 0x2F, 0x06, 0xDB, 0x6B, 0x12, 0x92, 0xE0};
|
||||
u8 demokeys_3XX_2[] = {0xF6, 0x62, 0x39, 0x6E, 0x26, 0x22, 0x4D, 0xCA, 0x02, 0x64, 0x16, 0x99, 0x7B, 0x9A, 0xE7, 0xB8};
|
||||
u8 ebootbin_271_new[] = {0xF4, 0xAE, 0xF4, 0xE1, 0x86, 0xDD, 0xD2, 0x9C, 0x7C, 0xC5, 0x42, 0xA6, 0x95, 0xA0, 0x83, 0x88};
|
||||
u8 ebootbin_280_new[] = {0xB8, 0x8C, 0x45, 0x8B, 0xB6, 0xE7, 0x6E, 0xB8, 0x51, 0x59, 0xA6, 0x53, 0x7C, 0x5E, 0x86, 0x31};
|
||||
u8 ebootbin_300_new[] = {0xED, 0x10, 0xE0, 0x36, 0xC4, 0xFE, 0x83, 0xF3, 0x75, 0x70, 0x5E, 0xF6, 0xA4, 0x40, 0x05, 0xF7};
|
||||
u8 ebootbin_310_new[] = {0x5C, 0x77, 0x0C, 0xBB, 0xB4, 0xC2, 0x4F, 0xA2, 0x7E, 0x3B, 0x4E, 0xB4, 0xB4, 0xC8, 0x70, 0xAF};
|
||||
u8 gameshare_260_271[] = {0xF9, 0x48, 0x38, 0x0C, 0x96, 0x88, 0xA7, 0x74, 0x4F, 0x65, 0xA0, 0x54, 0xC2, 0x76, 0xD9, 0xB8};
|
||||
u8 gameshare_280[] = {0x2D, 0x86, 0x77, 0x3A, 0x56, 0xA4, 0x4F, 0xDD, 0x3C, 0x16, 0x71, 0x93, 0xAA, 0x8E, 0x11, 0x43};
|
||||
u8 gameshare_300[] = {0x78, 0x1A, 0xD2, 0x87, 0x24, 0xBD, 0xA2, 0x96, 0x18, 0x3F, 0x89, 0x36, 0x72, 0x90, 0x92, 0x85};
|
||||
u8 gameshare_310[] = {0xC9, 0x7D, 0x3E, 0x0A, 0x54, 0x81, 0x6E, 0xC7, 0x13, 0x74, 0x99, 0x74, 0x62, 0x18, 0xE7, 0xDD};
|
||||
u8 key_380210F0[] = {0x32, 0x2C, 0xFA, 0x75, 0xE4, 0x7E, 0x93, 0xEB, 0x9F, 0x22, 0x80, 0x85, 0x57, 0x08, 0x98, 0x48};
|
||||
u8 key_380280F0[] = {0x97, 0x09, 0x12, 0xD3, 0xDB, 0x02, 0xBD, 0xD8, 0xE7, 0x74, 0x51, 0xFE, 0xF0, 0xEA, 0x6C, 0x5C};
|
||||
u8 key_380283F0[] = {0x34, 0x20, 0x0C, 0x8E, 0xA1, 0x86, 0x79, 0x84, 0xAF, 0x13, 0xAE, 0x34, 0x77, 0x6F, 0xEA, 0x89};
|
||||
u8 key_407810F0[] = {0xAF, 0xAD, 0xCA, 0xF1, 0x95, 0x59, 0x91, 0xEC, 0x1B, 0x27, 0xD0, 0x4E, 0x8A, 0xF3, 0x3D, 0xE7};
|
||||
u8 drmkeys_6XX_1[] = {0x36, 0xEF, 0x82, 0x4E, 0x74, 0xFB, 0x17, 0x5B, 0x14, 0x14, 0x05, 0xF3, 0xB3, 0x8A, 0x76, 0x18};
|
||||
u8 drmkeys_6XX_2[] = {0x21, 0x52, 0x5D, 0x76, 0xF6, 0x81, 0x0F, 0x15, 0x2F, 0x4A, 0x40, 0x89, 0x63, 0xA0, 0x10, 0x55};
|
||||
static const u8 keys260_0[] = {0xC3, 0x24, 0x89, 0xD3, 0x80, 0x87, 0xB2, 0x4E, 0x4C, 0xD7, 0x49, 0xE4, 0x9D, 0x1D, 0x34, 0xD1};
|
||||
static const u8 keys260_1[] = {0xF3, 0xAC, 0x6E, 0x7C, 0x04, 0x0A, 0x23, 0xE7, 0x0D, 0x33, 0xD8, 0x24, 0x73, 0x39, 0x2B, 0x4A};
|
||||
static const u8 keys260_2[] = {0x72, 0xB4, 0x39, 0xFF, 0x34, 0x9B, 0xAE, 0x82, 0x30, 0x34, 0x4A, 0x1D, 0xA2, 0xD8, 0xB4, 0x3C};
|
||||
static const u8 keys280_0[] = {0xCA, 0xFB, 0xBF, 0xC7, 0x50, 0xEA, 0xB4, 0x40, 0x8E, 0x44, 0x5C, 0x63, 0x53, 0xCE, 0x80, 0xB1};
|
||||
static const u8 keys280_1[] = {0x40, 0x9B, 0xC6, 0x9B, 0xA9, 0xFB, 0x84, 0x7F, 0x72, 0x21, 0xD2, 0x36, 0x96, 0x55, 0x09, 0x74};
|
||||
static const u8 keys280_2[] = {0x03, 0xA7, 0xCC, 0x4A, 0x5B, 0x91, 0xC2, 0x07, 0xFF, 0xFC, 0x26, 0x25, 0x1E, 0x42, 0x4B, 0xB5};
|
||||
static const u8 keys300_0[] = {0x9F, 0x67, 0x1A, 0x7A, 0x22, 0xF3, 0x59, 0x0B, 0xAA, 0x6D, 0xA4, 0xC6, 0x8B, 0xD0, 0x03, 0x77};
|
||||
static const u8 keys300_1[] = {0x15, 0x07, 0x63, 0x26, 0xDB, 0xE2, 0x69, 0x34, 0x56, 0x08, 0x2A, 0x93, 0x4E, 0x4B, 0x8A, 0xB2};
|
||||
static const u8 keys300_2[] = {0x56, 0x3B, 0x69, 0xF7, 0x29, 0x88, 0x2F, 0x4C, 0xDB, 0xD5, 0xDE, 0x80, 0xC6, 0x5C, 0xC8, 0x73};
|
||||
static const u8 keys303_0[] = {0x7b, 0xa1, 0xe2, 0x5a, 0x91, 0xb9, 0xd3, 0x13, 0x77, 0x65, 0x4a, 0xb7, 0xc2, 0x8a, 0x10, 0xaf};
|
||||
static const u8 keys310_0[] = {0xa2, 0x41, 0xe8, 0x39, 0x66, 0x5b, 0xfa, 0xbb, 0x1b, 0x2d, 0x6e, 0x0e, 0x33, 0xe5, 0xd7, 0x3f};
|
||||
static const u8 keys310_1[] = {0xA4, 0x60, 0x8F, 0xAB, 0xAB, 0xDE, 0xA5, 0x65, 0x5D, 0x43, 0x3A, 0xD1, 0x5E, 0xC3, 0xFF, 0xEA};
|
||||
static const u8 keys310_2[] = {0xE7, 0x5C, 0x85, 0x7A, 0x59, 0xB4, 0xE3, 0x1D, 0xD0, 0x9E, 0xCE, 0xC2, 0xD6, 0xD4, 0xBD, 0x2B};
|
||||
static const u8 keys310_3[] = {0x2E, 0x00, 0xF6, 0xF7, 0x52, 0xCF, 0x95, 0x5A, 0xA1, 0x26, 0xB4, 0x84, 0x9B, 0x58, 0x76, 0x2F};
|
||||
static const u8 keys330_0[] = {0x3B, 0x9B, 0x1A, 0x56, 0x21, 0x80, 0x14, 0xED, 0x8E, 0x8B, 0x08, 0x42, 0xFA, 0x2C, 0xDC, 0x3A};
|
||||
static const u8 keys330_1[] = {0xE8, 0xBE, 0x2F, 0x06, 0xB1, 0x05, 0x2A, 0xB9, 0x18, 0x18, 0x03, 0xE3, 0xEB, 0x64, 0x7D, 0x26};
|
||||
static const u8 keys330_2[] = {0xAB, 0x82, 0x25, 0xD7, 0x43, 0x6F, 0x6C, 0xC1, 0x95, 0xC5, 0xF7, 0xF0, 0x63, 0x73, 0x3F, 0xE7};
|
||||
static const u8 keys330_3[] = {0xA8, 0xB1, 0x47, 0x77, 0xDC, 0x49, 0x6A, 0x6F, 0x38, 0x4C, 0x4D, 0x96, 0xBD, 0x49, 0xEC, 0x9B};
|
||||
static const u8 keys330_4[] = {0xEC, 0x3B, 0xD2, 0xC0, 0xFA, 0xC1, 0xEE, 0xB9, 0x9A, 0xBC, 0xFF, 0xA3, 0x89, 0xF2, 0x60, 0x1F};
|
||||
static const u8 keys360_0[] = {0x3C, 0x2B, 0x51, 0xD4, 0x2D, 0x85, 0x47, 0xDA, 0x2D, 0xCA, 0x18, 0xDF, 0xFE, 0x54, 0x09, 0xED};
|
||||
static const u8 keys360_1[] = {0x31, 0x1F, 0x98, 0xD5, 0x7B, 0x58, 0x95, 0x45, 0x32, 0xAB, 0x3A, 0xE3, 0x89, 0x32, 0x4B, 0x34};
|
||||
static const u8 keys370_0[] = {0x26, 0x38, 0x0A, 0xAC, 0xA5, 0xD8, 0x74, 0xD1, 0x32, 0xB7, 0x2A, 0xBF, 0x79, 0x9E, 0x6D, 0xDB};
|
||||
static const u8 keys370_1[] = {0x53, 0xE7, 0xAB, 0xB9, 0xC6, 0x4A, 0x4B, 0x77, 0x92, 0x17, 0xB5, 0x74, 0x0A, 0xDA, 0xA9, 0xEA};
|
||||
static const u8 keys370_2[] = {0x71, 0x10, 0xF0, 0xA4, 0x16, 0x14, 0xD5, 0x93, 0x12, 0xFF, 0x74, 0x96, 0xDF, 0x1F, 0xDA, 0x89};
|
||||
static const u8 keys390_0[] = {0x45, 0xEF, 0x5C, 0x5D, 0xED, 0x81, 0x99, 0x84, 0x12, 0x94, 0x8F, 0xAB, 0xE8, 0x05, 0x6D, 0x7D};
|
||||
static const u8 keys390_1[] = {0x70, 0x1B, 0x08, 0x25, 0x22, 0xA1, 0x4D, 0x3B, 0x69, 0x21, 0xF9, 0x71, 0x0A, 0xA8, 0x41, 0xA9};
|
||||
static const u8 keys500_0[] = {0xEB, 0x1B, 0x53, 0x0B, 0x62, 0x49, 0x32, 0x58, 0x1F, 0x83, 0x0A, 0xF4, 0x99, 0x3D, 0x75, 0xD0};
|
||||
static const u8 keys500_1[] = {0xBA, 0xE2, 0xA3, 0x12, 0x07, 0xFF, 0x04, 0x1B, 0x64, 0xA5, 0x11, 0x85, 0xF7, 0x2F, 0x99, 0x5B};
|
||||
static const u8 keys500_2[] = {0x2C, 0x8E, 0xAF, 0x1D, 0xFF, 0x79, 0x73, 0x1A, 0xAD, 0x96, 0xAB, 0x09, 0xEA, 0x35, 0x59, 0x8B};
|
||||
static const u8 keys500_c[] = {0xA3, 0x5D, 0x51, 0xE6, 0x56, 0xC8, 0x01, 0xCA, 0xE3, 0x77, 0xBF, 0xCD, 0xFF, 0x24, 0xDA, 0x4D};
|
||||
static const u8 keys505_a[] = {0x7B, 0x94, 0x72, 0x27, 0x4C, 0xCC, 0x54, 0x3B, 0xAE, 0xDF, 0x46, 0x37, 0xAC, 0x01, 0x4D, 0x87};
|
||||
static const u8 keys505_0[] = {0x2E, 0x8E, 0x97, 0xA2, 0x85, 0x42, 0x70, 0x73, 0x18, 0xDA, 0xA0, 0x8A, 0xF8, 0x62, 0xA2, 0xB0};
|
||||
static const u8 keys505_1[] = {0x58, 0x2A, 0x4C, 0x69, 0x19, 0x7B, 0x83, 0x3D, 0xD2, 0x61, 0x61, 0xFE, 0x14, 0xEE, 0xAA, 0x11};
|
||||
static const u8 keys570_5k[] = {0x6D, 0x72, 0xA4, 0xBA, 0x7F, 0xBF, 0xD1, 0xF1, 0xA9, 0xF3, 0xBB, 0x07, 0x1B, 0xC0, 0xB3, 0x66};
|
||||
static const u8 keys600_1[] = {0xE3, 0x52, 0x39, 0x97, 0x3B, 0x84, 0x41, 0x1C, 0xC3, 0x23, 0xF1, 0xB8, 0xA9, 0x09, 0x4B, 0xF0};
|
||||
static const u8 keys600_2[] = {0xE1, 0x45, 0x93, 0x2C, 0x53, 0xE2, 0xAB, 0x06, 0x6F, 0xB6, 0x8F, 0x0B, 0x66, 0x91, 0xE7, 0x1E};
|
||||
static const u8 keys620_0[] = {0xD6, 0xBD, 0xCE, 0x1E, 0x12, 0xAF, 0x9A, 0xE6, 0x69, 0x30, 0xDE, 0xDA, 0x88, 0xB8, 0xFF, 0xFB};
|
||||
static const u8 keys620_1[] = {0x1D, 0x13, 0xE9, 0x50, 0x04, 0x73, 0x3D, 0xD2, 0xE1, 0xDA, 0xB9, 0xC1, 0xE6, 0x7B, 0x25, 0xA7};
|
||||
static const u8 keys620_a[] = {0xAC, 0x34, 0xBA, 0xB1, 0x97, 0x8D, 0xAE, 0x6F, 0xBA, 0xE8, 0xB1, 0xD6, 0xDF, 0xDF, 0xF1, 0xA2};
|
||||
static const u8 keys620_e[] = {0xB1, 0xB3, 0x7F, 0x76, 0xC3, 0xFB, 0x88, 0xE6, 0xF8, 0x60, 0xD3, 0x35, 0x3C, 0xA3, 0x4E, 0xF3};
|
||||
static const u8 keys620_5[] = {0xF1, 0xBC, 0x17, 0x07, 0xAE, 0xB7, 0xC8, 0x30, 0xD8, 0x34, 0x9D, 0x40, 0x6A, 0x8E, 0xDF, 0x4E};
|
||||
static const u8 keys620_5k[] = {0x41, 0x8A, 0x35, 0x4F, 0x69, 0x3A, 0xDF, 0x04, 0xFD, 0x39, 0x46, 0xA2, 0x5C, 0x2D, 0xF2, 0x21};
|
||||
static const u8 keys620_5v[] = {0xF2, 0x8F, 0x75, 0xA7, 0x31, 0x91, 0xCE, 0x9E, 0x75, 0xBD, 0x27, 0x26, 0xB4, 0xB4, 0x0C, 0x32};
|
||||
static const u8 keys630_k1[] = {0x36, 0xB0, 0xDC, 0xFC, 0x59, 0x2A, 0x95, 0x1D, 0x80, 0x2D, 0x80, 0x3F, 0xCD, 0x30, 0xA0, 0x1B};
|
||||
static const u8 keys630_k2[] = {0xd4, 0x35, 0x18, 0x02, 0x29, 0x68, 0xfb, 0xa0, 0x6a, 0xa9, 0xa5, 0xed, 0x78, 0xfd, 0x2e, 0x9d};
|
||||
static const u8 keys630_k3[] = {0x23, 0x8D, 0x3D, 0xAE, 0x41, 0x50, 0xA0, 0xFA, 0xF3, 0x2F, 0x32, 0xCE, 0xC7, 0x27, 0xCD, 0x50};
|
||||
static const u8 keys630_k4[] = {0xAA, 0xA1, 0xB5, 0x7C, 0x93, 0x5A, 0x95, 0xBD, 0xEF, 0x69, 0x16, 0xFC, 0x2B, 0x92, 0x31, 0xDD};
|
||||
static const u8 keys630_k5[] = {0x87, 0x37, 0x21, 0xCC, 0x65, 0xAE, 0xAA, 0x5F, 0x40, 0xF6, 0x6F, 0x2A, 0x86, 0xC7, 0xA1, 0xC8};
|
||||
static const u8 keys630_k6[] = {0x8D, 0xDB, 0xDC, 0x5C, 0xF2, 0x70, 0x2B, 0x40, 0xB2, 0x3D, 0x00, 0x09, 0x61, 0x7C, 0x10, 0x60};
|
||||
static const u8 keys630_k7[] = {0x77, 0x1C, 0x06, 0x5F, 0x53, 0xEC, 0x3F, 0xFC, 0x22, 0xCE, 0x5A, 0x27, 0xFF, 0x78, 0xA8, 0x48};
|
||||
static const u8 keys630_k8[] = {0x81, 0xD1, 0x12, 0x89, 0x35, 0xC8, 0xEA, 0x8B, 0xE0, 0x02, 0x2D, 0x2D, 0x6A, 0x18, 0x67, 0xB8};
|
||||
static const u8 keys636_k1[] = {0x07, 0xE3, 0x08, 0x64, 0x7F, 0x60, 0xA3, 0x36, 0x6A, 0x76, 0x21, 0x44, 0xC9, 0xD7, 0x06, 0x83};
|
||||
static const u8 keys636_k2[] = {0x91, 0xF2, 0x02, 0x9E, 0x63, 0x32, 0x30, 0xA9, 0x1D, 0xDA, 0x0B, 0xA8, 0xB7, 0x41, 0xA3, 0xCC};
|
||||
static const u8 keys638_k4[] = {0x98, 0x43, 0xFF, 0x85, 0x68, 0xB2, 0xDB, 0x3B, 0xD4, 0x22, 0xD0, 0x4F, 0xAB, 0x5F, 0x0A, 0x31};
|
||||
static const u8 keys639_k3[] = {0x01, 0x7B, 0xF0, 0xE9, 0xBE, 0x9A, 0xDD, 0x54, 0x37, 0xEA, 0x0E, 0xC4, 0xD6, 0x4D, 0x8E, 0x9E};
|
||||
static const u8 keys660_k1[] = {0x76, 0xF2, 0x6C, 0x0A, 0xCA, 0x3A, 0xBA, 0x4E, 0xAC, 0x76, 0xD2, 0x40, 0xF5, 0xC3, 0xBF, 0xF9};
|
||||
static const u8 keys660_k2[] = {0x7A, 0x3E, 0x55, 0x75, 0xB9, 0x6A, 0xFC, 0x4F, 0x3E, 0xE3, 0xDF, 0xB3, 0x6C, 0xE8, 0x2A, 0x82};
|
||||
static const u8 keys660_k3[] = {0xFA, 0x79, 0x09, 0x36, 0xE6, 0x19, 0xE8, 0xA4, 0xA9, 0x41, 0x37, 0x18, 0x81, 0x02, 0xE9, 0xB3};
|
||||
static const u8 keys660_v1[] = {0xBA, 0x76, 0x61, 0x47, 0x8B, 0x55, 0xA8, 0x72, 0x89, 0x15, 0x79, 0x6D, 0xD7, 0x2F, 0x78, 0x0E};
|
||||
static const u8 keys660_v2[] = {0xF9, 0x4A, 0x6B, 0x96, 0x79, 0x3F, 0xEE, 0x0A, 0x04, 0xC8, 0x8D, 0x7E, 0x5F, 0x38, 0x3A, 0xCF};
|
||||
static const u8 keys660_v3[] = {0x88, 0xAF, 0x18, 0xE9, 0xC3, 0xAA, 0x6B, 0x56, 0xF7, 0xC5, 0xA8, 0xBF, 0x1A, 0x84, 0xE9, 0xF3};
|
||||
static const u8 keys660_v4[] = {0xD1, 0xB0, 0xAE, 0xC3, 0x24, 0x36, 0x13, 0x49, 0xD6, 0x49, 0xD7, 0x88, 0xEA, 0xA4, 0x99, 0x86};
|
||||
static const u8 keys660_v5[] = {0xCB, 0x93, 0x12, 0x38, 0x31, 0xC0, 0x2D, 0x2E, 0x7A, 0x18, 0x5C, 0xAC, 0x92, 0x93, 0xAB, 0x32};
|
||||
static const u8 keys660_v6[] = {0x92, 0x8C, 0xA4, 0x12, 0xD6, 0x5C, 0x55, 0x31, 0x5B, 0x94, 0x23, 0x9B, 0x62, 0xB3, 0xDB, 0x47};
|
||||
static const u8 keys660_k4[] = {0xC8, 0xA0, 0x70, 0x98, 0xAE, 0xE6, 0x2B, 0x80, 0xD7, 0x91, 0xE6, 0xCA, 0x4C, 0xA9, 0x78, 0x4E};
|
||||
static const u8 keys660_k5[] = {0xBF, 0xF8, 0x34, 0x02, 0x84, 0x47, 0xBD, 0x87, 0x1C, 0x52, 0x03, 0x23, 0x79, 0xBB, 0x59, 0x81};
|
||||
static const u8 keys660_k6[] = {0xD2, 0x83, 0xCC, 0x63, 0xBB, 0x10, 0x15, 0xE7, 0x7B, 0xC0, 0x6D, 0xEE, 0x34, 0x9E, 0x4A, 0xFA};
|
||||
static const u8 keys660_k7[] = {0xEB, 0xD9, 0x1E, 0x05, 0x3C, 0xAE, 0xAB, 0x62, 0xE3, 0xB7, 0x1F, 0x37, 0xE5, 0xCD, 0x68, 0xC3};
|
||||
static const u8 keys660_v7[] = {0xC5, 0x9C, 0x77, 0x9C, 0x41, 0x01, 0xE4, 0x85, 0x79, 0xC8, 0x71, 0x63, 0xA5, 0x7D, 0x4F, 0xFB};
|
||||
static const u8 keys660_v8[] = {0x86, 0xA0, 0x7D, 0x4D, 0xB3, 0x6B, 0xA2, 0xFD, 0xF4, 0x15, 0x85, 0x70, 0x2D, 0x6A, 0x0D, 0x3A};
|
||||
static const u8 keys660_k8[] = {0x85, 0x93, 0x1F, 0xED, 0x2C, 0x4D, 0xA4, 0x53, 0x59, 0x9C, 0x3F, 0x16, 0xF3, 0x50, 0xDE, 0x46};
|
||||
static const u8 key_21C0[] = {0x6A, 0x19, 0x71, 0xF3, 0x18, 0xDE, 0xD3, 0xA2, 0x6D, 0x3B, 0xDE, 0xC7, 0xBE, 0x98, 0xE2, 0x4C};
|
||||
static const u8 key_2250[] = {0x50, 0xCC, 0x03, 0xAC, 0x3F, 0x53, 0x1A, 0xFA, 0x0A, 0xA4, 0x34, 0x23, 0x86, 0x61, 0x7F, 0x97};
|
||||
static const u8 key_22E0[] = {0x66, 0x0F, 0xCB, 0x3B, 0x30, 0x75, 0xE3, 0x10, 0x0A, 0x95, 0x65, 0xC7, 0x3C, 0x93, 0x87, 0x22};
|
||||
static const u8 key_2D80[] = {0x40, 0x02, 0xC0, 0xBF, 0x20, 0x02, 0xC0, 0xBF, 0x5C, 0x68, 0x2B, 0x95, 0x5F, 0x40, 0x7B, 0xB8};
|
||||
static const u8 key_2D90[] = {0x55, 0x19, 0x35, 0x10, 0x48, 0xD8, 0x2E, 0x46, 0xA8, 0xB1, 0x47, 0x77, 0xDC, 0x49, 0x6A, 0x6F};
|
||||
static const u8 key_2DA8[] = {0x80, 0x02, 0xC0, 0xBF, 0x00, 0x0A, 0xC0, 0xBF, 0x40, 0x03, 0xC0, 0xBF, 0x40, 0x00, 0x00, 0x00};
|
||||
static const u8 key_2DB8[] = {0x4C, 0x2D, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xB8, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
static const u8 key_D91605F0[] = {0xB8, 0x8C, 0x45, 0x8B, 0xB6, 0xE7, 0x6E, 0xB8, 0x51, 0x59, 0xA6, 0x53, 0x7C, 0x5E, 0x86, 0x31};
|
||||
static const u8 key_D91606F0[] = {0xED, 0x10, 0xE0, 0x36, 0xC4, 0xFE, 0x83, 0xF3, 0x75, 0x70, 0x5E, 0xF6, 0xA4, 0x40, 0x05, 0xF7};
|
||||
static const u8 key_D91608F0[] = {0x5C, 0x77, 0x0C, 0xBB, 0xB4, 0xC2, 0x4F, 0xA2, 0x7E, 0x3B, 0x4E, 0xB4, 0xB4, 0xC8, 0x70, 0xAF};
|
||||
static const u8 key_D91609F0[] = {0xD0, 0x36, 0x12, 0x75, 0x80, 0x56, 0x20, 0x43, 0xC4, 0x30, 0x94, 0x3E, 0x1C, 0x75, 0xD1, 0xBF};
|
||||
static const u8 key_D9160AF0[] = {0x10, 0xA9, 0xAC, 0x16, 0xAE, 0x19, 0xC0, 0x7E, 0x3B, 0x60, 0x77, 0x86, 0x01, 0x6F, 0xF2, 0x63};
|
||||
static const u8 key_D9160BF0[] = {0x83, 0x83, 0xF1, 0x37, 0x53, 0xD0, 0xBE, 0xFC, 0x8D, 0xA7, 0x32, 0x52, 0x46, 0x0A, 0xC2, 0xC2};
|
||||
static const u8 key_D91611F0[] = {0x61, 0xB0, 0xC0, 0x58, 0x71, 0x57, 0xD9, 0xFA, 0x74, 0x67, 0x0E, 0x5C, 0x7E, 0x6E, 0x95, 0xB9};
|
||||
static const u8 key_D91612F0[] = {0x9E, 0x20, 0xE1, 0xCD, 0xD7, 0x88, 0xDE, 0xC0, 0x31, 0x9B, 0x10, 0xAF, 0xC5, 0xB8, 0x73, 0x23};
|
||||
static const u8 key_D91613F0[] = {0xEB, 0xFF, 0x40, 0xD8, 0xB4, 0x1A, 0xE1, 0x66, 0x91, 0x3B, 0x8F, 0x64, 0xB6, 0xFC, 0xB7, 0x12};
|
||||
static const u8 key_D91614F0[] = {0xFD, 0xF7, 0xB7, 0x3C, 0x9F, 0xD1, 0x33, 0x95, 0x11, 0xB8, 0xB5, 0xBB, 0x54, 0x23, 0x73, 0x85};
|
||||
static const u8 key_D91615F0[] = {0xC8, 0x03, 0xE3, 0x44, 0x50, 0xF1, 0xE7, 0x2A, 0x6A, 0x0D, 0xC3, 0x61, 0xB6, 0x8E, 0x5F, 0x51};
|
||||
static const u8 key_D91616F0[] = {0x53, 0x03, 0xB8, 0x6A, 0x10, 0x19, 0x98, 0x49, 0x1C, 0xAF, 0x30, 0xE4, 0x25, 0x1B, 0x6B, 0x28};
|
||||
static const u8 key_D91617F0[] = {0x02, 0xFA, 0x48, 0x73, 0x75, 0xAF, 0xAE, 0x0A, 0x67, 0x89, 0x2B, 0x95, 0x4B, 0x09, 0x87, 0xA3};
|
||||
static const u8 key_D91618F0[] = {0x96, 0x96, 0x7C, 0xC3, 0xF7, 0x12, 0xDA, 0x62, 0x1B, 0xF6, 0x9A, 0x9A, 0x44, 0x44, 0xBC, 0x48};
|
||||
static const u8 key_D91619F0[] = {0xE0, 0x32, 0xA7, 0x08, 0x6B, 0x2B, 0x29, 0x2C, 0xD1, 0x4D, 0x5B, 0xEE, 0xA8, 0xC8, 0xB4, 0xE9};
|
||||
static const u8 key_D9161AF0[] = {0x27, 0xE5, 0xA7, 0x49, 0x52, 0xE1, 0x94, 0x67, 0x35, 0x66, 0x91, 0x0C, 0xE8, 0x9A, 0x25, 0x24};
|
||||
static const u8 key_D91620F0[] = {0x52, 0x1C, 0xB4, 0x5F, 0x40, 0x3B, 0x9A, 0xDD, 0xAC, 0xFC, 0xEA, 0x92, 0xFD, 0xDD, 0xF5, 0x90};
|
||||
static const u8 key_D91621F0[] = {0xD1, 0x91, 0x2E, 0xA6, 0x21, 0x14, 0x29, 0x62, 0xF6, 0xED, 0xAE, 0xCB, 0xDD, 0xA3, 0xBA, 0xFE};
|
||||
static const u8 key_D91622F0[] = {0x59, 0x5D, 0x78, 0x4D, 0x21, 0xB2, 0x01, 0x17, 0x6C, 0x9A, 0xB5, 0x1B, 0xDA, 0xB7, 0xF9, 0xE6};
|
||||
static const u8 key_D91623F0[] = {0xAA, 0x45, 0xEB, 0x4F, 0x62, 0xFB, 0xD1, 0x0D, 0x71, 0xD5, 0x62, 0xD2, 0xF5, 0xBF, 0xA5, 0x2F};
|
||||
static const u8 key_D91624F0[] = {0x61, 0xB7, 0x26, 0xAF, 0x8B, 0xF1, 0x41, 0x58, 0x83, 0x6A, 0xC4, 0x92, 0x12, 0xCB, 0xB1, 0xE9};
|
||||
static const u8 key_D91628F0[] = {0x49, 0xA4, 0xFC, 0x66, 0xDC, 0xE7, 0x62, 0x21, 0xDB, 0x18, 0xA7, 0x50, 0xD6, 0xA8, 0xC1, 0xB6};
|
||||
static const u8 key_D91680F0[] = {0x2C, 0x22, 0x9B, 0x12, 0x36, 0x74, 0x11, 0x67, 0x49, 0xD1, 0xD1, 0x88, 0x92, 0xF6, 0xA1, 0xD8};
|
||||
static const u8 key_D91681F0[] = {0x52, 0xB6, 0x36, 0x6C, 0x8C, 0x46, 0x7F, 0x7A, 0xCC, 0x11, 0x62, 0x99, 0xC1, 0x99, 0xBE, 0x98};
|
||||
static const u8 key_2E5E10F0[] = {0x9D, 0x5C, 0x5B, 0xAF, 0x8C, 0xD8, 0x69, 0x7E, 0x51, 0x9F, 0x70, 0x96, 0xE6, 0xD5, 0xC4, 0xE8};
|
||||
static const u8 key_2E5E12F0[] = {0x8A, 0x7B, 0xC9, 0xD6, 0x52, 0x58, 0x88, 0xEA, 0x51, 0x83, 0x60, 0xCA, 0x16, 0x79, 0xE2, 0x07};
|
||||
static const u8 key_2E5E13F0[] = {0xFF, 0xA4, 0x68, 0xC3, 0x31, 0xCA, 0xB7, 0x4C, 0xF1, 0x23, 0xFF, 0x01, 0x65, 0x3D, 0x26, 0x36};
|
||||
static const u8 key_2FD30BF0[] = {0xD8, 0x58, 0x79, 0xF9, 0xA4, 0x22, 0xAF, 0x86, 0x90, 0xAC, 0xDA, 0x45, 0xCE, 0x60, 0x40, 0x3F};
|
||||
static const u8 key_2FD311F0[] = {0x3A, 0x6B, 0x48, 0x96, 0x86, 0xA5, 0xC8, 0x80, 0x69, 0x6C, 0xE6, 0x4B, 0xF6, 0x04, 0x17, 0x44};
|
||||
static const u8 key_2FD312F0[] = {0xC5, 0xFB, 0x69, 0x03, 0x20, 0x7A, 0xCF, 0xBA, 0x2C, 0x90, 0xF8, 0xB8, 0x4D, 0xD2, 0xF1, 0xDE};
|
||||
static const u8 keys02G_E[] = {0x9D, 0x09, 0xFD, 0x20, 0xF3, 0x8F, 0x10, 0x69, 0x0D, 0xB2, 0x6F, 0x00, 0xCC, 0xC5, 0x51, 0x2E};
|
||||
static const u8 keys03G_E[] = {0x4F, 0x44, 0x5C, 0x62, 0xB3, 0x53, 0xC4, 0x30, 0xFC, 0x3A, 0xA4, 0x5B, 0xEC, 0xFE, 0x51, 0xEA};
|
||||
static const u8 keys05G_E[] = {0x5D, 0xAA, 0x72, 0xF2, 0x26, 0x60, 0x4D, 0x1C, 0xE7, 0x2D, 0xC8, 0xA3, 0x2F, 0x79, 0xC5, 0x54};
|
||||
static const u8 oneseg_310[] = {0xC7, 0x27, 0x72, 0x85, 0xAB, 0xA7, 0xF7, 0xF0, 0x4C, 0xC1, 0x86, 0xCC, 0xE3, 0x7F, 0x17, 0xCA};
|
||||
static const u8 oneseg_300[] = {0x76, 0x40, 0x9E, 0x08, 0xDB, 0x9B, 0x3B, 0xA1, 0x47, 0x8A, 0x96, 0x8E, 0xF3, 0xF7, 0x62, 0x92};
|
||||
static const u8 oneseg_280[] = {0x23, 0xDC, 0x3B, 0xB5, 0xA9, 0x82, 0xD6, 0xEA, 0x63, 0xA3, 0x6E, 0x2B, 0x2B, 0xE9, 0xE1, 0x54};
|
||||
static const u8 oneseg_260_271[] = {0x22, 0x43, 0x57, 0x68, 0x2F, 0x41, 0xCE, 0x65, 0x4C, 0xA3, 0x7C, 0xC6, 0xC4, 0xAC, 0xF3, 0x60};
|
||||
static const u8 oneseg_slim[] = {0x12, 0x57, 0x0D, 0x8A, 0x16, 0x6D, 0x87, 0x06, 0x03, 0x7D, 0xC8, 0x8B, 0x62, 0xA3, 0x32, 0xA9};
|
||||
static const u8 ms_app_main[] = {0x1E, 0x2E, 0x38, 0x49, 0xDA, 0xD4, 0x16, 0x08, 0x27, 0x2E, 0xF3, 0xBC, 0x37, 0x75, 0x80, 0x93};
|
||||
static const u8 demokeys_280[] = {0x12, 0x99, 0x70, 0x5E, 0x24, 0x07, 0x6C, 0xD0, 0x2D, 0x06, 0xFE, 0x7E, 0xB3, 0x0C, 0x11, 0x26};
|
||||
static const u8 demokeys_3XX_1[] = {0x47, 0x05, 0xD5, 0xE3, 0x56, 0x1E, 0x81, 0x9B, 0x09, 0x2F, 0x06, 0xDB, 0x6B, 0x12, 0x92, 0xE0};
|
||||
static const u8 demokeys_3XX_2[] = {0xF6, 0x62, 0x39, 0x6E, 0x26, 0x22, 0x4D, 0xCA, 0x02, 0x64, 0x16, 0x99, 0x7B, 0x9A, 0xE7, 0xB8};
|
||||
static const u8 ebootbin_271_new[] = {0xF4, 0xAE, 0xF4, 0xE1, 0x86, 0xDD, 0xD2, 0x9C, 0x7C, 0xC5, 0x42, 0xA6, 0x95, 0xA0, 0x83, 0x88};
|
||||
static const u8 ebootbin_280_new[] = {0xB8, 0x8C, 0x45, 0x8B, 0xB6, 0xE7, 0x6E, 0xB8, 0x51, 0x59, 0xA6, 0x53, 0x7C, 0x5E, 0x86, 0x31};
|
||||
static const u8 ebootbin_300_new[] = {0xED, 0x10, 0xE0, 0x36, 0xC4, 0xFE, 0x83, 0xF3, 0x75, 0x70, 0x5E, 0xF6, 0xA4, 0x40, 0x05, 0xF7};
|
||||
static const u8 ebootbin_310_new[] = {0x5C, 0x77, 0x0C, 0xBB, 0xB4, 0xC2, 0x4F, 0xA2, 0x7E, 0x3B, 0x4E, 0xB4, 0xB4, 0xC8, 0x70, 0xAF};
|
||||
static const u8 gameshare_260_271[] = {0xF9, 0x48, 0x38, 0x0C, 0x96, 0x88, 0xA7, 0x74, 0x4F, 0x65, 0xA0, 0x54, 0xC2, 0x76, 0xD9, 0xB8};
|
||||
static const u8 gameshare_280[] = {0x2D, 0x86, 0x77, 0x3A, 0x56, 0xA4, 0x4F, 0xDD, 0x3C, 0x16, 0x71, 0x93, 0xAA, 0x8E, 0x11, 0x43};
|
||||
static const u8 gameshare_300[] = {0x78, 0x1A, 0xD2, 0x87, 0x24, 0xBD, 0xA2, 0x96, 0x18, 0x3F, 0x89, 0x36, 0x72, 0x90, 0x92, 0x85};
|
||||
static const u8 gameshare_310[] = {0xC9, 0x7D, 0x3E, 0x0A, 0x54, 0x81, 0x6E, 0xC7, 0x13, 0x74, 0x99, 0x74, 0x62, 0x18, 0xE7, 0xDD};
|
||||
static const u8 key_380210F0[] = {0x32, 0x2C, 0xFA, 0x75, 0xE4, 0x7E, 0x93, 0xEB, 0x9F, 0x22, 0x80, 0x85, 0x57, 0x08, 0x98, 0x48};
|
||||
static const u8 key_380280F0[] = {0x97, 0x09, 0x12, 0xD3, 0xDB, 0x02, 0xBD, 0xD8, 0xE7, 0x74, 0x51, 0xFE, 0xF0, 0xEA, 0x6C, 0x5C};
|
||||
static const u8 key_380283F0[] = {0x34, 0x20, 0x0C, 0x8E, 0xA1, 0x86, 0x79, 0x84, 0xAF, 0x13, 0xAE, 0x34, 0x77, 0x6F, 0xEA, 0x89};
|
||||
static const u8 key_407810F0[] = {0xAF, 0xAD, 0xCA, 0xF1, 0x95, 0x59, 0x91, 0xEC, 0x1B, 0x27, 0xD0, 0x4E, 0x8A, 0xF3, 0x3D, 0xE7};
|
||||
static const u8 drmkeys_6XX_1[] = {0x36, 0xEF, 0x82, 0x4E, 0x74, 0xFB, 0x17, 0x5B, 0x14, 0x14, 0x05, 0xF3, 0xB3, 0x8A, 0x76, 0x18};
|
||||
static const u8 drmkeys_6XX_2[] = {0x21, 0x52, 0x5D, 0x76, 0xF6, 0x81, 0x0F, 0x15, 0x2F, 0x4A, 0x40, 0x89, 0x63, 0xA0, 0x10, 0x55};
|
||||
|
||||
// PRXDecrypter 144-byte tag keys.
|
||||
u32 g_key0[] = {
|
||||
static const u32 g_key0[] = {
|
||||
0x7b21f3be, 0x299c5e1d, 0x1c9c5e71, 0x96cb4645, 0x3c9b1be0, 0xeb85de3d,
|
||||
0x4a7f2022, 0xc2206eaa, 0xd50b3265, 0x55770567, 0x3c080840, 0x981d55f2,
|
||||
0x5fd8f6f3, 0xee8eb0c5, 0x944d8152, 0xf8278651, 0x2705bafa, 0x8420e533,
|
||||
0x27154ae9, 0x4819aa32, 0x59a3aa40, 0x2cb3cf65, 0xf274466d, 0x3a655605,
|
||||
0x21b0f88f, 0xc5b18d26, 0x64c19051, 0xd669c94e, 0xe87035f2, 0x9d3a5909,
|
||||
0x6f4e7102, 0xdca946ce, 0x8416881b, 0xbab097a5, 0x249125c6, 0xb34c0872};
|
||||
u32 g_key2[] = {
|
||||
static const u32 g_key2[] = {
|
||||
0xccfda932, 0x51c06f76, 0x046dcccf, 0x49e1821e, 0x7d3b024c, 0x9dda5865,
|
||||
0xcc8c9825, 0xd1e97db5, 0x6874d8cb, 0x3471c987, 0x72edb3fc, 0x81c8365d,
|
||||
0xe161e33a, 0xfc92db59, 0x2009b1ec, 0xb1a94ce4, 0x2f03696b, 0x87e236d8,
|
||||
0x3b2b8ce9, 0x0305e784, 0xf9710883, 0xb039db39, 0x893bea37, 0xe74d6805,
|
||||
0x2a5c38bd, 0xb08dc813, 0x15b32375, 0x46be4525, 0x0103fd90, 0xa90e87a2,
|
||||
0x52aba66a, 0x85bf7b80, 0x45e8ce63, 0x4dd716d3, 0xf5e30d2d, 0xaf3ae456};
|
||||
u32 g_key3[] = {
|
||||
static const u32 g_key3[] = {
|
||||
0xa6c8f5ca, 0x6d67c080, 0x924f4d3a, 0x047ca06a, 0x08640297, 0x4fd4a758,
|
||||
0xbd685a87, 0x9b2701c2, 0x83b62a35, 0x726b533c, 0xe522fa0c, 0xc24b06b4,
|
||||
0x459d1cac, 0xa8c5417b, 0x4fea62a2, 0x0615d742, 0x30628d09, 0xc44fab14,
|
||||
0x69ff715e, 0xd2d8837d, 0xbeed0b8b, 0x1e6e57ae, 0x61e8c402, 0xbe367a06,
|
||||
0x543f2b5e, 0xdb3ec058, 0xbe852075, 0x1e7e4dcc, 0x1564ea55, 0xec7825b4,
|
||||
0xc0538cad, 0x70f72c7f, 0x49e8c3d0, 0xeda97ec5, 0xf492b0a4, 0xe05eb02a};
|
||||
u32 g_key44[] = {
|
||||
static const u32 g_key44[] = {
|
||||
0xef80e005, 0x3a54689f, 0x43c99ccd, 0x1b7727be, 0x5cb80038, 0xdd2efe62,
|
||||
0xf369f92c, 0x160f94c5, 0x29560019, 0xbf3c10c5, 0xf2ce5566, 0xcea2c626,
|
||||
0xb601816f, 0x64e7481e, 0x0c34debd, 0x98f29cb0, 0x3fc504d7, 0xc8fb39f0,
|
||||
0x0221b3d8, 0x63f936a2, 0x9a3a4800, 0x6ecc32e3, 0x8e120cfd, 0xb0361623,
|
||||
0xaee1e689, 0x745502eb, 0xe4a6c61c, 0x74f23eb4, 0xd7fa5813, 0xb01916eb,
|
||||
0x12328457, 0xd2bc97d2, 0x646425d8, 0x328380a5, 0x43da8ab1, 0x4b122ac9};
|
||||
u32 g_key20[] = {
|
||||
static const u32 g_key20[] = {
|
||||
0x33b50800, 0xf32f5fcd, 0x3c14881f, 0x6e8a2a95, 0x29feefd5, 0x1394eae3,
|
||||
0xbd6bd443, 0x0821c083, 0xfab379d3, 0xe613e165, 0xf5a754d3, 0x108b2952,
|
||||
0x0a4b1e15, 0x61eadeba, 0x557565df, 0x3b465301, 0xae54ecc3, 0x61423309,
|
||||
0x70c9ff19, 0x5b0ae5ec, 0x989df126, 0x9d987a5f, 0x55bc750e, 0xc66eba27,
|
||||
0x2de988e8, 0xf76600da, 0x0382dccb, 0x5569f5f2, 0x8e431262, 0x288fe3d3,
|
||||
0x656f2187, 0x37d12e9c, 0x2f539eb4, 0xa492998e, 0xed3958f7, 0x39e96523};
|
||||
u32 g_key3A[] = {
|
||||
static const u32 g_key3A[] = {
|
||||
0x67877069, 0x3abd5617, 0xc23ab1dc, 0xab57507d, 0x066a7f40, 0x24def9b9,
|
||||
0x06f759e4, 0xdcf524b1, 0x13793e5e, 0x0359022d, 0xaae7e1a2, 0x76b9b2fa,
|
||||
0x9a160340, 0x87822fba, 0x19e28fbb, 0x9e338a02, 0xd8007e9a, 0xea317af1,
|
||||
0x630671de, 0x0b67ca7c, 0x865192af, 0xea3c3526, 0x2b448c8e, 0x8b599254,
|
||||
0x4602e9cb, 0x4de16cda, 0xe164d5bb, 0x07ecd88e, 0x99ffe5f8, 0x768800c1,
|
||||
0x53b091ed, 0x84047434, 0xb426dbbc, 0x36f948bb, 0x46142158, 0x749bb492};
|
||||
u32 g_keyEBOOT1xx[] = {
|
||||
static const u32 g_keyEBOOT1xx[] = {
|
||||
0x18CB69EF, 0x158E8912, 0xDEF90EBB, 0x4CB0FB23, 0x3687EE18, 0x868D4A6E,
|
||||
0x19B5C756, 0xEE16551D, 0xE7CB2D6C, 0x9747C660, 0xCE95143F, 0x2956F477,
|
||||
0x03824ADE, 0x210C9DF1, 0x5029EB24, 0x81DFE69F, 0x39C89B00, 0xB00C8B91,
|
||||
0xEF2DF9C2, 0xE13A93FC, 0x8B94A4A8, 0x491DD09D, 0x686A400D, 0xCED4C7E4,
|
||||
0x96C8B7C9, 0x1EAADC28, 0xA4170B84, 0x505D5DDC, 0x5DA6C3CF, 0x0E5DFA2D,
|
||||
0x6E7919B5, 0xCE5E29C7, 0xAAACDB94, 0x45F70CDD, 0x62A73725, 0xCCE6563D};
|
||||
u32 g_keyEBOOT2xx[] = {
|
||||
static const u32 g_keyEBOOT2xx[] = {
|
||||
0xDA8E36FA, 0x5DD97447, 0x76C19874, 0x97E57EAF, 0x1CAB09BD, 0x9835BAC6,
|
||||
0x03D39281, 0x03B205CF, 0x2882E734, 0xE714F663, 0xB96E2775, 0xBD8AAFC7,
|
||||
0x1DD3EC29, 0xECA4A16C, 0x5F69EC87, 0x85981E92, 0x7CFCAE21, 0xBAE9DD16,
|
||||
0xE6A97804, 0x2EEE02FC, 0x61DF8A3D, 0xDD310564, 0x9697E149, 0xC2453F3B,
|
||||
0xF91D8456, 0x39DA6BC8, 0xB3E5FEF5, 0x89C593A3, 0xFB5C8ABC, 0x6C0B7212,
|
||||
0xE10DD3CB, 0x98D0B2A8, 0x5FD61847, 0xF0DC2357, 0x7701166A, 0x0F5C3B68};
|
||||
u32 g_keyUPDATER[] = {
|
||||
static const u32 g_keyUPDATER[] = {
|
||||
0xA5603CBF, 0xD7482441, 0xF65764CC, 0x1F90060B, 0x4EA73E45, 0xE551D192,
|
||||
0xE7B75D8A, 0x465A506E, 0x40FB1022, 0x2C273350, 0x8096DA44, 0x9947198E,
|
||||
0x278DEE77, 0x745D062E, 0xC148FA45, 0x832582AF, 0x5FDB86DA, 0xCB15C4CE,
|
||||
0x2524C62F, 0x6C2EC3B1, 0x369BE39E, 0xF7EB1FC4, 0x1E51CE1A, 0xD70536F4,
|
||||
0xC34D39D8, 0x7418FB13, 0xE3C84DE1, 0xB118F03C, 0xA2018D4E, 0xE6D8770D,
|
||||
0x5720F390, 0x17F96341, 0x60A4A68F, 0x1327DD28, 0x05944C64, 0x0C2C4C12};
|
||||
u32 g_keyMEIMG250[] = {
|
||||
static const u32 g_keyMEIMG250[] = {
|
||||
0xA381FEBC, 0x99B9D5C9, 0x6C560A8D, 0x30309F95, 0x792646CC, 0x82B64E5E,
|
||||
0x1A3951AD, 0x0A182EC4, 0xC46131B4, 0x77C50C8A, 0x325F16C6, 0x02D1942E,
|
||||
0x0AA38AC4, 0x2A940AC6, 0x67034726, 0xE52DB133, 0xD2EF2107, 0x85C81E90,
|
||||
0xC8D164BA, 0xC38DCE1D, 0x948BA275, 0x0DB84603, 0xE2473637, 0xCD74FCDA,
|
||||
0x588E3D66, 0x6D28E822, 0x891E548B, 0xF53CF56D, 0x0BBDDB66, 0xC4B286AA,
|
||||
0x2BEBBC4B, 0xFC261FF4, 0x92B8E705, 0xDCEE6952, 0x5E0442E5, 0x8BEB7F21};
|
||||
u32 g_keyMEIMG260[] = {
|
||||
static const u32 g_keyMEIMG260[] = {
|
||||
0x11BFD698, 0xD7F9B324, 0xDD524927, 0x16215B86, 0x504AC36D, 0x5843B217,
|
||||
0xE5A0DA47, 0xBB73A1E7, 0x2915DB35, 0x375CFD3A, 0xBB70A905, 0x272BEFCA,
|
||||
0x2E960791, 0xEA0799BB, 0xB85AE6C8, 0xC9CAF773, 0x250EE641, 0x06E74A9E,
|
||||
0x5244895D, 0x466755A5, 0x9A84AF53, 0xE1024174, 0xEEBA031E, 0xED80B9CE,
|
||||
0xBC315F72, 0x5821067F, 0xE8313058, 0xD2D0E706, 0xE6D8933E, 0xD7D17FB4,
|
||||
0x505096C4, 0xFDA50B3B, 0x4635AE3D, 0xEB489C8A, 0x422D762D, 0x5A8B3231};
|
||||
u32 g_keyDEMOS27X[] = {
|
||||
static const u32 g_keyDEMOS27X[] = {
|
||||
0x1ABF102F, 0xD596D071, 0x6FC552B2, 0xD4F2531F, 0xF025CDD9, 0xAF9AAF03,
|
||||
0xE0CF57CF, 0x255494C4, 0x7003675E, 0x907BC884, 0x002D4EE4, 0x0B687A0D,
|
||||
0x9E3AA44F, 0xF58FDA81, 0xEC26AC8C, 0x3AC9B49D, 0x3471C037, 0xB0F3834D,
|
||||
0x10DC4411, 0xA232EA31, 0xE2E5FA6B, 0x45594B03, 0xE43A1C87, 0x31DAD9D1,
|
||||
0x08CD7003, 0xFA9C2FDF, 0x5A891D25, 0x9B5C1934, 0x22F366E5, 0x5F084A32,
|
||||
0x695516D5, 0x2245BE9F, 0x4F6DD705, 0xC4B8B8A1, 0xBC13A600, 0x77B7FC3B};
|
||||
u32 g_keyUNK1[] = {
|
||||
static const u32 g_keyUNK1[] = {
|
||||
0x33B50800, 0xF32F5FCD, 0x3C14881F, 0x6E8A2A95, 0x29FEEFD5, 0x1394EAE3,
|
||||
0xBD6BD443, 0x0821C083, 0xFAB379D3, 0xE613E165, 0xF5A754D3, 0x108B2952,
|
||||
0x0A4B1E15, 0x61EADEBA, 0x557565DF, 0x3B465301, 0xAE54ECC3, 0x61423309,
|
||||
0x70C9FF19, 0x5B0AE5EC, 0x989DF126, 0x9D987A5F, 0x55BC750E, 0xC66EBA27,
|
||||
0x2DE988E8, 0xF76600DA, 0x0382DCCB, 0x5569F5F2, 0x8E431262, 0x288FE3D3,
|
||||
0x656F2187, 0x37D12E9C, 0x2F539EB4, 0xA492998E, 0xED3958F7, 0x39E96523};
|
||||
u32 g_key_GAMESHARE1xx[] = {
|
||||
static const u32 g_key_GAMESHARE1xx[] = {
|
||||
0x721B53E8, 0xFC3E31C6, 0xF85BA2A2, 0x3CF0AC72, 0x54EEA7AB, 0x5959BFCB,
|
||||
0x54B8836B, 0xBC431313, 0x989EF2CF, 0xF0CE36B2, 0x98BA4CF8, 0xE971C931,
|
||||
0xA0375DC8, 0x08E52FA0, 0xAC0DD426, 0x57E4D601, 0xC56E61C7, 0xEF1AB98A,
|
||||
0xD1D9F8F4, 0x5FE9A708, 0x3EF09D07, 0xFA0C1A8C, 0xA91EEA5C, 0x58F482C5,
|
||||
0x2C800302, 0x7EE6F6C3, 0xFF6ABBBB, 0x2110D0D0, 0xD3297A88, 0x980012D3,
|
||||
0xDC59C87B, 0x7FDC5792, 0xDB3F5DA6, 0xFC23B787, 0x22698ED3, 0xB680E812};
|
||||
u32 g_key_GAMESHARE2xx[] = {
|
||||
static const u32 g_key_GAMESHARE2xx[] = {
|
||||
0x94A757C7, 0x9FD39833, 0xF8508371, 0x328B0B29, 0x2CBCB9DA, 0x2918B9C6,
|
||||
0x944C50BA, 0xF1DCE7D0, 0x640C3966, 0xC90B3D08, 0xF4AD17BA, 0x6CA0F84B,
|
||||
0xF7767C67, 0xA4D3A55A, 0x4A085C6A, 0x6BB27071, 0xFA8B38FB, 0x3FDB31B8,
|
||||
0x8B7196F2, 0xDB9BED4A, 0x51625B84, 0x4C1481B4, 0xF684F508, 0x30B44770,
|
||||
0x93AA8E74, 0x90C579BC, 0x246EC88D, 0x2E051202, 0xC774842E, 0xA185D997,
|
||||
0x7A2B3ADD, 0xFE835B6D, 0x508F184D, 0xEB4C4F13, 0x0E1993D3, 0xBA96DFD2};
|
||||
u32 g_key_INDEXDAT1xx[] = {
|
||||
static const u32 g_key_INDEXDAT1xx[] = {
|
||||
0x76CB00AF, 0x111CE62F, 0xB7B27E36, 0x6D8DE8F9, 0xD54BF16A, 0xD9E90373,
|
||||
0x7599D982, 0x51F82B0E, 0x636103AD, 0x8E40BC35, 0x2F332C94, 0xF513AAE9,
|
||||
0xD22AFEE9, 0x04343987, 0xFC5BB80C, 0x12349D89, 0x14A481BB, 0x25ED3AE8,
|
||||
@@ -259,13 +259,13 @@ u32 g_key_INDEXDAT1xx[] = {
|
||||
0xA34D8C80, 0x962B235D, 0x3E420548, 0x09CF9FFE, 0xD4883F5C, 0xD90E9CB5,
|
||||
0x00AEF4E9, 0xF0886DE9, 0x62A58A5B, 0x52A55546, 0x971941B5, 0xF5B79FAC};
|
||||
|
||||
typedef struct
|
||||
struct TAG_INFO
|
||||
{
|
||||
u32 tag; // 4 byte value at offset 0xD0 in the PRX file
|
||||
u32* key; // "step1_result" use for XOR step
|
||||
const u32 *key; // "step1_result" use for XOR step
|
||||
u8 code;
|
||||
u8 codeExtra;
|
||||
} TAG_INFO;
|
||||
};
|
||||
|
||||
static const TAG_INFO g_tagInfo[] =
|
||||
{
|
||||
@@ -287,7 +287,7 @@ static const TAG_INFO g_tagInfo[] =
|
||||
{ 0xBB67C59F, g_key_GAMESHARE2xx, 0x5E, 0x5E }
|
||||
};
|
||||
|
||||
static TAG_INFO const* GetTagInfo(u32 tagFind)
|
||||
static const TAG_INFO *GetTagInfo(u32 tagFind)
|
||||
{
|
||||
for (u32 iTag = 0; iTag < sizeof(g_tagInfo)/sizeof(TAG_INFO); iTag++)
|
||||
if (g_tagInfo[iTag].tag == tagFind)
|
||||
@@ -336,7 +336,7 @@ static int DecryptPRX1(const u8* pbIn, u8* pbOut, int cbTotal, u32 tag)
|
||||
int i, retsize;
|
||||
u8 bD0[0x80], b80[0x50], b00[0x80], bB0[0x20];
|
||||
|
||||
TAG_INFO const* pti = GetTagInfo(tag);
|
||||
const TAG_INFO *pti = GetTagInfo(tag);
|
||||
if (pti == NULL)
|
||||
{
|
||||
return -1;
|
||||
@@ -350,9 +350,15 @@ static int DecryptPRX1(const u8* pbIn, u8* pbOut, int cbTotal, u32 tag)
|
||||
break;
|
||||
}
|
||||
|
||||
// Scramble the key (!)
|
||||
//
|
||||
// NOTE: I can't make much sense out of this code. Scramble seems really odd, appears
|
||||
// to write to stuff that should be before the actual key.
|
||||
u8 key[0x90];
|
||||
memcpy(key, pti->key, 0x90);
|
||||
if (i == 0x14)
|
||||
{
|
||||
Scramble(pti->key, 0x90, pti->code);
|
||||
Scramble((u32 *)key, 0x90, pti->code);
|
||||
}
|
||||
|
||||
// build conversion into pbOut
|
||||
@@ -387,7 +393,7 @@ static int DecryptPRX1(const u8* pbIn, u8* pbOut, int cbTotal, u32 tag)
|
||||
int ret;
|
||||
int iXOR;
|
||||
for (iXOR = 0; iXOR < 0x70; iXOR++)
|
||||
pbOut[0x40+iXOR] = pbOut[0x40+iXOR] ^ ((u8*)pti->key)[0x14+iXOR];
|
||||
pbOut[0x40+iXOR] = pbOut[0x40+iXOR] ^ key[0x14+iXOR];
|
||||
|
||||
ret = sceUtilsBufferCopyWithRange(pbOut+0x2C, 20+0x70, pbOut+0x2C, 20+0x70, 7);
|
||||
if (ret != 0)
|
||||
@@ -396,7 +402,7 @@ static int DecryptPRX1(const u8* pbIn, u8* pbOut, int cbTotal, u32 tag)
|
||||
}
|
||||
|
||||
for (iXOR = 0x6F; iXOR >= 0; iXOR--)
|
||||
pbOut[0x40+iXOR] = pbOut[0x2C+iXOR] ^ ((u8*)pti->key)[0x20+iXOR];
|
||||
pbOut[0x40+iXOR] = pbOut[0x2C+iXOR] ^ key[0x20+iXOR];
|
||||
|
||||
memset(pbOut+0x80, 0, 0x30); // $40 bytes kept, clean up
|
||||
pbOut[0xA0] = 1;
|
||||
@@ -418,13 +424,13 @@ static int DecryptPRX1(const u8* pbIn, u8* pbOut, int cbTotal, u32 tag)
|
||||
|
||||
////////// Decryption 2 //////////
|
||||
|
||||
typedef struct
|
||||
struct TAG_INFO2
|
||||
{
|
||||
u32 tag; // 4 byte value at offset 0xD0 in the PRX file
|
||||
u8 *key; // 16 bytes keys
|
||||
const u8 *key; // 16 bytes keys
|
||||
u8 code; // code for scramble
|
||||
u8 type;
|
||||
} TAG_INFO2;
|
||||
};
|
||||
|
||||
static TAG_INFO2 g_tagInfo2[] =
|
||||
{
|
||||
@@ -575,11 +581,6 @@ static TAG_INFO2 *GetTagInfo2(u32 tagFind)
|
||||
return NULL; // not found
|
||||
}
|
||||
|
||||
// Moving these out here is a really ugly hack to avoid a stack corruption warning, warranted or not
|
||||
static u8 padding1[0x100];
|
||||
static u8 tmp1[0x150], tmp2[0x90+0x14], tmp3[0x60+0x14], tmp4[0x20];
|
||||
static u8 padding2[0x100];
|
||||
|
||||
static int DecryptPRX2(const u8 *inbuf, u8 *outbuf, u32 size, u32 tag)
|
||||
{
|
||||
TAG_INFO2 * pti = GetTagInfo2(tag);
|
||||
@@ -590,10 +591,11 @@ static int DecryptPRX2(const u8 *inbuf, u8 *outbuf, u32 size, u32 tag)
|
||||
}
|
||||
|
||||
int retsize = *(int *)&inbuf[0xB0];
|
||||
u8 tmp1[0x150], tmp2[0x90+0x14], tmp3[0x90+0x14], tmp4[0x20];
|
||||
|
||||
memset(tmp1, 0, 0x150);
|
||||
memset(tmp2, 0, 0x90+0x14);
|
||||
memset(tmp3, 0, 0x60+0x14);
|
||||
memset(tmp3, 0, 0x90+0x14);
|
||||
memset(tmp4, 0, 0x20);
|
||||
|
||||
if (inbuf != outbuf)
|
||||
@@ -619,10 +621,8 @@ static int DecryptPRX2(const u8 *inbuf, u8 *outbuf, u32 size, u32 tag)
|
||||
for (j = 0; j < 0x10; j++)
|
||||
{
|
||||
p[(i << 4) + j] = pti->key[j];
|
||||
|
||||
}
|
||||
|
||||
p[(i << 4)] = i;
|
||||
p[(i << 4)] = i; // really?
|
||||
}
|
||||
|
||||
if (Scramble((u32 *)tmp2, 0x90, pti->code) < 0)
|
||||
@@ -673,9 +673,7 @@ static int DecryptPRX2(const u8 *inbuf, u8 *outbuf, u32 size, u32 tag)
|
||||
return -8;
|
||||
}
|
||||
|
||||
int iXOR;
|
||||
|
||||
for (iXOR = 0; iXOR < 0x40; iXOR++)
|
||||
for (int iXOR = 0; iXOR < 0x40; iXOR++)
|
||||
{
|
||||
tmp3[iXOR+0x14] = outbuf[iXOR+0x80] ^ tmp2[iXOR+0x10];
|
||||
}
|
||||
@@ -685,7 +683,7 @@ static int DecryptPRX2(const u8 *inbuf, u8 *outbuf, u32 size, u32 tag)
|
||||
return -9;
|
||||
}
|
||||
|
||||
for (iXOR = 0x3F; iXOR >= 0; iXOR--)
|
||||
for (int iXOR = 0x3F; iXOR >= 0; iXOR--)
|
||||
{
|
||||
outbuf[iXOR+0x40] = tmp3[iXOR] ^ tmp2[iXOR+0x50]; // uns 8
|
||||
}
|
||||
@@ -708,7 +706,7 @@ static int DecryptPRX2(const u8 *inbuf, u8 *outbuf, u32 size, u32 tag)
|
||||
memcpy(outbuf+0xD0, outbuf+0xD0, 0x80);
|
||||
|
||||
// The real decryption
|
||||
if (sceUtilsBufferCopyWithRange(outbuf, size, outbuf+0x40, size-0x40, 0x1) != 0)
|
||||
if (sceUtilsBufferCopyWithRange(outbuf, size, outbuf + 0x40, size - 0x40, 0x1) != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -122,11 +122,11 @@ bool CISOFileBlockDevice::ReadBlock(int blockNumber, u8 *outPtr)
|
||||
{
|
||||
u32 idx = index[blockNumber];
|
||||
u32 idx2 = index[blockNumber+1];
|
||||
u8 inbuffer[4096]; //too big
|
||||
z_stream z;
|
||||
|
||||
u8 inbuffer[4096]; //too big
|
||||
z_stream z;
|
||||
|
||||
int plain = idx & 0x80000000;
|
||||
|
||||
|
||||
idx = (idx & 0x7FFFFFFF) << indexShift;
|
||||
idx2 = (idx2 & 0x7FFFFFFF) << indexShift;
|
||||
|
||||
|
||||
@@ -18,30 +18,142 @@
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
#include "FileUtil.h"
|
||||
#include "DirectoryFileSystem.h"
|
||||
|
||||
DirectoryFileSystem::DirectoryFileSystem(IHandleAllocator *_hAlloc, std::string _basePath) : basePath(_basePath)
|
||||
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
|
||||
static bool FixFilenameCase(const std::string &path, std::string &filename)
|
||||
{
|
||||
// Are we lucky?
|
||||
if (File::Exists(path + filename))
|
||||
return true;
|
||||
|
||||
size_t filenameSize = filename.size();
|
||||
for (size_t i = 0; i < filenameSize; i++)
|
||||
{
|
||||
filename[i] = tolower(filename[i]);
|
||||
}
|
||||
|
||||
//TODO: lookup filename in cache for "path"
|
||||
|
||||
struct dirent_large { struct dirent entry; char padding[FILENAME_MAX+1]; } diren;
|
||||
struct dirent_large;
|
||||
struct dirent *result = NULL;
|
||||
|
||||
DIR *dirp = opendir(path.c_str());
|
||||
if (!dirp)
|
||||
return false;
|
||||
|
||||
bool retValue = false;
|
||||
|
||||
while (!readdir_r(dirp, (dirent*) &diren, &result) && result)
|
||||
{
|
||||
// Hm, is this check UTF-8 compatible? (size vs strlen)
|
||||
if (strlen(result->d_name) != filenameSize)
|
||||
continue;
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < filenameSize; i++)
|
||||
{
|
||||
if (filename[i] != tolower(result->d_name[i]))
|
||||
break;
|
||||
}
|
||||
|
||||
if (i < filenameSize)
|
||||
continue;
|
||||
|
||||
filename = result->d_name;
|
||||
retValue = true;
|
||||
}
|
||||
|
||||
closedir(dirp);
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
bool DirectoryFileSystem::FixPathCase(std::string &path, FixPathCaseBehavior behavior)
|
||||
{
|
||||
size_t len = path.size();
|
||||
|
||||
if (len == 0)
|
||||
return true;
|
||||
|
||||
if (path[len - 1] == '/')
|
||||
{
|
||||
len--;
|
||||
|
||||
if (len == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string fullPath;
|
||||
fullPath.reserve(basePath.size() + len + 1);
|
||||
fullPath.append(basePath);
|
||||
|
||||
size_t start = 0;
|
||||
while (start < len)
|
||||
{
|
||||
size_t i = path.find('/', start);
|
||||
if (i == std::string::npos)
|
||||
i = len;
|
||||
|
||||
if (i > start)
|
||||
{
|
||||
std::string component = path.substr(start, i - start);
|
||||
|
||||
// Fix case and stop on nonexistant path component
|
||||
if (FixFilenameCase(fullPath, component) == false) {
|
||||
// Still counts as success if partial matches allowed or if this
|
||||
// is the last component and only the ones before it are required
|
||||
return (behavior == FPC_PARTIAL_ALLOWED || (behavior == FPC_PATH_MUST_EXIST && i >= len));
|
||||
}
|
||||
|
||||
path.replace(start, i - start, component);
|
||||
|
||||
fullPath.append(component);
|
||||
fullPath.append(1, '/');
|
||||
}
|
||||
|
||||
start = i + 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
DirectoryFileSystem::DirectoryFileSystem(IHandleAllocator *_hAlloc, std::string _basePath) : basePath(_basePath) {
|
||||
File::CreateFullPath(basePath);
|
||||
hAlloc = _hAlloc;
|
||||
}
|
||||
|
||||
std::string DirectoryFileSystem::GetLocalPath(std::string localpath)
|
||||
{
|
||||
DirectoryFileSystem::~DirectoryFileSystem() {
|
||||
for (auto iter = entries.begin(); iter != entries.end(); ++iter) {
|
||||
#ifdef _WIN32
|
||||
CloseHandle((*iter).second.hFile);
|
||||
#else
|
||||
fclose((*iter).second.hFile);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
std::string DirectoryFileSystem::GetLocalPath(std::string localpath) {
|
||||
if (localpath.empty())
|
||||
return basePath;
|
||||
|
||||
if (localpath[0] == '/')
|
||||
localpath.erase(0,1);
|
||||
//Convert slashes
|
||||
//Convert slashes
|
||||
#ifdef _WIN32
|
||||
for (size_t i = 0; i < localpath.size(); i++)
|
||||
{
|
||||
for (size_t i = 0; i < localpath.size(); i++) {
|
||||
if (localpath[i] == '/')
|
||||
localpath[i] = '\\';
|
||||
}
|
||||
@@ -49,18 +161,38 @@ std::string DirectoryFileSystem::GetLocalPath(std::string localpath)
|
||||
return basePath + localpath;
|
||||
}
|
||||
|
||||
bool DirectoryFileSystem::MkDir(const std::string &dirname) {
|
||||
|
||||
bool DirectoryFileSystem::MkDir(const std::string &dirname)
|
||||
{
|
||||
std::string fullName = GetLocalPath(dirname);
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
// Must fix case BEFORE attempting, because MkDir would create
|
||||
// duplicate (different case) directories
|
||||
|
||||
return File::CreateFullPath(fullName);
|
||||
std::string fixedCase = dirname;
|
||||
if ( ! FixPathCase(fixedCase, FPC_PARTIAL_ALLOWED) )
|
||||
return false;
|
||||
|
||||
return File::CreateFullPath(GetLocalPath(fixedCase));
|
||||
#else
|
||||
return File::CreateFullPath(GetLocalPath(dirname));
|
||||
#endif
|
||||
}
|
||||
|
||||
bool DirectoryFileSystem::RmDir(const std::string &dirname)
|
||||
{
|
||||
bool DirectoryFileSystem::RmDir(const std::string &dirname) {
|
||||
std::string fullName = GetLocalPath(dirname);
|
||||
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
// Maybe we're lucky?
|
||||
if (File::DeleteDirRecursively(fullName))
|
||||
return true;
|
||||
|
||||
// Nope, fix case and try again
|
||||
fullName = dirname;
|
||||
if ( ! FixPathCase(fullName, FPC_FILE_MUST_EXIST) )
|
||||
return false; // or go on and attempt (for a better error code than just false?)
|
||||
|
||||
fullName = GetLocalPath(fullName);
|
||||
#endif
|
||||
|
||||
/*#ifdef _WIN32
|
||||
return RemoveDirectory(fullName.c_str()) == TRUE;
|
||||
#else
|
||||
@@ -69,82 +201,185 @@ bool DirectoryFileSystem::RmDir(const std::string &dirname)
|
||||
return File::DeleteDirRecursively(fullName);
|
||||
}
|
||||
|
||||
bool DirectoryFileSystem::RenameFile(const std::string &from, const std::string &to)
|
||||
{
|
||||
std::string fullFrom = GetLocalPath(from);
|
||||
bool DirectoryFileSystem::RenameFile(const std::string &from, const std::string &to) {
|
||||
std::string fullTo = to;
|
||||
// TO filename may not include path. Intention is that it uses FROM's path
|
||||
if (to.find("/") != std::string::npos) {
|
||||
int offset = from.find_last_of("/");
|
||||
if (offset >= 0) {
|
||||
size_t offset = from.find_last_of("/");
|
||||
if (offset != std::string::npos) {
|
||||
fullTo = from.substr(0, offset + 1) + to;
|
||||
}
|
||||
}
|
||||
std::string fullFrom = GetLocalPath(from);
|
||||
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
// In case TO should overwrite a file with different case
|
||||
if ( ! FixPathCase(fullTo, FPC_PATH_MUST_EXIST) )
|
||||
return false; // or go on and attempt (for a better error code than just false?)
|
||||
#endif
|
||||
|
||||
fullTo = GetLocalPath(fullTo);
|
||||
const char * fullToC = fullTo.c_str();
|
||||
|
||||
#ifdef _WIN32
|
||||
return MoveFile(fullFrom.c_str(), fullTo.c_str()) == TRUE;
|
||||
bool retValue = (MoveFile(fullFrom.c_str(), fullToC) == TRUE);
|
||||
#else
|
||||
return 0 == rename(fullFrom.c_str(), fullTo.c_str());
|
||||
bool retValue = (0 == rename(fullFrom.c_str(), fullToC));
|
||||
#endif
|
||||
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
if (! retValue)
|
||||
{
|
||||
// May have failed due to case sensitivity on FROM, so try again
|
||||
fullFrom = from;
|
||||
if ( ! FixPathCase(fullFrom, FPC_FILE_MUST_EXIST) )
|
||||
return false; // or go on and attempt (for a better error code than just false?)
|
||||
fullFrom = GetLocalPath(fullFrom);
|
||||
|
||||
#ifdef _WIN32
|
||||
retValue = (MoveFile(fullFrom.c_str(), fullToC) == TRUE);
|
||||
#else
|
||||
retValue = (0 == rename(fullFrom.c_str(), fullToC));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
bool DirectoryFileSystem::DeleteFile(const std::string &filename)
|
||||
{
|
||||
bool DirectoryFileSystem::DeleteFile(const std::string &filename) {
|
||||
std::string fullName = GetLocalPath(filename);
|
||||
#ifdef _WIN32
|
||||
return DeleteFile(fullName.c_str()) == TRUE;
|
||||
bool retValue = (::DeleteFile(fullName.c_str()) == TRUE);
|
||||
#else
|
||||
return 0 == unlink(fullName.c_str());
|
||||
bool retValue = (0 == unlink(fullName.c_str()));
|
||||
#endif
|
||||
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
if (! retValue)
|
||||
{
|
||||
// May have failed due to case sensitivity, so try again
|
||||
fullName = filename;
|
||||
if ( ! FixPathCase(fullName, FPC_FILE_MUST_EXIST) )
|
||||
return false; // or go on and attempt (for a better error code than just false?)
|
||||
fullName = GetLocalPath(fullName);
|
||||
|
||||
#ifdef _WIN32
|
||||
retValue = (::DeleteFile(fullName.c_str()) == TRUE);
|
||||
#else
|
||||
retValue = (0 == unlink(fullName.c_str()));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
u32 DirectoryFileSystem::OpenFile(std::string filename, FileAccess access)
|
||||
{
|
||||
u32 DirectoryFileSystem::OpenFile(std::string filename, FileAccess access) {
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
if (access & (FILEACCESS_APPEND|FILEACCESS_CREATE|FILEACCESS_WRITE))
|
||||
{
|
||||
DEBUG_LOG(HLE, "Checking case for path %s", filename.c_str());
|
||||
if ( ! FixPathCase(filename, FPC_PATH_MUST_EXIST) )
|
||||
return 0; // or go on and attempt (for a better error code than just 0?)
|
||||
}
|
||||
// else we try fopen first (in case we're lucky) before simulating case insensitivity
|
||||
#endif
|
||||
|
||||
std::string fullName = GetLocalPath(filename);
|
||||
INFO_LOG(HLE,"Actually opening %s (%s)", fullName.c_str(), filename.c_str());
|
||||
const char *fullNameC = fullName.c_str();
|
||||
INFO_LOG(HLE,"Actually opening %s (%s)", fullNameC, filename.c_str());
|
||||
|
||||
OpenFileEntry entry;
|
||||
|
||||
//TODO: tests, should append seek to end of file? seeking in a file opened for append?
|
||||
#ifdef _WIN32
|
||||
// Convert parameters to Windows permissions and access
|
||||
DWORD desired = 0;
|
||||
DWORD sharemode = 0;
|
||||
DWORD openmode = 0;
|
||||
if (access & FILEACCESS_READ)
|
||||
{
|
||||
if (access & FILEACCESS_READ) {
|
||||
desired |= GENERIC_READ;
|
||||
sharemode |= FILE_SHARE_READ;
|
||||
}
|
||||
if (access & FILEACCESS_WRITE)
|
||||
{
|
||||
if (access & FILEACCESS_WRITE) {
|
||||
desired |= GENERIC_WRITE;
|
||||
sharemode |= FILE_SHARE_WRITE;
|
||||
}
|
||||
if (access & FILEACCESS_CREATE)
|
||||
{
|
||||
if (access & FILEACCESS_CREATE) {
|
||||
openmode = OPEN_ALWAYS;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
openmode = OPEN_EXISTING;
|
||||
|
||||
}
|
||||
//Let's do it!
|
||||
entry.hFile = CreateFile(fullName.c_str(), desired, sharemode, 0, openmode, 0, 0);
|
||||
entry.hFile = CreateFile(fullNameC, desired, sharemode, 0, openmode, 0, 0);
|
||||
bool success = entry.hFile != INVALID_HANDLE_VALUE;
|
||||
#else
|
||||
entry.hFile = fopen(fullName.c_str(), access & FILEACCESS_WRITE ? "wb" : "rb");
|
||||
bool success = entry.hFile != 0;
|
||||
// Convert flags in access parameter to fopen access mode
|
||||
const char *mode = NULL;
|
||||
if (access & FILEACCESS_APPEND) {
|
||||
if (access & FILEACCESS_READ)
|
||||
mode = "ab+"; // append+read, create if needed
|
||||
else
|
||||
mode = "ab"; // append only, create if needed
|
||||
} else if (access & FILEACCESS_WRITE) {
|
||||
if (access & FILEACCESS_READ) {
|
||||
// FILEACCESS_CREATE is ignored for read only, write only, and append
|
||||
// because C++ standard fopen's nonexistant file creation can only be
|
||||
// customized for files opened read+write
|
||||
if (access & FILEACCESS_CREATE)
|
||||
mode = "wb+"; // read+write, create if needed
|
||||
else
|
||||
mode = "rb+"; // read+write, but don't create
|
||||
} else {
|
||||
mode = "wb"; // write only, create if needed
|
||||
}
|
||||
} else { // neither write nor append, so default to read only
|
||||
mode = "rb"; // read only, don't create
|
||||
}
|
||||
|
||||
entry.hFile = fopen(fullNameC, mode);
|
||||
bool success = entry.hFile != 0;
|
||||
#endif
|
||||
|
||||
if (!success)
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
if (!success &&
|
||||
!(access & FILEACCESS_APPEND) &&
|
||||
!(access & FILEACCESS_CREATE) &&
|
||||
!(access & FILEACCESS_WRITE))
|
||||
{
|
||||
if ( ! FixPathCase(filename, FPC_PATH_MUST_EXIST) )
|
||||
return 0; // or go on and attempt (for a better error code than just 0?)
|
||||
fullName = GetLocalPath(filename);
|
||||
fullNameC = fullName.c_str();
|
||||
|
||||
DEBUG_LOG(HLE, "Case may have been incorrect, second try opening %s (%s)", fullNameC, filename.c_str());
|
||||
|
||||
// And try again with the correct case this time
|
||||
#ifdef _WIN32
|
||||
ERROR_LOG(HLE, "DirectoryFileSystem::OpenFile: FAILED, %i - access = %i", GetLastError(), (int)access);
|
||||
entry.hFile = CreateFile(fullNameC, desired, sharemode, 0, openmode, 0, 0);
|
||||
success = entry.hFile != INVALID_HANDLE_VALUE;
|
||||
#else
|
||||
entry.hFile = fopen(fullNameC, mode);
|
||||
success = entry.hFile != 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!success) {
|
||||
#ifdef _WIN32
|
||||
ERROR_LOG(HLE, "DirectoryFileSystem::OpenFile: FAILED, %i - access = %i", GetLastError(), (int)access);
|
||||
#else
|
||||
ERROR_LOG(HLE, "DirectoryFileSystem::OpenFile: FAILED, access = %i", (int)access);
|
||||
#endif
|
||||
//wwwwaaaaahh!!
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
if (access & FILEACCESS_APPEND)
|
||||
SetFilePointer(entry.hFile, 0, NULL, FILE_END);
|
||||
#endif
|
||||
|
||||
u32 newHandle = hAlloc->GetNewHandle();
|
||||
entries[newHandle] = entry;
|
||||
|
||||
@@ -152,55 +387,46 @@ u32 DirectoryFileSystem::OpenFile(std::string filename, FileAccess access)
|
||||
}
|
||||
}
|
||||
|
||||
void DirectoryFileSystem::CloseFile(u32 handle)
|
||||
{
|
||||
void DirectoryFileSystem::CloseFile(u32 handle) {
|
||||
EntryMap::iterator iter = entries.find(handle);
|
||||
if (iter != entries.end())
|
||||
{
|
||||
if (iter != entries.end()) {
|
||||
hAlloc->FreeHandle(handle);
|
||||
#ifdef _WIN32
|
||||
CloseHandle((*iter).second.hFile);
|
||||
#else
|
||||
fclose((*iter).second.hFile);
|
||||
fclose((*iter).second.hFile);
|
||||
#endif
|
||||
entries.erase(iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
//This shouldn't happen...
|
||||
ERROR_LOG(HLE,"Cannot close file that hasn't been opened: %08x", handle);
|
||||
}
|
||||
}
|
||||
|
||||
bool DirectoryFileSystem::OwnsHandle(u32 handle)
|
||||
{
|
||||
bool DirectoryFileSystem::OwnsHandle(u32 handle) {
|
||||
EntryMap::iterator iter = entries.find(handle);
|
||||
return (iter != entries.end());
|
||||
}
|
||||
|
||||
size_t DirectoryFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size)
|
||||
{
|
||||
size_t DirectoryFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size) {
|
||||
EntryMap::iterator iter = entries.find(handle);
|
||||
if (iter != entries.end())
|
||||
{
|
||||
size_t bytesRead;
|
||||
size_t bytesRead;
|
||||
#ifdef _WIN32
|
||||
::ReadFile(iter->second.hFile, (LPVOID)pointer, (DWORD)size, (LPDWORD)&bytesRead, 0);
|
||||
#else
|
||||
bytesRead = fread(pointer, 1, size, iter->second.hFile);
|
||||
bytesRead = fread(pointer, 1, size, iter->second.hFile);
|
||||
#endif
|
||||
return bytesRead;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
//This shouldn't happen...
|
||||
ERROR_LOG(HLE,"Cannot read file that hasn't been opened: %08x", handle);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
size_t DirectoryFileSystem::WriteFile(u32 handle, const u8 *pointer, s64 size)
|
||||
{
|
||||
size_t DirectoryFileSystem::WriteFile(u32 handle, const u8 *pointer, s64 size) {
|
||||
EntryMap::iterator iter = entries.find(handle);
|
||||
if (iter != entries.end())
|
||||
{
|
||||
@@ -208,67 +434,66 @@ size_t DirectoryFileSystem::WriteFile(u32 handle, const u8 *pointer, s64 size)
|
||||
#ifdef _WIN32
|
||||
::WriteFile(iter->second.hFile, (LPVOID)pointer, (DWORD)size, (LPDWORD)&bytesWritten, 0);
|
||||
#else
|
||||
bytesWritten = fwrite(pointer, 1, size, iter->second.hFile);
|
||||
bytesWritten = fwrite(pointer, 1, size, iter->second.hFile);
|
||||
#endif
|
||||
return bytesWritten;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
//This shouldn't happen...
|
||||
ERROR_LOG(HLE,"Cannot write to file that hasn't been opened: %08x", handle);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
size_t DirectoryFileSystem::SeekFile(u32 handle, s32 position, FileMove type)
|
||||
{
|
||||
size_t DirectoryFileSystem::SeekFile(u32 handle, s32 position, FileMove type) {
|
||||
EntryMap::iterator iter = entries.find(handle);
|
||||
if (iter != entries.end())
|
||||
{
|
||||
if (iter != entries.end()) {
|
||||
#ifdef _WIN32
|
||||
DWORD moveMethod = 0;
|
||||
switch (type)
|
||||
{
|
||||
case FILEMOVE_BEGIN: moveMethod = FILE_BEGIN; break;
|
||||
case FILEMOVE_CURRENT: moveMethod = FILE_CURRENT; break;
|
||||
case FILEMOVE_END: moveMethod = FILE_END; break;
|
||||
switch (type) {
|
||||
case FILEMOVE_BEGIN: moveMethod = FILE_BEGIN; break;
|
||||
case FILEMOVE_CURRENT: moveMethod = FILE_CURRENT; break;
|
||||
case FILEMOVE_END: moveMethod = FILE_END; break;
|
||||
}
|
||||
DWORD newPos = SetFilePointer((*iter).second.hFile, (LONG)position, 0, moveMethod);
|
||||
return newPos;
|
||||
return newPos;
|
||||
#else
|
||||
int moveMethod = 0;
|
||||
switch (type) {
|
||||
case FILEMOVE_BEGIN: moveMethod = SEEK_SET; break;
|
||||
case FILEMOVE_CURRENT: moveMethod = SEEK_CUR; break;
|
||||
case FILEMOVE_END: moveMethod = SEEK_END; break;
|
||||
}
|
||||
fseek(iter->second.hFile, position, moveMethod);
|
||||
int moveMethod = 0;
|
||||
switch (type) {
|
||||
case FILEMOVE_BEGIN: moveMethod = SEEK_SET; break;
|
||||
case FILEMOVE_CURRENT: moveMethod = SEEK_CUR; break;
|
||||
case FILEMOVE_END: moveMethod = SEEK_END; break;
|
||||
}
|
||||
fseek(iter->second.hFile, position, moveMethod);
|
||||
return ftell(iter->second.hFile);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
//This shouldn't happen...
|
||||
ERROR_LOG(HLE,"Cannot seek in file that hasn't been opened: %08x", handle);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename)
|
||||
{
|
||||
PSPFileInfo x;
|
||||
PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename) {
|
||||
PSPFileInfo x;
|
||||
x.name = filename;
|
||||
|
||||
|
||||
std::string fullName = GetLocalPath(filename);
|
||||
if (!File::Exists(fullName)) {
|
||||
if (! File::Exists(fullName)) {
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
if (! FixPathCase(filename, FPC_FILE_MUST_EXIST))
|
||||
return x;
|
||||
fullName = GetLocalPath(filename);
|
||||
|
||||
if (! File::Exists(fullName))
|
||||
return x;
|
||||
#else
|
||||
return x;
|
||||
#endif
|
||||
}
|
||||
x.type = File::IsDirectory(fullName) ? FILETYPE_NORMAL : FILETYPE_DIRECTORY;
|
||||
x.exists = true;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
WIN32_FILE_ATTRIBUTE_DATA data;
|
||||
GetFileAttributesEx(fullName.c_str(), GetFileExInfoStandard, &data);
|
||||
|
||||
@@ -282,8 +507,7 @@ PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename)
|
||||
return x;
|
||||
}
|
||||
|
||||
std::vector<PSPFileInfo> DirectoryFileSystem::GetDirListing(std::string path)
|
||||
{
|
||||
std::vector<PSPFileInfo> DirectoryFileSystem::GetDirListing(std::string path) {
|
||||
std::vector<PSPFileInfo> myVector;
|
||||
#ifdef _WIN32
|
||||
WIN32_FIND_DATA findData;
|
||||
@@ -293,33 +517,37 @@ std::vector<PSPFileInfo> DirectoryFileSystem::GetDirListing(std::string path)
|
||||
|
||||
hFind = FindFirstFile(w32path.c_str(), &findData);
|
||||
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (hFind == INVALID_HANDLE_VALUE) {
|
||||
return myVector; //the empty list
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
while (true) {
|
||||
PSPFileInfo entry;
|
||||
|
||||
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
entry.type = FILETYPE_DIRECTORY;
|
||||
else
|
||||
entry.type = FILETYPE_NORMAL;
|
||||
|
||||
if (!strcmp(findData.cFileName, "..") )// TODO: is this just for .. or all sub directories? Need to add a directory to the test to find out. Also why so different than the old test results?
|
||||
// TODO: is this just for .. or all subdirectories? Need to add a directory to the test
|
||||
// to find out. Also why so different than the old test results?
|
||||
if (!strcmp(findData.cFileName, "..") )
|
||||
entry.size = 4096;
|
||||
else
|
||||
entry.size = findData.nFileSizeLow | ((u64)findData.nFileSizeHigh<<32);
|
||||
entry.name = findData.cFileName;
|
||||
|
||||
myVector.push_back(entry);
|
||||
|
||||
int retval = FindNextFile(hFind, &findData);
|
||||
if (!retval)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
ERROR_LOG(HLE, "GetDirListing not implemented on non-Windows");
|
||||
#endif
|
||||
return myVector;
|
||||
}
|
||||
|
||||
void DirectoryFileSystem::DoState(PointerWrap &p) {
|
||||
if (!entries.empty()) {
|
||||
ERROR_LOG(FILESYS, "FIXME: Open files during savestate, could go badly.");
|
||||
}
|
||||
}
|
||||
@@ -28,29 +28,32 @@
|
||||
typedef void * HANDLE;
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
|
||||
class DirectoryFileSystem : public IFileSystem
|
||||
{
|
||||
struct OpenFileEntry
|
||||
{
|
||||
#ifdef _WIN32
|
||||
HANDLE hFile;
|
||||
#if TARGET_OS_IPHONE
|
||||
#define HOST_IS_CASE_SENSITIVE 1
|
||||
#elif TARGET_IPHONE_SIMULATOR
|
||||
#define HOST_IS_CASE_SENSITIVE 0
|
||||
#else
|
||||
FILE *hFile;
|
||||
// Mac OSX case sensitivity defaults off, but is user configurable (when
|
||||
// creating a filesytem), so assume the worst:
|
||||
#define HOST_IS_CASE_SENSITIVE 1
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef std::map<u32,OpenFileEntry> EntryMap;
|
||||
EntryMap entries;
|
||||
std::string basePath;
|
||||
IHandleAllocator *hAlloc;
|
||||
#elif defined(_WIN32) || defined(__SYMBIAN32__)
|
||||
#define HOST_IS_CASE_SENSITIVE 0
|
||||
|
||||
#else // Android, Linux, BSD (and the rest?)
|
||||
#define HOST_IS_CASE_SENSITIVE 1
|
||||
|
||||
// In case of Windows: Translate slashes, etc.
|
||||
std::string GetLocalPath(std::string localpath);
|
||||
#endif
|
||||
|
||||
class DirectoryFileSystem : public IFileSystem {
|
||||
public:
|
||||
DirectoryFileSystem(IHandleAllocator *_hAlloc, std::string _basePath);
|
||||
~DirectoryFileSystem();
|
||||
|
||||
void DoState(PointerWrap &p);
|
||||
std::vector<PSPFileInfo> GetDirListing(std::string path);
|
||||
u32 OpenFile(std::string filename, FileAccess access);
|
||||
void CloseFile(u32 handle);
|
||||
@@ -59,9 +62,35 @@ public:
|
||||
size_t SeekFile(u32 handle, s32 position, FileMove type);
|
||||
PSPFileInfo GetFileInfo(std::string filename);
|
||||
bool OwnsHandle(u32 handle);
|
||||
|
||||
bool MkDir(const std::string &dirname);
|
||||
bool RmDir(const std::string &dirname);
|
||||
bool RenameFile(const std::string &from, const std::string &to);
|
||||
bool DeleteFile(const std::string &filename);
|
||||
|
||||
private:
|
||||
struct OpenFileEntry {
|
||||
#ifdef _WIN32
|
||||
HANDLE hFile;
|
||||
#else
|
||||
FILE *hFile;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef std::map<u32, OpenFileEntry> EntryMap;
|
||||
EntryMap entries;
|
||||
std::string basePath;
|
||||
IHandleAllocator *hAlloc;
|
||||
|
||||
// In case of Windows: Translate slashes, etc.
|
||||
std::string GetLocalPath(std::string localpath);
|
||||
|
||||
#if HOST_IS_CASE_SENSITIVE
|
||||
typedef enum {
|
||||
FPC_FILE_MUST_EXIST, // all path components must exist (rmdir, move from)
|
||||
FPC_PATH_MUST_EXIST, // all except the last one must exist - still tries to fix last one (fopen, move to)
|
||||
FPC_PARTIAL_ALLOWED, // don't care how many exist (mkdir recursive)
|
||||
} FixPathCaseBehavior;
|
||||
bool FixPathCase(std::string &path, FixPathCaseBehavior behavior);
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../Globals.h"
|
||||
#include "../../Common/ChunkFile.h"
|
||||
#include <string>
|
||||
|
||||
enum FileAccess
|
||||
@@ -56,6 +57,20 @@ struct PSPFileInfo
|
||||
PSPFileInfo()
|
||||
: size(0), access(0), exists(false), type(FILETYPE_NORMAL), isOnSectorSystem(false), startSector(0), numSectors(0) {}
|
||||
|
||||
void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(name);
|
||||
p.Do(size);
|
||||
p.Do(access);
|
||||
p.Do(exists);
|
||||
p.Do(type);
|
||||
p.Do(mtime);
|
||||
p.Do(isOnSectorSystem);
|
||||
p.Do(startSector);
|
||||
p.Do(numSectors);
|
||||
p.DoMarker("PSPFileInfo");
|
||||
}
|
||||
|
||||
std::string name;
|
||||
s64 size;
|
||||
u32 access; //unix 777
|
||||
@@ -75,6 +90,7 @@ class IFileSystem
|
||||
public:
|
||||
virtual ~IFileSystem() {}
|
||||
|
||||
virtual void DoState(PointerWrap &p) = 0;
|
||||
virtual std::vector<PSPFileInfo> GetDirListing(std::string path) = 0;
|
||||
virtual u32 OpenFile(std::string filename, FileAccess access) = 0;
|
||||
virtual void CloseFile(u32 handle) = 0;
|
||||
@@ -93,6 +109,7 @@ public:
|
||||
class EmptyFileSystem : public IFileSystem
|
||||
{
|
||||
public:
|
||||
virtual void DoState(PointerWrap &p) {}
|
||||
std::vector<PSPFileInfo> GetDirListing(std::string path) {std::vector<PSPFileInfo> vec; return vec;}
|
||||
u32 OpenFile(std::string filename, FileAccess access) {return 0;}
|
||||
void CloseFile(u32 handle) {}
|
||||
|
||||
@@ -16,10 +16,11 @@
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Log.h"
|
||||
#include "Common.h"
|
||||
#include "ISOFileSystem.h"
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
const int sectorSize = 2048;
|
||||
@@ -28,11 +29,13 @@ static bool parseLBN(std::string filename, u32 *sectorStart, u32 *readSize)
|
||||
{
|
||||
if (filename.substr(0, 8) != "/sce_lbn")
|
||||
return false;
|
||||
std::string yo = filename;
|
||||
std::string prev = filename;
|
||||
filename.erase(0, 10);
|
||||
sscanf(filename.c_str(), "%08x", sectorStart);
|
||||
if (sscanf(filename.c_str(), "%08x", sectorStart) != 1)
|
||||
WARN_LOG(FILESYS, "Invalid LBN reference: %s", prev.c_str());
|
||||
filename.erase(0, filename.find("_size") + 7);
|
||||
sscanf(filename.c_str(), "%08x", readSize);
|
||||
if (sscanf(filename.c_str(), "%08x", readSize) != 1)
|
||||
WARN_LOG(FILESYS, "Incomplete LBN reference: %s", prev.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -128,6 +131,7 @@ ISOFileSystem::ISOFileSystem(IHandleAllocator *_hAlloc, BlockDevice *_blockDevic
|
||||
entireISO.size = _blockDevice->GetNumBlocks() * _blockDevice->GetBlockSize();
|
||||
entireISO.isBlockSectorMode = true;
|
||||
entireISO.flags = 0;
|
||||
entireISO.parent = NULL;
|
||||
|
||||
if (!memcmp(desc.cd001, "CD001", 5))
|
||||
{
|
||||
@@ -139,6 +143,12 @@ ISOFileSystem::ISOFileSystem(IHandleAllocator *_hAlloc, BlockDevice *_blockDevic
|
||||
}
|
||||
|
||||
treeroot = new TreeEntry;
|
||||
treeroot->isDirectory = true;
|
||||
treeroot->startingPosition = 0;
|
||||
treeroot->size = 0;
|
||||
treeroot->isBlockSectorMode = false;
|
||||
treeroot->flags = 0;
|
||||
treeroot->parent = NULL;
|
||||
|
||||
u32 rootSector = desc.root.firstDataSectorLE;
|
||||
u32 rootSize = desc.root.dataLengthLE;
|
||||
@@ -149,6 +159,7 @@ ISOFileSystem::ISOFileSystem(IHandleAllocator *_hAlloc, BlockDevice *_blockDevic
|
||||
ISOFileSystem::~ISOFileSystem()
|
||||
{
|
||||
delete blockDevice;
|
||||
delete treeroot;
|
||||
}
|
||||
|
||||
void ISOFileSystem::ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root)
|
||||
@@ -208,6 +219,7 @@ nextblock:
|
||||
e->isDirectory = !isFile;
|
||||
e->flags = dir.flags;
|
||||
e->isBlockSectorMode = false;
|
||||
e->parent = root;
|
||||
|
||||
// Let's not excessively spam the log - I commented this line out.
|
||||
//DEBUG_LOG(FILESYS, "%s: %s %08x %08x %i", e->isDirectory?"D":"F", name, dir.firstDataSectorLE, e->startingPosition, e->startingPosition);
|
||||
@@ -392,6 +404,8 @@ size_t ISOFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size)
|
||||
}
|
||||
else
|
||||
{
|
||||
_dbg_assert_msg_(HLE, e.file != 0, "Expecting non-raw fd to have a tree entry.");
|
||||
|
||||
//clamp read length
|
||||
if ((s64)e.seekPos > e.file->size - (s64)size)
|
||||
{
|
||||
@@ -535,3 +549,70 @@ std::vector<PSPFileInfo> ISOFileSystem::GetDirListing(std::string path)
|
||||
}
|
||||
return myVector;
|
||||
}
|
||||
|
||||
std::string ISOFileSystem::EntryFullPath(TreeEntry *e)
|
||||
{
|
||||
size_t fullLen = 0;
|
||||
TreeEntry *cur = e;
|
||||
while (cur != NULL && cur != treeroot)
|
||||
{
|
||||
// For the "/".
|
||||
fullLen += 1 + cur->name.size();
|
||||
cur = cur->parent;
|
||||
}
|
||||
|
||||
std::string path;
|
||||
path.resize(fullLen);
|
||||
|
||||
cur = e;
|
||||
while (cur != NULL && cur != treeroot)
|
||||
{
|
||||
path.replace(fullLen - cur->name.size(), cur->name.size(), cur->name);
|
||||
path.replace(fullLen - cur->name.size() - 1, 1, "/");
|
||||
fullLen -= 1 + cur->name.size();
|
||||
cur = cur->parent;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
void ISOFileSystem::DoState(PointerWrap &p)
|
||||
{
|
||||
int n = (int) entries.size();
|
||||
p.Do(n);
|
||||
|
||||
if (p.mode == p.MODE_READ)
|
||||
{
|
||||
entries.clear();
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
u32 fd;
|
||||
p.Do(fd);
|
||||
std::string path;
|
||||
p.Do(path);
|
||||
OpenFileEntry of;
|
||||
of.file = path.empty() ? NULL : GetFromPath(path);
|
||||
p.Do(of.seekPos);
|
||||
p.Do(of.isRawSector);
|
||||
p.Do(of.sectorStart);
|
||||
p.Do(of.openSize);
|
||||
entries[fd] = of;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (EntryMap::iterator it = entries.begin(), end = entries.end(); it != end; ++it)
|
||||
{
|
||||
p.Do(it->first);
|
||||
std::string path = "";
|
||||
if (it->second.file != NULL)
|
||||
path = EntryFullPath(it->second.file);
|
||||
p.Do(path);
|
||||
p.Do(it->second.seekPos);
|
||||
p.Do(it->second.isRawSector);
|
||||
p.Do(it->second.sectorStart);
|
||||
p.Do(it->second.openSize);
|
||||
}
|
||||
}
|
||||
p.DoMarker("ISOFileSystem");
|
||||
}
|
||||
@@ -42,8 +42,9 @@ class ISOFileSystem : public IFileSystem
|
||||
u32 startingPosition;
|
||||
s64 size;
|
||||
bool isDirectory;
|
||||
bool isBlockSectorMode; // "umd:" mode: all sizes and offsets are in 2048 byte chunks
|
||||
bool isBlockSectorMode; // "umd:" mode: all sizes and offsets are in 2048 byte chunks
|
||||
|
||||
TreeEntry *parent;
|
||||
std::vector<TreeEntry*> children;
|
||||
};
|
||||
|
||||
@@ -67,10 +68,12 @@ class ISOFileSystem : public IFileSystem
|
||||
|
||||
void ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root);
|
||||
TreeEntry *GetFromPath(std::string path);
|
||||
std::string EntryFullPath(TreeEntry *e);
|
||||
|
||||
public:
|
||||
ISOFileSystem(IHandleAllocator *_hAlloc, BlockDevice *_blockDevice);
|
||||
~ISOFileSystem();
|
||||
void DoState(PointerWrap &p);
|
||||
std::vector<PSPFileInfo> GetDirListing(std::string path);
|
||||
u32 OpenFile(std::string filename, FileAccess access);
|
||||
void CloseFile(u32 handle);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <set>
|
||||
#include "MetaFileSystem.h"
|
||||
|
||||
bool applyPathStringToComponentsVector(std::vector<std::string> &vector, const std::string &pathString)
|
||||
static bool ApplyPathStringToComponentsVector(std::vector<std::string> &vector, const std::string &pathString)
|
||||
{
|
||||
size_t len = pathString.length();
|
||||
size_t start = 0;
|
||||
@@ -42,8 +42,8 @@ bool applyPathStringToComponentsVector(std::vector<std::string> &vector, const s
|
||||
}
|
||||
else
|
||||
{
|
||||
// what does the real PSP do for "/../filename"?
|
||||
WARN_LOG(HLE, "RealPath: .. as first path component: \"%s\"", pathString.c_str());
|
||||
// The PSP silently ignores attempts to .. to parent of root directory
|
||||
WARN_LOG(HLE, "RealPath: ignoring .. beyond root - root directory is its own parent: \"%s\"", pathString.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -61,9 +61,10 @@ bool applyPathStringToComponentsVector(std::vector<std::string> &vector, const s
|
||||
|
||||
/*
|
||||
* Changes relative paths to absolute, removes ".", "..", and trailing "/"
|
||||
* "drive:./blah" is absolute (ignore the dot) and "/blah" is relative (because it's missing "drive:")
|
||||
* babel (and possibly other games) use "/directoryThatDoesNotExist/../directoryThatExists/filename"
|
||||
*/
|
||||
bool RealPath(const std::string ¤tDirectory, const std::string &inPath, std::string &outPath)
|
||||
static bool RealPath(const std::string ¤tDirectory, const std::string &inPath, std::string &outPath)
|
||||
{
|
||||
size_t inLen = inPath.length();
|
||||
if (inLen == 0)
|
||||
@@ -81,64 +82,27 @@ bool RealPath(const std::string ¤tDirectory, const std::string &inPath, st
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string curDirPrefix;
|
||||
size_t curDirColon = std::string::npos, curDirLen = currentDirectory.length();
|
||||
if (curDirLen != 0)
|
||||
{
|
||||
curDirColon = currentDirectory.find(':');
|
||||
|
||||
if (curDirColon == std::string::npos)
|
||||
{
|
||||
DEBUG_LOG(HLE, "RealPath: currentDirectory has no prefix: \"%s\"", currentDirectory.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (curDirColon + 1 == curDirLen)
|
||||
DEBUG_LOG(HLE, "RealPath: currentDirectory is all prefix and no path: \"%s\"", currentDirectory.c_str());
|
||||
|
||||
curDirPrefix = currentDirectory.substr(0, curDirColon + 1);
|
||||
}
|
||||
}
|
||||
|
||||
std::string inPrefix, inAfter;
|
||||
|
||||
if (inColon == std::string::npos)
|
||||
{
|
||||
inPrefix = curDirPrefix;
|
||||
inAfter = inPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
inPrefix = inPath.substr(0, inColon + 1);
|
||||
inAfter = inPath.substr(inColon + 1);
|
||||
}
|
||||
|
||||
bool relative = (inColon == std::string::npos);
|
||||
|
||||
std::string prefix, inAfterColon;
|
||||
std::vector<std::string> cmpnts; // path components
|
||||
size_t capacityGuess = inPath.length();
|
||||
size_t outPathCapacityGuess = inPath.length();
|
||||
|
||||
// Special hack for strange root paths.
|
||||
// Don't understand why this is needed. I don't think the current
|
||||
// directory should be the root.
|
||||
if (inAfter.substr(0, 11) == "./PSP_GAME/")
|
||||
inAfter = inAfter.substr(1);
|
||||
|
||||
if ((inAfter[0] != '/'))
|
||||
if (relative)
|
||||
{
|
||||
size_t curDirLen = currentDirectory.length();
|
||||
if (curDirLen == 0)
|
||||
{
|
||||
ERROR_LOG(HLE, "RealPath: inPath \"%s\" is relative, but current directory is empty", inPath.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (curDirColon == std::string::npos || curDirPrefix.length() == 0)
|
||||
size_t curDirColon = currentDirectory.find(':');
|
||||
if (curDirColon == std::string::npos)
|
||||
{
|
||||
ERROR_LOG(HLE, "RealPath: inPath \"%s\" is relative, but current directory \"%s\" has no prefix", inPath.c_str(), currentDirectory.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (inPrefix != curDirPrefix)
|
||||
WARN_LOG(HLE, "RealPath: inPath \"%s\" is relative, but specifies a different prefix than current directory \"%s\"", inPath.c_str(), currentDirectory.c_str());
|
||||
|
||||
if (curDirColon + 1 == curDirLen)
|
||||
{
|
||||
ERROR_LOG(HLE, "RealPath: inPath \"%s\" is relative, but current directory \"%s\" is all prefix and no path. Using \"/\" as path for current directory.", inPath.c_str(), currentDirectory.c_str());
|
||||
@@ -146,26 +110,34 @@ bool RealPath(const std::string ¤tDirectory, const std::string &inPath, st
|
||||
else
|
||||
{
|
||||
const std::string curDirAfter = currentDirectory.substr(curDirColon + 1);
|
||||
if (! applyPathStringToComponentsVector(cmpnts, curDirAfter) )
|
||||
if (! ApplyPathStringToComponentsVector(cmpnts, curDirAfter) )
|
||||
{
|
||||
ERROR_LOG(HLE,"RealPath: currentDirectory is not a valid path: \"%s\"", currentDirectory.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
outPathCapacityGuess += curDirLen;
|
||||
}
|
||||
|
||||
capacityGuess += currentDirectory.length();
|
||||
prefix = currentDirectory.substr(0, curDirColon + 1);
|
||||
inAfterColon = inPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
prefix = inPath.substr(0, inColon + 1);
|
||||
inAfterColon = inPath.substr(inColon + 1);
|
||||
}
|
||||
|
||||
if (! applyPathStringToComponentsVector(cmpnts, inAfter) )
|
||||
if (! ApplyPathStringToComponentsVector(cmpnts, inAfterColon) )
|
||||
{
|
||||
DEBUG_LOG(HLE, "RealPath: inPath is not a valid path: \"%s\"", inPath.c_str());
|
||||
WARN_LOG(HLE, "RealPath: inPath is not a valid path: \"%s\"", inPath.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
outPath.clear();
|
||||
outPath.reserve(capacityGuess);
|
||||
outPath.reserve(outPathCapacityGuess);
|
||||
|
||||
outPath.append(inPrefix);
|
||||
outPath.append(prefix);
|
||||
|
||||
size_t numCmpnts = cmpnts.size();
|
||||
for (size_t i = 0; i < numCmpnts; i++)
|
||||
@@ -188,31 +160,37 @@ IFileSystem *MetaFileSystem::GetHandleOwner(u32 handle)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool MetaFileSystem::MapFilePath(std::string inpath, std::string &outpath, IFileSystem **system)
|
||||
bool MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpath, IFileSystem **system)
|
||||
{
|
||||
//TODO: implement current directory per thread (NOT per drive)
|
||||
|
||||
//DEBUG_LOG(HLE, "MapFilePath: starting with \"%s\"", inpath.c_str());
|
||||
std::string realpath;
|
||||
|
||||
if ( RealPath(currentDirectory, inpath, inpath) )
|
||||
// Special handling: host0:command.txt (as seen in Super Monkey Ball Adventures, for example)
|
||||
// appears to mean the current directory on the UMD. Let's just assume the current directory.
|
||||
std::string inpath = _inpath;
|
||||
if (inpath.substr(0, 6) == "host0:") {
|
||||
INFO_LOG(HLE, "Host0 path detected, stripping: %s", inpath.c_str());
|
||||
inpath = inpath.substr(6);
|
||||
}
|
||||
|
||||
if ( RealPath(currentDirectory, inpath, realpath) )
|
||||
{
|
||||
for (size_t i = 0; i < fileSystems.size(); i++)
|
||||
{
|
||||
size_t prefLen = fileSystems[i].prefix.size();
|
||||
if (fileSystems[i].prefix == inpath.substr(0, prefLen))
|
||||
if (fileSystems[i].prefix == realpath.substr(0, prefLen))
|
||||
{
|
||||
outpath = inpath.substr(prefLen);
|
||||
outpath = realpath.substr(prefLen);
|
||||
*system = fileSystems[i].system;
|
||||
|
||||
DEBUG_LOG(HLE, "MapFilePath: mapped to prefix: \"%s\", path: \"%s\"", fileSystems[i].prefix.c_str(), outpath.c_str());
|
||||
DEBUG_LOG(HLE, "MapFilePath: mapped \"%s\" to prefix: \"%s\", path: \"%s\"", inpath.c_str(), fileSystems[i].prefix.c_str(), outpath.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_LOG(HLE, "MapFilePath: failed, returning false");
|
||||
|
||||
DEBUG_LOG(HLE, "MapFilePath: failed mapping \"%s\", returning false", inpath.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -389,3 +367,22 @@ size_t MetaFileSystem::SeekFile(u32 handle, s32 position, FileMove type)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MetaFileSystem::DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(current);
|
||||
p.Do(currentDirectory);
|
||||
|
||||
int n = (int) fileSystems.size();
|
||||
p.Do(n);
|
||||
if (n != fileSystems.size())
|
||||
{
|
||||
ERROR_LOG(FILESYS, "Savestate failure: number of filesystems doesn't match.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; ++i)
|
||||
fileSystems[i].system->DoState(p);
|
||||
|
||||
p.DoMarker("MetaFileSystem");
|
||||
}
|
||||
|
||||
@@ -36,8 +36,10 @@ public:
|
||||
u32 GetNewHandle() {return current++;}
|
||||
void FreeHandle(u32 handle) {}
|
||||
|
||||
virtual void DoState(PointerWrap &p);
|
||||
|
||||
IFileSystem *GetHandleOwner(u32 handle);
|
||||
bool MapFilePath(std::string inpath, std::string &outpath, IFileSystem **system);
|
||||
bool MapFilePath(const std::string &inpath, std::string &outpath, IFileSystem **system);
|
||||
|
||||
std::vector<PSPFileInfo> GetDirListing(std::string path);
|
||||
u32 OpenFile(std::string filename, FileAccess access);
|
||||
|
||||
@@ -136,7 +136,10 @@ template<u32 func(int)> void WrapU_I() {
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
|
||||
template<u32 func(int, int, u32)> void WrapU_IIU() {
|
||||
u32 retval = func(PARAM(0), PARAM(1), PARAM(2));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<int func(int)> void WrapI_I() {
|
||||
int retval = func(PARAM(0));
|
||||
@@ -183,6 +186,11 @@ template<u32 func(u32, u32)> void WrapU_UU() {
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(const char *, u32, u32, u32)> void WrapU_CUUU() {
|
||||
u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<void func(u32, int, u32, int, int)> void WrapV_UIUII() {
|
||||
func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4));
|
||||
}
|
||||
@@ -234,6 +242,11 @@ template<int func(int, int, int)> void WrapI_III() {
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<int func(int, int, int, int)> void WrapI_IIII() {
|
||||
int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<int func(int, int, u32)> void WrapI_IIU() {
|
||||
int retval = func(PARAM(0), PARAM(1), PARAM(2));
|
||||
RETURN(retval);
|
||||
@@ -301,11 +314,31 @@ template<u32 func(int, int, int)> void WrapU_III() {
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(int, int)> void WrapU_II() {
|
||||
u32 retval = func(PARAM(0), PARAM(1));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(int, int, int, int)> void WrapU_IIII() {
|
||||
u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(int, u32, u32)> void WrapU_IUU() {
|
||||
u32 retval = func(PARAM(0), PARAM(1), PARAM(2));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(int, u32, u32, u32)> void WrapU_IUUU() {
|
||||
u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(int, u32, u32, u32, u32)> void WrapU_IUUUU() {
|
||||
u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(u32, u32, u32)> void WrapU_UUU() {
|
||||
u32 retval = func(PARAM(0), PARAM(1), PARAM(2));
|
||||
RETURN(retval);
|
||||
@@ -415,6 +448,11 @@ template<u32 func(const char *, int)> void WrapU_CI() {
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(const char *, int, int)> void WrapU_CII() {
|
||||
int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<int func(const char *, int, u32, int, u32)> void WrapU_CIUIU() {
|
||||
int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2),
|
||||
PARAM(3), PARAM(4));
|
||||
|
||||
+62
-4
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "HLE.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "../MemMap.h"
|
||||
|
||||
#include "HLETables.h"
|
||||
@@ -26,7 +27,9 @@
|
||||
#include "sceAudio.h"
|
||||
#include "sceKernelMemory.h"
|
||||
#include "sceKernelThread.h"
|
||||
#include "sceKernelInterrupt.h"
|
||||
#include "../MIPS/MIPSCodeUtils.h"
|
||||
#include "../Host.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -40,6 +43,10 @@ enum
|
||||
HLE_AFTER_ALL_CALLBACKS = 0x04,
|
||||
// Reschedule and process current thread's callbacks after the syscall.
|
||||
HLE_AFTER_RESCHED_CALLBACKS = 0x08,
|
||||
// Run interrupts (and probably reschedule) after the syscall.
|
||||
HLE_AFTER_RUN_INTERRUPTS = 0x10,
|
||||
// Switch to CORE_STEPPING after the syscall (for debugging.)
|
||||
HLE_AFTER_DEBUG_BREAK = 0x20,
|
||||
};
|
||||
|
||||
static std::vector<HLEModule> moduleDB;
|
||||
@@ -52,9 +59,18 @@ void HLEInit()
|
||||
RegisterAllModules();
|
||||
}
|
||||
|
||||
void HLEDoState(PointerWrap &p)
|
||||
{
|
||||
Syscall sc = {0};
|
||||
p.Do(unresolvedSyscalls, sc);
|
||||
p.DoMarker("HLE");
|
||||
}
|
||||
|
||||
void HLEShutdown()
|
||||
{
|
||||
hleAfterSyscall = HLE_AFTER_NOTHING;
|
||||
moduleDB.clear();
|
||||
unresolvedSyscalls.clear();
|
||||
}
|
||||
|
||||
void RegisterModule(const char *name, int numFunctions, const HLEFunction *funcTable)
|
||||
@@ -208,7 +224,7 @@ void hleCheckCurrentCallbacks()
|
||||
void hleReSchedule(const char *reason)
|
||||
{
|
||||
_dbg_assert_msg_(HLE, reason != 0, "hleReSchedule: Expecting a valid reason.");
|
||||
_dbg_assert_msg_(HLE, strlen(reason) < 256, "hleReSchedule: Not too long reason.");
|
||||
_dbg_assert_msg_(HLE, reason != 0 && strlen(reason) < 256, "hleReSchedule: Not too long reason.");
|
||||
|
||||
hleAfterSyscall |= HLE_AFTER_RESCHED;
|
||||
|
||||
@@ -231,11 +247,42 @@ void hleReSchedule(bool callbacks, const char *reason)
|
||||
hleAfterSyscall |= HLE_AFTER_RESCHED_CALLBACKS;
|
||||
}
|
||||
|
||||
inline void hleFinishSyscall()
|
||||
void hleRunInterrupts()
|
||||
{
|
||||
hleAfterSyscall |= HLE_AFTER_RUN_INTERRUPTS;
|
||||
}
|
||||
|
||||
void hleDebugBreak()
|
||||
{
|
||||
hleAfterSyscall |= HLE_AFTER_DEBUG_BREAK;
|
||||
}
|
||||
|
||||
// Pauses execution after an HLE call.
|
||||
bool hleExecuteDebugBreak(const HLEFunction &func)
|
||||
{
|
||||
const u32 NID_SUSPEND_INTR = 0x092968F4, NID_RESUME_INTR = 0x5F10D406;
|
||||
|
||||
// Never break on these, they're noise.
|
||||
u32 blacklistedNIDs[] = {NID_SUSPEND_INTR, NID_RESUME_INTR, NID_IDLE};
|
||||
for (int i = 0; i < ARRAY_SIZE(blacklistedNIDs); ++i)
|
||||
{
|
||||
if (func.ID == blacklistedNIDs[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
Core_EnableStepping(true);
|
||||
host->SetDebugMode(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void hleFinishSyscall(int modulenum, int funcnum)
|
||||
{
|
||||
if ((hleAfterSyscall & HLE_AFTER_CURRENT_CALLBACKS) != 0)
|
||||
__KernelForceCallbacks();
|
||||
|
||||
if ((hleAfterSyscall & HLE_AFTER_RUN_INTERRUPTS) != 0)
|
||||
__RunOnePendingInterrupt();
|
||||
|
||||
// Rescheduling will also do HLE_AFTER_ALL_CALLBACKS.
|
||||
if ((hleAfterSyscall & HLE_AFTER_RESCHED_CALLBACKS) != 0)
|
||||
__KernelReSchedule(true, hleAfterSyscallReschedReason);
|
||||
@@ -244,6 +291,17 @@ inline void hleFinishSyscall()
|
||||
else if ((hleAfterSyscall & HLE_AFTER_ALL_CALLBACKS) != 0)
|
||||
__KernelCheckCallbacks();
|
||||
|
||||
if ((hleAfterSyscall & HLE_AFTER_DEBUG_BREAK) != 0)
|
||||
{
|
||||
if (!hleExecuteDebugBreak(moduleDB[modulenum].funcTable[funcnum]))
|
||||
{
|
||||
// We'll do it next syscall.
|
||||
hleAfterSyscall = HLE_AFTER_DEBUG_BREAK;
|
||||
hleAfterSyscallReschedReason[0] = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
hleAfterSyscall = HLE_AFTER_NOTHING;
|
||||
hleAfterSyscallReschedReason[0] = 0;
|
||||
}
|
||||
@@ -253,7 +311,7 @@ void CallSyscall(u32 op)
|
||||
u32 callno = (op >> 6) & 0xFFFFF; //20 bits
|
||||
int funcnum = callno & 0xFFF;
|
||||
int modulenum = (callno & 0xFF000) >> 12;
|
||||
if (funcnum == 0xfff)
|
||||
if (funcnum == 0xfff || op == 0xffff)
|
||||
{
|
||||
_dbg_assert_msg_(HLE,0,"Unknown syscall");
|
||||
ERROR_LOG(HLE,"Unknown syscall: Module: %s", moduleDB[modulenum].name);
|
||||
@@ -265,7 +323,7 @@ void CallSyscall(u32 op)
|
||||
func();
|
||||
|
||||
if (hleAfterSyscall != HLE_AFTER_NOTHING)
|
||||
hleFinishSyscall();
|
||||
hleFinishSyscall(modulenum, funcnum);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+5
-4
@@ -81,8 +81,13 @@ void hleCheckAllCallbacks();
|
||||
void hleReSchedule(const char *reason);
|
||||
// Reschedule and go into a callback processing state after the syscall finishes.
|
||||
void hleReSchedule(bool callbacks, const char *reason);
|
||||
// Run interrupts after the syscall finishes.
|
||||
void hleRunInterrupts();
|
||||
// Pause emulation after the syscall finishes.
|
||||
void hleDebugBreak();
|
||||
|
||||
void HLEInit();
|
||||
void HLEDoState(PointerWrap &p);
|
||||
void HLEShutdown();
|
||||
u32 GetNibByName(const char *module, const char *function);
|
||||
u32 GetSyscallOp(const char *module, u32 nib);
|
||||
@@ -90,7 +95,3 @@ void WriteSyscall(const char *module, u32 nib, u32 address);
|
||||
void CallSyscall(u32 op);
|
||||
void ResolveSyscall(const char *moduleName, u32 nib, u32 address);
|
||||
|
||||
// Need to be able to save entire kernel state
|
||||
int GetStateSize();
|
||||
void SaveState(u8 *ptr);
|
||||
void LoadState(const u8 *ptr);
|
||||
@@ -77,7 +77,7 @@ const HLEFunction UtilsForUser[] =
|
||||
{0x91E4F6A7, WrapU_V<sceKernelLibcClock>, "sceKernelLibcClock"},
|
||||
{0x27CC57F0, sceKernelLibcTime, "sceKernelLibcTime"},
|
||||
{0x71EC4271, sceKernelLibcGettimeofday, "sceKernelLibcGettimeofday"},
|
||||
{0xBFA98062, 0, "sceKernelDcacheInvalidateRange"},
|
||||
{0xBFA98062, WrapV_UI<sceKernelDcacheInvalidateRange>, "sceKernelDcacheInvalidateRange"},
|
||||
{0xC8186A58, 0, "sceKernelUtilsMd5Digest"},
|
||||
{0x9E5C5086, 0, "sceKernelUtilsMd5BlockInit"},
|
||||
{0x61E1E525, 0, "sceKernelUtilsMd5BlockUpdate"},
|
||||
@@ -92,8 +92,8 @@ const HLEFunction UtilsForUser[] =
|
||||
{0x6AD345D7, sceKernelSetGPO, "sceKernelSetGPO"},
|
||||
{0x79D1C3FA, sceKernelDcacheWritebackAll, "sceKernelDcacheWritebackAll"},
|
||||
{0xB435DEC5, sceKernelDcacheWritebackInvalidateAll, "sceKernelDcacheWritebackInvalidateAll"},
|
||||
{0x3EE30821, sceKernelDcacheWritebackRange, "sceKernelDcacheWritebackRange"},
|
||||
{0x34B9FA9E, sceKernelDcacheWritebackInvalidateRange, "sceKernelDcacheWritebackInvalidateRange"},
|
||||
{0x3EE30821, WrapV_UI<sceKernelDcacheWritebackRange>, "sceKernelDcacheWritebackRange"},
|
||||
{0x34B9FA9E, WrapV_UI<sceKernelDcacheWritebackInvalidateRange>, "sceKernelDcacheWritebackInvalidateRange"},
|
||||
{0xC2DF770E, 0, "sceKernelIcacheInvalidateRange"},
|
||||
{0x80001C4C, 0, "sceKernelDcacheProbe"},
|
||||
{0x16641D70, 0, "sceKernelDcacheReadTag"},
|
||||
|
||||
+49
-21
@@ -28,20 +28,15 @@
|
||||
#include "FixedSizeQueue.h"
|
||||
#include "Common/Thread.h"
|
||||
|
||||
// While buffers == MAX_BUFFERS, block on blocking write
|
||||
// non-blocking writes will return busy, I guess
|
||||
|
||||
#define MAX_BUFFERS 2
|
||||
#define MIN_BUFFERS 1
|
||||
|
||||
std::recursive_mutex section;
|
||||
|
||||
int eventAudioUpdate = -1;
|
||||
int eventHostAudioUpdate = -1;
|
||||
int mixFrequency = 44100;
|
||||
|
||||
const int hwSampleRate = 44100;
|
||||
const int hwBlockSize = 480;
|
||||
const int hostAttemptBlockSize = 64;
|
||||
const int hwBlockSize = 60;
|
||||
const int hostAttemptBlockSize = 256;
|
||||
const int audioIntervalUs = (int)(1000000ULL * hwBlockSize / hwSampleRate);
|
||||
const int audioHostIntervalUs = (int)(1000000ULL * hostAttemptBlockSize / hwSampleRate);
|
||||
|
||||
@@ -49,20 +44,20 @@ const int audioHostIntervalUs = (int)(1000000ULL * hostAttemptBlockSize / hwSamp
|
||||
const int chanQueueMaxSizeFactor = 4;
|
||||
const int chanQueueMinSizeFactor = 1;
|
||||
|
||||
FixedSizeQueue<s16, hwBlockSize * 8> outAudioQueue;
|
||||
FixedSizeQueue<s16, hostAttemptBlockSize * 16> outAudioQueue;
|
||||
|
||||
|
||||
void hleAudioUpdate(u64 userdata, int cyclesLate)
|
||||
{
|
||||
__AudioUpdate();
|
||||
|
||||
CoreTiming::ScheduleEvent(usToCycles(audioIntervalUs), eventAudioUpdate, 0);
|
||||
CoreTiming::ScheduleEvent(usToCycles(audioIntervalUs) - cyclesLate, eventAudioUpdate, 0);
|
||||
}
|
||||
|
||||
void hleHostAudioUpdate(u64 userdata, int cyclesLate)
|
||||
{
|
||||
host->UpdateSound();
|
||||
CoreTiming::ScheduleEvent(usToCycles(audioHostIntervalUs), eventHostAudioUpdate, 0);
|
||||
CoreTiming::ScheduleEvent(usToCycles(audioHostIntervalUs) - cyclesLate, eventHostAudioUpdate, 0);
|
||||
}
|
||||
|
||||
void __AudioInit()
|
||||
@@ -78,6 +73,33 @@ void __AudioInit()
|
||||
chans[i].clear();
|
||||
}
|
||||
|
||||
void __AudioDoState(PointerWrap &p)
|
||||
{
|
||||
section.lock();
|
||||
|
||||
p.Do(eventAudioUpdate);
|
||||
CoreTiming::RestoreRegisterEvent(eventAudioUpdate, "AudioUpdate", &hleAudioUpdate);
|
||||
p.Do(eventHostAudioUpdate);
|
||||
CoreTiming::RestoreRegisterEvent(eventHostAudioUpdate, "AudioUpdateHost", &hleAudioUpdate);
|
||||
|
||||
p.Do(mixFrequency);
|
||||
outAudioQueue.DoState(p);
|
||||
|
||||
int chanCount = ARRAY_SIZE(chans);
|
||||
p.Do(chanCount);
|
||||
if (chanCount != ARRAY_SIZE(chans))
|
||||
{
|
||||
ERROR_LOG(HLE, "Savestate failure: different number of audio channels.");
|
||||
section.unlock();
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < chanCount; ++i)
|
||||
chans[i].DoState(p);
|
||||
|
||||
section.unlock();
|
||||
p.DoMarker("sceAudio");
|
||||
}
|
||||
|
||||
void __AudioShutdown()
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
@@ -137,12 +159,12 @@ void __AudioUpdate()
|
||||
s32 mixBuffer[hwBlockSize * 2];
|
||||
memset(mixBuffer, 0, sizeof(mixBuffer));
|
||||
|
||||
for (int i = 0; i < MAX_CHANNEL; i++)
|
||||
for (int i = 0; i < PSP_AUDIO_CHANNEL_MAX; i++)
|
||||
{
|
||||
if (!chans[i].reserved)
|
||||
continue;
|
||||
if (!chans[i].sampleQueue.size()) {
|
||||
// DEBUG_LOG(HLE, "No queued samples, skipping channel %i", i);
|
||||
// ERROR_LOG(HLE, "No queued samples, skipping channel %i", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -178,14 +200,20 @@ void __AudioUpdate()
|
||||
|
||||
section.lock();
|
||||
|
||||
if (g_Config.bEnableSound && outAudioQueue.room() >= hwBlockSize * 2) {
|
||||
// Push the mixed samples onto the output audio queue.
|
||||
for (int i = 0; i < hwBlockSize; i++) {
|
||||
s32 sampleL = mixBuffer[i * 2] >> 2; // TODO - what factor?
|
||||
s32 sampleR = mixBuffer[i * 2 + 1] >> 2;
|
||||
if (g_Config.bEnableSound) {
|
||||
if (outAudioQueue.room() >= hwBlockSize * 2) {
|
||||
// Push the mixed samples onto the output audio queue.
|
||||
for (int i = 0; i < hwBlockSize; i++) {
|
||||
s32 sampleL = mixBuffer[i * 2] >> 2; // TODO - what factor?
|
||||
s32 sampleR = mixBuffer[i * 2 + 1] >> 2;
|
||||
|
||||
outAudioQueue.push((s16)sampleL);
|
||||
outAudioQueue.push((s16)sampleR);
|
||||
outAudioQueue.push((s16)sampleL);
|
||||
outAudioQueue.push((s16)sampleR);
|
||||
}
|
||||
} else {
|
||||
// This happens quite a lot. There's still something slightly off
|
||||
// about the amount of audio we produce.
|
||||
DEBUG_LOG(HLE, "Audio outbuffer overrun! room = %i / %i", outAudioQueue.room(), (u32)outAudioQueue.capacity());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,7 +253,7 @@ int __AudioMix(short *outstereo, int numFrames)
|
||||
}
|
||||
}
|
||||
if (anythingToPlay && underrun >= 0) {
|
||||
ERROR_LOG(HLE, "audio out buffer UNDERRUN at %i of %i", underrun, numFrames);
|
||||
DEBUG_LOG(HLE, "audio out buffer UNDERRUN at %i of %i", underrun, numFrames);
|
||||
} else {
|
||||
// DEBUG_LOG(HLE, "No underrun, mixed %i samples fine", numFrames);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
// Easy interface for sceAudio to write to, to keep the complexity in check.
|
||||
|
||||
void __AudioInit();
|
||||
void __AudioDoState(PointerWrap &p);
|
||||
void __AudioUpdate();
|
||||
void __AudioShutdown();
|
||||
void __AudioSetOutputFrequency(int freq);
|
||||
|
||||
+125
-97
@@ -28,13 +28,15 @@
|
||||
#define ATRAC_ERROR_API_FAIL 0x80630002
|
||||
#define ATRAC_ERROR_ALL_DATA_DECODED 0x80630024
|
||||
|
||||
int sceAtracAddStreamData(int atracID, u32 bytesToAdd)
|
||||
|
||||
|
||||
u32 sceAtracAddStreamData(int atracID, u32 bytesToAdd)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracAddStreamData(%i, %i)", atracID, bytesToAdd);
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracAddStreamData(%i, %08x)", atracID, bytesToAdd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceAtracDecodeData(int atracID, u32 outAddr, u32 numSamplesAddr, u32 finishFlagAddr, u32 remainAddr)
|
||||
u32 sceAtracDecodeData(int atracID, u32 outAddr, u32 numSamplesAddr, u32 finishFlagAddr, u32 remainAddr)
|
||||
{
|
||||
ERROR_LOG(HLE, "FAKE sceAtracDecodeData(%i, %08x, %08x, %08x, %08x)", atracID, outAddr, numSamplesAddr, finishFlagAddr, remainAddr);
|
||||
|
||||
@@ -48,76 +50,82 @@ int sceAtracDecodeData(int atracID, u32 outAddr, u32 numSamplesAddr, u32 finishF
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceAtracEndEntry()
|
||||
u32 sceAtracEndEntry()
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracEndEntry");
|
||||
RETURN(0);
|
||||
}
|
||||
|
||||
void sceAtracGetAtracID()
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracGetAtracID");
|
||||
RETURN(0);
|
||||
}
|
||||
|
||||
void sceAtracGetBufferInfoForReseting()
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracGetBufferInfoForReseting");
|
||||
RETURN(0);
|
||||
}
|
||||
|
||||
int sceAtracGetBitrate(int atracID, u32 outBitrateAddr)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracGetBitrate");
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracEndEntry(.)");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceAtracGetChannel()
|
||||
u32 sceAtracGetAtracID(int codecType)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracGetChannel");
|
||||
RETURN(0);
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracGetAtracID(%i)", codecType);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void sceAtracGetLoopStatus()
|
||||
u32 sceAtracGetBufferInfoForReseting(int atracID, int sample, u32 bufferInfoAddr)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracGetLoopStatus");
|
||||
RETURN(0);
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracGetBufferInfoForReseting(%i, %i, %08x)",atracID, sample, bufferInfoAddr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceAtracGetInternalErrorInfo()
|
||||
u32 sceAtracGetBitrate(int atracID, u32 outBitrateAddr)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracGetInternalErrorInfo");
|
||||
RETURN(0);
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracGetBitrate(%i, %08x)", atracID, outBitrateAddr);
|
||||
if (Memory::IsValidAddress(outBitrateAddr))
|
||||
Memory::Write_U32(64, outBitrateAddr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceAtracGetMaxSample()
|
||||
u32 sceAtracGetChannel(int atracID, u32 channelAddr)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracGetMaxSample");
|
||||
RETURN(0);
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracGetChannel(%i, %08x)", atracID, channelAddr);
|
||||
if (Memory::IsValidAddress(channelAddr))
|
||||
Memory::Write_U32(2, channelAddr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceAtracGetNextDecodePosition(int atracID, u32 outposAddr)
|
||||
u32 sceAtracGetLoopStatus(int atracID, u32 loopNbr, u32 statusAddr)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracGetLoopStatus(%i, %08x, %08x)", atracID, loopNbr, statusAddr );
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 sceAtracGetInternalErrorInfo(int atracID, u32 errorAddr)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracGetInternalErrorInfo(%i, %08x)", atracID, errorAddr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 sceAtracGetMaxSample(int atracID, u32 maxSamplesAddr)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracGetMaxSample(%i, %08x)", atracID, maxSamplesAddr);
|
||||
if (Memory::IsValidAddress(maxSamplesAddr))
|
||||
Memory::Write_U32(1024, maxSamplesAddr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 sceAtracGetNextDecodePosition(int atracID, u32 outposAddr)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracGetNextDecodePosition(%i, %08x)", atracID, outposAddr);
|
||||
Memory::Write_U32(1, outposAddr); // outpos
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceAtracGetNextSample(int atracID, u32 outNAddr)
|
||||
u32 sceAtracGetNextSample(int atracID, u32 outNAddr)
|
||||
{
|
||||
ERROR_LOG(HLE, "FAKE sceAtracGetNextSample(%i, %08x)", atracID, outNAddr);
|
||||
Memory::Write_U32(0, outNAddr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceAtracGetRemainFrame(int atracID, u32 outposAddr)
|
||||
u32 sceAtracGetRemainFrame(int atracID, u32 outposAddr)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceAtracGetRemainFrame(%i, %08x)", atracID, outposAddr);
|
||||
Memory::Write_U32(12, outposAddr); // outpos
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceAtracGetSecondBufferInfo(int atracID, u32 outposAddr, u32 outBytesAddr)
|
||||
u32 sceAtracGetSecondBufferInfo(int atracID, u32 outposAddr, u32 outBytesAddr)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceAtracGetSecondBufferInfo(%i, %08x, %08x)", atracID, outposAddr, outBytesAddr);
|
||||
Memory::Write_U32(0, outposAddr); // outpos
|
||||
@@ -125,7 +133,7 @@ int sceAtracGetSecondBufferInfo(int atracID, u32 outposAddr, u32 outBytesAddr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceAtracGetSoundSample(int atracID, u32 outEndSampleAddr, u32 outLoopStartSampleAddr, u32 outLoopEndSampleAddr)
|
||||
u32 sceAtracGetSoundSample(int atracID, u32 outEndSampleAddr, u32 outLoopStartSampleAddr, u32 outLoopEndSampleAddr)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracGetSoundSample(%i, %08x, %08x, %08x)", atracID, outEndSampleAddr, outLoopStartSampleAddr, outLoopEndSampleAddr);
|
||||
Memory::Write_U32(0x10000, outEndSampleAddr); // outEndSample
|
||||
@@ -134,7 +142,7 @@ int sceAtracGetSoundSample(int atracID, u32 outEndSampleAddr, u32 outLoopStartSa
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceAtracGetStreamDataInfo(int atracID, u32 writePointerAddr, u32 availableBytesAddr, u32 readOffsetAddr)
|
||||
u32 sceAtracGetStreamDataInfo(int atracID, u32 writePointerAddr, u32 availableBytesAddr, u32 readOffsetAddr)
|
||||
{
|
||||
ERROR_LOG(HLE, "FAKE sceAtracGetStreamDataInfo(%i, %08x, %08x, %08x)", atracID, writePointerAddr, availableBytesAddr, readOffsetAddr);
|
||||
Memory::Write_U32(0, readOffsetAddr);
|
||||
@@ -143,58 +151,58 @@ int sceAtracGetStreamDataInfo(int atracID, u32 writePointerAddr, u32 availableBy
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceAtracReleaseAtracID()
|
||||
u32 sceAtracReleaseAtracID(int atracID)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracReleaseAtracID");
|
||||
RETURN(0);
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracReleaseAtracID(%i)", atracID);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceAtracResetPlayPosition()
|
||||
u32 sceAtracResetPlayPosition(int atracID, int sample, int bytesWrittenFirstBuf, int bytesWrittenSecondBuf)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracResetPlayPosition");
|
||||
RETURN(0);
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracResetPlayPosition(%i, %i, %i, %i)", atracID, sample, bytesWrittenFirstBuf, bytesWrittenSecondBuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceAtracSetHalfwayBuffer()
|
||||
u32 sceAtracSetHalfwayBuffer(int atracID, u32 halfBuffer, u32 readSize, u32 halfBufferSize)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracSetHalfwayBuffer");
|
||||
RETURN(0);
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracSetHalfwayBuffer(%i, %08x, %8x, %8x)", atracID, halfBuffer, readSize, halfBufferSize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceAtracSetSecondBuffer()
|
||||
u32 sceAtracSetSecondBuffer(int atracID, u32 secondBuffer, u32 secondBufferSize)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracSetSecondBuffer(%i, %08x, %i)", PARAM(0),PARAM(1),PARAM(2));
|
||||
RETURN(0);
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracSetSecondBuffer(%i, %08x, %8x)", atracID, secondBuffer, secondBufferSize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceAtracSetData()
|
||||
u32 sceAtracSetData(int atracID, u32 buffer, u32 bufferSize)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracSetData");
|
||||
RETURN(0);
|
||||
} //?
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracSetData(%i, %08x, %08x)", atracID, buffer, bufferSize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceAtracSetDataAndGetID()
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracSetDataAndGetID(%08x, %i)", PARAM(0), PARAM(1));
|
||||
RETURN(1);
|
||||
int sceAtracSetDataAndGetID(u32 buffer, u32 bufferSize)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracSetDataAndGetID(%08x, %08x)", buffer, bufferSize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceAtracSetHalfwayBufferAndGetID()
|
||||
int sceAtracSetHalfwayBufferAndGetID(int atracID, u32 halfBuffer, u32 readSize, u32 halfBufferSize)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracSetHalfwayBufferAndGetID");
|
||||
RETURN(0);
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracSetHalfwayBufferAndGetID(%i, %08x, %08x, %08x)", atracID, halfBuffer, readSize, halfBufferSize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceAtracStartEntry()
|
||||
u32 sceAtracStartEntry()
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracStartEntry");
|
||||
RETURN(0);
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracStartEntry(.)");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceAtracSetLoopNum()
|
||||
u32 sceAtracSetLoopNum(int atracID, int loopNum)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracSetLoopNum(%i, %i)", PARAM(0), PARAM(1));
|
||||
RETURN(0);
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracSetLoopNum(%i, %i)", atracID, loopNum);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceAtracReinit()
|
||||
@@ -203,37 +211,57 @@ int sceAtracReinit()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceAtracGetOutputChannel(int atracID, u32 outputChanPtr)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracGetOutputChannel(%i, %08x)", atracID, outputChanPtr);
|
||||
if (Memory::IsValidAddress(outputChanPtr))
|
||||
Memory::Write_U32(2, outputChanPtr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceAtracIsSecondBufferNeeded(int atracID)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceAtracIsSecondBufferNeeded(%i)", atracID);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const HLEFunction sceAtrac3plus[] =
|
||||
{
|
||||
{0x7db31251,WrapI_IU<sceAtracAddStreamData>,"sceAtracAddStreamData"},
|
||||
{0x6a8c3cd5,WrapI_IUUUU<sceAtracDecodeData>,"sceAtracDecodeData"},
|
||||
{0xd5c28cc0,sceAtracEndEntry,"sceAtracEndEntry"},
|
||||
{0x780f88d1,sceAtracGetAtracID,"sceAtracGetAtracID"},
|
||||
{0xca3ca3d2,sceAtracGetBufferInfoForReseting,"sceAtracGetBufferInfoForReseting"},
|
||||
{0xa554a158,WrapI_IU<sceAtracGetBitrate>,"sceAtracGetBitrate"},
|
||||
{0x31668baa,sceAtracGetChannel,"sceAtracGetChannel"},
|
||||
{0xfaa4f89b,sceAtracGetLoopStatus,"sceAtracGetLoopStatus"},
|
||||
{0xe88f759b,sceAtracGetInternalErrorInfo,"sceAtracGetInternalErrorInfo"},
|
||||
{0xd6a5f2f7,sceAtracGetMaxSample,"sceAtracGetMaxSample"},
|
||||
{0xe23e3a35,WrapI_IU<sceAtracGetNextDecodePosition>,"sceAtracGetNextDecodePosition"},
|
||||
{0x36faabfb,WrapI_IU<sceAtracGetNextSample>,"sceAtracGetNextSample"},
|
||||
{0x9ae849a7,WrapI_IU<sceAtracGetRemainFrame>,"sceAtracGetRemainFrame"},
|
||||
{0x83e85ea0,WrapI_IUU<sceAtracGetSecondBufferInfo>,"sceAtracGetSecondBufferInfo"},
|
||||
{0xa2bba8be,WrapI_IUUU<sceAtracGetSoundSample>,"sceAtracGetSoundSample"},
|
||||
{0x5d268707,WrapI_IUUU<sceAtracGetStreamDataInfo>,"sceAtracGetStreamDataInfo"},
|
||||
{0x61eb33f5,sceAtracReleaseAtracID,"sceAtracReleaseAtracID"},
|
||||
{0x644e5607,sceAtracResetPlayPosition,"sceAtracResetPlayPosition"},
|
||||
{0x3f6e26b5,sceAtracSetHalfwayBuffer,"sceAtracSetHalfwayBuffer"},
|
||||
{0x83bf7afd,sceAtracSetSecondBuffer,"sceAtracSetSecondBuffer"},
|
||||
{0x0E2A73AB,sceAtracSetData,"sceAtracSetData"}, //?
|
||||
{0x7a20e7af,sceAtracSetDataAndGetID,"sceAtracSetDataAndGetID"},
|
||||
{0xd1f59fdb,sceAtracStartEntry,"sceAtracStartEntry"},
|
||||
{0x868120b5,sceAtracSetLoopNum,"sceAtracSetLoopNum"},
|
||||
{0x7db31251,WrapU_IU<sceAtracAddStreamData>,"sceAtracAddStreamData"},
|
||||
{0x6a8c3cd5,WrapU_IUUUU<sceAtracDecodeData>,"sceAtracDecodeData"},
|
||||
{0xd5c28cc0,WrapU_V<sceAtracEndEntry>,"sceAtracEndEntry"},
|
||||
{0x780f88d1,WrapU_I<sceAtracGetAtracID>,"sceAtracGetAtracID"},
|
||||
{0xca3ca3d2,WrapU_IIU<sceAtracGetBufferInfoForReseting>,"sceAtracGetBufferInfoForReseting"},
|
||||
{0xa554a158,WrapU_IU<sceAtracGetBitrate>,"sceAtracGetBitrate"},
|
||||
{0x31668baa,WrapU_IU<sceAtracGetChannel>,"sceAtracGetChannel"},
|
||||
{0xfaa4f89b,WrapU_IUU<sceAtracGetLoopStatus>,"sceAtracGetLoopStatus"},
|
||||
{0xe88f759b,WrapU_IU<sceAtracGetInternalErrorInfo>,"sceAtracGetInternalErrorInfo"},
|
||||
{0xd6a5f2f7,WrapU_IU<sceAtracGetMaxSample>,"sceAtracGetMaxSample"},
|
||||
{0xe23e3a35,WrapU_IU<sceAtracGetNextDecodePosition>,"sceAtracGetNextDecodePosition"},
|
||||
{0x36faabfb,WrapU_IU<sceAtracGetNextSample>,"sceAtracGetNextSample"},
|
||||
{0x9ae849a7,WrapU_IU<sceAtracGetRemainFrame>,"sceAtracGetRemainFrame"},
|
||||
{0x83e85ea0,WrapU_IUU<sceAtracGetSecondBufferInfo>,"sceAtracGetSecondBufferInfo"},
|
||||
{0xa2bba8be,WrapU_IUUU<sceAtracGetSoundSample>,"sceAtracGetSoundSample"},
|
||||
{0x5d268707,WrapU_IUUU<sceAtracGetStreamDataInfo>,"sceAtracGetStreamDataInfo"},
|
||||
{0x61eb33f5,WrapU_I<sceAtracReleaseAtracID>,"sceAtracReleaseAtracID"},
|
||||
{0x644e5607,WrapU_IIII<sceAtracResetPlayPosition>,"sceAtracResetPlayPosition"},
|
||||
{0x3f6e26b5,WrapU_IUUU<sceAtracSetHalfwayBuffer>,"sceAtracSetHalfwayBuffer"},
|
||||
{0x83bf7afd,WrapU_IUU<sceAtracSetSecondBuffer>,"sceAtracSetSecondBuffer"},
|
||||
{0x0E2A73AB,WrapU_IUU<sceAtracSetData>,"sceAtracSetData"}, //?
|
||||
{0x7a20e7af,WrapI_UU<sceAtracSetDataAndGetID>,"sceAtracSetDataAndGetID"},
|
||||
{0xd1f59fdb,WrapU_V<sceAtracStartEntry>,"sceAtracStartEntry"},
|
||||
{0x868120b5,WrapU_II<sceAtracSetLoopNum>,"sceAtracSetLoopNum"},
|
||||
{0x132f1eca,WrapI_V<sceAtracReinit>,"sceAtracReinit"},
|
||||
{0xeca32a99,0,"sceAtracIsSecondBufferNeeded"},
|
||||
{0x0fae370e,sceAtracSetHalfwayBufferAndGetID,"sceAtracSetHalfwayBufferAndGetID"},
|
||||
{0x2DD3E298,0,"sceAtrac3plus_2DD3E298"},
|
||||
{0xeca32a99,WrapI_I<sceAtracIsSecondBufferNeeded>,"sceAtracIsSecondBufferNeeded"},
|
||||
{0x0fae370e,WrapI_IUUU<sceAtracSetHalfwayBufferAndGetID>,"sceAtracSetHalfwayBufferAndGetID"},
|
||||
{0x2DD3E298,0,"sceAtracGetBufferInfoForResetting"},
|
||||
{0x5CF9D852,0,"sceAtracSetMOutHalfwayBuffer"},
|
||||
{0xB3B5D042,WrapI_IU<sceAtracGetOutputChannel>,"sceAtracGetOutputChannel"},
|
||||
{0xF6837A1A,0,"sceAtracSetMOutData"},
|
||||
{0x472E3825,0,"sceAtracSetMOutDataAndGetID"},
|
||||
{0x9CD7DE03,0,"sceAtracSetMOutHalfwayBufferAndGetID"},
|
||||
{0x5622B7C1,0,"sceAtracSetAA3DataAndGetID"},
|
||||
{0x5DD66588,0,"sceAtracSetAA3HalfwayBufferAndGetID"},
|
||||
};
|
||||
|
||||
|
||||
|
||||
+18
-22
@@ -41,7 +41,7 @@ u32 sceAudioOutputBlocking(u32 chan, u32 vol, u32 samplePtr) {
|
||||
ERROR_LOG(HLE, "sceAudioOutputBlocking - Sample pointer null");
|
||||
return 0;
|
||||
}
|
||||
if (chan < 0 || chan >= MAX_CHANNEL) {
|
||||
if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
||||
ERROR_LOG(HLE,"sceAudioOutputBlocking() - BAD CHANNEL");
|
||||
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
||||
} else if (!chans[chan].reserved) {
|
||||
@@ -60,7 +60,7 @@ u32 sceAudioOutputPannedBlocking(u32 chan, u32 volume1, u32 volume2, u32 sampleP
|
||||
if (samplePtr == 0) {
|
||||
ERROR_LOG(HLE, "sceAudioOutputPannedBlocking - Sample pointer null");
|
||||
return 0;
|
||||
} else if (chan < 0 || chan >= MAX_CHANNEL) {
|
||||
} else if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
||||
ERROR_LOG(HLE,"sceAudioOutputPannedBlocking() - BAD CHANNEL");
|
||||
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
||||
} else if (!chans[chan].reserved) {
|
||||
@@ -77,7 +77,7 @@ u32 sceAudioOutputPannedBlocking(u32 chan, u32 volume1, u32 volume2, u32 sampleP
|
||||
|
||||
u32 sceAudioOutput(u32 chan, u32 vol, u32 samplePtr)
|
||||
{
|
||||
if (chan < 0 || chan >= MAX_CHANNEL) {
|
||||
if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
||||
ERROR_LOG(HLE,"sceAudioOutput() - BAD CHANNEL");
|
||||
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ u32 sceAudioOutput(u32 chan, u32 vol, u32 samplePtr)
|
||||
|
||||
u32 sceAudioOutputPanned(u32 chan, u32 leftVol, u32 rightVol, u32 samplePtr)
|
||||
{
|
||||
if (chan < 0 || chan >= MAX_CHANNEL)
|
||||
if (chan >= PSP_AUDIO_CHANNEL_MAX)
|
||||
{
|
||||
ERROR_LOG(HLE,"sceAudioOutputPanned() - BAD CHANNEL");
|
||||
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
||||
@@ -122,7 +122,7 @@ u32 sceAudioOutputPanned(u32 chan, u32 leftVol, u32 rightVol, u32 samplePtr)
|
||||
|
||||
int sceAudioGetChannelRestLen(u32 chan)
|
||||
{
|
||||
if (chan < 0 || chan >= MAX_CHANNEL)
|
||||
if (chan >= PSP_AUDIO_CHANNEL_MAX)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceAudioGetChannelRestLen(%i) - BAD CHANNEL", chan);
|
||||
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
||||
@@ -135,7 +135,7 @@ int sceAudioGetChannelRestLen(u32 chan)
|
||||
|
||||
int sceAudioGetChannelRestLength(u32 chan)
|
||||
{
|
||||
if (chan < 0 || chan >= MAX_CHANNEL)
|
||||
if (chan >= PSP_AUDIO_CHANNEL_MAX)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceAudioGetChannelRestLength(%i) - BAD CHANNEL", chan);
|
||||
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
||||
@@ -148,13 +148,9 @@ int sceAudioGetChannelRestLength(u32 chan)
|
||||
|
||||
static int GetFreeChannel()
|
||||
{
|
||||
for (int i = 0; i < MAX_CHANNEL; i++)
|
||||
{
|
||||
for (int i = 0; i < PSP_AUDIO_CHANNEL_MAX ; i++)
|
||||
if (!chans[i].reserved)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -170,7 +166,7 @@ u32 sceAudioChReserve(u32 channel, u32 sampleCount, u32 format) //.Allocate soun
|
||||
return SCE_ERROR_AUDIO_NO_CHANNELS_AVAILABLE;
|
||||
}
|
||||
|
||||
if (channel < 0 || channel >= MAX_CHANNEL)
|
||||
if (channel >= PSP_AUDIO_CHANNEL_MAX)
|
||||
{
|
||||
ERROR_LOG(HLE ,"sceAudioChReserve(channel = %d, sampleCount = %d, format = %d) - BAD CHANNEL", channel, sampleCount, format);
|
||||
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
||||
@@ -186,7 +182,7 @@ u32 sceAudioChReserve(u32 channel, u32 sampleCount, u32 format) //.Allocate soun
|
||||
{
|
||||
WARN_LOG(HLE, "WARNING: Reserving already reserved channel. Error?");
|
||||
}
|
||||
DEBUG_LOG(HLE, "%i = sceAudioChReserve(%i, %i, %i)", channel, sampleCount, format);
|
||||
DEBUG_LOG(HLE, "sceAudioChReserve(channel = %d, sampleCount = %d, format = %d)", channel, sampleCount, format);
|
||||
|
||||
chans[channel].sampleCount = sampleCount;
|
||||
chans[channel].reserved = true;
|
||||
@@ -195,7 +191,7 @@ u32 sceAudioChReserve(u32 channel, u32 sampleCount, u32 format) //.Allocate soun
|
||||
|
||||
u32 sceAudioChRelease(u32 chan)
|
||||
{
|
||||
if (chan < 0 || chan >= MAX_CHANNEL)
|
||||
if (chan >= PSP_AUDIO_CHANNEL_MAX)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceAudioChRelease(%i) - BAD CHANNEL", chan);
|
||||
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
||||
@@ -214,7 +210,7 @@ u32 sceAudioChRelease(u32 chan)
|
||||
|
||||
u32 sceAudioSetChannelDataLen(u32 chan, u32 len)
|
||||
{
|
||||
if (chan < 0 || chan >= MAX_CHANNEL)
|
||||
if (chan >= PSP_AUDIO_CHANNEL_MAX)
|
||||
{
|
||||
ERROR_LOG(HLE,"sceAudioSetChannelDataLen(%i, %i) - BAD CHANNEL", chan, len);
|
||||
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
||||
@@ -234,7 +230,7 @@ u32 sceAudioSetChannelDataLen(u32 chan, u32 len)
|
||||
|
||||
u32 sceAudioChangeChannelConfig(u32 chan, u32 format)
|
||||
{
|
||||
if (chan < 0 || chan >= MAX_CHANNEL)
|
||||
if (chan >= PSP_AUDIO_CHANNEL_MAX)
|
||||
{
|
||||
ERROR_LOG(HLE,"sceAudioChangeChannelConfig(%i, %i) - invalid channel number", chan, format);
|
||||
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
||||
@@ -254,7 +250,7 @@ u32 sceAudioChangeChannelConfig(u32 chan, u32 format)
|
||||
|
||||
u32 sceAudioChangeChannelVolume(u32 chan, u32 lvolume, u32 rvolume)
|
||||
{
|
||||
if (chan < 0 || chan >= MAX_CHANNEL)
|
||||
if (chan >= PSP_AUDIO_CHANNEL_MAX)
|
||||
{
|
||||
ERROR_LOG(HLE,"sceAudioChangeChannelVolume(%i, %i, %i) - invalid channel number", chan, lvolume, rvolume);
|
||||
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
||||
@@ -272,7 +268,7 @@ u32 sceAudioChangeChannelVolume(u32 chan, u32 lvolume, u32 rvolume)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
u32 sceAudioInit()
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceAudioInit()");
|
||||
@@ -288,7 +284,7 @@ u32 sceAudioEnd()
|
||||
|
||||
u32 sceAudioOutput2Reserve(u32 sampleCount)
|
||||
{
|
||||
ERROR_LOG(HLE,"sceAudioOutput2Reserve(%i)", sampleCount);
|
||||
DEBUG_LOG(HLE,"sceAudioOutput2Reserve(%i)", sampleCount);
|
||||
chans[0].sampleCount = sampleCount;
|
||||
chans[0].reserved = true;
|
||||
return 0;
|
||||
@@ -305,20 +301,20 @@ u32 sceAudioOutput2OutputBlocking(u32 vol, u32 dataPtr)
|
||||
|
||||
u32 sceAudioOutput2ChangeLength(u32 sampleCount)
|
||||
{
|
||||
WARN_LOG(HLE,"sceAudioOutput2ChangeLength(%i)", sampleCount);
|
||||
DEBUG_LOG(HLE,"sceAudioOutput2ChangeLength(%i)", sampleCount);
|
||||
chans[0].sampleCount = sampleCount;
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 sceAudioOutput2GetRestSample()
|
||||
{
|
||||
WARN_LOG(HLE,"UNTESTED sceAudioOutput2GetRestSample()");
|
||||
DEBUG_LOG(HLE,"UNTESTED sceAudioOutput2GetRestSample()");
|
||||
return chans[0].sampleQueue.size() * 2;
|
||||
}
|
||||
|
||||
u32 sceAudioOutput2Release()
|
||||
{
|
||||
WARN_LOG(HLE,"sceAudioOutput2Release()");
|
||||
DEBUG_LOG(HLE,"sceAudioOutput2Release()");
|
||||
chans[0].reserved = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
+30
-18
@@ -36,45 +36,57 @@ enum PspAudioFrequencies { PSP_AUDIO_FREQ_44K = 44100, PSP_AUDIO_FREQ_48K = 48
|
||||
#define SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED 0x80260008
|
||||
#define SCE_ERROR_AUDIO_NOT_OUTPUT 0x80260009
|
||||
|
||||
#define MAX_CHANNEL 8
|
||||
#define PSP_AUDIO_CHANNEL_MAX 8
|
||||
|
||||
struct AudioChannel
|
||||
{
|
||||
AudioChannel() {
|
||||
AudioChannel() {
|
||||
clear();
|
||||
}
|
||||
|
||||
// PSP side
|
||||
// PSP side
|
||||
|
||||
bool reserved;
|
||||
bool reserved;
|
||||
|
||||
// last sample address
|
||||
u32 sampleAddress;
|
||||
u32 sampleCount; // Number of samples written in each OutputBlocking
|
||||
// last sample address
|
||||
u32 sampleAddress;
|
||||
u32 sampleCount; // Number of samples written in each OutputBlocking
|
||||
|
||||
int leftVolume;
|
||||
int rightVolume;
|
||||
int leftVolume;
|
||||
int rightVolume;
|
||||
|
||||
int format;
|
||||
int format;
|
||||
|
||||
SceUID waitingThread;
|
||||
|
||||
// PC side - should probably split out
|
||||
// PC side - should probably split out
|
||||
|
||||
// We copy samples as they are written into this simple ring buffer.
|
||||
// Might try something more efficient later.
|
||||
FixedSizeQueue<s16, 32768> sampleQueue;
|
||||
// We copy samples as they are written into this simple ring buffer.
|
||||
// Might try something more efficient later.
|
||||
FixedSizeQueue<s16, 32768> sampleQueue;
|
||||
|
||||
void clear() {
|
||||
reserved = false;
|
||||
void DoState(PointerWrap &p) {
|
||||
p.Do(reserved);
|
||||
p.Do(sampleAddress);
|
||||
p.Do(sampleCount);
|
||||
p.Do(leftVolume);
|
||||
p.Do(rightVolume);
|
||||
p.Do(format);
|
||||
p.Do(waitingThread);
|
||||
sampleQueue.DoState(p);
|
||||
p.DoMarker("AudioChannel");
|
||||
}
|
||||
|
||||
void clear() {
|
||||
reserved = false;
|
||||
waitingThread = 0;
|
||||
leftVolume = 0;
|
||||
rightVolume = 0;
|
||||
format = 0;
|
||||
sampleAddress = 0;
|
||||
sampleCount = 0;
|
||||
sampleQueue.clear();
|
||||
}
|
||||
sampleQueue.clear();
|
||||
}
|
||||
};
|
||||
|
||||
extern AudioChannel chans[8];
|
||||
|
||||
+116
-28
@@ -33,6 +33,7 @@
|
||||
|
||||
const int PSP_CTRL_ERROR_INVALID_MODE = 0x80000107;
|
||||
const int PSP_CTRL_ERROR_INVALID_NUM_BUFFERS = 0x80000104;
|
||||
const int PSP_CTRL_ERROR_INVALID_IDLE_PTR = 0x80000023;
|
||||
|
||||
const int NUM_CTRL_BUFFERS = 64;
|
||||
|
||||
@@ -61,7 +62,6 @@ struct CtrlLatch {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// STATE BEGIN
|
||||
static bool ctrlInited = false;
|
||||
static bool analogEnabled = false;
|
||||
static int ctrlLatchBufs = 0;
|
||||
static u32 ctrlOldButtons = 0;
|
||||
@@ -72,9 +72,16 @@ static int ctrlBuf = 0;
|
||||
static int ctrlBufRead = 0;
|
||||
static CtrlLatch latch;
|
||||
|
||||
static int ctrlIdleReset = -1;
|
||||
static int ctrlIdleBack = -1;
|
||||
|
||||
static int ctrlCycle = 0;
|
||||
|
||||
static std::vector<SceUID> waitingThreads;
|
||||
static std::recursive_mutex ctrlMutex;
|
||||
|
||||
static int ctrlTimer = -1;
|
||||
|
||||
// STATE END
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -125,6 +132,13 @@ u32 __CtrlPeekButtons()
|
||||
return ctrlCurrent.buttons;
|
||||
}
|
||||
|
||||
u32 __CtrlReadLatch()
|
||||
{
|
||||
u32 ret = latch.btnMake;
|
||||
__CtrlResetLatch();
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Functions so that the rest of the emulator can control what the sceCtrl interface should return
|
||||
// to the game:
|
||||
|
||||
@@ -202,9 +216,9 @@ int __CtrlReadBuffer(u32 ctrlDataPtr, u32 nBufs, bool negative, bool peek)
|
||||
return done;
|
||||
}
|
||||
|
||||
void __CtrlVblank()
|
||||
void __CtrlDoSample()
|
||||
{
|
||||
// When in vblank sampling mode, this samples the ctrl data into the buffers and updates the latch.
|
||||
// This samples the ctrl data into the buffers and updates the latch.
|
||||
__CtrlUpdateLatch();
|
||||
|
||||
// Wake up a single thread that was waiting for the buffer.
|
||||
@@ -226,15 +240,32 @@ retry:
|
||||
}
|
||||
}
|
||||
|
||||
void __CtrlVblank()
|
||||
{
|
||||
// This always runs, so make sure we're in vblank mode.
|
||||
if (ctrlCycle == 0)
|
||||
__CtrlDoSample();
|
||||
}
|
||||
|
||||
void __CtrlTimerUpdate(u64 userdata, int cyclesLate)
|
||||
{
|
||||
// This only runs in timer mode (ctrlCycle > 0.)
|
||||
_dbg_assert_msg_(HLE, ctrlCycle > 0, "Ctrl: sampling cycle should be > 0");
|
||||
|
||||
__CtrlDoSample();
|
||||
CoreTiming::ScheduleEvent(usToCycles(ctrlCycle), ctrlTimer, 0);
|
||||
}
|
||||
|
||||
void __CtrlInit()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> guard(ctrlMutex);
|
||||
ctrlTimer = CoreTiming::RegisterEvent("CtrlSampleTimer", __CtrlTimerUpdate);
|
||||
__DisplayListenVblank(__CtrlVblank);
|
||||
|
||||
if (!ctrlInited)
|
||||
{
|
||||
__DisplayListenVblank(__CtrlVblank);
|
||||
ctrlInited = true;
|
||||
}
|
||||
ctrlIdleReset = -1;
|
||||
ctrlIdleBack = -1;
|
||||
ctrlCycle = 0;
|
||||
|
||||
std::lock_guard<std::recursive_mutex> guard(ctrlMutex);
|
||||
|
||||
ctrlBuf = 1;
|
||||
ctrlBufRead = 0;
|
||||
@@ -253,31 +284,64 @@ void __CtrlInit()
|
||||
memcpy(&ctrlBufs[i], &ctrlCurrent, sizeof(_ctrl_data));
|
||||
}
|
||||
|
||||
void sceCtrlInit()
|
||||
void __CtrlDoState(PointerWrap &p)
|
||||
{
|
||||
__CtrlInit();
|
||||
std::lock_guard<std::recursive_mutex> guard(ctrlMutex);
|
||||
|
||||
DEBUG_LOG(HLE,"sceCtrlInit");
|
||||
RETURN(0);
|
||||
p.Do(analogEnabled);
|
||||
p.Do(ctrlLatchBufs);
|
||||
p.Do(ctrlOldButtons);
|
||||
|
||||
p.DoVoid(ctrlBufs, sizeof(ctrlBufs));
|
||||
p.Do(ctrlCurrent);
|
||||
p.Do(ctrlBuf);
|
||||
p.Do(ctrlBufRead);
|
||||
p.Do(latch);
|
||||
|
||||
p.Do(ctrlIdleReset);
|
||||
p.Do(ctrlIdleBack);
|
||||
|
||||
p.Do(ctrlCycle);
|
||||
|
||||
SceUID dv = 0;
|
||||
p.Do(waitingThreads, dv);
|
||||
|
||||
p.Do(ctrlTimer);
|
||||
CoreTiming::RestoreRegisterEvent(ctrlTimer, "CtrlSampleTimer", __CtrlTimerUpdate);
|
||||
p.DoMarker("sceCtrl");
|
||||
}
|
||||
|
||||
void __CtrlShutdown()
|
||||
{
|
||||
waitingThreads.clear();
|
||||
}
|
||||
|
||||
u32 sceCtrlSetSamplingCycle(u32 cycle)
|
||||
{
|
||||
if (cycle == 0)
|
||||
DEBUG_LOG(HLE, "sceCtrlSetSamplingCycle(%u)", cycle);
|
||||
|
||||
if ((cycle > 0 && cycle < 5555) || cycle > 20000)
|
||||
{
|
||||
// TODO: Change to vblank when we support something else.
|
||||
DEBUG_LOG(HLE, "sceCtrlSetSamplingCycle(%u)", cycle);
|
||||
WARN_LOG(HLE, "SCE_KERNEL_ERROR_INVALID_VALUE=sceCtrlSetSamplingCycle(%u)", cycle);
|
||||
return SCE_KERNEL_ERROR_INVALID_VALUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceCtrlSetSamplingCycle(%u)", cycle);
|
||||
}
|
||||
return 0;
|
||||
|
||||
u32 prev = ctrlCycle;
|
||||
ctrlCycle = cycle;
|
||||
|
||||
if (prev > 0)
|
||||
CoreTiming::UnscheduleEvent(ctrlTimer, 0);
|
||||
if (cycle > 0)
|
||||
CoreTiming::ScheduleEvent(usToCycles(ctrlCycle), ctrlTimer, 0);
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
int sceCtrlGetSamplingCycle(u32 cyclePtr)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceCtrlSetSamplingCycle(%08x)", cyclePtr);
|
||||
DEBUG_LOG(HLE, "sceCtrlSetSamplingCycle(%08x)", cyclePtr);
|
||||
if (Memory::IsValidAddress(cyclePtr))
|
||||
Memory::Write_U32(ctrlCycle, cyclePtr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -297,6 +361,7 @@ u32 sceCtrlSetSamplingMode(u32 mode)
|
||||
int sceCtrlGetSamplingMode(u32 modePtr)
|
||||
{
|
||||
u32 retVal = analogEnabled == true ? CTRL_MODE_ANALOG : CTRL_MODE_DIGITAL;
|
||||
DEBUG_LOG(HLE, "%d=sceCtrlGetSamplingMode(%i)", retVal);
|
||||
|
||||
if (Memory::IsValidAddress(modePtr))
|
||||
Memory::Write_U32(retVal, modePtr);
|
||||
@@ -304,10 +369,33 @@ int sceCtrlGetSamplingMode(u32 modePtr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceCtrlSetIdleCancelThreshold()
|
||||
int sceCtrlSetIdleCancelThreshold(int idleReset, int idleBack)
|
||||
{
|
||||
ERROR_LOG(HLE,"UNIMPL sceCtrlSetIdleCancelThreshold");
|
||||
RETURN(0);
|
||||
DEBUG_LOG(HLE, "FAKE sceCtrlSetIdleCancelThreshold(%d, %d)", idleReset, idleBack);
|
||||
|
||||
if (idleReset < -1 || idleBack < -1 || idleReset > 128 || idleBack > 128)
|
||||
return SCE_KERNEL_ERROR_INVALID_VALUE;
|
||||
|
||||
ctrlIdleReset = idleReset;
|
||||
ctrlIdleBack = idleBack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceCtrlGetIdleCancelThreshold(u32 idleResetPtr, u32 idleBackPtr)
|
||||
{
|
||||
DEBUG_LOG(HLE, "sceCtrlSetIdleCancelThreshold(%08x, %08x)", idleResetPtr, idleBackPtr);
|
||||
|
||||
if (idleResetPtr && !Memory::IsValidAddress(idleResetPtr))
|
||||
return PSP_CTRL_ERROR_INVALID_IDLE_PTR;
|
||||
if (idleBackPtr && !Memory::IsValidAddress(idleBackPtr))
|
||||
return PSP_CTRL_ERROR_INVALID_IDLE_PTR;
|
||||
|
||||
if (idleResetPtr)
|
||||
Memory::Write_U32(ctrlIdleReset, idleResetPtr);
|
||||
if (idleBackPtr)
|
||||
Memory::Write_U32(ctrlIdleBack, idleBackPtr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceCtrlReadBufferPositive(u32 ctrlDataPtr, u32 nBufs)
|
||||
@@ -378,7 +466,7 @@ u32 sceCtrlReadLatch(u32 latchDataPtr)
|
||||
|
||||
static const HLEFunction sceCtrl[] =
|
||||
{
|
||||
{0x3E65A0EA, WrapV_V<sceCtrlInit>, "sceCtrlInit"}, //(int unknown), init with 0
|
||||
{0x3E65A0EA, 0, "sceCtrlInit"}, //(int unknown), init with 0
|
||||
{0x1f4011e6, WrapU_U<sceCtrlSetSamplingMode>, "sceCtrlSetSamplingMode"}, //(int on);
|
||||
{0x6A2774F3, WrapU_U<sceCtrlSetSamplingCycle>, "sceCtrlSetSamplingCycle"},
|
||||
{0x02BAAD91, WrapI_U<sceCtrlGetSamplingCycle>,"sceCtrlGetSamplingCycle"},
|
||||
@@ -393,8 +481,8 @@ static const HLEFunction sceCtrl[] =
|
||||
{0xAF5960F3, 0, "sceCtrl_AF5960F3"},
|
||||
{0xA68FD260, 0, "sceCtrlClearRapidFire"},
|
||||
{0x6841BE1A, 0, "sceCtrlSetRapidFire"},
|
||||
{0xa7144800, WrapV_V<sceCtrlSetIdleCancelThreshold>, "sceCtrlSetIdleCancelThreshold"},
|
||||
{0x687660fa, 0, "sceCtrlGetIdleCancelThreshold"},
|
||||
{0xa7144800, WrapI_II<sceCtrlSetIdleCancelThreshold>, "sceCtrlSetIdleCancelThreshold"},
|
||||
{0x687660fa, WrapI_UU<sceCtrlGetIdleCancelThreshold>, "sceCtrlGetIdleCancelThreshold"},
|
||||
};
|
||||
|
||||
void Register_sceCtrl()
|
||||
|
||||
+6
-1
@@ -17,6 +17,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../Common/ChunkFile.h"
|
||||
|
||||
void Register_sceCtrl();
|
||||
|
||||
#define CTRL_SQUARE 0x8000
|
||||
@@ -33,6 +35,8 @@ void Register_sceCtrl();
|
||||
#define CTRL_RTRIGGER 0x0200
|
||||
|
||||
void __CtrlInit();
|
||||
void __CtrlDoState(PointerWrap &p);
|
||||
void __CtrlShutdown();
|
||||
|
||||
void __CtrlButtonDown(u32 buttonBit);
|
||||
void __CtrlButtonUp(u32 buttonBit);
|
||||
@@ -40,4 +44,5 @@ void __CtrlButtonUp(u32 buttonBit);
|
||||
void __CtrlSetAnalog(float x, float y);
|
||||
|
||||
// For use by internal UI like MsgDialog
|
||||
u32 __CtrlPeekButtons();
|
||||
u32 __CtrlPeekButtons();
|
||||
u32 __CtrlReadLatch();
|
||||
+109
-109
@@ -46,15 +46,19 @@
|
||||
// Internal drawing library
|
||||
#include "../Util/PPGeDraw.h"
|
||||
|
||||
extern ShaderManager shaderManager;
|
||||
|
||||
struct FrameBufferState
|
||||
{
|
||||
struct FrameBufferState {
|
||||
u32 topaddr;
|
||||
PspDisplayPixelFormat pspFramebufFormat;
|
||||
int pspFramebufLinesize;
|
||||
};
|
||||
|
||||
struct WaitVBlankInfo
|
||||
{
|
||||
WaitVBlankInfo(u32 tid) : threadID(tid), vcountUnblock(0) {}
|
||||
u32 threadID;
|
||||
int vcountUnblock; // what was this for again?
|
||||
};
|
||||
|
||||
// STATE BEGIN
|
||||
static FrameBufferState framebuf;
|
||||
static FrameBufferState latchedFramebuf;
|
||||
@@ -63,15 +67,18 @@ static bool framebufIsLatched;
|
||||
static int enterVblankEvent = -1;
|
||||
static int leaveVblankEvent = -1;
|
||||
|
||||
static int hCount = 0;
|
||||
static int hCountTotal = 0; //unused
|
||||
static int vCount = 0;
|
||||
static int isVblank = 0;
|
||||
static bool hasSetMode = false;
|
||||
double lastFrameTime = 0;
|
||||
static int hCount;
|
||||
static int hCountTotal; //unused
|
||||
static int vCount;
|
||||
static int isVblank;
|
||||
static bool hasSetMode;
|
||||
double lastFrameTime;
|
||||
|
||||
std::vector<WaitVBlankInfo> vblankWaitingThreads;
|
||||
|
||||
// STATE END
|
||||
|
||||
// Called when vblank happens (like an internal interrupt.) Not part of state, should be static.
|
||||
std::vector<VblankCallback> vblankListeners;
|
||||
|
||||
// The vblank period is 731.5 us (0.7315 ms)
|
||||
@@ -83,20 +90,10 @@ enum {
|
||||
PSP_DISPLAY_SETBUF_NEXTFRAME = 1
|
||||
};
|
||||
|
||||
struct WaitVBlankInfo
|
||||
{
|
||||
WaitVBlankInfo(u32 tid) : threadID(tid), vcountUnblock(0) {}
|
||||
u32 threadID;
|
||||
int vcountUnblock; // what was this for again?
|
||||
};
|
||||
|
||||
std::vector<WaitVBlankInfo> vblankWaitingThreads;
|
||||
|
||||
void hleEnterVblank(u64 userdata, int cyclesLate);
|
||||
void hleLeaveVblank(u64 userdata, int cyclesLate);
|
||||
|
||||
void __DisplayInit()
|
||||
{
|
||||
void __DisplayInit() {
|
||||
gpuStats.reset();
|
||||
hasSetMode = false;
|
||||
framebufIsLatched = false;
|
||||
@@ -110,31 +107,53 @@ void __DisplayInit()
|
||||
CoreTiming::ScheduleEvent(msToCycles(frameMs - vblankMs), enterVblankEvent, 0);
|
||||
isVblank = 0;
|
||||
vCount = 0;
|
||||
hCount = 0;
|
||||
hCountTotal = 0;
|
||||
hasSetMode = false;
|
||||
lastFrameTime = 0;
|
||||
|
||||
InitGfxState();
|
||||
}
|
||||
|
||||
void __DisplayShutdown()
|
||||
{
|
||||
void __DisplayDoState(PointerWrap &p) {
|
||||
p.Do(framebuf);
|
||||
p.Do(latchedFramebuf);
|
||||
p.Do(framebufIsLatched);
|
||||
p.Do(hCount);
|
||||
p.Do(hCountTotal);
|
||||
p.Do(vCount);
|
||||
p.Do(isVblank);
|
||||
p.Do(hasSetMode);
|
||||
p.Do(lastFrameTime);
|
||||
WaitVBlankInfo wvi(0);
|
||||
p.Do(vblankWaitingThreads, wvi);
|
||||
|
||||
p.Do(enterVblankEvent);
|
||||
CoreTiming::RestoreRegisterEvent(enterVblankEvent, "EnterVBlank", &hleEnterVblank);
|
||||
p.Do(leaveVblankEvent);
|
||||
CoreTiming::RestoreRegisterEvent(leaveVblankEvent, "LeaveVBlank", &hleLeaveVblank);
|
||||
|
||||
p.DoMarker("sceDisplay");
|
||||
}
|
||||
|
||||
void __DisplayShutdown() {
|
||||
vblankListeners.clear();
|
||||
vblankWaitingThreads.clear();
|
||||
ShutdownGfxState();
|
||||
}
|
||||
|
||||
void __DisplayListenVblank(VblankCallback callback)
|
||||
{
|
||||
void __DisplayListenVblank(VblankCallback callback) {
|
||||
vblankListeners.push_back(callback);
|
||||
}
|
||||
|
||||
void __DisplayFireVblank()
|
||||
{
|
||||
for (std::vector<VblankCallback>::iterator iter = vblankListeners.begin(), end = vblankListeners.end(); iter != end; ++iter)
|
||||
{
|
||||
void __DisplayFireVblank() {
|
||||
for (std::vector<VblankCallback>::iterator iter = vblankListeners.begin(), end = vblankListeners.end(); iter != end; ++iter) {
|
||||
VblankCallback cb = *iter;
|
||||
cb();
|
||||
}
|
||||
}
|
||||
|
||||
void hleEnterVblank(u64 userdata, int cyclesLate)
|
||||
{
|
||||
void hleEnterVblank(u64 userdata, int cyclesLate) {
|
||||
int vbCount = userdata;
|
||||
|
||||
DEBUG_LOG(HLE, "Enter VBlank %i", vbCount);
|
||||
@@ -145,19 +164,18 @@ void hleEnterVblank(u64 userdata, int cyclesLate)
|
||||
__DisplayFireVblank();
|
||||
|
||||
// Wake up threads waiting for VBlank
|
||||
for (int i = 0; i < vblankWaitingThreads.size(); i++) {
|
||||
for (size_t i = 0; i < vblankWaitingThreads.size(); i++) {
|
||||
__KernelResumeThreadFromWait(vblankWaitingThreads[i].threadID, 0);
|
||||
}
|
||||
vblankWaitingThreads.clear();
|
||||
|
||||
// Trigger VBlank interrupt handlers.
|
||||
__TriggerInterrupt(PSP_VBLANK_INTR);
|
||||
__TriggerInterrupt(PSP_INTR_IMMEDIATE | PSP_INTR_ONLY_IF_ENABLED, PSP_VBLANK_INTR);
|
||||
|
||||
CoreTiming::ScheduleEvent(msToCycles(vblankMs) - cyclesLate, leaveVblankEvent, vbCount+1);
|
||||
|
||||
// TODO: Should this be done here or in hleLeaveVblank?
|
||||
if (framebufIsLatched)
|
||||
{
|
||||
if (framebufIsLatched) {
|
||||
DEBUG_LOG(HLE, "Setting latched framebuffer %08x (prev: %08x)", latchedFramebuf.topaddr, framebuf.topaddr);
|
||||
framebuf = latchedFramebuf;
|
||||
framebufIsLatched = false;
|
||||
@@ -175,33 +193,35 @@ void hleEnterVblank(u64 userdata, int cyclesLate)
|
||||
|
||||
// Now we can subvert the Ge engine in order to draw custom overlays like stat counters etc.
|
||||
// Here we will be drawing to the non buffered front surface.
|
||||
if (g_Config.bShowDebugStats)
|
||||
{
|
||||
if (g_Config.bShowDebugStats && gpuStats.numDrawCalls) {
|
||||
gpu->UpdateStats();
|
||||
char stats[512];
|
||||
sprintf(stats,
|
||||
"Frames: %i\n"
|
||||
"Draw calls: %i\n"
|
||||
"Draw flushes: %i\n"
|
||||
"Vertices Transformed: %i\n"
|
||||
"Textures active: %i\n"
|
||||
"Textures decoded: %i\n"
|
||||
"Vertex shaders loaded: %i\n"
|
||||
"Fragment shaders loaded: %i\n"
|
||||
"Combined shaders loaded: %i\n",
|
||||
gpuStats.numFrames,
|
||||
gpuStats.numDrawCalls,
|
||||
gpuStats.numFlushes,
|
||||
gpuStats.numVertsTransformed,
|
||||
gpuStats.numTextures,
|
||||
gpuStats.numTexturesDecoded,
|
||||
gpuStats.numVertexShaders,
|
||||
gpuStats.numFragmentShaders,
|
||||
gpuStats.numShaders
|
||||
);
|
||||
|
||||
float zoom = 0.7f * sqrtf(g_Config.iWindowZoom);
|
||||
|
||||
float zoom = 0.7f; /// g_Config.iWindowZoom;
|
||||
PPGeBegin();
|
||||
PPGeDrawText(stats, 2, 2, 0, zoom, 0x90000000);
|
||||
PPGeDrawText(stats, 0, 0, 0, zoom);
|
||||
PPGeDrawText(stats, 0, 0, 0, zoom, 0xFFc0c0c0);
|
||||
PPGeEnd();
|
||||
|
||||
|
||||
gpuStats.resetFrame();
|
||||
}
|
||||
|
||||
@@ -214,20 +234,23 @@ void hleEnterVblank(u64 userdata, int cyclesLate)
|
||||
if (lastFrameTime == 0.0)
|
||||
lastFrameTime = time_now_d();
|
||||
if (!GetAsyncKeyState(VK_TAB)) {
|
||||
while (time_now_d() < lastFrameTime + 1.0 / 60.0f) {
|
||||
while (time_now_d() < lastFrameTime + 1.0 / 60.0) {
|
||||
Common::SleepCurrentThread(1);
|
||||
time_update();
|
||||
}
|
||||
lastFrameTime = time_now_d();
|
||||
// Advance lastFrameTime by a constant amount each frame,
|
||||
// but don't let it get too far behind.
|
||||
lastFrameTime = std::max(lastFrameTime + 1.0 / 60.0, time_now_d() - 1.5 / 60.0);
|
||||
}
|
||||
|
||||
// We are going to have to do something about audio timing for platforms that
|
||||
// are vsynced to something that's not exactly 60fps..
|
||||
|
||||
#endif
|
||||
|
||||
host->BeginFrame();
|
||||
gpu->BeginFrame();
|
||||
|
||||
shaderManager.DirtyShader();
|
||||
shaderManager.DirtyUniform(DIRTY_ALL);
|
||||
|
||||
// Tell the emu core that it's time to stop emulating
|
||||
// Win32 doesn't need this.
|
||||
#ifndef _WIN32
|
||||
@@ -235,9 +258,7 @@ void hleEnterVblank(u64 userdata, int cyclesLate)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void hleLeaveVblank(u64 userdata, int cyclesLate)
|
||||
{
|
||||
void hleLeaveVblank(u64 userdata, int cyclesLate) {
|
||||
isVblank = 0;
|
||||
DEBUG_LOG(HLE,"Leave VBlank %i", (int)userdata - 1);
|
||||
vCount++;
|
||||
@@ -245,19 +266,16 @@ void hleLeaveVblank(u64 userdata, int cyclesLate)
|
||||
CoreTiming::ScheduleEvent(msToCycles(frameMs - vblankMs) - cyclesLate, enterVblankEvent, userdata);
|
||||
}
|
||||
|
||||
void sceDisplayIsVblank()
|
||||
{
|
||||
void sceDisplayIsVblank() {
|
||||
DEBUG_LOG(HLE,"%i=sceDisplayIsVblank()",isVblank);
|
||||
RETURN(isVblank);
|
||||
}
|
||||
|
||||
u32 sceDisplaySetMode(u32 unknown, u32 xres, u32 yres)
|
||||
{
|
||||
u32 sceDisplaySetMode(u32 unknown, u32 xres, u32 yres) {
|
||||
DEBUG_LOG(HLE,"sceDisplaySetMode(%d,%d,%d)",unknown,xres,yres);
|
||||
host->BeginFrame();
|
||||
|
||||
if (!hasSetMode)
|
||||
{
|
||||
if (!hasSetMode) {
|
||||
gpu->InitClear();
|
||||
hasSetMode = true;
|
||||
}
|
||||
@@ -265,9 +283,7 @@ u32 sceDisplaySetMode(u32 unknown, u32 xres, u32 yres)
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 sceDisplaySetFramebuf()
|
||||
{
|
||||
//host->EndFrame();
|
||||
u32 sceDisplaySetFramebuf() {
|
||||
u32 topaddr = PARAM(0);
|
||||
int linesize = PARAM(1);
|
||||
int pixelformat = PARAM(2);
|
||||
@@ -275,25 +291,24 @@ u32 sceDisplaySetFramebuf()
|
||||
|
||||
FrameBufferState fbstate;
|
||||
DEBUG_LOG(HLE,"sceDisplaySetFramebuf(topaddr=%08x,linesize=%d,pixelsize=%d,sync=%d)",topaddr,linesize,pixelformat,sync);
|
||||
if (topaddr == 0)
|
||||
{
|
||||
if (topaddr == 0) {
|
||||
DEBUG_LOG(HLE,"- screen off");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
fbstate.topaddr = topaddr;
|
||||
fbstate.pspFramebufFormat = (PspDisplayPixelFormat)pixelformat;
|
||||
fbstate.pspFramebufLinesize = linesize;
|
||||
}
|
||||
|
||||
if (sync == PSP_DISPLAY_SETBUF_IMMEDIATE)
|
||||
{
|
||||
if (sync == PSP_DISPLAY_SETBUF_IMMEDIATE) {
|
||||
// Write immediately to the current framebuffer parameters
|
||||
framebuf = fbstate;
|
||||
gpu->SetDisplayFramebuffer(framebuf.topaddr, framebuf.pspFramebufLinesize, framebuf.pspFramebufFormat);
|
||||
}
|
||||
else if (topaddr != 0)
|
||||
{
|
||||
if (topaddr != 0)
|
||||
{
|
||||
framebuf = fbstate;
|
||||
gpu->SetDisplayFramebuffer(framebuf.topaddr, framebuf.pspFramebufLinesize, framebuf.pspFramebufFormat);
|
||||
}
|
||||
else
|
||||
WARN_LOG(HLE, "%s: PSP_DISPLAY_SETBUF_IMMEDIATE without topaddr?", __FUNCTION__);
|
||||
} else if (topaddr != 0) {
|
||||
// Delay the write until vblank
|
||||
latchedFramebuf = fbstate;
|
||||
framebufIsLatched = true;
|
||||
@@ -301,12 +316,11 @@ u32 sceDisplaySetFramebuf()
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 sceDisplayGetFramebuf(u32 topaddrPtr, u32 linesizePtr, u32 pixelFormatPtr, int mode)
|
||||
{
|
||||
u32 sceDisplayGetFramebuf(u32 topaddrPtr, u32 linesizePtr, u32 pixelFormatPtr, int mode) {
|
||||
const FrameBufferState &fbState = mode == 1 ? latchedFramebuf : framebuf;
|
||||
DEBUG_LOG(HLE,"sceDisplayGetFramebuf(*%08x = %08x, *%08x = %08x, *%08x = %08x, %i)",
|
||||
topaddrPtr, fbState.topaddr, linesizePtr, fbState.pspFramebufLinesize, pixelFormatPtr, fbState.pspFramebufFormat, mode);
|
||||
|
||||
|
||||
if (Memory::IsValidAddress(topaddrPtr))
|
||||
Memory::Write_U32(fbState.topaddr, topaddrPtr);
|
||||
if (Memory::IsValidAddress(linesizePtr))
|
||||
@@ -317,85 +331,73 @@ u32 sceDisplayGetFramebuf(u32 topaddrPtr, u32 linesizePtr, u32 pixelFormatPtr, i
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceDisplayWaitVblankStart()
|
||||
{
|
||||
void sceDisplayWaitVblankStart() {
|
||||
DEBUG_LOG(HLE,"sceDisplayWaitVblankStart()");
|
||||
vblankWaitingThreads.push_back(WaitVBlankInfo(__KernelGetCurThread()));
|
||||
__KernelWaitCurThread(WAITTYPE_VBLANK, 0, 0, 0, false);
|
||||
}
|
||||
|
||||
void sceDisplayWaitVblank()
|
||||
{
|
||||
void sceDisplayWaitVblank() {
|
||||
DEBUG_LOG(HLE,"sceDisplayWaitVblank()");
|
||||
vblankWaitingThreads.push_back(WaitVBlankInfo(__KernelGetCurThread()));
|
||||
__KernelWaitCurThread(WAITTYPE_VBLANK, 0, 0, 0, false);
|
||||
}
|
||||
|
||||
void sceDisplayWaitVblankStartMulti()
|
||||
{
|
||||
void sceDisplayWaitVblankStartMulti() {
|
||||
DEBUG_LOG(HLE,"sceDisplayWaitVblankStartMulti()");
|
||||
vblankWaitingThreads.push_back(WaitVBlankInfo(__KernelGetCurThread()));
|
||||
__KernelWaitCurThread(WAITTYPE_VBLANK, 0, 0, 0, false);
|
||||
}
|
||||
|
||||
void sceDisplayWaitVblankCB()
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceDisplayWaitVblankCB()");
|
||||
void sceDisplayWaitVblankCB() {
|
||||
DEBUG_LOG(HLE,"sceDisplayWaitVblankCB()");
|
||||
vblankWaitingThreads.push_back(WaitVBlankInfo(__KernelGetCurThread()));
|
||||
__KernelWaitCurThread(WAITTYPE_VBLANK, 0, 0, 0, true);
|
||||
}
|
||||
|
||||
void sceDisplayWaitVblankStartCB()
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceDisplayWaitVblankStartCB()");
|
||||
void sceDisplayWaitVblankStartCB() {
|
||||
DEBUG_LOG(HLE,"sceDisplayWaitVblankStartCB()");
|
||||
vblankWaitingThreads.push_back(WaitVBlankInfo(__KernelGetCurThread()));
|
||||
__KernelWaitCurThread(WAITTYPE_VBLANK, 0, 0, 0, true);
|
||||
}
|
||||
|
||||
void sceDisplayWaitVblankStartMultiCB()
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceDisplayWaitVblankStartMultiCB()");
|
||||
void sceDisplayWaitVblankStartMultiCB() {
|
||||
DEBUG_LOG(HLE,"sceDisplayWaitVblankStartMultiCB()");
|
||||
vblankWaitingThreads.push_back(WaitVBlankInfo(__KernelGetCurThread()));
|
||||
__KernelWaitCurThread(WAITTYPE_VBLANK, 0, 0, 0, true);
|
||||
}
|
||||
|
||||
u32 sceDisplayGetVcount()
|
||||
{
|
||||
u32 sceDisplayGetVcount() {
|
||||
// Too spammy
|
||||
// DEBUG_LOG(HLE,"%i=sceDisplayGetVcount()", vCount);
|
||||
// DEBUG_LOG(HLE,"%i=sceDisplayGetVcount()", vCount);
|
||||
|
||||
// Puyo Puyo Fever polls this as a substitute for waiting vblank.
|
||||
// Puyo Puyo Fever polls this as a substitute for waiting for vblank.
|
||||
// As a result, the game never gets to reschedule so it doesn't mix audio and things break.
|
||||
// I added this as a workaround until we figure out what call actually does reschedule - it doesn't call much though...
|
||||
// Need to find a better hack as this breaks games like Project Diva.
|
||||
// hleReSchedule("sceDisplayGetVcount hack"); // Puyo puyo hack?
|
||||
|
||||
CoreTiming::Idle(1000000);
|
||||
__KernelReSchedule(); // Puyo puyo hack?
|
||||
return vCount;
|
||||
}
|
||||
|
||||
void sceDisplayGetCurrentHcount()
|
||||
{
|
||||
void sceDisplayGetCurrentHcount() {
|
||||
RETURN(hCount++);
|
||||
}
|
||||
|
||||
|
||||
void sceDisplayGetAccumulatedHcount()
|
||||
{
|
||||
void sceDisplayGetAccumulatedHcount() {
|
||||
// Just do an estimate
|
||||
u32 accumHCount = CoreTiming::GetTicks() / (222000000 / 60 / 272);
|
||||
DEBUG_LOG(HLE,"%i=sceDisplayGetAccumulatedHcount()", accumHCount);
|
||||
DEBUG_LOG(HLE,"%i=sceDisplayGetAccumulatedHcount()", accumHCount);
|
||||
RETURN(accumHCount);
|
||||
}
|
||||
|
||||
float sceDisplayGetFramePerSec()
|
||||
{
|
||||
float sceDisplayGetFramePerSec() {
|
||||
float fps = 59.9400599f;
|
||||
DEBUG_LOG(HLE,"%f=sceDisplayGetFramePerSec()", fps);
|
||||
return fps; // (9MHz * 1)/(525 * 286)
|
||||
return fps; // (9MHz * 1)/(525 * 286)
|
||||
}
|
||||
|
||||
const HLEFunction sceDisplay[] =
|
||||
{
|
||||
const HLEFunction sceDisplay[] = {
|
||||
{0x0E20F177,WrapU_UUU<sceDisplaySetMode>, "sceDisplaySetMode"},
|
||||
{0x289D82FE,WrapU_V<sceDisplaySetFramebuf>, "sceDisplaySetFramebuf"},
|
||||
{0xEEDA2E54,WrapU_UUUI<sceDisplayGetFramebuf>,"sceDisplayGetFrameBuf"},
|
||||
@@ -415,10 +417,8 @@ const HLEFunction sceDisplay[] =
|
||||
{0xB4F378FA,0,"sceDisplayIsForeground"},
|
||||
{0x31C4BAA8,0,"sceDisplayGetBrightness"},
|
||||
{0x4D4E10EC,sceDisplayIsVblank,"sceDisplayIsVblank"},
|
||||
|
||||
};
|
||||
|
||||
void Register_sceDisplay()
|
||||
{
|
||||
void Register_sceDisplay() {
|
||||
RegisterModule("sceDisplay", ARRAY_SIZE(sceDisplay), sceDisplay);
|
||||
}
|
||||
@@ -18,6 +18,8 @@
|
||||
#pragma once
|
||||
|
||||
void __DisplayInit();
|
||||
void __DisplayDoState(PointerWrap &p);
|
||||
void __DisplayShutdown();
|
||||
|
||||
void Register_sceDisplay();
|
||||
|
||||
@@ -25,4 +27,5 @@ void Register_sceDisplay();
|
||||
bool __DisplayFrameDone();
|
||||
|
||||
typedef void (*VblankCallback)();
|
||||
// Listen for vblank events. Only register during init.
|
||||
void __DisplayListenVblank(VblankCallback callback);
|
||||
+57
-28
@@ -12,19 +12,19 @@ typedef u32 FontLibraryHandle;
|
||||
typedef u32 FontHandle;
|
||||
|
||||
typedef struct {
|
||||
u32* userDataAddr;
|
||||
u32 numFonts;
|
||||
u32* cacheDataAddr;
|
||||
u32 userDataAddr;
|
||||
u32 numFonts;
|
||||
u32 cacheDataAddr;
|
||||
|
||||
// Driver callbacks.
|
||||
void *(*allocFuncAddr)(void *, u32);
|
||||
void (*freeFuncAddr )(void *, void *);
|
||||
u32* openFuncAddr;
|
||||
u32* closeFuncAddr;
|
||||
u32* readFuncAddr;
|
||||
u32* seekFuncAddr;
|
||||
u32* errorFuncAddr;
|
||||
u32* ioFinishFuncAddr;
|
||||
u32 allocFuncAddr;
|
||||
u32 freeFuncAddr;
|
||||
u32 openFuncAddr;
|
||||
u32 closeFuncAddr;
|
||||
u32 readFuncAddr;
|
||||
u32 seekFuncAddr;
|
||||
u32 errorFuncAddr;
|
||||
u32 ioFinishFuncAddr;
|
||||
} FontNewLibParams;
|
||||
|
||||
typedef enum {
|
||||
@@ -138,11 +138,22 @@ typedef struct {
|
||||
u16 bufHeight;
|
||||
u16 bytesPerLine;
|
||||
u16 pad;
|
||||
void *buffer;
|
||||
u32 bufferPtr;
|
||||
} GlyphImage;
|
||||
|
||||
FontNewLibParams fontLib;
|
||||
|
||||
void __FontInit()
|
||||
{
|
||||
memset(&fontLib, 0, sizeof(fontLib));
|
||||
}
|
||||
|
||||
void __FontDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(fontLib);
|
||||
p.DoMarker("sceFont");
|
||||
}
|
||||
|
||||
u32 sceFontNewLib(u32 FontNewLibParamsPtr, u32 errorCodePtr)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceFontNewLib %x, %x", FontNewLibParamsPtr, errorCodePtr);
|
||||
@@ -235,32 +246,31 @@ int sceFontGetFontInfo(u32 fontHandle, u32 fontInfoPtr)
|
||||
memset (&fi, 0, sizeof(fi));
|
||||
if (Memory::IsValidAddress(fontInfoPtr))
|
||||
{
|
||||
fi.BPP =4;
|
||||
fi.BPP = 4;
|
||||
fi.charMapLength = 255;
|
||||
// fi.fontStyle =1;
|
||||
fi.maxGlyphAdvanceXF = 2.0;
|
||||
fi.maxGlyphAdvanceXI =2;
|
||||
fi.maxGlyphAdvanceXI = 2;
|
||||
fi.maxGlyphAdvanceYF = 2.0;
|
||||
fi.maxGlyphAdvanceYI = 32 << 6;
|
||||
fi.maxGlyphAscenderF =32 << 6;
|
||||
fi.maxGlyphAscenderF = 32 << 6;
|
||||
fi.maxGlyphAscenderI = 32 << 6;
|
||||
fi.maxGlyphBaseYF= 0.0;
|
||||
fi.maxGlyphBaseYI=0.0;
|
||||
fi.maxGlyphDescenderF =0;
|
||||
fi.maxGlyphDescenderI =0;
|
||||
fi.maxGlyphBaseYF = 0.0;
|
||||
fi.maxGlyphBaseYI = 0;
|
||||
fi.maxGlyphDescenderF = 0;
|
||||
fi.maxGlyphDescenderI = 0;
|
||||
fi.maxGlyphHeight = 32;
|
||||
fi.maxGlyphHeightF= 32;
|
||||
fi.maxGlyphHeightF = 32;
|
||||
fi.maxGlyphHeightI = 32;
|
||||
fi.maxGlyphLeftXF= 0;
|
||||
fi.maxGlyphLeftXF = 0;
|
||||
fi.maxGlyphLeftXI = 0;
|
||||
fi.maxGlyphTopYF =0;
|
||||
fi.maxGlyphTopYF = 0;
|
||||
fi.maxGlyphTopYI = 0;
|
||||
fi.maxGlyphWidth =32;
|
||||
fi.maxGlyphWidth = 32;
|
||||
fi.maxGlyphWidthF = 32;
|
||||
fi.maxGlyphWidthI= 32;
|
||||
fi.maxGlyphWidthI = 32;
|
||||
fi.minGlyphCenterXF = 16;
|
||||
fi.minGlyphCenterXI= 16;
|
||||
fi.shadowMapLength=0;
|
||||
fi.minGlyphCenterXI = 16;
|
||||
fi.shadowMapLength = 0;
|
||||
Memory::WriteStruct(fontInfoPtr, &fi);
|
||||
}
|
||||
|
||||
@@ -318,6 +328,25 @@ int sceFontGetCharGlyphImage_Clip(u32 libHandler, u32 charCode, u32 glyphImagePt
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceFontGetFontList(u32 fontLibHandle, u32 fontStylePtr, u32 numFonts)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceFontGetFontList %x, %x, %x", fontLibHandle, fontStylePtr, numFonts);
|
||||
|
||||
FontStyle style;
|
||||
memset(&style, 0, sizeof (style));
|
||||
|
||||
style.fontH = 20 / 64.f;
|
||||
style.fontV = 20 / 64.f;
|
||||
style.fontHRes = 20 / 64.f;
|
||||
style.fontVRes = 20 / 64.f;
|
||||
style.fontStyle = 1;
|
||||
|
||||
for (u32 i = 0; i < numFonts; i++)
|
||||
{
|
||||
Memory::WriteStruct(fontStylePtr+ (sizeof(style)), &style);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const HLEFunction sceLibFont[] =
|
||||
{
|
||||
@@ -325,7 +354,7 @@ const HLEFunction sceLibFont[] =
|
||||
{0x574b6fbc, WrapI_U<sceFontDoneLib>, "sceFontDoneLib"},
|
||||
{0x48293280, 0, "sceFontSetResolution"},
|
||||
{0x27f6e642, WrapI_UU<sceFontGetNumFontList>, "sceFontGetNumFontList"},
|
||||
{0xbc75d85b, 0, "sceFontGetFontList"},
|
||||
{0xbc75d85b, WrapI_UUU<sceFontGetFontList>, "sceFontGetFontList"},
|
||||
{0x099ef33c, WrapI_UUU<sceFontFindOptimumFont>, "sceFontFindOptimumFont"},
|
||||
{0x681e61a7, WrapI_UUU<sceFontFindFont>, "sceFontFindFont"},
|
||||
{0x2f67356a, 0, "sceFontCalcMemorySize"},
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../Common/ChunkFile.h"
|
||||
|
||||
void Register_sceFont();
|
||||
|
||||
void __FontInit();
|
||||
void __FontDoState(PointerWrap &p);
|
||||
+15
-3
@@ -33,6 +33,17 @@ void __GeInit()
|
||||
state = 0;
|
||||
}
|
||||
|
||||
void __GeDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(state);
|
||||
p.Do(gstate);
|
||||
p.Do(gstate_c);
|
||||
|
||||
ReapplyGfxState();
|
||||
gpu->InvalidateCache(0, -1);
|
||||
p.DoMarker("sceGe");
|
||||
}
|
||||
|
||||
void __GeShutdown()
|
||||
{
|
||||
|
||||
@@ -166,7 +177,7 @@ void sceGeUnsetCallback(u32 cbID) {
|
||||
u32 sceGeSaveContext(u32 ctxAddr)
|
||||
{
|
||||
DEBUG_LOG(HLE, "sceGeSaveContext(%08x)", ctxAddr);
|
||||
|
||||
gpu->Flush();
|
||||
if (sizeof(gstate) > 512 * 4)
|
||||
{
|
||||
ERROR_LOG(HLE, "AARGH! sizeof(gstate) has grown too large!");
|
||||
@@ -187,6 +198,7 @@ u32 sceGeSaveContext(u32 ctxAddr)
|
||||
u32 sceGeRestoreContext(u32 ctxAddr)
|
||||
{
|
||||
DEBUG_LOG(HLE, "sceGeRestoreContext(%08x)", ctxAddr);
|
||||
gpu->Flush();
|
||||
|
||||
if (sizeof(gstate) > 512 * 4)
|
||||
{
|
||||
@@ -225,12 +237,12 @@ const HLEFunction sceGe_user[] =
|
||||
{0xE0D68148,&WrapV_UU<sceGeListUpdateStallAddr>, "sceGeListUpdateStallAddr"},
|
||||
{0x03444EB4,&WrapI_UU<sceGeListSync>, "sceGeListSync"},
|
||||
{0xB287BD61,&WrapU_U<sceGeDrawSync>, "sceGeDrawSync"},
|
||||
{0xB448EC0D,&WrapV_U<sceGeBreak>, "sceGeBreak"},
|
||||
{0xB448EC0D,&WrapV_U<sceGeBreak>, "sceGeBreak"},
|
||||
{0x4C06E472,sceGeContinue, "sceGeContinue"},
|
||||
{0xA4FC06A4,&WrapU_U<sceGeSetCallback>, "sceGeSetCallback"},
|
||||
{0x05DB22CE,&WrapV_U<sceGeUnsetCallback>, "sceGeUnsetCallback"},
|
||||
{0x1F6752AD,&WrapU_V<sceGeEdramGetSize>, "sceGeEdramGetSize"},
|
||||
{0xB77905EA,&WrapU_I<sceGeEdramSetAddrTranslation>,"sceGeEdramSetAddrTranslation"},
|
||||
{0xB77905EA,&WrapU_I<sceGeEdramSetAddrTranslation>,"sceGeEdramSetAddrTranslation"},
|
||||
{0xDC93CFEF,0,"sceGeGetCmd"},
|
||||
{0x57C8945B,&sceGeGetMtx,"sceGeGetMtx"},
|
||||
{0x438A385A,&WrapU_U<sceGeSaveContext>,"sceGeSaveContext"},
|
||||
|
||||
@@ -37,6 +37,7 @@ typedef struct PspGeCallbackData
|
||||
void Register_sceGe_user();
|
||||
|
||||
void __GeInit();
|
||||
void __GeDoState(PointerWrap &p);
|
||||
void __GeShutdown();
|
||||
|
||||
|
||||
|
||||
+37
-10
@@ -33,9 +33,24 @@ const int PSP_LANGUAGE_KOREAN = 9;
|
||||
const int PSP_LANGUAGE_TRADITIONAL_CHINESE = 10;
|
||||
const int PSP_LANGUAGE_SIMPLIFIED_CHINESE = 11;
|
||||
|
||||
static u32 iLanguage = PSP_LANGUAGE_ENGLISH;
|
||||
static u32 iButtonValue = 0;
|
||||
static u32 language = PSP_LANGUAGE_ENGLISH;
|
||||
static u32 buttonValue = 0;
|
||||
static u32 umdPopup = 0;
|
||||
|
||||
void __ImposeInit()
|
||||
{
|
||||
language = PSP_LANGUAGE_ENGLISH;
|
||||
buttonValue = 0;
|
||||
umdPopup = 0;
|
||||
}
|
||||
|
||||
void __ImposeDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(language);
|
||||
p.Do(buttonValue);
|
||||
p.Do(umdPopup);
|
||||
p.DoMarker("sceImpose");
|
||||
}
|
||||
|
||||
u32 sceImposeGetBatteryIconStatus(u32 chargingPtr, u32 iconStatusPtr)
|
||||
{
|
||||
@@ -50,8 +65,8 @@ u32 sceImposeGetBatteryIconStatus(u32 chargingPtr, u32 iconStatusPtr)
|
||||
u32 sceImposeSetLanguageMode(u32 languageVal, u32 buttonVal)
|
||||
{
|
||||
DEBUG_LOG(HLE, "sceImposeSetLanguageMode(%08x, %08x)", languageVal, buttonVal);
|
||||
iLanguage = languageVal;
|
||||
iButtonValue = buttonVal;
|
||||
language = languageVal;
|
||||
buttonValue = buttonVal;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -59,20 +74,32 @@ u32 sceImposeGetLanguageMode(u32 languagePtr, u32 btnPtr)
|
||||
{
|
||||
DEBUG_LOG(HLE, "sceImposeGetLanguageMode(%08x, %08x)", languagePtr, btnPtr);
|
||||
if (Memory::IsValidAddress(languagePtr))
|
||||
Memory::Write_U32(iLanguage, languagePtr);
|
||||
Memory::Write_U32(language, languagePtr);
|
||||
if (Memory::IsValidAddress(btnPtr))
|
||||
Memory::Write_U32(iButtonValue, btnPtr);
|
||||
Memory::Write_U32(buttonValue, btnPtr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 sceImposeSetUMDPopup(int value) {
|
||||
DEBUG_LOG(HLE, "sceImposeSetUMDPopup(%i)", value);
|
||||
umdPopup = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 sceImposeGetUMDPopup() {
|
||||
DEBUG_LOG(HLE, "sceImposeGetUMDPopup()");
|
||||
return umdPopup;
|
||||
}
|
||||
|
||||
//OSD stuff? home button?
|
||||
const HLEFunction sceImpose[] =
|
||||
{
|
||||
{0x36aa6e91, &WrapU_UU<sceImposeSetLanguageMode>, "sceImposeSetLanguageMode"}, // Seen
|
||||
{0x36aa6e91, WrapU_UU<sceImposeSetLanguageMode>, "sceImposeSetLanguageMode"}, // Seen
|
||||
{0x381bd9e7, 0, "sceImposeHomeButton"},
|
||||
{0x24fd7bcf, &WrapU_UU<sceImposeGetLanguageMode>, "sceImposeGetLanguageMode"},
|
||||
{0x8c943191, &WrapU_UU<sceImposeGetBatteryIconStatus>, "sceImposeGetBatteryIconStatus"},
|
||||
{0x72189C48, 0, "sceImposeSetUMDPopup"},
|
||||
{0x24fd7bcf, WrapU_UU<sceImposeGetLanguageMode>, "sceImposeGetLanguageMode"},
|
||||
{0x8c943191, WrapU_UU<sceImposeGetBatteryIconStatus>, "sceImposeGetBatteryIconStatus"},
|
||||
{0x72189C48, WrapU_I<sceImposeSetUMDPopup>, "sceImposeSetUMDPopup"},
|
||||
{0xE0887BC8, WrapU_V<sceImposeGetUMDPopup>, "sceImposeGetUMDPopup"},
|
||||
};
|
||||
|
||||
void Register_sceImpose()
|
||||
|
||||
@@ -17,4 +17,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../Common/ChunkFile.h"
|
||||
|
||||
void Register_sceImpose();
|
||||
void __ImposeInit();
|
||||
void __ImposeDoState(PointerWrap &p);
|
||||
+168
-75
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "../System.h"
|
||||
#include "../Config.h"
|
||||
#include "../SaveState.h"
|
||||
#include "HLE.h"
|
||||
#include "../MIPS/MIPS.h"
|
||||
#include "../HW/MemoryStick.h"
|
||||
@@ -84,7 +85,7 @@ const std::string &EmuDebugOutput() {
|
||||
|
||||
typedef u32 (*DeferredAction)(SceUID id, int param);
|
||||
DeferredAction defAction = 0;
|
||||
u32 defParam;
|
||||
u32 defParam = 0;
|
||||
|
||||
#define SCE_STM_FDIR 0x1000
|
||||
#define SCE_STM_FREG 0x2000
|
||||
@@ -137,7 +138,18 @@ public:
|
||||
sprintf(ptr, "Seekpos: %08x", (u32)pspFileSystem.GetSeekPos(handle));
|
||||
}
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_BADF; }
|
||||
int GetIDType() const { return 0; }
|
||||
int GetIDType() const { return PPSSPP_KERNEL_TMID_File; }
|
||||
|
||||
virtual void DoState(PointerWrap &p) {
|
||||
p.Do(fullpath);
|
||||
p.Do(handle);
|
||||
p.Do(callbackID);
|
||||
p.Do(callbackArg);
|
||||
p.Do(asyncResult);
|
||||
p.Do(pendingAsyncResult);
|
||||
p.Do(sectorBlockMode);
|
||||
p.DoMarker("File");
|
||||
}
|
||||
|
||||
std::string fullpath;
|
||||
u32 handle;
|
||||
@@ -154,6 +166,8 @@ public:
|
||||
void __IoInit() {
|
||||
INFO_LOG(HLE, "Starting up I/O...");
|
||||
|
||||
MemoryStick_SetFatState(PSP_FAT_MEMORYSTICK_STATE_ASSIGNED);
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
char path_buffer[_MAX_PATH], drive[_MAX_DRIVE] ,dir[_MAX_DIR], file[_MAX_FNAME], ext[_MAX_EXT];
|
||||
@@ -191,8 +205,17 @@ void __IoInit() {
|
||||
pspFileSystem.Mount("flash1:", flash);
|
||||
}
|
||||
|
||||
void __IoShutdown() {
|
||||
void __IoDoState(PointerWrap &p) {
|
||||
// TODO: defAction is hard to save, and not the right way anyway.
|
||||
// Should probbly be an enum and on the FileNode anyway.
|
||||
if (defAction != NULL) {
|
||||
WARN_LOG(HLE, "FIXME: Savestate failure: deferred IO not saved yet.");
|
||||
}
|
||||
}
|
||||
|
||||
void __IoShutdown() {
|
||||
defAction = 0;
|
||||
defParam = 0;
|
||||
}
|
||||
|
||||
u32 sceIoAssign(const char *aliasname, const char *physname, const char *devname, u32 flag) {
|
||||
@@ -221,7 +244,7 @@ void __IoCompleteAsyncIO(SceUID id) {
|
||||
FileNode *f = kernelObjects.Get < FileNode > (id, error);
|
||||
if (f) {
|
||||
if (f->callbackID) {
|
||||
// __KernelNotifyCallbackType(THREAD_CALLBACK_IO, __KernelGetCurThread(), f->callbackID, f->callbackArg);
|
||||
__KernelNotifyCallback(THREAD_CALLBACK_IO, f->callbackID, f->callbackArg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -245,13 +268,16 @@ void __IoGetStat(SceIoStat *stat, PSPFileInfo &info) {
|
||||
u32 sceIoGetstat(const char *filename, u32 addr) {
|
||||
SceIoStat stat;
|
||||
PSPFileInfo info = pspFileSystem.GetFileInfo(filename);
|
||||
__IoGetStat(&stat, info);
|
||||
Memory::WriteStruct(addr, &stat);
|
||||
|
||||
DEBUG_LOG(HLE, "sceIoGetstat(%s, %08x) : sector = %08x", filename, addr,
|
||||
if (info.exists) {
|
||||
__IoGetStat(&stat, info);
|
||||
Memory::WriteStruct(addr, &stat);
|
||||
DEBUG_LOG(HLE, "sceIoGetstat(%s, %08x) : sector = %08x", filename, addr,
|
||||
info.startSector);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
} else {
|
||||
DEBUG_LOG(HLE, "sceIoGetstat(%s, %08x) : FILE NOT FOUND", filename, addr);
|
||||
return SCE_KERNEL_ERROR_NOFILE;
|
||||
}
|
||||
}
|
||||
|
||||
//Not sure about wrapping it or not, since the log seems to take the address of the data var
|
||||
@@ -364,24 +390,24 @@ u32 sceIoLseek32(int id, int offset, int whence) {
|
||||
}
|
||||
}
|
||||
|
||||
u32 sceIoOpen(const char* filename, int mode) {
|
||||
u32 sceIoOpen(const char* filename, int flags, int mode) {
|
||||
//memory stick filename
|
||||
int access = FILEACCESS_NONE;
|
||||
if (mode & O_RDONLY)
|
||||
if (flags & O_RDONLY)
|
||||
access |= FILEACCESS_READ;
|
||||
if (mode & O_WRONLY)
|
||||
if (flags & O_WRONLY)
|
||||
access |= FILEACCESS_WRITE;
|
||||
if (mode & O_APPEND)
|
||||
if (flags & O_APPEND)
|
||||
access |= FILEACCESS_APPEND;
|
||||
if (mode & O_CREAT)
|
||||
if (flags & O_CREAT)
|
||||
access |= FILEACCESS_CREATE;
|
||||
|
||||
u32 h = pspFileSystem.OpenFile(filename, (FileAccess) access);
|
||||
if (h == 0)
|
||||
{
|
||||
ERROR_LOG(HLE,
|
||||
"ERROR_ERRNO_FILE_NOT_FOUND=sceIoOpen(%s, %08x) - file not found",
|
||||
filename, mode);
|
||||
"ERROR_ERRNO_FILE_NOT_FOUND=sceIoOpen(%s, %08x, %08x) - file not found",
|
||||
filename, flags, mode);
|
||||
return ERROR_ERRNO_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -390,7 +416,7 @@ u32 sceIoOpen(const char* filename, int mode) {
|
||||
f->handle = h;
|
||||
f->fullpath = filename;
|
||||
f->asyncResult = id;
|
||||
DEBUG_LOG(HLE, "%i=sceIoOpen(%s, %08x)", id, filename, mode);
|
||||
DEBUG_LOG(HLE, "%i=sceIoOpen(%s, %08x, %08x)", id, filename, flags, mode);
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -428,11 +454,11 @@ void sceIoSync() {
|
||||
}
|
||||
|
||||
struct DeviceSize {
|
||||
u32 maxClusters;
|
||||
u32 freeClusters;
|
||||
u32 maxSectors;
|
||||
u32 sectorSize;
|
||||
u32 sectorsPerCluster;
|
||||
u32 totalClusters;
|
||||
u32 freeClusters;
|
||||
u32 sectorCount;
|
||||
};
|
||||
|
||||
u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 outPtr, int outLen) {
|
||||
@@ -494,9 +520,16 @@ u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 outPtr,
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x02025806: // Memory stick inserted?
|
||||
case 0x02025801: // Memstick Driver status?
|
||||
if (Memory::IsValidAddress(outPtr)) {
|
||||
if (Memory::IsValidAddress(outPtr) && outLen >= 4) {
|
||||
Memory::Write_U32(4, outPtr); // JPSCP: The right return value is 4 for some reason
|
||||
return 0;
|
||||
} else {
|
||||
return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS;
|
||||
}
|
||||
|
||||
case 0x02025806: // Memory stick inserted?
|
||||
if (Memory::IsValidAddress(outPtr) && outLen >= 4) {
|
||||
Memory::Write_U32(1, outPtr);
|
||||
return 0;
|
||||
} else {
|
||||
@@ -505,20 +538,23 @@ u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 outPtr,
|
||||
|
||||
case 0x02425818: // Get memstick size etc
|
||||
// Pretend we have a 2GB memory stick.
|
||||
if (Memory::IsValidAddress(argAddr)) { // "Should" be outPtr but isn't
|
||||
if (Memory::IsValidAddress(argAddr) && argLen >= 4) { // "Should" be outPtr but isn't
|
||||
u32 pointer = Memory::Read_U32(argAddr);
|
||||
|
||||
u64 totalSize = (u32)2 * 1024 * 1024 * 1024;
|
||||
u64 freeSize = 1 * 1024 * 1024 * 1024;
|
||||
u32 sectorSize = 0x200;
|
||||
u32 memStickSectorSize = 32 * 1024;
|
||||
u32 sectorCount = memStickSectorSize / sectorSize;
|
||||
u64 freeSize = 1 * 1024 * 1024 * 1024;
|
||||
DeviceSize deviceSize;
|
||||
deviceSize.maxSectors = 512;
|
||||
deviceSize.sectorSize = 0x200;
|
||||
deviceSize.sectorsPerCluster = 0x08;
|
||||
deviceSize.totalClusters = (u32)((totalSize * 95 / 100) / (deviceSize.sectorSize * deviceSize.sectorsPerCluster));
|
||||
deviceSize.freeClusters = (u32)((freeSize * 95 / 100) / (deviceSize.sectorSize * deviceSize.sectorsPerCluster));
|
||||
deviceSize.maxClusters = (u32)((freeSize * 95 / 100) / (sectorSize * sectorCount));
|
||||
deviceSize.freeClusters = deviceSize.maxClusters;
|
||||
deviceSize.maxSectors = deviceSize.maxClusters;
|
||||
deviceSize.sectorSize = sectorSize;
|
||||
deviceSize.sectorCount = sectorCount;
|
||||
Memory::WriteStruct(pointer, &deviceSize);
|
||||
DEBUG_LOG(HLE, "Returned memstick size: maxSectors=%i", deviceSize.maxSectors);
|
||||
return 0;
|
||||
} else {
|
||||
ERROR_LOG(HLE, "memstick size query: bad params");
|
||||
return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS;
|
||||
}
|
||||
}
|
||||
@@ -573,17 +609,18 @@ u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 outPtr,
|
||||
case 0x02425818: // Get memstick size etc
|
||||
// Pretend we have a 2GB memory stick.
|
||||
{
|
||||
if (Memory::IsValidAddress(argAddr)) { // "Should" be outPtr but isn't
|
||||
if (Memory::IsValidAddress(argAddr) && argLen >= 4) { // NOTE: not outPtr
|
||||
u32 pointer = Memory::Read_U32(argAddr);
|
||||
|
||||
u64 totalSize = (u32)2 * 1024 * 1024 * 1024;
|
||||
u64 freeSize = 1 * 1024 * 1024 * 1024;
|
||||
u32 sectorSize = 0x200;
|
||||
u32 memStickSectorSize = 32 * 1024;
|
||||
u32 sectorCount = memStickSectorSize / sectorSize;
|
||||
u64 freeSize = 1 * 1024 * 1024 * 1024;
|
||||
DeviceSize deviceSize;
|
||||
deviceSize.maxSectors = 512;
|
||||
deviceSize.sectorSize = 0x200;
|
||||
deviceSize.sectorsPerCluster = 0x08;
|
||||
deviceSize.totalClusters = (u32)((totalSize * 95 / 100) / (deviceSize.sectorSize * deviceSize.sectorsPerCluster));
|
||||
deviceSize.freeClusters = (u32)((freeSize * 95 / 100) / (deviceSize.sectorSize * deviceSize.sectorsPerCluster));
|
||||
deviceSize.maxClusters = (u32)((freeSize * 95 / 100) / (sectorSize * sectorCount));
|
||||
deviceSize.freeClusters = deviceSize.maxClusters;
|
||||
deviceSize.maxSectors = deviceSize.maxClusters;
|
||||
deviceSize.sectorSize = sectorSize;
|
||||
deviceSize.sectorCount = sectorCount;
|
||||
Memory::WriteStruct(pointer, &deviceSize);
|
||||
return 0;
|
||||
} else {
|
||||
@@ -622,7 +659,12 @@ u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 outPtr,
|
||||
}
|
||||
case 3: // EMULATOR_DEVCTL__IS_EMULATOR
|
||||
if (Memory::IsValidAddress(outPtr))
|
||||
Memory::Write_U32(1, outPtr); // TODO: Make a headless mode for running tests!
|
||||
Memory::Write_U32(1, outPtr);
|
||||
return 0;
|
||||
case 4: // EMULATOR_DEVCTL__VERIFY_STATE
|
||||
// Note that this is async, and makes sure the save state matches up.
|
||||
SaveState::Verify();
|
||||
// TODO: Maybe save/load to a file just to be sure?
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -656,26 +698,27 @@ u32 sceIoChdir(const char *dirname) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void sceIoChangeAsyncPriority()
|
||||
int sceIoChangeAsyncPriority(int id, int priority)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceIoChangeAsyncPriority(%d)", PARAM(0));
|
||||
RETURN(0);
|
||||
ERROR_LOG(HLE, "UNIMPL sceIoChangeAsyncPriority(%d, %d)", id, priority);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 __IoClose(SceUID id, int param)
|
||||
u32 __IoClose(SceUID actedFd, int closedFd)
|
||||
{
|
||||
DEBUG_LOG(HLE, "Deferred IoClose(%d)", id);
|
||||
__IoCompleteAsyncIO(id);
|
||||
return kernelObjects.Destroy < FileNode > (id);
|
||||
DEBUG_LOG(HLE, "Deferred IoClose(%d, %d)", actedFd, closedFd);
|
||||
__IoCompleteAsyncIO(closedFd);
|
||||
return kernelObjects.Destroy < FileNode > (closedFd);
|
||||
}
|
||||
|
||||
//TODO Not really sure if this should be wrapped nor how
|
||||
void sceIoCloseAsync()
|
||||
int sceIoCloseAsync(SceUID id)
|
||||
{
|
||||
DEBUG_LOG(HLE, "sceIoCloseAsync(%d)", PARAM(0));
|
||||
DEBUG_LOG(HLE, "sceIoCloseAsync(%d)", id);
|
||||
//sceIoClose();
|
||||
// TODO: Not sure this is a good solution. Seems like you can defer one per fd.
|
||||
defAction = &__IoClose;
|
||||
RETURN(0);
|
||||
defParam = id;
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 sceIoLseekAsync(int id, s64 offset, int whence)
|
||||
@@ -694,6 +737,7 @@ u32 sceIoSetAsyncCallback(int id, u32 clbckId, u32 clbckArg)
|
||||
FileNode *f = kernelObjects.Get < FileNode > (id, error);
|
||||
if (f)
|
||||
{
|
||||
// TODO: Check replacing / updating?
|
||||
f->callbackID = clbckId;
|
||||
f->callbackArg = clbckArg;
|
||||
return 0;
|
||||
@@ -712,13 +756,14 @@ u32 sceIoLseek32Async(int id, int offset, int whence)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceIoOpenAsync(const char *filename, int mode)
|
||||
u32 sceIoOpenAsync(const char *filename, int flags, int mode)
|
||||
{
|
||||
DEBUG_LOG(HLE, "sceIoOpenAsync() sorta implemented");
|
||||
RETURN(sceIoOpen(filename, mode));
|
||||
// __IoCompleteAsyncIO(currentMIPS->r[2]); // The return value
|
||||
// We have to return a UID here, which may have been destroyed when we reach Wait if it failed.
|
||||
// Now that we're just faking it, we just don't RETURN(0) here.
|
||||
u32 fd = sceIoOpen(filename, flags, mode);
|
||||
// TODO: This can't actually have a callback yet, but if it's set before waiting, it should be called.
|
||||
__IoCompleteAsyncIO(fd);
|
||||
// We have to return an fd here, which may have been destroyed when we reach Wait if it failed.
|
||||
return fd;
|
||||
}
|
||||
|
||||
u32 sceIoReadAsync(int id, u32 data_addr, int size)
|
||||
@@ -729,7 +774,7 @@ u32 sceIoReadAsync(int id, u32 data_addr, int size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 sceIoGetAsyncStat(int id, u32 address, u32 uknwn)
|
||||
u32 sceIoGetAsyncStat(int id, u32 poll, u32 address)
|
||||
{
|
||||
u32 error;
|
||||
FileNode *f = kernelObjects.Get < FileNode > (id, error);
|
||||
@@ -737,7 +782,9 @@ u32 sceIoGetAsyncStat(int id, u32 address, u32 uknwn)
|
||||
{
|
||||
Memory::Write_U64(f->asyncResult, address);
|
||||
DEBUG_LOG(HLE, "%i = sceIoGetAsyncStat(%i, %i, %08x) (HACK)",
|
||||
(u32) f->asyncResult, id, address, uknwn);
|
||||
(u32) f->asyncResult, id, poll, address);
|
||||
if (!poll)
|
||||
hleReSchedule("io waited");
|
||||
return 0; //completed
|
||||
}
|
||||
else
|
||||
@@ -747,7 +794,7 @@ u32 sceIoGetAsyncStat(int id, u32 address, u32 uknwn)
|
||||
}
|
||||
}
|
||||
|
||||
void sceIoWaitAsync(int id, u32 address, u32 uknwn) {
|
||||
int sceIoWaitAsync(int id, u32 address) {
|
||||
u32 error;
|
||||
FileNode *f = kernelObjects.Get < FileNode > (id, error);
|
||||
if (f) {
|
||||
@@ -758,15 +805,16 @@ void sceIoWaitAsync(int id, u32 address, u32 uknwn) {
|
||||
}
|
||||
Memory::Write_U64(res, address);
|
||||
DEBUG_LOG(HLE, "%i = sceIoWaitAsync(%i, %08x) (HACK)", (u32) res, id,
|
||||
uknwn);
|
||||
RETURN(0); //completed
|
||||
address);
|
||||
hleReSchedule("io waited");
|
||||
return 0; //completed
|
||||
} else {
|
||||
ERROR_LOG(HLE, "ERROR - sceIoWaitAsync waiting for invalid id %i", id);
|
||||
RETURN(-1);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void sceIoWaitAsyncCB(int id, u32 address) {
|
||||
int sceIoWaitAsyncCB(int id, u32 address) {
|
||||
// Should process callbacks here
|
||||
u32 error;
|
||||
FileNode *f = kernelObjects.Get < FileNode > (id, error);
|
||||
@@ -779,10 +827,13 @@ void sceIoWaitAsyncCB(int id, u32 address) {
|
||||
Memory::Write_U64(res, address);
|
||||
DEBUG_LOG(HLE, "%i = sceIoWaitAsyncCB(%i, %08x) (HACK)", (u32) res, id,
|
||||
address);
|
||||
RETURN(0); //completed
|
||||
hleCheckCurrentCallbacks();
|
||||
hleReSchedule(true, "io waited");
|
||||
return 0; //completed
|
||||
} else {
|
||||
ERROR_LOG(HLE, "ERROR - sceIoWaitAsyncCB waiting for invalid id %i",
|
||||
id);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -810,7 +861,20 @@ public:
|
||||
const char *GetName() {return name.c_str();}
|
||||
const char *GetTypeName() {return "DirListing";}
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_BADF; }
|
||||
int GetIDType() const { return 0; }
|
||||
int GetIDType() const { return PPSSPP_KERNEL_TMID_DirList; }
|
||||
|
||||
virtual void DoState(PointerWrap &p) {
|
||||
p.Do(name);
|
||||
|
||||
// TODO: Is this the right way for it to wake up?
|
||||
int count = listing.size();
|
||||
p.Do(count);
|
||||
listing.resize(count);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
listing[i].DoState(p);
|
||||
}
|
||||
p.DoMarker("DirListing");
|
||||
}
|
||||
|
||||
std::string name;
|
||||
std::vector<PSPFileInfo> listing;
|
||||
@@ -869,8 +933,37 @@ u32 sceIoDclose(int id) {
|
||||
|
||||
u32 sceIoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL 0=sceIoIoctrl id: %08x, cmd %08x, indataPtr %08x, inlen %08x, outdataPtr %08x, outLen %08x", id,cmd,indataPtr,inlen,outdataPtr,outlen);
|
||||
return 0;
|
||||
ERROR_LOG(HLE, "UNIMPL PARTIAL 0=sceIoIoctl id: %08x, cmd %08x, indataPtr %08x, inlen %08x, outdataPtr %08x, outLen %08x", id,cmd,indataPtr,inlen,outdataPtr,outlen);
|
||||
|
||||
u32 error;
|
||||
FileNode *f = kernelObjects.Get<FileNode>(id, error);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
//KD Hearts:
|
||||
//56:46:434 HLE\sceIo.cpp:886 E[HLE]: UNIMPL 0=sceIoIoctrl id: 0000011f, cmd 04100001, indataPtr 08b313d8, inlen 00000010, outdataPtr 00000000, outLen 0
|
||||
// 0000000
|
||||
switch (cmd) {
|
||||
case 0x04100001: // Define decryption key (amctrl.prx DRM)
|
||||
if (Memory::IsValidAddress(indataPtr) && inlen == 16) {
|
||||
u8 keybuf[16];
|
||||
memcpy(keybuf, Memory::GetPointer(indataPtr), 16);
|
||||
ERROR_LOG(HLE, "PGD DRM not yet supported, sorry.");
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
KernelObject *__KernelFileNodeObject() {
|
||||
return new FileNode;
|
||||
}
|
||||
|
||||
KernelObject *__KernelDirListingObject() {
|
||||
return new DirListing;
|
||||
}
|
||||
|
||||
const HLEFunction IoFileMgrForUser[] = {
|
||||
@@ -885,17 +978,17 @@ const HLEFunction IoFileMgrForUser[] = {
|
||||
{ 0x08bd7374, 0, "sceIoGetDevType" },
|
||||
{ 0xB2A628C1, &WrapU_CCCU<sceIoAssign>, "sceIoAssign" },
|
||||
{ 0xe8bc6571, 0, "sceIoCancel" },
|
||||
{ 0xb293727f, sceIoChangeAsyncPriority, "sceIoChangeAsyncPriority" },
|
||||
{ 0xb293727f, &WrapI_II<sceIoChangeAsyncPriority>, "sceIoChangeAsyncPriority" },
|
||||
{ 0x810C4BC3, &WrapU_I<sceIoClose>, "sceIoClose" }, //(int fd);
|
||||
{ 0xff5940b6, sceIoCloseAsync, "sceIoCloseAsync" },
|
||||
{ 0xff5940b6, &WrapI_I<sceIoCloseAsync>, "sceIoCloseAsync" },
|
||||
{ 0x54F5FB11, &WrapU_CIUIUI<sceIoDevctl>, "sceIoDevctl" }, //(const char *name int cmd, void *arg, size_t arglen, void *buf, size_t *buflen);
|
||||
{ 0xcb05f8d6, &WrapU_IUU<sceIoGetAsyncStat>, "sceIoGetAsyncStat" },
|
||||
{ 0x27EB27B8, &WrapI64_II64I<sceIoLseek>, "sceIoLseek" }, //(int fd, int offset, int whence);
|
||||
{ 0x68963324, &WrapU_III<sceIoLseek32>, "sceIoLseek32" },
|
||||
{ 0x1b385d8f, &WrapU_III<sceIoLseek32Async>, "sceIoLseek32Async" },
|
||||
{ 0x71b19e77, &WrapU_II64I<sceIoLseekAsync>, "sceIoLseekAsync" },
|
||||
{ 0x109F50BC, &WrapU_CI<sceIoOpen>, "sceIoOpen" }, //(const char* file, int mode);
|
||||
{ 0x89AA9906, &WrapV_CI<sceIoOpenAsync>, "sceIoOpenAsync" },
|
||||
{ 0x109F50BC, &WrapU_CII<sceIoOpen>, "sceIoOpen" }, //(const char* file, int mode);
|
||||
{ 0x89AA9906, &WrapU_CII<sceIoOpenAsync>, "sceIoOpenAsync" },
|
||||
{ 0x06A70004, &WrapU_CI<sceIoMkdir>, "sceIoMkdir" }, //(const char *dir, int mode);
|
||||
{ 0x3251ea56, &WrapU_IU<sceIoPollAsync>, "sceIoPollAsync" },
|
||||
{ 0x6A638D83, &WrapU_IUI<sceIoRead>, "sceIoRead" }, //(int fd, void *data, int size);
|
||||
@@ -908,8 +1001,8 @@ const HLEFunction IoFileMgrForUser[] = {
|
||||
{ 0x6d08a871, 0, "sceIoUnassign" },
|
||||
{ 0x42EC03AC, &WrapU_IVI<sceIoWrite>, "sceIoWrite" }, //(int fd, void *data, int size);
|
||||
{ 0x0facab19, 0, "sceIoWriteAsync" },
|
||||
{ 0x35dbd746, &WrapV_IU<sceIoWaitAsyncCB>, "sceIoWaitAsyncCB" },
|
||||
{ 0xe23eec33, &WrapV_IUU<sceIoWaitAsync>, "sceIoWaitAsync" },
|
||||
{ 0x35dbd746, &WrapI_IU<sceIoWaitAsyncCB>, "sceIoWaitAsyncCB" },
|
||||
{ 0xe23eec33, &WrapI_IU<sceIoWaitAsync>, "sceIoWaitAsync" },
|
||||
};
|
||||
|
||||
void Register_IoFileMgrForUser() {
|
||||
|
||||
@@ -19,9 +19,13 @@
|
||||
|
||||
#include <string>
|
||||
#include "HLE.h"
|
||||
#include "sceKernel.h"
|
||||
|
||||
void __IoInit();
|
||||
void __IoDoState(PointerWrap &p);
|
||||
void __IoShutdown();
|
||||
KernelObject *__KernelFileNodeObject();
|
||||
KernelObject *__KernelDirListingObject();
|
||||
|
||||
void Register_IoFileMgrForUser();
|
||||
void Register_StdioForUser();
|
||||
|
||||
+155
-14
@@ -24,13 +24,17 @@
|
||||
#include "../FileSystems/MetaFileSystem.h"
|
||||
#include "../PSPLoaders.h"
|
||||
#include "../../Core/CoreTiming.h"
|
||||
#include "../../Core/SaveState.h"
|
||||
#include "../../Core/System.h"
|
||||
#include "../../GPU/GPUInterface.h"
|
||||
#include "../../GPU/GPUState.h"
|
||||
|
||||
|
||||
#include "__sceAudio.h"
|
||||
#include "sceAudio.h"
|
||||
#include "sceCtrl.h"
|
||||
#include "sceDisplay.h"
|
||||
#include "sceFont.h"
|
||||
#include "sceGe.h"
|
||||
#include "sceIo.h"
|
||||
#include "sceKernel.h"
|
||||
@@ -53,11 +57,11 @@
|
||||
#include "sceSsl.h"
|
||||
#include "sceSas.h"
|
||||
#include "scePsmf.h"
|
||||
#include "sceImpose.h"
|
||||
#include "sceUsb.h"
|
||||
|
||||
#include "../Util/PPGeDraw.h"
|
||||
|
||||
extern MetaFileSystem pspFileSystem;
|
||||
|
||||
/*
|
||||
17: [MIPS32 R4K 00000000 ]: Loader: Type: 1 Vaddr: 00000000 Filesz: 2856816 Memsz: 2856816
|
||||
18: [MIPS32 R4K 00000000 ]: Loader: Loadable Segment Copied to 0898dab0, size 002b9770
|
||||
@@ -66,6 +70,7 @@ extern MetaFileSystem pspFileSystem;
|
||||
*/
|
||||
|
||||
static bool kernelRunning = false;
|
||||
KernelObjectPool kernelObjects;
|
||||
|
||||
void __KernelInit()
|
||||
{
|
||||
@@ -75,13 +80,19 @@ void __KernelInit()
|
||||
return;
|
||||
}
|
||||
|
||||
SaveState::Init();
|
||||
__InterruptsInit();
|
||||
__KernelMemoryInit();
|
||||
__KernelThreadingInit();
|
||||
__KernelAlarmInit();
|
||||
__KernelEventFlagInit();
|
||||
__KernelMbxInit();
|
||||
__KernelMutexInit();
|
||||
__KernelSemaInit();
|
||||
__IoInit();
|
||||
__AudioInit();
|
||||
__SasInit();
|
||||
__DisplayInit();
|
||||
__InterruptsInit();
|
||||
__GeInit();
|
||||
__PowerInit();
|
||||
__UtilityInit();
|
||||
@@ -90,6 +101,9 @@ void __KernelInit()
|
||||
__PsmfInit();
|
||||
__CtrlInit();
|
||||
__SslInit();
|
||||
__ImposeInit();
|
||||
__UsbInit();
|
||||
__FontInit();
|
||||
|
||||
// "Internal" PSP libraries
|
||||
__PPGeInit();
|
||||
@@ -113,13 +127,17 @@ void __KernelShutdown()
|
||||
__PsmfShutdown();
|
||||
__PPGeShutdown();
|
||||
|
||||
__CtrlShutdown();
|
||||
__UtilityShutdown();
|
||||
__GeShutdown();
|
||||
__SasShutdown();
|
||||
__DisplayShutdown();
|
||||
__AudioShutdown();
|
||||
__IoShutdown();
|
||||
__InterruptsShutdown();
|
||||
__KernelMutexShutdown();
|
||||
__KernelThreadingShutdown();
|
||||
__KernelMemoryShutdown();
|
||||
__InterruptsShutdown();
|
||||
|
||||
CoreTiming::ClearPendingEvents();
|
||||
CoreTiming::UnregisterAllEvents();
|
||||
@@ -127,6 +145,42 @@ void __KernelShutdown()
|
||||
kernelRunning = false;
|
||||
}
|
||||
|
||||
void __KernelDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(kernelRunning);
|
||||
kernelObjects.DoState(p);
|
||||
p.DoMarker("KernelObjects");
|
||||
|
||||
__InterruptsDoState(p);
|
||||
__KernelMemoryDoState(p);
|
||||
__KernelThreadingDoState(p);
|
||||
__KernelAlarmDoState(p);
|
||||
__KernelEventFlagDoState(p);
|
||||
__KernelMbxDoState(p);
|
||||
__KernelModuleDoState(p);
|
||||
__KernelMutexDoState(p);
|
||||
__KernelSemaDoState(p);
|
||||
|
||||
__AudioDoState(p);
|
||||
__CtrlDoState(p);
|
||||
__DisplayDoState(p);
|
||||
__FontDoState(p);
|
||||
__GeDoState(p);
|
||||
__ImposeDoState(p);
|
||||
__IoDoState(p);
|
||||
__PowerDoState(p);
|
||||
__SasDoState(p);
|
||||
__SslDoState(p);
|
||||
__UmdDoState(p);
|
||||
__UtilityDoState(p);
|
||||
__UsbDoState(p);
|
||||
|
||||
__PPGeDoState(p);
|
||||
|
||||
__InterruptsDoStateLate(p);
|
||||
__KernelThreadingDoStateLate(p);
|
||||
}
|
||||
|
||||
bool __KernelIsRunning() {
|
||||
return kernelRunning;
|
||||
}
|
||||
@@ -189,22 +243,27 @@ void sceKernelGetGPI()
|
||||
}
|
||||
|
||||
// Don't even log these, they're spammy and we probably won't
|
||||
// need to emulate them.
|
||||
// need to emulate them. Might be useful for invalidating cached
|
||||
// textures, and in the future display lists, in some cases though.
|
||||
void sceKernelDcacheInvalidateRange(u32 addr, int size)
|
||||
{
|
||||
gpu->InvalidateCache(addr, size);
|
||||
}
|
||||
void sceKernelDcacheWritebackAll()
|
||||
{
|
||||
}
|
||||
void sceKernelDcacheWritebackRange()
|
||||
void sceKernelDcacheWritebackRange(u32 addr, int size)
|
||||
{
|
||||
}
|
||||
void sceKernelDcacheWritebackInvalidateRange()
|
||||
void sceKernelDcacheWritebackInvalidateRange(u32 addr, int size)
|
||||
{
|
||||
gpu->InvalidateCache(addr, size);
|
||||
}
|
||||
void sceKernelDcacheWritebackInvalidateAll()
|
||||
{
|
||||
gpu->InvalidateCache(0, -1);
|
||||
}
|
||||
|
||||
KernelObjectPool kernelObjects;
|
||||
|
||||
KernelObjectPool::KernelObjectPool()
|
||||
{
|
||||
memset(occupied, 0, sizeof(bool)*maxCount);
|
||||
@@ -267,12 +326,12 @@ void KernelObjectPool::List()
|
||||
if (pool[i])
|
||||
{
|
||||
pool[i]->GetQuickInfo(buffer,256);
|
||||
INFO_LOG(HLE, "KO %i: %s \"%s\": %s", i + handleOffset, pool[i]->GetTypeName(), pool[i]->GetName(), buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(buffer,"WTF? Zero Pointer");
|
||||
}
|
||||
INFO_LOG(HLE, "KO %i: %s \"%s\": %s", i + handleOffset, pool[i]->GetTypeName(), pool[i]->GetName(), buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,6 +347,88 @@ int KernelObjectPool::GetCount()
|
||||
return count;
|
||||
}
|
||||
|
||||
void KernelObjectPool::DoState(PointerWrap &p)
|
||||
{
|
||||
int _maxCount = maxCount;
|
||||
p.Do(_maxCount);
|
||||
|
||||
if (_maxCount != maxCount)
|
||||
ERROR_LOG(HLE, "Unable to load state: different kernel object storage.");
|
||||
|
||||
if (p.mode == p.MODE_READ)
|
||||
kernelObjects.Clear();
|
||||
|
||||
p.DoArray(occupied, maxCount);
|
||||
for (int i = 0; i < maxCount; ++i)
|
||||
{
|
||||
if (!occupied[i])
|
||||
continue;
|
||||
|
||||
int type;
|
||||
if (p.mode == p.MODE_READ)
|
||||
{
|
||||
p.Do(type);
|
||||
pool[i] = CreateByIDType(type);
|
||||
pool[i]->uid = i + handleOffset;
|
||||
|
||||
// Already logged an error.
|
||||
if (pool[i] == NULL)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = pool[i]->GetIDType();
|
||||
p.Do(type);
|
||||
}
|
||||
pool[i]->DoState(p);
|
||||
}
|
||||
p.DoMarker("KernelObjectPool");
|
||||
}
|
||||
|
||||
KernelObject *KernelObjectPool::CreateByIDType(int type)
|
||||
{
|
||||
// Used for save states. This is ugly, but what other way is there?
|
||||
switch (type)
|
||||
{
|
||||
case SCE_KERNEL_TMID_Alarm:
|
||||
return __KernelAlarmObject();
|
||||
case SCE_KERNEL_TMID_EventFlag:
|
||||
return __KernelEventFlagObject();
|
||||
case SCE_KERNEL_TMID_Mbox:
|
||||
return __KernelMbxObject();
|
||||
case SCE_KERNEL_TMID_Fpl:
|
||||
return __KernelMemoryFPLObject();
|
||||
case SCE_KERNEL_TMID_Vpl:
|
||||
return __KernelMemoryVPLObject();
|
||||
case PPSSPP_KERNEL_TMID_PMB:
|
||||
return __KernelMemoryPMBObject();
|
||||
case PPSSPP_KERNEL_TMID_Module:
|
||||
return __KernelModuleObject();
|
||||
case SCE_KERNEL_TMID_Mpipe:
|
||||
return __KernelMsgPipeObject();
|
||||
case SCE_KERNEL_TMID_Mutex:
|
||||
return __KernelMutexObject();
|
||||
case SCE_KERNEL_TMID_LwMutex:
|
||||
return __KernelLwMutexObject();
|
||||
case SCE_KERNEL_TMID_Semaphore:
|
||||
return __KernelSemaphoreObject();
|
||||
case SCE_KERNEL_TMID_Callback:
|
||||
return __KernelCallbackObject();
|
||||
case SCE_KERNEL_TMID_Thread:
|
||||
return __KernelThreadObject();
|
||||
case SCE_KERNEL_TMID_VTimer:
|
||||
return __KernelVTimerObject();
|
||||
case PPSSPP_KERNEL_TMID_File:
|
||||
return __KernelFileNodeObject();
|
||||
case PPSSPP_KERNEL_TMID_DirList:
|
||||
return __KernelDirListingObject();
|
||||
|
||||
default:
|
||||
ERROR_LOG(COMMON, "Unable to load state: could not find object type %d.", type);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void sceKernelIcacheInvalidateAll()
|
||||
{
|
||||
DEBUG_LOG(CPU, "Icache invalidated - should clear JIT someday");
|
||||
@@ -418,10 +559,10 @@ const HLEFunction ThreadManForUser[] =
|
||||
{0x64D4540E,0,"sceKernelReferThreadProfiler"},
|
||||
|
||||
//Fifa Street 2 uses alarms
|
||||
{0x6652b8ca,sceKernelSetAlarm,"sceKernelSetAlarm"},
|
||||
{0xB2C25152,sceKernelSetSysClockAlarm,"sceKernelSetSysClockAlarm"},
|
||||
{0x7e65b999,sceKernelCancelAlarm,"sceKernelCancelAlarm"},
|
||||
{0xDAA3F564,sceKernelReferAlarmStatus,"sceKernelReferAlarmStatus"},
|
||||
{0x6652b8ca,WrapI_UUU<sceKernelSetAlarm>,"sceKernelSetAlarm"},
|
||||
{0xB2C25152,WrapI_UUU<sceKernelSetSysClockAlarm>,"sceKernelSetSysClockAlarm"},
|
||||
{0x7e65b999,WrapI_I<sceKernelCancelAlarm>,"sceKernelCancelAlarm"},
|
||||
{0xDAA3F564,WrapI_IU<sceKernelReferAlarmStatus>,"sceKernelReferAlarmStatus"},
|
||||
|
||||
{0xba6b92e2,sceKernelSysClock2USec,"sceKernelSysClock2USec"},
|
||||
{0x110DEC9A,0,"sceKernelUSec2SysClock"},
|
||||
|
||||
+18
-6
@@ -18,6 +18,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../Globals.h"
|
||||
#include "../../Common/ChunkFile.h"
|
||||
#include <cstring>
|
||||
|
||||
enum
|
||||
@@ -223,6 +224,7 @@ enum
|
||||
SCE_KERNEL_ERROR_ERRORMAX = 0x8002044d,
|
||||
};
|
||||
|
||||
// If you add to this, make sure to check KernelObjectPool::CreateByIDType().
|
||||
enum TMIDPurpose
|
||||
{
|
||||
SCE_KERNEL_TMID_Thread = 1,
|
||||
@@ -242,6 +244,12 @@ enum TMIDPurpose
|
||||
SCE_KERNEL_TMID_DelayThread = 65,
|
||||
SCE_KERNEL_TMID_SuspendThread = 66,
|
||||
SCE_KERNEL_TMID_DormantThread = 67,
|
||||
|
||||
// Not official, but need ids for save states.
|
||||
PPSSPP_KERNEL_TMID_Module = 0x100001,
|
||||
PPSSPP_KERNEL_TMID_PMB = 0x100002,
|
||||
PPSSPP_KERNEL_TMID_File = 0x100003,
|
||||
PPSSPP_KERNEL_TMID_DirList = 0x100004,
|
||||
};
|
||||
|
||||
typedef int SceUID;
|
||||
@@ -263,6 +271,7 @@ struct SceKernelLoadExecParam
|
||||
|
||||
void __KernelInit();
|
||||
void __KernelShutdown();
|
||||
void __KernelDoState(PointerWrap &p);
|
||||
bool __KernelIsRunning();
|
||||
bool __KernelLoadExec(const char *filename, SceKernelLoadExecParam *param);
|
||||
|
||||
@@ -283,9 +292,10 @@ void sceKernelFindModuleByName();
|
||||
|
||||
void sceKernelSetGPO();
|
||||
void sceKernelGetGPI();
|
||||
void sceKernelDcacheInvalidateRange(u32 addr, int size);
|
||||
void sceKernelDcacheWritebackAll();
|
||||
void sceKernelDcacheWritebackRange();
|
||||
void sceKernelDcacheWritebackInvalidateRange();
|
||||
void sceKernelDcacheWritebackRange(u32 addr, int size);
|
||||
void sceKernelDcacheWritebackInvalidateRange(u32 addr, int size);
|
||||
void sceKernelDcacheWritebackInvalidateAll();
|
||||
void sceKernelGetThreadStackFreeSize();
|
||||
void sceKernelIcacheInvalidateAll();
|
||||
@@ -310,9 +320,10 @@ public:
|
||||
// Implement this in all subclasses:
|
||||
// static u32 GetMissingErrorCode()
|
||||
|
||||
// Future
|
||||
// void Serialize(ChunkFile)
|
||||
// void DeSerialize(ChunkFile)
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
_dbg_assert_msg_(HLE, false, "Unable to save state: bad kernel object.");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -324,7 +335,8 @@ public:
|
||||
// Allocates a UID within the range and inserts the object into the map.
|
||||
SceUID Create(KernelObject *obj, int rangeBottom = 16, int rangeTop = 0x7fffffff);
|
||||
|
||||
// TODO: How will we ever save/restore this pool?
|
||||
void DoState(PointerWrap &p);
|
||||
static KernelObject *CreateByIDType(int type);
|
||||
|
||||
template <class T>
|
||||
u32 Destroy(SceUID handle)
|
||||
|
||||
+196
-12
@@ -17,28 +17,212 @@
|
||||
|
||||
#include "sceKernel.h"
|
||||
#include "sceKernelAlarm.h"
|
||||
#include "sceKernelInterrupt.h"
|
||||
#include "HLE.h"
|
||||
#include "../../Core/CoreTiming.h"
|
||||
|
||||
void sceKernelSetAlarm()
|
||||
const int NATIVEALARM_SIZE = 20;
|
||||
|
||||
struct NativeAlarm
|
||||
{
|
||||
ERROR_LOG(HLE,"UNIMPL sceKernelSetAlarm");
|
||||
RETURN(-1);
|
||||
SceSize size;
|
||||
u64 schedule;
|
||||
u32 handlerPtr;
|
||||
u32 commonPtr;
|
||||
};
|
||||
|
||||
struct Alarm : public KernelObject
|
||||
{
|
||||
const char *GetName() {return "[Alarm]";}
|
||||
const char *GetTypeName() {return "Alarm";}
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_ALMID; }
|
||||
int GetIDType() const { return SCE_KERNEL_TMID_Alarm; }
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(alm);
|
||||
p.DoMarker("Alarm");
|
||||
}
|
||||
|
||||
NativeAlarm alm;
|
||||
};
|
||||
|
||||
void __KernelScheduleAlarm(Alarm *alarm, u64 ticks);
|
||||
|
||||
class AlarmIntrHandler : public SubIntrHandler
|
||||
{
|
||||
public:
|
||||
static SubIntrHandler *Create()
|
||||
{
|
||||
return new AlarmIntrHandler();
|
||||
}
|
||||
|
||||
void setAlarm(Alarm *alarm)
|
||||
{
|
||||
alarmID = alarm->GetUID();
|
||||
handlerAddress = alarm->alm.handlerPtr;
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
virtual void copyArgsToCPU(const PendingInterrupt &pend)
|
||||
{
|
||||
SubIntrHandler::copyArgsToCPU(pend);
|
||||
|
||||
u32 error;
|
||||
Alarm *alarm = kernelObjects.Get<Alarm>(alarmID, error);
|
||||
if (alarm)
|
||||
currentMIPS->r[MIPS_REG_A0] = alarm->alm.commonPtr;
|
||||
else
|
||||
ERROR_LOG(HLE, "sceKernelAlarm: Unable to send interrupt args: alarm deleted?");
|
||||
}
|
||||
|
||||
virtual void handleResult(int result)
|
||||
{
|
||||
// A non-zero result means to reschedule.
|
||||
if (result > 0)
|
||||
{
|
||||
u32 error;
|
||||
Alarm *alarm = kernelObjects.Get<Alarm>(alarmID, error);
|
||||
__KernelScheduleAlarm(alarm, (u64) usToCycles(result));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result < 0)
|
||||
WARN_LOG(HLE, "Alarm requested reschedule for negative value %u, ignoring", (unsigned) result);
|
||||
|
||||
// Delete the alarm if it's not rescheduled.
|
||||
kernelObjects.Destroy<Alarm>(alarmID);
|
||||
__ReleaseSubIntrHandler(PSP_SYSTIMER0_INTR, alarmID);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
SubIntrHandler::DoState(p);
|
||||
p.Do(alarmID);
|
||||
p.DoMarker("AlarmIntrHandler");
|
||||
}
|
||||
|
||||
SceUID alarmID;
|
||||
};
|
||||
|
||||
static int alarmTimer = 0;
|
||||
|
||||
void __KernelTriggerAlarm(u64 userdata, int cyclesLate)
|
||||
{
|
||||
int uid = (int) userdata;
|
||||
|
||||
u32 error;
|
||||
Alarm *alarm = kernelObjects.Get<Alarm>(uid, error);
|
||||
if (alarm)
|
||||
__TriggerInterrupt(PSP_INTR_IMMEDIATE, PSP_SYSTIMER0_INTR, uid);
|
||||
}
|
||||
|
||||
void sceKernelSetSysClockAlarm()
|
||||
void __KernelAlarmInit()
|
||||
{
|
||||
ERROR_LOG(HLE,"UNIMPL sceKernelSetSysClockAlarm");
|
||||
RETURN(-1);
|
||||
alarmTimer = CoreTiming::RegisterEvent("Alarm", __KernelTriggerAlarm);
|
||||
__RegisterSubIntrCreator(PSP_SYSTIMER0_INTR, AlarmIntrHandler::Create);
|
||||
}
|
||||
|
||||
void sceKernelCancelAlarm()
|
||||
void __KernelAlarmDoState(PointerWrap &p)
|
||||
{
|
||||
ERROR_LOG(HLE,"UNIMPL sceKernelCancelAlarm");
|
||||
RETURN(-1);
|
||||
p.Do(alarmTimer);
|
||||
CoreTiming::RestoreRegisterEvent(alarmTimer, "Alarm", __KernelTriggerAlarm);
|
||||
p.DoMarker("sceKernelAlarm");
|
||||
}
|
||||
|
||||
void sceKernelReferAlarmStatus()
|
||||
KernelObject *__KernelAlarmObject()
|
||||
{
|
||||
ERROR_LOG(HLE,"UNIMPL sceKernelReferAlarmStatus");
|
||||
RETURN(-1);
|
||||
// Default object to load from state.
|
||||
return new Alarm;
|
||||
}
|
||||
|
||||
void __KernelScheduleAlarm(Alarm *alarm, u64 ticks)
|
||||
{
|
||||
alarm->alm.schedule = (CoreTiming::GetTicks() + ticks) / (u64) CoreTiming::GetClockFrequencyMHz();
|
||||
CoreTiming::ScheduleEvent((int) ticks, alarmTimer, alarm->GetUID());
|
||||
}
|
||||
|
||||
SceUID __KernelSetAlarm(u64 ticks, u32 handlerPtr, u32 commonPtr)
|
||||
{
|
||||
if (!Memory::IsValidAddress(handlerPtr))
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_ADDR;
|
||||
|
||||
Alarm *alarm = new Alarm;
|
||||
SceUID uid = kernelObjects.Create(alarm);
|
||||
|
||||
alarm->alm.size = NATIVEALARM_SIZE;
|
||||
alarm->alm.handlerPtr = handlerPtr;
|
||||
alarm->alm.commonPtr = commonPtr;
|
||||
|
||||
u32 error;
|
||||
AlarmIntrHandler *handler = (AlarmIntrHandler *) __RegisterSubIntrHandler(PSP_SYSTIMER0_INTR, uid, error);
|
||||
if (error != 0)
|
||||
{
|
||||
kernelObjects.Destroy<Alarm>(uid);
|
||||
return error;
|
||||
}
|
||||
|
||||
handler->setAlarm(alarm);
|
||||
__KernelScheduleAlarm(alarm, ticks);
|
||||
return uid;
|
||||
}
|
||||
|
||||
SceUID sceKernelSetAlarm(SceUInt micro, u32 handlerPtr, u32 commonPtr)
|
||||
{
|
||||
DEBUG_LOG(HLE, "sceKernelSetAlarm(%d, %08x, %08x)", micro, handlerPtr, commonPtr);
|
||||
return __KernelSetAlarm(usToCycles((u64) micro), handlerPtr, commonPtr);
|
||||
}
|
||||
|
||||
SceUID sceKernelSetSysClockAlarm(u32 microPtr, u32 handlerPtr, u32 commonPtr)
|
||||
{
|
||||
u64 micro;
|
||||
|
||||
if (Memory::IsValidAddress(microPtr))
|
||||
micro = Memory::Read_U64(microPtr);
|
||||
else
|
||||
return -1;
|
||||
|
||||
DEBUG_LOG(HLE, "sceKernelSetSysClockAlarm(%lld, %08x, %08x)", micro, handlerPtr, commonPtr);
|
||||
return __KernelSetAlarm(usToCycles(micro), handlerPtr, commonPtr);
|
||||
}
|
||||
|
||||
int sceKernelCancelAlarm(SceUID uid)
|
||||
{
|
||||
DEBUG_LOG(HLE, "sceKernelCancelAlarm(%08x)", uid);
|
||||
|
||||
CoreTiming::UnscheduleEvent(alarmTimer, uid);
|
||||
__ReleaseSubIntrHandler(PSP_SYSTIMER0_INTR, uid);
|
||||
|
||||
return kernelObjects.Destroy<Alarm>(uid);
|
||||
}
|
||||
|
||||
int sceKernelReferAlarmStatus(SceUID uid, u32 infoPtr)
|
||||
{
|
||||
u32 error;
|
||||
Alarm *alarm = kernelObjects.Get<Alarm>(uid, error);
|
||||
if (!alarm)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceKernelReferAlarmStatus(%08x, %08x): invalid alarm", uid, infoPtr);
|
||||
return error;
|
||||
}
|
||||
|
||||
DEBUG_LOG(HLE, "sceKernelReferAlarmStatus(%08x, %08x)", uid, infoPtr);
|
||||
|
||||
if (!Memory::IsValidAddress(infoPtr))
|
||||
return -1;
|
||||
|
||||
u32 size = Memory::Read_U32(infoPtr);
|
||||
|
||||
// Alarms actually respect size and write (kinda) what it can hold.
|
||||
if (size > 0)
|
||||
Memory::Write_U32(alarm->alm.size, infoPtr);
|
||||
if (size > 4)
|
||||
Memory::Write_U64(alarm->alm.schedule, infoPtr + 4);
|
||||
if (size > 12)
|
||||
Memory::Write_U32(alarm->alm.handlerPtr, infoPtr + 12);
|
||||
if (size > 16)
|
||||
Memory::Write_U32(alarm->alm.commonPtr, infoPtr + 16);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -17,7 +17,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
void sceKernelSetAlarm();
|
||||
void sceKernelSetSysClockAlarm();
|
||||
void sceKernelCancelAlarm();
|
||||
void sceKernelReferAlarmStatus();
|
||||
SceUID sceKernelSetAlarm(SceUInt clock, u32 handlerPtr, u32 commonPtr);
|
||||
SceUID sceKernelSetSysClockAlarm(u32 sysClockPtr, u32 handlerPtr, u32 commonPtr);
|
||||
int sceKernelCancelAlarm(SceUID uid);
|
||||
int sceKernelReferAlarmStatus(SceUID uid, u32 infoPtr);
|
||||
|
||||
void __KernelAlarmInit();
|
||||
void __KernelAlarmDoState(PointerWrap &p);
|
||||
KernelObject *__KernelAlarmObject();
|
||||
@@ -57,12 +57,20 @@ public:
|
||||
nef.currentPattern,
|
||||
nef.numWaitThreads);
|
||||
}
|
||||
|
||||
|
||||
static u32 GetMissingErrorCode() {
|
||||
return SCE_KERNEL_ERROR_UNKNOWN_EVFID;
|
||||
}
|
||||
int GetIDType() const { return SCE_KERNEL_TMID_EventFlag; }
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(nef);
|
||||
EventFlagTh eft = {0};
|
||||
p.Do(waitingThreads, eft);
|
||||
p.DoMarker("EventFlag");
|
||||
}
|
||||
|
||||
NativeEventFlag nef;
|
||||
std::vector<EventFlagTh> waitingThreads;
|
||||
};
|
||||
@@ -90,13 +98,24 @@ enum PspEventFlagWaitTypes
|
||||
PSP_EVENT_WAITKNOWN = PSP_EVENT_WAITCLEAR | PSP_EVENT_WAITCLEARALL | PSP_EVENT_WAITOR,
|
||||
};
|
||||
|
||||
bool eventFlagInitComplete = false;
|
||||
int eventFlagWaitTimer = 0;
|
||||
|
||||
void __KernelEventFlagInit()
|
||||
{
|
||||
eventFlagWaitTimer = CoreTiming::RegisterEvent("EventFlagTimeout", &__KernelEventFlagTimeout);
|
||||
eventFlagInitComplete = true;
|
||||
eventFlagWaitTimer = CoreTiming::RegisterEvent("EventFlagTimeout", __KernelEventFlagTimeout);
|
||||
}
|
||||
|
||||
void __KernelEventFlagDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(eventFlagWaitTimer);
|
||||
CoreTiming::RestoreRegisterEvent(eventFlagWaitTimer, "EventFlagTimeout", __KernelEventFlagTimeout);
|
||||
p.DoMarker("sceKernelEventFlag");
|
||||
}
|
||||
|
||||
KernelObject *__KernelEventFlagObject()
|
||||
{
|
||||
// Default object to load from state.
|
||||
return new EventFlag;
|
||||
}
|
||||
|
||||
bool __KernelEventFlagMatches(u32 *pattern, u32 bits, u8 wait, u32 outAddr)
|
||||
@@ -168,9 +187,6 @@ bool __KernelClearEventFlagThreads(EventFlag *e, int reason)
|
||||
//SceUID sceKernelCreateEventFlag(const char *name, int attr, int bits, SceKernelEventFlagOptParam *opt);
|
||||
int sceKernelCreateEventFlag(const char *name, u32 flag_attr, u32 flag_initPattern, u32 optPtr)
|
||||
{
|
||||
if (!eventFlagInitComplete)
|
||||
__KernelEventFlagInit();
|
||||
|
||||
if (!name)
|
||||
{
|
||||
WARN_LOG(HLE, "%08x=sceKernelCreateEventFlag(): invalid name", SCE_KERNEL_ERROR_ERROR);
|
||||
@@ -397,7 +413,7 @@ int sceKernelWaitEventFlag(SceUID id, u32 bits, u32 wait, u32 outBitsPtr, u32 ti
|
||||
th.bits = bits;
|
||||
th.wait = wait;
|
||||
// If < 5ms, sometimes hardware doesn't write this, but it's unpredictable.
|
||||
th.outAddr = timeout == 0 ? NULL : outBitsPtr;
|
||||
th.outAddr = timeout == 0 ? 0 : outBitsPtr;
|
||||
e->waitingThreads.push_back(th);
|
||||
|
||||
__KernelSetEventFlagTimeout(e, timeoutPtr);
|
||||
@@ -450,7 +466,7 @@ int sceKernelWaitEventFlagCB(SceUID id, u32 bits, u32 wait, u32 outBitsPtr, u32
|
||||
th.bits = bits;
|
||||
th.wait = wait;
|
||||
// If < 5ms, sometimes hardware doesn't write this, but it's unpredictable.
|
||||
th.outAddr = timeout == 0 ? NULL : outBitsPtr;
|
||||
th.outAddr = timeout == 0 ? 0 : outBitsPtr;
|
||||
e->waitingThreads.push_back(th);
|
||||
|
||||
__KernelSetEventFlagTimeout(e, timeoutPtr);
|
||||
|
||||
@@ -26,3 +26,7 @@ int sceKernelWaitEventFlagCB(SceUID id, u32 bits, u32 wait, u32 outBitsPtr, u32
|
||||
int sceKernelPollEventFlag(SceUID id, u32 bits, u32 wait, u32 outBitsPtr, u32 timeoutPtr);
|
||||
u32 sceKernelReferEventFlagStatus(SceUID id, u32 statusPtr);
|
||||
u32 sceKernelCancelEventFlag(SceUID uid, u32 pattern, u32 numWaitThreadsPtr);
|
||||
|
||||
void __KernelEventFlagInit();
|
||||
void __KernelEventFlagDoState(PointerWrap &p);
|
||||
KernelObject *__KernelEventFlagObject();
|
||||
+309
-173
@@ -28,40 +28,9 @@
|
||||
#include "sceKernelInterrupt.h"
|
||||
#include "sceKernelMutex.h"
|
||||
|
||||
struct Interrupt
|
||||
{
|
||||
PSPInterrupt intno;
|
||||
};
|
||||
|
||||
// Yeah, this bit is a bit silly.
|
||||
static int interruptsEnabled = 1;
|
||||
|
||||
static bool inInterrupt;
|
||||
|
||||
void __InterruptsInit()
|
||||
{
|
||||
interruptsEnabled = 1;
|
||||
}
|
||||
|
||||
void __InterruptsShutdown()
|
||||
{
|
||||
}
|
||||
|
||||
void __DisableInterrupts()
|
||||
{
|
||||
interruptsEnabled = 0;
|
||||
}
|
||||
|
||||
void __EnableInterrupts()
|
||||
{
|
||||
interruptsEnabled = 1;
|
||||
}
|
||||
|
||||
bool __InterruptsEnabled()
|
||||
{
|
||||
return interruptsEnabled != 0;
|
||||
}
|
||||
|
||||
void __DisableInterrupts();
|
||||
void __EnableInterrupts();
|
||||
bool __InterruptsEnabled();
|
||||
|
||||
// InterruptsManager
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -89,6 +58,7 @@ void sceKernelCpuResumeIntr(u32 enable)
|
||||
if (enable)
|
||||
{
|
||||
__EnableInterrupts();
|
||||
hleRunInterrupts();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -115,86 +85,31 @@ void sceKernelCpuResumeIntrWithSync(u32 enable)
|
||||
sceKernelCpuResumeIntr(enable);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool __IsInInterrupt()
|
||||
{
|
||||
return inInterrupt;
|
||||
}
|
||||
|
||||
bool __CanExecuteInterrupt()
|
||||
{
|
||||
return !inInterrupt;
|
||||
}
|
||||
|
||||
class AllegrexInterruptHandler;
|
||||
|
||||
struct PendingInterrupt {
|
||||
AllegrexInterruptHandler *handler;
|
||||
int arg;
|
||||
bool hasArg;
|
||||
};
|
||||
|
||||
|
||||
class AllegrexInterruptHandler
|
||||
{
|
||||
public:
|
||||
virtual ~AllegrexInterruptHandler() {}
|
||||
virtual void copyArgsToCPU(const PendingInterrupt &pend) = 0;
|
||||
virtual void queueUp() = 0;
|
||||
virtual void queueUpWithArg(int arg) = 0;
|
||||
};
|
||||
|
||||
std::list<PendingInterrupt> pendingInterrupts;
|
||||
|
||||
class SubIntrHandler : public AllegrexInterruptHandler
|
||||
{
|
||||
public:
|
||||
SubIntrHandler() {}
|
||||
virtual void queueUp()
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
PendingInterrupt pend;
|
||||
pend.handler = this;
|
||||
pend.hasArg = false;
|
||||
pendingInterrupts.push_back(pend);
|
||||
}
|
||||
virtual void queueUpWithArg(int arg)
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
PendingInterrupt pend;
|
||||
pend.handler = this;
|
||||
pend.arg = arg;
|
||||
pend.hasArg = true;
|
||||
pendingInterrupts.push_back(pend);
|
||||
}
|
||||
|
||||
virtual void copyArgsToCPU(const PendingInterrupt &pend)
|
||||
{
|
||||
DEBUG_LOG(CPU, "Entering interrupt handler %08x", handlerAddress);
|
||||
currentMIPS->pc = handlerAddress;
|
||||
currentMIPS->r[MIPS_REG_A0] = pend.hasArg ? pend.arg : number;
|
||||
currentMIPS->r[MIPS_REG_A1] = handlerArg;
|
||||
// RA is already taken care of
|
||||
}
|
||||
|
||||
bool enabled;
|
||||
int number;
|
||||
u32 handlerAddress;
|
||||
u32 handlerArg;
|
||||
};
|
||||
|
||||
class IntrHandler {
|
||||
public:
|
||||
void add(int subIntrNum, SubIntrHandler handler)
|
||||
IntrHandler()
|
||||
: subIntrCreator(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
SubIntrHandler *add(int subIntrNum)
|
||||
{
|
||||
SubIntrHandler *handler;
|
||||
if (subIntrCreator != NULL)
|
||||
handler = subIntrCreator();
|
||||
else
|
||||
handler = new SubIntrHandler();
|
||||
|
||||
subIntrHandlers[subIntrNum] = handler;
|
||||
return handler;
|
||||
}
|
||||
void remove(int subIntrNum)
|
||||
{
|
||||
subIntrHandlers.erase(subIntrNum);
|
||||
if (has(subIntrNum))
|
||||
{
|
||||
delete subIntrHandlers[subIntrNum];
|
||||
subIntrHandlers.erase(subIntrNum);
|
||||
}
|
||||
}
|
||||
bool has(int subIntrNum) const
|
||||
{
|
||||
@@ -203,20 +118,26 @@ public:
|
||||
SubIntrHandler *get(int subIntrNum)
|
||||
{
|
||||
if (has(subIntrNum))
|
||||
return &subIntrHandlers[subIntrNum];
|
||||
return subIntrHandlers[subIntrNum];
|
||||
else
|
||||
return 0;
|
||||
// what to do, what to do...
|
||||
return NULL;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
std::map<int, SubIntrHandler *>::iterator it, end;
|
||||
for (it = subIntrHandlers.begin(), end = subIntrHandlers.end(); it != end; ++it)
|
||||
delete it->second;
|
||||
subIntrHandlers.clear();
|
||||
}
|
||||
|
||||
void queueUp(int subintr)
|
||||
{
|
||||
// Just call execute on all the subintr handlers for this interrupt.
|
||||
// They will get queued up.
|
||||
for (std::map<int, SubIntrHandler>::iterator iter = subIntrHandlers.begin(); iter != subIntrHandlers.end(); ++iter)
|
||||
for (std::map<int, SubIntrHandler *>::iterator iter = subIntrHandlers.begin(); iter != subIntrHandlers.end(); ++iter)
|
||||
{
|
||||
if (subintr == -1 || iter->first == subintr)
|
||||
iter->second.queueUp();
|
||||
iter->second->queueUp();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,31 +145,71 @@ public:
|
||||
{
|
||||
// Just call execute on all the subintr handlers for this interrupt.
|
||||
// They will get queued up.
|
||||
for (std::map<int, SubIntrHandler>::iterator iter = subIntrHandlers.begin(); iter != subIntrHandlers.end(); ++iter)
|
||||
for (std::map<int, SubIntrHandler *>::iterator iter = subIntrHandlers.begin(); iter != subIntrHandlers.end(); ++iter)
|
||||
{
|
||||
if (subintr == -1 || iter->first == subintr)
|
||||
iter->second.queueUpWithArg(arg);
|
||||
iter->second->queueUpWithArg(arg);
|
||||
}
|
||||
}
|
||||
|
||||
void setCreator(SubIntrCreator creator)
|
||||
{
|
||||
subIntrCreator = creator;
|
||||
}
|
||||
|
||||
void DoState(PointerWrap &p)
|
||||
{
|
||||
// We assume that the same creator has already been registered.
|
||||
bool hasCreator = subIntrCreator != NULL;
|
||||
p.Do(hasCreator);
|
||||
if (hasCreator != (subIntrCreator != NULL))
|
||||
{
|
||||
ERROR_LOG(HLE, "Savestate failure: incompatible sub interrupt handler.");
|
||||
return;
|
||||
}
|
||||
|
||||
int n = (int) subIntrHandlers.size();
|
||||
p.Do(n);
|
||||
|
||||
if (p.mode == p.MODE_READ)
|
||||
{
|
||||
clear();
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
int subIntrNum;
|
||||
p.Do(subIntrNum);
|
||||
SubIntrHandler *handler = add(subIntrNum);
|
||||
handler->DoState(p);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::map<int, SubIntrHandler *>::iterator it, end;
|
||||
for (it = subIntrHandlers.begin(), end = subIntrHandlers.end(); it != end; ++it)
|
||||
{
|
||||
p.Do(it->first);
|
||||
it->second->DoState(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::map<int, SubIntrHandler> subIntrHandlers;
|
||||
SubIntrCreator subIntrCreator;
|
||||
std::map<int, SubIntrHandler *> subIntrHandlers;
|
||||
};
|
||||
|
||||
|
||||
class InterruptState
|
||||
{
|
||||
public:
|
||||
void save()
|
||||
{
|
||||
insideInterrupt = __IsInInterrupt();
|
||||
__KernelSaveContext(&savedCpu);
|
||||
}
|
||||
void save();
|
||||
void restore();
|
||||
void clear();
|
||||
|
||||
void restore()
|
||||
void DoState(PointerWrap &p)
|
||||
{
|
||||
::inInterrupt = insideInterrupt;
|
||||
__KernelLoadContext(&savedCpu);
|
||||
p.Do(insideInterrupt);
|
||||
p.Do(savedCpu);
|
||||
p.DoMarker("InterruptState");
|
||||
}
|
||||
|
||||
bool insideInterrupt;
|
||||
@@ -261,27 +222,152 @@ public:
|
||||
|
||||
InterruptState intState;
|
||||
IntrHandler intrHandlers[PSP_NUMBER_INTERRUPTS];
|
||||
std::list<PendingInterrupt> pendingInterrupts;
|
||||
|
||||
// Yeah, this bit is a bit silly.
|
||||
static int interruptsEnabled = 1;
|
||||
static bool inInterrupt;
|
||||
|
||||
|
||||
void __InterruptsInit()
|
||||
{
|
||||
interruptsEnabled = 1;
|
||||
inInterrupt = false;
|
||||
intState.clear();
|
||||
}
|
||||
|
||||
void __InterruptsDoState(PointerWrap &p)
|
||||
{
|
||||
int numInterrupts = PSP_NUMBER_INTERRUPTS;
|
||||
p.Do(numInterrupts);
|
||||
if (numInterrupts != PSP_NUMBER_INTERRUPTS)
|
||||
{
|
||||
ERROR_LOG(HLE, "Savestate failure: wrong number of interrupts, can't load.");
|
||||
return;
|
||||
}
|
||||
|
||||
intState.DoState(p);
|
||||
PendingInterrupt pi(0, 0);
|
||||
p.Do(pendingInterrupts, pi);
|
||||
p.Do(interruptsEnabled);
|
||||
p.Do(inInterrupt);
|
||||
p.DoMarker("sceKernelInterrupt");
|
||||
}
|
||||
|
||||
void __InterruptsDoStateLate(PointerWrap &p)
|
||||
{
|
||||
// We do these later to ensure the handlers have been registered.
|
||||
for (int i = 0; i < PSP_NUMBER_INTERRUPTS; ++i)
|
||||
intrHandlers[i].DoState(p);
|
||||
p.DoMarker("sceKernelInterrupt Late");
|
||||
}
|
||||
|
||||
void __InterruptsShutdown()
|
||||
{
|
||||
for (int i = 0; i < PSP_NUMBER_INTERRUPTS; ++i)
|
||||
intrHandlers[i].clear();
|
||||
pendingInterrupts.clear();
|
||||
}
|
||||
|
||||
void __DisableInterrupts()
|
||||
{
|
||||
interruptsEnabled = 0;
|
||||
}
|
||||
|
||||
void __EnableInterrupts()
|
||||
{
|
||||
interruptsEnabled = 1;
|
||||
}
|
||||
|
||||
bool __InterruptsEnabled()
|
||||
{
|
||||
return interruptsEnabled != 0;
|
||||
}
|
||||
|
||||
bool __IsInInterrupt()
|
||||
{
|
||||
return inInterrupt;
|
||||
}
|
||||
|
||||
bool __CanExecuteInterrupt()
|
||||
{
|
||||
return !inInterrupt;
|
||||
}
|
||||
|
||||
void InterruptState::save()
|
||||
{
|
||||
insideInterrupt = __IsInInterrupt();
|
||||
__KernelSaveContext(&savedCpu);
|
||||
}
|
||||
|
||||
void InterruptState::restore()
|
||||
{
|
||||
::inInterrupt = insideInterrupt;
|
||||
__KernelLoadContext(&savedCpu);
|
||||
}
|
||||
|
||||
void InterruptState::clear()
|
||||
{
|
||||
insideInterrupt = false;
|
||||
}
|
||||
|
||||
// http://forums.ps2dev.org/viewtopic.php?t=5687
|
||||
|
||||
// http://www.google.se/url?sa=t&rct=j&q=&esrc=s&source=web&cd=7&ved=0CFYQFjAG&url=http%3A%2F%2Fdev.psnpt.com%2Fredmine%2Fprojects%2Fuofw%2Frepository%2Frevisions%2F65%2Fraw%2Ftrunk%2Finclude%2Finterruptman.h&ei=J4pCUKvyK4nl4QSu-YC4Cg&usg=AFQjCNFxJcgzQnv6dK7aiQlht_BM9grfQQ&sig2=GGk5QUEWI6qouYDoyE07YQ
|
||||
|
||||
void SubIntrHandler::queueUp()
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
pendingInterrupts.push_back(PendingInterrupt(intrNumber, number));
|
||||
};
|
||||
|
||||
void SubIntrHandler::queueUpWithArg(int arg)
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
pendingInterrupts.push_back(PendingInterrupt(intrNumber, number, arg));
|
||||
}
|
||||
|
||||
void SubIntrHandler::copyArgsToCPU(const PendingInterrupt &pend)
|
||||
{
|
||||
DEBUG_LOG(CPU, "Entering interrupt handler %08x", handlerAddress);
|
||||
currentMIPS->pc = handlerAddress;
|
||||
currentMIPS->r[MIPS_REG_A0] = pend.hasArg ? pend.arg : number;
|
||||
currentMIPS->r[MIPS_REG_A1] = handlerArg;
|
||||
// RA is already taken care of
|
||||
}
|
||||
|
||||
|
||||
// Returns true if anything was executed.
|
||||
bool __RunOnePendingInterrupt()
|
||||
{
|
||||
if (inInterrupt)
|
||||
if (inInterrupt || !interruptsEnabled)
|
||||
{
|
||||
// Already in an interrupt! We'll keep going when it's done.
|
||||
return false;
|
||||
}
|
||||
// Can easily prioritize between different kinds of interrupts if necessary.
|
||||
retry:
|
||||
if (pendingInterrupts.size())
|
||||
{
|
||||
// If we came from CoreTiming::Advance(), we might've come from a waiting thread's callback.
|
||||
// To avoid "injecting" return values into our saved state, we context switch here.
|
||||
__KernelSwitchOffThread("interrupt");
|
||||
|
||||
PendingInterrupt pend = pendingInterrupts.front();
|
||||
pendingInterrupts.pop_front();
|
||||
SubIntrHandler *handler = intrHandlers[pend.intr].get(pend.subintr);
|
||||
if (handler == NULL)
|
||||
{
|
||||
WARN_LOG(HLE, "Ignoring interrupt, already been released.");
|
||||
pendingInterrupts.pop_front();
|
||||
goto retry;
|
||||
}
|
||||
|
||||
intState.save();
|
||||
pend.handler->copyArgsToCPU(pend);
|
||||
handler->copyArgsToCPU(pend);
|
||||
|
||||
currentMIPS->r[MIPS_REG_RA] = __KernelInterruptReturnAddress();
|
||||
inInterrupt = true;
|
||||
@@ -294,37 +380,92 @@ bool __RunOnePendingInterrupt()
|
||||
}
|
||||
}
|
||||
|
||||
void __TriggerInterrupt(PSPInterrupt intno, int subintr)
|
||||
void __TriggerRunInterrupts(int type)
|
||||
{
|
||||
intrHandlers[intno].queueUp(subintr);
|
||||
DEBUG_LOG(HLE, "Triggering subinterrupts for interrupt %i sub %i (%i in queue)", intno, subintr, pendingInterrupts.size());
|
||||
if (!inInterrupt)
|
||||
__RunOnePendingInterrupt();
|
||||
// If interrupts aren't enabled, we run them later.
|
||||
if (interruptsEnabled && !inInterrupt)
|
||||
{
|
||||
if ((type & PSP_INTR_HLE) != 0)
|
||||
hleRunInterrupts();
|
||||
else
|
||||
__RunOnePendingInterrupt();
|
||||
}
|
||||
}
|
||||
|
||||
void __TriggerInterruptWithArg(PSPInterrupt intno, int subintr, int arg)
|
||||
void __TriggerInterrupt(int type, PSPInterrupt intno, int subintr)
|
||||
{
|
||||
intrHandlers[intno].queueUpWithArg(subintr, arg);
|
||||
DEBUG_LOG(HLE, "Triggering subinterrupts for interrupt %i sub %i with arg %i (%i in queue)", intno, subintr, arg, pendingInterrupts.size());
|
||||
if (!inInterrupt)
|
||||
__RunOnePendingInterrupt();
|
||||
if (interruptsEnabled || (type & PSP_INTR_ONLY_IF_ENABLED) == 0)
|
||||
{
|
||||
intrHandlers[intno].queueUp(subintr);
|
||||
DEBUG_LOG(HLE, "Triggering subinterrupts for interrupt %i sub %i (%i in queue)", intno, subintr, (u32)pendingInterrupts.size());
|
||||
__TriggerRunInterrupts(type);
|
||||
}
|
||||
}
|
||||
|
||||
void __TriggerInterruptWithArg(int type, PSPInterrupt intno, int subintr, int arg)
|
||||
{
|
||||
if (interruptsEnabled || (type & PSP_INTR_ONLY_IF_ENABLED) == 0)
|
||||
{
|
||||
intrHandlers[intno].queueUpWithArg(subintr, arg);
|
||||
DEBUG_LOG(HLE, "Triggering subinterrupts for interrupt %i sub %i with arg %i (%i in queue)", intno, subintr, arg,
|
||||
(u32)pendingInterrupts.size());
|
||||
__TriggerRunInterrupts(type);
|
||||
}
|
||||
}
|
||||
|
||||
void __KernelReturnFromInterrupt()
|
||||
{
|
||||
DEBUG_LOG(CPU, "Left interrupt handler at %08x", currentMIPS->pc);
|
||||
inInterrupt = false;
|
||||
|
||||
// This is what we just ran.
|
||||
PendingInterrupt pend = pendingInterrupts.front();
|
||||
pendingInterrupts.pop_front();
|
||||
|
||||
SubIntrHandler *handler = intrHandlers[pend.intr].get(pend.subintr);
|
||||
if (handler != NULL)
|
||||
handler->handleResult(currentMIPS->r[MIPS_REG_V0]);
|
||||
else
|
||||
ERROR_LOG(HLE, "Interrupt released itself? Should not happen.");
|
||||
|
||||
// Restore context after running the interrupt.
|
||||
intState.restore();
|
||||
// All should now be back to normal, including PC.
|
||||
|
||||
// Alright, let's see if there's any more interrupts queued...
|
||||
|
||||
if (!__RunOnePendingInterrupt())
|
||||
__KernelReSchedule("return from interrupt");
|
||||
}
|
||||
|
||||
void __RegisterSubIntrCreator(u32 intrNumber, SubIntrCreator creator)
|
||||
{
|
||||
intrHandlers[intrNumber].setCreator(creator);
|
||||
}
|
||||
|
||||
SubIntrHandler *__RegisterSubIntrHandler(u32 intrNumber, u32 subIntrNumber, u32 &error)
|
||||
{
|
||||
SubIntrHandler *subIntrHandler = intrHandlers[intrNumber].add(subIntrNumber);
|
||||
subIntrHandler->number = subIntrNumber;
|
||||
subIntrHandler->intrNumber = intrNumber;
|
||||
error = 0;
|
||||
return subIntrHandler;
|
||||
}
|
||||
|
||||
u32 __ReleaseSubIntrHandler(u32 intrNumber, u32 subIntrNumber)
|
||||
{
|
||||
if (!intrHandlers[intrNumber].has(subIntrNumber))
|
||||
return -1;
|
||||
|
||||
for (std::list<PendingInterrupt>::iterator it = pendingInterrupts.begin(); it != pendingInterrupts.end(); )
|
||||
{
|
||||
// Hmmm...
|
||||
//__KernelReSchedule("return from interrupt");
|
||||
if (it->intr == intrNumber && it->subintr == subIntrNumber)
|
||||
pendingInterrupts.erase(it++);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
|
||||
intrHandlers[intrNumber].remove(subIntrNumber);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 sceKernelRegisterSubIntrHandler(u32 intrNumber, u32 subIntrNumber, u32 handler, u32 handlerArg)
|
||||
@@ -334,35 +475,31 @@ u32 sceKernelRegisterSubIntrHandler(u32 intrNumber, u32 subIntrNumber, u32 handl
|
||||
if (intrNumber >= PSP_NUMBER_INTERRUPTS)
|
||||
return -1;
|
||||
|
||||
SubIntrHandler subIntrHandler;
|
||||
subIntrHandler.number = subIntrNumber;
|
||||
subIntrHandler.enabled = false;
|
||||
subIntrHandler.handlerAddress = handler;
|
||||
subIntrHandler.handlerArg = handlerArg;
|
||||
intrHandlers[intrNumber].add(subIntrNumber, subIntrHandler);
|
||||
return 0;
|
||||
u32 error;
|
||||
SubIntrHandler *subIntrHandler = __RegisterSubIntrHandler(intrNumber, subIntrNumber, error);
|
||||
if (subIntrHandler)
|
||||
{
|
||||
subIntrHandler->enabled = false;
|
||||
subIntrHandler->handlerAddress = handler;
|
||||
subIntrHandler->handlerArg = handlerArg;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
u32 sceKernelReleaseSubIntrHandler(u32 intrNumber, u32 subIntrNumber)
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceKernelReleaseSubIntrHandler(%i, %i)", PARAM(0), PARAM(1));
|
||||
|
||||
// TODO: should check if it's pending and remove it from pending list! (although that's probably unlikely)
|
||||
|
||||
if (intrNumber >= PSP_NUMBER_INTERRUPTS)
|
||||
return -1;
|
||||
|
||||
if (!intrHandlers[intrNumber].has(subIntrNumber))
|
||||
return -1;
|
||||
|
||||
intrHandlers[intrNumber].remove(subIntrNumber);
|
||||
return 0;
|
||||
return __ReleaseSubIntrHandler(intrNumber, subIntrNumber);
|
||||
}
|
||||
|
||||
u32 sceKernelEnableSubIntr(u32 intrNumber, u32 subIntrNumber)
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceKernelEnableSubIntr(%i, %i)", intrNumber, subIntrNumber);
|
||||
if (intrNumber < 0 || intrNumber >= PSP_NUMBER_INTERRUPTS)
|
||||
if (intrNumber >= PSP_NUMBER_INTERRUPTS)
|
||||
return -1;
|
||||
|
||||
if (!intrHandlers[intrNumber].has(subIntrNumber))
|
||||
@@ -375,7 +512,7 @@ u32 sceKernelEnableSubIntr(u32 intrNumber, u32 subIntrNumber)
|
||||
u32 sceKernelDisableSubIntr(u32 intrNumber, u32 subIntrNumber)
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceKernelDisableSubIntr(%i, %i)", intrNumber, subIntrNumber);
|
||||
if (intrNumber < 0 || intrNumber >= PSP_NUMBER_INTERRUPTS)
|
||||
if (intrNumber >= PSP_NUMBER_INTERRUPTS)
|
||||
return -1;
|
||||
|
||||
if (!intrHandlers[intrNumber].has(subIntrNumber))
|
||||
@@ -410,15 +547,14 @@ void QueryIntrHandlerInfo()
|
||||
RETURN(0);
|
||||
}
|
||||
|
||||
void sceKernelMemset()
|
||||
// TODO: speedup
|
||||
u32 sceKernelMemset(u32 addr, u32 fillc, u32 n)
|
||||
{
|
||||
u32 addr = PARAM(0);
|
||||
u8 c = PARAM(1) & 0xff;
|
||||
u32 n = PARAM(2);
|
||||
u8 c = fillc & 0xff;
|
||||
DEBUG_LOG(HLE, "sceKernelMemset(ptr = %08x, c = %02x, n = %08x)", addr, c, n);
|
||||
for (size_t i = 0; i < n; i++)
|
||||
Memory::Write_U8((u8)c, addr + i);
|
||||
RETURN(0); /* TODO: verify it should return this */
|
||||
return 0; // TODO: verify it should return this
|
||||
}
|
||||
|
||||
u32 sceKernelMemcpy(u32 dst, u32 src, u32 size)
|
||||
@@ -431,21 +567,21 @@ u32 sceKernelMemcpy(u32 dst, u32 src, u32 size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
const HLEFunction Kernel_Library[] =
|
||||
const HLEFunction Kernel_Library[] =
|
||||
{
|
||||
{0x092968F4,sceKernelCpuSuspendIntr,"sceKernelCpuSuspendIntr"},
|
||||
{0x5F10D406,WrapV_U<sceKernelCpuResumeIntr>, "sceKernelCpuResumeIntr"}, //int oldstat
|
||||
{0x3b84732d,WrapV_U<sceKernelCpuResumeIntrWithSync>, "sceKernelCpuResumeIntrWithSync"},
|
||||
{0x47a0b729,sceKernelIsCpuIntrSuspended, "sceKernelIsCpuIntrSuspended"}, //flags
|
||||
{0xb55249d2,sceKernelIsCpuIntrEnable, "sceKernelIsCpuIntrEnable"},
|
||||
{0xa089eca4,sceKernelMemset, "sceKernelMemset"},
|
||||
{0xDC692EE3,&WrapI_UI<sceKernelTryLockLwMutex>, "sceKernelTryLockLwMutex"},
|
||||
{0x37431849,&WrapI_UI<sceKernelTryLockLwMutex_600>, "sceKernelTryLockLwMutex_600"},
|
||||
{0xbea46419,&WrapI_UIU<sceKernelLockLwMutex>, "sceKernelLockLwMutex"},
|
||||
{0x1FC64E09,&WrapI_UIU<sceKernelLockLwMutexCB>, "sceKernelLockLwMutexCB"},
|
||||
{0x15b6446b,&WrapI_UI<sceKernelUnlockLwMutex>, "sceKernelUnlockLwMutex"},
|
||||
{0x293b45b8,sceKernelGetThreadId, "sceKernelGetThreadId"},
|
||||
{0x1839852A,&WrapU_UUU<sceKernelMemcpy>,"sce_paf_private_memcpy"},
|
||||
{0xb55249d2,sceKernelIsCpuIntrEnable, "sceKernelIsCpuIntrEnable"},
|
||||
{0xa089eca4,WrapU_UUU<sceKernelMemset>, "sceKernelMemset"},
|
||||
{0xDC692EE3,WrapI_UI<sceKernelTryLockLwMutex>, "sceKernelTryLockLwMutex"},
|
||||
{0x37431849,WrapI_UI<sceKernelTryLockLwMutex_600>, "sceKernelTryLockLwMutex_600"},
|
||||
{0xbea46419,WrapI_UIU<sceKernelLockLwMutex>, "sceKernelLockLwMutex"},
|
||||
{0x1FC64E09,WrapI_UIU<sceKernelLockLwMutexCB>, "sceKernelLockLwMutexCB"},
|
||||
{0x15b6446b,WrapI_UI<sceKernelUnlockLwMutex>, "sceKernelUnlockLwMutex"},
|
||||
{0x293b45b8,sceKernelGetThreadId, "sceKernelGetThreadId"},
|
||||
{0x1839852A,WrapU_UUU<sceKernelMemcpy>,"sce_paf_private_memcpy"},
|
||||
};
|
||||
|
||||
void Register_Kernel_Library()
|
||||
@@ -454,7 +590,7 @@ void Register_Kernel_Library()
|
||||
}
|
||||
|
||||
|
||||
const HLEFunction InterruptManager[] =
|
||||
const HLEFunction InterruptManager[] =
|
||||
{
|
||||
{0xCA04A2B9, WrapU_UUUU<sceKernelRegisterSubIntrHandler>, "sceKernelRegisterSubIntrHandler"},
|
||||
{0xD61E6961, WrapU_UU<sceKernelReleaseSubIntrHandler>, "sceKernelReleaseSubIntrHandler"},
|
||||
@@ -463,7 +599,7 @@ const HLEFunction InterruptManager[] =
|
||||
{0x5CB5A78B, 0, "sceKernelSuspendSubIntr"},
|
||||
{0x7860E0DC, 0, "sceKernelResumeSubIntr"},
|
||||
{0xFC4374B8, 0, "sceKernelIsSubInterruptOccurred"},
|
||||
{0xD2E8363F, 0, "QueryIntrHandlerInfo"}, // No sce prefix for some reason
|
||||
{0xD2E8363F, QueryIntrHandlerInfo, "QueryIntrHandlerInfo"}, // No sce prefix for some reason
|
||||
{0xEEE43F47, 0, "sceKernelRegisterUserSpaceIntrStack"},
|
||||
};
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../Common/ChunkFile.h"
|
||||
|
||||
enum PSPInterrupt {
|
||||
PSP_GPIO_INTR = 4,
|
||||
PSP_ATA_INTR = 5,
|
||||
@@ -54,14 +56,70 @@ enum PSPGeSubInterrupts {
|
||||
PSP_GE_SUBINTR_SIGNAL = 15
|
||||
};
|
||||
|
||||
enum PSPInterruptTriggerType {
|
||||
// Trigger immediately, for CoreTiming events.
|
||||
PSP_INTR_IMMEDIATE = 0x0,
|
||||
// Trigger after the HLE syscall finishes.
|
||||
PSP_INTR_HLE = 0x1,
|
||||
// Only trigger (as above) if interrupts are not suspended.
|
||||
PSP_INTR_ONLY_IF_ENABLED = 0x2,
|
||||
};
|
||||
|
||||
struct PendingInterrupt {
|
||||
PendingInterrupt(int intr_, int subintr_)
|
||||
: intr(intr_), subintr(subintr_), hasArg(false) {}
|
||||
PendingInterrupt(int intr_, int subintr_, int arg_)
|
||||
: intr(intr_), subintr(subintr_), hasArg(true), arg(arg_) {}
|
||||
|
||||
int arg;
|
||||
bool hasArg;
|
||||
int intr;
|
||||
int subintr;
|
||||
};
|
||||
|
||||
class SubIntrHandler
|
||||
{
|
||||
public:
|
||||
SubIntrHandler() {}
|
||||
virtual ~SubIntrHandler() {}
|
||||
virtual void queueUp();
|
||||
virtual void queueUpWithArg(int arg);
|
||||
virtual void copyArgsToCPU(const PendingInterrupt &pend);
|
||||
virtual void handleResult(int result) {}
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(enabled);
|
||||
p.Do(intrNumber);
|
||||
p.Do(number);
|
||||
p.Do(handlerAddress);
|
||||
p.Do(handlerArg);
|
||||
p.DoMarker("SubIntrHandler");
|
||||
}
|
||||
|
||||
bool enabled;
|
||||
int intrNumber;
|
||||
int number;
|
||||
u32 handlerAddress;
|
||||
u32 handlerArg;
|
||||
};
|
||||
|
||||
typedef SubIntrHandler *(*SubIntrCreator)();
|
||||
|
||||
bool __IsInInterrupt();
|
||||
void __InterruptsInit();
|
||||
void __InterruptsDoState(PointerWrap &p);
|
||||
void __InterruptsDoStateLate(PointerWrap &p);
|
||||
void __InterruptsShutdown();
|
||||
void __TriggerInterrupt(PSPInterrupt intno, int subInterrupts = -1);
|
||||
void __TriggerInterruptWithArg(PSPInterrupt intno, int subintr, int arg); // For GE "callbacks"
|
||||
void __TriggerInterrupt(int type, PSPInterrupt intno, int subInterrupts = -1);
|
||||
void __TriggerInterruptWithArg(int type, PSPInterrupt intno, int subintr, int arg); // For GE "callbacks"
|
||||
bool __RunOnePendingInterrupt();
|
||||
void __KernelReturnFromInterrupt();
|
||||
|
||||
void __RegisterSubIntrCreator(u32 intrNumber, SubIntrCreator creator);
|
||||
SubIntrHandler *__RegisterSubIntrHandler(u32 intrNumber, u32 subIntrNumber, u32 &error);
|
||||
u32 __ReleaseSubIntrHandler(u32 intrNumber, u32 subIntrNumber);
|
||||
|
||||
u32 sceKernelRegisterSubIntrHandler(u32 intrNumber, u32 subIntrNumber, u32 handler, u32 handlerArg);
|
||||
u32 sceKernelReleaseSubIntrHandler(u32 intrNumber, u32 subIntrNumber);
|
||||
u32 sceKernelEnableSubIntr(u32 intrNumber, u32 subIntrNumber);
|
||||
|
||||
@@ -30,8 +30,7 @@ const int PSP_MBX_ERROR_DUPLICATE_MSG = 0x800201C9;
|
||||
typedef std::pair<SceUID, u32> MbxWaitingThread;
|
||||
void __KernelMbxTimeout(u64 userdata, int cyclesLate);
|
||||
|
||||
bool mbxInitComplete = false;
|
||||
int mbxWaitTimer = 0;
|
||||
static int mbxWaitTimer = 0;
|
||||
|
||||
struct NativeMbx
|
||||
{
|
||||
@@ -154,6 +153,14 @@ struct Mbx : public KernelObject
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(nmb);
|
||||
MbxWaitingThread mwt(0,0);
|
||||
p.Do(waitingThreads, mwt);
|
||||
p.DoMarker("Mbx");
|
||||
}
|
||||
|
||||
NativeMbx nmb;
|
||||
|
||||
std::vector<MbxWaitingThread> waitingThreads;
|
||||
@@ -161,9 +168,19 @@ struct Mbx : public KernelObject
|
||||
|
||||
void __KernelMbxInit()
|
||||
{
|
||||
mbxWaitTimer = CoreTiming::RegisterEvent("MbxTimeout", &__KernelMbxTimeout);
|
||||
mbxWaitTimer = CoreTiming::RegisterEvent("MbxTimeout", __KernelMbxTimeout);
|
||||
}
|
||||
|
||||
mbxInitComplete = true;
|
||||
void __KernelMbxDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(mbxWaitTimer);
|
||||
CoreTiming::RestoreRegisterEvent(mbxWaitTimer, "MbxTimeout", __KernelMbxTimeout);
|
||||
p.DoMarker("sceKernelMbx");
|
||||
}
|
||||
|
||||
KernelObject *__KernelMbxObject()
|
||||
{
|
||||
return new Mbx;
|
||||
}
|
||||
|
||||
bool __KernelUnlockMbxForThread(Mbx *m, MbxWaitingThread &th, u32 &error, int result, bool &wokeThreads)
|
||||
@@ -263,9 +280,6 @@ std::vector<MbxWaitingThread>::iterator __KernelMbxFindPriority(std::vector<MbxW
|
||||
|
||||
SceUID sceKernelCreateMbx(const char *name, u32 attr, u32 optAddr)
|
||||
{
|
||||
if (!mbxInitComplete)
|
||||
__KernelMbxInit();
|
||||
|
||||
if (!name)
|
||||
{
|
||||
WARN_LOG(HLE, "%08x=%s(): invalid name", SCE_KERNEL_ERROR_ERROR, __FUNCTION__);
|
||||
|
||||
@@ -32,3 +32,7 @@ int sceKernelReceiveMbxCB(SceUID id, u32 packetAddrPtr, u32 timeoutPtr);
|
||||
int sceKernelPollMbx(SceUID id, u32 packetAddrPtr);
|
||||
int sceKernelCancelReceiveMbx(SceUID id, u32 numWaitingThreadsAddr);
|
||||
int sceKernelReferMbxStatus(SceUID id, u32 infoAddr);
|
||||
|
||||
void __KernelMbxInit();
|
||||
void __KernelMbxDoState(PointerWrap &p);
|
||||
KernelObject *__KernelMbxObject();
|
||||
+240
-48
@@ -32,6 +32,12 @@ BlockAllocator kernelMemory(256);
|
||||
// STATE END
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define SCE_KERNEL_HASCOMPILEDSDKVERSION 0x1000
|
||||
#define SCE_KERNEL_HASCOMPILERVERSION 0x2000
|
||||
|
||||
int flags_ = 0;
|
||||
int sdkVersion_;
|
||||
int compilerVersion_;
|
||||
|
||||
struct NativeFPL
|
||||
{
|
||||
@@ -47,15 +53,12 @@ struct NativeFPL
|
||||
};
|
||||
|
||||
//FPL - Fixed Length Dynamic Memory Pool - every item has the same length
|
||||
struct FPL : KernelObject
|
||||
struct FPL : public KernelObject
|
||||
{
|
||||
const char *GetName() {return nf.name;}
|
||||
const char *GetTypeName() {return "FPL";}
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_FPLID; }
|
||||
int GetIDType() const { return SCE_KERNEL_TMID_Fpl; }
|
||||
NativeFPL nf;
|
||||
bool *blocks;
|
||||
u32 address;
|
||||
|
||||
int findFreeBlock() {
|
||||
for (int i = 0; i < nf.numBlocks; i++) {
|
||||
@@ -79,6 +82,18 @@ struct FPL : KernelObject
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(nf);
|
||||
p.DoArray(blocks, nf.numBlocks);
|
||||
p.Do(address);
|
||||
p.DoMarker("FPL");
|
||||
}
|
||||
|
||||
NativeFPL nf;
|
||||
bool *blocks;
|
||||
u32 address;
|
||||
};
|
||||
|
||||
struct SceKernelVplInfo
|
||||
@@ -91,15 +106,24 @@ struct SceKernelVplInfo
|
||||
int numWaitThreads;
|
||||
};
|
||||
|
||||
struct VPL : KernelObject
|
||||
struct VPL : public KernelObject
|
||||
{
|
||||
const char *GetName() {return nv.name;}
|
||||
const char *GetTypeName() {return "VPL";}
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_VPLID; }
|
||||
int GetIDType() const { return SCE_KERNEL_TMID_Vpl; }
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(nv);
|
||||
p.Do(size);
|
||||
p.Do(address);
|
||||
alloc.DoState(p);
|
||||
p.DoMarker("VPL");
|
||||
}
|
||||
|
||||
SceKernelVplInfo nv;
|
||||
u32 size;
|
||||
bool *freeBlocks;
|
||||
u32 address;
|
||||
BlockAllocator alloc;
|
||||
};
|
||||
@@ -111,6 +135,13 @@ void __KernelMemoryInit()
|
||||
INFO_LOG(HLE, "Kernel and user memory pools initialized");
|
||||
}
|
||||
|
||||
void __KernelMemoryDoState(PointerWrap &p)
|
||||
{
|
||||
kernelMemory.DoState(p);
|
||||
userMemory.DoState(p);
|
||||
p.DoMarker("sceKernelMemory");
|
||||
}
|
||||
|
||||
void __KernelMemoryShutdown()
|
||||
{
|
||||
INFO_LOG(HLE,"Shutting down user memory pool: ");
|
||||
@@ -344,13 +375,18 @@ public:
|
||||
sprintf(ptr, "MemPart: %08x - %08x size: %08x", address, address + sz, sz);
|
||||
}
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_MPPID; } /// ????
|
||||
int GetIDType() const { return 0; }
|
||||
int GetIDType() const { return PPSSPP_KERNEL_TMID_PMB; }
|
||||
|
||||
PartitionMemoryBlock(BlockAllocator *_alloc, u32 size, bool fromEnd)
|
||||
{
|
||||
alloc = _alloc;
|
||||
address = alloc->Alloc(size, fromEnd, "PMB");
|
||||
alloc->ListBlocks();
|
||||
|
||||
// 0 is used for save states to wake up.
|
||||
if (size != 0)
|
||||
{
|
||||
address = alloc->Alloc(size, fromEnd, "PMB");
|
||||
alloc->ListBlocks();
|
||||
}
|
||||
}
|
||||
~PartitionMemoryBlock()
|
||||
{
|
||||
@@ -358,6 +394,14 @@ public:
|
||||
}
|
||||
bool IsValid() {return address != (u32)-1;}
|
||||
BlockAllocator *alloc;
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(address);
|
||||
p.Do(name);
|
||||
p.DoMarker("PMB");
|
||||
}
|
||||
|
||||
u32 address;
|
||||
char name[32];
|
||||
};
|
||||
@@ -439,17 +483,169 @@ void sceKernelPrintf()
|
||||
RETURN(0);
|
||||
}
|
||||
|
||||
void sceKernelSetCompiledSdkVersion()
|
||||
void sceKernelSetCompiledSdkVersion(int sdkVersion)
|
||||
{
|
||||
//pretty sure this only takes one arg
|
||||
ERROR_LOG(HLE,"UNIMPL sceKernelSetCompiledSdkVersion(%08x)", PARAM(0));
|
||||
RETURN(0);
|
||||
int sdkMainVersion = sdkVersion & 0xFFFF0000;
|
||||
bool valiSDK = false;
|
||||
switch(sdkMainVersion)
|
||||
{
|
||||
case 0x1000000:
|
||||
case 0x1050000:
|
||||
case 0x2000000:
|
||||
case 0x2050000:
|
||||
case 0x2060000:
|
||||
case 0x2070000:
|
||||
case 0x2080000:
|
||||
case 0x3000000:
|
||||
case 0x3010000:
|
||||
case 0x3030000:
|
||||
case 0x3040000:
|
||||
case 0x3050000:
|
||||
case 0x3060000:
|
||||
valiSDK = true;
|
||||
break;
|
||||
default:
|
||||
valiSDK = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(valiSDK)
|
||||
{
|
||||
sdkVersion_ = sdkVersion;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILEDSDKVERSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(HLE,"sceKernelSetCompiledSdkVersion unknown SDK : %x\n",sdkVersion);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void sceKernelSetCompilerVersion()
|
||||
void sceKernelSetCompiledSdkVersion370(int sdkVersion)
|
||||
{
|
||||
ERROR_LOG(HLE,"UNIMPL sceKernelSetCompilerVersion(%08x, %08x, %08x, %08x)", PARAM(0),PARAM(1),PARAM(2),PARAM(3));
|
||||
RETURN(0);
|
||||
int sdkMainVersion = sdkVersion & 0xFFFF0000;
|
||||
if(sdkMainVersion == 0x3070000)
|
||||
{
|
||||
sdkVersion_ = sdkVersion;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILEDSDKVERSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(HLE,"sceKernelSetCompiledSdkVersion370 unknown SDK : %x\n",sdkVersion);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void sceKernelSetCompiledSdkVersion380_390(int sdkVersion)
|
||||
{
|
||||
int sdkMainVersion = sdkVersion & 0xFFFF0000;
|
||||
if(sdkMainVersion == 0x3080000 || sdkMainVersion == 0x3090000)
|
||||
{
|
||||
sdkVersion_ = sdkVersion;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILEDSDKVERSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(HLE,"sceKernelSetCompiledSdkVersion380_390 unknown SDK : %x\n",sdkVersion);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void sceKernelSetCompiledSdkVersion395(int sdkVersion)
|
||||
{
|
||||
int sdkMainVersion = sdkVersion & 0xFFFFFF00;
|
||||
if(sdkMainVersion == 0x4000000
|
||||
|| sdkMainVersion == 0x4000100
|
||||
|| sdkMainVersion == 0x4000500
|
||||
|| sdkMainVersion == 0x3090500
|
||||
|| sdkMainVersion == 0x3090600)
|
||||
{
|
||||
sdkVersion_ = sdkVersion;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILEDSDKVERSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(HLE,"sceKernelSetCompiledSdkVersion395 unknown SDK : %x\n",sdkVersion);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void sceKernelSetCompiledSdkVersion600_602(int sdkVersion)
|
||||
{
|
||||
int sdkMainVersion = sdkVersion & 0xFFFF0000;
|
||||
if(sdkMainVersion == 0x6010000
|
||||
|| sdkMainVersion == 0x6000000
|
||||
|| sdkMainVersion == 0x6020000)
|
||||
{
|
||||
sdkVersion_ = sdkVersion;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILEDSDKVERSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(HLE,"sceKernelSetCompiledSdkVersion600_602 unknown SDK : %x\n",sdkVersion);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void sceKernelSetCompiledSdkVersion603_605(int sdkVersion)
|
||||
{
|
||||
int sdkMainVersion = sdkVersion & 0xFFFF0000;
|
||||
if(sdkMainVersion == 0x6040000
|
||||
|| sdkMainVersion == 0x6030000
|
||||
|| sdkMainVersion == 0x6050000)
|
||||
{
|
||||
sdkVersion_ = sdkVersion;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILEDSDKVERSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(HLE,"sceKernelSetCompiledSdkVersion603_605 unknown SDK : %x\n",sdkVersion);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void sceKernelSetCompiledSdkVersion606(int sdkVersion)
|
||||
{
|
||||
int sdkMainVersion = sdkVersion & 0xFFFF0000;
|
||||
if(sdkMainVersion == 0x6060000)
|
||||
{
|
||||
sdkVersion_ = sdkVersion;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILEDSDKVERSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(HLE,"sceKernelSetCompiledSdkVersion606 unknown SDK : %x\n",sdkVersion);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int sceKernelGetCompiledSdkVersion()
|
||||
{
|
||||
if(!(flags_ & SCE_KERNEL_HASCOMPILEDSDKVERSION))
|
||||
return 0;
|
||||
return sdkVersion_;
|
||||
}
|
||||
|
||||
void sceKernelSetCompilerVersion(int version)
|
||||
{
|
||||
compilerVersion_ = version;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILERVERSION;
|
||||
}
|
||||
|
||||
KernelObject *__KernelMemoryFPLObject()
|
||||
{
|
||||
return new FPL;
|
||||
}
|
||||
|
||||
KernelObject *__KernelMemoryVPLObject()
|
||||
{
|
||||
return new VPL;
|
||||
}
|
||||
|
||||
KernelObject *__KernelMemoryPMBObject()
|
||||
{
|
||||
// TODO: We could theoretically handle kernelMemory too, but we don't support that now anyway.
|
||||
return new PartitionMemoryBlock(&userMemory, 0, true);
|
||||
}
|
||||
|
||||
// VPL = variable length memory pool
|
||||
@@ -642,58 +838,54 @@ void sceKernelReferVplStatus()
|
||||
RETURN(0);
|
||||
}
|
||||
|
||||
void AllocMemoryBlock() {
|
||||
const char *pname = Memory::GetCharPointer(PARAM(0));
|
||||
int type = PARAM(1);
|
||||
u32 size = PARAM(2);
|
||||
int paramsAddr = PARAM(3);
|
||||
|
||||
DEBUG_LOG(HLE,"AllocMemoryBlock(SysMemUserForUser_FE707FDF)(%s, %i, %i, %08x)", pname, type, size, paramsAddr);
|
||||
|
||||
// TODO: Make proper kernel objects for these instead of using the UID as a pointer.
|
||||
|
||||
u32 AllocMemoryBlock(const char *pname, u32 type, u32 size, u32 paramsAddr) {
|
||||
|
||||
// Just support allocating a block in the user region.
|
||||
|
||||
u32 blockPtr = userMemory.Alloc(size, false, pname);
|
||||
u32 blockPtr = userMemory.Alloc(size, type == 1, pname);
|
||||
INFO_LOG(HLE,"%08x=AllocMemoryBlock(SysMemUserForUser_FE707FDF)(%s, %i, %08x, %08x)", blockPtr, pname, type, size, paramsAddr);
|
||||
|
||||
// Create a UID object??? Nah, let's just us the UID itself (hack!)
|
||||
|
||||
RETURN(blockPtr);
|
||||
return blockPtr;
|
||||
}
|
||||
|
||||
void FreeMemoryBlock() {
|
||||
SceUID uid = PARAM(0);
|
||||
DEBUG_LOG(HLE, "FreeMemoryBlock(%i)", uid);
|
||||
u32 FreeMemoryBlock(u32 uid) {
|
||||
INFO_LOG(HLE, "FreeMemoryBlock(%08x)", uid);
|
||||
userMemory.Free(uid);
|
||||
RETURN(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GetMemoryBlockPtr() {
|
||||
SceUID uid = PARAM(0);
|
||||
DEBUG_LOG(HLE, "GetMemoryBlockPtr(%i)", uid);
|
||||
RETURN(uid);
|
||||
u32 GetMemoryBlockPtr(u32 uid, u32 addr) {
|
||||
INFO_LOG(HLE, "GetMemoryBlockPtr(%08x, %08x)", uid, addr);
|
||||
Memory::Write_U32(uid, addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const HLEFunction SysMemUserForUser[] =
|
||||
{
|
||||
const HLEFunction SysMemUserForUser[] = {
|
||||
{0xA291F107,sceKernelMaxFreeMemSize, "sceKernelMaxFreeMemSize"},
|
||||
{0xF919F628,sceKernelTotalFreeMemSize,"sceKernelTotalFreeMemSize"},
|
||||
{0x3FC9AE6A,sceKernelDevkitVersion, "sceKernelDevkitVersion"},
|
||||
{0x3FC9AE6A,sceKernelDevkitVersion, "sceKernelDevkitVersion"},
|
||||
{0x237DBD4F,sceKernelAllocPartitionMemory,"sceKernelAllocPartitionMemory"}, //(int size) ?
|
||||
{0xB6D61D02,sceKernelFreePartitionMemory,"sceKernelFreePartitionMemory"}, //(void *ptr) ?
|
||||
{0x9D9A5BA1,sceKernelGetBlockHeadAddr,"sceKernelGetBlockHeadAddr"}, //(void *ptr) ?
|
||||
{0x13a5abef,sceKernelPrintf,"sceKernelPrintf 0x13a5abef"},
|
||||
{0x7591c7db,sceKernelSetCompiledSdkVersion,"sceKernelSetCompiledSdkVersion"},
|
||||
{0x342061E5,0,"sceKernelSetCompiledSdkVersion370"},
|
||||
{0x315AD3A0,0,"sceKernelSetCompiledSdkVersion380_390"},
|
||||
{0xEBD5C3E6,0,"sceKernelSetCompiledSdkVersion395"},
|
||||
{0xf77d77cb,sceKernelSetCompilerVersion,"sceKernelSetCompilerVersion"},
|
||||
{0x35669d4c,0,"sceKernelSetCompiledSdkVersion600_602"}, //??
|
||||
{0x1b4217bc,0,"sceKernelSetCompiledSdkVersion603_605"},
|
||||
{0x358ca1bb,0,"sceKernelSetCompiledSdkVersion606"},
|
||||
{0x7591c7db,&WrapV_I<sceKernelSetCompiledSdkVersion>,"sceKernelSetCompiledSdkVersion"},
|
||||
{0x342061E5,&WrapV_I<sceKernelSetCompiledSdkVersion370>,"sceKernelSetCompiledSdkVersion370"},
|
||||
{0x315AD3A0,&WrapV_I<sceKernelSetCompiledSdkVersion380_390>,"sceKernelSetCompiledSdkVersion380_390"},
|
||||
{0xEBD5C3E6,&WrapV_I<sceKernelSetCompiledSdkVersion395>,"sceKernelSetCompiledSdkVersion395"},
|
||||
{0xf77d77cb,&WrapV_I<sceKernelSetCompilerVersion>,"sceKernelSetCompilerVersion"},
|
||||
{0x35669d4c,&WrapV_I<sceKernelSetCompiledSdkVersion600_602>,"sceKernelSetCompiledSdkVersion600_602"}, //??
|
||||
{0x1b4217bc,&WrapV_I<sceKernelSetCompiledSdkVersion603_605>,"sceKernelSetCompiledSdkVersion603_605"},
|
||||
{0x358ca1bb,&WrapV_I<sceKernelSetCompiledSdkVersion606>,"sceKernelSetCompiledSdkVersion606"},
|
||||
{0xfc114573,&WrapI_V<sceKernelGetCompiledSdkVersion>,"sceKernelGetCompiledSdkVersion"},
|
||||
// Obscure raw block API
|
||||
{0xDB83A952,GetMemoryBlockPtr,"SysMemUserForUser_DB83A952"}, // GetMemoryBlockAddr
|
||||
{0x91DE343C,0,"SysMemUserForUser_91DE343C"},
|
||||
{0x50F61D8A,FreeMemoryBlock,"SysMemUserForUser_50F61D8A"}, // FreeMemoryBlock
|
||||
{0xFE707FDF,AllocMemoryBlock,"SysMemUserForUser_FE707FDF"}, // AllocMemoryBlock
|
||||
{0xDB83A952,WrapU_UU<GetMemoryBlockPtr>,"SysMemUserForUser_DB83A952"}, // GetMemoryBlockAddr
|
||||
{0x50F61D8A,WrapU_U<FreeMemoryBlock>,"SysMemUserForUser_50F61D8A"}, // FreeMemoryBlock
|
||||
{0xFE707FDF,WrapU_CUUU<AllocMemoryBlock>,"SysMemUserForUser_FE707FDF"}, // AllocMemoryBlock
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../Util/BlockAllocator.h"
|
||||
#include "sceKernel.h"
|
||||
|
||||
|
||||
//todo: "real" memory block allocator,
|
||||
@@ -29,7 +30,11 @@ extern BlockAllocator userMemory;
|
||||
extern BlockAllocator kernelMemory;
|
||||
|
||||
void __KernelMemoryInit();
|
||||
void __KernelMemoryDoState(PointerWrap &p);
|
||||
void __KernelMemoryShutdown();
|
||||
KernelObject *__KernelMemoryFPLObject();
|
||||
KernelObject *__KernelMemoryVPLObject();
|
||||
KernelObject *__KernelMemoryPMBObject();
|
||||
|
||||
void sceKernelCreateVpl();
|
||||
void sceKernelDeleteVpl();
|
||||
@@ -49,5 +54,6 @@ void sceKernelFreeFpl();
|
||||
void sceKernelCancelFpl();
|
||||
void sceKernelReferFplStatus();
|
||||
|
||||
int sceKernelGetCompiledSdkVersion();
|
||||
|
||||
void Register_SysMemUserForUser();
|
||||
@@ -117,13 +117,45 @@ public:
|
||||
nm.entry_addr);
|
||||
}
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_MODULE; }
|
||||
int GetIDType() const { return 0; }
|
||||
int GetIDType() const { return PPSSPP_KERNEL_TMID_Module; }
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(nm);
|
||||
p.Do(memoryBlockAddr);
|
||||
p.DoMarker("Module");
|
||||
}
|
||||
|
||||
NativeModule nm;
|
||||
|
||||
u32 memoryBlockAddr;
|
||||
};
|
||||
|
||||
KernelObject *__KernelModuleObject()
|
||||
{
|
||||
return new Module;
|
||||
}
|
||||
|
||||
class AfterModuleEntryCall : public Action {
|
||||
public:
|
||||
AfterModuleEntryCall() {}
|
||||
SceUID moduleID_;
|
||||
u32 retValAddr;
|
||||
virtual void run();
|
||||
virtual void DoState(PointerWrap &p) {
|
||||
p.Do(moduleID_);
|
||||
p.Do(retValAddr);
|
||||
p.DoMarker("AfterModuleEntryCall");
|
||||
}
|
||||
static Action *Create() {
|
||||
return new AfterModuleEntryCall;
|
||||
}
|
||||
};
|
||||
|
||||
void AfterModuleEntryCall::run() {
|
||||
Memory::Write_U32(retValAddr, currentMIPS->r[2]);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// MODULES
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -156,10 +188,24 @@ struct SceKernelSMOption {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// STATE BEGIN
|
||||
static int actionAfterModule;
|
||||
static SceUID mainModuleID; // hack
|
||||
// STATE END
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void __KernelModuleInit()
|
||||
{
|
||||
actionAfterModule = __KernelRegisterActionType(AfterModuleEntryCall::Create);
|
||||
}
|
||||
|
||||
void __KernelModuleDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(mainModuleID);
|
||||
p.Do(actionAfterModule);
|
||||
__KernelRestoreActionType(actionAfterModule, AfterModuleEntryCall::Create);
|
||||
p.DoMarker("sceKernelModule");
|
||||
}
|
||||
|
||||
Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, std::string *error_string)
|
||||
{
|
||||
Module *module = new Module;
|
||||
@@ -249,7 +295,7 @@ Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, std::string *erro
|
||||
if (sceModuleInfoSection != -1)
|
||||
modinfo = (PspModuleInfo *)Memory::GetPointer(reader.GetSectionAddr(sceModuleInfoSection));
|
||||
else
|
||||
modinfo = (PspModuleInfo *)Memory::GetPointer(reader.GetVaddr() + (reader.GetSegmentPaddr(0) & 0x7FFFFFFF) - reader.GetSegmentOffset(0));
|
||||
modinfo = (PspModuleInfo *)Memory::GetPointer(reader.GetSegmentVaddr(0) + (reader.GetSegmentPaddr(0) & 0x7FFFFFFF) - reader.GetSegmentOffset(0));
|
||||
|
||||
// Check for module blacklist - we don't allow games to load these modules from disc
|
||||
// as we have HLE implementations and the originals won't run in the emu because they
|
||||
@@ -448,13 +494,13 @@ bool __KernelLoadPBP(const char *filename, std::string *error_string)
|
||||
in.seekg(offsets[5]);
|
||||
//in.read((char*)&id,4);
|
||||
{
|
||||
u8 *temp = new u8[1024*1024*8];
|
||||
in.read((char*)temp, 1024*1024*8);
|
||||
Module *module = __KernelLoadELFFromPtr(temp, PSP_GetDefaultLoadAddress(), error_string);
|
||||
u8 *elftemp = new u8[1024*1024*8];
|
||||
in.read((char*)elftemp, 1024*1024*8);
|
||||
Module *module = __KernelLoadELFFromPtr(elftemp, PSP_GetDefaultLoadAddress(), error_string);
|
||||
if (!module)
|
||||
return false;
|
||||
mipsr4k.pc = module->nm.entry_addr;
|
||||
delete [] temp;
|
||||
delete [] elftemp;
|
||||
}
|
||||
in.close();
|
||||
return true;
|
||||
@@ -515,6 +561,7 @@ bool __KernelLoadExec(const char *filename, SceKernelLoadExecParam *param, std::
|
||||
if (__KernelIsRunning())
|
||||
__KernelShutdown();
|
||||
|
||||
__KernelModuleInit();
|
||||
__KernelInit();
|
||||
|
||||
PSPFileInfo info = pspFileSystem.GetFileInfo(filename);
|
||||
@@ -599,8 +646,7 @@ u32 sceKernelLoadModule(const char *name, u32 flags)
|
||||
return SCE_KERNEL_ERROR_NOFILE;
|
||||
}
|
||||
|
||||
if (!size)
|
||||
{
|
||||
if (!size) {
|
||||
ERROR_LOG(LOADER, "sceKernelLoadModule(%s, %08x): Module file is size 0", name, flags);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_OBJECT;
|
||||
}
|
||||
@@ -610,10 +656,8 @@ u32 sceKernelLoadModule(const char *name, u32 flags)
|
||||
SceKernelLMOption *lmoption = 0;
|
||||
int position = 0;
|
||||
// TODO: Use position to decide whether to load high or low
|
||||
if (PARAM(2))
|
||||
{
|
||||
SceKernelLMOption *lmoption = (SceKernelLMOption *)Memory::GetPointer(PARAM(2));
|
||||
|
||||
if (PARAM(2)) {
|
||||
lmoption = (SceKernelLMOption *)Memory::GetPointer(PARAM(2));
|
||||
}
|
||||
|
||||
Module *module = 0;
|
||||
@@ -635,27 +679,13 @@ u32 sceKernelLoadModule(const char *name, u32 flags)
|
||||
INFO_LOG(HLE,"%i=sceKernelLoadModule(name=%s,flag=%08x,%08x,%08x,%08x,position = %08x)",
|
||||
module->GetUID(),name,flags,
|
||||
lmoption->size,lmoption->mpidtext,lmoption->mpiddata,lmoption->position);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
INFO_LOG(HLE,"%i=sceKernelLoadModule(name=%s,flag=%08x,(...))", module->GetUID(), name, flags);
|
||||
}
|
||||
|
||||
return module->GetUID();
|
||||
}
|
||||
|
||||
class AfterModuleEntryCall : public Action {
|
||||
public:
|
||||
AfterModuleEntryCall() {}
|
||||
Module *module_;
|
||||
u32 retValAddr;
|
||||
virtual void run();
|
||||
};
|
||||
|
||||
void AfterModuleEntryCall::run() {
|
||||
Memory::Write_U32(retValAddr, currentMIPS->r[2]);
|
||||
}
|
||||
|
||||
void sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 returnValueAddr, u32 optionAddr)
|
||||
{
|
||||
ERROR_LOG(HLE,"UNIMPL sceKernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x,%08x)",
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
#include "sceKernel.h"
|
||||
#include "HLE.h"
|
||||
|
||||
KernelObject *__KernelModuleObject();
|
||||
void __KernelModuleDoState(PointerWrap &p);
|
||||
|
||||
u32 __KernelGetModuleGP(SceUID module);
|
||||
bool __KernelLoadExec(const char *filename, SceKernelLoadExecParam *param, std::string *error_string);
|
||||
|
||||
|
||||
@@ -56,10 +56,12 @@ struct MsgPipe : public KernelObject
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_MPPID; }
|
||||
int GetIDType() const { return SCE_KERNEL_TMID_Mpipe; }
|
||||
|
||||
NativeMsgPipe nmp;
|
||||
|
||||
std::vector<MsgPipeWaitingThread> sendWaitingThreads;
|
||||
std::vector<MsgPipeWaitingThread> receiveWaitingThreads;
|
||||
MsgPipe() : buffer(NULL) {}
|
||||
~MsgPipe()
|
||||
{
|
||||
if (buffer != NULL)
|
||||
delete [] buffer;
|
||||
}
|
||||
|
||||
void AddWaitingThread(std::vector<MsgPipeWaitingThread> &list, SceUID id, u32 addr, u32 size, int waitMode, u32 transferredBytesAddr, bool usePrio)
|
||||
{
|
||||
@@ -98,7 +100,7 @@ struct MsgPipe : public KernelObject
|
||||
if (sendWaitingThreads.empty())
|
||||
return;
|
||||
MsgPipeWaitingThread *thread = &sendWaitingThreads.front();
|
||||
if (nmp.freeSize >= thread->bufSize)
|
||||
if ((u32) nmp.freeSize >= thread->bufSize)
|
||||
{
|
||||
// Put all the data to the buffer
|
||||
memcpy(buffer + (nmp.bufSize - nmp.freeSize), Memory::GetPointer(thread->bufAddr), thread->bufSize);
|
||||
@@ -126,7 +128,7 @@ struct MsgPipe : public KernelObject
|
||||
if (receiveWaitingThreads.empty())
|
||||
return;
|
||||
MsgPipeWaitingThread *thread = &receiveWaitingThreads.front();
|
||||
if (nmp.bufSize - nmp.freeSize >= thread->bufSize)
|
||||
if ((u32) nmp.bufSize - (u32) nmp.freeSize >= thread->bufSize)
|
||||
{
|
||||
// Get the needed data from the buffer
|
||||
Memory::Memcpy(thread->bufAddr, buffer, thread->bufSize);
|
||||
@@ -150,9 +152,36 @@ struct MsgPipe : public KernelObject
|
||||
}
|
||||
}
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(nmp);
|
||||
MsgPipeWaitingThread mpwt1 = {0}, mpwt2 = {0};
|
||||
p.Do(sendWaitingThreads, mpwt1);
|
||||
p.Do(receiveWaitingThreads, mpwt2);
|
||||
bool hasBuffer = buffer != NULL;
|
||||
p.Do(hasBuffer);
|
||||
if (hasBuffer)
|
||||
{
|
||||
if (buffer == NULL)
|
||||
buffer = new u8[nmp.bufSize];
|
||||
p.DoArray(buffer, nmp.bufSize);
|
||||
}
|
||||
p.DoMarker("MsgPipe");
|
||||
}
|
||||
|
||||
NativeMsgPipe nmp;
|
||||
|
||||
std::vector<MsgPipeWaitingThread> sendWaitingThreads;
|
||||
std::vector<MsgPipeWaitingThread> receiveWaitingThreads;
|
||||
|
||||
u8 *buffer;
|
||||
};
|
||||
|
||||
KernelObject *__KernelMsgPipeObject()
|
||||
{
|
||||
return new MsgPipe;
|
||||
}
|
||||
|
||||
void sceKernelCreateMsgPipe()
|
||||
{
|
||||
const char *name = Memory::GetCharPointer(PARAM(0));
|
||||
@@ -194,10 +223,6 @@ void sceKernelDeleteMsgPipe()
|
||||
RETURN(error);
|
||||
return;
|
||||
}
|
||||
if (m->buffer != 0)
|
||||
{
|
||||
delete [] m->buffer;
|
||||
}
|
||||
for (u32 i = 0; i < m->sendWaitingThreads.size(); i++)
|
||||
{
|
||||
__KernelResumeThreadFromWait(m->sendWaitingThreads[i].id);
|
||||
@@ -271,7 +296,7 @@ void __KernelSendMsgPipe(MsgPipe *m, u32 sendBufAddr, u32 sendSize, int waitMode
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sendSize <= m->nmp.freeSize)
|
||||
if (sendSize <= (u32) m->nmp.freeSize)
|
||||
{
|
||||
memcpy(m->buffer + (m->nmp.bufSize - m->nmp.freeSize), Memory::GetPointer(sendBufAddr), sendSize);
|
||||
m->nmp.freeSize -= sendSize;
|
||||
@@ -445,7 +470,7 @@ void __KernelReceiveMsgPipe(MsgPipe *m, u32 receiveBufAddr, u32 receiveSize, int
|
||||
else
|
||||
{
|
||||
// Enough data in the buffer: copy just the needed amount of data
|
||||
if (receiveSize <= m->nmp.bufSize - m->nmp.freeSize)
|
||||
if (receiveSize <= (u32) m->nmp.bufSize - (u32) m->nmp.freeSize)
|
||||
{
|
||||
Memory::Memcpy(receiveBufAddr, m->buffer, receiveSize);
|
||||
m->nmp.freeSize += receiveSize;
|
||||
|
||||
@@ -26,4 +26,6 @@ void sceKernelReceiveMsgPipe();
|
||||
void sceKernelReceiveMsgPipeCB();
|
||||
void sceKernelTryReceiveMsgPipe();
|
||||
void sceKernelCancelMsgPipe();
|
||||
void sceKernelReferMsgPipeStatus();
|
||||
void sceKernelReferMsgPipeStatus();
|
||||
|
||||
KernelObject *__KernelMsgPipeObject();
|
||||
+49
-16
@@ -62,6 +62,15 @@ struct Mutex : public KernelObject
|
||||
const char *GetTypeName() {return "Mutex";}
|
||||
static u32 GetMissingErrorCode() { return PSP_MUTEX_ERROR_NO_SUCH_MUTEX; }
|
||||
int GetIDType() const { return SCE_KERNEL_TMID_Mutex; }
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(nm);
|
||||
SceUID dv = 0;
|
||||
p.Do(waitingThreads, dv);
|
||||
p.DoMarker("Mutex");
|
||||
}
|
||||
|
||||
NativeMutex nm;
|
||||
std::vector<SceUID> waitingThreads;
|
||||
};
|
||||
@@ -103,31 +112,61 @@ struct LwMutex : public KernelObject
|
||||
const char *GetTypeName() {return "LwMutex";}
|
||||
static u32 GetMissingErrorCode() { return PSP_LWMUTEX_ERROR_NO_SUCH_LWMUTEX; }
|
||||
int GetIDType() const { return SCE_KERNEL_TMID_LwMutex; }
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(nm);
|
||||
SceUID dv = 0;
|
||||
p.Do(waitingThreads, dv);
|
||||
p.DoMarker("LwMutex");
|
||||
}
|
||||
|
||||
NativeLwMutex nm;
|
||||
std::vector<SceUID> waitingThreads;
|
||||
};
|
||||
|
||||
bool mutexInitComplete = false;
|
||||
int mutexWaitTimer = 0;
|
||||
int lwMutexWaitTimer = 0;
|
||||
static int mutexWaitTimer = 0;
|
||||
static int lwMutexWaitTimer = 0;
|
||||
// Thread -> Mutex locks for thread end.
|
||||
typedef std::multimap<SceUID, SceUID> MutexMap;
|
||||
MutexMap mutexHeldLocks;
|
||||
static MutexMap mutexHeldLocks;
|
||||
|
||||
void __KernelMutexInit()
|
||||
{
|
||||
mutexWaitTimer = CoreTiming::RegisterEvent("MutexTimeout", &__KernelMutexTimeout);
|
||||
lwMutexWaitTimer = CoreTiming::RegisterEvent("LwMutexTimeout", &__KernelLwMutexTimeout);
|
||||
mutexWaitTimer = CoreTiming::RegisterEvent("MutexTimeout", __KernelMutexTimeout);
|
||||
lwMutexWaitTimer = CoreTiming::RegisterEvent("LwMutexTimeout", __KernelLwMutexTimeout);
|
||||
|
||||
// TODO: Install on first mutex (if it's slow?)
|
||||
__KernelListenThreadEnd(&__KernelMutexThreadEnd);
|
||||
}
|
||||
|
||||
mutexInitComplete = true;
|
||||
void __KernelMutexDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(mutexWaitTimer);
|
||||
CoreTiming::RestoreRegisterEvent(mutexWaitTimer, "MutexTimeout", __KernelMutexTimeout);
|
||||
p.Do(lwMutexWaitTimer);
|
||||
CoreTiming::RestoreRegisterEvent(lwMutexWaitTimer, "LwMutexTimeout", __KernelLwMutexTimeout);
|
||||
p.Do(mutexHeldLocks);
|
||||
p.DoMarker("sceKernelMutex");
|
||||
}
|
||||
|
||||
KernelObject *__KernelMutexObject()
|
||||
{
|
||||
return new Mutex;
|
||||
}
|
||||
|
||||
KernelObject *__KernelLwMutexObject()
|
||||
{
|
||||
return new LwMutex;
|
||||
}
|
||||
|
||||
void __KernelMutexShutdown()
|
||||
{
|
||||
mutexHeldLocks.clear();
|
||||
}
|
||||
|
||||
void __KernelMutexAcquireLock(Mutex *mutex, int count, SceUID thread)
|
||||
{
|
||||
#if _DEBUG
|
||||
#if defined(_DEBUG)
|
||||
std::pair<MutexMap::iterator, MutexMap::iterator> locked = mutexHeldLocks.equal_range(thread);
|
||||
for (MutexMap::iterator iter = locked.first; iter != locked.second; ++iter)
|
||||
_dbg_assert_msg_(HLE, (*iter).second != mutex->GetUID(), "Thread %d / mutex %d wasn't removed from mutexHeldLocks properly.", thread, mutex->GetUID());
|
||||
@@ -184,9 +223,6 @@ std::vector<SceUID>::iterator __KernelMutexFindPriority(std::vector<SceUID> &wai
|
||||
|
||||
int sceKernelCreateMutex(const char *name, u32 attr, int initialCount, u32 optionsPtr)
|
||||
{
|
||||
if (!mutexInitComplete)
|
||||
__KernelMutexInit();
|
||||
|
||||
if (!name)
|
||||
{
|
||||
WARN_LOG(HLE, "%08x=sceKernelCreateMutex(): invalid name", SCE_KERNEL_ERROR_ERROR);
|
||||
@@ -500,9 +536,6 @@ int sceKernelUnlockMutex(SceUID id, int count)
|
||||
|
||||
int sceKernelCreateLwMutex(u32 workareaPtr, const char *name, u32 attr, int initialCount, u32 optionsPtr)
|
||||
{
|
||||
if (!mutexInitComplete)
|
||||
__KernelMutexInit();
|
||||
|
||||
if (!name)
|
||||
{
|
||||
WARN_LOG(HLE, "%08x=sceKernelCreateLwMutex(): invalid name", SCE_KERNEL_ERROR_ERROR);
|
||||
@@ -856,4 +889,4 @@ int sceKernelUnlockLwMutex(u32 workareaPtr, int count)
|
||||
Memory::WriteStruct(workareaPtr, &workarea);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -34,4 +34,10 @@ int sceKernelUnlockLwMutex(u32 workareaPtr, int count);
|
||||
|
||||
void __KernelMutexTimeout(u64 userdata, int cyclesLate);
|
||||
void __KernelLwMutexTimeout(u64 userdata, int cyclesLate);
|
||||
void __KernelMutexThreadEnd(SceUID thread);
|
||||
void __KernelMutexThreadEnd(SceUID thread);
|
||||
|
||||
void __KernelMutexInit();
|
||||
void __KernelMutexDoState(PointerWrap &p);
|
||||
void __KernelMutexShutdown();
|
||||
KernelObject *__KernelMutexObject();
|
||||
KernelObject *__KernelLwMutexObject();
|
||||
@@ -57,17 +57,35 @@ struct Semaphore : public KernelObject
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_SEMID; }
|
||||
int GetIDType() const { return SCE_KERNEL_TMID_Semaphore; }
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(ns);
|
||||
SceUID dv = 0;
|
||||
p.Do(waitingThreads, dv);
|
||||
p.DoMarker("Semaphore");
|
||||
}
|
||||
|
||||
NativeSemaphore ns;
|
||||
std::vector<SceUID> waitingThreads;
|
||||
};
|
||||
|
||||
bool semaInitComplete = false;
|
||||
int semaWaitTimer = 0;
|
||||
static int semaWaitTimer = 0;
|
||||
|
||||
void __KernelSemaInit()
|
||||
{
|
||||
semaWaitTimer = CoreTiming::RegisterEvent("SemaphoreTimeout", &__KernelSemaTimeout);
|
||||
semaInitComplete = true;
|
||||
semaWaitTimer = CoreTiming::RegisterEvent("SemaphoreTimeout", __KernelSemaTimeout);
|
||||
}
|
||||
|
||||
void __KernelSemaDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(semaWaitTimer);
|
||||
CoreTiming::RestoreRegisterEvent(semaWaitTimer, "SemaphoreTimeout", __KernelSemaTimeout);
|
||||
p.DoMarker("sceKernelSema");
|
||||
}
|
||||
|
||||
KernelObject *__KernelSemaphoreObject()
|
||||
{
|
||||
return new Semaphore;
|
||||
}
|
||||
|
||||
// Returns whether the thread should be removed.
|
||||
@@ -137,7 +155,6 @@ std::vector<SceUID>::iterator __KernelSemaFindPriority(std::vector<SceUID> &wait
|
||||
return best;
|
||||
}
|
||||
|
||||
// int sceKernelCancelSema(SceUID id, int newCount, int *numWaitThreads);
|
||||
int sceKernelCancelSema(SceUID id, int newCount, u32 numWaitThreadsPtr)
|
||||
{
|
||||
DEBUG_LOG(HLE, "sceKernelCancelSema(%i)", id);
|
||||
@@ -170,12 +187,8 @@ int sceKernelCancelSema(SceUID id, int newCount, u32 numWaitThreadsPtr)
|
||||
}
|
||||
}
|
||||
|
||||
//SceUID sceKernelCreateSema(const char *name, SceUInt attr, int initVal, int maxVal, SceKernelSemaOptParam *option);
|
||||
int sceKernelCreateSema(const char* name, u32 attr, int initVal, int maxVal, u32 optionPtr)
|
||||
{
|
||||
if (!semaInitComplete)
|
||||
__KernelSemaInit();
|
||||
|
||||
if (!name)
|
||||
{
|
||||
WARN_LOG(HLE, "%08x=sceKernelCreateSema(): invalid name", SCE_KERNEL_ERROR_ERROR);
|
||||
@@ -209,7 +222,6 @@ int sceKernelCreateSema(const char* name, u32 attr, int initVal, int maxVal, u32
|
||||
return id;
|
||||
}
|
||||
|
||||
//int sceKernelDeleteSema(SceUID semaid);
|
||||
int sceKernelDeleteSema(SceUID id)
|
||||
{
|
||||
DEBUG_LOG(HLE, "sceKernelDeleteSema(%i)", id);
|
||||
@@ -231,7 +243,6 @@ int sceKernelDeleteSema(SceUID id)
|
||||
}
|
||||
}
|
||||
|
||||
//int sceKernelDeleteSema(SceUID semaid, SceKernelSemaInfo *info);
|
||||
int sceKernelReferSemaStatus(SceUID id, u32 infoPtr)
|
||||
{
|
||||
u32 error;
|
||||
@@ -248,8 +259,7 @@ int sceKernelReferSemaStatus(SceUID id, u32 infoPtr)
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
//int sceKernelSignalSema(SceUID semaid, int signal);
|
||||
|
||||
int sceKernelSignalSema(SceUID id, int signal)
|
||||
{
|
||||
u32 error;
|
||||
@@ -364,15 +374,13 @@ int __KernelWaitSema(SceUID id, int wantedCount, u32 timeoutPtr, const char *bad
|
||||
}
|
||||
}
|
||||
|
||||
//int sceKernelWaitSema(SceUID semaid, int signal, SceUInt *timeout);
|
||||
int sceKernelWaitSema(SceUID id, int wantedCount, u32 timeoutPtr)
|
||||
{
|
||||
DEBUG_LOG(HLE, "sceKernelWaitSema(%i, %i, %i)", id, wantedCount, timeoutPtr);
|
||||
|
||||
return __KernelWaitSema(id, wantedCount, timeoutPtr, "sceKernelWaitSema: Trying to wait for invalid semaphore %i", false);
|
||||
}
|
||||
}
|
||||
|
||||
//int sceKernelWaitSemaCB(SceUID semaid, int signal, SceUInt *timeout);
|
||||
int sceKernelWaitSemaCB(SceUID id, int wantedCount, u32 timeoutPtr)
|
||||
{
|
||||
DEBUG_LOG(HLE, "sceKernelWaitSemaCB(%i, %i, %i)", id, wantedCount, timeoutPtr);
|
||||
|
||||
@@ -27,3 +27,7 @@ int sceKernelWaitSema(SceUID semaid, int signal, u32 timeoutPtr);
|
||||
int sceKernelWaitSemaCB(SceUID semaid, int signal, u32 timeoutPtr);
|
||||
|
||||
void __KernelSemaTimeout(u64 userdata, int cycleslate);
|
||||
|
||||
void __KernelSemaInit();
|
||||
void __KernelSemaDoState(PointerWrap &p);
|
||||
KernelObject *__KernelSemaphoreObject();
|
||||
+689
-362
File diff suppressed because it is too large.
Load diff
@@ -97,7 +97,11 @@ struct ThreadContext
|
||||
// Internal API, used by implementations of kernel functions
|
||||
|
||||
void __KernelThreadingInit();
|
||||
void __KernelThreadingDoState(PointerWrap &p);
|
||||
void __KernelThreadingDoStateLate(PointerWrap &p);
|
||||
void __KernelThreadingShutdown();
|
||||
KernelObject *__KernelThreadObject();
|
||||
KernelObject *__KernelCallbackObject();
|
||||
|
||||
void __KernelScheduleWakeup(int usFromNow, int threadnumber);
|
||||
SceUID __KernelGetCurThread();
|
||||
@@ -181,8 +185,18 @@ void __KernelSwitchContext(Thread *target, const char *reason);
|
||||
bool __KernelExecutePendingMipsCalls(bool reschedAfter);
|
||||
void __KernelNotifyCallback(RegisteredCallbackType type, SceUID cbId, int notifyArg);
|
||||
|
||||
// Switch to an idle / non-user thread, if not already on one.
|
||||
// Returns whether a switch occurred.
|
||||
bool __KernelSwitchOffThread(const char *reason);
|
||||
|
||||
// A call into game code. These can be pending on a thread.
|
||||
// Similar to Callback-s (NOT CallbackInfos) in JPCSP.
|
||||
class Action;
|
||||
typedef Action *(*ActionCreator)();
|
||||
Action *__KernelCreateAction(int actionType);
|
||||
int __KernelRegisterActionType(ActionCreator creator);
|
||||
void __KernelRestoreActionType(int actionType, ActionCreator creator);
|
||||
|
||||
struct MipsCall {
|
||||
u32 entryPoint;
|
||||
u32 cbId;
|
||||
@@ -195,9 +209,11 @@ struct MipsCall {
|
||||
u32 savedV0;
|
||||
u32 savedV1;
|
||||
bool returnVoid;
|
||||
const char *tag;
|
||||
std::string tag;
|
||||
u32 savedId;
|
||||
bool reschedAfter;
|
||||
|
||||
void DoState(PointerWrap &p);
|
||||
};
|
||||
enum ThreadStatus
|
||||
{
|
||||
|
||||
@@ -30,6 +30,18 @@ struct VTimer : public KernelObject
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_VTID; }
|
||||
int GetIDType() const { return SCE_KERNEL_TMID_VTimer; }
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(size);
|
||||
p.Do(name);
|
||||
p.Do(startTime);
|
||||
p.Do(running);
|
||||
p.Do(handler);
|
||||
p.Do(handlerTime);
|
||||
p.Do(argument);
|
||||
p.DoMarker("VTimer");
|
||||
}
|
||||
|
||||
SceSize size;
|
||||
char name[KERNELOBJECT_MAX_NAME_LENGTH+1];
|
||||
u64 startTime;
|
||||
@@ -39,6 +51,11 @@ struct VTimer : public KernelObject
|
||||
u32 argument;
|
||||
};
|
||||
|
||||
KernelObject *__KernelVTimerObject()
|
||||
{
|
||||
return new VTimer;
|
||||
}
|
||||
|
||||
void sceKernelCreateVTimer()
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceKernelCreateVTimer");
|
||||
|
||||
@@ -23,3 +23,5 @@ void sceKernelSetVTimerHandler();
|
||||
|
||||
// TODO
|
||||
void _sceKernelReturnFromTimerHandler();
|
||||
|
||||
KernelObject *__KernelVTimerObject();
|
||||
+22
-6
@@ -22,16 +22,21 @@
|
||||
#include "scePower.h"
|
||||
#include "sceKernelThread.h"
|
||||
|
||||
static bool volatileMemLocked;
|
||||
|
||||
const int POWER_CB_AUTO = -1;
|
||||
|
||||
const int numberOfCBPowerSlots = 16;
|
||||
static int powerCbSlots[numberOfCBPowerSlots];
|
||||
|
||||
static bool volatileMemLocked;
|
||||
static int powerCbSlots[numberOfCBPowerSlots];
|
||||
|
||||
void __PowerInit() {
|
||||
memset(powerCbSlots, 0, sizeof(powerCbSlots));
|
||||
volatileMemLocked = false;
|
||||
}
|
||||
|
||||
void __PowerDoState(PointerWrap &p) {
|
||||
p.DoArray(powerCbSlots, ARRAY_SIZE(powerCbSlots));
|
||||
p.Do(volatileMemLocked);
|
||||
p.DoMarker("scePower");
|
||||
}
|
||||
|
||||
int scePowerGetBatteryLifePercent() {
|
||||
@@ -163,6 +168,17 @@ void scePowerSetClockFrequency(u32 cpufreq, u32 busfreq, u32 gpufreq) {
|
||||
INFO_LOG(HLE,"scePowerSetClockFrequency(%i,%i,%i)", cpufreq, busfreq, gpufreq);
|
||||
}
|
||||
|
||||
u32 scePowerSetCpuClockFrequency(u32 cpufreq) {
|
||||
CoreTiming::SetClockFrequencyMHz(cpufreq);
|
||||
DEBUG_LOG(HLE,"scePowerSetCpuClockFrequency(%i)", cpufreq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 scePowerSetBusClockFrequency(u32 busfreq) {
|
||||
DEBUG_LOG(HLE,"scePowerSetBusClockFrequency(%i)", busfreq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 scePowerGetCpuClockFrequencyInt() {
|
||||
int freq = CoreTiming::GetClockFrequencyMHz();
|
||||
INFO_LOG(HLE,"%i=scePowerGetCpuClockFrequencyInt()", freq);
|
||||
@@ -218,8 +234,8 @@ static const HLEFunction scePower[] = {
|
||||
{0x0074EF9B,0,"scePowerGetResumeCount"},
|
||||
{0xDFA8BAF8,WrapI_I<scePowerUnregisterCallback>,"scePowerUnregisterCallback"},
|
||||
{0xDB9D28DD,WrapI_I<scePowerUnregisterCallback>,"scePowerUnregitserCallback"}, //haha
|
||||
{0x843FBF43,0,"scePowerSetCpuClockFrequency"},
|
||||
{0xB8D7B3FB,0,"scePowerSetBusClockFrequency"},
|
||||
{0x843FBF43,WrapU_U<scePowerSetCpuClockFrequency>,"scePowerSetCpuClockFrequency"},
|
||||
{0xB8D7B3FB,WrapU_U<scePowerSetBusClockFrequency>,"scePowerSetBusClockFrequency"},
|
||||
{0xFEE03A2F,0,"scePowerGetCpuClockFrequency"},
|
||||
{0x478FE6F5,0,"scePowerGetBusClockFrequency"},
|
||||
{0xFDB5BFE9,WrapU_V<scePowerGetCpuClockFrequencyInt>,"scePowerGetCpuClockFrequencyInt"},
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../Common/ChunkFile.h"
|
||||
|
||||
void __PowerInit();
|
||||
void __PowerDoState(PointerWrap &p);
|
||||
|
||||
void Register_scePower();
|
||||
void Register_sceSuspendForUser();
|
||||
+55
-68
@@ -154,13 +154,13 @@ void __RtcTicksToPspTime(ScePspDateTime &t, u64 ticks)
|
||||
t.microsecond = ticks % 1000000;
|
||||
}
|
||||
|
||||
u64 JumpYMD(u64 year, u64 month, u64 day) {
|
||||
return 367*year - 7*(year+(month+9)/12)/4 + 275*month/9 + day;
|
||||
u64 JumpYMD(u64 year, u64 month, u64 day) {
|
||||
return 367*year - 7*(year+(month+9)/12)/4 + 275*month/9 + day;
|
||||
}
|
||||
|
||||
u64 JumpSeconds(u64 year, u64 month, u64 day, u64 hour, u64 minute, u64 second) {
|
||||
static const u64 secs_per_day = 24 * 60 * 60;
|
||||
return JumpYMD(year, month, day) * secs_per_day + hour * 3600 + minute * 60 + second;
|
||||
static const u64 secs_per_day = 24 * 60 * 60;
|
||||
return JumpYMD(year, month, day) * secs_per_day + hour * 3600 + minute * 60 + second;
|
||||
}
|
||||
|
||||
u64 __RtcPspTimeToTicks(ScePspDateTime &t)
|
||||
@@ -299,7 +299,7 @@ u32 sceRtcGetDayOfWeek(u32 year, u32 month, u32 day)
|
||||
return 0;
|
||||
}
|
||||
year -= month < 3;
|
||||
return ( year + year/4 - year/100 + year/400 + t[month-1] + day) % 7;
|
||||
return (year + year/4 - year/100 + year/400 + t[month-1] + day) % 7;
|
||||
}
|
||||
|
||||
u32 sceRtcGetDaysInMonth(u32 year, u32 month)
|
||||
@@ -307,7 +307,7 @@ u32 sceRtcGetDaysInMonth(u32 year, u32 month)
|
||||
DEBUG_LOG(HLE, "sceRtcGetDaysInMonth(%d, %d)", year, month);
|
||||
u32 numberOfDays;
|
||||
|
||||
if (year <= 0 || month <= 0 || month > 12)
|
||||
if (year == 0 || month == 0 || month > 12)
|
||||
return SCE_KERNEL_ERROR_INVALID_ARGUMENT;
|
||||
|
||||
switch (month)
|
||||
@@ -336,7 +336,7 @@ u32 sceRtcGetDaysInMonth(u32 year, u32 month)
|
||||
u32 sceRtcIsLeapYear(u32 year)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceRtcIsLeapYear(%d)", year);
|
||||
return (year % 4 == 0) && !(year % 100 == 0)|| (year % 400 == 0);
|
||||
return (year % 4 == 0) && (!(year % 100 == 0) || (year % 400 == 0));
|
||||
}
|
||||
|
||||
int sceRtcConvertLocalTimeToUTC(u32 tickLocalPtr,u32 tickUTCPtr)
|
||||
@@ -374,55 +374,56 @@ int sceRtcConvertUtcToLocalTime(u32 tickUTCPtr,u32 tickLocalPtr)
|
||||
int sceRtcCheckValid(u32 datePtr)
|
||||
{
|
||||
DEBUG_LOG(HLE, "sceRtcCheckValid(%d)", datePtr);
|
||||
int ret = 0;
|
||||
|
||||
if (Memory::IsValidAddress(datePtr))
|
||||
{
|
||||
ScePspDateTime pt;
|
||||
Memory::ReadStruct(datePtr, &pt);
|
||||
if (pt.year < 1 || pt.year > 9999)
|
||||
{
|
||||
ret = PSP_TIME_INVALID_YEAR;
|
||||
}
|
||||
else if (pt.month < 1 || pt.month > 12)
|
||||
if (pt.year < 1 || pt.year > 9999)
|
||||
{
|
||||
ret = PSP_TIME_INVALID_MONTH;
|
||||
}
|
||||
else if (pt.day < 1 || pt.day > 31)
|
||||
return PSP_TIME_INVALID_YEAR;
|
||||
}
|
||||
else if (pt.month < 1 || pt.month > 12)
|
||||
{
|
||||
ret = PSP_TIME_INVALID_DAY;
|
||||
}
|
||||
else if (pt.day < 0 || pt.day > 31) // TODO: Needs to check actual days in month, including leaps
|
||||
{
|
||||
ret = PSP_TIME_INVALID_DAY;
|
||||
}
|
||||
else if (pt.hour < 0 || pt.hour > 23)
|
||||
return PSP_TIME_INVALID_MONTH;
|
||||
}
|
||||
else if (pt.day < 1 || pt.day > 31)
|
||||
{
|
||||
ret = PSP_TIME_INVALID_HOUR;
|
||||
}
|
||||
else if (pt.minute < 0 || pt.minute > 59)
|
||||
return PSP_TIME_INVALID_DAY;
|
||||
}
|
||||
else if (pt.day > 31) // TODO: Needs to check actual days in month, including leaps
|
||||
{
|
||||
ret = PSP_TIME_INVALID_MINUTES;
|
||||
}
|
||||
else if (pt.second < 0 || pt.second > 59)
|
||||
return PSP_TIME_INVALID_DAY;
|
||||
}
|
||||
else if (pt.hour > 23)
|
||||
{
|
||||
ret = PSP_TIME_INVALID_SECONDS;
|
||||
}
|
||||
else if (pt.microsecond < 0 || pt.microsecond >= 1000000)
|
||||
return PSP_TIME_INVALID_HOUR;
|
||||
}
|
||||
else if (pt.minute > 59)
|
||||
{
|
||||
ret = PSP_TIME_INVALID_MICROSECONDS;
|
||||
}
|
||||
return PSP_TIME_INVALID_MINUTES;
|
||||
}
|
||||
else if (pt.second > 59)
|
||||
{
|
||||
return PSP_TIME_INVALID_SECONDS;
|
||||
}
|
||||
else if (pt.microsecond >= 1000000)
|
||||
{
|
||||
return PSP_TIME_INVALID_MICROSECONDS;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret=-1;
|
||||
return -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int sceRtcSetTime_t(u32 datePtr, u32 time)
|
||||
{
|
||||
ERROR_LOG(HLE, "HACK sceRtcSetTime_t(%d,%d)", datePtr, time);
|
||||
ERROR_LOG(HLE, "HACK sceRtcSetTime_t(%08x,%d)", datePtr, time);
|
||||
if (Memory::IsValidAddress(datePtr))
|
||||
{
|
||||
ScePspDateTime pt;
|
||||
@@ -439,7 +440,7 @@ int sceRtcSetTime_t(u32 datePtr, u32 time)
|
||||
|
||||
int sceRtcSetTime64_t(u32 datePtr, u64 time)
|
||||
{
|
||||
ERROR_LOG(HLE, "HACK sceRtcSetTime64_t(%d,%d)", datePtr, time);
|
||||
ERROR_LOG(HLE, "HACK sceRtcSetTime64_t(%08x,%lld)", datePtr, time);
|
||||
if (Memory::IsValidAddress(datePtr))
|
||||
{
|
||||
ScePspDateTime pt;
|
||||
@@ -454,16 +455,15 @@ int sceRtcSetTime64_t(u32 datePtr, u64 time)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int sceRtcGetTime_t(u32 datePtr, u32 timePtr)
|
||||
{
|
||||
ERROR_LOG(HLE, "HACK sceRtcGetTime_t(%d,%d)", datePtr, time);
|
||||
ERROR_LOG(HLE, "HACK sceRtcGetTime_t(%08x,%08x)", datePtr, timePtr);
|
||||
if (Memory::IsValidAddress(datePtr)&&Memory::IsValidAddress(timePtr))
|
||||
{
|
||||
ScePspDateTime pt;
|
||||
Memory::ReadStruct(datePtr, &pt);
|
||||
pt.year-=1969;
|
||||
u64 result = __RtcPspTimeToTicks(pt)/1000000ULL;
|
||||
u32 result = (u32) (__RtcPspTimeToTicks(pt)/1000000ULL);
|
||||
Memory::Write_U32(result, timePtr);
|
||||
}
|
||||
else
|
||||
@@ -473,10 +473,9 @@ int sceRtcGetTime_t(u32 datePtr, u32 timePtr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int sceRtcGetTime64_t(u32 datePtr, u32 timePtr)
|
||||
{
|
||||
ERROR_LOG(HLE, "HACK sceRtcGetTime64_t(%d,%d)", datePtr, time);
|
||||
ERROR_LOG(HLE, "HACK sceRtcGetTime64_t(%08x,%08x)", datePtr, timePtr);
|
||||
if (Memory::IsValidAddress(datePtr)&&Memory::IsValidAddress(timePtr))
|
||||
{
|
||||
ScePspDateTime pt;
|
||||
@@ -492,8 +491,6 @@ int sceRtcGetTime64_t(u32 datePtr, u32 timePtr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int sceRtcSetDosTime(u32 datePtr, u32 dosTime)
|
||||
{
|
||||
ERROR_LOG(HLE, "HACK sceRtcSetDosTime(%d,%d)", datePtr, dosTime);
|
||||
@@ -544,20 +541,14 @@ int sceRtcGetWin32FileTime(u32 datePtr, u32 win32TimePtr)
|
||||
int sceRtcCompareTick(u32 tick1Ptr, u32 tick2Ptr)
|
||||
{
|
||||
ERROR_LOG(HLE, "HACK sceRtcCompareTick(%d,%d)", tick1Ptr, tick2Ptr);
|
||||
if (Memory::IsValidAddress(tick1Ptr)&&Memory::IsValidAddress(tick1Ptr))
|
||||
if (Memory::IsValidAddress(tick1Ptr) && Memory::IsValidAddress(tick2Ptr))
|
||||
{
|
||||
u64 tick1 = Memory::Read_U64(tick1Ptr);
|
||||
u64 tick2 = Memory::Read_U64(tick2Ptr);
|
||||
|
||||
if (tick1 > tick2)
|
||||
{
|
||||
if (tick1 > tick2)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (tick1 < tick2)
|
||||
{
|
||||
if (tick1 < tick2)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -572,7 +563,7 @@ int sceRtcTickAddTicks(u32 destTickPtr, u32 srcTickPtr, u64 numTicks)
|
||||
Memory::Write_U64(srcTick, destTickPtr);
|
||||
}
|
||||
|
||||
DEBUG_LOG(HLE, "sceRtcTickAddTicks(%d,%d,%d)", destTickPtr, srcTickPtr, numTicks);
|
||||
DEBUG_LOG(HLE, "sceRtcTickAddTicks(%x,%x,%llu)", destTickPtr, srcTickPtr, numTicks);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -586,7 +577,7 @@ int sceRtcTickAddMicroseconds(u32 destTickPtr,u32 srcTickPtr, u64 numMS)
|
||||
Memory::Write_U64(srcTick, destTickPtr);
|
||||
}
|
||||
|
||||
ERROR_LOG(HLE, "HACK sceRtcTickAddMicroseconds(%d,%d,%d)", destTickPtr, srcTickPtr, numMS);
|
||||
ERROR_LOG(HLE, "HACK sceRtcTickAddMicroseconds(%x,%x,%llu)", destTickPtr, srcTickPtr, numMS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -599,7 +590,7 @@ int sceRtcTickAddSeconds(u32 destTickPtr, u32 srcTickPtr, u64 numSecs)
|
||||
srcTick += numSecs * 1000000UL;
|
||||
Memory::Write_U64(srcTick, destTickPtr);
|
||||
}
|
||||
ERROR_LOG(HLE, "HACK sceRtcTickAddSeconds(%d,%d,%d)", destTickPtr, srcTickPtr, numSecs);
|
||||
ERROR_LOG(HLE, "HACK sceRtcTickAddSeconds(%x,%x,%llu)", destTickPtr, srcTickPtr, numSecs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -612,7 +603,7 @@ int sceRtcTickAddMinutes(u32 destTickPtr, u32 srcTickPtr, u64 numMins)
|
||||
srcTick += numMins*60000000UL;
|
||||
Memory::Write_U64(srcTick, destTickPtr);
|
||||
}
|
||||
ERROR_LOG(HLE, "HACK sceRtcTickAddMinutes(%d,%d,%d)", destTickPtr, srcTickPtr, numMins);
|
||||
ERROR_LOG(HLE, "HACK sceRtcTickAddMinutes(%x,%x,%llu)", destTickPtr, srcTickPtr, numMins);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -621,7 +612,6 @@ int sceRtcTickAddHours(u32 destTickPtr, u32 srcTickPtr, int numHours)
|
||||
if (Memory::IsValidAddress(destTickPtr) && Memory::IsValidAddress(srcTickPtr))
|
||||
{
|
||||
s64 srcTick = (s64)Memory::Read_U64(srcTickPtr);
|
||||
|
||||
srcTick += numHours*3600000000UL;
|
||||
Memory::Write_U64(srcTick, destTickPtr);
|
||||
}
|
||||
@@ -660,7 +650,7 @@ int sceRtcTickAddMonths(u32 destTickPtr, u32 srcTickPtr, int numMonths)
|
||||
if (Memory::IsValidAddress(destTickPtr) && Memory::IsValidAddress(srcTickPtr))
|
||||
{
|
||||
u64 srcTick = Memory::Read_U64(srcTickPtr);
|
||||
|
||||
|
||||
// slightly bodgy but we need to add months to a pt and then convert to ticks to cover different day count in months and leapyears
|
||||
ScePspDateTime pt;
|
||||
memset(&pt, 0, sizeof(pt));
|
||||
@@ -669,7 +659,7 @@ int sceRtcTickAddMonths(u32 destTickPtr, u32 srcTickPtr, int numMonths)
|
||||
numMonths = -numMonths;;
|
||||
int years = numMonths /12;
|
||||
int realmonths = numMonths % 12;
|
||||
|
||||
|
||||
pt.year = years;
|
||||
pt.month = realmonths;
|
||||
u64 monthTicks =__RtcPspTimeToTicks(pt);
|
||||
@@ -688,7 +678,6 @@ int sceRtcTickAddMonths(u32 destTickPtr, u32 srcTickPtr, int numMonths)
|
||||
{
|
||||
int years = numMonths /12;
|
||||
int realmonths = numMonths % 12;
|
||||
|
||||
pt.year = years;
|
||||
pt.month = realmonths;
|
||||
srcTick +=__RtcPspTimeToTicks(pt);
|
||||
@@ -700,7 +689,7 @@ int sceRtcTickAddMonths(u32 destTickPtr, u32 srcTickPtr, int numMonths)
|
||||
return 0;
|
||||
}
|
||||
|
||||
//TODO: off by 6 days every 2000 years.
|
||||
// TODO: off by 6 days every 2000 years.
|
||||
int sceRtcTickAddYears(u32 destTickPtr, u32 srcTickPtr, int numYears)
|
||||
{
|
||||
if (Memory::IsValidAddress(destTickPtr) && Memory::IsValidAddress(srcTickPtr))
|
||||
@@ -743,10 +732,10 @@ int sceRtcParseDateTime(u32 destTickPtr, u32 dateStringPtr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
const HLEFunction sceRtc[] =
|
||||
const HLEFunction sceRtc[] =
|
||||
{
|
||||
{0xC41C2853, WrapU_V<sceRtcGetTickResolution>, "sceRtcGetTickResolution"},
|
||||
{0x3f7ad767, WrapU_U<sceRtcGetCurrentTick>, "sceRtcGetCurrentTick"},
|
||||
{0x3f7ad767, WrapU_U<sceRtcGetCurrentTick>, "sceRtcGetCurrentTick"},
|
||||
{0x011F03C1, WrapU64_V<sceRtcGetAcculumativeTime>, "sceRtcGetAccumulativeTime"},
|
||||
{0x029CA3B3, WrapU64_V<sceRtcGetAcculumativeTime>, "sceRtcGetAccumlativeTime"},
|
||||
{0x4cfa57b0, WrapU_UI<sceRtcGetCurrentClock>, "sceRtcGetCurrentClock"},
|
||||
@@ -767,7 +756,7 @@ const HLEFunction sceRtc[] =
|
||||
{0x6FF40ACC, WrapU_UU<sceRtcGetTick>, "sceRtcGetTick"},
|
||||
{0x9ED0AE87, WrapI_UU<sceRtcCompareTick>, "sceRtcCompareTick"},
|
||||
{0x44F45E05, WrapI_UUU64<sceRtcTickAddTicks>, "sceRtcTickAddTicks"},
|
||||
{0x26D25A5D, WrapI_UUU64<sceRtcTickAddMicroseconds>, "sceRtcTickAddMicroseconds"},
|
||||
{0x26D25A5D, WrapI_UUU64<sceRtcTickAddMicroseconds>, "sceRtcTickAddMicroseconds"},
|
||||
{0xF2A4AFE5, WrapI_UUU64<sceRtcTickAddSeconds>, "sceRtcTickAddSeconds"},
|
||||
{0xE6605BCA, WrapI_UUU64<sceRtcTickAddMinutes>, "sceRtcTickAddMinutes"},
|
||||
{0x26D7A24A, WrapI_UUI<sceRtcTickAddHours>, "sceRtcTickAddHours"},
|
||||
@@ -785,8 +774,6 @@ const HLEFunction sceRtc[] =
|
||||
{0x1909c99b, WrapI_UU64<sceRtcSetTime64_t>, "sceRtcSetTime64_t"},
|
||||
};
|
||||
|
||||
|
||||
|
||||
void Register_sceRtc()
|
||||
{
|
||||
RegisterModule("sceRtc", ARRAY_SIZE(sceRtc), sceRtc);
|
||||
|
||||
+14
-2
@@ -50,6 +50,13 @@ void __SasInit() {
|
||||
sas = new SasInstance();
|
||||
}
|
||||
|
||||
void __SasDoState(PointerWrap &p) {
|
||||
if (sas != NULL) {
|
||||
sas->DoState(p);
|
||||
}
|
||||
p.DoMarker("sceSas");
|
||||
}
|
||||
|
||||
void __SasShutdown() {
|
||||
delete sas;
|
||||
sas = 0;
|
||||
@@ -114,6 +121,11 @@ u32 sceSasSetVoice(u32 core, int voiceNum, u32 vagAddr, int size, int loop)
|
||||
return ERROR_SAS_INVALID_VOICE;
|
||||
}
|
||||
|
||||
if (!Memory::IsValidAddress(vagAddr)) {
|
||||
ERROR_LOG(HLE, "Ignoring invalid VAG audio address %08x", vagAddr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Real VAG header is 0x30 bytes behind the vagAddr
|
||||
SasVoice &v = sas->voices[voiceNum];
|
||||
v.type = VOICETYPE_VAG;
|
||||
@@ -126,7 +138,7 @@ u32 sceSasSetVoice(u32 core, int voiceNum, u32 vagAddr, int size, int loop)
|
||||
|
||||
u32 sceSasSetVoicePCM(u32 core, int voiceNum, u32 pcmAddr, int size, int loop)
|
||||
{
|
||||
DEBUG_LOG(HLE,"0=sceSasSetVoicePCM(core=%08x, voicenum=%i, pcmAddr=%08x, size=%i, loop=%i)",core, voiceNum, pcmAddr, size, loop);
|
||||
DEBUG_LOG(HLE,"0=sceSasSetVoicePCM(core=%08x, voicenum=%i, pcmAddr=%08x, size=%i, loop=%i)", core, voiceNum, pcmAddr, size, loop);
|
||||
SasVoice &v = sas->voices[voiceNum];
|
||||
v.type = VOICETYPE_PCM;
|
||||
v.pcmAddr = pcmAddr;
|
||||
@@ -310,7 +322,7 @@ u32 sceSasGetEnvelopeHeight(u32 core, u32 voiceNum)
|
||||
{
|
||||
DEBUG_LOG(HLE,"UNIMPL 0=sceSasGetEnvelopeHeight(core=%08x, voicenum=%i)", core, voiceNum);
|
||||
}
|
||||
if (voiceNum >= PSP_SAS_VOICES_MAX || voiceNum < 0)
|
||||
if (voiceNum >= PSP_SAS_VOICES_MAX)
|
||||
{
|
||||
WARN_LOG(HLE, "%s: invalid voicenum %d", __FUNCTION__, voiceNum);
|
||||
return ERROR_SAS_INVALID_VOICE;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#pragma once
|
||||
|
||||
void __SasInit();
|
||||
void __SasDoState(PointerWrap &p);
|
||||
void __SasShutdown();
|
||||
|
||||
void Register_sceSasCore();
|
||||
@@ -35,6 +35,14 @@ void __SslInit()
|
||||
currentMemSize = 0;
|
||||
}
|
||||
|
||||
void __SslDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(isSslInit);
|
||||
p.Do(maxMemSize);
|
||||
p.Do(currentMemSize);
|
||||
p.DoMarker("sceSsl");
|
||||
}
|
||||
|
||||
int sceSslInit(int heapSize)
|
||||
{
|
||||
DEBUG_LOG(HLE, "sceSslInit %d", heapSize);
|
||||
|
||||
+4
-1
@@ -17,6 +17,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../Common/ChunkFile.h"
|
||||
|
||||
void Register_sceSsl();
|
||||
|
||||
void __SslInit();
|
||||
void __SslInit();
|
||||
void __SslDoState(PointerWrap &p);
|
||||
+21
-10
@@ -31,11 +31,11 @@ const int PSP_ERROR_UMD_INVALID_PARAM = 0x80010016;
|
||||
#define UMD_READABLE 0x20
|
||||
|
||||
|
||||
u8 umdActivated = 1;
|
||||
u32 umdStatus = 0;
|
||||
u32 umdErrorStat = 0;
|
||||
static int driveCBId= -1;
|
||||
int umdStatTimer = 0;
|
||||
static u8 umdActivated = 1;
|
||||
static u32 umdStatus = 0;
|
||||
static u32 umdErrorStat = 0;
|
||||
static int driveCBId = -1;
|
||||
static int umdStatTimer = 0;
|
||||
|
||||
|
||||
#define PSP_UMD_TYPE_GAME 0x10
|
||||
@@ -47,14 +47,28 @@ struct PspUmdInfo {
|
||||
u32 type;
|
||||
};
|
||||
|
||||
void __UmdStatTimeout(u64 userdata, int cyclesLate);
|
||||
|
||||
void __UmdInit() {
|
||||
void __UmdInit()
|
||||
{
|
||||
umdStatTimer = CoreTiming::RegisterEvent("UmdTimeout", __UmdStatTimeout);
|
||||
umdActivated = 1;
|
||||
umdStatus = 0;
|
||||
umdErrorStat = 0;
|
||||
driveCBId = -1;
|
||||
}
|
||||
|
||||
void __UmdDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(umdActivated);
|
||||
p.Do(umdStatus);
|
||||
p.Do(umdErrorStat);
|
||||
p.Do(driveCBId);
|
||||
p.Do(umdStatTimer);
|
||||
CoreTiming::RestoreRegisterEvent(umdStatTimer, "UmdTimeout", __UmdStatTimeout);
|
||||
p.DoMarker("sceUmd");
|
||||
}
|
||||
|
||||
u8 __KernelUmdGetState()
|
||||
{
|
||||
u8 state = UMD_PRESENT;
|
||||
@@ -134,7 +148,7 @@ int sceUmdActivate(u32 unknown, const char *name)
|
||||
int sceUmdDeactivate(u32 unknown, const char *name)
|
||||
{
|
||||
// Why 18? No idea.
|
||||
if (unknown < 0 || unknown > 18)
|
||||
if (unknown > 18)
|
||||
return PSP_ERROR_UMD_INVALID_PARAM;
|
||||
|
||||
bool changed = umdActivated != 0;
|
||||
@@ -214,9 +228,6 @@ void __UmdStatTimeout(u64 userdata, int cyclesLate)
|
||||
|
||||
void __UmdWaitStat(u32 timeout)
|
||||
{
|
||||
if (umdStatTimer == 0)
|
||||
umdStatTimer = CoreTiming::RegisterEvent("UmdTimeout", &__UmdStatTimeout);
|
||||
|
||||
// This happens to be how the hardware seems to time things.
|
||||
if (timeout <= 4)
|
||||
timeout = 15;
|
||||
|
||||
Loaded 100 of 212 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user