Pokérus: Difference between revisions

→‎Infection and spread details: whoops forgot a mask and had a wrong mask
(→‎Generation II: Technical details)
(→‎Infection and spread details: whoops forgot a mask and had a wrong mask)
Line 72: Line 72:
The spread code checks if a random byte is less than 85 and if the party has multiple members before proceeding as follows: if the spreader is the last party member, or if a random byte is less than 128, iterate backwards, otherwise iterate forwards. If the member being iterated over has an active infection, they are skipped over and become the spreader. If they are clear and never had the Pokérus, they are infected. The '''Y''' value for an infection is generated from the '''X''' value as it is for a spontaneous infection, unlike in future games where it is copied. The iteration stops when a member is newly infected, when it reaches a cured member, or when it would be about to pass through the beginning or end of the party.
The spread code checks if a random byte is less than 85 and if the party has multiple members before proceeding as follows: if the spreader is the last party member, or if a random byte is less than 128, iterate backwards, otherwise iterate forwards. If the member being iterated over has an active infection, they are skipped over and become the spreader. If they are clear and never had the Pokérus, they are infected. The '''Y''' value for an infection is generated from the '''X''' value as it is for a spontaneous infection, unlike in future games where it is copied. The iteration stops when a member is newly infected, when it reaches a cured member, or when it would be about to pass through the beginning or end of the party.


The new infection code first checks if the flag for having visited Goldenrod City is set, terminating if not. Then, it checks if a random byte is equal to zero and another random byte is less than three, terminating if not. It then chooses a random party member by generating a random byte and keeping its bottom three bits, rerolling until that number is a valid party index. If that party member has ever had the Pokérus, the code terminates. Otherwise, a random byte is rolled, rerolling if zero until not zero. This byte shall be represented as '''AB''' (not to be confused with registers A and B) in the same way that the Pokérus byte is represented as '''XY'''. If '''A''' is not zero, '''B''''s bottom three bits (bitwise ''and'' with seven) are copied as a four-bit value, incremented, and put into '''X''', and '''X''''s bottom two bits (bitwise ''and'' with four) are copied as a three-bit value, incremented, and put into '''Y'''. Otherwise, it is likely intended to copy '''B''' into '''X''', but, perhaps due to a misplaced load, zero is copied into '''X''' instead; '''Y''' is then derived from '''X''' with the same code as with '''A''' not zero, but since '''X''' is always zero, '''Y''' is always one. (If the misplaced load is placed in a more logical place, the '''Y''' value ends up always being one anyway, so there may have been more required effort to make the code work as intended.)
The new infection code first checks if the flag for having visited Goldenrod City is set, terminating if not. Then, it checks if a random byte is equal to zero and another random byte is less than three, terminating if not. It then chooses a random party member by generating a random byte and keeping its bottom three bits (bitwise ''and'' with seven), rerolling until that number is a valid party index. If that party member has ever had the Pokérus, the code terminates. Otherwise, a random byte is rolled, rerolling if zero until not zero. This byte shall be represented as '''AB''' (not to be confused with registers A and B) in the same way that the Pokérus byte is represented as '''XY'''. If '''A''' is not zero, '''B''''s bottom three bits (bitwise ''and'' with seven) are copied as a four-bit value, incremented, and put into '''X''', and '''X''''s bottom two bits (bitwise ''and'' with three) are copied as a three-bit value, incremented, and put into '''Y'''. Otherwise, it is likely intended to copy '''B''' into '''X''', but, perhaps due to a misplaced load, zero is copied into '''X''' instead; '''Y''' is then derived from '''X''' with the same code as with '''A''' not zero, but since '''X''' is always zero, '''Y''' is always one. (If the misplaced load is placed in a more logical place, the '''Y''' value ends up always being one anyway, so there may have been more required effort to make the code work as intended.)


'''X''' values of zero and eight can occur naturally: the latter is as designed, the former is due to the above bug. Due to this bug, an '''X''' value above eight cannot occur naturally. Probabilities of each strain is as follows:
'''X''' values of zero and eight can occur naturally: the latter is as designed, the former is due to the above bug. Due to this bug, an '''X''' value above eight cannot occur naturally. Probabilities of each strain is as follows:
20

edits