Basic Questions and Answers Thread

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

  1. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    415
    Ah, I've just noticed my mistake in the second fix I wrote for you. This is how it should be:



    lea SS_LayoutIndex(pc),a0
    movea.l (a0,d0.w),a0



    Anyways, it's good that you could leave the original instructions.

    There was nothing wrong with the data being located before the instructions that refer to it, and the "loop" you're talking about just doesn't exist. The processor can access any data in any accessible location in memory space (ROM/RAM/IO ports) in single time.


    Also, among those two instructions only one actually reads something from another location.


    * * *



    lea SS_StartLoc(pc,d0.w),a1



    LEA is for Load Effective Address.


    This instruction calculates the memory address and writes its value to an address register, A1 in your case. Memory address can be presented in many forms, like (xxx).w, (xxx).l, (an), d16(an) and others.


    Here, the address is presented in d8(pc,dn) addressing mode. To calculate the address, the processor will add program counter (PC), contents of data register and 8-bit displacement.


    This form is rather complicated for understanding, especially when displacement uses label instead of a number. Actually, during assembling this label will be replaced with a number, showing how far the label is.


    In fact, adding displacement of a label and PC will give you an absolute offset of this label. That's why



    lea SomeLabel(pc),a0



    is the same as



    lea (SomeLabel).l,a0



    I'm just pointing this out as I noticed number of programmers (and myself being among them about a year ago =P) using the later form which is slower and 2 bytes longer. Moreover, (xxx).l is the slowest addressing mode on M68K, avoid using it!


    On this note, which address will form SomeLabel(pc,d0) refer to? It will refer to address SomeLabel+d0.


    * * *



    movea.l SS_LayoutIndex(pc,d0.w),a0



    MOVEA is for Move to Address register.


    While LEA just calculates the address and writes address value, MOVE reads data from this address and writes (copies) this data to destination (address register in your case).


    The addressing mode is the same as described above. This instruction will copy a long word from offset SS_LayoutIndex+d0 to a0.


    If you don't understand what I'm explaining, don't worry, these are quite hard things from advanced assembly programming, or I'm just fail at explaining things (my English is far from being perfect =).


    Also, I would like to suggest more optimizations for your code (and one bug fix, I'm sure you'll figure it out):



    SS_Load: ; XREF: SpecialStage
    cmpi.b #6,($FFFFFE57).w ; Does sonic have 6 emeralds?


    bls.s SS_SpecialStageNumLoad ; If lower or same, branch


    move.b #0,($FFFFFE57).w ; reset if higher than 6


    SS_SpecialStageNumLoad:


    move.b ($FFFFFE57).w,($FFFFFE16).w ; move the value of address $FFFE57 to $FFFE16


    move.b ($FFFFFE16).w,d0


    bra.s SS_LoadData


    <...>



    BLS is for 'Branch if Lower or Same'.

    Sure, feel free to make tutorial of it.
     
    Last edited by a moderator: Jan 28, 2012
  2. ProfessorRenderer

    ProfessorRenderer Certified Bear Scientist Member

    Joined:
    Sep 28, 2011
    Messages:
    102
    Location:
    Willoughby, Ohio
    Ok, now I might do like DarkLeach's HUD which is 1970 age hud. How can I do it? I'll be happy if you do. :)
     
  3. DarkLeach

    DarkLeach Well-Known Member Member

    Joined:
    Jul 3, 2011
    Messages:
    193
    Location:
    In the middle of desert heat
    Jake92: All I did was simple, I got TLPFixed, I got a SMB1 Rom opened it up alongside the HUD.bin in the artunc folder and the HUD.bin in the artnem after I decompressed it with SonMapEd (Also used that to decompress). Then I have to change the color of the letters in SMB1 because whenever I dragged them to the HUD.bin, menutext.bin or, livescnt.bin they would be invisible, so on the SMB1 ROM I had to color all the letters a different color so they would be visible in the Sonic Games, and after that I dragged them over to menutext.bin and colored them all white and dragged and dropped them in their respective parts on other *.bin files. it's easy,but you have to know what you're doing really, but If you can't I'll make a .zip and post it for download.


    EDIT: I also had to find the palettes for Sonic 1 for TLPFixed so I knew what I was coloring was colored right.
     
    Last edited by a moderator: Jan 28, 2012
  4. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,229
    Location:
    UK
    Quick Question: Can you increase the hurt range for Sonic against an enemy?. Say for an example the enemy is quite big, yet only a bit of the mappings hurt Sonic. I want to change it so that the whole of the enemy can hurt Sonic. I would assume that if being possible such a thing would be in the Touch_Response Routine?.


    Edit: Forget it, someone else helped me.
     
    Last edited by a moderator: Jan 31, 2012
  5. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    Quick question, Where are the Art, Maps and DPLCs for Sonic stored in the Sonic CD files?
     
  6. OrdosAlpha

    OrdosAlpha RIGHT! Naebody move! Root Admin

    Joined:
    Aug 5, 2007
    Messages:
    1,793
    Location:
    Glasgow, Scotland
    In every level file, with the location of each varying from file to file.
     
    Last edited by a moderator: Feb 1, 2012
  7. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    Thanks Ordos!
     
  8. Rezeed

    Rezeed Dataspirit and Dream Traveller Member

    Joined:
    Oct 31, 2011
    Messages:
    35
    Location:
    Cyberspace
    I am kinda curious, but is there a way to import tiles and unique objects(Like breakaway rocks, the barrel of doom, cling switches, etc.) between sonic games?(Like S3K to S2, S1 to S3k, S2 to 1, and any other possible combination of the sort.)


    To drive that curiosity even further, is there a way to import tiles from other Sega Genesis/Megadrive games into the sonic games?
     
  9. EMK-20218

    EMK-20218 The Fuss Maker Exiled

    Joined:
    Aug 8, 2008
    Messages:
    1,067
    Location:
    Jardim Capelinha, São Paulo
    If you studied their internal formats of code/compression, it's theorically possible to import (or recreate =P) absolutely anything from all Genesis's games between themselves, it doesn't matter wich games they're. All you need is to disassemble them and converting the routine variables, constants, RAM addresses, fixing VRAM areas (and etc) by yourself. Having this power in hands, you'll be allowed to import absolutely everything from a game into other one. =P
     
  10. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    The Mega Drive itself has a VDP chip which has tiles in a specific format, what this means is that ALL Mega Drive games MUST follow the same tile rules, what this additionally means is that the tile art in all Mega Drive games is the exact same format, most of the games do tend to compress the tile data under specific formats for the purpose of saving ROM space, but they will always decompress to the standard 8x8 format.
     
  11. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    How would I make the jumping animation faster? I added 4 more frames, changed the animations and edited the code to only use that animation (Normally when going fast it uses a differnt animation). But when jumping while standing still the animation just feels slow.
     
  12. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    In SAnim_RollJump, you'll find something that modifies the frame duration (value in $1E(a0)). That's what you're looking for.
     
  13. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    Well that was the routine I edited to make only one animation used.




    SAnim_RollJump: ; XREF: SAnim_WalkRun


    addq.b #1,d0 ; is animation rolling/jumping?


    bne.s SAnim_Push ; if not, branch


    move.w $14(a0),d2 ; get Sonic's speed


    bpl.s loc_13ADE


    neg.w d2


    loc_13ADE:


    lea (SonAni_Roll).l,a1 ; use normal animation


    loc_13AF0:


    neg.w d2


    addi.w #$400,d2


    bpl.s loc_13AFA


    moveq #0,d2


    loc_13AFA:


    lsr.w #8,d2


    move.b d2,$1E(a0) ; modify frame duration


    move.b $22(a0),d1


    andi.b #1,d1


    andi.b #$FC,1(a0)


    or.b d1,1(a0)


    bra.w SAnim_Do2



    I think that the code changes the duration of the animation by how fast Sonic is going, but if Sonic is not moving the code is ignored. Im not sure what to add or change.
     
    Last edited by a moderator: Feb 3, 2012
  14. Crash

    Crash Well-Known Member Member

    Joined:
    Jul 15, 2010
    Messages:
    302
    Location:
    Australia
    Reduce the value in this line, it's the default animation speed ($4) multiplied by $100.




    addi.w #$400,d2



    The code still runs if Sonic is stopped,
     
    Last edited by a moderator: Feb 4, 2012
  15. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    Thanks Crash, but I found out just after posting.


    New problem:


    I changed it so that if Sonic is underwater and Skids (In the code this is known as stopping) he uses a differnt animation:




    move.b #$D,$1C(a0) ; use stopping animation


    btst #6,$22(a0) ; is Sonic underwater?


    beq.s SkidCont1 ; if not, branch


    move.b #$28,$1C(a0) ; use underwater stopping animation



    I applied this to both MoveLeft and MoveRight, But it still uses the first animation while underwater.
     
  16. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    Can you show the whole code of "MoveLeft" (or "MoveRight")?
     
  17. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    Here is the whole code:




    Sonic_MoveLeft: ; XREF: Sonic_Move


    move.w $14(a0),d0


    beq.s loc_13086


    bpl.s loc_130B2


    loc_13086:


    bset #0,$22(a0)


    bne.s loc_1309A


    bclr #5,$22(a0)


    move.b #1,$1D(a0)


    loc_1309A:


    sub.w d5,d0


    move.w d6,d1


    neg.w d1


    cmp.w d1,d0


    bgt.s loc_130A6


    add.w d5,d0


    cmp.w d1,d0


    ble.s loc_130A6


    move.w d1,d0


    loc_130A6:


    move.w d0,$14(a0)


    move.b #0,$1C(a0); use walking animation


    rts


    ; ===========================================================================


    loc_130B2: ; XREF: Sonic_MoveLeft


    sub.w d4,d0


    bcc.s loc_130BA


    move.w #-$80,d0


    loc_130BA:


    move.w d0,$14(a0)


    move.b $26(a0),d0


    addi.b #$20,d0


    andi.b #$C0,d0


    bne.s locret_130E8


    cmpi.w #$400,d0


    blt.s locret_130E8


    move.b #$D,$1C(a0) ; use stopping animation


    btst #6,$22(a0) ; is Sonic underwater?


    beq.s SkidCont1 ; if not, branch


    move.b #$28,$1C(a0) ; use underwater stopping animation


    SkidCont1:


    bclr #0,$22(a0)


    move.w #$A4,d0


    jsr (PlaySound_Special).l ; play stopping sound


    locret_130E8:


    rts


    ; End of function Sonic_MoveLeft


    ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||


    Sonic_MoveRight: ; XREF: Sonic_Move


    move.w $14(a0),d0


    bmi.s loc_13118


    bclr #0,$22(a0)


    beq.s loc_13104


    bclr #5,$22(a0)


    move.b #1,$1D(a0)


    loc_13104:


    add.w d5,d0


    cmp.w d6,d0


    blt.s loc_1310C


    sub.w d5,d0


    cmp.w d6,d0


    bge.s loc_1310C


    move.w d6,d0


    loc_1310C:


    move.w d0,$14(a0)


    move.b #0,$1C(a0); use walking animation


    rts


    ; ===========================================================================


    loc_13118: ; XREF: Sonic_MoveRight


    add.w d4,d0


    bcc.s loc_13120


    move.w #$80,d0


    loc_13120:


    move.w d0,$14(a0)


    move.b $26(a0),d0


    addi.b #$20,d0


    andi.b #$C0,d0


    bne.s locret_1314E


    cmpi.w #-$400,d0


    bgt.s locret_1314E


    move.b #$D,$1C(a0) ; use stopping animation


    btst #6,$22(a0) ; is Sonic underwater?


    beq.s SkidCont2 ; if not, branch


    move.b #$28,$1C(a0) ; use underwater stopping animation


    SkidCont2:


    bset #0,$22(a0)


    move.w #$A4,d0


    jsr (PlaySound_Special).l ; play stopping sound


    locret_1314E:


    rts


    ; End of function Sonic_MoveRight



    The only part I have touched is Stopping/Skidding routine


    EDIT: Nevermind im still a dummy.
     
    Last edited by a moderator: Feb 5, 2012
  18. Kensou

    Kensou Well-Known Member Member

    Joined:
    Aug 19, 2010
    Messages:
    59
    Basic question: How can I change a Nemesis compressed object to be loaded as uncompressed object?
     
  19. DarkLeach

    DarkLeach Well-Known Member Member

    Joined:
    Jul 3, 2011
    Messages:
    193
    Location:
    In the middle of desert heat
    This is probably a super easy fix (or not) but Music Pointer Fixer 1.0.0.1 is not letting me open S2 Format Music, I know it's because it's supposed to have "0603" or "0703" in a specific spot, but whenever I do that Music Pointer Fixer 1.0.0.1 crashes upon selecting Fix (I'm trying to convert S2 to S1), is there anything I can do to fix it? Also, why is the music in the S2 Simon Wai Beta Disassembly a *.snd file? I don't know what to do with those. Any help would be GREATLY Appreciated! :)





    @Kensou Open up the compressed tile graphics in SonMapEd and then save them as uncompressed tile graphics.
     
  20. Kensou

    Kensou Well-Known Member Member

    Joined:
    Aug 19, 2010
    Messages:
    59
    I mean the code related part to load the art, I'm not talking about to convert the art from Nemesis to uncompressed. I already did that, but I want to know what I have to change in the source to load that uncompressed art instead the Nemesis.