Revert "Merge branch 'update-cry-imp-exp' into quicker-pokemonedit-browsing"

This reverts commit 67cb497eca, reversing
changes made to 173a684cb8.
This commit is contained in:
Dreuu 2018-08-03 20:24:59 -04:00
parent 67cb497eca
commit a366c56d56
3 changed files with 49 additions and 406 deletions

View File

@ -24,24 +24,18 @@ Module CryFunctions
Public Function LoadCry(index As Integer, cryTable As Integer) As Cry
Dim CryToLoad As New Cry
'If ledrom Is Nothing Then
' Return False
'End If
' load cry table entry
'ledrom.Seek(cryTable + index * 12)
'Dim someValue = ledrom.ReadInt32()
'Dim cryOffset = ledrom.ReadPointer()
'Dim cryShape = ledrom.ReadInt32()
Dim CryToLoad As New Cry With {
.Index = index
}
Dim convIndex As Integer = -1
If index > 276 Then
Dim offset As Integer = Int32.Parse((GetString(GetINIFileLocation(), header, "CryConversionTable", "")), System.Globalization.NumberStyles.HexNumber)
convIndex = Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ((offset)) + ((index - 276) * 2), 2))), System.Globalization.NumberStyles.HexNumber)
End If
Dim someValue = Int32.Parse(ReverseHEX((ReadHEX(LoadedROM, (cryTable) + (index * 12), 4))), System.Globalization.NumberStyles.HexNumber)
Dim cryOffset = (Int32.Parse(ReverseHEX((ReadHEX(LoadedROM, (cryTable) + (index * 12) + 4, 4))), System.Globalization.NumberStyles.HexNumber) - &H8000000)
@ -56,14 +50,7 @@ Module CryFunctions
'ledrom.Seek(cryOffset)
CryToLoad.Offset = cryOffset
If convIndex <> -1 Then
someValue = Int32.Parse(ReverseHEX((ReadHEX(LoadedROM, (cryTable) + (convIndex * 12), 4))), System.Globalization.NumberStyles.HexNumber)
cryOffset = (Int32.Parse(ReverseHEX((ReadHEX(LoadedROM, (cryTable) + (convIndex * 12) + 4, 4))), System.Globalization.NumberStyles.HexNumber) - &H8000000)
cryShape = Int32.Parse(ReverseHEX((ReadHEX(LoadedROM, (cryTable) + (convIndex * 12) + 8, 4))), System.Globalization.NumberStyles.HexNumber)
CryToLoad.Offset = cryOffset
End If
CryToLoad.Index = index
'CryToLoad.Compressed = ledrom.ReadUInt16() = &H1
@ -81,22 +68,14 @@ Module CryFunctions
If Not CryToLoad.Compressed Then
' uncompressed, 1 sample per 1 byte of size
CryToLoad.Data = New SByte(CryToLoad.Size - 1) {}
For g As Integer = 0 To CryToLoad.Size - 1
Dim cryToLoadTemp As String = ReadHEX(LoadedROM, (cryOffset) + 16, CryToLoad.Size - 1)
For g As Integer = 0 To CryToLoad.Size - 2
CryToLoad.Data(g) = ByteToSignedInt("&H" & cryToLoadTemp.Substring(g * 2, 2))
CryToLoad.Data(g) = ByteToSignedInt("&H" & (ReadHEX(LoadedROM, (cryOffset) + 16 + g, 1)))
Next
'For g As Integer = 0 To CryToLoad.Size - 1
' CryToLoad.Data(g) = ByteToSignedInt("&H" & (ReadHEX(LoadedROM, (cryOffset) + 16 + g, 1)))
'Next
Else
' compressed, a bit of a hassle
Dim lookup = New SByte() {0, 1, 4, 9, 16, 25,
36, 49, -64, -49, -36, -25,
Dim lookup = New SByte() {0, 1, 4, 9, 16, 25, _
36, 49, -64, -49, -36, -25, _
-16, -9, -4, -1}
Dim start = (cryOffset) + 16
@ -106,47 +85,29 @@ Module CryFunctions
Dim pcmLevel As SByte = 0
Dim data = New List(Of SByte)()
Dim cryData As String = (ReadHEX(LoadedROM, offtrack, CryToLoad.Size))
offtrack = 0
While True
If alignment = 0 Then
pcmLevel = ByteToSignedInt("&H" & cryData.Substring(offtrack, 2)) '(ReadHEX(LoadedROM, offtrack, 1)))
offtrack = offtrack + 2 '1
pcmLevel = ByteToSignedInt("&H" & (ReadHEX(LoadedROM, offtrack, 1)))
offtrack = offtrack + 1
data.Add(pcmLevel)
alignment = &H20
End If
Dim input As Byte = ("&H" & cryData.Substring(offtrack, 2)) '(ReadHEX(LoadedROM, offtrack, 1)))
offtrack = offtrack + 2 '1
Dim input As Byte = ("&H" & (ReadHEX(LoadedROM, offtrack, 1)))
offtrack = offtrack + 1
If alignment < &H20 Then
' first nybble
Try
pcmLevel += lookup(input >> 4)
Catch
If pcmLevel < 0 And lookup(input >> 4) < 0 Then
pcmLevel = -128
Else
pcmLevel = 127
End If
End Try
pcmLevel += lookup(input >> 4)
data.Add(pcmLevel)
End If
' second nybble
Try
pcmLevel += lookup(input And &HF)
Catch
If pcmLevel < 0 And lookup(input And &HF) < 0 Then
pcmLevel = -128
Else
pcmLevel = 127
End If
End Try
pcmLevel += lookup(input And &HF)
data.Add(pcmLevel)
' exit when currentSize >= cry.Size
@ -160,7 +121,7 @@ Module CryFunctions
CryToLoad.Data = data.ToArray()
' bytes needed to recompress
CryToLoad.Size = offtrack / 2 'offtrack - start
CryToLoad.Size = offtrack - start
End If
Return CryToLoad
@ -238,7 +199,7 @@ Module CryFunctions
Public Sub ExportCry(filename As String, cry As Cry)
If cry.Offset = 0 Then
If Cry.Offset = 0 Then
Return
End If
@ -261,10 +222,10 @@ Module CryFunctions
' format: 1 = wave_format_pcm
writer.Write(CUShort(1))
' channel count
writer.Write(cry.SampleRate)
writer.Write(Cry.SampleRate)
' sample rate
' * 1 * 8 / 8
writer.Write(cry.SampleRate)
writer.Write(Cry.SampleRate)
' SampleRate * NumChannels * BitsPerSample/8
' * 8 / 8
writer.Write(CUShort(1))
@ -274,7 +235,7 @@ Module CryFunctions
' data chunk
writer.Write(Encoding.ASCII.GetBytes("data"))
' chunk ID
writer.Write(cry.Data.Length)
writer.Write(Cry.Data.Length)
' chunk size
For Each sample As SByte In cry.Data
writer.Write(CByte(sample + &H80))
@ -288,7 +249,7 @@ Module CryFunctions
Public Function ImportCry(filename As String, CryToLoad As Cry) As Cry
'If Cry.Offset = 0 Then
'If Cry.Offset = 0 Then
' Return
'End If
@ -359,8 +320,8 @@ Module CryFunctions
Return False
End If
'var lookup = new byte[] { 0x0, 0x1, 0x4, 0x9, 0x10, 0x19, 0x24, 0x31, 0xC0, 0xCF, 0xDC, 0xE7, 0xF0, 0xF7, 0xFC, 0xFF };
Dim lookup = New SByte() {0, 1, 4, 9, 16, 25,
36, 49, -64, -49, -36, -25,
Dim lookup = New SByte() {0, 1, 4, 9, 16, 25, _
36, 49, -64, -49, -36, -25, _
-16, -9, -4, -1}
crytosave.Compressed = False
@ -558,173 +519,4 @@ Module CryFunctions
Return True
End Function
Public Function SaveCryNoPrompt(crytosave As Cry, cryTable As Integer, growlTable As Integer) As Boolean
'If crytosave.Offset = 0 Then
'Return False
'End If
'var lookup = new byte[] { 0x0, 0x1, 0x4, 0x9, 0x10, 0x19, 0x24, 0x31, 0xC0, 0xCF, 0xDC, 0xE7, 0xF0, 0xF7, 0xFC, 0xFF };
Dim lookup = New SByte() {0, 1, 4, 9, 16, 25,
36, 49, -64, -49, -36, -25,
-16, -9, -4, -1}
crytosave.Compressed = False
' copy cry data to be written
Dim data = New List(Of Byte)()
'If crytosave.Compressed Then
If 0 Then
'MsgBox("This should not be enabled!")
'End
' data is compressed in blocks of 1 + 0x20 bytes at a time
' first byte is normal signed PCM data
' following 0x20 bytes are compressed based on previous value
' (for a value not in lookup table, closest value will be chosen instead)
'Console.WriteLine("compressed");
' each block has 0x40 samples
Dim blockCount = crytosave.Data.Length / &H40
If crytosave.Data.Length Mod &H40 > 0 Then
blockCount += 1
End If
' truncates the length of the last block
' so we don't waste space
Dim lastBlockSize = crytosave.Data.Length - crytosave.Data.Length / &H40 * &H40
If lastBlockSize = 0 Then
lastBlockSize = &H21
Else
lastBlockSize = 1 + (lastBlockSize / 2) + (If(lastBlockSize Mod 2 = 0, 0, 1))
End If
Dim blocks = New Byte(blockCount - 1)() {}
For n As Integer = 0 To blockCount - 1
' create new block
If n < blockCount - 1 Then
blocks(n) = New Byte(32) {}
Else
blocks(n) = New Byte(lastBlockSize - 1) {} ' - Not "- 1"
End If
Dim i As Integer = n * &H40
Dim k As Integer = 0
If i < crytosave.Data.Length Then
' set first value
blocks(n)(k) = BitConverter.GetBytes(crytosave.Data(i))(0)
End If
k = k + 1
Dim pcm As SByte
If i < crytosave.Data.Length Then
pcm = crytosave.Data(i)
End If
i = i + 1
Dim j As Integer = 1
While j < &H40 And i < crytosave.Data.Length
' get current sample
Dim sample As SByte = crytosave.Data(i)
i = i + 1
' difference between previous sample and this
Dim diff As Integer = sample - pcm
' check for a perfect match in lookup table
Dim lookupI = -1
For x As Integer = 0 To 15
If lookup(x) = diff Then
lookupI = x
Exit For
End If
Next
' search for the closest match in the table
If lookupI = -1 Then
Dim bestDiff As Integer = 255
For x As Integer = 0 To 15
If Math.Abs(CInt(lookup(x)) - diff) < bestDiff Then
lookupI = x
bestDiff = Math.Abs(lookup(x) - diff)
End If
Next
End If
' set value in block
' on an odd value, increase position in block
If j Mod 2 = 0 Then
blocks(n)(k) = blocks(n)(k) Or CByte(lookupI << 4)
Else
blocks(n)(k) = blocks(n)(k) Or CByte(lookupI)
k = k + 1
End If
' set previous
pcm = sample
j += 1
End While
Next
For n As Integer = 0 To blockCount - 1
data.AddRange(blocks(n))
Next
Else
' uncompressed, copy directly to data
'Console.WriteLine("uncompressed");
For Each s As SByte In crytosave.Data
data.Add(CByte(s And &HFF))
Next
End If
' set new cry offset
crytosave.Offset = SearchFreeSpaceFourAligned(LoadedROM, &HFF, data.Count, "&H" & GetString(GetINIFileLocation(), header, "StartSearchingForSpaceOffset", "800000"))
' write cry
WriteHEX(LoadedROM, crytosave.Offset, ReverseHEX(VB.Right("0000" & CUShort(If(crytosave.Compressed, 1, 0)), 4)))
WriteHEX(LoadedROM, crytosave.Offset + 2, ReverseHEX(VB.Right("0000" & CUShort(If(crytosave.Looped, &H4000, 0)), 4)))
WriteHEX(LoadedROM, crytosave.Offset + 4, ReverseHEX(VB.Right("00000000" & Hex(crytosave.SampleRate << 10), 8)))
WriteHEX(LoadedROM, crytosave.Offset + 8, ReverseHEX(VB.Right("00000000" & Hex(crytosave.LoopStart), 8)))
WriteHEX(LoadedROM, crytosave.Offset + 12, ReverseHEX(VB.Right("00000000" & Hex(crytosave.Data.Length - 2), 8)))
Dim tempbuff As String = ByteArrayToHexString(data.ToArray)
WriteHEX(LoadedROM, crytosave.Offset + 16, tempbuff)
' write cry table entry
WriteHEX(LoadedROM, cryTable + (crytosave.Index * 12), ReverseHEX(If(crytosave.Compressed, "00003C20", "00003C00")))
WriteHEX(LoadedROM, cryTable + (crytosave.Index * 12) + 4, ReverseHEX(VB.Right("00000000" & Hex(crytosave.Offset + &H8000000), 8)))
WriteHEX(LoadedROM, cryTable + (crytosave.Index * 12) + 8, "FF00FF")
WriteHEX(LoadedROM, growlTable + (crytosave.Index * 12), ReverseHEX(If(crytosave.Compressed, "00003C30", "00003C00")))
WriteHEX(LoadedROM, growlTable + (crytosave.Index * 12) + 4, ReverseHEX(VB.Right("00000000" & Hex(crytosave.Offset + &H8000000), 8)))
WriteHEX(LoadedROM, growlTable + (crytosave.Index * 12) + 8, "FF00FF")
If crytosave.Index > 276 Then
Dim offset As Integer = Int32.Parse((GetString(GetINIFileLocation(), header, "CryConversionTable", "")), System.Globalization.NumberStyles.HexNumber)
WriteHEX(LoadedROM, ((offset)) + ((crytosave.Index - 277) * 2), ReverseHEX(VB.Right("0000" & Hex(crytosave.Index), 4)))
End If
Return True
End Function
End Module

View File

@ -225,12 +225,7 @@ Partial Class Pokemonedit
Me.Label25 = New System.Windows.Forms.Label()
Me.GroupBox2 = New System.Windows.Forms.GroupBox()
Me.Clr1 = New System.Windows.Forms.ComboBox()
<<<<<<< HEAD
Me.TabPage6 = New System.Windows.Forms.TabPage()
=======
Me.TabPage5 = New System.Windows.Forms.TabPage()
Me.Button43 = New System.Windows.Forms.Button()
>>>>>>> update-cry-imp-exp
Me.GroupBox35 = New System.Windows.Forms.GroupBox()
Me.Button35 = New System.Windows.Forms.Button()
Me.Button36 = New System.Windows.Forms.Button()
@ -363,10 +358,7 @@ Partial Class Pokemonedit
Me.TabControl1.Controls.Add(Me.TabPage3)
Me.TabControl1.Controls.Add(Me.TabPage4)
Me.TabControl1.Controls.Add(Me.TabPage5)
<<<<<<< HEAD
Me.TabControl1.Controls.Add(Me.TabPage6)
=======
>>>>>>> update-cry-imp-exp
Me.TabControl1.Location = New System.Drawing.Point(222, 41)
Me.TabControl1.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)
Me.TabControl1.Name = "TabControl1"
@ -2026,7 +2018,6 @@ Partial Class Pokemonedit
'
'TabPage5
'
<<<<<<< HEAD
Me.TabPage5.Controls.Add(Me.GroupBox31)
Me.TabPage5.Controls.Add(Me.GroupBox32)
Me.TabPage5.Controls.Add(Me.GroupBox30)
@ -2040,21 +2031,6 @@ Partial Class Pokemonedit
Me.TabPage5.TabIndex = 5
Me.TabPage5.Text = "Pokedex"
Me.TabPage5.UseVisualStyleBackColor = True
=======
Me.TabPage6.Controls.Add(Me.GroupBox31)
Me.TabPage6.Controls.Add(Me.GroupBox32)
Me.TabPage6.Controls.Add(Me.GroupBox30)
Me.TabPage6.Controls.Add(Me.GroupBox29)
Me.TabPage6.Controls.Add(Me.GroupBox28)
Me.TabPage6.Controls.Add(Me.GroupBox2)
Me.TabPage6.Location = New System.Drawing.Point(4, 29)
Me.TabPage6.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)
Me.TabPage6.Name = "TabPage6"
Me.TabPage6.Size = New System.Drawing.Size(925, 736)
Me.TabPage6.TabIndex = 5
Me.TabPage6.Text = "Pokedex"
Me.TabPage6.UseVisualStyleBackColor = True
>>>>>>> update-cry-imp-exp
'
'GroupBox31
'
@ -2567,7 +2543,6 @@ Partial Class Pokemonedit
'
'TabPage6
'
<<<<<<< HEAD
Me.TabPage6.Controls.Add(Me.GroupBox35)
Me.TabPage6.Controls.Add(Me.GroupBox34)
Me.TabPage6.Controls.Add(Me.GroupBox21)
@ -2579,30 +2554,6 @@ Partial Class Pokemonedit
Me.TabPage6.TabIndex = 6
Me.TabPage6.Text = "Cry Data"
Me.TabPage6.UseVisualStyleBackColor = True
=======
Me.TabPage5.Controls.Add(Me.Button43)
Me.TabPage5.Controls.Add(Me.GroupBox35)
Me.TabPage5.Controls.Add(Me.GroupBox34)
Me.TabPage5.Controls.Add(Me.GroupBox21)
Me.TabPage5.Location = New System.Drawing.Point(4, 29)
Me.TabPage5.Margin = New System.Windows.Forms.Padding(3, 4, 3, 4)
Me.TabPage5.Name = "TabPage5"
Me.TabPage5.Padding = New System.Windows.Forms.Padding(3, 4, 3, 4)
Me.TabPage5.Size = New System.Drawing.Size(925, 736)
Me.TabPage5.TabIndex = 6
Me.TabPage5.Text = "Cry Data"
Me.TabPage5.UseVisualStyleBackColor = True
>>>>>>> update-cry-imp-exp
'
'Button43
'
Me.Button43.Location = New System.Drawing.Point(19, 682)
Me.Button43.Margin = New System.Windows.Forms.Padding(3, 4, 3, 4)
Me.Button43.Name = "Button43"
Me.Button43.Size = New System.Drawing.Size(237, 41)
Me.Button43.TabIndex = 30
Me.Button43.Text = "Import and Repoint All"
Me.Button43.UseVisualStyleBackColor = True
'
'GroupBox35
'
@ -2789,10 +2740,7 @@ Partial Class Pokemonedit
'
'Button33
'
<<<<<<< HEAD
Me.Button33.Enabled = False
=======
>>>>>>> update-cry-imp-exp
Me.Button33.Location = New System.Drawing.Point(336, 264)
Me.Button33.Margin = New System.Windows.Forms.Padding(3, 4, 3, 4)
Me.Button33.Name = "Button33"
@ -3565,5 +3513,4 @@ Partial Class Pokemonedit
Friend WithEvents Label59 As System.Windows.Forms.Label
Friend WithEvents TextBox8 As System.Windows.Forms.TextBox
Friend WithEvents Label58 As System.Windows.Forms.Label
Friend WithEvents Button43 As Button
End Class

