Deep Dive: Object values

For this post, I’ll dive into the values NESmaker uses in its object system. I’ll zoom in on the object direction variable especially, and add a Markdown file with the other object values that are available.

Object values

NESmaker uses an object system. Objects are (meta)sprites that are interactive: through user inputs, collisions or timers, for example. In the NESmaker UI, Game Objects and Monsters is where objects are managed. Under the hood, these objects use a plethora of values to define where they should spawn, what direction they are moving in or facing, how many health they got, if they’re friendly (NPC) or hostile (Monster), et cetera. These values are stored in both ROM (static, not changeable) and RAM (variable, changeable). I’ll get into each and every constant and variable objects have by default, since NESmaker allows, encourages and often even requires you to add your own.

Object_direction

The value that holds all information on an object’s direction, is the aptly named Object_direction value. The value consists of five bit flags and an octal value for the facing direction. These are the bit-values and what they mean/represent:

  • Bits 0-2 are the facing direction of the object. This can have eight values:
    • 000 = down
    • 001 = down + left
    • 010 = left
    • … (these progress in a clockwise direction)
    • 111 = down + right

     

  • Bit 3 is the “aim” bit. When this bit is set, the object uses aimed physics (move towards player).
  • Bit 4-5 define vertical movement of the object. The bits represent these values:
    • Bit 4: object moves down (1) or not (0)
    • Bit 5: object moves vertically (1) or not (0)
    • Or, you could say: 10= up, 11 = down, 00 or 01 = no vertical movement.

     

  • Bit 6-7 define horizontal movement of the object:
    • Bit 6: Object moves right (1) or not (0)
    • Bit 7: Object moves horizontally (1) or not (0)
    • Or, you could say: 10 = left, 11 = right, 00 or 01 = no horizontal movement.

     

To summarize, the definition of the Object_direction value is as follows:

Object_direction: h r v d a fff
                  | | | | | +++- facing direction. 000 is down, then it
                  | | | | |      increments in a clockwise direction
                  | | | | |      towards 111, which is down-right.
                  | | | | +----- use aimed physics (0:off, 1:on)
                  | | | +------- object moves down (0:no, 1:yes)
                  | | +--------- object moves vertically (0:no, 1:yes)
                  | +----------- object moves right (0:no, 1:yes)
                  +------------- object moves horizontally (0:no, 1:yes)

This value obviously is a variable that exists in RAM, because an object should be able to look/move in different directions throughout the game and therefore must be both accessible and modifiable.

All object values

You can find a Snip with all object values here: Object values