Mercurial > repos > blastem
comparison vdp.c @ 1929:c7e3e3ebb64a
Fix regression in Konami games from address/cd latch changes
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 17 Apr 2020 22:20:08 -0700 |
parents | abc89555f2e0 |
children | c3c62dbf1ceb |
comparison
equal
deleted
inserted
replaced
1928:abc89555f2e0 | 1929:c7e3e3ebb64a |
---|---|
3693 | 3693 |
3694 static void clear_pending(vdp_context *context) | 3694 static void clear_pending(vdp_context *context) |
3695 { | 3695 { |
3696 context->flags &= ~FLAG_PENDING; | 3696 context->flags &= ~FLAG_PENDING; |
3697 context->address = context->address_latch; | 3697 context->address = context->address_latch; |
3698 context->cd = context->cd_latch; | 3698 //It seems like the DMA enable bit doesn't so much enable DMA so much |
3699 //as it enables changing CD5 from control port writes | |
3700 if (context->regs[REG_MODE_2] & BIT_DMA_ENABLE) { | |
3701 context->cd = context->cd_latch; | |
3702 } else { | |
3703 context->cd = (context->cd & 0x20) | (context->cd_latch & 0x1F); | |
3704 } | |
3699 } | 3705 } |
3700 | 3706 |
3701 int vdp_control_port_write(vdp_context * context, uint16_t value) | 3707 int vdp_control_port_write(vdp_context * context, uint16_t value) |
3702 { | 3708 { |
3703 //printf("control port write: %X at %d\n", value, context->cycles); | 3709 //printf("control port write: %X at %d\n", value, context->cycles); |
3704 if (context->flags & FLAG_DMA_RUN) { | 3710 if (context->flags & FLAG_DMA_RUN) { |
3705 return -1; | 3711 return -1; |
3706 } | 3712 } |
3707 if (context->flags & FLAG_PENDING) { | 3713 if (context->flags & FLAG_PENDING) { |
3708 context->address_latch = (context->address_latch & 0x3FFF) | (value << 14 & 0x1C000); | 3714 context->address_latch = (context->address_latch & 0x3FFF) | (value << 14 & 0x1C000); |
3709 //It seems like the DMA enable bit doesn't so much enable DMA so much | 3715 context->cd_latch = (context->cd_latch & 0x3) | ((value >> 2) & ~0x3 & 0xFF); |
3710 //as it enables changing CD5 from control port writes | |
3711 uint8_t preserve = (context->regs[REG_MODE_2] & BIT_DMA_ENABLE) ? 0x3 : 0x23; | |
3712 context->cd_latch = (context->cd_latch & preserve) | ((value >> 2) & ~preserve & 0xFF); | |
3713 clear_pending(context); | 3716 clear_pending(context); |
3714 //Should these be taken care of here or after the first write? | 3717 //Should these be taken care of here or after the first write? |
3715 context->flags &= ~FLAG_READ_FETCHED; | 3718 context->flags &= ~FLAG_READ_FETCHED; |
3716 context->flags2 &= ~FLAG2_READ_PENDING; | 3719 context->flags2 &= ~FLAG2_READ_PENDING; |
3717 //printf("New Address: %X, New CD: %X\n", context->address, context->cd); | 3720 //printf("New Address: %X, New CD: %X\n", context->address, context->cd); |