• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Trading Card Game 2 protagonist in the poll by clicking here.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

How to loop those pesky .patt statements in a .s file

Fallenleader

Residential Pixelated Squirrel
  • 96
    Posts
    16
    Years
    ever noticed that you cannot just slap a looping statement in a .pat file and it work?
    well there is a way around this, and i will show you how.

    when you convert a .s file you get something like this. i will hilight the important stuff.
    Code:
        .include "MPlayDef.s"
    
        .equ    goldenrodexample_grp, voicegroup000
        .equ    goldenrodexample_pri, 0
        .equ    goldenrodexample_rev, 0
        .equ    goldenrodexample_mvl, 127
        .equ    goldenrodexample_key, 0
        .equ    goldenrodexample_tbs, 1
        .equ    goldenrodexample_exg, 0
        .equ    goldenrodexample_cmp, 1
    
        .section .rodata
        .global    goldenrodexample
        .align    2
    
    @**************** Track 1 (Midi-Chn.1) ****************@
    
    goldenrodexample_1:
        .byte    KEYSH , goldenrodexample_key+0
    @ 000   ----------------------------------------
        .byte    TEMPO , 100*goldenrodexample_tbs/2
        .byte        VOICE , 14
        .byte        PAN   , c_v-32
        .byte        VOL   , 64*goldenrodexample_mvl/mxv
        .byte        N24   , Fn4 , v104
        .byte    W24
        .byte                Cs4 
        .byte    W24
        .byte                Ds4 
        .byte    W24
        .byte                Cn4 
        .byte    W24
    @ 001   ----------------------------------------
    [S-HIGHLIGHT]goldenrodexample_1_001:[/S-HIGHLIGHT]
        .byte        N12   , Cs4 , v104
        .byte    W12
        .byte                Cn4 
        .byte    W12
        .byte                As3 
        .byte    W12
        .byte                Cn4 
        .byte    W12
        .byte        N36   , Gs3 
        .byte    W36
        .byte        N06   
        .byte    W06
        .byte                An3 
        .byte    W06
        .byte    PEND
    @ 002   ----------------------------------------
        .byte        N24   , As3 
        .byte    W24
        .byte                Cs4 
        .byte    W24
        .byte        N12   , As3 
        .byte    W12
        .byte                As4 
        .byte    W12
        .byte                Gs4 
        .byte    W12
        .byte                Fs4 
        .byte    W10
        .byte        VOICE , 60
        .byte    W02
    @ 003   ----------------------------------------
        .byte        N12   , Fn4 
        .byte    W12
        .byte                Fs4 
        .byte    W12
        .byte                Gs4 
        .byte    W12
        .byte                Fn4 
        .byte    W12
        .byte        N36   , Ds4 
        .byte    W48
    @ 004   ----------------------------------------
    goldenrodexample_1_004:
        .byte        N24   , Fn4 , v104
        .byte    W24
        .byte                Cs4 
        .byte    W24
        .byte                Ds4 
        .byte    W24
        .byte                Cn4 
        .byte    W24
        .byte    PEND
    @ 005   ----------------------------------------
        [S-HIGHLIGHT].byte    PATT
         .word    goldenrodexample_1_001[/S-HIGHLIGHT]
    @ 006   ----------------------------------------
    see the pattern statement?
    this is a auto loop as i call it.
    this has nothing to do with the final looping pattern statements which must exist.
    so here is the fix. see how it sats
    .byte PATT
    .word goldenrodexample_1_001?
    well go to 001, copy all of that, and replace the .patt with it like this:
    Code:
        .include "MPlayDef.s"
    
        .equ    goldenrodexample_grp, voicegroup000
        .equ    goldenrodexample_pri, 0
        .equ    goldenrodexample_rev, 0
        .equ    goldenrodexample_mvl, 127
        .equ    goldenrodexample_key, 0
        .equ    goldenrodexample_tbs, 1
        .equ    goldenrodexample_exg, 0
        .equ    goldenrodexample_cmp, 1
    
        .section .rodata
        .global    goldenrodexample
        .align    2
    
    @**************** Track 1 (Midi-Chn.1) ****************@
    
    goldenrodexample_1:
        .byte    KEYSH , goldenrodexample_key+0
    @ 000   ----------------------------------------
        .byte    TEMPO , 100*goldenrodexample_tbs/2
        .byte        VOICE , 14
        .byte        PAN   , c_v-32
        .byte        VOL   , 64*goldenrodexample_mvl/mxv
        .byte        N24   , Fn4 , v104
        .byte    W24
        .byte                Cs4 
        .byte    W24
        .byte                Ds4 
        .byte    W24
        .byte                Cn4 
        .byte    W24
    @ 001   ----------------------------------------
    goldenrodexample_1_001:
        .byte        N12   , Cs4 , v104
        .byte    W12
        .byte                Cn4 
        .byte    W12
        .byte                As3 
        .byte    W12
        .byte                Cn4 
        .byte    W12
        .byte        N36   , Gs3 
        .byte    W36
        .byte        N06   
        .byte    W06
        .byte                An3 
        .byte    W06
        .byte    PEND
    @ 002   ----------------------------------------
        .byte        N24   , As3 
        .byte    W24
        .byte                Cs4 
        .byte    W24
        .byte        N12   , As3 
        .byte    W12
        .byte                As4 
        .byte    W12
        .byte                Gs4 
        .byte    W12
        .byte                Fs4 
        .byte    W10
        .byte        VOICE , 60
        .byte    W02
    @ 003   ----------------------------------------
        .byte        N12   , Fn4 
        .byte    W12
        .byte                Fs4 
        .byte    W12
        .byte                Gs4 
        .byte    W12
        .byte                Fn4 
        .byte    W12
        .byte        N36   , Ds4 
        .byte    W48
    @ 004   ----------------------------------------
    goldenrodexample_1_004:
        .byte        N24   , Fn4 , v104
        .byte    W24
        .byte                Cs4 
        .byte    W24
        .byte                Ds4 
        .byte    W24
        .byte                Cn4 
        .byte    W24
        .byte    PEND
    @ 005   ----------------------------------------
    goldenrodexample_1_005:
        .byte        N12   , Cs4 , v104
        .byte    W12
        .byte                Cn4 
        .byte    W12
        .byte                As3 
        .byte    W12
        .byte                Cn4 
        .byte    W12
        .byte        N36   , Gs3 
        .byte    W36
        .byte        N06   
        .byte    W06
        .byte                An3 
        .byte    W06
        .byte    PEND
    @ 006   ----------------------------------------
    note i changed goldenrodexample_1_001: to goldenrodexample_1_005:. this is important so you
    dont get confused later or get a looping error. now these .patt statements must be present when looping. These you create yourself:
    Code:
        .include "MPlayDef.s"
    
        .equ    goldenrod_grp, voicegroup000
        .equ    goldenrod_pri, 0
        .equ    goldenrod_rev, 0
        .equ    goldenrod_mvl, 127
        .equ    goldenrod_key, 0
        .equ    goldenrod_tbs, 1
        .equ    goldenrod_exg, 0
        .equ    goldenrod_cmp, 1
    
        .section .rodata
        .global    goldenrod
        .align    2
    
    @**************** Track 1 (Midi-Chn.1) ****************@
    
    goldenrod_1:
        .byte    KEYSH , goldenrod_key+0
    @ 000   ----------------------------------------
        .byte    TEMPO , 100*goldenrod_tbs/2
        .byte        VOICE , 60
        .byte        PAN   , c_v-32
        .byte        VOL   , 64*goldenrod_mvl/mxv
        .byte        N24   , Fn4 , v104
        .byte    W24
        .byte                Cs4 
        .byte    W24
        .byte                Ds4 
        .byte    W24
        .byte                Cn4 
        .byte    W24
    @ 001   ----------------------------------------
        .byte        N12   , Cs4 , v104
        .byte    W12
        .byte                Cn4 
        .byte    W12
        .byte                As3 
        .byte    W12
        .byte                Cn4 
        .byte    W12
        .byte        N36   , Gs3 
        .byte    W36
        .byte        N06   
        .byte    W06
        .byte                An3 
        .byte    W06
    @ 002   ----------------------------------------
        .byte        N24   , As3 
        .byte    W24
        .byte                Cs4 
        .byte    W24
        .byte        N12   , As3 
        .byte    W12
        .byte                As4 
        .byte    W12
        .byte                Gs4 
        .byte    W12
        .byte                Fs4 
        .byte    W12
    @ 003   ----------------------------------------
        .byte        N12   , Fn4 
        .byte    W12
        .byte                Fs4 
        .byte    W12
        .byte                Gs4 
        .byte    W12
        .byte                Fn4 
        .byte    W12
        .byte        N36   , Ds4 
        .byte    W48
    @ 004   ----------------------------------------
        .byte        N24   , Fn4 , v104
        .byte    W24
        .byte                Cs4 
        .byte    W24
        .byte                Ds4 
        .byte    W24
        .byte                Cn4 
        .byte    W24
    @ 005   ----------------------------------------
    goldenrod_1_loop:
    goldenrod_1_005:
        .byte        N12   , Cs4 , v104
        .byte    W12
        .byte                Cn4 
        .byte    W12
        .byte                As3 
        .byte    W12
        .byte                Cn4 
        .byte    W12
        .byte        N36   , Gs3 
        .byte    W36
        .byte        N06   
        .byte    W06
        .byte                An3 
        .byte    W06
        .byte    PEND
    @ 006   ----------------------------------------
    goldenrod_1_006:
        .byte        N24   , As3 , v104
        .byte    W24
        .byte                Cs4 
        .byte    W24
        .byte        N12   , As3 
        .byte    W12
        .byte                As4 
        .byte    W12
        .byte                Gs4 
        .byte    W12
        .byte                Fs4 
        .byte    W12
        .byte    PEND
    @ 007   ----------------------------------------
    goldenrod_1_007:
        .byte                Gs4 
        .byte    W12
        .byte                As4 
        .byte    W12
        .byte                Cn5 
        .byte    W12
        .byte                Cs5 
        .byte    W12
        .byte        N36   , Ds5 
        .byte    W48
        .byte    PEND
    @ 008   ----------------------------------------
    goldenrod_1_008:
        .byte        N36   , Cs5 , v104
        .byte    W36
        .byte                Fn5 
        .byte    W36
        .byte        N24   , Cs5 
        .byte    W24
        .byte    PEND
    @ 009   ----------------------------------------
    goldenrod_1_009:
        .byte        N36   , Cn5 , v104
        .byte    W36
        .byte                Ds5 
        .byte    W36
        .byte        N12   , Cn5 
        .byte    W12
        .byte        N06   , Gs4 
        .byte    W06
        .byte                An4 
        .byte    W06
        .byte    PEND
    @ 010   ----------------------------------------
    goldenrod_1_010:
        .byte        N36   , As4 , v104
        .byte    W36
        .byte                Cs5 
        .byte    W36
        .byte        N24   , As4 
        .byte    W24
        .byte    PEND
    @ 011   ----------------------------------------
    goldenrod_1_011:
        .byte                Cn5 
        .byte    W24
        .byte        N12   , Ds5 
        .byte    W12
        .byte                Gs4 
        .byte    W12
        .byte                As4 
        .byte    W12
        .byte                Bn4 
        .byte    W12
        .byte        N24   , Cn5 
        .byte    W24
        .byte    PEND
    @ 012   ----------------------------------------
    goldenrod_1_012:
        .byte        N36   , Cs5 , v104
        .byte    W36
        .byte                Fn5 
        .byte    W36
        .byte        N24   , Cs5 
        .byte    W24
        .byte    PEND
    @ 013   ----------------------------------------
    goldenrod_1_013:
        .byte        N36   , Cn5 , v104
        .byte    W36
        .byte                Ds5 
        .byte    W36
        .byte        N12   , Cn5 
        .byte    W12
        .byte        N06   , Gs4 
        .byte    W06
        .byte                An4 
        .byte    W06
        .byte    PEND
    @ 014   ----------------------------------------
    goldenrod_1_014:
        .byte        N36   , As4 , v104
        .byte    W36
        .byte                Cs5 
        .byte    W36
        .byte        N24   , As4 
        .byte    W24
        .byte    PEND
    @ 015   ----------------------------------------
    goldenrod_1_015:
        .byte        N24   , Cn5 , v104
        .byte    W24
        .byte        N12   , Ds5 
        .byte    W12
        .byte                Fn5 
        .byte    W12
        .byte                Ds5 
        .byte    W12
        .byte                Cs5 
        .byte    W12
        .byte                Cn5 
        .byte    W12
        .byte                Gs4 
        .byte    W12
        .byte    PEND
    @ 016   ----------------------------------------
    goldenrod_1_016:
        .byte        N24   , Fn4 , v104
        .byte    W24
        .byte                Cs4 
        .byte    W24
        .byte                Ds4 
        .byte    W24
        .byte                Cn4 
        .byte    W24
        .byte    PEND
    @ 017   ----------------------------------------
        .byte    PATT
         .word    goldenrod_1_005
    @ 018   ----------------------------------------
        .byte    PATT
         .word    goldenrod_1_006
    @ 019   ----------------------------------------
        .byte    PATT
         .word    goldenrod_1_007
    @ 020   ----------------------------------------
        .byte    PATT
         .word    goldenrod_1_008
    @ 021   ----------------------------------------
        .byte    PATT
         .word    goldenrod_1_009
    @ 022   ----------------------------------------
        .byte    PATT
         .word    goldenrod_1_010
    @ 023   ----------------------------------------
        .byte    PATT
         .word    goldenrod_1_011
    @ 024   ----------------------------------------
        .byte    PATT
         .word    goldenrod_1_012
    @ 025   ----------------------------------------
        .byte    PATT
         .word    goldenrod_1_013
    @ 026   ----------------------------------------
        .byte    PATT
         .word    goldenrod_1_024
    @ 027   ----------------------------------------
        .byte    PATT
         .word    goldenrod_1_025
    @ 028   ----------------------------------------
        .byte    PATT
         .word    goldenrod_1_026
    @ 029   ----------------------------------------
        .byte        N12   , Cs4 , v104
        .byte    W12
        .byte                Cn4 
        .byte    W12
        .byte                As3 
        .byte    W12
        .byte                Cn4 
        .byte    W12
        .byte        N36   , Gs3 
        .byte    W36
        .byte        N06   
        .byte    W06
        .byte                An3 
        .byte    W06
        .byte GOTO
        .word goldenrod_1_loop
        .byte    W06
    @ 030   ----------------------------------------
        .byte    FINE
    You do this for all tracks.
    well thats all for today. hope this helps!
     
    Last edited by a moderator:
    shocking

    pretty straight forward, and to the point. the hilighting helps alot, yet you forgot it in a couple of them. fix it if you can. im giving you a one up on your popularity or whatever.
    im shocked no one else has replied to this.
     
    Uh, hmm...
    I don't know how to insert any music, but this tutorial seems very helpful, to maybe a question that hasn't been solved yet.
    Maybe I'm just talking nonsense here, but I think you did a pretty good job.
     
    There is a simplest way,just use uncompressed *.S file using Mid2Agb with CMD:

    [PokeCommunity.com] How to loop those pesky .patt statements in a .s file


    and you will get a simplified *.S file codes without any shorcuts(No worry the song size will be the same as the compressed one in the ROM) Like This:

    Code:
    @**************** Track 1 (Midi-Chn.1) ****************@
    
    dd_1:
        .byte        VOL   , 127*dd_mvl/mxv
        .byte    KEYSH , dd_key+0
    @ 000   ----------------------------------------
        .byte    TEMPO , 120*dd_tbs/2
        .byte        VOICE , 48
        .byte    W02
        .byte        N76   , Cn1 , v100
        .byte    W76
        .byte    W01
        .byte        N88   , Cs1 
        .byte    W17
    @ 001   ----------------------------------------
        .byte    W72
        .byte        N92   , Dn1 
        .byte    W24
    @ 002   ----------------------------------------
        .byte    W68
        .byte    W02
        .byte        TIE   , Ds1 
        .byte    W24
        .byte    W02
     
    Last edited:
    Patience *.S file Editor will be out soon.
    details would be nice, and it seems, my effort will have gone to waste :P
    anyway, for everybody, who is making this program, and what is the most likely release date? ty in advance for any information.
    it seems, that i can call myself an elite music hacker, as i have multiple tutorials i can post, but i have to find the time to juggle this fourth thing in my life. i already have 3 things occupying most of my time :P
     
    Back
    Top