shithub: pokecrystal

Download patch

ref: c9d3881a2ffa4e3bdb5e5c12d98c20c0bba1e400
parent: 70ecde3f78dc9885a04eb002f68681d03cc2d212
author: yenatch <[email protected]>
date: Fri Aug 30 18:59:40 EDT 2013

rename RNG to Random

also fix 'Far' naming scheme for BattleRandom

this was a long time coming

--- a/battle/ai/scoring.asm
+++ b/battle/ai/scoring.asm
@@ -129,7 +129,7 @@
 	jr .checkmove
 
 .discourage
-	call RNG
+	call Random
 	cp 30
 	jr c, .checkmove
 	inc [hl]
@@ -430,7 +430,7 @@
 	ret
 
 .asm_38815
-	call RNG
+	call Random
 
 	cp $64
 	ret c
@@ -575,7 +575,7 @@
 	call AICheckEnemyQuarterHP
 	ret nc
 
-	call RNG
+	call Random
 	cp 20
 	ret c
 
@@ -588,7 +588,7 @@
 
 
 AIScoring_DreamEater: ; 388ca
-	call RNG
+	call Random
 
 	cp $19
 	ret c
@@ -612,7 +612,7 @@
 	bit 0, a
 	jr nz, .asm_388ef
 
-	call RNG
+	call Random
 
 	cp $b2
 	jr nc, .asm_38911
@@ -628,7 +628,7 @@
 
 	jr nc, .asm_3890f
 
-	call RNG
+	call Random
 
 	cp $a
 	jr c, .asm_388ef
@@ -683,7 +683,7 @@
 	ret
 
 .asm_38938
-	call RNG
+	call Random
 	cp $50
 	ret c
 	dec [hl]
@@ -744,7 +744,7 @@
 	call AICompareSpeed
 
 	ret nc
-	call RNG
+	call Random
 
 	cp $19
 	ret c
@@ -766,7 +766,7 @@
 	bit 0, a
 	jr nz, .asm_3899d
 
-	call RNG
+	call Random
 
 	cp $b2
 	jr nc, .asm_389bf
@@ -782,7 +782,7 @@
 
 	jr nc, .asm_389bd
 
-	call RNG
+	call Random
 
 	cp $a
 	jr c, .asm_3899d
@@ -837,7 +837,7 @@
 	ret
 
 .asm_389e6
-	call RNG
+	call Random
 	cp $50
 	ret c
 	dec [hl]
@@ -878,7 +878,7 @@
 
 .asm_38a12
 	pop hl
-	call RNG
+	call Random
 	cp $28
 	ret c
 	dec [hl]
@@ -894,7 +894,7 @@
 AIScoring_Bide: ; 38a1e
 	call AICheckEnemyMaxHP
 	ret c
-	call RNG
+	call Random
 	cp $19
 	ret c
 	inc [hl]
@@ -926,7 +926,7 @@
 	ret
 
 .asm_38a45
-	call RNG
+	call Random
 	cp $19
 	ret c
 	dec [hl]
@@ -948,7 +948,7 @@
 AIScoring_Reflect: ; 38a54
 	call AICheckEnemyMaxHP
 	ret c
-	call RNG
+	call Random
 	cp $14
 	ret c
 	inc [hl]
@@ -1041,7 +1041,7 @@
 	ret c
 
 .asm_38acd
-	call RNG
+	call Random
 	cp $c8
 	ret c
 
@@ -1061,7 +1061,7 @@
 AIScoring_Confuse: ; 38adb
 	call AICheckPlayerHalfHP
 	ret c
-	call RNG
+	call Random
 	cp $19
 	jr c, .asm_38ae7
 	inc [hl]
@@ -1156,7 +1156,7 @@
 	ret nz
 	call AICompareSpeed
 	ret c
-	call RNG
+	call Random
 	cp 30
 	ret c
 	dec [hl]
@@ -1183,7 +1183,7 @@
 	ret
 
 .asm_38b72
-	call RNG
+	call Random
 	cp 40
 	ret c
 	inc [hl]
