Code repository for 2.0

36 posts in this topic

This thread is for the devs. There are a lot of assembly patches going into 1.10.0 2.0, let's collect them all in one place.





Pincer/Back/Side probabilities - DONE
Vindictive targeting fix - DONE
Encounter Rate - DONE
Reflect Timer - DONE
Melee Counter - DONE
MP low counter - DONE
Runic ignores Clear - DONE
N. Cross rebalance - DONE
Mind blast mod - DONE
Tank & Spank 1.0 - DONE
ATB colors - DONE
Quake/Vanish Fix - DONE
Modified Pincer/Side/Back attack probabilities - DONE
Lack of back attack damage stack hack - DONE
Exploder Multplier (for Gau) - DONE
Retreat Is Faster - ABANDONED
New status screen - WIP

??? Update - (to be PM'ed directly to Synchysi)
Status Display Update (Cycling Auras) - DONE
Status Display Update (Regen/Rerise) - DONE
Doomstick Bugfix - DONE
Relics Block Stop - DONE
Shop Preview - DONE
Spell Dot Display - DONE

Weapon Swap in Combat - WIP/TENTATIVE
Max HP/ATB toggle - DONE
Inventory Index Fix - DONE

Defend/Row 1/2 Turn - WIP/TENTATIVE
Elemental Mixing - DONE

SrBehemoth OpCode Update - DONE
Aero Speed Hack - DONE

@Gi Nattak
Booty Fix - DONE

Leet Sketcher
Imp Skimp - HERE

Genji Glove BatPwr Display Fix - ???
Rage list re-order - HERE
Optimize Fix - HERE

Poco Loco

Tritoch Animation Fix - HERE

Phunbaba Event Tile Fix - HERE (disclaimer)


Just clarifying:  this isn’t a discussion thread so any non dev post stuff will be purged. - Mish

Edited by BTB

Share this post

Link to post
Share on other sites

Melee Counter - DONE

EDIT: updated to fix a bug. NOTE: The free space requirements have increased.


	; New parameters for FC 05 - Melee counter and MP damage counter
    ; Updated to fix a bug where MP damage would trigger melee counters. The checkParams code is now 1 byte longer.
	; AI Script commands:
; FC 05 00 00 = counterattack all damage, as usual
; FC 05 00 01 = counterattack ONLY damage that's both physical and row-respecting
; FC 05 00 02 = counterattack ONLY MP damage
!freespace = $C23C61        ; Requires 5 bytes of free space in C2
!freespacelong = $C3F577    ; Requires 67 bytes of free space anywhere
	; Preparation:
; Hook functon C2/35E3 (Initialize several variables for counterattack purposes)
org $C235E9
      JSL initAttackVars  ; (initialize new var $327D,index containing bitflags for
                          ;  physical damage, respects row, and MP damage in bit 0,
                          ;  bit 5, and bit 7 respectively)
      macro initAttackVars()
      TXA                            ; (displaced code)
      STA $3290,Y              ; (displaced code)
      LDA $B3                  ; If Bit 5 is set it ignores attacker row
      EOR #$FF                 ; Invert it so bit 5 is set if melee
      LSR                      ; Shift it to bit 4
      ORA $11A7                ; Merge with bit 4 of $11A7 ("respects row")
      AND #$10                  ; Isolate bit 4 (1 = respects row)
      LDA $11A2                  ; Bit 0 = physical damage if set
      LSR                   ; Carry = 1 if physical damage
      ROL                   ; Bit 1 = physical
                          ; Bit 5 = melee
      ASL                   ; Shift again
      LDA $11A3        
      ROL                            ; Carry = 1 if affects MP
      ROR                            ; A: bit 1 = physical damage
                        ;    bit 5 = melee attack
                        ;    bit 7 = affects MP    
                        ; (all other bits are 0)
      STA $327D,Y                ; Save attack properties to unused var $327D,index
.exit    RTL
; Execution:
; FC command $05 (Counter if damaged)
org $C21C70
doCounter:                    ; (vanilla FC 05 code)
	; Redirect pointer for FC command $05 to new code
org $C21D5F
      dw checkParams
	org !freespace
      JML checkParamsLong
      macro checkParamsLong()
      LDA $3A2F            ; Script command byte 4
      LSR                    ; Check if it's 1 (melee counter)
      BCS .melee        
      LSR                    ; Check if it's 2 (MP damage counter)
      BCC .omni            ; If not set, it's a normal counter
      LDA $327D,Y        
      CMP #$80            ; Check if attack affects MP
      BNE .exit            ; Exit if not
      BRA .omni            ; Counter if attack affects MP
.melee    LDA $327D,Y            ; Attack properties
      CMP #$21            ; Check respect row, physical
      BNE .exit            ; Exit if not both are set
.omni    JML doCounter
.exit    CLC
		JML noCounter
org !freespacelong
reset bytes
print "New code requires ",bytes," bytes of free space anywhere"


Edited by seibaby

Share this post

Link to post
Share on other sites

MP low counter - DONE


	; HP/MP low counter redesign
; By Seibaby
	; FC command $06 (HP low counter) normally checks HP versus <parameter> * 128 while
; FC command $07 (MP low counter) checks MP versus <param> only. This makes it so that
; MP is compared to <param> * 128 as well.
	; FC command $06 (HP low counter)
org $C21D61
dw mpLowCounter
; FC command $07 (MP low counter)
org $C21D63
dw mpLowCounter
	org $C21BB7
        JSR $1D34
        BCC .exit
        LDA $3A2F
        REP #$20
	        CPX #$0E     ; is it command $07 - MP low counter?
        BCC .hp     ; branch if it's not (ie. it's $06 - HP low counter)
        CMP $3C08,Y ; MP
        BRA .exit
.hp        CMP $3BF4,Y ; HP
.exit    RTS
        padbyte $FF : pad $C21BD6
        warnpc $C21BD7
Edited by seibaby

Share this post

Link to post
Share on other sites

Runic ignores Clear - DONE


	; Set Runicked attacks to Ignore Clear
	org $C2357E
LDA #$2182
STA $11A3      ;Set just concern MP, not reflectable, Unblockable, Heal
LDA #$8040
TRB $B2        ;Flag little Runic sword animation, set Ignore Clear
SEP #$20       ;Set 8-bit Accumulator
LDA #$60
STA $11A2      ;Set just ignore defense, no split damage
TDC            ;need top half of A clear
LDA $11A5      ;MP cost of spell
JSR $4792      ;divide by X
STA $11A6      ;save as Battle Power
JSR $385E      ;Sets level, magic power to 0
JSR $2A0F      ;(some runic patch hook?)
LDA #$04       ; A = 4
STA $BA        ;Don't retarget if target invalid
DEC A          ; A = 3   
Edited by seibaby

Share this post

Link to post
Share on other sites

N. Cross rebalance - DONE


!freespace = $C2661B
	; N. Cross (Special effect $29)
; One or two targets will be picked randomly
org $C2414D
C2414D: REP #$20       ; Set 16-bit A
C2414F: LDA $A4        ; Targets
C24151: PHA            ; Save targets
C24152: JSR $522A      ; Randomly pick an entity from among the targets
C24155: JMP morecode
	org !freespace
        STA $A4        ; Save new target
        PLA            ; Get original targets again
        JSR $522A      ; Pick one at random
        TSB $A4        ; Save new target(s)
        SEP #$20       ; Set 8-bit A
Edited by seibaby

Share this post

Link to post
Share on other sites

Mind blast mod - DONE


	;BNW Mind Blast tweak
!freespace = $C25141   ; free space in 1.9...I think
	; Loop 5 times for Mind Blast
org $C2413E
LDY #$08
	org $C23BB8
LDX #$08
	org $C23BC1
JSR checkStam        ; Check Stamina before attempting to set status
org !freespace
SEP #$20
JSR $23B2            ; Check if Stamina blocks
REP #$20            
BCS .exit            ; Exit if so
JMP $3BD0            ; Randomly mark a status from attack data to be set
Edited by seibaby

Share this post

Link to post
Share on other sites

Tank & Spank 1.0 - DONE

;Tank & Spank (previously Cover Knight and Smart Cover)
;by Seibaby
	;v1.0 - Only allows back row targets for Stamina-based cover
;       Disables Cover when Dancing
;v0.9 - Disables Interceptor and halves Evasion when Covering
;v0.7 - Fixes a bug where Knight wouldn't reset Defending stance when Covering
;v0.6 - New Smart Cover logic
;       Some Cover nerfs
;v0.5 - Fixes an issue with Knights not taking targets' statuses into
;       account (Image and Clear, but also Zombie and Petrify)
;v0.4 - Fixes a bug causing Knights to Cover monsters attacking other
;       monsters
;v0.3 - Adds an exception to not trigger Cover if the Knight is Near Fatal
;       and the target is healthy.
;v0.2 - Fixes a bug that caused the wrong statuses (on the target) to be
;       considered for whether or not to disable True Knight.
	;Changes the True Knight effect to trigger with a Stamina / 192 chance even if
;the target isn't in Near Fatal status.
	;New Smart Cover patch, which disables True Knight for all attacks
;originating from a player character, unless that character is uncontrollable,
;in which case it will only disable it if the attack comes from a healing weapon,
;or if the weapon is elemental and the target absorbs/nullifies that element.
;It also considers a few extra statuses for purposes of disabling True Knight.
;ON TARGET: Death, Petrify, Zombie, Magitek, and Image
;           (in addition to Clear)
;ON KNIGHT: Dark, Magitek, Image, Berserk
;           (in addition to Death, Petrify, Clear, Zombie, Sleep, and Muddled)
;xkas 0.06
	!smartCover = $C2AE31       ;Requires 99 bytes of free space
;!halveEvade = $C10000       ;Requires 20 bytes of free space
;!noDogBlock = $C20000       ;Requires 9 bytes of free space
	;A few notes on the changes made to these functions:
;Entering this function, A is 16-bit and X/Y are 8-bit. Register width is
;never changed and the call following this function doesn't care about Carry,
;so I have removed a bunch of useless PHP/PLP and REP #$20 throughout, to make
;room for the new code.
;I have also removed some code related to monsters using True Knight, which was
;supported in vanilla, but unused (and remains so in BNW). The check for if the
;bodyguard was Controlled was also removed (doubly useless).
	org $C2123A
	;True Knight and Love Token
org $C2123B
        LDA $B2
        BIT #$0002          ;Is "No critical and Ignore True Knight" set?
        BNE .exit           ;Exit if so
        LDA $B8             ;intended target(s).  to my knowledge, there's only
                            ;one intended target set if we call this function..
        JMP smartCover
        macro smartCover()
        print "Writing smartCover() to ",pc
        reset bytes
        BEQ .exit           ;Exit if none
        LDY #$FF    
        STY $F4             ;default to no bodyguards.
        JSR $51F9           ;Y = index of our highest intended target.
                            ;0, 2, 4, or 6 for characters.  8, 10, 12, 14, 16,
                            ;or 18 for monsters.
        STY $F8             ;save target index
        STZ $F2             ;Highest Bodyguard HP So Far = 0.  this makes the
                            ;first eligible bodyguard we check get accepted.
                            ;later ones may replace him/her if they have more
        LDX $336C,Y         ;Love Token - which target takes damage for you
        BMI .noLove         ;Branch if none do
        JSR evalKnight_skip ;consider this target as a bodyguard (skip Stamina
                            ;and Near Fatal checks)
        JSR newTarget       ;if it was valid, make it intercept the attack  
.noLove PLX
        LDA $3A36
        BNE .exit           ;Exit if Golem is active
        CPX #$08            ;Check attacker
        BCS .status         ;Branch if attacker is a monster
        CPX $F8
        BEQ .exit           ;Exit if Attacker = Target
        LDA $3EE4,X         ;Attacker status byte 1-2
        BIT #$2002
        BNE .heals          ;Branch if Muddled or Zombied
        LDA $3394,X         ;Check if Attacker is Charmed
        BMI .exit           ;If not Muddled, Zombied, or Charmed, this
                            ;attack was initiated by the player, so exit
.heals  LDA $11A9           ;Special weapon property
        AND #$00FF          ;Isolate bottom byte
        CMP #$0018          ;Check "Curative Attributes"
        BEQ .exit           ;Exit if set
        SEP #$20         
        LDA $11A1           ;Attack element(s)
        PLA                 ;Copy to high byte
        REP #$20
        AND $3BCC,Y         ;Target absorbed/immune elements
        BNE .exit           ;If any absorbed or nullified, exit
.status LDA $3EE4,Y         ;Target status byte 1-2
        BIT #$04DA
        BNE .exit           ;Branch if Death, Petrify, Clear, Zombie, Magitek,
                            ;or Image
.seize  LDA $3358,Y         ;$3359 = who is Seizing you
        BPL .exit           ;Branch if target is seized
        LDA #$000F          ;Load all characters as potential bodyguards        
        JMP trueKnightAndLoveToken_cover
.exit   PLX
        print "smartCover: ",bytes," bytes written, ending at ",pc
	.cover  CPY #$08
        BCC .saveBg         ;Branch if target is character
        TDC                 ;Null all potential bodyguards
.saveBg STA $F0             ;Save potential bodyguards
        LDA $3018,Y         ;bit representing target
        ORA $3018,X         ;bit representing attacker
        TRB $F0             ;Clear attacker and target from potential
        LDX #$12
.loop   LDA $3C57,X         ;High byte = Relic Effects 3
        ASL #2              ;Check bit 6 (True Knight)
        BCC .next           ;Branch if no True Knight effect                
        LDA $3018,X
        BIT $F0
        BEQ .next           ;Branch if this candidate isn't on the same
                            ;team as the target
        JSR evalKnight      ;consider them as candidate bodyguard.  if they're
                            ;valid and their HP is >= past valid candidates,
                            ;they become the new frontrunner.
