mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-13 14:36:06 +09:00
ipf decoder update
This commit is contained in:
@@ -548,20 +548,21 @@ Object.freeze(_TVDOS.DRV.FS.DEVCON)
|
|||||||
|
|
||||||
_TVDOS.DRV.FS.DEVFBIPF = {}
|
_TVDOS.DRV.FS.DEVFBIPF = {}
|
||||||
|
|
||||||
_TVDOS.DRV.FS.DEVFBIPF.pwrite = (fd, ptr, _1, _2) => {
|
_TVDOS.DRV.FS.DEVFBIPF.pwrite = (fd, infilePtr, count, _2) => {
|
||||||
let decodefun = ([graphics.decodeIpf1, graphics.decodeIpf2])[sys.peek(ptr + 13)]
|
let decodefun = ([graphics.decodeIpf1, graphics.decodeIpf2])[sys.peek(infilePtr + 13)]
|
||||||
// offset 24..27: gzipped size
|
let width = sys.peek(infilePtr+8) | (sys.peek(infilePtr+9) << 8)
|
||||||
let width = sys.peek(ptr+8) | (sys.peek(ptr+9) << 8)
|
let height = sys.peek(infilePtr+10) | (sys.peek(infilePtr+11) << 8)
|
||||||
let height = sys.peek(ptr+10) | (sys.peek(ptr+11) << 8)
|
let hasAlpha = (sys.peek(infilePtr+12) != 0)
|
||||||
let hasAlpha = (sys.peek(12) != 0)
|
let ipfType = sys.peek(infilePtr+13)
|
||||||
|
let imgLen = sys.peek(infilePtr+24) | (sys.peek(infilePtr+25) << 8) | (sys.peek(infilePtr+26) << 16) | (sys.peek(infilePtr+27) << 24)
|
||||||
|
|
||||||
// println("Calling GPU")
|
let ipfbuf = sys.malloc(imgLen)
|
||||||
decodefun(ptr + 24, -1048577, -1310721, width, height, hasAlpha)
|
gzip.decompFromTo(infilePtr + 28, count - 28, ipfbuf) // should return FBUF_SIZE
|
||||||
|
|
||||||
// println("Changing graphics mode")
|
|
||||||
graphics.setGraphicsMode(4)
|
graphics.setGraphicsMode(4)
|
||||||
|
decodefun(ipfbuf, -1048577, -1310721, width, height, hasAlpha)
|
||||||
|
|
||||||
// println("cya!")
|
sys.free(ipfbuf)
|
||||||
}
|
}
|
||||||
_TVDOS.DRV.FS.DEVFBIPF.bwrite = (fd, bytes) => {
|
_TVDOS.DRV.FS.DEVFBIPF.bwrite = (fd, bytes) => {
|
||||||
// TODO pread the file
|
// TODO pread the file
|
||||||
|
|||||||
@@ -26,7 +26,12 @@ if (!magicMatching) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// decode input image
|
// decode input image
|
||||||
let width = sys.peek(infilePtr+8) | (sys.peek(infilePtr+9) << 8)
|
let ipfFile = files.open("FBIPF")
|
||||||
|
graphics.clearText(); graphics.clearPixels(0); graphics.clearPixels2(0)
|
||||||
|
ipfFile.pwrite(infilePtr, infile.size, 0)
|
||||||
|
sys.free(infilePtr)
|
||||||
|
|
||||||
|
/*let width = sys.peek(infilePtr+8) | (sys.peek(infilePtr+9) << 8)
|
||||||
let height = sys.peek(infilePtr+10) | (sys.peek(infilePtr+11) << 8)
|
let height = sys.peek(infilePtr+10) | (sys.peek(infilePtr+11) << 8)
|
||||||
let hasAlpha = (sys.peek(infilePtr+12) != 0)
|
let hasAlpha = (sys.peek(infilePtr+12) != 0)
|
||||||
let ipfType = sys.peek(infilePtr+13)
|
let ipfType = sys.peek(infilePtr+13)
|
||||||
@@ -44,4 +49,4 @@ graphics.setGraphicsMode(4)
|
|||||||
graphics.clearText(); graphics.clearPixels(0); graphics.clearPixels2(0)
|
graphics.clearText(); graphics.clearPixels(0); graphics.clearPixels2(0)
|
||||||
decodefun(ipfbuf, -1048577, -1310721, width, height, hasAlpha)
|
decodefun(ipfbuf, -1048577, -1310721, width, height, hasAlpha)
|
||||||
|
|
||||||
sys.free(ipfbuf)
|
sys.free(ipfbuf)*/
|
||||||
@@ -8,10 +8,8 @@ let noalpha = exec_args[4] != undefined && exec_args[4].toLowerCase() == "/noalp
|
|||||||
let infile = files.open(_G.shell.resolvePathInput(exec_args[2]).full)
|
let infile = files.open(_G.shell.resolvePathInput(exec_args[2]).full)
|
||||||
let outfile = files.open(_G.shell.resolvePathInput(exec_args[3]).full)
|
let outfile = files.open(_G.shell.resolvePathInput(exec_args[3]).full)
|
||||||
|
|
||||||
let ipfType = exec_args[1]|0
|
let ipfType = (exec_args[1]|0) - 1
|
||||||
let encodefun = undefined
|
let encodefun = ([graphics.decodeIpf1, graphics.decodeIpf2])[ipfType]
|
||||||
if (1 == exec_args[1]) encodefun = graphics.encodeIpf1
|
|
||||||
if (2 == exec_args[1]) encodefun = graphics.encodeIpf2
|
|
||||||
if (encodefun === undefined) throw Error(`Unknown IPF format: ${exec_args[1]}`)
|
if (encodefun === undefined) throw Error(`Unknown IPF format: ${exec_args[1]}`)
|
||||||
|
|
||||||
// read input file
|
// read input file
|
||||||
@@ -25,7 +23,7 @@ let hasAlpha = (4 == channels) && !noalpha
|
|||||||
|
|
||||||
// encode image
|
// encode image
|
||||||
let ipfBlockCount = Math.ceil(imgw / 4.0) * Math.ceil(imgh / 4.0)
|
let ipfBlockCount = Math.ceil(imgw / 4.0) * Math.ceil(imgh / 4.0)
|
||||||
let ipfSizePerBlock = 12 + 4*(ipfType - 1) + 8*hasAlpha
|
let ipfSizePerBlock = 12 + 4*(ipfType) + 8*hasAlpha
|
||||||
let ipfRawSize = ipfSizePerBlock * ipfBlockCount
|
let ipfRawSize = ipfSizePerBlock * ipfBlockCount
|
||||||
let ipfarea = sys.malloc(ipfRawSize)
|
let ipfarea = sys.malloc(ipfRawSize)
|
||||||
let gzippedImage = sys.malloc(28 + ipfRawSize+8) // ipf file header + somewhat arbitrary number. Get the actual count using 28+gzlen
|
let gzippedImage = sys.malloc(28 + ipfRawSize+8) // ipf file header + somewhat arbitrary number. Get the actual count using 28+gzlen
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user