HD Pack Builder: Allow HD tiles to be shown while recording

This commit is contained in:
Sour 2018-09-13 20:58:35 -04:00
parent 7ec7512fde
commit 35b182b435
4 changed files with 33 additions and 14 deletions

View file

@ -1138,7 +1138,7 @@ void Console::StartRecordingHdPack(string saveFolder, ScaleFilterType filterType
_memoryManager->UnregisterIODevice(_ppu.get());
_ppu.reset();
_ppu.reset(new HdBuilderPpu(shared_from_this(), _hdPackBuilder.get(), chrRamBankSize));
_ppu.reset(new HdBuilderPpu(shared_from_this(), _hdPackBuilder.get(), chrRamBankSize, _hdData));
_memoryManager->RegisterIODevice(_ppu.get());
shared_ptr<Debugger> debugger = _debugger;
@ -1159,7 +1159,11 @@ void Console::StopRecordingHdPack()
_memoryManager->UnregisterIODevice(_ppu.get());
_ppu.reset();
_ppu.reset(new PPU(shared_from_this()));
if(_hdData && (!_hdData->Tiles.empty() || !_hdData->Backgrounds.empty())) {
_ppu.reset(new HdPpu(shared_from_this(), _hdData.get()));
} else {
_ppu.reset(new PPU(shared_from_this()));
}
_memoryManager->RegisterIODevice(_ppu.get());
_hdPackBuilder.reset();

View file

@ -5,10 +5,11 @@
#include "VideoDecoder.h"
#include "RewindManager.h"
#include "HdPackBuilder.h"
#include "HdPpu.h"
class ControlManager;
class HdBuilderPpu : public PPU
class HdBuilderPpu : public HdPpu
{
private:
HdPackBuilder* _hdPackBuilder;
@ -86,6 +87,10 @@ protected:
//"If the current VRAM address points in the range $3F00-$3FFF during forced blanking, the color indicated by this palette location will be shown on screen instead of the backdrop color."
_currentOutputBuffer[(_scanline << 8) + _cycle - 1] = _paletteRAM[_state.VideoRamAddr & 0x1F];
}
if(_hdData) {
HdPpu::DrawPixel();
}
}
void WriteRAM(uint16_t addr, uint8_t value)
@ -107,7 +112,7 @@ protected:
}
public:
HdBuilderPpu(shared_ptr<Console> console, HdPackBuilder* hdPackBuilder, uint32_t chrRamBankSize) : PPU(console)
HdBuilderPpu(shared_ptr<Console> console, HdPackBuilder* hdPackBuilder, uint32_t chrRamBankSize, shared_ptr<HdPackData> hdData) : HdPpu(console, hdData.get())
{
_hdPackBuilder = hdPackBuilder;
_chrRamBankSize = chrRamBankSize;
@ -117,6 +122,10 @@ public:
void SendFrame()
{
PPU::SendFrame();
if(_hdData) {
HdPpu::SendFrame();
} else {
PPU::SendFrame();
}
}
};

View file

@ -123,18 +123,23 @@ void HdPpu::DrawPixel()
HdPpu::HdPpu(shared_ptr<Console> console, HdPackData * hdData) : PPU(console)
{
_hdData = hdData;
_version = _hdData->Version;
bool isChrRamGame = !console->GetMapper()->HasChrRom();
_screenInfo[0] = new HdScreenInfo(isChrRamGame);
_screenInfo[1] = new HdScreenInfo(isChrRamGame);
_info = _screenInfo[0];
if(_hdData) {
_version = _hdData->Version;
bool isChrRamGame = !console->GetMapper()->HasChrRom();
_screenInfo[0] = new HdScreenInfo(isChrRamGame);
_screenInfo[1] = new HdScreenInfo(isChrRamGame);
_info = _screenInfo[0];
}
}
HdPpu::~HdPpu()
{
delete _screenInfo[0];
delete _screenInfo[1];
if(_hdData) {
delete _screenInfo[0];
delete _screenInfo[1];
}
}
void HdPpu::SendFrame()

View file

@ -13,14 +13,15 @@ private:
HdScreenInfo *_screenInfo[2];
HdScreenInfo *_info;
uint32_t _version;
HdPackData *_hdData = nullptr;
protected:
HdPackData *_hdData = nullptr;
void DrawPixel() override;
public:
HdPpu(shared_ptr<Console> console, HdPackData* hdData);
~HdPpu();
virtual ~HdPpu();
void SendFrame() override;
};