Skip to content

Commit

Permalink
CDVDMAN: revised algorithm for unscrambling the PS2 logo. Fixes failu…
Browse files Browse the repository at this point in the history
…res to correctly unscramble the logo if the first byte of subsequent passes does not represent a black pixel.
  • Loading branch information
sp193 committed Feb 17, 2019
1 parent f16c52d commit ea01c62
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions modules/iopcore/cdvdman/cdvdman.c
Expand Up @@ -385,12 +385,18 @@ static int cdvdman_read_sectors(u32 lsn, unsigned int sectors, void *buf)
break;
}

// PS2LOGO Decryptor algorithm; based on misfire's code (https://github.com/mlafeldt/ps2logo)
/* PS2LOGO Decryptor algorithm; based on misfire's code (https://github.com/mlafeldt/ps2logo)
The PS2 logo is stored within the first 12 sectors, scrambled.
This algorithm exploits the characteristic that the value used for scrambling will be recorded,
when it is XOR'ed against a black pixel. The first pixel is black, hence the value of the first byte
was the value used for scrambling. */
if (lsn < 13) {
u32 j;
u8 *logo = (u8 *)ptr;
u8 key = logo[0];
if (logo[0] != 0) {
static u8 key = 0;
if (lsn == 0) //First sector? Copy the first byte as the value for unscrambling the logo.
key = logo[0];
if (key != 0) {
for (j = 0; j < (SectorsToRead * 2048); j++) {
logo[j] ^= key;
logo[j] = (logo[j] << 3) | (logo[j] >> 5);
Expand Down

0 comments on commit ea01c62

Please sign in to comment.