@@ -1334,7 +1334,7 @@
 
 
 .asm_38c30
-	call RNG
+	call Random
 	cp $64
 	jr c, .asm_38c38
 
@@ -1388,7 +1388,7 @@
 	jr nc, .asm_38c81
 
 .asm_38c78
-	call RNG
+	call Random
 	cp $46
 	ret c
 	dec [hl]
@@ -1527,7 +1527,7 @@
 	cp $f
 	jr nc, .asm_38d0b
 
-	call RNG
+	call Random
 	cp $64
 	ret nc
 
@@ -1536,7 +1536,7 @@
 	ret
 
 .asm_38d0d
-	call RNG
+	call Random
 	cp $64
 	ret c
 	dec [hl]
@@ -1700,7 +1700,7 @@
 	ret
 
 .asm_38dc9
-	call RNG
+	call Random
 
 	cp $19
 	ret c
@@ -1722,7 +1722,7 @@
 	pop hl
 	jr nc, .asm_38dee
 
-	call RNG
+	call Random
 	cp 100
 	ret c
 	dec [hl]
@@ -1734,7 +1734,7 @@
 	ret nz
 
 .asm_38df3
-	call RNG
+	call Random
 	cp 20
 	ret c
 	inc [hl]
@@ -1961,7 +1961,7 @@
 	inc [hl]
 
 .asm_38f14
-	call RNG
+	call Random
 	cp 20
 	ret c
 	inc [hl]
@@ -1985,7 +1985,7 @@
 	cp GHOST
 	jr z, .asm_38f41
 
-	call RNG
+	call Random
 	cp 20
 	ret c
 	inc [hl]
@@ -1992,7 +1992,7 @@
 	ret
 
 .asm_38f41
-	call RNG
+	call Random
 	cp 100
 	ret c
 	dec [hl]
@@ -2169,7 +2169,7 @@
 	cp 8
 	jr nc, .asm_39020
 
-	call RNG
+	call Random
 	cp 200
 	ret nc
 	dec [hl]
@@ -2196,7 +2196,7 @@
 	ret
 
 .asm_39032
-	call RNG
+	call Random
 	cp 200
 	ret nc
 	dec [hl]
@@ -2558,7 +2558,7 @@
 
 
 .asm_391ca
-	call RNG
+	call Random
 	cp 100
 	jr c, .asm_391d2
 	dec [hl]
@@ -2634,7 +2634,7 @@
 	cp WEATHER_RAIN
 	ret nz
 
-	call RNG
+	call Random
 	cp 25 ; 1/10
 	ret c
 
@@ -2657,7 +2657,7 @@
 	cp WEATHER_SUN
 	ret nz
 
-	call RNG
+	call Random
 	cp 25 ; 1/10
 	ret c
 
@@ -3150,7 +3150,7 @@
 	pop hl
 	jr nc, .asm_39425
 
-	call RNG
+	call Random
 	cp 230
 	ret nc
 
@@ -3274,7 +3274,7 @@
 	call AICheckEnemyMaxHP
 	jr c, .nextmove
 
-	call RNG
+	call Random
 	cp 200 ; 1/5
 	jr c, .nextmove
 
@@ -3347,7 +3347,7 @@
 
 
 Function_0x39521: ; 39521
-	call RNG
+	call Random
 	cp 50 ; 1/5
 	ret
 ; 39527
@@ -3354,7 +3354,7 @@
 
 
 Function_0x39527: ; 39527
-	call RNG
+	call Random
 	cp $80 ; 1/2
 	ret
 ; 3952d
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -288,7 +288,7 @@
 	call FarPlayBattleAnimation
 
 ; 50% chance of hitting itself
-	call FarBattleRNG
+	call BattleRandom
 	cp $80
 	jr nc, .CheckAttract
 
@@ -319,7 +319,7 @@
 	call FarPlayBattleAnimation
 
 ; 50% chance of infatuation
-	call FarBattleRNG
+	call BattleRandom
 	cp $80
 	jr c, .CheckDisabledMove
 
