Mercurial > repos > blastem
diff cdimage.c @ 2352:76dfad6a53b5
Fix bug in CD-ROM scrambling algorithm
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 18 Oct 2023 23:27:14 -0700 |
parents | 9f0c67e5c50a |
children | 69c28808b49a |
line wrap: on
line diff
--- a/cdimage.c Wed Oct 18 23:26:51 2023 -0700 +++ b/cdimage.c Wed Oct 18 23:27:14 2023 -0700 @@ -9,10 +9,13 @@ uint8_t cdrom_scramble(uint16_t *lsfr, uint8_t data) { data ^= *lsfr; - uint16_t new_bit = *lsfr; - *lsfr >>= 1; - new_bit = (new_bit ^ *lsfr) & 1; - *lsfr |= new_bit << 14; + for (int i = 0; i < 8; i++) + { + uint16_t new_bit = *lsfr; + *lsfr >>= 1; + new_bit = (new_bit ^ *lsfr) & 1; + *lsfr |= new_bit << 14; + } return data; }