Trying to understand a specific jumping code for a boss

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
Timaeus
Posts: 12
Joined: Wed Jul 13, 2022 1:06 pm

Trying to understand a specific jumping code for a boss

Post by 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~
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Trying to understand a specific jumping code for a boss

Post by Dwedit »

Mega Man 2 literally did exactly that with Quick Man. See the Video by Displaced Gamers.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Timaeus
Posts: 12
Joined: Wed Jul 13, 2022 1:06 pm

Re: Trying to understand a specific jumping code for a boss

Post by Timaeus »

I watched that video a couple of months ago, and I completly forgot that they had this information. I did not even knew that Quick Man uses this logic too (which actually explain why his jumps are like that). Thank you very, very much for pointing it out! :D

The hardest part of it was to find the right way to handle the remainder value after the division, but after some hard work, I found it out and I finally made the whole code to work.

Thank you very much, once again~
Post Reply