Actions

SCHG

Difference between revisions of "Sonic the Hedgehog (16-bit)"

From Sonic Retro

(Uncompressed Art Locations)
m (Main System Memory Locations)
Line 1,225: Line 1,225:
 
This is a map of 68k memory as used by the main gameplay engine. Note that any numbers entered (for example, score or number of rings) will have to be converted to hex first.
 
This is a map of 68k memory as used by the main gameplay engine. Note that any numbers entered (for example, score or number of rings) will have to be converted to hex first.
  
These are the offsets in RAM. To convert them to Genecyst savestate offsets, add $2478.
+
These are the offsets in RAM. To convert them to [[Genecyst]] savestate offsets, add $2478.
{| border="1"
+
{| border="1" class="prettytable"
 
!RAM offset||Description
 
!RAM offset||Description
 
|-
 
|-

Revision as of 13:54, 20 September 2007

Sonicretro-round.svg This short article is in need of work. You can help Sonic Retro by adding to it.
Back to SCHG main page

ROM Hacking

Art Editing

There are several different tools that can be used to edit art besides the hex editor. SonED is probably the best tool to use for editing level art, and can also be used on palettes. HivePal is also a great tool for editing palettes. Sonik Sprite is useful for editing uncompressed art; it gets its name from its ability to edit Sonic's sprites. LOst Library is most likely the best choice for editing compressed art in the Nemesis format.

If, however, you still want to do it yourself, your best bet is to download the Sonic 1 Split disassembly. Decompress the archive into a new folder, and place your S1 ROM, in binary format and named "S1.bin", in that folder. Run the batch file "split.bat". This will split up all the art into its own binary files, which you can then decompress and edit. When you're done, run "combine.bat".

Uncompressed Art Locations

Most of this information was taken from Nemesis's guide. Please excuse any mistakes or misunderstandings, as that guide wasn't exactly well-written. A description is written in parentheses after the original name if I deem it necessary; if I don't know what it is, "Unknown" appears in that place. Please correct this if you know. It doesn't list the number of blocks taken up, so if you know, put it in. Otherwise, I'll find out eventually.

Uncompressed Art Locations

Offset Description # of blocks
Zone Independent
$1CADA Numbers used on counters in game ?
$21AFE Sonic ?
$6A324 Giant Ring ?
Green Hill Zone
$66AD6 Waterfall tiles ?
$66CD6 Flower with pointy petals ?
$670D6 Flower with curved petals ?
Marble Zone
$6755A Lava surface ?
$67836 Lava ?
$67E56 Flame torch against stone ?
Scrap Brain Zone
$68156 Steam in background ?

Compressed Art Locations - Nemesis

See SCHG:Sonic the Hedgehog/Nemesis Compressed Art.

Compressed Art Locations - Kosinski format

  • $3DCF2 - GHZ main level patterns
  • $414D4 - LZ main level patterns
  • $46016 - MZ main level patterns
  • $4A7FE - SLZ main level patterns
  • $510F0 - SYZ main level patterns
  • $57A66 - SBZ main level patterns

Palette Locations

Usually, it's not really necessary to edit a palette in hex. Palette editors give you instant feedback for each RGB value, and the palette can be easily saved as a separate binary and reimported into the ROM. However, it is sometimes desirable or necessary to do it in hex, and it can't hurt to know how it's done.

These are the ROM offsets of the palettes in Sonic 1, as listed by HivePal:

Name Offset
Sega Logo (Background) $2208
Sega Logo (SEGA) $20C0
Title Screen $2288
Title Screen - Water Cycle $1B66
Level Select $2308
Sonic $2388
Green Hill $23A8
Green Hill - Water Cycle $1B86
Labyrinth $2408
Labyrinth - Sonic Underwater $2828
Labyrinth - Sonic Underwater (Alt) $2468
Labyrinth - Underwater $2488
Labyrinth - Water Cycle $1BA6
Labyrinth - Conveyor Cycle $1BC6
Labyrinth - Conveyor Cycle Underwater $1BD8
Marble $24E8
Star Light $2548
Star Light lights $1C52
Spring Yard $25A8
Spring Yard - Cycle 1 $1C76
Spring Yard - Cycle 2 $1C96
Scrap Brain Act 1 $2608
Scrap Brain Act 2/Final $2668
Scrap Brain Act 3 $2748
Scrap Brain Act 3 - Sonic Underwater $2848
Scrap Brain Act 3 - Sonic Underwater (Alt) $27A8
Scrap Brain Act 3 - Underwater $27C8
Scrap Brain Act 1/Act 2 - Cycle 1 $1D0A
Scrap Brain Act 1/Act 2 - Cycle 2 $1D1A
Scrap Brain Act 1/Act 2 - Cycle 3 $1D2A
Scrap Brain Act 1/Act 2 - Cycle 4 $1D3A
Scrap Brain Act 1/Act 2 - Cycle 5 $1D46
Scrap Brain Act 1/Act 2 - Cycle 6 $1D56
Scrap Brain Act 1/Act 2 - Cycle 7 $1D66
Scrap Brain Act 1/Act 2 - Cycle 8 $1D86
Scrap Brain Act 2 - Cycle 1 $1D90
Scrap Brain Act 2 - Cycle 2 $1DA0
Scrap Brain Act 3 - Water Cycle $1BEA
Special Stage - Sonic $26C8
Special Stage No. 1 $26E8
Special Stage No. 2 $2708
Special Stage No. 3 $2728
Special Stage Title Card $2868
Special Stage Cycle 1 $4ACA
Special Stage Cycle 2 $4B12
Special Stage Cycle 3 $4B92
Continue - Sonic $28E8
Continue $2908
Ending - Sonic $2928
Ending $2948

Object Editing

Object Pointer List

SS Note: Code offsets for each actual pointer were taken from the Nemesis guides; they do not all appear to be accurate, but I don't have enough skill to go back and correct them yet. Someone else may take this task up.

ID # Description Code Mappings Subparameters
01 Sonic $12BD8 ??
02 ???? $D5B2 ??
03 ???? $D5B2 ??
04 ???? $D5B2 ??
05 ???? $D5B2 ??
06 ???? $D5B2 ??
07 ???? $D5B2 ??
08 LZ water splash $142F0 ??
09 Sonic in Special Stage $1B984 ??
0A Drowning countdown numbers $13C98 $14152
0B LZ vertical pole $11206 $11326

$11331

  • $00 - Unbreakable
  • $01 - Breaks in 1 Seconds
  • $02 - Breaks in 2 Seconds
  • $03 - Breaks in 3 Seconds
  • $04 - Breaks in 4 Seconds
  • $05 - Breaks in 5 Seconds
  • $06 - Breaks in 6 Seconds
0C LZ doors that open and close $11346 ?? $02
0D End of level signpost $EB28 ??
0E Sonic on the title screen $A61C ??
0F "PRESS START BUTTON" and "TM" from title screen $A69C ??
10 Blank object $1C022
11 GHZ Bridge $7328 ??
  • $06 - 6 logs
  • $07 - 7 logs
  • $08 - 8 logs
  • $09 - 9 logs
  • $0A - 10 logs
  • $0B - 11 logs
  • $0C - 12 logs
  • $0D - 13 logs
  • $0E - 14 logs
  • $0F - 15 logs
12 Spinning light behind glass from SYZ $E90C ??
13/14? Fireball from MZ/SLZ $E296 $B37A
  • $17 - Goes left to right
  • $25 - Goes top to bottom
  • $30-31, 35, 40-42 - Goes up, then comes down
  • $36 - Goes right to left
15 GHZ and MZ swinging platforms
Spiked ball on a chain (SBZ)
SLZ swinging platforms
$E304 $7C4E
$10AA6
$7C6C
16 Spear from LZ $11F04 $11FA6
  • $00 - Horizontal spear
  • $02 - Vertical spear
17 Helix of spikes on a pole from GHZ $7CA2 $7E08 $10
18 GHZ platforms
SLZ platforms
SYZ platforms
$7E32 $8140
$819C
$818A
$80FE (unused)
  • $00 - Doesn't move (GHZ)
  • $01 - Falls (GHZ)
  • $02 - Moves up and down (GHZ)
  • $05 - Moves side to side (GHZ)
  • $07 - Rises when a switch is pressed (SYZ)
  • $0A - Large GHZ platform moving up and down
  • $0B - Moves up and down (SYZ)
19 Blank object $81A8
1A Collapsible cliff from GHZ $8210 $85A8
  • $00 - Style 1
  • $01 - Style 2
1B Water surface from LZ $110C6 $11178
1C Fireball launcher from SLZ
GHZ bridge stump
$87CA $8858
  • $00 - Fireball launcher
  • $03 - Bridge stump
1D ???? $885E $891E
1E Ballhog $8B4C $8E6E
1F Crabmeat $94F0 $975E
20 Big red explosion $8C1C ????
21 SCORE, TIME, RINGS $1C548 $1C5BC
22 Buzz bomber $97DE $9A42
23 Missile that Buzz Bomber throws $9932 $9B0E
24 Explosion $8CF2 $8EAE
25 Ring $9B26 $9FA2
26 Monitor $A118 $A5A2
  • $00 - Blank
  • $01 - Robotnik
  • $02 - 1-Up
  • $03 - Speed Up
  • $04 - Shield
  • $05 - Invincible
  • $06 - Super Ring
  • $07 - S Monitor
  • $08 - Goggles
27 Normal explosion $8D62 ????
28 Freed animals $8F22 $946C
$9484
$949C
29 Points upon destroying $9412 $94BC
2A One way barrier from SBZ $8934 $89FE
2B Chopper enemy $AB20 $ABCE
2C Jaws enemy $ABDA $AC78
2D Burrobot enemy $ACA4 $AE6A
2E Contents of monitor flying up from monitor being busted $A302 ????
2F Large platforms from MZ $AEB8 $B2DA
  • $01 - Large oscillating platform
  • $15 - Platform that sinks upon being walked on
  • $20-$29 - Smaller oscillating platform
    (Speed from 0 to 9, with 0 being fastest)
30 Large glassy blocks from MZ $B39E $B600
  • $01 - Oscillating block
  • $04 - Block moves down when switch 0 pressed
  • $14 - Moves down when switch 1 pressed
31 Metal stomping blocks on chains $B67C $BB64
  • $02, $12 - Large with spikes, short chain
  • $11 - Large with spikes, long chain
  • $23 - Small with metal head
  • $80-$85: Large with spikes, raises when switch 0-5 is pressed
32 Switch $BD2E $BEAC
  • $00-$0F: Switches 0-F
33 Moveable block in MZ and LZ $BED2 $C2EA
34 Title card $C306 ????
35 Fireball that sits on the floor (MZ)
(appears when you walk on sinking platforms)
$B1DC ????
36 Spikes $CE28 $CFF4
  • $00 - Three standard spikes
  • $01 - Three moving spikes
  • $10 - Three spikes facing left
  • $12 - Three moving spikes facing left
  • $20 - One spike
  • $30 - Three widely spaced spikes
  • $40 - Six widely spaced spikes
  • $50 - One spike facing left
  • $52 - One moving spike facing left
37 Rings flying out from being hit $9CB6 ????
38 Shield and invincibility stars $14158 $143C2
39 "Game over"/"Time over" sprite $C4B8 $CBAC
3A End of level results screen $C572 ????
3B GHZ purple rock $D050 $D110
3C Breakable walls in GHZ, SLZ $D11C $D2BC
  • $00 - Left edge
  • $01 - Main part of wall
  • $02 - Right edge
3D Robotnik in his primary ship $17700 $17D26
3E Egg prison $1AB22 $1AD82
3F Large explosion $8DF6 ????
40 Motobug $F61A $F7AE
41 Springs $DABE $DD26
  • $00 - Red vertical spring
  • $02 - Yellow vertical spring
  • $10 - Red spring facing left
  • $12 - Yellow spring facing left
42 Newtron enemy (GHZ) $DD68 $DF58
  • $00 - Flies along the ground
  • $01 - Fires missile, then disappears
43 Roller enemy (SYZ) $DFFA $E1AC
44 Wall barrier from GHZ $E1D4 $E256
  • $00 - Type 1 (shading at top)
  • $01 - Type 2 (regular pattern)
  • $02 - Type 3 (fully shaded)
45 Spiked metal block from beta version (MZ) $B99A $BC6C
46 Solid blocks and blocks that fall from the ceiling (MZ) $E7D0 $E906
  • $00 - Solid block
  • $01 - Wobbling block, doesn't fall
  • $02 - Wobbling block, falls
47 Pinball bumper (SYZ) $E9D0 $EB06
48 Swinging ball on a chain from GHZ boss $17AE4 $81B2
49 Waterfall sound effect $D0BE
4A Special stage entry from beta $14254 $1447C
4B Giant ring $9E06 $9FDA
4C Lava geyser / lava that falls from the ceiling trigger (MZ) $ED84 $F272
  • $01 - Falls from ceiling
  • Called by object $33 for use as geyser
4D Lava geyser / lava that falls from ceiling $EE70 ???? Triggered by object $4C
4E Advancing wall of lava (MZ) $F05E $F538
4F Blank object used for object $50
50 Yadrin enemy (SYZ) $F83A $F93A
51 Smashable green block (MZ) $FC92 $FDD8
52 Moving blocks (MZ, LZ, SBZ) $FDF8 $10054
$100A2
  • $01 - MZ block that moves back and forth
  • $02 - MZ block that moves right when stood on
  • $07 - LZ platform that appears when switch 2 is pressed
  • $28 - SBZ platform that moves up and down
  • $39 - SBZ platform that slides away
  • $41 - MZ platform that moves side to side
53 Collapsing floors (MZ, SLZ, SBZ) $8320 $874E
  • $01 - MZ/SBZ collapsing blocks
  • $81 - SLZ collapsing blocks
54 Invisible lava tag (MZ) $F1B8 $F212
55 Basaran enemy (MZ) $100A8 $10246
56 Moving blocks (SYZ/SLZ/LZ) $10286 $10710
  • $00 - SYZ Block
  • $01, 02 - SYZ Block that moves side to side
  • $13 - SYZ Block that moves up and down
  • $58-5B - SLZ Block that moves in a circle,
    moving up in circumference
57 Spiked ball on a chain $10782 $10964 Subparameters are set so the first half of the nybble sets the speed (lower is faster) and the second half determines the amount of links on the chain, starting with 2 at the 3 value.
58 Spikeball $10976 ????
  • $01 - Moves side to side
  • $02 - Moves up and down
  • $C3 - Moves in a circle
59 Raising platforms (SLZ) $10AD2 $10D4A
  • $00 - Rises when stood on
  • $01 - Rises higher when stood on
  • $03 - Falls when stood on
  • $0C - Rises diagonally when stood on
  • $8A - Series of platforms that rise and vanish
5A Platforms that move in circles (SLZ) $10D5A $10E84
  • $00-03 - First through fourth platforms moving clockwise
  • $04-07 - First through fourth platforms moving counterclockwise
5B Blocks that form a staircase (SLZ) $10E90 $1103E
  • $00 - Regular staircase
  • $02 - Staircase you need to knock down
5C Metal girders in foreground (SLZ) $11044 $11098
5D Fans (SLZ) $114FC $1161A $00-$02
5E Seesaws (SLZ) $1163C $119AC
$119EA
5F Walking bomb enemy (SLZ, SBZ) $119F6 $11C40
60 Orbinaut enemy (LZ, SLZ, SBZ) $11CCE $11EEC
  • $00 - Attacking type
  • $02 - Nonattacking type
61 Blocks (LZ) $11FD4 $121CA
  • $01 - Block that falls when stood on
  • $05 - Pushable block
  • $13 - Platform that rises
  • $30 - Block
62 Gargoyle head (LZ) $121E8 $12320 $01-$04
63 Platforms on a conveyor belt (LZ) $1233C $12686
  • $7F - Conveyor belt wheels
  • $80-85 - Tag for small platforms
64 Bubbles (LZ) $126A4 $129FA $80-82
65 Waterfalls (LZ) $12A9E $12B6C
  • $00, $07 - Vertical water
  • $02-$04, $06 - Waterfall corner
  • $08 - Diagonal water
  • $09 - Waterfall splash
  • $49 - Waterfall splash that moves up and down with water
66 Rotating disc that grabs Sonic (SBZ) $1509A $152B4
  • $00-$03 - Changes direction when switches 0 through 3 are pressed
67 Disc that you run around (SBZ)
(Small object; actual disc is in level tiles)
$154E2 $15688 $40
68 Conveyor belts (SBZ)
(Small object; actual belt is in level tiles)
???? ????
  • $20 - Belt going left
  • $E0 - Belt going right
69 Spinning platforms and trapdoors (SBZ) $15730 $158E6
$15944
  • $01, $02 - Trapdoor
  • $80-$83 - Spinning platform
  • $90-$9F - Spinning platform
6A Ground and ceiling saws (SBZ) $1597C $15BA0
  • $01 - Ceiling saw, moves sideways
  • $02 - Ceiling saw, moves up and down
  • $03 - Ground saw
6B Stomper and platforms (SBZ) $15C12 $15F72
  • $13, 24, 34 - Stomper
  • $80-88 - Doors opened by switches 0-8
6C Vanishing platforms (SBZ) $15FF8 $16132 $00, $40, $80, $C0, $C6, $E6
6D Flame thrower (SBZ) $E4E0 $E620 $43
6E Electrocution orbs (SBZ) $16146 $161EC
  • $02, $04, $06, $08 - Various speeds, lower is faster
6F Spinning platforms that move around a conveyor belt (SBZ) $1626A ???? $80-$85
70 Large girder block (SBZ) $1652A $1662A
71 Invisible solid blocks $1141A $114BC Various
72 Teleporter (SBZ) $16668 ???? $00-$08
73 Eggman (MZ) $18230 ????
74 Lava that Eggman drops (MZ) $186A4 ????
75 Eggman (SYZ) $190EE ????
76 Blocks that Eggman picks up (SYZ) $19692 $19808
77 Eggman (LZ) $17E36 ????
78 Caterkiller enemy (MZ, SBZ) $16934 $16D9E
79 Lamppost $16E2E $17100 $00-$09 - Posts 0 through 9
7A Eggman (SLZ) $188B8 ????
7B Exploding spikeys that the SLZ boss drops $18CCE $190E2
7C Special stage entry effect $9ED6 $A084
7D Hidden points at the end of a level $1715E $17250
  • $01 - 1,000 points
  • $02 - 100 points
  • $03 - 10 points
7E Special stage results screen $C7AE ????
7F Chaos Emeralds from the special stage results screen $C956 $CE02
80 Continue screen $4E42 $5066
81 Sonic on the continue screen $4F5C ????
82 Eggman (SBZ2) $19832 ????
83 Blocks that disintegrate when Eggman presses a switch $19B60 $19D1C
84 Cylinders Eggman hides in (FZ) $1A44E $1A68E
85 Eggman (FZ) $19D58 $1A3DE
86 Energy balls/launcher (FZ) $1A7DA $1AA5E
$1AABC
87 Sonic on the ending sequence $53E2 $5690
88 Chaos Emeralds on the ending sequence $553C $5788
89 "SONIC THE HEDGEHOG" text on the ending sequence $5616 $57B4
8A "SONIC TEAM PRESENTS" and credits $17264 $172F8
8B Robotnik on the "TRY AGAIN" and "END" screens $59E2 $5BCC
8C Chaos Emeralds on the "TRY AGAIN" screen $5AC2 ????

Mappings Editing

Object Placement

RAM Hacking

Main System Memory Locations

This is a map of 68k memory as used by the main gameplay engine. Note that any numbers entered (for example, score or number of rings) will have to be converted to hex first.

These are the offsets in RAM. To convert them to Genecyst savestate offsets, add $2478.

RAM offset Description
$0000 - $7FFF Metablock table
$F600 Screen Mode
  • $00 - Sega Screen
  • $04 - Title Screen
  • $08 - Demo Mode
  • $0C - Normal Level
  • $10 - Special Stage
  • $14 - Continue Screen
  • $18 - Ending Sequence
  • $1C - Credits
$F616-$F617 Camera Y Position for previous frame
$F618-$F619 Value of $F70C for previous frame
$F61A-$F61B Camera X Position for previous frame
$F61C-$F61D Value of $F708 for previous frame
$F61E-$F61F Value of $F71C for previous frame
$F620-$F621 Value of $F718 for previous frame
$F680 Address queue for Pattern Load Cues
$F700-$F701 Camera X Position
$F704-$F705 Camera Y Position
$F744 Scroll Hold Flag (set to stop all scrolling dead)
$F754-$F755
$F756-$F757
$F758-$F759
$F75A-$F75B
Bitfields used by the scrolling engine
$F760-$F761 Sonic's Top Speed
$F762-$F763 Sonic's Acceleration
$F764-$F765 Sonic's Deceleration
$F7AA Screen Lock Flag (Set to lock screen)
$F7C8 Control Lock Flag (Set to lock controls)
$FA00-$FA80 Underwater Palette Storage
$FE02 Restart Level Flag (Set to restart level)
$FE04 Level Timer
$FE10-$FE11 Zone/Act
$FE12-$FE13 Rings
$FE14 Remaining Air (When underwater)
$FE16 Last Special Stage Entered
$FE18 Continues
$FE1C Lives Counter (Set to update lives total on screen)
$FE1D Ring Counter (Set to update rings total on screen)
$FE1E Time Counter (Set to update current time on screen)
$FE1F Score Counter (Set to update score total on screen)
$FE26-$FE29 Score
$FE2C Shield Flag (Set to take a single hit without losing rings)
$FE2D Invincibility Flag (Set to make Sonic invincible)
$FE2E Speed Shoes Flag (Set to activate speed shoe physics)
$FE30 Lamppost Counter
$FE57 Emeralds
$FFF4 Credits Index Number

Sprite Status Table

The Sprite Status Table is located at RAM address $D000. Each entry is $40 bytes long. Here is a list of all the values for one entry in the SST:

Offset Size Description
$00 byte Object type
$01 byte Action flags. The bitfield looks like this:
  • Bit 0 is the horizontal mirror flag. If set, the object will be flipped on its horizontal axis.
  • Bit 1 is the vertical mirror flag.
  • Bit 2 is the coordinate system flag. If clear, the object will be positioned by absolute screen coordinates. This is used for things like the HUD and menu options. If set, the object will be positioned by the playfield coordinates, i.e. where it is in a level. Sonic uses the playfield positioning system.
  • Bits 3, 4, and 5 are either unused, or their purpose is unknown.
  • Bit 6 is Sonic's "Ride B" flag
  • Bit 7 is the draw object flag. It will be set if the object was onscreen when it came time to draw things. Otherwise, it is clear. There should be no reason to edit this flag, but it's good to know what it does.
$02 word Starting art block.
  • First nybble: Palette line the sprite will use.
  • Latter 3 nybbles: Starting art block in VRAM for which the object reads from. Multiply by $20 to get VRAM address; divide VRAM address by $20 to get this value.
$04 long Mappings offset
$08 word
  • If in playfield positioning mode, it is the X playfield coordinate.
  • If in screen positioning mode, it is the X screen coordinate.
$0A word
  • If the object is in playfield positioning mode, this is the X subpixel coordinate.
  • If in screen positioning mode, it's the Y screen coordinate.
$0C word
  • If in playfield positioning mode, it is the Y playfield coordinate.
  • If in screen positioning mode, it is unused.
$0E word
  • If the object is in playfield positioning mode, this is the Y subpixel coordinate.
  • If in screen positioning mode, it is unused.
$10 word Horizontal (X) velocity
$12 word Vertical (Y) velocity
$14 byte 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:

Bit Hex Description
0 $01 X Orientation. Clear is left and set is right.
1 $02 Y Orientation. Clear is right-side up, and set is upside-down
2 $04 Unknown or unused.
3 $08 Set if Sonic is standing on this object.
4 $10 Unknown or unused.
5 $20 Set if Sonic is pushing on this object.
6 $40 Unknown or unused.
7 $80 Unknown or unused.
Note that these bits have different meanings for Sonic (see below).
$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
Object-specific variables
Offset Size Description
$22 byte Sonic: Special bitfield. Counting from the least significant bit:
Bit Hex Description
0 $01 Orientation. Clear is left and set is right.
1 $02 Set if Sonic is in the air (jump counts).
2 $04 Set if jumping or rolling.
3 $08 Set if Sonic isn't on the ground but shouldn't fall. (Usually when he is on a object that should stop him falling, like a platform or a bridge.)
4 $10 Set if jumping after rolling.
5 $20 Set if pushing something.
6 $40 Set if underwater.
7 $80 Unused.

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 Sonic: 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 Sonic: Unused
$30-$31 word Sonic: Remaining invulnerability time. Starts at $0078 after Sonic is hit, and seems to decrement every frame until it reaches $0000.
$32-$33 word Sonic: Remaining time of invincibility.
$34-$35 word Sonic: Remaining time of Speed Shoes.
$36 byte Sonic: Angle of ground at Sonic's front collision hot spot ($03 is "edge of ground")
$37 byte Sonic: Angle of ground at Sonic's rear collision hot spot
$39 byte Sonic: Unused.
$3A-$3B word Sonic: Unused.
$3C byte Sonic: Set if jumping.
$3D byte Sonic: SST 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
Sonic Community Hacking Guide
General
SonED2 Manual | Subroutine Equivalency List
Game-Specific
Sonic the Hedgehog (16-bit) | Sonic the Hedgehog (8-bit) | Sonic CD (prototype 510) | Sonic CD | Sonic CD (PC) | Sonic CD (2011) | Sonic 2 (Simon Wai prototype) | Sonic 2 (16-bit) | Sonic 2 (Master System) | Sonic 3 | Sonic 3 & Knuckles | Chaotix | Sonic Jam | Sonic Jam 6 | Sonic Adventure | Sonic Adventure DX: Director's Cut | Sonic Adventure DX: PC | Sonic Adventure (2010) | Sonic Adventure 2 | Sonic Adventure 2: Battle | Sonic Adventure 2 (PC) | Sonic Heroes | Sonic Riders | Sonic the Hedgehog (2006) | Sonic & Sega All-Stars Racing | Sonic Unleashed (Xbox 360/PS3) | Sonic Colours | Sonic Generations | Sonic Forces
Technical information
Sonic Eraser | Sonic 2 (Nick Arcade prototype) | Sonic CD (prototype; 1992-12-04) | Dr. Robotnik's Mean Bean Machine | Sonic Triple Trouble | Tails Adventures | Sonic Crackers | Sonic 3D: Flickies' Island | Sonic & Knuckles Collection | Sonic R | Sonic Shuffle | Sonic Advance | Sonic Advance 3 | Sonic Battle | Shadow the Hedgehog | Sonic Rush | Sonic Classic Collection | Sonic Free Riders | Sonic Lost World
Legacy Guides
The Nemesis Hacking Guides The Esrael Hacking Guides
ROM: Sonic 1 | Sonic 2 | Sonic 2 Beta | Sonic 3

Savestate: Sonic 1 | Sonic 2 Beta/Final | Sonic 3

Sonic 1 (English / Portuguese) | Sonic 2 Beta (English / Portuguese) | Sonic 2 and Knuckles (English / Portuguese)
Move to Sega Retro
Number Systems (or scrap) | Assembly Hacking Guide | 68000 Instruction Set | 68000 ASM-to-Hex Code Reference | SMPS Music Hacking Guide | Mega Drive technical information