Difference between revisions of "Big ENTD unit loading routine"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m
m
 
(3 intermediate revisions by the same user not shown)
Line 23: Line 23:
 
  0017f8f0: a0203920 sb r0,0x3920(r1)
 
  0017f8f0: a0203920 sb r0,0x3920(r1)
 
  0017f8f4: 0c0172f4 jal 0x0005cbd0 Calculate highest party level
 
  0017f8f4: 0c0172f4 jal 0x0005cbd0 Calculate highest party level
  0017f8f8: 00808021 addu r16,r4,r0 r4 is return value from 0x42880 routine
+
  0017f8f8: 00808021 addu r16,r4,r0 r4 is return value from 0x42880 routine: ENTD pointer?
 
  0017f8fc: 0c04ed64 jal 0x0013b590 ??
 
  0017f8fc: 0c04ed64 jal 0x0013b590 ??
 
  0017f900: 34040039 ori r4,r0,0x0039
 
  0017f900: 34040039 ori r4,r0,0x0039
Line 50: Line 50:
 
  0017f95c: a212018a sb r18,0x018a(r16) Store ENTD ID = 0
 
  0017f95c: a212018a sb r18,0x018a(r16) Store ENTD ID = 0
 
  0017f960: 3c018006 lui r1,0x8006
 
  0017f960: 3c018006 lui r1,0x8006
  0017f964: ac376238 sw r23,0x6238(r1) Store ENTD to load next?
+
  0017f964: ac376238 sw r23,0x6238(r1) Store Current ENTD Pointer
 
  0017f968: 92e20000 lbu r2,0x0000(r23)
 
  0017f968: 92e20000 lbu r2,0x0000(r23)
 
  0017f96c: 00000000 nop
 
  0017f96c: 00000000 nop
Line 64: Line 64:
 
  0017f994: a2020183 sb r2,0x0183(r16) store unit exists
 
  0017f994: a2020183 sb r2,0x0183(r16) store unit exists
 
  0017f998: 3c058006 lui r5,0x8006
 
  0017f998: 3c058006 lui r5,0x8006
  0017f99c: 8ca56238 lw r5,0x6238(r5) load next ENTD?
+
  0017f99c: 8ca56238 lw r5,0x6238(r5) load Current ENTD Pointer
 
  0017f9a0: 0c016a6d jal 0x0005a9b4 Unit Battle Initialization
 
  0017f9a0: 0c016a6d jal 0x0005a9b4 Unit Battle Initialization
 
  0017f9a4: 00003821 addu r7,r0,r0
 
  0017f9a4: 00003821 addu r7,r0,r0
Line 79: Line 79:
 
  0017f9d0: 0040a821 addu r21,r2,r0
 
  0017f9d0: 0040a821 addu r21,r2,r0
 
  0017f9d4: 3c028006 lui r2,0x8006
 
  0017f9d4: 3c028006 lui r2,0x8006
  0017f9d8: 8c426238 lw r2,0x6238(r2) load next ENTD?
+
  0017f9d8: 8c426238 lw r2,0x6238(r2) load Current ENTD Pointer
 
  0017f9dc: 00000000 nop
 
  0017f9dc: 00000000 nop
  0017f9e0: 90530020 lbu r19,0x0020(r2)
+
  0017f9e0: 90530020 lbu r19,0x0020(r2)                 Unit ID from ENTD
 
  0017f9e4: 340800ff ori r8,r0,0x00ff
 
  0017f9e4: 340800ff ori r8,r0,0x00ff
  0017f9e8: 16680007 bne r19,r8,0x0017fa08
+
  0017f9e8: 16680007 bne r19,r8,0x0017fa08               Branch if Unit ID is not 0xFF
 
  0017f9ec: 00000000 nop
 
  0017f9ec: 00000000 nop
 
  0017f9f0: 93a20050 lbu r2,0x0050(r29)
 
  0017f9f0: 93a20050 lbu r2,0x0050(r29)
Line 89: Line 89:
 
  0017f9f8: 00404021 addu r8,r2,r0
 
  0017f9f8: 00404021 addu r8,r2,r0
 
  0017f9fc: 2508ffff addiu r8,r8,0xffff
 
  0017f9fc: 2508ffff addiu r8,r8,0xffff
  0017fa00: 305300ff andi r19,r2,0x00ff
