## News:

11 March 2016 - Forum Rules

## Trying to understand this specific boss jump movement code for my NES romhack

Started by Timaeus, January 12, 2023, 03:47:36 PM

#### Timaeus

The game in question is Megaman 1.

Basically, I want to make a robot master of mine be able to jump and land exactly where Megaman is, on Megaman's X position, which is horizontal.

I came up with alot of information about some things that could help, and right now, I did managed to make it work, but only with a very low jump Height. The logic that I came out was: set sprite id, set animation related command, set jump height whole value as 6, set jump height fractionated value as 20, set the carry to 1, load Megaman's X position, subtract with the boss's X position, add the whole value to the jump distance whole command and the remainder (in the carry, probably) as the value of the jump distance fractionated command, call a function to make the boss jump at the direction that I am (left or right), move to the next boss code, end (rts)

Obs: the fractionated commands goes from 00 to FF (0 to 255), and the whole commands goes uses 256 as a base for the value (which means value 01 makes it move 1 pixel per frame, representing 256. Value 2 represents 512, etc.)

Is this logic correct? If not, I want to know what I did wrong on it, because I want to understand these things better to improve my coding skill.

Thanks~

#### Cyneprepou4uk

#1

Is there a reason you're describing your code instead of actually posting it?

Instead of fractionated and whole commands, better call them low and high bytes.

pos_X_lo
pos_X_hi

#### Timaeus

So that is what high and low numbers are about in this kind of language. Thanks for that.

I did not had the code in hex when I did the post. Sorry about that.

It turned out that I had to subtract the boss X position's with Megaman's, and then do some stuff until it reaches the part of doing a division of the result by the number of frames that the jump takes from start to finish (with a specific jump height). Then add high values into a specific high value command and the remainder of the division in a low value command.

The hardest part was finding out how to handle the remainder value, but I finally managed to make the whole thing work.

Thank you, dude.