@@ -353,7 +353,7 @@
 	ret z
 
 ; 25% chance to be fully paralyzed
-	call FarBattleRNG
+	call BattleRandom
 	cp $3f
 	ret nc
 
@@ -544,7 +544,7 @@
 	call FarPlayBattleAnimation
 
 ; 50% chance of hitting itself
-	call FarBattleRNG
+	call BattleRandom
 	cp $80
 	jr nc, .CheckAttract
 
@@ -598,7 +598,7 @@
 	call FarPlayBattleAnimation
 
 ; 50% chance of infatuation
-	call FarBattleRNG
+	call BattleRandom
 	cp $80
 	jr c, .CheckDisabledMove
 
@@ -633,7 +633,7 @@
 	ret z
 
 ; 25% chance to be fully paralyzed
-	call FarBattleRNG
+	call BattleRandom
 	cp $3f
 	ret nc
 
@@ -808,7 +808,7 @@
 
 ; 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 @@
 
 ; Another random number from 0 to obedience level + monster level
 .rand2
-	call FarBattleRNG
+	call BattleRandom
 	cp b
 	jr nc, .rand2
 
@@ -843,7 +843,7 @@
 	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 @@
 
 
 .Nap
-	call FarBattleRNG
+	call BattleRandom
 	add a
 	swap a
 	and 7
@@ -876,7 +876,7 @@
 
 
 .DoNothing
-	call FarBattleRNG
+	call BattleRandom
 	and 3
 
 ; 'loafing around!'
@@ -964,7 +964,7 @@
 
 
 .RandomMove
-	call FarBattleRNG
+	call BattleRandom
 	and 3
 
 	cp b
@@ -1324,7 +1324,7 @@
 	ld hl, .Chances
 	ld b, 0
 	add hl, bc
-	call FarBattleRNG
+	call BattleRandom
 	cp [hl]
 	ret nc
 	ld a, 1
@@ -2338,7 +2338,7 @@
 
 ; Multiply by 85-100%...
 .loop
-	call FarBattleRNG
+	call BattleRandom
 	rrca
 	cp $d9 ; 85%
 	jr c, .loop
@@ -2423,7 +2423,7 @@
 	cp $ff
 	jr z, .Hit
 
-	call FarBattleRNG
+	call BattleRandom
 	cp b
 	jr nc, .Miss
 
@@ -2701,7 +2701,7 @@
 	ld hl, EnemyMoveEffectChance
 .asm_34ee1
 
-	call FarBattleRNG
+	call BattleRandom
 	cp [hl]
 	pop hl
 	ret c
@@ -2986,7 +2986,7 @@
 	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 @@
 	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 @@
 	bit 4, [hl]
 	jp nz, Function0x35923
 	set 4, [hl]
-	call FarBattleRNG
+	call BattleRandom
 	and $3
 	inc a
 	inc a
@@ -4782,7 +4782,7 @@
 
 	call SwitchTurn
 .asm_35a13
-	call FarBattleRNG
+	call BattleRandom
 	and $1f
 	cp $a
 	jr c, .asm_35a24 ; 35a1a $8
@@ -5005,7 +5005,7 @@
 	dec hl
 .asm_35b62
 	push hl
-	call FarBattleRNG
+	call BattleRandom
 	and $3
 	ld c, a
 	ld b, $0
@@ -5173,7 +5173,7 @@
 	jr z, .asm_35c91 ; 35c46 $49
 	push bc
 	call GetMoveName
-	call FarBattleRNG
+	call BattleRandom
 	and $3
 	inc a
 	inc a
@@ -5576,7 +5576,7 @@
 	ld b, $3
 
 .asm_35ea4
-	call FarBattleRNG
+	call BattleRandom
 	and b
 	jr z, .asm_35ea4
 	cp 7
@@ -5625,7 +5625,7 @@
 	bit 5, a
 	jr nz, .asm_35eec
 
-	call FarBattleRNG
+	call BattleRandom
 	cp $40
 	ret c
 
@@ -5715,7 +5715,7 @@
 	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 @@
 	cp EFFECT_ACCURACY_DOWN_HIT
 	jr z, .DidntMiss
 
