changeset 2139:11a3d5b00a66

Fix DRS and DTS bits of CDD status
author Michael Pavone <pavone@retrodev.com>
date Sun, 20 Mar 2022 13:55:31 -0700
parents b6338e18787e
children 6d0de02a068a
files cdd_mcu.c
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/cdd_mcu.c	Sat Mar 19 15:50:45 2022 -0700
+++ b/cdd_mcu.c	Sun Mar 20 13:55:31 2022 -0700
@@ -569,7 +569,6 @@
 			update_status(context, gate_array);
 			next_nibble = context->cycle + PROCESSING_DELAY;
 			context->current_status_nibble = 0;
-			gate_array[GAO_CDD_STATUS] |= BIT_DRS;
 			if (context->next_subcode_int_cycle != CYCLE_NEVER) {
 				context->subcode_int_pending = 1;
 			}
@@ -585,17 +584,18 @@
 		if (context->cycle >= next_nibble) {
 			if (context->current_status_nibble == sizeof(cdd_status)) {
 				context->current_status_nibble = -1;
-				gate_array[GAO_CDD_STATUS] &= ~BIT_DRS;
+				gate_array[GAO_CDD_CTRL] &= ~BIT_DRS;
 				if (context->cmd_recv_pending) {
 					context->cmd_recv_pending = 0;
 					context->current_cmd_nibble = 0;
-					gate_array[GAO_CDD_STATUS] |= BIT_DTS;
+					gate_array[GAO_CDD_CTRL] |= BIT_DTS;
 					next_cmd_nibble = context->cycle + NIBBLE_CLOCKS;
 				} else {
 					context->cmd_recv_wait = 1;
 				}
 				next_nibble = CYCLE_NEVER;
 			} else {
+				gate_array[GAO_CDD_CTRL] |= BIT_DRS;
 				uint8_t value = ((uint8_t *)&context->status_buffer)[context->current_status_nibble];
 				int ga_index = GAO_CDD_STATUS + (context->current_status_nibble >> 1);
 				if (context->current_status_nibble & 1) {
@@ -615,7 +615,7 @@
 			if (context->current_cmd_nibble == sizeof(cdd_cmd)) {
 				next_cmd_nibble = CYCLE_NEVER;
 				context->current_cmd_nibble = -1;
-				gate_array[GAO_CDD_STATUS] &= ~BIT_DTS;
+				gate_array[GAO_CDD_CTRL] &= ~BIT_DTS;
 				run_command(context);
 			} else {
 				int ga_index = GAO_CDD_CMD + (context->current_cmd_nibble >> 1);
@@ -679,9 +679,12 @@
 
 void cdd_mcu_start_cmd_recv(cdd_mcu *context, uint16_t *gate_array)
 {
+	if (gate_array[GAO_CDD_CTRL] & BIT_DTS) {
+		return;
+	}
 	if (context->cmd_recv_wait) {
 		context->current_cmd_nibble = 0;
-		gate_array[GAO_CDD_STATUS] |= BIT_DTS;
+		gate_array[GAO_CDD_CTRL] |= BIT_DTS;
 		context->last_nibble_cycle = context->cycle;
 		context->cmd_recv_wait = 0;
 	} else {