Skip to content

Commit

Permalink
fix: fix zx0 encoding crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelesaux committed Feb 14, 2022
1 parent cad6f42 commit 1591214
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions gfx/animate/animate_delta.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ func ExportDeltaAnimate(imageReference []byte, delta []*transformation.DeltaColl
var dataCode string
var deltaIndex []string
var code string
var nbDelta = len(delta)
if !isSprite {
if ex.Compression != -1 {
sourceCode = deltaScreenCompressCodeDelta
Expand Down Expand Up @@ -267,8 +268,12 @@ func ExportDeltaAnimate(imageReference []byte, delta []*transformation.DeltaColl
dataCode += name + ":\n"
if ex.Compression != -1 {
fmt.Fprintf(os.Stdout, "Using Zx0 cruncher")
d := zx0.Encode(data)
dataCode += file.FormatAssemblyDatabyte(d, "\n")
if dc.OccurencePerFrame != 0 {
d := zx0.Encode(data)
dataCode += file.FormatAssemblyDatabyte(d, "\n")
} else {
nbDelta--
}
} else {
dataCode += file.FormatAssemblyDatabyte(data, "\n")
}
Expand All @@ -293,8 +298,8 @@ func ExportDeltaAnimate(imageReference []byte, delta []*transformation.DeltaColl
header = strings.Replace(header, "$NBCOLORS$", nbColors, 1)

// replace the number of delta
nbDelta := fmt.Sprintf("%d", len(delta))
header = strings.Replace(header, "$NBDELTA$", nbDelta, 1)
nbDeltaLabel := fmt.Sprintf("%d", nbDelta)
header = strings.Replace(header, "$NBDELTA$", nbDeltaLabel, 1)

// replace char large for the screen
charLarge := fmt.Sprintf("#%.4x", 0xC000+ex.LineWidth)
Expand Down Expand Up @@ -337,6 +342,7 @@ func exportDeltaAnimate(imageReference []byte, delta []*transformation.DeltaColl
var dataCode string
var deltaIndex []string
var code string
nbDelta := len(delta)
if !isSprite {
if ex.Compression != -1 {
sourceCode = deltaScreenCompressCodeDelta
Expand Down Expand Up @@ -367,8 +373,13 @@ func exportDeltaAnimate(imageReference []byte, delta []*transformation.DeltaColl
dataCode += name + ":\n"
if ex.Compression != -1 {
fmt.Fprintf(os.Stdout, "Using Zx0 cruncher")
d := zx0.Encode(data)
dataCode += file.FormatAssemblyDatabyte(d, "\n")
if dc.OccurencePerFrame != 0 {
d := zx0.Encode(data)
dataCode += file.FormatAssemblyDatabyte(d, "\n")
dataCode += file.FormatAssemblyDatabyte(d, "\n")
} else {
nbDelta--
}
} else {
dataCode += file.FormatAssemblyDatabyte(data, "\n")
}
Expand All @@ -393,8 +404,9 @@ func exportDeltaAnimate(imageReference []byte, delta []*transformation.DeltaColl
header = strings.Replace(header, "$NBCOLORS$", nbColors, 1)

// replace the number of delta
nbDelta := fmt.Sprintf("%d", len(delta))
header = strings.Replace(header, "$NBDELTA$", nbDelta, 1)
// replace the number of delta
nbDeltaLabel := fmt.Sprintf("%d", nbDelta)
header = strings.Replace(header, "$NBDELTA$", nbDeltaLabel, 1)

// replace char large for the screen
charLarge := fmt.Sprintf("#%.4x", 0xC000+ex.LineWidth)
Expand Down

0 comments on commit 1591214

Please sign in to comment.