This page contains notes for the game Elektra.
How the Debug Menu Works#
The game has a variable, labeled y, which is updated every time a button is pressed on the main menu.
Upon pressing a button, the value contained in y gets bitshifted to the left by 4, and the inputted number is then summed to the new value. For example, y starts at 0. Upon pressing 6, the value then becomes 6, as 0 bitshifted to the left by 4 is still 0. Afterwards, upon pressing 4, the value becomes 100, as 6 bitshifted by 4 is 96, and 96 plus 4 is 100. A representative table can be seen below:
Action |
Value of y (Bits) |
Value of y (Decimal) |
|---|---|---|
N/A |
0000 0000 |
0 |
Press 6 |
0000 0110 |
6 |
Press 4 |
0110 0100 |
100 |
With that said, the game compares the value of y to five values (8610946, 9510932, 8819254, 1251128, 8614979), which associated with each of the five available codes, and if they're correct, a second variable, named x, becomes 1, enabling the "CHEAT" label on the main menu.
Here's the code with this formula located in Elektra.class:
// f - Number inputted
// h[] - Array with valid values
b var1 = z;
if (b.v != 0 && f != -1) {
y = (y << 4) + f & 16777215;
for(int var0 = 0; var0 < h.length; ++var0) {
if (y == h[var0]) {
x |= 1 << var0;
}
}
}
The same functionality exists in at least some J2ME games developed by MForma. For example, Blade Trinity.
(Source: UltimateGoblin)