diff sms.c @ 2321:2eda5f81f91e

More fully baked ROM db support for SMS
author Michael Pavone <pavone@retrodev.com>
date Thu, 15 Jun 2023 09:36:11 -0700
parents 8016dbb0fcde
children 26597f9805b4
line wrap: on
line diff
--- a/sms.c	Tue May 09 09:03:37 2023 -0700
+++ b/sms.c	Thu Jun 15 09:36:11 2023 -0700
@@ -165,7 +165,7 @@
 	return vcontext;
 }
 
-static void *cart_ram_write(uint32_t location, void *vcontext, uint8_t value)
+void *sms_cart_ram_write(uint32_t location, void *vcontext, uint8_t value)
 {
 	z80_context *z80 = vcontext;
 	sms_context *sms = z80->system;
@@ -712,6 +712,13 @@
 			warning("Unrecognized VDP type %s\n", vdp_str);
 		}
 	}
+	for (uint32_t i = 0; i < sms->header.info.map_chunks; i++)
+	{
+		memmap_chunk *chunk = sms->header.info.map + i;
+		if ((chunk->flags == MMAP_READ) && !chunk->buffer && chunk->start > 0xC000) {
+			chunk->buffer = sms->ram + ((chunk->start - 0xC000) & 0x1FFF);
+		}
+	}
 	if (is_gamegear) {
 		init_z80_opts(zopts, sms->header.info.map, sms->header.info.map_chunks, io_gg, 6, 15, 0xFF);
 		sms->start_button_region = 0xC0;