.next   DEX
        BPL .loop           ;Do for all characters and monsters
        LDA $F2
        BEQ .exit           ;Exit if no bodyguard found [or if the selfless
                            ;soul has 0 HP, which shouldn't be possible outside
                            ;of bugs].
        JSR newTarget       ;make chosen bodyguard -- provided there was one --
                            ;intercept attack.  if somebody's already been
                            ;slated to intercept it [i.e. due to Love Token],
                            ;the True Knight will sensibly defer to them.
.exit   PLX
;Make chosen bodyguard intercept attack, provided one hasn't been marked to do
;so already.
        LDX $F4
        BMI .exit           ;exit if no bodyguard found
        CPY $F8
        BNE .exit           ;exit if $F8 no longer points to the original
                            ;target, which means we've already assigned a
                            ;bodyguard with this function.
        STX $F8             ;save bodyguard's index
        STY $A8             ;save intended target's index
        LSR $A8             ;.. but for the latter, use 0,1,2,etc rather
                            ;than 0,2,4,etc
        LDA $3018,X
        STA $B8             ;save bodyguard as the new target of attack
        SEP #$20
        LDA $3AA1,X
        BIT #$02
        BEQ .noDef          ;Branch if not Defending
        JSR $0A41           ;Clear Defending flag
        JSR $0A3C           ;Relax Defending pose
.noDef  REP #$20
.exit   RTS
;Consider candidate bodyguard for True Knight or Love Token
        LDA #$0020
        BIT $3AA1,X
        BNE .exit           ;Exit if guard is in back row
        LDA $3EE5,Y         ;Low byte = Status byte 2
        LSR #2              ;Check bit 1 (Near Fatal)
        BCS .skip           ;Skip Stamina check if target Near Fatal        
        LDA $3AA1,Y
        BIT #$0020
        BEQ .exit           ;Exit if target is in back row
        LDA $3EE5,X         ;Knight's Status byte 2
        LSR #2              ;Check Near Fatal
        BCS .exit           ;If Knight is Near Fatal, exit
        SEP #$20                
        LDA #$C0            ;192
        JSR $4B65           ;Random: 0 to 191
        CMP $3B40,X         ;Stamina
        REP #$20
        BCS .exit           ;Exit if Stamina was lower
.skip                       ;Love Token enters here
        LDA $3AA0,X
        BCC .exit           ;Exit function if entity not present in battle?
        LDA $3358,X         ;$3359 = who is Seizing you
        BPL .exit           ;Exit if you're Seized
        LDA $3EE4,X
        BIT #$B4DB          ;Death, Petrify, Clear, Zombie, Sleep, Muddled,
                            ;Dark, Magitek, Image, Berserk
        BNE .exit           ;Exit if any set
        LDA $3EF8,X     
        BIT #$3211          ;Dance, Stop, Freeze, Spell Chant, Hide
        BNE .exit           ;Exit if any set
        LDA $3018,X
        TSB $A6             ;make this potential guard jump in front of the
                            ;target, can accompany others
        LDA $3BF4,X         ;HP of this potential bodyguard
        CMP $F2         
        BCC .exit           ;branch if it's not >= the highest HP of the other
                            ;bodyguards considered so far for this attack.
        STA $F2             ;if it is, save this entity's HP as the highest
                            ;HP so far.
        STX $F4             ;and this entity becomes the new bodyguard.
.exit   RTS
	print "Cover function end: ",pc
print "Vanilla Cover ends: c212f4"
	;Check for Covered attacks in Hit Determination
;Disable Dog Block if attack was Covered
org $C22282
        LDA $3EF9,Y
        BPL C22293            ;Branch if not dog block
        JSR skipDogBlock
        macro skipDogBlock()
        print "Writing skipDogBlock() to ",pc
        reset bytes
        CPY $F4             ;Is target = bodyguard?
        BNE .exit           ;If not, return
        CLC                 ;Otherwise, set carry = 0, ie.
.exit   JMP $4B53           ;Random: carry 0 or 1          
        print "skipDogBlock: ",bytes," bytes written, ending at ",pc
;        BCC C22293          ;50% chance
;        LDA #$40      
;        STA $FE             ;Set dog block animation flag
org $C22293
	;Halve Evasion if attack was Covered
org $C22345
        JSR halveEvasion    ;Get Evade
        macro halveEvasion()
        print "Writing halveEvasion() to ",pc
        reset bytes
        halveEvasion:       ;Y = target of attack
        CPY $F4             ;Index of bodyguard ($FF if no bodyguard)
        BNE .exit           ;If not the same as target, exit
        LDA #$FF            ;255
        SBC $3B54,Y         ;255 - (255 - Evade * 2 + 1)
                            ;(= Evade * 2 - 1)
        INC                 ;Evade * 2
        LSR                 ;Evade
        LSR                 ;Evade / 2
        JMP $2861           ;New blockvalue from halved Evade
.exit   LDA $3B54,Y         ;(255 - Evade * 2 + 1)
        print "halveEvasion: ",bytes," bytes written, ending at ",pc
	org !smartCover
;org !halveEvade
;org !noDogBlock

Share this post

Link to post
Share on other sites

ATB colors - DONE



; Time Magic affects the ATB bar colors
; By Seibaby 2018-09-23
	; It also changes the endcaps on the ATB bar based on whether ATB is full or not.
; This requires two new glyphs in the 8x8 font tileset (the two tiles immediately following
; the ATB endcaps, left and right). The endcaps are changed so that the uncharged ones don't
; use colors 2 or 4, just the grey and transparency. Then the charged endcaps use colors
; 4 (the brightest) and optionally color 2 like the vanilla endcaps did.
	; Palette color order
;       0: transparency
;       1: Text Drop shadow / ATB gauge outline
;       2: Text Grey magic dot / ATB gauge border
;       3: Text / ATB gauge core
	; $2EAF01: Palette #1: $21 - White text
; $2EAF09: Palette #2: $25 - Grey text
; $2EAF11: Palette #3: $29 - Yellow text / Full ATB gauge
; $2EAF19: Palette #4: $2D - Blue
; $2EAF21: Palette #5: $31 - All black (???)
; $2EAF29: Palette #6: $35 - White (charging) ATB gauge
; $2EAF31: Palette #7: $39 - Green Morph gauge
; $2EAF39: Palette #8: $3D - Red Condemned gauge (unused)
	!freespace = $EEAF01
	; Add checks for statuses to ATB drawing routine
org $C16872
         LDA $2021        ; ATB gauge setting
         LSR              ; Gauge enabled?
         BCC drawMaxHP    ; Branch if disabled
         LDA $3A8F        ; nATB: is ATB paused?
         LSR              ; (01 = paused)
         BCS .exit        ; Don't update bars while ATB is paused
         LDA $4E          ; Text color
         PHA              ; Save it
         LDA $18          ; Which character is it (0-3)
         TAX              ; Index it
         LDA $619E,X      ; Character's ATB gauge value
         PHA              ; Save it for later
         TXA              ; A = character 0-3
         ASL              ; Double it
         JSL newfunc
         macro newfunc()
         TAX              ; Character index (0-6)
         LDA $3EF8,X      ; Status byte 3
         BIT #$10         ; Is Stop status set?
         BEQ .slow        ; Branch if not Stopped
         LDA #$3D         ; Select palette #8           STOPPED
         BRA .store       ; Store palette
.slow    LDA $3EF8,X      ; Status byte 3
         BIT #$04         ; Is Slow status set?
         BEQ .haste       ; Branch if not Slowed
         LDA #$2D         ; Select palette #4           SLOW
         BRA .store       ; Store palette
.haste   LDA $3EF8,X      ; Status byte 3
         BIT #$08         ; Is Haste status set?
         BEQ .normal      ; Branch if not Hasted
         LDA #$39         ; Select palette #7           HASTE
         BRA .store       ; Store palette
.normal  LDA #$35         ; Select palette #6           NORMAL
.store   RTL
         STA $4E          ; Store palette
         PLA              ; Restore ATB gauge value
         JSR $6854        ; Draw the gauge
         PLA              ; Get saved text color
         STA $4E          ; Store text color
.exit    RTS
         print "c1/6872 ends at: ", pc,", should be c16898"
	org $C16898
LDA #$C0                  ; Draw a "/" as HP divider
	; Endcaps stuff
org $C16854
JSL newfunc2
	macro newfunc2()
LDA $04,S
BEQ .leftfull
LDA #$F9
BRA .drawleftcap
	JSR $66F3      ; Draw opening end of ATB gauge
LDA #$04
LDA $C168AC,X  ; Get the ATB gauge character
JSR $66F3      ; Draw tile A
DEC $1A        ; Decrement tiles to do
BNE .loop      ; Branch if we haven't done 4
JML newfunc3
macro newfunc3()
BEQ .rightfull
BRA .drawrightcap
LDA #$FC       ; Draw tail end of ATB gauge
JML $C166F3    ; Draw tile A
print "c1/6854 ends at: ",pc,", should be c16872"
; Relocate 2bpp palettes
org !freespace
print "palettes written to ",pc
incbin palettes-bnw.bin       ; Use SNESpal to edit the palettes
print "new code written to ", pc
	org $C140A8
LDA palettes,X            ; Load battle text palettes white and gray
	org $C140AF
LDA palettes+16,X         ; Load battle text palettes yellow and cyan
	org $C14100
LDA palettes+40,X         ; Load battle gauge palette
Edited by seibaby

Share this post

Link to post
Share on other sites

stop immunity - reverses normal application effect with equipment. not thoroughly tested. may be buggy. also old. i made it years ago.



org $c228c6
jsr remove_stop_from_equip

org $c22914
jsr equip_invert_stop
bra skip_skip
padbyte $ea : pad $c2291f

org $c2291f

org $c26610
and #$EF
sta $3c6d,x

sta $3330,x
sep #$20
lda $D4
and #$10
eor #$ff
sta $3330,x
rep #$20
eor $d2                                    ; equipment immunities
sta $331c,x                                ; vulnerable to whatever equipment doesn't
                                        ; block in immunity bytes 1 and 2


Share this post

Link to post
Share on other sites

This is the shop hack. It's a mess, and I think some unnecessary stuff is still in it.


table ff6_snes_menu_a.tbl,rtl

org $c388ce
ldx #$7B65
org $c388da
ldx #$7BE5
org $c388e6
ldx #$7C65
org $c388f2
ldx #$7CE5

org $C38D69
dw ele_resist
dw ele_absorb
dw ele_nullify
dw ele_weakness

org $c3baba
nop #3

org $c38746
;Fork: Draw offensive properties
C38746:    JSR $879C      ; Draw Bat.Pwr
        jsr gear_stats_evasion_attack_elements
        jsr load_item_index
        and #$80
        jsr check_text_color
        ldy #$8e30
        jsr process_text
        jsr load_item_index
        and #$40
        jsr check_text_color
        ldy #$8e38
        jsr process_text
        jsr load_item_index
        and #$02
        jsr check_text_color
        ldy #$8e26
        jsr process_text
padbyte $FF : pad $C38795
org $c3b4bd
        jsr handle_shop_stats
        jsr $1368        ; NMI
        jsr $7fd9        ; draw name (from BAC9)
padbyte $FF : pad $c3b4e6

org $c3b8c4
        jsr clear_screen_bg2
        nop #6
org $C3B95a
        jsr clear_screen_bg3
C3B963:    JSR $BFD3      ; Draw title
C3B969:    LDY #$C338     ; Text pointer
C3B96C:    JSR $02F9      ; Draw "GP"
C3B96F:    JSR $C2F2      ; Color: User's
C3B972:    LDY $1860      ; Gold LBs
C3B975:    STY $F1        ; Memorize it
C3B977:    LDA $1862      ; Gold HB
C3B97A:    STA $F3        ; Memorize it
C3B97C:    JSR $0582      ; Turn into text
C3B97F:    LDX #$7A33     ; Text position
C3B982:    JSR $04AC      ; Draw GP total
C3B985:    RTS

org $c3b989
        ldy #help_text
org $c3bac9
        jsr check_nmi
org $c3bfd3
;draw shop title, define shop index
C3BFD3:    JSR $C2F7      ; Color: Blue
C3BFD6:    LDA $4212      ; PPU status
C3BFD9:    AND #$40       ; H-Blank?
C3BFDB:    BEQ C3BFD6      ; Loop if not
C3BFDD:    LDA $0201      ; Shop number
C3BFE0:    STA $211B      ; Set matrix A LB
C3BFE3:    STZ $211B      ; Clear HB
C3BFE6:    LDA #$09       ; Shop data size
C3BFE8:    STA $211C      ; Set matrix B
C3BFEB:    STA $211C      ; ...
C3BFEE:    LDX $2134      ; Index product
C3BFF1:    STX $67        ; Set shop index
C3BFF3:    LDA $C47AC0,X  ; Shop flags
C3BFF7:    AND #$07       ; Title number
C3BFF9:    ASL A          ; Double it
C3BFFA:    TAX            ; Index it
C3BFFB:    REP #$20       ; 16-bit A
C3BFFD:    LDA $C3C00C,X  ; Text pointer
C3C001:    STA $E7        ; Set src LBs
C3C003:    SEP #$20       ; 8-bit A
C3C005:    LDA #$C3       ; Bank: C3
C3C007:    STA $E9        ; Set src HB
C3C009:    JMP $02FF      ; Draw title

org $c3c037
        db $2f,$06,$00
org $c3c2e1
        jsr buy_menu_exp
org $c3f850
C38749:    JSR $87EB      ; Draw evasions
        jsr $c2f7
