]> git.jsancho.org Git - guile-irrlicht.git/blob - irrlicht/bindings/io.scm
5532ec10f68f9f10c3a721f5e24e11ae49c34956
[guile-irrlicht.git] / irrlicht / bindings / io.scm
1 ;;; guile-irrlicht --- FFI bindings for Irrlicht Engine
2 ;;; Copyright (C) 2019 Javier Sancho <jsf@jsancho.org>
3 ;;;
4 ;;; This file is part of guile-irrlicht.
5 ;;;
6 ;;; Guile-irrlicht is free software; you can redistribute it and/or modify
7 ;;; it under the terms of the GNU Lesser General Public License as
8 ;;; published by the Free Software Foundation; either version 3 of the
9 ;;; License, or (at your option) any later version.
10 ;;;
11 ;;; Guile-irrlicht is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 ;;; General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU Lesser General Public
17 ;;; License along with guile-irrlicht.  If not, see
18 ;;; <http://www.gnu.org/licenses/>.
19
20
21 (define-module (irrlicht bindings io)
22   #:use-module (system foreign)
23   #:use-module (rnrs arithmetic bitwise))
24
25 (define cirr (dynamic-link "libCIrrlicht"))
26
27 (define (make-cirr-id c0 c1 c2 c3)
28   (define (char->numeric c)
29     (if (char? c) (char->integer c) c))
30   (logior
31    (char->numeric c0)
32    (bitwise-arithmetic-shift-left (char->numeric c1) 8)
33    (bitwise-arithmetic-shift-left (char->numeric c2) 16)
34    (bitwise-arithmetic-shift-left (char->numeric c3) 24)))
35
36 ;; irr_io_E_FILE_ARCHIVE_TYPE enum
37 ;; A PKZIP archive
38 (define-public EFAT_ZIP (make-cirr-id #\Z #\I #\P 0))
39 ;; A gzip archive
40 (define-public EFAT_GZIP (make-cirr-id #\g #\z #\i #\p))
41 ;; A virtual directory
42 (define-public EFAT_FOLDER (make-cirr-id #\f #\l #\d #\r))
43 ;; An ID Software PAK archive
44 (define-public EFAT_PAK (make-cirr-id #\P #\A #\K 0))
45 ;; A Nebula Device archive
46 (define-public EFAT_NPK (make-cirr-id #\N #\P #\K 0))
47 ;; A Tape ARchive
48 (define-public EFAT_TAR (make-cirr-id #\T #\A #\R 0))
49 ;; A wad Archive, Quake2, Halflife
50 (define-public EFAT_WAD (make-cirr-id #\W #\A #\D 0))
51 ;; The type of this archive is unknown
52 (define-public EFAT_UNKNOWN (make-cirr-id #\u #\n #\k #\n))
53
54 ;; IO functions
55 (define-public add-file-archive
56   (pointer->procedure
57    int
58    (dynamic-func "irr_io_addFileArchive" cirr)
59    (list '* '* int int int '* '*)))