Calculate Clockticks Until Unit Acts
Jump to navigation
Jump to search
00199b98: 90860038 lbu r6,0x0038(r4) Load Unit's SP 00199b9c: 3c03801a lui r3,0x801a 00199ba0: 2463f3c4 addiu r3,r3,0xf3c4 00199ba4: 10c00010 beq r6,r0,0x00199be8 Branch if SP = 0 00199ba8: 00002821 addu r5,r0,r0 Ticks = 0 00199bac: 94820058 lhu r2,0x0058(r4) Load Unit's Current Statuses 1+2 00199bb0: 00000000 nop 00199bb4: 30428140 andi r2,r2,0x8140 00199bb8: 1440000c bne r2,r0,0x00199bec Branch if Unit has Crystal/Treasure/Petrify 00199bbc: 3c027fff lui r2,0x7fff 00199bc0: 90820001 lbu r2,0x0001(r4) Load Unit's ID 00199bc4: 00000000 nop 00199bc8: 00021100 sll r2,r2,0x04 ID * 16 00199bcc: 00431021 addu r2,r2,r3 00199bd0: 90421833 lbu r2,0x1833(r2) Load ? 00199bd4: 00000000 nop 00199bd8: 00021142 srl r2,r2,0x05 ? / 0x20 00199bdc: 30420001 andi r2,r2,0x0001 (could just AND 0x20) 00199be0: 10400004 beq r2,r0,0x00199bf4 Branch if Unit doesn't need revived? 00199be4: 00000000 nop 00199be8: 3c027fff lui r2,0x7fff 00199bec: 08066720 j 0x00199c80 (could have just used FF) 00199bf0: 3442ffff ori r2,r2,0xffff Turns = 0x7fffffff 00199bf4: 9082005b lbu r2,0x005b(r4) Load Unit's Statuses 4 00199bf8: 00000000 nop 00199bfc: 30420002 andi r2,r2,0x0002 00199c00: 10400002 beq r2,r0,0x00199c0c Branch if Unit doesn't have Stop 00199c04: 00000000 nop 00199c08: 90850063 lbu r5,0x0063(r4) Ticks = Stop CT 00199c0c: 90830039 lbu r3,0x0039(r4) Load CT 00199c10: 00000000 nop 00199c14: 2c620064 sltiu r2,r3,0x0064 00199c18: 10400008 beq r2,r0,0x00199c3c Branch if CT >= 100 00199c1c: 34020064 ori r2,r0,0x0064 r2 = 100 00199c20: 00431023 subu r2,r2,r3 Remaining CT = 100 - CT 00199c24: 0046001a div r2,r6 Remaining CT / SP 00199c28: 00001012 mflo r2 r2 = Ticks Left 00199c2c: 00001810 mfhi r3 r3 = Remainder 00199c30: 10600002 beq r3,r0,0x00199c3c Branch if Remainder = 0 00199c34: 00a22821 addu r5,r5,r2 Ticks += Ticks Left 00199c38: 24a50001 addiu r5,r5,0x0001 Ticks += 1 (round ticks up) 00199c3c: 90820058 lbu r2,0x0058(r4) Load Unit's Statuses 1 00199c40: 00000000 nop 00199c44: 30420020 andi r2,r2,0x0020 00199c48: 1440000d bne r2,r0,0x00199c80 Branch if Unit is Dead 00199c4c: 00a01021 addu r2,r5,r0 r2 = Ticks 00199c50: 9082005c lbu r2,0x005c(r4) Load Unit's Statuses 5 00199c54: 00000000 nop 00199c58: 30420010 andi r2,r2,0x0010 00199c5c: 10400008 beq r2,r0,0x00199c80 Branch if Unit isn't Sleeping 00199c60: 00a01021 addu r2,r5,r0 r2 = Ticks 00199c64: 90840068 lbu r4,0x0068(r4) Load Sleep CT 00199c68: 00000000 nop 00199c6c: 00a4102a slt r2,r5,r4 00199c70: 10400003 beq r2,r0,0x00199c80 Branch if Ticks >= Sleep CT 00199c74: 00a01021 addu r2,r5,r0 r2 = Ticks 00199c78: 00802821 addu r5,r4,r0 Ticks = Sleep CT 00199c7c: 00a01021 addu r2,r5,r0 r2 = Ticks 00199c80: 03e00008 jr r31 00199c84: 00000000 nop