If you are still using the old URL (datacrystal.romhacking.net), please update your bookmarks! The old URL may stop working soon.
The current URL is datacrystal.tcrf.net.
The current URL is datacrystal.tcrf.net.
Sonic the Hedgehog (Genesis)/RAM map
Jump to navigation
Jump to search
Note: This page has been copied from http://info.sonicretro.org/SCHG:Sonic_the_Hedgehog/RAM_Editing with minor modifications.
Main System Memory Locations
This is a map of 68k memory as used by the main gameplay engine.
RAM offset | Description |
---|---|
$FF0000 - $FFA3FF | Chunk mappings |
$FFA400 - $FFA7FF | Level layout (1 byte per chunk, $40 bytes per line, lines for planes A and B interlaced) |
$FFA800 - $FFA9FF | Something to do with background scrolling in Star Light Zone |
$FFAA00 - $FFABFF | Something to do with the pattern load queue |
$FFAC00 - $FFAFFF | Sprite table (2 bytes per sprite + 2 bytes per priority level, each priority level takes $80 bytes.) |
$FFB000 - $FFC7FF | Block mappings |
$FFC800 - $FFCAFF | Sonic's art buffer. Sonic's dynamic pattern reloading routine copies the relevant art over here, from where it is DMAed to VRAM every V-int. |
$FFCB00 - $FFCBFF | Sonic previous position array (used for invincibility stars and such) |
$FFCC00 - $FFCFFF | Scroll RAM cache (sent to VRAM every frame via DMA) |
$FFD000 - $FFD7FF | Object table -- Reserved |
$FFD800 - $FFEFFF | Object table -- Main |
$FFF600 | Game Mode
|
$FFF616-$FFF617 | Plane A y-position for previous frame |
$FFF618-$FFF619 | Plane B y-position for previous frame |
$FFF61A-$FFF61B | Plane A x-position for previous frame |
$FFF61C-$FFF61D | Plane B x-position for previous frame |
$FFF61E-$FFF61F | Value of $F71C for previous frame |
$FFF620-$FFF621 | Value of $F718 for previous frame |
$FFF680 | Address queue for Pattern Load Cues |
$FFF700-$FFF701 | Plane A x-position |
$FFF704-$FFF705 | Plane A y-position |
$FFF708-$FFF709 | Plane B x-position |
$FFF70C-$FFF70D | Plane B y-position |
$FFF744 | Scroll Hold Flag (set to stop all scrolling dead) |
$FFF754-$FFF755 $FFF756-$FFF757 $FFF758-$FFF759 $FFF75A-$FFF75B |
Bitfields used by the scrolling engine |
$FFF760-$FFF761 | Sonic's Top Speed |
$FFF762-$FFF763 | Sonic's Acceleration |
$FFF764-$FFF765 | Sonic's Deceleration |
$FFF7AA | Screen Lock Flag (Set to lock screen) |
$FFF7C8 | Control Lock Flag (Set to lock controls) |
$FFFA00-$FFFA7F | Target underwater palette |
$FFFA80-$FFFAFF | Normal underwater palette |
$FFFB00-$FFFB7F | Normal palette |
$FFFB80-$FFFBFF | Target palette (calling Pal_FadeTo will brighten the normal palette until it is the same as the target palette) |
$FFFC00-$FFFD7F | Destroyable object state table |
$FFFE02 | Restart Level Flag (Set to restart level) |
$FFFE04-$FFFE05 | Level Timer (in frames) |
$FFFE10-$FFFE11 | Zone/Act |
$FFFE12-$FFFE13 | Rings |
$FFFE14-$FFFE15 | Remaining Air (When underwater) |
$FFFE16 | Last Special Stage Entered |
$FFFE18 | Continues |
$FFFE1C | Lives Counter Update Flag (Set to update lives total on screen) |
$FFFE1D | Ring Counter Update Flag (Set to update rings total on screen) |
$FFFE1E | Time Counter Update Flag (Set to update current time on screen) |
$FFFE1F | Score Counter Update Flag (Set to update score total on screen) |
$FFFE20-$FFFE21 | Ring Count |
$FFFE23 | Level Timer (Minutes) |
$FFFE24 | Level Timer (Seconds) |
$FFFE23 | Level Timer (Frames since last second) |
$FFFE26-$FFFE29 | Score |
$FFFE2C | Shield Flag (Set to take a single hit without losing rings) |
$FFFE2D | Invincibility Flag (Set to make Sonic invincible) |
$FFFE2E | Speed Shoes Flag (Set to activate speed shoe physics) |
$FFFE30 | Lamppost Counter |
$FFFE57 | Emeralds |
$FFFFF4 | Credits Index Number |
Object Table Format
The Object Status Table is located at RAM address $FFD000. Each entry is $40 bytes long. Here is a list of all the values for one entry in the OST:
Offset | Size | Description | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
$00 | byte | Object type | |||||||||||||||||||||||||||
$01 | byte | Render flags. The bitfield looks like this:
| |||||||||||||||||||||||||||
$02 | word | Starting art block.
| |||||||||||||||||||||||||||
$04 | long | Mappings offset | |||||||||||||||||||||||||||
$08 | word |
| |||||||||||||||||||||||||||
$0A | word |
| |||||||||||||||||||||||||||
$0C | word |
| |||||||||||||||||||||||||||
$0E | word |
| |||||||||||||||||||||||||||
$10 | word | Horizontal (X) velocity | |||||||||||||||||||||||||||
$12 | word | Vertical (Y) velocity | |||||||||||||||||||||||||||
$14 | word | Ground velocity (inertia). | |||||||||||||||||||||||||||
$16 | byte | Height/2 | |||||||||||||||||||||||||||
$17 | byte | Width/2 | |||||||||||||||||||||||||||
$18 | byte | Sprite priority (00 = front). | |||||||||||||||||||||||||||
$19 | byte | Width of the object, in pixels | |||||||||||||||||||||||||||
$1A | byte | Current animation frame to display. i.e, the frame currently being displayed on-screen, according to the animation script (currently parsed mappings frame, in other words). | |||||||||||||||||||||||||||
$1B | byte | Current frame in animation script. i.e, the frame entry IN the animation script being currently processed. | |||||||||||||||||||||||||||
$1C | byte | Animation number. When an animation ID is moved here, it's processed and displayed. | |||||||||||||||||||||||||||
$1D | byte | Restart animation flag (when $1D is not equal to $1C, animation restarts) | |||||||||||||||||||||||||||
$1E | byte | Animation frame duration (time until next frame). | |||||||||||||||||||||||||||
$20 | byte | Collision response bitfield. Tells what the object will do if hit by the character. The bitfield is in the format TTSS SSSS. TT is the type of collision - 00 is enemy, 01 increments the routine counter, 10 is harm, and 11 seems to be a special thing for the starpole. SSSSSS is the size, lifted from a lookup table in the collision response routine. | |||||||||||||||||||||||||||
$21 | byte | Custom collision property, for special interaction with Sonic. This is used by bosses, badniks, bumpers and other objects. The way in which this byte is used is different for each object. Bosses use this byte as a hit counter. | |||||||||||||||||||||||||||
$22 | byte | Status bitfield.
Counting from the least significant bit:
| |||||||||||||||||||||||||||
$23 | byte | Respawn index reference number, used by badniks, rings and monitors. Each destroyable object is assigned an index number (01, 02, 03 etc.) which refers to a list at $FC00 in the RAM. | |||||||||||||||||||||||||||
$24 | byte | Routine counter. | |||||||||||||||||||||||||||
$25 | byte | Second routine counter. This is used for some of the more complicated objects. | |||||||||||||||||||||||||||
$26 | word | Angle. | |||||||||||||||||||||||||||
$28 | byte | Object subtype. For example, the current monitor selected. See the Object List above for values. Has a different meaning for Sonic. | |||||||||||||||||||||||||||
$29-$3F | Object's scratch RAM | ||||||||||||||||||||||||||||
Sonic-specific variables | |||||||||||||||||||||||||||||
Offset | Size | Description | |||||||||||||||||||||||||||
$22 | byte | Special bitfield. Counting from the least significant bit:
You can add the hex values together to use multiple settings at once. Also notice that the first 3 bits (0-2) are used in the character object as a second routine counter. | |||||||||||||||||||||||||||
$28 | byte | Seconds of air left. Usually $1E; it decrements every second while the player is underwater. Beeps on $18, $13, and $0E. Countdown starts on $0B. | |||||||||||||||||||||||||||
$2B | byte | Unused | |||||||||||||||||||||||||||
$30-$31 | word | Remaining invulnerability time. Starts at $0078 after Sonic is hit, and seems to decrement every frame until it reaches $0000. | |||||||||||||||||||||||||||
$32-$33 | word | Remaining time of invincibility. | |||||||||||||||||||||||||||
$34-$35 | word | Remaining time of Speed Shoes. | |||||||||||||||||||||||||||
$36 | byte | Angle of ground at Sonic's front collision hot spot ($03 is "edge of ground") | |||||||||||||||||||||||||||
$37 | byte | Angle of ground at Sonic's rear collision hot spot | |||||||||||||||||||||||||||
$39 | byte | Unused. | |||||||||||||||||||||||||||
$3A-$3B | word | Unused. | |||||||||||||||||||||||||||
$3C | byte | Set if jumping. | |||||||||||||||||||||||||||
$3D | byte | OST index of object currently being stood on. (multiply by $40 and add $D000 to get the object's address). | |||||||||||||||||||||||||||
Boss Variables | |||||||||||||||||||||||||||||
Offset | Size | Description | |||||||||||||||||||||||||||
$21 | byte | Hit counter. Number of hits it takes to defeat a boss. | |||||||||||||||||||||||||||
$30 | word | X position | |||||||||||||||||||||||||||
$38 | word | Y position | |||||||||||||||||||||||||||
$3E | byte | Number of times to flash when hit |