@@ -62,13 +62,21 @@ namespace Line__Crypt
6262 return size;
6363 }
6464
65- static void Decrypt (void * file, uint32_t fileSize)
65+ static void Decrypt (void * file, uint32_t fileSize, bool isJPN )
6666 {
6767 // prepare key values and parameters
68- int key0 = 0x000cd8f3 ;
69- int key1 = 0x9b36bb94 ;
70- int key2 = 0xaf8910be ;
68+ int saltUSA = 0x180a ;
69+ int saltJPN = 0x0ce0 ;
7170 int salt = 0 ;
71+ int key0USA = 0x000cd8f3 ;
72+ int key0JPN = 0x0004f107 ;
73+ int key0 = isJPN ? key0JPN : key0USA;
74+ int key1USA = 0x9b36bb94 ;
75+ int key1JPN = 0xb5fb6483 ;
76+ int key1 = isJPN ? key1JPN : key1USA;
77+ int key2USA = 0xaf8910be ;
78+ int key2JPN = 0xdeaddead ;
79+ int key2 = isJPN ? key2JPN : key2USA;
7280 int fileSizeExtended = (fileSize + 0x1f ) & ~0 ; // filesize next multiple of 0x20
7381 int fileLocation = reinterpret_cast <int >(file);
7482 int r8 = rlwinm (fileSizeExtended, 30 , 2 , 31 );
@@ -83,7 +91,7 @@ namespace Line__Crypt
8391 {
8492 // decrypting 1st 4 bytes of 0x20 bytes block
8593 int keyProd = key2 * key1;
86- salt = 0x180a ;
94+ salt = isJPN ? saltJPN : saltUSA ;
8795 r3 = lwz (0 , rwLocation);
8896 int r29 = keyProd + key0;
8997 r3 ^= r29;
@@ -176,14 +184,14 @@ namespace Line__Crypt
176184 return ;
177185
178186 // set parameters for last block processing
179- r3 = 0x9b370000 ;
187+ r3 = isJPN ? 0xb5fb0000 : 0x9b370000 ;
180188 int r4 = rlwinm (cryptedWords, 2 , 0 , 29 );
181- r11 = r3, (short )0xbb94 ;
189+ r11 = r3 + isJPN ? ( short ) 0x6483 : (short )0xbb94 ;
182190 r3 = 0x000d0000 ;
183191 int r0 = r8 - cryptedWords;
184192 rwLocation = fileLocation + r4;
185- r3 += (short )0xd8f3 ;
186- salt = 0x180a ;
193+ r3 += isJPN ? ( short ) 0xf107 : (short )0xd8f3 ;
194+ salt = isJPN ? saltJPN : saltUSA ;
187195
188196 // crypt last block
189197 for (int i = r0; i > 0 ; --i)
0 commit comments