Difference between revisions of "Calculate Learned Abilities"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
(Created page with " Calculate Learned Abilities 0005ce74: 27bdffd0 addiu r29,r29,0xffd0 0005ce78: 00804021 addu r8,r4,r0 r8 = Unit's Data Pointer 0005ce7c: 00a03821 addu r7,r5,r0 Job ID = J...")
 
 
(One intermediate revision by the same user not shown)
Line 108: Line 108:
 
  0005d01c: 26040007 addiu r4,r16,0x0007
 
  0005d01c: 26040007 addiu r4,r16,0x0007
 
  0005d020: 34120001 ori r18,r0,0x0001 r18 = 1 (Ability Learned)
 
  0005d020: 34120001 ori r18,r0,0x0001 r18 = 1 (Ability Learned)
*Starting here is code that can be deleted, plus above Counter check/addition*
+
(*Starting here is code that can be deleted, plus above Counter check/addition*)
 
  0005d024: 000420c3 sra r4,r4,0x03 Counter / 8
 
  0005d024: 000420c3 sra r4,r4,0x03 Counter / 8
 
  0005d028: 02842821 addu r5,r20,r4 Known Abilities Pointer + Counter / 8 (byte to grab)
 
  0005d028: 02842821 addu r5,r20,r4 Known Abilities Pointer + Counter / 8 (byte to grab)
Line 118: Line 118:
 
  0005d040: 00621825 or r3,r3,r2 Enable Ability
 
  0005d040: 00621825 or r3,r3,r2 Enable Ability
 
  0005d044: a0a30000 sb r3,0x0000(r5) Store unit's new Known Abilities
 
  0005d044: a0a30000 sb r3,0x0000(r5) Store unit's new Known Abilities
*End*
+
(*End*)
 
  0005d048: 1240000d beq r18,r0,0x 0005d080 Branch if an Ability wasn't learned
 
  0005d048: 1240000d beq r18,r0,0x 0005d080 Branch if an Ability wasn't learned
 
  0005d04c: 00000000 nop (copy-paste code)
 
  0005d04c: 00000000 nop (copy-paste code)
Line 148: Line 148:
 
  0005d0b4: 03e00008 jr r31
 
  0005d0b4: 03e00008 jr r31
 
  0005d0b8: 00000000 nop
 
  0005d0b8: 00000000 nop
 +
 +
 +
== Return Locations ==
 +
 +
