Revision: 1798
Author: wattymage
Date: Mon Mar 15 10:55:47 2010
Log: initial alpha sample
http://code.google.com/p/jallib/source/detail?r=1798

Added:
 /trunk/catpad/graphics_mw.jal

=======================================
--- /dev/null
+++ /trunk/catpad/graphics_mw.jal       Mon Mar 15 10:55:47 2010
@@ -0,0 +1,774 @@
+-- Title: graphics_mw
+-- Author: Stef Mientki, Serkan Ayyýldýz Copyright (c) 2006..2009, all rights reserved.
+-- Adapted-by: Joep Suijs
+-- Added to by Michael Watterson
+-- Compiler: >=2.4
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the ZLIB license (http://www.opensource.org/licenses/zlib-license.html)
+--
+-- Sources:
+--
+-- Description: Generic routines for graphic mono display up to 128 x 128.
+-- glcd_box
+-- glcd_orth_ line
+-- --
+-- And mapping to char based lcd:
+-- lcd_put
+-- lcd_...
+--
+-- Notes:
+-- Added by Michael Watterson. All take ink so you can erase them
+-- to do:
+-- Arbitrary lines LCD_Line
+-- circle
+
+
+-- ----------------------------------------------------------
+var volatile bit LCD_bold = false
+var volatile bit LCD_state_double = false
+var volatile bit LCD_ink = true
+var volatile byte LCD_lineSpace = 8
+var volatile byte LCD_charSpace = 6
+-- ----------------------------------------------------------
+
+procedure LCD_double'put (bit in isWide) is
+    if LCD_state_double != isWide then
+        if isWide then
+            LCD_charSpace = LCD_charSpace *2
+            LCD_lineSpace = LCD_lineSpace *2
+        else
+            LCD_charSpace = LCD_charSpace /2
+            LCD_lineSpace = LCD_lineSpace /2
+        end if
+        LCD_state_double = isWide
+    end if
+end procedure
+
+function LCD_double'get ()return bit is
+    return LCD_state_double
+end function
+
+-- Only does 45 degrees, Hor or Vert
+procedure DrawOrthLine(byte in x0, byte in y0, byte in x1, byte in y1, bit in ink) is
+ var byte xi,yi , xfark,yfark, fark , xx
+
+   xi = x0
+   yi = y0
+   if x1 >= x0  then  xfark = x1 - x0 else  xfark = x0 - x1 end if
+   if y1 >= y0  then  yfark = y1 - y0 else  yfark = y0 - y1 end if
+
+   if xfark >= yfark then fark = xfark else fark = yfark end if
+   xx = 0
+   for fark loop
+      PlotPixel ( xi, yi ,ink)
+      if xx < xfark then
+          if x1 >= x0 then xi = xi + 1 else xi = xi - 1 end if
+      end if
+      if xx < yfark then
+          if y1 >= y0 then yi = yi + 1 else yi = yi - 1 end if
+      end if
+      xx = xx + 1
+   end loop
+end procedure
+
+-- ----------------------------------------------------------
+-- warning only for display up 0..127 in X or Y axis
+-- Change to swords for bigger display
+procedure DrawCircle(byte in cx, byte in cy ,byte in radius, bit in color) is
+var sbyte x, y, xchange, ychange, radiusError
+
+    x = sbyte(radius)
+    y = 0
+    xchange = 1 - 2 * sbyte(radius)
+    ychange = 1
+    radiusError = 0
+    while(x >= y) loop
+        PlotPixel(cx+x, cy+y, color)
+        PlotPixel(cx-x, cy+y, color)
+        PlotPixel(cx-x, cy-y, color)
+        PlotPixel(cx+x, cy-y, color)
+        PlotPixel(cx+y, cy+x, color)
+        PlotPixel(cx-y, cy+x, color)
+        PlotPixel(cx-y, cy-x, color)
+        PlotPixel(cx+y, cy-x, color)
+        y= y+1
+        radiusError = radiusError+ ychange
+        ychange = ychange + 2
+            if ( (2*radiusError + xchange) > 0 )  then
+               x = x-1
+                    radiusError = radiusError +xchange
+                    xchange = xchange + 2
+                End if
+    End Loop
+End procedure
+-- ----------------------------------------------------------
+procedure DrawOrthBox(byte in x0, byte in y0, byte in x1, byte in y1, bit in ink) is
+   DrawOrthLine ( x0,y0, x1,y0, ink )
+   DrawOrthLine ( x1,y0, x1,y1, ink )
+   DrawOrthLine ( x1,y1, x0,y1, ink )
+   DrawOrthLine ( x0,y1, x0,y0, ink )
+end procedure
+
+procedure DrawRectangle (byte in px , byte in py , byte in wx , byte in wy, bit in ink ) is
+var byte ind
+   wy = wy -1
+
+   For wx  using  ind loop
+       PlotPixel (ind+px, py, ink)
+       PlotPixel (ind+px, py + wy, ink)
+   end loop
+   wx = wx -1
+   For wy using ind loop
+        PlotPixel (px, ind +py , ink)
+        PlotPixel (px + wx, ind +py, ink)
+   end loop
+end procedure
+
+procedure DrawShadowBox(byte in px , byte in py , byte in wx , byte in wy, bit in ink ) is
+var byte ind
+   wy = wy -1
+    For wx using ind loop
+        PlotPixel ( ind+px, py, ink)
+        PlotPixel ( ind+px, py + wy, ink)
+        PlotPixel ( ind+px + 1, py + wy+1, ink)
+    end loop
+    wx = wx -1
+    For wy using ind loop
+        PlotPixel ( px, ind+py, ink)
+        PlotPixel ( px + wx, ind+py, ink)
+        PlotPixel ( px + wx+1, ind +py+1, ink)
+    end loop
+end procedure
+
+procedure DrawLine(byte in x0, byte in y0, byte in x1, byte in y1, bit in ink) is
+var bit steep, yinc
+var sword deltax, deltay, err
+var byte px, py
+    deltax = sword(x1)-sword(x0)
+    deltay = sword(y1)-sword(y0)
+    if (deltax < 0) then
+       deltax = -deltax
+    end if
+    if (deltay < 0) then
+       deltay = -deltay
+    end if
+    steep = (deltay > deltax)
+    if steep then   -- swap(x0,y0) swap(x1,y1)
+       px = x0
+       x0 = y0
+       y0 = px
+
+       px = x1
+       x1 = y1
+       y1 = px
+    end if
+    if (x0 > x1) then  -- swap(x0,x1) swap(y0,y1)
+       px = x0
+       x0 = x1
+       x1 = px
+
+       py = y0
+       y0 = y1
+       y1 = py
+    end if
+    deltax = sword(x1)-sword(x0)               -- we might have swapped
+    err = deltax / 2              -- assume the compiler does a shift
+    yinc =  (y1 > y0)
+    py = y0
+    deltay = sword(y1)-sword(y0)    -- we might have swapped
+     if (deltay < 0) then
+       deltay = -deltay
+    end if
+    for deltax using px loop
+       if steep then
+           PlotPixel (py, x0+px, ink)
+       else
+           PlotPixel (x0+px, py, ink)
+       end if
+       err = err - deltay
+       if (err < 0) then
+           if yinc then
+              py = py + 1
+           else
+              py = py -1
+           end if
+           err = err + deltax
+       end if
+    end loop
+end procedure
+
+
+procedure DrawYGraticule(byte in xLoc, byte in yOrg, byte in grid) is
+var byte plotIdx
+-- i.e.  6, 63, 8
+    For  yOrg using plotidx loop
+        PlotPixel( xLoc, plotIdx, True )
+        if ((plotidx % grid) == 0) then
+            PlotPixel( xLoc - 2, plotIdx, True)
+            PlotPixel( xLoc - 1, plotIdx, True)
+        end if
+    end loop
+end procedure
+
+procedure DrawXGraticule(byte in xOrg, byte in yLoc, byte in grid) is
+var byte plotIdx
+-- i.e.  50, 26, 5
+    For 127-xOrg using plotIdx loop
+            PlotPixel( xOrg + plotIdx, yLoc, True)
+            if ((plotidx % grid) == 0) then
+                 PlotPixel( xOrg + plotIdx, yLoc + 2, True)
+                PlotPixel( xOrg + plotIdx, yLoc + 1, True)
+            end if
+    end loop
+end procedure
+
+; 91 * 5 bytes = 455
+const byte _font_5x7_table[] = {
+0x00, 0x00, 0x00, 0x00, 0x00, ;; space, 32
+0x00, 0x00, 0x2f, 0x00, 0x00, ;; !, 33
+0x00, 0x07, 0x00, 0x07, 0x00, ;; ", 34
+0x14, 0x7f, 0x14, 0x7f, 0x14, ;; #, 35
+0x24, 0x2a, 0x7f, 0x2a, 0x12, ;; $, 36
+0xc4, 0xc8, 0x10, 0x26, 0x46, ;; %, 37
+0x36, 0x49, 0x55, 0x22, 0x50, ;; &, 38
+0x00, 0x05, 0x03, 0x00, 0x00, ;; ', 39
+0x00, 0x1c, 0x22, 0x41, 0x00, ;; (, 40
+0x00, 0x41, 0x22, 0x1c, 0x00, ;; ), 41
+0x14, 0x08, 0x3E, 0x08, 0x14, ;; *, 42
+0x08, 0x08, 0x3E, 0x08, 0x08, ;; +, 43
+0x00, 0x00, 0x50, 0x30, 0x00, ;; ,, 44
+0x10, 0x10, 0x10, 0x10, 0x10, ;; -, 45
+0x00, 0x60, 0x60, 0x00, 0x00, ;; ., 46
+0x20, 0x10, 0x08, 0x04, 0x02, ;; /, 47
+0x3E, 0x51, 0x49, 0x45, 0x3E, ;; 0, 48
+0x00, 0x42, 0x7F, 0x40, 0x00, ;; 1, 49
+0x42, 0x61, 0x51, 0x49, 0x46, ;; 2, 50
+0x21, 0x41, 0x45, 0x4B, 0x31, ;; 3, 51
+0x18, 0x14, 0x12, 0x7F, 0x10, ;; 4, 52
+0x27, 0x45, 0x45, 0x45, 0x39, ;; 5, 53
+0x3C, 0x4A, 0x49, 0x49, 0x30, ;; 6, 54
+0x01, 0x71, 0x09, 0x05, 0x03, ;; 7, 55
+0x36, 0x49, 0x49, 0x49, 0x36, ;; 8, 56
+0x06, 0x49, 0x49, 0x29, 0x1E, ;; 9, 57
+0x00, 0x36, 0x36, 0x00, 0x00, ;; :, 58
+0x00, 0x56, 0x36, 0x00, 0x00, ;; ;, 59
+0x08, 0x14, 0x22, 0x41, 0x00, ;; <, 60
+0x14, 0x14, 0x14, 0x14, 0x14, ;; =, 61
+0x00, 0x41, 0x22, 0x14, 0x08, ;; >, 62
+0x02, 0x01, 0x51, 0x09, 0x06, ;; ?, 63
+0x32, 0x49, 0x59, 0x51, 0x3E, ;; @, 64
+0x7E, 0x11, 0x11, 0x11, 0x7E, ;; A, 65
+0x7F, 0x49, 0x49, 0x49, 0x36, ;; B, 66
+0x3E, 0x41, 0x41, 0x41, 0x22, ;; C, 67
+0x7F, 0x41, 0x41, 0x22, 0x1C, ;; D, 68
+0x7F, 0x49, 0x49, 0x49, 0x41, ;; E, 69
+0x7F, 0x09, 0x09, 0x09, 0x01, ;; F, 70
+0x3E, 0x41, 0x49, 0x49, 0x7A, ;; G, 71
+0x7F, 0x08, 0x08, 0x08, 0x7F, ;; H, 72
+0x00, 0x41, 0x7F, 0x41, 0x00, ;; I, 73
+0x20, 0x40, 0x41, 0x3F, 0x01, ;; J, 74
+0x7F, 0x08, 0x14, 0x22, 0x41, ;; K, 75
+0x7F, 0x40, 0x40, 0x40, 0x40, ;; L, 76
+0x7F, 0x02, 0x0C, 0x02, 0x7F, ;; M, 77
+0x7F, 0x04, 0x08, 0x10, 0x7F, ;; N, 78
+0x3E, 0x41, 0x41, 0x41, 0x3E, ;; O, 79
+0x7F, 0x09, 0x09, 0x09, 0x06, ;; P, 80
+0x3E, 0x41, 0x51, 0x21, 0x5E, ;; Q, 81
+0x7F, 0x09, 0x19, 0x29, 0x46, ;; R, 82
+0x46, 0x49, 0x49, 0x49, 0x31, ;; S, 83
+0x01, 0x01, 0x7F, 0x01, 0x01, ;; T, 84
+0x3F, 0x40, 0x40, 0x40, 0x3F, ;; U, 85
+0x1F, 0x20, 0x40, 0x20, 0x1F, ;; V, 86
+0x3F, 0x40, 0x38, 0x40, 0x3F, ;; W, 87
+0x63, 0x14, 0x08, 0x14, 0x63, ;; X, 88
+0x07, 0x08, 0x70, 0x08, 0x07, ;; Y, 89
+0x61, 0x51, 0x49, 0x45, 0x43, ;; Z, 90
+0x00, 0x7F, 0x41, 0x41, 0x00, ;; [, 91
+0x55, 0x2A, 0x55, 0x2A, 0x55, ;; \, 92
+0x00, 0x41, 0x41, 0x7F, 0x00, ;; ], 93
+0x04, 0x02, 0x01, 0x02, 0x04, ;; ^, 94
+0x40, 0x40, 0x40, 0x40, 0x40, ;; _, 95
+0x00, 0x01, 0x02, 0x04, 0x00, ;; ', 96
+0x20, 0x54, 0x54, 0x54, 0x78, ;; a, 97
+0x7F, 0x48, 0x44, 0x44, 0x38, ;; b, 98
+0x38, 0x44, 0x44, 0x44, 0x20, ;; c, 99
+0x38, 0x44, 0x44, 0x48, 0x7F, ;; d, 100
+0x38, 0x54, 0x54, 0x54, 0x18, ;; e, 101
+0x08, 0x7E, 0x09, 0x01, 0x02, ;; f, 102
+0x0C, 0x52, 0x52, 0x52, 0x3E, ;; g, 103
+0x7F, 0x08, 0x04, 0x04, 0x78, ;; h, 104
+0x00, 0x44, 0x7D, 0x40, 0x00, ;; i, 105
+0x20, 0x40, 0x44, 0x3D, 0x00, ;; j, 106
+0x7F, 0x10, 0x28, 0x44, 0x00, ;; k, 107
+0x00, 0x41, 0x7F, 0x40, 0x00, ;; l, 108
+0x7C, 0x04, 0x18, 0x04, 0x78, ;; m, 109
+0x7C, 0x08, 0x04, 0x04, 0x78, ;; n, 110
+0x38, 0x44, 0x44, 0x44, 0x38, ;; o, 111
+0x7C, 0x14, 0x14, 0x14, 0x08, ;; p, 112
+0x08, 0x14, 0x14, 0x18, 0x7C, ;; q, 113
+0x7C, 0x08, 0x04, 0x04, 0x08, ;; r, 114
+0x48, 0x54, 0x54, 0x54, 0x20, ;; s, 115
+0x04, 0x3F, 0x44, 0x40, 0x20, ;; t, 116
+0x3C, 0x40, 0x40, 0x20, 0x7C, ;; u, 117
+0x1C, 0x20, 0x40, 0x20, 0x1C, ;; v, 118
+0x3C, 0x40, 0x30, 0x40, 0x3C, ;; w, 119
+0x44, 0x28, 0x10, 0x28, 0x44, ;; x, 120
+0x0C, 0x50, 0x50, 0x50, 0x3C, ;; y, 121
+0x44, 0x64, 0x54, 0x4C, 0x44, ;; z, 122
+0x08, 0x7F, 0x41, 0x41, 0x00, ;; {, 123
+0x00, 0x00, 0x7F, 0x00, 0x00, ;; |, 124
+0x00, 0x41, 0x41, 0x7F, 0x08, ;; }, 125
+0x10, 0x20, 0x10, 0x40, 0x10 ;; ~, 126
+
+
+}
+-- Writes a character to the display
+
+procedure PlotChar(byte in x, byte in y, byte in ch ) is
+var word indx = 0
+var byte cx, bitIdx
+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]
+               if ! LCD_ink then
+                  cx = !cx
+               end if
+               bitIdx = 1    -- index bits of font
+               for 8 loop
+                   ink = ((cx & bitIdx) > 0)
+                   PlotPixel(x, y, ink)
+                   PlotPixel(x+1, y, ink)
+                   PlotPixel(x, y+1, ink)
+                   PlotPixel(x+1, y+1, ink)
+                   if (bitIdx < 128) then
+                      bitIdx = bitIdx * 2
+                   end if
+                   y = y +2
+               end loop
+               y = y -16
+               indx = indx + 1
+               x = x + 2
+           end loop
+        elsif ((y % 8) == 0) then   -- only on 8 boundries
+            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 4 loop
+                    cx = _font_5x7_table[indx]
+                        -- plot in OR mode
+                    PlotColumn(x, y, cx, LCD_ink, false)
+                    indx = indx + 1
+                    x = x + 1
+                end loop
+                cx = _font_5x7_table[indx]
+                if !LCD_ink then
+                   cx = ! cx
+                end if
+                BlitColumn (x, y, cx)
+            end if
+ else -- not on 8 bit boundary, so BlitColumn and PlotColumn don't work!
+            for 5 loop
+               cx = _font_5x7_table[indx]
+               if ! LCD_ink then    -- black background, white text
+                  cx = !cx
+               end if
+               bitIdx = 1
+               for 8  loop
+                   ink = ((cx & bitIdx) > 0)
+                   PlotPixel(x, y, ink)
+                   if  LCD_bold then
+                       if (LCD_ink & ink) then
+                           PlotPixel(x+1, y, on)
+                       elsif ((!LCD_ink) & (!ink)) then
+                           PlotPixel(x+1, y, off)
+                       end if
+                   end if
+                   if (bitIdx < 128) then
+                        bitIdx = bitIdx * 2
+                   end if
+                   y = y +1
+               end loop    -- rows of font
+               y = y -8
+               indx = indx + 1
+               x = x+1
+            end loop   -- cols of font
+         end if    -- double or normal
+    end if      -- characters
+end procedure
+
+var byte glcd_char_x_pos = 0;
+var byte glcd_char_y_pos = 0;
+
+procedure DrawButton (byte in px , byte in py , byte in wx , byte in wy, byte in str[], bit in ink ) is
+var bit saveInk
+var byte cX, cY, chI
+    saveInk = LCD_ink
+    LCD_ink = ink
+    cY = py+2
+    cX = px+2
+    chI = 0
+    while (((cX +LCD_charSpace ) < (px + wx)) & (chI < count(str))) loop
+        PlotChar (cX,cY,str[chI])
+        chI = chI +1
+        if (LCD_double) then
+           cX = cX +(LCD_charSpace *2)
+        else
+           cX = cX + LCD_charSpace
+        end if
+    end loop
+    DrawShadowBox(px , py , wx , wy, ink )
+    LCD_ink = saveInk
+end procedure
+-- ----------------------------------------------------------
+-- Pseudo variable 'lcd' as alternative for lcd_writechar(<byte>)
+-- ----------------------------------------------------------
+
+
+-- Terminal stuff
+-- ------------------------------------------------------------
+-- Clear screen
+-- (and set the cursor to the upper left corner: row 0, column 0)
+-- ------------------------------------------------------------
+procedure  lcd_clearscreen() is
+   if LCD_ink then
+      lcd_fill(0)           -- Clear the display
+   else
+       lcd_fill (255)
+   end if
+   glcd_char_x_pos = 0;
+   glcd_char_y_pos = 0;
+   LCD_bold = false
+   LCD_state_double = false
+   LCD_ink = true
+   LCD_lineSpace = 8
+   LCD_charSpace = 6
+end procedure
+
+procedure LCD_clearEOL () is
+var byte col, fill
+     if LCD_ink then fill = 0 else fill = 255 end if
+     col = glcd_char_x_pos
+     while glcd_char_x_pos < 128 loop
+         BlitColumn (glcd_char_x_pos, glcd_char_y_pos,fill)
+         glcd_char_x_pos = glcd_char_x_pos +1
+     end loop
+     glcd_char_x_pos = col
+     if LCD_double then
+         col = glcd_char_x_pos
+         glcd_char_y_pos = glcd_char_y_pos+ 8
+         while glcd_char_x_pos < 128 loop
+             BlitColumn (glcd_char_x_pos, glcd_char_y_pos,fill)
+             glcd_char_x_pos = glcd_char_x_pos +1
+         end loop
+         glcd_char_y_pos = glcd_char_y_pos - 8
+         glcd_char_x_pos = col
+     end if
+end procedure
+
+-- ------------------------------------------------------------
+-- Set cursor position
+-- Specify row and column in base-0 notation (first line is 0).
+-- ------------------------------------------------------------
+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 = 0
+      glcd_char_y_pos = glcd_char_y_pos + LCD_lineSpace
+   end if
+   glcd_char_y_pos = row * LCD_lineSpace -- up to 8 rows
+   if glcd_char_y_pos > 63 Then
+      glcd_char_y_pos =  0
+   end if
+
+end procedure
+
+-- ----------------------------------------------------------------------------
+-- cursor returns home(line 1, position 1)
+-- ----------------------------------------------------------------------------
+procedure lcd_home()  is
+   glcd_char_y_pos = 0
+   glcd_char_x_pos = 0
+end procedure
+-- ----------------------------------------------------------------------------
+-- ******************
+-- DECIMAL      ATARI    IBM <----> ATARI     ASCII
+--    -HEX  NAME KEY    GRAPHICS CHARACTER    FUNCTION
+-- =======  ==== ===  ======================  ========
+--   0  00  NUL  ^,   none        heart       Null
+--   1  01  SOH  ^A   smiley      |-          Start of header
+--   2  02  STX  ^B   [smiley]    right |     Start of text
+--   3  03  ETX  ^C   heart       (9:00)      End of last text
+--   4  04  EOT  ^D   diamond     -|          End of transmission
+--   5  05  ENQ  ^E   club        (9:30)      Enquiry
+--   6  06  ACK  ^F   spade       /           Acknowledge (handshake)
+--   7  07  BEL  ^G   rain dot    \           Bell
+--   8  08  BS   ^H   doorbell    L triangle  Backspace
+--   9  09  HT   ^I   o           low-R-sq.   Horizontal tab
+--  10  0A  LF   ^J   [doorbell]  R triangle  Line feed
+--  11  0B  VT   ^K   Mars        hi-R-sq.    Vertical tab
+--  12  0C  FF   ^L   Venus       hi-L-sq.    Form feed
+--  13  0D  CR   ^M   note        high bar    Carriage return
+--  14  0E  SO   ^N   2 notes     low bar     Shift out
+--  15  0F  SI   ^O   sun         low-L-sq.   Shift in
+--  16  10  DLE  ^P   R pennant   club        Data link escape (break)
+--  17  11  DC1  ^Q   L pennant   (3:30)      Device #1 (P:)
+--  18  12  DC2  ^R   V arrows    --          Device #2
+--  19  13  DC3  ^S   !!          cross       Device #3 (deselects P:)
+--  20  14  DC4  ^T   paragraph   cloudy      Device #4 (stop)
+--  21  15  NAK  ^U   section     low block   Negative acknowl. (error)
+--  22  16  SYN  ^V   short -     left |      Synchronous idle
+--  23  17  ETB  ^W   base-V-arrs.low T       End of block
+--  24  18  CAN  ^X   up arrow    hi perp.    Cancel memory (in buffer)
+--  25  19  EM   ^Y   DN arrow    left half   End medium (tape drive)
+--  26  1A  SUB  ^Z   R arrow     (3:00)      Substitute
+--  27  1B  ESC  EE   L arrow     escape      Escape
+--  28  1C  FS   E^-  (3:00)      up arrow    File separator
+--  29  1D  GS   E^=  ice needles DN arrow    Group separator
+--  30  1E  RS   E^+  up triangle L arrow     Record separator
+--  31  1F  US   E^*  DN triangle R arrow     Unit separator
+--  32  20  SPC  bar  space       space       Space
+--
+-- Read more: http://www.faqs.org/faqs/atari-8-bit/faq/section-61.html#ixzz0dtsL4raA
+
+
+Const HE  = 1   -- home Goto 1,1
+--Const BL = 7    -- Bell
+Const BS = 8   -- Destructive backspace
+Const HT = 9    -- Hor Tab  Move next 4th column
+Const LF = 10  -- Next line same column, same as DN, down
+-- Const VT = 11  -- Vert Tab Move next even row
+Const CL = 12 -- Clear to End of Line
+Const CR = 13  -- Start of  line
+Const BD = 14  -- Bold = SO
+Const NL = 15 -- Normal = SI cancels Wide/double/bold
+Const WD = 23 -- ctrl W wide / double size
+Const IN = 26 -- subs invert ink
+Const UP = 28
+Const DN = 29 -- down
+Const LT = 30 -- left
+Const RT = 31 -- right
+Const DL = 127 -- DEL  destructive forward
+
+procedure lcd'put(byte in char) is
+        PlotChar(glcd_char_x_pos, glcd_char_y_pos, char)
+        glcd_char_x_pos = glcd_char_x_pos + LCD_charSpace
+        if glcd_char_x_pos > 127 then
+           glcd_char_x_pos = 0
+           glcd_char_y_pos = glcd_char_y_pos + LCD_lineSpace
+           if  glcd_char_y_pos > 63 then
+               glcd_char_y_pos = 0
+           end if
+        end if
+end procedure
+
+procedure TerminalChar (byte in char) is
+var byte col
+    if (char > 31)& (char != 127) then
+        PlotChar(glcd_char_x_pos, glcd_char_y_pos, char)
+        glcd_char_x_pos = glcd_char_x_pos + LCD_charSpace
+        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
+    else
+        case char of
+        HE : LCD_home()
+        BS : block
+              if glcd_char_x_pos >= LCD_charSpace then
+                 glcd_char_x_pos = glcd_char_x_pos- LCD_charSpace
+                 PlotChar(glcd_char_x_pos, glcd_char_y_pos, " ")
+                end if
+            end block
+        CR : glcd_char_x_pos = 0
+        LF : block
+               glcd_char_y_pos = glcd_char_y_pos + LCD_lineSpace
+               if  glcd_char_y_pos > 63 then
+                   glcd_char_y_pos =  0
+               end if
+             end block
+        DN : block
+               if  glcd_char_y_pos + LCD_lineSpace < 64 then
+                  glcd_char_y_pos = glcd_char_y_pos + LCD_lineSpace
+               end if
+           end block
+        UP : block
+               if  glcd_char_y_pos >  LCD_lineSpace then
+                   glcd_char_y_pos = glcd_char_y_pos - LCD_lineSpace
+               end if
+           end block
+        LT:  block
+              if glcd_char_x_pos >= LCD_charSpace then
+                  glcd_char_x_pos = glcd_char_x_pos- LCD_charSpace
+               end if
+            end block
+        RT:  block
+              if (glcd_char_x_pos + LCD_charSpace < 128) then
+                  glcd_char_x_pos = glcd_char_x_pos+ LCD_charSpace
+               end if
+            end block
+
+        HT : block
+              glcd_char_x_pos = glcd_char_x_pos + (4 * LCD_charSpace)
+              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
+               end if
+                -- up to 8 rows
+               if glcd_char_y_pos > 63 Then
+                  glcd_char_y_pos = glcd_char_y_pos - 64
+               end if
+             end block
+         CL: block
+             col = glcd_char_x_pos
+             while col < 127 loop
+                 PlotChar(col, glcd_char_y_pos, " ")
+                 col = col +1
+             end loop
+             end   block
+          NL: block
+              LCD_double = off
+              LCD_bold = off
+              LCD_ink = on
+              end block
+          WD: LCD_double = on
+          BD: LCD_bold = on
+          IN: LCD_ink = off
+          DL: block
+              if (glcd_char_x_pos + LCD_charSpace) < 128  then
+ PlotChar(glcd_char_x_pos + LCD_charSpace - LCD_charSpace, glcd_char_y_pos, " ")
+              end if
+              end block
+        end case
+    end if
+end procedure
+
+-- ----------------------------------------------------------
+-- Send byte to the LCD and automatically set the cursor one
+-- position right.
+-- There is now check on line overflow.
+-- ----------------------------------------------------------
+procedure  lcd_writechar(byte in c) is
+   lcd = c
+end procedure
+
+
+var byte Clock_X, Clock_Y, Clock_R
+var byte Clock_rm
+var sword Clock_xm, Clock_ym
+var byte Clock_rh
+var sword Clock_xh, Clock_yh
+var byte Clock_rs
+var sword Clock_xs, Clock_ys
+
+Procedure UpdateHands(byte in hours, byte in minutes, byte in seconds) is
+var sword handAngle
+    if hours > 12 then hours = hours -12 end if
+    hours = (hours * 15) + (minutes /4)
+    handangle = sword(hours)*2 - 90
+    PolarToCartesian (sword(Clock_rh), handangle,Clock_xh, Clock_yh )
+    handangle = sword(minutes)*6 - 90
+    PolarToCartesian (sword(Clock_rm), handangle,Clock_xm, Clock_ym )
+    handangle = sword(seconds)*6 - 90
+    PolarToCartesian (sword(Clock_rs), handangle,Clock_xs, Clock_ys )
+end procedure
+
+procedure DrawClockFace(byte in xOrg, byte in yOrg, byte in radius, bit in ink) is
+
+var  sword faceDots
+var sword xCoord, yCoord
+    lcd_fill(!ink)
+    Clock_X = xOrg
+    Clock_Y = yOrg
+    Clock_R = radius
+    Clock_rh = Clock_R / 2
+    Clock_rs = Clock_R - 2
+    Clock_rm = (Clock_rh+Clock_rs)/2
+    UpdateHands (16,42,0)
+    DrawRectangle (xOrg, yOrg, 2, 2, ink)    -- draw minutes dots
+    faceDots = 0
+    For 60 loop
+        PolarToCartesian (sword(Clock_R), faceDots,xCoord,yCoord )
+ PlotPixel (byte(sword(xOrg) + xCoord), byte(sword(yOrg) + yCoord), ink)
+        faceDots = faceDots + 6
+    end loop
+    -- draw hour squares
+    faceDots = 0
+    For 12 loop
+        PolarToCartesian (sword(Clock_R), faceDots,xCoord,yCoord )
+ DrawRectangle (byte(sword(xOrg) + xCoord), byte(sword(yOrg) + yCoord), 2, 2, ink)
+        faceDots = faceDots + 30
+    end loop
+End procedure
+
+procedure DrawHands(bit in ink) is
+ DrawLine (Clock_X, Clock_Y, byte(sword(Clock_X)+Clock_xh), byte(sword(Clock_Y)+Clock_yh), ink) + DrawLine (Clock_X, Clock_Y, byte(sword(Clock_X)+Clock_xm), byte(sword(Clock_Y)+Clock_ym), ink) + DrawLine (Clock_X, Clock_Y, byte(sword(Clock_X)+Clock_xs), byte(sword(Clock_Y)+Clock_ys), ink)
+End procedure
+-- -----------------------------------------------------------------------------
+--          Create a meter scale with 10 divisions
+--             40 to 140 degree scale
+--             width is automatically calculated as 2.5 times the height
+-- ----------------------------------------------------------------------------- +procedure DrawMeterFace(byte in xOrg, byte in yOrg, byte in height, bit in ink)is
+var  sword faceDots, scaleLen
+var sword xE, yE, xS, yS
+    scaleLen = (sword(height)*5) /4
+ DrawShadowBox (xOrg,yOrg,byte(scaleLen*2), height, ink) -- draw frame
+    faceDots = -140
+    For 101 loop
+        PolarToCartesian (scaleLen, faceDots,xE,yE )
+ PlotPixel (byte(sword(xOrg)+scaleLen + xE), byte(sword(yOrg) + yE+scaleLen+2), ink)
+        PolarToCartesian (scaleLen/2, faceDots,xE,yE )
+ PlotPixel (byte(sword(xOrg)+scaleLen + xE), byte(sword(yOrg) + yE+scaleLen+2), ink)
+        faceDots = faceDots + 1
+    end loop
+    -- draw hour squares
+    faceDots = -140
+    For 11 loop
+        PolarToCartesian (scaleLen+1, faceDots,xE,yE )
+        PolarToCartesian (scaleLen-3, faceDots,xS,yS )
+ Drawline (byte(sword(xOrg)+scaleLen +xS), byte(sword(yOrg)+scaleLen +2 +yS), + byte(sword(xOrg)+scaleLen+xE), byte(sword(yOrg)+scaleLen +2+yE), ink)
+        faceDots = faceDots + 10
+    end loop
+End procedure
+
+-- -----------------------------------------------------------------------------
+--          Add a needle to the meter scale
+--         0 to 101 input value, 100 is full scale
+-- draw with ink off and old value, then draw with ink on and new value
+--        invert ink if face was drawn inverted
+-- ----------------------------------------------------------------------------- +procedure DrawMeterNeedle(byte in xOrg, byte in yOrg, byte in height, byte in reading, bit in ink) is
+var sword radius
+var sword xE, yE, xS, yS
+    if reading > 101 then
+       reading = 101
+    end if
+    radius = (sword(height)*5) /4
+    PolarToCartesian (radius-4, sword(reading) -140,xE,yE )
+    PolarToCartesian (radius/2 +1, sword(reading) -140,xS,yS )
+ Drawline (byte(sword(xOrg)+radius +xS), byte(sword(yOrg)+radius +2 +yS), + byte(sword(xOrg)+radius+xE), byte(sword(yOrg)+radius +2+yE), ink)
+End procedure
+
+
+
+

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