Main Skillset/ability loading

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search

Runs when a skillset is selected

BATTLE.BIN - Main Skillset/ability loading
---------------------------------------------------------------------------------------
Parameter : r4 = 0x02 - 1st Menu (All Action menus and Math 1st set of skills)
                 0x01 - 2nd Menu for Math skills
                 0x00 - Last Menu for math skill (spell list)

Returns : Nothing

This Routine will : Initialize Lists of Ability data used in menu
                    Fill The lists (via other routines)
                    Set Menu Size and Headers
                    Set Blinking red/grey abilities
---------------------------------------------------------------------------------------
0013fa6c: 3c028017 lui r2,0x8017            |
0013fa70: 8c424048 lw r2,0x4048(r2)         |Pointer to Ability List
0013fa74: 27bdffa8 addiu r29,r29,-0x0058    |
0013fa78: afb20040 sw r18,0x0040(r29)       |
0013fa7c: 3c128015 lui r18,0x8015           |
0013fa80: 8652d08a lh r18,-0x2f76(r18)      |load attacker battle ID 8014d084 - Selected Unit ID
0013fa84: afb5004c sw r21,0x004c(r29)       |
0013fa88: afbf0054 sw r31,0x0054(r29)       |
0013fa8c: afb60050 sw r22,0x0050(r29)       |
0013fa90: afb40048 sw r20,0x0048(r29)       |
0013fa94: afb30044 sw r19,0x0044(r29)       |
0013fa98: afb1003c sw r17,0x003c(r29)       |
0013fa9c: afb00038 sw r16,0x0038(r29)       |
0013faa0: 244300a4 addiu r3,r2,0x00a4       |Pointer to output list "Stock" "Mp" 
0013faa4: 3c018016 lui r1,0x8016            |
0013faa8: ac2269a4 sw r2,0x69a4(r1)         |store skillset ability list pointer
0013faac: 24420148 addiu r2,r2,0x0148       |Pointer to output list "Turns" 
0013fab0: 3c018016 lui r1,0x8016            |
0013fab4: ac2369a8 sw r3,0x69a8(r1)         |store skillset ability list + 0xa4 for MP cost
0013fab8: 3c018016 lui r1,0x8016            |
0013fabc: ac2269ac sw r2,0x69ac(r1)         |Store skillset ability list + 0x0148 for #turns
0013fac0: 0c04b7d0 jal 0x0012df40           |-->0012df40_-_0012df64 Returns Selected unit battle pointer
0013fac4: 0080a821 addu r21,r4,r0           |r21 = PV (number of times gone through menus?)
0013fac8: 0040b021 addu r22,r2,r0           |Pointer to Unit Battle stats
0013facc: 00002821 addu r5,r0,r0            |Initialize counter
0013fad0: 3409ffff ori r9,r0,0xffff         |
0013fad4: 3c028017 lui r2,0x8017            |
0013fad8: 8c423cb8 lw r2,0x3cb8(r2)         |Pointer to menu data 0x80166b10
0013fadc: 340800ff ori r8,r0,0x00ff         |
0013fae0: 84420128 lh r2,0x0128(r2)         |Used Skillset (1 for Primary 2 For Secondary)
0013fae4: 34070001 ori r7,r0,0x0001         |
0013fae8: 3c018017 lui r1,0x8017            |
0013faec: 00220821 addu r1,r1,r2            |
0013faf0: 9031404c lbu r17,0x404c(r1)       |Load action menu ID  (based on used skillset)
0013faf4: 3c018017 lui r1,0x8017            |
0013faf8: 00220821 addu r1,r1,r2            |
0013fafc: 90304060 lbu r16,0x4060(r1)       |Load displayed skillset ID  (based on used skillset)
0013fb00: 3c068015 lui r6,0x8015            |
0013fb04: 24c6d264 addiu r6,r6,-0x2d9c      |8014d264
0013fb08: 3c018017 lui r1,0x8017            |
0013fb0c: a030982d sb r16,-0x67d3(r1)       |store skillset at 0x8016982d
                                            @LOOP - Initialize Abillity lists
