diff options
author | yenatch <yenatch@gmail.com> | 2013-08-30 22:59:40 -0400 |
---|---|---|
committer | yenatch <yenatch@gmail.com> | 2013-08-30 22:59:40 -0400 |
commit | c9d3881a2ffa4e3bdb5e5c12d98c20c0bba1e400 (patch) | |
tree | e1b80a12542896021ce624926b7fa2b00517bd92 /main.asm | |
parent | 70ecde3f78dc9885a04eb002f68681d03cc2d212 (diff) |
rename RNG to Random
also fix 'Far' naming scheme for BattleRandom
this was a long time coming
Diffstat (limited to 'main.asm')
-rw-r--r-- | main.asm | 177 |
1 files changed, 89 insertions, 88 deletions
@@ -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 |