Users browsing this thread: 1 Guest(s)
Restrict Espers by Character
04-05-2018, 03:06 AM
I modified this patch to use quite a bit less space. It uses a bitmask for which characters equip espers similar to way the equipment does, instead of a bunch of jump tables.
Code:
hirom ; Don't change this.
header ; Comment out if your ROM has no header.
; Restricts espers to be equippable only by certain characters set in the tables at the bottom.
; All locations have only been tested in FF3us ROM version 1.0, although it should work in version 1.1.
; This will likely not work in the Japanese version.
; Uses 138 bytes of free space at the end of bank C3.
; Address range utilized: C3/F091 to C3/F11A
; Loads the skills menu and gets the character ID. We interrupt this routine in order
; to store the character ID in $1CF8 (formerly Bushido names in the Japanese version;
; unused in FF3us).
; This is why it likely won't work in FF3j, although I suppose you could just find
; another unused location.
org $C31B61
JSR StChr
; Checks if any espers are already equipped. We come here just to create a label for
; ease of use and readability.
org $C35576
ChkEq:
; Sets text color to blue. This block is only executed if the esper is in question is
; already equipped by someone else.
org $C35593
LDA #$2C ; #$2C for grey text with a blue shadow/#$24 for blue
; Sets text color of the current esper to be printed. As above, we only come here to
; create a label. If an esper can't be equipped because a character can't use it, the
; text will be gray. If an esper can't be equipped because someone else already has it,
; the text will be blue. Otherwise, it'll be white.
; The game will later use the text color to determine whether to allow a character to
; use a particular esper.
org $C35595
SetTxtColor:
; This prints out the name of the person currently using the esper you're trying to
; equip, which was originally the only thing stopping someone from equipping a certain
; esper. We need to change this, as the name will be blank if the character simply
; can't equip it.
org $C355B2
JSR Uneq
; The following lines originally jumped to the subroutine for checking if espers were
; already equipped (C3/5574). This check obviously isn't necessary if the character is
; unable to equip the esper anyway.
org $C35524
JSR ChkEsp
org $C358E1
JSR ChkEsp
org $C359B1
JSR ChkEsp
; Checks if the text color is gray, and BZZTs the character if it is. Since we're also
; using blue to indicate an unequippable esper, we'll simply change the comparison from
; "if not gray, branch" to "if white, branch"
org $C358E8
CMP #$20
BEQ WhiteTxt
; Actions to perform if selecting anything in white text. We come here only to make
; a label
org $C35902
WhiteTxt:
; Custom functions follow.
org $C3F091 ; Start of free space in bank C3.
StChr: ; Gets the ID of the current character and stores it for later use.
TAX
LDA $69,X
STA $1CF8
RTS
ChkEsp: ; Checks if a character can use an esper before checking if someone else has it equipped.
PHX ; Preserve X. May or may not be necessary, but better safe than sorry.
PHP
STA $E0 ; Stores the esper ID for later use. Could use the stack, but the esper ID needs to go into $E0 anyway.
ASL
TAX
REP #$20
LDA EsperTable,X ; Get esper equip bitmask
SEP #$10
LDX $1CF8 ; Character ID, from above.
AND $C39C67,X ; AND with 2^X
BEQ NoEq
Eq:
PLP
PLX
JMP ChkEq
NoEq:
PLP
PLX
LDA #$28 ; Grey text color
JMP SetTxtColor
; Handles error messages in the case of trying to equip a grey esper.
Uneq:
LDA $1602,X ; Character's name.
CMP #$80 ; If the first letter isn't blank, then someone has the esper equipped and we can go back to tell the player as much.
BCS Exit
PLX ; Else, the character can't equip the esper at all and we need to tell the player as much.
LDX $00
; Above: PLX because we no longer need to RTS to where this subroutine was called from.
; Sloppy, I know. BCS alone (instead of branching to an RTS) won't work because the branch is just too long.
; I'm looking for a way to streamline it.
; LDX $00 because it's necessary anyway as a counter for the next block.
; The following is identical to the code that prints "<Char> has it!",
; just altered slightly so it reads "Can't equip!"
LoadNoEqTxt:
LDA NoEqTxt,X
BEQ Null ; If the character (letter) being written is null ($00), end the line.
STA $2180 ; Print the current letter.
INX ; Go to the next letter.
BRA LoadNoEqTxt
Exit:
RTS
Null:
STZ $2180 ; End this string.
JMP $7FD9
; "Can't equip!" text.
NoEqTxt:
DB $82,$9A,$A7,$C3,$AD,$FF,$9E,$AA,$AE,$A2,$A9,$BE,$00
; Esper equip table.
; Bitmask for which characters can equip the esper
; $0001 = Terra can equip
; $0002 = Locke
; $0004 = Cyan
; $0008 = Shadow
; $0010 = Edgar
; $0020 = Sabin
; $0040 = Celes
; $0080 = Strago
; $0100 = Relm
; $0200 = Setzer
; $0400 = Mog
; $0800 = Gau
; $1000 = Gogo
; $2000 = Umaro
; Logical OR them together to let multiple characters equip
; So $0030 = Figaro bros only
; $0141 = girls only
; $3fff = all 14 chars
; etc.
EsperTable:
DW $0000 ; Ramuh
DW $0000 ; Ifrit
DW $0000 ; Shiva
DW $0000 ; Siren
DW $0000 ; Terrato
DW $0000 ; Shoat
DW $0000 ; Maduin
DW $0000 ; Bismark
DW $0000 ; Stray
DW $0000 ; Palidor
DW $0000 ; Tritoch
DW $0000 ; Odin
DW $0000 ; Raiden
DW $0000 ; Bahamut
DW $0000 ; Alexander
DW $0000 ; Crusader
DW $0000 ; Ragnarok
DW $0000 ; Kirin
DW $0000 ; ZoneSeek
DW $0000 ; Carbunkle
DW $0000 ; Phantom
DW $0000 ; sraphim
DW $0000 ; Golem
DW $0000 ; Unicorn
DW $0000 ; Fenrir
DW $0000 ; Starlet
DW $0000 ; Phoenix
; EOF
The following 5 users say Thank You to Subtraction for this post:
• madsiur (04-05-2018), Robo Jesus (04-05-2018), seibaby (04-05-2018), Turbotastic (04-05-2018), Warrax (04-06-2018)
• madsiur (04-05-2018), Robo Jesus (04-05-2018), seibaby (04-05-2018), Turbotastic (04-05-2018), Warrax (04-06-2018)
« Next Oldest | Next Newest »
Users browsing this thread: 1 Guest(s)