From: <sba...@us...> - 2023-08-05 22:39:16
|
This is an automated email from the git hooks/post-receive-user script. sbaldovi pushed a commit to branch patches-142-currah-uspeech in repository fuse. View the commit online: https://sourceforge.net/p/fuse-emulator/fuse/ci/2324c3dd2a251fd6d07cf5cae226e4840357d67d/ The following commit(s) were added to refs/heads/patches-142-currah-uspeech by this push: new 2324c3dd Add memory address mirroring and more I/O ports to uSpeech 2324c3dd is described below commit 2324c3dd2a251fd6d07cf5cae226e4840357d67d Author: Sergio Baldoví <ser...@gm...> AuthorDate: Sun Aug 6 00:34:22 2023 +0200 Add memory address mirroring and more I/O ports to uSpeech According to Thomas Busse tests, some memory addresses are mirrored when reading (0x1000) or writing to (0x1000, 0x3000 and 0x3001). Also adds input port on 0x1000 and output ports on 0x1000, 0x3000 and 0x3001, as /MREQ is not decoded. --- memory_pages.c | 28 +++++++++++++++------ peripherals/sound/uspeech.c | 59 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 7 deletions(-) diff --git a/memory_pages.c b/memory_pages.c index e1e638aa..5c3f07ab 100644 --- a/memory_pages.c +++ b/memory_pages.c @@ -409,7 +409,7 @@ readbyte( libspectrum_word address ) if( uspeech_available ) { if( address == 0x0038 ) uspeech_toggle(); /* and return whatever is the "normal" value later */ - else if( uspeech_active && ( address == 0x1000 ) ) + else if( uspeech_active && ( address & 0xf000 ) == 0x1000 ) return uspeech_busy(); } } @@ -515,9 +515,12 @@ writebyte_internal( libspectrum_word address, libspectrum_byte b ) if( opus_active && address >= 0x2800 && address < 0x3800 ) { opus_write( address, b ); - } else if( mapping->writable || - (mapping->source != memory_source_none && - settings_current.writable_roms) ) { + return; + } + + if( mapping->writable || + ( mapping->source != memory_source_none && + settings_current.writable_roms ) ) { libspectrum_word offset = address & MEMORY_PAGE_SIZE_MASK; libspectrum_byte *memory = mapping->page; @@ -525,11 +528,22 @@ writebyte_internal( libspectrum_word address, libspectrum_byte b ) memory[ offset ] = b; } else if( uspeech_available ) { + /* TODO: check if we can move this check above memory writes. + uSpeech is not compatible with +2A/+3 all RAM modes */ + if( uspeech_active ) { + if( ( address & 0xf000 ) == 0x1000 ) { + uspeech_write( address & 0xf000, b ); + return; + } + + if( ( address & 0xf000 ) == 0x3000 ) { + uspeech_write( address & 0xf001, b ); + return; + } + } + if( address == 0x0038 ) uspeech_toggle(); - else if( uspeech_active && ( address == 0x1000 || ( address & 0xfffe ) == 0x3000 ) ) { - uspeech_write( address, b ); - } } } diff --git a/peripherals/sound/uspeech.c b/peripherals/sound/uspeech.c index bab48b72..5ba725d5 100644 --- a/peripherals/sound/uspeech.c +++ b/peripherals/sound/uspeech.c @@ -59,6 +59,14 @@ static void uspeech_toggle_write( libspectrum_word port, libspectrum_byte val ); static libspectrum_byte uspeech_toggle_read( libspectrum_word port, libspectrum_byte *attached ); +static libspectrum_byte uspeech_port_play_read( libspectrum_word port, + libspectrum_byte *attached ); +static void uspeech_port_play_write( libspectrum_word port, + libspectrum_byte data ); +static void uspeech_port_intonation_normal( libspectrum_word port, + libspectrum_byte data ); +static void uspeech_port_intonation_high( libspectrum_word port, + libspectrum_byte data ); static void uspeech_reset( int hard_reset ); static void uspeech_memory_map( void ); @@ -81,6 +89,9 @@ static const periph_port_t uspeech_ports[] = { /* Really?! This conflicts with the ULA! */ /* ---- ---- 0111 1000 */ { 0xffff, 0x0038, uspeech_toggle_read, uspeech_toggle_write }, + { 0xffff, 0x1000, uspeech_port_play_read, uspeech_port_play_write }, + { 0xffff, 0x3000, NULL, uspeech_port_intonation_normal }, + { 0xffff, 0x3001, NULL, uspeech_port_intonation_high }, { 0, 0, NULL, NULL } }; @@ -92,6 +103,44 @@ static const periph_t uspeech_periph = { /* .activate = */ NULL }; +static libspectrum_byte +uspeech_port_play_read( libspectrum_word port, libspectrum_byte *attached ) +{ + if( !uspeech_active ) return 0xff; + + /* TODO: check if this value should be set to 0xff */ + *attached = 0xff; + + return sp0256_busy(); +} + +static void +uspeech_port_play_write( libspectrum_word port, libspectrum_byte data ) +{ + if( !uspeech_active ) return; + + /* Address 0x1000 can also be accessed via I/O (read and write) */ + sp0256_play( data & 0x3f ); +} + +static void +uspeech_port_intonation_normal( libspectrum_word port, libspectrum_byte data ) +{ + if( !uspeech_active ) return; + + /* Address 0x3000 can also be accessed via I/O (only write) */ + sp0256_set_intonation( 0 ); +} + +static void +uspeech_port_intonation_high( libspectrum_word port, libspectrum_byte data ) +{ + if( !uspeech_active ) return; + + /* Address 0x3001 can also be accessed via I/O (only write) */ + sp0256_set_intonation( 1 ); +} + static void ensure_empty_mapping( void ) { @@ -286,12 +335,15 @@ uspeech_write( libspectrum_word address, libspectrum_byte b ) { switch( address ) { case 0x1000: + /* This address is mirrored at 0011XXXX XXXXXXXX */ sp0256_play( b & 0x3f ); break; case 0x3000: + /* This address is mirrored at 0011XXXX XXXXXXX0 */ sp0256_set_intonation( 0 ); break; case 0x3001: + /* This address is mirrored at 0011XXXX XXXXXXX1 */ sp0256_set_intonation( 1 ); break; } @@ -300,6 +352,13 @@ uspeech_write( libspectrum_word address, libspectrum_byte b ) libspectrum_byte uspeech_busy( void ) { + /* Thomas Busse tests claims: + - The bits are not floating, there seems to be some deterministic behaviour. + - Bits 0, 1 and 5 contain different values. + - Bits 2, 3 and 4 might be equal and bit 6 and 7 might be equal. + We only return/known bit 0 (busy), though. + */ + return sp0256_busy(); } |