0013fb10: 3c038017 lui r3,0x8017                |
0013fb14: 8c634048 lw r3,0x4048(r3)             |Pointer to Ability List
0013fb18: 00052040 sll r4,r5,0x01               |counter * 2
0013fb1c: 00831021 addu r2,r4,r3                |Dynamic Pointer to Ability List (Halfword offset)
0013fb20: 00651821 addu r3,r3,r5                |Dynamic Pointer to Ability List (Byte offset)
0013fb24: a4490000 sh r9,0x0000(r2)             |Initialize Ability ID List (0xffff from 0x00 to 0x100)
0013fb28: a06801ec sb r8,0x01ec(r3)             |Initialize MP cost, Consumed Item ID  with 0xff (0x1ec - 0x26c) 
0013fb2c: 3c028017 lui r2,0x8017                |
0013fb30: 8c424048 lw r2,0x4048(r2)             |Pointer to Ability List
0013fb34: 00000000 nop                          |
0013fb38: 00451021 addu r2,r2,r5                |Dynamic Pointer to Ability List (Byte offset)
0013fb3c: a047023e sb r7,0x023e(r2)             |Intialize CT list with 0x01 in ability CT  (0x23e - 0x2be, there is a lot of overlap with some of these.)
0013fb40: 3c028017 lui r2,0x8017                |
0013fb44: 8c424048 lw r2,0x4048(r2)             |Pointer to Ability List
0013fb48: 00000000 nop                          |
0013fb4c: 00822021 addu r4,r4,r2                |Dynamic Pointer to Ability List (Halfword offset)
0013fb50: 00451021 addu r2,r2,r5                |
0013fb54: a48000a4 sh r0,0x00a4(r4)             |clear "stock" "mp" (0xa4 - 0x1a4 Stock/MP)
0013fb58: a4890148 sh r9,0x0148(r4)             |store 0xffff (0x148 - 0x248)
0013fb5c: a0400290 sb r0,0x0290(r2)             |store 0x00 for silence/performance/reflect (0x290 - 0x310)
0013fb60: 3c028017 lui r2,0x8017                |
0013fb64: 8c424048 lw r2,0x4048(r2)             |Pointer to Ability List
0013fb68: 00000000 nop                          |
0013fb6c: 00451021 addu r2,r2,r5                |Dynamic Pointer to Ability List (Byte offset)
0013fb70: a04702e2 sb r7,0x02e2(r2)             |store 0x1 in # turns to complete (0x2e2 - 0x362)
0013fb74: 3c028017 lui r2,0x8017                |
0013fb78: 8c424048 lw r2,0x4048(r2)             |Pointer to Ability List ...and again
0013fb7c: 00000000 nop                          |
0013fb80: 00451021 addu r2,r2,r5                |Dynamic Pointer to Ability List (Byte offset)
0013fb84: a0480334 sb r8,0x0334(r2)             |store CT list = 0xFF
0013fb88: a4c00000 sh r0,0x0000(r6)             |store normal for ability display (0x8014d264 - 0x8014d300), no Unit ID (0x8014d304), and others From 0x8014d264 to 0x8014d364
0013fb8c: 24a50001 addiu r5,r5,0x0001           |Counter + 1
0013fb90: 28a20050 slti r2,r5,0x0050            |Check limit
0013fb94: 1440ffde bne r2,r0,0x0013fb10     Λ Loop 80 times
0013fb98: 24c60002 addiu r6,r6,0x0002           |Dynamic pointer to Ability display + 2
                                            Set end of lists
0013fb9c: 3c028017 lui r2,0x8017            |
0013fba0: 8c424048 lw r2,0x4048(r2)         |Pointer to Ability List
0013fba4: 340300ff ori r3,r0,0x00ff         |
0013fba8: a043023c sb r3,0x023c(r2)         |End MP/Stock List  it is already 0xff…
0013fbac: 3c028017 lui r2,0x8017            |
0013fbb0: 8c424048 lw r2,0x4048(r2)         |Pointer to Ability List
0013fbb4: 00000000 nop                      |
0013fbb8: a043028e sb r3,0x028e(r2)         |End CT List  it is already 0xff…
0013fbbc: 3c028017 lui r2,0x8017            |
0013fbc0: 8c424048 lw r2,0x4048(r2)         |Pointer to Ability List
0013fbc4: 00000000 nop                      |
0013fbc8: a04302e0 sb r3,0x02e0(r2)         |End Silence Reflect Perform list
0013fbcc: 3c028017 lui r2,0x8017            |
0013fbd0: 8c424048 lw r2,0x4048(r2)         |Pointer to Ability List
0013fbd4: 00000000 nop                      |
0013fbd8: a0430332 sb r3,0x0332(r2)         |End Turn list
0013fbdc: 3c028017 lui r2,0x8017            |
0013fbe0: 8c424048 lw r2,0x4048(r2)         |Pointer to Ability List

**Section 1 - Load ability-relevant data**
                                        ------- Action Menu 0x00 - Default -----------
0013fbe4: 16200014 bne r17,r0,0x0013fc38    #If Action Menu = 0x00
0013fbe8: a0430384 sb r3,0x0384(r2)             |
0013fbec: 02402021 addu r4,r18,r0               |r4 = attacker ID
0013fbf0: 3c068017 lui r6,0x8017                |
0013fbf4: 8cc64048 lw r6,0x4048(r6)             |Pointer to Ability List
0013fbf8: 02002821 addu r5,r16,r0               |r5 = skillset ID
0013fbfc: afa00014 sw r0,0x0014(r29)            |
0013fc00: 24c701ec addiu r7,r6,0x01ec           |Pointer to MP Cost/ Stock List
0013fc04: 24c2023e addiu r2,r6,0x023e           |Pointer to Ability CT
0013fc08: afa20010 sw r2,0x0010(r29)            |Send Ability CT pointer through stack
0013fc0c: 24c20290 addiu r2,r6,0x0290           | Pointer to Silence/persevere/Reflect
0013fc10: afa20018 sw r2,0x0018(r29)            |Send silence/performance/reflect pointer  through stack
0013fc14: 24c202e2 addiu r2,r6,0x02e2           | Pointer to Nb of Turns List
0013fc18: 0c0605f0 jal 0x001817c0               |-->Load_ability_data_for_skillset Fill List and returns Nb of usable Abilities (known - sword - materia - frog)
0013fc1c: afa2001c sw r2,0x001c(r29)            |Send Nb of Turns pointer through stack
0013fc20: 3c058017 lui r5,0x8017                |
0013fc24: 8ca54048 lw r5,0x4048(r5)             |Pointer to Ability List
0013fc28: 34060050 ori r6,r0,0x0050             |Size of data to transfer 0x50
0013fc2c: 24a40334 addiu r4,r5,0x0334           | Pointer to Ability CT
0013fc30: 0c052fd5 jal 0x0014bf54               |-->Copy 0x50 Bytes from r5 to r4
0013fc34: 24a5023e addiu r5,r5,0x023e           |Pointer to Ability CT

                                        ------- Action Menu 0x01 - Item inventory -----------
