Optimize scrolling

Move entire screen, starting from the second line, one line up
This commit is contained in:
Кирилл Алдашкин 2022-07-06 21:29:15 +08:00 committed by GitHub
parent 7aff64740e
commit eae470221b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,11 +83,9 @@ int print_char(char c, int col, int row, char attr) {
/* Check if the offset is over screen size and scroll */
if (offset >= MAX_ROWS * MAX_COLS * 2) {
int i;
for (i = 1; i < MAX_ROWS; i++)
memory_copy(get_offset(0, i) + VIDEO_ADDRESS,
get_offset(0, i-1) + VIDEO_ADDRESS,
MAX_COLS * 2);
memory_copy(get_offset(0, 1) + VIDEO_ADDRESS,
get_offset(0, 0) + VIDEO_ADDRESS,
MAX_COLS * (MAX_ROWS - 1) * 2);
/* Blank last line */
char *last_line = get_offset(0, MAX_ROWS-1) + VIDEO_ADDRESS;