summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Add-more-music-that-changes-at-night.md71
1 files changed, 69 insertions, 2 deletions
diff --git a/Add-more-music-that-changes-at-night.md b/Add-more-music-that-changes-at-night.md
index e989ee5..aea6b08 100644
--- a/Add-more-music-that-changes-at-night.md
+++ b/Add-more-music-that-changes-at-night.md
@@ -102,12 +102,25 @@ GetMapMusic::
push bc
ld de, MAP_MUSIC
call GetMapField
-+ call ChangeMusicIfNight
ld a, c
cp MUSIC_MAHOGANY_MART
+ jr z, .mahoganymart
+ bit RADIO_TOWER_MUSIC_F, c
+ jr nz, .radiotower
+ farcall Function8b342
++ call ChangeMusicIfNight
+ ld e, c
+ ld d, 0
+.done
+ pop bc
+ pop hl
+ ret
```
And that's it! The Night version of New Bark Town should now play during the night whenever that particular song is loaded!
-However, there's still a small oversight you might not even notice during gameplay: when the game reloads the overworld music after a battle or when the game is restarted, for example, it does it by loading the constant directly from the wram. This means that, if the time of day changes mid-battle, the map music won't actually be changed until the map itself is changed. This is very easy to fix.
+
+However, there's still a couple of small oversights that need to be fixed.
+
+The first one you might not even notice during gameplay: when the game reloads the overworld music after a battle or when the game is restarted, for example, it does it by loading the constant directly from the wram. This means that, if the time of day changes mid-battle, the map music won't actually be changed until the map itself is changed. This is very easy to fix.
Edit **home/audio.asm**:
@@ -135,6 +148,60 @@ RestartMapMusic::
```
Here we're just loading the current map music from the wram to `c` and checking if it needs to be changed using the same function as before.
+The second problem is a bit more tricky to fix. There are two special cases of maps that have their music change throughout the game: the Radio Tower in Goldenrod City and the small shop in Mahogany Town, both of which have their music change to the Team Rocket themes during the respective story sequences, and back to the normal town music when they are defeated. This is done through a series of checks in the `GetMapMusic` function, which we've already changed a while earlier. Because of the way this code is done, the music won't actually switch at night with the current code. To fix this issue, we need to change the logic of these checks.
+
+Edit **home/map.asm**:
+
+```diff
+GetMapMusic::
+ push hl
+ push bc
+ ld de, MAP_MUSIC
+ call GetMapField
+ ld a, c
+ cp MUSIC_MAHOGANY_MART
+ jr z, .mahoganymart
+ cp MUSIC_RADIO_TOWER
+ jr z, .radiotower
+ farcall Function8b342
++.done
+ call ChangeMusicIfNight
+ ld e, c
+ ld d, 0
+-.done
+ pop bc
+ pop hl
+ ret
+
+.radiotower
+ ld a, [wStatusFlags2]
+ bit STATUSFLAGS2_ROCKETS_IN_RADIO_TOWER_F, a
+ jr z, .clearedradiotower
+- ld de, MUSIC_ROCKET_OVERTURE
++ ld c, MUSIC_ROCKET_OVERTURE
+ jr .done
+
+.clearedradiotower
+- ld de, MUSIC_GOLDENROD_CITY
++ ld c, MUSIC_GOLDENROD_CITY
+ jr .done
+
+.mahoganymart
+ ld a, [wStatusFlags2]
+ bit STATUSFLAGS2_ROCKETS_IN_MAHOGANY_F, a
+ jr z, .clearedmahogany
+- ld de, MUSIC_ROCKET_HIDEOUT
++ ld c, MUSIC_ROCKET_HIDEOUT
+ jr .done
+
+.clearedmahogany
+- ld de, MUSIC_CHERRYGROVE_CITY
++ ld c, MUSIC_CHERRYGROVE_CITY
+ jr .done
+```
+
+What we are doing here is essentially changing the register where these checks place the music constant in, be it the Rocket version or the normal version. In the original code, they put the constant in `de`, which is what is needed for the next functions, but the new code to switch the music at night changes the constant at `c`, which is where `GetMapField` puts it. Luckily, there's already code that changes the register of the music constant (the `ld e, c` / `ld d, 0` lines), so we simply need to anticipate where those checks jump to in the base code (the `.done`) by three lines and thus reuse that bit of code.
+
## 4. Adding the rest of the music
The rest of the asm files for all overworld music of Gen 2 are in the files below: