
; letterfall/font.sscm - 40x25 8-bit retro font
; Copyright (C) 2012 Alan Manuel K. Gloria
;
; This file is part of Letterfall.
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY, without even the implied warranty of
; MERCHANTIBILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program.  If not, see <http://www.gnu.org/licenses/>

define-module
  letterfall font
  :export
  \\
    font-data

; uppercase letter font
define uppercase
  vector
    vector
      #b00011000 ; A
      #b00111100
      #b01100110
      #b01111110
      #b01111110
      #b01100110
      #b01100110
      #b00000000
    vector
      #b01111100 ; B
      #b01111110
      #b01100110
      #b01111100
      #b01100110
      #b01111110
      #b01111100
      #b00000000
    vector
      #b00111100 ; C
      #b01111110
      #b01100000
      #b01100000
      #b01100000
      #b01111110
      #b00111100
      #b00000000
    vector
      #b01111100 ; D
      #b01111110
      #b01100110
      #b01100110
      #b01100110
      #b01111110
      #b01111100
      #b00000000
    vector
      #b01111110 ; E
      #b01111110
      #b01100000
      #b01111100
      #b01100000
      #b01111110
      #b01111110
      #b00000000
    vector
      #b01111110 ; F
      #b01111110
      #b01100000
      #b01111110
      #b01111110
      #b01100000
      #b01100000
      #b00000000
    vector
      #b00111100 ; G
      #b01111110
      #b01100000
      #b01101111
      #b01100110
      #b01111110
      #b00111010
      #b00000000
    vector
      #b01100110 ; H
      #b01100110
      #b01100110
      #b01111110
      #b01100110
      #b01100110
      #b01100110
      #b00000000
    vector
      #b01111110 ; I
      #b00011000
      #b00011000
      #b00011000
      #b00011000
      #b00011000
      #b01111110
      #b00000000
    vector
      #b00001110 ; J
      #b00000110
      #b00000110
      #b00000110
      #b00000110
      #b01111110
      #b01111100
      #b00000000
    vector
      #b01100110 ; K
      #b01100110
      #b01101100
      #b01111000
      #b01101100
      #b01100110
      #b01100110
      #b00000000
    vector
      #b01100000 ; L
      #b01100000
      #b01100000
      #b01100000
      #b01100000
      #b01111110
      #b01111110
      #b00000000
    vector
      #b01100011 ; M
      #b01110111
      #b01111111
      #b01101011
      #b01100011
      #b01100011
      #b01100011
      #b00000000
    vector
      #b01100110 ; N
      #b01110110
      #b01111110
      #b01111110
      #b01101110
      #b01100110
      #b01100110
      #b00000000
    vector
      #b00111100 ; O
      #b01111110
      #b01100110
      #b01100110
      #b01100110
      #b01111110
      #b00111100
      #b00000000
    vector
      #b01111100 ; P
      #b01111110
      #b01100110
      #b01111110
      #b01111100
      #b01100000
      #b01100000
      #b00000000
    vector
      #b00111100 ; Q
      #b01111110
      #b01100110
      #b01100110
      #b01100110
      #b01111110
      #b00111100
      #b00000111
    vector
      #b01111100 ; R
      #b01111110
      #b01100110
      #b01111110
      #b01111100
      #b01100110
      #b01100110
      #b00000000
    vector
      #b00111110 ; S
      #b01111110
      #b01100000
      #b00111100
      #b00000110
      #b01111110
      #b01111100
      #b00000000
    vector
      #b01111110 ; T
      #b01111110
      #b00011000
      #b00011000
      #b00011000
      #b00011000
      #b00011000
      #b00000000
    vector
      #b01100110 ; U
      #b01100110
      #b01100110
      #b01100110
      #b01100110
      #b01111110
      #b00111100
      #b00000000
    vector
      #b01100110 ; V
      #b01100110
      #b01100110
      #b01100110
      #b00111100
      #b00111100
      #b00011000
      #b00000000
    vector
      #b01100011 ; W
      #b01100011
      #b01100011
      #b01101011
      #b01111111
      #b01110111
      #b01100011
      #b00000000
    vector
      #b01100110 ; X
      #b01100110
      #b00111100
      #b00011000
      #b00111100
      #b01100110
      #b01100110
      #b00000000
    vector
      #b01100110 ; Y
      #b01100110
      #b01100110
      #b00111100
      #b00011000
      #b00011000
      #b00011000
      #b00000000
    vector
      #b01111110 ; Z
      #b01111110
      #b00000110
      #b00011000
      #b01100000
      #b01111110
      #b01111110
      #b00000000
