Basic Questions and Answers Thread

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

  1. AsuharaMoon

    AsuharaMoon kakyoin did you lay this egg Member

    Joined:
    Aug 15, 2013
    Messages:
    67
    Which would be the most efficient way to extend the slots of S1's 68k Sound Driver? I just used this old guide from Sonic Retro as a practice base, which partly worked. But then there's the issue that sometimes the overload of SFXs (I guess?) skips the checks and plays the sound of the other bunch ($80-$FF rather than $01-$7F), being a really obvious mistake for someone who's not used to alter these things.

    This is how I ended up organizing it (and what I'm trying to achieve as well):
    Side 1
    Music: $01-$4F
    SFXs: $50-$7F
    Side 2
    SFXs: $81-$FA
    Special SFXs: $FB-$FF ($E0-$E4)
     
  2. penPhobic

    penPhobic Everything's all topsy-turvy now. Member

    Joined:
    Dec 11, 2016
    Messages:
    67
    Location:
    Basement
    One more question, I wanted to port Sonic 3 soundriver to Sonic 1 and it didn't work pretty well. I used the Retro's guide. I'm using the Hivebrain ASM68K disassembly btw.
     
  3. Inferno

    Inferno Rom Hacker Member

    Joined:
    Oct 27, 2015
    Messages:
    132
    Location:
    Sky Base Zone, South Island
    "It didn't work pretty well" isn't enough info. What exactly went wrong?
     
  4. Devon

    Devon Down you're going... down you're going... Member

    Joined:
    Aug 26, 2013
    Messages:
    1,372
    Location:
    your mom
    I think you're better off using this. It has a copy of the S3K sound driver fixed up for Natsumi's Z80 macro set for ASM68K and also SMPS2ASM and a few songs already converted. Way more flexible to use than the one in the old Sonic 3 sound driver porting guide.
     
    ProjectFM and penPhobic like this.
  5. ValleyBell

    ValleyBell Well-Known Member Member

    Joined:
    Dec 23, 2011
    Messages:
    166
    I recommend to completely revert the changes you did by following that guide and then do the index extension in a non-hackish way.
    Overview of the changes:
    • change the "empty" ID from $80 to $00
    • change the ID ranges to go from $81..$FF to $01..$FF (plus fixing the "ID $00 = stop all" behaviour)
    • adjust the sound priority array

    Code snippets are from the GitHub disassembly, but label names for the 2005 Hivebrain disasm are included as well.
    1. [S1 GitHub version only] adjust sound IDs
    • open Constants.asm and change the values for bgm__First / sfx__First / spec__First / flg__First to whatever you need
    • flg__First is the sound drivercontrol commands (stop sound, fading, etc)
    • spec__First is the index of the GHZ waterfall ("special SFX" category, I call them "background SFX" recently)
    2. fix the sound queue
    • extend the SoundPriorities array to $FF entries
      Values < $80 are for SFX, values >= $80 are for music/sound driver control.
    • in Sound_Play / CycleSoundQueue, search for this
      Code:
             subi.b   #bgm__First,d0       ; Make it into 0-based index
             blo.s   @nextinput       ; If negative (i.e., it was $80 or lower), branch
             cmpi.b   #$80,v_sound_id(a6)   ; Is v_sound_id a $80 (silence/empty)?
             beq.s   @havesound       ; If yes, branch
      
      Replace the "cmpi.b #$80" with a "tst.b", because the "empty" ID will now be 0. (tst = compare with 0)
      In the 2005 Hivebrain disassembly, you'll also have to fix the value of bgm__First manually.
    3. fix "empty" ID check in main update routine
    • Code:
      ; loc_71BBC:
      @nosndinput:
             cmpi.b   #$80,v_sound_id(a6)   ; is song queue set for silence (empty)?
             beq.s   @nonewsound       ; If yes, branch
             jsr   PlaySoundID(pc)
    • Instead of comparing with #$80, we just need to test for 0. Just as above.
    4. fix IDs in BGM/SFX/command selection routine
    • go to Sound_ChkValue / PlaySoundID
    • Code:
             move.b   v_sound_id(a6),d7
             beq.w   StopAllSound
             bpl.s   @locret           ; If >= 0, return (not a valid sound, bgm or command)
             move.b   #$80,v_sound_id(a6)   ; reset music flag
      Remove the branch to StopAllSound (It was doing that for ID 0, but we don't want that and there is a separate command for that.) and make the the conditional branch to @locret a "beq". This will make sound ID 0 have no effect (as intended).
    • We have to reset the "music flag" by setting it to 0 now.
    • If you use the Hivebrain disasm, you need to adjust all the other IDs here.
    5. [2005 Hivebrain only] fix the sound IDs in the functions that load music/SFX/...
    • In Sound_81to9F (Sound_PlayBGM) adjust the first cmpi.b, which checks for the extra life ID.
      In loc_7202C (bgm_loadMusic), there is a "subi.b #$81,d7". The $81 is the ID of the first song, so adjust that.
    • In Sound_A0toCF (Sound_PlaySFX) you need to adjust a few cmpi.b/move.b instructions that handle special SFX (ring / pushing blocks). The final line to adjust is "subi.b #$A0,d7". The value $A0 refers to the first sound effect ID here.
    • In Sound_D0toDF (Sound_PlaySpecial) there is only a "subi.b #$D0,d7" to fix.
    • Finally, in loc_71F8E (Sound_E0toE4) you need to fix the "subi.b #$E0,d7".
    • Note: The sound ID is stored in register d7. So when searching for instructions to change, make sure they do something with register d7.
    That should be everything you need to do in order to have a clean sound index extension on the sound driver side.
    Finding and fixing all the sound IDs scattered in the main game is another story.
     
    AsuharaMoon and MainMemory like this.
  6. AsuharaMoon

    AsuharaMoon kakyoin did you lay this egg Member

    Joined:
    Aug 15, 2013
    Messages:
    67
    Do I ever said how much I love your contributions? Thanks a lot!

    Btw, one more thing. Is this SoundTypes/SoundPriorities organized fine enough? Cuz' I tried making it more similar to the one from GitHub's S1, but Hivebrain's dc.b kinda forces it to fill them all with the same quantity (16 each one), or else it crashes the game from the beginning.

    Code:
    SoundTypes:
            dc.b $90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90    ; $01-$10 (Music)
            dc.b $90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90    ; $11-$20 ^
            dc.b $90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90    ; $21-$30 ^
            dc.b $90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90    ; $31-$40 ^
            dc.b $90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$80    ; $41-$50 ^
            dc.b $70,$70,$70,$70,$70,$70,$70,$70,$70,$68,$70,$70,$70,$60,$70,$70    ; $51-$60 (S1 SFXs $A0-$AF)
            dc.b $60,$70,$60,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$7F,$60    ; $61-$70 (S1 SFXs $B0-$BF)
            dc.b $70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$80    ; $71-$80 (S1 SFXs $C0-$CF)
            dc.b $70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70    ; $81-$90 (SFXs)
            dc.b $70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70    ; $91-$A0 ^
            dc.b $70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70    ; $A1-$B0 ^
            dc.b $70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70    ; $B1-$C0 ^
            dc.b $70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70    ; $C1-$D0 ^
            dc.b $70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70    ; $D1-$E0 ^
            dc.b $70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70    ; $E1-$F0 ^
            dc.b $70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$90,$90,$90,$90,$90,$80    ; $F1-$?0 (Last SFXs; driver commands)
    
     
  7. ValleyBell

    ValleyBell Well-Known Member Member

    Joined:
    Dec 23, 2011
    Messages:
    166
    You only need values for $01 to $FF. (I usually have $01-$0F on the first line and $10-$1F on the second one.)
    The crashes are caused by a lack of word alignment of the following data.
    The proper way of doing alignment is using the even keyword after byte-sized arrays.
     
    ProjectFM and AsuharaMoon like this.
  8. Tanman Tanner

    Tanman Tanner Well-Known Member Member

    Joined:
    Dec 23, 2016
    Messages:
    116
    Location:
    Buffalo, New York
    It's probably been explained before, but I gotta ask: in Sonic 1, how would I load the bumper sprites in a zone such as Star Light Zone? It appears to use the see-saw sprites, so do I need to overwrite see-saw's sprites in order to have the bumpers?
    If it's in .asm file specific locations, what is it? (I'm using the s1disasm AS branch)
     
  9. CreepyMystery

    CreepyMystery Reminiscence and Semblance Member

    Joined:
    Oct 20, 2017
    Messages:
    36
    This might not be an excellent explanation, but search in the "_inc" folder, and look for a file called "Pattern load cues.asm", this holds the data for which art loads where in a zone. To have bumpers in that zone, copy and paste the bumper entry into the Star Light entries. Make sure to add 1 to the "dc.w" instruction to the right of the label. This tells the list "Hey, you have a new entry".
     
    Tanman Tanner likes this.
  10. Tanman Tanner

    Tanman Tanner Well-Known Member Member

    Joined:
    Dec 23, 2016
    Messages:
    116
    Location:
    Buffalo, New York
    It works for the bumper, but now it overwrites the see-saw sprites. But I'll figure it out.
     
  11. Eiskaffee

    Eiskaffee Tails in in the sonic movie Member

    Joined:
    May 1, 2016
    Messages:
    12
    Location:
    United States
    When trying to port Knuckles Ending using MainMemory's guide I get a bunch of errors
    heres the code from s2.log

    (im assuming the guide is outdated given that bra.w didnt exist under LoadCharacterArt_Tails)
    I added it under jmpto at the end of LoadCharacterArt_Tails
    Code:
    > > >s2.asm(4531): error: jump distance too big
    > > >     bsr.w    LevelSizeLoad
    > > >s2.asm(13243): error: addressing mode not allowed on 68000
    > > >     move.l    word_A656(pc,d0.w),d1
    > > >s2.asm(13243): error: addressing mode not allowed here
    > > >     move.l    word_A656(pc,d0.w),d1
    > > >s2.asm(55641): error: addressing mode not allowed on 68000
    > > >     lea    Obj70_Positions(pc,d1.w),a1
    > > >s2.asm(55641): error: addressing mode not allowed here
    > > >     lea    Obj70_Positions(pc,d1.w),a1
     
  12. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    922
    I never finished that part of the guide. That said, change that first line to jmp (LevelSizeLoad).l and the rest of the errors will probably disappear.
     
  13. Eiskaffee

    Eiskaffee Tails in in the sonic movie Member

    Joined:
    May 1, 2016
    Messages:
    12
    Location:
    United States
    it made the first one go away but the bottom 4 are not going away same error am I supposed to change the bra.w to match the other loadcharacter arts or

    EDIT: nvm im stupid i did it wrong it probably will work now (it still didn't pfft)

    Code:
    > > >s2.asm(13243): error: addressing mode not allowed on 68000
    > > >     move.l    word_A656(pc,d0.w),d1
    > > >s2.asm(13243): error: addressing mode not allowed here
    > > >     move.l    word_A656(pc,d0.w),d1
    > > >s2.asm(55641): error: addressing mode not allowed on 68000
    > > >     lea    Obj70_Positions(pc,d1.w),a1
    > > >s2.asm(55641): error: addressing mode not allowed here
    > > >     lea    Obj70_Positions(pc,d1.w),a1
    
     
    Last edited: Dec 14, 2019
  14. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    922
    Then I guess you moved those instructions too far away from the labels they reference. You can either try to move the data at the label closer, or rewrite them so it loads the label's address into a1 first [lea (label).l,a1] and then uses a1 instead of pc in the next line, and remove the label too.
     
  15. DeltaWooloo

    DeltaWooloo The noob next door Member

    Joined:
    Aug 7, 2019
    Messages:
    373
    Hey guys! Hope you are having a wonderful Christmas holiday. Just a quick question to ask.


    I'm porting Chrome Gadget's background into Sonic 1, but rather than getting what I want, the background is messed up. Is there any way for me to sort this out via SonLVL or Hivebrain's 2005 source code?

    Screenshot 2019-12-20 at 19.02.16.png
     
  16. Inferno

    Inferno Rom Hacker Member

    Joined:
    Oct 27, 2015
    Messages:
    132
    Location:
    Sky Base Zone, South Island
    It appears that the BG is still loading SLZ graphics. Make sure you delete all BG art (in SonLVL, including tiles, blocks, and chunks) before importing, that may help.
     
  17. DeltaWooloo

    DeltaWooloo The noob next door Member

    Joined:
    Aug 7, 2019
    Messages:
    373
    Alright, it works. Thanks so much. Just another question. Inspired by Iso Kilo tutorial for adding that unused jumping-victory animation, I decided to follow his step but to do the victory animation used in the Sega CD BIOS. So I replaced the unused animation to the Sega CD sprites. What I want Sonic to do is to land on the floor, lock the controls and do his victory animation until the next act occurs, similar to Sonic 3 and Knuckles. But my coding skills are a bit off. When I gave it a go, it looked like this:
    Screenshot 2019-12-21 at 08.31.55.png The signpost was garbled, Sonic used his last animation before the controls were locked.

    I'm not sure what's going on. Is it OK if you can help me with this? (Hivebrain 2005 code only) Here are more screenshots if you desire. Screenshot 2019-12-21 at 08.34.49.png Replaced unused animation with this.
    Screenshot 2019-12-21 at 08.32.22.png Code similar to Iso Kilo's tutorial.
     
  18. Inferno

    Inferno Rom Hacker Member

    Joined:
    Oct 27, 2015
    Messages:
    132
    Location:
    Sky Base Zone, South Island
    You are telling the signpost to use animation 2, not Sonic. Do this:
    Code:
    move.b   #2,($FFFFD01C).w
    This moves #2 to Sonic's animation SST.
    Do similar where you are moving #$13 to $1C.
    That'll at least send the animation number to the right place.
    Edit: Also, I feel like the victory flag is kinda redundant in this case. Also, you can't use beq and it's siblings on a move command, IIRC.
     
  19. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    922
    You can, but the result of the branch will be dependent on the value that was moved. For example, that first beq there will never be taken because you're always moving 1, and beq only branches if the result is 0.
     
  20. DeltaWooloo

    DeltaWooloo The noob next door Member

    Joined:
    Aug 7, 2019
    Messages:
    373
    Another question. The sound driver is behaving weird. The peelout sound makes some grating noise, the spindash sound effect has some lag at the end. This didn't happen before. Do you know why?
     
    Last edited: Dec 22, 2019
    Trickster likes this.