Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HOW MAIN MENU EVENTS ARE SELECTED
- ---------------------------------
- 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:
- - Leg Shake
- - Kremlings bullying DK
- - Leg Shake (Different event, essentially a copy of the first leg shake)
- - Rambi chasing the beavers
- - Rambi riding on a wooden barrel
- - One Kremling shaking it's legs
- - A stack of beavers of varying sizes
- - Five mini beavers approaching DK
- - Two kremlings chasing butterflies
- - Scene turns to night (Night Cycle)
- - Scene starts to storm (Rain Cycle)
- Rain Cycle isn't viewable until after Night Cycle has been watched.
- Play around with the code: https://theballaam96.github.io/menu_events.html
- DETAILED EXPLANATION (THE DEVS DEFINITELY TOOK A COMPLEX APPROACH TO THIS PROBLEM)
- If you prefer looking at code compared to step by step: https://github.com/theballaam96/theballaam96.github.io/blob/master/menu_events.html#L898
- If you prefer a flow chart: https://imgur.com/UpUttaC
- Here is the process the game takes:
- 1) Decrease the timer value by one
- 2) If the timer exceeds 0, jump to step 7
- 3) Based on the current event, it reads an internal array in memory (Located at 0x800336A4), and grabs a signed 16-bit slot value.
- 4) If the slot value is equal to -5, jump to step 7
- 5) If the slot value does not equal -4, -3 or -2, jump to step 7
- 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.
- 7) A secondary slot value is set as equal to the first slot value.
- 8) If the slot value is greater than -6, jump to step 13
- 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
- 10) If DK is in the process of throwing a barrel, jump to step 12
- 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
- 12) The current menu event is incremented by two, the timer is read from the 0x800336A4 array.
- 13) If the secondary slot value is less than 0, jump to step 15
- 14) The current menu event is incremented by two, the timer is read from the 0x800336A4 array. The process finishes here.
- 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.
- 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.
- 17) A menu event offset is set as -1, and the current event is set to 0.
- 18) If the event index is greater than 10, then the event index will be set to 0
- 19) The game grabs a list of all the previous events watched. This data is reset any time you exit the main menu map.
- 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
- 21) The event index is incremented by 1
- 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
- 23) If the event index matches the initially proposed event index, then the game resets the "previous events watched" data
- 24) The game checks to see if this new event index has been watched before, if it has, then jump back to step 22
- 25) The event index is incremented by 1
- 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
- 27) A counter is set to 0
- 28) The counter is incremented by 1
- 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.
- 30) An event offset value is set to one higher than the current event value
- 31) If the slot value equals -1, jump to step 36
- 32) The current event is set to the event offset value
- 33) The game reads the array at 0x800336A4 based on the current event value (not index). This will be a secondary slot value
- 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
- 35) jump to step 37
- 36) The event offset value is set to the "current event + 1"
- 37) The current event value is incremented by 1
- 38) If the counter is not equal to the event index, jump back to step 28
- 39) Huzzah, the current event value is now your new event value.
Advertisement
Add Comment
Please, Sign In to add comment