Specifications
6
The next question is the size of the build buffer. If we can limit the size of the room photo, we can allocate a build
buffer large enough to hold any logical view window. If the window starts at pixel (0,0) in the room photo, plane 3 is
placed at the beginning of the build buffer. If the window occupies the lower right corner of the room photo, plane 0
is placed at the end of the build buffer. Such calculations are not particularly hard.
However, we do not want to restrict the size of the room photo, so we add a level of indirection and move the relative
offset of the logical view window within the build buffer as the logical view shifts within the room photo. The room
photo can thus be of almost arbitrary size, and is limited only by the size of the coordinate types (32-bit indices).
build buffer
copies a contiguous
region of memory for
simplicity
(show_x,show_y)
old img3 + address of
(scr_x,scr_y)
new img3 + address of
(scr_x,scr_y)
(show_x,show_y)
before copy
old logical
view window
new logical
view window
old logical
view window
new logical
view window
build buffer
after copy
The img3 and img3 off variables provide the additional level of indirection. At any point in time, adding the address
calculated from the logical view window coordinates (show x,show y) to the img3 pointer produces a pointer to the
start of plane 3 in the build buffer. However, the actual position of that plane in the build buffer may change over time.
Whenever a new logical view window setting is requested, the code checks whether all four planes of the new window
fall within the build buffer boundaries. If they do not, the window is repositioned within the build buffer in order to
make it fit. To minimize copying, the planes of the new window are centered within the build buffer. The figure at the
bottom of the previous page illustrates the process.
Finally, we add a memory fence to the build buffer to ensure that we didn’t screw up the copying calculations. Read
about it in the code.
A Few Preliminaries
Obtain a copy of the MP2 starting code. As with MP1, import an initial copy of the code from the class drive to
your SVN repository. We suggest that you check out your working copy under your ECE work directory this time:
when working with the Tux controller code, both of your virtual machines will need access to the files, and keeping
them on the work directory server means that you don’t have to copy them around as often.
Read the code and understand it. We will ask you questions about the code as part of the demo, and will also test
your conceptual understanding of the techniques used in the code during examinations. Don’t be shy about asking
questions on the web board, but do be careful so as not to give away MP answers. For example, it’s ok to ask and