HD Packs: Added new features (contributed by kya) + updated docs
This commit is contained in:
parent
2c361cc92e
commit
11135ec485
5 changed files with 55 additions and 24 deletions
|
@ -185,7 +185,7 @@ struct HdPackTileInfo : public HdTileKey
|
|||
uint32_t X;
|
||||
uint32_t Y;
|
||||
uint32_t BitmapIndex;
|
||||
uint8_t Brightness;
|
||||
int Brightness;
|
||||
bool DefaultTile;
|
||||
bool Blank;
|
||||
bool HasTransparentPixels;
|
||||
|
@ -309,11 +309,13 @@ struct HdBackgroundFileData
|
|||
struct HdBackgroundInfo
|
||||
{
|
||||
HdBackgroundFileData* Data;
|
||||
uint8_t Brightness;
|
||||
int Brightness;
|
||||
vector<HdPackCondition*> Conditions;
|
||||
float HorizontalScrollRatio;
|
||||
float VerticalScrollRatio;
|
||||
bool BehindBgPrioritySprites;
|
||||
uint32_t Left;
|
||||
uint32_t Top;
|
||||
|
||||
uint32_t* data()
|
||||
{
|
||||
|
@ -377,4 +379,5 @@ enum class HdPackOptions
|
|||
AlternateRegisterRange = 2,
|
||||
NoContours = 4,
|
||||
DisableCache = 8,
|
||||
DontRenderOriginalTiles = 16
|
||||
};
|
|
@ -29,12 +29,12 @@ void HdNesPack::BlendColors(uint8_t output[4], uint8_t input[4])
|
|||
output[3] = 0xFF;
|
||||
}
|
||||
|
||||
uint32_t HdNesPack::AdjustBrightness(uint8_t input[4], uint16_t brightness)
|
||||
uint32_t HdNesPack::AdjustBrightness(uint8_t input[4], int brightness)
|
||||
{
|
||||
return (
|
||||
std::min(255, (brightness * input[0]) >> 8) |
|
||||
(std::min(255, (brightness * input[1]) >> 8) << 8) |
|
||||
(std::min(255, (brightness * input[2]) >> 8) << 16) |
|
||||
std::min(255, (brightness * ((int)input[0] + 1)) >> 8) |
|
||||
(std::min(255, (brightness * ((int)input[1] + 1)) >> 8) << 8) |
|
||||
(std::min(255, (brightness * ((int)input[2] + 1)) >> 8) << 16) |
|
||||
(input[3] << 24)
|
||||
);
|
||||
}
|
||||
|
@ -53,9 +53,11 @@ void HdNesPack::DrawColor(uint32_t color, uint32_t *outputBuffer, uint32_t scale
|
|||
|
||||
void HdNesPack::DrawCustomBackground(uint32_t *outputBuffer, uint32_t x, uint32_t y, uint32_t scale, uint32_t screenWidth)
|
||||
{
|
||||
uint8_t brightness = _hdData->Backgrounds[_backgroundIndex].Brightness;
|
||||
int brightness = _hdData->Backgrounds[_backgroundIndex].Brightness;
|
||||
uint32_t left = _hdData->Backgrounds[_backgroundIndex].Left;
|
||||
uint32_t top = _hdData->Backgrounds[_backgroundIndex].Top;
|
||||
uint32_t width = _hdData->Backgrounds[_backgroundIndex].Data->Width;
|
||||
uint32_t *pngData = _hdData->Backgrounds[_backgroundIndex].data() + (y * _hdData->Scale * width) + (x * _hdData->Scale);
|
||||
uint32_t *pngData = _hdData->Backgrounds[_backgroundIndex].data() + ((top + y) * _hdData->Scale * width) + ((left + x) * _hdData->Scale);
|
||||
|
||||
if(scale == 1) {
|
||||
if(brightness == 255) {
|
||||
|
@ -71,7 +73,7 @@ void HdNesPack::DrawCustomBackground(uint32_t *outputBuffer, uint32_t x, uint32_
|
|||
pngData += width;
|
||||
}
|
||||
|
||||
if(brightness < 255) {
|
||||
if(brightness != 255) {
|
||||
for(uint32_t i = 0; i < scale; i++) {
|
||||
for(uint32_t j = 0; j < scale; j++) {
|
||||
*buffer = AdjustBrightness((uint8_t*)buffer, brightness);
|
||||
|
@ -107,7 +109,7 @@ void HdNesPack::DrawTile(HdPpuTileInfo &tileInfo, HdPackTileInfo &hdPackTileInfo
|
|||
}
|
||||
|
||||
uint32_t rgbValue;
|
||||
if(hdPackTileInfo.HasTransparentPixels || hdPackTileInfo.Brightness < 255) {
|
||||
if(hdPackTileInfo.HasTransparentPixels || hdPackTileInfo.Brightness != 255) {
|
||||
for(uint32_t y = 0; y < scale; y++) {
|
||||
for(uint32_t x = 0; x < scale; x++) {
|
||||
if(hdPackTileInfo.Brightness == 255) {
|
||||
|
@ -278,6 +280,7 @@ void HdNesPack::GetPixels(uint32_t x, uint32_t y, HdPpuPixelInfo &pixelInfo, uin
|
|||
HdPackTileInfo *hdPackSpriteInfo = nullptr;
|
||||
|
||||
bool hasSprite = pixelInfo.SpriteCount > 0;
|
||||
bool renderOriginalTiles = ((_hdData->OptionFlags & (int)HdPackOptions::DontRenderOriginalTiles) == 0);
|
||||
if(pixelInfo.Tile.TileIndex != HdPpuTileInfo::NoTile) {
|
||||
hdPackTileInfo = GetCachedMatchingTile(x, y, &pixelInfo.Tile);
|
||||
}
|
||||
|
@ -296,8 +299,8 @@ void HdNesPack::GetPixels(uint32_t x, uint32_t y, HdPpuPixelInfo &pixelInfo, uin
|
|||
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;
|
||||
(y + bgInfo.Top + _bgScrollY + 1) * _hdData->Scale <= bgInfo.Data->Height &&
|
||||
(x + bgInfo.Left + _bgScrollX + 1) * _hdData->Scale <= bgInfo.Data->Width;
|
||||
|
||||
if(hasCustomBackground) {
|
||||
hasNonBackgroundSurrounding = _contoursEnabled && IsNextToSprite(x, y);
|
||||
|
@ -331,7 +334,7 @@ void HdNesPack::GetPixels(uint32_t x, uint32_t y, HdPpuPixelInfo &pixelInfo, uin
|
|||
|
||||
if(hdPackTileInfo) {
|
||||
DrawTile(pixelInfo.Tile, *hdPackTileInfo, outputBuffer, screenWidth);
|
||||
} else {
|
||||
} else if(renderOriginalTiles) {
|
||||
//Draw regular SD background tile
|
||||
bool useCustomBackground = !hasNonBackgroundSurrounding && hasCustomBackground && pixelInfo.Tile.BgColorIndex == 0;
|
||||
if(!useCustomBackground && (pixelInfo.Tile.BgColorIndex != 0 || hasNonBackgroundSurrounding)) {
|
||||
|
|
|
@ -22,7 +22,7 @@ private:
|
|||
int32_t _bgScrollY = 0;
|
||||
|
||||
__forceinline void BlendColors(uint8_t output[4], uint8_t input[4]);
|
||||
__forceinline uint32_t AdjustBrightness(uint8_t input[4], uint16_t brightness);
|
||||
__forceinline uint32_t AdjustBrightness(uint8_t input[4], int 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);
|
||||
|
||||
|
@ -38,7 +38,7 @@ private:
|
|||
__forceinline void ProcessGrayscaleAndEmphasis(HdPpuPixelInfo &pixelInfo, uint32_t* outputBuffer, uint32_t hdScreenWidth);
|
||||
|
||||
public:
|
||||
static constexpr uint32_t CurrentVersion = 104;
|
||||
static constexpr uint32_t CurrentVersion = 105;
|
||||
|
||||
HdNesPack(shared_ptr<HdPackData> hdData, EmulationSettings* settings);
|
||||
~HdNesPack();
|
||||
|
|
|
@ -324,7 +324,9 @@ void HdPackLoader::ProcessTileTag(vector<string> &tokens, vector<HdPackCondition
|
|||
}
|
||||
}
|
||||
|
||||
if(_data->Version > 0) {
|
||||
if(_data->Version >= 105) {
|
||||
tileInfo->Brightness = (int)(std::stof(tokens[index++]) * 255);
|
||||
} else if(_data->Version > 0) {
|
||||
tileInfo->Brightness = (uint8_t)(std::stof(tokens[index++]) * 255);
|
||||
} else {
|
||||
tileInfo->Brightness = 255;
|
||||
|
@ -381,6 +383,8 @@ void HdPackLoader::ProcessOptionTag(vector<string> &tokens)
|
|||
_data->OptionFlags |= (int)HdPackOptions::NoContours;
|
||||
} else if(token == "disableCache") {
|
||||
_data->OptionFlags |= (int)HdPackOptions::DisableCache;
|
||||
} else if(token == "disableOriginalTiles") {
|
||||
_data->OptionFlags |= (int)HdPackOptions::DontRenderOriginalTiles;
|
||||
} else {
|
||||
MessageManager::Log("[HDPack] Invalid option: " + token);
|
||||
}
|
||||
|
@ -551,10 +555,16 @@ void HdPackLoader::ProcessBackgroundTag(vector<string> &tokens, vector<HdPackCon
|
|||
HdBackgroundInfo backgroundInfo;
|
||||
if(bgFileData) {
|
||||
backgroundInfo.Data = bgFileData;
|
||||
backgroundInfo.Brightness = (uint8_t)(std::stof(tokens[1]) * 255);
|
||||
if (_data->Version >= 105) {
|
||||
backgroundInfo.Brightness = (int)(std::stof(tokens[1]) * 255);
|
||||
} else {
|
||||
backgroundInfo.Brightness = (uint8_t)(std::stof(tokens[1]) * 255);
|
||||
}
|
||||
backgroundInfo.HorizontalScrollRatio = 0;
|
||||
backgroundInfo.VerticalScrollRatio = 0;
|
||||
backgroundInfo.BehindBgPrioritySprites = false;
|
||||
backgroundInfo.Left = 0;
|
||||
backgroundInfo.Top = 0;
|
||||
|
||||
for(HdPackCondition* condition : conditions) {
|
||||
if(
|
||||
|
@ -582,6 +592,11 @@ void HdPackLoader::ProcessBackgroundTag(vector<string> &tokens, vector<HdPackCon
|
|||
checkConstraint(_data->Version >= 102, "[HDPack] This feature requires version 102+ of HD Packs");
|
||||
backgroundInfo.BehindBgPrioritySprites = tokens[4] == "Y";
|
||||
}
|
||||
if(tokens.size() > 6) {
|
||||
checkConstraint(_data->Version >= 105, "[HDPack] This feature requires version 105+ of HD Packs");
|
||||
backgroundInfo.Left = std::max(0, std::stoi(tokens[5]));
|
||||
backgroundInfo.Top = std::max(0, std::stoi(tokens[6]));
|
||||
}
|
||||
}
|
||||
|
||||
_data->Backgrounds.push_back(backgroundInfo);
|
||||
|
|
|
@ -55,14 +55,14 @@ Before you start recording, select the options you want to use and the location
|
|||
|
||||
## File Format (hires.txt) ##
|
||||
|
||||
The following are the specifications for the hires.txt file, as of version "104".
|
||||
The following are the specifications for the hires.txt file, as of version "105".
|
||||
|
||||
### <ver> tag ###
|
||||
|
||||
**Syntax**: `<ver>[integer]`
|
||||
**Example**: `<ver>104`
|
||||
**Example**: `<ver>105`
|
||||
|
||||
The format's version number (currently 104).
|
||||
The format's version number (currently 105).
|
||||
|
||||
### <scale> tag ###
|
||||
|
||||
|
@ -174,7 +174,7 @@ The condition is true when the following expression is true:
|
|||
|
||||
### <tile> tag ###
|
||||
|
||||
**Syntax**: `<tile>[img index - integer], [tile data], [palette data], [x - integer], [y - integer], [brightness - 0.0 to 1.0], [default tile - Y or N]`
|
||||
**Syntax**: `<tile>[img index - integer], [tile data], [palette data], [x - integer], [y - integer], [brightness - float (default: 1.0)], [default tile - Y or N]`
|
||||
**Example (CHR ROM)**: `<tile>0,2E,FF16360F,0,0,1,N`
|
||||
**Example (CHR RAM)**: `<tile>0,0E0E079C1E3EA7076101586121010000,0F100017,176,1168,1,N`
|
||||
|
||||
|
@ -185,19 +185,22 @@ For CHR RAM games, `tile data` is a 32-character hexadecimal string representing
|
|||
`<tile>` define mappings between the original game's tile data and their replacements in the PNG file.
|
||||
The `tile data` and `palette data` are used to identify the original tile, while the `img index`, `x` and `y` fields are used to specify in which PNG file the replacement can be found, and at what x,y coordinates in that PNG file.
|
||||
|
||||
`brightness` can be used to reuse the same HD tile for multiple original tiles -- this can be useful when a game has fade in and out effects.
|
||||
`brightness` can be used to reuse the same HD tile for multiple original tiles -- this can be useful when a game has fade in and out effects (the brightness can be set to values above 1.0 to increase the PNG's normal brightness level).
|
||||
When `default tile` is enabled (with `Y`), the tile is marked as the `default tile` for all palettes. Whenever a tile appears on the screen that matches the tile data, but has no rules matching its palette data, the default tile will be used instead.
|
||||
|
||||
### <background> tag ###
|
||||
|
||||
**Syntax**: `<background>[name - text], [brightness level - 0.0 to 1.0], [horizontal scroll ratio (optional) - float], [vertical scroll ratio (optional) - float], [showBehindBackgroundPrioritySprites (optional) - Y or N]`
|
||||
**Example**: `<background>myBackground.png,1.0,0,0,N`
|
||||
**Syntax**: `<background>[name - text], [brightness level - float (default: 1.0)], [horizontal scroll ratio (optional) - float], [vertical scroll ratio (optional) - float], [showBehindBackgroundPrioritySprites (optional) - Y or N], [image left offset (optional) - int], [image top offset (optional) - int]`
|
||||
**Example**: `<background>myBackground.png,1.0,0,0,N,0,0`
|
||||
|
||||
`<background>` tags meant to be used alongside conditions to add a background image under certain conditions (e.g on a specific screen, for example).
|
||||
|
||||
The `Horizontal Scroll Ratio` and `Vertical Scroll Ratio` parameters are optional (their default value is `0.0`) and can be used to specify at what speed the background picture should scroll compared to the NES' scrolling.
|
||||
This can be used to create simple parallax scrolling effects.
|
||||
|
||||
The `Image Left Offset` and `Image Top Offset` parameters are optional (their default value is `0`) and can be used to offset the position of the background image within the PNG file. e.g: Specifying 100 for the left offset will cause the background to be scrolled 100 pixels to the left by default.
|
||||
With conditions, this can be used to create scrolling effects that are based on something other than the PPU's current scroll offset.
|
||||
|
||||
When the `Show Behind Background Priority Sprites` parameter is enabled (`Y`), the background priority sprites will be shown in front of the background image.
|
||||
|
||||
### <options> tag ###
|
||||
|
@ -208,6 +211,7 @@ When the `Show Behind Background Priority Sprites` parameter is enabled (`Y`), t
|
|||
**Available options**:
|
||||
`disableSpriteLimit`: Forces the emulator to disable the sprite limit when the HD pack is loaded.
|
||||
`disableContours`: Disables the outline effect that appears around sprites/tiles when using the `<background>` feature.
|
||||
`disableOriginalTiles`: Normally, when a replacement for a tile is not found, the original tile is drawn. When this option is enabled, the original tiles are never drawn, only their HD replacements.
|
||||
|
||||
### <bgm> tag ###
|
||||
|
||||
|
@ -304,6 +308,12 @@ These registers return the ASCII string `NEA` (NES Enhanced Audio) - this can be
|
|||
|
||||
## File Format Changelog ##
|
||||
|
||||
### Version 105 ###
|
||||
|
||||
* Brightness values above 1.0 are now allowed.
|
||||
* Added `disableOriginalTiles` option
|
||||
* Background tags can now specify `left` and `top` values.
|
||||
|
||||
### Version 104 ###
|
||||
|
||||
* Tile indexes for the `<condition>` tag (tileNearby/spriteNearby/tileAtPosition/spriteAtPosition) are now in hex instead of decimal (affects CHR ROM games only)
|
||||
|
|
Loading…
Add table
Reference in a new issue