Basic Questions and Answers Thread

Discussion in 'Discussion & Q&A' started by Malevolence, Jul 7, 2009.

  1. Prilix

    Prilix A normal romhacker In Limbo

    Joined:
    Sep 19, 2017
    Messages:
    20
    Location:
    Argentina
    I saw some romhack with the super peelout, then how I can add to my hivebrain disassembly???
     
  2. Iso Kilo

    Iso Kilo Sonic 1 Beta Researcher Member

    Joined:
    Oct 9, 2017
    Messages:
    203
    Location:
    Small Town in BC, Canada
    Well, considering you're new, I'll give you the quick and painless answer; The free assets thread has a disassemby known as 'Sonic CD Art Test' and if I recall, it keeps the peelout in a separate file. Just drag the file into your disam, go into sonic1.asm > Obj01_MdNormal, and type
    Code:
    bsr.w        Sonic_Peelout
    And put the routine you're trying to branch to under 'End of function Sonic_Loops' then include your new file. In the end it should look like;
    Code:
    ...
    ; End of function Sonic_Loops
    Sonic_Peelout:
              include   "peelout.asm"
    ...
    Adding the dash animation is up to you though, I'm not holding your hand forever.
    So enjoy your unoriginal peelout. Personally, I would just make my own code. Even then, I wouldn't bother with a peelout, it's so overused and it's pretty much a worse spindash. The peelout was used in Sonic CD to help the player time travel. Using it for any other reason is kind of pointless, to be honest. But it is your hack, so you have the right to be generic if you'd like.
     
  3. Prilix

    Prilix A normal romhacker In Limbo

    Joined:
    Sep 19, 2017
    Messages:
    20
    Location:
    Argentina
    Not I thought that would run easily.o_O
    but I had to change the value of the playsound, why it crashes.

    D2 > BE

    Code:
            move.w    #$BE,d0
            jsr        (PlaySound_Special).l ; Play peelout charge sound
    be wanting to put the sprites.
     
  4. Prilix

    Prilix A normal romhacker In Limbo

    Joined:
    Sep 19, 2017
    Messages:
    20
    Location:
    Argentina
    I need help, not be as step,so give me a hand??

    fixed up.
     

    Attached Files:

    • 00.png
      00.png
      File size:
      30.9 KB
      Views:
      177
    Last edited: Jul 22, 2018
  5. Prilix

    Prilix A normal romhacker In Limbo

    Joined:
    Sep 19, 2017
    Messages:
    20
    Location:
    Argentina
    ¿As I edit the order of the phases in S1 hivebrain??

    Fixed up.
     
    Last edited: Jul 30, 2018
  6. Pacca

    Pacca Why succeed when you can profit off of failure? Member

    Joined:
    Jul 5, 2014
    Messages:
    1,149
    Location:
    Triton (Moon)
    I've spent all evening tracking down an odd hardware specific freeze, as well as other odd side effects. It doesn't bring up a crash handler, and the problem doesn't even occur in pretty much every emulator I've tested. I tracked it down to the following bit of code, which handles SRAM:

    Code:
        move.b    #1,($A130F1).l        ; enable SRAM (required)
        lea    ($200001 + $42).l,a2        ; base of SRAM + Where the data I want is stored
    
    It functions exactly as I'd expect it to in Regen and Kega, but consistently messes up my Model 2, and I can't see why. It's not an issue with code later down the line or just before either; this is the start of a subroutine. Putting an rts right above the move.b fixes the problem (at the cost of making the subroutine not work, of course), and none of the code after the lea ever runs before the freeze occurs.

    There may be more to it then I can see; I'm willing to share more in private to figure this out; the feature this is related to is a secret for now, so I'd rather not do it publicly.
     
    Last edited: Jul 24, 2018
  7. AURORA☆FIELDS

    AURORA☆FIELDS the cute one here Member

    Joined:
    Oct 7, 2011
    Messages:
    715
    Location:
    Where I should've been a long time ago
    What is the code right after these 2 instructions. Also, where is this code located? Make sure it is nowhere after $200000!
     
    Pokepunch, MarkeyJester and Pacca like this.
  8. Pacca

    Pacca Why succeed when you can profit off of failure? Member

    Joined:
    Jul 5, 2014
    Messages:
    1,149
    Location:
    Triton (Moon)
    Oh! it compiled to $399AEE in the rom, which obviously is after $200000! I shuffled it up to the front of the rom, and it works like a charm now. Thanks for the tip, I never would have figured it out myself.
     
    AURORA☆FIELDS likes this.
  9. Greenknight9000

    Greenknight9000 Well-Known Member Member

    Joined:
    Apr 30, 2014
    Messages:
    53
    Hey guys it's me again
    I'm still struggling with adding Super Sonic in Sonic 1, I've looked all over the internet to see if there was an alternative tutorial that would be easier to follow, but to no avail, forcing me to ask for help once again.
    I'm here to ask how to add Super Sonic - not the sprites. (just the powers, triggers such as all 6 emeralds, Super Glow, etc.)
    I'm extremely self-conscious about asking for help, but any help is greatly appreciated.
     
  10. DanielHall

    DanielHall Well-Known Member Member

    Joined:
    Jan 18, 2010
    Messages:
    860
    Location:
    North Wales
    Just remember that if you wanna access any code or data that isn't SRAM, above $200000, you have to write 0 to $A130F1 first.

    The check itself is at the end of Sonic_Jumpheight, to Sonic_CheckgoSuper, while the super logic itself is Sonic_Super, called from the Sonic object (currently don't have a disasm to hand). Copy that code, convert the relevant ram addresses to Sonic 1's using the SCHG's RAM editing guide, and tell us how you got on. There are a few things you'll need to change, IIRC Sonic 1 uses a random RAM address for invincibility while Sonic 2 uses an SST.
     
  11. Greenknight9000

    Greenknight9000 Well-Known Member Member

    Joined:
    Apr 30, 2014
    Messages:
    53
    I already have the main Super Sonic code (Hopefully)
    I don't really have experience in RAM editing, should I send my Sonic1.asm file if allowed?
     
  12. TheInvisibleSun

    TheInvisibleSun Visible Member

    Joined:
    Jul 2, 2013
    Messages:
    305
    Location:
    Buffalo, NY, USA
    In the Level Main Loop code, you should be able to just trigger the variables/flags for speed shoes, invincibility. I did this from scratch in Sonic 1, by creating a new variable that would be set to $01 if btnA was pressed mid-air, but only if v_emeralds was greater than or equal to $06. Then you can use the new variable value as a condition to trigger the powers and special effects (look at the monitor contents/powerup code, if you don't know how those variables work), independent of their usual time limit.

    There's probably a more efficient/better way of doing it, though.
     
  13. Greenknight9000

    Greenknight9000 Well-Known Member Member

    Joined:
    Apr 30, 2014
    Messages:
    53
    I'm sorry, I think I was too ambitious.
    This was way too difficult and I shouldn't have wasted your time. I think I give up.
     
  14. LazloPsylus

    LazloPsylus A Certain Scientific Railgun The Railgun

    Joined:
    Nov 25, 2009
    Messages:
    Location:
    Academy City
    What part of wanting to learn how to do it is too ambitious?

    Look, it's OK if you don't just magically understand how everything works. Believe it or not, none of us started out automagically understanding everything and being able to code whatever we desired. The difference is that we didn't give up. So, what are you having trouble understanding? What's acting as your roadblock to being able to grasp and implement the feature? Talk it out some. Let's see if we can help you break down those barriers of understanding, and help you get to that next step. That's what we're here for as a community, after all.

    Just don't give up. Keep at it, ask questions to help make sense of it, and you'll succeed.
     
  15. Greenknight9000

    Greenknight9000 Well-Known Member Member

    Joined:
    Apr 30, 2014
    Messages:
    53
    I don't know how to thank you for the kind words, it makes me unspeakably happy.
    I'll be honest - When I first posted here, I initially just wanted to request a "copy-paste of the Super Sonic code"
    I knew that I wouldn't learn anything from it, so I went to give it a shot and followed this tutorial but I got stuck at the "
    Step 2 Porting Sonic's art from Sonic 2" part; not knowing how to use SonMapEd too well, I decided to leave out the sprites and just add Super Sonic, minus his sprites. I went to use the code from the "
    Actually porting Super Sonic" segment, yet to no avail - It builded with no errors, yet no Super transformation
    After asking for help, I became pretty self-conscious asking for help over and over, so I pretty much gave up.
    After hearing your words, I think I'm confident to ask again - please may I have help?
     
  16. Pacca

    Pacca Why succeed when you can profit off of failure? Member

    Joined:
    Jul 5, 2014
    Messages:
    1,149
    Location:
    Triton (Moon)
    So the game merely appears as if it hasn't been modified at all? Does any of the code appear to do anything? If some of it is running, like say ring drain for example, then something more specific might be wrong. Assuming you only did the steps up to "Actually porting Super Sonic" whilst skipping the sprites stuff, it might not be obvious that the code is working, because he'd neither flash yellow nor be invincible; those are fixed in later steps. If the only noticeable effect is ring drain, then the code you added is probably working just fine, and you should just continue the guide from there. If not, then you might want to double check to make sure you did the very first part of "Step 4 Actually porting Super Sonic" correctly. Although the guide isn't 100% clear on this, the two lines should go immediately after "locret_134C2", not before.
     
  17. Greenknight9000

    Greenknight9000 Well-Known Member Member

    Joined:
    Apr 30, 2014
    Messages:
    53
    There's no sign of any changes, nothing - nada
    No transformation or anything. In the Spoiler is the Super Sonic code I've used - what am I missing?
    ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||


    Sonic_JumpHeight: ; XREF: Obj01_MdJump; Obj01_MdJump2
    tst.b $3C(a0)
    beq.s loc_134C4
    move.w #-$400,d1
    btst #6,$22(a0)
    beq.s loc_134AE
    move.w #-$200,d1

    loc_134AE:
    cmp.w $12(a0),d1
    ble.s locret_134C2
    tst.b y_vel(a0) ; is Sonic exactly at the height of his jump?
    beq.s Sonic_CheckGoSuper ; if yes, test for turning into Super Sonic
    move.b ($FFFFF602).w,d0
    andi.b #$70,d0 ; is A, B or C pressed?
    bne.s locret_134C2 ; if yes, branch
    move.w d1,$12(a0)

    locret_134C2:
    rts
    ; ===========================================================================

    loc_134C4:
    cmpi.w #-$FC0,$12(a0)
    bge.s locret_134D2
    move.w #-$FC0,$12(a0)

    locret_134D2:
    rts
    ; End of function Sonic_JumpHeight

    ; ---------------------------------------------------------------------------
    ; Subroutine called at the peak of a jump that transforms Sonic into Super Sonic
    ; if he has enough rings and emeralds
    ; ---------------------------------------------------------------------------

    ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||

    ; loc_1AB38: test_set_SS:
    Sonic_CheckGoSuper:
    tst.b (Super_Sonic_flag).w ; is Sonic already Super?
    bne.s return_1ABA4 ; if yes, branch
    ; cmpi.b #7,(Emerald_count).w ; does Sonic have exactly 7 emeralds?
    ; bne.s return_1ABA4 ; if not, branch
    cmpi.w #50,(Ring_count).w ; does Sonic have at least 50 rings?
    bcs.s return_1ABA4 ; if not, branch

    move.b #1,(Super_Sonic_palette).w
    move.b #$F,(Palette_frame_count).w
    move.b #1,(Super_Sonic_flag).w
    move.b #$81,obj_control(a0)
    move.b #$1F,anim(a0) ; use transformation animation
    ; move.b #$7E,(Object_RAM+$2040).w ; Obj7E is the ending sonic which is why it's commented out
    move.w #$A00,(Sonic_top_speed).w
    move.w #$30,(Sonic_acceleration).w
    move.w #$100,(Sonic_deceleration).w
    move.w #0,invincibility_time(a0)
    bset #1,status_secondary(a0) ; make Sonic invincible
    move.w #$C3,d0 ;
    jsr (PlaySound).l ; Play special ring sound effect.
    move.w #$87,d0
    jmp (PlaySound_Special).l ; load the invincibility song and return also playmusic doesn't exist

    ; ---------------------------------------------------------------------------
    return_1ABA4:
    rts
    ; End of subroutine Sonic_CheckGoSuper


    ; ---------------------------------------------------------------------------
    ; Subroutine doing the extra logic for Super Sonic
    ; ---------------------------------------------------------------------------

    ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||

    ; loc_1ABA6:
    Sonic_Super:
    tst.b (Super_Sonic_flag).w ; Ignore all this code if not Super Sonic
    beq.w return_1AC3C
    tst.b (Update_HUD_timer).w
    beq.s Sonic_RevertToNormal ; ?
    subq.w #1,(Super_Sonic_frame_count).w
    bpl.w return_1AC3C
    move.w #60,(Super_Sonic_frame_count).w ; Reset frame counter to 60
    tst.w (Ring_count).w
    beq.s Sonic_RevertToNormal
    ori.b #1,(Update_HUD_rings).w
    cmpi.w #1,(Ring_count).w
    beq.s @update
    cmpi.w #10,(Ring_count).w
    beq.s @update
    cmpi.w #100,(Ring_count).w
    bne.s @update2
    @update
    ori.b #$80,(Update_HUD_rings).w
    @update2
    subq.w #1,(Ring_count).w
    bne.s return_1AC3C
    ; loc_1ABF2:
    Sonic_RevertToNormal:
    move.b #2,(Super_Sonic_palette).w ; Remove rotating palette
    move.w #$28,($FFFFF65C).w ; Unknown
    move.b #0,(Super_Sonic_flag).w
    move.b #1,next_anim(a0) ; Change animation back to normal ?
    move.w #1,invincibility_time(a0) ; Remove invincibility
    move.w #$600,(Sonic_top_speed).w
    move.w #$C,(Sonic_acceleration).w
    move.w #$80,(Sonic_deceleration).w
    btst #6,status(a0) ; Check if underwater, return if not
    beq.s return_1AC3C
    move.w #$300,(Sonic_top_speed).w
    move.w #6,(Sonic_acceleration).w
    move.w #$40,(Sonic_deceleration).w

    return_1AC3C:
    rts
    ; End of subroutine Sonic_Super
     
  18. Pacca

    Pacca Why succeed when you can profit off of failure? Member

    Joined:
    Jul 5, 2014
    Messages:
    1,149
    Location:
    Triton (Moon)
    Ah, I see your problem. I'm not used to explaining this kind of thing, but it's a very important thing to know about, so I'll do my best.

    A line of code in an ASM file can be one of five things. Since constants and macros aren't necessary right now, and blank/comment only lines do nothing, I'll focus on the two most important ones; "labels" and "code". Here's a typical label followed by a line of code:
    Code:
    do_something:
            move.w #something_else,(yet_another_thing).w
    There are some things of note here. For example, the label (and all other labels) has no spaces/tabs/indents/etc. separating it from the beginning of the line. Also, although it isn't necessary, most labels have a colon (":") at the end, to help clarify that it is indeed a label. Labels are basically names, used by the code to tell it where something is; in this case, the label tells some code that underneath this label is more code, which can be run if it needs to.

    Now, you may have noticed that the code has some odd names in it, like "something_else" and "yet_another_thing". These are actually the names of other labels. In order for the labels to be useful, code actually has to reference them. This is done quite a bit in most disassemblies, as it makes it easier to change code around. Now to get back to the issue at hand. The code you added was put after these lines:
    Code:
            cmp.w $12(a0),d1
            ble.s locret_134C2

    This code is not a label itself, but rather, code referencing a label. Most guides will assume you already know the difference between the two, although the confusion is certainly understandable. Whenever any guide mentions that you should add code after a name, like "locret_134C2", "return_2132", "Sonic_Jump", etc., it always wants you to put it after the label, not code using the label. In this case, the guide actually wants you to put the two lines here:
    Code:
    locret_134C2:
            ;super sonic lines go here
            rts
    
     
    Last edited: Jul 25, 2018
    TheInvisibleSun likes this.
  19. Greenknight9000

    Greenknight9000 Well-Known Member Member

    Joined:
    Apr 30, 2014
    Messages:
    53
    OH MY GOD
    SOMETHING HAPPENED
    Sonic's Sprite went blank (I assume null transformation sprites)
    the Invincibillity theme played and has Super Sneakers (no invincibility and no palette change or ring drain)
    Now, I'm contemplating on adding his sprites, but I don't want to jump the gun, I now need to do the rest of Super Sonic
    I'm actually getting really excited, I never done something so amazing like this, and I can't thank you enough!
     
  20. Pacca

    Pacca Why succeed when you can profit off of failure? Member

    Joined:
    Jul 5, 2014
    Messages:
    1,149
    Location:
    Triton (Moon)
    His sprite breaking is probably due to animation $1F not being defined. One of the lines says "use transformation animation". You can edit the number used there (which is $1F by default) to a smaller one, and it will play a valid Sonic 1 animation. Just change the number and test out different values to find an animation you like.

    The rest of the issues are handled directly by the guide, just follow the rest of the steps and you should be good to go!