Users browsing this thread: 4 Guest(s)
Breakable Tools - Need Help
Here's a breakdown of all the code that I believe needs to be changed from the Divergent Paths 1.0 release. I would've included all of the tool breakage code too, but there's an origin address missing in the first post so I don't know where all those command comparisons are taking place.
Essentially, you need to first make sure you've applied ALL of Bropedio's fix, so that Metamorph--which Kappa uses--and Steal/Mug--which Locke uses--are also fixed and don't contribute to the problem [Note the small tweak, the Steal fix is identical to the Metamorph fix in the above code]. THEN, we change the no_break branch to rev up the same restore situation that the break branch does, but with the original item ID in A instead of #$FF. We do this by taking the second variable on the stack, because it was the second-to-last to be placed in the stack [at the very start of your tool breakage subroutine]. This variable was the original item ID, before any multiplication or shuffling took place.
I tried it up to 14 with tool usage and it appears to work. I urge you to test it more thoroughly. Bropedio's code did all the heavy lifting here, all I did was restore the original tool ID before running it (kinda like that earlier fix I proposed, but with the vanilla bug now corrected).
EDIT: IMPORTANT! Make sure you also fix the item buffer length in C1, or the original bug will still be a problem! Added as the first line in the code block because it is by far the most essential.
EDIT: CAUTION! If you took the block of code before 7-8-2021, you need to take it again. I made a mistake in the assembly... wrote "TBA" instead of "XBA", xKas ignored it, and the code worked as intended. When I corrected my 'error', it started ADDING tools to the menu. This implied my earlier approach was not using Bropedio's buffer fix properly, so I ran through the code again and found that the four bytes that were bothering you were indeed a source of problems (they were telling the item to be added twice). So I removed them and now it seems to be working.
Code:
$C112D5: [Fix Item return buffer]
HEX
E0 50 00
CODE MEANING
CPX #$0050 ; The game only clears #$40 for item buffer, but it expects #$50 [Bropedio]
$C20A2B:
HEX
20 60 65
CODE MEANING
JSR ReturnReserve
$C239EC: [Steal Fix]
HEX
EB BD 18 30 20 4B 65 EA EA
CODE MEANING
XBA ; store acquired item in B
LDA $3018,X ; character's unique bit
JSR SaveItem ; save new item to buffer
NOP #2
$C23A7C: [Metamorph Fix]
HEX
EB BD 18 30 20 4B 65 EA EA
CODE MEANING
XBA ; store acquired item in B
LDA $3018,X ; character's unique bit
JSR SaveItem ; save new item to buffer
NOP #2
$C26490: [Breakable Tools]
HEX
C9 09 F0 06 C9 01 F0 02 C9 08 60 48 08 20 63 2B C2 10 AA BF 12 50 D8 10 1E 20 5A 4B 29 1F D0 17 A9 08 2C BB 3E D0 10 A9 44 8D 01 34 E2 10 BB A9 FF EB BD 18 30 80 09 E2 10 BB A3 02 EB BD 18 30 20 4B 65 28 68 E9 A2 85 B6 60
CODE MEANING
check_command_c2:
CMP #$09
BEQ check_command_c2_end
CMP #$01
BEQ check_command_c2_end
CMP #$08
check_command_c2_end:
RTS
check_break:
PHA
PHP
JSR $2B63 ; Multiply A by 30, size of item data block
REP #$10 ; Set 16-bit X and Y
TAX
LDA $D85012,X ; equipment spell byte. Bit 7: 1 = remove from inventory upon usage, 0 = nope
BPL no_break ; if the flag is not set, this tool never breaks
JSR $4B5A
AND #$1F ; 1/32 chance of breaking
BNE no_break
LDA #$08
BIT $3EBB ; Check bit 4 of $3EBB (loaded from 1DD0 at the beginning of battle).
BNE no_break ; If set, tools can't be broken (set via event with B8 3B. Clear with B9 3B)
LDA #$44 ; "Orge Nix broke!" dialog. Works for most tools but gets clobbered by the Air Anchor "Move and you're dust!"
STA $3401
SEP #$10 ; Set 8-bit X and Y
TYX
LDA #$FF
XBA ; Put it into B because we're in 8-bit mode. This acts like a free scratch variable
LDA $3018,X
BRA check_break_end
no_break:
SEP #$10 ; Set 8-bit X and Y
TYX
LDA $02,S ; Load the second item off the stack. In this instance, it's a copy of the A we pushed, the tool's original item ID.
XBA ; Put it into B because we're in 8-bit mode. This acts like a free scratch variable
LDA $3018,X ; character's unique bit
check_break_end:
JSR SaveItem ; save new item to buffer [This ensures if there's an old item waiting, like a reusable rod, it gets saved]
PLP
PLA
SBC #$A2 ; carry was clear, so subtract 163
STA $B6 ; save unique Tool index. 0 = NoiseBlaster, 1 = Bio Blaster, etc.
RTS
$C2654B: [Save Item & Return Reserve]
HEX
0C 8C 3A BD F4 32 48 EB 9D F4 32 DA 20 C7 62 FA 68 9D F4 32 60 BD 18 30 0C 8C 3A BD 19 32 60
CODE MEANING
SaveItem: ; 21 bytes
TSB $3A8C ; set character's reserve item to be added
LDA $32F4,X ; load current reserve item
PHA ; save reserve item on stack
XBA ; get new item in A
STA $32F4,X ; store new item in reserve byte
PHX ; save X
JSR $62C7 ; add reserve to obtained-items buffer
PLX ; restore X
PLA ; restore previous reserve item
STA $32F4,X ; store in reserve item byte again
RTS
ReturnReserve: ; 10 bytes
LDA $3018,X ; character's unique bit
TSB $3A8C ; return reserve to inventory at turn end
LDA $3219,X ; ATB top byte (vanilla code)
RTS
I tried it up to 14 with tool usage and it appears to work. I urge you to test it more thoroughly. Bropedio's code did all the heavy lifting here, all I did was restore the original tool ID before running it (kinda like that earlier fix I proposed, but with the vanilla bug now corrected).
EDIT: IMPORTANT! Make sure you also fix the item buffer length in C1, or the original bug will still be a problem! Added as the first line in the code block because it is by far the most essential.
EDIT: CAUTION! If you took the block of code before 7-8-2021, you need to take it again. I made a mistake in the assembly... wrote "TBA" instead of "XBA", xKas ignored it, and the code worked as intended. When I corrected my 'error', it started ADDING tools to the menu. This implied my earlier approach was not using Bropedio's buffer fix properly, so I ran through the code again and found that the four bytes that were bothering you were indeed a source of problems (they were telling the item to be added twice). So I removed them and now it seems to be working.
« Next Oldest | Next Newest »
Users browsing this thread: 4 Guest(s)