ref: 358eb31bb6e86f153a8a9261256a99ead7f1a08e
parent: 98a4d15507d812192519ab53fa552927eb2311eb
author: joe9 <joe9mail@gmail.com>
date: Tue Jul 13 06:22:58 EDT 2021
cga cursor move bug in vmx vmx is moving the cursor by 2 characters for each character pressed vmx debug prints show the position moved by 1 0x3d4 val 14 0x3d5 val 7 0x3d4 val 15 0x3d5 val 132 0x3d4 val 14 0x3d5 val 7 0x3d4 val 15 0x3d5 val 133 0x3d4 val 14 0x3d5 val 7 0x3d4 val 15 0x3d5 val 134 but the display is moving by 2. Also, cgascreenputc is only used by cgascreenputs. Hence, doing the movetocursor() after the string is printed
--- a/os/pc/cga.c
+++ b/os/pc/cga.c
@@ -31,7 +31,7 @@
*/
};
-#define CGASCREENBASE ((uchar*)KADDR(0xB8000))
+#define CGASCREENBASE ((uchar*)0xB8000)
static int cgapos;
static Lock cgascreenlock;
@@ -50,11 +50,6 @@
outb(0x3D4+1, data);
}
-/* TODO BUG the cursor is 2 characters beyond
- * could use pos = cgapos -2
- * but skips a character when 'd' is pressed
- * is it a bug in the shell prompt?
- */
static void
movecursor(void)
{
@@ -97,12 +92,14 @@
}
cgapos = Width*(Height-1);
}
- movecursor();
}
static void
cgascreenputs(char* s, int n)
{
+ int i,j;
+ /*char pre[512] = "";*/
+
if(!islo()){
/*
* Don't deadlock trying to
@@ -114,6 +111,10 @@
else
lock(&cgascreenlock);
+ /*j = snprint(pre,512,"-%d %d-",n, cgapos);
+ for(i=0;i<j&&i<512;i++){
+ outb(0x3D6, pre[i]);
+ }*/
while(n-- > 0){
outb(0x3D6, *s);
// outb(0x3D6, '-');
@@ -120,6 +121,7 @@
cgascreenputc(*s++);
// outb(0x3D6, '_');
}
+ movecursor();
unlock(&cgascreenlock);
// outb(0x3D6, ',');