[Sonic 1] 1 Song Per Act

Discussion in 'Tutorials Archive' started by PsychoSk8r, Mar 24, 2008.

Thread Status:
Not open for further replies.
  1. PsychoSk8r

    PsychoSk8r HighKnights Member

    Joined:
    Aug 9, 2007
    Messages:
    271
    Location:
    Birmingham, UK
    First of all, before we modify any code, go into the "misc" folder, and find "muslist1.bin"


    Copy it twice, naming the resulting files "muslist3.bin" and "muslist4.bin"


    Now, to the coding.


    First, Open up sonic1.asm, and find the following:



    Code:
    ; ---------------------------------------------------------------------------
    
    ; Music	playlist
    
    ; ---------------------------------------------------------------------------
    
    MusicList:	incbin	misc\muslist1.bin
    
    		even


    Add the following below the even:



    Code:
    MusicList3:	incbin	misc\muslist3.bin
    
    		even
    
    MusicList4:	incbin	misc\muslist4.bin
    
    		even


    Now, find the following:



    Code:
    Level_PlayBgm:
    
    		lea	(MusicList).l,a1; load	music playlist
    
    		move.b	(a1,d0.w),d0; add d0 to a1
    
    		bsr.w	PlaySound; play music
    
    		move.b	#$34,($FFFFD080).w; load title	card object


    Now, i'm not gonna make this a copy paste job, but i'm going to describe how it works.

    Before the load music playlist command above, we need to add a check for the act. The act number is stored at $FFFFFE11, and to check, we need to run a check, and the command to check something is cmpi, and since we're checking a single byte, it's cmpi.b.

    In this game, the values are like so:

    Act1: $0

    Act2: $1

    Act3: $2



    We'll be starting with Act 2, as there will be no need to check for act 1.



    So, put all of that together, we've got:



    Code:
    cmpi.b	#$1,($FFFFFE11).w; is act 2?
    Simple enough?

    Now what if it isn't act 2, we need to branch to check for the next act. This line is self explanatory:



    Code:
    bne.s	CheckAct3&#59;if not, branch to CheckAct3


    Now, putting this together with the original load code, we'll get what we need. Find:



    Code:
    lea	(MusicList).l,a1; load	music playlist
    And replace it with:



    Code:
    cmpi.b	#$1,($FFFFFE11).w; is act 2?
    
    bne.s	CheckAct3&#59;if not, branch to CheckAct3
    
    lea	(MusicList3).l,a1; load music playlist
    
    bra.s   PlayBGM_Cont;branch to rest of code
    Done? Good, now we need to do the same thing for act 3.

    Below the code you just put there, put the following, it's the same, but checks for Act 3 instead:

    cmpi.b #$2,($FFFFFE11).w ; is act 2?

    bne.s PlayAct1 ;if not, branch to PlayAct1

    lea (MusicList4).l,a1 ; load music playlist

    bra.s PlayBGM_Cont ;branch to rest of code

    Code:
    PlayAct1:
    
    			   lea	(MusicList3).l,a1; load music playlist
    
    
    
    PlayBGM_Cont:
    Altogether, it should look like this:



    Code:
    Level_PlayBgm:	
    
    				cmpi.b	#$1,($FFFFFE11).w; is act 2?
    
    				bne.s   CheckAct3&#59;if not, branch to CheckAct3
    
    				lea	(MusicList3).l,a1; load act 2's music playlist
    
    				bra.s   PlayBGM_Cont&#59;branch to rest of code
    
    
    
    CheckAct3:
    
    				cmpi.b	#$2,($FFFFFE11).w; is act 3?
    
    				bne.s   PlayAct1&#59;if not, branch to PlayAct1
    
    				lea	(MusicList3).l,a1; load act 3's music playlist
    
    				bra.s   PlayBGM_Cont&#59;branch to rest of code
    
    
    
    PlayAct1:
    
    		lea	(MusicList).l,a1; load	music playlist
    
    
    
    PlayBGM_Cont:
    
    		move.b	(a1,d0.w),d0; add d0 to a1
    
    		bsr.w	PlaySound; play music
    
    		move.b	#$34,($FFFFD080).w; load title	card object

    That's all the coding done, you just need to modify the playlists with a hex editor, which is very simple.


    Enjoy =P
     
    Last edited by a moderator: Feb 6, 2009
  2. GasparXR

    GasparXR Rides the metal monster Member

    Joined:
    Aug 10, 2007
    Messages:
    84
    Location:
    Ontario, Canada
    I edited the ASM file right, and all that. Sorry to be a n00b, but where's the address to modify the playlist and how do I do it? Or do I edit it in ASM? If so, where? Really sorry for being n00bish, and I do beleive it's easy to edit the playlist, I just don't know how exactly.


    On the plus side, I'm actually using programming code instead of a visual editor like I usually do=P


    EDIT: NVM, I got it. I opened the muslist3 and muslist 4 and it was straightforward from there=P


    Thanks for posting this. PsychoSk8R H41L :D
     
    Last edited by a moderator: Apr 12, 2008
Thread Status:
Not open for further replies.