static void divide_from_snapshot( libspectrum_snap *snap ) { size_t i; if( !libspectrum_snap_divide_active( snap ) ) return; settings_current.divide_wp = libspectrum_snap_divide_eprom_writeprotect( snap ); divide_control_write_internal( libspectrum_snap_divide_control( snap ) ); if( libspectrum_snap_divide_eprom( snap, 0 ) ) { memcpy( divide_eprom, libspectrum_snap_divide_eprom( snap, 0 ), DIVIDE_PAGE_LENGTH ); } for( i = 0; i < libspectrum_snap_divide_pages( snap ); i++ ) if( libspectrum_snap_divide_ram( snap, i ) ) memcpy( divide_ram[ i ], libspectrum_snap_divide_ram( snap, i ), DIVIDE_PAGE_LENGTH ); if( libspectrum_snap_divide_paged( snap ) ) { divide_page(); } else { divide_unpage(); } }
static void divide_enabled_snapshot( libspectrum_snap *snap ) { if( libspectrum_snap_divide_active( snap ) ) settings_current.divide_enabled = 1; }
libspectrum_error libspectrum_sna_write( libspectrum_byte **buffer, size_t *length, int *out_flags, libspectrum_snap *snap, int in_flags GCC_UNUSED ) { libspectrum_error error = LIBSPECTRUM_ERROR_NONE; libspectrum_byte *ptr; /* Minor info loss already due to things like tstate count, halted state, etc which are not stored in .sna format */ *out_flags = LIBSPECTRUM_FLAG_SNAPSHOT_MINOR_INFO_LOSS; /* We don't store +D info at all */ if( libspectrum_snap_plusd_active( snap ) ) *out_flags |= LIBSPECTRUM_FLAG_SNAPSHOT_MAJOR_INFO_LOSS; /* We don't store Beta info at all */ if( libspectrum_snap_beta_active( snap ) ) *out_flags |= LIBSPECTRUM_FLAG_SNAPSHOT_MAJOR_INFO_LOSS; /* We don't store Opus info at all */ if( libspectrum_snap_opus_active( snap ) ) *out_flags |= LIBSPECTRUM_FLAG_SNAPSHOT_MAJOR_INFO_LOSS; /* We don't save IDE interface info at all */ if( libspectrum_snap_zxatasp_active( snap ) ) *out_flags |= LIBSPECTRUM_FLAG_SNAPSHOT_MAJOR_INFO_LOSS; if( libspectrum_snap_zxcf_active( snap ) ) *out_flags |= LIBSPECTRUM_FLAG_SNAPSHOT_MAJOR_INFO_LOSS; if( libspectrum_snap_simpleide_active( snap ) ) *out_flags |= LIBSPECTRUM_FLAG_SNAPSHOT_MAJOR_INFO_LOSS; if( libspectrum_snap_divide_active( snap ) ) *out_flags |= LIBSPECTRUM_FLAG_SNAPSHOT_MAJOR_INFO_LOSS; /* We don't save the Interface 2 ROM at all */ if( libspectrum_snap_interface2_active( snap ) ) *out_flags |= LIBSPECTRUM_FLAG_SNAPSHOT_MAJOR_INFO_LOSS; /* We don't save the Timex Dock at all */ if( libspectrum_snap_dock_active( snap ) ) *out_flags |= LIBSPECTRUM_FLAG_SNAPSHOT_MAJOR_INFO_LOSS; /* We don't save custom ROMs at all */ if( libspectrum_snap_custom_rom( snap ) ) *out_flags |= LIBSPECTRUM_FLAG_SNAPSHOT_MAJOR_INFO_LOSS; /* We don't save AY interfaces at all */ if( libspectrum_snap_fuller_box_active( snap ) || libspectrum_snap_melodik_active( snap ) ) *out_flags |= LIBSPECTRUM_FLAG_SNAPSHOT_MAJOR_INFO_LOSS; /* We don't save the Specdrum state at all */ if( libspectrum_snap_specdrum_active( snap ) ) *out_flags |= LIBSPECTRUM_FLAG_SNAPSHOT_MAJOR_INFO_LOSS; /* We don't save the Spectranet state at all */ if( libspectrum_snap_spectranet_active( snap ) ) *out_flags |= LIBSPECTRUM_FLAG_SNAPSHOT_MAJOR_INFO_LOSS; /* We don't save the uSource state at all */ if( libspectrum_snap_usource_active( snap ) ) *out_flags |= LIBSPECTRUM_FLAG_SNAPSHOT_MAJOR_INFO_LOSS; /* We don't save the DISCiPLE state at all */ if( libspectrum_snap_disciple_active( snap ) ) *out_flags |= LIBSPECTRUM_FLAG_SNAPSHOT_MAJOR_INFO_LOSS; /* We don't save the Didaktik80 state at all */ if( libspectrum_snap_didaktik80_active( snap ) ) *out_flags |= LIBSPECTRUM_FLAG_SNAPSHOT_MAJOR_INFO_LOSS; ptr = *buffer; write_header( buffer, &ptr, length, snap ); switch( libspectrum_snap_machine( snap ) ) { case LIBSPECTRUM_MACHINE_48_NTSC: case LIBSPECTRUM_MACHINE_TC2048: case LIBSPECTRUM_MACHINE_TC2068: case LIBSPECTRUM_MACHINE_TS2068: *out_flags |= LIBSPECTRUM_FLAG_SNAPSHOT_MAJOR_INFO_LOSS; /* Fall through */ case LIBSPECTRUM_MACHINE_16: case LIBSPECTRUM_MACHINE_48: error = write_48k_sna( buffer, &ptr, length, snap ); break; case LIBSPECTRUM_MACHINE_128: case LIBSPECTRUM_MACHINE_128E: case LIBSPECTRUM_MACHINE_PENT512: case LIBSPECTRUM_MACHINE_PENT1024: case LIBSPECTRUM_MACHINE_PLUS2: case LIBSPECTRUM_MACHINE_PLUS2A: case LIBSPECTRUM_MACHINE_PLUS3: case LIBSPECTRUM_MACHINE_PLUS3E: case LIBSPECTRUM_MACHINE_SCORP: case LIBSPECTRUM_MACHINE_SE: *out_flags |= LIBSPECTRUM_FLAG_SNAPSHOT_MAJOR_INFO_LOSS; /* Fall through */ case LIBSPECTRUM_MACHINE_PENT: error = write_128k_sna( buffer, &ptr, length, snap ); break; case LIBSPECTRUM_MACHINE_UNKNOWN: libspectrum_print_error( LIBSPECTRUM_ERROR_LOGIC, "Emulated machine type is set to 'unknown'!" ); return LIBSPECTRUM_ERROR_LOGIC; } if( error ) return error; /* Set length to be actual length, not allocated length */ *length = ptr - *buffer; return LIBSPECTRUM_ERROR_NONE; }