ti/lcd: wrap to next line when overflowing

This commit is contained in:
Virgil Dupras 2019-11-08 22:55:56 -05:00
parent bb2e528b65
commit 6c1b1f2b79

View File

@ -27,6 +27,8 @@
; Current row being written on. In terms of pixels, not of glyphs. During a ; Current row being written on. In terms of pixels, not of glyphs. During a
; linefeed, this increases by FNT_HEIGHT+1. ; linefeed, this increases by FNT_HEIGHT+1.
.equ LCD_CURROW LCD_RAMSTART .equ LCD_CURROW LCD_RAMSTART
; Current column
.equ LCD_CURCOL @+1
.equ LCD_RAMEND @+1 .equ LCD_RAMEND @+1
; *** Code *** ; *** Code ***
@ -34,6 +36,7 @@ lcdInit:
; Initialize variables ; Initialize variables
xor a xor a
ld (LCD_CURROW), a ld (LCD_CURROW), a
ld (LCD_CURCOL), a
; Clear screen ; Clear screen
call lcdClrScr call lcdClrScr
@ -122,28 +125,23 @@ lcdSendGlyph:
ld a, (LCD_CURROW) ld a, (LCD_CURROW)
call lcdSetRow call lcdSetRow
ld a, (LCD_CURCOL)
call lcdSetCol
ld b, 7 ; let's increase (and wrap) col now
inc a
ld (LCD_CURCOL), a
cp 16
jr nz, .skip
call lcdLinefeed
.skip:
ld b, FNT_HEIGHT
.loop: .loop:
ld a, (hl) ld a, (hl)
inc hl inc hl
call lcdData call lcdData
djnz .loop djnz .loop
; 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
; line, which is blank (padding).
ld a, LCD_CMD_YINC
call lcdCmd
; send blank line
xor a
call lcdData
; go back in X-increment mode
ld a, LCD_CMD_XINC
call lcdCmd
pop hl pop hl
pop bc pop bc
pop af pop af
@ -156,7 +154,7 @@ lcdLinefeed:
add a, FNT_HEIGHT+1 add a, FNT_HEIGHT+1
ld (LCD_CURROW), a ld (LCD_CURROW), a
xor a xor a
call lcdSetCol ld (LCD_CURCOL), a
pop af pop af
ret ret