+
  0017fa00: 305300ff andi r19,r2,0x00ff                 r19 = 0xFF (new Unit ID)
 
  0017fa04: a3a80050 sb r8,0x0050(r29)
 
  0017fa04: a3a80050 sb r8,0x0050(r29)
 
  0017fa08: 92020005 lbu r2,0x0005(r16) load ENTD flags
 
  0017fa08: 92020005 lbu r2,0x0005(r16) load ENTD flags
Line 96: Line 96:
 
  0017fa14: 328300ff andi r3,r20,0x00ff
 
  0017fa14: 328300ff andi r3,r20,0x00ff
 
  0017fa18: 10600009 beq r3,r0,0x0017fa40 branch if not randomly/always present
 
  0017fa18: 10600009 beq r3,r0,0x0017fa40 branch if not randomly/always present
  0017fa1c: a2130161 sb r19,0x0161(r16) store ENTD ID = 0xff
+
  0017fa1c: a2130161 sb r19,0x0161(r16) store Battle Stats unit ID
 
  0017fa20: 34020040 ori r2,r0,0x0040
 
  0017fa20: 34020040 ori r2,r0,0x0040
 
  0017fa24: 1462000f bne r3,r2,0x0017fa64 branch if not randomly present
 
  0017fa24: 1462000f bne r3,r2,0x0017fa64 branch if not randomly present
Line 173: Line 173:
 
  0017fb48: 0805fed6 j 0x0017fb58
 
  0017fb48: 0805fed6 j 0x0017fb58
 
  0017fb4c: a2000183 sb r0,0x0183(r16) store unit doesn't exist, but can
 
  0017fb4c: a2000183 sb r0,0x0183(r16) store unit doesn't exist, but can
  0017fb50: 0c06036c jal 0x00180db0 ??
+
  0017fb50: 0c06036c jal 0x00180db0 [[Set Enemy Level Data]]
 
  0017fb54: 02002021 addu r4,r16,r0
 
  0017fb54: 02002021 addu r4,r16,r0
 
  0017fb58: 92040047 lbu r4,0x0047(r16)
 
  0017fb58: 92040047 lbu r4,0x0047(r16)

Latest revision as of 21:34, 6 October 2024

