# HG changeset patch # User Michael Pavone # Date 1662688594 25200 # Node ID 8e6fb2c060245a7736fe0fdb4ba7719fb36ff56e # Parent 3888c7ed4e36967dda47b1f32de439f0b9e95160 Fix CDC transfer regression diff -r 3888c7ed4e36 -r 8e6fb2c06024 lc8951.c --- a/lc8951.c Wed Sep 07 23:19:29 2022 -0700 +++ b/lc8951.c Thu Sep 08 18:56:34 2022 -0700 @@ -143,6 +143,7 @@ uint16_t transfer_size = context->regs[DBCL] | (context->regs[DBCH] << 8); context->transfer_end = context->cycle + transfer_size * context->cycles_per_byte; context->next_byte_cycle = context->cycle; + context->triggered = 1; printf("DTTRG: size %u, cycle %u, end %u\n", transfer_size, context->cycle, context->transfer_end); } break; @@ -278,6 +279,7 @@ } context->transfer_end = CYCLE_NEVER; context->next_byte_cycle = CYCLE_NEVER; + context->triggered = 0; } } } else { @@ -291,19 +293,17 @@ void lc8951_resume_transfer(lc8951 *context, uint32_t cycle) { - if (context->transfer_end == CYCLE_NEVER && (context->ifctrl & BIT_DOUTEN)) { + if (context->triggered && context->transfer_end == CYCLE_NEVER && (context->ifctrl & BIT_DOUTEN)) { uint16_t transfer_size = context->regs[DBCL] | (context->regs[DBCH] << 8); - if (transfer_size != 0xFFFF) { - //HACK!!! Work around Sub CPU running longer than we would like and dragging other components with it - uint32_t step_diff = (context->cycle - cycle) / context->clock_step; - if (step_diff) { - context->cycle -= step_diff * context->clock_step; - } - context->transfer_end = context->cycle + transfer_size * context->cycles_per_byte; - context->next_byte_cycle = context->cycle; - if (step_diff) { - lc8951_run(context, cycle); - } + //HACK!!! Work around Sub CPU running longer than we would like and dragging other components with it + uint32_t step_diff = (context->cycle - cycle) / context->clock_step; + if (step_diff) { + context->cycle -= step_diff * context->clock_step; + } + context->transfer_end = context->cycle + transfer_size * context->cycles_per_byte; + context->next_byte_cycle = context->cycle; + if (step_diff) { + lc8951_run(context, cycle); } } } diff -r 3888c7ed4e36 -r 8e6fb2c06024 lc8951.h --- a/lc8951.h Wed Sep 07 23:19:29 2022 -0700 +++ b/lc8951.h Thu Sep 08 18:56:34 2022 -0700 @@ -29,6 +29,7 @@ uint8_t ctrl1; uint8_t ar; uint8_t ar_mask; + uint8_t triggered; uint8_t sync_counter; } lc8951;