Basic Questions and Answers Thread

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

  1. AURORA☆FIELDS

    AURORA☆FIELDS so uh yes Exiled

    Joined:
    Oct 7, 2011
    Messages:
    759
    It depends how you want to implement it. If you want when you once collect it it stays and you cant collect it more, then what Calvin suggested is a working method. If you want to lose the emeralds, you could save a variable at beginning of the level of how many emeralds you had, and if you die, the amount you currently have would be reset to the value in this variable
     
    Niko likes this.
  2. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Hello, where is the routine of when Sonic restart the level after he dies?
    I don't find it.
     
  3. Ziro_

    Ziro_ Mentally Skewed Member

    Joined:
    Aug 1, 2016
    Messages:
    59
    Location:
    What are you a cop
    EDIT -- Delete this post as it is no longer needed.
     
    Last edited: Oct 12, 2016
  4. Soldaten

    Soldaten The Coilgun Root Admin

    Joined:
    Mar 10, 2016
    Messages:
    268
    Last edited: Oct 12, 2016
    Clownacy likes this.
  5. TheInvisibleSun

    TheInvisibleSun Visible Member

    Joined:
    Jul 2, 2013
    Messages:
    424
    Location:
    Western New York, USA
    You're probably over thinking this. Where did you already check? The answer is much easier to search for and find than you probably think, especially if you're using the Git disassembly (this is for Sonic 1 right?). I'll give a hint though; there is a flag that is set that controls whether the level is due to restart. Try checking where it gets used in the existing game. Good Luck!
     
  6. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Fixed. Thank you anyway.
     
  7. Ziro_

    Ziro_ Mentally Skewed Member

    Joined:
    Aug 1, 2016
    Messages:
    59
    Location:
    What are you a cop
    Even after googleing the question I had before I was unable to figure out how to add the variable. What I am trying to do is have the end of act subroutine update a variable(That I am still unsure of how to make) with the number of emeralds you have successfully obtained without dying in that level and have the game start with that amount next level and still retain that after you died in the next level.

    If you are replying to me learn asm. (I am) I just don't understand every single part of it. I understand what some of the commands do but not all of them. The only way for me to learn is to find a resource that lets me learn. And because I could not find one that worked for me I am asking for help so I can learn and not so I can just rip the code and go on with my day without learning something. If someone has a resource that could help me learn about the thing I am trying to learn above please respond with it because I could not find one on google or in MarkeyJester's asm guide that would help me with what I need help with.
     
    Last edited: Oct 12, 2016
  8. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Everyone here repeated to me: Learn about ASM.
    I think it also applies to you?
     
  9. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,020
    Why not just, I dunno, look at how all the other variables are defined?
     
    Pacca, breakthetargets and Soldaten like this.
  10. Ziro_

    Ziro_ Mentally Skewed Member

    Joined:
    Aug 1, 2016
    Messages:
    59
    Location:
    What are you a cop
    I tried to none of the variables that I could fine have a pattern that I could understand how they are formed or edited.
     
  11. TheInvisibleSun

    TheInvisibleSun Visible Member

    Joined:
    Jul 2, 2013
    Messages:
    424
    Location:
    Western New York, USA
    It's much simpler than you might think (I honestly over thought this myself, when I figured it out). Looking at the existing variable list (in the file variables.asm, for Git Sonic 1), just do as the other ones do, but simply use a name that's unique (v_something), and equate it to an unused ram address (if you search on these forums, there's a post that lists every unused ram address). That's it! Then be sure to leave a comment to the right of the semicolon so you remember what it does, or what it's for. I suggest looking up why you should be careful with odd numbered addresses though, as hardware doesn't like those sometimes.
     
    Last edited: Oct 12, 2016
  12. Ziro_

    Ziro_ Mentally Skewed Member

    Joined:
    Aug 1, 2016
    Messages:
    59
    Location:
    What are you a cop
    I found a way that might work without the use of variables but it is currently not working. I will attach the rom below because I cannot explain in words what is happening. In the rom when you collect the emerald monitors and die it resets to zero. After resetting to zero collect the emerald monitors again and kill sonic they will change to a weird value. I edited the killsonic subroutine to subtract the emeralds collected in that level. The emeralds address is now being used to count the emeralds collected in that level and is supposed to clear at death and going to the next level.


    Kill sonic
    Code:
    ; ---------------------------------------------------------------------------
    ; Subroutine to    kill Sonic
    ; ---------------------------------------------------------------------------
    
    ; ||||||||||||||| S U B    R O U T    I N E |||||||||||||||||||||||||||||||||||||||
    
    
    KillSonic:
            tst.w    ($FFFFFE08).w    ; is debug mode    active?
            bne.w    Kill_NoDeath    ; if yes, branch
            move.b    #0,($FFFFFE2D).w ; remove invincibility
            move.b    #6,$24(a0)
            bsr.w    Sonic_ResetOnFloor
            bset    #1,$22(a0)
            move.w    #-$700,$12(a0)
            move.w    #0,$10(a0)
            move.w    #0,$14(a0)
            move.w    $C(a0),$38(a0)
            move.b    #$18,$1C(a0)
            bset    #7,2(a0)
            cmpi.b    #7,($FFFFFE57).w ; do you have all emeralds?
            beq.w    emerald7death    ; if yes, branch
            cmpi.b    #6,($FFFFFE57).w ; do you have all emeralds?
            beq.w    emerald6death    ; if yes, branch
            cmpi.b    #5,($FFFFFE57).w ; do you have all emeralds?
            beq.w    emerald5death    ; if yes, branch
            cmpi.b    #4,($FFFFFE57).w ; do you have all emeralds?
            beq.w    emerald4death    ; if yes, branch
            cmpi.b    #3,($FFFFFE57).w ; do you have all emeralds?
            beq.w    emerald3death    ; if yes, branch
            cmpi.b    #2,($FFFFFE57).w ; do you have all emeralds?
            beq.w    emerald2death    ; if yes, branch
            cmpi.b    #1,($FFFFFE57).w ; do you have all emeralds?
            beq.w    emerald1death    ; if yes, branch
            move.w    #$A3,d0        ; play normal death sound
            cmpi.b    #$36,(a2)    ; check    if you were killed by spikes
            bne.w    Kill_Sound
            move.w    #$A6,d0        ; play spikes death sound
            
    emerald7death:
            subq.b    #7,($FFFFFE12).w
            subq.b    #7,($FFFFFE1C).w
            move.w    #$A3,d0        ; play normal death sound
            cmpi.b    #$36,(a2)    ; check    if you were killed by spikes
            bne.w    Kill_Sound
            move.w    #$A6,d0        ; play spikes death sound
            move.b    #0,($FFFFFE57).w ; clear emeralds
    emerald6death:
            subq.b    #6,($FFFFFE12).w
            subq.b    #6,($FFFFFE1C).w
            move.w    #$A3,d0        ; play normal death sound
            cmpi.b    #$36,(a2)    ; check    if you were killed by spikes
            bne.w    Kill_Sound
            move.w    #$A6,d0        ; play spikes death sound
            move.b    #0,($FFFFFE57).w ; clear emeralds       
    emerald5death:
            subq.b    #5,($FFFFFE12).w
            subq.b    #5,($FFFFFE1C).w
            move.w    #$A3,d0        ; play normal death sound
            cmpi.b    #$36,(a2)    ; check    if you were killed by spikes
            bne.w    Kill_Sound
            move.w    #$A6,d0        ; play spikes death sound
            move.b    #0,($FFFFFE57).w ; clear emeralds
    emerald4death:
            subq.b    #4,($FFFFFE12).w
            subq.b    #4,($FFFFFE1C).w
            move.w    #$A3,d0        ; play normal death sound
            cmpi.b    #$36,(a2)    ; check    if you were killed by spikes
            bne.w    Kill_Sound
            move.w    #$A6,d0        ; play spikes death sound
            move.b    #0,($FFFFFE57).w ; clear emeralds
    emerald3death:
            subq.b    #3,($FFFFFE12).w
            subq.b    #3,($FFFFFE1C).w
            move.w    #$A3,d0        ; play normal death sound
            cmpi.b    #$36,(a2)    ; check    if you were killed by spikes
            bne.w    Kill_Sound
            move.w    #$A6,d0        ; play spikes death sound
            move.b    #0,($FFFFFE57).w ; clear emeralds
    emerald2death:
            subq.b    #2,($FFFFFE12).w
            subq.b    #2,($FFFFFE1C).w
            move.w    #$A3,d0        ; play normal death sound
            cmpi.b    #$36,(a2)    ; check    if you were killed by spikes
            bne.w    Kill_Sound
            move.w    #$A6,d0        ; play spikes death sound
            move.b    #0,($FFFFFE57).w ; clear emeralds
    emerald1death:
            subq.b    #1,($FFFFFE12).w
            subq.b    #1,($FFFFFE1C).w
            move.w    #$A3,d0        ; play normal death sound
            cmpi.b    #$36,(a2)    ; check    if you were killed by spikes
            bne.w    Kill_Sound
            move.w    #$A6,d0        ; play spikes death sound
            move.b    #0,($FFFFFE57).w ; clear emeralds
    
    Kill_Sound:
            jsr    (PlaySound_Special).l
            
    
    Kill_NoDeath:
            moveq    #-1,d0
            rts   
    ; End of function KillSonic
    emerald monitor code
    Code:
    Obj2E_ChkSonic:
            cmpi.b    #2,d0        ; does monitor contain Sonic?
            bne.s    Obj2E_ChkShoes
            addi.b    #1,($FFFFFE57).w ; do you have all emeralds?
            jmp    Obj09_Get1Up
    
    ExtraLife:
            addq.b    #1,($FFFFFE12).w ; add 1 to the    number of lives    you have
            addq.b    #1,($FFFFFE1C).w ; add 1 to the    lives counter
            move.w    #$88,d0
            jmp    (PlaySound).l    ; play extra life music
    ; ===========================================================================
     

    Attached Files:

  13. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,020
    It probably has something to do with the fact your code doesn't use branches to exit the little if/else chain you have going on.
     
  14. Ziro_

    Ziro_ Mentally Skewed Member

    Joined:
    Aug 1, 2016
    Messages:
    59
    Location:
    What are you a cop
    How should I make it exit with branches because I am unsure of how it would help it?
     
  15. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,020
    Code:
    emerald7death:
           subq.b    #7,($FFFFFE12).w
            subq.b    #7,($FFFFFE1C).w
            move.w    #$A3,d0        ; play normal death sound
            cmpi.b    #$36,(a2)    ; check    if you were killed by spikes
            bne.w    Kill_Sound
            move.w    #$A6,d0        ; play spikes death sound
            move.b    #0,($FFFFFE57).w ; clear emeralds
    emerald6death:
            subq.b    #6,($FFFFFE12).w
            subq.b    #6,($FFFFFE1C).w
            move.w    #$A3,d0        ; play normal death sound
            cmpi.b    #$36,(a2)    ; check    if you were killed by spikes
            bne.w    Kill_Sound
            move.w    #$A6,d0        ; play spikes death sound
            move.b    #0,($FFFFFE57).w ; clear emeralds
    One of the most basic concepts in programming: the instructions are executed from top to bottom, that is, unless something changes where the CPU looks for code. Branch instructions do that. Can you seriously not see how the code after emerald6death would start executing as soon as emerald7death's instructions as done?
     
    Last edited: Oct 12, 2016
    Soldaten likes this.
  16. Ziro_

    Ziro_ Mentally Skewed Member

    Joined:
    Aug 1, 2016
    Messages:
    59
    Location:
    What are you a cop
    I tried that with an rts wouldn't it return to start of the routine and do the same job?
     
  17. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,020
    Branch instruction.
     
  18. Ziro_

    Ziro_ Mentally Skewed Member

    Joined:
    Aug 1, 2016
    Messages:
    59
    Location:
    What are you a cop
    I branched it it and it stops working after 1 clear. Am I doing something wrong.

    Code:
    KillSonic:
            tst.w    ($FFFFFE08).w    ; is debug mode    active?
            bne.w    Kill_NoDeath    ; if yes, branch
            move.b    #0,($FFFFFE2D).w ; remove invincibility
            move.b    #6,$24(a0)
            bsr.w    Sonic_ResetOnFloor
            bset    #1,$22(a0)
            move.w    #-$700,$12(a0)
            move.w    #0,$10(a0)
            move.w    #0,$14(a0)
            move.w    $C(a0),$38(a0)
            move.b    #$18,$1C(a0)
            bset    #7,2(a0)
            cmpi.b    #7,($FFFFFE57).w ; do you have all emeralds?
            beq.w    emerald7death    ; if yes, branch
            cmpi.b    #6,($FFFFFE57).w ; do you have all emeralds?
            beq.w    emerald6death    ; if yes, branch
            cmpi.b    #5,($FFFFFE57).w ; do you have all emeralds?
            beq.w    emerald5death    ; if yes, branch
            cmpi.b    #4,($FFFFFE57).w ; do you have all emeralds?
            beq.w    emerald4death    ; if yes, branch
            cmpi.b    #3,($FFFFFE57).w ; do you have all emeralds?
            beq.w    emerald3death    ; if yes, branch
            cmpi.b    #2,($FFFFFE57).w ; do you have all emeralds?
            beq.w    emerald2death    ; if yes, branch
            cmpi.b    #1,($FFFFFE57).w ; do you have all emeralds?
            beq.w    emerald1death    ; if yes, branch
            move.w    #$A3,d0        ; play normal death sound
            cmpi.b    #$36,(a2)    ; check    if you were killed by spikes
            bne.w    Kill_Sound
            move.w    #$A6,d0        ; play spikes death sound
            jmp        touch_special
            
    emerald7death:
            subq.b    #7,($FFFFFE12).w
            subq.b    #7,($FFFFFE1C).w
            move.w    #$A3,d0        ; play normal death sound
            cmpi.b    #$36,(a2)    ; check    if you were killed by spikes
            bne.w    Kill_Sound
            move.w    #$A6,d0        ; play spikes death sound
            move.b    d0,($FFFFFE57).w ; clear emeralds
            move.l    d0,($FFFFFE58).w ; clear emeralds
            move.l    d0,($FFFFFE5C).w ; clear emeralds
            tst.w    ($FFFFFE57).w
            bra.w    touch_special
    emerald6death:
            subq.b    #6,($FFFFFE12).w
            subq.b    #6,($FFFFFE1C).w
            move.w    #$A3,d0        ; play normal death sound
            cmpi.b    #$36,(a2)    ; check    if you were killed by spikes
            bne.w    Kill_Sound
            move.w    #$A6,d0        ; play spikes death sound
            move.b    d0,($FFFFFE57).w ; clear emeralds
            move.l    d0,($FFFFFE58).w ; clear emeralds
            move.l    d0,($FFFFFE5C).w ; clear emeralds
            tst.w    ($FFFFFE57).w
            bra.w    touch_special
    emerald5death:
            subq.b    #5,($FFFFFE12).w
            subq.b    #5,($FFFFFE1C).w
            move.w    #$A3,d0        ; play normal death sound
            cmpi.b    #$36,(a2)    ; check    if you were killed by spikes
            bne.w    Kill_Sound
            move.w    #$A6,d0        ; play spikes death sound
            move.b    d0,($FFFFFE57).w ; clear emeralds
            move.l    d0,($FFFFFE58).w ; clear emeralds
            move.l    d0,($FFFFFE5C).w ; clear emeralds
            tst.w    ($FFFFFE57).w
            bra.w    touch_special
    emerald4death:
            subq.b    #4,($FFFFFE12).w
            subq.b    #4,($FFFFFE1C).w
            move.w    #$A3,d0        ; play normal death sound
            cmpi.b    #$36,(a2)    ; check    if you were killed by spikes
            bne.w    Kill_Sound
            move.w    #$A6,d0        ; play spikes death sound
            move.b    d0,($FFFFFE57).w ; clear emeralds
            move.l    d0,($FFFFFE58).w ; clear emeralds
            move.l    d0,($FFFFFE5C).w ; clear emeralds
            tst.w    ($FFFFFE57).w
            bra.w    touch_special
    emerald3death:
            subq.b    #3,($FFFFFE12).w
            subq.b    #3,($FFFFFE1C).w
            move.w    #$A3,d0        ; play normal death sound
            cmpi.b    #$36,(a2)    ; check    if you were killed by spikes
            bne.w    Kill_Sound
            move.w    #$A6,d0        ; play spikes death sound
            move.b    d0,($FFFFFE57).w ; clear emeralds
            move.l    d0,($FFFFFE58).w ; clear emeralds
            move.l    d0,($FFFFFE5C).w ; clear emeralds
            tst.w    ($FFFFFE57).w
            bra.w    touch_special
    emerald2death:
            subq.b    #2,($FFFFFE12).w
            subq.b    #2,($FFFFFE1C).w
            move.w    #$A3,d0        ; play normal death sound
            cmpi.b    #$36,(a2)    ; check    if you were killed by spikes
            bne.w    Kill_Sound
            move.w    #$A6,d0        ; play spikes death sound
            move.b    d0,($FFFFFE57).w ; clear emeralds
            move.l    d0,($FFFFFE58).w ; clear emeralds
            move.l    d0,($FFFFFE5C).w ; clear emeralds
            tst.w    ($FFFFFE57).w
            bra.w    touch_special
    emerald1death:
            subq.b    #1,($FFFFFE12).w
            subq.b    #1,($FFFFFE1C).w
            move.w    #$A3,d0        ; play normal death sound
            cmpi.b    #$36,(a2)    ; check    if you were killed by spikes
            bne.w    Kill_Sound
            move.w    #$A6,d0        ; play spikes death sound
            move.b    d0,($FFFFFE57).w ; clear emeralds
            move.l    d0,($FFFFFE58).w ; clear emeralds
            move.l    d0,($FFFFFE5C).w ; clear emeralds
            tst.w    ($FFFFFE57).w
            bra.w    touch_special
    
    Kill_Sound:
            jsr    (PlaySound_Special).l
            
    
    Kill_NoDeath:
            moveq    #-1,d0
            rts   
    ; End of function KillSonic
     
  19. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,020
    ...I see you're 'clearing' the emeralds with the value '$A6'. That's probably meant to be a 0. Also, aren't you meant to be branching to Kill_Sound instead of touch_special?
     
  20. Ziro_

    Ziro_ Mentally Skewed Member

    Joined:
    Aug 1, 2016
    Messages:
    59
    Location:
    What are you a cop
    I branched it back to killsound is there something better I should be doing like clearing it to a different value.

    Edit: I got it to work for the most part thanks Clownacy and Calvin.;)

    EDIT2: Never mind when I die with Zero emeralds the counter I assume is trying to go into the negatives. What can I do???
     
    Last edited: Oct 12, 2016
    Niko likes this.