Ninja Gaiden (NES)/RAM map: Difference between revisions

From Data Crystal
Jump to navigation Jump to search
(Started)
 
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{rammap|game=Ninja Gaiden}}
{{rammap|game=Ninja Gaiden}}
'''Note:'''
* All RAM addresses are initialized to zero shortly after reset or power-on.  Variables marked as unused are never written to or used again.


{| border="1" cellpadding="1"
{| border="1" cellpadding="1"
|'''RAM'''  || '''Function''' || '''Detail'''
|'''RAM'''  || '''Function''' || '''Detail'''
|-
|-
|0x0056 || Current Pattern Table 1 ||
|$00-09 || Scratchwork || Used in various calculations
|-
|-
|0x0059 || Current Pattern Table 2 ||
|$03 || Upper Left Collision || Holds the collision value of the tile on Ryu's upper left.  Also a scratchwork variable elsewhere
|-
|-
|0x001e || Paused || $0x00=$0x80 = yes ||
|$04 || Lower Left Collision || Holds the collision value of the tile on Ryu's lower left.  Also a scratchwork variable elsewhere
|-
|-
|0x0060 || score || adds x*100 ||
|$0A-0B || Cut-Scene Bytecode Pointer || Scripting at this address controls the game flow during cut-scenes.
|-
|-
|0x0060 || score || adds x*25600 ||
|$0C-0D || Cut-scene Nametable Attribute PPU Address || Only used for writing data to the attribute array of a nametable in a cut-scene.
|-
|-
|0x0063 || timer ||
|$0E-0F || Cut-Scene Function Pointer, Relative PPU Address adjustment || Used as an indirect to read the values that it will store back into itself before acting as a function pointer.  $0E is Also used to store value to add to $E4-E5 when incrementing the PPU draw position during cut-scenes.
|-
|-
|0x0064 || Ninja power ||
|$10 || Room Loading Loop Controller || Loads the first screen you see when a room loads, one column of tiles at a time.
|-
|-
|0x0065 || Life || maximum is $0x10
|$11 || Stage End Loop Control || Similar to $0010 in it's use.  It gets used when you complete a stage to ensure that the status bar is fully updated before fading out
|-
|$12 || Unused
|-
|$13-14 || Reusable Indirect Pointer || Holds pointers for accessing data types through indirects
|-
|$15-16 || Reusable Indirect Pointer || Holds pointers for accessing data types through indirects
|-
|$17-18 || Reusable Function Pointer || Used to hold a function pointer accessed by JMP indirect opcode.  Used for:
* 1. Performing different functions based on D-Pad inputs
* 2. Obtaining powerups
* 3. Hitting a special collision tile (room advance, room retreat, stage advance, start cut-scene)
|-
|$19-1B || Unused
|-
|$1C || PPUCTRL Base || Base value written to $2000 (PPUCTRL) every frame
|-
|$1D || PPUMASK Base || Value written to $2001 (PPU_MASK) every frame
|-
|$1E || Pause Check || Top bit (x80) used to check whether the game is paused
|-
|$1F || NMI Detector || Used to check whether an NMI has occurred.  Used for "wait for NMI" loops.  Value set to FF at end of NMI.
|-
|$20-22 || Interrupt Variables || Only used for calculations that occur within NMI to prevent conflicts with other variables
|-
|$23-27 || Unused
|-
|$28 || Controller Input || Bitfield holding the buttons currently being held down on controller 1.
* x01 = Right
* x02 = Left
* x04 = Down
* x08 = Up
* x10 = Start
* x20 = Select
* x40 = B
* x80 = A
|-
|$29 || Controller Presses || Same as $28, except only holding values for buttons that were just pressed that frame.
|-
|$2A || Previous Controller Input || Similar to $28.  Used for determining $29.
|-
|$2B-2C || PPU Transmission Pointer || Pointer for data to be transmitted to PPU during the next NMI.  Format is:
*Byte 0: Size of data to be transmitted in bytes.  If top bit is set, sets bit 1 of $2000 (PPUCTRL), used for writing tile data vertically on-screen instead of horizontal. If the size byte is 0, end transmission.
*Byte 1: low byte of PPU address
*Byte 2: high byte of PPU address
*Byte 3-X: data to be transmitted
*After each set of data transmitted, the pattern will repeat until the size byte is read as zero.
|-
|$2D || Interrupt Prior A || Used to store and restore the accumulator value when an NMI is triggered
|-
|$2E || Interrupt Prior X || Used to store and restore the X register value when an NMI is triggered
|-
|$2F || Interrupt Prior Y || Used to store and restore the Y register value when an NMI is triggered
|-
|$30-31 || Sprite Tile Pointer || Holds a pointer to the start of sprite tile and position data when calculating sprite data before transmission to OAM array.
|-
|$32-33 || Sprite Attribute Pointer || Holds a pointer to the start of sprite attribute data when calculating sprite data before transmission to OAM array
|-
|$34 || Sprite Flip Bits || Holds horizontal and vertical flip data for Ryu or Enemies when calculating sprite positions and attributes.
|-
|$35 || Sprite Alternate Attributes || Used to change $32-33 when an enemy or powerup has an "alternate" set of attribute data.
|-
|$36 || Sprite Base X || Holds X coordinate of object to be displayed on-screen during sprite calculations
|-
|$37 || Sprite Base Y || Holds Y coordinate of object to be displayed on-screen during sprite calculations
|-
|$38 || Sprite Tile Pointer Offset || Holds offset into sprite tile and position data during sprite calculations
|-
|$39 || Sprite Attribute Pointer Offset || Holds offset into sprite attribute data during sprite calculations
|-
|$3A || Sprite Tiles Remaining || Holds the number of remaining sprite tiles to display for the current entity during sprite calculations
|-
|$3B || Sprite Write Position || Holds the current write position within the OAM data array at $200-2FF for writing sprite tiles.
|-
|$3C || Sprite Temp Variable || Used in sprite calculations when a sprite object is horizontally flipped.
|-
|$3D || Room Reverse || Top bit (x80) determines whether a room scrolls in reverse direction or not.
|-
|$3E || Status Bar Update State || Determines which part of the status bar to update on the next frame.
|-
|$3F || Scratchwork || Used as a scratchwork variable when reversing an enemy's movement direction.
|-
|$40-41 || Level Data Pointer || Pointer to the the next set of Level data to load during scrolling.
|-
|$42-43 || 4x4 Tile Set Address || Pointer to the array which selects four sets of 2x2 tiles to display on-screen for each byte of level data. Each entry is four bytes: top left, bottom left, top right, bottom right.
|-
|$44-45 || 2x2 Tile Set Address || Pointer to the array which defines the 2x2 tile sets that are displayed on-screen.  This array holds the actual tile values to transmit to the PPU. Each entry is four bytes: top left, bottom left, top right, bottom right.
|-
|$46-47 || 4x4 Palette Set Address || Pointer to the array which determines the palette of each 2x2 tile set within each byte of level data.  Each byte consists of 4 sets of 2 bits, where each set forms a value 0-3 selecting the BG palette to use.
|-
|$48-49 || Collision Set Address || Pointer to the array which determines the collision values to associate with each 2x2 tile set within each byte of level data.  There are 2 bytes for each entry.  Each nybble (upper or lower 4 bits) determines a collision value, in the order top left, bottom left, top right, bottom right.  The collision values 0-F index into an array at ROM x1E792 or x1E132 (with iNES header) that determine the actual collision bitfield. Ryu uses the bitfield from x1E792, while enemies use the values from x1E132.  Values of xA or greater also have special properties for Ryu, such as advancing rooms or stages or starting a cut-scene.
|-
|$4A-4B || Movement Tracker - Collision || Keeps track of Ryu's movement.  When Ryu moves x10 or more pixels in either direction, the value in $5F is shifted by 6 accordingly to change the starting offset into the collision array at $0300-03BF.  After this occurs, the top nybble of $4B is cleared.
|-
|$4C || Nametable Selector, Movement Direction, Large PPU transmission indicator || Least bit is ORA'ed with $1C to determine the nametable to use for the starting scroll position.  Bit 6 (x40) is set when new tile data is loaded into the PPU transmission array at $0700-07FF.  When bit 6 is set, the status bar will not be updated that frame to prevent graphical glitches.  Certain enemy actions will also be skipped.  When Ryu is moving to the left, the top bit is set.
|-
|$4D || ???? || Appears to have been intended to serve a similar purpose to the nametable selector bits of $4C.  However, it is associated with variables $AE-AF and $A4-A5, which are set but never used.  Possibly a result of code remnants intended to create vertical scrolling in the levels.
|-
|$4E || Left Edge Room Position || Horizontal position within the level, in terms of 2 tile increments.  Value increases by one every x10 pixels.  This value corresponds directly to the position of the left side of the screen within the level.  This value is used to determine whether enemies spawn, or whether powerups spawn while you are moving left.
|-
|$4F || Right Edge Room Position || Same as 4E, but x10 higher.  This value corresponds directly to the position of the right side of the screen within the level.  This value is used to determine whether powerups spawn if you are moving right.
|-
|$50-52 || Room X Position || Horizontal position within the level.  $52 is the number of full "screens" of movement, $51 is pixels, and $50 is partial pixels.  If $52 is negative, scrolling left is prohibited.
|-
|$53 || Room Width || Width of the room, in "screens".  If $52==$53, right scrolling is prevented.  If $53==0, there is no scrolling.
|-
|$54-55 || Unused
|-
|$56 || Graphics page for sprites in the status bar
|-
|$57 || Graphics page for sprites on the lower half of the screen.
|-
|$58 || Unused
|-
|$59 || Graphics page for backgrounds on the status bar
|-
|$5A || Graphics page for the level environment.
|-
|$5B || Unused
|-
|$5C || Prior PRG Bank || Last PRG bank swapped to outside of NMI.  NMI restores this bank when it exits.
|-
|$5D-5E || Collision Write Address || Write position within the collision array at $0300-03BF.  Level collision data read from ROM is written here.  Upper byte ($5E) is always 3.
|-
|$5F || Collision Offset || Current offset into the collision array at $0300-03BF.  As scrolling occurs, value is incremented by 6 for each 2x2 column.  Value wraps back to 0 after xC0, the width of the collision array.
|-
|$60-61 || Score total
|-
|$62 || Frame Countdown Timer || Values count down from 3C (60).  When they wrap around to negative, one second is removed from the time left to complete the stage.
|-
|$63 || Time remaining
|-
|$64 || Ninja Power/Spiritual Energy
|-
|$65 || Ryu's Health || Max value is x10
|-
|$66 || Boss Health || Max value is x10.  Only affects the amount displayed in the status bar.  Real enemy health is stored in an array at $0490-$0497.
|-
|$67-68 || Movement Tracker - PPU Update || Keeps track of Ryu's movement similarly to $4A-4B.  When Ryu has moved x10 or more pixels, it triggers new tiles to be transmitted to the nametable.  This also sets bit 6 of $4C, preventing new data from being transmitted to the status bar that frame.
|-
|$69-6A || Movement Tracker - Pointer Updater || Keeps track of Ryu's movement similarly to $4A-4B and $67-68.  However, the value resets every x20 pixels instead of every x10.  When this occurs, the pointer to the next set of level data to read ($40/41) is incremented or decremented by 6, and the write position within the collision array at $0300-03FF is incremented or decremented by xC.
|-
|$6B-6C || PPU Base Address for Level Drawing || Base offset into the current nametable used for calculating the location to store new tiles while scrolling, and also locate positions in the nametable attribute array to write the new palette data.
|-
|$6D || The current stage
|-
|$6E || The current room || Stages can have multiple rooms.
|-
|$6F || Room Re-entry Boolean || Top bit is set when you return to a previous room, and plays a role in correctly placing you at the opposite end of the room from where you normally would start.
|-
|$70-71 || Enemy AI Pointer || Holds a pointer to the list of AI function pointers for the enemy that is currently being processed.
|-
|$72 || The number of enemies on the screen
|-
|$73 || Enemy Slots || This byte is a bitfield, where each bit indicates that an enemy is occupying a specific "slot".  There are 8 enemy slots, and thus most enemy variables are stored in arrays that are 8 bytes long, one for each possible enemy.
|-
|$74 || Enemy Actions || Holds the number of remaining enemy actions that can be processed in a given frame.  It appears that at one point the programmers intended there to be a different number of potential enemy actions in a given frame depending on how many enemies are on-screen, but this functionality was scrapped due to the numerous glitches it would cause. As a result, there are only 8 enemy actions available per frame, one for each slot.  This variable counts down even if no enemy is occupying the slot, such that each enemy effectively only has its AI calculated once per frame.
|-
|$75 || Last Enemy || Holds the slot number of the last enemy that was processed, so that processing can begin on the next enemy next frame.  Was intended to work with the variable amount of enemy actions mentioned in $74, but currently this value will always hold 0, since each enemy's AI is calculated only once per frame.
|-
|$76 || Remaining Lives
|-
|$77 || Boss Rush Progress || Keeps track of your progress on the final boss-rush, so that you can skip the bosses you have already defeated.
|-
|$78 || Unused
|-
|$79 || Enemy Flags || Copied from $0498,X array for the given enemy slot while enemy is being processed.  Bits:
* x01: Set if Enemy is a boss
* x02: Set if Enemy was spawned by another enemy, not part of the normal spawn list
* x04: Set if Enemy is jumping or falling in the Y direction
* x10: Set if Enemy has been defeated and is performing its death explosion
* x40: Set if Enemy is able to move in the X direction
* x80: Set if Enemy ignores environment collision
|-
|$7A || Enemy Attribute Flags || Copied from $0440,X array for the given enemy slot while enemy is being processed.  Bits 0 and 1 form a value from 0 to 3 that is capable of selecting an alternate set of attribute data for the enemy's sprite tiles.  Only a couple enemies have extra attribute data defined.  Bit 6 (x40) is set if the enemy is facing left (horizontally flipped).  Bit 7 can trigger a vertical flip in the sprites, but enemies more than one sprite tall will not display properly.
|-
|$7B || Restore PPUCTRL Base || Stores the value from $1C while a cut-scene is playing, so it can restore it afterwards.
|-
|$7C || Restore PPUMASK Base || Stores the value from $1D while a cut-scene is playing, so it can restore it afterwards.
|-
|$7D || Restore Sprite Graphics Page || Stores the value from $56 while a cut-scene is playing, so it can restore it afterwards.
|-
|$7E || Restore Status Bar Graphics Page || Stores the value from $59 while a cut-scene is playing, so it can restore it afterwards.
|-
|$7F || Restore Prior PRG Bank || Stores the value from $5C while a cut-scene is playing, so it can restore it afterwards.
|-
|$80 || Ryu's Animation Sequence Number
|-
|$81 || Offset into Ryu's current animation sequence
|-
|$82 || Time remaining for Ryu's current animation frame
|-
|$83 || Ryu's current animation frame #
|-
|$84 || Ryu's flags || Bitfield Values:
* x01 Recently took damage
* x02 Invincible
* x04 Jumping or falling (Moving in Y direction)
* x08 Currently performing an animated action.  Cannot start a new one until the animation completes
* x10 Flickering effect
* x20 BG priority set.  Ryu can appear "behind" the background.
* x40 Horizontal Flip
* x80 Vertical flip (glitchy)
|-
|$85-86 || Ryu's Horizontal (X) position on-screen || $85 is a fractional pixel value, $86 is the integer pixel value.
|-
|$87 || Ryu's Fractional vertical speed || Value/x100 pixels per frame.
|-
|$89 || Ryu's Integer vertical speed || Pixels per frame.
|-
|$8A || Ryu's vertical (Y) position on-screen.
|-
|$8B || Dead Boolean || Top bit used to indicate Ryu has died.  Set it to kill Ryu.
|-
|$8C || Ryu's collision flags || Bitfield values:
* x01 Right wall
* x02 Right wall that you can latch to
* x04 Left wall
* x08 Left wall that you can latch to
* x10 Platform
* x20 Ladder
* x40 unused
* x80 Set if top half of Ryu passed through a latch-able wall but not his feet.  Used to allow Ryu to pass through some walls.
|-
|$8D || Flicker Counter || Used for Ryu's flickering effect when he is hit.  Determines whether to display his sprites that frame.
|-
|$8E || Upper Right Collision || Stores the collision value of the tile on Ryu's upper right
|-
|$8F || Lower Right Collision || Stores the collision value of the tile on Ryu's lower right
|-
|$90 || Ryu's Hitbox Height || For determining whether an enemy can hit him.
|-
|$91 || Ryu's Attack Box Top || Height to top of Ryu's hitbox, determining whether he can hit an enemy with sword
|-
|$92 || Ryu's Attack Box Bottom || Height to bottom of Ryu's hitbox, determining whether he can hit an enemy with sword
|-
|$93 || Hit Indicator || Used to indicate Ryu was recently hit, and whether or not he has hit the ground.
|-
|$94 || Flinch Direction || Determines the direction Ryu will flinch after being hit.  Overrides user input and writes direction to $28.
|-
|$95 || Invincibility timer after Ryu is hit
|-
|$96-97 || Enemy Spawn Pointer || Pointer to horizontal spawn positions of enemies within the room. Compare values at address with value in $4E to determine whether to spawn.
|-
|$98-99 || Enemy YX Pointer || Pointer to screen positions for enemies that spawn in the current room.  Upper nybbles are Y position, lower are X position.
|-
|$9A-9B || Enemy Type Pointer || Pointer to enemy type ID #'s for enemies that spawn in the current room.
|-
|$9C-9D || Powerup Spawn Pointer || Pointer to horizontal spawn positions of powerups within the current room.  Compare values with $4E and $4F to determine whether to spawn.
|-
|$9E-9F || Powerup Type Pointer || Pointer to powerup type ID #'s and Y position for powerups that spawn in the current room.  Upper nybbles are Y position, lower are the type.
|-
|$A0-A1 || Horizontal Scroll 1 || Horizontal scroll position of top part of screen. $A0 is fractional position, $A1 is integer position.  Only changes in cut-scenes, or else it would move the status bar.
|-
|$A2-A3 || Horizontal Scroll 2 || Scroll position in a level.  $A2 is a fractional position, $A3 is the integer position, stored to PPUSCROLL after the sprite zero hit detected from status bar.
|-
|$A4-A5 || ???? || Possibly meant to be a vertical scroll for the level.  $A4 is a fractional part, while $A5 is an integer part.  But the resulting values are never used.
|-
|$A6-A7 || Vertical Scroll || Vertical scroll position of the screen.  $A6 is fractional position, $A7 is integer position.  Only changes during cut-scenes.
|-
|$A8 || Unused
|-
|$A9 || Broken Vertical Scroll || Meant to be a vertical scroll for the lower part of the screen while in a stage, but it does not work correctly.
|-
|$AA-AB || Unused
|-
|$AC-AD || Ryu's horizontal (X) movement speed || $AC is the fractional part, $AD is the integer part.
|-
|$AE-AF || ???? || Potentially meant to be vertical scrolling speed (values added to $A4-A5 while scrolling), but these are always zero, and forcing them to be different does not change any apparent game behavior other than modifying $A4-A5 while you move.
|-
|$B0-B3 || Unused
|-
|$B4 || Number of Enemies || Number of enemies in the current room.  If top bit is set, no enemies spawn.
|-
|$B5 || Current Enemy Spawn Check || Enemy number in the list of available enemies for the room currently being tested to see if it can spawn.  The spawn code cycles through every enemy in the list, but it can only check 8 in a given frame.  With enough enemies in a room or a fast enough movement speed, it is possible to skip some enemy spawns.
 
|-
|$B7-BD || On-Screen Enemy Bits || Used to keep track of enemies that are currently loaded on-screen.  This prevents duplicate enemies from spawning.  Each enemy is assigned a bit in this array according to it's position in the enemy list found at the $96,$98, and $9A pointers.
|-
|$BE || Cut-Scene Initiate || Top bit is set to indicate that a cut-scene is about to start.
|-
|$BF || Frame counter || Value is incremented by 1 during the NMI code.  NG uses the counter as a crude RNG for some enemy AI.
|-
|$C0 || Powerup bitfield || Each of the lower 4 bits acts as a "slot" that is filled when a powerup spawns at the edge of the screen.  Only 4 powerups can be on the screen at once.
|-
|$C1 || Number Powerups || The number of powerups available in the room.  One is considered the minimum size, even if no powerup actually spawns in the room.
|-
|$C2 || Powerup Animation || Animation sequence # to use for the lanterns that hold the powerups.
|-
|$C3 || Time remaining for the current powerup lantern animation frame.
|-
|$C4 || Animation frame # for the powerup lanterns
|-
|$C5 || Offset into the animation sequence for the powerup lanterns.
|-
|$C6 || Powerup Left Spawn Offset || Index into the available array of spawnable powerups from $9C/$9E pointers.  This one is used to spawn powerups when moving left.
|-
|$C7 || Powerup Right Spawn Offset || Index into the available array of spawnable powerups from $9C/$9E pointers.  This one is used to spawn powerups when moving right.
|-
|$C8 || Ryu's projectile slots ||  Bits 0,1, and 2 are each a slot for a projectile.  No more than three can exist at once on screen.
|-
|$C9 || Ryu's equipped sub-weapon
|-
|$CA || Animation sequence # for the currently equipped sub-weapon, if a projectile
|-
|$CB || Time remaining for current projectile animation frame
|-
|$CC || Offset into the animation sequence for the current projectile
|-
|$CD || Animation Frame # for the current projectile
|-
|$CE || Projectile Size || Temporarily holds size of projectile in pixels, both horizontally and vertically (all projectiles are considered square).  Also gets reused to store the projectile number when looping through projectiles to display their sprites on-screen.
|-
|$CF || Projectile Damage || Temporarily holds amount of damage to be done by a projectile.
|-
|$D0 || Time Stop Boolean || Top bit activates the enemy time-stop effect when set.
|-
|$D1-DF || Unused
|-
|$E0-E1 || Cut-Scene X Scroll || Speed of horizontal scrolling during a cut-scene, in pixels per frame.  $E0 is fractional part, $E1 is integer part.
|-
|$E2-E3 || Cut-Scene Y Scroll || Speed of vertical scrolling during a cut-scene, in pixels per frame. $E2 is fractional part, $E3 is integer part.
|-
|$E4-E5 || Cut-Scene BG Draw Address || Forms a PPU address used to draw background images to the nametables during a cut-scene.
|-
|$E6-E7 || Cut-Scene Dialog Pointer || Pointer to the current line of text to display during a cut-scene.
|-
|$E8-E9 || Cut-Scene PPU Transmission Setup || Used by a cut-scene script command as a pointer to copy and set up a string of data to be transmitted to the PPU via $2006/$2007.
|-
|$EA || Cut-Scene Button Presses || Used to store all buttons held on the previous frame during a cut-scene.  Used to find exact moment player pressed Start to exit a scene.
|-
|$EB-EF || Unused
|-
|$F0-FD || Used in sound processing.
|-
|$FE-FF || Unused
|-
|$0100-01FF || Stack
|-
|$0200-02FF || Sprite data copied to OAM
|-
|$0300-03BF || Environment collision data ||  $0300-03FF also serves a variety of other purposes during cut-scenes
|-
|0x0314 || Current character index printing for current text in cut-scenes ||
|-
|0x03c7 || current character being printed in cut-scenes ||
|-
|$0400-0407 || Enemy type ID #'s for each enemy slot
|-
|$0408-040F || Enemy AI timer for each enemy slot
|-
|$0410-0417 || Enemy AI stage for each enemy slot || Different stages select a different function pointer from the list of available AI pointers for each enemy type. See $70/71
|-
|$0418-041F || Unused.  Available for enemy AI if needed.
|-
|$0420-0427 || Time remaining for the current animation frame # for each enemy slot.
|-
|$0428-042F || Animation sequence # for each enemy slot
|-
|$0430-0437 || Offset into animation sequence for each enemy slot
|-
|$0438-043F || Animation frame # for each enemy slot
|-
|$0440-0447 || Enemy attribute flags for each enemy slot.  See variable $7A.
|-
|$0448-044F || Fractional enemy X velocity for each enemy slot.
|-
|$0450-0457 || Integer enemy X velocity for each enemy slot, in pixels per frame.
|-
|$0458-045F || Fractional enemy X position on-screen for each enemy slot.
|-
|$0460-0467 || Enemy X position on-screen for each enemy slot.
|-
|$0468-046F || Fractional enemy Y velocity for each enemy slot.
|-
|$0470-0477 || Integer enemy Y velocity for each enemy slot, in pixels per frame.
|-
|$0478-047F || Fractional enemy Y position on-screen for each enemy slot.
|-
|$0480-0487 || Enemy Y position on-screen for each enemy slot.
|-
|$0488-048F || Enemy collision flags for each enemy slot. || Bitfield values:
* x10 = Platform to the right
* x20 = Platform to the left
* x40 = Wall to the right
* x80 = Wall to the left
|-
|$0490-0497 || Enemy HP || Hit points for each enemy slot.  Enemies with 0 HP are valid, and will die as soon as they are hit by any weapon.
|-
|$0498-049F || Enemy flags for each enemy slot ||  See variable $79.
|-
|$04A0-04A7 || Available variable to use for enemy AI, one for each enemy slot || Typically used with projectiles to keep track of the enemy slot number that spawned them.
|-
|$04A8-04AF || Unused.  Available for enemy AI if needed.
|-
|$04B0-04B7 || Enemy number for a given room || As it appears in the order of data at $96/$98/9A pointers.
|-
|$04B8 || Boss Kill Indicator || Top two bits set if a boss was just killed. Prevents new sound effects and projectiles during boss death animation, and triggers the score boost based on your remaining time and Ninja power.
|-
|$04B9 || Boss Kill Countdown timer || Activates right after you kill a boss.  It represents the minimum time before triggering a cut-scene and stage advance.  If you still have
Ninja power or remaining time when this hits zero, it waits until everything is zero before triggering the cut-scene.
|-
|$04BA || Boss Short timer || Cycles every 3 frames after you kill a boss.  Each time it wraps, it plays a sound effect and drops your Ninja Power or Time
remaining by one, while also increasing your score total.
|-
|$04BB-04BD || X position of Ryu's projectiles || Three different slots for throwing stars and fire wheel.  Boomerang star can only use slot 1.
|-
|$04BE-04C0 || Y position of Ryu's projectiles || Three different slots for throwing stars and fire wheel.  Boomerang star can only use slot 1.
|-
|$04C1-04C3 || X movement speed of Ryu's projectiles, for each slot || Boomering star uses fractional X speed also, using $04C2 for fractional and $04C1 for integer speed.
|-
|$04C4-04C6 || Y movement speed of Ryu's projectiles, for each slot ||Boomerang star does not use these at all, it simply increases or decreases Y position by 1 if Ryu is higher or lower.
|-
|$04C7 || Fractional Powerup countdown timer || For invincibility flame and time stop powerup items.  When this value hits zero, it is restored to x3C, a sound effect is played, and the main timer ($04C8) is decremented.
|-
|$04C8 || Powerup Timer || For the invincibility flame and time-stop powerup items.  Value is in seconds.
|-
|$04C9-04CC || Powerup type id # for each slot
|-
|$04CD-04D0 || Powerup animation frame # for each slot
|-
|$04D1-04D4 || Powerup info for each slot || Least two bits form a value 0-3 that can be used to select alternate attribute data for the powerup's sprites.  Bit 2 (x04) indicates that the lantern has been hit, revealing the powerup.  Bit 3 (x08) indicates that Ryu has picked up the powerup.
|-
|$04D5-04D8 || Powerup Fractional X position on-screen
|-
|$04D9-04DC || Powerup X position on-screen
|-
|$04DD-04E0 || Powerup Fractional Y position on-screen || Used when powerup has been revealed and is falling to the ground
|-
|$04E1-04E4 || Powerup Y position on-screen
|-
|$04E5-04E8 || Powerup Fractional Y Speed || Value/x100 pixels per frame.  Used after powerup has been revealed and is falling
|-
|$04E9-04EC || Powerup Integer Y Speed || In pixels per frame.  Used after powerup has been revealed and is falling
|-
|$04ED-04F0 || Powerup Pickup Countdown || When timer hits zero, the powerup disappears.
|-
|$04F1-04F4 || Powerup Number in Room || Stores the index representing the powerup at the $9C and $9E pointers for the room.
|-
|$04F5-04FF || Powerup Found Bitfield || Each bit here represents a powerup.  If the bit is true, the powerup is either already on the screen or has already been found and will not spawn again.
|-
|$0500-05FF || Unused
|-
|$0600-0605 || Play Sound || Storing a value to any of these addresses causes music or a sound effect to be played.  Although there are five slots, allowing multiple sounds to be initiated at once, only $0600 appears to be used.
|-
|$0606-06FF || Sound data
|-
|$0700-07FF || PPU transmission buffer || Data for palettes, level environments, the status bar, or anything else can be written here and transmitted to the PPU during NMI, as long as the value in $2B/2C is set to x0700.  See $2B/2C for details on formatting.  In practice, only values up to $074B are ever written to, the rest are unused.
|}
|}
<br>
<br>
{{stub}}
{{stub}}
{{Internal Data|game=Ninja Gaiden}}
{{Internal Data|game=Ninja Gaiden}}

