Adding cry functions.

Started adding cry functions from
https://github.com/doom-desire/Cry-Editor
This commit is contained in:
Gamer2020
2016-08-20 17:40:35 -05:00
parent 2f61d6ae32
commit e27537e575
21 changed files with 1552 additions and 597 deletions

Binary file not shown.

View File

@@ -0,0 +1,116 @@

'These functions are based off the ones found in this project: https://github.com/doom-desire/Cry-Editor
'Credit goes to doom-desire for these functions.
Module CryFunctions
Structure Cry
Public Index As Integer
Public Offset As Integer
Public Compressed As Boolean
Public Looped As Boolean
Public SampleRate As Integer
Public LoopStart As Integer
Public Size As Integer
Public Data As SByte()
End Structure
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 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)
Dim cryShape = Int32.Parse(ReverseHEX((ReadHEX(LoadedROM, (cryTable) + (index * 12) + 8, 4))), System.Globalization.NumberStyles.HexNumber)
'If cryOffset = 0 Then
' Return False
'End If
' load cry data
'ledrom.Seek(cryOffset)
CryToLoad.Offset = cryOffset
CryToLoad.Index = index
'CryToLoad.Compressed = ledrom.ReadUInt16() = &H1
'CryToLoad.Looped = ledrom.ReadUInt16() = &H4000
'CryToLoad.SampleRate = ledrom.ReadInt32() >> 10
'CryToLoad.LoopStart = ledrom.ReadInt32()
'CryToLoad.Size = ledrom.ReadInt32() + 1
CryToLoad.Compressed = Int16.Parse(ReverseHEX((ReadHEX(LoadedROM, (cryOffset) + 0, 2))), System.Globalization.NumberStyles.HexNumber) = &H1
CryToLoad.Looped = Int16.Parse(ReverseHEX((ReadHEX(LoadedROM, (cryOffset) + 2, 2))), System.Globalization.NumberStyles.HexNumber) = &H4000
CryToLoad.SampleRate = Int32.Parse(ReverseHEX((ReadHEX(LoadedROM, (cryOffset) + 4, 4))), System.Globalization.NumberStyles.HexNumber) >> 10
CryToLoad.LoopStart = Int32.Parse(ReverseHEX((ReadHEX(LoadedROM, (cryOffset) + 8, 4))), System.Globalization.NumberStyles.HexNumber)
CryToLoad.Size = Int32.Parse(ReverseHEX((ReadHEX(LoadedROM, (cryOffset) + 12, 4))), System.Globalization.NumberStyles.HexNumber) + 1
'If Not CryToLoad.Compressed Then
' ' uncompressed, 1 sample per 1 byte of size
' CryToLoad.Data = New SByte(CryToLoad.Size - 1) {}
' For i As Integer = 0 To CryToLoad.Size - 1
' CryToLoad.Data(i) = ledrom.ReadSByte()
' Next
'Else
' ' compressed, a bit of a hassle
' Dim lookup = New SByte() {0, 1, 4, 9, 16, 25, _
' 36, 49, -64, -49, -36, -25, _
' -16, -9, -4, -1}
' Dim start = ledrom.Position
' Dim alignment As Integer = 0, size As Integer = 0
' Dim pcmLevel As SByte = 0
' Dim data = New List(Of SByte)()
' While True
' If alignment = 0 Then
' pcmLevel = ledrom.ReadSByte()
' data.Add(pcmLevel)
' alignment = &H20
' End If
' Dim input = ledrom.ReadByte()
' If alignment < &H20 Then
' ' first nybble
' pcmLevel += lookup(input >> 4)
' data.Add(pcmLevel)
' End If
' ' second nybble
' pcmLevel += lookup(input And &HF)
' data.Add(pcmLevel)
' ' exit when currentSize >= cry.Size
' size += 2
' If size >= CryToLoad.Size Then
' Exit While
' End If
' alignment -= 1
' End While
' CryToLoad.Data = data.ToArray()
' ' bytes needed to recompress
' CryToLoad.Size = ledrom.Position - start
'End If
Return CryToLoad
End Function
End Module