0005bbe4: [[Calculate Unit's Abilities]]
 +
0005bc90: ^^

Latest revision as of 04:21, 1 March 2012

Calculate Learned Abilities
0005ce74: 27bdffd0 addiu r29,r29,0xffd0
0005ce78: 00804021 addu r8,r4,r0		r8 = Unit's Data Pointer
0005ce7c: 00a03821 addu r7,r5,r0		Job ID = Job Counter + 0x4a/0x4b
0005ce80: afb60028 sw r22,0x0028(r29)
0005ce84: 0000b021 addu r22,r0,r0		r22 = 0 (Can Learn)
0005ce88: 24e9ffb6 addiu r9,r7,0xffb6		Job Counter = Job Counter - 0x4a
0005ce8c: 3402004a ori r2,r0,0x004a		r2 = 0x4a
0005ce90: afbf002c sw r31,0x002c(r29)
0005ce94: afb50024 sw r21,0x0024(r29)
0005ce98: afb40020 sw r20,0x0020(r29)
0005ce9c: afb3001c sw r19,0x001c(r29)
0005cea0: afb20018 sw r18,0x0018(r29)
0005cea4: afb10014 sw r17,0x0014(r29)
0005cea8: 14e20011 bne r7,r2,0x 0005cef0		Branch if Job ID != Base Job
0005ceac: afb00010 sw r16,0x0010(r29)
0005ceb0: 91030000 lbu r3,0x0000(r8)		Load Unit's Sprite Set
0005ceb4: 00000000 nop
0005ceb8: 2462ff80 addiu r2,r3,0xff80		Sprite Set - 0x80 (no special jobs)
0005cebc: 304200ff andi r2,r2,0x00ff
0005cec0: 2c420002 sltiu r2,r2,0x0002
0005cec4: 14400016 bne r2,r0,0x 0005cf20		Branch if Unit is a generic Male/Female
0005cec8: 306300ff andi r3,r3,0x00ff
0005cecc: 34020082 ori r2,r0,0x0082
0005ced0: 14620004 bne r3,r2,0x 0005cee4		Branch if Unit isn't a Monster
0005ced4: 00000000 nop
0005ced8: 91070003 lbu r7,0x0003(r8)		Load Unit's Job ID
0005cedc: 080173c8 j 0x 0005cf20
0005cee0: 00000000 nop
0005cee4: 91070000 lbu r7,0x0000(r8)		Load Unit's Sprite Set
0005cee8: 080173c8 j 0x 0005cf20
0005ceec: 00000000 nop
0005cef0: 3c020080 lui r2,0x0080		Counter = 0x800000
0005cef4: 01228007 srav r16,r2,r9		Counter >> Job Counter
0005cef8: 91020096 lbu r2,0x0096(r8)		Load Unit's Unlocked Jobs 1-8
0005cefc: 91030097 lbu r3,0x0097(r8)		Load Unit's Unlocked Jobs 9-16
0005cf00: 91040098 lbu r4,0x0098(r8)		Load Unit's Unlocked Jobs 17-20
0005cf04: 00021400 sll r2,r2,0x10
0005cf08: 00031a00 sll r3,r3,0x08
0005cf0c: 00431021 addu r2,r2,r3
0005cf10: 00442821 addu r5,r2,r4		r5 = Complete Unlocked Jobs
0005cf14: 00b01024 and r2,r5,r16
0005cf18: 104 0005d beq r2,r0,0x 0005d090		Branch if Job isn't unlocked
0005cf1c: 00000000 nop
0005cf20: 91030006 lbu r3,0x0006(r8)		Load Unit's Gender Byte
0005cf24: 3402005b ori r2,r0,0x005b		r2 = 5b
0005cf28: 14e20004 bne r7,r2,0x 0005cf3c		Branch if Job ID != 0x5b (Bard)
0005cf2c: 3402005c ori r2,r0,0x005c		r2 = 5c
0005cf30: 30620040 andi r2,r3,0x0040
0005cf34: 144 00056 bne r2,r0,0x 0005d090		Branch if Unit is Female
0005cf38: 3402005c ori r2,r0,0x005c		r2 = 5c
0005cf3c: 14e20003 bne r7,r2,0x 0005cf4c		Branch if Job ID != 0x5c (Dancer)
0005cf40: 30620080 andi r2,r3,0x0080
0005cf44: 144 00052 bne r2,r0,0x 0005d090		Branch if Unit is Male
0005cf48: 00000000 nop
0005cf4c: 91020003 lbu r2,0x0003(r8)		Load Unit's Job ID
0005cf50: 00000000 nop
0005cf54: 14e20007 bne r7,r2,0x 0005cf74		Branch if Current Job ID != Unit's Job ID
0005cf58: 00071040 sll r2,r7,0x01		ID * 2
0005cf5c: 90c2001d lbu r2,0x001d(r6)		Load ENTD Primary Skillset
0005cf60: 91150012 lbu r21,0x0012(r8)		Load Unit's Primary Skillset
0005cf64: 1440000a bne r2,r0,0x 0005cf90		Branch if ENTD Primary Skillset != 0
0005cf68: 00008021 addu r16,r0,r0		Counter = 0
0005cf6c: 080173e4 j 0x 0005cf90
0005cf70: 34160001 ori r22,r0,0x0001		r22 = 1 (Can't Learn Normally)
0005cf74: 00471021 addu r2,r2,r7		ID * 3
0005cf78: 3c038006 lui r3,0x8006
0005cf7c: 8c636194 lw r3,0x6194(r3)		Load Job Data Pointer
0005cf80: 00021100 sll r2,r2,0x04		ID * 48
0005cf84: 00431021 addu r2,r2,r3
0005cf88: 90550000 lbu r21,0x0000(r2)		Load Job's Skillset
0005cf8c: 00008021 addu r16,r0,r0		Counter = 0
0005cf90: 00091040 sll r2,r9,0x01		Job Counter * 2
0005cf94: 00489821 addu r19,r2,r8		r19 = Unit's Data Pointer + Job Counter * 2
0005cf98: 00491021 addu r2,r2,r9		Job Counter * 3
0005cf9c: 00481021 addu r2,r2,r8		r2 = Unit's Data Pointer + Job Counter * 3
0005cfa0: 24540099 addiu r20,r2,0x0099		r20 = Unit's Known Abilities Pointer
0005cfa4: 00009021 addu r18,r0,r0		r18 = 0 (No Ability Learned)
0005cfa8: 02a02021 addu r4,r21,r0		r4 = Job's Skillset
0005cfac: 0c01695a jal 0x 0005a568		Load Ability From Skillset
0005cfb0: 02002821 addu r5,r16,r0		r5 = Counter
0005cfb4: 3042ffff andi r2,r2,0xffff
0005cfb8: 10400031 beq r2,r0,0x 0005d080		Branch if Ability ID = 0
0005cfbc: 000218c0 sll r3,r2,0x03		ID * 8
0005cfc0: 3c028006 lui r2,0x8006
0005cfc4: 2442ebf0 addiu r2,r2,0xebf0		r2 = Ability Data 1 Pointer
0005cfc8: 00628821 addu r17,r3,r2
0005cfcc: 92250002 lbu r5,0x0002(r17)		Load Ability's Chance to Learn
0005cfd0: 12c00003 beq r22,r0,0x 0005cfe0	Branch if Unit Can Learn abilities
0005cfd4: 00000000 nop
0005cfd8: 08017412 j 0x 0005d048
0005cfdc: 34120001 ori r18,r0,0x0001		r18 = 1 (Ability Learned)
0005cfe0: 0c017833 jal 0x 0005e0cc		Check if Random >= Chance
0005cfe4: 34040064 ori r4,r0,0x0064		Hit% = 100
0005cfe8: 14400017 bne r2,r0,0x 0005d048		Branch if Ability wasn't learned
0005cfec: 00000000 nop
0005cff0: 96230000 lhu r3,0x0000(r17)		Load Ability's JP Cost
0005cff4: 966200dc lhu r2,0x00dc(r19)		Load Unit's Current JP
0005cff8: 00000000 nop
0005cffc: 0043102b sltu r2,r2,r3
0005d000: 14400011 bne r2,r0,0x 0005d048		Branch if JP < JP Cost
0005d004: 02002021 addu r4,r16,r0		r4 = Counter
0005d008: 966200dc lhu r2,0x00dc(r19)		Load Unit's Current JP
0005d00c: 00000000 nop
0005d010: 00431023 subu r2,r2,r3		JP - JP Cost
0005d014: 06010002 bgez r16,0x 0005d020		Branch if Counter >= 0
0005d018: a66200dc sh r2,0x00dc(r19)		Store Unit's new Current JP
0005d01c: 26040007 addiu r4,r16,0x0007
0005d020: 34120001 ori r18,r0,0x0001		r18 = 1 (Ability Learned)
(*Starting here is code that can be deleted, plus above Counter check/addition*)
0005d024: 000420c3 sra r4,r4,0x03		Counter / 8
0005d028: 02842821 addu r5,r20,r4		Known Abilities Pointer + Counter / 8 (byte to grab)
0005d02c: 000420c0 sll r4,r4,0x03		Counter / 8 * 8
0005d030: 02042023 subu r4,r16,r4		Counter - Counter / 8 * 8 (current Ability)
0005d034: 34020080 ori r2,r0,0x0080		r2 = 0x80
0005d038: 90a30000 lbu r3,0x0000(r5)		Load Unit's Known Abilities
0005d03c: 00821007 srav r2,r2,r4		0x80 / 2^(current Ability Counter)
0005d040: 00621825 or r3,r3,r2			Enable Ability
0005d044: a0a30000 sb r3,0x0000(r5)		Store unit's new Known Abilities
(*End*)
0005d048: 1240000d beq r18,r0,0x 0005d080	Branch if an Ability wasn't learned
0005d04c: 00000000 nop				(copy-paste code)
0005d050: 06010002 bgez r16,0x 0005d05c		Branch if Counter is positive
0005d054: 02002021 addu r4,r16,r0		r4 = Counter
0005d058: 26040007 addiu r4,r16,0x0007
0005d05c: 000420c3 sra r4,r4,0x03		Counter / 8
0005d060: 02842821 addu r5,r20,r4		Known Abilities Pointer + Counter / 8
0005d064: 000420c0 sll r4,r4,0x03		Counter / 8 * 8
0005d068: 02042023 subu r4,r16,r4		Counter - Counter / 8 * 8
0005d06c: 34020080 ori r2,r0,0x0080		r2 = 0x80
0005d070: 90a30000 lbu r3,0x0000(r5)		Load Unit's Known Abilities
0005d074: 00821007 srav r2,r2,r4		0x80 / 2^(current Ability Counter)
0005d078: 00621825 or r3,r3,r2			Enable Ability
0005d07c: a0a30000 sb r3,0x0000(r5)		Store Unit's new Known Abilities
0005d080: 26100001 addiu r16,r16,0x0001		Counter ++
0005d084: 2a020018 slti r2,r16,0x0018
0005d088: 1440ffc7 bne r2,r0,0x 0005cfa8		Branch if Counter < 0x18
0005d08c: 00009021 addu r18,r0,r0		
0005d090: 8fbf002c lw r31,0x002c(r29)
0005d094: 8fb60028 lw r22,0x0028(r29)
0005d098: 8fb50024 lw r21,0x0024(r29)
0005d09c: 8fb40020 lw r20,0x0020(r29)
0005d0a0: 8fb3001c lw r19,0x001c(r29)
0005d0a4: 8fb20018 lw r18,0x0018(r29)
0005d0a8: 8fb10014 lw r17,0x0014(r29)
0005d0ac: 8fb00010 lw r16,0x0010(r29)
0005d0b0: 27bd0030 addiu r29,r29,0x0030
0005d0b4: 03e00008 jr r31
0005d0b8: 00000000 nop


Return Locations

0005bbe4: Calculate Unit's Abilities
0005bc90: ^^