Sabresite

Project Pokemon Save Editor - To Do List

5 posts in this topic

Here will be a nice list of ToDo's for PPSE. This list will be updated with new stuff, and old stuff will be subtracted as necessary.

  • Change hardcoded resources.cpp information to a text or binary loaded resource to lower initialization file.
  • Add PokeText <--> Unicode library for fixed-length, dynamic length strings, and trash byte support using the font dictable.
  • Create a universal file loading handler to handle all possible formats. Handler will keep the file in memory then convert the file to the raw SAV format.
  • Create a universal file saving handler to handle all possible formats. Handler will covert the modified sav file to the same format as the original file from memory. Handler should automatically handle headers/footers.

Share this post


Link to post
Share on other sites

As far as a PokéText dictionary / string conversion formula goes, Jiggy and I have both done this. I know for my part that the function I wrote will take a string of any size and output the PokéText data as a byte array (including an optional boolean parameter for whether or not to append the FF FF terminator). Conversely, I wrote a function that will accept such a byte array and turn it into a string. Am I misunderstanding your intentions?

And I also wrote a function that accepts a filename, determines which kind of save format to use, and returns an object of the matching type. Right now there are two structures to choose from, either DPSaveFile or PtSaveFile. I am using binary serialization to load / save these structures.

Jiggy-Ninja and SCV did something different here; I believe Jiggy wrote a series of constructors to obtain the data from a "file vector" or somesuch Qt terminology.

Unless you are referring to .DUC, .Sav, and all of those formats.

You should take a look at my source one day, if you can manage to read VB.Net without a brain hemmorhage.

Share this post


Link to post
Share on other sites
As far as a PokéText dictionary / string conversion formula goes, Jiggy and I have both done this. I know for my part that the function I wrote will take a string of any size and output the PokéText data as a byte array (including an optional boolean parameter for whether or not to append the FF FF terminator). Conversely, I wrote a function that will accept such a byte array and turn it into a string. Am I misunderstanding your intentions?

And I also wrote a function that accepts a filename, determines which kind of save format to use, and returns an object of the matching type. Right now there are two structures to choose from, either DPSaveFile or PtSaveFile. I am using binary serialization to load / save these structures.

Jiggy-Ninja and SCV did something different here; I believe Jiggy wrote a series of constructors to obtain the data from a "file vector" or somesuch Qt terminology.

Unless you are referring to .DUC, .Sav, and all of those formats.

You should take a look at my source one day, if you can manage to read VB.Net without a brain hemmorhage.

I haven't seen your VB code in regards to PokeText. I cannot find anything in the PPSE SVN for PokeText, so I will probably end up writing it. I have the code already taken care of, basically everything you said, except it also handles trash bytes dynamically.

For the file loading, yeah I was going to expand on what has already been coded to support other formats universally, so the program can load a file and save it using the same object.

Share this post


Link to post
Share on other sites
I haven't seen your VB code in regards to PokeText.

Here it is, if you want to see it.

And here's how I basically use it:

    Public Shared CNVRT As New PKMFontConverter

   Public Shared Function PKMBytesToString(ByVal Byte_Array() As Byte) _
As String

       PokemonLib.InitializeDictionaries()

       If Byte_Array.Length = 1 Then
           Dim buf As Byte = Byte_Array(0)
           ReDim Byte_Array(1)
           Byte_Array(0) = buf
       End If

       Dim strName As String = ""
       For iCount As Integer = 0 To Byte_Array.Length - 1 Step 2
           Dim iByte As UInt16 = BitConverter.ToUInt16(New Byte() {Byte_Array(iCount), Byte_Array(iCount + 1)}, 0)
           If iByte >= 0 Then
               If iByte <> &HFFFF Then strName &= Char.ConvertFromUtf32(CNVRT.PKMToUnicode(iByte))
           End If
           If Byte_Array(iCount + 0) = &HFF And Byte_Array(iCount + 1) = &HFF _
            Then Return strName
       Next
       Return strName

   End Function


   Public Shared Function StringToPKMBytes(ByVal mString As String, Optional ByVal Terminator As Boolean = False) As Byte()
       If mString = "" Then Return New Byte() {}
       Dim Data((mString.Length * 2) + 1) As Byte
       Dim strData As String = ""
       For i As Integer = 0 To mString.Length - 1
           Dim _i As Byte() = BitConverter.GetBytes(CNVRT.UnicodeToPKM(Char.ConvertToUtf32(mString, i)))
           strData &= _i(0) & "," & _i(1) & ","
       Next
       strData = strData.Substring(0, strData.LastIndexOf(","))
       Dim _strData() As String = strData.Split(",")
       CNVRT.DictionaryInitialize()
       For i As Integer = 0 To _strData.Length - 1
           Try
               Data(i) = Integer.Parse(_strData(i))
           Catch ex As Exception
               Console.WriteLine(Err.Number & ": " & ex.Message)
               Stop
           End Try
       Next
       If Terminator Then
           If _strData.Length = Data.Length Then
               Data(Data.Length - 2) = &HFF
               Data(Data.Length - 1) = &HFF
           Else
               Data(_strData.Length) = &HFF
               Data(_strData.Length + 1) = &HFF
           End If
       End If
       strData = ""
       For i As Integer = 0 To Data.Length - 1
           strData &= Hex(Data(i)) & ", "
       Next
       If Terminator Then Return Data
       Dim dataout(Data.Length - 3) As Byte
       Array.Copy(Data, 0, dataout, 0, dataout.Length)
       Return dataout
   End Function

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now