% !TEX TS-program = lualatex

\documentclass[10pt, stock, openany]{memoir}


\usepackage{fontspec}
\setmainfont{MyriadPro}

\usepackage{fapapersize}
\usefapapersize{148mm,210mm,15mm,15mm,20mm,15mm}
\usepackage{afterpage}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{xcolor}

\usepackage{ltablex}
\usepackage{parskip}
\usepackage{tasks}

\frenchspacing
\setlength{\parindent}{0pt}
\setlength{\parskip}{10pt}
\setsecnumdepth{subsection}


%% Idioms %%
\hyphenation{Com-put-er-Craft}
\hyphenation{O-pen-Com-put-ers}



\definecolor{black}{HTML}{000000}
\definecolor{white}{HTML}{FFFFFF}
\definecolor{dimgrey}{HTML}{555555}
\definecolor{brightgrey}{HTML}{AAAAAA}

\definecolor{yellow}{HTML}{FFFF00}
\definecolor{orange}{HTML}{FF6600}
\definecolor{red}{HTML}{DD0000}
\definecolor{magenta}{HTML}{FF0099}

\definecolor{purple}{HTML}{330099}
\definecolor{blue}{HTML}{0000CC}
\definecolor{cyan}{HTML}{0099FF}
\definecolor{lime}{HTML}{55FF00}

\definecolor{green}{HTML}{00AA00}
\definecolor{darkgreen}{HTML}{006600}
\definecolor{brown}{HTML}{663300}
\definecolor{tan}{HTML}{996633}



\newcommand{\unemph}[1]{\textcolor{brightgrey}{#1}}


% Title styling
\pretitle{\begin{flushright}\HUGE}
\posttitle{\par\end{flushright}\vskip 0.5em}

% new sections are new page
\let\oldsection\chapter
\renewcommand\chapter{\clearpage\oldsection}

% chapter title -- no now page after
\renewcommand\chapterheadstart{} % kill the drop
\renewcommand\afterchapternum{\vskip 0.5em} % space between number and title
\makeatletter
\renewcommand\memendofchapterhook{%
\m@mindentafterchapter\@afterheading}
\makeatother


\renewcommand{\thefootnote}{\fnsymbol{footnote}}


\aliaspagestyle{part}{empty}
\aliaspagestyle{chapter}{empty}


% The title
\title{\textbf{ROMBASIC DEVELOPERS' \\ MANUAL} \\ \vspace{7mm} \large For the Game \emph{Terrarum}\quad ·\quad First Edition}
\date{}
\author{}
\hypersetup{
	pdfauthor={Terrarum Developers},
	pdftitle={ROMBASIC DEVELOPERS’ MANUAL},
	unicode=true
}



\begin{document}
\begin{titlingpage}
\maketitle{}
\end{titlingpage}

\setcounter{page}{3}

\tableofcontents*



\part{APIs and Libraries}

\chapter{Filesystem}
\input{api_filesystem}

\chapter{Hexutils}
\input{api_hexutils}

\chapter{Input}
\input{api_input}

\chapter{Keys}
\input{api_keys}

\chapter{OS}
\input{api_os}

\chapter{Security}
\input{api_security}

\chapter{Shell}
\input{api_shell}

\chapter{Speaker}
\input{api_speaker}

\chapter{Terminal}
\input{api_terminal}

\chapter{Lua Globals}
\input{luaglobals}
\subsection{Changes from Generic Lua Environment}
\input{luadifferences}

\chapter{Machine}
\input{api_machine}


\part[Compatibility Layers---ComputerCraft]{{\LARGE Compatibility Layers} \\ ComputerCraft}

\chapter{Bit}
\input{cc_bit}

\chapter{Colors}
\input{cc_colors}

\chapter{Term}

\chapter{Filesystem}



\part[Compatibility Layers---OpenComputers]{{\LARGE Compatibility Layers} \\ OpenComputers}



\part{Peripherals}

\chapter{Line Printer}
\input{peri_lp}

\chapter{PSG}
%\input{peri_psg}



\part{References}

Some of the texts are taken from following sources:

\begin{itemize}
\item Lua Manual version 5.2, Lua.org, POC-Rio
\item ComputerCraft, dan200
\item OpenComputers, MightyPirates
\end{itemize}

\afterpage{\pagestyle{empty}\null\newpage}

\end{document}