HD Packs: Added built-in conditions (hmirror, vmirror, bgpriority)
This commit is contained in:
parent
92d1ca5382
commit
b469bc5308
5 changed files with 48 additions and 14 deletions
|
@ -109,6 +109,9 @@ enum class HdPackConditionType
|
|||
SpriteAtPosition,
|
||||
TileNearby,
|
||||
SpriteNearby,
|
||||
HorizontalMirroring,
|
||||
VerticalMirroring,
|
||||
BackgroundPriority,
|
||||
};
|
||||
|
||||
struct HdPackCondition
|
||||
|
@ -121,9 +124,18 @@ struct HdPackCondition
|
|||
int32_t TileIndex;
|
||||
uint8_t TileData[16];
|
||||
|
||||
bool CheckCondition(HdPpuPixelInfo *screenTiles, int x, int y)
|
||||
bool CheckCondition(HdPpuPixelInfo *screenTiles, int x, int y, HdPpuTileInfo* tile)
|
||||
{
|
||||
switch(Type) {
|
||||
case HdPackConditionType::HorizontalMirroring:
|
||||
return tile && tile->HorizontalMirroring;
|
||||
|
||||
case HdPackConditionType::VerticalMirroring:
|
||||
return tile && tile->VerticalMirroring;
|
||||
|
||||
case HdPackConditionType::BackgroundPriority:
|
||||
return tile && tile->BackgroundPriority;
|
||||
|
||||
case HdPackConditionType::TileAtPosition:
|
||||
case HdPackConditionType::SpriteAtPosition: {
|
||||
int pixelIndex = (TileY << 8) + TileX;
|
||||
|
@ -233,10 +245,10 @@ struct HdPackTileInfo : public HdTileKey
|
|||
|
||||
vector<HdPackCondition*> Conditions;
|
||||
|
||||
bool MatchesCondition(HdPpuPixelInfo *screenTiles, int x, int y)
|
||||
bool MatchesCondition(HdPpuPixelInfo *screenTiles, int x, int y, HdPpuTileInfo* tile)
|
||||
{
|
||||
for(HdPackCondition* condition : Conditions) {
|
||||
if(!condition->CheckCondition(screenTiles, x, y)) {
|
||||
if(!condition->CheckCondition(screenTiles, x, y, tile)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ void HdNesPack::OnBeforeApplyFilter(HdPpuPixelInfo *screenTiles)
|
|||
for(size_t i = 0; i < hdData->Backgrounds.size(); i++) {
|
||||
bool isMatch = true;
|
||||
for(HdPackCondition* condition : hdData->Backgrounds[i].Conditions) {
|
||||
if(!condition->CheckCondition(screenTiles, 0, 0)) {
|
||||
if(!condition->CheckCondition(screenTiles, 0, 0, nullptr)) {
|
||||
isMatch = false;
|
||||
break;
|
||||
}
|
||||
|
@ -156,18 +156,18 @@ void HdNesPack::OnBeforeApplyFilter(HdPpuPixelInfo *screenTiles)
|
|||
}
|
||||
}
|
||||
|
||||
HdPackTileInfo * HdNesPack::GetMatchingTile(HdPpuPixelInfo *screenTiles, uint32_t x, uint32_t y, HdTileKey &key)
|
||||
HdPackTileInfo * HdNesPack::GetMatchingTile(HdPpuPixelInfo *screenTiles, uint32_t x, uint32_t y, HdPpuTileInfo* tile)
|
||||
{
|
||||
HdPackData *hdData = Console::GetHdData();
|
||||
auto hdTile = hdData->TileByKey.find(key);
|
||||
auto hdTile = hdData->TileByKey.find(*tile);
|
||||
if(hdTile == hdData->TileByKey.end()) {
|
||||
hdTile = hdData->TileByKey.find(key.GetKey(true));
|
||||
hdTile = hdData->TileByKey.find(tile->GetKey(true));
|
||||
}
|
||||
|
||||
if(hdTile != hdData->TileByKey.end()) {
|
||||
for(HdPackTileInfo* tile : hdTile->second) {
|
||||
if(tile->MatchesCondition(screenTiles, x, y)) {
|
||||
return tile;
|
||||
for(HdPackTileInfo* hdTile : hdTile->second) {
|
||||
if(hdTile->MatchesCondition(screenTiles, x, y, tile)) {
|
||||
return hdTile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ void HdNesPack::GetPixels(HdPpuPixelInfo *screenTiles, uint32_t x, uint32_t y, H
|
|||
|
||||
bool hasSprite = pixelInfo.SpriteCount > 0;
|
||||
if(pixelInfo.Tile.TileIndex != HdPpuTileInfo::NoTile) {
|
||||
hdPackTileInfo = GetMatchingTile(screenTiles, x, y, pixelInfo.Tile);
|
||||
hdPackTileInfo = GetMatchingTile(screenTiles, x, y, &pixelInfo.Tile);
|
||||
}
|
||||
|
||||
bool hasBgSprite = false;
|
||||
|
@ -244,7 +244,7 @@ void HdNesPack::GetPixels(HdPpuPixelInfo *screenTiles, uint32_t x, uint32_t y, H
|
|||
hasBgSprite = true;
|
||||
lowestBgSprite = k;
|
||||
|
||||
hdPackSpriteInfo = GetMatchingTile(screenTiles, x, y, pixelInfo.Sprite[k]);
|
||||
hdPackSpriteInfo = GetMatchingTile(screenTiles, x, y, &pixelInfo.Sprite[k]);
|
||||
if(hdPackSpriteInfo) {
|
||||
DrawTile(pixelInfo.Sprite[k], *hdPackSpriteInfo, outputBuffer, screenWidth);
|
||||
} else if(pixelInfo.Sprite[k].SpriteColorIndex != 0) {
|
||||
|
@ -275,7 +275,7 @@ void HdNesPack::GetPixels(HdPpuPixelInfo *screenTiles, uint32_t x, uint32_t y, H
|
|||
if(hasSprite) {
|
||||
for(int k = pixelInfo.SpriteCount - 1; k >= 0; k--) {
|
||||
if(!pixelInfo.Sprite[k].BackgroundPriority && lowestBgSprite > k) {
|
||||
hdPackSpriteInfo = GetMatchingTile(screenTiles, x, y, pixelInfo.Sprite[k]);
|
||||
hdPackSpriteInfo = GetMatchingTile(screenTiles, x, y, &pixelInfo.Sprite[k]);
|
||||
if(hdPackSpriteInfo) {
|
||||
DrawTile(pixelInfo.Sprite[k], *hdPackSpriteInfo, outputBuffer, screenWidth);
|
||||
} else if(pixelInfo.Sprite[k].SpriteColorIndex != 0) {
|
||||
|
|
|
@ -12,7 +12,7 @@ private:
|
|||
__forceinline uint32_t AdjustBrightness(uint8_t input[4], uint16_t brightness);
|
||||
__forceinline void DrawColor(uint32_t color, uint32_t* outputBuffer, uint32_t scale, uint32_t screenWidth);
|
||||
__forceinline void DrawTile(HdPpuTileInfo &tileInfo, HdPackTileInfo &hdPackTileInfo, uint32_t* outputBuffer, uint32_t screenWidth);
|
||||
__forceinline HdPackTileInfo* GetMatchingTile(HdPpuPixelInfo *screenTiles, uint32_t x, uint32_t y, HdTileKey& key);
|
||||
__forceinline HdPackTileInfo* GetMatchingTile(HdPpuPixelInfo *screenTiles, uint32_t x, uint32_t y, HdPpuTileInfo* tile);
|
||||
|
||||
__forceinline bool IsNextToSprite(HdPpuPixelInfo *screenTiles, uint32_t x, uint32_t y);
|
||||
__forceinline uint32_t GetCustomBackgroundPixel(int x, int y, int offsetX, int offsetY);
|
||||
|
|
|
@ -112,6 +112,8 @@ bool HdPackLoader::LoadPack()
|
|||
return false;
|
||||
}
|
||||
|
||||
InitializeGlobalConditions();
|
||||
|
||||
for(string lineContent : StringUtilities::Split(string(hdDefinition.data(), hdDefinition.data() + hdDefinition.size()), '\n')) {
|
||||
lineContent = lineContent.substr(0, lineContent.length() - 1);
|
||||
|
||||
|
@ -178,6 +180,24 @@ bool HdPackLoader::ProcessImgTag(string src)
|
|||
}
|
||||
}
|
||||
|
||||
void HdPackLoader::InitializeGlobalConditions()
|
||||
{
|
||||
HdPackCondition* hmirror = new HdPackCondition();
|
||||
hmirror->Name = "hmirror";
|
||||
hmirror->Type = HdPackConditionType::HorizontalMirroring;
|
||||
_data->Conditions.push_back(unique_ptr<HdPackCondition>(hmirror));
|
||||
|
||||
HdPackCondition* vmirror = new HdPackCondition();
|
||||
vmirror->Name = "vmirror";
|
||||
vmirror->Type = HdPackConditionType::VerticalMirroring;
|
||||
_data->Conditions.push_back(unique_ptr<HdPackCondition>(vmirror));
|
||||
|
||||
HdPackCondition* bgpriority = new HdPackCondition();
|
||||
bgpriority->Name = "bgpriority";
|
||||
bgpriority->Type = HdPackConditionType::BackgroundPriority;
|
||||
_data->Conditions.push_back(unique_ptr<HdPackCondition>(bgpriority));
|
||||
}
|
||||
|
||||
void HdPackLoader::ProcessOverscanTag(vector<string> &tokens)
|
||||
{
|
||||
OverscanDimensions overscan;
|
||||
|
|
|
@ -27,6 +27,8 @@ private:
|
|||
void InitializeHdPack();
|
||||
void LoadCustomPalette();
|
||||
|
||||
void InitializeGlobalConditions();
|
||||
|
||||
bool ProcessImgTag(string src);
|
||||
void ProcessPatchTag(vector<string> &tokens);
|
||||
void ProcessOverscanTag(vector<string> &tokens);
|
||||
|
|
Loading…
Add table
Reference in a new issue