changeset 2095:c732dcc9c61b

Better simulation of CDD pause behavior
author Michael Pavone <pavone@retrodev.com>
date Mon, 07 Feb 2022 21:31:58 -0800
parents ca6fc8c8dc60
children 460c93c19146
files cdd_mcu.c cdd_mcu.h
diffstat 2 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/cdd_mcu.c	Mon Feb 07 21:25:56 2022 -0800
+++ b/cdd_mcu.c	Mon Feb 07 21:31:58 2022 -0800
@@ -76,6 +76,9 @@
 	if (context->seeking) {
 		if (context->seek_pba == context->head_pba) {
 			context->seeking = 0;
+			if (context->status == DS_PAUSE) {
+				context->pause_pba = context->head_pba;
+			}
 		} else if (context->seek_pba > context->head_pba) {
 			if (context->seek_pba - context->head_pba >= COARSE_SEEK || context->head_pba < LEADIN_SECTORS) {
 				context->head_pba += COARSE_SEEK;
@@ -129,6 +132,15 @@
 		break;
 	case DS_PAUSE:
 		handle_seek(context);
+		if (!context->seeking) {
+			context->head_pba++;
+			if (context->head_pba > context->pause_pba + FINE_SEEK) {
+				context->head_pba = context->pause_pba - FINE_SEEK;
+				if (context->head_pba < LEADIN_SECTORS) {
+					context->head_pba = LEADIN_SECTORS;
+				}
+			}
+		}
 		if (context->head_pba >= LEADIN_SECTORS) {
 			uint8_t track = context->media->seek(context->media, context->head_pba - LEADIN_SECTORS);
 			if (!context->seeking && context->media->tracks[track].type == TRACK_AUDIO) {
@@ -144,7 +156,7 @@
 				if (context->head_pba > 3*(context->media->num_tracks + 2)) {
 					context->toc_valid = 1;
 					context->seeking = 1;
-					context->seek_pba = LEADIN_SECTORS + context->media->tracks[0].start_lba;
+					context->seek_pba = LEADIN_SECTORS + context->media->tracks[0].start_lba + context->media->tracks[0].fake_pregap;
 					context->status = DS_PAUSE;
 				}
 
@@ -157,6 +169,7 @@
 		handle_seek(context);
 		if (!context->seeking) {
 			context->status = DS_PAUSE;
+			context->pause_pba = context->head_pba;
 		}
 		if (context->head_pba >= LEADIN_SECTORS) {
 			uint8_t track = context->media->seek(context->media, context->head_pba - LEADIN_SECTORS);
@@ -454,6 +467,9 @@
 			puts("CDD CMD: PAUSE");
 		}
 		context->status = DS_PAUSE;
+		if (!context->seeking) {
+			context->pause_pba = context->head_pba;
+		}
 		break;
 	case CMD_PLAY:
 		if (context->status == DS_DOOR_OPEN || context->status == DS_TRAY_MOVING || context->status == DS_DISC_LEADOUT || context->status == DS_DISC_LEADIN) {
--- a/cdd_mcu.h	Mon Feb 07 21:25:56 2022 -0800
+++ b/cdd_mcu.h	Mon Feb 07 21:31:58 2022 -0800
@@ -144,6 +144,7 @@
 	int           current_sector_byte;
 	uint32_t      head_pba;
 	uint32_t      seek_pba;
+	uint32_t      pause_pba;
 	cdd_status    status_buffer;
 	cdd_cmd       cmd_buffer;
 	status_format requested_format;