Project

General

Profile

Statistics
| Revision:

root / proj / report / report.tex @ 367

History | View | Annotate | Download (13.3 KB)

1 365 up20180642
\documentclass{article}
2
% Hyperreferences
3
\usepackage{hyperref}
4
% Margins
5
\usepackage[top=35mm,bottom=35mm,left=25mm,right=25mm]{geometry}
6
% Graphics and images
7 366 up20180642
\usepackage{graphicx} \graphicspath{{./images/}}
8
\usepackage{subcaption}
9
\usepackage{float}
10 365 up20180642
% Encodings (to render letters with diacritics and special characters)
11
\usepackage[utf8]{inputenc}
12
% Language
13
\usepackage[english]{babel}
14
% Section pagebreaks
15
\usepackage{titlesec}
16
\newcommand{\sectionbreak}{\clearpage}
17
\newcommand{\sectionnobreak}{% for when I want a section that does not break
18
  \global\toggletrue{afterpart}%
19
  \section
20
}
21
% Source code
22
\usepackage{listings}
23
\usepackage{xcolor}
24
\renewcommand{\lstlistingname}{File}
25
\lstset{
26
    frame=tb, % draw frame at top and bottom of the code
27
    tabsize=4, % tab space width
28
    numbers=left, % display line numbers on the left
29
	showstringspaces=false, % don't mark spaces in strings
30
    commentstyle=\color{green}, % comment color
31
    keywordstyle=\color{blue}, % keyword color
32
    stringstyle=\color{red} % string color
33
}
34
\lstdefinelanguage{Maxima}{
35
	keywords={log,jacobian,determinant,subst},
36
	sensitive=true,
37
	comment=[n][\itshape]{/*}{*/}
38
}
39
% Tables with bold rows
40
\usepackage{tabularx}
41
\newcommand\setrow[1]{\gdef\rowmac{#1}#1\ignorespaces}
42
\newcommand\clearrow{\global\let\rowmac\relax}
43
\clearrow
44
% Math stuff
45
\usepackage[mathscr]{euscript}
46
\usepackage{amsmath,amssymb}
47
\usepackage{mathtools}
48
\usepackage{enumitem}
49
\newcommand{\expnumber}[2]{{#1}\mathrm{e}{#2}} % scientific notation
50
% Definitions, theorems, remarks,...
51
\usepackage{amsthm}
52
\newtheorem{definition}{Definition}[section]
53
\newtheorem{theorem}{Theorem}[section]
54
\newtheorem{corollary}{Corollary}[theorem]
55
\newtheorem{lemma}[theorem]{Lemma}
56
\renewcommand\qedsymbol{$\blacksquare$}
57
\theoremstyle{remark}
58
\newtheorem*{remark}{Remark}
59
% Contents title
60
\addto\captionsenglish{\renewcommand*\contentsname{Table of contents}}
61
% Headers and footers
62
\usepackage{fancyhdr}
63
\pagestyle{fancyplain}
64
\fancyhf{}
65
\lhead{ \fancyplain{}{LabWars - Final report (LCOM 2019/20)}}
66
\lfoot{ \fancyplain{}{T5G03}}
67
\rfoot{ \fancyplain{}{\thepage} }
68
%
69
\newcommand{\email}[1]{
70
{\texttt{\href{mailto:#1}{#1}} }
71
}
72
\newcommand{\role}[1]{
73
\begin{tabular}{l l}
74
	\begin{minipage}[t]{30mm} \textbf{Roles} \end{minipage} &
75
	\begin{minipage}[t]{125mm} #1 \end{minipage}
76
\end{tabular}\\
77
}
78
\newcommand{\func}[1]{
79
\begin{tabular}{l l}
80
	\begin{minipage}[t]{30mm} \textbf{Functionalities} \end{minipage} &
81
	\begin{minipage}[t]{125mm} #1 \end{minipage}
82
\end{tabular}\\
83
}
84
% Metadata
85
\title{\Huge LabWars \\ \Large Final report \\ \vspace*{4pt} \large LCOM 2019/20}
86
\author{
87
T5G03\\
88
\begin{tabular}{r l}
89
	\email{up201806429@fe.up.pt} & Diogo Miguel Ferreira Rodrigues        \\
90
	\email{up201806554@fe.up.pt} & Telmo Alexandre Espirito Santo Baptista
91
\end{tabular}
92
}
93
\date{06/01/2020}
94
% Document
95
\begin{document}
96
%\begingroup
97
	\maketitle
98
%	\let\clearpage\relax
99
%	\setcounter{tocdepth}{2}
100
	\tableofcontents
101
%\endgroup
102
\section{User instructions}
103 366 up20180642
\subsection{How to play}
104
In all game modes, the controls are the same:
105
\begin{itemize}
106
	\item \textbf{WASD} to move North, East, South and West respectively.
107
	\item \textbf{Mouse left-click} to fire a bullet.
108
	\item \textbf{Ctrl+'+'} and \textbf{Ctrl+'-'} to zoom in and out.
109
	\item \textbf{ESC} to escape game mode (go back).
110
\end{itemize}
111 365 up20180642
\subsection{Main menu}
112
On startup, users are greeted by a \texttt{Loading...} message, briefly followed by the main screen.
113 366 up20180642
\begin{figure}[H] \centering
114
	\includegraphics[scale=0.45]{main_menu}
115
	\caption{Main menu}
116
\end{figure}
117
Using the mouse movement and clicks, the user can select one of the avaliable options:
118
\begin{itemize}
119
	\item \textbf{Single player}: Go to single player selection menu, to select one of the single player game modes.
120
	\item \textbf{Multiplayer}: Go to multiplayer mode, allowing to select more options.
121
	\item \textbf{Chat}: Exchange text messages with another connected computer.
122
	\item \textbf{Exit}: Exit the game
123
\end{itemize}
124
The user can also exit the game by presing \textbf{ESC}.
125
\pagebreak
126
\subsection{Single player}
127
Upon entering into single player mode, the user is presented with a menu from which he can choose one of the options. \par
128
\begin{figure}[H] \centering
129
	\includegraphics[scale=0.45]{singleplayer01}
130
	\caption{Single player menu}
131
\end{figure}
132
\begin{itemize}
133
	\item \textbf{Campaign}: campaign mode; kill all autonomous opponents.
134
	\item \textbf{Zombies}: zombies mode; kill as many zombies and survive as much time as possible.
135
	\item \textbf{Back}: go back to main menu.
136
\end{itemize}
137
The user can also go back to main menu by pressing \textbf{ESC}.
138
\pagebreak
139
\subsubsection{Campaign}
140
In campaign mode the goal is to kill all the opponents in the map as fast as possible, while sustaining as little damage as possible.
141
\begin{figure}[H] \centering
142
	\includegraphics[scale=0.45]{campaign01}
143
	\caption{Campaign mode}
144
\end{figure}
145
\pagebreak
146
\subsubsection{Zombies}
147
In zombie mode the goal is to kill as many zombies and survive as much time as possible. Zombies slowly follow the player and attack the player when in short range.\par
148
Once the player kills a zombie, a new zombie spawns in a random part of the map, with more life than all previous zombies.
149
\begin{figure}[H] \centering
150
	\includegraphics[scale=0.45]{zombies01}
151
	\caption{Zombies mode}
152
\end{figure}
153
\pagebreak
154
\subsection{Multiplayer}
155 367 up20180642
In multiplayer mode, \textcolor{red}{INCOMPLETE}.
156 366 up20180642
\pagebreak
157 365 up20180642
\subsection{Chat}
158
This chat tool was initially designed as a simple, text mode, test communication between different machines. We have however decided to include it as a functionality in the project for a number of reasons:
159
\begin{enumerate}
160
	\item It was easy to develop the graphical part and integrate in the project.
161
	\item Having a friendly functionality that uses the communication modules allows for faster debugging; in case the computers are not properly connected, or if during development something stops working we can immediately check if the communication modules also stopped working.
162
	\item It served as a minimal insurance that our project would integrate the communication modules, in case we could not implement multiplayer mode.
163
	\item It is a useful feature.
164
\end{enumerate}
165 366 up20180642
\begin{figure}[H] \centering
166
	\includegraphics[scale=0.45]{chat01}
167
	\caption{Chat environment}
168
\end{figure}
169 367 up20180642
The chat can be used for exchanging messages of up to 75 characters directly writable with the keyboard. The character limit was imposed to prevent strings from rendering as wider than the input box, and the fact they should be directly writable with the keyboard simplifies the process of capturing scancodes, having as downside not allowing to write characters that require more than one key press (like exclamation or question marks in a Portuguese keyboard). \par
170 366 up20180642
\begin{figure}[H] \centering
171
	\begin{subfigure}[b]{0.48\linewidth}
172
		\includegraphics[width=\linewidth]{chat02_01}
173
		\caption{Computer 1 chat}
174
	\end{subfigure}
175
	\begin{subfigure}[b]{0.48\linewidth}
176
		\includegraphics[width=\linewidth]{chat02_02}
177
		\caption{Computer 2 chat}
178
	\end{subfigure}
179
	\caption{Two users interacting via chat}
180
\end{figure}
181
The user can exit the chat mode by pressing \textbf{ESC}.
182
\section{Project status}
183
All functionalities previously presented were fully implemented, with the exception of:
184
\begin{itemize}
185
	\item \textbf{Campaign}: autonomous opponents were supposed to follow a pre-programmed path and shoot on sight at the player. Currently, they don't do either of those.
186
	\item \textbf{Multiplayer}: still working on it.
187
\end{itemize}
188
The I/O devices used in the project are presented in the following table.
189
\begin{center} \begin{tabular}{c || l | c}
190
	\textbf{Device} & \textbf{What for}                                        & Method \\ \hline
191
	Timer           & Frame rate, time since beginning of game                 & Interrupts \\
192
	Keyboard        & Player movement, writing chat messages                   & Interrupts \\
193
	Mouse           & Player orientation, shooting, selecting options in menus & Interrupts \\
194
	Video card      & In-game drawing, menus                                   & None \\
195
	RTC             & Scoreboards                                              & Polling \\
196
	Serial port     & Chat communication, multiplayer modes                    & Interrupts
197
\end{tabular} \end{center}
198
To manage all interrupt subscriptions, the general function \texttt{unsubscribe\_interrupt} was implemented and used.
199
\subsection{Timer}
200
Timer 0 is used to generate periodic interrupts at a rate of 60Hz, essentially controlling a large part of what the program does.\par
201
Timer interrupts regulate screen refreshing, which happens at a rate of 60Hz. In all game modes, timer interrupts serve not only the purpose of refreshing the screen, but also to process all the game data: collisions, movement, path-finding algorithms, etc. \par
202
To manage timer interrupt subscriptions, functions \texttt{subscribe\_timer\_interrupt}, \texttt{timer\_int\_handler} and \texttt{timer\_get\_no\_interrupts} were implemented and used.
203
\subsection{Keyboard}
204 367 up20180642
The keyboard was configured to issue interrupts on key presses and releases. \par
205
The keyboard is used to control some menus (namely using \textbf{ESC}), to input text in the chat, and to control player movement in the game and zoom in/out options.\par
206
To manage keyboard interrupt subscription, function \texttt{subscribe\_kbc\_interrupt} was implemented. To manage keyboard interrupts, functions \texttt{kbc\_ih}, \texttt{keyboard\_get\_done}, \texttt{keyboard\_get\_scancode} and \linebreak \texttt{update\_key\_presses} were implemented and used.
207 366 up20180642
\subsection{Mouse}
208 367 up20180642
The mouse was configured to issue interrupts on movement and button presses. \par
209
The mouse is used to control all menus (position and buttons), as well as allowing the player to aim at the opponents (position) and shoot bullets (buttons). \par
210
To manage mouse interrupt subscription, function \texttt{subscribe\_mouse\_interrupt} was implemented. To manage mouse interrupts, functions \texttt{mouse\_ih}, \texttt{mouse\_parse\_packet} and \texttt{update\_mouse}, among others, were implemented.
211 366 up20180642
\subsection{Video card}
212 367 up20180642
The video card was configured to work in graphic mode with direct color encoding, with resolution 1024x768 pixels and 8 bits for each color component Red, Green and Blue, yielding a total of approximately 16.8 million colors. \par
213
Simple buffering was used to eliminate flickering. All graphics are first drawn to the scree buffer, and only after all graphical operations (that is, at the end of the processing of the timer interrupt) is the buffer information copied to the VRAM. \par
214
The modules \texttt{rectangle\_t} and \texttt{menu\_t} were developed for displaying simple shapes and menus. The modules \texttt{basic\_sprite\_t} and \texttt{sprite\_t} were developed for displaying moving sprites, allowing for rotation around the "center" of the image, as well as scaling and movement. \par
215
The modules \texttt{font\_t} and \texttt{text\_t} were developed to allow for dynamic rendering of text, using as default (and, for now, sole) font Consolas. The only type of supported fonts are bitmap fonts. \par
216
Configuration of the UART was made using the functions \texttt{graph\_init} and \texttt{graph\_cleanup} developed during the project. Drawing to the buffer is made primarily through the functions \texttt{graph\_get\_XRes}, \linebreak \texttt{graph\_get\_YRes}, \texttt{graph\_set\_pixel}, \texttt{graph\_clear\_screen} and \texttt{graph\_draw}.\par
217
Basic sprites are constructed from small XPM files, or loaded at runtime from XPM2 files. A XPM2 file is a XPM file stripped from all the C syntax, leaving only the strings. This format is easier to load at runtime than XPM. A XPM file can be easily converted to a XPM2 file using the function \texttt{xpm\_save\_as\_xpm2}. All XPM arrays of strings are loaded to bitmaps using the function \texttt{xpm\_load} provided by the LCF.
218 366 up20180642
\subsection{Real-Time Clock (RTC)}
219 367 up20180642
\textcolor{red}{INCOMPLETE (TELMO)}
220 366 up20180642
\subsection{Serial port}
221 367 up20180642
The UART was configured to issue interrupts for Receiver Ready and Transmitter Empty. Communication is processed with the same parameters at both ends, at a bit-rate of 115200bps, 8 bits per char, 2 stop bits. UART FIFOs are not used. The protocols that were developed will be discussed in section \ref{sec:details}. \par
222
In multiplayer mode, data is transferred from host to remote at a frequency of 60Hz, with each message having at least 24 bytes. Data transference from remote to host is made whenever needed, with each message having on average 9 bytes.
223 366 up20180642
\pagebreak
224 365 up20180642
\section{Code organization/structure}
225 367 up20180642
\subsection{\texttt{libs}}
226
Collection of useful classes and functions. This module was developed with the goal of being as general and independent from \texttt{proj} as possible, although there are rare occasions where sub-modules of \texttt{libs} include sub-modules of \texttt{proj}.
227
\subsubsection{\texttt{classes}}
228
Provides classes \texttt{list\_t} and \texttt{queue\_t}. These classes achieve generality by storing pointers to \texttt{void}, which have as major disadvantage requiring the use of \texttt{free}. \par
229
\textcolor{red}{CONTINUE LIBS MODULES}
230
\subsection{\texttt{proj}}
231
\textcolor{red}{MAKE PROJ MODULES}
232
\section{Implementation details} \label{sec:details}
233
\textcolor{red}{WRITE IMPLEMENTATION DETAILS}
234
\subsection{XPM and XPM2}
235
\textcolor{red}{WRITE STUFF}
236
\subsection{Communication protocols}
237
\textcolor{red}{WRITE IMPLEMENTATION DETAILS}
238 365 up20180642
\section{Conclusions}
239 367 up20180642
\textcolor{red}{WRITE CONCLUSION}
240 365 up20180642
\end{document}