From 9cd9febf9c4ccc32cedfe0d0375c4eb8e7be7579 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sun, 18 Sep 2022 00:21:14 +0900 Subject: [PATCH] ipf decoder update --- assets/disk0/tvdos/TVDOS.SYS | 21 +++++++++++---------- assets/disk0/tvdos/bin/decodeipf.js | 9 +++++++-- assets/disk0/tvdos/bin/encodeipf.js | 8 +++----- assets/disk0/ycocg.ipf1 | Bin 5470 -> 5470 bytes assets/disk0/ycocg.ipf2 | Bin 7533 -> 7533 bytes assets/disk0/ycocg2.ipf1 | Bin 7360 -> 7360 bytes assets/disk0/ycocg2.ipf2 | Bin 10341 -> 10341 bytes 7 files changed, 21 insertions(+), 17 deletions(-) diff --git a/assets/disk0/tvdos/TVDOS.SYS b/assets/disk0/tvdos/TVDOS.SYS index 653576a..046f461 100644 --- a/assets/disk0/tvdos/TVDOS.SYS +++ b/assets/disk0/tvdos/TVDOS.SYS @@ -548,20 +548,21 @@ Object.freeze(_TVDOS.DRV.FS.DEVCON) _TVDOS.DRV.FS.DEVFBIPF = {} -_TVDOS.DRV.FS.DEVFBIPF.pwrite = (fd, ptr, _1, _2) => { - let decodefun = ([graphics.decodeIpf1, graphics.decodeIpf2])[sys.peek(ptr + 13)] - // offset 24..27: gzipped size - let width = sys.peek(ptr+8) | (sys.peek(ptr+9) << 8) - let height = sys.peek(ptr+10) | (sys.peek(ptr+11) << 8) - let hasAlpha = (sys.peek(12) != 0) +_TVDOS.DRV.FS.DEVFBIPF.pwrite = (fd, infilePtr, count, _2) => { + let decodefun = ([graphics.decodeIpf1, graphics.decodeIpf2])[sys.peek(infilePtr + 13)] + let width = sys.peek(infilePtr+8) | (sys.peek(infilePtr+9) << 8) + let height = sys.peek(infilePtr+10) | (sys.peek(infilePtr+11) << 8) + let hasAlpha = (sys.peek(infilePtr+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") - decodefun(ptr + 24, -1048577, -1310721, width, height, hasAlpha) + let ipfbuf = sys.malloc(imgLen) + gzip.decompFromTo(infilePtr + 28, count - 28, ipfbuf) // should return FBUF_SIZE -// println("Changing graphics mode") graphics.setGraphicsMode(4) + decodefun(ipfbuf, -1048577, -1310721, width, height, hasAlpha) -// println("cya!") + sys.free(ipfbuf) } _TVDOS.DRV.FS.DEVFBIPF.bwrite = (fd, bytes) => { // TODO pread the file diff --git a/assets/disk0/tvdos/bin/decodeipf.js b/assets/disk0/tvdos/bin/decodeipf.js index b29eb01..d24b531 100644 --- a/assets/disk0/tvdos/bin/decodeipf.js +++ b/assets/disk0/tvdos/bin/decodeipf.js @@ -26,7 +26,12 @@ if (!magicMatching) { } // 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 hasAlpha = (sys.peek(infilePtr+12) != 0) let ipfType = sys.peek(infilePtr+13) @@ -44,4 +49,4 @@ graphics.setGraphicsMode(4) graphics.clearText(); graphics.clearPixels(0); graphics.clearPixels2(0) decodefun(ipfbuf, -1048577, -1310721, width, height, hasAlpha) -sys.free(ipfbuf) \ No newline at end of file +sys.free(ipfbuf)*/ \ No newline at end of file diff --git a/assets/disk0/tvdos/bin/encodeipf.js b/assets/disk0/tvdos/bin/encodeipf.js index ee799a9..c4e2e90 100644 --- a/assets/disk0/tvdos/bin/encodeipf.js +++ b/assets/disk0/tvdos/bin/encodeipf.js @@ -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 outfile = files.open(_G.shell.resolvePathInput(exec_args[3]).full) -let ipfType = exec_args[1]|0 -let encodefun = undefined -if (1 == exec_args[1]) encodefun = graphics.encodeIpf1 -if (2 == exec_args[1]) encodefun = graphics.encodeIpf2 +let ipfType = (exec_args[1]|0) - 1 +let encodefun = ([graphics.decodeIpf1, graphics.decodeIpf2])[ipfType] if (encodefun === undefined) throw Error(`Unknown IPF format: ${exec_args[1]}`) // read input file @@ -25,7 +23,7 @@ let hasAlpha = (4 == channels) && !noalpha // encode image 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 ipfarea = sys.malloc(ipfRawSize) let gzippedImage = sys.malloc(28 + ipfRawSize+8) // ipf file header + somewhat arbitrary number. Get the actual count using 28+gzlen diff --git a/assets/disk0/ycocg.ipf1 b/assets/disk0/ycocg.ipf1 index 9925ccfbd311caf90240ea9faacd31894bac33b8..ae064faf4277107552bd507f725d1068de6403d2 100644 GIT binary patch delta 23 dcmcbobx(^=J|sBIH#5MEfe{E9Hu43C0svGg1+4%8 delta 23 ccmcbobx(^=J|sBIH#5MEfe{2Z@&$+j08}mot^fc4 diff --git a/assets/disk0/ycocg.ipf2 b/assets/disk0/ycocg.ipf2 index 297f3630e6096c7c8730cf0605fed1b56f061813..4755322c907dcf2f40511db45750c0b44073f837 100644 GIT binary patch delta 23 ccmaEB_120{J|sBIH#5MEfe{2Z^2N&n09l9z0{{R3 delta 23 dcmaEB_120{J|sBIH#5MEfe{FqHuA;G0svW!1_S^A diff --git a/assets/disk0/ycocg2.ipf1 b/assets/disk0/ycocg2.ipf1 index 4b7a0dc6755dd9ec3d552762bdc5593e508dff9a..34384a237595c7746d9c0cec90330157ba590588 100644 GIT binary patch delta 23 dcmX?LdBBoSJ|sBIH#5MEfe{E9Hu7zf0RU1$1^55} delta 23 ccmX?LdBBoSJ|sBIH#5MEfe{2Z@@