Mercurial > repos > blastem
comparison cdd_mcu.c @ 2084:c9d3b8e1ea56
Implement a couple more CDD commands force CDDA mute when seeking
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 05 Feb 2022 16:38:22 -0800 |
parents | cfd53c94fffb |
children | 0db3af42dd72 |
comparison
equal
deleted
inserted
replaced
2083:372625dd9590 | 2084:c9d3b8e1ea56 |
---|---|
120 if (!context->seeking) { | 120 if (!context->seeking) { |
121 context->head_pba++; | 121 context->head_pba++; |
122 } | 122 } |
123 if (context->head_pba >= LEADIN_SECTORS) { | 123 if (context->head_pba >= LEADIN_SECTORS) { |
124 uint8_t track = context->media->seek(context->media, context->head_pba - LEADIN_SECTORS); | 124 uint8_t track = context->media->seek(context->media, context->head_pba - LEADIN_SECTORS); |
125 if (context->media->tracks[track].type == TRACK_AUDIO) { | 125 if (!context->seeking && context->media->tracks[track].type == TRACK_AUDIO) { |
126 gate_array[GAO_CDD_CTRL] &= ~BIT_MUTE; | 126 gate_array[GAO_CDD_CTRL] &= ~BIT_MUTE; |
127 } | 127 } |
128 } | 128 } |
129 break; | 129 break; |
130 case DS_PAUSE: | 130 case DS_PAUSE: |
131 handle_seek(context); | 131 handle_seek(context); |
132 if (context->head_pba >= LEADIN_SECTORS) { | |
133 uint8_t track = context->media->seek(context->media, context->head_pba - LEADIN_SECTORS); | |
134 if (!context->seeking && context->media->tracks[track].type == TRACK_AUDIO) { | |
135 gate_array[GAO_CDD_CTRL] &= ~BIT_MUTE; | |
136 } | |
137 } | |
132 break; | 138 break; |
133 case DS_TOC_READ: | 139 case DS_TOC_READ: |
134 handle_seek(context); | 140 handle_seek(context); |
135 if (!context->seeking) { | 141 if (!context->seeking) { |
136 context->head_pba++; | 142 context->head_pba++; |
145 } else { | 151 } else { |
146 context->status = DS_NO_DISC; | 152 context->status = DS_NO_DISC; |
147 } | 153 } |
148 } | 154 } |
149 break; | 155 break; |
150 | 156 case DS_TRACKING: |
157 handle_seek(context); | |
158 if (!context->seeking) { | |
159 context->status = DS_PAUSE; | |
160 } | |
161 if (context->head_pba >= LEADIN_SECTORS) { | |
162 uint8_t track = context->media->seek(context->media, context->head_pba - LEADIN_SECTORS); | |
163 if (!context->seeking && context->media->tracks[track].type == TRACK_AUDIO) { | |
164 gate_array[GAO_CDD_CTRL] &= ~BIT_MUTE; | |
165 } | |
166 } | |
167 break; | |
151 } | 168 } |
152 if (context->first_cmd_received) { | 169 if (context->first_cmd_received) { |
153 switch (context->requested_format) | 170 switch (context->requested_format) |
154 { | 171 { |
155 case SF_ABSOLUTE: | 172 case SF_ABSOLUTE: |
285 break; | 302 break; |
286 } | 303 } |
287 if (context->error_status == DS_STOP) { | 304 if (context->error_status == DS_STOP) { |
288 if (context->requested_format >= SF_TOCO && context->requested_format <= SF_TOCN) { | 305 if (context->requested_format >= SF_TOCO && context->requested_format <= SF_TOCN) { |
289 context->status_buffer.status = DS_TOC_READ; | 306 context->status_buffer.status = DS_TOC_READ; |
290 } else if (context->seeking) { | 307 } else if (context->seeking && context->status != DS_TRACKING) { |
291 context->status_buffer.status = DS_SEEK; | 308 context->status_buffer.status = DS_SEEK; |
292 } else { | 309 } else { |
293 context->status_buffer.status = context->status; | 310 context->status_buffer.status = context->status; |
294 } | 311 } |
295 } else { | 312 } else { |
436 } else { | 453 } else { |
437 puts("CDD CMD: PAUSE"); | 454 puts("CDD CMD: PAUSE"); |
438 } | 455 } |
439 context->status = DS_PAUSE; | 456 context->status = DS_PAUSE; |
440 break; | 457 break; |
458 case CMD_PLAY: | |
459 if (context->status == DS_DOOR_OPEN || context->status == DS_TRAY_MOVING || context->status == DS_DISC_LEADOUT || context->status == DS_DISC_LEADIN) { | |
460 context->error_status = DS_CMD_ERROR; | |
461 break; | |
462 } | |
463 if (context->requested_format == SF_TOCT || context->requested_format == SF_TOCN) { | |
464 context->requested_format = SF_ABSOLUTE; | |
465 } | |
466 if (!context->toc_valid) { | |
467 context->error_status = DS_CMD_ERROR; | |
468 break; | |
469 } | |
470 if (context->status == DS_STOP || context->status == DS_TOC_READ) { | |
471 context->seeking = 1; | |
472 context->seek_pba = LEADIN_SECTORS + context->media->tracks[0].fake_pregap + context->media->tracks[0].start_lba; | |
473 printf("CDD CMD: PAUSE, seeking to %u\n", context->seek_pba); | |
474 } else { | |
475 puts("CDD CMD: PAUSE"); | |
476 } | |
477 break; | |
478 //TODO: CMD_FFWD, CMD_RWD | |
479 case CMD_TRACK_SKIP: | |
480 if (context->status != DS_PLAY && context->status != DS_PAUSE && context->status != DS_DISC_LEADOUT) { | |
481 context->error_status = DS_CMD_ERROR; | |
482 break; | |
483 } | |
484 if (context->requested_format == SF_TOCT || context->requested_format == SF_TOCN) { | |
485 context->requested_format = SF_ABSOLUTE; | |
486 } | |
487 if (!context->toc_valid) { | |
488 context->error_status = DS_CMD_ERROR; | |
489 break; | |
490 } | |
491 { | |
492 int32_t to_skip = context->cmd_buffer.b.skip.tracks_highest << 12 | context->cmd_buffer.b.skip.tracks_midhigh << 8 | |
493 | context->cmd_buffer.b.skip.tracks_midlow << 4 | context->cmd_buffer.b.skip.tracks_lowest; | |
494 if (context->cmd_buffer.b.skip.direction) { | |
495 to_skip = -to_skip; | |
496 } | |
497 printf("CDD CMD: TRACK_SKIP direction %u, num_tracks %i, delta %i\n", context->cmd_buffer.b.skip.direction, abs(to_skip), to_skip); | |
498 //circumference at 83mm point (roughly half way between inner and outer edge of program area) | |
499 //~ 260.75cm ~ 15 sectors | |
500 context->seek_pba = context->head_pba + to_skip * 15; | |
501 context->seeking = 1; | |
502 } | |
503 context->status = DS_TRACKING; | |
504 break; | |
441 default: | 505 default: |
442 printf("CDD CMD: Unimplemented(%d)\n", context->cmd_buffer.cmd_type); | 506 printf("CDD CMD: Unimplemented(%d)\n", context->cmd_buffer.cmd_type); |
443 } | 507 } |
444 } | 508 } |
445 | 509 |
471 next_subcode = context->cycle + SECTOR_CLOCKS; | 535 next_subcode = context->cycle + SECTOR_CLOCKS; |
472 update_status(context, gate_array); | 536 update_status(context, gate_array); |
473 next_nibble = context->cycle; | 537 next_nibble = context->cycle; |
474 context->current_status_nibble = 0; | 538 context->current_status_nibble = 0; |
475 gate_array[GAO_CDD_STATUS] |= BIT_DRS; | 539 gate_array[GAO_CDD_STATUS] |= BIT_DRS; |
476 if (context->status == DS_PLAY && context->head_pba >= LEADIN_SECTORS) { | 540 if ((context->status == DS_PLAY || context->status == DS_PAUSE) && context->head_pba >= LEADIN_SECTORS) { |
477 context->current_sector_byte = 0; | 541 context->current_sector_byte = 0; |
478 } | 542 } |
479 } | 543 } |
480 if (context->cycle >= next_nibble) { | 544 if (context->cycle >= next_nibble) { |
481 if (context->current_status_nibble == sizeof(cdd_status)) { | 545 if (context->current_status_nibble == sizeof(cdd_status)) { |