C38750:    LDY #$8E1D     ; Text pointer
C38753:    JSR $02F9      ; Draw "Attack"
C38756:    jmp $88A0      ; Draw elements
        beq grey_text_color
        lda #$20        ; palette 0
        bra store_tcolor
        lda #$24        ; grey text
        sta $29            ; color: user's
        ldx $2134        ; item index
        lda $d85013,x    ; byte to look at
        sty $e7
        jsr $8795
        jsr $6a28        ; clear bg2 map a
        jsr $6a2d        ; clear bg2 map b
        jsr $6a32        ; clear bg2 map c
        jsr $6a37        ; clear bg2 map d
        ldy #shop_gear_window
        jsr $0341        ; draw shop gear window
        ldy #shop_gear_window_actors
        jsr $0341        ; draw actors' window
        ldy #shop_gear_weapon_name
        jsr $0341
        ldy #shop_gear_description
        jsr $0341
        jsr $6a3c        ; clear bg3 map a
        jsr $6a41        ; clear bg3 map b
        jsr $6a46        ; clear bg3 map c
        jsr $6a4b        ; clear bg3 map d
        jsr $02ff        ; draw title
        lda #$10        ; reset/stop desc
        tsb $45            ; set menu flags
        jsr $0f39        ; queue text upload
        jsr $1368
        jsr $0f4d        ; queue text upload 2
        jsr $b8a6        ; handle d-pad
        jsr check_stats
        jsr $bc84        ; draw quantity owned
        jsr $bca8        ; draw quantity worn
;Handle hold Y
        lda $0D
        bit #$40        ; holding Y?
        beq shop_handle_b ; branch if not
        rep #$20        ; 16-bit A
        lda #$0100        ; BG2 scroll position
        sta $3b            ; BG2 Y position
        sta $3d            ; BG3 X position
        sep #$20        ; 8-bit A
        lda #$04        ; bit 2
        trb $45            ; set bit in menu flags A
        jsr gear_desc
;Fork: Handle B
        stz $3c
        stz $3e
        lda #$04
        tsb $45
C3B4CD:    LDA $09        ; No-autofire keys
C3B4CF:    BIT #$80       ; Pushing B?
C3B4D1:    BEQ shop_handle_a     ; Branch if not
C3B4D3:    JSR $0EA9      ; Sound: Cursor
C3B4D6:    JMP $B760      ; Exit submenu

;Fork: Handle A
C3B4D9:    LDA $08        ; No-autofire keys
C3B4DB:    BIT #$80       ; Pushing A?
        beq not_pushing_a
C3B4DF:    JSR $B82F      ; Set buy limit
C3B4E2:    JSR $B7E6      ; Test GP, stock

        jsr $1368
        jsr $c2f7        ; color: blue
        ldy #text_vigor    ; text: vigor
        jsr $02f9        ; draw text
        ldy #text_magic ; text: magic
        jsr $02f9        ; draw text
        ldy #text_stamina ; text: stamina
        jsr $02f9        ; draw text
        ldy #text_speed ; text: speed
        jsr $02f9        ; draw text
        ldy #text_def    ; text: defense
        jsr $02f9        ; draw text
        ldy #text_mdef    ; text: magic defense
        jsr $02f9        ; draw text
        ldy #text_eva    ; text: evasion
        jsr $02f9        ; draw text
        ldy #text_meva    ; text: magic evasion
        jsr $02f9        ; draw text
        ldy #text_bpow  ; text: bat.pow.
        jsr $02f9        ; draw text
        jsr $bfc2        ; get item
        ;jsr $1368        ; trigger NMI
        jsr $c2f2
        jsr $bfc2        ; get item
C38699:    JSR $8321      ; Compute index
C3869C:    LDX $2134      ; Load it
C3869F:    TDC            ; Terminator
C386A0:    STA $7E9E8D    ; Set mod B3
C386A4:    STA $7E9E8E    ; Set mod B4
C386A8:    REP #$20       ; 16-bit A
C386AA:    LDA #$8223     ; Tilemap ptr
C386AD:    STA $7E9E89    ; Set position
C386B1:    SEP #$20       ; 8-bit A
C386B3:    TDC            ; Clear A
C386B4:    LDA $D85010,X  ; Stat mods LB
C386B8:    PHA            ; Memorize them
C386B9:    AND #$0F       ; Vigor index
C386BB:    ASL A          ; Double it
C386BC:    JSR $8836      ; Draw modifier
C386BF:    REP #$20       ; 16-bit A
C386C1:    LDA #$82a3     ; Tilemap ptr
C386C4:    STA $7E9E89    ; Set position
C386C8:    SEP #$20       ; 8-bit A
C386CA:    TDC            ; Clear A
C386CB:    PLA            ; Stat mods LB
C386CC:    AND #$F0       ; Speed index
C386CE:    LSR A          ; Put in b3-b6
C386CF:    LSR A          ; Put in b2-b5
C386D0:    LSR A          ; Put in b1-b4
C386D1:    JSR $8836      ; Draw modifier
C386D4:    REP #$20       ; 16-bit A
C386D6:    LDA #$8241     ; Tilemap ptr
C386D9:    STA $7E9E89    ; Set position
C386DD:    SEP #$20       ; 8-bit A
C386DF:    LDX $2134      ; Item index
C386E2:    TDC            ; Clear A
C386E3:    LDA $D85011,X  ; Stats mods HB
C386E7:    PHA            ; Memorize them
C386E8:    AND #$0F       ; Stamina index
C386EA:    ASL A          ; Double it
C386EB:    JSR $8836      ; Draw modifier
C386EE:    REP #$20       ; 16-bit A
C386F0:    LDA #$82c1     ; Tilemap ptr
C386F3:    STA $7E9E89    ; Set position
C386F7:    SEP #$20       ; 8-bit A
C386F9:    TDC            ; Clear A
C386FA:    PLA            ; Stat mods HB
C386FB:    AND #$F0       ; Mag.Pwr index
C386FD:    LSR A          ; Put in b3-b6
C386FE:    LSR A          ; Put in b2-b5
C386FF:    LSR A          ; Put in b1-b4
C38700:    JSR $8836      ; Draw modifier
;draw defensive properties
C38703:    LDX $2134      ; Item index
C38706:    LDA $D85000,X  ; Properties
C3870A:    AND #$07       ; Get class
        beq not_weapon    ; branch if tool
C3870C:    CMP #$01       ; Weapon?
C3870E:    BEQ is_weapon    ; Branch if so
        cmp #$06        ; item?
        beq not_weapon    ; branch if so
C38710:    LDA $D85014,X  ; Defense
C38714:    JSR $04E0      ; Turn into text
C38717:    LDX #$83a1     ; Text position
C3871A:    JSR $04C0      ; Draw 3 digits
C3871D:    LDX $2134      ; Item index
C38720:    LDA $D85015,X  ; Mag.Def
C38724:    JSR $04E0      ; Turn into text
C38727:    LDX #$83bf     ; Text position
C3872A:    JSR $04C0      ; Draw 3 digits
        ldy #bat_pow_dash
        jsr $02f9
        ldx $2134        ; item index
        lda $d85000,x    ; properties
        and #$07
        cmp #$01
        bne not_weapon
