diff cdd_mcu.c @ 2081:cfd53c94fffb

Initial stab at RF5C164 emulation
author Michael Pavone <pavone@retrodev.com>
date Thu, 03 Feb 2022 23:15:42 -0800
parents bafb757e1cd2
children c9d3b8e1ea56
line wrap: on
line diff
--- a/cdd_mcu.c	Wed Feb 02 01:10:07 2022 -0800
+++ b/cdd_mcu.c	Thu Feb 03 23:15:42 2022 -0800
@@ -77,7 +77,7 @@
 		if (context->seek_pba == context->head_pba) {
 			context->seeking = 0;
 		} else if (context->seek_pba > context->head_pba) {
-			if (context->seek_pba - context->head_pba >= COARSE_SEEK) {
+			if (context->seek_pba - context->head_pba >= COARSE_SEEK || context->head_pba < LEADIN_SECTORS) {
 				context->head_pba += COARSE_SEEK;
 			} else if (context->seek_pba - context->head_pba >= FINE_SEEK) {
 				context->head_pba += FINE_SEEK;
@@ -119,6 +119,8 @@
 		handle_seek(context);
 		if (!context->seeking) {
 			context->head_pba++;
+		}
+		if (context->head_pba >= LEADIN_SECTORS) {
 			uint8_t track = context->media->seek(context->media, context->head_pba - LEADIN_SECTORS);
 			if (context->media->tracks[track].type == TRACK_AUDIO) {
 				gate_array[GAO_CDD_CTRL] &= ~BIT_MUTE;
@@ -471,7 +473,7 @@
 			next_nibble = context->cycle;
 			context->current_status_nibble = 0;
 			gate_array[GAO_CDD_STATUS] |= BIT_DRS;
-			if (context->status == DS_PLAY && !context->seeking) {
+			if (context->status == DS_PLAY && context->head_pba >= LEADIN_SECTORS) {
 				context->current_sector_byte = 0;
 			}
 		}