don't click here

Sonic 2 Split Collision Array

Discussion in 'Engineering & Reverse Engineering' started by Ultima, May 10, 2004.

  1. Ultima

    Ultima

    Games Publisher Tech Member
    2,398
    1
    18
    London, England
    Publishing mobile games!
    After a few days' work, I've managed to make a version of Sonic 2 with a split Collision Array. This means that every act in the game (0000, 0001, 0100, 0101 etc) can have a different set of 16x16 collision blocks to reference to, rather than the whole game sharing one.

    The advantages of this are as follows;

    -When making a level from scratch (using your own art), you're not limited to the default 255 collision blocks, meaning the shape of your tiles isn't limited anywhere near so much.

    -If you need to edit a few collision blocks, it won't change those blocks for every other level in the game (hence it won't screw up collisions for every level)

    The disadvantage is that the collision data is actually quite huge (weighing in at $44000 bytes), and thus, the ROM must be expanded to 2 MB. This isn't really a problem at all, except that SonED has a bug in it that causes it to delete any data after where it stops writing, meaning that if you save with SonED, the Collision data gets wiped. Until Stealth fixes that, it is possible to simply copy the data onto the end of the SonED-saved ROM, making sure that it all lines up properly. If you can do that, then w00t.

    ====

    Now, I'll explain how it is done:

    1. Go to the end of the ROM, and add $B9800 bytes (if you're working on a clean ROM... if not, just expand it so that the size is $1B9800).

    2. Go to 0x78, and replace with "001B 9800".

    3. Go to 0x1EA0C, 0x1EAB4 and 0x1EB32 and replace with "2478 FF9C 4E71".

    4. Go to 0x1E82C, 0x1E8D4, 0x1E964 and 0x1EAF8 and replace with "2478 FF98 4E71".

    5. Go to 0x1EAF2 and 0x1EB2C and replace with "2278 FF98 4E71".

    6. Download the Collision Array and data required from here.

    7. Open the extracted file in your Hex Editor, and copy the whole lot onto the end of your Sonic 2 ROM (the data must be placed at 0x1B9800). Your ROM's size should now be $200000.

    8. Test the ROM - If the collisions work correctly then well done! You've done everything correctly.

    Note: If you edit your ROM using SonED in future, you'll just have to copy the collision stuff to 0x1B9800 in your ROM (you'll have to expand it first).

    ====

    Finally, I'll explain everything:

    1B983A: Pointer to EHZ1 Collision Array
    1B9842: Pointer to EHZ2 Collision Array
    1B985A: Pointer to 0100 Collision Array
    1B9862: Pointer to 0101 Collision Array
    1B987A: Pointer to 0200 Collision Array
    1B9882: Pointer to 0201 Collision Array
    1B989A: Pointer to 0300 Collision Array
    1B98A2: Pointer to 0301 Collision Array
    1B98BA: Pointer to MTZ1 Collision Array
    1B98C2: Pointer to MTZ2 Collision Array
    1B98DA: Pointer to MTZ3 Collision Array
    1B98E2: Pointer to 0501 Collision Array
    1B98FA: Pointer to WFZ Collision Array
    1B9902: Pointer to 0601 Collision Array
    1B991A: Pointer to HTZ1 Collision Array
    1B9922: Pointer to HTZ2 Collision Array
    1B993A: Pointer to HPZ1 Collision Array
    1B9942: Pointer to HPZ2 Collision Array
    1B995A: Pointer to 0900 Collision Array
    1B9962: Pointer to 0901 Collision Array
    1B997A: Pointer to OOZ1 Collision Array
    1B9982: Pointer to OOZ2 Collision Array
    1B999A: Pointer to MCZ1 Collision Array
    1B99A2: Pointer to MCZ2 Collision Array
    1B99BA: Pointer to CNZ1 Collision Array
    1B99C2: Pointer to CNZ2 Collision Array
    1B99DA: Pointer to CPZ1 Collision Array
    1B99E2: Pointer to CPZ2 Collision Array
    1B99FA: Pointer to DEZ Collision Array
    1B9A02: Pointer to 0E01 Collision Array
    1B9A1A: Pointer to ARZ1 Collision Array
    1B9A22: Pointer to ARZ2 Collision Array
    1B9A3A: Pointer to SCZ Collision Array
    1B9A42: Pointer to 1001 Collision Array

    1BC000: EHZ1 Collision Array
    1BE000: EHZ2 Collision Array
    1C0000: 0100 Collision Array
    1C2000: 0101 Collision Array
    1C4000: 0200 Collision Array
    1C6000: 0201 Collision Array
    1C8000: 0300 Collision Array
    1CA000: 0301 Collision Array
    1CC000: MTZ1 Collision Array
    1CE000: MTZ2 Collision Array
    1D0000: MTZ3 Collision Array
    1D2000: 0501 Collision Array
    1D4000: WFZ Collision Array
    1D6000: 0601 Collision Array
    1D8000: HTZ1 Collision Array
    1DA000: HTZ2 Collision Array
    1DC000: HPZ1 Collision Array
    1DE000: HPZ2 Collision Array
    1E0000: 0900 Collision Array
    1E2000: 0901 Collision Array
    1E4000: OOZ1 Collision Array
    1E6000: OOZ2 Collision Array
    1E8000: MCZ1 Collision Array
    1EA000: MCZ2 Collision Array
    1EC000: CNZ1 Collision Array
    1EE000: CNZ2 Collision Array
    1F0000: CPZ1 Collision Array
    1F2000: CPZ2 Collision Array
    1F4000: DEZ Collision Array
    1F6000: 0E01 Collision Array
    1F8000: ARZ1 Collision Array
    1FA000: ARZ2 Collision Array
    1FC000: SCZ Collision Array
    1FE000: 1001 Collision Array

    42E50-44E50: Unused (free space if you wanna use it)

    ====

    The Collision Arrays use the original format, which is explained in Nemesis' guide, or if you're lazy, I have a VERY simple editor for them here. The editor will edit the Collision Array at 42E50, so you can just copy it into the right lace after you've finished editing. I am updating this app later to support (and possibly have an option of applying) this split Collision Array system, and to have more general use (such as editing the other aspects of Collisions in Sonic 2).

    Finally, for those who don't wanna bother doing all this, or wanna just see it and mess with it a bit, there's a ROM available here.