Jump to content

RenegadeRaven

Member
  • Posts

    26
  • Joined

  • Last visited

Posts posted by RenegadeRaven

  1. Lately, I've been shiny hunting distortion world Giratina in Pokémon Platinum, but it's been taking forever. Now I'm wondering if it can even shine for me, so I started looking into TSV for Gen 4 but can only find stuff for Gen 6 and 7. So how is TSV calculated in Gen 4? Because what I've found is TID xor SID = TSV, but when I put my IDs in it gives me 0.

  2. On 3/3/2018 at 11:46 AM, Regnum said:

    Is the Regigigas/Heatran event serial code the same for everyone? Turns out my Pokémon trainer club account didn’t have the receive newsletters option selected.

    So that I'm prepared for next time (had to find out from a gamestop employee when I asked them for the Regigigas/Heatran code), does anyone know how Entei/Raikou and the rest of the events are being distributed.

  3. 22 hours ago, theSLAYER said:

    Remember that the data is in little endian and needs to be swapped. At least that part is more of less working properly.

    now, slowly increment/push forward to see which sub or function isn't working

    I tried incrementing forward as you said and found that byter(z) = blocka(z) Xor rand() is equal to byter(z) = 0xAA60CFF and byter() is UInt16. 

    So I changed byter(z) = block_(z) Xor rand() to byter(z) = CType((block_(z) Xor rand()), System.UInt16), now the function rand() is giving me the System.OverflowException error.

  4. 5 minutes ago, theSLAYER said:

    before the select case, get your program to prompt a message box, and display the PID values.
    (to ensure that the program is indeed reading the file)

    It gave me 0x35C7F1EE, but the pk5 file in HxD says 0xEEF1C735.

  5. 5 hours ago, theSLAYER said:

    Not that I'm very good at programming, but maybe you wanna
    Dim ekx() as byte = encrypt(pkx)

    Maybe also want to do a "if then" logic tests in your routine,
    as Gen 6/7 encrypt is gonna be different from the Gen5 routine I showed you.

    I tried that, but the error persists. I then tried:

    Private Sub toEnc()
    	Dim myFile As String = OpenFileDialog1.FileName
    	Dim myBytes As Byte() = My.Computer.FileSystem.ReadAllBytes(myFile)
    	Dim txtTemp As New System.Text.StringBuilder()
    	For Each myByte As Byte In myBytes
    		txtTemp.Append(myByte.ToString("X2"))
    	Next
    	RichTextBox1.Text = txtTemp.ToString()
    
    	Dim myData = RichTextBox1.Text
    	Dim pkx As Byte() = HexStringToByteArray(myData)
    	Dim ekx() As Byte = encrypt(pkx)
    End Sub
    
    Private Shared Function HexStringToByteArray(ByRef strInput As String) As Byte()
            Dim length As Integer
            Dim bOutput As Byte()
            Dim c(1) As Integer
            length = strInput.Length / 2
            ReDim bOutput(length - 1)
            For i As Integer = 0 To (length - 1)
                For j As Integer = 0 To 1
                    c(j) = Asc(strInput.Chars(i * 2 + j))
                    If ((c(j) >= Asc("0")) And (c(j) <= Asc("9"))) Then
                        c(j) = c(j) - Asc("0")
                    ElseIf ((c(j) >= Asc("A")) And (c(j) <= Asc("F"))) Then
                        c(j) = c(j) - Asc("A") + &HA
                    ElseIf ((c(j) >= Asc("a")) And (c(j) <= Asc("f"))) Then
                        c(j) = c(j) - Asc("a") + &HA
                    End If
                Next j
                bOutput(i) = (c(0) * &H10 + c(1))
            Next i
         Return (bOutput)
    End Function

     

  6. 14 hours ago, theSLAYER said:

    you may need to set your own variables public and correct in other instances besides the function.

    How are you reading the file, and what variable is handling the Pokemon file you're reading
    (I'm getting the feeling you haven't loaded the file)

    The file is being loaded with:

    Dim myFile = OpenFileDialog1.FileName
    Dim pkx() As Byte = My.Computer.FileSystem.ReadAllBytes(myFile)
    Dim ekx = encrypt(pkx)

     

  7. 12 hours ago, theSLAYER said:

    @Regnum

    This is my encrypt code.
    Since this was made years back, there's probably definitely better ways to optimize the code,
    so you can keep that in mind if you're gonna adapt it.

     

      Reveal hidden contents

     

    
    
    
        Public Function encrypt(ByVal pkm() As Byte)
            Dim pid As UInt32 = 0
            Dim checksum As UInt16 = 0
            pid = BitConverter.ToUInt32(pkm, 0)
            checksum = BitConverter.ToUInt16(pkm, 6)
            Dim order As Integer = (pid >> (13) And 31) Mod 24
            Dim firstblock As String
            Dim secondblock As String
            Dim thirdblock As String
            Dim fourthblock As String
    
            firstblock = 0
            secondblock = 0
            thirdblock = 0
            fourthblock = 0
            Select Case order
                Case 0
                    firstblock = "A"
                    secondblock = "B"
                    thirdblock = "C"
                    fourthblock = "D"
                Case 1
                    firstblock = "A"
                    secondblock = "B"
                    thirdblock = "D"
                    fourthblock = "C"
                Case 2
                    firstblock = "A"
                    secondblock = "C"
                    thirdblock = "B"
                    fourthblock = "D"
                Case 3
                    firstblock = "A"
                    secondblock = "C"
                    thirdblock = "D"
                    fourthblock = "B"
                Case 4
                    firstblock = "A"
                    secondblock = "D"
                    thirdblock = "B"
                    fourthblock = "C"
                Case 5
                    firstblock = "A"
                    secondblock = "D"
                    thirdblock = "C"
                    fourthblock = "B"
                Case 6
                    firstblock = "B"
                    secondblock = "A"
                    thirdblock = "C"
                    fourthblock = "D"
                Case 7
                    firstblock = "B"
                    secondblock = "A"
                    thirdblock = "D"
                    fourthblock = "C"
                Case 8
                    firstblock = "B"
                    secondblock = "C"
                    thirdblock = "A"
                    fourthblock = "D"
                Case 9
                    firstblock = "B"
                    secondblock = "C"
                    thirdblock = "D"
                    fourthblock = "A"
                Case 10
                    firstblock = "B"
                    secondblock = "D"
                    thirdblock = "A"
                    fourthblock = "C"
                Case 11
                    firstblock = "B"
                    secondblock = "D"
                    thirdblock = "C"
                    fourthblock = "A"
                Case 12
                    firstblock = "C"
                    secondblock = "A"
                    thirdblock = "B"
                    fourthblock = "D"
                Case 13
                    firstblock = "C"
                    secondblock = "A"
                    thirdblock = "D"
                    fourthblock = "B"
                Case 14
                    firstblock = "C"
                    secondblock = "B"
                    thirdblock = "A"
                    fourthblock = "D"
                Case 15
                    firstblock = "C"
                    secondblock = "B"
                    thirdblock = "D"
                    fourthblock = "A"
                Case 16
                    firstblock = "C"
                    secondblock = "D"
                    thirdblock = "A"
                    fourthblock = "B"
                Case 17
                    firstblock = "C"
                    secondblock = "D"
                    thirdblock = "B"
                    fourthblock = "A"
                Case 18
                    firstblock = "D"
                    secondblock = "A"
                    thirdblock = "B"
                    fourthblock = "C"
                Case 19
                    firstblock = "D"
                    secondblock = "A"
                    thirdblock = "C"
                    fourthblock = "B"
                Case 20
                    firstblock = "D"
                    secondblock = "B"
                    thirdblock = "A"
                    fourthblock = "C"
                Case 21
                    firstblock = "D"
                    secondblock = "B"
                    thirdblock = "C"
                    fourthblock = "A"
                Case 22
                    firstblock = "D"
                    secondblock = "C"
                    thirdblock = "A"
                    fourthblock = "B"
                Case 23
                    firstblock = "D"
                    secondblock = "C"
                    thirdblock = "B"
                    fourthblock = "A"
            End Select
            Dim z As Integer = 0
            Dim v As Integer = 8
            'Block A
            Dim blocka(16) As UInt16
            While z < 16
                blocka(z) = BitConverter.ToUInt16(pkm, v)
                z = z + 1
                v = v + 2
            End While
            z = 0
            v = 40
            'Block B
            Dim blockb(16) As UInt16
            While z < 16
                blockb(z) = BitConverter.ToUInt16(pkm, v)
                z = z + 1
                v = v + 2
            End While
            z = 0
            'Block C
            v = 72
            Dim blockc(16) As UInt16
            While z < 16
                blockc(z) = BitConverter.ToUInt16(pkm, v)
                z = z + 1
                v = v + 2
            End While
            z = 0
            'Block D
            Dim blockd(16) As UInt16
            v = 104
            While z < 16
                blockd(z) = BitConverter.ToUInt16(pkm, v)
                z = z + 1
                v = v + 2
            End While
            z = 0
            srnd(checksum)
            Dim byter(16) As UInt16
            z = 0
            v = 8
    
            Select Case firstblock
                Case "A"
                    While z < 16
                        byter(z) = blocka(z) Xor rand()
                        z = z + 1
                    End While
                Case "B"
                    While z < 16
                        byter(z) = blockb(z) Xor rand()
                        z = z + 1
                    End While
                Case "C"
                    While z < 16
                        byter(z) = blockc(z) Xor rand()
                        z = z + 1
                    End While
                Case "D"
                    While z < 16
                        byter(z) = blockd(z) Xor rand()
                        z = z + 1
                    End While
            End Select
            z = 0
            v = 8
            While z < 16
                pkm(v) = byter(z) And 255
                pkm(v + 1) = byter(z) >> 8
                z = z + 1
                v = v + 2
            End While
            z = 0
            v = 40
            Select Case secondblock
                Case "A"
                    While z < 16
                        byter(z) = blocka(z) Xor rand()
                        z = z + 1
                    End While
                Case "B"
                    While z < 16
                        byter(z) = blockb(z) Xor rand()
                        z = z + 1
                    End While
                Case "C"
                    While z < 16
                        byter(z) = blockc(z) Xor rand()
                        z = z + 1
                    End While
                Case "D"
                    While z < 16
                        byter(z) = blockd(z) Xor rand()
                        z = z + 1
                    End While
            End Select
            z = 0
            While z < 16
                pkm(v) = byter(z) And 255
                pkm(v + 1) = byter(z) >> 8
                z = z + 1
                v = v + 2
            End While
            z = 0
            v = 72
            Select Case thirdblock
                Case "A"
                    While z < 16
                        byter(z) = blocka(z) Xor rand()
                        z = z + 1
                    End While
                Case "B"
                    While z < 16
                        byter(z) = blockb(z) Xor rand()
                        z = z + 1
                    End While
                Case "C"
                    While z < 16
                        byter(z) = blockc(z) Xor rand()
                        z = z + 1
                    End While
                Case "D"
                    While z < 16
                        byter(z) = blockd(z) Xor rand()
                        z = z + 1
                    End While
            End Select
            z = 0
            While z < 16
                pkm(v) = byter(z) And 255
                pkm(v + 1) = byter(z) >> 8
                z = z + 1
                v = v + 2
            End While
            z = 0
            v = 104
            Select Case fourthblock
                Case "A"
                    While z < 16
                        byter(z) = blocka(z) Xor rand()
                        z = z + 1
                    End While
                Case "B"
                    While z < 16
                        byter(z) = blockb(z) Xor rand()
                        z = z + 1
                    End While
                Case "C"
                    While z < 16
                        byter(z) = blockc(z) Xor rand()
                        z = z + 1
                    End While
                Case "D"
                    While z < 16
                        byter(z) = blockd(z) Xor rand()
                        z = z + 1
                    End While
            End Select
            z = 0
            While z < 16
                pkm(v) = byter(z) And 255
                pkm(v + 1) = byter(z) >> 8
                z = z + 1
                v = v + 2
            End While
            z = 0
            Return pkm
        End Function

     

     

    I keep getting a System.OverflowException at the Select Case firstblock.

  8. 15 minutes ago, theSLAYER said:

    here, Lemme show you:

     

      Hide contents
    
    
    
        Public Function encrypt(ByVal pkm() As Byte)
          	'variables here
    		'stuff happens here	
          	
          	'such as Shuffle the blocks using the block shuffling algorithm above. 
          
          	'Seed the PRNG with the checksum (let X[n] be the checksum), 
            srnd(checksum)
            
          	'finally, Sequentially, for each 2-byte word Y from 0x08 to 0x87, apply the transformation: unencryptedByte = Y xor rand() 
    		'example:    
    
            Select Case firstblock
                Case "A"
                    While z < 16
                        byter(z) = blocka(z) Xor rand()
                        z = z + 1
                    End While
              
          	'remainder of code
            Return pkm
        End Function

     

     

    So like this:

     

    'block shuffling stuff
    
    srnd(chksum)
    rand()

     

  9. 6 minutes ago, theSLAYER said:

    These are the functions I have relating to rand and the seed generation:

      Reveal hidden contents
    
    
    Public seed As UInt32
    
    Public Sub srnd(ByVal newSeed As UInt32)
            seed = newSeed
    End Sub
    
    Public Function rand() As UInt32
            seed = (((&H41C64E6D * seed) + &H6073)) And &HFFFFFFFF
            Return seed >> 16
    End Function

     


    So at every instance that you block xor rand(), the rand will give the updated random number as per the game's RNG.

    I'm pretty sure I got help for this a long time ago, but I can't remember from who.
    In any case, that is how it is done :)

    (edit: I think I use the srnd function relating to checksum)

    Is seed the checksum?

  10. 1 hour ago, theSLAYER said:

    The shuffling order formula is basically:
    dim order as integer = (pid >> (13) And 31) Mod 24

    and the horrible implementation for order shuffling I did a long time ago:

      Reveal hidden contents
    
    
    Select Case order
                Case 0
                    firstblock = "A"
                    secondblock = "B"
                    thirdblock = "C"
                    fourthblock = "D"
                Case 1
                    firstblock = "A"
                    secondblock = "B"
                    thirdblock = "D"
                    fourthblock = "C"
                Case 2
                    firstblock = "A"
                    secondblock = "C"
                    thirdblock = "B"
                    fourthblock = "D"
                Case 3
                    firstblock = "A"
                    secondblock = "D"
                    thirdblock = "B"
                    fourthblock = "C"
                Case 4
                    firstblock = "A"
                    secondblock = "C"
                    thirdblock = "D"
                    fourthblock = "B"
                Case 5
                    firstblock = "A"
                    secondblock = "D"
                    thirdblock = "C"
                    fourthblock = "B"
                Case 6
                    firstblock = "B"
                    secondblock = "A"
                    thirdblock = "C"
                    fourthblock = "D"
                Case 7
                    firstblock = "B"
                    secondblock = "A"
                    thirdblock = "D"
                    fourthblock = "C"
                Case 8
                    firstblock = "C"
                    secondblock = "A"
                    thirdblock = "B"
                    fourthblock = "D"
                Case 9
                    firstblock = "D"
                    secondblock = "A"
                    thirdblock = "B"
                    fourthblock = "C"
                Case 10
                    firstblock = "C"
                    secondblock = "A"
                    thirdblock = "D"
                    fourthblock = "B"
                Case 11
                    firstblock = "D"
                    secondblock = "A"
                    thirdblock = "C"
                    fourthblock = "B"
                Case 12
                    firstblock = "B"
                    secondblock = "C"
                    thirdblock = "A"
                    fourthblock = "D"
                Case 13
                    firstblock = "B"
                    secondblock = "D"
                    thirdblock = "A"
                    fourthblock = "C"
                Case 14
                    firstblock = "C"
                    secondblock = "B"
                    thirdblock = "A"
                    fourthblock = "D"
                Case 15
                    firstblock = "D"
                    secondblock = "B"
                    thirdblock = "A"
                    fourthblock = "C"
                Case 16
                    firstblock = "C"
                    secondblock = "D"
                    thirdblock = "A"
                    fourthblock = "B"
                Case 17
                    firstblock = "D"
                    secondblock = "C"
                    thirdblock = "A"
                    fourthblock = "B"
                Case 18
                    firstblock = "B"
                    secondblock = "C"
                    thirdblock = "D"
                    fourthblock = "A"
                Case 19
                    firstblock = "B"
                    secondblock = "D"
                    thirdblock = "C"
                    fourthblock = "A"
                Case 20
                    firstblock = "C"
                    secondblock = "B"
                    thirdblock = "D"
                    fourthblock = "A"
                Case 21
                    firstblock = "D"
                    secondblock = "B"
                    thirdblock = "C"
                    fourthblock = "A"
                Case 22
                    firstblock = "C"
                    secondblock = "D"
                    thirdblock = "B"
                    fourthblock = "A"
                Case 23
                    firstblock = "D"
                    secondblock = "C"
                    thirdblock = "B"
                    fourthblock = "A"
            End Select

     

     

    Thanks.

    Now, how do I use the formula, X[n+1] = (0x41C64E6D * X[n] + 0x6073), what do I put for X[n] and X[n+1]?

  11. 35 minutes ago, theSLAYER said:

    Gen IV and V
    Read up on PKM structure, and see checksum.


    And how the system got minor updates in Gen VI and VII

     

    I had looked at those, it’s that I don’t know how to apply the formulas written there.

  12. How do I convert *.pkx to *.ekx, x being 4, 5, 6, or 7? I'm trying to write a program in Visual Basic, and I need it to be able to encrypt *.pkx files into *.ekx files. The problem is I can't figure out how.

  13. 1 hour ago, theSLAYER said:

    Hello @Regnum,
    If I'm not mistaken, Pokemon Blue and Pokemon Red have the exact same offsets,

    So you could directly just import the save in your Pokemon Red, without having to make any changes.

    Have you tried doing that? (I'm asking, to find out whether it works as such)

    Thanks for trying @theSLAYER, I tried what you said and i got this...

    59d59a8941c10_2017-10-0421_22_44.thumb.jpg.664eba30006f9f40a0577d59c183bd31.jpg

    I'm unable to move or open the menu. All i can do is reset the game.

  14. Could someone help me? I'm try to transfer a save from blue to red, i was able to transfer all my data, but i was unable to set the ingame events to as if i already went thru them. Could someone tell me how to do that or can someone help find a save file that's just beaten the Fuchsia Gym and hasn't gone thru Silph Co. nor the Rocket Game Corner and hasn't beaten the Saffron, Cinnabar and Viridian Gyms.

    My Blue save is attached below to supply further info on what Red save I am looking for, and for if anyone is looking for a save for Blue.

    sav.dat

    And this is my attempt at converting a blue save to Red.

    sav.dat

×
×
  • Create New...