-	call FarBattleRNG
+	call BattleRandom
 	cp $40
 	jr c, .Failed
 
@@ -6789,7 +6789,7 @@
 
 ; 1/3 chance of each status
 .loop
-	call FarBattleRNG
+	call BattleRandom
 	swap a
 	and 3
 	jr z, .loop
@@ -7043,7 +7043,7 @@
 	ld [de], a
 	ld [PlayerMoveEffect], a
 	ld [EnemyMoveEffect], a
-	call FarBattleRNG
+	call BattleRandom
 	and $1
 	inc a
 	inc a
@@ -7080,7 +7080,7 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	ld c, a
 	inc c
 .asm_368e6
-	call FarBattleRNG
+	call BattleRandom
 	cp c
 	jr nc, .asm_368e6
 
@@ -7378,7 +7378,7 @@
 	ld a, [CurBattleMon]
 	ld c, a
 .asm_3693a
-	call FarBattleRNG
+	call BattleRandom
 	and $7
 	cp b
 	jr nc, .asm_3693a
@@ -7496,7 +7496,7 @@
 	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 @@
 	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 @@
 	ld d, h
 	ld e, l
 	call GetUserItem
-	call FarBattleRNG
+	call BattleRandom
 	cp c
 	ret nc
 	call EndRechargeOpp
@@ -7917,7 +7917,7 @@
 	call CleanGetBattleVarPair
 	bit 4, a
 	ret nz
-	call FarBattleRNG
+	call BattleRandom
 	and 3
 	inc a
 	inc a
@@ -8116,7 +8116,7 @@
 
 .asm_36d7b
 	set 7, [hl]
-	call FarBattleRNG
+	call BattleRandom
 	and 3
 	inc a
 	inc a
@@ -8196,7 +8196,7 @@
 	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 @@
 	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 @@
 	call Function0x37e77
 	jp PrintButItFailed
 .asm_370d9
-	call FarBattleRNG
+	call BattleRandom
 	and $3
 	ld c, a
 	ld b, $0
@@ -9235,7 +9235,7 @@
 	call Function0x37e36
 
 .GetMove
-	call FarBattleRNG
+	call BattleRandom
 
 ; No invalid moves.
 	cp BEAT_UP + 1
@@ -9596,7 +9596,7 @@
 	jr .asm_37665
 
 .asm_37656
-	call FarBattleRNG
+	call BattleRandom
 	and a
 	jr z, .asm_37656
 
@@ -10029,7 +10029,7 @@
 	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 @@
 ; getmagnitude
 
 	push bc
-	call FarBattleRNG
+	call BattleRandom
 	ld b, a
 	ld hl, .Magnitudes
 .asm_37999
--- a/engine/scripting.asm
+++ b/engine/scripting.asm
@@ -1988,7 +1988,7 @@
 	ld b, a
 .asm_97653
 	push bc
-	call RNG
+	call Random
 	pop bc
 	ld a, [$ffe1]
 	cp b
@@ -1996,7 +1996,7 @@
 	jr .asm_97666 ; 0x9765d $7
 .asm_9765f
 	push bc
-	call RNG
+	call Random
 	pop bc
 	ld a, [$ffe1]
 .asm_97666
--- a/items/item_effects.asm
+++ b/items/item_effects.asm
@@ -166,7 +166,7 @@
 .asm_e98e
 	ld b, a
 	ld [MagikarpLength], a
-	call RNG
+	call Random
 
 	cp b
 	ld a, $0
--- a/main.asm
+++ b/main.asm
@@ -5570,49 +5570,50 @@
 ; 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 @@
 	ld b, a
 	push bc
 .asm_2fbb
-	call RNG
+	call Random
 	ld a, [hRandomAdd]
 	ld c, a
 	add b
@@ -10416,7 +10417,7 @@
 ; 4822
 
 Function4822: ; 4822
-	call RNG
+	call Random
 	ld a, [hRandomAdd]
 	and 1
 	jp Function4af0
@@ -10423,7 +10424,7 @@
 ; 482c
 
 Function482c: ; 482c
