Basic Questions and Answers Thread

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

  1. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    528
    Location:
    France
    Ohhh, how could I not see it? :D Thank you Natsu!
     
  2. Baraksha

    Baraksha Well-Known Member Member

    Joined:
    Dec 23, 2015
    Messages:
    99
    quick question because I can't seem to find info on this.
    is there an instruction that can branch further then bne.w?
     
  3. Ralakimus

    Ralakimus "I want to die alone tonight~" Member

    Joined:
    Aug 26, 2013
    Messages:
    1,000
    Location:
    Assville, Shittucky
    No, but what you can do is have it branch to a label that will jump to the label you want.

    For example:
    Code:
        ...
        bne.s JmpTo_Label
        ...
    
    JmpTo_Label:
        jmp Label
     
  4. Baraksha

    Baraksha Well-Known Member Member

    Joined:
    Dec 23, 2015
    Messages:
    99
    it worked , thanks.

    now I have another quesiton, I am trying to change the GHZ boss, I changed the art for the eggmobile to something else but I don't like it using sonic's pallet, what is the best way for me to have the colors I want for the boss without ruining the other pallets? or do I have to use the already existing colors?
     
  5. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    810
    Location:
    Portland, Maine
    The Genesis can't handle anything more than 4 palette lines with 15 colors and a transparency so adding new colors is out of the question without some graphical effects that have limited use. Your best bet is to change the second palette line when you reach the boss area. By doing this, you have a lot of freedom with what colors the boss uses. This is the same palette line used for rings so you have to keep those three shades of yellow and that white in there.

    To do this, what you need to do first is create your palette line. Then, you need to add a point in sonic1.asm that includes (incbin or binclude) the file in the code. Next, you need to add an entry for the code in Pallet pointers.asm using the name that branches to the included file. Adding the entry will allow you to choose what palette the palette loads at and how many colors the palettes line uses. Finally, you need to choose a moment when the boss is loaded and make the palette load by moving the palette's entry number to d0 and then branching to subroutine to PalLoad1.
     
    Baraksha likes this.
  6. Baraksha

    Baraksha Well-Known Member Member

    Joined:
    Dec 23, 2015
    Messages:
    99
    ok, so far I made my pallet and gave it pointers in sonic1.asm, but I have a small and probably very noobish question about Palette pointers.asm , what is a "pallet length"? what exactly is being measured here? from what I can tell it's usually 7/$17/$1A . also should I use RAM address $FB00 or $FB20 because i'm not sure how this works.
    I also not sure how the inclusion of the pallet works inside the boss's routine, what line in object 3D says "load pallet" or maybe it doesn't work that way
     
    Last edited: Oct 2, 2016
  7. Painto

    Painto Samodzierżca Najdłuższego Kija Member

    Joined:
    Mar 24, 2014
    Messages:
    315
    Location:
    Poland
    The bosses originally (in S1) don't load any palette, so obviously you won't find anything. You can load the palette along with bosses PLC in the Resize routines.

    As for "pallet pointers", it is pretty much explained in the file itself (comments on first entry) Each palette line is $20 bytes long, so if you want to load it in line 1, use $FB20. "7/$17/$1A" is the number of colors in the palette (1 line - $10 colors), that is divided by $2 ($10/$2=$8 - PalLoad routines use longwords, which is 2 colors/2 words) and substracted by $1 ($8-$1=$7 - number of repeats for the PalLoad routines). You can use between 0 (2 colors) and $1F (all 64 colors). And you need to use PalLoad2, PalLoad1 is for fading in (if you want to load it underwater, use PalLoad3_Water,
    PalLoad4_Water is for fading in).
     
    Baraksha and ProjectFM like this.
  8. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    877
    You know, there's nothing saying you have to use the regular palette pointers list, especially if you're only using it once, you could just have the palette bin included near the code and copy it to palette ram manually.
     
  9. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    528
    Location:
    France
    I have create a monitor that make me able to switch between Sonic and Ashuro.
    here is the code:


    Code:
    Obj2E_Blank:    ; XREF: Obj2E_Move
            addq.b    #2,$24(a0)
            move.w    #29,$1E(a0)
            move.b    $1C(a0),d0
            cmpi.b    #0,d0; does monitor contain Eggman?
            bne.w    Obj2E_ChkEggman ; if not, go and check for the next monitor type (1-up icon)
            tst.b     ($FFFFFFF6).w ; if player flag not set?
            bne.s     Blank_Switch ; if set branch
            move.b     #1,($FFFFFFF6).w ; if not, set flag
            bra.s     Obj2E_Blank_end
            
    Blank_Switch:
            clr.b     ($FFFFFFF6).w ; clear player flag
            
    Obj2E_Blank_end:
            rts ; The blank monitor now does something!

    But when Sonic hit the monitor, the Ashuro's art is loaded correctly, but not his palette, and when he roll, run or use the spindash, his sprites are empty. So i think the PLC, Mappings and animations are not loaded. It's strange because i have the player flag present in all the subroutines for load the correct PLC/maps/palette...
    And when Ashuro use the monitor, Sonic is perfectly loaded, with his palettes, animations, pattern and mappings.
    Have an idea of whats wrong?
     
  10. Clownacy

    Clownacy Well-Known Member Staff

    Joined:
    Aug 15, 2014
    Messages:
    888
    The code looks like it should work, though it could do with some optimisation:

    cmpi.b #0,d0 can be changed to tst.b d0, and all that code relating to toggling $FFFFFFF6 can simply be done with a 'bchg #0,($FFFFFFF6).w'.
     
    Ashuro likes this.
  11. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    528
    Location:
    France
    What means "bchg"?
    I don't know this command :eek:
    And where/how can i use it?
     
  12. Ralakimus

    Ralakimus "I want to die alone tonight~" Member

    Joined:
    Aug 26, 2013
    Messages:
    1,000
    Location:
    Assville, Shittucky
    "bchg" takes a bit (the bit chosen is indicated in the source), and if that bit is set, it clears it, but if it's clear, it sets it.

    Example:
    bchg #0,($FFFFFFF6).w

    That takes bit 0 from the value in $FFFFFFF6 and applies the changes I described.

    If $FFFFFFF6 = 0, in binary that's:

    00000000

    So, it sets bit 0, which results in:

    00000001

    Which is 1 in decimal and hex.
     
  13. Xeal

    Xeal The Nuke Retired Staff

    Joined:
    Mar 10, 2016
    Messages:
    227
  14. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    528
    Location:
    France
    I'm not sure to understand

    EDIT: Thank you Xeal!

    I really need to learn more and more!
    Thank you all for this help, i will read the Markeyjester's guide again and again :p

    So i have tested it and:



    It's the same again...

    EDIT:
    I have tested to load the plc/map/palette of Ashuro in the monitor routine, and when i break it, i get an illegal instruction.
    I'm sure i have forget something somewhere but i don't know what.
     
    Last edited: Oct 2, 2016
  15. Pacca

    Pacca Why succeed when you can profit off of failure? Member

    Joined:
    Jul 5, 2014
    Messages:
    1,149
    Location:
    Triton (Moon)
    Have you tested if Ashuro works normally (not via monitor switch)? If so, I'm not 100% sure whats wrong. From the video, it seems clear that some of Ashuros Mappings and/or DPLCs are not loading correctly. You will likely have to manually rewrite the palette to get the colors to properly appear, like so (the following is pseudo code, so you'll need to modify it up a bit);

    Code:
    move   #(value of ashuro pal),d0
    jsr         Paload
    as for the mappings and DPLCs not working, I've found that changing those usually works instantly. Can you give an example of the code used to swap mappings and DPLCs, as well as where it's located? That's the only place I could see having an issue here.
     
    Ashuro likes this.
  16. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    528
    Location:
    France
    Everything works normally for Ashuro not via the monitor switch (i have tested to switch to Sonic with Ashuro and it's the same problem like with Sonic).

    Okay thank you for the palette help, i think i can do the rest for this! :)
    (For information i have the DMAqueue added ect...)

    I show you!

    Code:
    Obj2E_Blank:    ; XREF: Obj2E_Move
            addq.b    #2,$24(a0)
            move.w    #29,$1E(a0)
            move.b    $1C(a0),d0
            tst.b        d0; does monitor contain Eggman?
            bne.w    Obj2E_ChkEggman ; if not, go and check for the next monitor type (1-up icon)
            tst.b     ($FFFFFFF6).w
            bne.s     SwitchPlayer
            bchg.b     #0,($FFFFFFF6).w
            bra.s     Obj2E_Blank_end
            
    SwitchPlayer:
            clr.b     ($FFFFFFF6).w
    
    Obj2E_Blank_end:
            move.w    #$AF,d0
            jmp    (PlaySound).l    ; play shield sound
            rts ; The blank monitor now does something!

    Code:
    ; ---------------------------------------------------------------------------
    ; Sonic    pattern    loading    subroutine
    ; ---------------------------------------------------------------------------
    
    ; ||||||||||||||| S U B    R O U T    I N E |||||||||||||||||||||||||||||||||||||||
    
    
    LoadSonicDynPLC:            ; XREF: Obj01_Control; et al
            moveq    #0,d0
            move.b    $1A(a0),d0    ; load frame number
            cmp.b    ($FFFFF766).w,d0
            beq.s    locret_13C96
            move.b    d0,($FFFFF766).w
    
            tst.b    ($FFFFFFF6).w    ; is the multiple character flag set to $01 (Ashuro)?
            beq.s    SonicPLCLoad        ; if not, load Sonic's art
            lea        (AshuroDynPLC).l,a2
            bra.s    ContLoadPLC        ; branch to rest of code
    
    SonicPLCLoad:
            lea    (SonicDynPLC).l,a2
    
    ContLoadPLC:
            add.w    d0,d0
            adda.w    (a2,d0.w),a2
            moveq    #0,d5
            move.b    (a2)+,d5
            subq.w    #1,d5
            bmi.s    locret_13C96
            move.w    #$F000,d4
    
            tst.b    ($FFFFFFF6).w    ; is the multiple character flag set to $01 (Ashuro)?
            beq.s    SonicArtLoad        ; if not, load Sonic's art
            move.l    #Art_Ashuro,d6
            bra.s    SPLC_ReadEntry        ; branch to rest of code
    
    SonicArtLoad:
            move.l    #Art_Sonic,d6
    
    SPLC_ReadEntry:
            moveq    #0,d1
            move.b    (a2)+,d1
            lsl.w    #8,d1
            move.b    (a2)+,d1
            move.w    d1,d3
            lsr.w    #8,d3
            andi.w    #$F0,d3
            addi.w    #$10,d3
            andi.w    #$FFF,d1
            lsl.l    #5,d1
            add.l    d6,d1
            move.w    d4,d2
            add.w    d3,d4
            add.w    d3,d4
            jsr    (QueueDMATransfer).l
            dbf    d5,SPLC_ReadEntry    ; repeat for number of entries
    
    locret_13C96:
            rts

    This is you want me to show you??
     
  17. Pacca

    Pacca Why succeed when you can profit off of failure? Member

    Joined:
    Jul 5, 2014
    Messages:
    1,149
    Location:
    Triton (Moon)
    What about the mappings? Art is obviously being loaded properly, so either the mappings or DPLCs are failing to load. The DPLCs look fine here (to me anyways, I'm not the best at reading code), so it seems quite likely that the mappings are to blame.
     
  18. Ralakimus

    Ralakimus "I want to die alone tonight~" Member

    Joined:
    Aug 26, 2013
    Messages:
    1,000
    Location:
    Assville, Shittucky
    When you hit the monitor, have the object's mappings be switched to the correct mappings, and load the correct palette.

    To set the player object's mappings within the monitor object, you could do this:

    Code:
    move.l #MAPPINGS,($FFFFD000+4).w
    Just replace "MAPPINGS" with the correct mappings pointer, and have it check to see which character it is, so that it picks the correct mappings to use.

    You will also need to do the same for loading the correct palette (just to warn you, d7 is used in the PalLoad routines, which is also used as a counter for ObjectsLoad for the number of objects to check/run), so you will need to push the value of d7 into the stack, and then pop from the stack after loading the palette, so that we can keep the original d7 value intact when we are done. You can do pushing and popping the d7 register to/from the stack by:

    Code:
    move.l    d7,-(sp)         ; Push
    ; CODE
    move.l    (sp)+,d7         ; Pop
     
    ProjectFM and Ashuro like this.
  19. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    528
    Location:
    France
    The mappings! :)
    Code:
    Obj01_Main:                ; XREF: Obj01_Index
            addq.b    #2,$24(a0)
            move.b    #$13,$16(a0)
            move.b    #9,$17(a0)
    
            tst.b    ($FFFFFFF6).w    ; is the multiple character flag set to $01 (Ashuro)?
            beq.s    SonicMapLoad        ; if not, load Sonic's art
            move.l    #Map_Ashuro,4(a0)
            bra.s    ContLoadMap        ; branch to rest of code
    
    SonicMapLoad:
            move.l    #Map_Sonic,4(a0)
    
    ContLoadMap:
            move.w    #$780,2(a0)
            move.b    #2,$18(a0)
            move.b    #$18,$19(a0)
            move.b    #4,1(a0)
     
  20. Ralakimus

    Ralakimus "I want to die alone tonight~" Member

    Joined:
    Aug 26, 2013
    Messages:
    1,000
    Location:
    Assville, Shittucky
    The thing is, the mappings for the character are only set when the object is initialized when it gets loaded. Obj01_Main only gets run when Obj01 is first loaded, and usually is never run again, unless needed. Which is why you'll need to update the mappings pointer when you switch characters.
     
    Ashuro likes this.