Difference between revisions of "Construct Polygon for unit battle portrait"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m (Notes about checking unit ID and Special Portrait Unit ID)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
<font face='Courier New'>
 
<font face='Courier New'>
 +
 +
p2 = Unit ID
 
   
 
   
 
  00136bd0: 27bdffd8 addiu r29,r29,0xffd8
 
  00136bd0: 27bdffd8 addiu r29,r29,0xffd8
 
  00136bd4: afb10014 sw r17,0x0014(r29)
 
  00136bd4: afb10014 sw r17,0x0014(r29)
  00136bd8: 00808821 addu r17,r4,r0
+
  00136bd8: 00808821 addu r17,r4,r0             # portrait polygon
 
  00136bdc: afb00010 sw r16,0x0010(r29)
 
  00136bdc: afb00010 sw r16,0x0010(r29)
 
  00136be0: 00a08021 addu r16,r5,r0
 
  00136be0: 00a08021 addu r16,r5,r0
  00136be4: 02002021 addu r4,r16,r0
+
  00136be4: 02002021 addu r4,r16,r0             # unit ID
 
  00136be8: afbf0020 sw r31,0x0020(r29)
 
  00136be8: afbf0020 sw r31,0x0020(r29)
 
  00136bec: afb3001c sw r19,0x001c(r29)
 
  00136bec: afb3001c sw r19,0x001c(r29)
  00136bf0: 0c0602bf jal 0x00180afc
+
  00136bf0: 0c0602bf jal 0x00180afc             # [[Get Unit's Data Pointer]]
 
  00136bf4: afb20018 sw r18,0x0018(r29)
 
  00136bf4: afb20018 sw r18,0x0018(r29)
 
  00136bf8: 90430161 lbu r3,0x0161(r2)          # Load unit's Unit ID
 
  00136bf8: 90430161 lbu r3,0x0161(r2)          # Load unit's Unit ID
Line 17: Line 19:
 
  00136c08: 14620014 bne r3,r2,0x00136c5c      # Branch if Unit ID does not match Special Portrait Unit ID
 
  00136c08: 14620014 bne r3,r2,0x00136c5c      # Branch if Unit ID does not match Special Portrait Unit ID
 
  00136c0c: 00002021 addu r4,r0,r0
 
  00136c0c: 00002021 addu r4,r0,r0
 +
 +
giving special portrait to unit:
 
  00136c10: 00002821 addu r5,r0,r0
 
  00136c10: 00002821 addu r5,r0,r0
 
  00136c14: 34060380 ori r6,r0,0x0380          # x pos 0x380
 
  00136c14: 34060380 ori r6,r0,0x0380          # x pos 0x380
Line 23: Line 27:
 
  00136c20: 340300cf ori r3,r0,0x00cf
 
  00136c20: 340300cf ori r3,r0,0x00cf
 
  00136c24: 340200ff ori r2,r0,0x00ff
 
  00136c24: 340200ff ori r2,r0,0x00ff
  00136c28: a228000c sb r8,0x000c(r17)
+
  00136c28: a228000c sb r8,0x000c(r17)         u0 = 0xe0
  00136c2c: a223000d sb r3,0x000d(r17)
+
  00136c2c: a223000d sb r3,0x000d(r17)         v0 = 0xcf
  00136c30: a2220014 sb r2,0x0014(r17)
+
  00136c30: a2220014 sb r2,0x0014(r17)         u1 = 0xff
  00136c34: a2230015 sb r3,0x0015(r17)
+
  00136c34: a2230015 sb r3,0x0015(r17)         v1 = 0xcf
  00136c38: a228001c sb r8,0x001c(r17)
+
  00136c38: a228001c sb r8,0x001c(r17)         u2 = 0xe0
  00136c3c: a222001d sb r2,0x001d(r17)
+
  00136c3c: a222001d sb r2,0x001d(r17)         v2 = 0xff
  00136c40: a2220024 sb r2,0x0024(r17)
