Specifications
assert.c Suppor t for assertions and cleanups as design and debugging aids.
blocks.s Graphic block images of the maze, the player, fruits, etc.
input.c Input control. Provides for initialization and shutdown of the input controller. The version provided
to you supports keyboard control. You must write the support for the Tux controller. This file is not
compiled with th e rest of the game and should be used only to test your inputs separately fr om the
game. Can be compiled stand-alone to test the input device.
maze.c Maze generation and logic. Creates the maze; c reates, che c ks for, and consumes fruit; checks for
win conditions. Tra nsforms the block image data in blocks.s into pixelized graphic images of
maze lines and columns for use by modex.c in drawing parts of the logical v iew. Can be compiled
stand-alon e to test maze generation.
mazegame.c Multithreaded main process of the mazegame. There is a thread that controls the game logic, includ-
ing the m ain event loop, level set up, all timing logic, display control logic (motion and scrolling).
Includes a computer-controlled player as well as one using the regular input control. Another thread
is cre ated to handle keyboard control. You will eventually need to add ano ther thread for the Tux
Controller control.
modex.c Functions to support use of VGA mode X. Includes thin gs like switch ing from text mode to mode
X and back, and clearing the screens. Provides a logical view window abstraction that is drawn in
normal memory and co pied into video memory using a d ouble-buffering strategy. When the logical
view is shifted, data still on the screen are re tained, thus only those por tions of the logical view that
were not previously visible must be drawn. Finally, supp orts mapping from pixelized graphics in
formats convenient to C into drawing a screen at a certain logical position. Relies on maze.c to
provide vertical and horizontal lin es from the maze. Is also compiled stand- alone to create the tr
text mode restoration program.
text.c Text font data and conversion from ASCII strings to pixelized grap hic images of text (you must write
the latter).
We have also included two stripped binaries to illustrate your end goal. The mazegame-demo program is a fully
working versio n of the ga me that allows both keyboard and Tux controller inp ut. The input-demo program is a
stand-alon e compilation of input.c, again allowing both fo rms of input.
The tr Program
The make file provid e d to you builds both the game and a text-mode-restoration program called tr. The latter progr a m
is provided to help you with debugging. One difficulty involved with debugging code tha t makes use of the video
hardware is that the display may be left in an unusable (i.e., non-text-mode) state when the program crashes, hangs, or
hits a breakpoint. In order to force the display back in to text mode for debugging purposes (or, if yo u are not running
the program in a debugger, to regain control of your shell), you can run the tr program. Unless y ou are fairly confident
in your ability to type without visual feedback , we recommend that you keep a second v irtual console (CTRL-ALT-F1
through F6) logged in with the command to execute the text restoration program pre-typed , allowing you to simply
switch into that console and press Enter. Using this program is substantially e asier than rebooting your machine to put
it back into text mode.
You should also look at the cleanup handlers provided by the assert mod ule (assert.h and assert.c). These
cleanup hand lers provide support for fatal exceptions, putting the ma chine back into a usable state when your program
crashes. However, there may be instances and problems not covered by the handlers, and GDB can stop the program
before the handlers are invoked, leaving the machine in an unusable state un til you restore text mode with tr.
Mode X and Graphic Images
Mode X is a 256-color graphics mode with 320x200 resolution. It was not supported by the standard graphics routines
that came with the original VGAs, but was supported by the VGA hardware itself, and was quickly adopted as the stan-
dard for video games at the time because of certain technical advantages over the do c umented 256-color mode (mode
13h, where the ‘h’ stands for hexadecimal). In pa rticular, mode X sup ports multiple video pages, allowing a program
to switch the display between two screens, drawing only to the screen not currently displayed, and thereby avoiding the
annoying flicker effects associated with showing a partially-drawn image. T his technique is called double-buffering.