Outdated egg!
This is an egg for CHICKEN 3, the unsupported old release. You're almost certainly looking for the CHICKEN 4 version of this egg, if it exists.
If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.
aalib
Straightforward bindings to the aalib ASCII rendering library.
Requirements
Exported bindings
aa:ALL -> INT aa:BACKSPACE -> INT aa:BOLD -> INT aa:BOLD-MASK -> INT aa:BOLDFONT -> INT aa:BOLDFONT-MASK -> INT aa:BUTTON1 -> INT aa:BUTTON2 -> INT aa:BUTTON3 -> INT aa:DIM -> INT aa:DIM-MASK -> INT aa:DITHERTYPES -> INT aa:DOWN -> INT aa:EIGHT -> INT aa:ERRORDISTRIB -> INT aa:ESC -> INT aa:EXTENDED -> INT aa:FLOYD-S -> INT aa:HIDECURSOR -> INT aa:KBDALLMASK -> INT aa:LEFT -> INT aa:LIB-MINNOR -> INT aa:LIB-VERSION -> INT aa:LIB-VERSIONCODE -> INT aa:MOUSE -> INT aa:MOUSEALLMASK -> INT aa:MOUSEMOVEMASK -> INT aa:MOUSEPRESSMASK -> INT aa:NATTRS -> INT aa:NONE -> INT aa:NORMAL -> INT aa:NORMAL-MASK -> INT aa:NORMAL-SPACES -> INT aa:NPARAMS -> INT aa:PRESSEDMOVEMASK -> INT aa:RELEASE -> INT aa:RESIZE -> INT aa:REVERSE -> INT aa:REVERSE-MASK -> INT aa:RIGHT -> INT aa:SENDRELEASE -> INT aa:SPECIAL -> INT aa:UNKNOWN -> INT aa:UP -> INT aa:USE-PAGES -> INT aa:ansi-format -> FORMAT aa:hp-format -> FORMAT aa:hp2-format -> FORMAT aa:html-alt-format -> FORMAT aa:html-format -> FORMAT aa:irc-format -> FORMAT aa:more-format -> FORMAT aa:nhtml-format -> FORMAT aa:text-format -> FORMAT aa:zephyr-format -> FORMAT
aa:defparams -> PARAMS aa:defrenderparams -> RENDERPARAMS aa:mem-d -> DRIVER aa:save-d -> DRIVER aa:linux-d -> DRIVER ; only on Linux aa:stdout-d -> DRIVER aa:stderr-d -> DRIVER aa:X11-d -> DRIVER aa:kbd-curses-d -> KBDRIVER aa:kbd-stdin-d -> KBDRIVER aa:kbd-X11-d -> KBDRIVER aa:mouse-curses-d -> MOUSEDRIVER aa:mouse-X11-d -> MOUSEDRIVER
aa:font8 -> FONT aa:font14 -> FONT aa:font16 -> FONT aa:font9 -> FONT aa:fontline -> FONT aa:fontgl -> FONT aa:fontX13 -> FONT aa:fontX16 -> FONT aa:fontX13B -> FONT aa:fontcourier -> FONT
(aa:autoinit PARAMS) -> CONTEXT (aa:autoinitkbd CONTEXT MODE) -> INT (aa:autoinitmouse CONTEXT MODE) -> INT (aa:close CONTEXT) (aa:createedit CONTEXT X Y SIZE STRING MAXSIZE) -> EDIT (aa:edit CONTEXT X Y SIZE STRING MAXSIZE) (aa:editkey EDIT INT) (aa:fastrender CONTEXT X1 Y1 X2 Y2) (aa:flush CONTEXT) (aa:getevent CONTEXT WAIT?) -> INT (aa:getkey CONTEXT WAIT?) -> INT (aa:getmouse CONTEXT) -> X Y BUTTONS (aa:getpixel CONTEXT X Y) -> INT (aa:getpixel* CONTEXT POS) -> INT ; POS = index in row-major order (aa:getrenderparams) -> PARAMS (aa:gotoxy CONTEXT X Y) (aa:hidecursor CONTEXT) (aa:hidemouse CONTEXT) (aa:image CONTEXT) -> POINTER (aa:imgheight CONTEXT) -> INT (aa:imgwidth CONTEXT) -> INT (aa:init DRIVER PARAMS DATA) -> CONTEXT (aa:initkbd CONTEXT KBDRIVER MODE) -> INT (aa:initmouse CONTEXT MOUSEDRIVER MODE) -> INT (aa:mmheight CONTEXT) -> INT (aa:mmwidth CONTEXT) -> INT (aa:printf CONTEXT X Y ATTR FSTRING X ...) -> INT (aa:putpixel CONTEXT X Y COLOR) (aa:putpixel* CONTEXT POS COLOR) ; POS = index in row-major order (aa:puts CONTEXT X Y ATTR STRING) (aa:registerfont FONT) -> INT (aa:render CONTEXT RENDERPARAMS X1 Y1 X2 Y2) (aa:renderpalette CONTEXT S32VECTOR RENDERPARAMS X1 Y1 X2 Y2) (aa:resize CONTEXT) -> INT (aa:resizehandler CONTEXT FUNCTIONPTR) ; FUNCTIONPTR = callback accepting CONTEXT (aa:scrheight CONTEXT) -> INT (aa:scrwidth CONTEXT) -> INT (aa:setfont CONTEXT FONT) (aa:setpalette S32VECTOR INDEX R G B) (aa:setsupported CONTEXT SUPPORTED) (aa:showcursor CONTEXT) (aa:showmouse CONTEXT) (aa:uninitkbd CONTEXT) (aa:uninitmouse CONTEXT)
For more information see, the aalib documentation.
Example
;;;; fire.scm - The popular "fire" demo ; ; For maximum performance compile like this: ; ; csc -O3 -d0 fire.scm (declare (fixnum) (block) (disable-interrupts)) (use aalib srfi-4) (define-constant +maxtable+ (* 256 5)) (define-constant +ma+ 5) (define *context* (aa:autoinit aa:defparams)) (assert *context* "Failed to initialize aalib") (aa:autoinitkbd *context* 0) (define *params* (aa:getrenderparams)) (define *palette* (make-s32vector 256)) (define *pal* '#(0 0 0 0 0 6 0 0 6 0 0 7 0 0 8 0 0 8 0 0 9 0 0 10 2 0 10 4 0 9 6 0 9 8 0 8 10 0 7 12 0 7 14 0 6 16 0 5 18 0 5 20 0 4 22 0 4 24 0 3 26 0 2 28 0 2 30 0 1 32 0 0 32 0 0 33 0 0 34 0 0 35 0 0 36 0 0 36 0 0 37 0 0 38 0 0 39 0 0 40 0 0 40 0 0 41 0 0 42 0 0 43 0 0 44 0 0 45 0 0 46 1 0 47 1 0 48 2 0 49 2 0 50 3 0 51 3 0 52 4 0 53 4 0 54 5 0 55 5 0 56 6 0 57 6 0 58 7 0 59 7 0 60 8 0 61 8 0 63 9 0 63 9 0 63 10 0 63 10 0 63 11 0 63 11 0 63 12 0 63 12 0 63 13 0 63 13 0 63 14 0 63 14 0 63 15 0 63 15 0 63 16 0 63 16 0 63 17 0 63 17 0 63 18 0 63 18 0 63 19 0 63 19 0 63 20 0 63 20 0 63 21 0 63 21 0 63 22 0 63 22 0 63 23 0 63 24 0 63 24 0 63 25 0 63 25 0 63 26 0 63 26 0 63 27 0 63 27 0 63 28 0 63 28 0 63 29 0 63 29 0 63 30 0 63 30 0 63 31 0 63 31 0 63 32 0 63 32 0 63 33 0 63 33 0 63 34 0 63 34 0 63 35 0 63 35 0 63 36 0 63 36 0 63 37 0 63 38 0 63 38 0 63 39 0 63 39 0 63 40 0 63 40 0 63 41 0 63 41 0 63 42 0 63 42 0 63 43 0 63 43 0 63 44 0 63 44 0 63 45 0 63 45 0 63 46 0 63 46 0 63 47 0 63 47 0 63 48 0 63 48 0 63 49 0 63 49 0 63 50 0 63 50 0 63 51 0 63 52 0 63 52 0 63 52 0 63 52 0 63 52 0 63 53 0 63 53 0 63 53 0 63 53 0 63 54 0 63 54 0 63 54 0 63 54 0 63 54 0 63 55 0 63 55 0 63 55 0 63 55 0 63 56 0 63 56 0 63 56 0 63 56 0 63 57 0 63 57 0 63 57 0 63 57 0 63 57 0 63 58 0 63 58 0 63 58 0 63 58 0 63 59 0 63 59 0 63 59 0 63 59 0 63 60 0 63 60 0 63 60 0 63 60 0 63 60 0 63 61 0 63 61 0 63 61 0 63 61 0 63 62 0 63 62 0 63 62 0 63 62 0 63 63 0 63 63 1 63 63 2 63 63 3 63 63 4 63 63 5 63 63 6 63 63 7 63 63 8 63 63 9 63 63 10 63 63 10 63 63 11 63 63 12 63 63 13 63 63 14 63 63 15 63 63 16 63 63 17 63 63 18 63 63 19 63 63 20 63 63 21 63 63 21 63 63 22 63 63 23 63 63 24 63 63 25 63 63 26 63 63 27 63 63 28 63 63 29 63 63 30 63 63 31 63 63 31 63 63 32 63 63 33 63 63 34 63 63 35 63 63 36 63 63 37 63 63 38 63 63 39 63 63 40 63 63 41 63 63 42 63 63 42 63 63 43 63 63 44 63 63 45 63 63 46 63 63 47 63 63 48 63 63 49 63 63 50 63 63 51 63 63 52 63 63 52 63 63 53 63 63 54 63 63 55 63 63 56 63 63 57 63 63 58 63 63 59 63 63 60 63 63 61 63 63 62 63 63 63) ) (do ((i 0 (add1 i))) ((>= i 256)) (aa:setpalette *palette* i (* 4 (vector-ref *pal* (* i 3))) (* 4 (vector-ref *pal* (+ 1 (* i 3)))) (* 4 (vector-ref *pal* (+ 2 (* i 3)))) ) ) (aa:hidecursor *context*) (define *xsize* (aa:imgwidth *context*)) (define *ysize* (- (aa:imgheight *context*) 4)) (define *table* (make-u32vector +maxtable+)) (define (gentable) (let ((minus (fx/ 800 *ysize*))) (when (zero? minus) (set! minus 1)) (do ((i 0 (add1 i))) ((>= i +maxtable+)) (u32vector-set! *table* i (if (> i minus) (fx/ (fx- i minus) 5) 0) ) ) ) ) (define (firemain) (let ((pixels (fx* *xsize* *ysize*))) (do ((p 0 (add1 p))) ((>= p pixels)) (aa:putpixel* *context* p (u32vector-ref *table* (+ (aa:getpixel* *context* (+ p *xsize* -1)) (aa:getpixel* *context* (+ p *xsize* 1)) (aa:getpixel* *context* (+ p *xsize*)) (aa:getpixel* *context* (+ p (* 2 *xsize*) -1)) (aa:getpixel* *context* (+ p (* 2 *xsize*) 1)) ) ) ) ) ) ) (define drawfire (let ((height 0) (sloop 0) (iloop 0) ) (lambda () (let ((n (* *xsize* (add1 *ysize*)))) (set! height (add1 height)) (set! iloop (sub1 iloop)) (when (negative? iloop) (set! iloop (random 3)) (set! sloop (add1 sloop)) ) (do ((i1 1 (+ i1 4)) (i2 (add1 (* 4 *xsize*)) (- i2 4)) (p (* *xsize* *ysize*) (add1 p)) ) ((>= p n)) (let ((last1 (random (min i1 i2 height)))) (do ((i (random 6) (sub1 i))) ((or (>= p n) (zero? i))) (aa:putpixel* *context* p last1) (set! last1 (+ last1 (random 6) -2)) (aa:putpixel* *context* (+ p *xsize*) last1) (set! last1 (+ last1 (random 6) -2)) (set! p (add1 p)) (set! i1 (+ i1 4)) (set! i2 (- i2 4)) ) ) ) (firemain) (aa:renderpalette *context* *palette* *params* 0 0 (aa:scrwidth *context*) (aa:scrheight *context*)) (aa:flush *context*) ) ) ) ) (define (game) (gentable) (do () ((not (eq? (aa:getevent *context* #f) aa:NONE))) (drawfire) ) ) (game) (aa:close *context*)
>
Author
License
Copyright (c) 2007, Felix L. Winkelmann All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Version History
- 0.1
- Initial version