00137c10 - 00137ed0

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search

00137c10: 3c028016 lui r2,0x8016
00137c14: 94425ff6 lhu r2,0x5ff6(r2)              unknown
00137c18: 27bdffb0 addiu r29,r29,0xffb0
00137c1c: afb70044 sw r23,0x0044(r29)
00137c20: 00a0b821 addu r23,r5,r0                 selected option index in current menu
00137c24: afb00028 sw r16,0x0028(r29)
00137c28: 34100002 ori r16,r0,0x0002
00137c2c: afbf004c sw r31,0x004c(r29)
00137c30: afbe0048 sw r30,0x0048(r29)
00137c34: afb60040 sw r22,0x0040(r29)
00137c38: afb5003c sw r21,0x003c(r29)
00137c3c: afb40038 sw r20,0x0038(r29)
00137c40: afb30034 sw r19,0x0034(r29)
00137c44: afb20030 sw r18,0x0030(r29)
00137c48: afb1002c sw r17,0x002c(r29)
00137c4c: 14500007 bne r2,r16,0x00137c6c          ? skips checking tutorial variable.
00137c50: afa40010 sw r4,0x0010(r29)              store to p1 (current menu data pointer)
00137c54: 0c04ed64 jal 0x0013b590                 Get Script Variable
00137c58: 34040028 ori r4,r0,0x0028               var 0x28 (disallowed menu options for tutorial)
00137c5c: 02e21007 srav r2,r2,r23                 bit shift to obtain disallowed menu option
00137c60: 30420001 andi r2,r2,0x0001              is disallowed?
00137c64: 1440008e bne r2,r0,0x00137ea0           end if disallowed.
00137c68: 00000000 nop
00137c6c: 3c028017 lui r2,0x8017
00137c70: 8c4297d0 lw r2,-0x6830(r2)
00137c74: 00000000 nop
00137c78: 30420020 andi r2,r2,0x0020
00137c7c: 10400088 beq r2,r0,0x00137ea0
00137c80: 0000b021 addu r22,r0,r0
00137c84: 0c04dee6 jal 0x00137b98
00137c88: 00000000 nop
00137c8c: 10400084 beq r2,r0,0x00137ea0
00137c90: 00000000 nop
00137c94: 3c028017 lui r2,0x8017
00137c98: 8c424038 lw r2,0x4038(r2)
00137c9c: 00000000 nop
00137ca0: 00021a80 sll r3,r2,0x0a
00137ca4: 3c018017 lui r1,0x8017
00137ca8: 00230821 addu r1,r1,r3
00137cac: 8c2298c0 lw r2,-0x6740(r1)
00137cb0: 00000000 nop
00137cb4: 14400007 bne r2,r0,0x00137cd4
00137cb8: 00000000 nop
00137cbc: 3c018017 lui r1,0x8017
00137cc0: 00230821 addu r1,r1,r3
00137cc4: ac3098c0 sw r16,-0x6740(r1)
00137cc8: 3c018017 lui r1,0x8017
00137ccc: 00230821 addu r1,r1,r3
00137cd0: ac2098bc sw r0,-0x6744(r1)
00137cd4: 8fa80010 lw r8,0x0010(r29)               p1 = ptr to current menu data
00137cd8: 00000000 nop
00137cdc: 8d100024 lw r16,0x0024(r8)               ptr to current menu's index functions
00137ce0: 00000000 nop
00137ce4: 2602000f addiu r2,r16,0x000f             adds 0xf to a pointer?
00137ce8: 2c42000f sltiu r2,r2,0x000f
00137cec: 14400004 bne r2,r0,0x00137d00            branch if menu index pointer erroneously small
00137cf0: 0200a021 addu r20,r16,r0
00137cf4: 00171040 sll r2,r23,0x01
00137cf8: 00501021 addu r2,r2,r16
00137cfc: 84540000 lh r20,0x0000(r2)               load menu selection function (signed)
00137d00: 00000000 nop
00137d04: 06800023 bltz r20,0x00137d94             branch if signed value
00137d08: 32821000 andi r2,r20,0x1000
00137d0c: 10400003 beq r2,r0,0x00137d1c            branch if disabled flag(?) is not true (set for act and move, so not sure what the game is here. bring up text?)
00137d10: 00000000 nop
00137d14: 34160001 ori r22,r0,0x0001               r22 = 1
00137d18: 2694f000 addiu r20,r20,0xf000            -0x1000 (why not and? i dunno lol)
00137d1c: 0680001d bltz r20,0x00137d94             branch if signed (only if disabled, after above filter.)
00137d20: 2a820100 slti r2,r20,0x0100              check if only function is left
00137d24: 10400016 beq r2,r0,0x00137d80            branch if not
00137d28: 00148100 sll r16,r20,0x04                function * 0x10
00137d2c: 02148023 subu r16,r16,r20                function * 0x0f
00137d30: 00108080 sll r16,r16,0x02                function * 0x3c
00137d34: 3c028017 lui r2,0x8017
00137d38: 8c423cb8 lw r2,0x3cb8(r2)                pointer to menu data
00137d3c: 3c048017 lui r4,0x8017
00137d40: 8c844038 lw r4,0x4038(r4)                ID of next thread to initialise
00137d44: 02021021 addu r2,r16,r2
00137d48: 8c450028 lw r5,0x0028(r2)                function pointer for thread to run
00137d4c: 0c053228 jal 0x0014c8a0                  Initialize Thread <-- Menu Opening Threads
00137d50: 2484ffff addiu r4,r4,0xffff
00137d54: 00003021 addu r6,r0,r0
00137d58: 00003821 addu r7,r0,r0                   func param 2 & 3 null
00137d5c: 3c048017 lui r4,0x8017
00137d60: 8c844038 lw r4,0x4038(r4)                size of thread
00137d64: 3c058017 lui r5,0x8017
00137d68: 8ca53cb8 lw r5,0x3cb8(r5)                func param 1
00137d6c: 2484ffff addiu r4,r4,0xffff
00137d70: 0c05328e jal 0x0014ca38                  Store Thread Function Parameters
00137d74: 02052821 addu r5,r16,r5                  func param 1 = menu func to open
00137d78: 0804df99 j 0x00137e64
00137d7c: 00000000 nop

