Generate Party Unit In Empty Slot
Jump to navigation
Jump to search
# ROUTINE: GENERATE PARTY UNIT IN EMPTY SLOT # Parameters: # r4 = unitType (Parameter for Out of Battle Unit Generation) # 0 = Male # 1 = Female # 2 = Ramza (Initial Ch.1) # 3 = Monster # Returns: # r2 = (Unit index) of generated unit, if an empty slot was found to generate the unit; # -1, if no empty slots were available and no unit was created 80059ed4: 27bdff88 addiu r29,r29,-0x0078 80059ed8: afb20068 sw r18,0x0068(r29) 80059edc: 00809021 addu r18,r4,r0 # unitType 80059ee0: afb3006c sw r19,0x006c(r29) 80059ee4: 00009821 addu r19,r0,r0 # 0 80059ee8: afb00060 sw r16,0x0060(r29) 80059eec: 00008021 addu r16,r0,r0 # unitIndex = 0 80059ef0: afb10064 sw r17,0x0064(r29) 80059ef4: 27b10010 addiu r17,r29,0x0010 # unitArray (unitArrayPtr) 80059ef8: afbf0070 sw r31,0x0070(r29) # do { 80059efc: 0c0166bc jal 0x80059af0 # partyUnit = Get Party Data Pointer (unitIndex); 80059f00: 02002021 addu r4,r16,r0 80059f04: ae220000 sw r2,0x0000(r17) # unitArray[unitIndex] = partyUnit (*unitArrayPtr = partyUnit) 80059f08: 26100001 addiu r16,r16,0x0001 # unitIndex = unitIndex + 1 80059f0c: 2a020014 slti r2,r16,0x0014 80059f10: 1440fffa bne r2,r0,0x80059efc 80059f14: 26310004 addiu r17,r17,0x0004 # (unitArrayPtr = unitArrayPtr + 4) # } while (unitIndex < 20); 80059f18: 00008021 addu r16,r0,r0 # unitIndex = 0 80059f1c: 340500ff ori r5,r0,0x00ff # UNIT_INDEX_DOES_NOT_EXIST (0xff) 80059f20: 27a40010 addiu r4,r29,0x0010 # unitArray (unitArrayPtr) # do { 80059f24: 8c830000 lw r3,0x0000(r4) # unitArray[unitIndex] 80059f28: 00000000 nop 80059f2c: 90620001 lbu r2,0x0001(r3) # unitArray[unitIndex].UnitIndex 80059f30: 00000000 nop 80059f34: 1445000a bne r2,r5,0x80059f60 # if (unitArray[unitIndex].UnitIndex == UNIT_INDEX_DOES_NOT_EXIST) { 80059f38: 00000000 nop 80059f3c: a0700001 sb r16,0x0001(r3) # unitArray[unitIndex].UnitIndex = unitIndex 80059f40: 8c820000 lw r2,0x0000(r4) # unitArray[unitIndex] 80059f44: 00000000 nop 80059f48: a0530003 sb r19,0x0003(r2) # unitArray[unitIndex].Palette = 0 // Player/default palette 80059f4c: 8c840000 lw r4,0x0000(r4) # unitArray[unitIndex] 80059f50: 0c0167ff jal 0x80059ffc # Out of Battle Unit Generation (unitArray[unitIndex], unitType); 80059f54: 02402821 addu r5,r18,r0 80059f58: 080167dd j 0x80059f74 80059f5c: 02001021 addu r2,r16,r0 # return unitIndex; # } 80059f60: 26100001 addiu r16,r16,0x0001 # unitIndex = unitIndex + 1 80059f64: 2a020010 slti r2,r16,0x0010 80059f68: 1440ffee bne r2,r0,0x80059f24 80059f6c: 24840004 addiu r4,r4,0x0004 # (unitArrayPtr = unitArrayPtr + 4) # } while (unitIndex < 16); 80059f70: 2402ffff addiu r2,r0,-0x0001 # return -1; 80059f74: 8fbf0070 lw r31,0x0070(r29) 80059f78: 8fb3006c lw r19,0x006c(r29) 80059f7c: 8fb20068 lw r18,0x0068(r29) 80059f80: 8fb10064 lw r17,0x0064(r29) 80059f84: 8fb00060 lw r16,0x0060(r29) 80059f88: 27bd0078 addiu r29,r29,0x0078 80059f8c: 03e00008 jr r31 80059f90: 00000000 nop
Return Locations
SCUS_942.21 80042ad4 - ? 0x42ab0 80059e40 - Create Monster Egg WORLD.BIN 801209f0 - 00120a64 - 00120af8