Skip to content

Commit

Permalink
Merge pull request #8715 from unknownbrackets/tex-replace
Browse files Browse the repository at this point in the history
Initial texture replacement support
  • Loading branch information
unknownbrackets committed May 1, 2016
2 parents b6d7aab + 2e1986d commit 9280bb3
Show file tree
Hide file tree
Showing 33 changed files with 1,078 additions and 108 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,8 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/Screenshot.h
Core/System.cpp
Core/System.h
Core/TextureReplacer.cpp
Core/TextureReplacer.h
Core/Util/AudioFormat.cpp
Core/Util/AudioFormat.h
Core/Util/GameManager.cpp
Expand Down
33 changes: 33 additions & 0 deletions Common/ColorConv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,39 @@ void ConvertRGBA4444ToRGBA8888(u32 *dst32, const u16 *src, const u32 numPixels)
}
}

void ConvertABGR565ToRGBA8888(u32 *dst32, const u16 *src, const u32 numPixels) {
u8 *dst = (u8 *)dst32;
for (u32 x = 0; x < numPixels; x++) {
u16 col = src[x];
dst[x * 4] = Convert5To8((col >> 11) & 0x1f);
dst[x * 4 + 1] = Convert6To8((col >> 5) & 0x3f);
dst[x * 4 + 2] = Convert5To8((col) & 0x1f);
dst[x * 4 + 3] = 255;
}
}

void ConvertABGR1555ToRGBA8888(u32 *dst32, const u16 *src, const u32 numPixels) {
u8 *dst = (u8 *)dst32;
for (u32 x = 0; x < numPixels; x++) {
u16 col = src[x];
dst[x * 4] = Convert5To8((col >> 11) & 0x1f);
dst[x * 4 + 1] = Convert5To8((col >> 6) & 0x1f);
dst[x * 4 + 2] = Convert5To8((col >> 1) & 0x1f);
dst[x * 4 + 3] = (col & 1) ? 255 : 0;
}
}

void ConvertABGR4444ToRGBA8888(u32 *dst32, const u16 *src, const u32 numPixels) {
u8 *dst = (u8 *)dst32;
for (u32 x = 0; x < numPixels; x++) {
u16 col = src[x];
dst[x * 4] = Convert4To8(col >> 12);
dst[x * 4 + 1] = Convert4To8((col >> 8) & 0xf);
dst[x * 4 + 2] = Convert4To8((col >> 4) & 0xf);
dst[x * 4 + 3] = Convert4To8(col & 0xf);
}
}

void ConvertRGBA4444ToBGRA8888(u32 *dst32, const u16 *src, const u32 numPixels) {
u8 *dst = (u8 *)dst32;
for (u32 x = 0; x < numPixels; x++) {
Expand Down
4 changes: 4 additions & 0 deletions Common/ColorConv.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ void ConvertRGBA565ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels);
void ConvertRGBA5551ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels);
void ConvertRGBA4444ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels);

void ConvertABGR565ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels);
void ConvertABGR1555ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels);
void ConvertABGR4444ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels);