0017f8a0: 27bdff80 addiu r29,r29,0xff80
0017f8a4: 340800fe ori r8,r0,0x00fe
0017f8a8: afb00058 sw r16,0x0058(r29)
0017f8ac: afbf007c sw r31,0x007c(r29)
0017f8b0: afbe0078 sw r30,0x0078(r29)
0017f8b4: afb70074 sw r23,0x0074(r29)
0017f8b8: afb60070 sw r22,0x0070(r29)
0017f8bc: afb5006c sw r21,0x006c(r29)
0017f8c0: afb40068 sw r20,0x0068(r29)
0017f8c4: afb30064 sw r19,0x0064(r29)
0017f8c8: afb20060 sw r18,0x0060(r29)
0017f8cc: afb1005c sw r17,0x005c(r29)
0017f8d0: afa00040 sw r0,0x0040(r29)
0017f8d4: afa00048 sw r0,0x0048(r29)
0017f8d8: a3a80050 sb r8,0x0050(r29)
0017f8dc: 3c018019 lui r1,0x8019
0017f8e0: a0203898 sb r0,0x3898(r1)
0017f8e4: 3c018019 lui r1,0x8019
0017f8e8: a4203844 sh r0,0x3844(r1)
0017f8ec: 3c018019 lui r1,0x8019
0017f8f0: a0203920 sb r0,0x3920(r1)
0017f8f4: 0c0172f4 jal 0x0005cbd0			Calculate highest party level
0017f8f8: 00808021 addu r16,r4,r0			r4 is return value from 0x42880 routine: ENTD pointer?
0017f8fc: 0c04ed64 jal 0x0013b590			??
0017f900: 34040039 ori r4,r0,0x0039
0017f904: afa20030 sw r2,0x0030(r29)
0017f908: 2842000a slti r2,r2,0x000a
0017f90c: 10400004 beq r2,r0,0x0017f920
0017f910: 34020009 ori r2,r0,0x0009
0017f914: 8fa80030 lw r8,0x0030(r29)
0017f918: 0805fe49 j 0x0017f924
0017f91c: 00481023 subu r2,r2,r8
0017f920: 00001021 addu r2,r0,r0
0017f924: afa20030 sw r2,0x0030(r29)
0017f928: 24480007 addiu r8,r2,0x0007
0017f92c: 0000b021 addu r22,r0,r0
0017f930: 340400ff ori r4,r0,0x00ff
0017f934: 00002821 addu r5,r0,r0
0017f938: 00003021 addu r6,r0,r0
0017f93c: 0c05fefb jal 0x0017fbec				???
0017f940: afa80038 sw r8,0x0038(r29)
0017f944: 00009021 addu r18,r0,r0
0017f948: 0200b821 addu r23,r16,r0
0017f94c: 0000f021 addu r30,r0,r0
0017f950: 3c028019 lui r2,0x8019
0017f954: 244208cc addiu r2,r2,0x08cc
0017f958: 03c28021 addu r16,r30,r2
0017f95c: a212018a sb r18,0x018a(r16)			Store ENTD ID = 0
0017f960: 3c018006 lui r1,0x8006
0017f964: ac376238 sw r23,0x6238(r1)			Store Current ENTD Pointer
0017f968: 92e20000 lbu r2,0x0000(r23)
0017f96c: 00000000 nop
0017f970: 14400005 bne r2,r0,0x0017f988			branch if ENTD != 0 (same unit?)
0017f974: 02002021 addu r4,r16,r0
0017f978: 340800ff ori r8,r0,0x00ff
0017f97c: a2080001 sb r8,0x0001(r16)			store unit ID = 0xff
0017f980: 0805fee9 j 0x0017fba4
0017f984: a2080183 sb r8,0x0183(r16)			store unit cannot exist
0017f988: 00003021 addu r6,r0,r0
0017f98c: 34020001 ori r2,r0,0x0001
0017f990: a2120001 sb r18,0x0001(r16)			store unit ID = 0?
0017f994: a2020183 sb r2,0x0183(r16)			store unit exists
0017f998: 3c058006 lui r5,0x8006
0017f99c: 8ca56238 lw r5,0x6238(r5)				load Current ENTD Pointer
0017f9a0: 0c016a6d jal 0x0005a9b4				Unit Battle Initialization
0017f9a4: 00003821 addu r7,r0,r0
0017f9a8: 10400004 beq r2,r0,0x0017f9bc
0017f9ac: 02002021 addu r4,r16,r0
0017f9b0: 0c017a3a jal 0x0005e8e8				xfer r4 to r5, r4 = 0x03
0017f9b4: 26440258 addiu r4,r18,0x0258
0017f9b8: 02002021 addu r4,r16,r0
0017f9bc: 0c017822 jal 0x0005e088				Calculate unit palette/portrait
0017f9c0: 27a50028 addiu r5,r29,0x0028
0017f9c4: 02002021 addu r4,r16,r0
0017f9c8: 00002821 addu r5,r0,r0
0017f9cc: 0c0177f5 jal 0x0005dfd4				Minimum SP Capping/War Trophy Nulling/Status Initialization
0017f9d0: 0040a821 addu r21,r2,r0
0017f9d4: 3c028006 lui r2,0x8006
0017f9d8: 8c426238 lw r2,0x6238(r2)				load Current ENTD Pointer
0017f9dc: 00000000 nop
0017f9e0: 90530020 lbu r19,0x0020(r2)                  Unit ID from ENTD
0017f9e4: 340800ff ori r8,r0,0x00ff
0017f9e8: 16680007 bne r19,r8,0x0017fa08               Branch if Unit ID is not 0xFF
0017f9ec: 00000000 nop
0017f9f0: 93a20050 lbu r2,0x0050(r29)
0017f9f4: 00000000 nop
0017f9f8: 00404021 addu r8,r2,r0
0017f9fc: 2508ffff addiu r8,r8,0xffff
0017fa00: 305300ff andi r19,r2,0x00ff                  r19 = 0xFF (new Unit ID)
0017fa04: a3a80050 sb r8,0x0050(r29)
0017fa08: 92020005 lbu r2,0x0005(r16)			load ENTD flags
0017fa0c: 00000000 nop
0017fa10: 305400c0 andi r20,r2,0x00c0			
0017fa14: 328300ff andi r3,r20,0x00ff
0017fa18: 10600009 beq r3,r0,0x0017fa40			branch if not randomly/always present
0017fa1c: a2130161 sb r19,0x0161(r16)			store Battle Stats unit ID
0017fa20: 34020040 ori r2,r0,0x0040
0017fa24: 1462000f bne r3,r2,0x0017fa64			branch if not randomly present
0017fa28: 00000000 nop
0017fa2c: 0c0088c3 jal 0x0002230c                      # rand()
0017fa30: 00000000 nop
0017fa34: 30420001 andi r2,r2,0x0001
0017fa38: 1040000a beq r2,r0,0x0017fa64                # if ((rand() % 2) != 0) {     // 50% random chance   branch if branch if unit can exist?
0017fa3c: 00000000 nop
0017fa40: 340200ff ori r2,r0,0x00ff
0017fa44: a2020001 sb r2,0x0001(r16)			        store unit ID = 0xff
0017fa48: a2000183 sb r0,0x0183(r16)			        store unit doesn't exist (but can?)
0017fa4c: 3c058006 lui r5,0x8006
0017fa50: 8ca56238 lw r5,0x6238(r5)
0017fa54: 0c01791e jal 0x0005e478				Initialize Unit's X/Y+Facing/Battle Rewards
0017fa58: 02002021 addu r4,r16,r0
0017fa5c: 0805feea j 0x0017fba8                                jump to check next unit
0017fa60: 26f70028 addiu r23,r23,0x0028
0017fa64: 3c058006 lui r5,0x8006                       # }
0017fa68: 8ca56238 lw r5,0x6238(r5)
0017fa6c: 0c01791e jal 0x0005e478				Initialize Unit's X/Y+Facing/Battle Rewards
0017fa70: 02002021 addu r4,r16,r0
0017fa74: 0c05fdb1 jal 0x0017f6c4
0017fa78: 02402021 addu r4,r18,r0
0017fa7c: 10400007 beq r2,r0,0x0017fa9c
0017fa80: 340800ff ori r8,r0,0x00ff
0017fa84: 0c017a3a jal 0x0005e8e8				xfer r4 to r5, r4 = 0x03
0017fa88: 2644012c addiu r4,r18,0x012c
0017fa8c: 340200ff ori r2,r0,0x00ff
0017fa90: a2020001 sb r2,0x0001(r16)			store Unit ID = 0xff
0017fa94: 0805fee9 j 0x0017fba4
0017fa98: a2020183 sb r2,0x0183(r16)			store unit cannot exist
0017fa9c: 92020001 lbu r2,0x0001(r16)			load unit ID
0017faa0: 00000000 nop
0017faa4: 1048003f beq r2,r8,0x0017fba4			branch if unit doesn't exist?
0017faa8: 02402021 addu r4,r18,r0
0017faac: 8fa60030 lw r6,0x0030(r29)
0017fab0: 0c05fefb jal 0x0017fbec				???
0017fab4: 32a500ff andi r5,r21,0x00ff
0017fab8: 1040000c beq r2,r0,0x0017faec
0017fabc: 340200ff ori r2,r0,0x00ff
0017fac0: a2020001 sb r2,0x0001(r16)			unit ID = 0xff
0017fac4: a2000183 sb r0,0x0183(r16)			unit doesn't exist (but can)
0017fac8: 8fa80040 lw r8,0x0040(r29)
0017facc: 00000000 nop
0017fad0: 15000034 bne r8,r0,0x0017fba4
0017fad4: 00000000 nop
0017fad8: 0c017a3a jal 0x0005e8e8				xfer r4 to r5, r4 = 0x03
0017fadc: 26440064 addiu r4,r18,0x0064
0017fae0: 34080001 ori r8,r0,0x0001
0017fae4: 0805fee9 j 0x0017fba4
0017fae8: afa80040 sw r8,0x0040(r29)
0017faec: 328300ff andi r3,r20,0x00ff
0017faf0: 340200c0 ori r2,r0,0x00c0
0017faf4: 10620012 beq r3,r2,0x0017fb40			always/random present check?
0017faf8: 34110001 ori r17,r0,0x0001
0017fafc: 8fa80038 lw r8,0x0038(r29)
0017fb00: 00000000 nop
0017fb04: 02c8102a slt r2,r22,r8
0017fb08: 14400011 bne r2,r0,0x0017fb50
0017fb0c: 00008821 addu r17,r0,r0
0017fb10: 340200ff ori r2,r0,0x00ff
0017fb14: a2020001 sb r2,0x0001(r16)			store unit ID = 0xff
0017fb18: a2020183 sb r2,0x0183(r16)			store unit cannot exist
0017fb1c: 8fa80048 lw r8,0x0048(r29)
0017fb20: 00000000 nop
0017fb24: 1500001f bne r8,r0,0x0017fba4
0017fb28: 00000000 nop
0017fb2c: 0c017a3a jal 0x0005e8e8				xfer r4 to r5, r4 = 0x03
0017fb30: 264400c8 addiu r4,r18,0x00c8
0017fb34: 34080001 ori r8,r0,0x0001
0017fb38: 0805fee8 j 0x0017fba0
0017fb3c: afa80048 sw r8,0x0048(r29)
0017fb40: 340200ff ori r2,r0,0x00ff
0017fb44: a2020001 sb r2,0x0001(r16)			store unit ID = 0xff
0017fb48: 0805fed6 j 0x0017fb58
0017fb4c: a2000183 sb r0,0x0183(r16)			store unit doesn't exist, but can
0017fb50: 0c06036c jal 0x00180db0			Set Enemy Level Data
0017fb54: 02002021 addu r4,r16,r0
0017fb58: 92040047 lbu r4,0x0047(r16)
0017fb5c: 92050048 lbu r5,0x0048(r16)
0017fb60: 96070048 lhu r7,0x0048(r16)
0017fb64: 32a200ff andi r2,r21,0x00ff
0017fb68: afa20010 sw r2,0x0010(r29)
0017fb6c: 93a20028 lbu r2,0x0028(r29)
0017fb70: afb30018 sw r19,0x0018(r29)
0017fb74: afb0001c sw r16,0x001c(r29)
0017fb78: afb10020 sw r17,0x0020(r29)
0017fb7c: 000733c2 srl r6,r7,0x0f
0017fb80: 00073a02 srl r7,r7,0x08
0017fb84: 30e7000f andi r7,r7,0x000f
0017fb88: 0c023950 jal 0x0008e540
0017fb8c: afa20014 sw r2,0x0014(r29)
0017fb90: 328300ff andi r3,r20,0x00ff
0017fb94: 340200c0 ori r2,r0,0x00c0
0017fb98: 10620002 beq r3,r2,0x0017fba4
0017fb9c: 00000000 nop
0017fba0: 26d60001 addiu r22,r22,0x0001
0017fba4: 26f70028 addiu r23,r23,0x0028
0017fba8: 26520001 addiu r18,r18,0x0001
0017fbac: 2a420010 slti r2,r18,0x0010
0017fbb0: 1440ff67 bne r2,r0,0x0017f950
0017fbb4: 27de01c0 addiu r30,r30,0x01c0
0017fbb8: 8fbf007c lw r31,0x007c(r29)
0017fbbc: 8fbe0078 lw r30,0x0078(r29)
0017fbc0: 8fb70074 lw r23,0x0074(r29)
0017fbc4: 8fb60070 lw r22,0x0070(r29)
0017fbc8: 8fb5006c lw r21,0x006c(r29)
0017fbcc: 8fb40068 lw r20,0x0068(r29)
0017fbd0: 8fb30064 lw r19,0x0064(r29)
0017fbd4: 8fb20060 lw r18,0x0060(r29)
0017fbd8: 8fb1005c lw r17,0x005c(r29)
0017fbdc: 8fb00058 lw r16,0x0058(r29)
0017fbe0: 27bd0080 addiu r29,r29,0x0080
0017fbe4: 03e00008 jr r31
0017fbe8: 00000000 nop

Return Locations

0008e7e8: 0008e7b8 - 0008e808