Budcakes

Seltzer's Dice bugged?

6 posts in this topic

First off, I just started playing this recently and love it. Thank you guys for all the work you have put into it!

I guess I have a bug to report. Here it is:

Equipped Seltzer's dice. I also equipped Terra with the blood sword, maybe by hitting the L button right after\before equipping Setzer (not too sure of the order). Go into battle, Seltzer's attack animation shows him wielding the blood sword. Hmmm, I think. So I go back to the menu, unequip and reequip them. I also moved the party order around. Next battle: Setzer throws his dice, animation is normal. Then the game crashed.

I am playing 1.8.5, it may be worth noting that I started on the previous version (patched to a clean ROM per the instructions). It's not a big deal, just avoid using the dice, but I wanted to let you know.

1

Share this post


Link to post
Share on other sites

We're looking into it, trying to see if anyone can replicate it.

0

Share this post


Link to post
Share on other sites

I have done a little more playing around with it. It appears Setzer attacks with a random weapon each turn, not just one equipped on another character (like the blood sword). Here is a copy of my save. It's already setup in save slot 1.

https://dropfile.to/MeP8tTU

Hope this helps.

Final Fantasy III Brave New World.001.png

Final Fantasy III Brave New World.000.png

0

Share this post


Link to post
Share on other sites

Found the culprit. It's a build issue that causes the Dice code to jump to the near-end of the battle initialization code, and overwriting a fair chunk of the Dice code in addition.

This is a rather large bug that will cause random crashes whenever Dice is used. Until it can be fixed in the next release, I'll upload a hotfix. It will be removed once the bug is fixed in the next version.

Apply directly to Brave New World 1.8.5.

For headered ROMs

For non-headered ROMs

Edited by seibaby
2

Share this post


Link to post
Share on other sites

For Synchysi, here's a description of the cause of the bug, and code for the hotfix.

The hook at C2/418F is supposed to point to free space at C2/5141. Instead, it points to C2/08BF, causing crashes.

Furthermore, the dice bugfix code is supposed to be inserted to the free space at C2/5141. Instead, it is inserted directly into the code following the function call, overwriting part of the Dice function.

I won't speculate too much as to the cause, as I don't know your build process, but if you merged code patches into a larger assembly file, it's likely that the org !freespace line was omitted. It's also possible that my generic define and function names (!freespace and newfunc) somehow conflicted with other defines or function names in your code, but in that case your assembler should throw an error. I don't know what you use, but my code is written in xkas 0.06 syntax and assembled with xkas 0.06 for testing.

Hotfix code

 

;Restores the whole Dice function
	;Inserts the hook again
;Ensures the hook properly calls the new code in free space
	;xkas 0.06
hirom
;header
!freespace = $C25141      ;requires 15 bytes of free space in C2
	;New code
org !freespace
newDiceCode:
LDA $3A70           ;Which hand is striking (odd = right; even = left)
LSR
BCC .lefthandstrike ;Striking with left hand; branch
LDA $3B7C,Y         ;Hit rate of right hand
BRA .exit
.lefthandstrike
LDA $3B7D,Y         ;Hit rate of left hand
.exit
RTS
	;Restore the Dice function
org $C24158
C24158:  STZ $3414      ;Set to not modify damage
C2415B:  LDA #$20    
C2415D:  TSB $11A4      ;Makes unblockable
C24160:  LDA #$0F
C24162:  STA $B6        ;Third die defaults to null to start with
C24164:  TDC 
C24165:  JSR $4B5A      ;Random Number Function 0 to 255
C24168:  PHA 
C24169:  AND #$0F       ;0 to 15
C2416B:  LDX #$06       ;will divide bottom nibble of random number by 6
C2416D:  JSR $4792      ;Division A/X.  X will hold A MOD X
C24170:  STX $B7        ;First die roll, 0 to 5 -- 3/16 chance of 0 thru 3
                        ;each, 2/16 chance of 4 thru 5 each
C24172:  INX 
C24173:  STX $EE        ;Save first die roll, 1 to 6
C24175:  PLA            ;Retrieve our 0-255 random number
C24176:  LDX #$60       ;will divide top nibble of random number by 6
C24178:  JSR $4792      ;Division A/X
C2417B:  TXA            ;get MOD of division
C2417C:  AND #$F0       ;0 to 5
C2417E:  ORA $B7
C24180:  STA $B7        ;$B7: bottom nibble = 1st die roll 0 thru 5,
                        ;top nibble = 2nd die roll 0 thru 5
