home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / MoreHardware / GluemachineHC.lha / Sources / LCDLib / LCDLib.s next >
Encoding:
Text File  |  1995-07-08  |  2.7 KB  |  191 lines

  1. **************************************************************
  2. *                           \|/                              *
  3. *                           @ @                              *
  4. *-----------------------ooO-(_)-Ooo--------------------------*
  5. *                                                            *
  6. *                    LCD-display library.                    *
  7. *                        Gluemaster                          *
  8. *                          950708                            *
  9. *                                                            *
  10. *------------------------------------------------------------*
  11. *                                                            *
  12. *                                                            *
  13. **************************************************************
  14.     PROCESSOR 68HC11
  15.  
  16.     XDEF PutStr
  17.     XDEF InitLCD
  18.     XDEF CGInit
  19.  
  20.     include "ADEV11:include/hc11reg.i"
  21.     include "ADEV11:include/LCD.i"
  22.  
  23.     RSEG CODE
  24.  
  25. DELAY01MS    EQU    17
  26.  
  27. RW    EQU $10
  28. RS    EQU $20
  29. EN    EQU $40
  30. NEN    EQU $bf
  31.  
  32. ;Delay for X*0.1 ms
  33. Delay:
  34.     pshy
  35. eloop:
  36.     ldy #0
  37. iloop:
  38.     iny
  39.     cpy #DELAY01MS
  40.     bne iloop
  41.     dex
  42.     bne eloop
  43.     puly
  44.     rts
  45.  
  46.  
  47. WrCmdNib:
  48.     pshx
  49.     anda #$0f
  50.     staa REGBASE+PORTB
  51.     ldx #2
  52.     jsr Delay
  53.     oraa #EN
  54.     staa REGBASE+PORTB
  55.     ldx #2
  56.     jsr Delay
  57.     anda #NEN
  58.     staa REGBASE+PORTB
  59.     ldx #2
  60.     jsr Delay
  61.     pulx
  62.     rts
  63.  
  64.  
  65. WrCmd:
  66.     psha
  67.     rora
  68.     rora
  69.     rora
  70.     rora
  71. ;    anda #$0f
  72.     jsr WrCmdNib
  73.     pula
  74.     jsr WrCmdNib
  75.     rts
  76.  
  77.  
  78. WrDataNib:
  79.     pshx
  80.     anda #$0f
  81.     oraa #RS
  82.     staa REGBASE+PORTB
  83.     ldx #2
  84.     jsr Delay
  85.     oraa #EN
  86.     staa REGBASE+PORTB
  87.     ldx #2
  88.     jsr Delay
  89.     anda #NEN
  90.     staa REGBASE+PORTB
  91.     ldx #2
  92.     jsr Delay
  93.     pulx
  94.     rts
  95.  
  96.  
  97. WrData:
  98.     psha
  99.     rora
  100.     rora
  101.     rora
  102.     rora
  103. ;    anda #$0f
  104.     jsr WrDataNib
  105.     pula
  106.     jsr WrDataNib
  107.     rts
  108.  
  109.  
  110. ;a=address, x=datapointer, $ff terminates
  111. PutStr:
  112.     anda #$7f
  113.     oraa #$80
  114.     jsr WrCmd
  115.  
  116. LoopPutStr:
  117.     ldaa 0,x
  118.     cmpa #$ff
  119.     beq ExitPutStr
  120.     jsr WrData
  121.     inx
  122.     bra LoopPutStr
  123.  
  124. ExitPutStr:
  125.     ldaa #$02
  126.     jsr WrCmd
  127.  
  128.     rts
  129.  
  130.  
  131. ; Initialization sequence for a 4 bit mode LCD
  132. InitLCD:
  133.     ldx #100
  134.     jsr Delay
  135.     ldaa #$03
  136.     jsr WrCmdNib
  137.     ldx #50
  138.     jsr Delay
  139.     ldaa #$03
  140.     jsr WrCmdNib
  141.     ldx #10
  142.     jsr Delay
  143.     ldaa #$03
  144.     jsr WrCmdNib
  145.     ldx #10
  146.     jsr Delay
  147.     ldaa #$02
  148.     jsr WrCmdNib
  149.     ldx #10
  150.     jsr Delay
  151.  
  152.     ldaa #$28
  153.     jsr WrCmd
  154.  
  155.     ldaa #$08
  156.     jsr WrCmd
  157.     ldaa #$01
  158.     jsr WrCmd
  159.     ldaa #$06
  160.     jsr WrCmd
  161.  
  162.     ldaa #$0c
  163.     jsr WrCmd
  164.  
  165.     rts
  166.  
  167.  
  168. ;a=address, b=no. bytes, x=datapointer
  169. CGInit:
  170.     anda #$3f
  171.     oraa #$40
  172.     jsr WrCmd
  173. next:
  174.     ldaa 0,x
  175.     jsr WrData
  176.     inx
  177.     decb
  178.     bne next
  179.     ldaa #$80
  180.     jsr WrCmd
  181.     ldaa #$02
  182.     jsr WrCmd
  183.     rts
  184.  
  185. **************************************************************
  186. *                                                            *
  187. *-----------------------oooO---Oooo--------------------------*
  188. *                                                            *
  189. **************************************************************
  190.     END
  191.