comparison cdd_mcu.c @ 2347:047253715fd8

Minor fix to seek time calculation
author Michael Pavone <pavone@retrodev.com>
date Wed, 11 Oct 2023 11:36:18 -0700
parents 9ead0fe69d9b
children 2025ba21026a
comparison
equal deleted inserted replaced
2346:0111c8344477 2347:047253715fd8
18 //difference 4 mm = 4000 um 18 //difference 4 mm = 4000 um
19 //radius difference 2 mm = 2000 um 19 //radius difference 2 mm = 2000 um
20 //track pitch 1.6 um 20 //track pitch 1.6 um
21 //1250 physical tracks in between 21 //1250 physical tracks in between
22 //linear speed 1.2 m/s - 1.4 m/s 22 //linear speed 1.2 m/s - 1.4 m/s
23 // 1.3 m = 1300 mm 23 // 1.2 m = 1200 mm
24 // circumference at 46 mm ~ 144.51 mm 24 // circumference at 46 mm ~ 144.51 mm
25 // circumference at 50 mm ~ 157.08 mm 25 // circumference at 50 mm ~ 157.08 mm
26 // avg is 150.795 26 // avg is 150.795
27 // 75 sectors per second 27 // 75 sectors per second
28 // 17.3333 mm "typical" length of a sector 28 // 16 mm "typical" length of a sector
29 // ~8.7 sectors per track in lead-in area 29 // ~9.4 sectors per track in lead-in area
30 #define LEADIN_SECTORS 10875 30 #define LEADIN_SECTORS 11780
31 31
32 static uint32_t cd_block_to_mclks(uint32_t cycles) 32 static uint32_t cd_block_to_mclks(uint32_t cycles)
33 { 33 {
34 return ((uint64_t)cycles) * ((uint64_t)SCD_MCLKS) / ((uint64_t)CD_BLOCK_CLKS); 34 return ((uint64_t)cycles) * ((uint64_t)SCD_MCLKS) / ((uint64_t)CD_BLOCK_CLKS);
35 } 35 }
80 return (~sum) & 0xF; 80 return (~sum) & 0xF;
81 } 81 }
82 82
83 #define MIN_CIRCUMFERENCE 144.51f 83 #define MIN_CIRCUMFERENCE 144.51f
84 #define MAX_CIRCUMFERENCE 364.42f 84 #define MAX_CIRCUMFERENCE 364.42f
85 #define SECTOR_LENGTH 17.3333f 85 #define SECTOR_LENGTH 16.0f
86 // max diameter for program area 116 mm 86 // max diameter for program area 116 mm
87 // circumference ~ 364.42 mm 87 // circumference ~ 364.42 mm
88 // ~ 21 sectors per physical track at edge 88 // ~ 23 sectors per physical track at edge
89 // ~8 sectors per physical track at start of lead-in 89 // ~9 sectors per physical track at start of lead-in
90 #define COARSE_SEEK_TRACKS 57 //estimate based on seek test 90 // seek test suggests average somewhere around 54-60 tracks for a long seek, with a peak around 80
91 // Sonic CD title screen seems to need a much higher value to get reasonable sync
92 #define COARSE_SEEK_TRACKS 60
91 static void handle_seek(cdd_mcu *context) 93 static void handle_seek(cdd_mcu *context)
92 { 94 {
93 uint32_t old_coarse = context->coarse_seek; 95 uint32_t old_coarse = context->coarse_seek;
94 if (context->seeking) { 96 if (context->seeking) {
95 if (context->seek_pba == context->head_pba) { 97 if (context->seek_pba == context->head_pba) {
100 } 102 }
101 } else { 103 } else {
102 //TODO: better estimate of sectors per track at current head location 104 //TODO: better estimate of sectors per track at current head location
103 //TODO: drive will periodically lose tracking when seeking which slows 105 //TODO: drive will periodically lose tracking when seeking which slows
104 //things down from this ideal speed I'm curently estimating 106 //things down from this ideal speed I'm curently estimating
105 float circumference = (MAX_CIRCUMFERENCE-MIN_CIRCUMFERENCE) * ((float)context->head_pba) / (74 * 60 * SECTORS_PER_SECOND) + MIN_CIRCUMFERENCE; 107 float circumference = (MAX_CIRCUMFERENCE-MIN_CIRCUMFERENCE) * ((float)context->head_pba) / ((74 * 60 + 41) * SECTORS_PER_SECOND + LEADIN_SECTORS + 22) + MIN_CIRCUMFERENCE;
106 float sectors_per_track = circumference / SECTOR_LENGTH; 108 float sectors_per_track = circumference / SECTOR_LENGTH;
107 uint32_t max_seek = sectors_per_track * COARSE_SEEK_TRACKS; 109 uint32_t max_seek = sectors_per_track * COARSE_SEEK_TRACKS;
108 uint32_t min_seek = sectors_per_track; 110 uint32_t min_seek = sectors_per_track;
109 111
110 uint32_t old_pba = context->head_pba; 112 uint32_t old_pba = context->head_pba;