commit
e868235f46
|
@ -95,11 +95,8 @@ class NESInstanceBase
|
|||
|
||||
// Virtual functions
|
||||
|
||||
virtual uint8_t *getLowMem() const = 0;
|
||||
virtual uint8_t *getNametableMem() const = 0;
|
||||
virtual uint8_t *getHighMem() const = 0;
|
||||
virtual const uint8_t *getChrMem() const = 0;
|
||||
virtual size_t getChrMemSize() const = 0;
|
||||
virtual uint8_t *getLowMem() = 0;
|
||||
|
||||
virtual void serializeState(uint8_t *state) const = 0;
|
||||
virtual void deserializeState(const uint8_t *state) = 0;
|
||||
virtual size_t getStateSize() const = 0;
|
||||
|
@ -107,7 +104,7 @@ class NESInstanceBase
|
|||
virtual void doSoftReset() = 0;
|
||||
virtual void doHardReset() = 0;
|
||||
virtual std::string getCoreName() const = 0;
|
||||
virtual void *getInternalEmulatorPointer() const = 0;
|
||||
virtual void *getInternalEmulatorPointer() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -39,6 +39,12 @@ class PlaybackInstance
|
|||
// Initializes the playback module instance
|
||||
PlaybackInstance(NESInstance *emu, const std::vector<std::string> &sequence, const std::string &overlayPath = "") : _emu(emu)
|
||||
{
|
||||
// Allocating video buffer
|
||||
_video_buffer = (uint8_t *)malloc(image_width * image_height);
|
||||
|
||||
// Setting video buffer
|
||||
((emulator_t*)_emu->getInternalEmulatorPointer())->set_pixels(_video_buffer, image_width + 8);
|
||||
|
||||
// Enabling emulation rendering
|
||||
_emu->enableRendering();
|
||||
|
||||
|
@ -224,6 +230,7 @@ class PlaybackInstance
|
|||
}
|
||||
|
||||
private:
|
||||
|
||||
// Internal sequence information
|
||||
std::vector<stepData_t> _stepSequence;
|
||||
|
||||
|
@ -239,6 +246,9 @@ class PlaybackInstance
|
|||
// Flag to store whether to use the button overlay
|
||||
bool _useOverlay = false;
|
||||
|
||||
// Video buffer
|
||||
uint8_t *_video_buffer;
|
||||
|
||||
// Overlay info
|
||||
std::string _overlayPath;
|
||||
SDL_Surface *_overlayBaseSurface = NULL;
|
||||
|
|
|
@ -12,56 +12,31 @@ extern void register_misc_mappers();
|
|||
extern void register_extra_mappers();
|
||||
extern void register_mapper_70();
|
||||
|
||||
class NESInstance : public NESInstanceBase
|
||||
class NESInstance final : public NESInstanceBase
|
||||
{
|
||||
public:
|
||||
NESInstance() : NESInstanceBase()
|
||||
{
|
||||
// Creating new emulator
|
||||
_nes = new Nes_Emu;
|
||||
|
||||
// Allocating video buffer
|
||||
video_buffer = (uint8_t *)malloc(image_width * image_height);
|
||||
|
||||
// Setting video buffer
|
||||
_nes->set_pixels(video_buffer, image_width + 8);
|
||||
|
||||
// If running the original QuickNES, register extra mappers now
|
||||
register_misc_mappers();
|
||||
register_extra_mappers();
|
||||
register_mapper_70();
|
||||
}
|
||||
|
||||
virtual bool loadROMImpl(const uint8_t* romData, const size_t romSize) override
|
||||
{
|
||||
// Loading rom data
|
||||
Mem_File_Reader romReader(romData, (int)romSize);
|
||||
Auto_File_Reader romFile(romReader);
|
||||
auto result = _nes->load_ines(romFile);
|
||||
return result == 0;
|
||||
}
|
||||
|
||||
uint8_t *getLowMem() const override { return _nes->low_mem(); };
|
||||
uint8_t *getNametableMem() const override { return _nes->nametable_mem(); };
|
||||
uint8_t *getHighMem() const override { return _nes->high_mem(); };
|
||||
const uint8_t *getChrMem() const override { return _nes->chr_mem(); };
|
||||
size_t getChrMemSize() const override { return _nes->chr_size(); };
|
||||
|
||||
void enableStateBlockImpl(const std::string& block) override {};
|
||||
void disableStateBlockImpl(const std::string& block) override {};
|
||||
uint8_t *getLowMem() override { return _nes.low_mem(); };
|
||||
|
||||
void serializeState(uint8_t *state) const override
|
||||
{
|
||||
Mem_Writer w(state, _stateSize, 0);
|
||||
Auto_File_Writer a(w);
|
||||
_nes->save_state(a);
|
||||
_nes.save_state(a);
|
||||
}
|
||||
|
||||
void deserializeState(const uint8_t *state) override
|
||||
{
|
||||
Mem_File_Reader r(state, _stateSize);
|
||||
Auto_File_Reader a(r);
|
||||
_nes->load_state(a);
|
||||
_nes.load_state(a);
|
||||
}
|
||||
|
||||
inline size_t getStateSize() const override
|
||||
|
@ -69,28 +44,39 @@ class NESInstance : public NESInstanceBase
|
|||
uint8_t *data = (uint8_t *)malloc(_DUMMY_SIZE);
|
||||
Mem_Writer w(data, _DUMMY_SIZE);
|
||||
Auto_File_Writer a(w);
|
||||
_nes->save_state(a);
|
||||
_nes.save_state(a);
|
||||
free(data);
|
||||
return w.size();
|
||||
}
|
||||
|
||||
void advanceStateImpl(const Controller::port_t controller1, const Controller::port_t controller2) override
|
||||
std::string getCoreName() const override { return "QuickNES"; }
|
||||
void doSoftReset() override { _nes.reset(false); }
|
||||
void doHardReset() override { _nes.reset(true); }
|
||||
|
||||
void *getInternalEmulatorPointer() override { return &_nes; }
|
||||
|
||||
protected:
|
||||
|
||||
bool loadROMImpl(const uint8_t* romData, const size_t romSize) override
|
||||
{
|
||||
if (_doRendering == true) _nes->emulate_frame(controller1, controller2);
|
||||
if (_doRendering == false) _nes->emulate_skip_frame(controller1, controller2);
|
||||
// Loading rom data
|
||||
Mem_File_Reader romReader(romData, (int)romSize);
|
||||
Auto_File_Reader romFile(romReader);
|
||||
auto result = _nes.load_ines(romFile);
|
||||
return result == 0;
|
||||
}
|
||||
|
||||
std::string getCoreName() const override { return "QuickNES"; }
|
||||
void doSoftReset() override { _nes->reset(false); }
|
||||
void doHardReset() override { _nes->reset(true); }
|
||||
void enableStateBlockImpl(const std::string& block) override {};
|
||||
void disableStateBlockImpl(const std::string& block) override {};
|
||||
|
||||
void *getInternalEmulatorPointer() const override { return _nes; }
|
||||
void advanceStateImpl(const Controller::port_t controller1, const Controller::port_t controller2) override
|
||||
{
|
||||
if (_doRendering == true) _nes.emulate_frame(controller1, controller2);
|
||||
if (_doRendering == false) _nes.emulate_skip_frame(controller1, controller2);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// Video buffer
|
||||
uint8_t *video_buffer;
|
||||
|
||||
// Emulator instance
|
||||
Nes_Emu *_nes;
|
||||
emulator_t _nes;
|
||||
};
|
||||
|
|
|
@ -5,57 +5,42 @@
|
|||
|
||||
typedef quickerNES::Emu emulator_t;
|
||||
|
||||
class NESInstance : public NESInstanceBase
|
||||
class NESInstance final : public NESInstanceBase
|
||||
{
|
||||
public:
|
||||
NESInstance() : NESInstanceBase()
|
||||
{
|
||||
// Creating new emulator
|
||||
_nes = new emulator_t;
|
||||
|
||||
// Allocating video buffer
|
||||
video_buffer = (uint8_t *)malloc(image_width * image_height);
|
||||
uint8_t *getLowMem() override { return _nes.low_mem(); };
|
||||
|
||||
// Setting video buffer
|
||||
_nes->set_pixels(video_buffer, image_width + 8);
|
||||
}
|
||||
void serializeState(uint8_t *state) const override { _nes.serializeState(state); }
|
||||
void deserializeState(const uint8_t *state) override { _nes.deserializeState(state); }
|
||||
size_t getStateSize() const override { return _nes.getStateSize(); }
|
||||
|
||||
~NESInstance() = default;
|
||||
std::string getCoreName() const override { return "QuickerNES"; }
|
||||
|
||||
void doSoftReset() override { _nes.reset(false); }
|
||||
void doHardReset() override { _nes.reset(true); }
|
||||
|
||||
void *getInternalEmulatorPointer() override { return &_nes; }
|
||||
|
||||
protected:
|
||||
|
||||
virtual bool loadROMImpl(const uint8_t* romData, const size_t romSize) override
|
||||
bool loadROMImpl(const uint8_t* romData, const size_t romSize) override
|
||||
{
|
||||
// Loading rom data
|
||||
_nes->load_ines(romData);
|
||||
_nes.load_ines(romData);
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t *getLowMem() const override { return _nes->low_mem(); };
|
||||
uint8_t *getNametableMem() const override { return _nes->nametable_mem(); };
|
||||
uint8_t *getHighMem() const override { return _nes->high_mem(); };
|
||||
const uint8_t *getChrMem() const override { return _nes->chr_mem(); };
|
||||
size_t getChrMemSize() const override { return _nes->chr_size(); };
|
||||
|
||||
void serializeState(uint8_t *state) const override { _nes->serializeState(state); }
|
||||
void deserializeState(const uint8_t *state) override { _nes->deserializeState(state); }
|
||||
size_t getStateSize() const override { return _nes->getStateSize(); }
|
||||
void enableStateBlockImpl(const std::string& block) override { _nes->enableStateBlock(block); };
|
||||
void disableStateBlockImpl(const std::string& block) override { _nes->disableStateBlock(block); };
|
||||
|
||||
void enableStateBlockImpl(const std::string& block) override { _nes.enableStateBlock(block); };
|
||||
void disableStateBlockImpl(const std::string& block) override { _nes.disableStateBlock(block); };
|
||||
void advanceStateImpl(const Controller::port_t controller1, const Controller::port_t controller2) override
|
||||
{
|
||||
if (_doRendering == true) _nes->emulate_frame(controller1, controller2);
|
||||
if (_doRendering == false) _nes->emulate_skip_frame(controller1, controller2);
|
||||
if (_doRendering == true) _nes.emulate_frame(controller1, controller2);
|
||||
if (_doRendering == false) _nes.emulate_skip_frame(controller1, controller2);
|
||||
}
|
||||
|
||||
std::string getCoreName() const override { return "QuickerNES"; }
|
||||
void doSoftReset() override { _nes->reset(false); }
|
||||
void doHardReset() override { _nes->reset(true); }
|
||||
|
||||
void *getInternalEmulatorPointer() const override { return _nes; }
|
||||
|
||||
// Video buffer
|
||||
uint8_t *video_buffer;
|
||||
private:
|
||||
|
||||
// Emulator instance
|
||||
emulator_t *_nes;
|
||||
emulator_t _nes;
|
||||
};
|
||||
|
|
|
@ -167,7 +167,7 @@ inline hash_t calculateMetroHash(uint8_t *data, size_t size)
|
|||
return result;
|
||||
}
|
||||
|
||||
inline hash_t calculateStateHash(const NESInstance* nes)
|
||||
inline hash_t calculateStateHash(NESInstance* nes)
|
||||
{
|
||||
return calculateMetroHash(nes->getLowMem(), _LOW_MEM_SIZE);
|
||||
}
|
Loading…
Reference in New Issue