%%%%%%%%%%%%%%%%%%%%%%%% go.sty %%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % written by Hanna Kolodziejska (version 0.05 : November 1991) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Several changes introduced by Paul Miller (aka jettero). % $Id: jgo.sty,v 1.12 2004/01/25 15:52:19 jettero Exp $ % % Janruary 12th: \jpos{d}{4}=\black{1} puts a stone labeled % 1 on the lower left hoshi, and % \jpos{q}{16}=\white{2} is in the upper right. % This is different than the \pos behavior. % - Along with the help of (aka) Nichus, left hand % row labels were added to the diagrams % Janruary 13th: Added column lables along the bottom % Janruary 14th: Added the interval reversal code so (9..3) = % (3..9) automagically % Janruary 16th: Decided the finish of \jshowdiagram is over my % head. Appologies, the use of \showdiagram may % be confusing, but it's workable. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \catcode`@=11 \newbox\@gobox \newdimen\@godimen \def\gofontsize#1{ \font\gofont=go#1 at #1truept \font\blackfontOne=go1bla#1 at #1truept \font\blackfontTwo=go2bla#1 at #1truept \font\whitefontOne=go1whi#1 at #1truept \font\whitefontTwo=go2whi#1 at #1truept \ifnum #1=10 \font\letterfont=cmr10 at 10truept\else %%% <--- ??? \ifnum #1=15 \font\letterfont=cmr10 at 14.4truept\else %%% <--- ??? \ifnum #1=20 \font\letterfont=cmr10 at 17.28truept\fi\fi\fi \setbox\@gobox=\hbox{\gofont\char0} \@godimen=\wd\@gobox } \gofontsize{10} % initialization <--- \def\newgoline{\hfill\break} \def\hoshi{\gofont\char0} \def\empty{\gofont\char1} \def\lftborder{\gofont\char2} \def\rtborder{\gofont\char3} \def\topborder{\gofont\char4} \def\botborder{\gofont\char5} \def\lfttopcorner{\gofont\char6} \def\rttopcorner{\gofont\char7} \def\lftbotcorner{\gofont\char8} \def\rtbotcorner{\gofont\char9} \def\triangle{\whitefontTwo\char127} %%% \def\square{\whitefontTwo\char126} %%% \newcount\n \newcount\@beglet \newcount\@endlet \newcount\@lettercount \newcount\x \newcount\y \def\@letternumber#1{\relax \ifx #1a\@lettercount=1\else \ifx #1b\@lettercount=2\else \ifx #1c\@lettercount=3\else \ifx #1d\@lettercount=4\else \ifx #1e\@lettercount=5\else \ifx #1f\@lettercount=6\else \ifx #1g\@lettercount=7\else \ifx #1h\@lettercount=8\else \ifx #1i\@lettercount=9\else \ifx #1j\@lettercount=9\else \ifx #1k\@lettercount=10\else \ifx #1l\@lettercount=11\else \ifx #1m\@lettercount=12\else \ifx #1n\@lettercount=13\else \ifx #1o\@lettercount=14\else \ifx #1p\@lettercount=15\else \ifx #1q\@lettercount=16\else \ifx #1r\@lettercount=17\else \ifx #1s\@lettercount=18\else \ifx #1t\@lettercount=19\else \errmessage{Row label must be letter, not '#1'!} \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi } \def\inidiagram#1-#2:#3-#4 {\relax \@letternumber{#1} \@beglet=\@lettercount \@letternumber{#2} \@endlet=\@lettercount \ifnum #4>#3 \x=#3\y=#4 \else \y=#3\x=#4 \fi \ifnum \@beglet>\@endlet \n=\@endlet\@endlet=\@beglet\@beglet=\n\fi \def\@inirow##1##2{{\n=\x \loop \expandafter\let\csname @##1\romannumeral\n \endcsname=0\relax \edef\@@inirow{\global \def\csname @##1\romannumeral\n \endcsname{##2}}\@@inirow \ifnum \n<\y \advance \n by 1 \repeat }}\relax \loop \ifcase\@beglet\relax\or \@inirow{a}{\topborder}\relax \ifnum #3=1 \global\def\@ai{\lfttopcorner}\fi \ifnum #4=19 \global\def\@axix{\rttopcorner}\fi \or \@inirow{b}{\empty}\relax \ifnum #3=1 \global\def\@bi{\lftborder}\fi \ifnum #4=19 \global\def\@bxix{\rtborder}\fi \or \@inirow{c}{\empty}\relax \ifnum #3=1 \global\def\@ci{\lftborder}\fi \ifnum #4=19 \global\def\@cxix{\rtborder}\fi \or \@inirow{d}{\empty}\relax \ifnum #3=1 \global\def\@di{\lftborder}\fi \ifnum #3<5 \ifnum #4>3 \global\def\@div{\hoshi}\fi\fi \ifnum #3<11 \ifnum #4>9 \global\def\@dx{\hoshi}\fi\fi \ifnum #3<17 \ifnum #4>15 \global\def\@dxvi{\hoshi}\fi\fi \ifnum #4=19 \global\def\@dxix{\rtborder}\fi \or \@inirow{e}{\empty} \ifnum #3=1 \global\def\@ei{\lftborder}\fi \ifnum #4=19 \global\def\@exix{\rtborder}\fi \or \@inirow{f}{\empty} \ifnum #3=1 \global\def\@fi{\lftborder}\fi \ifnum #4=19 \global\def\@fxix{\rtborder}\fi \or \@inirow{g}{\empty} \ifnum #3=1 \global\def\@gi{\lftborder}\fi \ifnum #4=19 \global\def\@gxix{\rtborder}\fi \or \@inirow{h}{\empty} \ifnum #3=1 \global\def\@hi{\lftborder}\fi \ifnum #4=19 \global\def\@hxix{\rtborder}\fi \or \@inirow{j}{\empty} \ifnum #3=1 \global\def\@ji{\lftborder}\fi \ifnum #4=19 \global\def\@jxix{\rtborder}\fi \or \@inirow{k}{\empty} \ifnum #3=1 \global\def\@ki{\lftborder}\fi \ifnum #3<5 \ifnum #4>3 \global\def\@kiv{\hoshi}\fi\fi \ifnum #3<11 \ifnum #4>9 \global\def\@kx{\hoshi}\fi\fi \ifnum #3<17 \ifnum #4>15 \global\def\@kxvi{\hoshi}\fi\fi \ifnum #4=19 \global\def\@kxix{\rtborder}\fi \or \@inirow{l}{\empty} \ifnum #3=1 \global\def\@li{\lftborder}\fi \ifnum #4=19 \global\def\@lxix{\rtborder}\fi \or \@inirow{m}{\empty} \ifnum #3=1 \global\def\@mi{\lftborder}\fi \ifnum #4=19 \global\def\@mxix{\rtborder}\fi \or \@inirow{n}{\empty} \ifnum #3=1 \global\def\@ni{\lftborder}\fi \ifnum #4=19 \global\def\@nxix{\rtborder}\fi \or \@inirow{o}{\empty} \ifnum #3=1 \global\def\@oi{\lftborder}\fi \ifnum #4=19 \global\def\@oxix{\rtborder}\fi \or \@inirow{p}{\empty} \ifnum #3=1 \global\def\@pi{\lftborder}\fi \ifnum #4=19 \global\def\@pxix{\rtborder}\fi \or \@inirow{q}{\empty} \ifnum #3=1 \global\def\@qi{\lftborder}\fi \ifnum #3<5 \ifnum #4>3 \global\def\@qiv{\hoshi}\fi\fi \ifnum #3<11 \ifnum #4>9 \global\def\@qx{\hoshi}\fi\fi \ifnum #3<17 \ifnum #4>15 \global\def\@qxvi{\hoshi}\fi\fi \ifnum #4=19 \global\def\@qxix{\rtborder}\fi \or \@inirow{r}{\empty} \ifnum #3=1 \global\def\@ri{\lftborder}\fi \ifnum #4=19 \global\def\@rxix{\rtborder}\fi \or \@inirow{s}{\empty} \ifnum #3=1 \global\def\@si{\lftborder}\fi \ifnum #4=19 \global\def\@sxix{\rtborder}\fi \or \@inirow{t}{\botborder} \ifnum #3=1 \global\def\@ti{\lftbotcorner}\fi \ifnum #4=19 \global\def\@txix{\rtbotcorner}\fi \fi \ifnum \@beglet<\@endlet \advance \@beglet by 1 \repeat } \def\inifulldiagram{\inidiagram a-t:1-19 } \inifulldiagram % initialization % Majikal Nichus added this too... \def\oleftlabel#1{\relax \ifx #1a{\symbol{\hspace{0.5ex}19}}\else \ifx #1b{\symbol{\hspace{0.5ex}18}}\else \ifx #1c{\symbol{\hspace{0.5ex}17}}\else \ifx #1d{\symbol{\hspace{0.5ex}16}}\else \ifx #1e{\symbol{\hspace{0.5ex}15}}\else \ifx #1f{\symbol{\hspace{0.5ex}14}}\else \ifx #1g{\symbol{\hspace{0.5ex}13}}\else \ifx #1h{\symbol{\hspace{0.5ex}12}}\else \ifx #1i{\symbol{\hspace{0.5ex}11}}\else \ifx #1j{\symbol{\hspace{0.5ex}11}}\else \ifx #1k{\symbol{\hspace{0.5ex}10}}\else \ifx #1l{\symbol{\hspace{1.5ex}9}}\else \ifx #1m{\symbol{\hspace{1.5ex}8}}\else \ifx #1n{\symbol{\hspace{1.5ex}7}}\else \ifx #1o{\symbol{\hspace{1.5ex}6}}\else \ifx #1p{\symbol{\hspace{1.5ex}5}}\else \ifx #1q{\symbol{\hspace{1.5ex}4}}\else \ifx #1r{\symbol{\hspace{1.5ex}3}}\else \ifx #1s{\symbol{\hspace{1.5ex}2}}\else \ifx #1t{\symbol{\hspace{1.5ex}1}}\else \errmessage{Row label must be letter.} \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi } % jettero added this too... \def\obotlabel#1{\relax \ifnum #1=1{\symbol{a}}\else \ifnum #1=2{\symbol{b}}\else \ifnum #1=3{\symbol{c}}\else \ifnum #1=4{\symbol{d}}\else \ifnum #1=5{\symbol{e}}\else \ifnum #1=6{\symbol{f}}\else \ifnum #1=7{\symbol{g}}\else \ifnum #1=8{\symbol{h}}\else \ifnum #1=9{\symbol{j}}\else \ifnum #1=10{\symbol{k}}\else \ifnum #1=11{\symbol{l}}\else \ifnum #1=12{\symbol{m}}\else \ifnum #1=13{\symbol{n}}\else \ifnum #1=14{\symbol{o}}\else \ifnum #1=15{\symbol{p}}\else \ifnum #1=16{\symbol{q}}\else \ifnum #1=17{\symbol{r}}\else \ifnum #1=18{\symbol{s}}\else \ifnum #1=19{\symbol{t}}\else \errmessage{Row label must be letter.} \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi\fi\fi\fi\fi } \def\showdiagram#1-#2:#3-#4 {\vbox{\offinterlineskip\noindent \@letternumber{#1} \@beglet=\@lettercount \@letternumber{#2} \@endlet=\@lettercount \ifnum #4>#3 \x=#3\y=#4 \else \y=#3\x=#4 \fi \ifnum \@beglet>\@endlet \n=\@endlet\@endlet=\@beglet\@beglet=\n\fi \hsize=\@godimen \n=\y\advance\n by-\x\advance\n by1 \multiply\hsize by\n \def\@showrow##1{{\n=\x % Majikal Nichus was here... \oleftlabel{##1}\relax \loop \edef\@@showrow{\csname @##1\romannumeral\n \endcsname}\@@showrow \ifnum \n<\y \advance \n by 1 \repeat }}\relax \loop \ifcase\@beglet\relax\or \@showrow{a}\or \@showrow{b}\or \@showrow{c}\or \@showrow{d}\or \@showrow{e}\or \@showrow{f}\or \@showrow{g}\or \@showrow{h}\or \@showrow{j}\or \@showrow{k}\or \@showrow{l}\or \@showrow{m}\or \@showrow{n}\or \@showrow{o}\or \@showrow{p}\or \@showrow{q}\or \@showrow{r}\or \@showrow{s}\or \@showrow{t} \fi \ifnum \@beglet<\@endlet \newgoline \advance \@beglet by 1 \repeat \newgoline \symbol{\hspace{1ex}}\relax \n=\x \loop \obotlabel{\n}\relax \ifnum \n<\y \advance \n by 1 \repeat }} \def\showfulldiagram{\showdiagram a-t:1-19 } \def\jshowdiagram#1-#2:#3-#4 { \ifx #1a\global\def\@rlhs{1}\else \ifx #1b\global\def\@rlhs{2}\else \ifx #1c\global\def\@rlhs{3}\else \ifx #1d\global\def\@rlhs{4}\else \ifx #1e\global\def\@rlhs{5}\else \ifx #1f\global\def\@rlhs{6}\else \ifx #1g\global\def\@rlhs{7}\else \ifx #1h\global\def\@rlhs{8}\else \ifx #1i\global\def\@rlhs{9}\else \ifx #1j\global\def\@rlhs{9}\else \ifx #1k\global\def\@rlhs{10}\else \ifx #1l\global\def\@rlhs{11}\else \ifx #1m\global\def\@rlhs{12}\else \ifx #1n\global\def\@rlhs{13}\else \ifx #1o\global\def\@rlhs{14}\else \ifx #1p\global\def\@rlhs{15}\else \ifx #1q\global\def\@rlhs{16}\else \ifx #1r\global\def\@rlhs{17}\else \ifx #1s\global\def\@rlhs{18}\else \ifx #1t\global\def\@rlhs{19}\else \errmessage{error1} \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \ifx #2a\global\def\@rrhs{1}\else \ifx #2b\global\def\@rrhs{2}\else \ifx #2c\global\def\@rrhs{3}\else \ifx #2d\global\def\@rrhs{4}\else \ifx #2e\global\def\@rrhs{5}\else \ifx #2f\global\def\@rrhs{6}\else \ifx #2g\global\def\@rrhs{7}\else \ifx #2h\global\def\@rrhs{8}\else \ifx #2i\global\def\@rrhs{9}\else \ifx #2j\global\def\@rrhs{9}\else \ifx #2k\global\def\@rrhs{10}\else \ifx #2l\global\def\@rrhs{11}\else \ifx #2m\global\def\@rrhs{12}\else \ifx #2n\global\def\@rrhs{13}\else \ifx #2o\global\def\@rrhs{14}\else \ifx #2p\global\def\@rrhs{15}\else \ifx #2q\global\def\@rrhs{16}\else \ifx #2r\global\def\@rrhs{17}\else \ifx #2s\global\def\@rrhs{18}\else \ifx #2t\global\def\@rrhs{19}\else \errmessage{error2} \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \ifnum #3=19\global\def\@llhs{a}\else \ifnum #3=18\global\def\@llhs{b}\else \ifnum #3=17\global\def\@llhs{c}\else \ifnum #3=16\global\def\@llhs{d}\else \ifnum #3=15\global\def\@llhs{e}\else \ifnum #3=14\global\def\@llhs{f}\else \ifnum #3=13\global\def\@llhs{g}\else \ifnum #3=12\global\def\@llhs{h}\else \ifnum #3=11\global\def\@llhs{j}\else \ifnum #3=10\global\def\@llhs{k}\else \ifnum #3=9\global\def\@llhs{l}\else \ifnum #3=8\global\def\@llhs{m}\else \ifnum #3=7\global\def\@llhs{n}\else \ifnum #3=6\global\def\@llhs{o}\else \ifnum #3=5\global\def\@llhs{p}\else \ifnum #3=4\global\def\@llhs{q}\else \ifnum #3=3\global\def\@llhs{r}\else \ifnum #3=2\global\def\@llhs{s}\else \ifnum #3=1\global\def\@llhs{t}\else \errmessage{error3} \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi\fi\fi\fi\fi \ifnum #4=19\global\def\@lrhs{a}\else \ifnum #4=18\global\def\@lrhs{b}\else \ifnum #4=17\global\def\@lrhs{c}\else \ifnum #4=16\global\def\@lrhs{d}\else \ifnum #4=15\global\def\@lrhs{e}\else \ifnum #4=14\global\def\@lrhs{f}\else \ifnum #4=13\global\def\@lrhs{g}\else \ifnum #4=12\global\def\@lrhs{h}\else \ifnum #4=11\global\def\@lrhs{j}\else \ifnum #4=10\global\def\@lrhs{k}\else \ifnum #4=9\global\def\@lrhs{l}\else \ifnum #4=8\global\def\@lrhs{m}\else \ifnum #4=7\global\def\@lrhs{n}\else \ifnum #4=6\global\def\@lrhs{o}\else \ifnum #4=5\global\def\@lrhs{p}\else \ifnum #4=4\global\def\@lrhs{q}\else \ifnum #4=3\global\def\@lrhs{r}\else \ifnum #4=2\global\def\@lrhs{s}\else \ifnum #4=1\global\def\@lrhs{t}\else \errmessage{error4} \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi\fi\fi\fi\fi \showdiagram \@llhs-\@lrhs:\@rlhs-\@rrhs } \def\jpos#1#2=#3#4{ \ifnum #2=19\global\def\@lhs{a}\else \ifnum #2=18\global\def\@lhs{b}\else \ifnum #2=17\global\def\@lhs{c}\else \ifnum #2=16\global\def\@lhs{d}\else \ifnum #2=15\global\def\@lhs{e}\else \ifnum #2=14\global\def\@lhs{f}\else \ifnum #2=13\global\def\@lhs{g}\else \ifnum #2=12\global\def\@lhs{h}\else \ifnum #2=11\global\def\@lhs{j}\else \ifnum #2=10\global\def\@lhs{k}\else \ifnum #2=9\global\def\@lhs{l}\else \ifnum #2=8\global\def\@lhs{m}\else \ifnum #2=7\global\def\@lhs{n}\else \ifnum #2=6\global\def\@lhs{o}\else \ifnum #2=5\global\def\@lhs{p}\else \ifnum #2=4\global\def\@lhs{q}\else \ifnum #2=3\global\def\@lhs{r}\else \ifnum #2=2\global\def\@lhs{s}\else \ifnum #2=1\global\def\@lhs{t}\else \errmessage{Column label must be a number.} \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi\fi\fi\fi\fi \ifx #1a\global\def\@rhs{1}\else \ifx #1b\global\def\@rhs{2}\else \ifx #1c\global\def\@rhs{3}\else \ifx #1d\global\def\@rhs{4}\else \ifx #1e\global\def\@rhs{5}\else \ifx #1f\global\def\@rhs{6}\else \ifx #1g\global\def\@rhs{7}\else \ifx #1h\global\def\@rhs{8}\else \ifx #1i\global\def\@rhs{9}\else \ifx #1j\global\def\@rhs{9}\else \ifx #1k\global\def\@rhs{10}\else \ifx #1l\global\def\@rhs{11}\else \ifx #1m\global\def\@rhs{12}\else \ifx #1n\global\def\@rhs{13}\else \ifx #1o\global\def\@rhs{14}\else \ifx #1p\global\def\@rhs{15}\else \ifx #1q\global\def\@rhs{16}\else \ifx #1r\global\def\@rhs{17}\else \ifx #1s\global\def\@rhs{18}\else \ifx #1t\global\def\@rhs{19}\else \errmessage{Row label must be letter.} \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi %%% \errmessage{ #1 #2 , \@lhs \@rhs } \pos{\@lhs}{\@rhs}={#3}{#4} } \def\pos#1#2=#3#4{\relax \ifcat #1a\relax \else \errmessage{Row label must be a letter!}\fi \ifnum #2<1 \errmessage{Column number less than 1?}\fi \ifnum #2>19 \errmessage{Column number greater than 19?}\fi \edef\@fourth{#4}\relax \ifx .#4\ifx #3\empty\edef\@fourth{}\else \edef\@fourth{0}\fi\fi \edef\@borders{\relax \ifx #1a \ifnum #2=1 \gofont\char15 \else \ifnum #2=19 \gofont\char16 \else \gofont\char13 \fi\fi \else \ifx #1t \ifnum #2=1 \gofont\char17 \else \ifnum #2=19 \gofont\char18 \else \gofont\char14 \fi\fi \else \ifnum #2=1 \gofont\char11 \else \ifnum #2=19 \gofont\char12 \else \gofont\char10 \fi\fi\fi\fi}\relax \expandafter\let\csname @#1\romannumeral#2\endcsname=0\relax \edef\@pos{\def\csname @#1\romannumeral#2\endcsname{#3{\@fourth}}}\@pos \ignorespaces } \newcount\nr \def\black#1{\relax \ifx \triangle#1{\let\whitefontTwo=\blackfontTwo \rlap{\triangle}\@borders}\else \ifx \square#1{\let\whitefontTwo=\blackfontTwo \rlap{\square}\@borders}\else \ifnum #1<0 \errmessage{Negative Black's move?}\else \ifnum #1>253 \errmessage{Black's move too big!}\else \ifnum #1<128 {\blackfontOne\rlap{\char#1}\@borders}\else \nr=#1 \advance \nr by -128 {\blackfontTwo\rlap{\char\nr}\@borders}\ignorespaces \fi\fi\fi\fi\fi} \def\white#1{\relax \ifx \triangle#1{\rlap{\triangle}\@borders}\else \ifx \square#1{\rlap{\square}\@borders}\else \ifnum #1<0 \errmessage{Negative White's move?}\else \ifnum #1>253 \errmessage{White's move too big!}\else \ifnum #1<128 {\whitefontOne\rlap{\char#1}\@borders}\else \nr=#1 \advance \nr by -128 {\whitefontTwo\rlap{\char\nr}\@borders}\ignorespaces \fi\fi\fi\fi\fi} \def\textblack#1{\def\@borders{\hskip\wd\@gobox}\relax \ifx .#1\lower.2\wd\@gobox\hbox{\black{0}}\else \lower.2\wd\@gobox\hbox{\black{#1}}\fi} \def\textwhite#1{\def\@borders{\hskip\wd\@gobox}\relax \ifx .#1\lower.2\wd\@gobox\hbox{\white{0}}\else \lower.2\wd\@gobox\hbox{\white{#1}}\fi} \newbox\@letterbox \newdimen\@letterdim \def\symbol#1{\relax % \ifcat a#1\relax\else % \ifcat 0#1\relax\else % \errmessage{Strange parameter of symbol macro! (#1)} % \fi\fi \setbox\@letterbox=\hbox to\wd\@gobox{\hfil\letterfont #1\hfil}\relax \@letterdim=\wd\@gobox \divide \@letterdim by 24 \multiply \@letterdim by 22 \advance \@letterdim by -\ht\@letterbox {\raise.5\@letterdim\box\@letterbox}\relax } \let\letter=\symbol \catcode`@=12