function has extra flags?

00137d80: 340204d2 ori r2,r0,0x04d2
00137d84: 16820037 bne r20,r2,0x00137e64           branch if function is not 0x04d2
00137d88: 00000000 nop
00137d8c: 0804df99 j 0x00137e64
00137d90: 2417ffff addiu r23,r0,0xffff

function is signed

00137d94: 0014a023 subu r20,r0,r20                 negate
00137d98: 00009821 addu r19,r0,r0
00137d9c: 34050001 ori r5,r0,0x0001
00137da0: 34040003 ori r4,r0,0x0003
00137da4: 3c038017 lui r3,0x8017
00137da8: 246398b8 addiu r3,r3,0x98b8
00137dac: 8c620000 lw r2,0x0000(r3)                load some thread variable?
00137db0: 00000000 nop
00137db4: 14450002 bne r2,r5,0x00137dc0            don't store 0x03 if not 0x1
00137db8: 26730001 addiu r19,r19,0x0001
00137dbc: ac640000 sw r4,0x0000(r3)                store 0x03
00137dc0: 2a620010 slti r2,r19,0x0010              loop 10 times
00137dc4: 1440fff9 bne r2,r0,0x00137dac
00137dc8: 24630400 addiu r3,r3,0x0400
00137dcc: 1a800025 blez r20,0x00137e64             shouldn't branch
00137dd0: 00009821 addu r19,r0,r0
00137dd4: 34150008 ori r21,r0,0x0008
00137dd8: 3c1e8016 lui r30,0x8016
00137ddc: 27de5ee4 addiu r30,r30,0x5ee4            main menu selection
00137de0: 3c028017 lui r2,0x8017
00137de4: 8c424038 lw r2,0x4038(r2)                currently running thread ID
00137de8: 34030001 ori r3,r0,0x0001
00137dec: 02621021 addu r2,r19,r2
00137df0: 00022280 sll r4,r2,0x0a                  thread ID * 400
00137df4: 3c018017 lui r1,0x8017
00137df8: 00240821 addu r1,r1,r4
00137dfc: ac239874 sw r3,-0x678c(r1)               store current thread ID
00137e00: 14550014 bne r2,r21,0x00137e54
00137e04: 00000000 nop
00137e08: 1a800012 blez r20,0x00137e54             shouldn't branch
00137e0c: 00008821 addu r17,r0,r0
00137e10: 03c09021 addu r18,r30,r0
00137e14: 02b18023 subu r16,r21,r17                can check negative thread IDs? 
00137e18: 0c053325 jal 0x0014cc94                  Check Thread Running Status
00137e1c: 02002021 addu r4,r16,r0
00137e20: 10400009 beq r2,r0,0x00137e48            branch if thread is not running
00137e24: 26310001 addiu r17,r17,0x0001            
00137e28: 00101280 sll r2,r16,0x0a
00137e2c: 3c018017 lui r1,0x8017
00137e30: 00220821 addu r1,r1,r2
00137e34: 8c22986c lw r2,-0x6794(r1)
00137e38: 00000000 nop
00137e3c: 94420038 lhu r2,0x0038(r2)
00137e40: 00000000 nop
00137e44: a6420000 sh r2,0x0000(r18)
00137e48: 0234102a slt r2,r17,r20
00137e4c: 1440fff1 bne r2,r0,0x00137e14            loop for all r20
00137e50: 26520002 addiu r18,r18,0x0002
00137e54: 26730001 addiu r19,r19,0x0001
00137e58: 0274102a slt r2,r19,r20
00137e5c: 1440ffe0 bne r2,r0,0x00137de0
00137e60: 00000000 nop

return:

00137e64: 8fa80010 lw r8,0x0010(r29)
00137e68: 00000000 nop
00137e6c: 8d020034 lw r2,0x0034(r8)
00137e70: 3c018017 lui r1,0x8017
00137e74: ac2097d0 sw r0,-0x6830(r1)
00137e78: a4570000 sh r23,0x0000(r2)
00137e7c: 3c028016 lui r2,0x8016
00137e80: 8c425fbc lw r2,0x5fbc(r2)
00137e84: 00000000 nop
00137e88: 14400005 bne r2,r0,0x00137ea0
00137e8c: 00000000 nop
00137e90: 16c00003 bne r22,r0,0x00137ea0
00137e94: 00000000 nop
00137e98: 0c04b747 jal 0x0012dd1c                   0012dd1c - 0012dd2c
00137e9c: 00000000 nop
00137ea0: 8fbf004c lw r31,0x004c(r29)
00137ea4: 8fbe0048 lw r30,0x0048(r29)
00137ea8: 8fb70044 lw r23,0x0044(r29)
00137eac: 8fb60040 lw r22,0x0040(r29)
00137eb0: 8fb5003c lw r21,0x003c(r29)
00137eb4: 8fb40038 lw r20,0x0038(r29)
00137eb8: 8fb30034 lw r19,0x0034(r29)
00137ebc: 8fb20030 lw r18,0x0030(r29)
00137ec0: 8fb1002c lw r17,0x002c(r29)
00137ec4: 8fb00028 lw r16,0x0028(r29)
00137ec8: 27bd0050 addiu r29,r29,0x0050
00137ecc: 03e00008 jr r31
00137ed0: 00000000 nop