Specifications
7
answer questions about memory fences or other code given to you, but it’s not ok to give code or pseudo-code for
writing a vertical line to the mode X build buffer (one of the tasks below).
We expect you to follow good software engineering practices in your code. Variables should almost never be
global. On the other hand, don’t go parameter-happy: file scope variables are fine. The code given to you has one
global variable, which contains the font data for restoring text mode and for drawing text as graphic images while in
graphics mode. Buffers passed to functions should either be fixed-size, or the available space should be passed and
checked. Everything should be clearly thought out and well-commented. Functions should have function headers.
Prototypes and variables should be organized, not scattered about the files. Indentation must be done correctly.
The Checkpoint
The order presented here is only a suggestion, but we do strongly recommend that you read the code first, that you
tackle the parts one at a time rather than working on them all at once, that you commit working versions to your
repository as you get each part working, and that you start with the easier parts. You must do all of these things for the
first checkpoint. Other parts of the final MP are optional at the first checkpoint, and will not serve to make up points
for missing required functionality.
Write the vertical line drawing routine in modex.c. Everything but the function body is already in place for you (even
the function header!), and you can look at the horizontal line drawing routine right next to it, so this part should be an
easy place to start. The main difficulty is for you to understand both how mode X maps pixels and how the abstractions
in modex.c work, so try to read the code and documentation to the point that you feel you understand these things,
then try to write the function with the help of the examples.
Find the VGA documentation for the status bar. Doing so was part of PS2, and you can work together and discuss how
it should be done, but not trade code to do it.
Add the status bar to the game. It should be big enough to allow you to write a line of text with an extra pixel above
and below. How big is that? Read the code. Defined constants have been cleverly included to reduce the amount of
work for you (see IMAGE versus SCROLL dimensions in the code), but you will have to shift a couple of bits of the
existing code around here and there because of VGA constraints.
Write a text to graphics image generation routine in text.c. Given a string, it should produce a buffer that holds a
graphical image of the ASCII characters in the string. The height of the buffer is fixed. You may either (a) figure out
how much text fits on the status bar and produce a buffer of fixed-size, or (b) return the resulting image width. In either
case, the text must be centered on the bar, in case (a) by this routine, and in case (b) by the next routine. Don’t forget
to put a prototype and explanation into text.h.
Write a routine to put a graphic image, and in particular, the output of routine described in the previous paragraph, on
to the status bar.
Use your routine to fill the status bar with text. Synchronize with the helper thread, then check for a non-empty status
message. If one exists, show it on the bar. Otherwise, put the room name and current typing on the bar. Arrange these
things as you see fit to make them attractive.
Be sure to look ahead at the rest of the assignment. You may want to get an early start.
VGA Palette Manipulations
The rest of the MP, which is also only due at the final due date, consists primarily of manipulating VGA palette colors
and making use of the event loop to control timing.
Find the VGA documentation for setting palette colors. As with the status bar, doing so was part of PS2. Write a
function that sets a palette color. Put the function in modex.c.
Notice the difference in color quality between the demo version of the adventure game and the distribution provided
to you. The version provided to you maps each photograph into 6-bit color, using only 64 of the 256 colors available
in mode X. The same 64 colors are used for objects and the status bar.