define digit
  vector
    vector
      #b00111100 ; 0
      #b01111110
      #b01101110
      #b01110110
      #b01100110
      #b01111110
      #b00111100
      #b00000000
    vector
      #b00011000 ; 1
      #b00111000
      #b01111000
      #b00011000
      #b00011000
      #b00011000
      #b01111110
      #b00000000
    vector
      #b00111100 ; 2
      #b01111110
      #b00000110
      #b00011000
      #b01100000
      #b01111110
      #b01111110
      #b00000000
    vector
      #b01111100 ; 3
      #b01111110
      #b00000110
      #b00111100
      #b00000110
      #b01111110
      #b01111100
      #b00000000
    vector
      #b00011110 ; 4
      #b00111110
      #b01100110
      #b01111111
      #b01111111
      #b00000110
      #b00000110
      #b00000000
    vector
      #b01111110 ; 5
      #b01111110
      #b01100000
      #b01111100
      #b00000110
      #b01111110
      #b01111100
      #b00000000
    vector
      #b00111100 ; 6
      #b01111110
      #b01100000
      #b01111100
      #b01100110
      #b01111110
      #b00111100
      #b00000000
    vector
      #b01111110 ; 7
      #b01111110
      #b00000110
      #b00001100
      #b00011000
      #b00110000
      #b00110000
      #b00000000
    vector
      #b00111100 ; 8
      #b01111110
      #b01100110
      #b00111100
      #b01100110
      #b01111110
      #b00111100
      #b00000000
    vector
      #b00111100 ; 9
      #b01111110
      #b01100110
      #b00111110
      #b00000110
      #b01100110
      #b00111100
      #b00000000

; specific symbols
define dash-font
    vector
      #b00000000 ; -
      #b00000000
      #b00000000
      #b01111111
      #b00000000
      #b00000000
      #b00000000
      #b00000000
define apos-font
    vector
      #b00011000 ; '
      #b00011000
      #b00011000
      #b00000000
      #b00000000
      #b00000000
      #b00000000
      #b00000000
define space-font
  make-vector 8 #b00000000
define colon-font
    vector
      #b00000000 ; :
      #b00000000
      #b00011100
      #b00011100
      #b00000000
      #b00011100
      #b00011100
      #b00000000
define asterisk-font
    vector
      #b00001000 ; *
      #b00101010
      #b00011100
      #b01111111
      #b00011100
      #b00101010
      #b00001000
      #b00000000
define bang-font
    vector
      #b00011000 ; !
      #b00011000
      #b00011000
      #b00011000
      #b00000000
      #b00011000
      #b00011000
      #b00000000
define dot-font
    vector
      #b00000000 ; .
      #b00000000
      #b00000000
      #b00000000
      #b00000000
      #b00011000
      #b00011000
      #b00000000
define slash-font
    vector
      #b00000110 ; /
      #b00001100
      #b00001100
      #b00011000
      #b00110000
      #b00110000
      #b01100000
      #b00000000
define backslash-font
    vector
      #b01100000 ; \
      #b00110000
      #b00110000
      #b00011000
      #b00001100
      #b00001100
      #b00000110
      #b00000000

define font-data(c)
  let
    $ n $ char->integer c
    cond
      {{ 64 < n } and { n <= { 64 + 26 }}}
        vector-ref uppercase { n - 64 - 1 }
      {{ 96 < n } and { n <= { 96 + 26 }}}
        vector-ref uppercase { n - 96 - 1 } ; use uppercase font for now
      {{ 48 <= n } and { n <= { 48 + 9 }}}
        vector-ref digit { n - 48 }
      { c char=? #\- }
        dash-font
      { c char=? #\' }
        apos-font
      { c char=? #\: }
        colon-font
      { c char=? #\* }
        asterisk-font
      { c char=? #\! }
        bang-font
      { c char=? #\. }
        dot-font
      { c char=? #\/}
        slash-font
      { c char=? #\\}
        backslash-font
      #t
        space-font

; vim: set ft=scheme : ;
