Editing Levels - RetroKoH/S1Fixed GitHub Wiki

(Guide by RetroKoH)

There are multiple pieces that make up any one level in the classic Sonic games. These include: art tiles, block mappings, chunks, color palette(s), object layouts, ring layouts, level layouts, and the starting coordinates. The manner in which these are edited will differ significantly between Sonic 1, 2 and 3K, and S1Fixed uses an amalgamation of the three games. To keep things simple, I'm going to only cover S1Fixed here, but you can find level editing guides, courtesy of Sonic Retro, at the links below:

Object Placement

S1Fixed uses Sonic 3K's Object Manager, so object layouts are formatted as they are in that game. Similar to the original Sonic 1, there are six bytes in one object definition. The usage of the 6 bytes in both versions is fairly similar to one another, but not identical. Here is the byte layout for Sonic 1, S3K, and S1Fixed:

XX XX FY YY II SS
  • XX XX -- X-position. The X-position is capped at $FFFF.
  • FY YY -- Flags and Y-position
  • II -- Object Pointer Index
  • SS -- Object Subtype

The second pair of bytes contains flags along with the Y-position, and this is where S3K/Fixed differ from Sonic 1.
These bytes, broken down in bits, have the format ABC0 YYYY YYYY YYYY. Here's what each bit does:

  • 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.
  • 0 is unused (should always be 0).
  • YYYY YYYY YYYY is the Y-position of the object. The Y-position is capped at FFF.

Ring Placement

One key difference between Sonic 1, and later titles (along with S1Fixed) is the handling of rings. In Sonic 1, rings were included in object placement files, and when loaded into object RAM, they'd run a routine where they would load more rings into a row or column, the number and formation of which was based on the subtype of the initial object. A deeper breakdown will be provided in the S3K Rings Manager tutorial page. S1Fixed uses the S3K Rings Manager, which not only keeps in-stage rings out of object RAM, but also allows for a far greater number of rings within a level.

There are four bytes for every ring in the file. The first 2 bytes are X coordinates, and the next two are the Y coordinates.

XX XX YY YY

Because the ring positions are read directly from ROM, you don't need to be concerned with any discrepancies between what's in the files (or the ROM itself), and what appears in-game.

Level Layouts

Level layouts in S1Fixed follow Sonic 2's format, and are compressed in Kosinski format. This means that they get loaded into RAM, which gives Fixed the advantage of allowing for having dynamic layouts easily (such as Labyrinth Zone Act 3), but also gives it the disadvantage of being limited in size.

In the layout file, there's one byte per 128x128 tile to place on the map. The blocks are put together from left to right, top to bottom. Each horizontal row is 128 ($80) bytes long, and there are 16 rows each for the foreground and the background (32 total). The rows are interlaced between the foreground and the background, so that there are 128 bytes for the first row of the foreground, then 128 bytes for the first row of the background, then 128 bytes for the second row of the foreground, etc.

Art Tiles

Blocks

Chunks

Palettes