Actions

SCHG

Sonic the Hedgehog CD (PC)

From Sonic Retro

Revision as of 04:44, 25 March 2020 by Black Squirrel (talk | contribs) (Text replacement - "Genesis" to "Mega Drive")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Sonicretro-round.svg This short article is in need of work. You can help Sonic Retro by adding to it.

This is the Sonic Community Hacking Guide for the DirectX PC Version of Sonic CD.
Note: All data is little endian.
Any reference to a file name with ??? should be replaced by the Round, Zone and Time Period. Thus, DLL???.dll for Palmtree Panic Zone 1 Present is DLL11A.dll.

Level editing

Note that the current version of SonED2 modifies some level data during the extraction process. This page documents the original formats, which SonLVL can open.

Object placement

This data is located in the DLL???.dll file in each level's folder. See below for locations.
Each time period of each Zone shares an object list, so that the game can remember that you destroyed an enemy in the past, and not show it in the present.

There are eight bytes 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 AB00 YYYY YYYY YYYY, where A is the vertical flip flag, B 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, with the most significant bit if set indicating that the object should be assigned an entry on the object respawn table, 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. The last two bytes, broken down in bits, are ABC0 0000 0000 0000, where A indicates the object should appear in the past time period, B indicates the object should appear in the present time period, and C indicates the object should appear in the future time period.

Level layout

This data is located in the DLL???.dll file in each level's folder. See below for locations.
Level layouts are pretty simple. They are 64x8 chunks, there is one byte per 256x256 chunk to place on the map. The blocks are put together from left to right, top to bottom.

8x8 tiles

This data is located in the TCMP???.cm_ file in each level's folder, and is a SCRL file. The tiles will always have a width and height of 8x8.

16x16 block mappings

This data is located in the T???.map file in each level's folder.
16x16 block mappings consist of four 8x8 tiles, arranged in the shape:

0 1
2 3

Each 8x8 tile is represented by one word, which like all SEGA Mega Drive VDP pattern indices, 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.

256x256 Chunk mappings

This data is located in the Map???.bin file in each level's folder.
256x256 chunk mappings consist of 256 16x16 tiles, arranged in the shape:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255

Each 16x16 tile has a two-byte value with the format 0SSY X0II IIII IIII. SS is the solidity of the tile - 00 means not solid, 01 means top solid, 10 means left/right/bottom solid, and 11 means all solid. Y is the Y-flip flag, X is the X-flip flag, and II IIII IIII is the index of the 16x16 tile to use.

Palettes

This data is located in the DLL???.dll file in each level's folder. See below for locations.
Unlike all the Mega Drive games, and even Sonic & Knuckles Collection, this port does not use Mega Drive palettes. Instead, palette entries take four bytes, in the format RR GG BB 01, allowing for over 16 million shades instead of the Mega Drive' 512.

DLL Breakdown

DLL11A.DLL

Offset Type Length Description
18C70 Palette 40 Palette line 1
18CB0 Palette C0 Palette lines 2-4
19818 Object Layout F90
1CE60 Level Layout 200 Foreground layout
1D060 Level Layout 200 Background layout

Sound Effects

Sound effects are stored in the PCM8.CMP file, in 8-bit unsigned Mono at 11kHz. The file begins with a header that begins like this:

Offset Type Description
0 String "OTHE"
4 Pointer End of File
8 4 Bytes Number of Sound Effects
C Pointer Sound Effect data

After this, there is a 4 byte value for each sound effect describing its length in bytes, then the sound data as raw PCM. SCDPCsnd can edit this file by importing and exporting WAV files.

Sprites

This data is located in SCMP*.cm_ files, and is SZDD compressed. Windows comes with an expand.exe program that can decompress these, or you can use EXPAND.EXE and COMPRESS.EXE from SonED2's Sonic CD PC folder.

The file begins with a header that begins like this:

Offset Type Description
0 String "SPRT"
4 Pointer End of File
8 4 Bytes Number of Sprites
C Pointer Sprites

After that, there are 0xC bytes of data for each sprite:

Offset Type Description
0 2 Bytes, signed X Offset
2 2 Bytes, signed Y Offset
4 2 Bytes Width
6 2 Bytes Height
8 2 Bytes Offset in palette to start at, plus 16
A 2 Bytes C1 2B

Following that is the sprite data, in 4bpp. Each sprite takes height * (width / 2) bytes, and the next sprite follows immediately. If a sprite's width is not divisible by eight, it is padded to be divisible by eight.

Tiles

This data is located in the TCMP*.cm_ files, and is SZDD compressed. Windows comes with an expand.exe program that can decompress these, or you can use EXPAND.EXE and COMPRESS.EXE from SonED2's Sonic CD PC folder.

The file begins with a header that begins like this:

Offset Type Description
0 String "SCRL"
4 Pointer End of File
8 4 Bytes Number of Tiles
C Pointer Tiles

Following that is four sets of 2 byte values, counting the number of tiles that use each palette line. Then there are two 2 byte values for each tile indicating its width and height.

Following that is the tile data, in 4bpp. Each tile takes height * (width / 2) bytes, and the next tile follows immediately.

References


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