View File

@ -3943,46 +3943,49 @@ Public Class Pokemonedit
Me.Enabled = False
crynorm = ImportCry(fileOpenDialog.FileName, crynorm)
crynorm.Index += 1
Dim cryGood As Boolean = SaveCryNoPrompt(crynorm, CryTable, CryTable3)
If cryGood Then
SaveCry(crynorm, CryTable)
CryConver.Text = Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ((CryTable2)) + ((i - 276) * 2), 2))), System.Globalization.NumberStyles.HexNumber)
CryPointer.Text = Hex(Int32.Parse(ReverseHEX(ReadHEX(LoadedROM, ((CryTable) + (4)) + ((CryConver.Text) * 12), 4)), System.Globalization.NumberStyles.HexNumber) - &H8000000)
CryPointer2.Text = Hex(Int32.Parse(ReverseHEX(ReadHEX(LoadedROM, ((CryTable3) + (4)) + ((CryConver.Text) * 12), 4)), System.Globalization.NumberStyles.HexNumber) - &H8000000)
Me.Text = "Pokemon Editor"
Me.Enabled = True
End If
End Sub
'Label53.Text = "Sample Rate: " & ((Int32.Parse(((ReverseHEX(ReadHEX(LoadedROM, ("&H" & CryPointer.Text) + (4), 4)))), System.Globalization.NumberStyles.HexNumber)) >> 10) & " Hz"
'Label54.Text = "Sample Rate: " & ((Int32.Parse(((ReverseHEX(ReadHEX(LoadedROM, ("&H" & CryPointer2.Text) + (4), 4)))), System.Globalization.NumberStyles.HexNumber)) >> 10) & " Hz"
Private Sub Button38_Click(sender As Object, e As EventArgs) Handles Button38.Click
FolderBrowserDialog.Description = "Select folder to export all Cries to:"
crynorm = LoadCry(CryConver.Text, CryTable)
crygrowl = LoadCry(CryConver.Text, CryTable3)
If FolderBrowserDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
Me.Text = "Please wait..."
Me.UseWaitCursor = True
ProgressBar.Value = 0
ProgressBar.Visible = True
Label53.Text = "Sample Rate: " & crynorm.SampleRate & " Hz"
Label54.Text = "Sample Rate: " & crygrowl.SampleRate & " Hz"
If System.IO.Directory.Exists(FolderBrowserDialog.SelectedPath & "\Cries") = False Then
CreateDirectory(FolderBrowserDialog.SelectedPath & "\Cries")
End If
Dim LoopVar As Integer
Label55.Text = "Size: " & crynorm.Data.Length & " samples"
Label56.Text = "Size: " & crygrowl.Data.Length & " samples"
LoopVar = 0
Me.Enabled = False
While LoopVar < (GetString(GetINIFileLocation(), header, "NumberOfPokemon", "")) - 1 = True
PKMNames.SelectedIndex = LoopVar
chkCompressed1.Checked = crynorm.Compressed
chkCompressed2.Checked = crygrowl.Compressed
LoopVar = LoopVar + 1
pSample.Image = GetCryImage(crynorm)
pSample2.Image = GetCryImage(crygrowl)
ExportCry(FolderBrowserDialog.SelectedPath & "\Cries\" & LoopVar & ".wav", crynorm)
<<<<<<< HEAD
ProgressBar.Value = (LoopVar / (GetString(GetINIFileLocation(), header, "NumberOfPokemon", ""))) * 100
ProgressBar.Invalidate()
ProgressBar.Update()
End While
=======
End If
>>>>>>> update-cry-imp-exp
Me.Text = "Pokemon Editor"
Me.UseWaitCursor = False
Me.Enabled = True
ProgressBar.Visible = False
Me.BringToFront()
End If
End Sub
@ -4007,7 +4010,6 @@ Public Class Pokemonedit
End Sub
<<<<<<< HEAD
Private Sub TabChanged() Handles TabControl1.Selected
If (TabControl1.SelectedTab Is TabPage1 And Not Tab1LoadedMon = PKMNames.SelectedIndex + 1) Or
@ -4088,13 +4090,9 @@ Public Class Pokemonedit
Tab5LoadedMon = PKMNames.SelectedIndex + 1
End If
=======
Private Sub Button43_Click(sender As Object, e As EventArgs) Handles Button43.Click
FolderBrowserDialog.Description = "Select folder to import cries from:"
>>>>>>> update-cry-imp-exp
End Sub
<<<<<<< HEAD
Private Sub LoadUnloadedTabs()
'Me.Enabled = False
@ -4137,99 +4135,5 @@ Public Class Pokemonedit
Tab5LoadedMon = PKMNames.SelectedIndex + 1
'Me.Enabled = True
=======
If FolderBrowserDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
Me.Text = "Please wait..."
Me.UseWaitCursor = True
ProgressBar.Value = 0
ProgressBar.Visible = True
Dim LoopVar As Integer
LoopVar = 440
Me.Enabled = False
CryTable = Int32.Parse((GetString(GetINIFileLocation(), header, "CryTable", "")), System.Globalization.NumberStyles.HexNumber)
'CryTable2 = Int32.Parse((GetString(GetINIFileLocation(), header, "CryConversionTable", "")), System.Globalization.NumberStyles.HexNumber)
CryTable3 = Int32.Parse((GetString(GetINIFileLocation(), header, "CryTable2", "")), System.Globalization.NumberStyles.HexNumber)
While LoopVar < (GetString(GetINIFileLocation(), header, "NumberOfPokemon", "")) - 1 And 439 < LoopVar And 861 > LoopVar = True
'PKMNames.SelectedIndex = LoopVar
Dim convNum As Integer = LoopVar - 53
Dim validFiles As String() = GetFiles(FolderBrowserDialog.SelectedPath, "*" & convNum & "*")
If validFiles.Count > 0 Then
crynorm = New Cry With {
.Index = LoopVar
}
crynorm = ImportCry(validFiles(0), crynorm)
SaveCryNoPrompt(crynorm, CryTable, CryTable3)
End If
LoopVar = LoopVar + 1
ProgressBar.Value = (LoopVar / (GetString(GetINIFileLocation(), header, "NumberOfPokemon", ""))) * 100
ProgressBar.Invalidate()
ProgressBar.Update()
'Me.Refresh()
End While
LoopVar = 880
While LoopVar < (GetString(GetINIFileLocation(), header, "NumberOfPokemon", "")) - 1 And 439 < LoopVar = True
Dim validFiles As String() = GetFiles(FolderBrowserDialog.SelectedPath, "*" & LoopVar & "*")
If validFiles.Count > 0 Then
crynorm = New Cry With {
.Index = LoopVar
}
crynorm = ImportCry(validFiles(0), crynorm)
SaveCryNoPrompt(crynorm, CryTable, CryTable3)
End If
LoopVar = LoopVar + 1
ProgressBar.Value = (LoopVar / (GetString(GetINIFileLocation(), header, "NumberOfPokemon", ""))) * 100
ProgressBar.Invalidate()
ProgressBar.Update()
End While
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim convMons As New List(Of String)
convMons.AddRange(IO.File.ReadLines(FolderBrowserDialog.SelectedPath & "\Conversions.txt"))
Dim MonArray As List(Of String()) = New List(Of String())
For Each mon As String In convMons
MonArray.Add(mon.Split(New String() {"="}, StringSplitOptions.None))
Next
Dim offset As Integer = Int32.Parse((GetString(GetINIFileLocation(), header, "CryConversionTable", "")), System.Globalization.NumberStyles.HexNumber)
For Each mon As String() In MonArray
If mon.Count > 1 Then
If mon(1) < 277 Then
WriteHEX(LoadedROM, ((offset)) + ((Int32.Parse(mon(0)) - 277) * 2), ReverseHEX(VB.Right("0000" & Hex(Int32.Parse(mon(1) - 1)), 4)))
Else
WriteHEX(LoadedROM, ((offset)) + ((Int32.Parse(mon(0)) - 277) * 2), ReverseHEX(VB.Right("0000" & Hex(Int32.Parse(mon(1))), 4)))
End If
End If
Next
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
PKMNames.SelectedIndex = 0
Me.Text = "Pokemon Editor"
Me.UseWaitCursor = False
Me.Enabled = True
ProgressBar.Visible = False
Me.BringToFront()
End If
>>>>>>> update-cry-imp-exp
End Sub
End Class