Difference between revisions of "Random Process"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
(Created page with " Random Process (gives a random based on r4 (MOD) and checks against r5 (chance to work)) 0018eed8: 27bdffe0 addiu r29,r29,0xffe0 0018eedc: afb00010 sw r16,0x0010(r29) 0018...")
 
m (linking subroutine)
Line 5: Line 5:
 
  0018eee4: afb10014 sw r17,0x0014(r29)
 
  0018eee4: afb10014 sw r17,0x0014(r29)
 
  0018eee8: afbf0018 sw r31,0x0018(r29)
 
  0018eee8: afbf0018 sw r31,0x0018(r29)
  0018eeec: 0c063ba8 jal 0x0018eea0 Random Procees (returns 0-7FFF)
+
  0018eeec: 0c063ba8 jal 0x0018eea0 r2 = [[Random Process, gives a number between 0-7fff|rand()]] (see [[RNG]])
 
  0018eef0: 00a08821 addu r17,r5,r0 r17 = Chance
 
  0018eef0: 00a08821 addu r17,r5,r0 r17 = Chance
 
  0018eef4: 00500018 mult r2,r16 Random * MOD
 
  0018eef4: 00500018 mult r2,r16 Random * MOD

Revision as of 12:06, 13 September 2015

Random Process (gives a random based on r4 (MOD) and checks against r5 (chance to work))
0018eed8: 27bdffe0 addiu r29,r29,0xffe0
0018eedc: afb00010 sw r16,0x0010(r29)
0018eee0: 00808021 addu r16,r4,r0		r16 = Random MOD
0018eee4: afb10014 sw r17,0x0014(r29)
0018eee8: afbf0018 sw r31,0x0018(r29)
0018eeec: 0c063ba8 jal 0x0018eea0		r2 = rand() (see RNG)
0018eef0: 00a08821 addu r17,r5,r0		r17 = Chance
0018eef4: 00500018 mult r2,r16			Random * MOD
0018eef8: 00001012 mflo r2			r2 = Random * MOD
0018eefc: 04410002 bgez r2,0x0018ef08		Branch if Random * MOD >= 0
0018ef00: 00000000 nop
0018ef04: 24427fff addiu r2,r2,0x7fff		r2 + 7FFF (makes Random * MOD positive)
0018ef08: 000213c3 sra r2,r2,0x0f		Random * MOD / 8000h
0018ef0c: 0051102a slt r2,r2,r17		r2 = 1 IF Random < chance
0018ef10: 38420001 xori r2,r2,0x0001		r2 = 0 IF Random < chance
0018ef14: 8fbf0018 lw r31,0x0018(r29)
0018ef18: 8fb10014 lw r17,0x0014(r29)
0018ef1c: 8fb00010 lw r16,0x0010(r29)
0018ef20: 27bd0020 addiu r29,r29,0x0020
0018ef24: 03e00008 jr r31
0018ef28: 00000000 nop