From 476ba278dabeaf375c94847caacb2879bd4041b4 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Tue, 17 Jul 2012 16:22:21 +0200 Subject: [PATCH] Improved VGA scroll performance using memcpy(3). --- sortix/vgaterminal.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/sortix/vgaterminal.cpp b/sortix/vgaterminal.cpp index e0a4b969..7d791ff5 100644 --- a/sortix/vgaterminal.cpp +++ b/sortix/vgaterminal.cpp @@ -24,9 +24,12 @@ #include #include +#include #include "vga.h" #include "vgaterminal.h" +using namespace Maxsi; + namespace Sortix { namespace VGATerminal @@ -102,13 +105,11 @@ namespace Sortix { for ( nat y = 1; y < height; y++ ) { - for ( nat x = 0; x < width; x++ ) - { - unsigned oldindex = y * width + x; - unsigned newindex = (y-1) * width + x; - vga[newindex] = vga[oldindex]; - vgaattr[newindex] = vgaattr[oldindex]; - } + size_t linesize = width * sizeof(uint16_t); + size_t fromoff = (y-0) * width; + size_t destoff = (y-1) * width; + Memory::Copy(vga + destoff, vga + fromoff, linesize); + Memory::Copy(vgaattr + destoff, vgaattr + fromoff, linesize); } for ( nat x = 0; x < width; x++ ) @@ -124,13 +125,11 @@ namespace Sortix { for ( nat y = 1; y < height; y++ ) { - for ( nat x = 0; x < width; x++ ) - { - unsigned oldindex = (y-1) * width + x; - unsigned newindex = y * width + x; - vga[newindex] = vga[oldindex]; - vgaattr[newindex] = vgaattr[oldindex]; - } + size_t linesize = width * sizeof(uint16_t); + size_t fromoff = (y-1) * width; + size_t destoff = (y-0) * width; + Memory::Copy(vga + destoff, vga + fromoff, linesize); + Memory::Copy(vgaattr + destoff, vgaattr + fromoff, linesize); } for ( nat x = 0; x < width; x++ )