%                       .--###-.       ______
%                      /         \    /   _/
%                     /  _        \  /  _/
%                    /  (_)        \/  / 
%                    \      __     /\ K
%                     \   \  _\   /  \ \
%                      \___\/----'    \_\
%
%	K-fish!
%
% (C) 2002 Patryk Zadarnowski, or whoever else feels like owning some useless
% TeX code. All rights reserved pantswide.
%
% We must do our own line buffering, as TeX puts spaces between \message
% output:
\newcount\tmpcounter
\def\gets#1{\message{#1}\read-1}%
\def\puts#1{\xdef\linebuf{\linebuf #1}}%
\def\putsn#1#2{{\tmpcounter=#1 \edef\outchar{#2}\doput}}%
\def\doput{\ifnum\tmpcounter>0 \puts{\outchar}\advance\tmpcounter by -1
 \let\next=\doput\else\let\next=\relax\fi\next}%
\def\flush{\immediate\write16{\linebuf}\gdef\linebuf{}}%
\def\putline#1{\xdef\linebuf{}\puts{#1}\flush}%
\def\linebuf{}%
%
%%% The easy way of outputting backslash:
{\catcode"20=12 \gdef\ { }}%
{\catcode"23=12 \gdef\#{#}}%
{\catcode"5F=12 \gdef\_{_}}%
\begingroup\catcode`/=0 \relax
 /catcode"5C=12 /gdef/\{\}%
 /endgroup
%
%%% Prompt for the K-fish size:
\putline{K-fish generator}%
\putline{(C) 2002 Patryk Zadarnowski, Slarken Labs International.}%
\putline{All rights reserved Pantswise.}%
\putline{}%
\newcount\kfishsize
\def\getfish{\gets{Please enter the size of your Kfish: } to \n
 \ifnum\n<7 \putline{K-fish must be at least 7!}\let\next=\getfish
  \else\global\kfishsize=\n\let\next=\relax\fi\next}%
\getfish
\ifodd\kfishsize\else\advance\kfishsize by -1\fi
%
%%% Compute the left margin
\newcount\left
\left=80
\advance\left by -\kfishsize
\advance\left by -\kfishsize
\advance\left by -\kfishsize
\advance\left by -\kfishsize
\ifnum\left<14 \left=7 \else\divide\left by 2 \fi
%
\newcount\halfkfishsize
\halfkfishsize=\kfishsize
\divide\halfkfishsize by 2
%
\newcount\quaterkfishsize
\quaterkfishsize=\halfkfishsize
\divide\quaterkfishsize by 2
\ifodd\halfkfishsize\advance\quaterkfishsize by 1 \fi
%
\newcount\sixthkfishsize
\sixthkfishsize=\kfishsize
\divide\sixthkfishsize by 6
%
%%% K-fish!
\putline{}%
\putline{}%
\putsn\left{ }%
\putsn\halfkfishsize{ }%
\puts{.}%
\tmpcounter=\kfishsize
\divide\tmpcounter by 3
\putsn{\tmpcounter}{-}%
\tmpcounter=\kfishsize
\divide\tmpcounter by 3
\multiply\tmpcounter by -2
\advance\tmpcounter by \kfishsize
\putsn{\tmpcounter}{\#}%
\tmpcounter=\kfishsize
\divide\tmpcounter by 3
\advance\tmpcounter by -1
\putsn{\tmpcounter}{-}%
\puts{.}%
\putsn{\kfishsize}{ }%
\tmpcounter=\halfkfishsize
\multiply\tmpcounter by \sixthkfishsize
\advance\tmpcounter by 3
\putsn{\tmpcounter}{\_}%
\flush
\newcount\row
\def\top{%
 \putsn\left{ }%
 \tmpcounter=\halfkfishsize
 \advance\tmpcounter by -\row
 \putsn{\tmpcounter}{ }%
 \puts{/}%
 \tmpcounter=\row
 \advance\tmpcounter by -1
 \putsn{\tmpcounter}{ }
 \ifnum\row=\halfkfishsize
  \puts{(_)}%
 \else
  \tmpcounter\halfkfishsize
  \advance\tmpcounter by -1
  \ifnum\row=\tmpcounter
   \puts{ \_ }%
  \else
   \putsn3{ }%
  \fi
 \fi
 \tmpcounter=\kfishsize
 \advance\tmpcounter by -2
 \advance\tmpcounter by \row
 \putsn{\tmpcounter}{ }%
 \puts{\\}%
 \tmpcounter=\halfkfishsize
 \advance\tmpcounter by -\row
 \multiply\tmpcounter by 2
 \putsn{\tmpcounter}{ }%
 \puts{/}%
 \tmpcounter=\halfkfishsize
 \advance\tmpcounter by -\row
 \multiply\tmpcounter by \sixthkfishsize
 \advance\tmpcounter by 1
 \putsn{\tmpcounter}{ }%
 \ifnum\row=\halfkfishsize
  \putsn\sixthkfishsize{ }%
 \else
  \putsn\sixthkfishsize{\_}%
 \fi
 \puts{/}%
 \flush}%
\def\outtop{%
 \ifnum\row>\halfkfishsize\let\next=\relax
  \else\top\advance\row by 1 \let\next=\outtop\fi\next}%
\row=1
\outtop
\def\bot{%
 \putsn\left{ }%
 \tmpcounter=\row
 \advance\tmpcounter by -1
 \putsn{\tmpcounter}{ }%
 \puts{\\}%
 \ifnum\row=\halfkfishsize
  \putsn\halfkfishsize{\_}%
 \else
  \putsn\halfkfishsize{ }%
 \fi
 \ifnum\row=1
  \putsn\halfkfishsize{ }%
  \tmpcounter=\halfkfishsize
  \advance\tmpcounter by -1
  \putsn{\tmpcounter}{\_}%
  \tmpcounter=\kfishsize
  \advance\tmpcounter by -\halfkfishsize
  \advance\tmpcounter by 1
  \putsn{\tmpcounter}{ }%
  \puts{/}%
 \else
  \puts{\\}%
  \tmpcounter=\halfkfishsize
  \advance\tmpcounter by -\row
  \multiply\tmpcounter by 2
  \putsn{\tmpcounter}{ }%
  \ifnum\row>\quaterkfishsize
   \puts{/}%
   \tmpcounter=\kfishsize
   \advance\tmpcounter by -\halfkfishsize
   \ifnum\row=\halfkfishsize
    \putsn{\tmpcounter}{-}%
    \puts{'}%
   \else
    \putsn{\tmpcounter}{ }%
    \puts{/}%
   \fi
  \else
   \tmpcounter=\row
   \advance\tmpcounter by -2
   \multiply\tmpcounter by 2
   \advance\tmpcounter by 1
   \ifnum\row=\quaterkfishsize
    \putsn{\tmpcounter}{\_}%
   \else
    \putsn{\tmpcounter}{ }%
   \fi
   \puts{\\}%
   \multiply\tmpcounter by -1
   \advance\tmpcounter by \kfishsize
   \advance\tmpcounter by -\halfkfishsize   
   \putsn{\tmpcounter}{ }%
   \puts{/}%
  \fi
 \fi
 \tmpcounter=\row
 \advance\tmpcounter by -1
 \multiply\tmpcounter by 2
 \putsn{\tmpcounter}{ }%
 \puts{\\}%
 \ifnum\row=\halfkfishsize
  \putsn\sixthkfishsize{\_}%
 \else
  \putsn\sixthkfishsize{ }%
 \fi
 \ifnum\row=1
  \puts{K}%
 \else
  \puts{\\}%
 \fi
 \flush}%
\def\outbot{%
 \ifnum\row>\halfkfishsize\let\next=\relax
  \else\bot\advance\row by 1 \let\next=\outbot\fi\next}%
\row=1
\outbot
%
%%% Some important usage instructions:
\flush
\putline{}%
\putline{}%
\putline{Please enjoy your K-fish wisely and in moderation.}%
\putline{}%
\putline{\ \ \ \ \ \ \ \ \ FISH!}%
\putline{}%
\end
