Change Sonic's Starting Location on a Level

Discussion in 'Tutorials Archive' started by c1owd, Mar 19, 2010.

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

    c1owd Previously 'CarrascoZX0' Member

    Joined:
    Dec 13, 2008
    Messages:
    364
    Change Sonic's Starting Location on a Level:


    Guide by: CarrascoZX0


    About: Changing you character's location in Sonic 1.


    Credits: SonicVaan - for teaching me how to do this a long ass time ago... I think? =P


    -Story-


    Yea, well... Out of boredom, I decided to make a tutorial about something related to Sonic Hacking of course. =P


    And, recently I've been seeing posts on Sonic Retro and SSRG (old and recent) about people complaining that they want to change Sonic's starting location in Sonic 1 but they say: "I can't do it", "I suck at Hex editing", etc.


    Even, some people switch into using ESEII because changing Sonic's location was easier. =S


    Now, there's nothing wrong with ESEII by the way. It kicks ass! :p


    But, switching to it because you think you can't or too lazy to do a little tiny bit of Hex editing is sort of sad in my opinion.


    Anyway, I made this tutorial in hopes people will stop complaining and see that Hex editing isn't that hard.


    I tried to make this guide as easy as possible so even an idiot could understand. (But I can only go so far...)


    Also, I'm going to explain why this is this and that is that. I'm not a big fan of copy and paste guides.


    I don't know if this tutorial is considered a "No-Brainer". Because normally I would think it isn't.


    But man, I made this guide way too easy. It now looks like a "No-Brainer" to me. But meh... =P


    Anyway...


    Things That You'll Need:


    1.) For starters, a hack source. (That is yours!)


    2.) A Hex editing program, I will be using Hex Workshop in this tutorial.


    3.) An ASM editing program. I use ConTEXT.


    4.) And the most important one, a brain and some knowledge of hacking! Without that your screwed.


    That's all you'll be needing...


    So, lets begin!


    Step One - Enabling Debug Mode and Getting Sonic's Default Location:


    Okay, before we do anything. Were going to make debug mode activate without doing the debug cheat code on the title screen. This is just to make finding Sonic's location easier and not dying in the beginning of the level... If you changed the first chunk on the level that is. (This is temporary)


    Go to PlayLevel: in your sonic1.asm file. You should see this:



    PlayLevel: ; XREF: ROM:00003246j ...
    move.b #$C,($FFFFF600).w ; set screen mode to $0C (level)


    move.b #3,($FFFFFE12).w ; set lives to 3


    moveq #0,d0


    move.w d0,($FFFFFE20).w ; clear rings


    move.l d0,($FFFFFE22).w ; clear time


    move.l d0,($FFFFFE26).w ; clear score


    move.b d0,($FFFFFE16).w ; clear special stage number


    move.b d0,($FFFFFE57).w ; clear emeralds


    move.l d0,($FFFFFE58).w ; clear emeralds


    move.l d0,($FFFFFE5C).w ; clear emeralds


    move.b d0,($FFFFFE18).w ; clear continues


    move.b #$E0,d0


    bsr.w PlaySound_Special ; fade out music


    rts



    Now to enable debug mode, you have to make it so when you play a level. Debug mode automatically enables itself, just by going to any level.


    So, put this:



    move.b #1,($FFFFFFFA).w ; enable debug mode



    right after this:



    move.b d0,($FFFFFE18).w ; clear continues



    So in the end, the whole PlayLevel: routine should look like this:



    PlayLevel: ; XREF: ROM:00003246j ...
    move.b #$C,($FFFFF600).w ; set screen mode to $0C (level)


    move.b #3,($FFFFFE12).w ; set lives to 3


    moveq #0,d0


    move.w d0,($FFFFFE20).w ; clear rings


    move.l d0,($FFFFFE22).w ; clear time


    move.l d0,($FFFFFE26).w ; clear score


    move.b d0,($FFFFFE16).w ; clear special stage number


    move.b d0,($FFFFFE57).w ; clear emeralds


    move.l d0,($FFFFFE58).w ; clear emeralds


    move.l d0,($FFFFFE5C).w ; clear emeralds


    move.b d0,($FFFFFE18).w ; clear continues


    move.b #1,($FFFFFFFA).w ; enable debug mode ; <---- That where you put it! =P


    move.b #$E0,d0


    bsr.w PlaySound_Special ; fade out music


    rts



    Now, to see if it works and get Sonic's current location in the level. Save you ASM file and build your game. After, open your s1built.bin with any emulator... After you pressing start on the title screen or on any level on the level select. Debug mode should already be enabled when you first start the level. That means you did it right... Congratulations. =P


    Next, were going to be getting Sonic's location in Green Hill Zone - Act 1.


    So without moving Sonic, press start on the title screen as if you were going to play Sonic 1 normally.


    You should see on the HUD, two lines of "numbers and letters". The top line is what we will be needing.


    The top line tells you Sonic's current location in a level in this case Green Hill Zone - Act 1 (GHZ1):


    [​IMG]


    So, make a note of Sonic's current location in the very beginning of the GHZ1.


    It should be: 005003B0 (if you haven't moved Sonic of course...)


    Step Two - Getting Sonic's New Location


    Now, your probably wondering "what the hell is that rock doing there?" Well, I put it there purposely because that's where I'm going to make Sonic start off on GHZ1... On top of that rock!


    So, go to GHZ1 and debug should be enabled. Move Sonic to wherever you want to put him. In my case, on top of that rock. Now, if you see the HUD again. You should see that the "numbers and letters" are different than before.


    [​IMG]


    Take note of the new location! Again, in my case it's: 00A6038C


    Step Three - Changing Sonic's Default Location to the New Location


    Now comes the part many fear most... Hex editing!


    No but seriously, this part isn't hard as lots of people would think. Anyway, open up your Hex editor!


    I will be using Hex Workshop as I mentioned above...


    On your Hex editor, open up the file: sloc_lev.bin. Which should be in your misc folder by the way...


    On your Hex editor you should see something like this:


    [​IMG]


    Also, it is recommended that you set your Hex editor to display 16 bytes (Decimal) in each line! Or if you know Hex already... 00 to 0F


    Anyway this is how the sloc_lev.bin works:


    [​IMG]


    * By the way, about the last line where I put "Unknown". If someone knows what location is that, please tell me. I tried finding it but for some reason I couldn't...


    Anyway, as you can see on the picture above. It basically shows you every single start location in each Act on every level. (Your Welcome!)


    Now, every single start location is 4 bytes! Remember that! You don't want to be changing the location of the wrong level. =P


    Now, to find the default location of GHZ1. Which is the first four bytes by the way. I hope you figured that part out...


    If not, here's a picture to show you what I mean:


    [​IMG]


    Those "numbers and letters" look familiar don't they? It's the same as the first location we took note of! Remember?: 005003B0


    It's just in Hex format: 00 50 03 B0 (In bytes)


    I hope you took note of your new location too... I know I did. =P


    Anyway, my new location was on top of that rock right? And when I jumped on top of that rock it gave me a new location didn't it?


    Which was: 00A6038C


    Now it's time to put in that new location! So first of 00A6038C has to be in Hex format (bytes). So it should be 00 A6 03 8C


    So... It's obvious isn't it? replace: 00 50 03 B0


    To your new location, in my case: 00 A6 03 8C


    In the end it should look like this:


    [​IMG]


    After putting in your new location, save the file and now you can close your Hex editor... (See?! Was that so hard?)


    Step Four - Testing


    Finally, it's time to see if all this work paid off... So after saving your file on your Hex editor. Build your game and test your ROM.


    If you did it correctly. (Which you should have, since this is the simplest guide with pictures out there!)


    On GHZ1, Sonic should be starting on the new location. In my case on top of the rock and...


    [​IMG]


    Yay! Success! It worked! You changed Sonic's starting location in GHZ1! Congratulations.


    Now, comes the optional part...


    Final Step - Disabling Debug Mode From Activating Automatically


    This should be obvious to do... But I'll tell you anyway. =P


    Open your sonic1.asm and go back to your PlayLevel: routine.



    PlayLevel: ; XREF: ROM:00003246j ...
    move.b #$C,($FFFFF600).w ; set screen mode to $0C (level)


    move.b #3,($FFFFFE12).w ; set lives to 3


    moveq #0,d0


    move.w d0,($FFFFFE20).w ; clear rings


    move.l d0,($FFFFFE22).w ; clear time


    move.l d0,($FFFFFE26).w ; clear score


    move.b d0,($FFFFFE16).w ; clear special stage number


    move.b d0,($FFFFFE57).w ; clear emeralds


    move.l d0,($FFFFFE58).w ; clear emeralds


    move.l d0,($FFFFFE5C).w ; clear emeralds


    move.b d0,($FFFFFE18).w ; clear continues


    move.b #1,($FFFFFFFA).w ; enable debug mode ; <---- That where you put it! =P


    move.b #$E0,d0


    bsr.w PlaySound_Special ; fade out music


    rts



    Now, I recommend commenting out the line instead of completely deleting it. You might need it again.


    So just put a ";" here:



    PlayLevel: ; XREF: ROM:00003246j ...
    move.b #$C,($FFFFF600).w ; set screen mode to $0C (level)


    move.b #3,($FFFFFE12).w ; set lives to 3


    moveq #0,d0


    move.w d0,($FFFFFE20).w ; clear rings


    move.l d0,($FFFFFE22).w ; clear time


    move.l d0,($FFFFFE26).w ; clear score


    move.b d0,($FFFFFE16).w ; clear special stage number


    move.b d0,($FFFFFE57).w ; clear emeralds


    move.l d0,($FFFFFE58).w ; clear emeralds


    move.l d0,($FFFFFE5C).w ; clear emeralds


    move.b d0,($FFFFFE18).w ; clear continues


    ; <-- move.b #1,($FFFFFFFA).w ; enable debug mode


    move.b #$E0,d0


    bsr.w PlaySound_Special ; fade out music


    rts



    And then save your sonic1.asm and build it. When entering any level, debug mode should not active automatically. And there you have it.


    So, that pretty much sums up my tutorial. I hope you newbies learned something new today... So, have fun! =P
     
    Last edited by a moderator: May 7, 2011
    Nat The Porcupine likes this.
  2. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    You can even make it easier to change the starting locations.


    Download drx's disassembly and open it, then find the equivalent for the start location array in that one, you'll understand when you'll see it. ;)
     
  3. c1owd

    c1owd Previously 'CarrascoZX0' Member

    Joined:
    Dec 13, 2008
    Messages:
    364
    Haha, that works too. =P


    But...

    I'm pretty sure newbies won't understand that if there new to this... XD


    Maybe though, who knows...
     
    Last edited by a moderator: Mar 19, 2010
  4. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    You need to keep in mind two things:


    - How many people would come up with the idea to do that?


    - Even though it's in ASM format, you still need to know how to edit this (i.e. using debug mode, finding point where you need to type in your stuff etc.)


    So basically, it doesn't matter what you do.


    On topic: Wow... that was one of the well explained tutorials I've EVER seen. No lie. The only thing I need to criticize is the thing with enabling debug by default, because debug mode enabling on the normal isn't that hard and it would be even smarter to go to "Title_ClrObjRam2" and simply look at this:



    --> move.b #0,($FFFFFFFA).w ; disable debug mode
    move.w #$178,($FFFFF614).w ; run title screen for $178 frames


    lea ($FFFFD080).w,a1


    moveq #0,d0


    move.w #7,d1


    Title_ClrObjRam2:


    move.l d0,(a1)+


    dbf d1,Title_ClrObjRam2



    Just change that line to move.b #1,($FFFFFFFA).w and you already have what you want. =P
     
  5. Qjimbo

    Qjimbo Well-Known Member Member

    Joined:
    Feb 27, 2008
    Messages:
    850
    Location:
    Vancouver, BC
    Thanks for this Carrasco, I'll be sure to put it on the site for the revamp, very useful.
     
  6. c1owd

    c1owd Previously 'CarrascoZX0' Member

    Joined:
    Dec 13, 2008
    Messages:
    364
    Haha, well... That's how I wanted it. =P


    I might make more... Who knows... I just need a good idea. lol

    I somehow knew you were going to say something like this. =P


    But yeah, that works too.

    Oh, yea sure. I'm just happy to help. ;)
     
  7. EMK-20218

    EMK-20218 The Fuss Maker Exiled

    Joined:
    Aug 8, 2008
    Messages:
    1,067
    Location:
    Jardim Capelinha, São Paulo
    A guide for this?


    Try to make me be serious when I see that. CarrascoZX0, usually is so much easy to change this in pure hex!!


    But, this guide could be interesting to tell people in way figure how exactly this works.
     
  8. Spanner

    Spanner The Tool Member

    Joined:
    Aug 9, 2007
    Messages:
    2,570
    Taken from Esrael's Sonic 1 REV01 disassembly with a label modification, replace StartLocArray with the following:



    StartLocArray: ; Offset_0x00611E:
    dc.l $005003B0, $005000FC, $005003B0, $008000A8 ; GHz


    dc.l $0060006C, $005000EC, $005002EC, $0B800000 ; Lz


    dc.l $00300266, $00300266, $00300166, $008000A8 ; Mz


    dc.l $004002CC, $0040014C, $0040014C, $008000A8 ; SLz


    dc.l $003003BD, $003001BD, $003000EC, $008000A8 ; SYz


    dc.l $0030048C, $0030074C, $214005AC, $008000A8 ; SBz


    dc.l $0620016B, $0EE0016C, $008000A8, $008000A8 ; GHz Ending



    This makes things easier since you don't need to use a hex editor.
     
    Last edited by a moderator: Mar 23, 2010
  9. amphobius

    amphobius spreader of the pink text Member

    Joined:
    Feb 24, 2008
    Messages:
    970
    Location:
    United Kingdom
    I've found that a lazier, albeit an easier way to get the locations is within SonED2 itself.


    And that location is the location of any object that's placable.


    To be precise, I place a Null Object (00) where I want Sonic / the playable character in the game to start off at, though with a 8x gap between the floor and the object. I use the Object Location (which is found in all that data on the top left--it's actually quite handy). I've never used Debug once to get my starting locations for Thrash, S1 or S2 engine.
     
  10. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    I actually agree with DalekSam with that method and did infact work with it too, though I would like to point out that "how hard is it to simply use a Hexadecimal editor?" Don't get me wrong I can see some of the benefits of having the data in an unassembled format, but even so, there are benefits to working with the Hex values via a Hex editor; such as getting used to using it, this can improve your chances of knowledge and if you were to say for example, disassemble a full rom, then having a Hexadecimal editor can be very useful and you'd be very pleased with the fact that you've had experience with using one.
     
  11. c1owd

    c1owd Previously 'CarrascoZX0' Member

    Joined:
    Dec 13, 2008
    Messages:
    364
    Okay, I have no idea what you were just trying to say dude. :)

    That was the main point for this guide. =P

    Alright look guys, I know there's hundreds of easier ways to change Sonic's starting location. But basically in this tutorial, I just tried to show something easy to do with Hex so that newbies won't give up just because they think they can't do any Hex editing. In other words, I was trying to do basically what Markey just said.


    But, if you guys want to post more ways of changing Sonic's starting location... Shit, be my guest. =P
     
    Last edited by a moderator: Apr 29, 2011
  12. EMK-20218

    EMK-20218 The Fuss Maker Exiled

    Joined:
    Aug 8, 2008
    Messages:
    1,067
    Location:
    Jardim Capelinha, São Paulo
    Yeah, I just mean that this guide was a bit unecessary. But looking attempted for the details, this may be useful for the newbie people.
     
  13. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
Thread Status:
Not open for further replies.