Sonic the Hedgehog 2 (Master System)/Art

From Sonic Retro

(Redirected from SCHG:Sonic 2 SMS/Art)
SCHG: Sonic 2 (Master System)
Main Article
Art Editing
Editing Art
Uncompressed Art
Level Editing
Editing Levels
Level Headers
32x32 MetaTiles
Level Layout
Object Editing
Editing Objects
Object Layout
Object Types
Music Editing
Editing Music
Driver Technical Info
Module Format


Palettes are stored in bank 9, address $811F (absolute $2411F) in the standard SMS format. Individual palettes are accessed using an index value which is multiplied by 16 and added to $811F to calculate an absolute address.

Index Address Description
$00 $811F Unknown (4 shades of grey).
$01 $812F Unknown.
$02 $813F Level Select (most colors are unused)
$03 $814F Title Card Background
$04 $815F GHZ Sprite
$05 $816F SHZ 1 & 3 Sprite
$06 $817F SHZ 2 Sprite
$07 $818F ALZ 1 & 3 Sprite
$08 $819F ALZ 2 Sprite
$09 $81AF UGZ Sprite
$0A $81BF GMZ Sprite
$0B $81CF SEZ Sprite
$0C $81DF CEZ 1 & 2 Sprite
$0D $81EF CEZ 3 Sprite
$0E $81FF UGZ Background
$0F $820F SHZ 1 & 3 Background
$10 $821F SHZ 2 Background
$11 $822F ALZ 1 & 3 Background
$12 $823F ALZ 2 Background
$13 $824F GHZ Background
$14 $825F GMZ Background
$15 $826F SEZ Background
$16 $827F CEZ 1 & 2 Background
$17 $828F CEZ 3 Background
$18 $829F Intro Sequence Sprite
$19 $82AF Title Screen Sprite
$1A $82BF Intro Sequence Background
$1B $82CF Title Screen Background
$1C $82DF Unknown.
$1D $82EF UGZ Title Card Sprite
$1E $82FF SHZ Title Card Sprite
$1F $830F ALZ Title Card Sprite
$20 $831F GHZ Title Card Sprite
$21 $832F GMZ Title Card Sprite
$22 $833F SEZ Title Card Sprite
$23 $834F CEZ Title Card Sprite
$24 $835F Unknown.
$25 $836F Ending Sequence Sprite
$26 $837F Unknown.
$27 $838F 8 background palettes used by the ending sequence.

Uncompressed art

Uncompressed art is used for sprites that are loaded on-the-fly throughout the level (i.e. need to be loaded quickly). This includes Sonic's animations, rings, monitors, chaos emeralds, etc. Data is stored using the standard SMS planar format (see documentation on SMS Power!).


All level tiles and badnik art is compressed. The compression format is based on a simple principle: if the value is zero it can be omitted. Each omission is recorded in a flag bitfield at the end of the compressed data stream. The file structure is as follows:

Offset Size Description
$00 Word The value $0001 stored in little-endian format.
$02 Word The number of tiles in the compressed data.
$04 Word Pointer the compression bitfields (relative to start of file).
$06 Variable The compressed tile data.
Variable ceil(tile_count * 2 / 8) bytes Compression flags.

Compression flags

Four types of storage are employed in the compressed stream: 0 = tile is blank (32 zero bytes) and no data is stored (flags only), 1 = tile stored uncompressed, 2 = tile is compressed, 3 = tile is XOR encoded and then compressed. This means that 2 bits are required to store the compression type for each tile; thus each flag byte can store compression type for 4 tiles.

Flag bytes are read from the stream as required. The bytes are then rotated right twice to extract the compression type for a tile. Therefore, compression flag bytes will look like this:



  • 11 - Type for first tile;
  • 22 - Type for second tile;
  • 33 - Type for third tile;

Compression Types

Type 0

Blank Tile. To decompress, simply write 32 zero bytes.

Type 1

No compression. Straight copy of 32 bytes from the compressed data stream.

Type 2

Compressed data. A variable number of compressed bytes are preceded by 4 flag bytes (32 bits - one for each byte of uncompressed tile data). The decompression algorithm works as follows:

For each flag byte
Loop 8 times
Rotate right by one place
If bit rotated off was zero write a zero to the output
Else read one byte from the compressed data and copy to the output.

For example, given a flag byte of '01100101' and an input of 'E0 AB 43 A3 01', the decompressed output would be: 'E0 00 AB 00 00 43 A3 00'.

Type 3

XOR encoded, compressed data. To decompress follow the instructions for type 2 then decode according to the following algorithm (extracted from the Sonic the Hedgehog 2 (Master System) Disassembly): <syntaxhighlighter lang="z80"> XORDecode: ld ix, $D300 ;decode decompressed data at $D300 ld b, $07 -: ld a, (ix+0) ;xor byte at (ix+0) with byte at (ix+2)... xor (ix+2) ld (ix+2), a ;...and store the result at (ix+2)

ld a, (ix+1) ;xor byte at (ix+1) with byte at (ix+3)... xor (ix+3) ld (ix+3), a ;...and store the result at (ix+3)

ld a, (ix+16) ;xor byte at (ix+16) with byte at (ix+18)... xor (ix+18) ld (ix+18), a ;...and store result at (ix+18)

ld a, (ix+17) ;xor byte at (ix+17) with byte at (ix+19)... xor (ix+19) ld (ix+19), a ;...and store result at (ix+19)

inc ix inc ix ;ix += 2 djnz - ret </syntaxhighlighter>


Sonic Community Hacking Guide
SonED2 Manual | Subroutine Equivalency List
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 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