Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2011-11-13 22:43:44

329/703

Battle music

Here is the ASM that determines how in‐battle music is picked. It’s easy to fix the oversight that Rocket Executives and Scientists play normal trainer music. ☺

To play a specific song, just make sure its song number is in de by the time the code hits 0x445E6.

; 44569
ld a,[$D118] ; are we fighting a trainer?
and a
jr nz,+$1E ; if so, go to 4458D
ld a,$24 ; check region
ld hl,$694E
rst $8
ld a,e
and a
jr nz,+$F ; if in Kanto, go to 44588
ld de,$0029 ; set song
ld a,[$D157] ; check time of day
cp 2
jr nz,+$68 ; if not nighttime, we’re done (go to 445EB)
ld de,$004A ; set song
jr +$63 ; we’re done

; 44588
ld de,$0008 ; set song
jr +$5E ; we’re done

; 4458D
ld de,$002F ; set song
cp $10
jr z,+$57 ; if fighting Lance, we’re done
cp $3F
jr z,+$53 ; if fighting Red, we’re done
ld de,$0031 ; set song
cp $1F
jr z,+$4C ; if fighting male Rocket grunt, we’re done
cp $42
jr z,+$48 ; if fighting female Rocket grunt, we’re done
ld de,$0006 ; set song
ld a,$F
ld hl,$5075
rst $8
jr c,+$3D ; if fighting a Kanto Gym Leader, we’re done
ld de,$002E ; set song
ld a,$F
ld hl,$507A
rst $8
jr c,+$32 ; if fighting a Johto Gym Leader / Elite Four member, we’re done
ld de,$0030 ; set song
ld a,[$D118]
cp $09
jr z,+$28 ; if fighting rival type 1, we’re done
cp $2A
jr nz,+$C ; if not fighting rival type 2, go to 445D3
ld a,[$D11B] ; which rival are we fighting?
cp $04
jr c,+$1D ; if it’s not the fight inside Indigo Plateau, we’re done
ld de,$002F ; set song
jr +$18 ; we’re done

; 445D3
ld a,[$D042]
and a
jr nz,+$A ; if link battle(?), go to 445E3
ld a,$24
ld hl,$694E
rst $8
ld a,e
and a
jr nz,+$5 ; if in Kanto, go to 445E3
ld de,$002A
jr +$3 ; we’re done

; 445E3
ld de,$0007

; we’re done

#2 2011-11-13 23:06:27

tysonrss
Member
From: US, Ohio
Registered: 2011-08-27
Post 136/649

Re: Battle music

I found where the music data is in the hex editor after comparing it to the offsets and the set up above.

Nice table, I think it helped with many other things to as far as customizing who get's what by editing some bytes.

Last edited by tysonrss (2011-11-13 23:07:55)


Pokemon Blue DX is reborn!

Offline

#3 2011-11-21 05:40:14

tysonrss
Member
From: US, Ohio
Registered: 2011-08-27
Post 190/649

Re: Battle music

Are the Johto Leaders and E4 music data combined? Meaning if I change the music for the E4 I'd be changing Johto Leaders to?


Pokemon Blue DX is reborn!

Offline

#4 2011-11-21 06:04:34

347/703

Re: Battle music

tysonrss wrote:

Are the Johto Leaders and E4 music data combined? Meaning if I change the music for the E4 I'd be changing Johto Leaders to?

Yes. You need to change the ASM code in the previous post to suit your needs.

#5 2011-11-21 06:12:48

tysonrss
Member
From: US, Ohio
Registered: 2011-08-27
Post 191/649

Re: Battle music

What exactly do I use to understand that?


Pokemon Blue DX is reborn!

Offline

#6 2011-11-21 06:30:05

350/703

Re: Battle music

Try reading this thread. There are others that may be relevant.

#7 2011-11-21 06:39:29

tysonrss
Member
From: US, Ohio
Registered: 2011-08-27
Post 192/649

Re: Battle music

Wonder If I just blew my brains out?

Joking aside, I was never good with math to begin with. And to know that certain letters equal this and that and when combined forms this and that just makes me like this...

