What is the purpose of "Object_movement"?

cargo

spam bots yandex
If gamepad holds the NES controller's state, then what does Object_movement contains?
(Just trying to understand the underlying code)
 

chronosv2

New member
Object_movement is the direction an object is set to move. It's what tells the physics engine "This object is moving right."
That's why hold/press a direction sets a bit in that variable and releasing the button unsets the bit.
 

dale_coop

Moderator
Staff member
Joe made some great videos about that, on Vimeo:
https://vimeo.com/276741403
And all his old videos (it was about the beta):
https://vimeo.com/joegranatoiv
 

cargo

spam bots yandex
Thanks. I will add the video to my things to watch.
But unlike gamepad (which is a single variable) Object_movement points to a table array. Is this correct?
 

chronosv2

New member
The array is for each object in the object RAM.
For example, Object_movement,0 gets the movement data from the object in slot 0. Object_movement,4 gets the movement info for the object in slot 4.
From the comments in the StartMoving Macro:
Code:
	;; This macro uses the built in physics found in default physics scripts.
	;; Which observes acceleratoin and deceleration as long as bounds and tile collision.
	;; It is not a direct movement, but rather turns on a check for whether or not
	;; the object should move.
	
	;; Keep in mind, this does not alter the facing-direction of the object, just
	;; the actual motion.
	
	;constant definitions for direction are:
		;MOVE_RIGHT = #%11000000
		;MOVE_LEFT  = #%10000000
		;MOVE_DOWN  = #%00110000
		;MOVE_RIGHT = #%11000000
		;MOVE_LEFT  = #%10000000
		;MOVE_DOWN  = #%00110000
		;MOVE_UP    = #%00100000
		;               +--------Bit 7 is yes or no to h movement
		;                +----------- if 1, bit 6 is L (0) or R (1)
		;                 +------Bit 5 is yes or no to v movement
		;                  +--------- if 1, bit 4 is U (0) or D (1)
		;DIAGONALS:
		;MOVE_RIGHT_DOWN = #%11110000
		;MOVE_LEFT_DOWN  = #%10110000
		;MOVE_RIGHT_UP	 = #%11100000
		;MOVE_LEFT_UP	 = #%10100000
 

chronosv2

New member
No. Gamepad is different. It's a variable called "gamepad".
I believe the order of the bits in that variable are Right, Left, Down, Up, Start, Select, B, A
So Up+A would be #%00010001, for example.
Making constants for all the possible (legal) controller combinations would take a lot of constants. It's easier just to remember that bit order and work from that to check for certain controller combinations.
 

cargo

spam bots yandex
chronosv2 said:
No. Gamepad is different. It's a variable called "gamepad".
Well thank you Mr. Obvious.

Making constants for all the possible (legal) controller combinations would take a lot of constants. It's easier just to remember that bit order and work from that to check for certain controller combinations.
I never said button combinations. I was just wondering if the directional constant values used for obejct movement still matched those read from the gamepad. I'll figure it out on my own.
 

chronosv2

New member
GameEngineData\Routines\UserScripts\[Module]\MovementScripts
Figure it out from there.
Sorry my attempts to assist you were clearly insufficient. Good luck.
 

dale_coop

Moderator
Staff member
cargo said:
I was just wondering if the directional constant values used for obejct movement still matched those read from the gamepad. I'll figure it out on my own.

No it doesn’t! And chronosv2 shown an example (with the combinaisons).
The object_movement value contains informations for the direction mouvement AND informations of its facing directions... of the Player. The gamepad contains just the informations of the buttons actually pressed. Here, nothing about the player!
 

cargo

spam bots yandex
chronosv2 said:
GameEngineData\Routines\UserScripts\[Module]\MovementScripts
Figure it out from there.
Sorry my attempts to assist you were clearly insufficient. Good luck.
No it was your tone and your sarcasm. E.g. The "figure it out out from there" (maybe a little miffed that I called you "Mr. Obvious" after you condescendingly explained and quoted "gamepad"). I was genuinely curious and thought it was okay to ask experts like you without getting mocked. Then again in this text form you can't see the real intent or if you are talking to someone from a different culture or English as a second language. So if I misunderstood then my bad but think about this: Other people will come up with similar questions. Don't be condescending even if the answer seems obvious to you.
 

Dirk

Member
I don't think he meant it condensing. As far as I know him from the forum he is very nice and only trying to help.

Editl: "gamepad" is not in sarcastic quotes but in simple quote quotes.
 

chronosv2

New member
I'm not going to sit here and argue on the internet -- my original intent when I made my responses to your posts was to help. My intent wasn't to be condescending -- I had gone over the movement constants, you asked if they applied to the gamepad variable, and I took the time to explain how the gamepad variable worked and why the constants were not shared.

Then you reply to me with this.
cargo said:
chronosv2 said:
No. Gamepad is different. It's a variable called "gamepad".
Well thank you Mr. Obvious.

Making constants for all the possible (legal) controller combinations would take a lot of constants. It's easier just to remember that bit order and work from that to check for certain controller combinations.
I never said button combinations. I was just wondering if the directional constant values used for obejct movement still matched those read from the gamepad. I'll figure it out on my own.

You say yourself that we can't tell intent by text, yet you immediately assume I was being condescending to you when all I had done is thought that my answers combined would give you the complete answer. The format of the gamepad variable is different from that of the Object_movement variable. I was attempting to be informative, nothing more.

