I'm still here and still working on GMVania. If i worked the graveyard shift, I"d have more time to work on GMvania (I used to do most of my sprite ripping and programming during my 3 hour break at work, also got decent exercise lugging my old laptop to work with me every night).
Lately I've put scripting platforms and game mechanics on hold. The draw_clipped() script was begging for attention, refusing to draw my Sword Skeleton correctly (it worked for my Axe Knight, though), so I decided to scrap it for now (the code will still remain in GMvania but the function will be disabled by default). Instead, I set my sights on cracking movement codes in CV3. I'm not much interested in Simon's jumping mechanics, although later I may work on cracking that after all; what I have been really interested in cracking is the movement for those damned platforms that bob up and down. I realized in order to do that I would need to acquaint myself with a similar movement code -- Medusa Heads. That's right, I wanted to crack Konami's method of sinusoidal movement in Castlevania.
And I must say, it's pretty nifty in its simplicity.
The sword and bone skeletons made more sense to me than the Medusa Head's code at first, but cracking what some of the variables actually referred to helped it make more sense.
The first thing I had to learn about reading enemy movement code was to stop thinking in terms of hspeed and vspeed, since the NES games strictly modified the x and y values directly. However, CV3 did actually use hspeed and vspeed to an extent. Certain bytes were set to either 0 or 1 for positive hspeed, or -1 or -2 for negative hspeed. The carry bit of the status flag was added to those bytes, so at any time the hspeed was -2, -1, 0, +1 or +2. Ok, so far, so boring.
The next thing I realized was the same script was used for every skeleton -- from the normal, slow-plodding skeleton to the spry whip skeleton. Recognizing this script was the key to breaking the enemy movement code. Of course, like my Password Generator, I didn't actually take the time to translate the script into attractive GML, deciding instead to simply transliterate everything into compatible GML. This script followed this format:
A+=B;
carry=A>255;
X+=hspeed+carry;
That's the gist of the horizontal movement script of the skeletons. What's the big deal? Well, when I tried to crack the code for Medusa Heads, this was the first script I saw:
C+=D;
carry=C>255;
Y+=vspeed+carry;
And right below that in the debugger was the horizontal code above.What this told me was, as I suspected after cracking the skeletons' horizontal movement codes, that the Medusa Head's vertical movement code was at its most basic level the same (or at least very similar) function as the acceleration/deceleration horizontal movement in sword skeletons. The question left in my mind was, how did Konami tell the Medusa Head to change direction regardless of where Trevor was in relation to the Medusa Head?
For the skeletons, it was a simple case of set an alarm (yes, CV3 had the equivalent of alarms) then adjust the movement when the alarm is executed. I knew the general address which would hold any alarm used by the Medusa Head, but when I ran the game there were no such bytes to be found. I was perplexed, so I delved farther into the code. It didn't make much sense at first because there was a glaring issue I had overlooked -- Medusa Heads' y-origins are 5 pixels below their sprites! I kept staring at this byte set to C4, but Trevor was standing at C0 and the Medusa Head was knee-high. When the Medusa Head went up, the byte decreased, and vice-versa. Once I got that sorted out, I noticed in the code another byte also set to C4. It was in the same address as where an alarm byte would be, but as I ran the game I noticed it never increased or decreased. It occurred to me what I was looking at is the GM equivalent ystart. So now the code was staring me right in the face.
B-=(y-ystart);
carry=B<0 || B>255;
vspeed-=1-carry;
Er... I think that's what the code loosely translates to. Unfortunately the Ethernet port on my laptop is bent to hell, so I can't just copy-paste the ASM up to here.