Fixed player and some optimizations in the cpu

This commit is contained in:
Sergio Martin 2024-01-15 22:19:29 +01:00
parent a254482102
commit 4740e7d7cf
4 changed files with 14 additions and 12 deletions

View File

@ -87,6 +87,12 @@ int main(int argc, char *argv[])
auto e = QuickerNESInstance(); auto e = QuickerNESInstance();
#endif #endif
// Loading ROM File
e.loadROMFile(romFilePath);
// If an initial state is provided, load it now
if (stateFilePath != "") e.loadStateFile(stateFilePath);
// Creating playback instance // Creating playback instance
auto p = PlaybackInstance(&e, sequence); auto p = PlaybackInstance(&e, sequence);

View File

@ -123,10 +123,6 @@ imm##op: \
goto loop; \ goto loop; \
} }
inline void Nes_Cpu::set_code_page( int i, uint8_t const* p )
{
code_map [i] = p - (unsigned) i * page_size;
}
void Nes_Cpu::reset( void const* unmapped_page ) void Nes_Cpu::reset( void const* unmapped_page )
{ {
@ -143,12 +139,12 @@ void Nes_Cpu::reset( void const* unmapped_page )
irq_time_ = LONG_MAX / 2 + 1; irq_time_ = LONG_MAX / 2 + 1;
end_time_ = LONG_MAX / 2 + 1; end_time_ = LONG_MAX / 2 + 1;
set_code_page( 0, low_mem ); code_map [0] = low_mem;
set_code_page( 1, low_mem ); code_map [1] = low_mem - 1 * page_size;
set_code_page( 2, low_mem ); code_map [2] = low_mem - 2 * page_size;
set_code_page( 3, low_mem ); code_map [3] = low_mem - 3 * page_size;
for ( int i = 4; i < page_count + 1; i++ ) for ( int i = 4; i < page_count + 1; i++ )
set_code_page( i, (uint8_t*) unmapped_page ); code_map [i] = (uint8_t*) unmapped_page;
isCorrectExecution = true; isCorrectExecution = true;
} }
@ -156,8 +152,8 @@ void Nes_Cpu::reset( void const* unmapped_page )
void Nes_Cpu::map_code( nes_addr_t start, unsigned size, const void* data ) void Nes_Cpu::map_code( nes_addr_t start, unsigned size, const void* data )
{ {
unsigned first_page = start / page_size; unsigned first_page = start / page_size;
for ( unsigned i = size / page_size; i--; ) const uint8_t* newPtr = (uint8_t*) data - start;
set_code_page( first_page + i, (uint8_t*) data + i * page_size ); for ( unsigned i = size / page_size; i--; ) code_map [first_page + i] = newPtr;
} }
// Note: 'addr' is evaulated more than once in the following macros, so it // Note: 'addr' is evaulated more than once in the following macros, so it

View File

@ -73,7 +73,6 @@ public:
unsigned long error_count_; unsigned long error_count_;
enum { irq_inhibit = 0x04 }; enum { irq_inhibit = 0x04 };
void set_code_page( int, uint8_t const* );
void update_clock_limit(); void update_clock_limit();
registers_t r; registers_t r;

1
tests/.gitignore vendored
View File

@ -2,4 +2,5 @@
*.Identifier *.Identifier
*.zip *.zip
*.fds *.fds
test.sol