Go Back   The PokéCommunity Forums > ROM Hacking > Tools, Tutorials & Resources
Reload this Page Tutorial How to loop those pesky .patt statements in a .s file

Notices
For all updates, view the main page.

Tools, Tutorials & Resources Various tools to help you develop your hacks can be found here.
New threads in this forum are to be approved by a moderator before they are displayed.



Reply
 
Thread Tools
  #1    
Old February 2nd, 2010 (7:22 AM). Edited April 15th, 2010 by manipulation.
3dd13's Avatar
3dd13 3dd13 is offline
Leader of the Fallen
 
Join Date: Oct 2008
Location: Alabama! The Heart of Hell!
Age: 24
Gender: Male
Nature: Lonely
Posts: 96

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 ---------------------------------------- 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 ---------------------------------------- .byte PATT .word goldenrodexample_1_001 @ 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!

__________________
Reply With Quote

Relevant Advertising!

  #2    
Old April 10th, 2010 (6:58 AM).
Etchberger's Avatar
Etchberger Etchberger is offline
 
Join Date: Apr 2010
Gender: Male
Posts: 1

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.

Reply With Quote
  #3    
Old June 9th, 2010 (6:17 PM).
3dd13's Avatar
3dd13 3dd13 is offline
Leader of the Fallen
 
Join Date: Oct 2008
Location: Alabama! The Heart of Hell!
Age: 24
Gender: Male
Nature: Lonely
Posts: 96

i am apalled at the fact, that only my real life friend was kind enough to leave a comment. please take time to thank me, and others for their time at reasearch!!!

__________________
Reply With Quote
  #4    
Old June 9th, 2010 (8:29 PM).
Tropical Sunlight's Avatar
Tropical Sunlight Tropical Sunlight is offline
The Faltine
 
Join Date: Mar 2008
Location: Slovenia
Age: 20
Gender: Male
Posts: 3,578
Send a message via Windows Live Messenger to Tropical Sunlight

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.

__________________
Reply With Quote
  #5    
Old June 10th, 2010 (4:06 AM). Edited June 10th, 2010 by AmineX.
AmineX's Avatar
AmineX AmineX is offline
Music Expert
 
Join Date: Feb 2008
Location: Algeria
Age: 27
Nature: Gentle
Posts: 151
Send a message via ICQ to AmineX Send a message via Windows Live Messenger to AmineX Send a message via Skype™ to AmineX

There is a simplest way,just use uncompressed *.S file using Mid2Agb with CMD:

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

__________________
AmineX


All my pokemon music related videos here:
http://www.youtube.com/user/LHV1?feature=mhee
Reply With Quote
  #6    
Old June 10th, 2010 (1:47 PM).
3dd13's Avatar
3dd13 3dd13 is offline
Leader of the Fallen
 
Join Date: Oct 2008
Location: Alabama! The Heart of Hell!
Age: 24
Gender: Male
Nature: Lonely
Posts: 96

this is for people who dont know how to use mid2agb through the command line interface. (like me)
it is useful what you posted, however, please explain how to do this, or write a tutorial.

__________________
Reply With Quote
  #7    
Old June 11th, 2010 (11:40 AM).
AmineX's Avatar
AmineX AmineX is offline
Music Expert
 
Join Date: Feb 2008
Location: Algeria
Age: 27
Nature: Gentle
Posts: 151
Send a message via ICQ to AmineX Send a message via Windows Live Messenger to AmineX Send a message via Skype™ to AmineX

Patience *.S file Editor will be out soon.

__________________
AmineX


All my pokemon music related videos here:
http://www.youtube.com/user/LHV1?feature=mhee
Reply With Quote
  #8    
Old June 11th, 2010 (6:16 PM).
3dd13's Avatar
3dd13 3dd13 is offline
Leader of the Fallen
 
Join Date: Oct 2008
Location: Alabama! The Heart of Hell!
Age: 24
Gender: Male
Nature: Lonely
Posts: 96

Quote originally posted by AmineX:
Patience *.S file Editor will be out soon.
details would be nice, and it seems, my effort will have gone to waste
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

__________________
Reply With Quote
Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 3:45 AM.