And by no means am I an "expert" with anything ASM related. I've been learning it since August 26th. I'm about as novice as they come. I've been corrected multiple times by others on the forum who are much more knowledgeable than I. But this is a community and I'd like to be of assistance if at all possible. Before I wrote my original "gamepad" response I didn't even know what order the button states were stored in so I took the time to open an emulator, get the debugger set up and I manually tested the variable to find out which bits represented which button one by one so I didn't give you incorrect information.

Judging from the above response, you no longer wished for my help. I felt that the response I got for my time was rude, and I originally wanted to be much more confrontational with my own response. But this is the Internet. It's not worth it to get upset over words on a digital page and being confrontational here undermines my entire intent of attempting to be a useful asset to the community. So I concluded "Okay, this person no longer wishes for my help, so I won't beat about the bush; I'll tell them where to look, wish them luck and be on my way."
 

MistSonata

Moderator
Hi there! I'd like to make sure to remind everyone to try their best to keep things civil, even if you feel that someone isn't acting civil toward you. Misunderstandings can very easily happen, especially when the language spoken is not someone's native tongue, so please try not to continue the antagonism. If someone is being consistently rude and abusive, please report them so that I can help. It's what I'm here for, after all.

To address the topic of the thread, here's the notes I have on these two variables.

Code:
	;; gamepad bits
	;; 7 6 5 4 3 2 1 0
	;; | | | | | | | |
	;; | | | | | | | +--- A Button
	;; | | | | | | +----- B Button
	;; | | | | | +------- Start
	;; | | | | +--------- Select
	;; | | | +----------- Up
	;; | | +------------- Down
	;; | +--------------- Left
	;; +----------------- Right

	;; Object_movement
	;; 7 6 5 4 3 2 1 0
	;; | | | | | | | |
	;; | | | | | +-+-+--- Object Facing Direction
	;; | | | | |
	;; | | | | +--------- (Unused?)
	;; | | | |
	;; +-+-+-+----------- Object Movement Direction

	;; Facing:
	;; 000 = Down 
	;; 001 = Down-Right
	;; 010 = Right
	;; 011 = Up-Right
	;; 100 = Up
	;; 101 = Up-Left
	;; 110 = Left
	;; 111 = Down-Left

	;; Movement:
	;; 0011 = Down 
	;; 1111 = Down-Right
	;; 1100 = Right
	;; 1110 = Up-Right
	;; 0010 = Up
	;; 1010 = Up-Left
	;; 1000 = Left
	;; 1011 = Down-Left

Object_movement is divided up into two main parts, the first four bits determine which direction the object is moving, and the last three bits determine which direction it's facing. As far as I can tell, bit 3 isn't used right now, so best not to worry about it.
 

cargo

spam bots yandex
Originally I was hesitant to create this thread due to the micro focus programming aspect of the subject. Guess I should've trusted my instincts. I've already read those code comments pasted from the assembly files before making the thread and was looking for further insight. To me it doesn't matter if Object_movement has more pre-determined values than gamepad. They could very well share the same values for those relationships that match. At least to me it would because programmatically I think it makes my life easier. Technically it should not matter (though I am sure people will have different opinions).

My original impression was this is a table with all those values you quoted. I wasn't sure if it was that or the values for each monster. E.g. a table holding each monster's movement. That seems to make sense to me. I've seen it called on demo.txt through indexed addressing (eg, LDA Object_Movement, x). Understanding this could also help me understand other movement related scripts (like the one that moves enemy bullets).
 

MistSonata

Moderator
cargo said:
Originally I was hesitant to create this thread due to the micro focus programming aspect of the subject. Guess I should've trusted my instincts. I've already read those code comments pasted from the assembly files before making the thread and was looking for further insight. To me it doesn't matter if Object_movement has more pre-determined values than gamepad. They could very well share the same values for those relationships that match. At least to me it would because programmatically I think it makes my life easier. Technically it should not matter (though I am sure people will have different opinions).

My original impression was this is a table with all those values you quoted. I wasn't sure if it was that or the values for each monster. E.g. a table holding each monster's movement. That seems to make sense to me. I've seen it called on demo.txt through indexed addressing (eg, LDA Object_Movement, x). Understanding this could also help me understand other movement related scripts (like the one that moves enemy bullets).

I see. Object_movement is a table that holds the movement value of every active object in the game (including the player, monsters, bullets, etc), that's why it's separate from the gamepad variable, otherwise pressing a direction on the controller would move every object on the screen. I think the reasoning is also that (particularly in the case of pulling up menus or using different game mechanics) you might not always want pressing up to automatically move your character up the screen.

You might also find that some code uses something like "Object_h_speed_hi, x", which takes more direct control over the object's speed, but doesn't account for objects that have different movement speeds, which is why Object_movement is more commonly used, so that it respects the object's movement speed variable no matter what object you apply it to.
 

digitalbooty

New member
Is there a way to use this to make my melee attack move with an ascending or descending player character. For example, if my melee attack lasts 4 frames and I jump and perform a melee attack, my character begins to fall, but the melee object continues to spawn in the original position in air where the melee attack was summoned instead of falling with the character. Is there a way to use the object movement data to "track" and "follow" my character on the way down or up as it is spawning?
 
Top Bottom