The PokéCommunity Forums Fan Games ROM Hacking Help Tools, Tutorials & Resources
Tutorial ASM: Seasonal Music Switches (Like BW/B2W2!)

Tools, Tutorials & Resources Various tools to help you develop your hacks can be found here.

Reply
 
Thread Tools
  #1    
Old June 19th, 2015 (7:00 AM). Edited October 21st, 2015 by GoGoJJTech.
GoGoJJTech's Avatar
GoGoJJTech GoGoJJTech is offline
(☞゚ヮ゚)☞ http://GoGoJJTech.com ☜(゚ヮ゚☜)
 
Join Date: Nov 2012
Location: Earth
Age: 19
Gender: Female
Nature: Jolly
Posts: 2,475
This is a custom routine (currently only for FR) that switches music based on DNS's seasons. If the player doesn't have RTC or seasons enabled, the music defaults to spring music.

Here's an example of the ASM in action:


Neat, isn't it?

This is based off of Jambo51's hooks into the music loader. Once you add this routine in, all music changes as soon as the game begins, and in real time. If it changes from February to March as the player is playing the game, the next song they load will have spring music in it. Cool, isn't it?

Here's the ASM:
Fire Red
Spoiler:

Code:
.thumb

main:
	add r3, r2, #0x4
	ldr r1, DNS /*Check if DNS is installed*/
	ldrh r2, [r1]
	cmp r2, #0x0 /*If not, default to "spring" music*/
	beq spring
	ldrb r1, [r1, #3]
	cmp r1, #0xC /*December*/
	beq winter
	cmp r1, #0x9 /*September-November*/
	bge autumn
	cmp r1, #0x6 /*June-August*/
	bge summer
	cmp r1, #0x3 /*March-May*/
	bge spring /*If it doesn't go to spring, it covers the rest of the months as winter, AKA January and February*/
winter:
	ldr r1, wintertable
	b exit
autumn:
	ldr r1, autumntable
	b exit
summer:
	ldr r1, summertable
	b exit
spring:
	ldr r1, normaltable
exit:
	lsr r0, #0xD
	add r0, r1
	ldr r2, ramtable
	mov pc, r3

.align 2
DNS:		.word 0x0300553C
ramtable:	.word 0x084A329C
normaltable:	.word 0x0_______ /*Point this to the Spring songtable*/
summertable:	.word 0x0_______ /*Point this to the Summer songtable*/
wintertable:	.word 0x0_______ /*Point this to the Winter songtable*/
autumntable:	.word 0x0_______ /*Point this to the Autumn songtable*/
Yes, you will need to have 4 songtables to point to. BW/B2W2 have the songs for each season saved in the header, but that's not going to happen on gen 3 anytime soon, so having 4 songtables is easiest way to go.

To insert this into your FR hack, assemble the ASM above and place it at any free offset. Note down its location.
Navigate to 0x1DD0F8, 0x1DD124, 0x1DD170, 0x1DD1C4 and 0x1DD1F8 and change the code at ALL of the locations to:
Code:
7A 46 XX 49 08 47
The XX is there so you know not to overwrite the byte that's already there. Now, replace all previously existing pointers to 0x4A32CC with a pointer to the THUMB routine, remembering to add 1 for thumb of course.


Emerald
Spoiler:

Code:
.thumb

main:
	add r3, r2, #0x4
	ldr r1, DNS /*Check if DNS is installed*/
	ldrh r2, [r1]
	cmp r2, #0x0 /*If not, default to "spring" music*/
	beq spring
	ldrb r1, [r1, #3]
	cmp r1, #0xC /*December*/
	beq winter
	cmp r1, #0x9 /*September-November*/
	bge autumn
	cmp r1, #0x6 /*June-August*/
	bge summer
	cmp r1, #0x3 /*March-May*/
	bge spring /*If it doesn't go to spring, it covers the rest of the months as winter, AKA January and February*/
winter:
	ldr r1, wintertable
	b exit
autumn:
	ldr r1, autumntable
	b exit
summer:
	ldr r1, summertable
	b exit
spring:
	ldr r1, normaltable
exit:
	lsr r0, #0xD
	add r0, r1
	ldr r2, ramtable
	mov pc, r3

.align 2
DNS:		.word 0x0300553C
ramtable:	.word 0x086B49C0
normaltable:	.word 0x0_______ /*Point this to the Spring songtable*/
summertable:	.word 0x0_______ /*Point this to the Summer songtable*/
wintertable:	.word 0x0_______ /*Point this to the Winter songtable*/
autumntable:	.word 0x0_______ /*Point this to the Autumn songtable*/
Yes, you will need to have 4 songtables to point to. BW/B2W2 have the songs for each season saved in the header, but that's not going to happen on gen 3 anytime soon, so having 4 songtables is easiest way to go.

To insert this into your Em hack, assemble the ASM above and place it at any free offset. Note down its location.
Navigate to 0x2E0134, 0x2E0160, 0x2E01AC, 0x2E0200 and 0x2E0234 and change the code at ALL of the locations to:
Code:
7A 46 XX 49 08 47
The XX is there so you know not to overwrite the byte that's already there. Now, replace all previously existing pointers to 0x6B49F0 with a pointer to the THUMB routine, remembering to add 1 for thumb of course.


To have the music work out, you just place the same songs in the same slots in each table. For example, you'd place all 4 of the same route in slot 293 in Sappy, however, they'd all be from the different seasons. For songs that don't switch between seasons such as the trainer battle theme, just keep them all the exact same.

Once you insert, your music should automatically begin to switch on its own without you doing anything. You will have to restart all save states, not save files. And now you're done!
__________________
I believe in Jesus Christ my Savior. If you do too, and aren't scared to admit it, then copy and paste this into your signature.
The HGSS Music Patch - The BW/2 Music Patch - ASM: Switch Music Based on Seasons
Romhack.me Profile - Pokecommunity Profile - Youtube Channel

Support me at my site!
Pokémon Platinum Red and Blue
Reply With Quote
  #2    
Old June 21st, 2015 (2:50 AM).
Daman's Avatar
Daman Daman is offline
Lal Mirch
     
    Join Date: Feb 2015
    Location: North Carolina
    Gender: Male
    Nature: Rash
    Posts: 188
    Great job , Gogo !
    Reply With Quote
      #3    
    Old June 21st, 2015 (10:26 AM).
    BlackStorm20x's Avatar
    BlackStorm20x BlackStorm20x is offline
    idek
       
      Join Date: Apr 2014
      Gender: Male
      Nature: Quiet
      Posts: 476
      Yo that's neat GoGo! Great job!
      __________________
      Reply With Quote
        #4    
      Old June 21st, 2015 (4:42 PM).
      GoGoJJTech's Avatar
      GoGoJJTech GoGoJJTech is offline
      (☞゚ヮ゚)☞ http://GoGoJJTech.com ☜(゚ヮ゚☜)
       
      Join Date: Nov 2012
      Location: Earth
      Age: 19
      Gender: Female
      Nature: Jolly
      Posts: 2,475
      Quote:
      Originally Posted by ShinyQuilava97(Gold) View Post
      Great job , Gogo !
      Quote:
      Originally Posted by BlackStorm20x View Post
      Yo that's neat GoGo! Great job!
      Thanks!

      Again, I plan on adding Emerald support (mainly so the BW/2 patch can have it as well) but that'd have to be saved for another day. Just a reminder for those who are doing Emerald.
      __________________
      I believe in Jesus Christ my Savior. If you do too, and aren't scared to admit it, then copy and paste this into your signature.
      The HGSS Music Patch - The BW/2 Music Patch - ASM: Switch Music Based on Seasons
      Romhack.me Profile - Pokecommunity Profile - Youtube Channel

      Support me at my site!
      Pokémon Platinum Red and Blue
      Reply With Quote
        #5    
      Old August 12th, 2015 (8:39 AM).
      Graykis23390's Avatar
      Graykis23390 Graykis23390 is offline
      Graykis Jiang
         
        Join Date: Jul 2015
        Location: Hongkong
        Gender: Male
        Nature: Calm
        Posts: 48
        Great Tutorial!
        __________________
        Never giving up!
        Reply With Quote
          #6    
        Old October 17th, 2015 (4:29 AM). Edited October 21st, 2015 by jirachiwishmaker.
        jirachiwishmaker's Avatar
        jirachiwishmaker jirachiwishmaker is offline
           
          Join Date: Jul 2007
          Location: Forina
          Gender: Male
          Nature: Lonely
          Posts: 106
          Hi. I actually have had did a portion of Emerald last few months ago.

          ASM part:
          .align 2
          DNS: .word 0x0300553C
          ramtable: .word 0x086B49C0

          Bytes changing parts:
          0x2E0134-> 7A 46 08 49 08 47
          0x2E0160-> 7A 46 0A 49 08 47
          0x2E01AC-> 7A 46 0A 49 08 47
          0x2E0200-> 7A 46 0A 49 08 47
          0x2E0234-> 7A 46 0A 49 08 47

          Pointers changing part:
          All 0x6B49F0 to a pointer (+1) to the THUMB routine.
          Reply With Quote
            #7    
          Old November 9th, 2015 (3:58 AM).
          FlyingShell FlyingShell is offline
             
            Join Date: Jan 2015
            Gender: Male
            Posts: 14
            Oh gud, this is awesome. (O _ o) (o _ O)
            Gotta try it on my rom..
            Reply With Quote
            Reply

            Quick Reply

            Join the conversation!

            Create an account to post a reply in this thread, participate in other discussions, and more!

            Create a PokéCommunity Account
            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 4:03 PM.