[Help] fire explosion effect following sonic at high speed

Discussion in 'Discussion and Q&A Archive' started by Ziro_, Sep 25, 2016.

  1. Ziro_

    Ziro_ Mentally Skewed Member

    Joined:
    Aug 1, 2016
    Messages:
    59
    Location:
    What are you a cop
    Using the hivebrain disassembly I tried to Have fire particles follow Sonic. Sadly It did not work and I do not know why. If you could point me int he right direction it would be much appreciated.

    Code:
    Sonic_fire:
            cmpi.w   #$600,d0        ; is the sonic inertia greater than 600?
            bne.s    Sonic_fire_rts    ; if not, branch
            move.b    #$91,0(a1)    ; load explosion object
            move.b    #1,($FFFFD21C).w
            move.b    #$91,0(a1)    ; load explosion object
            move.b    #2,($FFFFD25C).w
            move.b    #$91,0(a1)    ; load explosion object
            move.b    #3,($FFFFD29C).w
            move.b    #$91,0(a1)    ; load explosion object
    ; ---------------------------------------------------------------------------
    Sonic_fire_rts:
            rts
     
  2. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    It's been a while since I did this, but I pulled my old code out to compare. It seems that you need to jump to a routine named "SingleObjLoad2" (that's what it's called in the Sonic 2 Xenowhirl disassembly, it might be different for you) for the game to officially added an object. Simply writing object IDs' to RAM won't cut it, as the game doesn't know to load that object ram (plus, that's super hard coded and might conflict with preexisting objects). The routine is clearly intended to fix that. You need to move the relevant object info relative to a1 so that the routine can load it.

    Sonic 1 and Sonic 2 have nearly identical object management systems, so if you find the appropriate S1 hivebrain label for SingleObjLoad2, you should be fine.

    Also, we have a basic Q&A thread here. This would have been perfect for that thread.
     
    Soldaten likes this.
  3. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,016
    Last time you asked someone to 'point you in the right direction', you wound up just asking them to fix the code for you.

    Anyway, to add to Pacguy's post, I believe SingleObjLoad2 isn't exactly what you're looking for: that subroutine searches for a free object RAM slot after the current object. SingleObjLoad, on the other hand, searches the entire object RAM. You're just more likely to find a free slot that way. SingleObjLoad2 is only good for parent->child objects, where the child shouldn't update before the parent, and for some technical reasons, being in a later slot ensures that.
     
    FireRat and Pacca like this.
  4. GenesisDoes

    GenesisDoes What Nintendont Member

    Joined:
    Jan 2, 2016
    Messages:
    159
    Location:
    Pittsburgh, PA
    Not sure of the equivalent line labels/file names in Sonic 1 Hivebrain, but in Sonic 1 Github, in "_incobj/Sonic RecordPosition.asm" is the subroutine that tracks Sonic's position, in order to load the invincibility star objects when Sonic is invincible. It seems to be called by "bsr" opcodes in only a few places, specifically in routines for Sonic's movements. I would look at the game code to see how it handles loading the invincibility stars and on how it uses that subroutine, and then using that information to load the fire particle objects.