+
  00136c40: a2220024 sb r2,0x0024(r17)         u3 = 0xff
 
  00136c44: 0c008e63 jal 0x0002398c            [[P00 GetTpage]]
 
  00136c44: 0c008e63 jal 0x0002398c            [[P00 GetTpage]]
  00136c48: a2220025 sb r2,0x0025(r17)
+
  00136c48: a2220025 sb r2,0x0025(r17)          v3 = 0xff --> maps portrait UV to ((224,207),(255, 207),(224, 255),(255,255))
 
  00136c4c: 34040040 ori r4,r0,0x0040
 
  00136c4c: 34040040 ori r4,r0,0x0040
  00136c50: 340501fe ori r5,r0,0x01fe
+
  00136c50: 340501fe ori r5,r0,0x01fe           portrait CLUT coords @ (0x40, 0x1fe)
 
  00136c54: 0804db42 j 0x00136d08
 
  00136c54: 0804db42 j 0x00136d08
  00136c58: a6220016 sh r2,0x0016(r17)
+
  00136c58: a6220016 sh r2,0x0016(r17)          store TPAGE of special portrait
  00136c5c: 0c02339e jal 0x0008ce78
+
 
 +
giving portrait 9 to unit (not special portrait)
 +
  00136c5c: 0c02339e jal 0x0008ce78             [[Get Unique Sprite ID that matches Misc ID]] ( not sure on the name. moved it like 3 times)
 
  00136c60: 02002021 addu r4,r16,r0
 
  00136c60: 02002021 addu r4,r16,r0
 
  00136c64: 02002021 addu r4,r16,r0
 
  00136c64: 02002021 addu r4,r16,r0
  00136c68: 0c023388 jal 0x0008ce20
+
  00136c68: 0c023388 jal 0x0008ce20             [[Get Unit Misc ID By Unit Index]]
  00136c6c: 00408021 addu r16,r2,r0
+
  00136c6c: 00408021 addu r16,r2,r0             unit battle data pointer
  00136c70: 00109140 sll r18,r16,0x05
+
  00136c70: 00109140 sll r18,r16,0x05           ID * 0x20
  00136c74: 2a100008 slti r16,r16,0x0008
+
  00136c74: 2a100008 slti r16,r16,0x0008      
  00136c78: 16000009 bne r16,r0,0x00136ca0
+
  00136c78: 16000009 bne r16,r0,0x00136ca0     branch if ID < 8
  00136c7c: 00409821 addu r19,r2,r0
+
  00136c7c: 00409821 addu r19,r2,r0             unit Misc. ID
 
  00136c80: 00002021 addu r4,r0,r0
 
  00136c80: 00002021 addu r4,r0,r0
 
  00136c84: 00002821 addu r5,r0,r0
 
  00136c84: 00002821 addu r5,r0,r0
Line 50: Line 56:
 
  00136c8c: 0c008e63 jal 0x0002398c            [[P00 GetTpage]]
 
  00136c8c: 0c008e63 jal 0x0002398c            [[P00 GetTpage]]
 
  00136c90: 34070120 ori r7,r0,0x0120          # 0x20 is ignored. point to item.bin
 
  00136c90: 34070120 ori r7,r0,0x0120          # 0x20 is ignored. point to item.bin
  00136c94: a6220016 sh r2,0x0016(r17)
+
  00136c94: a6220016 sh r2,0x0016(r17)         # store TPAGE
 
  00136c98: 0804db2e j 0x00136cb8
 
  00136c98: 0804db2e j 0x00136cb8
  00136c9c: 00009021 addu r18,r0,r0
+
  00136c9c: 00009021 addu r18,r0,r0             if unit has portrait 9, unique sprite ID is irrelevant (always points to first portrait; on ITEM.BIN)
 +
 
 +