-	call RNG
+	call Random
 	ld a, [hRandomAdd]
 	and 1
 	or 2
@@ -10431,7 +10432,7 @@
 ; 4838
 
 Function4838: ; 4838
-	call RNG
+	call Random
 	ld a, [hRandomAdd]
 	and 3
 	jp Function4af0
@@ -10438,7 +10439,7 @@
 ; 4842
 
 Function4842: ; 4842
-	call RNG
+	call Random
 	ld a, [hRandomAdd]
 	and $c
 	ld hl, $0008
@@ -10453,7 +10454,7 @@
 	ld a, [hl]
 	and $c
 	ld d, a
-	call RNG
+	call Random
 	ld a, [hRandomAdd]
 	and $c
 	cp d
@@ -10956,7 +10957,7 @@
 ; 4b1d
 
 Function4b1d: ; 4b1d
-	call RNG
+	call Random
 	ld a, [hRandomAdd]
 	and $7f
 	jr Function4b2d
@@ -10963,7 +10964,7 @@
 ; 4b26
 
 Function4b26: ; 4b26
-	call RNG
+	call Random
 	ld a, [hRandomAdd]
 	and $1f
 	; fallthrough
@@ -13248,10 +13249,10 @@
 	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 @@
 	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 @@
 	dec [hl]
 	ret nz
 
-	call RNG
+	call Random
 	ld [hl], a
 	ld hl, $6e1d
 	ld a, $5
@@ -15983,7 +15984,7 @@
 	ld b, $a
 
 .asm_72f8
-	call RNG
+	call Random
 	cp b
 	ret nc
 	ld hl, DaycareMan
@@ -16180,7 +16181,7 @@
 	call GetCurNick
 	call Function746e
 	pop hl
-	call RNG
+	call Random
 .next
 	sub [hl]
 	jr c, .asm_7444
@@ -20995,9 +20996,9 @@
 	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 @@
 	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 @@
 	call Function2a111
 	call Function2a124
 	call Function2a138
-	call RNG
+	call Random
 	cp b
 	ret
 ; 2a111
@@ -33804,7 +33805,7 @@
 .asm_2a174
 	push hl
 .asm_2a175
-	call RNG
+	call Random
 	cp 100
 	jr nc, .asm_2a175
 	inc a
@@ -33828,7 +33829,7 @@
 	call Function1852
 	jr nz, .asm_2a1aa
 
-	call RNG
+	call Random
 	cp 89
 	jr c, .asm_2a1aa
 	inc b
@@ -34073,7 +34074,7 @@
 	call Function1852
 	jr z, .asm_2a30a
 	call Function2a27f
-	call RNG
+	call Random
 	cp 100
 	jr nc, .asm_2a30a
 	and 3
@@ -34182,7 +34183,7 @@
 .asm_2a36e
 	ld h, d
 	ld l, e
-	call RNG
+	call Random
 	and $1f
 	jr z, .asm_2a3cd
 	and $3
@@ -34243,7 +34244,7 @@
 .asm_2a3cd
 	ld hl, $640f
 .asm_2a3d0
-	call RNG
+	call Random
 	and $f
 	cp $10
 	jr nc, .asm_2a3d0
@@ -34944,7 +34945,7 @@
 	ld hl, StatusFlags2
 	bit 6, [hl]
 	ret z
-	call RNG
+	call Random
 	ld a, [hRandomAdd]
 	and a
 	ret nz
@@ -34954,7 +34955,7 @@
 	ld a, [PartyCount]
 	ld b, a
 .asm_2ed70
-	call RNG
+	call Random
 	and $7
 	cp b
 	jr nc, .asm_2ed70
@@ -34964,7 +34965,7 @@
 	and $f0
 	ret nz
 .asm_2ed82
-	call RNG
+	call Random
 	and a
 	jr z, .asm_2ed82
 	ld b, a
@@ -34984,7 +34985,7 @@
 	ret
 
 .asm_2ed9a
-	call RNG
+	call Random
 	cp $55
 	ret nc
 	ld a, [PartyCount]
