[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Normal mode patch
From: |
Gianluca Guida |
Subject: |
Re: Normal mode patch |
Date: |
Fri, 9 Jan 2004 10:50:53 +0100 |
User-agent: |
Mutt/1.4.1i |
On Wed, Jan 07, 2004 at 02:07:29PM +0100, Yoshinori K. Okuji wrote:
>
> On Wednesday 31 December 2003 18:24, Marco Gerards wrote:
> > gianluca (I don't remember his real name) told me on IRC that it
> > crashes whenever the console scrolls. I was able to reproduce this.
> > It is not clear what still needs to be done to get the graphics
> > console to work. If it is not a lot of work I can do that, I have
> > quite some experience with VGA programming.
>
> You are right. There is a big problem when scrolling the menu. Probably
> it is due to a wrong calculation of a memory pointer, but I'm not sure
> where it is. As you see, the code is a bit ugly, so it might be better
> to clean up the code more or less before diving into the problem
> seriously.
>
As Marco Gerards made me note, the problem in vga.c was due to a wrong
check to ypos value for scrolling (TEXT_HEIGHT instead of TEXT_HEIGHT-1).
After fixing this, however, I've experienced another problem: the
scrolling itself doesn't work. It clears the screen instead of moving
it. I am not at all a VGA expert, and as long as my brain works at late
night it seems that when using pupa_memmove the memory is read as
zero-valued.
I've then implemented a slow but simple and working function that
rebuilds completely the screen using textbuf info. I've called it
screen_update(). Under bochs runned on a Pentium MMX (;-)) it showed
slow, but on real hardware (Pentium III 600Mhz) its speed was acceptable.
I think that as long as what we want do is to scroll some hundreds of
characters, no one will complain too much about this rude patch.
Gianluca
? vga_patch
Index: vga.c
===================================================================
RCS file: /cvsroot/pupa/pupa/term/i386/pc/vga.c,v
retrieving revision 1.1
diff -u -p -r1.1 vga.c
--- vga.c 25 Sep 2003 20:15:52 -0000 1.1
+++ vga.c 9 Jan 2004 01:49:54 -0000
@@ -279,14 +279,34 @@ write_cursor (void)
}
static void
+screen_update (void)
+{
+ int oldxpos, oldypos;
+ int i,j;
+
+ oldxpos=xpos; oldypos=ypos;
+ for (j=0; j<TEXT_HEIGHT; j++)
+ {
+ ypos=j;
+
+ for(i=0; i<TEXT_WIDTH; i++)
+ {
+ xpos=i;
+ write_char();
+ }
+ }
+}
+
+static void
scroll_up (void)
{
unsigned i;
unsigned plane;
+
pupa_memmove (text_buf, text_buf + TEXT_WIDTH,
sizeof (struct colored_char) * TEXT_WIDTH * (TEXT_HEIGHT - 1));
-
+
for (i = TEXT_WIDTH * (TEXT_HEIGHT - 1); i < TEXT_WIDTH * TEXT_HEIGHT; i++)
{
text_buf[i].code = ' ';
@@ -296,16 +316,7 @@ scroll_up (void)
text_buf[i].index = 0;
}
- for (plane = 0x1; plane <= 0x8; plane <<= 1)
- {
- set_map_mask (plane);
- pupa_memmove (VGA_MEM, VGA_MEM + VGA_WIDTH * CHAR_HEIGHT / 8,
- VGA_WIDTH * (VGA_HEIGHT - CHAR_HEIGHT) / 8);
- }
-
- set_map_mask (0x0f);
- pupa_memset (VGA_MEM + VGA_WIDTH * (VGA_HEIGHT - CHAR_HEIGHT) / 8, 0,
- VGA_WIDTH * CHAR_HEIGHT / 8);
+ screen_update();
}
static void
@@ -331,7 +342,7 @@ pupa_vga_putchar (pupa_uint32_t c)
break;
case '\n':
- if (ypos >= TEXT_HEIGHT)
+ if (ypos >= TEXT_HEIGHT - 1)
scroll_up ();
else
ypos++;
@@ -381,7 +392,7 @@ pupa_vga_putchar (pupa_uint32_t c)
{
xpos = 0;
- if (ypos >= TEXT_HEIGHT)
+ if (ypos >= TEXT_HEIGHT - 1)
scroll_up ();
else
ypos++;
Re: Normal mode patch,
Gianluca Guida <=
Re: Normal mode patch, Gianluca Guida, 2004/01/09