| 
					
						 Hello
 it's OK..
 
 I found this code in C language (CCS COMPILER ) for ks0108 128x64 lcd. it is free.
 I posted it for newbie , it could somebody to help. I use it.
 Do you know it ?
 
 
 Code for PIC16f84-4/p 
 CCS COMPILER C
 
 #include <16F84.H>
 #use delay (clock=4000000)
 #use fast_io(A)
 #use fast_io(B)
 #fuses nowdt,xt
 
 
 struct ballstruct {
    int1 xvect;
    int1 yvect;
    int8 xloc;
    int8 yloc;
    int8 oldx;
    int8 oldy;
    int8 oldx1;
    int8 oldy1;
    } *currball,ball[3] = {3,23,70,23,7 0,23,70,
                           2,28,40,28,40,28,40,
                           1,50,30,50,30,50,30};
 
 char CONST msg1[4] = {0xc0,0x40,0xb8,0x3f};
 int8 mult;
 
 void write(char c) {
    output_b(c);                 //Put character on PORTB
    output_high(PIN_A3);         //Pulse LCD Enable line
    delay_cycles(1);
    output_low(PIN_A3);
 }
 
 void setxy(int8 x,int8 y) {     //x=vertical point (0-63) & y=horizontal point (0-127)
    if(bit_test(y,6)) {          //if y>63, then switch to controller on right side
       output_high(PIN_A0);
       output_low(PIN_A1);
    }
    else {                       //else use left side controller
       output_low(PIN_A0);
       output_high(PIN_A1);
    }
    output_low(PIN_A4);          //Switch to Instruction mode
    write(0xB8 | (x/8));         //Set memory bank to (x / 8)
    write(0x40 | (y&0x3F));      //Set column to (y & 0x3F)
    output_high(PIN_A4);         //Switch to Data mode (Don't forget the pullup resistor!)
 }
 
 #int_rtcc
 clock_isr() {
    int8 data,oldx,oldy,x;
 
    for(x=0;x<3;x++) {         //Process all 3 balls
       currball=&ball[x];      //Grab pointer to current ball
 
       if((currball->xloc==0) && (currball->xvect==0))           //Edge detection on x-axis
          currball->xvect = 1;
       else if((currball->xloc==62) && (currball->xvect==1))
          currball->xvect = 0;
 
       if((currball->yloc==0) && (currball->yvect==0))           //Edge detection on y-axis
          currball->yvect = 1;
       else if((currball->yloc==126) && (currball->yvect==1))
          currball->yvect = 0;
 
       if(currball->xvect==0)        //A value of 0 in vector will subtract 1 from the x-axis position
          currball->xloc--;
       else                      //A value of 1 in vector will add 1 to the x-axis position
          currball->xloc++;
 
       if(currball->yvect==0)        //ditto
          currball->yloc--;
       else
          currball->yloc++;
 
       if(mult==2) {         //Only update the screen every 3 interrupts
          oldx=currball->xloc; //Save old position so it can be erased later
          oldy=currball->yloc;
 
          setxy(currball->oldx1,currball->oldy1);        //Erase really old ball
          write(0);                                      //  (2 pictures of each ball are on the
          setxy(currball->oldx1,currball->oldy1+1);      //    screen at one time to minimize fading)
          write(0);
          setxy(currball->oldx1+1,currball->oldy1);
          write(0);
          setxy(currball->oldx1+1,currball->oldy1+1);
          write(0);
 
          currball->oldx1 = currball->oldx;            //Move old position to really old position
          currball->oldy1 = currball->oldy;
 
          data=0;
          bit_set(data,(currball->xloc % 8 ));            //Draw new ball
          if((currball->xloc % 8 )<7) {                   //  This is a brute-force method, but it works
             bit_set(data,(currball->xloc % 8 )+1);
             setxy(currball->xloc,currball->yloc);
             write(data);
             setxy(currball->xloc,currball->yloc+1);
             write(data);
          }
          else {
             setxy(currball->xloc,currball->yloc);
             write(data);
             setxy(currball->xloc,currball->yloc+1);
             write(data);
             setxy(currball->xloc+1,currball->yloc);
             write(1);
             setxy(currball->xloc+1,currball->yloc+1);
             write(1);
          }
          currball->oldx = oldx;               //Move current position to old position
          currball->oldy = oldy;
       }
    }
    if(mult==2) {            //If screen is updated, reset counter
       mult=0;
    }
    else {                       //Otherwise increment
       mult++;
    }
 }
 
 void init() {                   //Initialize LCD
    int8 x,y;
 
    output_a(0);                 //Setup everything as outputs
    output_b(0);
    set_tris_a(0);
    set_tris_b(0);
 
    output_high(PIN_A0);         //CS1 - high
    output_low(PIN_A1);          //CS2 - low
    output_low(PIN_A4);          //Instruction mode
    for(x=0;x<4;x++) {         //Send init chars
       write(msg1[x]);
    }
 
    output_low(PIN_A0);          //ditto, but for other controller
    output_high(PIN_A1);
    output_low(PIN_A4);
    for(x=0;x<4;x++) {
       write(msg1[x]);
    }
 
    output_high(PIN_A4);         //My LCD starts up with all ram locations = 0xFF
    output_high(PIN_A0);         //This clears the ram
    output_low(PIN_A1);
    for(x=0;x<8;x++) {
       for(y=0;y<64;y++) {
          output_low(PIN_A4);
          delay_cycles(1);
          write(0xB8 | x);
          write(0x40 | y);
          output_high(PIN_A4);
          delay_cycles(1);
          write(0);
       }
    }
    output_low(PIN_A0);          //Clear other side
    output_high(PIN_A1);
    for(x=0;x<8;x++) {
       for(y=0;y<64;y++) {
          output_low(PIN_A4);
          delay_cycles(1);
          write(0xB8 | x);
          write(0x40 | y);
          output_high(PIN_A4);
          delay_cycles(1);
          write(0);
       }
    }
 }
 
 void main() {
    int8 x;
 
    init();                      //Initialize LCD
 
 
    setup_counters(RTCC_INTERNAL,RTCC_DIV_64);   //Setup interrupts
 
    enable_interrupts(INT_RTCC);         //Start Interrupts
    enable_interrupts(GLOBAL);
 
 
 
    while(1);            //Twiddle thumbs forever...
                         //Probably user input code will go here
 
 
 
 
 }
 
 
 note:
 when I use write function for example:
 
 setxy(0,0);
  write (1) ; b'0000001'
 
 The PIC 'light on' two pixel and not one. I dont't know why.
 
 lcd screen 
 ____________________________________________
 |. pixel(0,0)                   pixel(0,64)   . (why?)
 |                                                
 |
 | 
					
  
						
					 |