\hyphenation{stand-alone Real-Live}

\newcommand{\opus}[1]{\textit{#1}} % name of a game or other work

\newcommand{\file}[1]{\texttt{#1}}     % filename
\newcommand{\inivar}[1]{\texttt{#1}}   % variable in gameexe.ini
\newcommand{\metavar}[1]{{\itshape\texttt{#1}}}
\newcommand{\metaopt}[1]{{\itshape{}[\texttt{#1}]}}
\newcommand{\clopt}[1]{{\ttfamily-#1}}
\newcommand{\cllong}[1]{{\ttfamily-\texttt{-}#1}}
\newcommand{\clboth}[2]{{\ttfamily-#1\textrm{, }-\texttt{-}#2}}
\newcommand{\clbarg}[3]{{\ttfamily-#1 \textit{#3}\textrm{, }-\texttt{-}#2=\textit{#3}}}

\newcommand{\archiver}{Kprl}
\newcommand{\disassembler}{\archiver}
\newcommand{\compiler}{Rlc}
\newcommand{\converter}{Vaconv}
\newcommand{\dataxml}{RlXml}
\newcommand{\package}{RLdev}
\newcommand{\vas}{Vis\-ual\-Art's}
\newcommand{\reallive}{RealLive}
\newcommand{\avgns}{AVG2000}
\newcommand{\gameexe}{\file{gameexe.ini}}

\newcommand\minver[2]{\emph{This #1 is not available in \reallive\ prior to #2.}}
\newcommand\maxver[2]{\emph{This #1 is not available in \reallive\ after #2.}}

\ifhevea
  \newenvironment{nicelist}{\begin{list}{}{}}{\end{list}}
  \newenvironment{syscom}{\begin{tabular}{rcp{0.8\textwidth}}}{\end{tabular}}
  \newenvironment{multicols}[1]{}{}
  \newenvironment{allononepageforgodssake}{}{}
  \newcommand{\hs}{\hspace{3cm}}
\else
  \newenvironment{nicelist}{%
    \begin{basedescript}{%
      \setlength{\partopsep}{\topsep}%
      \setlength{\itemsep}{1em}%
      \setlength{\topsep}{0pt}%
      \desclabelstyle{\nextlinelabel}%
      \desclabelwidth{1em}%
    }%
  }{\end{basedescript}}
  \newlength{\syscomw}\setlength{\syscomw}{-3em}\addtolength{\syscomw}{\textwidth}
  \newenvironment{syscom}{\begin{supertabular}{r@{~}c@{~}p{\syscomw}}}{\end{supertabular}}
  \newenvironment{allononepageforgodssake}{\noindent\begin{minipage}{\textwidth}}{\end{minipage}}
  \newcommand{\hs}{\hspace{5mm}}
\fi

\ifhevea
  \newcommand{\makelink}[4][!!!]{\ahrefloc{#2:#3}{#4}}
  \newcommand{\maketarget}[3][!!!]{\aname{#2:#3}{}}
  \newcommand{\prespace}{}
\else
  \newcommand{\makelink}[4][!!!]{\ifthenelse{\equal{#1}{!!!}}{\hyperlink{#2:#3}{#4}}{\hyperlink{#2:#1}{#4}}}
  \newcommand{\maketarget}[3][!!!]{\ifthenelse{\equal{#1}{!!!}}{\hypertarget{#2:#3}{}}{\hypertarget{#2:#1}{}}}
  \newcommand{\prespace}{\vspace{1.5\medskipamount}\noindent}
\fi
\newcommand{\fnref}[2][!!!]{\makelink[#1]{func}{#2}{\texttt{#2()}}}
\newcommand{\fnrefnoparens}[2][!!!]{\makelink[#1]{func}{#2}{\texttt{#2}}}
\newcommand{\fnidx}[1]{\index[funcidx]{#1}}
\newcommand{\dirref}[2][!!!]{\makelink[#1]{directive}{#2}{\texttt{\##2}}}
\newcommand{\diridx}[1]{\index{#1@\texttt{\##1}}}
\newcommand{\dirdef}[2][!!!]{\prespace\maketarget[#1]{directive}{#2}\diridx{#2}}
\newcommand{\ccref}[2][!!!]{\makelink[#1]{ccode}{#2}{\texttt{$\backslash$#2}}}
\newcommand{\ccidx}[1]{\index{#1@\texttt{$\backslash$#1}}}
\newcommand{\ccdef}[2][!!!]{\prespace\maketarget[#1]{ccode}{#2}\ccidx{#2}}
\newcommand{\ivarref}[2][!!!]{\makelink[#1]{ivar}{#2}{\texttt{\##2}}}
\newcommand{\ivaridx}[1]{\index[ivaridx]{#1@\texttt{\##1}}}
\newcommand{\ivarsidx}[2]{\index[ivaridx]{#1@\texttt{\##1.}!#2@\texttt{#2}}}

\newenvironment{cmdesc}{%
 \begin{list}{}{%
  \setlength{\topsep}{3pt}%
  \setlength{\itemsep}{1em}%
  \setlength{\leftmargin}{1em}%
  \setlength{\listparindent}{1em}%
  \setlength{\itemindent}{0pt}%
  \setlength{\parsep}{\parskip}%
 }%
\item[]}{\end{list}}

% Entities

\ifhevea
  \newcommand{\rawlbrace}{\texttt{\{}}
  \newcommand{\amac}{\@print{&#x101;}}
  \newcommand{\umac}{\@print{&#x16b;}}
  \newcommand{\omac}{\@print{&#x14d;}}
  \providecommand{\textbar}{|}
  \providecommand{\textemdash}{\@print{&mdash;}}
  \providecommand{\textendash}{\@print{&ndash;}}
  \providecommand{\frontmatter}{}
  \providecommand{\mainmatter}{}
  \providecommand{\backmatter}{}
  \providecommand{\leqslant}{\leq}
\else
  \newcommand{\rawlbrace}{\lstinline|\{|}
  \newcommand{\amac}{\=a}
  \newcommand{\umac}{\=u}
  \newcommand{\omac}{\=o}
\fi

% Code pretty-printing settings

\ifhevea
  \newcommand{\lchapter}[1]{\lstset{gobble=0}\chapter{#1}}
  \newcommand{\lsection}[1]{\lstset{gobble=2}\section{#1}}
  \newcommand{\lsubsection}[1]{\lstset{gobble=4}\subsection{#1}}
  \newcommand{\lsubsubsection}[1]{\lstset{gobble=6}\subsubsection*{#1}}
\else
  \newcommand{\lchapter}[1]{\lstset{gobble=2}\chapter{#1}}
  \newcommand{\lsection}[1]{\lstset{gobble=4}\section{#1}}
  \newcommand{\lsubsection}[1]{\lstset{gobble=6}\subsection{#1}}
  \newcommand{\lsubsubsection}[1]{\lstset{gobble=8}\subsubsection*{#1}}
\fi

\lstdefinelanguage{kepago}{%
  morekeywords={if,else,for,while,repeat,till,case,of,other,ecase,break,continue,eof,op},%
  alsoletter={\#},%
  ndkeywords={\#load,\#file,\#line,\#resource,\#entrypoint,\#character,\#res,\#define,\#undef,\#const,\#set,\#target,\#print,\#warn,\#error,\#if,\#ifdef,\#ifndef,\#elseif,\#else,\#endif,\#for,\#kidoku_type},%
  sensitive=false,%
  comment=[l]{//},%
  morecomment=[s]{\{-}{-\}},%
  string=[b]{'},%
  morestring=[b]{"}}[keywords,comments,strings,directives]

\lstset
 {extendedchars=false,
  language=kepago,
  columns=flexible,
  showstringspaces=false,
  escapechar=^}

\ifhevea
  \lstset
   {commentstyle=\color[rgb]{0, 0.33, 0.33},
    keywordstyle=\color[rgb]{0, 0, 0.8},
    ndkeywordstyle=\color[rgb]{0, 0.33, 0},
    stringstyle=\color[rgb]{0.33, 0.33, 0.33}}
\else
  \lstset
   {commentstyle=\itshape,
    stringstyle=\ttfamily,
    ndkeywordstyle=\ttfamily\itshape,
    xleftmargin=\parindent}
\fi