C3868E:    LDA #$20       ; Palette 0
C38690:    STA $29        ; Color: User's
C387AB:    CMP #$51       ; Dice?
C387AD:    BEQ hide_bpow      ; Hide if so
        ldx $2134
C387B3:    LDA $D85014,X  ; Bat.Pwr
C387B7:    JSR $04E0      ; Turn into text
C387BA:    LDX #$813f        ; Text position
C387BD:    JSR $04C0      ; Draw 3 digits
        ldy #def_dash
        jsr $02f9
        ldy #mdef_dash
        jsr $02f9
        bra not_weapon

        LDY #wpn_unknown     ; Text pointer
C387C3:    JSR $02F9      ; Draw "???"
        jsr all_dashes
C387EB:    REP #$20       ; 16-bit A
C387ED:    LDA #$8321     ; Tilemap ptr
C387F0:    STA $7E9E89    ; Set position
C387F4:    SEP #$20       ; 8-bit A
C387F6:    LDX $2134      ; Item index
C387F9:    TDC            ; Clear A
C387FA:    LDA $D8501A,X  ; Evasion mods
C387FE:    PHA            ; Memorize them
C387FF:    AND #$0F       ; Evade index
C38801:    ASL A          ; x2
C38802:    ASL A          ; x4
C38803:    JSR $881A      ; Draw modifier
C38806:    REP #$20       ; 16-bit A
C38808:    LDA #$833f     ; Tilemap ptr
C3880B:    STA $7E9E89    ; Set position
C3880F:    SEP #$20       ; 8-bit A
C38811:    LDX $2134      ; Item index
C38814:    TDC            ; Clear A
C38815:    PLA            ; Evasion mods
C38816:    AND #$F0       ; MBlock index
C38818:    LSR A          ;
C38819:    LSR A          ;
C3881A:    TAX            ; Index it
C3881B:    LDA $C38854,X  ; Sign
C3881F:    STA $7E9E8B    ; Add to string
C38823:    LDA $C38855,X  ; Tens digit
C38827:    STA $7E9E8C    ; Add to string
C3882B:    LDA $C38856,X  ; Ones digit
C3882F:    STA $7E9E8D    ; Add to string
C38833:    JSR $8847      ; Draw modifier

; name and cleanup
        REP #$20
        lda #$810d        ; tilemap ptr
        sta $7e9e89
        SEP #$20        
        jsr $bfc2        ; get item
        jsr $c068        ; load item name
        jsr $7fd9
        jsr $bc92

        ldx $2134
        lda $d85000,x
        and #$07
        cmp #$06
        bne skip_all_dashes
        ldy #bat_pow_dash
        jsr $02f9
        ldy #def_dash
        jsr $02f9
        ldy #mdef_dash
        jsr $02f9
        lda $02
        cmp $4B
        bne gear_desc_end
        jsr gear_desc2    ; build description tilemap for shop menu
        jsr $b4e6        ; set description flags
        jsr $b4ef        ; load item description for buy menu
        lda $4b
        sta $02
C3A6F4:    LDX #$7849     ; Base: 7E/7849
C3A6F7:    STX $EB        ; Set map ptr LBs
C3A6F9:    LDA #$7E       ; Bank: 7E
C3A6FB:    STA $ED        ; Set ptr HB
C3A6FD:    LDY #$0CBC     ; Ends at 30,19
C3A700:    STY $E7        ; Set row's limit
C3A702:    LDY #$0C84     ; Starts at 3,19
C3A705:    LDX #$3500     ; Tile 256, pal 5
C3A708:    STX $E0        ; Priority enabled
C3A70A:    JSR $A783      ; Do line 1, row 1
C3A70D:    LDY #$0CFC     ; Ends at 30,20
C3A710:    STY $E7        ; Set row's limit
C3A712:    LDY #$0CC4     ; Starts at 3,20
C3A715:    LDX #$3501     ; Tile 257, pal 5
C3A718:    STX $E0        ; Priority enabled
C3A71A:    JSR $A783      ; Do line 1, row 2
C3A71D:    LDY #$0D3C     ; Ends at 30,21
C3A720:    STY $E7        ; Set row's limit
C3A722:    LDY #$0D04     ; Starts at 3,21
C3A725:    LDX #$3538     ; Tile 312, pal 5
C3A728:    STX $E0        ; Priority enabled
C3A72A:    JSR $A783      ; Do line 2, row 1
C3A72D:    LDY #$0D7C     ; Ends at 30,22
C3A730:    STY $E7        ; Set row's limit
C3A732:    LDY #$0D44     ; Starts at 3,22
C3A735:    LDX #$3539     ; Tile 313, pal 5
C3A738:    STX $E0        ; Priority enabled
C3A73A:    JMP $A783      ; Do line 2, row 2

        dw $791f : db "Hold Y for details.",$00
        dw $820d : db "Vigor",$00 ; +12 = $821f
        dw $828d : db "Speed",$00 ; +12 = $829f
        dw $822b : db "Stamina",$00 ; +12 = $823d
        dw $82ab : db "Magic",$00 ; +12 = $82bd
        dw $838d : db "Defense",$00 ; +12 = $819f
        dw $83ab : db "M.Def.",$00 ; +12 = $81bd
        dw $830d : db "Evade",$00 ; +12 = $831f
        dw $832b : db "M.Evade",$00 ; +12 = $833f
        dw $812b : db "B.Power",$00 ; + 12 = $813d
        dw $813f : db "???",$00
        dw $813f : db "---",$00
        dw $83a1 : db "---",$00
        dw $83bf : db "---",$00
        dw $7B8D : db "Resist:",$00
        dw $7C0D : db "Absorb:",$00
        dw $7C8D : db "Nullify:",$00
        dw $7D0D : db "Weakness:",$00

;Window layout data
dw $718B : db $1C,$06
dw $750B : db $1C,$06
dw $708B : db $1C,$02
dw $738B : db $1c,$04


Share this post

Link to post
Share on other sites

"spell dot" hack. BTB supposedly has the dots drawn in the VWF area. make sure you draw in a space as well, or it'll look crunched.



org $c1602e
    nop #3
org $c16031
    lda $e6f567,x


Share this post

Link to post
Share on other sites

Random encounter mod - DONE

EDIT: updated to fix a bug with formation odds.


;Random encounters mod for BNW
;v4 - no longer screws up formation odds
;v3 - re-jiggered some numbers courtesy of nowea
;v2 - should actually work now 
;Should raise the minimum number of steps for a random encounter to 10, while still maintaining the overall rate

!freespaceC2 = $C2FBF0
!freespaceC0 = $C0FF90

; Overworld and Town/Dungeon encounters
org $C0C48C
LDA #$E9      ; 233
JSR longCall
ADC #$04      ; Random 4..236

org !freespaceC0
JSL c2rand  ; Random 0..232

org !freespaceC2
JSR $4B65


