Difference between revisions of "Sonic the Hedgehog 2 (Master System)/Level Editing"
From Sonic Retro
m (Black Squirrel moved page SCHG:Sonic 2 SMS/Level Editing to SCHG:Sonic the Hedgehog 2 (Master System)/Level Editing: Text replacement - "Sonic 2 SMS" to "Sonic the Hedgehog 2 (Master System)") |
m (Text replacement - "__NOTOC__ ==" to "==") |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{SCHG S2SMS}} | {{SCHG S2SMS}} | ||
− | |||
==Level headers== | ==Level headers== | ||
Line 24: | Line 23: | ||
ROM addresses for the level headers: | ROM addresses for the level headers: | ||
− | {| class=prettytable | + | {| class="prettytable" style="width:auto;" |
! Offset||Level | ! Offset||Level | ||
|- | |- | ||
Line 66: | Line 65: | ||
First of all, the metatiles begin with an offset index containing 256 16-bit, little endian pointers. The pointers are relative to a fixed position in the ROM, which varies depending on which set of mappings you're looking at. Immediately after the offset index is the metatile data itself. Each 32x32 tile is composed of 16 8x8 tiles. A 16-bit, little endian value is used to define which 8x8 tile is pulled from VRAM, and also how that 8x8 tile is displayed. Adding certain amounts to the value cause the 8x8 tile to be flipped/mirrored: | First of all, the metatiles begin with an offset index containing 256 16-bit, little endian pointers. The pointers are relative to a fixed position in the ROM, which varies depending on which set of mappings you're looking at. Immediately after the offset index is the metatile data itself. Each 32x32 tile is composed of 16 8x8 tiles. A 16-bit, little endian value is used to define which 8x8 tile is pulled from VRAM, and also how that 8x8 tile is displayed. Adding certain amounts to the value cause the 8x8 tile to be flipped/mirrored: | ||
− | {| class=prettytable | + | {| class="prettytable" style="width:auto;" |
! Value added||Effect | ! Value added||Effect | ||
|- | |- | ||
Line 86: | Line 85: | ||
− | ==Level Layout & | + | ==Level Layout & compression== |
Each byte in the level layout represents a 32x32 tile. The level is composed of many 32x32 tiles. In a savestate, the level is easy to edit because it's simple and uncompressed. However, in the ROM it's usually compressed. | Each byte in the level layout represents a 32x32 tile. The level is composed of many 32x32 tiles. In a savestate, the level is easy to edit because it's simple and uncompressed. However, in the ROM it's usually compressed. | ||
Line 100: | Line 99: | ||
Strangely, '''1515''' (for example) appears in the ROM as '''FD02''' '''15''', which wastes space. Repeated strings of bytes can be used in the ROM, and will appear correctly in the game. Compression is entirely optional, given that there is enough space in the ROM for the data. | Strangely, '''1515''' (for example) appears in the ROM as '''FD02''' '''15''', which wastes space. Repeated strings of bytes can be used in the ROM, and will appear correctly in the game. Compression is entirely optional, given that there is enough space in the ROM for the data. | ||
+ | |||
+ | ==References== | ||
+ | <references /> | ||
{{SCHGuides}} | {{SCHGuides}} |
Latest revision as of 04:38, 25 March 2020
SCHG: Sonic 2 (Master System) |
---|
Main Article |
Art Editing |
Editing Art |
Level Editing |
Editing Levels |
Object Editing |
Editing Objects |
Music Editing |
Editing Music |
Level headers
Each level header consists of 22 bytes:
AA BBBB CC DDDD EEEE FFFF GGGG HHHH IIII JJJJ KKKK LLLL
- AA = 32x32 mapping bank number
- BBBB = 32x32 mappings pointer
- CC = Level layout bank number
- DDDD = Level layout pointer
- EEEE = Level width in mapping blocks
- FFFF = 2's complement level width in blocks
- GGGG = Vertical offset into layout data. This is always 7 * EEEE.
- HHHH = Minimum camera x coordinate
- IIII = Minimum camera y coordinate
- JJJJ = Maximum camera x coordinate
- KKKK = Maximum camera y coordinate
- LLLL = Pointer to table of multiples of level width.
The EEEE and FFFF words are used by collision detection routines to move backwards and forwards in the level data array, whole rows at a time (e.g. for checking collisions above and below an object). The LLLL field is used to calculate the address of any given row of mappings in the level data array.
ROM addresses for the level headers:
Offset | Level |
---|---|
5635, 564B, 5661 | GHZ1/2/3 |
5677, 568D, 56A3 | SHZ1/2/3 |
56B9, 56CF, 56E5 | ALZ1/2/3 |
56FB, 5711, 5727 | UGZ1/2/3 |
573D, 5753, 5769 | GMZ1/2/3 |
577F, 5795, 57AB | SEZ1/2/3 |
57C1, 57D7, 57ED | CEZ1/2/3 |
5803 | Bad Ending |
5819 | Good Ending |
582F | Intro |
5845 | Title Screen |
32x32 MetaTiles
First of all, the metatiles begin with an offset index containing 256 16-bit, little endian pointers. The pointers are relative to a fixed position in the ROM, which varies depending on which set of mappings you're looking at. Immediately after the offset index is the metatile data itself. Each 32x32 tile is composed of 16 8x8 tiles. A 16-bit, little endian value is used to define which 8x8 tile is pulled from VRAM, and also how that 8x8 tile is displayed. Adding certain amounts to the value cause the 8x8 tile to be flipped/mirrored:
Value added | Effect |
---|---|
$0000 | Nothing (no flip, use BG palette, low priority) |
$0200 | Flip horizontally |
$0400 | Flip vertically |
$0800 | Use sprite palette |
$1000 | High priority |
Level Layout & compression
Each byte in the level layout represents a 32x32 tile. The level is composed of many 32x32 tiles. In a savestate, the level is easy to edit because it's simple and uncompressed. However, in the ROM it's usually compressed.
Uncompressed: 2020 2020 2020 |
---> | Compressed: FD06 20 |
FD means compression has occurred. 06 is the number of times a byte has been repeated. 20 is the byte which has been repeated.
Strangely, 1515 (for example) appears in the ROM as FD02 15, which wastes space. Repeated strings of bytes can be used in the ROM, and will appear correctly in the game. Compression is entirely optional, given that there is enough space in the ROM for the data.
References