Basic Questions and Answers Thread

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

  1. Scrap Sorra

    Scrap Sorra Well-Known Member Member

    Joined:
    Sep 18, 2020
    Messages:
    112
    Location:
    Development Hell
    Thanks for the help! One problem though: I don't actually know where to change the palette line for the 10 ring monitor icon. I tried this but it didn't work.
    Code:
    Mon_Main:    ; Routine 0
            addq.b    #2,obRoutine(a0)
            move.b    #$E,obHeight(a0)
            move.b    #$E,obWidth(a0)
            move.l    #Map_Monitor,obMap(a0)
            cmpi.b    #6,d0
            bne.s    @notring
            move.w    #$2680,obGfx(a0)   
    @notring:       
            move.w    #$680,obGfx(a0)
            move.b    #4,obRender(a0)
            move.b    #3,obPriority(a0)
            move.b    #$F,obActWid(a0)
            lea    (v_objstate).w,a2
            moveq    #0,d0
            move.b    obRespawnNo(a0),d0
            bclr    #7,2(a2,d0.w)
            btst    #0,2(a2,d0.w)    ; has monitor been broken?
            beq.s    @notbroken    ; if not, branch
            move.b    #8,obRoutine(a0) ; run "Mon_Display" routine
            move.b    #$B,obFrame(a0)    ; use broken monitor frame
            rts    
    Is there a better way to do this?
     
  2. TheInvisibleSun

    TheInvisibleSun Visible Member

    Joined:
    Jul 2, 2013
    Messages:
    424
    Location:
    Western New York, USA
    You need another branch to skip the 'move.w #$680,obGfx(a0)'. Otherwise, it will always override your new code.

    You may want something like this:

    Code:
            cmpi.b    #6,d0
            bne.s    @notring
            move.w    #$2680,obGfx(a0)
            bra    SkipTheNextTwoLines  ;branch here regardless
    @notring:   
            move.w    #$680,obGfx(a0)
    SkipTheNextTwoLines:   ;continue here to skip the other code
            move.b    #4,obRender(a0)
            ...
     
    vladikcomper and Scrap Sorra like this.
  3. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    You didn't set d0 to the value of any variables. Assuming you are checking if the mapping frame is 6, you would replace d0 with $1A(a0).

    However, there is an easier way, and that's the fact that you can choose the palette line of any mapping piece in SonMapED and Flex 2 by selecting it and pressing the p key.
     
    Scrap Sorra and vladikcomper like this.
  4. Scrap Sorra

    Scrap Sorra Well-Known Member Member

    Joined:
    Sep 18, 2020
    Messages:
    112
    Location:
    Development Hell
    I got it to work! On another note, I'm putting Botanic Base tiles in GHZ and this requires me to change the rotating palette. I successfully disabled the rotating palette, but I need to add a new one for the waterfall tiles. How can I do that? (Palette screenshot for reference, waterfall tiles use the last 3 lines in the third palette line) upload_2020-10-26_7-55-18.png
     
    ProjectFM likes this.
  5. Scrap Sorra

    Scrap Sorra Well-Known Member Member

    Joined:
    Sep 18, 2020
    Messages:
    112
    Location:
    Development Hell
    Guess I'll ask a different question then. Okay, so I would like to disable Marble Zone's bg scroll and disable the GHZ background water effect. I've tried messing around with Deform Layers.asm and have had no results. Is there any way I can change that?
     
  6. StephenUK

    StephenUK Working on a Quackshot disassembly Member

    Joined:
    Aug 5, 2007
    Messages:
    1,026
    What you've asked for is quite a general question. I mean, you can redirect both entries in the offset table to an RTS command, which will in turn disable both the scrolling and the water effect, but I have a feeling that the result from that will not be the result you're expecting at all and will only lead to more questions. Can you be a bit clearer on what your final goal is, in which case people may be better placed to help you out better?
     
  7. Inferno

    Inferno Rom Hacker Member

    Joined:
    Oct 27, 2015
    Messages:
    132
    Location:
    Sky Base Zone, South Island
    Sorry for bothering y'all, but I've hit another brick wall.

    [​IMG]
    This is what I've dubbed the "psuedo-loopback bug". Now, this occurs no matter what when one hits 128 chunks out from the left of the level layout. The collision of what is supposed to be there applies, but the visuals have looped back around to the start of the level layout.
    For reference, this is what SonLVL shows:
    [​IMG]
    I still have yet to trace down exactly which routine causes this issue, but due to it being visual, I am guessing GetBlockData is involved. As such, I've included the full code of GetBlockData in the following spoiler:
    Code:
    GetBlockData:
            if Revision=0
            lea    (v_16x16).w,a1    ; MJ: load Block's location
            add.w    4(a3),d4    ; MJ: load Y position to d4
            add.w    (a3),d5        ; MJ: load X position to d5
            else
                add.w    (a3),d5        ; MJ: load X position to d5
        GetBlockData_2:
                add.w    4(a3),d4    ; MJ: load Y position to d4
                lea    (v_16x16).w,a1    ; MJ: load Block's location
            endc
        ; Ok, let's ensure that the conversion goes well.
        ; Register conversions:
        ; d0 (FindNearestTile) -> d3 (GetBlockData)
        ; d1 (FindNearestTile) -> d0 (GetBlockData)
        ; d2 (FindNearestTile) -> d4 (GetBlockData)
        ; d3 (FindNearestTile) -> d5 (GetBlockData)
        ; d4 (FindNearestTile) -> ??? No equalivent. (Forcing an equalivent making it fall within d1 or d2, set to d1.)
        ; a1 (FindNearestTile) -> a4 (GetBlockData)
            ; Set Y coordinate in level layout
            move.w    d4,d0        ; MJ: copy Y position to d3
            lsr.w    #5,d0
            and.w    (Layout_row_index_mask).w,d0
            movea.w    (a4,d0.w),a1       
            ; Set X coordinate in level layout
            lsr.w    #3,d5        ; MJ: divide X position by 8
            move.w    d5,d0        ; MJ: copy to d0
            lsr.w    #4,d0        ; MJ: divide by 10 (Not 20)
            andi.w    #$7F,d0
            moveq    #-1,d3        ; MJ: prepare FFFF in d3
            clr.w    d3
            ; Turn chunk ID from level layout
            move.b  (a1,d0.w),d3
            lsl.w    #7,d3        ; MJ: multiply by 80
            ; Turn Y coordinate into index into chunk
            andi.w    #$70,d4        ; MJ: keep Y pos within 80 pixels
            ; Turn X coordinate into index into chunk
            andi.w    #$E,d5        ; MJ: keep X pos within 10   
            
            ; Get chunk metadata
            add.w    d4,d3        ; MJ: add calc'd Y pos to ror'd d3
            add.w    d5,d3        ; MJ: add calc'd X pos to ror'd d3
            movea.l    d3,a0        ; MJ: set address (Chunk to read)
            move.w    (a0),d3
            lea    (v_16x16).w,a1    ; MJ: load Block's location
            ; Turn block ID into address
            andi.w    #$3FF,d3
            lsl.w    #3,d3
            adda.w    d3,a1
    
    locret_6C1E:
            rts   
    ; End of function GetBlockData
    If you need any further info, I'll supply it. I'm not quite sure where to even start on fixing this issue, hence why I'm asking for help.

    Most levels in S3 have a greater width, and they don't have this issue.
     
  8. RandomName

    RandomName Newcomer Member

    Joined:
    Jun 3, 2020
    Messages:
    21
    Location:
    Russia
    This happens, because of this line:
    Code:
    andi.w    #$7F,d0
    d0 in this case is X position in chunks. So, if d0 is greater than 127 it will loop X position making pseudo-loopback. To fix this you need just comment out this line of code.
     
    ProjectFM, Inferno and DeltaWooloo like this.
  9. Inferno

    Inferno Rom Hacker Member

    Joined:
    Oct 27, 2015
    Messages:
    132
    Location:
    Sky Base Zone, South Island
    I should have seen an obvious answer coming, thanks dude.
     
  10. Scrap Sorra

    Scrap Sorra Well-Known Member Member

    Joined:
    Sep 18, 2020
    Messages:
    112
    Location:
    Development Hell
    What I want to achieve is to have the GHZ background still have the cloud loop but not the water effect, and have a second BG layer under it akin to marble zone. For Marble, I just want to make it so the layers where the clouds and mountains would be don't scroll so my background doesn't come apart like this.
    upload_2020-11-1_15-2-44.png
     
  11. Scrap Sorra

    Scrap Sorra Well-Known Member Member

    Joined:
    Sep 18, 2020
    Messages:
    112
    Location:
    Development Hell
    What I want to achieve is to have the GHZ background still have the cloud loop but not the water effect, and have a second BG layer under it akin to marble zone. For Marble, I just want to make it so the layers where the clouds and mountains would be don't scroll so my background doesn't come apart like this.
     
  12. Angel X

    Angel X Well-Known Member Member

    Joined:
    Sep 15, 2017
    Messages:
    291
    Location:
    Italy
    Hi, I'm here to ask for a quick thing.
    I wanted to make a slight change to the title screen of sonic 1.
    I wanted to change the words in white "the hedgehog".
    Do you know a tool to change the title screen or the method to do it?
     
  13. Psi

    Psi Well-Known Member Member

    Joined:
    Dec 20, 2014
    Messages:
    102
    Okay, a few questions:

    1. Does anyone know a good resource for restoring the Wood Zone in Sonic 2 (eg. assets, tutorial, level editor files)?

    2. I'm trying to make an object that, when the player touches it, they get propelled upward. Right now the only way I've managed to get this running is by giving it enemy collision and turning off its ability to harm the player, though even this isn't exactly optimised since there's still other elements that interact with the enemy coding and it also means the propel level is based on the player holding jump button if they land on it the wrong way. Is there a better way of going about this?

    (For reference here is the object routine, it is my own crude work so I don't really mind if anyone steals it, their funeral. :p)

    Code:
    ObjE4:
        moveq    #0,d0
        move.b    routine(a0),d0
        move.w    off_ObjE4(pc,d0.w),d1
        jmp    off_ObjE4(pc,d1.w)
    ; ===========================================================================
    off_ObjE4:
        dc.w ObjE4_Init-off_ObjE4
        dc.w ObjE4_Main-off_ObjE4; 2
    ; ===========================================================================
    ObjE4_Init:
        addq.b    #2,routine(a0)
        move.l    #ObjE4_Mappings,mappings(a0)
        move.b    #4,render_flags(a0)
        move.w    #0,art_tile(a0)
        jsr    (Adjust2PArtPointer).l
        move.b    #$2,priority(a0)
              move.b  #$20,width_pixels(a0)
            move.b  #$4,y_radius(a0) ; $A
              move.b  #9,collision_flags(a0)
    
    
    ObjE4_Main:
        moveq    #0,d0            ; clear d0
        move.w    $8(a0),d0        ; load block's X-pos to d0
        sub.w    (MainCharacter+$8).w,d0    ; substract Amy's X-pos from it
        bpl.s    ObjE4_XPositive        ; if answer is positive, branch
        neg.w    d0            ; otherwise negate d0
    
    ObjE4_XPositive:
        cmpi.w    #$20,d0            ; is Amy within 25 pixels of the object (X-axis)?
        bge.s    ObjE4_RTS    ; if not, branch
        moveq    #0,d0            ; clear d0
        move.w    $C(a0),d0        ; load block's Y-pos to d0
        sub.w    (MainCharacter+$C).w,d0    ; substract Amy's Y-pos from it
        bpl.s    ObjE4_YPositive        ; if answer is positive, branch
        neg.w    d0            ; otherwise negate d0
    
    ObjE4_YPositive:
        cmpi.w    #$20,d0            ; is Amy within 25 pixels of the object (Y-axis)?
        bne.s    ObjE4_RTS    ; if not, branch
        move.b    #1,anim(a0)
    
    ; ===========================================================================
    ObjE4_RTS:
        lea    (Ani_Fountain).l,a1
        jsr    AnimateSprite
        jmp    DisplaySprite
    The code to move the player upward is then listed in the Touch_Enemy routine.


    3. Also, I've heard porting the S3K ring manager to S2 can cause issues with VS mode. Is this true?
     
  14. yami

    yami the homing attack addict Member

    Joined:
    Sep 24, 2020
    Messages:
    34
    If i'm not mistaken, I believe you can do that with a plane mapping editor like SonPLN or PlaneED.
     
    Angel X likes this.
  15. yami

    yami the homing attack addict Member

    Joined:
    Sep 24, 2020
    Messages:
    34
    For 1, I know there's a sheet in the custom section of The Spriters Resource, but for the other two I'm clueless.

    and for Spanner, thanks for the reminder. I genuinely forgot. :)
     
    Last edited: Nov 3, 2020
  16. Spanner

    Spanner The Tool Member

    Joined:
    Aug 9, 2007
    Messages:
    2,570
    Please don't double post so quickly, you could have just edited that into your first post, saving you from using up one post. Do remember you are a Trialist, with limited posts.
     
    yami and DeltaWooloo like this.
  17. Cyber Axe

    Cyber Axe Newcomer Trialist

    Joined:
    Jun 21, 2020
    Messages:
    6
    How do you set the speed of the current sonic animation?

    I can set animations fine, but cant find any info on changing the speed at which they play at, this is specifically for the sonic 1 github but I'm assuming it would be similar in the other games too.

    The two specific scenarios i wish to solve are..

    Sonic CD Style Spindash, i cant figure out how to speed up the animation like in sonic cd it just rotates at the slowest speed until you release and start moving.

    I've also implemented the Super Peelout using the regular sonic run animation, i want to do the same here, set it to full running speed

    thought ramping it up over a couple of frames would be preferred similar to in sonic cd how the spin dash starts of slow then quickly speeds to full speed
     
  18. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    If you just want to change the speed of the animation, the first hexadecimal number for each animation determines the speed. The number itself is the amount of time between frames of animation, so lowering it makes the animation go faster.

    If you want to the animation to speed up as it goes, you'll need to hard code it into Sonic_Animate similar to how the walk/run/roll animations are. obTimeFrame is the variable in Sonic's status table which counts down the time between frames of animation. Usually it counts down to zero, then is reset to the animation speed number. When walking/running/rolling it is instead reset to a value that depends on Sonic's inertia.
     
  19. Cyber Axe

    Cyber Axe Newcomer Trialist

    Joined:
    Jun 21, 2020
    Messages:
    6
    Thanks, after your reply and relooking at the code I was able to achieve the desired effect in peelout with adding: move.w #$0F00,obInertia(a0) ; Set Sonic's speed

    works for spindash too but it needs tweaking

    posting for reference
     
    RandomName and ProjectFM like this.
  20. Scrap Sorra

    Scrap Sorra Well-Known Member Member

    Joined:
    Sep 18, 2020
    Messages:
    112
    Location:
    Development Hell
    I'm adding custom collision and level chunks and I wanted Sonic to be able to jump off walls when he's going up them like he should be able to but he can't for some reason. What is preventing that from occurring? (image marked as spoiler because it's big)
    upload_2020-11-4_12-0-56.png

    edit: nevermind, it was the fact I had it on l/r/b/ solid
     
    Last edited: Nov 5, 2020