% maamac.tex 1.5 1995/04/06 -- Malvern A Macros

%%%@TeX-definition-file {
%%% filename       = "$texmf/tex/plain/pdcmac/maamac.tex",
%%% version        = "1.5",
%%% date           = "1995/04/06",
%%% package        = "pdcmac 1.0",
%%% author         = "P. Damian Cugley",
%%% email          = "damian.cugley@comlab.ox.ac.uk",
%%% address        = "Oxford University Computing Laboratory,
%%%                   Parks Road, Oxford  OX1 3QD, UK",
%%% codetable      = "USASCII",
%%% keywords       = "TeX, plain TeX, macros",
%%% supported      = "Maybe",
%%% abstract       = "Macros for using the Malvern-A font coding
%%%                   scheme in plain TeX documents.
%%%                   This file was generated by running
%%%                   plain TeX on maamac.dtx",
%%% copyright      = "Copyright (c) 1991-1995 P. Damian Cugley",
%%% copying        = "DO NOT DISTRIBUTE THIS FILE.
%%%                   Distribute maamac.dtx only as part of the
%%%                   package it came in.",
%%% dependencies   = "",
%%% }

\message{1.5 <pdc 1995/04/06>}

\dimendef\dimena0  \dimendef\dimenb2
\toksdef\toksa0
\countdef\counta255
\ifx\countb\UNDEFINED \csname newcount\endcsname\countb \fi
\ifx\countc\UNDEFINED \csname newcount\endcsname\countc \fi
\def\code#1{%
    \ifcat#1a%
        `#1
    \else\ifcat#1+%
        `#1
    \else\ifx\char#1
    \else
        #1%
    \fi\fi\fi
}
\let\then=\iffalse
\def\ifcap#1\then{\expandafter\ifcapnum\code{#1}\then}
\def\ifcapnum#1\then{\ifnum\lccode#1=#1}
\def\iflower#1\then{\expandafter\iflowernum\code{#1}\then}
\def\iflowernum#1\then{\ifnum\uccode#1=#1}
\def\fontslant#1{\expandafter\stripPT\the\fontdimen1#1}
\begingroup \uccode`2=`p \uccode`3=`t \uppercase{\toksa{\endgroup
    \def\\#123{#1}
}} \the\toksa
\let\stripPT=\\
\def\putxy#1#2#3{\leavevmode\rlap{\hskip#1\raise#2\hbox{#3}}}
\def\putmarkxy#1#2#3#4{{%
    \setbox0=\hbox{#4}#2\relax
    \dimenb#1\wd0 \advance\dimenb\fontslant\font\dimena
    \leavevmode
    \putxy{\dimenb}{\dimena}{\hbox to 0pt{\hss\char#3\hss}}%
    \box0
}}
\def\putmarky{\putmarkxy{0.5}}
\def\typeImark#1#2{{%
    \setbox2=\hbox{#2}%
    \ifdim \ht2=1ex
        \accent#1\relax#2%
    \else
        \counta\code{#2}%
        \ifnum\counta>64 \ifnum\counta<96
            \advance\counta 128
        \fi \fi
        \putmarky{\dimena0.5\ht0 \advance\dimena-0.5ex }
                {#1}{\char\counta}%
    \fi
}}
\chardef\dotglyph22     \def\.{\typeImark\dotglyph}
\chardef\twodotsglyph23 \def\"{\typeImark\twodotsglyph}
\chardef\macronglyph150 \def\={\typeImark\macronglyph}
\chardef\longmacronglyph151
        \def\longmacronmark{\typeImark\longmacronglyph}
\def\typeIImark#1#2{{%
    \counta#1\relax \countb\code{#2}%
    \ifcap{#2}\then
        \ifnum \counta<128 \advance\counta 128 \fi
        \ifnum \countb<128 \advance\countb 128 \fi
    \fi
    \accent\counta \char\countb
}}
\chardef\acuteglyph8      \def\'{\typeIImark\acuteglyph}
\chardef\graveglyph9      \def\`{\typeIImark\graveglyph}
\chardef\circumglyph10    \def\^{\typeIImark\circumglyph}
\chardef\tildeglyph11     \def\~{\typeIImark\tildeglyph}
\chardef\ringglyph12      \def\ringmark{\typeIImark\ringglyph}
\chardef\caronglyph13     \def\v{\typeIImark\caronglyph}
\chardef\breveglyph14     \def\u{\typeIImark\breveglyph}
\chardef\hungarglyph15 \def\H{\typeIImark\hungarglyph}
\def\cedillalike#1#2#3{{%
    \setbox0=\hbox{#3}%
    \ifdim\ht0>1ex
        \ooalign{\hidewidth\char#2\relax\hidewidth\crcr\unhbox0 }%
    \else
        \accent#1 #3%
    \fi
}}
\chardef\cedillaglyph6 \chardef\Cedillaglyph134
\def\c{\cedillalike\cedillaglyph\Cedillaglyph}
\chardef\ogonekglyph7 \chardef\Ogonekglyph135
\def\k{\cedillalike\ogonekglyph\Ogonekglyph}
\chardef\TH"00  \chardef\th"10  \chardef\DH"04  \chardef\dh"14
\chardef\A "01  \chardef\a "11  \chardef\E "05  \chardef\e "15
\chardef\NG"02  \chardef\ng"12  \chardef\L "03  \chardef\l "13
\chardef\AE"5E  \chardef\ae"7E  \chardef\OE"5F  \chardef\oe"7F
\chardef\O "5C  \chardef\o "7C
\chardef\vd"9C  \chardef\vt"9D  \chardef\h "9E  \chardef\vl"9F
\chardef\ss"18  \chardef\i "19  \chardef\j "1A
\def\aa{\ringmark a} \def\AA{\ringmark A}
\chardef\orda"98 \chardef\ordo"99 \def\No{N\ordo} \def\no{n\ordo}
\chardef\csuperior"98 \def\Mc{M\csuperior}
\chardef\trademark "22
\chardef\copyright "FB  \chardef\registered"FD
\chardef\careof    "9A  \chardef\Box       "A0
\chardef\cents     "A2  \chardef\pounds    "A3
\chardef\currency  "A4  \chardef\permille  "A5
\chardef\yen       "A8  \chardef\florin    "A9
\chardef\dag       "AA  \chardef\ddag      "AB
\chardef\gbdecimal "AE  \chardef\minus     "AF
\chardef\S         "BA  \chardef\P         "BB
\chardef\degrees   "C0
\chardef\lguillemet"BC  \chardef\rguillemet"BE
\mathcode`\,"602C  \mathcode`\-"20AF
\mathcode`\."002E  \mathcode`\/"002F
\mathchardef\bullet   "2020  \mathchardef\times    "20A6
\mathchardef\backslash"005B  \mathchardef\setminus "205B
\mathchardef\cdot     "20AE  \mathchardef\cdotp    "60AE
\def\langle{\delimiter"40DB30A }  \delcode`\<"0DB30A
\def\rangle{\delimiter"50DD30B }  \delcode`\>"0DD30B
\def\lbrace{\delimiter"407B308 }  \let\{\lbrace  \mathcode`\{"407B
\def\rbrace{\delimiter"507D309 }  \let\}\rbrace  \mathcode`\}"407D
\uccode\th\TH  \lccode\TH\th  \uccode\TH\TH  \lccode\th\th
\uccode\a \A   \lccode\A \a   \uccode\A \A   \lccode\a \a
\uccode\ng\NG  \lccode\NG\ng  \uccode\NG\NG  \lccode\ng\ng
\uccode\l \L   \lccode\L \l   \uccode\L \L   \lccode\l \l
\uccode\dh\DH  \lccode\DH\dh  \uccode\DH\DH  \lccode\dh\dh
\uccode\e \E   \lccode\E \e   \uccode\E \E   \lccode\e \e
\uccode\o \O   \lccode\O \o   \uccode\O \O   \lccode\o \o
\uccode\ae\AE  \lccode\AE\ae  \uccode\AE\AE  \lccode\ae\ae
\uccode\oe\OE  \lccode\OE\oe  \uccode\OE\OE  \lccode\oe\oe
\uccode\i`I    \uccode\j`J \lccode\i\i \lccode\j\j
\uccode\csuperior`C
\def\changecodes#1#2#3#4{%
    \counta#2\relax \countb#3\relax \countc#4\relax
    \loop
    \ifnum\countc>0
        #1\counta\countb
        \advance\counta 1
        \advance\countb 1
        \advance\countc-1
    \repeat
}
\changecodes\uccode{"E1}{`A}{26}
\changecodes\uccode{"C1}{"C1}{26}
\changecodes\lccode{"E1}{"E1}{26}
\changecodes\lccode{"C1}{`a}{26}
\changecodes\lccode{"B0}{`0}{10}
\changecodes\uccode{`0}{"B0}{10}
\changecodes\mathcode{`a}{"7461}{26}
\changecodes\mathcode{`A}{"7441}{26}
\changecodes\mathcode{`0}{"70B0}{10}
\def\capspecials#1#2{%
    \chardef\TH"#10 \chardef\A "#11 \chardef\NG"#12
    \chardef\L "#13 \chardef\DH"#14 \chardef\E "#15
    \chardef\O "#2C \chardef\AE"#2E \chardef\OE"#2F
}
\def\lcspecials#1#2#3{%
    \chardef\th"#10 \chardef\a "#11 \chardef\ng"#12
    \chardef\l "#13 \chardef\dh"#14 \chardef\e "#15
    \chardef\o "#2C \chardef\ae"#2E \chardef\oe"#2F
    \def\ss{\char"#23 \char"#23 }\chardef\i"#39 \chardef\j"#3A
}
\def\sc#1{{%
    \changecodes\lccode{`A}{"E1}{26}\capspecials9F\lowercase{#1}%
}}
\def\mc#1{{%
    \changecodes\lccode{`A}{"C1}{26}\capspecials8D\lowercase{#1}%
}}
\def\csc#1{{%
    \changecodes\uccode{`a}{"E1}{26}\lcspecials9FE\uppercase{#1}%
}}
\def\allcaps#1{{%
    \lcspecials054\uppercase{#1}%
}}
\def\alllc#1{{%
    \capspecials17\lowercase{#1}%
}}
