Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------
- HOW DK64 DETERMINES "SWITCH LUCK"
- ---------------------------------
- Mad Jack switches are random, but at least there's logic behind how the game determines where to place the switches. Here's how it's done.
- The code for Mad Jack switches is split into two parts, the white switch and the blue switch. The code for the white switch is practically identical to the code for the blue switch. For reference, the white switch is determined first.
- This takes place at the start of the last jump, where DK's square is based on what square Mad Jack *thinks* he's going to at the point where he's just about to take his last jump. This means you can do a fake-out just before this point to trick the system.
- For each switch the following process takes place:
- 1) The game calls a function to cycle RNG. This takes the old RNG value, and multiplies it by 31,415,821 (0x1DF5E0D). The lower 32 bits of this result are taken. This new result is incremented by one and then the lower 32 bits of that is set as the new RNG value.
- 2) Bits 17>15 are then read from the RNG value. To be clearer on this, if we say the new RNG value is 0x80142069, that value can be represented in binary as:
- 1000 0000 0001 0100 0010 0000 0110 1001
- Bits 17>15 are the following:
- ---- ---- ---- --00 0--- ---- ---- ----
- AKA 000, or in decimal: 0.
- If you're unsure of the binary base system, this may help make things a little clearer. https://www.rapidtables.com/convert/number/binary-converter.html
- 3) This result is essentially an index for a table that is located in a static part of memory:
- White Switches: 0x80035BDC
- Blue Switches: 0x80035BE4
- Taking the value at that index in the table produces a switch location value that the game can interpret:
- INDEX WHITE BLUE
- 0 (000) Row 1, Col 1 Row 1, Col 2
- 1 (001) Row 1, Col 3 Row 1, Col 4
- 2 (010) Row 2, Col 2 Row 2, Col 1
- 3 (011) Row 2, Col 4 Row 2, Col 3
- 4 (100) Row 3, Col 1 Row 3, Col 2
- 5 (101) Row 3, Col 3 Row 3, Col 4
- 6 (110) Row 4, Col 2 Row 4, Col 1
- 7 (111) Row 4, Col 4 Row 4, Col 3
- 4) The game then validates this proposed switch location to make sure the switch isn't in any of the following locations:
- - Mad Jack's Square
- - The Kong's Square
- - The four squares directly west, east, south & north (In that order) of the Kong's square.
- If the game determines that the proposed switch is on one of those squares, then it goes back to step 1 and starts the process for THE SWITCH IN QUESTION all over again
- ------------------
- "So What"
- Well, not only does this information help make TASing Mad Jack easier as there is potential for a tool to be built into ScriptHawk to list the next RNG value which provides a desired result, but there's also one potential thing for RTA.
- Whilst the index chosen is random, due to the pseudo-random nature of 1990s RNG Cycling, there may be bias towards some indexes meaning that certain positions become more likely to be more favourable. I'll try working on something for https://theballaam96.github.io/ in the coming days.
- UPDATE: https://theballaam96.github.io/mj_luck_calculator.html
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement