|
|||||||
![]() |
|
|
Thread Tools |
|
|
#376 |
|
My goal in life is to make everyone cringe with my bad puns
Join Date: Feb 2008
Posts: 1,249
|
Just wondering, is there a chance that timing is different in Japanese carts? I may want to try it in my Japanese LeafGreen cartridge.
__________________
White: 4727-8034-9319 White 2: 4513-9096-8698 Joint trade thread with OmegaDonut If I ask for something on SQSR, don't link me to Pokecheck. If I were willing to use it, I wouldn't be asking for it there. My blog. I'm compiling a list of vocabulary used in Japanese game manuals to help me and other people learn the language of the Land of the Rising Sun. Last edited by RockinX; Aug 29th, 2011 at 11:12:46 PM. |
|
|
|
|
#377 |
|
Join Date: Jan 2009
Posts: 659
The AI is catching on....
|
My guess is that they would be the same, but I can't say with 100% certainty that they (since I own only american retail and no japanese carts :/)
__________________
We like 'em RARE! [Trade Shop]
ZariGS on FanFiction.net Soul Silver (Trades): 2709 5214 9088 White2 (trades/battles): FC Pending |
|
|
|
|
#378 |
|
My goal in life is to make everyone cringe with my bad puns
Join Date: Feb 2008
Posts: 1,249
|
Well, given that the way the game seeds the RNG is the same in Japanese 4th gen carts, it's more than likely that this is the case for FRLG as well.
__________________
White: 4727-8034-9319 White 2: 4513-9096-8698 Joint trade thread with OmegaDonut If I ask for something on SQSR, don't link me to Pokecheck. If I were willing to use it, I wouldn't be asking for it there. My blog. I'm compiling a list of vocabulary used in Japanese game manuals to help me and other people learn the language of the Land of the Rising Sun. |
|
|
|
|
#379 |
|
Dies, died, will die.
Join Date: Jun 2010
Posts: 302
|
nevermind, i guess
Last edited by Bond697; Sep 2nd, 2011 at 7:19:59 PM. |
|
|
|
|
#380 |
Join Date: Oct 2006
Posts: 869
|
I remember back in Emerald research there was speculation that the timer ran slightly differently on different systems, so it's interesting to see something like this emerge! I take it from your latest post that theoretically, different seed groupings should be available on the DS as opposed to the GBA due to the difference in the system clock? If so, that widens the total pool of seed groupings available, which is certainly advantageous for manipulators with more than one system.
|
|
|
|
|
#381 | |
|
Join Date: Jan 2009
Posts: 659
The AI is catching on....
|
Quote:
------- As I've already caught mewtwo, I've had to make do with zapdos, but that's not troubling me in the slightest. One thing that IS troubling me, however, is that my frame seems to be dependent upon how long I stay in the "recollection of your past events" scenes. I dunno if this has happened to anyone else, but once I get out of the recollections my frame seems to just stop. It's not the quiet/noisy area problem, I know that much, but getting a frame of 308 when my target is 1852 (timed with eontimer) is just plain weird. On another note, I've discovered some additional seed groupings (and hit some old ones as well), but I'll edit those in later when I have more data.
__________________
We like 'em RARE! [Trade Shop]
ZariGS on FanFiction.net Soul Silver (Trades): 2709 5214 9088 White2 (trades/battles): FC Pending |
|
|
|
|
|
#382 |
|
Dies, died, will die.
Join Date: Jun 2010
Posts: 302
|
You know what, nevermind about the changed timer. The info I was given was wrong. The NDS' ARM7TDMI is clocked at 16.78mhz in GBA mode. Unless GBATek is wrong, which I doubt.
|
|
|
|
|
#383 |
|
Join Date: Apr 2011
Posts: 101
Twinleaf Town, Sinnoh
|
How do I quickly find my seed from the information I have about the Pokemon I caught?
The FRLGSeedFinder requires me to type in a Seed. So I am confused. |
|
|
|
|
#384 |
|
Join Date: Mar 2009
Posts: 580
Nuvema town-ish
|
does inputting the necessary criteria in pokerng old version then transferring the seed results along with the nature and ivs on rngreporter work? if not, idk.
|
|
|
|
|
#385 |
|
Join Date: Apr 2011
Posts: 101
Twinleaf Town, Sinnoh
|
Well I worked out how to do it. It's just confusing how the word Seed means 2 different things.
So when trying to find an initial seed you commonly hit do this (v9.81): 1. Capture a high level Pokemon. 2. Check it's IVs using Metal kid. 3. Go on to the RNG Reporter (9.81). 4. Click '4th Gen Tools' at the top. 5. Click 'Calculate PID from IVs'. 6. Type in the Nature and IVs of the Pokemon you caught. 7. Find which of the results it the correct Method. (Method 1 for stationary Pokemon as in first post, Method 2 for wild Pokemon) 8. Type out the Seed that was generated into the App attached to the first post. 9. One of the new 4 hex-digit long Seeds is your Initial Seed. (4 hex-digits is 2-bytes). The Seeds starting: 54... 30... 0b... or 9e... are probably yours. imo Smogon has good guides but need to be written simpler. e.g. The bit about catching a Pokemon and checking it's IVs with the equations and calling it TCheck is basically this: If you're trying to get a high frame and have time to check IVs then: 1. Capture a wild Pokemon with Sweet Scent while your timer is running waiting for the right frame. 2. Follow the steps above for finding your Initial Seed. 3. If you hit the right Seed then carry on waiting. If it's wrong don't wait around and start again. Note: It might be a good idea to see how long it takes you to check IVs so you know if you have enough time to verify your Initial Seed before your Target Frame appears. |
|
|
|
|
#386 |
|
It's a ninja bug!
![]() ![]() ![]()
|
Those instructions are actually stated quite clearly in the OP. Just wanted to add, however, that if you get a seed that's not in one of those groups, pay attention to the frame. Usually, if you mash through the windows and encounter the pokemon right away, it's between 500 to 600 frames. It's not unusual to find whack ass seeds, and they're pretty discouraging to get, but yes, most of the times you will find seeds in the groupings you listed.
|
|
|
|
|
#387 |
|
Join Date: Apr 2010
Posts: 126
|
I don't think sweet scenting to check your seed before hitting your target frame will work.
While you're sweet scenting, several frames are skipped, and then the game enters noisy mode when you enter a battle. So using this method to check your seed before a long wait is unfeasible. Zari picked a small enough frame so that he wouldn't have to check his seed before battling Mewtwo, so he probably didn't run into this problem. |
|
|
|
|
#388 | |
|
Remodeling Kitchens
![]()
Join Date: Apr 2009
Posts: 758
Berkeley, CA
|
Quote:
It's problematic to trace back to what frame you had originally hit, but with enough work it's possible. edit: fine, "noisy" just means that the vblank advancement isnt the only thing advancing. There's NPCs, battles, wild cries, etc. Last edited by Kaphotics; Sep 12th, 2011 at 2:12:01 PM. |
|
|
|
|
|
#389 |
|
Join Date: Apr 2010
Posts: 126
|
What I understand by "noisy" is that every other frame is skipped. As in, the game is running at pseudo-120 fps. I do see where Method H comes in, since the frames do jump when I use sweet scent, but during a battle, the game seems to be skipping every other frame, what I understand to be "noisy."
My point was that if you're trying this on a cart, and you have a 16 min spread, you can't check your seed, and then expect to hit the right frame 16 minutes in. Sure, you'll know your seed, but you'll probably be several thousand frames off. |
|
|
|
|
#390 |
|
Dies, died, will die.
Join Date: Jun 2010
Posts: 302
|
no it's not at all. pid restrictions don't cause the rng to advance 2 at a time when in battle/not doing anything but walking around.
|
|
|
|
|
#391 | |
|
Dies, died, will die.
Join Date: Jun 2010
Posts: 302
|
RSE/FRLG Method Determination
------------------------------- So I've been sitting on this for about a week tryng to decide how to go about making this post and having it be at least mostly understandable to everyone. I don;t think that I quite can, so we're just going to have to go with this. First, let's consider pokemon creation: This is Method H in a nutshell:(the numbers are the locations in the ROM where the routines run from) ------------------------------- 080B5144 Battle test 080B4AC8 Encounter slot 080B4C74 Set level 080B4E2A Sync(bool) 080B4E4C Nature setup/decision(skip if(sync() == TRUE)) 08067E96 PKM building routine(test temp PIDs, make IVs on success) Now, obviously, all of those decisions need to be made using the RNG. The way Gamefreak decided to handle that was through a very simple method of taking the current result of their rand() function and using modulus to produce a number within the range they wanted. A number mod another number produces a value between 0 and the second number minus 1. So, a %(mod) b will result in a value between 0 and b-1, so it's very simple and it works. If you need a number between 1 and 100. just do a % 100 and you get results between 0 and 99, so 100 numbers. Anyway, this is used for basically everything. And all of these modulus operations are done with one specific routine: 082E7BE0 Modulus routine- r0 % r1, return result in r0 **As a quick refresher, the way Method H/J/K(basically) work is that the game takes a seed and does (seed >> 16) % 0x19. Then it starts making PIDs and doing PID % 0x19 and it keeps making PIDs until it gets a match to that original (seed >> 16) % 0x19.** What this would look like in C(the game is written in the C programming language) is something like: ushort getMod(ushort random, int m) {return (ushort)(random % m);} So, knowing that, why do we need to dwell on the formulas and modulus? Because they themselves are the root of the issue that causes the methods to occur. This is an excerpt from an ARM Application Note(#34, ARM DAI #0034A) regarding using division and (by association) the modulus operation: Quote:
That's right, 4 times as many cycles used (on average) per computation when doing out Method H and checking to see if PID % 0x19 matches (seed >> 16) % 0x19. Now, to further compare how bloated this is, let's compare the gen 3 modulus function with the divmod used in gen 4 and 5 Gen 3 modulus function:
...
Notice how it relies on expensive(in cycles) loops and branches in order to accomplish its goal. Gen 4/5 divmod:
...
Notice that this one uses a switch statement to decide how many iterations to go through and then only starts where it needs to and uses cheap add with carry(and set status flags) and subtract if carry clear instructions to accomplish the division. This one also returns the result of r0/r1 and r0%r1, which is more functionality than the one in gen 3 as well.Also, if you recall, I said that the gen 3 mod function used roughly 270 instructions on average and 750 cycles. The gen 4/5 divmod uses roughly 47-53 instructions on average and roughly 50-55 cycles total. For both division and modulus together. Each of those adcs and subcc instructions is only 1 cycle vs. the 3 for each branch/loop in gen 3. It also never loops, cutting out expensive branching. I'm of the opinion that this is an unrolled loop with a switch statement in front for proper setup and is quite likely custom assembly written by someone at Gamefreak. It's extremely efficient, possibly because the one in gen 3 was so bad. So now we know that the functions to create test PIDs in gen 3 was extremely poor in terms of speed. We also know how Method H works and why it causes so much slowdown.(slow calculation function) So knowing all of that, how does this relate to methods 2/3/4, etc? It isn't fast enough to always finish before video rendering functions(interrupts, really) break up the PID building function. Last edited by Bond697; Sep 21st, 2011 at 10:00:14 AM. |
|
|
|
|
|
#392 |
|
Dies, died, will die.
Join Date: Jun 2010
Posts: 302
|
Video
------ The GBA has some video functions that run 60x/second. They clear the screen, draw the screen, render video, etc. They are also interrupts and can run at any time if the GBA needs to. One is called VBlank. Wikipedia defines VBlank as "The vertical blanking interval (VBI), also known as the vertical interval or VBLANK, is the time difference between the last line of one frame or field of a raster display, and the beginning of the first line of the next frame." Basically, it's an interval of time when nothing is drawn to the screen, though functiuons can continue to run. It isn't a thing, just a poeriod of time. In fact, the RNG runs once per VBlank interrupt period as part of the VBlank callback function. This means that the RNG runs(needlessly) 60x/second, not just when it is needed. VCOUNT is an important I/O register that keeps track of the current vertical line that is being drawn to render the screen. The GBA's LCD screen is 240px wide by 160px high, so VCOUNT would be counting 160 lines from 0-159. Once VCOUNT is filled up, the screen must be cleared to render the next frame. Let's have a look at a diagram: ![]() This is a chart of the LCD and the blanking intervals. As we can see the GBA is 240x160, but there looks to be extra room around the screen to the right and below. That is the period of time when VBlank/HBlank are running. Lines are still being drawn, they just aren't being rendered onscreen. As we can see in the red-boxed items, the normal number of lines is 160(thus what VCOUNT normally counts to), but there are 68 extra horizontal lines being drawn that aren't showing up on the screen because nothing is being written to it. During this 4.994 milliseconds, the VBlank function is running. The RNG advances once, as well. Since the screen is 160px tall and 68 extra lines are being drawn, we can conclude that the total number of horizontal lines being drawn per vertical interval is 228 and it occurs in 16.743ms(11.749 + 4.994) Now, as I said, VBlank is an interrupt. That means that it can run at any time. What triggers it, though? VCOUNT is the sort of "monitor" for the horizontal lines being drawn vertically. When it hits 0xA0(160), that means the screen is full and VBlank must occur to clear the screen for the next frame of video. So, VCOUNT hits 160, the interrupt handler fires, VBlank runs no matter what to keep everything onscreen moving fluidly, and then it bounces back to what it was doing. ,This means that the game has 11.749ms to fully create a pokemon using those extremely slow PID creation functions and all the modulus calculations. If that doesn't happen, VBlank will occur and the RNG will advance once and throw off the pokemon being made. So now we know about the VBlank period and VCOUNT and interrupts and the IRQ handler, etc. Let's go ahead and tie this all together. If you look in a debugger(VBA-SDL-H, VBA-M, or No$GBA) and keep up, you'll notice that during the PID creation function where the game is wasting huge numbers of cycles, the VBlank interrupt will occasionally fire and advance the RNG by 1. If you notice that happening, stop the debugger and have a look at the VCOUNT register and you will see that it is always 0xA0). So then, what precisely is happening? Due to the slow speed of the function used for basically all of Method H(mainly the PID creation, though- little numbers into big numbers is very rough on it), VCOUNT fills up and thus, another video frame must be rendered. Before the new frame is rendered, the VBlank interrupt fires and wipes the screen, **also causing the RNG to advance.** Occasionally, VCOUNT will fill up as the final PID is being built and will cause an advancement between PID halves or between PID and IVs or IV halves. This is how the other methods are created. If the pokemon creation function isn't able to finish in 11.749ms(provided it has the full interval to work with), then the RNG will advance with VBlank, causing one of the other methods. In conclusion, we can say that the other methods(2-4, at least) are caused by Gamefreak's own poor programming practice and technique. The Application Note I referred to(#34) is from roughly 1998, so there is no reason to not have read it and implemented it ASAP. It is clear that gamefreak was aware of the issue, as gen 4 and 5 have an extremely fast(probably custom) div/mod algorithm implemented and it is 8-10 times as fast. For reference ------------- The offsets for Method H came from my work here: http://projectpokemon.org/wiki/Notable_Breakpoints GBATek is still the best and biggest source of info for the GBA and NDS: http://pokemon.thundaga.com/research/gbatek.htm The diagram and other great info came from romhacking.net's GBA programming manual: http://www.romhacking.net/documents/228/ GBADev and its forums is a great source of dev info(and general info) for both the GBA and NDS: http://gbadev.org/, http://forum.gbadev.org/ e: How could I forget the ARM Application Note set? http://www.nalanda.nitc.ac.in/indust...otes/index.htm Last edited by Bond697; Sep 21st, 2011 at 10:53:58 AM. |
|
|
|
|
#393 |
|
Dies, died, will die.
Join Date: Jun 2010
Posts: 302
|
i just want to make a note here that i was wrong about the gba routine using 540 cycles on average. i was using the wrong clock cycle filter in no$debug. if you set it to "cycles"
(and not "detailed formula") to show the number of cycles the current instruction uses, you can get a more accurate count. long story short, i was undercounting the number of cycles that function uses. the gen 3 modulus function seems to use about 750(!!) cycles per run, while the gen 4/5 divmod uses 55 or so. so the gen 3 mod function was taking even more time than i thought, which just makes my point even stronger. |
|
|
|
|
#394 |
|
Dies, died, will die.
Join Date: Jun 2010
Posts: 302
|
and while i'm thinking of it, those times when the rng seems to be skipping a seed, it actually isn't. the rng is doing 2 worthless advancements per frame instead of 1 at those times. some genius at gamefreak thought that adding another worthless rand() call at the top of a different function was a great idea.
can someone name a place where the rng advances double-time outside of battle? i'd like to see if it's the same for that and (preferably) what exactly causes it. |
|
|
|
|
#395 | |
|
Join Date: Apr 2011
Posts: 4
New Jersey
|
Quote:
Apparently, Cerulean Cave is a "noisy" area as long as you don't load your game from inside the cave. I'm not 100% sure so it's worth double checking.
__________________
"Although personally I am quite content with existing explosives, I feel we must not stand in the path of improvement." --Winston Churchill |
|
|
|
|
|
#396 |
Join Date: Oct 2006
Posts: 869
|
Hi again, Bond697, and thanks once more for your information-rich posts. School has started once again, so I don't have the time to parse these latest developments, so I have instead put a prominent link in the first post to your two "mega" posts. If there continue to be large posts like this during the school year, I may continue posting links in this fashion instead of attempting to pick out the relevant information—unless anyone feels that would be doing the thread too much of a disservice, that is.
|
|
|
|
|
#397 |
|
Dies, died, will die.
Join Date: Jun 2010
Posts: 302
|
i should also probably mention that those walls of text above are also responsible for split breeding spreads.
also, the pokemon gba games were gamefreak's first foray into arm/programming for the arm cpu series, so i guess it's sort of understandable that it didn't come out great? |
|
|
|
|
#398 | |
|
Join Date: Apr 2011
Posts: 4
New Jersey
|
Quote:
On a less related note, I'm having trouble getting my seed from FRLG Seedfinder, and I was wondering if anyone could either point me towards a written guide for it (if there is one) or give me a set of steps to go through to get accurate results. The problem I'm having is that the seed output that Seedfinder gives me doesn't fit with the spreads RNG reporter says I should be getting and the results I'm actually getting on. Could someone maybe pm me about this? (I don't wanna hijack the thread.)
__________________
"Although personally I am quite content with existing explosives, I feel we must not stand in the path of improvement." --Winston Churchill Last edited by saphiren; Sep 19th, 2011 at 3:32:07 PM. Reason: cleaned up a mistake |
|
|
|
|
|
#399 |
|
Dies, died, will die.
Join Date: Jun 2010
Posts: 302
|
i just noticed that the gen 4/5 divmod uses a custom assembly routine that checks 1 bit at a time starting at 31 and ending at 0. they use a switch statement to decide which bit to start on, then go a bit at a time. i'm not sure that gamefreak wrote this, though. have a look here:
http://www.peter-teichmann.de/adiv1e.html that's their divmod routine, in arm, just without the switch and written for strongARM, not arm7tdmi or arm946-es. |
|
|
|
|
#400 |
|
Dies, died, will die.
Join Date: Jun 2010
Posts: 302
|
i think this should help (some) people understand what's going on:
Code:
#include <nds.h>
#include <stdio.h>
#include <timers.h>
#define REG_GXSTAT (*(vu32*)0x04000600)
#define REG_T0 (*(vu16*)0x04000100)
#define REG_T1 (*(vu16*)0x04000104)
#define REG_T2 (*(vu16*)0x04000108)
#define REG_T3 (*(vu16*)0x0400010C)
volatile int frame = 0;
typedef unsigned short u16_t;
typedef unsigned int u32_t;
typedef unsigned long long u64_t;
u32_t rand64();
u64_t mul64(u64_t num1, u64_t num2);
u16_t rand32();
u64_t seed = 0;
u32_t seed32 = 0;
//---------------------------------------------------------------------------------
void Vblank() {
//---------------------------------------------------------------------------------
frame++;
rand32();
rand64();
}
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
lcdSwap();
irqSet(IRQ_VBLANK, Vblank);
consoleDemoInit();
int i = rand() % 4;
switch(i)
{
case 0:
TIMER_CR(0) = TIMER_ENABLE | TIMER_DIV_1;
break;
case 1:
TIMER_CR(1) = TIMER_ENABLE | TIMER_DIV_64;
break;
case 2:
TIMER_CR(2) = TIMER_ENABLE | TIMER_DIV_256;
break;
case 3:
TIMER_CR(3) = TIMER_ENABLE | TIMER_DIV_1024;
}
iprintf(" Test\n\n");
//iprintf(" %X \n", t0);
u32_t gx = REG_GXSTAT + rand();
seed = (u64_t)gx;
while(1) {
//timerStop(i);
u16_t lc32 = rand32();
u32_t lc64 = rand64();
iprintf("\x1b[10;0HFrame: %u", frame);
iprintf("\x1b[12;0H64-bit: %16llX", seed);
iprintf("\x1b[14;0H64-bit return: %08X", lc64);
iprintf("\x1b[16;0H32-bit: %08X", seed32);
iprintf("\x1b[18;0H32-bit return: %04X", lc32);
swiWaitForVBlank();
}
return 0;
}
u32_t rand64()
{
const u64_t a = 0x5d588b656c078965;
const u64_t c = 0x0000000000269ec3;
seed = mul64(seed, a) + c;
return (u32_t)(seed >> 32);
}
u64_t mul64(u64_t num1, u64_t num2)
{
u64_t result = (num1 * num2);
return result;
}
u16_t rand32()
{
const u32_t a = 0x41C64E6D;
const u32_t c = 0x00006073;
seed32 = (a * seed32) + c;
return (u16_t)(seed32 >> 16);
}
http://pokemon.thundaga.com/research/apps/vblank.nds (note for mods: this is a program that i wrote and compiled using a free toolchain. no illegal/confidential applications were used to build this rom image. feel free to pm me for further clarification.) now, if you run it, you'll see a frame counter, and both rngs running along with output to cut them in half like gamefreak does. what you're seeing here is vblank running at 60fps(since it's clearing the screen to let the next frame of video be drawn) and every time it runs, the rng advances once. this is exactly what gamefreak did and how the rng advances quickly in gen 3. |
|
|
![]() |
| Thread Tools | |
|
|