# HG changeset patch # User Michael Pavone # Date 1644298318 28800 # Node ID c732dcc9c61b09b17b22a33a6ae0f13e9fd5c82b # Parent ca6fc8c8dc6005db91e3290aa84c24f04b0376a9 Better simulation of CDD pause behavior diff -r ca6fc8c8dc60 -r c732dcc9c61b cdd_mcu.c --- 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) { diff -r ca6fc8c8dc60 -r c732dcc9c61b cdd_mcu.h --- 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;