Latest revision as of 20:35, 28 January 2024

Chip tiny.png The following article is a RAM map for Ninja Gaiden (NES).

Note:

  • All RAM addresses are initialized to zero shortly after reset or power-on. Variables marked as unused are never written to or used again.
RAM Function Detail
$00-09 Scratchwork Used in various calculations
$03 Upper Left Collision Holds the collision value of the tile on Ryu's upper left. Also a scratchwork variable elsewhere
$04 Lower Left Collision Holds the collision value of the tile on Ryu's lower left. Also a scratchwork variable elsewhere
$0A-0B Cut-Scene Bytecode Pointer Scripting at this address controls the game flow during cut-scenes.
$0C-0D Cut-scene Nametable Attribute PPU Address Only used for writing data to the attribute array of a nametable in a cut-scene.
$0E-0F Cut-Scene Function Pointer, Relative PPU Address adjustment Used as an indirect to read the values that it will store back into itself before acting as a function pointer. $0E is Also used to store value to add to $E4-E5 when incrementing the PPU draw position during cut-scenes.
$10 Room Loading Loop Controller Loads the first screen you see when a room loads, one column of tiles at a time.
$11 Stage End Loop Control Similar to $0010 in it's use. It gets used when you complete a stage to ensure that the status bar is fully updated before fading out
$12 Unused
$13-14 Reusable Indirect Pointer Holds pointers for accessing data types through indirects
$15-16 Reusable Indirect Pointer Holds pointers for accessing data types through indirects
$17-18 Reusable Function Pointer Used to hold a function pointer accessed by JMP indirect opcode. Used for:
  • 1. Performing different functions based on D-Pad inputs
  • 2. Obtaining powerups
  • 3. Hitting a special collision tile (room advance, room retreat, stage advance, start cut-scene)
