summaryrefslogtreecommitdiff
path: root/vdp.c
diff options
context:
space:
mode:
authorMike Pavone <pavone@retrodev.com>2013-09-17 09:45:14 -0700
committerMike Pavone <pavone@retrodev.com>2013-09-17 09:45:14 -0700
commitb1170b0ee50fdb523fdb65e6f99851fe67acd1c1 (patch)
tree403138f1232f57a2af27c26aa47a71ff0fa9bc25 /vdp.c
parent7f8e47eb7e81a7001f0c6a00f2cf52f1e50a96a2 (diff)
Implement HV counter latch
Diffstat (limited to 'vdp.c')
-rw-r--r--vdp.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/vdp.c b/vdp.c
index 5d02ce6..4d21f1c 100644
--- a/vdp.c
+++ b/vdp.c
@@ -1467,10 +1467,10 @@ int vdp_control_port_write(vdp_context * context, uint16_t value)
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);
- 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_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_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_data_port_read(vdp_context * context)
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;