Author Topic: ASM: Change the Battle Theme by Map  (Read 460 times)


  • Guru of Time
  • Earthbound (+15)
  • *
  • Posts: 40
    • View Profile
ASM: Change the Battle Theme by Map
« on: November 21, 2022, 05:04:02 pm »
This is the 2nd battle theme ASM that I have developed. The other one changed the battle theme at a specific chapter of the game. Both of these ASMs come included in the Chrono Trigger Soundtrack Expansion project, toggleable with a 4-byte change.

What makes this possible: Chrono Trigger does something rather odd in its code. Rather than difrect-referencing the ROM for what the random battle theme is, it instead loads the theme's Index # into a RAM Byte (7E/01FA), and refreshes this value on every map load.

I have taken advantage of that and put in a hook that checks the Map Index # against a lookup table, allowing you to define a different random battle theme on a map-by-map basis. While many of the maps in the game do not have any random battles, they are included anyway to make this ASM compatible with any future romhack.

Code: [Select]
At C0/0C58 (00x0C58), the following code is in the base rom:
A9 45      LDA #$45      ;Load song $45 - Battle 1
85 FA      STA 7E/01FA   ;Write song to the "current battle theme" RAM byte

You will want to replace those 4 bytes with the following:
22 ?? ?? ??   JSL !freespace   ;Jump to the new subroutine

Then, in the freespace area, add this code:
DA PHX Store the old X value, to be safe
AE 00 01 LDX $7E/0100 Load the current map number to X
BF ?? ?? ?? LDA,X !battletable Look up map's battle theme in the battle table
85 FA STA $7E/01FA Save "Current battle theme"
FA PLX Retrieve the old X value
6B RTL Return

[This table consists of $200 bytes, one corresponding to each map)

With this new code, I'm soliciting opinionson which battle theme should go where. I could take the easy approach of having a consistent battle theme for every time period. In that case, I'd do Battle 1 for Present/Past, Battle 2 for Future/Antiquity, and Burn! Bobonga! for Prehistory. I could also do this by dungeon though. Below is a list of dungeons. If a music track is written next to it, it means that the event code is specifying a specific music track. These can still be changed, but it will require event editing. If there is an "NA" it means that it is technically a "dungeon", but there are no random battles that occur there.

1000 AD - Present
 Millenial Fair (Gato)
 Guardia Forest
 Guardia Castle Prison
 Guardia Castle Basement
 Heckran Cave
 Sunken Desert
 Northern Ruins - N/A
 Forest Secret - N/A

600 AD - Past
 Truce Canyon
 Guardia Forest
 Manoria Cathedral
 Zenan Bridge
 Denadoro Mountains
 Cursed Woods
 Magic Cave
 Magus's Castle
 Ozzie's Fort
 Northern Ruins
 Giant's Claw - Tyrano Lair

2300 AD - Future
 Lab 16
 Arris Dome
 Lab 32
 Sewer Access
 Factory Ruins
 Geno Dome
 Death Peak
 Sun Palace - N/A

65,000,000 BC - Prehistory
 Mystic Mountain
 Hunting Range - Burn Bobonga!
 Forest Maze
 Reptite Lair
 Dactyl Nest
 Tyrano Lair - Tyrano Lair

12,000 BC - Antiquity
 Beast's Nest
 Mt. Woe
 Ocean Palace - Ocean Palace
 North Cape - NA
Black Omen - Black Omen
End of Time - NA

The songs that I think work as battle themes are:
Battle 1
Battle 2
A Shot of Crisis
Bike Chase
Primitive Mountain
Burn! Bobonga!
Battle 1 Rough (Pre-release rom)
« Last Edit: November 21, 2022, 05:06:42 pm by PowerPanda »