Skip to content

Prince Froggy

Raidenthequick edited this page Aug 3, 2017 · 4 revisions

Health/Damage

Prince Froggy's health is stored as damage so it starts at 0 and gets added to each hit instead of subtracted from a max health value. He dies when it goes above $FFFF. The memory address for it is $7A38,x and because his uvula sprite should always be at slot $5C, this expands out to $701A94.

Damage is computed on each egg hit to the uvula. The formula for damage can be summarized as follows:

-(X Distance between egg and uvula)/2 + (either 0 or X velocity of egg) + (positive or negative Y velocity of egg)

The X distance between egg and uvula may be negative; it is simply egg X coordinate minus uvula X coordinate. The game first takes the negative of that value, then takes only the low byte of that and shifts it up to the high byte (using XBA) then sign-extend shifts it once to the right , effectively negating, dividing by 2 & preserving sign.

"Either 0 or X velocity of egg": well, which one? Based on what? The sign bits of both the egg X velocity and the distance value computed from just above are compared; if they're the same sign value, we add X velocity of egg. If the sign values differ, we add nothing (0). In plainer terms: If egg X is moving in the same direction as which side the egg is on compared to uvula, we add 0, otherwise add egg X velocity. For example, if egg is moving right and it is on the right side of the uvula, nothing is added. Whereas if the egg is moving left and it is on the right side, we do add the egg X velocity. The velocity in any case is added directly; not tampered with as the distance is.

"Positive or negative Y velocity of egg"? Again, which one? Similar to the above, sign bits of two values are compared. This time, the two values are the untampered egg X distance to uvula (not the negated XBA'd divided by 2) and the egg Y velocity. If the signs are different, we add untampered egg Y velocity; if they're the same sign, we first take the negative of the egg Y velocity (whether it was negative or positive, it becomes the opposite) then add that on instead. In plainer terms: If egg Y is moving up and is on the right side of the uvula, or moving down and on the left side of the uvula, add egg Y velocity as-is. If moving up and on left side, or moving down and on right side, take the negative of the egg Y velocity first then add that.

After all of this computation, the absolute value of the final result (sum of the three terms) is finally added onto $701A94. This means if the value is not positive, take the negation to make it positive first, then add it on. The way the game checks for death is simply checking the carry bit of this add, meaning anything over $FFFF will wrap back around through $0000 and carry bit is set, hence "dead".

Clone this wiki locally