Help with bitwise operation (i think :P)
Posted: Thu Feb 14, 2008 3:56 pm
I have a function looking like this:
returns a byte (i.e 0x07).
I need some help understanding what this does:
I Have a variable containing both text and background color. How can i then modify this functio to use that variable?
Thanks in advance
Code: Select all
void scroll(size_t lines) {
if(!lines) return; /* nothing to scroll */
/* copy memory from "X position = top+lines" to top */
memcpy(video_mem,
video_mem+((SCREENCOLS*lines)<<1),
((SCREENROWS-lines)*SCREENCOLS)<<1);
/* Then zero the other lines below the copied lines, which
is the same amount as the number lines that we've scrolled. */
memsetw(video_mem+(((SCREENROWS-lines)
*SCREENCOLS)<<1), /* multiply by 2 */
((k_text_color_get() & 0x70)<<8) /* fill with bgcolor */,
((SCREENCOLS*lines)) /* amount of lines to copy */);
/* If we're not yet at the top of the screen,
* move the "Y position" up by X lines. */
if(screen_ypos >= lines) screen_ypos -= lines;
}
Code: Select all
k_text_color_get()
I need some help understanding what this does:
Code: Select all
((k_text_color_get() & 0x70)<<8)
Thanks in advance