Re: mouse cursor corrupts chars under syscons

From: Christoph Mallon <christoph.mallon_at_gmx.de>
Date: Thu, 08 Jan 2009 17:03:17 +0100
Alexander Best schrieb:
> the effect is hard to describe. when moving the cursor over chars you can see
> that the edges of certain chars flicker. try running the command below. the
> effect should be quite obvious. i'm using an old fashioned crt monitor. the
> effect might not be visible on tft displays.
> 
> i have absolutely no idea what's causing this. but here's a wild guess:
> 
> from the effect it looks like the mouse cursor is actually made up of a 32x32
> or 64x64 pixel square. this square contains the white cursor. apart from the
> cursor the rest of the square is transparent. it appears the code that
> calculates the actual pixel-colour-value between the transparent parts of the
> cursor-square and the cars on syscons has a bug in it.
> 
> however that's just a wild guess.

Ah! Now I understand what you mean. First I did not see the effect, 
because I use 80x50 instead of 80x25 and a different font is used there.
You see the right border of the "0" flickering when you move the mouse 
cursor, right?

The effect is caused by how video hardware works in textmode and how the 
mouse cursor magic works.

First video hardware in textmode: You see 80x25 chars. The resolution is 
720x400 pixels. So every char consists 9x16 pixels. To display a char 
the video card uses a map with a bitmap for every char. But the bitmap 
of every char consists only of 16 bytes. So we are missing one bit per 
line. So there is another trick: Either the 9th column is displayed 
black (or whatever the background colour is) *or* the 8th column is 
repeated. What actually happens depends on two registers in the video 
card, which represent a range. You can set them so that char 213 till 
234 (just random example) have their 8th column repeated to the 9th and 
all others have a black 9th column. Usually "0" is outside of this 
range, so the 9th column is black.

Now how does the mouse cursor magic work: The mouse cursors consists of 
2x2 chars. The bitmap for these 4 chars are altered and the codes for 
the 4 chars are copied to the place where the mouse cursor should 
appear. Remember: We are in text mode, so you cannot just paint pixels. 
Everything has to go through the character map.
So to make the mouse cursor appear following happens:
First the pixel coordinates of the cursor are mapped to the character 
coordinates. Then the 4 chars there are read and the character maps are 
copied to the 4 reserved chars. Then the mouse cursor is painted onto 
these 4 reserved chars. Last the 4 reserved character codes are copied 
to the screen, so you see the mouse cursor appear. So when you move your 
mouse onto a "0" you no longer see a "real" 0, but you see another 
character with the same charmap but the mouse cursor painted on it.
Now the 9th column trick: The cursor would have a gap when it is outside 
the repeat-8th-column range. So the reserved characters are chosen to be 
in this range, the 8th column is copied and the mouse cursor appears 
continuous. This is also the reason why the mouse cursor has a "jumping" 
step when you move it around, just look closely. It is exactly at the 
right edge of a character.
So the 8th column gets copied, but a "0" (and other chars, too) have 
pixel data in there, which also gets copied and this causes the effect 
you observe.

Long story short: Everything is correct. (:

Bonus: You can see the mouse cursor magic at work if you move the 
reserved character range:
Write ABCD on the terminal: echo AB; echo CD
Then execute "vidcontrol -M 65".
65 is ASCII A, you can only specify the start of the range.
Now you see how the magic works in the four letters ABCD you wrote 
before. You'll also notice, that the mouse cursor now has a gap, because 
65-68 are outside of the repeat-8th-column range. When you now move the 
mouse over "0" you no longer see the effect you described for the same 
reason.
Use "vidcontrol -M 208" to reset to default.


I hope this explanation is helpful for you

	Christoph
Received on Thu Jan 08 2009 - 15:03:21 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:40 UTC