Password Generation for the Prince of Persia Game Series

    Good afternoon, dear users.
    Today I would like to talk about one wonderful series of games. Many met her, thanks to the version on NES, some saw the Persian prince on DOS, someone played Prince of Persia on Sega Genesis and ... like everything, but no! The first part was ported to a large number of different gaming platforms. And how many password systems were invented about this? And how many ports did the second part have? What passwords were there?
    I would like to tell you about this.

    Prince of Persia (Sega Master System / Sega Game Gear)


    image

    Theory


    Password consists of 6 positions. These positions save these game parameters:
    • level (1-14)
    • time (0-99)
    • life (0-7)
    • random (0-25)

    Generation

    1 position = ((level -1) + random) mod26
    2 position = ((time div10) + random) mod26
    3 position = ((time mod10) + random) mod26
    4 position = (life + random) mod26
    5 position = random
    6 position = ((sum of positions 1 to 5) + 10) mod26

    Coding

    Symbols in positions take the values ​​"ABCDEFGHIJKLMNOPQRSTUVWXYZ", where A = 0, B = 1 ... Y = 24, Z = 25.

    Password Generation Example
    Create a password that saves these parameters:
    • level (12)
    • life (6)
    • time (59)
    • random (18)

    We calculate:
    1)
    1 position = ((12 -1) + 18) mod26
    2 position = ((59 div10) + 18) mod26
    3 position = ((59 mod10) +18) mod26
    4 position = (6 + 18) mod26
    5 position = 18
    6 position = 10

    2)
    1 position = 3
    2 position = 23
    3 position = 1
    4 position = 24
    5 position = 18
    6 position = (3 + 23 + 1 + 24 + 18 + 10) mod26 = 1

    Now encode the resulting values:
    DXBYSB

    Interesting bug


    The game has a bug with which you can get immortality. But before explaining, I would like to discuss level architecture. Conditionally divide the screen into 3 floors.

    Floors
    image

    If the prince lives from 1 to 7, then when falling from 2 floors to 1, lives are not wasted. And when falling from 3 floors to 1, 1 life is spent. If lives 0, then the opposite happens. When falling from 2 floors to 1, the prince dies, and when falling from 3 floors to 1, a bug occurs: the game will give the prince 8 lives (do not forget that the maximum is seven).

    8 lives
    image

    After the operation, the prince will be able to jump from the 3rd and 2nd floors without causing damage to himself (if you take the 4th floor, the prince will die). Also, the prince will be invulnerable to enemy attacks (if the weapon is in the hands). After completing the level, the bug disappears and the prince will again have 0 lives. And if you attack the guard with zero lives, he will simply ignore you and it will become impossible to kill him.

    Ghost prince
    image

    Here it is.

      

    Prince of Persia (Game Boy / Game Boy Color)


    image

    Theory


    Password consists of 8 positions. These positions save these game parameters:
    • level (2-14)
    • time (1-59)
    • life (3-9)

    Note: at level 7 you cannot create a password.

    Generation

    1 position = (4 position + 7 position + 8 position) mod10
    2 position = (5 position + 6 position) mod10
    3 position = (7 position + 8 position) mod10
    4 position = life
    5 position = time mod10
    6 position = time div10
    7 position = mod10 level
    8 position = div10 level

    Coding

    The operation is applied to all positions: XOR 5. If, after performing this operation, a two-digit number is obtained, then subtract 4.

    Password Generation Example
    Create a password that saves these parameters:
    • level (9)
    • life (7)
    • time (35)

    We calculate:
    1)
    1 position = 0
    2 position = 0
    3 position = 0
    4 position = 7
    5 position = 35 mod10
    6 position = 35 div10
    7 position = 9 mod10
    8 position = 9 div10

    2)
    1 position = (7 + 9 + 0) mod10 = 6
    2 position = (5 + 3) mod10 = 8
    3 position = (9 + 0) mod10 = 9
    4 position = 7
    5 position = 5
    6 position = 3
    7 position = 9
    8 position = 0

    Now we code the resulting values:
    6 XOR 5 = 3
    8 XOR 5 = 13-4 = 9
    9 XOR 5 = 12-4 = 8
    7 XOR 5 = 2
    5 XOR 5 = 0
    3 XOR 5 = 6
    9 XOR 5 = 12-4 = 8
    0 XOR 5 = 5

    Ready password: 39820685

      
      

    Prince of Persia (Sega Genesis)


    image

    Theory


    Password consists of 6 positions. These positions save these game parameters:

    US version:
    • level (1-13)
    • time (0-60)
    • life (1-8)

    EU version:
    • level (1-13)
    • time (0-60)
    • life (0-8)

    If you play this game, it is better to choose the EU version, as:
    • 4 additional levels added in EU version
    • EU version has musical accompaniment at levels
    • in the EU version there is a bug immortality

    Generation

    We conditionally divide the password into two parts (each part consists of three positions).

    The first part saves time:
    (10545 * time) mod 17576

    The resulting number from 10 CC is converted to 26 SS (SS is the number system).
    Then the obtained value needs to be mirrored. If the length of the received "password" is less than 3 characters, then the required number of zeros is added to the right.

    The second part saves time, number of lives and level:
    ((10545 * time) + (14157 * (level-1)) + (5145 * life)) mod 17576

    The resulting number from 10 CC is converted to 26 SS. Then the obtained value needs to be mirrored. If the length of the received "password" is less than 3 characters, then the required number of zeros is added to the right.

    Coding

    Symbols in positions take the values ​​"ABCDEFGHIJKLMNOPQRSTUVWXYZ", where A = 0, B = 1 ... Y = 24, Z = 25.

    Password Generation Example
    Create a password that saves these parameters:
    • level (12)
    • life (6)
    • time (39)

    We calculate:

    The first part of the password:
    (10545 * 39) mod 17576 = 411255 mod 17576 = 7007
    7007 (10 SS) = 10.9.13 (26 SS)
    Mirror the resulting value:
    10.9.13 = 13.9.10

    The second part of the password:
    ((10545 * 39) + (14157 * (12-1)) + (5145 * 6)) mod 17576 = (411255 + 155727 + 30870) mod 17576 = 268
    268 (10 CC) = 10.8 (26 CC)
    Mirror the resulting value:
    10.8 = 8.10
    Append zero on the right:
    8.10.0

    Now we encode the resulting values:
    13,9,10,8,10,0 = NJKIKA

    Interesting bug


    The game has a bug with which you can get immortality. To activate it, you need to enter a password with zero lives in the EU version. Now the prince is not afraid of enemies (the main thing is not to remove the weapons). But with the activation of the bug, the player gets one problem. If you fall from a great height, which threatens with the loss of all lives, then nothing will happen. But if you fall from a height at which the prince should spend his life, then the game will freeze and the screen will turn red.

     

    Prince of Persia (SNES)


    image

    So it's time to talk about the best implementation of the first Persian prince (in my humble opinion).

    Compared with all previous versions, for SNES they made more colorful locations, improved parry, partially changed the initial levels and added many new stages (total 20). And so that the player does not suffer, the time is increased to 120 minutes (play as much as you like).

    Theory


    The password consists of 7 positions, each position consists of 5 bits, total 7 * 5 = 35 bits. These bits store these game parameters:
    • level (1-20)
    • time spent on the game (0-7200) (in seconds)
    • life (0-15)

    Now let's see what the raw password consists of:

    (? (0) , S (0) , L (3) , T (0) , T (7) ) (C1 (0) , S (1) , L (2) , T (1) , T (6 ) ) (C2 (0) , S (2) , L (1) , T (2) , T (5) ) (C3 (0) , S (3) , L (0) , T (3) , T (4) )  

    (C4 (0) , S (4) , U (0) , T (8) , T (9) ) (C4 (1), T (10) , T (11) , T (12) , T (13) ) (C4 (2) , C4 (3) , C4 (4) , T (14) , T (15) )

    * in brackets bit number specified.

    Designations

    S - level number ((1-20) -1) in binary CC
    L - number of lives (0-15) in binary CC
    U - unused bits.
    ? - always equal to zero.
    T - time spent on the game (0-7200).
    The time is written in the password, in accordance with a special formula:

    (time * 7) + (5, if time mod60 ≠ 0) + (5 * ((time div60) -1)) + random (0-6 + ((5, if time mod60 = 0) or (14534 if time div 7200 = 1)))

    C1 = S (1) XOR S (4) XOR L (0) XOR L (1) XOR T (0) XOR T (1) XOR T (2) XOR T (5) XOR T (7) XOR T (8) XOR T (10) XOR T (13) XOR T (15) XOR U (0) XOR 1

    C2 = S (1) XOR S (2) XOR S (3) XOR L (0) XOR L (2) XOR L (3) XOR T (1) XOR T (4) XOR T (5) XOR T (8) XOR T (9) XOR T (10) XOR T (12) XOR T (14) XOR T (15)

    C3 = S (0) XOR S (1) XOR S (3) XOR L (2) XOR T (2) XOR T (3) XOR T (5) XOR T (6) XOR T (7) XOR T (8 ) XOR T (9) XOR T (11) XOR T (14) XOR U (0)

    C4 = S (0), L (3), T (0), T (7)
         + S (1), L ( 2), T (1), T (6)
         + S (2), L (1), T (2), T (5)
         + S (3), L (0), T (3), T ( 4)
         + S (4), U (0), T (8), T (9)
       + T (10), T (11), T (12), T (13)
       + 0, 0, T (14 ), T (15)

    Coding

    US / EU: "BTL3GY7Q9CVM4HZ8R + DWN5J12S! FXP6K."
    JP: "AIQYEMU34BJRZFNVW5CKS1GOPX6DLT2H."

    Password Generation Example
    Create a password that saves these parameters:
    • level (15)
    • life (13)
    • time (95.00) or (5700 seconds)
    • unused bit activated

    Переводим значения в двоичную систему счисления:
    Уровень = 15-1 =14 = 01110
    Жизни = 13 = 1101

    Вычисляем время:
    Время = 7200-5700=1500
    (1500*7) + (0, т.к. 1500 mod 60 = 0) + (5*(25-1)) + рандом (т.к. 1500 mod 60 = 0, то рандом = 0-6+5 = 0-11. Я выбираю рандом = 11.)
    10500 + 120 + 11 = 10631 = 0010100110000111

    Вычисляем контрольные суммы:
    C1 = 1 XOR 0 XOR 1 XOR 0 XOR 1 XOR 1 XOR 1 XOR 0 XOR 1 XOR 1 XOR 0 XOR 1 XOR 0 XOR 1 XOR 1 = 0
    C2 = 1 XOR 1 XOR 1 XOR 1 XOR 1 XOR 1 XOR 1 XOR 0 XOR 0 XOR 1 XOR 0 XOR 0 XOR 0 XOR 0 XOR 0 = 0
    C3 = 0 XOR 1 XOR 1 XOR 1 XOR 1 XOR 0 XOR 0 XOR 0 XOR 1 XOR 1 XOR 0 XOR 1 XOR 0 XOR 1 = 0
    C4 = 0111 + 1110 + 1010 + 1100 + 0110 +0101 + 0000 = 110110

    Записываем получившийся пароль в двоичной С.С.:
    (00111) (01110) (01010) (01100) (00110) (10101) (10100)

    Записываем получившийся пароль в десятичной С.С.:
    (7) (14) (10) (12) (6) (21) (20)

    Теперь кодируем получившиеся значения:
    US/EU: QZV475N
    JP: 3NJZU1S

      
      

    Prince of Persia 2: The Shadow & The Flame


    The first part has gained immense popularity. The sequel was just a matter of time. And four years later, a sequel appeared. But the new part did not find a storm of applause, which awarded the first part. And ported it to a small number of gaming platforms. It's a pity! I believe that the second part is better than the first. Now the prince does not travel through monotonous dark locations, but through the whole of Persia. But enough lyrics, it's time to get down to business.

    The game has got two ports that save gameplay with passwords. These ports are terrible (better play the DOS version). The SNES version turned out to be clumsy: the music is rattling, the sounds are nasty, the gameplay is killed and to all this, the game cut level 14, in which the battle with Jaffar should take place.

    The version for Sega Genesis is no better. Since this game was not officially released, I could only see it with the help of a pirate cartridge on Sega. And what was my disappointment when I reached level 9 and found out that due to a bug with the statue of the horse, this level is impassable. The game can be completed, but for this you need a password to level 10 ... but in the password book, this game was not.

      

    Prince of Persia 2: The Shadow & The Flame (SNES)


    image

    Theory


    The password consists of 6 positions, each position consists of 4 bits, total 6 * 4 = 24 bits. These bits store these game parameters:

    US / EU versions:
    • level (1-13)
    • time (0-164)
    • life (1-15)

    Now let's see what the raw password consists of:

    (S (3) , S (2) , S (1) , S (0) ) (L (3) , L (2) , L (1) , L (0) ) (T1 (3) , T1 ( 2) , T1 (1) , T1 (0) ) (T2 (3) , T2 (2) , T2 (1) , T2 (0) )
     
    (C1 (3) , C1 (2) , C1 (1) , C1 (0) ) (C2 (3) , C2 (2) , C2 (1) , C2 (0) )

    Designations

    S - (level - 1) in binary S.S.
    L is the number of lives (1-15) in binary S.S.
    T1 - 1 value (0-15) in binary C.S.
    T2 - 2 value (0-15) in binary C.S.
    1 value - the number of time units (the number of tens of 1 value goes into 2 value).
    2 value - the number of tens of times (the number of tens of 2 values ​​goes into the number of hundreds).
    C1 = (sum of positions 1 to 3) mod16
    C2 = ((sum of positions 1 to 3) div16) + 4 position

    Coding

    The characters in the positions take the values ​​“BCDFGHJKLMNPRTVW”, where B = 0 ... W = 15.

    Features of saving time and password performance:

    If you think about it, everything is simple - one position is responsible for the time mod10, and the other for the time div10 and the maximum amount of time is 99. But it's not so simple. The maximum value of units and tens is not checked in the password. What does it mean? In the password, you can set the number of tens and units from 0 to 15. If I create a password where the number of units is 15, then there will be 5 units, and 1 will go into the number of tens, similarly, if I create a password where the number of tens is 15, then tens will be 5, and 1 will go into the number of hundreds.

    It turns out that the maximum amount of time is:

      150
    +015
       =
      165

    But above, I have already described that the maximum value = 164. And why? This is due to the checksum. If C2≥16, then the password will not work. I will explain this aspect a bit later, and now we will move on to password generation (to understand the further narration, I advise you to read the example of password generation).

    Password Generation Example
    Create a password that saves these parameters:
    • level (2)
    • life (1)
    • time (163)

    We translate the values ​​into a binary number system:

    Level = 2-1 = 1 = 0001
    Life = 1 = 0001

    We calculate the time:

    163 = 150 + 13
    1 value = 13 = 1101
    2 value = 15 = 1111

    We write the raw password and calculate 2 checksums:

    (0001) (0001) (1101) (1111) (****) (****)

    C1 = 0001 + 0001 + 1101 = 1111
    C2 = (0001 + 0001 + 1101) mod16 + 1111 = 0000 + 1111 = 1111

    (0001) (0001) (1101) (1111) (1111) (1111)

    We write the resulting password in decimal C.S .:

    (1) (1) (13) (15) (15) (15)

    Now we encode the resulting values:

    CCTWWW

    Total


    I created a CCTWWW password. If you increase the level by 1, then the password will not work, because C2 will be 16. The idle password will be: DCTWBB. Now let's check the game "for lice." The second level is very short, so it can be completed without wasting time. If I pass the level, what password will the game give me?

    Suddenly there is a secret in the password system that I have not revealed? What if…

    Password
    image

    ... here is the infection. In the game, not only the gameplay is terrible, but the password system is unfinished.
       
      

    Prince of Persia 2: The Shadow & The Flame (Sega Genesis)


    image

    Theory


    Password consists of 5 positions. These positions save these game parameters:

    • level (1-14)
    • time (0-99)
    • life (1-12)

    Generation

    1 position = (level) or (level (1-7) +15)
    2 position = (time mod10) or (time mod10 + 10) or (time mod10 (0-2) + 20)
    3 position = (1 position + 2 position + 4 position + 5 position) mod23
    4 position = (time div10) or (time div10 + 10) or (time div10 (0-2) + 20)
    5 position = (life -1) or (life (1- 11) + 11)

    Coding

    The characters in the positions take the values ​​“HFMGRANBPWTEIZVQDLYSKCX”, where H = 0, F = 1 ... C = 21, X = 22.

    Password Generation Example
    Create a password that saves these parameters:
    • level (11)
    • life (10)
    • time (92)

    Вычисляем:

    Первый шаг:
    1 позиция = уровень сохраняется по одной из двух формул. Так как уровень больше 7, то сохранить данные можно только по первой формуле (11).
    2 позиция = время сохраняется по одной из трёх формул. 92 mod10 = 2. Это значение можно закодировать по любой формуле и я выбираю третью (2+20 = 22)
    3 позиция = 0
    4 позиция = время сохраняется по одной из трёх формул. 92 div10 = 9. Это значение можно закодировать только по первой и второй формуле, и я выбираю вторую (9+10 = 19)
    5 позиция = жизни сохраняются по одной из двух формул. Это значение можно закодировать по любой формуле и я выбираю вторую (10+11 = 21).

    Второй шаг:
    1 позиция = 11
    2 позиция = 22
    3 позиция = (11 + 22 + 19 + 21)mod 23 = 4
    4 position = 19
    5 position = 21

    Now we encode the resulting values:
    EXRSC

      

    Conclusion


    So the list of games came to an end. Well, good luck, thanks for reading.

    Also popular now: