don't click here

Proof of Concept: Sonic 2 Lockon

Discussion in 'Engineering & Reverse Engineering' started by MainMemory, Jul 31, 2012.

  1. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,625
    206
    43
    SonLVL
    This zip file contains the following:
    • A Sonic 2 ROM, with all level-specific code and data removed, and modifications to load level data from data added to the end of the ROM (s2lockon.bin)
    • A prebuilt level file for Emerald Hill Zone Act 1 (EHZ1.bin)
    • A binary of s2lockon.bin+EHZ1.bin (s2lev.bin)
    • All code and data needed to build EHZ level (EHZ1.asm et al)

    The format is documented at the bottom of s2.constants.asm in the LevelHeader struct, and at the top of EHZ1.asm. All offsets in the header are unsigned (no backwards references).
    For those of you who would want to make levels with this, all your object code will have to use position-independent code. That means all data accesses within the level must be pc-relative, all branches within the level must be short or word-sized, all references to code or data in the base ROM must be longword addresses, and you must use the proper "rel" or "abs" macro for PLCs and debug object list entries.

    I know a single-level demo that doesn't have many apparent changes from stock Sonic 2 isn't very exciting, but I didn't feel like going to the trouble of extracting the necessary code and data for another level, and converting its object layout to new IDs.
     
  2. RetroKoH

    RetroKoH

    Member
    1,661
    17
    18
    Project Sonic 8x16
    I think this is a MUCH bigger deal than people are going to make it out to be. Do you think that one could use something like this to say... lock all 3 (or 4 [​IMG]) Sonic trilogy games together into one?

    Or perhaps making it easier for people to have custom levels into their ROMS, in particular, people who either don't know how to hack, or have difficulty hacking levels into games...
     
  3. Cinossu

    Cinossu

    Administrator
    2,830
    16
    18
    London, UK
    Sonic the Hedgehog Extended Edition
    Lock-on is far easier than people make it out to be; it's just reading from addresses higher than the original ROM's filesize for data. Even checking to see if it's locked on is that easy; check for a set of values that aren't blank at 0x??????? and you're done. The fun part is making it all mean something, but again the logistics of it aren't hard if you put some thought into it.

    While unreleased, I know of many "proof of concept" lock-ons, including my own. :P (Why do you think there is no level select/debug stuff in s1sage2010 or omochao edition? All self-contained in a debug lock-on addition.) Welcome to the club, MainMemory.
     
  4. Jayextee

    Jayextee

    Monochrome Cat Game Guy™ Member
    3,219
    5
    18
    Atro City
    I DONE MAKED GAMES.
    If this is eventually going to lead to the point where one can design a full expansion level-set without ever touching the ASM or anything other than a level editor (you know, like a Doom .wad or something), then I'll be watching this like a fucking hawk. Nice. :)
     
  5. jasonchrist

    jasonchrist

    Give Us A Wank Misfit
    1,893
    0
    0
    Sonic Classic Hybrid Project
    This just might be what I need for the Hybrid Project.
     
  6. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,625
    206
    43
    SonLVL
    This isn't even the first released hack with support for lock-on: Blue Sphere Plus keeps S&K's original lock-on mode, and also supports custom map files.
    Not likely. Even the simplest level still needs background scrolling, the initial camera manager, and code for any level-specific objects.
     
  7. Cinossu

    Cinossu

    Administrator
    2,830
    16
    18
    London, UK
    Sonic the Hedgehog Extended Edition
    Oh, I know, just saying it isn't as uncommon and difficult as people probably think it is.
     
  8. RetroKoH

    RetroKoH

    Member
    1,661
    17
    18
    Project Sonic 8x16
    Speaking of this, and I apologize if you are sick of answering this question, is there any update on Retro Channel? I've been dying to try to beat my old records on this hack, and set new ones too...
     
  9. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,625
    206
    43
    SonLVL
    In news that is actually relevant to the topic being discussed, I have uploaded a new version which uses position-independent code. This means that you can add EHZ1.bin to s2lockon.bin multiple times in order to play it back to back.

    Next I guess I'm going to work on something that automatically generates the level asm file with the necessary data?
     
  10. Cinossu

    Cinossu

    Administrator
    2,830
    16
    18
    London, UK
    Sonic the Hedgehog Extended Edition
    Retro Channel is being worked on and will be ready when it's ready; [email protected] will get a much-needed update at the same time, however as for compatibility with the older version.. ehh, we'll see.

    Nicely done; are there no absolute jumps for any of the code being used at all, such as stock functions? I can't take a look at the code right now as I'm at work. :P
     
  11. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,625
    206
    43
    SonLVL
    Well yes, references to common functions in the base ROM are using absolute addresses, otherwise you'd have to include copies of them in every level.