Page 1 of 1

Screen + Scrollen

Posted: Thu Sep 26, 2002 10:24 am
by Matze2002
Hi,
i try to write a small os. Now i write functions for the console. The Problem is the scroll-function. The os is protected mode. i have found a scroll function, but when i execute this function, my pc reboots, why ?

Thanks
Matze



Here is the function:

unsigned short crtc_adr = 0x3D4;
unsigned short offset = 80;

outportb(crtc_adr + 0, 12);
outportb(crtc_adr + 1, offset >> 8);
outportb(crtc_adr + 0, 13);
outportb(crtc_adr + 1, offset & 0xFF);

Re:Screen + Scrollen

Posted: Fri Sep 27, 2002 10:28 am
by Matze2002
Hi,
where can i find source code in c, to scroll the screen, or a full printf function for my os ?

Thanks, bye
Matze

Re:Screen + Scrollen

Posted: Fri Sep 27, 2002 12:32 pm
by frank
I've written a printf function (And a scroll function, I think)
see http://www.anemaet.nl/nitix/

Re:Screen + Scrollen

Posted: Sat Sep 28, 2002 3:02 am
by Matze2002
Hey,
i have found a scroll function. But this function works only 5 times (It scrolls 3-5 lines down) than the pc reboot. Why ?



Here is the function

Code: Select all

#define SYS_SCREEN_SEL  24
#define SYS_LINEAR_SEL  40

typedef struct  {
           char x, y, resx, resy, color;
      }SCREEN;

SCREEN screen = {0, 0, 80, 25, 7};

void movedata(unsigned ssel, unsigned s, unsigned dsel, unsigned d, unsigned len)
{
        asm(
        "pushw %%ds\n"
        "pushw %%ax\n"
        "popw  %%ds\n"
        "pushw %%es\n"
        "pushw %%bx\n"
        "popw  %%es\n"
        "moveloop: \n"
        "lodsb     \n"
        "stosb     \n"
        "loop moveloop\n"
        "popw   %%es\n"
        "popw   %%ds"
        ::"a" (ssel), "b" (dsel), "D" (d), "S" (s), "c" (len))
}


void scrollscreen()
{
        BYTE i;
        movedata(SYS_SCREEN_SEL, (unsigned
screen.resx*4, SYS_SCREEN_SEL, screen.resx*2, (screen.resy-2) * screen.resx * 2);

        for(i = 0; i < screen.resx; i++) 
   {
      putchar(i, screen.resy, ' ');
   }
        screen.y--;
        setCursor(screen.x, screen.y);                   
}