Question: Program Specification The program must start at address x 3 0 0 0 . The program will start by copying a picture of a cow

Program Specification
The program must start at address x3000.
The program will start by copying a picture of a cow from location x5000 into the center of the screen.
The image of the cow is a rectangle 30 pixels wide by 25 pixels high. This cow image is provided to you
as a separate cow.obj file to be loaded into Pennsim. This cow image data is stored in row order. For
example, the first row of 30 pixels is stored at x5000-x501D, the second row is stored at x501E-503B,
and so on.
2
The user will then draw 10-20 blades of grass colored green on the sides of the cow. These blades of
grass should be 2 pixels wide, start at the same pixel row as the bottom of the initial cow image, and be
as tall as the cow image. These grass blades do not move with the cow moves or tips. The grass is not
redrawn when it is stomped by the cow.
The PennSim graphics display (the screen) is 128 by 124 pixels. We use an (x, y) coordinate system
to describe a location on the screen. Location (0,0) is the top left corner. The x coordinate increases as
we move to the right, and the y coordinate increases as we move down. In other words, (1,0) is one
pixel to the right of (0,0), and location (0,1) is one pixel below (0,0). Location (127,123) is the
bottom right corner of the screen.
The user interacts with the program using one-character commands. The commands are typed on the
keyboard, but are not echoed to the console display. Nothing will be printed to the console during the
execution of this program. The program will wait for a key press, perform the corresponding command,
and repeat. If the keystroke does not correspond to a legal command, it will have no effect.
There are four commands for changing the location of the Pen. We use the WASD scheme of
navigation, used by various computer games. 3
Details
The PennSim graphics display is bit-mapped, meaning that each pixel has a corresponding memory
location. The content of that memory location controls the color of the pixel.
Pixel Addresses
Addresses xC000 through xFDFF are assigned to the graphics display. The low address corresponds to
the top left corner (0,0). Moving one pixel to the right adds one to the address, and it wraps around to
the next row when it gets to the right edge. Since the display is 128 pixels wide, this means that moving
down one pixel is equivalent to adding 128 to the address.
The address of point (x, y) can be calculated as: xC000+ x +128y.
For this assignment, you will not need to calculate arbitrary pixel addresses, except to figure out where
the initial location is. You will be moving left (-4), right (+4), up (-512) or down (+512) from the
current address.
You will, however, need to recognize when the Cow is at an edge of the display, so that you dont go
beyond the edge.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!