diff genesis.c @ 1444:14a2834d010c

Save/restore mapper state in native save states
author Michael Pavone <pavone@retrodev.com>
date Sun, 27 Aug 2017 18:15:00 -0700
parents 7d4483944d4d
children 349d50930c03
line wrap: on
line diff
--- a/genesis.c	Sat Aug 26 11:29:46 2017 -0700
+++ b/genesis.c	Sun Aug 27 18:15:00 2017 -0700
@@ -81,7 +81,7 @@
 	save_buffer8(buf, gen->zram, Z80_RAM_BYTES);
 	end_section(buf);
 	
-	//TODO: mapper state
+	cart_serialize(&gen->header, buf);
 }
 
 static void ram_deserialize(deserialize_buffer *buf, void *vgen)
@@ -124,6 +124,7 @@
 	register_section_handler(buf, (section_handler){.fun = io_deserialize, .data = gen->io.ports + 2}, SECTION_SEGA_IO_EXT);
 	register_section_handler(buf, (section_handler){.fun = ram_deserialize, .data = gen}, SECTION_MAIN_RAM);
 	register_section_handler(buf, (section_handler){.fun = zram_deserialize, .data = gen}, SECTION_SOUND_RAM);
+	register_section_handler(buf, (section_handler){.fun = cart_deserialize, .data = gen}, SECTION_MAPPER);
 	//TODO: mapper state
 	while (buf->cur_pos < buf->size)
 	{
@@ -1267,7 +1268,7 @@
 	}
 	setup_io_devices(config, rom, &gen->io);
 
-	gen->save_type = rom->save_type;
+	gen->mapper_type = rom->mapper_type;
 	gen->save_type = rom->save_type;
 	if (gen->save_type != SAVE_NONE) {
 		gen->save_ram_mask = rom->save_mask;