Well, I'm almost through and there are a few issues to resolve.
First and foremost, reading the count of objects in an LGP archive. Your code reads:
Dim fs As FileStream = New FileStream(OpenedFile, FileMode.Open, FileAccess.Read)
Dim stream As New StreamReader(fs)
Dim b As Integer
stream.BaseStream.Seek(12, SeekOrigin.Begin)
For i = 0 To 3
Select Case i
Case 0
b += stream.Read()
Case 1
b += (stream.Read() * 256)
Case 2
b += (stream.Read() * 65536)
Case 3
b += (stream.Read() * 16777216)
End Select
Next
stream.Close()
fs.Close()
MsgBox("This file Contains " & b & " objects!")
Are you kidding, LeeHiOoO? Why have you added these redundant For...Next and Select...Case statements? There will be absolutely no difference if you delete them, like this:
Dim fs As FileStream = New FileStream(OpenedFile, FileMode.Open, FileAccess.Read)
Dim stream As New StreamReader(fs)
Dim b As Integer
stream.BaseStream.Seek(12, SeekOrigin.Begin)
b += stream.Read()
b += (stream.Read() * 256)
b += (stream.Read() * 65536)
b += (stream.Read() * 16777216)
stream.Close()
fs.Close()
MsgBox("This file Contains " & b & " objects!")
However, both codes are inherently erroneous. Check this out:
http://rapidshare.com/files/268451194/Counts_of_objects_in_LGP_archives__as_reported_by_various_LGP_Tools.xlsxThis is a report that compares the count of objects inside various FF7 LGP Archives as reported by Aali/Kranmer UnLGP.exe v0.5 and your LGP_VBNET. As you can see, there are inconsistencies. Your LGP_VBNET reports wrong number of items for magic.lgp, flevel.lgp, chocobo.lgp, condor.lgp and world_us.lgp.
Basically, you are calculating the number of items in an unaligned self-composed Little-Endian manner. What's more is that you use a Text File Stream Reader to read bytes from a binary file, while you should have used a Binary Stream Reader to do so. Meanwhile, be careful not to read "Char" in UTF-8 formats.
The correct code to read the number of items is:
Dim fs As FileStream = New FileStream(OpenedFile, FileMode.Open, FileAccess.Read)
Dim TheLGPFile As BinaryReader = New BinaryReader(fs, Encoding.GetEncoding(1252))
Dim tmp(12) As Byte
TheLGPFile.Read(tmp, 0, 12)
Dim LGPObjectsNum As Integer = TheLGPFile.ReadInt32()
TheLGPFile.Close()
fs.Close()
Return LGPObjectsNum
Here, try this update. I've implemented a debug routine to quickly read and compare the number of items in standard LGP archives of FF7 v1.02:
http://rapidshare.com/files/268455952/LGP_VBNET_update_2_Fleet_Command.zipThere is also issues with user-interface too. Consider setting Tab Order properties appropriately. Also add shortcut for the most frequently used menu items (the way I did in case of Open...) but not all menu items need shortcuts. Try to use shortcuts which are familiar for Windows users. (Notepad is a good example that you can use)
And now:Now, fix the structs and being implementing LGP_Stream class, DeLGP class, their file I/O methods and exception-catching code. Remember: LGP_Stream will have two descendants: DeLGP and EnLGP classes. While LGP_Stream performs generic functions, DeLGP and EnLGP classes will be variants of this class that perform specialized I/O, i.e. DeLGP class opens LGP files that already exist as read only. Meanwhile EnLGP class creates nonexistent empty LGP files with write access.
Currently, focus on DeLGP class and leave implementing EnLGP class for a later time. (You don't want to be buried under a thick layer of unused codes, do you?) For now, focus on creating an LGP extractor and focus more on creating underlying codes than User Interface. (But don't forget about it either.) Start by moving this count-reader code from your form code into LGP_Stream and DeLGP classes.
Remember: These I/O classes should have no User Interface items like message boxes. Have the methods of these classes to return error codes. Your form, which is currently in charge of user interface, and later, maybe other classes, are the only elements which should generate message boxes.
Let me see the results. If they were done properly, the most time-taking part is finished. (You'll probably need no help building the rest of the program on your own but I'll stick around.)
Oh, and whenever you feel you don't need to experiment with the debug code that I added, you can safely remove it and its Listbox1 and Menu item.
Good luck