changeset 1431:030b40139de9

Update VDP color map when loading a native save state
author Michael Pavone <pavone@retrodev.com>
date Fri, 11 Aug 2017 18:58:03 -0700
parents 747c779fc137
children 5e7e6d9b79ff
files vdp.c
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/vdp.c	Fri Aug 11 18:43:48 2017 -0700
+++ b/vdp.c	Fri Aug 11 18:58:03 2017 -0700
@@ -774,13 +774,18 @@
 //rough estimate of slot number at which border display starts
 #define BG_START_SLOT 6
 
+static void update_color_map(vdp_context *context, uint16_t index, uint16_t value)
+{
+	context->colors[index] = color_map[value & CRAM_BITS];
+	context->colors[index + CRAM_SIZE] = color_map[(value & CRAM_BITS) | FBUF_SHADOW];
+	context->colors[index + CRAM_SIZE*2] = color_map[(value & CRAM_BITS) | FBUF_HILIGHT];
+	context->colors[index + CRAM_SIZE*3] = color_map[(value & CRAM_BITS) | FBUF_MODE4];
+}
+
 void write_cram_internal(vdp_context * context, uint16_t addr, uint16_t value)
 {
 	context->cram[addr] = value;
-	context->colors[addr] = color_map[value & CRAM_BITS];
-	context->colors[addr + CRAM_SIZE] = color_map[(value & CRAM_BITS) | FBUF_SHADOW];
-	context->colors[addr + CRAM_SIZE*2] = color_map[(value & CRAM_BITS) | FBUF_HILIGHT];
-	context->colors[addr + CRAM_SIZE*3] = color_map[(value & CRAM_BITS) | FBUF_MODE4];
+	update_color_map(context, addr, value);
 }
 
 static void write_cram(vdp_context * context, uint16_t address, uint16_t value)
@@ -3617,6 +3622,10 @@
 		buf->cur_pos += (vramk * 1024) - VRAM_SIZE;
 	}
 	load_buffer16(buf, context->cram, CRAM_SIZE);
+	for (int i = 0; i < CRAM_SIZE; i++)
+	{
+		update_color_map(context, i, context->cram[i]);
+	}
 	load_buffer16(buf, context->vsram, VSRAM_SIZE);
 	load_buffer8(buf, context->sat_cache, SAT_CACHE_SIZE);
 	for (int i = 0; i <= REG_DMASRC_H; i++)