# HG changeset patch # User Mike Pavone # Date 1379436314 25200 # Node ID 0737953132ad546c256f7b732dfd38f7246e4bc5 # Parent 863e868752cfbca4ace5732c22d57ae2639a7c08 Implement HV counter latch diff -r 863e868752cf -r 0737953132ad vdp.c --- a/vdp.c Tue Sep 17 00:42:49 2013 -0700 +++ b/vdp.c Tue Sep 17 09:45:14 2013 -0700 @@ -1467,10 +1467,10 @@ uint8_t reg = (value >> 8) & 0x1F; if (reg < (context->regs[REG_MODE_2] & BIT_MODE_5 ? VDP_REGS : 0xA)) { //printf("register %d set to %X\n", reg, value & 0xFF); + if (reg == REG_MODE_1 && (value & BIT_HVC_LATCH) && !(context->regs[reg] & BIT_HVC_LATCH)) { + context->hv_latch = vdp_hv_counter_read(context); + } context->regs[reg] = value; - if (reg == REG_MODE_2) { - //printf("Display is now %s\n", (context->regs[REG_MODE_2] & DISPLAY_ENABLE) ? "enabled" : "disabled"); - } if (reg == REG_MODE_4) { context->double_res = (value & (BIT_INTERLACE | BIT_DOUBLE_RES)) == (BIT_INTERLACE | BIT_DOUBLE_RES); if (!context->double_res) { @@ -1613,7 +1613,9 @@ uint16_t vdp_hv_counter_read(vdp_context * context) { - //TODO: deal with clock adjustemnts handled in vdp_run_context + if (context->regs[REG_MODE_1] & BIT_HVC_LATCH) { + return context->hv_latch; + } uint32_t line= context->cycles / MCLKS_LINE; if (!line) { line = 0xFF; diff -r 863e868752cf -r 0737953132ad vdp.h --- a/vdp.h Tue Sep 17 00:42:49 2013 -0700 +++ b/vdp.h Tue Sep 17 09:45:14 2013 -0700 @@ -152,6 +152,7 @@ sprite_info sprite_info_list[MAX_SPRITES_LINE]; uint16_t col_1; uint16_t col_2; + uint16_t hv_latch; uint8_t v_offset; uint8_t dma_cd; uint8_t hint_counter;