]> git.jsancho.org Git - guile-irrlicht.git/blob - irrlicht/bindings/io.scm
TOC with direct C++
[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   #:use-module (irrlicht util foreign))
25
26 (define (make-cirr-id c0 c1 c2 c3)
27   (define (char->numeric c)
28     (if (char? c) (char->integer c) c))
29   (logior
30    (char->numeric c0)
31    (bitwise-arithmetic-shift-left (char->numeric c1) 8)
32    (bitwise-arithmetic-shift-left (char->numeric c2) 16)
33    (bitwise-arithmetic-shift-left (char->numeric c3) 24)))
34
35 ;; irr_io_E_FILE_ARCHIVE_TYPE enum
36 ;; A PKZIP archive
37 (define-public EFAT_ZIP (make-cirr-id #\Z #\I #\P 0))
38 ;; A gzip archive
39 (define-public EFAT_GZIP (make-cirr-id #\g #\z #\i #\p))
40 ;; A virtual directory
41 (define-public EFAT_FOLDER (make-cirr-id #\f #\l #\d #\r))
42 ;; An ID Software PAK archive
43 (define-public EFAT_PAK (make-cirr-id #\P #\A #\K 0))
44 ;; A Nebula Device archive
45 (define-public EFAT_NPK (make-cirr-id #\N #\P #\K 0))
46 ;; A Tape ARchive
47 (define-public EFAT_TAR (make-cirr-id #\T #\A #\R 0))
48 ;; A wad Archive, Quake2, Halflife
49 (define-public EFAT_WAD (make-cirr-id #\W #\A #\D 0))
50 ;; The type of this archive is unknown
51 (define-public EFAT_UNKNOWN (make-cirr-id #\u #\n #\k #\n))
52
53 ;; IO functions
54 (define-foreign add-file-archive
55   int "irr_io_addFileArchive" (list '* '* int int int '* '*))