Actions

SCHG

Difference between revisions of "Sonic the Hedgehog 2 (16-bit)/Object Editing"

From Sonic Retro

 
m (Text replacement - "Genesis" to "Mega Drive")
 
(21 intermediate revisions by 5 users not shown)
Line 1: Line 1:
__NOTOC__
 
 
{{SCHG S2}}
 
{{SCHG S2}}
===Object Editing===
+
==Sounds==
====Sounds====
 
 
<!--Original submission by Weird Person-->
 
<!--Original submission by Weird Person-->
 
If you change the "ring" sound effect, ''all'' objects using that sound will have the new sound. This may not be desired, however - you may have only wanted the Super Ring powerup to play the new sound. With this list, you can edit the sound effect that an object plays. If you change the sound for the Super Ring power-up, '''only''' the Super Ring will have the new sound. Note that you are not changing any sound effects - you are only changing which effect will play.
 
If you change the "ring" sound effect, ''all'' objects using that sound will have the new sound. This may not be desired, however - you may have only wanted the Super Ring powerup to play the new sound. With this list, you can edit the sound effect that an object plays. If you change the sound for the Super Ring power-up, '''only''' the Super Ring will have the new sound. Note that you are not changing any sound effects - you are only changing which effect will play.
Line 10: Line 8:
 
To change the sound, first, take a value from the sound test (Ex: 1-up sound is $18) , add $80 to it and you get $98. This is the way you have to replace sounds (take a value from sound test, add $80 to it, and after that, insert the byte in the offset where you wish change the sound.)
 
To change the sound, first, take a value from the sound test (Ex: 1-up sound is $18) , add $80 to it and you get $98. This is the way you have to replace sounds (take a value from sound test, add $80 to it, and after that, insert the byte in the offset where you wish change the sound.)
  
=====Offset List=====
+
===Offset list===
 
The following list is the offset where you will place the new sound. I not will make a list with the values and its respective sounds. Use the trick (explained above) and Sound Test. Of course you can place the objects in any level you want (see Object Placement below), I'm just saying the level the object is used in for a better description.
 
The following list is the offset where you will place the new sound. I not will make a list with the values and its respective sounds. Use the trick (explained above) and Sound Test. Of course you can place the objects in any level you want (see Object Placement below), I'm just saying the level the object is used in for a better description.
  
{| border="1"
+
{| class="prettytable" style="width:auto;"
 
! Level||Description||Offset
 
! Level||Description||Offset
 
|-
 
|-
Line 93: Line 91:
 
|}
 
|}
  
====Object Pointer List====
+
==Object Pointer list==
See [[SCHG:Sonic 2/Object Editing/Pointers]].
+
See [[SCHG:Sonic the Hedgehog 2 (16-bit)/Object Editing/Pointers]].
  
====Sprite table (aka mappings)====
+
==Sprite mappings==
[http://sonicology.fateback.com/hacks/mappings/sonic2_format.htm Reference]<br>
+
[http://sonicology.fateback.com/hacks/mappings/sonic2_format.htm Reference]
The sprite table data can be expressed with this pseudocode:
 
  
<pre>
+
Each sprite mapping consists of four words. A contiguous list of sprite mappings preceded with a word-length number of mappings defines one frame for an object. The four words have the following purposes:
struct spriteTablePiece{
 
  byte yPosition;
 
  byte shape;
 
  byte attributes1P;
 
  byte artOffset1P;
 
  byte attributes2P;
 
  byte artOffset2P;
 
  word xPosition;
 
};
 
  
struct spriteTableLenghth03{
+
*First word:
  const word length == 3;
+
**High byte is the relative signed top edge position of the sprite from the center of the object.
  spriteTablePiece table[3];
+
**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.
} spriteTable01;
+
*Second and third words:
</pre>
+
**The second word applies to one-player mode; the third applies to two-player mode.
 +
**The relevant word will be added to the object's VRAM offset and then used as the pattern index for that sprite. Like all SEGA Mega Drive 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 (or bit-shifted right by 5).
 +
*Fourth word: This is the relative signed left edge position of the sprite from the center of the object.
  
* The value of <tt>shape</tt> can range from $00 (1x1) to $0F (4x4). $01 is a 1x2 sprite, $02 is a 1x3 sprite, $04 is a 2x1 sprite, and so on.
+
==Dynamic PLCs==
* <tt>attributes1P</tt> and <tt>attributes2P</tt> are bitfields that controls various sprite attributes:
+
Dynamic PLCs (pattern load cues) were hard-coded and for the most part unnoticed in ''[[Sonic the Hedgehog]]''. In ''Sonic 2'', they are more flexible and used for many more objects. The format of DPLCs is simple: the first word is the number of DPLC requests to make, and each successive word (up to the value of the first word) is split up so that the first nybble is the number of tiles to load minus one, and the last three nybbles are the offset (in tiles, i.e. multiples of $20 bytes) of the art to load from the beginning of the object's specified art offset in ROM. Therefore, in order to request ''x'' tiles to be loaded, you need 1+floor(''x''/16) words in the DPLC.
:{|border="1"
 
!Bit||Attribute
 
|-
 
| 3
 
| Flip sprite horizontally
 
|-
 
| 4
 
| Flip sprite vertically
 
|-
 
| 5
 
| Palette line +1
 
|-
 
| 6
 
| Palette line +2
 
|-
 
| 7
 
| Keep sprite in forground
 
|}
 
* <tt>artOffset1P</tt> and <tt>artOffset2P</tt> control the offset from the object's base tile that the sprite should start reading from. For example, if the object's art started a tile $3F0, and <tt>artOffset1P</tt> was $06, then the sprite would start reading its art at $3F6.
 
 
 
<font color="red">Question: Are <tt>xPosition</tt> and <tt>yPosition</tt> offsets from the object's current position?</font>
 
  
====Object Placement====
 
There are six bites in one object definition. The first two bytes are the X position of the object, and the next two bytes are the Y position. 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 [[Sonic Community Hacking Guide/Sonic 2/Level Specific|level specific hacking info]] for the locations of the object lists.
 
  
The 6th byte, the object subtype, is loaded in the 28th byte of the SST of that object (see below).
+
==References==
 +
<references />
  
 
{{SCHGuides}}
 
{{SCHGuides}}
[[Category:Sonic Community Hacking Guide]]
 

Latest revision as of 04:44, 25 March 2020

Sonic Community Hacking Guide
Sonic the Hedgehog 2 (16-bit)
Art
Objects
Levels
Text
Music
RAM
Miscellaneous

Sounds

If you change the "ring" sound effect, all objects using that sound will have the new sound. This may not be desired, however - you may have only wanted the Super Ring powerup to play the new sound. With this list, you can edit the sound effect that an object plays. If you change the sound for the Super Ring power-up, only the Super Ring will have the new sound. Note that you are not changing any sound effects - you are only changing which effect will play.

These notes are for those who don't want see the programming stuff of the objects to change its sounds.

To change the sound, first, take a value from the sound test (Ex: 1-up sound is $18) , add $80 to it and you get $98. This is the way you have to replace sounds (take a value from sound test, add $80 to it, and after that, insert the byte in the offset where you wish change the sound.)

Offset list

The following list is the offset where you will place the new sound. I not will make a list with the values and its respective sounds. Use the trick (explained above) and Sound Test. Of course you can place the objects in any level you want (see Object Placement below), I'm just saying the level the object is used in for a better description.

Level Description Offset
ALL Invincibility power-up $12A81
ALL Shield power-up $12A37
ALL Super Ring $129CD
ALL Lamp Post: $1F191
Casino Night Bumper $1F7F5
ALL Red and Yellow Springs Facing Up $18A69
ALL Red and Yellow Springs Facing Right $18BBF
ALL Red Spring Facing Down $18D63
Chemical Plant Speed booster $223DB
Chemical Plant Blue worm (The sound is repeated 3 Times.) $224EA
Aquatic Ruin Arrow launcher $257B7
Casino Night Slot machine cage $2BE1F
Casino Night Point cage $2BE6B
Hill Top Zip line $21E75
Casino Night Blue Bumper $2C577
Casino Night Green flipper $2B30B
Casino Night Orange flipper $2B3BF
Casino Night Impulse spring facing up $2AE4F
Wing Fortress Propellor (repeat infinitely) $3B3A3

Object Pointer list

See SCHG:Sonic the Hedgehog 2 (16-bit)/Object Editing/Pointers.

Sprite mappings

Reference

Each sprite mapping consists of four words. A contiguous list of sprite mappings preceded with a word-length number of mappings defines one frame for an object. The four words have the following purposes:

  • 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 and third words:
    • The second word applies to one-player mode; the third applies to two-player mode.
    • The relevant word will be added to the object's VRAM offset and then used as the pattern index for that sprite. Like all SEGA Mega Drive 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 (or bit-shifted right by 5).
  • Fourth word: This is the relative signed left edge position of the sprite from the center of the object.

Dynamic PLCs

Dynamic PLCs (pattern load cues) were hard-coded and for the most part unnoticed in Sonic the Hedgehog. In Sonic 2, they are more flexible and used for many more objects. The format of DPLCs is simple: the first word is the number of DPLC requests to make, and each successive word (up to the value of the first word) is split up so that the first nybble is the number of tiles to load minus one, and the last three nybbles are the offset (in tiles, i.e. multiples of $20 bytes) of the art to load from the beginning of the object's specified art offset in ROM. Therefore, in order to request x tiles to be loaded, you need 1+floor(x/16) words in the DPLC.


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