ti/lcd: add linefeed support

There's no scrolling yet...

ref #41
This commit is contained in:
Virgil Dupras 2019-11-07 20:52:09 -05:00
parent f4871d4d58
commit fda9c9826e
2 changed files with 30 additions and 4 deletions

View File

@ -2,6 +2,9 @@
; ;
; Implement PutC on TI-84+ (for now)'s LCD screen. ; Implement PutC on TI-84+ (for now)'s LCD screen.
; ;
; Note that "X-increment" and "Y-increment" work in the opposite way than what
; most people expect. Y moves left and right, X moves up and down.
;
; *** Requirements *** ; *** Requirements ***
; fnt/mgm ; fnt/mgm
; ;
@ -10,6 +13,7 @@
.equ LCD_PORT_DATA 0x11 .equ LCD_PORT_DATA 0x11
.equ LCD_CMD_6BIT 0x00 .equ LCD_CMD_6BIT 0x00
.equ LCD_CMD_8BIT 0x01
.equ LCD_CMD_DISABLE 0x02 .equ LCD_CMD_DISABLE 0x02
.equ LCD_CMD_ENABLE 0x03 .equ LCD_CMD_ENABLE 0x03
.equ LCD_CMD_XINC 0x05 .equ LCD_CMD_XINC 0x05
@ -18,6 +22,12 @@
.equ LCD_CMD_ROW 0x80 .equ LCD_CMD_ROW 0x80
.equ LCD_CMD_CONTRAST 0xc0 .equ LCD_CMD_CONTRAST 0xc0
; *** Variables ***
; Current row being written on. In terms of pixels, not of glyphs. During a
; linefeed, this increases by FNT_HEIGHT+1.
.equ LCD_CURROW LCD_RAMSTART
.equ LCD_RAMEND @+1
; *** Code *** ; *** Code ***
lcdInit: lcdInit:
; Enable the LCD ; Enable the LCD
@ -72,18 +82,22 @@ lcdOff:
; Set LCD's current column to A ; Set LCD's current column to A
lcdSetCol: lcdSetCol:
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 lcdWait
out (LCD_PORT_CMD), a out (LCD_PORT_CMD), a
pop af
ret ret
; Set LCD's current row to A ; Set LCD's current row to A
lcdSetRow: lcdSetRow:
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 lcdWait
out (LCD_PORT_CMD), a out (LCD_PORT_CMD), a
pop af
ret ret
; Send the 5x7 glyph that HL points to to the LCD, at its current position. ; Send the 5x7 glyph that HL points to to the LCD, at its current position.
@ -94,9 +108,7 @@ lcdSendGlyph:
push bc push bc
push hl push hl
; For the purpose of this program, we only write on the first line. ld a, (LCD_CURROW)
; We can assume that we always start at row 0.
xor a
call lcdSetRow call lcdSetRow
ld b, 7 ld b, 7
@ -129,7 +141,20 @@ lcdSendGlyph:
pop af pop af
ret ret
; Changes the current line and go back to leftmost column
lcdLinefeed:
push af
ld a, (LCD_CURROW)
add a, FNT_HEIGHT+1
ld (LCD_CURROW), a
xor a
call lcdSetCol
pop af
ret
lcdPutC: lcdPutC:
cp ASCII_LF
jp z, lcdLinefeed
push hl push hl
call fntGet call fntGet
jr nz, .end jr nz, .end

View File

@ -26,9 +26,10 @@
.equ FNT_WIDTH 5 .equ FNT_WIDTH 5
.equ FNT_HEIGHT 7 .equ FNT_HEIGHT 7
.inc "fnt/mgm.asm" .inc "fnt/mgm.asm"
.equ LCD_RAMSTART RAMSTART
.inc "ti/lcd.asm" .inc "ti/lcd.asm"
.inc "ti/kbd.asm" .inc "ti/kbd.asm"
.equ STDIO_RAMSTART RAMSTART .equ STDIO_RAMSTART LCD_RAMEND
.equ STDIO_GETC GetC .equ STDIO_GETC GetC
.equ STDIO_PUTC lcdPutC .equ STDIO_PUTC lcdPutC
.inc "stdio.asm" .inc "stdio.asm"