comparison vdp.c @ 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 2540c05520f2
children 5e7e6d9b79ff
comparison
equal deleted inserted replaced
1430:747c779fc137 1431:030b40139de9
772 #define VSRAM_DIRTY_BITS 0xF800 772 #define VSRAM_DIRTY_BITS 0xF800
773 773
774 //rough estimate of slot number at which border display starts 774 //rough estimate of slot number at which border display starts
775 #define BG_START_SLOT 6 775 #define BG_START_SLOT 6
776 776
777 static void update_color_map(vdp_context *context, uint16_t index, uint16_t value)
778 {
779 context->colors[index] = color_map[value & CRAM_BITS];
780 context->colors[index + CRAM_SIZE] = color_map[(value & CRAM_BITS) | FBUF_SHADOW];
781 context->colors[index + CRAM_SIZE*2] = color_map[(value & CRAM_BITS) | FBUF_HILIGHT];
782 context->colors[index + CRAM_SIZE*3] = color_map[(value & CRAM_BITS) | FBUF_MODE4];
783 }
784
777 void write_cram_internal(vdp_context * context, uint16_t addr, uint16_t value) 785 void write_cram_internal(vdp_context * context, uint16_t addr, uint16_t value)
778 { 786 {
779 context->cram[addr] = value; 787 context->cram[addr] = value;
780 context->colors[addr] = color_map[value & CRAM_BITS]; 788 update_color_map(context, addr, value);
781 context->colors[addr + CRAM_SIZE] = color_map[(value & CRAM_BITS) | FBUF_SHADOW];
782 context->colors[addr + CRAM_SIZE*2] = color_map[(value & CRAM_BITS) | FBUF_HILIGHT];
783 context->colors[addr + CRAM_SIZE*3] = color_map[(value & CRAM_BITS) | FBUF_MODE4];
784 } 789 }
785 790
786 static void write_cram(vdp_context * context, uint16_t address, uint16_t value) 791 static void write_cram(vdp_context * context, uint16_t address, uint16_t value)
787 { 792 {
788 uint16_t addr; 793 uint16_t addr;
3615 load_buffer8(buf, context->vdpmem, (vramk * 1024) <= VRAM_SIZE ? vramk * 1024 : VRAM_SIZE); 3620 load_buffer8(buf, context->vdpmem, (vramk * 1024) <= VRAM_SIZE ? vramk * 1024 : VRAM_SIZE);
3616 if ((vramk * 1024) > VRAM_SIZE) { 3621 if ((vramk * 1024) > VRAM_SIZE) {
3617 buf->cur_pos += (vramk * 1024) - VRAM_SIZE; 3622 buf->cur_pos += (vramk * 1024) - VRAM_SIZE;
3618 } 3623 }
3619 load_buffer16(buf, context->cram, CRAM_SIZE); 3624 load_buffer16(buf, context->cram, CRAM_SIZE);
3625 for (int i = 0; i < CRAM_SIZE; i++)
3626 {
3627 update_color_map(context, i, context->cram[i]);
3628 }
3620 load_buffer16(buf, context->vsram, VSRAM_SIZE); 3629 load_buffer16(buf, context->vsram, VSRAM_SIZE);
3621 load_buffer8(buf, context->sat_cache, SAT_CACHE_SIZE); 3630 load_buffer8(buf, context->sat_cache, SAT_CACHE_SIZE);
3622 for (int i = 0; i <= REG_DMASRC_H; i++) 3631 for (int i = 0; i <= REG_DMASRC_H; i++)
3623 { 3632 {
3624 context->regs[i] = load_int8(buf); 3633 context->regs[i] = load_int8(buf);