Basic Questions and Answers Thread

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

  1. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    So I got the rings to show up and here are the problems I'm facing:
    -The rings' mappings aren't correct. They are three tiles wide and one tile long and don't display the correct art. Switching the mappings to Sonic 2 or 3 format makes them use the correct art but the wrong shape.
    -The rings can't be collected
    -They appear in the correct formation the formation repeats across the stage both vertically and horizontally. Formations later in the stage seem to repeat from that point onward.
     
  2. Devon

    Devon Down you're going... down you're going... Member

    Joined:
    Aug 26, 2013
    Messages:
    1,372
    Location:
    your mom
    1) Have you set up the BuildRings routine correctly? Like, did you make it similar to Sonic 1's BuildSprites code for drawing a sprite for S1 mappings? Did you also change the art tile value to match the one in Obj25? (This value begins with a $2 in the code).

    2) You need to put a branch to the code for collecting rings at the beginning of TouchResponse.

    3) The S3K rings manager doesn't handle groups of rings like S1 and S2 do. There is a tool for splitting the group of rings individually on the porting the ring manager to S2 tutorial on Retro.
     
    ProjectFM likes this.
  3. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Hi!
    I want to add this feature because in my hack, the gameplay was fast.

    So i've see that there is a RAM adress with the Y camera position based on sonic (used for look up and duck) here:
    ----------------------------------------------------------------------------------
    $F73E-$F73F Y-camera position, based on Sonic ($60 = default)
    ----------------------------------------------------------------------------------

    But after searching, apparently there is no adress for X-camera position...

    I have to create it or does it exist?

    redhotsonic edit: Moved thread/post to Basic Q&A thread
     
    Last edited by a moderator: May 31, 2016
  4. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    1. Solved. New problem: I have an 8 frame ring animation and so I changed move.w #$604,(a4) to move.w #$608,(a4) so the flash animation displays correctly. The problem is that the flashing animation when you collect a ring doesn't end until it reaches frame 7 and I can't find the line of code I can use to make the animation stop at frame A.

    2. Solved. New problem: The rang for collecting the rings is too big. I haven't tried fixing this one yet so I may not need a reply.

    3. Not solved. I don't need the tool because SonLVL already uses Sonic 3's format.
     
  5. Devon

    Devon Down you're going... down you're going... Member

    Joined:
    Aug 26, 2013
    Messages:
    1,372
    Location:
    your mom
    No, you need the tool, because the rings haven't been converted properly.
     
  6. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    Sonic 1 doesn't use a ring manager so there is no ring format to convert and the tool wasn't made to work with Sonic 1's ring objects because the tutorial was made for Sonic 2. I'm just adding rings using SonLVL with SonLVL.ini changed so it would use Sonic 3's ring format.
     
  7. Devon

    Devon Down you're going... down you're going... Member

    Joined:
    Aug 26, 2013
    Messages:
    1,372
    Location:
    your mom
    You can use LevelConverter (made by MainMemory, can be found on his website or via the SonLVL updater) to get the ring data and then use the tool to split the group of rings to work with the S3K ring manager. I also suggest that after getting the ring data, you delete all instances of the ring object in the object data, since the rings aren't really objects anymore (unless you're using debug, which adds Obj25).

    Yes, I know the tool was made for the S2 tutorial, but I used it for when I ported the S3K ring manager to S1, and it worked fine for me.
     
    Last edited: Jun 1, 2016
  8. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    I didn't think of that. Thanks.
     
  9. NiphFM

    NiphFM Host of the Mega Drive Music Contest Member

    Joined:
    Jun 5, 2015
    Messages:
    430
    Location:
    Music Plant Zone
    How would I get Eggman to say something after getting beaten via MegaPCM?

    Like in Sonic Advance
     
  10. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    I think there is a mini tutorial in the MegaPCM tutorial, to make Sonic say a voice when he hurt, using a .wav file 8 bit.

    Check this, and try to know if this is possible to play a .wav voice using MegaPCM for Eggman.
     
    MarkeyJester likes this.
  11. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Sorry for the double post:

    Here is a code (mine):

    Code:
    move.w    $14(a0),d0
            cmpi.w   #$800,d0    ; is sonic goes his max speed? (right)
            bcc.s      SonicB_Okay
            rts
    When my speed is equal or greater than $800, i can use my ability.
    But only when i'm going to the right.

    When i'm going to the left, my character use his ability any time regardless of his speed...

    I've try the neg.w and the bclr #0$14,(a0) but that glitch all of my code, lol

    Need help someone please!
     
  12. TheStoneBanana

    TheStoneBanana banana Member

    Joined:
    Nov 27, 2013
    Messages:
    602
    Location:
    The Milky Way Galaxy
    Code:
    @chkgrndvelocity:
       move.w $14(a0),d0 ; copy Sonic's ground velocity to d0
       bpl.s @notnegative ; if the velocity is positive, branch
       neg.w d0 ; otherwise, negate d0
    
    @notnegative:
       cmpi.w #$800,d0 ; is Sonic going at his maximum speed?
       bcc.s @blahblahblah ; if so (or even somehow higher), branch
       rts
    
    @blahblahblah:
       ...
    The labels are just there for demo purposes.
     
    Devon and vladikcomper like this.
  13. Devon

    Devon Down you're going... down you're going... Member

    Joined:
    Aug 26, 2013
    Messages:
    1,372
    Location:
    your mom
    Ashuro, you were only checking for positive numbers, but you never considered if it were negative (a.k.a when Sonic is moving left). In TheStoneBanana's code, it takes the speed and stores it into d0, and then negates it if it's negative, so that it becomes positive. By doing so, you only have to do a single check for when the value is greater than or equal to $800, without the need to check -$800, since d0 will always be positive because of the extra code to make it positive if it's negative.

    EDIT (ninja'd by TSB)
     
    Last edited: May 31, 2016
  14. TheStoneBanana

    TheStoneBanana banana Member

    Joined:
    Nov 27, 2013
    Messages:
    602
    Location:
    The Milky Way Galaxy
    Additionally @Ashuro, you mentioned that you used bclr. I don't think that you quite know what that opcode does.
    bclr essentially clears a bit specified in the Source Operand. For example, you doing:
    Code:
       bclr #0,$14(a0)
    clears the 0th bit of the byte contained at $14(a0).
     
  15. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Thank you, it's working perfectly!
    See you soon :)

    My ability is awesome, when i'll release my hack, i think that i will post a tutorial for this... Maybe..

    EDIT: Ok thanks Banana for the lesson! :D
     
    TheStoneBanana likes this.
  16. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    So I fixed the range and animation problems but I still have garbage rings and repeating formations and it really slows down levels the have a lot of rings in them. Again, the code is right here:
    Code:
    RingsManager:
        moveq    #0,d0
        move.b    ($FFFFFE17).w,d0
        move.w    RingsManager_States(pc,d0.w),d0
        jmp    RingsManager_States(pc,d0.w)
    ; ===========================================================================
    ; off_16F96:
    RingsManager_States:
        dc.w RingsManager_Init-RingsManager_States
        dc.w RingsManager_Main-RingsManager_States
    ; ===========================================================================
    ; loc_16F9A:
    RingsManager_Init:
        addq.b    #2,($FFFFFE17).w ; => RingsManager_Main
        bsr.w    RingsManager_Setup
        movea.l    ($FFFFE800+Rings_Space).w,a1
        lea    ($FFFFE800).w,a2
        move.w    ($FFFFF700).w,d4
        subq.w    #8,d4
        bhi.s    loc_16FB6
        moveq    #1,d4
        bra.s    loc_16FB6
    ; ===========================================================================
    
    loc_16FB2:
        addq.w    #4,a1
        addq.w    #2,a2
    
    loc_16FB6:
        cmp.w    (a1),d4
        bhi.s    loc_16FB2
        move.l    a1,($FFFFE800+Rings_Space).w
        move.w    a2,($FFFFF7A2).w
        addi.w    #$150,d4
        bra.s    loc_16FCE
    ; ===========================================================================
    
    loc_16FCA:
        addq.w    #4,a1
    
    loc_16FCE:
        cmp.w    (a1),d4
        bhi.s    loc_16FCA
        move.l    a1,($FFFFE800+Rings_Space+4).w
        rts
    ; ===========================================================================
    ; loc_16FDE:
    RingsManager_Main:
        lea    ($FFFFEF80).w,a2
        move.w    (a2)+,d1
        subq.w    #1,d1
        bcs.s    loc_17014
    
    loc_16FE8:
        move.w    (a2)+,d0
        beq.s    loc_16FE8
        movea.w    d0,a1
        subq.b    #1,(a1)
        bne.s    loc_17010
        move.b    #6,(a1)
        addq.b    #1,1(a1)
        cmpi.b    #$C,1(a1)
        bne.s    loc_17010
        move.w    #-1,(a1)
        move.w    #0,-2(a2)
        subq.w    #1,($FFFFEF80).w
    
    loc_17010:
        dbf    d1,loc_16FE8
    
    loc_17014:
        movea.l    ($FFFFE800+Rings_Space).w,a1
        movea.w    ($FFFFF7A2).w,a2
        move.w    ($FFFFF700).w,d4
        subq.w    #8,d4
        bhi.s    loc_17028
        moveq    #1,d4
        bra.s    loc_17028
    ; ===========================================================================
    
    loc_17024:
        addq.w    #4,a1
        addq.w    #2,a2
    
    loc_17028:
        cmp.w    (a1),d4
        bhi.s    loc_17024
        bra.s    loc_17032
    ; ===========================================================================
    
    loc_17030:
        subq.w    #4,a1
        subq.w    #2,a2
    
    loc_17032:
        cmp.w    -4(a1),d4
        bls.s    loc_17030
        move.l    a1,($FFFFE800+Rings_Space).w
        move.w    a2,($FFFFF7A2).w
        movea.l    ($FFFFE800+Rings_Space+4).w,a2
        addi.w    #$150,d4
        bra.s    loc_1704A
    ; ===========================================================================
    
    loc_17046:
        addq.w    #4,a2
    
    loc_1704A:
        cmp.w    (a2),d4
        bhi.s    loc_17046
        bra.s    loc_17054
    ; ===========================================================================
    
    loc_17052:
        subq.w    #4,a2
    
    loc_17054:
        cmp.w    -4(a2),d4
        bls.s    loc_17052
        move.l    a2,($FFFFE800+Rings_Space+4).w
        rts
    ; ===========================================================================
    
    Touch_Rings:
        movea.l    ($FFFFE800+Rings_Space).w,a1
        movea.l    ($FFFFE800+Rings_Space+4).w,a2
    
    loc_170D0:
        cmpa.l    a1,a2
        beq.w    return_17166
        movea.w    ($FFFFF7A2).w,a4
        cmpi.w    #$5A,$30(a0)
        bcc.w    return_17166
        cmpi.b    #1,($FFFFFE2C).w    ; does Sonic have a lightning shield?
        bne.s    Touch_Rings_NoAttraction    ; if not, branch
        move.w    8(a0),d2
        move.w    $C(a0),d3
        subi.w    #$40,d2
        subi.w    #$40,d3
        move.w    #6,d1
        move.w    #$C,d6
        move.w    #$80,d4
        move.w    #$80,d5
        bra.s    loc_17112
    ; ===========================================================================
       
    Touch_Rings_NoAttraction:
        move.w    8(a0),d2
        move.w    $C(a0),d3
        subi.w    #8,d2
        moveq    #0,d5
        move.b    $16(a0),d5
        subq.b    #3,d5
        sub.w    d5,d3
        cmpi.b    #$4D,4(a0)
        bne.s    loc_17111
        addi.w    #$C,d3
        moveq    #$A,d5
    
    loc_17111:
        move.w    #6,d1
        move.w    #$C,d6
        move.w    #$10,d4
        add.w    d5,d5
    
    loc_17112:
        tst.w    (a4)
        bne.w    loc_1715C
        move.w    (a1),d0
        sub.w    d1,d0
        sub.w    d2,d0
        bcc.s    loc_1712A
        add.w    d6,d0
        bcs.s    loc_17130
        bra.w    loc_1715C
    ; ===========================================================================
    
    loc_1712A:
        cmp.w    d4,d0
        bhi.w    loc_1715C
    
    loc_17130:
        move.w    2(a1),d0
        sub.w    d1,d0
        sub.w    d3,d0
        bcc.s    loc_17142
        add.w    d6,d0
        bcs.s    loc_17148
        bra.w    loc_1715C
    ; ===========================================================================
    
    loc_17142:
        cmp.w    d5,d0
        bhi.w    loc_1715C
    
    loc_17148:
        btst    #5,$2B(a0)
        bne.s    AttractRing
       
    loc_17148_cont:
        move.w    #$608,(a4)
        bsr.s    loc_17168
        lea    ($FFFFEF82).w,a3
    
    loc_17152:
        tst.w    (a3)+
        bne.s    loc_17152
        move.w    a4,-(a3)
        addq.w    #1,($FFFFEF80).w
    
    loc_1715C:
        addq.w    #4,a1
        addq.w    #2,a4
        cmpa.l    a1,a2
        bne.w    loc_17112
    
    return_17166:
        rts
    ; ===========================================================================
    
    loc_17168:
        subq.w    #1,($FFFFF712).w
        bra.w    CollectRing
    ; ===========================================================================
    
    AttractRing:
        movea.l    a1,a3
        jsr    SingleObjLoad
        bne.w    AttractRing_NoFreeSlot
        move.b    #$4C,(a1)
        move.w    (a3),8(a1)
        move.w    2(a3),$C(a1)
    ;    move.w    a0,parent(a1)
        move.w    #-1,(a4)
        rts   
    ; ===========================================================================
       
    AttractRing_NoFreeSlot:
        movea.l    a3,a1
        bra.s    loc_17148_cont
    ; ===========================================================================
    
    BuildRings:
        movea.l    ($FFFFE800+Rings_Space).w,a0
        move.l    ($FFFFE800+Rings_Space+4).w,d7
        sub.l    a0,d7
        bne.s    loc_17186
        rts
    ; ===========================================================================
    
    loc_17186:
        movea.w    ($FFFFF7A2).w,a4
        lea    ($FFFFF700).w,a3
    
    loc_1718A:
        tst.w    (a4)+
        bmi.w    loc_171EC
        move.w    (a0),d3
        sub.w    (a3),d3
        addi.w    #$80,d3
        move.w    2(a0),d2
        sub.w    4(a3),d2
        andi.w    #$7FF,d2
        addi.w    #8,d2
        bmi.s    loc_171EC
        cmpi.w    #$F0,d2
        bge.s    loc_171EC
        addi.w    #$78,d2
        lea    (Map_Obj25).l,a1
        moveq    #0,d1
        move.b    -1(a4),d1
        bne.s    loc_171C8
        move.b    ($FFFFFEC3).w,d1
    
    loc_171C8:
        add.w    d1,d1
        adda.w    (a1,d1.w),a1
        moveq    #$00,d1                    ; MJ: clear d1 (because of our byte to word change)
        move.b    (a1)+,d1
        subq.b    #1,d1
        bmi.s    loc_171EC
        move.b    (a1)+,d0
        ext.w    d0
        add.w    d2,d0
        move.w    d0,(a2)+
        move.b    (a1)+,(a2)+
        addq.b    #1,d5
        move.b    d5,(a2)+
        move.b    (a1)+,d0
        lsl.w    #8,d0
        move.b    (a1)+,d0
        addi.w    #$247C,d0
        move.w    d0,(a2)+
        move.b    (a1)+,d0
        ext.w    d0
        add.w    d3,d0
        move.w    d0,(a2)+
    
    loc_171EC:
        addq.w    #4,a0
        subq.w    #4,d7
        bne.s    loc_1718A
        rts
    ; ===========================================================================
    
    RingsManager_Setup:
        lea    ($FFFFE800).w,a1
        moveq    #0,d0
        move.w    #Rings_Space/4-1,d1
    
    loc_172AE:                ; CODE XREF: h+33Cj
        move.l    d0,(a1)+
        dbf    d1,loc_172AE
    
        lea    ($FFFFEF80).w,a1
        move.w    #$1F,d1
    
    loc_172AF:
        move.l    d0,(a1)+
        dbf    d1,loc_172AF
    
        moveq    #0,d5
        moveq    #0,d0
        move.w    ($FFFFFE10).w,d0
        lsl.b    #6,d0
        lsr.w    #4,d0
        lea    (RingPos_Index).l,a1
        move.w    (a1,d0.w),d0
        lea    (a1,d0.w),a1
        move.l    a1,($FFFFE800+Rings_Space).w
        addq.w    #4,a1
        moveq    #0,d5
        move.w    #(Max_Rings-1),d0
    
    loc_172B0:
        tst.l    (a1)+
        bmi.s    loc_172B1
        addq.w    #1,d5
        dbf    d0,loc_172B0
    
    loc_172B1:
        move.w    d5,($FFFFF712).w
        move.w    #0,($FFFFF716).w    ; no idea what this is
        rts
     
  17. Devon

    Devon Down you're going... down you're going... Member

    Joined:
    Aug 26, 2013
    Messages:
    1,372
    Location:
    your mom
    If you are trying to add groups of rings (what I mean by that is that in S1, you could add a row of rings as 1 object in the object data, and Obj25 would create more ring objects to make the row when it's loaded), then use the tool I mentioned countless times to split them into individual rings. When I ported it, I forgot to split the groups, and that caused the repeating problem to happen.
     
    ProjectFM likes this.
  18. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    I'm using Sonic 3's ring format and the problem still occurs. It's obviously not the problem. Also, to be more descriptive of the problem, the garbage rings can't be collected and sometimes use single frames, and sometimes odd mappings with the wrong palette.

    I'm sorry for the confusion. The earlier post where I said thanks was for the idea that rings could be ported from object format to S3 ring format using MainMemory's Level Converter.
     
  19. LuigiXHero

    LuigiXHero Well-Known Member Member

    Joined:
    Mar 22, 2014
    Messages:
    280
    Dude it wouldn't hurt to at least try what ralakimus is suggesting. He had the same exact problem when he first ported the ring manager (I was there) and he fixed it via the way he is saying.
     
    TheInvisibleSun, Devon and ProjectFM like this.
  20. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    Holy crap it worked!

    Anyway, Ralakimus, I owe you a big apology for my stubbornness. I assumed that SonLVL would do everything correctly and that you were talking about a different yet similar problem. I thought I knew everything and I didn't and that's a problem I have that I'm working to improve.

    And thanks, LuigiXHero, for backing him up.
     
    LuigiXHero and Devon like this.