Edited by seibaby

Share this post

Link to post
Share on other sites

Reflect timer - DONE

	; Disable Reflect timer and randomly remove Reflect when triggered
; by Seibaby (2018-12-01)
!freespace = $C2AEA9    ; Requires 9 bytes of free space in C2
	; The hook offset for the new code depends on whether you have Terii's
; Vanish/Doom patch applied or not.
;!hook = $C22248         ; Vanilla
!hook = $C22256         ; Vanish/Doom patch applied
	; Disable Reflect timer
org $C2469B
nothing: RTS
	org $C246DE
      dw nothing        ; Action when setting Rflect
	; Hook Hit Determination to call new code
org !hook
JMP remove_reflect      ; Make attack miss if reflecting
	; The purpose of the following modifications are to make room for the
; new code. The Reflect timer is no longer used, so it's safe to remove
; both the code that sets the timer, and the code that checks whether it
; has run out. This frees up enough space for the new code.
	; This new code replaces the code that set the Reflect timer (10 bytes)
org $C24687
         SEP #$20       ; 8-bit A
         JSR $4B5A      ; RNG: 0..255
         CMP #$55       ; 1 in 3 chance to clear Rflect status
         JMP remove_reflect2  ; (continued...)
	; The following code handles timers and status removal upon expiry.
; The code that handled the Reflect timer was removed, and the second part
; of the new code was inserted at the end of the function.
org $C25AE9
	org $C25B06
C25B06:                 ; (Code relevant to the Reflect timer was
                        ;  removed from the start of this block)
         STA $B8
         LDA $3F0D,X    ; Time until Freeze wears off
         BEQ .sleep     ; Branch if timer not active
         DEC $3F0D,X    ; Decrement Freeze timer
         BNE .sleep
         LDA #$04
         TSB $B8        ; If Freeze timer reached 0 on this tick,
                        ; Set to remove Freeze
.sleep   LDA $3CF9,X    ; Time until Sleep wears off
         BEQ .end       ; Branch if timer not active
         DEC $3CF9,X    ; Decrement Sleep timer
         BNE .end
         LDA #$08
         TSB $B8        ; If Sleep timer reached 0 on this tick,
                        ; Set to remove Sleep
.end     LDA $B8
         BEQ exit       ; Exit if we haven't marked any of the
                        ; Statuses to be auto-removed
         LDA #$29
         JMP $4E91      ; Queue the status removal
	; New code (continued)
; Replaces the code that handled the Reflect timer (14 bytes)
         BCS .end       ; Exit 2/3 times
         LDA $3330,Y    ; Blocked status 3
         BPL .end       ; No removal if permanent Reflect
         JSR remove_reflect3
.end     JMP $22E5      ; Make attack miss
         NOP            ; (Padding)
	; The space freed up by excising the Reflect timer isn't enough to
; handle the message boxes, so here's dipping into free space.
org !freespace
reset bytes
         LDA $3E10,Y    ; Status to clear 3
         ORA #$80       ; Bit 7 = Rflect
         STA $3E10,Y    ; Mark Rflect to be cleared
print bytes," bytes added"


Share this post

Link to post
Share on other sites

Quake/Vanish fix - DONE

; Quake removes Clear status even when missing Floating targets fix
; Version 1.0
; by Seibaby

;xkas 0.06
!freespace = $C2xxxx

; Spell Effect Pointer $25: Quake (Once-per-strike)
org $C2432B
dw groundBased

; Untarget Floating targets, except if all targets are Floating
org !freespace
reset bytes
        REP #$20          ; Set 16-bit Accumulator
        LDA $A2
        STA $EE           ; Copy targets to temporary variable
        LDX #$12
.loop   LDA $3EF8,X       ; Current status byte 3-4
        BPL .next         ; Check next target if this one is not floating
        LDA $3018,X
        TRB $EE           ; Clear this monster from potential targets
.next   DEX
        BPL .loop         ; Loop for all 10 targets
        LDA $EE
        BNE .save         ; Branch if any target(s) left
        LDA #$0080
        TRB $B3           ; No targets valid, so set Ignore Clear
        LDA $A2           ; Else, use original Targets
.save   STA $B8           ; save target(s)
        JMP $57C2
print bytes

Edited by seibaby

Share this post

Link to post
Share on other sites

Elemental fixing - DONE 


;xkas 0.06
!freespace = $C0FD40 ;patch to this offset
; change to 2/3 and resist at 1 null at 3

org $C20B9D
JML newfunc2

