Basic Questions and Answers Thread

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

  1. Irixion

    Irixion Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    670
    Location:
    Ontario, Canada
    I find myself saying this for the fourth time now. He doesn't know what he's doing. Look at how 68k works before you try programming in it. Basic order of operation. It's like trying to read a sentence but with the words in random order.
     
  2. Mike B Berry

    Mike B Berry A grandiose return Member

    Joined:
    Jun 6, 2012
    Messages:
    377
    Location:
    New places, newer motivation
    How many times have we done this with him by the way? It's obvious that the material linked (Mainly the 68k guide) either hasn't been understood correctly, or he hasn't built a foundation around his studies. I have created a simple guide to run him through, but the main issues depend on what he is trying to accomplish. I myself have a couple things to learn. I'm sure that in time (the distant future, that is,) his issues will be resolved.
     
    Last edited by a moderator: Sep 13, 2012
  3. SuperEgg

    SuperEgg I'm a guy that knows that you know that I know Member

    Joined:
    Oct 17, 2009
    Messages:
    Location:
    THE BEST GOD DAMN STATE OF TEXAS
    Come on Irixion. Be nice;). It's not his fault he hasn't learned m68k in full =P. in all seriousness, Irixion is right, you need at least a mild understanding as to what the hell is going on. You are slightly getting a grasp of the concept, you just have no idea how to code it, which can be solved I suppose, if you read up. As I said though, I suggest you drop that old method and instead just make obj01(Sonic) clones, but obviously changed up so that you could easily modify one without mangling up the other.
     
  4. Sonic master

    Sonic master Well-Known Member Member

    Joined:
    Mar 27, 2010
    Messages:
    303
    waroneortwo I would recomend you check out http://68k.hax.com/ it tells you exactly what each instruction does, It is very helpful for me I use it alot. So just read though it and in no time at all you will become a good m68k programmer and remember if you forget an instruction you can always come back to it while programming (that is what I do occasonlly when I forgot what an instruction did).
     
  5. Irixion

    Irixion Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    670
    Location:
    Ontario, Canada
    His code makes no sense, I've commented on what's wrong with it. warr1or2, you're telling the game to do numerous things at the same time, it can't do that. Look at how 68k works, start with the basics. This is beyond basic. You'll be able to help yourself in these situations if you know.

     
    Last edited by a moderator: Sep 14, 2012
  6. Flamewing

    Flamewing Elite Hacker Member

    Joined:
    Aug 28, 2011
    Messages:
    37
    Location:
    France
    Lets see: the sf.b line sets $FFFFFFFE to zero for Sonic; the "addq.b #$01" line changes this to 0 (previous value) + 1 = 1 for another character; when (if) the "addq.b #$02" line is run, it will change $FFFFFFFE to 1 (previous value) + 2 = 3; likewise, when (if) the "addq.b #$03" line is run, it will change $FFFFFFFE to 3 (previous value) + 3 = 6; finally, when (if) the "addq.b #$05" line is run, it will change $FFFFFFFE to 6 (previous value) + 5 = 11.


    I think you want to either change all of them to be "addq.b #1" or you want to use move.b instead of addq.
     
  7. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,873
    Ladies and gentlemen, I couldn't help but notice several posts saying "learn 68k" with no additional help, the fact is, he's already been told once, we don't need it printed out in several posts, especially by those who don't quite understand the language themselves. What you should be doing is directing him to tutorials and tools, and if one person has already said and done that, then there's no point in repeating them.


    From this moment, if anyone repeats another recent post without anything additional of value, I will trash it, you're not a bunch of vinyl records stuck in a loop you know.
     
  8. StephenUK

    StephenUK Working on a Quackshot disassembly Root Admin

    Joined:
    Aug 5, 2007
    Messages:
    1,021
    To be honest, that isn't good advice for someone starting out in asm. Not only does it waste a considerable amount of space duplicating code, along with being time consuming to rename all the labels, but it won't help him grasp the basics of writing code. Making 5 Sonic clones would waste a tremendous amount of rom space, and although it may help the game run a bit better by removing the checks, I can't imagine for a minute that it will cause him any problems at this stage. It would only be a problem after extensive engine modifications and additions, and with the way things are at the moment, I can't see that happening any time soon. It's always something that could be addressed at a later date if speed does become a problem, when he will have a broader asm knowledge.


    EDIT: Reworded for clarity, as original post didn't really get the point across.
     
    Last edited by a moderator: Sep 14, 2012
  9. SuperEgg

    SuperEgg I'm a guy that knows that you know that I know Member

    Joined:
    Oct 17, 2009
    Messages:
    Location:
    THE BEST GOD DAMN STATE OF TEXAS
    actually, if you just copy the whole code into a separate asm, change the subs that have loc_1xxxx to loc_2xxxx' etc, it is quite easy =P.


    The making of sonic clones can be tiresome, but I personally like it better. It gives more flexibility to do whatever. Though, this is just personal preference, I'd find that easier any day over attempting 4+ checks just to figure out which art shall be loaded.
     
  10. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    401
    Location:
    Town Creek, AL
    actually my problem is solved. it didn't lie with the code ($FFFFFFFE).w, I looked at Sonic Open Source Project and found it's ACTUALLY with this code ($FFFFFF8B).w cause I tested my character swap monitors with both code and found out ($FFFFFFFE).w is NOT character related but ($FFFFFF8B).w is
     
  11. Mike B Berry

    Mike B Berry A grandiose return Member

    Joined:
    Jun 6, 2012
    Messages:
    377
    Location:
    New places, newer motivation
    Alright my good people. It is time for this retard (Me) to ask yet another question.


    As some of you may have read the last post of my Project Utilization topic; If not then here it is: http://sonicresearch...?showtopic=3153.


    I have imported a modified version of the Sonic 2 menu, but I'm having a couple of issues with the code.


    http://youtu.be/QqLar8vsKz8


    My question is "Why does the Level select code send me to the second act of GHZ, and why does the special stage activate level select as well?" I have the code, and I have it pretty much imported, just these two issues are keeping me from finishing the import.


    I'm sure I am looking over something. but I can't seem to get it right. Could you please help me out?


    Here is the code:



    Code:
    
    Title_ChkLevSel:
    
    cmp.b #6,($FFFFD0A4).w ; is Title Menu on?
    
    beq.w loc_317C ; if it not was deleted, branch
    
    moveq #0,d2
    
    move.b ($FFFFFFB0).w,d2 ; load the choice
    
    add.w d2,d2 ; multiply by 2
    
    move.w Obj0F_Menu_Choice(pc,d2.w),d2
    
    jmp Obj0F_Menu_Choice(pc,d2.w) ; jump to the choice code
    
    ; ===========================================================================
    
    Obj0F_Menu_Choice:
    
    dc.w PlayLevel-Obj0F_Menu_Choice ; 0
    
    dc.l Menu_LevelSelect-Obj0F_Menu_Choice ; 2
    
    dc.l PlaySpecialStage-Obj0F_Menu_Choice ; 4
    
    ; ===========================================================================
    
    Menu_LevelSelect: (Possible issues are affiliated with this menu choice.)
    
    move.b #$E0,d0
    
    bsr.w PlaySound_Special ; fade out music
    
    jsr Pal_FadeFrom ;Fade-out is necesarry now
    
    moveq #$FFFFFF90,d0
    
    jsr PlaySample
    
    moveq #2,d0
    
    bsr.w PalLoad1
    
    lea ($FFFF0000).l,a1
    
    lea (Eni_LevSel).l,a0
    
    move.w #1,d0
    
    jsr EniDec
    
    lea ($FFFF0000).l,a0
    
    move.l #$40000003,d0
    
    moveq #39,d1
    
    moveq #29,d2
    
    jsr ShowVDPGraphics
    
    move.l #$40200000,($C00004).l
    
    lea (Nem_LevSel).l,a0
    
    jsr NemDec
    
    lea ($FFFFCC00).w,a1
    
    moveq #0,d0
    
    move.w #$DF,d1
    
    @ClrScroll:
    
    move.l d0,(a1)+
    
    dbf d1,@ClrScroll
    
    lea ($FFFFD000).w,a1
    
    moveq #0,d0
    
    move.w #$7FF,d1
    
    @ClrObjRam:
    
    move.l d0,(a1)+
    
    dbf d1,@ClrObjRam
    
    lea ($FFFFF628).w,a1
    
    moveq #0,d0
    
    move.w #$15,d1
    
    @ClrVars:
    
    move.l d0,(a1)+
    
    dbf d1,@ClrVars
    
    lea ($FFFFF700).w,a1
    
    moveq #0,d0
    
    move.w #$3F,d1
    
    @ClrVars2:
    
    move.l d0,(a1)+
    
    dbf d1,@ClrVars2
    
    lea ($FFFFFE60).w,a1
    
    moveq #0,d0
    
    move.w #$47,d1
    
    @ClrVars3:
    
    move.l d0,(a1)+
    
    dbf d1,@ClrVars3
    
    lea ($FFFFF800).w,a1
    
    moveq #0,d0
    
    move.w #$7F,d1
    
    @ClrSprTable:
    
    move.l d0,(a1)+
    
    dbf d1,@ClrSprTable
    
    move.l #0,($FFFFF616).w ;Clean VScroll
    
    move #$2700,sr
    
    lea ($C00000).l,a6
    
    move.l #$60000003,($C00004).l
    
    move.w #$3FF,d1
    
    @ClearBG:
    
    move.l d0,(a6)
    
    dbf d1,@ClearBG
    
    bsr.w LevSelTextLoad
    
    jsr Pal_FadeTo
    
    ; ==========================================================================
    
    PlaySpecialStage: (Menu choice issue occurs with this line)
    
    cmpi.w #$700,d0 ; check if level is 0700 (Special Stage)
    
    bne.s LevSel_Level ; if not, branch
    
    move.b #$10,($FFFFF600).w ; set screen mode to $10 (Special Stage)
    
    clr.w ($FFFFFE10).w ; clear level
    
    move.b #3,($FFFFFE12).w ; set lives to 3
    
    moveq #0,d0
    
    move.w d0,($FFFFFE20).w ; clear rings
    
    move.l d0,($FFFFFE22).w ; clear time
    
    move.l d0,($FFFFFE26).w ; clear score
    
    ; ===========================================================================
    
    PlayLevel: ; XREF: ROM:00003246j ... (This is affiliated with the menu choice selection as well)
    
    if DemoRecord=1
    
    move.b #$8,($FFFFF600).w ; set screen mode to $08
    
    else
    
    move.b #$C,($FFFFF600).w ; set screen mode to $0C (level)
    
    endif
    
    move.b #3,($FFFFFE12).w ; set lives to 3
    
    moveq #0,d0
    
    move.w d0,($FFFFFE20).w ; clear rings
    
    move.l d0,($FFFFFE22).w ; clear time
    
    move.l d0,($FFFFFE26).w ; clear score
    
    move.b d0,($FFFFFE16).w ; clear special stage number
    
    move.b d0,($FFFFFE57).w ; clear emeralds
    
    move.l d0,($FFFFFE58).w ; clear emeralds
    
    move.l d0,($FFFFFE5C).w ; clear emeralds
    
    move.b d0,($FFFFFE18).w ; clear continues
    
    move.b #$E0,d0
    
    bsr.w PlaySound_Special ; fade out music
    
    rts
    
    ...
    
    
    [/CODE]
     
  12. Irixion

    Irixion Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    670
    Location:
    Ontario, Canada
    I'm not seeing the code tell the game to actually load the special stage, only to set the screen mode, which doesn't load the stage iirc
     
  13. Mike B Berry

    Mike B Berry A grandiose return Member

    Joined:
    Jun 6, 2012
    Messages:
    377
    Location:
    New places, newer motivation
    Every time I do this, the level select code glitches and it causes and illegal error... I'll work more with it today and see if anything happens. I really intend for this feature to work properly before I can release the WIP of the Re-utilization Rom. I also noticed I hadn't put the PlaySpecialStage code in the right place. But The result ends up the same either way. But thanks for the tips as usual Irixion.
     
  14. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,229
    Location:
    UK
    Can you not just use the S2levelselect guide here on SSRG? although it looks like the normal sonic 1 levelselect so I could be mistaken here.
     
  15. Mike B Berry

    Mike B Berry A grandiose return Member

    Joined:
    Jun 6, 2012
    Messages:
    377
    Location:
    New places, newer motivation
    I'm just using the Sonic 2 title selection menu, nothing more. Everything else is using a modified version of Sonic 1's code.
     
    Last edited by a moderator: Sep 19, 2012
  16. redhotsonic

    redhotsonic Also known as RHS Retired Staff

    Joined:
    Aug 10, 2007
    Messages:
    2,970
    Location:
    England
    cmpi.w #$700,d0 ; check if level is 0700 (Special Stage)
    bne.s LevSel_Level ; if not, branch



    If d0 is $700, it will load Special Stage (because it's not branching). If it's not $700, it will branch to "LevSel_Level". Can you post the code under the label "LevSel_Level" because I can't see it.


    EDIT: Having a quick look at the S1 SVN disassembly, you've probably got the table "LevSel_Ptrs" wrong? That's where it gets the pointers from. Can you also post that here?
     
    Last edited by a moderator: Sep 19, 2012
  17. Mike B Berry

    Mike B Berry A grandiose return Member

    Joined:
    Jun 6, 2012
    Messages:
    377
    Location:
    New places, newer motivation
    Well this is a bad thing to say, I don't run the SVN disassembly. I run the Hivebrain disassembly. There is another method to use, but I'm sure that I have overlooked it. I would very much like to send in the ASM file. Would that be alright?
     
  18. redhotsonic

    redhotsonic Also known as RHS Retired Staff

    Joined:
    Aug 10, 2007
    Messages:
    2,970
    Location:
    England

    No, just the code under the "LevSel_Level" label will do.
     
  19. GT Koopa

    GT Koopa Well-Known Member Member

    Joined:
    Mar 9, 2011
    Messages:
    83
    Location:
    Elgin. IL
    Ok, I was trying to make a new object in S3K, using one of the unused object slots. Specifically 25. But I ran into a problem. How in the world do I connect object 25 to my code? I searched through other objects (who are named with actual names in the asm files, not the number) to see if they had a line of code that directed it to their actual numbers. Nothing. I tried to see in the asm file if there was a special bunch of renaming code that pointed the object numbers to the renamed object names. Nothing. I tried to see if there was a renaming file outside the asm file. Couldn't find it. What am I missing?


    Edit: found it with help. I guess I wasn't looking hard enough in the right folders.


    Levels-->Misc-->Object list
     
    Last edited by a moderator: Sep 20, 2012
  20. Mike B Berry

    Mike B Berry A grandiose return Member

    Joined:
    Jun 6, 2012
    Messages:
    377
    Location:
    New places, newer motivation

    Code:
    
    LevSel_Level_SS: ; XREF: LevelSelect
    
    add.w d0,d0
    
    move.l LSelectPointers(pc,d0.w),d0 ; load level number
    
    bmi.w LevelSelect
    
    <= PlaySpecialStage: (I backtracked my rom just in case.)
    
    cmpi.w #$700,d0 ; check if level is 0700 (Special Stage)
    
    bne.s LevSel_Level ; if not, branch
    
    move.b #$10,($FFFFF600).w ; set screen mode to $10 (Special Stage)
    
    clr.w ($FFFFFE10).w ; clear level
    
    move.b #3,($FFFFFE12).w ; set lives to 3
    
    moveq #0,d0
    
    move.w d0,($FFFFFE20).w ; clear rings
    
    move.l d0,($FFFFFE22).w ; clear time
    
    move.l d0,($FFFFFE26).w ; clear score
    
    ; ===========================================================================
    
    LevSel_Level: ; XREF: LevSel_Level_SS
    
    andi.w #$3FFF,d0
    
    move.w d0,($FFFFFE10).w ; set level number
    
    
    
    PlayLevel: ; XREF: ROM:00003246j ...
    
    if DemoRecord=1
    
    move.b #$8,($FFFFF600).w ; set screen mode to $08
    
    else
    
    move.b #$C,($FFFFF600).w ; set screen mode to $0C (level)
    
    endif
    
    move.b #3,($FFFFFE12).w ; set lives to 3
    
    moveq #0,d0
    
    move.w d0,($FFFFFE20).w ; clear rings
    
    move.l d0,($FFFFFE22).w ; clear time
    
    move.l d0,($FFFFFE26).w ; clear score
    
    move.b d0,($FFFFFE16).w ; clear special stage number
    
    move.b d0,($FFFFFE57).w ; clear emeralds
    
    move.l d0,($FFFFFE58).w ; clear emeralds
    
    move.l d0,($FFFFFE5C).w ; clear emeralds
    
    move.b d0,($FFFFFE18).w ; clear continues
    
    move.b #$E0,d0
    
    bsr.w PlaySound_Special ; fade out music
    
    rts
    [/CODE]
     
    Last edited by a moderator: Sep 20, 2012