$19-1B Unused
$1C PPUCTRL Base Base value written to $2000 (PPUCTRL) every frame
$1D PPUMASK Base Value written to $2001 (PPU_MASK) every frame
$1E Pause Check Top bit (x80) used to check whether the game is paused
$1F NMI Detector Used to check whether an NMI has occurred. Used for "wait for NMI" loops. Value set to FF at end of NMI.
$20-22 Interrupt Variables Only used for calculations that occur within NMI to prevent conflicts with other variables
$23-27 Unused
$28 Controller Input Bitfield holding the buttons currently being held down on controller 1.
  • x01 = Right
  • x02 = Left
  • x04 = Down
  • x08 = Up
  • x10 = Start
  • x20 = Select
  • x40 = B
  • x80 = A
$29 Controller Presses Same as $28, except only holding values for buttons that were just pressed that frame.
$2A Previous Controller Input Similar to $28. Used for determining $29.
$2B-2C PPU Transmission Pointer Pointer for data to be transmitted to PPU during the next NMI. Format is:
  • Byte 0: Size of data to be transmitted in bytes. If top bit is set, sets bit 1 of $2000 (PPUCTRL), used for writing tile data vertically on-screen instead of horizontal. If the size byte is 0, end transmission.
  • Byte 1: low byte of PPU address
  • Byte 2: high byte of PPU address
  • Byte 3-X: data to be transmitted
  • After each set of data transmitted, the pattern will repeat until the size byte is read as zero.
