Actions

SCHG

SCHG:Sonic the Hedgehog 3 & Knuckles

From Sonic Retro

Revision as of 13:53, 25 May 2008 by Shobiz (talk | contribs) (Dammit, missed one)

This is the Sonic Community Hacking Guide for Sonic 3 & Knuckles. As S3&K is a "lock-on" game, all offsets below $200000 are in the base S&K ROM, and all offsets above $200000 are in the connected S3 ROM.

ROM Hacking

Art Editing

Uncompressed Art Locations

Nemesis Compressed Art Locations

Kosinski Compressed Art Locations

Palette Editing

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 3 and Knuckles:

Offset Name
2AF6 Angel Island Act 1 Cycle #1
2B16 Angel Island Act 1 Cycle #2
2B96 Angel Island Act 1 Cycle #3
2BF6 Angel Island Act 1 Cycle #4
2C26 Angel Island Act 2 Cycle #1
2C46 Angel Island Act 2 Cycle #2
2C76 Angel Island Act 2 Cycle #3
2CA6 Angel Island Act 2 Cycle #4
2CDA Angel Island Act 2 Cycle #5
2D0E Hydrocity Act 1 Cycle
2D2E Carnival Night Cycle #1
2D8E Carnival Night Cycle #2
2E42 Carnival Night Cycle #3
2E82 Carnival Night Cycle #4
2EE2 Carnival Night Cycle #5
2FD6 Icecap Cycle #1
3016 Icecap Cycle #2
305E Icecap Cycle #3
3076 Icecap Cycle #4
30B6 Launch Base Act 1 Cycle
30C8 Launch Base Act 2 Cycle
30DA Sandopolis Zone Act 1 Cycle
317A Sandopolis Zone Act 2 Cycle
327E Lava Reef Zone Cycle #1
32FE Lava Reef Zone Cycle #2
3322 Lava Reef Zone Act 1 Cycle #3
3344 Lava Reef Zone Act 2 Cycle #3
3444 Death Egg Zone Cycle #1
3474 Death Egg Zone Cycle #2
349C Death Egg Zone Act 1 Cycle #3
34CC 2P Level - Balloon Park Cycle #1
34DE 2P Level - Balloon Park Cycle #2
355C 2P Level - Chrome Gadget Zone
35AC 2P Level - Endless Mine Cycle #1
35E8 2P Level - Endless Mine Cycle #2
398E Super Sonic
39CA Super Sonic Underwater (AIZ and ICZ)
3A06 Super Sonic Underwater (all other levels)
3A42 Hyper Sonic
3A8A Super Tails
3AAE Super Knuckles
3AEA Super Knuckles (reverting back to normal palette)
459C Sonic 3k title screen
460C Sonic 3k title Frame #1
462C Sonic 3k title Frame #2
464C Sonic 3k title Frame #3
466C Sonic 3k title Frame #4
468C Sonic 3k title Frame #5
46AC Sonic 3k title Frame #6
46CC Sonic 3k title Frame #7
46EC Sonic 3k title Frame #8
470C Sonic 3k title Frame #9
472C Sonic 3k title Frame #10
474C Sonic 3k title Frame #11
476C Sonic 3k title Frame #12
47AC Sonic 3k title Frame #13
4904 Shimmering water rotating palette (Sonic 3k title screen)
5588 S&K title screen palette (all four lines)
55A8 S&K SEGA screen palette (three lines starting at line 2)
5608 S&K title screen line 2 palette
6C0C 2P level line 2 palette (same for all levels)
7A4A Knuckles' underwater colours. Three colours per level for all levels till LBZ, which go in underwater palette slots 2, 3 and 4
896E Special Stage - Sonic and Tails (all four lines)
89EE Special Stages - Knuckles (last 8 colours of line 1)
89FE Special Stage 1 (Sonic 3)
8A24 Special Stage 2 (Sonic 3)
8A4A Special Stage 3 (Sonic 3)
8A70 Special Stage 4 (Sonic 3)
8A96 Special Stage 5 (Sonic 3)
8ABC Special Stage 6 (Sonic 3)
8AE2 Special Stage 7 (Sonic 3)
8B08 Special Stage 8 (Sonic 3)
8B2E Special Stage 1 (Sonic & Knuckles)
8B54 Special Stage 2 (Sonic & Knuckles)
8B7A Special Stage 3 (Sonic & Knuckles)
8BA0 Special Stage 4 (Sonic & Knuckles)
8BC6 Special Stage 5 (Sonic & Knuckles)
8BEC Special Stage 6 (Sonic & Knuckles)
8C12 Special Stage 7 (Sonic & Knuckles)
8C38 Special Stage 8 (Sonic & Knuckles)
9D1E Special stage emeralds palette. 4 colours per emerald for 8 emeralds
CA78 Data Select main palette
CA9A Data Select - Emeralds rotating palette
CAB8 Data Select - Sonic Portrait
CAD8 Data Select - Super Sonic Portrait
CAF8 Data Select - Sonic, Tails and Knuckles portrait
CB18 Data Select - AIZ Portrait
CB38 Data Select - HCZ Portrait
CB58 Data Select - MGZ Portrait
CB78 Data Select - CNZ Portrait
CB98 Data Select - ICZ Portrait
CBB8 Data Select - LBZ Portrait
CBD8 Data Select - MHZ Portrait
CBF8 Data Select - FBZ Portrait
CC18 Data Select - SZ Portrait
CC38 Data Select - LRZ Portrait
CC58 Data Select - HPZ Portrait
CC78 Data Select - SSZ Portrait
CC98 Data Select - DEZ Portrait
CCB8 Data Select - DDZ Portrait
CCD8 Data Select - Knuckles Portrait
CCF8 Data Select - Super Knuckles Portrait
CD18 Data Select - Tails Portrait
CD38 Data Select - Alternate Tails Portrait (when he finishes with all 7 chaos emeralds)
2E318 Special Stage Results
4CB36 Blue Spheres title screen when Sonic 1 is locked on
4CBB6 Blue Spheres title screen when any other game is locked on
4DE08 Blue Spheres result screen text palette
4DE68 Blue Spheres result screen background palette
A8A3C Sonic and Tails
A8A7C Level select
A8AFC Knuckles
A8B1C Angel Island Act 1 Intro - Emeralds
A8B7C Angel Island Zone
A8BDC Angel Island Act 1 fire
A8C3C Angel Island Act 1 Boss
A8C9C Angel Island Act 1 Underwater
A8D1C Angel Island Act 2 Underwater
A8D9C Hydrocity Act 1
A8DFC Hydrocity Act 2
A8E5C Hydrocity Act 1 Underwater
A8EDC Hydrocity Act 2 Underwater
A8F5C Marble Garden Zone
A8FBC Carnival Night Zone
A901C Carnival Night Act 2 Underwater
A909C Flying Battery Act 1
A90FC Flying Battery Act 2
A915C Icecap Act 1
A91BC Icecap Act 2
A921C Icecap Act 2 Underwater
A929C Launch Base Act 1
A92FC Launch Base Act 2
A935C Launch Base Act 2 Underwater
A93DC Launch Base Death Egg
A943C Mushroom Hill Act 1
A949C Mushroom Hill Act 2
A94FC Sandopolis Act 1
A955C Sandopolis Act 2
A95BC Sandopolis Act 2 medium-dark palette
A961C Sandopolis Act 2 fully dark palette
A967C Lava Reef Act 1
A96DC Lava Reef Act 2
A973C Sky Sanctuary Act 1
A979C Sky Sanctuary Act 2
A98BC Death Egg Act 1
A991C Death Egg Act 2
A997C The Doomsday
A99DC Azure Lake Zone
A9A3C Balloon Park Zone
A9A9C Desert Palace Zone
A9AFC Chrome Gadget Zone
A9B5C Endless Mine Zone
A9BBC Gumball bonus
A9C1C Magnetic orbs bonus
A9C7C Slot machine bonus
A9CDC Lava Reef Act 2 Boss
A9D3C Hidden Palace
A9D5C Hidden Palace special stage portal
A9D9C Death Egg Act 2 Boss
209818 2P Menu palette (first 3 lines)
20A55E 2P Menu - Sonic and Tails
20A57E 2P Menu - Knuckles
20A59E 2P Menu - Unselected Portraits
20A5BE 2P Menu - ALZ Portrait
20A5DE 2P Menu - BPZ Portrait
20A5FE 2P Menu - CGZ Portrait
20A61E 2P Menu - DPZ Portrait
20A63E 2P Menu - EMZ Portrait
39D262 Data Select - Background
39D282 2P mode common colours (line 4 in main menu, line 1 in level select, player select, results screen and time attack records screen)

