PokemonGameEditor/GBAPokemonGameEditor/HexFunctions.vb
Gamer2020 ae1f427215 Massive update!
I was away for a month or so without internet. In that time I continued
to work on PGE. There are a lot of new things in this version.

The Attack adder has been updated. I've completed Jambo51's move table
hack for Fire Red and made it so the Attack adder installs it. I still
have yet to port the hack to Emerald.

The Pokemon adder works for English Fire Red. I made it add Pokemon the
same way that it's done in DoesntKnowHowToPlay's tutorial in order to
remain consistent with what others may have already done. If any
problems occur with the Pokemon adder please let me know. Unlike G3HS,
cries and other things are expanded correctly by PGE. I advise not using
G3HS to add more Pokemon.

When an offset is missing from the ini, PGE will now dump text to a file
named errors.txt letting you know what offset is missing and for what
ROM. I may expand on this in the future.

Improved importing and exporting of data. Attacks, Abilities, and
Pokemon can be exported and imported as inis. It is now handled better
than in older versions.

I fixed the Pokedex data editor because it seems it wasn't loading some
data properly.

I've added a Pokedex tab to the Pokemon Editor. Even though I feel they
should be seperate I mainly added it because I want Pokedex data to be
included when you export Pokemon Data.

I made it so that the Pokedex tab shows you how big the sprites will be
in the size compare. I will make it show where the sprites will be
onscreen once I figure out the formula for it. Bulbapedia is wrong when
it comes to the Pokedex data.

Added the item use anitmation (FR/LG) bytes to the Pokemon Editor.

Added editing of the in battle sprite positions. Has the preview from
Advance Series.  (Loading of all the Pokemon data seems slow now.
Eventually I will have to come back and optimize things.)

Pokemon sprites can be imported and exported. The format is the same as
Advance Series. The importing and exporting of the animations from
Emerald are handled better than in Advance Series.

Pokemon Icons can now be imported and exported. Advance Series
compatable as well.

Pokemon Footprints can be imported and exported.

Other Miscellaneous fixes and additions.
2016-04-01 21:23:11 -04:00

94 lines
4.2 KiB
VB.net

Option Strict Off
Option Explicit On
Module HexFunctions
' ------------------------------------------------
' ----------------------------------------------------
' --------------------------------------------------------
' |----------HEX Editing Functions by: Darthatron----------|
' --------------------------------------------------------
' |--When using these functions I must be credited fully.--|
' |--Check on Darthatron.Com for updates of this function--|
' |--as these are merely the BETA forms and may need some--|
' |--updates. If you find any bugs, please email them to:--|
' |--info@darthatron.com, thankyou: Regards, Darthatron.--|
' --------------------------------------------------------
' ----------------------------------------------------
' ------------------------------------------------
' ------------------------------------------------
' ----------You can't handle the truth!!----------
' ------------------------------------------------
' ------------------------------------------------
' ----------------------------------------------------
' --------------------------------------------------------
' |----------Update 001: Sunday 18th May 2008----------|
' --------------------------------------------------------
' |----Pretty much just fixed the WriteHEX Function, it----|
' |----------should be reasonably faster now. :)----------|
' --------------------------------------------------------
' ----------------------------------------------------
' ------------------------------------------------
Public Function ReverseHEX(ByRef HEXData As String) As String
Dim iNum As Integer
Dim HEXHolder As String = ""
If Len(HEXData) / 2 <> Int(Len(HEXData) / 2) Then HEXData = "0" & HEXData
For iNum = 0 To Len(HEXData) + 1
If Len(HEXData) <= 1 Then GoTo EndNow
HEXHolder = HEXHolder & Right(HEXData, 2)
HEXData = Left(HEXData, Len(HEXData) - 2)
Next iNum
EndNow:
ReverseHEX = HEXHolder
End Function
Public Function ReadHEX(ByRef FilePath As String, ByRef Start As Integer, ByRef Length As Integer) As String
On Error GoTo ErrHandle
Dim iFile As Integer
Dim bytHex As Byte
Dim sHex As String
Dim i As Integer
Start = Start + 1
iFile = FreeFile
sHex = ""
i = 0
FileOpen(iFile, FilePath, OpenMode.Binary)
For i = Start To (Start + Length - 1)
'UPGRADE_WARNING: Get was upgraded to FileGet and has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
FileGet(iFile, bytHex, i)
sHex = sHex & Right("00" & Hex(bytHex), 2)
Next i
FileClose(iFile)
ReadHEX = sHex
Exit Function
ErrHandle:
MsgBox(Err.Description, MsgBoxStyle.OKOnly, "Error: " & Err.Number)
End Function
Public Function WriteHEX(ByRef FilePath As String, ByRef Start As Integer, ByRef Data As String) As Object
On Error GoTo ErrHandle
Dim iFile As Integer
Dim sPost As Integer
Dim bytHex As Byte
' Start = Start + 1
iFile = FreeFile
sPost = 0
If Len(Data) <> Int(Len(Data) / 2) * 2 Then Data = "0" & Data
FileOpen(iFile, FilePath, OpenMode.Binary)
Do While Len(Data) > 0
bytHex = Int32.Parse((Mid(Data, 1, 2)), System.Globalization.NumberStyles.HexNumber)
'UPGRADE_WARNING: Put was upgraded to FilePut and has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
FilePut(iFile, bytHex, Start + 1 + sPost)
Data = Right(Data, Len(Data) - 2)
sPost = sPost + 1
Loop
FileClose(iFile)
Exit Function
ErrHandle:
MsgBox(Err.Description, MsgBoxStyle.OkOnly, "Error: " & Err.Number)
End Function
End Module