Plaster
New
List
Login
common-lisp
default
anonymous
2024.12.23 17:18:12
(in-package #:fileformat) (define-primitive-decoder byte256 () ;; Byte whose value 0 implies 256 (let ((val (read-int 1))) (if (zerop val) 256 val))) (def fli-file (little-endian) ;; Header (fli-header header) ((sparse-array chunk :bytes (- (:find header size) 128))) ) (def fli-header (u32 size) (enum u16 type (#xaf11 fli) (#xaf12 flc-flx) (#xaf44 flic-non8bpp) (#xaf30 flic-nonrle) (#xaf31 flic-frameshift)) (u16 frames) (u16 width) (u16 height) (u16 depth) (u16 flags) (u32 speed) (u16 reserved1) (u32 created) (u32 creator) (u32 updated) (u32 updater) (u16 aspect-dx) (u16 aspect-dy) (u16 ext-flags) (u16 keyframes) (u16 total-frames) (u32 req-memory) (u16 max-regions) (u16 transp_num) ((array 24 u8) reserved2) (u32 oframe1) (u32 oframe2) ((array 40 u8) reserved3) ) (def chunk (u32 size) (enum u16 type (11 color-64 (u16 num-packets) ((sparse-array palette-entry :count num-packets) entries)) (12 delta-fli ;; rle delta ((sparse-array u8 :count (- size 6)) rle-bytes)) (15 byte-run ;; full image rle ((sparse-array u8 :count (- size 6)) rle-bytes)) (#xf100 prefix-type) (#xf1e0 script-chunk) (#xf1fa frame-type (u16 num-chunks) (u16 delay-msec) (u16 reserved) (u16 width) (u16 height) ((sparse-array chunk :count num-chunks) subchunks)) (#xf1fb segment-table) (#xf1fc huffman-table)) ) (def palette-entry (u8 skip) (byte256 num) ((sparse-array color :count num) colors)) (def color (u8 r) (u8 g) (u8 b)) (defun test () (parse (read-file-into-byte-vector "~/Downloads/UFOINT.FLI") 'fli-file)) OUTPUT: (FLI-FILE ((HEADER FLI-HEADER ((SIZE . 2474590) (TYPE . FLI) (FRAMES . 890) (WIDTH . 320) (HEIGHT . 200) (DEPTH . 8) (FLAGS . 3) (SPEED . 5) (RESERVED1 . 0) (CREATED . 0) (CREATOR . 0) (UPDATED . 0) (UPDATER . 0) (ASPECT-DX . 0) (ASPECT-DY . 0) (EXT-FLAGS . 0) (KEYFRAMES . 0) (TOTAL-FRAMES . 0) (REQ-MEMORY . 0) (MAX-REGIONS . 0) (TRANSP_NUM . 0) (RESERVED2 ARRAY ((0 . 0) (1 . 0) (2 . 0) (3 . 0) (4 . 0) (5 . 0) (6 . 0) (7 . 0) (8 . 0) (9 . 0) (10 . 0) (11 . 0) (12 . 0) (13 . 0) (14 . 0) (15 . 0) (16 . 0) (17 . 0) (18 . 0) (19 . 0) (20 . 0) (21 . 0) (22 . 0) (23 . 0))) (OFRAME1 . 0) (OFRAME2 . 0) (RESERVED3 ARRAY ((0 . 0) (1 . 0) (2 . 0) (3 . 0) (4 . 0) (5 . 0) (6 . 0) (7 . 0) (8 . 0) (9 . 0) (10 . 0) (11 . 0) (12 . 0) (13 . 0) (14 . 0) (15 . 0) (16 . 0) (17 . 0) (18 . 0) (19 . 0) (20 . 0) (21 . 0) (22 . 0) (23 . 0) (24 . 0) (25 . 0) (26 . 0) (27 . 0) (28 . 0) (29 . 0) (30 . 0) (31 . 0) (32 . 0) (33 . 0) (34 . 0) (35 . 0) (36 . 0) (37 . 0) (38 . 0) (39 . 0))))) SPARSE-ARRAY ((0 CHUNK ((SIZE . 5740) (TYPE . FRAME-TYPE) (NUM-CHUNKS . 2) (DELAY-MSEC . 0) (RESERVED . 0) (WIDTH . 0) (HEIGHT . 0) (SUBCHUNKS SPARSE-ARRAY ((0 CHUNK ((SIZE . 778) (TYPE . COLOR-64) (NUM-PACKETS . 1) (ENTRIES SPARSE-ARRAY ((0 PALETTE-ENTRY ((SKIP . 0) (NUM . 256) (COLORS SPARSE-ARRAY ((0 COLOR ((R . 0) (G . 0) (B . 0))) (1 COLOR ((R . 63) (G . 63) (B . 63))) (2 COLOR ((R . 61) (G . 61) (B . 61))) (3 COLOR ((R . 58) (G . 58) (B . 58))) (4 COLOR ((R . 56) (G . 56) (B . 56))) (5 COLOR ((R . 54) (G . 54) (B . 54))) (6 COLOR ((R . 52) (G . 52) (B . 52))) (7 COLOR ((R . 50) (G . 50) (B . 50))) ....
Raw
Annotate
Repaste
Edit