0013fc38: 34140001 ori r20,r0,0x0001        |
0013fc3c: 16340007 bne r17,r20,0x0013fc5c   #If Action Menu = 0x01
0013fc40: 34130002 ori r19,r0,0x0002            |
0013fc44: 02402021 addu r4,r18,r0               |r4 = unit ID
0013fc48: 3c068017 lui r6,0x8017                |
0013fc4c: 8cc64048 lw r6,0x4048(r6)             |Pointer to Ability List
0013fc50: 02002821 addu r5,r16,r0               |
0013fc54: 0c0606dc jal 0x00181b70               |-->Item_Ability_Loading
0013fc58: 24c601ec addiu r6,r6,0x01ec           |Item Used List per Ability ID (don't parse other arguments through stack)

                                        ------- Action Menu0x02 - Weapon inventory -----------
0013fc5c: 16330008 bne r17,r19,0x0013fc80   #If Action Menu = 0x02
0013fc60: 34020003 ori r2,r0,0x0003             |
0013fc64: 02402021 addu r4,r18,r0               |r4 = unit ID
0013fc68: 3c068017 lui r6,0x8017                |
0013fc6c: 8cc64048 lw r6,0x4048(r6)             |Pointer to Ability List
0013fc70: 02002821 addu r5,r16,r0               |skillset
0013fc74: 0c06072e jal 0x00181cb8               |-->Throw Ability & Item Loading
0013fc78: 24c601ec addiu r6,r6,0x01ec           |Item Used list per Item ID
0013fc7c: 34020003 ori r2,r0,0x0003             |math skill check

                                        ------- Action Menu 0x03 - Mathematics  -----------
0013fc80: 16220014 bne r17,r2,0x0013fcd4    #If Action Menu = 0x03
0013fc84: 00000000 nop                          |
0013fc88: 16b30005 bne r21,r19,0x0013fca0       #If PV = 0x02 : Load 1st set of Math abilities
0013fc8c: 02402021 addu r4,r18,r0                   |r4 = attacker ID
0013fc90: 3c068017 lui r6,0x8017                    |
0013fc94: 8cc64048 lw r6,0x4048(r6)                 |Pointer to Ability List
0013fc98: 0c0607bc jal 0x00181ef0                   |-->Math_Skill_Ability_Display Checks for primary menu
0013fc9c: 02002821 addu r5,r16,r0                   |r5 = skillset ID
0013fca0: 16b40005 bne r21,r20,0x0013fcb8       #if PV = 0x01 : Load 2nd set of Math abilities
0013fca4: 02402021 addu r4,r18,r0                   |r4 = attacker ID
0013fca8: 3c068017 lui r6,0x8017                    |
0013fcac: 8cc64048 lw r6,0x4048(r6)                 |Pointer to Ability List
0013fcb0: 0c0607c5 jal 0x00181f14                   |-->Math_Skill_Ability_Display Checks for secondary menu
0013fcb4: 02002821 addu r5,r16,r0                   |Skillset ID
0013fcb8: 16a00007 bne r21,r0,0x0013fcd8        #if PV = 0x00 : Load Math spell list
0013fcbc: 34020006 ori r2,r0,0x0006                 |
0013fcc0: 02402021 addu r4,r18,r0                   |r4 = attacker ID
0013fcc4: 3c068017 lui r6,0x8017                    |
0013fcc8: 8cc64048 lw r6,0x4048(r6)                 |Pointer to Ability List
0013fccc: 0c06081a jal 0x00182068                   |-->Math_Skill_ability_loading Loop through Valid skillset and seek known Spells
0013fcd0: 02002821 addu r5,r16,r0                   |Skillset ID

                                        ------- Action Menu 0x06 Monsters / Frog  -----------
0013fcd4: 34020006 ori r2,r0,0x0006         |
0013fcd8: 1622000a bne r17,r2,0x0013fd04    #If Action Menu = 0x06
0013fcdc: 34020007 ori r2,r0,0x0007             |
0013fce0: 02402021 addu r4,r18,r0               |Unit ID
0013fce4: 02002821 addu r5,r16,r0               |Skillset ID
0013fce8: 3c068017 lui r6,0x8017                |
0013fcec: 8cc64048 lw r6,0x4048(r6)             |Pointer to Ability List
0013fcf0: 00003821 addu r7,r0,r0                |r7 = 0
0013fcf4: 24c20290 addiu r2,r6,0x0290           | Pointer to Silence/persevere/Reflect
0013fcf8: 0c0608b3 jal 0x001822cc               |-->Monster_skill,_frog_attack_ability_loading
0013fcfc: afa20010 sw r2,0x0010(r29)            |send silence/reflectable/performance pointer through stack
0013fd00: 34020007 ori r2,r0,0x0007             |

                                        ------- Action Menu 0x07 Katana Inventory -----------
0013fd04: 16220008 bne r17,r2,0x0013fd28    #If Action Menu = 0x07
0013fd08: 3402000a ori r2,r0,0x000a             |
0013fd0c: 02402021 addu r4,r18,r0               |Unit ID
0013fd10: 3c068017 lui r6,0x8017                |
0013fd14: 8cc64048 lw r6,0x4048(r6)             |Pointer to Ability List
0013fd18: 02002821 addu r5,r16,r0               |Skillset ID
0013fd1c: 0c060999 jal 0x00182664               |-->Draw_Out
0013fd20: 24c601ec addiu r6,r6,0x01ec           |Pointer to MP Cost/ Stock List
0013fd24: 3402000a ori r2,r0,0x000a             |

                                        ------- Action Menu 0x0A - Aim -----------
0013fd28: 16220010 bne r17,r2,0x0013fd6c    #If Action Menu = 0x0A
0013fd2c: 34020003 ori r2,r0,0x0003             |
0013fd30: 02402021 addu r4,r18,r0               |Unit ID
0013fd34: 3c068017 lui r6,0x8017                |
0013fd38: 8cc64048 lw r6,0x4048(r6)             |Pointer to Ability List
0013fd3c: 02002821 addu r5,r16,r0               |
0013fd40: 24c701ec addiu r7,r6,0x01ec           |Raw Ability CT Use MP list to store charge CT ?
0013fd44: 24c202e2 addiu r2,r6,0x02e2           |Turns
0013fd48: 0c0609ed jal 0x001827b4               |-->Charge_Skillset_Loading
0013fd4c: afa20010 sw r2,0x0010(r29)            # turns in stack + 0x10
0013fd50: 3c058017 lui r5,0x8017                |
0013fd54: 8ca54048 lw r5,0x4048(r5)             |Ability ID list
0013fd58: 34060050 ori r6,r0,0x0050             |r6 = 0x80
0013fd5c: 24a40334 addiu r4,r5,0x0334           |Ability CT?
0013fd60: 0c052fd5 jal 0x0014bf54               |-->Copy 0x50 Bytes from r5 to r4
0013fd64: 24a501ec addiu r5,r5,0x01ec           |Raw ability CT
0013fd68: 34020003 ori r2,r0,0x0003             |

**2nd Section -  Set Usabilities / Menu data **
                                        ------ POST ACTION MENU MAIN SECTION ----
0013fd6c: 12220002 beq r17,r2,0x0013fd78    #If Action Menu is not Mathematics
0013fd70: 341200ac ori r18,r0,0x00ac        |default r18 to 0xac (menu type flags?)
0013fd74: 0000a821 addu r21,r0,r0               |r21 = 0 if not math skill (Last Math skill menu has already r21 to 0x00)
0013fd78: 34020003 ori r2,r0,0x0003         |
0013fd7c: 3c018016 lui r1,0x8016            |
0013fd80: a42269a0 sh r2,0x69a0(r1)         |store stock/mp/turns display (initialised)
0013fd84: 3c018016 lui r1,0x8016            |
0013fd88: a42269a2 sh r2,0x69a2(r1)         |store stock/mp/turns display (initialised)
0013fd8c: 3402006a ori r2,r0,0x006a         |
0013fd90: 3c018016 lui r1,0x8016            |
0013fd94: a422699a sh r2,0x699a(r1)         |store MP display X offset
0013fd98: 3402007e ori r2,r0,0x007e         |
0013fd9c: 3c018016 lui r1,0x8016            |
0013fda0: a422699c sh r2,0x699c(r1)         |store turn display X offset
0013fda4: 00111080 sll r2,r17,0x02          |Action Menu ID*4
0013fda8: 3c018016 lui r1,0x8016            |
0013fdac: a420699e sh r0,0x699e(r1)         |store Ability name display
0013fdb0: 3c018017 lui r1,0x8017            |
0013fdb4: 00220821 addu r1,r1,r2            |
0013fdb8: 84239266 lh r3,-0x6d9a(r1)        |80169266 + Action menu byte*4 (if action menu calls inventory or not?)  * details in notes
0013fdbc: 34020001 ori r2,r0,0x0001         |
0013fdc0: 14620048 bne r3,r2,0x0013fee4     #If used Action Menu Call inventory (r3 = 0x01)
0013fdc4: 00003021 addu r6,r0,r0            |Defaut Menu dimension/Tags

                                            Item/Throw/Draw Out - Set usability based on item quantity
0013fdc8: 3c048017 lui r4,0x8017                |
0013fdcc: 8c844048 lw r4,0x4048(r4)             |load ability list address
0013fdd0: 0c04fe80 jal 0x0013fa00               |-->0013fa00_-_0013fa34
0013fdd4: 248501ec addiu r5,r4,0x01ec           |Item Used
0013fdd8: 00408021 addu r16,r2,r0               |r16 = # of abilities
0013fddc: 3c058017 lui r5,0x8017                |
0013fde0: 8ca54048 lw r5,0x4048(r5)             |load skillset data
0013fde4: 02003021 addu r6,r16,r0               # of abilities
0013fde8: 24a40148 addiu r4,r5,0x0148           |r4 = Turns
0013fdec: 0c04fe8e jal 0x0013fa38               |-->0013fa38_-_0013fa68 do for each r6, load from r5, store in r4 **Set Turns**
0013fdf0: 24a502e2 addiu r5,r5,0x02e2           |r5 = turns
0013fdf4: 00003021 addu r6,r0,r0                |
0013fdf8: 1a000019 blez r16,0x0013fe60          #branch if no abilities found
0013fdfc: 00002821 addu r5,r0,r0                    |
0013fe00: 34070004 ori r7,r0,0x0004                 |
0013fe04: 3c048015 lui r4,0x8015                    |
0013fe08: 2484d264 addiu r4,r4,0xd264               |load availability Data
0013fe0c: 3c038017 lui r3,0x8017                    |
0013fe10: 8c634048 lw r3,0x4048(r3)                 |load Ability ID list
                                                    @LOOP : Grey Out item abilities
0013fe14: 00000000 nop                                  |
0013fe18: 94620000 lhu r2,0x0000(r3)                    |load ability
0013fe1c: 3c018006 lui r1,0x8006                        |
0013fe20: 00220821 addu r1,r1,r2                        |
0013fe24: 902296e0 lbu r2,-0x6920(r1)                   |load item quantity
0013fe28: 00000000 nop                                  |
0013fe2c: a46200a4 sh r2,0x00a4(r3)                     |store item quantity
0013fe30: 946200a4 lhu r2,0x00a4(r3)                    |load item quantity
0013fe34: 00000000 nop                                  |
0013fe38: 14400003 bne r2,r0,0x0013fe48                 #If No items
0013fe3c: 00000000 nop                                      |
0013fe40: 0804ff93 j 0x0013fe4c                             |
0013fe44: a4870000 sh r7,0x0000(r4)                         |store grayed out ability
                                                        Else : if item quantity != 0
0013fe48: 34060001 ori r6,r0,0x0001                         |set ability usable?
0013fe4c: 24840002 addiu r4,r4,0x0002                   |count another availability if item is usable
0013fe50: 24a50001 addiu r5,r5,0x0001                   |counter + 1
0013fe54: 00b0102a slt r2,r5,r16                        |
0013fe58: 1440ffee bne r2,r0,0x0013fe14             Λ Loop - do for all Items in list
0013fe5c: 24630002 addiu r3,r3,0x0002                   |next ability ID
0013fe60: 10c00003 beq r6,r0,0x0013fe70         #branch if there is consumable items
0013fe64: 34070007 ori r7,r0,0x0007             |Control Value = 0x07
0013fe68: 0804ffa7 j 0x0013fe9c                     |
0013fe6c: 2652fffc addiu r18,r18,0xfffc             |if items are available, r18 = 0xa8
                                                Else : if no items with quantity > 0 found
0013fe70: 02003021 addu r6,r16,r0                   |
0013fe74: 34120094 ori r18,r0,0x0094                |if no items can be found, r18 = 0x94
0013fe78: 3c058017 lui r5,0x8017                    |
0013fe7c: 8ca54048 lw r5,0x4048(r5)                 |r5 = skillset abilities
0013fe80: 34020002 ori r2,r0,0x0002                 |
0013fe84: 3c018016 lui r1,0x8016                    |
0013fe88: a42269a2 sh r2,0x69a2(r1)                 |Remove "stock" display numbers
0013fe8c: 24a400a4 addiu r4,r5,0x00a4               |r4 = item quantities
0013fe90: 0c04fe8e jal 0x0013fa38                   |-->0013fa38_-_0013fa68
0013fe94: 24a502e2 addiu r5,r5,0x02e2               |r5 = 01 data
0013fe98: 34070008 ori r7,r0,0x0008                 |Control value = 0x08
0013fe9c: 34093800 ori r9,r0,0x3800             |Store Item display
0013fea0: 3c048016 lui r4,0x8016                |
0013fea4: 2484699a addiu r4,r4,0x699a           |8016699a
0013fea8: 94820000 lhu r2,0x0000(r4)            |load Stock numbers display location
0013feac: 3c038016 lui r3,0x8016                |
0013feb0: 9463699c lhu r3,0x699c(r3)            |load Turns display location
0013feb4: 2442fffc addiu r2,r2,0xfffc           |move left by 4
0013feb8: 2463fffc addiu r3,r3,0xfffc           |move left by 4
0013febc: a4820000 sh r2,0x0000(r4)             |store new location
0013fec0: 34020007 ori r2,r0,0x0007             |
0013fec4: 3c018016 lui r1,0x8016                |
0013fec8: a423699c sh r3,0x699c(r1)             |store new location
0013fecc: 1622005e bne r17,r2,0x00140048        #branch if not Draw out
0013fed0: 34060011 ori r6,r0,0x0011             |Item/Throw
0013fed4: 08050012 j 0x00140048                     >>Jump
0013fed8: 34060017 ori r6,r0,0x0017                 |Katana
                                                -- 2 shitty lines, reached by backward branching --
0013fedc: 0804ffd5 j 0x0013ff54                 >>Skip Next Section
0013fee0: 34060001 ori r6,r0,0x0001             |Dimension Tag if at least one Ability in list has a MP cost

                                            Not Item/throw/draw out 
0013fee4: 00008021 addu r16,r0,r0               |Initialize counter
0013fee8: 3404ffff ori r4,r0,0xffff             |
0013feec: 3c038017 lui r3,0x8017                |
0013fef0: 8c634048 lw r3,0x4048(r3)             |Pointer to Ability List
                                                @LOOP - Count listed Abilities
0013fef4: 00000000 nop                              |
0013fef8: 94620000 lhu r2,0x0000(r3)                |Ability ID
0013fefc: 00000000 nop                              |
0013ff00: 10440005 beq r2,r4,0x0013ff18             #if ID = 0xfff : Exit Loop (end of listed abilities)
0013ff04: 00000000 nop                              |
0013ff08: 26100001 addiu r16,r16,0x0001             |Counter + 1
0013ff0c: 2a020040 slti r2,r16,0x0040               |Check list limit
0013ff10: 1440fff8 bne r2,r0,0x0013fef4         Λ Loop until last Ability or end of list
0013ff14: 24630002 addiu r3,r3,0x0002               |Dynamic list pointer (halfword offset)

                                                Defaut Action Menu (0x00)
0013ff18: 1620000f bne r17,r0,0x0013ff58        #if Used Action Menu = Default
0013ff1c: 34020003 ori r2,r0,0x0003                 |
0013ff20: 1a00000d blez r16,0x0013ff58              #If There is no Ability in List : Branch to  Next Section
0013ff24: 00002821 addu r5,r0,r0                    |Initialize counter
0013ff28: 3c038017 lui r3,0x8017                        |
0013ff2c: 8c634048 lw r3,0x4048(r3)                 |Pointer to Ability List
0013ff30: 00000000 nop                              |
0013ff34: 00651021 addu r2,r3,r5                    |Dynamic Pointer to Ability List (Byte offset)
                                                    @Loop - MP Cost
0013ff38: 904201ec lbu r2,0x01ec(r2)                    |load MP cost
0013ff3c: 00000000 nop                                  |
0013ff40: 1440ffe6 bne r2,r0,0x0013fedc                 #Branch back if ability has MP cost (set custom menu dimensions/tags) and exit loop Seriously ?
0013ff44: 24a50001 addiu r5,r5,0x0001                   |counter++
0013ff48: 00b0102a slt r2,r5,r16                        |set if yet to search all abilities
0013ff4c: 1440fffa bne r2,r0,0x0013ff38             Λ Loop (all listed abilities)
0013ff50: 00651021 addu r2,r3,r5                        |Dynamic Pointer to Ability List (Byte offset)
0013ff54: 34020003 ori r2,r0,0x0003                     |

                                                Mathematics Action Menu (0x03)
0013ff58: 1622000a bne r17,r2,0x0013ff84        #If Action Menu is Mathematics
0013ff5c: 00000000 nop                              |
0013ff60: 1aa00008 blez r21,0x0013ff84              #If Not Loading Spell list (Preset value <> 0x00) :  Skip Section
0013ff64: 34020002 ori r2,r0,0x0002                     |
0013ff68: 34120088 ori r18,r0,0x0088                    |if math skill, r18 = 0x88
0013ff6c: 3c018016 lui r1,0x8016                        |
0013ff70: a42269a0 sh r2,0x69a0(r1)                     |store 0x0002
0013ff74: 3c018016 lui r1,0x8016                        |
0013ff78: a42269a2 sh r2,0x69a2(r1)                     |store 0x0002
0013ff7c: 08050010 j 0x00140040                         |
0013ff80: 34070009 ori r7,r0,0x0009                     |jump down, Set control value = 0x09

                                                Not Mathematics (Item - Throw - Draw Out - Default)
0013ff84: 10c00019 beq r6,r0,0x0013ffec         #If Ability Has a MP cost
0013ff88: 00000000 nop                              |
0013ff8c: 16200018 bne r17,r0,0x0013fff0            #If Not Defaut Action Menu :  Skip Section
0013ff90: 02003021 addu r6,r16,r0                   |For Each Ability
0013ff94: 3c058017 lui r5,0x8017                    |
0013ff98: 8ca54048 lw r5,0x4048(r5)                 |Pointer to Ability List
0013ff9c: 2652fff8 addiu r18,r18,-0x0008            |if default menu, r18 = 0xa4 (menu width includes MP)
0013ffa0: 24a400a4 addiu r4,r5,0x00a4               |Pointer MP List
0013ffa4: 0c04fe80 jal 0x0013fa00                   |-->Set MP Values Copy data from r5 (byte) to r4(halfwords)
0013ffa8: 24a501ec addiu r5,r5,0x01ec               |Pointer MP List
0013ffac: 3c058017 lui r5,0x8017                    |
0013ffb0: 8ca54048 lw r5,0x4048(r5)                 |Pointer to Ability List
0013ffb4: 02003021 addu r6,r16,r0                   |For Each Ability
0013ffb8: 24a40148 addiu r4,r5,0x0148               |Pointer Turn List
0013ffbc: 0c04fe8e jal 0x0013fa38                   |-->Transfer Turns Copy data from r5 (byte) to r4(halfwords)
0013ffc0: 24a502e2 addiu r5,r5,0x02e2               |Pointer Turn List
0013ffc4: 34070006 ori r7,r0,0x0006                 |menu header type = "Ability"     "Ref" "MP" "Turns"
0013ffc8: 3c048016 lui r4,0x8016                    |
0013ffcc: 2484699a addiu r4,r4,0x699a               |8016699a
0013ffd0: 94820000 lhu r2,0x0000(r4)                |load "MP" header display location
0013ffd4: 3c038016 lui r3,0x8016                    |
0013ffd8: 9463699c lhu r3,0x699c(r3)                |load "turns" header display
0013ffdc: 2442fff8 addiu r2,r2,0xfff8               |r2 -= 0x08
0013ffe0: 2463fff8 addiu r3,r3,0xfff8               |r3 -= 0x08
0013ffe4: 0805000e j 0x00140038                     |
0013ffe8: a4820000 sh r2,0x0000(r4)                 |store new "MP" header display location
                                                Else : Ability Without MP Cost (Or not default action menu)
0013ffec: 02003021 addu r6,r16,r0                   |
0013fff0: 3c058017 lui r5,0x8017                    |
0013fff4: 8ca54048 lw r5,0x4048(r5)                 |
0013fff8: 34120094 ori r18,r0,0x0094                |if menu cannot not use items, is not default, or isn't math, r18 = 0x94
0013fffc: 24a400a4 addiu r4,r5,0x00a4               |Pointer MP/Stock List
00140000: 0c04fe8e jal 0x0013fa38                   |-->Transfer Turns Copy data from r5 (byte) to r4(halfwords)
00140004: 24a502e2 addiu r5,r5,0x02e2               |Pointer MP/Stock List
00140008: 34070005 ori r7,r0,0x0005                 |
0014000c: 34020002 ori r2,r0,0x0002                 |
00140010: 3c018016 lui r1,0x8016                    |
00140014: a42269a2 sh r2,0x69a2(r1)                 |store no stock/mp display?
00140018: 3c028016 lui r2,0x8016                    |
0014001c: 9442699a lhu r2,0x699a(r2)                |load mp/stock display location
00140020: 3c038016 lui r3,0x8016                    |
00140024: 9463699c lhu r3,0x699c(r3)                |turns display location
00140028: 2442fffc addiu r2,r2,0xfffc               |
0014002c: 2463fffc addiu r3,r3,0xfffc               |move to the left by 4
00140030: 3c018016 lui r1,0x8016                    |
00140034: a422699a sh r2,0x699a(r1)                 |store new
00140038: 3c018016 lui r1,0x8016                |
0014003c: a423699c sh r3,0x699c(r1)             |store new display location
00140040: 34097000 ori r9,r0,0x7000         |Default Ability Type
00140044: 34060005 ori r6,r0,0x0005         |
00140048: 3c028017 lui r2,0x8017            |
0014004c: 8c423cb8 lw r2,0x3cb8(r2)         |80166b10 - Menu Data
00140050: 00002821 addu r5,r0,r0            |
00140054: a45200b8 sh r18,0x00b8(r2)        |store menu type? 3 times. 0x94 means no abilities available?
00140058: a45200c0 sh r18,0x00c0(r2)        |
0014005c: a45200c8 sh r18,0x00c8(r2)        |
00140060: a44700e0 sh r7,0x00e0(r2)         |store menu headers set
00140064: 1a000031 blez r16,0x0014012c      #If There is abilities in the list
00140068: a44600ee sh r6,0x00ee(r2)         |store skillset type?
0014006c: 34080008 ori r8,r0,0x0008             |blinking red
00140070: 340a0006 ori r10,r0,0x0006            |
00140074: 3c068017 lui r6,0x8017                |
00140078: 8cc64048 lw r6,0x4048(r6)             |Pointer to Ability List
0014007c: 3c078015 lui r7,0x8015                |
00140080: 24e7d264 addiu r7,r7,0xd264           |Pointer to Ability Display
00140084: 00c02021 addu r4,r6,r0                |Pointer to Ability List
                                                @Loop - Set usability for default abilities based on MP
00140088: 94c20000 lhu r2,0x0000(r6)                |load ability ID
0014008c: 00000000 nop                              |
00140090: 00491025 or r2,r2,r9                      |Add ability type flags (r9 is 0x7000)
00140094: 1620000e bne r17,r0,0x001400d0            #If Action Menu ID is Default (0x00)
00140098: a4c20000 sh r2,0x0000(r6)                 |store ability with type flags
0014009c: 96c2002c lhu r2,0x002c(r22)                   |load Unit MP
001400a0: 908301ec lbu r3,0x01ec(r4)                    |load MP cost
001400a4: 00000000 nop                                  |
001400a8: 00431023 subu r2,r2,r3                        |MP - MP cost
001400ac: 04410006 bgez r2,0x001400c8                   #If unit has not enough MP
001400b0: 00000000 nop                                      |
001400b4: 90820334 lbu r2,0x0334(r4)                        |Load CT
001400b8: 00000000 nop                                      |
001400bc: 10400002 beq r2,r0,0x001400c8                     #If There is a CT
001400c0: 00000000 nop                                          |
001400c4: a4e80000 sh r8,0x0000(r7)                             |Set ability blinking red
001400c8: 12200003 beq r17,r0,0x001400d8                #Avoid Monster check and go to monster-default section could just be a jump…
001400cc: 00000000 nop                                      |
001400d0: 162a0010 bne r17,r10,0x00140114           #If Action Menu is Monster (0x06)   (Or Default)
001400d4: 00000000 nop                                  |
001400d8: 90820290 lbu r2,0x0290(r4)                    |load silence/persevere/reflect flags
001400dc: 00000000 nop                                  |
001400e0: 30420002 andi r2,r2,0x0002                    |
001400e4: 1040000b beq r2,r0,0x00140114                 #If Affected by silance
001400e8: 00000000 nop                                      |
001400ec: 90820334 lbu r2,0x0334(r4)                        |Load CT
001400f0: 00000000 nop                                      |
001400f4: 10400007 beq r2,r0,0x00140114                     #If no CT : Avoid blinking red
001400f8: 00000000 nop                                          |
001400fc: 92c20059 lbu r2,0x0059(r22)                       |Load current status 2
00140100: 00000000 nop                                      |
00140104: 30420008 andi r2,r2,0x0008                        |
00140108: 10400002 beq r2,r0,0x00140114                     #If Unit has Silence
0014010c: 00000000 nop                                          |
00140110: a4e80000 sh r8,0x0000(r7)                             |set skill blinking red (0x08)
00140114: 24e70002 addiu r7,r7,0x0002               |Dynamic Pointer to Ability display (Halfword offset)
00140118: 24840001 addiu r4,r4,0x0001               |Dynamic Pointer to Ability List (Byte offset)
0014011c: 24a50001 addiu r5,r5,0x0001               |Loop counter + 1
00140120: 00b0102a slt r2,r5,r16                    |
00140124: 1440ffd8 bne r2,r0,0x00140088         Λ do for all abilities
00140128: 24c60002 addiu r6,r6,0x0002               |Dynamic Pointer to Ability List (Halfword offset)
0014012c: 1600000e bne r16,r0,0x00140168    #If There is no Ability in list
00140130: 34037000 ori r3,r0,0x7000             |
00140134: 3c028017 lui r2,0x8017                |
00140138: 8c423cb8 lw r2,0x3cb8(r2)             |load menu data
0014013c: 34100001 ori r16,r0,0x0001            |
00140140: a44000e0 sh r0,0x00e0(r2)             |store no menu type
00140144: 3c028017 lui r2,0x8017                |
00140148: 8c424048 lw r2,0x4048(r2)             |Pointer to Ability List
0014014c: 00000000 nop                          |
00140150: a4430000 sh r3,0x0000(r2)             |store not-usable
00140154: a44000a4 sh r0,0x00a4(r2)             |
00140158: a4400148 sh r0,0x0148(r2)             |
0014015c: 34020004 ori r2,r0,0x0004             |
00140160: 3c018015 lui r1,0x8015                |
00140164: a422d264 sh r2,-0x2d9c(r1)            |store greyed out skillset?
00140168: 3c048017 lui r4,0x8017                |
0014016c: 8c843cb8 lw r4,0x3cb8(r4)         |load menu data
00140170: 34020030 ori r2,r0,0x0030         |
00140174: a48200be sh r2,0x00be(r4)         |store 0xbe byte
00140178: 2a020007 slti r2,r16,0x0007       |
0014017c: 14400009 bne r2,r0,0x001401a4     #If Nb of Abilities in List > 0x06
00140180: 34020006 ori r2,r0,0x0006             |
00140184: 2602fffa addiu r2,r16,-0x0006         |abilities - 6
00140188: 3c018016 lui r1,0x8016                |
0014018c: a4226996 sh r2,0x6996(r1)             |store number of scrollable slots
00140190: 34020006 ori r2,r0,0x0006             |
00140194: 3c018016 lui r1,0x8016                |
00140198: a4226994 sh r2,0x6994(r1)             |store 6 number of displayed slots
0014019c: 08050072 j 0x001401c8                 |
001401a0: 00000000 nop                          |
                                            Else Nb Of Abilities < 0x06
001401a4: 00501023 subu r2,r2,r16               |
001401a8: 3c018016 lui r1,0x8016                |
001401ac: a4206996 sh r0,0x6996(r1)             |store number of scrollable slots
001401b0: 3c018016 lui r1,0x8016                |
001401b4: a4306994 sh r16,0x6994(r1)            |store number of abilities
001401b8: 948300be lhu r3,0x00be(r4)            |
001401bc: 000210c0 sll r2,r2,0x03               |
001401c0: 00621821 addu r3,r3,r2                |
001401c4: a48300be sh r3,0x00be(r4)             |
001401c8: 3c028017 lui r2,0x8017                |
001401cc: 8c424038 lw r2,0x4038(r2)         |load block # Currently running thread
001401d0: 34030001 ori r3,r0,0x0001         |
001401d4: 00021280 sll r2,r2,0x0a           |
001401d8: 3c018017 lui r1,0x8017            |
001401dc: 00220821 addu r1,r1,r2            |
001401e0: ac239870 sw r3,-0x6790(r1)        |169870
001401e4: 3c018017 lui r1,0x8017            |
001401e8: 00220821 addu r1,r1,r2            |
001401ec: ac209874 sw r0,-0x678c(r1)        |169874
001401f0: 3c018017 lui r1,0x8017            |
001401f4: 00220821 addu r1,r1,r2            |
001401f8: ac239878 sw r3,-0x6788(r1)        |169878
001401fc: 8fbf0054 lw r31,0x0054(r29)       END
00140200: 8fb60050 lw r22,0x0050(r29)
00140204: 8fb5004c lw r21,0x004c(r29)
00140208: 8fb40048 lw r20,0x0048(r29)
0014020c: 8fb30044 lw r19,0x0044(r29)
00140210: 8fb20040 lw r18,0x0040(r29)
00140214: 8fb1003c lw r17,0x003c(r29)
00140218: 8fb00038 lw r16,0x0038(r29)
0014021c: 27bd0058 addiu r29,r29,0x0058
00140220: 03e00008 jr r31
00140224: 00000000 nop

Notes

Data at 0x80169266 : 2 halfwords per action menu ID
This routine only uses 0x00

0x80169266               0x00    0x02
-------------------------------------
0x00     Default         0000    0003
0x04     Item Inventory  0001    0003
0x08     Throw           0001    0003
0x12     Math Skill      0000    fffd
0x16     Elemental       0000    fffd
0x20     Blank           0000    0003
0x24     Monster         0000    0003
0x28     Katana          0001    fffd
0x32     Attack          0000    fffd
0x36     Jump            0000    fffd
0x40     Charge          0000    fffd
0x44     Defend          0000    0505
0x48     Equip Change    0605    0524
0x52     Unknown         0505    0505
0x56     Blank           0505    0505
0x60     Unknown         1010    0010

Return location

Battle.bin
0014cf18: Call_Inner_Subroutine  (via jalr)