org $C20BD3
LDA $11A1
BEQ done
LDA $3BCC,Y ;(Absorbed elements)
BIT $11A1
BEQ nullstart   ;(branch if none are used in attack)
EOR #$01
STA $F2     ;(toggle healing flag)
BRA done
PHX ; 17 bytes so far
LDX #$00
LDA $3BCD,Y ;(Nullified elements)
AND $11A1
BEQ resiststart   ;(branch if none are used in attack or left to check)
BCC null ;(move to next ele if this one isn't nulled)
BRA null ;(counted this nulled element, 34 bytes so far)
LDA $3BE1,Y ;(Resisted elements)
AND $11A1
BEQ weakstart   ;(branch if none are used in attack or left to check)
BCC resist ;(move to next ele if this one isn't resisted)
BRA resist ;(counted this resisted element, 48 bytes)
LDA $3BE0,Y ;(Weak elements)
AND $11A1
BEQ damage   ;(branch if none are used in attack or left to check)
BCC weak ;(move to next ele if this one isn't weak)
BRA weak ;(counted this weak element, 62 bytes)
JSL newfunc
LDA $11A9 ;  (get attack special effect, 69 (nice) bytes)
CMP #$04
BNE skip ;  (Branch if not Atma Weapon)
JSR $0E39 ;  (Atma Weapon damage modification)

org !freespace
PHY ; (stack is y)
LDY #$00
LDA $11A1
BEQ continue   ;(no eles left, 8 bytes)
BCC elecount ;(this ele isn't used)
INY ; (12 bytes so far)
BRA elecount
BPL proper ; if it's negative, we're takin double
BRA done2
TYA ; at this point, A is the element count, X is the resistance total. We are gonna do some bullshit
CMP #$02 ; compare to 2, carry is set if element count >= 2
BCC elehandled
TXA ; A and X are resistance totals now
TAX ; finished manipulating
TXA ; :^) 21 bytes
CMP #$03 ; if >= 2, we're blocking
BCC resistcheck
STZ $F1 ; 35
CMP #$02 ; if == 1, we resist
BNE done2

BMI petrified
JML returnfromnewfunc2
JML done

Share this post

Link to post
Share on other sites

GrayShadow's inventory item count removal

C3/82F1:    200883      JSR $8308      ; Set desc ptrs
C3/82F4:    7B          TDC            ; Clear A
C3/82F5:    A54B        LDA $4B        ; Cursor slot
C3/82F7:    A8          TAY            ; Index it
C3/82F8:    B96918      LDA $1869,Y    ; Item in slot
C3/82FB:    203857      JSR $5738      ; Load description
C3/82FE:    205683      JSR $8356      ; Count items
C3/8301:    A920        LDA #$20       ; Palette 0
C3/8303:    8529        STA $29        ; Color: User's
C3/8305:    4C7A83      JMP $837A      ; Draw item count

HACK: Change the JSR at /82FB to a JMP.

Share this post

Link to post
Share on other sites

Modified Pincer/Side/Back attack probabilities - DONE

; Probabilities for Side/Pincer/Back/Normal attacks
org $C25279
db $20    ; Side attack (32/255)
db $20    ; Pincer (32/255)
db $20    ; Back attack (32/255)
db $9B    ; Normal (155/255)

Share this post

Link to post
Share on other sites

@Synchysi @seibabyBe aware, that patch I posted (which is linked in the first post of this thread) does NOT work in BNW, only on vanilla. I couldn't get the patch to work for BNW. Synchsi has to move event 0 in WoR Mobliz to tile (15,20) and event 1 to tile (28,16).

Share this post

Link to post
Share on other sites

Fix for Quartrstaff and Doomstick:


org $c2381d
    jsl targetting
org $c4b9d0
    lda #$02                ; auto-crit
    bit $b3                    ; check if true
    bne end                    ; ignore if not
    lda $b6                    ; spell #
    cmp #$17                ; is it quartr?
    beq change_q            ; branch if so
    cmp #$0d                ; is it doom?
    beq change_d            ; branch if so
    lda #$40                ; original targetting values
    sta $bb                    ; targetting RAM
    lda #$12
    sta $b6
    lda #$6e                ; change targetting
    sta $bb                    ; targetting RAM
    lda #$40                ; set to randomize (why? this shouldn't be necessary. shitty code.)
    tsb $ba                    ; apply
    stz $11a9
    stz $341a

Share this post

Link to post
Share on other sites

Status aura cycling code; this still has a delay between cycles, which is annoying. if anybody can sort that out, it'd be appreciated. aside from that though, it seems to work fine.

hirom  ; don't change this

org $C12E4F  ; location in v1.0
C12E4F:    BRA reset_rotation ; $2B

org $C12E5C  ; location in v1.0
C12E5C:    BRA reset_rotation ; $1E

org $C12E69  ; location in v1.0
C12E69:    BRA reset_rotation ; $11

C12E6B:    LDA $2EA9,Y  ; get current outline rotation

C12E6E:    BIT $38  ; check against current status
C12E70:    BNE set_colour  ; branch if a match was found
C12E72:    LSR A  ; check next status
C12E73:    ADC #$00  ; maintain wait bit
C12E75:    STA $2EA9,Y  ; update outline colour rotation
C12E78:    CMP #$20  ; loop over 6 statuses
C12E7A:    BCS main_loop

C12E7C:    LDA #$80  ; no match found, reset to Rflect

C12E7E:    STA $2EA9,Y
C12E81:    RTS

C12E82:    AND #$E0  ; clear wait bit
C12E84:    JSR $1A0F  ; v1.0 or v1.1
C12E87:    LDA.l outline_color_table,X  ; get outline colour
C12E8B:    BRA outline_control  ; implement

DB $04  ; Slow
DB $03  ; Haste
DB $07  ; Stop
DB $02  ; Shell
DB $01  ; Safe
DB $00  ; Rflect

C12E93:    LDA $2EA9,Y  ; current outline colour rotation

C12E96:    LSR A  ; move one step forward
C12E97: BCS reset_rotation  ; if wait bit set, clear it, reset and exit
C12E99:    AND #$FC  ; keep 6 bits
C12E9B:    BEQ reset_rotation  ; if all cleared, reset and exit

C12E9D:    BIT $38  ; check current status
C12E9F:    BEQ rotation_loop  ; loop until match found
C12EA1:    BRA update_rotation  ; update outline rotation

C12EA3:    NOP
C12EA4:    NOP
C12EA5:    NOP
C12EA6:    NOP
C12EA7:    NOP
C12EA8:    NOP
C12EA9:    NOP
C12EAA:    NOP
C12EAB:    NOP
C12EAC:    NOP
C12EAD:    NOP
C12EAE:    NOP
C12EAF:    NOP
C12EB0:    NOP
C12EB1:    NOP
C12EB2:    NOP

C12EB4:    RTS

org $C12EC3  ; location in v1.0
C12EC3:    PHA
C12EC4:    LDA $0E
C12EC6:    STA $2C
C12EC8:    PLA
C12EC9:    PHA
C12ECA:    LDA $2C
C12ECC:    AND #$03
C12ECE:    TAX
C12ECF:    LDA.l $C2E3AA,X  ; v1.0 or v1.1
C12ED3:    CLC
C12ED4:    ADC $2C
C12ED6:    STA $36
C12ED8:    AND #$3C
C12EDA:    LSR A
C12EDB:    STA $2C
C12EDD:    STZ $2D
    LDA $36
    ASL A
    ASL A
    BCC colour_transition
    LDA #$1F
    SBC $2C
    STA $2C

    LDA $2C
    CMP #$1F
    BNE continue_control
    JSR rotate_outline
    BRA continue_control

org $C13043
    LDA $2EBF,x

org $C1FFE5
    NOP #7

org $C2307D  ; location in v1.0 or v1.1
C2307D:    PHX  ; preserve party member index
C2307E:    LDA $FE  ; get row
C23080:    STA $3AA1,X  ; save to special properties
C23083:    LDA $3ED9,X  ; preserve special sprite
C23086:    PHA
C23087:    LDA $05,S  ; get loop variable
C23089:    STA $3ED9,X  ; save to roster position
C2308C:    TDC
C2308D:    TXA
C2308E:    ASL A
C2308F:    ASL A
C23090:    ASL A
C23091:    ASL A
C23092:    TAX
C23093:    LDA #$06  ; 7-iteration loop
C23095:    STA $FE  ; initialize loop counter
C23097:    PHY  ; preserve Y-loop index

C23098:    LDA $1601,Y  ; get normal sprite & name characters

C2309B:    STA $2EAE,X  ; store to display variables
REPLACE3:  ; mass replacement, nothing after this
C2309E:    INX
C2309F:    INY
C230A0:    DEC $FE
C230A2:    BPL display_init_loop
C230A4:    PLY  ; restore Y-loop index
C230A5:    PLA  ; restore special sprite
C230A6:    CMP #$FF  ; is special sprite null?
C230A8: BEQ init_outline_rotation  ; if not...
C230AA:    STA $2EA7,X  ; ...overwrite sprite

C230AD:    LDA #$81  ; Rflect status, wait bit
C230AF:    STA $2EA2,X  ; initialize outline rotation
C230B2:    LDA $03,S  ; get character ID
C230B4:    STA $2EBF,X  ; save it
C230B7:    CMP #$0E  ; is it Banon or higher?
C230B9:    REP #$20  ; 16-bit A
C230BB:    TAX  ; move to X

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