$2D Interrupt Prior A Used to store and restore the accumulator value when an NMI is triggered
$2E Interrupt Prior X Used to store and restore the X register value when an NMI is triggered
$2F Interrupt Prior Y Used to store and restore the Y register value when an NMI is triggered
$30-31 Sprite Tile Pointer Holds a pointer to the start of sprite tile and position data when calculating sprite data before transmission to OAM array.
$32-33 Sprite Attribute Pointer Holds a pointer to the start of sprite attribute data when calculating sprite data before transmission to OAM array
$34 Sprite Flip Bits Holds horizontal and vertical flip data for Ryu or Enemies when calculating sprite positions and attributes.
$35 Sprite Alternate Attributes Used to change $32-33 when an enemy or powerup has an "alternate" set of attribute data.
$36 Sprite Base X Holds X coordinate of object to be displayed on-screen during sprite calculations
$37 Sprite Base Y Holds Y coordinate of object to be displayed on-screen during sprite calculations
$38 Sprite Tile Pointer Offset Holds offset into sprite tile and position data during sprite calculations
$39 Sprite Attribute Pointer Offset Holds offset into sprite attribute data during sprite calculations
$3A Sprite Tiles Remaining Holds the number of remaining sprite tiles to display for the current entity during sprite calculations
$3B Sprite Write Position Holds the current write position within the OAM data array at $200-2FF for writing sprite tiles.
$3C Sprite Temp Variable Used in sprite calculations when a sprite object is horizontally flipped.
$3D Room Reverse Top bit (x80) determines whether a room scrolls in reverse direction or not.
$3E Status Bar Update State Determines which part of the status bar to update on the next frame.
$3F Scratchwork Used as a scratchwork variable when reversing an enemy's movement direction.
$40-41 Level Data Pointer Pointer to the the next set of Level data to load during scrolling.
$42-43 4x4 Tile Set Address Pointer to the array which selects four sets of 2x2 tiles to display on-screen for each byte of level data. Each entry is four bytes: top left, bottom left, top right, bottom right.
$44-45 2x2 Tile Set Address Pointer to the array which defines the 2x2 tile sets that are displayed on-screen. This array holds the actual tile values to transmit to the PPU. Each entry is four bytes: top left, bottom left, top right, bottom right.
$46-47 4x4 Palette Set Address Pointer to the array which determines the palette of each 2x2 tile set within each byte of level data. Each byte consists of 4 sets of 2 bits, where each set forms a value 0-3 selecting the BG palette to use.
$48-49 Collision Set Address Pointer to the array which determines the collision values to associate with each 2x2 tile set within each byte of level data. There are 2 bytes for each entry. Each nybble (upper or lower 4 bits) determines a collision value, in the order top left, bottom left, top right, bottom right. The collision values 0-F index into an array at ROM x1E792 or x1E132 (with iNES header) that determine the actual collision bitfield. Ryu uses the bitfield from x1E792, while enemies use the values from x1E132. Values of xA or greater also have special properties for Ryu, such as advancing rooms or stages or starting a cut-scene.
$4A-4B Movement Tracker - Collision Keeps track of Ryu's movement. When Ryu moves x10 or more pixels in either direction, the value in $5F is shifted by 6 accordingly to change the starting offset into the collision array at $0300-03BF. After this occurs, the top nybble of $4B is cleared.
$4C Nametable Selector, Movement Direction, Large PPU transmission indicator Least bit is ORA'ed with $1C to determine the nametable to use for the starting scroll position. Bit 6 (x40) is set when new tile data is loaded into the PPU transmission array at $0700-07FF. When bit 6 is set, the status bar will not be updated that frame to prevent graphical glitches. Certain enemy actions will also be skipped. When Ryu is moving to the left, the top bit is set.
$4D ???? Appears to have been intended to serve a similar purpose to the nametable selector bits of $4C. However, it is associated with variables $AE-AF and $A4-A5, which are set but never used. Possibly a result of code remnants intended to create vertical scrolling in the levels.
$4E Left Edge Room Position Horizontal position within the level, in terms of 2 tile increments. Value increases by one every x10 pixels. This value corresponds directly to the position of the left side of the screen within the level. This value is used to determine whether enemies spawn, or whether powerups spawn while you are moving left.
$4F Right Edge Room Position Same as 4E, but x10 higher. This value corresponds directly to the position of the right side of the screen within the level. This value is used to determine whether powerups spawn if you are moving right.
$50-52 Room X Position Horizontal position within the level. $52 is the number of full "screens" of movement, $51 is pixels, and $50 is partial pixels. If $52 is negative, scrolling left is prohibited.
$53 Room Width Width of the room, in "screens". If $52==$53, right scrolling is prevented. If $53==0, there is no scrolling.
$54-55 Unused
$56 Graphics page for sprites in the status bar
$57 Graphics page for sprites on the lower half of the screen.
$58 Unused
$59 Graphics page for backgrounds on the status bar
$5A Graphics page for the level environment.
$5B Unused
$5C Prior PRG Bank Last PRG bank swapped to outside of NMI. NMI restores this bank when it exits.
$5D-5E Collision Write Address Write position within the collision array at $0300-03BF. Level collision data read from ROM is written here. Upper byte ($5E) is always 3.
$5F Collision Offset Current offset into the collision array at $0300-03BF. As scrolling occurs, value is incremented by 6 for each 2x2 column. Value wraps back to 0 after xC0, the width of the collision array.
$60-61 Score total
$62 Frame Countdown Timer Values count down from 3C (60). When they wrap around to negative, one second is removed from the time left to complete the stage.
$63 Time remaining
$64 Ninja Power/Spiritual Energy
$65 Ryu's Health Max value is x10
$66 Boss Health Max value is x10. Only affects the amount displayed in the status bar. Real enemy health is stored in an array at $0490-$0497.
$67-68 Movement Tracker - PPU Update Keeps track of Ryu's movement similarly to $4A-4B. When Ryu has moved x10 or more pixels, it triggers new tiles to be transmitted to the nametable. This also sets bit 6 of $4C, preventing new data from being transmitted to the status bar that frame.
$69-6A Movement Tracker - Pointer Updater Keeps track of Ryu's movement similarly to $4A-4B and $67-68. However, the value resets every x20 pixels instead of every x10. When this occurs, the pointer to the next set of level data to read ($40/41) is incremented or decremented by 6, and the write position within the collision array at $0300-03FF is incremented or decremented by xC.
$6B-6C PPU Base Address for Level Drawing Base offset into the current nametable used for calculating the location to store new tiles while scrolling, and also locate positions in the nametable attribute array to write the new palette data.
$6D The current stage
$6E The current room Stages can have multiple rooms.
$6F Room Re-entry Boolean Top bit is set when you return to a previous room, and plays a role in correctly placing you at the opposite end of the room from where you normally would start.
$70-71 Enemy AI Pointer Holds a pointer to the list of AI function pointers for the enemy that is currently being processed.
$72 The number of enemies on the screen
$73 Enemy Slots This byte is a bitfield, where each bit indicates that an enemy is occupying a specific "slot". There are 8 enemy slots, and thus most enemy variables are stored in arrays that are 8 bytes long, one for each possible enemy.
$74 Enemy Actions Holds the number of remaining enemy actions that can be processed in a given frame. It appears that at one point the programmers intended there to be a different number of potential enemy actions in a given frame depending on how many enemies are on-screen, but this functionality was scrapped due to the numerous glitches it would cause. As a result, there are only 8 enemy actions available per frame, one for each slot. This variable counts down even if no enemy is occupying the slot, such that each enemy effectively only has its AI calculated once per frame.
$75 Last Enemy Holds the slot number of the last enemy that was processed, so that processing can begin on the next enemy next frame. Was intended to work with the variable amount of enemy actions mentioned in $74, but currently this value will always hold 0, since each enemy's AI is calculated only once per frame.
$76 Remaining Lives
$77 Boss Rush Progress Keeps track of your progress on the final boss-rush, so that you can skip the bosses you have already defeated.
$78 Unused
$79 Enemy Flags Copied from $0498,X array for the given enemy slot while enemy is being processed. Bits:
  • x01: Set if Enemy is a boss
  • x02: Set if Enemy was spawned by another enemy, not part of the normal spawn list
  • x04: Set if Enemy is jumping or falling in the Y direction
  • x10: Set if Enemy has been defeated and is performing its death explosion
  • x40: Set if Enemy is able to move in the X direction
  • x80: Set if Enemy ignores environment collision
