+ Reply to Thread
Page 2 of 6
FirstFirst 1 2 3 4 5 6 LastLast
Results 16 to 30 of 90

Thread: Help with some new stuff; trash bytes?

  1. #16
    Member
    Join Date
    Jul 2009
    Age
    21
    Posts
    63

    Re: Trouble understanding the PID information

    That's basically what I had, but it doesn't work.

    'IV is the hex value of hex offsets 38-3B in little endian
    IV = String.Format("{0,2:X2}", data(41)) + String.Format("{0,2:X2}", data(40)) + String.Format("{0,2:X2}", data(39)) + String.Format("{0,2:X2}", data(38))

    'value2 is IV converted to integer
    Dim value2 As Integer = Integer.Parse(IV, Globalization.NumberStyles.HexNumber)

    'exactly what you have, I sometimes use And Binary where Binary is int 31
    DEF_IV = ((value2 >> (10)) And &H1F)


    When it is in little endian format, I constantly get 0's for any IV. If I do it in big endian, I get wrong answers. This particular file has the IVs: HP = 0, Attack = 6, Defense = 28. When I print the 3 IVs in big endian (as little returns all 0's), I get 0, 8 and 26.

  2. #17
    Learning to breathe IRC VOPDeveloperGame Save ResearcherModerator codemonkey85's Avatar
    Join Date
    Apr 2009
    Location
    http://goo.gl/Wd4id
    Age
    27
    Posts
    800

    Re: Trouble understanding the PID information

    Quote Originally Posted by greentea View Post
    'IV is the hex value of hex offsets 38-3B in little endian
    IV = String.Format("{0,2:X2}", data(41)) + String.Format("{0,2:X2}", data(40)) + String.Format("{0,2:X2}", data(39)) + String.Format("{0,2:X2}", data(38))
    Part of the problem I am seeing is that you are using decimal instead of hexadecimal for your offsets. In VB you use the prefix &H to specify hex instead of decimal; so 38 should actually be &H38, 39 should be &H39, and the next two are actually &H3A and &H3B.

    Why are you doing it this way, anyway? How about doing this instead:

    Code:
    IV = BitConverter.ToUInt32(DATA, &H38)
    The BitConverter class will automatically put your number together. DATA is your byte array, and &H38 is the starting offset. Easy, right?

  3. #18
    Member
    Join Date
    Jul 2009
    Age
    21
    Posts
    63

    Re: Trouble understanding the PID information

    The offsets are hex. That value does indeed produce a hex. I am using String.Format. X makes the value a hexadecimal.

    C0 70 FE 00 is the hex 38-3B for this particular file.

    Using the way I wrote it, in little endian.

    txtIV.AppendText(IV)

    returns "00FE70C0"


    NEVERMIND. I got it to work this way. I was using the wrong offsets hahaha.

    Now, I've got another couple of questions. Ability and moves, do they follow regular patterns or do I have to just make a chart of them. I'm asking because you had the chart last time, maybe you have more for this =P.

    And for gender, nature and shiny, I didn't see any info for it, so I'm kind of in the dark here how to figure it out.
    Last edited by greentea; Jul 12th, 2009 at 02:08 PM.

  4. #19
    Member DeveloperRAM Researcher Jiggy-Ninja's Avatar
    Join Date
    Apr 2009
    Age
    22
    Posts
    293

    Re: A couple more questions, IV is solved at least =P

    I'm a Natu.
    Spoiler

  5. #20
    Member
    Join Date
    Jul 2009
    Age
    21
    Posts
    63

    Re: A couple more questions, IV is solved at least =P

    Figures I wouldn't think to look on Bulbapedia for this. Thanks, it looks like I'll be able to code it from that, hopefully.

  6. #21
    Learning to breathe IRC VOPDeveloperGame Save ResearcherModerator codemonkey85's Avatar
    Join Date
    Apr 2009
    Location
    http://goo.gl/Wd4id
    Age
    27
    Posts
    800

    Re: A couple more questions, IV is solved at least =P

    greentea, most of the database information I use came originally from Legendary Pokémon. Some of it had to be edited / revised / reformatted for my needs, but there's a bunch there that I think you will find useful.

  7. #22
    Member
    Join Date
    Jul 2009
    Age
    21
    Posts
    63

    Re: A couple more questions, IV is solved at least =P

    I'm a little stuck on the gender now, and the shiny or not part.

    First off, ability and nature were pretty easy. I'll use a text file for the abilities, nature I coded straight in, there's only 25.

    With gender, I have a Charizard I was checking. Charizard, according to Serebii, is 87.5% Male (which makes sense). It returned 189 with my code. Since the value is 31, we know it is male, which it is. However, I went and used a Lugia. It returned 166. We know Lugia to be genderless, so the site says it should return 255. Pokesav shows it as genderless.

    The code I am using is:

    gender = PID mod 256

    which is just what the site says "essentially p % 256" which is easier to code than whatever other stuff they were talking about (clearly I didn't get it).

    Secondly, we get to shininess. This Lugia I am using, it has a PID that is 9 digits long, so in binary, it is only 27 digits long. These are 32 bit binary numbers, so do I assume the first 5 are 0? Or how else should I go about this. The rest of that code makes sense to me. I know truth tables and all, I understand XOR logic. The code is there and easy enough to do.

  8. #23
    Member DeveloperRAM Researcher Jiggy-Ninja's Avatar
    Join Date
    Apr 2009
    Age
    22
    Posts
    293

    Re: A couple more questions, IV is solved at least =P

    Yes, assume the leading 5 digits are 0.

    For Lugia, the 255 is a reference to the gender value that is part of the Pokemon's base stat structure. IE, it's the same as the 31 is for Charizard. It is not what the p % 256 needs to output.

    Pokemon with 255 as their base gender value will always be genderless, regardless of what p%256 outputs. Pokemon 254 as the gender value will always be female.
    I'm a Natu.
    Spoiler

  9. #24
    Learning to breathe IRC VOPDeveloperGame Save ResearcherModerator codemonkey85's Avatar
    Join Date
    Apr 2009
    Location
    http://goo.gl/Wd4id
    Age
    27
    Posts
    800

    Re: A couple more questions, IV is solved at least =P


  10. #25
    Member DeveloperRAM Researcher Jiggy-Ninja's Avatar
    Join Date
    Apr 2009
    Age
    22
    Posts
    293

    Re: A couple more questions, IV is solved at least =P

    It's likely that there's a manual check before or after the PID calculation that checks the Pokemon's

    If you think about it, there already has to be a check for 255 to make the Pokemon genderless. It's not that farfetch'd to think there's another check for 254, the all female value.
    I'm a Natu.
    Spoiler

  11. #26
    Member
    Join Date
    Jul 2009
    Age
    21
    Posts
    63

    Re: A couple more questions, IV is solved at least =P

    Actually, the way I was currently checking, it was using the FE. When I programmed it, I saw the part about male and female so I did that. However, I ran into a slight problem. For the few pokemon that have alternate forms, their FE doesn't respond to male or female. What of those few?

  12. #27
    Learning to breathe IRC VOPDeveloperGame Save ResearcherModerator codemonkey85's Avatar
    Join Date
    Apr 2009
    Location
    http://goo.gl/Wd4id
    Age
    27
    Posts
    800

    Re: A couple more questions, IV is solved at least =P

    EDIT: Ah, son of a gun. Jiggy got me again.

    The information for Fateful Encounter, gender, and alternate forms are stored in completely separate bits of the bytes at 0x40-0x41. Look at the two bytes this way:

    0|0|0|0 0000 0000 0000

    Where Blue is the flag for Fateful Encounter, Red is the flag for female, dark red is the flag for genderless, and the rest is for alternate forms.

    Bear in mind that the data is stored in little-endian, which means the bits (and bytes) go from least significant to most significant from right to left.
    Last edited by codemonkey85; Jul 20th, 2009 at 10:56 PM.

  13. #28
    Member DeveloperRAM Researcher Jiggy-Ninja's Avatar
    Join Date
    Apr 2009
    Age
    22
    Posts
    293

    Re: A couple more questions, IV is solved at least =P

    Quote Originally Posted by codemonkey85 View Post
    Bear in mind that the data is stored in little-endian, which means the bits (and bytes) go from least significant to most significant from right to left.
    You have bit dyslexia again.

    Little Endian has the least significant bits on the left side. It's the exact opposite of our normal number system, which is Big Endian.

    You're color coded diagram is written in Big Endian.
    I'm a Natu.
    Spoiler

  14. #29
    Member
    Join Date
    Jul 2009
    Age
    21
    Posts
    63

    Re: A couple more questions, IV is solved at least =P

    I guess I gotta review some stuff about bits and bytes.

    From what I understand though, I just need to access the first 3 parts of the binary to check. I guess it's simple enough as long as I understand the bits and bytes, haha. And I guess I can assume non-female, non-genderless is male.

    You guys always come to my rescue. This is what happens when you take a mixed (in between college level and university level) CS course. That you ace (with 100%) and do nothing half the time cause you're done (and everyone but one aren't) because they're stupid. Did I mention the class average was 68% and my teacher knows C/C++ and never did VB? If I had learned any of this... hahaha

  15. #30
    Learning to breathe IRC VOPDeveloperGame Save ResearcherModerator codemonkey85's Avatar
    Join Date
    Apr 2009
    Location
    http://goo.gl/Wd4id
    Age
    27
    Posts
    800

    Re: A couple more questions, IV is solved at least =P

    I took a VB beginner's course recently because I have to (college degree and all), and the teacher knew nothing at all about binary file handling. I was disappointed to find this out when I asked him some questions.

    But anyway.

    Just remember that VB handles a lot of things for you. Don't go reinventing the wheel; if you need to do some kind of bitwise operation or conversion, look and see what VB has to offer first.

+ Reply to Thread
Page 2 of 6
FirstFirst 1 2 3 4 5 6 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
PPN Top 50