Anonymous avatar Anonymous committed 3ab6d97

First commit to new repository.
Changes since last commit:
- new function from libtcod 1.3.4 added: console-put-char-ex
- bindings updated for 1.4.3: console-print-frame and console-print-double-frame

Comments (0)

Files changed (6)

+Welcome to CL-TCOD, an interface between Common Lisp and the Doryen Library
+("libtcod"), a portable truecolour console library intended for use with
+roguelike games.
+
+CL-TCOD consists of 2 files:
+
+1. TCOD.LISP, a lisp file which creates lisp bindings for C functions in the
+   compiled libtcod library, using the "CFFI" lisp foreign function interface.
+
+2. TCOD.ASD, which allows TCOD to be easily loaded and used as a library by
+   other common lisp programs, via the "ASDF" library-loading facility.
+   
+CL-TCOD has been tested with SBCL 1.0.25, CLISP 2.44, and Clozure 1.3 on
+Linux. It should work on any common lisp implementation where CFFI works.
+
+**Note** that it has not been used on a Mac; if you do this you may need to
+tell CFFI what the name of the compiled libtcod library under MacOS is. To do
+this, open tcod.lisp in an editor, find the '(define-foreign-library...'
+clause, uncomment the '(:macintosh...)' line and change the string on that line
+to the name of the libtcod library file.
+
+
+    
+=======
+Licence
+=======
+
+The CL-TCOD package is placed in the Public Domain by its author.
+
+
+
+=====================
+Hints on installation
+=====================
+
+
+You need to know your way around your chosen common lisp and how to install and
+load lisp libraries before proceeding. You also need to have a version of
+libtcod newer than 1.4.1rc2, which is the first version that includes the
+'wrappers.c' and 'wrappers.h' source files that allow CL-TCOD to interface with
+libtcod.
+
+1. Ensure you have a working common lisp installation. 
+2. Ensure the ASDF lisp library is installed.
+3. If CFFI is not installed (see above), download and install it somewhere ASDF can
+   find it.
+4. Put the CL-TCOD files in a directory where ASDF can find them.
+5. Make sure libtcod is installed and compiled. Make sure the libtcod
+   dynamically linked library (.DLL or .SO file) is somewhere your lisp system
+   can find it. It probably is, but if CFFI complains about being unable to
+   find the library, you can either copy it to an appropriate directory or add
+   its directory to the list variable cffi:*foreign-library-directories*
+   e.g. by typing the following in the lisp interpreter:
+
+   (push #P"/my/libtcod/directory/" cffi:*foreign-library-directories*)
+
+6. Start lisp. Load ASDF, CFFI, and finally CL-TCOD:
+
+   (asdf:oos 'asdf:load-op :tcod)
+
+7. Type something like the following commands at the lisp prompt to start using TCOD
+from within Lisp:
+
+   (tcod:console-set-custom-font "myfont.bmp" :font-layout-ascii-in-row 16 16)
+   (tcod:console-init-root 80 25 "Test" nil)
+   (tcod:console-clear tcod:*root*)
+   (tcod:console-print-left tcod:*root* 1 1 :set "Hello, world!~%")
+   (tcod:console-flush)
+
+
+
+
+=======================================
+Differences between CL-TCOD and libtcod
+=======================================
+
+
+1. Naming conventions
+   ------------------
+
+The C function 'TCOD_foobar' corresponds to the lisp function 'foobar', which is in
+the 'tcod' package (and so requires a prefix of 'tcod:' to access in most
+situations). Underscores become hyphens. So:
+
+  TCOD_foobar_function(a, b)     <===>    (tcod:foobar-function a b)
+
+"Predicate functions" are functions whose main job is to return a boolean value (true or
+false) that answers a question. These have a terminal '?' added to their name:
+
+  TCOD_console_is_fullscreen()   <===>    (tcod:console-is-fullscreen?)
+
+C enums have generally more succinct names. As they are lisp keywords, their
+names all begin with ':'. THey are named according to the following pattern:
+
+  TCODK_BACKSPACE (etc)         <===>  :backspace
+  TCOD_CHAR_HLINE  (etc)        <===>  :char-hline
+  TCOD_COLCTRL_1  (etc)         <===>  :colctrl-1
+  TCOD_BKGND_SET (etc)          <===>  :set
+  TCOD_FONT_LAYOUT_ASCII_INCOL  <===>  :font-layout-ascii-in-col 
+  FOV_SHADOW                    <===>  :fov-shadow
+  TCOD_KEY_PRESSED              <===>  :key-pressed
+  CENTER                        <===>  :center
+
+In general, all functions exist in both U.S. and non-U.S. spellings, This is
+mainly relevant to those functions with colour/color in their name.
+
+
+2. Colournums
+   ----------
+
+In libtcod, colours are represented as structures containing three integer
+values: red, green and blue (each 0-255). The name of the structure type is
+TCOD_color_t.
+
+In CL-TCOD, these colour structs are converted into 3-byte integers using the C
+functions int_to_color(int) and color_to_int(TCOD_color_t), both defined in
+wrappers.c. The 3 bytes are red, green and blue in order (blue is 1's). ie:
+
+    /* C */                              ;; lisp ;;
+   struct TCOD_color_t {r, g, b}  <==>   #x00RRGGBB
+
+So, for example, one way to use the function TCOD_color_multiply_scalar from
+lisp is:
+
+  (tcod:color-multiply-scalar (tcod:compose-colour 218 165 32) 0.5)
+
+All C functions that take or return TCOD_color_t structs, are wrapped by lisp
+functions that take or return integers as described above.
+
+
+3. Colours by keyword
+   ------------------
+
+A lisp keyword is any symbol beginning with ':'. In lisp, keywords (like all
+symbols) are first-class values and can be passed around just like any other
+value. CL-TCOD uses keywords to refer to particular colours, for example the
+keyword :cyan refers to the colour #x0056A3CD (or 5678029 in decimal notation).
+
+You can use keywords instead of colournums as arguments to lisp functions, by
+using the function COLOUR to return the colournum associated with a keyword:
+
+  (tcod:colour :cyan)    -->    5678029
+
+
+You can also define your own colour names, like so:
+
+  (tcod:make-colour :my-goldenrod 218 165 32)
+  (tcod:color-multiply-scalar (tcod:colour :my-goldenrod) 0.5)
+
+CL-TCOD knows all the colour names defined in the 'rgb.txt' file under Xwindows
+(Unix/Linux), eg :navajo-white, :honeydew, :mint-cream, and so on. There is
+nothing special about the fact that rgb.txt comes from Xwindows -- the colours
+are just named R,G,B values and can be used anywhere that CL-TCOD can be
+used. Look in the source file 'tcod-colours.lisp' to see the available colour
+names.
+
+
+4. Lisp format versus C printf
+   ---------------------------
+   
+  The TCOD functions that accept 'printf'-like string-formatting arguments,
+  have been modified to instead accept arguments to Common Lisp's 'format'
+  function.'  For example:
+
+    TCOD_console_print_left (con, x, y, TCOD_BKGND_SET,
+      "Printing at %d, %d\n", x, y);
+
+    becomes:
+
+    (tcod:console-print-left con x y :set "Printing at ~D, ~D~%" x y)
+
+    
+4. Miscellaneous extra functions
+   -----------------------------
+   
+  (tcod:console-print-double-frame CONSOLE X Y W H EMPTY? STRING...)
+  
+     - Like console-print-frame, but draws using "double-line"
+       characters.
+     
+
+=========
+Resources
+=========
+
+
+The latest version of CL-TCOD is available at:
+
+    http://bitbucket.org/moriarty4/cl-tcod/
+
+The latest version of libtcod is available at:
+
+    http://doryen.eptalys.net/libtcod/
+
+This Common Lisp package depends on CFFI, the Common Foreign Function Interface:
+
+    http://common-lisp.net/project/cffi/
+
+Learn Common Lisp (free book):
+
+    http://www.gigamonkeys.com/book/
+
+Full-featured, free Common Lisp implementations:
+
+    http://www.sbcl.org (compiles to machine code)
+    http://clisp.cons.org (bytecode compiler, but the friendliest on Win32)
+    http://ccl.clozure.com (compiles to machine code; version 1.3 recently released
+    			    for 32-bit intel systems i.e. linux and windows)
+    
+"Lisp in a Box" -- aims to make it easy to start using Common Lisp by providing
+a single download with everything set up in advance:
+
+    http://common-lisp.net/project/lispbox/
+
+Help & advice with lisp:
+
+    http://www.lispforum.com
+
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;;;;;;;;;;;;;;;80
+
+(defpackage #:parse-rgb-asd
+  (:use :cl :asdf))
+
+(in-package :parse-rgb-asd)
+
+(defsystem parse-rgb
+  :name "parse-rgb"
+  :version "1"
+  :author "moriarty4@gmail.com"
+  :description
+  "Autogenerate TCOD colour definitions by parsing rgb.txt on Xwindows"
+  :serial t	; Only true for the simple case	.
+  :components 
+   ((:file "parse-rgb"))
+  :depends-on ("tcod" "cl-ppcre"))
+
+
+
+
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;;;;;;;;;;;;;;;80
+;;;;
+;;;; parse X11's rgb.txt file to automatically generate colour definitions
+;;;; for CL-TCOD.
+;;;;
+;;;; Taken from Tamas Papp's CL-COLORS library and modified.
+;;;; Original library is available at: (@url :file-name "http://github.com/tpapp/cl-colors/" :display "Github")
+;;;;
+;;;; If you want to regenerate tcod-colours.lisp:
+;;;; - Install the CL-PPCRE library
+;;;;   from: (@url :file-name "http://weitz.de/cl-ppcre/" :display "PCCRE website")
+;;;; - At command prompt, change into the cl-tcod library's directory
+;;;; - Start lisp, and at the command prompt:
+;;;;      (asdf:load-system :parse-rgb)
+;;;;      (parse-rgb:parse-rgb-file)
+
+(defpackage :parse-rgb
+  (:use :cl)
+  (:export #:parse-rgb-file))
+
+(in-package :parse-rgb)
+
+(defvar *rgb-txt-file* "/etc/X11/rgb.txt"
+  "Full path to rgb.txt file to parse")
+
+(defvar *output-file-name* "tcod-colours.lisp"
+  "Name of file to generate")
+
+(defun parse-rgb-file (&key (infile *rgb-txt-file*)
+			      (outfile *output-file-name*))
+  "Parse a file of colour definitions in the format of the X-windows file
+'rgb.txt'. Generate a file of lisp code that allows the CL-TCOD library
+to use all the colours defined in the input file, by name."
+  (let ((color-scanner		     ; will only take names w/o spaces
+	 (cl-ppcre:create-scanner 
+	  "^\\s*(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+([\\s\\w]+\?)\\s*$"
+	  :extended-mode t))
+	(comment-scanner
+	 (cl-ppcre:create-scanner
+	  "^\\s*!")))
+    (with-open-file (s infile
+		       :direction :input
+		       :if-does-not-exist :error)
+      (with-open-file (colornames outfile
+				  :direction :output
+				  :if-exists :supersede
+				  :if-does-not-exist :create)
+	(format colornames ";;;; This file was generated automatically ~
+by parse-rgb.lisp~%~
+;;;; Please do not edit directly.~%~
+ (in-package :tcod)~%")
+	(labels ((string-to-float (string)
+		   (let ((i (read-from-string string)))
+		     (assert (and (typep i 'integer) (<= i 255)))
+		     i)))
+	  (do ((line (read-line s nil nil) (read-line s nil nil)))
+	      ((not line))
+	    (unless (cl-ppcre:scan-to-strings comment-scanner line)
+	      (multiple-value-bind (match registers)
+		  (cl-ppcre:scan-to-strings color-scanner line)
+		(cond
+		  (match
+		  (if (find #\space (aref registers 3))
+		      (setf (aref registers 3) (substitute #\- #\space
+							   (aref registers 3))))
+		  (format colornames
+			  "(make-colour :~A ~A ~A ~A)~%"
+			  (string-downcase (aref registers 3))
+			  (string-to-float (aref registers 0))
+			  (string-to-float (aref registers 1))
+			  (string-to-float (aref registers 2))))
+		  (t
+		   (format *error-output* "ignoring line ~A~%" line)))))))))))

tcod-colours.lisp

+;;;; This file was generated automatically by parse-rgb.lisp
+;;;; Please do not edit directly.
+(in-package :tcod)
+(make-colour :snow 255 250 250)
+(make-colour :ghost-white 248 248 255)
+(make-colour :ghostwhite 248 248 255)
+(make-colour :white-smoke 245 245 245)
+(make-colour :whitesmoke 245 245 245)
+(make-colour :gainsboro 220 220 220)
+(make-colour :floral-white 255 250 240)
+(make-colour :floralwhite 255 250 240)
+(make-colour :old-lace 253 245 230)
+(make-colour :oldlace 253 245 230)
+(make-colour :linen 250 240 230)
+(make-colour :antique-white 250 235 215)
+(make-colour :antiquewhite 250 235 215)
+(make-colour :papaya-whip 255 239 213)
+(make-colour :papayawhip 255 239 213)
+(make-colour :blanched-almond 255 235 205)
+(make-colour :blanchedalmond 255 235 205)
+(make-colour :bisque 255 228 196)
+(make-colour :peach-puff 255 218 185)
+(make-colour :peachpuff 255 218 185)
+(make-colour :navajo-white 255 222 173)
+(make-colour :navajowhite 255 222 173)
+(make-colour :moccasin 255 228 181)
+(make-colour :cornsilk 255 248 220)
+(make-colour :ivory 255 255 240)
+(make-colour :lemon-chiffon 255 250 205)
+(make-colour :lemonchiffon 255 250 205)
+(make-colour :seashell 255 245 238)
+(make-colour :honeydew 240 255 240)
+(make-colour :mint-cream 245 255 250)
+(make-colour :mintcream 245 255 250)
+(make-colour :azure 240 255 255)
+(make-colour :alice-blue 240 248 255)
+(make-colour :aliceblue 240 248 255)
+(make-colour :lavender 230 230 250)
+(make-colour :lavender-blush 255 240 245)
+(make-colour :lavenderblush 255 240 245)
+(make-colour :misty-rose 255 228 225)
+(make-colour :mistyrose 255 228 225)
+(make-colour :white 255 255 255)
+(make-colour :black 0 0 0)
+(make-colour :dark-slate-gray 47 79 79)
+(make-colour :darkslategray 47 79 79)
+(make-colour :dark-slate-grey 47 79 79)
+(make-colour :darkslategrey 47 79 79)
+(make-colour :dim-gray 105 105 105)
+(make-colour :dimgray 105 105 105)
+(make-colour :dim-grey 105 105 105)
+(make-colour :dimgrey 105 105 105)
+(make-colour :slate-gray 112 128 144)
+(make-colour :slategray 112 128 144)
+(make-colour :slate-grey 112 128 144)
+(make-colour :slategrey 112 128 144)
+(make-colour :light-slate-gray 119 136 153)
+(make-colour :lightslategray 119 136 153)
+(make-colour :light-slate-grey 119 136 153)
+(make-colour :lightslategrey 119 136 153)
+(make-colour :gray 190 190 190)
+(make-colour :grey 190 190 190)
+(make-colour :light-grey 211 211 211)
+(make-colour :lightgrey 211 211 211)
+(make-colour :light-gray 211 211 211)
+(make-colour :lightgray 211 211 211)
+(make-colour :midnight-blue 25 25 112)
+(make-colour :midnightblue 25 25 112)
+(make-colour :navy 0 0 128)
+(make-colour :navy-blue 0 0 128)
+(make-colour :navyblue 0 0 128)
+(make-colour :cornflower-blue 100 149 237)
+(make-colour :cornflowerblue 100 149 237)
+(make-colour :dark-slate-blue 72 61 139)
+(make-colour :darkslateblue 72 61 139)
+(make-colour :slate-blue 106 90 205)
+(make-colour :slateblue 106 90 205)
+(make-colour :medium-slate-blue 123 104 238)
+(make-colour :mediumslateblue 123 104 238)
+(make-colour :light-slate-blue 132 112 255)
+(make-colour :lightslateblue 132 112 255)
+(make-colour :medium-blue 0 0 205)
+(make-colour :mediumblue 0 0 205)
+(make-colour :royal-blue 65 105 225)
+(make-colour :royalblue 65 105 225)
+(make-colour :blue 0 0 255)
+(make-colour :dodger-blue 30 144 255)
+(make-colour :dodgerblue 30 144 255)
+(make-colour :deep-sky-blue 0 191 255)
+(make-colour :deepskyblue 0 191 255)
+(make-colour :sky-blue 135 206 235)
+(make-colour :skyblue 135 206 235)
+(make-colour :light-sky-blue 135 206 250)
+(make-colour :lightskyblue 135 206 250)
+(make-colour :steel-blue 70 130 180)
+(make-colour :steelblue 70 130 180)
+(make-colour :light-steel-blue 176 196 222)
+(make-colour :lightsteelblue 176 196 222)
+(make-colour :light-blue 173 216 230)
+(make-colour :lightblue 173 216 230)
+(make-colour :powder-blue 176 224 230)
+(make-colour :powderblue 176 224 230)
+(make-colour :pale-turquoise 175 238 238)
+(make-colour :paleturquoise 175 238 238)
+(make-colour :dark-turquoise 0 206 209)
+(make-colour :darkturquoise 0 206 209)
+(make-colour :medium-turquoise 72 209 204)
+(make-colour :mediumturquoise 72 209 204)
+(make-colour :turquoise 64 224 208)
+(make-colour :cyan 0 255 255)
+(make-colour :light-cyan 224 255 255)
+(make-colour :lightcyan 224 255 255)
+(make-colour :cadet-blue 95 158 160)
+(make-colour :cadetblue 95 158 160)
+(make-colour :medium-aquamarine 102 205 170)
+(make-colour :mediumaquamarine 102 205 170)
+(make-colour :aquamarine 127 255 212)
+(make-colour :dark-green 0 100 0)
+(make-colour :darkgreen 0 100 0)
+(make-colour :dark-olive-green 85 107 47)
+(make-colour :darkolivegreen 85 107 47)
+(make-colour :dark-sea-green 143 188 143)
+(make-colour :darkseagreen 143 188 143)
+(make-colour :sea-green 46 139 87)
+(make-colour :seagreen 46 139 87)
+(make-colour :medium-sea-green 60 179 113)
+(make-colour :mediumseagreen 60 179 113)
+(make-colour :light-sea-green 32 178 170)
+(make-colour :lightseagreen 32 178 170)
+(make-colour :pale-green 152 251 152)
+(make-colour :palegreen 152 251 152)
+(make-colour :spring-green 0 255 127)
+(make-colour :springgreen 0 255 127)
+(make-colour :lawn-green 124 252 0)
+(make-colour :lawngreen 124 252 0)
+(make-colour :green 0 255 0)
+(make-colour :chartreuse 127 255 0)
+(make-colour :medium-spring-green 0 250 154)
+(make-colour :mediumspringgreen 0 250 154)
+(make-colour :green-yellow 173 255 47)
+(make-colour :greenyellow 173 255 47)
+(make-colour :lime-green 50 205 50)
+(make-colour :limegreen 50 205 50)
+(make-colour :yellow-green 154 205 50)
+(make-colour :yellowgreen 154 205 50)
+(make-colour :forest-green 34 139 34)
+(make-colour :forestgreen 34 139 34)
+(make-colour :olive-drab 107 142 35)
+(make-colour :olivedrab 107 142 35)
+(make-colour :dark-khaki 189 183 107)
+(make-colour :darkkhaki 189 183 107)
+(make-colour :khaki 240 230 140)
+(make-colour :pale-goldenrod 238 232 170)
+(make-colour :palegoldenrod 238 232 170)
+(make-colour :light-goldenrod-yellow 250 250 210)
+(make-colour :lightgoldenrodyellow 250 250 210)
+(make-colour :light-yellow 255 255 224)
+(make-colour :lightyellow 255 255 224)
+(make-colour :yellow 255 255 0)
+(make-colour :gold 255 215 0)
+(make-colour :light-goldenrod 238 221 130)
+(make-colour :lightgoldenrod 238 221 130)
+(make-colour :goldenrod 218 165 32)
+(make-colour :dark-goldenrod 184 134 11)
+(make-colour :darkgoldenrod 184 134 11)
+(make-colour :rosy-brown 188 143 143)
+(make-colour :rosybrown 188 143 143)
+(make-colour :indian-red 205 92 92)
+(make-colour :indianred 205 92 92)
+(make-colour :saddle-brown 139 69 19)
+(make-colour :saddlebrown 139 69 19)
+(make-colour :sienna 160 82 45)
+(make-colour :peru 205 133 63)
+(make-colour :burlywood 222 184 135)
+(make-colour :beige 245 245 220)
+(make-colour :wheat 245 222 179)
+(make-colour :sandy-brown 244 164 96)
+(make-colour :sandybrown 244 164 96)
+(make-colour :tan 210 180 140)
+(make-colour :chocolate 210 105 30)
+(make-colour :firebrick 178 34 34)
+(make-colour :brown 165 42 42)
+(make-colour :dark-salmon 233 150 122)
+(make-colour :darksalmon 233 150 122)
+(make-colour :salmon 250 128 114)
+(make-colour :light-salmon 255 160 122)
+(make-colour :lightsalmon 255 160 122)
+(make-colour :orange 255 165 0)
+(make-colour :dark-orange 255 140 0)
+(make-colour :darkorange 255 140 0)
+(make-colour :coral 255 127 80)
+(make-colour :light-coral 240 128 128)
+(make-colour :lightcoral 240 128 128)
+(make-colour :tomato 255 99 71)
+(make-colour :orange-red 255 69 0)
+(make-colour :orangered 255 69 0)
+(make-colour :red 255 0 0)
+(make-colour :hot-pink 255 105 180)
+(make-colour :hotpink 255 105 180)
+(make-colour :deep-pink 255 20 147)
+(make-colour :deeppink 255 20 147)
+(make-colour :pink 255 192 203)
+(make-colour :light-pink 255 182 193)
+(make-colour :lightpink 255 182 193)
+(make-colour :pale-violet-red 219 112 147)
+(make-colour :palevioletred 219 112 147)
+(make-colour :maroon 176 48 96)
+(make-colour :medium-violet-red 199 21 133)
+(make-colour :mediumvioletred 199 21 133)
+(make-colour :violet-red 208 32 144)
+(make-colour :violetred 208 32 144)
+(make-colour :magenta 255 0 255)
+(make-colour :violet 238 130 238)
+(make-colour :plum 221 160 221)
+(make-colour :orchid 218 112 214)
+(make-colour :medium-orchid 186 85 211)
+(make-colour :mediumorchid 186 85 211)
+(make-colour :dark-orchid 153 50 204)
+(make-colour :darkorchid 153 50 204)
+(make-colour :dark-violet 148 0 211)
+(make-colour :darkviolet 148 0 211)
+(make-colour :blue-violet 138 43 226)
+(make-colour :blueviolet 138 43 226)
+(make-colour :purple 160 32 240)
+(make-colour :medium-purple 147 112 219)
+(make-colour :mediumpurple 147 112 219)
+(make-colour :thistle 216 191 216)
+(make-colour :snow1 255 250 250)
+(make-colour :snow2 238 233 233)
+(make-colour :snow3 205 201 201)
+(make-colour :snow4 139 137 137)
+(make-colour :seashell1 255 245 238)
+(make-colour :seashell2 238 229 222)
+(make-colour :seashell3 205 197 191)
+(make-colour :seashell4 139 134 130)
+(make-colour :antiquewhite1 255 239 219)
+(make-colour :antiquewhite2 238 223 204)
+(make-colour :antiquewhite3 205 192 176)
+(make-colour :antiquewhite4 139 131 120)
+(make-colour :bisque1 255 228 196)
+(make-colour :bisque2 238 213 183)
+(make-colour :bisque3 205 183 158)
+(make-colour :bisque4 139 125 107)
+(make-colour :peachpuff1 255 218 185)
+(make-colour :peachpuff2 238 203 173)
+(make-colour :peachpuff3 205 175 149)
+(make-colour :peachpuff4 139 119 101)
+(make-colour :navajowhite1 255 222 173)
+(make-colour :navajowhite2 238 207 161)
+(make-colour :navajowhite3 205 179 139)
+(make-colour :navajowhite4 139 121 94)
+(make-colour :lemonchiffon1 255 250 205)
+(make-colour :lemonchiffon2 238 233 191)
+(make-colour :lemonchiffon3 205 201 165)
+(make-colour :lemonchiffon4 139 137 112)
+(make-colour :cornsilk1 255 248 220)
+(make-colour :cornsilk2 238 232 205)
+(make-colour :cornsilk3 205 200 177)
+(make-colour :cornsilk4 139 136 120)
+(make-colour :ivory1 255 255 240)
+(make-colour :ivory2 238 238 224)
+(make-colour :ivory3 205 205 193)
+(make-colour :ivory4 139 139 131)
+(make-colour :honeydew1 240 255 240)
+(make-colour :honeydew2 224 238 224)
+(make-colour :honeydew3 193 205 193)
+(make-colour :honeydew4 131 139 131)
+(make-colour :lavenderblush1 255 240 245)
+(make-colour :lavenderblush2 238 224 229)
+(make-colour :lavenderblush3 205 193 197)
+(make-colour :lavenderblush4 139 131 134)
+(make-colour :mistyrose1 255 228 225)
+(make-colour :mistyrose2 238 213 210)
+(make-colour :mistyrose3 205 183 181)
+(make-colour :mistyrose4 139 125 123)
+(make-colour :azure1 240 255 255)
+(make-colour :azure2 224 238 238)
+(make-colour :azure3 193 205 205)
+(make-colour :azure4 131 139 139)
+(make-colour :slateblue1 131 111 255)
+(make-colour :slateblue2 122 103 238)
+(make-colour :slateblue3 105 89 205)
+(make-colour :slateblue4 71 60 139)
+(make-colour :royalblue1 72 118 255)
+(make-colour :royalblue2 67 110 238)
+(make-colour :royalblue3 58 95 205)
+(make-colour :royalblue4 39 64 139)
+(make-colour :blue1 0 0 255)
+(make-colour :blue2 0 0 238)
+(make-colour :blue3 0 0 205)
+(make-colour :blue4 0 0 139)
+(make-colour :dodgerblue1 30 144 255)
+(make-colour :dodgerblue2 28 134 238)
+(make-colour :dodgerblue3 24 116 205)
+(make-colour :dodgerblue4 16 78 139)
+(make-colour :steelblue1 99 184 255)
+(make-colour :steelblue2 92 172 238)
+(make-colour :steelblue3 79 148 205)
+(make-colour :steelblue4 54 100 139)
+(make-colour :deepskyblue1 0 191 255)
+(make-colour :deepskyblue2 0 178 238)
+(make-colour :deepskyblue3 0 154 205)
+(make-colour :deepskyblue4 0 104 139)
+(make-colour :skyblue1 135 206 255)
+(make-colour :skyblue2 126 192 238)
+(make-colour :skyblue3 108 166 205)
+(make-colour :skyblue4 74 112 139)
+(make-colour :lightskyblue1 176 226 255)
+(make-colour :lightskyblue2 164 211 238)
+(make-colour :lightskyblue3 141 182 205)
+(make-colour :lightskyblue4 96 123 139)
+(make-colour :slategray1 198 226 255)
+(make-colour :slategray2 185 211 238)
+(make-colour :slategray3 159 182 205)
+(make-colour :slategray4 108 123 139)
+(make-colour :lightsteelblue1 202 225 255)
+(make-colour :lightsteelblue2 188 210 238)
+(make-colour :lightsteelblue3 162 181 205)
+(make-colour :lightsteelblue4 110 123 139)
+(make-colour :lightblue1 191 239 255)
+(make-colour :lightblue2 178 223 238)
+(make-colour :lightblue3 154 192 205)
+(make-colour :lightblue4 104 131 139)
+(make-colour :lightcyan1 224 255 255)
+(make-colour :lightcyan2 209 238 238)
+(make-colour :lightcyan3 180 205 205)
+(make-colour :lightcyan4 122 139 139)
+(make-colour :paleturquoise1 187 255 255)
+(make-colour :paleturquoise2 174 238 238)
+(make-colour :paleturquoise3 150 205 205)
+(make-colour :paleturquoise4 102 139 139)
+(make-colour :cadetblue1 152 245 255)
+(make-colour :cadetblue2 142 229 238)
+(make-colour :cadetblue3 122 197 205)
+(make-colour :cadetblue4 83 134 139)
+(make-colour :turquoise1 0 245 255)
+(make-colour :turquoise2 0 229 238)
+(make-colour :turquoise3 0 197 205)
+(make-colour :turquoise4 0 134 139)
+(make-colour :cyan1 0 255 255)
+(make-colour :cyan2 0 238 238)
+(make-colour :cyan3 0 205 205)
+(make-colour :cyan4 0 139 139)
+(make-colour :darkslategray1 151 255 255)
+(make-colour :darkslategray2 141 238 238)
+(make-colour :darkslategray3 121 205 205)
+(make-colour :darkslategray4 82 139 139)
+(make-colour :aquamarine1 127 255 212)
+(make-colour :aquamarine2 118 238 198)
+(make-colour :aquamarine3 102 205 170)
+(make-colour :aquamarine4 69 139 116)
+(make-colour :darkseagreen1 193 255 193)
+(make-colour :darkseagreen2 180 238 180)
+(make-colour :darkseagreen3 155 205 155)
+(make-colour :darkseagreen4 105 139 105)
+(make-colour :seagreen1 84 255 159)
+(make-colour :seagreen2 78 238 148)
+(make-colour :seagreen3 67 205 128)
+(make-colour :seagreen4 46 139 87)
+(make-colour :palegreen1 154 255 154)
+(make-colour :palegreen2 144 238 144)
+(make-colour :palegreen3 124 205 124)
+(make-colour :palegreen4 84 139 84)
+(make-colour :springgreen1 0 255 127)
+(make-colour :springgreen2 0 238 118)
+(make-colour :springgreen3 0 205 102)
+(make-colour :springgreen4 0 139 69)
+(make-colour :green1 0 255 0)
+(make-colour :green2 0 238 0)
+(make-colour :green3 0 205 0)
+(make-colour :green4 0 139 0)
+(make-colour :chartreuse1 127 255 0)
+(make-colour :chartreuse2 118 238 0)
+(make-colour :chartreuse3 102 205 0)
+(make-colour :chartreuse4 69 139 0)
+(make-colour :olivedrab1 192 255 62)
+(make-colour :olivedrab2 179 238 58)
+(make-colour :olivedrab3 154 205 50)
+(make-colour :olivedrab4 105 139 34)
+(make-colour :darkolivegreen1 202 255 112)
+(make-colour :darkolivegreen2 188 238 104)
+(make-colour :darkolivegreen3 162 205 90)
+(make-colour :darkolivegreen4 110 139 61)
+(make-colour :khaki1 255 246 143)
+(make-colour :khaki2 238 230 133)
+(make-colour :khaki3 205 198 115)
+(make-colour :khaki4 139 134 78)
+(make-colour :lightgoldenrod1 255 236 139)
+(make-colour :lightgoldenrod2 238 220 130)
+(make-colour :lightgoldenrod3 205 190 112)
+(make-colour :lightgoldenrod4 139 129 76)
+(make-colour :lightyellow1 255 255 224)
+(make-colour :lightyellow2 238 238 209)
+(make-colour :lightyellow3 205 205 180)
+(make-colour :lightyellow4 139 139 122)
+(make-colour :yellow1 255 255 0)
+(make-colour :yellow2 238 238 0)
+(make-colour :yellow3 205 205 0)
+(make-colour :yellow4 139 139 0)
+(make-colour :gold1 255 215 0)
+(make-colour :gold2 238 201 0)
+(make-colour :gold3 205 173 0)
+(make-colour :gold4 139 117 0)
+(make-colour :goldenrod1 255 193 37)
+(make-colour :goldenrod2 238 180 34)
+(make-colour :goldenrod3 205 155 29)
+(make-colour :goldenrod4 139 105 20)
+(make-colour :darkgoldenrod1 255 185 15)
+(make-colour :darkgoldenrod2 238 173 14)
+(make-colour :darkgoldenrod3 205 149 12)
+(make-colour :darkgoldenrod4 139 101 8)
+(make-colour :rosybrown1 255 193 193)
+(make-colour :rosybrown2 238 180 180)
+(make-colour :rosybrown3 205 155 155)
+(make-colour :rosybrown4 139 105 105)
+(make-colour :indianred1 255 106 106)
+(make-colour :indianred2 238 99 99)
+(make-colour :indianred3 205 85 85)
+(make-colour :indianred4 139 58 58)
+(make-colour :sienna1 255 130 71)
+(make-colour :sienna2 238 121 66)
+(make-colour :sienna3 205 104 57)
+(make-colour :sienna4 139 71 38)
+(make-colour :burlywood1 255 211 155)
+(make-colour :burlywood2 238 197 145)
+(make-colour :burlywood3 205 170 125)
+(make-colour :burlywood4 139 115 85)
+(make-colour :wheat1 255 231 186)
+(make-colour :wheat2 238 216 174)
+(make-colour :wheat3 205 186 150)
+(make-colour :wheat4 139 126 102)
+(make-colour :tan1 255 165 79)
+(make-colour :tan2 238 154 73)
+(make-colour :tan3 205 133 63)
+(make-colour :tan4 139 90 43)
+(make-colour :chocolate1 255 127 36)
+(make-colour :chocolate2 238 118 33)
+(make-colour :chocolate3 205 102 29)
+(make-colour :chocolate4 139 69 19)
+(make-colour :firebrick1 255 48 48)
+(make-colour :firebrick2 238 44 44)
+(make-colour :firebrick3 205 38 38)
+(make-colour :firebrick4 139 26 26)
+(make-colour :brown1 255 64 64)
+(make-colour :brown2 238 59 59)
+(make-colour :brown3 205 51 51)
+(make-colour :brown4 139 35 35)
+(make-colour :salmon1 255 140 105)
+(make-colour :salmon2 238 130 98)
+(make-colour :salmon3 205 112 84)
+(make-colour :salmon4 139 76 57)
+(make-colour :lightsalmon1 255 160 122)
+(make-colour :lightsalmon2 238 149 114)
+(make-colour :lightsalmon3 205 129 98)
+(make-colour :lightsalmon4 139 87 66)
+(make-colour :orange1 255 165 0)
+(make-colour :orange2 238 154 0)
+(make-colour :orange3 205 133 0)
+(make-colour :orange4 139 90 0)
+(make-colour :darkorange1 255 127 0)
+(make-colour :darkorange2 238 118 0)
+(make-colour :darkorange3 205 102 0)
+(make-colour :darkorange4 139 69 0)
+(make-colour :coral1 255 114 86)
+(make-colour :coral2 238 106 80)
+(make-colour :coral3 205 91 69)
+(make-colour :coral4 139 62 47)
+(make-colour :tomato1 255 99 71)
+(make-colour :tomato2 238 92 66)
+(make-colour :tomato3 205 79 57)
+(make-colour :tomato4 139 54 38)
+(make-colour :orangered1 255 69 0)
+(make-colour :orangered2 238 64 0)
+(make-colour :orangered3 205 55 0)
+(make-colour :orangered4 139 37 0)
+(make-colour :red1 255 0 0)
+(make-colour :red2 238 0 0)
+(make-colour :red3 205 0 0)
+(make-colour :red4 139 0 0)
+(make-colour :debianred 215 7 81)
+(make-colour :deeppink1 255 20 147)
+(make-colour :deeppink2 238 18 137)
+(make-colour :deeppink3 205 16 118)
+(make-colour :deeppink4 139 10 80)
+(make-colour :hotpink1 255 110 180)
+(make-colour :hotpink2 238 106 167)
+(make-colour :hotpink3 205 96 144)
+(make-colour :hotpink4 139 58 98)
+(make-colour :pink1 255 181 197)
+(make-colour :pink2 238 169 184)
+(make-colour :pink3 205 145 158)
+(make-colour :pink4 139 99 108)
+(make-colour :lightpink1 255 174 185)
+(make-colour :lightpink2 238 162 173)
+(make-colour :lightpink3 205 140 149)
+(make-colour :lightpink4 139 95 101)
+(make-colour :palevioletred1 255 130 171)
+(make-colour :palevioletred2 238 121 159)
+(make-colour :palevioletred3 205 104 137)
+(make-colour :palevioletred4 139 71 93)
+(make-colour :maroon1 255 52 179)
+(make-colour :maroon2 238 48 167)
+(make-colour :maroon3 205 41 144)
+(make-colour :maroon4 139 28 98)
+(make-colour :violetred1 255 62 150)
+(make-colour :violetred2 238 58 140)
+(make-colour :violetred3 205 50 120)
+(make-colour :violetred4 139 34 82)
+(make-colour :magenta1 255 0 255)
+(make-colour :magenta2 238 0 238)
+(make-colour :magenta3 205 0 205)
+(make-colour :magenta4 139 0 139)
+(make-colour :orchid1 255 131 250)
+(make-colour :orchid2 238 122 233)
+(make-colour :orchid3 205 105 201)
+(make-colour :orchid4 139 71 137)
+(make-colour :plum1 255 187 255)
+(make-colour :plum2 238 174 238)
+(make-colour :plum3 205 150 205)
+(make-colour :plum4 139 102 139)
+(make-colour :mediumorchid1 224 102 255)
+(make-colour :mediumorchid2 209 95 238)
+(make-colour :mediumorchid3 180 82 205)
+(make-colour :mediumorchid4 122 55 139)
+(make-colour :darkorchid1 191 62 255)
+(make-colour :darkorchid2 178 58 238)
+(make-colour :darkorchid3 154 50 205)
+(make-colour :darkorchid4 104 34 139)
+(make-colour :purple1 155 48 255)
+(make-colour :purple2 145 44 238)
+(make-colour :purple3 125 38 205)
+(make-colour :purple4 85 26 139)
+(make-colour :mediumpurple1 171 130 255)
+(make-colour :mediumpurple2 159 121 238)
+(make-colour :mediumpurple3 137 104 205)
+(make-colour :mediumpurple4 93 71 139)
+(make-colour :thistle1 255 225 255)
+(make-colour :thistle2 238 210 238)
+(make-colour :thistle3 205 181 205)
+(make-colour :thistle4 139 123 139)
+(make-colour :gray0 0 0 0)
+(make-colour :grey0 0 0 0)
+(make-colour :gray1 3 3 3)
+(make-colour :grey1 3 3 3)
+(make-colour :gray2 5 5 5)
+(make-colour :grey2 5 5 5)
+(make-colour :gray3 8 8 8)
+(make-colour :grey3 8 8 8)
+(make-colour :gray4 10 10 10)
+(make-colour :grey4 10 10 10)
+(make-colour :gray5 13 13 13)
+(make-colour :grey5 13 13 13)
+(make-colour :gray6 15 15 15)
+(make-colour :grey6 15 15 15)
+(make-colour :gray7 18 18 18)
+(make-colour :grey7 18 18 18)
+(make-colour :gray8 20 20 20)
+(make-colour :grey8 20 20 20)
+(make-colour :gray9 23 23 23)
+(make-colour :grey9 23 23 23)
+(make-colour :gray10 26 26 26)
+(make-colour :grey10 26 26 26)
+(make-colour :gray11 28 28 28)
+(make-colour :grey11 28 28 28)
+(make-colour :gray12 31 31 31)
+(make-colour :grey12 31 31 31)
+(make-colour :gray13 33 33 33)
+(make-colour :grey13 33 33 33)
+(make-colour :gray14 36 36 36)
+(make-colour :grey14 36 36 36)
+(make-colour :gray15 38 38 38)
+(make-colour :grey15 38 38 38)
+(make-colour :gray16 41 41 41)
+(make-colour :grey16 41 41 41)
+(make-colour :gray17 43 43 43)
+(make-colour :grey17 43 43 43)
+(make-colour :gray18 46 46 46)
+(make-colour :grey18 46 46 46)
+(make-colour :gray19 48 48 48)
+(make-colour :grey19 48 48 48)
+(make-colour :gray20 51 51 51)
+(make-colour :grey20 51 51 51)
+(make-colour :gray21 54 54 54)
+(make-colour :grey21 54 54 54)
+(make-colour :gray22 56 56 56)
+(make-colour :grey22 56 56 56)
+(make-colour :gray23 59 59 59)
+(make-colour :grey23 59 59 59)
+(make-colour :gray24 61 61 61)
+(make-colour :grey24 61 61 61)
+(make-colour :gray25 64 64 64)
+(make-colour :grey25 64 64 64)
+(make-colour :gray26 66 66 66)
+(make-colour :grey26 66 66 66)
+(make-colour :gray27 69 69 69)
+(make-colour :grey27 69 69 69)
+(make-colour :gray28 71 71 71)
+(make-colour :grey28 71 71 71)
+(make-colour :gray29 74 74 74)
+(make-colour :grey29 74 74 74)
+(make-colour :gray30 77 77 77)
+(make-colour :grey30 77 77 77)
+(make-colour :gray31 79 79 79)
+(make-colour :grey31 79 79 79)
+(make-colour :gray32 82 82 82)
+(make-colour :grey32 82 82 82)
+(make-colour :gray33 84 84 84)
+(make-colour :grey33 84 84 84)
+(make-colour :gray34 87 87 87)
+(make-colour :grey34 87 87 87)
+(make-colour :gray35 89 89 89)
+(make-colour :grey35 89 89 89)
+(make-colour :gray36 92 92 92)
+(make-colour :grey36 92 92 92)
+(make-colour :gray37 94 94 94)
+(make-colour :grey37 94 94 94)
+(make-colour :gray38 97 97 97)
+(make-colour :grey38 97 97 97)
+(make-colour :gray39 99 99 99)
+(make-colour :grey39 99 99 99)
+(make-colour :gray40 102 102 102)
+(make-colour :grey40 102 102 102)
+(make-colour :gray41 105 105 105)
+(make-colour :grey41 105 105 105)
+(make-colour :gray42 107 107 107)
+(make-colour :grey42 107 107 107)
+(make-colour :gray43 110 110 110)
+(make-colour :grey43 110 110 110)
+(make-colour :gray44 112 112 112)
+(make-colour :grey44 112 112 112)
+(make-colour :gray45 115 115 115)
+(make-colour :grey45 115 115 115)
+(make-colour :gray46 117 117 117)
+(make-colour :grey46 117 117 117)
+(make-colour :gray47 120 120 120)
+(make-colour :grey47 120 120 120)
+(make-colour :gray48 122 122 122)
+(make-colour :grey48 122 122 122)
+(make-colour :gray49 125 125 125)
+(make-colour :grey49 125 125 125)
+(make-colour :gray50 127 127 127)
+(make-colour :grey50 127 127 127)
+(make-colour :gray51 130 130 130)
+(make-colour :grey51 130 130 130)
+(make-colour :gray52 133 133 133)
+(make-colour :grey52 133 133 133)
+(make-colour :gray53 135 135 135)
+(make-colour :grey53 135 135 135)
+(make-colour :gray54 138 138 138)
+(make-colour :grey54 138 138 138)
+(make-colour :gray55 140 140 140)
+(make-colour :grey55 140 140 140)
+(make-colour :gray56 143 143 143)
+(make-colour :grey56 143 143 143)
+(make-colour :gray57 145 145 145)
+(make-colour :grey57 145 145 145)
+(make-colour :gray58 148 148 148)
+(make-colour :grey58 148 148 148)
+(make-colour :gray59 150 150 150)
+(make-colour :grey59 150 150 150)
+(make-colour :gray60 153 153 153)
+(make-colour :grey60 153 153 153)
+(make-colour :gray61 156 156 156)
+(make-colour :grey61 156 156 156)
+(make-colour :gray62 158 158 158)
+(make-colour :grey62 158 158 158)
+(make-colour :gray63 161 161 161)
+(make-colour :grey63 161 161 161)
+(make-colour :gray64 163 163 163)
+(make-colour :grey64 163 163 163)
+(make-colour :gray65 166 166 166)
+(make-colour :grey65 166 166 166)
+(make-colour :gray66 168 168 168)
+(make-colour :grey66 168 168 168)
+(make-colour :gray67 171 171 171)
+(make-colour :grey67 171 171 171)
+(make-colour :gray68 173 173 173)
+(make-colour :grey68 173 173 173)
+(make-colour :gray69 176 176 176)
+(make-colour :grey69 176 176 176)
+(make-colour :gray70 179 179 179)
+(make-colour :grey70 179 179 179)
+(make-colour :gray71 181 181 181)
+(make-colour :grey71 181 181 181)
+(make-colour :gray72 184 184 184)
+(make-colour :grey72 184 184 184)
+(make-colour :gray73 186 186 186)
+(make-colour :grey73 186 186 186)
+(make-colour :gray74 189 189 189)
+(make-colour :grey74 189 189 189)
+(make-colour :gray75 191 191 191)
+(make-colour :grey75 191 191 191)
+(make-colour :gray76 194 194 194)
+(make-colour :grey76 194 194 194)
+(make-colour :gray77 196 196 196)
+(make-colour :grey77 196 196 196)
+(make-colour :gray78 199 199 199)
+(make-colour :grey78 199 199 199)
+(make-colour :gray79 201 201 201)
+(make-colour :grey79 201 201 201)
+(make-colour :gray80 204 204 204)
+(make-colour :grey80 204 204 204)
+(make-colour :gray81 207 207 207)
+(make-colour :grey81 207 207 207)
+(make-colour :gray82 209 209 209)
+(make-colour :grey82 209 209 209)
+(make-colour :gray83 212 212 212)
+(make-colour :grey83 212 212 212)
+(make-colour :gray84 214 214 214)
+(make-colour :grey84 214 214 214)
+(make-colour :gray85 217 217 217)
+(make-colour :grey85 217 217 217)
+(make-colour :gray86 219 219 219)
+(make-colour :grey86 219 219 219)
+(make-colour :gray87 222 222 222)
+(make-colour :grey87 222 222 222)
+(make-colour :gray88 224 224 224)
+(make-colour :grey88 224 224 224)
+(make-colour :gray89 227 227 227)
+(make-colour :grey89 227 227 227)
+(make-colour :gray90 229 229 229)
+(make-colour :grey90 229 229 229)
+(make-colour :gray91 232 232 232)
+(make-colour :grey91 232 232 232)
+(make-colour :gray92 235 235 235)
+(make-colour :grey92 235 235 235)
+(make-colour :gray93 237 237 237)
+(make-colour :grey93 237 237 237)
+(make-colour :gray94 240 240 240)
+(make-colour :grey94 240 240 240)
+(make-colour :gray95 242 242 242)
+(make-colour :grey95 242 242 242)
+(make-colour :gray96 245 245 245)
+(make-colour :grey96 245 245 245)
+(make-colour :gray97 247 247 247)
+(make-colour :grey97 247 247 247)
+(make-colour :gray98 250 250 250)
+(make-colour :grey98 250 250 250)
+(make-colour :gray99 252 252 252)
+(make-colour :grey99 252 252 252)
+(make-colour :gray100 255 255 255)
+(make-colour :grey100 255 255 255)
+(make-colour :dark-grey 169 169 169)
+(make-colour :darkgrey 169 169 169)
+(make-colour :dark-gray 169 169 169)
+(make-colour :darkgray 169 169 169)
+(make-colour :dark-blue 0 0 139)
+(make-colour :darkblue 0 0 139)
+(make-colour :dark-cyan 0 139 139)
+(make-colour :darkcyan 0 139 139)
+(make-colour :dark-magenta 139 0 139)
+(make-colour :darkmagenta 139 0 139)
+(make-colour :dark-red 139 0 0)
+(make-colour :darkred 139 0 0)
+(make-colour :light-green 144 238 144)
+(make-colour :lightgreen 144 238 144)
+;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
+
+(defpackage #:tcod-system
+	(:use #:cl #:asdf))
+
+(in-package #:tcod-system)
+
+(defsystem tcod
+    :description "CFFI for libtcod, a truecolour console library."
+    :author "moriarty4@gmail.com"
+    :components
+    ((:file "tcod") (:file "tcod-colours"))
+    :depends-on ("cffi"))
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;;;;;;;;;;;;;;;80
+
+(in-package :cl-user)
+
+
+;;;
+;;; Windows users: change the string "libtcod-mingw.dll" to reflect the name
+;;; of your libtcod library (DLL file).
+;;;
+;;; Colours are passed to C as integers. There is also a system mapping 
+;;; - make a colour from R, G, B values using COMPOSE-COLOUR.
+;;; - break down a colour into R, G and B values using DECOMPOSE-COLOUR.
+;;; - to start the colour system call START-COLOURS.
+;;; - to make a new colour and associate it with a name, use MAKE-COLOUR.
+
+
+
+
+(defpackage :tcod
+  (:use :cl :cffi)
+  (:export
+   #:*root*
+   #:+null+
+   ;; == Colours ==
+   #:start-colours
+   #:start-colors
+   #:colour
+   #:compose-colour
+   #:compose-color
+   #:decompose-colour
+   #:decompose-color
+   #:invert-colour
+   #:invert-color
+   #:colour->grayscale
+   #:color->grayscale
+   ;; == Console ==
+   #:console-wait-for-keypress
+   #:console-check-for-keypress
+   #:console-set-colour-control
+   #:console-set-color-control
+   #:console-flush
+   #:console-get-fading-colour
+   #:console-get-fading-color
+   #:console-get-fade
+   #:console-set-fade
+   #:console-get-char
+   #:console-get-fore
+   #:console-get-back
+   #:console-get-foreground-colour
+   #:console-get-background-colour
+   #:console-get-foreground-color
+   #:console-get-background-color
+   #:console-print-left
+   #:console-print-right
+   #:console-print-centre
+   #:console-print-left-rect
+   #:console-print-right-rect
+   #:console-print-centre-rect
+   #:console-print-frame
+   #:console-print-double-frame
+   #:console-put-char
+   #:console-put-char-ex
+   #:console-set-char
+   #:console-set-fore
+   #:console-set-back
+   #:console-clear
+   #:console-set-foreground-colour
+   #:console-set-background-colour
+   #:console-set-foreground-color
+   #:console-set-background-color
+   #:console-init-root
+   #:console-is-fullscreen?
+   #:console-set-fullscreen
+   #:console-is-window-closed?
+   #:console-credits
+   #:console-credits-render
+   #:console-set-custom-font
+   #:console-set-window-title
+   #:console-rect
+   #:colour-set-hsv
+   #:colour-get-hsv
+   #:colour-equals?
+   #:colour-add
+   #:colour-multiply
+   #:colour-multiply-scalar
+   #:colour-lerp
+   #:make-colour
+   #:color-set-hsv
+   #:color-get-hsv
+   #:color-equals?
+   #:color-add
+   #:color-multiply
+   #:color-multiply-scalar
+   #:color-lerp
+   #:make-color
+   #:keycode
+   #:drawing-character
+   #:colctrl
+   #:colctrl->char
+   #:background-flag
+   #:key
+   #:key-p
+   #:key-c
+   #:key-vk
+   #:key-lalt
+   #:key-ralt
+   #:key-lctrl
+   #:key-rctrl
+   #:key-shift
+   #:make-key
+   #:make-simple-key
+   #:same-keys?
+   #:key-state
+   #:key-pressed
+   #:console
+   #:is-key-pressed?
+   #:console-new
+   #:console-delete
+   #:console-get-width
+   #:console-get-height
+   #:console-blit
+   ;; == Unicode ==
+   ;; todo not yet implemented
+   ;; == Mouse ==
+   #:mouse
+   #:make-mouse
+   #:mouse-x
+   #:mouse-y
+   #:mouse-cx
+   #:mouse-cy
+   #:mouse-dx
+   #:mouse-dy
+   #:mouse-lbutton
+   #:mouse-mbutton
+   #:mouse-rbutton
+   #:mouse-lbutton-pressed
+   #:mouse-mbutton-pressed
+   #:mouse-rbutton-pressed
+   #:mouse-wheel-down
+   #:mouse-wheel-up
+   #:mouse-flags
+   #:mouse-move
+   #:mouse-get-status
+   ;; == Image ==
+   #:image-load
+   #:image-save
+   #:image-from-console
+   #:image-clear
+   #:image-put-pixel
+   #:image-blit
+   #:image-set-key-color
+   #:image-set-key-colour
+   ;; == Random ==
+   #:random-new
+   #:random-get-int
+   #:random-get-float
+   ;; == Noise ==
+   #:noise-new
+   #:noise-perlin
+   #:noise-fbm-perlin
+   #:noise-turbulence-perlin
+   #:noise-delete
+   ;; == System layer ==
+   #:sys-save-screenshot
+   #:sys-sleep-milli
+   #:sys-set-fps
+   #:sys-get-fps
+   #:sys-get-current-resolution
+   #:sys-flush
+   ))
+
+(in-package :tcod)
+
+;;; CFFI 0.10.0 started using Babel to "encode" strings. This breaks extended
+;;; ASCII characters when the default encoding scheme of :UTF-8 is used, ie C
+;;; will receive different characters from those which are sent to it by the
+;;; Lisp program. To actually pass the literal string to C, we need to change
+;;; the encoding scheme to ISO-8859-1.
+;;;
+
+(setf cffi:*default-foreign-encoding* :iso-8859-1)
+
+(define-foreign-library libtcod
+	(:unix "libtcod.so")
+	(:windows "libtcod-mingw.dll")
+	;; (:macintosh "name-of-libtcod-file-in-macos")
+	(t (:default "libtcod")))
+
+(defvar *libtcod-loaded* nil)
+
+(eval-when (:load-toplevel :execute)
+	(unless *libtcod-loaded*
+		(use-foreign-library libtcod)
+		(setf *libtcod-loaded* t)))
+
+(defvar *root* (null-pointer) "The root console.")
+(defparameter +NULL+ (null-pointer))
+(defconstant +NOISE-DEFAULT-HURST+ 0.5)
+(defconstant +NOISE-DEFAULT-LACUNARITY+ 2.0)
+
+
+;;; Foreign types.
+
+(defctype colournum :unsigned-int)
+
+(defcstruct colour  ; TCOD_color_t
+	(r :uint8)
+	(g :uint8)
+	(b :uint8))
+
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defun compose-colour (r g b)
+    "Given three integer values R, G and B, representing the red, green and
+blue components of a colour, return a 3 byte integer whose value is #xRRGGBB."
+    (+ (ash r 16) (ash g 8) b))
+  (defun compose-color (r g b) (compose-colour r g b)))
+
+
+(defun decompose-colour (num)
+  "Given a colournum #xRRGGBB, return R, G and B integer values
+as 3 separate return values."
+  (values
+	 (ash (logand num #xff0000) -16)
+	 (ash (logand num #x00ff00) -8)
+	 (logand num #x0000ff)))
+(defun decompose-color (num) (decompose-colour num))
+
+
+(defun invert-colour (num)
+  (multiple-value-bind (r g b) (decompose-colour num)
+    (compose-colour (- 255 r) (- 255 g) (- 255 b))))
+(defun invert-color (num) (invert-colour num))
+
+
+;; (defvar *black* (compose-colour 0 0 0))
+;; (defvar *dark-grey* (compose-colour 96 96 96))
+;; (defvar *grey* (compose-colour 196 196 196))
+;; (defvar *white* (compose-colour 255 255 255))
+;; (defvar *dark-blue* (compose-colour 40 40 128))
+;; (defvar *light-blue* (compose-colour 120 120 255))
+;; (defvar *dark-red* (compose-colour 128 0 0))
+;; (defvar *light-red* (compose-colour 255 100 50))
+;; (defvar *dark-brown* (compose-colour 32 16 0))
+;; (defvar *light-yellow* (compose-colour 255 255 150))
+;; (defvar *yellow* (compose-colour 255 255 0))
+;; (defvar *dark-yellow* (compose-colour 164 164 0))
+;; (defvar *green* (compose-colour 0 220 0))
+;; (defvar *orange* (compose-colour 255 150 0))
+;; (defvar *red* (compose-colour 255 0 0))
+;; (defvar *silver* (compose-colour 203 203 203))
+;; (defvar *gold* (compose-colour 255 255 102))
+;; (defvar *purple* (compose-colour 204 51 153))
+;; (defvar *dark-purple* (compose-colour 51 0 51))
+;; ;;; Colours not defined in TCOD.
+;; (defvar *slate-grey* (compose-colour #x80 #x80 #x80))
+;; (defvar *umber* (compose-colour #x80 #x40 0))
+;; (defvar *pink* (compose-colour 255 0 255))
+;; (defvar *chocolate* (compose-colour 210 105 30))
+;; ;;; ...etc...
+
+
+(defvar *colour-table* nil)
+(defvar *initial-colours*
+  `((:true-black	#x00 #x00 #x00)
+    (:true-pink		#xFF #x00 #xFF)
+    (:true-white	#xFF #xFF #xFF)
+    (:true-red		#xFF #x00 #x00)
+    (:true-green	#x00 #xFF #x00)
+    (:true-blue		#x00 #x00 #xFF)
+    (:black		#x00 #x00 #x00)
+    (:dark-grey 	96 96 96)
+    (:grey 		196 196 196)
+    (:white 		255 255 255)
+    (:blue		13 103 196)
+    (:dark-blue 	40 40 128)
+    (:light-blue 	120 120 255)
+    (:dark-red 		128 0 0)
+    (:light-red 	255 100 50)
+    (:dark-brown 	32 16 0)
+    (:light-yellow 	255 255 150)
+    (:yellow 		255 255 0)
+    (:dark-yellow 	164 164 0)
+    (:green 		0 220 0)
+    (:cyan		86 163 205)
+    (:orange 		255 150 0)
+    (:red 		255 0 0)
+    (:silver 		203 203 203)
+    (:gold 		255 255 102)
+    (:purple 		204 51 153)
+    (:dark-purple 	51 0 51)
+    ;; Colours not defined in TCOD.
+    (:slate-grey 	#x80 #x80 #x80)
+    (:umber 		#x80 #x40 0)
+    (:pink 		#xFF #x00 #xFF)
+    (:chocolate 	210 105 30)))
+
+;; TCOD_keycode_t
+(defcenum keycode
+	:NONE
+	:ESCAPE
+	:BACKSPACE
+	:TAB
+	:ENTER
+	:SHIFT
+	:CONTROL
+	:ALT
+	:PAUSE
+	:CAPSLOCK
+	:PAGEUP
+	:PAGEDOWN
+	:END
+	:HOME
+	:UP
+	:LEFT
+	:RIGHT
+	:DOWN
+	:PRINTSCREEN
+	:INSERT
+	:DELETE
+	:LWIN
+	:RWIN
+	:APPS
+	:key-0
+	:key-1
+	:key-2
+	:key-3
+	:key-4
+	:key-5
+	:key-6
+	:key-7
+	:key-8
+	:key-9
+	:KP0
+	:KP1
+	:KP2
+	:KP3
+	:KP4
+	:KP5
+	:KP6
+	:KP7
+	:KP8
+	:KP9
+	:KPADD
+	:KPSUB
+	:KPDIV
+	:KPMUL
+	:KPDEC
+	:KPENTER
+	:F1
+	:F2
+	:F3
+	:F4
+	:F5
+	:F6
+	:F7
+	:F8
+	:F9
+	:F10
+	:F11
+	:F12
+	:NUMLOCK
+	:SCROLLLOCK
+	:SPACE
+	:CHAR)
+
+
+;; TCOD_key_t
+(defcstruct key-press
+	(vk keycode)     ; character if vk == TCODK_CHAR else 0
+	(c :unsigned-char)
+	(flags :uint8))  ; does this correspond to a key press or key
+					; release event ?
+
+(defstruct key
+  (vk :none :type keyword)
+  (c #\null :type character)
+  (pressed nil :type boolean)
+  (lalt nil :type boolean)
+  (lctrl nil :type boolean)
+  (ralt nil :type boolean)
+  (rctrl nil :type boolean)
+  (shift nil :type boolean))
+
+
+(defun make-simple-key (ch)
+  (make-key :vk :char :c ch))
+
+
+(defun same-keys? (key1 key2)
+  (and (key-p key1) (key-p key2)
+       (eql (key-vk key1) (key-vk key2))
+       (eql (key-c key1) (key-c key2))
+       (eql (key-shift key1) (key-shift key2))
+       (eql (or (key-lalt key1) (key-ralt key1))
+	    (or (key-lalt key2) (key-ralt key2)))
+       (eql (or (key-lctrl key1) (key-rctrl key1))
+	    (or (key-lctrl key2) (key-rctrl key2)))))
+       
+
+
+(defcenum drawing-character
+	(:CHAR-HLINE 196)
+	(:CHAR-VLINE 179)
+	(:CHAR-NE 191) 
+	(:CHAR-NW 218) 
+	(:CHAR-SE 217) 
+	(:CHAR-SW 192)
+	(:CHAR-TEEW 180) 
+	(:CHAR-TEEE 195) 
+	(:CHAR-TEEN 193)
+	(:CHAR-TEES 194)
+	(:CHAR-CROSS 197)
+	;; Double walls
+	(:CHAR-DHLINE 205)
+	(:CHAR-DVLINE 186)
+	(:CHAR-DNE 187) 
+	(:CHAR-DNW 201) 
+	(:CHAR-DSE 188) 
+	(:CHAR-DSW 200)
+	(:CHAR-DTEEW 181) 
+	(:CHAR-DTEEE 198) 
+	(:CHAR-DTEEN 208)
+	(:CHAR-DTEES 210)
+	(:CHAR-DCROSS 206)
+	;; Blocks
+	(:CHAR-BLOCK1 178) 
+	(:CHAR-BLOCK2 177) 
+	(:CHAR-BLOCK3 176)
+	;; Arrows
+	(:CHAR-ARROW-N 24) 
+	(:CHAR-ARROW-S 25) 
+	(:CHAR-ARROW-E 26) 
+	(:CHAR-ARROW_W 27)
+	;; Arrows without tail
+	(:CHAR-ARROW2-N 30)
+	(:CHAR-ARROW2-S 31)
+	(:CHAR-ARROW2-E 16)
+	(:CHAR-ARROW2-W 17)
+	;; Double arrows
+	(:CHAR-DARROW2-H 29)
+	(:CHAR-DARROW2-V 18)
+	;; GUI stuff
+	(:CHAR-CHECKBOX-UNSET 224)
+	(:CHAR-CHECKBOX-SET 225)
+	(:CHAR-RADIO-UNSET 9)
+	(:CHAR-RADIO-SET 10)
+	;; Subpixel resolution kit
+	(:CHAR-SUBP-NW 226)
+	(:CHAR-SUBP-NE 227)
+	(:CHAR-SUBP-N 228)
+	(:CHAR-SUBP-SE 229)
+	(:CHAR-SUBP-DIAG 230)
+	(:CHAR-SUBP-E 231)
+	(:CHAR-SUBP-SW 232))
+
+
+;; TCOD_colctrl_t
+(defcenum colctrl
+	(:COLCTRL-1 1)
+	:COLCTRL-2
+	:COLCTRL-3
+	:COLCTRL-4
+	:COLCTRL-5
+	(:COLCTRL-NUMBER 5)
+	:COLCTRL-FORE-RGB
+	:COLCTRL-BACK-RGB
+	:COLCTRL-STOP )
+
+;; TCOD_bkgnd_flag_t
+(defcenum background-flag
+	:NONE
+	:SET
+	:MULTIPLY
+	:LIGHTEN
+	:DARKEN
+	:SCREEN
+	:COLOR-DODGE
+	:COLOR-BURN
+	:ADD
+	:ADDA
+	:BURN
+	:OVERLAY
+	:ALPH)
+
+
+(defcenum alignment
+	:LEFT
+	:CENTER
+	:RIGHT)
+
+
+(defcenum fov-algorithm
+    :FOV-BASIC
+  :FOV-DIAMOND
+  :FOV-SHADOW
+  :FOV-PERMISSIVE-0
+  :FOV-PERMISSIVE-1
+  :FOV-PERMISSIVE-2
+  :FOV-PERMISSIVE-3
+  :FOV-PERMISSIVE-4
+  :FOV-PERMISSIVE-5
+  :FOV-PERMISSIVE-6
+  :FOV-PERMISSIVE-7
+  :FOV-PERMISSIVE-8
+  :FOV-RESTRICTIVE
+  :NB-FOV-ALGORITHMS)
+
+
+(defbitfield key-state
+	(:KEY-PRESSED 1)
+	(:KEY-RELEASED 2))
+
+(defbitfield custom-font-flags
+	(:FONT-LAYOUT-ASCII-IN-COL 1)
+	(:FONT-LAYOUT-ASCII-IN-ROW 2)
+	(:FONT-TYPE-GREYSCALE 4)
+	(:FONT-LAYOUT-TCOD 8))
+
+
+;; TCOD_console_t
+(defctype console :pointer)
+
+;;#define TCOD_BKGND_ALPHA(alpha) 
+;;((TCOD_bkgnd_flag_t)(TCOD_BKGND_ALPH|(((uint8)(alpha*255))<<8)))
+(defun background-alpha (alpha)
+  (foreign-enum-keyword 'background-flag
+			(logior (foreign-enum-value 'background-flag :alph)
+				(ash (mod (* alpha 255) 256) 8))))
+
+;;
+;;#define TCOD_BKGND_ADDALPHA(alpha) 
+;;((TCOD_bkgnd_flag_t)(TCOD_BKGND_ADDA|(((uint8)(alpha*255))<<8)))
+(defun background-add-alpha (alpha)
+  (foreign-enum-keyword 'background-flag
+			(logior (foreign-enum-value 'background-flag :adda)
+				(ash (mod (* alpha 255) 256) 8))))
+
+
+(defun start-colours ()
+  (setf *colour-table* (make-hash-table :test #'eql))
+  (dolist (term *initial-colours*)
+    (destructuring-bind (name r g b) term
+      (make-colour name r g b))))
+(defun start-colors () (start-colours))
+
+
+(defun make-colour (kwd r g b)
+  (unless (hash-table-p *colour-table*)
+    (start-colours))
+  (setf (gethash kwd *colour-table*)
+	(compose-colour r g b)))
+(defun make-color (kwd r g b) (make-colour kwd r g b))
+
+
+(defun colour->grayscale (col)
+  (multiple-value-bind (r g b) (decompose-colour col)
+    (let ((brightness (round (+ r g b) 3)))
+      (compose-colour brightness brightness brightness))))
+(defun color->grayscale (col) (colour->grayscale col))
+  
+
+(defun colour (keywd)
+  "Given a colour keyword such as :GREY, return its corresponding RGB
+value (#xRRGGBB)."
+  (cond
+    ((integerp keywd)
+     keywd)
+    (t
+     (unless *colour-table*
+       (start-colours))
+     (gethash keywd *colour-table*))))
+(defun color (keywd) (colour keywd))
+
+
+(defun colctrl->char (ctrl)
+  (code-char (foreign-enum-value 'colctrl ctrl)))
+
+      
+;; TCODLIB_API bool TCOD_color_equals (TCOD_color_t c1, TCOD_color_t c2); 
+(defcfun ("TCOD_color_equals_wrapper" color-equals?) :boolean
+	(c1 colournum) (c2 colournum))
+(defun colour-equals? (c1 c2) (color-equals? c1 c2))
+
+
+;;TCODLIB_API TCOD_color_t TCOD_color_add (TCOD_color_t c1, TCOD_color_t c2);
+(defcfun ("TCOD_color_add_wrapper" color-add) colournum
+	(c1 colournum) (c2 colournum))
+(defun colour-add (c1 c2) (color-add c1 c2))
+
+
+;;TCODLIB_API TCOD_color_t TCOD_color_multiply (TCOD_color_t c1,
+;; TCOD_color_t c2); 
+(defcfun ("TCOD_color_multiply_wrapper" color-multiply) colournum
+	(c1 colournum) (c2 colournum))
+(defun colour-multiply (c1 c2) (color-multiply c1 c2))
+
+
+;;TCODLIB_API TCOD_color_t TCOD_color_multiply_scalar (TCOD_color_t c1,
+;; float value);
+(defcfun ("TCOD_color_multiply_scalar_wrapper" color-multiply-scalar) colournum
+	(c1 colournum) (value :float))
+(defun colour-multiply-scalar (c1 value) (color-multiply-scalar c1 value))
+
+
+;; TCODLIB_API TCOD_color_t TCOD_color_lerp(TCOD_color_t c1, TCOD_color_t c2,
+;; float coef);
+(defcfun ("TCOD_color_lerp_wrapper" color-lerp) colournum
+	(c1 colournum) (c2 colournum) (coef :float))
+(defun colour-lerp (c1 c2 coef) (color-lerp c1 c2 coef))
+
+
+;; TCODLIB_API void TCOD_color_set_HSV(TCOD_color_t *c,float h, float s,
+;; float v);
+(defcfun ("TCOD_color_set_HSV" color-set-hsv) :void
+	(c :pointer) (h :float) (s :float) (v :float))
+(defun colour-set-hsv (c h s v) (color-set-hsv c h s v))
+
+
+;; TCODLIB_API void TCOD_color_get_HSV(TCOD_color_t c,float * h, float * s,
+;; float * v);
+
+(defvar *internal-color-hue-ptr* (foreign-alloc :int))
+(defvar *internal-color-saturation-ptr* (foreign-alloc :int))
+(defvar *internal-color-value-ptr* (foreign-alloc :int))
+
+(defcfun ("TCOD_color_get_HSV_wrapper" %color-get-hsv) :void
+	(c colournum) (h :pointer) (s :pointer) (v :pointer))
+
+(defun color-get-hsv (color)
+    (%color-get-hsv color
+		    *internal-color-hue-ptr*
+		    *internal-color-saturation-ptr*
+		    *internal-color-value-ptr*)
+    (list (mem-ref *internal-color-hue-ptr* :int)
+	  (mem-ref *internal-color-saturation-ptr* :int)
+	  (mem-ref *internal-color-value-ptr* :int)))
+
+(defun colour-get-hsv (colour) (color-get-hsv colour))
+
+(defcfun ("TCOD_console_credits" console-credits) :void)
+
+(defcfun ("TCOD_console_credits_render" console-credits-render) :boolean
+  (x :int) (y :int) (alpha :boolean))
+
+
+;;TCODLIB_API void TCOD_console_init_root(int w, int h, const char * title,
+;;                                        bool fullscreen);
+(defcfun ("TCOD_console_init_root" console-init-root) :void
+	(w :int) (h :int) (title :string) (fullscreen :boolean))
+
+;;TCODLIB_API void TCOD_console_set_custom_font(const char *fontFile,
+;;                        int char_width, int char_height, int nb_char_horiz,
+;;                        int nb_char_vertic, bool chars_by_row,
+;;                        TCOD_color_t key_color);
+(defcfun ("TCOD_console_set_custom_font" %console-set-custom-font) :void
+	(fontfile :string) (flags custom-font-flags)
+	(chars-horizontal :int) (chars-vertical :int)
+	)
+;; (nb-char-vertic :int)
+;; 	(chars-by-row? :boolean) (key-colour colournum))
+
+
+(defun console-set-custom-font (fontfile flags chars-horizontal chars-vertical)
+  "FLAGS accepts a quoted list containing one or more of the symbols
+:FONT-LAYOUT-ASCII-IN-ROW, :FONT-LAYOUT-ASCII-IN-COL, :FONT-TYPE-GREYSCALE,
+or :FONT-LAYOUT-TCOD."
+  (assert (probe-file fontfile))
+  (%console-set-custom-font fontfile flags chars-horizontal chars-vertical))
+
+
+;;TCODLIB_API void TCOD_console_set_window_title(const char *title);
+(defcfun ("TCOD_console_set_window_title" console-set-window-title) :void
+  (title :string))
+
+;;TCODLIB_API void TCOD_console_set_fullscreen(bool fullscreen);
+(defcfun ("TCOD_console_set_fullscreen" console-set-fullscreen) :void
+  (full? :boolean))
+
+;;TCODLIB_API bool TCOD_console_is_fullscreen();
+(defcfun ("TCOD_console_is_fullscreen" console-is-fullscreen?) :boolean)
+
+;;TCODLIB_API bool TCOD_console_is_window_closed();
+(defcfun ("TCOD_console_is_window_closed" console-is-window-closed?) :boolean)
+
+
+;;TCODLIB_API void TCOD_console_set_background_color(TCOD_console_t con,
+;; TCOD_color_t col);
+(defcfun ("TCOD_console_set_background_color_wrapper"
+	  console-set-background-color) :void
+	(con console) (col colournum))
+(defun console-set-background-colour (con col)
+  (console-set-background-color con col))
+
+
+;;TCODLIB_API void TCOD_console_set_foreground_color(TCOD_console_t con,
+;;                                                   TCOD_color_t col);
+(defcfun ("TCOD_console_set_foreground_color_wrapper"
+	  console-set-foreground-color) :void
+	(con console) (col colournum))
+(defun console-set-foreground-colour (con col)
+  (console-set-foreground-color con col))
+
+
+;;TCODLIB_API void TCOD_console_clear(TCOD_console_t con);
+(defcfun ("TCOD_console_clear" console-clear) :void
+	(con console))
+
+
+;;TCODLIB_API void TCOD_console_set_back(TCOD_console_t con,int x, int y,
+;;                                       TCOD_color_t col,
+;;                                       TCOD_bkgnd_flag_t flag);
+(defcfun ("TCOD_console_set_back_wrapper" console-set-back) :void
+  (con console) (x :int) (y :int) (col colournum) (flag background-flag))
+
+;;TCODLIB_API void TCOD_console_set_fore(TCOD_console_t con,int x, int y,
+;;                                       TCOD_color_t col);
+(defcfun ("TCOD_console_set_fore_wrapper" console-set-fore) :void
+  (con console) (x :int) (y :int) (col colournum))
+ 
+;;TCODLIB_API void TCOD_console_set_char(TCOD_console_t con,int x, int y,
+;; int c);
+(defcfun ("TCOD_console_set_char" console-set-char) :void
+  (con console) (x :int) (y :int) (c :unsigned-char))
+
+;;TCODLIB_API void TCOD_console_put_char(TCOD_console_t con,int x, int y,
+;;                                       int c, TCOD_bkgnd_flag_t flag);
+(defcfun ("TCOD_console_put_char" console-put-char) :void
+	(con console) (x :int) (y :int) (c :unsigned-char)
+	(flag background-flag))
+
+;;TCODLIB_API void TCOD_console_put_char_ex(TCOD_console_t con,int x, int y,
+;;                                          int c, TCOD_bkgnd_flag_t flag);
+(defcfun ("TCOD_console_put_char_ex_wrapper" console-put-char-ex) :void
+	(con console) (x :int) (y :int) (c :unsigned-char)
+	(fg colournum) (bg colournum))
+
+;;TCODLIB_API void TCOD_console_print_left(TCOD_console_t con,int x, int y,
+;;                                         TCOD_bkgnd_flag_t flag,
+;;                                         const char *fmt, ...); 
+(defcfun ("TCOD_console_print_left" %console-print-left) :void
+	(con console) (x :int) (y :int) (flag background-flag) (fmt :string)
+	&rest)
+
+(defun console-print-left (con x y flag fmt &rest args)
+  (%console-print-left con x y flag (apply #'format nil fmt args)))
+
+(defcfun ("TCOD_console_print_return_string"
+	  %console-print-return-string) :string
+	(con console) (x :int) (y :int) (rw :int) (rh :int)
+	(flag background-flag) (align alignment) (msg :string)
+	(can-split? :boolean) (count-only? :boolean))
+
+(defun console-print-return-string (con x y rw rh flag align msg can-split?
+				    count-only?)
+  (%console-print-return-string con x y rw rh flag align msg
+				can-split? count-only?))
+
+;;TCODLIB_API void TCOD_console_print_right(TCOD_console_t con,int x, int y,
+;; TCOD_bkgnd_flag_t flag, const char *fmt, ...); 
+(defcfun ("TCOD_console_print_right" console-print-right) :void
+	(con console) (x :int) (y :int) (flag background-flag) (fmt :string)
+	&rest)
+
+;;TCODLIB_API void TCOD_console_print_center(TCOD_console_t con,int x, int y,
+;; TCOD_bkgnd_flag_t flag, const char *fmt, ...); 
+(defcfun ("TCOD_console_print_center" console-print-centre) :void
+	(con console) (x :int) (y :int) (flag background-flag) (fmt :string)
+	&rest)
+
+;;TCODLIB_API int TCOD_console_print_left_rect(TCOD_console_t con,int x, int y,
+;; int w, int h, TCOD_bkgnd_flag_t flag, const char *fmt, ...); 
+(defcfun ("TCOD_console_print_left_rect" console-print-left-rect) :int
+	(con console) (x :int) (y :int) (w :int) (h :int)
+	(flag background-flag) (fmt :string)
+	&rest)
+
+;;TCODLIB_API int TCOD_console_print_right_rect(TCOD_console_t con,int x,
+;; int y, int w, int h, TCOD_bkgnd_flag_t flag, const char *fmt, ...); 
+(defcfun ("TCOD_console_print_right_rect" console-print-right-rect) :int
+	(con console) (x :int) (y :int) (w :int) (h :int)
+	(flag background-flag) (fmt :string)
+	&rest)
+
+
+;;TCODLIB_API int TCOD_console_print_center_rect(TCOD_console_t con,int x,
+;; int y, int w, int h, TCOD_bkgnd_flag_t flag, const char *fmt, ...); 
+(defcfun ("TCOD_console_print_center_rect" console-print-centre-rect) :int
+	(con console) (x :int) (y :int) (w :int) (h :int)
+	(flag background-flag) (fmt :string)
+	&rest)
+
+;;TCODLIB_API void TCOD_console_rect(TCOD_console_t con,int x, int y, int w,
+;; int h, bool clear, TCOD_bkgnd_flag_t flag);
+(defcfun ("TCOD_console_rect" console-rect) :void
+  (con console) (x :int) (y :int) (w :int) (h :int) (clear? :boolean)
+  (flag background-flag))
+
+;;TCODLIB_API void TCOD_console_hline(TCOD_console_t con,int x,int y, int l,
+;; TCOD_bkgnd_flag_t flag);
+;;TCODLIB_API void TCOD_console_vline(TCOD_console_t con,int x,int y, int l,
+;; TCOD_bkgnd_flag_t flag);
+
+;;TCODLIB_API void TCOD_console_print_frame(TCOD_console_t con,int x,int y,
+;; int w,int h, bool empty, const char *fmt, ...);
+(defcfun ("TCOD_console_print_frame" console-print-frame) :void
+  (con console) (x :int) (y :int) (w :int) (h :int)
+  (empty? :boolean) (flag background-flag) (fmt :string) &rest)
+
+;; Added in wrappers.c
+(defcfun ("TCOD_console_print_double_frame" console-print-double-frame) :void
+  (con console) (x :int) (y :int) (w :int) (h :int)
+  (empty? :boolean) (flag background-flag) (fmt :string) &rest)
+
+;;TCODLIB_API TCOD_color_t TCOD_console_get_background_color(TCOD_console_t con);
+(defcfun ("TCOD_console_get_background_color"
+	  console-get-background-color) colournum
+  (con console))
+(defun console-get-background-colour (con)
+  (console-get-background-color con))
+
+
+;;TCODLIB_API TCOD_color_t TCOD_console_get_foreground_color(TCOD_console_t con);
+(defcfun ("TCOD_console_get_foreground_color"
+	  console-get-foreground-color) colournum
+  (con console))
+(defun console-get-foreground-colour (con)
+  (console-get-foreground-color con))
+
+
+;;TCODLIB_API TCOD_color_t TCOD_console_get_back(TCOD_console_t con,int x, int y)
+(defcfun ("TCOD_console_get_back_wrapper" console-get-back) colournum
+  (con console) (x :int) (y :int))
+
+;;TCODLIB_API TCOD_color_t TCOD_console_get_fore(TCOD_console_t con,
+;;                                               int x, int y);
+(defcfun ("TCOD_console_get_fore_wrapper" console-get-fore) colournum
+  (con console) (x :int) (y :int))
+
+;;TCODLIB_API int TCOD_console_get_char(TCOD_console_t con,int x, int y);
+(defcfun ("TCOD_console_get_char" console-get-char) :unsigned-char
+  (con console) (x :int) (y :int))
+
+;;TCODLIB_API void TCOD_console_set_fade(uint8 val, TCOD_color_t fade);
+(defcfun ("TCOD_console_set_fade_wrapper" console-set-fade) :void
+  (val :uint8) (fade colournum))
+
+;;TCODLIB_API uint8 TCOD_console_get_fade();
+(defcfun ("TCOD_console_get_fade" console-get-fade) :uint8)
+
+
+;;TCODLIB_API TCOD_color_t TCOD_console_get_fading_color();
+(defcfun ("TCOD_console_get_fading_color_wrapper"
+	  console-get-fading-color) colournum)
+(defun console-get-fading-colour ()
+  (console-get-fading-color))
+
+
+;;TCODLIB_API void TCOD_console_flush();
+(defcfun ("TCOD_console_flush" console-flush) :void)
+
+;; (sys-flush t) forces a redraw of the whole root console.
+(defcfun ("TCOD_sys_flush" sys-flush) :void
+	(flag :boolean))
+
+;;TCODLIB_API void TCOD_console_set_color_control(TCOD_colctrl_t con,
+;;     TCOD_color_t fore, TCOD_color_t back);
+(defcfun ("TCOD_console_set_color_control_wrapper"
+	  console-set-color-control) :void
+  (con colctrl) (fore colournum) (back colournum))
+(defun console-set-colour-control (con fore back)
+  (console-set-color-control con fore back))
+
+
+;;TCODLIB_API TCOD_key_t TCOD_console_check_for_keypress(int flags);
+(defcfun ("TCOD_console_check_for_keypress_wrapper"
+	  %console-check-for-keypress) :boolean
+	(keyptr key-press) (flags key-state))
+
+
+(defun get-bit (n pos)
+  "POS = 1 refers to the 1's bit"
+  (/= 0 (logand n (expt 2 (1- pos)))))
+
+
+(defun key->keypress (keyptr)
+  (let ((flags (foreign-slot-value keyptr 'key-press 'flags)))
+    (make-key :vk (foreign-slot-value keyptr 'key-press 'vk)
+	      :c (code-char (foreign-slot-value keyptr 'key-press 'c))
+	      :pressed (get-bit flags 1)
+	      :lalt (get-bit flags 2)
+	      :lctrl (get-bit flags 3)
+	      :ralt (get-bit flags 4)
+	      :rctrl (get-bit flags 5)
+	      :shift (get-bit flags 6))))
+
+
+(defvar *key* nil)
+
+(defun console-check-for-keypress (flags)
+  (unless *key*
+    (setf *key* (foreign-alloc 'key-press)))
+  (%console-check-for-keypress *key* flags)
+  (unless (eql :none (foreign-slot-value *key* 'key-press 'vk))
+    (key->keypress *key*)))
+
+(defun console-wait-for-keypress (flush)
+  (unless *key*
+    (setf *key* (foreign-alloc 'key-press)))
+  (%console-wait-for-keypress *key* flush)
+  (key->keypress *key*))
+
+
+;;TCODLIB_API TCOD_key_t TCOD_console_wait_for_keypress(bool flush);
+(defcfun ("TCOD_console_wait_for_keypress_wrapper"
+	  %console-wait-for-keypress) :void
+	(keyptr key-press) (flush :boolean))
+
+;;TCODLIB_API void TCOD_console_set_keyboard_repeat(int initial_delay,
+;; int interval);
+;;TCODLIB_API void TCOD_console_disable_keyboard_repeat();
+;;TCODLIB_API bool TCOD_console_is_key_pressed(TCOD_keycode_t key);
+(defcfun ("TCOD_console_is_key_pressed" is-key-pressed?) :boolean
+  (code keycode))
+
+;;TCODLIB_API TCOD_console_t TCOD_console_new(int w, int h);
+(defcfun ("TCOD_console_new" console-new) console
+  (w :int) (h :int))
+
+;;TCODLIB_API int TCOD_console_get_width(TCOD_console_t con);
+(defcfun ("TCOD_console_get_width" console-get-width) :int
+  (con console))
+
+;;TCODLIB_API int TCOD_console_get_height(TCOD_console_t con);
+(defcfun ("TCOD_console_get_height" console-get-height) :int
+  (con console))
+
+;;TCODLIB_API void TCOD_console_blit(TCOD_console_t src,int xSrc, int ySrc,
+;; int wSrc, int hSrc, TCOD_console_t dst, int xDst, int yDst, int fade);
+(defcfun ("TCOD_console_blit" console-blit) :void
+  (src console)
+  (xsrc :int) (ysrc :int)
+  (wsrc :int) (hsrc :int)
+  (dest console)
+  (xdest :int) (ydest :int)
+  (foreground-alpha :float) (background-alpha :float))
+
+;;TCODLIB_API void TCOD_console_delete(TCOD_console_t console);
+(defcfun ("TCOD_console_delete" console-delete) :void
+  (con console))
+
+;;; sys.h
+
+;;TCODLIB_API uint32 TCOD_sys_elapsed_milli();
+;;TCODLIB_API float TCOD_sys_elapsed_seconds();
+;;TCODLIB_API void TCOD_sys_sleep_milli(uint32 val);
+(defcfun ("TCOD_sys_sleep_milli" sys-sleep-milli) :void
+  (val :unsigned-int))
+
+;;TCODLIB_API void TCOD_sys_save_screenshot(const char *filename);
+(defcfun ("TCOD_sys_save_screenshot" %sys-save-screenshot) :void
+  (filename :string))
+
+(defun sys-save-screenshot (&optional (filename (null-pointer)))
+  (%sys-save-screenshot filename))
+
+;;TCODLIB_API void TCOD_sys_force_fullscreen_resolution(int width, int height);
+;;TCODLIB_API void TCOD_sys_set_fps(int val);
+(defcfun ("TCOD_sys_set_fps" sys-set-fps) :void
+  (val :int))
+
+;;TCODLIB_API int TCOD_sys_get_fps();
+(defcfun ("TCOD_sys_get_fps" sys-get-fps) :int)
+
+;;TCODLIB_API float TCOD_sys_get_last_frame_length();
+;;TCODLIB_API void TCOD_sys_get_current_resolution(int *w, int *h);
+(defvar *internal-width-ptr* (foreign-alloc :int))
+(defvar *internal-height-ptr* (foreign-alloc :int))
+
+(defcfun ("TCOD_sys_get_current_resolution" %sys-get-current-resolution) :void
+  (w-ptr :pointer) (h-ptr :pointer))
+
+(defun sys-get-current-resolution ()
+  (%sys-get-current-resolution *internal-width-ptr* *internal-height-ptr*)
+  (values (mem-ref *internal-width-ptr* :int)
+	  (mem-ref *internal-height-ptr* :int)))
+
+;;; mersenne.h
+
+;; TCOD_random_t
+(defctype randomptr :pointer)
+
+;;TCODLIB_API TCOD_random_t TCOD_random_get_instance();
+;;TCODLIB_API TCOD_random_t TCOD_random_new();
+(defcfun ("TCOD_random_new" random-new) randomptr)
+
+;;TCODLIB_API TCOD_random_t TCOD_random_new_from_seed(uint32 seed);
+;;TCODLIB_API int TCOD_random_get_int(TCOD_random_t mersenne, int min, int max);
+(defcfun ("TCOD_random_get_int" random-get-int) :int
+  (rng randomptr) (min :int) (max :int))
+
+;;TCODLIB_API float TCOD_random_get_float(TCOD_random_t mersenne, float min,
+;;   float max);
+(defcfun ("TCOD_random_get_float" random-get-float) :float
+  (rng randomptr) (min :float) (max :float))
+
+;;TCODLIB_API int TCOD_random_get_int_from_byte_array(int min, int max,
+;;   const char *data,int len);
+;;TCODLIB_API void TCOD_random_delete(TCOD_random_t mersenne);
+
+;;; mouse.h
+
+(defcstruct mouse-state
+	(x :int)	
+	(y :int)	
+	(dx :int)	
+	(dy :int)
+	(cx :int)	
+	(cy :int)
+	(dcx :int)	
+	(dcy :int)
+	(flags :uint8))
+
+(defstruct mouse
+	(x 0 :type integer)	;; absolute position
+	(y 0 :type integer)	
+	(dx 0 :type integer)	;; movement since last update in pixels
+	(dy 0 :type integer)
+	(cx 0 :type integer)	;; cell coordinates in the root console 
+	(cy 0 :type integer)
+	(dcx 0 :type integer)	;; movement since last update in console cells
+	(dcy 0 :type integer)
+	(lbutton nil :type boolean)	;; left button status
+	(rbutton nil :type boolean)	;; right button status
+	(mbutton nil :type boolean) ;; middle button status
+	(lbutton-pressed nil :type boolean)	;; left button pressed event
+	(rbutton-pressed nil :type boolean)	;; right button pressed event
+	(mbutton-pressed nil :type boolean)	;; middle button pressed event
+	(wheel-up nil :type boolean)		;; wheel up event
+	(wheel-down nil :type boolean)   ;; wheel down event 
+	(flags 0 :type integer))	;; copied from mouse-state
+
+
+(defun mouse-state->mouse (ms)
+  (let ((flags (foreign-slot-value ms 'mouse-state 'flags)))
+    (make-mouse :x (foreign-slot-value ms 'mouse-state 'x)
+		:y (foreign-slot-value ms 'mouse-state 'y)
+		:dx (foreign-slot-value ms 'mouse-state 'dx)
+		:dy (foreign-slot-value ms 'mouse-state 'dy)
+		:cx (foreign-slot-value ms 'mouse-state 'cx)
+		:cy (foreign-slot-value ms 'mouse-state 'cy)
+		:dcx (foreign-slot-value ms 'mouse-state 'dcx)
+		:dcy (foreign-slot-value ms 'mouse-state 'dcy)
+		:lbutton (get-bit flags 1)
+		:rbutton  (get-bit flags 2)
+		:mbutton (get-bit flags 3)
+		:lbutton-pressed (get-bit flags 4)
+		:rbutton-pressed  (get-bit flags 5)
+		:mbutton-pressed (get-bit flags 6)
+		:wheel-up (get-bit flags 7)
+		:wheel-down (get-bit flags 8)
+		:flags flags)))
+
+	      
+;;TCODLIB_API TCOD_mouse_t TCOD_mouse_get_status();
+(defcfun ("TCOD_mouse_get_status_wrapper" %mouse-get-status) :void
+  (mouseptr mouse-state))
+
+(let ((rodent nil))
+  (defun mouse-get-status ()
+    (unless rodent
+      (setf rodent (foreign-alloc 'mouse-state)))
+    (%mouse-get-status rodent)
+    (mouse-state->mouse rodent)))
+
+
+;;TCODLIB_API void TCOD_mouse_show_cursor(bool visible);
+;;TCODLIB_API bool TCOD_mouse_is_cursor_visible();
+;;TCODLIB_API void TCOD_mouse_move(int x, int y);
+(defcfun ("TCOD_mouse_move" mouse-move) :void
+  (x :int) (y :int))
+
+
+;;; image.h
+
+;; TCOD_image_t
+(defctype image :pointer)
+
+;;TCODLIB_API TCOD_image_t TCOD_image_new(int width, int height);
+;;TCODLIB_API TCOD_image_t TCOD_image_from_console(TCOD_console_t console);
+(defcfun ("TCOD_image_from_console" image-from-console) image
+  (con console))
+
+;;TCODLIB_API TCOD_image_t TCOD_image_load(const char *filename);
+(defcfun ("TCOD_image_load" image-load) image
+  (filename :string))
+
+
+;;TCODLIB_API void TCOD_image_clear(TCOD_image_t image, TCOD_color_t color);
+(defcfun ("TCOD_image_clear_wrapper" image-clear) :void
+  (image image) (color colournum))
+
+;;TCODLIB_API void TCOD_image_save(TCOD_image_t image, const char *filename);
+(defcfun ("TCOD_image_save" image-save) :void
+  (image image) (filename :string))
+
+
+;;TCODLIB_API void TCOD_image_get_size(TCOD_image_t image, int *w,int *h);
+;;TCODLIB_API TCOD_color_t TCOD_image_get_pixel(TCOD_image_t image,int x, int y);
+(defcfun ("TCOD_image_get_pixel_wrapper" image-get-pixel) colournum
+  (image image) (x :int) (y :int))
+
+;;TCODLIB_API TCOD_color_t TCOD_image_get_mipmap_pixel(TCOD_image_t image,
+;; float x0,float y0, float x1, float y1);
+(defcfun ("TCOD_image_get_mipmap_pixel_wrapper"
+	  image-get-mipmap-pixel) colournum
+  (image image) (x0 :float) (y0 :float) (x1 :float) (y1 :float))
+
+;;TCODLIB_API void TCOD_image_put_pixel(TCOD_image_t image,int x, int y,
+;; TCOD_color_t col);
+(defcfun ("TCOD_image_put_pixel_wrapper" image-put-pixel) :void
+  (image image) (x :int) (y :int) (col colournum))
+
+;;TCODLIB_API void TCOD_image_blit(TCOD_image_t image, TCOD_console_t console,
+;; float x, float y, 
+;;	TCOD_bkgnd_flag_t bkgnd_flag, float scalex, float scaley, float angle);
+(defcfun ("TCOD_image_blit" image-blit) :void
+  (image image) (con console) (x :float) (y :float) (flag background-flag)
+  (scalex :float) (scaley :float) (angle :float))
+
+
+;;TCODLIB_API void TCOD_image_blit_rect(TCOD_image_t image,
+;; TCOD_console_t console, int x, int y, int w, int h, 
+;;	TCOD_bkgnd_flag_t bkgnd_flag);
+(defcfun ("TCOD_image_blit_rect" image-blit-rect) :void
+  (image image) (con console) (x :int) (y :int) (w :int) (h :int)
+  (flag background-flag))
+
+
+;;TCODLIB_API void TCOD_image_delete(TCOD_image_t image);
+;;TCODLIB_API void TCOD_image_set_key_color(TCOD_image_t image,
+;; TCOD_color_t key_color);
+(defcfun ("TCOD_image_set_key_color" image-set-key-color) :void
+  (image image) (key-color colournum))
+(defun image-set-key-colour (image key-colour)
+  (image-set-key-color image key-colour))
+
+
+;;TCODLIB_API bool TCOD_image_is_pixel_transparent(TCOD_image_t image, int x,
+;;  int y);
+
+
+;;; ========
+;;;  Noise
+;;; ========
+
+(defctype noise :pointer)
+
+;; TCODLIB_API TCOD_noise_t TCOD_noise_new(int dimensions, float hurst,
+;; float lacunarity, TCOD_random_t random);
+;; For randomptr, use +NULL+ to use the default RNG
+(defcfun ("TCOD_noise_new" %noise-new) noise
+  (dimensions :int) (hurst :float) (lacunarity :float) (randomptr :pointer))
+
+(defun noise-new (dimensions &key (hurst +NOISE-DEFAULT-HURST+)
+		  (lacunarity +NOISE-DEFAULT-LACUNARITY+)
+		  (rng +NULL+))
+  (%noise-new dimensions hurst lacunarity rng))
+
+
+;; // basic perlin noise
+;; TCODLIB_API float TCOD_noise_get( TCOD_noise_t noise, float *f );
+(defcfun ("TCOD_noise_perlin" %noise-perlin) :float
+  (noise noise) (f :pointer))
+
+(defun noise-perlin (noise &rest nums)
+  (with-foreign-object (f :float (length nums))
+    (dotimes (i (length nums))
+      (setf (mem-aref f :float i) (coerce (nth i nums) 'single-float)))
+    (%noise-perlin noise f)))
+
+
+;; // fractional brownian motion
+;; TCODLIB_API float TCOD_noise_fbm( TCOD_noise_t noise, float *f,
+;; float octaves );
+(defcfun ("TCOD_noise_fbm_perlin" %noise-fbm-perlin) :float
+  (noise noise) (f :pointer) (octaves :float))
+
+(defun noise-fbm-perlin (noise octaves &rest nums)
+  (with-foreign-object (f :float (length nums))
+    (dotimes (i (length nums))
+      (setf (mem-aref f :float i) (coerce (nth i nums) 'single-float)))
+    (%noise-fbm-perlin noise f octaves)))
+
+;; // turbulence
+;; TCODLIB_API float TCOD_noise_turbulence( TCOD_noise_t noise,
+;;   float *f, float octaves );
+(defcfun ("TCOD_noise_turbulence_perlin" %noise-turbulence-perlin) :float
+  (noise noise) (f :pointer) (octaves :float))
+
+(defun noise-turbulence-perlin (noise octaves &rest nums)
+  (with-foreign-object (f :float (length nums))
+    (dotimes (i (length nums))
+      (setf (mem-aref f :float i) (coerce (nth i nums) 'single-float)))
+    (%noise-turbulence-perlin noise f octaves)))
+
+
+;; TCODLIB_API void TCOD_noise_delete(TCOD_noise_t noise);
+(defcfun ("TCOD_noise_delete" noise-delete) :void
+  (noise noise))
+
+
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.