giving portraits 1 -> 8
 
  00136ca0: 00002021 addu r4,r0,r0
 
  00136ca0: 00002021 addu r4,r0,r0
 
  00136ca4: 00002821 addu r5,r0,r0
 
  00136ca4: 00002821 addu r5,r0,r0
 
  00136ca8: 34060340 ori r6,r0,0x0340
 
  00136ca8: 34060340 ori r6,r0,0x0340
 
  00136cac: 0c008e63 jal 0x0002398c            [[P00 GetTpage]]
 
  00136cac: 0c008e63 jal 0x0002398c            [[P00 GetTpage]]
  00136cb0: 34070100 ori r7,r0,0x0100          # points to wldface.bin (3)
+
  00136cb0: 34070100 ori r7,r0,0x0100          # points to battle portrait list
  00136cb4: a6220016 sh r2,0x0016(r17)
+
  00136cb4: a6220016 sh r2,0x0016(r17)         # store TPAGE
  00136cb8: 3264000f andi r4,r19,0x000f
+
 
 +
all generic portraits
 +
  00136cb8: 3264000f andi r4,r19,0x000f         # misc ID
 
  00136cbc: 34020080 ori r2,r0,0x0080
 
  00136cbc: 34020080 ori r2,r0,0x0080
  00136cc0: 26430020 addiu r3,r18,0x0020
+
  00136cc0: 26430020 addiu r3,r18,0x0020       # portrait offset bottom
  00136cc4: a222000c sb r2,0x000c(r17)
+
  00136cc4: a222000c sb r2,0x000c(r17)         # u0 = 0x80
  00136cc8: a2220014 sb r2,0x0014(r17)
+
  00136cc8: a2220014 sb r2,0x0014(r17)         # u1 = 0x80
  00136ccc: 34020050 ori r2,r0,0x0050
+
  00136ccc: 34020050 ori r2,r0,0x0050          
  00136cd0: a2230015 sb r3,0x0015(r17)
+
  00136cd0: a2230015 sb r3,0x0015(r17)         # v1 = portrait offset bottom
  00136cd4: a222001c sb r2,0x001c(r17)
+
  00136cd4: a222001c sb r2,0x001c(r17)         # u2 = 0x50
  00136cd8: a2220024 sb r2,0x0024(r17)
+
  00136cd8: a2220024 sb r2,0x0024(r17)         # u3 = 0x50
 
  00136cdc: 92220015 lbu r2,0x0015(r17)
 
  00136cdc: 92220015 lbu r2,0x0015(r17)
  00136ce0: 00042100 sll r4,r4,0x04
+
  00136ce0: 00042100 sll r4,r4,0x04             # misc ID * 0x10
  00136ce4: a2230025 sb r3,0x0025(r17)
+
  00136ce4: a2230025 sb r3,0x0025(r17)         # v3 = portrait offset bottom
 
  00136ce8: 92230025 lbu r3,0x0025(r17)
 
  00136ce8: 92230025 lbu r3,0x0025(r17)
  00136cec: 340501ea ori r5,r0,0x01ea
+
  00136cec: 340501ea ori r5,r0,0x01ea           # 0x01ea (Clut coordinates ([misc ID],0x1ea))
  00136cf0: a232000d sb r18,0x000d(r17)
+
  00136cf0: a232000d sb r18,0x000d(r17)         # v0 = portrait offset top
  00136cf4: a232001d sb r18,0x001d(r17)
+
  00136cf4: a232001d sb r18,0x001d(r17)         # v2 = portrait offset top
  00136cf8: 2442ffff addiu r2,r2,0xffff
+
  00136cf8: 2442ffff addiu r2,r2,0xffff         #
 
  00136cfc: 2463ffff addiu r3,r3,0xffff
 
  00136cfc: 2463ffff addiu r3,r3,0xffff
 
  00136d00: a2220015 sb r2,0x0015(r17)
 
  00136d00: a2220015 sb r2,0x0015(r17)
  00136d04: a2230025 sb r3,0x0025(r17)
+
  00136d04: a2230025 sb r3,0x0025(r17)         # subtract 1 from v1 and v3 (...? uh, okay. bit late eh?)
 +
 
 +