For information about the palette format, see Megadrive palette.

Pattern Load Requests

PLRs tell the game engine where to get Nemesis-compressed art data and where to put it. The format is rather simple: each PLR starts off with a one-word header, which is the number of entries to load - 1. The actual entries follow this header - each entry is one longword, which is the location in ROM of the compressed art, followed by one word, which is the location in VRAM to decompress to.

The RAM queue is $60 bytes long, meaning it has space for 16 PLRs. However, a coding error in the clearing routine means that storing a PLR in the last slot screws everything up, so effectively only 15 requests can be stored at one time. Note that the routines that load PLRs into the queue do not do any bounds checking, and it is quite easy to create a buffer overrun condition. Further, both lists seem to be moved into the queue at the same time, so even if neither one is longer than 15 requests, they can still overrun the queue and destroy the variables that are stored just beyond it. Make sure that the primary and secondary PLR lists are no more than 15 requests long.

Object Editing

Object Pointer List

Sonic 3 & Knuckles, being a combination of two games, also contains two object pointer lists. The first one is located at $94EA2, and caters to all 1-player Sonic 3 levels as well as Flying Battery Zone, all 2-player zones and all bonus stages. The second one is located at $952A2, and caters to all Sonic & Knuckles levels except Flying Battery Zone and the bonus stages. There are also many objects which are not referenced by either list, since Sonic 3 & Knuckles' method of handling objects means that objects do not necessarily need to be stored in a pointer list to be used by the game. In fact, the only objects stored in the pointer list are those which are part of a level's object placement.

The ID number is in hex, and denotes the object's position in the list (starting from 0). Code is the value of the actual pointer. Note that this is only the starting code pointer, and may change during an object's lifespan. Mappings tells where to find the object's sprite mappings, and Subparameters tells what arguments, if any, the object can take when it's placed on the playfield.

FIXME: More subparameters!
Object pointer list #1
ID # Description Code Mappings Subparameters
00 Ring $1A51A $1A99A
01 Monitor $1D566 $1DBA2
  • $00 - Static (harms character)
  • $01 - 1-up
  • $02 - Robotnik
  • $03 - Super Ring
  • $04 - Speed Shoes
  • $05 - Fire shield
  • $06 - Lightning shield
  • $07 - Bubble shield
  • $08 - Invincibility
  • $09 - S monitor
  • $0A - Broken
02 Collision plane switcher $1CCAE $1D05A
03 Large tree from AIZ 1 (the one right leading up to the miniboss cutscene) $1F746 None (part of level art)
04 Crumbling platforms from AIZ and ICZ $204FE
  • $21E6C8 (AIZ 1)
  • $21E7AC (AIZ 2)
  • $21F2F2 (ICZ)
05 Rock from AIZ, LRZ and EMZ $1F9E0
  • $21DCDC (AIZ 1)
  • $21DD64 (AIZ 2)
  • $203D8 (LRZ 1)
  • $2047A (LRZ 2)
  • $21DDEC (EMZ)
06 Vine which slides down a rope from AIZ 1 $21C6E $22B9E
07 Spring $22D06
  • $2375C (red spring)
  • $23904 (red spring in 2P mode)
  • $23772 (yellow spring)
  • $23912 (yellow spring in 2P mode)
The upper nybble determines the orientation:
  • $0 - facing up
  • $1 - facing to the side
  • $2 - facing down
  • $3 - facing diagonally up and to the right
  • $4 - facing diagonally down and to the right

The lower nybble determines the colour:

  • $0 - red
  • $2 - yellow
08 Spikes $23F84 $24456 The upper nybble determines size and orientation. Size varies from $0 (smallest) to $3 (largest), and if bit 2 of this nybble (bit 6 of the entire byte) is set, the spike is vertical. The lower nybble determines the spike type. 0 means static, 1 means it moves up and down, 2 means it moves sideways, and 3 means it's pushable
09 Tree bark from AIZ 1. Used only by the tree at coordinates $2F78 and $318. The only purpose this serves is that the bombers passing through the sky are masked by it instead of appearing over the tree $1E78A $21C3E8
0A Rope peg from AIZ 1, at the end of the pulley which you ride down $1E7B6 $21C42A
0B Ring (unused slot) $1A51A $1A99A
0C Swinging wine from AIZ $2237E $22B9E
0D Breakable wall $2131C
  • $21FD52 (AIZ)
  • $21FFD8 (HCZ)
  • $21FF18 (MGZ)
  • $21ABA (CNZ, SOZ)
  • $22005E (LBZ)
  • $21BCE (MHZ)
  • $21C1E (LRZ)
0E Ridge from AIZ which launches player up and forces twirl $24D68 None (part of the level art)
0F Collapsing platform/bridge/ledge $20630
  • $21EA1A (HCZ)
  • $21EE68 (MGZ)
  • $21F2F2 (ICZ)
  • $21E896 (LBZ collapsing bridge)
  • $21E992 (LBZ collapsing ledge)
  • $2108E (FBZ)
  • $2127A (SOZ)
  • $20F0E (LRZ)
  • $20FCE (HPZ)
10 Tube transporters from LBZ $29C9E $2291A4
11 Floating platform from LBZ $24E3C $25338

Determines platform type:

  • 0 - stationary
  • 1 - moves left and right
  • 2 - moves left and right over a larger range
  • 3 - moves up and down
  • 4 - moves up and down over a larger range
  • 5 - moves diagonally up and to the right
  • 6 - moves diagonally down and to the right
  • 7 - doesn't sink slightly when player stands on it
  • 8-B - move around clockwise in the shape of a rectangle. The size of the rectangle increases from 8 to B
  • C - moves left and right over a very large range
  • D - falls when player stands on it
  • E - unknown
12 Platform in LBZ which moves up when a flag is set and then returns to its original position when the flag is cleared (unused) $25AF6 $2248EA The upper nybble can be set anywhere from 0-5, and specifies the Y range the platform travels between. The lower nybble is an index number into the level trigger flags data, used to choose the correct flag to check for motion
13 Exploding trigger from LBZ which causes bridges to change positions $25CBE $2249A8 Serves as an index number into the level trigger flags data. Used to associate the trigger with the actual bridge
14 Bridge from LBZ which changes position when its corresponding trigger explodes $25F6A $224DE6 The upper nybble determines starting position and ending position:
  • 0 - starts vertical, falls down horizontally leftwards
  • 1 - starts horizontal, becomes upright vertically to the right
  • 2 - starts vertical, falls down horizontally rightwards
  • 3 - starts vertical, falls down horizontally rightwards

The lower nybble serves as an index number into the level trigger flags data. Used to associate the bridge with its trigger

15 Launcher from LBZ which thrusts the player forward at a high speed $26130 $22534C If this is 0, the launcher gives the player an initial X speed of $1000. If it's 2 (which incidentally none of the boosters in-game are), the speed given is $A00
16 Flame thrower from LBZ $263D2 $22544E
17 Hooked ride from LBZ $264C0 $26930
18 Cup elevator from LBZ $2694E $22619A
19 Pole attached to cup elevator from LBZ $27096 $22619A
1A Unknown object which can be rotated using controller 2. Art seems to have been deleted, so purpose is hard to gauge (unused) $27106 $2264E0
1B Smashable mini-pillar from LBZ $273E4 $226854
1C Ring (unused slot) $1A51A $1A99A
1D Platform from LBZ which you can hang on to at the bottom (unused) $25368 $254EA
1E Launcher from LBZ 2 which thrusts player upward and forces a spin $28DB8 $227BC2
1F Hook from LBZ which transports player up $29020 $227DBC
20 Smashing pillar from MGZ, smashing spikes from LBZ $29216 $228236 (LBZ) / $228246 (MGZ)
21 Laser-shooting gate from LBZ $29338 $228394
22 Siren from LBZ 1 $29446 None (part of level art)
23 Invisible object which forces a falling animation when the player comes in contact with it (unused) $29518 None (not displayed) Vertical radius of the object, divided by 8
24 Looping pipes from LBZ which eject the player out at high speed $295D0 None (part of level art)
25 Ring (unused slot) $1A51A $1A99A
26 Alternate collision plane switcher. Not sure how this differs from the normal one, but it always seems to be placed at tunnel entrances/exits $1E7E2 $1D05A
27 Leftover lava collision marker (object $31) from Sonic 2 (unused) $1EB36 $1EBBC (when not in debug)/$1EBC4 (when in debug) Can be set from 0 to 2, and determines the width of the rectangle
28 Invisible barrier (the GTGT blocks in debug mode) $1EC18 $1ECC6
29 Disappearing platform from AIZ $2A252 $2294B4
2A Breakable floor piece from various levels $2A3D0
  • $229B60 (AIZ 1)
  • $229BD4 (AIZ 2)
  • $229C48 (CNZ)
  • $229CE0 (ICZ)
  • $229EE8 (LBZ)
  • $2A920 (FBZ)
2B Flipping stairway from AIZ $2A94C $22A310
2C Collapsing log bridge from AIZ $2ACDC $2B070
2D Falling logs from AIZ $2B586 $22AE30 (Act 1)/$22AE20 (Act 2)
2E Spiked rotating log from AIZ 2 $2B758 $22B0F0
2F Various non-animated still sprites from levels. Includes stuff like bridge posts from AIZ, waterfalls from HCZ, mini-towers from LBZ, etc $2B928 $2BA9A The mapping frame to display
30 Small pieces of fire from AIZ 2 $2BF20 $2BFDA The animation number to use
31 Rotating cylinders from LBZ $2C3AE None (part of the level art)
32 Drawbridge from AIZ 2 (the one which Knuckles destroys after the boss fight) $2B12A $2B558
33 Button $2C518
  • $2C71E (AIZ/FBZ)
  • $22BD1A (HCZ)
  • $22BD4A (CNZ)
  • $2C748 (LRZ)
  • $22BD7A (2P mode)
34 Starpole $2CFA8 $2D348 The designation number of the star pole, from $00-$09. Used to determine order - if you hit pole $04 before you've hit $03, the game will behave as if you did hit $03, even if you never actually go near it
35 Plants in foreground in AIZ 1 $2C1F0 $22B8EC
36 Breakable bar from HCZ $1ED26 $21CDCA
37 The vertical water stream from HCZ 1 which moves forward when you break the first barrier $2FDA4 $22E60C
38 Propelling fans from HCZ and CGZ $30580 $22F3AA (HCZ)/$22F620 (CGZ)
39 Large fan from HCZ which propels player forward $308FA $22F418
3A Hand launcher from HCZ $30AD0 $22F998
3B Wall in HCZ 1 from which a stream of water gushes out, breaking bricks along the way $2FEF6 $22EE10
3C Door (used in HCZ, CNZ and DEZ) $30E24 $30F86
3D Spring from FBZ 2 which moves up and down. Only used once in entire game $239E4
  • $2375C (red spring)
  • $23772 (yellow spring)
3E Conveyor belt from HCZ $31164 None (part of level art)
3F Spike on HCZ conveyor belt $31502 $23035E
40 Single block from HCZ. Usually pieced together to form horizontal groups $1F392 $21D04A
41 Balloon from CNZ $31704 $230502
42 Cannon from CNZ $318A4 $230A32
43 Platform from CNZ which falls when you stand on it and rises when you jump $31B9E $230CDC
44 Trapdoor in CNZ from which player is ejected after entering a corkscrew $31C9E $230DCC
45 Lightbulb in bell-jar from CNZ 2 (near the button which turns the lights off) $31D3A $230E52
46 Fans which make the player hover from CNZ $31D90 $231010
47 Rotating barrels from CNZ $320F2 $2317B0
48 Vacuum tubes from CNZ $31F30 None (part of level art)
49 Rotating wheel from CNZ $328C4 None (part of level art)
4A Bumper $32DF2
  • $2322CE (CNZ)
  • $2322EE (BPZ)
  • $330A2 (Magnetic orbs bonus)
4B Triangular springs from CNZ which knock the player forward $32990 None (part of level art)
4C Corkscrew from CNZ $330C8 None (part of level art)
4D Pole from CNZ on which you go round and round diagonally upwards or downwards $33360 None (part of level art)
4E Rotating vertical mesh from CNZ $33836 None (part of level art)
4F Mud from MGZ and ALZ and quicksand from DPZ $32A78 None (part of level art)
50 Pole from MGZ, at the base of some loops, on which you go round and round $33C74 None (part of level art)
51 Floating platform $25506
  • $256A2 (AIZ)
  • $25688 (HCZ)
  • $25654 (MGZ)

The upper nybble determines size - 0 is for MGZ, 1 is for HCZ and 2 is for AIZ. The lower nybble determines platform type:

  • 0 - stationary
  • 1 - moves left and right
  • 2 - moves left and right over a larger range
  • 3 - moves up and down
  • 4 - moves up and down over a larger range
  • 5 - moves diagonally up and to the right
  • 6 - moves diagonally down and to the right
  • 7 - moves up as far as possible when player stands on it
  • 8-B - move around clockwise in the shape of a rectangle. The size of the rectangle increases from 8 to B
  • C - moves left and right over a very large range
