News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: [SOLVED] Changing one Boss' Scream in Streets of Rage 2 (A RAM Search?)  (Read 838 times)

eskayelle

  • Full Member
  • ***
  • Posts: 184
  • NBA Jam 2KTE / TMNT of Rage / Pong de las TMNT Dev
    • View Profile
In SoR2, each boss runs the same code to play the same death scream when he dies.

Code: [Select]
00:E800  20 3C  MOVE.L  #$0000020B,D0            A0=0000E7E0 A1=FFFFF700 A2=FFFFF100 A3=FFFFFA00 A4=001F4BB4 A5=FFFFF700 A6=FFFFEC80 A7=FFFFFFF2 D0=0000FFFC D1=51B200A8 D2=0000FFFF D3=87D187D9 D4=0000D000 D5=7E80FF00 D6=0000FFFF D7=00C40050 xnZvc
00:E806  72 00  MOVEQ   #$00,D1                  A0=0000E7E0 A1=FFFFF700 A2=FFFFF100 A3=FFFFFA00 A4=001F4BB4 A5=FFFFF700 A6=FFFFEC80 A7=FFFFFFF2 D0=0000020B D1=51B200A8 D2=0000FFFF D3=87D187D9 D4=0000D000 D5=7E80FF00 D6=0000FFFF D7=00C40050 xnzvc
00:E808  4E B9  JSR     ($00040008)              A0=0000E7E0 A1=FFFFF700 A2=FFFFF100 A3=FFFFFA00 A4=001F4BB4 A5=FFFFF700 A6=FFFFEC80 A7=FFFFFFF2 D0=0000020B D1=00000000 D2=0000FFFF D3=87D187D9 D4=0000D000 D5=7E80FF00 D6=0000FFFF D7=00C40050 xnZvc

But... what if we wanted a female boss, and in turn a female death cry, for at least one SoR2 boss?  In this example, I'm working with Shiva.

Looking at the code, my inclination is to assume each boss is assigned some value in RAM, such that I could create an if/then statement to play the typical death cry for all bosses but Shiva, and another sound for Shiva.  Preliminarily, I'd find some empty space in the rom and do a hijack akin to the code below (note that this is untested, as there's a variable missing, and I may also have a syntax error or two):
Code: [Select]
;org $0000E800
;4E B9 00 03 1D 60 jsr ($00031D60)
;
;org $00031D60
;0C 78 00 01 Fx xx cmpi.w #$001C,($Fxxx) ;in Pancake, Shiva is 22 (so should it be 21?); might not help, may need unused ram and just assign a value to it for when Shiva is fought.
;66 0A bne #$08
;20 3C 00 00 02 17 move.l #$00000217,D0
;60 08 bra #$06
;20 3C 00 00 02 08 move.l #$00000208,D0
;4E 75 rts

Here's where I'm looking for some guidance.  Does anyone know to what value in RAM a boss value is assigned, if that's the tactic in SoR2? Or... would anyone have guidance on how I'd determine a boss value and where it resides in RAM? 

The other option may be to create a flag in unused RAM that only registers during the Shiva fight.  If the first option above is unlikely, would anyone be able to help identify where in a boss fight this should be assigned (so that it only happens during the Shiva fight) and what the easiest method might be to locate unused RAM?
« Last Edit: February 10, 2021, 06:14:11 pm by eskayelle »
I once wrote a blog.  Maybe you'll find something in it useful?  https://www.romhacking.net/forum/index.php?topic=30593.0

FAST6191

  • Hero Member
  • *****
  • Posts: 3136
    • View Profile
Is it a boss fight or an enemy value?

Equally you don't necessarily need a value specifically related to the boss, but a value that happens to be there at the same time (could even be a specific music track if you are already pulling things apart on the sound front).

As far as finding this value you could try doing change searches for when new enemies spawn (I imagine there are a bunch of slots) but I would sooner find the enemy health with a cheat and work backwards from there.

eskayelle

  • Full Member
  • ***
  • Posts: 184
  • NBA Jam 2KTE / TMNT of Rage / Pong de las TMNT Dev
    • View Profile
Thanks for the feedback.  I went with the RAM value for the stage, which took me here.

Code: [Select]
;org $0000E800
;4E B9 00 03 1D 60 jsr ($00031D60) ;hijack here and find some empty space for code
;
;org $00031D60
;0C 78 00 07 FD 0E cmpi.w #$0007,($FD0E) ;checks for round 8
;66 08 bne #$08
;20 3C 00 00 02 17 move.l #$00000217,D0 ;lady death scream
;60 06 bra #$06
;20 3C 00 00 02 0B move.l #$0000020B,D0 ;boss death scream; this was at $E800
;4E B9 00 00 E8 06 jsr ($0000E806) ;return to code post-hijack
;4E 75 rts

It worked perfectly!

I then noticed there's a second standard enemy scream occurring after that first one, so I tried a similar tactic, finding an unknown RAM value that seemed to change inside of that stage. The problem is that it's fairly consistent for the entirety of the stage, so it caused all enemies in that stage to take on the death scream.  I'm not sure, but I think messing with the ADDI function via a hijack also causes the music to stop playing after a few seconds, so I may just let that death scream go.

