#!/bin/ksh

#check for packages
need_this="git ecl"
for i in $need_this ; do
case $i in
        $i) [ ! -a /usr/local/bin/$i ] && (print "you need $i"; print "consider
# pkg_add $i" ;exit);;
esac
done

#check if directories exist, otherwise mkdir and git clone
[ ! -d ~/common-lisp ] && mkdir ~/common-lisp/
cd ~/common-lisp
[ ! -d lispusers ] && git clone https://codeberg.org/tfw/lispusers.git

print /files/fish.pbm | nc triapul.cz 70 > fish.pbm

ecl << EOG | less
(require :asdf)
(asdf:load-system :lispusers/tfw/low/pbm)
(in-package :lispusers/tfw/low/pbm)
(loop initially
 (defvar *arr* (pbm2arr #p"fish.pbm"))
 (defvar *edges* (loop for n from 0
                  for oldbit = nil then bit
                  for bit across *arr*
                  when (and oldbit (not (equal bit oldbit)))
                  collect n))
 for fgc = (code-char #x2620) for bgc = #\space
 for count from 0 to (expt 80 2)
 for fgp = nil then
 (if (and edges (= count (car edges)))
  (progn (pop edges) (not fgp)) fgp)
 for edges = (copy-list *edges*) then edges
 when (zerop (mod count 80)) do (terpri)
 when fgp do (princ fgc) unless fgp do (princ bgc)
 finally (uiop:quit))
EOG