📜 ⬆️ ⬇️

Generating passwords for the Prince of Persia series of games

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

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


image

Theory


The password consists of 6 positions. These positions save the game data parameters:

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 = ((the sum of positions from 1 to 5) + 10) mod26

Coding

The characters in the 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)

Calculate:
one)
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 we 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 the architecture of the levels. Conditionally divide the screen into 3 floors.

Floors
image

If a prince has life from 1 to 7, then when falling from the 2nd floor to 1, lives are not wasted. And when falling from the 3rd floor to 1, 1 life is spent. If 0 lives, then everything happens the opposite. 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 damaging 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 passing the level, the bug disappears and the prince will again have 0 lives. And if you attack a guard with zero lives, he will simply ignore you and it will be impossible to kill him.

Ghost prince
image

This is how it is.


Prince of Persia (Game Boy / Game Boy Color)


image

Theory


The password consists of 8 positions. These positions save the game data parameters:

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 = mod10 time
6 position = div10 time
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 4 must be subtracted.

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

Calculate:
one)
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 encode 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


The password consists of 6 positions. These positions save the game data parameters:

US version:

EU version:

If you play this game, it is better to choose the EU version, since:

Generation

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 of 10 CC is converted to 26 SS (SS - number system).
Then the resulting value must be mirrored. If the length of the received "password" is less than 3 characters, then the right number of zeros is added to the right.

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

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

Coding

The characters in the 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)

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 SS) = 10.8 (26 SS)
Mirror the resulting value:
10.8 = 8.10
We add to the right zero:
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 in the EU version with zero number of lives. Now the prince is not afraid of enemies (the main thing - do not remove the weapon). But with the activation of the bug, the player gets one problem. If you fall from a great height that threatens the loss of all lives, nothing will happen. But if you fall from a height at which the prince has to spend his life, the game will freeze and the screen will turn red.


Prince of Persia (SNES)


image

So it is time to talk about the best realization of the first Persian prince (in my humble opinion).

Compared to 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, a total of 7 * 5 = 35 bits. These bits save game data parameters:

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 is the number of bits.

Legend

S - level number ((1-20) -1) in binary CC
L is the 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 recorded in the password, in accordance with the special formula:

(time * 7) + (5, if time is mod60 ≠ 0) + (5 * ((time div60) -1)) + random (0-6 + ((5 if time is 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

We translate the values ​​into the binary number system:
Level = 15-1 = 14 = 01110
Life = 13 = 1101

Calculate time:
Time = 7200-5700 = 1500
(1500 * 7) + (0, because 1500 mod 60 = 0) + (5 * (25-1)) + random (since 1500 mod 60 = 0, then random = 0-6 + 5 = 0-11. I choose random = 11.)
10500 + 120 + 11 = 10631 = 0010100110000111

Calculate checksums:
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

Write the resulting password in the binary SS:
(00111) (01110) (01010) (01100) (00110) (10101) (10100)

Write the resulting password in decimal SS:
(7) (14) (10) (12) (6) (21) (20)

Now we encode the resulting values:
US / EU: QZV475N
JP: 3NJZU1S



Prince of Persia 2: The Shadow & The Flame


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

The game has got two ports that save the 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 has cut level 14, in which the battle with Jaffar should take place.

The Sega Genesis version is no better. Since this game was not officially released, I could only see it with the help of a pirate cartridge on Segou. And what my disappointment turned out to be when I reached level 9 and learned that because of a bug with a statue of a horse, this level is impassable. The game can be passed, but for this you need a password for level 10 ... and 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, a total of 6 * 4 = 24 bits. These bits save game data parameters:

US / EU versions:

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) )

Legend

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 S.S.
T2 - 2 value (0-15) in binary S.S.
1 value - the number of units of time (the number of tens of 1 value goes to 2 value).
2 value - the number of tens of time (the number of tens from 2 values ​​goes into the number of hundreds).
C1 = (sum of positions 1 through 3) mod16
C2 = ((sum of positions from 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 health:

If you think about it, then everything is simple - one position is responsible for the mod10 time, and the other for div10 and the maximum amount of time is 99. But everything is not so simple. The password does not check the maximum value of units and tens. 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 the units will be 5, 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 little later, and now we will move on to generating a password (to understand the further narration, I advise you to read an example of generating a password).

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

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

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

Calculate time:

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

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)

Write the resulting password in decimal SS:

(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 become equal to 16. A non-working password will be: DCTWBB. And now let's check the game for lice. The second level is very short, so you can pass it without loss of time. If I pass a level, what password will the game give me?

Suddenly there is a secret in the password system that I didn’t reveal? What if…

Password
image

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


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


image

Theory


The password consists of 5 positions. These positions save the game data parameters:


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)

Calculate:

First step:
1 position = level is saved by one of two formulas. Since the level is greater than 7, the data can be saved only by the first formula (11).
2 position = time is saved by one of the three formulas. 92 mod10 = 2. This value can be encoded using any formula and I choose the third (2 + 20 = 22)
3 position = 0
4 position = time is saved by one of the three formulas. 92 div10 = 9. This value can be encoded only by the first and second formula, and I choose the second (9 + 10 = 19)
5 position = lives are saved by one of two formulas. This value can be encoded using any formula and I choose the second one (10 + 11 = 21).

Second step:
1 position = 11
2 position = 22
3 position = (11 + 22 + 19 + 21) mod 23 = 4
4 position = 19
5 position = 21

Now we encode the resulting values:
EXRSC


Conclusion


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

Source: https://habr.com/ru/post/309722/


All Articles