C24182:  LSR 
C24183:  LSR 
C24184:  LSR 
C24185:  LSR 
C24186:  INC            ;2nd die roll, converted to a 1 thru 6 value
C24187:  XBA            ;put in top half of A
C24188:  LDA $EE        ;Get first die roll, 1 to 6
C2418A:  JSR $4781      ;Multiply them
C2418D:  STA $EE        ;$EE = 1st roll * 2nd roll, where each roll is 1 thru 6
	;Insert the hook
C2418F:  JSR newDiceCode
	C24192:  CMP #$03
C24194:  BCC C241AB     ;Branch if less than 3 dice, i.e. there's 2
C24196:  TDC            ;Clear Accumulator
C24197:  LDA $021E      ;our 1-60 frame counter.  because 6 divides evenly into 60,
                        ;the third die has the same odds for all sides; it is NOT
                        ;slanted against you like the first two dice.
C2419A:  LDX #$06
C2419C:  JSR $4792      ;Division A/X
C2419F:  TXA            ;new random number MOD 6
C241A0:  STA $B6        ;save third die roll
C241A2:  INC         
C241A3:  XBA            ;3rd die roll, converted to a 1 thru 6 value
C241A4:  LDA $EE     
C241A6:  JSR $4781      ;1st roll * 2nd roll * 3rd roll
C241A9:  STA $EE        ;$EE = 1st roll * 2nd roll * 3rd roll, where each roll
                        ;is 1 thru 6
C241AB:  LDX #$00    
C241AD:  LDA $B6        ;holds third die roll [0 to 5] if 3 dice,
                        ;or 0Fh if only 2 dice
C241AF:  ASL 
C241B0:  ASL 
C241B1:  ASL 
C241B2:  ASL 
C241B3:  ORA $B6        ;A: if 2 dice, A = FF.  if 3 dice, A top nibble = 3rd die roll,
                        ;and A bottom nibble = 3rd die roll
C241B5:  CMP $B7        ;does 3rd die roll match both 1st and 2nd?
                        ;obviously, it can NEVER if A = FF
C241B7:  BNE C241BB      ;if no match, branch
C241B9:  LDX $B6        ;X = 0 if there's not 3 matching dice.  if there are,
                        ;we've got a bonus coming, so let X be the 0 thru 5
                        ;roll value
C241BB:  LDA $EE        ;depending on # of dice, retrieve either:
                        ; 1st roll * 2nd roll   OR
                        ; 1st roll * 2nd roll * 3rd roll
C241BD:  XBA 
C241BE:  LDA $11AF      ;Attacker Level
C241C1:  ASL 
C241C2:  JSR $4781      ; ;1st roll * 2nd roll * 3rd roll * ;Level * 2 
C241C5:  REP #$20       ;set 16 bit-Accumulator
C241C7:  STA $EE        ;overall damage = 
                        ;2 Dice: 1st roll * 2nd roll * Level * 2,
                        ;3 Dice: 1st roll * 2nd roll * 3rd roll * Level * 2
C241C9:  CLC 
C241CA:  STA $11B0      ;save damage
C241CD:  LDA $EE
C241CF:  ADC $11B0      ;Add [Level * 1st roll * 2nd roll * 3rd roll * 2]
                        ;or [Level * 1st roll * 2nd roll * 2] to damage
C241D2:  BCC C241D6     ;branch if it didn't overflow
C241D4:  TDC 
C241D5:  DEC            ;set running damage to 65535
C241D6:  DEX 
C241D7:  BPL C241C9     ;Add the damage to itself X times, where X is the value
                        ;as commented at C2/41B9.  This loop serves to multiply
                        ;3 matching dice by the roll value once more, bringing
                        ;the damage to:  Roll * Roll * Roll * Level * 2 * Roll .
                        ;if X is 0 ;i.e. no 3 matching dice, or 3 matching dice
                        ;with a value of 1, only the bonus-less damage is saved.
C241D9:  SEP #$20       ;8-bit Accumulator
C241DB:  LDA $B5     
C241DD:  CMP #$00
C241DF:  BNE C241E3     ;Branch if command not Fight
C241E1:  LDA #$26
C241E3:  STA $B5        ;Store a dice toss animation
C241E5:  RTS 
Edited by seibaby
2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now