HD Packs: Fixed a couple of regressions

This commit is contained in:
Sour 2018-02-26 18:42:49 -05:00
parent 022114bc1f
commit e31f1b9b32
4 changed files with 14 additions and 10 deletions

View file

@ -6,7 +6,7 @@ HdAudioDevice::HdAudioDevice(HdPackData * hdData)
{
_hdData = hdData;
_album = 0;
_flags = 0;
_playbackOptions = 0;
_trackError = false;
_sfxVolume = 128;
_bgmVolume = 128;
@ -24,14 +24,15 @@ void HdAudioDevice::StreamState(bool saving)
if(trackOffset < 0) {
_lastBgmTrack = -1;
}
Stream(_album, _lastBgmTrack, trackOffset, _sfxVolume, _bgmVolume);
Stream(_album, _lastBgmTrack, trackOffset, _sfxVolume, _bgmVolume, _playbackOptions);
} else {
Stream(_album, _lastBgmTrack, trackOffset, _sfxVolume, _bgmVolume);
Stream(_album, _lastBgmTrack, trackOffset, _sfxVolume, _bgmVolume, _playbackOptions);
if(_lastBgmTrack != -1 && trackOffset > 0) {
PlayBgmTrack(_lastBgmTrack, trackOffset);
}
_oggMixer->SetBgmVolume(_bgmVolume);
_oggMixer->SetSfxVolume(_sfxVolume);
_oggMixer->SetPlaybackOptions(_playbackOptions);
}
}
@ -103,7 +104,10 @@ void HdAudioDevice::WriteRAM(uint16_t addr, uint8_t value)
//Playback Options
//Bit 0: Loop BGM
//Bit 1-7: Unused, reserved - must be 0
case 0: _oggMixer->SetPlaybackOptions(value); break;
case 0:
_playbackOptions = value;
_oggMixer->SetPlaybackOptions(_playbackOptions);
break;
//Playback Control
//Bit 0: Toggle Pause/Resume (only affects BGM)

View file

@ -12,7 +12,7 @@ class HdAudioDevice : public IMemoryHandler, public Snapshotable
private:
HdPackData *_hdData;
uint8_t _album;
uint8_t _flags;
uint8_t _playbackOptions;
bool _trackError;
OggMixer* _oggMixer;
int32_t _lastBgmTrack;

View file

@ -285,7 +285,6 @@ void HdNesPack::GetPixels(uint32_t x, uint32_t y, HdPpuPixelInfo &pixelInfo, uin
hdPackTileInfo = GetCachedMatchingTile(x, y, &pixelInfo.Tile);
}
bool hasBgSprite = false;
int lowestBgSprite = 999;
DrawColor(_palette[pixelInfo.Tile.PpuBackgroundColor], outputBuffer, hdData->Scale, screenWidth);
@ -293,8 +292,9 @@ void HdNesPack::GetPixels(uint32_t x, uint32_t y, HdPpuPixelInfo &pixelInfo, uin
if(hasSprite) {
for(int k = pixelInfo.SpriteCount - 1; k >= 0; k--) {
if(pixelInfo.Sprite[k].BackgroundPriority) {
hasBgSprite = true;
if(pixelInfo.Sprite[k].SpriteColorIndex != 0) {
lowestBgSprite = k;
}
hdPackSpriteInfo = GetMatchingTile(x, y, &pixelInfo.Sprite[k]);
if(hdPackSpriteInfo) {

View file

@ -16,7 +16,7 @@ struct HdPackBaseTileCondition : public HdPackCondition
{
TileX = x;
TileY = y;
PixelOffset = (y << 8) + x;
PixelOffset = (y * 256) + x;
PaletteColors = palette;
TileIndex = tileIndex;
if(tileData.size() == 32) {
@ -252,7 +252,7 @@ struct HdPackSpriteNearbyCondition : public HdPackBaseTileCondition
{
int xSign = tile && tile->HorizontalMirroring ? -1 : 1;
int ySign = tile && tile->VerticalMirroring ? -1 : 1;
int pixelIndex = PixelOffset + (y * 256 * ySign) + x * xSign;
int pixelIndex = ((y + TileY * ySign) * 256) + x + (TileX * xSign);
if(pixelIndex < 0 || pixelIndex > PPU::PixelCount) {
return false;