Difference between revisions of "Change Default Battle Theme (Map Flag)"

From Chrono Compendium
Jump to: navigation, search
(Created page with "==General Information== ===Chrono Trigger=== ''Thanks to PowerPanda'' What makes this possible: Chrono Trigger does something rather odd in its code. Rather than direct-ref...")
 
Line 27: Line 27:
 
!battletable
 
!battletable
 
[This table consists of $200 bytes, one corresponding to each map)</pre>
 
[This table consists of $200 bytes, one corresponding to each map)</pre>
 +
 +
====Vanilla Bug====
 +
 +
This is a vanilla bug that never actually shows up in the original game. As such, it's main use is for hackers and people who want to use my other ASM that allows you to set random battle music on a map-by-map basis. Anyway, the bug is that if your random battle music matches the music already playing on the field, and the battle itself is not set to use the field music, the game never switches sound effect banks. Credit to Reld on this one. I found the bug itself, but he found the cause of the bug.
 +
 +
It's easy to reproduce. In Temporal Flux, set Guardia Forest (Present) to have the field music of "$45 - Battle 1" and get into a random battle. Make sure to bring Frog, not because it's important for recreating the bug, but because his sword strike sound effect gets turned into a cat's meow.
 +
 +
To fix this, we just need to compare the battle music with the field music, and say that if they match the game should treat it like the random battle had the flag set to not use battle music. That flag causes the code to skip to a seperate routine that loads the sound effects, but not the music.
 +
 +
<pre>;Starting at C0/1BBF
 +
LDA $FA A5 FA ;C0/1BBF  Load the map's battle music
 +
STA $1E01 8D 01 1E ;C0/1BC1  Save it to 7E/1E01
 +
CMP $7E/29AE CF AE 29 7E ;C0/1BC4  Compare it to the field music
 +
BEQ $1BD5 F0 0C ;C0/1BC8  If they match, treat like the battle was set to not use battle music
 +
JSL $46/1EFC 22 FC 1E 46 ;C0/1BCA  Load new subroutine: relocated code
 +
JSL $C7/0004 22 04 00 C7 ;C0/1BCE  Load pre-existing subroutine
 +
PLD 2B
 +
PLB AB
 +
RTL 6B
 +
 +
;Relocated code @46/1EFC
 +
LDA $14 A9 14
 +
STA $1E00 8D 00 1E
 +
LDA $FF A9 FF
 +
STA $1E10 8D 10 1E
 +
RTL 6B</pre>
  
 
''From'':  [[Modification]]
 
''From'':  [[Modification]]

Revision as of 05:39, 11 December 2022

General Information

Chrono Trigger

Thanks to PowerPanda

What makes this possible: Chrono Trigger does something rather odd in its code. Rather than direct-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.

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: !freespace 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

!battletable [This table consists of $200 bytes, one corresponding to each map)</pre>

Vanilla Bug

This is a vanilla bug that never actually shows up in the original game. As such, it's main use is for hackers and people who want to use my other ASM that allows you to set random battle music on a map-by-map basis. Anyway, the bug is that if your random battle music matches the music already playing on the field, and the battle itself is not set to use the field music, the game never switches sound effect banks. Credit to Reld on this one. I found the bug itself, but he found the cause of the bug.

It's easy to reproduce. In Temporal Flux, set Guardia Forest (Present) to have the field music of "$45 - Battle 1" and get into a random battle. Make sure to bring Frog, not because it's important for recreating the bug, but because his sword strike sound effect gets turned into a cat's meow.

To fix this, we just need to compare the battle music with the field music, and say that if they match the game should treat it like the random battle had the flag set to not use battle music. That flag causes the code to skip to a seperate routine that loads the sound effects, but not the music.

;Starting at C0/1BBF
LDA $FA		A5 FA		;C0/1BBF  Load the map's battle music
STA $1E01	8D 01 1E	;C0/1BC1  Save it to 7E/1E01
CMP $7E/29AE	CF AE 29 7E	;C0/1BC4  Compare it to the field music
BEQ $1BD5	F0 0C		;C0/1BC8  If they match, treat like the battle was set to not use battle music
JSL $46/1EFC	22 FC 1E 46	;C0/1BCA  Load new subroutine: relocated code
JSL $C7/0004	22 04 00 C7	;C0/1BCE  Load pre-existing subroutine
PLD		2B			
PLB		AB
RTL		6B

;Relocated code @46/1EFC
LDA $14		A9 14
STA $1E00	8D 00 1E
LDA $FF		A9 FF
STA $1E10	8D 10 1E
RTL		6B

From: Modification