Mercurial > repos > blastem
comparison cdd_mcu.c @ 2348:2025ba21026a
Fix backwards seek calculation
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 11 Oct 2023 23:18:16 -0700 |
parents | 047253715fd8 |
children | c66e051de8a6 |
comparison
equal
deleted
inserted
replaced
2347:047253715fd8 | 2348:2025ba21026a |
---|---|
123 } else { | 123 } else { |
124 context->head_pba++; | 124 context->head_pba++; |
125 } | 125 } |
126 } else { | 126 } else { |
127 uint32_t seek_amount; | 127 uint32_t seek_amount; |
128 for (seek_amount = max_seek; seek_amount >= min_seek; seek_amount >>= 1) | 128 for (seek_amount = max_seek; seek_amount >= min_seek;) |
129 { | 129 { |
130 if (context->head_pba - context->seek_pba >= seek_amount) { | 130 uint32_t next_seek = seek_amount >> 1; |
131 if (context->head_pba - context->seek_pba > next_seek) { | |
131 break; | 132 break; |
132 } | 133 } |
133 } | 134 seek_amount = next_seek; |
134 if (seek_amount >= min_seek) { | 135 } |
136 if (seek_amount >= min_seek && context->head_pba >= seek_amount) { | |
135 context->head_pba -= seek_amount; | 137 context->head_pba -= seek_amount; |
136 } else if (context->head_pba >= min_seek){ | 138 } else if (context->head_pba >= min_seek){ |
137 context->head_pba -= min_seek; | 139 context->head_pba -= min_seek; |
138 } else { | 140 } else { |
139 context->head_pba = 0; | 141 context->head_pba = 0; |