mirror of
https://github.com/libretro/Mesen.git
synced 2025-01-23 17:44:34 +00:00
HD Packs: Added option to display custom backgrounds behind bg priority sprites (instead of over them)
This commit is contained in:
parent
ad1925bbfd
commit
4a52c94816
@ -314,6 +314,7 @@ struct HdBackgroundInfo
|
||||
vector<HdPackCondition*> Conditions;
|
||||
float HorizontalScrollRatio;
|
||||
float VerticalScrollRatio;
|
||||
bool BehindBgPrioritySprites;
|
||||
|
||||
uint32_t* data()
|
||||
{
|
||||
|
@ -289,6 +289,28 @@ void HdNesPack::GetPixels(uint32_t x, uint32_t y, HdPpuPixelInfo &pixelInfo, uin
|
||||
|
||||
DrawColor(_palette[pixelInfo.Tile.PpuBackgroundColor], outputBuffer, hdData->Scale, screenWidth);
|
||||
|
||||
bool hasCustomBackground = false;
|
||||
bool hasNonBackgroundSurrounding = false;
|
||||
bool backgroundBehindBgSprites = false;
|
||||
if(_backgroundIndex >= 0) {
|
||||
HdBackgroundInfo &bgInfo = hdData->Backgrounds[_backgroundIndex];
|
||||
|
||||
//Enable custom background if the current pixel fits within the background's boundaries
|
||||
hasCustomBackground =
|
||||
(int32_t)x >= -_bgScrollX &&
|
||||
(int32_t)y >= -_bgScrollY &&
|
||||
(y + _bgScrollY + 1) * hdData->Scale <= bgInfo.Data->Height &&
|
||||
(x + _bgScrollX + 1) * hdData->Scale <= bgInfo.Data->Width;
|
||||
|
||||
if(hasCustomBackground) {
|
||||
hasNonBackgroundSurrounding = _contoursEnabled && IsNextToSprite(x, y);
|
||||
if(bgInfo.BehindBgPrioritySprites) {
|
||||
DrawCustomBackground(outputBuffer, x + _bgScrollX, y + _bgScrollY, hdData->Scale, screenWidth);
|
||||
backgroundBehindBgSprites = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(hasSprite) {
|
||||
for(int k = pixelInfo.SpriteCount - 1; k >= 0; k--) {
|
||||
if(pixelInfo.Sprite[k].BackgroundPriority) {
|
||||
@ -306,22 +328,8 @@ void HdNesPack::GetPixels(uint32_t x, uint32_t y, HdPpuPixelInfo &pixelInfo, uin
|
||||
}
|
||||
}
|
||||
|
||||
bool hasCustomBackground = false;
|
||||
bool hasNonBackgroundSurrounding = false;
|
||||
if(_backgroundIndex >= 0) {
|
||||
HdBackgroundInfo &bgInfo = hdData->Backgrounds[_backgroundIndex];
|
||||
|
||||
//Enable custom background if the current pixel fits within the background's boundaries
|
||||
hasCustomBackground =
|
||||
(int32_t)x >= -_bgScrollX &&
|
||||
(int32_t)y >= -_bgScrollY &&
|
||||
(y + _bgScrollY + 1) * hdData->Scale <= bgInfo.Data->Height &&
|
||||
(x + _bgScrollX + 1) * hdData->Scale <= bgInfo.Data->Width;
|
||||
|
||||
if(hasCustomBackground) {
|
||||
hasNonBackgroundSurrounding = _contoursEnabled && IsNextToSprite(x, y);
|
||||
DrawCustomBackground(outputBuffer, x + _bgScrollX, y + _bgScrollY, hdData->Scale, screenWidth);
|
||||
}
|
||||
if (hasCustomBackground && !backgroundBehindBgSprites) {
|
||||
DrawCustomBackground(outputBuffer, x + _bgScrollX, y + _bgScrollY, hdData->Scale, screenWidth);
|
||||
}
|
||||
|
||||
if(hdPackTileInfo) {
|
||||
|
@ -33,7 +33,7 @@ private:
|
||||
__forceinline void ProcessGrayscaleAndEmphasis(HdPpuPixelInfo &pixelInfo, uint32_t* outputBuffer, uint32_t hdScreenWidth);
|
||||
|
||||
public:
|
||||
static const uint32_t CurrentVersion = 101;
|
||||
static const uint32_t CurrentVersion = 102;
|
||||
|
||||
HdNesPack();
|
||||
~HdNesPack();
|
||||
|
@ -213,7 +213,6 @@ bool HdPackLoader::ProcessImgTag(string src)
|
||||
bitmapInfo.PixelData.resize(pixelData.size() / 4);
|
||||
memcpy(bitmapInfo.PixelData.data(), pixelData.data(), bitmapInfo.PixelData.size() * sizeof(bitmapInfo.PixelData[0]));
|
||||
|
||||
|
||||
_hdNesBitmaps.push_back(bitmapInfo);
|
||||
return true;
|
||||
} else {
|
||||
@ -533,6 +532,7 @@ void HdPackLoader::ProcessBackgroundTag(vector<string> &tokens, vector<HdPackCon
|
||||
backgroundInfo.Brightness = (uint8_t)(std::stof(tokens[1]) * 255);
|
||||
backgroundInfo.HorizontalScrollRatio = 0;
|
||||
backgroundInfo.VerticalScrollRatio = 0;
|
||||
backgroundInfo.BehindBgPrioritySprites = false;
|
||||
|
||||
for(HdPackCondition* condition : conditions) {
|
||||
if(
|
||||
@ -556,6 +556,10 @@ void HdPackLoader::ProcessBackgroundTag(vector<string> &tokens, vector<HdPackCon
|
||||
if(tokens.size() > 3) {
|
||||
backgroundInfo.VerticalScrollRatio = std::stof(tokens[3]);
|
||||
}
|
||||
if(tokens.size() > 4) {
|
||||
checkConstraint(_data->Version >= 102, "[HDPack] This feature requires version 102+ of HD Packs");
|
||||
backgroundInfo.BehindBgPrioritySprites = tokens[4] == "Y";
|
||||
}
|
||||
}
|
||||
|
||||
_data->Backgrounds.push_back(backgroundInfo);
|
||||
|
@ -23,7 +23,7 @@ namespace Mesen.GUI.Config
|
||||
public ScreenRotation ScreenRotation = ScreenRotation.None;
|
||||
[MinMax(0.1, 5.0)] public double CustomAspectRatio = 1.0;
|
||||
public bool VerticalSync = false;
|
||||
public bool UseHdPacks = false;
|
||||
public bool UseHdPacks = true;
|
||||
public bool IntegerFpsMode = false;
|
||||
public string PaletteData;
|
||||
|
||||
|
@ -95,6 +95,9 @@ namespace Mesen.GUI.Forms
|
||||
if(ConfigManager.Config.AudioInfo.AudioLatency < 60) {
|
||||
ConfigManager.Config.AudioInfo.AudioLatency = 60;
|
||||
}
|
||||
|
||||
//No reason to keep this disabled by default - enabling it by default makes it easier for new users to install/use HD packs
|
||||
ConfigManager.Config.VideoInfo.UseHdPacks = true;
|
||||
}
|
||||
|
||||
ConfigManager.Config.MesenVersion = InteropEmu.GetMesenVersion();
|
||||
|
Loading…
x
Reference in New Issue
Block a user