Skip to content

Commit

Permalink
Review decomprssor code
Browse files Browse the repository at this point in the history
  • Loading branch information
hansbonini committed Jul 12, 2024
1 parent 73c2862 commit 3848354
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions tools/segard/decomp.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"io"
"math/big"
"math/bits"
"os"
)

Expand Down Expand Up @@ -49,28 +48,28 @@ func main() {
a := data[0]
b := binary.BigEndian.Uint32(data[1:])
pattern |= b
for y := 0; y < 0x20; y++ {
_, bit := bits.Add32(b, b, 0)
b += b
k := 0
for y := 0x1F; y >= 0; y-- {
bit := (b >> y) & 0x1
if bit&0x1 == 1 {
window[y] = a
window[k] = a
}
k++
}
}

x := 0
pattern2 := 0xFFFFFFFF ^ pattern
if pattern2 != 0 {
for y := 0; y < 0x20; y++ {
_, bit := bits.Add32(pattern, pattern, 0)
pattern += pattern
if bit&0x1 == 1 {
x++
} else {
rom.Read(tmp)
if pattern != 0xFFFFFFFF {
for y := 0x1F; y >= 0x0; y-- {
bit := (pattern >> y) & 0x1
if bit&0x1 == 0 {
_, err := rom.Read(tmp)
if err == io.EOF {
break
}
window[x] = tmp[0]
x++
}
x++
}
}

Expand Down

0 comments on commit 3848354

Please sign in to comment.