This is a new block of code I placed at C3/FF99 near the end of the big block of free space right before the new pointer table I made for the new command loading procedure.
I changed the old check for Mimic that prevented it from being loaded into a jump to the new code.
Also, $22A6 is a new subroutine in the optimized version of the code block labeled "One portion of Gogo's custom command setting in status menu
" at $2248.
When I optimized that section I noticed a significant portion of the original code was duplicated for no good reason that I could tell. So I moved to the end and made it into it's own sub-routine that has all the prep for getting the character ID.
You're right, though, the way it is crashes the game.
I stripped it down to just a jump to $FF99 and a jump back to where I left off and even that gives me a black screen.
I did think about the registers being in the wrong mode, but I didn't know much about it. Looking into it now.
I'm trying not to use a compiler at all in order to force myself to learn the opcodes, but I appreciate the suggestion.
I'm familiar with asar in the context of SMW hacking, but I ever used it for was to add certain patches or whatnot.
If I get tired of fumbling around I'll take your suggestion under advisement.
By chance do you know of any of the other bytes in $1DD1 are used and if so what for?
Also, do you think I can use $1DD1 to exclude the Magic command for most characters?
I can't remember if unlocking Morph coincides with Magic being available for all characters.
Here's all the code I've changed so far:
I changed the old check for Mimic that prevented it from being loaded into a jump to the new code.
Also, $22A6 is a new subroutine in the optimized version of the code block labeled "One portion of Gogo's custom command setting in status menu
" at $2248.
When I optimized that section I noticed a significant portion of the original code was duplicated for no good reason that I could tell. So I moved to the end and made it into it's own sub-routine that has all the prep for getting the character ID.
You're right, though, the way it is crashes the game.
I stripped it down to just a jump to $FF99 and a jump back to where I left off and even that gives me a black screen.
I did think about the registers being in the wrong mode, but I didn't know much about it. Looking into it now.
I'm trying not to use a compiler at all in order to force myself to learn the opcodes, but I appreciate the suggestion.
I'm familiar with asar in the context of SMW hacking, but I ever used it for was to add certain patches or whatnot.
If I get tired of fumbling around I'll take your suggestion under advisement.
By chance do you know of any of the other bytes in $1DD1 are used and if so what for?
Also, do you think I can use $1DD1 to exclude the Magic command for most characters?
I can't remember if unlocking Morph coincides with Magic being available for all characters.
Here's all the code I've changed so far:
Code:
DP $26 is #$0B - initiate the status screen
C3/1C46: 202F35 JSR $352F (from C3/01F1, turns off DMA and HDMA transfers, turns the screen off)
C3/1C49: 200B62 JSR $620B (do a DMA transfer)
C3/1C4C: 20055D JSR $5D05 (put status screen in VRAM?)
C3/1C4F: 205D1C JSR $1C5D [go to InitStat1]
C3/1C52: A901 LDA #$01
C3/1C54: 8526 STA $26 (transition process)
C3/1C56: A90C LDA #$0C
C3/1C58: 8527 STA $27 (queue up to execute at C3/21F5)
C3/1C5A: 4C4135 JMP $3541
InitStat1: C3/1C5D: 7B TDC
C3/1C5E: A528 LDA $28
C3/1C60: 0A ASL A
C3/1C61: AA TAX
C3/1C62: B46D LDY $6D,X
C3/1C64: B90000 LDA $0000,Y (load character ID)
C3/1C67: C90C CMP #$0C (Is this Gogo?)
//change this to determin which characters can display command edit finger pointer.
//C90D CMP #$0D This checks for Umaro and above.
//If Functional Umaro patch is used change the comparison to 0E which is Bannon.
C3/1C69: D00D BNE $1C78 (branch if not)
//change this to determin which characters can display command edit finger pointer.
//B00D BCS $1C78 This should branch if the character is higher than Gogo.
C3/1C6B: 20FF36 JSR $36FF (get hotspot data)
C3/1C6E: 200837 JSR $3708 (set finger positioning)
C3/1C71: A906 LDA #$06
C3/1C73: 0446 TSB $46
C3/1C75: 4CB007 JMP $07B0 (finger OAM initiating)
C3/1C78: A906 LDA #$06
C3/1C7A: 1446 TRB $46
C3/1C7C: 60 RTS
DP $26 is #$0C - sustain the status screen
C3/21F5: 20390F JSR addr $0F39 [Jump to Subroutine: Absolute, go to Unknown1] (from C3/01F3)
C3/21F8: A508 LDA dp $08 [Load Accumulator from Memory: Direct Page]
C3/21FA: 8910 BIT #const #$10 [Test Bits: Immediate] (are you pressing L?)
C3/21FC: F014 BEQ nearlabel $2212 [Branch if Equal: Program Counter Relative, go to Branch1]
C3/21FE: A528 LDA dp $28 [Load Accumulator from Memory: Direct Page]
C3/2200: 8579 STA dp $79 [Store Accumulator to Memory: Direct Page]
Loop1: C3/2202: 7B TDC -- [Transfer Direct Page Register to 16-bit Accumulator]
C3/2203: A528 LDA dp $28 [Load Accumulator from Memory: Direct Page]
C3/2205: 1A INC A [Increment Accumulator]
C3/2206: 2903 AND #const #$03 [AND Accumulator with Memory]
C3/2208: 8528 STA dp $28 [Store Accumulator to Memory: Direct Page]
C3/220A: AA TAX -- [Transfer Accumulator to Index Register X]
C3/220B: B569 LDA dp,X $69,X [Load Accumulator from Memory: DP Indexed,X]
C3/220D: 30F3 BMI nearlabel $2202 [Branch if Minus: Program Counter Relative, go to Loop1]
C3/220F: 4C2922 JMP addr $2229 [Jump: Absolute, go to Skip1]
Branch1: C3/2212: A508 LDA dp $08 [Load Accumulator from Memory: Direct Page] (A already holds the contents of $08)
C3/2214: 8920 BIT #const #$20 [Test Bits: Immediate] (are you pressing R?)
C3/2216: F020 BEQ nearlabel $2238 [Branch if Equal: Program Counter Relative, go to Skip2]
C3/2218: A528 LDA dp $28 [Load Accumulator from Memory: Direct Page]
C3/221A: 8579 STA dp $79 [Store Accumulator to Memory: Direct Page]
Loop2: C3/221C: 7B TDC -- [Transfer Direct Page Register to 16-bit Accumulator]
C3/221D: A528 LDA dp $28 [Load Accumulator from Memory: Direct Page]
C3/221F: 3A DEC A [Decrement Accumulator]
C3/2220: 2903 AND #const #$03 [AND Accumulator with Memory: Immediate]
C3/2222: 8528 STA dp $28 [Store Accumulator to Memory: Direct Page]
C3/2224: AA TAX -- [Transfer Accumulator to Index Register X]
C3/2225: B569 LDA dp,X $69,X [Load Accumulator from Memory: DP Indexed,X]
C3/2227: 30F3 BMI nearlabel $221C [Branch if Minus: Program Counter Relative, go to Loop2]
Skip1: C3/2229: A528 LDA dp $28 [Load Accumulator from Memory: Direct Page]
C3/222B: C579 CMP dp $79 [Compare Accumulator with Memory: Direct Page]
C3/222D: F003 BEQ nearlabel $2232 [Branch if Equal: Program Counter Relative, go to Skip3]
C3/222F: 20A30E JSR addr $0EA3 [Jump to Subroutine: Absolute, go to Unknown2] //has to do with playing a sound.
Skip3: C3/2232: 205D1C JSR addr $1C5D [Jump to Subroutine: Absolute, go to InitStat1]
C3/2235: 4C835D JMP addr $5D83 [Jump: Absolute, go to $5D83]
Skip2: C3/2238: A509 LDA dp $09 [Load Accumulator from Memory: Direct Page] (from C3/2222)
C3/223A: 8980 BIT #const #$80 [Test Bits: Immediate] (did you press B?)
C3/223C: F00A BEQ nearlabel $2248 [Branch if Equal: Program Counter Relative, go to Gogo]
C3/223E: 20A90E JSR addr $0EA9 [Jump to Subroutine: Absolute, go to Unknown3] //has to do with playing a sound. (should it be 0EA3 instead?)
C3/2241: A904 LDA #const #$04 [Load Accumulator from Memory: Immediate]
C3/2243: 8527 STA dp $27 [Store Accumulator to Memory: Direct Page] (init the main menu, queue up to execute at C3/1A8A)
C3/2245: 6426 STZ dp $26 [Store Zero to Memory: Direct Page] (fade out)
C3/2247: 60 RTS
One portion of Gogo's custom command setting in status menu
Gogo: C3/2248: 20A622 JSR addr $22A6 [Jump to Subroutine: Absolute, go to GSub1] (from C3/223C)
C3/224B: B90000 LDA addr,Y $0000,Y [Load Accumulator from Memory: Absolute Indexed,Y] (get character ID)
C3/224E: C90D CMP #const #$0D [Compare Accumulator with Memory: Immediate] (is character Guest?)
C3/2250: B053 BCS nearlabel $22A5 [Branch if Carry Set: Program Counter Relative, go to GEnd] (branch if greater than or equal)
C3/2252: 200537 JSR addr $3705 [Jump to Subroutine: Absolute, go to Unknown4] (set finger positioning data for the four commands in status menu)
C3/2255: A508 LDA dp $08 [Load Accumulator from Memory: Direct Page]
C3/2257: 8980 BIT #const #$80 [Test Bits: Immediate] (did you press A?)
C3/2259: F04A BEQ nearlabel $22A5 [Branch if Equal: Program Counter Relative, go to GEnd]
C3/225B: A54B LDA dp $4B [Load Accumulator from Memory: Direct Page]
C3/225D: 85E7 STA dp $E7 [Store Accumulator to Memory: Direct Page]
C3/225F: 64E8 STZ dp $E8 [Store Zero to Memory: Direct Page]
C3/2261: 20A622 JSR addr $22A6 [Jump to Subroutine: Absolute, go to GSub1]
C3/2264: C220 REP #const #$20 [Reset Processor Status Bits: Immediate] (16 bit memory/accum.)
C3/2266: 98 TYA [Transfer Index Register Y to Accumulator: Implied]
C3/2267: 18 CLC [Clear Carry: Implied]
C3/2268: 65E7 ADC dp $E7 [Add with Carry: Direct Page]
C3/226A: A8 TAY [Transfer Accumulator to Index Register Y: Implied]
C3/226B: E220 SEP #$20 [Set Processor Status Bits: Immediate] (8 bit memory/accum.)
C3/226D: B91600 LDA addr,Y $0016,Y [Load Accumulator from Memory: Absolute Indexed,Y] (unmodified commands)
C3/2270: C912 CMP #const #$12 [Compare Accumulator with Memory: Immediate] (is command Mimic?)
C3/2272: F02B BEQ nearlabel $229F [Branch if Equal: Program Counter Relative, go to GBuzz] (branch to buzzer sound + RTS)
C3/2274: 20062F JSR addr $2F06 [Jump to Subroutine: Absolute, go to Unknown5]
C3/2277: A54E LDA dp $4E [Load Accumulator from Memory: Direct Page]
C3/2279: 855E STA dp $5E [Store Accumulator to Memory: Direct Page]
C3/227B: A54B LDA dp $4B [Load Accumulator from Memory: Direct Page]
C3/227D: 8564 STA dp $64 [Store Accumulator to Memory: Direct Page]
C3/227F: A906 LDA #const #$06 [Load Accumulator from Memory: Immediate]
C3/2281: 8520 STA dp $20 [Store Accumulator to Memory: Direct Page]
C3/2283: A00C00 LDY dp,X #$000C [Load Index Register Y from Memory: DP Indexed, X]
C3/2286: 849C STY dp $9C [Store Index Register Y to Memory: Direct Page]
C3/2288: A96A LDA #const #$6A [Load Accumulator from Memory: Immediate]
C3/228A: 8527 STA dp $27 [Store Accumulator to Memory: Direct Page] (queue up to execute at C3/63A7)
C3/228C: A965 LDA #const #$65 [Load Accumulator from Memory: Immediate]
C3/228E: 8526 STA dp $26 [Store Accumulator to Memory: Direct Page] (execute at C3/36E7)
C3/2290: 200364 JSR addr $6403 [Jump to Subroutine: Absolute, go to Unknown6]
C3/2293: AF899D7E LDA long $7E9D89 [Load Accumulator from Memory: Absolute Long]
C3/2297: 8554 STA dp $54 [Store Accumulator to Memory: Direct Page]
C3/2299: 20B20E JSR addr $0EB2 [Jump to Subroutine: Absolute, go to Click] (makes the click sound)
C3/229C: 4C0C64 JMP addr $640C [Jump: Absolute, go to Unknown7] (set finger positioning data for Gogo's customizable commands)
GBuzz: C3/229F: 20C00E JSR addr $0EC0 [Jump to Subroutine: Absolute, go to Buzzer] (makes the buzzer sound)
C3/22A2: 205D30 JSR addr $305D [Jump to Subroutine: Absolute, go to Mosaic] (triggers the mosaic effect)
GEnd: C3/22A5: 60 RTS
GSub1: C3/22A6: 7B TDC -- [Transfer Direct Page Register to 16-bit Accumulator] (prep data to get current character ID)
C3/22A7: A528 LDA dp $28 [Load Accumulator from Memory: Direct Page]
C3/22A9: 0A ASL A [Arithmetic Shift Left: Accumulator]
C3/22AA: AA TAX -- [Transfer Accumulator to Index Register X]
C3/22AB: B46D LDY dp,X $6D,X [Load Index Register Y from Memory: DP Indexed, X]
C3/22AD: 60 RTS
C3/22AE: A509 LDA dp $09 [Load Accumulator from Memory: Direct Page]
C3/22B0: 8980 BIT #const #$80 [Test Bits: Immediate] (did you press B?)
C3/22B2: D009 BNE nearlabel $22BD [Branch if Not Equal: Program Counter Relative, go to GEnd2]
C3/22B4: 20A90E JSR addr $0EA9 [Jump to Subroutine: Absolute, go to Unknown3]
C3/22B7: A904 LDA #const #$04 [Load Accumulator from Memory: Immediate]
C3/22B9: 8527 STA dp $27 [Store Accumulator to Memory: Direct Page] (init the main menu, queue up to execute at C3/1A8A)
C3/22BB: 6426 STZ dp $26 [Store Zero to Memory: Direct Page] (fade out)
GEnd2: C3/22BD: 60 RTS
C3/22BE: EAEAEAEA Free Space
C3/22C2: EAEAEA 7 Bytes
Code:
(Generate large command list for righthand side of Gogo's Status screen)
[35FC1]
C3/5DC1: A2 09 9E LDX #$9E09 (from C3/5D08)
C3/5DC4: 8E 81 21 STX $2181 (all writes to $2180 start at 7E/9E09)
C3/5DC7: 7B TDC (A = #$0000)
C3/5DC8: AA TAX (X = #$0000)
-------------------------------------------------------------------------------------------------------------------------
//This loop builds the command list
LP1:
C3/5DC9: DA PHX (save X)
C3/5DCA: C2 20 REP #$20 (16 bit memory/accum.)
C3/5DCC: 8A TXA
C3/5DCD: 0A ASL (* 2)
C3/5DCE: AA TAX
C3/5DCF: AD DC 1E LDA $1EDC
C3/5DD2: 3F 67 9C C3 AND $C39C67,X (do you have this character?)
C3/5DD6: F0 27 BEQ $5DFF (branch if not, BR1)
C3/5DD8: C2 20 REP #$20 (16 bit memory/accum.)
C3/5DDA: BF E0 FF C3 LDA $C3FFE0,X (Xth character's working ROM offset)
C3/5DDE: AA TAX
C3/5DDF: E2 20 SEP #$20 (8 bit memory/accum.)
C3/5DE1: BF A2 7C ED LDA $ED7CA2,X (default command 1)
C3/5DE5: 8D 80 21 STA $2180
C3/5DE9: BF A3 7C ED LDA $ED7CA3,X (default command 2)
C3/5DED: 8D 80 21 STA $2180
C3/5DF0: BF A4 7C ED LDA $ED7CA4,X (default command 3)
C3/5DF4: 8D 80 21 STA $2180
C3/5DF7: BF A5 7C ED LDA $ED7CA5,X (default command 4)
C3/5DFB: 8D 80 21 STA $2180
C3/5DFD: 80 10 BRA $5E0F (isolates null command entry for missing PCs, BR2)
BR1:
C3/5DFF: E2 20 SEP #$20 (8 bit memory/accum.)
C3/5E01: A9 FF LDA #$FF
C3/5E03: 8D 80 21 STA $2180
C3/5E06: 8D 80 21 STA $2180
C3/5E09: 8D 80 21 STA $2180
C3/5E0C: 8D 80 21 STA $2180 (four null commands)
BR2:
C3/5E0F: FA PLX (retrieve X)
C3/5E10: E8 INX
C3/5E11: E0 10 00 CPX #$0010 (iterate for all 16 character slots)
(so we're generating a 64-command list with every recruited character's raw command)
C3/5E14: D0 B3 BNE $5DC9 (loop back for next PC, LP1)
=========================================================================================================================
C3/5E16: 7B TDC (A = #$0000)
C3/5E17: AA TAX (X = #$0000)
-------------------------------------------------------------------------------------------------------------------------
//This loop replaces duplicates from the command list with null commands
LP3:
C3/5E18: DA PHX (save X)
C3/5E19: BF 09 9E 7E LDA $7E9E09,X (load command from one slot)
LP2:
C3/5E1D: DF 0A 9E 7E CMP $7E9E0A,X (compare to command from a later slot)
C3/5E21: D0 08 BNE $5E2B (branch if they didn't match, BR3)
C3/5E23: 48 PHA (save A)
C3/5E24: A9 FF LDA #$FF (load value for null command)
C3/5E26: 9F 0A 9E 7E STA $7E9E0A,X (if they did, replace second instance with a null command)
C3/5E2A: 68 PLA (retrieve A)
BR3:
C3/5E2B: E8 INX
C3/5E2C: E0 3F 00 CPX #$003F
C3/5E2F: D0 EC BNE $5E1D (this loop compares the command at position N to those at positions N+1 through 64 [zero-based], LP2)
C3/5E31: FA PLX (retrieve X)
C3/5E32: E8 INX
C3/5E33: E0 3F 00 CPX #$003F
C3/5E36: D0 E0 BNE $5E18 (this loop increments position N, LP3)
=========================================================================================================================
C3/5E38: A2 8A 9D LDX #$9D8A
C3/5E3B: 8E 81 21 STX $2181 (all writes to $2180 start at 7E/9D8A)
C3/5E3E: A9 FF LDA #$FF
C3/5E40: 7B TDC (A = #$0000)
C3/5E41: AA TAX (X = #$0000)
C3/5E42: A8 TAY (Y = #$0000)
-------------------------------------------------------------------------------------------------------------------------
//This loop removes duplicate commands and excludes certain others from the command list
LP4:
C3/5E43: 7B TDC (A = #$0000)
C3/5E44: DA PHX (save X)
C3/5E45: BF 09 9E 7E LDA $7E9E09,X (load command)
C3/5E49: 30 15 BMI $5E60 (branch if no command, BR4)
C3/5E4B: 4C 99 FF JMP $FF99 (go to new code at $FF99)
//Remove this branch in order to allow the Mimic command to be added to the command list.
//Replace with jump to new code: Check for Morph & Mimic, but skip Morph check if character is Terra & skip Mimic check if character is Gogo.
BR5:
C3/5E4E: 85 E0 STA $E0 (save A to RAM)
C3/5E50: 0A ASL (* 2)
C3/5E51: AA TAX
C3/5E52: BF 00 FE CF LDA $CFFE00,X (load command info)
C3/5E56: 29 01 AND #$01 (can Gogo use this command?)
C3/5E58: F0 06 BEQ $5E60 (branch if not, BR4)
//Kill this branch to allow all commands to be added to the list.
//The above code is used to add commands to the command list by checking against a table of usable commands.
//Replace with jump to new code: 2 routines that will do the original check for Gogo, and a separate one for all other characters.
C3/5E5A: A5 E0 LDA $E0 (load A from RAM)
C3/5E5C: 8D 80 21 STA $2180
C3/5E5F: C8 INY (increment valid command quantity)
BR4:
C3/5E60: FA PLX (retrieve X)
C3/5E61: E8 INX
C3/5E62: E0 40 00 CPX #$0040 (have we checked 64 commands yet?)
C3/5E65: D0 DC BNE $5E43 (loop if not, LP4)
=========================================================================================================================
C3/5E67: EA INY (add 1 to valid command quantity, for the initial blank slot)
C3/5E68: 98 TYA
C3/5E69: 8F 89 9D 7E STA $7E9D89 (save valid command quantity + 1)
C3/5E6D: A2 8D AA LDX #$AA8D
C3/5E70: 8E 81 21 STX $2181 (all writes to $2180 start at 7E/AA8D)
C3/5E73: 7B TDC (A = #$0000)
C3/5E74: AA TAX (X = #$0000)
C3/5E75: BF 85 5F C3 LDA $C35F85,X (window data for the command list)
C3/5E79: 8D 80 21 STA $2180
C3/5E7C: E8 INX
C3/5E7D: E0 08 00 CPX #$0008
C3/5E80: D0 F3 BNE $5E75 (iterate 8 times)
C3/5E82: A9 18 LDA #$18 (set command quantity to fixed amount)
C3/5E83: EA STA $E2
C3/5E85: EA CLC
C3/5E86: EA EA ADC $E2
C3/5E88: EA EA ADC $E2 (A = A * 3)
C3/5E8A: EA EA AND #$FE
C3/5E8C: EA EA BEQ $5E90
C3/5E8E: EA INC
C3/5E8F: EA INC
C3/5E90: EA LSR
C3/5E91: 8F 90 AA 7E STA $7EAA90
C3/5E95: 8F 94 AA 7E STA $7EAA94
C3/5E99: A0 8D AA LDY #$AA8D
C3/5E9C: A9 7E LDA #$7E
C3/5E9E: EA EA STA $E9 (JSR $0343 would save 2 bytes)
C3/5EA0: 20 43 03 JSR $0343 (draw a window, data at 7E/AA8D)
C3/5EA3: A0 91 AA LDY #$AA91
C3/5EA6: A9 7E LDA #$7E
C3/5EA8: EA EA STA $E9 (JSR $0343 would save 2 bytes)
C3/5EAA: 20 43 03 JSR $0343 (draw a window, data at 7E/AA91)
C3/5EAD: AF 89 9D 7E LDA $7E9D89
C3/5EB1: 85 E5 STA $E5 (copy command quantity)
C3/5EB3: 64 E6 STZ $E6
C3/5EB5: 7B TDC (A = #$0000)
C3/5EB6: AA TAX (X = #$0000)
C3/5EB7: A0 C9 80 LDY #$80C9 (set position in tilemap)
C3/5EBA: DA PHX (save X)
C3/5EBB: 5A PHY (save Y)
//Add code here to load current character's equipment data
C3/5EBC: BF 8A 9D 7E LDA $7E9D8A,X (get command ID)
C3/5EC0: 20 D7 5E JSR $5ED7 (output command name, blank if no command.
also check whether it's grayable.)
(the problem is, it's being grayed/whitened based
on the equipment data of whomever's Status screen
you last entered from the main menu, not
necessarily Gogo's.)
C3/5EC3: 7A PLY (retrieve Y)
C3/5EC4: C2 20 REP #$20 (16 bit memory/accum.)
C3/5EC6: 98 TYA
C3/5EC7: 18 CLC
C3/5EC8: 69 80 00 ADC #$0080 (2 lines down for next position in tilemap)
C3/5ECB: A8 TAY
C3/5ECC: E2 20 SEP #$20 (8 bit memory/accum.)
C3/5ECE: FA PLX (retrieve X)
C3/5ECF: E8 INX
C3/5ED0: E4 E5 CPX $E5
C3/5ED2: D0 E6 BNE $5EBA (iterate for command quantity # of entries)
C3/5ED4: 4C 50 5F JMP $5F50 (blank out Gogo's portrait for the command list.
no BRA?)
-----------------------------
(Outputs a command name or, if the command's unavailable, a string of blanks.
For SwdTech and Runic, it also decides whether the command will be lit up
or grayed based on weapons held.)
(4-command list on Status screen and when arranging "Short" layout on
Config screen: enter at C3/5EE1.
Long list on right of [Gogo's] Status screen: enter at C3/5ED7.)
C3/5ED7: 48 PHA
C3/5ED8: 20 19 35 JSR $3519
C3/5EDB: 68 PLA (restore command ID)
C3/5EDC: 30 2E BMI $5F0C (if it's null, go blank it)
C3/5EDE: 4C E6 5E JMP $5EE6 (skip blanking of command check, as caller already
determined it should be listed. no BRA?)
C3/5EE1: 20 2C 61 JSR $612C (Check for blanked commands)
C3/5EE4: 30 26 BMI $5F0C
C3/5EE6: 20 25 5F JSR $5F25 (Check for grayed out commands)
C3/5EE9: 85 E2 STA $E2 (save command #)
C3/5EEB: 48 PHA (ditto)
C3/5EEC: 0A ASL
C3/5EED: 0A ASL
C3/5EEE: 85 E0 STA $E0 (= command_num * 4)
C3/5EF0: 68 PLA
C3/5EF1: 0A ASL (= command_num * 2)
C3/5EF2: 18 CLC
C3/5EF3: 65 E0 ADC $E0 (= command_num * 6)
C3/5EF5: 65 E2 ADC $E2 (= command_num * 7)
C3/5EF7: AA TAX
C3/5EF8: A0 07 00 LDY #$0007 (Commands are 7 letters long)
C3/5EFB: BF A0 CE D8 LDA $D8CEA0,X (Load Xth letter of Battle Cmd. name)
C3/5EFF: 8D 80 21 STA $2180
C3/5F02: E8 INX
C3/5F03: 88 DEY
C3/5F04: D0 F5 BNE $5EFB
C3/5F06: 9C 80 21 STZ $2180 (zero-terminate the string)
C3/5F09: 4C D9 7F JMP $7FD9
c3/5F0C: A9 FF LDA #$FF
C3/5F0E: 8D 80 21 STA $2180
C3/5F11: 8D 80 21 STA $2180
C3/5F14: 8D 80 21 STA $2180
C3/5F17: 8D 80 21 STA $2180
C3/5F1A: 8D 80 21 STA $2180
C3/5F1D: 8D 80 21 STA $2180
C3/5F20: 8D 80 21 STA $2180 (output 7 null characters)
C3/5F23: 80 E1 BRA $5F06
(Precheck for Grayed out commands)
C3/5F25: 48 PHA
C3/5F26: C9 0B CMP #$0B (is it Runic?)
C3/5F28: F0 10 BEQ $5F3A
C3/5F2A: C9 07 CMP #$07 (is it SwdTech?)
C3/5F2C: F0 16 BEQ $5F44
C3/5F2E: A9 20 LDA #$20
C3/5F30: 85 29 STA $29 (set text color to white)
C3/5F32: 68 PLA
C3/5F33: 60 RTS
C3/5F34: A9 24 LDA #$24
C3/5F36: 85 29 STA $29 (set text color to gray)
C3/5F38: 68 PLA
C3/5F39: 60 RTS
(Gray out Runic command if no weapons have Runic ability)
C3/5F3A: AD DA 11 LDA $11DA
C3/5F3D: 0D DB 11 ORA $11DB (weapon properties, both hands)
C3/5F40: 10 F2 BPL $5F34 (branch if neither have bit 7 set)
C3/5F42: 80 EA BRA $5F2E
(Gray out SwdTech command if no weapons have SwdTech ability)
C3/5F44: AD DA 11 LDA $11DA
C3/5F47: 0D DB 11 ORA $11DB (weapon properties, both hands)
C3/5F4A: 89 02 BIT #$02 (branch if neither have bit 1 set)
C3/5F4C: F0 E6 BEQ $5F34
C3/5F4E: 80 DE BRA $5F2E