#include #include #include #include #include #include #include /* change to 0xb000 for monochrome displays */ #define TEXT_OFFSET 0xb8000 #define TEXT_LENGTH (80 * 25 * 2) // = 4000 #define ATTR_OFF 0 /* All attributes off */ #define ATTR_BOLD 1 /* Bold On */ #define ATTR_DIM 2 /* Dim (Is this really in the ANSI standard? */ #define ATTR_UNDERLINE 4 /* Underline (Monochrome Display Only */ #define ATTR_BLINK 5 /* Blink On */ #define ATTR_REVERSE 7 /* Reverse Video On */ #define ATTR_INVISIBLE 8 /* Concealed On */ #define COLOR_BLACK 0 /* Black */ #define COLOR_RED 1 /* Red */ #define COLOR_GREEN 2 /* Green */ #define COLOR_YELLOW 3 /* Yellow */ #define COLOR_BLUE 4 /* Blue */ #define COLOR_MAGENTA 5 /* Magenta */ #define COLOR_CYAN 6 /* Cyan */ #define COLOR_WHITE 7 /* White */ static const char *device = "/dev/mem"; int main () { int i,fd; unsigned char *text,*s,*d; char buf[TEXT_LENGTH],tmp[TEXT_LENGTH]; /* * Map the text memory to something we can access */ if ((fd = open (device,O_RDWR | O_SYNC)) < 0) { perror ("open()"); exit (1); } text = mmap (NULL,TEXT_LENGTH,PROT_READ | PROT_WRITE,MAP_SHARED,fd,TEXT_OFFSET); if (text == MAP_FAILED) { perror ("mmap()"); exit (1); } /* * Do the tricks */ /* copy entire screen to temp buf */ memcpy (buf,text,TEXT_LENGTH); /* flip buf upside-down */ // memcpy (tmp,buf,TEXT_LENGTH); // for (i = 0, s = buf, d = tmp + TEXT_LENGTH - 80*2; i < 25/2; i++, s += 80*2, d -= 80*2) // memcpy (d,s,80*2); // memcpy (buf,tmp,TEXT_LENGTH); /* set color to bright cyan */ for (i = 1; i < TEXT_LENGTH; i += 2) buf[i] = /*COLOR_CYAN*/5; /* copy buf to screen */ memcpy (text,buf,TEXT_LENGTH); msync (text,TEXT_LENGTH,MS_SYNC); /* * Clean up and exit */ munmap (text,TEXT_LENGTH); close (fd); exit (0); }