Calculate Unit's R/S/M

From Final Fantasy Hacktics Wiki
Revision as of 04:23, 1 March 2012 by Choto (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Calculate Unit's R/S/M
0005d0bc: 27bdfbe0 addiu r29,r29,0xfbe0
0005d0c0: 00804021 addu r8,r4,r0		r8 = Unit's Data Pointer
0005d0c4: afb60410 sw r22,0x0410(r29)
0005d0c8: 00c0b021 addu r22,r6,r0		r22 = R/S/M Check
0005d0cc: 00e05021 addu r10,r7,r0		r10 = ENTD Pointer
0005d0d0: 30a5ffff andi r5,r5,0xffff		r5 = Ability ID
0005d0d4: 2ca201fe sltiu r2,r5,0x01fe		(could load all of the known R/S/M into the stack, which
0005d0d8: afbf041c sw r31,0x041c(r29)		 it gives plenty of space for (~0x400, and if all 20 jobs
0005d0dc: afbe0418 sw r30,0x0418(r29)		 had 6 R/S/M each, that'd only be 0xf0 total), and sort
0005d0e0: afb70414 sw r23,0x0414(r29)		 them based on type, then randomly choose all 3 at once)
0005d0e4: afb5040c sw r21,0x040c(r29)
0005d0e8: afb40408 sw r20,0x0408(r29)
0005d0ec: afb30404 sw r19,0x0404(r29)
0005d0f0: afb20400 sw r18,0x0400(r29)
0005d0f4: afb103fc sw r17,0x03fc(r29)
0005d0f8: 10400003 beq r2,r0,0x 0005d108		Branch if Ability is Random
0005d0fc: afb003f8 sw r16,0x03f8(r29)
0005d100: 080174e4 j 0x 0005d390
0005d104: 00a01021 addu r2,r5,r0		Ability ID = ENTD Ability
0005d108: 91020006 lbu r2,0x0006(r8)		Load Unit's Gender Byte
0005d10c: 00000000 nop
0005d110: 30420020 andi r2,r2,0x0020
0005d114: 1440009e bne r2,r0,0x 0005d390		Branch if Unit is a monster
0005d118: 00001021 addu r2,r0,r0		Ability ID = 0
0005d11c: 00009821 addu r19,r0,r0		Counter = 0
0005d120: 01002021 addu r4,r8,r0		r4 = Unit's Data Pointer
0005d124: 27a30010 addiu r3,r29,0x0010		r3 = Stack Pointer + 0x10
0005d128: 9482000a lhu r2,0x000a(r4)		Load Unit's Innate Ability
0005d12c: 24840002 addiu r4,r4,0x0002		Unit's Data Pointer += 2
0005d130: 26730001 addiu r19,r19,0x0001		Counter ++
0005d134: a46203c0 sh r2,0x03c0(r3)		Store Innate Ability on the Stack
0005d138: 2a620004 slti r2,r19,0x0004
0005d13c: 1440fffa bne r2,r0,0x 0005d128		Branch if Counter < 4
0005d140: 24630002 addiu r3,r3,0x0002		Stack Pointer += 2
0005d144: 0000a021 addu r20,r0,r0		Stack Counter = 0
0005d148: 34070001 ori r7,r0,0x0001		r7 = 1 (Secondary not checked yet)
0005d14c: 91060013 lbu r6,0x0013(r8)		Load Unit's Secondary ID
0005d150: 00009821 addu r19,r0,r0		Counter = 0
0005d154: 0100f021 addu r30,r8,r0		r30 = Unit's Data Pointer
0005d158: 00009021 addu r18,r0,r0		Skillset = 0
0005d15c: 34020013 ori r2,r0,0x0013		r2 = 0x13
0005d160: 16620008 bne r19,r2,0x 0005d184	Branch if Counter != 0x13 (Mime check)
0005d164: 34150001 ori r21,r0,0x0001		r21 = 1 (Checking known abilities)
0005d168: 10e00078 beq r7,r0,0x 0005d34c		Branch if Secondary has been checked
0005d16c: 00000000 nop
0005d170: 00c09021 addu r18,r6,r0		Skillset = Unit's Secondary ID
0005d174: 12400075 beq r18,r0,0x 0005d34c	Branch if Unit doesn't have a secondary
0005d178: 00000000 nop
0005d17c: 08017472 j 0x 0005d1c8			(this is for mime with a non-generic secondary?)
0005d180: 0000a821 addu r21,r0,r0		r21 = 0 (Not checking known abilities)
0005d184: 16600010 bne r19,r0,0x 0005d1c8	Branch if Counter != 0 (Base ID check)
0005d188: 2669004a addiu r9,r19,0x004a		Job ID = Counter + 0x4a
0005d18c: 91030000 lbu r3,0x0000(r8)		Load Unit's Sprite Set
0005d190: 00000000 nop
0005d194: 2462ff80 addiu r2,r3,0xff80		Sprite Set - 0x80
0005d198: 304200ff andi r2,r2,0x00ff
0005d19c: 2c420002 sltiu r2,r2,0x0002
0005d1a0: 14400002 bne r2,r0,0x 0005d1ac		Branch if Sprite Set is Generic Male/Female
0005d1a4: 00000000 nop
0005d1a8: 00604821 addu r9,r3,r0		Job ID = Sprite Set
0005d1ac: 9143001d lbu r3,0x001d(r10)		Load ENTD Primary Skillset
0005d1b0: 00000000 nop
0005d1b4: 10600004 beq r3,r0,0x 0005d1c8		Branch if Primary Skillset = 0
0005d1b8: 340200ff ori r2,r0,0x00ff
0005d1bc: 10620002 beq r3,r2,0x 0005d1c8		Branch if Primary Skillset = FF (job's)
0005d1c0: 00000000 nop
0005d1c4: 9152001d lbu r18,0x001d(r10)		Load ENTD Primary Skillset
0005d1c8: 00000000 nop
0005d1cc: 16400009 bne r18,r0,0x 0005d1f4	Branch if Skillset != 0
0005d1d0: 312300ff andi r3,r9,0x00ff		r3 = Job ID
0005d1d4: 106 0005d beq r3,r0,0x 0005d34c		Branch if Job ID = 0
0005d1d8: 00031040 sll r2,r3,0x01		Job ID * 2
0005d1dc: 00431021 addu r2,r2,r3		ID * 3
0005d1e0: 3c038006 lui r3,0x8006
0005d1e4: 8c636194 lw r3,0x6194(r3)		Load Job Data Pointer
0005d1e8: 00021100 sll r2,r2,0x04		ID * 48
0005d1ec: 00431021 addu r2,r2,r3
0005d1f0: 90520000 lbu r18,0x0000(r2)		Load Job's Skillset
0005d1f4: 00000000 nop
0005d1f8: 16460002 bne r18,r6,0x 0005d204	Branch if Skillset != Unit's Secondary ID
0005d1fc: 00000000 nop
0005d200: 00003821 addu r7,r0,r0		r7 = 0 (Secondary checked)
0005d204: 12a00004 beq r21,r0,0x 0005d218	Branch if not checking known Abilities (Mime)
0005d208: 34100010 ori r16,r0,0x0010		Known Ability Counter = 0x10 (R/S/M)
0005d20c: 93cb009b lbu r11,0x009b(r30)		Load Unit's Known R/S/M
0005d210: 00000000 nop
0005d214: a3ab03d8 sb r11,0x03d8(r29)		Temp Store Known R/S/M
0005d218: 93b703d8 lbu r23,0x03d8(r29)		r23 = Known R/S/M
0005d21c: 12a0000c beq r21,r0,0x 0005d250	Branch if not checking known abilities (Mime)
0005d220: 00008821 addu r17,r0,r0		r17 = 0 (ID isn't acceptable)
0005d224: 06010002 bgez r16,0x 0005d230		Branch if Ability Counter >= 0
0005d228: 02001821 addu r3,r16,r0		r3 = Ability Counter
0005d22c: 26030007 addiu r3,r16,0x0007
0005d230: 000318c3 sra r3,r3,0x03		Ability Counter / 8
0005d234: 000318c0 sll r3,r3,0x03		Ability Counter / 8 * 8
0005d238: 02031823 subu r3,r16,r3		Current Ability = Ability Counter - Ability Counter / 8 * 8
0005d23c: 34020080 ori r2,r0,0x0080		r2 = 0x80
0005d240: 00621007 srav r2,r2,r3		0x80 / 2^(Current Ability)
0005d244: 02e21024 and r2,r23,r2		r2 = Current Known R/S/M
0005d248: 1040003c beq r2,r0,0x 0005d33c		Branch if R/S/M isnt known
0005d24c: 00008821 addu r17,r0,r0		r17 = 0 (ID isn't acceptable)
0005d250: 324400ff andi r4,r18,0x00ff		r4 = Skillset
0005d254: 02002821 addu r5,r16,r0		r5 = Known Ability Counter
0005d258: afa603e0 sw r6,0x03e0(r29)		Temp Store Unit's Secondary Skillset
0005d25c: afa703e4 sw r7,0x03e4(r29)		Temp Store r7
0005d260: afa803e8 sw r8,0x03e8(r29)		Temp Store Unit's Data Pointer
0005d264: afa903ec sw r9,0x03ec(r29)		Temp Store Job ID
0005d268: 0c01695a jal 0x 0005a568		Load Ability From Skillset
0005d26c: afaa03f0 sw r10,0x03f0(r29)		Temp Store ENTD Pointer
0005d270: 00402021 addu r4,r2,r0		r4 = R/S/M ID
0005d274: 3083ffff andi r3,r4,0xffff
0005d278: 340201a9 ori r2,r0,0x01a9		r2 = 0x1a9 (Sunken State)
0005d27c: 8fa603e0 lw r6,0x03e0(r29)
0005d280: 8fa703e4 lw r7,0x03e4(r29)
0005d284: 8fa803e8 lw r8,0x03e8(r29)
0005d288: 8fa903ec lw r9,0x03ec(r29)
0005d28c: 8faa03f0 lw r10,0x03f0(r29)		Reload Temp Stored Values
0005d290: 1062002a beq r3,r2,0x 0005d33c		Branch if R/S/M ID = Sunken State
0005d294: 00000000 nop
0005d298: 97a203d0 lhu r2,0x03d0(r29)		Load Innate Ability 1
0005d29c: 00000000 nop
0005d2a0: 10620026 beq r3,r2,0x 0005d33c		Branch if Innate = Sunken State
0005d2a4: 00000000 nop
0005d2a8: 97a203d2 lhu r2,0x03d2(r29)		Load Innate Ability 2
0005d2ac: 00000000 nop
0005d2b0: 10620022 beq r3,r2,0x 0005d33c		Branch if Innate = Sunken State
0005d2b4: 00000000 nop
0005d2b8: 97a203d4 lhu r2,0x03d4(r29)		Load Innate Ability 3
0005d2bc: 00000000 nop
0005d2c0: 1062001e beq r3,r2,0x 0005d33c		Branch if Innate = Sunken State
0005d2c4: 00000000 nop
0005d2c8: 97a203d6 lhu r2,0x03d6(r29)		Load Innate Ability 4
0005d2cc: 00000000 nop
0005d2d0: 1062001a beq r3,r2,0x 0005d33c		Branch if Innate = Sunken State
0005d2d4: 32c20002 andi r2,r22,0x0002
0005d2d8: 10400003 beq r2,r0,0x 0005d2e8		Branch if not setting reaction
0005d2dc: 2482fe5a addiu r2,r4,0xfe5a		r2 = R/S/M - 0x1a6
0005d2e0: 3042ffff andi r2,r2,0xffff
0005d2e4: 2c510020 sltiu r17,r2,0x0020		r17 = Reaction is a Reaction ID Check (ID acceptable check)
0005d2e8: 32c20004 andi r2,r22,0x0004
0005d2ec: 10400006 beq r2,r0,0x 0005d308		Branch if not setting Support
0005d2f0: 2482fe3a addiu r2,r4,0xfe3a		r2 = R/S/M - 0x1c6
0005d2f4: 3042ffff andi r2,r2,0xffff
0005d2f8: 2c420020 sltiu r2,r2,0x0020
0005d2fc: 10400003 beq r2,r0,0x 0005d30c		Branch if Support isn't a support ID
0005d300: 32c20008 andi r2,r22,0x0008
0005d304: 34110001 ori r17,r0,0x0001		r17 = 1 (ID is acceptable)
0005d308: 32c20008 andi r2,r22,0x0008
0005d30c: 1040 0005 beq r2,r0,0x 0005d324		Branch if not setting movement
0005d310: 3082ffff andi r2,r4,0xffff
0005d314: 2c4201e6 sltiu r2,r2,0x01e6
0005d318: 14400002 bne r2,r0,0x 0005d324		Branch if Movement isn't a Movement ID
0005d31c: 00000000 nop
0005d320: 34110001 ori r17,r0,0x0001		r17 = 1 (ID is acceptable)
0005d324: 1220 0005 beq r17,r0,0x 0005d33c	Branch if ID isn't acceptable
0005d328: 00141040 sll r2,r20,0x01		Stack Counter * 2
0005d32c: 27a30010 addiu r3,r29,0x0010		r3 = Stack Pointer + 0x10
0005d330: 00431021 addu r2,r2,r3
0005d334: a4440000 sh r4,0x0000(r2)		Store R/S/M ID
0005d338: 26940001 addiu r20,r20,0x0001		Stack Counter ++
0005d33c: 26100001 addiu r16,r16,0x0001		Ability Counter ++
0005d340: 2a020016 slti r2,r16,0x0016
0005d344: 1440ffb5 bne r2,r0,0x 0005d21c		Branch if Ability Counter < 0x16
0005d348: 00000000 nop
0005d34c: 26730001 addiu r19,r19,0x0001		Counter ++
0005d350: 2a620014 slti r2,r19,0x0014		(could limit to 0x13 to skip mime)
0005d354: 1440ff80 bne r2,r0,0x 0005d158		Branch if Counter < 0x14
0005d358: 27de0003 addiu r30,r30,0x0003		Unit's Known Abilities Pointer += 3
0005d35c: 1280000c beq r20,r0,0x 0005d390	Branch if Stack Counter = 0
0005d360: 00001021 addu r2,r0,r0		r2 = 0
0005d364: 0c0088c3 jal 0x0002230c		Random Number Generator
0005d368: 00000000 nop
0005d36c: 00540018 mult r2,r20			Random * Stack Counter
0005d370: 00001012 mflo r2			r2 = "
0005d374: 04410002 bgez r2,0x 0005d380		Branch if Random * Stack Counter is positive
0005d378: 00000000 nop
0005d37c: 24427fff addiu r2,r2,0x7fff
0005d380: 000213c3 sra r2,r2,0x0f		rand(0..Stack Counter)
0005d384: 00021040 sll r2,r2,0x01		rand(0..Stack Counter) * 2
0005d388: 03a21021 addu r2,r29,r2
0005d38c: 94420010 lhu r2,0x0010(r2)		Load chosen R/S/M
0005d390: 8fbf041c lw r31,0x041c(r29)
0005d394: 8fbe0418 lw r30,0x0418(r29)
0005d398: 8fb70414 lw r23,0x0414(r29)
0005d39c: 8fb60410 lw r22,0x0410(r29)
0005d3a0: 8fb5040c lw r21,0x040c(r29)
0005d3a4: 8fb40408 lw r20,0x0408(r29)
0005d3a8: 8fb30404 lw r19,0x0404(r29)
0005d3ac: 8fb20400 lw r18,0x0400(r29)
0005d3b0: 8fb103fc lw r17,0x03fc(r29)
0005d3b4: 8fb003f8 lw r16,0x03f8(r29)
0005d3b8: 27bd0420 addiu r29,r29,0x0420
0005d3bc: 03e00008 jr r31
0005d3c0: 00000000 nop


Return Locations

0005bd40: Calculate Unit's Abilities
0005bd58:
0005bd70: