mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 11:51:49 +09:00
FBIPF writing impl
This commit is contained in:
@@ -230,7 +230,7 @@ let headerBytes = [
|
||||
0x1F, 0x54, 0x53, 0x56, 0x4D, 0x69, 0x50, 0x46, // magic
|
||||
imgw & 255, (imgw >>> 8) & 255, // width
|
||||
imgh & 255, (imgh >>> 8) & 255, // height
|
||||
((hasAlpha) ? 1 : 0), 0x00, // has alpha
|
||||
((hasAlpha) ? 1 : 0), 0x00, // has alpha, iPF type 1
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // reserved
|
||||
]
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ let headerBytes = [
|
||||
0x1F, 0x54, 0x53, 0x56, 0x4D, 0x69, 0x50, 0x46, // magic
|
||||
imgw & 255, (imgw >>> 8) & 255, // width
|
||||
imgh & 255, (imgh >>> 8) & 255, // height
|
||||
((hasAlpha) ? 1 : 0), 0x00, // has alpha
|
||||
((hasAlpha) ? 1 : 0), 0x01, // has alpha, iPF Type 2
|
||||
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // reserved
|
||||
]
|
||||
|
||||
|
||||
@@ -525,6 +525,48 @@ 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)
|
||||
|
||||
println("Calling GPU")
|
||||
decodefun(ptr + 24, -1048577, -1310721, width, height, hasAlpha)
|
||||
|
||||
println("Changing graphics mode")
|
||||
graphics.setGraphicsMode(4)
|
||||
|
||||
println("cya!")
|
||||
}
|
||||
_TVDOS.DRV.FS.DEVFBIPF.bwrite = (fd, bytes) => {
|
||||
// TODO pread the file
|
||||
let fp = sys.malloc(bytes.length)
|
||||
bytes.forEach((it,i) => {
|
||||
sys.poke(fp + i, it)
|
||||
})
|
||||
_TVDOS.DRV.FS.DEVFBIPF.pwrite(fd, fp)
|
||||
sys.free(fp)
|
||||
}
|
||||
|
||||
_TVDOS.DRV.FS.DEVFBIPF.flush = () => {}
|
||||
_TVDOS.DRV.FS.DEVFBIPF.close = () => {}
|
||||
_TVDOS.DRV.FS.DEVFBIPF.isDirectory = () => false
|
||||
_TVDOS.DRV.FS.DEVFBIPF.listFiles = () => undefined
|
||||
_TVDOS.DRV.FS.DEVFBIPF.touch = () => {}
|
||||
_TVDOS.DRV.FS.DEVFBIPF.mkDir = () => {}
|
||||
_TVDOS.DRV.FS.DEVFBIPF.mkFile = () => {}
|
||||
_TVDOS.DRV.FS.DEVFBIPF.remove = () => {}
|
||||
_TVDOS.DRV.FS.DEVFBIPF.exists = () => true
|
||||
|
||||
Object.freeze(_TVDOS.DRV.FS.DEVFBIPF)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// Legacy Serial filesystem, !!pending for removal!!
|
||||
|
||||
const filesystem = {};
|
||||
@@ -654,7 +696,20 @@ Object.freeze(filesystem);
|
||||
|
||||
const files = {}
|
||||
|
||||
files.reservedNames = ["AUX","COM1","COM2","COM3","COM4","CON","FB1","FB2","FB3","FB4","LPT1","LPT2","LPT3","LPT4","MEM","NUL","PMEM0","PMEM1","PMEM2","PMEM3","PMEM4","PMEM5","PMEM6","PMEM7","PRN","RND","ZERO"]
|
||||
files.reservedNames = ["AUX", // unused
|
||||
"COM1","COM2","COM3","COM4", // serial ports
|
||||
"CON", // the tty
|
||||
"FB1","FB2", // raw framebuffer, 256 colours, typ. 560x448
|
||||
"FBIPF", // framebuffer that accepts IPF-formatted bytes, reduced colours, typ. 560x448
|
||||
"HFB1","HFB2","HFB3","HFB4", // half-dimension framebuffers, 256 colours, typ. 280x224
|
||||
"LPT1","LPT2","LPT3","LPT4", // reserved for "parallel ports"; unused
|
||||
"MEM", // /dev/mem
|
||||
"NUL", // /dev/null
|
||||
"PMEM0","PMEM1","PMEM2","PMEM3","PMEM4","PMEM5","PMEM6","PMEM7", // /dev/mem for peripherals
|
||||
"PRN", // a printer
|
||||
"RND", // /dev/urandom
|
||||
"XFB", // raw framebuffer, 4096 colours, typ. 560x448. Memory layout follows the gpu's (0..250779: RG-plane, 250880..262143: gap, 262144..513023: BA-plane)
|
||||
"ZERO"] // /dev/zero
|
||||
|
||||
/** This function only creates a file descriptor; will not actually interact with the drives yet. */
|
||||
files.open = (fullpath) => {
|
||||
|
||||
@@ -617,7 +617,7 @@ shell.execute = function(line) {
|
||||
gotError = true
|
||||
|
||||
serial.printerr(`[command.js] program quit with ${e}:\n${e.stack || '(stack trace unavailable)'}`)
|
||||
printerrln(`Program quit with error:\n${e.stack || '(stack trace unavailable)'}`)
|
||||
printerrln(`Program quit with ${e}:\n${e.stack || '(stack trace unavailable)'}`)
|
||||
|
||||
if (`${e}`.startsWith("InterruptedException"))
|
||||
errorlevel = SIGTERM.name
|
||||
|
||||
@@ -411,7 +411,7 @@ TYPE 255 FRAME -
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
TSVM Interchangeable Picture Format (aka iPF Type 1)
|
||||
TSVM Interchangeable Picture Format (aka iPF Type 1/2)
|
||||
|
||||
Image is divided into 4x4 blocks and each block is serialised, then the entire file is gzipped
|
||||
|
||||
@@ -419,12 +419,15 @@ Image is divided into 4x4 blocks and each block is serialised, then the entire f
|
||||
# File Structure
|
||||
\x1F T S V M i P F
|
||||
[HEADER]
|
||||
[Blocks.gz]
|
||||
[Blocks.gz] or [Blocks] // gzipping is optional and only done for videos
|
||||
|
||||
- Header
|
||||
uint16 WIDTH
|
||||
uint16 HEIGHT
|
||||
uint16 HAS ALPHA
|
||||
uint8 HAS ALPHA
|
||||
uint8 IPF Type
|
||||
0: Type 1
|
||||
1: Type 2
|
||||
byte[10] RESERVED
|
||||
|
||||
- *.gz
|
||||
|
||||
Reference in New Issue
Block a user