Screen + Scrollen

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Matze2002

Screen + Scrollen

Post 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);
Matze2002

Re:Screen + Scrollen

Post 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
frank

Re:Screen + Scrollen

Post by frank »

I've written a printf function (And a scroll function, I think)
see http://www.anemaet.nl/nitix/
Matze2002

Re:Screen + Scrollen

Post 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);                   
}
Post Reply