Store New Seed and Lay Eggs
(Redirected from 00125a04 - 00125cf8)
Jump to navigation
Jump to search
# Store New RNG seed depends on current game time, and lay eggs.
# Description # When you arrive at a location, RNG seed is updated depends on current game time. # Which means if you arrive in exactly same game time, you can reproduce same things. # new RNG seed = Milsec * 101 + Seconds * 10 + Minutes + Hours
00125a04: 3c058004 lui r5,0x8004 00125a08: 8ca559b8 lw r5,0x59b8(r5) r5 = Milsecs (60 counts per 1 sec) 00125a0c: 3c038004 lui r3,0x8004 00125a10: 8c6359bc lw r3,0x59bc(r3) r3 = Seconds 00125a14: 27bdffa0 addiu r29,r29,0xffa0 00125a18: afb50054 sw r21,0x0054(r29) 00125a1c: 0000a821 addu r21,r0,r0 Skillset Counter = 0 00125a20: afb60058 sw r22,0x0058(r29) 00125a24: 0000b021 addu r22,r0,r0 Level Counter = 0 00125a28: afb40050 sw r20,0x0050(r29) 00125a2c: 0000a021 addu r20,r0,r0 Party ID = 0 00125a30: afbf005c sw r31,0x005c(r29) 00125a34: afb3004c sw r19,0x004c(r29) 00125a38: afb20048 sw r18,0x0048(r29) 00125a3c: afb10044 sw r17,0x0044(r29) 00125a40: afb00040 sw r16,0x0040(r29) 00125a44: 00052040 sll r4,r5,0x01 00125a48: 00852021 addu r4,r4,r5 00125a4c: 000420c0 sll r4,r4,0x03 00125a50: 00852021 addu r4,r4,r5 00125a54: 00042080 sll r4,r4,0x02 r4 = Milsec * 100 00125a58: 00031080 sll r2,r3,0x02 00125a5c: 00431021 addu r2,r2,r3 00125a60: 00021040 sll r2,r2,0x01 r2 = Seconds * 10 00125a64: 00822021 addu r4,r4,r2 r4 = Milsec * 100 + Seconds * 10 00125a68: 3c028004 lui r2,0x8004 00125a6c: 8c4259c0 lw r2,0x59c0(r2) r2 = Minutes 00125a70: 3c038004 lui r3,0x8004 00125a74: 8c6359c4 lw r3,0x59c4(r3) r3 = Hours 00125a78: 00822021 addu r4,r4,r2 00125a7c: 00832021 addu r4,r4,r3 00125a80: 0c0088c7 jal 0x0002231c srand(r4) (Store new RNG seed depends on current game time) 00125a84: 00852021 addu r4,r4,r5 r4 = Milsec * 101 + Seconds * 10 + Minutes + Hours 00125a88: 0c0166bc jal 0x00059af0 Get Party Data Pointer 00125a8c: 02802021 addu r4,r20,r0 r4 = Party ID 00125a90: 00409021 addu r18,r2,r0 r18 = Unit's Party Data Pointer 00125a94: 92430001 lbu r3,0x0001(r18) Load Unit's Party ID 00125a98: 340200ff ori r2,r0,0x00ff (0xFF Unit doesn't exist) 00125a9c: 10620038 beq r3,r2,0x00125b80 Branch if Unit doesn't exist 00125aa0: 00000000 nop 00125aa4: 92420004 lbu r2,0x0004(r18) Load Unit's Gender Byte 00125aa8: 00000000 nop 00125aac: 30420004 andi r2,r2,0x0004 (normally ??? stats; used as Egg Flag here) 00125ab0: 10400026 beq r2,r0,0x00125b4c Branch if unit isn't an Egg 00125ab4: 27a20028 addiu r2,r29,0x0028 r2 = Stack Pointer + 0x28 00125ab8: 92420005 lbu r2,0x0005(r18) Load Unit's Birthday (used as Egg Counter) 00125abc: 00000000 nop 00125ac0: 3050000f andi r16,r2,0x000f r16 = Birthday Low Nybble (Egg Counter) 00125ac4: 2610ffff addiu r16,r16,0xffff Egg Counter -- 00125ac8: 304200f0 andi r2,r2,0x00f0 r3 = Birthday High Nybble (Starting Egg Counter * 0x10) 00125acc: 00501025 or r2,r2,r16 r2 = Starting Egg Counter + Egg Counter 00125ad0: 1600002b bne r16,r0,0x00125b80 Branch if Egg Counter != 0 00125ad4: a2420005 sb r2,0x0005(r18) Store new Egg Counter Data 00125ad8: 34020020 ori r2,r0,0x0020 00125adc: a2420004 sb r2,0x0004(r18) Store Unit's Gender Byte = Monster (0x20) 00125ae0: 0c03bc6a jal 0x000ef1a8 Load Main Variable 00125ae4: 3404002f ori r4,r0,0x002f r4 = 0x2f (Get Day) (these are likely *4 then load words 00125ae8: 3404002e ori r4,r0,0x002e r4 = 0x2e (Get Month) starting from 0x5771c) 00125aec: 0c03bc6a jal 0x000ef1a8 Load Main Variable 00125af0: 00409821 addu r19,r2,r0 r19 = Day 00125af4: 34100001 ori r16,r0,0x0001 Counter = 1 00125af8: 00402021 addu r4,r2,r0 r4 = Month 00125afc: 0204102a slt r2,r16,r4 00125b00: 10400009 beq r2,r0,0x00125b28 Branch if Counter >= Month 00125b04: 00008821 addu r17,r0,r0 Day Total = 0 00125b08: 3c018019 lui r1,0x8019 00125b0c: 00300821 addu r1,r1,r16 00125b10: 9022deac lbu r2,-0x2154(r1) Load Month's Total Days 00125b14: 26100001 addiu r16,r16,0x0001 Counter ++ 00125b18: 02228821 addu r17,r17,r2 Day Total += Month's Total Days 00125b1c: 0204102a slt r2,r16,r4 00125b20: 1440fff9 bne r2,r0,0x00125b08 Branch if Counter < Month 00125b24: 00000000 nop 00125b28: 02338821 addu r17,r17,r19 Day Total += Day 00125b2c: 0c049664 jal 0x00125990 00125b30: 02602821 addu r5,r19,r0 r5 = Day 00125b34: 00021300 sll r2,r2,0x0c 00125b38: 02228825 or r17,r17,r2 00125b3c: 00111203 sra r2,r17,0x08 00125b40: a2510005 sb r17,0x0005(r18) Store Unit's Birthday 00125b44: 080496e0 j 0x00125b80 00125b48: a2420006 sb r2,0x0006(r18) Store Unit's Zodiac sign 00125b4c: 92430016 lbu r3,0x0016(r18) Load Unit's Level 00125b50: 00561021 addu r2,r2,r22 Stack Pointer + 0x28 + Stack Counter 00125b54: a0430000 sb r3,0x0000(r2) Store Unit's Level 00125b58: 92440002 lbu r4,0x0002(r18) Load Unit's Job ID 00125b5c: 0c0489db jal 0x0012276c Get job's skillset 00125b60: 26d60001 addiu r22,r22,0x0001 Level Counter ++ 00125b64: 2442ff50 addiu r2,r2,0xff50 Skillset - 0xb0 (Monster skillset) 00125b68: 2c420030 sltiu r2,r2,0x0030 00125b6c: 10400004 beq r2,r0,0x00125b80 Branch if Skillset isn't a monster skillset 00125b70: 27a20010 addiu r2,r29,0x0010 r2 = Stack Pointer + 0x10 00125b74: 00551021 addu r2,r2,r21 Stack Pointer + 0x10 + Skillset Counter 00125b78: a0540000 sb r20,0x0000(r2) Store Monster's Party ID 00125b7c: 26b50001 addiu r21,r21,0x0001 Skillset Counter ++ 00125b80: 26940001 addiu r20,r20,0x0001 Party ID ++ 00125b84: 2a820014 slti r2,r20,0x0014 00125b88: 1440ffbf bne r2,r0,0x00125a88 Branch if Party ID < 0x14 00125b8c: 00000000 nop 00125b90: 12a0004f beq r21,r0,0x00125cd0 Branch if Skillset Counter = 0 (no monsters) 00125b94: 00000000 nop 00125b98: 0c0088c3 jal 0x0002230c Random Number Generator 00125b9c: 00000000 nop 00125ba0: 305100ff andi r17,r2,0x00ff Random = rand(0..255) 00125ba4: 2a220006 slti r2,r17,0x0006 00125ba8: 14400005 bne r2,r0,0x00125bc0 Branch if Random < 6 (~2.3%) 00125bac: 34100003 ori r16,r0,0x0003 Monster Rarity = 3 (Rare) 00125bb0: 2a220010 slti r2,r17,0x0010 00125bb4: 14400002 bne r2,r0,0x00125bc0 Branch if Random < 16 (~3.9%) 00125bb8: 34100002 ori r16,r0,0x0002 Monster Rarity = 2 (Uncommon) 00125bbc: 2a300020 slti r16,r17,0x0020 00125bc0: 12000043 beq r16,r0,0x00125cd0 Don't branch if Random < 32 (6.25%; Monster Rarity = 1 (Common)) 00125bc4: 00000000 nop 00125bc8: 0c0088c3 jal 0x0002230c Random Number Generator 00125bcc: 00000000 nop 00125bd0: 0055001a div r2,r21 00125bd4: 0000a810 mfhi r21 rand(0..Skillset Counter) 00125bd8: 00000000 nop 00125bdc: 03b51021 addu r2,r29,r21 00125be0: 90440010 lbu r4,0x0010(r2) Load Chosen Skillset 00125be4: 0c0166bc jal 0x00059af0 Get Party Data Pointer 00125be8: 00000000 nop 00125bec: 90420002 lbu r2,0x0002(r2) Load Unit's Job ID 00125bf0: 00000000 nop 00125bf4: 2442ffa2 addiu r2,r2,0xffa2 ID - 0x5e (Monster Job ID) 00125bf8: 00021080 sll r2,r2,0x02 ID * 4 00125bfc: 00501021 addu r2,r2,r16 ID * 4 + Monster Rarity 00125c00: 3c018019 lui r1,0x8019 00125c04: 00220821 addu r1,r1,r2 00125c08: 9030debc lbu r16,-0x2144(r1) Load Child Job ID 00125c0c: 0c0088c3 jal 0x0002230c Random Number Generator 00125c10: 00000000 nop 00125c14: 2603ffa2 addiu r3,r16,0xffa2 Child ID - 0x5e 00125c18: 00031880 sll r3,r3,0x02 ID * 4 00125c1c: 3c018019 lui r1,0x8019 00125c20: 00230821 addu r1,r1,r3 00125c24: 9023debc lbu r3,-0x2144(r1) Load Egg Timer 00125c28: 00000000 nop 00125c2c: 0043001a div r2,r3 Random / Egg Timer 00125c30: 00001810 mfhi r3 r3 = rand(0..Egg Timer - 1) 00125c34: 00000000 nop 00125c38: 24740001 addiu r20,r3,0x0001 Egg Mod = rand(1..Egg Timer) 00125c3c: 2a820002 slti r2,r20,0x0002 00125c40: 10400002 beq r2,r0,0x00125c4c Branch if Egg Mod >= 2 00125c44: 00000000 nop 00125c48: 34140002 ori r20,r0,0x0002 Egg Mod = Min of 2 00125c4c: 3c12801d lui r18,0x801d 00125c50: 2652d8c4 addiu r18,r18,0xd8c4 00125c54: 3c02801d lui r2,0x801d 00125c58: 8c42d8c8 lw r2,-0x2738(r2) Load ? (to override current value) 00125c5c: 8e510000 lw r17,0x0000(r18) Load ? (to store back later) 00125c60: 0c0088c3 jal 0x0002230c Random Number Generator 00125c64: ae420000 sw r2,0x0000(r18) Store new ? 00125c68: 04410002 bgez r2,0x00125c74 Branch if Random is positive 00125c6c: 00403021 addu r6,r2,r0 r6 = Random 00125c70: 24460003 addiu r6,r2,0x0003 00125c74: 02002021 addu r4,r16,r0 r4 = Monster Job ID (Child) 00125c78: 00142900 sll r5,r20,0x04 Egg Mod * 16 00125c7c: 02852821 addu r5,r20,r5 Egg Mod * 17 00125c80: 00063083 sra r6,r6,0x02 00125c84: 00063080 sll r6,r6,0x02 Random / 4 * 4 00125c88: 0c016786 jal 0x00059e18 Create Monster Egg 00125c8c: 00463023 subu r6,r2,r6 rand(0..3) 00125c90: 00408021 addu r16,r2,r0 r16 = Party ID of Egg 00125c94: 2402ffff addiu r2,r0,0xffff 00125c98: 1202000d beq r16,r2,0x00125cd0 Branch if Egg Creation failed 00125c9c: ae510000 sw r17,0x0000(r18) Store old ? 00125ca0: 0c0166bc jal 0x00059af0 Get Party Data Pointer 00125ca4: 02002021 addu r4,r16,r0 r4 = Party ID 00125ca8: 0c0088c3 jal 0x0002230c Random Number Generator 00125cac: 00409021 addu r18,r2,r0 r18 = Unit's Party Data Pointer 00125cb0: 0056001a div r2,r22 Random / Level Counter 00125cb4: 00001810 mfhi r3 rand(0..Level Counter) 00125cb8: 00000000 nop 00125cbc: 03a31021 addu r2,r29,r3 Stack Pointer + Level Random 00125cc0: 90450028 lbu r5,0x0028(r2) Load Chosen Level 00125cc4: 02402021 addu r4,r18,r0 r4 = Unit's Party Data Pointer 00125cc8: 0c01763f jal 0x0005d8fc Level Unit to Specific Level 00125ccc: 24a5ffff addiu r5,r5,0xffff r5 = Chosen Level 00125cd0: 8fbf005c lw r31,0x005c(r29) 00125cd4: 8fb60058 lw r22,0x0058(r29) 00125cd8: 8fb50054 lw r21,0x0054(r29) 00125cdc: 8fb40050 lw r20,0x0050(r29) 00125ce0: 8fb3004c lw r19,0x004c(r29) 00125ce4: 8fb20048 lw r18,0x0048(r29) 00125ce8: 8fb10044 lw r17,0x0044(r29) 00125cec: 8fb00040 lw r16,0x0040(r29) 00125cf0: 27bd0060 addiu r29,r29,0x0060 00125cf4: 03e00008 jr r31 00125cf8: 00000000 nop