Project

General

Profile

Revision 390

report

View differences:

proj/doc/report/report.tex
145 145
\end{figure}
146 146
\pagebreak
147 147
\subsubsection{Zombies}
148
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
149
Once the player kills a zombie, a new zombie spawns in a random part of the map, with more life than all previous zombies.
148
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. Once the player kills a zombie, a new zombie spawns in a random part of the map, with more life than all previous zombies.
150 149
\begin{figure}[H] \centering
151
	\includegraphics[scale=0.45]{zombies01}
150
	\includegraphics[scale=0.39]{zombies01}
152 151
	\caption{Zombies mode}
153 152
\end{figure}
153
After exiting zombie mode, the player can check the scoreboard by selecting  \textbf{Zombies Ranking}.
154
\begin{figure}[H] \centering
155
	\includegraphics[scale=0.39]{zombies_scoreboard01}
156
	\caption{Zombies mode scoreboard}
157
\end{figure}
154 158
\pagebreak
155 159
\subsection{Multiplayer}
156 160
In multiplayer mode, \textcolor{red}{INCOMPLETE}.
......
204 208
\subsection{Keyboard}
205 209
The keyboard was configured to issue interrupts on key presses and releases. \par
206 210
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
207
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. 
211
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 \texttt{update\_key\_presses} were implemented and used. 
208 212
\subsection{Mouse}
209 213
The mouse was configured to issue interrupts on movement and button presses. \par
210 214
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
......
223 227
The RTC is used to obtain date and time for the scoreboards on the game-modes.
224 228

  
225 229
\subsection{Serial port}
226
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
230
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 9600bps, 8 bits per char, 2 stop bits. UART FIFOs are used, with  trigger level of 4 bytes per interrupt. The protocols that were developed will be discussed in section \ref{sec:details}. \par
227 231
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.
228 232
\pagebreak
229 233
\section{Code organization/structure}
......
257 261
The XPM2 file format is similar to XPM, except it is stripped from all the C syntax, making it a plain text file. This file format has the main advantage of being easy to load on runtime, unlike XPM that would require extensive parsing.\par
258 262
To use the XPM2 file format, two functions \texttt{xpm\_save\_to\_xpm2} and \texttt{xpm\_load\_xpm2} were implemented; the first one to convert XPM files to XPM2 files, and the second one was used in the project to load the XPM data (as an array of C-strings) from the XPM2 file format.
259 263
\subsection{Communication protocols}
260
\textcolor{red}{WRITE IMPLEMENTATION DETAILS}
264
\subsubsection{Non-Critical Transmission Protocol}
265
NCTP was designed to encapsulate the basic UART functions that were developed, by providing a set of middle-level functions that allow communication between computers.\par
266
NCTP allows to send a message to another computer through the function \texttt{nctp\_send}, which sends the contents of a set of memory blocks as a single message. The first argument is the number of memory blocks, followed by an array of pointers to void denoting the beginning of each memory block, and an array of sizes, where \texttt{sz[i]} is the number of bytes of the block starting at \texttt{ptr[i]} that should be sent. On receiving, NCTP calls a user-provided function to interpret the message.\par
267
NCTP uses queues on transmission and receiving. When a Tx interrupt occurs, NCTP tries to send as many chars of the transmission queue as possible, and on a Rx interrupts NCTP tries to extract from the receiving register as many chars as possible, putting them in the receiving queue.\par
268
When a complete message is detected, the chars of the message are popped out of the receiving queue, and passed to the user-provided function for interpretation.\par
269
A message is composed of a header, a body and trailling filler chars. The header is a pair of bytes denoting the size of the body. Then comes the body, and finally the trailling filler chars, whose purpose is to make sure the total size of the message is a multiple of 4, to prevent problems like a number of final message chars smaller than the trigger level causing a timeout.
270
\subsubsection{High-Level Transmission Protocol}
271
HLTP fills the gap left by NCTP, by providing a way to interpret messages. For that, HLTP keeps an enumeration of all the data types it knows, and for each deta type a pair of functions for coding and decoding a message containing that data type.\par
272
HLTP inserts at the beginning of the body a byte indicating the data type, so the message can then be decoded on the other computer.
261 273
\subsection{Path-finding}
274
The implementation of the following behaviour of zombies was made using a modified version of Dijkstra's path-finding algorithm. Because running a regular Dijkstra every frame causes tremendous lag, a modification was made; for each pixel, it is known the zombie should go to another pixel. At the beginning, a complete Dijkstra is ran, and each time the position of the player changes Dijkstra is only ran in the vicinity of the player.\par
275
This solution does not always provide the shortest path, but is significantly more efficient and returns a working path to the player.
262 276
\end{document}

Also available in: Unified diff