Adding new Characters to Sonic 2

Discussion in 'Tutorials Archive' started by Niko, Jun 4, 2015.

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

    Niko All's well that ends well, right? Member

    Joined:
    Mar 1, 2014
    Messages:
    245
    Location:
    $C800
    This is for Sonic 2's Git-hub Disassembly. 

    Personally, I just swap the art upon character selection, so if you want to use the official Knuckles, this won't work. You'd need to make a custom one with Sonic's mapping for this idea.
    I don't like Shadow all that much, to be honest. 

    I personally don't have any intention to make or extract Shadow art, unless it's requested with good reason.
    (And, if I ever do, it would be this one.)

    http://www.angelfire.com/games6/horsefacekilla/Sonic_2___Shadow_ver_1_1.JPG

    I haven't tested this method for a long time, and this is re-written long after I did this for Sonic 2. 


    I'm sure that if you're looking at this, you're just one of those poops that looks for copy and pastes to try, so I won't explain very much (other than comments I add into the ASM).
    And, if you are like that, I'm not helping you with the options screen part. That part is as obvious as heck. 

    (Because this is a very obvious series of codes, and there are better ones. I'm just making this one for the public.)
    ((Can someone show me where this "ASM box" is? It's not auto-appearing when I paste, like in other posts.))

    Following ​this tutorial for adding "metalsonic" with Shadow, or whatever you want, but applying the changes needed for Sonic 2. 

    I assume you know how to make more options in the Character select menu.
    (As if you've seen something like this..?)

    TextOptScr_Shadow: menutxt " SHADOW "

    Let's begin:

    Use this to load Shadow's art, put it just under Sonic's (or Tails's).

    This will make it so the game knows where to find your custom artwork.

    align $20
    ArtUnc_Shadow: BINCLUDE art\uncompressed\Shadow's Art.bin; Load Shadow's art.
    even
    To make Shadow load when you choose the third player option, replace InitPlayers_TailsAlone with this:

    This expands the options so that if you choose option 3, the game will PROPERLY load Sonic, rather than the automated (and glitched up) "1" that turns out to be Sonic with bad physics. 

    InitPlayers_TailsAlone:

    subq.w #2,d0
    bne.s InitPlayers_Shadew ; Choose Shadow if this isn't a Tails alone game
    move.b #ObjID_Tails,(MainCharacter+id).w ; load Obj02 Tails object at $FFFFB000
    move.b #ObjID_SpindashDust,(Tails_Dust+id).w ; load Obj08 Tails' spindash dust/splash object at $FFFFD100
    addi_.w #4,(MainCharacter+y_pos).w
    rts
    InitPlayers_Shadew:

    move.b #ObjID_Sonic,(MainCharacter+id).w ; load Obj01 Sonic object at $FFFFB000
    move.b #ObjID_SpindashDust,(Sonic_Dust+id).w ; load Obj08 Sonic's spindash dust/splash object at $FFFFD100
    ; Yes, the code to remove Tails in some Zones isn't here. It's no use!
    ; Remove lines below to get rid of Tails
    move.b #ObjID_Tails,(Sidekick+id).w ; load Obj02 Tails object at $FFFFB040
    move.w (MainCharacter+x_pos).w,(Sidekick+x_pos).w
    move.w (MainCharacter+y_pos).w,(Sidekick+y_pos).w
    subi.w #$20,(Sidekick+x_pos).w
    addi_.w #4,(Sidekick+y_pos).w
    move.b #ObjID_SpindashDust,(Tails_Dust+id).w ; load Obj08 Tails' spindash dust/splash object at $FFFFD140
    ; End of loading Tails.
    addi_.w #4,(MainCharacter+y_pos).w
    rts
    ; End of function InitPlayers

    Now, you need to make the game use Shadow's art if you chose him. (And other mappings would be in this step, if you choose to. I won't cover that.)

    Go to "SPLC_ReadEntry"​

    Use this code for "SPLC_ReadEntry:" to right before "return_1B89A:"

    This will make it so that when Shadow is chosen, according to the code above, Shadow's art will load, as apposed to Sonic's art. 

    SPLC_ReadEntry:
    moveq #0,d1
    move.w (a2)+,d1
    move.w d1,d3
    lsr.w #8,d3
    andi.w #$F0,d3
    addi.w #$10,d3
    andi.w #$FFF,d1
    lsl.l #5,d1
    cmpi.b #$02,

    AltArt: ;Start Alternate Character Art Loader
    move.w (Player_mode).w,d0
    bne.s ShadowArtLoad ; Load Shadows's art if this isn't a Sonic and Tails game
    addi.l #ArtUnc_Sonic,d1 ; Load Sonic's art if this is a Sonic and Tails game
    bra.s ContSPLCLoad ; branch to rest of code
    ShadowArtLoad:
    addi.l #ArtUnc_Shadow,d1 ; Load Shadow's art if this is a Sonic and Tails game

    ContSPLCLoad: ;End Alternate Character Art Loader
    move.w d4,d2
    add.w d3,d4
    add.w d3,d4
    jsr (QueueDMATransfer).l
    dbf d5,SPLC_ReadEntry ; repeat for number of entriesAnd, that's it!
    But, BE SURE TO READ THE TOP, if you didn't already. 
    (Any feedback is really appreciated.) 
     
    Last edited by a moderator: Jun 4, 2015
  2. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    I appreciate that your trying to support the community, but that particular guide you based this one off of is not a good one to work with. I should know, I used it, then later ditched it for a much better method. While an art swap does make it look like your playing as another character, it doesn't actually have a separate object running this character; as a result, the only way to make new moves and physics changes specific to each character is to add checks, which is inefficient and slowly clutters up Obj01.

    The better solution is to copy all of Obj01s' code, and fix all the labels. From there, you have an entire new object to work with, allowing you to add new moves and make changes with ease, all the while having a new set of art, mappings, animations, and more to work with. I've done this in Sonic 1 and Sonic 2, and once you get around the amount of time it takes to change every defined label in the copied object code, adding new characters becomes incredibly easy. The only possible issue this could have in relation to this method is taking up a little more space, but these days, with SD cards that are smaller then your thumb that can hold the entire Genesis library, that's become irrelevant. This method sacrifices a little speed, as well as edit-ability, making it inefficient in the long run (especially if you want to add more then one character).

    Also, never just skip the explanation and let people copy/paste code. Good explanations and numerous comments were what allowed me to code my own ASM to begin with; without those guides, I might have gotten bored of hacking and left by now. Besides, making guides with the intent to make it easy copy/paste is never a good idea...

    EDIT: Woah, that's a wall of text 0.o. Sorry to go on such a long tangent, I just have a lot of experience doing this...
     
    Last edited by a moderator: Jun 4, 2015
  3. Niko

    Niko All's well that ends well, right? Member

    Joined:
    Mar 1, 2014
    Messages:
    245
    Location:
    $C800
    I made plenty of comments within the actual ASM as I modified it. 
    And, yes, that is very ideal, but this is something far less advanced, for those beginners. 
     
  4. Niko

    Niko All's well that ends well, right? Member

    Joined:
    Mar 1, 2014
    Messages:
    245
    Location:
    $C800
    I'll add explanations now, for those who are trying to learn this. 
     
  5. SuperEgg

    SuperEgg I'm a guy that knows that you know that I know Member

    Joined:
    Oct 17, 2009
    Messages:
    Location:
    THE BEST GOD DAMN STATE OF TEXAS
    Honestly, this tutorial is far from ideal, if anything it perpetuates the problem. Ideally speaking, you'd want to teach beginners the basics of object programming, or how the game reads objects. Adding all of these checks is a headache and doesn't truly deliver what the tutorial promised, which is the addition of a new character. Though theoritically speaking, you could add in characters in such a manner as the old tutorials suggest, it a considerable huge amount of work you'd have to do in order to make anything outside old sprite change to happen.
     
Thread Status:
Not open for further replies.