diff --git a/doc/implementation.tex b/doc/implementation.tex index 8bbb0f2..b924977 100644 --- a/doc/implementation.tex +++ b/doc/implementation.tex @@ -244,7 +244,7 @@ if (0 == status){ \section{Communication MMIO and How It Actually Works} -\index{MMIO-com}The status flags and transfer/receive blocks are memory-mapped to these address: +\index{MMIO-com}\label{comm-mmio}The status flags and transfer/receive blocks are memory-mapped to these address: \footnote{RW stands for read-write status. RW means both reading and writing is posseble, RO means it's read-only} @@ -538,6 +538,41 @@ The MMIO Area is further divided as shown: \draw(3,0.5) node[anchor=mid] {\memlabel{MMIO for Peripheral \#7}}; \end{tikzpicture} + +\section{MMIO for Main Hardwares} + +Some internal hardwares are memory-mapped and can be controled by poking and peeking. + +Multibyte values are stored in Little Endian. + +\index{main hardware memory mapping} +\begin{tabulary}{\textwidth}{rcL} +Address & RW & Description \\ +\hline +-1..-32 & RO & Raw Keyboard Input Buffer (raw means the values are not shifted around) \\ +-33..-34 & RO & Mouse X Pos (latched by -40) \\ +-35..-36 & RO & Mouse Y Pos (latched by -40) \\ +-37 & RO & Mouse Button Down (1 if True) \\ +-38 & RW & The head key on the Keyboard Input Buffer \\ +-39 & RW & Text Input Stream control. Write nonzero value to open it. The Keyboard Input Buffer will be cleared whenever the Input Stream is opened. \\ +-40 & WO & Latch Keyboard and Mouse input \\ +-41..-48 & RO & List of pressed keys (latched by -40) \\ +-49 & RO & System Flags A (code{0b r000 000t}, where r: RESET button held, t: STOP button held) \\ +-50..-52 & RO & Unused System Flags \\ +-65..-68 & RO & Size of the Scratchpad Memory \\ +-69 & WO & Counter Latch (\code{0b01}--Uptime, \code{0b10}--RTC) \\ +-73..-80 & RO & System Uptime in nanoseconds (latched by -69) \\ +-81..-88 & RO & RTC in nanoseconds (latched by -69) \\ +-89 & RW & ROM Mapping \\ +-1025..-2048 & RW & Reserved for the integrated peripherals \\ +-4077..-20480 & $ \ast $ & See \ref{comm-mmio} \\ +-65537..-131072 & RO & Contents in the mapped ROM +\end{tabulary} + + + + + \chapter{Text and Graphics Display} TODO: Textbuf, pixelbuf, graphics mode, chart of the draw order @@ -548,8 +583,38 @@ While the graphics adapters can be plugged into any peripheral slot, it is highl \index{text buffer}The reference text buffer stores 80 columns, 32 rows of characters and 256 foreground and background colours are assigned separately for each character cell. -Text buffer is memory-mapped to the following address offset: +\subsection{Escape Sequences} +\newcommand{\csi}{{\condensedfont{CSI}}} + +Printing out certain sequences of string can invoke special functions on the graphics, and such sequneces are called Escape Sequences. + +For the following chart, please interpret \csi\ as \code{\rs{}x1B [}. + +\begin{tabulary}{\textwidth}{lL} +Sequence & Description \\ +\hline +\csi\ \emph{n} A & Moves the cursor up by \emph{n} (default \code{1}) \\ +\csi\ \emph{n} B & Moves the cursor down by \emph{n} (default \code{1}) \\ +\csi\ \emph{n} C & Moves the cursor right by \emph{n} (default \code{1}) \\ +\csi\ \emph{n} D & Moves the cursor left by \emph{n (default \code{1})} \\ +\csi\ \emph{n} E & Moves the cursor to the beginning of the line \emph{n} (default \code{1}) lines down \\ +\csi\ \emph{n} F & Moves the cursor to the beginning of the line \emph{n} (default \code{1}) lines up \\ +\csi\ \emph{n} G & Moves the cursor to the \emph{n}th (default \code{1}) column \\ +\csi\ \emph{n} ; \emph{m} H & Moves the cursor to \emph{n}th row, \emph{m}th column \\ +\csi\ 2 J & Clears the entire text buffer \\ +\csi\ \emph{n} S & Scoll the entire page up by \emph{n} (default \code{1}) lines \\ +\csi\ \emph{n} T & Scoll the entire page down by \emph{n} (default \code{1}) lines \\ +\csi\ m & Resets the text attributes to the default status \\ +\csi\ 7 m & Inverts the text by swapping the foreground and background colour \\ +\csi\ 30-37 m & Changes the foreground colour. 30--Black, 31--Red, 32--Green, 33--Yellow, 34--Blue, 35--Magenta, 36--Cyan, 37--White \\ +\csi\ 40-47 m & Changes the background colour. 40--Black, 41--Red, 42--Green, 43--Yellow, 44--Blue, 45--Magenta, 46--Cyan, 47--White \\ +\csi\ 38 ; 5 ; \emph{col} m & Changes the foreground colour using the Colour Palette \\ +\csi\ 48 ; 5 ; \emph{col} m & Changes the foreground colour using the Colour Palette \\ +\csi\ ? 25 h & Shows the text cursor \\ +\csi\ ? 25 l & Hides the text cursor \\ +{\condensedfont{\rs{}x84} \emph{charcode}} u & Prints out the symbol corresponds to the given charcode +\end{tabulary} \subsection{Code Page} \label{codepage} @@ -886,35 +951,35 @@ TODO Multibyte values are stored in Little Endian. \index{graphics adapter memory mapping} -\begin{tabulary}{\textwidth}{rL} -Address & Description \\ +\begin{tabulary}{\textwidth}{rcL} +Address & RW & Description \\ \hline --131073..-131074 & Framebuffer Width \\ --131075..-131076 & Framebuffer Height \\ --131077 & Text Columns \\ --131078 & Text Rows \\ --131079 & Text Mode Attributes \\ --131080 & Graphics Mode Attributes \\ --131081 & Last Used Colour for the Framebuffer \\ --131082 & Text Foreground Colour \\ --131083 & Text Background Colour \\ --131084 & Number of Graphics Memory Banks (1--4) \\ --131085 & Current Graphics Mode \\ --131086 & Current Layer Arrangement Index \\ --131087..-131088 & Framebuffer Horizontal Scroll \\ --131089..-131090 & Framebuffer Vertical Scroll \\ --132097..-131120 & Scanline Offsets \\ --1048577..-1299456 & First Framebuffer \\ --1299457 & Screen Background RED \\ --1299458 & Screen Background GREEN \\ --1299459 & Screen Background BLUE \\ --1299460 & Command \\ --1299461..-1299472 & Command Arguments \\ --1300607..-1302526 & Font ROM Mapping Area \\ --1302527..-1302528 & Text Cursor Position in $row \times 80 + col$ \\ --1302529..-1305088 & Text Foreground Colours \\ --1305089..-1307648 & Text Background Colours \\ --1307649..-1310208 & Text Buffer \\ --1310209..-1310720 & Palettes in This Pattern: {\ttfamily 0b RRRR GGGG; 0b BBBB AAAA} \\ --1310721..-1561600 & Second Framebuffer \\ +-131073..-131074 & RO & Framebuffer Width \\ +-131075..-131076 & RO & Framebuffer Height \\ +-131077 & RO & Text Columns \\ +-131078 & RO & Text Rows \\ +-131079 & RW & Text Mode Attributes \\ +-131080 & RW & Graphics Mode Attributes \\ +-131081 & RO & Last Used Colour for the Framebuffer \\ +-131082 & RW & Text Foreground Colour \\ +-131083 & RW & Text Background Colour \\ +-131084 & RO & Number of Graphics Memory Banks (1--4) \\ +-131085 & RW & Current Graphics Mode \\ +-131086 & RW & Current Layer Arrangement Index \\ +-131087..-131088 & RW & Framebuffer Horizontal Scroll \\ +-131089..-131090 & RW & Framebuffer Vertical Scroll \\ +-132097..-131120 & RW & Scanline Offsets \\ +-1048577..-1299456 & RW & First Framebuffer \\ +-1299457 & RW & Screen Background RED \\ +-1299458 & RW & Screen Background GREEN \\ +-1299459 & RW & Screen Background BLUE \\ +-1299460 & RW & Command \\ +-1299461..-1299472 & RW & Command Arguments \\ +-1300607..-1302526 & RW & Font ROM Mapping Area \\ +-1302527..-1302528 & RW & Text Cursor Position in $row \times 80 + col$ \\ +-1302529..-1305088 & RW & Text Foreground Colours \\ +-1305089..-1307648 & RW & Text Background Colours \\ +-1307649..-1310208 & RW & Text Buffer \\ +-1310209..-1310720 & RW & Palettes in This Pattern: {\ttfamily 0b RRRR GGGG; 0b BBBB AAAA} \\ +-1310721..-1561600 & RW & Second Framebuffer \\ \end{tabulary} diff --git a/doc/tsvmcp.png b/doc/tsvmcp.png index 42fac24..445b1d7 100644 Binary files a/doc/tsvmcp.png and b/doc/tsvmcp.png differ diff --git a/doc/tsvmman.idx b/doc/tsvmman.idx deleted file mode 100644 index 2153f10..0000000 --- a/doc/tsvmman.idx +++ /dev/null @@ -1,29 +0,0 @@ -\indexentry{js extensions|hyperpage}{7} -\indexentry{stdio (library)|hyperpage}{9} -\indexentry{console (library)|hyperpage}{9} -\indexentry{con (library)|hyperpage}{9} -\indexentry{gzip (library)|hyperpage}{12} -\indexentry{gzip (library)|hyperpage}{12} -\indexentry{base64 (library)|hyperpage}{13} -\indexentry{base64 (library)|hyperpage}{13} -\indexentry{sys (library)|hyperpage}{13} -\indexentry{block communication|hyperpage}{16} -\indexentry{com (library)|hyperpage}{16} -\indexentry{com (library)|hyperpage}{16} -\indexentry{MMIO-com|hyperpage}{18} -\indexentry{keycodes|hyperpage}{20} -\indexentry{code page|hyperpage}{22} -\indexentry{colour palette|hyperpage}{24} -\indexentry{graphics (library)|hyperpage}{26} -\indexentry{graphics (library)|hyperpage}{26} -\indexentry{MMIO-graphics|hyperpage}{26} -\indexentry{boot process|hyperpage}{29} -\indexentry{coreutils (DOS)|hyperpage}{30} -\indexentry{built-in apps (DOS)|hyperpage}{31} -\indexentry{user apps (DOS)|hyperpage}{33} -\indexentry{pipe (DOS)|hyperpage}{35} -\indexentry{filesystem (DOS)|hyperpage}{37} -\indexentry{file descriptor (DOS)|hyperpage}{37} -\indexentry{device file|hyperpage}{39} -\indexentry{input (DOS)|hyperpage}{41} -\indexentry{gl (DOS)|hyperpage}{43} diff --git a/doc/tsvmman.ilg b/doc/tsvmman.ilg deleted file mode 100644 index 88cfddc..0000000 --- a/doc/tsvmman.ilg +++ /dev/null @@ -1,6 +0,0 @@ -This is makeindex, version 2.16 [TeX Live 2022] (kpathsea + Thai support). -Scanning input file tsvmman.idx....done (29 entries accepted, 0 rejected). -Sorting entries....done (142 comparisons). -Generating output file tsvmman.ind....done (62 lines written, 0 warnings). -Output written in tsvmman.ind. -Transcript written in tsvmman.ilg. diff --git a/doc/tsvmman.ind b/doc/tsvmman.ind deleted file mode 100644 index cfa5177..0000000 --- a/doc/tsvmman.ind +++ /dev/null @@ -1,62 +0,0 @@ -\begin{theindex} - - \item base64 (library), \hyperpage{13} - \item block communication, \hyperpage{16} - \item boot process, \hyperpage{29} - \item built-in apps (DOS), \hyperpage{31} - - \indexspace - - \item code page, \hyperpage{22} - \item colour palette, \hyperpage{24} - \item com (library), \hyperpage{16} - \item con (library), \hyperpage{9} - \item console (library), \hyperpage{9} - \item coreutils (DOS), \hyperpage{30} - - \indexspace - - \item device file, \hyperpage{39} - - \indexspace - - \item file descriptor (DOS), \hyperpage{37} - \item filesystem (DOS), \hyperpage{37} - - \indexspace - - \item gl (DOS), \hyperpage{43} - \item graphics (library), \hyperpage{26} - \item gzip (library), \hyperpage{12} - - \indexspace - - \item input (DOS), \hyperpage{41} - - \indexspace - - \item js extensions, \hyperpage{7} - - \indexspace - - \item keycodes, \hyperpage{20} - - \indexspace - - \item MMIO-com, \hyperpage{18} - \item MMIO-graphics, \hyperpage{26} - - \indexspace - - \item pipe (DOS), \hyperpage{35} - - \indexspace - - \item stdio (library), \hyperpage{9} - \item sys (library), \hyperpage{13} - - \indexspace - - \item user apps (DOS), \hyperpage{33} - -\end{theindex} diff --git a/doc/tsvmman.tex b/doc/tsvmman.tex index 9d30329..f5590ea 100644 --- a/doc/tsvmman.tex +++ b/doc/tsvmman.tex @@ -102,6 +102,7 @@ \newcommand\forceindent{\hskip1.5em} %% BASIC operators %% +\newcommand\rs{\symbol{92}} \newcommand\tildechar{{\large\raisebox{-0.22ex}{\char`\~}}} \newcommand{\instbit}[1]{\mbox{\scriptsize #1}} \newcommand{\instbitrange}[2]{~\instbit{#1} \hfill \instbit{#2}~} diff --git a/doc/tvdos.tex b/doc/tvdos.tex index e830db6..0ce38d0 100644 --- a/doc/tvdos.tex +++ b/doc/tvdos.tex @@ -4,12 +4,10 @@ All \thedos-related features requires the DOS to be fully loaded. -On this documentation, what would be a reverse solidus (e.g. directory separators) are typesetted using a slash; while they \emph{are} interchangeable, using the reverse solidus are recommended for path input. - \chapter{Bootstrapping} -\index{boot process}\thedos\ goes through follwing progress to deliver the \code{A:/} prompt: +\index{boot process}\thedos\ goes through follwing progress to deliver the \code{A:\rs} prompt: \section{Probing Bootable Devices} BIOS @@ -17,10 +15,10 @@ BIOS \section{The Bootloader} LOADBOOT -Then the Bootsector will try to read and execute \code{A:/tvdos/TVDOS.SYS} +Then the Bootsector will try to read and execute \code{A:\rs{}tvdos\rs{}TVDOS.SYS} \section{TVDOS.SYS} -\thedos.SYS will load system libraries and variables and then will try to run the boot script by executing \code{A:/AUTOEXEC.BAT} +\thedos.SYS will load system libraries and variables and then will try to run the boot script by executing \code{A:\rs{}AUTOEXEC.BAT} \section{AUTOEXEC.BAT} @@ -191,7 +189,7 @@ Functions: \section{The Device Files} -\index{device file}Some devices are also virtualised through the file descriptor, and they are given a special drive letter of \code{\$}. (e.g. \code{\$:/RND}) +\index{device file}Some devices are also virtualised through the file descriptor, and they are given a special drive letter of \code{\$}. (e.g. \code{\$:\rs{}RND}) \begin{outline} \1\inlinesynopsis{RND}{returns random bytes upon reading} @@ -222,7 +220,7 @@ Functions: \dosnamespaceis{Input}{input} \begin{outline} -\1\inlinesynopsis{changeKeyLayout}[layoutName]{Changes the key layout. The key layout file must be stored as \code{A:/tvdos/layoutName.key}} +\1\inlinesynopsis{changeKeyLayout}[layoutName]{Changes the key layout. The key layout file must be stored as \code{A:\rs{}tvdos\rs{}layoutName.key}} \1\inlinesynopsis{withEvent}[callback]{Invokes the callback function when an input event is available.} \end{outline}