don't click here

Basic Questions & Answers thread

Discussion in 'Engineering & Reverse Engineering' started by Tweaker, May 29, 2008.

  1. Selbi

    Selbi

    The Euphonic Mess Member
    1,497
    48
    28
    Northern Germany
    Sonic ERaZor
    If you want to check if down and A is being pressed, you need to do this check:
    Code (ASM):
    1.         move.b  ($FFFFF603).w,d0    ; move the current button press to d0
    2.         and.b   #$42,d0         ; and the your value on it ($42/A+down in this case)
    3.         beq.s   JD_Return       ; if A + down is not being pressed, branch
    And as an explaination, here you have a tiny guide about button presses. If you want to check for multiple buttons being pressed at the same time, you just need to add the values together (so: $40=A + $02=down = $42=A+down).

    Oh, almost forgot something: I'd like to help you with your problems on MSN or something. If you agree, just shoot me a PM and I'll see what I can do (and don't be shy, I won't byte =P).
     
  2. T-Rae

    T-Rae

    Tryin' to get back into Sonic hacking... Member
    17
    0
    0
    Maryland
    none ATM
    Okay, two things. Does anybody know how to change the SEGA logo sound especially if you are using an assembler? Also, is there a way to import Sonic 3D Blast music into Sonic 1? I tried using the ESEII Sound Importer, but the version 2 beta is a little complicated for me to understand.
     
  3. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,202
    432
    63
    Japan
    The problem here is that it'll not branch if A "OR" Down is pressed, this is how it works.

    Lets say you are pressing A, Down & C at the same time, "ReadJoypads" is a subroutine of which will dump the controls from the ports to ram (Obviously to prevent having to read from the port constantly which would take more processing to do).

    move.b ($FFFFF603).w,d0

    So, we've loaded all the buttons from that ram space to d0 so we can modify it for checking. The way that the controls are read is in bits (0000 0000) each bit represents a button (SACB RLDU).

    S = Start
    A = Button A
    C = Button C
    B = Button B
    R = D-Pad Right
    L = D-Pad Left
    D = D-Pad Down
    U = D-Pad Up

    If the bit is set (1), then the button has been pressed, is it is clear (0), then the button has not been pressed, in our example we have A, Down & C pressed, so in bits that would be 0110 0010, and in Hex bytes that would be $62. The purpose of this command below is to clear ALL other buttons being pressed except the buttons you want checking:

    and.b #$42,d0

    This is clearing all bits except the ?'s 0?00 00?0, so now only button statuses A or Down are held in d0 (C was cleared).

    beq.s JD_Return

    Due to the ccr there is an automatic branch if certain requirements are met, this in a basic term asks the question, "If the ? bits (0?00 00?0) are null (if they are both 0), then branch. If ANY of those two ? bits are set (if any are 1), DO NOT BRANCH."

    ----

    So it seems your jumpdash will dash if A + Down are pressed, or is only A is pressed, or if only Down is pressed.

    It might be a simple idea to put:
    Code (ASM):
    1.         move.b  ($FFFFF603).w,d0                ; move the current button press to d0
    2.         and.b   #$42,d0                     ; get only buttons A and Down
    3.         cmp.b   #$42,d0                     ; were both A and Down pressed?
    4.         bne.s   JD_Return                   ; if not, branch
    5.  
    ..and there you have it.
     
  4. Spanner

    Spanner

    The Tool Member
    I still use the old disassembly. =P
    And the asm68k version doesn't even need s1comb.asm any more.
     
  5. Korou Tenshi

    Korou Tenshi

    Member
    442
    3
    18
    UK
    Unusual question, but I feel like doing a bit of hacking again, albeit simple stuff (adding levels and art, swapping music and level orders, maybe swapping bosses and such in Sonic 2).
    Problem is I'm running on Mac OSX, and stuff like SonEd and even disassemblies are unavailable to me, and I don't really want to be running parallels or anything as I have neither the disk space or the money.

    So yeah, to my question ~ How feasible would it be for me to actually do any of this stuff? What tools would I need, what would the processes be required, and how difficult would it be?
     
  6. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    While it has corrected the button activation it still hardly ever works. It seems random whether pressing the buttons activate a normal jump attack or the dash. If it helps here is my reworked code. It is assigned to Md_Jump2 and placed after Sonic_Roll

    Code (Text):
    1. ; ---------------------------------------------------------------------------
    2. ; Subroutine for Sonic's hammer spin animation
    3. ; ---------------------------------------------------------------------------
    4.  
    5. ; ||||||||||||||| S U B    R O U T    I N E |||||||||||||||||||||||||||||||||||||||
    6.  
    7. Sonic_HammerSpin:
    8.         move.b    ($FFFFF603).w,d0; move the current button press to d0
    9.         and.b    #$42,d0    ; get only buttons A and Down
    10.         cmp.b    #$42,d0    ; were both A and Down pressed?
    11.         bne.s    JD_End    ; if not, branch        
    12.         tst.b    ($FFFFFFEB).w; was jumpdash flag set?        
    13.         bne.w    JD_End    ; if yes, branch        
    14.         move.b    #1,($FFFFFFEB).w; if not, set jumpdash flag
    15.         move.b    #$20,$1C(a0); show hammer animation        
    16.         move.w    #$BC,d0    ; set jumpdash sound        
    17.         jsr    (PlaySound).l; play jumpdash sound        
    18.         bclr    #4,$22(a0); clear double jump flag        
    19.         move.w    #$800,d0; set normal jumpdash speed        
    20.         tst.b    ($FFFFFE2E).w; do you have speed shoes?        
    21.         beq.s    JD_ChkUW; if not, branch        
    22.         move.w    #$A00,d0; set speed shoes jumpdash speed
    23.  
    24. JD_ChkUW:        
    25.         btst    #6,$22(a0); is Sonic underwater?        
    26.         beq.s    JD_ChkDirection; if not, branch        
    27.         move.w    #$400,d0; set underwater jumpdash speed
    28.  
    29. JD_ChkDirection:        
    30.         btst    #0,$22(a0); is sonic facing left?        
    31.         beq.s    JD_Move    ; if yes, branch        
    32.         neg.w    d0    ; if not, negate d0 (for jumping to the right)
    33.  
    34. JD_Move:        
    35.         move.w    #$F00,$12(a0); move sonic forward (y-velocity)        
    36.  
    37.  
    38. JD_End:        
    39.         rts        ; return
    40. ; End of function Sonic_JumpDash
    There are different animations for jumping (the spring animation plus a landing transition $21) and the animation for the dash is $20 rather than a roll, it works fine the times it activates it just seems to work rarely and randomly. Is the normal jump attack interfering or something?
     
  7. Selbi

    Selbi

    The Euphonic Mess Member
    1,497
    48
    28
    Northern Germany
    Sonic ERaZor
    I'm not sure about this, but I think it's because you are using the same flag as a normal jumpdash ($FFFFFFEB). I'm not sure if you have any other moves using this flag anyway, but try using a different one. I'll just give you $FFFFFFB0, hoping you haven't used it yet. Also, make sure you are clearing that flag in Sonic_ResetOnFloor.
     
  8. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    I don't even know how to give flags to moves anyway.

    How do you clear a flag in Sonic_ResetOnFloor? I take it this is why it only works once.

    Still same thing otherwise, works on a whim, almost never first time, activating A jump attack instead. Aside from the Touch_Enemy/Monitor and Bounce coding, is there any other coding I'm supposed to add or edit?
     
  9. OK, this one, I need to know. Suppose you want to make a Sonic 1 level using a special project template. However, I have not seen a lot of templates for novice hackers. If anyone can make a GHZ template or find one off the internet, I'm sure to get started.
     
  10. Mikel

    Mikel

    Member
    I think Selbi means something like this:

    Code (ASM):
    1. Sonic_ResetOnFloor:         ; XREF: PlatformObject; et al
    2.         clr.b   ($FFFFFFEB).w   ; clear jumpdash flag
    3.         clr.b   ($FFFFFFB0).w   ; clear HammerSpin flag
    4.         btst    #4,$22(a0)
    5.         beq.s   loc_137AE
    6.         nop
    7.         nop
    8.         nop
    9.  
    10. loc_137AE:
    11.         bclr    #5,$22(a0)
    12.         bclr    #1,$22(a0)
    13.         bclr    #4,$22(a0)
    14.         btst    #2,$22(a0)
    15.         beq.s   loc_137E4
    16.         bclr    #2,$22(a0)
    17.         move.b  #$13,$16(a0)
    18.         move.b  #9,$17(a0)
    19.         move.b  #0,$1C(a0)  ; use running/walking animation
    20.         subq.w  #5,$C(a0)
    21.  
    22. loc_137E4:
    23.         move.b  #0,$3C(a0)
    24.         move.w  #0,($FFFFF7D0).w
    25.         rts
     
  11. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    Got it. It works! Thanx, fellas.
     
  12. GT Koopa

    GT Koopa

    Member
    2,021
    18
    18
    Elgin, IL
    Flicky Turncoat DX, T.L.W.S. Vs M.G.W.
    Stumbled upon something, didn't know how useful it could be.

    Would this program help anybody here at Retro with anything at all?
     
  13. T-Rae

    T-Rae

    Tryin' to get back into Sonic hacking... Member
    17
    0
    0
    Maryland
    none ATM
    I have a question about porting music from another game. Is it possible to change what DAC voices are used in a music file by using a hex editor? The music that I ported plays fine but when it comes to the DAC playing I usually hear the messed up Sega sound playing. Also, is it possible to change how a music file plays because I have some music that I ported from xm to smps which plays from beginning to end and starts over again. With a hex editor, is there anyway I can loop the music from a certain point in the song?

    Also, I want to add a new monitor that gives out a random amount of rings when hit. It probably works somewhat the same as getting 10 rings but how exactly could this be done?
     
  14. nineko

    nineko

    I am the Holy Cat Tech Member
    6,308
    486
    63
    italy
    Yes. Assuming that you want to port songs from Sonic 3 to Sonic 1, for example, you'll have (at least) to change the kick from $86 to $81, and the snare from $81 to $82 (complete tables can be found here). Of course make sure to change the snare first, or you'll end up with a bunch of $81s and you wouldn't know what to do with them. To find the portion of the smps song which contains the DAC channel, you have to look at the header: get the pointer to the DAC channel, and the first pointer which is higher than that (it's usually the pointer to the voices). For example, if your pointer to the DAC channel is $1234, and amongst the other pointers you have $1200, $963, and $2345, your DAC channel will be between $1234 and $2345-1, unless there are crazy jumps around the song (if that's the case you're pretty much fucked unless you feel like following the pointers around). So just go to that range and do the needed replacements

    I bet you can if you have an infinite amount of time and patience. But every converter in the xm2/3/4smps series has built-in support to set a custom loop point. Just define it in your XM file and it will be automatically ported over. In Mod Plug Tracker, this setting is called "Restart Position", and it's in the General tab; it's measured in patterns, so you might need to split a pattern by hand in order to have it loop properly, but most of the times it's an easy cut and paste job.

    Good luck! :)
     
  15. T-Rae

    T-Rae

    Tryin' to get back into Sonic hacking... Member
    17
    0
    0
    Maryland
    none ATM
    Thanks Nineko, that helped me out a lot.
     
  16. BaconFace

    BaconFace

    DrTapeworm Member
    38
    0
    6
    Sorry if this a dumb question, but how do I get a level to use different enemies in Sonic 2? I want to use the Metropolis Zone crab in Emerald Hill Zone, and I think I might have to edit the graphics.
     
  17. amphobius

    amphobius

    doing more important things with my life Member
    2,120
    0
    16
    life
    Start playing around with the code around ArtLoadCues:. You may want to also edit the palletes as well.
     
  18. BaconFace

    BaconFace

    DrTapeworm Member
    38
    0
    6
    And where would I find these? In the ASM files?
     
  19. Selbi

    Selbi

    The Euphonic Mess Member
    1,497
    48
    28
    Northern Germany
    Sonic ERaZor
    Why was searching around some locations the best thing I could do to take a break from an epic huge 10 pages report? I really don't know...

    Anyway, the ArtLoadCues routine is... oh... well... I just noticed: What the hell? Is it really that hard to press Ctrl + F in the ASM file and seach for ArtLoadCues:? In other words, yes it is there (s2.asm), but even if it's not, you could just check out the other files and search there, because it's gotta be somewhere.

    Ok, end of post. Enough break time.
     
  20. amphobius

    amphobius

    doing more important things with my life Member
    2,120
    0
    16
    life
    Try looking down.