$7A Enemy Attribute Flags Copied from $0440,X array for the given enemy slot while enemy is being processed. Bits 0 and 1 form a value from 0 to 3 that is capable of selecting an alternate set of attribute data for the enemy's sprite tiles. Only a couple enemies have extra attribute data defined. Bit 6 (x40) is set if the enemy is facing left (horizontally flipped). Bit 7 can trigger a vertical flip in the sprites, but enemies more than one sprite tall will not display properly.
$7B Restore PPUCTRL Base Stores the value from $1C while a cut-scene is playing, so it can restore it afterwards.
$7C Restore PPUMASK Base Stores the value from $1D while a cut-scene is playing, so it can restore it afterwards.
$7D Restore Sprite Graphics Page Stores the value from $56 while a cut-scene is playing, so it can restore it afterwards.
$7E Restore Status Bar Graphics Page Stores the value from $59 while a cut-scene is playing, so it can restore it afterwards.
$7F Restore Prior PRG Bank Stores the value from $5C while a cut-scene is playing, so it can restore it afterwards.
$80 Ryu's Animation Sequence Number
$81 Offset into Ryu's current animation sequence
$82 Time remaining for Ryu's current animation frame
$83 Ryu's current animation frame #
$84 Ryu's flags Bitfield Values:
  • x01 Recently took damage
  • x02 Invincible
  • x04 Jumping or falling (Moving in Y direction)
  • x08 Currently performing an animated action. Cannot start a new one until the animation completes
  • x10 Flickering effect
  • x20 BG priority set. Ryu can appear "behind" the background.
  • x40 Horizontal Flip
  • x80 Vertical flip (glitchy)
