Out of Battle Unit Generation
Jump to navigation
Jump to search
Out of Battle Unit Generation 00059ffc: 27bdffc8 addiu r29,r29,0xffc8 0005a000: afb20018 sw r18,0x0018(r29) 0005a004: 00809021 addu r18,r4,r0 r18 = Party Data Pointer 0005a008: afb50024 sw r21,0x0024(r29) 0005a00c: 00a0a821 addu r21,r5,r0 r21 = Unit Type 0005a010: afbf0034 sw r31,0x0034(r29) 0005a014: afbe0030 sw r30,0x0030(r29) 0005a018: afb7002c sw r23,0x002c(r29) 0005a01c: afb60028 sw r22,0x0028(r29) 0005a020: afb40020 sw r20,0x0020(r29) 0005a024: afb3001c sw r19,0x001c(r29) 0005a028: afb10014 sw r17,0x0014(r29) 0005a02c: 16a00006 bne r21,r0,0x0005a048 Branch if Not creating a male 0005a030: afb00010 sw r16,0x0010(r29) 0005a034: 34174100 ori r23,r0,0x4100 Name Flags = 0x4100 0005a038: 34160100 ori r22,r0,0x0100 Name Modifier = 0x100 0005a03c: 34020080 ori r2,r0,0x0080 Sprite Set = Generic Male (Gender = Male) 0005a040: 08016822 j 0x0005a088 0005a044: a2420000 sb r2,0x0000(r18) Store Party Sprite Set 0005a048: 34020001 ori r2,r0,0x0001 0005a04c: 16a20006 bne r21,r2,0x0005a068 Branch if Not creating a Female 0005a050: 34174200 ori r23,r0,0x4200 Name Flags = 0x4200 0005a054: 34160200 ori r22,r0,0x0200 Name Modifier = 0x200 0005a058: 34020081 ori r2,r0,0x0081 Sprite Set = Generic Female 0005a05c: a2420000 sb r2,0x0000(r18) Store Party Sprite Set 0005a060: 08016822 j 0x0005a088 0005a064: 34020040 ori r2,r0,0x0040 Gender = Female 0005a068: 34020003 ori r2,r0,0x0003 0005a06c: 16a2000a bne r21,r2,0x0005a098 Branch if Not creating a Monster 0005a070: 34174000 ori r23,r0,0x4000 Name Flags = 0x4000 0005a074: 34174300 ori r23,r0,0x4300 Name Flags = 0x4300 0005a078: 34160300 ori r22,r0,0x0300 Name Modifier = 0x300 0005a07c: 34020082 ori r2,r0,0x0082 Sprite Set = Monster 0005a080: a2420000 sb r2,0x0000(r18) Store Party Sprite Set 0005a084: 34020020 ori r2,r0,0x0020 Gender = Monster 0005a088: a2420004 sb r2,0x0004(r18) Store Party Gender Byte 0005a08c: 3402004a ori r2,r0,0x004a 0005a090: 0801682d j 0x0005a0b4 0005a094: a2420002 sb r2,0x0002(r18) Store Job ID = Squire 0005a098: 34150002 ori r21,r0,0x0002 Unit Type = Ramza 0005a09c: 0000b021 addu r22,r0,r0 Name Modifier = 0 0005a0a0: 34030001 ori r3,r0,0x0001 Sprite Set/Job ID = C1 Ramza 0005a0a4: 34020080 ori r2,r0,0x0080 Gender = Male 0005a0a8: a2430000 sb r3,0x0000(r18) Store Party Sprite Set 0005a0ac: a2420004 sb r2,0x0004(r18) Store Party Gender Byte 0005a0b0: a2430002 sb r3,0x0002(r18) Store Party Job ID 0005a0b4: 0c0088c3 jal 0x0002230c Random Number Generator 0005a0b8: 00000000 nop 0005a0bc: 000218c0 sll r3,r2,0x03 Random * 8 0005a0c0: 00621821 addu r3,r3,r2 Random * 9 0005a0c4: 000318c0 sll r3,r3,0x03 Random * 72 0005a0c8: 00621821 addu r3,r3,r2 Random * 73 0005a0cc: 00031080 sll r2,r3,0x02 Random * 292 0005a0d0: 00621821 addu r3,r3,r2 Random * 365 0005a0d4: 04610003 bgez r3,0x0005a0e4 Branch if Random is positive 0005a0d8: 000383c3 sra r16,r3,0x0f rand(0..364) 0005a0dc: 24637fff addiu r3,r3,0x7fff 0005a0e0: 000383c3 sra r16,r3,0x0f 0005a0e4: 26100001 addiu r16,r16,0x0001 rand(0..364) + 1 (random birthday) 0005a0e8: 02008821 addu r17,r16,r0 r17 = Birthday 0005a0ec: 0c017976 jal 0x0005e5d8 Calculate Zodiac Symbol 0005a0f0: 3224ffff andi r4,r17,0xffff r4 = Birthday 0005a0f4: 00021100 sll r2,r2,0x04 Zodiac * 16 0005a0f8: 32100100 andi r16,r16,0x0100 r16 = Birthday High Bit 0005a0fc: 00108202 srl r16,r16,0x08 High Bit / 256 0005a100: 02028021 addu r16,r16,r2 Zodiac + High Bit 0005a104: 34020002 ori r2,r0,0x0002 0005a108: a2510005 sb r17,0x0005(r18) Store Party Birthday 0005a10c: 16a20004 bne r21,r2,0x0005a120 Branch if Unit Type != Ramza 0005a110: a2500006 sb r16,0x0006(r18) Store Party Zodiac 0005a114: 34020046 ori r2,r0,0x0046 Brave/Faith = 70 0005a118: 0801685a j 0x0005a168 0005a11c: a2420017 sb r2,0x0017(r18) Store Party Brave 0005a120: 0c0088c3 jal 0x0002230c Random Number Generator 0005a124: 00000000 nop 0005a128: 00021940 sll r3,r2,0x05 Random * 32 0005a12c: 00621023 subu r2,r3,r2 Random * 31 0005a130: 04410002 bgez r2,0x0005a13c Branch if Random is positive 0005a134: 00000000 nop 0005a138: 24427fff addiu r2,r2,0x7fff 0005a13c: 000213c3 sra r2,r2,0x0f rand(0..30) 0005a140: 24420028 addiu r2,r2,0x0028 Brave = 40 + rand(0..30) 0005a144: 0c0088c3 jal 0x0002230c Random Number Generator 0005a148: a2420017 sb r2,0x0017(r18) Store Party Brave 0005a14c: 00021940 sll r3,r2,0x05 Random * 32 0005a150: 00621023 subu r2,r3,r2 Random * 31 0005a154: 04410002 bgez r2,0x0005a160 Branch if Random is positive 0005a158: 00000000 nop 0005a15c: 24427fff addiu r2,r2,0x7fff 0005a160: 000213c3 sra r2,r2,0x0f rand(0..30) 0005a164: 24420028 addiu r2,r2,0x0028 Faith = 40 + rand(0..30) 0005a168: a2420018 sb r2,0x0018(r18) Store Party Faith 0005a16c: 26440007 addiu r4,r18,0x0007 r4 = Party Secondary Skillset Pointer 0005a170: 0c017991 jal 0x0005e644 Data Nullifying (Secondary/R /S/M/Helm/Armor/Accessory) 0005a174: 34050007 ori r5,r0,0x0007 Limit = 7 0005a178: 02402021 addu r4,r18,r0 r4 = Party Data Pointer 0005a17c: 0c0168f8 jal 0x0005a3e0 Generate Unit's Base Raw Stats Prep (Useless Prep) 0005a180: 02a02821 addu r5,r21,r0 r5 = Unit Type 0005a184: 26440028 addiu r4,r18,0x0028 r4 = Party Unlocked Jobs 0005a188: 34050096 ori r5,r0,0x0096 Limit = 0x96 0005a18c: 34020001 ori r2,r0,0x0001 Level 0005a190: a2420016 sb r2,0x0016(r18) Store Level 0005a194: 0c017991 jal 0x0005e644 Data Nullifying 0005a198: a2400015 sb r0,0x0015(r18) Store Experience = 0 0005a19c: 92530004 lbu r19,0x0004(r18) Load Party Gender 0005a1a0: 00000000 nop 0005a1a4: 326200c0 andi r2,r19,0x00c0 0005a1a8: 10400025 beq r2,r0,0x0005a240 Branch if Unit doesn't have a Gender 0005a1ac: 32620080 andi r2,r19,0x0080 0005a1b0: 00008021 addu r16,r0,r0 Current Job = 0 0005a1b4: 34140011 ori r20,r0,0x0011 r20 = 0x11 (doubles as job levels) 0005a1b8: 02408821 addu r17,r18,r0 r17 = Party Data Pointer 0005a1bc: 16140004 bne r16,r20,0x0005a1d0 Branch if Current Job != Bard 0005a1c0: 34020012 ori r2,r0,0x0012 r2 = 0x12 0005a1c4: 32620040 andi r2,r19,0x0040 0005a1c8: 14400018 bne r2,r0,0x0005a22c Branch if Unit is a Female 0005a1cc: 34020012 ori r2,r0,0x0012 0005a1d0: 16020003 bne r16,r2,0x0005a1e0 Branch if Current Job != Dancer 0005a1d4: 32620080 andi r2,r19,0x0080 0005a1d8: 14400014 bne r2,r0,0x0005a22c Branch if Unit is a Male 0005a1dc: 00000000 nop 0005a1e0: 0c0088c3 jal 0x0002230c Random Number Generator 0005a1e4: 00000000 nop 0005a1e8: 00021840 sll r3,r2,0x01 Random * 2 0005a1ec: 00621821 addu r3,r3,r2 Random * 3 0005a1f0: 000318c0 sll r3,r3,0x03 Random * 24 0005a1f4: 00621821 addu r3,r3,r2 Random * 25 0005a1f8: 00031080 sll r2,r3,0x02 Random * 100 0005a1fc: 04410002 bgez r2,0x0005a208 Branch if Random is positive 0005a200: 00000000 nop 0005a204: 24427fff addiu r2,r2,0x7fff 0005a208: 000213c3 sra r2,r2,0x0f rand(0..99) 0005a20c: 24420064 addiu r2,r2,0x0064 JP = 100 + rand(0..99) 0005a210: a2220096 sb r2,0x0096(r17) Store Party Total JP 0005a214: a222006e sb r2,0x006e(r17) Store Party Current JP 0005a218: 001017c2 srl r2,r16,0x1f 0005a21c: 02021021 addu r2,r16,r2 0005a220: 00021043 sra r2,r2,0x01 Current Job / 2 0005a224: 02421021 addu r2,r18,r2 0005a228: a0540064 sb r20,0x0064(r2) Store Party Job Levels = 1 0005a22c: 26100001 addiu r16,r16,0x0001 Current Job ++ 0005a230: 2a020014 slti r2,r16,0x0014 0005a234: 1440ffe1 bne r2,r0,0x0005a1bc Branch if Current Job < 0x14 0005a238: 26310002 addiu r17,r17,0x0002 JP Pointer += 2 0005a23c: 32620080 andi r2,r19,0x0080 0005a240: 10400002 beq r2,r0,0x0005a24c Branch if Unit isn't a Male 0005a244: 34020001 ori r2,r0,0x0001 Dancer Level = 0; Mime = 1 0005a248: a242006d sb r2,0x006d(r18) Store Dancer/Mime Level 0005a24c: 32620040 andi r2,r19,0x0040 0005a250: 10400003 beq r2,r0,0x0005a260 Branch if Unit isn't a Female 0005a254: 00008021 addu r16,r0,r0 Counter = 0 0005a258: 34020010 ori r2,r0,0x0010 Calculator = 1; Bard = 0 0005a25c: a242006c sb r2,0x006c(r18) Store Calculator/Bard Level 0005a260: 3c038006 lui r3,0x8006 0005a264: 2463e90c addiu r3,r3,0xe90c 0005a268: 00151040 sll r2,r21,0x01 Unit Type * 2 0005a26c: 00551021 addu r2,r2,r21 Type * 3 0005a270: 00021080 sll r2,r2,0x02 Type * 12 0005a274: 00432821 addu r5,r2,r3 r5 = Type's Base Data Pointer 0005a278: 92440000 lbu r4,0x0000(r18) Load Party Sprite Set 0005a27c: 34020080 ori r2,r0,0x0080 Unlocked Jobs = Base 0005a280: a2420028 sb r2,0x0028(r18) Store Unlocked Jobs 0005a284: 000411c2 srl r2,r4,0x07 Sprite Set / 128 0005a288: 00021023 subu r2,r0,r2 r2 = -(Sprite Set / 128) 0005a28c: 00822024 and r4,r4,r2 Generic Name ID = Sprite Set - Sprite Set / 128 (or AND 0x7f) 0005a290: 02501821 addu r3,r18,r16 r3 = Party Data Pointer + Counter 0005a294: 00b01021 addu r2,r5,r16 r2 = Base Data Pointer + Counter 0005a298: 90420005 lbu r2,0x0005(r2) Load Base Equipment 0005a29c: 26100001 addiu r16,r16,0x0001 Counter ++ 0005a2a0: a062000e sb r2,0x000e(r3) Store Party Equipment 0005a2a4: 2a020007 slti r2,r16,0x0007 0005a2a8: 1440fff9 bne r2,r0,0x0005a290 Branch if Counter < 7 0005a2ac: 34020002 ori r2,r0,0x0002 0005a2b0: 16a20003 bne r21,r2,0x0005a2c0 Branch if Unit Type != Ramza 0005a2b4: 00161a02 srl r3,r22,0x08 r3 = Name Modifier / 256 0005a2b8: 080168db j 0x0005a36c 0005a2bc: 34050001 ori r5,r0,0x0001 Chosen Name = 1 (Ramza) 0005a2c0: 3c1e8005 lui r30,0x8005 0005a2c4: 27de7f74 addiu r30,r30,0x7f74 r30 = Party Data Pointer 0005a2c8: 341400ff ori r20,r0,0x00ff r20 = FF 0005a2cc: 309300ff andi r19,r4,0x00ff r19 = Generic Name ID 0005a2d0: 340200ff ori r2,r0,0x00ff r2 = FF 0005a2d4: a24200ce sb r2,0x00ce(r18) Store Unit's Name ID = Default (never used? ) 0005a2d8: a24300cf sb r3,0x00cf(r18) Store Unit's Name ID high bit = Name Mod / 256 0005a2dc: 0c0088c3 jal 0x0002230c Random Number Generator 0005a2e0: 34110001 ori r17,r0,0x0001 r17 = 1 (Use Chosen Name) 0005a2e4: 00021a00 sll r3,r2,0x08 Random * 256 0005a2e8: 00621023 subu r2,r3,r2 Random * 255 0005a2ec: 04410002 bgez r2,0x0005a2f8 Branch if Random is positive 0005a2f0: 00008021 addu r16,r0,r0 Counter = 0 0005a2f4: 24427fff addiu r2,r2,0x7fff 0005a2f8: 000213c3 sra r2,r2,0x0f rand(0..254) 0005a2fc: 02c22821 addu r5,r22,r2 Chosen Name ID = Name Modifier + rand(0..254) 0005a300: 30a6ffff andi r6,r5,0xffff r6 = Chosen Name ID 0005a304: 03c02021 addu r4,r30,r0 r4 = Party Data Pointer 0005a308: 90820001 lbu r2,0x0001(r4) Load Party ID 0005a30c: 00000000 nop 0005a310: 10540010 beq r2,r20,0x0005a354 Branch if unit doesn't exist 0005a314: 00000000 nop 0005a318: 90830000 lbu r3,0x0000(r4) Load Party Sprite Set 0005a31c: 00000000 nop 0005a320: 000311c2 srl r2,r3,0x07 0005a324: 00021023 subu r2,r0,r2 0005a328: 00621824 and r3,r3,r2 r3 = Generic Name ID 0005a32c: 14730009 bne r3,r19,0x0005a354 Branch if Generic Name ID's differ 0005a330: 00000000 nop 0005a334: 908200cf lbu r2,0x00cf(r4) Load Party Name ID High Bit 0005a338: 908300ce lbu r3,0x00ce(r4) Load Party Name ID 0005a33c: 00021200 sll r2,r2,0x08 High Bit * 256 0005a340: 00621825 or r3,r3,r2 r3 = Name I D 0005a344: 14660003 bne r3,r6,0x0005a354 Branch if Chosen Name isn't already used 0005a348: 00000000 nop 0005a34c: 080168d9 j 0x0005a364 0005a350: 00008821 addu r17,r0,r0 r17 = 0 (Re-roll Name) 0005a354: 26100001 addiu r16,r16,0x0001 Counter ++ 0005a358: 2a020010 slti r2,r16,0x0010 0005a35c: 1440ffea bne r2,r0,0x0005a308 Branch if Counter < 0x10 0005a360: 24840100 addiu r4,r4,0x0100 Party Pointer += 0x100 0005a364: 1220ffdd beq r17,r0,0x0005a2dc Branch if Name already exists 0005a368: 00000000 nop 0005a36c: 00051202 srl r2,r5,0x08 Chosen Name / 256 0005a370: 30a400ff andi r4,r5,0x00ff r4 = Chosen Name 0005a374: 02e42021 addu r4,r23,r4 r4 = Name Flags + Chosen Name 0005a378: a24500ce sb r5,0x00ce(r18) Store Party Name ID 0005a37c: 0c039bb7 jal 0x000e6edc Prep for Loading Text (world) 0005a380: a24200cf sb r2,0x00cf(r18) Store Party Name ID High Bit 0005a384: 00402021 addu r4,r2,r0 r4 = Chosen Name 0005a388: 264500be addiu r5,r18,0x00be r5 = Party Name Pointer 0005a38c: 0c017319 jal 0x0005cc64 Store X into Y (Unit's Name) 0005a390: 34060010 ori r6,r0,0x0010 Limit = 0x10 0005a394: 34020002 ori r2,r0,0x0002 r2 = 2 0005a398: a24000d0 sb r0,0x00d0(r18) Store ? = 0 0005a39c: 16a20003 bne r21,r2,0x0005a3ac Branch if Unit Type != Ramza 0005a3a0: a24000d2 sb r0,0x00d2(r18) Store ? = 0 0005a3a4: 34020004 ori r2,r0,0x0004 Known Abilities = Wish 0005a3a8: a242002b sb r2,0x002b(r18) Store Base Known Abilities 0005a3ac: 8fbf0034 lw r31,0x0034(r29) 0005a3b0: 8fbe0030 lw r30,0x0030(r29) 0005a3b4: 8fb7002c lw r23,0x002c(r29) 0005a3b8: 8fb60028 lw r22,0x0028(r29) 0005a3bc: 8fb50024 lw r21,0x0024(r29) 0005a3c0: 8fb40020 lw r20,0x0020(r29) 0005a3c4: 8fb3001c lw r19,0x001c(r29) 0005a3c8: 8fb20018 lw r18,0x0018(r29) 0005a3cc: 8fb10014 lw r17,0x0014(r29) 0005a3d0: 8fb00010 lw r16,0x0010(r29) 0005a3d4: 27bd0038 addiu r29,r29,0x0038 0005a3d8: 03e00008 jr r31 0005a3dc: 00000000 nop
Return Locations
00059f50: Find Empty Party Slot and Generate Unit