From V5.04.09 MMBasic has the facility to add a display driver written entirely in BASIC.
Goto http://www.thebackshed.com/forum/forum_posts.asp?TID=10159&PN=1 for some
examples of drivers using this technique.

---------------------------------------------------------------------------------

A display driver written in BASIC comprises just three routines

1 Initialise the display

2 A subroutine to output a filled rectangle to the display (a single pixel is a very
  small rectangle).  The name of the sub must be MM.USER_RECTANGLE

3 A subroutine to output a rectangular bitmap to the display.
  The name of the sub must be MM.USER_BITMAP


In the initialisation code you need to setup the I/O to the display and execute
the following command:
    OPTION LCDPANEL USER, hres, vres
where hres and vres are the horiz and vert resolution of the display.
The initialisation code should be in the library or the first code in a program.

OPTION LCDPANEL USER will setup pointers to the two BASIC drawing functions.  The
following lists suitable prototypes for these functions:

  ' MM.USER_RECTANGLE - Draw a rectangle
  ' This routine outputs a rectangle to the display. The limiting case is a single
  ' pixel.  The calling sequence is defined and must be adhered to.  The parameters
  ' are the coordinates of the two extreme corners of the rectangle (note that the
  ' orientation can vary).
  sub MM.USER_RECTANGLE x1%, y1%, x2%, y2%, c%
    ' code to draw a rectangle starting at x1% y1% and ending at x2% y2%.
    ' the colour is c% (a 24 bit colour value)
  end sub


  ' MM.USER_BITMAP - Draw a bitmap on the screen
  ' The bitmap is supplied as a pointer to an area of memory so we need to use
  ' PEEK(BYTE bitmap% + x) to access the x'th byte in the bitmap.
  ' Each byte is a horizontal row of pixels starting with the most significant bit
  ' e.g. for an 8x8 bitmap (ie, width% = 8 and height% = 8)
  '    Byte0Bit7, Byte0Bit6, Byte0Bit5, Byte0Bit4, Byte0Bit3, Byte0Bit2, Byte0Bit1, Byte0Bit0
  '    Byte1Bit7, ........., ........., ........., ........., ........., ........., .........
  '    Byte2Bit7, ........., ........., ........., ........., ........., ........., .........
  '    Byte3Bit7, ........., ........., ........., ........., ........., ........., .........
  '    Byte4Bit7, ........., ........., ........., ........., ........., ........., .........
  '    Byte5Bit7, ........., ........., ........., ........., ........., ........., .........
  '    Byte6Bit7, ........., ........., ........., ........., ........., ........., .........
  '    Byte7Bit7, ........., ........., ........., ........., ........., ........., Byte7bit0
  ' width% might not be evenly divisable by eight and in that case the pixels should wrap
  ' around to the next row.
  sub MM.USER_BITMAP x1%, y1%, width%, height%, scale%, fc%, bc%, bitmap%
    ' code to draw a bitmap with the top left coordinate at x1% y1%.
    ' foreground colour is fc% and background bc% (both are 24 bit colour values)
  end sub

Note that the driver could be asked to draw pixels that lie outside the drawing area of the
screen (ie, their coordinates could be negative or greater than the height or width of the screen).
In that case the driver should ignore any such pixels.