View File

@@ -161,6 +161,7 @@
</Compile>
<Compile Include="ChangeImageFunctions.vb" />
<Compile Include="ChangeNameFunctions.vb" />
<Compile Include="CryFunctions.vb" />
<Compile Include="EggMoveEditor.Designer.vb">
<DependentUpon>EggMoveEditor.vb</DependentUpon>
</Compile>
@@ -254,6 +255,7 @@
<Compile Include="Pokemonedit.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="ROM.vb" />
<Compile Include="RomExpander.Designer.vb">
<DependentUpon>RomExpander.vb</DependentUpon>
</Compile>

File diff suppressed because one or more lines are too long

View File

@@ -6,6 +6,7 @@ Imports System.Net
Imports VB = Microsoft.VisualBasic
Public Class Pokemonedit
Dim baseoff As Integer
Dim FrontSpritePointers As Integer
Dim BackSpritePointers As Integer
@@ -36,6 +37,8 @@ Public Class Pokemonedit
Private Sub Pokemonedit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' ledrom = New ROM(LoadedROM)
Type1.Items.Clear()
Type2.Items.Clear()
@@ -655,6 +658,10 @@ Public Class Pokemonedit
'cry stuff with conversion table support
If (i + 1) < 252 Then
GroupBox21.Enabled = True
GroupBox34.Enabled = True
GroupBox35.Enabled = True
CryPointer.Text = Hex(Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, (CryTable) + (4) + (i * 12), 4))), System.Globalization.NumberStyles.HexNumber) - &H8000000)
CryConver.Text = ""
CryPointer2.Text = Hex(Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, (CryTable3) + (4) + (i * 12), 4))), System.Globalization.NumberStyles.HexNumber) - &H8000000)
@@ -662,11 +669,31 @@ Public Class Pokemonedit
CryComp1.Text = Hex(Int32.Parse(((ReadHEX(LoadedROM, (CryTable) + (i * 12), 1))), System.Globalization.NumberStyles.HexNumber))
CryComp2.Text = Hex(Int32.Parse(((ReadHEX(LoadedROM, (CryTable3) + (i * 12), 1))), System.Globalization.NumberStyles.HexNumber))
crynorm = LoadCry(i, CryTable)
crygrowl = LoadCry(i, CryTable3)
Label53.Text = "Sample Rate: " & crynorm.SampleRate & " Hz"
Label54.Text = "Sample Rate: " & crygrowl.SampleRate & " Hz"
Label55.Text = "Size: " & crynorm.Size & " samples"
Label56.Text = "Size: " & crygrowl.Size & " samples"
'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"
'Label55.Text = "Size: " & ((Int32.Parse(((ReverseHEX(ReadHEX(LoadedROM, ("&H" & CryPointer.Text) + (12), 4)))), System.Globalization.NumberStyles.HexNumber)) + 1) & " samples"
'Label56.Text = "Size: " & ((Int32.Parse(((ReverseHEX(ReadHEX(LoadedROM, ("&H" & CryPointer2.Text) + (12), 4)))), System.Globalization.NumberStyles.HexNumber)) + 1) & " samples"
CryConver.Enabled = False
Button13.Enabled = False
ElseIf (i + 1) > 251 And (i + 1) <= 276 Then
GroupBox21.Enabled = False
GroupBox34.Enabled = False
GroupBox35.Enabled = False
CryPointer.Text = ""
CryPointer2.Text = ""
CryConver.Text = ""
@@ -674,6 +701,12 @@ Public Class Pokemonedit
CryComp1.Text = ""
CryComp2.Text = ""
Label53.Text = "Sample Rate: " & 0 & " Hz"
Label54.Text = "Sample Rate: " & 0 & " Hz"
Label55.Text = "Size: 0 samples"
Label56.Text = "Size: 0 samples"
End If
@@ -681,6 +714,8 @@ Public Class Pokemonedit
GroupBox21.Enabled = True
CryConver.Enabled = True
Button13.Enabled = True
GroupBox34.Enabled = True
GroupBox35.Enabled = True
' MsgBox((CryTable2) + ((i - 276) * 2))
CryConver.Text = Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ((CryTable2)) + ((i - 276) * 2), 2))), System.Globalization.NumberStyles.HexNumber)
@@ -689,8 +724,15 @@ Public Class Pokemonedit
CryPointer2.Text = Hex(Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ((CryTable3) + (4)) + ((CryConver.Text) * 12), 4))), System.Globalization.NumberStyles.HexNumber) - &H8000000)
CryComp1.Text = Hex(Int32.Parse(((ReadHEX(LoadedROM, ((CryTable)) + ((CryConver.Text) * 12), 1))), System.Globalization.NumberStyles.HexNumber))
CryComp2.Text = Hex(Int32.Parse(((ReadHEX(LoadedROM, ((CryTable3)) + ((CryConver.Text) * 12), 1))), System.Globalization.NumberStyles.HexNumber))
crynorm = LoadCry(CryConver.Text, CryTable)
crygrowl = LoadCry(CryConver.Text, CryTable3)
Label53.Text = "Sample Rate: " & crynorm.SampleRate & " Hz"
Label54.Text = "Sample Rate: " & crygrowl.SampleRate & " Hz"
Label55.Text = "Size: " & crynorm.Size & " samples"
Label56.Text = "Size: " & crygrowl.Size & " samples"
End If
@@ -991,7 +1033,7 @@ Public Class Pokemonedit
End If
End Sub
Private Sub EvoPKMNames_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EvoPKMNames.SelectedIndexChanged
@@ -1704,10 +1746,20 @@ Public Class Pokemonedit
If (i + 1) < 252 Then
WriteHEX(LoadedROM, (CryTable) + (4) + (i * 12), ReverseHEX(Hex(Int32.Parse(((CryPointer.Text)), System.Globalization.NumberStyles.HexNumber) + &H8000000)))
WriteHEX(LoadedROM, (CryTable3) + (4) + (i * 12), ReverseHEX(Hex(Int32.Parse(((CryPointer2.Text)), System.Globalization.NumberStyles.HexNumber) + &H8000000)))
' WriteHEX(LoadedROM, (CryTable3) + (4) + (i * 12), ReverseHEX(Hex(Int32.Parse(((CryPointer2.Text)), System.Globalization.NumberStyles.HexNumber) + &H8000000)))
WriteHEX(LoadedROM, (CryTable) + (i * 12), (Hex(Int32.Parse(((CryComp1.Text)), System.Globalization.NumberStyles.HexNumber))))
WriteHEX(LoadedROM, (CryTable3) + (i * 12), (Hex(Int32.Parse(((CryComp2.Text)), System.Globalization.NumberStyles.HexNumber))))
'WriteHEX(LoadedROM, (CryTable3) + (i * 12), (Hex(Int32.Parse(((CryComp2.Text)), System.Globalization.NumberStyles.HexNumber))))
crynorm = LoadCry(i, CryTable)
crygrowl = LoadCry(i, CryTable3)
Label53.Text = "Sample Rate: " & crynorm.SampleRate & " Hz"
Label54.Text = "Sample Rate: " & crygrowl.SampleRate & " Hz"
Label55.Text = "Size: " & crynorm.Size & " samples"
Label56.Text = "Size: " & crygrowl.Size & " samples"
ElseIf (i + 1) > 251 And (i + 1) < 276 Then
@@ -1715,10 +1767,20 @@ Public Class Pokemonedit
ElseIf (i + 1) > 276 Then
WriteHEX(LoadedROM, (CryTable) + (4) + (((Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ((CryTable2)) + ((i - 276) * 2), 2))), System.Globalization.NumberStyles.HexNumber))) * 12), ReverseHEX(Hex(Int32.Parse(((CryPointer.Text)), System.Globalization.NumberStyles.HexNumber) + &H8000000)))
WriteHEX(LoadedROM, (CryTable3) + (4) + (((Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ((CryTable2)) + ((i - 276) * 2), 2))), System.Globalization.NumberStyles.HexNumber))) * 12), ReverseHEX(Hex(Int32.Parse(((CryPointer2.Text)), System.Globalization.NumberStyles.HexNumber) + &H8000000)))
' WriteHEX(LoadedROM, (CryTable3) + (4) + (((Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ((CryTable2)) + ((i - 276) * 2), 2))), System.Globalization.NumberStyles.HexNumber))) * 12), ReverseHEX(Hex(Int32.Parse(((CryPointer2.Text)), System.Globalization.NumberStyles.HexNumber) + &H8000000)))
WriteHEX(LoadedROM, (CryTable) + (((Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ((CryTable2)) + ((i - 276) * 2), 2))), System.Globalization.NumberStyles.HexNumber))) * 12), (Hex(Int32.Parse(((CryComp1.Text)), System.Globalization.NumberStyles.HexNumber))))
WriteHEX(LoadedROM, (CryTable3) + (((Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ((CryTable2)) + ((i - 276) * 2), 2))), System.Globalization.NumberStyles.HexNumber))) * 12), (Hex(Int32.Parse(((CryComp2.Text)), System.Globalization.NumberStyles.HexNumber))))
'WriteHEX(LoadedROM, (CryTable3) + (((Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ((CryTable2)) + ((i - 276) * 2), 2))), System.Globalization.NumberStyles.HexNumber))) * 12), (Hex(Int32.Parse(((CryComp2.Text)), System.Globalization.NumberStyles.HexNumber))))
crynorm = LoadCry(((Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ((CryTable2)) + ((i - 276) * 2), 2))), System.Globalization.NumberStyles.HexNumber))), CryTable)
crygrowl = LoadCry(((Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ((CryTable2)) + ((i - 276) * 2), 2))), System.Globalization.NumberStyles.HexNumber))), CryTable3)
Label53.Text = "Sample Rate: " & crynorm.SampleRate & " Hz"
Label54.Text = "Sample Rate: " & crygrowl.SampleRate & " Hz"
Label55.Text = "Size: " & crynorm.Size & " samples"
Label56.Text = "Size: " & crygrowl.Size & " samples"
End If
End Sub
@@ -2040,10 +2102,24 @@ Public Class Pokemonedit
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)
'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"
crynorm = LoadCry(CryConver.Text, CryTable)
crygrowl = LoadCry(CryConver.Text, CryTable3)
Label53.Text = "Sample Rate: " & crynorm.SampleRate & " Hz"
Label54.Text = "Sample Rate: " & crygrowl.SampleRate & " Hz"
Label55.Text = "Size: " & crynorm.Size & " samples"
Label56.Text = "Size: " & crygrowl.Size & " samples"
End If
End Sub
Private Sub CryPointer_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CryPointer.TextChanged
Private Sub CryPointer_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
@@ -2340,9 +2416,9 @@ Public Class Pokemonedit
Else
GroupBox32.Enabled = False
GroupBox29.Enabled = False
GroupBox31.Enabled = False
GroupBox30.Enabled = False
GroupBox29.Enabled = False
GroupBox31.Enabled = False
GroupBox30.Enabled = False
End If
@@ -2456,9 +2532,9 @@ Public Class Pokemonedit
End If
RSEDexPoke.Location = PokePoint
RSEDexPoke.SizeMode = PictureBoxSizeMode.StretchImage
RSEDexPoke.SizeMode = PictureBoxSizeMode.StretchImage
End If
End If
End Sub
@@ -3544,4 +3620,51 @@ Public Class Pokemonedit
End If
End Sub
Private Sub Button31_Click(sender As Object, e As EventArgs) Handles Button31.Click
i = PKMNames.SelectedIndex
If (i + 1) < 252 Then
'WriteHEX(LoadedROM, (CryTable) + (4) + (i * 12), ReverseHEX(Hex(Int32.Parse(((CryPointer.Text)), System.Globalization.NumberStyles.HexNumber) + &H8000000)))
WriteHEX(LoadedROM, (CryTable3) + (4) + (i * 12), ReverseHEX(Hex(Int32.Parse(((CryPointer2.Text)), System.Globalization.NumberStyles.HexNumber) + &H8000000)))
'WriteHEX(LoadedROM, (CryTable) + (i * 12), (Hex(Int32.Parse(((CryComp1.Text)), System.Globalization.NumberStyles.HexNumber))))
WriteHEX(LoadedROM, (CryTable3) + (i * 12), (Hex(Int32.Parse(((CryComp2.Text)), System.Globalization.NumberStyles.HexNumber))))
crynorm = LoadCry(i, CryTable)
crygrowl = LoadCry(i, CryTable3)
Label53.Text = "Sample Rate: " & crynorm.SampleRate & " Hz"
Label54.Text = "Sample Rate: " & crygrowl.SampleRate & " Hz"
Label55.Text = "Size: " & crynorm.Size & " samples"
Label56.Text = "Size: " & crygrowl.Size & " samples"
ElseIf (i + 1) > 251 And (i + 1) < 276 Then
MsgBox("This shoudln't be enabled! report it!")
ElseIf (i + 1) > 276 Then
'WriteHEX(LoadedROM, (CryTable) + (4) + (((Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ((CryTable2)) + ((i - 276) * 2), 2))), System.Globalization.NumberStyles.HexNumber))) * 12), ReverseHEX(Hex(Int32.Parse(((CryPointer.Text)), System.Globalization.NumberStyles.HexNumber) + &H8000000)))
WriteHEX(LoadedROM, (CryTable3) + (4) + (((Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ((CryTable2)) + ((i - 276) * 2), 2))), System.Globalization.NumberStyles.HexNumber))) * 12), ReverseHEX(Hex(Int32.Parse(((CryPointer2.Text)), System.Globalization.NumberStyles.HexNumber) + &H8000000)))
'WriteHEX(LoadedROM, (CryTable) + (((Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ((CryTable2)) + ((i - 276) * 2), 2))), System.Globalization.NumberStyles.HexNumber))) * 12), (Hex(Int32.Parse(((CryComp1.Text)), System.Globalization.NumberStyles.HexNumber))))
WriteHEX(LoadedROM, (CryTable3) + (((Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ((CryTable2)) + ((i - 276) * 2), 2))), System.Globalization.NumberStyles.HexNumber))) * 12), (Hex(Int32.Parse(((CryComp2.Text)), System.Globalization.NumberStyles.HexNumber))))
crynorm = LoadCry(((Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ((CryTable2)) + ((i - 276) * 2), 2))), System.Globalization.NumberStyles.HexNumber))), CryTable)
crygrowl = LoadCry(((Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ((CryTable2)) + ((i - 276) * 2), 2))), System.Globalization.NumberStyles.HexNumber))), CryTable3)
Label53.Text = "Sample Rate: " & crynorm.SampleRate & " Hz"
Label54.Text = "Sample Rate: " & crygrowl.SampleRate & " Hz"
Label55.Text = "Size: " & crynorm.Size & " samples"
Label56.Text = "Size: " & crygrowl.Size & " samples"
End If
End Sub
End Class

