Basic Questions and Answers Thread

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

  1. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,016
    I could be miles off, but I think I got that S3K behavior in my S2 hack when I ported S3K's Sonic object, so the code responsible should be in there somewhere. Sonic_LevelBounds, maybe?
     
    Ashuro likes this.
  2. Baraksha

    Baraksha Well-Known Member Member

    Joined:
    Dec 23, 2015
    Messages:
    99
    ok, so I am currently trying to make sonic have another level of speed kind of like in sonic CD where if sonic is fast enough he uses the peel out sprites but doesn't achieve it by running on flat ground long enough enough. I know what you guys told me about the Running and Walking being Hard Coded, but I herd this is easy to do. so far I got the animation made but now I noticed something about Sonic 1 that I seem to have missed, unlike it's squeals sonic doesn't not accelerate when running down hills, he goes the same speed as he does on flat ground, you can only accelerate by rolling. so, is it as easy as people say it is or do I need to try and implement sonic 2's acceleration and then set the faster running animation to a certain speed?
     
  3. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    415
    Ashuro, setting memory byte $FFFFF7AA to any non-zero value will lock screen's right boundary, as seen in this bit of Sonic_LevelBound code (just where Clownacy told you to look at):
    Code:
            move.w  ($FFFFF72A).w,d0        ; load camera's right boundary
            addi.w  #$128,d0                ; add 296 pixels to it (which is 320-24)
            tst.b   ($FFFFF7AA).w           ; is right boundary lock active?
            bne.s   loc_13332               ; if yes, branch
            addi.w  #$40,d0                 ; if not, add 64 additional pixels to allow Sonic go off-screen
    loc_13332:
    
    Notice the last line of code. If flag is not set, the boundary is extended by 64 pixels, allowing Sonic to go to that red area seen on your illustration.
    Flag $FFFFF7AA is usually used during boss battles.
     
    Ashuro likes this.
  4. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Thank you Clown, thank you Vlad! :)
     
  5. Devon

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

    Joined:
    Aug 26, 2013
    Messages:
    1,372
    Location:
    your mom
    $FFFFF7AA is referred to as the "lock screen" flag in the modern disassemblies (I don't know if the variable name was changed since I last checked), which is incorrect, because it doesn't lock the screen, but rather keeps Sonic from going offscreen on the right level boundary when set, as Vladikcomper said.
     
    Ashuro likes this.
  6. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,016
    Ah, interesting. I was doing some boss work earlier, and wondering why that flag didn't work. I'll update the Git disasms when I get the chance.
     
  7. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    I have found a solution, at this line:
    addi.w #$40,d0 ; if not, add 64 additional pixels to allow Sonic go off-screen

    and replaced by this:


    addi.w #$1,d0 ; if not, add 64 additional pixels to allow Sonic go off-screen

    And finally it's done! :)
     
  8. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    415
    Ashuro, I much simpler (and flexible) solution would be just to set flag $FFFFF7AA where appropriate, for example:
    Code:
        st.b  $FFFFF7AA    ; set flag to $FF
    Thus, the branch in the code I showed above would work by default, completely bypassing that "add.w #$40,d0" instruction.

    In case you don't need the ability to go off-screen at all, you might just remove this entire bit:
    Code:
           tst.b   ($FFFFF7AA).w           ; is right boundary lock active?
            bne.s   loc_13332               ; if yes, branch
            addi.w  #$40,d0                 ; if not, add 64 additional pixels to allow Sonic go off-screen
    loc_13332:
     
    Ashuro likes this.
  9. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Tested and it's done! I use the $F7AA flag now and it's much simpler, right!
    I have tested it before but in the wrong way.
    Thank you!
    And last question, if i want to make a cinematic, i need a control lock flag, but what is the better:

    $F7C8 or $F7CC?
     
  10. TheStoneBanana

    TheStoneBanana banana Member

    Joined:
    Nov 27, 2013
    Messages:
    602
    Location:
    The Milky Way Galaxy
    $FFFFF7C8 locks Sonic's control and position, while $FFFFF7CC just locks his controls.
    So... that said, I think $FFFFF7CC is what you want.
     
    vladikcomper likes this.
  11. Baraksha

    Baraksha Well-Known Member Member

    Joined:
    Dec 23, 2015
    Messages:
    99
    Ok, I eventually was able to figure out how to make my FasterRun sprites react to when sonic goes at a speed of $700, however like I said in sonic 1 sonic does not accelerate when running down hills and so this speed is only achievable through Speed Shoes or through red spring. so now my main thing I want to do is to make sonic accelerate while running down hills like in sonic 2 and 3.
     
  12. Soldaten

    Soldaten The Coilgun Root Admin

    Joined:
    Mar 10, 2016
    Messages:
    267
  13. Baraksha

    Baraksha Well-Known Member Member

    Joined:
    Dec 23, 2015
    Messages:
    99
    Soldaten likes this.
  14. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    When the level start, i want Sonic to run to the right instead of use his "standing" animation (like Sonic in Sunny Shore's Megamix).
    I have searched at "Level:" but my changes doesn't do anything. And when i want Sonic to fall at the begining, i place Sonic at the top of the level, and when the titlecard disapear, he fall in his standing animation but i want to put a custom animation.
    Where do i have to look for these things?
     
  15. AURORA☆FIELDS

    AURORA☆FIELDS so uh yes Exiled

    Joined:
    Oct 7, 2011
    Messages:
    759
    You have to insert a custom code to set few variables to get custom animations and the like working. S3K's solution to this is instead of just loading Sonic, it will have another routine to load him (or Tails/Knuckles) and depending on the level it may also change some things. This is a simple level and act ID check, and branch after the code if different level.
     
    Pacca and Ashuro like this.
  16. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    And there is a particular routine where I can create my code?
    Or i can create it anywhere in the rom?
    Because I can not find the routine that loads Sonic in the level. (or i looked in the wrong place?).
    Code:
    loc_3946:
            moveq    #3,d0
            bsr.w    PalLoad1    ; load Sonic's pallet line
            bsr.w    LevelSizeLoad
            bsr.w    DeformBgLayer
            bset    #2,($FFFFF754).w
            bsr.w    MainLoadBlockLoad ; load block mappings    and pallets
            bsr.w    LoadTilesFromStart
            jsr    FloorLog_Unk
            bsr.w    ColIndexLoad
            bsr.w    LZWaterEffects
            move.b    #1,($FFFFD000).w ; load    Sonic object
            btst      #1,$22(a0) ;if sonic is in the air?
            bne.s     loc2_3946
            move.w     #$1B,$2A(a0)
           
    loc2_3946:
            tst.w    ($FFFFFFF0).w
            bmi.s    Level_ChkDebug
            move.b    #$21,($FFFFD040).w ; load HUD object
    ....
    This is it?
    It's under "Level:"

    EDIT:

    I have doing this:


    Code:
    loc_3946:
            moveq    #3,d0
            bsr.w    PalLoad1    ; load Sonic's pallet line
            bsr.w    LevelSizeLoad
            bsr.w    DeformBgLayer
            bset    #2,($FFFFF754).w
            bsr.w    MainLoadBlockLoad ; load block mappings    and pallets
            bsr.w    LoadTilesFromStart
            jsr    FloorLog_Unk
            bsr.w    ColIndexLoad
            bsr.w    LZWaterEffects
            move.b    #1,($FFFFD000).w ; load    Sonic object
            cmpi.w     #$001,($FFFFFE10).w ; if Green Hill Zone act 2?
            bge.s     loc_3946_cont     ; branch if equal or greater
            move.w    #$900,($FFFFD014).w         ; make sonic run at $0900 speed
            
    loc_3946_cont:
            btst      #1,$22(a0) ;if sonic is in the air?
            bne.s     loc2_3946
            move.w     #$1B,$2A(a0)
    ...
    
    And the result is well good.
     
    Last edited: Oct 1, 2016
  17. AURORA☆FIELDS

    AURORA☆FIELDS so uh yes Exiled

    Joined:
    Oct 7, 2011
    Messages:
    759
    You could create your own routine for this and replace "load Sonic object" with a call to this routine, but if you just are gonna use one or two levels this wont be beneficial really.
     
    Ashuro likes this.
  18. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Oh yes! Thanks Natsumi!

    EDIT: All works... Instead of the "in air" animation.

    I have doing this:
    Code:
    SonIntro2:
            ;btst     #1,$22(a0) ; if sonic is in the air?
            ;bne.s     loc2_3946
            ;move.w     #$20,$1C(a0) ; set Fall animation
            btst     #2,$22(a0) ; if in the air?
            bne.s     loc2_3946
            move.w     #$20,$1C(a0) ; set Fall animation
    ....
    I have tried the first obstatut, but do not still work, so i have commented it, and the second obstatut do not work too.
    Sonic still fall like this:
    Sans titre.png
     
    Last edited: Oct 1, 2016
  19. GenesisDoes

    GenesisDoes What Nintendont Member

    Joined:
    Jan 2, 2016
    Messages:
    159
    Location:
    Pittsburgh, PA
    As part of my hack, I modified the special stage layout loading routine in Sonic 1 after hitting a Big Ring to load normal platforming levels from a LUT instead of rotating level layouts. Everything works rather fine, except the game crashes when attempting to fetch the zone for the 6th special stage, because it somehow fetches a large, invalid zone ID according to a RAM watch in Gens. In a perfect game (no failed Special Stages), v_lastspecial = $04 before entering the final big ring and the game crashes.

    Anyone see anything wrong with the modified routine posted below?


    Code:
    ; ---------------------------------------------------------------------------
    ; Subroutine to    load special stage layout
    ; ---------------------------------------------------------------------------
    
    ; ||||||||||||||| S U B    R O U T    I N E |||||||||||||||||||||||||||||||||||||||
    
    ;!@Special Stage
    ;Modified SS_Load routine
    ;Loads special stage zone into v_zone
    SS_Load:
            moveq    #0,d0
            move.b    (v_lastspecial).w,d0     ; load number of last special stage entered
            addq.b    #1,(v_lastspecial).w    ; Increment special stage zone
            cmpi.b    #6,(v_lastspecial).w
            blo.s    SS_ChkEmldNum
            move.b    #0,(v_lastspecial).w ; reset if higher than 6
    
    SS_ChkEmldNum:
            cmpi.b    #6,(v_emeralds).w ; do you have all emeralds?
            beq.s    SS_LoadData    ; if yes, branch
            moveq    #0,d1
            move.b    (v_emeralds).w,d1
            subq.b    #1,d1
            blo.s    SS_LoadData
            lea    (v_emldlist).w,a3 ; check which emeralds you have
    
    SS_ChkEmldLoop:   
            cmp.b    (a3,d1.w),d0
            bne.s    SS_ChkEmldRepeat
            bra.s    SS_Load
    ; ===========================================================================
    
    SS_ChkEmldRepeat:
            dbf    d1,SS_ChkEmldLoop
    
    ;!@Modified SS_LoadData simply fetches appropriate zone/act ID for the special stages from a LUT
    SS_LoadData:
            subq.b    #1,(v_lastspecial).w            ; Decrement special stage zone. This fixes an odd bug which causes lastspecial to increment by 2 instead of 1
            move.b    (v_lastspecial).w,d0             ; Load special stage # into d0
            andi.w    #7,d0
            add.w    d0,d0
            ;lsl.w    #2,d0
            move.w    LevelOrderSpecial(pc,d0.w),d0    ; load next SS level from level order array
            move.w    d0,(v_zone).w                    ; set level number
            rts
            
            ;!@Special Stage
            ;Holds special stage order.
            ;ZZAA format like with orig Level Order.
            ;7 slots for the 7 chaos emeralds. (7th stage currently unused until I modify game code to support a 7th emerald)
            LevelOrderSpecial:    incbin    "misc\Level Order Special.bin"
                even
                zonewarningnoending LevelOrder,8
    
    Contents of misc\Level Order Special.bin :
    0B 00 0B 01 04 03 0B 02 0C 00 0C 01 0C 02
     
  20. AURORA☆FIELDS

    AURORA☆FIELDS so uh yes Exiled

    Joined:
    Oct 7, 2011
    Messages:
    759
    @Ashuro You do not want to rely on object status before you actually run the object's code. The status will be 0 by default anyways. Rather you should just set the flags you want, because it really doesnt matter what it would be if you are just gonna set it.
     
    Ashuro likes this.