GoGoJJTech

(☞゚ヮ゚)☞ http://GoGoJJTech.com ☜(゚ヮ゚☜)

Age 21
Female
Earth
Seen December 9th, 2016
Posted December 5th, 2016
2,473 posts
7.8 Years
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:

.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:
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:

.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:
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

GoGoJJTech

(☞゚ヮ゚)☞ http://GoGoJJTech.com ☜(゚ヮ゚☜)

Age 21
Female
Earth
Seen December 9th, 2016
Posted December 5th, 2016
2,473 posts
7.8 Years
Great job , Gogo !
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
Male
Forina
Seen 2 Days Ago
Posted July 13th, 2019
110 posts
13.1 Years
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.