mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-12-26 04:32:05 +00:00
Added partial code to pack 126x128 images.
This commit is contained in:
parent
e82f75009d
commit
c1f0cdab58
@ -196,6 +196,40 @@ class PackPartitions
|
||||
return outBuf
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse raw frame image data, only 126x128 pixels
|
||||
*/
|
||||
def parse126Data(imgEl)
|
||||
{
|
||||
// Locate the data for the Apple II (as opposed to C64 etc.)
|
||||
def dataEl = imgEl.displayData?.find { it.@platform == "AppleII" }
|
||||
assert dataEl : "image '${imgEl.@name}' missing AppleII platform data"
|
||||
|
||||
// Parse out the hex data on each line and add it to a buffer.
|
||||
def hexStr = dataEl.text()
|
||||
def arr = new byte[128*18]
|
||||
def srcPos = 0
|
||||
def dstPos = 0
|
||||
|
||||
// Process each line
|
||||
(0..<128).each { y ->
|
||||
|
||||
// Process all 18 bytes in one line
|
||||
(0..<18).each { x ->
|
||||
arr[dstPos+x] = Integer.parseInt(hexStr[srcPos..srcPos+1], 16)
|
||||
srcPos += 2
|
||||
}
|
||||
dstPos += 18
|
||||
}
|
||||
|
||||
// Put the results into the buffer
|
||||
def outBuf = ByteBuffer.allocate(128*18)
|
||||
outBuf.put(arr)
|
||||
|
||||
// All done. Return the buffer.
|
||||
return outBuf
|
||||
}
|
||||
|
||||
/**
|
||||
* Flood fill from the upper left and upper right corners to determine
|
||||
* all transparent areas.
|
||||
@ -531,6 +565,14 @@ class PackPartitions
|
||||
return buf
|
||||
}
|
||||
|
||||
def pack126(imgEl)
|
||||
{
|
||||
println "Packing 126 image named '${imgEl.@name}'."
|
||||
def buf = parse126Data(imgEl)
|
||||
buf = compress(buf)
|
||||
println "...compressed: ${buf.len} bytes."
|
||||
}
|
||||
|
||||
def packTile(imgEl)
|
||||
{
|
||||
def buf = parseTileData(imgEl)
|
||||
@ -989,6 +1031,8 @@ class PackPartitions
|
||||
dataIn.image.each { image ->
|
||||
if (image.category.text() == "frame" || image.category.text() == "title")
|
||||
packFrameImage(image)
|
||||
else if (image.category.text() == "126")
|
||||
pack126(image)
|
||||
else
|
||||
packTexture(image)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user