rename RNG to Random

also fix 'Far' naming scheme for BattleRandom

this was a long time coming
This commit is contained in:
yenatch 2013-08-30 22:59:40 -04:00
parent 70ecde3f78
commit c9d3881a2f
8 changed files with 184 additions and 183 deletions

View File

@ -129,7 +129,7 @@ AIScoring_RedStatMods: ; 385e0
jr .checkmove
.discourage
call RNG
call Random
cp 30
jr c, .checkmove
inc [hl]
@ -430,7 +430,7 @@ AIScoring_LeechHit: ; 387f7
ret
.asm_38815
call RNG
call Random
cp $64
ret c
@ -575,7 +575,7 @@ AIScoring_Explosion: ; 388a6
call AICheckEnemyQuarterHP
ret nc
call RNG
call Random
cp 20
ret c
@ -588,7 +588,7 @@ AIScoring_Explosion: ; 388a6
AIScoring_DreamEater: ; 388ca
call RNG
call Random
cp $19
ret c
@ -612,7 +612,7 @@ AIScoring_EvasionUp: ; 388d4
bit 0, a
jr nz, .asm_388ef
call RNG
call Random
cp $b2
jr nc, .asm_38911
@ -628,7 +628,7 @@ AIScoring_EvasionUp: ; 388d4
jr nc, .asm_3890f
call RNG
call Random
cp $a
jr c, .asm_388ef
@ -683,7 +683,7 @@ AIScoring_EvasionUp: ; 388d4
ret
.asm_38938
call RNG
call Random
cp $50
ret c
dec [hl]
@ -744,7 +744,7 @@ AIScoring_MirrorMove: ; 3895b
call AICompareSpeed
ret nc
call RNG
call Random
cp $19
ret c
@ -766,7 +766,7 @@ AIScoring_AccuracyDown: ; 38985
bit 0, a
jr nz, .asm_3899d
call RNG
call Random
cp $b2
jr nc, .asm_389bf
@ -782,7 +782,7 @@ AIScoring_AccuracyDown: ; 38985
jr nc, .asm_389bd
call RNG
call Random
cp $a
jr c, .asm_3899d
@ -837,7 +837,7 @@ AIScoring_AccuracyDown: ; 38985
ret
.asm_389e6
call RNG
call Random
cp $50
ret c
dec [hl]
@ -878,7 +878,7 @@ AIScoring_Haze: ; 389f5
.asm_38a12
pop hl
call RNG
call Random
cp $28
ret c
dec [hl]
@ -894,7 +894,7 @@ AIScoring_Haze: ; 389f5
AIScoring_Bide: ; 38a1e
call AICheckEnemyMaxHP
ret c
call RNG
call Random
cp $19
ret c
inc [hl]
@ -926,7 +926,7 @@ AIScoring_Moonlight: ; 38a3a
ret
.asm_38a45
call RNG
call Random
cp $19
ret c
dec [hl]
@ -948,7 +948,7 @@ AIScoring_LightScreen:
AIScoring_Reflect: ; 38a54
call AICheckEnemyMaxHP
ret c
call RNG
call Random
cp $14
ret c
inc [hl]
@ -1041,7 +1041,7 @@ AIScoring_Unused2B: ; 38a9c
ret c
.asm_38acd
call RNG
call Random
cp $c8
ret c
@ -1061,7 +1061,7 @@ AIScoring_Unused2B: ; 38a9c
AIScoring_Confuse: ; 38adb
call AICheckPlayerHalfHP
ret c
call RNG
call Random
cp $19
jr c, .asm_38ae7
inc [hl]
@ -1156,7 +1156,7 @@ AIScoring_SpeedDownHit: ; 38b40
ret nz
call AICompareSpeed
ret c
call RNG
call Random
cp 30
ret c
dec [hl]
@ -1183,7 +1183,7 @@ AIScoring_HyperBeam: ; 38b63
ret
.asm_38b72
call RNG
call Random
cp 40
ret c
inc [hl]
@ -1334,7 +1334,7 @@ AIScoring_Counter: ; 38bf1
.asm_38c30
call RNG
call Random
cp $64
jr c, .asm_38c38
@ -1388,7 +1388,7 @@ AIScoring_Encore: ; 38c3b
jr nc, .asm_38c81
.asm_38c78
call RNG
call Random
cp $46
ret c
dec [hl]
@ -1527,7 +1527,7 @@ AIScoring_Spite: ; 38cd5
cp $f
jr nc, .asm_38d0b
call RNG
call Random
cp $64
ret nc
@ -1536,7 +1536,7 @@ AIScoring_Spite: ; 38cd5
ret
.asm_38d0d
call RNG
call Random
cp $64
ret c
dec [hl]
@ -1700,7 +1700,7 @@ AIScoring_Conversion2: ; 38d98
ret
.asm_38dc9
call RNG
call Random
cp $19
ret c
@ -1722,7 +1722,7 @@ AIScoring_Disable: ; 38dd1
pop hl
jr nc, .asm_38dee
call RNG
call Random
cp 100
ret c
dec [hl]
@ -1734,7 +1734,7 @@ AIScoring_Disable: ; 38dd1
ret nz
.asm_38df3
call RNG
call Random
cp 20
ret c
inc [hl]
@ -1961,7 +1961,7 @@ AIScoring_Protect: ; 38ed2
inc [hl]
.asm_38f14
call RNG
call Random
cp 20
ret c
inc [hl]
@ -1985,14 +1985,14 @@ AIScoring_Foresight: ; 38f1d
cp GHOST
jr z, .asm_38f41
call RNG
call Random
cp 20
ret c
inc [hl]
ret
.asm_38f41
call RNG
call Random
cp 100
ret c
dec [hl]
@ -2169,7 +2169,7 @@ AIScoring_Rollout: ; 38fef
cp 8
jr nc, .asm_39020
call RNG
call Random
cp 200
ret nc
dec [hl]
@ -2196,7 +2196,7 @@ AIScoring_Attract: ; 39026
ret
.asm_39032
call RNG
call Random
cp 200
ret nc
dec [hl]
@ -2558,7 +2558,7 @@ AIScoring_MirrorCoat: ; 3918b
.asm_391ca
call RNG
call Random
cp 100
jr c, .asm_391d2
dec [hl]
@ -2634,7 +2634,7 @@ AIScoring_Solarbeam: ; 3920b
cp WEATHER_RAIN
ret nz
call RNG
call Random
cp 25 ; 1/10
ret c
@ -2657,7 +2657,7 @@ AIScoring_Thunder: ; 39225
cp WEATHER_SUN
ret nz
call RNG
call Random
cp 25 ; 1/10
ret c
@ -3150,7 +3150,7 @@ AIScoring_Cautious: ; 39418
pop hl
jr nc, .asm_39425
call RNG
call Random
cp 230
ret nc
@ -3274,7 +3274,7 @@ AIScoring_Risky: ; 394a9
call AICheckEnemyMaxHP
jr c, .nextmove
call RNG
call Random
cp 200 ; 1/5
jr c, .nextmove
@ -3347,14 +3347,14 @@ AIGetEnemyMove: ; 39508
Function_0x39521: ; 39521
call RNG
call Random
cp 50 ; 1/5
ret
; 39527
Function_0x39527: ; 39527
call RNG
call Random
cp $80 ; 1/2
ret
; 3952d

