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
    It's a joke?
    I said that i have already trying to place checks, there several hours and still doesn't work.
    Almost 48 hours i'm working on and with all the help SSRG gives me, i can't do it. So YES i'm stuck.

    EDIT:
    I have trying again to place checks into the routines, like this:
    ; ---------------------------------------------------------------------------
    ; Subroutine to load pattern load cues
    ; ---------------------------------------------------------------------------

    ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
    LoadPLC:
    movem.l a1-a2,-(sp)
    cmpi.w #$01,($FFFFFFFE).w ; if player flag set
    bne.s LoadPLC_Cont
    beq.s ArtLoadCuesGo

    LoadPLC_Cont:
    lea (ArtLoadCues).l,a1
    add.w d0,d0
    move.w (a1,d0.w),d0
    lea (a1,d0.w),a1
    lea ($FFFFF680).w,a2
    bra.s loc_1598

    ArtLoadCuesGo:
    lea (ArtLoadCues2).l,a1
    add.w d0,d0
    move.w (a1,d0.w),d0
    lea (a1,d0.w),a1
    lea ($FFFFF680).w,a2

    loc_1598:
    tst.l (a2)
    beq.s loc_15A0
    addq.w #6,a2
    bra.s loc_1598
    ; ===========================================================================

    loc_15A0: ; XREF: LoadPLC
    move.w (a1)+,d0
    bmi.s loc_15AC

    loc_15A4:
    move.l (a1)+,(a2)+
    move.w (a1)+,(a2)+
    dbf d0,loc_15A4

    loc_15AC:
    movem.l (sp)+,a1-a2
    rts
    ; End of function LoadPLC


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


    LoadPLC2:
    movem.l a1-a2,-(sp)
    cmpi.w #$01,($FFFFFFFE).w ; if player flag set
    bne.s LoadPLC2_Cont
    beq.s ArtLoadCuesGo2

    LoadPLC2_Cont:
    lea (ArtLoadCues).l,a1
    add.w d0,d0
    move.w (a1,d0.w),d0
    lea (a1,d0.w),a1
    bsr.s ClearPLC
    lea ($FFFFF680).w,a2
    move.w (a1)+,d0
    bmi.s loc_15D8
    bra.s loc_15D0

    ArtLoadCuesGo2:
    lea (ArtLoadCues2).l,a1
    add.w d0,d0
    move.w (a1,d0.w),d0
    lea (a1,d0.w),a1
    bsr.s ClearPLC
    lea ($FFFFF680).w,a2
    move.w (a1)+,d0
    bmi.s loc_15D8

    loc_15D0:
    move.l (a1)+,(a2)+
    move.w (a1)+,(a2)+
    dbf d0,loc_15D0

    loc_15D8:
    movem.l (sp)+,a1-a2
    rts
    ; End of function LoadPLC2

    ; ---------------------------------------------------------------------------
    ; Subroutine to clear the pattern load cues
    ; ---------------------------------------------------------------------------

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


    ClearPLC: ; XREF: LoadPLC2
    lea ($FFFFF680).w,a2
    moveq #$1F,d0

    ClearPLC_Loop:
    clr.l (a2)+
    dbf d0,ClearPLC_Loop
    rts
    ; End of function ClearPLC

    ; ---------------------------------------------------------------------------
    ; Subroutine to use graphics listed in a pattern load cue
    ; ---------------------------------------------------------------------------

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


    RunPLC_RAM: ; XREF: Pal_FadeTo
    tst.l ($FFFFF680).w
    beq.s locret_1640
    tst.w ($FFFFF6F8).w
    bne.s locret_1640
    movea.l ($FFFFF680).w,a0
    lea (loc_1502).l,a3
    lea ($FFFFAA00).w,a1
    move.w (a0)+,d2
    bpl.s loc_160E
    adda.w #$A,a3

    loc_160E:
    andi.w #$7FFF,d2
    move.w d2,($FFFFF6F8).w
    bsr.w NemDec4
    move.b (a0)+,d5
    asl.w #8,d5
    move.b (a0)+,d5
    moveq #$10,d6
    moveq #0,d0
    move.l a0,($FFFFF680).w
    move.l a3,($FFFFF6E0).w
    move.l d0,($FFFFF6E4).w
    move.l d0,($FFFFF6E8).w
    move.l d0,($FFFFF6EC).w
    move.l d5,($FFFFF6F0).w
    move.l d6,($FFFFF6F4).w

    locret_1640:
    rts
    ; End of function RunPLC_RAM


    ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
    sub_1642: ; XREF: loc_C44; loc_F54; loc_F9A
    tst.w ($FFFFF6F8).w
    beq.w locret_16DA
    move.w #9,($FFFFF6FA).w
    moveq #0,d0
    move.w ($FFFFF684).w,d0
    addi.w #$120,($FFFFF684).w
    bra.s loc_1676
    ; End of function sub_1642


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


    sub_165E: ; XREF: Demo_Time
    tst.w ($FFFFF6F8).w
    beq.s locret_16DA
    move.w #3,($FFFFF6FA).w
    moveq #0,d0
    move.w ($FFFFF684).w,d0
    addi.w #$60,($FFFFF684).w

    loc_1676: ; XREF: sub_1642
    lea ($C00004).l,a4
    lsl.l #2,d0
    lsr.w #2,d0
    ori.w #$4000,d0
    swap d0
    move.l d0,(a4)
    subq.w #4,a4
    movea.l ($FFFFF680).w,a0
    movea.l ($FFFFF6E0).w,a3
    move.l ($FFFFF6E4).w,d0
    move.l ($FFFFF6E8).w,d1
    move.l ($FFFFF6EC).w,d2
    move.l ($FFFFF6F0).w,d5
    move.l ($FFFFF6F4).w,d6
    lea ($FFFFAA00).w,a1

    loc_16AA: ; XREF: sub_165E
    movea.w #8,a5
    bsr.w NemDec3
    subq.w #1,($FFFFF6F8).w
    beq.s loc_16DC
    subq.w #1,($FFFFF6FA).w
    bne.s loc_16AA
    move.l a0,($FFFFF680).w
    move.l a3,($FFFFF6E0).w
    move.l d0,($FFFFF6E4).w
    move.l d1,($FFFFF6E8).w
    move.l d2,($FFFFF6EC).w
    move.l d5,($FFFFF6F0).w
    move.l d6,($FFFFF6F4).w

    locret_16DA: ; XREF: sub_1642
    rts
    ; ===========================================================================

    loc_16DC: ; XREF: sub_165E
    lea ($FFFFF680).w,a0
    moveq #$15,d0

    loc_16E2: ; XREF: sub_165E
    move.l 6(a0),(a0)+
    dbf d0,loc_16E2
    rts
    ; End of function sub_165E

    ; ---------------------------------------------------------------------------
    ; Subroutine to execute the pattern load cue
    ; ---------------------------------------------------------------------------

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


    RunPLC_ROM:
    cmpi.w #$01,($FFFFFFFE).w ; if player flag set
    bne.s RunPLC_Cont
    beq.s ArtLoadCuesGo3

    RunPLC_Cont:
    lea (ArtLoadCues).l,a1 ; load the PLC index
    add.w d0,d0
    move.w (a1,d0.w),d0
    lea (a1,d0.w),a1
    move.w (a1)+,d1 ; load number of entries in the PLC
    bra.s RunPLC_Loop

    ArtLoadCuesGo3:
    lea (ArtLoadCues2).l,a1 ; load the PLC index
    add.w d0,d0
    move.w (a1,d0.w),d0
    lea (a1,d0.w),a1
    move.w (a1)+,d1 ; load number of entries in the PLC

    RunPLC_Loop:
    movea.l (a1)+,a0 ; get art pointer
    moveq #0,d0
    move.w (a1)+,d0 ; get VRAM address
    lsl.l #2,d0 ; divide address by $20
    lsr.w #2,d0
    ori.w #$4000,d0
    swap d0
    move.l d0,($C00004).l ; put the VRAM address into VDP
    bsr.w NemDec ; decompress
    dbf d1,RunPLC_Loop ; loop for number of entries
    rts
    ; End of function RunPLC_ROM

    That doesn't work, but moreover, i have a new problem, the life counter number disappeared:
     

    Attached Files:

  2. Painto

    Painto Samodzierżca Najdłuższego Kija Member

    Joined:
    Mar 24, 2014
    Messages:
    315
    Location:
    Poland
    Yet again, you make easy things hard. Instead of all these hackish things, you may just do this:
    Code:
    ...code...
      lea (ArtLoadCues).l,a1 ; or whatever you want to swap when playing with Ashuro
      tst.w ($FFFFFFFE).w
      beq.s Code_cont
      lea (ArtLoadCues2).l,a1
    Code_cont:
    ...moar code...
    
     
  3. Xeal

    Xeal The Nuke Retired Staff

    Joined:
    Mar 10, 2016
    Messages:
    227
    Your response blatantly ignores my suggestion of pasting code when you ask for help.
    Also using proper grammar and being clearer in your explanations would speak to you how long you've been working on this. Don't expect me to know you've been working on this for 2 days. I'm no mind reader.
     
    Misinko, jubbalub and TheStoneBanana like this.
  4. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    528
    Location:
    France
    Okay i will do it more easily. I'm a beginner.

    I'm sorry , I do not want to seem rude. (sorry for "bad grammar"), i'm french.
    I have not ignored your help, on the contrary.
    Following your help gives me another error. :(
     
  5. TheStoneBanana

    TheStoneBanana The Bananaman Member

    Joined:
    Nov 27, 2013
    Messages:
    605
    Location:
    The Milky Way Galaxy
    Ashuro, I must once again recommend that you read up more on 68k ASM. The examples of code you posted here are messy and some don't even make sense. They most likely have a hand in your problem.

    Now, for my suggestions.
    A.) Use something other than $FFFFFFFE. There is sooo much other free RAM for you to use in Sonic 1. Give the "Sonic 1 RAM Editing" page on Retro a gander to see what I mean.
    B.) Don't read/write the flag as a word. It's a waste of space. Just read/write it as a byte with the '.b' extension on the opcode.
     
  6. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    528
    Location:
    France
    Thank you, my problem is solved, i have choosen the flag "$FFFFF601" and it's work perfectly!
     
  7. Pacca

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

    Joined:
    Jul 5, 2014
    Messages:
    1,149
    Location:
    Triton (Moon)
    Just a quick word of advice, Ashuro; don't use odd ram addresses. Even ones are fine, but odd values will crash genuine hardware and more accurate emulators when used for word or long values. I learned this the hard way, and it was a pain to track down and fix.
     
  8. AURORA☆FIELDS

    AURORA☆FIELDS the cute one here Member

    Joined:
    Oct 7, 2011
    Messages:
    711
    Location:
    Nathan's arms <3
    using odd addresses is fine, if you keep in mind never to do word/long read/writes. It would be really silly to not use a good chunk of the RAM because "it could crash".
     
    Ralakimus likes this.
  9. TheStoneBanana

    TheStoneBanana The Bananaman Member

    Joined:
    Nov 27, 2013
    Messages:
    605
    Location:
    The Milky Way Galaxy
    Right then. So... Natsumi pointed out to me that my answer here was perhaps a bit too vague and misleading in terms of what you should be doing, Ashuro. Though it fixed your problem, I should have explained to you why you needed to change that RAM address. So, I will now! :D

    $FFFFFFFE is used space. It shows there on that RAM editing page, and you can see that its written to during the checksum routine.
    Code:
        move.l   #'init',($FFFFFFFC).w ; set flag so checksum won't be run again
    
    The old guide that you were using, Ashuro, is pretty awful, and uses this space to contain its flag.

    So, ah, yeah. That's why you needed to change that. Sorry for leaving that out earlier.

    EDIT: It's worth mentioning as well that this space isn't used in the game itself, but it's still not a good idea to write there due to the fact that soft resets exists, and they check that space to make sure the Checksum routine has ran before. Since you would have changed it in-game, it would think that the routine HASNT run before, and it would have to calculate the same checksum allll over again
     
    Last edited: Jul 31, 2016
    MarkeyJester likes this.
  10. EonGenesis

    EonGenesis Newcomer Trialist

    Joined:
    Jul 31, 2016
    Messages:
    1
    Hello folks, I was wondering if it's possible to make a mod of the Fantasy Zone DLC track & kart on to the PC/Steam version of SA2B?

    My second question, is there a way we can make the XBLA/PSN version of Sonic the Fighters on PC with online play support since it's already build in the XBLA/PSN versions?
     
    Pokepunch, MarkeyJester and Xeal like this.
  11. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    877
    The format of the track data is not currently known. Porting the kart might be possible, I guess.

    You can't make a game designed for one platform run on another without one of three things: 1. the source code 2. an emulator 3. several years of reverse engineering.
     
  12. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    528
    Location:
    France
    Thank you all!!
    I will keep in mind this in mind!
    I have noticed that since yesterday, using the "$FFFFF601" ram address, and since i've using it, some bad tiles appears when i'm running at some parts of my levels.

    EDIT: it's better to show my problem:
    EDIT 2: i have noticed that the problem appears when there is a motobug on screen.
    EDIT 3: The glitch tiles problem only happens on a motobug. And the motobug doesn't move, he turns on himself and the tiles glitch appears, i don't know why he do this.
    EDIT 4: same problem on the "Sonic has passed" title card of the Green Hill act 2:
    I really don't know anything about it, what i'm doing wrong or if it's a pattern load cues problem.
     

    Attached Files:

    Last edited: Aug 1, 2016
  13. Clownacy

    Clownacy Well-Known Member Staff

    Joined:
    Aug 15, 2014
    Messages:
    888
    It looks like bad mappings, which you can get from an invalid obMap pointer, using an invalid obFrame, or the mapping file itself being broken. Not sure how changing the PLCs caused that, so it could be some other change you made. You say the Motobug doesn't move, so its code's probably been broken. As for the end-of-act tally, that could be a bad obFrame. Like, somehow the mapping file no longer has a frame for the 'act 2' text.
     
  14. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    528
    Location:
    France
    Now this is the lamppost :D
    Then, i will check if this is the mappings and the frames.

    I have looked at the lampost and moto bug's art, mappings on SonMapEd.
    Pattern Load Cues file too and there no problem or error.

    But ingame it's the same problem.
     

    Attached Files:

    Last edited: Aug 1, 2016
  15. Clownacy

    Clownacy Well-Known Member Staff

    Joined:
    Aug 15, 2014
    Messages:
    888
    The lamppost doesn't look like your usual bad mappings, which just throw garbage all over the screen. That looks like the lampost art was overwritten in VRAM.
     
  16. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    528
    Location:
    France

    In fact, I think all my problems is from an overwritten VRAM. And i know nothing about that.

    EDIT: After trying somethings with the art, plc and, my problem is the same.
    I have edited the VRAM adress in Pattern Load cues.asm and it's even worse.
    I'm a NOOB in VRAM, what i have to do? I don't want to cancel my hack or begin from the start...
     
    Last edited: Aug 1, 2016
  17. FireRat

    FireRat Well-Known Member Exiled

    Joined:
    Oct 31, 2009
    Messages:
    544
    For SonED2, is it possible to read 256x256-sized chunks in Sonic 2's format properly? How to do so?
     
  18. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    877
    I'm assuming you mean dual path 256x256 chunks. Based on the documentation, I'm assuming that SonED2 only supports single path 256x256 chunks or dual path 128x128 chunks.

    Based on that, your only option is to use SonLVL, which allows you to specify an arbitrary multiple of 16 for chunk size (chunksize=256), or even width and height separately (chunkwidth=256, chunkheight=256).
     
    FireRat likes this.
  19. FireRat

    FireRat Well-Known Member Exiled

    Joined:
    Oct 31, 2009
    Messages:
    544
    Actually, time later I found out that by forcing double path, SonED2 uses two unused bits from original Sonic 1 format (as explained here: http://info.sonicretro.org/SCHG:Sonic_the_Hedgehog_(16-bit)/Level_Editing):

    0SSY X0II IIII IIII
    With the first being the 2nd path's "side collision" and the latter "Top collision" bits respectively.
    Rare implementation, nor I see it documented anywhere...
    Thanks for your reply, you saved me a ton of reformatting work ;)
     
  20. jubbalub

    jubbalub Mania fanboy Member

    Joined:
    Dec 25, 2014
    Messages:
    279
    So after studying loopnums.bin, I was able to make a custom loop chunk for Green Hill, but the same can not be said for Spring Yard, and I'm not sure what I'm doing wrong. Help?

    upload_2016-8-2_16-34-22.png

    upload_2016-8-2_16-36-30.png upload_2016-8-2_16-36-13.png

    And before anyone asks, I did set the loop tag.