+;;; guile-irrlicht --- FFI bindings for Irrlicht Engine
+;;; Copyright (C) 2019 Javier Sancho <jsf@jsancho.org>
+;;;
+;;; This file is part of guile-irrlicht.
+;;;
+;;; Guile-irrlicht is free software; you can redistribute it and/or modify
+;;; it under the terms of the GNU Lesser General Public License as
+;;; published by the Free Software Foundation; either version 3 of the
+;;; License, or (at your option) any later version.
+;;;
+;;; Guile-irrlicht is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU Lesser General Public
+;;; License along with guile-irrlicht. If not, see
+;;; <http://www.gnu.org/licenses/>.
+
+
+(define-module (irrlicht bindings io)
+ #:use-module (system foreign)
+ #:use-module (rnrs arithmetic bitwise))
+
+(define cirr (dynamic-link "libCIrrlicht"))
+
+(define (make-cirr-id c0 c1 c2 c3)
+ (define (char->numeric c)
+ (if (char? c) (char->integer c) c))
+ (logior
+ (char->numeric c0)
+ (bitwise-arithmetic-shift-left (char->numeric c1) 8)
+ (bitwise-arithmetic-shift-left (char->numeric c2) 16)
+ (bitwise-arithmetic-shift-left (char->numeric c3) 24)))
+
+;; irr_io_E_FILE_ARCHIVE_TYPE enum
+;; A PKZIP archive
+(define-public EFAT_ZIP (make-cirr-id #\Z #\I #\P 0))
+;; A gzip archive
+(define-public EFAT_GZIP (make-cirr-id #\g #\z #\i #\p))
+;; A virtual directory
+(define-public EFAT_FOLDER (make-cirr-id #\f #\l #\d #\r))
+;; An ID Software PAK archive
+(define-public EFAT_PAK (make-cirr-id #\P #\A #\K 0))
+;; A Nebula Device archive
+(define-public EFAT_NPK (make-cirr-id #\N #\P #\K 0))
+;; A Tape ARchive
+(define-public EFAT_TAR (make-cirr-id #\T #\A #\R 0))
+;; A wad Archive, Quake2, Halflife
+(define-public EFAT_WAD (make-cirr-id #\W #\A #\D 0))
+;; The type of this archive is unknown
+(define-public EFAT_UNKNOWN (make-cirr-id #\u #\n #\k #\n))
+
+;; IO functions
+(define-public add-file-archive
+ (pointer->procedure
+ int
+ (dynamic-func "irr_io_addFileArchive" cirr)
+ (list '* '* int int int '* '*)))