View File

@ -288,7 +288,7 @@ CheckPlayerTurn:
call FarPlayBattleAnimation
; 50% chance of hitting itself
call FarBattleRNG
call BattleRandom
cp $80
jr nc, .CheckAttract
@ -319,7 +319,7 @@ CheckPlayerTurn:
call FarPlayBattleAnimation
; 50% chance of infatuation
call FarBattleRNG
call BattleRandom
cp $80
jr c, .CheckDisabledMove
@ -353,7 +353,7 @@ CheckPlayerTurn:
ret z
; 25% chance to be fully paralyzed
call FarBattleRNG
call BattleRandom
cp $3f
ret nc
@ -544,7 +544,7 @@ CheckEnemyTurn: ; 3421f
call FarPlayBattleAnimation
; 50% chance of hitting itself
call FarBattleRNG
call BattleRandom
cp $80
jr nc, .CheckAttract
@ -598,7 +598,7 @@ CheckEnemyTurn: ; 3421f
call FarPlayBattleAnimation
; 50% chance of infatuation
call FarBattleRNG
call BattleRandom
cp $80
jr c, .CheckDisabledMove
@ -633,7 +633,7 @@ CheckEnemyTurn: ; 3421f
ret z
; 25% chance to be fully paralyzed
call FarBattleRNG
call BattleRandom
cp $3f
ret nc
@ -808,7 +808,7 @@ BattleCommand02: ; 343db
; Random number from 0 to obedience level + monster level
.rand1
call FarBattleRNG
call BattleRandom
swap a
cp b
jr nc, .rand1
@ -826,7 +826,7 @@ BattleCommand02: ; 343db
; Another random number from 0 to obedience level + monster level
.rand2
call FarBattleRNG
call BattleRandom
cp b
jr nc, .rand2
@ -843,7 +843,7 @@ BattleCommand02: ; 343db
ld b, a
; The chance of napping is the difference out of 256.
call FarBattleRNG
call BattleRandom
swap a
sub b
jr c, .Nap
@ -862,7 +862,7 @@ BattleCommand02: ; 343db
.Nap
call FarBattleRNG
call BattleRandom
add a
swap a
and 7
@ -876,7 +876,7 @@ BattleCommand02: ; 343db
.DoNothing
call FarBattleRNG
call BattleRandom
and 3
; 'loafing around!'
@ -964,7 +964,7 @@ BattleCommand02: ; 343db
.RandomMove
call FarBattleRNG
call BattleRandom
and 3
cp b
@ -1324,7 +1324,7 @@ BattleCommand05: ; 34631
ld hl, .Chances
ld b, 0
add hl, bc
call FarBattleRNG
call BattleRandom
cp [hl]
ret nc
ld a, 1
@ -2338,7 +2338,7 @@ BattleCommand08: ; 34cfd
; Multiply by 85-100%...
.loop
call FarBattleRNG
call BattleRandom
rrca
cp $d9 ; 85%
jr c, .loop
@ -2423,7 +2423,7 @@ BattleCommand09: ; 34d32
cp $ff
jr z, .Hit
call FarBattleRNG
call BattleRandom
cp b
jr nc, .Miss
@ -2701,7 +2701,7 @@ BattleCommand90: ; 34ecc
ld hl, EnemyMoveEffectChance
.asm_34ee1
call FarBattleRNG
call BattleRandom
cp [hl]
pop hl
ret c
@ -2986,7 +2986,7 @@ BattleCommand0e: ; 3505e
cp HELD_FOCUS_BAND
ld b, $0
jr nz, .asm_3508b ; 3507a $f
call FarBattleRNG
call BattleRandom
cp c
jr nc, .asm_3508b ; 35080 $9
call BattleCommand4b
@ -4332,7 +4332,7 @@ BattleCommand3f: ; 35726
add b
ld b, a
.asm_3575d
call FarBattleRNG
call BattleRandom
and a
jr z, .asm_3575d ; 35761 $fa
cp b
@ -4555,7 +4555,7 @@ BattleCommand41: ; 35864
bit 4, [hl]
jp nz, Function0x35923
set 4, [hl]
call FarBattleRNG
call BattleRandom
and $3
inc a
inc a
@ -4782,7 +4782,7 @@ BattleCommand44: ; 359e6
call SwitchTurn
.asm_35a13
call FarBattleRNG
call BattleRandom
and $1f
cp $a
jr c, .asm_35a24 ; 35a1a $8
@ -5005,7 +5005,7 @@ BattleCommand48: ; 35b33
dec hl
.asm_35b62
push hl
call FarBattleRNG
call BattleRandom
and $3
ld c, a
ld b, $0
@ -5173,7 +5173,7 @@ BattleCommand4a: ; 35c0f
jr z, .asm_35c91 ; 35c46 $49
push bc
call GetMoveName
call FarBattleRNG
call BattleRandom
and $3
inc a
inc a
@ -5576,7 +5576,7 @@ BattleCommand14: ; 35e5c
ld b, $3
.asm_35ea4
call FarBattleRNG
call BattleRandom
and b
jr z, .asm_35ea4
cp 7
@ -5625,7 +5625,7 @@ Function0x35ece: ; 35ece
bit 5, a
jr nz, .asm_35eec
call FarBattleRNG
call BattleRandom
cp $40
ret c
@ -5715,7 +5715,7 @@ BattleCommand2f: ; 35f2c
ld a, [PlayerSubStatus5]
bit 5, a
jr nz, .asm_35f89 ; 35f80 $7
call FarBattleRNG
call BattleRandom
cp $40
jr c, .asm_35fb8 ; 35f87 $2f
.asm_35f89
@ -6375,7 +6375,7 @@ BattleCommand1d: ; 362e3
cp EFFECT_ACCURACY_DOWN_HIT
jr z, .DidntMiss
call FarBattleRNG
call BattleRandom
cp $40
jr c, .Failed
@ -6789,7 +6789,7 @@ BattleCommandac: ; 3658f
; 1/3 chance of each status
.loop
call FarBattleRNG
call BattleRandom
swap a
and 3
jr z, .loop
@ -7043,7 +7043,7 @@ BattleCommand22: ; 366e5
ld [de], a
ld [PlayerMoveEffect], a
ld [EnemyMoveEffect], a
call FarBattleRNG
call BattleRandom
and $1
inc a
inc a
@ -7080,7 +7080,7 @@ BattleCommand3e: ; 3671a
pop af
jr nz, .asm_3674c ; 3673f $b
set 7, [hl]
call FarBattleRNG
call BattleRandom
and $1
inc a
inc a
@ -7110,7 +7110,7 @@ BattleCommand3d: ; 36751
ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVarPair
set 1, [hl]
call FarBattleRNG
call BattleRandom
and $1
inc a
ld [de], a
@ -7152,7 +7152,7 @@ BattleCommanda0: ; 36778
ld c, a
inc c
.asm_367ac
call FarBattleRNG
call BattleRandom
cp c
jr nc, .asm_367ac ; 367b0 $fa
srl b
@ -7177,7 +7177,7 @@ BattleCommanda0: ; 36778
ld c, a
inc c
.asm_367d2
call FarBattleRNG
call BattleRandom
cp c
jr nc, .asm_367d2 ; 367d6 $fa
srl b
@ -7242,7 +7242,7 @@ BattleCommand23: ; 3680f
ld c, a
inc c
.asm_36845
call FarBattleRNG
call BattleRandom
cp c
jr nc, .asm_36845 ; 36849 $fa
srl b
@ -7282,7 +7282,7 @@ BattleCommand23: ; 3680f
ld a, [CurOTMon]
ld c, a
.asm_3689a
call FarBattleRNG
call BattleRandom
and $7
cp b
jr nc, .asm_3689a ; 368a0 $f8
@ -7332,7 +7332,7 @@ BattleCommand23: ; 3680f
ld c, a
inc c
.asm_368e6
call FarBattleRNG
call BattleRandom
cp c
jr nc, .asm_368e6
@ -7378,7 +7378,7 @@ BattleCommand23: ; 3680f
ld a, [CurBattleMon]
ld c, a
.asm_3693a
call FarBattleRNG
call BattleRandom
and $7
cp b
jr nc, .asm_3693a
@ -7496,7 +7496,7 @@ BattleCommand24: ; 369b6
cp EFFECT_TRIPLE_KICK
jr nz, .asm_36a2b
.asm_369ec
call FarBattleRNG
call BattleRandom
and $3
jr z, .asm_369ec
dec a
@ -7530,11 +7530,11 @@ BattleCommand24: ; 369b6
call BattleCommanda8
jp EndMoveEffect
.asm_36a2b
call FarBattleRNG
call BattleRandom
and $3
cp $2
jr c, .asm_36a39 ; 36a32 $5
call FarBattleRNG
call BattleRandom
and $3
.asm_36a39
inc a
@ -7670,7 +7670,7 @@ BattleCommand4d: ; 36ac9
ld d, h
ld e, l
call GetUserItem
call FarBattleRNG
call BattleRandom
cp c
ret nc
call EndRechargeOpp
@ -7917,7 +7917,7 @@ BattleCommand3b: ; 36c2d
call CleanGetBattleVarPair
bit 4, a
ret nz
call FarBattleRNG
call BattleRandom
and 3
inc a
inc a
@ -8116,7 +8116,7 @@ Function0x36d70: ; 36d70
.asm_36d7b
set 7, [hl]
call FarBattleRNG
call BattleRandom
and 3
inc a
inc a
@ -8196,7 +8196,7 @@ BattleCommand30: ; 36dc7
ld a, [PlayerSubStatus5]
bit 5, a
jr nz, .asm_36e0e ; 36e05 $7
call FarBattleRNG
call BattleRandom
cp $40
jr c, .asm_36e52 ; 36e0c $44
.asm_36e0e
@ -8558,7 +8558,7 @@ BattleCommand37: ; 36fed
and a
jr z, .asm_37059 ; 3702c $2b
.asm_3702e
call FarBattleRNG
call BattleRandom
and $7
jr z, .asm_3702e ; 37033 $f9
inc a
@ -8677,7 +8677,7 @@ BattleCommand1f: ; 3707f
call Function0x37e77
jp PrintButItFailed
.asm_370d9
call FarBattleRNG
call BattleRandom
and $3
ld c, a
ld b, $0
@ -9235,7 +9235,7 @@ BattleCommand34: ; 37418
call Function0x37e36
.GetMove
call FarBattleRNG
call BattleRandom
; No invalid moves.
cp BEAT_UP + 1
@ -9596,7 +9596,7 @@ Function0x3762c: ; 3762c
jr .asm_37665
.asm_37656
call FarBattleRNG
call BattleRandom
and a
jr z, .asm_37656
@ -10029,7 +10029,7 @@ BattleCommand61: ; 37874
and a
jp nz, Function0x37e77
push bc
call FarBattleRNG
call BattleRandom
ld b, a
ld hl, .table_37907
ld c, 0
@ -10186,7 +10186,7 @@ BattleCommand66: ; 37991
; getmagnitude
push bc
call FarBattleRNG
call BattleRandom
ld b, a
ld hl, .Magnitudes
.asm_37999

