1. New to the forums? Check out our Mentorship Program!
    Our mentors will answer your questions and help you become a part of the community!
  2. Welcome to Smogon Forums! Please take a minute to read the rules.
  3. Welcome to Wi-Fi! Please remember to read the rules and do NOT create a new thread for simple trades or Friend Safari codes.

Past Gen RNG Research

Discussion in 'Wi-Fi' started by mingot, Sep 12, 2009.

  1. Kaphotics

    Kaphotics Remodeling Kitchens
    is a Pokemon Researcheris a Contributor to Smogon

    Joined:
    Apr 25, 2009
    Messages:
    779
    5th Generation & Pickup

    img of researcher (open)
    [​IMG]


    Pickup only works if you don't run.

    Carrying 6 Pickup Mons and defeating a wild poke:
    It cycles 7 times after battle if you don't get a pickup, 8 times if one gets a pickup, hence a calc proccing another calc immediately after.

    Exiting Seed from the battle is considered the Initial Seed for this post:

    Initial
    Code:
    Advanced Once, 
      if    SEED*100>>32    is < 10
         then [SEED+1]*100>>32 for Pickup Item Value (0-99)
        else, advance once and repeat for next slot.
      end
    6 iterations, there is one calc afterwards for something else.
    Pickup Table located here, although the placement for the 1%'s is off. Prism Scale is 98 for level 100 (leftovers is 99).

    Double Pickup (open)
    [​IMG]


    Code:
    0-29 30-39 40-49 50-59 60-69 70-79 80-89 90-94 95-97 98 99
     30%   10%   10%   10%   10%   10%   10%    5%    3% 1% 1%
  2. Bond697

    Bond697 Dies, died, will die.
    is a Pokemon Researcher

    Joined:
    Jun 20, 2010
    Messages:
    307
    you can simplify that, actually. the game does it like so:

    -rng advance
    -save u32 to r0
    -umull u32(r0) by 0xA to r4/r5 then r0/r1(the result we want in r4 is moved to r1)
    -move r1 -> r0
    -cmp r0 to 0, then bcs
    -go ahead with the pickup calc if the result of r0 * 0xA is 0, move on if == 1-9
    -rng advance
    -this calc is r0 * 0x64

    to make it easier, just make it ((seed) >> 32 * 0xA) >> 32; if result == 0, do pickup calc
  3. chiizu

    chiizu PPPPPPPPPPPPPPPPP RNG
    is a Programmeris a Pokemon Researcher

    Joined:
    Nov 12, 2010
    Messages:
    422
    On request, here's the translation of the double battle encounters found in the same pokebw readme file as the compound eyes encounter (which were implemented in PPRNG probably a month ago when this readme was first found...).

    Researcher screenshots with actual RNG frames are left as an exercise for the researcher.

    Code:
    0:  Start
    1:  Sync check (applies to both Pokemon, skip this if lead Pokemon
                    has compound eyes just like in single encounter)
    2:  Double battle check (as posted previously in this thread)
    3:  ESV for right Pokemon
    4:  Unknown (same unknown as in normal wild encounters,
                 my guess is Pokerus infection check)
    5:  ESV for left Pokemon
    6:  Unknown (same as 4 above, I'd imagine)
    7:  Right Pokemon PID
    8:  Right Pokemon Nature
    9:  If right Pokemon can hold an item, roll for item as previously described,
          otherwise this is skipped (i.e. no RNG value consumed)
    10: Left Pokemon PID
    11: Left Pokemon Nature
    12: If left Pokemon can hold an item, role for item as previously described,
          otherwise this is skipped (i.e. no RNG value consumed)
    
    If the double battle check fails, the single battle frame continues on as normal (i.e. steps 3, 4, 7, 8, and 9).

    The fun take away here is that the PID and nature of the left Pokemon is affected by whether the right Pokemon can hold an item.

    Also, regarding compound eyes removing the sync check, this means that some PIDs for swirling dust / bridge shadow encounters will be hittable with compound eyes when they would not be with a non-compound eyes lead.
  4. Bond697

    Bond697 Dies, died, will die.
    is a Pokemon Researcher

    Joined:
    Jun 20, 2010
    Messages:
    307
    Thank you.

    Here's the shaking patch info, btw:

    Show Hide
    Code:
    
    shaking patches
    ---------------------------
    
    First, there's a secondary step counter at 2257034(White U) that counts 0-19 like so:
    
    021AABE8 2000     mov     r0,#0x0   // r0 from 2257028 to 0
    021AABEA 43C0     mvn     r0,r0 // set r0 to NOT 0, so r0 = !0 = FFFFFFFF
    021AABEC 330C     add     r3,#0xC // 2257028 + 0xC - 2257034 - shakling patch step counter address
    021AABEE 4282     cmp     r2,r0 // r2 is shaking patch step counter value, compare counter value w/ 0
    021AABF0 D201     bcs     #0x21AABF6 // to 21AABF6 if r2 is 0, shaking patch calc stuff
    021AABF2 1C50     add     r0,r2,1 // tack 1 onto the value of the step counter, throw sum in r0
    021AABF4 6018     str     r0,[r3] // store this new value (step counter +1) to 2257034
    021AABF6 4804     ldr     r0,=#0x5B8
    021AABF8 681A     ldr     r2,[r3] // load the new step counter to r2
    021AABFA 5A08     ldrh    r0,[r1,r0] // halfword at 232e500 to r0
    021AABFC 4282     cmp     r2,r0
    021AABFE D301     bcc     #0x21AAC04 // true, branch
    
    021AAC04 2000     mov     r0,#0x0
    021AAC06 4770     bx      r14
    
    
    When it does hit 0, it does this to see if it should create a shaking patch:
    
    02005728 B538     push    {r3-r5,r14} // this all just sets up the rng for multiplication
    0200572A 1C05     mov     r5,r0
    0200572C 480A     ldr     r0,=#0x20AA1B4
    0200572E 6904     ldr     r4,[r0,#0x10]
    02005730 68A0     ldr     r0,[r4,#0x8]
    02005732 68E1     ldr     r1,[r4,#0xC]
    02005734 6822     ldr     r2,[r4]
    02005736 6863     ldr     r3,[r4,#0x4]
    02005738 F096EC98 blx     #0x209C06C
    
    (rng.multiply())(via 64-bit multiply function)
    
    0200573C 6922     ldr     r2,[r4,#0x10] // put the rng back, get ready to do the standard u32 * XXX(or skip it for pid calcs)
    0200573E 6963     ldr     r3,[r4,#0x14]
    02005740 1810     add     r0,r2,r0
    02005742 414B     adc     r3,r1
    02005744 6020     str     r0,[r4]
    02005746 6063     str     r3,[r4,#0x4]
    02005748 1C18     mov     r0,r3
    0200574A 2100     mov     r1,#0x0
    0200574C 2300     mov     r3,#0x0
    0200574E 1C2A     mov     r2,r5
    02005750 F096EC8C blx     #0x209C06C
    
    u32 * XXX multiplier- 3E8 in this case(1000dec)
    rnd.calc();
    
    02005754 1C08         mov  r0, r1   // final result
    02005756 BD38         pop  (r3-r5,r15)  // restore stack, jump back to restored r15
    
    021AA8D4 490C     ldr     r1,=#0x5BA
    021AA8D6 5A62     ldrh    r2,[r4,r1] // r2 == 0xA
    021AA8D8 210A     mov     r1,#0xA // r1 == 0xA
    021AA8DA 4351     mul     r1,r2 // r1 == 100dec
    021AA8DC 4288     cmp     r0,r1 // compare result of rng*1000dec mult w/ 1000(r0-r1)
    021AA8DE D304     bcc     #0x21AA8EA // carry isn't clear unless it's less than 100, so branch if < 100
    
    if >= 100
    -------------
    021AA8E0 1C30     mov     r0,r6 // false? set r0 to 2257028- the rng advancement routine
    021AA8E2 F000F993 bl      #0x21AAC0C // done, off to other stuff
    


    I'll put the rest up later with some notes.

    e: not that this is super-important, but npc movement is (u32 * 4) >> 32. npcs move based on a timed coundown and once it hits 0 the rng is called and that calculation is done. i never bothered to figure out what direction 0-3 correspond to, though, exactly.

    [21:50] <Kaphotics> 0 - Up, 1 - Down, 2 - Left, 3 - Right

    there, directions
  5. Kaphotics

    Kaphotics Remodeling Kitchens
    is a Pokemon Researcheris a Contributor to Smogon

    Joined:
    Apr 25, 2009
    Messages:
    779
    Wondercards with a locked-in gender but variable nature have their own method of PID generation separate from the normal generation.

    Test Data (open)
    Code:
    0	E9F11E5F06414BB4	Initial Pre-Load
    Everything is loaded from the card from 1 to 23
    24	C459BD1164D3FAEC	Initial: "OT" received a "PKM" (Pre-IV)
    25	DD993995A584E9DF	27	HP
    26	0244C0E5E7D83ABE	0	Atk
    27	0BF80A6EF31779B9	1	Def
    28	41FA83D8D89CA5C0	8	SpA
    29	6C81B76ED2E7C383	13	SpD
    30	D7F97C17D9CCDC72	26	Spe
    31	8814F98BAF1099BD	
    32	417D45ACE4246B54	
    33	EA3491B7DF40EAE7	
    34	157F7C07B2C9EAE6	
    35	D193AF140CCF6181	
    36	000427771FAD1FA8	0 (hardy) We look Forward to your next visit	
    37	F99EEE51E2FD040B	End Talk-Double Advance
    38	EB0A5CBEB5701A1A
    
    Up/T Low/S
    1892 0089
    181B 0000
    XOR = 0


    Another Trial

    Code:
    0	9E2FE436D6F3BA08	Initial Pre-Load
    24	41FA83D8D89CA5C0	Initial Pre-IV
    25	6C81B76ED2E7C383	13	HP
    26	D7F97C17D9CCDC72	26	Atk
    27	8814F98BAF1099BD	17	Def
    28	417D45ACE4246B54	6	SpA
    29	EA3491B7DF40EAE7	29	SpD
    30	157F7C07B2C9EAE6	2	Spe
    31	D193AF140CCF6181	
    32	000427771FAD1FA8	
    33	F99EEE51E2FD040B	
    34	EB0A5CBEB5701A1A	
    35	22D151AC420ED505	
    36	D11A3A8EEF2356BC	20 (calm)
    37	15245718F1A672EF	End Talk-Double Advance
    38	BDCEA77E62DCDE0E	
    
    Up/T Low/S
    18E8 00F3
    181B 0000
    XOR = 0


    "GLAN" Wondercard Generation Structure
    Code:
    0 - Initial
    (card loaded/pre-data, dependent on card)
    25 - HP IV (>>27)   [offset varies]
    26 - Atk IV (>>27)
    27 - Def IV (>>27)
    28 - SpA IV (>>27)
    29 - SpD IV (>>27)
    30 - Spe IV (>>27)
    31-35 PID Gen
    36 - Nature (*25,>>32)
    This was the Hydreigon present. Didn't test the Golurk.

    Essentially, there's 2 more dummy frames before the IVs and 1 more in the PID routine. Should be easy to adapt this method in!
  6. Bond697

    Bond697 Dies, died, will die.
    is a Pokemon Researcher

    Joined:
    Jun 20, 2010
    Messages:
    307
    white forest pids match gift pokemon as far as i can see. there might be a different formula for it, but i've not done the disassembly yet.
  7. chiizu

    chiizu PPPPPPPPPPPPPPPPP RNG
    is a Programmeris a Pokemon Researcher

    Joined:
    Nov 12, 2010
    Messages:
    422
    This appears to be the main method used to detect whether the game is running on a DS or DSi. I base that statement on the fact that it's reading a value from a register that doesn't exist on the DS and checking for a specific result. On a DS, this should return a 0 value if no such register exists.

    This function is called in lots of places and the result is used to decide which code or values to use in numerous functions.

    Code (open)
    Code:
    ------------------- DSi check  (White JP)
    -- determines whether running on DSi, and stores result to 02151008 (1 = DSi, 0 = DS)
    --- check is done by looking at a register 0x04004000, which doesn't exist on DS
    --- if lowest two bits == 0x1, *02151008 = 1
    --- subsequent calls just read from 02151008 rather than checking the register
    :02085C60 E59F003C ldr r0,[r15, #+0x3c]      ; r0 = 0x02151004 (baes address of a global variable structure)
    :02085C64 E590001C ldr r0,[r0, #+0x1c]       ; r0 = r0[1c](*02151020) - static bool for onetime check
    :02085C68 E3500000 cmp r0,#0x0               ; if (r0 == 0) - if not called before
    :02085C6C 1A000009 bne 02085C98              ; {
    :02085C70 E59F0030 ldr r0,[r15, #+0x30]      ;   r0 = 0x04004000
    :02085C74 E3A02001 mov  r2,#0x1              ;   r2 = 1
    :02085C78 E5D00000 ldrb r0,[r0, #+0x0]       ;   r0 = *04004000 (DSi register?)
    :02085C7C E3A01001 mov  r1,#0x1              ;   r1 = 1
    :02085C80 E2000003 and  r0,r0,#0x3           ;   r0 = r0 & 0x3
    :02085C84 E3500001 cmp r0,#0x1               ;   if (r0 != 0x1) - check that low 2 bits of register are 01
    :02085C88 E59F0014 ldr r0,[r15, #+0x14]      ;   r0 = 0x02151004
    :02085C8C 13A02000 movne  r2,#0x0            ;     r2 = 0 (not 0x1, so not DSi)
    :02085C90 E5802004 str r2,[r0, #+0x4]        ;   *02151008 = r2 (store in global)
    :02085C94 E580101C str r1,[r0, #+0x1c]       ;   *02151020 = r1 (set flag to indicate result is cached
    :02085C98 E59F0004 ldr r0,[r15, #+0x4]       ; r0 = 0x02151004
    :02085C9C E5900004 ldr r0,[r0, #+0x4]        ; r0 = *02151008  (read cached result)
    :02085CA0 E12FFF1E bx r14
    
    
  8. Kaphotics

    Kaphotics Remodeling Kitchens
    is a Pokemon Researcheris a Contributor to Smogon

    Joined:
    Apr 25, 2009
    Messages:
    779
    Somewhat unrelated to Pokemon Generation, but can influence it via frame advancement:

    NPC actions...

    The RAM area associated to NPC movement is in the 0x02250000 region, and is different for each location. Tethered NPCs (don't step) have...

    A timer set by the RNG to determine when to call for the next move
    A Movement Limiter (Limits Movements determined by RNG to a specified range)
    A NPC-# to instruct which NPC to move
    A NPC directional to instruct it how to move.

    As we've seen already, the NPC directional is determined by *4. However, if the NPC cannot move in that direction a call is still consumed to reseed the timer.

    Nimbasa Pokemon Center Moving NPC RAM view (open)
    [​IMG]


    For moving NPCs, -0x10 from the face directional to have the move directional.
    Below these are the movement limits and so on. Meh.

    There's a small cooldown timer for moving and facing so that they won't be allowed to move even if the timer goes down (moving too much).


    tl;dr -- even if NPCs don't move they still can consume frames
  9. Kaphotics

    Kaphotics Remodeling Kitchens
    is a Pokemon Researcheris a Contributor to Smogon

    Joined:
    Apr 25, 2009
    Messages:
    779
    RSFRLG Egg Inheritance
    nailed it
    Sapphire Memory Locations (open)
    Code:
    03004818 	RNG Seed
    
    03004360	Party 1 PID
    030043C4	Party 2 PID
    03004428	Party 3 PID
    0300448C	Party 4 PID
    030044F0	Party 5 PID
    03004554	Party 6 PID
    020286d0	Daycare A PID
    02028720	Daycare B PID
    020287E8	Egg LowPID
    020287EA	Egg Stepcounter


    Sapphire Egg Inheritance Test (open)
    Code:
    =====================================
    38310586	Seed
    28575 frames back gives D661
    
    Ditto 		1/1/1/1/1/1
    Sceptile	0/0/0/0/0/0
    Ditto deposited first 		= A
    Sceptile deposited second 	= B
    =====================================
    IV's, Method 1 Frame, PIDs, and Inheritance
    -----------------------------------
    Pokemon's IV's -- 0/2/1/0/30/11	
    appears as Method 1 Frame 5
    PID: 918869601 (dec)	36C4[I]D661[/I] hex
    
    B/2/A/B/30/11 is what I got.
    
    B/x/A/B/x/x on Frame 9 for HGSS
    -----------------------------------
    Pokemon's IVs -- 31/1/29/0/13/0	
    appears as Method 1 Frame 7
    PID: 2024527457 (dec)	78AB[I]D661[/I] (hex)
    
    31/A/29/B/13/B is what I got.
    
    x/A/x/B/x/B on Frame 11 for HGSS
    -----------------------------------
    Pokemon's IVs -- 10/0/0/1/1/3	
    appears as Method 1 Frame 9
    PID: 3055081057	(dec)	B618[I]D661[/I] (hex)
    
    10/B/B/A/1/3 is what I got.
    
    x/B/B/A/x/x on Frame 13 for HGSS
    -----------------------------------
    14/0/12/28/1/0	Frame 13
    PID: 2689717857 (dec)	A051[I]D661[/I] (hex)
    
    14/B/12/28/A/B is what I got.
    
    x/B/x/x/A/B on Frame 17 for HGSS


    An example...
    Code:
    [I]Lower Half[/I] of the PID comes from [I]Method 1[/I] when the egg becomes available.
    --
    [I]Upper Half[/I] of the PID comes from [I]Method 1[/I] Frame 1. 
    IV's come from [I]Method 1[/I] Frame 2.
    Inheritance comes from [I]HGSS's Inheritance[/I] Frame 6.
    ==

    Contrary to what was thought, eggs are not generated on the stepcounter's reset. Freezing the "resetted" step counter to an arbitrary value still allows for eggs to be generated.

    Show Hide
    Freezing the total step counters will prevent eggs from being generated, located at -0x8 and -0x10 of the 0-255 stepcounter location.
    [​IMG]
  10. GoldenBanana

    GoldenBanana

    Joined:
    Apr 10, 2010
    Messages:
    137
    Thank you so much, Kaphotics, for your RSFRLG findings! I was just beginning to research this, only to find that you've almost uncovered all that there is to know.

    I am a little confused about the information you've presented though. Firstly, I don't understand where you get D661 from (that's supposed to be the Sapphire version seed, right?) and its corresponding frame. When I use NeoSyrex's FR/LG seed finder application, I get 5a0, which is the seed you're stuck with when the game tells you that the battery has run dry. I also get a different frame, and what's more is that I can only find the spreads you listed when I enter 5a0 as the seed in RNG Reporter.

    Secondly, what is the long number you've listed underneath the IVs, and what is the number that is followed by _D661? What is their significance?

    Lastly, what is a uPID, and what is it used for?

    Let me see if I've got the gist of your findings:
    Say I'm on some seed, frame 1287. The uPID (whatever that is) will come from M1 frame 1287, the IVs from M1 frame 1288, and the inheritance from Breeding (HGSS) frame 1292?
  11. Kaphotics

    Kaphotics Remodeling Kitchens
    is a Pokemon Researcheris a Contributor to Smogon

    Joined:
    Apr 25, 2009
    Messages:
    779
    Oops, I changed my shorthand to something more coherent (re-read the post :X).

    As OmegaDonut noted earlier about the egg PID generation method in RSFRLG, the egg PID is generated in two steps. All I did during my period of research was replicate what he did (independently, mapping memory locations as I went), and figured out the last part that we didn't know: inheritance.

    I wasn't around / researching Gen 3/4 things when they were popular, so I have no clue how HGSS/Emerald inheritance works, I just know that's what's happening for inheritance. We know Nintendo likes to re-use stuff, but whodathunk HGSS's inheritance was reused from RSFRLG?

    ===

    For my case, the D661 was the lower part of the resulting egg PIDs (I rerolled save states at different frames). It probably was from [00005A0's frame 85456 in Researcher]. I saved my game and restarted just to make sure that the value stayed there.
    If you were to use the initial seed 000005A0 in RNG Reporter, the frames I hit for inheritance were starting at 16835. For my tests, I just used the "current seed", which is just a further along frame.

    The RNG can be thought of as a number line, you can start from many points and still end up at the same place. :)

    ===

    You got the gist of it :)
  12. Kaphotics

    Kaphotics Remodeling Kitchens
    is a Pokemon Researcheris a Contributor to Smogon

    Joined:
    Apr 25, 2009
    Messages:
    779
    B/W Wild Pokemon Levels

    Encounter Levels for everything but aquatic encounters are set between the same two values. For fishing/surfing(+spots) they are not the same, thus resulting in the level range obtainable.

    The formula is this for the "Level Calc" Frame:
    Code:
    Load the  LowLimit on the Pokemon's Level (BaseLVL)
    Load the HighLimit on the Pokemon's Level (HighLVL)
    
    {{{ (u32*100>>32);  
                       % [[HighLVL - BaseLVL + 1]] }}} 
                                                       + BaseLVL
    In simple terms:
    Code:
    Take the *100 of the seed
             You have a number (0 thru 99)
    Mod it by the (level difference +1)
             You have a number (0 thru gap+1),
             Modding results in a # (0 thru gap)
    Add the resulting # to the lowest possible level. 
             You now have the wild Pokemon's Level
    For non-aquatic encounters this still occurs, the mod(levelgap+1=1) always yields 0, and thus you get the static level.
    Chiizu's post on double battle structure has an "Unknown" frame consumed, this is what is happening there. For every wild encounter, the Level is calculated right after ESV.


    See the Encounter Slots: Water post for examples and frame occurrence.
  13. GoldenBanana

    GoldenBanana

    Joined:
    Apr 10, 2010
    Messages:
    137
    More on RSFRLG egg generation

    I don't know if this has been figured out already, but I'll post it anyway. Also, I apologize in advance for any illiteracy I may show on this subject.

    It seems that when the number at the location in memory that records the Egg Step Counter ends in FF (like 1FF or 2FF), there is a chance that the old man will have an egg. Since you can't check the game's memory on a cartridge, the only way to properly do this would be to place the parents in the daycare (rather than collecting an egg with the parents already in the daycare), walk 254 steps 1 square away from the old man, and save. Walking one step towards the man will trigger a chance for the egg to be generated. Every 256 steps afterward will trigger this same chance.

    It's also important to note that the appearance of the egg doesn't appear to be seed dependent. Resetting on the same seed (5a0) and walking one step to advance the egg step counter to FF did not always result in an egg being generated.

    Also, for people who are interested in doing this on a cartridge, I found that the time it takes to generate the egg from the moment you press a direction (basically the walk animation) is 16 frames.
    ----------------------
    I'm looking at the RNG Seed in Ruby's memory, and as I'm advancing the frame one-by-one manually, some method 1 frames seem to be skipped. Is anyone else experiencing this problem?
  14. chiizu

    chiizu PPPPPPPPPPPPPPPPP RNG
    is a Programmeris a Pokemon Researcher

    Joined:
    Nov 12, 2010
    Messages:
    422
    Starting PID Frames
    or why this guy's table and code works as a substitute for the real (giant) table and strangely complicated code.

    The simplified version of the PID start frame calc follows. Take note of the array named kakuritu ('percentage' in Japanese).
    Taken from the same guy's program (open)

    Note: I don't see any difference between the behavior of simulateOffset from this guy's program and what RNG Reporter is doing, despite the comment in the RNG Reporter source that this code is broken. I see the difference now.
    Code:
    void simulateOffset()
    {
        int kaisu = 5;  //多くの場合は5回だと思いますが絶対に5回とは言い切れません
        for(int i = 0; i < kaisu;i++)
        {
            selectMissionAll();
        }
    }
    
    int selectMission(int pattern) {
        static const int kakuritu[6][5] ={  //謎の確率テーブル
          {  50,100,100,100,100 },
          {  50, 50,100,100,100 },
          {  30, 50,100,100,100 },
          {  25, 30, 50,100,100 },
          {  20, 25, 33, 50,100 },
          { 100,100,100,100,100 }
        } ;
        
        if(pattern > 6)return 0;
        if(pattern < 0)return 0;
        int rn = 0;
        for(int i = 0;i < 5;i++)
        {
            if(kakuritu[pattern][i] == 100)return i;    //確率が100だったときは乱数を発生させずに処理を抜けます
            rn = ransuu.genRand64(101);                    //0~100の乱数を発生させます。
            if(rn <= kakuritu[pattern][i])return i;        //乱数が確率の値以下だったときは、その場で処理から抜けます。
        }
        return 0;
    }
    
    int selectMissionAll()
    {
        for(int i = 0;i < 6;i++)
            selectMission(i);  //上のselectMissionの全パターン分を順番に呼び出します。
        return 0;
    }
    


    The table and code he gives is a simplified version of the 224 row in-game table and the functions that use it as part of a process that ends up consuming the initial RNG frames in the game. The purpose of that process is currently unclear, but the Japanese developer may be thinking that it has something to do with Entralink missions and power levels (judging by the function names and some comments on his twitter).
    The actual table the game uses (note that names are just my choices based on how a variable is used in this context) (open)

    Code:
    struct TableRow
    {
      byte  index;
      byte  sumCheck;
      byte  percent;
      byte  evenOrOdd;
    };
    
    struct Table
    {
        TableRow  row[224];
    };
    
    The raw bytes of the rows (all numbers in hexidecimal), located at 02176ACC in White JP
    01 30 19 04
    01 30 19 03
    01 26 19 04
    01 26 19 03
    01 20 19 04
    01 20 19 03
    01 18 19 04
    01 18 19 03
    01 11 21 04
    01 11 21 03
    01 0e 21 04
    01 0e 21 03
    01 0b 21 04
    01 0b 21 03
    01 08 32 04
    01 08 32 03
    01 05 32 04
    01 05 32 03
    01 02 32 04
    01 02 32 03
    01 00 32 04
    01 00 32 03
    01 00 32 04
    01 00 32 03
    01 00 64 04
    01 00 64 03
    02 32 19 04
    02 32 19 03
    02 28 19 04
    02 28 19 03
    02 22 19 04
    02 22 19 03
    02 19 1e 04
    02 19 1e 03
    02 13 1e 04
    02 13 1e 03
    02 10 1e 04
    02 10 1e 03
    02 0d 1e 04
    02 0d 1e 03
    02 0a 32 04
    02 0a 32 03
    02 07 32 04
    02 07 32 03
    02 04 32 04
    02 04 32 03
    02 00 1e 04
    02 00 1e 03
    02 00 32 04
    02 00 32 03
    02 00 64 04
    02 00 64 03
    00 2a 14 04
    00 2a 14 03
    00 22 14 04
    00 22 14 03
    00 1a 19 04
    00 1a 19 03
    00 12 19 04
    00 12 19 03
    00 0a 21 04
    00 0a 21 03
    00 05 21 04
    00 05 21 03
    00 00 32 04
    00 00 32 03
    00 00 64 04
    00 00 64 03
    05 19 21 04
    05 19 21 03
    05 0f 32 04
    05 0f 32 03
    05 05 32 04
    05 05 32 03
    05 00 64 04
    05 00 64 03
    04 30 0f 04
    04 30 0f 03
    04 30 14 04
    04 30 14 03
    04 30 19 04
    04 30 19 03
    04 2b 0f 04
    04 2b 0f 03
    04 2b 14 04
    04 2b 14 03
    04 2b 19 04
    04 2b 19 03
    04 26 0f 04
    04 26 0f 03
    04 26 14 04
    04 26 14 03
    04 26 19 04
    04 26 19 03
    04 21 0f 04
    04 21 0f 03
    04 21 14 04
    04 21 14 03
    04 21 19 04
    04 21 19 03
    04 1c 0f 04
    04 1c 0f 03
    04 1c 14 04
    04 1c 14 03
    04 1c 19 04
    04 1c 19 03
    04 17 14 04
    04 17 14 03
    04 17 19 04
    04 17 19 03
    04 17 1e 04
    04 17 1e 03
    04 12 14 04
    04 12 14 03
    04 12 19 04
    04 12 19 03
    04 12 1e 04
    04 12 1e 03
    04 0d 14 04
    04 0d 14 03
    04 0d 19 04
    04 0d 19 03
    04 0d 1e 04
    04 0d 1e 03
    04 08 14 04
    04 08 14 03
    04 08 19 04
    04 08 19 03
    04 08 1e 04
    04 08 1e 03
    04 04 14 04
    04 04 14 03
    04 04 19 04
    04 04 19 03
    04 04 1e 04
    04 04 1e 03
    04 04 32 04
    04 04 32 03
    04 00 14 04
    04 00 14 03
    04 00 19 04
    04 00 19 03
    04 00 21 04
    04 00 21 03
    04 00 32 04
    04 00 32 03
    04 00 64 04
    04 00 64 03
    03 36 0f 04
    03 36 0f 03
    03 36 14 04
    03 36 14 03
    03 36 19 04
    03 36 19 03
    03 36 1e 04
    03 36 1e 03
    03 31 0f 04
    03 31 0f 03
    03 31 14 04
    03 31 14 03
    03 31 21 04
    03 31 21 03
    03 2c 0f 04
    03 2c 0f 03
    03 2c 14 04
    03 2c 14 03
    03 2c 21 04
    03 2c 21 03
    03 27 0f 04
    03 27 0f 03
    03 27 14 04
    03 27 14 03
    03 27 21 04
    03 27 21 03
    03 22 0f 04
    03 22 0f 03
    03 22 14 04
    03 22 14 03
    03 22 21 04
    03 22 21 03
    03 1d 14 04
    03 1d 14 03
    03 1d 1e 04
    03 1d 1e 03
    03 1d 32 04
    03 1d 32 03
    03 18 14 04
    03 18 14 03
    03 18 1e 04
    03 18 1e 03
    03 18 32 04
    03 18 32 03
    03 13 14 04
    03 13 14 03
    03 13 1e 04
    03 13 1e 03
    03 13 32 04
    03 13 32 03
    03 0e 14 04
    03 0e 14 03
    03 0e 1e 04
    03 0e 1e 03
    03 0e 32 04
    03 0e 32 03
    03 08 14 04
    03 08 14 03
    03 08 1e 04
    03 08 1e 03
    03 08 32 04
    03 08 32 03
    03 03 14 04
    03 03 14 03
    03 03 1e 04
    03 03 1e 03
    03 03 32 04
    03 03 32 03
    03 00 19 04
    03 00 19 03
    03 00 1e 04
    03 00 1e 03
    03 00 32 04
    03 00 32 03
    03 00 64 04
    03 00 64 03
    


    The inner functions (decompilation of actual function used in game (open)

    Code:
    r6 = ?
    Address = memory address of some data structure
    
    This small loop is around 02176240 in White JP
    for (OuterCounter = 0; OuterCounter < 6; ++ OuterCounter)
    {
      *(Address + 6 + OuterCounter) = r6
      f(Address, OuterCounter)
    }
    
    This function is located at 2176254 in White JP
    f(uint8_t *Address, OuterCounter)
    {
      Sum = ((uint16_t*)Address)[6] + ((uint16_t*)Address)[7];
      i = 0;
      Table  *table = &BigTable;  // address of above 224 row table
      
      do
      {
        if ((table->row[i].index == OuterCounter) &&
            (table->row[i].sumCheck <= Sum) &&
            IsOdd(table->row[i].evenOrOdd))
        {
          percent = table->row[i].percent;
          if ((percent == 100) || (percent >= NextRNG(101))
          {
            Address[OuterCounter] = i
            return
          }
        }
      }
      while (++i != 224)
      .
      .
      .
    }
    


    The important thing that makes the smaller table work is that at start up, everything located at Address in the above code is 0, and r6 seems to always be 0 as well. This means that the sum of Address[6] and Address[7] is always 0, and therefore only the rows of the giant table that have a sumCheck value of 0 along with an evenOrOdd value that is odd (3 for this table) will be actually considered.

    If you filter out all rows with a sumCheck value greater than 0 and a evenOrOdd value of 4, and then reorder the rows by the index byte you get the following:
    Show Hide
    Code:
    Index 0 Rows
    00 00 32 03    // % = 50
    00 00 64 03    // % = 100
    
    Index 1 Rows
    01 00 32 03    // % = 50
    01 00 32 03    // % = 50
    01 00 64 03    // % = 100
    
    Index 2 Rows
    02 00 1e 03    // % = 30
    02 00 32 03    // % = 50
    02 00 64 03    // % = 100
    
    Index 3 Rows
    03 00 19 03    // % = 25
    03 00 1e 03    // % = 30
    03 00 32 03    // % = 50
    03 00 64 03    // % = 100
    
    Index 4 Rows
    04 00 14 03    // % = 20
    04 00 19 03    // % = 25
    04 00 21 03    // % = 33
    04 00 32 03    // % = 50
    04 00 64 03    // % = 100
    
    Index 5 Rows
    05 00 64 03    // % = 100
    


    Add additional 100% rows to each index so that all have 5 rows (to match index 4) and what you will see is the content of the simplified table in code given at the beginning.

    Given that the real table contains lots of rows that would be considered when the sum value is larger (if r6 is non-zero, for example), as well as having duplicate rows with alternating values of 3 and 4 in the final byte, it's fairly easy to conclude that this table serves some larger purpose in the game beyond a seemingly random initial RNG frame advancement.

    I don't expect this post will lead to new discoveries (though who knows what may come up down the line - this table definitely has other uses), but I thought it was nice to have actual evidence of where the simplified table being used in RNG Reporter (derived originally by the guy linked to at the beginning) ultimately comes from.
  15. Kaphotics

    Kaphotics Remodeling Kitchens
    is a Pokemon Researcheris a Contributor to Smogon

    Joined:
    Apr 25, 2009
    Messages:
    779
    Black and White Swarms
    Basically the same as the Wild structure, but with a calculation in between Sync and ESV

    Code:
    [I]if[/I]         {{  u32*100>>32  }} < 40
       [I]then[/I]    return active swarm, and still consume ESV
       [I]else[/I]    calculate ESV, standard Pokemon (not swarm)
    
    Swarm Level Range: (15 thru 55)
    
    0	Initial
    1	Sync
    2	Swarm
    3	ESV
    4	Level
    5	PID
    6	Nature
    Most notably, Swarm Pokemon don't have any held items thus they don't have a calculation for them at the end of the call cycle.
    Essentially the Swarm Calculation is the same thing as the doubles grass calculation.

    Example at Route 10 - Tyrogue (open)
    Code:
    0	C06688275F850487	Initial
    1	9F089A75F2BEA706	Sync
    2	36A8487BE5EABA21	Swarm
    3	009490E25644B6C8	ESV
    4	03D6575C2E8BC3AB	Level
    5	21A3141CA6AE543A	PID
    6	9EA717AFD396E3A5	Nature
    [​IMG]
  16. Kaphotics

    Kaphotics Remodeling Kitchens
    is a Pokemon Researcheris a Contributor to Smogon

    Joined:
    Apr 25, 2009
    Messages:
    779
    scribbly post, gen 5

    frozen seed C9DAE91DEB4AAAED generates an egg in less than 20 steps for a "They Get Along" breed.

    Trying to find out why...
    0 C9DAE91DEB4AAAED
    1 02F00960728FE344 02F00960... (top4bits= 0)

    It's definitely not the main step counter. Probably that 17steps/rng one.

    scribblesection gen 3
    Outputting SIDs for Emerald ID abuse (open)
    [​IMG]


    0-59 60-79 80-99
    60% 20% 20%


    Old Rod
    Slot 0: 0-59 60%
    Slot 1: 60-89 30%
    Slot 2: 90-94 5%
    Slot 3: 95-98 4%
    Slot 4: 99 1%

    Slots 0234 and 1 make 70 30
    Need to determine if it's not 0-69/70-99.

    Good Rod
    60/20/20



    Super Rod
    Slot 0: 0-39 40%
    Slot 1: 40-79 40%
    Slot 2: 80-94 15%
    Slot 3: 95-98 4%
    Slot 4: 99 1%

    034 1 2 make 45/40/15
    023 1 4 make 59/40/1

    Feebas and the Level Calc in Emerald hardly WIP
    how does this work I dont even
    Code:
    What I think it will be: 
    Before ESV, Low bit determines if Feebas will appear. Works like sync check.
    
    
    Fishing Levels are determined by u16%(max-min+1)+min
    Can't get it to work for Method 2 and Feebas. wat???????????
    examples (open)
    Can't even figure this out. sjghbdriekgjndreghbeargszgrzredgdehbdsxrenh

    with help from zari to get test results


    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
  17. Kaphotics

    Kaphotics Remodeling Kitchens
    is a Pokemon Researcheris a Contributor to Smogon

    Joined:
    Apr 25, 2009
    Messages:
    779
    RSEFRLG Encounter Slots

    RNG Seed is 32 bits, only uses u16 as we know already.

    Backwards Method:
    1. Find the frame the IVs occur on for the initial seed (000005A0).
    2. Take the PID of that frame and %25 (0x19) to get Nature.
    3. Subtract One from the frame, determine if it is odd or even.
    4. Set up researcher, as described in the example (until a method is available).
      • I call it Method H, it's VERY similar to Method J / K in gen 4 due to how it works. It exists before gen 4, thus H is before J.
    5. Work backwards from the PID frame, only looking for your Nature in custom 2 in the even/odd frames (You determined even or odd in step 3).
    6. Once you have found it, two frames back on Custom 3 is the ESV.

    Instead if you predict it forwards, you can possibly have a few different encounter slots for the PIDIV, just like Gen 4.

    Code:
    Slot      0     1     2     3     4     5     6     7     8     9  10  11
    Rate    20%   20%   10%   10%   10%   10%    5%    5%    4%    4%  1%  1%
    Value  0-19 20-39 40-49 50-59 60-69 70-79 80-84 85-89 90-93 94-97  98  99
    
    Encounter Slots for Gen 3 games can be found at poccil's web site.
    [URL="http://upokecenter.com/games/rs/guides/"]RSE[/URL] and [URL="http://www.upokecenter.com/games/fireleaf/firelocs.php"]FR[/URL]/[URL="http://www.upokecenter.com/games/fireleaf/leaflocs.php"]LG[/URL]
    RS Example (open)
    Code:
    LOCATION: [URL="http://bulbapedia.bulbagarden.net/wiki/New_Mauville#Pok.C3.A9mon"]New Mauville Basement[/URL]
    Initial Seed: 00005A0 (Dead Battery)
    Sweet Scenting Gloom
    [​IMG]

    Emerald Example (open)
    Code:
    LOCATION: [URL="http://bulbapedia.bulbagarden.net/wiki/New_Mauville#Pok.C3.A9mon"]New Mauville Basement[/URL]
    Initial Seed: 00000000 (Emerald)
    Sweet Scenting Gloom
    [​IMG]

    FRLG example (open)
    Code:
    LOCATION: [URL="http://bulbapedia.bulbagarden.net/wiki/Cerulean_Cave#B1F_2"]Cerulean Cave B1F[/URL]
    Initial Seed: 00005542
    Version: Fire Red
    Sweet Scenting Sceptile (lulz)
    [​IMG]


    Do note that this does make some spreads unobtainable for this encounter type just like in J/K.
    Method 1 based generation will have the same excluded spreads as Method K, but for Method 2 and 4 based generation, nobody knows yet!

    Emerald Sync
    Essentially the same as in method K, in which the Nature call's u16 low bit determines yes-0 or no-1. If no, consume another frame for nature.

    Emerald Sync Example (open)
    [​IMG]


    Much thanks to FractalFusion, poccil and mingot :)
  18. Kaphotics

    Kaphotics Remodeling Kitchens
    is a Pokemon Researcheris a Contributor to Smogon

    Joined:
    Apr 25, 2009
    Messages:
    779
    Daily Item RNG
    Show Hide
    Twist Mountain Fossil Man in B/W
    Code:
    (u32*7) >> 32
    
    yields 0-6, follows this #-Item distribution:
    0    Root  Fossil (Lileep)
    1    Claw  Fossil (Anorith)
    2    Helix Fossil (Omanyte)
    3    Dome  Fossil (Kabuto)
    4    Old   Amber  (Aerodactyl)
    5    Armor Fossil (Shieldon)
    6    Skull Fossil (Cranidos)
    Fish of the Day
    Code:
    (u32*21) >> 32
    
    yields 0-20, follows this #-Fish distribution:
    0	Carvanha
    1	Basculin
    2	Sharpedo
    3	Feebas
    4	Milotic
    5	Goldeen
    6	Seaking
    7	Poliwag
    8	Poliwhirl
    9	Poliwrath
    10	Krabby
    11	Shellder
    12	Luvdisc
    13	Kingler
    14	Cloyster
    15	Finneon
    16	Horsea
    17	Seadra
    18	Qwilfish
    19	Lumineon
    20	Kingdra
    Treasure Hunter's Daily Item
    Code:
    (u32*27) >> 32
    
    yields 0-26, follow this #-Item Distribution
    0	Blue Flute
    1	Yellow Flute
    2	Red Flute
    3	Black Flute
    4	White Flute
    5	Shoal Salt
    6	Shoal Shell
    7	Big Pearl
    8	Heart Scale
    9	DeepSeaTooth
    10	DeepSeaScale
    11	Lucky Egg
    12	Metal Coat
    13	Dragon Scale
    14	Up-Grade
    15	Lucky Punch
    16	Metal Powder
    17	Thick Club
    18	Stick
    19	Protector
    20	Electirizer
    21	Reaper Cloth
    22	Magmarizer
    23	Razor Fang
    24	Razor Claw
    25	King's Rock
    26	Dubious Disc


    Lost Item at Anville Town
    Show Hide
    Code:
    (u32*10) >> 32
    
    Pay attention to: 022598D0 english white
    Value is loaded when it displays what item you receive.
    When you dismiss his final dialogue (happy item), 
               next week's item value will be there.
    Depending on Block Shuffling, it is stored at 2032A, quantity at 2032C.
    
    You have to win 7*x battles in the battle subway for him to give you the next item.
    You will get 1*x of that item when you talk to him. Max of 10.
    So, you can get up to 10 Rare Candies each day.
    
    0	Rare Candy
    1	Full Restore
    2	Max Revive
    3	Elixir
    4	Protein
    5	Iron
    6	Calcium
    7	Zinc
    8	Carbos
    9	HP Up
    
    Item Codes: Reference
    0017 	Full Restore	1
    001D	Max Revive	2
    0028	Elixir		3
    002D	HP Up		9
    002E	Protein		4
    002F	Iron		5
    0030	Carbos		8
    0031	Calcium		6
    0032	Rare Candy	0
    0034	Zinc		7
    
  19. Kaphotics

    Kaphotics Remodeling Kitchens
    is a Pokemon Researcheris a Contributor to Smogon

    Joined:
    Apr 25, 2009
    Messages:
    779
    Sports Dome Trainers

    The game generates 6 trainers (order of position 654321 in image) out of 52 in a Pool to choose from.

    Research Scribbly important mechanics (open)


    Mid - Research, probably needs breaking.[​IMG]

    Code:
    Seed: B760BD8432B5DA3E
    Frame	Trainer
    1	49
    2	42
    3	4E/4D
    4	3A
    5	3C/3D
    6	5C/5D
    7	5A/59
    8	47/46
    9	41/40
    10	65/64
    11	56/57
    12	4F
    13	68
    14	4D
    [​IMG]
    Code:
    u32*100	7	10	18	22	30	36	43	
    trainer	3A	3C/3D	40/41	42	46/47	49	4D/4E	
    
    u32*100	45	47	62	67	71	87	95
    trainer	4D	4F	56/57	59/5A	5C/5D	64/65	68
    As you can see, it likes to follow the linear scale set from the Upper32 seed.

    Trainer order is located at 0x2033E, depending on shuffling. Occupies a 12 digit span (00TR * 6)

    Non Random Trainer Hexes
    Code:
    00 = Ungenerated
    01 = Smasher Elena (30s)
    02 = Smasher Elena (40s)
    03 = Smasher Elena (65s)
    04 = Smasher Aspen (40s)
    05 = Smasher Aspen (65s)
    06 = Smasher Mari (65s)
    07 = Infielder Alex (20s)
    08 = Infielder Alex (30s)
    09 = Infielder Alex (40s)
    0A = Infielder Alex (65s)
    0B = Infielder Connor (40s)
    0C = Infielder Connor (65s)
    0D = Infielder Todd (65s)
    0E = Striker Tony (20s)
    0F = Striker Tony (30s)
    10 = Striker Tony (40s)
    11 = Striker Tony (65s)
    12 = Striker Roberto (40s)
    13 = Striker Roberto (65s)
    14 = Striker Marco (65s)
    15 = Linebacker Dan (20s)
    16 = Linebacker Dan (30s)
    17 = Linebacker Dan (40s)
    18 = Linebacker Dan (65s)
    19 = Linebacker Bob (40s)
    1A = Linebacker Bob (65s)
    1B = Linebacker Jonah (65s)
    1C = Hoopster Bobby (20s)
    1D = Hoopster Bobby (30s)
    1E = Hoopster Bobby (40s)
    1F = Hoopster Bobby (65s)
    20 = Hoopster John (40s)
    21 = Hoopster John (65s)
    22 = Hoopster Lamarcus (65s)
    
    23 = Backers Hawk & Dar (30s)
    24 = Backers Hawk & Dar (40s)
    25 = Backers Hawk & Dar (65s)
    26 = Backers Cam & Abby (65s)
    27 = Backers Ami & Eira (30s)
    28 = Backers Ami & Eira (40s)
    29 = Backers Ami & Eira (65s)
    2A = Backers Alf & Fred (65s)
    2B = Backers Kay & Ali (30s) 
    2C = Backers Kay & Ali (40s) 
    2D = Backers Kay & Ali (65s) 
    2E = Backers Les & Web (65s) 
    2F = Backers Joe & Ross (30s)
    30 = Backers Joe & Ross (40s)
    31 = Backers Joe & Ross (65s)
    32 = Backers Ai & Ciel (65s)
    33 = Backers Masa & Yas (30s)
    34 = Backers Masa & Yas (40s) 
    35 = Backers Masa & Yas (65s)
    36 = Backers Kat & Phae (65s)
    Code:
    37 = Clerk F Wren
    38 = Waiter Clint
    39 = Waitress Bonita
    3A = Ace Trainer Charlie
    3B = Ace Trainer Lucille
    3C = Lass Sophie
    3D = Rich Boy Anthony
    3E = Policeman Jeff
    3F = Black Belt Lao
    40 = Harlequin Charley
    41 = Artist Pierre
    42 = Scientist Simon
    43 = Scientist Blythe
    44 = Psychic Gerard
    45 = Psychic Madhu
    46 = Worker Matthew
    47 = Worker Tyler
    48 = Gentleman Renaud
    49 = School Kid Alan 
    4A = School Kid Sally
    4B = Roughneck Fletcher
    4C = Janitor Caleb
    4D = Pokefan Colin
    4E = Pokefan Darcy
    4F = Dancer Davey
    50 = Youngster Kevin
    51 = Fisherman Devon
    52 = Depot Agent Josh
    53 = Doctor Jules
    54 = Nurse Kirsten
    55 = Pilot Leonard
    56 = Backpacker Alexander
    57 = Backpacker Patty
    58 = Battle Girl Janie
    59 = Parasol Lady Gwyneth
    5A = Clerk M Nelson
    5B = Clerk M Fredric
    5C = Baker Lilly
    5D = Veteran Arlen
    5E = Veteran Sayuri
    5F = Nursery Aide Leah
    60 = PKMN Breeder Owen
    61 = PKMN Breeder Brooke
    62 = PKMN Ranger Alain
    63 = PKMN Ranger Heidi
    64 = Socialite Emilia
    65 = Lass Dana
    66 = Musician Boris
    67 = Maid Alicia
    68 = Hiker Russel
    69 = Preeschooler Evan
    6A = Preeschooler Mia
    
    6B = YOURSELF (unused)
    
    More exist beyond, but they are not part of the random trainers.
    
    6C = PKMN Ranger Mylene, who is in Desert Resort
    .

    sup arlen
    223BF0A houses all 6 trainer #'s, is saved to save file.
    [​IMG]


    Code:
    see next page for how to calc.
    
    Process 6 times total to get 6 random Trainers.
    
    0 = Clerk F Wren
    [U]1 = Waiter Clint[/U]  -- Fresh Water
    [U]2 = Waitress Bonita[/U]  -- Fresh Water
    [B][U]3 = Ace Trainer Charlie[/U][/B] - PP Up
    [U][B]4 = Ace Trainer Lucille[/B][/U] - PP Up
    [U]5 = Lass Sophie[/U]  -- Ultra Ball
    6 = Rich Boy Anthony
    7 = Policeman Jeff
    8 = Black Belt Lao
    9 = Harlequin Charley
    10 = Artist Pierre
    [U]11 = Scientist Simon[/U]  -- Ether
    [U]12 = Scientist Blythe[/U]  -- Ether
    13 = Psychic Gerard
    14 = Psychic Madhu
    15 = Worker Matthew
    16 = Worker Tyler
    [u]17 = Gentleman Renaud[/U]  -- Nugget
    18 = School Kid Alan 
    19 = School Kid Sally
    20 = Roughneck Fletcher
    21 = Janitor Caleb
    22 = Pokefan Colin
    23 = Pokefan Darcy
    24 = Dancer Davey
    [U]25 = Youngster Kevin[/U]  -- Ultra Ball
    26 = Fisherman Devon
    27 = Depot Agent Josh
    [U]28 = Doctor Jules[/U]  -- Max Revive
    [U]29 = Nurse Kirsten[/U]  -- Full Restore
    30 = Pilot Leonard
    [U]31 = Backpacker Alexander[/U]  -- Repel
    [U]32 = Backpacker Patty[/U]  -- Repel
    33 = Battle Girl Janie
    34 = Parasol Lady Gwyneth
    35 = Clerk M Nelson
    36 = Clerk M Fredric
    [U]37 = Baker Lilly[/U]  -- Moomoo Milk
    [B][U]38 = Veteran Arlen[/U][/B] -- PP Max
    [B][U]39 = Veteran Sayuri[/U][/B] -- PP Max
    [U]40 = Nursery Aide Leah[/U]  -- Rare Candy
    41 = PKMN Breeder Owen
    42 = PKMN Breeder Brooke
    43 = PKMN Ranger Alain
    44 = PKMN Ranger Heidi
    [u]45 = Socialite Emilia[/U]  -- Big Pearl
    46 = Lass Dana
    47 = Musician Boris
    48 = Maid Alicia
    49 = Hiker Russel
    50 = Preeschooler Evan
    51 = Preeschooler Mia
  20. Bond697

    Bond697 Dies, died, will die.
    is a Pokemon Researcher

    Joined:
    Jun 20, 2010
    Messages:
    307
    considering that u32 * XX >> 32 is less than half the formula(and 51 is wrong), i'm not surprised there's "a little iffyness".
  21. Kaphotics

    Kaphotics Remodeling Kitchens
    is a Pokemon Researcheris a Contributor to Smogon

    Joined:
    Apr 25, 2009
    Messages:
    779
    RSFRLG Encounters (Part 2)
    Part crossposted from FRLG thread.

    If you freeze a value to the main seed location, it will act as the initial seed for PID generation, thus bypassing any advancement from sweet scent (even though it doesn't "consume"). A little hackish, but gets research done.

    Now that I can successfully test individual seeds (knowing what Nature I'll hit) via seed freezing in the emulator, I can verify those ESV->Slots.

    Fishing Encounter Slots (open)

    Here's what I believe them to be:
    Code:
    Old Rod
    Slot 0: 0-69 
    Slot 1: 70-99 
    
    Good Rod
    Slot 0: 0-59
    Slot 1: 60-79
    Slot 2: 80-99
    
    Super Rod 
    Slot 0: 0-39
    Slot 1: 40-79
    Slot 2: 80-94
    Slot 3: 95-98
    Slot 4: 99


    Battle Decision Trigger Calcs (open)
    Code:
    R/S: Upper16 %0xB40 < 16*Density
    	Restated: 	if (u16%2880)/16 < D	, pass encounter
    
    Modifications (Poccil's Site):    
       1. If the Mach Bike or Acro Bike is used, multiply by 4/5.
       2. If the Black Flute had been used, multiply by 1/2. If the White Flute had been used, multiply by 3/2.
       3. If the first Pokémon in party has a Cleanse Tag, multiply by 2/3.
       4. If the first Pokémon in party has Stench, multiply by 1/2. If the first Pokémon in party has Illuminate, multiply by 2. (In either case, ignore if the Pokémon holds a Cleanse Tag.)
    
    Maximize: (*6) White Flute, Illuminate
    Minimize: (*1/20) Stench, Black Flute, Bike
    Apply to the resulting value to density.
    
    
    FRLG: See [URL="http://upokecenter.com/games/rs/guides/notes.php?section=Encounters"]Poccil's site[/URL] for psuedocode.
    Emerald: See [URL="http://upokecenter.com/games/rs/guides/notes.php?section=Encounters"]Poccil's site[/URL] for psuedocode.

    PKM Generation Routine (Method H) (open)

    Setup of everything before PID:

    Code:
    0 - Initial
    1 - Battle Decision,		 If Sweet Scent, pass		 = Battle
    2 - Encounter Slot Value (0-99), via Upper16 %100		 = Slot
    3 - Encounter Level (from Slot), via Upper16 %(High-Low+1) + Low = Level
    4 - Encounter Nature, 		 via Upper16 %25		 = Nature
    Now to generate a PID.
    Code:
    set n = 0
    loop until break to get a PID%25 = Nature
    5+n - Temp  Low16PID
    6+n - Temp High16PID
    
    	if High16PID_Low16PID % 25 = Nature
    		set as the PID, break
    	    else n=n+2
    		repeat loop
    	end
    
    end
    Then comes the IVs, which depend on the Method of Generation.
    Not sure if this is that calc at frame 1, the rejection of IV bits, or something else.
    Code:
    	if Method 1
    		a = 0 
    		b = 0
    	elseif Method 2
    		a = 1
    		b = 0
    	elseif Method 4
    		a = 0
    		b = 1
    	end
    
    7+n + a   - IVSet1
    8+n + a+b - IVSet2
    
    Now this assumes method 3 is never used. I don't think I've seen it, ever. Jussayin'


    =============================

    I looked back at some of the spreads that Zari hit for the Feebas. On a different route (Outside New Mauville) I got a Method 1 instead of Method 4 spread.

    Gen Seed: DCD4AA7E (frame 39035 hardy).
    I'm gonna try the same route. If someone can give me a .sav of Sapphire on a Feebas tile, I can try to figure out how those work.
  22. Kaphotics

    Kaphotics Remodeling Kitchens
    is a Pokemon Researcheris a Contributor to Smogon

    Joined:
    Apr 25, 2009
    Messages:
    779
    R/S (FRLG?) Egg Availability [and Generation]

    Code:
    Egg Decision:
    if 2nd Total Stepcounter == xxFF
    
    hex (u16*0x64) / 0xFFFF   = E
    dec (u16*100)  /  65535   = E
    
    if E < Breed#, then generate egg.
    Code:
    Breed#
    Different OT,      Same Species -- 70
         Same OT,      Same Species -- 50
    Different OT, Different Species -- 50
         Same OT, Different Species -- 20
    Code:
    0 - Initial 
    1 - ????
    2 - Egg Decision
    3 - Egg PID Frame
         \--->    Make Sure 0000 nor FFFF happen:
    
    [u]Seed 	 = u16  ==> LPID[/u]
    761A62EA = 7FFF ==> 8000    [+1]
    5B883D42 = FFFB ==> FFFC    [+1]
    506A1C76 = FFFC ==> FFFD    [+1]
    F5D0CAD9 = FFFD ==> FFFE    [+1]
    476DCAD9 = FFFE ==> 0001    [+3]
    409E279F = FFFF ==> 0002    [+3]
    923B279F = 0000 ==> 0001    [+1]
    403ED126 = 0001 ==> 0002    [+1]
    91DBD126 = 0002 ==> 0003    [+1]
    
    If u16 (pre-addition) > FFFD, 
      then +3 and %0xFFFF (or -0xFFFF)
     else +1
    end
    It doesn't like FFFF or 0000. FFFF is just an odd case ¯\_(ツ)_/¯
    RAM Addresses (Sapphire) (open)
    Code:
    There's 2 large step counters (that equal each other) 
            and one small, the second large step counter is for Egg Generation.[code][COLOR="Silver"]0x020287E0  --  Nonimportant Step counter[/COLOR]
    [B]0x020287E4  --  Egg Creation step counter[/B]
    [COLOR="silver"]0x020287EA  --  Egg Hatch step counter[/COLOR]


    You'd deposit, walk 254 steps, then save your game. Both locations are saved when you save your game, so essentially you can take just one step and talk to the man to confirm, as we already know.

    Everstone does not work in RSFRLG, as it is an Emerald Only feature. You can use nature as a frame confirmation tool; have fun hatching!
    I'd assume the same calculation is used to determine egg availability in Emerald and FRLG.

    ===

    For the breeding method (UPID + IVs + Inheritance), the first call is ?????????? (second is UPID). I think it's probably Nidoran/etc (species) decision, then it generates the rest of the PIDIV as I've already described on the last page. Most likely via %100 -> 50/50. Who cares about breeding these two species in Gen 3 anyways?
  23. Bond697

    Bond697 Dies, died, will die.
    is a Pokemon Researcher

    Joined:
    Jun 20, 2010
    Messages:
    307
    Ruby/Sapphire Feebas Encounters

    There is no frame, there is no check; Feebas tiles just follow changed encounter slots.

    Show Hide

    Code:
    08084AA6 0400     lsl     r0,r0,#0x10
    08084AA8 0C00     lsr     r0,r0,#0x10
    08084AAA 2164     mov     r1,#0x64
    08084AAC F15CF9F4 bl      #0x81E0E98
    
    
    081E0908 2301     mov     r3,#0x1		// r3 = 1
    081E090A 2900     cmp     r1,#0x0		// 6 v. 0
    081E090C D05E     beq     #0x81E09CC	// no branch
    081E090E D500     bpl     #0x81E0912	// branch
    081E0910 4249     neg     r1,r1-skipped
    081E0912 B410     push    {r4}			// r4 to the stack(3007E00)
    081E0914 B401     push    {r0}			// r0 to the stack(8A72)
    081E0916 2800     cmp     r0,#0x0		
    081E0918 D500     bpl     #0x81E091C	true, branch
    081E091A 4240     neg     r0,r0-skipped
    081E091C 4288     cmp     r0,r1			
    081E091E D34F     bcc     #0x81E09C0
    081E0920 2401     mov     r4,#0x1
    081E0922 0724     lsl     r4,r4,#0x1C
    081E0924 42A1     cmp     r1,r4
    081E0926 D204     bcs     #0x81E0932
    081E0928 4281     cmp     r1,r0
    081E092A D202     bcs     #0x81E0932
    081E092C 0109     lsl     r1,r1,#0x4
    081E092E 011B     lsl     r3,r3,#0x4
    081E0930 E7F8     b       #0x81E0924
    081E0932 00E4     lsl     r4,r4,#0x3
    081E0934 42A1     cmp     r1,r4
    081E0936 D204     bcs     #0x81E0942
    081E0938 4281     cmp     r1,r0
    081E093A D202     bcs     #0x81E0942
    081E093C 0049     lsl     r1,r1,#0x1
    081E093E 005B     lsl     r3,r3,#0x1
    081E0940 E7F8     b       #0x81E0934
    081E0942 2200     mov     r2,#0x0
    081E0944 4288     cmp     r0,r1
    081E0946 D300     bcc     #0x81E094A
    081E0948 1A40     sub     r0,r0,r1
    081E094A 084C     lsr     r4,r1,#0x1
    081E094C 42A0     cmp     r0,r4
    081E094E D305     bcc     #0x81E095C
    081E0950 1B00     sub     r0,r0,r4
    081E0952 469C     mov     r12,r3
    081E0954 2401     mov     r4,#0x1
    081E0956 41E3     ror     r3,r4
    081E0958 431A     orr     r2,r3
    081E095A 4663     mov     r3,r12
    081E095C 088C     lsr     r4,r1,#0x2
    081E095E 42A0     cmp     r0,r4
    081E0960 D305     bcc     #0x81E096E
    081E0962 1B00     sub     r0,r0,r4
    081E0964 469C     mov     r12,r3
    081E0966 2402     mov     r4,#0x2
    081E0968 41E3     ror     r3,r4
    081E096A 431A     orr     r2,r3
    081E096C 4663     mov     r3,r12
    081E096E 08CC     lsr     r4,r1,#0x3
    081E0970 42A0     cmp     r0,r4
    081E0972 D305     bcc     #0x81E0980
    081E0974 1B00     sub     r0,r0,r4
    081E0976 469C     mov     r12,r3
    081E0978 2403     mov     r4,#0x3
    081E097A 41E3     ror     r3,r4
    081E097C 431A     orr     r2,r3
    081E097E 4663     mov     r3,r12
    081E0980 469C     mov     r12,r3
    081E0982 2800     cmp     r0,#0x0
    081E0984 D003     beq     #0x81E098E
    081E0986 091B     lsr     r3,r3,#0x4
    081E0988 D001     beq     #0x81E098E
    081E098A 0909     lsr     r1,r1,#0x4
    081E098C E7D9     b       #0x81E0942
    081E098E 240E     mov     r4,#0xE
    081E0990 0724     lsl     r4,r4,#0x1C
    081E0992 4022     and     r2,r4
    081E0994 D014     beq     #0x81E09C0
    081E0996 4663     mov     r3,r12
    081E0998 2403     mov     r4,#0x3
    081E099A 41E3     ror     r3,r4
    081E099C 421A     tst     r2,r3
    081E099E D001     beq     #0x81E09A4
    081E09A0 08CC     lsr     r4,r1,#0x3
    081E09A2 1900     add     r0,r0,r4
    081E09A4 4663     mov     r3,r12
    081E09A6 2402     mov     r4,#0x2
    081E09A8 41E3     ror     r3,r4
    081E09AA 421A     tst     r2,r3
    081E09AC D001     beq     #0x81E09B2
    081E09AE 088C     lsr     r4,r1,#0x2
    081E09B0 1900     add     r0,r0,r4
    081E09B2 4663     mov     r3,r12
    081E09B4 2401     mov     r4,#0x1
    081E09B6 41E3     ror     r3,r4
    081E09B8 421A     tst     r2,r3
    081E09BA D001     beq     #0x81E09C0
    081E09BC 084C     lsr     r4,r1,#0x1
    081E09BE 1900     add     r0,r0,r4
    081E09C0 BC10     pop     {r4}
    081E09C2 2C00     cmp     r4,#0x0
    081E09C4 D500     bpl     #0x81E09C8
    081E09C6 4240     neg     r0,r0
    081E09C8 BC10     pop     {r4}
    081E09CA 46F7     mov     r15,r14
    
    
    08084AB0 0400     lsl     r0,r0,#0x10
    08084AB2 0C00     lsr     r0,r0,#0x10
    [b]08084AB4 2831     cmp     r0,#0x31[/b]
    08084AB6 D907     bls     #0x8084AC8
    08084AB8 E03E     b       #0x8084B38
    



    I really don't feel like commenting a bunch of assembly I understand anyway, so here's a summation of what's going on:

    Code:
    ushort_t slots[2] = [349, 318};
    ushort_t slot = 0;
    
    feebas = (seed >> 16) % 100;
    
    if (feebas < 50 )
    {
      slot = slots[1];
      return slot;
    }
    else
    {
      slot = slots[2];
      return slot;
    }
    
    1. fishing junk, i'm sure
    2. changed encounter slot
    3. level
    4. nature, et al.


    and just as one last note, i saw the same routine in emerald. it's late now, so i'm not checking it out, but i will tomorrow.
  24. Kaphotics

    Kaphotics Remodeling Kitchens
    is a Pokemon Researcheris a Contributor to Smogon

    Joined:
    Apr 25, 2009
    Messages:
    779
    Rock Smash in Gen 3

    Code:
    Uses the battle decision:
    R/S: Upper16 %0xB40 < 16*Density
    
    0 - Initial
    1 - ?????
    2 - Battle Decision
    3 - Encounter Slot
    4 - Level (uses same calc)
    5 - Nature
  25. Kaphotics

    Kaphotics Remodeling Kitchens
    is a Pokemon Researcheris a Contributor to Smogon

    Joined:
    Apr 25, 2009
    Messages:
    779
    Headbutt RNG

    Code:
    n - 3     initial
    n - 2     ????
    n - 1     Slot
    n         Nature
    n +2x     LPID
    n +2x+1   UPID
    n +2x+2   IV1
    n +2x+3   IV2
    etc
    Nobody has mapped the slots, but I can get Shroomish@30% at ~35 (Level 3). The usual /656.
    Do note Bulbapedia has the wrong level distributions (I get level 3 shroomishes, which shouldn't be possible :P)

    my guess (open)
    Code:
    slot 0:    0-9   (10%)
    slot 1:  10-19   (10%)
    slot 2:  20-29   (10%)
    slot 3:  30-39   (10%)
    slot 4:  40-49   (10%)
    slot 5:  50-59   (10%)
    slot 6:  60-69   (10%)
    slot 7:  70-79   (10%)
    slot 8:  80-89   (10%)
    slot 9:  90-94    (5%)
    slot 10: 95-99    (5%)

Users Viewing Thread (Users: 0, Guests: 1)