Adding doRendering flag to disable audio/picture rendering for performance
This commit is contained in:
parent
86ffc7fce7
commit
52bb0987e3
|
@ -38,6 +38,7 @@ Nes_Core::Nes_Core() : ppu( this )
|
||||||
mapper = NULL;
|
mapper = NULL;
|
||||||
memset( &nes, 0, sizeof nes );
|
memset( &nes, 0, sizeof nes );
|
||||||
memset( &joypad, 0, sizeof joypad );
|
memset( &joypad, 0, sizeof joypad );
|
||||||
|
_doRendering = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * Nes_Core::init()
|
const char * Nes_Core::init()
|
||||||
|
@ -510,14 +511,17 @@ nes_time_t Nes_Core::emulate_frame()
|
||||||
clock_ = cpu_time_offset;
|
clock_ = cpu_time_offset;
|
||||||
|
|
||||||
// TODO: clean this fucking mess up
|
// TODO: clean this fucking mess up
|
||||||
impl->apu.run_until_( emulate_frame_() );
|
auto t0 = emulate_frame_();
|
||||||
|
if (_doRendering == true) impl->apu.run_until_( t0 );
|
||||||
clock_ = cpu_time_offset;
|
clock_ = cpu_time_offset;
|
||||||
impl->apu.run_until_( cpu_time() );
|
auto t1 = cpu_time();
|
||||||
|
if (_doRendering == true) impl->apu.run_until_( t1 );
|
||||||
|
|
||||||
nes_time_t ppu_frame_length = ppu.frame_length();
|
nes_time_t ppu_frame_length = ppu.frame_length();
|
||||||
nes_time_t length = cpu_time();
|
nes_time_t length = cpu_time();
|
||||||
nes.timestamp = ppu.end_frame( length );
|
nes.timestamp = ppu.end_frame( length );
|
||||||
mapper->end_frame( length );
|
mapper->end_frame( length );
|
||||||
|
|
||||||
impl->apu.end_frame( ppu_frame_length );
|
impl->apu.end_frame( ppu_frame_length );
|
||||||
|
|
||||||
disable_rendering();
|
disable_rendering();
|
||||||
|
|
|
@ -20,6 +20,9 @@ public:
|
||||||
Nes_Core();
|
Nes_Core();
|
||||||
~Nes_Core();
|
~Nes_Core();
|
||||||
|
|
||||||
|
// Flag to enable/disable rendering
|
||||||
|
bool _doRendering;
|
||||||
|
|
||||||
const char * init();
|
const char * init();
|
||||||
const char * open( Nes_Cart const* );
|
const char * open( Nes_Cart const* );
|
||||||
void reset( bool full_reset = true, bool erase_battery_ram = false );
|
void reset( bool full_reset = true, bool erase_battery_ram = false );
|
||||||
|
|
|
@ -140,8 +140,11 @@ const char * Nes_Emu::emulate_frame( int joypad1, int joypad2 )
|
||||||
|
|
||||||
emu.ppu.host_pixels = NULL;
|
emu.ppu.host_pixels = NULL;
|
||||||
|
|
||||||
|
if (emu._doRendering == true)
|
||||||
|
{
|
||||||
unsigned changed_count = sound_buf->channels_changed_count();
|
unsigned changed_count = sound_buf->channels_changed_count();
|
||||||
bool new_enabled = (frame_ != NULL);
|
bool new_enabled = (frame_ != NULL);
|
||||||
|
|
||||||
if ( sound_buf_changed_count != changed_count || sound_enabled != new_enabled )
|
if ( sound_buf_changed_count != changed_count || sound_enabled != new_enabled )
|
||||||
{
|
{
|
||||||
sound_buf_changed_count = changed_count;
|
sound_buf_changed_count = changed_count;
|
||||||
|
@ -177,10 +180,13 @@ const char * Nes_Emu::emulate_frame( int joypad1, int joypad2 )
|
||||||
f->joypad_read_count = emu.joypad_read_count;
|
f->joypad_read_count = emu.joypad_read_count;
|
||||||
f->burst_phase = emu.ppu.burst_phase;
|
f->burst_phase = emu.ppu.burst_phase;
|
||||||
f->pitch = emu.ppu.host_row_bytes;
|
f->pitch = emu.ppu.host_row_bytes;
|
||||||
if (emu.ppu.host_pixels != NULL)
|
|
||||||
f->pixels = emu.ppu.host_pixels + f->left;
|
f->pixels = emu.ppu.host_pixels + f->left;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
f->pixels = NULL;
|
{
|
||||||
|
emu.ppu.max_palette_size = 0;
|
||||||
|
emu.emulate_frame();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,6 +42,9 @@ public:
|
||||||
|
|
||||||
const uint8_t* getHostPixels () const { return emu.ppu.host_pixels; }
|
const uint8_t* getHostPixels () const { return emu.ppu.host_pixels; }
|
||||||
|
|
||||||
|
void enableRendering() { emu._doRendering = true; }
|
||||||
|
void disableRendering() { emu._doRendering = false; }
|
||||||
|
|
||||||
// Basic emulation
|
// Basic emulation
|
||||||
|
|
||||||
// Emulate one video frame using joypad1 and joypad2 as input. Afterwards, image
|
// Emulate one video frame using joypad1 and joypad2 as input. Afterwards, image
|
||||||
|
|
|
@ -64,6 +64,7 @@ int main(int argc, char *argv[])
|
||||||
// Printing provided parameters
|
// Printing provided parameters
|
||||||
printw("[] Rom File Path: '%s'\n", romFilePath.c_str());
|
printw("[] Rom File Path: '%s'\n", romFilePath.c_str());
|
||||||
printw("[] Sequence File Path: '%s'\n", sequenceFilePath.c_str());
|
printw("[] Sequence File Path: '%s'\n", sequenceFilePath.c_str());
|
||||||
|
printw("[] Sequence Length: %lu\n", sequence.size());
|
||||||
printw("[] State File Path: '%s'\n", stateFilePath.empty() ? "<Boot Start>" : stateFilePath.c_str());
|
printw("[] State File Path: '%s'\n", stateFilePath.empty() ? "<Boot Start>" : stateFilePath.c_str());
|
||||||
printw("[] Generating Sequence...\n");
|
printw("[] Generating Sequence...\n");
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,11 @@ int main(int argc, char *argv[])
|
||||||
// Creating emulator instance
|
// Creating emulator instance
|
||||||
auto e = EmuInstance(romFilePath, initialStateFilePath);
|
auto e = EmuInstance(romFilePath, initialStateFilePath);
|
||||||
|
|
||||||
|
// Disable rendering
|
||||||
|
e.getInternalEmulator()->disableRendering();
|
||||||
|
|
||||||
|
// Getting initial hash
|
||||||
auto initialHash = e.getStateHash();
|
auto initialHash = e.getStateHash();
|
||||||
printf("[] Initial State Hash: 0x%lX%lX\n", initialHash.first, initialHash.second);
|
|
||||||
|
|
||||||
// Getting state size
|
// Getting state size
|
||||||
const auto stateSize = e.getStateSize();
|
const auto stateSize = e.getStateSize();
|
||||||
|
@ -98,6 +101,7 @@ int main(int argc, char *argv[])
|
||||||
printf("[] Verification State File: '%s'\n", verificationStateFilePath.c_str());
|
printf("[] Verification State File: '%s'\n", verificationStateFilePath.c_str());
|
||||||
printf("[] Sequence File: '%s'\n", sequenceFilePath.c_str());
|
printf("[] Sequence File: '%s'\n", sequenceFilePath.c_str());
|
||||||
printf("[] Sequence Length: %lu\n", sequenceLength);
|
printf("[] Sequence Length: %lu\n", sequenceLength);
|
||||||
|
printf("[] Initial State Hash: 0x%lX%lX\n", initialHash.first, initialHash.second);
|
||||||
printf("[] State Size: %lu bytes\n", stateSize);
|
printf("[] State Size: %lu bytes\n", stateSize);
|
||||||
printf("[] Running Test...\n");
|
printf("[] Running Test...\n");
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
nomalloc = environment({'MALLOC_PERTURB_': '0'})
|
nomalloc = environment({'MALLOC_PERTURB_': '0'})
|
||||||
|
|
||||||
|
subdir('arkanoid')
|
||||||
subdir('castlevania1')
|
subdir('castlevania1')
|
||||||
subdir('superOffroad')
|
subdir('superOffroad')
|
||||||
subdir('princeOfPersia')
|
subdir('princeOfPersia')
|
||||||
|
@ -8,3 +9,4 @@ subdir('ninjaGaiden2')
|
||||||
subdir('ironSword')
|
subdir('ironSword')
|
||||||
subdir('solarJetman')
|
subdir('solarJetman')
|
||||||
subdir('tennis')
|
subdir('tennis')
|
||||||
|
subdir('nigelMansell')
|
Loading…
Reference in New Issue