Code: [Select]
;but wait... there's a second scream, and it's coming from all enemies at ED6A.
00:E6DA  06 80  ADDI.L  #$0000020A,D0            A0=0000E692 A1=FFFFF700 A2=FFFFF100 A3=FFFFFA00 A4=001F4BB4 A5=FFFFF700 A6=FFFFEC80 A7=FFFFFFF2 D0=00000001 D1=509400A8 D2=0000FFFF D3=87D187D9 D4=0000D000 D5=7E80FF00 D6=0000FFFF D7=00C40050 xnzvc
00:E6E0  72 00  MOVEQ   #$00,D1                  A0=0000E692 A1=FFFFF700 A2=FFFFF100 A3=FFFFFA00 A4=001F4BB4 A5=FFFFF700 A6=FFFFEC80 A7=FFFFFFF2 D0=0000020B D1=509400A8 D2=0000FFFF D3=87D187D9 D4=0000D000 D5=7E80FF00 D6=0000FFFF D7=00C40050 xnzvc
00:E6E2  4E B9  JSR     ($00040008)              A0=0000E692 A1=FFFFF700 A2=FFFFF100 A3=FFFFFA00 A4=001F4BB4 A5=FFFFF700 A6=FFFFEC80 A7=FFFFFFF2 D0=0000020B D1=00000000 D2=0000FFFF D3=87D187D9 D4=0000D000 D5=7E80FF00 D6=0000FFFF D7=00C40050 xnZvc
;so... we may want to change this too...
;
;org $0000E6DA
;4E B9 00 03 1D 90 jsr ($00031D90)
;
;org $00031D90
;0C 78 00 07 FD 0E cmpi.w #$0007,($FD0E) ;checks for round 8
;66 10 bne #$10
;0C 78 20 00 B5 BC cmpi.w #$2000,($B5BC) ;$FFB5BC is #$2000 when shiva fights and dies
;66 08 bne #$08
;06 80 00 00 02 17 addi.l #$00000217,D0 ;lady death scream
;60 06 bra #$06
;06 80 00 00 02 0A addi.l #$0000020A,D0 ;enemy death scream 1
;4E B9 00 00 E6 E0 jsr ($0000E6E0)
;4E 75
;this causes a lot of bad guys on the floor to lady death scream and the music seems to stop.
;messing with this addi function seems to cause the music to stop playing after a few seconds in.

I may try my hijack earlier in the sequence as well as base the second RAM value on the boss health being zero (though I'm not sure if it'll be zero throughout the stage).  We'll see how that goes.

EDIT: No luck there.  The next line above the ADDI function is an ANDI, and the line before that in the trace log is an RTS.  So I added the ANDI function to the code, and the effect is the same... music is truncated.

I also changed the second variable to consider the boss' health ($FFF181) of zero, but it appears that the health value is zero throughout the level, until Shiva is visible and activated, so the death screams of all the enemies in the level default to the lady death scream branch in the code.

February 10, 2021, 06:13:32 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
SOLVED!

I remembered from my previous TMNT of Rage forum posts the link to the SoR2 disassembly.  I did a search in it for the subroutines I had been messing with and found Shiva's object ID as #$32.  I then rejiggered my code for the second scream as a branching exercise using that object ID as the comparison.  I also removed that jump at the end, since the RTS gets me back to where I need to go.  The simpler comparison solved for the second scream, and popping out that extraneous JSR kept the music from stopping.

Here's the solution.

Shiva Scream 1:
Code: [Select]
;org $0000E800
;4E B9 00 03 1D 60 jsr ($00031D60) ;hijack here and find some empty space for code
;
;org $00031D60
;0C 78 00 07 FD 0E cmpi.w #$0007,($FD0E) ;checks for round 8
;66 08 bne #$08
;20 3C 00 00 02 17 move.l #$00000217,D0 ;lady death scream
;60 06 bra #$06
;20 3C 00 00 02 0B move.l #$0000020B,D0 ;boss death scream; this was at $E800
;4E B9 00 00 E8 06 jsr ($0000E806) ;return to code post-hijack
;4E 75 rts

Shiva Scream 2:
Code: [Select]
;org $0000E6DA
;4E B9 00 03 1D 90 jsr ($00031D90)
;
;org $00031D90
;0C 6A 00 32 00 0C cmpi.w  #$0032,$000C(A2);#$0032 is Shiva's object ID, while $000C is the variable for Object ID
;66 08 bne #$08
;06 80 00 00 02 17 addi.l #$00000217,D0 ;lady death scream
;60 06 bra #$06
;06 80 00 00 02 0A addi.l #$0000020A,D0 ;enemy death scream 1
;4E 75 rts
« Last Edit: February 13, 2021, 12:47:17 am by eskayelle »
I once wrote a blog.  Maybe you'll find something in it useful?  https://www.romhacking.net/forum/index.php?topic=30593.0