video.c
sys/io.h
sys/video.h
ubixos/types.h
ubixos/spinlock.h
ubixos/tty.h
ubixos/spinlock.h
ubixos/types.h
sys/_types.h
sys/video.h
src/sys/sys/video.c
ubixos/tty.h
sys/io.h
void void backSpace () backSpace inportByte outportByte printColor tty_foreground tty_termNode::tty_x tty_termNode::tty_y videoBuffer keyboardHandler
void void clearScreen () clearScreen defaultColor outportByte videoBuffer x20 kmain
void void kprint (char *string) kprint char * string inportByte NULL outportByte printColor tty_find tty_foreground tty_print videoBuffer x20 fdcRw kmain kprintf
int int printColor printColor defaultColor backSpace kprint
unsigned char * unsigned char* videoBuffer videoBuffer (char *)0xB8000

    /*****************************************************************************************
    Copyright(c)2002-2005TheUbixOSProject
    Allrightsreserved.

    Redistributionanduseinsourceandbinaryforms,withorwithoutmodification,are
    permittedprovidedthatthefollowingconditionsaremet:

    Redistributionsofsourcecodemustretaintheabovecopyrightnotice,thislistof
    conditions,thefollowingdisclaimerandthelistofauthors.Redistributionsinbinary
    formmustreproducetheabovecopyrightnotice,thislistofconditions,thefollowing
    disclaimerandthelistofauthorsinthedocumentationand/orothermaterialsprovided
    withthedistribution.NeitherthenameoftheUbixOSProjectnorthenamesofits
    contributorsmaybeusedtoendorseorpromoteproductsderivedfromthissoftware
    withoutspecificpriorwrittenpermission.

    THISSOFTWAREISPROVIDEDBYTHECOPYRIGHTHOLDERSANDCONTRIBUTORS"ASIS"ANDANY
    EXPRESSORIMPLIEDWARRANTIES,INCLUDING,BUTNOTLIMITEDTO,THEIMPLIEDWARRANTIESOF
    MERCHANTABILITYANDFITNESSFORAPARTICULARPURPOSEAREDISCLAIMED.INNOEVENTSHALL
    THECOPYRIGHTOWNERORCONTRIBUTORSBELIABLEFORANYDIRECT,INDIRECT,INCIDENTAL,
    SPECIAL,EXEMPLARY,ORCONSEQUENTIALDAMAGES(INCLUDING,BUTNOTLIMITEDTO,PROCUREMENT
    OFSUBSTITUTEGOODSORSERVICES;LOSSOFUSE,DATA,ORPROFITS;ORBUSINESSINTERRUPTION)
    HOWEVERCAUSEDANDONANYTHEORYOFLIABILITY,WHETHERINCONTRACT,STRICTLIABILITY,OR
    TORT(INCLUDINGNEGLIGENCEOROTHERWISE)ARISINGINANYWAYOUTOFTHEUSEOFTHIS
    SOFTWARE,EVENIFADVISEDOFTHEPOSSIBILITYOFSUCHDAMAGE.

    $Id: video_8c.xml 88 2016-01-12 00:11:29Z reddawg $

    *****************************************************************************************/

    #include<sys/io.h>
    #include<sys/video.h>
    #include<ubixos/types.h>
    #include<ubixos/spinlock.h>
    #include<ubixos/tty.h>

    staticunsignedchar*videoBuffer=(char*)0xB8000;
    intprintColor=defaultColor;

    voidbackSpace(){
    uInt32bufferOffset=0x0;
    outportByte(0x3d4,0x0e);
    bufferOffset=inportByte(0x3d5);
    bufferOffset<<=0x8;/*ShiftAddressLeft8Bits*/
    outportByte(0x3d4,0x0f);
    bufferOffset+=inportByte(0x3d5);
    bufferOffset<<=0x1;/*ShiftAddressLeft1Bits*/
    videoBuffer[bufferOffset--]=0x20;
    videoBuffer[bufferOffset--]=printColor;
    videoBuffer[bufferOffset]=0x20;
    bufferOffset>>=0x1;
    tty_foreground->tty_x=(bufferOffset&0xFF);
    tty_foreground->tty_y=(bufferOffset>>0x8);
    outportByte(0x3D4,0x0f);
    outportByte(0x3D5,tty_foreground->tty_x);
    outportByte(0x3D4,0x0e);
    outportByte(0x3D5,tty_foreground->tty_y);
    return;
    }

    void
    kprint(char*string)
    {

    unsignedintbufferOffset=0x0,character=0x0,i=0x0;

    /*Shortcircuitifwe'reinttymode*/
    if(NULL!=tty_foreground)
    {
    tty_print(string,tty_find(0));
    return;
    }

    /*WeNeedToGetTheYPosition*/
    outportByte(0x3D4,0x0e);
    bufferOffset=inportByte(0x3D5);
    bufferOffset<<=8;/*ShiftAddressLeft8Bits*/
    /*ThenWeNeedToAddTheXPosition*/
    outportByte(0x3D4,0x0f);
    bufferOffset+=inportByte(0x3D5);
    bufferOffset<<=1;/*ShiftAddressLeft1Bits*/

    while((character=*string++)){
    switch(character){
    case'\n':
    bufferOffset=(bufferOffset/160)*160+160;
    break;
    default:
    videoBuffer[bufferOffset++]=character;
    videoBuffer[bufferOffset++]=printColor;
    break;
    }/*switch*/
    /*CheckToSeeIfWeAreOutOfBounds*/
    if(bufferOffset>=160*25){
    for(i=0;i<160*24;i++){
    videoBuffer[i]=videoBuffer[i+160];
    }/*for*/
    for(i=0;i<80;i++){
    videoBuffer[(160*24)+(i*2)]=0x20;
    videoBuffer[(160*24)+(i*2)+1]=printColor;
    }/*for*/
    bufferOffset-=160;
    }/*if*/
    }/*while*/
    bufferOffset>>=1;/*Setthenewcursorposition*/
    outportByte(0x3D4,0x0f);
    outportByte(0x3D5,((bufferOffset&0x0ff)&0xFF));
    outportByte(0x3D4,0x0e);
    outportByte(0x3D5,((bufferOffset>>8)&0xFF));

    return;
    }

    /*ClearsTheScreen*/
    voidclearScreen(){
    shorti=0x0;

    for(i=0x0;i<(80*25);i++){
    videoBuffer[i*2]=0x20;
    videoBuffer[i*2+1]=defaultColor;
    }
    outportByte(0x3D4,0x0f);
    outportByte(0x3D5,0);
    outportByte(0x3D4,0x0e);
    outportByte(0x3D5,0);
    }

    /***
    END
    ***/