jataka5000
New member
Hello,
I've finished all the platformer tutorials (up through tutorial 13), and I'm diving deeper to try and understand how gravity really works in the NESmaker doHandlePhysics_Gravity subroutine.
So far, I've figured out that Object_v_speed_hi and Object_v_speed_lo are the major and minor (respectively) numbers that tell you what your speed is. It seems that a positive value means falling downward.
I'd like to understand the asm code for the gravity part (e.g. doHandlePhysics_Gravity_LeftBoundsSolid_vulnerabilityBit_oneWayPlat_prizeBlock.asm lines 374 onward) to see how I could reverse the effect of gravity -- that is, all objects would tend to move upward instead of down.
It seems that
adds the gravity acceleration value to Object_v_speed_hi until it reaches the max speed. I thought that
would subtract the gravity acceleration value from Object_v_speed_hi but I don't think I was right.
Perhaps the issue is in line 474:
A large part of my confusion is that I don't know what combinations of Object_v_speed_hi and Object_v_speed_lo correspond to negative or positive velocities (i.e. going up vs down)... Also, it seems that BNE doesn't only check to see if one value is not equal to the other, but whether one value is larger than the other.
Greatly appreciate any help in deciphering what is happening with the code. Let's defy gravity! Well, not just defy but make it turn the opposite direction, for starters...
-j5k
I've finished all the platformer tutorials (up through tutorial 13), and I'm diving deeper to try and understand how gravity really works in the NESmaker doHandlePhysics_Gravity subroutine.
So far, I've figured out that Object_v_speed_hi and Object_v_speed_lo are the major and minor (respectively) numbers that tell you what your speed is. It seems that a positive value means falling downward.
I'd like to understand the asm code for the gravity part (e.g. doHandlePhysics_Gravity_LeftBoundsSolid_vulnerabilityBit_oneWayPlat_prizeBlock.asm lines 374 onward) to see how I could reverse the effect of gravity -- that is, all objects would tend to move upward instead of down.
It seems that
Code:
ADC #GRAVITY_HI
Code:
SBC #GRAVITY_HI
Perhaps the issue is in line 474:
Code:
BNE notOverFallSpeed
;; is at least max fall speed.
LDA #$00
STA Object_v_speed_lo,x
notOverFallSpeed:
A large part of my confusion is that I don't know what combinations of Object_v_speed_hi and Object_v_speed_lo correspond to negative or positive velocities (i.e. going up vs down)... Also, it seems that BNE doesn't only check to see if one value is not equal to the other, but whether one value is larger than the other.
Greatly appreciate any help in deciphering what is happening with the code. Let's defy gravity! Well, not just defy but make it turn the opposite direction, for starters...
-j5k