mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-30 01:33:45 +01:00
commit
d6a08ba939
17 files changed
+619
-85
No files matched your search
@@ -70,6 +70,16 @@ static inline int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **res
|
||||
}
|
||||
#endif
|
||||
|
||||
// No thread safe
|
||||
#ifdef _WIN32
|
||||
inline struct tm* localtime_r (const time_t *clock, struct tm *result) {
|
||||
if (!clock || !result) return NULL;
|
||||
memcpy(result,localtime(clock),sizeof(*result));
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// This namespace has various generic functions related to files and paths.
|
||||
// The code still needs a ton of cleanup.
|
||||
// REMEMBER: strdup considered harmful!
|
||||
@@ -346,6 +356,34 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
|
||||
#endif
|
||||
}
|
||||
|
||||
tm GetModifTime(const std::string &filename)
|
||||
{
|
||||
tm return_time;
|
||||
if (!Exists(filename))
|
||||
{
|
||||
WARN_LOG(COMMON, "GetCreateTime: failed %s: No such file", filename.c_str());
|
||||
return return_time;
|
||||
}
|
||||
|
||||
if (IsDirectory(filename))
|
||||
{
|
||||
WARN_LOG(COMMON, "GetCreateTime: failed %s: is a directory", filename.c_str());
|
||||
return return_time;
|
||||
}
|
||||
struct stat64 buf;
|
||||
if (stat64(filename.c_str(), &buf) == 0)
|
||||
{
|
||||
DEBUG_LOG(COMMON, "GetCreateTime: %s: %lld",
|
||||
filename.c_str(), (long long)buf.st_mtime);
|
||||
localtime_r((time_t*)&buf.st_mtime,&return_time);
|
||||
return return_time;
|
||||
}
|
||||
|
||||
ERROR_LOG(COMMON, "GetCreateTime: Stat failed %s: %s",
|
||||
filename.c_str(), GetLastErrorMsg());
|
||||
return return_time;
|
||||
}
|
||||
|
||||
// Returns the size of filename (64bit)
|
||||
u64 GetSize(const std::string &filename)
|
||||
{
|
||||
|
||||
@@ -56,6 +56,9 @@ bool Exists(const std::string &filename);
|
||||
// Returns true if filename is a directory
|
||||
bool IsDirectory(const std::string &filename);
|
||||
|
||||
// Returns struct with modification date of file
|
||||
tm GetModifTime(const std::string &filename);
|
||||
|
||||
// Returns the size of filename (64bit)
|
||||
u64 GetSize(const std::string &filename);
|
||||
|
||||
|
||||
+33
-2
@@ -22,10 +22,10 @@
|
||||
#include <numeric>
|
||||
|
||||
namespace {
|
||||
|
||||
#ifdef USE_SSE
|
||||
static u32 saved_sse_state = _mm_getcsr();
|
||||
static const u32 default_sse_state = _mm_getcsr();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace MathUtil
|
||||
@@ -116,19 +116,25 @@ namespace MathUtil
|
||||
|
||||
void LoadDefaultSSEState()
|
||||
{
|
||||
#ifdef USE_SSE
|
||||
_mm_setcsr(default_sse_state);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void LoadSSEState()
|
||||
{
|
||||
#ifdef USE_SSE
|
||||
_mm_setcsr(saved_sse_state);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void SaveSSEState()
|
||||
{
|
||||
#ifdef USE_SSE
|
||||
saved_sse_state = _mm_getcsr();
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void MatrixMul(int n, const float *a, const float *b, float *result)
|
||||
@@ -247,3 +253,28 @@ void Matrix44::Multiply(const Matrix44 &a, const Matrix44 &b, Matrix44 &result)
|
||||
MatrixMul(4, a.data, b.data, result.data);
|
||||
}
|
||||
|
||||
int Pow2roundup(int x)
|
||||
{
|
||||
if (x < 0)
|
||||
return 0;
|
||||
--x;
|
||||
x |= x >> 1;
|
||||
x |= x >> 2;
|
||||
x |= x >> 4;
|
||||
x |= x >> 8;
|
||||
x |= x >> 16;
|
||||
return x+1;
|
||||
}
|
||||
|
||||
int GetPow2(int x)
|
||||
{
|
||||
int ret = 0;
|
||||
int val = 1;
|
||||
while(x > val)
|
||||
{
|
||||
ret++;
|
||||
val *= 2;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
+9
-1
@@ -20,7 +20,14 @@
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
#ifndef ANDROID
|
||||
#define USE_SSE
|
||||
#endif
|
||||
|
||||
#ifdef USE_SSE
|
||||
#include <xmmintrin.h>
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace MathUtil
|
||||
@@ -146,6 +153,8 @@ struct Rectangle
|
||||
|
||||
inline float pow2f(float x) {return x * x;}
|
||||
inline double pow2(double x) {return x * x;}
|
||||
int Pow2roundup(int x);
|
||||
int GetPow2(int x);
|
||||
|
||||
|
||||
/*
|
||||
@@ -163,7 +172,6 @@ float MathFloatVectorSum(const std::vector<float>&);
|
||||
#define ROUND_UP(x, a) (((x) + (a) - 1) & ~((a) - 1))
|
||||
#define ROUND_DOWN(x, a) ((x) & ~((a) - 1))
|
||||
|
||||
|
||||
// Tiny matrix/vector library.
|
||||
// Used for things like Free-Look in the gfx backend.
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ void PSPSaveDialog::DisplaySaveList(bool canMove)
|
||||
int displayCount = 0;
|
||||
for(int i = 0; i < param.GetFilenameCount(); i++)
|
||||
{
|
||||
int textureColor = 0xFF000000; // Hack for differencing save existing and not while real texture not displayed
|
||||
int textureColor = 0xFFFFFFFF;
|
||||
|
||||
if(param.GetFileInfo(i).size == 0)
|
||||
{
|
||||
@@ -154,8 +154,20 @@ void PSPSaveDialog::DisplaySaveList(bool canMove)
|
||||
y += 90 + 50 * (displayCount - currentSelectedSave - 1);
|
||||
}
|
||||
|
||||
PPGeDraw4Patch(I_BUTTON, x, y, w, h, textureColor); // TODO : Display save texture image, or default if no save
|
||||
|
||||
int tw = 256;
|
||||
int th = 256;
|
||||
if(param.GetFileInfo(i).textureData != 0)
|
||||
{
|
||||
tw = param.GetFileInfo(i).textureWidth;
|
||||
th = param.GetFileInfo(i).textureHeight;
|
||||
PPGeSetTexture(param.GetFileInfo(i).textureData, param.GetFileInfo(i).textureWidth, param.GetFileInfo(i).textureHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
PPGeDisableTexture();
|
||||
}
|
||||
PPGeDrawImage(x, y, w, h, 0, 0 ,1 ,1 ,tw, th, textureColor);
|
||||
PPGeSetDefaultTexture();
|
||||
displayCount++;
|
||||
}
|
||||
|
||||
@@ -174,7 +186,7 @@ void PSPSaveDialog::DisplaySaveList(bool canMove)
|
||||
|
||||
void PSPSaveDialog::DisplaySaveIcon()
|
||||
{
|
||||
int textureColor = 0xFF000000; // Hack for differencing save existing and not while real texture not displayed
|
||||
int textureColor = 0xFFFFFFFF;
|
||||
|
||||
if(param.GetFileInfo(currentSelectedSave).size == 0)
|
||||
{
|
||||
@@ -187,8 +199,23 @@ void PSPSaveDialog::DisplaySaveIcon()
|
||||
int x = 20;
|
||||
int y = 80;
|
||||
|
||||
PPGeDraw4Patch(I_BUTTON, x, y, w, h, textureColor); // TODO : Display save texture image, or default if no save
|
||||
|
||||
int tw = 256;
|
||||
int th = 256;
|
||||
if(param.GetFileInfo(currentSelectedSave).textureData != 0)
|
||||
{
|
||||
tw = param.GetFileInfo(currentSelectedSave).textureWidth;
|
||||
th = param.GetFileInfo(currentSelectedSave).textureHeight;
|
||||
PPGeSetTexture(param.GetFileInfo(currentSelectedSave).textureData, param.GetFileInfo(currentSelectedSave).textureWidth, param.GetFileInfo(currentSelectedSave).textureHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
PPGeDisableTexture();
|
||||
}
|
||||
PPGeDrawImage(x, y, w, h, 0, 0 ,1 ,1 ,tw, th, textureColor);
|
||||
if(param.GetFileInfo(currentSelectedSave).textureData != 0)
|
||||
{
|
||||
PPGeSetDefaultTexture();
|
||||
}
|
||||
}
|
||||
|
||||
void PSPSaveDialog::DisplaySaveDataInfo1()
|
||||
@@ -200,7 +227,17 @@ void PSPSaveDialog::DisplaySaveDataInfo1()
|
||||
else
|
||||
{
|
||||
char txt[1024];
|
||||
sprintf(txt,"%s\nSize : %d",param.GetFilename(currentSelectedSave).c_str(),param.GetFileInfo(currentSelectedSave).size);
|
||||
sprintf(txt,"%s\n%02d/%02d/%d %02d:%02d %d KB\n%s\n%s"
|
||||
, param.GetFileInfo(currentSelectedSave).title
|
||||
, param.GetFileInfo(currentSelectedSave).modif_time.tm_mday
|
||||
, param.GetFileInfo(currentSelectedSave).modif_time.tm_mon + 1
|
||||
, param.GetFileInfo(currentSelectedSave).modif_time.tm_year + 1900
|
||||
, param.GetFileInfo(currentSelectedSave).modif_time.tm_hour
|
||||
, param.GetFileInfo(currentSelectedSave).modif_time.tm_min
|
||||
, param.GetFileInfo(currentSelectedSave).size / 1024
|
||||
, param.GetFileInfo(currentSelectedSave).saveTitle
|
||||
, param.GetFileInfo(currentSelectedSave).saveDetail
|
||||
);
|
||||
std::string saveinfoTxt = txt;
|
||||
PPGeDrawText(saveinfoTxt.c_str(), 200, 100, PPGE_ALIGN_LEFT, 0.5f, 0xFFFFFFFF);
|
||||
}
|
||||
@@ -214,7 +251,15 @@ void PSPSaveDialog::DisplaySaveDataInfo2()
|
||||
else
|
||||
{
|
||||
char txt[1024];
|
||||
sprintf(txt,"%s\nSize : %d",param.GetFilename(currentSelectedSave).c_str(),param.GetFileInfo(currentSelectedSave).size);
|
||||
sprintf(txt,"%s\n%02d/%02d/%d %02d:%02d\n%d KB"
|
||||
, param.GetFileInfo(currentSelectedSave).saveTitle
|
||||
, param.GetFileInfo(currentSelectedSave).modif_time.tm_mday
|
||||
, param.GetFileInfo(currentSelectedSave).modif_time.tm_mon + 1
|
||||
, param.GetFileInfo(currentSelectedSave).modif_time.tm_year + 1900
|
||||
, param.GetFileInfo(currentSelectedSave).modif_time.tm_hour
|
||||
, param.GetFileInfo(currentSelectedSave).modif_time.tm_min
|
||||
, param.GetFileInfo(currentSelectedSave).size / 1024
|
||||
);
|
||||
std::string saveinfoTxt = txt;
|
||||
PPGeDrawText(saveinfoTxt.c_str(), 10, 180, PPGE_ALIGN_LEFT, 0.5f, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
+218
-16
@@ -17,10 +17,14 @@
|
||||
|
||||
#include "SavedataParam.h"
|
||||
#include "../System.h"
|
||||
#include "image/png_load.h"
|
||||
#include "../HLE/sceKernelMemory.h"
|
||||
#include "../ELF/ParamSFO.h"
|
||||
|
||||
std::string icon0Name = "ICON0.PNG";
|
||||
std::string icon1Name = "ICON1.PNG";
|
||||
std::string icon1Name = "ICON1.PMF";
|
||||
std::string pic1Name = "PIC1.PNG";
|
||||
std::string snd0Name = "SND0.AT3";
|
||||
std::string sfoName = "PARAM.SFO";
|
||||
|
||||
std::string savePath = "ms0:/PSP/SAVEDATA/";
|
||||
@@ -43,8 +47,7 @@ void SavedataParam::Init()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string SavedataParam::GetSaveFilePath(SceUtilitySavedataParam* param, int saveId)
|
||||
std::string SavedataParam::GetSaveDir(SceUtilitySavedataParam* param, int saveId)
|
||||
{
|
||||
if (!param) {
|
||||
return "";
|
||||
@@ -54,7 +57,16 @@ std::string SavedataParam::GetSaveFilePath(SceUtilitySavedataParam* param, int s
|
||||
if(saveId >= 0 && saveNameListDataCount > 0) // if user selection, use it
|
||||
dirPath = std::string(GetGameName(param))+GetFilename(saveId);
|
||||
|
||||
return savePath + dirPath;
|
||||
return dirPath;
|
||||
}
|
||||
|
||||
std::string SavedataParam::GetSaveFilePath(SceUtilitySavedataParam* param, int saveId)
|
||||
{
|
||||
if (!param) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return savePath + GetSaveDir(param,saveId);
|
||||
}
|
||||
|
||||
std::string SavedataParam::GetGameName(SceUtilitySavedataParam* param)
|
||||
@@ -132,9 +144,27 @@ bool SavedataParam::Save(SceUtilitySavedataParam* param, int saveId)
|
||||
{
|
||||
pspFileSystem.CloseFile(handle);
|
||||
|
||||
// TODO SAVE PARAM.SFO
|
||||
/*data_ = (u8*)Memory::GetPointer(*((unsigned int*)¶m->dataBuf));
|
||||
writeDataToFile(false, );*/
|
||||
// SAVE PARAM.SFO
|
||||
ParamSFOData sfoFile;
|
||||
sfoFile.SetValue("TITLE",param->sfoParam.title,128);
|
||||
sfoFile.SetValue("SAVEDATA_TITLE",param->sfoParam.savedataTitle,128);
|
||||
sfoFile.SetValue("SAVEDATA_DETAIL",param->sfoParam.detail,1024);
|
||||
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;
|
||||
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);
|
||||
}
|
||||
delete[] sfoData;
|
||||
|
||||
// SAVE ICON0
|
||||
if(param->icon0FileData.buf)
|
||||
@@ -173,7 +203,18 @@ bool SavedataParam::Save(SceUtilitySavedataParam* param, int saveId)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Save SND
|
||||
// Save SND
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -259,10 +300,30 @@ bool SavedataParam::GetList(SceUtilitySavedataParam* param)
|
||||
return true;
|
||||
}
|
||||
|
||||
void SavedataParam::Clear()
|
||||
{
|
||||
if(saveDataList)
|
||||
{
|
||||
for(int i = 0; i < saveNameListDataCount; i++)
|
||||
{
|
||||
if(saveDataList[i].textureData != 0)
|
||||
kernelMemory.Free(saveDataList[i].textureData);
|
||||
saveDataList[i].textureData = 0;
|
||||
}
|
||||
|
||||
delete[] saveDataList;
|
||||
saveDataList = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void SavedataParam::SetPspParam(SceUtilitySavedataParam* param)
|
||||
{
|
||||
pspParam = param;
|
||||
if(!pspParam) return;
|
||||
if(!pspParam)
|
||||
{
|
||||
Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
bool listEmptyFile = true;
|
||||
if(param->mode == SCE_UTILITY_SAVEDATA_TYPE_LISTLOAD ||
|
||||
@@ -282,8 +343,7 @@ void SavedataParam::SetPspParam(SceUtilitySavedataParam* param)
|
||||
count++;
|
||||
} while(saveNameListData[count][0] != 0);
|
||||
|
||||
if(saveDataList)
|
||||
delete[] saveDataList;
|
||||
Clear();
|
||||
saveDataList = new SaveFileInfo[count];
|
||||
|
||||
// get and stock file info for each file
|
||||
@@ -296,10 +356,65 @@ void SavedataParam::SetPspParam(SceUtilitySavedataParam* param)
|
||||
PSPFileInfo info = pspFileSystem.GetFileInfo(fileDataPath);
|
||||
if(info.exists)
|
||||
{
|
||||
// TODO : Load PARAM.SFO when saved and save title and save info
|
||||
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;
|
||||
}
|
||||
|
||||
DEBUG_LOG(HLE,"%s Exist",fileDataPath.c_str());
|
||||
realCount++;
|
||||
}
|
||||
@@ -310,6 +425,7 @@ void SavedataParam::SetPspParam(SceUtilitySavedataParam* param)
|
||||
saveDataList[realCount].size = 0;
|
||||
saveDataList[realCount].saveName = saveNameListData[i];
|
||||
saveDataList[realCount].idx = i;
|
||||
saveDataList[realCount].textureData = 0;
|
||||
DEBUG_LOG(HLE,"Don't Exist");
|
||||
realCount++;
|
||||
}
|
||||
@@ -317,6 +433,95 @@ void SavedataParam::SetPspParam(SceUtilitySavedataParam* param)
|
||||
}
|
||||
saveNameListDataCount = realCount;
|
||||
}
|
||||
else // Load info on only save
|
||||
{
|
||||
saveNameListData == 0;
|
||||
|
||||
Clear();
|
||||
saveDataList = new SaveFileInfo[1];
|
||||
|
||||
// get and stock file info for each file
|
||||
DEBUG_LOG(HLE,"Name : %s",GetSaveName(param).c_str());
|
||||
|
||||
std::string fileDataPath = savePath+GetGameName(param)+GetSaveName(param)+"/"+param->fileName;
|
||||
PSPFileInfo info = pspFileSystem.GetFileInfo(fileDataPath);
|
||||
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;
|
||||
}
|
||||
|
||||
DEBUG_LOG(HLE,"%s Exist",fileDataPath.c_str());
|
||||
saveNameListDataCount = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(listEmptyFile)
|
||||
{
|
||||
saveDataList[0].size = 0;
|
||||
saveDataList[0].saveName = GetSaveName(param);
|
||||
saveDataList[0].idx = 0;
|
||||
saveDataList[0].textureData = 0;
|
||||
DEBUG_LOG(HLE,"Don't Exist");
|
||||
}
|
||||
saveNameListDataCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SceUtilitySavedataParam* SavedataParam::GetPspParam()
|
||||
@@ -335,10 +540,7 @@ const SaveFileInfo& SavedataParam::GetFileInfo(int idx)
|
||||
}
|
||||
std::string SavedataParam::GetFilename(int idx)
|
||||
{
|
||||
char fileName[21];
|
||||
memcpy(fileName,saveDataList[idx].saveName,20);
|
||||
fileName[20] = 0;
|
||||
return fileName;
|
||||
return saveDataList[idx].saveName;
|
||||
}
|
||||
|
||||
int SavedataParam::GetSelectedSave()
|
||||
|
||||
@@ -121,8 +121,18 @@ struct SceUtilitySavedataParam
|
||||
struct SaveFileInfo
|
||||
{
|
||||
int size;
|
||||
char* saveName;
|
||||
std::string saveName;
|
||||
int idx;
|
||||
|
||||
char title[128];
|
||||
char saveTitle[128];
|
||||
char saveDetail[1024];
|
||||
|
||||
tm modif_time;
|
||||
|
||||
u32 textureData;
|
||||
int textureWidth;
|
||||
int textureHeight;
|
||||
};
|
||||
|
||||
class SavedataParam
|
||||
@@ -130,6 +140,7 @@ class SavedataParam
|
||||
public:
|
||||
static void Init();
|
||||
std::string GetSaveFilePath(SceUtilitySavedataParam* param, int saveId = -1);
|
||||
std::string GetSaveDir(SceUtilitySavedataParam* param, int saveId = -1);
|
||||
bool Delete(SceUtilitySavedataParam* param, int saveId = -1);
|
||||
bool Save(SceUtilitySavedataParam* param, int saveId = -1);
|
||||
bool Load(SceUtilitySavedataParam* param, int saveId = -1);
|
||||
@@ -153,6 +164,8 @@ public:
|
||||
void SetSelectedSave(int idx);
|
||||
|
||||
private:
|
||||
void Clear();
|
||||
|
||||
SceUtilitySavedataParam* pspParam;
|
||||
int selectedSave;
|
||||
char (*saveNameListData)[20];
|
||||
|
||||
+129
-13
@@ -38,22 +38,48 @@ struct IndexTable
|
||||
u32 data_table_offset; /* Offset of the param_data from start of data_table */
|
||||
};
|
||||
|
||||
void ParseDataString(const char *key, const char *utfdata, ParamSFOData *sfodata, int maxlen = 0)
|
||||
void ParamSFOData::SetValue(std::string key, unsigned int value, int max_size)
|
||||
{
|
||||
std::string data;
|
||||
if (maxlen)
|
||||
data = std::string(utfdata, maxlen);
|
||||
else
|
||||
data = std::string(utfdata);
|
||||
if (!strcmp(key, "DISC_ID")) {
|
||||
sfodata->discID = data;
|
||||
} else if (!strcmp(key, "TITLE")) {
|
||||
sfodata->title = data;
|
||||
values[key].type = VT_INT;
|
||||
values[key].i_value = value;
|
||||
values[key].max_size = 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].s_value = value;
|
||||
values[key].max_size = max_size;
|
||||
}
|
||||
|
||||
int ParamSFOData::GetValueInt(std::string key)
|
||||
{
|
||||
std::map<std::string,ValueData>::iterator it = values.find(key);
|
||||
if(it == values.end() || it->second.type != VT_INT)
|
||||
return 0;
|
||||
return it->second.i_value;
|
||||
}
|
||||
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))
|
||||
return "";
|
||||
return it->second.s_value;
|
||||
}
|
||||
|
||||
// I'm so sorry Ced but this is highly endian unsafe :(
|
||||
bool ParseParamSFO(const u8 *paramsfo, size_t size, ParamSFOData *data)
|
||||
bool ParamSFOData::ReadSFO(const u8 *paramsfo, size_t size)
|
||||
{
|
||||
const Header *header = (const Header *)paramsfo;
|
||||
if (header->magic != 0x46535000)
|
||||
@@ -75,6 +101,7 @@ bool ParseParamSFO(const u8 *paramsfo, size_t size, ParamSFOData *data)
|
||||
{
|
||||
// Unsigned int
|
||||
const u32 *data = (const u32 *)(data_start + indexTables[i].data_table_offset);
|
||||
SetValue(key,*data,indexTables[i].param_max_len);
|
||||
DEBUG_LOG(LOADER, "%s %08x", key, *data);
|
||||
}
|
||||
break;
|
||||
@@ -83,7 +110,7 @@ bool ParseParamSFO(const u8 *paramsfo, size_t size, ParamSFOData *data)
|
||||
{
|
||||
const char *utfdata = (const char *)(data_start + indexTables[i].data_table_offset);
|
||||
DEBUG_LOG(LOADER, "%s %s", key, utfdata);
|
||||
ParseDataString(key, utfdata, data, indexTables[i].param_len);
|
||||
SetValue(key,std::string(utfdata,indexTables[i].param_len),indexTables[i].param_max_len);
|
||||
}
|
||||
break;
|
||||
case 0x0204:
|
||||
@@ -91,7 +118,7 @@ bool ParseParamSFO(const u8 *paramsfo, size_t size, ParamSFOData *data)
|
||||
{
|
||||
const char *utfdata = (const char *)(data_start + indexTables[i].data_table_offset);
|
||||
DEBUG_LOG(LOADER, "%s %s", key, utfdata);
|
||||
ParseDataString(key, utfdata, data, indexTables[i].param_len);
|
||||
SetValue(key,std::string(utfdata,indexTables[i].param_len),indexTables[i].param_max_len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -99,3 +126,92 @@ bool ParseParamSFO(const u8 *paramsfo, size_t size, ParamSFOData *data)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParamSFOData::WriteSFO(u8 **paramsfo, size_t *size)
|
||||
{
|
||||
size_t total_size = 0;
|
||||
size_t key_size = 0;
|
||||
size_t data_size = 0;
|
||||
|
||||
Header header;
|
||||
header.magic = 0x46535000;
|
||||
header.version = 0x00000101;
|
||||
header.index_table_entries = 0;
|
||||
|
||||
total_size += sizeof(Header);
|
||||
|
||||
// Get size info
|
||||
for(std::map<std::string,ValueData>::iterator it = values.begin(); it != values.end(); it++)
|
||||
{
|
||||
key_size += it->first.size()+1;
|
||||
data_size += it->second.max_size;
|
||||
|
||||
header.index_table_entries++;
|
||||
}
|
||||
|
||||
// Padding
|
||||
while((key_size%4)) key_size++;
|
||||
|
||||
header.key_table_start = sizeof(Header) + header.index_table_entries * sizeof(IndexTable);
|
||||
header.data_table_start = header.key_table_start + key_size;
|
||||
|
||||
total_size += sizeof(IndexTable) * header.index_table_entries;
|
||||
total_size += key_size;
|
||||
total_size += data_size;
|
||||
*size = total_size;
|
||||
|
||||
u8* data = new u8[total_size];
|
||||
*paramsfo = data;
|
||||
memset(data,0,total_size);
|
||||
memcpy(data,&header,sizeof(Header));
|
||||
|
||||
// Now fill
|
||||
IndexTable *index_ptr = (IndexTable*)(data + sizeof(Header));
|
||||
u8* key_ptr = data + header.key_table_start;
|
||||
u8* data_ptr = data + header.data_table_start;
|
||||
|
||||
for(std::map<std::string,ValueData>::iterator it = values.begin(); it != values.end(); it++)
|
||||
{
|
||||
u16 offset = (u16)(key_ptr - (data+header.key_table_start));
|
||||
index_ptr->key_table_offset = offset;
|
||||
offset = (u16)(data_ptr - (data+header.data_table_start));
|
||||
index_ptr->data_table_offset = offset;
|
||||
index_ptr->param_max_len = it->second.max_size;
|
||||
if(it->second.type == VT_INT)
|
||||
{
|
||||
index_ptr->param_fmt = 0x0404;
|
||||
index_ptr->param_len = 4;
|
||||
|
||||
*(int*)data_ptr = it->second.i_value;
|
||||
}
|
||||
else if(it->second.type == VT_UTF8_SPE)
|
||||
{
|
||||
index_ptr->param_fmt = 0x0004;
|
||||
index_ptr->param_len = it->second.s_value.size()+1;
|
||||
|
||||
memcpy(data_ptr,it->second.s_value.c_str(),index_ptr->param_len);
|
||||
data_ptr[index_ptr->param_len] = 0;
|
||||
}
|
||||
else if(it->second.type == VT_UTF8)
|
||||
{
|
||||
index_ptr->param_fmt = 0x0204;
|
||||
index_ptr->param_len = it->second.s_value.size()+1;
|
||||
|
||||
memcpy(data_ptr,it->second.s_value.c_str(),index_ptr->param_len);
|
||||
data_ptr[index_ptr->param_len] = 0;
|
||||
}
|
||||
|
||||
memcpy(key_ptr,it->first.c_str(),it->first.size());
|
||||
key_ptr[it->first.size()] = 0;
|
||||
|
||||
data_ptr += index_ptr->param_max_len;
|
||||
key_ptr += it->first.size()+1;
|
||||
index_ptr++;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
+28
-4
@@ -18,11 +18,35 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
|
||||
struct ParamSFOData
|
||||
class ParamSFOData
|
||||
{
|
||||
std::string discID;
|
||||
std::string title; // utf-8
|
||||
public:
|
||||
void SetValue(std::string key, unsigned int value, int max_size);
|
||||
void SetValue(std::string key, std::string value, int max_size);
|
||||
|
||||
int GetValueInt(std::string key);
|
||||
std::string GetValueString(std::string key);
|
||||
|
||||
bool ReadSFO(const u8 *paramsfo, size_t size);
|
||||
bool WriteSFO(u8 **paramsfo, size_t *size);
|
||||
private:
|
||||
|
||||
enum ValueType
|
||||
{
|
||||
VT_INT,
|
||||
VT_UTF8,
|
||||
VT_UTF8_SPE
|
||||
};
|
||||
struct ValueData
|
||||
{
|
||||
ValueType type;
|
||||
int max_size;
|
||||
std::string s_value;
|
||||
int i_value;
|
||||
};
|
||||
|
||||
std::map<std::string,ValueData> values;
|
||||
};
|
||||
|
||||
bool ParseParamSFO(const u8 *paramsfo, size_t size, ParamSFOData *data);
|
||||
@@ -277,6 +277,7 @@ PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename)
|
||||
x.size = File::GetSize(fullName);
|
||||
//TODO
|
||||
#endif
|
||||
x.mtime = File::GetModifTime(fullName);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -62,6 +62,8 @@ struct PSPFileInfo
|
||||
bool exists;
|
||||
FileType type;
|
||||
|
||||
tm mtime;
|
||||
|
||||
bool isOnSectorSystem;
|
||||
u32 startSector;
|
||||
u32 numSectors;
|
||||
|
||||
+2
-2
@@ -78,10 +78,10 @@ bool Load_PSP_ISO(const char *filename, std::string *error_string)
|
||||
pspFileSystem.ReadFile(fd, paramsfo, fileInfo.size);
|
||||
pspFileSystem.CloseFile(fd);
|
||||
ParamSFOData data;
|
||||
if (ParseParamSFO(paramsfo, (size_t)fileInfo.size, &data))
|
||||
if (data.ReadSFO(paramsfo, (size_t)fileInfo.size))
|
||||
{
|
||||
char title[1024];
|
||||
sprintf(title, "%s : %s", data.discID.c_str(), data.title.c_str());
|
||||
sprintf(title, "%s : %s", data.GetValueString("DISC_ID").c_str(), data.GetValueString("TITLE").c_str());
|
||||
INFO_LOG(LOADER, "%s", title);
|
||||
host->SetWindowTitle(title);
|
||||
}
|
||||
|
||||
+81
-37
@@ -27,8 +27,11 @@
|
||||
#include "gfx/texture_atlas.h"
|
||||
#include "gfx/gl_common.h"
|
||||
#include "../System.h"
|
||||
#include "MathUtil.h"
|
||||
|
||||
static u32 atlasPtr;
|
||||
static int atlasWidth;
|
||||
static int atlasHeight;
|
||||
|
||||
struct PPGeVertex {
|
||||
u16 u, v;
|
||||
@@ -78,11 +81,11 @@ static void BeginVertexData() {
|
||||
vertexStart = dataWritePtr;
|
||||
}
|
||||
|
||||
static void Vertex(float x, float y, float u, float v, u32 color = 0xFFFFFFFF)
|
||||
static void Vertex(float x, float y, float u, float v, int tw, int th, u32 color = 0xFFFFFFFF)
|
||||
{
|
||||
PPGeVertex vtx;
|
||||
vtx.x = x - 0.5f; vtx.y = y - 0.5f; vtx.z = 0;
|
||||
vtx.u = u * 256 - 0.5f; vtx.v = v * 256 - 0.5f;
|
||||
vtx.u = u * tw - 0.5f; vtx.v = v * th - 0.5f;
|
||||
vtx.color = color;
|
||||
Memory::WriteStruct(dataWritePtr, &vtx);
|
||||
vertexCount++;
|
||||
@@ -112,6 +115,8 @@ void __PPGeInit()
|
||||
}
|
||||
|
||||
u32 atlasSize = height * width * 2; // it's a 4444 texture
|
||||
atlasWidth = width;
|
||||
atlasHeight = height;
|
||||
dlPtr = kernelMemory.Alloc(dlSize, false, "PPGe Display List");
|
||||
dataPtr = kernelMemory.Alloc(dataSize, false, "PPGe Vertex Data");
|
||||
atlasPtr = kernelMemory.Alloc(atlasSize, false, "PPGe Atlas Texture");
|
||||
@@ -173,17 +178,7 @@ void PPGeBegin()
|
||||
WriteCmd(GE_CMD_CULLFACEENABLE, 0);
|
||||
WriteCmd(GE_CMD_CLEARMODE, 0); // Normal mode
|
||||
|
||||
WriteCmd(GE_CMD_TEXTUREMAPENABLE, 1);
|
||||
WriteCmd(GE_CMD_TEXSIZE0, 8 | (8 << 8)); // 1 << (7+1) = 256
|
||||
WriteCmd(GE_CMD_TEXMAPMODE, 0 | (1 << 8));
|
||||
WriteCmd(GE_CMD_TEXMODE, 0);
|
||||
WriteCmd(GE_CMD_TEXFORMAT, 2); // 4444
|
||||
WriteCmd(GE_CMD_TEXFILTER, (1 << 8) | 1); // mag = LINEAR min = LINEAR
|
||||
WriteCmd(GE_CMD_TEXWRAP, (1 << 8) | 1); // clamp texture wrapping
|
||||
WriteCmd(GE_CMD_TEXFUNC, (0 << 16) | (1 << 8) | 0); // RGBA texture reads, modulate, no color doubling
|
||||
WriteCmd(GE_CMD_TEXADDR0, atlasPtr & 0xFFFFF0);
|
||||
WriteCmd(GE_CMD_TEXBUFWIDTH0, 256 | ((atlasPtr & 0xFF000000) >> 8));
|
||||
WriteCmd(GE_CMD_TEXFLUSH, 0);
|
||||
PPGeSetDefaultTexture();
|
||||
|
||||
WriteCmd(GE_CMD_SCISSOR1, (0 << 10) | 0);
|
||||
WriteCmd(GE_CMD_SCISSOR2, (1023 << 10) | 1023);
|
||||
@@ -271,8 +266,8 @@ void PPGeDrawText(const char *text, float x, float y, int align, float scale, u3
|
||||
float cy1 = y + c.oy * scale;
|
||||
float cx2 = x + (c.ox + c.pw) * scale;
|
||||
float cy2 = y + (c.oy + c.ph) * scale;
|
||||
Vertex(cx1, cy1, c.sx, c.sy, color);
|
||||
Vertex(cx2, cy2, c.ex, c.ey, color);
|
||||
Vertex(cx1, cy1, c.sx, c.sy, 256, 256, color);
|
||||
Vertex(cx2, cy2, c.ex, c.ey, 256, 256, color);
|
||||
x += c.wx * scale;
|
||||
}
|
||||
EndVertexDataAndDraw(GE_PRIM_RECTANGLES);
|
||||
@@ -296,26 +291,26 @@ void PPGeDraw4Patch(int atlasImage, float x, float y, float w, float h, u32 colo
|
||||
float y2 = y + h;
|
||||
BeginVertexData();
|
||||
// Top row
|
||||
Vertex(x, y, u1, v1, color);
|
||||
Vertex(xmid1, ymid1, uhalf, vhalf, color);
|
||||
Vertex(xmid1, y, uhalf, v1, color);
|
||||
Vertex(xmid2, ymid1, uhalf, vhalf, color);
|
||||
Vertex(xmid2, y, uhalf, v1, color);
|
||||
Vertex(x2, ymid1, u2, vhalf, color);
|
||||
Vertex(x, y, u1, v1, atlasWidth, atlasHeight, color);
|
||||
Vertex(xmid1, ymid1, uhalf, vhalf, atlasWidth, atlasHeight, color);
|
||||
Vertex(xmid1, y, uhalf, v1, atlasWidth, atlasHeight, color);
|
||||
Vertex(xmid2, ymid1, uhalf, vhalf, atlasWidth, atlasHeight, color);
|
||||
Vertex(xmid2, y, uhalf, v1, atlasWidth, atlasHeight, color);
|
||||
Vertex(x2, ymid1, u2, vhalf, atlasWidth, atlasHeight, color);
|
||||
// Middle row
|
||||
Vertex(x, ymid1, u1, vhalf, color);
|
||||
Vertex(xmid1, ymid2, uhalf, vhalf, color);
|
||||
Vertex(xmid1, ymid1, uhalf, vhalf, color);
|
||||
Vertex(xmid2, ymid2, uhalf, vhalf, color);
|
||||
Vertex(xmid2, ymid1, uhalf, vhalf, color);
|
||||
Vertex(x2, ymid2, u2, v2, color);
|
||||
Vertex(x, ymid1, u1, vhalf, atlasWidth, atlasHeight, color);
|
||||
Vertex(xmid1, ymid2, uhalf, vhalf, atlasWidth, atlasHeight, color);
|
||||
Vertex(xmid1, ymid1, uhalf, vhalf, atlasWidth, atlasHeight, color);
|
||||
Vertex(xmid2, ymid2, uhalf, vhalf, atlasWidth, atlasHeight, color);
|
||||
Vertex(xmid2, ymid1, uhalf, vhalf, atlasWidth, atlasHeight, color);
|
||||
Vertex(x2, ymid2, u2, v2, atlasWidth, atlasHeight, color);
|
||||
// Bottom row
|
||||
Vertex(x, ymid2, u1, vhalf, color);
|
||||
Vertex(xmid1, y2, uhalf, v2, color);
|
||||
Vertex(xmid1, ymid2, uhalf, vhalf, color);
|
||||
Vertex(xmid2, y2, uhalf, v2, color);
|
||||
Vertex(xmid2, ymid2, uhalf, vhalf, color);
|
||||
Vertex(x2, y2, u2, v2, color);
|
||||
Vertex(x, ymid2, u1, vhalf, atlasWidth, atlasHeight, color);
|
||||
Vertex(xmid1, y2, uhalf, v2, atlasWidth, atlasHeight, color);
|
||||
Vertex(xmid1, ymid2, uhalf, vhalf, atlasWidth, atlasHeight, color);
|
||||
Vertex(xmid2, y2, uhalf, v2, atlasWidth, atlasHeight, color);
|
||||
Vertex(xmid2, ymid2, uhalf, vhalf, atlasWidth, atlasHeight, color);
|
||||
Vertex(x2, y2, u2, v2, atlasWidth, atlasHeight, color);
|
||||
EndVertexDataAndDraw(GE_PRIM_RECTANGLES);
|
||||
}
|
||||
|
||||
@@ -329,8 +324,8 @@ void PPGeDrawImage(int atlasImage, float x, float y, int align, u32 color)
|
||||
float w = img.w;
|
||||
float h = img.h;
|
||||
BeginVertexData();
|
||||
Vertex(x, y, img.u1, img.v1, color);
|
||||
Vertex(x + w, y + h, img.u2, img.v2, color);
|
||||
Vertex(x, y, img.u1, img.v1, atlasWidth, atlasHeight, color);
|
||||
Vertex(x + w, y + h, img.u2, img.v2, atlasWidth, atlasHeight, color);
|
||||
EndVertexDataAndDraw(GE_PRIM_RECTANGLES);
|
||||
}
|
||||
|
||||
@@ -341,8 +336,57 @@ void PPGeDrawImage(int atlasImage, float x, float y, float w, float h, int align
|
||||
|
||||
const AtlasImage &img = ppge_atlas.images[atlasImage];
|
||||
BeginVertexData();
|
||||
Vertex(x, y, img.u1, img.v1, color);
|
||||
Vertex(x + w, y + h, img.u2, img.v2, color);
|
||||
Vertex(x, y, img.u1, img.v1, atlasWidth, atlasHeight, color);
|
||||
Vertex(x + w, y + h, img.u2, img.v2, atlasWidth, atlasHeight, color);
|
||||
EndVertexDataAndDraw(GE_PRIM_RECTANGLES);
|
||||
}
|
||||
|
||||
void PPGeDrawImage(float x, float y, float w, float h, float u1, float v1, float u2, float v2, int tw, int th, u32 color)
|
||||
{
|
||||
if (!dlPtr)
|
||||
return;
|
||||
BeginVertexData();
|
||||
Vertex(x, y, u1, v1, tw, th, color);
|
||||
Vertex(x + w, y + h, u2, v2, tw, th, color);
|
||||
EndVertexDataAndDraw(GE_PRIM_RECTANGLES);
|
||||
}
|
||||
|
||||
void PPGeSetDefaultTexture()
|
||||
{
|
||||
WriteCmd(GE_CMD_TEXTUREMAPENABLE, 1);
|
||||
int wp2 = GetPow2(atlasWidth);
|
||||
int hp2 = GetPow2(atlasHeight);
|
||||
WriteCmd(GE_CMD_TEXSIZE0, wp2 | (hp2 << 8)); // 1 << (7+1) = 256
|
||||
WriteCmd(GE_CMD_TEXMAPMODE, 0 | (1 << 8));
|
||||
WriteCmd(GE_CMD_TEXMODE, 0);
|
||||
WriteCmd(GE_CMD_TEXFORMAT, 2); // 4444
|
||||
WriteCmd(GE_CMD_TEXFILTER, (1 << 8) | 1); // mag = LINEAR min = LINEAR
|
||||
WriteCmd(GE_CMD_TEXWRAP, (1 << 8) | 1); // clamp texture wrapping
|
||||
WriteCmd(GE_CMD_TEXFUNC, (0 << 16) | (1 << 8) | 0); // RGBA texture reads, modulate, no color doubling
|
||||
WriteCmd(GE_CMD_TEXADDR0, atlasPtr & 0xFFFFF0);
|
||||
WriteCmd(GE_CMD_TEXBUFWIDTH0, atlasWidth | ((atlasPtr & 0xFF000000) >> 8));
|
||||
WriteCmd(GE_CMD_TEXFLUSH, 0);
|
||||
}
|
||||
|
||||
void PPGeSetTexture(u32 dataAddr, int width, int height)
|
||||
{
|
||||
WriteCmd(GE_CMD_TEXTUREMAPENABLE, 1);
|
||||
int wp2 = GetPow2(width);
|
||||
int hp2 = GetPow2(height);
|
||||
WriteCmd(GE_CMD_TEXSIZE0, wp2 | (hp2 << 8)); // 1 << (7+1) = 256
|
||||
WriteCmd(GE_CMD_TEXMAPMODE, 0 | (1 << 8));
|
||||
WriteCmd(GE_CMD_TEXMODE, 0);
|
||||
WriteCmd(GE_CMD_TEXFORMAT, GE_TFMT_8888); // 4444
|
||||
WriteCmd(GE_CMD_TEXFILTER, (1 << 8) | 1); // mag = LINEAR min = LINEAR
|
||||
WriteCmd(GE_CMD_TEXWRAP, (1 << 8) | 1); // clamp texture wrapping
|
||||
WriteCmd(GE_CMD_TEXFUNC, (0 << 16) | (1 << 8) | 0); // RGBA texture reads, modulate, no color doubling
|
||||
WriteCmd(GE_CMD_TEXADDR0, dataAddr & 0xFFFFF0);
|
||||
WriteCmd(GE_CMD_TEXBUFWIDTH0, width | ((dataAddr & 0xFF000000) >> 8));
|
||||
WriteCmd(GE_CMD_TEXFLUSH, 0);
|
||||
}
|
||||
|
||||
void PPGeDisableTexture()
|
||||
{
|
||||
WriteCmd(GE_CMD_TEXTUREMAPENABLE, 0);
|
||||
}
|
||||
|
||||
@@ -68,4 +68,9 @@ void PPGeDraw4Patch(int atlasImage, float x, float y, float w, float h, u32 colo
|
||||
// Just blits an image to the screen, multiplied with the color.
|
||||
void PPGeDrawImage(int atlasImage, float x, float y, int align, u32 color = 0xFFFFFFFF);
|
||||
void PPGeDrawImage(int atlasImage, float x, float y, float w, float h, int align, u32 color = 0xFFFFFFFF);
|
||||
void PPGeDrawImage(float x, float y, float w, float h, float u1, float v1, float u2, float v2, int tw, int th, u32 color);
|
||||
|
||||
void PPGeSetDefaultTexture();
|
||||
void PPGeSetTexture(u32 dataAddr, int width, int height);
|
||||
void PPGeDisableTexture();
|
||||
|
||||
@@ -561,6 +561,7 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff)
|
||||
break;
|
||||
|
||||
case GE_CMD_TEXTUREMAPENABLE:
|
||||
gstate_c.textureChanged = true;
|
||||
DEBUG_LOG(G3D, "DL Texture map enable: %i", data);
|
||||
break;
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ LOCAL_SRC_FILES := \
|
||||
$(SRC)/Common/Timer.cpp \
|
||||
$(SRC)/Common/ThunkARM.cpp \
|
||||
$(SRC)/Common/Misc.cpp \
|
||||
$(SRC)/Common/MathUtil.cpp \
|
||||
$(SRC)/GPU/Math3D.cpp \
|
||||
$(SRC)/GPU/GPUState.cpp \
|
||||
$(SRC)/GPU/GLES/Framebuffer.cpp \
|
||||
|
||||
+1
-1
Submodule native updated: 417a7ae2f3...0de5e114f3.
Reference in new issue
Block a user