Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task: using C++ language(program) 1)Draw a horizontal line centered on the screen.2)hold the line at that position for 250ms. 3)Erase the previous line.4)move the line

Task: using C++ language(program) 1)Draw a horizontal line centered on the screen.2)hold the line at that position for 250ms. 3)Erase the previous line.4)move the line vertically by an increment of "1"in the y-direction 5)when the screen boundary is detected reverse the direction of motion 6)Use the interval timer to generate the 250ms delay.

#include

/* these globals are written by interrupt service routines; we have to declare * these as volatile to avoid the compiler caching their values in registers */ extern volatile char byte1, byte2; /* modified by PS/2 interrupt service routine */ extern volatile int timeout; // used to synchronize with the timer

/*Color a pixel */ void drawpixel(int x_vga, int y_vga, short color) { volatile char *pixel_address = (volatile char*) (0x08000000 + (y_vga <<7) + (x_vga)); *pixel_address = color; }

/* For DE0-CV * * void drawpixel(int x_vga, int, y_vga, short color) { volatile short *pixel_address = (volatile short*)(0x08000000 + (y_vga<<10) + (x_vga<<1)); *pixel_address = color; } * */

/* Paint the screen BLACK * DE0 Limits x= 79, y=59 * DE0-CV x= 319, y=239 */

void clearscreen () { int x_vga, y_vga; for (x_vga = 0; x_vga <=79; x_vga = x_vga + 1) { for (y_vga = 0; y_vga <=59; y_vga = y_vga + 1) { drawpixel(x_vga, y_vga, 0x0); } } }

/* Draw a single character on the screen */

void drawcharacter(int x_char, int y_char, char mychar) { volatile char* character_buffer = (char *) (0x09000000 + (y_char <<7) + x_char); *character_buffer = mychar; }

int main() { char* fullstring = "Welcome to ELEC2850 !!!"; char* fullstring2 = "YES !!!"; clearscreen(); int x_max, y_max, x_start, y_start; /* Draw an orange horzontal line */ for (x_max = 0; x_max < 78; x_max = x_max + 1) { drawpixel(x_max, 50, 248); } /* Draw an red vertical line */ for (y_max = 0; y_max < 49; y_max = y_max + 1) { drawpixel(79, y_max, 224); } /* Write text to the monitor beginning at (col=x_start, row=y_start) fullstring */ x_start = 28; y_start = 5; while (*fullstring) { drawcharacter(x_start, y_start, *fullstring); x_start = x_start + 1; fullstring = fullstring + 1; } /* Write text to the monitor beginning at (col=x_start, row=y_start) fullstring2*/ x_start = 31; y_start = 10; while (*fullstring2) { drawcharacter(x_start, y_start, *fullstring2); x_start = x_start + 1; fullstring2 = fullstring2 + 1; } return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genetic Databases

Authors: Martin J. Bishop

1st Edition

0121016250, 978-0121016258

More Books

Students also viewed these Databases questions