SUCCESS!
So here's what we're looking at in terms of functionality...
Salve is now a command that, when selected, opens the item menu. All of the same items will be available as if you had selected Item.
If you choose an attack item (anything that by default targets one or all enemies), the targeting will be All Enemies.
If you choose a healing/support item (anything that by default targets one or all allies), the targeting will be All Allies.
If you choose a weapon from your left or right hand, there will be no difference than if you had selected it from item (no idea why, but I consider this among the best-case scenarios, so I'm not going to look into it)
In the end, not a whole lot of complicated changes had to be made, but it's all custom. I am 99% sure that it doesn't use any of the same space as any of my other stuff, but I'm only posting code here and no patch.
The original block of code that makes the game open a sub-menu is here:
$02/B9B9 FA PLX A:0000 X:0000 Y:0000
$02/B9BA BD 03 33 LDA $3303,x[$7E:3307] A:0000 X:0004 Y:0000 ;LOAD COMMAND SELECTED FROM MAIN COMMAND MENU
$02/B9BD C9 16 CMP #$16 A:0001 X:0004 Y:0000
$02/B9BF F0 1D BEQ $1D [$B9DE] A:0001 X:0004 Y:0000 ;IF IT'S DART, JUMP TO SPECIALIZED DART SUB-MENU ROUTINE
$02/B9C1 C9 18 CMP #$18 A:0001 X:0004 Y:0000
$02/B9C3 F0 64 BEQ $64 [$BA29] A:0001 X:0004 Y:0000 ;IF IT'S NINJA, JUMP TO THE BLACK MAGIC SUB-MENU ROUTINE
$02/B9C5 C9 05 CMP #$05 A:0001 X:0004 Y:0000
$02/B9C7 90 03 BCC $03 [$B9CC] A:0001 X:0004 Y:0000 ;IF IT'S ANYTHING ELSE DARK WAVE OR LATER, JUMP BEYOND THE SUB-MENU ROUTINES
$02/B9CC 0A ASL A A:0001 X:0004 Y:0000
$02/B9CD AA TAX A:0002 X:0004 Y:0000 ;IF IT'S FIGHT, ITEM, WHITE MAGIC OR BLACK MAGIC, TURN THE COMMAND NUMBER INTO AN INDEX TO REFERENCE CODE POINTERS (2B9E6-2B9EF)
$02/B9CE BF E6 B9 02 LDA $02B9E6,x[$02:B9E8] A:0002 X:0002 Y:0000
$02/B9D2 85 0E STA $0E [$00:000E] A:0005 X:0002 Y:0000
$02/B9D4 BF E7 B9 02 LDA $02B9E7,x[$02:B9E9] A:0005 X:0002 Y:0000
$02/B9D8 85 0F STA $0F [$00:000F] A:00BA X:0002 Y:0000
$02/B9DA 6C 0E 00 JMP ($000E)[$02:BA05] A:00BA X:0002 Y:0000 ;JUMP TO THE APPROPRIATE CODE BASED ON POINTERS
The first step here was to get the game to behave like Item if the command selected was Salve, so enter some custom code:
***
$02/B9BA 20 C3 9A JSR $9AC3 [$02:9AC3];JUMP TO SUBROUTINE AT $02/9AC3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$02/9AC3 22 80 8D 14 JSL $148D80[$14:8D80];JUMP TO SUBROUTINE AT $14/8D80 (BECAUSE THERE REALLY ISN'T ENOUGH ROOM IN THE 28000 BLOCK FOR THIS)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$14/8D80 BD 03 33 LDA $3303,x[$00:342F];LOAD COMMAND SELECTED FROM MAIN COMMAND MENU
$14/8D83 C9 01 CMP #$01
$14/8D85 F0 04 BEQ $04 [$8D8B]
$14/8D87 C9 0A CMP #$0A
$14/8D89 D0 04 BNE $04 [$8D8F] ;IF IT'S NOT SALVE OR ITEM, THEN LEAVE THIS ROUTINE
$14/8D8B 85 F0 STA $F0 [$00:06F0];IF IT IS SALVE OR ITEM, STORE WHICH ONE INTO (NORMALLY UNUSED BYTE) 00F0 IN RAM - THIS WILL BE IMPORTANT LATER
$14/8D8D A9 01 LDA #$01 ;IF IT IS SALVE OR ITEM, CAUSE THE GAME TO BEGIN ACTING LIKE ITEM
$14/8D8F 6B RTL ;RETURN
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$02/9AC7 60 RTS ;BACK TO OUR REGULARLY SCHEDULED PROGRAM
So that makes it so selecting Salve is like selecting Item... except that makes it so selecting Salve is exactly like selecting Item. That's where storing that command into 00F0 comes into play...
For targeting:
Normally, item targeting is generated from the op code at $02/B606 - BD 1A 32 LDA $321A,x[$7E:321A]
Well, we need the game to act differently if Salve is the active command, so, enter more custom code:
***
$02/B606 20 B7 9A JSR $9AB7 [$02:9AB7];JUMP TO SUBROUTINE AT $02/9AB7
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$02/9AB7 22 90 8D 14 JSL $148D90[$14:8D90];JUMP TO SUBROUTINE AT $14/8D90 (STILL NO ROOM IN THE 28000 BLOCK)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$14/8D90 A5 F0 LDA $F0 [$00:00F0];LOAD WHETHER THIS IS ITEM OR SALVE
$14/8D92 C9 0A CMP #$0A
$14/8D94 D0 0D BNE $0D [$8DA3] ;IF NOT SALVE (AND THEREFORE ITEM) THEN LEAVE THIS ROUTINE
$14/8D96 BD 1A 32 LDA $321A,x[$7E:321A];OTHERWISE, LOAD ITEM'S TARGETING
$14/8D99 C9 40 CMP #$40
$14/8D9B B0 03 BCS $03 [$8DA0] ;IF IT'S AN ATTACK ITEM, SKIP AHEAD
$14/8D9D A9 20 LDA #$20 ;IF IT'S A HEALING/SUPPORT ITEM, LOAD 20 (ALL ALLIES) INTO TARGETING
$14/8D9F 6B RTL ;AND RETURN
$14/8DA0 A9 60 LDA #$60 ;IF IT'S AN ATTACK ITEM, LOAD 60 (ALL ENEMIES) INTO TARGETING
$14/8DA2 6B RTL ;AND RETURN
$14/8DA3 BD 1A 32 LDA $321A,x[$7E:321A];IF IT'S ITEM (COMMAND), LOAD ITEM'S NORMAL TARGETING INTO TARGETING
$14/8DA6 6B RTL ;AND RETURN
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$02/9ABB 60 RTS ;BACK TO OUR REGULARLY SCHEDULED PROGRAM
The truth of the matter is that all of that targeting stuff is just for show. The Salve code is what actually assigns targeting to the command, but I needed to do this to make it look natural.
So now we have selected our item and targeting. Somewhere along the lines here, the game takes care of subtracting 1 from the item quantity, so we can remove that from the regular Salve code entirely.
Now, however, the game will still proceed as though the command was Item, meaning the Life item won't be split properly, so we still need whatever the Salve code does to make things work properly, and in order to do that, we need to tell the game to execute Salve if we chose Salve.
So, a bit of background code that normally takes place shortly after this is here:
$03/A6AD A9 01 LDA #$01This 01 will get loaded into the character's "next action," even if the action selected was Salve.
So, we're gonna use that 00F0 value again here:
***
$03/A6AD A5 F0 LDA $F0Now, instead, whichever action we really chose will be loaded into A and stored in the character's next action.
And finally, we have to change the Salve routine around so that it pays attention to the new stuff we just did, so now it will look like this:
***
$03/E2E4 A6 A6 LDX $A6 ;LOAD CHARACTER SLOT INTO X
$03/E2E6 BD 52 20 LDA $2052,x;LOAD ITEM SELECTED INTO A
$03/E2E9 85 FE STA $FE ;STORE A INTO 00FE
$03/E2EB 4C 24 E3 JMP $E324 ;JUMP TO $03/E324 (SKIPPING OVER THE NO-LONGER-RELEVANT QTY REDUCTION ROUTINE, SINCE ITEM SELECTION TAKES CARE OF THIS. REPLACED WITH EMPTY SPACE... PERHAPS FOR LATER USE!)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$03/E324 98 TYA
$03/E325 85 01 STA $01
$03/E327 A9 06 LDA #$06
$03/E329 20 85 80 JSR $8085
$03/E32C A9 F8 LDA #$F8
$03/E32E 8D D4 26 STA $26D4 ;TARGETING STUFF, SINCE WHAT WE DID DURING ITEM SELECTION WAS REALLY JUST FOR SHOW
$03/E331 A5 FE LDA $FE
$03/E333 8D D2 26 STA $26D2 ;LOAD ITEM INTO NEXT ACTION TO TAKE
$03/E336 EE 2A 35 INC $352A
$03/E339 20 3E CD JSR $CD3E ;MAGIC CALL
$03/E33C A5 FE LDA $FE
$03/E33E 8D C5 33 STA $33C5 ;MAGIC GRAPHIC
$03/E341 A9 0A LDA #$0A
$03/E343 8D C8 34 STA $34C8 ;LOAD "SALVE" INTO SMALL COMMAND DISPLAY WINDOW
$03/E346 A9 10 LDA #$10
$03/E348 8D C7 34 STA $34C7 ;(DON'T KNOW)
$03/E34B 60 RTS ;RETURN
And there you have it!
I can't really make a patch of this, because I don't have a clean base to work from for reference, but if you want this new Salve in your ROM, just write in the sections of code in this post that are preceded by three asterisks (***).