all return:
 
  00136d08: 0c008e95 jal 0x00023a54            [[P01 GetClut]]
 
  00136d08: 0c008e95 jal 0x00023a54            [[P01 GetClut]]
 
  00136d0c: 00000000 nop
 
  00136d0c: 00000000 nop
  00136d10: a622000e sh r2,0x000e(r17)
+
  00136d10: a622000e sh r2,0x000e(r17)         Store CLUT of portrait
 
  00136d14: 8fbf0020 lw r31,0x0020(r29)
 
  00136d14: 8fbf0020 lw r31,0x0020(r29)
 
  00136d18: 8fb3001c lw r19,0x001c(r29)
 
  00136d18: 8fb3001c lw r19,0x001c(r29)

Latest revision as of 02:08, 23 September 2024

p2 = Unit ID

00136bd0: 27bdffd8 addiu r29,r29,0xffd8
00136bd4: afb10014 sw r17,0x0014(r29)
00136bd8: 00808821 addu r17,r4,r0             # portrait polygon
00136bdc: afb00010 sw r16,0x0010(r29)
00136be0: 00a08021 addu r16,r5,r0
00136be4: 02002021 addu r4,r16,r0             # unit ID
00136be8: afbf0020 sw r31,0x0020(r29)
00136bec: afb3001c sw r19,0x001c(r29)
00136bf0: 0c0602bf jal 0x00180afc             # Get Unit's Data Pointer
00136bf4: afb20018 sw r18,0x0018(r29)
00136bf8: 90430161 lbu r3,0x0161(r2)          # Load unit's Unit ID
00136bfc: 3c028005 lui r2,0x8005
00136c00: 9042d954 lbu r2,-0x26ac(r2)         # Check Special Portrait Unit ID at 0x8004D954
00136c04: 00000000 nop
00136c08: 14620014 bne r3,r2,0x00136c5c       # Branch if Unit ID does not match Special Portrait Unit ID
00136c0c: 00002021 addu r4,r0,r0

giving special portrait to unit:

00136c10: 00002821 addu r5,r0,r0
00136c14: 34060380 ori r6,r0,0x0380           # x pos 0x380
00136c18: 34070100 ori r7,r0,0x0100           # y pos 0x100 (point to item.bin)
00136c1c: 340800e0 ori r8,r0,0x00e0
00136c20: 340300cf ori r3,r0,0x00cf
00136c24: 340200ff ori r2,r0,0x00ff
00136c28: a228000c sb r8,0x000c(r17)          u0 = 0xe0
00136c2c: a223000d sb r3,0x000d(r17)          v0 = 0xcf
00136c30: a2220014 sb r2,0x0014(r17)          u1 = 0xff
00136c34: a2230015 sb r3,0x0015(r17)          v1 = 0xcf
00136c38: a228001c sb r8,0x001c(r17)          u2 = 0xe0
00136c3c: a222001d sb r2,0x001d(r17)          v2 = 0xff
00136c40: a2220024 sb r2,0x0024(r17)          u3 = 0xff
00136c44: 0c008e63 jal 0x0002398c             P00 GetTpage
00136c48: a2220025 sb r2,0x0025(r17)          v3 = 0xff --> maps portrait UV to ((224,207),(255, 207),(224, 255),(255,255))
00136c4c: 34040040 ori r4,r0,0x0040
00136c50: 340501fe ori r5,r0,0x01fe           portrait CLUT coords @ (0x40, 0x1fe)
00136c54: 0804db42 j 0x00136d08
00136c58: a6220016 sh r2,0x0016(r17)          store TPAGE of special portrait

giving portrait 9 to unit (not special portrait)

