From: <sba...@us...> - 2023-07-19 17:45:10
|
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 libspectrum. View the commit online: https://sourceforge.net/p/fuse-emulator/libspectrum/ci/88532dba809ca33611b726f854587f917cac6604/ commit 88532dba809ca33611b726f854587f917cac6604 Author: Vic Chwe <ch...@us...> AuthorDate: Wed Jul 19 19:04:49 2023 +0200 Enable SZX support for Currah uSpeech --- snap_accessors.txt | 4 ++++ szx.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/snap_accessors.txt b/snap_accessors.txt index fb1d2a0..5d0cf78 100644 --- a/snap_accessors.txt +++ b/snap_accessors.txt @@ -241,6 +241,10 @@ int usource_custom_rom libspectrum_byte* usource_rom 1 size_t usource_rom_length 1 /* Length of the ROM */ +/* uSpeech emulation */ +int uspeech_active +int uspeech_paged + /* DISCiPLE emulation */ int disciple_active int disciple_paged diff --git a/szx.c b/szx.c index 5889de8..761801d 100644 --- a/szx.c +++ b/szx.c @@ -338,6 +338,9 @@ write_mfce_chunk( libspectrum_buffer *buffer, libspectrum_buffer *data, static void write_zmmc_chunk( libspectrum_buffer *buffer, libspectrum_buffer *data, libspectrum_snap *snap ); +static void +write_uspeech_chunk( libspectrum_buffer *buffer, libspectrum_buffer *data, + libspectrum_snap *snap ); #ifdef HAVE_ZLIB_H @@ -2443,6 +2446,30 @@ read_zmmc_chunk( libspectrum_snap *snap, libspectrum_word version GCC_UNUSED, return LIBSPECTRUM_ERROR_NONE; } +static libspectrum_error +read_uspeech_chunk( libspectrum_snap *snap, libspectrum_word version GCC_UNUSED, + const libspectrum_byte **buffer, + const libspectrum_byte *end GCC_UNUSED, size_t data_length, + szx_context *ctx GCC_UNUSED ) +{ + libspectrum_byte paged; + + if( data_length != 1 ) { + libspectrum_print_error( LIBSPECTRUM_ERROR_UNKNOWN, + "%s:read_uspeech_chunk: unknown length %lu", + __FILE__, (unsigned long)data_length ); + return LIBSPECTRUM_ERROR_UNKNOWN; + } + + paged = *(*buffer)++; + + libspectrum_snap_set_uspeech_paged( snap, paged ); + + libspectrum_snap_set_uspeech_active( snap, 1 ); + + return LIBSPECTRUM_ERROR_NONE; +} + static libspectrum_error skip_chunk( libspectrum_snap *snap GCC_UNUSED, libspectrum_word version GCC_UNUSED, @@ -2501,7 +2528,7 @@ static struct read_chunk_t read_chunks[] = { { ZXSTBID_SPECTRANETFLASHPAGE, read_snef_chunk }, { ZXSTBID_SPECTRANETRAMPAGE, read_sner_chunk }, { ZXSTBID_TIMEXREGS, read_scld_chunk }, - { ZXSTBID_USPEECH, skip_chunk }, + { ZXSTBID_USPEECH, read_uspeech_chunk }, { ZXSTBID_Z80REGS, read_z80r_chunk }, { ZXSTBID_ZXATASPRAMPAGE, read_atrp_chunk }, { ZXSTBID_ZXATASP, read_zxat_chunk }, @@ -2920,6 +2947,10 @@ libspectrum_szx_write( libspectrum_buffer *buffer, int *out_flags, write_zmmc_chunk( buffer, block_data, snap ); } + if( libspectrum_snap_uspeech_active( snap ) ) { + write_uspeech_chunk( buffer, block_data, snap ); + } + libspectrum_buffer_free( block_data ); return LIBSPECTRUM_ERROR_NONE; @@ -4157,6 +4188,16 @@ write_zmmc_chunk( libspectrum_buffer *buffer, libspectrum_buffer *data, write_chunk( buffer, ZXSTBID_ZXMMC, NULL ); } +static void +write_uspeech_chunk( libspectrum_buffer *buffer, libspectrum_buffer *data, + libspectrum_snap *snap ) +{ + libspectrum_buffer_write_byte( data, + libspectrum_snap_uspeech_paged( snap ) ); + + write_chunk( buffer, ZXSTBID_USPEECH, data ); +} + static void write_chunk( libspectrum_buffer *buffer, const char *id, libspectrum_buffer *block_data ) |