$85-86 Ryu's Horizontal (X) position on-screen $85 is a fractional pixel value, $86 is the integer pixel value.
$87 Ryu's Fractional vertical speed Value/x100 pixels per frame.
$89 Ryu's Integer vertical speed Pixels per frame.
$8A Ryu's vertical (Y) position on-screen.
$8B Dead Boolean Top bit used to indicate Ryu has died. Set it to kill Ryu.
$8C Ryu's collision flags Bitfield values:
  • x01 Right wall
  • x02 Right wall that you can latch to
  • x04 Left wall
  • x08 Left wall that you can latch to
  • x10 Platform
  • x20 Ladder
  • x40 unused
  • x80 Set if top half of Ryu passed through a latch-able wall but not his feet. Used to allow Ryu to pass through some walls.
$8D Flicker Counter Used for Ryu's flickering effect when he is hit. Determines whether to display his sprites that frame.
$8E Upper Right Collision Stores the collision value of the tile on Ryu's upper right
$8F Lower Right Collision Stores the collision value of the tile on Ryu's lower right
$90 Ryu's Hitbox Height For determining whether an enemy can hit him.
$91 Ryu's Attack Box Top Height to top of Ryu's hitbox, determining whether he can hit an enemy with sword
$92 Ryu's Attack Box Bottom Height to bottom of Ryu's hitbox, determining whether he can hit an enemy with sword
$93 Hit Indicator Used to indicate Ryu was recently hit, and whether or not he has hit the ground.
$94 Flinch Direction Determines the direction Ryu will flinch after being hit. Overrides user input and writes direction to $28.
$95 Invincibility timer after Ryu is hit
$96-97 Enemy Spawn Pointer Pointer to horizontal spawn positions of enemies within the room. Compare values at address with value in $4E to determine whether to spawn.
$98-99 Enemy YX Pointer Pointer to screen positions for enemies that spawn in the current room. Upper nybbles are Y position, lower are X position.
$9A-9B Enemy Type Pointer Pointer to enemy type ID #'s for enemies that spawn in the current room.
$9C-9D Powerup Spawn Pointer Pointer to horizontal spawn positions of powerups within the current room. Compare values with $4E and $4F to determine whether to spawn.
$9E-9F Powerup Type Pointer Pointer to powerup type ID #'s and Y position for powerups that spawn in the current room. Upper nybbles are Y position, lower are the type.
$A0-A1 Horizontal Scroll 1 Horizontal scroll position of top part of screen. $A0 is fractional position, $A1 is integer position. Only changes in cut-scenes, or else it would move the status bar.
$A2-A3 Horizontal Scroll 2 Scroll position in a level. $A2 is a fractional position, $A3 is the integer position, stored to PPUSCROLL after the sprite zero hit detected from status bar.
$A4-A5 ???? Possibly meant to be a vertical scroll for the level. $A4 is a fractional part, while $A5 is an integer part. But the resulting values are never used.
$A6-A7 Vertical Scroll Vertical scroll position of the screen. $A6 is fractional position, $A7 is integer position. Only changes during cut-scenes.
$A8 Unused
$A9 Broken Vertical Scroll Meant to be a vertical scroll for the lower part of the screen while in a stage, but it does not work correctly.
$AA-AB Unused
$AC-AD Ryu's horizontal (X) movement speed $AC is the fractional part, $AD is the integer part.
$AE-AF ???? Potentially meant to be vertical scrolling speed (values added to $A4-A5 while scrolling), but these are always zero, and forcing them to be different does not change any apparent game behavior other than modifying $A4-A5 while you move.
$B0-B3 Unused
$B4 Number of Enemies Number of enemies in the current room. If top bit is set, no enemies spawn.
$B5 Current Enemy Spawn Check Enemy number in the list of available enemies for the room currently being tested to see if it can spawn. The spawn code cycles through every enemy in the list, but it can only check 8 in a given frame. With enough enemies in a room or a fast enough movement speed, it is possible to skip some enemy spawns.
$B7-BD On-Screen Enemy Bits Used to keep track of enemies that are currently loaded on-screen. This prevents duplicate enemies from spawning. Each enemy is assigned a bit in this array according to it's position in the enemy list found at the $96,$98, and $9A pointers.
$BE Cut-Scene Initiate Top bit is set to indicate that a cut-scene is about to start.
$BF Frame counter Value is incremented by 1 during the NMI code. NG uses the counter as a crude RNG for some enemy AI.
$C0 Powerup bitfield Each of the lower 4 bits acts as a "slot" that is filled when a powerup spawns at the edge of the screen. Only 4 powerups can be on the screen at once.
$C1 Number Powerups The number of powerups available in the room. One is considered the minimum size, even if no powerup actually spawns in the room.
$C2 Powerup Animation Animation sequence # to use for the lanterns that hold the powerups.
$C3 Time remaining for the current powerup lantern animation frame.
$C4 Animation frame # for the powerup lanterns
$C5 Offset into the animation sequence for the powerup lanterns.
$C6 Powerup Left Spawn Offset Index into the available array of spawnable powerups from $9C/$9E pointers. This one is used to spawn powerups when moving left.
$C7 Powerup Right Spawn Offset Index into the available array of spawnable powerups from $9C/$9E pointers. This one is used to spawn powerups when moving right.
$C8 Ryu's projectile slots Bits 0,1, and 2 are each a slot for a projectile. No more than three can exist at once on screen.
$C9 Ryu's equipped sub-weapon
$CA Animation sequence # for the currently equipped sub-weapon, if a projectile
$CB Time remaining for current projectile animation frame
$CC Offset into the animation sequence for the current projectile
$CD Animation Frame # for the current projectile
$CE Projectile Size Temporarily holds size of projectile in pixels, both horizontally and vertically (all projectiles are considered square). Also gets reused to store the projectile number when looping through projectiles to display their sprites on-screen.
$CF Projectile Damage Temporarily holds amount of damage to be done by a projectile.
$D0 Time Stop Boolean Top bit activates the enemy time-stop effect when set.
$D1-DF Unused
$E0-E1 Cut-Scene X Scroll Speed of horizontal scrolling during a cut-scene, in pixels per frame. $E0 is fractional part, $E1 is integer part.
$E2-E3 Cut-Scene Y Scroll Speed of vertical scrolling during a cut-scene, in pixels per frame. $E2 is fractional part, $E3 is integer part.
$E4-E5 Cut-Scene BG Draw Address Forms a PPU address used to draw background images to the nametables during a cut-scene.
$E6-E7 Cut-Scene Dialog Pointer Pointer to the current line of text to display during a cut-scene.
$E8-E9 Cut-Scene PPU Transmission Setup Used by a cut-scene script command as a pointer to copy and set up a string of data to be transmitted to the PPU via $2006/$2007.
$EA Cut-Scene Button Presses Used to store all buttons held on the previous frame during a cut-scene. Used to find exact moment player pressed Start to exit a scene.
$EB-EF Unused
$F0-FD Used in sound processing.
$FE-FF Unused
$0100-01FF Stack
$0200-02FF Sprite data copied to OAM
$0300-03BF Environment collision data $0300-03FF also serves a variety of other purposes during cut-scenes
0x0314 Current character index printing for current text in cut-scenes
0x03c7 current character being printed in cut-scenes
$0400-0407 Enemy type ID #'s for each enemy slot
$0408-040F Enemy AI timer for each enemy slot
$0410-0417 Enemy AI stage for each enemy slot Different stages select a different function pointer from the list of available AI pointers for each enemy type. See $70/71
$0418-041F Unused. Available for enemy AI if needed.
$0420-0427 Time remaining for the current animation frame # for each enemy slot.
$0428-042F Animation sequence # for each enemy slot
$0430-0437 Offset into animation sequence for each enemy slot
$0438-043F Animation frame # for each enemy slot
$0440-0447 Enemy attribute flags for each enemy slot. See variable $7A.
$0448-044F Fractional enemy X velocity for each enemy slot.
$0450-0457 Integer enemy X velocity for each enemy slot, in pixels per frame.
$0458-045F Fractional enemy X position on-screen for each enemy slot.
$0460-0467 Enemy X position on-screen for each enemy slot.
$0468-046F Fractional enemy Y velocity for each enemy slot.
$0470-0477 Integer enemy Y velocity for each enemy slot, in pixels per frame.
$0478-047F Fractional enemy Y position on-screen for each enemy slot.
$0480-0487 Enemy Y position on-screen for each enemy slot.
$0488-048F Enemy collision flags for each enemy slot. Bitfield values:
  • x10 = Platform to the right
  • x20 = Platform to the left
  • x40 = Wall to the right
  • x80 = Wall to the left