images?q=tbn:ANd9GcQTRi92eHQI3aY1sM9TBzxxEq85oaIl_Ybn9NwyS9GrdAtBl5quo9yjIFe6Jg


Pokemon Blue DX is reborn!

Offline

#8 2011-12-28 22:38:13

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 1,140/3,578

Re: Battle music

One thing not covered by this is the song that plays when you are seen by a trainer. I'm not sure if this is a table or a routine similar to this one. I have something listen in the useful offsets thread that looks like it might be a table, although in all honesty it has not been fully tested. Any information on this aspect of trainer battles?

Offline

#9 2011-12-28 23:06:48

400/703

Re: Battle music

Mateo wrote:

One thing not covered by this is the song that plays when you are seen by a trainer. I'm not sure if this is a table or a routine similar to this one. I have something listen in the useful offsets thread that looks like it might be a table, although in all honesty it has not been fully tested. Any information on this aspect of trainer battles?

That’s described in Tauwasser’s scripting doc, command 0x7F. The list is at 3A:5027.

#10 2012-02-11 16:53:07

Miksy91
Member
Registered: 2010-10-16
Post 773/2,339

Re: Battle music

Not sure why I haven't noticed how helpful this document is before :O

Anyway, what I'm wondering though - how does the game recognize which trainer groups are defined as gym leaders ?

Offline

#11 2012-02-11 20:36:46

435/703

Re: Battle music

ld de,$0006 ; set song
ld a,$F
ld hl,$5075
rst $8
jr c,+$3D ; if fighting a Kanto Gym Leader, we’re done
ld de,$002E ; set song
ld a,$F
ld hl,$507A
rst $8
jr c,+$32 ; if fighting a Johto Gym Leader / Elite Four member, we’re done

rst $8 triggers a bankswitch, so the game calls routines at 0F:5075 and 0F:507A that set the carry flag if the trainer is of an appropriate class.

; 0F:5075
ld hl,$5097
jr +3

; 0F:507A
ld hl,$5089
push de
ld a,[$D118]
ld de,1
call $3186
pop de
ret

; 0F:5089
db FALKNER, WHITNEY, BUGSY, MORTY, PRYCE, JASMINE, CHUCK, CLAIR, WILL, BRUNO, KAREN, KOGA

; 0F:5095 (unused!)
db LANCE, RED

; 0F:5097
db BROCK, MISTY, LT_SURGE, ERIKA, JANINE, SABRINA, BLAINE, BLUE, $FF

$3186 is a trivial “set carry if value in $FF‐terminated array” function.

Notice that as‐is, the $5097 list is a subset of the $5089 list, so what happens is dependent on the order that you call $5075 and $507A. You should call $5075 first, or you can replace the unused Lance reference with a $FF so they really are separate lists.

#12 2012-02-11 20:53:48

Miksy91
Member
Registered: 2010-10-16
Post 774/2,339

Re: Battle music

Got it !
I actually figured out before that part of the code might be in 0F:5075 and 0F:507A by remembering (from some random post here) that you can load the bank in a and the pointer in hl although didn't know rst $8 is used as the command for carrying out the bank switch itself.

Thanks for info about "call $3186" too - I might need it sooner or later :D

Last edited by Miksy91 (2012-02-11 21:00:06)

Offline

#13 2012-12-14 06:48:38

delpo
Member
Registered: 2012-11-26
Post 28/40

Re: Battle music

So can I just add (gameboy assembler plus syntax)

cp a,14
jr z,445EB
cp a,33
jr z,445EB
cp a,37
jr z,445EB

before ld de,$0031 in order to get the rocket executive members and scientist to also play the rocket music?  Or do I have to find something to delete that takes the same amount of bytes as this insertion into the routine or else other parts of the routine will be overwritten?

Offline

#14 2012-12-14 11:28:37

Miksy91
Member
Registered: 2010-10-16
Post 1,316/2,339

Re: Battle music

You have to insert it elsewhere and call/jump to it sometime during the loading of the music.
If not, unwanted data will be overwritten indeed.

Offline

Board footer

Powered by FluxBB