void ConvertRGBA4444ToBGRA8888(u32 *dst, const u16 *src, const u32 numPixels);
void ConvertRGBA5551ToBGRA8888(u32 *dst, const u16 *src, const u32 numPixels);
void ConvertRGB565ToBGRA8888(u32 *dst, const u16 *src, const u32 numPixels);
Expand Down
3 changes: 2 additions & 1 deletion Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,9 @@ static ConfigSetting graphicsSettings[] = {
ConfigSetting("ImmersiveMode", &g_Config.bImmersiveMode, false, true, true),

ReportedConfigSetting("TrueColor", &g_Config.bTrueColor, true, true, true),

ReportedConfigSetting("MipMap", &g_Config.bMipMap, true, true, true),
ReportedConfigSetting("ReplaceTextures", &g_Config.bReplaceTextures, true, true, true),
ReportedConfigSetting("SaveNewTextures", &g_Config.bSaveNewTextures, false, true, true),

ReportedConfigSetting("TexScalingLevel", &g_Config.iTexScalingLevel, 1, true, true),
ReportedConfigSetting("TexScalingType", &g_Config.iTexScalingType, 0, true, true),
Expand Down
2 changes: 2 additions & 0 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ struct Config {
int bHighQualityDepth;
bool bTrueColor;
bool bMipMap;
bool bReplaceTextures;
bool bSaveNewTextures;
int iTexScalingLevel; // 1 = off, 2 = 2x, ..., 5 = 5x
int iTexScalingType; // 0 = xBRZ, 1 = Hybrid
bool bTexDeposterize;
Expand Down
2 changes: 2 additions & 0 deletions Core/Core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
<ClCompile Include="..\ext\udis86\syn-intel.c" />
<ClCompile Include="..\ext\udis86\syn.c" />
<ClCompile Include="..\ext\udis86\udis86.c" />
<ClCompile Include="TextureReplacer.cpp" />
<ClCompile Include="Compatibility.cpp" />
<ClCompile Include="Config.cpp" />
<ClCompile Include="Core.cpp" />
Expand Down Expand Up @@ -506,6 +507,7 @@
<ClInclude Include="..\ext\udis86\types.h" />
<ClInclude Include="..\ext\udis86\udint.h" />
<ClInclude Include="..\ext\udis86\udis86.h" />
<ClInclude Include="TextureReplacer.h" />
<ClInclude Include="Compatibility.h" />
<ClInclude Include="Config.h" />
<ClInclude Include="Core.h" />
Expand Down
6 changes: 6 additions & 0 deletions Core/Core.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,9 @@
<ClCompile Include="FileLoaders\RamCachingFileLoader.cpp">
<Filter>FileLoaders</Filter>
</ClCompile>
<ClCompile Include="TextureReplacer.cpp">
<Filter>Core</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ELF\ElfReader.h">
Expand Down Expand Up @@ -1173,6 +1176,9 @@
<ClInclude Include="FileLoaders\RamCachingFileLoader.h">
<Filter>FileLoaders</Filter>
</ClInclude>
<ClInclude Include="TextureReplacer.h">
<Filter>Core</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
Expand Down
2 changes: 1 addition & 1 deletion Core/HLE/sceAtrac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ struct Atrac {
channels_(0), outputChannels_(2), bitrate_(64), bytesPerFrame_(0), bufferMaxSize_(0), jointStereo_(0),
currentSample_(0), endSample_(0), firstSampleOffset_(0), dataOff_(0),
loopStartSample_(-1), loopEndSample_(-1), loopNum_(0),
failedDecode_(false), codecType_(0), ignoreDataBuf_(false),
failedDecode_(false), ignoreDataBuf_(false), codecType_(0),
bufferState_(ATRAC_STATUS_NO_DATA) {
memset(&first_, 0, sizeof(first_));
memset(&second_, 0, sizeof(second_));
Expand Down
4 changes: 0 additions & 4 deletions Core/HW/MediaEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ extern "C" {
}
#endif // USE_FFMPEG

int g_iNumVideos = 0;

#ifdef USE_FFMPEG
static AVPixelFormat getSwsFormat(int pspFormat)
{
Expand Down Expand Up @@ -149,12 +147,10 @@ MediaEngine::MediaEngine(): m_pdata(0) {
m_ringbuffersize = 0;
m_mpegheaderReadPos = 0;
m_audioType = PSP_CODEC_AT3PLUS; // in movie, we use only AT3+ audio
g_iNumVideos++;
}

MediaEngine::~MediaEngine() {
closeMedia();
g_iNumVideos--;
}

void MediaEngine::closeMedia() {
Expand Down
2 changes: 1 addition & 1 deletion Core/HW/SasReverb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void SasReverb::SetPreset(int preset) {
template<int bufsize>
class BufferWrapper {
public:
BufferWrapper(int16_t *buffer, int position, int usedSize) : buf_(buffer), pos_(position), base_(bufsize - usedSize), end_(bufsize), size_(usedSize) {}
BufferWrapper(int16_t *buffer, int position, int usedSize) : buf_(buffer), pos_(position), end_(bufsize), base_(bufsize - usedSize), size_(usedSize) {}
int16_t &operator [](int index) {
int addr = pos_ + index;
if (addr >= end_) { addr -= size_; }
Expand Down
2 changes: 2 additions & 0 deletions Core/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,8 @@ std::string GetSysDirectory(PSPDirectories directoryType) {
return g_Config.memStickDirectory + "PSP/PPSSPP_STATE/";
case DIRECTORY_CACHE:
return g_Config.memStickDirectory + "PSP/SYSTEM/CACHE/";
case DIRECTORY_TEXTURES:
return g_Config.memStickDirectory + "PSP/TEXTURES/";
case DIRECTORY_APP_CACHE:
if (!g_Config.appCacheDirectory.empty()) {
return g_Config.appCacheDirectory;
Expand Down
1 change: 1 addition & 0 deletions Core/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ enum PSPDirectories {
DIRECTORY_DUMP,
DIRECTORY_SAVESTATE,
DIRECTORY_CACHE,
DIRECTORY_TEXTURES,
DIRECTORY_APP_CACHE, // Use the OS app cache if available
};

Expand Down
Loading

0 comments on commit 9280bb3

Please sign in to comment.