Hi,
In addition to the "memset does 8-bit bytes and not 16-bit words" problem, there's a bug with the moving - "memcpy()" is allowed to assume that the source and destination do not overlap, which allows it to use faster implementation with fewer checks. Because your source and destination areas do overlap you should be using "memmove()" instead.
Note that the easiest way to fix the "memset()" problem is to make the buffer 1 line larger and pre-fill the extra "never modified" last row once (e.g. when clearing the buffer during initialisation); then (when you "memmove()") you can copy the "never modified, always full of space" extra row into the last row.
Mostly, the whole thing could be:
Code:
void terminal_scroll(void) {
memmove(terminal_buffer, terminal_buffer + 80*2, 80*25*2);
}
darvark wrote:
But terminal shows only first 25 lines, and doesn't scroll. Iny ideas what I'm doing wrong?
You'd also need to copy the buffer to video display memory so that the changes are visible. Typically this happens later (e.g. you try to add some character/s but you're at the bottom of the screen; so you scroll, then add the character/s, then copy from the buffer to the video card's display memory).
Cheers,
Brendan