how to create a "hub zone" in sonic 2?

Discussion in 'Discussion and Q&A Archive' started by Olivier, Jul 31, 2013.

Thread Status:
Not open for further replies.
  1. Olivier

    Olivier Newcomer In Limbo

    Joined:
    Mar 31, 2013
    Messages:
    20
    hi everybody, I'd create a hub zone must jump into something to be teleported to a level. I already created the level, but I do not know how to create objects that teleport through the levels ... How would you know?
     
  2. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    I never tried to do that, and I don't have a disassembly right here, but here's the obvious suggestion: look at how Scrap Brain Zone 2 does it and see if you can replicate it. I guess it's as simple as checking Sonic's X and/or Y position, updating the zone and act bytes in RAM, and issuing a level restart event.
     
    Last edited by a moderator: Jul 31, 2013
  3. Olivier

    Olivier Newcomer In Limbo

    Joined:
    Mar 31, 2013
    Messages:
    20
    The problem is that there is nothing at the end, there is no object ...
     
  4. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    There is no object there. Here, I retrieved a disassembly:

    Resize_SBZ3:
    cmpi.w #$D00,($FFFFF700).w
    bcs.s locret_6F8C
    cmpi.w #$18,($FFFFD00C).w ; has Sonic reached the top of the level?
    bcc.s locret_6F8C ; if not, branch
    clr.b ($FFFFFE30).w
    move.w #1,($FFFFFE02).w ; restart level
    move.w #$502,($FFFFFE10).w ; set level number to 0502 (FZ)
    move.b #1,($FFFFF7C8).w ; freeze SonicAs I expected, there is a check, a level set, and a restart event.

    Remember: FFFFD008 is the X position, and FFFFD00C is the Y position.
     
    Last edited by a moderator: Jul 31, 2013
  5. Olivier

    Olivier Newcomer In Limbo

    Joined:
    Mar 31, 2013
    Messages:
    20
    thank you but I would do it several times and is or what I should put these lines(and I want it in Sonic 2)?
     
    Last edited by a moderator: Jul 31, 2013
  6. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    This is the last advice I give you. cmpi.w is used to compare a word value with a RAM address (or a register, but you don't want to do that now); the following bxx.x instruction is used to jump somewhere else in the code, according to the result of the comparison (greater than, less than, equal to, and so on, look them up).


    Once you know the X and Y positions, you can set up a "map" of the areas that should warp you to another level, and set up the code accordingly. To say it with pseudocode, something like:

    Code:
    IF X > 10 AND X < 20 AND Y > 30 AND Y < 40 THEN CHANGE LEVEL
    No more advice from here. Good luck.
     
    Last edited by a moderator: Jul 31, 2013
  7. Irixion

    Irixion Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    670
    Location:
    Ontario, Canada
    I don't think this guy understands what you're even saying... In Sonic 2, I'm pretty sure in Wing Fortress Zone--after the boss, the game checks your X/Y positions before taking over for the cutscene. Go look in the level events, that's what you need to tweak to your liking.
     
  8. KingofHarts

    KingofHarts Well-Known Member Member

    Joined:
    Sep 30, 2012
    Messages:
    54
    Location:
    Chi-Town
    If you want portal objects instead of level events like SBZ2 or WFZ as mentioned above... study how the objects are created.

    You only need 1 portal object, with multiple subtypes... one for each level you wanna be taken to. You'd set the collision_flags appropriately so that when Sonic collides with it, its routine will advance +2.

    Then the next routine for the object could be removing the Sonic object, adding a teleport effect, followed by the level being set based on the object's subtype, and finally the aforementioned LevelRestart event. There is a scrapped effect object in Sonic 1 that does something like this. Give it a look.

    This, along with Nineko and Irixion's mentions of the level events that occur without objects... are all you should really need. You can go one route or the other.

    EDIT: Just realized that I necro-posted for the sake of answering a question for someone in limbo as it is. My apologies guys, wasn't paying much attention.
     
    Last edited by a moderator: Sep 8, 2013
  9. Dark Lips

    Dark Lips Well-Known Member Member

    Joined:
    Nov 14, 2008
    Messages:
    293
    Location:
    Wolverhampton UK
    I think there is the remains of the unused sonic 1 big ring object - its not too hard to rig that to work... at least i think its sonic 2... could be the nick arcade or the beta version - superegg should be able to point you in the right direction about this.
     
  10. KingofHarts

    KingofHarts Well-Known Member Member

    Joined:
    Sep 30, 2012
    Messages:
    54
    Location:
    Chi-Town
    That'd be better than the object I suggested, actually... I forgot that was there...

    Set aside the fact that unlike the S1 object, there isn't that delay with Sonic disappearing with the Giant Ring...
    It's also a Sonic 2 object, so no "code porting" needed
     
Thread Status:
Not open for further replies.