-
Compression in vb6
Hello, I am Isaac. I am writing a Rom hacking tool in vb6 and have noticed that alot of very clever people are on these forums. And I would like some help with my code...
The games data is stored in compressed form, the algorithm is as follows:
Uncompressed: 00 43 43 43 43 22 05
Compressed: 00 43 43 03 22 05
A double byte in the compressed data triggers the copying of the compressed byte (after the first byte) however many times it says in the third byte.
eg: 22 22 would compress as 22 22 01
22 22 22 would compress as 22 22 02 etc...
I have written the decompression successfully, but i am unsure how to recompress it. I feel I am close, and I will post the code for you to look at below...
Decompression:
Code:
Function Decompress(str As String) As String
'Variable declarations
Dim temp() As String
Dim temp2 As String
Dim prev_byte As Integer
Dim current_byte As Integer
Dim byte_count As Long
Dim outstring As String
Dim compr_flag As Boolean
'set up variables
temp2 = Trim(str)
temp2 = "f00 " & temp2
temp = Split(temp2, " ")
byte_count = UBound(temp)
current_byte = 0
compr_flag = False
'start of code
While current_byte <= byte_count
If compr_flag = True Then
byte_representation = CDec(" &H" & temp(current_byte))
For i = 1 To byte_representation - 1
outstr = outstr & " " & temp(prev_byte)
Next i
compr_flag = False
Else
outstr = outstr & " " & temp(current_byte)
If temp(current_byte) = temp(prev_byte) Then
compr_flag = True
End If
End If
prev_byte = current_byte
current_byte = current_byte + 1
Wend
Decompress = Trim(outstr)
End Function
And my draft compression function is below:
Code:
Function Compress(str As String) As String
'variables
Dim temp() As String
Dim temp2 As String
Dim prev_byte As Integer
Dim current_byte As Integer
Dim bytecount As Long
Dim outstring As String
Dim compr_flag As Boolean
Dim repcount As Integer
'set up array etc
temp2 = Trim(str)
temp2 = "f00 " & temp2
temp = Split(temp2, " ")
bytecount = UBound(temp)
current_byte = 0
outstr = ""
'code it dude
While current_byte < bytecount
If compr_flag = False Then
outstr = outstr & " " & temp(current_byte)
If temp(current_byte) = temp(prev_byte) Then
compr_flag = True
repcount = 1
End If
Else
While temp(current_byte) = temp(prev_byte)
prev_byte = current_byte
current_byte = current_byte + 1
repcount = repcount + 1
Wend
If rep_count < 15 Then
outstr = outstr & " 0" & Hex(rep_count)
Else
outstr = outstr & " " & Hex(rep_count)
End If
compr_flag = False
End If
Wend
Compress = Trim(outstring)
End Function
Some advice on the compression would be greatly appreciated. I am puzzled 
Thanks
-
 Originally Posted by partyatmine38
Hello, I am Isaac. I am writing a Rom hacking tool in vb6
We do not support this type of activity in any way size, shape, form or manner.
If you bothered to read the AUP you agreed to when joining this site, you would have found that out.
This thread is closed.
Similar Threads
-
By manishlondon in forum Java
Replies: 0
Last Post: 10-17-2006, 05:19 AM
-
Replies: 246
Last Post: 10-26-2002, 12:30 AM
-
By Richard Curzon in forum .NET
Replies: 3
Last Post: 07-21-2001, 02:32 PM
-
By Mark Burns in forum .NET
Replies: 24
Last Post: 02-09-2001, 01:18 PM
-
By Esmond Hart in forum .NET
Replies: 2
Last Post: 01-29-2001, 07:44 PM
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|