theballaam96

Main Menu Events Explanation

Nov 17th, 2020 (edited)
493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.03 KB | None | 0 0
  1. HOW MAIN MENU EVENTS ARE SELECTED
  2. ---------------------------------
  3.  
  4. TL;DR Explanation - RNG selects a random index. Checks the index over all of the previous events watched, if it's been already watched, it increments that index by one until it finds a new value to pick. Indexes go in the following order:
  5. - Leg Shake
  6. - Kremlings bullying DK
  7. - Leg Shake (Different event, essentially a copy of the first leg shake)
  8. - Rambi chasing the beavers
  9. - Rambi riding on a wooden barrel
  10. - One Kremling shaking it's legs
  11. - A stack of beavers of varying sizes
  12. - Five mini beavers approaching DK
  13. - Two kremlings chasing butterflies
  14. - Scene turns to night (Night Cycle)
  15. - Scene starts to storm (Rain Cycle)
  16. Rain Cycle isn't viewable until after Night Cycle has been watched.
  17.  
  18. Play around with the code: https://theballaam96.github.io/menu_events.html
  19.  
  20. DETAILED EXPLANATION (THE DEVS DEFINITELY TOOK A COMPLEX APPROACH TO THIS PROBLEM)
  21. If you prefer looking at code compared to step by step: https://github.com/theballaam96/theballaam96.github.io/blob/master/menu_events.html#L898
  22. If you prefer a flow chart: https://imgur.com/UpUttaC
  23.  
  24. Here is the process the game takes:
  25. 1) Decrease the timer value by one
  26. 2) If the timer exceeds 0, jump to step 7
  27. 3) Based on the current event, it reads an internal array in memory (Located at 0x800336A4), and grabs a signed 16-bit slot value.
  28. 4) If the slot value is equal to -5, jump to step 7
  29. 5) If the slot value does not equal -4, -3 or -2, jump to step 7
  30. 6) The next event is set as two values higher than the current event. The time until the next event is deduced from the same array as mentioned in step 3, but at a memory location two bytes further along. If the slot value is equal to 4, 3 or 2, the process finishes here.
  31. 7) A secondary slot value is set as equal to the first slot value.
  32. 8) If the slot value is greater than -6, jump to step 13
  33. 9) A third slot value is set as "0 - (slotValue + 6)", and is converted to be inside the bounds of a signed 16-bit integer
  34. 10) If DK is in the process of throwing a barrel, jump to step 12
  35. 11) The secondary slot value is set as the output of a search of a different array in memory (Located at 0x80033724), using the third slot value as an index for that search
  36. 12) The current menu event is incremented by two, the timer is read from the 0x800336A4 array.
  37. 13) If the secondary slot value is less than 0, jump to step 15
  38. 14) The current menu event is incremented by two, the timer is read from the 0x800336A4 array. The process finishes here.
  39. 15) RNG is cycled once. The game tries to find a floating point value of the same value as the new RNG. Once a closest floating point value has been found, it takes the Hex representation and takes away 0x10000000 from it. This new hex representation is converted back into a float and multiplied by 10. The game rounds this to the nearest integer (round to zero method). This is stored as an attempted event index.
  40. 16) RNG is cycled again, the game takes the lowest 7 bits of the RNG value and sets the timer as these 7 bits plus 300.
  41. 17) A menu event offset is set as -1, and the current event is set to 0.
  42. 18) If the event index is greater than 10, then the event index will be set to 0
  43. 19) The game grabs a list of all the previous events watched. This data is reset any time you exit the main menu map.
  44. 20) By comparing the proposed event index and the list of "previous events watched", the game determines whether the proposed event index is tied to an event that has already been watched before. If it hasn't been watched before, jump to step 26
  45. 21) The event index is incremented by 1
  46. 22) The event index is checked to ensure it remains within the confines of a 16 bit integer. If the event index equals 11, then the event index is set to 0
  47. 23) If the event index matches the initially proposed event index, then the game resets the "previous events watched" data
  48. 24) The game checks to see if this new event index has been watched before, if it has, then jump back to step 22
  49. 25) The event index is incremented by 1
  50. 26) The game adds the event index to the list of watched events. If the event index is equal to 0, then the process ends here
  51. 27) A counter is set to 0
  52. 28) The counter is incremented by 1
  53. 29) The game reads the array at 0x800336a4 based on the current event value (not the index, the value), this is regarded as a slot value.
  54. 30) An event offset value is set to one higher than the current event value
  55. 31) If the slot value equals -1, jump to step 36
  56. 32) The current event is set to the event offset value
  57. 33) The game reads the array at 0x800336A4 based on the current event value (not index). This will be a secondary slot value
  58. 34) If this secondary slot value is not equal to -1, set the event offset value is set to the "current event + 1" and jump back to step 32
  59. 35) jump to step 37
  60. 36) The event offset value is set to the "current event + 1"
  61. 37) The current event value is incremented by 1
  62. 38) If the counter is not equal to the event index, jump back to step 28
  63. 39) Huzzah, the current event value is now your new event value.
Advertisement
Add Comment
Please, Sign In to add comment