ti/lcd: clear screen on init
LCD RAM persists between reboots, makingit necessary to clear it. ref #41
This commit is contained in:
parent
c896b77143
commit
bb2e528b65
@ -35,35 +35,32 @@ lcdInit:
|
|||||||
xor a
|
xor a
|
||||||
ld (LCD_CURROW), a
|
ld (LCD_CURROW), a
|
||||||
|
|
||||||
|
; Clear screen
|
||||||
|
call lcdClrScr
|
||||||
|
|
||||||
; Enable the LCD
|
; Enable the LCD
|
||||||
ld a, LCD_CMD_ENABLE
|
ld a, LCD_CMD_ENABLE
|
||||||
call lcdWait
|
call lcdCmd
|
||||||
out (LCD_PORT_CMD), a
|
|
||||||
|
|
||||||
; Hack to get LCD to work. According to WikiTI, we're to sure why TIOS
|
; Hack to get LCD to work. According to WikiTI, we're to sure why TIOS
|
||||||
; sends these, but it sends it, and it is required to make the LCD
|
; sends these, but it sends it, and it is required to make the LCD
|
||||||
; work. So...
|
; work. So...
|
||||||
ld a, 0x17
|
ld a, 0x17
|
||||||
call lcdWait
|
call lcdCmd
|
||||||
out (LCD_PORT_CMD), a
|
|
||||||
ld a, 0x0b
|
ld a, 0x0b
|
||||||
call lcdWait
|
call lcdCmd
|
||||||
out (LCD_PORT_CMD), a
|
|
||||||
|
|
||||||
; Set some usable contrast
|
; Set some usable contrast
|
||||||
ld a, LCD_CMD_CONTRAST+0x34
|
ld a, LCD_CMD_CONTRAST+0x34
|
||||||
call lcdWait
|
call lcdCmd
|
||||||
out (LCD_PORT_CMD), a
|
|
||||||
|
|
||||||
; Enable 6-bit mode.
|
; Enable 6-bit mode.
|
||||||
ld a, LCD_CMD_6BIT
|
ld a, LCD_CMD_6BIT
|
||||||
call lcdWait
|
call lcdCmd
|
||||||
out (LCD_PORT_CMD), a
|
|
||||||
|
|
||||||
; Enable X-increment mode
|
; Enable X-increment mode
|
||||||
ld a, LCD_CMD_XINC
|
ld a, LCD_CMD_XINC
|
||||||
call lcdWait
|
call lcdCmd
|
||||||
out (LCD_PORT_CMD), a
|
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -78,11 +75,23 @@ lcdWait:
|
|||||||
pop af
|
pop af
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; Send cmd A to LCD
|
||||||
|
lcdCmd:
|
||||||
|
out (LCD_PORT_CMD), a
|
||||||
|
jr lcdWait
|
||||||
|
|
||||||
|
; Send data A to LCD
|
||||||
|
lcdData:
|
||||||
|
out (LCD_PORT_DATA), a
|
||||||
|
jr lcdWait
|
||||||
|
|
||||||
; Turn LCD off
|
; Turn LCD off
|
||||||
lcdOff:
|
lcdOff:
|
||||||
|
push af
|
||||||
ld a, LCD_CMD_DISABLE
|
ld a, LCD_CMD_DISABLE
|
||||||
call lcdWait
|
call lcdCmd
|
||||||
out (LCD_PORT_CMD), a
|
out (LCD_PORT_CMD), a
|
||||||
|
pop af
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Set LCD's current column to A
|
; Set LCD's current column to A
|
||||||
@ -90,8 +99,7 @@ lcdSetCol:
|
|||||||
push af
|
push af
|
||||||
; The col index specified in A is compounded with LCD_CMD_COL
|
; The col index specified in A is compounded with LCD_CMD_COL
|
||||||
add a, LCD_CMD_COL
|
add a, LCD_CMD_COL
|
||||||
call lcdWait
|
call lcdCmd
|
||||||
out (LCD_PORT_CMD), a
|
|
||||||
pop af
|
pop af
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -100,8 +108,7 @@ lcdSetRow:
|
|||||||
push af
|
push af
|
||||||
; The col index specified in A is compounded with LCD_CMD_COL
|
; The col index specified in A is compounded with LCD_CMD_COL
|
||||||
add a, LCD_CMD_ROW
|
add a, LCD_CMD_ROW
|
||||||
call lcdWait
|
call lcdCmd
|
||||||
out (LCD_PORT_CMD), a
|
|
||||||
pop af
|
pop af
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -120,26 +127,22 @@ lcdSendGlyph:
|
|||||||
.loop:
|
.loop:
|
||||||
ld a, (hl)
|
ld a, (hl)
|
||||||
inc hl
|
inc hl
|
||||||
call lcdWait
|
call lcdData
|
||||||
out (LCD_PORT_DATA), a
|
|
||||||
djnz .loop
|
djnz .loop
|
||||||
|
|
||||||
; Now that we've sent our 7 rows of pixels, let's go in "Y-increment"
|
; Now that we've sent our 7 rows of pixels, let's go in "Y-increment"
|
||||||
; mode to let the LCD increase by one column after we've sent our 8th
|
; mode to let the LCD increase by one column after we've sent our 8th
|
||||||
; line, which is blank (padding).
|
; line, which is blank (padding).
|
||||||
ld a, LCD_CMD_YINC
|
ld a, LCD_CMD_YINC
|
||||||
call lcdWait
|
call lcdCmd
|
||||||
out (LCD_PORT_CMD), a
|
|
||||||
|
|
||||||
; send blank line
|
; send blank line
|
||||||
xor a
|
xor a
|
||||||
call lcdWait
|
call lcdData
|
||||||
out (LCD_PORT_DATA), a
|
|
||||||
|
|
||||||
; go back in X-increment mode
|
; go back in X-increment mode
|
||||||
ld a, LCD_CMD_XINC
|
ld a, LCD_CMD_XINC
|
||||||
call lcdWait
|
call lcdCmd
|
||||||
out (LCD_PORT_CMD), a
|
|
||||||
|
|
||||||
pop hl
|
pop hl
|
||||||
pop bc
|
pop bc
|
||||||
@ -157,6 +160,49 @@ lcdLinefeed:
|
|||||||
pop af
|
pop af
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; Clears B rows starting at row A
|
||||||
|
; The LCD will then be set back at row A, column 0
|
||||||
|
; B is not preserved by this routine
|
||||||
|
lcdClrX:
|
||||||
|
push af
|
||||||
|
call lcdSetRow
|
||||||
|
ld a, LCD_CMD_8BIT
|
||||||
|
call lcdCmd
|
||||||
|
.outer:
|
||||||
|
push bc ; --> lvl 1
|
||||||
|
ld b, 11
|
||||||
|
ld a, LCD_CMD_YINC
|
||||||
|
call lcdCmd
|
||||||
|
xor a
|
||||||
|
call lcdSetCol
|
||||||
|
.inner:
|
||||||
|
call lcdData
|
||||||
|
djnz .inner
|
||||||
|
ld a, LCD_CMD_XINC
|
||||||
|
call lcdCmd
|
||||||
|
xor a
|
||||||
|
call lcdData
|
||||||
|
pop bc ; <-- lvl 1
|
||||||
|
djnz .outer
|
||||||
|
ld a, LCD_CMD_6BIT
|
||||||
|
call lcdCmd
|
||||||
|
pop af
|
||||||
|
ret
|
||||||
|
|
||||||
|
lcdClrLn:
|
||||||
|
push bc
|
||||||
|
ld b, FNT_HEIGHT+1
|
||||||
|
call lcdClrX
|
||||||
|
pop bc
|
||||||
|
ret
|
||||||
|
|
||||||
|
lcdClrScr:
|
||||||
|
push bc
|
||||||
|
ld b, 64
|
||||||
|
call lcdClrX
|
||||||
|
pop bc
|
||||||
|
ret
|
||||||
|
|
||||||
lcdPutC:
|
lcdPutC:
|
||||||
cp ASCII_LF
|
cp ASCII_LF
|
||||||
jp z, lcdLinefeed
|
jp z, lcdLinefeed
|
||||||
|
Loading…
Reference in New Issue
Block a user