52 Smashing pillar from MGZ, smashing spikes from LBZ (repeated entry) $29216 $228236 (LBZ) / $228246 (MGZ)
53 Platforms from MGZ which rotate around a centre $33F84 $233318
54 Air-bubble emitting object $2F938 $2FCB2
55 Arrow-shooting head from MGZ which you have to hit thrice $34302 $233812
56 Moving rotating platform from MGZ with spikes on the sides $346E2 $233B98
57 Platform in MGZ triggered by the rotating blue wheel $34574 $2339B2
58 Swinging spiked ball from MGZ $340CC $233572 If it's 0, the ball swings horizontally. If it's 1, the ball swings vertically
59 Blue rotating wheel from MGZ which is triggered by a spindash $25D54 $224B88
5A Pulley from MGZ $34800 $2340C0
5B Blue spinning top platform from MGZ $34BF8 $35964
5C Launcher for the blue spinning top from MGZ $3598E $35964
5D Triangular springs from CGZ $32C6A None (part of level art)
5E Platform from CGZ with blades at the bottom $35A7A $35BBC
5F Retracting spring from 2P mode $23B38 $23F4A (normal)/$23F52 (EMZ only)
60 Elepant block from BPZ $35BF8 $35D5A
61 Balloon from BPZ $35D80 $35E9A
62 Dissolving sand bar from DPZ $35F3A $3609A (shorter)/$360D6 (longer) 0 for the shorter one, 1 for the longer one
63 Button from DPZ $362A2 $36350
64 Bubble containing item in 2P mode $36364 $36AA6
65 Goal marker in 2P mode $36BE0 $36FFA
66 Dripper from EMZ $380F8 $38252
67 Silver blocks from HCZ 2 which move around and expand and collapse into each other $256BE $25688
68 Spinning blue column from HCZ $32656 $231AEE
69 Curved twisting blue pipe from HCZ 2 $3907C None (part of level art)
6A Invisible horizontal block which hurts player $1F3F8 $1ECC6
6B Invisible vertical block which hurts player $1F5A0 $1ECC6
6C Bridge which sags when you walk across it $38688 $38FF2 (HCZ/LRZ)/$38FBA (ICZ)
6D Special water splash from HCZ, where a waterfall hits an object $383BC $237C60/$237C7A
6E Water drops from HCZ $3827C $23794E
6F Horizontal rotating mesh from FBZ $39F2E None (part of level art)
70 Vertical mesh from FBZ inside which player rotates $3A23A None (part of level art)
71 Floating platform from FBZ $3A580 $3A742
72 Row of metal hangers from FBZ $3A7CC $3AD8A
73 Magnetic ceiling panel from FBZ $3B0E2 $3B25C
74 Magnetic spiked platform and chain from FBZ $3B2F6 $3B4DE
75 4 spheres in a chain which move in and out of pipes arranged in a rectangle $3B534 $3B6CE
76 L-shaped pipe in FBZ from which the sphere chain emerges $3B6DE $3B73C
77 Rotating sphere chain from FBZ $3B766 $3B91A
78 Object which launches player forward in FBZ and DEZ $3B934 $3BA8A
79 Disappearing platform from FBZ (the one in the shape of a quarter-circle) $3BAB2 $3BBBE
7A Door from FBZ in the shape of a corkscrew $3BBEE $3BD8E
7B Fan pole from FBZ $3BF56 None (part of level art)
7C Fan on top of pole from FBZ $3C1A6 $3C20C
7D Giant crushing piston from FBZ 1 $3C25C $3C328
7E Blocks from FBZ which make up the horizontal platform gate $3C34C $3C416
7F Missile launcher from FBZ $3C462 $3C78E
80 Hidden monitors which bounce out when the starpost touches them $836E0 $1DBA2
81 Egg capsule $86540 $86BFC
82 All appearences of Knuckles as a bad guy or as a non-controllable character $61D4C Varies depending on appearance (aka I'm lazy)

Determines behaviour:

  • 00 - Knuckles at the start of AIZ 1
  • 04 - Knuckles at the end of AIZ 2
  • 08 - Knuckles at the end of HCZ 2
  • 0C - Knuckles in the middle of CNZ 2
  • 10 - Knuckles at the end of CNZ 2
  • 14 - Knuckles from LBZ 1
  • 18 - Knuckles from LBZ 2
  • 1C - Knuckles from MHZ 1
  • 20 - Knuckles from MHZ 2
  • 24 - Knuckles at the end of LRZ 2
  • 28 - Knuckles boss from HPZ
  • 2C - Knuckles from SSZ
  • 30 - Knuckles in the MHZ 1 intro (only in S&K alone)
83 Buttons used by Knuckles $65BD4 $2C71E
84 Sonic during the AIZ intro sequence $67472 $146620
85 Giant ring $6166A $619E0 (normal)/$61B28 (flash)
86 Gumball level from gumball bonus stage. Also initializes all other sprites $60C56 $6148A
87 Springs on the sides of the gumball bonus stage $60F2E $6148A
88 Special breakable floor from CNZ 2 which causes a water level rise when broken $65D16 None (not displayed, spawns a normal breakable floor object)
89 Button which switches the lights on again in CNZ 2 $65D6E $2C71E
8A Doors and insides of windows in the cutscene at the end of FBZ 2 $86CF6 $86D2A
8B Sprite which performs some sprite masking. Not sure what effect this achieves $862AE $18595E
8C Bloominator badnik from AIZ $86D6A $3616C0
8D Rhinobot $86E56 $3615A8
8E Monkey badnik from AIZ $87156 $361776
8F Catakiller Jr. badnik from AIZ $876CA $361A18
90 First appearance of the AIZ 1 miniboss, in which he sets the level on fire $684EC $3624D0
91 Miniboss from AIZ 1 $68A24 $3624D0
92 Boss from AIZ 2 $691A8 $361FD6
93 Jawz badnik from HCZ $878B2 $361364
94 Blastoid badnik from HCZ $87928 $360DD0
95 Buggernaut badnik from HCZ $87A24 $360EB4
96 Turbo Spiker badnik from HCZ $87BC4 $361212
97 Mega Chopper badnik from HCZ $87F56 $360F26
98 Pointdexter badnik from HCZ $8827C $360E72
99 Miniboss from HCZ 1 $69EA0 $3629E0
9A Boss from HCZ 2 $6AEB6 $3634D4
9B Bubbles badnik from MGZ $88336 $361C68
9C Spiker badnik from MGZ $88B96 $361CB8
9D Mantis badnik from MGZ $88E60 $361D26
9E Driller from MGZ 1 $8845A $361972
9F Miniboss from MGZ 1 $88568 $361972
A0 Drilling Eggman from MGZ 2 $6BF2A $362608
A1 Boss from MGZ 2 $6C31A $362608
A2 Knuckles' boss from MGZ 2 $6C698 $362608
A3 Clamer badnik from CNZ $88FB4 $361ABC
A4 Blastoid badnik from CNZ $89198 $361B34
A5 Batbot badnik from CNZ $89376 $361BD0
A6 Miniboss from CNZ 1 $6D99C $362ED4
A7 Boss from CNZ 2 $6E47E $3609AA
A8 Blaster badnik from FBZ $8948E $8977C
A9 Technosqueek badnik from FBZ $89820 $89B78
AA Miniboss from FBZ 1 $6EE68 $6FAF8
AB Laser boss from FBZ 2 $6FD0C $70440
AC Boss from FBZ 2 $705EA $70FB4
AD Penguinator badnik from ICZ $8BADE $361E90
AE Star Pointer badnik from ICZ $8BE2E $361FAE
AF Crushing column from ICZ $8A44A $3639C0 Determines column type:
  • 1 - moves up as soon as player stands on it
  • 2 - moves up by itself at constant intervals
  • 3 - comes down as soon as player passes it, blocks path
  • 4 - moves down by itself at constant intervals
  • 5 - only blocks Knuckles' way
B0 Platform from ICZ $89F32 $363C44 Determines platform type:
  • 0 - falls down when player stands on it, slides down slopes and breaks walls
  • 2 - moves when player pushes it, slides down slopes and breaks walls
  • 4 - stationary (unused in game)
  • 6 - sinks when player stands on it
B1 Breakable wall from ICZ $8A26C $3639C0
B2 Freezer from ICZ $8A640 $363C44
B3 Segmented column from ICZ $8AB4E $3639C0 Determines column type:
  • 0 - doesn't have top non-breakable standing segment
  • 2 - has top non-breakable standing segment
B4 Swinging platform from ICZ $8AD04 $363C44 0 for normal, 2 for the special one at the end of ICZ 1 which breaks off
B5 Stalactite from ICZ $8B194 $3639C0
B6 Ice cube which covers monitors and switches from ICZ $8B36C $363C44
B7 Ice spikes from ICZ $8B2A0 $3639C0
B8 Harmful ice pieces from ICZ $8B4CA $363C44 0 for the ones on the walls, 2 for the ones in the air
B9 Snowpile from ICZ $8B550 $363C44
BA Trampoline from ICZ $8B89A $363C44
BB Right trampoline support from ICZ $8A330 $363C44
BC Miniboss from ICZ 1 $71162 $363344
BD Boss from ICZ 2 $71BCE $362CB4
BE Snale Blaster badnik from LBZ $8BFAE $360400
BF Ribot badnik from LBZ $8C2E2 $3604B8
C0 Orbinaut badnik from LBZ $8C632 $3604A4
C1 Corkey badnik from LBZ $8C728 $3605C2
C2 Flybot767 badnik from LBZ $8C966 $36065A
C3 Eggman from LBZ 1 $8CB56 $6820C
C4 Miniboss box from LBZ 1. Triggered only in case the player dies during the fight and restarts at the near starpost $8CDB8 $36036A
C5 Knuckles' miniboss box from LBZ 1 $8CF80 $36036A
C6 Egg Mobile which transports Sonic to the final boss arena in LBZ 2 $8D29C $6820C
C7 Ring (unused slot) $1A51A $1A99A
C8 Towers supporting the Death Egg at the time of launch $62AC2 $62AFC
C9 Miniboss from LBZ 1 $723E0 $3602C8
CA Laser columns boss from LBZ 2 $729BA $6820C
CB Black ball machine boss from LBZ 2 $738D6 $360896
CC Squeeze Tag boss from LBZ 2 $74262 $6820C
CD Laser colums boss initializer for Knuckles in LBZ 2 $72FFA None (just handles boss setup)
CE Door of Flying Battery which Sonic breaks to fall down into Sandopolis $70C2C $70F7E
CF Egg prison from FBZ $89BDC $1871E8 Determines how prison acts:
  • 0 - releases animals
  • 1 - releases rings
  • 2 - releases enemies
D0 Egg prison plunger from FBZ which acts as a spring $89C86 $1871E8
D1 Ring (unused slot) $1A51A $1A99A
D2 Ring (unused slot) $1A51A $1A99A
D3 Ring (unused slot) $1A51A $1A99A
D4 Ring (unused slot) $1A51A $1A99A
D5 Ring (unused slot) $1A51A $1A99A
D6 Ring (unused slot) $1A51A $1A99A
D7 Ring (unused slot) $1A51A $1A99A
D8 Ring (unused slot) $1A51A $1A99A
D9 Ring (unused slot) $1A51A $1A99A
DA Ring (unused slot) $1A51A $1A99A
DB Ring (unused slot) $1A51A $1A99A
DC Ring (unused slot) $1A51A $1A99A
DD Ring (unused slot) $1A51A $1A99A
DE Ring (unused slot) $1A51A $1A99A
DF Ring (unused slot) $1A51A $1A99A
E0 Missile which shoots out of a wall in FBZ 1 $3C7EC $3C906
E1 Mine from FBZ $3C946 $3CA06
E2 Elevator from FBZ $3CA1A $3CB0C
E3 Spring which flips onto itself at the end of a tunnel from FBZ $3CB3A $3CC5A
E4 Flamethrower from FBZ $3CC8A $3CFD0
E5 Spider crane from FBZ $3D090 $3D2FC
E6 Triangular bumper from magnetic orbs bonus stage $49AAE $49C0A
E7 Flipper from magnetic orbs bonus stage $49C5E $49E8C
E8 Energy trap from magnetic orbs bonus stage $49EEE $4A08A
E9 Individual spheres which make up the magnetic orbs bonus stage energy trap $4A09A $4A118
EA Platform from magnetic orbs bonus stage (unused, but viewable in debug mode) $4A186 $4A1D6
EB Gumball item from magnetic orbs bonus stage $4A2C6 $4A3D2 (F gumball viewable in debug mode)/$6148A (all other gumballs)
EC Magnetic orb from magnetic orbs bonus stage $4A3DC $4A3D2 (object is never displayed though, part of level art)
ED Item orb from magnetic orbs bonus stage $4A1E6 $4A294
EE Ring (unused slot) $1A51A $1A99A
EF Ring (unused slot) $1A51A $1A99A
F0 Ring (unused slot) $1A51A $1A99A
F1 Ring (unused slot) $1A51A $1A99A
F2 Ring (unused slot) $1A51A $1A99A
F3 Ring (unused slot) $1A51A $1A99A
F4 Ring (unused slot) $1A51A $1A99A
F5 Ring (unused slot) $1A51A $1A99A
F6 Ring (unused slot) $1A51A $1A99A
F7 Ring (unused slot) $1A51A $1A99A
F8 Ring (unused slot) $1A51A $1A99A
F9 Ring (unused slot) $1A51A $1A99A
FA Ring (unused slot) $1A51A $1A99A
FB Ring (unused slot) $1A51A $1A99A
FC Ring (unused slot) $1A51A $1A99A
FD Ring (unused slot) $1A51A $1A99A
FE Ring (unused slot) $1A51A $1A99A
FF Pendulum from FBZ which swings player from one side to another $3D448 $3D9AE 0 for horizontal, $80 for vertical

Sprite Mappings

Sprite mappings define how to arrange the sprite art. A sprite's mappings begin with an offset table which gives the location of the mappings data for each frame. The actual mappings data consists of a one word header, which gives the number of sprite pieces which make up the frame. Following this header is the actual pieces data, the data for each piece consisting of three words:

  • First word:
    • High byte is the relative signed top edge position of the sprite from the center of the object.
    • Low byte is the size of the sprite, in tiles minus one. The upper four bits are ignored, the next two bits control the width and the lowest two bits control the height. Thus sprites can be of any size from 1x1 tile to 4x4 tiles. For example, $01 is a 1x2 sprite, $02 is a 1x3 sprite, $04 is a 2x1 sprite, and so on.
  • Second word:
    • This word will be added to the object's VRAM offset and then used as the pattern index for that sprite. Like all SEGA Genesis VDP pattern indices, it is a bitmask of the form PCCY XAAA AAAA AAAA. P is the priority flag, CC is the palette line to use, X and Y indicate that the sprite should be flipped horizontally and vertically respectively and AAA AAAA AAAA is the actual tile index, i.e. the VRAM offset of the pattern divided by $20.
  • Fourth word: This is the relative signed left edge position of the sprite from the center of the object.

Object Placement

There are six bites in one object definition. The first two bytes are the X position of the object. The next two bytes, broken down in bits, have the format ABC0 YYYY YYYY YYYY, where A is a flag which if set indicates that the object should be loaded whenever it is in X range regardless of its Y position, B is the vertical flip flag, C is the horizontal flip flag and YYYY YYYY YYYY is the Y position of the object. The 5th byte is the reference number on the object pointer list (see above), and the 6th byte is an optional declaration to use for defining that object's behavior and/or animation. This will depend on the object. See the level specific hacking info for the locations of the object lists.

The 6th byte, the object subtype, is loaded in the byte $2C of the SST of that object (see below).

Ring Placement

There are four bytes for every ring object. The first 2 bytes are X coordinates, and the next two are the Y coordinates. Sonic 3k uses individual rings, unlike Sonic 2, which uses ring groups that have to be expanded into RAM. The advantage of Sonic 3k's method is that ring position data can be read directly from ROM, meaning that only two bytes are used up in RAM per ring instead of six, saving on RAM space and allowing Sonic 3k levels to have a maximum of 511 rings, as compared to Sonic 2's 255, despite allocating $200 bytes less to the ring status table.

The ring placement data must start with 0000 0000, and must end with FFFF. These prevent the rings position checker subroutine from going over the bounds of the ring placement data, and are necessary for the correct functioning of the rings manager.

Level Layout

Level layouts are stored uncompressed in the ROM, and the format they use differs significantly from the format used in Sonic 2, allowing much larger levels.

The layout starts with an 8 byte header describing the layout. The first word of this header is the number of 128x128 tiles that make one foreground row, and the second word is the number of 128x128 tiles that make one background row. The third word is the number of foreground rows, and the fourth is the number of background rows.

Next is a list of 64 word-sized pointers in RAM. Each row of 128x128 tiles has two pointers - one for the foreground data and one for the background data. The maximum level height is thus (64 / 2 * 128) = $1000 pixels, double the maximum level height for Sonic 2.

The actual rows data (beginning at byte $88) is very simple - there is one byte per 128x128 tile, and the blocks are put together from left to right.

See the level specific hacking info for the locations of level layout data. (Put here for now, will eventually be moved to subpage)

Offset Level Name
$281420 Angel Island 1
$281C6C Angel Island 2
$2829D2 Hydrocity 1
$2834FA Hydrocity 2
$2843A2 Marble Garden 1
$285032 Marble Garden 2
$285DE2 Carnival Night 1
$2869AC Carnival Night 2
$28793A Icecap 1
$288902 Icecap 2
$289752 Launch Base 1
$28A6FE Launch Base 2
$9F3B6 Mushroom Hill 1
$A00EA Mushroom Hill 2
$9D680 Flying Battery 1
$9E428 Flying Battery 2
$A0D5A Sandopolis 1
$A1BC6 Sandopolis 2
$A29DE Lava Reef 1
$A3806 Lava Reef 2
$A766C Lava Reef 2 (Robotnik)
$A7924 Hidden Palace
$A458E Sky Sanctuary 1
$A51FE Sky Sanctuary 2
$A537A Death Egg 1
$A6348 Death Egg 2
$A7F4C Death Egg 2 (Robotnik)
$A71D6 Doomsday
$28B626 Azure Lake
$28B7F2 Balloon Park
$28BA3E Chrome Gadget
$28B946 Desert Palace
$28BB36 Endless Mine
$28BC2E Gumball bonus
$A72E2 Magnetic orbs bonus
$A74CA Slot machine bonus

16x16 Block Mappings

Text Editing

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 128x128 mappings
$8000-$8FFF Level layout
$9000-$A9FF 16x16 mappings
$AA00-$ABFF Pattern decompression buffer
$AC00-$AFFF Sprite table input. Consists of 8 different priority levels, each level taking up $80 bytes. The first word of each level is the number of objects currently in that priority level multiplied by 2, and the next $3F words are the addresses in RAM (inside the SST) of the objects on that priority level. The information in this table is processed by BuildSprites to create the actual sprite table
$B000-$CFCB Object attribute table
$D000-$DFFF Kosinski decompression buffer
$E000-$E37F Horizontal scroll buffer
$E380 Number of objects currently in collision response list, multiplied by 2.
$E382-$E3FF Collision response list. The format is one word per object, where the word is the starting address of the object's SST. Only objects in this list are processed by the collision response routine.
$E700-$EAFF Ring status table. The format is two bytes per ring, these bytes being 0000 while the ring has yet to be consumed, serving as a ring destruction timer while the ring is being consumed, and being set to FFFF when the ring has been fully consumed.
$EB00-$EDFF Object respawn table. Each object which is part of a level's object placement gets an entry in this table, and whenever the objects manager creates a new object, it sets bit 7 of the object's entry in the object respawn table. While bit 7 is set, the object will not be loaded again by the objects manager. The other seven bits of the entry are free for use by the object - for example, monitors set bit 0 to signify a broken monitor. Since every object which is part of the level's object placement has an entry in this table, the maximum number of objects any level can have in its object placement is 768, although the only level that gets close to that number is AIZ 2, with 751 objects.
$EE12 Screen Y end
$EE14 Screen X start
$EE16 Screen X end
$EE18 Screen Y start
$EE1A Screen Y end location for Sonic; the maximum value for camera Y position. Like $EE12, but changes slowly instead of instantly when the level Y boundary changes.
$EE33 Routine counter for Dynamic Screen Resizing. (Dynamic Level Events)
$EE42-$EE45 Address (in the ROM) of the first ring whose X position is greater than or equal to the current camera X value minus 8.
$EE46-$EE49 Address (in the ROM) of the first ring whose X position is greater than or equal to the current camera X value + $148.
$EE4A-$EE4B Address (in the ring status table) of the first ring whose X position is greater than or equal to the current camera X value minus 8.
$EE60 Camera X for the second player in 2p mode
$EE64 Camera Y for the second player in 2p mode
$EE68 Copy of camera X for the second player in 2p mode for rasters
$EE6C Copy of camera Y for the second player in 2p mode for rasters
$EE78 Camera X
$EE7C Camera Y
$EE80 Copy of Camera X for Rasters
$EE84 Copy of Camera Y for Rasters
$EEC6 Level property (like killer wall in HCZ2 or avalanche in ICZ1)
$EF49 Flag which determines whether the second player in a 2P versus game is player-controlled or just a "ghost" of the first player.
$EF72-$EF73 Flag which is set to $FF00 if an ending is running. The only thing this seems to do is prevent the game from being able to pause.
$EF80 The number of rings inside the ring consumption table.
$EF82-$EFFF Ring consumption table. Contains the RAM addresses (inside the ring status table) of rings which are currently being consumed. Once consumed, the rings are deleted from this table.
$F000-$F07F Second underwater palette.
$F080-$F0FF Underwater palette.
$F600 Master level trigger. Tells the game what it should be doing.

The MSB is a loading routine flag. It only matters for some game modes. It won't have any effect when changing modes because it's filtered out, but the corresponding routine does pay attention to it...

$F602 In-game Controller 1 held state. Same as F604, but it only updates during the main game loop, and not while paused, or a custcene is running.
$F603 In-game Controller 1 pressed state. Same as F602, but only tells which buttons are being pressed newly this frame.
$F604 This bitfield tells which button(s) on Controller 1, if any, are currently pressed. Format is:
  • Bit 0 - Up
  • Bit 1 - Down
  • Bit 2 - Left
  • Bit 3 - Right
  • Bit 4 - B
  • Bit 5 - C
  • Bit 6 - A
  • Bit 7 - Start

This is updated every frame.

$F605 Same as $F604, but only tells which buttons are being pressed newly this frame.
$F606 Same as $F604, but for Controller 2.
$F607 Same as $F606, but only tells which buttons are being pressed newly this frame for Controller 2.
$F614 Demo time left & Time until demo starts from title screen.
$F636 RNG seed (used for pseudo-random number generation).
$F63A-$F63B Game paused flag.
$F648-$F649 Current water level. Should be a valid Y-axis value. Remember, the top of the level is $0000.
$F64C Water on: seems to be a copy of $F730.
$F65E Super Sonic palette counter. Decremented with every frame. How it works, exactly, is not known.
$F65F Sets the rotating palette for Super Sonic.
$F66A In-game Controller 2 held state. Same as $F602, but for controller 2
$F66B In-game Controller 2 pressed state. Same as $F66A, but only tells which buttons are being pressed newly this frame.
$F670-$F671 Super Sonic ring drain counter. This is updated each frame, so the counter is set to 60 ($3C) on consoles operating in 60Hz mode, or 50 ($32) in consoles operating in 50Hz mode. After each frame, the code subtracts 1. One ring is removed when this counter reaches zero; in other words, each second.
$F680-$F6DF A buffer for pattern loading cues (requests). Each entry in this consists of one longword followed by one word, the longword being the location in ROM of the compressed art, and the word being the VRAM location to decompress to. Can store a maximum of 16 entries, but a coding error in the clearing routine means that storing a PLC in the last slot screws everything up, so effectively only 15 requests can be stored at one time.
$F6E0-$F6E3 The address in ROM of the decompression routine to be used for the art
$F6E4-$F6F7 Used by the PLC routines using decompression. No idea what their function is, although it seems they get passed in as parameters to the decompression routine, and are stored updated when the routine returns.
$F6F8-$F6F9 The total number of tiles left to be decompressed for the current piece of art
$F6FA-$F6FB The number of tiles left to be decompressed in the current frame
$F700-$F701 Seems to be set to $0001 when in a Sonic & Tails game. Set to $0000 when not a Sonic & Tails game.
$F702-$F703 Tails control counter. Counts how long until the CPU takes control.
$F704-$F705 Tails repawn counter.
$F708-$F709 Tails CPU routine.
$F70A-$F70B Tails CPU target X position. Tells Tails where Sonic's X position is so he can fly back to him.
$F70C-$F70D Tails CPU target Y position. Tells Tails where Sonic's Y position is so he can fly back to him.
$F70E-$F70F Tails interact ID. Object ID of last object Tails stood on.
$F710 Routine counter for the rings manager.
$F711 Level started flag. Set to 1 as soon as the player first gets control in the level.
$F730 Water flag. Must be set for any of the other water variables to have any effect. Note that levels without water don't have an underwater palette; you must set one or everything below the water level will be black.
$F760-$F761 Sonic's top speed
$F762-$F763 Sonic's acceleration
$F764-$F765 Sonic's deceleration
$F766 Sonic's current mapping frame number.
$F7AA Seems to be clear during normal play, but set to some value during a boss fight. That value may be the current Zone number.
$F7C6 Reverse gravity flag. Only in Sonic & Knuckles.
$F7CA Controller lock for controller 1.
$F7CB Controller lock for controller 2.
$F7D0-$F7D1 Bonus counter. Increments upon destruction of a destroyable object, and is used to determine how many points the destruction should give. Resets when the player touches the ground.
$F7D2-$F7D3 Time bonus counter at the end of level result screen
$F7D4-$F7D5 Ring bonus counter at the end of level result screen
$F7DA-$F7DB Counts the number of times the camera has scrolled to the right by one full screen width from its previous position - initial value is $FF80 and then counts up like: $FF80,$0000,$0080,$0100,$0180,etc.
$F800-$FA7F Sprite attribute table buffer.
$FB00-$FBFB VDP command buffer. Stores up to 18 sets of queued up VDP commands to be issued later.
$FBFC-$FBFF VDP command buffer free slot. Stores the address of the first available empty place in the VDP command buffer.
$FC00-$FC7F Normal palette.
$FC80-$FCFF Second palette.
$FE00 Start of the system stack. Note that the stack grows up rather than down. This means that when something is pushed onto the stack, the SP is decremented, and when something is popped from it, the SP is incremented.
$FE02-$FE03 Level restart flag.
$FE06 Object currently selected in debug mode.
$FE09 Object placement mode flag.
$FE10 The current Zone. This is the value assigned to the Zone, not its position in the level list.
$FE11 Act number
$FE12 Life Count
$FE18 Number of continues.
$FE19 Super Sonic flag. Setting this will load the Super Sonic tiles, adjust Sonic's jump height, and start draining rings, but it will not load the rotating palette, change acceleration, max speed, or deceleration, or make him invincible.
$FE1A Flag which is set when the player has a time over.
$FE1B This bitfield tells the game if the player has collected extra lives from rings. Seems to work differently in S3k than in S2.
$FE1C Flag determines if the lives counter needs to be updated
$FE1D Flag determines if the rings counter needs to be updated
$FE1E Flag determines if the timer needs to be updated
$FE1F Flag determines if the score counter needs to be updated
$FE20-$FE21 Ring count
$FE23 Minutes on clock. Should not go above $09, or the clock will look like shit.
$FE24 Seconds. This one shouldn't go above $3B, for the same reason.
$FE25 Centiseconds. I don't know what'll happen if this goes out of range, but it's probably not good.
$FE26-$FE29 Score (divided by 10)
$FE2A Greatest reference number of passed star poles
$FE2B Starpole ID of the last starpole hit
$FE2C Zone in which the last starpole was hit
$FE2D Act in which the last starpole was hit
$FE2E-$FE2F X position of the last starpole hit
$FE30-$FE31 Y position of the last starpole hit
$FE32-$FE33 The number of the rings the player had when the last starpole was hit
$FE34-$FE37 Copy of the entire clock data when the last starpole was hit
$FE35 Minutes on the clock when the last starpole was hit
$FE36 Seconds on the clock when the last starpole was hit
$FE37 Centiseconds on the clock when the last starpole was hit
$FE38-$FE39 Starting art block of the main character when the last starpole was hit
$FE3A-$FE3B Main character's collision layers data when the last starpole was hit
$FE3C-$FE3D Camera's X position when the last starpole was hit
$FE3E-$FE3F Camera's Y position when the last starpole was hit
$FE40-$FE41 Water level when the last starpole was hit
$FE42 The state of the water movement flag when the last starpole was hit
$FE43 The state of the extra lives from rings bitfield when the last starpole was hit
$FE44-$FE45 Camera's current maximum Y position when the last starpole was hit
$FE46 DSR/DLE routine when the last starpole was hit
$FE48 Flag which is set upon special stage entry and cleared when the data saved on special stage entry is restored
$FE49 Starpole ID of the last starpole hit before the last special stage entry
$FE4A Zone from which the last special stage was entered
$FE4B Act from which the last special stage was entered
$FE50-$FE51 The number of rings the player had when the last special stage was entered
$FE52-$FE55 Copy of the entire clock data when the last special stage was entered
$FE53 Minutes on the clock when the last special stage was entered
$FE54 Seconds on the clock when the last special stage was entered
$FE55 Centiseconds on the clock when the last special stage was entered
$FE56-$FE57 Starting art block of the main character when the last special stage was entered
$FE58-$FE59 Main character's collision layers data when the last special stage was entered
$FE5A-$FE5B Camera's X position when the last special stage was entered
$FE5C-$FE5D Camera's Y position when the last special stage was entered
$FE5E-$FE5F Water level when the last special stage was entered
$FE60 The state of the water movement flag when the last special stage was entered
$FE61 The state of the extra lives from rings bitfield when the last special stage was entered
$FE62-$FE63 Camera's current maximum Y position when the last special stage was entered
$FE64 DSR/DLE routine when the last special stage was entered
$FE6E-$FEAF Oscillating numbers data
$FEB2 Rings animation counter.
$FEB3 Rings animation frame.
$FEB6 Spilling rings animation counter.
$FEB7 Spilling rings animation frame.
$FEC0-$FEC1 Tails's max speed
$FEC2-$FEC3 Tails's acceleration
$FEC4-$FEC5 Tails's deceleration
$FEC6 Tails's lives in 2P mode. Unused in S3K, but its there.
$FEC7 This bitfield tells the game if the player has collected extra lives from rings. Used for Tails in 2P mode. Unused in S3K, but its there.
$FEC8-$FEC9 Rings collected since level load. Resets if you enter Special/Bonus stage. Starts recounting from 0 when level is reentered. Unknown use.
$FF04-$FF05 Perfect counter (leftover from S2). No perfect bonus is given for collecting all the rings, making this variable virtually useless.
$FF08-$FF09 Current character (00 - sonic & tails, 01 - sonic, 02 - tails, 03 - knuckles)
$FF0A-$FF0B Character selected in level select (00 - sonic & tails, 01 - sonic, 02 - tails, 03 - knuckles)
$FF0E-$FF0F Number of kosinski compressed data pieces on the kosinski decompression queue ($FF40-$FF5F) waiting to be decompressed to RAM. The most significant bit of this being set signifies a decompression is in progress
$FF10-$FF37 Kosinski queue processing routine register backup. Registers d0-d6 and a0-a2 are backed up here in case the Kosinski queue processing routine is interrupted by V-Int. They're restored the next time the processing routine is called
$FF38-$FF39 Kosinski queue processing routine status register backup. In case the processing routine is interrupted by V-Int, the SR is stored here and restored the next time the routine is called
$FF3A-$FF3D Kosinski queue processing routine program counter backup. In the instance of the processing routine being interrupted by V-Int, when V-Int is ready to return, the processing does not resume. Instead, by means of the subroutine at $1BF0, program resumption is forced to occur at $1D0C, and the actual overwritten program counter value gets stored here. Next time the processing routine is called, the routine at $1CFC kicks in, pushing this value and the stored SR onto the stack and executing an RTE, causing both to get restored and the processing to resume.
$FF3E-$FF3F The Kosinski queue processing routine uses this to store words byteswapped. It's used by the processing routine the same way the stack is used by the normal Kosinski decompression routine
$FF40-$FF5F The Kosinski decompression queue. Each entry consists of two longwords:
  • $00 - the source Kosinski data location
  • $04 - the destination RAM address to decompress to

Since this is 32 bytes long, only 4 pieces can be stored on it at one time.

$FF60 Number of modules of KosinskiM compressed data waiting on the KosinskiM decompression and DMA queue ($FF64-$FF7B) to be decompressed to RAM and subsequently DMAed to VRAM. Bit 7 set to 1 indicates that the art has been already decompressed to the Kosinski art buffer ($D000), and is ready to be DMAed
$FF62-$FF63 The decompressed size of the last module of the KosinskiM data divided by 2. All other modules have a fixed decompressed size of $1000
$FF64-$FF7B The KosinskiM decompression and DMA queue. Each entry consists of a longword followed by a word:
  • $00 - the source Kosinski module location
  • $04 - the destination VRAM address to DMA the decompressed module to

Like the decompression queue, this can also only store 4 pieces at a time.

$FF96 State of the main character's secondary status bitfield when the last special stage was entered, used to restore any shield the character had when he entered the special stage and cleared once the shield is restored
$FFB0 Number of chaos emeralds
$FFB1 Number of super emeralds
$FFB2-$FFB8 Array of finished special stages. Each byte represents one stage:
  • 0 - special stage not completed
  • 1 - chaos emerald collected
  • 2 - super emerald present but grayed
  • 3 - super emerald present and activated
$FFBB If this is set to 0, Sonic 3 special stages will run. If it's 1, Sonic & Knuckles special stages will run.
$FFD2-$FFD3 Demo number
$FFDA Debug mode flag
$FFE8 2P versus mode flag
$FFEA 2p mode player 1's character
$FFEB 2p mode player 2's character

Object Status Table

The starting offset in RAM for this list is $B000. The first object is always player 1; the second is always player 2. Each object is alloted a block of $4A bytes. Note that many of these variables are object-specific - for example, some of them only make sense for Sonic, and some only work on badniks.

Offset Description
$00-$03 Pointer to object code. Note that this pointer does not necessarily remain constant for a single object.
$04 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, Tails and Knuckles use both positioning systems (though I don't know how Tails uses it in a Sonic and Tails game).
  • Bits 3, 4, 5 and 6 are either unused, or their purpose is unknown.
  • 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.
$05 Routine number. This is always an even value (i.e. it goes in units of 2)
$06 Unknown.
$07 Width of the object, in pixels.
$08-$09 Sprite priority, in units of $80 (00 = front).
$0A-$0B The lower 11 bits of this represent the starting art block. This is an index into an array of cells; to get the actual address, multiply by $20. Bits 14 and 13 are used to specify the default palette line the sprite uses, and bit 15 is the priority flag - if this is set, the sprite will be given high priority.
$0C-$0F Object's mappings offset.
$10-$11 If the object is Sonic, Tails or Knuckles, this is the X playfield coordinate. Otherwise:
  • If in playfield positioning mode, it is the X playfield coordinate.
  • If in screen postioning mode, it is the X screen coordinate.
$12-$13 If the object is Sonic, Tails or Knuckles, this is the X subpixel playfield coordinate. Otherwise:
  • If in playfield positioning mode, it is unused.
  • If in screen positioning mode, it's the Y screen coordinate.
$14-$15 If the object is Sonic, Tails or Knuckles, this is the Y playfield coordinate. Otherwise:
  • If in playfield positioning mode, it is the Y playfield coordinate.
  • If in screen positioning mode, it is unused.
$16-$17 If the object is Sonic, Tails or Knuckles, this is the Y subpixel playfield coordinate. Otherwise:
  • It's unused.
$18-$19 X speed.
$1A-$1B Y speed.
$1C-$1D Potential speed (inertia).
$1E Height/2
$1F Width/2
$20 Animation number.
$21 Restart animation flag (when $21 is not equal to $20, animation restarts)
$22 Current animation frame to display.
$23 Current frame in animation script.
$24 Animation frame duration (time until next frame).
$25 Animation counter.
$26 Angle.
$27 Second angle (different axis).
$28 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.
$29 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.
$2A 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 Set if Tails is standing on this object.
5 $20 Set if Sonic is pushing on this object.
6 $40 Set if Tails is pushing on this object.
7 $80 Unknown or unused.
Note that these bits have different meanings for Sonic (see below).
$2B Object shield reaction bitfield.
Bit Hex Description
3 $08 Bounces off shield.
4 $10 Negated by fire shield.
5 $20 Negated by lightning shield.
6 $40 Negated by bubble shield.
$2C Object subtype. For example, the current monitor selected. Has a different meaning for Sonic, Tails and Knuckles.
$42-$43 Parent. Address of the object that spawned this one. Has a different meaning for orphans like Sonic, Tails and Knuckles.
Variables specific to Sonic, Tails and/or Knuckles
Offset Description
$25
  • If Sonic, it's unused.
  • If Tails, it's the number of flying frames remaining / 2.
  • If Knuckles, it's something gliding related.
$2A Status bitfield. Counting from the least significant bit:
Bit Hex Description
0 $01 Orientation. Clear is right and set is left.
1 $02 Set if in the air (jump counts).
2 $04 Set if jumping or rolling.
3 $08 Set if the character 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 bits 1 and 2 are used in the character object as a second routine counter.

$2B Secondary status bitfield.
Bit Hex Description
0 $01 Shield flag. Can be set to create the effect of having a shield, though the graphics will not be loaded.
1 $02 Sets invincibility. Behaves like you would expect. No graphics are loaded when set manually.
2 $04 Speed Shoes flag. (Doesn't have visible effect in game)
3 $08 Unused.
4 $10 Fire shield flag.
5 $20 Lightning shield flag.
6 $40 Bubble shield flag.
7 $80 Sets infinite inertia. While the character is in collision with the ground, he will continue moving in the same direction and at the same speed that he was moving before (even if that speed was zero). You can still jump and control him in midair. (A few movement routines are skipped if it's set, which produces this effect).
$2C 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.
$2D Invert flipping flag.
$2E Object control flag. If bit 7 is not set, the character is under control of another object but can jump out (e.g. being carried by Tails), and if it is, the character is under control of another object and cannot jump out (e.g. LBZ tubes).
$2F Double jump flag. For Sonic:
  • 0 - on ground.
  • 1 - performing an instashield, fire dash, bubble bounce or lightning jump, or has performed the latter three.
  • 2 - has performed an instashield.

For Tails:

  • 0 - on ground.
  • 1 - gravity-affected flying.
  • Above 1 - gravity-less flying.

For Knuckles:

  • 0 - on ground.
  • 1 - gliding.
  • 2 - falling after a glide.
  • 3 - sliding across ground.
  • 4 - wall-climbing.
  • 5 - climbing over a wall and onto the ground.
$30 Number of flip revolutions remaining.
$31 Number of flip revolutions per frame divided by 256.
$32-$33 Horizontal control lock. Counts down to 0, left and right control on the ground is locked unless it's 0. Used for springs and bumpers and falling down slopes.
$34 Remaining invunerability time. Starts at $78 after Sonic is hit, and seems to decrement every frame until it reaches $00.
$35 Remaining time of invincibility. Decremented once every eight frames.
$36 Remaining time of Speed Shoes. Decremented once every eight frames.
$38 Character ID:
  • 0 - Sonic
  • 1 - Tails
  • 2 - Knuckles
$39 Character looking up/ducking counter. Starts off at 0 and is incremented each frame the character is looking up/ducking. When this reaches $78, the camera starts to scroll. Reset to 0 upon release of the up/down button.
$3A Angle on ground in front of sprite.
$3B Angle on ground under sprite.
$3C Stick to convex surfaces flag.
$3D Set if charging a spindash.
$3E-$3F Spindash counter. Cleared when the spindash is started. After each subsequent "rev", $200 is added to the counter, which then rapidly decreases (the algorithm is to logically shift the value right by five bits and subtract the results from the

original). It maxes out at $800. The game looks at the high-order byte to determine how fast the character should move after the dash is released.

$40 Set if jumping.
$42-43 RAM address of the last object Sonic stood on.
$44 Default height.
$45 Default width.
$46 Current collision plane/layer, seems to always be $C or $E.
$47 Unknown, seems to always be objstatus($46)+1, affects collision.
Variables specific to dynamically reloaded sprites, excluding Sonic, Tails and Knuckles
$34 Previous frame.
$38-$3B Pointer to uncompressed art.
$3C-$3F Pointer to dPLCs.
$40-$41 Address of art in VRAM (the same as starting art block * $20)
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