repo: https://github.com/microNET-OS/microCORE
One of the bugs I had to fix was a completely broken terminal. I mean, it could output text and in color, but it couldn't scroll. I fixed this issue by implementing an array shift to shift the buffer's array 80 characters to the left (out of the array). This does work, however it is slow. The function is as follows:
from Terminal.cpp
Code: Select all
void Terminal::shift()
{
for (int i = 0; i < 80; i++)
{
buffer[i] = vga_entry(0, 0);
}
/* DO() is a macro for a `for` loop */
DO(VGA_WIDTH) // shift VGA_WIDTH (80) times
{
for (int i = 0; i < (VGA_HEIGHT * VGA_WIDTH); i++) {
buffer[i] = buffer[i + 1]; // shift vga buffer to the left
}
}
if (staticLogo)
{
for (int i = 0; i < (VGA_WIDTH * 15); i++)
{
buffer[i] = vga_entry(0, 0);
}
size_t rowtemp = row;
size_t coltemp = column;
setCursor(0, 0);
Terminal::instance() << logo;
setCursor(coltemp, rowtemp);
}
row--;
}
from new Terminal.cpp
Code: Select all
void Terminal::shift()
{
uint16_t *tbuffer = reinterpret_cast<uint16_t *>(0xe9500);
for (int i = 0; i < 80; i++)
{
tbuffer[i] = vga_entry(0, 0);
}
DO(VGA_WIDTH) // shift VGA_WIDTH (80) times
{
for (int i = 0; i < (VGA_HEIGHT * VGA_WIDTH); i++) {
tbuffer[i] = tbuffer[i + 1]; // shift vga buffer to the left
}
}
if (staticLogo)
{
for (int i = 0; i < (VGA_WIDTH * 15); i++)
{
tbuffer[i] = vga_entry(0, 0);
}
size_t rowtemp = row;
size_t coltemp = column;
setCursor(0, 0);
Terminal::instance() << logo;
setCursor(coltemp, rowtemp);
}
*buffer = *tbuffer;
row--;
}
I appreciate any help.