Skip to content

Commit

Permalink
Speed up readbyte()
Browse files Browse the repository at this point in the history
Check the address first and only test for the peripherals if the address
is in the relevant range.
  • Loading branch information
jmakovicka authored and fmeunier committed Mar 20, 2021
1 parent b0fff7d commit fe8398c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

* Fuse 1.?.? released.

* Emulation core improvements:
* Speed up reading emulated memory locations (Jindřich Makovička).

* UI improvements:
* Timex: don't abort if the Timex dock cartridge image is not
found (Alberto Garcia).
Expand Down
26 changes: 14 additions & 12 deletions memory_pages.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,19 +385,21 @@ readbyte( libspectrum_word address )
if( mapping->contended ) tstates += ula_contention[ tstates ];
tstates += 3;

if( opus_active && address >= 0x2800 && address < 0x3800 )
return opus_read( address );
if( address < 0x4000 ) {
if( opus_active && address >= 0x2800 && address < 0x3800 )
return opus_read( address );

if( spectranet_paged ) {
if( spectranet_w5100_paged_a && address >= 0x1000 && address < 0x2000 )
return spectranet_w5100_read( mapping, address );
if( spectranet_w5100_paged_b && address >= 0x2000 && address < 0x3000 )
return spectranet_w5100_read( mapping, address );
}

if( spectranet_paged ) {
if( spectranet_w5100_paged_a && address >= 0x1000 && address < 0x2000 )
return spectranet_w5100_read( mapping, address );
if( spectranet_w5100_paged_b && address >= 0x2000 && address < 0x3000 )
return spectranet_w5100_read( mapping, address );
}

if( ttx2000s_paged ) {
if( address >= 0x2000 && address < 0x4000 )
return ttx2000s_sram_read( address );
if( ttx2000s_paged ) {
if( address >= 0x2000 && address < 0x4000 )
return ttx2000s_sram_read( address );
}
}

return mapping->page[ address & MEMORY_PAGE_SIZE_MASK ];
Expand Down

0 comments on commit fe8398c

Please sign in to comment.