340
GBAPokemonGameEditor/ROM.vb Normal file
View File

@@ -0,0 +1,340 @@
Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.IO
Imports System.Text
Public Class ROM
'Implements IDisposable
Private buffer As Byte()
Private pos As Integer = 0
Private m_filePath As String
Private fileWatcher As FileSystemWatcher
Private ignoreChange As Boolean
Private disposed As Boolean
Public Sub New(filePath As String)
Try
' read contents of file into buffer
Using fs = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
buffer = New Byte(fs.Length - 1) {}
fs.Read(buffer, 0, buffer.Length)
End Using
' create file watcher to monitor ROM being modified
fileWatcher = New FileSystemWatcher()
fileWatcher.Path = Path.GetDirectoryName(filePath)
fileWatcher.Filter = "*.gba"
AddHandler fileWatcher.Changed, AddressOf OnSourceFileChanged
AddHandler fileWatcher.Renamed, AddressOf OnSourceFileRenamed
fileWatcher.EnableRaisingEvents = True
Catch
Throw New Exception("Unable to open {filePath}!")
End Try
Me.m_filePath = filePath
End Sub
Protected Overrides Sub Finalize()
Try
Dispose()
Finally
MyBase.Finalize()
End Try
End Sub
Public Sub Dispose()
If disposed Then
Return
End If
disposed = True
fileWatcher.Dispose()
buffer = Nothing
End Sub
Public Sub Save()
If String.IsNullOrEmpty(m_filePath) Then
Return
End If
Using fs = File.Open(m_filePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite)
fs.Write(buffer, 0, buffer.Length)
End Using
ignoreChange = True
End Sub
Public Sub Seek(offset As Integer)
If offset < 0 OrElse offset > buffer.Length Then
Throw New IndexOutOfRangeException()
End If
pos = offset
End Sub
Public Sub Skip(bytes As Integer)
pos += bytes
If pos < 0 OrElse pos > buffer.Length Then
Throw New IndexOutOfRangeException()
End If
End Sub
#Region "Read"
Public Function ReadByte() As Byte
Return buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1))
End Function
Public Function PeekByte() As Byte
Return buffer(pos)
End Function
Public Function ReadSByte() As SByte
Return CSByte(ReadByte())
End Function
Public Function ReadUInt16() As UShort
Return CUShort(buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) Or (buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) << 8))
End Function
Public Function ReadInt32() As Integer
Return buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) Or (buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) << 8) Or (buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) << 16) Or (buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) << 24)
End Function
Public Function ReadUInt32() As UInteger
Return CUInt(buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) Or (buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) << 8) Or (buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) << 16) Or (buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) << 24))
End Function
Public Function ReadUInt64() As ULong
Return CULng(buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) Or (buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) << 8) Or (buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) << 16) Or (buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) << 24) Or (buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) << 32) Or (buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) << 40) Or (buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) << 48) Or (buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) << 56))
End Function
Public Function ReadBytes(count As Integer) As Byte()
Dim b = New Byte(count - 1) {}
For i As Integer = 0 To count - 1
b(i) = buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1))
Next
Return b
End Function
' Read a UTF8 encoded string
Public Function ReadString(length As Integer) As String
Return Encoding.UTF8.GetString(ReadBytes(length))
End Function
Public Function ReadPointer() As Integer
' read value
Dim ptr = ReadInt32()
' return on blank pointer
If ptr = 0 Then
Return 0
End If
' a pointer must be between 0x0 and 0x1FFFFFF to be valid on the GBA
' ROM pointer format is OFFSET | 0x8000000, so 0x8000000 <= POINTER <= 0x9FFFFFF
If ptr < &H8000000 OrElse ptr > &H9FFFFFF Then
Throw New Exception(String.Format("Bad pointer at 0x{0:X6}", pos - 4))
End If
' easy way to extract
Return ptr And &H1FFFFFF
End Function
' read a GBA string
'Public Function ReadText(length As Integer, Optional encoding As CharacterEncoding = CharacterEncoding.English) As String
' Return TextTable.GetString(ReadBytes(length), encoding)
'End Function
'Public Function ReadTextTable(stringLength As Integer, tableSize As Integer, Optional encoding As CharacterEncoding = CharacterEncoding.English) As String()
' Dim table = New String(tableSize - 1) {}
' For i As Integer = 0 To tableSize - 1
' table(i) = ReadText(stringLength, encoding)
' Next
' Return table
'End Function
#End Region
#Region "Write"
Public Sub WriteByte(value As Byte)
buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) = value
End Sub
Public Sub WriteSByte(value As SByte)
WriteByte(CByte(value))
End Sub
Public Sub WriteUInt16(value As UShort)
buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) = CByte(value)
buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) = CByte(value >> 8)
End Sub
Public Sub WriteInt32(value As Integer)
For i As Integer = 0 To 3
buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) = CByte(value >> (i * 8))
Next
End Sub
Public Sub WriteUInt32(value As UInteger)
For i As Integer = 0 To 3
buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) = CByte(value >> (i * 8))
Next
End Sub
Public Sub WriteUInt64(value As ULong)
For i As Integer = 0 To 7
buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) = CByte(value >> (i * 8))
Next
End Sub
Public Sub WriteBytes(bytes As Byte())
For i As Integer = 0 To bytes.Length - 1
buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) = bytes(i)
Next
End Sub
' Write a byte value count number of times
Public Sub WriteBytes(value As Byte, count As Integer)
For i As Integer = 0 To count - 1
buffer(System.Math.Max(System.Threading.Interlocked.Increment(pos), pos - 1)) = value
Next
End Sub
Public Sub WritePointer(offset As Integer)
If offset > &H1FFFFFF Then
Throw New Exception(String.Format("Offset 0x{0:X6} too large for a ROM pointer (0 <= offset <= 0x1FFFFFF)!"))
End If
WriteInt32(offset Or &H8000000)
End Sub
' Write a UTF8 encoded string
Public Sub WriteString(str As String)
WriteBytes(Encoding.UTF8.GetBytes(str))
End Sub
#End Region
#Region "Search"
Public Function FindFreeSpace(length As Integer, Optional freespace As Byte = &HFF, Optional startOffset As Integer = 0, Optional alignment As Integer = 1) As Integer
' The simpest freespace finder I could think of
If alignment > 1 AndAlso startOffset Mod alignment <> 0 Then
startOffset += alignment - (startOffset Mod alignment)
End If
Dim i As Integer = startOffset
While i < buffer.Length - length
Dim match As Boolean = True
For j As Integer = 0 To length - 1
If buffer(i + j) <> freespace Then
match = False
Exit For
End If
Next
If match Then
Return i
End If
i += alignment
End While
Return -1
End Function
#End Region
#Region "Properties"
Public ReadOnly Property FilePath() As String
Get
Return m_filePath
End Get
End Property
Public ReadOnly Property Length() As Integer
Get
Return buffer.Length
End Get
End Property
Public Property Position() As Integer
Get
Return pos
End Get
Set(value As Integer)
pos = value
If pos < 0 OrElse pos > buffer.Length Then
Throw New IndexOutOfRangeException()
End If
End Set
End Property
Public ReadOnly Property EndOfStream() As Boolean
Get
Return pos >= buffer.Length
End Get
End Property
' ROM specific properties
' TODO: better to store these as existing strings
Public ReadOnly Property Name() As String
Get
Return Encoding.UTF8.GetString(buffer, &HA0, 12)
End Get
End Property
Public ReadOnly Property Code() As String
Get
Return Encoding.UTF8.GetString(buffer, &HAC, 4)
End Get
End Property
Public ReadOnly Property Maker() As String
Get
Return Encoding.UTF8.GetString(buffer, &HB0, 2)
End Get
End Property
#End Region
Private Sub OnSourceFileChanged(sender As Object, e As FileSystemEventArgs)
Console.WriteLine("ROM {e.FullPath} changed {e.ChangeType}.")
If ignoreChange Then
ignoreChange = False
Return
End If
If e.FullPath = m_filePath Then
Console.WriteLine("Reloading buffer...")
Using fs = File.Open(m_filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
If buffer.Length <> fs.Length Then
buffer = New Byte(fs.Length - 1) {}
End If
fs.Read(buffer, 0, buffer.Length)
End Using
End If
End Sub
Private Sub OnSourceFileRenamed(sender As Object, e As RenamedEventArgs)
Console.WriteLine("{e.OldFullPath} renamed to {e.FullPath}!")
If e.OldFullPath = m_filePath Then
m_filePath = e.FullPath
End If
End Sub
End Class

View File

@@ -16,7 +16,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<dsig:DigestValue>Lfa3tUh1a3B7Ce+KO1XOAFpQKJM=</dsig:DigestValue>
<dsig:DigestValue>cEChvezvtmhv3eHbLmFCkRtITkk=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>

View File

@@ -43,14 +43,14 @@
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="PokemonGameEditor.exe" size="2002432">
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="PokemonGameEditor.exe" size="2019840">
<assemblyIdentity name="PokemonGameEditor" version="3.7.0.0" language="neutral" processorArchitecture="msil" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<dsig:DigestValue>EnCvmx2c0VL8RvQ7IT/nN4FYRW8=</dsig:DigestValue>
<dsig:DigestValue>GrraqbCuBqWEnZ+CKRBzJpXfl+g=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>

View File

@@ -16,7 +16,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<dsig:DigestValue>Lfa3tUh1a3B7Ce+KO1XOAFpQKJM=</dsig:DigestValue>
<dsig:DigestValue>cEChvezvtmhv3eHbLmFCkRtITkk=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>

View File

@@ -43,14 +43,14 @@
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="PokemonGameEditor.exe" size="2002432">
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="PokemonGameEditor.exe" size="2019840">
<assemblyIdentity name="PokemonGameEditor" version="3.7.0.0" language="neutral" processorArchitecture="msil" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<dsig:DigestValue>EnCvmx2c0VL8RvQ7IT/nN4FYRW8=</dsig:DigestValue>
<dsig:DigestValue>GrraqbCuBqWEnZ+CKRBzJpXfl+g=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>

View File

@@ -5,6 +5,7 @@
Module mMain
Public LoadedROM As String
'Public ledrom As ROM
Public AppPath As String = System.AppDomain.CurrentDomain.BaseDirectory() & IIf(Right(System.AppDomain.CurrentDomain.BaseDirectory(), 1) = "\", "", "\")
Public i As Integer
Public FileNum As Integer
@@ -15,6 +16,9 @@ Module mMain
Public SkipVar As Integer
Public x As Integer
Public crynorm As New Cry()
Public crygrowl As New Cry()
'For Map Edit
Public Point2MapBankPointers As String
Public MapBankPointers As String

View File

@@ -16,7 +16,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<dsig:DigestValue>Lfa3tUh1a3B7Ce+KO1XOAFpQKJM=</dsig:DigestValue>
<dsig:DigestValue>cEChvezvtmhv3eHbLmFCkRtITkk=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>

View File

@@ -43,14 +43,14 @@
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="PokemonGameEditor.exe" size="2002432">
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="PokemonGameEditor.exe" size="2019840">
<assemblyIdentity name="PokemonGameEditor" version="3.7.0.0" language="neutral" processorArchitecture="msil" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<dsig:DigestValue>EnCvmx2c0VL8RvQ7IT/nN4FYRW8=</dsig:DigestValue>
<dsig:DigestValue>GrraqbCuBqWEnZ+CKRBzJpXfl+g=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>

View File

@@ -3,7 +3,7 @@ Please use the lastest beta!
![alt tag](https://raw.githubusercontent.com/Gamer2020/PokemonGameEditor/master/Screenshots/PGEBANNER.png)
Pokemon Game Editor, commonly know as PGE, is an all in one tool started in 2010 by Gamer2020 for hacking the Game Boy Advanced Pokemon games. The program continues to evolve over the years and has had 60,000+ downloads. It has even inspired several copycat programs hence the slogan "Accept no Imitations!" was adopted. The program is currently developed in VB.Net with Visual Studio 2015.
Pokemon Game Editor, commonly know as PGE, is an all in one tool started in 2010 by Gamer2020 for hacking the Game Boy Advanced Pokemon games. The program continues to evolve over the years and has had 60,000+ downloads. It has even inspired several copycat programs hence the slogan "Accept no Imitations!" was adopted. The program is currently developed in VB.Net with Visual Studio 2013.
Screenshots
=================
@@ -187,6 +187,8 @@ DoesntKnowHowToPlay
AkameTheBulbasaur
doom-desire
Downloads
================================
https://github.com/Gamer2020/PokemonGameEditor/releases