19 #ifdef XEMU_SNAPSHOT_SUPPORT
40 #define M65_MEMORY_BLOCK_VERSION 1
48 static int snapcallback_memory_loader (
const struct xemu_snapshot_definition_st *def,
struct xemu_snapshot_block_st *
block )
50 const struct memblock_st *mem = (
const struct memblock_st *)def->user_data;
51 if (
block->block_version != M65_MEMORY_BLOCK_VERSION ||
block->sub_counter != 0 ||
block->sub_size > mem->size)
52 RETURN_XSNAPERR_USER(
"Bad memory block syntax @ %s", def->idstr);
53 memset(mem->data, 0xFF, mem->size);
54 return xemusnap_read_file(mem->data,
block->sub_size);
58 static int snapcallback_memory_saver (
const struct xemu_snapshot_definition_st *def )
60 const struct memblock_st *mem = (
const struct memblock_st *)def->user_data;
61 int ret = xemusnap_write_block_header(def->idstr, M65_MEMORY_BLOCK_VERSION);
64 while (ret && mem->data[ret] == 0xFF)
66 return xemusnap_write_sub_block(mem->data, ret + 1);
70 #define DEFINE_SNAPSHOT_MEMORY_BLOCK(name, structure) { "MemoryRegion:" name, (void*)&structure, snapcallback_memory_loader, snapcallback_memory_saver }
73 static const struct memblock_st memblock_main_ram = {
main_ram,
sizeof main_ram };
75 static const struct memblock_st memblock_char_wom = {
char_wom,
sizeof char_wom };
76 static const struct memblock_st memblock_hypervisor = {
hypervisor_ram, 0x4000 };
78 const struct xemu_snapshot_definition_st m65_snapshot_definition[] = {
79 {
"CPU", NULL, cpu65_snapshot_load_state, cpu65_snapshot_save_state },
80 {
"CIA#1", &cia1, cia_snapshot_load_state, cia_snapshot_save_state },
81 {
"CIA#2", &
cia2, cia_snapshot_load_state, cia_snapshot_save_state },
82 {
"VIC-4", NULL, vic4_snapshot_load_state, vic4_snapshot_save_state },
83 {
"M65", NULL, m65emu_snapshot_load_state, m65emu_snapshot_save_state },
84 {
"SID#1", &
sid[0], sid_snapshot_load_state, sid_snapshot_save_state },
85 {
"SID#2", &
sid[1], sid_snapshot_load_state, sid_snapshot_save_state },
86 {
"SID#3", &
sid[3], sid_snapshot_load_state, sid_snapshot_save_state },
87 {
"SID#4", &
sid[4], sid_snapshot_load_state, sid_snapshot_save_state },
88 {
"DMAgic", NULL, dma_snapshot_load_state, dma_snapshot_save_state },
89 {
"SDcard", NULL, sdcard_snapshot_load_state, sdcard_snapshot_save_state },
90 {
"FDC-F011", NULL, fdc_snapshot_load_state, fdc_snapshot_save_state },
91 DEFINE_SNAPSHOT_MEMORY_BLOCK(
"RAM:Main", memblock_main_ram),
92 DEFINE_SNAPSHOT_MEMORY_BLOCK(
"RAM:Colour", memblock_colour_ram),
93 DEFINE_SNAPSHOT_MEMORY_BLOCK(
"WOM:Char", memblock_char_wom),
94 DEFINE_SNAPSHOT_MEMORY_BLOCK(
"RAM:Hyppo", memblock_hypervisor),
95 { NULL, NULL, m65emu_snapshot_loading_finalize, NULL }