@@ -34994,7 +34995,7 @@
 	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 @@
 	ld hl, StatusFlags2
 	bit 6, [hl]
 	ret z
-	call RNG
+	call Random
 	cp $10
 	ret nc
 	ld hl, PartyMons
@@ -35505,7 +35506,7 @@
 	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 @@
 .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 @@
 	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 @@
 .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 @@
 	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 @@
 .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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	call IsInArray
 	jr c, .Flee
 
-	call FarBattleRNG
+	call BattleRandom
 	ld b, a
 	cp $80
 	jr nc, .Stay
@@ -37772,7 +37773,7 @@
 	ld a, [$c73f]
 	and a
 	ret nz
-	call FarBattleRNG
+	call BattleRandom
 	cp $19
 	ret nc
 	xor a
@@ -37793,7 +37794,7 @@
 	ld a, [$c740]
 	and a
 	ret nz
-	call FarBattleRNG
+	call BattleRandom
 	cp $19
 	ret nc
 	xor a
@@ -39731,7 +39732,7 @@
 .asm_3d6a7
 	ld a, [OTPartyCount]
 	ld b, a
-	call FarBattleRNG
+	call BattleRandom
 	and $7
 	cp b
 	jr nc, .asm_3d6a7
@@ -40122,7 +40123,7 @@
 	jr .asm_3d96c
 
 .asm_3d97a
-	call FarBattleRNG
+	call BattleRandom
 	ld b, a
 	ld a, [$ffb6]
 	cp b
@@ -42258,7 +42259,7 @@
 	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 @@
 ; 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 @@
 ;     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 @@
 ; (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 @@
 	
 .GenerateDVs
 ; Generate new random DVs
-	call FarBattleRNG
+	call BattleRandom
 	ld b, a
-	call FarBattleRNG
+	call BattleRandom
 	ld c, a
 	
 .UpdateDVs
@@ -42584,7 +42585,7 @@
 	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 @@
 	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 @@
 	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,7 +43390,7 @@
 ; 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.
 
@@ -43396,7 +43397,7 @@
 ; 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 @@
 	ret
 
 .asm_3f9c4
-	call FarBattleRNG
+	call BattleRandom
 	and $f
 	ret nz
 
@@ -47147,7 +47148,7 @@
 
 .asm_44197
 	ld hl, Buffer1
-	call RNG
+	call Random
 	and 3
 	ld c, a
 	ld b, 0
@@ -59827,7 +59828,7 @@
 
 Function97d31: ; 97d31
 .asm_97d31
-	call RNG
+	call Random
 	cp 100 << 1
 	jr nc, .asm_97d31
 	srl a
@@ -59854,7 +59855,7 @@
 .asm_97d54
 	ld c, a
 	inc c
-	call RNG
+	call Random
 	ld a, [hRandomAdd]
 	call SimpleDivide
 	add d
@@ -59879,7 +59880,7 @@
 	ld a, $a
 	ld hl, $6138
 	rst FarCall
-	call RNG
+	call Random
 	ld a, [hRandomAdd]
 	cp b
 	ret c
--- a/stats/battle_tower.asm
+++ b/stats/battle_tower.asm
@@ -15,7 +15,7 @@
 	ld a, [hRandomAdd]
 	ld b, a
 .asm_1f8022
-	call RNG
+	call Random
 	ld a, [hRandomAdd]
 	add b
 	ld b, a
@@ -83,7 +83,7 @@
 	ld a, [hRandomAdd]
 	ld b, a
 .asm_1f8099
-	call RNG
+	call Random
 	ld a, [hRandomAdd]
 	add b
 	ld b, a
--- a/stats/odd_eggs.asm
+++ b/stats/odd_eggs.asm
@@ -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
--- a/stats/wild/fish.asm
+++ b/stats/wild/fish.asm
@@ -39,7 +39,7 @@
 ; 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 @@
 	ld l, a
 	
 ; Encounter chance for this monster:
-	call RNG
+	call Random
 	
 .CheckEncounter
 	cp [hl]