View File

@ -1988,7 +1988,7 @@ Script_random: ; 0x97640
ld b, a
.asm_97653
push bc
call RNG
call Random
pop bc
ld a, [$ffe1]
cp b
@ -1996,7 +1996,7 @@ Script_random: ; 0x97640
jr .asm_97666 ; 0x9765d $7
.asm_9765f
push bc
call RNG
call Random
pop bc
ld a, [$ffe1]
.asm_97666

View File

@ -166,7 +166,7 @@ ParkBall: ; e8a2
.asm_e98e
ld b, a
ld [MagikarpLength], a
call RNG
call Random
cp b
ld a, $0

177
main.asm
View File

@ -5570,49 +5570,50 @@ Function2f79: ; 2f79
; 2f8c
RNG: ; 2f8c
Random: ; 2f8c
; A simple hardware-based random number generator (RNG).
; Two random numbers are generated by adding and subtracting
; the divider to the respective values every time it's called.
; The divider is a value that increments at a rate of 16384Hz.
; The divider is a register that increments at a rate of 16384Hz.
; For comparison, the Game Boy operates at a clock speed of 4.2MHz.
; Additionally, an equivalent function is called every frame.
; Additionally, an equivalent function is executed in VBlank.
; output:
; a: rand2
; ffe1: rand1
; ffe2: rand2
; This leaves a with the value in hRandomSub.
push bc
; Added value
ld a, [rDIV]
ld b, a
ld a, [hRandomAdd]
adc b
ld [hRandomAdd], a
; Subtracted value
ld a, [rDIV]
ld b, a
ld a, [hRandomSub]
sbc b
ld [hRandomSub], a
pop bc
ret
; 2f9f
FarBattleRNG: ; 2f9f
; BattleRNG lives in another bank.
; It handles all RNG calls in the battle engine,
; allowing link battles to remain in sync using a shared PRNG.
BattleRandom: ; 2f9f
; _BattleRandom lives in another bank.
; It handles all RNG calls in the battle engine, allowing
; link battles to remain in sync using a shared PRNG.
; Save bank
ld a, [hROMBank] ; bank
push af
; Bankswitch
ld a, BANK(BattleRNG)
ld a, BANK(_BattleRandom)
rst Bankswitch
call BattleRNG
call _BattleRandom
; Restore bank
ld [$cfb6], a
pop af
@ -5634,7 +5635,7 @@ Function2fb1: ; 2fb1
ld b, a
push bc
.asm_2fbb
call RNG
call Random
ld a, [hRandomAdd]
ld c, a
add b
@ -10416,14 +10417,14 @@ Function4821: ; 4821
; 4822
Function4822: ; 4822
call RNG
call Random
ld a, [hRandomAdd]
and 1
jp Function4af0
; 482c
Function482c: ; 482c
call RNG
call Random
ld a, [hRandomAdd]
and 1
or 2
@ -10431,14 +10432,14 @@ Function482c: ; 482c
; 4838
Function4838: ; 4838
call RNG
call Random
ld a, [hRandomAdd]
and 3
jp Function4af0
; 4842
Function4842: ; 4842
call RNG
call Random
ld a, [hRandomAdd]
and $c
ld hl, $0008
@ -10453,7 +10454,7 @@ Function4851: ; 4851
ld a, [hl]
and $c
ld d, a
call RNG
call Random
ld a, [hRandomAdd]
and $c
cp d
@ -10956,14 +10957,14 @@ Function4b17: ; 4b17
; 4b1d
Function4b1d: ; 4b1d
call RNG
call Random
ld a, [hRandomAdd]
and $7f
jr Function4b2d
; 4b26
Function4b26: ; 4b26
call RNG
call Random
ld a, [hRandomAdd]
and $1f
; fallthrough
@ -13248,10 +13249,10 @@ Function5bae: ; 5bae
ld a, [hRandomAdd]
ld [PlayerID + 1], a
call RNG
call Random
ld [$d84a], a
call DelayFrame
call RNG
call Random
ld [$d84b], a
ld hl, PartyCount
@ -13460,9 +13461,9 @@ Function5d33: ; 5d33
jr z, .asm_5d55
ld a, b
ld [$ac68], a
call RNG
call Random
ld c, a
call RNG
call Random
.asm_5d55
ld [$dc9f], a
@ -15963,7 +15964,7 @@ DaycareStep: ; 7282
dec [hl]
ret nz
call RNG
call Random
ld [hl], a
ld hl, $6e1d
ld a, $5
@ -15983,7 +15984,7 @@ DaycareStep: ; 7282
ld b, $a
.asm_72f8
call RNG
call Random
cp b
ret nc
ld hl, DaycareMan
@ -16180,7 +16181,7 @@ Function7420: ; 7420
call GetCurNick
call Function746e
pop hl
call RNG
call Random
.next
sub [hl]
jr c, .asm_7444
@ -20995,9 +20996,9 @@ Functiond88c: ; d88c
ld a, [IsInBattle]
and a
jr nz, .asm_d9f3
call RNG
call Random
ld b, a
call RNG
call Random
ld c, a
.asm_d9b5
@ -22024,9 +22025,9 @@ Functione277: ; e277
call GetFarByte
ld b, a
ld hl, $ad2c
call RNG
call Random
ld [hli], a
call RNG
call Random
ld [hl], a
call CloseSRAM
ld a, $13
@ -33725,7 +33726,7 @@ Function2a103: ; 2a103
call Function2a111
call Function2a124
call Function2a138
call RNG
call Random
cp b
ret
; 2a111
@ -33804,7 +33805,7 @@ Function2a14f: ; 2a14f
.asm_2a174
push hl
.asm_2a175
call RNG
call Random
cp 100
jr nc, .asm_2a175
inc a
@ -33828,7 +33829,7 @@ Function2a14f: ; 2a14f
call Function1852
jr nz, .asm_2a1aa
call RNG
call Random
cp 89
jr c, .asm_2a1aa
inc b
@ -34073,7 +34074,7 @@ Function2a2ce: ; 2a2ce
call Function1852
jr z, .asm_2a30a
call Function2a27f
call RNG
call Random
cp 100
jr nc, .asm_2a30a
and 3
@ -34182,7 +34183,7 @@ Function2a355: ; 2a355
.asm_2a36e
ld h, d
ld l, e
call RNG
call Random
and $1f
jr z, .asm_2a3cd
and $3
@ -34243,7 +34244,7 @@ Function2a355: ; 2a355
.asm_2a3cd
ld hl, $640f
.asm_2a3d0
call RNG
call Random
and $f
cp $10
jr nc, .asm_2a3d0
@ -34944,7 +34945,7 @@ Function2ed44: ; 2ed44
ld hl, StatusFlags2
bit 6, [hl]
ret z
call RNG
call Random
ld a, [hRandomAdd]
and a
ret nz
@ -34954,7 +34955,7 @@ Function2ed44: ; 2ed44
ld a, [PartyCount]
ld b, a
.asm_2ed70
call RNG
call Random
and $7
cp b
jr nc, .asm_2ed70
@ -34964,7 +34965,7 @@ Function2ed44: ; 2ed44
and $f0
ret nz
.asm_2ed82
call RNG
call Random
and a
jr z, .asm_2ed82
ld b, a
@ -34984,7 +34985,7 @@ Function2ed44: ; 2ed44
ret
.asm_2ed9a
call RNG
call Random
cp $55
ret nc
ld a, [PartyCount]
@ -34994,7 +34995,7 @@ Function2ed44: ; 2ed44
ld a, b
cp $2
jr c, .asm_2edc3
call RNG
call Random
cp $80
jr c, .asm_2edc3
.asm_2edb3
@ -35047,7 +35048,7 @@ Function2ede6: ; 2ede6
ld hl, StatusFlags2
bit 6, [hl]
ret z
call RNG
call Random
cp $10
ret nc
ld hl, PartyMons
@ -35505,7 +35506,7 @@ Function38045: ; 38045
jp z, Function38041
cp $10
jr nz, .asm_38061
call RNG
call Random
cp $80
jr c, .asm_38077
jp Function38041
@ -35513,13 +35514,13 @@ Function38045: ; 38045
.asm_38061
cp $20
jr nz, .asm_3806f
call RNG
call Random
cp $c8
jr c, .asm_38077
jp Function38041
.asm_3806f
call RNG
call Random
cp $a
jp c, Function38041
@ -35538,7 +35539,7 @@ Function38083: ; 38083
jp z, Function38041
cp $10
jr nz, .asm_3809f
call RNG
call Random
cp $14
jr c, .asm_380b5
jp Function38041
@ -35546,13 +35547,13 @@ Function38083: ; 38083
.asm_3809f
cp $20
jr nz, .asm_380ad
call RNG
call Random
cp $1e
jr c, .asm_380b5
jp Function38041
.asm_380ad
call RNG
call Random
cp $c8
jp c, Function38041
@ -35571,7 +35572,7 @@ Function380c1: ; 380c1
jp z, Function38041
cp $10
jr nz, .asm_380dd
call RNG
call Random
cp $32
jr c, .asm_380f3
jp Function38041
@ -35579,13 +35580,13 @@ Function380c1: ; 380c1
.asm_380dd
cp $20
jr nz, .asm_380eb
call RNG
call Random
cp $80
jr c, .asm_380f3
jp Function38041
.asm_380eb
call RNG
call Random
cp $32
jp c, Function38041
@ -36673,13 +36674,13 @@ Function3c314: ; 3c314
ld a, [$ffcb]
cp $2
jr z, .asm_3c341
call FarBattleRNG
call BattleRandom
cp $80
jp c, $43f1
jp Function3c3f3
.asm_3c341
call FarBattleRNG
call BattleRandom
cp $80
jp c, Function3c3f3
jp $43f1
@ -36711,7 +36712,7 @@ Function3c314: ; 3c314
ld a, b
cp $4a
jr z, .asm_3c39f
call FarBattleRNG
call BattleRandom
cp e
jr nc, .asm_3c3c5
jp $43f1
@ -36720,7 +36721,7 @@ Function3c314: ; 3c314
ld a, b
cp $4a
jr nz, .asm_3c3c5
call FarBattleRNG
call BattleRandom
cp c
jr nc, .asm_3c3c5
jp Function3c3f3
@ -36729,19 +36730,19 @@ Function3c314: ; 3c314
ld a, [$ffcb]
cp $2
jr z, .asm_3c3b5
call FarBattleRNG
call BattleRandom
cp c
jp c, Function3c3f3
call FarBattleRNG
call BattleRandom
cp e
jp c, $43f1
jr .asm_3c3c5
.asm_3c3b5
call FarBattleRNG
call BattleRandom
cp e
jp c, $43f1
call FarBattleRNG
call BattleRandom
cp c
jp c, Function3c3f3
jr .asm_3c3c5
@ -36759,13 +36760,13 @@ Function3c314: ; 3c314
ld a, [$ffcb]
cp $2
jr z, .asm_3c3e9
call FarBattleRNG
call BattleRandom
cp $80
jp c, $43f1
jp Function3c3f3
.asm_3c3e9
call FarBattleRNG
call BattleRandom
cp $80
jp c, Function3c3f3
scf
@ -36996,7 +36997,7 @@ Function3c543: ; 3c543
call IsInArray
jr c, .Flee
call FarBattleRNG
call BattleRandom
ld b, a
cp $80
jr nc, .Stay
@ -37772,7 +37773,7 @@ Function3ca8f: ; 3ca8f
ld a, [$c73f]
and a
ret nz
call FarBattleRNG
call BattleRandom
cp $19
ret nc
xor a
@ -37793,7 +37794,7 @@ Function3ca8f: ; 3ca8f
ld a, [$c740]
and a
ret nz
call FarBattleRNG
call BattleRandom
cp $19
ret nc
xor a
@ -39731,7 +39732,7 @@ Function3d672: ; 3d672
.asm_3d6a7
ld a, [OTPartyCount]
ld b, a
call FarBattleRNG
call BattleRandom
and $7
cp b
jr nc, .asm_3d6a7
@ -40122,7 +40123,7 @@ Function3d8b3: ; 3d8b3
jr .asm_3d96c
.asm_3d97a
call FarBattleRNG
call BattleRandom
ld b, a
ld a, [$ffb6]
cp b
@ -42258,7 +42259,7 @@ Function3e7c1: ; 3e7c1
jr nz, .asm_3e882
.asm_3e855
ld hl, EnemyMonMove1
call FarBattleRNG
call BattleRandom
and $3
ld c, a
ld b, $0
@ -42360,7 +42361,7 @@ LoadEnemyMon: ; 3e8eb
; To do this we pull the species from TempEnemyMonSpecies
; Notes:
; FarBattleRNG is used to ensure sync between Game Boys
; BattleRandom is used to ensure sync between Game Boys
; Clear the whole EnemyMon struct
xor a
@ -42419,13 +42420,13 @@ LoadEnemyMon: ; 3e8eb
; 2% Item2
; 25% chance of getting an item
call FarBattleRNG
call BattleRandom
cp a, $c0
ld a, NO_ITEM
jr c, .UpdateItem
; From there, an 8% chance for Item2
call FarBattleRNG
call BattleRandom
cp a, $14 ; 8% of 25% = 2% Item2
ld a, [BaseItems]
jr nc, .UpdateItem
@ -42505,10 +42506,10 @@ LoadEnemyMon: ; 3e8eb
; (HP is initialized at the end of the battle)
call GetRoamMonDVs
inc hl
call FarBattleRNG
call BattleRandom
ld [hld], a
ld c, a
call FarBattleRNG
call BattleRandom
ld [hl], a
ld b, a
; We're done with DVs
@ -42529,9 +42530,9 @@ LoadEnemyMon: ; 3e8eb
.GenerateDVs
; Generate new random DVs
call FarBattleRNG
call BattleRandom
ld b, a
call FarBattleRNG
call BattleRandom
ld c, a
.UpdateDVs
@ -42584,7 +42585,7 @@ LoadEnemyMon: ; 3e8eb
jr nz, .CheckMagikarpArea
; 5% chance of skipping size checks
call RNG
call Random
cp a, $0c ; / $100
jr c, .CheckMagikarpArea
; Try again if > 1614
@ -42593,7 +42594,7 @@ LoadEnemyMon: ; 3e8eb
jr nc, .GenerateDVs
; 20% chance of skipping this check
call RNG
call Random
cp a, $32 ; / $100
jr c, .CheckMagikarpArea
; Try again if > 1598
@ -42618,7 +42619,7 @@ LoadEnemyMon: ; 3e8eb
cp a, MAP_LAKE_OF_RAGE
jr z, .Happiness
; 40% chance of not flooring
call RNG
call Random
cp a, $64 ; / $100
jr c, .Happiness
; Floor at length 1024
@ -43389,14 +43390,14 @@ EmptyBattleTextBox: ; 3edd1
; 3edd8
BattleRNG: ; 3edd8
_BattleRandom: ; 3edd8
; If the normal RNG is used in a link battle it'll desync.
; To circumvent this a shared PRNG is used instead.
; But if we're in a non-link battle we're safe to use it
ld a, [InLinkBattle]
and a
jp z, RNG
jp z, Random
; The PRNG operates in streams of 10 values.
@ -45208,7 +45209,7 @@ Function3f998: ; 3f998
ret
.asm_3f9c4
call FarBattleRNG
call BattleRandom
and $f
ret nz
@ -47147,7 +47148,7 @@ AIChooseMove: ; 440ce
.asm_44197
ld hl, Buffer1
call RNG
call Random
and 3
ld c, a
ld b, 0
@ -59827,7 +59828,7 @@ Function97d23: ; 97d23
Function97d31: ; 97d31
.asm_97d31
call RNG
call Random
cp 100 << 1
jr nc, .asm_97d31
srl a
@ -59854,7 +59855,7 @@ Function97d31: ; 97d31
.asm_97d54
ld c, a
inc c
call RNG
call Random
ld a, [hRandomAdd]
call SimpleDivide
add d
@ -59879,7 +59880,7 @@ Function97d64: ; 97d64
ld a, $a
ld hl, $6138
rst FarCall
call RNG
call Random
ld a, [hRandomAdd]
cp b
ret c

View File

@ -15,7 +15,7 @@ Function1f8000: ; 1f8000
ld a, [hRandomAdd]
ld b, a
.asm_1f8022
call RNG
call Random
ld a, [hRandomAdd]
add b
ld b, a
@ -83,7 +83,7 @@ Function1f8081: ; 1f8081
ld a, [hRandomAdd]
ld b, a
.asm_1f8099
call RNG
call Random
ld a, [hRandomAdd]
add b
ld b, a

View File

@ -1,7 +1,7 @@
GiveOddEgg: ; 1fb4b6
; Figure out which egg to give.
call RNG
call Random
ld hl, .Probabilities
ld c, 0
ld b, c

View File

@ -39,7 +39,7 @@ Fish: ; 9241a
; Fish for monsters with rod b from encounter data in FishGroup at hl.
; Return monster e at level d.
call RNG
call Random
; Got a bite?
cp [hl]
@ -59,7 +59,7 @@ Fish: ; 9241a
ld l, a
; Encounter chance for this monster:
call RNG
call Random
.CheckEncounter
cp [hl]