00136c5c: 0c02339e jal 0x0008ce78             Get Unique Sprite ID that matches Misc ID ( not sure on the name. moved it like 3 times)
00136c60: 02002021 addu r4,r16,r0
00136c64: 02002021 addu r4,r16,r0
00136c68: 0c023388 jal 0x0008ce20             Get Unit Misc ID By Unit Index
00136c6c: 00408021 addu r16,r2,r0             unit battle data pointer
00136c70: 00109140 sll r18,r16,0x05           ID * 0x20
00136c74: 2a100008 slti r16,r16,0x0008        
00136c78: 16000009 bne r16,r0,0x00136ca0      branch if ID < 8 
00136c7c: 00409821 addu r19,r2,r0             unit Misc. ID
00136c80: 00002021 addu r4,r0,r0
00136c84: 00002821 addu r5,r0,r0
00136c88: 34060380 ori r6,r0,0x0380
00136c8c: 0c008e63 jal 0x0002398c             P00 GetTpage
00136c90: 34070120 ori r7,r0,0x0120           # 0x20 is ignored. point to item.bin
00136c94: a6220016 sh r2,0x0016(r17)          # store TPAGE
00136c98: 0804db2e j 0x00136cb8
00136c9c: 00009021 addu r18,r0,r0             if unit has portrait 9, unique sprite ID is irrelevant (always points to first portrait; on ITEM.BIN)

giving portraits 1 -> 8

00136ca0: 00002021 addu r4,r0,r0
00136ca4: 00002821 addu r5,r0,r0
00136ca8: 34060340 ori r6,r0,0x0340
00136cac: 0c008e63 jal 0x0002398c             P00 GetTpage
00136cb0: 34070100 ori r7,r0,0x0100           # points to battle portrait list
00136cb4: a6220016 sh r2,0x0016(r17)          # store TPAGE

all generic portraits

00136cb8: 3264000f andi r4,r19,0x000f         # misc ID
00136cbc: 34020080 ori r2,r0,0x0080
00136cc0: 26430020 addiu r3,r18,0x0020        # portrait offset bottom
00136cc4: a222000c sb r2,0x000c(r17)          # u0 = 0x80
00136cc8: a2220014 sb r2,0x0014(r17)          # u1 = 0x80
00136ccc: 34020050 ori r2,r0,0x0050           
00136cd0: a2230015 sb r3,0x0015(r17)          # v1 = portrait offset bottom
00136cd4: a222001c sb r2,0x001c(r17)          # u2 = 0x50
00136cd8: a2220024 sb r2,0x0024(r17)          # u3 = 0x50
00136cdc: 92220015 lbu r2,0x0015(r17)
00136ce0: 00042100 sll r4,r4,0x04             # misc ID * 0x10
00136ce4: a2230025 sb r3,0x0025(r17)          # v3 = portrait offset bottom
00136ce8: 92230025 lbu r3,0x0025(r17)
00136cec: 340501ea ori r5,r0,0x01ea           # 0x01ea (Clut coordinates ([misc ID],0x1ea))
00136cf0: a232000d sb r18,0x000d(r17)         # v0 = portrait offset top
00136cf4: a232001d sb r18,0x001d(r17)         # v2 = portrait offset top
00136cf8: 2442ffff addiu r2,r2,0xffff         #
00136cfc: 2463ffff addiu r3,r3,0xffff
00136d00: a2220015 sb r2,0x0015(r17)
00136d04: a2230025 sb r3,0x0025(r17)          # subtract 1 from v1 and v3 (...? uh, okay. bit late eh?)

all return:

00136d08: 0c008e95 jal 0x00023a54             P01 GetClut
00136d0c: 00000000 nop
00136d10: a622000e sh r2,0x000e(r17)          Store CLUT of portrait
00136d14: 8fbf0020 lw r31,0x0020(r29)
00136d18: 8fb3001c lw r19,0x001c(r29)
00136d1c: 8fb20018 lw r18,0x0018(r29)
00136d20: 8fb10014 lw r17,0x0014(r29)
00136d24: 8fb00010 lw r16,0x0010(r29)
00136d28: 27bd0028 addiu r29,r29,0x0028
00136d2c: 03e00008 jr r31
00136d30: 00000000 nop