-- As earlier promised...

-- New char routines for any graphics panel, to do bold and double
width& height text

-- ----------------------------------------------------------
var bit LCD_bold = false
var bit LCD_double = false
var bit LCD_ink = true
var byte LCD_lineSpace = 8
var byte LCD_charSpace = 6
-- ----------------------------------------------------------



procedure PlotChar(byte in x, byte in y, byte in ch ) is
var word indx = 0
var byte cx, colIdx
var bit ink
    if (ch > 31)& (ch < 127) then
        indx = indx + 5 * word(ch - 32)
        if LCD_double then
           for 5 loop
               cx = _font_5x7_table[indx]
               colIdx = 1
               for 8  loop
                   ink = ((cx & colIdx) > 0)
                   PlotPixel(x, y, ink)
                   PlotPixel(x+1, y, ink)
                   PlotPixel(x, y+1, ink)
                   PlotPixel(x+1, y+1, ink)
                   if colIdx < 128 then
                      colIdx = colIdx * 2
                   end if
                   y = y +2
               end loop
               y = y -16
               indx = indx + 1
               x = x + 2
           end loop
        else
            for 5 loop
                cx = _font_5x7_table[indx]
                if !LCD_ink then
                   cx = ! cx
                end if
                BlitColumn (x, y, cx)
                indx = indx + 1
                x = x + 1
            end loop
            if LCD_bold then
                indx = indx-5
                x = x -4
                for 5 loop
                    cx = _font_5x7_table[indx]
                    if !LCD_ink then
                       cx = ! cx
                    end if
                        -- plot in OR mode
                    PlotColumn(x, y, cx, on, false)
                    indx = indx + 1
                    x = x + 1
                end loop
            end if
        end if
    end if
end procedure




-- Revised "wrapping"
var byte glcd_char_x_pos = 0;
var byte glcd_char_y_pos = 0;


procedure lcd'put(byte in char) is
    PlotChar(glcd_char_x_pos, glcd_char_y_pos, char)
    if LCD_double then
       glcd_char_x_pos = glcd_char_x_pos + (LCD_charSpace *2)
    else
       glcd_char_x_pos = glcd_char_x_pos + LCD_charSpace
    end if
    if glcd_char_x_pos > 127 then
       glcd_char_x_pos = glcd_char_x_pos - 128
       glcd_char_y_pos = glcd_char_y_pos + LCD_lineSpace
       if  glcd_char_y_pos > 63 then
           glcd_char_y_pos = glcd_char_y_pos -64
       end if
    end if
end procedure


-- revised to be same order parameters as GotoXY
procedure  lcd_setcursor(byte in col, byte in row)  is
   glcd_char_x_pos = col * LCD_charSpace -- up to 21 cols
   if glcd_char_x_pos > 127 then
      glcd_char_x_pos = glcd_char_x_pos - 128
      row = row + 1
   end if
   glcd_char_y_pos = row * LCD_lineSpace -- up to 8 rows
   if glcd_char_y_pos > 63 Then
      glcd_char_y_pos = glcd_char_y_pos - 64
   end if
end procedure

************************
in the ks0108 library:
************************
-- use for sprites or fonts that are multiple of 8 high
procedure BlitColumn (byte in x, byte in y,  byte in column ) is
    _ks0108_inst() -- Set for instruction
    if (x > 128) then
       x = x -128
    end if
        if y > 191 then
         y = y -192
    elsif y > 127 then
         y = y - 128
    elsif y > 63 then
         y = y -64
    end if
    if (x < 64) then
        _ks0108_column(KS0108_LEFT,x) -- Set the horizontal address
        _ks0108_page(KS0108_LEFT, (y / 8)) -- Set the page address
        _ks0108_data() -- Set for data
        _ks0108_write(KS0108_LEFT, column) -- Write the pixel data
    else
        _ks0108_column(KS0108_RIGHT, x-64) -- Set the horizontal
address
        _ks0108_page(KS0108_RIGHT, (y / 8)) -- Set the page address
        _ks0108_data() -- Set for data
        _ks0108_write(KS0108_RIGHT, column) -- Write the pixel data
    end if
end procedure

-- use for more complex font/sprite
procedure PlotColumn(byte in x, byte in y, byte in column, bit in ink,
bit in replace) is
-- if ink is false, invert column data
-- if replace is true, plot 0 and 1 ink, else plot only only ink value
ink
var byte data
var byte side = KS0108_LEFT -- Stores which chip to use on the LCD
    if x > 127 then
       x = x -128
    end if
    if x > 63 then -- Check for first or second display area
        x = x - 64
        side = KS0108_RIGHT
    end if
    if y > 191 then
         y = y -192
    elsif y > 127 then
         y = y - 128
    elsif y > 63 then
         y = y -64
    end if
    if replace then
       if ink then
          data = column
       else
          data = ! column
        end if
    else
        _ks0108_inst() -- Set for instruction
        _ks0108_column(side,x) -- Set the horizontal address
        _ks0108_page(side,(y / 8)) -- Set the page address
        _ks0108_data() -- Set for data
        data = _ks0108_read(side) -- Need two reads to get data at new
address
        data = _ks0108_read(side) -- DO NOT REMOVE 2nd Read!
       if ink then
           data = data | column
       else
           data = data & (! column)
       end if
    end if
    _ks0108_inst() -- Set for instruction
    _ks0108_column(side,x) -- Set the horizontal address
    _ks0108_page(side,(y / 8)) -- Set the page address
    _ks0108_data() -- Set for data
    _ks0108_write(side, data) -- Write the pixel data
end procedure


-- I've added some "bounds" checking to libraries.. I hate the SVN,
esp. turtle. I must find a different SVN client that works better for
Windows.

Actually, I hate how CVS, SVN and the MS shared Studio stuff works.
It's all evil :-)


I'll try to get some SVN working, but my priority is my Catpad project
first.  It's eating up RAM and ROM. I hope I don't have to swap to the
ARM.

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to