Jun 16, 2012

Scratch another enemy of the list of enemies to crack!

Finished with the movement code of Medusa Heads. It was a very informative endeavor. Of all the codes I intend to crack in CV3, those pertaining to sinusoidal movement were at the top of my list. When you don't have access to pi or cosines, how the hell do you make a sine wave? Well, here's how Konami did it:


vert_2 -= y - ystart + $100 & $FF
c_bit = vert_2 >= 0
vert_2 = vert_2 + $100 & $FF

vert_3 -= $FF * (y < ystart) + !c_bit + $100 & $FF
vert_3 = vert_3 + $100 & $FF

vert_1 += vert_2
c_bit = vert_1 > $FF
vert_1 &= $FF;

vspd = (vert_3 ^ $80) - $80 + c_bit
 

Again, I had to work around the fact that GM uses qwords whereas the NES used bytes. The conversion was simple enough: add $100 then AND by $FF. Converting an unsigned byte to a signed byte (vert_3) was trickier, but with a little logic I figured it out: XOR by $80 then subtract $80.

As with the generic movement code for skeletons, the movement code for Medusa Heads is used for other enemies as well. Now that I have a working translation, I'll side-track from the enemies and work on CV3's floating platforms.

No comments:

Post a Comment

©TheouAegis Productions™. Powered by Blogger.