don't click here

Basic Questions & Answers thread

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

  1. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    Okay this is a more complex one that is sort of an theory throughout all 3 games, but I wanna know if it's possible to turn off the animation reset when landing on the ground or on an object.

    Like when you land on something it reverts to standing or running, and even on something you bounce off it just converts your animation (eg. when you bounce off a breakable rock, it doesn't continue the rolling animation, it just commands it again so it looks like the loop is continuing, turn that off as it defaults to walking animation).

    I wanna know if there's something that can turn that off and let an in-air animation continue until it's finished even when you land.
     
  2. Devon

    Devon

    I'm a loser, baby, so why don't you kill me? Tech Member
    1,245
    1,415
    93
    your mom
    You'd have to change how it handles setting the animation and resetting it in (Player)_Move, (Player)_Move(Direction), ResetOnFloor, and AnglePos. Just check for a flag or specific animation and skip over setting/resetting the animation in those routines, and I think you should be good to go.
     
    Last edited: Jun 15, 2020
  3. AppleSauce

    AppleSauce

    It's now illegal to use your meme! Member
    44
    2
    8
    A'ight this is a question intended for Selbi to answer - in Sonic Erazor (one of my favourite games, even if it is a romhack) the giant rings in Uberhub Place take you to different levels. I'd like to know how you did that, along with the haptic effects when you hit a monitor or Badnik.

    Also, how did you add textboxes? I'd like to actually incorporate a story into my game by interacting with NPCs (i.e objects) to show textboxes.
     
  4. Wafer

    Wafer

    Find me on Twitter instead Member
    255
    75
    28
    @AppleSauce Selbi hasn't even been online for over a year, what makes you think that he's gonna turn up now to answer your question?

    I'm gonna give you the best, last advice you'll ever get from me: TRY to learn to program, instead of asking everyone else to tell you how to implement cool ideas. Start small, follow some bugfix guides, learn the engine. Don't just follow the guides by rote, actually try to understand the changes you're making. If you don't understand a line, look it up in the instruction set. Make mistakes, learn from them, try to improve yourself.

    And next time you come to ask a question, don't aim it specifically at a stranger just because you don't like the advice that you've already been offered.
     
  5. Aerosol

    Aerosol

    Not here. Moderator
    11,163
    573
    93
    Not where I want to be.
    Sonic (?): Coming summer of 2055...?
    Echoing the above: this is the BASIC questions and answers thread. Asking how to implement entire features is outside it's scope.

    That being said, for text boxes, you could probably start here: https://blog.bigevilcorporation.co.uk/2012/04/09/sega-megadrive-5-fonts-and-text/

    If that's over your head, you need to start smaller.

    EDIT: I do have a problem of my own though.

    My object won't persist. I'm trying to change it a bit so that rather than moving Sonic into position, he just snaps there. That works, but after using the object it disappears.

    There's a second problem with it as well, probably due to how I'm snapping Sonic into position. When he lands, he lands a few pixels below the ground. He seems to interact with it fine though, and it fixes itself if I jump.

    Here's the code: https://pastebin.com/X1e4sVks
     
    Last edited: Jun 17, 2020
  6. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    A characters animation is reset to 0 upon landing on the floor. Take a look at X_resetonfloor (x being the character name, in most cases), perhaps you could make a check for the specific animation you want, and if it is positive, branch over the line that sets the animation to 0. ;)


    Perhaps, set a flag when Sonic is bounced off the object. Check in the resetonfloor subroutine for the flag, and if so, subtract his y_pos by a few pixels.
     
  7. Aerosol

    Aerosol

    Not here. Moderator
    11,163
    573
    93
    Not where I want to be.
    Sonic (?): Coming summer of 2055...?
    That's an option!

    Djohe taught me a few things and it turns out the idle code I have is better served in Sonic 2 via the MarkObjGone subroutine. My object persists properly now, so that's a plus.
     
  8. ashthedragon

    ashthedragon

    Sonic Paradise Researcher
    1,428
    73
    28
    Spain
    Sonic Paradise & Sonic Ages
    Thanks! My level is very, very newbie. I've never edited Mster system games before and have not much technical knowledge haha. Thanks for the info! Ive been replacing the text, keeping the same number of characters and changing when any word has less characters than the ones that were before into EB (blank space). But it still wont work. I'l try with a better emulator then and see what can I do. Thanks!
     
  9. Wafer

    Wafer

    Find me on Twitter instead Member
    255
    75
    28
    @ashthedragon Cool. I just had a crack at this myself based on the information on the wiki and I got positive results after a couple of attempts, no need to change the checksum, at least on Emulicious and Kega. I did trip up over the control codes a bit, so just be wary of those. But no matter what I did to the data, it didn't stop the ROM from loading in Emulicious or Kega, so I'm not sure what's causing your issues.
     
  10. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    Can someone tell me if this code is correct?

    Code (Text):
    1. Chase_Object: ; a0 = MainCharacter a2 = object
    2.         move.w    d0,d2            ; d0 = Maximum speed
    3.         neg.w    d2                   ; reverse max speed?
    4.         move.w    d1,d3            ; d1 = acceleration
    5.         move.w    x_pos(a0),d4 ; move x_pos of a0 to d4
    6.         cmp.w    x_pos(a2),d4   ; compare the x_pos of a2 to a0's
    7.         seq        d5                   ; set if equal
    8.         beq.s    loc_8545E         ; branch if equal as well
    9.         bcs.s    loc_8544C         ; branch if carry set
    10.         neg.w    d1                   ; reverse acceleration
    11.  
    12. loc_8544C:
    13.         move.w    x_vel(a0),d4  ; move x_vel of a0 to d4 now
    14.         add.w    d1,d4              ; add acceleration of d1 to d4
    15.         cmp.w    d2,d4             ; compare reversed max speed
    16.         blt.s    loc_8545E          ; if it's lower than max, branch
    17.         cmp.w    d0,d4             ; compare max speed
    18.         bgt.s    loc_8545E        ; if it is higher than max, branch
    19.         move.w    d4,x_vel(a0) ; otherwise move max speed to x_vel
    20.  
    21. loc_8545E:
    22.         move.w    y_pos(a0),d4     ; move y_pos of a0 to d4 now
    23.         cmp.w    y_pos(a2),d4     ; compare with y_pos of a2 to a0's
    24.         beq.s    loc_85480        ; if equal, branch
    25.         bcs.s    loc_8546C        ; if carry clear, branch
    26.         neg.w    d3                 ; otherwise, reverse max speed
    27.  
    28. loc_8546C:
    29.         move.w    y_vel(a0),d4     ; move y_vel of a0 to d4 now
    30.         add.w    d3,d4            ; add acceleration of d3 to d4
    31.         cmp.w    d2,d4            ; compare with y_vel of a2
    32.         blt.s    locret_8547E     ; if less than, branch
    33.         cmp.w    d0,d4            ; compare max speed with acceleration
    34.         bgt.s    locret_8547E     ; branch if greater than
    35.         move.w    d4,y_vel(a0)     ; move acceleration of d4 to y_vel
    36.  
    37. locret_8547E:
    38.         rts
    39. ; ---------------------------------------------------------------------------
    40.  
    41. loc_85480:
    42.         tst.b    d5                 ; test for d5
    43.         beq.s    locret_8547E     ; if yes, branch
    44.         clr.w    x_vel(a0)         ; clear x_vel of a0
    45.         clr.w    y_vel(a0)         ; clear y_vel of a0
    46.         rts
    47. ; End of function Chase_Object
    My thought is, player is in a0, object being chased is in a2. If conditions are met, it ends, otherwise continues.
     
    Last edited: Jun 19, 2020
  11. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,201
    431
    63
    Japan
    You are more or less on the right track, except you have them swapped, and a few of the terminology is somewhat wrong (or vague/incomplete).

    Code (Text):
    1. Chase_Object:
    2.     move.w  d0,d2           ; copy and create a negative version of the maximum speed
    3.     neg.w   d2              ; ''
    4.     move.w  d1,d3           ; store current speed in d3 (for Y later)
    5.  
    6.     ; --- Checking X position ---
    7.  
    8.     move.w  x_pos(a0),d4    ; load object's X position
    9.     cmp.w   x_pos(a2),d4    ; check against character's X position (subtraction)
    10.     seq d5                  ; if they are in exactly the same spot on X, set d5 as a reminder for later
    11.     beq.s   CO_FinishX      ; if they are in exactly the same spot on X, branch
    12.     bcs.s   CO_MoveRight    ; if carry set, then character is to the right of the object, so branch
    13.     neg.w   d1              ; convert speed to negative (go left instead of right)
    14.  
    15. CO_MoveRight:
    16.  
    17.     ; --- Handling X speed ---
    18.  
    19.     move.w  x_vel(a0),d4    ; load object's X speed
    20.     add.w   d1,d4           ; add current speed
    21.     cmp.w   d2,d4           ; is the speed passed its maximum in negative (left)?
    22.     blt.s   CO_FinishX      ; if so, branch (don't change the speed)
    23.     cmp.w   d0,d4           ; is the speed passed its maximum in positive (right)?
    24.     bgt.s   CO_FinishX      ; if so, branch (don't change the speed)
    25.     move.w  d4,x_vel(a0)    ; update object's new X speed
    26.  
    27. CO_FinishX:
    28.  
    29.     ; --- Checking Y position ---
    30.  
    31.     move.w  y_pos(a0),d4    ; load object's Y position
    32.     cmp.w   y_pos(a2),d4    ; check against character's Y position (subtraction)
    33.     beq.s   CO_FinishY      ; if they are in exactly the same spot on Y, branch
    34.     bcs.s   CO_MoveDown     ; if carry set, then character is below the object, so branch
    35.     neg.w   d3              ; convert speed to negative (go up instead of down)
    36.  
    37. CO_MoveDown:
    38.  
    39.     ; --- Handling Y speed ---
    40.  
    41.     move.w  y_vel(a0),d4    ; load object's Y speed
    42.     add.w   d3,d4           ; add current speed
    43.     cmp.w   d2,d4           ; is the speed passed its maximum in negative (up)?
    44.     blt.s   CO_Return       ; if so, branch (don't change the speed)
    45.     cmp.w   d0,d4           ; is the speed passed its maximum in positive (down)?
    46.     bgt.s   CO_Return       ; if so, branch (don't change the speed)
    47.     move.w  d4,y_vel(a0)    ; update object's new Y speed
    48.  
    49. CO_Return:
    50.     rts                     ; return
    51.  
    52.     ; --- Destination reached check ---
    53.  
    54. CO_FinishY:
    55.     tst.b   d5              ; has the object reached the character exactly on X (and Y)?
    56.     beq.s   CO_Return       ; if not, branch/return
    57.     clr.w   x_vel(a0)       ; stop object from moving on X
    58.     clr.w   y_vel(a0)       ; stop object from moving on Y
    59.     rts                     ; return
     
  12. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    Wouldn't this do the opposite of what I was looking for, in a sense? If I am reading it correctly, this is check to see if the object (a0) is reaching the player's (a2) position.
    I am looking for if the player (a0) reached the object's (a2) position. Hit me up in DMs on discord maybe.

    Edit: What I am looking for, is what I call persistent tracking. I want the player to continuously move towards the object's location until it is reached. It seems, what this routine does, at least in my testing, is controls the player's max speed depending on distance from the target object.
     
    Last edited: Jun 20, 2020
  13. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,201
    431
    63
    Japan
    This subroutine is designed to move an object in a0 towards an object in a2 in a gravity like way, at the acceleration speed of d1, and a maximum speed of d0. This is likely the subroutine responsible for moving the rings towards the main character when they have an electric shield on.

    It sounds to me like you're looking for something more along the lines of a homing attack?
     
  14. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    Actually its current setup might be useful to me. I want to make a routine for a projectile so it homes back to the player when it's finished it's thrust forward routine. Would the above code be advisable for such behaviour? (And if so, would you be against me stealing it? :P)
     
    Last edited: Jun 20, 2020
  15. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    You are more than welcome to use it how you see fit. All you have to do is reverse the registers in order to make the object come to the player.
     
  16. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    Thanx. I'm not sure I need to though, because I placed it in the object's routine where the main character is already a2 (and switching them around only tries to forcibly move the main character instead).

    Here's what I have so far, but it doesn't seem to do the job, the object just seems to delete when the counter is done:

    Code (Text):
    1.  
    2.     move.w     #$740,x_vel(a0)                ; speed of laser
    3.     move.w     #-$490,y_vel(a0)                ; speed of laser
    4.     move.b    #$38,$30(a0)                 ; distance laser will travel
    5.  
    6. Obj4D_Cont:
    7.     btst    #0,($FFFFB001).w
    8.     beq.s +
    9.     neg.w    x_vel(a0)
    10.     add.w    #$40,x_pos(a0)
    11.     bset    #0,$22(a0)                    ; Flip to the left
    12.     bra.w    ++
    13. +
    14.     sub.w    #$40,x_pos(a0)
    15. +
    16.     move.w #$9E00,d2
    17.     addq.b    #2,$24(a0) ;
    18.  
    19.  
    20. Obj_Blob_Move:
    21.     cmp.b    #0,$30(a0)
    22.     bne.w    ContCounter
    23.  
    24. Reel_Homing:
    25.         move.b  #1,anim(a0)
    26. Chase_Object:
    27.     lea    (MainCharacter).w,a2
    28.         move.w  d0,d2           ; copy and create a negative version of the maximum speed
    29.         neg.w   d2              ; ''
    30.         move.w  d1,d3           ; store current speed in d3 (for Y later)
    31.  
    32.     ; --- Checking X position ---
    33.  
    34.         move.w  x_pos(a0),d4    ; load object's X position
    35.         cmp.w   x_pos(a2),d4    ; check against character's X position (subtraction)
    36.         seq d5                  ; if they are in exactly the same spot on X, set d5 as a reminder for later
    37.         beq.s   CO_FinishX      ; if they are in exactly the same spot on X, branch
    38.         bcs.s   CO_MoveRight    ; if carry set, then character is to the right of the object, so branch
    39.         neg.w   d1              ; convert speed to negative (go left instead of right)
    40.  
    41. CO_MoveRight:
    42.  
    43.     ; --- Handling X speed ---
    44.  
    45.         move.w  x_vel(a0),d4    ; load object's X speed
    46.         add.w   d1,d4           ; add current speed
    47.         cmp.w   d2,d4           ; is the speed passed its maximum in negative (left)?
    48.         blt.s   CO_FinishX      ; if so, branch (don't change the speed)
    49.         cmp.w   d0,d4           ; is the speed passed its maximum in positive (right)?
    50.         bgt.s   CO_FinishX      ; if so, branch (don't change the speed)
    51.         move.w  d4,x_vel(a0)    ; update object's new X speed
    52.  
    53. CO_FinishX:
    54.  
    55.     ; --- Checking Y position ---
    56.  
    57.         move.w  y_pos(a0),d4    ; load object's Y position
    58.         cmp.w   y_pos(a2),d4    ; check against character's Y position (subtraction)
    59.         beq.s   CO_FinishY      ; if they are in exactly the same spot on Y, branch
    60.         bcs.s   CO_MoveDown     ; if carry set, then character is below the object, so branch
    61.         neg.w   d3              ; convert speed to negative (go up instead of down)
    62.  
    63. CO_MoveDown:
    64.  
    65.     ; --- Handling Y speed ---
    66.  
    67.         move.w  y_vel(a0),d4    ; load object's Y speed
    68.         add.w   d3,d4           ; add current speed
    69.         cmp.w   d2,d4           ; is the speed passed its maximum in negative (up)?
    70.         blt.s   CO_Return       ; if so, branch (don't change the speed)
    71.         cmp.w   d0,d4           ; is the speed passed its maximum in positive (down)?
    72.         bgt.s   CO_Return       ; if so, branch (don't change the speed)
    73.         move.w  d4,y_vel(a0)    ; update object's new Y speed
    74.  
    75. CO_Return:
    76.         rts                     ; return
    77.  
    78.     ; --- Destination reached check ---
    79.  
    80. CO_FinishY:
    81.         tst.b   d5              ; has the object reached the character exactly on X (and Y)?
    82.         beq.s   CO_Return       ; if not, branch/return
    83.         clr.w   x_vel(a0)       ; stop object from moving on X
    84.         clr.w   y_vel(a0)       ; stop object from moving on Y
    85.     bra.w    Obj_Blob_Destroy
    86.     rts
    87.  
    88. ContCounter:
    89.     sub.b     #$1,$30(a0)
    90.     bsr.w    ObjectMoveAndFall
    91.     move.b    $40,$20(a0)    ; lol
    92.  
    93.     clr.w d0
    94.     move.b $1A(a0),d0
    95.     asl.w #$1,d0     ; *2 for correct offset
    96.     lea (ArtUnc_Lure).l,a1
    97.     adda.w (a1,d0.w),a1
    98.     move.w #$9E00,d2
    99.  
    100.     lea    (Ani_Laser).l,a1
    101.     jsr    AnimateSprite
    102.     bsr.w    LoadLureDynPLC
    103.     jsr    (TouchResponse).l ;Touch_KillEnemy, Touch_Monitor
    104.     jmp    DisplaySprite
    105.  
    106. Obj_Blob_Destroy:
    107.     lea    (MainCharacter).w,a2
    108.     btst    #1,status(a2)
    109.     bne.s    Obj_Blob_Destroy_2
    110.     move.w    #0,(Chain_Bonus_counter).w
    111. Obj_Blob_Destroy_2:
    112.     jmp DeleteObject
    113.  
    I'm guessing I've made a blatant error here. Any idea?


    EDIT: Okay I've partially solved this by moving the animation/PLC branches up since the new routine skipped over them, however the object still doesn't move a muscle after it's run it's distance.

    What did you use to program max speed into d0 by any chance. Was it x_vel?
     
    Last edited: Jun 20, 2020
  17. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    I've actually worked out how to do exactly what you are looking for. Hit me up on Discord later, and I will walk you through it.
     
  18. AppleSauce

    AppleSauce

    It's now illegal to use your meme! Member
    44
    2
    8
    Hey y'all. In Sonic 1, I'm trying to create a new jump mechanic. My original plan was to have it curl midair and stay in a ball until they reach the ground, like Pantufa: Extended Edition with the player being vulnerable if they are not in a ball. I couldn't figure out how to repeat only a segment of the animation, so instead, it also curls out of the ball midair. I think I got the animation going good, but in SAnim_RollJump, I'm having trouble keeping the animation speed consistent regardless of speed, and for some reason, no matter what I do, when I go to GHZ Act 2 and jump, the character jumps reeeeaaally quickly like he's high on caffeine. Could anyone provide me with help?

    I'm using the Hivebrain 2005 disassembly.
     
  19. nineko

    nineko

    I am the Holy Cat Tech Member
    6,308
    486
    63
    italy
    I can't address your other issues, but:
    Are you using the FE flag?
     
  20. AppleSauce

    AppleSauce

    It's now illegal to use your meme! Member
    44
    2
    8
    Yes, at the very start of both roll anims.

    Edit: I clicked on the orange text in your reply, and I didn't know I was supposed to set the FE flag to step back a few sprites. I thought it handled speed, because if I don't have the FE flag at the start of the anims, it is really slow, like a snail carrying heavy shopping. So what's up with that?
     
    Last edited: Jun 21, 2020