What's with this ClearScreen() function?
Posted: Fri May 06, 2005 4:15 pm
My console function to clear the screen based on the desired attribute is for some reason, glitching up the screen with strange colors and symbols before finally crashing Bochs. I'm wondering why. I would attempt to extract information from an exception handler, but when I clear the screen they're not set up yet.
I don't see what's wrong with this, but I noticed that Bran's tutorial says
And I'm wondering if it has something to do with the rows not being arranged directly after one another. Sorry about so much code, but I'm not good at explaining programming issues without it.
Code: Select all
type
TAttrChar = packed record
chChar: Char;
btAttribute: Byte;
end;
PAttrChar = ^TAttrChar;
var
btAttribute: Byte;
procedure ClearScreen();
var
acChar: TAttrChar;
begin
acChar.chChar:= Char($20);
acChar.btAttribute:= btAttribute;
FillWord(pVideoMemory^,25*80,Word(acChar));
end;
Code: Select all
void cls()
{
unsigned blank;
int i;
/* Again, we need the 'short' that will be used to
* represent a space with color */
blank = 0x20 | (attrib << 8);
/* Sets the entire screen to spaces in our current
* color */
for(i = 0; i < 25; i++)
memsetw (textmemptr + i * 80, blank, 80);
/* Update out virtual cursor, and then move the
* hardware cursor */
csr_x = 0;
csr_y = 0;
move_csr();
}