$0490-0497 Enemy HP Hit points for each enemy slot. Enemies with 0 HP are valid, and will die as soon as they are hit by any weapon.
$0498-049F Enemy flags for each enemy slot See variable $79.
$04A0-04A7 Available variable to use for enemy AI, one for each enemy slot Typically used with projectiles to keep track of the enemy slot number that spawned them.
$04A8-04AF Unused. Available for enemy AI if needed.
$04B0-04B7 Enemy number for a given room As it appears in the order of data at $96/$98/9A pointers.
$04B8 Boss Kill Indicator Top two bits set if a boss was just killed. Prevents new sound effects and projectiles during boss death animation, and triggers the score boost based on your remaining time and Ninja power.
$04B9 Boss Kill Countdown timer Activates right after you kill a boss. It represents the minimum time before triggering a cut-scene and stage advance. If you still have

Ninja power or remaining time when this hits zero, it waits until everything is zero before triggering the cut-scene.

$04BA Boss Short timer Cycles every 3 frames after you kill a boss. Each time it wraps, it plays a sound effect and drops your Ninja Power or Time

remaining by one, while also increasing your score total.

$04BB-04BD X position of Ryu's projectiles Three different slots for throwing stars and fire wheel. Boomerang star can only use slot 1.
$04BE-04C0 Y position of Ryu's projectiles Three different slots for throwing stars and fire wheel. Boomerang star can only use slot 1.
$04C1-04C3 X movement speed of Ryu's projectiles, for each slot Boomering star uses fractional X speed also, using $04C2 for fractional and $04C1 for integer speed.
$04C4-04C6 Y movement speed of Ryu's projectiles, for each slot Boomerang star does not use these at all, it simply increases or decreases Y position by 1 if Ryu is higher or lower.
$04C7 Fractional Powerup countdown timer For invincibility flame and time stop powerup items. When this value hits zero, it is restored to x3C, a sound effect is played, and the main timer ($04C8) is decremented.
$04C8 Powerup Timer For the invincibility flame and time-stop powerup items. Value is in seconds.
$04C9-04CC Powerup type id # for each slot
$04CD-04D0 Powerup animation frame # for each slot
$04D1-04D4 Powerup info for each slot Least two bits form a value 0-3 that can be used to select alternate attribute data for the powerup's sprites. Bit 2 (x04) indicates that the lantern has been hit, revealing the powerup. Bit 3 (x08) indicates that Ryu has picked up the powerup.
$04D5-04D8 Powerup Fractional X position on-screen
$04D9-04DC Powerup X position on-screen
$04DD-04E0 Powerup Fractional Y position on-screen Used when powerup has been revealed and is falling to the ground
$04E1-04E4 Powerup Y position on-screen
$04E5-04E8 Powerup Fractional Y Speed Value/x100 pixels per frame. Used after powerup has been revealed and is falling
$04E9-04EC Powerup Integer Y Speed In pixels per frame. Used after powerup has been revealed and is falling
$04ED-04F0 Powerup Pickup Countdown When timer hits zero, the powerup disappears.
$04F1-04F4 Powerup Number in Room Stores the index representing the powerup at the $9C and $9E pointers for the room.
$04F5-04FF Powerup Found Bitfield Each bit here represents a powerup. If the bit is true, the powerup is either already on the screen or has already been found and will not spawn again.
$0500-05FF Unused
$0600-0605 Play Sound Storing a value to any of these addresses causes music or a sound effect to be played. Although there are five slots, allowing multiple sounds to be initiated at once, only $0600 appears to be used.
$0606-06FF Sound data
$0700-07FF PPU transmission buffer Data for palettes, level environments, the status bar, or anything else can be written here and transmitted to the PPU during NMI, as long as the value in $2B/2C is set to x0700. See $2B/2C for details on formatting. In practice, only values up to $074B are ever written to, the rest are unused.


So very stubbly.
This page is rather stubbly and could use some expansion.
Are you a bad enough dude to rescue this article?